@prisma/orm-target-mongo 8.0.0-rc.2-dev.3 → 8.0.0-rc.20

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 (122) hide show
  1. package/README.md +1 -5
  2. package/dist/adapter.d.mts +2 -2
  3. package/dist/adapter.d.mts.map +1 -1
  4. package/dist/adapter.mjs +3 -3
  5. package/dist/adapter.mjs.map +1 -1
  6. package/dist/adapter__control.d.mts +204 -3
  7. package/dist/adapter__control.d.mts.map +1 -0
  8. package/dist/adapter__control.mjs +481 -3
  9. package/dist/adapter__control.mjs.map +1 -0
  10. package/dist/adapter__runtime.d.mts +3 -1
  11. package/dist/adapter__runtime.d.mts.map +1 -1
  12. package/dist/adapter__runtime.mjs +5 -3
  13. package/dist/adapter__runtime.mjs.map +1 -1
  14. package/dist/codec-ids-BKQbXhZt.d.mts +18 -0
  15. package/dist/codec-ids-BKQbXhZt.d.mts.map +1 -0
  16. package/dist/codec-ids-WdrumsYA-CZVjuKW8.mjs +18 -0
  17. package/dist/codec-ids-WdrumsYA-CZVjuKW8.mjs.map +1 -0
  18. package/dist/codec-types-oKxM85p-.d.mts +89 -0
  19. package/dist/codec-types-oKxM85p-.d.mts.map +1 -0
  20. package/dist/codecs-B1ab7vfj-QL33tkm2.mjs +392 -0
  21. package/dist/codecs-B1ab7vfj-QL33tkm2.mjs.map +1 -0
  22. package/dist/codecs-Y5GYsLPj.d.mts +36 -0
  23. package/dist/codecs-Y5GYsLPj.d.mts.map +1 -0
  24. package/dist/control-Cq6qWohQ.mjs +2421 -0
  25. package/dist/control-Cq6qWohQ.mjs.map +1 -0
  26. package/dist/{control-CxXmTy_h.d.mts → control-CrFS8bqh.d.mts} +133 -95
  27. package/dist/control-CrFS8bqh.d.mts.map +1 -0
  28. package/dist/data-types-LShlnAUM.d.mts +25 -0
  29. package/dist/data-types-LShlnAUM.d.mts.map +1 -0
  30. package/dist/data-types-hoKLBrYZ-h9cAgbOy.mjs +624 -0
  31. package/dist/data-types-hoKLBrYZ-h9cAgbOy.mjs.map +1 -0
  32. package/dist/descriptor-meta-DTj807jv-CjvK2XDD.mjs +146 -0
  33. package/dist/descriptor-meta-DTj807jv-CjvK2XDD.mjs.map +1 -0
  34. package/dist/descriptor-meta-runtime-BaRbjvD7-D0786_Lv.mjs +20 -0
  35. package/dist/descriptor-meta-runtime-BaRbjvD7-D0786_Lv.mjs.map +1 -0
  36. package/dist/driver.d.mts +1 -1
  37. package/dist/driver.mjs +1 -1
  38. package/dist/driver__control.d.mts +4 -3
  39. package/dist/driver__control.d.mts.map +1 -1
  40. package/dist/driver__control.mjs +5 -2
  41. package/dist/driver__control.mjs.map +1 -1
  42. package/dist/{migration-BkqcE2Uv.d.mts → migration-C4m4Uj8E.d.mts} +15 -7
  43. package/dist/migration-C4m4Uj8E.d.mts.map +1 -0
  44. package/dist/migration-factories-BqROEHRs-CfExMr9r.mjs +406 -0
  45. package/dist/migration-factories-BqROEHRs-CfExMr9r.mjs.map +1 -0
  46. package/dist/{mongo-adapter-B2HEyX0b-CQt2HH_o.mjs → mongo-adapter-Bo6ciURK-DIMJdC7y.mjs} +37 -18
  47. package/dist/mongo-adapter-Bo6ciURK-DIMJdC7y.mjs.map +1 -0
  48. package/dist/{mongo-adapter-CjJU3S9o-BIJruFYW.d.mts → mongo-adapter-wvK2fQOZ-FswLS-PJ.d.mts} +2 -2
  49. package/dist/mongo-adapter-wvK2fQOZ-FswLS-PJ.d.mts.map +1 -0
  50. package/dist/{mongo-driver-D1lEf5Kl-KPfGUVXK.d.mts → mongo-driver-CTyvKDUg-Bm9sBrfs.d.mts} +9 -4
  51. package/dist/mongo-driver-CTyvKDUg-Bm9sBrfs.d.mts.map +1 -0
  52. package/dist/{mongo-driver-Dk7mris6-CMTaUgPD.mjs → mongo-driver-Cu6FP6OU-DhOzFM2D.mjs} +34 -8
  53. package/dist/mongo-driver-Cu6FP6OU-DhOzFM2D.mjs.map +1 -0
  54. package/dist/mongo-target-errors-Btf3ML1w-QOtEG7EX.mjs +9 -0
  55. package/dist/mongo-target-errors-Btf3ML1w-QOtEG7EX.mjs.map +1 -0
  56. package/dist/{op-factory-call-B7EKa4Ri-B2Lb6W68.d.mts → op-factory-call-BoYr7vvM-CjA8nx36.d.mts} +43 -9
  57. package/dist/op-factory-call-BoYr7vvM-CjA8nx36.d.mts.map +1 -0
  58. package/dist/pack-CIfujQmd.d.mts +266 -0
  59. package/dist/pack-CIfujQmd.d.mts.map +1 -0
  60. package/dist/prisma6-binding-DhnqslLT.d.mts +54 -0
  61. package/dist/prisma6-binding-DhnqslLT.d.mts.map +1 -0
  62. package/dist/prisma6-binding-vt4tbT-Z.mjs +45 -0
  63. package/dist/prisma6-binding-vt4tbT-Z.mjs.map +1 -0
  64. package/dist/{runtime-B9_-kjBX.d.mts → runtime-DbFgyDql.d.mts} +2 -2
  65. package/dist/runtime-DbFgyDql.d.mts.map +1 -0
  66. package/dist/target.d.mts +11 -8
  67. package/dist/target.mjs +7 -3
  68. package/dist/target__codec-ids.d.mts +2 -0
  69. package/dist/target__codec-ids.mjs +2 -0
  70. package/dist/target__codec-types.d.mts +2 -2
  71. package/dist/target__codecs.d.mts +2 -0
  72. package/dist/target__codecs.mjs +2 -0
  73. package/dist/target__control.d.mts +3 -4
  74. package/dist/target__control.mjs +2 -2
  75. package/dist/target__data-types.d.mts +2 -0
  76. package/dist/target__data-types.mjs +2 -0
  77. package/dist/target__migration.d.mts +2 -2
  78. package/dist/target__migration.mjs +2 -2
  79. package/dist/target__pack.d.mts +3 -2
  80. package/dist/target__pack.mjs +2 -2
  81. package/dist/target__pack.mjs.map +1 -1
  82. package/dist/target__prisma6-binding.d.mts +2 -0
  83. package/dist/target__prisma6-binding.mjs +2 -0
  84. package/dist/target__runtime.d.mts +1 -1
  85. package/dist/target__runtime.mjs +3 -3
  86. package/dist/target__runtime.mjs.map +1 -1
  87. package/package.json +16 -15
  88. package/dist/adapter__codec-ids.d.mts +0 -12
  89. package/dist/adapter__codec-ids.d.mts.map +0 -1
  90. package/dist/adapter__codec-ids.mjs +0 -2
  91. package/dist/adapter__codec-types.d.mts +0 -38
  92. package/dist/adapter__codec-types.d.mts.map +0 -1
  93. package/dist/adapter__codec-types.mjs +0 -1
  94. package/dist/adapter__codecs.d.mts +0 -14
  95. package/dist/adapter__codecs.d.mts.map +0 -1
  96. package/dist/adapter__codecs.mjs +0 -2
  97. package/dist/codec-ids-BennPcpQ-Btzz3ILV.mjs +0 -12
  98. package/dist/codec-ids-BennPcpQ-Btzz3ILV.mjs.map +0 -1
  99. package/dist/codec-types-Bx2fHyq_.d.mts +0 -35
  100. package/dist/codec-types-Bx2fHyq_.d.mts.map +0 -1
  101. package/dist/codecs-DLWO-Cjc-CWfQj0bY.mjs +0 -170
  102. package/dist/codecs-DLWO-Cjc-CWfQj0bY.mjs.map +0 -1
  103. package/dist/control-CxXmTy_h.d.mts.map +0 -1
  104. package/dist/control-D2-m_BQJ.mjs +0 -1563
  105. package/dist/control-D2-m_BQJ.mjs.map +0 -1
  106. package/dist/control-DQD76x-1.mjs +0 -437
  107. package/dist/control-DQD76x-1.mjs.map +0 -1
  108. package/dist/control-rPM2HNxW.d.mts +0 -170
  109. package/dist/control-rPM2HNxW.d.mts.map +0 -1
  110. package/dist/descriptor-meta-CBiaTwe5-HX742pZh.mjs +0 -17
  111. package/dist/descriptor-meta-CBiaTwe5-HX742pZh.mjs.map +0 -1
  112. package/dist/migration-BkqcE2Uv.d.mts.map +0 -1
  113. package/dist/migration-factories-CCJFG_3e-75oJ8xn2.mjs +0 -201
  114. package/dist/migration-factories-CCJFG_3e-75oJ8xn2.mjs.map +0 -1
  115. package/dist/mongo-adapter-B2HEyX0b-CQt2HH_o.mjs.map +0 -1
  116. package/dist/mongo-adapter-CjJU3S9o-BIJruFYW.d.mts.map +0 -1
  117. package/dist/mongo-driver-D1lEf5Kl-KPfGUVXK.d.mts.map +0 -1
  118. package/dist/mongo-driver-Dk7mris6-CMTaUgPD.mjs.map +0 -1
  119. package/dist/op-factory-call-B7EKa4Ri-B2Lb6W68.d.mts.map +0 -1
  120. package/dist/pack-MK8ZQfrL.d.mts +0 -22
  121. package/dist/pack-MK8ZQfrL.d.mts.map +0 -1
  122. package/dist/runtime-B9_-kjBX.d.mts.map +0 -1
