@prisma/orm-mongo 8.0.0-rc.16-dev.5 → 8.0.0-rc.16-dev.7

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.
@@ -1,10 +1,10 @@
1
1
  import { MongoRawClient } from "@prisma/orm-family-mongo/orm";
2
2
  import { MongoExecutionContext } from "@prisma/orm-family-mongo/runtime";
3
- import { NamespacedEnums } from "@prisma/orm-framework/contract/enum-accessor";
4
3
  import { UNBOUND_NAMESPACE_ID } from "@prisma/orm-framework/components/ir";
5
4
  import { mongoQuery } from "@prisma/orm-family-mongo/query-builder";
5
+ import { NamespacedEnums } from "@prisma/orm-framework/contract/enum-accessor";
6
6
  import { AnyMongoTypeMaps, MongoContract, MongoContractWithTypeMaps } from "@prisma/orm-family-mongo/contract";
7
- //#region ../../../3-extensions/mongo/dist/mongo-static-BdSGXYgQ.d.mts
7
+ //#region ../../../3-extensions/mongo/dist/mongo-static-CHHCsRvL.d.mts
8
8
  //#region src/static/mongo-static.d.ts
9
9
  type UnboundEnums<TContract extends MongoContractWithTypeMaps<MongoContract, AnyMongoTypeMaps>> = NamespacedEnums<TContract>[typeof UNBOUND_NAMESPACE_ID];
10
10
  interface MongoStaticContext<TContract extends MongoContractWithTypeMaps<MongoContract, AnyMongoTypeMaps>> {
@@ -19,4 +19,4 @@ declare function mongoStatic<TContract extends MongoContractWithTypeMaps<MongoCo
19
19
  }): MongoStaticContext<TContract>;
20
20
  //#endregion
21
21
  export { mongoStatic as n, MongoStaticContext as t };
22
- //# sourceMappingURL=mongo-static-BdSGXYgQ-DSA-2DiK.d.mts.map
22
+ //# sourceMappingURL=mongo-static-CHHCsRvL-DXMjx76B.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mongo-static-BdSGXYgQ-DSA-2DiK.d.mts","names":[],"sources":["../../../../3-extensions/mongo/dist/mongo-static-BdSGXYgQ.d.mts"],"mappings":";;;;;;;;KAOK,aAAa,kBAAkB,0BAA0B,eAAe,qBAAqB,gBAAgB,kBAAkB;UAC1H,mBAAmB,kBAAkB,0BAA0B,eAAe;WAC7E,SAAS,sBAAsB;WAC/B,UAAU;WACV,OAAO,aAAa;WACpB,OAAO,kBAAkB,WAAW;WACpC,KAAK,eAAe;;iBAEd,YAAY,kBAAkB,0BAA0B,eAAe,mBAAmB;WAChG;IACP,mBAAmB"}
1
+ {"version":3,"file":"mongo-static-CHHCsRvL-DXMjx76B.d.mts","names":[],"sources":["../../../../3-extensions/mongo/dist/mongo-static-CHHCsRvL.d.mts"],"mappings":";;;;;;;;KAOK,aAAa,kBAAkB,0BAA0B,eAAe,qBAAqB,gBAAgB,kBAAkB;UAC1H,mBAAmB,kBAAkB,0BAA0B,eAAe;WAC7E,SAAS,sBAAsB;WAC/B,UAAU;WACV,OAAO,aAAa;WACpB,OAAO,kBAAkB,WAAW;WACpC,KAAK,eAAe;;iBAEd,YAAY,kBAAkB,0BAA0B,eAAe,mBAAmB;WAChG;IACP,mBAAmB"}
@@ -1,30 +1,29 @@
1
1
  import { MongoContractSerializer } from "@prisma/orm-family-mongo/family/ir";
2
2
  import { mongoRaw } from "@prisma/orm-family-mongo/orm";
3
- import { createMongoExecutionContext, createMongoExecutionStack } from "@prisma/orm-family-mongo/runtime";
3
+ import { buildMongoEnums, createMongoExecutionContext, createMongoExecutionStack } from "@prisma/orm-family-mongo/runtime";
4
4
  import { blindCast } from "@prisma/orm-framework/utils/casts";
5
5
  import mongoRuntimeAdapter from "@prisma/orm-target-mongo/adapter/runtime";
6
- import { buildNamespacedEnums } from "@prisma/orm-framework/contract/enum-accessor";
7
6
  import { UNBOUND_NAMESPACE_ID } from "@prisma/orm-framework/components/ir";
8
7
  import { mongoQuery } from "@prisma/orm-family-mongo/query-builder";
9
8
  import mongoRuntimeTarget from "@prisma/orm-target-mongo/target/runtime";
10
9
  import { assertDefined } from "@prisma/orm-framework/utils/assertions";
