@prisma/orm-sqlite 8.0.0-rc.2-dev.3 → 8.0.0-rc.20-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (166) hide show
  1. package/README.md +2 -7
  2. package/dist/config.d.mts +1 -1
  3. package/dist/config.d.mts.map +1 -1
  4. package/dist/config.mjs +3 -8
  5. package/dist/config.mjs.map +1 -1
  6. package/dist/contract-builder.d.mts +205 -15
  7. package/dist/contract-builder.d.mts.map +1 -1
  8. package/dist/contract-builder.mjs +24 -4
  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-support.d.mts +1 -0
  17. package/dist/family-contract__data-type-support.mjs +2 -0
  18. package/dist/family-contract__data-type.d.mts +1 -0
  19. package/dist/family-contract__data-type.mjs +2 -0
  20. package/dist/family-contract__sql-expression.d.mts +1 -0
  21. package/dist/family-contract__sql-expression.mjs +2 -0
  22. package/dist/family__psl-build.d.mts +1 -0
  23. package/dist/family__psl-build.mjs +2 -0
  24. package/dist/relational-core__collection-methods.d.mts +1 -0
  25. package/dist/relational-core__collection-methods.mjs +2 -0
  26. package/dist/relational-core__functions.d.mts +1 -0
  27. package/dist/relational-core__functions.mjs +2 -0
  28. package/dist/relational-core__index-reference.d.mts +1 -0
  29. package/dist/relational-core__index-reference.mjs +2 -0
  30. package/dist/runtime.d.mts +3 -3
  31. package/dist/runtime.d.mts.map +1 -1
  32. package/dist/runtime.mjs +107 -62
  33. package/dist/runtime.mjs.map +1 -1
  34. package/dist/sqlite-Yizsft25-C2Eb0g8b.d.mts +94 -0
  35. package/dist/sqlite-Yizsft25-C2Eb0g8b.d.mts.map +1 -0
  36. package/dist/sqlite-static-B8zoCVS5-XntMNNFh.mjs +83 -0
  37. package/dist/sqlite-static-B8zoCVS5-XntMNNFh.mjs.map +1 -0
  38. package/dist/static.d.mts +25 -2
  39. package/dist/static.d.mts.map +1 -0
  40. package/dist/static.mjs +2 -2
  41. package/dist/target__data-types.d.mts +1 -0
  42. package/dist/target__data-types.mjs +2 -0
  43. package/dist/utils__suppress-idle-connection-errors.d.mts +1 -0
  44. package/dist/utils__suppress-idle-connection-errors.mjs +2 -0
  45. package/dist/utils__text.d.mts +1 -0
  46. package/dist/utils__text.mjs +2 -0
  47. package/package.json +26 -15
  48. package/skills/prisma-8/SKILL.md +96 -0
  49. package/skills/prisma-8/references/build.md +142 -0
  50. package/skills/prisma-8/references/contract.md +544 -0
  51. package/skills/prisma-8/references/debug.md +149 -0
  52. package/skills/prisma-8/references/feedback.md +251 -0
  53. package/skills/prisma-8/references/migration-model.md +179 -0
  54. package/skills/prisma-8/references/migration-review.md +211 -0
  55. package/skills/prisma-8/references/migrations.md +581 -0
  56. package/skills/prisma-8/references/queries-mongo.md +238 -0
  57. package/skills/prisma-8/references/queries-postgres.md +710 -0
  58. package/skills/prisma-8/references/queries.md +253 -0
  59. package/skills/prisma-8/references/quickstart.md +317 -0
  60. package/skills/prisma-8/references/runtime.md +463 -0
  61. package/skills/prisma-8/references/supabase.md +234 -0
  62. package/skills/prisma-8/references/upgrade-app.md +102 -0
  63. package/skills/prisma-8/references/upgrade-extension.md +106 -0
  64. package/skills/prisma-8/upgrading/app/upgrades/0.10-to-0.11/instructions.md +56 -0
  65. package/skills/prisma-8/upgrading/app/upgrades/0.11-to-0.12/instructions.md +381 -0
  66. package/skills/prisma-8/upgrading/app/upgrades/0.11-to-0.12/re-emit-closed-mongo-contracts.ts +202 -0
  67. package/skills/prisma-8/upgrading/app/upgrades/0.11-to-0.12/re-emit-domain-namespaced-contracts.ts +201 -0
  68. package/skills/prisma-8/upgrading/app/upgrades/0.11-to-0.12/re-emit-postgres-public-default.ts +198 -0
  69. package/skills/prisma-8/upgrading/app/upgrades/0.11-to-0.12/strip-migration-labels-hints.ts +340 -0
  70. package/skills/prisma-8/upgrading/app/upgrades/0.12-to-0.13/instructions.md +339 -0
  71. package/skills/prisma-8/upgrading/app/upgrades/0.12-to-0.13/re-emit-mti-variant-link-columns.ts +229 -0
  72. package/skills/prisma-8/upgrading/app/upgrades/0.13-to-0.14/instructions.md +543 -0
  73. package/skills/prisma-8/upgrading/app/upgrades/0.13-to-0.14/migration-op-factories-to-methods.ts +290 -0
  74. package/skills/prisma-8/upgrading/app/upgrades/0.13-to-0.14/uuid-preset-rename.ts +43 -0
  75. package/skills/prisma-8/upgrading/app/upgrades/0.14-to-0.15/instructions.md +359 -0
  76. package/skills/prisma-8/upgrading/app/upgrades/0.15-to-0.16/instructions.md +173 -0
  77. package/skills/prisma-8/upgrading/app/upgrades/0.16-to-0.17/instructions.md +805 -0
  78. package/skills/prisma-8/upgrading/app/upgrades/0.16-to-0.17/strip-sha256-hash-prefixes.ts +382 -0
  79. package/skills/prisma-8/upgrading/app/upgrades/0.17-to-8.0.0-rc.1/instructions.md +72 -0
  80. package/skills/prisma-8/upgrading/app/upgrades/0.7-to-0.8/instructions.md +8 -0
  81. package/skills/prisma-8/upgrading/app/upgrades/0.8-to-0.9/instructions.md +36 -0
  82. package/skills/prisma-8/upgrading/app/upgrades/0.8-to-0.9/strip-inline-contracts.ts +226 -0
  83. package/skills/prisma-8/upgrading/app/upgrades/0.9-to-0.10/instructions.md +86 -0
  84. package/skills/prisma-8/upgrading/app/upgrades/0.9-to-0.10/stamp-storage-types-kind.ts +360 -0
  85. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.1-to-8.0.0-rc.2/instructions.md +588 -0
  86. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.10-to-8.0.0-rc.11/instructions.md +34 -0
  87. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.11-to-8.0.0-rc.12/instructions.md +639 -0
  88. 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
  89. 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
  90. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.12-to-8.0.0-rc.13/instructions.md +332 -0
  91. 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
  92. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.13-to-8.0.0-rc.14/instructions.md +489 -0
  93. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.14-to-8.0.0-rc.15/instructions.md +1368 -0
  94. 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
  95. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.15-to-8.0.0-rc.16/instructions.md +108 -0
  96. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.16-to-8.0.0-rc.17/instructions.md +755 -0
  97. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.17-to-8.0.0-rc.18/instructions.md +973 -0
  98. 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
  99. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.18-to-8.0.0-rc.19/instructions.md +1826 -0
  100. 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
  101. 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
  102. 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
  103. 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
  104. 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
  105. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.19-to-8.0.0-rc.20/instructions.md +502 -0
  106. 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
  107. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.2-to-8.0.0-rc.3/instructions.md +5 -0
  108. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.3-to-8.0.0-rc.4/instructions.md +158 -0
  109. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.4-to-8.0.0-rc.5/instructions.md +42 -0
  110. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.5-to-8.0.0-rc.6/instructions.md +157 -0
  111. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.6-to-8.0.0-rc.7/instructions.md +33 -0
  112. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.7-to-8.0.0-rc.8/instructions.md +36 -0
  113. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.8-to-8.0.0-rc.9/instructions.md +63 -0
  114. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.9-to-8.0.0-rc.10/instructions.md +84 -0
  115. package/skills/prisma-8/upgrading/extension/upgrades/0.10-to-0.11/instructions.md +276 -0
  116. package/skills/prisma-8/upgrading/extension/upgrades/0.11-to-0.12/instructions.md +738 -0
  117. package/skills/prisma-8/upgrading/extension/upgrades/0.11-to-0.12/migrate-contract-testing-imports.ts +97 -0
  118. package/skills/prisma-8/upgrading/extension/upgrades/0.11-to-0.12/regenerate-extension-public-baseline.ts +223 -0
  119. package/skills/prisma-8/upgrading/extension/upgrades/0.11-to-0.12/strip-migration-labels-hints.ts +340 -0
  120. package/skills/prisma-8/upgrading/extension/upgrades/0.12-to-0.13/instructions.md +266 -0
  121. package/skills/prisma-8/upgrading/extension/upgrades/0.13-to-0.14/instructions.md +522 -0
  122. package/skills/prisma-8/upgrading/extension/upgrades/0.13-to-0.14/migration-op-factories-to-methods.ts +290 -0
  123. package/skills/prisma-8/upgrading/extension/upgrades/0.13-to-0.14/uuid-preset-rename.ts +43 -0
  124. package/skills/prisma-8/upgrading/extension/upgrades/0.14-to-0.15/instructions.md +803 -0
  125. package/skills/prisma-8/upgrading/extension/upgrades/0.15-to-0.16/instructions.md +219 -0
  126. package/skills/prisma-8/upgrading/extension/upgrades/0.16-to-0.17/instructions.md +731 -0
  127. package/skills/prisma-8/upgrading/extension/upgrades/0.16-to-0.17/strip-sha256-hash-prefixes.ts +382 -0
  128. package/skills/prisma-8/upgrading/extension/upgrades/0.17-to-8.0.0-rc.1/instructions.md +194 -0
  129. package/skills/prisma-8/upgrading/extension/upgrades/0.7-to-0.8/instructions.md +8 -0
  130. package/skills/prisma-8/upgrading/extension/upgrades/0.8-to-0.9/instructions.md +57 -0
  131. package/skills/prisma-8/upgrading/extension/upgrades/0.8-to-0.9/strip-inline-contracts.ts +226 -0
  132. package/skills/prisma-8/upgrading/extension/upgrades/0.9-to-0.10/instructions.md +150 -0
  133. package/skills/prisma-8/upgrading/extension/upgrades/0.9-to-0.10/stamp-storage-types-kind.ts +360 -0
  134. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.1-to-8.0.0-rc.2/instructions.md +746 -0
  135. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.10-to-8.0.0-rc.11/instructions.md +34 -0
  136. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.11-to-8.0.0-rc.12/instructions.md +857 -0
  137. 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
  138. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.12-to-8.0.0-rc.13/instructions.md +504 -0
  139. 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
  140. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.13-to-8.0.0-rc.14/instructions.md +143 -0
  141. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.14-to-8.0.0-rc.15/instructions.md +2168 -0
  142. 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
  143. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.15-to-8.0.0-rc.16/instructions.md +223 -0
  144. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.16-to-8.0.0-rc.17/instructions.md +583 -0
  145. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.17-to-8.0.0-rc.18/instructions.md +1008 -0
  146. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.18-to-8.0.0-rc.19/instructions.md +2000 -0
  147. 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
  148. 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
  149. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.19-to-8.0.0-rc.20/instructions.md +379 -0
  150. 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
  151. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.2-to-8.0.0-rc.3/instructions.md +5 -0
  152. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.3-to-8.0.0-rc.4/instructions.md +137 -0
  153. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.4-to-8.0.0-rc.5/instructions.md +129 -0
  154. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.5-to-8.0.0-rc.6/instructions.md +102 -0
  155. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.6-to-8.0.0-rc.7/instructions.md +33 -0
  156. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.7-to-8.0.0-rc.8/instructions.md +35 -0
  157. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.8-to-8.0.0-rc.9/instructions.md +86 -0
  158. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.9-to-8.0.0-rc.10/instructions.md +63 -0
  159. package/dist/family-contract__pack-types.d.mts +0 -1
  160. package/dist/family-contract__pack-types.mjs +0 -2
  161. package/dist/sqlite-CjWZostj-Cprd7rkt.d.mts +0 -76
  162. package/dist/sqlite-CjWZostj-Cprd7rkt.d.mts.map +0 -1
  163. package/dist/sqlite-static-CBCbqogG-BtpT_pWA.mjs +0 -44
  164. package/dist/sqlite-static-CBCbqogG-BtpT_pWA.mjs.map +0 -1
  165. package/dist/target__native-type-normalizer.d.mts +0 -1
  166. package/dist/target__native-type-normalizer.mjs +0 -2
