@prisma/orm-target-mongo 8.0.0-rc.24-dev.28 → 8.0.0-rc.24-dev.30

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.
Files changed (47) hide show
  1. package/dist/adapter.mjs +1 -1
  2. package/dist/adapter__control.mjs +4 -3
  3. package/dist/adapter__control.mjs.map +1 -1
  4. package/dist/adapter__runtime.mjs +2 -2
  5. package/dist/{codecs-BxTQKKXN-p2W9ISNn.mjs → codecs-DKwnfU85-BAZ4CD7m.mjs} +6 -27
  6. package/dist/codecs-DKwnfU85-BAZ4CD7m.mjs.map +1 -0
  7. package/dist/{control-aaXa_r6J.mjs → control-Be0fS-hV.mjs} +2 -2
  8. package/dist/{control-aaXa_r6J.mjs.map → control-Be0fS-hV.mjs.map} +1 -1
  9. package/dist/{control-D2tbWwPF.mjs → control-D9f8mKHr.mjs} +16 -41
  10. package/dist/control-D9f8mKHr.mjs.map +1 -0
  11. package/dist/{control-ByHwQ1ve.d.mts → control-DBNn1M3A.d.mts} +4 -12
  12. package/dist/control-DBNn1M3A.d.mts.map +1 -0
  13. package/dist/{data-types-BR7vssy0-CuNYIJHI.mjs → data-types-DacjqiBe-D5ui4_5e.mjs} +11 -43
  14. package/dist/data-types-DacjqiBe-D5ui4_5e.mjs.map +1 -0
  15. package/dist/{date-time-now-generators-CGx9UUde-Bf7961yv.mjs → date-time-now-generators-ClztoylE-Bq7Fps2T.mjs} +3 -3
  16. package/dist/{date-time-now-generators-CGx9UUde-Bf7961yv.mjs.map → date-time-now-generators-ClztoylE-Bq7Fps2T.mjs.map} +1 -1
  17. package/dist/{descriptor-meta-BWjqdX8D-BAnaqzWL.mjs → descriptor-meta-BRjal4JG-G-1rNvuk.mjs} +5 -5
  18. package/dist/{descriptor-meta-BWjqdX8D-BAnaqzWL.mjs.map → descriptor-meta-BRjal4JG-G-1rNvuk.mjs.map} +1 -1
  19. package/dist/{descriptor-meta-runtime-lnkLN7r9-Qb8szw6W.mjs → descriptor-meta-runtime-Bnv0sQnr-DVFwLDn7.mjs} +4 -4
  20. package/dist/{descriptor-meta-runtime-lnkLN7r9-Qb8szw6W.mjs.map → descriptor-meta-runtime-Bnv0sQnr-DVFwLDn7.mjs.map} +1 -1
  21. package/dist/driver.mjs +1 -1
  22. package/dist/driver__control.mjs +1 -1
  23. package/dist/driver__runtime.mjs +1 -1
  24. package/dist/driver__runtime.mjs.map +1 -1
  25. package/dist/{mongo-adapter-DemWVyNv-ClNih50Z.mjs → mongo-adapter-DemWVyNv-ivErOBO6.mjs} +2 -2
  26. package/dist/{mongo-adapter-DemWVyNv-ClNih50Z.mjs.map → mongo-adapter-DemWVyNv-ivErOBO6.mjs.map} +1 -1
  27. package/dist/{mongo-driver-Cp7ApMWY-uuvB0cAv.mjs → mongo-driver-C9yvIHgo-BYNinbNE.mjs} +3 -3
  28. package/dist/{mongo-driver-Cp7ApMWY-uuvB0cAv.mjs.map → mongo-driver-C9yvIHgo-BYNinbNE.mjs.map} +1 -1
  29. package/dist/{prisma6-binding-DRtXGY85.mjs → prisma6-binding-D-mtJWjJ.mjs} +2 -2
  30. package/dist/{prisma6-binding-DRtXGY85.mjs.map → prisma6-binding-D-mtJWjJ.mjs.map} +1 -1
  31. package/dist/{runtime-BJGi8c9G.mjs → runtime-DDzO_Noh.mjs} +2 -2
  32. package/dist/{runtime-BJGi8c9G.mjs.map → runtime-DDzO_Noh.mjs.map} +1 -1
  33. package/dist/target.d.mts +1 -1
  34. package/dist/target.mjs +5 -5
  35. package/dist/target__codecs.mjs +1 -1
  36. package/dist/target__control.d.mts +1 -1
  37. package/dist/target__control.mjs +1 -1
  38. package/dist/target__data-types.mjs +1 -1
  39. package/dist/target__pack.mjs +1 -1
  40. package/dist/target__pack.mjs.map +1 -1
  41. package/dist/target__prisma6-binding.mjs +1 -1
  42. package/dist/target__runtime.mjs +2 -2
  43. package/package.json +13 -13
  44. package/dist/codecs-BxTQKKXN-p2W9ISNn.mjs.map +0 -1
  45. package/dist/control-ByHwQ1ve.d.mts.map +0 -1
  46. package/dist/control-D2tbWwPF.mjs.map +0 -1
  47. package/dist/data-types-BR7vssy0-CuNYIJHI.mjs.map +0 -1
package/dist/adapter.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { b as MONGO_VECTOR_CODEC_ID } from "./codec-ids-DZQsuh80-ywDzfnAg.mjs";
2
- import { a as lowerStage, i as lowerPipeline, n as lowerAggExpr, r as lowerFilter, t as createMongoAdapter } from "./mongo-adapter-DemWVyNv-ClNih50Z.mjs";
2
+ import { a as lowerStage, i as lowerPipeline, n as lowerAggExpr, r as lowerFilter, t as createMongoAdapter } from "./mongo-adapter-DemWVyNv-ivErOBO6.mjs";
3
3
  //#region ../../../3-targets/mongo/2-adapter/dist/index.mjs
4
4
  const mongoVectorNearOperation = Object.freeze({
5
5
  self: { codecId: MONGO_VECTOR_CODEC_ID },
@@ -1,4 +1,4 @@
1
- import { t as createMongoAdapter } from "./mongo-adapter-DemWVyNv-ClNih50Z.mjs";
1
+ import { t as createMongoAdapter } from "./mongo-adapter-DemWVyNv-ivErOBO6.mjs";
2
2
  import { structuredError } from "@prisma/orm-framework/utils/structured-error";
3
3
  import { ifDefined } from "@prisma/orm-framework/utils/defined";
4
4
  import { type } from "arktype";
@@ -419,6 +419,7 @@ var MongoControlAdapterImpl = class {
419
419
  };
420
420
  }
421
421
  };
