Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • jw_sonar
  • jw_sonar_backup
  • main
  • move-to-esm-only
  • open_tool_for_self_hosting
  • v5.0
  • v4.1
  • v4.2
8 results

Target

Select target project
  • dojo_project/projects/shared/nodesharedcode
1 result
Select Git revision
  • jw_sonar
  • jw_sonar_backup
  • main
  • move-to-esm-only
  • open_tool_for_self_hosting
  • v5.0
  • v4.1
  • v4.2
8 results
Show changes
Commits on Source (6)
import Ajv, { ErrorObject, JTDSchemaType } from 'ajv/dist/jtd';
import fs from 'fs';
import JSON5 from 'json5';
import EnonceFile from '../../types/Dojo/EnonceFile';
class SharedEnonceHelper {
private validateDescriptionFileV1(resultsFilePathOrStr: string, isFile: boolean = true): { results: EnonceFile | undefined, isValid: boolean, errors: Array<ErrorObject | string> | null | undefined } {
const ajv = new Ajv();
const schema: JTDSchemaType<EnonceFile> = {
properties : {
dojoEnonceVersion: { type: 'uint32' },
version : { type: 'uint32' },
immutable: {
elements: {
properties: {
description: { type: 'string' },
path : { type: 'string' },
isDirectory: { type: 'boolean' }
}
}
},
result: {
properties: {
container: { type: 'string' },
volume : { type: 'string' }
}
}
},
additionalProperties: false
};
const validator = ajv.compile(schema);
try {
const results = JSON5.parse(isFile ? fs.readFileSync(resultsFilePathOrStr, 'utf8') : resultsFilePathOrStr);
const isValid = validator(results);
return {
results: isValid ? results : results as any,
isValid: isValid,
errors : validator.errors
};
} catch ( error ) {
return {
results: undefined,
isValid: false,
errors : [ `JSON5 invalid : ${ JSON.stringify(error) }` ]
};
}
}
validateDescriptionFile(resultsFilePathOrStr: string, isFile: boolean = true, version: number = 1): { results: EnonceFile | undefined, isValid: boolean, errors: Array<ErrorObject | string> | null | undefined } {
switch ( version ) {
case 1:
return this.validateDescriptionFileV1(resultsFilePathOrStr, isFile);
default:
return {
results: undefined,
isValid: false,
errors : [ `Version ${ version } not supported` ]
};
}
}
}
export default new SharedEnonceHelper();
\ No newline at end of file
import Ajv, { ErrorObject, JTDSchemaType } from 'ajv/dist/jtd';
import fs from 'fs';
import ExerciceResultsFile from '../types/Dojo/ExerciceResultsFile';
import ExerciceResultsFile from '../../types/Dojo/ExerciceResultsFile';
import JSON5 from 'json5';
class ExerciceHelper {
class SharedExerciceHelper {
validateResultFile(resultsFilePathOrStr: string, isFile: boolean = true): { results: ExerciceResultsFile | undefined, isValid: boolean, errors: Array<ErrorObject<string, Record<string, any>, unknown> | string> | null | undefined } {
const ajv = new Ajv();
......@@ -62,4 +62,4 @@ class ExerciceHelper {
}
export default new ExerciceHelper();
\ No newline at end of file
export default new SharedExerciceHelper();
\ No newline at end of file
enum ExerciceCheckerError {
EXERCICE_ENONCE_GET_ERROR = 200,
DOCKER_COMPOSE_RUN_ERROR = 201,
DOCKER_COMPOSE_LOGS_ERROR = 202,
DOCKER_COMPOSE_DOWN_ERROR = 203,
EXERCICE_RESULTS_FOLDER_TOO_BIG = 204,
EXERCICE_RESULTS_FILE_NOT_FOUND = 205,
EXERCICE_RESULTS_FILE_SCHEMA_NOT_VALID = 206,
UPLOAD = 207
}
export default ExerciceCheckerError;
\ No newline at end of file
enum GitlabRoutes {
enum GitlabRoute {
NOTIFICATION_SETTINGS = '/notification_settings',
USERS_GET = '/users',
REPOSITORY_GET = '/projects/{{id}}',
......@@ -14,4 +14,4 @@ enum GitlabRoutes {
}
export default GitlabRoutes;
\ No newline at end of file
export default GitlabRoute;
\ No newline at end of file