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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (159) hide show
  1. package/README.md +4 -9
  2. package/dist/config.d.mts +12 -4
  3. package/dist/config.d.mts.map +1 -1
  4. package/dist/config.mjs +33 -18
  5. package/dist/config.mjs.map +1 -1
  6. package/dist/contract-builder.d.mts +14 -85
  7. package/dist/contract-builder.d.mts.map +1 -1
  8. package/dist/contract-builder.mjs +7 -2
  9. package/dist/contract-builder.mjs.map +1 -1
  10. package/dist/contract__validate-once.d.mts +1 -0
  11. package/dist/contract__validate-once.mjs +2 -0
  12. package/dist/control.d.mts +1 -1
  13. package/dist/control.d.mts.map +1 -1
  14. package/dist/control.mjs +1 -1
  15. package/dist/control.mjs.map +1 -1
  16. package/dist/family-contract__data-type.d.mts +1 -0
  17. package/dist/family-contract__data-type.mjs +2 -0
  18. package/dist/mongo-static-Cz5l8Wei-Cm-iMEyb.mjs +72 -0
  19. package/dist/mongo-static-Cz5l8Wei-Cm-iMEyb.mjs.map +1 -0
  20. package/dist/{mongo-static-BdSGXYgQ-DSA-2DiK.d.mts → mongo-static-D_RcLkSZ-DL_Qae5D.d.mts} +13 -4
  21. package/dist/mongo-static-D_RcLkSZ-DL_Qae5D.d.mts.map +1 -0
  22. package/dist/runtime.d.mts +19 -27
  23. package/dist/runtime.d.mts.map +1 -1
  24. package/dist/runtime.mjs +38 -21
  25. package/dist/runtime.mjs.map +1 -1
  26. package/dist/static.d.mts +24 -2
  27. package/dist/static.d.mts.map +1 -0
  28. package/dist/static.mjs +2 -2
  29. package/dist/target__codec-ids.d.mts +1 -0
  30. package/dist/target__codec-ids.mjs +2 -0
  31. package/dist/target__codecs.d.mts +1 -0
  32. package/dist/target__codecs.mjs +2 -0
  33. package/dist/target__data-types.d.mts +1 -0
  34. package/dist/target__data-types.mjs +2 -0
  35. package/dist/utils__suppress-idle-connection-errors.d.mts +1 -0
  36. package/dist/utils__suppress-idle-connection-errors.mjs +2 -0
  37. package/dist/utils__text.d.mts +1 -0
  38. package/dist/utils__text.mjs +2 -0
  39. package/package.json +23 -16
  40. package/skills/prisma-8/SKILL.md +96 -0
  41. package/skills/prisma-8/references/build.md +142 -0
  42. package/skills/prisma-8/references/contract.md +544 -0
  43. package/skills/prisma-8/references/debug.md +149 -0
  44. package/skills/prisma-8/references/feedback.md +251 -0
  45. package/skills/prisma-8/references/migration-model.md +179 -0
  46. package/skills/prisma-8/references/migration-review.md +211 -0
  47. package/skills/prisma-8/references/migrations.md +581 -0
  48. package/skills/prisma-8/references/queries-mongo.md +238 -0
  49. package/skills/prisma-8/references/queries-postgres.md +710 -0
  50. package/skills/prisma-8/references/queries.md +253 -0
  51. package/skills/prisma-8/references/quickstart.md +317 -0
  52. package/skills/prisma-8/references/runtime.md +463 -0
  53. package/skills/prisma-8/references/supabase.md +234 -0
  54. package/skills/prisma-8/references/upgrade-app.md +102 -0
  55. package/skills/prisma-8/references/upgrade-extension.md +106 -0
  56. package/skills/prisma-8/upgrading/app/upgrades/0.10-to-0.11/instructions.md +56 -0
  57. package/skills/prisma-8/upgrading/app/upgrades/0.11-to-0.12/instructions.md +381 -0
  58. package/skills/prisma-8/upgrading/app/upgrades/0.11-to-0.12/re-emit-closed-mongo-contracts.ts +202 -0
  59. package/skills/prisma-8/upgrading/app/upgrades/0.11-to-0.12/re-emit-domain-namespaced-contracts.ts +201 -0
  60. package/skills/prisma-8/upgrading/app/upgrades/0.11-to-0.12/re-emit-postgres-public-default.ts +198 -0
  61. package/skills/prisma-8/upgrading/app/upgrades/0.11-to-0.12/strip-migration-labels-hints.ts +340 -0
  62. package/skills/prisma-8/upgrading/app/upgrades/0.12-to-0.13/instructions.md +339 -0
  63. package/skills/prisma-8/upgrading/app/upgrades/0.12-to-0.13/re-emit-mti-variant-link-columns.ts +229 -0
  64. package/skills/prisma-8/upgrading/app/upgrades/0.13-to-0.14/instructions.md +543 -0
  65. package/skills/prisma-8/upgrading/app/upgrades/0.13-to-0.14/migration-op-factories-to-methods.ts +290 -0
  66. package/skills/prisma-8/upgrading/app/upgrades/0.13-to-0.14/uuid-preset-rename.ts +43 -0
  67. package/skills/prisma-8/upgrading/app/upgrades/0.14-to-0.15/instructions.md +359 -0
  68. package/skills/prisma-8/upgrading/app/upgrades/0.15-to-0.16/instructions.md +173 -0
  69. package/skills/prisma-8/upgrading/app/upgrades/0.16-to-0.17/instructions.md +805 -0
  70. package/skills/prisma-8/upgrading/app/upgrades/0.16-to-0.17/strip-sha256-hash-prefixes.ts +382 -0
  71. package/skills/prisma-8/upgrading/app/upgrades/0.17-to-8.0.0-rc.1/instructions.md +72 -0
  72. package/skills/prisma-8/upgrading/app/upgrades/0.7-to-0.8/instructions.md +8 -0
  73. package/skills/prisma-8/upgrading/app/upgrades/0.8-to-0.9/instructions.md +36 -0
  74. package/skills/prisma-8/upgrading/app/upgrades/0.8-to-0.9/strip-inline-contracts.ts +226 -0
  75. package/skills/prisma-8/upgrading/app/upgrades/0.9-to-0.10/instructions.md +86 -0
  76. package/skills/prisma-8/upgrading/app/upgrades/0.9-to-0.10/stamp-storage-types-kind.ts +360 -0
  77. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.1-to-8.0.0-rc.2/instructions.md +588 -0
  78. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.10-to-8.0.0-rc.11/instructions.md +34 -0
  79. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.11-to-8.0.0-rc.12/instructions.md +639 -0
  80. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.11-to-8.0.0-rc.12/scripts/multifile-psl/add-use-prisma-8-directive.mjs +60 -0
  81. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.11-to-8.0.0-rc.12/scripts/psl-verbatim-table-names/add-model-map.mjs +256 -0
  82. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.12-to-8.0.0-rc.13/instructions.md +332 -0
  83. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.12-to-8.0.0-rc.13/scripts/execution-ref-entry-field/rename-execution-ref-keys.ts +193 -0
  84. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.13-to-8.0.0-rc.14/instructions.md +489 -0
  85. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.14-to-8.0.0-rc.15/instructions.md +1368 -0
  86. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.14-to-8.0.0-rc.15/scripts/data-type-in-contract/data-type-in-contract.ts +1492 -0
  87. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.15-to-8.0.0-rc.16/instructions.md +108 -0
  88. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.16-to-8.0.0-rc.17/instructions.md +755 -0
  89. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.17-to-8.0.0-rc.18/instructions.md +973 -0
  90. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.17-to-8.0.0-rc.18/scripts/sql-expression-literals-psl/rewrite-sql-strings.mjs +271 -0
  91. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.18-to-8.0.0-rc.19/instructions.md +1826 -0
  92. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.18-to-8.0.0-rc.19/scripts/client-takes-contract-value/contract-from-json.ts +382 -0
  93. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.18-to-8.0.0-rc.19/scripts/data-type-values/data-type-values.ts +1117 -0
  94. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.18-to-8.0.0-rc.19/scripts/default-generators-to-on-create/rewrite-default-generators.mjs +86 -0
  95. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.18-to-8.0.0-rc.19/scripts/mongo-field-storage-names/mongo-field-storage-names.ts +250 -0
  96. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.18-to-8.0.0-rc.19/scripts/remove-nocheck/remove-nocheck.ts +813 -0
  97. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.19-to-8.0.0-rc.20/instructions.md +502 -0
  98. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.19-to-8.0.0-rc.20/scripts/expand-type-aliases/expand-type-aliases.ts +1171 -0
  99. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.2-to-8.0.0-rc.3/instructions.md +5 -0
  100. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.3-to-8.0.0-rc.4/instructions.md +158 -0
  101. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.4-to-8.0.0-rc.5/instructions.md +42 -0
  102. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.5-to-8.0.0-rc.6/instructions.md +157 -0
  103. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.6-to-8.0.0-rc.7/instructions.md +33 -0
  104. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.7-to-8.0.0-rc.8/instructions.md +36 -0
  105. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.8-to-8.0.0-rc.9/instructions.md +63 -0
  106. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.9-to-8.0.0-rc.10/instructions.md +84 -0
  107. package/skills/prisma-8/upgrading/extension/upgrades/0.10-to-0.11/instructions.md +276 -0
  108. package/skills/prisma-8/upgrading/extension/upgrades/0.11-to-0.12/instructions.md +738 -0
  109. package/skills/prisma-8/upgrading/extension/upgrades/0.11-to-0.12/migrate-contract-testing-imports.ts +97 -0
  110. package/skills/prisma-8/upgrading/extension/upgrades/0.11-to-0.12/regenerate-extension-public-baseline.ts +223 -0
  111. package/skills/prisma-8/upgrading/extension/upgrades/0.11-to-0.12/strip-migration-labels-hints.ts +340 -0
  112. package/skills/prisma-8/upgrading/extension/upgrades/0.12-to-0.13/instructions.md +266 -0
  113. package/skills/prisma-8/upgrading/extension/upgrades/0.13-to-0.14/instructions.md +522 -0
  114. package/skills/prisma-8/upgrading/extension/upgrades/0.13-to-0.14/migration-op-factories-to-methods.ts +290 -0
  115. package/skills/prisma-8/upgrading/extension/upgrades/0.13-to-0.14/uuid-preset-rename.ts +43 -0
  116. package/skills/prisma-8/upgrading/extension/upgrades/0.14-to-0.15/instructions.md +803 -0
  117. package/skills/prisma-8/upgrading/extension/upgrades/0.15-to-0.16/instructions.md +219 -0
  118. package/skills/prisma-8/upgrading/extension/upgrades/0.16-to-0.17/instructions.md +731 -0
  119. package/skills/prisma-8/upgrading/extension/upgrades/0.16-to-0.17/strip-sha256-hash-prefixes.ts +382 -0
  120. package/skills/prisma-8/upgrading/extension/upgrades/0.17-to-8.0.0-rc.1/instructions.md +194 -0
  121. package/skills/prisma-8/upgrading/extension/upgrades/0.7-to-0.8/instructions.md +8 -0
  122. package/skills/prisma-8/upgrading/extension/upgrades/0.8-to-0.9/instructions.md +57 -0
  123. package/skills/prisma-8/upgrading/extension/upgrades/0.8-to-0.9/strip-inline-contracts.ts +226 -0
  124. package/skills/prisma-8/upgrading/extension/upgrades/0.9-to-0.10/instructions.md +150 -0
  125. package/skills/prisma-8/upgrading/extension/upgrades/0.9-to-0.10/stamp-storage-types-kind.ts +360 -0
  126. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.1-to-8.0.0-rc.2/instructions.md +746 -0
  127. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.10-to-8.0.0-rc.11/instructions.md +34 -0
  128. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.11-to-8.0.0-rc.12/instructions.md +857 -0
  129. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.11-to-8.0.0-rc.12/scripts/psl-verbatim-table-names/add-model-map.mjs +256 -0
  130. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.12-to-8.0.0-rc.13/instructions.md +504 -0
  131. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.12-to-8.0.0-rc.13/scripts/execution-ref-entry-field/rename-execution-ref-keys.ts +193 -0
  132. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.13-to-8.0.0-rc.14/instructions.md +143 -0
  133. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.14-to-8.0.0-rc.15/instructions.md +2168 -0
  134. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.14-to-8.0.0-rc.15/scripts/data-type-in-contract/data-type-in-contract.ts +1492 -0
  135. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.15-to-8.0.0-rc.16/instructions.md +223 -0
  136. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.16-to-8.0.0-rc.17/instructions.md +583 -0
  137. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.17-to-8.0.0-rc.18/instructions.md +1008 -0
  138. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.18-to-8.0.0-rc.19/instructions.md +2000 -0
  139. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.18-to-8.0.0-rc.19/scripts/client-takes-contract-value/contract-from-json.ts +382 -0
  140. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.18-to-8.0.0-rc.19/scripts/remove-nocheck/remove-nocheck.ts +813 -0
  141. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.19-to-8.0.0-rc.20/instructions.md +379 -0
  142. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.19-to-8.0.0-rc.20/scripts/expand-type-aliases/expand-type-aliases.ts +1171 -0
  143. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.2-to-8.0.0-rc.3/instructions.md +5 -0
  144. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.3-to-8.0.0-rc.4/instructions.md +137 -0
  145. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.4-to-8.0.0-rc.5/instructions.md +129 -0
  146. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.5-to-8.0.0-rc.6/instructions.md +102 -0
  147. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.6-to-8.0.0-rc.7/instructions.md +33 -0
  148. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.7-to-8.0.0-rc.8/instructions.md +35 -0
  149. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.8-to-8.0.0-rc.9/instructions.md +86 -0
  150. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.9-to-8.0.0-rc.10/instructions.md +63 -0
  151. package/dist/adapter__codec-ids.d.mts +0 -1
  152. package/dist/adapter__codec-ids.mjs +0 -2
  153. package/dist/adapter__codec-types.d.mts +0 -1
  154. package/dist/adapter__codec-types.mjs +0 -2
  155. package/dist/adapter__codecs.d.mts +0 -1
  156. package/dist/adapter__codecs.mjs +0 -2
  157. package/dist/mongo-static-BdSGXYgQ-DSA-2DiK.d.mts.map +0 -1
  158. package/dist/mongo-static-_wy-fC4P-mXlhePy0.mjs +0 -38
  159. package/dist/mongo-static-_wy-fC4P-mXlhePy0.mjs.map +0 -1