11
- //#region ../../../3-extensions/mongo/dist/mongo-static-B2OhCUJZ.mjs
12
- function extractUnboundEnums(contract) {
13
- const enums = buildNamespacedEnums(contract.domain)[UNBOUND_NAMESPACE_ID];
14
- assertDefined(enums, "the unbound namespace always exists on a mongo builder output");
15
- return enums;
16
- }
10
+ //#region ../../../3-extensions/mongo/dist/mongo-static-UlmsQasy.mjs
17
11
  function buildMongoStaticContext(contract) {
12
+ const context = createMongoExecutionContext({
13
+ contract,
14
+ stack: createMongoExecutionStack({
15
+ target: mongoRuntimeTarget,
16
+ adapter: mongoRuntimeAdapter
17
+ })
18
+ });
19
+ const enumsByNamespace = buildMongoEnums(contract, context.codecs);
20
+ const unbound = enumsByNamespace[UNBOUND_NAMESPACE_ID];
21
+ assertDefined(unbound, "the unbound namespace always exists on a mongo builder output");
18
22
  return {
19
- context: createMongoExecutionContext({
20
- contract,
21
- stack: createMongoExecutionStack({
22
- target: mongoRuntimeTarget,
23
- adapter: mongoRuntimeAdapter
24
- })
25
- }),
23
+ context,
26
24
  contract,
27
- enums: extractUnboundEnums(contract),
25
+ enums: blindCast(unbound),
26
+ enumsByNamespace,
28
27
  query: mongoQuery({ contractJson: contract }),
29
28
  raw: mongoRaw({ contract })
30
29
  };
@@ -35,4 +34,4 @@ function mongoStatic(options) {
35
34
  //#endregion
36
35
  export { mongoStatic as n, buildMongoStaticContext as t };
37
36
 
38
- //# sourceMappingURL=mongo-static-B2OhCUJZ-1vCg8HI8.mjs.map
37
+ //# sourceMappingURL=mongo-static-UlmsQasy-DBZWYIip.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mongo-static-UlmsQasy-DBZWYIip.mjs","names":[],"sources":["../../../../3-extensions/mongo/dist/mongo-static-UlmsQasy.mjs"],"sourcesContent":["import { MongoContractSerializer } from \"@internal/family-mongo/ir\";\nimport { mongoRaw } from \"@internal/mongo-orm\";\nimport { buildMongoEnums, createMongoExecutionContext, createMongoExecutionStack } from \"@internal/mongo-runtime\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport mongoRuntimeAdapter from \"@internal/adapter-mongo/runtime\";\nimport { UNBOUND_NAMESPACE_ID } from \"@internal/framework-components/ir\";\nimport { mongoQuery } from \"@internal/mongo-query-builder\";\nimport mongoRuntimeTarget from \"@internal/target-mongo/runtime\";\nimport { assertDefined } from \"@internal/utils/assertions\";\n//#region src/static/mongo-static.ts\nfunction buildMongoStaticContext(contract) {\n\tconst context = createMongoExecutionContext({\n\t\tcontract,\n\t\tstack: createMongoExecutionStack({\n\t\t\ttarget: mongoRuntimeTarget,\n\t\t\tadapter: mongoRuntimeAdapter\n\t\t})\n\t});\n\tconst enumsByNamespace = buildMongoEnums(contract, context.codecs);\n\tconst unbound = enumsByNamespace[UNBOUND_NAMESPACE_ID];\n\tassertDefined(unbound, \"the unbound namespace always exists on a mongo builder output\");\n\treturn {\n\t\tcontext,\n\t\tcontract,\n\t\tenums: blindCast(unbound),\n\t\tenumsByNamespace,\n\t\tquery: mongoQuery({ contractJson: contract }),\n\t\traw: mongoRaw({ contract })\n\t};\n}\nfunction mongoStatic(options) {\n\treturn buildMongoStaticContext(blindCast(new MongoContractSerializer().deserializeContract(options.contractJson)));\n}\n//#endregion\nexport { mongoStatic as n, buildMongoStaticContext as t };\n\n//# sourceMappingURL=mongo-static-UlmsQasy.mjs.map"],"mappings":";;;;;;;;;;AAUA,SAAS,wBAAwB,UAAU;CAC1C,MAAM,UAAU,4BAA4B;EAC3C;EACA,OAAO,0BAA0B;GAChC,QAAQ;GACR,SAAS;EACV,CAAC;CACF,CAAC;CACD,MAAM,mBAAmB,gBAAgB,UAAU,QAAQ,MAAM;CACjE,MAAM,UAAU,iBAAiB;CACjC,cAAc,SAAS,+DAA+D;CACtF,OAAO;EACN;EACA;EACA,OAAO,UAAU,OAAO;EACxB;EACA,OAAO,WAAW,EAAE,cAAc,SAAS,CAAC;EAC5C,KAAK,SAAS,EAAE,SAAS,CAAC;CAC3B;AACD;AACA,SAAS,YAAY,SAAS;CAC7B,OAAO,wBAAwB,UAAU,IAAI,wBAAwB,CAAC,CAAC,oBAAoB,QAAQ,YAAY,CAAC,CAAC;AAClH"}
@@ -1,4 +1,4 @@
1
- import { t as MongoStaticContext } from "./mongo-static-BdSGXYgQ-DSA-2DiK.mjs";
1
+ import { t as MongoStaticContext } from "./mongo-static-CHHCsRvL-DXMjx76B.mjs";
2
2
  import { MongoClient as MongoClient$1 } from "mongodb";
3
3
  import { MongoOrmClient, MongoRawClient } from "@prisma/orm-family-mongo/orm";
4
4
  import { MongoExecutionContext, MongoMiddleware, MongoRuntime } from "@prisma/orm-family-mongo/runtime";
package/dist/runtime.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { t as buildMongoStaticContext } from "./mongo-static-B2OhCUJZ-1vCg8HI8.mjs";
1
+ import { t as buildMongoStaticContext } from "./mongo-static-UlmsQasy-DBZWYIip.mjs";
2
2
  import { ifDefined } from "@prisma/orm-framework/utils/defined";
3
3
  import { MongoContractSerializer } from "@prisma/orm-family-mongo/family/ir";
4
4
  import { mongoOrm } from "@prisma/orm-family-mongo/orm";
@@ -107,7 +107,7 @@ function resolveContract(options) {
107
107
  function mongo(options) {
108
108
  const contract = resolveContract(options);
109
109
  let binding = resolveOptionalMongoBinding(options);
110
- const { context, query, enums, raw } = buildMongoStaticContext(contract);
110
+ const { context, query, enums, enumsByNamespace, raw } = buildMongoStaticContext(contract);
111
111
  let runtimePromise;
112
112
  let closed = false;
113
113
  let ownedDispose;
@@ -147,7 +147,8 @@ function mongo(options) {
147
147
  query: queryRows,
148
148
  execute: executeStats
149
149
  },
150
- mutationDefaults: context
150
+ mutationDefaults: context,
151
+ enums: enumsByNamespace
151
152
  }),
152
153
  query,
153
154
  raw,
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.mjs","names":[],"sources":["../../../../3-extensions/mongo/dist/runtime.mjs"],"sourcesContent":["import { t as buildMongoStaticContext } from \"./mongo-static-B2OhCUJZ.mjs\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { MongoDriverImpl } from \"@internal/driver-mongo\";\nimport { MongoContractSerializer } from \"@internal/family-mongo/ir\";\nimport { AsyncIterableResult } from \"@internal/framework-components/runtime\";\nimport { mongoOrm } from \"@internal/mongo-orm\";\nimport { createMongoRuntime } from \"@internal/mongo-runtime\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { InternalError } from \"@internal/utils/internal-error\";\nimport { ConnectionString } from \"mongodb-connection-string-url\";\nimport { structuredError } from \"@internal/utils/structured-error\";\n//#region src/runtime/mongo-errors.ts\nfunction mongoError(code, message, options) {\n\treturn structuredError(code, message, {\n\t\t...options,\n\t\tmeta: {\n\t\t\t...options?.meta,\n\t\t\textension: \"mongo\"\n\t\t}\n\t});\n}\n//#endregion\n//#region src/runtime/binding.ts\nconst URL_SCHEME_PATTERN = /^([a-z][a-z\\d+.-]*):\\/\\//i;\nconst MONGO_SCHEMES = /* @__PURE__ */ new Set([\"mongodb\", \"mongodb+srv\"]);\nfunction validateMongoUrl(url) {\n\tconst trimmed = url.trim();\n\tif (trimmed.length === 0) throw mongoError(\"RUNTIME.BINDING_INVALID\", \"Mongo URL must be a non-empty string\");\n\tconst scheme = URL_SCHEME_PATTERN.exec(trimmed)?.[1];\n\tif (scheme === void 0) throw mongoError(\"RUNTIME.BINDING_INVALID\", \"Mongo URL must be a valid URL\");\n\tif (!MONGO_SCHEMES.has(scheme)) throw mongoError(\"RUNTIME.BINDING_INVALID\", \"Mongo URL must use mongodb:// or mongodb+srv://\");\n\ttry {\n\t\treturn new ConnectionString(trimmed);\n\t} catch {\n\t\tthrow mongoError(\"RUNTIME.BINDING_INVALID\", \"Mongo URL must be a valid URL\");\n\t}\n}\nfunction extractDbNameFromUrl(parsed) {\n\tconst [encodedDbName = \"\"] = parsed.pathname.slice(1).split(\"/\");\n\tif (encodedDbName.length === 0) return;\n\ttry {\n\t\treturn decodeURIComponent(encodedDbName);\n\t} catch {\n\t\tthrow mongoError(\"RUNTIME.BINDING_INVALID\", \"Mongo URL must be a valid URL\");\n\t}\n}\nfunction resolveMongoBinding(options) {\n\tconst providedCount = Number(options.binding !== void 0) + Number(options.url !== void 0) + Number(options.uri !== void 0) + Number(options.mongoClient !== void 0);\n\tif (providedCount !== 1) throw mongoError(\"RUNTIME.BINDING_INVALID\", \"Provide one binding input: binding, url, uri+dbName, or mongoClient+dbName\", { meta: { received: providedCount } });\n\tif (options.binding !== void 0) return options.binding;\n\tif (options.url !== void 0) {\n\t\tconst parsed = validateMongoUrl(options.url);\n\t\tif (options.dbName !== void 0 && options.dbName.trim().length === 0) throw mongoError(\"RUNTIME.BINDING_INVALID\", \"Mongo binding via { url, dbName } requires a non-empty dbName\");\n\t\tconst explicitDbName = options.dbName?.trim();\n\t\tconst dbName = explicitDbName !== void 0 && explicitDbName.length > 0 ? explicitDbName : extractDbNameFromUrl(parsed);\n\t\tif (dbName === void 0 || dbName.length === 0) throw mongoError(\"RUNTIME.BINDING_INVALID\", \"Mongo URL must include a database name in its path (e.g. mongodb://host:27017/mydb), or pass dbName explicitly\");\n\t\treturn {\n\t\t\tkind: \"url\",\n\t\t\turl: options.url.trim(),\n\t\t\tdbName\n\t\t};\n\t}\n\tif (options.uri !== void 0) {\n\t\tvalidateMongoUrl(options.uri);\n\t\tconst dbName = options.dbName?.trim();\n\t\tif (dbName === void 0 || dbName.length === 0) throw mongoError(\"RUNTIME.BINDING_INVALID\", \"Mongo binding via { uri, dbName } requires a non-empty dbName\");\n\t\treturn {\n\t\t\tkind: \"url\",\n\t\t\turl: options.uri.trim(),\n\t\t\tdbName\n\t\t};\n\t}\n\tconst mongoClient = options.mongoClient;\n\tif (mongoClient === void 0) throw new InternalError(\"Invariant violation: expected mongo binding after validation\");\n\tconst dbName = options.dbName?.trim();\n\tif (dbName === void 0 || dbName.length === 0) throw mongoError(\"RUNTIME.BINDING_INVALID\", \"Mongo binding via { mongoClient, dbName } requires a non-empty dbName\");\n\treturn {\n\t\tkind: \"mongoClient\",\n\t\tclient: mongoClient,\n\t\tdbName\n\t};\n}\nfunction resolveOptionalMongoBinding(options) {\n\tconst providedCount = Number(options.binding !== void 0) + Number(options.url !== void 0) + Number(options.uri !== void 0) + Number(options.mongoClient !== void 0);\n\tif (providedCount === 0) return;\n\tif (providedCount !== 1) throw mongoError(\"RUNTIME.BINDING_INVALID\", \"Provide one binding input: binding, url, uri+dbName, or mongoClient+dbName\", { meta: { received: providedCount } });\n\tif (options.binding !== void 0) return resolveMongoBinding({ binding: options.binding });\n\tif (options.url !== void 0) return resolveMongoBinding(options.dbName !== void 0 ? {\n\t\turl: options.url,\n\t\tdbName: options.dbName\n\t} : { url: options.url });\n\tif (options.uri !== void 0) return resolveMongoBinding({\n\t\turi: options.uri,\n\t\tdbName: options.dbName ?? \"\"\n\t});\n\tif (options.mongoClient !== void 0) return resolveMongoBinding({\n\t\tmongoClient: options.mongoClient,\n\t\tdbName: options.dbName ?? \"\"\n\t});\n\tthrow new InternalError(\"Invariant violation: expected one mongo binding branch\");\n}\n//#endregion\n//#region src/runtime/mongo.ts\nfunction hasContractJson(options) {\n\treturn \"contractJson\" in options;\n}\nfunction resolveContract(options) {\n\tconst contractInput = hasContractJson(options) ? options.contractJson : options.contract;\n\treturn blindCast(new MongoContractSerializer().deserializeContract(contractInput));\n}\nfunction mongo(options) {\n\tconst contract = resolveContract(options);\n\tlet binding = resolveOptionalMongoBinding(options);\n\tconst { context, query, enums, raw } = buildMongoStaticContext(contract);\n\tlet runtimePromise;\n\tlet closed = false;\n\tlet ownedDispose;\n\tconst buildRuntime = async (resolvedBinding) => {\n\t\tconst driver = resolvedBinding.kind === \"url\" ? await MongoDriverImpl.fromConnection(resolvedBinding.url, resolvedBinding.dbName) : MongoDriverImpl.fromDb(resolvedBinding.client.db(resolvedBinding.dbName));\n\t\tif (resolvedBinding.kind === \"url\") ownedDispose = () => driver.close();\n\t\treturn createMongoRuntime({\n\t\t\tcontext,\n\t\t\tdriver,\n\t\t\t...ifDefined(\"mode\", options.mode),\n\t\t\t...ifDefined(\"middleware\", options.middleware)\n\t\t});\n\t};\n\tconst getRuntime = () => {\n\t\tif (closed) return Promise.reject(mongoError(\"DRIVER.NOT_CONNECTED\", \"Mongo client is closed\"));\n\t\tif (runtimePromise !== void 0) return runtimePromise;\n\t\tif (binding === void 0) return Promise.reject(mongoError(\"RUNTIME.BINDING_MISSING\", \"Mongo binding not configured. Pass url/uri+dbName/mongoClient+dbName/binding to mongo(...) or call db.connect({ ... }).\"));\n\t\truntimePromise = buildRuntime(binding).catch((err) => {\n\t\t\truntimePromise = void 0;\n\t\t\tthrow err;\n\t\t});\n\t\treturn runtimePromise;\n\t};\n\tfunction queryRows(plan) {\n\t\tasync function* iterate() {\n\t\t\tyield* (await getRuntime()).query(plan);\n\t\t}\n\t\treturn new AsyncIterableResult(iterate());\n\t}\n\tasync function executeStats(plan) {\n\t\treturn (await getRuntime()).execute(plan);\n\t}\n\treturn {\n\t\torm: mongoOrm({\n\t\t\tcontract,\n\t\t\texecutor: {\n\t\t\t\tquery: queryRows,\n\t\t\t\texecute: executeStats\n\t\t\t},\n\t\t\tmutationDefaults: context\n\t\t}),\n\t\tquery,\n\t\traw,\n\t\tcontract,\n\t\tenums,\n\t\tcontext,\n\t\tasync connect(bindingInput) {\n\t\t\tif (closed) throw mongoError(\"DRIVER.NOT_CONNECTED\", \"Mongo client is closed\");\n\t\t\tif (runtimePromise !== void 0) throw mongoError(\"DRIVER.ALREADY_CONNECTED\", \"Mongo client already connected\");\n\t\t\tif (bindingInput !== void 0) binding = resolveMongoBinding(bindingInput);\n\t\t\tif (binding === void 0) throw mongoError(\"RUNTIME.BINDING_MISSING\", \"Mongo binding not configured. Pass url/uri+dbName/mongoClient+dbName/binding to mongo(...) or call db.connect({ ... }).\");\n\t\t\treturn getRuntime();\n\t\t},\n\t\truntime() {\n\t\t\treturn getRuntime();\n\t\t},\n\t\tasync close() {\n\t\t\tif (closed) return;\n\t\t\tclosed = true;\n\t\t\tif (runtimePromise === void 0) return;\n\t\t\ttry {\n\t\t\t\tawait runtimePromise;\n\t\t\t} catch {}\n\t\t\tconst dispose = ownedDispose;\n\t\t\townedDispose = void 0;\n\t\t\tawait dispose?.();\n\t\t},\n\t\t[Symbol.asyncDispose]() {\n\t\t\treturn this.close();\n\t\t}\n\t};\n}\n//#endregion\nexport { mongo as default };\n\n//# sourceMappingURL=runtime.mjs.map"],"mappings":";;;;;;;;;;;;AAYA,SAAS,WAAW,MAAM,SAAS,SAAS;CAC3C,OAAO,gBAAgB,MAAM,SAAS;EACrC,GAAG;EACH,MAAM;GACL,GAAG,SAAS;GACZ,WAAW;EACZ;CACD,CAAC;AACF;AAGA,MAAM,qBAAqB;AAC3B,MAAM,gCAAgC,IAAI,IAAI,CAAC,WAAW,aAAa,CAAC;AACxE,SAAS,iBAAiB,KAAK;CAC9B,MAAM,UAAU,IAAI,KAAK;CACzB,IAAI,QAAQ,WAAW,GAAG,MAAM,WAAW,2BAA2B,sCAAsC;CAC5G,MAAM,SAAS,mBAAmB,KAAK,OAAO,CAAC,GAAG;CAClD,IAAI,WAAW,KAAK,GAAG,MAAM,WAAW,2BAA2B,+BAA+B;CAClG,IAAI,CAAC,cAAc,IAAI,MAAM,GAAG,MAAM,WAAW,2BAA2B,iDAAiD;CAC7H,IAAI;EACH,OAAO,IAAI,iBAAiB,OAAO;CACpC,QAAQ;EACP,MAAM,WAAW,2BAA2B,+BAA+B;CAC5E;AACD;AACA,SAAS,qBAAqB,QAAQ;CACrC,MAAM,CAAC,gBAAgB,MAAM,OAAO,SAAS,MAAM,CAAC,CAAC,CAAC,MAAM,GAAG;CAC/D,IAAI,cAAc,WAAW,GAAG;CAChC,IAAI;EACH,OAAO,mBAAmB,aAAa;CACxC,QAAQ;EACP,MAAM,WAAW,2BAA2B,+BAA+B;CAC5E;AACD;AACA,SAAS,oBAAoB,SAAS;CACrC,MAAM,gBAAgB,OAAO,QAAQ,YAAY,KAAK,CAAC,IAAI,OAAO,QAAQ,QAAQ,KAAK,CAAC,IAAI,OAAO,QAAQ,QAAQ,KAAK,CAAC,IAAI,OAAO,QAAQ,gBAAgB,KAAK,CAAC;CACl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Z,SAAS;GACT,IAAI,mBAAmB,KAAK,GAAG;GAC/B,IAAI;IACH,MAAM;GACP,QAAQ,CAAC;GACT,MAAM,UAAU;GAChB,eAAe,KAAK;GACpB,MAAM,UAAU;EACjB;EACA,CAAC,OAAO,gBAAgB;GACvB,OAAO,KAAK,MAAM;EACnB;CACD;AACD"}
1
+ {"version":3,"file":"runtime.mjs","names":[],"sources":["../../../../3-extensions/mongo/dist/runtime.mjs"],"sourcesContent":["import { t as buildMongoStaticContext } from \"./mongo-static-UlmsQasy.mjs\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { MongoDriverImpl } from \"@internal/driver-mongo\";\nimport { MongoContractSerializer } from \"@internal/family-mongo/ir\";\nimport { AsyncIterableResult } from \"@internal/framework-components/runtime\";\nimport { mongoOrm } from \"@internal/mongo-orm\";\nimport { createMongoRuntime } from \"@internal/mongo-runtime\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { InternalError } from \"@internal/utils/internal-error\";\nimport { ConnectionString } from \"mongodb-connection-string-url\";\nimport { structuredError } from \"@internal/utils/structured-error\";\n//#region src/runtime/mongo-errors.ts\nfunction mongoError(code, message, options) {\n\treturn structuredError(code, message, {\n\t\t...options,\n\t\tmeta: {\n\t\t\t...options?.meta,\n\t\t\textension: \"mongo\"\n\t\t}\n\t});\n}\n//#endregion\n//#region src/runtime/binding.ts\nconst URL_SCHEME_PATTERN = /^([a-z][a-z\\d+.-]*):\\/\\//i;\nconst MONGO_SCHEMES = /* @__PURE__ */ new Set([\"mongodb\", \"mongodb+srv\"]);\nfunction validateMongoUrl(url) {\n\tconst trimmed = url.trim();\n\tif (trimmed.length === 0) throw mongoError(\"RUNTIME.BINDING_INVALID\", \"Mongo URL must be a non-empty string\");\n\tconst scheme = URL_SCHEME_PATTERN.exec(trimmed)?.[1];\n\tif (scheme === void 0) throw mongoError(\"RUNTIME.BINDING_INVALID\", \"Mongo URL must be a valid URL\");\n\tif (!MONGO_SCHEMES.has(scheme)) throw mongoError(\"RUNTIME.BINDING_INVALID\", \"Mongo URL must use mongodb:// or mongodb+srv://\");\n\ttry {\n\t\treturn new ConnectionString(trimmed);\n\t} catch {\n\t\tthrow mongoError(\"RUNTIME.BINDING_INVALID\", \"Mongo URL must be a valid URL\");\n\t}\n}\nfunction extractDbNameFromUrl(parsed) {\n\tconst [encodedDbName = \"\"] = parsed.pathname.slice(1).split(\"/\");\n\tif (encodedDbName.length === 0) return;\n\ttry {\n\t\treturn decodeURIComponent(encodedDbName);\n\t} catch {\n\t\tthrow mongoError(\"RUNTIME.BINDING_INVALID\", \"Mongo URL must be a valid URL\");\n\t}\n}\nfunction resolveMongoBinding(options) {\n\tconst providedCount = Number(options.binding !== void 0) + Number(options.url !== void 0) + Number(options.uri !== void 0) + Number(options.mongoClient !== void 0);\n\tif (providedCount !== 1) throw mongoError(\"RUNTIME.BINDING_INVALID\", \"Provide one binding input: binding, url, uri+dbName, or mongoClient+dbName\", { meta: { received: providedCount } });\n\tif (options.binding !== void 0) return options.binding;\n\tif (options.url !== void 0) {\n\t\tconst parsed = validateMongoUrl(options.url);\n\t\tif (options.dbName !== void 0 && options.dbName.trim().length === 0) throw mongoError(\"RUNTIME.BINDING_INVALID\", \"Mongo binding via { url, dbName } requires a non-empty dbName\");\n\t\tconst explicitDbName = options.dbName?.trim();\n\t\tconst dbName = explicitDbName !== void 0 && explicitDbName.length > 0 ? explicitDbName : extractDbNameFromUrl(parsed);\n\t\tif (dbName === void 0 || dbName.length === 0) throw mongoError(\"RUNTIME.BINDING_INVALID\", \"Mongo URL must include a database name in its path (e.g. mongodb://host:27017/mydb), or pass dbName explicitly\");\n\t\treturn {\n\t\t\tkind: \"url\",\n\t\t\turl: options.url.trim(),\n\t\t\tdbName\n\t\t};\n\t}\n\tif (options.uri !== void 0) {\n\t\tvalidateMongoUrl(options.uri);\n\t\tconst dbName = options.dbName?.trim();\n\t\tif (dbName === void 0 || dbName.length === 0) throw mongoError(\"RUNTIME.BINDING_INVALID\", \"Mongo binding via { uri, dbName } requires a non-empty dbName\");\n\t\treturn {\n\t\t\tkind: \"url\",\n\t\t\turl: options.uri.trim(),\n\t\t\tdbName\n\t\t};\n\t}\n\tconst mongoClient = options.mongoClient;\n\tif (mongoClient === void 0) throw new InternalError(\"Invariant violation: expected mongo binding after validation\");\n\tconst dbName = options.dbName?.trim();\n\tif (dbName === void 0 || dbName.length === 0) throw mongoError(\"RUNTIME.BINDING_INVALID\", \"Mongo binding via { mongoClient, dbName } requires a non-empty dbName\");\n\treturn {\n\t\tkind: \"mongoClient\",\n\t\tclient: mongoClient,\n\t\tdbName\n\t};\n}\nfunction resolveOptionalMongoBinding(options) {\n\tconst providedCount = Number(options.binding !== void 0) + Number(options.url !== void 0) + Number(options.uri !== void 0) + Number(options.mongoClient !== void 0);\n\tif (providedCount === 0) return;\n\tif (providedCount !== 1) throw mongoError(\"RUNTIME.BINDING_INVALID\", \"Provide one binding input: binding, url, uri+dbName, or mongoClient+dbName\", { meta: { received: providedCount } });\n\tif (options.binding !== void 0) return resolveMongoBinding({ binding: options.binding });\n\tif (options.url !== void 0) return resolveMongoBinding(options.dbName !== void 0 ? {\n\t\turl: options.url,\n\t\tdbName: options.dbName\n\t} : { url: options.url });\n\tif (options.uri !== void 0) return resolveMongoBinding({\n\t\turi: options.uri,\n\t\tdbName: options.dbName ?? \"\"\n\t});\n\tif (options.mongoClient !== void 0) return resolveMongoBinding({\n\t\tmongoClient: options.mongoClient,\n\t\tdbName: options.dbName ?? \"\"\n\t});\n\tthrow new InternalError(\"Invariant violation: expected one mongo binding branch\");\n}\n//#endregion\n//#region src/runtime/mongo.ts\nfunction hasContractJson(options) {\n\treturn \"contractJson\" in options;\n}\nfunction resolveContract(options) {\n\tconst contractInput = hasContractJson(options) ? options.contractJson : options.contract;\n\treturn blindCast(new MongoContractSerializer().deserializeContract(contractInput));\n}\nfunction mongo(options) {\n\tconst contract = resolveContract(options);\n\tlet binding = resolveOptionalMongoBinding(options);\n\tconst { context, query, enums, enumsByNamespace, raw } = buildMongoStaticContext(contract);\n\tlet runtimePromise;\n\tlet closed = false;\n\tlet ownedDispose;\n\tconst buildRuntime = async (resolvedBinding) => {\n\t\tconst driver = resolvedBinding.kind === \"url\" ? await MongoDriverImpl.fromConnection(resolvedBinding.url, resolvedBinding.dbName) : MongoDriverImpl.fromDb(resolvedBinding.client.db(resolvedBinding.dbName));\n\t\tif (resolvedBinding.kind === \"url\") ownedDispose = () => driver.close();\n\t\treturn createMongoRuntime({\n\t\t\tcontext,\n\t\t\tdriver,\n\t\t\t...ifDefined(\"mode\", options.mode),\n\t\t\t...ifDefined(\"middleware\", options.middleware)\n\t\t});\n\t};\n\tconst getRuntime = () => {\n\t\tif (closed) return Promise.reject(mongoError(\"DRIVER.NOT_CONNECTED\", \"Mongo client is closed\"));\n\t\tif (runtimePromise !== void 0) return runtimePromise;\n\t\tif (binding === void 0) return Promise.reject(mongoError(\"RUNTIME.BINDING_MISSING\", \"Mongo binding not configured. Pass url/uri+dbName/mongoClient+dbName/binding to mongo(...) or call db.connect({ ... }).\"));\n\t\truntimePromise = buildRuntime(binding).catch((err) => {\n\t\t\truntimePromise = void 0;\n\t\t\tthrow err;\n\t\t});\n\t\treturn runtimePromise;\n\t};\n\tfunction queryRows(plan) {\n\t\tasync function* iterate() {\n\t\t\tyield* (await getRuntime()).query(plan);\n\t\t}\n\t\treturn new AsyncIterableResult(iterate());\n\t}\n\tasync function executeStats(plan) {\n\t\treturn (await getRuntime()).execute(plan);\n\t}\n\treturn {\n\t\torm: mongoOrm({\n\t\t\tcontract,\n\t\t\texecutor: {\n\t\t\t\tquery: queryRows,\n\t\t\t\texecute: executeStats\n\t\t\t},\n\t\t\tmutationDefaults: context,\n\t\t\tenums: enumsByNamespace\n\t\t}),\n\t\tquery,\n\t\traw,\n\t\tcontract,\n\t\tenums,\n\t\tcontext,\n\t\tasync connect(bindingInput) {\n\t\t\tif (closed) throw mongoError(\"DRIVER.NOT_CONNECTED\", \"Mongo client is closed\");\n\t\t\tif (runtimePromise !== void 0) throw mongoError(\"DRIVER.ALREADY_CONNECTED\", \"Mongo client already connected\");\n\t\t\tif (bindingInput !== void 0) binding = resolveMongoBinding(bindingInput);\n\t\t\tif (binding === void 0) throw mongoError(\"RUNTIME.BINDING_MISSING\", \"Mongo binding not configured. Pass url/uri+dbName/mongoClient+dbName/binding to mongo(...) or call db.connect({ ... }).\");\n\t\t\treturn getRuntime();\n\t\t},\n\t\truntime() {\n\t\t\treturn getRuntime();\n\t\t},\n\t\tasync close() {\n\t\t\tif (closed) return;\n\t\t\tclosed = true;\n\t\t\tif (runtimePromise === void 0) return;\n\t\t\ttry {\n\t\t\t\tawait runtimePromise;\n\t\t\t} catch {}\n\t\t\tconst dispose = ownedDispose;\n\t\t\townedDispose = void 0;\n\t\t\tawait dispose?.();\n\t\t},\n\t\t[Symbol.asyncDispose]() {\n\t\t\treturn this.close();\n\t\t}\n\t};\n}\n//#endregion\nexport { mongo as default };\n\n//# sourceMappingURL=runtime.mjs.map"],"mappings":";;;;;;;;;;;;AAYA,SAAS,WAAW,MAAM,SAAS,SAAS;CAC3C,OAAO,gBAAgB,MAAM,SAAS;EACrC,GAAG;EACH,MAAM;GACL,GAAG,SAAS;GACZ,WAAW;EACZ;CACD,CAAC;AACF;AAGA,MAAM,qBAAqB;AAC3B,MAAM,gCAAgC,IAAI,IAAI,CAAC,WAAW,aAAa,CAAC;AACxE,SAAS,iBAAiB,KAAK;CAC9B,MAAM,UAAU,IAAI,KAAK;CACzB,IAAI,QAAQ,WAAW,GAAG,MAAM,WAAW,2BAA2B,sCAAsC;CAC5G,MAAM,SAAS,mBAAmB,KAAK,OAAO,CAAC,GAAG;CAClD,IAAI,WAAW,KAAK,GAAG,MAAM,WAAW,2BAA2B,+BAA+B;CAClG,IAAI,CAAC,cAAc,IAAI,MAAM,GAAG,MAAM,WAAW,2BAA2B,iDAAiD;CAC7H,IAAI;EACH,OAAO,IAAI,iBAAiB,OAAO;CACpC,QAAQ;EACP,MAAM,WAAW,2B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;CACA,OAAO;EACN,KAAK,SAAS;GACb;GACA,UAAU;IACT,OAAO;IACP,SAAS;GACV;GACA,kBAAkB;GAClB,OAAO;EACR,CAAC;EACD;EACA;EACA;EACA;EACA;EACA,MAAM,QAAQ,cAAc;GAC3B,IAAI,QAAQ,MAAM,WAAW,wBAAwB,wBAAwB;GAC7E,IAAI,mBAAmB,KAAK,GAAG,MAAM,WAAW,4BAA4B,gCAAgC;GAC5G,IAAI,iBAAiB,KAAK,GAAG,UAAU,oBAAoB,YAAY;GACvE,IAAI,YAAY,KAAK,GAAG,MAAM,WAAW,2BAA2B,yHAAyH;GAC7L,OAAO,WAAW;EACnB;EACA,UAAU;GACT,OAAO,WAAW;EACnB;EACA,MAAM,QAAQ;GACb,IAAI,QAAQ;GACZ,SAAS;GACT,IAAI,mBAAmB,KAAK,GAAG;GAC/B,IAAI;IACH,MAAM;GACP,QAAQ,CAAC;GACT,MAAM,UAAU;GAChB,eAAe,KAAK;GACpB,MAAM,UAAU;EACjB;EACA,CAAC,OAAO,gBAAgB;GACvB,OAAO,KAAK,MAAM;EACnB;CACD;AACD"}
package/dist/static.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { n as mongoStatic, t as MongoStaticContext } from "./mongo-static-BdSGXYgQ-DSA-2DiK.mjs";
1
+ import { n as mongoStatic, t as MongoStaticContext } from "./mongo-static-CHHCsRvL-DXMjx76B.mjs";
2
2
  export { type MongoStaticContext, mongoStatic as default };