@@ -0,0 +1,193 @@
1
+ // Renames `table`/`column` to `entry`/`field` in execution default refs of contracts under `migrations/`.
2
+ import { readdir, readFile, rename, rm, writeFile } from 'node:fs/promises';
3
+ import { basename, dirname, join, relative, sep } from 'node:path';
4
+
5
+ const SKIP_DIRS = new Set(['node_modules', '.git', 'dist']);
6
+ const RENAMES = new Map([
7
+ ['table', 'entry'],
8
+ ['column', 'field'],
9
+ ]);
10
+
11
+ const check = process.argv.includes('--check');
12
+ const projectRoot = process.cwd();
13
+
14
+ function isContractFile(name: string): boolean {
15
+ return name.endsWith('.json') || name.endsWith('.d.ts');
16
+ }
17
+
18
+ async function findMigrationFiles(dir: string, found: string[] = []): Promise<string[]> {
19
+ for (const entry of await readdir(dir, { withFileTypes: true })) {
20
+ const path = join(dir, entry.name);
21
+ if (entry.isDirectory() && !SKIP_DIRS.has(entry.name)) {
22
+ await findMigrationFiles(path, found);
23
+ } else if (
24
+ entry.isFile() &&
25
+ isContractFile(entry.name) &&
26
+ relative(projectRoot, dir).split(sep).includes('migrations')
27
+ ) {
28
+ found.push(path);
29
+ }
30
+ }
31
+ return found;
32
+ }
33
+
34
+ function isObject(value: unknown): value is Record<string, unknown> {
35
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
36
+ }
37
+
38
+ function sortKeys(value: unknown): unknown {
39
+ if (Array.isArray(value)) return value.map(sortKeys);
40
+ if (!isObject(value)) return value;
41
+ const sorted: Record<string, unknown> = {};
42
+ for (const key of Object.keys(value).sort()) sorted[key] = sortKeys(value[key]);
43
+ return sorted;
44
+ }
45
+
46
+ function parseJson(text: string): unknown {
47
+ try {
48
+ return JSON.parse(text);
49
+ } catch {
50
+ return undefined;
51
+ }
52
+ }
53
+
54
+ function serializeLike(original: string, value: unknown): string {
55
+ if (original === `${JSON.stringify(sortKeys(parseJson(original)))}\n`) {
56
+ return `${JSON.stringify(sortKeys(value))}\n`;
57
+ }
58
+ const indent = /\n([ \t]+)/.exec(original)?.[1] ?? 2;
59
+ return `${JSON.stringify(value, null, indent)}${original.endsWith('\n') ? '\n' : ''}`;
60
+ }
61
+
62
+ function renameInJson(text: string): string | undefined {
63
+ const contract = parseJson(text);
64
+ if (contract === undefined) return undefined;
65
+ if (!isObject(contract) || !isObject(contract['execution'])) return text;
66
+ const mutations = contract['execution']['mutations'];
67
+ const defaults = isObject(mutations) ? mutations['defaults'] : undefined;
68
+ if (!Array.isArray(defaults)) return text;
69
+ let changed = false;
70
+ for (const entry of defaults) {
71
+ if (!isObject(entry) || !isObject(entry['ref'])) continue;
72
+ const keys = Object.keys(entry['ref']);
73
+ if (!keys.some((key) => RENAMES.has(key))) continue;
74
+ entry['ref'] = sortKeys(
75
+ Object.fromEntries(
76
+ Object.entries(entry['ref']).map(([key, value]) => [RENAMES.get(key) ?? key, value]),
77
+ ),
78
+ );
79
+ changed = true;
80
+ }
81
+ return changed ? serializeLike(text, contract) : text;
82
+ }
83
+
84
+ const DEFAULT_ELEMENT_PATH = ['execution', 'mutations', 'defaults', ''];
85
+ const MEMBER_BEFORE_OPENER = /readonly (\w+): (?:readonly )?$/;
86
+ const REF_MEMBER = /readonly (\w+): ('(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*")/g;
87
+
88
+ interface OpenBlock {
89
+ readonly member: string;
90
+ readonly start: number;
91
+ readonly isDefaultRef: boolean;
92
+ }
93
+
94
+ interface Span {
95
+ readonly start: number;
96
+ readonly end: number;
97
+ }
98
+
99
+ function closingQuote(text: string, start: number): number {
100
+ let i = start + 1;
101
+ while (i < text.length && text[i] !== text[start]) i += text[i] === '\\' ? 2 : 1;
102
+ return i;
103
+ }
104
+
105
+ function commentEnd(text: string, start: number): number {
106
+ const end =
107
+ text[start + 1] === '/' ? text.indexOf('\n', start) : text.indexOf('*/', start + 2) + 1;
108
+ return end > start ? end : text.length;
109
+ }
110
+
111
+ function isDefaultElement(open: readonly OpenBlock[]): boolean {
112
+ const members = open.slice(-DEFAULT_ELEMENT_PATH.length).map((block) => block.member);
113
+ return members.join('/') === DEFAULT_ELEMENT_PATH.join('/');
114
+ }
115
+
116
+ function executionDefaultRefs(text: string): Span[] {
117
+ const open: OpenBlock[] = [];
118
+ const refs: Span[] = [];
119
+ for (let i = 0; i < text.length; i++) {
120
+ const char = text[i];
121
+ if (char === "'" || char === '"' || char === '`') {
122
+ i = closingQuote(text, i);
123
+ } else if (char === '/' && (text[i + 1] === '/' || text[i + 1] === '*')) {
124
+ i = commentEnd(text, i);
125
+ } else if (char === '{' || char === '[') {
126
+ const member = MEMBER_BEFORE_OPENER.exec(text.slice(Math.max(0, i - 64), i))?.[1] ?? '';
127
+ const isDefaultRef = char === '{' && member === 'ref' && isDefaultElement(open);
128
+ open.push({ member, start: i, isDefaultRef });
129
+ } else if (char === '}' || char === ']') {
130
+ const block = open.pop();
131
+ if (block?.isDefaultRef) refs.push({ start: block.start, end: i + 1 });
132
+ }
133
+ }
134
+ return refs;
135
+ }
136
+
137
+ function renameRefMembers(block: string): string {
138
+ const members = [...block.matchAll(REF_MEMBER)];
139
+ if (!members.some(([, key = '']) => RENAMES.has(key))) return block;
140
+ const sorted = members
141
+ .map(([, key = '', value = '']) => `readonly ${RENAMES.get(key) ?? key}: ${value}`)
142
+ .sort();
143
+ let i = 0;
144
+ return block.replace(REF_MEMBER, () => sorted[i++] ?? '');
145
+ }
146
+
147
+ function renameInDts(text: string): string {
148
+ let renamed = text;
149
+ for (const { start, end } of executionDefaultRefs(text).reverse()) {
150
+ const block = renameRefMembers(renamed.slice(start, end));
151
+ renamed = `${renamed.slice(0, start)}${block}${renamed.slice(end)}`;
152
+ }
153
+ return renamed;
154
+ }
155
+
156
+ async function replaceFile(path: string, content: string): Promise<void> {
157
+ const temporary = join(dirname(path), `.${basename(path)}.${process.pid}.tmp`);
158
+ try {
159
+ await writeFile(temporary, content, 'utf-8');
160
+ await rename(temporary, path);
161
+ } catch (error) {
162
+ await rm(temporary, { force: true });
163
+ throw error;
164
+ }
165
+ }
166
+
167
+ async function main(): Promise<void> {
168
+ const files = await findMigrationFiles(projectRoot);
169
+ let changed = 0;
170
+ let unparseable = 0;
171
+ for (const path of files.sort()) {
172
+ const before = await readFile(path, 'utf-8');
173
+ const after = path.endsWith('.json') ? renameInJson(before) : renameInDts(before);
174
+ if (after === undefined) {
175
+ unparseable += 1;
176
+ console.log(`NOT JSON ${relative(projectRoot, path)}`);
177
+ continue;
178
+ }
179
+ if (after === before) continue;
180
+ changed += 1;
181
+ console.log(`${check ? 'WOULD FIX' : 'FIXED'} ${relative(projectRoot, path)}`);
182
+ if (!check) await replaceFile(path, after);
183
+ }
184
+ console.log(
185
+ `${files.length} file(s) under migrations/ scanned, ${changed} ${check ? 'need' : 'got'} the rename.`,
186
+ );
187
+ if (unparseable > 0) {
188
+ console.log(`${unparseable} .json file(s) could not be parsed; check them by hand.`);
189
+ }
190
+ if (unparseable > 0 || (check && changed > 0)) process.exit(1);
191
+ }
192
+
193
+ void main();
@@ -0,0 +1,143 @@
1
+ ---
2
+ from: "8.0.0-rc.13"
3
+ to: "8.0.0-rc.14"
4
+ changes:
5
+ - id: engine-pin-moves-to-0-6-2
6
+ summary: |
7
+ The toolchain now peers `@prisma/cli-engine@0.6.2` (up from 0.6.1). An extension package that pins `@prisma/cli-engine` for its tests or tooling must move the pin to `0.6.2`. With this engine the CLI prints its own name in hints and messages where it used to print a literal `{bin}`.
8
+ detection:
9
+ glob: "**/package.json"
10
+ contains:
11
+ - '"@prisma/cli-engine": "0.6.1"'
12
+ - id: temporal-polyfill-is-a-peer-dependency
13
+ summary: |
14
+ `temporal-polyfill` is now a required peer dependency of `@prisma/orm-target-postgres` and `@prisma/orm-postgres`, not a dependency. The target's control entry imports it. An extension pack that peers the target does not declare it; the application supplies it. npm, pnpm and bun install it automatically. An extension package that installs with Yarn and loads the target's control entry in its tests or tooling must add `temporal-polyfill` (`^1.0.4`) to its `devDependencies`.
15
+ detection:
16
+ glob: "**/yarn.lock"
17
+ contains:
18
+ - "@prisma/orm-postgres@"
19
+ - "@prisma/orm-target-postgres@"
20
+ anyMatch: true
21
+ - id: mongo-result-shape-includes-and-value-objects
22
+ summary: |
23
+ `contractModelToMongoResultShape(model, options)` (`@prisma/orm-mongo/query-builder`,
24
+ `@internal/mongo-query-builder`) takes `includes`, a map from relation name to the shape of
25
+ the included document, instead of `includeRelationNames`, and an optional `valueObjects`
26
+ map that makes value-object fields decode as documents. `contractFieldToMongoFieldShape`
27
+ takes the same `valueObjects` as an optional second argument.
28
+ detection:
29
+ glob: "**/*.{ts,mts,cts}"
30
+ matches:
31
+ - '\bincludeRelationNames\b'
32
+ - id: mongo-compile-query-value-objects
33
+ summary: |
34
+ `compileMongoQuery(collection, state, storageHash, model, valueObjects)`
35
+ (`@prisma/orm-mongo/orm`, `@internal/mongo-orm`) takes the contract's value objects as a
36
+ fifth argument, and each `MongoIncludeExpr` in the state carries the related model as
37
+ `targetModel`.
38
+ detection:
39
+ glob: "**/*.{ts,mts,cts}"
40
+ matches:
41
+ - '\bcompileMongoQuery\('
42
+ - id: psl-unknown-field-preset-lists-presets
43
+ summary: |
44
+ `reportUnknownFieldPreset(...)` (`@prisma/orm-framework/psl-parser/interpret`,
45
+ `@internal/psl-parser/interpret`) takes the `authoringContributions` it looks the namespace's
46
+ presets up in, and its message lists them.
47
+ detection:
48
+ glob: "**/*.{ts,mts,cts}"
49
+ matches:
50
+ - '\breportUnknownFieldPreset\('
51
+ - id: mongo-double-codec-encodes-double
52
+ summary: |
53
+ The `mongo/double@1` codec's `encode` (from `buildStandardCodecRegistry()` or
54
+ `mongoStandardCodecs` in `@prisma/orm-mongo/target/codecs`, `@internal/target-mongo/codecs`)
55
+ returns the driver's `Double` wrapping the number, so a whole number is stored as a BSON
56
+ double; it refuses a value that is not a number. The `mongo/int32@1` codec's `encode` refuses
57
+ a value that is not an integer in the signed 32-bit range. The `mongo/string@1`,
58
+ `mongo/bool@1`, `mongo/date@1`, `mongo/objectId@1` and `mongo/vector@1` codecs' `encode`
59
+ refuse a value of the wrong type, and `mongo/binary@1` decodes a `Buffer` or `Uint8Array` as
60
+ well as a `Binary`.
61
+ detection:
62
+ glob: "**/*.{ts,mts,cts}"
63
+ matches:
64
+ - "['\"]mongo/(?:double|int32)@1['\"]"
65
+ - id: mongo-insert-results-carry-documents
66
+ summary: |
67
+ `InsertOneResult` and `InsertManyResult` (`@prisma/orm-mongo/query-ast/execution`,
68
+ `@internal/mongo-query-ast/execution`) carry the inserted documents as stored: `document` on
69
+ one, `documents` on the other, in insert order. A Mongo driver's `insertOne` and `insertMany`
70
+ commands must yield them; the ORM returns them, decoded, from `create()` and `createAll()`.
71
+ detection:
72
+ glob: "**/*.{ts,mts,cts}"
73
+ matches:
74
+ - 'import[^;]*\bInsert(?:One|Many)Result\b[^;]*from\s*[''"]@(?:prisma/orm-mongo|internal/mongo-query-ast)/'
75
+ - id: mongo-adapter-passes-bson-values-through
76
+ summary: |
77
+ The Mongo adapter's `resolveValue` passes an instance of a `bson` class (an object with a
78
+ `_bsontype` tag and a class prototype), a `RegExp` and a `Uint8Array` through unchanged
79
+ instead of copying their fields into a plain object, at any depth of a command.
80
+ - id: mongo-codec-types-carry-traits
81
+ summary: |
82
+ Each entry of the Mongo `CodecTypes` map (`@prisma/orm-mongo/target/codec-types`,
83
+ `@internal/target-mongo/codec-types`) carries `traits`, the union of its codec descriptor's
84
+ traits. The ORM's field accessor gives `inc` and `mul` to a field whose codec has the
85
+ `numeric` trait, taking the codec's input type, and `FieldExpression` takes that operand
86
+ type as an optional second type parameter.
87
+ - id: mongo-field-builder-preset-not-optional
88
+ summary: |
89
+ The Mongo `FieldBuilder` (`@prisma/orm-mongo/contract-builder`,
90
+ `@internal/mongo-contract-ts/contract-builder`)'s `optional` and `many` are properties whose type refuses a call when
91
+ the builder carries execution defaults: a function whose `this` type is a string that says
92
+ why. The widest constraint,
93
+ `FieldBuilder<ContractFieldType, boolean, boolean, EnumTypeHandle | undefined, ExecutionMutationDefaultPhases | undefined>`,
94
+ still accepts every builder.
95
+ ---
96
+
97
+ # 8.0.0-rc.13 → 8.0.0-rc.14 — Extension author upgrade instructions
98
+
99
+ ## `engine-pin-moves-to-0-6-2`
100
+
101
+ For every `package.json` matched by `detection`, change the `@prisma/cli-engine` version from `0.6.1` to `0.6.2` and reinstall.
102
+
103
+ Engine 0.6.2 replaces the placeholder `{bin}` with the name of the CLI that was run. A hint that used to print as `{bin} db migrate` now prints as `prisma db migrate`. The replacement applies to next actions, warnings, errors, and summary and list text, in human, `--json`, and `--format markdown` output. Keep writing `{bin}` in the commands and messages your extension produces; the engine replaces it. If a test of yours runs the CLI and matches the literal text `{bin}` in its output, change it to match the CLI name.
104
+
105
+ ## `temporal-polyfill-is-a-peer-dependency`
106
+
107
+ For each Yarn project that `detection` matches, add `"temporal-polyfill": "^1.0.4"` to `devDependencies` in the `package.json` that installs `@prisma/orm-target-postgres` or `@prisma/orm-postgres`, then reinstall. Without it, a test or script that loads the target's control entry fails because Node.js cannot find the package `temporal-polyfill`.
108
+
109
+ ## `mongo-result-shape-includes-and-value-objects`
110
+
111
+ Replace `includeRelationNames: ['author']` with `includes: { author: shape }`, where `shape` describes the included document, for example `{ kind: 'document', nullable: true, fields }` for a to-one include with `fields` from `contractModelToMongoResultShape(targetModel, { valueObjects }).fields`, or an `array` of such documents for a to-many include. A shape of `{ kind: 'unknown' }` keeps the old behaviour of passing the included value through undecoded. Pass `valueObjects` (for example `domainValueObjectsAtDefaultNamespace(contract.domain)`) to decode value-object fields.
112
+
113
+ ## `mongo-compile-query-value-objects`
114
+
115
+ Pass the contract's value objects, `domainValueObjectsAtDefaultNamespace(contract.domain) ?? {}`, as the fifth argument, and add `targetModel` (the related model's definition) to each include expression you build.
116
+
117
+ ## `psl-unknown-field-preset-lists-presets`
118
+
119
+ Add the `authoringContributions` your interpreter already holds to each call.
120
+
121
+ ## `mongo-double-codec-encodes-double`
122
+
123
+ Code that compares what the `mongo/double@1` codec's `encode` returns with a number unwraps it with `.valueOf()` or `Number(...)`. A test double or fixture that passed a fraction or an out-of-range number through the `mongo/int32@1` codec's `encode` now gets `RUNTIME.ENCODE_FAILED`; pass an integer. The same holds for a test double that passes a value of the wrong type through the string, boolean, date, ObjectId or vector codec, such as a number for an ObjectId; pass a 24-digit hex string or an `ObjectId`.
124
+
125
+ ## `mongo-insert-results-carry-documents`
126
+
127
+ A driver of your own yields `{ insertedId, document }` for `insertOne`, where `document` is the command's document with the `_id` the database assigned, as the database stores it: serialise it with the database's BSON options and deserialise it again, as `BSON.deserialize(BSON.serialize(document, options), options)` does. It yields `{ insertedIds, insertedCount, documents }` for `insertMany`. Code that builds these results in a test double adds the same fields.
128
+
129
+ ## `mongo-adapter-passes-bson-values-through`
130
+
131
+ This change has no detection pattern: it changes what reaches the driver, not how the adapter is called.
132
+
133
+ A codec or middleware that received a copied plain object in place of a `bson` class instance, and rebuilt the instance from it, now receives the instance. Remove the rebuilding.
134
+
135
+ ## `mongo-codec-types-carry-traits`
136
+
137
+ This change has no detection pattern: few extensions build a Mongo codec types map themselves.
138
+
139
+ A type you declare to satisfy the Mongo `CodecTypes` shape, or a codec types map of your own that should get `inc` and `mul`, adds `traits` to each entry, such as `readonly traits: 'equality' | 'order' | 'numeric'` for a numeric codec.
140
+
141
+ ## `mongo-field-builder-preset-not-optional`
142
+
143
+ This change has no detection pattern: few extensions implement `FieldBuilder` themselves. An object typed as a `FieldBuilder` that implements `optional()` and `many()` as methods assigns them through a cast to the conditional property types, as `createFieldBuilder` does, or builds the field with the contract builder's `field` helpers.