@prisma/orm-sqlite 8.0.0-rc.20-dev.8 → 8.0.0-rc.20-dev.10

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 (26) hide show
  1. package/dist/runtime.mjs +1 -1
  2. package/dist/runtime.mjs.map +1 -1
  3. package/dist/{sqlite-static-DORjKoZ5-ChzQDdU5.mjs → sqlite-static-mr8PBZYf-C8YT9m5s.mjs} +3 -3
  4. package/dist/sqlite-static-mr8PBZYf-C8YT9m5s.mjs.map +1 -0
  5. package/dist/static.mjs +1 -1
  6. package/package.json +8 -8
  7. package/skills/prisma-8/SKILL.md +1 -1
  8. package/skills/prisma-8/references/migrations.md +2 -1
  9. package/skills/prisma-8/references/upgrade-app.md +2 -2
  10. package/skills/prisma-8/references/upgrade-extension.md +2 -2
  11. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.18-to-8.0.0-rc.19/instructions.md +130 -94
  12. 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 +245 -30
  13. 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 +8 -5
  14. 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 +77 -23
  15. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.18-to-8.0.0-rc.19/scripts/remove-nocheck/remove-nocheck.ts +1668 -19
  16. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.19-to-8.0.0-rc.20/instructions.md +23 -12
  17. 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 +50 -15
  18. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.18-to-8.0.0-rc.19/instructions.md +273 -87
  19. 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 +245 -30
  20. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.18-to-8.0.0-rc.19/scripts/data-type-values/data-type-values.ts +1120 -0
  21. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.18-to-8.0.0-rc.19/scripts/default-generators-to-on-create/rewrite-default-generators.mjs +86 -0
  22. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.18-to-8.0.0-rc.19/scripts/mongo-field-storage-names/mongo-field-storage-names.ts +304 -0
  23. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.18-to-8.0.0-rc.19/scripts/remove-nocheck/remove-nocheck.ts +1668 -19
  24. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.19-to-8.0.0-rc.20/instructions.md +8 -6
  25. 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 +50 -15
  26. package/dist/sqlite-static-DORjKoZ5-ChzQDdU5.mjs.map +0 -1
@@ -4,11 +4,11 @@ to: "8.0.0-rc.20"
4
4
  changes:
5
5
  - id: engine-pin-moves-to-0-9-0
6
6
  summary: |
7
- The toolchain now peers `@prisma/cli-engine@0.9.0` (up from 0.7.0). An extension package that depends on `@prisma/cli-engine` for its tests or tooling must move to `0.9.0`.
7
+ The toolchain now peers `@prisma/cli-engine@0.9.0` (up from 0.7.0). An extension package whose tests or tooling load `@prisma/cli-engine` alongside the Prisma toolchain must move it to `0.9.0`, in `package.json` or in a `pnpm-workspace.yaml` catalog. A separate CLI that the package builds on the engine is not affected. The detection matches an engine version below 0.9 in either file.
8
8
  detection:
9
- glob: "**/package.json"
9
+ glob: "**/{package.json,pnpm-workspace.yaml}"
10
10
  matches:
11
- - '"@prisma/cli-engine":\s*"[^"]*(?<![\d.])0\.[0-8](?!\d)'
11
+ - '[\x27"]@prisma/cli-engine[\x27"]\s*:\s*[\x27"]?[^\x27"\n#]*(?<![\d.])0\.[0-8](?!\d)'
12
12
  - id: piped-output-needs-json
13
13
  summary: |
14
14
  A piped Prisma ORM command no longer prints JSON. A test that runs the CLI with a non-terminal stdout and parses JSON frames from it must pass `--json`.
@@ -143,7 +143,9 @@ One change comes with a script. Run `stored-contracts-expand-type-aliases` befor
143
143
 
144
144
  ### `engine-pin-moves-to-0-9-0`
145
145
 