package/dist/runtime.mjs CHANGED
@@ -1,13 +1,13 @@
1
- import { t as buildMongoStaticContext } from "./mongo-static-_wy-fC4P-mXlhePy0.mjs";
1
+ import { i as validateMongoContract, t as buildMongoStaticContext } from "./mongo-static-Cz5l8Wei-Cm-iMEyb.mjs";
2
2
  import { ifDefined } from "@prisma/orm-framework/utils/defined";
3
- import { MongoContractSerializer } from "@prisma/orm-family-mongo/family/ir";
4
3
  import { mongoOrm } from "@prisma/orm-family-mongo/orm";
5
4
  import { createMongoRuntime } from "@prisma/orm-family-mongo/runtime";
6
5
  import { MongoDriverImpl } from "@prisma/orm-target-mongo/driver";
7
6
  import { AsyncIterableResult } from "@prisma/orm-framework/components/runtime";
8
7
  import { InternalError } from "@prisma/orm-framework/utils/internal-error";
8
+ import { ConnectionString } from "mongodb-connection-string-url";
9
9
  import { structuredError } from "@prisma/orm-framework/utils/structured-error";
10
- //#region ../../../3-extensions/mongo/dist/runtime.mjs
10
+ //#region ../../../3-targets/mongo/9-facade/dist/runtime.mjs
11
11
  function mongoError(code, message, options) {
12
12
  return structuredError(code, message, {
13
13
  ...options,
@@ -17,23 +17,28 @@ function mongoError(code, message, options) {
17
17
  }
18
18
  });
19
19
  }
