@fougere/schema 0.17.4-alpha.0 → 0.19.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/README.md +1 -1
- 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/boundary/Boundary.d.ts.map +1 -1
- package/dist/axis/boundary/Boundary.js +3 -5
- package/dist/axis/boundary/Boundary.js.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/boundary/Boundary.ts +3 -5
- 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,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
|
}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import type { FieldDescriptor } from './FieldDescriptor.js';
|
|
2
2
|
import type { DerivedFrom } from './DerivedFrom.js';
|
|
3
|
+
import type { Envelope } from './Envelope.js';
|
|
3
4
|
|
|
4
|
-
export interface SchemaDescriptor {
|
|
5
|
+
export interface SchemaDescriptor extends Envelope {
|
|
5
6
|
title?: string;
|
|
6
7
|
type: 'object';
|
|
7
8
|
properties: Record<string, FieldDescriptor>;
|
|
8
9
|
required?: string[];
|
|
9
10
|
'x-fougere-derived'?: DerivedFrom;
|
|
10
|
-
'x-fougere-version': 1;
|
|
11
|
-
'x-fougere-vendor': 'fougere';
|
|
12
11
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Field, type Shared } from '../../field/Field.js';
|
|
2
2
|
import type { SchemaView } from '../../SchemaView.js';
|
|
3
|
+
import type { Entity } from '../../entity/Entity.js';
|
|
3
4
|
import { InputValidator } from '../../validator/InputValidator.js';
|
|
4
5
|
import { SchemaError } from '../../SchemaError.js';
|
|
5
6
|
|
|
6
|
-
type Entity = SchemaView & (new (...args: never[]) => unknown);
|
|
7
7
|
|
|
8
8
|
export function json<T = unknown>(opts?: Shared<T>): Field<T>;
|
|
9
|
-
export function json<E extends
|
|
9
|
+
export function json<E extends Entity>(
|
|
10
10
|
of: E,
|
|
11
11
|
opts?: Shared<InstanceType<E>>,
|
|
12
12
|
): Field<InstanceType<E>>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Entity } from '../../entity/Entity.js';
|
|
2
2
|
import { Relation } from '../../axis/role/Relation.js';
|
|
3
3
|
import { Field, type Described } from '../../field/Field.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* `many(() => Post)` → `{ type: 'array' }` with `role.relation.kind` `'many'`
|
|
7
7
|
*/
|
|
8
|
-
export function many<E extends
|
|
8
|
+
export function many<E extends Entity>(
|
|
9
9
|
target: E | (() => E),
|
|
10
10
|
opts?: Described,
|
|
11
11
|
): Field<InstanceType<E>[]> {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Entity } from '../../entity/Entity.js';
|
|
2
2
|
import { Relation, type OnDelete } from '../../axis/role/Relation.js';
|
|
3
3
|
import { Field, type Shared } from '../../field/Field.js';
|
|
4
4
|
|
|
@@ -6,7 +6,7 @@ export interface RefOptions extends Shared<string> {
|
|
|
6
6
|
onDelete?: OnDelete;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
export function ref<E extends
|
|
9
|
+
export function ref<E extends Entity>(
|
|
10
10
|
target: E | (() => E),
|
|
11
11
|
opts?: RefOptions,
|
|
12
12
|
): Field<string> {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EntityConstructor.d.ts","sourceRoot":"","sources":["../../../src/axis/role/EntityConstructor.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,GAAG,QAAQ,MAAM,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EntityConstructor.js","sourceRoot":"","sources":["../../../src/axis/role/EntityConstructor.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type EntityConstructor = abstract new (...args: any[]) => any;
|