@@ -1,3 +1,481 @@
1
- import { t as createMongoAdapter } from "./mongo-adapter-B2HEyX0b-CQt2HH_o.mjs";
2
- import { a as introspectSchema, c as mongoScalarAuthoringTypes, i as extractDb, n as MongoInspectionExecutor, o as isMongoControlDriver, r as createMongoRunnerDeps, s as mongoAdapterDescriptor, t as MongoControlAdapterImpl } from "./control-DQD76x-1.mjs";
3
- export { MongoControlAdapterImpl, MongoInspectionExecutor, createMongoAdapter, createMongoRunnerDeps, mongoAdapterDescriptor as default, mongoAdapterDescriptor, extractDb, introspectSchema, isMongoControlDriver, mongoScalarAuthoringTypes };
1
+ import { a as MONGO_DECIMAL128_CODEC_ID, c as MONGO_INT64_CODEC_ID, d as MONGO_OBJECTID_CODEC_ID, f as MONGO_STRING_CODEC_ID, i as MONGO_DATE_CODEC_ID, l as MONGO_INT64_NUMBER_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_JSON_CODEC_ID } from "./codec-ids-WdrumsYA-CZVjuKW8.mjs";
2
+ import { t as createMongoAdapter } from "./mongo-adapter-Bo6ciURK-DIMJdC7y.mjs";
3
+ import { structuredError } from "@prisma/orm-framework/utils/structured-error";
4
+ import { type } from "arktype";
5
+ import { blindCast } from "@prisma/orm-framework/utils/casts";
6
+ import { MongoSchemaCollection, MongoSchemaCollectionOptions, MongoSchemaIR, MongoSchemaIndex, MongoSchemaValidator } from "@prisma/orm-family-mongo/schema-ir";
7
+ import { MongoAggFieldRef, MongoAggLiteral, MongoAggOperator } from "@prisma/orm-family-mongo/query-ast/execution";
8
+ import { expr, fn } from "@prisma/orm-family-mongo/query-builder";
9
+ import { collection } from "@prisma/orm-family-mongo/query-builder/contract-free";
10
+ import { APP_SPACE_ID } from "@prisma/orm-framework/components/control";
11
+ import { MongoServerError } from "mongodb";
12
+ import { parseMarkerRowSafely, withMarkerReadErrorHandling } from "@prisma/orm-framework/errors/execution";
13
+ import { ledgerOriginFromStored } from "@prisma/orm-toolchain/migration-tools/ledger-origin";
14
+ //#region ../../../3-targets/mongo/2-adapter/dist/control.mjs
15
+ const PRISMA_MIGRATIONS_COLLECTION = "_prisma_migrations";
16
+ function parseIndexKeys(keySpec) {
17
+ const keys = [];
18
+ for (const [field, direction] of Object.entries(keySpec)) keys.push({
19
+ field,
20
+ direction
21
+ });
22
+ return keys;
23
+ }
24
+ /**
25
+ * Exported for unit tests to exercise the defensive `!key` guard; not part of
26
+ * the public API. Callers in this package use it via the `introspectSchema`
27
+ * pipeline only.
28
+ */
29
+ function isDefaultIdIndex(doc) {
30
+ const key = doc["key"];
31
+ if (!key) return false;
32
+ const entries = Object.entries(key);
33
+ return entries.length === 1 && entries[0]?.[0] === "_id" && entries[0]?.[1] === 1;
34
+ }
35
+ function parseIndex(doc) {
36
+ const keySpec = doc["key"];
37
+ return new MongoSchemaIndex({
38
+ keys: parseIndexKeys(keySpec),
39
+ unique: doc["unique"],
40
+ sparse: doc["sparse"],
41
+ expireAfterSeconds: doc["expireAfterSeconds"],
42
+ partialFilterExpression: doc["partialFilterExpression"],
43
+ wildcardProjection: doc["wildcardProjection"],
44
+ collation: doc["collation"] ? blindCast(doc["collation"]) : void 0,
45
+ weights: doc["weights"],
46
+ default_language: doc["default_language"],
47
+ language_override: doc["language_override"]
48
+ });
49
+ }
50
+ function parseValidator(options) {
51
+ const validator = options["validator"];
52
+ if (!validator) return void 0;
53
+ const jsonSchema = validator["$jsonSchema"];
54
+ if (!jsonSchema) return void 0;
55
+ return new MongoSchemaValidator({
56
+ jsonSchema,
57
+ validationLevel: options["validationLevel"] ?? "strict",
58
+ validationAction: options["validationAction"] ?? "error"
59
+ });
60
+ }
61
+ function parseCollectionOptions(info) {
62
+ const options = info["options"];
63
+ if (!options) return void 0;
64
+ const capped = options["capped"];
65
+ const size = options["size"];
66
+ const max = options["max"];
67
+ const timeseries = options["timeseries"];
68
+ const collation = options["collation"] ? blindCast(options["collation"]) : void 0;
69
+ const changeStreamPreAndPostImages = options["changeStreamPreAndPostImages"];
70
+ const clusteredIndex = options["clusteredIndex"];
71
+ if (!(capped || timeseries || collation || changeStreamPreAndPostImages || clusteredIndex)) return void 0;
72
+ return new MongoSchemaCollectionOptions({
73
+ ...capped ? { capped: {
74
+ size: size ?? 0,
75
+ ...max != null ? { max } : {}
76
+ } } : {},
77
+ ...timeseries ? { timeseries } : {},
78
+ ...collation ? { collation } : {},
79
+ ...changeStreamPreAndPostImages ? { changeStreamPreAndPostImages } : {},
80
+ ...clusteredIndex ? { clusteredIndex } : {}
81
+ });
82
+ }
83
+ async function introspectSchema(db) {
84
+ const collectionInfos = await db.listCollections().toArray();
85
+ const collections = [];
86
+ for (const info of collectionInfos) {
87
+ const name = info["name"];
88
+ const type = info["type"];
89
+ if (name === PRISMA_MIGRATIONS_COLLECTION) continue;
90
+ if (name.startsWith("system.")) continue;
91
+ if (type === "view") continue;
92
+ const indexes = (await db.collection(name).listIndexes().toArray()).filter((doc) => !isDefaultIdIndex(doc)).map(parseIndex);
93
+ const validator = parseValidator("options" in info ? info["options"] : {});
94
+ const options = parseCollectionOptions(info);
95
+ collections.push(new MongoSchemaCollection({
96
+ name,
97
+ indexes,
98
+ ...validator ? { validator } : {},
99
+ ...options ? { options } : {}
100
+ }));
101
+ }
102
+ return new MongoSchemaIR(collections);
103
+ }
104
+ /**
105
+ * Executes the read-only catalog inspections (`listCollections` / `listIndexes`)
106
+ * that migration prechecks/postchecks and operation preview evaluate, directly
107
+ * against `db`. Routing these checks through the adapter's lowering seam is
108
+ * deferred to the `typed-migration-verification-queries` slice.
109
+ */
110
+ var MongoInspectionExecutor = class {
111
+ db;
112
+ constructor(db) {
113
+ this.db = db;
114
+ }
115
+ async listIndexes(cmd) {
116
+ try {
117
+ return await this.db.collection(cmd.collection).listIndexes().toArray();
118
+ } catch (error) {
119
+ if (error instanceof MongoServerError && error.code === 26) return [];
120
+ throw error;
121
+ }
122
+ }
123
+ async listCollections(_cmd) {
124
+ return this.db.listCollections().toArray();
125
+ }
126
+ };
127
+ function mongoAdapterError(code, message, options) {
128
+ return structuredError(code, message, options);
129
+ }
130
+ function describeReceivedValue(value) {
131
+ if (value === null) return "null";
132
+ if (typeof value !== "object") return typeof value;
133
+ return `object with keys [${Object.keys(value).join(", ")}]`;
134
+ }
135
+ const COLLECTION = "_prisma_migrations";
136
+ const MONGO_MARKER_COLLECTION = `_prisma_migrations marker documents in ${COLLECTION}`;
137
+ const MONGO_LEDGER_COLLECTION = `_prisma_migrations ledger documents in ${COLLECTION}`;
138
+ const MongoMarkerDocSchema = type({
139
+ space: "string",
140
+ storageHash: "string",
141
+ profileHash: "string",
142
+ "contractJson?": "unknown | null",
143
+ "canonicalVersion?": "number | null",
144
+ "updatedAt?": "Date",
145
+ "appTag?": "string | null",
146
+ "meta?": type({ "[string]": "unknown" }).or("null"),
147
+ "invariants?": type("string").array(),
148
+ "+": "delete"
149
+ });
150
+ function parseMongoMarkerDoc(doc) {
151
+ const result = MongoMarkerDocSchema(doc);
152
+ if (result instanceof type.errors) throw mongoAdapterError("CONTRACT.MARKER_ROW_CORRUPT", `Invalid marker doc on ${COLLECTION}: ${result.summary}`, { meta: {
153
+ collection: COLLECTION,
154
+ detail: result.summary
155
+ } });
156
+ return {
157
+ storageHash: result.storageHash,
158
+ profileHash: result.profileHash,
159
+ contractJson: result.contractJson ?? null,
160
+ canonicalVersion: result.canonicalVersion ?? null,
161
+ updatedAt: result.updatedAt ?? /* @__PURE__ */ new Date(),
162
+ appTag: result.appTag ?? null,
163
+ meta: result.meta ?? {},
164
+ invariants: result.invariants ?? []
165
+ };
166
+ }
167
+ function parseMongoMarkerDocSafely(doc, space) {
168
+ return parseMarkerRowSafely(doc, parseMongoMarkerDoc, {
169
+ space,
170
+ markerLocation: MONGO_MARKER_COLLECTION
171
+ });
172
+ }
173
+ const MARKER_LEDGER_COLLECTION = "_prisma_migrations";
174
+ function isMongoControlDriver(driver) {
175
+ return driver.familyId === "mongo" && driver.targetId === "mongo" && "execute" in driver && typeof driver.execute === "function";
176
+ }
177
+ function requireMongoControlDriver(driver) {
178
+ if (!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) } });
179
+ return driver;
180
+ }
181
+ function extractDb(driver) {
182
+ return requireMongoControlDriver(driver).db;
183
+ }
184
+ /**
185
+ * Mongo control adapter for control-plane operations like introspection
186
+ * and marker-ledger CAS. Implements the family-level `MongoControlAdapter`
187
+ * SPI. Every marker/ledger operation builds a canonical command inline via
188
+ * the contract-free fluent builder and dispatches it through the family
189
+ * adapter's lowering path (`createMongoAdapter().lower(plan, {})`) onto the
190
+ * Mongo wire transport (`driver.execute(wireCommand)`) — the same route SQL
191
+ * marker/ledger ops take through `adapter.lower()` → `driver.query()`.
192
+ */
193
+ var MongoControlAdapterImpl = class {
194
+ familyId = "mongo";
195
+ targetId = "mongo";
196
+ #adapter = createMongoAdapter();
197
+ #markerLedgerCollection = collection(MARKER_LEDGER_COLLECTION);
198
+ async #execute(driver, command) {
199
+ const plan = {
200
+ collection: MARKER_LEDGER_COLLECTION,
201
+ command,
202
+ meta: {
203
+ target: "mongo",
204
+ targetFamily: "mongo",
205
+ storageHash: "",
206
+ lane: "control"
207
+ }
208
+ };
209
+ const wireCommand = await this.#adapter.lower(plan, {});
210
+ if (!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) } });
211
+ const rows = [];
212
+ for await (const row of driver.execute(wireCommand)) rows.push(row);
213
+ return rows;
214
+ }
215
+ async executeDdl(driver, command) {
216
+ const wire = await this.#adapter.lower({ command }, {});
217
+ await driver.run(wire);
218
+ }
219
+ /**
220
+ * Server-side invariant-merge aggregation expression:
221
+ * `$sortArray({ input: $setUnion([$ifNull('$invariants', []), incoming]), sortBy: 1 })`.
222
+ *
223
+ * Built through the typed agg-expr layer — `fn.setUnion` plus the generic
224
+ * `MongoAggOperator` for `$ifNull` / `$sortArray` (neither has a named `fn`
225
+ * helper). Returns a `MongoAggOperator` that is passed directly to
226
+ * `f.stage.set({ invariants: ... })` in the update pipeline.
227
+ */
228
+ #invariantMergeExpr(incoming) {
229
+ const existingOrEmpty = MongoAggOperator.of("$ifNull", [MongoAggFieldRef.of("invariants"), MongoAggLiteral.of([])]);
230
+ const merged = fn.setUnion({
231
+ _field: {
232
+ codecId: "mongo/array@1",
233
+ nullable: false
234
+ },
235
+ node: existingOrEmpty
236
+ }, {
237
+ _field: {
238
+ codecId: "mongo/array@1",
239
+ nullable: false
240
+ },
241
+ node: MongoAggLiteral.of([...incoming])
242
+ });
243
+ return MongoAggOperator.of("$sortArray", {
244
+ input: merged.node,
245
+ sortBy: MongoAggLiteral.of(1)
246
+ });
247
+ }
248
+ async readMarker(driver, space) {
249
+ const doc = (await withMarkerReadErrorHandling(() => this.#execute(driver, this.#markerLedgerCollection.aggregate().match((f) => f._id.eq(space)).match((f) => f.space.eq(space)).limit(1).build()), {
250
+ space,
251
+ markerLocation: MONGO_MARKER_COLLECTION
252
+ }))[0];
253
+ if (!doc) return null;
254
+ return parseMongoMarkerDocSafely(doc, space);
255
+ }
256
+ async readAllMarkers(driver) {
257
+ const 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()), {
258
+ space: APP_SPACE_ID,
259
+ markerLocation: MONGO_MARKER_COLLECTION
260
+ });
261
+ const out = /* @__PURE__ */ new Map();
262
+ for (const doc of docs) {
263
+ const space = doc["space"];
264
+ /* 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`. */
265
+ if (typeof space !== "string") continue;
266
+ out.set(space, parseMongoMarkerDocSafely(doc, space));
267
+ }
268
+ return out;
269
+ }
270
+ async initMarker(driver, space, destination) {
271
+ const document = {
272
+ _id: space,
273
+ space,
274
+ storageHash: destination.storageHash,
275
+ profileHash: destination.profileHash,
276
+ contractJson: null,
277
+ canonicalVersion: null,
278
+ updatedAt: /* @__PURE__ */ new Date(),
279
+ appTag: null,
280
+ meta: {},
281
+ invariants: [...destination.invariants ?? []]
282
+ };
283
+ await this.#execute(driver, this.#markerLedgerCollection.insertOne(document));
284
+ }
285
+ async updateMarker(driver, space, expectedFrom, destination) {
286
+ const { invariants } = destination;
287
+ return (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 ? {
288
+ storageHash: MongoAggLiteral.of(destination.storageHash),
289
+ profileHash: MongoAggLiteral.of(destination.profileHash),
290
+ updatedAt: MongoAggLiteral.of(/* @__PURE__ */ new Date())
291
+ } : {
292
+ storageHash: MongoAggLiteral.of(destination.storageHash),
293
+ profileHash: MongoAggLiteral.of(destination.profileHash),
294
+ updatedAt: MongoAggLiteral.of(/* @__PURE__ */ new Date()),
295
+ invariants: this.#invariantMergeExpr(invariants)
296
+ })], { upsert: false }))).length > 0;
297
+ }
298
+ async writeLedgerEntry(driver, space, entry) {
299
+ const document = {
300
+ type: "ledger",
301
+ space,
302
+ edgeId: entry.edgeId,
303
+ from: entry.from,
304
+ to: entry.to,
305
+ migrationName: entry.migrationName,
306
+ migrationHash: entry.migrationHash,
307
+ operations: blindCast(entry.operations),
308
+ appliedAt: /* @__PURE__ */ new Date()
309
+ };
310
+ await this.#execute(driver, this.#markerLedgerCollection.insertOne(document));
311
+ }
312
+ async readLedger(driver, space) {
313
+ const ledgerContext = {
314
+ space: space ?? "*",
315
+ markerLocation: MONGO_LEDGER_COLLECTION
316
+ };
317
+ const chain = this.#markerLedgerCollection.aggregate().match((f) => f.type.eq("ledger"));
318
+ const command = space === void 0 ? chain.sort({ _id: 1 }).build() : chain.match((f) => f.space.eq(space)).sort({ _id: 1 }).build();
319
+ const docs = await withMarkerReadErrorHandling(() => this.#execute(driver, command), ledgerContext);
320
+ const entries = [];
321
+ for (const doc of docs) {
322
+ const migrationName = doc["migrationName"];
323
+ const migrationHash = doc["migrationHash"];
324
+ const from = doc["from"];
325
+ const to = doc["to"];
326
+ const docSpace = doc["space"];
327
+ if (typeof migrationName !== "string" || typeof migrationHash !== "string") continue;
328
+ if (typeof from !== "string" || typeof to !== "string") continue;
329
+ if (typeof docSpace !== "string") continue;
330
+ const appliedAt = doc["appliedAt"];
331
+ const appliedAtDate = appliedAt instanceof Date ? appliedAt : appliedAt !== void 0 ? new Date(String(appliedAt)) : /* @__PURE__ */ new Date();
332
+ const operations = doc["operations"];
333
+ const opList = Array.isArray(operations) ? operations : [];
334
+ entries.push({
335
+ space: docSpace,
336
+ migrationName,
337
+ migrationHash,
338
+ from: ledgerOriginFromStored(from),
339
+ to,
340
+ appliedAt: appliedAtDate,
341
+ operationCount: opList.length
342
+ });
343
+ }
344
+ return entries;
345
+ }
346
+ async introspectSchema(driver) {
347
+ return introspectSchema(extractDb(driver));
348
+ }
349
+ createRunnerDependencies(driver) {
350
+ const controlDriver = requireMongoControlDriver(driver);
351
+ return {
352
+ inspectionExecutor: new MongoInspectionExecutor(controlDriver.db),
353
+ adapter: this.#adapter,
354
+ driver: controlDriver,
355
+ executeDdl: (command) => this.executeDdl(controlDriver, command),
356
+ markerOps: {
357
+ readMarker: (space) => this.readMarker(controlDriver, space),
358
+ initMarker: (space, destination) => this.initMarker(controlDriver, space, destination),
359
+ updateMarker: (space, expectedFrom, destination) => this.updateMarker(controlDriver, space, expectedFrom, destination),
360
+ writeLedgerEntry: (space, entry) => this.writeLedgerEntry(controlDriver, space, entry)
361
+ },
362
+ introspectSchema: () => this.introspectSchema(controlDriver)
363
+ };
364
+ }
365
+ };
366
+ /**
367
+ * The base PSL scalars as zero-arg type constructors in the unified authoring channel. Each names a codec; the collection validator reads the BSON types from the data type the codec represents, not from the constructor.
368
+ */
369
+ const mongoScalarAuthoringTypes = {
370
+ String: {
371
+ kind: "typeConstructor",
372
+ documentation: "Text, stored as BSON string.",
373
+ output: { codecId: MONGO_STRING_CODEC_ID }
374
+ },
375
+ Int32: {
376
+ kind: "typeConstructor",
377
+ documentation: "A signed 32-bit integer, stored as BSON int.",
378
+ output: { codecId: MONGO_INT32_CODEC_ID }
379
+ },
380
+ Bool: {
381
+ kind: "typeConstructor",
382
+ documentation: "A true or false value, stored as BSON bool.",
383
+ output: { codecId: MONGO_BOOLEAN_CODEC_ID }
384
+ },
385
+ Date: {
386
+ kind: "typeConstructor",
387
+ documentation: "A date and time with millisecond precision, stored as BSON date.",
388
+ output: { codecId: MONGO_DATE_CODEC_ID }
389
+ },
390
+ ObjectId: {
391
+ kind: "typeConstructor",
392
+ documentation: "A 12-byte MongoDB identifier, stored as BSON objectId.",
393
+ output: { codecId: MONGO_OBJECTID_CODEC_ID }
394
+ },
395
+ Double: {
396
+ kind: "typeConstructor",
397
+ documentation: "A double-precision floating-point number, stored as BSON double.",
398
+ output: { codecId: MONGO_DOUBLE_CODEC_ID }
399
+ },
400
+ Int64: {
401
+ kind: "typeConstructor",
402
+ documentation: "A signed 64-bit integer read as a bigint, stored as BSON long.",
403
+ output: { codecId: MONGO_INT64_CODEC_ID }
404
+ },
405
+ Int64Number: {
406
+ kind: "typeConstructor",
407
+ documentation: "A signed 64-bit integer read as a JavaScript number within its safe integer range, stored as BSON long.",
408
+ output: { codecId: MONGO_INT64_NUMBER_CODEC_ID }
409
+ },
410
+ Decimal128: {
411
+ kind: "typeConstructor",
412
+ documentation: "A 128-bit decimal read as decimal text without an exponent, stored as BSON decimal.",
413
+ output: { codecId: MONGO_DECIMAL128_CODEC_ID }
414
+ },
415
+ Binary: {
416
+ kind: "typeConstructor",
417
+ documentation: "Bytes read as a Uint8Array, stored as BSON binData.",
418
+ output: { codecId: MONGO_BINARY_CODEC_ID }
419
+ },
420
+ Json: {
421
+ kind: "typeConstructor",
422
+ documentation: "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.",
423
+ output: { codecId: MONGO_JSON_CODEC_ID }
424
+ },
425
+ Bson: {
426
+ kind: "typeConstructor",
427
+ documentation: "Any BSON value, read as BsonValue; the collection validator does not constrain it.",
428
+ output: { codecId: MONGO_BSON_CODEC_ID }
429
+ },
430
+ Int: {
431
+ kind: "typeConstructor",
432
+ documentation: "Deprecated: use Int32. A signed 32-bit integer, stored as BSON int.",
433
+ output: { codecId: MONGO_INT32_CODEC_ID },
434
+ deprecated: { replacement: "Int32" }
435
+ },
436
+ Float: {
437
+ kind: "typeConstructor",
438
+ documentation: "Deprecated: use Double. A double-precision floating-point number, stored as BSON double.",
439
+ output: { codecId: MONGO_DOUBLE_CODEC_ID },
440
+ deprecated: { replacement: "Double" }
441
+ },
442
+ Boolean: {
443
+ kind: "typeConstructor",
444
+ documentation: "Deprecated: use Bool. A true or false value, stored as BSON bool.",
445
+ output: { codecId: MONGO_BOOLEAN_CODEC_ID },
446
+ deprecated: { replacement: "Bool" }
447
+ },
448
+ DateTime: {
449
+ kind: "typeConstructor",
450
+ documentation: "Deprecated: use Date. A date and time with millisecond precision, stored as BSON date.",
451
+ output: { codecId: MONGO_DATE_CODEC_ID },
452
+ deprecated: { replacement: "Date" }
453
+ }
454
+ };
455
+ const mongoAdapterDescriptor = {
456
+ kind: "adapter",
457
+ id: "mongo",
458
+ familyId: "mongo",
459
+ targetId: "mongo",
460
+ version: "0.0.1",
461
+ authoring: { type: mongoScalarAuthoringTypes },
462
+ types: { codecTypes: {
463
+ import: {
464
+ package: "@internal/target-mongo/codec-types",
465
+ named: "CodecTypes",
466
+ alias: "MongoCodecTypes"
467
+ },
468
+ parameterizedOutputTypes: {
469
+ package: "@internal/target-mongo/codec-types",
470
+ named: "ParameterizedOutputTypesForTypeParams",
471
+ alias: "MongoParameterizedOutputTypes"
472
+ }
473
+ } },
474
+ create(_stack) {
475
+ return new MongoControlAdapterImpl();
476
+ }
477
+ };
478
+ //#endregion
479
+ export { MongoControlAdapterImpl, MongoInspectionExecutor, createMongoAdapter, mongoAdapterDescriptor as default, mongoAdapterDescriptor, extractDb, introspectSchema, isMongoControlDriver, mongoScalarAuthoringTypes };
480
+
481
+ //# sourceMappingURL=adapter__control.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter__control.mjs","names":["#execute","#adapter","#markerLedgerCollection","#invariantMergeExpr"],"sources":["../../../../3-targets/mongo/2-adapter/dist/control.mjs"],"sourcesContent":["import { t as createMongoAdapter } from \"./mongo-adapter-Bo6ciURK.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_INT64_NUMBER_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 { MongoSchemaCollection, MongoSchemaCollectionOptions, MongoSchemaIR, MongoSchemaIndex, MongoSchemaValidator } from \"@internal/mongo-schema-ir\";\nimport { MongoServerError } from \"mongodb\";\nimport { parseMarkerRowSafely, withMarkerReadErrorHandling } from \"@internal/errors/execution\";\nimport { APP_SPACE_ID } from \"@internal/framework-components/control\";\nimport { ledgerOriginFromStored } from \"@internal/migration-tools/ledger-origin\";\nimport { expr, fn } from \"@internal/mongo-query-builder\";\nimport { collection } from \"@internal/mongo-query-builder/contract-free\";\nimport { type } from \"arktype\";\n//#region src/core/introspect-schema.ts\nconst PRISMA_MIGRATIONS_COLLECTION = \"_prisma_migrations\";\nfunction parseIndexKeys(keySpec) {\n\tconst keys = [];\n\tfor (const [field, direction] of Object.entries(keySpec)) keys.push({\n\t\tfield,\n\t\tdirection\n\t});\n\treturn keys;\n}\n/**\n* Exported for unit tests to exercise the defensive `!key` guard; not part of\n* the public API. Callers in this package use it via the `introspectSchema`\n* pipeline only.\n*/\nfunction isDefaultIdIndex(doc) {\n\tconst key = doc[\"key\"];\n\tif (!key) return false;\n\tconst entries = Object.entries(key);\n\treturn entries.length === 1 && entries[0]?.[0] === \"_id\" && entries[0]?.[1] === 1;\n}\nfunction parseIndex(doc) {\n\tconst keySpec = doc[\"key\"];\n\treturn new MongoSchemaIndex({\n\t\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/migrations/inspection-executor.ts\n/**\n* Executes the read-only catalog inspections (`listCollections` / `listIndexes`)\n* that migration prechecks/postchecks and operation preview evaluate, directly\n* against `db`. Routing these checks through the adapter's lowering seam is\n* deferred to the `typed-migration-verification-queries` slice.\n*/\nvar MongoInspectionExecutor = class {\n\tdb;\n\tconstructor(db) {\n\t\tthis.db = db;\n\t}\n\tasync listIndexes(cmd) {\n\t\ttry {\n\t\t\treturn await this.db.collection(cmd.collection).listIndexes().toArray();\n\t\t} catch (error) {\n\t\t\tif (error instanceof MongoServerError && error.code === 26) return [];\n\t\t\tthrow error;\n\t\t}\n\t}\n\tasync listCollections(_cmd) {\n\t\treturn this.db.listCollections().toArray();\n\t}\n};\n//#endregion\n//#region src/core/errors.ts\nfunction mongoAdapterError(code, message, options) {\n\treturn structuredError(code, message, options);\n}\nfunction describeReceivedValue(value) {\n\tif (value === null) return \"null\";\n\tif (typeof value !== \"object\") return typeof value;\n\treturn `object with keys [${Object.keys(value).join(\", \")}]`;\n}\n//#endregion\n//#region src/core/marker-ledger.ts\nconst COLLECTION = \"_prisma_migrations\";\nconst MONGO_MARKER_COLLECTION = `_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/migrations/mongo-control-driver.ts\nfunction isMongoControlDriver(driver) {\n\treturn driver.familyId === \"mongo\" && driver.targetId === \"mongo\" && \"execute\" in driver && typeof driver.execute === \"function\";\n}\nfunction requireMongoControlDriver(driver) {\n\tif (!isMongoControlDriver(driver)) throw mongoAdapterError(\"CONFIG.VALIDATION_FAILED\", \"Expected a Mongo control driver created by mongoControlDriver.create() from `@internal/driver-mongo/control`.\", { meta: { received: describeReceivedValue(driver) } });\n\treturn driver;\n}\nfunction extractDb(driver) {\n\treturn requireMongoControlDriver(driver).db;\n}\n//#endregion\n//#region src/core/migrations/mongo-control-adapter.ts\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_SPACE_ID,\n\t\t\tmarkerLocation: MONGO_MARKER_COLLECTION\n\t\t});\n\t\tconst out = /* @__PURE__ */ new Map();\n\t\tfor (const doc of docs) {\n\t\t\tconst space = doc[\"space\"];\n\t\t\t/* v8 ignore next -- @preserve type-narrowing guard: the $match stage above filters on `space: { $type: 'string' }`, so this branch is unreachable at runtime. The check exists so the `out.set(space, ...)` call below can accept `string`. */\n\t\t\tif (typeof space !== \"string\") continue;\n\t\t\tout.set(space, parseMongoMarkerDocSafely(doc, space));\n\t\t}\n\t\treturn out;\n\t}\n\tasync initMarker(driver, space, destination) {\n\t\tconst 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. Each names a codec; the collection validator reads the BSON types from the data type the codec represents, not from the constructor.\n*/\nconst mongoScalarAuthoringTypes = {\n\tString: {\n\t\tkind: \"typeConstructor\",\n\t\tdocumentation: \"Text, stored as BSON string.\",\n\t\toutput: { codecId: MONGO_STRING_CODEC_ID }\n\t},\n\tInt32: {\n\t\tkind: \"typeConstructor\",\n\t\tdocumentation: \"A signed 32-bit integer, stored as BSON int.\",\n\t\toutput: { codecId: MONGO_INT32_CODEC_ID }\n\t},\n\tBool: {\n\t\tkind: \"typeConstructor\",\n\t\tdocumentation: \"A true or false value, stored as BSON bool.\",\n\t\toutput: { codecId: MONGO_BOOLEAN_CODEC_ID }\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: { codecId: MONGO_DATE_CODEC_ID }\n\t},\n\tObjectId: {\n\t\tkind: \"typeConstructor\",\n\t\tdocumentation: \"A 12-byte MongoDB identifier, stored as BSON objectId.\",\n\t\toutput: { codecId: MONGO_OBJECTID_CODEC_ID }\n\t},\n\tDouble: {\n\t\tkind: \"typeConstructor\",\n\t\tdocumentation: \"A double-precision floating-point number, stored as BSON double.\",\n\t\toutput: { codecId: MONGO_DOUBLE_CODEC_ID }\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: { codecId: MONGO_INT64_CODEC_ID }\n\t},\n\tInt64Number: {\n\t\tkind: \"typeConstructor\",\n\t\tdocumentation: \"A signed 64-bit integer read as a JavaScript number within its safe integer range, stored as BSON long.\",\n\t\toutput: { codecId: MONGO_INT64_NUMBER_CODEC_ID }\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: { codecId: MONGO_DECIMAL128_CODEC_ID }\n\t},\n\tBinary: {\n\t\tkind: \"typeConstructor\",\n\t\tdocumentation: \"Bytes read as a Uint8Array, stored as BSON binData.\",\n\t\toutput: { codecId: MONGO_BINARY_CODEC_ID }\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: { codecId: MONGO_JSON_CODEC_ID }\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: { codecId: MONGO_BSON_CODEC_ID }\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: { codecId: MONGO_INT32_CODEC_ID },\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: { codecId: MONGO_DOUBLE_CODEC_ID },\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: { codecId: MONGO_BOOLEAN_CODEC_ID },\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: { codecId: MONGO_DATE_CODEC_ID },\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\tparameterizedOutputTypes: {\n\t\t\tpackage: \"@internal/target-mongo/codec-types\",\n\t\t\tnamed: \"ParameterizedOutputTypesForTypeParams\",\n\t\t\talias: \"MongoParameterizedOutputTypes\"\n\t\t}\n\t} },\n\tcreate(_stack) {\n\t\treturn new MongoControlAdapterImpl();\n\t}\n};\n//#endregion\nexport { MongoControlAdapterImpl, MongoInspectionExecutor, createMongoAdapter, mongoAdapterDescriptor as default, mongoAdapterDescriptor, extractDb, introspectSchema, isMongoControlDriver, mongoScalarAuthoringTypes };\n\n//# sourceMappingURL=control.mjs.map"],"mappings":";;;;;;;;;;;;;;AAcA,MAAM,+BAA+B;AACrC,SAAS,eAAe,SAAS;CAChC,MAAM,OAAO,CAAC;CACd,KAAK,MAAM,CAAC,OAAO,cAAc,OAAO,QAAQ,OAAO,GAAG,KAAK,KAAK;EACnE;EACA;CACD,CAAC;CACD,OAAO;AACR;;;;;;AAMA,SAAS,iBAAiB,KAAK;CAC9B,MAAM,MAAM,IAAI;CAChB,IAAI,CAAC,KAAK,OAAO;CACjB,MAAM,UAAU,OAAO,QAAQ,GAAG;CAClC,OAAO,QAAQ,WAAW,KAAK,QAAQ,EAAE,GAAG,OAAO,SAAS,QAAQ,EAAE,GAAG,OAAO;AACjF;AACA,SAAS,WAAW,KAAK;CACxB,MAAM,UAAU,IAAI;CACpB,OAAO,IAAI,iBAAiB;EAC3B,MAAM,eAAe,OAAO;EAC5B,QAAQ,IAAI;EACZ,QAAQ,IAAI;EACZ,oBAAoB,IAAI;EACxB,yBAAyB,IAAI;EAC7B,oBAAoB,IAAI;EACxB,WAAW,IAAI,eAAe,UAAU,IAAI,YAAY,IAAI,KAAK;EACjE,SAAS,IAAI;EACb,kBAAkB,IAAI;EACtB,mBAAmB,IAAI;CACxB,CAAC;AACF;AACA,SAAS,eAAe,SAAS;CAChC,MAAM,YAAY,QAAQ;CAC1B,IAAI,CAAC,WAAW,OAAO,KA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ACA,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,0BAA0B;GACzB,SAAS;GACT,OAAO;GACP,OAAO;EACR;CACD,EAAE;CACF,OAAO,QAAQ;EACd,OAAO,IAAI,wBAAwB;CACpC;AACD"}
@@ -1,7 +1,8 @@
1
1
  import { MongoCodecRegistry } from "@prisma/orm-family-mongo/codec";
