@fougere/schema 0.10.0-alpha.0 → 0.12.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 +4 -2
- package/dist/Schema.d.ts +1 -1
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +4 -3
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaConstructor.d.ts +3 -4
- package/dist/SchemaConstructor.d.ts.map +1 -1
- package/dist/SchemaDefinition.d.ts.map +1 -1
- package/dist/SchemaDefinition.js +2 -1
- package/dist/SchemaDefinition.js.map +1 -1
- package/dist/SchemaError.d.ts +4 -0
- package/dist/SchemaError.d.ts.map +1 -0
- package/dist/SchemaError.js +7 -0
- package/dist/SchemaError.js.map +1 -0
- package/dist/SchemaView.d.ts +1 -1
- package/dist/SchemaView.d.ts.map +1 -1
- package/dist/axis/boundary/Boundary.d.ts.map +1 -1
- package/dist/axis/boundary/Boundary.js +3 -2
- package/dist/axis/boundary/Boundary.js.map +1 -1
- package/dist/axis/boundary/Decoder.d.ts +2 -5
- package/dist/axis/boundary/Decoder.d.ts.map +1 -1
- package/dist/axis/boundary/Decoder.js +2 -2
- package/dist/axis/boundary/Decoder.js.map +1 -1
- package/dist/axis/lifecycle/Clock.d.ts +4 -12
- package/dist/axis/lifecycle/Clock.d.ts.map +1 -1
- package/dist/axis/lifecycle/Clock.js +7 -13
- package/dist/axis/lifecycle/Clock.js.map +1 -1
- package/dist/axis/lifecycle/Generators.d.ts +5 -5
- package/dist/axis/lifecycle/Generators.d.ts.map +1 -1
- package/dist/axis/lifecycle/Generators.js +5 -15
- package/dist/axis/lifecycle/Generators.js.map +1 -1
- package/dist/axis/lifecycle/Lifecycle.d.ts +3 -3
- package/dist/axis/lifecycle/Lifecycle.d.ts.map +1 -1
- package/dist/axis/lifecycle/Lifecycle.js +11 -7
- package/dist/axis/lifecycle/Lifecycle.js.map +1 -1
- package/dist/axis/lifecycle/apply.d.ts.map +1 -1
- package/dist/axis/lifecycle/apply.js +3 -19
- package/dist/axis/lifecycle/apply.js.map +1 -1
- package/dist/axis/role/Relation.d.ts +4 -2
- package/dist/axis/role/Relation.d.ts.map +1 -1
- package/dist/axis/role/Relation.js +2 -2
- package/dist/axis/role/Relation.js.map +1 -1
- package/dist/axis/shape/Shape.d.ts +2 -2
- package/dist/axis/shape/Shape.d.ts.map +1 -1
- package/dist/axis/shape/Shape.js +2 -2
- package/dist/axis/shape/Shape.js.map +1 -1
- package/dist/entity/EntityAdapterSet.d.ts.map +1 -1
- package/dist/entity/EntityAdapterSet.js +3 -2
- package/dist/entity/EntityAdapterSet.js.map +1 -1
- package/dist/entity.d.ts +0 -1
- package/dist/entity.d.ts.map +1 -1
- package/dist/entity.js +0 -1
- package/dist/entity.js.map +1 -1
- package/dist/field/Field.d.ts.map +1 -1
- package/dist/field/Field.js +5 -4
- package/dist/field/Field.js.map +1 -1
- package/dist/field/FieldSet.d.ts.map +1 -1
- package/dist/field/FieldSet.js +5 -3
- package/dist/field/FieldSet.js.map +1 -1
- package/dist/field/Values.d.ts +6 -0
- package/dist/field/Values.d.ts.map +1 -0
- package/dist/field/Values.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/Registry.d.ts +1 -2
- package/dist/lib/Registry.d.ts.map +1 -1
- package/dist/lib/Registry.js +4 -4
- package/dist/lib/Registry.js.map +1 -1
- package/dist/lib/Verdict.d.ts +12 -0
- package/dist/lib/Verdict.d.ts.map +1 -0
- package/dist/lib/Verdict.js +2 -0
- package/dist/lib/Verdict.js.map +1 -0
- package/dist/projection/Cases.js +52 -54
- package/dist/projection/Cases.js.map +1 -1
- package/dist/projection/card/Bundle.d.ts.map +1 -1
- package/dist/projection/card/Bundle.js +2 -1
- package/dist/projection/card/Bundle.js.map +1 -1
- package/dist/projection/card/Card.d.ts +1 -1
- package/dist/projection/card/Card.d.ts.map +1 -1
- package/dist/projection/card/Card.js +7 -2
- package/dist/projection/card/Card.js.map +1 -1
- package/dist/projection/card/Diff.d.ts.map +1 -1
- package/dist/projection/card/Diff.js +34 -37
- package/dist/projection/card/Diff.js.map +1 -1
- package/dist/projection/card/admission.d.ts.map +1 -1
- package/dist/projection/card/admission.js +2 -1
- package/dist/projection/card/admission.js.map +1 -1
- package/dist/validator/AdapterFieldValidator.d.ts.map +1 -1
- package/dist/validator/AdapterFieldValidator.js +3 -2
- package/dist/validator/AdapterFieldValidator.js.map +1 -1
- package/dist/validator/FieldValueValidator.d.ts +3 -3
- package/dist/validator/FieldValueValidator.d.ts.map +1 -1
- package/dist/validator/FieldValueValidator.js +12 -11
- package/dist/validator/FieldValueValidator.js.map +1 -1
- package/dist/validator/InputValidator.d.ts +3 -0
- package/dist/validator/InputValidator.d.ts.map +1 -1
- package/dist/validator/InputValidator.js +28 -31
- package/dist/validator/InputValidator.js.map +1 -1
- package/dist/vocabulary/primitive/list.d.ts.map +1 -1
- package/dist/vocabulary/primitive/list.js +2 -1
- package/dist/vocabulary/primitive/list.js.map +1 -1
- package/dist/vocabulary/primitive/ref.d.ts +6 -1
- package/dist/vocabulary/primitive/ref.d.ts.map +1 -1
- package/dist/vocabulary/primitive/ref.js +1 -1
- package/dist/vocabulary/primitive/ref.js.map +1 -1
- package/dist/vocabulary/vocabulary.d.ts.map +1 -1
- package/dist/vocabulary/vocabulary.js +2 -1
- package/dist/vocabulary/vocabulary.js.map +1 -1
- package/package.json +1 -1
- package/src/Schema.ts +6 -4
- package/src/SchemaConstructor.ts +4 -4
- package/src/SchemaDefinition.ts +2 -1
- package/src/SchemaError.ts +7 -0
- package/src/SchemaView.ts +1 -1
- package/src/axis/boundary/Boundary.ts +3 -2
- package/src/axis/boundary/Decoder.ts +4 -3
- package/src/axis/lifecycle/Clock.ts +9 -13
- package/src/axis/lifecycle/Generators.ts +6 -18
- package/src/axis/lifecycle/Lifecycle.ts +14 -9
- package/src/axis/lifecycle/apply.ts +2 -16
- package/src/axis/role/Relation.ts +6 -3
- package/src/axis/shape/Shape.ts +3 -3
- package/src/entity/EntityAdapterSet.ts +3 -2
- package/src/entity.ts +0 -1
- package/src/field/Field.ts +5 -4
- package/src/field/FieldSet.ts +5 -3
- package/src/{Values.ts → field/Values.ts} +2 -2
- package/src/index.ts +3 -0
- package/src/lib/Registry.ts +5 -4
- package/src/lib/Verdict.ts +10 -0
- package/src/projection/Cases.ts +61 -57
- package/src/projection/card/Bundle.ts +2 -1
- package/src/projection/card/Card.ts +12 -4
- package/src/projection/card/Diff.ts +42 -42
- package/src/projection/card/admission.ts +2 -1
- package/src/validator/AdapterFieldValidator.ts +3 -2
- package/src/validator/FieldValueValidator.ts +15 -14
- package/src/validator/InputValidator.ts +30 -32
- package/src/vocabulary/primitive/list.ts +2 -1
- package/src/vocabulary/primitive/ref.ts +7 -3
- package/src/vocabulary/vocabulary.ts +2 -1
- package/dist/PartialValues.d.ts +0 -4
- package/dist/PartialValues.d.ts.map +0 -1
- package/dist/PartialValues.js +0 -2
- package/dist/PartialValues.js.map +0 -1
- package/dist/Values.d.ts +0 -6
- package/dist/Values.d.ts.map +0 -1
- package/dist/Values.js.map +0 -1
- package/dist/axis/boundary/Boundaries.d.ts +0 -17
- package/dist/axis/boundary/Boundaries.d.ts.map +0 -1
- package/dist/axis/boundary/Boundaries.js +0 -25
- package/dist/axis/boundary/Boundaries.js.map +0 -1
- package/dist/lib/Checked.d.ts +0 -11
- package/dist/lib/Checked.d.ts.map +0 -1
- package/dist/lib/Checked.js +0 -2
- package/dist/lib/Checked.js.map +0 -1
- package/dist/projection/standard.d.ts +0 -14
- package/dist/projection/standard.d.ts.map +0 -1
- package/dist/projection/standard.js +0 -2
- package/dist/projection/standard.js.map +0 -1
- package/src/PartialValues.ts +0 -4
- package/src/axis/boundary/Boundaries.ts +0 -36
- package/src/lib/Checked.ts +0 -5
- package/src/projection/standard.ts +0 -13
- /package/dist/{Values.js → field/Values.js} +0 -0
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { Registry } from '../../lib/Registry.js';
|
|
2
|
-
/**
|
|
3
|
-
* `decoders` for a value coming in, `encoders` for one going out, `aliases` for the word
|
|
4
|
-
* that names a pair. Three registries, so a codec is never half declared.
|
|
5
|
-
* FR : `decoders` à l'entrée, `encoders` à la sortie, `aliases` pour le mot qui nomme la paire.
|
|
6
|
-
* `Boundaries.aliases.register('isoDate', { in: { decode: 'isoDate' }, out: { encode: 'isoDate' } })`
|
|
7
|
-
* → a field saying `boundary: 'isoDate'` decodes to a `Date` and leaves as a string
|
|
8
|
-
*/
|
|
9
|
-
export const Boundaries = {
|
|
10
|
-
decoders: new Registry('boundary decoder', 'call Boundaries.decoders.register(name, fn)'),
|
|
11
|
-
encoders: new Registry('boundary encoder', 'call Boundaries.encoders.register(name, fn)'),
|
|
12
|
-
aliases: new Registry('boundary alias'),
|
|
13
|
-
};
|
|
14
|
-
Boundaries.decoders.register('isoDate', (value) => {
|
|
15
|
-
if (value instanceof Date)
|
|
16
|
-
return { value };
|
|
17
|
-
if (typeof value === 'string') {
|
|
18
|
-
const date = new Date(value);
|
|
19
|
-
return Number.isNaN(date.getTime()) ? { error: 'Invalid date' } : { value: date };
|
|
20
|
-
}
|
|
21
|
-
return { error: 'Expected a date' };
|
|
22
|
-
});
|
|
23
|
-
Boundaries.encoders.register('isoDate', (value) => value instanceof Date ? value.toISOString() : value);
|
|
24
|
-
Boundaries.aliases.register('isoDate', { in: { decode: 'isoDate' }, out: { encode: 'isoDate' } });
|
|
25
|
-
//# sourceMappingURL=Boundaries.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Boundaries.js","sourceRoot":"","sources":["../../../src/axis/boundary/Boundaries.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,QAAQ,EAAE,IAAI,QAAQ,CACpB,kBAAkB,EAClB,6CAA6C,CAC9C;IACD,QAAQ,EAAE,IAAI,QAAQ,CACpB,kBAAkB,EAClB,6CAA6C,CAC9C;IACD,OAAO,EAAE,IAAI,QAAQ,CAAgB,gBAAgB,CAAC;CACvD,CAAC;AAEF,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE;IAChD,IAAI,KAAK,YAAY,IAAI;QAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC5C,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC;QAC7B,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;IACpF,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,iBAAiB,EAAE,CAAC;AACtC,CAAC,CAAC,CAAC;AACH,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE,CAChD,KAAK,YAAY,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,KAAK,CACpD,CAAC;AACF,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,SAAS,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,GAAG,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC"}
|
package/dist/lib/Checked.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A field's verdict. `path` is where INSIDE the value the refusal happened — empty when the
|
|
3
|
-
* field itself is refused, `['street']` when the shape below it is.
|
|
4
|
-
*/
|
|
5
|
-
export type Checked = {
|
|
6
|
-
value: unknown;
|
|
7
|
-
} | {
|
|
8
|
-
error: string;
|
|
9
|
-
path?: readonly string[];
|
|
10
|
-
};
|
|
11
|
-
//# sourceMappingURL=Checked.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Checked.d.ts","sourceRoot":"","sources":["../../src/lib/Checked.ts"],"names":[],"mappings":"AAAA;;;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"}
|
package/dist/lib/Checked.js
DELETED
package/dist/lib/Checked.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Checked.js","sourceRoot":"","sources":["../../src/lib/Checked.ts"],"names":[],"mappings":""}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The Standard Schema interface, from the package that owns it.
|
|
3
|
-
*
|
|
4
|
-
* This file used to CARRY the spec — 47 lines of hand-copied interface — and the copy had
|
|
5
|
-
* silently fallen a version behind: v1.1 gave `Props` a base it extends (`StandardTypedV1`)
|
|
6
|
-
* and gave `validate` a second `options` parameter. Nothing broke, because a realization may
|
|
7
|
-
* ignore an optional argument, which is exactly why nobody noticed. A standard is owned by
|
|
8
|
-
* whoever publishes it; the package is types only (`index.js` is zero bytes), so importing
|
|
9
|
-
* it costs a browser nothing.
|
|
10
|
-
*
|
|
11
|
-
* Documented: [Standard Schema](https://fougere.dev/docs/schema/standard-schema).
|
|
12
|
-
*/
|
|
13
|
-
export type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
14
|
-
//# sourceMappingURL=standard.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"standard.d.ts","sourceRoot":"","sources":["../../src/projection/standard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,YAAY,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"standard.js","sourceRoot":"","sources":["../../src/projection/standard.ts"],"names":[],"mappings":""}
|
package/src/PartialValues.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import type { Decoder } from './Decoder.js';
|
|
2
|
-
import type { Encoder } from './Encoder.js';
|
|
3
|
-
import type { BoundaryRules } from './BoundaryRules.js';
|
|
4
|
-
import { Registry } from '../../lib/Registry.js';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* `decoders` for a value coming in, `encoders` for one going out, `aliases` for the word
|
|
8
|
-
* that names a pair. Three registries, so a codec is never half declared.
|
|
9
|
-
* FR : `decoders` à l'entrée, `encoders` à la sortie, `aliases` pour le mot qui nomme la paire.
|
|
10
|
-
* `Boundaries.aliases.register('isoDate', { in: { decode: 'isoDate' }, out: { encode: 'isoDate' } })`
|
|
11
|
-
* → a field saying `boundary: 'isoDate'` decodes to a `Date` and leaves as a string
|
|
12
|
-
*/
|
|
13
|
-
export const Boundaries = {
|
|
14
|
-
decoders: new Registry<Decoder>(
|
|
15
|
-
'boundary decoder',
|
|
16
|
-
'call Boundaries.decoders.register(name, fn)',
|
|
17
|
-
),
|
|
18
|
-
encoders: new Registry<Encoder>(
|
|
19
|
-
'boundary encoder',
|
|
20
|
-
'call Boundaries.encoders.register(name, fn)',
|
|
21
|
-
),
|
|
22
|
-
aliases: new Registry<BoundaryRules>('boundary alias'),
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
Boundaries.decoders.register('isoDate', (value) => {
|
|
26
|
-
if (value instanceof Date) return { value };
|
|
27
|
-
if (typeof value === 'string') {
|
|
28
|
-
const date = new Date(value);
|
|
29
|
-
return Number.isNaN(date.getTime()) ? { error: 'Invalid date' } : { value: date };
|
|
30
|
-
}
|
|
31
|
-
return { error: 'Expected a date' };
|
|
32
|
-
});
|
|
33
|
-
Boundaries.encoders.register('isoDate', (value) =>
|
|
34
|
-
value instanceof Date ? value.toISOString() : value,
|
|
35
|
-
);
|
|
36
|
-
Boundaries.aliases.register('isoDate', { in: { decode: 'isoDate' }, out: { encode: 'isoDate' } });
|
package/src/lib/Checked.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The Standard Schema interface, from the package that owns it.
|
|
3
|
-
*
|
|
4
|
-
* This file used to CARRY the spec — 47 lines of hand-copied interface — and the copy had
|
|
5
|
-
* silently fallen a version behind: v1.1 gave `Props` a base it extends (`StandardTypedV1`)
|
|
6
|
-
* and gave `validate` a second `options` parameter. Nothing broke, because a realization may
|
|
7
|
-
* ignore an optional argument, which is exactly why nobody noticed. A standard is owned by
|
|
8
|
-
* whoever publishes it; the package is types only (`index.js` is zero bytes), so importing
|
|
9
|
-
* it costs a browser nothing.
|
|
10
|
-
*
|
|
11
|
-
* Documented: [Standard Schema](https://fougere.dev/docs/schema/standard-schema).
|
|
12
|
-
*/
|
|
13
|
-
export type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
File without changes
|