146
- For every `package.json` matched by `detection`, change the `@prisma/cli-engine` version (`0.7.0`, `^0.7.0` or any other 0.x below 0.9) to `0.9.0` and reinstall.
146
+ This applies to tests and tooling that load `@prisma/cli-engine` alongside the Prisma toolchain. A separate CLI that the package builds on the engine runs its own engine, so it does not have to move with this upgrade.
147
+
148
+ For every `package.json` or `pnpm-workspace.yaml` catalog matched by `detection`, change the `@prisma/cli-engine` version (`0.7.0`, `^0.7.0` or any other 0.x below 0.9) to `0.9.0` and reinstall.
147
149
 
148
150
  ### `piped-output-needs-json`
149
151
 
@@ -163,7 +165,7 @@ Migration snapshots that an extension ships, its bundled `contract.json`, and an
163
165
  node <guide>/scripts/expand-type-aliases/expand-type-aliases.ts
164
166
  ```
165
167
 
166
- `<guide>` is the directory that holds this guide. Node 24 or later runs the TypeScript script directly; it needs no `tsx`. The script reads and writes files only and needs no database. It rewrites every SQL contract under the root, skipping `node_modules`, `.git`, `dist` and `build`. That includes test fixtures: if you keep an old contract on purpose, restore it with git afterwards.
168
+ `<guide>` is the directory that holds this guide. Node 24 or later runs the TypeScript script directly; it needs no `tsx`. The script reads and writes files only and needs no database. It rewrites every SQL contract under the root, skipping `node_modules`, `dist`, `build` and every directory whose name starts with `.`, such as `.git` and the worktrees under `.claude/worktrees/`. That includes test fixtures: if you keep an old contract on purpose, restore it with git afterwards.
167
169
 
168
170
  In each contract it replaces every column's `typeRef` with the parameters of the `storage.types` entry it names, and removes each entry a column named. It makes the same change in the `contract.d.ts` next to the contract. The extension's own contract space is an extension's space, because its `migrations/` directory holds `refs/` directly, so an entry that no column names is kept, as a database type the contract registers, and the script lists it. The script cannot tell such an entry from an alias your source declares but no field uses, so it keeps both. A re-emit drops an unused alias, so the bundled contract then gets another storage hash than the one the script wrote into `migrations/refs/head.json`. Do not change the script's output to match: each application runs the same script on its own copy of your migrations and gets the hash the script wrote. Add a migration to the re-emitted contract instead, as described after the re-emit below.
169
171
 
@@ -210,7 +212,7 @@ const contractSpace = contractSpaceFromJson<Contract<SqlStorage>>({
210
212
  });
211
213
  ```
212
214
 
213
- If the storage hash of the bundled contract changed, tell the applications that use the extension, in your release notes, to run `prisma db sign` against every database after they upgrade, and name the old and new hash. The old hash is the one the bundled contract had before you ran the script, and the new hash is the one in `migrations/refs/head.json` when you publish. The Supabase extension's contract is an example: its hash changes from `292489649ae6d6928de98a32b544bd9caf6b7d49718c10fe2720b83545a4b5a2` to `110ad99e1e466691bdb0a4349a17365561e76ad017f58beb272f4496b05b8e9e`. Tell them too that `prisma migration status` no longer marks the extension's migrations applied before the upgrade as applied, because each rewritten migration has a new hash. `prisma db migrate` runs none of them again, and `prisma db verify` passes.
215
+ If the storage hash of the bundled contract changed, tell the applications that use the extension, in your release notes, to run `prisma db sign` against every database after they upgrade, and name the old and new hash. The old hash is the one the bundled contract had before you ran the script, and the new hash is the one in `migrations/refs/head.json` when you publish. The Supabase extension's contract is an example: its hash changes from `292489649ae6d6928de98a32b544bd9caf6b7d49718c10fe2720b83545a4b5a2` to `110ad99e1e466691bdb0a4349a17365561e76ad017f58beb272f4496b05b8e9e`. Tell them too that `prisma migration status` no longer marks the extension's migrations applied before the upgrade as applied, because each rewritten migration has a new hash. `prisma db migrate` runs none of them again, and `prisma db verify` passes. A database that has not applied every migration yet is refused by a plain `prisma db sign`, and `prisma db migrate` stops on it with `MIGRATION.MARKER_MISMATCH`: tell them to sign it with `prisma db sign --contract <the last migration it applied>` and then run `prisma db migrate`, as the app guide's `stored-contracts-expand-type-aliases` says.
214
216
 
