@prisma/orm-family-mongo 0.16.0-dev.36
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/LICENSE +201 -0
- package/README.md +27 -0
- package/dist/authoring-entity-types-BGtkMyoN-D32kzx28.mjs +176 -0
- package/dist/authoring-entity-types-BGtkMyoN-D32kzx28.mjs.map +1 -0
- package/dist/canonicalization-hooks-DF3Z6sjO.mjs +22 -0
- package/dist/canonicalization-hooks-DF3Z6sjO.mjs.map +1 -0
- package/dist/codec.d.mts +2 -0
- package/dist/codec.mjs +2 -0
- package/dist/config-types-CFDf9ivE.mjs +37 -0
- package/dist/config-types-CFDf9ivE.mjs.map +1 -0
- package/dist/config-types-CQOf5N7R.d.mts +12 -0
- package/dist/config-types-CQOf5N7R.d.mts.map +1 -0
- package/dist/contract-builder-BFq0gOMV.mjs +634 -0
- package/dist/contract-builder-BFq0gOMV.mjs.map +1 -0
- package/dist/contract-builder-DB8nguDE.d.mts +445 -0
- package/dist/contract-builder-DB8nguDE.d.mts.map +1 -0
- package/dist/contract-errors-BCN6RVI5-kMurtAbI.mjs +9 -0
- package/dist/contract-errors-BCN6RVI5-kMurtAbI.mjs.map +1 -0
- package/dist/contract-psl.d.mts +45 -0
- package/dist/contract-psl.d.mts.map +1 -0
- package/dist/contract-psl.mjs +2 -0
- package/dist/contract-psl__provider.d.mts +15 -0
- package/dist/contract-psl__provider.d.mts.map +1 -0
- package/dist/contract-psl__provider.mjs +82 -0
- package/dist/contract-psl__provider.mjs.map +1 -0
- package/dist/contract-ts.d.mts +3 -0
- package/dist/contract-ts.mjs +3 -0
- package/dist/contract-ts__config-types.d.mts +2 -0
- package/dist/contract-ts__config-types.mjs +2 -0
- package/dist/contract-ts__contract-builder.d.mts +2 -0
- package/dist/contract-ts__contract-builder.mjs +2 -0
- package/dist/contract.d.mts +3 -0
- package/dist/contract.mjs +3 -0
- package/dist/contract__canonicalization-hooks.d.mts +9 -0
- package/dist/contract__canonicalization-hooks.d.mts.map +1 -0
- package/dist/contract__canonicalization-hooks.mjs +2 -0
- package/dist/contract__entity-kinds.d.mts +17 -0
- package/dist/contract__entity-kinds.d.mts.map +1 -0
- package/dist/contract__entity-kinds.mjs +2 -0
- package/dist/control-C7-kthr1.d.mts +193 -0
- package/dist/control-C7-kthr1.d.mts.map +1 -0
- package/dist/control-CClR5JMr.mjs +127 -0
- package/dist/control-CClR5JMr.mjs.map +1 -0
- package/dist/control-CFr3tYsg.mjs +398 -0
- package/dist/control-CFr3tYsg.mjs.map +1 -0
- package/dist/control-Cj81sPbj.d.mts +101 -0
- package/dist/control-Cj81sPbj.d.mts.map +1 -0
- package/dist/control-adapter-Db5pT77b.d.mts +83 -0
- package/dist/control-adapter-Db5pT77b.d.mts.map +1 -0
- package/dist/dist-C7Ykq48Q.mjs +19 -0
- package/dist/dist-C7Ykq48Q.mjs.map +1 -0
- package/dist/dist-Czwqx_i3.mjs +58 -0
- package/dist/dist-Czwqx_i3.mjs.map +1 -0
- package/dist/dist-DHrEJnhK.mjs +236 -0
- package/dist/dist-DHrEJnhK.mjs.map +1 -0
- package/dist/dist-Dyp05u64.mjs +1546 -0
- package/dist/dist-Dyp05u64.mjs.map +1 -0
- package/dist/emitter.d.mts +22 -0
- package/dist/emitter.d.mts.map +1 -0
- package/dist/emitter.mjs +2 -0
- package/dist/entity-kinds-B4KNTF8z-DPIuUuuB.mjs +603 -0
- package/dist/entity-kinds-B4KNTF8z-DPIuUuuB.mjs.map +1 -0
- package/dist/execution-CKnUiOfm.d.mts +48 -0
- package/dist/execution-CKnUiOfm.d.mts.map +1 -0
- package/dist/execution-D5XyZ5XS.mjs +1269 -0
- package/dist/execution-D5XyZ5XS.mjs.map +1 -0
- package/dist/exports-Bx-hlnZ3.mjs +209 -0
- package/dist/exports-Bx-hlnZ3.mjs.map +1 -0
- package/dist/exports-CJMh0VTU.mjs +156 -0
- package/dist/exports-CJMh0VTU.mjs.map +1 -0
- package/dist/family.d.mts +10 -0
- package/dist/family.mjs +9 -0
- package/dist/family__control-adapter.d.mts +2 -0
- package/dist/family__control-adapter.mjs +1 -0
- package/dist/family__control.d.mts +2 -0
- package/dist/family__control.mjs +3 -0
- package/dist/family__ir.d.mts +3 -0
- package/dist/family__ir.mjs +4 -0
- package/dist/family__migration.d.mts +2 -0
- package/dist/family__migration.mjs +2 -0
- package/dist/family__pack.d.mts +2 -0
- package/dist/family__pack.mjs +16 -0
- package/dist/family__pack.mjs.map +1 -0
- package/dist/family__runtime.d.mts +3 -0
- package/dist/family__runtime.mjs +2 -0
- package/dist/family__schema-verify.d.mts +2 -0
- package/dist/family__schema-verify.mjs +2 -0
- package/dist/field-accessor-0oUt6RZC-B_Z30uAA.mjs +234 -0
- package/dist/field-accessor-0oUt6RZC-B_Z30uAA.mjs.map +1 -0
- package/dist/field-accessor-DHsAPiW3-BdYCspQC.d.mts +588 -0
- package/dist/field-accessor-DHsAPiW3-BdYCspQC.d.mts.map +1 -0
- package/dist/filter-expressions-Uo8ZdzwB-53qnqceS.mjs +181 -0
- package/dist/filter-expressions-Uo8ZdzwB-53qnqceS.mjs.map +1 -0
- package/dist/index-BR0ue13b.d.mts +136 -0
- package/dist/index-BR0ue13b.d.mts.map +1 -0
- package/dist/index-Cd2zLiU6.d.mts +128 -0
- package/dist/index-Cd2zLiU6.d.mts.map +1 -0
- package/dist/index-DAOkcTCK.d.mts +151 -0
- package/dist/index-DAOkcTCK.d.mts.map +1 -0
- package/dist/index-Dv2PNMiG.d.mts +53 -0
- package/dist/index-Dv2PNMiG.d.mts.map +1 -0
- package/dist/index-DxoO-ywI.d.mts +178 -0
- package/dist/index-DxoO-ywI.d.mts.map +1 -0
- package/dist/index-wKMm41HC.d.mts +30 -0
- package/dist/index-wKMm41HC.d.mts.map +1 -0
- package/dist/interpreter-BxbUTQ3k-ClR98Ned.mjs +1091 -0
- package/dist/interpreter-BxbUTQ3k-ClR98Ned.mjs.map +1 -0
- package/dist/ir-CQrenTYt.d.mts +147 -0
- package/dist/ir-CQrenTYt.d.mts.map +1 -0
- package/dist/ir-Ch2aPr7a.mjs +62 -0
- package/dist/ir-Ch2aPr7a.mjs.map +1 -0
- package/dist/lowering.d.mts +2 -0
- package/dist/lowering.mjs +1 -0
- package/dist/migration-CNDQv5yB.d.mts +50 -0
- package/dist/migration-CNDQv5yB.d.mts.map +1 -0
- package/dist/migration-dcM7u4HG.mjs +52 -0
- package/dist/migration-dcM7u4HG.mjs.map +1 -0
- package/dist/mongo-contract-serializer-Cx7Fae8e-C8ZYPXpc.mjs +119 -0
- package/dist/mongo-contract-serializer-Cx7Fae8e-C8ZYPXpc.mjs.map +1 -0
- package/dist/mongo-contract-view-AnejqfrQ-BaCFT0xm.d.mts +27 -0
- package/dist/mongo-contract-view-AnejqfrQ-BaCFT0xm.d.mts.map +1 -0
- package/dist/mongo-contract-view-rcWzby6f-wRBCUnBt.mjs +17 -0
- package/dist/mongo-contract-view-rcWzby6f-wRBCUnBt.mjs.map +1 -0
- package/dist/mongo-value-set-tNn9-pun-dJYx_rVD.d.mts +536 -0
- package/dist/mongo-value-set-tNn9-pun-dJYx_rVD.d.mts.map +1 -0
- package/dist/mongodb-types-B4HmhF1S.d.mts +2 -0
- package/dist/orm.d.mts +311 -0
- package/dist/orm.d.mts.map +1 -0
- package/dist/orm.mjs +664 -0
- package/dist/orm.mjs.map +1 -0
- package/dist/pack-D9aLY50F.d.mts +44 -0
- package/dist/pack-D9aLY50F.d.mts.map +1 -0
- package/dist/query-ast.d.mts +5 -0
- package/dist/query-ast.mjs +4 -0
- package/dist/query-ast__control.d.mts +4 -0
- package/dist/query-ast__control.mjs +3 -0
- package/dist/query-ast__execution.d.mts +3 -0
- package/dist/query-ast__execution.mjs +3 -0
- package/dist/query-builder.d.mts +836 -0
- package/dist/query-builder.d.mts.map +1 -0
- package/dist/query-builder.mjs +3 -0
- package/dist/query-builder__contract-free.d.mts +83 -0
- package/dist/query-builder__contract-free.d.mts.map +1 -0
- package/dist/query-builder__contract-free.mjs +107 -0
- package/dist/query-builder__contract-free.mjs.map +1 -0
- package/dist/query-plan-C0-Yu8hf-DdilEdW6.d.mts +822 -0
- package/dist/query-plan-C0-Yu8hf-DdilEdW6.d.mts.map +1 -0
- package/dist/runtime-DPkRW4iu.d.mts +1 -0
- package/dist/runtime.d.mts +286 -0
- package/dist/runtime.d.mts.map +1 -0
- package/dist/runtime.mjs +532 -0
- package/dist/runtime.mjs.map +1 -0
- package/dist/schema-ir.d.mts +2 -0
- package/dist/schema-ir.mjs +2 -0
- package/dist/schema-verify-DJGr28XW.d.mts +23 -0
- package/dist/schema-verify-DJGr28XW.d.mts.map +1 -0
- package/dist/value.d.mts +2 -0
- package/dist/value.mjs +2 -0
- package/dist/value__mongodb-types.d.mts +2 -0
- package/dist/value__mongodb-types.mjs +1 -0
- package/dist/verify-mongo-schema-De0FG2Rm-CCzwnNPY.mjs +447 -0
- package/dist/verify-mongo-schema-De0FG2Rm-CCzwnNPY.mjs.map +1 -0
- package/dist/wire.d.mts +3 -0
- package/dist/wire.mjs +190 -0
- package/dist/wire.mjs.map +1 -0
- package/package.json +89 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dist-C7Ykq48Q.mjs","names":[],"sources":["../../../../2-mongo-family/1-foundation/mongo-value/dist/index.mjs"],"sourcesContent":["//#region src/param-ref.ts\nvar MongoParamRef = class MongoParamRef {\n\tvalue;\n\tname;\n\tcodecId;\n\tconstructor(value, options) {\n\t\tthis.value = value;\n\t\tthis.name = options?.name;\n\t\tthis.codecId = options?.codecId;\n\t\tObject.freeze(this);\n\t}\n\tstatic of(value, options) {\n\t\treturn new MongoParamRef(value, options);\n\t}\n};\n//#endregion\nexport { MongoParamRef };\n\n//# sourceMappingURL=index.mjs.map"],"mappings":";AACA,IAAI,gBAAgB,MAAM,cAAc;CACvC;CACA;CACA;CACA,YAAY,OAAO,SAAS;EAC3B,KAAK,QAAQ;EACb,KAAK,OAAO,SAAS;EACrB,KAAK,UAAU,SAAS;EACxB,OAAO,OAAO,IAAI;CACnB;CACA,OAAO,GAAG,OAAO,SAAS;EACzB,OAAO,IAAI,cAAc,OAAO,OAAO;CACxC;AACD"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { structuredError } from "@prisma/orm-framework/utils/structured-error";
|
|
2
|
+
//#region ../../../2-mongo-family/1-foundation/mongo-codec/dist/index.mjs
|
|
3
|
+
/**
|
|
4
|
+
* Create a new Mongo codec registry. Inline object literal — no class implementation; the registry is just a private `Map` with the documented surface methods.
|
|
5
|
+
*/
|
|
6
|
+
function newMongoCodecRegistry() {
|
|
7
|
+
const byId = /* @__PURE__ */ new Map();
|
|
8
|
+
return {
|
|
9
|
+
get: (id) => byId.get(id),
|
|
10
|
+
has: (id) => byId.has(id),
|
|
11
|
+
register: (codec) => {
|
|
12
|
+
if (byId.has(codec.id)) throw structuredError("RUNTIME.DUPLICATE_CODEC", `Codec with ID '${codec.id}' is already registered`);
|
|
13
|
+
byId.set(codec.id, codec);
|
|
14
|
+
},
|
|
15
|
+
values: () => byId.values(),
|
|
16
|
+
[Symbol.iterator]: function* () {
|
|
17
|
+
yield* byId.values();
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Construct a Mongo codec from author functions.
|
|
23
|
+
*
|
|
24
|
+
* Author `encode` and `decode` as sync or async functions; the factory produces a {@link MongoCodec} whose query-time methods follow the boundary contract documented on the framework {@link BaseCodec}. Authors receive a second `ctx` options argument carrying the per-call context; ignore it if you don't need it.
|
|
25
|
+
*
|
|
26
|
+
* Both `encode` and `decode` are required so `TInput` and `TWire` are always covered by an explicit author function — the factory installs no identity fallback. `encodeJson` and `decodeJson` default to identity **only when `TInput` is assignable to `JsonValue`**; otherwise both are required so the contract artifact stays JSON-safe.
|
|
27
|
+
*
|
|
28
|
+
* Codec-id-keyed static metadata (`traits`, `targetTypes`, `renderOutputType`) lives on the unified `CodecDescriptor` rather than on the codec instance itself (TML-2357).
|
|
29
|
+
*/
|
|
30
|
+
function mongoCodec(config) {
|
|
31
|
+
const identity = (v) => v;
|
|
32
|
+
const userEncode = config.encode;
|
|
33
|
+
const userDecode = config.decode;
|
|
34
|
+
const widenedConfig = config;
|
|
35
|
+
return {
|
|
36
|
+
id: config.typeId,
|
|
37
|
+
encode: (value, ctx) => {
|
|
38
|
+
try {
|
|
39
|
+
return Promise.resolve(userEncode(value, ctx));
|
|
40
|
+
} catch (error) {
|
|
41
|
+
return Promise.reject(error);
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
decode: (wire, ctx) => {
|
|
45
|
+
try {
|
|
46
|
+
return Promise.resolve(userDecode(wire, ctx));
|
|
47
|
+
} catch (error) {
|
|
48
|
+
return Promise.reject(error);
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
encodeJson: widenedConfig.encodeJson ?? identity,
|
|
52
|
+
decodeJson: widenedConfig.decodeJson ?? identity
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
56
|
+
export { newMongoCodecRegistry as n, mongoCodec as t };
|
|
57
|
+
|
|
58
|
+
//# sourceMappingURL=dist-Czwqx_i3.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dist-Czwqx_i3.mjs","names":[],"sources":["../../../../2-mongo-family/1-foundation/mongo-codec/dist/index.mjs"],"sourcesContent":["import { structuredError } from \"@internal/utils/structured-error\";\n//#region src/codec-registry.ts\n/**\n* Create a new Mongo codec registry. Inline object literal — no class implementation; the registry is just a private `Map` with the documented surface methods.\n*/\nfunction newMongoCodecRegistry() {\n\tconst byId = /* @__PURE__ */ new Map();\n\treturn {\n\t\tget: (id) => byId.get(id),\n\t\thas: (id) => byId.has(id),\n\t\tregister: (codec) => {\n\t\t\tif (byId.has(codec.id)) throw structuredError(\"RUNTIME.DUPLICATE_CODEC\", `Codec with ID '${codec.id}' is already registered`);\n\t\t\tbyId.set(codec.id, codec);\n\t\t},\n\t\tvalues: () => byId.values(),\n\t\t[Symbol.iterator]: function* () {\n\t\t\tyield* byId.values();\n\t\t}\n\t};\n}\n//#endregion\n//#region src/codecs.ts\n/**\n* Construct a Mongo codec from author functions.\n*\n* Author `encode` and `decode` as sync or async functions; the factory produces a {@link MongoCodec} whose query-time methods follow the boundary contract documented on the framework {@link BaseCodec}. Authors receive a second `ctx` options argument carrying the per-call context; ignore it if you don't need it.\n*\n* Both `encode` and `decode` are required so `TInput` and `TWire` are always covered by an explicit author function — the factory installs no identity fallback. `encodeJson` and `decodeJson` default to identity **only when `TInput` is assignable to `JsonValue`**; otherwise both are required so the contract artifact stays JSON-safe.\n*\n* Codec-id-keyed static metadata (`traits`, `targetTypes`, `renderOutputType`) lives on the unified `CodecDescriptor` rather than on the codec instance itself (TML-2357).\n*/\nfunction mongoCodec(config) {\n\tconst identity = (v) => v;\n\tconst userEncode = config.encode;\n\tconst userDecode = config.decode;\n\tconst widenedConfig = config;\n\treturn {\n\t\tid: config.typeId,\n\t\tencode: (value, ctx) => {\n\t\t\ttry {\n\t\t\t\treturn Promise.resolve(userEncode(value, ctx));\n\t\t\t} catch (error) {\n\t\t\t\treturn Promise.reject(error);\n\t\t\t}\n\t\t},\n\t\tdecode: (wire, ctx) => {\n\t\t\ttry {\n\t\t\t\treturn Promise.resolve(userDecode(wire, ctx));\n\t\t\t} catch (error) {\n\t\t\t\treturn Promise.reject(error);\n\t\t\t}\n\t\t},\n\t\tencodeJson: widenedConfig.encodeJson ?? identity,\n\t\tdecodeJson: widenedConfig.decodeJson ?? identity\n\t};\n}\n//#endregion\nexport { mongoCodec, newMongoCodecRegistry };\n\n//# sourceMappingURL=index.mjs.map"],"mappings":";;;;;AAKA,SAAS,wBAAwB;CAChC,MAAM,uBAAuB,IAAI,IAAI;CACrC,OAAO;EACN,MAAM,OAAO,KAAK,IAAI,EAAE;EACxB,MAAM,OAAO,KAAK,IAAI,EAAE;EACxB,WAAW,UAAU;GACpB,IAAI,KAAK,IAAI,MAAM,EAAE,GAAG,MAAM,gBAAgB,2BAA2B,kBAAkB,MAAM,GAAG,wBAAwB;GAC5H,KAAK,IAAI,MAAM,IAAI,KAAK;EACzB;EACA,cAAc,KAAK,OAAO;EAC1B,CAAC,OAAO,WAAW,aAAa;GAC/B,OAAO,KAAK,OAAO;EACpB;CACD;AACD;;;;;;;;;;AAYA,SAAS,WAAW,QAAQ;CAC3B,MAAM,YAAY,MAAM;CACxB,MAAM,aAAa,OAAO;CAC1B,MAAM,aAAa,OAAO;CAC1B,MAAM,gBAAgB;CACtB,OAAO;EACN,IAAI,OAAO;EACX,SAAS,OAAO,QAAQ;GACvB,IAAI;IACH,OAAO,QAAQ,QAAQ,WAAW,OAAO,GAAG,CAAC;GAC9C,SAAS,OAAO;IACf,OAAO,QAAQ,OAAO,KAAK;GAC5B;EACD;EACA,SAAS,MAAM,QAAQ;GACtB,IAAI;IACH,OAAO,QAAQ,QAAQ,WAAW,MAAM,GAAG,CAAC;GAC7C,SAAS,OAAO;IACf,OAAO,QAAQ,OAAO,KAAK;GAC5B;EACD;EACA,YAAY,cAAc,cAAc;EACxC,YAAY,cAAc,cAAc;CACzC;AACD"}
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import { n as MongoCollationOptions, o as MongoIndex, p as composeMongoEntityKinds } from "./entity-kinds-B4KNTF8z-DPIuUuuB.mjs";
|
|
2
|
+
import { structuredError } from "@prisma/orm-framework/utils/structured-error";
|
|
3
|
+
import { IRNodeBase, NamespaceBase, UNBOUND_NAMESPACE_ID, buildNamespacedEntities, buildSingleNamespaceView, freezeNode, hydrateNamespaceEntities } from "@prisma/orm-framework/components/ir";
|
|
4
|
+
import { UNBOUND_DOMAIN_NAMESPACE_ID } from "@prisma/orm-framework/contract/default-namespace";
|
|
5
|
+
import { blindCast } from "@prisma/orm-framework/utils/casts";
|
|
6
|
+
//#region ../../../2-mongo-family/1-foundation/mongo-contract/dist/index.mjs
|
|
7
|
+
const MONGO_BUILTIN_KINDS = ["collection"];
|
|
8
|
+
/**
|
|
9
|
+
* Builds the Mongo view: unwraps the sole namespace's built-in `collection` kind
|
|
10
|
+
* to the root, attaches the namespace-keyed `namespace` map, and layers both
|
|
11
|
+
* over the deserialized contract so the result is a structural superset of the
|
|
12
|
+
* contract.
|
|
13
|
+
*/
|
|
14
|
+
function buildMongoContractView(contract) {
|
|
15
|
+
const rootAccessors = buildSingleNamespaceView(contract.storage, MONGO_BUILTIN_KINDS);
|
|
16
|
+
const namespace = buildNamespacedEntities(contract.storage, MONGO_BUILTIN_KINDS);
|
|
17
|
+
return {
|
|
18
|
+
...contract,
|
|
19
|
+
...rootAccessors,
|
|
20
|
+
namespace
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/** Default storage namespace for Mongo-family contracts at runtime. */
|
|
24
|
+
const defaultMongoStorageNamespaceId = UNBOUND_NAMESPACE_ID;
|
|
25
|
+
/** Default domain namespace for Mongo-family contracts at runtime. */
|
|
26
|
+
const defaultMongoDomainNamespaceId = UNBOUND_DOMAIN_NAMESPACE_ID;
|
|
27
|
+
var MongoUnboundNamespace = class MongoUnboundNamespace extends NamespaceBase {
|
|
28
|
+
static instance = new MongoUnboundNamespace();
|
|
29
|
+
id = UNBOUND_NAMESPACE_ID;
|
|
30
|
+
entries = Object.freeze({ collection: Object.freeze({}) });
|
|
31
|
+
constructor() {
|
|
32
|
+
super();
|
|
33
|
+
Object.defineProperty(this, "kind", {
|
|
34
|
+
value: "mongo-namespace",
|
|
35
|
+
writable: false,
|
|
36
|
+
enumerable: false,
|
|
37
|
+
configurable: true
|
|
38
|
+
});
|
|
39
|
+
freezeNode(this);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
const MONGO_NAMESPACE_KIND = "mongo-namespace";
|
|
43
|
+
var MongoBoundNamespace = class MongoBoundNamespace extends NamespaceBase {
|
|
44
|
+
id;
|
|
45
|
+
entries;
|
|
46
|
+
static fromCollectionsInput(input) {
|
|
47
|
+
const collectionMap = input.entries["collection"];
|
|
48
|
+
const collectionCount = collectionMap !== void 0 ? Object.keys(collectionMap).length : 0;
|
|
49
|
+
const hasUnknownKinds = Object.keys(input.entries).some((kind) => kind !== "collection");
|
|
50
|
+
if (input.id === UNBOUND_NAMESPACE_ID && collectionCount === 0 && !hasUnknownKinds) return MongoUnboundNamespace.instance;
|
|
51
|
+
return new MongoBoundNamespace(input);
|
|
52
|
+
}
|
|
53
|
+
constructor(input) {
|
|
54
|
+
super();
|
|
55
|
+
this.id = input.id;
|
|
56
|
+
const rawEntries = {
|
|
57
|
+
collection: {},
|
|
58
|
+
...input.entries
|
|
59
|
+
};
|
|
60
|
+
this.entries = Object.freeze(blindCast(hydrateNamespaceEntities(rawEntries, composeMongoEntityKinds(), "carry")));
|
|
61
|
+
Object.defineProperty(this, "kind", {
|
|
62
|
+
value: MONGO_NAMESPACE_KIND,
|
|
63
|
+
writable: false,
|
|
64
|
+
enumerable: false,
|
|
65
|
+
configurable: true
|
|
66
|
+
});
|
|
67
|
+
freezeNode(this);
|
|
68
|
+
}
|
|
69
|
+
get collection() {
|
|
70
|
+
return this.entries.collection ?? Object.freeze({});
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
function buildMongoNamespace(input) {
|
|
74
|
+
return MongoBoundNamespace.fromCollectionsInput(input);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Clustered-collection options (the `clusteredIndex` collection-creation
|
|
78
|
+
* field). Lifted from a `type =` data shape to an AST class extending
|
|
79
|
+
* `IRNodeBase` per FR18.
|
|
80
|
+
*
|
|
81
|
+
* MongoDB requires `key` and `unique` for any clustered collection; the
|
|
82
|
+
* constructor enforces presence by type signature.
|
|
83
|
+
*/
|
|
84
|
+
var MongoClusteredCollectionOptions = class extends IRNodeBase {
|
|
85
|
+
kind = "mongo-clustered-collection-options";
|
|
86
|
+
key;
|
|
87
|
+
unique;
|
|
88
|
+
constructor(options) {
|
|
89
|
+
super();
|
|
90
|
+
if (options.name !== void 0) this.name = options.name;
|
|
91
|
+
this.key = options.key;
|
|
92
|
+
this.unique = options.unique;
|
|
93
|
+
freezeNode(this);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Mongo Contract IR node for the per-index option vocabulary (the second
|
|
98
|
+
* argument to `db.collection.createIndex(keys, options)` minus the keys
|
|
99
|
+
* themselves). Lifted from a `type =` data shape to an AST class
|
|
100
|
+
* extending `IRNodeBase` per FR18.
|
|
101
|
+
*
|
|
102
|
+
* Nested `collation` is itself an IR class (`MongoCollationOptions`); the
|
|
103
|
+
* constructor accepts either a class instance or a data literal and
|
|
104
|
+
* normalises to the class form so downstream walks see a uniform IR tree.
|
|
105
|
+
*/
|
|
106
|
+
var MongoIndexOptions = class extends IRNodeBase {
|
|
107
|
+
kind = "mongo-index-options";
|
|
108
|
+
constructor(options = {}) {
|
|
109
|
+
super();
|
|
110
|
+
if (options.unique !== void 0) this.unique = options.unique;
|
|
111
|
+
if (options.name !== void 0) this.name = options.name;
|
|
112
|
+
if (options.partialFilterExpression !== void 0) this.partialFilterExpression = options.partialFilterExpression;
|
|
113
|
+
if (options.sparse !== void 0) this.sparse = options.sparse;
|
|
114
|
+
if (options.expireAfterSeconds !== void 0) this.expireAfterSeconds = options.expireAfterSeconds;
|
|
115
|
+
if (options.weights !== void 0) this.weights = options.weights;
|
|
116
|
+
if (options.default_language !== void 0) this.default_language = options.default_language;
|
|
117
|
+
if (options.language_override !== void 0) this.language_override = options.language_override;
|
|
118
|
+
if (options.textIndexVersion !== void 0) this.textIndexVersion = options.textIndexVersion;
|
|
119
|
+
if (options["2dsphereIndexVersion"] !== void 0) this["2dsphereIndexVersion"] = options["2dsphereIndexVersion"];
|
|
120
|
+
if (options.bits !== void 0) this.bits = options.bits;
|
|
121
|
+
if (options.min !== void 0) this.min = options.min;
|
|
122
|
+
if (options.max !== void 0) this.max = options.max;
|
|
123
|
+
if (options.bucketSize !== void 0) this.bucketSize = options.bucketSize;
|
|
124
|
+
if (options.hidden !== void 0) this.hidden = options.hidden;
|
|
125
|
+
if (options.collation !== void 0) this.collation = options.collation instanceof MongoCollationOptions ? options.collation : new MongoCollationOptions(options.collation);
|
|
126
|
+
if (options.wildcardProjection !== void 0) this.wildcardProjection = options.wildcardProjection;
|
|
127
|
+
freezeNode(this);
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
var MongoStorage = class extends IRNodeBase {
|
|
131
|
+
storageHash;
|
|
132
|
+
namespaces;
|
|
133
|
+
constructor(input) {
|
|
134
|
+
super();
|
|
135
|
+
Object.defineProperty(this, "kind", {
|
|
136
|
+
value: "mongo-storage",
|
|
137
|
+
writable: false,
|
|
138
|
+
enumerable: false,
|
|
139
|
+
configurable: true
|
|
140
|
+
});
|
|
141
|
+
this.storageHash = input.storageHash;
|
|
142
|
+
this.namespaces = Object.freeze(input.namespaces);
|
|
143
|
+
freezeNode(this);
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
function isScalarDiscriminatorValue(value) {
|
|
147
|
+
const t = typeof value;
|
|
148
|
+
return t === "string" || t === "number" || t === "boolean";
|
|
149
|
+
}
|
|
150
|
+
function formatValue(value) {
|
|
151
|
+
if (typeof value === "string") return JSON.stringify(value);
|
|
152
|
+
if (value === null) return "null";
|
|
153
|
+
if (Array.isArray(value)) return JSON.stringify(value);
|
|
154
|
+
if (typeof value === "object") return JSON.stringify(value);
|
|
155
|
+
return String(value);
|
|
156
|
+
}
|
|
157
|
+
function applyPolymorphicScopeToMongoIndex(index, scope) {
|
|
158
|
+
if (!isScalarDiscriminatorValue(scope.discriminatorValue)) return {
|
|
159
|
+
kind: "conflict",
|
|
160
|
+
reason: `Variant-scoped indexes require a scalar (string, number, or boolean) discriminator value for field "${scope.discriminatorField}", but received ${formatValue(scope.discriminatorValue)}.`
|
|
161
|
+
};
|
|
162
|
+
const existing = index.partialFilterExpression;
|
|
163
|
+
if (existing && Object.hasOwn(existing, scope.discriminatorField)) {
|
|
164
|
+
const existingValue = existing[scope.discriminatorField];
|
|
165
|
+
if (existingValue === scope.discriminatorValue) return {
|
|
166
|
+
kind: "ok",
|
|
167
|
+
index
|
|
168
|
+
};
|
|
169
|
+
return {
|
|
170
|
+
kind: "conflict",
|
|
171
|
+
reason: `Index partialFilterExpression sets "${scope.discriminatorField}" to ${formatValue(existingValue)}, which conflicts with the variant's discriminator value ${formatValue(scope.discriminatorValue)}.`
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
const merged = {
|
|
175
|
+
...existing ?? {},
|
|
176
|
+
[scope.discriminatorField]: scope.discriminatorValue
|
|
177
|
+
};
|
|
178
|
+
return {
|
|
179
|
+
kind: "ok",
|
|
180
|
+
index: new MongoIndex({
|
|
181
|
+
keys: index.keys,
|
|
182
|
+
...index.unique !== void 0 && { unique: index.unique },
|
|
183
|
+
...index.sparse !== void 0 && { sparse: index.sparse },
|
|
184
|
+
...index.expireAfterSeconds !== void 0 && { expireAfterSeconds: index.expireAfterSeconds },
|
|
185
|
+
partialFilterExpression: merged,
|
|
186
|
+
...index.wildcardProjection !== void 0 && { wildcardProjection: index.wildcardProjection },
|
|
187
|
+
...index.collation !== void 0 && { collation: index.collation },
|
|
188
|
+
...index.weights !== void 0 && { weights: index.weights },
|
|
189
|
+
...index.default_language !== void 0 && { default_language: index.default_language },
|
|
190
|
+
...index.language_override !== void 0 && { language_override: index.language_override }
|
|
191
|
+
})
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
function formatCrossRef(crossRef) {
|
|
195
|
+
return `${crossRef.namespace}.${crossRef.model}`;
|
|
196
|
+
}
|
|
197
|
+
function storageDeclaresCollection(storage, collectionName) {
|
|
198
|
+
for (const ns of Object.values(storage.namespaces)) if (Object.hasOwn(ns.entries["collection"] ?? {}, collectionName)) return true;
|
|
199
|
+
return false;
|
|
200
|
+
}
|
|
201
|
+
function validateMongoStorage(contract) {
|
|
202
|
+
const errors = [];
|
|
203
|
+
for (const [namespaceId, namespace] of Object.entries(contract.domain.namespaces)) {
|
|
204
|
+
const models = namespace.models;
|
|
205
|
+
for (const [modelName, model] of Object.entries(models)) {
|
|
206
|
+
const qualifiedName = `${namespaceId}:${modelName}`;
|
|
207
|
+
if (model.storage.collection && !storageDeclaresCollection(contract.storage, model.storage.collection)) errors.push(`Model "${qualifiedName}" references collection "${model.storage.collection}" which is not declared under any namespace's collections map`);
|
|
208
|
+
if (model.base) {
|
|
209
|
+
const baseModel = models[model.base.model];
|
|
210
|
+
if (baseModel) {
|
|
211
|
+
const variantCollection = model.storage.collection;
|
|
212
|
+
const baseCollection = baseModel.storage.collection;
|
|
213
|
+
if (variantCollection !== baseCollection) errors.push(`Mongo does not support multi-table inheritance; variant "${qualifiedName}" must share its base's collection ("${baseCollection ?? "(none)"}"), but has "${variantCollection ?? "(none)"}"`);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
for (const [relName, relation] of Object.entries(model.relations ?? {})) {
|
|
217
|
+
const targetModel = models[relation.to.model];
|
|
218
|
+
const targetLabel = formatCrossRef(relation.to);
|
|
219
|
+
if (targetModel?.owner) {
|
|
220
|
+
if (targetModel.owner !== modelName) errors.push(`Embed relation "${relName}" targets "${targetLabel}" which is owned by "${targetModel.owner}", not "${qualifiedName}"`);
|
|
221
|
+
if (targetModel.storage.collection) errors.push(`Embed relation "${relName}" targets "${targetLabel}" which must not have a collection`);
|
|
222
|
+
} else if ("on" in relation && relation.on) {
|
|
223
|
+
for (const localField of relation.on.localFields) if (!(localField in model.fields)) errors.push(`Reference relation "${relName}": localField "${localField}" is not a field on model "${qualifiedName}"`);
|
|
224
|
+
if (targetModel) {
|
|
225
|
+
for (const targetField of relation.on.targetFields) if (!(targetField in targetModel.fields)) errors.push(`Reference relation "${relName}": targetField "${targetField}" is not a field on model "${targetLabel}"`);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
if (errors.length > 0) throw structuredError("CONTRACT.VALIDATION_FAILED", `Contract storage validation failed:\n- ${errors.join("\n- ")}`);
|
|
232
|
+
}
|
|
233
|
+
//#endregion
|
|
234
|
+
export { applyPolymorphicScopeToMongoIndex as a, defaultMongoDomainNamespaceId as c, MongoUnboundNamespace as i, defaultMongoStorageNamespaceId as l, MongoIndexOptions as n, buildMongoContractView as o, MongoStorage as r, buildMongoNamespace as s, MongoClusteredCollectionOptions as t, validateMongoStorage as u };
|
|
235
|
+
|
|
236
|
+
//# sourceMappingURL=dist-DHrEJnhK.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dist-DHrEJnhK.mjs","names":[],"sources":["../../../../2-mongo-family/1-foundation/mongo-contract/dist/index.mjs"],"sourcesContent":["import { a as MongoCollection, c as MongoCollectionOptions, d as MongoCollationOptions, f as MongoChangeStreamPreAndPostImagesOptions, g as createMongoNamespaceEnvelopeSchema, h as createMongoContractSchema, i as MongoValueSet, l as MongoTimeSeriesCollectionOptions, m as StorageValueSetSchema, n as composeMongoEntityKinds, o as MongoValidator, p as MongoContractSchema, s as MongoIndex, u as MongoIndexOptionDefaults } from \"./entity-kinds-B4KNTF8z.mjs\";\nimport { IRNodeBase, NamespaceBase, UNBOUND_NAMESPACE_ID, buildNamespacedEntities, buildSingleNamespaceView, freezeNode, hydrateNamespaceEntities } from \"@internal/framework-components/ir\";\nimport { UNBOUND_DOMAIN_NAMESPACE_ID } from \"@internal/contract/default-namespace\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { structuredError } from \"@internal/utils/structured-error\";\n//#region src/contract-view.ts\nconst MONGO_BUILTIN_KINDS = [\"collection\"];\n/**\n* Builds the Mongo view: unwraps the sole namespace's built-in `collection` kind\n* to the root, attaches the namespace-keyed `namespace` map, and layers both\n* over the deserialized contract so the result is a structural superset of the\n* contract.\n*/\nfunction buildMongoContractView(contract) {\n\tconst rootAccessors = buildSingleNamespaceView(contract.storage, MONGO_BUILTIN_KINDS);\n\tconst namespace = buildNamespacedEntities(contract.storage, MONGO_BUILTIN_KINDS);\n\treturn {\n\t\t...contract,\n\t\t...rootAccessors,\n\t\tnamespace\n\t};\n}\n//#endregion\n//#region src/default-namespace.ts\n/** Default storage namespace for Mongo-family contracts at runtime. */\nconst defaultMongoStorageNamespaceId = UNBOUND_NAMESPACE_ID;\n/** Default domain namespace for Mongo-family contracts at runtime. */\nconst defaultMongoDomainNamespaceId = UNBOUND_DOMAIN_NAMESPACE_ID;\n//#endregion\n//#region src/ir/mongo-unbound-namespace.ts\nvar MongoUnboundNamespace = class MongoUnboundNamespace extends NamespaceBase {\n\tstatic instance = new MongoUnboundNamespace();\n\tid = UNBOUND_NAMESPACE_ID;\n\tentries = Object.freeze({ collection: Object.freeze({}) });\n\tconstructor() {\n\t\tsuper();\n\t\tObject.defineProperty(this, \"kind\", {\n\t\t\tvalue: \"mongo-namespace\",\n\t\t\twritable: false,\n\t\t\tenumerable: false,\n\t\t\tconfigurable: true\n\t\t});\n\t\tfreezeNode(this);\n\t}\n};\n//#endregion\n//#region src/ir/build-mongo-namespace.ts\nconst MONGO_NAMESPACE_KIND = \"mongo-namespace\";\nvar MongoBoundNamespace = class MongoBoundNamespace extends NamespaceBase {\n\tid;\n\tentries;\n\tstatic fromCollectionsInput(input) {\n\t\tconst collectionMap = input.entries[\"collection\"];\n\t\tconst collectionCount = collectionMap !== void 0 ? Object.keys(collectionMap).length : 0;\n\t\tconst hasUnknownKinds = Object.keys(input.entries).some((kind) => kind !== \"collection\");\n\t\tif (input.id === UNBOUND_NAMESPACE_ID && collectionCount === 0 && !hasUnknownKinds) return MongoUnboundNamespace.instance;\n\t\treturn new MongoBoundNamespace(input);\n\t}\n\tconstructor(input) {\n\t\tsuper();\n\t\tthis.id = input.id;\n\t\tconst rawEntries = {\n\t\t\tcollection: {},\n\t\t\t...input.entries\n\t\t};\n\t\tthis.entries = Object.freeze(blindCast(hydrateNamespaceEntities(rawEntries, composeMongoEntityKinds(), \"carry\")));\n\t\tObject.defineProperty(this, \"kind\", {\n\t\t\tvalue: MONGO_NAMESPACE_KIND,\n\t\t\twritable: false,\n\t\t\tenumerable: false,\n\t\t\tconfigurable: true\n\t\t});\n\t\tfreezeNode(this);\n\t}\n\tget collection() {\n\t\treturn this.entries.collection ?? Object.freeze({});\n\t}\n};\nfunction buildMongoNamespace(input) {\n\treturn MongoBoundNamespace.fromCollectionsInput(input);\n}\n//#endregion\n//#region src/ir/mongo-clustered-collection-options.ts\n/**\n* Clustered-collection options (the `clusteredIndex` collection-creation\n* field). Lifted from a `type =` data shape to an AST class extending\n* `IRNodeBase` per FR18.\n*\n* MongoDB requires `key` and `unique` for any clustered collection; the\n* constructor enforces presence by type signature.\n*/\nvar MongoClusteredCollectionOptions = class extends IRNodeBase {\n\tkind = \"mongo-clustered-collection-options\";\n\tkey;\n\tunique;\n\tconstructor(options) {\n\t\tsuper();\n\t\tif (options.name !== void 0) this.name = options.name;\n\t\tthis.key = options.key;\n\t\tthis.unique = options.unique;\n\t\tfreezeNode(this);\n\t}\n};\n//#endregion\n//#region src/ir/mongo-index-options.ts\n/**\n* Mongo Contract IR node for the per-index option vocabulary (the second\n* argument to `db.collection.createIndex(keys, options)` minus the keys\n* themselves). Lifted from a `type =` data shape to an AST class\n* extending `IRNodeBase` per FR18.\n*\n* Nested `collation` is itself an IR class (`MongoCollationOptions`); the\n* constructor accepts either a class instance or a data literal and\n* normalises to the class form so downstream walks see a uniform IR tree.\n*/\nvar MongoIndexOptions = class extends IRNodeBase {\n\tkind = \"mongo-index-options\";\n\tconstructor(options = {}) {\n\t\tsuper();\n\t\tif (options.unique !== void 0) this.unique = options.unique;\n\t\tif (options.name !== void 0) this.name = options.name;\n\t\tif (options.partialFilterExpression !== void 0) this.partialFilterExpression = options.partialFilterExpression;\n\t\tif (options.sparse !== void 0) this.sparse = options.sparse;\n\t\tif (options.expireAfterSeconds !== void 0) this.expireAfterSeconds = options.expireAfterSeconds;\n\t\tif (options.weights !== void 0) this.weights = options.weights;\n\t\tif (options.default_language !== void 0) this.default_language = options.default_language;\n\t\tif (options.language_override !== void 0) this.language_override = options.language_override;\n\t\tif (options.textIndexVersion !== void 0) this.textIndexVersion = options.textIndexVersion;\n\t\tif (options[\"2dsphereIndexVersion\"] !== void 0) this[\"2dsphereIndexVersion\"] = options[\"2dsphereIndexVersion\"];\n\t\tif (options.bits !== void 0) this.bits = options.bits;\n\t\tif (options.min !== void 0) this.min = options.min;\n\t\tif (options.max !== void 0) this.max = options.max;\n\t\tif (options.bucketSize !== void 0) this.bucketSize = options.bucketSize;\n\t\tif (options.hidden !== void 0) this.hidden = options.hidden;\n\t\tif (options.collation !== void 0) this.collation = options.collation instanceof MongoCollationOptions ? options.collation : new MongoCollationOptions(options.collation);\n\t\tif (options.wildcardProjection !== void 0) this.wildcardProjection = options.wildcardProjection;\n\t\tfreezeNode(this);\n\t}\n};\n//#endregion\n//#region src/ir/mongo-storage.ts\nvar MongoStorage = class extends IRNodeBase {\n\tstorageHash;\n\tnamespaces;\n\tconstructor(input) {\n\t\tsuper();\n\t\tObject.defineProperty(this, \"kind\", {\n\t\t\tvalue: \"mongo-storage\",\n\t\t\twritable: false,\n\t\t\tenumerable: false,\n\t\t\tconfigurable: true\n\t\t});\n\t\tthis.storageHash = input.storageHash;\n\t\tthis.namespaces = Object.freeze(input.namespaces);\n\t\tfreezeNode(this);\n\t}\n};\n//#endregion\n//#region src/polymorphic-index-scope.ts\nfunction isScalarDiscriminatorValue(value) {\n\tconst t = typeof value;\n\treturn t === \"string\" || t === \"number\" || t === \"boolean\";\n}\nfunction formatValue(value) {\n\tif (typeof value === \"string\") return JSON.stringify(value);\n\tif (value === null) return \"null\";\n\tif (Array.isArray(value)) return JSON.stringify(value);\n\tif (typeof value === \"object\") return JSON.stringify(value);\n\treturn String(value);\n}\nfunction applyPolymorphicScopeToMongoIndex(index, scope) {\n\tif (!isScalarDiscriminatorValue(scope.discriminatorValue)) return {\n\t\tkind: \"conflict\",\n\t\treason: `Variant-scoped indexes require a scalar (string, number, or boolean) discriminator value for field \"${scope.discriminatorField}\", but received ${formatValue(scope.discriminatorValue)}.`\n\t};\n\tconst existing = index.partialFilterExpression;\n\tif (existing && Object.hasOwn(existing, scope.discriminatorField)) {\n\t\tconst existingValue = existing[scope.discriminatorField];\n\t\tif (existingValue === scope.discriminatorValue) return {\n\t\t\tkind: \"ok\",\n\t\t\tindex\n\t\t};\n\t\treturn {\n\t\t\tkind: \"conflict\",\n\t\t\treason: `Index partialFilterExpression sets \"${scope.discriminatorField}\" to ${formatValue(existingValue)}, which conflicts with the variant's discriminator value ${formatValue(scope.discriminatorValue)}.`\n\t\t};\n\t}\n\tconst merged = {\n\t\t...existing ?? {},\n\t\t[scope.discriminatorField]: scope.discriminatorValue\n\t};\n\treturn {\n\t\tkind: \"ok\",\n\t\tindex: new MongoIndex({\n\t\t\tkeys: index.keys,\n\t\t\t...index.unique !== void 0 && { unique: index.unique },\n\t\t\t...index.sparse !== void 0 && { sparse: index.sparse },\n\t\t\t...index.expireAfterSeconds !== void 0 && { expireAfterSeconds: index.expireAfterSeconds },\n\t\t\tpartialFilterExpression: merged,\n\t\t\t...index.wildcardProjection !== void 0 && { wildcardProjection: index.wildcardProjection },\n\t\t\t...index.collation !== void 0 && { collation: index.collation },\n\t\t\t...index.weights !== void 0 && { weights: index.weights },\n\t\t\t...index.default_language !== void 0 && { default_language: index.default_language },\n\t\t\t...index.language_override !== void 0 && { language_override: index.language_override }\n\t\t})\n\t};\n}\n//#endregion\n//#region src/validate-storage.ts\nfunction formatCrossRef(crossRef) {\n\treturn `${crossRef.namespace}.${crossRef.model}`;\n}\nfunction storageDeclaresCollection(storage, collectionName) {\n\tfor (const ns of Object.values(storage.namespaces)) if (Object.hasOwn(ns.entries[\"collection\"] ?? {}, collectionName)) return true;\n\treturn false;\n}\nfunction validateMongoStorage(contract) {\n\tconst errors = [];\n\tfor (const [namespaceId, namespace] of Object.entries(contract.domain.namespaces)) {\n\t\tconst models = namespace.models;\n\t\tfor (const [modelName, model] of Object.entries(models)) {\n\t\t\tconst qualifiedName = `${namespaceId}:${modelName}`;\n\t\t\tif (model.storage.collection && !storageDeclaresCollection(contract.storage, model.storage.collection)) errors.push(`Model \"${qualifiedName}\" references collection \"${model.storage.collection}\" which is not declared under any namespace's collections map`);\n\t\t\tif (model.base) {\n\t\t\t\tconst baseModel = models[model.base.model];\n\t\t\t\tif (baseModel) {\n\t\t\t\t\tconst variantCollection = model.storage.collection;\n\t\t\t\t\tconst baseCollection = baseModel.storage.collection;\n\t\t\t\t\tif (variantCollection !== baseCollection) errors.push(`Mongo does not support multi-table inheritance; variant \"${qualifiedName}\" must share its base's collection (\"${baseCollection ?? \"(none)\"}\"), but has \"${variantCollection ?? \"(none)\"}\"`);\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (const [relName, relation] of Object.entries(model.relations ?? {})) {\n\t\t\t\tconst targetModel = models[relation.to.model];\n\t\t\t\tconst targetLabel = formatCrossRef(relation.to);\n\t\t\t\tif (targetModel?.owner) {\n\t\t\t\t\tif (targetModel.owner !== modelName) errors.push(`Embed relation \"${relName}\" targets \"${targetLabel}\" which is owned by \"${targetModel.owner}\", not \"${qualifiedName}\"`);\n\t\t\t\t\tif (targetModel.storage.collection) errors.push(`Embed relation \"${relName}\" targets \"${targetLabel}\" which must not have a collection`);\n\t\t\t\t} else if (\"on\" in relation && relation.on) {\n\t\t\t\t\tfor (const localField of relation.on.localFields) if (!(localField in model.fields)) errors.push(`Reference relation \"${relName}\": localField \"${localField}\" is not a field on model \"${qualifiedName}\"`);\n\t\t\t\t\tif (targetModel) {\n\t\t\t\t\t\tfor (const targetField of relation.on.targetFields) if (!(targetField in targetModel.fields)) errors.push(`Reference relation \"${relName}\": targetField \"${targetField}\" is not a field on model \"${targetLabel}\"`);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tif (errors.length > 0) throw structuredError(\"CONTRACT.VALIDATION_FAILED\", `Contract storage validation failed:\\n- ${errors.join(\"\\n- \")}`);\n}\n//#endregion\nexport { MongoChangeStreamPreAndPostImagesOptions, MongoClusteredCollectionOptions, MongoCollationOptions, MongoCollection, MongoCollectionOptions, MongoContractSchema, MongoIndex, MongoIndexOptionDefaults, MongoIndexOptions, MongoStorage, MongoTimeSeriesCollectionOptions, MongoUnboundNamespace, MongoValidator, MongoValueSet, StorageValueSetSchema, applyPolymorphicScopeToMongoIndex, buildMongoContractView, buildMongoNamespace, createMongoContractSchema, createMongoNamespaceEnvelopeSchema, defaultMongoDomainNamespaceId, defaultMongoStorageNamespaceId, validateMongoStorage };\n\n//# sourceMappingURL=index.mjs.map"],"mappings":";;;;;;AAMA,MAAM,sBAAsB,CAAC,YAAY;;;;;;;AAOzC,SAAS,uBAAuB,UAAU;CACzC,MAAM,gBAAgB,yBAAyB,SAAS,SAAS,mBAAmB;CACpF,MAAM,YAAY,wBAAwB,SAAS,SAAS,mBAAmB;CAC/E,OAAO;EACN,GAAG;EACH,GAAG;EACH;CACD;AACD;;AAIA,MAAM,iCAAiC;;AAEvC,MAAM,gCAAgC;AAGtC,IAAI,wBAAwB,MAAM,8BAA8B,cAAc;CAC7E,OAAO,WAAW,IAAI,sBAAsB;CAC5C,KAAK;CACL,UAAU,OAAO,OAAO,EAAE,YAAY,OAAO,OAAO,CAAC,CAAC,EAAE,CAAC;CACzD,cAAc;EACb,MAAM;EACN,OAAO,eAAe,MAAM,QAAQ;GACnC,OAAO;GACP,UAAU;GACV,YAAY;GACZ,cAAc;EACf,CAAC;EACD,WAAW,IAAI;CAChB;AACD;AAGA,MAAM,uBAAuB;AAC7B,IAAI,sBAAsB,MAAM,4BAA4B,cAAc;CACzE;CACA;CACA,OAAO,qBAAqB,OAAO;EAClC,MAAM,gBAAgB,MAAM,QAAQ;EACpC,MAAM,kBAAkB,kBAAkB,KAAK,IAAI,OAAO,KAAK,aAAa,CAAC,CAAC,SAAS;EACvF,MAAM,kBAAkB,OAAO,KAAK,MAAM,OAAO,CAAC,CAAC,MAAM,SAAS,SAAS,YAAY;EACvF,IAAI,MAAM,OAAO,wBAA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