422
+ const targetModuleBase = "@prisma/orm-target-mongo/target";
422
423
  const mongoAdapterDescriptor = {
423
424
  kind: "adapter",
424
425
  id: "mongo",
@@ -427,12 +428,12 @@ const mongoAdapterDescriptor = {
427
428
  version: "0.0.1",
428
429
  types: { codecTypes: {
429
430
  import: {
430
- package: "@internal/target-mongo/codec-types",
431
+ package: `${targetModuleBase}/codec-types`,
431
432
  named: "CodecTypes",
432
433
  alias: "MongoCodecTypes"
433
434
  },
434
435
  parameterizedOutputTypes: {
435
- package: "@internal/target-mongo/codec-types",
436
+ package: `${targetModuleBase}/codec-types`,
436
437
  named: "ParameterizedOutputTypesForTypeParams",
437
438
  alias: "MongoParameterizedOutputTypes"
438
439
  }
@@ -1 +1 @@
1
- {"version":3,"file":"adapter__control.mjs","names":["#adapter","#execute","#markerLedgerCollection","#invariantMergeExpr"],"sources":["../../../../3-targets/mongo/2-adapter/dist/control.mjs"],"sourcesContent":["import { t as createMongoAdapter } from \"./mongo-adapter-DemWVyNv.mjs\";\nimport { MongoAggCond, MongoAggFieldRef, MongoAggLiteral, MongoAggMap, MongoAggOperator, MongoExprFilter } from \"@internal/mongo-query-ast/execution\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { structuredError } from \"@internal/utils/structured-error\";\nimport { assembleMongoCodecRegistry } from \"@internal/mongo-codec\";\nimport { MongoSchemaCollection, MongoSchemaCollectionOptions, MongoSchemaIR, MongoSchemaIndex, MongoSchemaValidator } from \"@internal/mongo-schema-ir\";\nimport { MongoServerError } from \"mongodb\";\nimport { parseMarkerRowSafely, withMarkerReadErrorHandling } from \"@internal/errors/execution\";\nimport { APP_SPACE_ID, DATABASE_POLICIES_KEYS, DATABASE_POLICIES_META_KEY, DATA_PROTECTION_KEYS, DEFAULT_DATABASE_POLICIES, storedDatabasePolicies } from \"@internal/framework-components/control\";\nimport { ledgerOriginFromStored } from \"@internal/migration-tools/ledger-origin\";\nimport { expr, fn } from \"@internal/mongo-query-builder\";\nimport { collection } from \"@internal/mongo-query-builder/contract-free\";\nimport { type } from \"arktype\";\n//#region src/core/introspect-schema.ts\nconst PRISMA_MIGRATIONS_COLLECTION = \"_prisma_migrations\";\nfunction parseIndexKeys(keySpec) {\n\tconst keys = [];\n\tfor (const [field, direction] of Object.entries(keySpec)) keys.push({\n\t\tfield,\n\t\tdirection\n\t});\n\treturn keys;\n}\n/**\n* Exported for unit tests to exercise the defensive `!key` guard; not part of\n* the public API. Callers in this package use it via the `introspectSchema`\n* pipeline only.\n*/\nfunction isDefaultIdIndex(doc) {\n\tconst key = doc[\"key\"];\n\tif (!key) return false;\n\tconst entries = Object.entries(key);\n\treturn entries.length === 1 && entries[0]?.[0] === \"_id\" && entries[0]?.[1] === 1;\n}\nfunction parseIndex(doc) {\n\tconst keySpec = doc[\"key\"];\n\treturn new MongoSchemaIndex({\n\t\tname: String(doc[\"name\"]),\n\t\tkeys: parseIndexKeys(keySpec),\n\t\tunique: doc[\"unique\"],\n\t\tsparse: doc[\"sparse\"],\n\t\texpireAfterSeconds: doc[\"expireAfterSeconds\"],\n\t\tpartialFilterExpression: doc[\"partialFilterExpression\"],\n\t\twildcardProjection: doc[\"wildcardProjection\"],\n\t\tcollation: doc[\"collation\"] ? blindCast(doc[\"collation\"]) : void 0,\n\t\tweights: doc[\"weights\"],\n\t\tdefault_language: doc[\"default_language\"],\n\t\tlanguage_override: doc[\"language_override\"]\n\t});\n}\nfunction parseValidator(options) {\n\tconst validator = options[\"validator\"];\n\tif (!validator) return void 0;\n\tconst jsonSchema = validator[\"$jsonSchema\"];\n\tif (!jsonSchema) return void 0;\n\treturn new MongoSchemaValidator({\n\t\tjsonSchema,\n\t\tvalidationLevel: options[\"validationLevel\"] ?? \"strict\",\n\t\tvalidationAction: options[\"validationAction\"] ?? \"error\"\n\t});\n}\nfunction parseCollectionOptions(info) {\n\tconst options = info[\"options\"];\n\tif (!options) return void 0;\n\tconst capped = options[\"capped\"];\n\tconst size = options[\"size\"];\n\tconst max = options[\"max\"];\n\tconst timeseries = options[\"timeseries\"];\n\tconst collation = options[\"collation\"] ? blindCast(options[\"collation\"]) : void 0;\n\tconst changeStreamPreAndPostImages = options[\"changeStreamPreAndPostImages\"];\n\tconst clusteredIndex = options[\"clusteredIndex\"];\n\tif (!(capped || timeseries || collation || changeStreamPreAndPostImages || clusteredIndex)) return void 0;\n\treturn new MongoSchemaCollectionOptions({\n\t\t...capped ? { capped: {\n\t\t\tsize: size ?? 0,\n\t\t\t...max != null ? { max } : {}\n\t\t} } : {},\n\t\t...timeseries ? { timeseries } : {},\n\t\t...collation ? { collation } : {},\n\t\t...changeStreamPreAndPostImages ? { changeStreamPreAndPostImages } : {},\n\t\t...clusteredIndex ? { clusteredIndex } : {}\n\t});\n}\nasync function introspectSchema(db) {\n\tconst collectionInfos = await db.listCollections().toArray();\n\tconst collections = [];\n\tfor (const info of collectionInfos) {\n\t\tconst name = info[\"name\"];\n\t\tconst type = info[\"type\"];\n\t\tif (name === PRISMA_MIGRATIONS_COLLECTION) continue;\n\t\tif (name.startsWith(\"system.\")) continue;\n\t\tif (type === \"view\") continue;\n\t\tconst indexes = (await db.collection(name).listIndexes().toArray()).filter((doc) => !isDefaultIdIndex(doc)).map(parseIndex);\n\t\tconst validator = parseValidator(\"options\" in info ? info[\"options\"] : {});\n\t\tconst options = parseCollectionOptions(info);\n\t\tcollections.push(new MongoSchemaCollection({\n\t\t\tname,\n\t\t\tindexes,\n\t\t\t...validator ? { validator } : {},\n\t\t\t...options ? { options } : {}\n\t\t}));\n\t}\n\treturn new MongoSchemaIR(collections, { fromDatabase: true });\n}\n//#endregion\n//#region src/core/migrations/inspection-executor.ts\n/**\n* Executes the read-only catalog inspections (`listCollections` / `listIndexes`)\n* that migration prechecks/postchecks and operation preview evaluate, directly\n* against `db`. Routing these checks through the adapter's lowering seam is\n* deferred to the `typed-migration-verification-queries` slice.\n*/\nvar MongoInspectionExecutor = class {\n\tdb;\n\tconstructor(db) {\n\t\tthis.db = db;\n\t}\n\tasync listIndexes(cmd) {\n\t\ttry {\n\t\t\treturn await this.db.collection(cmd.collection).listIndexes().toArray();\n\t\t} catch (error) {\n\t\t\tif (error instanceof MongoServerError && error.code === 26) return [];\n\t\t\tthrow error;\n\t\t}\n\t}\n\tasync listCollections(_cmd) {\n\t\treturn this.db.listCollections().toArray();\n\t}\n};\n//#endregion\n//#region src/core/errors.ts\nfunction mongoAdapterError(code, message, options) {\n\treturn structuredError(code, message, options);\n}\nfunction describeReceivedValue(value) {\n\tif (value === null) return \"null\";\n\tif (typeof value !== \"object\") return typeof value;\n\treturn `object with keys [${Object.keys(value).join(\", \")}]`;\n}\n//#endregion\n//#region src/core/marker-ledger.ts\nconst COLLECTION = \"_prisma_migrations\";\nconst MONGO_MARKER_COLLECTION = COLLECTION;\nconst MONGO_LEDGER_COLLECTION = `_prisma_migrations ledger documents in ${COLLECTION}`;\nconst MongoMarkerDocSchema = type({\n\tspace: \"string\",\n\tstorageHash: \"string\",\n\tprofileHash: \"string\",\n\t\"contractJson?\": \"unknown | null\",\n\t\"canonicalVersion?\": \"number | null\",\n\t\"updatedAt?\": \"Date\",\n\t\"appTag?\": \"string | null\",\n\t\"meta?\": type({ \"[string]\": \"unknown\" }).or(\"null\"),\n\t\"invariants?\": type(\"string\").array(),\n\t\"+\": \"delete\"\n});\nfunction parseMongoMarkerDoc(doc) {\n\tconst result = MongoMarkerDocSchema(doc);\n\tif (result instanceof type.errors) throw mongoAdapterError(\"CONTRACT.MARKER_ROW_CORRUPT\", `Invalid marker doc on ${COLLECTION}: ${result.summary}`, { meta: {\n\t\tcollection: COLLECTION,\n\t\tdetail: result.summary\n\t} });\n\treturn {\n\t\tstorageHash: result.storageHash,\n\t\tprofileHash: result.profileHash,\n\t\tcontractJson: result.contractJson ?? null,\n\t\tcanonicalVersion: result.canonicalVersion ?? null,\n\t\tupdatedAt: result.updatedAt ?? /* @__PURE__ */ new Date(),\n\t\tappTag: result.appTag ?? null,\n\t\tmeta: result.meta ?? {},\n\t\tinvariants: result.invariants ?? []\n\t};\n}\nfunction parseMongoMarkerDocSafely(doc, space) {\n\treturn parseMarkerRowSafely(doc, parseMongoMarkerDoc, {\n\t\tspace,\n\t\tmarkerLocation: MONGO_MARKER_COLLECTION\n\t});\n}\n//#endregion\n//#region src/core/marker-ledger-collection.ts\nconst MARKER_LEDGER_COLLECTION = \"_prisma_migrations\";\n//#endregion\n//#region src/core/migrations/mongo-control-driver.ts\nfunction isMongoControlDriver(driver) {\n\treturn driver.familyId === \"mongo\" && driver.targetId === \"mongo\" && \"execute\" in driver && typeof driver.execute === \"function\";\n}\nfunction requireMongoControlDriver(driver) {\n\tif (!isMongoControlDriver(driver)) throw mongoAdapterError(\"CONFIG.VALIDATION_FAILED\", \"Expected a Mongo control driver created by mongoControlDriver.create() from `@internal/driver-mongo/control`.\", { meta: { received: describeReceivedValue(driver) } });\n\treturn driver;\n}\nfunction extractDb(driver) {\n\treturn requireMongoControlDriver(driver).db;\n}\n//#endregion\n//#region src/core/migrations/mongo-control-adapter.ts\nfunction policiesDocument(policies) {\n\tconst stored = storedDatabasePolicies(policies);\n\treturn {\n\t\tchange: stored.change,\n\t\tdataProtection: { ...stored.dataProtection }\n\t};\n}\nconst POLICIES_PATH = `meta.${DATABASE_POLICIES_META_KEY}`;\nfunction typeOf(path) {\n\treturn MongoAggOperator.of(\"$type\", MongoAggFieldRef.of(path));\n}\n/**\n* Holds while `path` is missing, or is an object carrying no key outside `keys`: the framework parser\n* rejects any other key, so a marker with one does not hold the checked policies.\n*/\nfunction missingOrObjectOf(path, keys) {\n\tconst keysAtPath = MongoAggMap.of(MongoAggOperator.of(\"$objectToArray\", MongoAggFieldRef.of(path)), MongoAggFieldRef.of(\"$entry.k\"), \"entry\");\n\treturn MongoAggCond.of(MongoAggOperator.of(\"$eq\", [typeOf(path), MongoAggLiteral.of(\"object\")]), MongoAggOperator.of(\"$setIsSubset\", [keysAtPath, MongoAggLiteral.of([...keys])]), MongoAggOperator.of(\"$eq\", [typeOf(path), MongoAggLiteral.of(\"missing\")]));\n}\nfunction missingWhenDefault(path, isDefault) {\n\treturn isDefault ? MongoAggOperator.of(\"$eq\", [typeOf(path), MongoAggLiteral.of(\"missing\")]) : MongoAggLiteral.of(false);\n}\nfunction settingHolds(path, value, defaultValue) {\n\treturn MongoAggOperator.of(\"$or\", [MongoAggOperator.of(\"$eq\", [MongoAggFieldRef.of(path), MongoAggLiteral.of(value)]), missingWhenDefault(path, value === defaultValue)]);\n}\nfunction sameStrategies(a, b) {\n\tconst left = new Set(a);\n\tconst right = new Set(b);\n\treturn left.size === right.size && [...left].every((strategy) => right.has(strategy));\n}\n/**\n* An aggregation predicate that holds while the marker's `meta.policies` reads as `checkedPolicies`,\n* however it is stored. It follows the framework parser and its defaults: no key outside\n* {@link DATABASE_POLICIES_KEYS} and {@link DATA_PROTECTION_KEYS}, `change` compared as a set, each\n* data protection setting by value, and an absent setting matching only its default.\n*/\nfunction policiesHoldExpr(checkedPolicies) {\n\tconst changePath = `${POLICIES_PATH}.change`;\n\tconst dataProtectionPath = `${POLICIES_PATH}.dataProtection`;\n\tconst defaults = DEFAULT_DATABASE_POLICIES;\n\tconst { change, dataProtection } = checkedPolicies;\n\treturn MongoAggOperator.of(\"$and\", [\n\t\tmissingOrObjectOf(POLICIES_PATH, DATABASE_POLICIES_KEYS),\n\t\tMongoAggCond.of(MongoAggOperator.of(\"$isArray\", MongoAggFieldRef.of(changePath)), MongoAggOperator.of(\"$setEquals\", [MongoAggFieldRef.of(changePath), MongoAggLiteral.of([...change])]), missingWhenDefault(changePath, sameStrategies(change, defaults.change))),\n\t\tmissingOrObjectOf(dataProtectionPath, DATA_PROTECTION_KEYS),\n\t\t...DATA_PROTECTION_KEYS.map((key) => settingHolds(`${dataProtectionPath}.${key}`, dataProtection[key], defaults.dataProtection[key]))\n\t]);\n}\n/**\n* Mongo control adapter for control-plane operations like introspection\n* and marker-ledger CAS. Implements the family-level `MongoControlAdapter`\n* SPI. Every marker/ledger operation builds a canonical command inline via\n* the contract-free fluent builder and dispatches it through the family\n* adapter's lowering path (`createMongoAdapter().lower(plan, {})`) onto the\n* Mongo wire transport (`driver.execute(wireCommand)`) — the same route SQL\n* marker/ledger ops take through `adapter.lower()` → `driver.query()`.\n*/\nvar MongoControlAdapterImpl = class {\n\tfamilyId = \"mongo\";\n\ttargetId = \"mongo\";\n\tmarkerLocation = MONGO_MARKER_COLLECTION;\n\t#adapter;\n\t#markerLedgerCollection = collection(MARKER_LEDGER_COLLECTION);\n\tconstructor(codecs) {\n\t\tthis.#adapter = createMongoAdapter(codecs);\n\t}\n\tasync #execute(driver, command) {\n\t\tconst plan = {\n\t\t\tcollection: MARKER_LEDGER_COLLECTION,\n\t\t\tcommand,\n\t\t\tmeta: {\n\t\t\t\ttarget: \"mongo\",\n\t\t\t\ttargetFamily: \"mongo\",\n\t\t\t\tstorageHash: \"\",\n\t\t\t\tlane: \"control\"\n\t\t\t}\n\t\t};\n\t\tconst wireCommand = await this.#adapter.lower(plan, {});\n\t\tif (!isMongoControlDriver(driver)) throw mongoAdapterError(\"CONFIG.VALIDATION_FAILED\", \"Mongo control adapter requires a Mongo control driver with an execute() transport. Provide a MongoControlDriver from `@internal/driver-mongo/control`.\", { meta: { received: describeReceivedValue(driver) } });\n\t\tconst rows = [];\n\t\tfor await (const row of driver.execute(wireCommand)) rows.push(row);\n\t\treturn rows;\n\t}\n\tasync executeDdl(driver, command) {\n\t\tconst wire = await this.#adapter.lower({ command }, {});\n\t\tawait driver.run(wire);\n\t}\n\t/**\n\t* Server-side invariant-merge aggregation expression:\n\t* `$sortArray({ input: $setUnion([$ifNull('$invariants', []), incoming]), sortBy: 1 })`.\n\t*\n\t* Built through the typed agg-expr layer — `fn.setUnion` plus the generic\n\t* `MongoAggOperator` for `$ifNull` / `$sortArray` (neither has a named `fn`\n\t* helper). Returns a `MongoAggOperator` that is passed directly to\n\t* `f.stage.set({ invariants: ... })` in the update pipeline.\n\t*/\n\t#invariantMergeExpr(incoming) {\n\t\tconst existingOrEmpty = MongoAggOperator.of(\"$ifNull\", [MongoAggFieldRef.of(\"invariants\"), MongoAggLiteral.of([])]);\n\t\tconst merged = fn.setUnion({\n\t\t\t_field: {\n\t\t\t\tcodecId: \"mongo/array@1\",\n\t\t\t\tnullable: false\n\t\t\t},\n\t\t\tnode: existingOrEmpty\n\t\t}, {\n\t\t\t_field: {\n\t\t\t\tcodecId: \"mongo/array@1\",\n\t\t\t\tnullable: false\n\t\t\t},\n\t\t\tnode: MongoAggLiteral.of([...incoming])\n\t\t});\n\t\treturn MongoAggOperator.of(\"$sortArray\", {\n\t\t\tinput: merged.node,\n\t\t\tsortBy: MongoAggLiteral.of(1)\n\t\t});\n\t}\n\tasync readMarker(driver, space) {\n\t\tconst doc = (await withMarkerReadErrorHandling(() => this.#execute(driver, this.#markerLedgerCollection.aggregate().match((f) => f._id.eq(space)).match((f) => f.space.eq(space)).limit(1).build()), {\n\t\t\tspace,\n\t\t\tmarkerLocation: MONGO_MARKER_COLLECTION\n\t\t}))[0];\n\t\tif (!doc) return null;\n\t\treturn parseMongoMarkerDocSafely(doc, space);\n\t}\n\tasync readAllMarkers(driver) {\n\t\tconst docs = await withMarkerReadErrorHandling(() => this.#execute(driver, this.#markerLedgerCollection.aggregate().match((f) => f._id.type(\"string\")).match((f) => f.space.type(\"string\")).match((f) => expr(fn.eq(f._id, f.space))).build()), {\n\t\t\tspace: APP_SPACE_ID,\n\t\t\tmarkerLocation: MONGO_MARKER_COLLECTION\n\t\t});\n\t\tconst out = /* @__PURE__ */ new Map();\n\t\tfor (const doc of docs) {\n\t\t\tconst space = doc[\"space\"];\n\t\t\t/* v8 ignore next -- @preserve type-narrowing guard: the $match stage above filters on `space: { $type: 'string' }`, so this branch is unreachable at runtime. The check exists so the `out.set(space, ...)` call below can accept `string`. */\n\t\t\tif (typeof space !== \"string\") continue;\n\t\t\tout.set(space, parseMongoMarkerDocSafely(doc, space));\n\t\t}\n\t\treturn out;\n\t}\n\tasync initMarker(driver, space, destination) {\n\t\tconst { databasePolicies } = destination;\n\t\tconst document = {\n\t\t\t_id: space,\n\t\t\tspace,\n\t\t\tstorageHash: destination.storageHash,\n\t\t\tprofileHash: destination.profileHash,\n\t\t\tcontractJson: null,\n\t\t\tcanonicalVersion: null,\n\t\t\tupdatedAt: /* @__PURE__ */ new Date(),\n\t\t\tappTag: null,\n\t\t\tmeta: databasePolicies === void 0 ? {} : { [DATABASE_POLICIES_META_KEY]: policiesDocument(databasePolicies) },\n\t\t\tinvariants: [...destination.invariants ?? []]\n\t\t};\n\t\tawait this.#execute(driver, this.#markerLedgerCollection.insertOne(document));\n\t}\n\tasync updateMarker(driver, space, expectedFrom, destination, checkedPolicies) {\n\t\tconst { invariants, databasePolicies } = destination;\n\t\tconst fields = {\n\t\t\tstorageHash: MongoAggLiteral.of(destination.storageHash),\n\t\t\tprofileHash: MongoAggLiteral.of(destination.profileHash),\n\t\t\tupdatedAt: MongoAggLiteral.of(/* @__PURE__ */ new Date()),\n\t\t\t...ifDefined(\"invariants\", invariants === void 0 ? void 0 : this.#invariantMergeExpr(invariants)),\n\t\t\t...ifDefined(POLICIES_PATH, databasePolicies === void 0 ? void 0 : MongoAggLiteral.of(policiesDocument(databasePolicies)))\n\t\t};\n\t\tconst atExpectedHash = this.#markerLedgerCollection.match((f) => f._id.eq(space)).match((f) => f.space.eq(space)).match((f) => f.storageHash.eq(expectedFrom));\n\t\tconst guarded = checkedPolicies === void 0 ? atExpectedHash : atExpectedHash.match(() => MongoExprFilter.of(policiesHoldExpr(checkedPolicies)));\n\t\treturn (await this.#execute(driver, guarded.findOneAndUpdate((f) => [f.stage.set(fields)], { upsert: false }))).length > 0;\n\t}\n\tasync writeLedgerEntry(driver, space, entry) {\n\t\tconst document = {\n\t\t\ttype: \"ledger\",\n\t\t\tspace,\n\t\t\tedgeId: entry.edgeId,\n\t\t\tfrom: entry.from,\n\t\t\tto: entry.to,\n\t\t\tmigrationName: entry.migrationName,\n\t\t\tmigrationHash: entry.migrationHash,\n\t\t\toperations: blindCast(entry.operations),\n\t\t\tappliedAt: /* @__PURE__ */ new Date()\n\t\t};\n\t\tawait this.#execute(driver, this.#markerLedgerCollection.insertOne(document));\n\t}\n\tasync readLedger(driver, space) {\n\t\tconst ledgerContext = {\n\t\t\tspace: space ?? \"*\",\n\t\t\tmarkerLocation: MONGO_LEDGER_COLLECTION\n\t\t};\n\t\tconst chain = this.#markerLedgerCollection.aggregate().match((f) => f.type.eq(\"ledger\"));\n\t\tconst command = space === void 0 ? chain.sort({ _id: 1 }).build() : chain.match((f) => f.space.eq(space)).sort({ _id: 1 }).build();\n\t\tconst docs = await withMarkerReadErrorHandling(() => this.#execute(driver, command), ledgerContext);\n\t\tconst entries = [];\n\t\tfor (const doc of docs) {\n\t\t\tconst migrationName = doc[\"migrationName\"];\n\t\t\tconst migrationHash = doc[\"migrationHash\"];\n\t\t\tconst from = doc[\"from\"];\n\t\t\tconst to = doc[\"to\"];\n\t\t\tconst docSpace = doc[\"space\"];\n\t\t\tif (typeof migrationName !== \"string\" || typeof migrationHash !== \"string\") continue;\n\t\t\tif (typeof from !== \"string\" || typeof to !== \"string\") continue;\n\t\t\tif (typeof docSpace !== \"string\") continue;\n\t\t\tconst appliedAt = doc[\"appliedAt\"];\n\t\t\tconst appliedAtDate = appliedAt instanceof Date ? appliedAt : appliedAt !== void 0 ? new Date(String(appliedAt)) : /* @__PURE__ */ new Date();\n\t\t\tconst operations = doc[\"operations\"];\n\t\t\tconst opList = Array.isArray(operations) ? operations : [];\n\t\t\tentries.push({\n\t\t\t\tspace: docSpace,\n\t\t\t\tmigrationName,\n\t\t\t\tmigrationHash,\n\t\t\t\tfrom: ledgerOriginFromStored(from),\n\t\t\t\tto,\n\t\t\t\tappliedAt: appliedAtDate,\n\t\t\t\toperationCount: opList.length\n\t\t\t});\n\t\t}\n\t\treturn entries;\n\t}\n\tasync introspectSchema(driver) {\n\t\treturn introspectSchema(extractDb(driver));\n\t}\n\tcreateRunnerDependencies(driver) {\n\t\tconst controlDriver = requireMongoControlDriver(driver);\n\t\treturn {\n\t\t\tinspectionExecutor: new MongoInspectionExecutor(controlDriver.db),\n\t\t\tadapter: this.#adapter,\n\t\t\tdriver: controlDriver,\n\t\t\texecuteDdl: (command) => this.executeDdl(controlDriver, command),\n\t\t\tmarkerOps: {\n\t\t\t\tmarkerLocation: this.markerLocation,\n\t\t\t\treadMarker: (space) => this.readMarker(controlDriver, space),\n\t\t\t\tinitMarker: (space, destination) => this.initMarker(controlDriver, space, destination),\n\t\t\t\tupdateMarker: (space, expectedFrom, destination, checkedPolicies) => this.updateMarker(controlDriver, space, expectedFrom, destination, checkedPolicies),\n\t\t\t\twriteLedgerEntry: (space, entry) => this.writeLedgerEntry(controlDriver, space, entry)\n\t\t\t},\n\t\t\tintrospectSchema: () => this.introspectSchema(controlDriver)\n\t\t};\n\t}\n};\n//#endregion\n//#region src/exports/control.ts\nconst mongoAdapterDescriptor = {\n\tkind: \"adapter\",\n\tid: \"mongo\",\n\tfamilyId: \"mongo\",\n\ttargetId: \"mongo\",\n\tversion: \"0.0.1\",\n\ttypes: { codecTypes: {\n\t\timport: {\n\t\t\tpackage: \"@internal/target-mongo/codec-types\",\n\t\t\tnamed: \"CodecTypes\",\n\t\t\talias: \"MongoCodecTypes\"\n\t\t},\n\t\tparameterizedOutputTypes: {\n\t\t\tpackage: \"@internal/target-mongo/codec-types\",\n\t\t\tnamed: \"ParameterizedOutputTypesForTypeParams\",\n\t\t\talias: \"MongoParameterizedOutputTypes\"\n\t\t}\n\t} },\n\tcreate(stack) {\n\t\treturn new MongoControlAdapterImpl(assembleMongoCodecRegistry([\n\t\t\tstack.target,\n\t\t\t...stack.adapter === void 0 ? [] : [stack.adapter],\n\t\t\t...stack.extensions\n\t\t]));\n\t}\n};\n//#endregion\nexport { MongoControlAdapterImpl, MongoInspectionExecutor, createMongoAdapter, mongoAdapterDescriptor as default, mongoAdapterDescriptor, extractDb, introspectSchema, isMongoControlDriver };\n\n//# sourceMappingURL=control.mjs.map"],"mappings":";;;;;;;;;;;;;;;AAeA,MAAM,+BAA+B;AACrC,SAAS,eAAe,SAAS;CAChC,MAAM,OAAO,CAAC;CACd,KAAK,MAAM,CAAC,OAAO,cAAc,OAAO,QAAQ,OAAO,GAAG,KAAK,KAAK;EACnE;EACA;CACD,CAAC;CACD,OAAO;AACR;;;;;;AAMA,SAAS,iBAAiB,KAAK;CAC9B,MAAM,MAAM,IAAI;CAChB,IAAI,CAAC,KAAK,OAAO;CACjB,MAAM,UAAU,OAAO,QAAQ,GAAG;CAClC,OAAO,QAAQ,WAAW,KAAK,QAAQ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W;IACrF,eAAe,OAAO,cAAc,aAAa,oBAAoB,KAAK,aAAa,eAAe,OAAO,cAAc,aAAa,eAAe;IACvJ,mBAAmB,OAAO,UAAU,KAAK,iBAAiB,eAAe,OAAO,KAAK;GACtF;GACA,wBAAwB,KAAK,iBAAiB,aAAa;EAC5D;CACD;AACD;AAGA,MAAM,yBAAyB;CAC9B,MAAM;CACN,IAAI;CACJ,UAAU;CACV,UAAU;CACV,SAAS;CACT,OAAO,EAAE,YAAY;EACpB,QAAQ;GACP,SAAS;GACT,OAAO;GACP,OAAO;EACR;EACA,0BAA0B;GACzB,SAAS;GACT,OAAO;GACP,OAAO;EACR;CACD,EAAE;CACF,OAAO,OAAO;EACb,OAAO,IAAI,wBAAwB,2BAA2B;GAC7D,MAAM;GACN,GAAG,MAAM,YAAY,KAAK,IAAI,CAAC,IAAI,CAAC,MAAM,OAAO;GACjD,GAAG,MAAM;EACV,CAAC,CAAC;CACH;AACD"}
1
+ {"version":3,"file":"adapter__control.mjs","names":["#adapter","#execute","#markerLedgerCollection","#invariantMergeExpr"],"sources":["../../../../3-targets/mongo/2-adapter/dist/control.mjs"],"sourcesContent":["import { t as createMongoAdapter } from \"./mongo-adapter-DemWVyNv.mjs\";\nimport { MongoAggCond, MongoAggFieldRef, MongoAggLiteral, MongoAggMap, MongoAggOperator, MongoExprFilter } from \"@internal/mongo-query-ast/execution\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { structuredError } from \"@internal/utils/structured-error\";\nimport { assembleMongoCodecRegistry } from \"@internal/mongo-codec\";\nimport { MongoSchemaCollection, MongoSchemaCollectionOptions, MongoSchemaIR, MongoSchemaIndex, MongoSchemaValidator } from \"@internal/mongo-schema-ir\";\nimport { MongoServerError } from \"mongodb\";\nimport { parseMarkerRowSafely, withMarkerReadErrorHandling } from \"@internal/errors/execution\";\nimport { APP_SPACE_ID, DATABASE_POLICIES_KEYS, DATABASE_POLICIES_META_KEY, DATA_PROTECTION_KEYS, DEFAULT_DATABASE_POLICIES, storedDatabasePolicies } from \"@internal/framework-components/control\";\nimport { ledgerOriginFromStored } from \"@internal/migration-tools/ledger-origin\";\nimport { expr, fn } from \"@internal/mongo-query-builder\";\nimport { collection } from \"@internal/mongo-query-builder/contract-free\";\nimport { type } from \"arktype\";\n//#region src/core/introspect-schema.ts\nconst PRISMA_MIGRATIONS_COLLECTION = \"_prisma_migrations\";\nfunction parseIndexKeys(keySpec) {\n\tconst keys = [];\n\tfor (const [field, direction] of Object.entries(keySpec)) keys.push({\n\t\tfield,\n\t\tdirection\n\t});\n\treturn keys;\n}\n/**\n* Exported for unit tests to exercise the defensive `!key` guard; not part of\n* the public API. Callers in this package use it via the `introspectSchema`\n* pipeline only.\n*/\nfunction isDefaultIdIndex(doc) {\n\tconst key = doc[\"key\"];\n\tif (!key) return false;\n\tconst entries = Object.entries(key);\n\treturn entries.length === 1 && entries[0]?.[0] === \"_id\" && entries[0]?.[1] === 1;\n}\nfunction parseIndex(doc) {\n\tconst keySpec = doc[\"key\"];\n\treturn new MongoSchemaIndex({\n\t\tname: String(doc[\"name\"]),\n\t\tkeys: parseIndexKeys(keySpec),\n\t\tunique: doc[\"unique\"],\n\t\tsparse: doc[\"sparse\"],\n\t\texpireAfterSeconds: doc[\"expireAfterSeconds\"],\n\t\tpartialFilterExpression: doc[\"partialFilterExpression\"],\n\t\twildcardProjection: doc[\"wildcardProjection\"],\n\t\tcollation: doc[\"collation\"] ? blindCast(doc[\"collation\"]) : void 0,\n\t\tweights: doc[\"weights\"],\n\t\tdefault_language: doc[\"default_language\"],\n\t\tlanguage_override: doc[\"language_override\"]\n\t});\n}\nfunction parseValidator(options) {\n\tconst validator = options[\"validator\"];\n\tif (!validator) return void 0;\n\tconst jsonSchema = validator[\"$jsonSchema\"];\n\tif (!jsonSchema) return void 0;\n\treturn new MongoSchemaValidator({\n\t\tjsonSchema,\n\t\tvalidationLevel: options[\"validationLevel\"] ?? \"strict\",\n\t\tvalidationAction: options[\"validationAction\"] ?? \"error\"\n\t});\n}\nfunction parseCollectionOptions(info) {\n\tconst options = info[\"options\"];\n\tif (!options) return void 0;\n\tconst capped = options[\"capped\"];\n\tconst size = options[\"size\"];\n\tconst max = options[\"max\"];\n\tconst timeseries = options[\"timeseries\"];\n\tconst collation = options[\"collation\"] ? blindCast(options[\"collation\"]) : void 0;\n\tconst changeStreamPreAndPostImages = options[\"changeStreamPreAndPostImages\"];\n\tconst clusteredIndex = options[\"clusteredIndex\"];\n\tif (!(capped || timeseries || collation || changeStreamPreAndPostImages || clusteredIndex)) return void 0;\n\treturn new MongoSchemaCollectionOptions({\n\t\t...capped ? { capped: {\n\t\t\tsize: size ?? 0,\n\t\t\t...max != null ? { max } : {}\n\t\t} } : {},\n\t\t...timeseries ? { timeseries } : {},\n\t\t...collation ? { collation } : {},\n\t\t...changeStreamPreAndPostImages ? { changeStreamPreAndPostImages } : {},\n\t\t...clusteredIndex ? { clusteredIndex } : {}\n\t});\n}\nasync function introspectSchema(db) {\n\tconst collectionInfos = await db.listCollections().toArray();\n\tconst collections = [];\n\tfor (const info of collectionInfos) {\n\t\tconst name = info[\"name\"];\n\t\tconst type = info[\"type\"];\n\t\tif (name === PRISMA_MIGRATIONS_COLLECTION) continue;\n\t\tif (name.startsWith(\"system.\")) continue;\n\t\tif (type === \"view\") continue;\n\t\tconst indexes = (await db.collection(name).listIndexes().toArray()).filter((doc) => !isDefaultIdIndex(doc)).map(parseIndex);\n\t\tconst validator = parseValidator(\"options\" in info ? info[\"options\"] : {});\n\t\tconst options = parseCollectionOptions(info);\n\t\tcollections.push(new MongoSchemaCollection({\n\t\t\tname,\n\t\t\tindexes,\n\t\t\t...validator ? { validator } : {},\n\t\t\t...options ? { options } : {}\n\t\t}));\n\t}\n\treturn new MongoSchemaIR(collections, { fromDatabase: true });\n}\n//#endregion\n//#region src/core/migrations/inspection-executor.ts\n/**\n* Executes the read-only catalog inspections (`listCollections` / `listIndexes`)\n* that migration prechecks/postchecks and operation preview evaluate, directly\n* against `db`. Routing these checks through the adapter's lowering seam is\n* deferred to the `typed-migration-verification-queries` slice.\n*/\nvar MongoInspectionExecutor = class {\n\tdb;\n\tconstructor(db) {\n\t\tthis.db = db;\n\t}\n\tasync listIndexes(cmd) {\n\t\ttry {\n\t\t\treturn await this.db.collection(cmd.collection).listIndexes().toArray();\n\t\t} catch (error) {\n\t\t\tif (error instanceof MongoServerError && error.code === 26) return [];\n\t\t\tthrow error;\n\t\t}\n\t}\n\tasync listCollections(_cmd) {\n\t\treturn this.db.listCollections().toArray();\n\t}\n};\n//#endregion\n//#region src/core/errors.ts\nfunction mongoAdapterError(code, message, options) {\n\treturn structuredError(code, message, options);\n}\nfunction describeReceivedValue(value) {\n\tif (value === null) return \"null\";\n\tif (typeof value !== \"object\") return typeof value;\n\treturn `object with keys [${Object.keys(value).join(\", \")}]`;\n}\n//#endregion\n//#region src/core/marker-ledger.ts\nconst COLLECTION = \"_prisma_migrations\";\nconst MONGO_MARKER_COLLECTION = COLLECTION;\nconst MONGO_LEDGER_COLLECTION = `_prisma_migrations ledger documents in ${COLLECTION}`;\nconst MongoMarkerDocSchema = type({\n\tspace: \"string\",\n\tstorageHash: \"string\",\n\tprofileHash: \"string\",\n\t\"contractJson?\": \"unknown | null\",\n\t\"canonicalVersion?\": \"number | null\",\n\t\"updatedAt?\": \"Date\",\n\t\"appTag?\": \"string | null\",\n\t\"meta?\": type({ \"[string]\": \"unknown\" }).or(\"null\"),\n\t\"invariants?\": type(\"string\").array(),\n\t\"+\": \"delete\"\n});\nfunction parseMongoMarkerDoc(doc) {\n\tconst result = MongoMarkerDocSchema(doc);\n\tif (result instanceof type.errors) throw mongoAdapterError(\"CONTRACT.MARKER_ROW_CORRUPT\", `Invalid marker doc on ${COLLECTION}: ${result.summary}`, { meta: {\n\t\tcollection: COLLECTION,\n\t\tdetail: result.summary\n\t} });\n\treturn {\n\t\tstorageHash: result.storageHash,\n\t\tprofileHash: result.profileHash,\n\t\tcontractJson: result.contractJson ?? null,\n\t\tcanonicalVersion: result.canonicalVersion ?? null,\n\t\tupdatedAt: result.updatedAt ?? /* @__PURE__ */ new Date(),\n\t\tappTag: result.appTag ?? null,\n\t\tmeta: result.meta ?? {},\n\t\tinvariants: result.invariants ?? []\n\t};\n}\nfunction parseMongoMarkerDocSafely(doc, space) {\n\treturn parseMarkerRowSafely(doc, parseMongoMarkerDoc, {\n\t\tspace,\n\t\tmarkerLocation: MONGO_MARKER_COLLECTION\n\t});\n}\n//#endregion\n//#region src/core/marker-ledger-collection.ts\nconst MARKER_LEDGER_COLLECTION = \"_prisma_migrations\";\n//#endregion\n//#region src/core/migrations/mongo-control-driver.ts\nfunction isMongoControlDriver(driver) {\n\treturn driver.familyId === \"mongo\" && driver.targetId === \"mongo\" && \"execute\" in driver && typeof driver.execute === \"function\";\n}\nfunction requireMongoControlDriver(driver) {\n\tif (!isMongoControlDriver(driver)) throw mongoAdapterError(\"CONFIG.VALIDATION_FAILED\", \"Expected a Mongo control driver created by mongoControlDriver.create() from `@internal/driver-mongo/control`.\", { meta: { received: describeReceivedValue(driver) } });\n\treturn driver;\n}\nfunction extractDb(driver) {\n\treturn requireMongoControlDriver(driver).db;\n}\n//#endregion\n//#region src/core/migrations/mongo-control-adapter.ts\nfunction policiesDocument(policies) {\n\tconst stored = storedDatabasePolicies(policies);\n\treturn {\n\t\tchange: stored.change,\n\t\tdataProtection: { ...stored.dataProtection }\n\t};\n}\nconst POLICIES_PATH = `meta.${DATABASE_POLICIES_META_KEY}`;\nfunction typeOf(path) {\n\treturn MongoAggOperator.of(\"$type\", MongoAggFieldRef.of(path));\n}\n/**\n* Holds while `path` is missing, or is an object carrying no key outside `keys`: the framework parser\n* rejects any other key, so a marker with one does not hold the checked policies.\n*/\nfunction missingOrObjectOf(path, keys) {\n\tconst keysAtPath = MongoAggMap.of(MongoAggOperator.of(\"$objectToArray\", MongoAggFieldRef.of(path)), MongoAggFieldRef.of(\"$entry.k\"), \"entry\");\n\treturn MongoAggCond.of(MongoAggOperator.of(\"$eq\", [typeOf(path), MongoAggLiteral.of(\"object\")]), MongoAggOperator.of(\"$setIsSubset\", [keysAtPath, MongoAggLiteral.of([...keys])]), MongoAggOperator.of(\"$eq\", [typeOf(path), MongoAggLiteral.of(\"missing\")]));\n}\nfunction missingWhenDefault(path, isDefault) {\n\treturn isDefault ? MongoAggOperator.of(\"$eq\", [typeOf(path), MongoAggLiteral.of(\"missing\")]) : MongoAggLiteral.of(false);\n}\nfunction settingHolds(path, value, defaultValue) {\n\treturn MongoAggOperator.of(\"$or\", [MongoAggOperator.of(\"$eq\", [MongoAggFieldRef.of(path), MongoAggLiteral.of(value)]), missingWhenDefault(path, value === defaultValue)]);\n}\nfunction sameStrategies(a, b) {\n\tconst left = new Set(a);\n\tconst right = new Set(b);\n\treturn left.size === right.size && [...left].every((strategy) => right.has(strategy));\n}\n/**\n* An aggregation predicate that holds while the marker's `meta.policies` reads as `checkedPolicies`,\n* however it is stored. It follows the framework parser and its defaults: no key outside\n* {@link DATABASE_POLICIES_KEYS} and {@link DATA_PROTECTION_KEYS}, `change` compared as a set, each\n* data protection setting by value, and an absent setting matching only its default.\n*/\nfunction policiesHoldExpr(checkedPolicies) {\n\tconst changePath = `${POLICIES_PATH}.change`;\n\tconst dataProtectionPath = `${POLICIES_PATH}.dataProtection`;\n\tconst defaults = DEFAULT_DATABASE_POLICIES;\n\tconst { change, dataProtection } = checkedPolicies;\n\treturn MongoAggOperator.of(\"$and\", [\n\t\tmissingOrObjectOf(POLICIES_PATH, DATABASE_POLICIES_KEYS),\n\t\tMongoAggCond.of(MongoAggOperator.of(\"$isArray\", MongoAggFieldRef.of(changePath)), MongoAggOperator.of(\"$setEquals\", [MongoAggFieldRef.of(changePath), MongoAggLiteral.of([...change])]), missingWhenDefault(changePath, sameStrategies(change, defaults.change))),\n\t\tmissingOrObjectOf(dataProtectionPath, DATA_PROTECTION_KEYS),\n\t\t...DATA_PROTECTION_KEYS.map((key) => settingHolds(`${dataProtectionPath}.${key}`, dataProtection[key], defaults.dataProtection[key]))\n\t]);\n}\n/**\n* Mongo control adapter for control-plane operations like introspection\n* and marker-ledger CAS. Implements the family-level `MongoControlAdapter`\n* SPI. Every marker/ledger operation builds a canonical command inline via\n* the contract-free fluent builder and dispatches it through the family\n* adapter's lowering path (`createMongoAdapter().lower(plan, {})`) onto the\n* Mongo wire transport (`driver.execute(wireCommand)`) — the same route SQL\n* marker/ledger ops take through `adapter.lower()` → `driver.query()`.\n*/\nvar MongoControlAdapterImpl = class {\n\tfamilyId = \"mongo\";\n\ttargetId = \"mongo\";\n\tmarkerLocation = MONGO_MARKER_COLLECTION;\n\t#adapter;\n\t#markerLedgerCollection = collection(MARKER_LEDGER_COLLECTION);\n\tconstructor(codecs) {\n\t\tthis.#adapter = createMongoAdapter(codecs);\n\t}\n\tasync #execute(driver, command) {\n\t\tconst plan = {\n\t\t\tcollection: MARKER_LEDGER_COLLECTION,\n\t\t\tcommand,\n\t\t\tmeta: {\n\t\t\t\ttarget: \"mongo\",\n\t\t\t\ttargetFamily: \"mongo\",\n\t\t\t\tstorageHash: \"\",\n\t\t\t\tlane: \"control\"\n\t\t\t}\n\t\t};\n\t\tconst wireCommand = await this.#adapter.lower(plan, {});\n\t\tif (!isMongoControlDriver(driver)) throw mongoAdapterError(\"CONFIG.VALIDATION_FAILED\", \"Mongo control adapter requires a Mongo control driver with an execute() transport. Provide a MongoControlDriver from `@internal/driver-mongo/control`.\", { meta: { received: describeReceivedValue(driver) } });\n\t\tconst rows = [];\n\t\tfor await (const row of driver.execute(wireCommand)) rows.push(row);\n\t\treturn rows;\n\t}\n\tasync executeDdl(driver, command) {\n\t\tconst wire = await this.#adapter.lower({ command }, {});\n\t\tawait driver.run(wire);\n\t}\n\t/**\n\t* Server-side invariant-merge aggregation expression:\n\t* `$sortArray({ input: $setUnion([$ifNull('$invariants', []), incoming]), sortBy: 1 })`.\n\t*\n\t* Built through the typed agg-expr layer — `fn.setUnion` plus the generic\n\t* `MongoAggOperator` for `$ifNull` / `$sortArray` (neither has a named `fn`\n\t* helper). Returns a `MongoAggOperator` that is passed directly to\n\t* `f.stage.set({ invariants: ... })` in the update pipeline.\n\t*/\n\t#invariantMergeExpr(incoming) {\n\t\tconst existingOrEmpty = MongoAggOperator.of(\"$ifNull\", [MongoAggFieldRef.of(\"invariants\"), MongoAggLiteral.of([])]);\n\t\tconst merged = fn.setUnion({\n\t\t\t_field: {\n\t\t\t\tcodecId: \"mongo/array@1\",\n\t\t\t\tnullable: false\n\t\t\t},\n\t\t\tnode: existingOrEmpty\n\t\t}, {\n\t\t\t_field: {\n\t\t\t\tcodecId: \"mongo/array@1\",\n\t\t\t\tnullable: false\n\t\t\t},\n\t\t\tnode: MongoAggLiteral.of([...incoming])\n\t\t});\n\t\treturn MongoAggOperator.of(\"$sortArray\", {\n\t\t\tinput: merged.node,\n\t\t\tsortBy: MongoAggLiteral.of(1)\n\t\t});\n\t}\n\tasync readMarker(driver, space) {\n\t\tconst doc = (await withMarkerReadErrorHandling(() => this.#execute(driver, this.#markerLedgerCollection.aggregate().match((f) => f._id.eq(space)).match((f) => f.space.eq(space)).limit(1).build()), {\n\t\t\tspace,\n\t\t\tmarkerLocation: MONGO_MARKER_COLLECTION\n\t\t}))[0];\n\t\tif (!doc) return null;\n\t\treturn parseMongoMarkerDocSafely(doc, space);\n\t}\n\tasync readAllMarkers(driver) {\n\t\tconst docs = await withMarkerReadErrorHandling(() => this.#execute(driver, this.#markerLedgerCollection.aggregate().match((f) => f._id.type(\"string\")).match((f) => f.space.type(\"string\")).match((f) => expr(fn.eq(f._id, f.space))).build()), {\n\t\t\tspace: APP_SPACE_ID,\n\t\t\tmarkerLocation: MONGO_MARKER_COLLECTION\n\t\t});\n\t\tconst out = /* @__PURE__ */ new Map();\n\t\tfor (const doc of docs) {\n\t\t\tconst space = doc[\"space\"];\n\t\t\t/* v8 ignore next -- @preserve type-narrowing guard: the $match stage above filters on `space: { $type: 'string' }`, so this branch is unreachable at runtime. The check exists so the `out.set(space, ...)` call below can accept `string`. */\n\t\t\tif (typeof space !== \"string\") continue;\n\t\t\tout.set(space, parseMongoMarkerDocSafely(doc, space));\n\t\t}\n\t\treturn out;\n\t}\n\tasync initMarker(driver, space, destination) {\n\t\tconst { databasePolicies } = destination;\n\t\tconst document = {\n\t\t\t_id: space,\n\t\t\tspace,\n\t\t\tstorageHash: destination.storageHash,\n\t\t\tprofileHash: destination.profileHash,\n\t\t\tcontractJson: null,\n\t\t\tcanonicalVersion: null,\n\t\t\tupdatedAt: /* @__PURE__ */ new Date(),\n\t\t\tappTag: null,\n\t\t\tmeta: databasePolicies === void 0 ? {} : { [DATABASE_POLICIES_META_KEY]: policiesDocument(databasePolicies) },\n\t\t\tinvariants: [...destination.invariants ?? []]\n\t\t};\n\t\tawait this.#execute(driver, this.#markerLedgerCollection.insertOne(document));\n\t}\n\tasync updateMarker(driver, space, expectedFrom, destination, checkedPolicies) {\n\t\tconst { invariants, databasePolicies } = destination;\n\t\tconst fields = {\n\t\t\tstorageHash: MongoAggLiteral.of(destination.storageHash),\n\t\t\tprofileHash: MongoAggLiteral.of(destination.profileHash),\n\t\t\tupdatedAt: MongoAggLiteral.of(/* @__PURE__ */ new Date()),\n\t\t\t...ifDefined(\"invariants\", invariants === void 0 ? void 0 : this.#invariantMergeExpr(invariants)),\n\t\t\t...ifDefined(POLICIES_PATH, databasePolicies === void 0 ? void 0 : MongoAggLiteral.of(policiesDocument(databasePolicies)))\n\t\t};\n\t\tconst atExpectedHash = this.#markerLedgerCollection.match((f) => f._id.eq(space)).match((f) => f.space.eq(space)).match((f) => f.storageHash.eq(expectedFrom));\n\t\tconst guarded = checkedPolicies === void 0 ? atExpectedHash : atExpectedHash.match(() => MongoExprFilter.of(policiesHoldExpr(checkedPolicies)));\n\t\treturn (await this.#execute(driver, guarded.findOneAndUpdate((f) => [f.stage.set(fields)], { upsert: false }))).length > 0;\n\t}\n\tasync writeLedgerEntry(driver, space, entry) {\n\t\tconst document = {\n\t\t\ttype: \"ledger\",\n\t\t\tspace,\n\t\t\tedgeId: entry.edgeId,\n\t\t\tfrom: entry.from,\n\t\t\tto: entry.to,\n\t\t\tmigrationName: entry.migrationName,\n\t\t\tmigrationHash: entry.migrationHash,\n\t\t\toperations: blindCast(entry.operations),\n\t\t\tappliedAt: /* @__PURE__ */ new Date()\n\t\t};\n\t\tawait this.#execute(driver, this.#markerLedgerCollection.insertOne(document));\n\t}\n\tasync readLedger(driver, space) {\n\t\tconst ledgerContext = {\n\t\t\tspace: space ?? \"*\",\n\t\t\tmarkerLocation: MONGO_LEDGER_COLLECTION\n\t\t};\n\t\tconst chain = this.#markerLedgerCollection.aggregate().match((f) => f.type.eq(\"ledger\"));\n\t\tconst command = space === void 0 ? chain.sort({ _id: 1 }).build() : chain.match((f) => f.space.eq(space)).sort({ _id: 1 }).build();\n\t\tconst docs = await withMarkerReadErrorHandling(() => this.#execute(driver, command), ledgerContext);\n\t\tconst entries = [];\n\t\tfor (const doc of docs) {\n\t\t\tconst migrationName = doc[\"migrationName\"];\n\t\t\tconst migrationHash = doc[\"migrationHash\"];\n\t\t\tconst from = doc[\"from\"];\n\t\t\tconst to = doc[\"to\"];\n\t\t\tconst docSpace = doc[\"space\"];\n\t\t\tif (typeof migrationName !== \"string\" || typeof migrationHash !== \"string\") continue;\n\t\t\tif (typeof from !== \"string\" || typeof to !== \"string\") continue;\n\t\t\tif (typeof docSpace !== \"string\") continue;\n\t\t\tconst appliedAt = doc[\"appliedAt\"];\n\t\t\tconst appliedAtDate = appliedAt instanceof Date ? appliedAt : appliedAt !== void 0 ? new Date(String(appliedAt)) : /* @__PURE__ */ new Date();\n\t\t\tconst operations = doc[\"operations\"];\n\t\t\tconst opList = Array.isArray(operations) ? operations : [];\n\t\t\tentries.push({\n\t\t\t\tspace: docSpace,\n\t\t\t\tmigrationName,\n\t\t\t\tmigrationHash,\n\t\t\t\tfrom: ledgerOriginFromStored(from),\n\t\t\t\tto,\n\t\t\t\tappliedAt: appliedAtDate,\n\t\t\t\toperationCount: opList.length\n\t\t\t});\n\t\t}\n\t\treturn entries;\n\t}\n\tasync introspectSchema(driver) {\n\t\treturn introspectSchema(extractDb(driver));\n\t}\n\tcreateRunnerDependencies(driver) {\n\t\tconst controlDriver = requireMongoControlDriver(driver);\n\t\treturn {\n\t\t\tinspectionExecutor: new MongoInspectionExecutor(controlDriver.db),\n\t\t\tadapter: this.#adapter,\n\t\t\tdriver: controlDriver,\n\t\t\texecuteDdl: (command) => this.executeDdl(controlDriver, command),\n\t\t\tmarkerOps: {\n\t\t\t\tmarkerLocation: this.markerLocation,\n\t\t\t\treadMarker: (space) => this.readMarker(controlDriver, space),\n\t\t\t\tinitMarker: (space, destination) => this.initMarker(controlDriver, space, destination),\n\t\t\t\tupdateMarker: (space, expectedFrom, destination, checkedPolicies) => this.updateMarker(controlDriver, space, expectedFrom, destination, checkedPolicies),\n\t\t\t\twriteLedgerEntry: (space, entry) => this.writeLedgerEntry(controlDriver, space, entry)\n\t\t\t},\n\t\t\tintrospectSchema: () => this.introspectSchema(controlDriver)\n\t\t};\n\t}\n};\n//#endregion\n//#region src/core/target-module-base.ts\nconst targetModuleBase = typeof __PRISMA_PUBLISHED_MODULE_BASE__TARGET_MONGO === \"string\" ? __PRISMA_PUBLISHED_MODULE_BASE__TARGET_MONGO : \"@internal/target-mongo\";\n//#endregion\n//#region src/exports/control.ts\nconst mongoAdapterDescriptor = {\n\tkind: \"adapter\",\n\tid: \"mongo\",\n\tfamilyId: \"mongo\",\n\ttargetId: \"mongo\",\n\tversion: \"0.0.1\",\n\ttypes: { codecTypes: {\n\t\timport: {\n\t\t\tpackage: `${targetModuleBase}/codec-types`,\n\t\t\tnamed: \"CodecTypes\",\n\t\t\talias: \"MongoCodecTypes\"\n\t\t},\n\t\tparameterizedOutputTypes: {\n\t\t\tpackage: `${targetModuleBase}/codec-types`,\n\t\t\tnamed: \"ParameterizedOutputTypesForTypeParams\",\n\t\t\talias: \"MongoParameterizedOutputTypes\"\n\t\t}\n\t} },\n\tcreate(stack) {\n\t\treturn new MongoControlAdapterImpl(assembleMongoCodecRegistry([\n\t\t\tstack.target,\n\t\t\t...stack.adapter === void 0 ? [] : [stack.adapter],\n\t\t\t...stack.extensions\n\t\t]));\n\t}\n};\n//#endregion\nexport { MongoControlAdapterImpl, MongoInspectionExecutor, createMongoAdapter, mongoAdapterDescriptor as default, mongoAdapterDescriptor, extractDb, introspectSchema, isMongoControlDriver };\n\n//# sourceMappingURL=control.mjs.map"],"mappings":";;;;;;;;;;;;;;;AAeA,MAAM,+BAA+B;AACrC,SAAS,eAAe,SAAS;CAChC,MAAM,OAAO,CAAC;CACd,KAAK,MAAM,CAAC,OAAO,cAAc,OAAO,QAAQ,OAAO,GAAG,KAAK,KAAK;EACnE;EACA;CACD,CAAC;CACD,OAAO;AACR;;;;;;AAMA,SAAS,iBAAiB,KAAK;CAC9B,MAAM,MAAM,IAAI;CAChB,IAAI,CAAC,KAAK,OAAO;CACjB,MAAM,UAAU,OAAO,QAAQ,GAAG;CAClC,OAAO,QAAQ,WAAW,KAAK,QAAQ,EAAE,GAAG,OAAO,SAAS,QAAQ,EAAE,GAAG,OAAO;AACjF;AACA,SAAS,WAAW,KAAK;CACxB,MAAM,UAAU,IAAI;CACpB,OAAO,IAAI,iBAAiB;EAC3B,MAAM,OAAO,IAAI,OAAO;EACxB,MAAM,eAAe,OAAO;EAC5B,QAAQ,IAAI;EACZ,QAAQ,IAAI;EACZ,oBAAoB,IAAI;EACxB,yBAAyB,IAAI;EAC7B,oBAAoB,IAAI;EACxB,WAAW,IAAI,eAAe,UAAU,IAAI,YAAY,IAAI,KAAK;EACjE,SAAS,IAAI;EACb,kBAAkB,IAAI;EACtB,mBAAmB,IAAI;CACxB,CAAC;AACF;AACA,SAAS,eAAe,SAAS;CAChC,MAAM,YAAY,QAAQ;CAC1B,IAAI,CAAC,WAAW,OAAO,KAAK;CAC5B,MAAM,aAAa,UAAU;CAC7B,IAAI,CAAC,YAAY,OAAO,KAAK;CA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AAC,IAAI,CAAC,MAAM,OAAO;GACjD,GAAG,MAAM;EACV,CAAC,CAAC;CACH;AACD"}
@@ -1,5 +1,5 @@
1
- import { n as mongoNowGenerators } from "./date-time-now-generators-CGx9UUde-Bf7961yv.mjs";
2
- import { t as createMongoAdapter } from "./mongo-adapter-DemWVyNv-ClNih50Z.mjs";
1
+ import { n as mongoNowGenerators } from "./date-time-now-generators-ClztoylE-Bq7Fps2T.mjs";
2
+ import { t as createMongoAdapter } from "./mongo-adapter-DemWVyNv-ivErOBO6.mjs";
3
3
  import { assembleMongoCodecRegistry } from "@prisma/orm-family-mongo/codec";
4
4
  import { timestampNowRuntimeGenerator } from "@prisma/orm-family-mongo/family/runtime";
5
5
  //#region ../../../3-targets/mongo/2-adapter/dist/runtime.mjs
@@ -1,6 +1,6 @@
1
1
  import { _ as MONGO_STRING_CODEC_ID, a as MONGO_DATE_INSTANT_CODEC_ID, b as MONGO_VECTOR_CODEC_ID, c as MONGO_DATE_TEMPORAL_CODEC_ID, d as MONGO_DURATION_STRING_CODEC_ID, f as MONGO_INT32_CODEC_ID, g as MONGO_OBJECTID_CODEC_ID, h as MONGO_JSON_CODEC_ID, i as MONGO_DATE_CODEC_ID, l as MONGO_DECIMAL128_CODEC_ID, m as MONGO_INT64_NUMBER_CODEC_ID, n as MONGO_BOOLEAN_CODEC_ID, o as MONGO_DATE_INSTANT_STRING_CODEC_ID, p as MONGO_INT64_CODEC_ID, r as MONGO_BSON_CODEC_ID, s as MONGO_DATE_STRING_CODEC_ID, t as MONGO_BINARY_CODEC_ID, u as MONGO_DOUBLE_CODEC_ID, v as MONGO_TIME_STRING_CODEC_ID, y as MONGO_TIME_TEMPORAL_CODEC_ID } from "./codec-ids-DZQsuh80-ywDzfnAg.mjs";
2
2
  import { t as mongoTargetError } from "./mongo-target-errors-Btf3ML1w-QOtEG7EX.mjs";
3
- import { $ as mongoVector, B as mongoDecimal128, C as int64Decode, D as int64NumberFromDigits, E as int64NumberEncode, F as mongoBson, G as mongoInt32, H as mongoDuration, I as mongoCalendarDate, J as mongoObjectId, K as mongoInt64, L as mongoCalendarDateText, M as isPlainObject, N as mongoBinary, O as int64NumberToJson, P as mongoBool, Q as mongoTimeText, S as int32ToJson, T as int64NumberDecode, U as mongoDurationText, V as mongoDouble, W as mongoInstantText, Y as mongoString, Z as mongoTime, _ as decimal128ToJson, a as booleanEncode, at as vectorEncode, b as encodeBsonValue, c as bsonTypeTag, d as dateEncode, f as dateToJson, h as decimal128Encode, i as binaryToBase64, it as stringEncode, j as isPlainArray, k as int64ToJson, l as child, m as decimal128Decode, n as binaryEncode, nt as objectIdToJson, o as bsonClassTag, ot as where, p as dbRefEntries, q as mongoJson, r as binaryFromBase64, rt as readBsonJson, s as bsonToJson, t as binaryDecode, tt as objectIdEncode, u as constructorName, v as decodeBsonValue, w as int64Encode, x as int32Encode, y as doubleEncode, z as mongoDate } from "./data-types-BR7vssy0-CuNYIJHI.mjs";
3
+ import { B as mongoDouble, C as int64Decode, D as int64NumberFromDigits, E as int64NumberEncode, F as mongoCalendarDate, G as mongoInt64, H as mongoDurationText, I as mongoCalendarDateText, J as mongoString, K as mongoJson, M as mongoBinary, N as mongoBool, O as int64NumberToJson, P as mongoBson, Q as mongoVector, R as mongoDate, S as int32ToJson, T as int64NumberDecode, U as mongoInstantText, V as mongoDuration, W as mongoInt32, X as mongoTime, Z as mongoTimeText, _ as decimal128ToJson, a as booleanEncode, at as where, b as encodeBsonValue, c as bsonTypeTag, d as dateEncode, et as objectIdEncode, f as dateToJson, h as decimal128Encode, i as binaryToBase64, it as vectorEncode, j as isPlainObject, k as int64ToJson, l as child, m as decimal128Decode, n as binaryEncode, nt as readBsonJson, o as bsonClassTag, p as dbRefEntries, q as mongoObjectId, r as binaryFromBase64, rt as stringEncode, s as bsonToJson, t as binaryDecode, tt as objectIdToJson, u as constructorName, v as decodeBsonValue, w as int64Encode, x as int32Encode, y as doubleEncode, z as mongoDecimal128 } from "./data-types-DacjqiBe-D5ui4_5e.mjs";
4
4
  import { decimalTextBigintLiteral, decimalTextNumberLiteral, floatNumberLiteral, floatToJson, readJsonFloat, renderTsLiteral } from "@prisma/orm-framework/components/codec";
5
5
  import { hasDigitsBelowAMillisecond, isValidDate } from "@prisma/orm-framework/type-implementations/date";
6
6
  import { ifDefined } from "@prisma/orm-framework/utils/defined";
@@ -8,7 +8,8 @@ import { blindCast } from "@prisma/orm-framework/utils/casts";
8
8
  import { findTemporal } from "@prisma/orm-framework/type-implementations/temporal";
9
9
  import { mongoCodec, mongoCodecDescriptor } from "@prisma/orm-family-mongo/codec";
10
10
  import { describeValue, temporalFromText, temporalToText } from "@prisma/orm-framework/type-implementations/temporal-text";
11
- //#region ../../../3-targets/mongo/1-target/dist/codecs-BxTQKKXN.mjs
11
+ import { findNonJsonValue } from "@prisma/orm-framework/type-implementations/json";
12
+ //#region ../../../3-targets/mongo/1-target/dist/codecs-DKwnfU85.mjs
12
13
  const TEMPORAL_UNAVAILABLE_FIX = "Run on a runtime with Temporal available, install a Temporal polyfill before creating the client, or write the field as a convenience type at its default, which needs no Temporal: `DateTime` reads a JavaScript `Date`, and `Date`, `Time` and `Duration` read ISO 8601 strings.";
13
14
  function errorTemporalUnavailable(codecId, operation) {
14
15
  return mongoTargetError("RUNTIME.TEMPORAL_UNAVAILABLE", `Codec '${codecId}' cannot ${operation} a value because this runtime has no global Temporal implementation.`, {
@@ -312,34 +313,12 @@ function encodeRefused(received, path) {
312
313
  valuePath: path
313
314
  } });
314
315
  }
315
- function describeNonJson(value) {
316
- if (value === null || typeof value === "string" || typeof value === "boolean") return void 0;
317
- if (typeof value === "number") return Number.isFinite(value) ? void 0 : String(value);
318
- if (typeof value !== "object") return typeof value;
319
- const tag = bsonTypeTag(value);
320
- if (tag !== void 0) return tag;
321
- if (value instanceof Date) return "Date";
322
- if (isPlainArray(value)) return void 0;
323
- return isPlainObject(value) ? void 0 : constructorName(value);
324
- }
325
- function assertJsonValue(value, path, ancestors) {
326
- const received = describeNonJson(value);
327
- if (received !== void 0) encodeRefused(received, path);
328
- if (typeof value !== "object" || value === null) return;
329
- if (ancestors.has(value)) encodeRefused("circular reference", path);
330
- ancestors.add(value);
331
- if (Array.isArray(value)) for (let index = 0; index < value.length; index++) {
332
- if (!(index in value)) encodeRefused("sparse array hole", child(path, index));
333
- assertJsonValue(value[index], child(path, index), ancestors);
334
- }
335
- else for (const [key, entry] of Object.entries(value)) assertJsonValue(entry, child(path, key), ancestors);
336
- ancestors.delete(value);
337
- }
338
316
  /**
339
317
  * Returns `value` unchanged when it is a plain JSON value at every depth, and throws `RUNTIME.ENCODE_FAILED` naming the first value that is not, with its path.
340
318
  */
341
319
  function encodeJsonValue(value) {
342
- assertJsonValue(value, "", /* @__PURE__ */ new Set());
320
+ const found = findNonJsonValue(value, { tagOf: bsonTypeTag });
321
+ if (found !== void 0) encodeRefused(found.received, found.path);
343
322
  return value;
344
323
  }
345
324
  function decodeRefused(bsonType, path) {
@@ -617,4 +596,4 @@ function mongoDescriptorById(codecId) {
617
596
  //#endregion
618
597
  export { mongoDescriptorById as n, requireTemporal as r, mongoCodecDescriptors as t };
619
598
 
620
- //# sourceMappingURL=codecs-BxTQKKXN-p2W9ISNn.mjs.map
599
+ //# sourceMappingURL=codecs-DKwnfU85-BAZ4CD7m.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codecs-DKwnfU85-BAZ4CD7m.mjs","names":[],"sources":["../../../../3-targets/mongo/1-target/dist/codecs-DKwnfU85.mjs"],"sourcesContent":["import { _ as MONGO_STRING_CODEC_ID, a as MONGO_DATE_INSTANT_CODEC_ID, b as MONGO_VECTOR_CODEC_ID, c as MONGO_DATE_TEMPORAL_CODEC_ID, d as MONGO_DURATION_STRING_CODEC_ID, f as MONGO_INT32_CODEC_ID, g as MONGO_OBJECTID_CODEC_ID, h as MONGO_JSON_CODEC_ID, i as MONGO_DATE_CODEC_ID, l as MONGO_DECIMAL128_CODEC_ID, m as MONGO_INT64_NUMBER_CODEC_ID, n as MONGO_BOOLEAN_CODEC_ID, o as MONGO_DATE_INSTANT_STRING_CODEC_ID, p as MONGO_INT64_CODEC_ID, r as MONGO_BSON_CODEC_ID, s as MONGO_DATE_STRING_CODEC_ID, t as MONGO_BINARY_CODEC_ID, u as MONGO_DOUBLE_CODEC_ID, v as MONGO_TIME_STRING_CODEC_ID, y as MONGO_TIME_TEMPORAL_CODEC_ID } from \"./codec-ids-DZQsuh80.mjs\";\nimport { t as mongoTargetError } from \"./mongo-target-errors-Btf3ML1w.mjs\";\nimport { $ as int64NumberToJson, A as constructorName, B as dateToJson, C as bsonToJson, D as bsonClassTag, E as readBsonJson, F as binaryEncode, G as doubleEncode, H as decimal128Encode, I as binaryFromBase64, J as int64Decode, K as int32Encode, L as binaryToBase64, M as isPlainObject, N as where, O as bsonTypeTag, P as binaryDecode, Q as int64NumberFromDigits, R as booleanEncode, T as encodeBsonValue, V as decimal128Decode, W as decimal128ToJson, X as int64NumberDecode, Y as int64Encode, Z as int64NumberEncode, _ as mongoString, a as mongoCalendarDateText, at as vectorEncode, b as mongoTimeText, c as mongoDecimal128, d as mongoDurationText, et as int64ToJson, f as mongoInstantText, g as mongoObjectId, h as mongoJson, i as mongoCalendarDate, it as stringEncode, j as dbRefEntries, k as child, l as mongoDouble, m as mongoInt64, n as mongoBool, nt as objectIdEncode, p as mongoInt32, q as int32ToJson, r as mongoBson, rt as objectIdToJson, s as mongoDate, t as mongoBinary, u as mongoDuration, w as decodeBsonValue, x as mongoVector, y as mongoTime, z as dateEncode } from \"./data-types-DacjqiBe.mjs\";\nimport { decimalTextBigintLiteral, decimalTextNumberLiteral, floatNumberLiteral, floatToJson, readJsonFloat, renderTsLiteral } from \"@internal/framework-components/codec\";\nimport { hasDigitsBelowAMillisecond, isValidDate } from \"@internal/type-implementations/date\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { findTemporal } from \"@internal/type-implementations/temporal\";\nimport { mongoCodec, mongoCodecDescriptor } from \"@internal/mongo-codec\";\nimport { describeValue, temporalFromText, temporalToText } from \"@internal/type-implementations/temporal-text\";\nimport { findNonJsonValue } from \"@internal/type-implementations/json\";\n//#region src/core/date-time-errors.ts\nconst TEMPORAL_UNAVAILABLE_FIX = \"Run on a runtime with Temporal available, install a Temporal polyfill before creating the client, or write the field as a convenience type at its default, which needs no Temporal: `DateTime` reads a JavaScript `Date`, and `Date`, `Time` and `Duration` read ISO 8601 strings.\";\nfunction errorTemporalUnavailable(codecId, operation) {\n\treturn mongoTargetError(\"RUNTIME.TEMPORAL_UNAVAILABLE\", `Codec '${codecId}' cannot ${operation} a value because this runtime has no global Temporal implementation.`, {\n\t\twhy: \"Temporal-backed codecs read and write their values through the global Temporal API, which this runtime does not provide.\",\n\t\tfix: TEMPORAL_UNAVAILABLE_FIX,\n\t\tmeta: {\n\t\t\tcodecId,\n\t\t\toperation\n\t\t}\n\t});\n}\nfunction errorTemporalUnavailableForDefault(generatorId) {\n\treturn mongoTargetError(\"RUNTIME.TEMPORAL_UNAVAILABLE\", `Mutation default generator '${generatorId}' cannot produce a value because this runtime has no global Temporal implementation.`, {\n\t\twhy: \"The generator answers a Temporal-backed field, so the value it produces is a Temporal value, which this runtime cannot construct.\",\n\t\tfix: TEMPORAL_UNAVAILABLE_FIX,\n\t\tmeta: { generatorId }\n\t});\n}\nfunction errorTemporalWrongType(codecId, temporalTag, stringType, received) {\n\treturn mongoTargetError(\"RUNTIME.ENCODE_FAILED\", `Codec '${codecId}' encodes a ${temporalTag}, but received ${received}.`, {\n\t\twhy: \"The codec writes the value a Temporal value names. A value of another type names none the field holds.\",\n\t\tfix: `Pass a ${temporalTag}, or author the field with its ${stringType} type to write ISO 8601 text.`,\n\t\tmeta: {\n\t\t\tcodecId,\n\t\t\ttemporalTag,\n\t\t\tstringType,\n\t\t\treceived\n\t\t}\n\t});\n}\nfunction errorTemporalNonIsoCalendar(codecId, calendarId) {\n\treturn mongoTargetError(\"RUNTIME.ENCODE_FAILED\", `Codec '${codecId}' accepts only the iso8601 calendar, but the value carries '${calendarId}'.`, {\n\t\twhy: \"MongoDB stores no calendar alongside a date, so a non-ISO calendar would be discarded on write and the value would read back as a different date than the one authored.\",\n\t\tfix: \"Convert the value with .withCalendar(\\\"iso8601\\\") before writing if the ISO projection is what you mean to store.\",\n\t\tmeta: {\n\t\t\tcodecId,\n\t\t\tcalendarId\n\t\t}\n\t});\n}\n/** A date or time codec read a value from MongoDB that is not a value of its type, or that `Temporal` cannot hold. */\nfunction errorDateTimeUnreadable(options) {\n\tconst { codecId, value, detail } = options;\n\treturn mongoTargetError(\"RUNTIME.DECODE_FAILED\", `Codec '${codecId}' cannot read ${value}: ${detail}`, {\n\t\twhy: \"MongoDB checks no form for a BSON date or string beyond its BSON type, so a document written outside Prisma can hold a value that is not a value of the field’s type.\",\n\t\tfix: \"Rewrite the document in the form the field stores, or read the field with a type that holds what it stores, such as DateTime for a BSON date or String for a BSON string.\",\n\t\tmeta: {\n\t\t\tcodecId,\n\t\t\tvalue: value.slice(0, 100)\n\t\t},\n\t\t...ifDefined(\"cause\", options.cause)\n\t});\n}\n/** A date or time codec was given a value that names no value its type stores, such as text with a digit below a millisecond. */\nfunction errorDateTimeUnwritable(options) {\n\tconst { codecId, received, detail } = options;\n\treturn mongoTargetError(\"RUNTIME.ENCODE_FAILED\", `Codec '${codecId}' cannot write ${received}. ${detail}`, {\n\t\twhy: \"A BSON date holds milliseconds, a calendar date is stored at midnight UTC, and a time of day as a string with three fraction digits. A value that form cannot hold is refused rather than changed.\",\n\t\tfix: \"Write a value the field holds, as the message shows.\",\n\t\tmeta: {\n\t\t\tcodecId,\n\t\t\treceived: received.slice(0, 100)\n\t\t},\n\t\t...ifDefined(\"cause\", options.cause)\n\t});\n}\n//#endregion\n//#region src/core/require-temporal.ts\n/**\n* The `Temporal` to use: the runtime's own when it has one, else the fallback. Throws\n* `RUNTIME.TEMPORAL_UNAVAILABLE` when there is neither.\n*/\nfunction requireTemporal(meta) {\n\tconst temporal = findTemporal();\n\tif (temporal !== void 0) return temporal;\n\tthrow \"generatorId\" in meta ? errorTemporalUnavailableForDefault(meta.generatorId) : errorTemporalUnavailable(meta.codecId, meta.operation);\n}\n//#endregion\n//#region src/core/date-time-values.ts\nconst MILLISECONDS_PER_DAY = 864e5;\nfunction messageOf(cause) {\n\treturn cause instanceof Error ? cause.message : String(cause);\n}\n/** The text a write stores for `value`, in the form `stored` writes; a value `stored` refuses is refused as `RUNTIME.ENCODE_FAILED`. */\nfunction storedTextForWrite(codecId, value, stored) {\n\tif (typeof value !== \"string\") throw errorDateTimeUnwritable({\n\t\tcodecId,\n\t\treceived: describeValue(value),\n\t\tdetail: \"It writes ISO 8601 text.\"\n\t});\n\ttry {\n\t\treturn stored(value);\n\t} catch (cause) {\n\t\tthrow errorDateTimeUnwritable({\n\t\t\tcodecId,\n\t\t\treceived: JSON.stringify(value),\n\t\t\tdetail: messageOf(cause),\n\t\t\tcause\n\t\t});\n\t}\n}\n/** The stored form of a BSON string MongoDB returned, as `stored` reads it; text `stored` refuses is refused as `RUNTIME.DECODE_FAILED`. */\nfunction storedTextFromWire(codecId, wire, stored) {\n\tif (typeof wire !== \"string\") throw errorDateTimeUnreadable({\n\t\tcodecId,\n\t\tvalue: String(wire),\n\t\tdetail: `MongoDB returned ${describeValue(wire)}, not a string.`\n\t});\n\ttry {\n\t\treturn stored(wire);\n\t} catch (cause) {\n\t\tthrow errorDateTimeUnreadable({\n\t\t\tcodecId,\n\t\t\tvalue: JSON.stringify(wire),\n\t\t\tdetail: messageOf(cause),\n\t\t\tcause\n\t\t});\n\t}\n}\n/** The BSON date MongoDB returned, as the `Date` the driver reads it as. */\nfunction dateFromWire(codecId, wire) {\n\tif (isValidDate(wire)) return wire;\n\tthrow errorDateTimeUnreadable({\n\t\tcodecId,\n\t\tvalue: String(wire),\n\t\tdetail: `MongoDB returned ${describeValue(wire)}, not a BSON date.`\n\t});\n}\n/** Whether `date` is at midnight UTC, the form a calendar date is stored in. */\nfunction isAtMidnightUtc(date) {\n\treturn date.getTime() % MILLISECONDS_PER_DAY === 0;\n}\n/** The date part of `date` in UTC, as in `2024-02-29`, for a `Date` at midnight UTC. */\nfunction calendarDateTextOf(date) {\n\tconst iso = date.toISOString();\n\treturn iso.slice(0, iso.indexOf(\"T\"));\n}\n/** The calendar date a BSON date at midnight UTC holds, as in `2024-02-29`. A BSON date at another time is refused, so a field written as an instant is never read as a date. */\nfunction calendarDateFromWire(codecId, wire) {\n\tconst date = dateFromWire(codecId, wire);\n\tif (isAtMidnightUtc(date)) return calendarDateTextOf(date);\n\tthrow errorDateTimeUnreadable({\n\t\tcodecId,\n\t\tvalue: date.toISOString(),\n\t\tdetail: \"a calendar date is stored as a BSON date at midnight UTC. A field that holds a time of day is a DateTime.\"\n\t});\n}\n/** The BSON date at midnight UTC that stores the calendar date `text`, as in `2024-02-29`. */\nfunction midnightUtcOf(text) {\n\treturn /* @__PURE__ */ new Date(`${text}T00:00:00.000Z`);\n}\n/** The Temporal value that stored text names, read with `parse`. */\nfunction temporalFromStoredText(identity, text, parse) {\n\tconst read = temporalFromText(requireTemporal({\n\t\tcodecId: identity.codecId,\n\t\toperation: \"decode\"\n\t}), text, parse);\n\tif (read.kind === \"unreadable\") throw errorDateTimeUnreadable({\n\t\tcodecId: identity.codecId,\n\t\tvalue: JSON.stringify(text),\n\t\tdetail: `${identity.temporalTag} cannot hold it: ${read.detail}. Use ${identity.stringType} to read the field as text.`,\n\t\tcause: read.cause\n\t});\n\treturn read.value;\n}\n/** The text a write stores for a Temporal value, in the form `stored` writes. A value of another kind, in a calendar other than ISO 8601, or with digits below a millisecond is refused. */\nfunction storedTextOfTemporal(identity, value, stored) {\n\tconst encoded = temporalToText(value, identity.temporalTag);\n\tswitch (encoded.kind) {\n\t\tcase \"wrong-type\": throw errorTemporalWrongType(identity.codecId, identity.temporalTag, identity.stringType, encoded.received);\n\t\tcase \"non-iso-calendar\": throw errorTemporalNonIsoCalendar(identity.codecId, encoded.calendarId);\n\t\tcase \"text\":\n\t\t\tif (hasDigitsBelowAMillisecond(encoded.text)) throw errorDateTimeUnwritable({\n\t\t\t\tcodecId: identity.codecId,\n\t\t\t\treceived: `the ${identity.temporalTag} ${encoded.text}`,\n\t\t\t\tdetail: \"It has digits below a millisecond, and the field holds milliseconds. Round it first, as in value.round({ smallestUnit: 'millisecond', roundingMode: 'trunc' }).\"\n\t\t\t});\n\t\t\treturn storedTextForWrite(identity.codecId, encoded.text, stored);\n\t}\n}\n//#endregion\n//#region src/core/date-time-codecs.ts\nconst INSTANT = {\n\tcodecId: MONGO_DATE_INSTANT_CODEC_ID,\n\ttemporalTag: \"Temporal.Instant\",\n\tstringType: \"DateInstantString\"\n};\nconst PLAIN_DATE = {\n\tcodecId: MONGO_DATE_TEMPORAL_CODEC_ID,\n\ttemporalTag: \"Temporal.PlainDate\",\n\tstringType: \"DateString\"\n};\nconst PLAIN_TIME = {\n\tcodecId: MONGO_TIME_TEMPORAL_CODEC_ID,\n\ttemporalTag: \"Temporal.PlainTime\",\n\tstringType: \"TimeString\"\n};\nconst instantText = (value) => storedTextOfTemporal(INSTANT, value, mongoInstantText);\nconst plainDateText = (value) => storedTextOfTemporal(PLAIN_DATE, value, mongoCalendarDateText);\nconst plainTimeText = (value) => storedTextOfTemporal(PLAIN_TIME, value, mongoTimeText);\n/** An instant, stored as a BSON date and read as `Temporal.Instant`. */\nconst mongoDateInstantCodec = mongoCodec({\n\ttypeId: MONGO_DATE_INSTANT_CODEC_ID,\n\tdataType: mongoDate,\n\tfromWire: (wire) => temporalFromStoredText(INSTANT, dateFromWire(MONGO_DATE_INSTANT_CODEC_ID, wire).toISOString(), (temporal, text) => temporal.Instant.from(text)),\n\ttoWire: (value) => new Date(instantText(value)),\n\ttoDataTypeValue: (value) => mongoDate.valueFrom(instantText(value), {}),\n\tfromDataTypeValue: (value) => temporalFromStoredText(INSTANT, value.value, (temporal, text) => temporal.Instant.from(text))\n});\n/** An instant, stored as a BSON date and read as the text `Date.toISOString()` writes, `2024-01-01T00:00:00.000Z`. A write takes ISO 8601 text with any UTC offset. */\nconst mongoDateInstantStringCodec = mongoCodec({\n\ttypeId: MONGO_DATE_INSTANT_STRING_CODEC_ID,\n\tdataType: mongoDate,\n\tfromWire: (wire) => dateFromWire(MONGO_DATE_INSTANT_STRING_CODEC_ID, wire).toISOString(),\n\ttoWire: (value) => new Date(storedTextForWrite(MONGO_DATE_INSTANT_STRING_CODEC_ID, value, mongoInstantText)),\n\ttoDataTypeValue: (value) => mongoDate.valueFrom(storedTextForWrite(MONGO_DATE_INSTANT_STRING_CODEC_ID, value, mongoInstantText), {}),\n\tfromDataTypeValue: (value) => value.value\n});\n/** A calendar date, stored as a BSON date at midnight UTC and read as `2024-02-29`. */\nconst mongoDateStringCodec = mongoCodec({\n\ttypeId: MONGO_DATE_STRING_CODEC_ID,\n\tdataType: mongoCalendarDate,\n\tfromWire: (wire) => calendarDateFromWire(MONGO_DATE_STRING_CODEC_ID, wire),\n\ttoWire: (value) => midnightUtcOf(storedTextForWrite(MONGO_DATE_STRING_CODEC_ID, value, mongoCalendarDateText)),\n\ttoDataTypeValue: (value) => mongoCalendarDate.valueFrom(storedTextForWrite(MONGO_DATE_STRING_CODEC_ID, value, mongoCalendarDateText), {}),\n\tfromDataTypeValue: (value) => value.value\n});\n/** A calendar date, stored as a BSON date at midnight UTC and read as `Temporal.PlainDate`. */\nconst mongoDateTemporalCodec = mongoCodec({\n\ttypeId: MONGO_DATE_TEMPORAL_CODEC_ID,\n\tdataType: mongoCalendarDate,\n\tfromWire: (wire) => temporalFromStoredText(PLAIN_DATE, calendarDateFromWire(MONGO_DATE_TEMPORAL_CODEC_ID, wire), (temporal, text) => temporal.PlainDate.from(text)),\n\ttoWire: (value) => midnightUtcOf(plainDateText(value)),\n\ttoDataTypeValue: (value) => mongoCalendarDate.valueFrom(plainDateText(value), {}),\n\tfromDataTypeValue: (value) => temporalFromStoredText(PLAIN_DATE, value.value, (temporal, text) => temporal.PlainDate.from(text))\n});\n/** A time of day, stored as a BSON string and read as that string, `09:30:00.000`. A write pads a string with fewer fraction digits to three. */\nconst mongoTimeStringCodec = mongoCodec({\n\ttypeId: MONGO_TIME_STRING_CODEC_ID,\n\tdataType: mongoTime,\n\tfromWire: (wire) => storedTextFromWire(MONGO_TIME_STRING_CODEC_ID, wire, mongoTimeText),\n\ttoWire: (value) => storedTextForWrite(MONGO_TIME_STRING_CODEC_ID, value, mongoTimeText),\n\ttoDataTypeValue: (value) => mongoTime.valueFrom(storedTextForWrite(MONGO_TIME_STRING_CODEC_ID, value, mongoTimeText), {}),\n\tfromDataTypeValue: (value) => value.value\n});\n/** A time of day, stored as a BSON string, `09:30:00.000`, and read as `Temporal.PlainTime`. */\nconst mongoTimeTemporalCodec = mongoCodec({\n\ttypeId: MONGO_TIME_TEMPORAL_CODEC_ID,\n\tdataType: mongoTime,\n\tfromWire: (wire) => temporalFromStoredText(PLAIN_TIME, storedTextFromWire(MONGO_TIME_TEMPORAL_CODEC_ID, wire, mongoTimeText), (temporal, text) => temporal.PlainTime.from(text)),\n\ttoWire: (value) => plainTimeText(value),\n\ttoDataTypeValue: (value) => mongoTime.valueFrom(plainTimeText(value), {}),\n\tfromDataTypeValue: (value) => temporalFromStoredText(PLAIN_TIME, value.value, (temporal, text) => temporal.PlainTime.from(text))\n});\n/** A length of time, stored as a BSON string and read as the ISO 8601 duration it was written as, `PT1H30M`. */\nconst mongoDurationStringCodec = mongoCodec({\n\ttypeId: MONGO_DURATION_STRING_CODEC_ID,\n\tdataType: mongoDuration,\n\tfromWire: (wire) => storedTextFromWire(MONGO_DURATION_STRING_CODEC_ID, wire, mongoDurationText),\n\ttoWire: (value) => storedTextForWrite(MONGO_DURATION_STRING_CODEC_ID, value, mongoDurationText),\n\tfromDataTypeValue: (value) => value.value\n});\n//#endregion\n//#region src/core/json-codec-helpers.ts\nconst BSON_TYPE_BY_TAG = {\n\tObjectId: \"objectId\",\n\tDecimal128: \"decimal\",\n\tBinary: \"binData\",\n\tBSONRegExp: \"regex\",\n\tTimestamp: \"timestamp\",\n\tBSONSymbol: \"symbol\",\n\tCode: \"javascript\",\n\tMinKey: \"minKey\",\n\tMaxKey: \"maxKey\"\n};\nconst NOT_FINITE_FIX = \"JSON has no NaN or Infinity; store null or a string, or declare the field Bson.\";\nconst BSON_FIX = \"Declare the field Bson to store BSON values.\";\nconst PLAIN_VALUE_FIX = \"Convert it to a plain object or array.\";\nconst ENCODE_FIX_BY_RECEIVED = {\n\tDate: \"Store the date as an ISO 8601 string, or declare the field Bson.\",\n\tbigint: \"Store it as a number in the safe-integer range or as decimal text, or declare the field BigInt or Bson.\",\n\tNaN: NOT_FINITE_FIX,\n\tInfinity: NOT_FINITE_FIX,\n\t\"-Infinity\": NOT_FINITE_FIX,\n\tundefined: \"Leave the key out, or store null.\",\n\tUint8Array: \"Store the bytes as a base64 string, or declare the field Bytes or Bson.\",\n\tBuffer: \"Store the bytes as a base64 string, or declare the field Bytes or Bson.\",\n\tBinary: \"Store the bytes as a base64 string, or declare the field Bytes or Bson.\",\n\tObjectId: \"Store its hex string, or declare the field ObjectId or Bson.\",\n\tLong: \"Store a number in the safe-integer range or decimal text, or declare the field BigInt or Bson.\",\n\tDecimal128: \"Store the decimal text, or declare the field Decimal or Bson.\",\n\tInt32: \"Pass a plain number.\",\n\tDouble: \"Pass a plain number.\",\n\tRegExp: \"Store the pattern as a string, or declare the field Bson.\",\n\tBSONRegExp: \"Store the pattern as a string, or declare the field Bson.\",\n\tsymbol: \"Store a string instead.\",\n\tfunction: \"Store data, not a function.\",\n\t\"circular reference\": \"Remove the cycle; a JSON value is a tree.\",\n\t\"sparse array hole\": \"Fill the hole with null.\",\n\tDBRef: \"Write it as a { $ref, $id } document instead.\"\n};\nfunction encodeFix(received) {\n\treturn ENCODE_FIX_BY_RECEIVED[received] ?? (Object.hasOwn(BSON_TYPE_BY_TAG, received) ? BSON_FIX : PLAIN_VALUE_FIX);\n}\nfunction encodeRefused(received, path) {\n\tthrow mongoTargetError(\"RUNTIME.ENCODE_FAILED\", `${MONGO_JSON_CODEC_ID} value must be a JSON value; received ${received} at ${where(path)}. ${encodeFix(received)}`, { meta: {\n\t\tcodecId: MONGO_JSON_CODEC_ID,\n\t\treceived,\n\t\tvaluePath: path\n\t} });\n}\n/**\n* Returns `value` unchanged when it is a plain JSON value at every depth, and throws `RUNTIME.ENCODE_FAILED` naming the first value that is not, with its path.\n*/\nfunction encodeJsonValue(value) {\n\tconst found = findNonJsonValue(value, { tagOf: bsonTypeTag });\n\tif (found !== void 0) encodeRefused(found.received, found.path);\n\treturn value;\n}\nfunction decodeRefused(bsonType, path) {\n\tthrow mongoTargetError(\"RUNTIME.DECODE_FAILED\", `${MONGO_JSON_CODEC_ID} wire value contains a non-JSON BSON ${bsonType} at ${where(path)}`, { meta: {\n\t\tcodecId: MONGO_JSON_CODEC_ID,\n\t\treceived: bsonType,\n\t\tvaluePath: path\n\t} });\n}\nfunction safeLong(value, path) {\n\tconst number = Number(value);\n\treturn Number.isSafeInteger(number) && BigInt(number) === value ? number : decodeRefused(\"long\", path);\n}\nfunction finiteDouble(value, path) {\n\tif (Number.isFinite(value)) return value;\n\tconst received = String(value);\n\tthrow mongoTargetError(\"RUNTIME.DECODE_FAILED\", `${MONGO_JSON_CODEC_ID} wire value contains ${received} at ${where(path)}; a JSON number cannot be NaN or Infinity`, { meta: {\n\t\tcodecId: MONGO_JSON_CODEC_ID,\n\t\treceived,\n\t\tvaluePath: path\n\t} });\n}\nfunction decodeEntries(entries, path) {\n\treturn Object.fromEntries(entries.map(([key, entry]) => [key, decodeValue(entry, child(path, key))]));\n}\nfunction decodeTagged(value, tag, path) {\n\tswitch (tag) {\n\t\tcase \"DBRef\": return decodeEntries(dbRefEntries(value), path);\n\t\tcase \"Long\": return safeLong(blindCast(value).toBigInt(), path);\n\t\tcase \"Int32\":\n\t\tcase \"Double\": return finiteDouble(Number(value.valueOf()), path);\n\t}\n\treturn decodeRefused(BSON_TYPE_BY_TAG[tag] ?? tag, path);\n}\nfunction decodeValue(value, path) {\n\tif (value === null || typeof value === \"string\" || typeof value === \"boolean\") return value;\n\tif (typeof value === \"number\") return finiteDouble(value, path);\n\tif (typeof value === \"bigint\") return safeLong(value, path);\n\tif (typeof value === \"undefined\") return decodeRefused(\"undefined\", path);\n\tif (typeof value === \"symbol\") return decodeRefused(\"symbol\", path);\n\tif (typeof value === \"function\") return decodeRefused(\"javascript\", path);\n\tconst tag = bsonClassTag(value);\n\tif (tag !== void 0) return decodeTagged(value, tag, path);\n\tif (value instanceof Date) return decodeRefused(\"date\", path);\n\tif (value instanceof RegExp) return decodeRefused(\"regex\", path);\n\tif (value instanceof Uint8Array) return decodeRefused(\"binData\", path);\n\tif (Array.isArray(value)) {\n\t\tconst decoded = value.map((entry, index) => decodeValue(entry, child(path, index)));\n\t\treturn decoded.some((entry, index) => entry !== value[index]) ? decoded : value;\n\t}\n\tif (!isPlainObject(value)) return decodeRefused(constructorName(value), path);\n\tconst entries = Object.entries(value);\n\tconst decoded = decodeEntries(entries, path);\n\treturn entries.some(([key, entry]) => decoded[key] !== entry) ? decoded : blindCast(value);\n}\n/**\n* Decodes a wire value to the JSON value it holds: a `long` in the safe-integer range and the driver's `Int32` and `Double` wrappers become numbers. Only the objects and arrays around a converted value are copied; a wire value that is already JSON is returned as the same object. Throws `RUNTIME.DECODE_FAILED` naming the BSON type and path of the first value that is not JSON.\n*/\nfunction decodeJsonValue(wire) {\n\treturn decodeValue(wire, \"\");\n}\n//#endregion\n//#region src/core/codecs.ts\nconst mongoObjectIdCodec = mongoCodec({\n\ttypeId: MONGO_OBJECTID_CODEC_ID,\n\tdataType: mongoObjectId,\n\tfromWire: (wire) => wire.toHexString(),\n\ttoWire: (value) => objectIdEncode(MONGO_OBJECTID_CODEC_ID, value),\n\ttoDataTypeValue: (value) => mongoObjectId.valueFrom(objectIdToJson(MONGO_OBJECTID_CODEC_ID, value), {}),\n\tfromDataTypeValue: (value) => value.value\n});\nconst mongoStringCodec = mongoCodec({\n\ttypeId: MONGO_STRING_CODEC_ID,\n\tdataType: mongoString,\n\tfromWire: (wire) => wire,\n\ttoWire: (value) => stringEncode(MONGO_STRING_CODEC_ID, value),\n\tfromDataTypeValue: (value) => value.value\n});\nconst mongoDoubleCodec = mongoCodec({\n\ttypeId: MONGO_DOUBLE_CODEC_ID,\n\tdataType: mongoDouble,\n\tfromWire: (wire) => Number(wire),\n\ttoWire: (value) => doubleEncode(MONGO_DOUBLE_CODEC_ID, value),\n\ttoDataTypeValue: (value) => mongoDouble.valueFrom(floatToJson(value), {}),\n\tfromDataTypeValue: (value) => readJsonFloat(MONGO_DOUBLE_CODEC_ID, value.value)\n});\nconst mongoInt32Codec = mongoCodec({\n\ttypeId: MONGO_INT32_CODEC_ID,\n\tdataType: mongoInt32,\n\tfromWire: (wire) => wire,\n\ttoWire: (value) => int32Encode(MONGO_INT32_CODEC_ID, value),\n\ttoDataTypeValue: (value) => mongoInt32.valueFrom(int32ToJson(MONGO_INT32_CODEC_ID, value), {}),\n\tfromDataTypeValue: (value) => value.value\n});\nconst mongoBooleanCodec = mongoCodec({\n\ttypeId: MONGO_BOOLEAN_CODEC_ID,\n\tdataType: mongoBool,\n\tfromWire: (wire) => wire,\n\ttoWire: (value) => booleanEncode(MONGO_BOOLEAN_CODEC_ID, value),\n\tfromDataTypeValue: (value) => value.value\n});\nconst mongoDateCodec = mongoCodec({\n\ttypeId: MONGO_DATE_CODEC_ID,\n\tdataType: mongoDate,\n\tfromWire: (wire) => wire,\n\ttoWire: (value) => dateEncode(MONGO_DATE_CODEC_ID, value),\n\ttoDataTypeValue: (value) => mongoDate.valueFrom(dateToJson(MONGO_DATE_CODEC_ID, value), {}),\n\tfromDataTypeValue: (value) => new Date(value.value)\n});\n/** The vector codec for a column of `mongo/vector` with `params`. The dimension reaches only the TypeScript type `Vector<n>`. */\nfunction vectorCodec(params) {\n\treturn mongoCodec({\n\t\ttypeId: MONGO_VECTOR_CODEC_ID,\n\t\tdataType: mongoVector,\n\t\t...ifDefined(\"params\", params),\n\t\tfromWire: (wire) => wire,\n\t\ttoWire: (value) => vectorEncode(MONGO_VECTOR_CODEC_ID, value),\n\t\tfromDataTypeValue: (value) => value.value\n\t});\n}\nconst mongoVectorCodec = vectorCodec();\n/**\n* A BSON `long`. The application value is a `bigint`, because a `number` cannot hold the full 64-bit range; its stored form is decimal text.\n*/\nconst mongoInt64Codec = mongoCodec({\n\ttypeId: MONGO_INT64_CODEC_ID,\n\tdataType: mongoInt64,\n\tfromWire: (wire) => int64Decode(MONGO_INT64_CODEC_ID, wire),\n\ttoWire: (value) => int64Encode(MONGO_INT64_CODEC_ID, value),\n\ttoDataTypeValue: (value) => mongoInt64.valueFrom(int64ToJson(MONGO_INT64_CODEC_ID, value), {}),\n\tfromDataTypeValue: (value) => BigInt(value.value)\n});\n/**\n* A BSON `long` read and written as a `number` from -(2^53 - 1) to 2^53 - 1, the value a Prisma 6 `Int` presents. A value outside that range, or with a fraction, is refused rather than rounded.\n*/\nconst mongoInt64NumberCodec = mongoCodec({\n\ttypeId: MONGO_INT64_NUMBER_CODEC_ID,\n\tdataType: mongoInt64,\n\tfromWire: (wire) => int64NumberDecode(MONGO_INT64_NUMBER_CODEC_ID, wire),\n\ttoWire: (value) => int64NumberEncode(MONGO_INT64_NUMBER_CODEC_ID, value),\n\ttoDataTypeValue: (value) => mongoInt64.valueFrom(int64NumberToJson(MONGO_INT64_NUMBER_CODEC_ID, value), {}),\n\tfromDataTypeValue: (value) => int64NumberFromDigits(MONGO_INT64_NUMBER_CODEC_ID, value.value)\n});\n/**\n* A BSON `decimal`. The application value and its stored form are the same decimal text, written without an exponent.\n*/\nconst mongoDecimal128Codec = mongoCodec({\n\ttypeId: MONGO_DECIMAL128_CODEC_ID,\n\tdataType: mongoDecimal128,\n\tfromWire: (wire) => decimal128Decode(MONGO_DECIMAL128_CODEC_ID, wire),\n\ttoWire: (value) => decimal128Encode(MONGO_DECIMAL128_CODEC_ID, value),\n\ttoDataTypeValue: (value) => mongoDecimal128.valueFrom(decimal128ToJson(MONGO_DECIMAL128_CODEC_ID, value), {}),\n\tfromDataTypeValue: (value) => value.value\n});\n/**\n* BSON `binData`. The application value is a `Uint8Array`; its stored form is unwrapped base64.\n*/\nconst mongoBinaryCodec = mongoCodec({\n\ttypeId: MONGO_BINARY_CODEC_ID,\n\tdataType: mongoBinary,\n\tfromWire: (wire) => binaryDecode(MONGO_BINARY_CODEC_ID, wire),\n\ttoWire: (value) => binaryEncode(MONGO_BINARY_CODEC_ID, value),\n\ttoDataTypeValue: (value) => mongoBinary.valueFrom(binaryToBase64(value), {}),\n\tfromDataTypeValue: (value) => binaryFromBase64(value.value)\n});\n/**\n* A JSON value, stored as the BSON object, array, string, number, boolean or null it maps to. Encode and decode refuse any other value at any depth, naming its path.\n*/\nconst mongoJsonCodec = mongoCodec({\n\ttypeId: MONGO_JSON_CODEC_ID,\n\tdataType: mongoJson,\n\tfromWire: (wire) => decodeJsonValue(wire),\n\ttoWire: (value) => encodeJsonValue(value)\n});\n/**\n* Any BSON value, passed through unchanged except that decode turns a `DBRef` back into the `{ $ref, $id }` document it was stored as. Encode takes a `BsonInputValue` and decode returns a `BsonValue`. Its stored form is canonical MongoDB Extended JSON v2, written with each number and `Uint8Array` as the BSON type the driver stores, so a round trip keeps the BSON bytes but may return wrapper classes such as `Int32` and `Double`.\n*/\nconst mongoBsonCodec = mongoCodec({\n\ttypeId: MONGO_BSON_CODEC_ID,\n\tdataType: mongoBson,\n\tfromWire: (wire) => decodeBsonValue(wire),\n\ttoWire: (value) => encodeBsonValue(value),\n\ttoDataTypeValue: (value) => mongoBson.valueFrom(bsonToJson(value), {}),\n\tfromDataTypeValue: (value) => readBsonJson(MONGO_BSON_CODEC_ID, value.value)\n});\n/**\n* Mongo wire-type codec descriptors. Static metadata such as `traits` lives here (the descriptor shape) — `MongoCodec` itself carries its data type and the four conversion methods (TML-2357).\n*/\nconst mongoCodecDescriptors = [\n\tmongoCodecDescriptor(mongoObjectIdCodec, { traits: [\"equality\"] }),\n\tmongoCodecDescriptor(mongoStringCodec, {\n\t\ttraits: [\n\t\t\t\"equality\",\n\t\t\t\"order\",\n\t\t\t\"textual\"\n\t\t],\n\t\trenderValueLiteral: renderTsLiteral\n\t}),\n\tmongoCodecDescriptor(mongoDoubleCodec, {\n\t\ttraits: [\n\t\t\t\"equality\",\n\t\t\t\"order\",\n\t\t\t\"numeric\"\n\t\t],\n\t\trenderValueLiteral: floatNumberLiteral\n\t}),\n\tmongoCodecDescriptor(mongoInt32Codec, {\n\t\ttraits: [\n\t\t\t\"equality\",\n\t\t\t\"order\",\n\t\t\t\"numeric\"\n\t\t],\n\t\trenderValueLiteral: renderTsLiteral\n\t}),\n\tmongoCodecDescriptor(mongoBooleanCodec, {\n\t\ttraits: [\"equality\", \"boolean\"],\n\t\trenderValueLiteral: renderTsLiteral\n\t}),\n\tmongoCodecDescriptor(mongoDateCodec, { traits: [\"equality\", \"order\"] }),\n\tmongoCodecDescriptor(mongoVectorCodec, {\n\t\ttraits: [\"equality\"],\n\t\twithParams: vectorCodec\n\t}),\n\tmongoCodecDescriptor(mongoInt64Codec, {\n\t\ttraits: [\n\t\t\t\"equality\",\n\t\t\t\"order\",\n\t\t\t\"numeric\"\n\t\t],\n\t\trenderValueLiteral: decimalTextBigintLiteral\n\t}),\n\tmongoCodecDescriptor(mongoInt64NumberCodec, {\n\t\ttraits: [\n\t\t\t\"equality\",\n\t\t\t\"order\",\n\t\t\t\"numeric\"\n\t\t],\n\t\trenderValueLiteral: decimalTextNumberLiteral\n\t}),\n\tmongoCodecDescriptor(mongoDecimal128Codec, {\n\t\ttraits: [\n\t\t\t\"equality\",\n\t\t\t\"order\",\n\t\t\t\"numeric\"\n\t\t],\n\t\tkeepsWrittenForm: true\n\t}),\n\tmongoCodecDescriptor(mongoBinaryCodec, { traits: [\"equality\"] }),\n\tmongoCodecDescriptor(mongoJsonCodec, { traits: [] }),\n\tmongoCodecDescriptor(mongoBsonCodec, { traits: [] }),\n\tmongoCodecDescriptor(mongoDateInstantCodec, { traits: [\"equality\", \"order\"] }),\n\tmongoCodecDescriptor(mongoDateInstantStringCodec, {\n\t\ttraits: [\"equality\", \"order\"],\n\t\trenderValueLiteral: renderTsLiteral\n\t}),\n\tmongoCodecDescriptor(mongoDateStringCodec, {\n\t\ttraits: [\"equality\", \"order\"],\n\t\trenderValueLiteral: renderTsLiteral\n\t}),\n\tmongoCodecDescriptor(mongoDateTemporalCodec, { traits: [\"equality\", \"order\"] }),\n\tmongoCodecDescriptor(mongoTimeStringCodec, {\n\t\ttraits: [\"equality\", \"order\"],\n\t\trenderValueLiteral: renderTsLiteral\n\t}),\n\tmongoCodecDescriptor(mongoTimeTemporalCodec, { traits: [\"equality\", \"order\"] }),\n\tmongoCodecDescriptor(mongoDurationStringCodec, {\n\t\ttraits: [\"equality\"],\n\t\trenderValueLiteral: renderTsLiteral\n\t})\n];\n/**\n* Lookup descriptor metadata by codec id — used by tests and for descriptor-side reads of static metadata.\n*/\nfunction mongoDescriptorById(codecId) {\n\treturn mongoCodecDescriptors.find((d) => d.codecId === codecId);\n}\n//#endregion\nexport { mongoDescriptorById as n, requireTemporal as r, mongoCodecDescriptors as t };\n\n//# sourceMappingURL=codecs-DKwnfU85.mjs.map"],"mappings":";;;;;;;;;;;;AAYA,MAAM,2BAA2B;AACjC,SAAS,yBAAyB,SAAS,WAAW;CACrD,OAAO,iBAAiB,gCAAgC,UAAU,QAAQ,WAAW,UAAU,uEAAuE;EACrK,KAAK;EACL,KAAK;EACL,MAAM;GACL;GACA;EACD;CACD,CAAC;AACF;AACA,SAAS,mCAAmC,aAAa;CACxD,OAAO,iBAAiB,gCAAgC,+BAA+B,YAAY,uFAAuF;EACzL,KAAK;EACL,KAAK;EACL,MAAM,EAAE,YAAY;CACrB,CAAC;AACF;AACA,SAAS,uBAAuB,SAAS,aAAa,YAAY,UAAU;CAC3E,OAAO,iBAAiB,yBAAyB,UAAU,QAAQ,cAAc,YAAY,iBAAiB,SAAS,IAAI;EAC1H,KAAK;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;GACA;EACD;EACA,kBAAkB;CACnB,CAAC;CACD,qBAAqB,kBAAkB,EAAE,QAAQ,CAAC,UAAU,EAAE,CAAC;CAC/D,qBAAqB,gBAAgB,EAAE,QAAQ,CAAC,EAAE,CAAC;CACnD,qBAAqB,gBAAgB,EAAE,QAAQ,CAAC,EAAE,CAAC;CACnD,qBAAqB,uBAAuB,EAAE,QAAQ,CAAC,YAAY,OAAO,EAAE,CAAC;CAC7E,qBAAqB,6BAA6B;EACjD,QAAQ,CAAC,YAAY,OAAO;EAC5B,oBAAoB;CACrB,CAAC;CACD,qBAAqB,sBAAsB;EAC1C,QAAQ,CAAC,YAAY,OAAO;EAC5B,oBAAoB;CACrB,CAAC;CACD,qBAAqB,wBAAwB,EAAE,QAAQ,CAAC,YAAY,OAAO,EAAE,CAAC;CAC9E,qBAAqB,sBAAsB;EAC1C,QAAQ,CAAC,YAAY,OAAO;EAC5B,oBAAoB;CACrB,CAAC;CACD,qBAAqB,wBAAwB,EAAE,QAAQ,CAAC,YAAY,OAAO,EAAE,CAAC;CAC9E,qBAAqB,0BAA0B;EAC9C,QAAQ,CAAC,UAAU;EACnB,oBAAoB;CACrB,CAAC;AACF;;;;AAIA,SAAS,oBAAoB,SAAS;CACrC,OAAO,sBAAsB,MAAM,MAAM,EAAE,YAAY,OAAO;AAC/D"}
@@ -1,4 +1,4 @@
1
- import { n as MongoDriverImpl, r as mongoDriverDescriptorMeta, t as DRIVER_INFO } from "./mongo-driver-Cp7ApMWY-uuvB0cAv.mjs";
1
+ import { n as MongoDriverImpl, r as mongoDriverDescriptorMeta, t as DRIVER_INFO } from "./mongo-driver-C9yvIHgo-BYNinbNE.mjs";
2
2
  import { errorRuntime } from "@prisma/orm-framework/errors/execution";
3
3
  import { MongoClient } from "mongodb";
4
4
  import { redactDatabaseUrl } from "@prisma/orm-framework/utils/redact-db-url";
@@ -42,4 +42,4 @@ const mongoControlDriverDescriptor = {
42
42
  //#endregion
43
43
  export { mongoControlDriverDescriptor as n, MongoControlDriver as t };
44
44
 
45
- //# sourceMappingURL=control-aaXa_r6J.mjs.map
45
+ //# sourceMappingURL=control-Be0fS-hV.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"control-aaXa_r6J.mjs","names":[],"sources":["../../../../3-targets/mongo/3-driver/dist/control.mjs"],"sourcesContent":["import { n as mongoDriverDescriptorMeta, r as DRIVER_INFO, t as MongoDriverImpl } from \"./mongo-driver-Cp7ApMWY.mjs\";\nimport { errorRuntime } from \"@internal/errors/execution\";\nimport { redactDatabaseUrl } from \"@internal/utils/redact-db-url\";\nimport { MongoClient } from \"mongodb\";\n//#region src/exports/control.ts\nvar MongoControlDriver = class extends MongoDriverImpl {\n\tfamilyId = \"mongo\";\n\ttargetId = \"mongo\";\n\tdb;\n\tconstructor(db, mongoClient) {\n\t\tsuper(db, mongoClient);\n\t\tthis.db = db;\n\t}\n\tasync databaseName() {\n\t\treturn this.db.databaseName;\n\t}\n};\nconst mongoControlDriverDescriptor = {\n\t...mongoDriverDescriptorMeta,\n\tasync create(url) {\n\t\tconst client = new MongoClient(url, {\n\t\t\tserverSelectionTimeoutMS: 5e3,\n\t\t\tconnectTimeoutMS: 5e3,\n\t\t\tdriverInfo: DRIVER_INFO\n\t\t});\n\t\ttry {\n\t\t\tawait client.connect();\n\t\t\treturn new MongoControlDriver(client.db(), client);\n\t\t} catch (error) {\n\t\t\ttry {\n\t\t\t\tawait client.close();\n\t\t\t} catch {}\n\t\t\tthrow errorRuntime(\"DRIVER.CONNECTION_FAILED\", \"Database connection failed\", {\n\t\t\t\twhy: error instanceof Error ? error.message : String(error),\n\t\t\t\tfix: \"Verify the MongoDB URL, ensure the database is reachable, and confirm credentials/permissions\",\n\t\t\t\tmeta: { ...redactDatabaseUrl(url) },\n\t\t\t\tcause: error\n\t\t\t});\n\t\t}\n\t}\n};\n//#endregion\nexport { MongoControlDriver, mongoControlDriverDescriptor as default };\n\n//# sourceMappingURL=control.mjs.map"],"mappings":";;;;;AAKA,IAAI,qBAAqB,cAAc,gBAAgB;CACtD,WAAW;CACX,WAAW;CACX;CACA,YAAY,IAAI,aAAa;EAC5B,MAAM,IAAI,WAAW;EACrB,KAAK,KAAK;CACX;CACA,MAAM,eAAe;EACpB,OAAO,KAAK,GAAG;CAChB;AACD;AACA,MAAM,+BAA+B;CACpC,GAAG;CACH,MAAM,OAAO,KAAK;EACjB,MAAM,SAAS,IAAI,YAAY,KAAK;GACnC,0BAA0B;GAC1B,kBAAkB;GAClB,YAAY;EACb,CAAC;EACD,IAAI;GACH,MAAM,OAAO,QAAQ;GACrB,OAAO,IAAI,mBAAmB,OAAO,GAAG,GAAG,MAAM;EAClD,SAAS,OAAO;GACf,IAAI;IACH,MAAM,OAAO,MAAM;GACpB,QAAQ,CAAC;GACT,MAAM,aAAa,4BAA4B,8BAA8B;IAC5E,KAAK,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;IAC1D,KAAK;IACL,MAAM,EAAE,GAAG,kBAAkB,GAAG,EAAE;IAClC,OAAO;GACR,CAAC;EACF;CACD;AACD"}
1
+ {"version":3,"file":"control-Be0fS-hV.mjs","names":[],"sources":["../../../../3-targets/mongo/3-driver/dist/control.mjs"],"sourcesContent":["import { n as mongoDriverDescriptorMeta, r as DRIVER_INFO, t as MongoDriverImpl } from \"./mongo-driver-C9yvIHgo.mjs\";\nimport { errorRuntime } from \"@internal/errors/execution\";\nimport { redactDatabaseUrl } from \"@internal/utils/redact-db-url\";\nimport { MongoClient } from \"mongodb\";\n//#region src/exports/control.ts\nvar MongoControlDriver = class extends MongoDriverImpl {\n\tfamilyId = \"mongo\";\n\ttargetId = \"mongo\";\n\tdb;\n\tconstructor(db, mongoClient) {\n\t\tsuper(db, mongoClient);\n\t\tthis.db = db;\n\t}\n\tasync databaseName() {\n\t\treturn this.db.databaseName;\n\t}\n};\nconst mongoControlDriverDescriptor = {\n\t...mongoDriverDescriptorMeta,\n\tasync create(url) {\n\t\tconst client = new MongoClient(url, {\n\t\t\tserverSelectionTimeoutMS: 5e3,\n\t\t\tconnectTimeoutMS: 5e3,\n\t\t\tdriverInfo: DRIVER_INFO\n\t\t});\n\t\ttry {\n\t\t\tawait client.connect();\n\t\t\treturn new MongoControlDriver(client.db(), client);\n\t\t} catch (error) {\n\t\t\ttry {\n\t\t\t\tawait client.close();\n\t\t\t} catch {}\n\t\t\tthrow errorRuntime(\"DRIVER.CONNECTION_FAILED\", \"Database connection failed\", {\n\t\t\t\twhy: error instanceof Error ? error.message : String(error),\n\t\t\t\tfix: \"Verify the MongoDB URL, ensure the database is reachable, and confirm credentials/permissions\",\n\t\t\t\tmeta: { ...redactDatabaseUrl(url) },\n\t\t\t\tcause: error\n\t\t\t});\n\t\t}\n\t}\n};\n//#endregion\nexport { MongoControlDriver, mongoControlDriverDescriptor as default };\n\n//# sourceMappingURL=control.mjs.map"],"mappings":";;;;;AAKA,IAAI,qBAAqB,cAAc,gBAAgB;CACtD,WAAW;CACX,WAAW;CACX;CACA,YAAY,IAAI,aAAa;EAC5B,MAAM,IAAI,WAAW;EACrB,KAAK,KAAK;CACX;CACA,MAAM,eAAe;EACpB,OAAO,KAAK,GAAG;CAChB;AACD;AACA,MAAM,+BAA+B;CACpC,GAAG;CACH,MAAM,OAAO,KAAK;EACjB,MAAM,SAAS,IAAI,YAAY,KAAK;GACnC,0BAA0B;GAC1B,kBAAkB;GAClB,YAAY;EACb,CAAC;EACD,IAAI;GACH,MAAM,OAAO,QAAQ;GACrB,OAAO,IAAI,mBAAmB,OAAO,GAAG,GAAG,MAAM;EAClD,SAAS,OAAO;GACf,IAAI;IACH,MAAM,OAAO,MAAM;GACpB,QAAQ,CAAC;GACT,MAAM,aAAa,4BAA4B,8BAA8B;IAC5E,KAAK,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;IAC1D,KAAK;IACL,MAAM,EAAE,GAAG,kBAAkB,GAAG,EAAE;IAClC,OAAO;GACR,CAAC;EACF;CACD;AACD"}
@@ -1,5 +1,5 @@
1
1
  import { t as mongoTargetError } from "./mongo-target-errors-Btf3ML1w-QOtEG7EX.mjs";
2
- import { t as mongoTargetDescriptorMeta } from "./descriptor-meta-BWjqdX8D-BAnaqzWL.mjs";
2
+ import { t as mongoTargetDescriptorMeta } from "./descriptor-meta-BRjal4JG-G-1rNvuk.mjs";
3
3
  import { A as unrewritableKeyReason, C as renameCollection, E as replaceStoredValue, O as storedKeyPath, S as removeStoredValue, T as renameStoredKey, _ as keysOf, a as createIndex, c as documentsMissingOrNull, d as dropCollection, f as dropIndex, g as jsonPathText, h as isConvertTarget, i as createCollection, j as unsetField, k as unrewritableFieldNameReason, l as documentsNotOfType, m as fillStoredKey, n as castsFrom, p as fillField, r as collMod, s as deleteDocuments, t as castField, u as documentsWithObject, v as lacksKey, w as renameField, x as removeStoredKey } from "./migration-factories-RJZq8NhE-CigCh286.mjs";
4
4
  import { assembleDataTypes } from "@prisma/orm-framework/components/codec";
5
5
  import { bsonTypesOfCodec, temporaryValueOfCodec } from "@prisma/orm-family-mongo/contract/data-type";
@@ -24,7 +24,6 @@ import { CliStructuredError } from "@prisma/orm-framework/errors/control";
24
24
  import { errorUnfilledPlaceholder } from "@prisma/orm-framework/errors/migration";
25
25
  import { TsExpression, jsonToTsSource, renderImports, tsObjectSource, tsStringLiteral } from "@prisma/orm-framework/ts-render";
26
26
  import { Migration } from "@prisma/orm-toolchain/migration-tools/migration";
27
- import { resolveRequirementSpecifiers } from "@prisma/orm-framework/components/emission";
28
27
  import { detectScaffoldRuntime, shebangLineFor } from "@prisma/orm-toolchain/migration-tools/migration-ts";
29
28
  import { errorMarkerPoliciesCorrupt } from "@prisma/orm-framework/errors/execution";
30
29
  import { verifyMongoSchema } from "@prisma/orm-family-mongo/family/schema-verify";
@@ -718,18 +717,11 @@ var UnfilledValue = class {
718
717
  Object.freeze(this);
719
718
  }
720
719
  };
721
- /**
722
- * The single module a scaffolded Mongo `migration.ts` imports from: the
723
- * operation factories below, plus the `Migration` base and `MigrationCLI`
724
- * that `render-typescript.ts` adds. The authored name; `render-typescript.ts`
725
- * maps it to whatever the consuming application's import root calls it,
726
- * once over the whole assembled import list.
727
- */
728
- const TARGET_MIGRATION_MODULE = "@internal/target-mongo/migration";
720
+ const MIGRATION_MODULE = "<migrations.module>";
729
721
  var OpFactoryCallNode = class extends TsExpression {
730
722
  importRequirements() {
731
723
  return [{
732
- moduleSpecifier: TARGET_MIGRATION_MODULE,
724
+ moduleSpecifier: MIGRATION_MODULE,
733
725
  symbol: this.factoryName
734
726
  }];
735
727
  }
@@ -985,7 +977,7 @@ var DataTransformCall = class extends OpFactoryCallNode {
985
977
  "rawUpdateMany",
986
978
  "placeholder"
987
979
  ].map((symbol) => ({
988
- moduleSpecifier: TARGET_MIGRATION_MODULE,
980
+ moduleSpecifier: MIGRATION_MODULE,
989
981
  symbol
990
982
  }));
991
983
  }
@@ -1082,7 +1074,7 @@ var FillStoredKeyCall = class extends OpFactoryCallNode {
1082
1074
  }
1083
1075
  importRequirements() {
1084
1076
  return [...super.importRequirements(), ...this.options.value instanceof UnfilledValue ? [{
1085
- moduleSpecifier: TARGET_MIGRATION_MODULE,
1077
+ moduleSpecifier: MIGRATION_MODULE,
1086
1078
  symbol: "placeholder"
1087
1079
  }] : []];
1088
1080
  }
@@ -1142,7 +1134,7 @@ var RemoveStoredValueCall = class extends OpFactoryCallNode {
1142
1134
  }
1143
1135
  importRequirements() {
1144
1136
  return [...super.importRequirements(), ...this.imports.importsReplacement ? [{
1145
- moduleSpecifier: TARGET_MIGRATION_MODULE,
1137
+ moduleSpecifier: MIGRATION_MODULE,
1146
1138
  symbol: "replaceStoredValue"
1147
1139
  }] : []];
1148
1140
  }
@@ -3640,30 +3632,11 @@ function planVariantDocumentRewrites(input) {
3640
3632
  function renderOps(calls) {
3641
3633
  return calls.map((call) => call.toOp());
3642
3634
  }
3643
- /**
3644
- * Always-present base imports for the rendered scaffold, both from the
3645
- * target's own `migration` entry:
3646
- *
3647
- * - `Migration` — the user-facing Mongo `Migration` base, forwarded from
3648
- * `@internal/family-mongo`; subclasses don't need to redeclare
3649
- * `targetId` or thread family/target generics.
3650
- * - `MigrationCLI` — the migration-file CLI entrypoint that loads
3651
- * `prisma.config.ts`, assembles a `ControlStack`, and instantiates
3652
- * the migration class. The migration file owns this dependency directly:
3653
- * pulling CLI machinery in at script run time is acceptable because the
3654
- * script's whole purpose is to be invoked from the project that owns the
3655
- * config.
3656
- *
3657
- * Naming one package rather than three is what lets an application that
3658
- * installed only `@prisma/orm-mongo` run a scaffolded migration: emitted
3659
- * code may name only a direct dependency (ADR 242), and the facade carries
3660
- * the target's `migration` entry but neither the family base nor the CLI.
3661
- */
3662
3635
  const BASE_IMPORTS = [{
3663
- moduleSpecifier: TARGET_MIGRATION_MODULE,
3636
+ moduleSpecifier: MIGRATION_MODULE,
3664
3637
  symbol: "Migration"
3665
3638
  }, {
3666
- moduleSpecifier: TARGET_MIGRATION_MODULE,
3639
+ moduleSpecifier: MIGRATION_MODULE,
3667
3640
  symbol: "MigrationCLI"
3668
3641
  }];
3669
3642
  /**
@@ -3671,8 +3644,7 @@ const BASE_IMPORTS = [{
3671
3644
  * The result is shebanged, imports the contract JSON from the shared
3672
3645
  * snapshot store (the destination contract, plus the source contract for a
3673
3646
  * non-baseline migration), extends `Migration<Start, End>` (or
3674
- * `Migration<never, End>` for a baseline) from
3675
- * `@internal/target-mongo/migration`,
3647
+ * `Migration<never, End>` for a baseline) from the config's migration module,
3676
3648
  * assigns the JSON to `endContractJson` / `startContractJson`, and implements
3677
3649
  * `operations`. The `Migration` base derives `describe()` from those fields.
3678
3650
  *
@@ -3711,7 +3683,10 @@ function renderCallsToTypeScript(calls, meta) {
3711
3683
  function buildImports(calls, meta) {
3712
3684
  const requirements = [...BASE_IMPORTS, ...contractImports(meta)];
3713
3685
  for (const call of calls) for (const req of call.importRequirements()) requirements.push(req);
3714
- return renderImports(resolveRequirementSpecifiers(requirements, meta.resolveImportSpecifier));
3686
+ return renderImports(requirements.map((requirement) => requirement.moduleSpecifier === "<migrations.module>" ? {
3687
+ ...requirement,
3688
+ moduleSpecifier: meta.migrationModule
3689
+ } : requirement));
3715
3690
  }
3716
3691
  /**
3717
3692
  * The committed contract-JSON imports the scaffold reads its from/to identity
@@ -3786,12 +3761,12 @@ var PlannerProducedMongoMigration = class extends Migration {
3786
3761
  describe() {
3787
3762
  return this.meta;
3788
3763
  }
3789
- renderTypeScript(resolveImportSpecifier) {
3764
+ renderTypeScript(migrationModule) {
3790
3765
  return renderCallsToTypeScript(this.calls, {
3791
3766
  from: this.meta.from,
3792
3767
  to: this.meta.to,
3793
3768
  snapshotsImportPath: this.snapshotsImportPath,
3794
- resolveImportSpecifier
3769
+ migrationModule
3795
3770
  });
3796
3771
  }
3797
3772
  };
@@ -6562,4 +6537,4 @@ const mongoTargetDescriptor = {
6562
6537
  //#endregion
6563
6538
  export { schemaIndexToCreateIndexOptions as C, schemaCollectionToCreateCollectionOptions as S, deserializeMongoOp as _, DropIndexCall as a, renderCallsToTypeScript as b, MongoMigrationRunner as c, MongoTargetSchemaVerifier as d, MongoTargetUnboundDatabase as f, UnsetFieldCall as g, RenameFieldCall as h, DropCollectionCall as i, MongoTargetContractSerializer as l, RenameCollectionCall as m, CreateCollectionCall as n, FilterEvaluator as o, PlannerProducedMongoMigration as p, CreateIndexCall as r, MongoMigrationPlanner as s, CollModCall as t, MongoTargetDatabase as u, deserializeMongoOps as v, serializeMongoOps as w, renderOps as x, mongoTargetDescriptor as y };
6564
6539
 
6565
- //# sourceMappingURL=control-D2tbWwPF.mjs.map
6540
+ //# sourceMappingURL=control-D9f8mKHr.mjs.map