@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
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ValidationError } from '../../lib/
|
|
1
|
+
import type { ValidationError } from '../../lib/ValidationError.js';
|
|
2
2
|
import { Shapes } from '../../axis/shape/Shape.js';
|
|
3
|
-
import { dotted } from '../../lib/
|
|
3
|
+
import { dotted } from '../../lib/ValidationResult.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Throws with what is wrong AND what to write: a card's author is in another process.
|
|
@@ -43,7 +43,7 @@ export const oneOfTokens = <T extends readonly string[]>(
|
|
|
43
43
|
): value is T[number] => typeof value === 'string' && (tokens as readonly string[]).includes(value);
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
|
-
* Compiles every `pattern` at the
|
|
46
|
+
* Compiles every `pattern` at the facade, so a bad one is refused here and not at the first row.
|
|
47
47
|
* FR : compile chaque `pattern` à la porte : un mauvais est refusé ici, pas au premier row.
|
|
48
48
|
* `{ type: 'string', pattern: '(' }` → `Field 'code' states pattern: "(", which is not a regular expression`
|
|
49
49
|
*/
|
|
@@ -2,7 +2,8 @@ import { EXTENSION_AXES } from '../axis/Axis.js';
|
|
|
2
2
|
import { Shapes } from '../axis/shape/Shape.js';
|
|
3
3
|
import type { Field } from '../field/Field.js';
|
|
4
4
|
import { isObject, shown } from '../lib/utils.js';
|
|
5
|
-
import type { ValidationError
|
|
5
|
+
import type { ValidationError } from '../lib/ValidationError.js';
|
|
6
|
+
import type { ValidationResult } from '../lib/ValidationResult.js';
|
|
6
7
|
|
|
7
8
|
export class FieldDeclarationValidator {
|
|
8
9
|
private constructor(private readonly declaration: unknown) {}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { Validator, format as engineFormats } from '@cfworker/json-schema';
|
|
2
2
|
import { Boundary } from '../axis/boundary/Boundary.js';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { type FormatPredicate } from '../axis/shape/FormatPredicate.js';
|
|
4
|
+
import { Formats } from '../axis/shape/Formats.js';
|
|
5
|
+
import { type Shape } from '../axis/shape/Shape.js';
|
|
6
|
+
import { Shapes } from '../axis/shape/Shape.js';
|
|
5
7
|
import type { Field } from '../field/Field.js';
|
|
6
|
-
import type { Checked } from '../lib/
|
|
8
|
+
import type { Checked } from '../lib/Checked.js';
|
|
7
9
|
import type { OutputUnit } from '@cfworker/json-schema';
|
|
8
10
|
|
|
9
11
|
interface ShapePlan {
|
|
@@ -1,14 +1,13 @@
|
|
|
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 { Field
|
|
5
|
-
import type {
|
|
4
|
+
import type { Field } from '../field/Field.js';
|
|
5
|
+
import type { Fields } from '../field/Fields.js';
|
|
6
|
+
import type { ValidationError } from '../lib/ValidationError.js';
|
|
7
|
+
import type { ValidationResult } from '../lib/ValidationResult.js';
|
|
6
8
|
import { FieldValueValidator } from './FieldValueValidator.js';
|
|
7
9
|
import { InputRefusal } from './InputRefusal.js';
|
|
8
|
-
|
|
9
|
-
export interface ValidateOptions {
|
|
10
|
-
patch?: boolean;
|
|
11
|
-
}
|
|
10
|
+
import type { ValidateOptions } from './ValidateOptions.js';
|
|
12
11
|
|
|
13
12
|
export class InputValidator {
|
|
14
13
|
private constructor(
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type EntityConstructor } from '../../axis/role/EntityConstructor.js';
|
|
2
|
+
import { Relation } from '../../axis/role/Relation.js';
|
|
2
3
|
import { Field } from '../../field/Field.js';
|
|
3
4
|
|
|
4
5
|
/**
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type EntityConstructor } from '../../axis/role/EntityConstructor.js';
|
|
2
|
+
import { Relation } from '../../axis/role/Relation.js';
|
|
2
3
|
import { Field } from '../../field/Field.js';
|
|
3
4
|
|
|
4
5
|
export interface RefOptions {
|
package/dist/lib/validation.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
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
|
-
}
|
|
10
|
-
export type ValidationResult<T> = {
|
|
11
|
-
success: true;
|
|
12
|
-
data: T;
|
|
13
|
-
} | {
|
|
14
|
-
success: false;
|
|
15
|
-
errors: ValidationError[];
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* A field's verdict. `path` is where INSIDE the value the refusal happened — empty when the
|
|
19
|
-
* field itself is refused, `['street']` when the shape below it is.
|
|
20
|
-
*/
|
|
21
|
-
export type Checked = {
|
|
22
|
-
value: unknown;
|
|
23
|
-
} | {
|
|
24
|
-
error: string;
|
|
25
|
-
path?: readonly string[];
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* A path as a message writes it — `addr.street`. One rendering among others, and the
|
|
29
|
-
* reason the value stays segmented: this one cannot be read back.
|
|
30
|
-
*/
|
|
31
|
-
export declare const dotted: (path: readonly string[]) => string;
|
|
32
|
-
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/lib/validation.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B;;;;OAIG;IACH,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAC1B;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,CAAC,CAAA;CAAE,GAC1B;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,eAAe,EAAE,CAAA;CAAE,CAAC;AAElD;;;GAGG;AACH,MAAM,MAAM,OAAO,GAAG;IAAE,KAAK,EAAE,OAAO,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAC;AAEvF;;;GAGG;AACH,eAAO,MAAM,MAAM,SAAU,SAAS,MAAM,EAAE,KAAG,MAAwB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/lib/validation.ts"],"names":[],"mappings":"AAoBA;;;GAGG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,IAAuB,EAAU,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC"}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import type { BoundaryRef } from '../../axis/boundary/Boundary.js';
|
|
2
|
-
import type { LifecycleRules } from '../../axis/lifecycle/Lifecycle.js';
|
|
3
|
-
import type { Relation } from '../../axis/role/Relation.js';
|
|
4
|
-
import type { RoleRules } from '../../axis/role/Role.js';
|
|
5
|
-
import type { JSONSchema7TypeName } from 'json-schema';
|
|
6
|
-
import type { Shape } from '../../axis/shape/Shape.js';
|
|
7
|
-
type ShapeKeywords = UnionToIntersection<KeywordsOf<Shape>>;
|
|
8
|
-
type KeywordsOf<S> = S extends unknown ? Partial<Omit<S, 'type' | 'items' | 'properties'>> : never;
|
|
9
|
-
type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
10
|
-
export type FieldDescriptor = ShapeKeywords & {
|
|
11
|
-
type?: JSONSchema7TypeName | JSONSchema7TypeName[];
|
|
12
|
-
items?: FieldDescriptor;
|
|
13
|
-
properties?: Record<string, FieldDescriptor>;
|
|
14
|
-
description?: string;
|
|
15
|
-
'x-fougere'?: FieldExtension;
|
|
16
|
-
};
|
|
17
|
-
export interface FieldExtension {
|
|
18
|
-
role?: RoleDescriptor;
|
|
19
|
-
lifecycle?: LifecycleRules;
|
|
20
|
-
boundary?: BoundaryRef;
|
|
21
|
-
}
|
|
22
|
-
export type RoleDescriptor = Pick<RoleRules, 'primary' | 'index'> & {
|
|
23
|
-
unique?: string[][];
|
|
24
|
-
relation?: RelationDescriptor;
|
|
25
|
-
};
|
|
26
|
-
export type RelationDescriptor = Pick<Relation, 'kind' | 'onDelete'> & {
|
|
27
|
-
to: string;
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* What a derivation was cut from, and what the cut left — `nameOf` keyed by the
|
|
31
|
-
* ORIGIN's field names. Absent on a declaration that derives from nothing.
|
|
32
|
-
*
|
|
33
|
-
* A dropped field is `null` and never `undefined`: JSON.stringify erases the second,
|
|
34
|
-
* which would leave the card saying only what remains — what `properties` already says.
|
|
35
|
-
*/
|
|
36
|
-
export interface DerivedFrom {
|
|
37
|
-
from: string;
|
|
38
|
-
nameOf: Record<string, string | null>;
|
|
39
|
-
}
|
|
40
|
-
export interface SchemaDescriptor {
|
|
41
|
-
title?: string;
|
|
42
|
-
type: 'object';
|
|
43
|
-
properties: Record<string, FieldDescriptor>;
|
|
44
|
-
required?: string[];
|
|
45
|
-
'x-fougere-derived'?: DerivedFrom;
|
|
46
|
-
'x-fougere-version': 1;
|
|
47
|
-
'x-fougere-vendor': 'fougere';
|
|
48
|
-
}
|
|
49
|
-
export interface SchemaBundle {
|
|
50
|
-
$defs: Record<string, SchemaDescriptor>;
|
|
51
|
-
'x-fougere-version': 1;
|
|
52
|
-
'x-fougere-vendor': 'fougere';
|
|
53
|
-
}
|
|
54
|
-
export {};
|
|
55
|
-
//# sourceMappingURL=Descriptor.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Descriptor.d.ts","sourceRoot":"","sources":["../../../src/projection/card/Descriptor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAEvD,KAAK,aAAa,GAAG,mBAAmB,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;AAE5D,KAAK,UAAU,CAAC,CAAC,IAAI,CAAC,SAAS,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,YAAY,CAAC,CAAC,GAAG,KAAK,CAAC;AACnG,KAAK,mBAAmB,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,OAAO,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK,IAAI,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,EAAE,MAAM,CAAC,KAAK,IAAI,GAAG,CAAC,GAAG,KAAK,CAAC;AAEpH,MAAM,MAAM,eAAe,GAAG,aAAa,GAAG;IAC5C,IAAI,CAAC,EAAE,mBAAmB,GAAG,mBAAmB,EAAE,CAAC;IACnD,KAAK,CAAC,EAAE,eAAe,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAC7C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,cAAc,CAAC;CAC9B,CAAC;AAEF,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,SAAS,CAAC,EAAE,cAAc,CAAC;IAC3B,QAAQ,CAAC,EAAE,WAAW,CAAC;CACxB;AAED,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,GAAG;IAClE,MAAM,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC;IACpB,QAAQ,CAAC,EAAE,kBAAkB,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU,CAAC,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtF;;;;;;GAMG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;CACvC;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,QAAQ,CAAC;IACf,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAC5C,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,mBAAmB,CAAC,EAAE,WAAW,CAAC;IAClC,mBAAmB,EAAE,CAAC,CAAC;IACvB,kBAAkB,EAAE,SAAS,CAAC;CAC/B;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IACxC,mBAAmB,EAAE,CAAC,CAAC;IACvB,kBAAkB,EAAE,SAAS,CAAC;CAC/B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Descriptor.js","sourceRoot":"","sources":["../../../src/projection/card/Descriptor.ts"],"names":[],"mappings":""}
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import type { BoundaryRef } from '../../axis/boundary/Boundary.js';
|
|
2
|
-
import type { LifecycleRules } from '../../axis/lifecycle/Lifecycle.js';
|
|
3
|
-
import type { FieldDescriptor, RoleDescriptor, SchemaDescriptor } from './Descriptor.js';
|
|
4
|
-
/** One named difference, at one place. Each kind exists because a reader asks for it. */
|
|
5
|
-
export type Change =
|
|
6
|
-
/** DDL: add the column. Codec: the old caller never sends it. Boot: refuse when required. */
|
|
7
|
-
{
|
|
8
|
-
kind: 'added';
|
|
9
|
-
field: string;
|
|
10
|
-
to: FieldDescriptor;
|
|
11
|
-
required: boolean;
|
|
12
|
-
}
|
|
13
|
-
/** DDL: drop the column. Codec: the old caller still sends it, and it goes nowhere. */
|
|
14
|
-
| {
|
|
15
|
-
kind: 'removed';
|
|
16
|
-
field: string;
|
|
17
|
-
from: FieldDescriptor;
|
|
18
|
-
required: boolean;
|
|
19
|
-
}
|
|
20
|
-
/** DDL: rename the column. Codec and storage: one more entry in the field-to-column map. */
|
|
21
|
-
| {
|
|
22
|
-
kind: 'renamed';
|
|
23
|
-
from: string;
|
|
24
|
-
to: string;
|
|
25
|
-
field: FieldDescriptor;
|
|
26
|
-
}
|
|
27
|
-
/** DDL: alter the type. Codec: convert the value, when it can. */
|
|
28
|
-
| {
|
|
29
|
-
kind: 'retyped';
|
|
30
|
-
field: string;
|
|
31
|
-
from: TypeSet;
|
|
32
|
-
to: TypeSet;
|
|
33
|
-
}
|
|
34
|
-
/** Same type, different bounds: a CHECK moves, and a value legal yesterday may not be. */
|
|
35
|
-
| {
|
|
36
|
-
kind: 'reshaped';
|
|
37
|
-
field: string;
|
|
38
|
-
from: FieldDescriptor;
|
|
39
|
-
to: FieldDescriptor;
|
|
40
|
-
}
|
|
41
|
-
/** NOT NULL in either direction. Boot: an old writer cannot fill what it never knew. */
|
|
42
|
-
| {
|
|
43
|
-
kind: 'required';
|
|
44
|
-
field: string;
|
|
45
|
-
from: boolean;
|
|
46
|
-
to: boolean;
|
|
47
|
-
}
|
|
48
|
-
/** An axis other than shape was restated. */
|
|
49
|
-
| {
|
|
50
|
-
kind: 'restated';
|
|
51
|
-
field: string;
|
|
52
|
-
axis: 'role';
|
|
53
|
-
from?: RoleDescriptor;
|
|
54
|
-
to?: RoleDescriptor;
|
|
55
|
-
} | {
|
|
56
|
-
kind: 'restated';
|
|
57
|
-
field: string;
|
|
58
|
-
axis: 'lifecycle';
|
|
59
|
-
from?: LifecycleRules;
|
|
60
|
-
to?: LifecycleRules;
|
|
61
|
-
} | {
|
|
62
|
-
kind: 'restated';
|
|
63
|
-
field: string;
|
|
64
|
-
axis: 'boundary';
|
|
65
|
-
from?: BoundaryRef;
|
|
66
|
-
to?: BoundaryRef;
|
|
67
|
-
};
|
|
68
|
-
/** A field's declared types, always represented as a set. */
|
|
69
|
-
export type TypeSet = string[];
|
|
70
|
-
/** A removal and an addition that could be one rename: same shape, different name. */
|
|
71
|
-
export interface RenameCandidate {
|
|
72
|
-
removed: string;
|
|
73
|
-
added: string;
|
|
74
|
-
}
|
|
75
|
-
export interface Diff {
|
|
76
|
-
changes: Change[];
|
|
77
|
-
/** Questions the comparison refuses to decide without an explicit rename declaration. */
|
|
78
|
-
ambiguous: RenameCandidate[];
|
|
79
|
-
}
|
|
80
|
-
export interface DiffOptions {
|
|
81
|
-
/** Renames as declared at the time: old name to new name. */
|
|
82
|
-
renamed?: Record<string, string>;
|
|
83
|
-
}
|
|
84
|
-
export interface SetDiff {
|
|
85
|
-
/** Entities the target bundle has and the source bundle had not. */
|
|
86
|
-
entitiesAdded: string[];
|
|
87
|
-
/** Entities the source bundle had and the target bundle has not. */
|
|
88
|
-
entitiesRemoved: string[];
|
|
89
|
-
/** Differences for entities present in both bundles; unchanged entities are absent. */
|
|
90
|
-
entities: Record<string, Diff>;
|
|
91
|
-
}
|
|
92
|
-
export interface SetDiffOptions {
|
|
93
|
-
/** Declared renames, per entity: `{ post: { body: 'content' } }`. */
|
|
94
|
-
renamed?: Record<string, Record<string, string>>;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* What changed between two descriptions of the same entity, read from the wire form alone.
|
|
98
|
-
* FR : ce qui a changé entre deux descriptions d'une même entité, lu du seul format du fil.
|
|
99
|
-
* `compare(v1, v2, { renamed: { body: 'content' } })` → one `renamed`, no `ambiguous`
|
|
100
|
-
*
|
|
101
|
-
* Documented: [how a schema moves](https://fougere.dev/docs/schema/evolution).
|
|
102
|
-
*/
|
|
103
|
-
export declare function compare(was: SchemaDescriptor, is: SchemaDescriptor, options?: DiffOptions): Diff;
|
|
104
|
-
//# sourceMappingURL=diff.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../../src/projection/card/diff.ts"],"names":[],"mappings":"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"}
|
package/src/lib/validation.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
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
|
-
}
|
|
10
|
-
|
|
11
|
-
export type ValidationResult<T> =
|
|
12
|
-
| { success: true; data: T }
|
|
13
|
-
| { success: false; errors: ValidationError[] };
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* A field's verdict. `path` is where INSIDE the value the refusal happened — empty when the
|
|
17
|
-
* field itself is refused, `['street']` when the shape below it is.
|
|
18
|
-
*/
|
|
19
|
-
export type Checked = { value: unknown } | { error: string; path?: readonly string[] };
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* A path as a message writes it — `addr.street`. One rendering among others, and the
|
|
23
|
-
* reason the value stays segmented: this one cannot be read back.
|
|
24
|
-
*/
|
|
25
|
-
export const dotted = (path: readonly string[]): string => path.join('.');
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import type { BoundaryRef } from '../../axis/boundary/Boundary.js';
|
|
2
|
-
import type { LifecycleRules } from '../../axis/lifecycle/Lifecycle.js';
|
|
3
|
-
import type { Relation } from '../../axis/role/Relation.js';
|
|
4
|
-
import type { RoleRules } from '../../axis/role/Role.js';
|
|
5
|
-
import type { JSONSchema7TypeName } from 'json-schema';
|
|
6
|
-
import type { Shape } from '../../axis/shape/Shape.js';
|
|
7
|
-
|
|
8
|
-
type ShapeKeywords = UnionToIntersection<KeywordsOf<Shape>>;
|
|
9
|
-
|
|
10
|
-
type KeywordsOf<S> = S extends unknown ? Partial<Omit<S, 'type' | 'items' | 'properties'>> : never;
|
|
11
|
-
type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
12
|
-
|
|
13
|
-
export type FieldDescriptor = ShapeKeywords & {
|
|
14
|
-
type?: JSONSchema7TypeName | JSONSchema7TypeName[];
|
|
15
|
-
items?: FieldDescriptor;
|
|
16
|
-
properties?: Record<string, FieldDescriptor>;
|
|
17
|
-
description?: string;
|
|
18
|
-
'x-fougere'?: FieldExtension;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export interface FieldExtension {
|
|
22
|
-
role?: RoleDescriptor;
|
|
23
|
-
lifecycle?: LifecycleRules;
|
|
24
|
-
boundary?: BoundaryRef;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export type RoleDescriptor = Pick<RoleRules, 'primary' | 'index'> & {
|
|
28
|
-
unique?: string[][];
|
|
29
|
-
relation?: RelationDescriptor;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export type RelationDescriptor = Pick<Relation, 'kind' | 'onDelete'> & { to: string };
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* What a derivation was cut from, and what the cut left — `nameOf` keyed by the
|
|
36
|
-
* ORIGIN's field names. Absent on a declaration that derives from nothing.
|
|
37
|
-
*
|
|
38
|
-
* A dropped field is `null` and never `undefined`: JSON.stringify erases the second,
|
|
39
|
-
* which would leave the card saying only what remains — what `properties` already says.
|
|
40
|
-
*/
|
|
41
|
-
export interface DerivedFrom {
|
|
42
|
-
from: string;
|
|
43
|
-
nameOf: Record<string, string | null>;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export interface SchemaDescriptor {
|
|
47
|
-
title?: string;
|
|
48
|
-
type: 'object';
|
|
49
|
-
properties: Record<string, FieldDescriptor>;
|
|
50
|
-
required?: string[];
|
|
51
|
-
'x-fougere-derived'?: DerivedFrom;
|
|
52
|
-
'x-fougere-version': 1;
|
|
53
|
-
'x-fougere-vendor': 'fougere';
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export interface SchemaBundle {
|
|
57
|
-
$defs: Record<string, SchemaDescriptor>;
|
|
58
|
-
'x-fougere-version': 1;
|
|
59
|
-
'x-fougere-vendor': 'fougere';
|
|
60
|
-
}
|