glossarist 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/src/gcr-writer.js
CHANGED
|
@@ -4,7 +4,7 @@ import { InvalidInputError } from './errors.js';
|
|
|
4
4
|
|
|
5
5
|
export class GcrWriter {
|
|
6
6
|
static async createBuffer(options) {
|
|
7
|
-
if (!options || !
|
|
7
|
+
if (!options || !options.concepts || typeof options.concepts[Symbol.iterator] !== 'function') {
|
|
8
8
|
throw new InvalidInputError(
|
|
9
9
|
'GcrWriter requires { concepts: Concept[] }',
|
|
10
10
|
'object with concepts array',
|
package/src/index.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export { ConceptCollection } from './concept-collection';
|
|
|
26
26
|
export { ManagedConceptCollection } from './managed-concept-collection';
|
|
27
27
|
|
|
28
28
|
// Validators
|
|
29
|
-
export { validateConcept, validateRegister, createConceptValidator, ValidationError, ValidationRule } from './validators/index';
|
|
29
|
+
export { validateConcept, validateRegister, createConceptValidator, ValidationError, ValidationRule, RegisterValidator } from './validators/index';
|
|
30
30
|
|
|
31
31
|
// UUID
|
|
32
32
|
export { conceptUuid, localizedConceptUuid, uuidV5 } from './uuid';
|
package/src/index.js
CHANGED
|
@@ -4,7 +4,7 @@ export { writeConcept, writeConcepts } from './concept-writer.js';
|
|
|
4
4
|
export { createGcr, GcrWriter } from './gcr-writer.js';
|
|
5
5
|
export { ConceptCollection } from './concept-collection.js';
|
|
6
6
|
export { ManagedConceptCollection } from './managed-concept-collection.js';
|
|
7
|
-
export { validateConcept, validateRegister, createConceptValidator, ValidationError, ValidationRule } from './validators/index.js';
|
|
7
|
+
export { validateConcept, validateRegister, createConceptValidator, ValidationError, ValidationRule, RegisterValidator } from './validators/index.js';
|
|
8
8
|
export { conceptUuid, localizedConceptUuid, uuidV5 } from './uuid.js';
|
|
9
9
|
export { ReferenceResolver, Reference, referenceResolver } from './reference-resolver.js';
|
|
10
10
|
export { V1Reader, migrateV1ToV2 } from './v1-reader.js';
|
|
@@ -97,23 +97,3 @@ export class ConceptValidator {
|
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
export class RegisterValidator {
|
|
101
|
-
validate(register) {
|
|
102
|
-
const errors = [];
|
|
103
|
-
if (!register || typeof register !== 'object') {
|
|
104
|
-
errors.push(new ValidationError('', 'Register must be a non-null object'));
|
|
105
|
-
return { valid: false, errors, warnings: [] };
|
|
106
|
-
}
|
|
107
|
-
if (!register.schema_version) {
|
|
108
|
-
errors.push(new ValidationError('schema_version', 'Register must have a schema_version', 'warning'));
|
|
109
|
-
}
|
|
110
|
-
if (!register.shortname) {
|
|
111
|
-
errors.push(new ValidationError('shortname', 'Register should have a shortname', 'warning'));
|
|
112
|
-
}
|
|
113
|
-
return {
|
|
114
|
-
valid: errors.filter(e => e.severity === 'error').length === 0,
|
|
115
|
-
errors: errors.filter(e => e.severity === 'error'),
|
|
116
|
-
warnings: errors.filter(e => e.severity === 'warning'),
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
}
|
|
@@ -11,6 +11,23 @@ export class ValidationRule {
|
|
|
11
11
|
validate(value: any, path: string): ValidationError[];
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
export class ConceptValidator {
|
|
15
|
+
addRule(rule: ValidationRule): this;
|
|
16
|
+
validate(concept: any): {
|
|
17
|
+
valid: boolean;
|
|
18
|
+
errors: ValidationError[];
|
|
19
|
+
warnings: ValidationError[];
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export class RegisterValidator {
|
|
24
|
+
validate(register: any): {
|
|
25
|
+
valid: boolean;
|
|
26
|
+
errors: ValidationError[];
|
|
27
|
+
warnings: ValidationError[];
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
14
31
|
export function validateConcept(concept: any): {
|
|
15
32
|
valid: boolean;
|
|
16
33
|
errors: ValidationError[];
|
|
@@ -23,4 +40,4 @@ export function validateRegister(register: any): {
|
|
|
23
40
|
warnings: ValidationError[];
|
|
24
41
|
};
|
|
25
42
|
|
|
26
|
-
export function createConceptValidator():
|
|
43
|
+
export function createConceptValidator(): ConceptValidator;
|
package/src/validators/index.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
export { ValidationError } from './validation-error.js';
|
|
2
2
|
export { ValidationRule } from './validation-rule.js';
|
|
3
|
-
export { ConceptValidator,
|
|
3
|
+
export { ConceptValidator, LanguageCodeRule, DesignationTypeRule, EntryStatusRule } from './concept-validator.js';
|
|
4
|
+
export { RegisterValidator } from './register-validator.js';
|
|
4
5
|
|
|
5
6
|
import { ConceptValidator, LanguageCodeRule, DesignationTypeRule, EntryStatusRule } from './concept-validator.js';
|
|
6
|
-
import { RegisterValidator } from './
|
|
7
|
+
import { RegisterValidator } from './register-validator.js';
|
|
7
8
|
|
|
8
9
|
const _default = new ConceptValidator()
|
|
9
10
|
.addRule(new LanguageCodeRule())
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ValidationError } from './validation-error.js';
|
|
2
|
+
|
|
3
|
+
export class RegisterValidator {
|
|
4
|
+
validate(register) {
|
|
5
|
+
const errors = [];
|
|
6
|
+
if (!register || typeof register !== 'object') {
|
|
7
|
+
errors.push(new ValidationError('', 'Register must be a non-null object'));
|
|
8
|
+
return { valid: false, errors, warnings: [] };
|
|
9
|
+
}
|
|
10
|
+
if (!register.schema_version) {
|
|
11
|
+
errors.push(new ValidationError('schema_version', 'Register must have a schema_version', 'warning'));
|
|
12
|
+
}
|
|
13
|
+
if (!register.shortname) {
|
|
14
|
+
errors.push(new ValidationError('shortname', 'Register should have a shortname', 'warning'));
|
|
15
|
+
}
|
|
16
|
+
return {
|
|
17
|
+
valid: errors.filter(e => e.severity === 'error').length === 0,
|
|
18
|
+
errors: errors.filter(e => e.severity === 'error'),
|
|
19
|
+
warnings: errors.filter(e => e.severity === 'warning'),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
}
|