package/dist/static.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { n as mongoStatic } from "./mongo-static-B2OhCUJZ-1vCg8HI8.mjs";
1
+ import { n as mongoStatic } from "./mongo-static-UlmsQasy-DBZWYIip.mjs";
2
2
  export { mongoStatic as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/orm-mongo",
3
- "version": "8.0.0-rc.16-dev.5",
3
+ "version": "8.0.0-rc.16-dev.7",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -10,18 +10,18 @@
10
10
  "skills"
11
11
  ],
12
12
  "dependencies": {
13
- "@prisma/orm-family-mongo": "8.0.0-rc.16-dev.5",
14
- "@prisma/orm-framework": "8.0.0-rc.16-dev.5",
15
- "@prisma/orm-target-mongo": "8.0.0-rc.16-dev.5",
16
- "@prisma/orm-toolchain": "8.0.0-rc.16-dev.5",
13
+ "@prisma/orm-family-mongo": "8.0.0-rc.16-dev.7",
14
+ "@prisma/orm-framework": "8.0.0-rc.16-dev.7",
15
+ "@prisma/orm-target-mongo": "8.0.0-rc.16-dev.7",
16
+ "@prisma/orm-toolchain": "8.0.0-rc.16-dev.7",
17
17
  "mongodb-connection-string-url": "^7.0.1",
18
18
  "pathe": "^2.0.3",
19
19
  "tinyglobby": "^0.2.17"
20
20
  },
