@prisma/orm-target-mongo 8.0.0-rc.13-dev.12 → 8.0.0-rc.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapter.mjs +1 -1
- package/dist/adapter.mjs.map +1 -1
- package/dist/adapter__control.mjs +1 -1
- package/dist/adapter__control.mjs.map +1 -1
- package/dist/adapter__runtime.mjs +2 -2
- package/dist/adapter__runtime.mjs.map +1 -1
- package/dist/{codec-types-BqPLybhD.d.mts → codec-types-CxbyKvKL.d.mts} +13 -1
- package/dist/codec-types-CxbyKvKL.d.mts.map +1 -0
- package/dist/{codecs-xffquj_O.d.mts → codecs-8iNuBwPO.d.mts} +3 -3
- package/dist/codecs-8iNuBwPO.d.mts.map +1 -0
- package/dist/{codecs-B0Szbq1k-DGXwjn9l.mjs → codecs-CUY6H3CA-BuXwvtSA.mjs} +142 -31
- package/dist/codecs-CUY6H3CA-BuXwvtSA.mjs.map +1 -0
- package/dist/{control-BsJepSbb.mjs → control-BBuW6JsP.mjs} +53 -6
- package/dist/control-BBuW6JsP.mjs.map +1 -0
- package/dist/{descriptor-meta-Bobm2m-Q-C9Bd4xUM.mjs → descriptor-meta-BlNLaw2v-DEFzOiYx.mjs} +3 -3
- package/dist/{descriptor-meta-Bobm2m-Q-C9Bd4xUM.mjs.map → descriptor-meta-BlNLaw2v-DEFzOiYx.mjs.map} +1 -1
- package/dist/{descriptor-meta-runtime-C5SUv3LG-Dv9IWBR2.mjs → descriptor-meta-runtime-Z8gDDekl-CpdMeIL6.mjs} +3 -3
- package/dist/{descriptor-meta-runtime-C5SUv3LG-Dv9IWBR2.mjs.map → descriptor-meta-runtime-Z8gDDekl-CpdMeIL6.mjs.map} +1 -1
- package/dist/driver.d.mts +1 -1
- package/dist/driver.mjs +1 -1
- package/dist/driver__control.d.mts +2 -1
- package/dist/driver__control.d.mts.map +1 -1
- package/dist/driver__control.mjs +4 -1
- package/dist/driver__control.mjs.map +1 -1
- package/dist/{mongo-adapter-Cm9V2ftE-B9vITX5a.mjs → mongo-adapter-BGuuu-r7-C7GzLW2H.mjs} +15 -8
- package/dist/mongo-adapter-BGuuu-r7-C7GzLW2H.mjs.map +1 -0
- package/dist/{mongo-driver-D1lEf5Kl-KPfGUVXK.d.mts → mongo-driver-BTjYMBKs-CN2niXFQ.d.mts} +7 -3
- package/dist/mongo-driver-BTjYMBKs-CN2niXFQ.d.mts.map +1 -0
- package/dist/{mongo-driver-DWHM65jW-BbJhtGzG.mjs → mongo-driver-DzlaPv-p-BtFKcX2W.mjs} +26 -7
- package/dist/mongo-driver-DzlaPv-p-BtFKcX2W.mjs.map +1 -0
- package/dist/{pack-8KElTm25.d.mts → pack-C3mtcx_t.d.mts} +2 -2
- package/dist/{pack-8KElTm25.d.mts.map → pack-C3mtcx_t.d.mts.map} +1 -1
- package/dist/{prisma6-binding-CbZetx23.mjs → prisma6-binding-Cwvq3v6M.mjs} +2 -2
- package/dist/{prisma6-binding-CbZetx23.mjs.map → prisma6-binding-Cwvq3v6M.mjs.map} +1 -1
- package/dist/target.d.mts +3 -3
- package/dist/target.mjs +3 -3
- package/dist/target__codec-types.d.mts +1 -1
- package/dist/target__codecs.d.mts +1 -1
- package/dist/target__codecs.mjs +1 -1
- package/dist/target__control.mjs +1 -1
- package/dist/target__pack.d.mts +1 -1
- package/dist/target__pack.mjs +1 -1
- package/dist/target__pack.mjs.map +1 -1
- package/dist/target__prisma6-binding.mjs +1 -1
- package/dist/target__runtime.mjs +1 -1
- package/dist/target__runtime.mjs.map +1 -1
- package/package.json +9 -9
- package/dist/codec-types-BqPLybhD.d.mts.map +0 -1
- package/dist/codecs-B0Szbq1k-DGXwjn9l.mjs.map +0 -1
- package/dist/codecs-xffquj_O.d.mts.map +0 -1
- package/dist/control-BsJepSbb.mjs.map +0 -1
- package/dist/mongo-adapter-Cm9V2ftE-B9vITX5a.mjs.map +0 -1
- package/dist/mongo-driver-D1lEf5Kl-KPfGUVXK.d.mts.map +0 -1
- package/dist/mongo-driver-DWHM65jW-BbJhtGzG.mjs.map +0 -1
package/dist/adapter.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { f as MONGO_VECTOR_CODEC_ID } from "./codec-ids-CuHXNFWL-BYExYC_z.mjs";
|
|
2
|
-
import { a as lowerStage, i as lowerPipeline, n as lowerAggExpr, r as lowerFilter, t as createMongoAdapter } from "./mongo-adapter-
|
|
2
|
+
import { a as lowerStage, i as lowerPipeline, n as lowerAggExpr, r as lowerFilter, t as createMongoAdapter } from "./mongo-adapter-BGuuu-r7-C7GzLW2H.mjs";
|
|
3
3
|
//#region ../../../3-mongo-target/2-mongo-adapter/dist/index.mjs
|
|
4
4
|
const mongoVectorNearOperation = Object.freeze({
|
|
5
5
|
self: { codecId: MONGO_VECTOR_CODEC_ID },
|
package/dist/adapter.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.mjs","names":[],"sources":["../../../../3-mongo-target/2-mongo-adapter/dist/index.mjs"],"sourcesContent":["import { a as lowerStage, i as lowerPipeline, n as lowerAggExpr, r as lowerFilter, t as createMongoAdapter } from \"./mongo-adapter-
|
|
1
|
+
{"version":3,"file":"adapter.mjs","names":[],"sources":["../../../../3-mongo-target/2-mongo-adapter/dist/index.mjs"],"sourcesContent":["import { a as lowerStage, i as lowerPipeline, n as lowerAggExpr, r as lowerFilter, t as createMongoAdapter } from \"./mongo-adapter-BGuuu-r7.mjs\";\nimport { MONGO_VECTOR_CODEC_ID } from \"@internal/target-mongo/codec-ids\";\n//#region src/core/operations.ts\nconst mongoVectorNearOperation = Object.freeze({\n\tself: { codecId: MONGO_VECTOR_CODEC_ID },\n\timpl: () => void 0\n});\nconst mongoVectorOperationDescriptors = { near: mongoVectorNearOperation };\n//#endregion\nexport { createMongoAdapter, lowerAggExpr, lowerFilter, lowerPipeline, lowerStage, mongoVectorNearOperation, mongoVectorOperationDescriptors };\n\n//# sourceMappingURL=index.mjs.map"],"mappings":";;;AAGA,MAAM,2BAA2B,OAAO,OAAO;CAC9C,MAAM,EAAE,SAAS,sBAAsB;CACvC,YAAY,KAAK;AAClB,CAAC;AACD,MAAM,kCAAkC,EAAE,MAAM,yBAAyB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as MONGO_DECIMAL128_CODEC_ID, c as MONGO_INT64_CODEC_ID, d as MONGO_STRING_CODEC_ID, i as MONGO_DATE_CODEC_ID, l as MONGO_JSON_CODEC_ID, n as MONGO_BOOLEAN_CODEC_ID, o as MONGO_DOUBLE_CODEC_ID, r as MONGO_BSON_CODEC_ID, s as MONGO_INT32_CODEC_ID, t as MONGO_BINARY_CODEC_ID, u as MONGO_OBJECTID_CODEC_ID } from "./codec-ids-CuHXNFWL-BYExYC_z.mjs";
|
|
2
|
-
import { t as createMongoAdapter } from "./mongo-adapter-
|
|
2
|
+
import { t as createMongoAdapter } from "./mongo-adapter-BGuuu-r7-C7GzLW2H.mjs";
|
|
3
3
|
import { blindCast } from "@prisma/orm-framework/utils/casts";
|
|
4
4
|
import { structuredError } from "@prisma/orm-framework/utils/structured-error";
|
|
5
5
|
import { expr, fn } from "@prisma/orm-family-mongo/query-builder";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter__control.mjs","names":["#execute","#adapter","#markerLedgerCollection","#invariantMergeExpr"],"sources":["../../../../3-mongo-target/2-mongo-adapter/dist/control.mjs"],"sourcesContent":["import { t as createMongoAdapter } from \"./mongo-adapter-Cm9V2ftE.mjs\";\nimport { MONGO_BINARY_CODEC_ID, MONGO_BOOLEAN_CODEC_ID, MONGO_BSON_CODEC_ID, MONGO_DATE_CODEC_ID, MONGO_DECIMAL128_CODEC_ID, MONGO_DOUBLE_CODEC_ID, MONGO_INT32_CODEC_ID, MONGO_INT64_CODEC_ID, MONGO_JSON_CODEC_ID, MONGO_OBJECTID_CODEC_ID, MONGO_STRING_CODEC_ID } from \"@internal/target-mongo/codec-ids\";\nimport { MongoAggFieldRef, MongoAggLiteral, MongoAggOperator } from \"@internal/mongo-query-ast/execution\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { structuredError } from \"@internal/utils/structured-error\";\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/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 = `_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}\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/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\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\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) => this.updateMarker(controlDriver, space, expectedFrom, destination),\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\n/**\n* The base PSL scalars as zero-arg type constructors in the unified authoring channel. For a codec with one BSON type, `nativeType` is that type (`codecLookup.targetTypesFor(codecId)[0]`). `Json` (several BSON types) and `Bson` (none) have a `nativeType` that names the codec instead; the validator reads the codec's `targetTypes` list, not this value.\n*/\nconst mongoScalarAuthoringTypes = {\n\tString: {\n\t\tkind: \"typeConstructor\",\n\t\tdocumentation: \"Text, stored as BSON string.\",\n\t\toutput: {\n\t\t\tcodecId: MONGO_STRING_CODEC_ID,\n\t\t\tnativeType: \"string\"\n\t\t}\n\t},\n\tInt32: {\n\t\tkind: \"typeConstructor\",\n\t\tdocumentation: \"A signed 32-bit integer, stored as BSON int.\",\n\t\toutput: {\n\t\t\tcodecId: MONGO_INT32_CODEC_ID,\n\t\t\tnativeType: \"int\"\n\t\t}\n\t},\n\tBool: {\n\t\tkind: \"typeConstructor\",\n\t\tdocumentation: \"A true or false value, stored as BSON bool.\",\n\t\toutput: {\n\t\t\tcodecId: MONGO_BOOLEAN_CODEC_ID,\n\t\t\tnativeType: \"bool\"\n\t\t}\n\t},\n\tDate: {\n\t\tkind: \"typeConstructor\",\n\t\tdocumentation: \"A date and time with millisecond precision, stored as BSON date.\",\n\t\toutput: {\n\t\t\tcodecId: MONGO_DATE_CODEC_ID,\n\t\t\tnativeType: \"date\"\n\t\t}\n\t},\n\tObjectId: {\n\t\tkind: \"typeConstructor\",\n\t\tdocumentation: \"A 12-byte MongoDB identifier, stored as BSON objectId.\",\n\t\toutput: {\n\t\t\tcodecId: MONGO_OBJECTID_CODEC_ID,\n\t\t\tnativeType: \"objectId\"\n\t\t}\n\t},\n\tDouble: {\n\t\tkind: \"typeConstructor\",\n\t\tdocumentation: \"A double-precision floating-point number, stored as BSON double.\",\n\t\toutput: {\n\t\t\tcodecId: MONGO_DOUBLE_CODEC_ID,\n\t\t\tnativeType: \"double\"\n\t\t}\n\t},\n\tInt64: {\n\t\tkind: \"typeConstructor\",\n\t\tdocumentation: \"A signed 64-bit integer read as a bigint, stored as BSON long.\",\n\t\toutput: {\n\t\t\tcodecId: MONGO_INT64_CODEC_ID,\n\t\t\tnativeType: \"long\"\n\t\t}\n\t},\n\tDecimal128: {\n\t\tkind: \"typeConstructor\",\n\t\tdocumentation: \"A 128-bit decimal read as decimal text without an exponent, stored as BSON decimal.\",\n\t\toutput: {\n\t\t\tcodecId: MONGO_DECIMAL128_CODEC_ID,\n\t\t\tnativeType: \"decimal\"\n\t\t}\n\t},\n\tBinary: {\n\t\tkind: \"typeConstructor\",\n\t\tdocumentation: \"Bytes read as a Uint8Array, stored as BSON binData.\",\n\t\toutput: {\n\t\t\tcodecId: MONGO_BINARY_CODEC_ID,\n\t\t\tnativeType: \"binData\"\n\t\t}\n\t},\n\tJson: {\n\t\tkind: \"typeConstructor\",\n\t\tdocumentation: \"A JSON value, stored as BSON object, array, string, double, int, long, bool or null; the collection validator admits only those types at the top level, and the codec refuses anything else at any depth.\",\n\t\toutput: {\n\t\t\tcodecId: MONGO_JSON_CODEC_ID,\n\t\t\tnativeType: \"json\"\n\t\t}\n\t},\n\tBson: {\n\t\tkind: \"typeConstructor\",\n\t\tdocumentation: \"Any BSON value, read as BsonValue; the collection validator does not constrain it.\",\n\t\toutput: {\n\t\t\tcodecId: MONGO_BSON_CODEC_ID,\n\t\t\tnativeType: \"bson\"\n\t\t}\n\t},\n\tInt: {\n\t\tkind: \"typeConstructor\",\n\t\tdocumentation: \"Deprecated: use Int32. A signed 32-bit integer, stored as BSON int.\",\n\t\toutput: {\n\t\t\tcodecId: MONGO_INT32_CODEC_ID,\n\t\t\tnativeType: \"int\"\n\t\t},\n\t\tdeprecated: { replacement: \"Int32\" }\n\t},\n\tFloat: {\n\t\tkind: \"typeConstructor\",\n\t\tdocumentation: \"Deprecated: use Double. A double-precision floating-point number, stored as BSON double.\",\n\t\toutput: {\n\t\t\tcodecId: MONGO_DOUBLE_CODEC_ID,\n\t\t\tnativeType: \"double\"\n\t\t},\n\t\tdeprecated: { replacement: \"Double\" }\n\t},\n\tBoolean: {\n\t\tkind: \"typeConstructor\",\n\t\tdocumentation: \"Deprecated: use Bool. A true or false value, stored as BSON bool.\",\n\t\toutput: {\n\t\t\tcodecId: MONGO_BOOLEAN_CODEC_ID,\n\t\t\tnativeType: \"bool\"\n\t\t},\n\t\tdeprecated: { replacement: \"Bool\" }\n\t},\n\tDateTime: {\n\t\tkind: \"typeConstructor\",\n\t\tdocumentation: \"Deprecated: use Date. A date and time with millisecond precision, stored as BSON date.\",\n\t\toutput: {\n\t\t\tcodecId: MONGO_DATE_CODEC_ID,\n\t\t\tnativeType: \"date\"\n\t\t},\n\t\tdeprecated: { replacement: \"Date\" }\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/target-mongo/codec-types\",\n\t\t\tnamed: \"CodecTypes\",\n\t\t\talias: \"MongoCodecTypes\"\n\t\t},\n\t\ttypeImports: [{\n\t\t\tpackage: \"@internal/target-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, mongoAdapterDescriptor as default, mongoAdapterDescriptor, extractDb, introspectSchema, isMongoControlDriver, mongoScalarAuthoringTypes };\n\n//# sourceMappingURL=control.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;;AAmBA,IAAI,0BAA0B,MAAM;CACnC;CACA,YAAY,IAAI;EACf,KAAK,KAAK;CACX;CACA,MAAM,YAAY,KAAK;EACtB,IAAI;GACH,OAAO,MA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AAY;EACb;CACD;CACA,QAAQ;EACP,MAAM;EACN,eAAe;EACf,QAAQ;GACP,SAAS;GACT,YAAY;EACb;CACD;CACA,MAAM;EACL,MAAM;EACN,eAAe;EACf,QAAQ;GACP,SAAS;GACT,YAAY;EACb;CACD;CACA,MAAM;EACL,MAAM;EACN,eAAe;EACf,QAAQ;GACP,SAAS;GACT,YAAY;EACb;CACD;CACA,KAAK;EACJ,MAAM;EACN,eAAe;EACf,QAAQ;GACP,SAAS;GACT,YAAY;EACb;EACA,YAAY,EAAE,aAAa,QAAQ;CACpC;CACA,OAAO;EACN,MAAM;EACN,eAAe;EACf,QAAQ;GACP,SAAS;GACT,YAAY;EACb;EACA,YAAY,EAAE,aAAa,SAAS;CACrC;CACA,SAAS;EACR,MAAM;EACN,eAAe;EACf,QAAQ;GACP,SAAS;GACT,YAAY;EACb;EACA,YAAY,EAAE,aAAa,OAAO;CACnC;CACA,UAAU;EACT,MAAM;EACN,eAAe;EACf,QAAQ;GACP,SAAS;GACT,YAAY;EACb;EACA,YAAY,EAAE,aAAa,OAAO;CACnC;AACD;AACA,MAAM,yBAAyB;CAC9B,MAAM;CACN,IAAI;CACJ,UAAU;CACV,UAAU;CACV,SAAS;CACT,WAAW,EAAE,MAAM,0BAA0B;CAC7C,OAAO,EAAE,YAAY;EACpB,QAAQ;GACP,SAAS;GACT,OAAO;GACP,OAAO;EACR;EACA,aAAa,CAAC;GACb,SAAS;GACT,OAAO;GACP,OAAO;EACR,CAAC;CACF,EAAE;CACF,OAAO,QAAQ;EACd,OAAO,IAAI,wBAAwB;CACpC;AACD"}
|
|
1
|
+
{"version":3,"file":"adapter__control.mjs","names":["#execute","#adapter","#markerLedgerCollection","#invariantMergeExpr"],"sources":["../../../../3-mongo-target/2-mongo-adapter/dist/control.mjs"],"sourcesContent":["import { t as createMongoAdapter } from \"./mongo-adapter-BGuuu-r7.mjs\";\nimport { MONGO_BINARY_CODEC_ID, MONGO_BOOLEAN_CODEC_ID, MONGO_BSON_CODEC_ID, MONGO_DATE_CODEC_ID, MONGO_DECIMAL128_CODEC_ID, MONGO_DOUBLE_CODEC_ID, MONGO_INT32_CODEC_ID, MONGO_INT64_CODEC_ID, MONGO_JSON_CODEC_ID, MONGO_OBJECTID_CODEC_ID, MONGO_STRING_CODEC_ID } from \"@internal/target-mongo/codec-ids\";\nimport { MongoAggFieldRef, MongoAggLiteral, MongoAggOperator } from \"@internal/mongo-query-ast/execution\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { structuredError } from \"@internal/utils/structured-error\";\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/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 = `_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}\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/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\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\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) => this.updateMarker(controlDriver, space, expectedFrom, destination),\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\n/**\n* The base PSL scalars as zero-arg type constructors in the unified authoring channel. For a codec with one BSON type, `nativeType` is that type (`codecLookup.targetTypesFor(codecId)[0]`). `Json` (several BSON types) and `Bson` (none) have a `nativeType` that names the codec instead; the validator reads the codec's `targetTypes` list, not this value.\n*/\nconst mongoScalarAuthoringTypes = {\n\tString: {\n\t\tkind: \"typeConstructor\",\n\t\tdocumentation: \"Text, stored as BSON string.\",\n\t\toutput: {\n\t\t\tcodecId: MONGO_STRING_CODEC_ID,\n\t\t\tnativeType: \"string\"\n\t\t}\n\t},\n\tInt32: {\n\t\tkind: \"typeConstructor\",\n\t\tdocumentation: \"A signed 32-bit integer, stored as BSON int.\",\n\t\toutput: {\n\t\t\tcodecId: MONGO_INT32_CODEC_ID,\n\t\t\tnativeType: \"int\"\n\t\t}\n\t},\n\tBool: {\n\t\tkind: \"typeConstructor\",\n\t\tdocumentation: \"A true or false value, stored as BSON bool.\",\n\t\toutput: {\n\t\t\tcodecId: MONGO_BOOLEAN_CODEC_ID,\n\t\t\tnativeType: \"bool\"\n\t\t}\n\t},\n\tDate: {\n\t\tkind: \"typeConstructor\",\n\t\tdocumentation: \"A date and time with millisecond precision, stored as BSON date.\",\n\t\toutput: {\n\t\t\tcodecId: MONGO_DATE_CODEC_ID,\n\t\t\tnativeType: \"date\"\n\t\t}\n\t},\n\tObjectId: {\n\t\tkind: \"typeConstructor\",\n\t\tdocumentation: \"A 12-byte MongoDB identifier, stored as BSON objectId.\",\n\t\toutput: {\n\t\t\tcodecId: MONGO_OBJECTID_CODEC_ID,\n\t\t\tnativeType: \"objectId\"\n\t\t}\n\t},\n\tDouble: {\n\t\tkind: \"typeConstructor\",\n\t\tdocumentation: \"A double-precision floating-point number, stored as BSON double.\",\n\t\toutput: {\n\t\t\tcodecId: MONGO_DOUBLE_CODEC_ID,\n\t\t\tnativeType: \"double\"\n\t\t}\n\t},\n\tInt64: {\n\t\tkind: \"typeConstructor\",\n\t\tdocumentation: \"A signed 64-bit integer read as a bigint, stored as BSON long.\",\n\t\toutput: {\n\t\t\tcodecId: MONGO_INT64_CODEC_ID,\n\t\t\tnativeType: \"long\"\n\t\t}\n\t},\n\tDecimal128: {\n\t\tkind: \"typeConstructor\",\n\t\tdocumentation: \"A 128-bit decimal read as decimal text without an exponent, stored as BSON decimal.\",\n\t\toutput: {\n\t\t\tcodecId: MONGO_DECIMAL128_CODEC_ID,\n\t\t\tnativeType: \"decimal\"\n\t\t}\n\t},\n\tBinary: {\n\t\tkind: \"typeConstructor\",\n\t\tdocumentation: \"Bytes read as a Uint8Array, stored as BSON binData.\",\n\t\toutput: {\n\t\t\tcodecId: MONGO_BINARY_CODEC_ID,\n\t\t\tnativeType: \"binData\"\n\t\t}\n\t},\n\tJson: {\n\t\tkind: \"typeConstructor\",\n\t\tdocumentation: \"A JSON value, stored as BSON object, array, string, double, int, long, bool or null; the collection validator admits only those types at the top level, and the codec refuses anything else at any depth.\",\n\t\toutput: {\n\t\t\tcodecId: MONGO_JSON_CODEC_ID,\n\t\t\tnativeType: \"json\"\n\t\t}\n\t},\n\tBson: {\n\t\tkind: \"typeConstructor\",\n\t\tdocumentation: \"Any BSON value, read as BsonValue; the collection validator does not constrain it.\",\n\t\toutput: {\n\t\t\tcodecId: MONGO_BSON_CODEC_ID,\n\t\t\tnativeType: \"bson\"\n\t\t}\n\t},\n\tInt: {\n\t\tkind: \"typeConstructor\",\n\t\tdocumentation: \"Deprecated: use Int32. A signed 32-bit integer, stored as BSON int.\",\n\t\toutput: {\n\t\t\tcodecId: MONGO_INT32_CODEC_ID,\n\t\t\tnativeType: \"int\"\n\t\t},\n\t\tdeprecated: { replacement: \"Int32\" }\n\t},\n\tFloat: {\n\t\tkind: \"typeConstructor\",\n\t\tdocumentation: \"Deprecated: use Double. A double-precision floating-point number, stored as BSON double.\",\n\t\toutput: {\n\t\t\tcodecId: MONGO_DOUBLE_CODEC_ID,\n\t\t\tnativeType: \"double\"\n\t\t},\n\t\tdeprecated: { replacement: \"Double\" }\n\t},\n\tBoolean: {\n\t\tkind: \"typeConstructor\",\n\t\tdocumentation: \"Deprecated: use Bool. A true or false value, stored as BSON bool.\",\n\t\toutput: {\n\t\t\tcodecId: MONGO_BOOLEAN_CODEC_ID,\n\t\t\tnativeType: \"bool\"\n\t\t},\n\t\tdeprecated: { replacement: \"Bool\" }\n\t},\n\tDateTime: {\n\t\tkind: \"typeConstructor\",\n\t\tdocumentation: \"Deprecated: use Date. A date and time with millisecond precision, stored as BSON date.\",\n\t\toutput: {\n\t\t\tcodecId: MONGO_DATE_CODEC_ID,\n\t\t\tnativeType: \"date\"\n\t\t},\n\t\tdeprecated: { replacement: \"Date\" }\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/target-mongo/codec-types\",\n\t\t\tnamed: \"CodecTypes\",\n\t\t\talias: \"MongoCodecTypes\"\n\t\t},\n\t\ttypeImports: [{\n\t\t\tpackage: \"@internal/target-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, mongoAdapterDescriptor as default, mongoAdapterDescriptor, extractDb, intro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1
|
-
import { t as buildStandardCodecRegistry } from "./codecs-
|
|
2
|
-
import { t as createMongoAdapter } from "./mongo-adapter-
|
|
1
|
+
import { t as buildStandardCodecRegistry } from "./codecs-CUY6H3CA-BuXwvtSA.mjs";
|
|
2
|
+
import { t as createMongoAdapter } from "./mongo-adapter-BGuuu-r7-C7GzLW2H.mjs";
|
|
3
3
|
import { timestampNowRuntimeGenerator } from "@prisma/orm-family-mongo/family/runtime";
|
|
4
4
|
//#region ../../../3-mongo-target/2-mongo-adapter/dist/runtime.mjs
|
|
5
5
|
const mongoRuntimeAdapterDescriptor = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter__runtime.mjs","names":[],"sources":["../../../../3-mongo-target/2-mongo-adapter/dist/runtime.mjs"],"sourcesContent":["import { t as createMongoAdapter } from \"./mongo-adapter-
|
|
1
|
+
{"version":3,"file":"adapter__runtime.mjs","names":[],"sources":["../../../../3-mongo-target/2-mongo-adapter/dist/runtime.mjs"],"sourcesContent":["import { t as createMongoAdapter } from \"./mongo-adapter-BGuuu-r7.mjs\";\nimport { buildStandardCodecRegistry } from \"@internal/target-mongo/codecs\";\nimport { timestampNowRuntimeGenerator } from \"@internal/family-mongo/runtime\";\n//#region src/exports/runtime.ts\nconst mongoRuntimeAdapterDescriptor = {\n\tkind: \"adapter\",\n\tid: \"mongo\",\n\tfamilyId: \"mongo\",\n\ttargetId: \"mongo\",\n\tversion: \"0.0.1\",\n\tcodecs: buildStandardCodecRegistry,\n\tmutationDefaultGenerators: () => [timestampNowRuntimeGenerator()],\n\tcreate(_stack) {\n\t\tconst adapter = createMongoAdapter();\n\t\treturn {\n\t\t\tfamilyId: \"mongo\",\n\t\t\ttargetId: \"mongo\",\n\t\t\tlower: adapter.lower.bind(adapter),\n\t\t\tstructuralLower: adapter.structuralLower.bind(adapter),\n\t\t\tresolveParams: adapter.resolveParams.bind(adapter)\n\t\t};\n\t}\n};\n//#endregion\nexport { mongoRuntimeAdapterDescriptor as default };\n\n//# sourceMappingURL=runtime.mjs.map"],"mappings":";;;;AAIA,MAAM,gCAAgC;CACrC,MAAM;CACN,IAAI;CACJ,UAAU;CACV,UAAU;CACV,SAAS;CACT,QAAQ;CACR,iCAAiC,CAAC,6BAA6B,CAAC;CAChE,OAAO,QAAQ;EACd,MAAM,UAAU,mBAAmB;EACnC,OAAO;GACN,UAAU;GACV,UAAU;GACV,OAAO,QAAQ,MAAM,KAAK,OAAO;GACjC,iBAAiB,QAAQ,gBAAgB,KAAK,OAAO;GACrD,eAAe,QAAQ,cAAc,KAAK,OAAO;EAClD;CACD;AACD"}
|
|
@@ -9,52 +9,64 @@ type CodecTypes = {
|
|
|
9
9
|
readonly 'mongo/objectId@1': {
|
|
10
10
|
readonly input: string;
|
|
11
11
|
readonly output: string;
|
|
12
|
+
readonly traits: 'equality';
|
|
12
13
|
};
|
|
13
14
|
readonly 'mongo/string@1': {
|
|
14
15
|
readonly input: string;
|
|
15
16
|
readonly output: string;
|
|
17
|
+
readonly traits: 'equality' | 'order' | 'textual';
|
|
16
18
|
};
|
|
17
19
|
readonly 'mongo/double@1': {
|
|
18
20
|
readonly input: number;
|
|
19
21
|
readonly output: number;
|
|
22
|
+
readonly traits: 'equality' | 'order' | 'numeric';
|
|
20
23
|
};
|
|
21
24
|
readonly 'mongo/int32@1': {
|
|
22
25
|
readonly input: number;
|
|
23
26
|
readonly output: number;
|
|
27
|
+
readonly traits: 'equality' | 'order' | 'numeric';
|
|
24
28
|
};
|
|
25
29
|
readonly 'mongo/bool@1': {
|
|
26
30
|
readonly input: boolean;
|
|
27
31
|
readonly output: boolean;
|
|
32
|
+
readonly traits: 'equality' | 'boolean';
|
|
28
33
|
};
|
|
29
34
|
readonly 'mongo/date@1': {
|
|
30
35
|
readonly input: Date;
|
|
31
36
|
readonly output: Date;
|
|
37
|
+
readonly traits: 'equality' | 'order';
|
|
32
38
|
};
|
|
33
39
|
readonly 'mongo/vector@1': {
|
|
34
40
|
readonly input: readonly number[];
|
|
35
41
|
readonly output: readonly number[];
|
|
42
|
+
readonly traits: 'equality';
|
|
36
43
|
};
|
|
37
44
|
readonly 'mongo/int64@1': {
|
|
38
45
|
readonly input: bigint;
|
|
39
46
|
readonly output: bigint;
|
|
47
|
+
readonly traits: 'equality' | 'order' | 'numeric';
|
|
40
48
|
};
|
|
41
49
|
readonly 'mongo/decimal128@1': {
|
|
42
50
|
readonly input: string;
|
|
43
51
|
readonly output: string;
|
|
52
|
+
readonly traits: 'equality' | 'order' | 'numeric';
|
|
44
53
|
};
|
|
45
54
|
readonly 'mongo/binary@1': {
|
|
46
55
|
readonly input: Uint8Array;
|
|
47
56
|
readonly output: Uint8Array;
|
|
57
|
+
readonly traits: 'equality';
|
|
48
58
|
};
|
|
49
59
|
readonly 'mongo/json@1': {
|
|
50
60
|
readonly input: JsonValue;
|
|
51
61
|
readonly output: JsonValue;
|
|
62
|
+
readonly traits: never;
|
|
52
63
|
};
|
|
53
64
|
readonly 'mongo/bson@1': {
|
|
54
65
|
readonly input: BsonInputValue;
|
|
55
66
|
readonly output: BsonValue;
|
|
67
|
+
readonly traits: never;
|
|
56
68
|
};
|
|
57
69
|
};
|
|
58
70
|
//#endregion
|
|
59
71
|
export { Vector as a, CodecTypes as i, BsonScalar as n, BsonValue$1 as r, BsonInputValue$1 as t };
|
|
60
|
-
//# sourceMappingURL=codec-types-
|
|
72
|
+
//# sourceMappingURL=codec-types-CxbyKvKL.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codec-types-CxbyKvKL.d.mts","names":[],"sources":["../../../../3-mongo-target/1-mongo-target/dist/codec-types.d.mts"],"mappings":";;;;KAGK,OAAO;WACD,iBAAiB;;KAEvB;WACM;aACE;aACA;aACA;;WAEF;aACE;aACA;aACA;;WAEF;aACE;aACA;aACA;;WAEF;aACE;aACA;aACA;;WAEF;aACE;aACA;aACA;;WAEF;aACE,OAAO;aACP,QAAQ;aACR;;WAEF;aACE;aACA;aACA;;WAEF;aACE;aACA;aACA;;WAEF;aACE;aACA;aACA;;WAEF;aACE,OAAO;aACP,QAAQ;aACR;;WAEF;aACE,OAAO;aACP,QAAQ;aACR;;WAEF;aACE,OAAO;aACP,QAAQ;aACR"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CodecDescriptor } from "@prisma/orm-framework/components/codec";
|
|
2
2
|
import { MongoCodec, MongoCodecRegistry } from "@prisma/orm-family-mongo/codec";
|
|
3
|
-
import { Binary, Decimal128, Long, ObjectId } from "bson";
|
|
3
|
+
import { Binary, Decimal128, Double, Long, ObjectId } from "bson";
|
|
4
4
|
import { BsonInputValue, BsonValue } from "@prisma/orm-family-mongo/value";
|
|
5
5
|
import { JsonValue } from "@prisma/orm-framework/contract/types";
|
|
6
6
|
//#region ../../../3-mongo-target/1-mongo-target/dist/codecs.d.mts
|
|
@@ -10,7 +10,7 @@ import { JsonValue } from "@prisma/orm-framework/contract/types";
|
|
|
10
10
|
*
|
|
11
11
|
* Single source of truth for both control- and runtime-plane adapter descriptors. Don't duplicate this list — import it.
|
|
12
12
|
*/
|
|
13
|
-
declare const mongoStandardCodecs: readonly [MongoCodec<"mongo/objectId@1", readonly [], ObjectId, string, string>, MongoCodec<"mongo/string@1", readonly [], string, string, string>, MongoCodec<"mongo/double@1", readonly [], number, number, number>, MongoCodec<"mongo/int32@1", readonly [], number, number, number>, MongoCodec<"mongo/bool@1", readonly [], boolean, boolean, boolean>, MongoCodec<"mongo/date@1", readonly [], Date, Date, Date>, MongoCodec<"mongo/vector@1", readonly [], readonly number[], readonly number[], readonly number[]>, MongoCodec<"mongo/int64@1", readonly [], number | bigint | Long, bigint, bigint>, MongoCodec<"mongo/decimal128@1", readonly [], Decimal128, string, string>, MongoCodec<"mongo/binary@1", readonly [], Binary
|
|
13
|
+
declare const mongoStandardCodecs: readonly [MongoCodec<"mongo/objectId@1", readonly [], ObjectId, string, string>, MongoCodec<"mongo/string@1", readonly [], string, string, string>, MongoCodec<"mongo/double@1", readonly [], number | Double, number, number>, MongoCodec<"mongo/int32@1", readonly [], number, number, number>, MongoCodec<"mongo/bool@1", readonly [], boolean, boolean, boolean>, MongoCodec<"mongo/date@1", readonly [], Date, Date, Date>, MongoCodec<"mongo/vector@1", readonly [], readonly number[], readonly number[], readonly number[]>, MongoCodec<"mongo/int64@1", readonly [], number | bigint | Long, bigint, bigint>, MongoCodec<"mongo/decimal128@1", readonly [], Decimal128, string, string>, MongoCodec<"mongo/binary@1", readonly [], Binary | Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>, MongoCodec<"mongo/json@1", readonly [], string | number | boolean | {
|
|
14
14
|
readonly [key: string]: JsonValue;
|
|
15
15
|
} | readonly JsonValue[] | null, string | number | boolean | {
|
|
16
16
|
readonly [key: string]: JsonValue;
|
|
@@ -33,4 +33,4 @@ declare function mongoDescriptorById(codecId: string): CodecDescriptor | undefin
|
|
|
33
33
|
declare function buildStandardCodecRegistry(): MongoCodecRegistry;
|
|
34
34
|
//#endregion
|
|
35
35
|
export { mongoStandardCodecs as i, mongoCodecDescriptors as n, mongoDescriptorById as r, buildStandardCodecRegistry as t };
|
|
36
|
-
//# sourceMappingURL=codecs-
|
|
36
|
+
//# sourceMappingURL=codecs-8iNuBwPO.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codecs-8iNuBwPO.d.mts","names":[],"sources":["../../../../3-mongo-target/1-mongo-target/dist/codecs.d.mts"],"mappings":";;;;;;;;;;;;cAWc,+BAA+B,4CAA4C,2BAA2B,mEAAmE,mDAAmD,yBAAyB,kEAAkE,oEAAoE,wCAAwC,MAAM,MAAM,OAAO,oGAAoG,2DAA2D,uBAAuB,8CAA8C,6BAA6B,0CAA0C,SAAS,WAAW,kBAAkB,WAAW,kBAAkB,WAAW,mBAAmB;YACp0B,cAAc;aACb;YACD,cAAc;aACb;YACD,cAAc;aACb,qBAAqB,wCAAwC,gBAAgB,gBAAgB;;;;cAI5F,uBAAuB,cAAc;;;;iBAIlC,oBAAoB,kBAAkB;;;;;;iBAMtC,8BAA8B"}
|
|
@@ -6,7 +6,7 @@ import { blindCast } from "@prisma/orm-framework/utils/casts";
|
|
|
6
6
|
import { ifDefined } from "@prisma/orm-framework/utils/defined";
|
|
7
7
|
import { Binary, Code, Decimal128, Double, EJSON, Long, MinKey, ObjectId } from "bson";
|
|
8
8
|
import { structuredError } from "@prisma/orm-framework/utils/structured-error";
|
|
9
|
-
//#region ../../../3-mongo-target/1-mongo-target/dist/codecs-
|
|
9
|
+
//#region ../../../3-mongo-target/1-mongo-target/dist/codecs-CUY6H3CA.mjs
|
|
10
10
|
function where(path) {
|
|
11
11
|
return path === "" ? "the root" : path;
|
|
12
12
|
}
|
|
@@ -20,6 +20,13 @@ function isPlainObject(value) {
|
|
|
20
20
|
function isPlainArray(value) {
|
|
21
21
|
return Array.isArray(value) && Object.getPrototypeOf(value) === Array.prototype;
|
|
22
22
|
}
|
|
23
|
+
const BSON_VERSION = Symbol.for("@@mdb.bson.version");
|
|
24
|
+
/** The major version of the `bson` this package loads, which every `bson` class instance it can serialise carries. */
|
|
25
|
+
const BSON_MAJOR = Reflect.get(new MinKey(), BSON_VERSION);
|
|
26
|
+
/** Whether a `bson` class instance comes from the same major version of `bson`, rather than being a look-alike or from another version. */
|
|
27
|
+
function createdByBsonMajor(value) {
|
|
28
|
+
return Reflect.get(value, BSON_VERSION) === BSON_MAJOR;
|
|
29
|
+
}
|
|
23
30
|
function bsonTypeTag(value) {
|
|
24
31
|
const tag = Reflect.get(value, "_bsontype");
|
|
25
32
|
return typeof tag === "string" ? tag : void 0;
|
|
@@ -61,10 +68,10 @@ const BSON_VALUE_TAGS = /* @__PURE__ */ new Set([
|
|
|
61
68
|
"MaxKey",
|
|
62
69
|
"BSONSymbol"
|
|
63
70
|
]);
|
|
64
|
-
const
|
|
65
|
-
const BSON_MAJOR = Reflect.get(new MinKey(), BSON_VERSION);
|
|
71
|
+
const ENCODE_FIX_BY_RECEIVED$1 = { DBRef: "Write it as a { $ref, $id } document instead." };
|
|
66
72
|
function encodeRefused$1(received, path) {
|
|
67
|
-
|
|
73
|
+
const fix = ENCODE_FIX_BY_RECEIVED$1[received];
|
|
74
|
+
throw mongoTargetError("RUNTIME.ENCODE_FAILED", `${MONGO_BSON_CODEC_ID} value must be a BSON value; received ${received} at ${where(path)}${fix === void 0 ? "" : `. ${fix}`}`, { meta: {
|
|
68
75
|
codecId: MONGO_BSON_CODEC_ID,
|
|
69
76
|
received,
|
|
70
77
|
valuePath: path
|
|
@@ -79,7 +86,7 @@ function assertBsonValue(value, path, ancestors) {
|
|
|
79
86
|
const tag = bsonTypeTag(value);
|
|
80
87
|
if (tag !== void 0) {
|
|
81
88
|
if (!BSON_VALUE_TAGS.has(tag)) encodeRefused$1(tag, path);
|
|
82
|
-
if (
|
|
89
|
+
if (!createdByBsonMajor(value)) encodeRefused$1(`${tag} not created by bson ${String(BSON_MAJOR)}`, path);
|
|
83
90
|
return;
|
|
84
91
|
}
|
|
85
92
|
if (value instanceof Date || value instanceof RegExp || value instanceof Uint8Array) return;
|
|
@@ -141,10 +148,10 @@ function decodeValue$1(value) {
|
|
|
141
148
|
function decodeBsonValue(wire) {
|
|
142
149
|
return blindCast(decodeValue$1(wire));
|
|
143
150
|
}
|
|
144
|
-
const INT32_MIN = -(2 ** 31);
|
|
145
|
-
const INT32_MAX = 2 ** 31 - 1;
|
|
151
|
+
const INT32_MIN$1 = -(2 ** 31);
|
|
152
|
+
const INT32_MAX$1 = 2 ** 31 - 1;
|
|
146
153
|
function asDriverWrites(value) {
|
|
147
|
-
if (typeof value === "number") return Number.isInteger(value) && (value < INT32_MIN || value > INT32_MAX) ? new Double(value) : value;
|
|
154
|
+
if (typeof value === "number") return Number.isInteger(value) && (value < INT32_MIN$1 || value > INT32_MAX$1) ? new Double(value) : value;
|
|
148
155
|
if (typeof value !== "object" || value === null) return value;
|
|
149
156
|
if (value instanceof Uint8Array) return new Binary(value);
|
|
150
157
|
if (Array.isArray(value)) return value.map(asDriverWrites);
|
|
@@ -194,6 +201,71 @@ function encodeFailed(codecId, message, received) {
|
|
|
194
201
|
received: String(received).slice(0, RECEIVED_PREVIEW_LIMIT)
|
|
195
202
|
} });
|
|
196
203
|
}
|
|
204
|
+
function describeReceived(value) {
|
|
205
|
+
if (typeof value === "number" || typeof value === "bigint") return String(value);
|
|
206
|
+
if (typeof value === "string") return `string ${JSON.stringify(value.slice(0, RECEIVED_PREVIEW_LIMIT))}`;
|
|
207
|
+
if (value === null) return "null";
|
|
208
|
+
if (value instanceof Date) return Number.isNaN(value.getTime()) ? "an invalid Date" : "a Date";
|
|
209
|
+
if (Array.isArray(value)) return "an array";
|
|
210
|
+
return typeof value;
|
|
211
|
+
}
|
|
212
|
+
function refuseType(codecId, expected, value, received = describeReceived(value)) {
|
|
213
|
+
return encodeFailed(codecId, `value must be ${expected}; received ${received}`, value);
|
|
214
|
+
}
|
|
215
|
+
function stringEncode(codecId, value) {
|
|
216
|
+
if (typeof value !== "string") refuseType(codecId, "a string", value);
|
|
217
|
+
return value;
|
|
218
|
+
}
|
|
219
|
+
function booleanEncode(codecId, value) {
|
|
220
|
+
if (typeof value !== "boolean") refuseType(codecId, "a boolean", value);
|
|
221
|
+
return value;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* The driver writes an invalid `Date` as the epoch, so one is refused with any other non-`Date` value.
|
|
225
|
+
*/
|
|
226
|
+
function dateEncode(codecId, value) {
|
|
227
|
+
if (!(value instanceof Date) || Number.isNaN(value.getTime())) refuseType(codecId, "a valid Date", value);
|
|
228
|
+
return value;
|
|
229
|
+
}
|
|
230
|
+
const OBJECT_ID_HEX = /^[0-9a-f]{24}$/i;
|
|
231
|
+
function hexStringOf(value) {
|
|
232
|
+
const toHexString = Reflect.get(value, "toHexString");
|
|
233
|
+
if (typeof toHexString !== "function") return void 0;
|
|
234
|
+
const hex = Reflect.apply(toHexString, value, []);
|
|
235
|
+
return typeof hex === "string" && OBJECT_ID_HEX.test(hex) ? hex : void 0;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* `new ObjectId(...)` makes a fresh id from `null` or `undefined` and reads a number as a timestamp, so only a string, which the constructor accepts only as 24 hex digits, or an `ObjectId` is passed to it. An `ObjectId` is rebuilt from its hex string, so one from any major version of `bson` works.
|
|
239
|
+
*/
|
|
240
|
+
function objectIdEncode(codecId, value) {
|
|
241
|
+
const expected = "a 24-digit hex string or an ObjectId";
|
|
242
|
+
if (typeof value === "string") try {
|
|
243
|
+
return new ObjectId(value);
|
|
244
|
+
} catch {
|
|
245
|
+
return refuseType(codecId, expected, value);
|
|
246
|
+
}
|
|
247
|
+
if (typeof value !== "object" || value === null || !hasBsonTypeTag(value, "ObjectId")) return refuseType(codecId, expected, value);
|
|
248
|
+
const hex = hexStringOf(value);
|
|
249
|
+
if (hex === void 0) return refuseType(codecId, expected, value, "an object tagged ObjectId whose toHexString() does not return 24 hex digits");
|
|
250
|
+
return new ObjectId(hex);
|
|
251
|
+
}
|
|
252
|
+
function vectorEncode(codecId, value) {
|
|
253
|
+
if (!Array.isArray(value) || !value.every((element) => typeof element === "number")) refuseType(codecId, "an array of numbers", value);
|
|
254
|
+
return value;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Wraps the number in the driver's `Double`, because the driver writes a whole JavaScript number in the int32 range as a BSON `int`, which a `double` validator refuses.
|
|
258
|
+
*/
|
|
259
|
+
function doubleEncode(codecId, value) {
|
|
260
|
+
if (typeof value !== "number") encodeFailed(codecId, `value must be a number; received ${describeReceived(value)}`, value);
|
|
261
|
+
return new Double(value);
|
|
262
|
+
}
|
|
263
|
+
const INT32_MIN = -(2 ** 31);
|
|
264
|
+
const INT32_MAX = 2 ** 31 - 1;
|
|
265
|
+
function int32Encode(codecId, value) {
|
|
266
|
+
if (typeof value !== "number" || !Number.isInteger(value) || value < INT32_MIN || value > INT32_MAX) encodeFailed(codecId, `value must be an integer from ${INT32_MIN} to ${INT32_MAX}; received ${describeReceived(value)}`, value);
|
|
267
|
+
return value;
|
|
268
|
+
}
|
|
197
269
|
const INT64_MIN = -(2n ** 63n);
|
|
198
270
|
const INT64_MAX = 2n ** 63n - 1n;
|
|
199
271
|
/**
|
|
@@ -299,8 +371,12 @@ function binaryEncode(codecId, value) {
|
|
|
299
371
|
if (!(value instanceof Uint8Array)) encodeFailed(codecId, "value must be a Uint8Array", value);
|
|
300
372
|
return new Binary(value);
|
|
301
373
|
}
|
|
374
|
+
/**
|
|
375
|
+
* The driver reads binData as a `Binary`, or as a `Buffer` with `promoteBuffers: true`; either becomes a plain `Uint8Array` copy of the bytes.
|
|
376
|
+
*/
|
|
302
377
|
function binaryDecode(codecId, wire) {
|
|
303
|
-
if (
|
|
378
|
+
if (wire instanceof Uint8Array) return new Uint8Array(wire);
|
|
379
|
+
if (!isBinary(wire)) return decodeFailed(codecId, "wire value must be a Binary or a Uint8Array", wire);
|
|
304
380
|
return new Uint8Array(wire.value());
|
|
305
381
|
}
|
|
306
382
|
function binaryEncodeJson(value) {
|
|
@@ -310,8 +386,48 @@ function binaryDecodeJson(codecId, json) {
|
|
|
310
386
|
if (typeof json !== "string" || !BASE64_TEXT.test(json)) return decodeFailed(codecId, "JSON value must be base64 text", json);
|
|
311
387
|
return new Uint8Array(Buffer.from(json, "base64"));
|
|
312
388
|
}
|
|
389
|
+
const BSON_TYPE_BY_TAG = {
|
|
390
|
+
ObjectId: "objectId",
|
|
391
|
+
Decimal128: "decimal",
|
|
392
|
+
Binary: "binData",
|
|
393
|
+
BSONRegExp: "regex",
|
|
394
|
+
Timestamp: "timestamp",
|
|
395
|
+
BSONSymbol: "symbol",
|
|
396
|
+
Code: "javascript",
|
|
397
|
+
MinKey: "minKey",
|
|
398
|
+
MaxKey: "maxKey"
|
|
399
|
+
};
|
|
400
|
+
const NOT_FINITE_FIX = "JSON has no NaN or Infinity; store null or a string, or declare the field Bson.";
|
|
401
|
+
const BSON_FIX = "Declare the field Bson to store BSON values.";
|
|
402
|
+
const PLAIN_VALUE_FIX = "Convert it to a plain object or array.";
|
|
403
|
+
const ENCODE_FIX_BY_RECEIVED = {
|
|
404
|
+
Date: "Store the date as an ISO 8601 string, or declare the field Bson.",
|
|
405
|
+
bigint: "Store it as a number in the safe-integer range or as decimal text, or declare the field Int64 or Bson.",
|
|
406
|
+
NaN: NOT_FINITE_FIX,
|
|
407
|
+
Infinity: NOT_FINITE_FIX,
|
|
408
|
+
"-Infinity": NOT_FINITE_FIX,
|
|
409
|
+
undefined: "Leave the key out, or store null.",
|
|
410
|
+
Uint8Array: "Store the bytes as a base64 string, or declare the field Binary or Bson.",
|
|
411
|
+
Buffer: "Store the bytes as a base64 string, or declare the field Binary or Bson.",
|
|
412
|
+
Binary: "Store the bytes as a base64 string, or declare the field Binary or Bson.",
|
|
413
|
+
ObjectId: "Store its hex string, or declare the field ObjectId or Bson.",
|
|
414
|
+
Long: "Store a number in the safe-integer range or decimal text, or declare the field Int64 or Bson.",
|
|
415
|
+
Decimal128: "Store the decimal text, or declare the field Decimal128 or Bson.",
|
|
416
|
+
Int32: "Pass a plain number.",
|
|
417
|
+
Double: "Pass a plain number.",
|
|
418
|
+
RegExp: "Store the pattern as a string, or declare the field Bson.",
|
|
419
|
+
BSONRegExp: "Store the pattern as a string, or declare the field Bson.",
|
|
420
|
+
symbol: "Store a string instead.",
|
|
421
|
+
function: "Store data, not a function.",
|
|
422
|
+
"circular reference": "Remove the cycle; a JSON value is a tree.",
|
|
423
|
+
"sparse array hole": "Fill the hole with null.",
|
|
424
|
+
DBRef: "Write it as a { $ref, $id } document instead."
|
|
425
|
+
};
|
|
426
|
+
function encodeFix(received) {
|
|
427
|
+
return ENCODE_FIX_BY_RECEIVED[received] ?? (Object.hasOwn(BSON_TYPE_BY_TAG, received) ? BSON_FIX : PLAIN_VALUE_FIX);
|
|
428
|
+
}
|
|
313
429
|
function encodeRefused(received, path) {
|
|
314
|
-
throw mongoTargetError("RUNTIME.ENCODE_FAILED", `${MONGO_JSON_CODEC_ID} value must be a JSON value; received ${received} at ${where(path)}`, { meta: {
|
|
430
|
+
throw mongoTargetError("RUNTIME.ENCODE_FAILED", `${MONGO_JSON_CODEC_ID} value must be a JSON value; received ${received} at ${where(path)}. ${encodeFix(received)}`, { meta: {
|
|
315
431
|
codecId: MONGO_JSON_CODEC_ID,
|
|
316
432
|
received,
|
|
317
433
|
valuePath: path
|
|
@@ -347,17 +463,6 @@ function encodeJsonValue(value) {
|
|
|
347
463
|
assertJsonValue(value, "", /* @__PURE__ */ new Set());
|
|
348
464
|
return value;
|
|
349
465
|
}
|
|
350
|
-
const BSON_TYPE_BY_TAG = {
|
|
351
|
-
ObjectId: "objectId",
|
|
352
|
-
Decimal128: "decimal",
|
|
353
|
-
Binary: "binData",
|
|
354
|
-
BSONRegExp: "regex",
|
|
355
|
-
Timestamp: "timestamp",
|
|
356
|
-
BSONSymbol: "symbol",
|
|
357
|
-
Code: "javascript",
|
|
358
|
-
MinKey: "minKey",
|
|
359
|
-
MaxKey: "maxKey"
|
|
360
|
-
};
|
|
361
466
|
function decodeRefused(bsonType, path) {
|
|
362
467
|
throw mongoTargetError("RUNTIME.DECODE_FAILED", `${MONGO_JSON_CODEC_ID} wire value contains a non-JSON BSON ${bsonType} at ${where(path)}`, { meta: {
|
|
363
468
|
codecId: MONGO_JSON_CODEC_ID,
|
|
@@ -370,7 +475,13 @@ function safeLong(value, path) {
|
|
|
370
475
|
return Number.isSafeInteger(number) && BigInt(number) === value ? number : decodeRefused("long", path);
|
|
371
476
|
}
|
|
372
477
|
function finiteDouble(value, path) {
|
|
373
|
-
|
|
478
|
+
if (Number.isFinite(value)) return value;
|
|
479
|
+
const received = String(value);
|
|
480
|
+
throw mongoTargetError("RUNTIME.DECODE_FAILED", `${MONGO_JSON_CODEC_ID} wire value contains ${received} at ${where(path)}; a JSON number cannot be NaN or Infinity`, { meta: {
|
|
481
|
+
codecId: MONGO_JSON_CODEC_ID,
|
|
482
|
+
received,
|
|
483
|
+
valuePath: path
|
|
484
|
+
} });
|
|
374
485
|
}
|
|
375
486
|
function decodeEntries(entries, path) {
|
|
376
487
|
return Object.fromEntries(entries.map(([key, entry]) => [key, decodeValue(entry, child(path, key))]));
|
|
@@ -414,32 +525,32 @@ function decodeJsonValue(wire) {
|
|
|
414
525
|
const mongoObjectIdCodec = mongoCodec({
|
|
415
526
|
typeId: MONGO_OBJECTID_CODEC_ID,
|
|
416
527
|
decode: (wire) => wire.toHexString(),
|
|
417
|
-
encode: (value) =>
|
|
528
|
+
encode: (value) => objectIdEncode(MONGO_OBJECTID_CODEC_ID, value)
|
|
418
529
|
});
|
|
419
530
|
const mongoStringCodec = mongoCodec({
|
|
420
531
|
typeId: MONGO_STRING_CODEC_ID,
|
|
421
532
|
decode: (wire) => wire,
|
|
422
|
-
encode: (value) => value
|
|
533
|
+
encode: (value) => stringEncode(MONGO_STRING_CODEC_ID, value)
|
|
423
534
|
});
|
|
424
535
|
const mongoDoubleCodec = mongoCodec({
|
|
425
536
|
typeId: MONGO_DOUBLE_CODEC_ID,
|
|
426
|
-
decode: (wire) => wire,
|
|
427
|
-
encode: (value) => value
|
|
537
|
+
decode: (wire) => Number(wire),
|
|
538
|
+
encode: (value) => doubleEncode(MONGO_DOUBLE_CODEC_ID, value)
|
|
428
539
|
});
|
|
429
540
|
const mongoInt32Codec = mongoCodec({
|
|
430
541
|
typeId: MONGO_INT32_CODEC_ID,
|
|
431
542
|
decode: (wire) => wire,
|
|
432
|
-
encode: (value) => value
|
|
543
|
+
encode: (value) => int32Encode(MONGO_INT32_CODEC_ID, value)
|
|
433
544
|
});
|
|
434
545
|
const mongoBooleanCodec = mongoCodec({
|
|
435
546
|
typeId: MONGO_BOOLEAN_CODEC_ID,
|
|
436
547
|
decode: (wire) => wire,
|
|
437
|
-
encode: (value) => value
|
|
548
|
+
encode: (value) => booleanEncode(MONGO_BOOLEAN_CODEC_ID, value)
|
|
438
549
|
});
|
|
439
550
|
const mongoDateCodec = mongoCodec({
|
|
440
551
|
typeId: MONGO_DATE_CODEC_ID,
|
|
441
552
|
decode: (wire) => wire,
|
|
442
|
-
encode: (value) => value,
|
|
553
|
+
encode: (value) => dateEncode(MONGO_DATE_CODEC_ID, value),
|
|
443
554
|
encodeJson: (value) => value.toISOString(),
|
|
444
555
|
decodeJson: (json) => {
|
|
445
556
|
if (typeof json !== "string") throw mongoTargetError("RUNTIME.DECODE_FAILED", "expected ISO date string", { meta: {
|
|
@@ -452,7 +563,7 @@ const mongoDateCodec = mongoCodec({
|
|
|
452
563
|
const mongoVectorCodec = mongoCodec({
|
|
453
564
|
typeId: MONGO_VECTOR_CODEC_ID,
|
|
454
565
|
decode: (wire) => wire,
|
|
455
|
-
encode: (value) => value
|
|
566
|
+
encode: (value) => vectorEncode(MONGO_VECTOR_CODEC_ID, value)
|
|
456
567
|
});
|
|
457
568
|
/**
|
|
458
569
|
* A BSON `long`. The application value is a `bigint`, because a `number` cannot hold the full 64-bit range; its JSON form is decimal text.
|
|
@@ -669,4 +780,4 @@ function buildStandardCodecRegistry() {
|
|
|
669
780
|
//#endregion
|
|
670
781
|
export { mongoTargetError as a, mongoStandardCodecs as i, mongoCodecDescriptors as n, mongoDescriptorById as r, buildStandardCodecRegistry as t };
|
|
671
782
|
|
|
672
|
-
//# sourceMappingURL=codecs-
|
|
783
|
+
//# sourceMappingURL=codecs-CUY6H3CA-BuXwvtSA.mjs.map
|