@prisma/orm-target-mongo 0.16.0-dev.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +23 -0
  3. package/dist/adapter.d.mts +19 -0
  4. package/dist/adapter.d.mts.map +1 -0
  5. package/dist/adapter.mjs +12 -0
  6. package/dist/adapter.mjs.map +1 -0
  7. package/dist/adapter__codec-ids.d.mts +12 -0
  8. package/dist/adapter__codec-ids.d.mts.map +1 -0
  9. package/dist/adapter__codec-ids.mjs +2 -0
  10. package/dist/adapter__codec-types.d.mts +38 -0
  11. package/dist/adapter__codec-types.d.mts.map +1 -0
  12. package/dist/adapter__codec-types.mjs +1 -0
  13. package/dist/adapter__codecs.d.mts +14 -0
  14. package/dist/adapter__codecs.d.mts.map +1 -0
  15. package/dist/adapter__codecs.mjs +2 -0
  16. package/dist/adapter__control.d.mts +3 -0
  17. package/dist/adapter__control.mjs +3 -0
  18. package/dist/adapter__runtime.d.mts +16 -0
  19. package/dist/adapter__runtime.d.mts.map +1 -0
  20. package/dist/adapter__runtime.mjs +25 -0
  21. package/dist/adapter__runtime.mjs.map +1 -0
  22. package/dist/codec-ids-BennPcpQ-Btzz3ILV.mjs +12 -0
  23. package/dist/codec-ids-BennPcpQ-Btzz3ILV.mjs.map +1 -0
  24. package/dist/codec-types-Bx2fHyq_.d.mts +35 -0
  25. package/dist/codec-types-Bx2fHyq_.d.mts.map +1 -0
  26. package/dist/codecs-DLWO-Cjc-CWfQj0bY.mjs +170 -0
  27. package/dist/codecs-DLWO-Cjc-CWfQj0bY.mjs.map +1 -0
  28. package/dist/control-BOc5lrQg.mjs +437 -0
  29. package/dist/control-BOc5lrQg.mjs.map +1 -0
  30. package/dist/control-CEXmcht7.mjs +1563 -0
  31. package/dist/control-CEXmcht7.mjs.map +1 -0
  32. package/dist/control-CxXmTy_h.d.mts +312 -0
  33. package/dist/control-CxXmTy_h.d.mts.map +1 -0
  34. package/dist/control-rPM2HNxW.d.mts +170 -0
  35. package/dist/control-rPM2HNxW.d.mts.map +1 -0
  36. package/dist/descriptor-meta-CBiaTwe5-HX742pZh.mjs +17 -0
  37. package/dist/descriptor-meta-CBiaTwe5-HX742pZh.mjs.map +1 -0
  38. package/dist/driver.d.mts +2 -0
  39. package/dist/driver.mjs +2 -0
  40. package/dist/driver__control.d.mts +16 -0
  41. package/dist/driver__control.d.mts.map +1 -0
  42. package/dist/driver__control.mjs +46 -0
  43. package/dist/driver__control.mjs.map +1 -0
  44. package/dist/migration-BkqcE2Uv.d.mts +42 -0
  45. package/dist/migration-BkqcE2Uv.d.mts.map +1 -0
  46. package/dist/migration-C-jfTsGU.mjs +4 -0
  47. package/dist/migration-factories-CCJFG_3e-75oJ8xn2.mjs +201 -0
  48. package/dist/migration-factories-CCJFG_3e-75oJ8xn2.mjs.map +1 -0
  49. package/dist/mongo-adapter-BkVYI6jn-ChXldtpg.mjs +807 -0
  50. package/dist/mongo-adapter-BkVYI6jn-ChXldtpg.mjs.map +1 -0
  51. package/dist/mongo-adapter-CjJU3S9o-BIJruFYW.d.mts +16 -0
  52. package/dist/mongo-adapter-CjJU3S9o-BIJruFYW.d.mts.map +1 -0
  53. package/dist/mongo-driver-C7zThOjZ-BcMrlirh.mjs +161 -0
  54. package/dist/mongo-driver-C7zThOjZ-BcMrlirh.mjs.map +1 -0
  55. package/dist/mongo-driver-D1lEf5Kl-KPfGUVXK.d.mts +33 -0
  56. package/dist/mongo-driver-D1lEf5Kl-KPfGUVXK.d.mts.map +1 -0
  57. package/dist/op-factory-call-B7EKa4Ri-B2Lb6W68.d.mts +76 -0
  58. package/dist/op-factory-call-B7EKa4Ri-B2Lb6W68.d.mts.map +1 -0
  59. package/dist/pack-MK8ZQfrL.d.mts +22 -0
  60. package/dist/pack-MK8ZQfrL.d.mts.map +1 -0
  61. package/dist/runtime-B9_-kjBX.d.mts +15 -0
  62. package/dist/runtime-B9_-kjBX.d.mts.map +1 -0
  63. package/dist/target.d.mts +8 -0
  64. package/dist/target.mjs +4 -0
  65. package/dist/target__codec-types.d.mts +2 -0
  66. package/dist/target__codec-types.mjs +1 -0
  67. package/dist/target__control.d.mts +4 -0
  68. package/dist/target__control.mjs +2 -0
  69. package/dist/target__migration.d.mts +2 -0
  70. package/dist/target__migration.mjs +3 -0
  71. package/dist/target__pack.d.mts +2 -0
  72. package/dist/target__pack.mjs +7 -0
  73. package/dist/target__pack.mjs.map +1 -0
  74. package/dist/target__runtime.d.mts +2 -0
  75. package/dist/target__runtime.mjs +21 -0
  76. package/dist/target__runtime.mjs.map +1 -0
  77. package/package.json +63 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"control-BOc5lrQg.mjs","names":["#execute","#adapter","#markerLedgerCollection","#invariantMergeExpr"],"sources":["../../../../3-mongo-target/2-mongo-adapter/dist/control.mjs"],"sourcesContent":["import { t as createMongoAdapter } from \"./mongo-adapter-BkVYI6jn.mjs\";\nimport { a as mongoAdapterError, i as describeReceivedValue } from \"./codecs-DLWO-Cjc.mjs\";\nimport { MongoAggFieldRef, MongoAggLiteral, MongoAggOperator } from \"@internal/mongo-query-ast/execution\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { MongoServerError } from \"mongodb\";\nimport { MongoSchemaCollection, MongoSchemaCollectionOptions, MongoSchemaIR, MongoSchemaIndex, MongoSchemaValidator } from \"@internal/mongo-schema-ir\";\nimport { parseMarkerRowSafely, withMarkerReadErrorHandling } from \"@internal/errors/execution\";\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/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/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\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);\n}\n//#endregion\n//#region src/core/marker-ledger.ts\nconst COLLECTION = \"_prisma_migrations\";\nconst MONGO_MARKER_COLLECTION = `_prisma_migrations marker documents in ${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/mongo-control-driver.ts\nfunction isMongoControlDriver(driver) {\n\treturn driver.familyId === \"mongo\" && driver.targetId === \"mongo\" && \"execute\" in driver && typeof driver.execute === \"function\";\n}\n//#endregion\n//#region src/core/runner-deps.ts\nfunction extractDb(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.db;\n}\n/**\n* Build the runner-dependencies envelope. `controlAdapter` is the\n* dispatch surface for wire-level Mongo CAS operations (marker reads,\n* marker advances, ledger appends, introspection); the envelope's\n* `markerOps` shim simply forwards each call through it. When the\n* caller already has a `MongoControlAdapter` on the control stack it\n* can pass it in; otherwise a default `MongoControlAdapterImpl` is\n* constructed locally.\n*/\nfunction createMongoRunnerDeps(controlDriver, driver, _family, controlAdapter = new MongoControlAdapterImpl()) {\n\tconst adapter = createMongoAdapter();\n\treturn {\n\t\tinspectionExecutor: new MongoInspectionExecutor(extractDb(controlDriver)),\n\t\tadapter,\n\t\tdriver,\n\t\texecuteDdl: (command) => adapter.lower({ command }, {}).then((wire) => driver.run(wire)),\n\t\tmarkerOps: {\n\t\t\treadMarker: (space) => controlAdapter.readMarker(controlDriver, space),\n\t\t\tinitMarker: (space, dest) => controlAdapter.initMarker(controlDriver, space, dest),\n\t\t\tupdateMarker: (space, expectedFrom, dest) => controlAdapter.updateMarker(controlDriver, space, expectedFrom, dest),\n\t\t\twriteLedgerEntry: (space, entry) => controlAdapter.writeLedgerEntry(controlDriver, space, entry)\n\t\t},\n\t\tintrospectSchema: () => controlAdapter.introspectSchema(controlDriver)\n\t};\n}\n//#endregion\n//#region src/core/mongo-control-adapter.ts\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\t#adapter = createMongoAdapter();\n\t#markerLedgerCollection = collection(MARKER_LEDGER_COLLECTION);\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\",\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 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: {},\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) {\n\t\tconst { invariants } = destination;\n\t\treturn (await this.#execute(driver, this.#markerLedgerCollection.match((f) => f._id.eq(space)).match((f) => f.space.eq(space)).match((f) => f.storageHash.eq(expectedFrom)).findOneAndUpdate((f) => [f.stage.set(invariants === void 0 ? {\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} : {\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\tinvariants: this.#invariantMergeExpr(invariants)\n\t\t})], { 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};\n//#endregion\n//#region src/exports/control.ts\n/**\n* The base PSL scalars as zero-arg type constructors in the unified authoring\n* channel, with explicit `nativeType` values pinned to the codec manifests\n* (`codecLookup.targetTypesFor(codecId)[0]`).\n*/\nconst mongoScalarAuthoringTypes = {\n\tString: {\n\t\tkind: \"typeConstructor\",\n\t\toutput: {\n\t\t\tcodecId: \"mongo/string@1\",\n\t\t\tnativeType: \"string\"\n\t\t}\n\t},\n\tInt: {\n\t\tkind: \"typeConstructor\",\n\t\toutput: {\n\t\t\tcodecId: \"mongo/int32@1\",\n\t\t\tnativeType: \"int\"\n\t\t}\n\t},\n\tBoolean: {\n\t\tkind: \"typeConstructor\",\n\t\toutput: {\n\t\t\tcodecId: \"mongo/bool@1\",\n\t\t\tnativeType: \"bool\"\n\t\t}\n\t},\n\tDateTime: {\n\t\tkind: \"typeConstructor\",\n\t\toutput: {\n\t\t\tcodecId: \"mongo/date@1\",\n\t\t\tnativeType: \"date\"\n\t\t}\n\t},\n\tObjectId: {\n\t\tkind: \"typeConstructor\",\n\t\toutput: {\n\t\t\tcodecId: \"mongo/objectId@1\",\n\t\t\tnativeType: \"objectId\"\n\t\t}\n\t},\n\tFloat: {\n\t\tkind: \"typeConstructor\",\n\t\toutput: {\n\t\t\tcodecId: \"mongo/double@1\",\n\t\t\tnativeType: \"double\"\n\t\t}\n\t}\n};\nconst mongoAdapterDescriptor = {\n\tkind: \"adapter\",\n\tid: \"mongo\",\n\tfamilyId: \"mongo\",\n\ttargetId: \"mongo\",\n\tversion: \"0.0.1\",\n\tauthoring: { type: mongoScalarAuthoringTypes },\n\ttypes: { codecTypes: {\n\t\timport: {\n\t\t\tpackage: \"@internal/adapter-mongo/codec-types\",\n\t\t\tnamed: \"CodecTypes\",\n\t\t\talias: \"MongoCodecTypes\"\n\t\t},\n\t\ttypeImports: [{\n\t\t\tpackage: \"@internal/adapter-mongo/codec-types\",\n\t\t\tnamed: \"Vector\",\n\t\t\talias: \"Vector\"\n\t\t}]\n\t} },\n\tcreate(_stack) {\n\t\treturn new MongoControlAdapterImpl();\n\t}\n};\n//#endregion\nexport { MongoControlAdapterImpl, MongoInspectionExecutor, createMongoAdapter, createMongoRunnerDeps, mongoAdapterDescriptor as default, mongoAdapterDescriptor, extractDb, introspectSchema, isMongoControlDriver, mongoScalarAuthoringTypes };\n\n//# sourceMappingURL=control.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;AAkBA,IAAI,0BAA0B,MAAM;CACnC;CACA,YAAY,IAAI;EACf,KAAK,KAAK;CACX;CACA,MAAM,YAAY,KAAK;EACtB,IAAI;GACH,OAAO,MAAM,KAAK,GAAG,WAAW,IAAI,UAAU,CAAC,CAAC,YAAY,CAAC,CAAC,QAAQ;EACvE,SAAS,OAAO;GACf,IAAI,iBAAiB,oBAAoB,MAAM,SAAS,IAAI,OAAO,CAAC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