21
21
  "devDependencies": {
22
- "@internal/mongo": "8.0.0-rc.16-dev.5",
23
- "@repo/tsconfig": "8.0.0-rc.16-dev.5",
24
- "@repo/tsdown": "8.0.0-rc.16-dev.5",
22
+ "@internal/mongo": "8.0.0-rc.16-dev.7",
23
+ "@repo/tsconfig": "8.0.0-rc.16-dev.7",
24
+ "@repo/tsdown": "8.0.0-rc.16-dev.7",
25
25
  "tsdown": "0.22.14",
26
26
  "typescript": "5.9.3"
27
27
  },
@@ -15,7 +15,7 @@ description: >-
15
15
  ORM 7 or earlier (schema.prisma + @prisma/client).
16
16
  metadata:
17
17
  library: '@prisma/orm-mongo'
18
- library_version: '8.0.0-rc.16-dev.5'
18
+ library_version: '8.0.0-rc.16-dev.7'
19
19
  version: '2026-09-12'
20
20
  ---
21
21
 
@@ -301,6 +301,12 @@ model User {
301
301
  }
302
302
  ```
303
303
 
304
+ **Reading members at runtime (`db.enums`).** `db.enums.<namespace>.<Enum>` on Postgres, and `db.enums.<Enum>` on SQLite and Mongo, holds each member as a query returns it: a `pg/int8@1` member written `Low = "1"` is `1n`, a date or timestamp member is the `Date` or Temporal value its codec reads, and a float member written `"NaN"` is `NaN`. So `db.enums.public.Level.members.Low === row.level` holds wherever `===` applies. `has(value)`, `nameOf(value)` and `ordinalOf(value)` find a value equal to a member: a string, number or bigint must be the member itself, and an object such as a `Date` must be of the member's kind and stored as the member is, so a date equal to a member matches although it is a different object. Text a codec would normalize, such as an upper-case uuid, is no member. Each read of a mutable member, such as a `Date` or a `Uint8Array`, returns a fresh copy, so changing it does not change the enum; a Temporal member is immutable and is the same value on every read. An enum's members are decoded when the enum is first read, so a client builds without `Temporal` even when its contract has a Temporal enum. `contract.d.ts` types each member as that same value. The rule behind this: the value a codec reads from the contract's stored form equals the value a query returns for it. The stored form itself can differ from the text the database prints, such as ISO 8601 for a timestamp.
305
+
306
+ **Codecs an enum cannot use.** An enum compares values with its members, so a codec whose values cannot be compared for equality, or whose values read back never equal a member as the contract stores it, is refused, in TypeScript with `CONTRACT.ENUM_INVALID` and in PSL with `PSL_EXTENSION_INVALID_VALUE` at the `@@type`. The message says why and what to use instead. On Postgres: `pg/timestamp-string@1` and `pg/timestamptz-string@1` (use `pg/timestamp-temporal@1` or `pg/timestamptz-temporal@1`), `pg/json@1` (use `pg/jsonb@1`), and `pg/bytea@1` and `pg/tsquery@1`, for which no enum is possible (use a text enum).
307
+
308
+ **Mongo enums.** A Mongo PSL contract's collection validator lists each enum's members in their stored JSON forms, so a PSL enum needs a codec whose BSON type JSON holds: string, int, double, bool, object or array, with finite numbers for doubles. An enum over `mongo/int64@1`, `mongo/date@1` or `mongo/objectId@1` is refused with `PSL_EXTENSION_INVALID_VALUE`. A TypeScript Mongo contract has no collection validator and accepts these enums.
309
+
304
310
  **Waiving enforcement (`@noCheck`).** A field can decline the generated CHECK constraints for its column: bare `@noCheck` waives every kind the column's shape derives; `@noCheck(membership)` and `@noCheck(elementNotNull)` waive one kind (`membership` is the enum value-set check; `elementNotNull` is the no-NULL-elements check every list column gets). The TS authoring equivalent is `.noCheck(...)` on the field builder. Declared types do not change: the field still types as the enum union, and a list still types with non-null elements — once enforcement is waived, runtime values may diverge from what the types claim. That divergence is the author's accepted risk, and it is scoped to the kinds actually waived: waiving `membership` stops the database rejecting out-of-set values, waiving `elementNotNull` stops it rejecting NULL elements. A list that waives only `membership` still rejects NULL elements. `contract infer` emits `@noCheck(elementNotNull)` automatically for list columns whose source database does not carry the generated check.
305
311
 
306
312
  Canonical worked example: `examples/prisma-8-demo/src/prisma/contract.prisma`.
@@ -427,11 +433,11 @@ Infer captures indexes at full fidelity — expression, partial (`where:`), uniq
427
433
  4. **Reaching into internal packages from user code.** User-authored files (`prisma.config.ts`, `contract.ts`, `db.ts`, control clients) import only from `@internal/<target>/<subpath>` and `@internal/extension-<name>/<subpath>`. Imports from `@internal/cli/*`, `@internal/family-*`, `@internal/target-*`, `@internal/adapter-*`, `@internal/driver-*`, or `@internal/sql-contract-*` are framework-internal — the façade composes them for you. If a façade subpath you need is missing for your target, see *What Prisma 8 doesn't do yet* and route to `references/feedback.md`. The canonical worked examples are `examples/multi-extension-monorepo/app/prisma.config.ts` and `examples/prisma-8-postgis-demo/prisma.config.ts`.
428
434
  5. **Confusing the config `extensions` with the TS builder's `extensions`.** Same packs, two surfaces, one field name but two shapes: `ormConfig({ extensions: [pgvector] })` (array of *control* descriptors from `@internal/extension-<name>/control`) versus `defineContract({ extensions: { pgvector } })` (record of *pack* descriptors from `@internal/extension-<name>/pack`).
429
435
  6. **Writing a flat `prisma.config.ts`.** `export default defineConfig({ contract, extensions })` from the target config alone is the pre-rc.4 shape and fails with `CONFIG.VERSION_MARKER_MISSING`. Wrap it: `definePrismaConfig({ orm: ormConfig({...}) })`.
430
- 7. **Renaming a field and expecting the planner to detect it.** Prisma 8 has no in-contract rename hint; the planner sees a destructive drop+add. Hand-edit `migration.ts` after `migration plan` (see `references/migrations.md`), or use the keep-then-drop two-migration pattern.
436
+ 7. **Renaming a model or field and expecting the planner to detect it.** The contract does not record renames, so the planner sees a destructive drop+add. State the rename on the command line with `--rename old:new` on `migration plan` or `db update` (see `references/migrations.md`); the planner then renames instead of dropping. Do not invent a rename attribute in the contract source.
431
437
 
432
438
  ## What Prisma 8 doesn't do yet
433
439
 
434
- - **In-contract rename hint.** No `@@rename(old: ..., new: ...)` or similar. Use the workarounds in *Common Pitfalls* #7. To request first-class rename, file via `references/feedback.md`.
440
+ - **In-contract rename hint.** No `@@rename(old: ..., new: ...)` or similar; renames are stated with `--rename` on the command line, as in *Common Pitfalls* #7.
435
441
  - **Model validations.** No declarative `@validates(...)` surface. Validate in application code (arktype). To request declarative validations in the contract, file via `references/feedback.md`.
436
442
  - **Lifecycle callbacks** (`beforeSave`, `afterCreate`, etc.). Not supported. Use middleware (`references/runtime.md`) or app code. To request lifecycle callbacks, file via `references/feedback.md`.
437
443
  - **Soft delete / `paranoid: true`.** No built-in soft-delete column. Add a nullable `deletedAt DateTime?` and filter explicitly in queries (or in middleware). To request built-in soft delete, file via `references/feedback.md`.
@@ -454,8 +460,8 @@ Infer captures indexes at full fidelity — expression, partial (`where:`), uniq
454
460
  - [ ] Edited the contract source (`contract.prisma` or `contract.ts`), not an emitted artefact.
455
461
  - [ ] For new extension namespaces: added the package, imported its control descriptor (`@internal/extension-<name>/control`), added it to `extensions: [...]` in `ormConfig({...})` (and the matching pack descriptor to `defineContract({extensions: {...}})` if using the TS builder).
456
462
  - [ ] `prisma.config.ts` is the envelope form — `definePrismaConfig({ orm: ormConfig({...}) })` — not a flat `defineConfig({...})`.
457
- - [ ] For renames: hand-edited `migration.ts` after `migration plan` (or used the keep-then-drop two-migration pattern) — Prisma 8 has no rename hint today.
463
+ - [ ] For renames: passed `--rename old:new` to `migration plan` or `db update` (or hand-edited `migration.ts` where statements do not cover the rename).
458
464
  - [ ] Ran `pnpm prisma contract emit` after the edit (or let the Vite plugin re-emit on save).
459
465
  - [ ] Confirmed `contract.json` and `contract.d.ts` updated next to the source.
460
466
  - [ ] Did **not** hand-edit `contract.json` / `contract.d.ts`.
461
- - [ ] Did **not** confabulate a missing feature (validations, callbacks, soft delete, scopes, in-contract rename hint) — referred the user to *What Prisma 8 doesn't do yet* + `references/feedback.md`.
467
+ - [ ] Did **not** confabulate a missing feature (validations, callbacks, soft delete, scopes, a rename attribute in the contract source) — referred the user to *What Prisma 8 doesn't do yet* + `references/feedback.md`.
@@ -74,6 +74,9 @@ Treat the rendered import lines as framework-managed on both targets:
74
74
  | `MIGRATION.DESTRUCTIVE_CHANGES` | `db update` run non-interactively without consent | Re-run with `--confirm <database>` (the database name from the connection), or `--dry-run` to preview. |
75
75
  | `CONTRACT.MARKER_MISMATCH` | `db verify` (finding, exit 4) | The marker disagrees with the contract hash (**Postgres:** `prisma_contract.marker`; **Mongo:** `_prisma_migrations`). The DB is at a different contract version than the code thinks. Either run a migration forward, or — if the DB is correct and the marker is stale after a manual fix-up — run `db sign`. |
76
76
  | `CONTRACT.MARKER_MISSING` | `db verify` (finding, exit 4), runtime startup (warning) | The DB has no marker yet. Run `prisma db init --db <url>` to baseline an empty database, `db update --db <url>` to apply the current contract directly, or `db sign --db <url>` if the schema already matches the contract. |
77
+ | `MIGRATION.STATEMENT_INVALID` | `migration plan` / `db update` with `--rename` | The statement is malformed, mixes a model and a field, renames something to itself, swaps two names, or repeats a name. The error's next step is the statement to type instead; use it. |
78
+ | `MIGRATION.STATEMENT_UNRESOLVED` | `migration plan` / `db update` with `--rename` | A name is not where a rename needs it. The error lists the names it found and says what to type: the statement the right way round, the order that works, or to leave out a rename that has already happened. |
79
+ | `MIGRATION.STATEMENT_ORIGIN_UNKNOWN` | `db update --rename` | `db update` has no snapshot of the contract the database is at. Follow the error's steps: emit that contract, run `db update --advance-ref <name> --dry-run` and check it plans no operations, then run it without `--dry-run` to store its snapshot, then emit the new contract and run the rename. Do not drop the statements to get past it: without them the plan drops the renamed table with its rows. |
77
80
 
78
81
  ## Decision — which path do you take?
79
82
 
@@ -359,7 +362,7 @@ On Postgres the operations are **methods on the `Migration` base class**, each t
359
362
  **Postgres** operations (representative set, all `this.<name>({...})`):
360
363
 
361
364
  - Tables: `createTable`, `renameTable`, `dropTable`. `renameTable` reads the migration's start and end contracts and returns the table rename plus a rename of every constraint and index named after the old table, so spread it: `...this.renameTable({ table: 'userProfile', to: 'UserProfile' })`.
362
- - Columns: `addColumn` (`column: col(name, nativeType, { codecRef })`), `dropColumn`, `alterColumnType`, `setNotNull`, `dropNotNull`, `setDefault` (`column: col(name, nativeType, { default: lit(value) or fn(expression), codecRef })`; `fn('autoincrement()')` on a smallint, integer or bigint column creates or reuses the `{table}_{column}_seq` sequence, attaches it, and starts it past the column's largest value), `dropDefault`.
365
+ - Columns: `addColumn` (`column: col(name, nativeType, { codecRef })`), `renameColumn` (also renames the constraints and indexes named after the column, so spread it: `...this.renameColumn({ table: 'User', column: 'email', to: 'emailAddress' })`), `dropColumn`, `alterColumnType`, `setNotNull`, `dropNotNull`, `setDefault` (`column: col(name, nativeType, { default: lit(value) or fn(expression), codecRef })`; `fn('autoincrement()')` on a smallint, integer or bigint column creates or reuses the `{table}_{column}_seq` sequence, attaches it, and starts it past the column's largest value), `dropDefault`.
363
366
  - Constraints: `addPrimaryKey`, `addForeignKey`, `addUnique`, `addCheckConstraint`, `renameConstraint` (`kind`: `primaryKey`, `unique`, `foreignKey` or `checkConstraint`), `renameCheckConstraint`, `dropCheckConstraint`, `dropConstraint`.
364
367
  - Indexes: `createIndex`, `renameIndex`, `dropIndex`.
365
368
  - Enums: `createNativeEnumType`, `addNativeEnumValue`, `dropNativeEnumType`.
@@ -494,7 +497,7 @@ Interactively, consent is typing the database name back (the prompt names it). I
494
497
  6. **Aggregate `check` closure in Postgres `this.dataTransform`.** Returning `count(*)` or `bool_and(...)` breaks the precheck/postcheck contract — both sides resolve to constants. Use a rowset shape: `select('id').where(<violation>).limit(1)`.
495
498
  7. **Two contract references in one migration.** Building a query plan against a different contract than the one passed to `this.dataTransform(endContract, ...)` raises `MIGRATION.DATA_TRANSFORM_CONTRACT_MISMATCH`. Always import `endContract` once at module scope and use the same reference.
496
499
  11. **Calling Postgres operations as free functions.** `addColumn('public', 'user', {...})` does not exist as an import; the operations are `this.addColumn({ schema, table, column })` and friends on the `Migration` base class, with `col(...)` building the column. Only `col`, `rawSql`, `placeholder`, `Migration`, and `MigrationCLI` are imported.
497
- 8. **Renaming and expecting the planner to detect it (Postgres).** Prisma 8 has no in-contract rename hint today; the planner emits a destructive drop+add. Hand-edit `migration.ts` to rewrite the destructive op as a `rawSql({ ... })` that issues `ALTER TABLE ... RENAME COLUMN ...` (or use the two-migration keep / backfill / drop pattern), then self-emit. See `references/contract.md` § *Edit a field — rename*.
500
+ 8. **Renaming a model or field without a statement (Postgres, SQLite).** The planner cannot tell a rename from a drop and a create, so without a statement it plans a destructive drop+add. State the rename on the command line: `migration plan --name <slug> --rename User:Person --rename Person.email:Person.emailAddress`, or the same `--rename` flags on `db update`. A field is named through its model as the new contract names it. The planner then renames the table or column and the constraints and indexes named after it. For a rename statements do not cover, such as a model that keeps its name but changes its `@@map`, hand-edit `migration.ts` with `...this.renameTable(...)` or `...this.renameColumn(...)`, then self-emit.
498
501
  9. **Planning with no `db` ref and no `--from` in a project that already has migrations.** The origin falls through to the empty database, which would make the plan a full-create migration; `migration plan` refuses with `MIGRATION.PLAN_ORIGIN_UNKNOWN` rather than writing it. Pick the exit that matches your intent — the error lists them, and `references/migration-model.md` § *The trap* explains which to choose.
499
502
  10. **Hand-authoring `migration.ts` from a blank file, or rewriting the rendered import line.** Migration files are framework-rendered — let `prisma migration plan` (or `migration new`) render the package, then edit only the holes the framework leaves for you. On Postgres leave the rendered `@internal/postgres/migration` (or `@internal/sqlite/migration`) import path alone; on Mongo leave `@prisma/orm-mongo/target/migration` as rendered. Add symbols to the existing import line rather than introducing new import paths.
500
503
 
@@ -503,7 +506,7 @@ Interactively, consent is typing the database name back (the prompt names it). I
503
506
  - **Runtime-apply migrations.** Prisma 8 doesn't apply pending migrations from your app's startup code (the "Drizzle pattern" for serverless / edge). Workaround: run `prisma db migrate` from your deploy pipeline before the app starts. If you need runtime-apply built-in, file a feature request via the `references/feedback.md` skill.
504
507
  - **Seeds-as-first-class.** Prisma 8 doesn't ship a `prisma db seed` equivalent. Workaround: write a TypeScript script that imports your `db` instance and runs your setup queries; invoke it from `package.json`'s scripts. If you need first-class seeding, file a feature request via the `references/feedback.md` skill.
505
508
  - **Migration squashing.** Prisma 8 doesn't squash older migrations into a baseline. They accumulate; for very large histories, manual baseline-and-truncate is the path. If you need built-in squashing, file a feature request via the `references/feedback.md` skill.
506
- - **In-contract rename hints.** The planner cannot detect that a field rename is a rename rather than a drop+add. Workaround: hand-edit `migration.ts` to issue a `RENAME COLUMN` via `rawSql(...)`, or use a keep / backfill / drop pattern across two migrations. If you need a contract-level rename hint, file a feature request via the `references/feedback.md` skill.
509
+ - **Renames beyond models and fields, and renames on MongoDB.** `--rename` covers models and fields on Postgres and SQLite. It does not rename enum values, namespaces or value objects, and does not move a model to another namespace. On MongoDB, `--rename` fails with `MIGRATION.PLANNING_FAILED` and plans nothing. Workaround: follow the error's advice and make the rename by hand in `mongosh` on each database, before a plan made without `--rename` is applied there: `renameCollection` for a model, and for a field turn off the collection's validator, drop each unique index that includes the field, then `updateMany({}, { $rename: ... })`. Applying the plan then creates the new indexes and turns the validator back on. There is no Mongo rename operation to write in `migration.ts`. If you need one of these, file a feature request via the `references/feedback.md` skill.
507
510
 
508
511
  ## Graph and history commands
509
512
 
@@ -1 +0,0 @@
1
- {"version":3,"file":"mongo-static-B2OhCUJZ-1vCg8HI8.mjs","names":[],"sources":["../../../../3-extensions/mongo/dist/mongo-static-B2OhCUJZ.mjs"],"sourcesContent":["import { MongoContractSerializer } from \"@internal/family-mongo/ir\";\nimport { mongoRaw } from \"@internal/mongo-orm\";\nimport { createMongoExecutionContext, createMongoExecutionStack } from \"@internal/mongo-runtime\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport mongoRuntimeAdapter from \"@internal/adapter-mongo/runtime\";\nimport { buildNamespacedEnums } from \"@internal/contract/enum-accessor\";\nimport { UNBOUND_NAMESPACE_ID } from \"@internal/framework-components/ir\";\nimport { mongoQuery } from \"@internal/mongo-query-builder\";\nimport mongoRuntimeTarget from \"@internal/target-mongo/runtime\";\nimport { assertDefined } from \"@internal/utils/assertions\";\n//#region src/static/mongo-static.ts\nfunction extractUnboundEnums(contract) {\n\tconst enums = buildNamespacedEnums(contract.domain)[UNBOUND_NAMESPACE_ID];\n\tassertDefined(enums, \"the unbound namespace always exists on a mongo builder output\");\n\treturn enums;\n}\nfunction buildMongoStaticContext(contract) {\n\treturn {\n\t\tcontext: createMongoExecutionContext({\n\t\t\tcontract,\n\t\t\tstack: createMongoExecutionStack({\n\t\t\t\ttarget: mongoRuntimeTarget,\n\t\t\t\tadapter: mongoRuntimeAdapter\n\t\t\t})\n\t\t}),\n\t\tcontract,\n\t\tenums: extractUnboundEnums(contract),\n\t\tquery: mongoQuery({ contractJson: contract }),\n\t\traw: mongoRaw({ contract })\n\t};\n}\nfunction mongoStatic(options) {\n\treturn buildMongoStaticContext(blindCast(new MongoContractSerializer().deserializeContract(options.contractJson)));\n}\n//#endregion\nexport { mongoStatic as n, buildMongoStaticContext as t };\n\n//# sourceMappingURL=mongo-static-B2OhCUJZ.mjs.map"],"mappings":";;;;;;;;;;;AAWA,SAAS,oBAAoB,UAAU;CACtC,MAAM,QAAQ,qBAAqB,SAAS,MAAM,CAAC,CAAC;CACpD,cAAc,OAAO,+DAA+D;CACpF,OAAO;AACR;AACA,SAAS,wBAAwB,UAAU;CAC1C,OAAO;EACN,SAAS,4BAA4B;GACpC;GACA,OAAO,0BAA0B;IAChC,QAAQ;IACR,SAAS;GACV,CAAC;EACF,CAAC;EACD;EACA,OAAO,oBAAoB,QAAQ;EACnC,OAAO,WAAW,EAAE,cAAc,SAAS,CAAC;EAC5C,KAAK,SAAS,EAAE,SAAS,CAAC;CAC3B;AACD;AACA,SAAS,YAAY,SAAS;CAC7B,OAAO,wBAAwB,UAAU,IAAI,wBAAwB,CAAC,CAAC,oBAAoB,QAAQ,YAAY,CAAC,CAAC;AAClH"}