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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (166) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +27 -0
  3. package/dist/authoring-entity-types-BGtkMyoN-D32kzx28.mjs +176 -0
  4. package/dist/authoring-entity-types-BGtkMyoN-D32kzx28.mjs.map +1 -0
  5. package/dist/canonicalization-hooks-DF3Z6sjO.mjs +22 -0
  6. package/dist/canonicalization-hooks-DF3Z6sjO.mjs.map +1 -0
  7. package/dist/codec.d.mts +2 -0
  8. package/dist/codec.mjs +2 -0
  9. package/dist/config-types-CFDf9ivE.mjs +37 -0
  10. package/dist/config-types-CFDf9ivE.mjs.map +1 -0
  11. package/dist/config-types-CQOf5N7R.d.mts +12 -0
  12. package/dist/config-types-CQOf5N7R.d.mts.map +1 -0
  13. package/dist/contract-builder-BFq0gOMV.mjs +634 -0
  14. package/dist/contract-builder-BFq0gOMV.mjs.map +1 -0
  15. package/dist/contract-builder-DB8nguDE.d.mts +445 -0
  16. package/dist/contract-builder-DB8nguDE.d.mts.map +1 -0
  17. package/dist/contract-errors-BCN6RVI5-kMurtAbI.mjs +9 -0
  18. package/dist/contract-errors-BCN6RVI5-kMurtAbI.mjs.map +1 -0
  19. package/dist/contract-psl.d.mts +45 -0
  20. package/dist/contract-psl.d.mts.map +1 -0
  21. package/dist/contract-psl.mjs +2 -0
  22. package/dist/contract-psl__provider.d.mts +15 -0
  23. package/dist/contract-psl__provider.d.mts.map +1 -0
  24. package/dist/contract-psl__provider.mjs +82 -0
  25. package/dist/contract-psl__provider.mjs.map +1 -0
  26. package/dist/contract-ts.d.mts +3 -0
  27. package/dist/contract-ts.mjs +3 -0
  28. package/dist/contract-ts__config-types.d.mts +2 -0
  29. package/dist/contract-ts__config-types.mjs +2 -0
  30. package/dist/contract-ts__contract-builder.d.mts +2 -0
  31. package/dist/contract-ts__contract-builder.mjs +2 -0
  32. package/dist/contract.d.mts +3 -0
  33. package/dist/contract.mjs +3 -0
  34. package/dist/contract__canonicalization-hooks.d.mts +9 -0
  35. package/dist/contract__canonicalization-hooks.d.mts.map +1 -0
  36. package/dist/contract__canonicalization-hooks.mjs +2 -0
  37. package/dist/contract__entity-kinds.d.mts +17 -0
  38. package/dist/contract__entity-kinds.d.mts.map +1 -0
  39. package/dist/contract__entity-kinds.mjs +2 -0
  40. package/dist/control-C7-kthr1.d.mts +193 -0
  41. package/dist/control-C7-kthr1.d.mts.map +1 -0
  42. package/dist/control-CClR5JMr.mjs +127 -0
  43. package/dist/control-CClR5JMr.mjs.map +1 -0
  44. package/dist/control-CFr3tYsg.mjs +398 -0
  45. package/dist/control-CFr3tYsg.mjs.map +1 -0
  46. package/dist/control-Cj81sPbj.d.mts +101 -0
  47. package/dist/control-Cj81sPbj.d.mts.map +1 -0
  48. package/dist/control-adapter-Db5pT77b.d.mts +83 -0
  49. package/dist/control-adapter-Db5pT77b.d.mts.map +1 -0
  50. package/dist/dist-C7Ykq48Q.mjs +19 -0
  51. package/dist/dist-C7Ykq48Q.mjs.map +1 -0
  52. package/dist/dist-Czwqx_i3.mjs +58 -0
  53. package/dist/dist-Czwqx_i3.mjs.map +1 -0
  54. package/dist/dist-DHrEJnhK.mjs +236 -0
  55. package/dist/dist-DHrEJnhK.mjs.map +1 -0
  56. package/dist/dist-Dyp05u64.mjs +1546 -0
  57. package/dist/dist-Dyp05u64.mjs.map +1 -0
  58. package/dist/emitter.d.mts +22 -0
  59. package/dist/emitter.d.mts.map +1 -0
  60. package/dist/emitter.mjs +2 -0
  61. package/dist/entity-kinds-B4KNTF8z-DPIuUuuB.mjs +603 -0
  62. package/dist/entity-kinds-B4KNTF8z-DPIuUuuB.mjs.map +1 -0
  63. package/dist/execution-CKnUiOfm.d.mts +48 -0
  64. package/dist/execution-CKnUiOfm.d.mts.map +1 -0
  65. package/dist/execution-D5XyZ5XS.mjs +1269 -0
  66. package/dist/execution-D5XyZ5XS.mjs.map +1 -0
  67. package/dist/exports-Bx-hlnZ3.mjs +209 -0
  68. package/dist/exports-Bx-hlnZ3.mjs.map +1 -0
  69. package/dist/exports-CJMh0VTU.mjs +156 -0
  70. package/dist/exports-CJMh0VTU.mjs.map +1 -0
  71. package/dist/family.d.mts +10 -0
  72. package/dist/family.mjs +9 -0
  73. package/dist/family__control-adapter.d.mts +2 -0
  74. package/dist/family__control-adapter.mjs +1 -0
  75. package/dist/family__control.d.mts +2 -0
  76. package/dist/family__control.mjs +3 -0
  77. package/dist/family__ir.d.mts +3 -0
  78. package/dist/family__ir.mjs +4 -0
  79. package/dist/family__migration.d.mts +2 -0
  80. package/dist/family__migration.mjs +2 -0
  81. package/dist/family__pack.d.mts +2 -0
  82. package/dist/family__pack.mjs +16 -0
  83. package/dist/family__pack.mjs.map +1 -0
  84. package/dist/family__runtime.d.mts +3 -0
  85. package/dist/family__runtime.mjs +2 -0
  86. package/dist/family__schema-verify.d.mts +2 -0
  87. package/dist/family__schema-verify.mjs +2 -0
  88. package/dist/field-accessor-0oUt6RZC-B_Z30uAA.mjs +234 -0
  89. package/dist/field-accessor-0oUt6RZC-B_Z30uAA.mjs.map +1 -0
  90. package/dist/field-accessor-DHsAPiW3-BdYCspQC.d.mts +588 -0
  91. package/dist/field-accessor-DHsAPiW3-BdYCspQC.d.mts.map +1 -0
  92. package/dist/filter-expressions-Uo8ZdzwB-53qnqceS.mjs +181 -0
  93. package/dist/filter-expressions-Uo8ZdzwB-53qnqceS.mjs.map +1 -0
  94. package/dist/index-BR0ue13b.d.mts +136 -0
  95. package/dist/index-BR0ue13b.d.mts.map +1 -0
  96. package/dist/index-Cd2zLiU6.d.mts +128 -0
  97. package/dist/index-Cd2zLiU6.d.mts.map +1 -0
  98. package/dist/index-DAOkcTCK.d.mts +151 -0
  99. package/dist/index-DAOkcTCK.d.mts.map +1 -0
  100. package/dist/index-Dv2PNMiG.d.mts +53 -0
  101. package/dist/index-Dv2PNMiG.d.mts.map +1 -0
  102. package/dist/index-DxoO-ywI.d.mts +178 -0
  103. package/dist/index-DxoO-ywI.d.mts.map +1 -0
  104. package/dist/index-wKMm41HC.d.mts +30 -0
  105. package/dist/index-wKMm41HC.d.mts.map +1 -0
  106. package/dist/interpreter-BxbUTQ3k-ClR98Ned.mjs +1091 -0
  107. package/dist/interpreter-BxbUTQ3k-ClR98Ned.mjs.map +1 -0
  108. package/dist/ir-CQrenTYt.d.mts +147 -0
  109. package/dist/ir-CQrenTYt.d.mts.map +1 -0
  110. package/dist/ir-Ch2aPr7a.mjs +62 -0
  111. package/dist/ir-Ch2aPr7a.mjs.map +1 -0
  112. package/dist/lowering.d.mts +2 -0
  113. package/dist/lowering.mjs +1 -0
  114. package/dist/migration-CNDQv5yB.d.mts +50 -0
  115. package/dist/migration-CNDQv5yB.d.mts.map +1 -0
  116. package/dist/migration-dcM7u4HG.mjs +52 -0
  117. package/dist/migration-dcM7u4HG.mjs.map +1 -0
  118. package/dist/mongo-contract-serializer-Cx7Fae8e-C8ZYPXpc.mjs +119 -0
  119. package/dist/mongo-contract-serializer-Cx7Fae8e-C8ZYPXpc.mjs.map +1 -0
  120. package/dist/mongo-contract-view-AnejqfrQ-BaCFT0xm.d.mts +27 -0
  121. package/dist/mongo-contract-view-AnejqfrQ-BaCFT0xm.d.mts.map +1 -0
  122. package/dist/mongo-contract-view-rcWzby6f-wRBCUnBt.mjs +17 -0
  123. package/dist/mongo-contract-view-rcWzby6f-wRBCUnBt.mjs.map +1 -0
  124. package/dist/mongo-value-set-tNn9-pun-dJYx_rVD.d.mts +536 -0
  125. package/dist/mongo-value-set-tNn9-pun-dJYx_rVD.d.mts.map +1 -0
  126. package/dist/mongodb-types-B4HmhF1S.d.mts +2 -0
  127. package/dist/orm.d.mts +311 -0
  128. package/dist/orm.d.mts.map +1 -0
  129. package/dist/orm.mjs +664 -0
  130. package/dist/orm.mjs.map +1 -0
  131. package/dist/pack-D9aLY50F.d.mts +44 -0
  132. package/dist/pack-D9aLY50F.d.mts.map +1 -0
  133. package/dist/query-ast.d.mts +5 -0
  134. package/dist/query-ast.mjs +4 -0
  135. package/dist/query-ast__control.d.mts +4 -0
  136. package/dist/query-ast__control.mjs +3 -0
  137. package/dist/query-ast__execution.d.mts +3 -0
  138. package/dist/query-ast__execution.mjs +3 -0
  139. package/dist/query-builder.d.mts +836 -0
  140. package/dist/query-builder.d.mts.map +1 -0
  141. package/dist/query-builder.mjs +3 -0
  142. package/dist/query-builder__contract-free.d.mts +83 -0
  143. package/dist/query-builder__contract-free.d.mts.map +1 -0
  144. package/dist/query-builder__contract-free.mjs +107 -0
  145. package/dist/query-builder__contract-free.mjs.map +1 -0
  146. package/dist/query-plan-C0-Yu8hf-DdilEdW6.d.mts +822 -0
  147. package/dist/query-plan-C0-Yu8hf-DdilEdW6.d.mts.map +1 -0
  148. package/dist/runtime-DPkRW4iu.d.mts +1 -0
  149. package/dist/runtime.d.mts +286 -0
  150. package/dist/runtime.d.mts.map +1 -0
  151. package/dist/runtime.mjs +532 -0
  152. package/dist/runtime.mjs.map +1 -0
  153. package/dist/schema-ir.d.mts +2 -0
  154. package/dist/schema-ir.mjs +2 -0
  155. package/dist/schema-verify-DJGr28XW.d.mts +23 -0
  156. package/dist/schema-verify-DJGr28XW.d.mts.map +1 -0
  157. package/dist/value.d.mts +2 -0
  158. package/dist/value.mjs +2 -0
  159. package/dist/value__mongodb-types.d.mts +2 -0
  160. package/dist/value__mongodb-types.mjs +1 -0
  161. package/dist/verify-mongo-schema-De0FG2Rm-CCzwnNPY.mjs +447 -0
  162. package/dist/verify-mongo-schema-De0FG2Rm-CCzwnNPY.mjs.map +1 -0
  163. package/dist/wire.d.mts +3 -0
  164. package/dist/wire.mjs +190 -0
  165. package/dist/wire.mjs.map +1 -0
  166. package/package.json +89 -0
