@fougere/schema 0.9.2-alpha.0 → 0.10.0-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/PartialValues.d.ts +4 -0
- package/dist/PartialValues.d.ts.map +1 -0
- package/dist/PartialValues.js +2 -0
- package/dist/PartialValues.js.map +1 -0
- package/dist/Schema.d.ts +9 -21
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaConstraints.d.ts +24 -0
- package/dist/SchemaConstraints.d.ts.map +1 -0
- package/dist/SchemaConstraints.js +39 -0
- package/dist/SchemaConstraints.js.map +1 -0
- package/dist/SchemaConstructor.d.ts +25 -0
- package/dist/SchemaConstructor.d.ts.map +1 -0
- package/dist/SchemaConstructor.js +2 -0
- package/dist/SchemaConstructor.js.map +1 -0
- package/dist/SchemaDefinition.d.ts +5 -23
- package/dist/SchemaDefinition.d.ts.map +1 -1
- package/dist/SchemaDefinition.js +1 -38
- package/dist/SchemaDefinition.js.map +1 -1
- package/dist/SchemaDerivation.d.ts +1 -1
- package/dist/SchemaDerivation.d.ts.map +1 -1
- package/dist/SchemaView.d.ts +6 -8
- package/dist/SchemaView.d.ts.map +1 -1
- package/dist/Values.d.ts +6 -0
- package/dist/Values.d.ts.map +1 -0
- package/dist/Values.js +2 -0
- package/dist/Values.js.map +1 -0
- package/dist/axis/Axis.d.ts +2 -2
- package/dist/axis/Axis.d.ts.map +1 -1
- package/dist/axis/Axis.js.map +1 -1
- package/dist/axis/Resolver.d.ts +2 -0
- package/dist/axis/Resolver.d.ts.map +1 -0
- package/dist/axis/Resolver.js +2 -0
- package/dist/axis/Resolver.js.map +1 -0
- package/dist/axis/boundary/Boundaries.d.ts +3 -12
- package/dist/axis/boundary/Boundaries.d.ts.map +1 -1
- package/dist/axis/boundary/Boundaries.js.map +1 -1
- package/dist/axis/boundary/Boundary.d.ts +3 -10
- package/dist/axis/boundary/Boundary.d.ts.map +1 -1
- package/dist/axis/boundary/Boundary.js +1 -1
- package/dist/axis/boundary/Boundary.js.map +1 -1
- package/dist/axis/boundary/BoundaryAxis.d.ts +1 -1
- package/dist/axis/boundary/BoundaryAxis.d.ts.map +1 -1
- package/dist/axis/boundary/BoundaryRef.d.ts +3 -0
- package/dist/axis/boundary/BoundaryRef.d.ts.map +1 -0
- package/dist/axis/boundary/BoundaryRef.js +2 -0
- package/dist/axis/boundary/BoundaryRef.js.map +1 -0
- package/dist/axis/boundary/BoundaryRules.d.ts +9 -0
- package/dist/axis/boundary/BoundaryRules.d.ts.map +1 -0
- package/dist/axis/boundary/BoundaryRules.js +2 -0
- package/dist/axis/boundary/BoundaryRules.js.map +1 -0
- package/dist/axis/boundary/Decoder.d.ts +26 -0
- package/dist/axis/boundary/Decoder.d.ts.map +1 -0
- package/dist/axis/boundary/Decoder.js +25 -0
- package/dist/axis/boundary/Decoder.js.map +1 -0
- package/dist/axis/boundary/Encoder.d.ts +2 -0
- package/dist/axis/boundary/Encoder.d.ts.map +1 -0
- package/dist/axis/boundary/Encoder.js +2 -0
- package/dist/axis/boundary/Encoder.js.map +1 -0
- package/dist/axis/lifecycle/Lifecycle.d.ts +1 -10
- package/dist/axis/lifecycle/Lifecycle.d.ts.map +1 -1
- package/dist/axis/lifecycle/Lifecycle.js +0 -2
- package/dist/axis/lifecycle/Lifecycle.js.map +1 -1
- package/dist/axis/lifecycle/LifecycleAxis.d.ts +1 -1
- package/dist/axis/lifecycle/LifecycleAxis.d.ts.map +1 -1
- package/dist/axis/lifecycle/LifecycleAxis.js +1 -1
- package/dist/axis/lifecycle/LifecycleAxis.js.map +1 -1
- package/dist/axis/lifecycle/LifecycleRules.d.ts +12 -0
- package/dist/axis/lifecycle/LifecycleRules.d.ts.map +1 -0
- package/dist/axis/lifecycle/LifecycleRules.js +3 -0
- package/dist/axis/lifecycle/LifecycleRules.js.map +1 -0
- package/dist/axis/lifecycle/apply.d.ts +1 -1
- package/dist/axis/lifecycle/apply.d.ts.map +1 -1
- package/dist/axis/lifecycle/apply.js.map +1 -1
- package/dist/axis/role/EntityConstructor.d.ts +2 -0
- package/dist/axis/role/EntityConstructor.d.ts.map +1 -0
- package/dist/axis/role/EntityConstructor.js +2 -0
- package/dist/axis/role/EntityConstructor.js.map +1 -0
- package/dist/axis/role/Relation.d.ts +1 -1
- package/dist/axis/role/Relation.d.ts.map +1 -1
- package/dist/axis/role/Relation.js.map +1 -1
- package/dist/axis/role/Role.d.ts +3 -7
- package/dist/axis/role/Role.d.ts.map +1 -1
- package/dist/axis/role/Role.js.map +1 -1
- package/dist/axis/role/RoleAxis.d.ts +2 -2
- package/dist/axis/role/RoleAxis.d.ts.map +1 -1
- package/dist/axis/role/RoleAxis.js.map +1 -1
- package/dist/axis/role/RoleRules.d.ts +8 -0
- package/dist/axis/role/RoleRules.d.ts.map +1 -0
- package/dist/axis/role/RoleRules.js +2 -0
- package/dist/axis/role/RoleRules.js.map +1 -0
- package/dist/axis/shape/FormatPredicate.d.ts +2 -0
- package/dist/axis/shape/FormatPredicate.d.ts.map +1 -0
- package/dist/axis/shape/FormatPredicate.js +2 -0
- package/dist/axis/shape/FormatPredicate.js.map +1 -0
- package/dist/axis/shape/Formats.d.ts +1 -2
- package/dist/axis/shape/Formats.d.ts.map +1 -1
- package/dist/axis/shape/Formats.js.map +1 -1
- package/dist/axis/shape/Shape.d.ts +3 -9
- package/dist/axis/shape/Shape.d.ts.map +1 -1
- package/dist/axis/shape/Shape.js +1 -1
- package/dist/axis/shape/Shape.js.map +1 -1
- package/dist/axis/shape/ShapeType.d.ts +8 -0
- package/dist/axis/shape/ShapeType.d.ts.map +1 -0
- package/dist/axis/shape/ShapeType.js +2 -0
- package/dist/axis/shape/ShapeType.js.map +1 -0
- package/dist/axis/shape/StringFormat.d.ts +2 -0
- package/dist/axis/shape/StringFormat.d.ts.map +1 -0
- package/dist/axis/shape/StringFormat.js +2 -0
- package/dist/axis/shape/StringFormat.js.map +1 -0
- package/dist/entity/CompositeUnique.d.ts +4 -0
- package/dist/entity/CompositeUnique.d.ts.map +1 -0
- package/dist/entity/CompositeUnique.js +2 -0
- package/dist/entity/CompositeUnique.js.map +1 -0
- package/dist/entity/EntityAdapterSet.d.ts +1 -1
- package/dist/entity/EntityAdapterSet.d.ts.map +1 -1
- package/dist/entity/EntityAdapters.d.ts +3 -3
- package/dist/entity/EntityAdapters.d.ts.map +1 -1
- package/dist/entity/EntityDeclarations.d.ts +3 -3
- package/dist/entity/EntityDeclarations.d.ts.map +1 -1
- package/dist/entity/FougereEntityAdapters.d.ts +3 -0
- package/dist/entity/FougereEntityAdapters.d.ts.map +1 -0
- package/dist/entity/FougereEntityAdapters.js +2 -0
- package/dist/entity/FougereEntityAdapters.js.map +1 -0
- package/dist/entity/PreviousNames.d.ts +4 -0
- package/dist/entity/PreviousNames.d.ts.map +1 -0
- package/dist/entity/PreviousNames.js +2 -0
- package/dist/entity/PreviousNames.js.map +1 -0
- package/dist/entity.d.ts +2 -2
- package/dist/entity.d.ts.map +1 -1
- package/dist/entity.js.map +1 -1
- package/dist/field/Field.d.ts +3 -5
- package/dist/field/Field.d.ts.map +1 -1
- package/dist/field/Field.js +1 -1
- package/dist/field/Field.js.map +1 -1
- package/dist/field/FieldName.d.ts +3 -0
- package/dist/field/FieldName.d.ts.map +1 -0
- package/dist/field/FieldName.js +2 -0
- package/dist/field/FieldName.js.map +1 -0
- package/dist/field/FieldSet.d.ts +3 -2
- package/dist/field/FieldSet.d.ts.map +1 -1
- package/dist/field/FieldSet.js.map +1 -1
- package/dist/field/Fields.d.ts +3 -0
- package/dist/field/Fields.d.ts.map +1 -0
- package/dist/field/Fields.js +2 -0
- package/dist/field/Fields.js.map +1 -0
- package/dist/index.d.ts +21 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/lib/Checked.d.ts +11 -0
- package/dist/lib/Checked.d.ts.map +1 -0
- package/dist/lib/Checked.js +2 -0
- package/dist/lib/Checked.js.map +1 -0
- package/dist/lib/ValidationError.d.ts +10 -0
- package/dist/lib/ValidationError.d.ts.map +1 -0
- package/dist/lib/ValidationError.js +2 -0
- package/dist/lib/ValidationError.js.map +1 -0
- package/dist/lib/ValidationResult.d.ts +14 -0
- package/dist/lib/ValidationResult.d.ts.map +1 -0
- package/dist/lib/{validation.js → ValidationResult.js} +1 -1
- package/dist/lib/ValidationResult.js.map +1 -0
- package/dist/projection/Cases.d.ts +1 -18
- package/dist/projection/Cases.d.ts.map +1 -1
- package/dist/projection/Cases.js.map +1 -1
- package/dist/projection/ValidationCase.d.ts +19 -0
- package/dist/projection/ValidationCase.d.ts.map +1 -0
- package/dist/projection/ValidationCase.js +2 -0
- package/dist/projection/ValidationCase.js.map +1 -0
- package/dist/projection/Visibility.d.ts +1 -1
- package/dist/projection/Visibility.d.ts.map +1 -1
- package/dist/projection/card/Bundle.d.ts +3 -2
- 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 +10 -6
- package/dist/projection/card/Card.d.ts.map +1 -1
- package/dist/projection/card/Card.js +3 -3
- package/dist/projection/card/Card.js.map +1 -1
- package/dist/projection/card/Change.d.ts +70 -0
- package/dist/projection/card/Change.d.ts.map +1 -0
- package/dist/projection/card/Change.js +2 -0
- package/dist/projection/card/Change.js.map +1 -0
- package/dist/projection/card/DerivedFrom.d.ts +12 -0
- package/dist/projection/card/DerivedFrom.d.ts.map +1 -0
- package/dist/projection/card/DerivedFrom.js +2 -0
- package/dist/projection/card/DerivedFrom.js.map +1 -0
- package/dist/projection/card/Diff.d.ts +18 -0
- package/dist/projection/card/Diff.d.ts.map +1 -0
- package/dist/projection/card/{diff.js → Diff.js} +1 -1
- package/dist/projection/card/{diff.js.map → Diff.js.map} +1 -1
- package/dist/projection/card/DiffOptions.d.ts +5 -0
- package/dist/projection/card/DiffOptions.d.ts.map +1 -0
- package/dist/projection/card/DiffOptions.js +2 -0
- package/dist/projection/card/DiffOptions.js.map +1 -0
- package/dist/projection/card/FieldDescriptor.d.ts +11 -0
- package/dist/projection/card/FieldDescriptor.d.ts.map +1 -0
- package/dist/projection/card/FieldDescriptor.js +2 -0
- package/dist/projection/card/FieldDescriptor.js.map +1 -0
- package/dist/projection/card/FieldExtension.d.ts +9 -0
- package/dist/projection/card/FieldExtension.d.ts.map +1 -0
- package/dist/projection/card/FieldExtension.js +2 -0
- package/dist/projection/card/FieldExtension.js.map +1 -0
- package/dist/projection/card/RelationDescriptor.d.ts +5 -0
- package/dist/projection/card/RelationDescriptor.d.ts.map +1 -0
- package/dist/projection/card/RelationDescriptor.js +2 -0
- package/dist/projection/card/RelationDescriptor.js.map +1 -0
- package/dist/projection/card/RenameCandidate.d.ts +6 -0
- package/dist/projection/card/RenameCandidate.d.ts.map +1 -0
- package/dist/projection/card/RenameCandidate.js +2 -0
- package/dist/projection/card/RenameCandidate.js.map +1 -0
- package/dist/projection/card/RoleDescriptor.d.ts +7 -0
- package/dist/projection/card/RoleDescriptor.d.ts.map +1 -0
- package/dist/projection/card/RoleDescriptor.js +2 -0
- package/dist/projection/card/RoleDescriptor.js.map +1 -0
- package/dist/projection/card/SchemaBundle.d.ts +7 -0
- package/dist/projection/card/SchemaBundle.d.ts.map +1 -0
- package/dist/projection/card/SchemaBundle.js +2 -0
- package/dist/projection/card/SchemaBundle.js.map +1 -0
- package/dist/projection/card/SchemaDescriptor.d.ts +12 -0
- package/dist/projection/card/SchemaDescriptor.d.ts.map +1 -0
- package/dist/projection/card/SchemaDescriptor.js +2 -0
- package/dist/projection/card/SchemaDescriptor.js.map +1 -0
- package/dist/projection/card/SetDiff.d.ts +10 -0
- package/dist/projection/card/SetDiff.d.ts.map +1 -0
- package/dist/projection/card/SetDiff.js +2 -0
- package/dist/projection/card/SetDiff.js.map +1 -0
- package/dist/projection/card/SetDiffOptions.d.ts +5 -0
- package/dist/projection/card/SetDiffOptions.d.ts.map +1 -0
- package/dist/projection/card/SetDiffOptions.js +2 -0
- package/dist/projection/card/SetDiffOptions.js.map +1 -0
- package/dist/projection/card/ShapeKeywords.d.ts +7 -0
- package/dist/projection/card/ShapeKeywords.d.ts.map +1 -0
- package/dist/projection/card/ShapeKeywords.js +2 -0
- package/dist/projection/card/ShapeKeywords.js.map +1 -0
- package/dist/projection/card/TypeSet.d.ts +3 -0
- package/dist/projection/card/TypeSet.d.ts.map +1 -0
- package/dist/projection/card/TypeSet.js +2 -0
- package/dist/projection/card/TypeSet.js.map +1 -0
- package/dist/projection/card/admission.d.ts +2 -2
- package/dist/projection/card/admission.d.ts.map +1 -1
- package/dist/projection/card/admission.js +2 -2
- package/dist/projection/card/admission.js.map +1 -1
- package/dist/validator/FieldDeclarationValidator.d.ts +1 -1
- package/dist/validator/FieldDeclarationValidator.d.ts.map +1 -1
- package/dist/validator/FieldDeclarationValidator.js.map +1 -1
- package/dist/validator/FieldValueValidator.d.ts +1 -1
- package/dist/validator/FieldValueValidator.d.ts.map +1 -1
- package/dist/validator/FieldValueValidator.js.map +1 -1
- package/dist/validator/InputValidator.d.ts +4 -5
- package/dist/validator/InputValidator.d.ts.map +1 -1
- package/dist/validator/InputValidator.js.map +1 -1
- package/dist/validator/ValidateOptions.d.ts +4 -0
- package/dist/validator/ValidateOptions.d.ts.map +1 -0
- package/dist/validator/ValidateOptions.js +2 -0
- package/dist/validator/ValidateOptions.js.map +1 -0
- package/dist/vocabulary/primitive/many.d.ts +1 -1
- package/dist/vocabulary/primitive/many.d.ts.map +1 -1
- package/dist/vocabulary/primitive/many.js.map +1 -1
- package/dist/vocabulary/primitive/ref.d.ts +1 -1
- package/dist/vocabulary/primitive/ref.d.ts.map +1 -1
- package/dist/vocabulary/primitive/ref.js.map +1 -1
- package/dist/vocabulary/primitive/text.d.ts +1 -1
- package/dist/vocabulary/primitive/text.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/PartialValues.ts +4 -0
- package/src/Schema.ts +12 -32
- package/src/SchemaConstraints.ts +46 -0
- package/src/SchemaConstructor.ts +32 -0
- package/src/SchemaDefinition.ts +6 -50
- package/src/SchemaDerivation.ts +1 -1
- package/src/SchemaView.ts +6 -10
- package/src/Values.ts +6 -0
- package/src/axis/Axis.ts +2 -3
- package/src/axis/Resolver.ts +1 -0
- package/src/axis/boundary/Boundaries.ts +3 -9
- package/src/axis/boundary/Boundary.ts +7 -10
- package/src/axis/boundary/BoundaryAxis.ts +1 -1
- package/src/axis/boundary/BoundaryRef.ts +3 -0
- package/src/axis/boundary/BoundaryRules.ts +4 -0
- package/src/axis/boundary/Decoder.ts +42 -0
- package/src/axis/boundary/Encoder.ts +1 -0
- package/src/axis/lifecycle/Lifecycle.ts +1 -8
- package/src/axis/lifecycle/LifecycleAxis.ts +3 -2
- package/src/axis/lifecycle/LifecycleRules.ts +9 -0
- package/src/axis/lifecycle/apply.ts +2 -1
- package/src/axis/role/EntityConstructor.ts +1 -0
- package/src/axis/role/Relation.ts +2 -1
- package/src/axis/role/Role.ts +3 -8
- package/src/axis/role/RoleAxis.ts +7 -5
- package/src/axis/role/RoleRules.ts +8 -0
- package/src/axis/shape/FormatPredicate.ts +1 -0
- package/src/axis/shape/Formats.ts +1 -11
- package/src/axis/shape/Shape.ts +20 -24
- package/src/axis/shape/ShapeType.ts +12 -0
- package/src/axis/shape/StringFormat.ts +8 -0
- package/src/entity/CompositeUnique.ts +6 -0
- package/src/entity/EntityAdapterSet.ts +1 -1
- package/src/entity/EntityAdapters.ts +3 -4
- package/src/entity/EntityDeclarations.ts +3 -9
- package/src/entity/FougereEntityAdapters.ts +2 -0
- package/src/entity/PreviousNames.ts +6 -0
- package/src/entity.ts +3 -2
- package/src/field/Field.ts +4 -8
- package/src/field/FieldName.ts +3 -0
- package/src/field/FieldSet.ts +4 -2
- package/src/field/Fields.ts +3 -0
- package/src/index.ts +21 -19
- package/src/lib/Checked.ts +5 -0
- package/src/lib/ValidationError.ts +9 -0
- package/src/lib/ValidationResult.ts +11 -0
- package/src/projection/Cases.ts +1 -17
- package/src/projection/ValidationCase.ts +16 -0
- package/src/projection/Visibility.ts +1 -1
- package/src/projection/card/Bundle.ts +7 -4
- package/src/projection/card/Card.ts +16 -13
- package/src/projection/card/Change.ts +24 -0
- package/src/projection/card/DerivedFrom.ts +11 -0
- package/src/projection/card/{diff.ts → Diff.ts} +7 -49
- package/src/projection/card/DiffOptions.ts +4 -0
- package/src/projection/card/FieldDescriptor.ts +11 -0
- package/src/projection/card/FieldExtension.ts +9 -0
- package/src/projection/card/RelationDescriptor.ts +3 -0
- package/src/projection/card/RenameCandidate.ts +5 -0
- package/src/projection/card/RoleDescriptor.ts +7 -0
- package/src/projection/card/SchemaBundle.ts +7 -0
- package/src/projection/card/SchemaDescriptor.ts +12 -0
- package/src/projection/card/SetDiff.ts +10 -0
- package/src/projection/card/SetDiffOptions.ts +4 -0
- package/src/projection/card/ShapeKeywords.ts +7 -0
- package/src/projection/card/TypeSet.ts +2 -0
- package/src/projection/card/admission.ts +3 -3
- package/src/validator/FieldDeclarationValidator.ts +2 -1
- package/src/validator/FieldValueValidator.ts +5 -3
- package/src/validator/InputValidator.ts +5 -6
- package/src/validator/ValidateOptions.ts +3 -0
- package/src/vocabulary/primitive/many.ts +2 -1
- package/src/vocabulary/primitive/ref.ts +2 -1
- package/src/vocabulary/primitive/text.ts +1 -1
- package/dist/lib/validation.d.ts +0 -32
- package/dist/lib/validation.d.ts.map +0 -1
- package/dist/lib/validation.js.map +0 -1
- package/dist/projection/card/Descriptor.d.ts +0 -55
- package/dist/projection/card/Descriptor.d.ts.map +0 -1
- package/dist/projection/card/Descriptor.js +0 -2
- package/dist/projection/card/Descriptor.js.map +0 -1
- package/dist/projection/card/diff.d.ts +0 -104
- package/dist/projection/card/diff.d.ts.map +0 -1
- package/src/lib/validation.ts +0 -25
- package/src/projection/card/Descriptor.ts +0 -60
package/src/axis/shape/Shape.ts
CHANGED
|
@@ -1,22 +1,15 @@
|
|
|
1
1
|
import type { JSONSchema7, JSONSchema7TypeName } from 'json-schema';
|
|
2
|
-
import type { StringFormat } from './
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* The standard's own list, less `null` — a shape states that as the `[T,'null']` union —
|
|
6
|
-
* and with `string` in the three forms every projection here tells apart: a `date()`, a
|
|
7
|
-
* bounded set, and everything else. Those three are the whole of what this package adds.
|
|
8
|
-
*/
|
|
9
|
-
export type ShapeType =
|
|
10
|
-
| Exclude<JSONSchema7TypeName, 'null' | 'string'>
|
|
11
|
-
| 'text'
|
|
12
|
-
| 'date'
|
|
13
|
-
| 'choice';
|
|
2
|
+
import type { StringFormat } from './StringFormat.js';
|
|
3
|
+
import type { ShapeType } from './ShapeType.js';
|
|
14
4
|
|
|
15
5
|
type Nullably<T extends string> = T | readonly [T, 'null'];
|
|
16
6
|
|
|
17
7
|
interface StringConstraints { minLength?: number; maxLength?: number; pattern?: string; enum?: readonly (string | null)[]; format?: StringFormat }
|
|
8
|
+
|
|
18
9
|
interface NumericConstraints { minimum?: number; maximum?: number }
|
|
10
|
+
|
|
19
11
|
interface ArrayConstraints { items?: Shape; minItems?: number; maxItems?: number }
|
|
12
|
+
|
|
20
13
|
interface ObjectConstraints { properties?: Record<string, unknown>; required?: readonly string[]; additionalProperties?: boolean | Shape; propertyNames?: Shape }
|
|
21
14
|
|
|
22
15
|
export type Shape =
|
|
@@ -40,6 +33,20 @@ interface ShapeParts {
|
|
|
40
33
|
nullable: boolean;
|
|
41
34
|
}
|
|
42
35
|
|
|
36
|
+
type Assert<T extends true> = T;
|
|
37
|
+
|
|
38
|
+
type ShapeKeys<T> = T extends unknown ? keyof T : never;
|
|
39
|
+
|
|
40
|
+
type _ShapeConformsToJsonSchema = Assert<
|
|
41
|
+
[Exclude<ShapeKeys<Shape>, keyof JSONSchema7>] extends [never] ? true : false
|
|
42
|
+
>;
|
|
43
|
+
|
|
44
|
+
type _ShapeTypesAreTheStandardsLessNull = Assert<
|
|
45
|
+
[Exclude<Exclude<JSONSchema7TypeName, 'null'>, (typeof SHAPE_TYPES)[number]>] extends [never]
|
|
46
|
+
? true
|
|
47
|
+
: false
|
|
48
|
+
>;
|
|
49
|
+
|
|
43
50
|
export class Shapes {
|
|
44
51
|
static is(value: unknown): value is Shape {
|
|
45
52
|
if (typeof value !== 'object' || value === null) return false;
|
|
@@ -55,7 +62,7 @@ export class Shapes {
|
|
|
55
62
|
/**
|
|
56
63
|
* Every `pattern` a shape states, the nested ones included — `items`, `properties`.
|
|
57
64
|
*
|
|
58
|
-
* Two readers ask two questions of the same list: the card
|
|
65
|
+
* Two readers ask two questions of the same list: the card facade asks whether each one
|
|
59
66
|
* compiles, `fougere check` whether each one backtracks. Neither owns the walk.
|
|
60
67
|
*/
|
|
61
68
|
static patterns(shape: unknown): string[] {
|
|
@@ -129,14 +136,3 @@ export class Shapes {
|
|
|
129
136
|
return base.enum?.length ? 'choice' : 'text';
|
|
130
137
|
}
|
|
131
138
|
}
|
|
132
|
-
|
|
133
|
-
type Assert<T extends true> = T;
|
|
134
|
-
type ShapeKeys<T> = T extends unknown ? keyof T : never;
|
|
135
|
-
type _ShapeConformsToJsonSchema = Assert<
|
|
136
|
-
[Exclude<ShapeKeys<Shape>, keyof JSONSchema7>] extends [never] ? true : false
|
|
137
|
-
>;
|
|
138
|
-
type _ShapeTypesAreTheStandardsLessNull = Assert<
|
|
139
|
-
[Exclude<Exclude<JSONSchema7TypeName, 'null'>, (typeof SHAPE_TYPES)[number]>] extends [never]
|
|
140
|
-
? true
|
|
141
|
-
: false
|
|
142
|
-
>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { JSONSchema7TypeName } from 'json-schema';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The standard's own list, less `null` — a shape states that as the `[T,'null']` union —
|
|
5
|
+
* and with `string` in the three forms every projection here tells apart: a `date()`, a
|
|
6
|
+
* bounded set, and everything else. Those three are the whole of what this package adds.
|
|
7
|
+
*/
|
|
8
|
+
export type ShapeType =
|
|
9
|
+
| Exclude<JSONSchema7TypeName, 'null' | 'string'>
|
|
10
|
+
| 'text'
|
|
11
|
+
| 'date'
|
|
12
|
+
| 'choice';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type { FieldName
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export interface FougereEntityAdapters<K extends string> {}
|
|
1
|
+
import type { FieldName } from '../field/FieldName.js';
|
|
2
|
+
import type { Fields } from '../field/Fields.js';
|
|
3
|
+
import type { FougereEntityAdapters } from './FougereEntityAdapters.js';
|
|
5
4
|
|
|
6
5
|
export type EntityAdapters<TFields extends Fields> = Readonly<
|
|
7
6
|
Partial<FougereEntityAdapters<FieldName<TFields>>>
|
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Fields } from '../field/Fields.js';
|
|
2
2
|
import type { EntityAdapters } from './EntityAdapters.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export type CompositeUnique<TFields extends Fields> =
|
|
6
|
-
readonly (readonly FieldName<TFields>[])[];
|
|
7
|
-
|
|
8
|
-
export type PreviousNames<TFields extends Fields> = Readonly<
|
|
9
|
-
Partial<Record<FieldName<TFields>, string>>
|
|
10
|
-
>;
|
|
3
|
+
import type { CompositeUnique } from './CompositeUnique.js';
|
|
4
|
+
import type { PreviousNames } from './PreviousNames.js';
|
|
11
5
|
|
|
12
6
|
export interface EntityDeclarations<TFields extends Fields> {
|
|
13
7
|
adapters?: EntityAdapters<TFields>;
|
package/src/entity.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { type Fields } from './field/
|
|
1
|
+
import { type Fields } from './field/Fields.js';
|
|
2
2
|
import { type EntityDeclarations } from './entity/EntityDeclarations.js';
|
|
3
|
-
import { Schema
|
|
3
|
+
import { Schema } from './Schema.js';
|
|
4
|
+
import { type SchemaConstructor } from './SchemaConstructor.js';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* The one call everything derives from: the fields, and what the entity states about them.
|
package/src/field/Field.ts
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
import type { Shape } from '../axis/shape/Shape.js';
|
|
2
|
-
import type { RoleRules } from '../axis/role/
|
|
3
|
-
import type { LifecycleRules } from '../axis/lifecycle/
|
|
4
|
-
import type { BoundaryRef } from '../axis/boundary/
|
|
2
|
+
import type { RoleRules } from '../axis/role/RoleRules.js';
|
|
3
|
+
import type { LifecycleRules } from '../axis/lifecycle/LifecycleRules.js';
|
|
4
|
+
import type { BoundaryRef } from '../axis/boundary/BoundaryRef.js';
|
|
5
5
|
import type { Meta } from './Meta.js';
|
|
6
6
|
import type { Axis } from '../axis/Axis.js';
|
|
7
7
|
import { FieldDeclarationValidator } from '../validator/FieldDeclarationValidator.js';
|
|
8
8
|
import { FieldValueValidator } from '../validator/FieldValueValidator.js';
|
|
9
|
-
import { dotted } from '../lib/
|
|
10
|
-
|
|
11
|
-
export type Fields = Record<string, Field>;
|
|
12
|
-
|
|
13
|
-
export type FieldName<TFields extends Fields> = Extract<keyof TFields, string>;
|
|
9
|
+
import { dotted } from '../lib/ValidationResult.js';
|
|
14
10
|
|
|
15
11
|
type FieldDeclaration = Pick<Field, 'shape' | Axis['slot'] | 'meta'>;
|
|
16
12
|
|
package/src/field/FieldSet.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Role } from '../axis/role/Role.js';
|
|
2
|
-
import type { CompositeUnique } from '../entity/
|
|
3
|
-
import { Field
|
|
2
|
+
import type { CompositeUnique } from '../entity/CompositeUnique.js';
|
|
3
|
+
import { Field } from './Field.js';
|
|
4
|
+
import { type FieldName } from './FieldName.js';
|
|
5
|
+
import { type Fields } from './Fields.js';
|
|
4
6
|
|
|
5
7
|
export class FieldSet<TFields extends Fields = Fields> {
|
|
6
8
|
private constructor(private readonly fields: TFields) {}
|
package/src/index.ts
CHANGED
|
@@ -2,41 +2,43 @@ export { entity } from './entity.js';
|
|
|
2
2
|
|
|
3
3
|
export * from './vocabulary/index.js';
|
|
4
4
|
|
|
5
|
-
export {
|
|
5
|
+
export { ANONYMOUS_SCHEMA_NAME, Schema } from './Schema.js';
|
|
6
|
+
export { type SchemaConstructor } from './SchemaConstructor.js';
|
|
6
7
|
export { type SchemaView } from './SchemaView.js';
|
|
7
|
-
export { Field
|
|
8
|
+
export { Field } from './field/Field.js';
|
|
9
|
+
export { type Fields } from './field/Fields.js';
|
|
8
10
|
export { FieldSet } from './field/FieldSet.js';
|
|
9
|
-
export { type Shape
|
|
11
|
+
export { type Shape } from './axis/shape/Shape.js';
|
|
12
|
+
export { type ShapeType } from './axis/shape/ShapeType.js';
|
|
13
|
+
export { Shapes } from './axis/shape/Shape.js';
|
|
10
14
|
export { Role } from './axis/role/Role.js';
|
|
11
|
-
export { type EntityConstructor } from './axis/role/
|
|
15
|
+
export { type EntityConstructor } from './axis/role/EntityConstructor.js';
|
|
12
16
|
export { Lifecycle } from './axis/lifecycle/Lifecycle.js';
|
|
13
17
|
export { Boundary } from './axis/boundary/Boundary.js';
|
|
14
18
|
export { applyCreate, applyUpdate } from './axis/lifecycle/apply.js';
|
|
15
19
|
export { InputRefusal } from './validator/InputRefusal.js';
|
|
16
|
-
export {
|
|
20
|
+
export { type ValidationError } from './lib/ValidationError.js';
|
|
21
|
+
export { dotted, type ValidationResult } from './lib/ValidationResult.js';
|
|
17
22
|
|
|
18
23
|
export { Card } from './projection/card/Card.js';
|
|
19
24
|
export { Bundle } from './projection/card/Bundle.js';
|
|
20
25
|
export { Visibility } from './projection/Visibility.js';
|
|
21
|
-
export { Cases
|
|
22
|
-
export type
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
} from './projection/card/
|
|
27
|
-
export type {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
SetDiff,
|
|
31
|
-
SetDiffOptions,
|
|
32
|
-
} from './projection/card/diff.js';
|
|
26
|
+
export { Cases } from './projection/Cases.js';
|
|
27
|
+
export { type ValidationCase } from './projection/ValidationCase.js';
|
|
28
|
+
export type { FieldDescriptor } from './projection/card/FieldDescriptor.js';
|
|
29
|
+
export type { SchemaBundle } from './projection/card/SchemaBundle.js';
|
|
30
|
+
export type { SchemaDescriptor } from './projection/card/SchemaDescriptor.js';
|
|
31
|
+
export type { Change } from './projection/card/Change.js';
|
|
32
|
+
export type { Diff } from './projection/card/Diff.js';
|
|
33
|
+
export type { SetDiff } from './projection/card/SetDiff.js';
|
|
34
|
+
export type { SetDiffOptions } from './projection/card/SetDiffOptions.js';
|
|
33
35
|
|
|
34
36
|
export * from './lib/index.js';
|
|
35
37
|
export { Formats } from './axis/shape/Formats.js';
|
|
36
38
|
export { Generators } from './axis/lifecycle/Generators.js';
|
|
37
|
-
export { Boundaries } from './axis/boundary/
|
|
39
|
+
export { Boundaries } from './axis/boundary/Decoder.js';
|
|
38
40
|
export { Clock } from './axis/lifecycle/Clock.js';
|
|
39
|
-
export { type FougereEntityAdapters } from './entity/
|
|
41
|
+
export { type FougereEntityAdapters } from './entity/FougereEntityAdapters.js';
|
|
40
42
|
export { InputValidator } from './validator/InputValidator.js';
|
|
41
43
|
export { FieldValueValidator } from './validator/FieldValueValidator.js';
|
|
42
44
|
export { AdapterFieldValidator } from './validator/AdapterFieldValidator.js';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface ValidationError {
|
|
2
|
+
/**
|
|
3
|
+
* Where the refusal happened: the field, then where under it the shape refused.
|
|
4
|
+
* Empty when the input itself is refused. Segments, never a sentence — a field may
|
|
5
|
+
* legally be named `a.b`, and re-parsing a joined path invents a segment it never had.
|
|
6
|
+
*/
|
|
7
|
+
path: readonly string[];
|
|
8
|
+
message: string;
|
|
9
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ValidationError } from './ValidationError.js';
|
|
2
|
+
|
|
3
|
+
export type ValidationResult<T> =
|
|
4
|
+
| { success: true; data: T }
|
|
5
|
+
| { success: false; errors: ValidationError[] };
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A path as a message writes it — `addr.street`. One rendering among others, and the
|
|
9
|
+
* reason the value stays segmented: this one cannot be read back.
|
|
10
|
+
*/
|
|
11
|
+
export const dotted = (path: readonly string[]): string => path.join('.');
|
package/src/projection/Cases.ts
CHANGED
|
@@ -6,23 +6,7 @@ import type { Field } from '../field/Field.js';
|
|
|
6
6
|
import type { SchemaView } from '../SchemaView.js';
|
|
7
7
|
import { InputValidator } from '../validator/InputValidator.js';
|
|
8
8
|
import { InputRefusal } from '../validator/InputRefusal.js';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* One input, and what the validator must answer.
|
|
12
|
-
*
|
|
13
|
-
* `expect` carries the PATH of the field at fault and never the message. We know which
|
|
14
|
-
* field must be refused because we are the ones who broke it; naming the message would
|
|
15
|
-
* make this list a second validator, and the two would then have to be kept in step by hand —
|
|
16
|
-
* which is the duplication the whole thing exists to remove.
|
|
17
|
-
*/
|
|
18
|
-
export interface ValidationCase {
|
|
19
|
-
/** What this input does, in one clause — carried into the assertion so a failure reads. */
|
|
20
|
-
why: string;
|
|
21
|
-
input: unknown;
|
|
22
|
-
/** Judged as an update rather than a creation. */
|
|
23
|
-
patch: boolean;
|
|
24
|
-
expect: 'accept' | { reject: string };
|
|
25
|
-
}
|
|
9
|
+
import type { ValidationCase } from './ValidationCase.js';
|
|
26
10
|
|
|
27
11
|
/**
|
|
28
12
|
* A value of the wrong type, so every field yields at least one case whatever it declares.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One input, and what the validator must answer.
|
|
3
|
+
*
|
|
4
|
+
* `expect` carries the PATH of the field at fault and never the message. We know which
|
|
5
|
+
* field must be refused because we are the ones who broke it; naming the message would
|
|
6
|
+
* make this list a second validator, and the two would then have to be kept in step by hand —
|
|
7
|
+
* which is the duplication the whole thing exists to remove.
|
|
8
|
+
*/
|
|
9
|
+
export interface ValidationCase {
|
|
10
|
+
/** What this input does, in one clause — carried into the assertion so a failure reads. */
|
|
11
|
+
why: string;
|
|
12
|
+
input: unknown;
|
|
13
|
+
/** Judged as an update rather than a creation. */
|
|
14
|
+
patch: boolean;
|
|
15
|
+
expect: 'accept' | { reject: string };
|
|
16
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Boundary } from '../axis/boundary/Boundary.js';
|
|
2
2
|
import { Lifecycle } from '../axis/lifecycle/Lifecycle.js';
|
|
3
3
|
import { Role } from '../axis/role/Role.js';
|
|
4
|
-
import type { Fields } from '../field/
|
|
4
|
+
import type { Fields } from '../field/Fields.js';
|
|
5
5
|
|
|
6
6
|
export class Visibility {
|
|
7
7
|
private constructor(private readonly fields: Fields) {}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import type { Resolver } from '../../axis/
|
|
2
|
-
import type { EntityConstructor } from '../../axis/role/
|
|
1
|
+
import type { Resolver } from '../../axis/Resolver.js';
|
|
2
|
+
import type { EntityConstructor } from '../../axis/role/EntityConstructor.js';
|
|
3
3
|
import { lowerFirst } from '../../lib/utils.js';
|
|
4
4
|
import type { SchemaView } from '../../SchemaView.js';
|
|
5
5
|
import { Card } from './Card.js';
|
|
6
|
-
import type { SchemaBundle
|
|
7
|
-
import type {
|
|
6
|
+
import type { SchemaBundle } from './SchemaBundle.js';
|
|
7
|
+
import type { SchemaDescriptor } from './SchemaDescriptor.js';
|
|
8
|
+
import type { Diff } from './Diff.js';
|
|
9
|
+
import type { SetDiff } from './SetDiff.js';
|
|
10
|
+
import type { SetDiffOptions } from './SetDiffOptions.js';
|
|
8
11
|
|
|
9
12
|
type SchemaSet = Record<string, SchemaView> | SchemaView[];
|
|
10
13
|
|
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
import { EXTENSION_AXES
|
|
1
|
+
import { EXTENSION_AXES } from '../../axis/Axis.js';
|
|
2
|
+
import { type Resolver } from '../../axis/Resolver.js';
|
|
2
3
|
import { clean, isObject } from '../../lib/utils.js';
|
|
3
|
-
import { Field
|
|
4
|
-
import {
|
|
4
|
+
import { Field } from '../../field/Field.js';
|
|
5
|
+
import { type Fields } from '../../field/Fields.js';
|
|
6
|
+
import { SchemaConstraints } from '../../SchemaConstraints.js';
|
|
5
7
|
import { InputValidator } from '../../validator/InputValidator.js';
|
|
6
|
-
import { Schema
|
|
7
|
-
import
|
|
8
|
+
import { Schema } from '../../Schema.js';
|
|
9
|
+
import { type SchemaConstructor } from '../../SchemaConstructor.js';
|
|
10
|
+
import type { SchemaView } from '../../SchemaView.js';
|
|
11
|
+
import type { Values } from '../../Values.js';
|
|
8
12
|
import { admitPatterns, refuse } from './admission.js';
|
|
9
|
-
import type {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
} from './
|
|
15
|
-
import { compare, type Diff, type DiffOptions } from './diff.js';
|
|
13
|
+
import type { DerivedFrom } from './DerivedFrom.js';
|
|
14
|
+
import type { FieldDescriptor } from './FieldDescriptor.js';
|
|
15
|
+
import type { FieldExtension } from './FieldExtension.js';
|
|
16
|
+
import type { SchemaDescriptor } from './SchemaDescriptor.js';
|
|
17
|
+
import { compare, type Diff } from './Diff.js';
|
|
18
|
+
import { type DiffOptions } from './DiffOptions.js';
|
|
16
19
|
|
|
17
20
|
type FieldsOf<T> = { [K in keyof T]-?: Field<T[K]> };
|
|
18
21
|
|
|
@@ -74,7 +77,7 @@ export class Card<T = Values<Fields>> {
|
|
|
74
77
|
const descriptor = this.descriptor;
|
|
75
78
|
const subject = name ? `schema '${name}'` : 'this schema';
|
|
76
79
|
if (!isObject(descriptor))
|
|
77
|
-
refuse(`${subject} is not an object`, 'A card carries one JSON Schema per
|
|
80
|
+
refuse(`${subject} is not an object`, 'A card carries one JSON Schema per facade.');
|
|
78
81
|
const version = descriptor['x-fougere-version'];
|
|
79
82
|
if (version !== 1) {
|
|
80
83
|
refuse(
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { BoundaryRef } from '../../axis/boundary/BoundaryRef.js';
|
|
2
|
+
import type { LifecycleRules } from '../../axis/lifecycle/LifecycleRules.js';
|
|
3
|
+
import type { FieldDescriptor } from './FieldDescriptor.js';
|
|
4
|
+
import type { RoleDescriptor } from './RoleDescriptor.js';
|
|
5
|
+
import type { TypeSet } from './TypeSet.js';
|
|
6
|
+
|
|
7
|
+
/** One named difference, at one place. Each kind exists because a reader asks for it. */
|
|
8
|
+
export type Change =
|
|
9
|
+
/** DDL: add the column. Codec: the old caller never sends it. Boot: refuse when required. */
|
|
10
|
+
| { kind: 'added'; field: string; to: FieldDescriptor; required: boolean }
|
|
11
|
+
/** DDL: drop the column. Codec: the old caller still sends it, and it goes nowhere. */
|
|
12
|
+
| { kind: 'removed'; field: string; from: FieldDescriptor; required: boolean }
|
|
13
|
+
/** DDL: rename the column. Codec and storage: one more entry in the field-to-column map. */
|
|
14
|
+
| { kind: 'renamed'; from: string; to: string; field: FieldDescriptor }
|
|
15
|
+
/** DDL: alter the type. Codec: convert the value, when it can. */
|
|
16
|
+
| { kind: 'retyped'; field: string; from: TypeSet; to: TypeSet }
|
|
17
|
+
/** Same type, different bounds: a CHECK moves, and a value legal yesterday may not be. */
|
|
18
|
+
| { kind: 'reshaped'; field: string; from: FieldDescriptor; to: FieldDescriptor }
|
|
19
|
+
/** NOT NULL in either direction. Boot: an old writer cannot fill what it never knew. */
|
|
20
|
+
| { kind: 'required'; field: string; from: boolean; to: boolean }
|
|
21
|
+
/** An axis other than shape was restated. */
|
|
22
|
+
| { kind: 'restated'; field: string; axis: 'role'; from?: RoleDescriptor; to?: RoleDescriptor }
|
|
23
|
+
| { kind: 'restated'; field: string; axis: 'lifecycle'; from?: LifecycleRules; to?: LifecycleRules }
|
|
24
|
+
| { kind: 'restated'; field: string; axis: 'boundary'; from?: BoundaryRef; to?: BoundaryRef };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a derivation was cut from, and what the cut left — `nameOf` keyed by the
|
|
3
|
+
* ORIGIN's field names. Absent on a declaration that derives from nothing.
|
|
4
|
+
*
|
|
5
|
+
* A dropped field is `null` and never `undefined`: JSON.stringify erases the second,
|
|
6
|
+
* which would leave the card saying only what remains — what `properties` already says.
|
|
7
|
+
*/
|
|
8
|
+
export interface DerivedFrom {
|
|
9
|
+
from: string;
|
|
10
|
+
nameOf: Record<string, string | null>;
|
|
11
|
+
}
|
|
@@ -1,36 +1,13 @@
|
|
|
1
|
-
import type { BoundaryRef } from '../../axis/boundary/Boundary.js';
|
|
2
|
-
import type { LifecycleRules } from '../../axis/lifecycle/Lifecycle.js';
|
|
3
1
|
import { dequal } from 'dequal';
|
|
4
2
|
import { EXTENSION_SLOTS } from '../../axis/Axis.js';
|
|
5
|
-
import type { FieldDescriptor
|
|
3
|
+
import type { FieldDescriptor } from './FieldDescriptor.js';
|
|
4
|
+
import type { FieldExtension } from './FieldExtension.js';
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
| { kind: 'removed'; field: string; from: FieldDescriptor; required: boolean }
|
|
13
|
-
/** DDL: rename the column. Codec and storage: one more entry in the field-to-column map. */
|
|
14
|
-
| { kind: 'renamed'; from: string; to: string; field: FieldDescriptor }
|
|
15
|
-
/** DDL: alter the type. Codec: convert the value, when it can. */
|
|
16
|
-
| { kind: 'retyped'; field: string; from: TypeSet; to: TypeSet }
|
|
17
|
-
/** Same type, different bounds: a CHECK moves, and a value legal yesterday may not be. */
|
|
18
|
-
| { kind: 'reshaped'; field: string; from: FieldDescriptor; to: FieldDescriptor }
|
|
19
|
-
/** NOT NULL in either direction. Boot: an old writer cannot fill what it never knew. */
|
|
20
|
-
| { kind: 'required'; field: string; from: boolean; to: boolean }
|
|
21
|
-
/** An axis other than shape was restated. */
|
|
22
|
-
| { kind: 'restated'; field: string; axis: 'role'; from?: RoleDescriptor; to?: RoleDescriptor }
|
|
23
|
-
| { kind: 'restated'; field: string; axis: 'lifecycle'; from?: LifecycleRules; to?: LifecycleRules }
|
|
24
|
-
| { kind: 'restated'; field: string; axis: 'boundary'; from?: BoundaryRef; to?: BoundaryRef };
|
|
25
|
-
|
|
26
|
-
/** A field's declared types, always represented as a set. */
|
|
27
|
-
export type TypeSet = string[];
|
|
28
|
-
|
|
29
|
-
/** A removal and an addition that could be one rename: same shape, different name. */
|
|
30
|
-
export interface RenameCandidate {
|
|
31
|
-
removed: string;
|
|
32
|
-
added: string;
|
|
33
|
-
}
|
|
6
|
+
import type { SchemaDescriptor } from './SchemaDescriptor.js';
|
|
7
|
+
import type { Change } from './Change.js';
|
|
8
|
+
import type { TypeSet } from './TypeSet.js';
|
|
9
|
+
import type { RenameCandidate } from './RenameCandidate.js';
|
|
10
|
+
import type { DiffOptions } from './DiffOptions.js';
|
|
34
11
|
|
|
35
12
|
export interface Diff {
|
|
36
13
|
changes: Change[];
|
|
@@ -38,25 +15,6 @@ export interface Diff {
|
|
|
38
15
|
ambiguous: RenameCandidate[];
|
|
39
16
|
}
|
|
40
17
|
|
|
41
|
-
export interface DiffOptions {
|
|
42
|
-
/** Renames as declared at the time: old name to new name. */
|
|
43
|
-
renamed?: Record<string, string>;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export interface SetDiff {
|
|
47
|
-
/** Entities the target bundle has and the source bundle had not. */
|
|
48
|
-
entitiesAdded: string[];
|
|
49
|
-
/** Entities the source bundle had and the target bundle has not. */
|
|
50
|
-
entitiesRemoved: string[];
|
|
51
|
-
/** Differences for entities present in both bundles; unchanged entities are absent. */
|
|
52
|
-
entities: Record<string, Diff>;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export interface SetDiffOptions {
|
|
56
|
-
/** Declared renames, per entity: `{ post: { body: 'content' } }`. */
|
|
57
|
-
renamed?: Record<string, Record<string, string>>;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
18
|
/**
|
|
61
19
|
* What changed between two descriptions of the same entity, read from the wire form alone.
|
|
62
20
|
* FR : ce qui a changé entre deux descriptions d'une même entité, lu du seul format du fil.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ShapeKeywords } from './ShapeKeywords.js';
|
|
2
|
+
import type { JSONSchema7TypeName } from 'json-schema';
|
|
3
|
+
import type { FieldExtension } from './FieldExtension.js';
|
|
4
|
+
|
|
5
|
+
export type FieldDescriptor = ShapeKeywords & {
|
|
6
|
+
type?: JSONSchema7TypeName | JSONSchema7TypeName[];
|
|
7
|
+
items?: FieldDescriptor;
|
|
8
|
+
properties?: Record<string, FieldDescriptor>;
|
|
9
|
+
description?: string;
|
|
10
|
+
'x-fougere'?: FieldExtension;
|
|
11
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { BoundaryRef } from '../../axis/boundary/BoundaryRef.js';
|
|
2
|
+
import type { LifecycleRules } from '../../axis/lifecycle/LifecycleRules.js';
|
|
3
|
+
import type { RoleDescriptor } from './RoleDescriptor.js';
|
|
4
|
+
|
|
5
|
+
export interface FieldExtension {
|
|
6
|
+
role?: RoleDescriptor;
|
|
7
|
+
lifecycle?: LifecycleRules;
|
|
8
|
+
boundary?: BoundaryRef;
|
|
9
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { FieldDescriptor } from './FieldDescriptor.js';
|
|
2
|
+
import type { DerivedFrom } from './DerivedFrom.js';
|
|
3
|
+
|
|
4
|
+
export interface SchemaDescriptor {
|
|
5
|
+
title?: string;
|
|
6
|
+
type: 'object';
|
|
7
|
+
properties: Record<string, FieldDescriptor>;
|
|
8
|
+
required?: string[];
|
|
9
|
+
'x-fougere-derived'?: DerivedFrom;
|
|
10
|
+
'x-fougere-version': 1;
|
|
11
|
+
'x-fougere-vendor': 'fougere';
|
|
12
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Diff } from './Diff.js';
|
|
2
|
+
|
|
3
|
+
export interface SetDiff {
|
|
4
|
+
/** Entities the target bundle has and the source bundle had not. */
|
|
5
|
+
entitiesAdded: string[];
|
|
6
|
+
/** Entities the source bundle had and the target bundle has not. */
|
|
7
|
+
entitiesRemoved: string[];
|
|
8
|
+
/** Differences for entities present in both bundles; unchanged entities are absent. */
|
|
9
|
+
entities: Record<string, Diff>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Shape } from '../../axis/shape/Shape.js';
|
|
2
|
+
|
|
3
|
+
type KeywordsOf<S> = S extends unknown ? Partial<Omit<S, 'type' | 'items' | 'properties'>> : never;
|
|
4
|
+
type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
5
|
+
|
|
6
|
+
/** Every keyword any shape may carry, flattened — what a descriptor records of one. */
|
|
7
|
+
export type ShapeKeywords = UnionToIntersection<KeywordsOf<Shape>>;
|