20
+ const URL_SCHEME_PATTERN = /^([a-z][a-z\d+.-]*):\/\//i;
21
+ const MONGO_SCHEMES = /* @__PURE__ */ new Set(["mongodb", "mongodb+srv"]);
20
22
  function validateMongoUrl(url) {
21
23
  const trimmed = url.trim();
22
24
  if (trimmed.length === 0) throw mongoError("RUNTIME.BINDING_INVALID", "Mongo URL must be a non-empty string");
23
- let parsed;
25
+ const scheme = URL_SCHEME_PATTERN.exec(trimmed)?.[1];
26
+ if (scheme === void 0) throw mongoError("RUNTIME.BINDING_INVALID", "Mongo URL must be a valid URL");
27
+ if (!MONGO_SCHEMES.has(scheme)) throw mongoError("RUNTIME.BINDING_INVALID", "Mongo URL must use mongodb:// or mongodb+srv://");
24
28
  try {
25
- parsed = new URL(trimmed);
29
+ return new ConnectionString(trimmed);
26
30
  } catch {
27
31
  throw mongoError("RUNTIME.BINDING_INVALID", "Mongo URL must be a valid URL");
28
32
  }
29
- if (parsed.protocol !== "mongodb:" && parsed.protocol !== "mongodb+srv:") throw mongoError("RUNTIME.BINDING_INVALID", "Mongo URL must use mongodb:// or mongodb+srv://");
30
- return parsed;
31
33
  }
32
34
  function extractDbNameFromUrl(parsed) {
33
- const path = parsed.pathname.startsWith("/") ? parsed.pathname.slice(1) : parsed.pathname;
34
- if (path.length === 0) return;
35
- const slash = path.indexOf("/");
36
- return slash === -1 ? path : path.slice(0, slash);
35
+ const [encodedDbName = ""] = parsed.pathname.slice(1).split("/");
36
+ if (encodedDbName.length === 0) return;
37
+ try {
38
+ return decodeURIComponent(encodedDbName);
39
+ } catch {
40
+ throw mongoError("RUNTIME.BINDING_INVALID", "Mongo URL must be a valid URL");
41
+ }
37
42
  }
38
43
  function resolveMongoBinding(options) {
39
44
  const providedCount = Number(options.binding !== void 0) + Number(options.url !== void 0) + Number(options.uri !== void 0) + Number(options.mongoClient !== void 0);
@@ -90,17 +95,27 @@ function resolveOptionalMongoBinding(options) {
90
95
  });
91
96
  throw new InternalError("Invariant violation: expected one mongo binding branch");
92
97
  }
93
- function hasContractJson(options) {
94
- return "contractJson" in options;
95
- }
96
- function resolveContract(options) {
97
- const contractInput = hasContractJson(options) ? options.contractJson : options.contract;
98
- return new MongoContractSerializer().deserializeContract(contractInput);
99
- }
98
+ /**
99
+ * Creates a lazy Mongo client. The client infers its contract type from `contract`: a value from
100
+ * `contractFromJson` for an emitted contract, or a TypeScript-authored contract. A contract is
101
+ * validated once, however many clients are built from it. The `orm` and `query` surfaces are
102
+ * available at once; the driver connects on the first query or `connect()`.
103
+ *
104
+ * @example
105
+ * ```ts
106
+ * import { contractFromJson } from '@prisma/orm-mongo/static';
107
+ * import mongo from '@prisma/orm-mongo/runtime';
108
+ * import type { Contract } from './contract.d';
109
+ * import contractJson from './contract.json' with { type: 'json' };
110
+ *
111
+ * export const contract = contractFromJson<Contract>(contractJson);
112
+ * export const db = mongo({ contract, url: process.env['MONGODB_URL']! });
113
+ * ```
114
+ */
100
115
  function mongo(options) {
101
- const contract = resolveContract(options);
116
+ const contract = validateMongoContract(options.contract);
102
117
  let binding = resolveOptionalMongoBinding(options);
103
- const { context, query, enums, raw } = buildMongoStaticContext(contract);
118
+ const { context, query, enums, enumsByNamespace, raw } = buildMongoStaticContext(contract);
104
119
  let runtimePromise;
105
120
  let closed = false;
106
121
  let ownedDispose;
@@ -139,7 +154,9 @@ function mongo(options) {
139
154
  executor: {
140
155
  query: queryRows,
141
156
  execute: executeStats
142
- }
157
+ },
158
+ mutationDefaults: context,
159
+ enums: enumsByNamespace
143
160
  }),
144
161
  query,
145
162
  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-_wy-fC4P.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 { InternalError } from \"@internal/utils/internal-error\";\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\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\tlet parsed;\n\ttry {\n\t\tparsed = new URL(trimmed);\n\t} catch {\n\t\tthrow mongoError(\"RUNTIME.BINDING_INVALID\", \"Mongo URL must be a valid URL\");\n\t}\n\tif (parsed.protocol !== \"mongodb:\" && parsed.protocol !== \"mongodb+srv:\") throw mongoError(\"RUNTIME.BINDING_INVALID\", \"Mongo URL must use mongodb:// or mongodb+srv://\");\n\treturn parsed;\n}\nfunction extractDbNameFromUrl(parsed) {\n\tconst path = parsed.pathname.startsWith(\"/\") ? parsed.pathname.slice(1) : parsed.pathname;\n\tif (path.length === 0) return;\n\tconst slash = path.indexOf(\"/\");\n\treturn slash === -1 ? path : path.slice(0, slash);\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 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}),\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":";;;;;;;;;;AAUA,SAAS,WAAW,MAAM,SAAS,SAAS;CAC3C,OAAO,gBAAgB,MAAM,SAAS;EACrC,G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HAAyH,CAAC;EAC9M,iBAAiB,aAAa,OAAO,CAAC,CAAC,OAAO,QAAQ;GACrD,iBAAiB,KAAK;GACtB,MAAM;EACP,CAAC;EACD,OAAO;CACR;CACA,SAAS,UAAU,MAAM;EACxB,gBAAgB,UAAU;GACzB,QAAQ,MAAM,WAAW,EAAA,CAAG,MAAM,IAAI;EACvC;EACA,OAAO,IAAI,oBAAoB,QAAQ,CAAC;CACzC;CACA,eAAe,aAAa,MAAM;EACjC,QAAQ,MAAM,WAAW,EAAA,CAAG,QAAQ,IAAI;CACzC;CACA,OAAO;EACN,KAAK,SAAS;GACb;GACA,UAAU;IACT,OAAO;IACP,SAAS;GACV;EACD,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"}
