@prisma-next/sql-contract 0.14.0-dev.83 → 0.14.0-dev.85

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"canonicalization-hooks.d.mts","names":[],"sources":["../src/canonicalization-hooks.ts"],"mappings":";;;cA6Ba,gCAAA;EAAA,SACF,mBAAA,EAAqB,sBAAA;EAAA,SACrB,WAAA,EAAa,WAAW;AAAA"}
1
+ {"version":3,"file":"canonicalization-hooks.d.mts","names":[],"sources":["../src/canonicalization-hooks.ts"],"mappings":";;;cAqDa,gCAAA;EAAA,SACF,mBAAA,EAAqB,sBAAA;EAAA,SACrB,WAAA,EAAa,WAAW;AAAA"}
@@ -1,67 +1,85 @@
1
- import { createPreserveEmptyPredicate, createStorageSort } from "@prisma-next/contract/hashing-utils";
2
- const sqlContractCanonicalizationHooks = {
3
- shouldPreserveEmpty: createPreserveEmptyPredicate([
4
- [
5
- "storage",
6
- "namespaces",
7
- "*",
8
- "entries",
9
- "table"
10
- ],
11
- [
12
- "storage",
13
- "namespaces",
14
- "*",
15
- "entries",
16
- "table",
17
- "*"
18
- ],
1
+ import { createPreserveEmptyPredicate, createStorageSort, matchesPathPattern } from "@prisma-next/contract/hashing-utils";
2
+ //#region src/canonicalization-hooks.ts
3
+ const preserveEmptyPatterns = [
4
+ [
5
+ "storage",
6
+ "namespaces",
7
+ "*",
8
+ "entries",
9
+ "table"
10
+ ],
11
+ [
12
+ "storage",
13
+ "namespaces",
14
+ "*",
15
+ "entries",
16
+ "table",
17
+ "*"
18
+ ],
19
+ [
20
+ "storage",
21
+ "namespaces",
22
+ "*",
23
+ "entries",
24
+ "table",
25
+ "*",
19
26
  [
20
- "storage",
21
- "namespaces",
22
- "*",
23
- "entries",
24
- "table",
25
- "*",
26
- [
27
- "uniques",
28
- "indexes",
29
- "foreignKeys"
30
- ]
31
- ],
32
- [
33
- "storage",
34
- "namespaces",
35
- "*",
36
- "entries",
37
- "table",
38
- "*",
39
- "foreignKeys",
40
- ["constraint", "index"]
41
- ],
42
- [
43
- "storage",
44
- "namespaces",
45
- "*",
46
- "entries",
47
- "table",
48
- "*",
49
- "columns",
50
- "*",
51
- "default",
52
- "value"
27
+ "uniques",
28
+ "indexes",
29
+ "foreignKeys"
53
30
  ]
54
- ]),
55
- sortStorage: createStorageSort([{
56
- path: [
57
- "namespaces",
58
- "*",
59
- "entries",
60
- "table",
61
- "*"
62
- ],
63
- arrayKeys: ["indexes", "uniques"]
64
- }])
31
+ ],
32
+ [
33
+ "storage",
34
+ "namespaces",
35
+ "*",
36
+ "entries",
37
+ "table",
38
+ "*",
39
+ "foreignKeys",
40
+ ["constraint", "index"]
41
+ ],
42
+ [
43
+ "storage",
44
+ "namespaces",
45
+ "*",
46
+ "entries",
47
+ "table",
48
+ "*",
49
+ "columns",
50
+ "*",
51
+ "default",
52
+ "value"
53
+ ]
54
+ ];
55
+ const columnDefaultValuePrefix = [
56
+ "storage",
57
+ "namespaces",
58
+ "*",
59
+ "entries",
60
+ "table",
61
+ "*",
62
+ "columns",
63
+ "*",
64
+ "default",
65
+ "value"
66
+ ];
67
+ const isColumnDefaultValuePath = (path) => path.length >= columnDefaultValuePrefix.length && matchesPathPattern(path.slice(0, columnDefaultValuePrefix.length), columnDefaultValuePrefix);
68
+ const sortTargets = [{
69
+ path: [
70
+ "namespaces",
71
+ "*",
72
+ "entries",
73
+ "table",
74
+ "*"
75
+ ],
76
+ arrayKeys: ["indexes", "uniques"]
77
+ }];
78
+ const matchesPreserveEmptyPattern = createPreserveEmptyPredicate(preserveEmptyPatterns);
79
+ const shouldPreserveEmpty = (path) => isColumnDefaultValuePath(path) || matchesPreserveEmptyPattern(path);
80
+ const sqlContractCanonicalizationHooks = {
81
+ shouldPreserveEmpty,
82
+ sortStorage: createStorageSort(sortTargets)
65
83
  };
66
84
  //#endregion
67
85
  export { sqlContractCanonicalizationHooks };
@@ -1 +1 @@
1
- {"version":3,"file":"canonicalization-hooks.mjs","names":[],"sources":["../src/canonicalization-hooks.ts"],"sourcesContent":["import type { PreserveEmptyPredicate, StorageSort } from '@prisma-next/contract/hashing';\nimport {\n createPreserveEmptyPredicate,\n createStorageSort,\n type NamedArraySortTarget,\n type PathPattern,\n} from '@prisma-next/contract/hashing-utils';\n\nconst preserveEmptyPatterns = [\n ['storage', 'namespaces', '*', 'entries', 'table'],\n ['storage', 'namespaces', '*', 'entries', 'table', '*'],\n ['storage', 'namespaces', '*', 'entries', 'table', '*', ['uniques', 'indexes', 'foreignKeys']],\n ['storage', 'namespaces', '*', 'entries', 'table', '*', 'foreignKeys', ['constraint', 'index']],\n // A column default's literal payload is data, not shape — `{ kind:\n // 'literal', value: false }` (or `value: []`) must survive the\n // default-omission walk or the emitted contract fails its own\n // validation on the next read (PN-CLI-4003 on `Boolean @default(false)`).\n ['storage', 'namespaces', '*', 'entries', 'table', '*', 'columns', '*', 'default', 'value'],\n] as const satisfies readonly PathPattern[];\n\nconst sortTargets = [\n { path: ['namespaces', '*', 'entries', 'table', '*'], arrayKeys: ['indexes', 'uniques'] },\n] as const satisfies readonly NamedArraySortTarget[];\n\nconst shouldPreserveEmpty: PreserveEmptyPredicate =\n createPreserveEmptyPredicate(preserveEmptyPatterns);\n\nconst sortStorage: StorageSort = createStorageSort(sortTargets);\n\nexport const sqlContractCanonicalizationHooks: {\n readonly shouldPreserveEmpty: PreserveEmptyPredicate;\n readonly sortStorage: StorageSort;\n} = {\n shouldPreserveEmpty,\n sortStorage,\n};\n"],"mappings":";AA6BA,MAAa,mCAGT;CACF,qBARA,6BAA6B;EAhB7B;GAAC;GAAW;GAAc;GAAK;GAAW;EAAO;EACjD;GAAC;GAAW;GAAc;GAAK;GAAW;GAAS;EAAG;EACtD;GAAC;GAAW;GAAc;GAAK;GAAW;GAAS;GAAK;IAAC;IAAW;IAAW;GAAa;EAAC;EAC7F;GAAC;GAAW;GAAc;GAAK;GAAW;GAAS;GAAK;GAAe,CAAC,cAAc,OAAO;EAAC;EAK9F;GAAC;GAAW;GAAc;GAAK;GAAW;GAAS;GAAK;GAAW;GAAK;GAAW;EAAO;CAQ7D,CAQ7B;CACA,aAP+B,kBAAkB,CANjD;EAAE,MAAM;GAAC;GAAc;GAAK;GAAW;GAAS;EAAG;EAAG,WAAW,CAAC,WAAW,SAAS;CAAE,CAMvC,CAOjD;AACF"}
1
+ {"version":3,"file":"canonicalization-hooks.mjs","names":[],"sources":["../src/canonicalization-hooks.ts"],"sourcesContent":["import type { PreserveEmptyPredicate, StorageSort } from '@prisma-next/contract/hashing';\nimport {\n createPreserveEmptyPredicate,\n createStorageSort,\n matchesPathPattern,\n type NamedArraySortTarget,\n type PathPattern,\n} from '@prisma-next/contract/hashing-utils';\n\nconst preserveEmptyPatterns = [\n ['storage', 'namespaces', '*', 'entries', 'table'],\n ['storage', 'namespaces', '*', 'entries', 'table', '*'],\n ['storage', 'namespaces', '*', 'entries', 'table', '*', ['uniques', 'indexes', 'foreignKeys']],\n ['storage', 'namespaces', '*', 'entries', 'table', '*', 'foreignKeys', ['constraint', 'index']],\n // A column default's literal payload is data, not shape — `{ kind:\n // 'literal', value: false }` (or `value: []`) must survive the\n // default-omission walk or the emitted contract fails its own\n // validation on the next read (PN-CLI-4003 on `Boolean @default(false)`).\n ['storage', 'namespaces', '*', 'entries', 'table', '*', 'columns', '*', 'default', 'value'],\n] as const satisfies readonly PathPattern[];\n\n// A literal column default's value is user data, not omittable structure:\n// `@default(false)` (and empty objects/arrays at any depth inside the value)\n// must survive canonicalization, or the emitted contract fails the runtime's\n// structural validation with `default.value … (was missing)`.\nconst columnDefaultValuePrefix = [\n 'storage',\n 'namespaces',\n '*',\n 'entries',\n 'table',\n '*',\n 'columns',\n '*',\n 'default',\n 'value',\n] as const satisfies PathPattern;\n\nconst isColumnDefaultValuePath = (path: readonly string[]): boolean =>\n path.length >= columnDefaultValuePrefix.length &&\n matchesPathPattern(path.slice(0, columnDefaultValuePrefix.length), columnDefaultValuePrefix);\n\nconst sortTargets = [\n { path: ['namespaces', '*', 'entries', 'table', '*'], arrayKeys: ['indexes', 'uniques'] },\n] as const satisfies readonly NamedArraySortTarget[];\n\nconst matchesPreserveEmptyPattern = createPreserveEmptyPredicate(preserveEmptyPatterns);\n\nconst shouldPreserveEmpty: PreserveEmptyPredicate = (path) =>\n isColumnDefaultValuePath(path) || matchesPreserveEmptyPattern(path);\n\nconst sortStorage: StorageSort = createStorageSort(sortTargets);\n\nexport const sqlContractCanonicalizationHooks: {\n readonly shouldPreserveEmpty: PreserveEmptyPredicate;\n readonly sortStorage: StorageSort;\n} = {\n shouldPreserveEmpty,\n sortStorage,\n};\n"],"mappings":";;AASA,MAAM,wBAAwB;CAC5B;EAAC;EAAW;EAAc;EAAK;EAAW;CAAO;CACjD;EAAC;EAAW;EAAc;EAAK;EAAW;EAAS;CAAG;CACtD;EAAC;EAAW;EAAc;EAAK;EAAW;EAAS;EAAK;GAAC;GAAW;GAAW;EAAa;CAAC;CAC7F;EAAC;EAAW;EAAc;EAAK;EAAW;EAAS;EAAK;EAAe,CAAC,cAAc,OAAO;CAAC;CAK9F;EAAC;EAAW;EAAc;EAAK;EAAW;EAAS;EAAK;EAAW;EAAK;EAAW;CAAO;AAC5F;AAMA,MAAM,2BAA2B;CAC/B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAM,4BAA4B,SAChC,KAAK,UAAU,yBAAyB,UACxC,mBAAmB,KAAK,MAAM,GAAG,yBAAyB,MAAM,GAAG,wBAAwB;AAE7F,MAAM,cAAc,CAClB;CAAE,MAAM;EAAC;EAAc;EAAK;EAAW;EAAS;CAAG;CAAG,WAAW,CAAC,WAAW,SAAS;AAAE,CAC1F;AAEA,MAAM,8BAA8B,6BAA6B,qBAAqB;AAEtF,MAAM,uBAA+C,SACnD,yBAAyB,IAAI,KAAK,4BAA4B,IAAI;AAIpE,MAAa,mCAGT;CACF;CACA,aAP+B,kBAAkB,WAOjD;AACF"}
package/package.json CHANGED
@@ -1,20 +1,20 @@
1
1
  {
2
2
  "name": "@prisma-next/sql-contract",
3
- "version": "0.14.0-dev.83",
3
+ "version": "0.14.0-dev.85",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "description": "SQL contract types, validators, and IR factories for Prisma Next",
8
8
  "dependencies": {
9
- "@prisma-next/contract": "0.14.0-dev.83",
10
- "@prisma-next/framework-components": "0.14.0-dev.83",
11
- "@prisma-next/utils": "0.14.0-dev.83",
9
+ "@prisma-next/contract": "0.14.0-dev.85",
10
+ "@prisma-next/framework-components": "0.14.0-dev.85",
11
+ "@prisma-next/utils": "0.14.0-dev.85",
12
12
  "arktype": "^2.2.2"
13
13
  },
14
14
  "devDependencies": {
15
- "@prisma-next/test-utils": "0.14.0-dev.83",
16
- "@prisma-next/tsconfig": "0.14.0-dev.83",
17
- "@prisma-next/tsdown": "0.14.0-dev.83",
15
+ "@prisma-next/test-utils": "0.14.0-dev.85",
16
+ "@prisma-next/tsconfig": "0.14.0-dev.85",
17
+ "@prisma-next/tsdown": "0.14.0-dev.85",
18
18
  "tsdown": "0.22.3",
19
19
  "typescript": "5.9.3",
20
20
  "vitest": "4.1.10"
@@ -2,6 +2,7 @@ import type { PreserveEmptyPredicate, StorageSort } from '@prisma-next/contract/
2
2
  import {
3
3
  createPreserveEmptyPredicate,
4
4
  createStorageSort,
5
+ matchesPathPattern,
5
6
  type NamedArraySortTarget,
6
7
  type PathPattern,
7
8
  } from '@prisma-next/contract/hashing-utils';
@@ -18,12 +19,35 @@ const preserveEmptyPatterns = [
18
19
  ['storage', 'namespaces', '*', 'entries', 'table', '*', 'columns', '*', 'default', 'value'],
19
20
  ] as const satisfies readonly PathPattern[];
20
21
 
22
+ // A literal column default's value is user data, not omittable structure:
23
+ // `@default(false)` (and empty objects/arrays at any depth inside the value)
24
+ // must survive canonicalization, or the emitted contract fails the runtime's
25
+ // structural validation with `default.value … (was missing)`.
26
+ const columnDefaultValuePrefix = [
27
+ 'storage',
28
+ 'namespaces',
29
+ '*',
30
+ 'entries',
31
+ 'table',
32
+ '*',
33
+ 'columns',
34
+ '*',
35
+ 'default',
36
+ 'value',
37
+ ] as const satisfies PathPattern;
38
+
39
+ const isColumnDefaultValuePath = (path: readonly string[]): boolean =>
40
+ path.length >= columnDefaultValuePrefix.length &&
41
+ matchesPathPattern(path.slice(0, columnDefaultValuePrefix.length), columnDefaultValuePrefix);
42
+
21
43
  const sortTargets = [
22
44
  { path: ['namespaces', '*', 'entries', 'table', '*'], arrayKeys: ['indexes', 'uniques'] },
23
45
  ] as const satisfies readonly NamedArraySortTarget[];
24
46
 
25
- const shouldPreserveEmpty: PreserveEmptyPredicate =
26
- createPreserveEmptyPredicate(preserveEmptyPatterns);
47
+ const matchesPreserveEmptyPattern = createPreserveEmptyPredicate(preserveEmptyPatterns);
48
+
49
+ const shouldPreserveEmpty: PreserveEmptyPredicate = (path) =>
50
+ isColumnDefaultValuePath(path) || matchesPreserveEmptyPattern(path);
27
51
 
28
52
  const sortStorage: StorageSort = createStorageSort(sortTargets);
29
53