@orkestrel/contract 0.0.13 → 0.0.15
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/src/core/index.cjs +228 -70
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +47 -0
- package/dist/src/core/index.d.ts +47 -0
- package/dist/src/core/index.js +228 -71
- package/dist/src/core/index.js.map +1 -1
- package/package.json +16 -12
|
@@ -1214,6 +1214,14 @@ export declare class ContractCompiler<S extends ContractShape = ContractShape> i
|
|
|
1214
1214
|
* interrupted outer read, and every later read with one shared cause-free
|
|
1215
1215
|
* error.
|
|
1216
1216
|
*
|
|
1217
|
+
* After every family exists, the compiler releases its working set — the owned
|
|
1218
|
+
* graph, the node index, the order, and every family plan. A compiler read for
|
|
1219
|
+
* one artifact and then kept holds that whole set for as long as you keep the
|
|
1220
|
+
* compiler. A compiled artifact is the opposite: each one closes over the child
|
|
1221
|
+
* entries its family needed while that family was built, so it answers on its
|
|
1222
|
+
* own and outlives the compiler that produced it. When one artifact is what you
|
|
1223
|
+
* want, keep the artifact and let the compiler go.
|
|
1224
|
+
*
|
|
1217
1225
|
* @example
|
|
1218
1226
|
* ```ts
|
|
1219
1227
|
* const compiler = new ContractCompiler(stringShape({ min: 1 }))
|
|
@@ -1410,6 +1418,20 @@ export declare function createArrayFaults(shape: ArrayShape, length: number, pat
|
|
|
1410
1418
|
* longer re-walk and re-gate the declaration on every call the way they used
|
|
1411
1419
|
* to; `contract.audit` and `compileAuditor` are the same compiled function
|
|
1412
1420
|
* reached two ways.
|
|
1421
|
+
* The bundle is eager by intent. Its members are plain data properties holding
|
|
1422
|
+
* the compiled artifacts, so `const { is, parse } = createContract(shape)`
|
|
1423
|
+
* destructures those exact values and a spread of the result copies them; a
|
|
1424
|
+
* lazily compiled member would compile on either, which spends the laziness
|
|
1425
|
+
* rather than saving it. A malformed declaration refuses at this call rather
|
|
1426
|
+
* than at the first read of whichever member a caller happens to touch, so the
|
|
1427
|
+
* failure arrives at the call the caller made — carrying the authoring door's
|
|
1428
|
+
* own diagnosis, which this door adopts rather than rewraps. Every member is
|
|
1429
|
+
* self-contained, and the compiler this call builds releases its working set
|
|
1430
|
+
* before the call returns. The contract keeps part of the declaration even so:
|
|
1431
|
+
* the auditor and reporter plans close over the owned leaf and array nodes they
|
|
1432
|
+
* read their bounds from, so a kept contract retains those nodes and, through
|
|
1433
|
+
* an array node's `items` field, the subgraph beneath them. Nothing the caller
|
|
1434
|
+
* keeps reaches back into the compiler.
|
|
1413
1435
|
*
|
|
1414
1436
|
* @param shape - The shape to compile
|
|
1415
1437
|
* @returns A contract bundling `schema` / `is` / `parse` / `audit` / `explain` / `generate`
|
|
@@ -4752,6 +4774,31 @@ export declare function pickOf<S extends GuardsShape, K extends ReadonlyArray<ke
|
|
|
4752
4774
|
*/
|
|
4753
4775
|
export declare function pinMembers(prototype: object, owner: string): void;
|
|
4754
4776
|
|
|
4777
|
+
/**
|
|
4778
|
+
* The maximum number of object keys one compiled presence mask carries, frozen.
|
|
4779
|
+
*
|
|
4780
|
+
* @remarks
|
|
4781
|
+
* A compiled object plan decides which declared keys a value carries. The keys
|
|
4782
|
+
* it asks about are fixed when the plan is built, so the plan assigns each one a
|
|
4783
|
+
* bit position once and a call ORs one bit per own key it finds and compares the
|
|
4784
|
+
* result against the full mask — no per-call collection, and one integer compare
|
|
4785
|
+
* instead of one membership dispatch per declared key.
|
|
4786
|
+
*
|
|
4787
|
+
* The bound is the width a JavaScript bitwise operand has: `1 << position`
|
|
4788
|
+
* evaluates on a 32-bit signed integer, so positions run `0` through `30` and a
|
|
4789
|
+
* mask stays positive. A declaration with more keys than this is ordinary
|
|
4790
|
+
* authoring rather than an attack, so it is answered rather than refused:
|
|
4791
|
+
* {@link ContractCompiler} builds no position record for it and its compiled
|
|
4792
|
+
* guard, parser, auditor, and reporter decide presence from a collected key
|
|
4793
|
+
* vocabulary instead. Both branches answer identically; only the cost differs.
|
|
4794
|
+
*
|
|
4795
|
+
* @example
|
|
4796
|
+
* ```ts
|
|
4797
|
+
* PRESENCE_MASK_LIMIT // 31
|
|
4798
|
+
* ```
|
|
4799
|
+
*/
|
|
4800
|
+
export declare const PRESENCE_MASK_LIMIT = 31;
|
|
4801
|
+
|
|
4755
4802
|
/**
|
|
4756
4803
|
* Render a short, safe, TOTAL preview of an unknown value for a {@link Fault}'s
|
|
4757
4804
|
* `received` field.
|
package/dist/src/core/index.d.ts
CHANGED
|
@@ -1214,6 +1214,14 @@ export declare class ContractCompiler<S extends ContractShape = ContractShape> i
|
|
|
1214
1214
|
* interrupted outer read, and every later read with one shared cause-free
|
|
1215
1215
|
* error.
|
|
1216
1216
|
*
|
|
1217
|
+
* After every family exists, the compiler releases its working set — the owned
|
|
1218
|
+
* graph, the node index, the order, and every family plan. A compiler read for
|
|
1219
|
+
* one artifact and then kept holds that whole set for as long as you keep the
|
|
1220
|
+
* compiler. A compiled artifact is the opposite: each one closes over the child
|
|
1221
|
+
* entries its family needed while that family was built, so it answers on its
|
|
1222
|
+
* own and outlives the compiler that produced it. When one artifact is what you
|
|
1223
|
+
* want, keep the artifact and let the compiler go.
|
|
1224
|
+
*
|
|
1217
1225
|
* @example
|
|
1218
1226
|
* ```ts
|
|
1219
1227
|
* const compiler = new ContractCompiler(stringShape({ min: 1 }))
|
|
@@ -1410,6 +1418,20 @@ export declare function createArrayFaults(shape: ArrayShape, length: number, pat
|
|
|
1410
1418
|
* longer re-walk and re-gate the declaration on every call the way they used
|
|
1411
1419
|
* to; `contract.audit` and `compileAuditor` are the same compiled function
|
|
1412
1420
|
* reached two ways.
|
|
1421
|
+
* The bundle is eager by intent. Its members are plain data properties holding
|
|
1422
|
+
* the compiled artifacts, so `const { is, parse } = createContract(shape)`
|
|
1423
|
+
* destructures those exact values and a spread of the result copies them; a
|
|
1424
|
+
* lazily compiled member would compile on either, which spends the laziness
|
|
1425
|
+
* rather than saving it. A malformed declaration refuses at this call rather
|
|
1426
|
+
* than at the first read of whichever member a caller happens to touch, so the
|
|
1427
|
+
* failure arrives at the call the caller made — carrying the authoring door's
|
|
1428
|
+
* own diagnosis, which this door adopts rather than rewraps. Every member is
|
|
1429
|
+
* self-contained, and the compiler this call builds releases its working set
|
|
1430
|
+
* before the call returns. The contract keeps part of the declaration even so:
|
|
1431
|
+
* the auditor and reporter plans close over the owned leaf and array nodes they
|
|
1432
|
+
* read their bounds from, so a kept contract retains those nodes and, through
|
|
1433
|
+
* an array node's `items` field, the subgraph beneath them. Nothing the caller
|
|
1434
|
+
* keeps reaches back into the compiler.
|
|
1413
1435
|
*
|
|
1414
1436
|
* @param shape - The shape to compile
|
|
1415
1437
|
* @returns A contract bundling `schema` / `is` / `parse` / `audit` / `explain` / `generate`
|
|
@@ -4752,6 +4774,31 @@ export declare function pickOf<S extends GuardsShape, K extends ReadonlyArray<ke
|
|
|
4752
4774
|
*/
|
|
4753
4775
|
export declare function pinMembers(prototype: object, owner: string): void;
|
|
4754
4776
|
|
|
4777
|
+
/**
|
|
4778
|
+
* The maximum number of object keys one compiled presence mask carries, frozen.
|
|
4779
|
+
*
|
|
4780
|
+
* @remarks
|
|
4781
|
+
* A compiled object plan decides which declared keys a value carries. The keys
|
|
4782
|
+
* it asks about are fixed when the plan is built, so the plan assigns each one a
|
|
4783
|
+
* bit position once and a call ORs one bit per own key it finds and compares the
|
|
4784
|
+
* result against the full mask — no per-call collection, and one integer compare
|
|
4785
|
+
* instead of one membership dispatch per declared key.
|
|
4786
|
+
*
|
|
4787
|
+
* The bound is the width a JavaScript bitwise operand has: `1 << position`
|
|
4788
|
+
* evaluates on a 32-bit signed integer, so positions run `0` through `30` and a
|
|
4789
|
+
* mask stays positive. A declaration with more keys than this is ordinary
|
|
4790
|
+
* authoring rather than an attack, so it is answered rather than refused:
|
|
4791
|
+
* {@link ContractCompiler} builds no position record for it and its compiled
|
|
4792
|
+
* guard, parser, auditor, and reporter decide presence from a collected key
|
|
4793
|
+
* vocabulary instead. Both branches answer identically; only the cost differs.
|
|
4794
|
+
*
|
|
4795
|
+
* @example
|
|
4796
|
+
* ```ts
|
|
4797
|
+
* PRESENCE_MASK_LIMIT // 31
|
|
4798
|
+
* ```
|
|
4799
|
+
*/
|
|
4800
|
+
export declare const PRESENCE_MASK_LIMIT = 31;
|
|
4801
|
+
|
|
4755
4802
|
/**
|
|
4756
4803
|
* Render a short, safe, TOTAL preview of an unknown value for a {@link Fault}'s
|
|
4757
4804
|
* `received` field.
|