@fougere/schema 0.12.0-alpha.0 → 0.12.2-alpha.0
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/dist/FougereFieldAxes.d.ts +3 -0
- package/dist/FougereFieldAxes.d.ts.map +1 -0
- package/dist/FougereFieldAxes.js +2 -0
- package/dist/FougereFieldAxes.js.map +1 -0
- package/dist/Schema.d.ts +4 -3
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +3 -0
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaConstraints.d.ts +13 -10
- package/dist/SchemaConstraints.d.ts.map +1 -1
- package/dist/SchemaConstraints.js +32 -20
- package/dist/SchemaConstraints.js.map +1 -1
- package/dist/SchemaDefinition.d.ts.map +1 -1
- package/dist/SchemaDefinition.js +6 -5
- package/dist/SchemaDefinition.js.map +1 -1
- package/dist/SchemaError.d.ts +4 -1
- package/dist/SchemaError.d.ts.map +1 -1
- package/dist/SchemaError.js +6 -3
- package/dist/SchemaError.js.map +1 -1
- package/dist/SchemaView.d.ts +3 -2
- package/dist/SchemaView.d.ts.map +1 -1
- package/dist/axis/Axes.d.ts +16 -0
- package/dist/axis/Axes.d.ts.map +1 -0
- package/dist/axis/Axes.js +27 -0
- package/dist/axis/Axes.js.map +1 -0
- package/dist/axis/Axis.d.ts +15 -9
- package/dist/axis/Axis.d.ts.map +1 -1
- package/dist/axis/Axis.js +1 -10
- package/dist/axis/Axis.js.map +1 -1
- package/dist/axis/boundary/Boundary.d.ts +38 -5
- package/dist/axis/boundary/Boundary.d.ts.map +1 -1
- package/dist/axis/boundary/Boundary.js +18 -11
- package/dist/axis/boundary/Boundary.js.map +1 -1
- package/dist/axis/boundary/Decoder.d.ts +8 -2
- package/dist/axis/boundary/Decoder.d.ts.map +1 -1
- package/dist/axis/boundary/Decoder.js.map +1 -1
- package/dist/axis/lifecycle/Lifecycle.d.ts +29 -8
- package/dist/axis/lifecycle/Lifecycle.d.ts.map +1 -1
- package/dist/axis/lifecycle/Lifecycle.js +26 -11
- package/dist/axis/lifecycle/Lifecycle.js.map +1 -1
- package/dist/axis/lifecycle/apply.d.ts.map +1 -1
- package/dist/axis/lifecycle/apply.js +3 -4
- package/dist/axis/lifecycle/apply.js.map +1 -1
- package/dist/axis/role/Role.d.ts +31 -12
- package/dist/axis/role/Role.d.ts.map +1 -1
- package/dist/axis/role/Role.js +56 -22
- package/dist/axis/role/Role.js.map +1 -1
- package/dist/axis/shape/Shape.d.ts +32 -9
- package/dist/axis/shape/Shape.d.ts.map +1 -1
- package/dist/axis/shape/Shape.js +43 -12
- package/dist/axis/shape/Shape.js.map +1 -1
- package/dist/axis/shape/ShapeFormat.d.ts +10 -0
- package/dist/axis/shape/ShapeFormat.d.ts.map +1 -0
- package/dist/axis/shape/ShapeFormat.js +32 -0
- package/dist/axis/shape/ShapeFormat.js.map +1 -0
- package/dist/axis/shape/{Formats.d.ts → StringFormats.d.ts} +3 -3
- package/dist/axis/shape/StringFormats.d.ts.map +1 -0
- package/dist/axis/shape/{Formats.js → StringFormats.js} +3 -3
- package/dist/axis/shape/StringFormats.js.map +1 -0
- package/dist/entity/EntityDeclarations.d.ts +3 -2
- package/dist/entity/EntityDeclarations.d.ts.map +1 -1
- package/dist/entity/FieldGroups.d.ts +9 -0
- package/dist/entity/FieldGroups.d.ts.map +1 -0
- package/dist/entity/FieldGroups.js +2 -0
- package/dist/entity/FieldGroups.js.map +1 -0
- package/dist/field/Field.d.ts +37 -12
- package/dist/field/Field.d.ts.map +1 -1
- package/dist/field/Field.js +55 -8
- package/dist/field/Field.js.map +1 -1
- package/dist/field/FieldFormat.d.ts +9 -0
- package/dist/field/FieldFormat.d.ts.map +1 -0
- package/dist/field/FieldFormat.js +12 -0
- package/dist/field/FieldFormat.js.map +1 -0
- package/dist/field/FieldSet.d.ts +12 -3
- package/dist/field/FieldSet.d.ts.map +1 -1
- package/dist/field/FieldSet.js +22 -15
- package/dist/field/FieldSet.js.map +1 -1
- package/dist/index.d.ts +7 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/lib/Format.d.ts +75 -0
- package/dist/lib/Format.d.ts.map +1 -0
- package/dist/lib/Format.js +123 -0
- package/dist/lib/Format.js.map +1 -0
- package/dist/lib/JsonSchema.d.ts +2 -0
- package/dist/lib/JsonSchema.d.ts.map +1 -0
- package/dist/lib/JsonSchema.js +2 -0
- package/dist/lib/JsonSchema.js.map +1 -0
- package/dist/lib/Registry.d.ts +4 -2
- package/dist/lib/Registry.d.ts.map +1 -1
- package/dist/lib/Registry.js +11 -5
- package/dist/lib/Registry.js.map +1 -1
- package/dist/lib/UnionToIntersection.d.ts +7 -0
- package/dist/lib/UnionToIntersection.d.ts.map +1 -0
- package/dist/lib/UnionToIntersection.js +2 -0
- package/dist/lib/UnionToIntersection.js.map +1 -0
- package/dist/lib/ValidationResult.d.ts +2 -0
- package/dist/lib/ValidationResult.d.ts.map +1 -1
- package/dist/lib/ValidationResult.js +6 -0
- package/dist/lib/ValidationResult.js.map +1 -1
- package/dist/lib/utils.d.ts +1 -1
- package/dist/lib/utils.d.ts.map +1 -1
- package/dist/lib/utils.js +1 -1
- package/dist/lib/utils.js.map +1 -1
- package/dist/projection/Cases.d.ts +1 -1
- package/dist/projection/Cases.d.ts.map +1 -1
- package/dist/projection/Cases.js +20 -8
- package/dist/projection/Cases.js.map +1 -1
- package/dist/projection/Visibility.d.ts +11 -0
- package/dist/projection/Visibility.d.ts.map +1 -1
- package/dist/projection/Visibility.js +28 -6
- package/dist/projection/Visibility.js.map +1 -1
- package/dist/projection/card/Bundle.d.ts.map +1 -1
- package/dist/projection/card/Bundle.js.map +1 -1
- package/dist/projection/card/Card.d.ts.map +1 -1
- package/dist/projection/card/Card.js +24 -30
- package/dist/projection/card/Card.js.map +1 -1
- package/dist/projection/card/CardForm.d.ts +7 -0
- package/dist/projection/card/CardForm.d.ts.map +1 -0
- package/dist/projection/card/CardForm.js +2 -0
- package/dist/projection/card/CardForm.js.map +1 -0
- package/dist/projection/card/CardForms.d.ts +10 -0
- package/dist/projection/card/CardForms.d.ts.map +1 -0
- package/dist/projection/card/CardForms.js +12 -0
- package/dist/projection/card/CardForms.js.map +1 -0
- package/dist/projection/card/Change.d.ts +2 -2
- package/dist/projection/card/Change.d.ts.map +1 -1
- package/dist/projection/card/Diff.js +2 -2
- package/dist/projection/card/Diff.js.map +1 -1
- package/dist/projection/card/FieldExtension.d.ts +4 -2
- package/dist/projection/card/FieldExtension.d.ts.map +1 -1
- package/dist/projection/card/RoleDescriptor.d.ts +15 -3
- package/dist/projection/card/RoleDescriptor.d.ts.map +1 -1
- package/dist/projection/card/RoleDescriptor.js +40 -1
- package/dist/projection/card/RoleDescriptor.js.map +1 -1
- package/dist/projection/card/ShapeKeywords.d.ts +1 -1
- package/dist/projection/card/ShapeKeywords.d.ts.map +1 -1
- package/dist/projection/card/admission.d.ts +0 -14
- package/dist/projection/card/admission.d.ts.map +1 -1
- package/dist/projection/card/admission.js +0 -20
- package/dist/projection/card/admission.js.map +1 -1
- package/dist/validator/FieldDeclarationValidator.d.ts.map +1 -1
- package/dist/validator/FieldDeclarationValidator.js +10 -25
- package/dist/validator/FieldDeclarationValidator.js.map +1 -1
- package/dist/validator/FieldValueValidator.d.ts.map +1 -1
- package/dist/validator/FieldValueValidator.js +9 -29
- package/dist/validator/FieldValueValidator.js.map +1 -1
- package/dist/validator/InputValidator.d.ts +7 -1
- package/dist/validator/InputValidator.d.ts.map +1 -1
- package/dist/validator/InputValidator.js +15 -14
- package/dist/validator/InputValidator.js.map +1 -1
- package/dist/validator/JsonSchemaValidator.d.ts +23 -0
- package/dist/validator/JsonSchemaValidator.d.ts.map +1 -0
- package/dist/validator/JsonSchemaValidator.js +113 -0
- package/dist/validator/JsonSchemaValidator.js.map +1 -0
- package/dist/vocabulary/preset/created.d.ts +2 -2
- package/dist/vocabulary/preset/created.d.ts.map +1 -1
- package/dist/vocabulary/preset/created.js +2 -2
- package/dist/vocabulary/preset/created.js.map +1 -1
- package/dist/vocabulary/preset/updated.d.ts +2 -2
- package/dist/vocabulary/preset/updated.d.ts.map +1 -1
- package/dist/vocabulary/preset/updated.js +2 -2
- package/dist/vocabulary/preset/updated.js.map +1 -1
- package/dist/vocabulary/primitive/bool.d.ts +2 -5
- package/dist/vocabulary/primitive/bool.d.ts.map +1 -1
- package/dist/vocabulary/primitive/bool.js +1 -5
- package/dist/vocabulary/primitive/bool.js.map +1 -1
- package/dist/vocabulary/primitive/date.d.ts +2 -3
- package/dist/vocabulary/primitive/date.d.ts.map +1 -1
- package/dist/vocabulary/primitive/date.js +2 -3
- package/dist/vocabulary/primitive/date.js.map +1 -1
- package/dist/vocabulary/primitive/json.d.ts +3 -3
- package/dist/vocabulary/primitive/json.d.ts.map +1 -1
- package/dist/vocabulary/primitive/json.js +11 -11
- package/dist/vocabulary/primitive/json.js.map +1 -1
- package/dist/vocabulary/primitive/list.d.ts +6 -5
- package/dist/vocabulary/primitive/list.d.ts.map +1 -1
- package/dist/vocabulary/primitive/list.js +13 -7
- package/dist/vocabulary/primitive/list.js.map +1 -1
- package/dist/vocabulary/primitive/many.d.ts +2 -4
- package/dist/vocabulary/primitive/many.d.ts.map +1 -1
- package/dist/vocabulary/primitive/many.js +2 -4
- package/dist/vocabulary/primitive/many.js.map +1 -1
- package/dist/vocabulary/primitive/number.d.ts +2 -4
- package/dist/vocabulary/primitive/number.d.ts.map +1 -1
- package/dist/vocabulary/primitive/number.js +1 -3
- package/dist/vocabulary/primitive/number.js.map +1 -1
- package/dist/vocabulary/primitive/oneOf.d.ts +4 -7
- package/dist/vocabulary/primitive/oneOf.d.ts.map +1 -1
- package/dist/vocabulary/primitive/oneOf.js +19 -11
- package/dist/vocabulary/primitive/oneOf.js.map +1 -1
- package/dist/vocabulary/primitive/primary.d.ts +2 -2
- package/dist/vocabulary/primitive/primary.d.ts.map +1 -1
- package/dist/vocabulary/primitive/primary.js +2 -3
- package/dist/vocabulary/primitive/primary.js.map +1 -1
- package/dist/vocabulary/primitive/ref.d.ts +2 -6
- package/dist/vocabulary/primitive/ref.d.ts.map +1 -1
- package/dist/vocabulary/primitive/ref.js +1 -1
- package/dist/vocabulary/primitive/ref.js.map +1 -1
- package/dist/vocabulary/primitive/text.d.ts +2 -4
- package/dist/vocabulary/primitive/text.d.ts.map +1 -1
- package/dist/vocabulary/primitive/text.js +1 -3
- package/dist/vocabulary/primitive/text.js.map +1 -1
- package/dist/vocabulary/rule/nullable.d.ts +0 -1
- package/dist/vocabulary/rule/nullable.d.ts.map +1 -1
- package/dist/vocabulary/rule/nullable.js +0 -1
- package/dist/vocabulary/rule/nullable.js.map +1 -1
- package/dist/vocabulary/rule/optional.d.ts +0 -1
- package/dist/vocabulary/rule/optional.d.ts.map +1 -1
- package/dist/vocabulary/rule/optional.js +0 -1
- package/dist/vocabulary/rule/optional.js.map +1 -1
- package/dist/vocabulary/rule/readOnly.d.ts +0 -2
- package/dist/vocabulary/rule/readOnly.d.ts.map +1 -1
- package/dist/vocabulary/rule/readOnly.js +0 -2
- package/dist/vocabulary/rule/readOnly.js.map +1 -1
- package/dist/vocabulary/rule/writeOnly.d.ts +0 -2
- package/dist/vocabulary/rule/writeOnly.d.ts.map +1 -1
- package/dist/vocabulary/rule/writeOnly.js +0 -2
- package/dist/vocabulary/rule/writeOnly.js.map +1 -1
- package/dist/vocabulary/vocabulary.d.ts +2 -3
- package/dist/vocabulary/vocabulary.d.ts.map +1 -1
- package/dist/vocabulary/vocabulary.js +18 -20
- package/dist/vocabulary/vocabulary.js.map +1 -1
- package/package.json +1 -1
- package/src/FougereFieldAxes.ts +2 -0
- package/src/Schema.ts +11 -8
- package/src/SchemaConstraints.ts +40 -22
- package/src/SchemaDefinition.ts +7 -5
- package/src/SchemaError.ts +9 -3
- package/src/SchemaView.ts +3 -2
- package/src/axis/Axes.ts +34 -0
- package/src/axis/Axis.ts +15 -19
- package/src/axis/boundary/Boundary.ts +39 -13
- package/src/axis/boundary/Decoder.ts +3 -1
- package/src/axis/lifecycle/Lifecycle.ts +42 -14
- package/src/axis/lifecycle/apply.ts +12 -6
- package/src/axis/role/Role.ts +73 -25
- package/src/axis/shape/Shape.ts +89 -23
- package/src/axis/shape/ShapeFormat.ts +37 -0
- package/src/axis/shape/{Formats.ts → StringFormats.ts} +2 -2
- package/src/entity/EntityDeclarations.ts +3 -2
- package/src/entity/FieldGroups.ts +9 -0
- package/src/field/Field.ts +89 -16
- package/src/field/FieldFormat.ts +18 -0
- package/src/field/FieldSet.ts +27 -19
- package/src/index.ts +7 -3
- package/src/lib/Format.ts +172 -0
- package/src/lib/JsonSchema.ts +1 -0
- package/src/lib/Registry.ts +14 -6
- package/src/lib/UnionToIntersection.ts +10 -0
- package/src/lib/ValidationResult.ts +8 -0
- package/src/lib/utils.ts +5 -1
- package/src/projection/Cases.ts +25 -8
- package/src/projection/Visibility.ts +31 -6
- package/src/projection/card/Bundle.ts +2 -0
- package/src/projection/card/Card.ts +29 -27
- package/src/projection/card/CardForm.ts +8 -0
- package/src/projection/card/CardForms.ts +13 -0
- package/src/projection/card/Change.ts +2 -2
- package/src/projection/card/Diff.ts +6 -2
- package/src/projection/card/FieldExtension.ts +5 -2
- package/src/projection/card/RoleDescriptor.ts +54 -3
- package/src/projection/card/ShapeKeywords.ts +1 -1
- package/src/projection/card/admission.ts +0 -33
- package/src/validator/FieldDeclarationValidator.ts +10 -25
- package/src/validator/FieldValueValidator.ts +13 -36
- package/src/validator/InputValidator.ts +17 -12
- package/src/validator/JsonSchemaValidator.ts +142 -0
- package/src/vocabulary/preset/created.ts +3 -3
- package/src/vocabulary/preset/updated.ts +4 -3
- package/src/vocabulary/primitive/bool.ts +3 -8
- package/src/vocabulary/primitive/date.ts +5 -4
- package/src/vocabulary/primitive/json.ts +27 -12
- package/src/vocabulary/primitive/list.ts +16 -9
- package/src/vocabulary/primitive/many.ts +3 -4
- package/src/vocabulary/primitive/number.ts +3 -8
- package/src/vocabulary/primitive/oneOf.ts +40 -24
- package/src/vocabulary/primitive/primary.ts +9 -5
- package/src/vocabulary/primitive/ref.ts +3 -7
- package/src/vocabulary/primitive/text.ts +3 -8
- package/src/vocabulary/rule/nullable.ts +0 -1
- package/src/vocabulary/rule/optional.ts +0 -1
- package/src/vocabulary/rule/readOnly.ts +0 -2
- package/src/vocabulary/rule/writeOnly.ts +0 -2
- package/src/vocabulary/vocabulary.ts +19 -21
- package/dist/axis/boundary/BoundaryAxis.d.ts +0 -4
- package/dist/axis/boundary/BoundaryAxis.d.ts.map +0 -1
- package/dist/axis/boundary/BoundaryAxis.js +0 -30
- package/dist/axis/boundary/BoundaryAxis.js.map +0 -1
- package/dist/axis/boundary/BoundaryRef.d.ts +0 -3
- package/dist/axis/boundary/BoundaryRef.d.ts.map +0 -1
- package/dist/axis/boundary/BoundaryRef.js +0 -2
- package/dist/axis/boundary/BoundaryRef.js.map +0 -1
- package/dist/axis/boundary/BoundaryRules.d.ts +0 -9
- package/dist/axis/boundary/BoundaryRules.d.ts.map +0 -1
- package/dist/axis/boundary/BoundaryRules.js +0 -2
- package/dist/axis/boundary/BoundaryRules.js.map +0 -1
- package/dist/axis/lifecycle/Clock.d.ts +0 -10
- package/dist/axis/lifecycle/Clock.d.ts.map +0 -1
- package/dist/axis/lifecycle/Clock.js +0 -19
- package/dist/axis/lifecycle/Clock.js.map +0 -1
- package/dist/axis/lifecycle/LifecycleAxis.d.ts +0 -4
- package/dist/axis/lifecycle/LifecycleAxis.d.ts.map +0 -1
- package/dist/axis/lifecycle/LifecycleAxis.js +0 -52
- package/dist/axis/lifecycle/LifecycleAxis.js.map +0 -1
- package/dist/axis/lifecycle/LifecycleRules.d.ts +0 -12
- package/dist/axis/lifecycle/LifecycleRules.d.ts.map +0 -1
- package/dist/axis/lifecycle/LifecycleRules.js +0 -3
- package/dist/axis/lifecycle/LifecycleRules.js.map +0 -1
- package/dist/axis/role/RoleAxis.d.ts +0 -5
- package/dist/axis/role/RoleAxis.d.ts.map +0 -1
- package/dist/axis/role/RoleAxis.js +0 -93
- package/dist/axis/role/RoleAxis.js.map +0 -1
- package/dist/axis/role/RoleRules.d.ts +0 -8
- package/dist/axis/role/RoleRules.d.ts.map +0 -1
- package/dist/axis/role/RoleRules.js +0 -2
- package/dist/axis/role/RoleRules.js.map +0 -1
- package/dist/axis/shape/Formats.d.ts.map +0 -1
- package/dist/axis/shape/Formats.js.map +0 -1
- package/dist/entity/CompositeUnique.d.ts +0 -4
- package/dist/entity/CompositeUnique.d.ts.map +0 -1
- package/dist/entity/CompositeUnique.js +0 -2
- package/dist/entity/CompositeUnique.js.map +0 -1
- package/dist/field/Meta.d.ts +0 -4
- package/dist/field/Meta.d.ts.map +0 -1
- package/dist/field/Meta.js +0 -2
- package/dist/field/Meta.js.map +0 -1
- package/dist/projection/card/RelationDescriptor.d.ts +0 -5
- package/dist/projection/card/RelationDescriptor.d.ts.map +0 -1
- package/dist/projection/card/RelationDescriptor.js +0 -2
- package/dist/projection/card/RelationDescriptor.js.map +0 -1
- package/dist/validator/AdapterFieldValidator.d.ts +0 -14
- package/dist/validator/AdapterFieldValidator.d.ts.map +0 -1
- package/dist/validator/AdapterFieldValidator.js +0 -37
- package/dist/validator/AdapterFieldValidator.js.map +0 -1
- package/src/axis/boundary/BoundaryAxis.ts +0 -32
- package/src/axis/boundary/BoundaryRef.ts +0 -3
- package/src/axis/boundary/BoundaryRules.ts +0 -4
- package/src/axis/lifecycle/Clock.ts +0 -22
- package/src/axis/lifecycle/LifecycleAxis.ts +0 -55
- package/src/axis/lifecycle/LifecycleRules.ts +0 -9
- package/src/axis/role/RoleAxis.ts +0 -104
- package/src/axis/role/RoleRules.ts +0 -8
- package/src/entity/CompositeUnique.ts +0 -6
- package/src/field/Meta.ts +0 -3
- package/src/projection/card/RelationDescriptor.ts +0 -3
- package/src/validator/AdapterFieldValidator.ts +0 -41
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RelationDescriptor.js","sourceRoot":"","sources":["../../../src/projection/card/RelationDescriptor.ts"],"names":[],"mappings":""}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { Shape } from '../axis/shape/Shape.js';
|
|
2
|
-
/**
|
|
3
|
-
* The format is DATA, not a TypeScript interface: an interface is erased before a JS
|
|
4
|
-
* caller, a config or a card from another language could be measured against it.
|
|
5
|
-
*/
|
|
6
|
-
export declare class AdapterFieldValidator {
|
|
7
|
-
private readonly validator;
|
|
8
|
-
private constructor();
|
|
9
|
-
/** Compiled once, at the adapter's own module load. */
|
|
10
|
-
static of(format: Shape): AdapterFieldValidator;
|
|
11
|
-
/** `Post.adapters.sql.body.columnType: Property "postgre" does not match …` */
|
|
12
|
-
assert(entries: unknown, path: string): void;
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=AdapterFieldValidator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AdapterFieldValidator.d.ts","sourceRoot":"","sources":["../../src/validator/AdapterFieldValidator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAIpD;;;GAGG;AACH,qBAAa,qBAAqB;IACZ,OAAO,CAAC,QAAQ,CAAC,SAAS;IAA9C,OAAO,eAAsD;IAE7D,uDAAuD;IACvD,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,KAAK,GAAG,qBAAqB,CAE9C;IAED,+EAA+E;IAC/E,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAqB3C;CACF"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { Validator } from '@cfworker/json-schema';
|
|
2
|
-
import { isObject } from '../lib/utils.js';
|
|
3
|
-
import { SchemaError } from '../SchemaError.js';
|
|
4
|
-
/**
|
|
5
|
-
* The format is DATA, not a TypeScript interface: an interface is erased before a JS
|
|
6
|
-
* caller, a config or a card from another language could be measured against it.
|
|
7
|
-
*/
|
|
8
|
-
export class AdapterFieldValidator {
|
|
9
|
-
validator;
|
|
10
|
-
constructor(validator) {
|
|
11
|
-
this.validator = validator;
|
|
12
|
-
}
|
|
13
|
-
/** Compiled once, at the adapter's own module load. */
|
|
14
|
-
static of(format) {
|
|
15
|
-
return new AdapterFieldValidator(new Validator(format, '2020-12', true));
|
|
16
|
-
}
|
|
17
|
-
/** `Post.adapters.sql.body.columnType: Property "postgre" does not match …` */
|
|
18
|
-
assert(entries, path) {
|
|
19
|
-
if (entries === undefined)
|
|
20
|
-
return;
|
|
21
|
-
if (!isObject(entries)) {
|
|
22
|
-
throw new SchemaError(`${path}: expected an object keyed by field name, got ${typeof entries}.`);
|
|
23
|
-
}
|
|
24
|
-
for (const [field, entry] of Object.entries(entries)) {
|
|
25
|
-
const verdict = this.validator.validate(entry);
|
|
26
|
-
if (verdict.valid)
|
|
27
|
-
continue;
|
|
28
|
-
// The engine reports outermost first and ends on `False boolean schema`, which names
|
|
29
|
-
// nothing. The last unit above that one is the one carrying the offending key.
|
|
30
|
-
const units = verdict.errors.filter((unit) => unit.keyword !== 'false');
|
|
31
|
-
const failure = units[units.length - 1] ?? verdict.errors[0];
|
|
32
|
-
const nested = (failure?.instanceLocation ?? '#').slice(1).replaceAll('/', '.');
|
|
33
|
-
throw new SchemaError(`${path}.${field}${nested}: ${failure?.error ?? 'does not match the format'}`);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
//# sourceMappingURL=AdapterFieldValidator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AdapterFieldValidator.js","sourceRoot":"","sources":["../../src/validator/AdapterFieldValidator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD;;;GAGG;AACH,MAAM,OAAO,qBAAqB;IACK,SAAS;IAA9C,YAAqC,SAAoB;yBAApB,SAAS;IAAc,CAAC;IAE7D,uDAAuD;IACvD,MAAM,CAAC,EAAE,CAAC,MAAa;QACrB,OAAO,IAAI,qBAAqB,CAAC,IAAI,SAAS,CAAC,MAAgB,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC;IACrF,CAAC;IAED,+EAA+E;IAC/E,MAAM,CAAC,OAAgB,EAAE,IAAY;QACnC,IAAI,OAAO,KAAK,SAAS;YAAE,OAAO;QAElC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;YACvB,MAAM,IAAI,WAAW,CACnB,GAAG,IAAI,iDAAiD,OAAO,OAAO,GAAG,CAC1E,CAAC;QACJ,CAAC;QAED,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YACrD,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;YAC/C,IAAI,OAAO,CAAC,KAAK;gBAAE,SAAS;YAE5B,qFAAqF;YACrF,+EAA+E;YAC/E,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,KAAK,OAAO,CAAC,CAAC;YACxE,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;YAC7D,MAAM,MAAM,GAAG,CAAC,OAAO,EAAE,gBAAgB,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;YAEhF,MAAM,IAAI,WAAW,CAAC,GAAG,IAAI,IAAI,KAAK,GAAG,MAAM,KAAK,OAAO,EAAE,KAAK,IAAI,2BAA2B,EAAE,CAAC,CAAC;QACvG,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { Axis } from '../Axis.js';
|
|
2
|
-
import { admitWire } from '../../projection/card/admission.js';
|
|
3
|
-
import { isObject, shown } from '../../lib/utils.js';
|
|
4
|
-
import type { BoundaryRef } from './BoundaryRef.js';
|
|
5
|
-
|
|
6
|
-
export const boundaryAxis: Axis<BoundaryRef, BoundaryRef> = {
|
|
7
|
-
slot: 'boundary',
|
|
8
|
-
|
|
9
|
-
validator(value, errors) {
|
|
10
|
-
if (typeof value === 'string') return;
|
|
11
|
-
if (!isObject(value)) {
|
|
12
|
-
errors.push({
|
|
13
|
-
path: ['boundary'],
|
|
14
|
-
message: `Expected an alias name or { in, out } — got ${shown(value)}`,
|
|
15
|
-
});
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
for (const [side, verb] of [['in', 'decode'], ['out', 'encode']] as const) {
|
|
19
|
-
const rule = value[side];
|
|
20
|
-
if (rule === undefined || rule === 'closed') continue;
|
|
21
|
-
if (!isObject(rule) || typeof rule[verb] !== 'string') {
|
|
22
|
-
errors.push({ path: ['boundary', side], message: `Expected 'closed' or { ${verb}: <name> }` });
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
describe: (value) => value,
|
|
28
|
-
reconstruct: (wire) => {
|
|
29
|
-
admitWire(boundaryAxis.validator, wire, 'boundary');
|
|
30
|
-
return wire;
|
|
31
|
-
},
|
|
32
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export class Clock {
|
|
2
|
-
private static reading: () => number = Date.now;
|
|
3
|
-
|
|
4
|
-
static now(): number {
|
|
5
|
-
return this.reading();
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
*
|
|
10
|
-
* @returns function to restore the clock
|
|
11
|
-
*/
|
|
12
|
-
static freeze(at: number | Date): () => void {
|
|
13
|
-
const previous = this.reading;
|
|
14
|
-
const instant = at instanceof Date ? at.getTime() : at;
|
|
15
|
-
|
|
16
|
-
this.reading = () => instant;
|
|
17
|
-
|
|
18
|
-
return () => {
|
|
19
|
-
this.reading = previous;
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import type { Axis } from '../Axis.js';
|
|
2
|
-
import type { ValidationError } from '../../lib/ValidationError.js';
|
|
3
|
-
import { admitWire, oneOfTokens } from '../../projection/card/admission.js';
|
|
4
|
-
import { isObject, shown } from '../../lib/utils.js';
|
|
5
|
-
import { CREATE_TOKENS, UPDATE_TOKENS } from './LifecycleRules.js';
|
|
6
|
-
import { type LifecycleRules } from './LifecycleRules.js';
|
|
7
|
-
|
|
8
|
-
export const lifecycleAxis: Axis<LifecycleRules, LifecycleRules> = {
|
|
9
|
-
slot: 'lifecycle',
|
|
10
|
-
|
|
11
|
-
validator(value, errors) {
|
|
12
|
-
if (!isObject(value)) {
|
|
13
|
-
errors.push({ path: ['lifecycle'], message: `Expected an object — got ${shown(value)}` });
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
if (value.create !== undefined) validateCreate(value.create, errors);
|
|
17
|
-
if (value.update !== undefined && !oneOfTokens(value.update, UPDATE_TOKENS)) {
|
|
18
|
-
errors.push({
|
|
19
|
-
path: ['lifecycle', 'update'],
|
|
20
|
-
message: `Expected 'now' or 'forbidden' — got ${shown(value.update)}`,
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
|
|
25
|
-
describe: (value) => value,
|
|
26
|
-
reconstruct: (wire) => {
|
|
27
|
-
admitWire(lifecycleAxis.validator, wire, 'lifecycle');
|
|
28
|
-
return wire;
|
|
29
|
-
},
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Judges the create rule, whose four legal forms are stated here and nowhere else.
|
|
34
|
-
* FR : juge la règle de création, dont les quatre formes légales sont énoncées ici seulement.
|
|
35
|
-
* `create: 3` → `Expected 'now', 'optional', { value } or { generate } — got 3`
|
|
36
|
-
*/
|
|
37
|
-
function validateCreate(rule: unknown, errors: ValidationError[]): void {
|
|
38
|
-
if (oneOfTokens(rule, CREATE_TOKENS)) return;
|
|
39
|
-
if (isObject(rule)) {
|
|
40
|
-
if ('value' in rule) return;
|
|
41
|
-
if ('generate' in rule) {
|
|
42
|
-
if (typeof rule.generate !== 'string') {
|
|
43
|
-
errors.push({
|
|
44
|
-
path: ['lifecycle', 'create', 'generate'],
|
|
45
|
-
message: `Expected a generator name — got ${shown(rule.generate)}`,
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
errors.push({
|
|
52
|
-
path: ['lifecycle', 'create'],
|
|
53
|
-
message: `Expected 'now', 'optional', { value } or { generate } — got ${shown(rule)}`,
|
|
54
|
-
});
|
|
55
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { GeneratorRef } from './Generators.js';
|
|
2
|
-
|
|
3
|
-
export const CREATE_TOKENS = ['now', 'optional'] as const;
|
|
4
|
-
export const UPDATE_TOKENS = ['now', 'forbidden'] as const;
|
|
5
|
-
|
|
6
|
-
export interface LifecycleRules {
|
|
7
|
-
create?: { value: unknown } | { generate: GeneratorRef } | (typeof CREATE_TOKENS)[number];
|
|
8
|
-
update?: (typeof UPDATE_TOKENS)[number];
|
|
9
|
-
}
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import type { Axis } from '../Axis.js';
|
|
2
|
-
import type { Resolver } from '../Resolver.js';
|
|
3
|
-
import { refuse, oneOfTokens } from '../../projection/card/admission.js';
|
|
4
|
-
import { isObject, lowerFirst, shown } from '../../lib/utils.js';
|
|
5
|
-
import type { ValidationError } from '../../lib/ValidationError.js';
|
|
6
|
-
import { type EntityConstructor } from './EntityConstructor.js';
|
|
7
|
-
import { ON_DELETE, RELATION_KINDS, type Relation } from './Relation.js';
|
|
8
|
-
import { type RoleRules } from './RoleRules.js';
|
|
9
|
-
import type { RoleDescriptor } from '../../projection/card/RoleDescriptor.js';
|
|
10
|
-
|
|
11
|
-
export const roleAxis: Axis<RoleRules, RoleDescriptor> = {
|
|
12
|
-
slot: 'role',
|
|
13
|
-
|
|
14
|
-
validator(value, errors) {
|
|
15
|
-
if (!isObject(value)) {
|
|
16
|
-
errors.push({ path: ['role'], message: `Expected an object — got ${shown(value)}` });
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
for (const flag of ['primary', 'index', 'unique'] as const) {
|
|
20
|
-
if (value[flag] !== undefined && typeof value[flag] !== 'boolean') {
|
|
21
|
-
errors.push({
|
|
22
|
-
path: ['role', flag],
|
|
23
|
-
message: `Expected a boolean — got ${shown(value[flag])}`,
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
if (value.relation !== undefined) validateRelation(value.relation, errors);
|
|
28
|
-
},
|
|
29
|
-
|
|
30
|
-
/** A card carries the target's NAME: a class cannot cross a process boundary. */
|
|
31
|
-
describe(role, key) {
|
|
32
|
-
const descriptor: Mutable<RoleDescriptor> = {};
|
|
33
|
-
if (role.primary) descriptor.primary = true;
|
|
34
|
-
if (role.unique) descriptor.unique = [[key]];
|
|
35
|
-
if (role.index) descriptor.index = true;
|
|
36
|
-
if (role.relation) {
|
|
37
|
-
const target = role.relation.to() as { name?: string };
|
|
38
|
-
descriptor.relation = {
|
|
39
|
-
to: lowerFirst(target.name ?? ''),
|
|
40
|
-
kind: role.relation.kind,
|
|
41
|
-
...(role.relation.onDelete ? { onDelete: role.relation.onDelete } : {}),
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
return Object.keys(descriptor).length ? descriptor : undefined;
|
|
45
|
-
},
|
|
46
|
-
|
|
47
|
-
reconstruct(wire, resolve?: Resolver) {
|
|
48
|
-
const rules: RoleRules = {};
|
|
49
|
-
if (wire.primary) rules.primary = true;
|
|
50
|
-
if (wire.unique?.some((group) => group.length === 1)) rules.unique = true;
|
|
51
|
-
if (wire.index) rules.index = true;
|
|
52
|
-
if (wire.relation) {
|
|
53
|
-
// `validator` cannot serve here: it demands `() => Post` where a card carries a name.
|
|
54
|
-
if (!oneOfTokens(wire.relation.kind, RELATION_KINDS)) {
|
|
55
|
-
refuse(
|
|
56
|
-
`role.relation.kind is ${JSON.stringify(wire.relation.kind)}`,
|
|
57
|
-
`Expected one of ${RELATION_KINDS.join(', ')}.`,
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
if (wire.relation.onDelete !== undefined && !oneOfTokens(wire.relation.onDelete, ON_DELETE)) {
|
|
61
|
-
refuse(
|
|
62
|
-
`role.relation.onDelete is ${JSON.stringify(wire.relation.onDelete)}`,
|
|
63
|
-
`Expected one of ${ON_DELETE.join(', ')}.`,
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
const name = wire.relation.to;
|
|
67
|
-
rules.relation = {
|
|
68
|
-
to: () => (resolve?.(name) ?? ({ name } as unknown)) as EntityConstructor,
|
|
69
|
-
kind: wire.relation.kind as Relation['kind'],
|
|
70
|
-
...(wire.relation.onDelete ? { onDelete: wire.relation.onDelete as Relation['onDelete'] } : {}),
|
|
71
|
-
} as RoleRules['relation'];
|
|
72
|
-
}
|
|
73
|
-
return rules;
|
|
74
|
-
},
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Judges a relation where `to` is a thunk; a card states a NAME, resolved by `toSchema` first.
|
|
79
|
-
* FR : juge une relation dont `to` est une fonction ; une carte y met un NOM, résolu avant.
|
|
80
|
-
* `{ to: User, kind: 'one' }` → `Expected a function returning the target entity, … () => Post`
|
|
81
|
-
*/
|
|
82
|
-
function validateRelation(relation: unknown, errors: ValidationError[]): void {
|
|
83
|
-
if (!isObject(relation)) {
|
|
84
|
-
errors.push({ path: ['role', 'relation'], message: `Expected an object — got ${shown(relation)}` });
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
if (!oneOfTokens(relation.kind, RELATION_KINDS)) {
|
|
88
|
-
errors.push({
|
|
89
|
-
path: ['role', 'relation', 'kind'],
|
|
90
|
-
message: `Expected 'one' or 'many' — got ${shown(relation.kind)}`,
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
if (typeof relation.to !== 'function') {
|
|
94
|
-
errors.push({ path: ['role', 'relation', 'to'], message: 'Expected a function returning the target entity, such as () => Post' });
|
|
95
|
-
}
|
|
96
|
-
if (relation.onDelete !== undefined && !oneOfTokens(relation.onDelete, ON_DELETE)) {
|
|
97
|
-
errors.push({
|
|
98
|
-
path: ['role', 'relation', 'onDelete'],
|
|
99
|
-
message: `Expected 'cascade', 'restrict' or 'set null' — got ${shown(relation.onDelete)}`,
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
type Mutable<T> = { -readonly [K in keyof T]: T[K] };
|
package/src/field/Meta.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { Validator } from '@cfworker/json-schema';
|
|
2
|
-
import type { Shape } from '../axis/shape/Shape.js';
|
|
3
|
-
import { isObject } from '../lib/utils.js';
|
|
4
|
-
import { SchemaError } from '../SchemaError.js';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* The format is DATA, not a TypeScript interface: an interface is erased before a JS
|
|
8
|
-
* caller, a config or a card from another language could be measured against it.
|
|
9
|
-
*/
|
|
10
|
-
export class AdapterFieldValidator {
|
|
11
|
-
private constructor(private readonly validator: Validator) {}
|
|
12
|
-
|
|
13
|
-
/** Compiled once, at the adapter's own module load. */
|
|
14
|
-
static of(format: Shape): AdapterFieldValidator {
|
|
15
|
-
return new AdapterFieldValidator(new Validator(format as object, '2020-12', true));
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/** `Post.adapters.sql.body.columnType: Property "postgre" does not match …` */
|
|
19
|
-
assert(entries: unknown, path: string): void {
|
|
20
|
-
if (entries === undefined) return;
|
|
21
|
-
|
|
22
|
-
if (!isObject(entries)) {
|
|
23
|
-
throw new SchemaError(
|
|
24
|
-
`${path}: expected an object keyed by field name, got ${typeof entries}.`,
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
for (const [field, entry] of Object.entries(entries)) {
|
|
29
|
-
const verdict = this.validator.validate(entry);
|
|
30
|
-
if (verdict.valid) continue;
|
|
31
|
-
|
|
32
|
-
// The engine reports outermost first and ends on `False boolean schema`, which names
|
|
33
|
-
// nothing. The last unit above that one is the one carrying the offending key.
|
|
34
|
-
const units = verdict.errors.filter((unit) => unit.keyword !== 'false');
|
|
35
|
-
const failure = units[units.length - 1] ?? verdict.errors[0];
|
|
36
|
-
const nested = (failure?.instanceLocation ?? '#').slice(1).replaceAll('/', '.');
|
|
37
|
-
|
|
38
|
-
throw new SchemaError(`${path}.${field}${nested}: ${failure?.error ?? 'does not match the format'}`);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|