@smthrs/plan 1.0.0-rc.5 → 1.0.0-rc.6
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/CHANGELOG.md +2 -0
- package/README.md +5 -5
- package/THIRD_PARTY_NOTICES.md +48 -0
- package/dist/cjs/KeyMaterial.d.ts +1 -1
- package/dist/cjs/KeyMaterial.js.map +1 -1
- package/dist/cjs/Node.d.ts +71 -0
- package/dist/cjs/Node.d.ts.map +1 -1
- package/dist/cjs/Node.js +7 -0
- package/dist/cjs/Node.js.map +2 -2
- package/dist/cjs/StepKey.d.ts +1 -1
- package/dist/cjs/StepKey.js.map +1 -1
- package/dist/cjs/internal/SchemaIdentity.d.ts +140 -0
- package/dist/cjs/internal/SchemaIdentity.d.ts.map +1 -0
- package/dist/cjs/internal/SchemaIdentity.js +718 -0
- package/dist/cjs/internal/SchemaIdentity.js.map +7 -0
- package/dist/cjs/internal/node.d.ts +1 -1
- package/dist/cjs/internal/node.d.ts.map +1 -1
- package/dist/cjs/internal/node.js +2 -1
- package/dist/cjs/internal/node.js.map +2 -2
- package/dist/esm/KeyMaterial.d.ts +1 -1
- package/dist/esm/KeyMaterial.js +1 -1
- package/dist/esm/KeyMaterial.js.map +1 -1
- package/dist/esm/Node.d.ts +71 -0
- package/dist/esm/Node.d.ts.map +1 -1
- package/dist/esm/Node.js +46 -0
- package/dist/esm/Node.js.map +1 -1
- package/dist/esm/StepKey.d.ts +1 -1
- package/dist/esm/StepKey.js +1 -1
- package/dist/esm/StepKey.js.map +1 -1
- package/dist/esm/internal/SchemaIdentity.d.ts +140 -0
- package/dist/esm/internal/SchemaIdentity.d.ts.map +1 -0
- package/dist/esm/internal/SchemaIdentity.js +1002 -0
- package/dist/esm/internal/SchemaIdentity.js.map +1 -0
- package/dist/esm/internal/node.d.ts +1 -1
- package/dist/esm/internal/node.d.ts.map +1 -1
- package/dist/esm/internal/node.js +3 -2
- package/dist/esm/internal/node.js.map +1 -1
- package/docs/README.md +1 -1
- package/docs/api.md +11 -1
- package/docs/concepts/authoring-ast.md +2 -1
- package/docs/installation.md +3 -3
- package/package.json +9 -8
- package/src/KeyMaterial.ts +1 -1
- package/src/Node.ts +79 -0
- package/src/StepKey.ts +1 -1
- package/src/internal/SchemaIdentity.ts +1096 -0
- package/src/internal/node.ts +3 -2
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The schema identity projection: the JSON-Schema-shaped document a schema
|
|
3
|
+
* contributes to a step key.
|
|
4
|
+
*
|
|
5
|
+
* A call node folds what its callee accepts and produces into the material a
|
|
6
|
+
* step key is derived from, and a catch node folds its filter the same way. A
|
|
7
|
+
* projection that printed differently under another `effect` release would
|
|
8
|
+
* re-key every recorded step in every journal at once. `effect` is a peer
|
|
9
|
+
* range, so the application picks the release; the projection therefore
|
|
10
|
+
* cannot be the installed `Schema.toJsonSchemaDocument`. `effect@4.0.4`
|
|
11
|
+
* already changed what that emitter prints for `Schema.Int`, `isMinLength`,
|
|
12
|
+
* `isPattern`, repeated bounds, `oneOf` unions and shared definitions.
|
|
13
|
+
*
|
|
14
|
+
* This module owns the bytes instead. It reads the schema through two public
|
|
15
|
+
* functions, `Schema.toCodecJson` and `Schema.toRepresentation`, and prints
|
|
16
|
+
* the result with the emitter and the check fragments fixed below, which
|
|
17
|
+
* reproduce `Schema.toJsonSchemaDocument(schema, options)` of
|
|
18
|
+
* `effect@4.0.0-rc.115` for both values of `onExcessProperty`.
|
|
19
|
+
*
|
|
20
|
+
* It is for identity only. Where a JSON Schema is shown to a model or a
|
|
21
|
+
* person, the installed emitter is the right one.
|
|
22
|
+
*
|
|
23
|
+
* What still moves an identity, by design: a release that changes a schema's
|
|
24
|
+
* JSON codec or its representation changes what the schema accepts on the
|
|
25
|
+
* wire. Three limits follow from what the representation carries:
|
|
26
|
+
*
|
|
27
|
+
* - A built-in check contributes the constraint its id and payload name. A
|
|
28
|
+
* `toJsonSchema` annotation passed to a built-in check constructor is not
|
|
29
|
+
* consulted; one on a `makeFilter` check is.
|
|
30
|
+
* - A built-in check this module does not list falls back to the installed
|
|
31
|
+
* check's own `toJsonSchema` annotation.
|
|
32
|
+
* - `Schema.brand` is not part of the representation from `effect@4.0.4` on.
|
|
33
|
+
* Under rc.115 a schema that takes a definition (an `identifier` or a
|
|
34
|
+
* recursive schema) and appeared both branded and unbranded in one document
|
|
35
|
+
* got two definitions; it now gets one.
|
|
36
|
+
*
|
|
37
|
+
* Provenance: {@link fromRepresentation} and its helpers are adapted from
|
|
38
|
+
* `effect@4.0.0-rc.115` (MIT, Copyright (c) 2023 Effectful Technologies Inc;
|
|
39
|
+
* the notice is in this package's `THIRD_PARTY_NOTICES.md`), files
|
|
40
|
+
* `src/internal/schema/toJsonSchemaDocument.ts`, `src/JsonSchema.ts`
|
|
41
|
+
* (`rewriteRefs`), `src/JsonPointer.ts` and `src/SchemaAST.ts` (`isJson`).
|
|
42
|
+
* Changes: `onExcessProperty` is the only option; one root; a built-in
|
|
43
|
+
* check's fragment comes from {@link builtinChecks}, not from
|
|
44
|
+
* the installed annotation; an approximate check result contributes its
|
|
45
|
+
* schema.
|
|
46
|
+
*
|
|
47
|
+
* @since 1.0.0
|
|
48
|
+
*/
|
|
49
|
+
import type * as JsonSchema from "effect/JsonSchema";
|
|
50
|
+
import * as Schema from "effect/Schema";
|
|
51
|
+
import type * as SchemaAST from "effect/SchemaAST";
|
|
52
|
+
import * as SchemaRepresentation from "effect/SchemaRepresentation";
|
|
53
|
+
/**
|
|
54
|
+
* The document a schema's identity is: exactly what rc.115 returned from
|
|
55
|
+
* `Schema.toJsonSchemaDocument`, key order included.
|
|
56
|
+
*
|
|
57
|
+
* @since 1.0.0
|
|
58
|
+
* @private
|
|
59
|
+
*/
|
|
60
|
+
export type Document = JsonSchema.Document<"draft-2020-12">;
|
|
61
|
+
/**
|
|
62
|
+
* How an object schema treats a key it does not declare, which is the one
|
|
63
|
+
* emitter option a declaration's identity is taken under. It has rc.115's
|
|
64
|
+
* meaning and rc.115's default: `"ignore"` leaves such keys open, `"error"`
|
|
65
|
+
* closes them.
|
|
66
|
+
*
|
|
67
|
+
* @since 1.0.0
|
|
68
|
+
* @private
|
|
69
|
+
*/
|
|
70
|
+
export interface Options {
|
|
71
|
+
readonly onExcessProperty?: "ignore" | "error" | undefined;
|
|
72
|
+
}
|
|
73
|
+
declare const SchemaIdentityError_base: Schema.Class<SchemaIdentityError, Schema.TaggedStruct<"@smthrs/plan/SchemaIdentityError", {
|
|
74
|
+
readonly message: Schema.String;
|
|
75
|
+
}>, import("effect/Cause").YieldableError>;
|
|
76
|
+
/**
|
|
77
|
+
* A schema a step key cannot be derived from: one with no JSON Schema form or
|
|
78
|
+
* no representation, or one whose built-in check the installed `effect`
|
|
79
|
+
* describes differently from the releases this package supports. The message
|
|
80
|
+
* is the one `effect@4.0.0-rc.115` gave for the same schema, where it gave one.
|
|
81
|
+
*
|
|
82
|
+
* @since 1.0.0
|
|
83
|
+
* @category errors
|
|
84
|
+
*/
|
|
85
|
+
export declare class SchemaIdentityError extends SchemaIdentityError_base {
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* The ids {@link builtinChecks} lists, for the test that holds the list
|
|
89
|
+
* against the checks the installed `effect` can revive.
|
|
90
|
+
*
|
|
91
|
+
* @since 1.0.0
|
|
92
|
+
* @private
|
|
93
|
+
*/
|
|
94
|
+
export declare const builtinCheckIds: ReadonlyArray<string>;
|
|
95
|
+
/**
|
|
96
|
+
* Prints a representation document as the JSON Schema document rc.115
|
|
97
|
+
* printed for it under the same options.
|
|
98
|
+
*
|
|
99
|
+
* Reserved for {@link schemaIdentity} and for the tests that hand it a
|
|
100
|
+
* representation no schema produces.
|
|
101
|
+
*
|
|
102
|
+
* @since 1.0.0
|
|
103
|
+
* @private
|
|
104
|
+
*/
|
|
105
|
+
export declare const fromRepresentation: (document: SchemaRepresentation.Document, options?: Options) => Document;
|
|
106
|
+
/**
|
|
107
|
+
* The identity a schema contributes: a pure function of the schema and the
|
|
108
|
+
* option, and of nothing the installed `effect` release prints. It takes the
|
|
109
|
+
* place of `Schema.toJsonSchemaDocument(schema, options)` wherever the
|
|
110
|
+
* document is hashed, compared or pinned.
|
|
111
|
+
*
|
|
112
|
+
* Throws what rc.115 threw for a schema with no JSON Schema form: more than
|
|
113
|
+
* one rest element, a record key that is neither a string nor a template, a
|
|
114
|
+
* `toJsonSchema` annotation that throws.
|
|
115
|
+
*
|
|
116
|
+
* @since 1.0.0
|
|
117
|
+
* @private
|
|
118
|
+
*/
|
|
119
|
+
export declare const schemaIdentity: (schema: Schema.Top, options?: Options) => Document;
|
|
120
|
+
/**
|
|
121
|
+
* The representation identity of a schema AST: what
|
|
122
|
+
* `SchemaRepresentation.toJson(SchemaRepresentation.toRepresentation(ast))`
|
|
123
|
+
* returned under `effect@4.0.0-rc.115`, key order included. A sealed action's
|
|
124
|
+
* step key hashes it, so it must not move with the installed `effect`.
|
|
125
|
+
*
|
|
126
|
+
* The installed release encodes the representation; this writes back the six
|
|
127
|
+
* check ids renamed after rc.115. One difference cannot be undone: from
|
|
128
|
+
* `effect@4.0.4` on, `Schema.brand` is not part of the AST, so the `brands`
|
|
129
|
+
* annotation rc.115 wrote is absent and a declaration with a brand re-keys
|
|
130
|
+
* once.
|
|
131
|
+
*
|
|
132
|
+
* Throws what rc.115 threw for an AST with no representation, such as one
|
|
133
|
+
* whose check carries no `representation` annotation.
|
|
134
|
+
*
|
|
135
|
+
* @since 1.0.0
|
|
136
|
+
* @private
|
|
137
|
+
*/
|
|
138
|
+
export declare const representationIdentity: (ast: SchemaAST.AST) => Schema.Json;
|
|
139
|
+
export {};
|
|
140
|
+
//# sourceMappingURL=SchemaIdentity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SchemaIdentity.d.ts","sourceRoot":"","sources":["../../../src/internal/SchemaIdentity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAEH,OAAO,KAAK,KAAK,UAAU,MAAM,mBAAmB,CAAA;AACpD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,SAAS,MAAM,kBAAkB,CAAA;AAClD,OAAO,KAAK,oBAAoB,MAAM,6BAA6B,CAAA;AAiBnE;;;;;;GAMG;AACH,MAAM,MAAM,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAA;AAE3D;;;;;;;;GAQG;AACH,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,gBAAgB,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,SAAS,CAAA;CAC3D;;;;AAED;;;;;;;;GAQG;AACH,qBAAa,mBAAoB,SAAQ,wBAEvC;CAAG;AA2VL;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,EAAE,aAAa,CAAC,MAAM,CAA6B,CAAA;AAyM/E;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,GAAI,UAAU,oBAAoB,CAAC,QAAQ,EAAE,UAAU,OAAO,KAAG,QAuV/F,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,cAAc,GAAI,QAAQ,MAAM,CAAC,GAAG,EAAE,UAAU,OAAO,KAAG,QACW,CAAA;AAkDlF;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,sBAAsB,GAAI,KAAK,SAAS,CAAC,GAAG,KAAG,MAAM,CAAC,IACyB,CAAA"}
|