@prisma/orm-family-mongo 8.0.0-rc.18-dev.15 → 8.0.0-rc.18-dev.17
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/{authoring-entity-types-ooM-r2td-r5JwBDd-.mjs → authoring-entity-types-C4WFd_RV-BiY2lX_e.mjs} +6 -6
- package/dist/{authoring-entity-types-ooM-r2td-r5JwBDd-.mjs.map → authoring-entity-types-C4WFd_RV-BiY2lX_e.mjs.map} +1 -1
- package/dist/codec.d.mts +1 -1
- package/dist/codec.mjs +1 -1
- package/dist/{contract-builder-C_-FfTnK.mjs → contract-builder-DYeV4YqF.mjs} +4 -4
- package/dist/{contract-builder-C_-FfTnK.mjs.map → contract-builder-DYeV4YqF.mjs.map} +1 -1
- package/dist/contract-prisma6__provider.mjs +3 -3
- package/dist/contract-psl.d.mts +1 -1
- package/dist/contract-psl.mjs +1 -1
- package/dist/contract-psl__provider.mjs +1 -1
- package/dist/contract-psl__provider.mjs.map +1 -1
- package/dist/contract-ts.mjs +1 -1
- package/dist/contract-ts__contract-builder.mjs +1 -1
- package/dist/contract.mjs +1 -1
- package/dist/{control-Dx9KcAk2.mjs → control-Dr88-3gg.mjs} +5 -5
- package/dist/{control-Dx9KcAk2.mjs.map → control-Dr88-3gg.mjs.map} +1 -1
- package/dist/{dist-CqUoKyeL.mjs → dist-Bgk36iLI.mjs} +15 -11
- package/dist/dist-Bgk36iLI.mjs.map +1 -0
- package/dist/{dist-BbfUvuqQ.mjs → dist-K-Zzlzm5.mjs} +2 -2
- package/dist/{dist-BbfUvuqQ.mjs.map → dist-K-Zzlzm5.mjs.map} +1 -1
- package/dist/{dist-iEoPybgM.mjs → dist-PsrJ9kgJ.mjs} +2 -2
- package/dist/{dist-iEoPybgM.mjs.map → dist-PsrJ9kgJ.mjs.map} +1 -1
- package/dist/dist-xk_0xOR-.mjs.map +1 -1
- package/dist/family.mjs +7 -7
- package/dist/family__control.mjs +2 -2
- package/dist/family__ir.mjs +2 -2
- package/dist/family__migration.mjs +1 -1
- package/dist/family__pack.mjs +2 -2
- package/dist/family__pack.mjs.map +1 -1
- package/dist/family__runtime.mjs +1 -1
- package/dist/family__schema-verify.mjs +1 -1
- package/dist/index-CQG5l2o9.d.mts +67 -0
- package/dist/index-CQG5l2o9.d.mts.map +1 -0
- package/dist/{interpreter-BKBSURkK-B9QVhiLs.mjs → interpreter-CHQQ4WDf-UuxfVRi6.mjs} +12 -8
- package/dist/interpreter-CHQQ4WDf-UuxfVRi6.mjs.map +1 -0
- package/dist/{migration-Bd8GWTeP.mjs → migration-CaBC0X76.mjs} +2 -2
- package/dist/{migration-Bd8GWTeP.mjs.map → migration-CaBC0X76.mjs.map} +1 -1
- package/dist/{mongo-contract-serializer-5OphMWx2-DkWnm3kW.mjs → mongo-contract-serializer-5OphMWx2-BlW2zlIQ.mjs} +3 -3
- package/dist/{mongo-contract-serializer-5OphMWx2-DkWnm3kW.mjs.map → mongo-contract-serializer-5OphMWx2-BlW2zlIQ.mjs.map} +1 -1
- package/dist/{mongo-contract-view-OSrxTeL0-IBirxnYy.mjs → mongo-contract-view-OSrxTeL0-C6aB-oJt.mjs} +3 -3
- package/dist/{mongo-contract-view-OSrxTeL0-IBirxnYy.mjs.map → mongo-contract-view-OSrxTeL0-C6aB-oJt.mjs.map} +1 -1
- package/dist/orm.mjs +2 -2
- package/dist/query-builder.mjs +1 -1
- package/dist/runtime.d.mts +2 -2
- package/dist/runtime.mjs +3 -3
- package/dist/runtime.mjs.map +1 -1
- package/dist/{verify-mongo-schema-BTj4mddD-C6v0IjFl.mjs → verify-mongo-schema-BTj4mddD-75_ALNmN.mjs} +2 -2
- package/dist/{verify-mongo-schema-BTj4mddD-C6v0IjFl.mjs.map → verify-mongo-schema-BTj4mddD-75_ALNmN.mjs.map} +1 -1
- package/package.json +20 -20
- package/dist/dist-CqUoKyeL.mjs.map +0 -1
- package/dist/index-DQD6JW4d.d.mts +0 -66
- package/dist/index-DQD6JW4d.d.mts.map +0 -1
- package/dist/interpreter-BKBSURkK-B9QVhiLs.mjs.map +0 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { n as isMongoDataType } from "./mongo-data-type-DJ7W2ota-BnUN7ydW.mjs";
|
|
2
|
-
import { _ as validatorEnumMemberRefusalOf, v as validatorEnumRefusalOf } from "./dist-
|
|
2
|
+
import { _ as validatorEnumMemberRefusalOf, v as validatorEnumRefusalOf } from "./dist-K-Zzlzm5.mjs";
|
|
3
|
+
import { enumRefusalOf } from "@prisma/orm-framework/components/codec";
|
|
4
|
+
import "@prisma/orm-framework/utils/casts";
|
|
3
5
|
import "@prisma/orm-framework/components/ir";
|
|
4
6
|
import "@prisma/orm-framework/contract/types";
|
|
5
|
-
import { enumRefusalOf } from "@prisma/orm-framework/components/codec";
|
|
6
7
|
import "@prisma/orm-framework/contract/hashing";
|
|
7
|
-
import "@prisma/orm-framework/utils/casts";
|
|
8
8
|
import { InternalError } from "@prisma/orm-framework/utils/internal-error";
|
|
9
9
|
import { enumType } from "@prisma/orm-framework/contract-authoring";
|
|
10
10
|
import { readEnumBlockMembers, resolveEnumCodecId } from "@prisma/orm-framework/components/authoring";
|
|
@@ -12,7 +12,7 @@ import { blockAttribute, jsonValue, mapBlock, str } from "@prisma/orm-framework/
|
|
|
12
12
|
import "@prisma/orm-framework/utils/defined";
|
|
13
13
|
import "@prisma/orm-framework/components/control";
|
|
14
14
|
import "@prisma/orm-framework/utils/canonical-stringify";
|
|
15
|
-
//#region ../../../2-mongo-family/9-family/dist/authoring-entity-types-
|
|
15
|
+
//#region ../../../2-mongo-family/9-family/dist/authoring-entity-types-C4WFd_RV.mjs
|
|
16
16
|
function mongoFamilyEnumSpec() {
|
|
17
17
|
return mapBlock({
|
|
18
18
|
value: {
|
|
@@ -87,7 +87,7 @@ const mongoFamilyEntityTypes = { enum: {
|
|
|
87
87
|
if (members === void 0) return void 0;
|
|
88
88
|
let unlistedMember = false;
|
|
89
89
|
for (const member of members) {
|
|
90
|
-
const refusal = validatorEnumMemberRefusalOf(bsonTypes, codec.
|
|
90
|
+
const refusal = validatorEnumMemberRefusalOf(bsonTypes, codec.dataType.toContract(codec.toDataTypeValue(member.value)));
|
|
91
91
|
if (refusal === void 0) continue;
|
|
92
92
|
diagnostics?.push({
|
|
93
93
|
code: "PSL_EXTENSION_INVALID_VALUE",
|
|
@@ -121,4 +121,4 @@ const mongoFamilyPslBlockDescriptors = { enum: {
|
|
|
121
121
|
//#endregion
|
|
122
122
|
export { mongoFamilyPslBlockDescriptors as n, mongoFamilyEntityTypes as t };
|
|
123
123
|
|
|
124
|
-
//# sourceMappingURL=authoring-entity-types-
|
|
124
|
+
//# sourceMappingURL=authoring-entity-types-C4WFd_RV-BiY2lX_e.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authoring-entity-types-
|
|
1
|
+
{"version":3,"file":"authoring-entity-types-C4WFd_RV-BiY2lX_e.mjs","names":[],"sources":["../../../../2-mongo-family/9-family/dist/authoring-entity-types-C4WFd_RV.mjs"],"sourcesContent":["import \"@internal/utils/defined\";\nimport { readEnumBlockMembers, resolveEnumCodecId } from \"@internal/framework-components/authoring\";\nimport { enumRefusalOf } from \"@internal/framework-components/codec\";\nimport { validatorEnumMemberRefusalOf, validatorEnumRefusalOf } from \"@internal/mongo-contract\";\nimport { isMongoDataType } from \"@internal/mongo-contract/data-type\";\nimport \"@internal/contract/hashing\";\nimport \"@internal/contract/types\";\nimport { enumType } from \"@internal/contract-authoring\";\nimport \"@internal/framework-components/control\";\nimport \"@internal/framework-components/ir\";\nimport \"@internal/mongo-contract/canonicalization-hooks\";\nimport \"@internal/utils/canonical-stringify\";\nimport \"@internal/utils/casts\";\nimport { blockAttribute, jsonValue, mapBlock, str } from \"@internal/psl-parser\";\nimport { InternalError } from \"@internal/utils/internal-error\";\n//#region src/core/authoring-entity-types.ts\nfunction mongoFamilyEnumSpec() {\n\treturn mapBlock({\n\t\tvalue: {\n\t\t\ttype: jsonValue(),\n\t\t\tdocumentation: \"The stored member value; a bare member stores its own name.\"\n\t\t},\n\t\tallowBare: true\n\t});\n}\nconst mongoFamilyEntityTypes = { enum: {\n\tkind: \"entity\",\n\tdiscriminator: \"enum\",\n\toutput: { factory: (block, ctx) => {\n\t\tconst sourceId = ctx.sourceId ?? \"unknown\";\n\t\tconst diagnostics = ctx.diagnostics;\n\t\tconst resolved = resolveEnumCodecId(block, ctx);\n\t\tif (resolved === void 0) return;\n\t\tconst { codecId, codecSpan } = resolved;\n\t\tconst descriptor = ctx.codecLookup.descriptorFor(codecId);\n\t\tif (descriptor === void 0) {\n\t\t\tdiagnostics?.push({\n\t\t\t\tcode: \"PSL_EXTENSION_INVALID_VALUE\",\n\t\t\t\tmessage: `enum \"${block.name}\" @@type references unknown codec \"${codecId}\"`,\n\t\t\t\tsourceId,\n\t\t\t\tspan: codecSpan\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\t\tconst dataType = ctx.dataTypeLookup.get(descriptor.dataType);\n\t\tif (dataType === void 0) {\n\t\t\tdiagnostics?.push({\n\t\t\t\tcode: \"PSL_EXTENSION_INVALID_VALUE\",\n\t\t\t\tmessage: `enum \"${block.name}\" @@type codec \"${codecId}\" represents data type \"${descriptor.dataType}\", which no component registers`,\n\t\t\t\tsourceId,\n\t\t\t\tspan: codecSpan\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\t\tif (!isMongoDataType(dataType)) throw new InternalError(`Data type ${dataType.id} is not a Mongo data type.`);\n\t\tconst { bsonTypes } = dataType.mongo;\n\t\tconst validatorRefusal = validatorEnumRefusalOf(bsonTypes);\n\t\tif (validatorRefusal !== void 0) {\n\t\t\tdiagnostics?.push({\n\t\t\t\tcode: \"PSL_EXTENSION_INVALID_VALUE\",\n\t\t\t\tmessage: `enum \"${block.name}\" @@type codec \"${codecId}\" ${validatorRefusal}`,\n\t\t\t\tsourceId,\n\t\t\t\tspan: codecSpan\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\t\tconst enumRefusal = enumRefusalOf(descriptor);\n\t\tif (enumRefusal !== void 0) {\n\t\t\tdiagnostics?.push({\n\t\t\t\tcode: \"PSL_EXTENSION_INVALID_VALUE\",\n\t\t\t\tmessage: `enum \"${block.name}\" cannot use the codec \"${codecId}\". ${enumRefusal}`,\n\t\t\t\tsourceId,\n\t\t\t\tspan: codecSpan\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\t\tconst codec = ctx.codecLookup.get(codecId);\n\t\tif (codec === void 0) {\n\t\t\tdiagnostics?.push({\n\t\t\t\tcode: \"PSL_EXTENSION_INVALID_VALUE\",\n\t\t\t\tmessage: `enum \"${block.name}\" @@type codec \"${codecId}\" is registered but codecLookup.get has no codec for it`,\n\t\t\t\tsourceId,\n\t\t\t\tspan: codecSpan\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\t\tconst members = readEnumBlockMembers(block, codecId, codec, ctx);\n\t\tif (members === void 0) return void 0;\n\t\tlet unlistedMember = false;\n\t\tfor (const member of members) {\n\t\t\tconst refusal = validatorEnumMemberRefusalOf(bsonTypes, codec.dataType.toContract(codec.toDataTypeValue(member.value)));\n\t\t\tif (refusal === void 0) continue;\n\t\t\tdiagnostics?.push({\n\t\t\t\tcode: \"PSL_EXTENSION_INVALID_VALUE\",\n\t\t\t\tmessage: `enum \"${block.name}\" member \"${member.name}\" ${refusal}`,\n\t\t\t\tsourceId,\n\t\t\t\tspan: block.parameterSpans[member.name] ?? block.span\n\t\t\t});\n\t\t\tunlistedMember = true;\n\t\t}\n\t\tif (unlistedMember) return void 0;\n\t\treturn enumType(block.name, { codecId }, ...members);\n\t} }\n} };\nconst enumTypeBlockAttribute = blockAttribute(\"type\", {\n\tdocumentation: \"Selects the storage codec for this enum.\",\n\tpositional: [{\n\t\tkey: \"codecId\",\n\t\ttype: str(),\n\t\tdocumentation: \"The fully qualified codec identifier used to store enum values.\"\n\t}]\n});\nconst mongoFamilyPslBlockDescriptors = { enum: {\n\tkind: \"pslBlock\",\n\tkeyword: \"enum\",\n\tdocumentation: \"Defines an enum with named values and an inferred or explicitly selected storage codec.\",\n\tdiscriminator: \"enum\",\n\tname: { required: true },\n\tspec: mongoFamilyEnumSpec,\n\tattributes: { type: () => enumTypeBlockAttribute }\n} };\n//#endregion\nexport { mongoFamilyPslBlockDescriptors as n, mongoFamilyEntityTypes as t };\n\n//# sourceMappingURL=authoring-entity-types-C4WFd_RV.mjs.map"],"mappings":";;;;;;;;;;;;;;;AAgBA,SAAS,sBAAsB;CAC9B,OAAO,SAAS;EACf,OAAO;GACN,MAAM,UAAU;GAChB,eAAe;EAChB;EACA,WAAW;CACZ,CAAC;AACF;AACA,MAAM,yBAAyB,EAAE,MAAM;CACtC,MAAM;CACN,eAAe;CACf,QAAQ,EAAE,UAAU,OAAO,QAAQ;EAClC,MAAM,WAAW,IAAI,YAAY;EACjC,MAAM,cAAc,IAAI;EACxB,MAAM,WAAW,mBAAmB,OAAO,GAAG;EAC9C,IAAI,aAAa,KAAK,GAAG;EACzB,MAAM,EAAE,SAAS,cAAc;EAC/B,MAAM,aAAa,IAAI,YAAY,cAAc,OAAO;EACxD,IAAI,eAAe,KAAK,GAAG;GAC1B,aAAa,KAAK;IACjB,MAAM;IACN,SAAS,SAAS,MAAM,KAAK,qCAAqC,QAAQ;IAC1E;IACA,MAAM;GACP,CAAC;GACD;EACD;EACA,MAAM,WAAW,IAAI,eAAe,IAAI,WAAW,QAAQ;EAC3D,IAAI,aAAa,KAAK,GAAG;GACxB,aAAa,KAAK;IACjB,MAAM;IACN,SAAS,SAAS,MAAM,KAAK,kBAAkB,QAAQ,0BAA0B,WAAW,SAAS;IACrG;IACA,MAAM;GACP,CAAC;GACD;EACD;EACA,IAAI,CAAC,gBAAgB,QAAQ,GAAG,MAAM,IAAI,cAAc,aAAa,SAAS,GAAG,2BAA2B;EAC5G,MAAM,EAAE,cAAc,SAAS;EAC/B,MAAM,mBAAmB,uBAAuB,SAAS;EACzD,IAAI,qBAAqB,KAAK,GAAG;GAChC,a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AE,UAAU,KAAK;CACvB,MAAM;CACN,YAAY,EAAE,YAAY,uBAAuB;AAClD,EAAE"}
|
package/dist/codec.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as mongoCodec, i as MongoCodecTrait, n as MongoCodecInput, o as newMongoCodecRegistry, r as MongoCodecRegistry, t as MongoCodec } from "./index-
|
|
1
|
+
import { a as mongoCodec, i as MongoCodecTrait, n as MongoCodecInput, o as newMongoCodecRegistry, r as MongoCodecRegistry, t as MongoCodec } from "./index-CQG5l2o9.mjs";
|
|
2
2
|
export { type MongoCodec, type MongoCodecInput, type MongoCodecRegistry, type MongoCodecTrait, mongoCodec, newMongoCodecRegistry };
|
package/dist/codec.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as newMongoCodecRegistry, t as mongoCodec } from "./dist-
|
|
1
|
+
import { n as newMongoCodecRegistry, t as mongoCodec } from "./dist-Bgk36iLI.mjs";
|
|
2
2
|
export { mongoCodec, newMongoCodecRegistry };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { t as mongoContractCanonicalizationHooks } from "./canonicalization-hooks-CRVM-Kqh-Qi-VmEVg.mjs";
|
|
2
2
|
import { i as MongoCollectionOptions, o as MongoIndex } from "./entity-kinds-RooUvcN8-B1AF_ppw.mjs";
|
|
3
|
-
import { c as buildMongoNamespace, m as mongoValueSetsOf, o as applyPolymorphicScopeToMongoIndex, r as MongoStorage } from "./dist-
|
|
3
|
+
import { c as buildMongoNamespace, m as mongoValueSetsOf, o as applyPolymorphicScopeToMongoIndex, r as MongoStorage } from "./dist-K-Zzlzm5.mjs";
|
|
4
4
|
import { t as contractError } from "./contract-errors-BCN6RVI5-kMurtAbI.mjs";
|
|
5
|
+
import { assembleDataTypes } from "@prisma/orm-framework/components/codec";
|
|
6
|
+
import { blindCast } from "@prisma/orm-framework/utils/casts";
|
|
5
7
|
import { UNBOUND_NAMESPACE_ID } from "@prisma/orm-framework/components/ir";
|
|
6
8
|
import { crossRef } from "@prisma/orm-framework/contract/types";
|
|
7
|
-
import { assembleDataTypes } from "@prisma/orm-framework/components/codec";
|
|
8
9
|
import { buildExecutionSection, computeProfileHash, computeStorageHash } from "@prisma/orm-framework/contract/hashing";
|
|
9
|
-
import { blindCast } from "@prisma/orm-framework/utils/casts";
|
|
10
10
|
import { bindEnumType, composePackAuthoringNamespace, createEntityHelpersFromNamespace, createFieldHelpersFromNamespace, encodeEnumTypeMembers, enumType as enumType$1, isEnumTypeHandle, member, resolveToOneRelationNullable } from "@prisma/orm-framework/contract-authoring";
|
|
11
11
|
import { assertNoCrossRegistryCollisions, instantiateAuthoringFieldPreset, validateAuthoringHelperArguments } from "@prisma/orm-framework/components/authoring";
|
|
12
12
|
import { ifDefined } from "@prisma/orm-framework/utils/defined";
|
|
@@ -764,4 +764,4 @@ function defineContract(definition, factory) {
|
|
|
764
764
|
//#endregion
|
|
765
765
|
export { field as a, member as c, valueObject as d, enumType$1 as i, model as l, buildBoundContract as n, index as o, defineContract as r, isEnumTypeHandle as s, bindEnumType as t, rel as u };
|
|
766
766
|
|
|
767
|
-
//# sourceMappingURL=contract-builder-
|
|
767
|
+
//# sourceMappingURL=contract-builder-DYeV4YqF.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract-builder-C_-FfTnK.mjs","names":[],"sources":["../../../../2-mongo-family/2-authoring/contract-ts/dist/contract-builder.mjs"],"sourcesContent":["import { t as contractError } from \"./contract-errors-BCN6RVI5.mjs\";\nimport { buildExecutionSection, computeProfileHash, computeStorageHash } from \"@internal/contract/hashing\";\nimport { crossRef } from \"@internal/contract/types\";\nimport { bindEnumType, composePackAuthoringNamespace, createEntityHelpersFromNamespace, createFieldHelpersFromNamespace, encodeEnumTypeMembers, enumType, isEnumTypeHandle, member, resolveToOneRelationNullable } from \"@internal/contract-authoring\";\nimport { assertNoCrossRegistryCollisions, instantiateAuthoringFieldPreset, validateAuthoringHelperArguments } from \"@internal/framework-components/authoring\";\nimport { assembleDataTypes } from \"@internal/framework-components/codec\";\nimport { extractCodecLookup } from \"@internal/framework-components/control\";\nimport { UNBOUND_NAMESPACE_ID } from \"@internal/framework-components/ir\";\nimport { MongoCollectionOptions, MongoIndex, MongoStorage, applyPolymorphicScopeToMongoIndex, buildMongoNamespace, mongoValueSetsOf } from \"@internal/mongo-contract\";\nimport { mongoContractCanonicalizationHooks } from \"@internal/mongo-contract/canonicalization-hooks\";\nimport { canonicalStringify } from \"@internal/utils/canonical-stringify\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { ifDefined } from \"@internal/utils/defined\";\n//#region src/contract-builder.ts\nfunction stableStringify(value) {\n\tif (Array.isArray(value)) return `[${value.map(stableStringify).join(\",\")}]`;\n\tif (value && typeof value === \"object\") return `{${Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([key, entry]) => `${JSON.stringify(key)}:${stableStringify(entry)}`).join(\",\")}}`;\n\treturn JSON.stringify(value);\n}\nconst MONGO_RESERVED_HELPER_KEYS = [\n\t\"field\",\n\t\"index\",\n\t\"model\",\n\t\"rel\",\n\t\"valueObject\"\n];\nfunction buildFieldPreset(helperPath, descriptor, args) {\n\tvalidateAuthoringHelperArguments(helperPath, descriptor.args, args);\n\tconst preset = instantiateAuthoringFieldPreset(descriptor, args);\n\tconst unsupported = [\n\t\t...preset.default !== void 0 ? [\"default\"] : [],\n\t\t...preset.id ? [\"id\"] : [],\n\t\t...preset.unique ? [\"unique\"] : []\n\t];\n\tif (unsupported.length > 0) throw contractError(\"CONTRACT.PACK_CONTRIBUTION_INVALID\", `Field preset \"${helperPath}\" contributes ${unsupported.join(\", \")}, which Mongo does not support. Mongo supports presets that set a codec and execution defaults only.`, { meta: {\n\t\thelperPath,\n\t\treason: \"preset-contribution-unsupported\",\n\t\tcontribution: unsupported\n\t} });\n\treturn createFieldBuilder({\n\t\ttype: {\n\t\t\tkind: \"scalar\",\n\t\t\tcodecId: preset.descriptor.codecId,\n\t\t\t...normalizeOptionalTypeParams(preset.descriptor.typeParams)\n\t\t},\n\t\tnullable: preset.nullable,\n\t\tmany: false\n\t}, void 0, preset.executionDefaults);\n}\nfunction composeMongoFieldHelpers(fieldNamespace) {\n\tconst presetHelpers = createFieldHelpersFromNamespace(fieldNamespace, ({ helperPath, descriptor }) => (...args) => buildFieldPreset(helperPath, descriptor, args));\n\tconst collisions = Object.keys(presetHelpers).filter((name) => Object.hasOwn(field, name));\n\tif (collisions.length > 0) throw contractError(\"CONTRACT.PACK_CONTRIBUTION_INVALID\", `Pack-contributed field preset(s) ${collisions.map((c) => `\"${c}\"`).join(\", \")} collide with the built-in Mongo field helper(s) of the same name.`, { meta: {\n\t\treason: \"core-field-helper-collision\",\n\t\tcontribution: collisions\n\t} });\n\treturn {\n\t\t...field,\n\t\t...presetHelpers\n\t};\n}\nfunction composeMongoAuthoringHelpers(family, target, extensions) {\n\tconst components = [\n\t\tfamily,\n\t\ttarget,\n\t\t...Object.values(extensions ?? {})\n\t];\n\tconst entityNamespace = composePackAuthoringNamespace(components, \"entityTypes\");\n\tconst fieldNamespace = composePackAuthoringNamespace(components, \"field\");\n\tassertNoCrossRegistryCollisions({}, fieldNamespace, entityNamespace);\n\tconst collisions = Object.keys(entityNamespace).filter((name) => MONGO_RESERVED_HELPER_KEYS.includes(name));\n\tif (collisions.length > 0) throw contractError(\"CONTRACT.PACK_CONTRIBUTION_INVALID\", `Pack-contributed entity type(s) ${collisions.map((c) => `\"${c}\"`).join(\", \")} collide with the reserved built-in helper key(s) on the Mongo composed helpers surface. Reserved keys: ${MONGO_RESERVED_HELPER_KEYS.map((k) => `\"${k}\"`).join(\", \")}.`, { meta: {\n\t\treason: \"reserved-helper-key-collision\",\n\t\tcontribution: collisions\n\t} });\n\treturn blindCast({\n\t\t...createEntityHelpersFromNamespace(entityNamespace, { ctx: {\n\t\t\tfamily: family.familyId,\n\t\t\ttarget: target.targetId,\n\t\t\tcodecLookup: extractCodecLookup(components),\n\t\t\tdataTypeLookup: assembleDataTypes(components).lookup\n\t\t} }),\n\t\tfield: composeMongoFieldHelpers(fieldNamespace),\n\t\tindex,\n\t\tmodel,\n\t\trel,\n\t\tvalueObject\n\t});\n}\nfunction createFieldBuilder(spec, enumHandle, executionDefaults) {\n\tfunction many(options) {\n\t\treturn createFieldBuilder({\n\t\t\ttype: spec.type,\n\t\t\tnullable: spec.nullable,\n\t\t\tmany: { elementNullable: options?.elementsNullable ?? false }\n\t\t}, enumHandle, executionDefaults);\n\t}\n\treturn {\n\t\t__kind: \"field\",\n\t\t...ifDefined(\"__executionDefaults\", executionDefaults),\n\t\t__type: spec.type,\n\t\t__nullable: spec.nullable,\n\t\t__many: spec.many,\n\t\t__enumHandle: blindCast(enumHandle),\n\t\toptional: blindCast(() => createFieldBuilder({\n\t\t\ttype: spec.type,\n\t\t\tnullable: true,\n\t\t\tmany: spec.many\n\t\t}, enumHandle, executionDefaults)),\n\t\tmany: blindCast(many)\n\t};\n}\nfunction normalizeOptionalTypeParams(typeParams) {\n\tif (!typeParams) return {};\n\treturn { typeParams };\n}\nfunction createScalarFieldBuilder(codecId, options) {\n\treturn createFieldBuilder({\n\t\ttype: blindCast({\n\t\t\tkind: \"scalar\",\n\t\t\tcodecId,\n\t\t\t...normalizeOptionalTypeParams(options?.typeParams)\n\t\t}),\n\t\tnullable: false,\n\t\tmany: false\n\t});\n}\nconst field = {\n\tscalar: createScalarFieldBuilder,\n\tobjectId() {\n\t\treturn createScalarFieldBuilder(\"mongo/objectId@1\");\n\t},\n\tstring() {\n\t\treturn createScalarFieldBuilder(\"mongo/string@1\");\n\t},\n\tdouble() {\n\t\treturn createScalarFieldBuilder(\"mongo/double@1\");\n\t},\n\tint32() {\n\t\treturn createScalarFieldBuilder(\"mongo/int32@1\");\n\t},\n\tbool() {\n\t\treturn createScalarFieldBuilder(\"mongo/bool@1\");\n\t},\n\tdate() {\n\t\treturn createScalarFieldBuilder(\"mongo/date@1\");\n\t},\n\tint64() {\n\t\treturn createScalarFieldBuilder(\"mongo/int64@1\");\n\t},\n\tint64Number() {\n\t\treturn createScalarFieldBuilder(\"mongo/int64Number@1\");\n\t},\n\tdecimal128() {\n\t\treturn createScalarFieldBuilder(\"mongo/decimal128@1\");\n\t},\n\tbinary() {\n\t\treturn createScalarFieldBuilder(\"mongo/binary@1\");\n\t},\n\tjson() {\n\t\treturn createScalarFieldBuilder(\"mongo/json@1\");\n\t},\n\tbson() {\n\t\treturn createScalarFieldBuilder(\"mongo/bson@1\");\n\t},\n\tvector(options) {\n\t\treturn createScalarFieldBuilder(\"mongo/vector@1\", options);\n\t},\n\tvalueObject(valueObjectName) {\n\t\treturn createFieldBuilder({\n\t\t\ttype: blindCast({\n\t\t\t\tkind: \"valueObject\",\n\t\t\t\tname: resolveValueObjectName(valueObjectName)\n\t\t\t}),\n\t\t\tnullable: false,\n\t\t\tmany: false\n\t\t});\n\t},\n\tnamedType(handle) {\n\t\treturn createFieldBuilder({\n\t\t\ttype: blindCast({\n\t\t\t\tkind: \"scalar\",\n\t\t\t\tcodecId: handle.codecId\n\t\t\t}),\n\t\t\tnullable: false,\n\t\t\tmany: false\n\t\t}, handle);\n\t}\n};\nfunction index(fields, options) {\n\treturn {\n\t\tfields,\n\t\t...options ? { options } : {}\n\t};\n}\nfunction createFieldReference(modelName, fieldName) {\n\treturn {\n\t\t__kind: \"fieldRef\",\n\t\tmodelName,\n\t\tfieldName\n\t};\n}\nfunction isFieldReference(value) {\n\treturn typeof value === \"object\" && value !== null && \"__kind\" in value && value.__kind === \"fieldRef\";\n}\nfunction resolveModelName(value) {\n\treturn typeof value === \"string\" ? value : value.__name;\n}\nfunction resolveValueObjectName(value) {\n\treturn typeof value === \"string\" ? value : value.__name;\n}\nfunction normalizeStringList(value) {\n\treturn typeof value === \"string\" ? [value] : [...value];\n}\nfunction normalizeTargetField(targetModelName, value) {\n\tif (!isFieldReference(value)) return value;\n\tif (value.modelName !== targetModelName) throw contractError(\"CONTRACT.RELATION_INVALID\", `Relation target \"${targetModelName}\" cannot reference field \"${value.modelName}.${value.fieldName}\".`, { meta: {\n\t\tmodelName: targetModelName,\n\t\treason: \"cross-model-field-reference\",\n\t\treferencedModel: value.modelName,\n\t\treferencedField: value.fieldName\n\t} });\n\treturn value.fieldName;\n}\nfunction normalizeTargetFields(targetModelName, value) {\n\tif (typeof value === \"string\") return [value];\n\tif (isFieldReference(value)) return [normalizeTargetField(targetModelName, value)];\n\treturn value.map((entry) => normalizeTargetField(targetModelName, entry));\n}\nfunction createRelationBuilder(spec) {\n\treturn {\n\t\t__kind: \"relation\",\n\t\t__to: spec.to,\n\t\t__cardinality: spec.cardinality,\n\t\t__on: spec.on,\n\t\t__nullable: spec.nullable\n\t};\n}\nfunction createReferenceRelationBuilder(target, cardinality, options, nullable) {\n\tconst targetModelName = resolveModelName(target);\n\treturn createRelationBuilder({\n\t\tto: blindCast(targetModelName),\n\t\tcardinality,\n\t\ton: {\n\t\t\tlocalFields: blindCast(normalizeStringList(options.from)),\n\t\t\ttargetFields: blindCast(normalizeTargetFields(targetModelName, options.to))\n\t\t},\n\t\tnullable\n\t});\n}\nfunction createEmbedRelationBuilder(target, cardinality) {\n\treturn createRelationBuilder({\n\t\tto: blindCast(resolveModelName(target)),\n\t\tcardinality,\n\t\ton: void 0,\n\t\tnullable: void 0\n\t});\n}\nfunction hasOne(target, options) {\n\tif (!options) return createEmbedRelationBuilder(target, \"1:1\");\n\treturn createReferenceRelationBuilder(target, \"1:1\", options, true);\n}\nfunction hasMany(target, options) {\n\tif (!options) return createEmbedRelationBuilder(target, \"1:N\");\n\treturn createReferenceRelationBuilder(target, \"1:N\", options, void 0);\n}\nfunction belongsTo(target, options) {\n\treturn createReferenceRelationBuilder(target, \"N:1\", options, options.optional);\n}\nconst rel = {\n\tbelongsTo,\n\thasMany,\n\thasOne\n};\nfunction valueObject(name, input) {\n\treturn {\n\t\t__kind: \"valueObject\",\n\t\t__name: name,\n\t\t__fields: input.fields\n\t};\n}\nfunction model(name, input) {\n\treturn {\n\t\t__kind: \"model\",\n\t\t__name: name,\n\t\t__fields: input.fields,\n\t\t__relations: blindCast(input.relations ?? {}),\n\t\t__indexes: input.indexes,\n\t\t__collectionOptions: input.collectionOptions,\n\t\t__controlPolicy: input.controlPolicy,\n\t\t__collection: blindCast(input.collection),\n\t\t__owner: blindCast(input.owner ? resolveModelName(input.owner) : void 0),\n\t\t__base: blindCast(input.base ? resolveModelName(input.base) : void 0),\n\t\t__storageRelations: blindCast(input.storageRelations),\n\t\t__discriminator: blindCast(input.discriminator ? { field: input.discriminator.field } : void 0),\n\t\t__variants: blindCast(input.discriminator?.variants),\n\t\tref(fieldName) {\n\t\t\treturn createFieldReference(name, fieldName);\n\t\t}\n\t};\n}\nfunction validateTargetPackRef(family, target) {\n\tif (family.familyId !== \"mongo\") throw contractError(\"CONTRACT.PACK_FAMILY_MISMATCH\", `defineContract only accepts Mongo family packs. Received family \"${family.familyId}\".`, { meta: {\n\t\tpackId: family.id,\n\t\tpackFamilyId: family.familyId,\n\t\tcontractFamilyId: \"mongo\"\n\t} });\n\tif (target.familyId !== family.familyId) throw contractError(\"CONTRACT.PACK_FAMILY_MISMATCH\", `target pack \"${target.id}\" targets family \"${target.familyId}\" but contract family is \"${family.familyId}\".`, { meta: {\n\t\tpackId: target.id,\n\t\tpackFamilyId: target.familyId,\n\t\tcontractFamilyId: family.familyId\n\t} });\n}\nfunction validateExtensionPackRefs(target, extensions) {\n\tif (!extensions) return;\n\tfor (const packRef of Object.values(extensions)) {\n\t\tif (packRef.kind !== \"extension\") throw contractError(\"CONTRACT.PACK_REF_INVALID\", `defineContract only accepts extension pack refs in extensions. Received kind \"${packRef.kind}\".`, { meta: {\n\t\t\tpackId: packRef.id,\n\t\t\tkind: packRef.kind\n\t\t} });\n\t\tif (packRef.familyId !== target.familyId) throw contractError(\"CONTRACT.PACK_FAMILY_MISMATCH\", `extension pack \"${packRef.id}\" targets family \"${packRef.familyId}\" but contract target family is \"${target.familyId}\".`, { meta: {\n\t\t\tpackId: packRef.id,\n\t\t\tpackFamilyId: packRef.familyId,\n\t\t\tcontractFamilyId: target.familyId\n\t\t} });\n\t\tif (packRef.targetId && packRef.targetId !== target.targetId) throw contractError(\"CONTRACT.PACK_TARGET_MISMATCH\", `extension pack \"${packRef.id}\" targets \"${packRef.targetId}\" but contract target is \"${target.targetId}\".`, { meta: {\n\t\t\tpackId: packRef.id,\n\t\t\tpackTargetId: packRef.targetId,\n\t\t\tcontractTargetId: target.targetId\n\t\t} });\n\t}\n}\nfunction isContractScaffold(value) {\n\tif (typeof value !== \"object\" || value === null) return false;\n\treturn \"family\" in value && \"target\" in value;\n}\nfunction buildContractField(builder) {\n\tconst valueSet = builder.__enumHandle ? {\n\t\tplane: \"domain\",\n\t\tentityKind: \"enum\",\n\t\tnamespaceId: UNBOUND_NAMESPACE_ID,\n\t\tentityName: builder.__enumHandle.enumName\n\t} : void 0;\n\treturn {\n\t\ttype: builder.__type,\n\t\tnullable: builder.__nullable,\n\t\tmany: builder.__many,\n\t\t...ifDefined(\"valueSet\", valueSet)\n\t};\n}\nfunction buildFields(fields) {\n\tconst builtFields = {};\n\tfor (const [fieldName, fieldBuilder] of Object.entries(fields)) builtFields[fieldName] = buildContractField(fieldBuilder);\n\treturn builtFields;\n}\nfunction toOneRelationNullable(modelName, relationName, relationBuilder, on, fields) {\n\tconst location = `Relation \"${modelName}.${relationName}\"`;\n\tconst ownsForeignKey = relationBuilder.__cardinality !== \"1:1\";\n\tconst localFields = ownsForeignKey ? on.localFields.map((fieldName) => {\n\t\tconst localField = fields[fieldName];\n\t\tif (localField === void 0) throw contractError(\"CONTRACT.RELATION_INVALID\", `${location} joins on local field \"${fieldName}\", which model \"${modelName}\" does not declare`, { meta: {\n\t\t\tmodelName,\n\t\t\trelationName,\n\t\t\tfieldName,\n\t\t\treason: \"local-field-unknown\"\n\t\t} });\n\t\treturn localField;\n\t}) : [];\n\tconst { nullable, contradiction } = resolveToOneRelationNullable({\n\t\tdeclaredNullable: relationBuilder.__nullable,\n\t\tlocalFieldNullability: localFields.map((localField) => localField.__nullable === true),\n\t\townsReference: ownsForeignKey\n\t});\n\tif (contradiction !== void 0) throw contractError(\"CONTRACT.RELATION_INVALID\", !ownsForeignKey ? `${location} is required but does not own the foreign key, so nothing in storage guarantees the related document exists` : contradiction === \"declared-optional\" ? `${location} is optional but every local field it joins on is required` : `${location} is required but a local field it joins on is nullable`, { meta: {\n\t\tmodelName,\n\t\trelationName,\n\t\treason: \"to-one-nullability-mismatch\"\n\t} });\n\treturn nullable;\n}\nfunction buildRelation(modelName, relationName, relationBuilder, fields) {\n\tconst to = crossRef(relationBuilder.__to, UNBOUND_NAMESPACE_ID);\n\tconst on = relationBuilder.__on;\n\tif (on === void 0) return {\n\t\tto,\n\t\tcardinality: relationBuilder.__cardinality\n\t};\n\tif (relationBuilder.__cardinality === \"1:N\") return {\n\t\tto,\n\t\tcardinality: \"1:N\",\n\t\ton\n\t};\n\treturn {\n\t\tto,\n\t\tcardinality: relationBuilder.__cardinality,\n\t\tnullable: toOneRelationNullable(modelName, relationName, relationBuilder, on, fields),\n\t\ton\n\t};\n}\nfunction buildRelations(modelName, relations, fields) {\n\tconst builtRelations = {};\n\tfor (const [relationName, relationBuilder] of Object.entries(relations)) builtRelations[relationName] = buildRelation(modelName, relationName, relationBuilder, fields);\n\treturn builtRelations;\n}\nfunction buildValueObjects(valueObjects) {\n\tconst builtValueObjects = {};\n\tfor (const valueObjectBuilder of Object.values(valueObjects ?? {})) {\n\t\tif (valueObjectBuilder.__name in builtValueObjects) throw contractError(\"CONTRACT.NAME_DUPLICATE\", `Duplicate value object name \"${valueObjectBuilder.__name}\" in defineContract().`, { meta: {\n\t\t\tkind: \"valueObject\",\n\t\t\tname: valueObjectBuilder.__name\n\t\t} });\n\t\tbuiltValueObjects[valueObjectBuilder.__name] = { fields: buildFields(valueObjectBuilder.__fields) };\n\t}\n\treturn builtValueObjects;\n}\nfunction buildModels(models) {\n\tconst builtModels = {};\n\tfor (const modelBuilder of Object.values(models ?? {})) {\n\t\tif (modelBuilder.__name in builtModels) throw contractError(\"CONTRACT.NAME_DUPLICATE\", `Duplicate model name \"${modelBuilder.__name}\" in defineContract().`, { meta: {\n\t\t\tkind: \"model\",\n\t\t\tname: modelBuilder.__name\n\t\t} });\n\t\tassertUniqueDiscriminatorValues(modelBuilder);\n\t\tconst storage = {\n\t\t\t...modelBuilder.__collection ? { collection: modelBuilder.__collection } : {},\n\t\t\t...modelBuilder.__storageRelations ? { relations: modelBuilder.__storageRelations } : {}\n\t\t};\n\t\tbuiltModels[modelBuilder.__name] = {\n\t\t\tfields: buildFields(modelBuilder.__fields),\n\t\t\trelations: buildRelations(modelBuilder.__name, modelBuilder.__relations, modelBuilder.__fields),\n\t\t\tstorage,\n\t\t\t...modelBuilder.__owner ? { owner: modelBuilder.__owner } : {},\n\t\t\t...modelBuilder.__base ? { base: crossRef(modelBuilder.__base, UNBOUND_NAMESPACE_ID) } : {},\n\t\t\t...modelBuilder.__discriminator ? { discriminator: modelBuilder.__discriminator } : {},\n\t\t\t...modelBuilder.__variants ? { variants: Object.fromEntries(Object.entries(modelBuilder.__variants).map(([variantName, { value }]) => [value, crossRef(variantName, UNBOUND_NAMESPACE_ID)])) } : {}\n\t\t};\n\t}\n\treturn builtModels;\n}\nfunction assertUniqueDiscriminatorValues(modelBuilder) {\n\tconst variantNamesByValue = /* @__PURE__ */ new Map();\n\tfor (const [variantName, { value }] of Object.entries(modelBuilder.__variants ?? {})) {\n\t\tconst existingVariant = variantNamesByValue.get(value);\n\t\tif (existingVariant !== void 0) throw contractError(\"CONTRACT.ARGUMENT_INVALID\", `Discriminator value \"${value}\" is used by both \"${existingVariant}\" and \"${variantName}\" on base model \"${modelBuilder.__name}\".`, { meta: {\n\t\t\tmodelName: modelBuilder.__name,\n\t\t\tvalue,\n\t\t\tvariants: [existingVariant, variantName],\n\t\t\treason: \"duplicate-discriminator-value\"\n\t\t} });\n\t\tvariantNamesByValue.set(value, variantName);\n\t}\n}\nfunction deriveRoots(models) {\n\tconst roots = {};\n\tfor (const modelBuilder of Object.values(models ?? {})) {\n\t\tif (!modelBuilder.__collection || modelBuilder.__owner || modelBuilder.__base) continue;\n\t\troots[modelBuilder.__collection] = crossRef(modelBuilder.__name, UNBOUND_NAMESPACE_ID);\n\t}\n\treturn roots;\n}\nfunction normalizeRoots(roots) {\n\tconst normalizedRoots = {};\n\tfor (const [rootName, rootValue] of Object.entries(roots ?? {})) normalizedRoots[rootName] = crossRef(resolveModelName(rootValue), UNBOUND_NAMESPACE_ID);\n\treturn normalizedRoots;\n}\nfunction toStorageIndex(index) {\n\tconst input = { keys: Object.entries(index.fields).map(([field, direction]) => ({\n\t\tfield,\n\t\tdirection\n\t})) };\n\tif (index.options) {\n\t\tfor (const [key, value] of Object.entries(index.options)) if (value !== void 0) input[key] = value;\n\t}\n\treturn new MongoIndex(blindCast(input));\n}\nfunction toStorageCollectionOptions(opts) {\n\treturn new MongoCollectionOptions({\n\t\t...opts.capped ? { capped: {\n\t\t\tsize: opts.size ?? 0,\n\t\t\t...opts.max != null && { max: opts.max }\n\t\t} } : {},\n\t\t...ifDefined(\"storageEngine\", opts.storageEngine),\n\t\t...ifDefined(\"indexOptionDefaults\", opts.indexOptionDefaults),\n\t\t...ifDefined(\"collation\", opts.collation),\n\t\t...ifDefined(\"timeseries\", opts.timeseries),\n\t\t...opts.clusteredIndex !== void 0 && { clusteredIndex: opts.clusteredIndex.name !== void 0 ? { name: opts.clusteredIndex.name } : {} },\n\t\t...ifDefined(\"expireAfterSeconds\", opts.expireAfterSeconds),\n\t\t...ifDefined(\"changeStreamPreAndPostImages\", opts.changeStreamPreAndPostImages)\n\t});\n}\nfunction findMissingIndexField(index, modelFields) {\n\tfor (const fieldName of Object.keys(index.fields)) {\n\t\tconst wildcardMatch = fieldName.match(/^(.+)\\.\\$\\*\\*$/);\n\t\tconst lookupName = wildcardMatch ? wildcardMatch[1] : fieldName;\n\t\tif (lookupName === void 0 || lookupName.length === 0) continue;\n\t\tif (lookupName === \"$**\") continue;\n\t\tif (!Object.hasOwn(modelFields, lookupName)) return lookupName;\n\t}\n}\nfunction resolveVariantScope(modelBuilder, modelsByName) {\n\tif (!modelBuilder.__base) return void 0;\n\tconst baseBuilder = modelsByName[modelBuilder.__base];\n\tif (!baseBuilder) return void 0;\n\tconst discriminatorField = baseBuilder.__discriminator?.field;\n\tconst variantValue = baseBuilder.__variants?.[modelBuilder.__name]?.value;\n\tif (!discriminatorField || variantValue === void 0) return void 0;\n\treturn {\n\t\tdiscriminatorField,\n\t\tdiscriminatorValue: variantValue\n\t};\n}\nfunction scopeVariantIndex(storageIndex, scope, variantName, authoredIndex) {\n\tconst result = applyPolymorphicScopeToMongoIndex(storageIndex, scope);\n\tif (result.kind === \"conflict\") {\n\t\tconst indexLabel = authoredIndex ? canonicalStringify(authoredIndex) : \"<unknown>\";\n\t\tthrow contractError(\"CONTRACT.INDEX_INVALID\", `Variant model \"${variantName}\" index ${indexLabel} conflicts with discriminator scope: ${result.reason}`, { meta: {\n\t\t\tvariantName,\n\t\t\tindexLabel,\n\t\t\treason: result.reason\n\t\t} });\n\t}\n\treturn result.index;\n}\nfunction buildCollections(models) {\n\tconst intermediate = {};\n\tconst declaredIndexOwners = /* @__PURE__ */ new Map();\n\tconst modelMap = models ?? {};\n\tconst modelsByName = {};\n\tfor (const builder of Object.values(modelMap)) modelsByName[builder.__name] = builder;\n\tfor (const modelBuilder of Object.values(modelMap)) {\n\t\tif (!modelBuilder.__collection) {\n\t\t\tif (modelBuilder.__indexes && modelBuilder.__indexes.length > 0) throw contractError(\"CONTRACT.COLLECTION_INVALID\", `Model \"${modelBuilder.__name}\" defines indexes but has no collection to attach them to.`, { meta: {\n\t\t\t\tmodelName: modelBuilder.__name,\n\t\t\t\treason: \"indexes-without-collection\"\n\t\t\t} });\n\t\t\tif (modelBuilder.__collectionOptions) throw contractError(\"CONTRACT.COLLECTION_INVALID\", `Model \"${modelBuilder.__name}\" defines collectionOptions but has no collection to attach them to.`, { meta: {\n\t\t\t\tmodelName: modelBuilder.__name,\n\t\t\t\treason: \"collectionOptions-without-collection\"\n\t\t\t} });\n\t\t\tif (modelBuilder.__controlPolicy) throw contractError(\"CONTRACT.COLLECTION_INVALID\", `Model \"${modelBuilder.__name}\" defines controlPolicy but has no collection to attach it to.`, { meta: {\n\t\t\t\tmodelName: modelBuilder.__name,\n\t\t\t\treason: \"controlPolicy-without-collection\"\n\t\t\t} });\n\t\t\tcontinue;\n\t\t}\n\t\tconst existingCollection = intermediate[modelBuilder.__collection] ?? {};\n\t\tconst existingIndexes = existingCollection.indexes ?? [];\n\t\tif (existingCollection.options && modelBuilder.__collectionOptions) throw contractError(\"CONTRACT.COLLECTION_INVALID\", `Collection \"${modelBuilder.__collection}\" has collectionOptions declared by multiple models. Author collectionOptions on a single model per collection.`, { meta: {\n\t\t\tmodelName: modelBuilder.__name,\n\t\t\tcollection: modelBuilder.__collection,\n\t\t\treason: \"collectionOptions-declared-by-multiple-models\"\n\t\t} });\n\t\tif (existingCollection.control !== void 0 && modelBuilder.__controlPolicy) throw contractError(\"CONTRACT.COLLECTION_INVALID\", `Collection \"${modelBuilder.__collection}\" has controlPolicy declared by multiple models. Author controlPolicy on a single model per collection.`, { meta: {\n\t\t\tmodelName: modelBuilder.__name,\n\t\t\tcollection: modelBuilder.__collection,\n\t\t\treason: \"controlPolicy-declared-by-multiple-models\"\n\t\t} });\n\t\tfor (const collectionIndex of modelBuilder.__indexes ?? []) {\n\t\t\tconst missingField = findMissingIndexField(collectionIndex, modelBuilder.__fields);\n\t\t\tif (missingField !== void 0) {\n\t\t\t\tconst indexSignature = canonicalStringify(collectionIndex);\n\t\t\t\tthrow contractError(\"CONTRACT.FIELD_UNKNOWN\", `Model \"${modelBuilder.__name}\" index ${indexSignature} references unknown field \"${missingField}\".`, { meta: {\n\t\t\t\t\tmodelName: modelBuilder.__name,\n\t\t\t\t\tfieldName: missingField,\n\t\t\t\t\tindexSignature\n\t\t\t\t} });\n\t\t\t}\n\t\t}\n\t\tconst polymorphicScope = resolveVariantScope(modelBuilder, modelsByName);\n\t\tconst rawStorageIndexes = (modelBuilder.__indexes ?? []).map(toStorageIndex);\n\t\tconst storageIndexes = polymorphicScope ? rawStorageIndexes.map((idx, i) => scopeVariantIndex(idx, polymorphicScope, modelBuilder.__name, modelBuilder.__indexes?.[i])) : rawStorageIndexes;\n\t\tfor (let i = 0; i < storageIndexes.length; i++) {\n\t\t\tconst storageIndex = storageIndexes[i];\n\t\t\tif (storageIndex === void 0) continue;\n\t\t\tconst indexSignature = stableStringify(storageIndex);\n\t\t\tconst collectionIndexKey = `${modelBuilder.__collection}:${indexSignature}`;\n\t\t\tconst firstOwner = declaredIndexOwners.get(collectionIndexKey);\n\t\t\tif (firstOwner) {\n\t\t\t\tconst authoredIndex = modelBuilder.__indexes?.[i];\n\t\t\t\tconst reportedSignature = authoredIndex ? canonicalStringify(authoredIndex) : indexSignature;\n\t\t\t\tthrow contractError(\"CONTRACT.NAME_DUPLICATE\", `Collection \"${modelBuilder.__collection}\" defines duplicate index ${reportedSignature}. First declared on model \"${firstOwner}\" and duplicated on model \"${modelBuilder.__name}\".`, { meta: {\n\t\t\t\t\tkind: \"index\",\n\t\t\t\t\tname: reportedSignature,\n\t\t\t\t\tcollection: modelBuilder.__collection,\n\t\t\t\t\tfirst: firstOwner,\n\t\t\t\t\tsecond: modelBuilder.__name\n\t\t\t\t} });\n\t\t\t}\n\t\t\tdeclaredIndexOwners.set(collectionIndexKey, modelBuilder.__name);\n\t\t}\n\t\tconst storageOptions = modelBuilder.__collectionOptions ? toStorageCollectionOptions(modelBuilder.__collectionOptions) : void 0;\n\t\tconst controlPatch = modelBuilder.__controlPolicy !== void 0 ? { control: modelBuilder.__controlPolicy } : {};\n\t\tintermediate[modelBuilder.__collection] = storageIndexes.length > 0 ? {\n\t\t\t...existingCollection,\n\t\t\tindexes: [...existingIndexes, ...storageIndexes],\n\t\t\t...storageOptions ? { options: storageOptions } : {},\n\t\t\t...controlPatch\n\t\t} : storageOptions ? {\n\t\t\t...existingCollection,\n\t\t\toptions: storageOptions,\n\t\t\t...controlPatch\n\t\t} : Object.keys(controlPatch).length > 0 ? {\n\t\t\t...existingCollection,\n\t\t\t...controlPatch\n\t\t} : existingCollection;\n\t}\n\treturn intermediate;\n}\nfunction executionDefaultError(modelName, fieldName, reason, message) {\n\treturn contractError(\"CONTRACT.DEFAULT_INVALID\", `Field \"${modelName}.${fieldName}\" ${message}`, { meta: {\n\t\tmodelName,\n\t\tfieldName,\n\t\treason\n\t} });\n}\nfunction hasExecutionDefaults(fieldBuilder) {\n\tconst phases = fieldBuilder.__executionDefaults;\n\treturn phases?.onCreate !== void 0 || phases?.onUpdate !== void 0;\n}\nfunction assertNoValueObjectExecutionDefaults(valueObjects) {\n\tfor (const valueObjectBuilder of Object.values(valueObjects ?? {})) for (const [fieldName, fieldBuilder] of Object.entries(valueObjectBuilder.__fields)) if (hasExecutionDefaults(fieldBuilder)) throw executionDefaultError(valueObjectBuilder.__name, fieldName, \"executionDefaults-on-value-object\", \"has executionDefaults, but it belongs to a value object. Generated values are only supported on model fields.\");\n}\nfunction buildExecutionDefaults(models) {\n\tconst modelBuilders = Object.values(models ?? {});\n\tconst collectionByModelName = new Map(modelBuilders.map((modelBuilder) => [modelBuilder.__name, modelBuilder.__collection]));\n\tconst byRef = /* @__PURE__ */ new Map();\n\tconst defaults = [];\n\tfor (const modelBuilder of modelBuilders) for (const [fieldName, fieldBuilder] of Object.entries(modelBuilder.__fields)) {\n\t\tconst phases = fieldBuilder.__executionDefaults;\n\t\tif (!phases || !hasExecutionDefaults(fieldBuilder)) continue;\n\t\tconst modelName = modelBuilder.__name;\n\t\tif (fieldBuilder.__nullable) throw executionDefaultError(modelName, fieldName, \"nullable-with-executionDefaults\", \"is filled on write by a preset such as temporal.createdAt(), so it cannot be optional; remove .optional().\");\n\t\tif (fieldBuilder.__many) throw executionDefaultError(modelName, fieldName, \"many-with-executionDefaults\", \"is filled on write by a preset such as temporal.createdAt(), so it cannot be a list; remove .many().\");\n\t\tif (modelBuilder.__base !== void 0) {\n\t\t\tconst collection = modelBuilder.__collection ?? collectionByModelName.get(modelBuilder.__base);\n\t\t\tthrow executionDefaultError(modelName, fieldName, \"executionDefaults-on-variant\", `has executionDefaults, but \"${modelName}\" is a variant of \"${modelBuilder.__base}\". Execution defaults apply to every document in collection \"${collection}\", so declare them on the base model.`);\n\t\t}\n\t\tconst entry = modelBuilder.__collection;\n\t\tif (entry === void 0) throw executionDefaultError(modelName, fieldName, \"executionDefaults-without-collection\", \"has executionDefaults, but its model has no collection. Generated values are only supported on fields of a model stored in a collection.\");\n\t\tconst refKey = JSON.stringify([entry, fieldName]);\n\t\tconst phasesKey = canonicalStringify(phases);\n\t\tconst existing = byRef.get(refKey);\n\t\tif (existing !== void 0) {\n\t\t\tif (existing.phasesKey !== phasesKey) throw executionDefaultError(modelName, fieldName, \"executionDefaults-conflict\", `has different executionDefaults than \"${existing.modelName}.${fieldName}\", which is stored in the same collection \"${entry}\". Use the same executionDefaults on both models.`);\n\t\t\tcontinue;\n\t\t}\n\t\tbyRef.set(refKey, {\n\t\t\tmodelName,\n\t\t\tphasesKey\n\t\t});\n\t\tdefaults.push({\n\t\t\tref: {\n\t\t\t\tnamespace: UNBOUND_NAMESPACE_ID,\n\t\t\t\tentry,\n\t\t\t\tfield: fieldName\n\t\t\t},\n\t\t\t...phases\n\t\t});\n\t}\n\treturn defaults;\n}\nfunction buildContractFromDefinition(definition) {\n\tvalidateTargetPackRef(definition.family, definition.target);\n\tvalidateExtensionPackRefs(definition.target, definition.extensions);\n\tconst builtModels = buildModels(definition.models);\n\tconst builtValueObjects = buildValueObjects(definition.valueObjects);\n\tconst roots = definition.roots ? normalizeRoots(definition.roots) : deriveRoots(definition.models);\n\tconst capabilities = {};\n\tconst collections = buildCollections(definition.models);\n\tassertNoValueObjectExecutionDefaults(definition.valueObjects);\n\tconst execution = buildExecutionSection({\n\t\ttarget: definition.target.targetId,\n\t\ttargetFamily: definition.family.familyId,\n\t\tdefaults: buildExecutionDefaults(definition.models)\n\t});\n\tconst codecLookup = extractCodecLookup([definition.target]);\n\tconst builtEnums = {};\n\tfor (const [enumName, handle] of Object.entries(definition.enums ?? {})) builtEnums[enumName] = {\n\t\tcodecId: handle.codecId,\n\t\tmembers: encodeEnumTypeMembers(handle, codecLookup, \"the field\")\n\t};\n\tconst storageValueSets = mongoValueSetsOf(builtEnums);\n\tconst unboundNamespace = buildMongoNamespace({\n\t\tid: UNBOUND_NAMESPACE_ID,\n\t\tentries: {\n\t\t\tcollection: collections,\n\t\t\t...ifDefined(\"valueSet\", Object.keys(storageValueSets).length > 0 ? storageValueSets : void 0)\n\t\t}\n\t});\n\tconst storageBody = { namespaces: { [UNBOUND_NAMESPACE_ID]: {\n\t\tid: UNBOUND_NAMESPACE_ID,\n\t\tcollections: unboundNamespace.entries.collection,\n\t\t...ifDefined(\"valueSet\", unboundNamespace.entries.valueSet)\n\t} } };\n\tconst storage = new MongoStorage({\n\t\tstorageHash: computeStorageHash({\n\t\t\ttarget: definition.target.targetId,\n\t\t\ttargetFamily: definition.family.familyId,\n\t\t\tstorage: storageBody,\n\t\t\t...mongoContractCanonicalizationHooks\n\t\t}),\n\t\tnamespaces: { [UNBOUND_NAMESPACE_ID]: unboundNamespace }\n\t});\n\tfor (const [enumName, handle] of Object.entries(definition.enums ?? {})) if (enumName !== handle.enumName) throw contractError(\"CONTRACT.ENUM_INVALID\", `enum declaration key \"${enumName}\" must match enumType name \"${handle.enumName}\". Aliases are not supported.`, { meta: {\n\t\tenumName: handle.enumName,\n\t\tdeclaredKey: enumName,\n\t\treason: \"declaration-key-mismatch\"\n\t} });\n\tconst hasEnums = Object.keys(builtEnums).length > 0;\n\tfor (const [modelName, modelBuilder] of Object.entries(definition.models ?? {})) for (const [fieldName, fieldBuilder] of Object.entries(modelBuilder.__fields)) {\n\t\tconst handle = fieldBuilder.__enumHandle;\n\t\tif (handle && !(handle.enumName in builtEnums)) throw contractError(\"CONTRACT.ENUM_UNKNOWN\", `Model \"${modelName}\" field \"${fieldName}\" references enum \"${handle.enumName}\" which is not declared in defineContract({ enums: { ... } }).`, { meta: {\n\t\t\tmodelName,\n\t\t\tfieldName,\n\t\t\tenumName: handle.enumName\n\t\t} });\n\t}\n\treturn blindCast({\n\t\ttarget: definition.target.targetId,\n\t\ttargetFamily: definition.family.familyId,\n\t\t...ifDefined(\"defaultControlPolicy\", definition.defaultControlPolicy),\n\t\troots,\n\t\tdomain: { namespaces: { [UNBOUND_NAMESPACE_ID]: {\n\t\t\tmodels: builtModels,\n\t\t\t...Object.keys(builtValueObjects).length > 0 ? { valueObjects: builtValueObjects } : {},\n\t\t\t...hasEnums ? { enum: builtEnums } : {}\n\t\t} } },\n\t\tstorage,\n\t\tcapabilities,\n\t\textensions: definition.extensions ?? {},\n\t\tprofileHash: computeProfileHash({\n\t\t\ttarget: definition.target.targetId,\n\t\t\ttargetFamily: definition.family.familyId,\n\t\t\tcapabilities\n\t\t}),\n\t\tmeta: {},\n\t\t...ifDefined(\"execution\", execution)\n\t});\n}\n/** Implementation. */\nfunction buildBoundContract(family, target, definition, factory) {\n\tconst full = {\n\t\t...definition,\n\t\tfamily,\n\t\ttarget\n\t};\n\tif (factory !== void 0) {\n\t\tconst built = factory(composeMongoAuthoringHelpers(family, target, definition.extensions));\n\t\treturn buildContractFromDefinition({\n\t\t\t...full,\n\t\t\t...ifDefined(\"models\", built.models),\n\t\t\t...ifDefined(\"valueObjects\", built.valueObjects),\n\t\t\t...ifDefined(\"roots\", built.roots)\n\t\t});\n\t}\n\treturn buildContractFromDefinition(full);\n}\nfunction defineContract(definition, factory) {\n\tif (!isContractScaffold(definition)) throw contractError(\"CONTRACT.ARGUMENT_INVALID\", \"defineContract expects a contract definition object. Define your contract with defineContract({ family, target, models, ... }).\");\n\tif (factory !== void 0) return buildBoundContract(definition.family, definition.target, definition, factory);\n\treturn buildBoundContract(definition.family, definition.target, definition);\n}\n//#endregion\nexport { bindEnumType, buildBoundContract, defineContract, enumType, field, index, isEnumTypeHandle, member, model, rel, valueObject };\n\n//# sourceMappingURL=contract-builder.mjs.map"],"mappings":";;;;;;;;;;;;;;;AAcA,SAAS,gBAAgB,OAAO;CAC/B,IAAI,MAAM,QAAQ,KAAK,GAAG,OAAO,IAAI,MAAM,IAAI,eAAe,CAAC,CAAC,KAAK,GAAG,EAAE;CAC1E,IAAI,SAAS,OAAO,UAAU,UAAU,OAAO,IAAI,OAAO,QAAQ,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,KAAK,cAAc,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,WAAW,GAAG,KAAK,UAAU,GAAG,EAAE,GAAG,gBAAgB,KAAK,GAAG,CAAC,CAAC,KAAK,GAAG,EAAE;CAClN,OAAO,KAAK,UAAU,KAAK;AAC5B;AACA,MAAM,6BAA6B;CAClC;CACA;CACA;CACA;CACA;AACD;AACA,SAAS,iBAAiB,YAAY,YAAY,MAAM;CACvD,iCAAiC,YAAY,WAAW,MAAM,IAAI;CAClE,MAAM,SAAS,gCAAgC,YAAY,IAAI;CAC/D,MAAM,cAAc;EACnB,GAAG,OAAO,YAAY,KAAK,IAAI,CAAC,SAAS,IAAI,CAAC;EAC9C,GAAG,OAAO,KAAK,CAAC,IAAI,IAAI,CAAC;EACzB,GAAG,OAAO,SAAS,CAAC,QAAQ,IAAI,CAAC;CAClC;CACA,IAAI,YAAY,SAAS,GAAG,MAAM,cAAc,sCAAsC,iBAAiB,WAAW,gBAAgB,YAAY,KAAK,IAAI,EAAE,uGAAuG,EAAE,MAAM;EACvQ;EACA,QAAQ;EACR,cAAc;CACf,EAAE,CAAC;CACH,OAAO,mBAAmB;EACzB,MAAM;GACL,MAAM;GACN,SAAS,OAAO,WAAW;GAC3B,GAAG,4BAA4B,OAAO,WAAW,UAAU;EAC5D;EACA,UAAU,OAAO;EACjB,MAAM;CACP,GAAG,KAAK,GAAG,OAAO,iBAAiB;AACpC;AACA,SAAS,yBAAyB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6B,QAAQ,QAAQ,WAAW,UAAU,CAAC;EACzF,OAAO,4BAA4B;GAClC,GAAG;GACH,GAAG,UAAU,UAAU,MAAM,MAAM;GACnC,GAAG,UAAU,gBAAgB,MAAM,YAAY;GAC/C,GAAG,UAAU,SAAS,MAAM,KAAK;EAClC,CAAC;CACF;CACA,OAAO,4BAA4B,IAAI;AACxC;AACA,SAAS,eAAe,YAAY,SAAS;CAC5C,IAAI,CAAC,mBAAmB,UAAU,GAAG,MAAM,cAAc,6BAA6B,iIAAiI;CACvN,IAAI,YAAY,KAAK,GAAG,OAAO,mBAAmB,WAAW,QAAQ,WAAW,QAAQ,YAAY,OAAO;CAC3G,OAAO,mBAAmB,WAAW,QAAQ,WAAW,QAAQ,UAAU;AAC3E"}
|
|
1
|
+
{"version":3,"file":"contract-builder-DYeV4YqF.mjs","names":[],"sources":["../../../../2-mongo-family/2-authoring/contract-ts/dist/contract-builder.mjs"],"sourcesContent":["import { t as contractError } from \"./contract-errors-BCN6RVI5.mjs\";\nimport { buildExecutionSection, computeProfileHash, computeStorageHash } from \"@internal/contract/hashing\";\nimport { crossRef } from \"@internal/contract/types\";\nimport { bindEnumType, composePackAuthoringNamespace, createEntityHelpersFromNamespace, createFieldHelpersFromNamespace, encodeEnumTypeMembers, enumType, isEnumTypeHandle, member, resolveToOneRelationNullable } from \"@internal/contract-authoring\";\nimport { assertNoCrossRegistryCollisions, instantiateAuthoringFieldPreset, validateAuthoringHelperArguments } from \"@internal/framework-components/authoring\";\nimport { assembleDataTypes } from \"@internal/framework-components/codec\";\nimport { extractCodecLookup } from \"@internal/framework-components/control\";\nimport { UNBOUND_NAMESPACE_ID } from \"@internal/framework-components/ir\";\nimport { MongoCollectionOptions, MongoIndex, MongoStorage, applyPolymorphicScopeToMongoIndex, buildMongoNamespace, mongoValueSetsOf } from \"@internal/mongo-contract\";\nimport { mongoContractCanonicalizationHooks } from \"@internal/mongo-contract/canonicalization-hooks\";\nimport { canonicalStringify } from \"@internal/utils/canonical-stringify\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { ifDefined } from \"@internal/utils/defined\";\n//#region src/contract-builder.ts\nfunction stableStringify(value) {\n\tif (Array.isArray(value)) return `[${value.map(stableStringify).join(\",\")}]`;\n\tif (value && typeof value === \"object\") return `{${Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([key, entry]) => `${JSON.stringify(key)}:${stableStringify(entry)}`).join(\",\")}}`;\n\treturn JSON.stringify(value);\n}\nconst MONGO_RESERVED_HELPER_KEYS = [\n\t\"field\",\n\t\"index\",\n\t\"model\",\n\t\"rel\",\n\t\"valueObject\"\n];\nfunction buildFieldPreset(helperPath, descriptor, args) {\n\tvalidateAuthoringHelperArguments(helperPath, descriptor.args, args);\n\tconst preset = instantiateAuthoringFieldPreset(descriptor, args);\n\tconst unsupported = [\n\t\t...preset.default !== void 0 ? [\"default\"] : [],\n\t\t...preset.id ? [\"id\"] : [],\n\t\t...preset.unique ? [\"unique\"] : []\n\t];\n\tif (unsupported.length > 0) throw contractError(\"CONTRACT.PACK_CONTRIBUTION_INVALID\", `Field preset \"${helperPath}\" contributes ${unsupported.join(\", \")}, which Mongo does not support. Mongo supports presets that set a codec and execution defaults only.`, { meta: {\n\t\thelperPath,\n\t\treason: \"preset-contribution-unsupported\",\n\t\tcontribution: unsupported\n\t} });\n\treturn createFieldBuilder({\n\t\ttype: {\n\t\t\tkind: \"scalar\",\n\t\t\tcodecId: preset.descriptor.codecId,\n\t\t\t...normalizeOptionalTypeParams(preset.descriptor.typeParams)\n\t\t},\n\t\tnullable: preset.nullable,\n\t\tmany: false\n\t}, void 0, preset.executionDefaults);\n}\nfunction composeMongoFieldHelpers(fieldNamespace) {\n\tconst presetHelpers = createFieldHelpersFromNamespace(fieldNamespace, ({ helperPath, descriptor }) => (...args) => buildFieldPreset(helperPath, descriptor, args));\n\tconst collisions = Object.keys(presetHelpers).filter((name) => Object.hasOwn(field, name));\n\tif (collisions.length > 0) throw contractError(\"CONTRACT.PACK_CONTRIBUTION_INVALID\", `Pack-contributed field preset(s) ${collisions.map((c) => `\"${c}\"`).join(\", \")} collide with the built-in Mongo field helper(s) of the same name.`, { meta: {\n\t\treason: \"core-field-helper-collision\",\n\t\tcontribution: collisions\n\t} });\n\treturn {\n\t\t...field,\n\t\t...presetHelpers\n\t};\n}\nfunction composeMongoAuthoringHelpers(family, target, extensions) {\n\tconst components = [\n\t\tfamily,\n\t\ttarget,\n\t\t...Object.values(extensions ?? {})\n\t];\n\tconst entityNamespace = composePackAuthoringNamespace(components, \"entityTypes\");\n\tconst fieldNamespace = composePackAuthoringNamespace(components, \"field\");\n\tassertNoCrossRegistryCollisions({}, fieldNamespace, entityNamespace);\n\tconst collisions = Object.keys(entityNamespace).filter((name) => MONGO_RESERVED_HELPER_KEYS.includes(name));\n\tif (collisions.length > 0) throw contractError(\"CONTRACT.PACK_CONTRIBUTION_INVALID\", `Pack-contributed entity type(s) ${collisions.map((c) => `\"${c}\"`).join(\", \")} collide with the reserved built-in helper key(s) on the Mongo composed helpers surface. Reserved keys: ${MONGO_RESERVED_HELPER_KEYS.map((k) => `\"${k}\"`).join(\", \")}.`, { meta: {\n\t\treason: \"reserved-helper-key-collision\",\n\t\tcontribution: collisions\n\t} });\n\treturn blindCast({\n\t\t...createEntityHelpersFromNamespace(entityNamespace, { ctx: {\n\t\t\tfamily: family.familyId,\n\t\t\ttarget: target.targetId,\n\t\t\tcodecLookup: extractCodecLookup(components),\n\t\t\tdataTypeLookup: assembleDataTypes(components).lookup\n\t\t} }),\n\t\tfield: composeMongoFieldHelpers(fieldNamespace),\n\t\tindex,\n\t\tmodel,\n\t\trel,\n\t\tvalueObject\n\t});\n}\nfunction createFieldBuilder(spec, enumHandle, executionDefaults) {\n\tfunction many(options) {\n\t\treturn createFieldBuilder({\n\t\t\ttype: spec.type,\n\t\t\tnullable: spec.nullable,\n\t\t\tmany: { elementNullable: options?.elementsNullable ?? false }\n\t\t}, enumHandle, executionDefaults);\n\t}\n\treturn {\n\t\t__kind: \"field\",\n\t\t...ifDefined(\"__executionDefaults\", executionDefaults),\n\t\t__type: spec.type,\n\t\t__nullable: spec.nullable,\n\t\t__many: spec.many,\n\t\t__enumHandle: blindCast(enumHandle),\n\t\toptional: blindCast(() => createFieldBuilder({\n\t\t\ttype: spec.type,\n\t\t\tnullable: true,\n\t\t\tmany: spec.many\n\t\t}, enumHandle, executionDefaults)),\n\t\tmany: blindCast(many)\n\t};\n}\nfunction normalizeOptionalTypeParams(typeParams) {\n\tif (!typeParams) return {};\n\treturn { typeParams };\n}\nfunction createScalarFieldBuilder(codecId, options) {\n\treturn createFieldBuilder({\n\t\ttype: blindCast({\n\t\t\tkind: \"scalar\",\n\t\t\tcodecId,\n\t\t\t...normalizeOptionalTypeParams(options?.typeParams)\n\t\t}),\n\t\tnullable: false,\n\t\tmany: false\n\t});\n}\nconst field = {\n\tscalar: createScalarFieldBuilder,\n\tobjectId() {\n\t\treturn createScalarFieldBuilder(\"mongo/objectId@1\");\n\t},\n\tstring() {\n\t\treturn createScalarFieldBuilder(\"mongo/string@1\");\n\t},\n\tdouble() {\n\t\treturn createScalarFieldBuilder(\"mongo/double@1\");\n\t},\n\tint32() {\n\t\treturn createScalarFieldBuilder(\"mongo/int32@1\");\n\t},\n\tbool() {\n\t\treturn createScalarFieldBuilder(\"mongo/bool@1\");\n\t},\n\tdate() {\n\t\treturn createScalarFieldBuilder(\"mongo/date@1\");\n\t},\n\tint64() {\n\t\treturn createScalarFieldBuilder(\"mongo/int64@1\");\n\t},\n\tint64Number() {\n\t\treturn createScalarFieldBuilder(\"mongo/int64Number@1\");\n\t},\n\tdecimal128() {\n\t\treturn createScalarFieldBuilder(\"mongo/decimal128@1\");\n\t},\n\tbinary() {\n\t\treturn createScalarFieldBuilder(\"mongo/binary@1\");\n\t},\n\tjson() {\n\t\treturn createScalarFieldBuilder(\"mongo/json@1\");\n\t},\n\tbson() {\n\t\treturn createScalarFieldBuilder(\"mongo/bson@1\");\n\t},\n\tvector(options) {\n\t\treturn createScalarFieldBuilder(\"mongo/vector@1\", options);\n\t},\n\tvalueObject(valueObjectName) {\n\t\treturn createFieldBuilder({\n\t\t\ttype: blindCast({\n\t\t\t\tkind: \"valueObject\",\n\t\t\t\tname: resolveValueObjectName(valueObjectName)\n\t\t\t}),\n\t\t\tnullable: false,\n\t\t\tmany: false\n\t\t});\n\t},\n\tnamedType(handle) {\n\t\treturn createFieldBuilder({\n\t\t\ttype: blindCast({\n\t\t\t\tkind: \"scalar\",\n\t\t\t\tcodecId: handle.codecId\n\t\t\t}),\n\t\t\tnullable: false,\n\t\t\tmany: false\n\t\t}, handle);\n\t}\n};\nfunction index(fields, options) {\n\treturn {\n\t\tfields,\n\t\t...options ? { options } : {}\n\t};\n}\nfunction createFieldReference(modelName, fieldName) {\n\treturn {\n\t\t__kind: \"fieldRef\",\n\t\tmodelName,\n\t\tfieldName\n\t};\n}\nfunction isFieldReference(value) {\n\treturn typeof value === \"object\" && value !== null && \"__kind\" in value && value.__kind === \"fieldRef\";\n}\nfunction resolveModelName(value) {\n\treturn typeof value === \"string\" ? value : value.__name;\n}\nfunction resolveValueObjectName(value) {\n\treturn typeof value === \"string\" ? value : value.__name;\n}\nfunction normalizeStringList(value) {\n\treturn typeof value === \"string\" ? [value] : [...value];\n}\nfunction normalizeTargetField(targetModelName, value) {\n\tif (!isFieldReference(value)) return value;\n\tif (value.modelName !== targetModelName) throw contractError(\"CONTRACT.RELATION_INVALID\", `Relation target \"${targetModelName}\" cannot reference field \"${value.modelName}.${value.fieldName}\".`, { meta: {\n\t\tmodelName: targetModelName,\n\t\treason: \"cross-model-field-reference\",\n\t\treferencedModel: value.modelName,\n\t\treferencedField: value.fieldName\n\t} });\n\treturn value.fieldName;\n}\nfunction normalizeTargetFields(targetModelName, value) {\n\tif (typeof value === \"string\") return [value];\n\tif (isFieldReference(value)) return [normalizeTargetField(targetModelName, value)];\n\treturn value.map((entry) => normalizeTargetField(targetModelName, entry));\n}\nfunction createRelationBuilder(spec) {\n\treturn {\n\t\t__kind: \"relation\",\n\t\t__to: spec.to,\n\t\t__cardinality: spec.cardinality,\n\t\t__on: spec.on,\n\t\t__nullable: spec.nullable\n\t};\n}\nfunction createReferenceRelationBuilder(target, cardinality, options, nullable) {\n\tconst targetModelName = resolveModelName(target);\n\treturn createRelationBuilder({\n\t\tto: blindCast(targetModelName),\n\t\tcardinality,\n\t\ton: {\n\t\t\tlocalFields: blindCast(normalizeStringList(options.from)),\n\t\t\ttargetFields: blindCast(normalizeTargetFields(targetModelName, options.to))\n\t\t},\n\t\tnullable\n\t});\n}\nfunction createEmbedRelationBuilder(target, cardinality) {\n\treturn createRelationBuilder({\n\t\tto: blindCast(resolveModelName(target)),\n\t\tcardinality,\n\t\ton: void 0,\n\t\tnullable: void 0\n\t});\n}\nfunction hasOne(target, options) {\n\tif (!options) return createEmbedRelationBuilder(target, \"1:1\");\n\treturn createReferenceRelationBuilder(target, \"1:1\", options, true);\n}\nfunction hasMany(target, options) {\n\tif (!options) return createEmbedRelationBuilder(target, \"1:N\");\n\treturn createReferenceRelationBuilder(target, \"1:N\", options, void 0);\n}\nfunction belongsTo(target, options) {\n\treturn createReferenceRelationBuilder(target, \"N:1\", options, options.optional);\n}\nconst rel = {\n\tbelongsTo,\n\thasMany,\n\thasOne\n};\nfunction valueObject(name, input) {\n\treturn {\n\t\t__kind: \"valueObject\",\n\t\t__name: name,\n\t\t__fields: input.fields\n\t};\n}\nfunction model(name, input) {\n\treturn {\n\t\t__kind: \"model\",\n\t\t__name: name,\n\t\t__fields: input.fields,\n\t\t__relations: blindCast(input.relations ?? {}),\n\t\t__indexes: input.indexes,\n\t\t__collectionOptions: input.collectionOptions,\n\t\t__controlPolicy: input.controlPolicy,\n\t\t__collection: blindCast(input.collection),\n\t\t__owner: blindCast(input.owner ? resolveModelName(input.owner) : void 0),\n\t\t__base: blindCast(input.base ? resolveModelName(input.base) : void 0),\n\t\t__storageRelations: blindCast(input.storageRelations),\n\t\t__discriminator: blindCast(input.discriminator ? { field: input.discriminator.field } : void 0),\n\t\t__variants: blindCast(input.discriminator?.variants),\n\t\tref(fieldName) {\n\t\t\treturn createFieldReference(name, fieldName);\n\t\t}\n\t};\n}\nfunction validateTargetPackRef(family, target) {\n\tif (family.familyId !== \"mongo\") throw contractError(\"CONTRACT.PACK_FAMILY_MISMATCH\", `defineContract only accepts Mongo family packs. Received family \"${family.familyId}\".`, { meta: {\n\t\tpackId: family.id,\n\t\tpackFamilyId: family.familyId,\n\t\tcontractFamilyId: \"mongo\"\n\t} });\n\tif (target.familyId !== family.familyId) throw contractError(\"CONTRACT.PACK_FAMILY_MISMATCH\", `target pack \"${target.id}\" targets family \"${target.familyId}\" but contract family is \"${family.familyId}\".`, { meta: {\n\t\tpackId: target.id,\n\t\tpackFamilyId: target.familyId,\n\t\tcontractFamilyId: family.familyId\n\t} });\n}\nfunction validateExtensionPackRefs(target, extensions) {\n\tif (!extensions) return;\n\tfor (const packRef of Object.values(extensions)) {\n\t\tif (packRef.kind !== \"extension\") throw contractError(\"CONTRACT.PACK_REF_INVALID\", `defineContract only accepts extension pack refs in extensions. Received kind \"${packRef.kind}\".`, { meta: {\n\t\t\tpackId: packRef.id,\n\t\t\tkind: packRef.kind\n\t\t} });\n\t\tif (packRef.familyId !== target.familyId) throw contractError(\"CONTRACT.PACK_FAMILY_MISMATCH\", `extension pack \"${packRef.id}\" targets family \"${packRef.familyId}\" but contract target family is \"${target.familyId}\".`, { meta: {\n\t\t\tpackId: packRef.id,\n\t\t\tpackFamilyId: packRef.familyId,\n\t\t\tcontractFamilyId: target.familyId\n\t\t} });\n\t\tif (packRef.targetId && packRef.targetId !== target.targetId) throw contractError(\"CONTRACT.PACK_TARGET_MISMATCH\", `extension pack \"${packRef.id}\" targets \"${packRef.targetId}\" but contract target is \"${target.targetId}\".`, { meta: {\n\t\t\tpackId: packRef.id,\n\t\t\tpackTargetId: packRef.targetId,\n\t\t\tcontractTargetId: target.targetId\n\t\t} });\n\t}\n}\nfunction isContractScaffold(value) {\n\tif (typeof value !== \"object\" || value === null) return false;\n\treturn \"family\" in value && \"target\" in value;\n}\nfunction buildContractField(builder) {\n\tconst valueSet = builder.__enumHandle ? {\n\t\tplane: \"domain\",\n\t\tentityKind: \"enum\",\n\t\tnamespaceId: UNBOUND_NAMESPACE_ID,\n\t\tentityName: builder.__enumHandle.enumName\n\t} : void 0;\n\treturn {\n\t\ttype: builder.__type,\n\t\tnullable: builder.__nullable,\n\t\tmany: builder.__many,\n\t\t...ifDefined(\"valueSet\", valueSet)\n\t};\n}\nfunction buildFields(fields) {\n\tconst builtFields = {};\n\tfor (const [fieldName, fieldBuilder] of Object.entries(fields)) builtFields[fieldName] = buildContractField(fieldBuilder);\n\treturn builtFields;\n}\nfunction toOneRelationNullable(modelName, relationName, relationBuilder, on, fields) {\n\tconst location = `Relation \"${modelName}.${relationName}\"`;\n\tconst ownsForeignKey = relationBuilder.__cardinality !== \"1:1\";\n\tconst localFields = ownsForeignKey ? on.localFields.map((fieldName) => {\n\t\tconst localField = fields[fieldName];\n\t\tif (localField === void 0) throw contractError(\"CONTRACT.RELATION_INVALID\", `${location} joins on local field \"${fieldName}\", which model \"${modelName}\" does not declare`, { meta: {\n\t\t\tmodelName,\n\t\t\trelationName,\n\t\t\tfieldName,\n\t\t\treason: \"local-field-unknown\"\n\t\t} });\n\t\treturn localField;\n\t}) : [];\n\tconst { nullable, contradiction } = resolveToOneRelationNullable({\n\t\tdeclaredNullable: relationBuilder.__nullable,\n\t\tlocalFieldNullability: localFields.map((localField) => localField.__nullable === true),\n\t\townsReference: ownsForeignKey\n\t});\n\tif (contradiction !== void 0) throw contractError(\"CONTRACT.RELATION_INVALID\", !ownsForeignKey ? `${location} is required but does not own the foreign key, so nothing in storage guarantees the related document exists` : contradiction === \"declared-optional\" ? `${location} is optional but every local field it joins on is required` : `${location} is required but a local field it joins on is nullable`, { meta: {\n\t\tmodelName,\n\t\trelationName,\n\t\treason: \"to-one-nullability-mismatch\"\n\t} });\n\treturn nullable;\n}\nfunction buildRelation(modelName, relationName, relationBuilder, fields) {\n\tconst to = crossRef(relationBuilder.__to, UNBOUND_NAMESPACE_ID);\n\tconst on = relationBuilder.__on;\n\tif (on === void 0) return {\n\t\tto,\n\t\tcardinality: relationBuilder.__cardinality\n\t};\n\tif (relationBuilder.__cardinality === \"1:N\") return {\n\t\tto,\n\t\tcardinality: \"1:N\",\n\t\ton\n\t};\n\treturn {\n\t\tto,\n\t\tcardinality: relationBuilder.__cardinality,\n\t\tnullable: toOneRelationNullable(modelName, relationName, relationBuilder, on, fields),\n\t\ton\n\t};\n}\nfunction buildRelations(modelName, relations, fields) {\n\tconst builtRelations = {};\n\tfor (const [relationName, relationBuilder] of Object.entries(relations)) builtRelations[relationName] = buildRelation(modelName, relationName, relationBuilder, fields);\n\treturn builtRelations;\n}\nfunction buildValueObjects(valueObjects) {\n\tconst builtValueObjects = {};\n\tfor (const valueObjectBuilder of Object.values(valueObjects ?? {})) {\n\t\tif (valueObjectBuilder.__name in builtValueObjects) throw contractError(\"CONTRACT.NAME_DUPLICATE\", `Duplicate value object name \"${valueObjectBuilder.__name}\" in defineContract().`, { meta: {\n\t\t\tkind: \"valueObject\",\n\t\t\tname: valueObjectBuilder.__name\n\t\t} });\n\t\tbuiltValueObjects[valueObjectBuilder.__name] = { fields: buildFields(valueObjectBuilder.__fields) };\n\t}\n\treturn builtValueObjects;\n}\nfunction buildModels(models) {\n\tconst builtModels = {};\n\tfor (const modelBuilder of Object.values(models ?? {})) {\n\t\tif (modelBuilder.__name in builtModels) throw contractError(\"CONTRACT.NAME_DUPLICATE\", `Duplicate model name \"${modelBuilder.__name}\" in defineContract().`, { meta: {\n\t\t\tkind: \"model\",\n\t\t\tname: modelBuilder.__name\n\t\t} });\n\t\tassertUniqueDiscriminatorValues(modelBuilder);\n\t\tconst storage = {\n\t\t\t...modelBuilder.__collection ? { collection: modelBuilder.__collection } : {},\n\t\t\t...modelBuilder.__storageRelations ? { relations: modelBuilder.__storageRelations } : {}\n\t\t};\n\t\tbuiltModels[modelBuilder.__name] = {\n\t\t\tfields: buildFields(modelBuilder.__fields),\n\t\t\trelations: buildRelations(modelBuilder.__name, modelBuilder.__relations, modelBuilder.__fields),\n\t\t\tstorage,\n\t\t\t...modelBuilder.__owner ? { owner: modelBuilder.__owner } : {},\n\t\t\t...modelBuilder.__base ? { base: crossRef(modelBuilder.__base, UNBOUND_NAMESPACE_ID) } : {},\n\t\t\t...modelBuilder.__discriminator ? { discriminator: modelBuilder.__discriminator } : {},\n\t\t\t...modelBuilder.__variants ? { variants: Object.fromEntries(Object.entries(modelBuilder.__variants).map(([variantName, { value }]) => [value, crossRef(variantName, UNBOUND_NAMESPACE_ID)])) } : {}\n\t\t};\n\t}\n\treturn builtModels;\n}\nfunction assertUniqueDiscriminatorValues(modelBuilder) {\n\tconst variantNamesByValue = /* @__PURE__ */ new Map();\n\tfor (const [variantName, { value }] of Object.entries(modelBuilder.__variants ?? {})) {\n\t\tconst existingVariant = variantNamesByValue.get(value);\n\t\tif (existingVariant !== void 0) throw contractError(\"CONTRACT.ARGUMENT_INVALID\", `Discriminator value \"${value}\" is used by both \"${existingVariant}\" and \"${variantName}\" on base model \"${modelBuilder.__name}\".`, { meta: {\n\t\t\tmodelName: modelBuilder.__name,\n\t\t\tvalue,\n\t\t\tvariants: [existingVariant, variantName],\n\t\t\treason: \"duplicate-discriminator-value\"\n\t\t} });\n\t\tvariantNamesByValue.set(value, variantName);\n\t}\n}\nfunction deriveRoots(models) {\n\tconst roots = {};\n\tfor (const modelBuilder of Object.values(models ?? {})) {\n\t\tif (!modelBuilder.__collection || modelBuilder.__owner || modelBuilder.__base) continue;\n\t\troots[modelBuilder.__collection] = crossRef(modelBuilder.__name, UNBOUND_NAMESPACE_ID);\n\t}\n\treturn roots;\n}\nfunction normalizeRoots(roots) {\n\tconst normalizedRoots = {};\n\tfor (const [rootName, rootValue] of Object.entries(roots ?? {})) normalizedRoots[rootName] = crossRef(resolveModelName(rootValue), UNBOUND_NAMESPACE_ID);\n\treturn normalizedRoots;\n}\nfunction toStorageIndex(index) {\n\tconst input = { keys: Object.entries(index.fields).map(([field, direction]) => ({\n\t\tfield,\n\t\tdirection\n\t})) };\n\tif (index.options) {\n\t\tfor (const [key, value] of Object.entries(index.options)) if (value !== void 0) input[key] = value;\n\t}\n\treturn new MongoIndex(blindCast(input));\n}\nfunction toStorageCollectionOptions(opts) {\n\treturn new MongoCollectionOptions({\n\t\t...opts.capped ? { capped: {\n\t\t\tsize: opts.size ?? 0,\n\t\t\t...opts.max != null && { max: opts.max }\n\t\t} } : {},\n\t\t...ifDefined(\"storageEngine\", opts.storageEngine),\n\t\t...ifDefined(\"indexOptionDefaults\", opts.indexOptionDefaults),\n\t\t...ifDefined(\"collation\", opts.collation),\n\t\t...ifDefined(\"timeseries\", opts.timeseries),\n\t\t...opts.clusteredIndex !== void 0 && { clusteredIndex: opts.clusteredIndex.name !== void 0 ? { name: opts.clusteredIndex.name } : {} },\n\t\t...ifDefined(\"expireAfterSeconds\", opts.expireAfterSeconds),\n\t\t...ifDefined(\"changeStreamPreAndPostImages\", opts.changeStreamPreAndPostImages)\n\t});\n}\nfunction findMissingIndexField(index, modelFields) {\n\tfor (const fieldName of Object.keys(index.fields)) {\n\t\tconst wildcardMatch = fieldName.match(/^(.+)\\.\\$\\*\\*$/);\n\t\tconst lookupName = wildcardMatch ? wildcardMatch[1] : fieldName;\n\t\tif (lookupName === void 0 || lookupName.length === 0) continue;\n\t\tif (lookupName === \"$**\") continue;\n\t\tif (!Object.hasOwn(modelFields, lookupName)) return lookupName;\n\t}\n}\nfunction resolveVariantScope(modelBuilder, modelsByName) {\n\tif (!modelBuilder.__base) return void 0;\n\tconst baseBuilder = modelsByName[modelBuilder.__base];\n\tif (!baseBuilder) return void 0;\n\tconst discriminatorField = baseBuilder.__discriminator?.field;\n\tconst variantValue = baseBuilder.__variants?.[modelBuilder.__name]?.value;\n\tif (!discriminatorField || variantValue === void 0) return void 0;\n\treturn {\n\t\tdiscriminatorField,\n\t\tdiscriminatorValue: variantValue\n\t};\n}\nfunction scopeVariantIndex(storageIndex, scope, variantName, authoredIndex) {\n\tconst result = applyPolymorphicScopeToMongoIndex(storageIndex, scope);\n\tif (result.kind === \"conflict\") {\n\t\tconst indexLabel = authoredIndex ? canonicalStringify(authoredIndex) : \"<unknown>\";\n\t\tthrow contractError(\"CONTRACT.INDEX_INVALID\", `Variant model \"${variantName}\" index ${indexLabel} conflicts with discriminator scope: ${result.reason}`, { meta: {\n\t\t\tvariantName,\n\t\t\tindexLabel,\n\t\t\treason: result.reason\n\t\t} });\n\t}\n\treturn result.index;\n}\nfunction buildCollections(models) {\n\tconst intermediate = {};\n\tconst declaredIndexOwners = /* @__PURE__ */ new Map();\n\tconst modelMap = models ?? {};\n\tconst modelsByName = {};\n\tfor (const builder of Object.values(modelMap)) modelsByName[builder.__name] = builder;\n\tfor (const modelBuilder of Object.values(modelMap)) {\n\t\tif (!modelBuilder.__collection) {\n\t\t\tif (modelBuilder.__indexes && modelBuilder.__indexes.length > 0) throw contractError(\"CONTRACT.COLLECTION_INVALID\", `Model \"${modelBuilder.__name}\" defines indexes but has no collection to attach them to.`, { meta: {\n\t\t\t\tmodelName: modelBuilder.__name,\n\t\t\t\treason: \"indexes-without-collection\"\n\t\t\t} });\n\t\t\tif (modelBuilder.__collectionOptions) throw contractError(\"CONTRACT.COLLECTION_INVALID\", `Model \"${modelBuilder.__name}\" defines collectionOptions but has no collection to attach them to.`, { meta: {\n\t\t\t\tmodelName: modelBuilder.__name,\n\t\t\t\treason: \"collectionOptions-without-collection\"\n\t\t\t} });\n\t\t\tif (modelBuilder.__controlPolicy) throw contractError(\"CONTRACT.COLLECTION_INVALID\", `Model \"${modelBuilder.__name}\" defines controlPolicy but has no collection to attach it to.`, { meta: {\n\t\t\t\tmodelName: modelBuilder.__name,\n\t\t\t\treason: \"controlPolicy-without-collection\"\n\t\t\t} });\n\t\t\tcontinue;\n\t\t}\n\t\tconst existingCollection = intermediate[modelBuilder.__collection] ?? {};\n\t\tconst existingIndexes = existingCollection.indexes ?? [];\n\t\tif (existingCollection.options && modelBuilder.__collectionOptions) throw contractError(\"CONTRACT.COLLECTION_INVALID\", `Collection \"${modelBuilder.__collection}\" has collectionOptions declared by multiple models. Author collectionOptions on a single model per collection.`, { meta: {\n\t\t\tmodelName: modelBuilder.__name,\n\t\t\tcollection: modelBuilder.__collection,\n\t\t\treason: \"collectionOptions-declared-by-multiple-models\"\n\t\t} });\n\t\tif (existingCollection.control !== void 0 && modelBuilder.__controlPolicy) throw contractError(\"CONTRACT.COLLECTION_INVALID\", `Collection \"${modelBuilder.__collection}\" has controlPolicy declared by multiple models. Author controlPolicy on a single model per collection.`, { meta: {\n\t\t\tmodelName: modelBuilder.__name,\n\t\t\tcollection: modelBuilder.__collection,\n\t\t\treason: \"controlPolicy-declared-by-multiple-models\"\n\t\t} });\n\t\tfor (const collectionIndex of modelBuilder.__indexes ?? []) {\n\t\t\tconst missingField = findMissingIndexField(collectionIndex, modelBuilder.__fields);\n\t\t\tif (missingField !== void 0) {\n\t\t\t\tconst indexSignature = canonicalStringify(collectionIndex);\n\t\t\t\tthrow contractError(\"CONTRACT.FIELD_UNKNOWN\", `Model \"${modelBuilder.__name}\" index ${indexSignature} references unknown field \"${missingField}\".`, { meta: {\n\t\t\t\t\tmodelName: modelBuilder.__name,\n\t\t\t\t\tfieldName: missingField,\n\t\t\t\t\tindexSignature\n\t\t\t\t} });\n\t\t\t}\n\t\t}\n\t\tconst polymorphicScope = resolveVariantScope(modelBuilder, modelsByName);\n\t\tconst rawStorageIndexes = (modelBuilder.__indexes ?? []).map(toStorageIndex);\n\t\tconst storageIndexes = polymorphicScope ? rawStorageIndexes.map((idx, i) => scopeVariantIndex(idx, polymorphicScope, modelBuilder.__name, modelBuilder.__indexes?.[i])) : rawStorageIndexes;\n\t\tfor (let i = 0; i < storageIndexes.length; i++) {\n\t\t\tconst storageIndex = storageIndexes[i];\n\t\t\tif (storageIndex === void 0) continue;\n\t\t\tconst indexSignature = stableStringify(storageIndex);\n\t\t\tconst collectionIndexKey = `${modelBuilder.__collection}:${indexSignature}`;\n\t\t\tconst firstOwner = declaredIndexOwners.get(collectionIndexKey);\n\t\t\tif (firstOwner) {\n\t\t\t\tconst authoredIndex = modelBuilder.__indexes?.[i];\n\t\t\t\tconst reportedSignature = authoredIndex ? canonicalStringify(authoredIndex) : indexSignature;\n\t\t\t\tthrow contractError(\"CONTRACT.NAME_DUPLICATE\", `Collection \"${modelBuilder.__collection}\" defines duplicate index ${reportedSignature}. First declared on model \"${firstOwner}\" and duplicated on model \"${modelBuilder.__name}\".`, { meta: {\n\t\t\t\t\tkind: \"index\",\n\t\t\t\t\tname: reportedSignature,\n\t\t\t\t\tcollection: modelBuilder.__collection,\n\t\t\t\t\tfirst: firstOwner,\n\t\t\t\t\tsecond: modelBuilder.__name\n\t\t\t\t} });\n\t\t\t}\n\t\t\tdeclaredIndexOwners.set(collectionIndexKey, modelBuilder.__name);\n\t\t}\n\t\tconst storageOptions = modelBuilder.__collectionOptions ? toStorageCollectionOptions(modelBuilder.__collectionOptions) : void 0;\n\t\tconst controlPatch = modelBuilder.__controlPolicy !== void 0 ? { control: modelBuilder.__controlPolicy } : {};\n\t\tintermediate[modelBuilder.__collection] = storageIndexes.length > 0 ? {\n\t\t\t...existingCollection,\n\t\t\tindexes: [...existingIndexes, ...storageIndexes],\n\t\t\t...storageOptions ? { options: storageOptions } : {},\n\t\t\t...controlPatch\n\t\t} : storageOptions ? {\n\t\t\t...existingCollection,\n\t\t\toptions: storageOptions,\n\t\t\t...controlPatch\n\t\t} : Object.keys(controlPatch).length > 0 ? {\n\t\t\t...existingCollection,\n\t\t\t...controlPatch\n\t\t} : existingCollection;\n\t}\n\treturn intermediate;\n}\nfunction executionDefaultError(modelName, fieldName, reason, message) {\n\treturn contractError(\"CONTRACT.DEFAULT_INVALID\", `Field \"${modelName}.${fieldName}\" ${message}`, { meta: {\n\t\tmodelName,\n\t\tfieldName,\n\t\treason\n\t} });\n}\nfunction hasExecutionDefaults(fieldBuilder) {\n\tconst phases = fieldBuilder.__executionDefaults;\n\treturn phases?.onCreate !== void 0 || phases?.onUpdate !== void 0;\n}\nfunction assertNoValueObjectExecutionDefaults(valueObjects) {\n\tfor (const valueObjectBuilder of Object.values(valueObjects ?? {})) for (const [fieldName, fieldBuilder] of Object.entries(valueObjectBuilder.__fields)) if (hasExecutionDefaults(fieldBuilder)) throw executionDefaultError(valueObjectBuilder.__name, fieldName, \"executionDefaults-on-value-object\", \"has executionDefaults, but it belongs to a value object. Generated values are only supported on model fields.\");\n}\nfunction buildExecutionDefaults(models) {\n\tconst modelBuilders = Object.values(models ?? {});\n\tconst collectionByModelName = new Map(modelBuilders.map((modelBuilder) => [modelBuilder.__name, modelBuilder.__collection]));\n\tconst byRef = /* @__PURE__ */ new Map();\n\tconst defaults = [];\n\tfor (const modelBuilder of modelBuilders) for (const [fieldName, fieldBuilder] of Object.entries(modelBuilder.__fields)) {\n\t\tconst phases = fieldBuilder.__executionDefaults;\n\t\tif (!phases || !hasExecutionDefaults(fieldBuilder)) continue;\n\t\tconst modelName = modelBuilder.__name;\n\t\tif (fieldBuilder.__nullable) throw executionDefaultError(modelName, fieldName, \"nullable-with-executionDefaults\", \"is filled on write by a preset such as temporal.createdAt(), so it cannot be optional; remove .optional().\");\n\t\tif (fieldBuilder.__many) throw executionDefaultError(modelName, fieldName, \"many-with-executionDefaults\", \"is filled on write by a preset such as temporal.createdAt(), so it cannot be a list; remove .many().\");\n\t\tif (modelBuilder.__base !== void 0) {\n\t\t\tconst collection = modelBuilder.__collection ?? collectionByModelName.get(modelBuilder.__base);\n\t\t\tthrow executionDefaultError(modelName, fieldName, \"executionDefaults-on-variant\", `has executionDefaults, but \"${modelName}\" is a variant of \"${modelBuilder.__base}\". Execution defaults apply to every document in collection \"${collection}\", so declare them on the base model.`);\n\t\t}\n\t\tconst entry = modelBuilder.__collection;\n\t\tif (entry === void 0) throw executionDefaultError(modelName, fieldName, \"executionDefaults-without-collection\", \"has executionDefaults, but its model has no collection. Generated values are only supported on fields of a model stored in a collection.\");\n\t\tconst refKey = JSON.stringify([entry, fieldName]);\n\t\tconst phasesKey = canonicalStringify(phases);\n\t\tconst existing = byRef.get(refKey);\n\t\tif (existing !== void 0) {\n\t\t\tif (existing.phasesKey !== phasesKey) throw executionDefaultError(modelName, fieldName, \"executionDefaults-conflict\", `has different executionDefaults than \"${existing.modelName}.${fieldName}\", which is stored in the same collection \"${entry}\". Use the same executionDefaults on both models.`);\n\t\t\tcontinue;\n\t\t}\n\t\tbyRef.set(refKey, {\n\t\t\tmodelName,\n\t\t\tphasesKey\n\t\t});\n\t\tdefaults.push({\n\t\t\tref: {\n\t\t\t\tnamespace: UNBOUND_NAMESPACE_ID,\n\t\t\t\tentry,\n\t\t\t\tfield: fieldName\n\t\t\t},\n\t\t\t...phases\n\t\t});\n\t}\n\treturn defaults;\n}\nfunction buildContractFromDefinition(definition) {\n\tvalidateTargetPackRef(definition.family, definition.target);\n\tvalidateExtensionPackRefs(definition.target, definition.extensions);\n\tconst builtModels = buildModels(definition.models);\n\tconst builtValueObjects = buildValueObjects(definition.valueObjects);\n\tconst roots = definition.roots ? normalizeRoots(definition.roots) : deriveRoots(definition.models);\n\tconst capabilities = {};\n\tconst collections = buildCollections(definition.models);\n\tassertNoValueObjectExecutionDefaults(definition.valueObjects);\n\tconst execution = buildExecutionSection({\n\t\ttarget: definition.target.targetId,\n\t\ttargetFamily: definition.family.familyId,\n\t\tdefaults: buildExecutionDefaults(definition.models)\n\t});\n\tconst codecLookup = extractCodecLookup([definition.target]);\n\tconst builtEnums = {};\n\tfor (const [enumName, handle] of Object.entries(definition.enums ?? {})) builtEnums[enumName] = {\n\t\tcodecId: handle.codecId,\n\t\tmembers: encodeEnumTypeMembers(handle, codecLookup, \"the field\")\n\t};\n\tconst storageValueSets = mongoValueSetsOf(builtEnums);\n\tconst unboundNamespace = buildMongoNamespace({\n\t\tid: UNBOUND_NAMESPACE_ID,\n\t\tentries: {\n\t\t\tcollection: collections,\n\t\t\t...ifDefined(\"valueSet\", Object.keys(storageValueSets).length > 0 ? storageValueSets : void 0)\n\t\t}\n\t});\n\tconst storageBody = { namespaces: { [UNBOUND_NAMESPACE_ID]: {\n\t\tid: UNBOUND_NAMESPACE_ID,\n\t\tcollections: unboundNamespace.entries.collection,\n\t\t...ifDefined(\"valueSet\", unboundNamespace.entries.valueSet)\n\t} } };\n\tconst storage = new MongoStorage({\n\t\tstorageHash: computeStorageHash({\n\t\t\ttarget: definition.target.targetId,\n\t\t\ttargetFamily: definition.family.familyId,\n\t\t\tstorage: storageBody,\n\t\t\t...mongoContractCanonicalizationHooks\n\t\t}),\n\t\tnamespaces: { [UNBOUND_NAMESPACE_ID]: unboundNamespace }\n\t});\n\tfor (const [enumName, handle] of Object.entries(definition.enums ?? {})) if (enumName !== handle.enumName) throw contractError(\"CONTRACT.ENUM_INVALID\", `enum declaration key \"${enumName}\" must match enumType name \"${handle.enumName}\". Aliases are not supported.`, { meta: {\n\t\tenumName: handle.enumName,\n\t\tdeclaredKey: enumName,\n\t\treason: \"declaration-key-mismatch\"\n\t} });\n\tconst hasEnums = Object.keys(builtEnums).length > 0;\n\tfor (const [modelName, modelBuilder] of Object.entries(definition.models ?? {})) for (const [fieldName, fieldBuilder] of Object.entries(modelBuilder.__fields)) {\n\t\tconst handle = fieldBuilder.__enumHandle;\n\t\tif (handle && !(handle.enumName in builtEnums)) throw contractError(\"CONTRACT.ENUM_UNKNOWN\", `Model \"${modelName}\" field \"${fieldName}\" references enum \"${handle.enumName}\" which is not declared in defineContract({ enums: { ... } }).`, { meta: {\n\t\t\tmodelName,\n\t\t\tfieldName,\n\t\t\tenumName: handle.enumName\n\t\t} });\n\t}\n\treturn blindCast({\n\t\ttarget: definition.target.targetId,\n\t\ttargetFamily: definition.family.familyId,\n\t\t...ifDefined(\"defaultControlPolicy\", definition.defaultControlPolicy),\n\t\troots,\n\t\tdomain: { namespaces: { [UNBOUND_NAMESPACE_ID]: {\n\t\t\tmodels: builtModels,\n\t\t\t...Object.keys(builtValueObjects).length > 0 ? { valueObjects: builtValueObjects } : {},\n\t\t\t...hasEnums ? { enum: builtEnums } : {}\n\t\t} } },\n\t\tstorage,\n\t\tcapabilities,\n\t\textensions: definition.extensions ?? {},\n\t\tprofileHash: computeProfileHash({\n\t\t\ttarget: definition.target.targetId,\n\t\t\ttargetFamily: definition.family.familyId,\n\t\t\tcapabilities\n\t\t}),\n\t\tmeta: {},\n\t\t...ifDefined(\"execution\", execution)\n\t});\n}\n/** Implementation. */\nfunction buildBoundContract(family, target, definition, factory) {\n\tconst full = {\n\t\t...definition,\n\t\tfamily,\n\t\ttarget\n\t};\n\tif (factory !== void 0) {\n\t\tconst built = factory(composeMongoAuthoringHelpers(family, target, definition.extensions));\n\t\treturn buildContractFromDefinition({\n\t\t\t...full,\n\t\t\t...ifDefined(\"models\", built.models),\n\t\t\t...ifDefined(\"valueObjects\", built.valueObjects),\n\t\t\t...ifDefined(\"roots\", built.roots)\n\t\t});\n\t}\n\treturn buildContractFromDefinition(full);\n}\nfunction defineContract(definition, factory) {\n\tif (!isContractScaffold(definition)) throw contractError(\"CONTRACT.ARGUMENT_INVALID\", \"defineContract expects a contract definition object. Define your contract with defineContract({ family, target, models, ... }).\");\n\tif (factory !== void 0) return buildBoundContract(definition.family, definition.target, definition, factory);\n\treturn buildBoundContract(definition.family, definition.target, definition);\n}\n//#endregion\nexport { bindEnumType, buildBoundContract, defineContract, enumType, field, index, isEnumTypeHandle, member, model, rel, valueObject };\n\n//# sourceMappingURL=contract-builder.mjs.map"],"mappings":";;;;;;;;;;;;;;;AAcA,SAAS,gBAAgB,OAAO;CAC/B,IAAI,MAAM,QAAQ,KAAK,GAAG,OAAO,IAAI,MAAM,IAAI,eAAe,CAAC,CAAC,KAAK,GAAG,EAAE;CAC1E,IAAI,SAAS,OAAO,UAAU,UAAU,OAAO,IAAI,OAAO,QAAQ,KAAK,CAAC,CAAC,MAAM,CAAC,O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IAAiI;CACvN,IAAI,YAAY,KAAK,GAAG,OAAO,mBAAmB,WAAW,QAAQ,WAAW,QAAQ,YAAY,OAAO;CAC3G,OAAO,mBAAmB,WAAW,QAAQ,WAAW,QAAQ,UAAU;AAC3E"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { o as MongoIndex } from "./entity-kinds-RooUvcN8-B1AF_ppw.mjs";
|
|
2
|
-
import { g as validateMongoStorage, l as buildMongoStorage, m as mongoValueSetsOf } from "./dist-
|
|
3
|
-
import { i as pairMongoBackRelations } from "./interpreter-
|
|
2
|
+
import { g as validateMongoStorage, l as buildMongoStorage, m as mongoValueSetsOf } from "./dist-K-Zzlzm5.mjs";
|
|
3
|
+
import { i as pairMongoBackRelations } from "./interpreter-CHQQ4WDf-UuxfVRi6.mjs";
|
|
4
4
|
import { isStructuredError } from "@prisma/orm-framework/utils/structured-error";
|
|
5
|
+
import { blindCast } from "@prisma/orm-framework/utils/casts";
|
|
5
6
|
import { crossRef } from "@prisma/orm-framework/contract/types";
|
|
6
7
|
import { buildExecutionSection, computeProfileHash } from "@prisma/orm-framework/contract/hashing";
|
|
7
|
-
import { blindCast } from "@prisma/orm-framework/utils/casts";
|
|
8
8
|
import { readFile, readdir, stat } from "node:fs/promises";
|
|
9
9
|
import { applySpecifierDefaultControlPolicy } from "@prisma/orm-framework/contract/apply-specifier-default-control-policy";
|
|
10
10
|
import { validateContractDomain } from "@prisma/orm-framework/contract/validate-domain";
|
package/dist/contract-psl.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Contract, ContractReferenceRelation } from "@prisma/orm-framework/contract/types";
|
|
2
1
|
import { CodecLookupWithDescriptors } from "@prisma/orm-framework/components/codec";
|
|
2
|
+
import { Contract, ContractReferenceRelation } from "@prisma/orm-framework/contract/types";
|
|
3
3
|
import { DocumentAst, PslSources } from "@prisma/orm-framework/psl-parser/syntax";
|
|
4
4
|
import { Result } from "@prisma/orm-framework/utils/result";
|
|
5
5
|
import { AuthoringContributions, DataTypeSupport } from "@prisma/orm-framework/components/authoring";
|
package/dist/contract-psl.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { i as pairMongoBackRelations, n as interpretPslDocumentToMongoContract, r as mongoAttributeSpecs, t as describeUnsupportedMongoAttribute } from "./interpreter-
|
|
1
|
+
import { i as pairMongoBackRelations, n as interpretPslDocumentToMongoContract, r as mongoAttributeSpecs, t as describeUnsupportedMongoAttribute } from "./interpreter-CHQQ4WDf-UuxfVRi6.mjs";
|
|
2
2
|
import { t as describeUnresolvedMongoType } from "./dist-xk_0xOR-.mjs";
|
|
3
3
|
export { describeUnresolvedMongoType, describeUnsupportedMongoAttribute, interpretPslDocumentToMongoContract, mongoAttributeSpecs, pairMongoBackRelations };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as interpretPslDocumentToMongoContract } from "./interpreter-
|
|
1
|
+
import { n as interpretPslDocumentToMongoContract } from "./interpreter-CHQQ4WDf-UuxfVRi6.mjs";
|
|
2
2
|
import { assertDefined } from "@prisma/orm-framework/utils/assertions";
|
|
3
3
|
import { readFile } from "node:fs/promises";
|
|
4
4
|
import { parse } from "@prisma/orm-framework/psl-parser/syntax";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract-psl__provider.mjs","names":[],"sources":["../../../../2-mongo-family/2-authoring/contract-psl/dist/exports/provider.mjs"],"sourcesContent":["import { t as interpretPslDocumentToMongoContract } from \"../interpreter-
|
|
1
|
+
{"version":3,"file":"contract-psl__provider.mjs","names":[],"sources":["../../../../2-mongo-family/2-authoring/contract-psl/dist/exports/provider.mjs"],"sourcesContent":["import { t as interpretPslDocumentToMongoContract } from \"../interpreter-CHQQ4WDf.mjs\";\nimport { collectScalarTypeConstructors } from \"@internal/framework-components/authoring\";\nimport { buildSymbolTable, createBinder, isPrismaNextSchema, mapPslDiagnostics } from \"@internal/psl-parser\";\nimport { withSeedDiagnostics } from \"@internal/psl-parser/interpret\";\nimport { parse } from \"@internal/psl-parser/syntax\";\nimport { assertDefined } from \"@internal/utils/assertions\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { notOk } from \"@internal/utils/result\";\nimport { readFile } from \"node:fs/promises\";\n//#region src/provider.ts\nfunction collectScalarTypeCodecIds(namespace) {\n\treturn new Map([...collectScalarTypeConstructors(namespace)].map(([name, output]) => [name, output.codecId]));\n}\nfunction mongoContract(schemaPath, options) {\n\treturn {\n\t\tsource: {\n\t\t\tformat: \"psl\",\n\t\t\tinputs: [schemaPath],\n\t\t\tinterpret(input, context) {\n\t\t\t\treturn interpretPslDocumentToMongoContract({\n\t\t\t\t\tdocuments: input.documents,\n\t\t\t\t\tsymbolTable: input.symbolTable,\n\t\t\t\t\tsources: input.sources,\n\t\t\t\t\tbinder: input.binder,\n\t\t\t\t\tseedDiagnostics: [],\n\t\t\t\t\tscalarTypeCodecIds: collectScalarTypeCodecIds(context.authoringContributions.type),\n\t\t\t\t\tdefaultFunctionRegistry: context.controlMutationDefaults.defaultFunctionRegistry,\n\t\t\t\t\tdataTypes: context.dataTypes,\n\t\t\t\t\tcodecLookup: context.codecLookup,\n\t\t\t\t\tauthoringContributions: context.authoringContributions,\n\t\t\t\t\t...ifDefined(\"enumInferenceCodecs\", options?.enumInferenceCodecs),\n\t\t\t\t\t...ifDefined(\"reportWarning\", context.reportWarning)\n\t\t\t\t});\n\t\t\t},\n\t\t\tasync load(context) {\n\t\t\t\tconst candidates = [...new Set(context.resolvedInputs)].sort();\n\t\t\t\tif (candidates.length === 0) return notOk({\n\t\t\t\t\tsummary: \"No schema files matched the configured contract source\",\n\t\t\t\t\tdiagnostics: [{\n\t\t\t\t\t\tcode: \"PSL_NO_SCHEMA_FILES_MATCHED\",\n\t\t\t\t\t\tmessage: `No files matched the configured pattern \"${schemaPath}\"`,\n\t\t\t\t\t\tsourceId: schemaPath\n\t\t\t\t\t}]\n\t\t\t\t});\n\t\t\t\tconst readDiagnostics = [];\n\t\t\t\tconst members = [];\n\t\t\t\tconst undirected = [];\n\t\t\t\tfor (const path of candidates) {\n\t\t\t\t\tlet text;\n\t\t\t\t\ttry {\n\t\t\t\t\t\ttext = await readFile(path, \"utf-8\");\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tconst message = String(error);\n\t\t\t\t\t\treadDiagnostics.push({\n\t\t\t\t\t\t\tcode: \"PSL_SCHEMA_READ_FAILED\",\n\t\t\t\t\t\t\tmessage,\n\t\t\t\t\t\t\tsourceId: path\n\t\t\t\t\t\t});\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tif (isPrismaNextSchema(text)) members.push({\n\t\t\t\t\t\tpath,\n\t\t\t\t\t\ttext\n\t\t\t\t\t});\n\t\t\t\t\telse undirected.push(path);\n\t\t\t\t}\n\t\t\t\tif (members.length === 0) {\n\t\t\t\t\tif (undirected.length === 0) return notOk({\n\t\t\t\t\t\tsummary: \"Failed to read Prisma schema files\",\n\t\t\t\t\t\tdiagnostics: readDiagnostics\n\t\t\t\t\t});\n\t\t\t\t\treturn notOk({\n\t\t\t\t\t\tsummary: \"No schema file carries the \\\"// use prisma-8\\\" directive\",\n\t\t\t\t\t\tdiagnostics: [...readDiagnostics, {\n\t\t\t\t\t\t\tcode: \"PSL_NO_OPTED_IN_SCHEMA_FILES\",\n\t\t\t\t\t\t\tmessage: `None of the matched files carry the \"// use prisma-8\" directive: ${undirected.join(\", \")}`,\n\t\t\t\t\t\t\tsourceId: schemaPath\n\t\t\t\t\t\t}]\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tconst parsed = members.map(({ path, text }) => parse(text, path));\n\t\t\t\tconst documents = parsed.map(({ document }) => document);\n\t\t\t\tconst [firstSources, ...restSources] = parsed.map(({ sources }) => sources);\n\t\t\t\tassertDefined(firstSources, \"mongoContract requires at least one parsed schema file\");\n\t\t\t\tconst sources = firstSources.merge(...restSources);\n\t\t\t\tconst seedDiagnostics = [...readDiagnostics, ...mapPslDiagnostics(parsed.flatMap(({ diagnostics }) => diagnostics), sources)];\n\t\t\t\tconst { symbolTable, diagnostics: symbolTableDiagnostics } = buildSymbolTable({\n\t\t\t\t\tdocuments,\n\t\t\t\t\tsources,\n\t\t\t\t\tdefaultNamespaceId: context.defaultNamespaceId\n\t\t\t\t});\n\t\t\t\tconst { binder, diagnostics: binderDiagnostics } = createBinder({\n\t\t\t\t\tsymbolTable,\n\t\t\t\t\tsources,\n\t\t\t\t\tcontext\n\t\t\t\t});\n\t\t\t\treturn withSeedDiagnostics(this.interpret({\n\t\t\t\t\tdocuments,\n\t\t\t\t\tsources,\n\t\t\t\t\tsymbolTable,\n\t\t\t\t\tbinder\n\t\t\t\t}, context), [...seedDiagnostics, ...mapPslDiagnostics([...symbolTableDiagnostics, ...binderDiagnostics], sources)]);\n\t\t\t}\n\t\t},\n\t\t...ifDefined(\"output\", options?.output)\n\t};\n}\n//#endregion\nexport { mongoContract };\n\n//# sourceMappingURL=provider.mjs.map"],"mappings":";;;;;;;;;;AAUA,SAAS,0BAA0B,WAAW;CAC7C,OAAO,IAAI,IAAI,CAAC,GAAG,8BAA8B,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,YAAY,CAAC,MAAM,OAAO,OAAO,CAAC,CAAC;AAC7G;AACA,SAAS,cAAc,YAAY,SAAS;CAC3C,OAAO;EACN,QAAQ;GACP,QAAQ;GACR,QAAQ,CAAC,UAAU;GACnB,UAAU,OAAO,SAAS;IACzB,OAAO,oCAAoC;KAC1C,WAAW,MAAM;KACjB,aAAa,MAAM;KACnB,SAAS,MAAM;KACf,QAAQ,MAAM;KACd,iBAAiB,CAAC;KAClB,oBAAoB,0BAA0B,QAAQ,uBAAuB,IAAI;KACjF,yBAAyB,QAAQ,wBAAwB;KACzD,WAAW,QAAQ;KACnB,aAAa,QAAQ;KACrB,wBAAwB,QAAQ;KAChC,GAAG,UAAU,uBAAuB,SAAS,mBAAmB;KAChE,GAAG,UAAU,iBAAiB,QAAQ,aAAa;IACpD,C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GAAG,OAAO,CAAC;IAC5H,MAAM,EAAE,aAAa,aAAa,2BAA2B,iBAAiB;KAC7E;KACA;KACA,oBAAoB,QAAQ;IAC7B,CAAC;IACD,MAAM,EAAE,QAAQ,aAAa,sBAAsB,aAAa;KAC/D;KACA;KACA;IACD,CAAC;IACD,OAAO,oBAAoB,KAAK,UAAU;KACzC;KACA;KACA;KACA;IACD,GAAG,OAAO,GAAG,CAAC,GAAG,iBAAiB,GAAG,kBAAkB,CAAC,GAAG,wBAAwB,GAAG,iBAAiB,GAAG,OAAO,CAAC,CAAC;GACpH;EACD;EACA,GAAG,UAAU,UAAU,SAAS,MAAM;CACvC;AACD"}
|
package/dist/contract-ts.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { n as typescriptContractFromPath, t as typescriptContract } from "./config-types-x4rKdA0F.mjs";
|
|
2
|
-
import { a as field, c as member, d as valueObject, i as enumType, l as model, n as buildBoundContract, o as index, r as defineContract, s as isEnumTypeHandle, t as bindEnumType, u as rel } from "./contract-builder-
|
|
2
|
+
import { a as field, c as member, d as valueObject, i as enumType, l as model, n as buildBoundContract, o as index, r as defineContract, s as isEnumTypeHandle, t as bindEnumType, u as rel } from "./contract-builder-DYeV4YqF.mjs";
|
|
3
3
|
export { bindEnumType, buildBoundContract, defineContract, enumType, field, index, isEnumTypeHandle, member, model, rel, typescriptContract, typescriptContractFromPath, valueObject };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as field, c as member, d as valueObject, i as enumType, l as model, n as buildBoundContract, o as index, r as defineContract, s as isEnumTypeHandle, t as bindEnumType, u as rel } from "./contract-builder-
|
|
1
|
+
import { a as field, c as member, d as valueObject, i as enumType, l as model, n as buildBoundContract, o as index, r as defineContract, s as isEnumTypeHandle, t as bindEnumType, u as rel } from "./contract-builder-DYeV4YqF.mjs";
|
|
2
2
|
export { bindEnumType, buildBoundContract, defineContract, enumType, field, index, isEnumTypeHandle, member, model, rel, valueObject };
|
package/dist/contract.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { a as MongoContractSchema, c as MongoTimeSeriesCollectionOptions, d as StorageValueSetSchema, h as createMongoNamespaceEnvelopeSchema, i as MongoCollectionOptions, l as MongoValidator, m as createMongoContractSchema, n as MongoCollationOptions, o as MongoIndex, r as MongoCollection, s as MongoIndexOptionDefaults, t as MongoChangeStreamPreAndPostImagesOptions, u as MongoValueSet } from "./entity-kinds-RooUvcN8-B1AF_ppw.mjs";
|
|
2
|
-
import { _ as validatorEnumMemberRefusalOf, a as RelationKeys, c as buildMongoNamespace, d as defaultMongoStorageNamespaceId, f as deriveCollectionValidators, g as validateMongoStorage, h as resolveMongoToOneRelationFields, i as MongoUnboundNamespace, l as buildMongoStorage, m as mongoValueSetsOf, n as MongoIndexOptions, o as applyPolymorphicScopeToMongoIndex, p as documentIdRefusalOf, r as MongoStorage, s as buildMongoContractView, t as MongoClusteredCollectionOptions, u as defaultMongoDomainNamespaceId, v as validatorEnumRefusalOf } from "./dist-
|
|
2
|
+
import { _ as validatorEnumMemberRefusalOf, a as RelationKeys, c as buildMongoNamespace, d as defaultMongoStorageNamespaceId, f as deriveCollectionValidators, g as validateMongoStorage, h as resolveMongoToOneRelationFields, i as MongoUnboundNamespace, l as buildMongoStorage, m as mongoValueSetsOf, n as MongoIndexOptions, o as applyPolymorphicScopeToMongoIndex, p as documentIdRefusalOf, r as MongoStorage, s as buildMongoContractView, t as MongoClusteredCollectionOptions, u as defaultMongoDomainNamespaceId, v as validatorEnumRefusalOf } from "./dist-K-Zzlzm5.mjs";
|
|
3
3
|
export { MongoChangeStreamPreAndPostImagesOptions, MongoClusteredCollectionOptions, MongoCollationOptions, MongoCollection, MongoCollectionOptions, MongoContractSchema, MongoIndex, MongoIndexOptionDefaults, MongoIndexOptions, MongoStorage, MongoTimeSeriesCollectionOptions, MongoUnboundNamespace, MongoValidator, MongoValueSet, RelationKeys, StorageValueSetSchema, applyPolymorphicScopeToMongoIndex, buildMongoContractView, buildMongoNamespace, buildMongoStorage, createMongoContractSchema, createMongoNamespaceEnvelopeSchema, defaultMongoDomainNamespaceId, defaultMongoStorageNamespaceId, deriveCollectionValidators, documentIdRefusalOf, mongoValueSetsOf, resolveMongoToOneRelationFields, validateMongoStorage, validatorEnumMemberRefusalOf, validatorEnumRefusalOf };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { t as mongoContractCanonicalizationHooks } from "./canonicalization-hooks-CRVM-Kqh-Qi-VmEVg.mjs";
|
|
2
|
-
import { r as mongoAttributeSpecs, t as describeUnsupportedMongoAttribute } from "./interpreter-
|
|
2
|
+
import { r as mongoAttributeSpecs, t as describeUnsupportedMongoAttribute } from "./interpreter-CHQQ4WDf-UuxfVRi6.mjs";
|
|
3
3
|
import { t as describeUnresolvedMongoType } from "./dist-xk_0xOR-.mjs";
|
|
4
4
|
import { t as mongoEmission } from "./exports-C32AbWNp.mjs";
|
|
5
5
|
import { et as RawUpdateManyCommand } from "./execution-CgP1Sdbr.mjs";
|
|
6
|
-
import { i as verifyMongoSchema } from "./verify-mongo-schema-BTj4mddD-
|
|
7
|
-
import { n as mongoFamilyPslBlockDescriptors, t as mongoFamilyEntityTypes } from "./authoring-entity-types-
|
|
8
|
-
import { t as MongoContractSerializer } from "./mongo-contract-serializer-5OphMWx2-
|
|
6
|
+
import { i as verifyMongoSchema } from "./verify-mongo-schema-BTj4mddD-75_ALNmN.mjs";
|
|
7
|
+
import { n as mongoFamilyPslBlockDescriptors, t as mongoFamilyEntityTypes } from "./authoring-entity-types-C4WFd_RV-BiY2lX_e.mjs";
|
|
8
|
+
import { t as MongoContractSerializer } from "./mongo-contract-serializer-5OphMWx2-BlW2zlIQ.mjs";
|
|
9
9
|
import { structuredError } from "@prisma/orm-framework/utils/structured-error";
|
|
10
10
|
import { blindCast } from "@prisma/orm-framework/utils/casts";
|
|
11
11
|
import { InternalError } from "@prisma/orm-framework/utils/internal-error";
|
|
@@ -493,4 +493,4 @@ const mongoFamilyDescriptor = new MongoFamilyDescriptor();
|
|
|
493
493
|
//#endregion
|
|
494
494
|
export { mongoOperationsToPreview as a, mongoFamilyDescriptor as i, fieldRewriteOf as n, formatMongoOperations as r, createMongoFamilyInstance as t };
|
|
495
495
|
|
|
496
|
-
//# sourceMappingURL=control-
|
|
496
|
+
//# sourceMappingURL=control-Dr88-3gg.mjs.map
|