@fougere/schema 0.17.4-alpha.0 → 0.18.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/SchemaConstraints.d.ts +4 -4
- package/dist/SchemaConstraints.d.ts.map +1 -1
- package/dist/SchemaConstraints.js +1 -7
- package/dist/SchemaConstraints.js.map +1 -1
- package/dist/SchemaConstructor.d.ts +0 -5
- package/dist/SchemaConstructor.d.ts.map +1 -1
- package/dist/SchemaDefinition.d.ts.map +1 -1
- package/dist/SchemaDefinition.js.map +1 -1
- package/dist/axis/Resolver.d.ts +2 -1
- package/dist/axis/Resolver.d.ts.map +1 -1
- package/dist/axis/role/Relation.d.ts +5 -8
- 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 -3
- package/dist/axis/role/Role.d.ts.map +1 -1
- package/dist/axis/role/Role.js.map +1 -1
- package/dist/axis/shape/Shape.d.ts +6 -11
- package/dist/axis/shape/Shape.d.ts.map +1 -1
- package/dist/axis/shape/Shape.js.map +1 -1
- package/dist/entity/Entity.d.ts +4 -0
- package/dist/entity/Entity.d.ts.map +1 -0
- package/dist/entity/Entity.js +2 -0
- package/dist/entity/Entity.js.map +1 -0
- package/dist/field/FieldSet.d.ts +4 -7
- package/dist/field/FieldSet.d.ts.map +1 -1
- package/dist/field/FieldSet.js +2 -1
- package/dist/field/FieldSet.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/projection/card/Bundle.d.ts.map +1 -1
- package/dist/projection/card/Bundle.js +2 -2
- 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 +4 -4
- package/dist/projection/card/Card.js.map +1 -1
- package/dist/projection/card/Change.d.ts +10 -21
- package/dist/projection/card/Change.d.ts.map +1 -1
- package/dist/projection/card/Envelope.d.ts +7 -0
- package/dist/projection/card/Envelope.d.ts.map +1 -0
- package/dist/projection/card/Envelope.js +3 -0
- package/dist/projection/card/Envelope.js.map +1 -0
- package/dist/projection/card/FieldDescriptor.d.ts +0 -1
- package/dist/projection/card/FieldDescriptor.d.ts.map +1 -1
- package/dist/projection/card/FieldExtension.d.ts +9 -8
- package/dist/projection/card/FieldExtension.d.ts.map +1 -1
- package/dist/projection/card/RoleDescriptor.js.map +1 -1
- package/dist/projection/card/SchemaBundle.d.ts +2 -3
- package/dist/projection/card/SchemaBundle.d.ts.map +1 -1
- package/dist/projection/card/SchemaDescriptor.d.ts +2 -3
- package/dist/projection/card/SchemaDescriptor.d.ts.map +1 -1
- package/dist/vocabulary/primitive/json.d.ts +2 -2
- package/dist/vocabulary/primitive/json.d.ts.map +1 -1
- package/dist/vocabulary/primitive/json.js.map +1 -1
- package/dist/vocabulary/primitive/many.d.ts +2 -2
- package/dist/vocabulary/primitive/many.d.ts.map +1 -1
- package/dist/vocabulary/primitive/ref.d.ts +2 -2
- package/dist/vocabulary/primitive/ref.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/SchemaConstraints.ts +6 -1
- package/src/SchemaConstructor.ts +0 -5
- package/src/SchemaDefinition.ts +6 -11
- package/src/axis/Resolver.ts +3 -1
- package/src/axis/role/Relation.ts +6 -9
- package/src/axis/role/Role.ts +3 -3
- package/src/axis/shape/Shape.ts +5 -6
- package/src/entity/Entity.ts +5 -0
- package/src/field/FieldSet.ts +6 -4
- package/src/index.ts +1 -1
- package/src/projection/card/Bundle.ts +5 -5
- package/src/projection/card/Card.ts +6 -5
- package/src/projection/card/Change.ts +9 -6
- package/src/projection/card/Envelope.ts +4 -0
- package/src/projection/card/FieldDescriptor.ts +0 -1
- package/src/projection/card/FieldExtension.ts +8 -10
- package/src/projection/card/RoleDescriptor.ts +2 -2
- package/src/projection/card/SchemaBundle.ts +2 -3
- package/src/projection/card/SchemaDescriptor.ts +2 -3
- package/src/vocabulary/primitive/json.ts +2 -2
- package/src/vocabulary/primitive/many.ts +2 -2
- package/src/vocabulary/primitive/ref.ts +2 -2
- package/dist/axis/role/EntityConstructor.d.ts +0 -2
- package/dist/axis/role/EntityConstructor.d.ts.map +0 -1
- package/dist/axis/role/EntityConstructor.js +0 -2
- package/dist/axis/role/EntityConstructor.js.map +0 -1
- package/src/axis/role/EntityConstructor.ts +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Change.d.ts","sourceRoot":"","sources":["../../../src/projection/card/Change.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"Change.d.ts","sourceRoot":"","sources":["../../../src/projection/card/Change.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,yFAAyF;AACzF,MAAM,MAAM,MAAM;AAChB,6FAA6F;AAC3F;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,eAAe,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAA;CAAE;AAC1E,uFAAuF;GACrF;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,eAAe,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAA;CAAE;AAC9E,4FAA4F;GAC1F;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,eAAe,CAAA;CAAE;AACvE,kEAAkE;GAChE;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,CAAC;IAAC,EAAE,EAAE,OAAO,CAAA;CAAE;AAChE,0FAA0F;GACxF;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,eAAe,CAAC;IAAC,EAAE,EAAE,eAAe,CAAA;CAAE;AACjF,wFAAwF;GACtF;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,CAAC;IAAC,EAAE,EAAE,OAAO,CAAA;CAAE;AACjE,6CAA6C;GAC3C;KAAG,IAAI,IAAI,MAAM,gBAAgB,CAAC,CAAC,GAAG;QACtC,IAAI,EAAE,UAAU,CAAC;QACjB,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,IAAI,CAAC;QACX,IAAI,CAAC,EAAE,cAAc,CAAC,IAAI,CAAC,CAAC;QAC5B,EAAE,CAAC,EAAE,cAAc,CAAC,IAAI,CAAC,CAAC;KAC3B;CAAE,CAAC,MAAM,gBAAgB,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** What every card document carries: the format it speaks, and who wrote it. */
|
|
2
|
+
export declare const ENVELOPE: {
|
|
3
|
+
readonly 'x-fougere-version': 1;
|
|
4
|
+
readonly 'x-fougere-vendor': 'fougere';
|
|
5
|
+
};
|
|
6
|
+
export type Envelope = typeof ENVELOPE;
|
|
7
|
+
//# sourceMappingURL=Envelope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Envelope.d.ts","sourceRoot":"","sources":["../../../src/projection/card/Envelope.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,eAAO,MAAM,QAAQ;aAAK,mBAAmB,EAAE,CAAC;aAAE,kBAAkB,EAAE,SAAS;CAAW,CAAC;AAE3F,MAAM,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Envelope.js","sourceRoot":"","sources":["../../../src/projection/card/Envelope.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,MAAM,CAAC,MAAM,QAAQ,GAAG,EAAE,mBAAmB,EAAE,CAAC,EAAE,kBAAkB,EAAE,SAAS,EAAW,CAAC"}
|
|
@@ -5,7 +5,6 @@ export type FieldDescriptor = ShapeKeywords & {
|
|
|
5
5
|
type?: JSONSchema7TypeName | JSONSchema7TypeName[];
|
|
6
6
|
items?: FieldDescriptor;
|
|
7
7
|
properties?: Record<string, FieldDescriptor>;
|
|
8
|
-
description?: string;
|
|
9
8
|
'x-fougere'?: FieldExtension;
|
|
10
9
|
};
|
|
11
10
|
//# sourceMappingURL=FieldDescriptor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldDescriptor.d.ts","sourceRoot":"","sources":["../../../src/projection/card/FieldDescriptor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,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,
|
|
1
|
+
{"version":3,"file":"FieldDescriptor.d.ts","sourceRoot":"","sources":["../../../src/projection/card/FieldDescriptor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,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,cAAc,CAAC;CAC9B,CAAC"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { LifecycleRules } from '../../axis/lifecycle/Lifecycle.js';
|
|
1
|
+
import type { FougereFieldAxes } from '../../FougereFieldAxes.js';
|
|
3
2
|
import type { RoleDescriptor } from './RoleDescriptor.js';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
/**
|
|
4
|
+
* What each axis writes on a card — its declaration as it stands, except `role`, whose target
|
|
5
|
+
* travels as a name. An axis registered from outside writes here too, under its own name.
|
|
6
|
+
*/
|
|
7
|
+
export type FieldExtension = {
|
|
8
|
+
[Axis in keyof FougereFieldAxes]?: Axis extends 'role' ? RoleDescriptor : FougereFieldAxes[Axis];
|
|
9
|
+
} & {
|
|
9
10
|
[axis: string]: unknown;
|
|
10
|
-
}
|
|
11
|
+
};
|
|
11
12
|
//# sourceMappingURL=FieldExtension.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldExtension.d.ts","sourceRoot":"","sources":["../../../src/projection/card/FieldExtension.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"FieldExtension.d.ts","sourceRoot":"","sources":["../../../src/projection/card/FieldExtension.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,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MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC9B,KAAK,CAAC,QAAQ,GAAG;gBACf,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,IAAK,EAAE,IAAI,EAAc,CAAW;gBAC9D,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI;gBACxB,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aACxE,CAAC;QACJ,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CACF,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { SchemaDescriptor } from './SchemaDescriptor.js';
|
|
2
|
-
|
|
2
|
+
import type { Envelope } from './Envelope.js';
|
|
3
|
+
export interface SchemaBundle extends Envelope {
|
|
3
4
|
$defs: Record<string, SchemaDescriptor>;
|
|
4
|
-
'x-fougere-version': 1;
|
|
5
|
-
'x-fougere-vendor': 'fougere';
|
|
6
5
|
}
|
|
7
6
|
//# sourceMappingURL=SchemaBundle.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaBundle.d.ts","sourceRoot":"","sources":["../../../src/projection/card/SchemaBundle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"SchemaBundle.d.ts","sourceRoot":"","sources":["../../../src/projection/card/SchemaBundle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C,MAAM,WAAW,YAAa,SAAQ,QAAQ;IAC5C,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;CACzC"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import type { FieldDescriptor } from './FieldDescriptor.js';
|
|
2
2
|
import type { DerivedFrom } from './DerivedFrom.js';
|
|
3
|
-
|
|
3
|
+
import type { Envelope } from './Envelope.js';
|
|
4
|
+
export interface SchemaDescriptor extends Envelope {
|
|
4
5
|
title?: string;
|
|
5
6
|
type: 'object';
|
|
6
7
|
properties: Record<string, FieldDescriptor>;
|
|
7
8
|
required?: string[];
|
|
8
9
|
'x-fougere-derived'?: DerivedFrom;
|
|
9
|
-
'x-fougere-version': 1;
|
|
10
|
-
'x-fougere-vendor': 'fougere';
|
|
11
10
|
}
|
|
12
11
|
//# sourceMappingURL=SchemaDescriptor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaDescriptor.d.ts","sourceRoot":"","sources":["../../../src/projection/card/SchemaDescriptor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"SchemaDescriptor.d.ts","sourceRoot":"","sources":["../../../src/projection/card/SchemaDescriptor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C,MAAM,WAAW,gBAAiB,SAAQ,QAAQ;IAChD,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;CACnC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Field, type Shared } from '../../field/Field.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { Entity } from '../../entity/Entity.js';
|
|
3
3
|
export declare function json<T = unknown>(opts?: Shared<T>): Field<T>;
|
|
4
|
-
export declare function json<E extends
|
|
4
|
+
export declare function json<E extends Entity>(of: E, opts?: Shared<InstanceType<E>>): Field<InstanceType<E>>;
|
|
5
5
|
//# sourceMappingURL=json.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../../src/vocabulary/primitive/json.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,MAAM,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../../src/vocabulary/primitive/json.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAKrD,wBAAgB,IAAI,CAAC,CAAC,GAAG,OAAO,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;AAC9D,wBAAgB,IAAI,CAAC,CAAC,SAAS,MAAM,EACnC,EAAE,EAAE,CAAC,EACL,IAAI,CAAC,EAAE,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,GAC7B,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json.js","sourceRoot":"","sources":["../../../src/vocabulary/primitive/json.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAe,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"json.js","sourceRoot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AI,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE;KAChF,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;AACvB,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Entity } from '../../entity/Entity.js';
|
|
2
2
|
import { Field, type Described } from '../../field/Field.js';
|
|
3
3
|
/**
|
|
4
4
|
* `many(() => Post)` → `{ type: 'array' }` with `role.relation.kind` `'many'`
|
|
5
5
|
*/
|
|
6
|
-
export declare function many<E extends
|
|
6
|
+
export declare function many<E extends Entity>(target: E | (() => E), opts?: Described): Field<InstanceType<E>[]>;
|
|
7
7
|
//# sourceMappingURL=many.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"many.d.ts","sourceRoot":"","sources":["../../../src/vocabulary/primitive/many.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"many.d.ts","sourceRoot":"","sources":["../../../src/vocabulary/primitive/many.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAErD,OAAO,EAAE,KAAK,EAAE,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAE7D;;GAEG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,MAAM,EACnC,MAAM,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,EACrB,IAAI,CAAC,EAAE,SAAS,GACf,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,CAK1B"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Entity } from '../../entity/Entity.js';
|
|
2
2
|
import { type OnDelete } from '../../axis/role/Relation.js';
|
|
3
3
|
import { Field, type Shared } from '../../field/Field.js';
|
|
4
4
|
export interface RefOptions extends Shared<string> {
|
|
5
5
|
onDelete?: OnDelete;
|
|
6
6
|
}
|
|
7
|
-
export declare function ref<E extends
|
|
7
|
+
export declare function ref<E extends Entity>(target: E | (() => E), opts?: RefOptions): Field<string>;
|
|
8
8
|
//# sourceMappingURL=ref.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ref.d.ts","sourceRoot":"","sources":["../../../src/vocabulary/primitive/ref.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"ref.d.ts","sourceRoot":"","sources":["../../../src/vocabulary/primitive/ref.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAY,KAAK,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,EAAE,KAAK,EAAE,KAAK,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE1D,MAAM,WAAW,UAAW,SAAQ,MAAM,CAAC,MAAM,CAAC;IAChD,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED,wBAAgB,GAAG,CAAC,CAAC,SAAS,MAAM,EAClC,MAAM,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,EACrB,IAAI,CAAC,EAAE,UAAU,GAChB,KAAK,CAAC,MAAM,CAAC,CAKf"}
|
package/package.json
CHANGED
package/src/SchemaConstraints.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type FieldName } from './field/FieldName.js';
|
|
2
2
|
import { type Fields } from './field/Fields.js';
|
|
3
3
|
import { type FieldGroups } from './entity/FieldGroups.js';
|
|
4
|
+
import type { EntityDeclarations } from './entity/EntityDeclarations.js';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* What a schema states beyond any single field: groups of names. `unique` constrains the
|
|
@@ -9,7 +10,11 @@ import { type FieldGroups } from './entity/FieldGroups.js';
|
|
|
9
10
|
* spanning two fields — a check, an exclusion — is a member here, not an eighth positional
|
|
10
11
|
* argument in a list that has already lost one.
|
|
11
12
|
*/
|
|
13
|
+
export type ConstraintKind = (typeof SchemaConstraints.kinds)[number];
|
|
14
|
+
|
|
12
15
|
export class SchemaConstraints<TFields extends Fields = Fields> {
|
|
16
|
+
static readonly kinds = ['unique', 'index'] as const;
|
|
17
|
+
|
|
13
18
|
private constructor(
|
|
14
19
|
readonly unique: FieldGroups<TFields>,
|
|
15
20
|
readonly index: FieldGroups<TFields>,
|
|
@@ -23,7 +28,7 @@ export class SchemaConstraints<TFields extends Fields = Fields> {
|
|
|
23
28
|
* `SchemaConstraints.of([['a','b'], ['a','b']])` → `unique` holds one group
|
|
24
29
|
*/
|
|
25
30
|
static of<TFields extends Fields>(
|
|
26
|
-
groups:
|
|
31
|
+
groups: Pick<EntityDeclarations<TFields>, ConstraintKind>,
|
|
27
32
|
): SchemaConstraints<TFields> {
|
|
28
33
|
return new SchemaConstraints(deduped(groups.unique), deduped(groups.index));
|
|
29
34
|
}
|
package/src/SchemaConstructor.ts
CHANGED
|
@@ -3,17 +3,12 @@ import type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
|
3
3
|
import { type Fields } from './field/Fields.js';
|
|
4
4
|
|
|
5
5
|
import { type EntityDeclarations } from './entity/EntityDeclarations.js';
|
|
6
|
-
import { type PreviousNames } from './entity/PreviousNames.js';
|
|
7
|
-
import { SchemaDerivation } from './SchemaDerivation.js';
|
|
8
6
|
import type { SchemaView } from './SchemaView.js';
|
|
9
7
|
import type { Values } from './field/Values.js';
|
|
10
8
|
|
|
11
9
|
export interface SchemaConstructor<TFields extends Fields> extends SchemaView<TFields> {
|
|
12
10
|
new (data: Partial<Values<TFields>>): Values<TFields>;
|
|
13
11
|
readonly '~standard': StandardSchemaV1.Props<Record<string, unknown>, Values<TFields>>;
|
|
14
|
-
readonly derivation?: SchemaDerivation;
|
|
15
|
-
readonly previous?: PreviousNames<TFields>;
|
|
16
|
-
readonly anchored?: boolean;
|
|
17
12
|
from(data: Record<string, unknown>): Values<TFields>;
|
|
18
13
|
pick<K extends string & keyof TFields>(
|
|
19
14
|
...keys: K[]
|
package/src/SchemaDefinition.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { type ValidateOptions } from './validator/ValidateOptions.js';
|
|
|
9
9
|
import type { SchemaView } from './SchemaView.js';
|
|
10
10
|
import { SchemaConstraints } from './SchemaConstraints.js';
|
|
11
11
|
import { SchemaError } from './SchemaError.js';
|
|
12
|
+
import type { ConstraintKind } from './SchemaConstraints.js';
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* Everything a definition is made of, every member required.
|
|
@@ -17,15 +18,10 @@ import { SchemaError } from './SchemaError.js';
|
|
|
17
18
|
* `anchored: false` are the two a derivation decides, and positionally they were an
|
|
18
19
|
* `undefined` and a `false` a reader had to count arguments to name.
|
|
19
20
|
*/
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
adapterSet
|
|
23
|
-
|
|
24
|
-
previous: PreviousNames<Fields> | undefined;
|
|
25
|
-
derivation: SchemaDerivation | undefined;
|
|
26
|
-
anchored: boolean;
|
|
27
|
-
constraints: SchemaConstraints;
|
|
28
|
-
}
|
|
21
|
+
type SchemaState = Pick<
|
|
22
|
+
SchemaDefinition,
|
|
23
|
+
'fields' | 'adapterSet' | 'opts' | 'previous' | 'derivation' | 'anchored' | 'constraints'
|
|
24
|
+
>;
|
|
29
25
|
|
|
30
26
|
/** What a schema is built from; the rest is stated by `declares` or inherited by a derivation. */
|
|
31
27
|
export interface SchemaDeclaration<TFields extends Fields> {
|
|
@@ -183,8 +179,7 @@ export class SchemaDefinition {
|
|
|
183
179
|
static merged(views: readonly SchemaView[]): SchemaDefinition {
|
|
184
180
|
const fields: Fields = {};
|
|
185
181
|
let opts: ValidateOptions = {};
|
|
186
|
-
const groups:
|
|
187
|
-
{ unique: [], index: [] };
|
|
182
|
+
const groups: Record<ConstraintKind, (readonly string[])[]> = { unique: [], index: [] };
|
|
188
183
|
for (const view of views) {
|
|
189
184
|
Object.assign(fields, view.getFields());
|
|
190
185
|
opts = { ...opts, ...view.getOpts() };
|
package/src/axis/Resolver.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Entity } from '../../entity/Entity.js';
|
|
2
|
+
import type { RoleRules } from './Role.js';
|
|
2
3
|
|
|
3
4
|
export const RELATION_KINDS = ['one', 'many'] as const;
|
|
4
5
|
|
|
@@ -7,11 +8,7 @@ export const ON_DELETE = ['cascade', 'restrict', 'set null'] as const;
|
|
|
7
8
|
/** What becomes of the rows that name a deleted one. */
|
|
8
9
|
export type OnDelete = (typeof ON_DELETE)[number];
|
|
9
10
|
|
|
10
|
-
export
|
|
11
|
-
to: () => EntityConstructor;
|
|
12
|
-
kind: (typeof RELATION_KINDS)[number];
|
|
13
|
-
onDelete?: OnDelete;
|
|
14
|
-
}
|
|
11
|
+
export type Relation = NonNullable<RoleRules['relation']>;
|
|
15
12
|
|
|
16
13
|
/**
|
|
17
14
|
* How a relation is built — the one place a target becomes `() => Entity`.
|
|
@@ -22,15 +19,15 @@ export interface Relation {
|
|
|
22
19
|
*/
|
|
23
20
|
export const Relation = {
|
|
24
21
|
/** `() => Post` so two entities can point at each other. */
|
|
25
|
-
one(target:
|
|
22
|
+
one(target: Entity | (() => Entity), onDelete?: OnDelete): Relation {
|
|
26
23
|
return { to: normalizeTarget(target), kind: 'one', ...(onDelete ? { onDelete } : {}) };
|
|
27
24
|
},
|
|
28
25
|
|
|
29
|
-
many(target:
|
|
26
|
+
many(target: Entity | (() => Entity)): Relation {
|
|
30
27
|
return { to: normalizeTarget(target), kind: 'many' };
|
|
31
28
|
},
|
|
32
29
|
};
|
|
33
30
|
|
|
34
|
-
function normalizeTarget<E extends
|
|
31
|
+
function normalizeTarget<E extends Entity>(target: E | (() => E)): () => E {
|
|
35
32
|
return 'getFields' in target ? () => target as E : (target as () => E);
|
|
36
33
|
}
|
package/src/axis/role/Role.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Relation } from './Relation.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { Entity } from '../../entity/Entity.js';
|
|
3
3
|
import { isObject } from '../../lib/utils.js';
|
|
4
4
|
import { Shapes, type Shape } from '../shape/Shape.js';
|
|
5
5
|
import type { ValidationError } from '../../lib/ValidationError.js';
|
|
@@ -14,7 +14,7 @@ export class Role {
|
|
|
14
14
|
.key(
|
|
15
15
|
'relation',
|
|
16
16
|
Format.of()
|
|
17
|
-
.key('to', Format.anything.as<() =>
|
|
17
|
+
.key('to', Format.anything.as<() => Entity>())
|
|
18
18
|
.key('kind', Format.tokens(RELATION_KINDS))
|
|
19
19
|
.key('onDelete', Format.tokens(ON_DELETE))
|
|
20
20
|
.needs('to', 'kind')
|
|
@@ -86,7 +86,7 @@ export class Role {
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
/** Calls `() => Post` so no caller has to. */
|
|
89
|
-
get target():
|
|
89
|
+
get target(): Entity | undefined {
|
|
90
90
|
return this.rules.relation?.to();
|
|
91
91
|
}
|
|
92
92
|
|
package/src/axis/shape/Shape.ts
CHANGED
|
@@ -52,12 +52,11 @@ export const SHAPE_TYPES = [
|
|
|
52
52
|
'object',
|
|
53
53
|
] as const;
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
| ({ type: 'object' } & ObjectConstraints);
|
|
55
|
+
|
|
56
|
+
/** A shape with `null` taken out of its type — what `Shapes` splits a nullable one into. */
|
|
57
|
+
type BaseShape = Shape extends infer Each
|
|
58
|
+
? Each extends { type: infer Type } ? Omit<Each, 'type'> & { type: Type extends readonly [infer One, 'null'] ? One : Type } : never
|
|
59
|
+
: never;
|
|
61
60
|
|
|
62
61
|
interface ShapeParts {
|
|
63
62
|
base?: BaseShape;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { SchemaView } from '../SchemaView.js';
|
|
2
|
+
|
|
3
|
+
/** An entity class, whichever its fields — what a relation, a prefab or `json()` is handed. */
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- a row of any shape
|
|
5
|
+
export type Entity = SchemaView & (abstract new (...args: any[]) => any);
|
package/src/field/FieldSet.ts
CHANGED
|
@@ -4,6 +4,8 @@ import { Field } from './Field.js';
|
|
|
4
4
|
import { type FieldName } from './FieldName.js';
|
|
5
5
|
import { type Fields } from './Fields.js';
|
|
6
6
|
import { SchemaError } from '../SchemaError.js';
|
|
7
|
+
import { SchemaConstraints, type ConstraintKind } from '../SchemaConstraints.js';
|
|
8
|
+
import type { EntityDeclarations } from '../entity/EntityDeclarations.js';
|
|
7
9
|
|
|
8
10
|
export class FieldSet<TFields extends Fields = Fields> {
|
|
9
11
|
private constructor(private readonly fields: TFields) {}
|
|
@@ -24,15 +26,15 @@ export class FieldSet<TFields extends Fields = Fields> {
|
|
|
24
26
|
*/
|
|
25
27
|
static declaring<TFields extends Fields>(
|
|
26
28
|
declared: TFields,
|
|
27
|
-
groups:
|
|
28
|
-
): { fields: TFields
|
|
29
|
+
groups: Pick<EntityDeclarations<TFields>, ConstraintKind> = {},
|
|
30
|
+
): { fields: TFields } & Record<ConstraintKind, FieldGroups<TFields>> {
|
|
29
31
|
const fields: Fields = {};
|
|
30
32
|
for (const [key, field] of Object.entries(declared))
|
|
31
33
|
fields[key] = new Field(field, key);
|
|
32
34
|
|
|
33
|
-
const composite
|
|
35
|
+
const composite: Record<ConstraintKind, FieldName<TFields>[][]> = { unique: [], index: [] };
|
|
34
36
|
|
|
35
|
-
for (const kind of
|
|
37
|
+
for (const kind of SchemaConstraints.kinds) {
|
|
36
38
|
for (const group of groups[kind] ?? []) {
|
|
37
39
|
const missing = group.filter((key) => !Object.hasOwn(fields, key));
|
|
38
40
|
if (missing.length)
|
package/src/index.ts
CHANGED
|
@@ -4,6 +4,7 @@ export * from './vocabulary/index.js';
|
|
|
4
4
|
|
|
5
5
|
export { ANONYMOUS_SCHEMA_NAME, Schema } from './Schema.js';
|
|
6
6
|
export { type SchemaConstructor } from './SchemaConstructor.js';
|
|
7
|
+
export { type Entity } from './entity/Entity.js';
|
|
7
8
|
export { type SchemaView } from './SchemaView.js';
|
|
8
9
|
export { Field } from './field/Field.js';
|
|
9
10
|
export { type Fields } from './field/Fields.js';
|
|
@@ -13,7 +14,6 @@ export { type ShapeType } from './axis/shape/ShapeType.js';
|
|
|
13
14
|
export { Shapes } from './axis/shape/Shape.js';
|
|
14
15
|
export { Role } from './axis/role/Role.js';
|
|
15
16
|
export { ON_DELETE, type OnDelete } from './axis/role/Relation.js';
|
|
16
|
-
export { type EntityConstructor } from './axis/role/EntityConstructor.js';
|
|
17
17
|
export { Lifecycle } from './axis/lifecycle/Lifecycle.js';
|
|
18
18
|
export { Boundary } from './axis/boundary/Boundary.js';
|
|
19
19
|
export { applyCreate, applyUpdate } from './axis/lifecycle/apply.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Resolver } from '../../axis/Resolver.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { Entity } from '../../entity/Entity.js';
|
|
3
3
|
import { lowerFirst } from '../../lib/utils.js';
|
|
4
4
|
import type { SchemaView } from '../../SchemaView.js';
|
|
5
5
|
import { Card } from './Card.js';
|
|
@@ -9,6 +9,7 @@ import type { Diff } from './Diff.js';
|
|
|
9
9
|
import type { SetDiff } from './SetDiff.js';
|
|
10
10
|
import type { SetDiffOptions } from './SetDiffOptions.js';
|
|
11
11
|
import { SchemaError } from '../../SchemaError.js';
|
|
12
|
+
import { ENVELOPE } from './Envelope.js';
|
|
12
13
|
|
|
13
14
|
type SchemaSet = Record<string, SchemaView> | SchemaView[];
|
|
14
15
|
|
|
@@ -38,8 +39,7 @@ export class Bundle {
|
|
|
38
39
|
|
|
39
40
|
return new Bundle({
|
|
40
41
|
$defs: definitions,
|
|
41
|
-
|
|
42
|
-
'x-fougere-vendor': 'fougere',
|
|
42
|
+
...ENVELOPE,
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
45
|
|
|
@@ -48,12 +48,12 @@ export class Bundle {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
toSchemas(): Record<string, SchemaView> {
|
|
51
|
-
const byName: Record<string,
|
|
51
|
+
const byName: Record<string, Entity> = {};
|
|
52
52
|
const resolve: Resolver = (name) => byName[name.toLowerCase()];
|
|
53
53
|
const schemas: Record<string, SchemaView> = {};
|
|
54
54
|
for (const [name, descriptor] of Object.entries(this.descriptor.$defs)) {
|
|
55
55
|
const schema = Card.fromDescriptor(descriptor).toSchema(resolve, name);
|
|
56
|
-
byName[name.toLowerCase()] = schema
|
|
56
|
+
byName[name.toLowerCase()] = schema;
|
|
57
57
|
schemas[name] = schema;
|
|
58
58
|
}
|
|
59
59
|
|
|
@@ -19,6 +19,8 @@ import type { SchemaDescriptor } from './SchemaDescriptor.js';
|
|
|
19
19
|
import { compare, type Diff } from './Diff.js';
|
|
20
20
|
import { type DiffOptions } from './DiffOptions.js';
|
|
21
21
|
import { SchemaError } from '../../SchemaError.js';
|
|
22
|
+
import type { ConstraintKind } from '../../SchemaConstraints.js';
|
|
23
|
+
import { ENVELOPE } from './Envelope.js';
|
|
22
24
|
|
|
23
25
|
type FieldsOf<T> = { [K in keyof T]-?: Field<T[K]> };
|
|
24
26
|
|
|
@@ -42,15 +44,14 @@ export class Card<T = Values<Fields>> {
|
|
|
42
44
|
properties[key] = describeField(field, key);
|
|
43
45
|
if (validator.requires(field)) required.push(key);
|
|
44
46
|
}
|
|
45
|
-
for (const kind of
|
|
47
|
+
for (const kind of SchemaConstraints.kinds)
|
|
46
48
|
for (const group of kind === 'unique' ? schema.getUnique() : schema.getIndex())
|
|
47
49
|
for (const member of group) carryGroup(properties[member], kind, group);
|
|
48
50
|
|
|
49
51
|
const descriptor: SchemaDescriptor = {
|
|
50
52
|
type: 'object',
|
|
51
53
|
properties,
|
|
52
|
-
|
|
53
|
-
'x-fougere-vendor': 'fougere',
|
|
54
|
+
...ENVELOPE,
|
|
54
55
|
};
|
|
55
56
|
const title = name ?? Card.titleOf(schema);
|
|
56
57
|
if (title) descriptor.title = title;
|
|
@@ -98,7 +99,7 @@ export class Card<T = Values<Fields>> {
|
|
|
98
99
|
}
|
|
99
100
|
|
|
100
101
|
const fields: Fields = {};
|
|
101
|
-
const groups:
|
|
102
|
+
const groups: Record<ConstraintKind, string[][]> = { unique: [], index: [] };
|
|
102
103
|
for (const [key, property] of Object.entries(descriptor.properties)) {
|
|
103
104
|
if (!isObject(property)) {
|
|
104
105
|
refuse(
|
|
@@ -107,7 +108,7 @@ export class Card<T = Values<Fields>> {
|
|
|
107
108
|
);
|
|
108
109
|
}
|
|
109
110
|
fields[key] = reconstructField(property, key, resolve);
|
|
110
|
-
for (const kind of
|
|
111
|
+
for (const kind of SchemaConstraints.kinds)
|
|
111
112
|
for (const group of property['x-fougere']?.role?.[kind] ?? [])
|
|
112
113
|
if (group.length > 1) groups[kind].push([...group]);
|
|
113
114
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { LifecycleRules } from '../../axis/lifecycle/Lifecycle.js';
|
|
1
|
+
import type { FougereFieldAxes } from '../../FougereFieldAxes.js';
|
|
3
2
|
import type { FieldDescriptor } from './FieldDescriptor.js';
|
|
4
|
-
import type {
|
|
3
|
+
import type { FieldExtension } from './FieldExtension.js';
|
|
5
4
|
import type { TypeSet } from './TypeSet.js';
|
|
6
5
|
|
|
7
6
|
/** One named difference, at one place. Each kind exists because a reader asks for it. */
|
|
@@ -19,6 +18,10 @@ export type Change =
|
|
|
19
18
|
/** NOT NULL in either direction. Boot: an old writer cannot fill what it never knew. */
|
|
20
19
|
| { kind: 'required'; field: string; from: boolean; to: boolean }
|
|
21
20
|
/** An axis other than shape was restated. */
|
|
22
|
-
| {
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
| { [Axis in keyof FougereFieldAxes]-?: {
|
|
22
|
+
kind: 'restated';
|
|
23
|
+
field: string;
|
|
24
|
+
axis: Axis;
|
|
25
|
+
from?: FieldExtension[Axis];
|
|
26
|
+
to?: FieldExtension[Axis];
|
|
27
|
+
} }[keyof FougereFieldAxes];
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { LifecycleRules } from '../../axis/lifecycle/Lifecycle.js';
|
|
1
|
+
import type { FougereFieldAxes } from '../../FougereFieldAxes.js';
|
|
3
2
|
import type { RoleDescriptor } from './RoleDescriptor.js';
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
4
|
+
/**
|
|
5
|
+
* What each axis writes on a card — its declaration as it stands, except `role`, whose target
|
|
6
|
+
* travels as a name. An axis registered from outside writes here too, under its own name.
|
|
7
|
+
*/
|
|
8
|
+
export type FieldExtension = {
|
|
9
|
+
[Axis in keyof FougereFieldAxes]?: Axis extends 'role' ? RoleDescriptor : FougereFieldAxes[Axis];
|
|
10
|
+
} & { [axis: string]: unknown };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Entity } from '../../entity/Entity.js';
|
|
2
2
|
import type { Relation } from '../../axis/role/Relation.js';
|
|
3
3
|
import type { RoleRules } from '../../axis/role/Role.js';
|
|
4
4
|
import type { Resolver } from '../../axis/Resolver.js';
|
|
@@ -47,7 +47,7 @@ export const roleOnCard: CardForm<RoleRules, RoleDescriptor> = {
|
|
|
47
47
|
if (wire.relation) {
|
|
48
48
|
const name = wire.relation.to;
|
|
49
49
|
rules.relation = {
|
|
50
|
-
to: () => (resolve?.(name) ?? ({ name } as unknown)) as
|
|
50
|
+
to: () => (resolve?.(name) ?? ({ name } as unknown)) as Entity,
|
|
51
51
|
kind: wire.relation.kind,
|
|
52
52
|
...(wire.relation.onDelete ? { onDelete: wire.relation.onDelete } : {}),
|
|
53
53
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { SchemaDescriptor } from './SchemaDescriptor.js';
|
|
2
|
+
import type { Envelope } from './Envelope.js';
|
|
2
3
|
|
|
3
|
-
export interface SchemaBundle {
|
|
4
|
+
export interface SchemaBundle extends Envelope {
|
|
4
5
|
$defs: Record<string, SchemaDescriptor>;
|
|
5
|
-
'x-fougere-version': 1;
|
|
6
|
-
'x-fougere-vendor': 'fougere';
|
|
7
6
|
}
|