@prisma/orm-family-mongo 0.17.0-dev.5 → 0.17.0-dev.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  import { t as mongoContractCanonicalizationHooks } from "./canonicalization-hooks-DF3Z6sjO.mjs";
2
- import { t as mongoEmission } from "./exports-CJMh0VTU.mjs";
2
+ import { t as mongoEmission } from "./exports-C4RGBGzZ.mjs";
3
3
  import { i as verifyMongoSchema } from "./verify-mongo-schema-De0FG2Rm-CCzwnNPY.mjs";
4
4
  import { n as mongoFamilyPslBlockDescriptors, t as mongoFamilyEntityTypes } from "./authoring-entity-types-BGtkMyoN-D32kzx28.mjs";
5
5
  import { t as MongoContractSerializer } from "./mongo-contract-serializer-Cx7Fae8e-C8ZYPXpc.mjs";
@@ -395,4 +395,4 @@ const mongoFamilyDescriptor = new MongoFamilyDescriptor();
395
395
  //#endregion
396
396
  export { mongoOperationsToPreview as i, formatMongoOperations as n, mongoFamilyDescriptor as r, createMongoFamilyInstance as t };
397
397
 
398
- //# sourceMappingURL=control-CFr3tYsg.mjs.map
398
+ //# sourceMappingURL=control-BbZQqmxo.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"control-CFr3tYsg.mjs","names":[],"sources":["../../../../2-mongo-family/9-family/dist/control.mjs"],"sourcesContent":["import { i as contractToMongoSchemaIR, n as canonicalizeSchemasForVerification, r as diffMongoSchemas, t as verifyMongoSchema } from \"./verify-mongo-schema-De0FG2Rm.mjs\";\nimport { n as mongoFamilyPslBlockDescriptors, t as mongoFamilyEntityTypes } from \"./authoring-entity-types-BGtkMyoN.mjs\";\nimport { t as MongoContractSerializer } from \"./mongo-contract-serializer-Cx7Fae8e.mjs\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { mongoEmission } from \"@internal/mongo-emitter\";\nimport { structuredError } from \"@internal/utils/structured-error\";\nimport { APP_SPACE_ID, SchemaTreeNode, VERIFY_CODE_HASH_MISMATCH, VERIFY_CODE_MARKER_MISSING, VERIFY_CODE_TARGET_MISMATCH } from \"@internal/framework-components/control\";\nimport { mongoContractCanonicalizationHooks } from \"@internal/mongo-contract/canonicalization-hooks\";\nimport { assertDescriptorSelfConsistency } from \"@internal/migration-tools/spaces\";\nimport { InternalError } from \"@internal/utils/internal-error\";\n//#region src/core/operation-preview.ts\nfunction formatKeySpec(keys) {\n\treturn `{ ${keys.map((k) => `${JSON.stringify(k.field)}: ${JSON.stringify(k.direction)}`).join(\", \")} }`;\n}\nconst COMMAND_META_KEYS = /* @__PURE__ */ new Set([\n\t\"kind\",\n\t\"collection\",\n\t\"keys\"\n]);\nfunction formatOptionEntries(cmd) {\n\tconst parts = Object.entries(cmd).filter(([key, value]) => !COMMAND_META_KEYS.has(key) && value !== void 0).map(([key, value]) => `${key}: ${JSON.stringify(value)}`);\n\tif (parts.length === 0) return void 0;\n\treturn `{ ${parts.join(\", \")} }`;\n}\nfunction formatOptions(cmd) {\n\treturn formatOptionEntries(cmd);\n}\nfunction formatCreateCollectionOptions(cmd) {\n\treturn formatOptionEntries(cmd);\n}\nvar MongoDdlCommandFormatter = class {\n\tcreateIndex(cmd) {\n\t\tconst keySpec = formatKeySpec(cmd.keys);\n\t\tconst opts = formatOptions(cmd);\n\t\treturn opts ? `db.${cmd.collection}.createIndex(${keySpec}, ${opts})` : `db.${cmd.collection}.createIndex(${keySpec})`;\n\t}\n\tdropIndex(cmd) {\n\t\treturn `db.${cmd.collection}.dropIndex(${JSON.stringify(cmd.name)})`;\n\t}\n\tcreateCollection(cmd) {\n\t\tconst opts = formatCreateCollectionOptions(cmd);\n\t\treturn opts ? `db.createCollection(${JSON.stringify(cmd.collection)}, ${opts})` : `db.createCollection(${JSON.stringify(cmd.collection)})`;\n\t}\n\tdropCollection(cmd) {\n\t\treturn `db.${cmd.collection}.drop()`;\n\t}\n\tcollMod(cmd) {\n\t\tconst parts = [`collMod: ${JSON.stringify(cmd.collection)}`];\n\t\tfor (const [key, value] of Object.entries(cmd)) if (!COMMAND_META_KEYS.has(key) && value !== void 0) parts.push(`${key}: ${JSON.stringify(value)}`);\n\t\treturn `db.runCommand({ ${parts.join(\", \")} })`;\n\t}\n};\nconst formatter = new MongoDdlCommandFormatter();\nfunction formatMongoOperations(operations) {\n\tconst statements = [];\n\tfor (const operation of operations) {\n\t\tconst candidate = operation;\n\t\tif (!(\"execute\" in candidate) || !Array.isArray(candidate[\"execute\"])) continue;\n\t\tfor (const step of candidate[\"execute\"]) if (step.command && typeof step.command.accept === \"function\") statements.push(step.command.accept(formatter));\n\t}\n\treturn statements;\n}\n/**\n* Wraps `formatMongoOperations` into the family-agnostic\n* `OperationPreview` shape. Each statement carries\n* `language: 'mongodb-shell'`. Mirrors `sqlOperationsToPreview`.\n*/\nfunction mongoOperationsToPreview(operations) {\n\treturn { statements: formatMongoOperations(operations).map((text) => ({\n\t\ttext,\n\t\tlanguage: \"mongodb-shell\"\n\t})) };\n}\n//#endregion\n//#region src/core/schema-to-view.ts\nfunction mongoSchemaToView(schema) {\n\tconst collectionNodes = schema.collections.map((collection) => collectionToSchemaNode(collection.name, collection));\n\treturn { root: new SchemaTreeNode({\n\t\tkind: \"root\",\n\t\tid: \"mongo-schema\",\n\t\tlabel: \"database\",\n\t\t...ifDefined(\"children\", collectionNodes.length > 0 ? collectionNodes : void 0)\n\t}) };\n}\nfunction collectionToSchemaNode(name, collection) {\n\tconst children = [];\n\tfor (const index of collection.indexes) {\n\t\tconst keysSummary = index.keys.map((k) => {\n\t\t\tif (k.direction === 1) return k.field;\n\t\t\tif (k.direction === -1) return `${k.field} desc`;\n\t\t\treturn `${k.field} ${k.direction}`;\n\t\t}).join(\", \");\n\t\tconst prefix = index.unique ? \"unique index\" : \"index\";\n\t\tconst options = [];\n\t\tif (index.sparse) options.push(\"sparse\");\n\t\tif (index.expireAfterSeconds != null) options.push(`ttl: ${index.expireAfterSeconds}s`);\n\t\tif (index.partialFilterExpression) options.push(\"partial\");\n\t\tconst optsSuffix = options.length > 0 ? ` (${options.join(\", \")})` : \"\";\n\t\tchildren.push(new SchemaTreeNode({\n\t\t\tkind: \"index\",\n\t\t\tid: `index-${name}-${index.keys.map((k) => `${k.field}_${k.direction}`).join(\"_\")}`,\n\t\t\tlabel: `${prefix} (${keysSummary})${optsSuffix}`,\n\t\t\tmeta: {\n\t\t\t\tkeys: index.keys,\n\t\t\t\tunique: index.unique,\n\t\t\t\t...ifDefined(\"sparse\", index.sparse || void 0),\n\t\t\t\t...ifDefined(\"expireAfterSeconds\", index.expireAfterSeconds ?? void 0),\n\t\t\t\t...ifDefined(\"partialFilterExpression\", index.partialFilterExpression ?? void 0)\n\t\t\t}\n\t\t}));\n\t}\n\tif (collection.validator) {\n\t\tconst validatorChildren = [];\n\t\tconst jsonSchema = collection.validator.jsonSchema;\n\t\tconst properties = jsonSchema[\"properties\"];\n\t\tconst required = new Set(jsonSchema[\"required\"] ?? []);\n\t\tif (properties) for (const [propName, propDef] of Object.entries(properties)) {\n\t\t\tconst bsonType = propDef[\"bsonType\"] ?? \"unknown\";\n\t\t\tconst suffix = required.has(propName) ? \" (required)\" : \"\";\n\t\t\tvalidatorChildren.push(new SchemaTreeNode({\n\t\t\t\tkind: \"field\",\n\t\t\t\tid: `field-${name}-${propName}`,\n\t\t\t\tlabel: `${propName}: ${bsonType}${suffix}`\n\t\t\t}));\n\t\t}\n\t\tchildren.push(new SchemaTreeNode({\n\t\t\tkind: \"field\",\n\t\t\tid: `validator-${name}`,\n\t\t\tlabel: `validator (level: ${collection.validator.validationLevel}, action: ${collection.validator.validationAction})`,\n\t\t\tmeta: {\n\t\t\t\tvalidationLevel: collection.validator.validationLevel,\n\t\t\t\tvalidationAction: collection.validator.validationAction,\n\t\t\t\tjsonSchema: collection.validator.jsonSchema\n\t\t\t},\n\t\t\t...ifDefined(\"children\", validatorChildren.length > 0 ? validatorChildren : void 0)\n\t\t}));\n\t}\n\tif (collection.options) {\n\t\tconst opts = collection.options;\n\t\tconst optLabels = [];\n\t\tif (opts.capped) optLabels.push(\"capped\");\n\t\tif (opts.timeseries) optLabels.push(\"timeseries\");\n\t\tif (opts.collation) optLabels.push(\"collation\");\n\t\tif (opts.changeStreamPreAndPostImages) optLabels.push(\"changeStreamPreAndPostImages\");\n\t\tif (opts.clusteredIndex) optLabels.push(\"clusteredIndex\");\n\t\tif (optLabels.length > 0) children.push(new SchemaTreeNode({\n\t\t\tkind: \"field\",\n\t\t\tid: `options-${name}`,\n\t\t\tlabel: `options (${optLabels.join(\", \")})`,\n\t\t\tmeta: {\n\t\t\t\t...ifDefined(\"capped\", opts.capped ?? void 0),\n\t\t\t\t...ifDefined(\"timeseries\", opts.timeseries ?? void 0),\n\t\t\t\t...ifDefined(\"collation\", opts.collation ?? void 0),\n\t\t\t\t...ifDefined(\"changeStreamPreAndPostImages\", opts.changeStreamPreAndPostImages ?? void 0),\n\t\t\t\t...ifDefined(\"clusteredIndex\", opts.clusteredIndex ?? void 0)\n\t\t\t}\n\t\t}));\n\t}\n\treturn new SchemaTreeNode({\n\t\tkind: \"collection\",\n\t\tid: `collection-${name}`,\n\t\tlabel: `collection ${name}`,\n\t\t...ifDefined(\"children\", children.length > 0 ? children : void 0)\n\t});\n}\n//#endregion\n//#region src/core/control-instance.ts\nfunction deserializeMongoContract(contractJson) {\n\treturn new MongoContractSerializer().deserializeContract(contractJson);\n}\n/**\n* Family-method contract input. By the time control-plane methods\n* (`verify`, `verifySchema`, `sign`, …) are invoked through the CLI\n* control client (`client.ts`), the input has already been threaded\n* through `familyInstance.deserializeContract`. The value is therefore a\n* class-form `MongoTargetContract` (or a structurally-equivalent\n* envelope post-deserialization) and must NOT be re-fed through\n* structural validation (arktype rejects extra keys like `namespaces`).\n*\n* The parameter type on the framework SPI is `unknown` for variance\n* reasons (so the family can express its own contract type without\n* leaking it to the framework). This helper recovers the validated\n* shape with a single narrow cast.\n*/\nfunction asValidatedMongoContract(contract) {\n\treturn contract;\n}\nfunction buildVerifyResult(opts) {\n\treturn {\n\t\tok: opts.ok,\n\t\t...ifDefined(\"code\", opts.code),\n\t\tsummary: opts.summary,\n\t\tcontract: {\n\t\t\tstorageHash: opts.contractStorageHash,\n\t\t\t...ifDefined(\"profileHash\", opts.contractProfileHash)\n\t\t},\n\t\t...ifDefined(\"marker\", opts.marker ? {\n\t\t\tstorageHash: opts.marker.storageHash,\n\t\t\tprofileHash: opts.marker.profileHash\n\t\t} : void 0),\n\t\ttarget: {\n\t\t\texpected: opts.expectedTargetId,\n\t\t\t...ifDefined(\"actual\", opts.actualTargetId)\n\t\t},\n\t\tmeta: {\n\t\t\tcontractPath: opts.contractPath,\n\t\t\t...ifDefined(\"configPath\", opts.configPath)\n\t\t},\n\t\ttimings: { total: opts.totalTime }\n\t};\n}\nfunction createMongoFamilyInstance(controlStack) {\n\tconst extensions = controlStack.extensions ?? [];\n\tfor (const extension of extensions) if (extension.contractSpace) {\n\t\tconst { contractJson, headRef } = extension.contractSpace;\n\t\tassertDescriptorSelfConsistency({\n\t\t\textensionId: extension.id,\n\t\t\ttarget: contractJson.target,\n\t\t\ttargetFamily: contractJson.targetFamily,\n\t\t\tstorage: contractJson.storage,\n\t\t\theadRefHash: headRef.hash,\n\t\t\t...mongoContractCanonicalizationHooks\n\t\t});\n\t}\n\tconst adapter = controlStack.adapter;\n\tconst getControlAdapter = () => {\n\t\tif (!adapter) throw new InternalError(\"Mongo family requires an adapter descriptor in ControlStack\");\n\t\treturn adapter.create(controlStack);\n\t};\n\tfunction isMongoTargetDriver(driver) {\n\t\treturn driver.targetId === \"mongo\";\n\t}\n\tfunction asMongoDriver(driver) {\n\t\tif (!isMongoTargetDriver(driver)) throw structuredError(\"CONTRACT.TARGET_MISMATCH\", `Expected Mongo control driver with targetId 'mongo', got '${driver.targetId}'`);\n\t\treturn driver;\n\t}\n\treturn {\n\t\tfamilyId: \"mongo\",\n\t\tdeserializeContract(contractJson) {\n\t\t\treturn deserializeMongoContract(contractJson);\n\t\t},\n\t\tasync verify(options) {\n\t\t\tconst { driver, contract: rawContract, expectedTargetId, contractPath, configPath } = options;\n\t\t\tconst startTime = Date.now();\n\t\t\tconst contract = asValidatedMongoContract(rawContract);\n\t\t\tconst contractStorageHash = contract.storage.storageHash;\n\t\t\tconst contractProfileHash = contract.profileHash;\n\t\t\tconst contractTarget = contract.target;\n\t\t\tconst baseOpts = {\n\t\t\t\tcontractStorageHash,\n\t\t\t\tcontractProfileHash,\n\t\t\t\texpectedTargetId,\n\t\t\t\tcontractPath,\n\t\t\t\t...ifDefined(\"configPath\", configPath)\n\t\t\t};\n\t\t\tif (contractTarget !== expectedTargetId) return buildVerifyResult({\n\t\t\t\t...baseOpts,\n\t\t\t\tok: false,\n\t\t\t\tcode: VERIFY_CODE_TARGET_MISMATCH,\n\t\t\t\tsummary: \"Target mismatch\",\n\t\t\t\tactualTargetId: contractTarget,\n\t\t\t\ttotalTime: Date.now() - startTime\n\t\t\t});\n\t\t\tconst marker = await getControlAdapter().readMarker(asMongoDriver(driver), APP_SPACE_ID);\n\t\t\tif (!marker) return buildVerifyResult({\n\t\t\t\t...baseOpts,\n\t\t\t\tok: false,\n\t\t\t\tcode: VERIFY_CODE_MARKER_MISSING,\n\t\t\t\tsummary: \"Marker missing\",\n\t\t\t\ttotalTime: Date.now() - startTime\n\t\t\t});\n\t\t\tif (marker.storageHash !== contractStorageHash) return buildVerifyResult({\n\t\t\t\t...baseOpts,\n\t\t\t\tok: false,\n\t\t\t\tcode: VERIFY_CODE_HASH_MISMATCH,\n\t\t\t\tsummary: \"Hash mismatch\",\n\t\t\t\tmarker,\n\t\t\t\ttotalTime: Date.now() - startTime\n\t\t\t});\n\t\t\tif (contractProfileHash && marker.profileHash !== contractProfileHash) return buildVerifyResult({\n\t\t\t\t...baseOpts,\n\t\t\t\tok: false,\n\t\t\t\tcode: VERIFY_CODE_HASH_MISMATCH,\n\t\t\t\tsummary: \"Hash mismatch\",\n\t\t\t\tmarker,\n\t\t\t\ttotalTime: Date.now() - startTime\n\t\t\t});\n\t\t\treturn buildVerifyResult({\n\t\t\t\t...baseOpts,\n\t\t\t\tok: true,\n\t\t\t\tsummary: \"Database matches contract\",\n\t\t\t\tmarker,\n\t\t\t\ttotalTime: Date.now() - startTime\n\t\t\t});\n\t\t},\n\t\tverifySchema(options) {\n\t\t\treturn verifyMongoSchema({\n\t\t\t\tcontract: asValidatedMongoContract(options.contract),\n\t\t\t\tschema: options.schema,\n\t\t\t\tstrict: options.strict,\n\t\t\t\tframeworkComponents: options.frameworkComponents\n\t\t\t});\n\t\t},\n\t\tasync sign(options) {\n\t\t\tconst { driver, contract: rawContract, contractPath, configPath } = options;\n\t\t\tconst startTime = Date.now();\n\t\t\tconst contract = asValidatedMongoContract(rawContract);\n\t\t\tconst contractStorageHash = contract.storage.storageHash;\n\t\t\tconst contractProfileHash = contract.profileHash;\n\t\t\tconst controlAdapter = getControlAdapter();\n\t\t\tconst mongoDriver = asMongoDriver(driver);\n\t\t\tconst existingMarker = await controlAdapter.readMarker(mongoDriver, APP_SPACE_ID);\n\t\t\tlet markerCreated = false;\n\t\t\tlet markerUpdated = false;\n\t\t\tlet previousHashes;\n\t\t\tif (!existingMarker) {\n\t\t\t\tawait controlAdapter.initMarker(mongoDriver, APP_SPACE_ID, {\n\t\t\t\t\tstorageHash: contractStorageHash,\n\t\t\t\t\tprofileHash: contractProfileHash\n\t\t\t\t});\n\t\t\t\tmarkerCreated = true;\n\t\t\t} else {\n\t\t\t\tconst storageHashMatches = existingMarker.storageHash === contractStorageHash;\n\t\t\t\tconst profileHashMatches = existingMarker.profileHash === contractProfileHash;\n\t\t\t\tif (!storageHashMatches || !profileHashMatches) {\n\t\t\t\t\tpreviousHashes = {\n\t\t\t\t\t\tstorageHash: existingMarker.storageHash,\n\t\t\t\t\t\tprofileHash: existingMarker.profileHash\n\t\t\t\t\t};\n\t\t\t\t\tif (!await controlAdapter.updateMarker(mongoDriver, APP_SPACE_ID, existingMarker.storageHash, {\n\t\t\t\t\t\tstorageHash: contractStorageHash,\n\t\t\t\t\t\tprofileHash: contractProfileHash\n\t\t\t\t\t})) throw structuredError(\"MIGRATION.MARKER_CAS_FAILURE\", \"CAS conflict: marker was modified by another process during sign\");\n\t\t\t\t\tmarkerUpdated = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\tlet summary;\n\t\t\tif (markerCreated) summary = \"Database signed (marker created)\";\n\t\t\telse if (markerUpdated) summary = `Database signed (marker updated from ${previousHashes?.storageHash ?? \"unknown\"})`;\n\t\t\telse summary = \"Database already signed with this contract\";\n\t\t\treturn {\n\t\t\t\tok: true,\n\t\t\t\tsummary,\n\t\t\t\tcontract: {\n\t\t\t\t\tstorageHash: contractStorageHash,\n\t\t\t\t\tprofileHash: contractProfileHash\n\t\t\t\t},\n\t\t\t\ttarget: {\n\t\t\t\t\texpected: contract.target,\n\t\t\t\t\tactual: contract.target\n\t\t\t\t},\n\t\t\t\tmarker: {\n\t\t\t\t\tcreated: markerCreated,\n\t\t\t\t\tupdated: markerUpdated,\n\t\t\t\t\t...ifDefined(\"previous\", previousHashes)\n\t\t\t\t},\n\t\t\t\tmeta: {\n\t\t\t\t\tcontractPath,\n\t\t\t\t\t...ifDefined(\"configPath\", configPath)\n\t\t\t\t},\n\t\t\t\ttimings: { total: Date.now() - startTime }\n\t\t\t};\n\t\t},\n\t\tasync readMarker(options) {\n\t\t\treturn getControlAdapter().readMarker(asMongoDriver(options.driver), options.space);\n\t\t},\n\t\tasync readAllMarkers(options) {\n\t\t\treturn getControlAdapter().readAllMarkers(asMongoDriver(options.driver));\n\t\t},\n\t\tasync readLedger(options) {\n\t\t\treturn getControlAdapter().readLedger(asMongoDriver(options.driver), options.space);\n\t\t},\n\t\tasync introspect(options) {\n\t\t\treturn getControlAdapter().introspectSchema(asMongoDriver(options.driver));\n\t\t},\n\t\ttoSchemaView(schema) {\n\t\t\treturn mongoSchemaToView(schema);\n\t\t},\n\t\ttoOperationPreview(operations) {\n\t\t\treturn mongoOperationsToPreview(operations);\n\t\t}\n\t};\n}\n//#endregion\n//#region src/core/control-descriptor.ts\nvar MongoFamilyDescriptor = class {\n\tkind = \"family\";\n\tid = \"mongo\";\n\tfamilyId = \"mongo\";\n\tversion = \"0.0.1\";\n\temission = mongoEmission;\n\tauthoring = {\n\t\tentityTypes: mongoFamilyEntityTypes,\n\t\tpslBlockDescriptors: mongoFamilyPslBlockDescriptors\n\t};\n\tcreate(stack) {\n\t\treturn createMongoFamilyInstance(stack);\n\t}\n};\nconst mongoFamilyDescriptor = new MongoFamilyDescriptor();\n//#endregion\nexport { canonicalizeSchemasForVerification, contractToMongoSchemaIR, createMongoFamilyInstance, diffMongoSchemas, formatMongoOperations, mongoFamilyDescriptor, mongoOperationsToPreview };\n\n//# sourceMappingURL=control.mjs.map"],"mappings":";;;;;;;;;;;AAWA,SAAS,cAAc,MAAM;CAC5B,OAAO,KAAK,KAAK,KAAK,MAAM,GAAG,KAAK,UAAU,EAAE,KAAK,EAAE,IAAI,KAAK,UAAU,EAAE,SAAS,GAAG,CAAC,CAAC,KAAK,IAAI,EAAE;AACtG;AACA,MAAM,oCAAoC,IAAI,IAAI;CACjD;CACA;CACA;AACD,CAAC;AACD,SAAS,oBAAoB,KAAK;CACjC,MAAM,QAAQ,OAAO,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC,KAAK,WAAW,CAAC,kBAAkB,IAAI,GAAG,KAAK,UAAU,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,WAAW,GAAG,IAAI,IAAI,KAAK,UAAU,KAAK,GAAG;CACpK,IAAI,MAAM,WAAW,GAAG,OAAO,KAAK;CACpC,OAAO,KAAK,MAAM,KAAK,IAAI,EAAE;AAC9B;AACA,SAAS,cAAc,KAAK;CAC3B,OAAO,oBAAoB,GAAG;AAC/B;AACA,SAAS,8BAA8B,KAAK;CAC3C,OAAO,oBAAoB,GAAG;AAC/B;AACA,IAAI,2BAA2B,MAAM;CACpC,YAAY,KAAK;EAChB,MAAM,UAAU,cAAc,IAAI,IAAI;EACtC,MAAM,OAA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","names":[],"sources":["../../../../2-mongo-family/9-family/dist/control.mjs"],"sourcesContent":["import { i as contractToMongoSchemaIR, n as canonicalizeSchemasForVerification, r as diffMongoSchemas, t as verifyMongoSchema } from \"./verify-mongo-schema-De0FG2Rm.mjs\";\nimport { n as mongoFamilyPslBlockDescriptors, t as mongoFamilyEntityTypes } from \"./authoring-entity-types-BGtkMyoN.mjs\";\nimport { t as MongoContractSerializer } from \"./mongo-contract-serializer-Cx7Fae8e.mjs\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { mongoEmission } from \"@internal/mongo-emitter\";\nimport { structuredError } from \"@internal/utils/structured-error\";\nimport { APP_SPACE_ID, SchemaTreeNode, VERIFY_CODE_HASH_MISMATCH, VERIFY_CODE_MARKER_MISSING, VERIFY_CODE_TARGET_MISMATCH } from \"@internal/framework-components/control\";\nimport { mongoContractCanonicalizationHooks } from \"@internal/mongo-contract/canonicalization-hooks\";\nimport { assertDescriptorSelfConsistency } from \"@internal/migration-tools/spaces\";\nimport { InternalError } from \"@internal/utils/internal-error\";\n//#region src/core/operation-preview.ts\nfunction formatKeySpec(keys) {\n\treturn `{ ${keys.map((k) => `${JSON.stringify(k.field)}: ${JSON.stringify(k.direction)}`).join(\", \")} }`;\n}\nconst COMMAND_META_KEYS = /* @__PURE__ */ new Set([\n\t\"kind\",\n\t\"collection\",\n\t\"keys\"\n]);\nfunction formatOptionEntries(cmd) {\n\tconst parts = Object.entries(cmd).filter(([key, value]) => !COMMAND_META_KEYS.has(key) && value !== void 0).map(([key, value]) => `${key}: ${JSON.stringify(value)}`);\n\tif (parts.length === 0) return void 0;\n\treturn `{ ${parts.join(\", \")} }`;\n}\nfunction formatOptions(cmd) {\n\treturn formatOptionEntries(cmd);\n}\nfunction formatCreateCollectionOptions(cmd) {\n\treturn formatOptionEntries(cmd);\n}\nvar MongoDdlCommandFormatter = class {\n\tcreateIndex(cmd) {\n\t\tconst keySpec = formatKeySpec(cmd.keys);\n\t\tconst opts = formatOptions(cmd);\n\t\treturn opts ? `db.${cmd.collection}.createIndex(${keySpec}, ${opts})` : `db.${cmd.collection}.createIndex(${keySpec})`;\n\t}\n\tdropIndex(cmd) {\n\t\treturn `db.${cmd.collection}.dropIndex(${JSON.stringify(cmd.name)})`;\n\t}\n\tcreateCollection(cmd) {\n\t\tconst opts = formatCreateCollectionOptions(cmd);\n\t\treturn opts ? `db.createCollection(${JSON.stringify(cmd.collection)}, ${opts})` : `db.createCollection(${JSON.stringify(cmd.collection)})`;\n\t}\n\tdropCollection(cmd) {\n\t\treturn `db.${cmd.collection}.drop()`;\n\t}\n\tcollMod(cmd) {\n\t\tconst parts = [`collMod: ${JSON.stringify(cmd.collection)}`];\n\t\tfor (const [key, value] of Object.entries(cmd)) if (!COMMAND_META_KEYS.has(key) && value !== void 0) parts.push(`${key}: ${JSON.stringify(value)}`);\n\t\treturn `db.runCommand({ ${parts.join(\", \")} })`;\n\t}\n};\nconst formatter = new MongoDdlCommandFormatter();\nfunction formatMongoOperations(operations) {\n\tconst statements = [];\n\tfor (const operation of operations) {\n\t\tconst candidate = operation;\n\t\tif (!(\"execute\" in candidate) || !Array.isArray(candidate[\"execute\"])) continue;\n\t\tfor (const step of candidate[\"execute\"]) if (step.command && typeof step.command.accept === \"function\") statements.push(step.command.accept(formatter));\n\t}\n\treturn statements;\n}\n/**\n* Wraps `formatMongoOperations` into the family-agnostic\n* `OperationPreview` shape. Each statement carries\n* `language: 'mongodb-shell'`. Mirrors `sqlOperationsToPreview`.\n*/\nfunction mongoOperationsToPreview(operations) {\n\treturn { statements: formatMongoOperations(operations).map((text) => ({\n\t\ttext,\n\t\tlanguage: \"mongodb-shell\"\n\t})) };\n}\n//#endregion\n//#region src/core/schema-to-view.ts\nfunction mongoSchemaToView(schema) {\n\tconst collectionNodes = schema.collections.map((collection) => collectionToSchemaNode(collection.name, collection));\n\treturn { root: new SchemaTreeNode({\n\t\tkind: \"root\",\n\t\tid: \"mongo-schema\",\n\t\tlabel: \"database\",\n\t\t...ifDefined(\"children\", collectionNodes.length > 0 ? collectionNodes : void 0)\n\t}) };\n}\nfunction collectionToSchemaNode(name, collection) {\n\tconst children = [];\n\tfor (const index of collection.indexes) {\n\t\tconst keysSummary = index.keys.map((k) => {\n\t\t\tif (k.direction === 1) return k.field;\n\t\t\tif (k.direction === -1) return `${k.field} desc`;\n\t\t\treturn `${k.field} ${k.direction}`;\n\t\t}).join(\", \");\n\t\tconst prefix = index.unique ? \"unique index\" : \"index\";\n\t\tconst options = [];\n\t\tif (index.sparse) options.push(\"sparse\");\n\t\tif (index.expireAfterSeconds != null) options.push(`ttl: ${index.expireAfterSeconds}s`);\n\t\tif (index.partialFilterExpression) options.push(\"partial\");\n\t\tconst optsSuffix = options.length > 0 ? ` (${options.join(\", \")})` : \"\";\n\t\tchildren.push(new SchemaTreeNode({\n\t\t\tkind: \"index\",\n\t\t\tid: `index-${name}-${index.keys.map((k) => `${k.field}_${k.direction}`).join(\"_\")}`,\n\t\t\tlabel: `${prefix} (${keysSummary})${optsSuffix}`,\n\t\t\tmeta: {\n\t\t\t\tkeys: index.keys,\n\t\t\t\tunique: index.unique,\n\t\t\t\t...ifDefined(\"sparse\", index.sparse || void 0),\n\t\t\t\t...ifDefined(\"expireAfterSeconds\", index.expireAfterSeconds ?? void 0),\n\t\t\t\t...ifDefined(\"partialFilterExpression\", index.partialFilterExpression ?? void 0)\n\t\t\t}\n\t\t}));\n\t}\n\tif (collection.validator) {\n\t\tconst validatorChildren = [];\n\t\tconst jsonSchema = collection.validator.jsonSchema;\n\t\tconst properties = jsonSchema[\"properties\"];\n\t\tconst required = new Set(jsonSchema[\"required\"] ?? []);\n\t\tif (properties) for (const [propName, propDef] of Object.entries(properties)) {\n\t\t\tconst bsonType = propDef[\"bsonType\"] ?? \"unknown\";\n\t\t\tconst suffix = required.has(propName) ? \" (required)\" : \"\";\n\t\t\tvalidatorChildren.push(new SchemaTreeNode({\n\t\t\t\tkind: \"field\",\n\t\t\t\tid: `field-${name}-${propName}`,\n\t\t\t\tlabel: `${propName}: ${bsonType}${suffix}`\n\t\t\t}));\n\t\t}\n\t\tchildren.push(new SchemaTreeNode({\n\t\t\tkind: \"field\",\n\t\t\tid: `validator-${name}`,\n\t\t\tlabel: `validator (level: ${collection.validator.validationLevel}, action: ${collection.validator.validationAction})`,\n\t\t\tmeta: {\n\t\t\t\tvalidationLevel: collection.validator.validationLevel,\n\t\t\t\tvalidationAction: collection.validator.validationAction,\n\t\t\t\tjsonSchema: collection.validator.jsonSchema\n\t\t\t},\n\t\t\t...ifDefined(\"children\", validatorChildren.length > 0 ? validatorChildren : void 0)\n\t\t}));\n\t}\n\tif (collection.options) {\n\t\tconst opts = collection.options;\n\t\tconst optLabels = [];\n\t\tif (opts.capped) optLabels.push(\"capped\");\n\t\tif (opts.timeseries) optLabels.push(\"timeseries\");\n\t\tif (opts.collation) optLabels.push(\"collation\");\n\t\tif (opts.changeStreamPreAndPostImages) optLabels.push(\"changeStreamPreAndPostImages\");\n\t\tif (opts.clusteredIndex) optLabels.push(\"clusteredIndex\");\n\t\tif (optLabels.length > 0) children.push(new SchemaTreeNode({\n\t\t\tkind: \"field\",\n\t\t\tid: `options-${name}`,\n\t\t\tlabel: `options (${optLabels.join(\", \")})`,\n\t\t\tmeta: {\n\t\t\t\t...ifDefined(\"capped\", opts.capped ?? void 0),\n\t\t\t\t...ifDefined(\"timeseries\", opts.timeseries ?? void 0),\n\t\t\t\t...ifDefined(\"collation\", opts.collation ?? void 0),\n\t\t\t\t...ifDefined(\"changeStreamPreAndPostImages\", opts.changeStreamPreAndPostImages ?? void 0),\n\t\t\t\t...ifDefined(\"clusteredIndex\", opts.clusteredIndex ?? void 0)\n\t\t\t}\n\t\t}));\n\t}\n\treturn new SchemaTreeNode({\n\t\tkind: \"collection\",\n\t\tid: `collection-${name}`,\n\t\tlabel: `collection ${name}`,\n\t\t...ifDefined(\"children\", children.length > 0 ? children : void 0)\n\t});\n}\n//#endregion\n//#region src/core/control-instance.ts\nfunction deserializeMongoContract(contractJson) {\n\treturn new MongoContractSerializer().deserializeContract(contractJson);\n}\n/**\n* Family-method contract input. By the time control-plane methods\n* (`verify`, `verifySchema`, `sign`, …) are invoked through the CLI\n* control client (`client.ts`), the input has already been threaded\n* through `familyInstance.deserializeContract`. The value is therefore a\n* class-form `MongoTargetContract` (or a structurally-equivalent\n* envelope post-deserialization) and must NOT be re-fed through\n* structural validation (arktype rejects extra keys like `namespaces`).\n*\n* The parameter type on the framework SPI is `unknown` for variance\n* reasons (so the family can express its own contract type without\n* leaking it to the framework). This helper recovers the validated\n* shape with a single narrow cast.\n*/\nfunction asValidatedMongoContract(contract) {\n\treturn contract;\n}\nfunction buildVerifyResult(opts) {\n\treturn {\n\t\tok: opts.ok,\n\t\t...ifDefined(\"code\", opts.code),\n\t\tsummary: opts.summary,\n\t\tcontract: {\n\t\t\tstorageHash: opts.contractStorageHash,\n\t\t\t...ifDefined(\"profileHash\", opts.contractProfileHash)\n\t\t},\n\t\t...ifDefined(\"marker\", opts.marker ? {\n\t\t\tstorageHash: opts.marker.storageHash,\n\t\t\tprofileHash: opts.marker.profileHash\n\t\t} : void 0),\n\t\ttarget: {\n\t\t\texpected: opts.expectedTargetId,\n\t\t\t...ifDefined(\"actual\", opts.actualTargetId)\n\t\t},\n\t\tmeta: {\n\t\t\tcontractPath: opts.contractPath,\n\t\t\t...ifDefined(\"configPath\", opts.configPath)\n\t\t},\n\t\ttimings: { total: opts.totalTime }\n\t};\n}\nfunction createMongoFamilyInstance(controlStack) {\n\tconst extensions = controlStack.extensions ?? [];\n\tfor (const extension of extensions) if (extension.contractSpace) {\n\t\tconst { contractJson, headRef } = extension.contractSpace;\n\t\tassertDescriptorSelfConsistency({\n\t\t\textensionId: extension.id,\n\t\t\ttarget: contractJson.target,\n\t\t\ttargetFamily: contractJson.targetFamily,\n\t\t\tstorage: contractJson.storage,\n\t\t\theadRefHash: headRef.hash,\n\t\t\t...mongoContractCanonicalizationHooks\n\t\t});\n\t}\n\tconst adapter = controlStack.adapter;\n\tconst getControlAdapter = () => {\n\t\tif (!adapter) throw new InternalError(\"Mongo family requires an adapter descriptor in ControlStack\");\n\t\treturn adapter.create(controlStack);\n\t};\n\tfunction isMongoTargetDriver(driver) {\n\t\treturn driver.targetId === \"mongo\";\n\t}\n\tfunction asMongoDriver(driver) {\n\t\tif (!isMongoTargetDriver(driver)) throw structuredError(\"CONTRACT.TARGET_MISMATCH\", `Expected Mongo control driver with targetId 'mongo', got '${driver.targetId}'`);\n\t\treturn driver;\n\t}\n\treturn {\n\t\tfamilyId: \"mongo\",\n\t\tdeserializeContract(contractJson) {\n\t\t\treturn deserializeMongoContract(contractJson);\n\t\t},\n\t\tasync verify(options) {\n\t\t\tconst { driver, contract: rawContract, expectedTargetId, contractPath, configPath } = options;\n\t\t\tconst startTime = Date.now();\n\t\t\tconst contract = asValidatedMongoContract(rawContract);\n\t\t\tconst contractStorageHash = contract.storage.storageHash;\n\t\t\tconst contractProfileHash = contract.profileHash;\n\t\t\tconst contractTarget = contract.target;\n\t\t\tconst baseOpts = {\n\t\t\t\tcontractStorageHash,\n\t\t\t\tcontractProfileHash,\n\t\t\t\texpectedTargetId,\n\t\t\t\tcontractPath,\n\t\t\t\t...ifDefined(\"configPath\", configPath)\n\t\t\t};\n\t\t\tif (contractTarget !== expectedTargetId) return buildVerifyResult({\n\t\t\t\t...baseOpts,\n\t\t\t\tok: false,\n\t\t\t\tcode: VERIFY_CODE_TARGET_MISMATCH,\n\t\t\t\tsummary: \"Target mismatch\",\n\t\t\t\tactualTargetId: contractTarget,\n\t\t\t\ttotalTime: Date.now() - startTime\n\t\t\t});\n\t\t\tconst marker = await getControlAdapter().readMarker(asMongoDriver(driver), APP_SPACE_ID);\n\t\t\tif (!marker) return buildVerifyResult({\n\t\t\t\t...baseOpts,\n\t\t\t\tok: false,\n\t\t\t\tcode: VERIFY_CODE_MARKER_MISSING,\n\t\t\t\tsummary: \"Marker missing\",\n\t\t\t\ttotalTime: Date.now() - startTime\n\t\t\t});\n\t\t\tif (marker.storageHash !== contractStorageHash) return buildVerifyResult({\n\t\t\t\t...baseOpts,\n\t\t\t\tok: false,\n\t\t\t\tcode: VERIFY_CODE_HASH_MISMATCH,\n\t\t\t\tsummary: \"Hash mismatch\",\n\t\t\t\tmarker,\n\t\t\t\ttotalTime: Date.now() - startTime\n\t\t\t});\n\t\t\tif (contractProfileHash && marker.profileHash !== contractProfileHash) return buildVerifyResult({\n\t\t\t\t...baseOpts,\n\t\t\t\tok: false,\n\t\t\t\tcode: VERIFY_CODE_HASH_MISMATCH,\n\t\t\t\tsummary: \"Hash mismatch\",\n\t\t\t\tmarker,\n\t\t\t\ttotalTime: Date.now() - startTime\n\t\t\t});\n\t\t\treturn buildVerifyResult({\n\t\t\t\t...baseOpts,\n\t\t\t\tok: true,\n\t\t\t\tsummary: \"Database matches contract\",\n\t\t\t\tmarker,\n\t\t\t\ttotalTime: Date.now() - startTime\n\t\t\t});\n\t\t},\n\t\tverifySchema(options) {\n\t\t\treturn verifyMongoSchema({\n\t\t\t\tcontract: asValidatedMongoContract(options.contract),\n\t\t\t\tschema: options.schema,\n\t\t\t\tstrict: options.strict,\n\t\t\t\tframeworkComponents: options.frameworkComponents\n\t\t\t});\n\t\t},\n\t\tasync sign(options) {\n\t\t\tconst { driver, contract: rawContract, contractPath, configPath } = options;\n\t\t\tconst startTime = Date.now();\n\t\t\tconst contract = asValidatedMongoContract(rawContract);\n\t\t\tconst contractStorageHash = contract.storage.storageHash;\n\t\t\tconst contractProfileHash = contract.profileHash;\n\t\t\tconst controlAdapter = getControlAdapter();\n\t\t\tconst mongoDriver = asMongoDriver(driver);\n\t\t\tconst existingMarker = await controlAdapter.readMarker(mongoDriver, APP_SPACE_ID);\n\t\t\tlet markerCreated = false;\n\t\t\tlet markerUpdated = false;\n\t\t\tlet previousHashes;\n\t\t\tif (!existingMarker) {\n\t\t\t\tawait controlAdapter.initMarker(mongoDriver, APP_SPACE_ID, {\n\t\t\t\t\tstorageHash: contractStorageHash,\n\t\t\t\t\tprofileHash: contractProfileHash\n\t\t\t\t});\n\t\t\t\tmarkerCreated = true;\n\t\t\t} else {\n\t\t\t\tconst storageHashMatches = existingMarker.storageHash === contractStorageHash;\n\t\t\t\tconst profileHashMatches = existingMarker.profileHash === contractProfileHash;\n\t\t\t\tif (!storageHashMatches || !profileHashMatches) {\n\t\t\t\t\tpreviousHashes = {\n\t\t\t\t\t\tstorageHash: existingMarker.storageHash,\n\t\t\t\t\t\tprofileHash: existingMarker.profileHash\n\t\t\t\t\t};\n\t\t\t\t\tif (!await controlAdapter.updateMarker(mongoDriver, APP_SPACE_ID, existingMarker.storageHash, {\n\t\t\t\t\t\tstorageHash: contractStorageHash,\n\t\t\t\t\t\tprofileHash: contractProfileHash\n\t\t\t\t\t})) throw structuredError(\"MIGRATION.MARKER_CAS_FAILURE\", \"CAS conflict: marker was modified by another process during sign\");\n\t\t\t\t\tmarkerUpdated = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\tlet summary;\n\t\t\tif (markerCreated) summary = \"Database signed (marker created)\";\n\t\t\telse if (markerUpdated) summary = `Database signed (marker updated from ${previousHashes?.storageHash ?? \"unknown\"})`;\n\t\t\telse summary = \"Database already signed with this contract\";\n\t\t\treturn {\n\t\t\t\tok: true,\n\t\t\t\tsummary,\n\t\t\t\tcontract: {\n\t\t\t\t\tstorageHash: contractStorageHash,\n\t\t\t\t\tprofileHash: contractProfileHash\n\t\t\t\t},\n\t\t\t\ttarget: {\n\t\t\t\t\texpected: contract.target,\n\t\t\t\t\tactual: contract.target\n\t\t\t\t},\n\t\t\t\tmarker: {\n\t\t\t\t\tcreated: markerCreated,\n\t\t\t\t\tupdated: markerUpdated,\n\t\t\t\t\t...ifDefined(\"previous\", previousHashes)\n\t\t\t\t},\n\t\t\t\tmeta: {\n\t\t\t\t\tcontractPath,\n\t\t\t\t\t...ifDefined(\"configPath\", configPath)\n\t\t\t\t},\n\t\t\t\ttimings: { total: Date.now() - startTime }\n\t\t\t};\n\t\t},\n\t\tasync readMarker(options) {\n\t\t\treturn getControlAdapter().readMarker(asMongoDriver(options.driver), options.space);\n\t\t},\n\t\tasync readAllMarkers(options) {\n\t\t\treturn getControlAdapter().readAllMarkers(asMongoDriver(options.driver));\n\t\t},\n\t\tasync readLedger(options) {\n\t\t\treturn getControlAdapter().readLedger(asMongoDriver(options.driver), options.space);\n\t\t},\n\t\tasync introspect(options) {\n\t\t\treturn getControlAdapter().introspectSchema(asMongoDriver(options.driver));\n\t\t},\n\t\ttoSchemaView(schema) {\n\t\t\treturn mongoSchemaToView(schema);\n\t\t},\n\t\ttoOperationPreview(operations) {\n\t\t\treturn mongoOperationsToPreview(operations);\n\t\t}\n\t};\n}\n//#endregion\n//#region src/core/control-descriptor.ts\nvar MongoFamilyDescriptor = class {\n\tkind = \"family\";\n\tid = \"mongo\";\n\tfamilyId = \"mongo\";\n\tversion = \"0.0.1\";\n\temission = mongoEmission;\n\tauthoring = {\n\t\tentityTypes: mongoFamilyEntityTypes,\n\t\tpslBlockDescriptors: mongoFamilyPslBlockDescriptors\n\t};\n\tcreate(stack) {\n\t\treturn createMongoFamilyInstance(stack);\n\t}\n};\nconst mongoFamilyDescriptor = new MongoFamilyDescriptor();\n//#endregion\nexport { canonicalizeSchemasForVerification, contractToMongoSchemaIR, createMongoFamilyInstance, diffMongoSchemas, formatMongoOperations, mongoFamilyDescriptor, mongoOperationsToPreview };\n\n//# sourceMappingURL=control.mjs.map"],"mappings":";;;;;;;;;;;AAWA,SAAS,cAAc,MAAM;CAC5B,OAAO,KAAK,KAAK,KAAK,MAAM,GAAG,KAAK,UAAU,EAAE,KAAK,EAAE,IAAI,KAAK,UAAU,EAAE,SAAS,GAAG,CAAC,CAAC,KAAK,IAAI,EAAE;AACtG;AACA,MAAM,oCAAoC,IAAI,IAAI;CACjD;CACA;CACA;AACD,CAAC;AACD,SAAS,oBAAoB,KAAK;CACjC,MAAM,QAAQ,OAAO,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC,KAAK,WA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AS;GACzB,OAAO,kBAAkB,CAAC,CAAC,iBAAiB,cAAc,QAAQ,MAAM,CAAC;EAC1E;EACA,aAAa,QAAQ;GACpB,OAAO,kBAAkB,MAAM;EAChC;EACA,mBAAmB,YAAY;GAC9B,OAAO,yBAAyB,UAAU;EAC3C;CACD;AACD;AAGA,IAAI,wBAAwB,MAAM;CACjC,OAAO;CACP,KAAK;CACL,WAAW;CACX,UAAU;CACV,WAAW;CACX,YAAY;EACX,aAAa;EACb,qBAAqB;CACtB;CACA,OAAO,OAAO;EACb,OAAO,0BAA0B,KAAK;CACvC;AACD;AACA,MAAM,wBAAwB,IAAI,sBAAsB"}
package/dist/emitter.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { t as mongoEmission } from "./exports-CJMh0VTU.mjs";
1
+ import { t as mongoEmission } from "./exports-C4RGBGzZ.mjs";
2
2
  export { mongoEmission };