1
+ {"version":3,"file":"runtime.mjs","names":[],"sources":["../../../../3-targets/mongo/9-facade/dist/runtime.mjs"],"sourcesContent":["import { i as validateMongoContract, t as buildMongoStaticContext } from \"./mongo-static-Cz5l8Wei.mjs\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { MongoDriverImpl } from \"@internal/driver-mongo\";\nimport { AsyncIterableResult } from \"@internal/framework-components/runtime\";\nimport { mongoOrm } from \"@internal/mongo-orm\";\nimport { createMongoRuntime } from \"@internal/mongo-runtime\";\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\n/**\n* Creates a lazy Mongo client. The client infers its contract type from `contract`: a value from\n* `contractFromJson` for an emitted contract, or a TypeScript-authored contract. A contract is\n* validated once, however many clients are built from it. The `orm` and `query` surfaces are\n* available at once; the driver connects on the first query or `connect()`.\n*\n* @example\n* ```ts\n* import { contractFromJson } from '@prisma/orm-mongo/static';\n* import mongo from '@prisma/orm-mongo/runtime';\n* import type { Contract } from './contract.d';\n* import contractJson from './contract.json' with { type: 'json' };\n*\n* export const contract = contractFromJson<Contract>(contractJson);\n* export const db = mongo({ contract, url: process.env['MONGODB_URL']! });\n* ```\n*/\nfunction mongo(options) {\n\tconst contract = validateMongoContract(options.contract);\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":";;;;;;;;;;AAUA,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;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B;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,24 @@
1
- import { n as mongoStatic, t as MongoStaticContext } from "./mongo-static-BdSGXYgQ-DSA-2DiK.mjs";
2
- export { type MongoStaticContext, mongoStatic as default };
1
+ import { n as mongoStatic, t as MongoStaticContext } from "./mongo-static-D_RcLkSZ-DL_Qae5D.mjs";
2
+ import { AnyMongoTypeMaps, MongoContract, MongoContractWithTypeMaps } from "@prisma/orm-family-mongo/contract";
3
+ //#region ../../../3-targets/mongo/9-facade/dist/static.d.mts
4
+ //#region src/static/contract-from-json.d.ts
5
+ /**
6
+ * Validates an emitted Mongo `contract.json` and returns it as the contract type the application
7
+ * names, ready to pass to `mongo({ contract })` and `mongoStatic({ contract })`. Clients built from
8
+ * the result do not validate it again.
9
+ *
10
+ * The returned value's top level is frozen; its nested objects are not. Do not change `json` or the
11
+ * returned value after the call: clients built from the value later do not validate it again.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * import type { Contract } from './contract.d';
16
+ * import contractJson from './contract.json' with { type: 'json' };
17
+ *
18
+ * export const contract = contractFromJson<Contract>(contractJson);
19
+ * ```
20
+ */
21
+ declare function contractFromJson<TContract extends MongoContractWithTypeMaps<MongoContract, AnyMongoTypeMaps>>(json: unknown): TContract;
22
+ //#endregion
23
+ export { type MongoStaticContext, contractFromJson, mongoStatic as default };
24
+ //# sourceMappingURL=static.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"static.d.mts","names":[],"sources":["../../../../3-targets/mongo/9-facade/dist/static.d.mts"],"mappings":";;;;;;;;;;;;;;;;;;;;iBAmBiB,iBAAiB,kBAAkB,0BAA0B,eAAe,mBAAmB,gBAAgB"}
package/dist/static.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { n as mongoStatic } from "./mongo-static-_wy-fC4P-mXlhePy0.mjs";
2
- export { mongoStatic as default };
1
+ import { n as contractFromJson, r as mongoStatic } from "./mongo-static-Cz5l8Wei-Cm-iMEyb.mjs";
2
+ export { contractFromJson, mongoStatic as default };
@@ -0,0 +1 @@
1
+ export * from "@prisma/orm-target-mongo/target/codec-ids";
@@ -0,0 +1,2 @@
1
+ export * from "@prisma/orm-target-mongo/target/codec-ids";
2
+ export {};
@@ -0,0 +1 @@
1
+ export * from "@prisma/orm-target-mongo/target/codecs";
@@ -0,0 +1,2 @@
1
+ export * from "@prisma/orm-target-mongo/target/codecs";
2
+ export {};
@@ -0,0 +1 @@
1
+ export * from "@prisma/orm-target-mongo/target/data-types";
@@ -0,0 +1,2 @@
1
+ export * from "@prisma/orm-target-mongo/target/data-types";
2
+ export {};
@@ -0,0 +1 @@
1
+ export * from "@prisma/orm-framework/utils/suppress-idle-connection-errors";
@@ -0,0 +1,2 @@
1
+ export * from "@prisma/orm-framework/utils/suppress-idle-connection-errors";
2
+ export {};
@@ -0,0 +1 @@
1
+ export * from "@prisma/orm-framework/utils/text";
@@ -0,0 +1,2 @@
1
+ export * from "@prisma/orm-framework/utils/text";
2
+ export {};
package/package.json CHANGED
@@ -1,24 +1,27 @@
1
1
  {
2
2
  "name": "@prisma/orm-mongo",
3
- "version": "8.0.0-rc.2-dev.2",
3
+ "version": "8.0.0-rc.20",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
- "description": "Prisma Next for MongoDB: the one package a MongoDB application installs",
7
+ "description": "Prisma 8 for MongoDB: the one package a MongoDB application installs",
8
8
  "files": [
9
- "dist"
9
+ "dist",
10
+ "skills"
10
11
  ],
11
12
  "dependencies": {
12
- "@prisma/orm-family-mongo": "8.0.0-rc.2-dev.2",
13
- "@prisma/orm-framework": "8.0.0-rc.2-dev.2",
14
- "@prisma/orm-target-mongo": "8.0.0-rc.2-dev.2",
15
- "@prisma/orm-toolchain": "8.0.0-rc.2-dev.2",
16
- "pathe": "^2.0.3"
13
+ "@prisma/orm-family-mongo": "8.0.0-rc.20",
14
+ "@prisma/orm-framework": "8.0.0-rc.20",
15
+ "@prisma/orm-target-mongo": "8.0.0-rc.20",
16
+ "@prisma/orm-toolchain": "8.0.0-rc.20",
17
+ "mongodb-connection-string-url": "^7.0.1",
18
+ "pathe": "^2.0.3",
19
+ "tinyglobby": "^0.2.17"
17
20
  },
18
21
  "devDependencies": {
19
- "@internal/mongo": "8.0.0-rc.2-dev.2",
20
- "@repo/tsconfig": "8.0.0-rc.2-dev.2",
21
- "@repo/tsdown": "8.0.0-rc.2-dev.2",
22
+ "@internal/mongo": "8.0.0-rc.20",
23
+ "@repo/tsconfig": "8.0.0-rc.20",
24
+ "@repo/tsdown": "8.0.0-rc.20",
22
25
  "tsdown": "0.22.14",
23
26
  "typescript": "5.9.3"
24
27
  },
@@ -33,9 +36,6 @@
33
36
  },
34
37
  "exports": {
35
38
  "./adapter": "./dist/adapter.mjs",
36
- "./adapter/codec-ids": "./dist/adapter__codec-ids.mjs",
37
- "./adapter/codec-types": "./dist/adapter__codec-types.mjs",
38
- "./adapter/codecs": "./dist/adapter__codecs.mjs",
39
39
  "./adapter/control": "./dist/adapter__control.mjs",
40
40
  "./adapter/runtime": "./dist/adapter__runtime.mjs",
41
41
  "./bson": "./dist/bson.mjs",
@@ -62,6 +62,7 @@
62
62
  "./contract/resolve-domain-model": "./dist/contract__resolve-domain-model.mjs",
63
63
  "./contract/types": "./dist/contract__types.mjs",
64
64
  "./contract/validate-domain": "./dist/contract__validate-domain.mjs",
65
+ "./contract/validate-once": "./dist/contract__validate-once.mjs",
65
66
  "./contract-builder": "./dist/contract-builder.mjs",
66
67
  "./control": "./dist/control.mjs",
67
68
  "./driver": "./dist/driver.mjs",
@@ -76,6 +77,7 @@
76
77
  "./family/schema-verify": "./dist/family__schema-verify.mjs",
77
78
  "./family-contract": "./dist/family-contract.mjs",
78
79
  "./family-contract/canonicalization-hooks": "./dist/family-contract__canonicalization-hooks.mjs",
80
+ "./family-contract/data-type": "./dist/family-contract__data-type.mjs",
79
81
  "./family-contract/entity-kinds": "./dist/family-contract__entity-kinds.mjs",
80
82
  "./family-runtime": "./dist/family-runtime.mjs",
81
83
  "./migration-tools/aggregate": "./dist/migration-tools__aggregate.mjs",
@@ -92,8 +94,11 @@
92
94
  "./runtime": "./dist/runtime.mjs",
93
95
  "./static": "./dist/static.mjs",
94
96
  "./target": "./dist/target.mjs",
97
+ "./target/codec-ids": "./dist/target__codec-ids.mjs",
95
98
  "./target/codec-types": "./dist/target__codec-types.mjs",
99
+ "./target/codecs": "./dist/target__codecs.mjs",
96
100
  "./target/control": "./dist/target__control.mjs",
101
+ "./target/data-types": "./dist/target__data-types.mjs",
97
102
  "./target/migration": "./dist/target__migration.mjs",
98
103
  "./target/pack": "./dist/target__pack.mjs",
99
104
  "./target/runtime": "./dist/target__runtime.mjs",
@@ -112,6 +117,8 @@
112
117
  "./utils/result": "./dist/utils__result.mjs",
113
118
  "./utils/simplify-deep": "./dist/utils__simplify-deep.mjs",
114
119
  "./utils/structured-error": "./dist/utils__structured-error.mjs",
120
+ "./utils/suppress-idle-connection-errors": "./dist/utils__suppress-idle-connection-errors.mjs",
121
+ "./utils/text": "./dist/utils__text.mjs",
115
122
  "./utils/types": "./dist/utils__types.mjs",
116
123
  "./value": "./dist/value.mjs",
117
124
  "./value/mongodb-types": "./dist/value__mongodb-types.mjs",
@@ -120,12 +127,12 @@
120
127
  },
121
128
  "repository": {
122
129
  "type": "git",
123
- "url": "https://github.com/prisma/prisma.git",
130
+ "url": "https://github.com/prisma/orm.git",
124
131
  "directory": "packages/9-public/@prisma/orm-mongo"
125
132
  },
126
133
  "scripts": {
127
134
  "build": "tsdown",
128
135
  "lint": "biome check . --error-on-warnings",
129
- "clean": "rm -rf dist src-gen"
136
+ "clean": "rm -rf dist src-gen skills"
130
137
  }
131
138
  }
@@ -0,0 +1,96 @@
1
+ ---
2
+ name: prisma-8
3
+ description: >-
4
+ Use when working in a project that depends on @prisma/orm-postgres,
5
+ @prisma/orm-sqlite, or @prisma/orm-mongo (Prisma 8, formerly Prisma Next): editing
6
+ contract.prisma or a contract.ts builder, running `prisma contract emit`,
7
+ planning or applying migrations, editing migration.ts, writing db.orm /
8
+ db.sql / db.query queries, wiring db.ts or middleware, integrating a build
9
+ tool, using the Supabase extension or RLS, or reading a dotted error code
10
+ such as MIGRATION.HASH_MISMATCH. Use when the user asks "what is Prisma
11
+ 8", "where do I start", or compares it to another ORM. Use when the user
12
+ asks to upgrade or bump Prisma 8 in an app or an extension package. Use when
13
+ you see @internal/* or @prisma/orm-* imports, prisma.config.ts with
14
+ definePrismaConfig, or contract.json / contract.d.ts. Do not use for Prisma
15
+ ORM 7 or earlier (schema.prisma + @prisma/client).
16
+ metadata:
17
+ library: '@prisma/orm-mongo'
18
+ library_version: '8.0.0-rc.20'
19
+ version: '2026-09-12'
20
+ ---
21
+
22
+ # Prisma 8 (Prisma 8)
23
+
24
+ > **Edit your data contract. Prisma handles the rest.**
25
+
26
+ Prisma 8 moves fast, and your training data about it is very likely outdated. This skill ships inside the installed Prisma packages, so it describes the exact version this project has — treat it and its reference files as the source of truth, over anything you remember about Prisma.
27
+
28
+ ## Pre-conditions
29
+
30
+ Check these before acting on anything below. Halt on the first one that fails and tell the user what is missing.
31
+
32
+ 1. **The project is on Prisma 8.** `prisma.config.ts` exports `definePrismaConfig({ orm: ... })`, and `package.json` depends on `@prisma/orm-postgres`, `@prisma/orm-sqlite`, or `@prisma/orm-mongo`. A project with `schema.prisma` and `@prisma/client` is Prisma 7 or earlier; this skill does not apply to it, and its instructions will break such a project.
33
+ 2. **The skill matches the installed version.** Compare `metadata.library_version` in this file's frontmatter with the installed `@prisma/orm-*` version in `package.json`. If they differ, run `prisma skills sync` and re-read this file before continuing.
34
+ 3. **The contract artefacts exist.** `contract.json` and `contract.d.ts` sit next to the contract source named by `prisma.config.ts`. If they are missing or older than the source, run `prisma contract emit` first; every query and migration instruction below assumes current artefacts.
35
+
36
+ **Import paths in the references.** The reference files spell façade imports as `@internal/<target>/<subpath>` and `@internal/extension-<name>/<subpath>`. In an application those packages are published as `@prisma/orm-<target>/<subpath>` (`@prisma/orm-postgres/runtime`, `@prisma/orm-mongo/config`, `@prisma/orm-sqlite/runtime`) and `@prisma/orm-extension-<name>/<subpath>` (`@prisma/orm-extension-pgvector/control`). Write the `@prisma/orm-*` name in user code; the two spellings are the same package. Paths already written as `@prisma/orm-*` in the references are exact. The `metadata.library_version` in this file's frontmatter is the version it was published with; if it does not match the project's installed Prisma packages, run `prisma skills sync` and re-read.
37
+
38
+ Prisma 8 is a contract-first data layer. This skill routes every Prisma 8 task to the right reference file — open the reference before writing code; do not answer from this file alone.
39
+
40
+ ## The canonical model (one paragraph)
41
+
42
+ You author a **data contract** (a `contract.prisma` file, or a TypeScript builder). The framework emits machine-readable artifacts (`contract.json`, `contract.d.ts`) and gives you two runtime surfaces on SQL targets: a typed SQL query builder (`db.sql.<ns>.<table>`) and a typed ORM client (`db.orm.<ns>.<Model>`). On MongoDB targets only the ORM lane exists, and its keys are collection storage names (`db.orm.users`) rather than PSL model names — [`references/queries.md`](references/queries.md) § *MongoDB ORM addressing* covers the rule. Migrations are planned from the contract diff; you review them, optionally edit the `migration.ts` for data transforms, and apply.
43
+
44
+ Three steps the user does:
45
+
46
+ 1. **Edit your data contract.** ([`references/contract.md`](references/contract.md))
47
+ 2. **The system plans the migrations for you.** ([`references/migrations.md`](references/migrations.md))
48
+ 3. **If you need data migrations, you edit `migration.ts` and execute it.** ([`references/migrations.md`](references/migrations.md))
49
+
50
+ Everything else — queries, runtime wiring, build integration, debugging, feedback — sits on top of those three.
51
+
52
+ One cross-cutting migration fact: `migration plan` does **not** chain from the newest migration on disk. Its origin is `--from`, else the `db` ref, else an empty database — so a project with no ref keeps planning from scratch. Over existing migrations the CLI refuses that (`MIGRATION.PLAN_ORIGIN_UNKNOWN`) instead of writing a full-create package; choose the exit that matches your intent rather than reflexively passing `--from @empty`. [`references/migration-model.md`](references/migration-model.md) § *The trap* explains which to choose.
53
+
54
+ ## Routing table
55
+
56
+ Open the reference whose triggers match the task. If more than one matches, open each — they are written to compose.
57
+
58
+ | Task | Reference | Triggers |
59
+ | --- | --- | --- |
60
+ | Adopt / set up / first steps | [`references/quickstart.md`](references/quickstart.md) | new project, existing database, "what can I do with Prisma 8", "where do I start", "just ran createprisma", `npx create-prisma`, first steps, first query, `prisma orm init` greenfield setup, `contract infer` + `db sign` brownfield adoption, connect-write-read first arc, day-to-day commands (`contract emit`, `db init`, `db update`, `migration plan`, `db migrate`, `db schema`, `db verify`), flags `--target` / `--authoring` / `--schema-path` / `--probe-db` / `--output` |
61
+ | Edit the data contract | [`references/contract.md`](references/contract.md) | schema, models, fields, attributes, relations, indexes, enums, value objects (composite types), type aliases, namespaces (Postgres schemas), cross-contract foreign keys (cross-space FK), polymorphic types (`@@discriminator` / `@@base`), extension namespaces (`pgvector.Vector(...)`, `postgis.Geometry(...)`), `prisma.config.ts` / `definePrismaConfig` / `ormConfig`, `prisma contract emit`, PSL, `contract.prisma`, `contract.ts`, `contract.json`, `contract.d.ts`, `@internal/postgres/config`, `@internal/postgres/contract-builder`, `@internal/mongo/config`, `extensions:`, pgvector, postgis, paradedb, Temporal / `temporal-polyfill` / `RUNTIME.TEMPORAL_UNAVAILABLE`, `@@control`, control policy (managed / tolerated / external / observed), soft delete, validations, callbacks |
62
+ | Author migrations | [`references/migrations.md`](references/migrations.md) | `db update` vs `migration plan`, `db migrate`, `migration new`, `migration show`, `db update --dry-run`, `db verify`, `db sign`, data migration, `dataTransform`, placeholder sentinels in framework-rendered `migration.ts`, `MIGRATION.HASH_MISMATCH`, `MIGRATION.UNFILLED_PLACEHOLDER`, data-loss questions (`--delete`, `--rename`, `--allow`, `CLI.CONSENT_REQUIRED`), schema drift |
63
+ | Migration graph, refs, plan origin | [`references/migration-model.md`](references/migration-model.md) | migration graph, refs, `migration ref set` / `list` / `delete`, the `db` ref, `--advance-ref`, `--no-advance-ref`, `migration plan --from`, `from: (baseline)` in plan output, greenfield / from-scratch plan, baseline, first migration before deploy (Composer / CD-managed databases), chaining migrations, retrofitting migrations onto an existing database, `MIGRATION.HASH_NOT_IN_GRAPH`, `MIGRATION.PATH_UNREACHABLE` at plan/chain time |
64
+ | Review migrations on deploy | [`references/migration-review.md`](references/migration-review.md) | "what migrations are going to run", "what runs on deploy / merge", merge conflict, diamond convergence, concurrent migrations, migration status, ref management for CI, staging / production environment refs, `MIGRATION.MARKER_NOT_IN_HISTORY`, `MIGRATION.MISSING_INVARIANTS`, `db migrate --show` |
65
+ | Write queries | [`references/queries.md`](references/queries.md) | query, where, select, project, orderBy, limit, offset, take, skip, include, lookup, first, all, count, aggregate, groupBy, create, update, delete, upsert, returning, transaction, `db.orm`, `db.sql`, `runtime.query(plan)` vs `runtime.execute(plan)`, `db.prepare` / prepared statements, streaming / `for await`, many-to-many `include` and nested `connect`, `and` / `or` / `not` from `@prisma/orm-postgres/orm-client`, `db.query.from(...)` (Mongo pipeline), namespace-aware accessors, `.all()` Thenable, single-use iterators (`RUNTIME.ITERATOR_CONSUMED`), target-declared aggregate types (`count`, integer `sum`, and integer `avg` are `number`; `count` and integer `sum` throw outside ±(2^53 − 1) rather than round, while `avg` is a fraction already and carries no guard; `countBigInt` / `sumBigInt` / `avgDecimal` are the lossless forms, `avgDecimal` on PostgreSQL only), custom collection class (`extends Collection`), `with` and query fragments (`QueryFragment`, `Filtered`, `Ordered`), shared query fragments and scopes (`db.orm.fragment(fields, body)` for a filter on every model with given fields, `CodecField`, `db.orm.public.Post.fragment(...)` for a shared `select` / `include`, `orderByField` for an order or sort parameter from a request), drizzle-style, kysely-style. Naming types (§ *Naming model and result types*): "type of my model", "return type of a query", `ResultType`, `Scalars`, `Shape`, `models` / `Models` namespace in `contract.d.ts`, `Models.public_User`, Prisma 7 `Prisma.User` / `GetPayload` / `UserGetPayload` equivalents. Postgres/SQLite specifics: [`references/queries-postgres.md`](references/queries-postgres.md); Mongo specifics: [`references/queries-mongo.md`](references/queries-mongo.md) |
66
+ | Wire the runtime | [`references/runtime.md`](references/runtime.md) | `db.ts`, `contractFromJson<Contract>(...)`, `postgres({ contract })` / `sqlite({ contract })` / `mongo({ contract })` façades, middleware composition (lints, budgets, cache via `@prisma/orm-extension-middleware-cache`, custom `activityEnded` middleware, `@prisma/orm-postgres/family-runtime`), `DATABASE_URL`, `.env`, connection pool / `poolOptions`, dev vs prod config, transactions, read replicas, multi-database, script won't exit / hangs, `db.close` / `pool.end`, `await using` / `[Symbol.asyncDispose]` |
67
+ | Build-tool integration | [`references/build.md`](references/build.md) | Vite plugin (`@internal/vite-plugin-contract-emit`, Vite 7/8), `vite.config.ts`, contract emit on save, HMR / dev server, Next.js / Webpack / esbuild / Rollup / Turbopack (named gaps, not fabricated) |
68
+ | Supabase | [`references/supabase.md`](references/supabase.md) | `@internal/extension-supabase`, RLS, row level security, policies (`policy_select` / `policy_update` / `@@rls`, `auth.uid()`), role binding (`asUser(jwt)` / `asAnon()` / `asServiceRole()`), `auth.users`, cross-space FKs to `supabase:auth.AuthUser`, JWT / JWKS (`SUPABASE_JWKS_URL`, `SUPABASE_JWT_SECRET`), `SUPABASE.JWT_INVALID`, `SUPABASE.CONFIG_INVALID`, `RoleBoundDb`, session pooler |
69
+ | Debug an error | [`references/debug.md`](references/debug.md) | any structured error envelope (code, severity, why, fix, nextActions, meta), emit failed, query won't typecheck, query crashed, migration won't apply, `MIGRATION.HASH_MISMATCH`, `MIGRATION.SCHEMA_VERIFY_FAILED`, `MIGRATION.PRECHECK_FAILED`, `BUDGET.ROWS_EXCEEDED`, `BUDGET.TIME_EXCEEDED`, `RUNTIME.ABORTED`, `RUNTIME.TEMPORAL_UNAVAILABLE`, `PLAN.HASH_MISMATCH`, `CONTRACT.MARKER_MISSING`, `CONFIG.*` / `CLI.*` / `CONTRACT.*` / `MIGRATION.*` / `ORM.*` / `RUNTIME.*` codes, legacy `PN-*` codes, exit code 4 findings, drift, capability missing, planner conflict, EXPLAIN, query log, script won't exit / close connection |
70
+ | Upgrade Prisma in an app | [`references/upgrade-app.md`](references/upgrade-app.md) | "upgrade Prisma", "upgrade Prisma 8", "bump Prisma 8", "move to Prisma 8 X.Y", `@internal/*` version bump in an application, per-transition upgrade instructions in [`upgrading/app/upgrades/`](upgrading/app/upgrades/), extension-pin pre-flight, `PN-UPGRADE-*` |
71
+ | Upgrade Prisma in an extension | [`references/upgrade-extension.md`](references/upgrade-extension.md) | the same request in a package that *is* a Prisma extension (`@internal/contract` / SPI dependency, `^@.*/extension-` name), `prisma-8-check-pins`, exact-pin rule, per-transition instructions in [`upgrading/extension/upgrades/`](upgrading/extension/upgrades/) |
72
+ | File feedback / ask the team | [`references/feedback.md`](references/feedback.md) | bug report, file an issue, feature request, missing feature, capability gap, "this is broken", surprising behaviour, Q&A / design discussion, ask the Prisma team, Prisma Discord (pris.ly/discord), extension-author questions |
73
+
74
+ ## Routing rules
75
+
76
+ If the task clearly matches a row, open that reference directly without asking.
77
+
78
+ For a vague prompt, ask **one** disambiguating question. Pick from:
79
+
80
+ - *"Are you new to Prisma 8 and asking what you can do with it, or where to start?"* → [`references/quickstart.md`](references/quickstart.md) (first-touch orientation path).
81
+ - *"Do you want to set up a new Prisma 8 project, or wire it into an existing database?"* → [`references/quickstart.md`](references/quickstart.md).
82
+ - *"Do you want to edit your data contract (add a model / field / relation), or work with the database (migrations, queries)?"* → [`references/contract.md`](references/contract.md) vs the others.
83
+ - *"Is this about authoring a migration, or about reviewing what's going to run on deploy?"* → [`references/migrations.md`](references/migrations.md) vs [`references/migration-review.md`](references/migration-review.md). If it's about where a plan starts, refs, or an unexpected from-scratch plan → [`references/migration-model.md`](references/migration-model.md).
84
+ - *"Is this about wiring Prisma 8 into your build tool (Vite / Next.js / …), or about wiring `db.ts` and middleware at runtime?"* → [`references/build.md`](references/build.md) vs [`references/runtime.md`](references/runtime.md).
85
+ - *"What error or symptom are you seeing?"* → [`references/debug.md`](references/debug.md).
86
+ - *"Do you want to report this as a bug to the Prisma 8 team, or is this a feature request?"* → [`references/feedback.md`](references/feedback.md).
87
+ - *"Is the project you want to upgrade an application, or a Prisma extension package?"* → [`references/upgrade-app.md`](references/upgrade-app.md) vs [`references/upgrade-extension.md`](references/upgrade-extension.md).
88
+
89
+ If you still can't tell which reference applies, ask the user what they want to do. Do not guess.
90
+
91
+ ## Checklist
92
+
93
+ - [ ] If the task matches a routing-table row, open that reference before writing code.
94
+ - [ ] If the prompt is vague, ask one disambiguating question.
95
+ - [ ] Do not attempt to answer from this file alone — the references carry the verified tool surface.
96
+ - [ ] If the user describes a missing feature or a misbehaviour they want fixed, open [`references/feedback.md`](references/feedback.md).
@@ -0,0 +1,142 @@
1
+
2
+ # Prisma 8 — Build-System Integration
3
+
4
+ > **Edit your data contract. Prisma handles the rest.**
5
+
6
+ This skill covers Prisma 8's build-tool plugins — the dev-server / build-system integrations that re-emit contract artifacts automatically as the user edits the contract source. Today that's [`@internal/vite-plugin-contract-emit`](https://github.com/prisma/prisma/blob/main/packages/1-framework/3-tooling/vite-plugin-contract-emit/README.md) for Vite 7 and Vite 8. Next.js, Webpack, esbuild, Rollup, and Turbopack plugins are documented under *What Prisma 8 doesn't do yet* with the workaround.
7
+
8
+ **If the project is using Vite and consuming the contract, install the plugin.** There's no good reason not to — manual `prisma contract emit` during dev is friction the plugin eliminates. The agent should proactively offer the plugin whenever it sees a `vite.config.ts` in the project; the user doesn't need to ask.
9
+
10
+ ## When to Use
11
+
12
+ - The project is using Vite (the agent sees a `vite.config.ts` or `@vitejs/*` deps) and the contract is being consumed at runtime — proactively offer the plugin.
13
+ - User asks how to wire Prisma 8 into their Vite project.
14
+ - User asks about Next.js integration, Webpack integration, or any other bundler — the answer is *"not yet, here's the workaround"* and the skill walks them through it.
15
+ - User mentions: *vite plugin, vite-plugin, vite.config.ts, prismaVitePlugin, contract emit on save, HMR, hot reload contract, dev server, vite 7, vite 8*.
16
+ - User mentions Next.js / Webpack / esbuild / Rollup / Turbopack in the context of Prisma 8 integration — the gap-listing path fires.
17
+
18
+ ## When Not to Use
19
+
20
+ - User wants to wire `db.ts` and middleware → `references/runtime.md`.
21
+ - User wants to file a feature request for an unbuilt bundler plugin → `references/feedback.md`.
22
+
23
+ ## Key Concepts
24
+
25
+ - **The plugin's job is `contract emit`, on a schedule the bundler knows about.** It is *not* a runtime concern — at runtime, the application reads `contract.json` / `contract.d.ts` the same way whether the plugin emitted them or a script did. The plugin saves you the manual command during development.
26
+ - **Vite 7 and Vite 8 only.** Peer range `^7.0.0 || ^8.0.0`. Vite 6 is not on the support matrix.
27
+ - **`executeContractEmit` is the canonical publish path.** Custom plugins for other bundlers must also call it — never re-implement the load → emit → publish dance. The atomic-rename invariant (`contract.d.ts` renamed before `contract.json`) and the per-output FIFO queue live in `@internal/cli/control-api`.
28
+ - **No build-time / production emission.** The Vite plugin runs in `vite dev` only. For `vite build` / production, run `prisma contract emit` from a `prebuild` script.
29
+
30
+ ## Workflow — Vite (the supported path)
31
+
32
+ ### 1. Install the plugin
33
+
34
+ ```bash
35
+ pnpm add -D @internal/vite-plugin-contract-emit
36
+ ```
37
+
38
+ (Or `npm install --save-dev`, `yarn add -D`, `bun add -d` — use what the project's package manager is.)
39
+
40
+ ### 2. Wire `vite.config.ts`
41
+
42
+ ```typescript
43
+ // vite.config.ts
44
+ import { defineConfig } from 'vite';
45
+ import { prismaVitePlugin } from '@internal/vite-plugin-contract-emit';
46
+
47
+ export default defineConfig({
48
+ plugins: [prismaVitePlugin('prisma.config.ts')],
49
+ });
50
+ ```
51
+
52
+ The argument is the **path to `prisma.config.ts` relative to Vite root**. Not the path to `schema.psl` or `contract.ts` — the plugin reads the config to discover the contract source.
53
+
54
+ ### 3. Configure (optional)
55
+
56
+ ```typescript
57
+ plugins: [
58
+ prismaVitePlugin('prisma.config.ts', {
59
+ debounceMs: 150, // delay before re-emitting (default 150)
60
+ logLevel: 'info', // 'silent' | 'info' | 'debug' (default 'info')
61
+ }),
62
+ ],
63
+ ```
64
+
65
+ Set `logLevel: 'debug'` only while troubleshooting; default `'info'` in committed config so the dev server isn't noisy.
66
+
67
+ ### 4. Verify the dev loop
68
+
69
+ 1. Start `vite dev`.
70
+ 2. Watch for the success log: `[prisma] emitted contract.d.ts + contract.json`.
71
+ 3. Edit `prisma/schema.psl` (e.g. add a field to a model).
72
+ 4. Within ~150ms (the debounce), watch for a re-emit log line.
73
+ 5. Type-check your application code that uses the new field — should pass without restarting the dev server.
74
+
75
+ If the plugin warns about *config-only watching*, see [Common Pitfalls](#common-pitfalls).
76
+
77
+ ### 5. CI / production builds
78
+
79
+ The plugin does **not** run during `vite build`. For CI and production deploys, run `prisma contract emit` as a prebuild step:
80
+
81
+ ```json
82
+ // package.json
83
+ {
84
+ "scripts": {
85
+ "prebuild": "prisma contract emit",
86
+ "build": "vite build"
87
+ }
88
+ }
89
+ ```
90
+
91
+ `pnpm build` then runs `prebuild` automatically before `build`.
92
+
93
+ ## Workflow — React Router v7 Framework Mode
94
+
95
+ The Vite plugin is compatible with `@react-router/dev/vite`. Both plugins are listed in `vite.config.ts`; there's no ordering constraint between them today, and the Prisma 8 plugin's re-emit fires alongside React Router's own SSR re-load.
96
+
97
+ ```typescript
98
+ import { reactRouter } from '@react-router/dev/vite';
99
+ import { prismaVitePlugin } from '@internal/vite-plugin-contract-emit';
100
+
101
+ export default defineConfig({
102
+ plugins: [
103
+ reactRouter(),
104
+ prismaVitePlugin('prisma.config.ts'),
105
+ ],
106
+ });
107
+ ```
108
+
109
+ See [`examples/react-router-demo`](https://github.com/prisma/prisma/tree/main/examples/react-router-demo) for the canonical configuration plus a smoke test that proves the dev loop.
110
+
111
+ ## Common Pitfalls
112
+
113
+ 1. **Pointing the plugin at `schema.psl` instead of `prisma.config.ts`.** The argument is the config path. The plugin reads the config to find the contract source.
114
+ 2. **Vite 6 or earlier.** Not supported. Upgrade Vite to 7 or 8.
115
+ 3. **The plugin warns: *"watching only the config; loader resolved inputs unavailable."*** The plugin couldn't resolve `contract.source.inputs` from the loader. The fallback watches only `prisma.config.ts` itself, so contract edits won't re-emit. Causes: the config file throws during loading; the contract source path resolves outside the Vite root. Fix the config error first, then check that the contract source path in the config is relative to (or inside) the Vite root.
116
+ 4. **Expecting `vite build` to re-emit.** It doesn't. Add a `prebuild` script.
117
+ 5. **Emit errors during dev**: the plugin surfaces them via Vite's error overlay. Read the overlay; the underlying cause is a contract authoring problem — chain to `references/debug.md` for resolution (PSL syntax, missing namespace, conflicting extensions).
118
+ 6. **Re-installing dependencies without the plugin's peer-range move.** When PN bumps the plugin's peer range, you must re-run `pnpm install` so the lockfile picks up the new range. A stale lockfile keeps the old plugin and produces confusing version mismatch warnings.
119
+
120
+ ## What Prisma 8 doesn't do yet
121
+
122
+ - **Next.js plugin.** No first-party `@internal/next-plugin-*` exists. Workaround: run `prisma contract emit` from a `prebuild` script in `package.json` and run it manually during development when the contract changes. Many Next.js projects also run a dev-time `tsx --watch` against a small script that calls the CLI on contract-source change. If you want a first-party Next.js plugin, file a feature request via the `references/feedback.md` skill.
123
+ - **Webpack, esbuild, Rollup, Turbopack plugins.** None exist yet as first-party. Workaround: the canonical `executeContractEmit` surface lives in `@internal/cli/control-api` — a small per-bundler plugin can call it from the bundler's prebuild hook, but PN doesn't ship one for you. The `vite-plugin-contract-emit` source is the reference implementation if you want to write one yourself. If you want a first-party plugin for your bundler, file a feature request via the `references/feedback.md` skill.
124
+ - **`vite build` integration.** The plugin runs in `vite dev` only. Workaround: a `prebuild` script that runs `prisma contract emit`. If you want the plugin to also run during `vite build`, file a feature request via the `references/feedback.md` skill.
125
+ - **Vite 6 or earlier.** Not on the support matrix. Workaround: upgrade Vite to 7 or 8. If you have a hard reason to stay on Vite 6, file a feature request via the `references/feedback.md` skill.
126
+
127
+ ## Reference Files
128
+
129
+ - The plugin's own README: <https://github.com/prisma/prisma/blob/main/packages/1-framework/3-tooling/vite-plugin-contract-emit/README.md> — support matrix, full API surface, architecture diagram, the *canonical publish path* warning for custom plugin authors.
130
+ - ADR 008 (Dev Auto-Emit, CI Explicit Emit) — the rationale for splitting dev-time auto-emit from the explicit CI / build step.
131
+ - ADR 032 (Dev Auto-Emit Integration) — the plugin's integration contract with the CLI control API.
132
+
133
+ ## Checklist
134
+
135
+ - [ ] Plugin pointed at `prisma.config.ts` (not the contract source).
136
+ - [ ] Vite version 7 or 8 (`pnpm ls vite`).
137
+ - [ ] `vite dev` log shows the initial emit on server start.
138
+ - [ ] Editing the contract source triggers a re-emit log line.
139
+ - [ ] `prebuild` script (or equivalent) runs `prisma contract emit` for CI / production builds.
140
+ - [ ] No `vite build` expectation that the plugin will run.
141
+ - [ ] For non-Vite bundlers: surfaced the *What PN doesn't do yet* entry and routed the user to `references/feedback.md` if they want first-party support.
142
+ - [ ] Did NOT confabulate a `@internal/next-plugin-contract-emit` package or any other bundler-specific plugin that doesn't exist.