215
217
  ### `types-key-is-database-types`
216
218
 
@@ -31,10 +31,11 @@ interface JsonRecord {
31
31
  [key: string]: Json;
32
32
  }
33
33
 
34
- const SKIPPED_DIRECTORIES = new Set(['node_modules', '.git', 'dist', 'build']);
34
+ const SKIPPED_DIRECTORIES = new Set(['node_modules', 'dist', 'build']);
35
35
  const APP_SPACE_ID = 'app';
36
36
  const HASH = /^[0-9a-f]{64}$/;
37
37
  const TEMPORARY_SUFFIX = '.expand-type-aliases-tmp';
38
+ const BYTE_ORDER_MARK = '\uFEFF';
38
39
 
39
40
  function isRecord(value: unknown): value is JsonRecord {
40
41
  if (typeof value !== 'object' || value === null || Array.isArray(value)) return false;
@@ -42,9 +43,13 @@ function isRecord(value: unknown): value is JsonRecord {
42
43
  return prototype === Object.prototype || prototype === null;
43
44
  }
44
45
 
46
+ function withoutByteOrderMark(text: string): string {
47
+ return text.startsWith(BYTE_ORDER_MARK) ? text.slice(BYTE_ORDER_MARK.length) : text;
48
+ }
49
+
45
50
  function parseJson(text: string): Json | undefined {
46
51
  try {
47
- const value: Json = JSON.parse(text);
52
+ const value: Json = JSON.parse(withoutByteOrderMark(text));
48
53
  return value;
49
54
  } catch {
50
55
  return undefined;
@@ -325,7 +330,7 @@ function listFiles(root: string): ProjectFiles {
325
330
  continue;
326
331
  }
327
332
  if (entry.isDirectory() || (entry.isSymbolicLink() && isDirectory(path))) {
328
- if (!SKIPPED_DIRECTORIES.has(entry.name)) visit(path);
333
+ if (!SKIPPED_DIRECTORIES.has(entry.name) && !entry.name.startsWith('.')) visit(path);
329
334
  continue;
330
335
  }
331
336
  if (!isFileEntry(dir, entry)) continue;
@@ -518,12 +523,20 @@ function withStorageHash(contract: JsonRecord, hash: string): JsonRecord {
518
523
  return { ...contract, storage: { ...storage, storageHash: hash } };
519
524
  }
520
525
 
521
- /** The contract written the way the file held it: a snapshot's canonical line, or indented JSON. */
526
+ function lineEndingOf(text: string): string {
527
+ return text.includes('\r\n') ? '\r\n' : '\n';
528
+ }
529
+
530
+ /** The contract written the way the file held it: a snapshot's canonical line, or indented JSON, with the file's byte order mark and line ending. */
522
531
  function writtenForm(contract: JsonRecord, original: JsonRecord, text: string): string {
523
- const newline = text.endsWith('\n') ? '\n' : '';
524
- if (text === `${canonicalizeJson(original)}${newline}`)
525
- return `${canonicalizeJson(contract)}${newline}`;
526
- return `${JSON.stringify(contract, null, 2)}${newline}`;
532
+ const mark = text.startsWith(BYTE_ORDER_MARK) ? BYTE_ORDER_MARK : '';
533
+ const body = withoutByteOrderMark(text);
534
+ const lineEnding = lineEndingOf(body);
535
+ const finalNewline = body.endsWith('\n') ? lineEnding : '';
536
+ if (body === `${canonicalizeJson(original)}${finalNewline}`)
537
+ return `${mark}${canonicalizeJson(contract)}${finalNewline}`;
538
+ const indented = JSON.stringify(contract, null, 2).replaceAll('\n', lineEnding);
539
+ return `${mark}${indented}${finalNewline}`;
527
540
  }
528
541
 
529
542
  interface Block {
@@ -621,7 +634,7 @@ function lineStart(text: string, position: number): number {
621
634
 
622
635
  /** The end of the member a block closes: past its `;` and the line break after it. */
623
636
  function memberEnd(text: string, block: Block): number {
624
- const rest = /^\s*;?[ \t]*\n?/.exec(text.slice(block.end + 1));
637
+ const rest = /^\s*;?[ \t]*(?:\r?\n)?/.exec(text.slice(block.end + 1));
625
638
  return block.end + 1 + (rest?.[0].length ?? 0);
626
639
  }
627
640
 
@@ -657,7 +670,7 @@ function topLevelMembers(literal: string): string[] {
657
670
  }
658
671
 
659
672
  /** The `readonly typeParams` member, laid out as the emitter's formatter lays it out at `indent`. */
660
- function typeParamsMember(literal: string, indent: string): string {
673
+ function typeParamsMember(literal: string, indent: string, lineEnding: string): string {
661
674
  const lines = literal.split('\n');
662
675
  const head = `${indent}readonly typeParams: `;
663
676
  if (lines.length > 1) {
@@ -670,7 +683,7 @@ function typeParamsMember(literal: string, indent: string): string {
670
683
  const single = `${head}${literal};`;
671
684
  if (single.length <= DTS_LINE_WIDTH) return single;
672
685
  const members = topLevelMembers(literal).map((member) => `${indent} ${member};`);
673
- return `${head}{\n${members.join('\n')}\n${indent}};`;
686
+ return `${head}{${lineEnding}${members.join(lineEnding)}${lineEnding}${indent}};`;
674
687
  }
675
688
 
676
689
  /** The text of `typeParams` in an entry block of `readonly types`, as the emitter wrote it. */
@@ -703,6 +716,7 @@ function rewriteDts(
703
716
  removedEntries: ReadonlySet<string>,
704
717
  hashes: ReadonlyMap<string, string>,
705
718
  ): string {
719
+ const lineEnding = lineEndingOf(text);
706
720
  const blocks = scanBlocks(text);
707
721
  const typesBlock = storageTypesBlock(blocks);
708
722
  const entryBlocks = typesBlock === undefined ? [] : childBlocks(blocks, typesBlock);
@@ -726,12 +740,13 @@ function rewriteDts(
726
740
  const literal = literals.get(alias);
727
741
  if (literal === undefined) {
728
742
  const end = match.index + match[0].length;
729
- edits.push({ start, end: text[end] === '\n' ? end + 1 : end, text: '' });
743
+ const lineBreak = /^\r?\n/.exec(text.slice(end))?.[0] ?? '';
744
+ edits.push({ start, end: end + lineBreak.length, text: '' });
730
745
  } else {
731
746
  edits.push({
732
747
  start,
733
748
  end: match.index + match[0].length,
734
- text: typeParamsMember(literal, indentOf(text, match.index)),
749
+ text: typeParamsMember(literal, indentOf(text, match.index), lineEnding),
735
750
  });
736
751
  }
737
752
  }
@@ -966,7 +981,27 @@ function mergedSnapshots(
966
981
 
967
982
  const JSON_FILES_THAT_MUST_PARSE = new Set(['contract.json', 'migration.json']);
968
983
 
969
- function main(root: string): number {
984
+ function parseRoot(args: readonly string[]): { readonly root: string; readonly errors: string[] } {
985
+ const errors = args.filter((arg) => arg.startsWith('-')).map((arg) => `${arg}: unknown option`);
986
+ const positional = args.filter((arg) => !arg.startsWith('-'));
987
+ if (positional.length > 1) errors.push(`expected one project root, got ${positional.length}`);
988
+ const root = resolve(positional[0] ?? process.cwd());
989
+ if (errors.length === 0 && !isDirectory(root)) errors.push(`${root}: not a directory`);
990
+ if (errors.length > 0) errors.push('Usage: node expand-type-aliases.ts [project-root]');
991
+ return { root, errors };
992
+ }
993
+
994
+ function main({
995
+ root,
996
+ errors,
997
+ }: {
998
+ readonly root: string;
999
+ readonly errors: readonly string[];
1000
+ }): number {
1001
+ if (errors.length > 0) {
1002
+ process.stderr.write(`${errors.join('\n')}\n`);
1003
+ return 1;
1004
+ }
970
1005
  const display = (path: string): string => relative(root, path).split(sep).join('/');
971
1006
  const files = listFiles(root);
972
1007
  const references = hashReferences(files);
@@ -1168,4 +1203,4 @@ function main(root: string): number {
1168
1203
  return 0;
1169
1204
  }
1170
1205
 
1171
- process.exitCode = main(resolve(process.argv[2] ?? '.'));
1206
+ process.exitCode = main(parseRoot(process.argv.slice(2)));
@@ -1 +0,0 @@
1
- {"version":3,"file":"sqlite-static-DORjKoZ5-ChzQDdU5.mjs","names":[],"sources":["../../../../3-targets/sqlite/9-facade/dist/sqlite-static-DORjKoZ5.mjs"],"sourcesContent":["import sqliteAdapter from \"@internal/adapter-sqlite/runtime\";\nimport { UNBOUND_NAMESPACE_ID } from \"@internal/framework-components/ir\";\nimport { createRawLane, sql } from \"@internal/sql-builder/runtime\";\nimport { createExecutionContext, createSqlExecutionStack, createToSql } from \"@internal/sql-runtime\";\nimport sqliteTarget, { SqliteContractSerializer } from \"@internal/target-sqlite/runtime\";\nimport { assertDefined } from \"@internal/utils/assertions\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { validateContractOnce } from \"@internal/contract/validate-once\";\nimport { buildNamespacedEnums } from \"@internal/contract/enum-accessor\";\n//#region package.json\nvar version = \"8.0.0-rc.20-dev.8\";\n//#endregion\n//#region src/static/contract-from-json.ts\nconst serializer = new SqliteContractSerializer();\nconst validator = `${sqliteTarget.targetId}@${version}`;\n/**\n* Validates an emitted SQLite `contract.json` and returns it as the contract type the application\n* names, ready to pass to `sqlite({ contract })` and `sqliteStatic({ contract })`. Clients built\n* from the result do not validate it again.\n*\n* The returned value's top level is frozen; its nested objects are not. Do not change `json` or the\n* returned value after the call: clients built from the value later do not validate it again.\n*\n* @example\n* ```ts\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* ```\n*/\nfunction contractFromJson(json) {\n\treturn validateContractOnce(json, validator, (input) => serializer.deserializeContract(input));\n}\nfunction validateSqliteContract(contract) {\n\treturn validateContractOnce(contract, validator, () => serializer.deserializeContract(serializer.serializeContract(contract)));\n}\n//#endregion\n//#region src/static/sqlite-static.ts\nfunction buildSqliteStaticContext(contract, context, stack) {\n\tconst { rawCodecInferer } = stack.adapter;\n\tconst sqlNamespace = sql({\n\t\tcontext,\n\t\trawCodecInferer\n\t})[UNBOUND_NAMESPACE_ID];\n\tassertDefined(sqlNamespace, \"the unbound namespace always exists on a sqlite builder output\");\n\tconst sqlDb = blindCast(sqlNamespace);\n\tconst raw = createRawLane({\n\t\tcontext,\n\t\trawCodecInferer\n\t});\n\tconst enums = Object.freeze(buildNamespacedEnums(context.contract.domain, (codecId) => context.contractCodecs.forCodecRef({ codecId })))[UNBOUND_NAMESPACE_ID];\n\tassertDefined(enums, \"the unbound namespace always exists on a sqlite builder output\");\n\treturn {\n\t\tcontext,\n\t\tcontract,\n\t\tenums,\n\t\tsql: sqlDb,\n\t\traw,\n\t\ttoSql: createToSql(stack, contract)\n\t};\n}\n/**\n* The query surfaces of a SQLite client without a driver: `sql`, `raw`, `enums` and `toSql`. Use\n* it where loading `node:sqlite` is not wanted.\n*\n* @example\n* ```ts\n* const { enums } = sqliteStatic({ contract: contractFromJson<Contract>(contractJson) });\n* ```\n*/\nfunction sqliteStatic(options) {\n\tconst contract = validateSqliteContract(options.contract);\n\tconst stack = createSqlExecutionStack({\n\t\ttarget: sqliteTarget,\n\t\tadapter: sqliteAdapter,\n\t\textensions: options.extensions ?? []\n\t});\n\treturn buildSqliteStaticContext(contract, createExecutionContext({\n\t\tcontract,\n\t\tstack\n\t}), stack);\n}\n//#endregion\nexport { validateSqliteContract as i, sqliteStatic as n, contractFromJson as r, buildSqliteStaticContext as t };\n\n//# sourceMappingURL=sqlite-static-DORjKoZ5.mjs.map"],"mappings":";;;;;;;;;;AAUA,IAAI,UAAU;AAGd,MAAM,aAAa,IAAI,yBAAyB;AAChD,MAAM,YAAY,GAAG,aAAa,SAAS,GAAG;;;;;;;;;;;;;;;;;AAiB9C,SAAS,iBAAiB,MAAM;CAC/B,OAAO,qBAAqB,MAAM,YAAY,UAAU,WAAW,oBAAoB,KAAK,CAAC;AAC9F;AACA,SAAS,uBAAuB,UAAU;CACzC,OAAO,qBAAqB,UAAU,iBAAiB,WAAW,oBAAoB,WAAW,kBAAkB,QAAQ,CAAC,CAAC;AAC9H;AAGA,SAAS,yBAAyB,UAAU,SAAS,OAAO;CAC3D,MAAM,EAAE,oBAAoB,MAAM;CAClC,MAAM,eAAe,IAAI;EACxB;EACA;CACD,CAAC,CAAC,CAAC;CACH,cAAc,cAAc,gEAAgE;CAC5F,MAAM,QAAQ,UAAU,YAAY;CACpC,MAAM,MAAM,cAAc;EACzB;EACA;CACD,CAAC;CACD,MAAM,QAAQ,OAAO,OAAO,qBAAqB,QAAQ,SAAS,SAAS,YAAY,QAAQ,eAAe,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;CACzI,cAAc,OAAO,gEAAgE;CACrF,OAAO;EACN;EACA;EACA;EACA,KAAK;EACL;EACA,OAAO,YAAY,OAAO,QAAQ;CACnC;AACD;;;;;;;;;;AAUA,SAAS,aAAa,SAAS;CAC9B,MAAM,WAAW,uBAAuB,QAAQ,QAAQ;CACxD,MAAM,QAAQ,wBAAwB;EACrC,QAAQ;EACR,SAAS;EACT,YAAY,QAAQ,cAAc,CAAC;CACpC,CAAC;CACD,OAAO,yBAAyB,UAAU,uBAAuB;EAChE;EACA;CACD,CAAC,GAAG,KAAK;AACV"}