@prisma-next/contract 0.11.0 → 0.12.0-dev.10
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/canonicalization-Di-tQ20o.d.mts +69 -0
- package/dist/canonicalization-Di-tQ20o.d.mts.map +1 -0
- package/dist/canonicalization-path-match-b2jFuEso.mjs +25 -0
- package/dist/canonicalization-path-match-b2jFuEso.mjs.map +1 -0
- package/dist/{contract-types-Bt2uyqs3.d.mts → contract-types-jgIOdqua.d.mts} +68 -73
- package/dist/contract-types-jgIOdqua.d.mts.map +1 -0
- package/dist/contract-validation-error-ClZaKqMW.mjs +20 -0
- package/dist/contract-validation-error-ClZaKqMW.mjs.map +1 -0
- package/dist/contract-validation-error-T5LH4DW-.d.mts +13 -0
- package/dist/contract-validation-error-T5LH4DW-.d.mts.map +1 -0
- package/dist/contract-validation-error.d.mts +2 -10
- package/dist/contract-validation-error.mjs +2 -2
- package/dist/domain-envelope-Cv5OTm8D.d.mts +110 -0
- package/dist/domain-envelope-Cv5OTm8D.d.mts.map +1 -0
- package/dist/hashing-utils.d.mts +19 -0
- package/dist/hashing-utils.d.mts.map +1 -0
- package/dist/hashing-utils.mjs +50 -0
- package/dist/hashing-utils.mjs.map +1 -0
- package/dist/hashing.d.mts +8 -37
- package/dist/hashing.d.mts.map +1 -1
- package/dist/hashing.mjs +175 -1
- package/dist/hashing.mjs.map +1 -0
- package/dist/namespace-id-CVpkSFUK.mjs +9 -0
- package/dist/namespace-id-CVpkSFUK.mjs.map +1 -0
- package/dist/types.d.mts +4 -2
- package/dist/types.mjs +104 -2
- package/dist/types.mjs.map +1 -0
- package/dist/validate-domain.d.mts +6 -8
- package/dist/validate-domain.d.mts.map +1 -1
- package/dist/validate-domain.mjs +99 -56
- package/dist/validate-domain.mjs.map +1 -1
- package/package.json +16 -9
- package/src/canonicalization-path-match.ts +44 -0
- package/src/canonicalization-storage-sort.ts +88 -0
- package/src/canonicalization.ts +92 -161
- package/src/contract-types.ts +35 -7
- package/src/contract-validation-error.ts +7 -0
- package/src/control-policy.ts +25 -0
- package/src/cross-reference.ts +28 -0
- package/src/domain-envelope.ts +87 -0
- package/src/domain-types.ts +13 -15
- package/src/exports/contract-validation-error.ts +1 -0
- package/src/exports/hashing-utils.ts +12 -0
- package/src/exports/hashing.ts +2 -0
- package/src/exports/types.ts +27 -1
- package/src/hashing.ts +28 -11
- package/src/namespace-id.ts +10 -0
- package/src/types.ts +35 -0
- package/src/validate-domain.ts +162 -94
- package/dist/contract-types-Bt2uyqs3.d.mts.map +0 -1
- package/dist/contract-validation-error-Dp2vHZt5.mjs +0 -14
- package/dist/contract-validation-error-Dp2vHZt5.mjs.map +0 -1
- package/dist/contract-validation-error.d.mts.map +0 -1
- package/dist/hashing-rZiqFOlc.mjs +0 -204
- package/dist/hashing-rZiqFOlc.mjs.map +0 -1
- package/dist/testing.d.mts +0 -32
- package/dist/testing.d.mts.map +0 -1
- package/dist/testing.mjs +0 -63
- package/dist/testing.mjs.map +0 -1
- package/dist/types-CVGwkRLa.mjs +0 -46
- package/dist/types-CVGwkRLa.mjs.map +0 -1
- package/src/exports/testing.ts +0 -1
- package/src/testing-factories.ts +0 -115
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { t as Contract } from "./contract-types-jgIOdqua.mjs";
|
|
2
|
+
import { JsonObject } from "@prisma-next/utils/json";
|
|
3
|
+
|
|
4
|
+
//#region src/canonicalization.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Per-target contract serializer hook. The framework canonicalizer uses
|
|
7
|
+
* this to convert an in-memory contract (which may carry class-instance
|
|
8
|
+
* IR nodes whose runtime-only fields must not appear in the on-disk
|
|
9
|
+
* envelope) into a plain JsonObject before applying the family-agnostic
|
|
10
|
+
* canonical-key ordering / default-omission / sort steps. Targets whose
|
|
11
|
+
* contract is JSON-clean by construction return the contract unchanged.
|
|
12
|
+
*/
|
|
13
|
+
type SerializeContract = (contract: Contract) => JsonObject;
|
|
14
|
+
/**
|
|
15
|
+
* Family-contributed predicate for the default-omission walk. Called when
|
|
16
|
+
* a value at `path` is a default (empty object/array or `false`); if this
|
|
17
|
+
* returns `true` the value is kept rather than stripped.
|
|
18
|
+
*
|
|
19
|
+
* The framework only calls the predicate inside the `isDefaultValue` branch,
|
|
20
|
+
* so there is no need to guard against non-default values.
|
|
21
|
+
*/
|
|
22
|
+
type PreserveEmptyPredicate = (path: readonly string[]) => boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Family-contributed storage sort. Applied to the serialized `storage`
|
|
25
|
+
* subtree after the default-omission walk; the result replaces the
|
|
26
|
+
* `storage` field before the final key sort. Use to establish a
|
|
27
|
+
* deterministic order for storage arrays (indexes, uniques) that the
|
|
28
|
+
* family-agnostic `sortObjectKeys` pass cannot handle.
|
|
29
|
+
*/
|
|
30
|
+
type StorageSort = (storage: unknown) => unknown;
|
|
31
|
+
interface CanonicalizeContractOptions {
|
|
32
|
+
readonly schemaVersion?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Per-target hook that converts the in-memory contract (which may
|
|
35
|
+
* carry class-instance IR nodes) into a plain JsonObject before the
|
|
36
|
+
* family-agnostic canonicalization steps run.
|
|
37
|
+
*
|
|
38
|
+
* Routing through the hook is what lets each target decide which
|
|
39
|
+
* fields appear in the on-disk envelope; runtime-only class API
|
|
40
|
+
* fields stay invisible to the canonicalization walk by virtue of
|
|
41
|
+
* the per-target serializer not putting them in the JSON shape.
|
|
42
|
+
*/
|
|
43
|
+
readonly serializeContract: SerializeContract;
|
|
44
|
+
/**
|
|
45
|
+
* Family-contributed preserve-empty predicate. When the walk encounters a
|
|
46
|
+
* default value (empty object/array or `false`) at `path`, calling this
|
|
47
|
+
* with the full path allows the family to veto the omission. If absent,
|
|
48
|
+
* only the framework's family-agnostic required-slot rules apply.
|
|
49
|
+
*/
|
|
50
|
+
readonly shouldPreserveEmpty?: PreserveEmptyPredicate;
|
|
51
|
+
/**
|
|
52
|
+
* Family-contributed storage sort. Applied to the serialized `storage`
|
|
53
|
+
* subtree after the default-omission walk, before the final key sort.
|
|
54
|
+
* SQL family uses this to impose a deterministic order on `indexes` and
|
|
55
|
+
* `uniques` arrays within each namespace table. Families that require no
|
|
56
|
+
* special storage ordering omit this hook.
|
|
57
|
+
*/
|
|
58
|
+
readonly sortStorage?: StorageSort;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Object-form variant of {@link canonicalizeContract}. Exported because the
|
|
62
|
+
* emitter writes the canonical contract through a separate JSON-stringify
|
|
63
|
+
* pass and consumes the structured object directly.
|
|
64
|
+
*/
|
|
65
|
+
declare function canonicalizeContractToObject(contract: Contract, options: CanonicalizeContractOptions): Record<string, unknown>;
|
|
66
|
+
declare function canonicalizeContract(contract: Contract, options: CanonicalizeContractOptions): string;
|
|
67
|
+
//#endregion
|
|
68
|
+
export { canonicalizeContract as a, StorageSort as i, PreserveEmptyPredicate as n, canonicalizeContractToObject as o, SerializeContract as r, CanonicalizeContractOptions as t };
|
|
69
|
+
//# sourceMappingURL=canonicalization-Di-tQ20o.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canonicalization-Di-tQ20o.d.mts","names":[],"sources":["../src/canonicalization.ts"],"mappings":";;;;;;AAcA;;;;;;KAAY,iBAAA,IAAqB,QAAA,EAAU,QAAA,KAAa,UAAU;;AAAA;AAUlE;;;;AAA6D;AAS7D;KATY,sBAAA,IAA0B,IAAuB;;;AASlB;AA6K3C;;;;KA7KY,WAAA,IAAe,OAAgB;AAAA,UA6K1B,2BAAA;EAAA,SACN,aAAA;EAAA;;;;;;;;AA0ByB;AAQpC;EAlCW,SAWA,iBAAA,EAAmB,iBAAA;;;;;;;WAOnB,mBAAA,GAAsB,sBAAA;EAiB/B;;;;;AAEO;AA0BT;EA5BE,SATS,WAAA,GAAc,WAAA;AAAA;;;;;;iBAQT,4BAAA,CACd,QAAA,EAAU,QAAA,EACV,OAAA,EAAS,2BAAA,GACR,MAAA;AAAA,iBA0Ba,oBAAA,CACd,QAAA,EAAU,QAAA,EACV,OAAA,EAAS,2BAA2B"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//#region src/canonicalization-path-match.ts
|
|
2
|
+
function matchesPathPattern(path, pattern) {
|
|
3
|
+
if (path.length !== pattern.length) return false;
|
|
4
|
+
for (let i = 0; i < pattern.length; i++) {
|
|
5
|
+
const segment = pattern[i];
|
|
6
|
+
const value = path[i];
|
|
7
|
+
if (segment === void 0 || value === void 0) return false;
|
|
8
|
+
if (segment === "*") continue;
|
|
9
|
+
if (typeof segment === "string") {
|
|
10
|
+
if (value !== segment) return false;
|
|
11
|
+
continue;
|
|
12
|
+
}
|
|
13
|
+
if (Array.isArray(segment)) {
|
|
14
|
+
if (!segment.includes(value)) return false;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
function createPreserveEmptyPredicate(patterns) {
|
|
20
|
+
return (path) => patterns.some((pattern) => matchesPathPattern(path, pattern));
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
export { matchesPathPattern as n, createPreserveEmptyPredicate as t };
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=canonicalization-path-match-b2jFuEso.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canonicalization-path-match-b2jFuEso.mjs","names":[],"sources":["../src/canonicalization-path-match.ts"],"sourcesContent":["import type { PreserveEmptyPredicate } from './canonicalization';\n\nexport type PathSegment = string | '*' | readonly string[];\n\nexport type PathPattern = readonly PathSegment[];\n\nexport function matchesPathPattern(path: readonly string[], pattern: PathPattern): boolean {\n if (path.length !== pattern.length) {\n return false;\n }\n\n for (let i = 0; i < pattern.length; i++) {\n const segment = pattern[i];\n const value = path[i];\n if (segment === undefined || value === undefined) {\n return false;\n }\n\n if (segment === '*') {\n continue;\n }\n\n if (typeof segment === 'string') {\n if (value !== segment) {\n return false;\n }\n continue;\n }\n\n if (Array.isArray(segment)) {\n if (!segment.includes(value)) {\n return false;\n }\n }\n }\n\n return true;\n}\n\nexport function createPreserveEmptyPredicate(\n patterns: readonly PathPattern[],\n): PreserveEmptyPredicate {\n return (path) => patterns.some((pattern) => matchesPathPattern(path, pattern));\n}\n"],"mappings":";AAMA,SAAgB,mBAAmB,MAAyB,SAA+B;CACzF,IAAI,KAAK,WAAW,QAAQ,QAC1B,OAAO;CAGT,KAAK,IAAI,IAAI,GAAG,IAAI,QAAQ,QAAQ,KAAK;EACvC,MAAM,UAAU,QAAQ;EACxB,MAAM,QAAQ,KAAK;EACnB,IAAI,YAAY,KAAA,KAAa,UAAU,KAAA,GACrC,OAAO;EAGT,IAAI,YAAY,KACd;EAGF,IAAI,OAAO,YAAY,UAAU;GAC/B,IAAI,UAAU,SACZ,OAAO;GAET;EACF;EAEA,IAAI,MAAM,QAAQ,OAAO;OACnB,CAAC,QAAQ,SAAS,KAAK,GACzB,OAAO;EAAA;CAGb;CAEA,OAAO;AACT;AAEA,SAAgB,6BACd,UACwB;CACxB,QAAQ,SAAS,SAAS,MAAM,YAAY,mBAAmB,MAAM,OAAO,CAAC;AAC/E"}
|
|
@@ -1,67 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
readonly localFields: readonly string[];
|
|
24
|
-
readonly targetFields: readonly string[];
|
|
25
|
-
};
|
|
26
|
-
type ContractReferenceRelation = {
|
|
27
|
-
readonly to: string;
|
|
28
|
-
readonly cardinality: '1:1' | '1:N' | 'N:1';
|
|
29
|
-
readonly on: ContractRelationOn;
|
|
30
|
-
};
|
|
31
|
-
type ContractEmbedRelation = {
|
|
32
|
-
readonly to: string;
|
|
33
|
-
readonly cardinality: '1:1' | '1:N';
|
|
34
|
-
};
|
|
35
|
-
type ContractRelation = ContractReferenceRelation | ContractEmbedRelation;
|
|
36
|
-
type ContractDiscriminator = {
|
|
37
|
-
readonly field: string;
|
|
38
|
-
};
|
|
39
|
-
type ContractVariantEntry = {
|
|
40
|
-
readonly value: string;
|
|
41
|
-
};
|
|
42
|
-
type ContractValueObject = {
|
|
43
|
-
readonly fields: Record<string, ContractField>;
|
|
44
|
-
};
|
|
45
|
-
type ModelStorageBase = Readonly<Record<string, unknown>>;
|
|
46
|
-
interface ContractModelBase<TModelStorage extends ModelStorageBase = ModelStorageBase> {
|
|
47
|
-
readonly fields: Record<string, ContractField>;
|
|
48
|
-
readonly relations: Record<string, ContractRelation>;
|
|
49
|
-
readonly storage: TModelStorage;
|
|
50
|
-
readonly discriminator?: ContractDiscriminator;
|
|
51
|
-
readonly variants?: Record<string, ContractVariantEntry>;
|
|
52
|
-
readonly base?: string;
|
|
53
|
-
readonly owner?: string;
|
|
54
|
-
}
|
|
55
|
-
interface ContractModel<TModelStorage extends ModelStorageBase = ModelStorageBase> extends ContractModelBase<TModelStorage> {
|
|
56
|
-
readonly fields: Record<string, ContractField>;
|
|
57
|
-
}
|
|
58
|
-
type HasModelsWithRelations = {
|
|
59
|
-
readonly models: Record<string, {
|
|
60
|
-
readonly relations: Record<string, ContractRelation>;
|
|
61
|
-
}>;
|
|
62
|
-
};
|
|
63
|
-
type ReferenceRelationKeys<TContract extends HasModelsWithRelations, ModelName extends string & keyof TContract['models']> = { [K in keyof TContract['models'][ModelName]['relations']]: TContract['models'][ModelName]['relations'][K] extends ContractReferenceRelation ? K : never }[keyof TContract['models'][ModelName]['relations']];
|
|
64
|
-
type EmbedRelationKeys<TContract extends HasModelsWithRelations, ModelName extends string & keyof TContract['models']> = { [K in keyof TContract['models'][ModelName]['relations']]: TContract['models'][ModelName]['relations'][K] extends ContractReferenceRelation ? never : K }[keyof TContract['models'][ModelName]['relations']];
|
|
1
|
+
import { T as CrossReference, _ as ContractValueObject, p as ContractModelBase, t as ApplicationDomain } from "./domain-envelope-Cv5OTm8D.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/control-policy.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Governance posture for a storage-plane node or for the contract as a whole.
|
|
6
|
+
*
|
|
7
|
+
* - `managed` — Prisma Next owns the full lifecycle (DDL, migrations, verification).
|
|
8
|
+
* - `tolerated` — node was found in the database but is not schema-managed; Prisma Next
|
|
9
|
+
* leaves it untouched while tracking its existence.
|
|
10
|
+
* - `external` — node is owned by an external system; Prisma Next never emits DDL for it.
|
|
11
|
+
* - `observed` — read-only access; Prisma Next does not write to or migrate the node.
|
|
12
|
+
*/
|
|
13
|
+
type ControlPolicy = 'managed' | 'tolerated' | 'external' | 'observed';
|
|
14
|
+
/**
|
|
15
|
+
* Resolves the effective control policy for a storage-plane node.
|
|
16
|
+
*
|
|
17
|
+
* Precedence: node-level value → contract default → `'managed'`.
|
|
18
|
+
*
|
|
19
|
+
* Both parameters are optional raw values so this function stays node-type-agnostic
|
|
20
|
+
* and can be called by any consumer (verifier, planner, etc.) without importing IR classes.
|
|
21
|
+
*/
|
|
22
|
+
declare function effectiveControl(nodeControl: ControlPolicy | undefined, defaultControl: ControlPolicy | undefined): ControlPolicy;
|
|
65
23
|
//#endregion
|
|
66
24
|
//#region src/types.d.ts
|
|
67
25
|
/**
|
|
@@ -98,13 +56,32 @@ declare function coreHash<const T extends string>(value: T): StorageHashBase<T>;
|
|
|
98
56
|
*/
|
|
99
57
|
type ProfileHashBase<THash extends string> = THash & Brand<'ProfileHash'>;
|
|
100
58
|
declare function profileHash<const T extends string>(value: T): ProfileHashBase<T>;
|
|
59
|
+
/**
|
|
60
|
+
* One entity-kind slot in a namespace — a map of entity name to entry.
|
|
61
|
+
* Values are opaque at the foundation layer; family and target concretions
|
|
62
|
+
* refine them to typed IR classes.
|
|
63
|
+
*/
|
|
64
|
+
type StorageEntitySlot = Readonly<Record<string, unknown>>;
|
|
65
|
+
/**
|
|
66
|
+
* Plain-data namespace entry in a storage block. Every hydrated contract
|
|
67
|
+
* carries at least `id` plus zero or more entity-kind slot maps (`tables`,
|
|
68
|
+
* `collections`, …). Foundation declares only this shape — no IR machinery.
|
|
69
|
+
*/
|
|
70
|
+
interface StorageNamespace {
|
|
71
|
+
readonly id: string;
|
|
72
|
+
}
|
|
101
73
|
/**
|
|
102
74
|
* Base type for family-specific storage blocks.
|
|
103
75
|
* Family storage types (SqlStorage, MongoStorage, etc.) extend this to carry the
|
|
104
76
|
* storage hash alongside family-specific data (tables, collections, etc.).
|
|
77
|
+
*
|
|
78
|
+
* The `namespaces` map is carried by every hydrated storage block. Serialized
|
|
79
|
+
* envelope shape is target-owned; this types the in-memory contract after
|
|
80
|
+
* `deserializeContract`.
|
|
105
81
|
*/
|
|
106
82
|
interface StorageBase<THash extends string = string> {
|
|
107
83
|
readonly storageHash: StorageHashBase<THash>;
|
|
84
|
+
readonly namespaces: Readonly<Record<string, StorageNamespace>>;
|
|
108
85
|
}
|
|
109
86
|
interface FieldType {
|
|
110
87
|
readonly type: string;
|
|
@@ -217,6 +194,19 @@ interface ContractMarkerRecord {
|
|
|
217
194
|
readonly meta: Record<string, unknown>;
|
|
218
195
|
readonly invariants: readonly string[];
|
|
219
196
|
}
|
|
197
|
+
/**
|
|
198
|
+
* One applied migration edge from the per-space ledger journal.
|
|
199
|
+
* Returned by `readLedger` in append (apply) order.
|
|
200
|
+
*/
|
|
201
|
+
interface LedgerEntryRecord {
|
|
202
|
+
readonly space: string;
|
|
203
|
+
readonly migrationName: string;
|
|
204
|
+
readonly migrationHash: string;
|
|
205
|
+
readonly from: string | null;
|
|
206
|
+
readonly to: string;
|
|
207
|
+
readonly appliedAt: Date;
|
|
208
|
+
readonly operationCount: number;
|
|
209
|
+
}
|
|
220
210
|
//#endregion
|
|
221
211
|
//#region src/contract-types.d.ts
|
|
222
212
|
/**
|
|
@@ -252,22 +242,27 @@ type ContractExecutionSection<THash extends string = string> = {
|
|
|
252
242
|
interface Contract<TStorage extends StorageBase = StorageBase, TModels extends Record<string, ContractModelBase> = Record<string, ContractModelBase>> {
|
|
253
243
|
readonly target: string;
|
|
254
244
|
readonly targetFamily: string;
|
|
255
|
-
readonly roots: Record<string,
|
|
256
|
-
readonly models: TModels;
|
|
257
|
-
readonly valueObjects?: Record<string, ContractValueObject>;
|
|
245
|
+
readonly roots: Record<string, CrossReference>;
|
|
258
246
|
/**
|
|
259
|
-
*
|
|
260
|
-
*
|
|
261
|
-
* omitted from the on-disk envelope so emitted contracts stay byte-stable.
|
|
247
|
+
* Application plane (ADR 221): `domain.namespaces.<nsId>.{ models, valueObjects }`.
|
|
248
|
+
* `TModels` types the union of model entries across namespaces for family DSL inference.
|
|
262
249
|
*/
|
|
263
|
-
readonly domain
|
|
250
|
+
readonly domain: ApplicationDomain<TModels>;
|
|
264
251
|
readonly storage: TStorage;
|
|
265
252
|
readonly capabilities: Record<string, Record<string, boolean>>;
|
|
266
253
|
readonly extensionPacks: Record<string, unknown>;
|
|
267
254
|
readonly execution?: ContractExecutionSection;
|
|
268
255
|
readonly profileHash: ProfileHashBase<string>;
|
|
269
256
|
readonly meta: Record<string, unknown>;
|
|
257
|
+
readonly defaultControl?: ControlPolicy;
|
|
270
258
|
}
|
|
259
|
+
type ContractModelsMap<TContract extends Contract> = TContract extends Contract<StorageBase, infer TModels> ? TModels : never;
|
|
260
|
+
type ExactlyOneKey<T extends Record<string, unknown>> = keyof T extends infer Only extends keyof T ? [keyof T] extends [Only] ? Only : never : never;
|
|
261
|
+
type NamespaceValueObjectsOf<TNamespace> = TNamespace extends {
|
|
262
|
+
readonly valueObjects?: infer VO;
|
|
263
|
+
} ? VO extends Record<string, ContractValueObject> ? VO : Record<never, never> : Record<never, never>;
|
|
264
|
+
/** Value-object map for the contract's sole domain namespace (type-level single-namespace projection). */
|
|
265
|
+
type ContractValueObjectsMap<TContract extends Contract> = NamespaceValueObjectsOf<TContract['domain']['namespaces'][ExactlyOneKey<TContract['domain']['namespaces']>]> extends infer Projected ? Projected extends Record<string, ContractValueObject> ? Projected : Record<never, never> : Record<never, never>;
|
|
271
266
|
//#endregion
|
|
272
|
-
export {
|
|
273
|
-
//# sourceMappingURL=contract-types-
|
|
267
|
+
export { StorageNamespace as A, LedgerEntryRecord as C, StorageBase as D, Source as E, isExecutionMutationDefaultValue as F, profileHash as I, ControlPolicy as L, executionHash as M, isColumnDefault as N, StorageEntitySlot as O, isColumnDefaultLiteralInputValue as P, effectiveControl as R, JsonValue as S, ProfileHashBase as T, ExecutionSection as _, $ as a, GeneratedValueSpec as b, ColumnDefaultLiteralInputValue as c, DocCollection as d, DocIndex as f, ExecutionMutationDefaultValue as g, ExecutionMutationDefaultPhases as h, ContractValueObjectsMap as i, coreHash as j, StorageHashBase as k, ColumnDefaultLiteralValue as l, ExecutionMutationDefault as m, ContractExecutionSection as n, Brand as o, ExecutionHashBase as p, ContractModelsMap as r, ColumnDefault as s, Contract as t, ContractMarkerRecord as u, Expr as v, PlanMeta as w, JsonPrimitive as x, FieldType as y };
|
|
268
|
+
//# sourceMappingURL=contract-types-jgIOdqua.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract-types-jgIOdqua.d.mts","names":[],"sources":["../src/control-policy.ts","../src/types.ts","../src/contract-types.ts"],"mappings":";;;;;;AASA;;;;AAAyB;AAUzB;KAVY,aAAA;;;;;;;;;iBAUI,gBAAA,CACd,WAAA,EAAa,aAAA,cACb,cAAA,EAAgB,aAAA,eACf,aAAA;;;;;;cCnBU,CAAA;;;;ADMY;AAUzB;;KCRY,KAAA;EAAA,CACT,CAAA,WACO,IAAA,GAAO,MAAA;AAAA;;;;;;KASL,eAAA,yBAAwC,KAAA,GAAQ,KAAK;;ADAjD;;;;KCOJ,iBAAA,yBAA0C,KAAA,GAAQ,KAAK;AAAA,iBAEnD,aAAA,wBAAA,CA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;;KAGQ,uBAAA,mBAA0C,QAAA,IACpD,uBAAA,CACE,SAAA,yBAAkC,aAAA,CAAc,SAAA,sDAE9C,SAAA,SAAkB,MAAA,SAAe,mBAAA,IAC/B,SAAA,GACA,MAAA,iBACF,MAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//#region src/contract-validation-error.ts
|
|
2
|
+
var ContractValidationError = class extends Error {
|
|
3
|
+
code = "CONTRACT.VALIDATION_FAILED";
|
|
4
|
+
phase;
|
|
5
|
+
constructor(message, phase) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = "ContractValidationError";
|
|
8
|
+
this.phase = phase;
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
var DomainNamespaceResolutionError = class extends Error {
|
|
12
|
+
constructor(message) {
|
|
13
|
+
super(message);
|
|
14
|
+
this.name = "DomainNamespaceResolutionError";
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
//#endregion
|
|
18
|
+
export { DomainNamespaceResolutionError as n, ContractValidationError as t };
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=contract-validation-error-ClZaKqMW.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract-validation-error-ClZaKqMW.mjs","names":[],"sources":["../src/contract-validation-error.ts"],"sourcesContent":["export type ContractValidationPhase = 'structural' | 'domain' | 'storage';\n\nexport class ContractValidationError extends Error {\n readonly code = 'CONTRACT.VALIDATION_FAILED';\n readonly phase: ContractValidationPhase;\n\n constructor(message: string, phase: ContractValidationPhase) {\n super(message);\n this.name = 'ContractValidationError';\n this.phase = phase;\n }\n}\n\nexport class DomainNamespaceResolutionError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'DomainNamespaceResolutionError';\n }\n}\n"],"mappings":";AAEA,IAAa,0BAAb,cAA6C,MAAM;CACjD,OAAgB;CAChB;CAEA,YAAY,SAAiB,OAAgC;EAC3D,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,QAAQ;CACf;AACF;AAEA,IAAa,iCAAb,cAAoD,MAAM;CACxD,YAAY,SAAiB;EAC3B,MAAM,OAAO;EACb,KAAK,OAAO;CACd;AACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/contract-validation-error.d.ts
|
|
2
|
+
type ContractValidationPhase = 'structural' | 'domain' | 'storage';
|
|
3
|
+
declare class ContractValidationError extends Error {
|
|
4
|
+
readonly code = "CONTRACT.VALIDATION_FAILED";
|
|
5
|
+
readonly phase: ContractValidationPhase;
|
|
6
|
+
constructor(message: string, phase: ContractValidationPhase);
|
|
7
|
+
}
|
|
8
|
+
declare class DomainNamespaceResolutionError extends Error {
|
|
9
|
+
constructor(message: string);
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { ContractValidationPhase as n, DomainNamespaceResolutionError as r, ContractValidationError as t };
|
|
13
|
+
//# sourceMappingURL=contract-validation-error-T5LH4DW-.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract-validation-error-T5LH4DW-.d.mts","names":[],"sources":["../src/contract-validation-error.ts"],"mappings":";KAAY,uBAAA;AAAA,cAEC,uBAAA,SAAgC,KAAA;EAAA,SAClC,IAAA;EAAA,SACA,KAAA,EAAO,uBAAA;cAEJ,OAAA,UAAiB,KAAA,EAAO,uBAAA;AAAA;AAAA,cAOzB,8BAAA,SAAuC,KAAK;cAC3C,OAAA;AAAA"}
|
|
@@ -1,10 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
declare class ContractValidationError extends Error {
|
|
4
|
-
readonly code = "CONTRACT.VALIDATION_FAILED";
|
|
5
|
-
readonly phase: ContractValidationPhase;
|
|
6
|
-
constructor(message: string, phase: ContractValidationPhase);
|
|
7
|
-
}
|
|
8
|
-
//#endregion
|
|
9
|
-
export { ContractValidationError, type ContractValidationPhase };
|
|
10
|
-
//# sourceMappingURL=contract-validation-error.d.mts.map
|
|
1
|
+
import { n as ContractValidationPhase, r as DomainNamespaceResolutionError, t as ContractValidationError } from "./contract-validation-error-T5LH4DW-.mjs";
|
|
2
|
+
export { ContractValidationError, type ContractValidationPhase, DomainNamespaceResolutionError };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as ContractValidationError } from "./contract-validation-error-
|
|
2
|
-
export { ContractValidationError };
|
|
1
|
+
import { n as DomainNamespaceResolutionError, t as ContractValidationError } from "./contract-validation-error-ClZaKqMW.mjs";
|
|
2
|
+
export { ContractValidationError, DomainNamespaceResolutionError };
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import * as _$arktype_internal_variants_object_ts0 from "arktype/internal/variants/object.ts";
|
|
2
|
+
|
|
3
|
+
//#region src/namespace-id.d.ts
|
|
4
|
+
type NamespaceId = string & {
|
|
5
|
+
readonly __brand: 'NamespaceId';
|
|
6
|
+
};
|
|
7
|
+
declare function asNamespaceId(value: string): NamespaceId;
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region src/cross-reference.d.ts
|
|
10
|
+
interface CrossReference {
|
|
11
|
+
readonly namespace: NamespaceId;
|
|
12
|
+
readonly model: string;
|
|
13
|
+
}
|
|
14
|
+
declare const CrossReferenceSchema: _$arktype_internal_variants_object_ts0.ObjectType<CrossReference, {}>;
|
|
15
|
+
declare function crossRef(model: string, namespace?: string): CrossReference;
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region src/domain-types.d.ts
|
|
18
|
+
type ScalarFieldType = {
|
|
19
|
+
readonly kind: 'scalar';
|
|
20
|
+
readonly codecId: string;
|
|
21
|
+
readonly typeParams?: Record<string, unknown>;
|
|
22
|
+
};
|
|
23
|
+
type ValueObjectFieldType = {
|
|
24
|
+
readonly kind: 'valueObject';
|
|
25
|
+
readonly name: string;
|
|
26
|
+
};
|
|
27
|
+
type UnionFieldType = {
|
|
28
|
+
readonly kind: 'union';
|
|
29
|
+
readonly members: ReadonlyArray<ScalarFieldType | ValueObjectFieldType>;
|
|
30
|
+
};
|
|
31
|
+
type ContractFieldType = ScalarFieldType | ValueObjectFieldType | UnionFieldType;
|
|
32
|
+
type ContractField = {
|
|
33
|
+
readonly nullable: boolean;
|
|
34
|
+
readonly type: ContractFieldType;
|
|
35
|
+
readonly many?: true;
|
|
36
|
+
readonly dict?: true;
|
|
37
|
+
};
|
|
38
|
+
type ContractRelationOn = {
|
|
39
|
+
readonly localFields: readonly string[];
|
|
40
|
+
readonly targetFields: readonly string[];
|
|
41
|
+
};
|
|
42
|
+
type ContractReferenceRelation = {
|
|
43
|
+
readonly to: CrossReference;
|
|
44
|
+
readonly cardinality: '1:1' | '1:N' | 'N:1';
|
|
45
|
+
readonly on: ContractRelationOn;
|
|
46
|
+
};
|
|
47
|
+
type ContractEmbedRelation = {
|
|
48
|
+
readonly to: CrossReference;
|
|
49
|
+
readonly cardinality: '1:1' | '1:N';
|
|
50
|
+
};
|
|
51
|
+
type ContractRelation = ContractReferenceRelation | ContractEmbedRelation;
|
|
52
|
+
type ContractDiscriminator = {
|
|
53
|
+
readonly field: string;
|
|
54
|
+
};
|
|
55
|
+
type ContractVariantEntry = {
|
|
56
|
+
readonly value: string;
|
|
57
|
+
};
|
|
58
|
+
type ContractValueObject = {
|
|
59
|
+
readonly fields: Record<string, ContractField>;
|
|
60
|
+
};
|
|
61
|
+
type ModelStorageBase = Readonly<Record<string, unknown>>;
|
|
62
|
+
interface ContractModelBase<TModelStorage extends ModelStorageBase = ModelStorageBase> {
|
|
63
|
+
readonly fields: Record<string, ContractField>;
|
|
64
|
+
readonly relations: Record<string, ContractRelation>;
|
|
65
|
+
readonly storage: TModelStorage;
|
|
66
|
+
readonly discriminator?: ContractDiscriminator;
|
|
67
|
+
readonly variants?: Record<string, ContractVariantEntry>;
|
|
68
|
+
readonly base?: CrossReference;
|
|
69
|
+
readonly owner?: string;
|
|
70
|
+
}
|
|
71
|
+
interface ContractModel<TModelStorage extends ModelStorageBase = ModelStorageBase> extends ContractModelBase<TModelStorage> {
|
|
72
|
+
readonly fields: Record<string, ContractField>;
|
|
73
|
+
}
|
|
74
|
+
type ReferenceRelationKeys<TModels extends Record<string, {
|
|
75
|
+
readonly relations: Record<string, ContractRelation>;
|
|
76
|
+
}>, ModelName extends string & keyof TModels> = { [K in keyof TModels[ModelName]['relations']]: TModels[ModelName]['relations'][K] extends ContractReferenceRelation ? K : never }[keyof TModels[ModelName]['relations']];
|
|
77
|
+
type EmbedRelationKeys<TModels extends Record<string, {
|
|
78
|
+
readonly relations: Record<string, ContractRelation>;
|
|
79
|
+
}>, ModelName extends string & keyof TModels> = { [K in keyof TModels[ModelName]['relations']]: TModels[ModelName]['relations'][K] extends ContractReferenceRelation ? never : K }[keyof TModels[ModelName]['relations']];
|
|
80
|
+
//#endregion
|
|
81
|
+
//#region src/domain-envelope.d.ts
|
|
82
|
+
declare const UNBOUND_DOMAIN_NAMESPACE_ID: "__unbound__";
|
|
83
|
+
/**
|
|
84
|
+
* One namespace's application-domain entities — models and optional value
|
|
85
|
+
* objects keyed by entity name within that namespace coordinate.
|
|
86
|
+
*/
|
|
87
|
+
interface ApplicationDomainNamespace<TModels extends Record<string, ContractModelBase> = Record<string, ContractModelBase>> {
|
|
88
|
+
readonly models: TModels;
|
|
89
|
+
readonly valueObjects?: Record<string, ContractValueObject>;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Application-domain envelope: entity content keyed by namespace id.
|
|
93
|
+
* Mirrors the storage plane's `namespaces` segment (ADR 221).
|
|
94
|
+
*/
|
|
95
|
+
interface ApplicationDomain<TModels extends Record<string, ContractModelBase> = Record<string, ContractModelBase>> {
|
|
96
|
+
readonly namespaces: Readonly<Record<string, ApplicationDomainNamespace<TModels>>>;
|
|
97
|
+
}
|
|
98
|
+
type ContractWithDomain = {
|
|
99
|
+
readonly domain: ApplicationDomain;
|
|
100
|
+
};
|
|
101
|
+
declare function resolveSingleDomainNamespaceId(domain: ApplicationDomain, namespaceId?: string): string;
|
|
102
|
+
declare function contractModels<TModels extends Record<string, ContractModelBase>>(contract: {
|
|
103
|
+
readonly domain: ApplicationDomain<TModels>;
|
|
104
|
+
}, namespaceId?: string): TModels;
|
|
105
|
+
declare function contractValueObjects<TModels extends Record<string, ContractModelBase>>(contract: {
|
|
106
|
+
readonly domain: ApplicationDomain<TModels>;
|
|
107
|
+
}, namespaceId?: string): Record<string, ContractValueObject> | undefined;
|
|
108
|
+
//#endregion
|
|
109
|
+
export { UnionFieldType as C, crossRef as D, CrossReferenceSchema as E, NamespaceId as O, ScalarFieldType as S, CrossReference as T, ContractValueObject as _, contractModels as a, ModelStorageBase as b, ContractDiscriminator as c, ContractFieldType as d, ContractModel as f, ContractRelationOn as g, ContractRelation as h, UNBOUND_DOMAIN_NAMESPACE_ID as i, asNamespaceId as k, ContractEmbedRelation as l, ContractReferenceRelation as m, ApplicationDomainNamespace as n, contractValueObjects as o, ContractModelBase as p, ContractWithDomain as r, resolveSingleDomainNamespaceId as s, ApplicationDomain as t, ContractField as u, ContractVariantEntry as v, ValueObjectFieldType as w, ReferenceRelationKeys as x, EmbedRelationKeys as y };
|
|
110
|
+
//# sourceMappingURL=domain-envelope-Cv5OTm8D.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"domain-envelope-Cv5OTm8D.d.mts","names":[],"sources":["../src/namespace-id.ts","../src/cross-reference.ts","../src/domain-types.ts","../src/domain-envelope.ts"],"mappings":";;;KAEY,WAAA;EAAA,SAAkC,OAAO;AAAA;AAAA,iBAErC,aAAA,CAAc,KAAA,WAAgB,WAAW;;;UCAxC,cAAA;EAAA,SACN,SAAA,EAAW,WAAW;EAAA,SACtB,KAAA;AAAA;AAAA,cAGE,oBAAA,EAAoB,sCAAA,CAAA,UAAA,CAAA,cAAA;AAAA,iBAajB,QAAA,CACd,KAAA,UACA,SAAA,YACC,cAAc;;;KCvBL,eAAA;EAAA,SACD,IAAA;EAAA,SACA,OAAA;EAAA,SACA,UAAA,GAAa,MAAM;AAAA;AAAA,KAGlB,oBAAA;EAAA,SACD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Di-tQ20o.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/canonicalization-path-match.d.ts
|
|
4
|
+
type PathSegment = string | '*' | readonly string[];
|
|
5
|
+
type PathPattern = readonly PathSegment[];
|
|
6
|
+
declare function matchesPathPattern(path: readonly string[], pattern: PathPattern): boolean;
|
|
7
|
+
declare function createPreserveEmptyPredicate(patterns: readonly PathPattern[]): PreserveEmptyPredicate;
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region src/canonicalization-storage-sort.d.ts
|
|
10
|
+
type PathSegment$1 = string | '*';
|
|
11
|
+
interface NamedArraySortTarget {
|
|
12
|
+
readonly path: readonly PathSegment$1[];
|
|
13
|
+
readonly arrayKeys: readonly string[];
|
|
14
|
+
}
|
|
15
|
+
declare function compareByNameProperty(a: unknown, b: unknown): number;
|
|
16
|
+
declare function createStorageSort(targets: readonly NamedArraySortTarget[], compare?: (a: unknown, b: unknown) => number): StorageSort;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { type NamedArraySortTarget, type PathPattern, type PathSegment as PreserveEmptyPathSegment, type PathSegment$1 as StorageSortPathSegment, compareByNameProperty, createPreserveEmptyPredicate, createStorageSort, matchesPathPattern };
|
|
19
|
+
//# sourceMappingURL=hashing-utils.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hashing-utils.d.mts","names":[],"sources":["../src/canonicalization-path-match.ts","../src/canonicalization-storage-sort.ts"],"mappings":";;;KAEY,WAAA;AAAA,KAEA,WAAA,YAAuB,WAAW;AAAA,iBAE9B,kBAAA,CAAmB,IAAA,qBAAyB,OAAA,EAAS,WAAW;AAAA,iBAiChE,4BAAA,CACd,QAAA,WAAmB,WAAA,KAClB,sBAAsB;;;KCvCb,aAAA;AAAA,UAEK,oBAAA;EAAA,SACN,IAAA,WAAe,aAAW;EAAA,SAC1B,SAAA;AAAA;AAAA,iBAOK,qBAAA,CAAsB,CAAA,WAAY,CAAU;AAAA,iBA2D5C,iBAAA,CACd,OAAA,WAAkB,oBAAA,IAClB,OAAA,IAAU,CAAA,WAAY,CAAA,uBACrB,WAAW"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { n as matchesPathPattern, t as createPreserveEmptyPredicate } from "./canonicalization-path-match-b2jFuEso.mjs";
|
|
2
|
+
//#region src/canonicalization-storage-sort.ts
|
|
3
|
+
function isPlainRecord(value) {
|
|
4
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5
|
+
}
|
|
6
|
+
function compareByNameProperty(a, b) {
|
|
7
|
+
const nameA = isPlainRecord(a) && typeof a["name"] === "string" ? a["name"] : "";
|
|
8
|
+
const nameB = isPlainRecord(b) && typeof b["name"] === "string" ? b["name"] : "";
|
|
9
|
+
return nameA.localeCompare(nameB);
|
|
10
|
+
}
|
|
11
|
+
function sortArrayKeysOnRecord(record, arrayKeys, compare) {
|
|
12
|
+
const sorted = { ...record };
|
|
13
|
+
for (const key of arrayKeys) {
|
|
14
|
+
const value = record[key];
|
|
15
|
+
if (Array.isArray(value)) sorted[key] = [...value].sort(compare);
|
|
16
|
+
}
|
|
17
|
+
return sorted;
|
|
18
|
+
}
|
|
19
|
+
function walkAndSort(node, pathSegments, arrayKeys, compare) {
|
|
20
|
+
if (pathSegments.length === 0) {
|
|
21
|
+
if (!isPlainRecord(node)) return node;
|
|
22
|
+
return sortArrayKeysOnRecord(node, arrayKeys, compare);
|
|
23
|
+
}
|
|
24
|
+
if (!isPlainRecord(node)) return node;
|
|
25
|
+
const [head, ...rest] = pathSegments;
|
|
26
|
+
if (head === void 0) return node;
|
|
27
|
+
if (head === "*") {
|
|
28
|
+
const sorted = { ...node };
|
|
29
|
+
for (const key of Object.keys(node)) sorted[key] = walkAndSort(node[key], rest, arrayKeys, compare);
|
|
30
|
+
return sorted;
|
|
31
|
+
}
|
|
32
|
+
const child = node[head];
|
|
33
|
+
if (child === void 0) return node;
|
|
34
|
+
return {
|
|
35
|
+
...node,
|
|
36
|
+
[head]: walkAndSort(child, rest, arrayKeys, compare)
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function createStorageSort(targets, compare = compareByNameProperty) {
|
|
40
|
+
return (storage) => {
|
|
41
|
+
if (!isPlainRecord(storage)) return storage;
|
|
42
|
+
let result = storage;
|
|
43
|
+
for (const target of targets) result = walkAndSort(result, target.path, target.arrayKeys, compare);
|
|
44
|
+
return result;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
//#endregion
|
|
48
|
+
export { compareByNameProperty, createPreserveEmptyPredicate, createStorageSort, matchesPathPattern };
|
|
49
|
+
|
|
50
|
+
//# sourceMappingURL=hashing-utils.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hashing-utils.mjs","names":[],"sources":["../src/canonicalization-storage-sort.ts"],"sourcesContent":["import type { StorageSort } from './canonicalization';\n\nexport type PathSegment = string | '*';\n\nexport interface NamedArraySortTarget {\n readonly path: readonly PathSegment[];\n readonly arrayKeys: readonly string[];\n}\n\nfunction isPlainRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nexport function compareByNameProperty(a: unknown, b: unknown): number {\n const nameA = isPlainRecord(a) && typeof a['name'] === 'string' ? a['name'] : '';\n const nameB = isPlainRecord(b) && typeof b['name'] === 'string' ? b['name'] : '';\n return nameA.localeCompare(nameB);\n}\n\nfunction sortArrayKeysOnRecord(\n record: Record<string, unknown>,\n arrayKeys: readonly string[],\n compare: (a: unknown, b: unknown) => number,\n): Record<string, unknown> {\n const sorted: Record<string, unknown> = { ...record };\n for (const key of arrayKeys) {\n const value = record[key];\n if (Array.isArray(value)) {\n sorted[key] = [...value].sort(compare);\n }\n }\n return sorted;\n}\n\nfunction walkAndSort(\n node: unknown,\n pathSegments: readonly PathSegment[],\n arrayKeys: readonly string[],\n compare: (a: unknown, b: unknown) => number,\n): unknown {\n if (pathSegments.length === 0) {\n if (!isPlainRecord(node)) {\n return node;\n }\n return sortArrayKeysOnRecord(node, arrayKeys, compare);\n }\n\n if (!isPlainRecord(node)) {\n return node;\n }\n\n const [head, ...rest] = pathSegments;\n if (head === undefined) {\n return node;\n }\n\n if (head === '*') {\n const sorted: Record<string, unknown> = { ...node };\n for (const key of Object.keys(node)) {\n sorted[key] = walkAndSort(node[key], rest, arrayKeys, compare);\n }\n return sorted;\n }\n\n const child = node[head];\n if (child === undefined) {\n return node;\n }\n\n return { ...node, [head]: walkAndSort(child, rest, arrayKeys, compare) };\n}\n\nexport function createStorageSort(\n targets: readonly NamedArraySortTarget[],\n compare: (a: unknown, b: unknown) => number = compareByNameProperty,\n): StorageSort {\n return (storage) => {\n if (!isPlainRecord(storage)) {\n return storage;\n }\n\n let result: unknown = storage;\n for (const target of targets) {\n result = walkAndSort(result, target.path, target.arrayKeys, compare);\n }\n return result;\n };\n}\n"],"mappings":";;AASA,SAAS,cAAc,OAAkD;CACvE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;AAEA,SAAgB,sBAAsB,GAAY,GAAoB;CACpE,MAAM,QAAQ,cAAc,CAAC,KAAK,OAAO,EAAE,YAAY,WAAW,EAAE,UAAU;CAC9E,MAAM,QAAQ,cAAc,CAAC,KAAK,OAAO,EAAE,YAAY,WAAW,EAAE,UAAU;CAC9E,OAAO,MAAM,cAAc,KAAK;AAClC;AAEA,SAAS,sBACP,QACA,WACA,SACyB;CACzB,MAAM,SAAkC,EAAE,GAAG,OAAO;CACpD,KAAK,MAAM,OAAO,WAAW;EAC3B,MAAM,QAAQ,OAAO;EACrB,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO,OAAO,CAAC,GAAG,KAAK,EAAE,KAAK,OAAO;CAEzC;CACA,OAAO;AACT;AAEA,SAAS,YACP,MACA,cACA,WACA,SACS;CACT,IAAI,aAAa,WAAW,GAAG;EAC7B,IAAI,CAAC,cAAc,IAAI,GACrB,OAAO;EAET,OAAO,sBAAsB,MAAM,WAAW,OAAO;CACvD;CAEA,IAAI,CAAC,cAAc,IAAI,GACrB,OAAO;CAGT,MAAM,CAAC,MAAM,GAAG,QAAQ;CACxB,IAAI,SAAS,KAAA,GACX,OAAO;CAGT,IAAI,SAAS,KAAK;EAChB,MAAM,SAAkC,EAAE,GAAG,KAAK;EAClD,KAAK,MAAM,OAAO,OAAO,KAAK,IAAI,GAChC,OAAO,OAAO,YAAY,KAAK,MAAM,MAAM,WAAW,OAAO;EAE/D,OAAO;CACT;CAEA,MAAM,QAAQ,KAAK;CACnB,IAAI,UAAU,KAAA,GACZ,OAAO;CAGT,OAAO;EAAE,GAAG;GAAO,OAAO,YAAY,OAAO,MAAM,WAAW,OAAO;CAAE;AACzE;AAEA,SAAgB,kBACd,SACA,UAA8C,uBACjC;CACb,QAAQ,YAAY;EAClB,IAAI,CAAC,cAAc,OAAO,GACxB,OAAO;EAGT,IAAI,SAAkB;EACtB,KAAK,MAAM,UAAU,SACnB,SAAS,YAAY,QAAQ,OAAO,MAAM,OAAO,WAAW,OAAO;EAErE,OAAO;CACT;AACF"}
|
package/dist/hashing.d.mts
CHANGED
|
@@ -1,44 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { T as ProfileHashBase, k as StorageHashBase, p as ExecutionHashBase } from "./contract-types-jgIOdqua.mjs";
|
|
2
|
+
import { a as canonicalizeContract, i as StorageSort, n as PreserveEmptyPredicate, o as canonicalizeContractToObject, r as SerializeContract, t as CanonicalizeContractOptions } from "./canonicalization-Di-tQ20o.mjs";
|
|
3
3
|
|
|
4
|
-
//#region src/canonicalization.d.ts
|
|
5
|
-
/**
|
|
6
|
-
* Per-target contract serializer hook. The framework canonicalizer uses
|
|
7
|
-
* this to convert an in-memory contract (which may carry class-instance
|
|
8
|
-
* IR nodes whose runtime-only fields must not appear in the on-disk
|
|
9
|
-
* envelope) into a plain JsonObject before applying the family-agnostic
|
|
10
|
-
* canonical-key ordering / default-omission / sort steps. Targets whose
|
|
11
|
-
* contract is JSON-clean by construction return the contract unchanged.
|
|
12
|
-
*/
|
|
13
|
-
type SerializeContract = (contract: Contract) => JsonObject;
|
|
14
|
-
interface CanonicalizeContractOptions {
|
|
15
|
-
readonly schemaVersion?: string;
|
|
16
|
-
/**
|
|
17
|
-
* Per-target hook that converts the in-memory contract (which may
|
|
18
|
-
* carry class-instance IR nodes) into a plain JsonObject before the
|
|
19
|
-
* family-agnostic canonicalization steps run.
|
|
20
|
-
*
|
|
21
|
-
* Routing through the hook is what lets each target decide which
|
|
22
|
-
* fields appear in the on-disk envelope; runtime-only class API
|
|
23
|
-
* fields stay invisible to the canonicalization walk by virtue of
|
|
24
|
-
* the per-target serializer not putting them in the JSON shape.
|
|
25
|
-
*/
|
|
26
|
-
readonly serializeContract: SerializeContract;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Object-form variant of {@link canonicalizeContract}. Exported because the
|
|
30
|
-
* emitter writes the canonical contract through a separate JSON-stringify
|
|
31
|
-
* pass and consumes the structured object directly.
|
|
32
|
-
*/
|
|
33
|
-
declare function canonicalizeContractToObject(contract: Contract, options: CanonicalizeContractOptions): Record<string, unknown>;
|
|
34
|
-
declare function canonicalizeContract(contract: Contract, options: CanonicalizeContractOptions): string;
|
|
35
|
-
//#endregion
|
|
36
4
|
//#region src/hashing.d.ts
|
|
37
|
-
|
|
5
|
+
type ComputeStorageHashArgs = {
|
|
38
6
|
target: string;
|
|
39
7
|
targetFamily: string;
|
|
40
8
|
storage: Record<string, unknown>;
|
|
41
|
-
|
|
9
|
+
readonly shouldPreserveEmpty?: PreserveEmptyPredicate;
|
|
10
|
+
readonly sortStorage?: StorageSort;
|
|
11
|
+
};
|
|
12
|
+
declare function computeStorageHash(args: ComputeStorageHashArgs): StorageHashBase<string>;
|
|
42
13
|
declare function computeExecutionHash(args: {
|
|
43
14
|
target: string;
|
|
44
15
|
targetFamily: string;
|
|
@@ -50,5 +21,5 @@ declare function computeProfileHash(args: {
|
|
|
50
21
|
capabilities: Record<string, Record<string, boolean>>;
|
|
51
22
|
}): ProfileHashBase<string>;
|
|
52
23
|
//#endregion
|
|
53
|
-
export { type CanonicalizeContractOptions, type SerializeContract, canonicalizeContract, canonicalizeContractToObject, computeExecutionHash, computeProfileHash, computeStorageHash };
|
|
24
|
+
export { type CanonicalizeContractOptions, type PreserveEmptyPredicate, type SerializeContract, type StorageSort, canonicalizeContract, canonicalizeContractToObject, computeExecutionHash, computeProfileHash, computeStorageHash };
|
|
54
25
|
//# sourceMappingURL=hashing.d.mts.map
|
package/dist/hashing.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hashing.d.mts","names":[],"sources":["../src/
|
|
1
|
+
{"version":3,"file":"hashing.d.mts","names":[],"sources":["../src/hashing.ts"],"mappings":";;;;KAqDY,sBAAA;EACV,MAAA;EACA,YAAA;EACA,OAAA,EAAS,MAAA;EAAA,SACA,mBAAA,GAAsB,sBAAA;EAAA,SACtB,WAAA,GAAc,WAAA;AAAA;AAAA,iBAGT,kBAAA,CAAmB,IAAA,EAAM,sBAAA,GAAyB,eAAe;AAAA,iBAIjE,oBAAA,CAAqB,IAAA;EACnC,MAAA;EACA,YAAA;EACA,SAAA,EAAW,MAAA;AAAA,IACT,iBAAiB;AAAA,iBAIL,kBAAA,CAAmB,IAAA;EACjC,MAAA;EACA,YAAA;EACA,YAAA,EAAc,MAAA,SAAe,MAAA;AAAA,IAC3B,eAAA"}
|