@@ -0,0 +1,398 @@
1
+ import { t as mongoContractCanonicalizationHooks } from "./canonicalization-hooks-DF3Z6sjO.mjs";
2
+ import { t as mongoEmission } from "./exports-CJMh0VTU.mjs";
3
+ import { i as verifyMongoSchema } from "./verify-mongo-schema-De0FG2Rm-CCzwnNPY.mjs";
4
+ import { n as mongoFamilyPslBlockDescriptors, t as mongoFamilyEntityTypes } from "./authoring-entity-types-BGtkMyoN-D32kzx28.mjs";
5
+ import { t as MongoContractSerializer } from "./mongo-contract-serializer-Cx7Fae8e-C8ZYPXpc.mjs";
6
+ import { structuredError } from "@prisma/orm-framework/utils/structured-error";
7
+ import { ifDefined } from "@prisma/orm-framework/utils/defined";
8
+ import { InternalError } from "@prisma/orm-framework/utils/internal-error";
9
+ import { APP_SPACE_ID, SchemaTreeNode, VERIFY_CODE_HASH_MISMATCH, VERIFY_CODE_MARKER_MISSING, VERIFY_CODE_TARGET_MISMATCH } from "@prisma/orm-framework/components/control";
10
+ import { assertDescriptorSelfConsistency } from "@prisma/orm-toolchain/migration-tools/spaces";
11
+ //#region ../../../2-mongo-family/9-family/dist/control.mjs
12
+ function formatKeySpec(keys) {
13
+ return `{ ${keys.map((k) => `${JSON.stringify(k.field)}: ${JSON.stringify(k.direction)}`).join(", ")} }`;
14
+ }
15
+ const COMMAND_META_KEYS = /* @__PURE__ */ new Set([
16
+ "kind",
17
+ "collection",
18
+ "keys"
19
+ ]);
20
+ function formatOptionEntries(cmd) {
21
+ const parts = Object.entries(cmd).filter(([key, value]) => !COMMAND_META_KEYS.has(key) && value !== void 0).map(([key, value]) => `${key}: ${JSON.stringify(value)}`);
22
+ if (parts.length === 0) return void 0;
23
+ return `{ ${parts.join(", ")} }`;
24
+ }
25
+ function formatOptions(cmd) {
26
+ return formatOptionEntries(cmd);
27
+ }
28
+ function formatCreateCollectionOptions(cmd) {
29
+ return formatOptionEntries(cmd);
30
+ }
31
+ var MongoDdlCommandFormatter = class {
32
+ createIndex(cmd) {
33
+ const keySpec = formatKeySpec(cmd.keys);
34
+ const opts = formatOptions(cmd);
35
+ return opts ? `db.${cmd.collection}.createIndex(${keySpec}, ${opts})` : `db.${cmd.collection}.createIndex(${keySpec})`;
36
+ }
37
+ dropIndex(cmd) {
38
+ return `db.${cmd.collection}.dropIndex(${JSON.stringify(cmd.name)})`;
39
+ }
40
+ createCollection(cmd) {
41
+ const opts = formatCreateCollectionOptions(cmd);
42
+ return opts ? `db.createCollection(${JSON.stringify(cmd.collection)}, ${opts})` : `db.createCollection(${JSON.stringify(cmd.collection)})`;
43
+ }
44
+ dropCollection(cmd) {
45
+ return `db.${cmd.collection}.drop()`;
46
+ }
47
+ collMod(cmd) {
48
+ const parts = [`collMod: ${JSON.stringify(cmd.collection)}`];
49
+ for (const [key, value] of Object.entries(cmd)) if (!COMMAND_META_KEYS.has(key) && value !== void 0) parts.push(`${key}: ${JSON.stringify(value)}`);
50
+ return `db.runCommand({ ${parts.join(", ")} })`;
51
+ }
52
+ };
53
+ const formatter = new MongoDdlCommandFormatter();
54
+ function formatMongoOperations(operations) {
55
+ const statements = [];
56
+ for (const operation of operations) {
57
+ const candidate = operation;
58
+ if (!("execute" in candidate) || !Array.isArray(candidate["execute"])) continue;
59
+ for (const step of candidate["execute"]) if (step.command && typeof step.command.accept === "function") statements.push(step.command.accept(formatter));
60
+ }
61
+ return statements;
62
+ }
63
+ /**
64
+ * Wraps `formatMongoOperations` into the family-agnostic
65
+ * `OperationPreview` shape. Each statement carries
66
+ * `language: 'mongodb-shell'`. Mirrors `sqlOperationsToPreview`.
67
+ */
68
+ function mongoOperationsToPreview(operations) {
69
+ return { statements: formatMongoOperations(operations).map((text) => ({
70
+ text,
71
+ language: "mongodb-shell"
72
+ })) };
73
+ }
74
+ function mongoSchemaToView(schema) {
75
+ const collectionNodes = schema.collections.map((collection) => collectionToSchemaNode(collection.name, collection));
76
+ return { root: new SchemaTreeNode({
77
+ kind: "root",
78
+ id: "mongo-schema",
79
+ label: "database",
80
+ ...ifDefined("children", collectionNodes.length > 0 ? collectionNodes : void 0)
81
+ }) };
82
+ }
83
+ function collectionToSchemaNode(name, collection) {
84
+ const children = [];
85
+ for (const index of collection.indexes) {
86
+ const keysSummary = index.keys.map((k) => {
87
+ if (k.direction === 1) return k.field;
88
+ if (k.direction === -1) return `${k.field} desc`;
89
+ return `${k.field} ${k.direction}`;
90
+ }).join(", ");
91
+ const prefix = index.unique ? "unique index" : "index";
92
+ const options = [];
93
+ if (index.sparse) options.push("sparse");
94
+ if (index.expireAfterSeconds != null) options.push(`ttl: ${index.expireAfterSeconds}s`);
95
+ if (index.partialFilterExpression) options.push("partial");
96
+ const optsSuffix = options.length > 0 ? ` (${options.join(", ")})` : "";
97
+ children.push(new SchemaTreeNode({
98
+ kind: "index",
99
+ id: `index-${name}-${index.keys.map((k) => `${k.field}_${k.direction}`).join("_")}`,
100
+ label: `${prefix} (${keysSummary})${optsSuffix}`,
101
+ meta: {
102
+ keys: index.keys,
103
+ unique: index.unique,
104
+ ...ifDefined("sparse", index.sparse || void 0),
105
+ ...ifDefined("expireAfterSeconds", index.expireAfterSeconds ?? void 0),
106
+ ...ifDefined("partialFilterExpression", index.partialFilterExpression ?? void 0)
107
+ }
108
+ }));
109
+ }
110
+ if (collection.validator) {
111
+ const validatorChildren = [];
112
+ const jsonSchema = collection.validator.jsonSchema;
113
+ const properties = jsonSchema["properties"];
114
+ const required = new Set(jsonSchema["required"] ?? []);
115
+ if (properties) for (const [propName, propDef] of Object.entries(properties)) {
116
+ const bsonType = propDef["bsonType"] ?? "unknown";
117
+ const suffix = required.has(propName) ? " (required)" : "";
118
+ validatorChildren.push(new SchemaTreeNode({
119
+ kind: "field",
120
+ id: `field-${name}-${propName}`,
121
+ label: `${propName}: ${bsonType}${suffix}`
122
+ }));
123
+ }
124
+ children.push(new SchemaTreeNode({
125
+ kind: "field",
126
+ id: `validator-${name}`,
127
+ label: `validator (level: ${collection.validator.validationLevel}, action: ${collection.validator.validationAction})`,
128
+ meta: {
129
+ validationLevel: collection.validator.validationLevel,
130
+ validationAction: collection.validator.validationAction,
131
+ jsonSchema: collection.validator.jsonSchema
132
+ },
133
+ ...ifDefined("children", validatorChildren.length > 0 ? validatorChildren : void 0)
134
+ }));
135
+ }
136
+ if (collection.options) {
137
+ const opts = collection.options;
138
+ const optLabels = [];
139
+ if (opts.capped) optLabels.push("capped");
140
+ if (opts.timeseries) optLabels.push("timeseries");
141
+ if (opts.collation) optLabels.push("collation");
142
+ if (opts.changeStreamPreAndPostImages) optLabels.push("changeStreamPreAndPostImages");
143
+ if (opts.clusteredIndex) optLabels.push("clusteredIndex");
144
+ if (optLabels.length > 0) children.push(new SchemaTreeNode({
145
+ kind: "field",
146
+ id: `options-${name}`,
147
+ label: `options (${optLabels.join(", ")})`,
148
+ meta: {
149
+ ...ifDefined("capped", opts.capped ?? void 0),
150
+ ...ifDefined("timeseries", opts.timeseries ?? void 0),
151
+ ...ifDefined("collation", opts.collation ?? void 0),
152
+ ...ifDefined("changeStreamPreAndPostImages", opts.changeStreamPreAndPostImages ?? void 0),
153
+ ...ifDefined("clusteredIndex", opts.clusteredIndex ?? void 0)
154
+ }
155
+ }));
156
+ }
157
+ return new SchemaTreeNode({
158
+ kind: "collection",
159
+ id: `collection-${name}`,
160
+ label: `collection ${name}`,
161
+ ...ifDefined("children", children.length > 0 ? children : void 0)
162
+ });
163
+ }
164
+ function deserializeMongoContract(contractJson) {
165
+ return new MongoContractSerializer().deserializeContract(contractJson);
166
+ }
167
+ /**
168
+ * Family-method contract input. By the time control-plane methods
169
+ * (`verify`, `verifySchema`, `sign`, …) are invoked through the CLI
170
+ * control client (`client.ts`), the input has already been threaded
171
+ * through `familyInstance.deserializeContract`. The value is therefore a
172
+ * class-form `MongoTargetContract` (or a structurally-equivalent
173
+ * envelope post-deserialization) and must NOT be re-fed through
174
+ * structural validation (arktype rejects extra keys like `namespaces`).
175
+ *
176
+ * The parameter type on the framework SPI is `unknown` for variance
177
+ * reasons (so the family can express its own contract type without
178
+ * leaking it to the framework). This helper recovers the validated
179
+ * shape with a single narrow cast.
180
+ */
181
+ function asValidatedMongoContract(contract) {
182
+ return contract;
183
+ }
184
+ function buildVerifyResult(opts) {
185
+ return {
186
+ ok: opts.ok,
187
+ ...ifDefined("code", opts.code),
188
+ summary: opts.summary,
189
+ contract: {
190
+ storageHash: opts.contractStorageHash,
191
+ ...ifDefined("profileHash", opts.contractProfileHash)
192
+ },
193
+ ...ifDefined("marker", opts.marker ? {
194
+ storageHash: opts.marker.storageHash,
195
+ profileHash: opts.marker.profileHash
196
+ } : void 0),
197
+ target: {
198
+ expected: opts.expectedTargetId,
199
+ ...ifDefined("actual", opts.actualTargetId)
200
+ },
201
+ meta: {
202
+ contractPath: opts.contractPath,
203
+ ...ifDefined("configPath", opts.configPath)
204
+ },
205
+ timings: { total: opts.totalTime }
206
+ };
207
+ }
208
+ function createMongoFamilyInstance(controlStack) {
209
+ const extensions = controlStack.extensions ?? [];
210
+ for (const extension of extensions) if (extension.contractSpace) {
211
+ const { contractJson, headRef } = extension.contractSpace;
212
+ assertDescriptorSelfConsistency({
213
+ extensionId: extension.id,
214
+ target: contractJson.target,
215
+ targetFamily: contractJson.targetFamily,
216
+ storage: contractJson.storage,
217
+ headRefHash: headRef.hash,
218
+ ...mongoContractCanonicalizationHooks
219
+ });
220
+ }
221
+ const adapter = controlStack.adapter;
222
+ const getControlAdapter = () => {
223
+ if (!adapter) throw new InternalError("Mongo family requires an adapter descriptor in ControlStack");
224
+ return adapter.create(controlStack);
225
+ };
226
+ function isMongoTargetDriver(driver) {
227
+ return driver.targetId === "mongo";
228
+ }
229
+ function asMongoDriver(driver) {
230
+ if (!isMongoTargetDriver(driver)) throw structuredError("CONTRACT.TARGET_MISMATCH", `Expected Mongo control driver with targetId 'mongo', got '${driver.targetId}'`);
231
+ return driver;
232
+ }
233
+ return {
234
+ familyId: "mongo",
235
+ deserializeContract(contractJson) {
236
+ return deserializeMongoContract(contractJson);
237
+ },
238
+ async verify(options) {
239
+ const { driver, contract: rawContract, expectedTargetId, contractPath, configPath } = options;
240
+ const startTime = Date.now();
241
+ const contract = asValidatedMongoContract(rawContract);
242
+ const contractStorageHash = contract.storage.storageHash;
243
+ const contractProfileHash = contract.profileHash;
244
+ const contractTarget = contract.target;
245
+ const baseOpts = {
246
+ contractStorageHash,
247
+ contractProfileHash,
248
+ expectedTargetId,
249
+ contractPath,
250
+ ...ifDefined("configPath", configPath)
251
+ };
252
+ if (contractTarget !== expectedTargetId) return buildVerifyResult({
253
+ ...baseOpts,
254
+ ok: false,
255
+ code: VERIFY_CODE_TARGET_MISMATCH,
256
+ summary: "Target mismatch",
257
+ actualTargetId: contractTarget,
258
+ totalTime: Date.now() - startTime
259
+ });
260
+ const marker = await getControlAdapter().readMarker(asMongoDriver(driver), APP_SPACE_ID);
261
+ if (!marker) return buildVerifyResult({
262
+ ...baseOpts,
263
+ ok: false,
264
+ code: VERIFY_CODE_MARKER_MISSING,
265
+ summary: "Marker missing",
266
+ totalTime: Date.now() - startTime
267
+ });
268
+ if (marker.storageHash !== contractStorageHash) return buildVerifyResult({
269
+ ...baseOpts,
270
+ ok: false,
271
+ code: VERIFY_CODE_HASH_MISMATCH,
272
+ summary: "Hash mismatch",
273
+ marker,
274
+ totalTime: Date.now() - startTime
275
+ });
276
+ if (contractProfileHash && marker.profileHash !== contractProfileHash) return buildVerifyResult({
277
+ ...baseOpts,
278
+ ok: false,
279
+ code: VERIFY_CODE_HASH_MISMATCH,
280
+ summary: "Hash mismatch",
281
+ marker,
282
+ totalTime: Date.now() - startTime
283
+ });
284
+ return buildVerifyResult({
285
+ ...baseOpts,
286
+ ok: true,
287
+ summary: "Database matches contract",
288
+ marker,
289
+ totalTime: Date.now() - startTime
290
+ });
291
+ },
292
+ verifySchema(options) {
293
+ return verifyMongoSchema({
294
+ contract: asValidatedMongoContract(options.contract),
295
+ schema: options.schema,
296
+ strict: options.strict,
297
+ frameworkComponents: options.frameworkComponents
298
+ });
299
+ },
300
+ async sign(options) {
301
+ const { driver, contract: rawContract, contractPath, configPath } = options;
302
+ const startTime = Date.now();
303
+ const contract = asValidatedMongoContract(rawContract);
304
+ const contractStorageHash = contract.storage.storageHash;
305
+ const contractProfileHash = contract.profileHash;
306
+ const controlAdapter = getControlAdapter();
307
+ const mongoDriver = asMongoDriver(driver);
308
+ const existingMarker = await controlAdapter.readMarker(mongoDriver, APP_SPACE_ID);
309
+ let markerCreated = false;
310
+ let markerUpdated = false;
311
+ let previousHashes;
312
+ if (!existingMarker) {
313
+ await controlAdapter.initMarker(mongoDriver, APP_SPACE_ID, {
314
+ storageHash: contractStorageHash,
315
+ profileHash: contractProfileHash
316
+ });
317
+ markerCreated = true;
318
+ } else {
319
+ const storageHashMatches = existingMarker.storageHash === contractStorageHash;
320
+ const profileHashMatches = existingMarker.profileHash === contractProfileHash;
321
+ if (!storageHashMatches || !profileHashMatches) {
322
+ previousHashes = {
323
+ storageHash: existingMarker.storageHash,
324
+ profileHash: existingMarker.profileHash
325
+ };
326
+ if (!await controlAdapter.updateMarker(mongoDriver, APP_SPACE_ID, existingMarker.storageHash, {
327
+ storageHash: contractStorageHash,
328
+ profileHash: contractProfileHash
329
+ })) throw structuredError("MIGRATION.MARKER_CAS_FAILURE", "CAS conflict: marker was modified by another process during sign");
330
+ markerUpdated = true;
331
+ }
332
+ }
333
+ let summary;
334
+ if (markerCreated) summary = "Database signed (marker created)";
335
+ else if (markerUpdated) summary = `Database signed (marker updated from ${previousHashes?.storageHash ?? "unknown"})`;
336
+ else summary = "Database already signed with this contract";
337
+ return {
338
+ ok: true,
339
+ summary,
340
+ contract: {
341
+ storageHash: contractStorageHash,
342
+ profileHash: contractProfileHash
343
+ },
344
+ target: {
345
+ expected: contract.target,
346
+ actual: contract.target
347
+ },
348
+ marker: {
349
+ created: markerCreated,
350
+ updated: markerUpdated,
351
+ ...ifDefined("previous", previousHashes)
352
+ },
353
+ meta: {
354
+ contractPath,
355
+ ...ifDefined("configPath", configPath)
356
+ },
357
+ timings: { total: Date.now() - startTime }
358
+ };
359
+ },
360
+ async readMarker(options) {
361
+ return getControlAdapter().readMarker(asMongoDriver(options.driver), options.space);
362
+ },
363
+ async readAllMarkers(options) {
364
+ return getControlAdapter().readAllMarkers(asMongoDriver(options.driver));
365
+ },
366
+ async readLedger(options) {
367
+ return getControlAdapter().readLedger(asMongoDriver(options.driver), options.space);
368
+ },
369
+ async introspect(options) {
370
+ return getControlAdapter().introspectSchema(asMongoDriver(options.driver));
371
+ },
372
+ toSchemaView(schema) {
373
+ return mongoSchemaToView(schema);
374
+ },
375
+ toOperationPreview(operations) {
376
+ return mongoOperationsToPreview(operations);
377
+ }
378
+ };
379
+ }
380
+ var MongoFamilyDescriptor = class {
381
+ kind = "family";
382
+ id = "mongo";
383
+ familyId = "mongo";
384
+ version = "0.0.1";
385
+ emission = mongoEmission;
386
+ authoring = {
387
+ entityTypes: mongoFamilyEntityTypes,
388
+ pslBlockDescriptors: mongoFamilyPslBlockDescriptors
389
+ };
390
+ create(stack) {
391
+ return createMongoFamilyInstance(stack);
392
+ }
393
+ };
394
+ const mongoFamilyDescriptor = new MongoFamilyDescriptor();
395
+ //#endregion
396
+ export { mongoOperationsToPreview as i, formatMongoOperations as n, mongoFamilyDescriptor as r, createMongoFamilyInstance as t };
397
+
398
+ //# sourceMappingURL=control-CFr3tYsg.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"control-CFr3tYsg.mjs","names":[],"sources":["../../../../2-mongo-family/9-family/dist/control.mjs"],"sourcesContent":["import { i as contractToMongoSchemaIR, n as canonicalizeSchemasForVerification, r as diffMongoSchemas, t as verifyMongoSchema } from \"./verify-mongo-schema-De0FG2Rm.mjs\";\nimport { n as mongoFamilyPslBlockDescriptors, t as mongoFamilyEntityTypes } from \"./authoring-entity-types-BGtkMyoN.mjs\";\nimport { t as MongoContractSerializer } from \"./mongo-contract-serializer-Cx7Fae8e.mjs\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { mongoEmission } from \"@internal/mongo-emitter\";\nimport { structuredError } from \"@internal/utils/structured-error\";\nimport { APP_SPACE_ID, SchemaTreeNode, VERIFY_CODE_HASH_MISMATCH, VERIFY_CODE_MARKER_MISSING, VERIFY_CODE_TARGET_MISMATCH } from \"@internal/framework-components/control\";\nimport { mongoContractCanonicalizationHooks } from \"@internal/mongo-contract/canonicalization-hooks\";\nimport { assertDescriptorSelfConsistency } from \"@internal/migration-tools/spaces\";\nimport { InternalError } from \"@internal/utils/internal-error\";\n//#region src/core/operation-preview.ts\nfunction formatKeySpec(keys) {\n\treturn `{ ${keys.map((k) => `${JSON.stringify(k.field)}: ${JSON.stringify(k.direction)}`).join(\", \")} }`;\n}\nconst COMMAND_META_KEYS = /* @__PURE__ */ new Set([\n\t\"kind\",\n\t\"collection\",\n\t\"keys\"\n]);\nfunction formatOptionEntries(cmd) {\n\tconst parts = Object.entries(cmd).filter(([key, value]) => !COMMAND_META_KEYS.has(key) && value !== void 0).map(([key, value]) => `${key}: ${JSON.stringify(value)}`);\n\tif (parts.length === 0) return void 0;\n\treturn `{ ${parts.join(\", \")} }`;\n}\nfunction formatOptions(cmd) {\n\treturn formatOptionEntries(cmd);\n}\nfunction formatCreateCollectionOptions(cmd) {\n\treturn formatOptionEntries(cmd);\n}\nvar MongoDdlCommandFormatter = class {\n\tcreateIndex(cmd) {\n\t\tconst keySpec = formatKeySpec(cmd.keys);\n\t\tconst opts = formatOptions(cmd);\n\t\treturn opts ? `db.${cmd.collection}.createIndex(${keySpec}, ${opts})` : `db.${cmd.collection}.createIndex(${keySpec})`;\n\t}\n\tdropIndex(cmd) {\n\t\treturn `db.${cmd.collection}.dropIndex(${JSON.stringify(cmd.name)})`;\n\t}\n\tcreateCollection(cmd) {\n\t\tconst opts = formatCreateCollectionOptions(cmd);\n\t\treturn opts ? `db.createCollection(${JSON.stringify(cmd.collection)}, ${opts})` : `db.createCollection(${JSON.stringify(cmd.collection)})`;\n\t}\n\tdropCollection(cmd) {\n\t\treturn `db.${cmd.collection}.drop()`;\n\t}\n\tcollMod(cmd) {\n\t\tconst parts = [`collMod: ${JSON.stringify(cmd.collection)}`];\n\t\tfor (const [key, value] of Object.entries(cmd)) if (!COMMAND_META_KEYS.has(key) && value !== void 0) parts.push(`${key}: ${JSON.stringify(value)}`);\n\t\treturn `db.runCommand({ ${parts.join(\", \")} })`;\n\t}\n};\nconst formatter = new MongoDdlCommandFormatter();\nfunction formatMongoOperations(operations) {\n\tconst statements = [];\n\tfor (const operation of operations) {\n\t\tconst candidate = operation;\n\t\tif (!(\"execute\" in candidate) || !Array.isArray(candidate[\"execute\"])) continue;\n\t\tfor (const step of candidate[\"execute\"]) if (step.command && typeof step.command.accept === \"function\") statements.push(step.command.accept(formatter));\n\t}\n\treturn statements;\n}\n/**\n* Wraps `formatMongoOperations` into the family-agnostic\n* `OperationPreview` shape. Each statement carries\n* `language: 'mongodb-shell'`. Mirrors `sqlOperationsToPreview`.\n*/\nfunction mongoOperationsToPreview(operations) {\n\treturn { statements: formatMongoOperations(operations).map((text) => ({\n\t\ttext,\n\t\tlanguage: \"mongodb-shell\"\n\t})) };\n}\n//#endregion\n//#region src/core/schema-to-view.ts\nfunction mongoSchemaToView(schema) {\n\tconst collectionNodes = schema.collections.map((collection) => collectionToSchemaNode(collection.name, collection));\n\treturn { root: new SchemaTreeNode({\n\t\tkind: \"root\",\n\t\tid: \"mongo-schema\",\n\t\tlabel: \"database\",\n\t\t...ifDefined(\"children\", collectionNodes.length > 0 ? collectionNodes : void 0)\n\t}) };\n}\nfunction collectionToSchemaNode(name, collection) {\n\tconst children = [];\n\tfor (const index of collection.indexes) {\n\t\tconst keysSummary = index.keys.map((k) => {\n\t\t\tif (k.direction === 1) return k.field;\n\t\t\tif (k.direction === -1) return `${k.field} desc`;\n\t\t\treturn `${k.field} ${k.direction}`;\n\t\t}).join(\", \");\n\t\tconst prefix = index.unique ? \"unique index\" : \"index\";\n\t\tconst options = [];\n\t\tif (index.sparse) options.push(\"sparse\");\n\t\tif (index.expireAfterSeconds != null) options.push(`ttl: ${index.expireAfterSeconds}s`);\n\t\tif (index.partialFilterExpression) options.push(\"partial\");\n\t\tconst optsSuffix = options.length > 0 ? ` (${options.join(\", \")})` : \"\";\n\t\tchildren.push(new SchemaTreeNode({\n\t\t\tkind: \"index\",\n\t\t\tid: `index-${name}-${index.keys.map((k) => `${k.field}_${k.direction}`).join(\"_\")}`,\n\t\t\tlabel: `${prefix} (${keysSummary})${optsSuffix}`,\n\t\t\tmeta: {\n\t\t\t\tkeys: index.keys,\n\t\t\t\tunique: index.unique,\n\t\t\t\t...ifDefined(\"sparse\", index.sparse || void 0),\n\t\t\t\t...ifDefined(\"expireAfterSeconds\", index.expireAfterSeconds ?? void 0),\n\t\t\t\t...ifDefined(\"partialFilterExpression\", index.partialFilterExpression ?? void 0)\n\t\t\t}\n\t\t}));\n\t}\n\tif (collection.validator) {\n\t\tconst validatorChildren = [];\n\t\tconst jsonSchema = collection.validator.jsonSchema;\n\t\tconst properties = jsonSchema[\"properties\"];\n\t\tconst required = new Set(jsonSchema[\"required\"] ?? []);\n\t\tif (properties) for (const [propName, propDef] of Object.entries(properties)) {\n\t\t\tconst bsonType = propDef[\"bsonType\"] ?? \"unknown\";\n\t\t\tconst suffix = required.has(propName) ? \" (required)\" : \"\";\n\t\t\tvalidatorChildren.push(new SchemaTreeNode({\n\t\t\t\tkind: \"field\",\n\t\t\t\tid: `field-${name}-${propName}`,\n\t\t\t\tlabel: `${propName}: ${bsonType}${suffix}`\n\t\t\t}));\n\t\t}\n\t\tchildren.push(new SchemaTreeNode({\n\t\t\tkind: \"field\",\n\t\t\tid: `validator-${name}`,\n\t\t\tlabel: `validator (level: ${collection.validator.validationLevel}, action: ${collection.validator.validationAction})`,\n\t\t\tmeta: {\n\t\t\t\tvalidationLevel: collection.validator.validationLevel,\n\t\t\t\tvalidationAction: collection.validator.validationAction,\n\t\t\t\tjsonSchema: collection.validator.jsonSchema\n\t\t\t},\n\t\t\t...ifDefined(\"children\", validatorChildren.length > 0 ? validatorChildren : void 0)\n\t\t}));\n\t}\n\tif (collection.options) {\n\t\tconst opts = collection.options;\n\t\tconst optLabels = [];\n\t\tif (opts.capped) optLabels.push(\"capped\");\n\t\tif (opts.timeseries) optLabels.push(\"timeseries\");\n\t\tif (opts.collation) optLabels.push(\"collation\");\n\t\tif (opts.changeStreamPreAndPostImages) optLabels.push(\"changeStreamPreAndPostImages\");\n\t\tif (opts.clusteredIndex) optLabels.push(\"clusteredIndex\");\n\t\tif (optLabels.length > 0) children.push(new SchemaTreeNode({\n\t\t\tkind: \"field\",\n\t\t\tid: `options-${name}`,\n\t\t\tlabel: `options (${optLabels.join(\", \")})`,\n\t\t\tmeta: {\n\t\t\t\t...ifDefined(\"capped\", opts.capped ?? void 0),\n\t\t\t\t...ifDefined(\"timeseries\", opts.timeseries ?? void 0),\n\t\t\t\t...ifDefined(\"collation\", opts.collation ?? void 0),\n\t\t\t\t...ifDefined(\"changeStreamPreAndPostImages\", opts.changeStreamPreAndPostImages ?? void 0),\n\t\t\t\t...ifDefined(\"clusteredIndex\", opts.clusteredIndex ?? void 0)\n\t\t\t}\n\t\t}));\n\t}\n\treturn new SchemaTreeNode({\n\t\tkind: \"collection\",\n\t\tid: `collection-${name}`,\n\t\tlabel: `collection ${name}`,\n\t\t...ifDefined(\"children\", children.length > 0 ? children : void 0)\n\t});\n}\n//#endregion\n//#region src/core/control-instance.ts\nfunction deserializeMongoContract(contractJson) {\n\treturn new MongoContractSerializer().deserializeContract(contractJson);\n}\n/**\n* Family-method contract input. By the time control-plane methods\n* (`verify`, `verifySchema`, `sign`, …) are invoked through the CLI\n* control client (`client.ts`), the input has already been threaded\n* through `familyInstance.deserializeContract`. The value is therefore a\n* class-form `MongoTargetContract` (or a structurally-equivalent\n* envelope post-deserialization) and must NOT be re-fed through\n* structural validation (arktype rejects extra keys like `namespaces`).\n*\n* The parameter type on the framework SPI is `unknown` for variance\n* reasons (so the family can express its own contract type without\n* leaking it to the framework). This helper recovers the validated\n* shape with a single narrow cast.\n*/\nfunction asValidatedMongoContract(contract) {\n\treturn contract;\n}\nfunction buildVerifyResult(opts) {\n\treturn {\n\t\tok: opts.ok,\n\t\t...ifDefined(\"code\", opts.code),\n\t\tsummary: opts.summary,\n\t\tcontract: {\n\t\t\tstorageHash: opts.contractStorageHash,\n\t\t\t...ifDefined(\"profileHash\", opts.contractProfileHash)\n\t\t},\n\t\t...ifDefined(\"marker\", opts.marker ? {\n\t\t\tstorageHash: opts.marker.storageHash,\n\t\t\tprofileHash: opts.marker.profileHash\n\t\t} : void 0),\n\t\ttarget: {\n\t\t\texpected: opts.expectedTargetId,\n\t\t\t...ifDefined(\"actual\", opts.actualTargetId)\n\t\t},\n\t\tmeta: {\n\t\t\tcontractPath: opts.contractPath,\n\t\t\t...ifDefined(\"configPath\", opts.configPath)\n\t\t},\n\t\ttimings: { total: opts.totalTime }\n\t};\n}\nfunction createMongoFamilyInstance(controlStack) {\n\tconst extensions = controlStack.extensions ?? [];\n\tfor (const extension of extensions) if (extension.contractSpace) {\n\t\tconst { contractJson, headRef } = extension.contractSpace;\n\t\tassertDescriptorSelfConsistency({\n\t\t\textensionId: extension.id,\n\t\t\ttarget: contractJson.target,\n\t\t\ttargetFamily: contractJson.targetFamily,\n\t\t\tstorage: contractJson.storage,\n\t\t\theadRefHash: headRef.hash,\n\t\t\t...mongoContractCanonicalizationHooks\n\t\t});\n\t}\n\tconst adapter = controlStack.adapter;\n\tconst getControlAdapter = () => {\n\t\tif (!adapter) throw new InternalError(\"Mongo family requires an adapter descriptor in ControlStack\");\n\t\treturn adapter.create(controlStack);\n\t};\n\tfunction isMongoTargetDriver(driver) {\n\t\treturn driver.targetId === \"mongo\";\n\t}\n\tfunction asMongoDriver(driver) {\n\t\tif (!isMongoTargetDriver(driver)) throw structuredError(\"CONTRACT.TARGET_MISMATCH\", `Expected Mongo control driver with targetId 'mongo', got '${driver.targetId}'`);\n\t\treturn driver;\n\t}\n\treturn {\n\t\tfamilyId: \"mongo\",\n\t\tdeserializeContract(contractJson) {\n\t\t\treturn deserializeMongoContract(contractJson);\n\t\t},\n\t\tasync verify(options) {\n\t\t\tconst { driver, contract: rawContract, expectedTargetId, contractPath, configPath } = options;\n\t\t\tconst startTime = Date.now();\n\t\t\tconst contract = asValidatedMongoContract(rawContract);\n\t\t\tconst contractStorageHash = contract.storage.storageHash;\n\t\t\tconst contractProfileHash = contract.profileHash;\n\t\t\tconst contractTarget = contract.target;\n\t\t\tconst baseOpts = {\n\t\t\t\tcontractStorageHash,\n\t\t\t\tcontractProfileHash,\n\t\t\t\texpectedTargetId,\n\t\t\t\tcontractPath,\n\t\t\t\t...ifDefined(\"configPath\", configPath)\n\t\t\t};\n\t\t\tif (contractTarget !== expectedTargetId) return buildVerifyResult({\n\t\t\t\t...baseOpts,\n\t\t\t\tok: false,\n\t\t\t\tcode: VERIFY_CODE_TARGET_MISMATCH,\n\t\t\t\tsummary: \"Target mismatch\",\n\t\t\t\tactualTargetId: contractTarget,\n\t\t\t\ttotalTime: Date.now() - startTime\n\t\t\t});\n\t\t\tconst marker = await getControlAdapter().readMarker(asMongoDriver(driver), APP_SPACE_ID);\n\t\t\tif (!marker) return buildVerifyResult({\n\t\t\t\t...baseOpts,\n\t\t\t\tok: false,\n\t\t\t\tcode: VERIFY_CODE_MARKER_MISSING,\n\t\t\t\tsummary: \"Marker missing\",\n\t\t\t\ttotalTime: Date.now() - startTime\n\t\t\t});\n\t\t\tif (marker.storageHash !== contractStorageHash) return buildVerifyResult({\n\t\t\t\t...baseOpts,\n\t\t\t\tok: false,\n\t\t\t\tcode: VERIFY_CODE_HASH_MISMATCH,\n\t\t\t\tsummary: \"Hash mismatch\",\n\t\t\t\tmarker,\n\t\t\t\ttotalTime: Date.now() - startTime\n\t\t\t});\n\t\t\tif (contractProfileHash && marker.profileHash !== contractProfileHash) return buildVerifyResult({\n\t\t\t\t...baseOpts,\n\t\t\t\tok: false,\n\t\t\t\tcode: VERIFY_CODE_HASH_MISMATCH,\n\t\t\t\tsummary: \"Hash mismatch\",\n\t\t\t\tmarker,\n\t\t\t\ttotalTime: Date.now() - startTime\n\t\t\t});\n\t\t\treturn buildVerifyResult({\n\t\t\t\t...baseOpts,\n\t\t\t\tok: true,\n\t\t\t\tsummary: \"Database matches contract\",\n\t\t\t\tmarker,\n\t\t\t\ttotalTime: Date.now() - startTime\n\t\t\t});\n\t\t},\n\t\tverifySchema(options) {\n\t\t\treturn verifyMongoSchema({\n\t\t\t\tcontract: asValidatedMongoContract(options.contract),\n\t\t\t\tschema: options.schema,\n\t\t\t\tstrict: options.strict,\n\t\t\t\tframeworkComponents: options.frameworkComponents\n\t\t\t});\n\t\t},\n\t\tasync sign(options) {\n\t\t\tconst { driver, contract: rawContract, contractPath, configPath } = options;\n\t\t\tconst startTime = Date.now();\n\t\t\tconst contract = asValidatedMongoContract(rawContract);\n\t\t\tconst contractStorageHash = contract.storage.storageHash;\n\t\t\tconst contractProfileHash = contract.profileHash;\n\t\t\tconst controlAdapter = getControlAdapter();\n\t\t\tconst mongoDriver = asMongoDriver(driver);\n\t\t\tconst existingMarker = await controlAdapter.readMarker(mongoDriver, APP_SPACE_ID);\n\t\t\tlet markerCreated = false;\n\t\t\tlet markerUpdated = false;\n\t\t\tlet previousHashes;\n\t\t\tif (!existingMarker) {\n\t\t\t\tawait controlAdapter.initMarker(mongoDriver, APP_SPACE_ID, {\n\t\t\t\t\tstorageHash: contractStorageHash,\n\t\t\t\t\tprofileHash: contractProfileHash\n\t\t\t\t});\n\t\t\t\tmarkerCreated = true;\n\t\t\t} else {\n\t\t\t\tconst storageHashMatches = existingMarker.storageHash === contractStorageHash;\n\t\t\t\tconst profileHashMatches = existingMarker.profileHash === contractProfileHash;\n\t\t\t\tif (!storageHashMatches || !profileHashMatches) {\n\t\t\t\t\tpreviousHashes = {\n\t\t\t\t\t\tstorageHash: existingMarker.storageHash,\n\t\t\t\t\t\tprofileHash: existingMarker.profileHash\n\t\t\t\t\t};\n\t\t\t\t\tif (!await controlAdapter.updateMarker(mongoDriver, APP_SPACE_ID, existingMarker.storageHash, {\n\t\t\t\t\t\tstorageHash: contractStorageHash,\n\t\t\t\t\t\tprofileHash: contractProfileHash\n\t\t\t\t\t})) throw structuredError(\"MIGRATION.MARKER_CAS_FAILURE\", \"CAS conflict: marker was modified by another process during sign\");\n\t\t\t\t\tmarkerUpdated = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\tlet summary;\n\t\t\tif (markerCreated) summary = \"Database signed (marker created)\";\n\t\t\telse if (markerUpdated) summary = `Database signed (marker updated from ${previousHashes?.storageHash ?? \"unknown\"})`;\n\t\t\telse summary = \"Database already signed with this contract\";\n\t\t\treturn {\n\t\t\t\tok: true,\n\t\t\t\tsummary,\n\t\t\t\tcontract: {\n\t\t\t\t\tstorageHash: contractStorageHash,\n\t\t\t\t\tprofileHash: contractProfileHash\n\t\t\t\t},\n\t\t\t\ttarget: {\n\t\t\t\t\texpected: contract.target,\n\t\t\t\t\tactual: contract.target\n\t\t\t\t},\n\t\t\t\tmarker: {\n\t\t\t\t\tcreated: markerCreated,\n\t\t\t\t\tupdated: markerUpdated,\n\t\t\t\t\t...ifDefined(\"previous\", previousHashes)\n\t\t\t\t},\n\t\t\t\tmeta: {\n\t\t\t\t\tcontractPath,\n\t\t\t\t\t...ifDefined(\"configPath\", configPath)\n\t\t\t\t},\n\t\t\t\ttimings: { total: Date.now() - startTime }\n\t\t\t};\n\t\t},\n\t\tasync readMarker(options) {\n\t\t\treturn getControlAdapter().readMarker(asMongoDriver(options.driver), options.space);\n\t\t},\n\t\tasync readAllMarkers(options) {\n\t\t\treturn getControlAdapter().readAllMarkers(asMongoDriver(options.driver));\n\t\t},\n\t\tasync readLedger(options) {\n\t\t\treturn getControlAdapter().readLedger(asMongoDriver(options.driver), options.space);\n\t\t},\n\t\tasync introspect(options) {\n\t\t\treturn getControlAdapter().introspectSchema(asMongoDriver(options.driver));\n\t\t},\n\t\ttoSchemaView(schema) {\n\t\t\treturn mongoSchemaToView(schema);\n\t\t},\n\t\ttoOperationPreview(operations) {\n\t\t\treturn mongoOperationsToPreview(operations);\n\t\t}\n\t};\n}\n//#endregion\n//#region src/core/control-descriptor.ts\nvar MongoFamilyDescriptor = class {\n\tkind = \"family\";\n\tid = \"mongo\";\n\tfamilyId = \"mongo\";\n\tversion = \"0.0.1\";\n\temission = mongoEmission;\n\tauthoring = {\n\t\tentityTypes: mongoFamilyEntityTypes,\n\t\tpslBlockDescriptors: mongoFamilyPslBlockDescriptors\n\t};\n\tcreate(stack) {\n\t\treturn createMongoFamilyInstance(stack);\n\t}\n};\nconst mongoFamilyDescriptor = new MongoFamilyDescriptor();\n//#endregion\nexport { canonicalizeSchemasForVerification, contractToMongoSchemaIR, createMongoFamilyInstance, diffMongoSchemas, formatMongoOperations, mongoFamilyDescriptor, mongoOperationsToPreview };\n\n//# sourceMappingURL=control.mjs.map"],"mappings":";;;;;;;;;;;AAWA,SAAS,cAAc,MAAM;CAC5B,OAAO,KAAK,KAAK,KAAK,MAAM,GAAG,KAAK,UAAU,EAAE,KAAK,EAAE,IAAI,KAAK,UAAU,EAAE,SAAS,GAAG,CAAC,CAAC,KAAK,IAAI,EAAE;AACtG;AACA,MAAM,oCAAoC,IAAI,IAAI;CACjD;CACA;CACA;AACD,CAAC;AACD,SAAS,oBAAoB,KAAK;CACjC,MAAM,QAAQ,OAAO,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC,KAAK,WAAW,CAAC,kBAAkB,IAAI,GAAG,KAAK,UAAU,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,WAAW,GAAG,IAAI,IAAI,KAAK,UAAU,KAAK,GAAG;CACpK,IAAI,MAAM,WAAW,GAAG,OAAO,KAAK;CACpC,OAAO,KAAK,MAAM,KAAK,IAAI,EAAE;AAC9B;AACA,SAAS,cAAc,KAAK;CAC3B,OAAO,oBAAoB,GAAG;AAC/B;AACA,SAAS,8BAA8B,KAAK;CAC3C,OAAO,oBAAoB,GAAG;AAC/B;AACA,IAAI,2BAA2B,MAAM;CACpC,YAAY,KAAK;EAChB,MAAM,UAAU,cAAc,IAAI,IAAI;EACtC,MAAM,OAAO,cAAc,GAAG;EAC9B,OAAO,OAAO,MAAM,IAAI,WAAW,eAAe,QAA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"./index-Cd2zLiU6.mjs";
3
+ import { o as MongoSchemaIR } from "./index-DxoO-ywI.mjs";
4
+ import { Contract, ControlPolicy } from "@prisma/orm-framework/contract/types";
5
+ import { ContractSerializer, ContractSpace, ControlExtensionDescriptor, ControlFamilyDescriptor, ControlFamilyInstance, ControlStack, MigratableTargetDescriptor, MigrationPlanOperation, OperationPreview, OperationPreviewCapable, SchemaDiffIssue, SchemaVerifier, SchemaViewCapable } from "@prisma/orm-framework/components/control";
6
+ //#region ../../../2-mongo-family/9-family/dist/control.d.mts
7
+ //#region src/core/contract-to-schema.d.ts
8
+ declare function contractToMongoSchemaIR(contract: MongoContract | null): MongoSchemaIR;
9
+ //#endregion
10
+ //#region src/core/control-instance.d.ts
11
+ interface MongoControlFamilyInstance extends ControlFamilyInstance<'mongo', MongoSchemaIR>, SchemaViewCapable<MongoSchemaIR>, OperationPreviewCapable {
12
+ /**
13
+ * The family seam-of-record for on-disk contract reads. Structurally
14
+ * validates the JSON envelope, then casts to the framework `Contract`
15
+ * shape; the per-target serializer (held on the Mongo target
16
+ * descriptor) does the class-form wrap for downstream consumers, so
17
+ * the family only needs the validated data. The single named entry
18
+ * point every CLI on-disk read crosses (TML-2536) — `as Contract`
19
+ * casts in production package sources are a serializer-bypass smell
20
+ * guarded by `pnpm lint:no-contract-cast`.
21
+ */
22
+ deserializeContract(contractJson: unknown): Contract;
23
+ }
24
+ declare function createMongoFamilyInstance(controlStack: ControlStack): MongoControlFamilyInstance;
25
+ //#endregion
26
+ //#region src/core/control-descriptor.d.ts
27
+ declare const mongoFamilyDescriptor: ControlFamilyDescriptor<'mongo', MongoControlFamilyInstance>;
28
+ //#endregion
29
+ //#region src/core/control-target-descriptor.d.ts
30
+ /**
31
+ * Mongo target control descriptor type. Extends the framework's
32
+ * `MigratableTargetDescriptor` with two named SPI properties next to
33
+ * the existing `migrations` capability:
34
+ *
35
+ * - `contractSerializer` — JSON to class boundary for Mongo contracts.
36
+ * - `schemaVerifier` — per-target verifier walking the family contract
37
+ * against `MongoSchemaIR`.
38
+ *
39
+ * The descriptor itself is the aggregator; no extra `Target<TContract,
40
+ * TSchema>` interface is introduced.
41
+ */
42
+ interface MongoControlTargetDescriptor<TContract extends MongoContract = MongoContract> extends MigratableTargetDescriptor<'mongo', 'mongo', MongoControlFamilyInstance> {
43
+ readonly contractSerializer: ContractSerializer<TContract>;
44
+ readonly schemaVerifier: SchemaVerifier<TContract, MongoSchemaIR>;
45
+ }
46
+ //#endregion
47
+ //#region src/core/control-types.d.ts
48
+ /**
49
+ * Mongo-family extension descriptor.
50
+ *
51
+ * Extensions that contribute schema opt into the per-space planner /
52
+ * runner / verifier by setting `contractSpace`. Extensions without it
53
+ * are codec-only or query-ops-only — today's behaviour preserved.
54
+ *
55
+ * The shape comes from `@internal/framework-components/control`
56
+ * (`ContractSpace`) — contract-space identity is a framework concept,
57
+ * not a Mongo-specific one. The Mongo family specialises the generic
58
+ * to `MongoContract<MongoStorageShape>` so descriptor authors see a
59
+ * typed contract value over the raw-JSON envelope shape; the runtime
60
+ * in-memory class `MongoStorage` structurally satisfies the shape.
61
+ * Mirrors `SqlControlExtensionDescriptor`.
62
+ */
63
+ interface MongoControlExtensionDescriptor extends ControlExtensionDescriptor<'mongo', 'mongo'> {
64
+ readonly contractSpace?: ContractSpace<MongoContract<MongoStorageShape>>;
65
+ }
66
+ //#endregion
67
+ //#region src/core/operation-preview.d.ts
68
+ declare function formatMongoOperations(operations: readonly MigrationPlanOperation[]): string[];
69
+ /**
70
+ * Wraps `formatMongoOperations` into the family-agnostic
71
+ * `OperationPreview` shape. Each statement carries
72
+ * `language: 'mongodb-shell'`. Mirrors `sqlOperationsToPreview`.
73
+ */
74
+ declare function mongoOperationsToPreview(operations: readonly MigrationPlanOperation[]): OperationPreview;
75
+ //#endregion
76
+ //#region src/core/schema-diff.d.ts
77
+ /**
78
+ * The Mongo schema diff, issue-only: `failures` carry the verdict (a verify
79
+ * passes exactly when it is empty), `warnings` the surviving warn-graded
80
+ * findings (live-only extras in non-strict mode, `observed` subjects).
81
+ *
82
+ * Each issue's `path` carries the coordinate — `[collectionName]` for a
83
+ * whole-collection finding, `[collectionName, 'index:…' | 'validator' |
84
+ * 'options']` for an auxiliary — and `expected`/`actual` carry the real
85
+ * Mongo schema-IR node the finding concerns.
86
+ */
87
+ interface MongoSchemaDiff {
88
+ readonly failures: readonly SchemaDiffIssue[];
89
+ readonly warnings: readonly SchemaDiffIssue[];
90
+ }
91
+ declare function diffMongoSchemas(live: MongoSchemaIR, expected: MongoSchemaIR, strict: boolean, collectionControlPolicy: (collectionName: string) => ControlPolicy): MongoSchemaDiff;
92
+ //#endregion
93
+ //#region src/core/schema-verify/canonicalize-introspection.d.ts
94
+ interface CanonicalizedSchemas {
95
+ readonly live: MongoSchemaIR;
96
+ readonly expected: MongoSchemaIR;
97
+ }
98
+ declare function canonicalizeSchemasForVerification(live: MongoSchemaIR, expected: MongoSchemaIR): CanonicalizedSchemas;
99
+ //#endregion
100
+ export { contractToMongoSchemaIR as a, formatMongoOperations as c, canonicalizeSchemasForVerification as i, mongoFamilyDescriptor as l, MongoControlFamilyInstance as n, createMongoFamilyInstance as o, MongoControlTargetDescriptor as r, diffMongoSchemas as s, MongoControlExtensionDescriptor as t, mongoOperationsToPreview as u };
101
+ //# sourceMappingURL=control-Cj81sPbj.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"control-Cj81sPbj.d.mts","names":[],"sources":["../../../../2-mongo-family/9-family/dist/control.d.mts"],"mappings":";;;;;;;iBAKiB,wBAAwB,UAAU,uBAAuB;;;UAGhE,mCAAmC,+BAA+B,gBAAgB,kBAAkB,gBAAgB;;;;;;;;;;;EAW5H,oBAAoB,wBAAwB;;iBAE7B,0BAA0B,cAAc,eAAe;;;cAG1D,uBAAuB,iCAAiC;;;;;;;;;;;;;;;UAe5D,6BAA6B,kBAAkB,gBAAgB,uBAAuB,6CAA6C;WAClI,oBAAoB,mBAAmB;WACvC,gBAAgB,eAAe,WAAW;;;;;;;;;;;;;;;;;;;UAmB3C,wCAAwC;WACvC,gBAAgB,cAAc,cAAc;;;;iBAItC,sBAAsB,qBAAqB;;;;;;iBAM3C,yBAAyB,qBAAqB,2BAA2B;;;;;;;;;;;;;UAahF;WACC,mBAAmB;WACnB,mBAAmB;;iBAEb,iBAAiB,MAAM,eAAe,UAAU,eAAe,iBAAiB,0BAA0B,2BAA2B,gBAAgB;;;UAG5J;WACC,MAAM;WACN,UAAU;;iBAEJ,mCAAmC,MAAM,eAAe,UAAU,gBAAgB"}
@@ -0,0 +1,83 @@
1
+ import { o as MongoSchemaIR } from "./index-DxoO-ywI.mjs";
2
+ import { ContractMarkerRecord, LedgerEntryRecord } from "@prisma/orm-framework/contract/types";
3
+ import { ControlAdapterDescriptor, ControlAdapterInstance, ControlDriverInstance } from "@prisma/orm-framework/components/control";
4
+ //#region ../../../2-mongo-family/9-family/dist/control-adapter.d.mts
5
+ //#region src/core/control-adapter.d.ts
6
+ /**
7
+ * Mongo control adapter interface for control-plane operations.
8
+ * Implemented by target-specific adapters (e.g. `@internal/adapter-mongo`).
9
+ *
10
+ * Mirrors `SqlControlAdapter` so the family layer dispatches every
11
+ * driver-bound wire operation through a single SPI surface instead of
12
+ * importing target-package internals directly. The adapter is the
13
+ * natural home for these method bodies because it owns both the
14
+ * `ControlDriverInstance` (which exposes the underlying `Db`) and the
15
+ * Mongo command vocabulary used to talk to it.
16
+ *
17
+ * @template TTarget - The target ID (today only `'mongo'`).
18
+ */
19
+ interface MongoControlAdapter<TTarget extends string = string> extends ControlAdapterInstance<'mongo', TTarget> {
20
+ /**
21
+ * Reads the contract marker document for `space`, or returns `null`
22
+ * if no marker document has been written for that space yet. Each
23
+ * space owns one document keyed by `_id: <space>` in the
24
+ * `_prisma_migrations` collection.
25
+ */
26
+ readMarker(driver: ControlDriverInstance<'mongo', TTarget>, space: string): Promise<ContractMarkerRecord | null>;
27
+ /**
28
+ * Reads every marker document (one per contract space) and returns
29
+ * them keyed by `space`. Used by the per-space verifier to detect
30
+ * marker-vs-on-disk drift and orphan marker rows. Returns an empty
31
+ * map when no marker documents exist yet.
32
+ */
33
+ readAllMarkers(driver: ControlDriverInstance<'mongo', TTarget>): Promise<ReadonlyMap<string, ContractMarkerRecord>>;
34
+ /**
35
+ * Inserts an initial marker document for the given space.
36
+ */
37
+ initMarker(driver: ControlDriverInstance<'mongo', TTarget>, space: string, destination: {
38
+ readonly storageHash: string;
39
+ readonly profileHash: string;
40
+ readonly invariants?: readonly string[];
41
+ }): Promise<void>;
42
+ /**
43
+ * Atomically updates the marker document for `space` (CAS on
44
+ * `expectedFrom`). Returns `true` when the CAS succeeded, `false`
45
+ * when another process advanced the marker first.
46
+ */
47
+ updateMarker(driver: ControlDriverInstance<'mongo', TTarget>, space: string, expectedFrom: string, destination: {
48
+ readonly storageHash: string;
49
+ readonly profileHash: string;
50
+ readonly invariants?: readonly string[];
51
+ }): Promise<boolean>;
52
+ /**
53
+ * Appends a ledger entry for the given space. Ledger entries co-exist
54
+ * with marker documents in the same collection; their key shape
55
+ * distinguishes them at read time.
56
+ */
57
+ writeLedgerEntry(driver: ControlDriverInstance<'mongo', TTarget>, space: string, entry: {
58
+ readonly edgeId: string;
59
+ readonly from: string;
60
+ readonly to: string;
61
+ readonly migrationName: string;
62
+ readonly migrationHash: string;
63
+ readonly operations: readonly unknown[];
64
+ }): Promise<void>;
65
+ /**
66
+ * Reads the per-migration ledger journal in apply order. When `space` is
67
+ * omitted, returns rows for every space.
68
+ */
69
+ readLedger(driver: ControlDriverInstance<'mongo', TTarget>, space?: string): Promise<readonly LedgerEntryRecord[]>;
70
+ /**
71
+ * Introspects the live database and returns a `MongoSchemaIR`.
72
+ */
73
+ introspectSchema(driver: ControlDriverInstance<'mongo', TTarget>): Promise<MongoSchemaIR>;
74
+ }
75
+ /**
76
+ * Mongo control adapter descriptor. Mirrors `SqlControlAdapterDescriptor`:
77
+ * extends the framework's `ControlAdapterDescriptor` and narrows the
78
+ * `create()` return to a `MongoControlAdapter<TTarget>`.
79
+ */
80
+ interface MongoControlAdapterDescriptor<TTarget extends string = string> extends ControlAdapterDescriptor<'mongo', TTarget, MongoControlAdapter<TTarget>> {}
81
+ //#endregion
82
+ export { MongoControlAdapterDescriptor as n, MongoControlAdapter as t };
83
+ //# sourceMappingURL=control-adapter-Db5pT77b.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"control-adapter-Db5pT77b.d.mts","names":[],"sources":["../../../../2-mongo-family/9-family/dist/control-adapter.d.mts"],"mappings":";;;;;;;;;;;;;;;;;;UAiBU,oBAAoB,yCAAyC,gCAAgC;;;;;;;EAOrG,WAAW,QAAQ,+BAA+B,UAAU,gBAAgB,QAAQ;;;;;;;EAOpF,eAAe,QAAQ,+BAA+B,WAAW,QAAQ,oBAAoB;;;;EAI7F,WAAW,QAAQ,+BAA+B,UAAU,eAAe;aAChE;aACA;aACA;MACP;;;;;;EAMJ,aAAa,QAAQ,+BAA+B,UAAU,eAAe,sBAAsB;aACxF;aACA;aACA;MACP;;;;;;EAMJ,iBAAiB,QAAQ,+BAA+B,UAAU,eAAe;aACtE;aACA;aACA;aACA;aACA;aACA;MACP;;;;;EAKJ,WAAW,QAAQ,+BAA+B,UAAU,iBAAiB,iBAAiB;;;;EAI9F,iBAAiB,QAAQ,+BAA+B,WAAW,QAAQ;;;;;;;UAOnE,8BAA8B,yCAAyC,kCAAkC,SAAS,oBAAoB"}
@@ -0,0 +1,19 @@
1
+ //#region ../../../2-mongo-family/1-foundation/mongo-value/dist/index.mjs
2
+ var MongoParamRef = class MongoParamRef {
3
+ value;
4
+ name;
5
+ codecId;
6
+ constructor(value, options) {
7
+ this.value = value;
8
+ this.name = options?.name;
9
+ this.codecId = options?.codecId;
10
+ Object.freeze(this);
11
+ }
12
+ static of(value, options) {
13
+ return new MongoParamRef(value, options);
14
+ }
15
+ };
16
+ //#endregion
17
+ export { MongoParamRef as t };
18
+
19
+ //# sourceMappingURL=dist-C7Ykq48Q.mjs.map