2
+ import { RuntimeMutationDefaultGenerator } from "@prisma/orm-framework/components/runtime";
2
3
  import { MongoAdapter } from "@prisma/orm-family-mongo/lowering";
3
4
  import { RuntimeAdapterDescriptor, RuntimeAdapterInstance } from "@prisma/orm-framework/components/execution";
4
- //#region ../../../3-mongo-target/2-mongo-adapter/dist/runtime.d.mts
5
+ //#region ../../../3-targets/mongo/2-adapter/dist/runtime.d.mts
5
6
  //#region src/exports/runtime.d.ts
6
7
  /**
7
8
  * adapter-mongo deliberately does NOT import the `MongoRuntimeAdapterDescriptor` type alias from `@internal/mongo-runtime`. The adapter package is downstream of the Mongo runtime package only conceptually; introducing a hard import would create a workspace dependency cycle (`mongo-runtime` consumes the runtime descriptor's `create(stack)` factory; `adapter-mongo` would then need `mongo-runtime` to type the
@@ -10,6 +11,7 @@ import { RuntimeAdapterDescriptor, RuntimeAdapterInstance } from "@prisma/orm-fr
10
11
  interface MongoRuntimeAdapterInstance extends RuntimeAdapterInstance<'mongo', 'mongo'>, MongoAdapter {}
11
12
  declare const mongoRuntimeAdapterDescriptor: RuntimeAdapterDescriptor<'mongo', 'mongo', MongoRuntimeAdapterInstance> & {
12
13
  readonly codecs: () => MongoCodecRegistry;
14
+ readonly mutationDefaultGenerators: () => ReadonlyArray<RuntimeMutationDefaultGenerator>;
13
15
  };
14
16
  //#endregion
15
17
  export { mongoRuntimeAdapterDescriptor as default };
@@ -1 +1 @@
1
- {"version":3,"file":"adapter__runtime.d.mts","names":[],"sources":["../../../../3-mongo-target/2-mongo-adapter/dist/runtime.d.mts"],"mappings":";;;;;;;;;UAQU,oCAAoC,0CAA0C;cAC1E,+BAA+B,2CAA2C;WAC7E,cAAc"}
1
+ {"version":3,"file":"adapter__runtime.d.mts","names":[],"sources":["../../../../3-targets/mongo/2-adapter/dist/runtime.d.mts"],"mappings":";;;;;;;;;;UASU,oCAAoC,0CAA0C;cAC1E,+BAA+B,2CAA2C;WAC7E,cAAc;WACd,iCAAiC,cAAc"}
@@ -1,6 +1,7 @@
1
- import { t as buildStandardCodecRegistry } from "./codecs-DLWO-Cjc-CWfQj0bY.mjs";
2
- import { t as createMongoAdapter } from "./mongo-adapter-B2HEyX0b-CQt2HH_o.mjs";
3
- //#region ../../../3-mongo-target/2-mongo-adapter/dist/runtime.mjs
1
+ import { t as buildStandardCodecRegistry } from "./codecs-B1ab7vfj-QL33tkm2.mjs";
2
+ import { t as createMongoAdapter } from "./mongo-adapter-Bo6ciURK-DIMJdC7y.mjs";
3
+ import { timestampNowRuntimeGenerator } from "@prisma/orm-family-mongo/family/runtime";
4
+ //#region ../../../3-targets/mongo/2-adapter/dist/runtime.mjs
4
5
  const mongoRuntimeAdapterDescriptor = {
5
6
  kind: "adapter",
6
7
  id: "mongo",
@@ -8,6 +9,7 @@ const mongoRuntimeAdapterDescriptor = {
8
9
  targetId: "mongo",
9
10
  version: "0.0.1",
10
11
  codecs: buildStandardCodecRegistry,
12
+ mutationDefaultGenerators: () => [timestampNowRuntimeGenerator()],
11
13
  create(_stack) {
12
14
  const adapter = createMongoAdapter();
13
15
  return {
@@ -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-B2HEyX0b.mjs\";\nimport { t as buildStandardCodecRegistry } from \"./codecs-DLWO-Cjc.mjs\";\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\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":";;;AAGA,MAAM,gCAAgC;CACrC,MAAM;CACN,IAAI;CACJ,UAAU;CACV,UAAU;CACV,SAAS;CACT,QAAQ;CACR,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"}
1
+ {"version":3,"file":"adapter__runtime.mjs","names":[],"sources":["../../../../3-targets/mongo/2-adapter/dist/runtime.mjs"],"sourcesContent":["import { t as createMongoAdapter } from \"./mongo-adapter-Bo6ciURK.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"}
@@ -0,0 +1,18 @@
1
+ //#region ../../../3-targets/mongo/1-target/dist/codec-ids.d.mts
2
+ //#region src/core/codec-ids.d.ts
3
+ declare const MONGO_OBJECTID_CODEC_ID: "mongo/objectId@1";
4
+ declare const MONGO_STRING_CODEC_ID: "mongo/string@1";
5
+ declare const MONGO_DOUBLE_CODEC_ID: "mongo/double@1";
6
+ declare const MONGO_INT32_CODEC_ID: "mongo/int32@1";
7
+ declare const MONGO_BOOLEAN_CODEC_ID: "mongo/bool@1";
8
+ declare const MONGO_DATE_CODEC_ID: "mongo/date@1";
9
+ declare const MONGO_VECTOR_CODEC_ID: "mongo/vector@1";
10
+ declare const MONGO_INT64_CODEC_ID: "mongo/int64@1";
11
+ declare const MONGO_INT64_NUMBER_CODEC_ID: "mongo/int64Number@1";
12
+ declare const MONGO_DECIMAL128_CODEC_ID: "mongo/decimal128@1";
13
+ declare const MONGO_BINARY_CODEC_ID: "mongo/binary@1";
14
+ declare const MONGO_JSON_CODEC_ID: "mongo/json@1";
15
+ declare const MONGO_BSON_CODEC_ID: "mongo/bson@1";
16
+ //#endregion
17
+ export { MONGO_DECIMAL128_CODEC_ID as a, MONGO_INT64_CODEC_ID as c, MONGO_OBJECTID_CODEC_ID as d, MONGO_STRING_CODEC_ID as f, MONGO_DATE_CODEC_ID as i, MONGO_INT64_NUMBER_CODEC_ID as l, MONGO_BOOLEAN_CODEC_ID as n, MONGO_DOUBLE_CODEC_ID as o, MONGO_VECTOR_CODEC_ID as p, MONGO_BSON_CODEC_ID as r, MONGO_INT32_CODEC_ID as s, MONGO_BINARY_CODEC_ID as t, MONGO_JSON_CODEC_ID as u };
18
+ //# sourceMappingURL=codec-ids-BKQbXhZt.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codec-ids-BKQbXhZt.d.mts","names":[],"sources":["../../../../3-targets/mongo/1-target/dist/codec-ids.d.mts"],"mappings":";;cACc;cACA;cACA;cACA;cACA;cACA;cACA;cACA;cACA;cACA;cACA;cACA;cACA"}
@@ -0,0 +1,18 @@
1
+ //#region ../../../3-targets/mongo/1-target/dist/codec-ids-WdrumsYA.mjs
2
+ const MONGO_OBJECTID_CODEC_ID = "mongo/objectId@1";
3
+ const MONGO_STRING_CODEC_ID = "mongo/string@1";
4
+ const MONGO_DOUBLE_CODEC_ID = "mongo/double@1";
5
+ const MONGO_INT32_CODEC_ID = "mongo/int32@1";
6
+ const MONGO_BOOLEAN_CODEC_ID = "mongo/bool@1";
7
+ const MONGO_DATE_CODEC_ID = "mongo/date@1";
8
+ const MONGO_VECTOR_CODEC_ID = "mongo/vector@1";
9
+ const MONGO_INT64_CODEC_ID = "mongo/int64@1";
10
+ const MONGO_INT64_NUMBER_CODEC_ID = "mongo/int64Number@1";
11
+ const MONGO_DECIMAL128_CODEC_ID = "mongo/decimal128@1";
12
+ const MONGO_BINARY_CODEC_ID = "mongo/binary@1";
13
+ const MONGO_JSON_CODEC_ID = "mongo/json@1";
14
+ const MONGO_BSON_CODEC_ID = "mongo/bson@1";
15
+ //#endregion
16
+ export { MONGO_DECIMAL128_CODEC_ID as a, MONGO_INT64_CODEC_ID as c, MONGO_OBJECTID_CODEC_ID as d, MONGO_STRING_CODEC_ID as f, MONGO_DATE_CODEC_ID as i, MONGO_INT64_NUMBER_CODEC_ID as l, MONGO_BOOLEAN_CODEC_ID as n, MONGO_DOUBLE_CODEC_ID as o, MONGO_VECTOR_CODEC_ID as p, MONGO_BSON_CODEC_ID as r, MONGO_INT32_CODEC_ID as s, MONGO_BINARY_CODEC_ID as t, MONGO_JSON_CODEC_ID as u };
17
+
18
+ //# sourceMappingURL=codec-ids-WdrumsYA-CZVjuKW8.mjs.map