@@ -9,7 +9,7 @@ const MONGO_NAMESPACE_KIND_FALLBACK = "mongo-namespace";
9
9
  function mongoNamespaceSerializedKind(ns) {
10
10
  const kind = ns.kind;
11
11
  if (typeof kind === "string") return `readonly kind: ${serializeValue(kind)}`;
12
- return `readonly kind: '${MONGO_NAMESPACE_KIND_FALLBACK}'`;
12
+ return `readonly kind: "${MONGO_NAMESPACE_KIND_FALLBACK}"`;
13
13
  }
14
14
  function assertUniqueMongoCollectionNames(storage) {
15
15
  const seen = /* @__PURE__ */ new Map();
@@ -153,4 +153,4 @@ const mongoEmission = {
153
153
  //#endregion
154
154
  export { mongoEmission as t };
155
155
 
156
- //# sourceMappingURL=exports-CJMh0VTU.mjs.map
156
+ //# sourceMappingURL=exports-C4RGBGzZ.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exports-C4RGBGzZ.mjs","names":[],"sources":["../../../../2-mongo-family/3-tooling/emitter/dist/exports/index.mjs"],"sourcesContent":["import { serializeObjectKey, serializeValue } from \"@internal/emitter/domain-type-generation\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { structuredError } from \"@internal/utils/structured-error\";\n//#region src/index.ts\nfunction validationError(message, model) {\n\treturn structuredError(\"CONTRACT.VALIDATION_FAILED\", message, model === void 0 ? void 0 : { meta: { model } });\n}\nconst MONGO_NAMESPACE_KIND_FALLBACK = \"mongo-namespace\";\nfunction mongoNamespaceSerializedKind(ns) {\n\tconst kind = ns.kind;\n\tif (typeof kind === \"string\") return `readonly kind: ${serializeValue(kind)}`;\n\treturn `readonly kind: \"${MONGO_NAMESPACE_KIND_FALLBACK}\"`;\n}\nfunction assertUniqueMongoCollectionNames(storage) {\n\tconst seen = /* @__PURE__ */ new Map();\n\tfor (const [namespaceId, ns] of Object.entries(storage.namespaces)) for (const coll of Object.keys(ns.entries.collection ?? {})) {\n\t\tconst existing = seen.get(coll);\n\t\tif (existing !== void 0 && existing !== namespaceId) throw structuredError(\"CONTRACT.NAME_DUPLICATE\", `Duplicate collection name \"${coll}\" in namespaces \"${existing}\" and \"${namespaceId}\"`);\n\t\tseen.set(coll, namespaceId);\n\t}\n}\nfunction generateMongoCollectionEntryType(coll) {\n\tif (Object.entries(coll).filter(([key, v]) => v !== void 0 && key !== \"kind\").length === 0) return \"MongoCollection\";\n\treturn serializeValue(coll);\n}\nfunction generateMongoNamespaceCollectionsType(collections) {\n\tconst entries = [];\n\tfor (const [collName, coll] of Object.entries(collections).sort(([a], [b]) => a.localeCompare(b))) entries.push(`readonly ${serializeObjectKey(collName)}: ${generateMongoCollectionEntryType(coll)}`);\n\tif (entries.length === 0) return \"Record<string, never>\";\n\treturn `{ ${entries.join(\"; \")} }`;\n}\nfunction generateMongoNamespacesType(namespaces) {\n\tconst sorted = Object.entries(namespaces ?? {}).sort(([a], [b]) => a.localeCompare(b));\n\tif (sorted.length === 0) return \"Record<string, never>\";\n\tconst parts = [];\n\tfor (const [name, ns] of sorted) {\n\t\tconst collectionsType = generateMongoNamespaceCollectionsType(ns.entries.collection ?? {});\n\t\tparts.push(`readonly ${serializeObjectKey(name)}: { readonly id: ${serializeValue(ns.id)}; ${mongoNamespaceSerializedKind(ns)}; readonly entries: { readonly collection: ${collectionsType} } }`);\n\t}\n\treturn `{ ${parts.join(\"; \")} }`;\n}\nconst mongoEmission = {\n\tid: \"mongo\",\n\tvalidateTypes(contract, _ctx) {\n\t\tconst typeIdRegex = /^([^/]+)\\/([^@]+)@(\\d+)$/;\n\t\tfor (const [namespaceId, domainNs] of Object.entries(contract.domain.namespaces)) {\n\t\t\tconst models = domainNs.models;\n\t\t\tfor (const [modelName, model] of Object.entries(models)) {\n\t\t\t\tconst qualifiedName = `${namespaceId}:${modelName}`;\n\t\t\t\tfor (const [fieldName, field] of Object.entries(model.fields)) {\n\t\t\t\t\tconst fieldType = field.type;\n\t\t\t\t\tif (!fieldType) continue;\n\t\t\t\t\tconst scalarTypes = fieldType.kind === \"scalar\" ? [fieldType] : fieldType.kind === \"union\" && fieldType.members ? fieldType.members.filter((m) => m.kind === \"scalar\") : [];\n\t\t\t\t\tfor (const scalarType of scalarTypes) {\n\t\t\t\t\t\tconst { codecId } = scalarType;\n\t\t\t\t\t\tif (!codecId) throw validationError(`Field \"${fieldName}\" on model \"${qualifiedName}\" is missing codecId`, qualifiedName);\n\t\t\t\t\t\tif (!codecId.match(typeIdRegex)?.[1]) throw validationError(`Field \"${fieldName}\" on model \"${qualifiedName}\" has invalid codec ID format \"${codecId}\". Expected format: ns/name@version`, qualifiedName);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t},\n\tvalidateStructure(contract) {\n\t\tif (contract.targetFamily !== \"mongo\") throw validationError(`Expected targetFamily \"mongo\", got \"${contract.targetFamily}\"`);\n\t\tconst storage = contract.storage;\n\t\tif (!storage?.namespaces || typeof storage.namespaces !== \"object\") throw validationError(\"Mongo contract must have storage.namespaces\");\n\t\tassertUniqueMongoCollectionNames(storage);\n\t\tconst collectionNames = /* @__PURE__ */ new Set();\n\t\tfor (const ns of Object.values(storage.namespaces)) for (const c of Object.keys(ns.entries.collection ?? {})) collectionNames.add(c);\n\t\tfor (const [namespaceId, domainNs] of Object.entries(contract.domain.namespaces)) {\n\t\t\tconst models = domainNs.models;\n\t\t\tif (Object.keys(models).length === 0) continue;\n\t\t\tfor (const [modelName, model] of Object.entries(models)) {\n\t\t\t\tconst qualifiedName = `${namespaceId}:${modelName}`;\n\t\t\t\tif (!model.fields || typeof model.fields !== \"object\") throw validationError(`Model \"${qualifiedName}\" is missing required field \"fields\"`, qualifiedName);\n\t\t\t\tif (!model.relations || typeof model.relations !== \"object\") throw validationError(`Model \"${qualifiedName}\" is missing required field \"relations\" (must be an object)`, qualifiedName);\n\t\t\t\tif (!model.storage || typeof model.storage !== \"object\") throw validationError(`Model \"${qualifiedName}\" is missing required field \"storage\" (must be an object)`, qualifiedName);\n\t\t\t\tconst collectionValue = model.storage[\"collection\"];\n\t\t\t\tconst collection = typeof collectionValue === \"string\" ? collectionValue : void 0;\n\t\t\t\tif (model.owner) {\n\t\t\t\t\tif (collection) throw validationError(`Owned model \"${qualifiedName}\" must not have storage.collection (embedded models are stored within their owner)`, qualifiedName);\n\t\t\t\t\tif (!models[model.owner]) throw validationError(`Model \"${qualifiedName}\" declares owner \"${model.owner}\" which does not exist in models`, qualifiedName);\n\t\t\t\t} else if (collection) {\n\t\t\t\t\tif (!collectionNames.has(collection)) throw validationError(`Model \"${qualifiedName}\" references collection \"${collection}\" which is not in storage.namespaces[..].entries.collection`, qualifiedName);\n\t\t\t\t}\n\t\t\t\tif (model.base) {\n\t\t\t\t\tconst baseModel = models[model.base.model];\n\t\t\t\t\tif (!baseModel) throw validationError(`Model \"${qualifiedName}\" declares base \"${model.base.namespace}:${model.base.model}\" which does not exist in models`, qualifiedName);\n\t\t\t\t\tconst variantCollection = collection;\n\t\t\t\t\tconst baseCollection = baseModel.storage[\"collection\"];\n\t\t\t\t\tif (variantCollection !== baseCollection) throw validationError(`Variant \"${qualifiedName}\" must share its base's collection (\"${baseCollection ?? \"(none)\"}\"), but has \"${variantCollection ?? \"(none)\"}\"`, qualifiedName);\n\t\t\t\t}\n\t\t\t\tconst storageRelations = model.storage[\"relations\"];\n\t\t\t\tif (storageRelations) {\n\t\t\t\t\tfor (const relName of Object.keys(storageRelations)) if (!model.relations[relName]) throw validationError(`Model \"${qualifiedName}\" has storage.relations.${relName} but no matching domain-level relation`, qualifiedName);\n\t\t\t\t}\n\t\t\t\tfor (const [relName, rel] of Object.entries(model.relations)) {\n\t\t\t\t\tconst targetModelName = rel[\"to\"]?.model;\n\t\t\t\t\tif (targetModelName) {\n\t\t\t\t\t\tif (models[targetModelName]?.owner === modelName && !storageRelations?.[relName]) throw validationError(`Model \"${qualifiedName}\" has embed relation \"${relName}\" to owned model \"${targetModelName}\" but no matching storage.relations entry`, qualifiedName);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t},\n\tgenerateStorageType(contract, storageHashTypeName) {\n\t\tconst storage = contract.storage;\n\t\treturn `{ readonly namespaces: ${generateMongoNamespacesType(storage.namespaces)}; readonly storageHash: ${storageHashTypeName} }`;\n\t},\n\tgenerateModelStorageType(_modelName, model) {\n\t\tconst parts = [];\n\t\tconst collection = model.storage[\"collection\"];\n\t\tif (collection) parts.push(`readonly collection: ${serializeValue(collection)}`);\n\t\tconst storageRelations = model.storage[\"relations\"];\n\t\tif (storageRelations && Object.keys(storageRelations).length > 0) {\n\t\t\tconst relEntries = [];\n\t\t\tfor (const [relName, relVal] of Object.entries(storageRelations)) relEntries.push(`readonly ${serializeObjectKey(relName)}: ${serializeValue(relVal)}`);\n\t\t\tparts.push(`readonly relations: { ${relEntries.join(\"; \")} }`);\n\t\t}\n\t\treturn parts.length > 0 ? `{ ${parts.join(\"; \")} }` : \"Record<string, never>\";\n\t},\n\tresolveFieldValueSet(_modelName, fieldName, model, contract) {\n\t\tconst field = model.fields[fieldName];\n\t\tif (field === void 0 || field.type.kind !== \"scalar\") return void 0;\n\t\tconst ref = field.valueSet;\n\t\tif (ref === void 0) return void 0;\n\t\tconst valueSet = blindCast(contract.storage).namespaces[ref.namespaceId]?.entries.valueSet?.[ref.entityName];\n\t\tif (valueSet === void 0) return void 0;\n\t\treturn {\n\t\t\tencodedValues: valueSet.values,\n\t\t\tcodecId: field.type.codecId\n\t\t};\n\t},\n\tgetFamilyImports(resolveImportSpecifier) {\n\t\treturn [\n\t\t\t\"import type {\",\n\t\t\t\" MongoCollection,\",\n\t\t\t\" MongoContractWithTypeMaps,\",\n\t\t\t\" MongoTypeMaps,\",\n\t\t\t`} from '${resolveImportSpecifier(\"@internal/mongo-contract\")}';`\n\t\t];\n\t},\n\tgetFamilyTypeAliases() {\n\t\treturn \"\";\n\t},\n\tgetTypeMapsExpression() {\n\t\treturn \"MongoTypeMaps<CodecTypes, FieldOutputTypes, FieldInputTypes>\";\n\t},\n\tgetContractWrapper(contractBaseName, typeMapsName) {\n\t\treturn `export type Contract = MongoContractWithTypeMaps<${contractBaseName}, ${typeMapsName}>;`;\n\t}\n};\n//#endregion\nexport { mongoEmission };\n\n//# sourceMappingURL=index.mjs.map"],"mappings":";;;;AAIA,SAAS,gBAAgB,SAAS,OAAO;CACxC,OAAO,gBAAgB,8BAA8B,SAAS,UAAU,KAAK,IAAI,KAAK,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AAC9G;AACA,MAAM,gCAAgC;AACtC,SAAS,6BAA6B,IAAI;CACzC,MAAM,OAAO,GAAG;CAChB,IAAI,OAAO,SAAS,UAAU,OAAO,kBAAkB,eAAe,IAAI;CAC1E,OAAO,mBAAmB,8BAA8B;AACzD;AACA,SAAS,iCAAiC,SAAS;CAClD,MAAM,uBAAuB,IAAI,IAAI;CACrC,KAAK,MAAM,CAAC,aAAa,OAAO,OAAO,QAAQ,QAAQ,UAAU,GAAG,KAAK,MAAM,QAAQ,OAAO,KAAK,GAAG,QAAQ,cAAc,CAAC,CAAC,GAAG;EAChI,MAAM,WAAW,KAAK,IAAI,IAAI;EAC9B,IAAI,aAAa,KAAK,KAAK,aAAa,aAAa,MAAM,gBAAgB,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M,WAAW,UAAU,SAAS,OAAO,CAAC,CAAC,WAAW,IAAI,YAAY,EAAE,QAAQ,WAAW,IAAI;EACjG,IAAI,aAAa,KAAK,GAAG,OAAO,KAAK;EACrC,OAAO;GACN,eAAe,SAAS;GACxB,SAAS,MAAM,KAAK;EACrB;CACD;CACA,iBAAiB,wBAAwB;EACxC,OAAO;GACN;GACA;GACA;GACA;GACA,WAAW,uBAAuB,0BAA0B,EAAE;EAC/D;CACD;CACA,uBAAuB;EACtB,OAAO;CACR;CACA,wBAAwB;EACvB,OAAO;CACR;CACA,mBAAmB,kBAAkB,cAAc;EAClD,OAAO,oDAAoD,iBAAiB,IAAI,aAAa;CAC9F;AACD"}
package/dist/family.mjs CHANGED
@@ -2,7 +2,7 @@ import { c as defaultMongoDomainNamespaceId, l as defaultMongoStorageNamespaceId
2
2
  import { i as verifyMongoSchema, n as contractToMongoSchemaIR, r as diffMongoSchemas, t as canonicalizeSchemasForVerification } from "./verify-mongo-schema-De0FG2Rm-CCzwnNPY.mjs";
3
3
  import { n as mongoFamilyPslBlockDescriptors, t as mongoFamilyEntityTypes } from "./authoring-entity-types-BGtkMyoN-D32kzx28.mjs";
4
4
  import { n as MongoContractSerializerBase, t as MongoContractSerializer } from "./mongo-contract-serializer-Cx7Fae8e-C8ZYPXpc.mjs";
5
- import { i as mongoOperationsToPreview, n as formatMongoOperations, r as mongoFamilyDescriptor, t as createMongoFamilyInstance } from "./control-CFr3tYsg.mjs";
5
+ import { i as mongoOperationsToPreview, n as formatMongoOperations, r as mongoFamilyDescriptor, t as createMongoFamilyInstance } from "./control-BbZQqmxo.mjs";
6
6
  import { t as MongoContractView$1 } from "./mongo-contract-view-rcWzby6f-wRBCUnBt.mjs";
7
7
  import { t as MongoSchemaVerifierBase } from "./ir-Ch2aPr7a.mjs";
8
8
  import { t as MongoMigration } from "./migration-dcM7u4HG.mjs";
@@ -1,3 +1,3 @@
1
1
  import { n as contractToMongoSchemaIR, r as diffMongoSchemas, t as canonicalizeSchemasForVerification } from "./verify-mongo-schema-De0FG2Rm-CCzwnNPY.mjs";
2
- import { i as mongoOperationsToPreview, n as formatMongoOperations, r as mongoFamilyDescriptor, t as createMongoFamilyInstance } from "./control-CFr3tYsg.mjs";
2
+ import { i as mongoOperationsToPreview, n as formatMongoOperations, r as mongoFamilyDescriptor, t as createMongoFamilyInstance } from "./control-BbZQqmxo.mjs";
3
3
  export { canonicalizeSchemasForVerification, contractToMongoSchemaIR, createMongoFamilyInstance, diffMongoSchemas, formatMongoOperations, mongoFamilyDescriptor, mongoOperationsToPreview };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/orm-family-mongo",
3
- "version": "0.17.0-dev.5",
3
+ "version": "0.17.0-dev.6",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -9,29 +9,29 @@
9
9
  "dist"
10
10
  ],
11
11
  "dependencies": {
12
- "@prisma/orm-framework": "0.17.0-dev.5",
13
- "@prisma/orm-toolchain": "0.17.0-dev.5",
12
+ "@prisma/orm-framework": "0.17.0-dev.6",
13
+ "@prisma/orm-toolchain": "0.17.0-dev.6",
14
14
  "arktype": "^2.2.2",
15
15
  "mongodb": "^7.4.0",
16
16
  "pathe": "^2.0.3"
17
17
  },
18
18
  "devDependencies": {
19
- "@internal/family-mongo": "0.17.0-dev.5",
20
- "@internal/mongo-codec": "0.17.0-dev.5",
21
- "@internal/mongo-contract": "0.17.0-dev.5",
22
- "@internal/mongo-contract-psl": "0.17.0-dev.5",
23
- "@internal/mongo-contract-ts": "0.17.0-dev.5",
24
- "@internal/mongo-emitter": "0.17.0-dev.5",
25
- "@internal/mongo-lowering": "0.17.0-dev.5",
26
- "@internal/mongo-orm": "0.17.0-dev.5",
27
- "@internal/mongo-query-ast": "0.17.0-dev.5",
28
- "@internal/mongo-query-builder": "0.17.0-dev.5",
29
- "@internal/mongo-runtime": "0.17.0-dev.5",
30
- "@internal/mongo-schema-ir": "0.17.0-dev.5",
31
- "@internal/mongo-value": "0.17.0-dev.5",
32
- "@internal/mongo-wire": "0.17.0-dev.5",
33
- "@repo/tsconfig": "0.17.0-dev.5",
34
- "@repo/tsdown": "0.17.0-dev.5",
19
+ "@internal/family-mongo": "0.17.0-dev.6",
20
+ "@internal/mongo-codec": "0.17.0-dev.6",
21
+ "@internal/mongo-contract": "0.17.0-dev.6",
22
+ "@internal/mongo-contract-psl": "0.17.0-dev.6",
23
+ "@internal/mongo-contract-ts": "0.17.0-dev.6",
24
+ "@internal/mongo-emitter": "0.17.0-dev.6",
25
+ "@internal/mongo-lowering": "0.17.0-dev.6",
26
+ "@internal/mongo-orm": "0.17.0-dev.6",
27
+ "@internal/mongo-query-ast": "0.17.0-dev.6",
28
+ "@internal/mongo-query-builder": "0.17.0-dev.6",
29
+ "@internal/mongo-runtime": "0.17.0-dev.6",
30
+ "@internal/mongo-schema-ir": "0.17.0-dev.6",
31
+ "@internal/mongo-value": "0.17.0-dev.6",
32
+ "@internal/mongo-wire": "0.17.0-dev.6",
33
+ "@repo/tsconfig": "0.17.0-dev.6",
34
+ "@repo/tsdown": "0.17.0-dev.6",
35
35
  "tsdown": "0.22.14",
36
36
  "typescript": "5.9.3"
37
37
  },
@@ -1 +0,0 @@
1
- {"version":3,"file":"exports-CJMh0VTU.mjs","names":[],"sources":["../../../../2-mongo-family/3-tooling/emitter/dist/exports/index.mjs"],"sourcesContent":["import { serializeObjectKey, serializeValue } from \"@internal/emitter/domain-type-generation\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { structuredError } from \"@internal/utils/structured-error\";\n//#region src/index.ts\nfunction validationError(message, model) {\n\treturn structuredError(\"CONTRACT.VALIDATION_FAILED\", message, model === void 0 ? void 0 : { meta: { model } });\n}\nconst MONGO_NAMESPACE_KIND_FALLBACK = \"mongo-namespace\";\nfunction mongoNamespaceSerializedKind(ns) {\n\tconst kind = ns.kind;\n\tif (typeof kind === \"string\") return `readonly kind: ${serializeValue(kind)}`;\n\treturn `readonly kind: '${MONGO_NAMESPACE_KIND_FALLBACK}'`;\n}\nfunction assertUniqueMongoCollectionNames(storage) {\n\tconst seen = /* @__PURE__ */ new Map();\n\tfor (const [namespaceId, ns] of Object.entries(storage.namespaces)) for (const coll of Object.keys(ns.entries.collection ?? {})) {\n\t\tconst existing = seen.get(coll);\n\t\tif (existing !== void 0 && existing !== namespaceId) throw structuredError(\"CONTRACT.NAME_DUPLICATE\", `Duplicate collection name \"${coll}\" in namespaces \"${existing}\" and \"${namespaceId}\"`);\n\t\tseen.set(coll, namespaceId);\n\t}\n}\nfunction generateMongoCollectionEntryType(coll) {\n\tif (Object.entries(coll).filter(([key, v]) => v !== void 0 && key !== \"kind\").length === 0) return \"MongoCollection\";\n\treturn serializeValue(coll);\n}\nfunction generateMongoNamespaceCollectionsType(collections) {\n\tconst entries = [];\n\tfor (const [collName, coll] of Object.entries(collections).sort(([a], [b]) => a.localeCompare(b))) entries.push(`readonly ${serializeObjectKey(collName)}: ${generateMongoCollectionEntryType(coll)}`);\n\tif (entries.length === 0) return \"Record<string, never>\";\n\treturn `{ ${entries.join(\"; \")} }`;\n}\nfunction generateMongoNamespacesType(namespaces) {\n\tconst sorted = Object.entries(namespaces ?? {}).sort(([a], [b]) => a.localeCompare(b));\n\tif (sorted.length === 0) return \"Record<string, never>\";\n\tconst parts = [];\n\tfor (const [name, ns] of sorted) {\n\t\tconst collectionsType = generateMongoNamespaceCollectionsType(ns.entries.collection ?? {});\n\t\tparts.push(`readonly ${serializeObjectKey(name)}: { readonly id: ${serializeValue(ns.id)}; ${mongoNamespaceSerializedKind(ns)}; readonly entries: { readonly collection: ${collectionsType} } }`);\n\t}\n\treturn `{ ${parts.join(\"; \")} }`;\n}\nconst mongoEmission = {\n\tid: \"mongo\",\n\tvalidateTypes(contract, _ctx) {\n\t\tconst typeIdRegex = /^([^/]+)\\/([^@]+)@(\\d+)$/;\n\t\tfor (const [namespaceId, domainNs] of Object.entries(contract.domain.namespaces)) {\n\t\t\tconst models = domainNs.models;\n\t\t\tfor (const [modelName, model] of Object.entries(models)) {\n\t\t\t\tconst qualifiedName = `${namespaceId}:${modelName}`;\n\t\t\t\tfor (const [fieldName, field] of Object.entries(model.fields)) {\n\t\t\t\t\tconst fieldType = field.type;\n\t\t\t\t\tif (!fieldType) continue;\n\t\t\t\t\tconst scalarTypes = fieldType.kind === \"scalar\" ? [fieldType] : fieldType.kind === \"union\" && fieldType.members ? fieldType.members.filter((m) => m.kind === \"scalar\") : [];\n\t\t\t\t\tfor (const scalarType of scalarTypes) {\n\t\t\t\t\t\tconst { codecId } = scalarType;\n\t\t\t\t\t\tif (!codecId) throw validationError(`Field \"${fieldName}\" on model \"${qualifiedName}\" is missing codecId`, qualifiedName);\n\t\t\t\t\t\tif (!codecId.match(typeIdRegex)?.[1]) throw validationError(`Field \"${fieldName}\" on model \"${qualifiedName}\" has invalid codec ID format \"${codecId}\". Expected format: ns/name@version`, qualifiedName);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t},\n\tvalidateStructure(contract) {\n\t\tif (contract.targetFamily !== \"mongo\") throw validationError(`Expected targetFamily \"mongo\", got \"${contract.targetFamily}\"`);\n\t\tconst storage = contract.storage;\n\t\tif (!storage?.namespaces || typeof storage.namespaces !== \"object\") throw validationError(\"Mongo contract must have storage.namespaces\");\n\t\tassertUniqueMongoCollectionNames(storage);\n\t\tconst collectionNames = /* @__PURE__ */ new Set();\n\t\tfor (const ns of Object.values(storage.namespaces)) for (const c of Object.keys(ns.entries.collection ?? {})) collectionNames.add(c);\n\t\tfor (const [namespaceId, domainNs] of Object.entries(contract.domain.namespaces)) {\n\t\t\tconst models = domainNs.models;\n\t\t\tif (Object.keys(models).length === 0) continue;\n\t\t\tfor (const [modelName, model] of Object.entries(models)) {\n\t\t\t\tconst qualifiedName = `${namespaceId}:${modelName}`;\n\t\t\t\tif (!model.fields || typeof model.fields !== \"object\") throw validationError(`Model \"${qualifiedName}\" is missing required field \"fields\"`, qualifiedName);\n\t\t\t\tif (!model.relations || typeof model.relations !== \"object\") throw validationError(`Model \"${qualifiedName}\" is missing required field \"relations\" (must be an object)`, qualifiedName);\n\t\t\t\tif (!model.storage || typeof model.storage !== \"object\") throw validationError(`Model \"${qualifiedName}\" is missing required field \"storage\" (must be an object)`, qualifiedName);\n\t\t\t\tconst collectionValue = model.storage[\"collection\"];\n\t\t\t\tconst collection = typeof collectionValue === \"string\" ? collectionValue : void 0;\n\t\t\t\tif (model.owner) {\n\t\t\t\t\tif (collection) throw validationError(`Owned model \"${qualifiedName}\" must not have storage.collection (embedded models are stored within their owner)`, qualifiedName);\n\t\t\t\t\tif (!models[model.owner]) throw validationError(`Model \"${qualifiedName}\" declares owner \"${model.owner}\" which does not exist in models`, qualifiedName);\n\t\t\t\t} else if (collection) {\n\t\t\t\t\tif (!collectionNames.has(collection)) throw validationError(`Model \"${qualifiedName}\" references collection \"${collection}\" which is not in storage.namespaces[..].entries.collection`, qualifiedName);\n\t\t\t\t}\n\t\t\t\tif (model.base) {\n\t\t\t\t\tconst baseModel = models[model.base.model];\n\t\t\t\t\tif (!baseModel) throw validationError(`Model \"${qualifiedName}\" declares base \"${model.base.namespace}:${model.base.model}\" which does not exist in models`, qualifiedName);\n\t\t\t\t\tconst variantCollection = collection;\n\t\t\t\t\tconst baseCollection = baseModel.storage[\"collection\"];\n\t\t\t\t\tif (variantCollection !== baseCollection) throw validationError(`Variant \"${qualifiedName}\" must share its base's collection (\"${baseCollection ?? \"(none)\"}\"), but has \"${variantCollection ?? \"(none)\"}\"`, qualifiedName);\n\t\t\t\t}\n\t\t\t\tconst storageRelations = model.storage[\"relations\"];\n\t\t\t\tif (storageRelations) {\n\t\t\t\t\tfor (const relName of Object.keys(storageRelations)) if (!model.relations[relName]) throw validationError(`Model \"${qualifiedName}\" has storage.relations.${relName} but no matching domain-level relation`, qualifiedName);\n\t\t\t\t}\n\t\t\t\tfor (const [relName, rel] of Object.entries(model.relations)) {\n\t\t\t\t\tconst targetModelName = rel[\"to\"]?.model;\n\t\t\t\t\tif (targetModelName) {\n\t\t\t\t\t\tif (models[targetModelName]?.owner === modelName && !storageRelations?.[relName]) throw validationError(`Model \"${qualifiedName}\" has embed relation \"${relName}\" to owned model \"${targetModelName}\" but no matching storage.relations entry`, qualifiedName);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t},\n\tgenerateStorageType(contract, storageHashTypeName) {\n\t\tconst storage = contract.storage;\n\t\treturn `{ readonly namespaces: ${generateMongoNamespacesType(storage.namespaces)}; readonly storageHash: ${storageHashTypeName} }`;\n\t},\n\tgenerateModelStorageType(_modelName, model) {\n\t\tconst parts = [];\n\t\tconst collection = model.storage[\"collection\"];\n\t\tif (collection) parts.push(`readonly collection: ${serializeValue(collection)}`);\n\t\tconst storageRelations = model.storage[\"relations\"];\n\t\tif (storageRelations && Object.keys(storageRelations).length > 0) {\n\t\t\tconst relEntries = [];\n\t\t\tfor (const [relName, relVal] of Object.entries(storageRelations)) relEntries.push(`readonly ${serializeObjectKey(relName)}: ${serializeValue(relVal)}`);\n\t\t\tparts.push(`readonly relations: { ${relEntries.join(\"; \")} }`);\n\t\t}\n\t\treturn parts.length > 0 ? `{ ${parts.join(\"; \")} }` : \"Record<string, never>\";\n\t},\n\tresolveFieldValueSet(_modelName, fieldName, model, contract) {\n\t\tconst field = model.fields[fieldName];\n\t\tif (field === void 0 || field.type.kind !== \"scalar\") return void 0;\n\t\tconst ref = field.valueSet;\n\t\tif (ref === void 0) return void 0;\n\t\tconst valueSet = blindCast(contract.storage).namespaces[ref.namespaceId]?.entries.valueSet?.[ref.entityName];\n\t\tif (valueSet === void 0) return void 0;\n\t\treturn {\n\t\t\tencodedValues: valueSet.values,\n\t\t\tcodecId: field.type.codecId\n\t\t};\n\t},\n\tgetFamilyImports(resolveImportSpecifier) {\n\t\treturn [\n\t\t\t\"import type {\",\n\t\t\t\" MongoCollection,\",\n\t\t\t\" MongoContractWithTypeMaps,\",\n\t\t\t\" MongoTypeMaps,\",\n\t\t\t`} from '${resolveImportSpecifier(\"@internal/mongo-contract\")}';`\n\t\t];\n\t},\n\tgetFamilyTypeAliases() {\n\t\treturn \"\";\n\t},\n\tgetTypeMapsExpression() {\n\t\treturn \"MongoTypeMaps<CodecTypes, FieldOutputTypes, FieldInputTypes>\";\n\t},\n\tgetContractWrapper(contractBaseName, typeMapsName) {\n\t\treturn `export type Contract = MongoContractWithTypeMaps<${contractBaseName}, ${typeMapsName}>;`;\n\t}\n};\n//#endregion\nexport { mongoEmission };\n\n//# sourceMappingURL=index.mjs.map"],"mappings":";;;;AAIA,SAAS,gBAAgB,SAAS,OAAO;CACxC,OAAO,gBAAgB,8BAA8B,SAAS,UAAU,KAAK,IAAI,KAAK,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AAC9G;AACA,MAAM,gCAAgC;AACtC,SAAS,6BAA6B,IAAI;CACzC,MAAM,OAAO,GAAG;CAChB,IAAI,OAAO,SAAS,UAAU,OAAO,kBAAkB,eAAe,IAAI;CAC1E,OAAO,mBAAmB,8BAA8B;AACzD;AACA,SAAS,iCAAiC,SAAS;CAClD,MAAM,uBAAuB,IAAI,IAAI;CACrC,KAAK,MAAM,CAAC,aAAa,OAAO,OAAO,QAAQ,QAAQ,UAAU,GAAG,KAAK,MAAM,QAAQ,OAAO,KAAK,GAAG,QAAQ,cAAc,CAAC,CAAC,GAAG;EAChI,MAAM,WAAW,KAAK,IAAI,IAAI;EAC9B,IAAI,aAAa,KAAK,KAAK,aAAa,aAAa,MAAM,gBAAgB,2BAA2B,8BAA8B,KAAK,mBAAmB,SAAS,SAAS,YAAY,EAAE;EAC5L,KAAK,IAAI,MAAM,WAAW;CAC3B;AACD;AACA,SAAS,iCAAiC,MAAM;CAC/C,IAAI,OAAO,QAAQ,IAAI,CAAC,CAAC,QAAQ,CAAC,KAAK,OAAO,MAAM,KAAK,KAAK,QAAQ,MAAM,CAAC,CAAC,WAAW,GAAG,OAAO;CACnG,OAAO,eAAe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