@prisma-next/target-sqlite 0.5.0-dev.65 → 0.5.0-dev.67

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 (102) hide show
  1. package/dist/{codec-ids-DyLO2Rfx.d.mts → codec-ids-CYwMu3-4.d.mts} +1 -1
  2. package/dist/codec-ids-CYwMu3-4.d.mts.map +1 -0
  3. package/dist/{codec-ids-B1-OiN8Q.mjs → codec-ids-CuUxYcd0.mjs} +2 -3
  4. package/dist/{codec-ids-B1-OiN8Q.mjs.map → codec-ids-CuUxYcd0.mjs.map} +1 -1
  5. package/dist/codec-ids.d.mts +1 -1
  6. package/dist/codec-ids.mjs +2 -3
  7. package/dist/{codec-types-Bbzv7qCW.d.mts → codec-types-DNauB5UT.d.mts} +7 -8
  8. package/dist/codec-types-DNauB5UT.d.mts.map +1 -0
  9. package/dist/codec-types.d.mts +2 -3
  10. package/dist/codec-types.mjs +2 -3
  11. package/dist/{codecs-BqDitp2X.d.mts → codecs-BAlEiSeP.d.mts} +18 -19
  12. package/dist/codecs-BAlEiSeP.d.mts.map +1 -0
  13. package/dist/{codecs-CDcidsHL.mjs → codecs-DVnHtVWW.mjs} +3 -4
  14. package/dist/codecs-DVnHtVWW.mjs.map +1 -0
  15. package/dist/codecs.d.mts +1 -2
  16. package/dist/codecs.mjs +2 -3
  17. package/dist/codecs.mjs.map +1 -1
  18. package/dist/control.d.mts +1 -1
  19. package/dist/control.d.mts.map +1 -1
  20. package/dist/control.mjs +9 -11
  21. package/dist/control.mjs.map +1 -1
  22. package/dist/{default-normalizer-R-sQXAYt.mjs → default-normalizer-3Fccw7yw.mjs} +2 -2
  23. package/dist/{default-normalizer-R-sQXAYt.mjs.map → default-normalizer-3Fccw7yw.mjs.map} +1 -1
  24. package/dist/default-normalizer.d.mts +0 -1
  25. package/dist/default-normalizer.d.mts.map +1 -1
  26. package/dist/default-normalizer.mjs +2 -3
  27. package/dist/descriptor-meta-CE2Kbn9b.mjs +17 -0
  28. package/dist/descriptor-meta-CE2Kbn9b.mjs.map +1 -0
  29. package/dist/migration.d.mts +2 -3
  30. package/dist/migration.d.mts.map +1 -1
  31. package/dist/migration.mjs +4 -5
  32. package/dist/migration.mjs.map +1 -1
  33. package/dist/{native-type-normalizer-BMovohPm.mjs → native-type-normalizer-BlN5XfD-.mjs} +2 -2
  34. package/dist/{native-type-normalizer-BMovohPm.mjs.map → native-type-normalizer-BlN5XfD-.mjs.map} +1 -1
  35. package/dist/native-type-normalizer.d.mts.map +1 -1
  36. package/dist/native-type-normalizer.mjs +2 -3
  37. package/dist/{op-factory-call-BUVV-W9F.mjs → op-factory-call-DvewDQ7a.mjs} +3 -4
  38. package/dist/{op-factory-call-BUVV-W9F.mjs.map → op-factory-call-DvewDQ7a.mjs.map} +1 -1
  39. package/dist/{op-factory-call-dUIOao68.d.mts → op-factory-call-DzKIrTLj.d.mts} +3 -4
  40. package/dist/op-factory-call-DzKIrTLj.d.mts.map +1 -0
  41. package/dist/op-factory-call.d.mts +1 -2
  42. package/dist/op-factory-call.mjs +2 -3
  43. package/dist/pack.d.mts +1 -3
  44. package/dist/pack.d.mts.map +1 -1
  45. package/dist/pack.mjs +2 -3
  46. package/dist/{planner-DmOFOhoq.mjs → planner-CIjeXa04.mjs} +8 -11
  47. package/dist/planner-CIjeXa04.mjs.map +1 -0
  48. package/dist/{planner-produced-sqlite-migration-BANB82Pw.mjs → planner-produced-sqlite-migration-CH7YGZf6.mjs} +4 -6
  49. package/dist/planner-produced-sqlite-migration-CH7YGZf6.mjs.map +1 -0
  50. package/dist/{planner-produced-sqlite-migration-CJr8ATRH.d.mts → planner-produced-sqlite-migration-IZZt7TRg.d.mts} +4 -4
  51. package/dist/planner-produced-sqlite-migration-IZZt7TRg.d.mts.map +1 -0
  52. package/dist/planner-produced-sqlite-migration.d.mts +1 -4
  53. package/dist/planner-produced-sqlite-migration.mjs +2 -3
  54. package/dist/{planner-target-details-BQIWQlBu.mjs → planner-target-details-Bm71XPKb.mjs} +2 -3
  55. package/dist/{planner-target-details-BQIWQlBu.mjs.map → planner-target-details-Bm71XPKb.mjs.map} +1 -1
  56. package/dist/{planner-target-details-CtWRvse0.d.mts → planner-target-details-vhvZDWK1.d.mts} +1 -1
  57. package/dist/planner-target-details-vhvZDWK1.d.mts.map +1 -0
  58. package/dist/planner-target-details.d.mts +1 -1
  59. package/dist/planner-target-details.mjs +2 -3
  60. package/dist/planner.d.mts +2 -5
  61. package/dist/planner.d.mts.map +1 -1
  62. package/dist/planner.mjs +2 -3
  63. package/dist/{render-ops-CXOv7SRC.mjs → render-ops-CSRDT4YL.mjs} +2 -2
  64. package/dist/{render-ops-CXOv7SRC.mjs.map → render-ops-CSRDT4YL.mjs.map} +1 -1
  65. package/dist/render-ops.d.mts +2 -3
  66. package/dist/render-ops.d.mts.map +1 -1
  67. package/dist/render-ops.mjs +2 -3
  68. package/dist/runtime.d.mts.map +1 -1
  69. package/dist/runtime.mjs +3 -5
  70. package/dist/runtime.mjs.map +1 -1
  71. package/dist/{shared-D_1fFqLf.d.mts → shared-qLsgTOZs.d.mts} +2 -2
  72. package/dist/shared-qLsgTOZs.d.mts.map +1 -0
  73. package/dist/{sql-utils-D3SMPFDD.mjs → sql-utils-DhevMgef.mjs} +4 -2
  74. package/dist/sql-utils-DhevMgef.mjs.map +1 -0
  75. package/dist/sql-utils.d.mts.map +1 -1
  76. package/dist/sql-utils.mjs +2 -3
  77. package/dist/{sqlite-migration-CnLhIrJF.mjs → sqlite-migration-BBJktVVw.mjs} +2 -3
  78. package/dist/{sqlite-migration-CnLhIrJF.mjs.map → sqlite-migration-BBJktVVw.mjs.map} +1 -1
  79. package/dist/{sqlite-migration-BeR1cikr.d.mts → sqlite-migration-DAb2NEX6.d.mts} +2 -3
  80. package/dist/sqlite-migration-DAb2NEX6.d.mts.map +1 -0
  81. package/dist/{statement-builders-DobaAWnW.mjs → statement-builders-DMT4ltXR.mjs} +2 -3
  82. package/dist/{statement-builders-DobaAWnW.mjs.map → statement-builders-DMT4ltXR.mjs.map} +1 -1
  83. package/dist/statement-builders.d.mts.map +1 -1
  84. package/dist/statement-builders.mjs +2 -3
  85. package/dist/{tables-sKIg_lWE.mjs → tables-D84zfPZI.mjs} +5 -10
  86. package/dist/tables-D84zfPZI.mjs.map +1 -0
  87. package/package.json +19 -19
  88. package/dist/codec-ids-DyLO2Rfx.d.mts.map +0 -1
  89. package/dist/codec-types-Bbzv7qCW.d.mts.map +0 -1
  90. package/dist/codecs-BqDitp2X.d.mts.map +0 -1
  91. package/dist/codecs-CDcidsHL.mjs.map +0 -1
  92. package/dist/descriptor-meta-BA2YAFQq.mjs +0 -24
  93. package/dist/descriptor-meta-BA2YAFQq.mjs.map +0 -1
  94. package/dist/op-factory-call-dUIOao68.d.mts.map +0 -1
  95. package/dist/planner-DmOFOhoq.mjs.map +0 -1
  96. package/dist/planner-produced-sqlite-migration-BANB82Pw.mjs.map +0 -1
  97. package/dist/planner-produced-sqlite-migration-CJr8ATRH.d.mts.map +0 -1
  98. package/dist/planner-target-details-CtWRvse0.d.mts.map +0 -1
  99. package/dist/shared-D_1fFqLf.d.mts.map +0 -1
  100. package/dist/sql-utils-D3SMPFDD.mjs.map +0 -1
  101. package/dist/sqlite-migration-BeR1cikr.d.mts.map +0 -1
  102. package/dist/tables-sKIg_lWE.mjs.map +0 -1
@@ -10,4 +10,4 @@ declare const SQLITE_JSON_CODEC_ID: "sqlite/json@1";
10
10
  declare const SQLITE_BIGINT_CODEC_ID: "sqlite/bigint@1";
11
11
  //#endregion
12
12
  export { SQLITE_JSON_CODEC_ID as a, SQL_CHAR_CODEC_ID as c, SQL_VARCHAR_CODEC_ID as d, SQLITE_INTEGER_CODEC_ID as i, SQL_FLOAT_CODEC_ID as l, SQLITE_BLOB_CODEC_ID as n, SQLITE_REAL_CODEC_ID as o, SQLITE_DATETIME_CODEC_ID as r, SQLITE_TEXT_CODEC_ID as s, SQLITE_BIGINT_CODEC_ID as t, SQL_INT_CODEC_ID as u };
13
- //# sourceMappingURL=codec-ids-DyLO2Rfx.d.mts.map
13
+ //# sourceMappingURL=codec-ids-CYwMu3-4.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codec-ids-CYwMu3-4.d.mts","names":[],"sources":["../src/core/codec-ids.ts"],"mappings":";;;cAMa,oBAAA;AAAA,cACA,uBAAA;AAAA,cACA,oBAAA;AAAA,cACA,oBAAA;AAAA,cACA,wBAAA;AAAA,cACA,oBAAA;AAAA,cACA,sBAAA"}
@@ -1,5 +1,4 @@
1
1
  import { SQL_CHAR_CODEC_ID, SQL_FLOAT_CODEC_ID, SQL_INT_CODEC_ID, SQL_VARCHAR_CODEC_ID } from "@prisma-next/sql-relational-core/ast";
2
-
3
2
  //#region src/core/codec-ids.ts
4
3
  const SQLITE_TEXT_CODEC_ID = "sqlite/text@1";
5
4
  const SQLITE_INTEGER_CODEC_ID = "sqlite/integer@1";
@@ -8,7 +7,7 @@ const SQLITE_BLOB_CODEC_ID = "sqlite/blob@1";
8
7
  const SQLITE_DATETIME_CODEC_ID = "sqlite/datetime@1";
9
8
  const SQLITE_JSON_CODEC_ID = "sqlite/json@1";
10
9
  const SQLITE_BIGINT_CODEC_ID = "sqlite/bigint@1";
11
-
12
10
  //#endregion
13
11
  export { SQLITE_JSON_CODEC_ID as a, SQL_CHAR_CODEC_ID as c, SQL_VARCHAR_CODEC_ID as d, SQLITE_INTEGER_CODEC_ID as i, SQL_FLOAT_CODEC_ID as l, SQLITE_BLOB_CODEC_ID as n, SQLITE_REAL_CODEC_ID as o, SQLITE_DATETIME_CODEC_ID as r, SQLITE_TEXT_CODEC_ID as s, SQLITE_BIGINT_CODEC_ID as t, SQL_INT_CODEC_ID as u };
14
- //# sourceMappingURL=codec-ids-B1-OiN8Q.mjs.map
12
+
13
+ //# sourceMappingURL=codec-ids-CuUxYcd0.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"codec-ids-B1-OiN8Q.mjs","names":[],"sources":["../src/core/codec-ids.ts"],"sourcesContent":["export {\n SQL_CHAR_CODEC_ID,\n SQL_FLOAT_CODEC_ID,\n SQL_INT_CODEC_ID,\n SQL_VARCHAR_CODEC_ID,\n} from '@prisma-next/sql-relational-core/ast';\nexport const SQLITE_TEXT_CODEC_ID = 'sqlite/text@1' as const;\nexport const SQLITE_INTEGER_CODEC_ID = 'sqlite/integer@1' as const;\nexport const SQLITE_REAL_CODEC_ID = 'sqlite/real@1' as const;\nexport const SQLITE_BLOB_CODEC_ID = 'sqlite/blob@1' as const;\nexport const SQLITE_DATETIME_CODEC_ID = 'sqlite/datetime@1' as const;\nexport const SQLITE_JSON_CODEC_ID = 'sqlite/json@1' as const;\nexport const SQLITE_BIGINT_CODEC_ID = 'sqlite/bigint@1' as const;\n"],"mappings":";;;AAMA,MAAa,uBAAuB;AACpC,MAAa,0BAA0B;AACvC,MAAa,uBAAuB;AACpC,MAAa,uBAAuB;AACpC,MAAa,2BAA2B;AACxC,MAAa,uBAAuB;AACpC,MAAa,yBAAyB"}
1
+ {"version":3,"file":"codec-ids-CuUxYcd0.mjs","names":[],"sources":["../src/core/codec-ids.ts"],"sourcesContent":["export {\n SQL_CHAR_CODEC_ID,\n SQL_FLOAT_CODEC_ID,\n SQL_INT_CODEC_ID,\n SQL_VARCHAR_CODEC_ID,\n} from '@prisma-next/sql-relational-core/ast';\nexport const SQLITE_TEXT_CODEC_ID = 'sqlite/text@1' as const;\nexport const SQLITE_INTEGER_CODEC_ID = 'sqlite/integer@1' as const;\nexport const SQLITE_REAL_CODEC_ID = 'sqlite/real@1' as const;\nexport const SQLITE_BLOB_CODEC_ID = 'sqlite/blob@1' as const;\nexport const SQLITE_DATETIME_CODEC_ID = 'sqlite/datetime@1' as const;\nexport const SQLITE_JSON_CODEC_ID = 'sqlite/json@1' as const;\nexport const SQLITE_BIGINT_CODEC_ID = 'sqlite/bigint@1' as const;\n"],"mappings":";;AAMA,MAAa,uBAAuB;AACpC,MAAa,0BAA0B;AACvC,MAAa,uBAAuB;AACpC,MAAa,uBAAuB;AACpC,MAAa,2BAA2B;AACxC,MAAa,uBAAuB;AACpC,MAAa,yBAAyB"}
@@ -1,2 +1,2 @@
1
- import { a as SQLITE_JSON_CODEC_ID, c as SQL_CHAR_CODEC_ID, d as SQL_VARCHAR_CODEC_ID, i as SQLITE_INTEGER_CODEC_ID, l as SQL_FLOAT_CODEC_ID, n as SQLITE_BLOB_CODEC_ID, o as SQLITE_REAL_CODEC_ID, r as SQLITE_DATETIME_CODEC_ID, s as SQLITE_TEXT_CODEC_ID, t as SQLITE_BIGINT_CODEC_ID, u as SQL_INT_CODEC_ID } from "./codec-ids-DyLO2Rfx.mjs";
1
+ import { a as SQLITE_JSON_CODEC_ID, c as SQL_CHAR_CODEC_ID, d as SQL_VARCHAR_CODEC_ID, i as SQLITE_INTEGER_CODEC_ID, l as SQL_FLOAT_CODEC_ID, n as SQLITE_BLOB_CODEC_ID, o as SQLITE_REAL_CODEC_ID, r as SQLITE_DATETIME_CODEC_ID, s as SQLITE_TEXT_CODEC_ID, t as SQLITE_BIGINT_CODEC_ID, u as SQL_INT_CODEC_ID } from "./codec-ids-CYwMu3-4.mjs";
2
2
  export { SQLITE_BIGINT_CODEC_ID, SQLITE_BLOB_CODEC_ID, SQLITE_DATETIME_CODEC_ID, SQLITE_INTEGER_CODEC_ID, SQLITE_JSON_CODEC_ID, SQLITE_REAL_CODEC_ID, SQLITE_TEXT_CODEC_ID, SQL_CHAR_CODEC_ID, SQL_FLOAT_CODEC_ID, SQL_INT_CODEC_ID, SQL_VARCHAR_CODEC_ID };
@@ -1,3 +1,2 @@
1
- import { a as SQLITE_JSON_CODEC_ID, c as SQL_CHAR_CODEC_ID, d as SQL_VARCHAR_CODEC_ID, i as SQLITE_INTEGER_CODEC_ID, l as SQL_FLOAT_CODEC_ID, n as SQLITE_BLOB_CODEC_ID, o as SQLITE_REAL_CODEC_ID, r as SQLITE_DATETIME_CODEC_ID, s as SQLITE_TEXT_CODEC_ID, t as SQLITE_BIGINT_CODEC_ID, u as SQL_INT_CODEC_ID } from "./codec-ids-B1-OiN8Q.mjs";
2
-
3
- export { SQLITE_BIGINT_CODEC_ID, SQLITE_BLOB_CODEC_ID, SQLITE_DATETIME_CODEC_ID, SQLITE_INTEGER_CODEC_ID, SQLITE_JSON_CODEC_ID, SQLITE_REAL_CODEC_ID, SQLITE_TEXT_CODEC_ID, SQL_CHAR_CODEC_ID, SQL_FLOAT_CODEC_ID, SQL_INT_CODEC_ID, SQL_VARCHAR_CODEC_ID };
1
+ import { a as SQLITE_JSON_CODEC_ID, c as SQL_CHAR_CODEC_ID, d as SQL_VARCHAR_CODEC_ID, i as SQLITE_INTEGER_CODEC_ID, l as SQL_FLOAT_CODEC_ID, n as SQLITE_BLOB_CODEC_ID, o as SQLITE_REAL_CODEC_ID, r as SQLITE_DATETIME_CODEC_ID, s as SQLITE_TEXT_CODEC_ID, t as SQLITE_BIGINT_CODEC_ID, u as SQL_INT_CODEC_ID } from "./codec-ids-CuUxYcd0.mjs";
2
+ export { SQLITE_BIGINT_CODEC_ID, SQLITE_BLOB_CODEC_ID, SQLITE_DATETIME_CODEC_ID, SQLITE_INTEGER_CODEC_ID, SQLITE_JSON_CODEC_ID, SQLITE_REAL_CODEC_ID, SQLITE_TEXT_CODEC_ID, SQL_CHAR_CODEC_ID, SQL_FLOAT_CODEC_ID, SQL_INT_CODEC_ID, SQL_VARCHAR_CODEC_ID };
@@ -1,14 +1,13 @@
1
- import { a as SqliteIntegerDescriptor, c as SqliteTextDescriptor, i as SqliteDatetimeDescriptor, n as SqliteBigintDescriptor, o as SqliteJsonDescriptor, r as SqliteBlobDescriptor, s as SqliteRealDescriptor } from "./codecs-BqDitp2X.mjs";
2
- import * as _prisma_next_sql_relational_core_ast0 from "@prisma-next/sql-relational-core/ast";
1
+ import { a as SqliteIntegerDescriptor, c as SqliteTextDescriptor, i as SqliteDatetimeDescriptor, n as SqliteBigintDescriptor, o as SqliteJsonDescriptor, r as SqliteBlobDescriptor, s as SqliteRealDescriptor } from "./codecs-BAlEiSeP.mjs";
2
+ import * as _$_prisma_next_sql_relational_core_ast0 from "@prisma-next/sql-relational-core/ast";
3
3
  import { ExtractCodecTypes } from "@prisma-next/sql-relational-core/ast";
4
4
 
5
5
  //#region src/exports/codec-types.d.ts
6
-
7
6
  declare const codecDescriptorMap: {
8
- readonly char: _prisma_next_sql_relational_core_ast0.SqlCharDescriptor;
9
- readonly varchar: _prisma_next_sql_relational_core_ast0.SqlVarcharDescriptor;
10
- readonly int: _prisma_next_sql_relational_core_ast0.SqlIntDescriptor;
11
- readonly float: _prisma_next_sql_relational_core_ast0.SqlFloatDescriptor;
7
+ readonly char: _$_prisma_next_sql_relational_core_ast0.SqlCharDescriptor;
8
+ readonly varchar: _$_prisma_next_sql_relational_core_ast0.SqlVarcharDescriptor;
9
+ readonly int: _$_prisma_next_sql_relational_core_ast0.SqlIntDescriptor;
10
+ readonly float: _$_prisma_next_sql_relational_core_ast0.SqlFloatDescriptor;
12
11
  readonly text: SqliteTextDescriptor;
13
12
  readonly integer: SqliteIntegerDescriptor;
14
13
  readonly real: SqliteRealDescriptor;
@@ -21,4 +20,4 @@ type Resolve<T> = { readonly [K in keyof T]: { readonly [P in keyof T[K]]: T[K][
21
20
  type CodecTypes = Resolve<ExtractCodecTypes<typeof codecDescriptorMap>>;
22
21
  //#endregion
23
22
  export { CodecTypes as t };
24
- //# sourceMappingURL=codec-types-Bbzv7qCW.d.mts.map
23
+ //# sourceMappingURL=codec-types-DNauB5UT.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codec-types-DNauB5UT.d.mts","names":[],"sources":["../src/exports/codec-types.ts"],"mappings":";;;;;cAwBM,kBAAA;EAAA,eAYI,uCAAA,CAAA,iBAAA;EAAA;;;;;;;;;;;KAEL,OAAA,6BAAoC,CAAA,0BAA2B,CAAA,CAAE,CAAA,IAAK,CAAA,CAAE,CAAA,EAAG,CAAA;AAAA,KAEpE,UAAA,GAAa,OAAA,CAAQ,iBAAA,QAAyB,kBAAA"}
@@ -1,4 +1,3 @@
1
- import "./codec-ids-DyLO2Rfx.mjs";
2
- import { g as JsonValue } from "./codecs-BqDitp2X.mjs";
3
- import { t as CodecTypes } from "./codec-types-Bbzv7qCW.mjs";
1
+ import { g as JsonValue } from "./codecs-BAlEiSeP.mjs";
2
+ import { t as CodecTypes } from "./codec-types-DNauB5UT.mjs";
4
3
  export { CodecTypes, JsonValue };
@@ -1,3 +1,2 @@
1
- import { sqlCharDescriptor, sqlFloatDescriptor, sqlIntDescriptor, sqlVarcharDescriptor } from "@prisma-next/sql-relational-core/ast";
2
-
3
- export { };
1
+ import "@prisma-next/sql-relational-core/ast";
2
+ export {};
@@ -1,7 +1,7 @@
1
- import { a as SQLITE_JSON_CODEC_ID, i as SQLITE_INTEGER_CODEC_ID, n as SQLITE_BLOB_CODEC_ID, o as SQLITE_REAL_CODEC_ID, r as SQLITE_DATETIME_CODEC_ID, s as SQLITE_TEXT_CODEC_ID, t as SQLITE_BIGINT_CODEC_ID } from "./codec-ids-DyLO2Rfx.mjs";
2
- import * as _prisma_next_framework_components_codec0 from "@prisma-next/framework-components/codec";
1
+ import { a as SQLITE_JSON_CODEC_ID, i as SQLITE_INTEGER_CODEC_ID, n as SQLITE_BLOB_CODEC_ID, o as SQLITE_REAL_CODEC_ID, r as SQLITE_DATETIME_CODEC_ID, s as SQLITE_TEXT_CODEC_ID, t as SQLITE_BIGINT_CODEC_ID } from "./codec-ids-CYwMu3-4.mjs";
2
+ import * as _$_prisma_next_framework_components_codec0 from "@prisma-next/framework-components/codec";
3
3
  import { CodecCallContext, CodecDescriptorImpl, CodecImpl, CodecInstanceContext } from "@prisma-next/framework-components/codec";
4
- import * as _standard_schema_spec0 from "@standard-schema/spec";
4
+ import * as _$_standard_schema_spec0 from "@standard-schema/spec";
5
5
  import { JsonValue } from "@prisma-next/contract/types";
6
6
  import { CodecDescriptorRegistry } from "@prisma-next/sql-relational-core/query-lane-context";
7
7
 
@@ -14,7 +14,6 @@ type JsonValue$1 = string | number | boolean | null | {
14
14
  } | readonly JsonValue$1[];
15
15
  //#endregion
16
16
  //#region src/core/codecs.d.ts
17
-
18
17
  declare class SqliteTextCodec extends CodecImpl<typeof SQLITE_TEXT_CODEC_ID, readonly ['equality', 'order', 'textual'], string, string> {
19
18
  encode(value: string, _ctx: CodecCallContext): Promise<string>;
20
19
  decode(wire: string, _ctx: CodecCallContext): Promise<string>;
@@ -25,10 +24,10 @@ declare class SqliteTextDescriptor extends CodecDescriptorImpl<void> {
25
24
  readonly codecId: "sqlite/text@1";
26
25
  readonly traits: readonly ["equality", "order", "textual"];
27
26
  readonly targetTypes: readonly ["text"];
28
- readonly paramsSchema: _standard_schema_spec0.StandardSchemaV1<void, void>;
27
+ readonly paramsSchema: _$_standard_schema_spec0.StandardSchemaV1<void, void>;
29
28
  factory(): (ctx: CodecInstanceContext) => SqliteTextCodec;
30
29
  }
31
- declare const sqliteTextColumn: () => _prisma_next_framework_components_codec0.ColumnSpec<SqliteTextCodec, undefined>;
30
+ declare const sqliteTextColumn: () => _$_prisma_next_framework_components_codec0.ColumnSpec<SqliteTextCodec, undefined>;
32
31
  declare class SqliteIntegerCodec extends CodecImpl<typeof SQLITE_INTEGER_CODEC_ID, readonly ['equality', 'order', 'numeric'], number, number> {
33
32
  encode(value: number, _ctx: CodecCallContext): Promise<number>;
34
33
  decode(wire: number, _ctx: CodecCallContext): Promise<number>;
@@ -39,10 +38,10 @@ declare class SqliteIntegerDescriptor extends CodecDescriptorImpl<void> {
39
38
  readonly codecId: "sqlite/integer@1";
40
39
  readonly traits: readonly ["equality", "order", "numeric"];
41
40
  readonly targetTypes: readonly ["integer"];
42
- readonly paramsSchema: _standard_schema_spec0.StandardSchemaV1<void, void>;
41
+ readonly paramsSchema: _$_standard_schema_spec0.StandardSchemaV1<void, void>;
43
42
  factory(): (ctx: CodecInstanceContext) => SqliteIntegerCodec;
44
43
  }
45
- declare const sqliteIntegerColumn: () => _prisma_next_framework_components_codec0.ColumnSpec<SqliteIntegerCodec, undefined>;
44
+ declare const sqliteIntegerColumn: () => _$_prisma_next_framework_components_codec0.ColumnSpec<SqliteIntegerCodec, undefined>;
46
45
  declare class SqliteRealCodec extends CodecImpl<typeof SQLITE_REAL_CODEC_ID, readonly ['equality', 'order', 'numeric'], number, number> {
47
46
  encode(value: number, _ctx: CodecCallContext): Promise<number>;
48
47
  decode(wire: number, _ctx: CodecCallContext): Promise<number>;
@@ -53,10 +52,10 @@ declare class SqliteRealDescriptor extends CodecDescriptorImpl<void> {
53
52
  readonly codecId: "sqlite/real@1";
54
53
  readonly traits: readonly ["equality", "order", "numeric"];
55
54
  readonly targetTypes: readonly ["real"];
56
- readonly paramsSchema: _standard_schema_spec0.StandardSchemaV1<void, void>;
55
+ readonly paramsSchema: _$_standard_schema_spec0.StandardSchemaV1<void, void>;
57
56
  factory(): (ctx: CodecInstanceContext) => SqliteRealCodec;
58
57
  }
59
- declare const sqliteRealColumn: () => _prisma_next_framework_components_codec0.ColumnSpec<SqliteRealCodec, undefined>;
58
+ declare const sqliteRealColumn: () => _$_prisma_next_framework_components_codec0.ColumnSpec<SqliteRealCodec, undefined>;
60
59
  declare class SqliteBlobCodec extends CodecImpl<typeof SQLITE_BLOB_CODEC_ID, readonly ['equality'], Uint8Array, Uint8Array> {
61
60
  encode(value: Uint8Array, _ctx: CodecCallContext): Promise<Uint8Array>;
62
61
  decode(wire: Uint8Array, _ctx: CodecCallContext): Promise<Uint8Array>;
@@ -67,10 +66,10 @@ declare class SqliteBlobDescriptor extends CodecDescriptorImpl<void> {
67
66
  readonly codecId: "sqlite/blob@1";
68
67
  readonly traits: readonly ["equality"];
69
68
  readonly targetTypes: readonly ["blob"];
70
- readonly paramsSchema: _standard_schema_spec0.StandardSchemaV1<void, void>;
69
+ readonly paramsSchema: _$_standard_schema_spec0.StandardSchemaV1<void, void>;
71
70
  factory(): (ctx: CodecInstanceContext) => SqliteBlobCodec;
72
71
  }
73
- declare const sqliteBlobColumn: () => _prisma_next_framework_components_codec0.ColumnSpec<SqliteBlobCodec, undefined>;
72
+ declare const sqliteBlobColumn: () => _$_prisma_next_framework_components_codec0.ColumnSpec<SqliteBlobCodec, undefined>;
74
73
  declare class SqliteDatetimeCodec extends CodecImpl<typeof SQLITE_DATETIME_CODEC_ID, readonly ['equality', 'order'], string, Date> {
75
74
  private parseDate;
76
75
  encode(value: Date, _ctx: CodecCallContext): Promise<string>;
@@ -82,10 +81,10 @@ declare class SqliteDatetimeDescriptor extends CodecDescriptorImpl<void> {
82
81
  readonly codecId: "sqlite/datetime@1";
83
82
  readonly traits: readonly ["equality", "order"];
84
83
  readonly targetTypes: readonly ["text"];
85
- readonly paramsSchema: _standard_schema_spec0.StandardSchemaV1<void, void>;
84
+ readonly paramsSchema: _$_standard_schema_spec0.StandardSchemaV1<void, void>;
86
85
  factory(): (ctx: CodecInstanceContext) => SqliteDatetimeCodec;
87
86
  }
88
- declare const sqliteDatetimeColumn: () => _prisma_next_framework_components_codec0.ColumnSpec<SqliteDatetimeCodec, undefined>;
87
+ declare const sqliteDatetimeColumn: () => _$_prisma_next_framework_components_codec0.ColumnSpec<SqliteDatetimeCodec, undefined>;
89
88
  declare class SqliteJsonCodec extends CodecImpl<typeof SQLITE_JSON_CODEC_ID, readonly ['equality'], string | JsonValue, JsonValue> {
90
89
  encode(value: JsonValue, _ctx: CodecCallContext): Promise<string>;
91
90
  decode(wire: string | JsonValue, _ctx: CodecCallContext): Promise<JsonValue>;
@@ -96,10 +95,10 @@ declare class SqliteJsonDescriptor extends CodecDescriptorImpl<void> {
96
95
  readonly codecId: "sqlite/json@1";
97
96
  readonly traits: readonly ["equality"];
98
97
  readonly targetTypes: readonly ["text"];
99
- readonly paramsSchema: _standard_schema_spec0.StandardSchemaV1<void, void>;
98
+ readonly paramsSchema: _$_standard_schema_spec0.StandardSchemaV1<void, void>;
100
99
  factory(): (ctx: CodecInstanceContext) => SqliteJsonCodec;
101
100
  }
102
- declare const sqliteJsonColumn: () => _prisma_next_framework_components_codec0.ColumnSpec<SqliteJsonCodec, undefined>;
101
+ declare const sqliteJsonColumn: () => _$_prisma_next_framework_components_codec0.ColumnSpec<SqliteJsonCodec, undefined>;
103
102
  declare class SqliteBigintCodec extends CodecImpl<typeof SQLITE_BIGINT_CODEC_ID, readonly ['equality', 'order', 'numeric'], number | bigint, bigint> {
104
103
  encode(value: bigint, _ctx: CodecCallContext): Promise<number | bigint>;
105
104
  decode(wire: number | bigint, _ctx: CodecCallContext): Promise<bigint>;
@@ -110,10 +109,10 @@ declare class SqliteBigintDescriptor extends CodecDescriptorImpl<void> {
110
109
  readonly codecId: "sqlite/bigint@1";
111
110
  readonly traits: readonly ["equality", "order", "numeric"];
112
111
  readonly targetTypes: readonly ["integer"];
113
- readonly paramsSchema: _standard_schema_spec0.StandardSchemaV1<void, void>;
112
+ readonly paramsSchema: _$_standard_schema_spec0.StandardSchemaV1<void, void>;
114
113
  factory(): (ctx: CodecInstanceContext) => SqliteBigintCodec;
115
114
  }
116
- declare const sqliteBigintColumn: () => _prisma_next_framework_components_codec0.ColumnSpec<SqliteBigintCodec, undefined>;
115
+ declare const sqliteBigintColumn: () => _$_prisma_next_framework_components_codec0.ColumnSpec<SqliteBigintCodec, undefined>;
117
116
  //#endregion
118
117
  //#region src/core/registry.d.ts
119
118
  /**
@@ -124,4 +123,4 @@ declare const sqliteBigintColumn: () => _prisma_next_framework_components_codec0
124
123
  declare const sqliteCodecRegistry: CodecDescriptorRegistry;
125
124
  //#endregion
126
125
  export { SqliteIntegerDescriptor as a, SqliteTextDescriptor as c, sqliteDatetimeColumn as d, sqliteIntegerColumn as f, JsonValue$1 as g, sqliteTextColumn as h, SqliteDatetimeDescriptor as i, sqliteBigintColumn as l, sqliteRealColumn as m, SqliteBigintDescriptor as n, SqliteJsonDescriptor as o, sqliteJsonColumn as p, SqliteBlobDescriptor as r, SqliteRealDescriptor as s, sqliteCodecRegistry as t, sqliteBlobColumn as u };
127
- //# sourceMappingURL=codecs-BqDitp2X.d.mts.map
126
+ //# sourceMappingURL=codecs-BAlEiSeP.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codecs-BAlEiSeP.d.mts","names":[],"sources":["../src/core/codec-helpers.ts","../src/core/codecs.ts","../src/core/registry.ts"],"mappings":";;;;;;;;;;;KAIY,WAAA;EAAA,UAKI,GAAA,WAAc,WAAA;AAAA,aACjB,WAAA;;;cC+BA,eAAA,SAAwB,SAAA,QAC5B,oBAAA;EAKD,MAAA,CAAO,KAAA,UAAe,IAAA,EAAM,gBAAA,GAAmB,OAAA;EAG/C,MAAA,CAAO,IAAA,UAAc,IAAA,EAAM,gBAAA,GAAmB,OAAA;EAGpD,UAAA,CAAW,KAAA,WAAgB,SAAA;EAG3B,UAAA,CAAW,IAAA,EAAM,SAAA;AAAA;AAAA,cAKN,oBAAA,SAA6B,mBAAA;EAAA,SACtB,OAAA;EAAA,SACA,MAAA;EAAA,SACA,WAAA;EAAA,SACA,YAAA,EAJc,wBAAA,CAIF,gBAAA;EACrB,OAAA,CAAA,IAAY,GAAA,EAAK,oBAAA,KAAyB,eAAA;AAAA;AAAA,cAOxC,gBAAA,QAAgB,0CAAA,CAAA,UAAA,CAAA,eAAA;AAAA,cAMhB,kBAAA,SAA2B,SAAA,QAC/B,uBAAA;EAKD,MAAA,CAAO,KAAA,UAAe,IAAA,EAAM,gBAAA,GAAmB,OAAA;EAG/C,MAAA,CAAO,IAAA,UAAc,IAAA,EAAM,gBAAA,GAAmB,OAAA;EAGpD,UAAA,CAAW,KAAA,WAAgB,SAAA;EAG3B,UAAA,CAAW,IAAA,EAAM,SAAA;AAAA;AAAA,cAKN,uBAAA,SAAgC,mBAAA;EAAA,SACzB,OAAA;EAAA,SACA,MAAA;EAAA,SACA,WAAA;EAAA,SACA,YAAA,EAJiB,wBAAA,CAIL,gBAAA;EACrB,OAAA,CAAA,IAAY,GAAA,EAAK,oBAAA,KAAyB,kBAAA;AAAA;AAAA,cAOxC,mBAAA,QAAmB,0CAAA,CAAA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AAM,gBAAA,GAAmB,OAAA;EAG7D,UAAA,CAAW,KAAA,WAAgB,SAAA;EAG3B,UAAA,CAAW,IAAA,EAAM,SAAA;AAAA;AAAA,cAQN,sBAAA,SAA+B,mBAAA;EAAA,SACxB,OAAA;EAAA,SACA,MAAA;EAAA,SACA,WAAA;EAAA,SACA,YAAA,EAJgB,wBAAA,CAIJ,gBAAA;EACrB,OAAA,CAAA,IAAY,GAAA,EAAK,oBAAA,KAAyB,iBAAA;AAAA;AAAA,cAOxC,kBAAA,QAAkB,0CAAA,CAAA,UAAA,CAAA,iBAAA;;;;;;;;cCrTlB,mBAAA,EAAqB,uBAAA"}
@@ -1,7 +1,6 @@
1
- import { a as SQLITE_JSON_CODEC_ID, i as SQLITE_INTEGER_CODEC_ID, n as SQLITE_BLOB_CODEC_ID, o as SQLITE_REAL_CODEC_ID, r as SQLITE_DATETIME_CODEC_ID, s as SQLITE_TEXT_CODEC_ID, t as SQLITE_BIGINT_CODEC_ID } from "./codec-ids-B1-OiN8Q.mjs";
1
+ import { a as SQLITE_JSON_CODEC_ID, i as SQLITE_INTEGER_CODEC_ID, n as SQLITE_BLOB_CODEC_ID, o as SQLITE_REAL_CODEC_ID, r as SQLITE_DATETIME_CODEC_ID, s as SQLITE_TEXT_CODEC_ID, t as SQLITE_BIGINT_CODEC_ID } from "./codec-ids-CuUxYcd0.mjs";
2
2
  import { sqlCharDescriptor, sqlFloatDescriptor, sqlIntDescriptor, sqlVarcharDescriptor } from "@prisma-next/sql-relational-core/ast";
3
3
  import { CodecDescriptorImpl, CodecImpl, column, voidParamsSchema } from "@prisma-next/framework-components/codec";
4
-
5
4
  //#region src/core/codecs.ts
6
5
  var SqliteTextCodec = class extends CodecImpl {
7
6
  async encode(value, _ctx) {
@@ -215,7 +214,7 @@ const codecDescriptors = [
215
214
  sqliteJsonDescriptor,
216
215
  sqliteBigintDescriptor
217
216
  ];
218
-
219
217
  //#endregion
220
218
  export { sqliteIntegerColumn as a, sqliteTextColumn as c, sqliteDatetimeColumn as i, sqliteBigintColumn as n, sqliteJsonColumn as o, sqliteBlobColumn as r, sqliteRealColumn as s, codecDescriptors as t };
221
- //# sourceMappingURL=codecs-CDcidsHL.mjs.map
219
+
220
+ //# sourceMappingURL=codecs-DVnHtVWW.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codecs-DVnHtVWW.mjs","names":[],"sources":["../src/core/codecs.ts"],"sourcesContent":["/**\n * Native SQLite target codecs (TML-2357). Mirrors the Postgres codec class form in `packages/3-targets/3-targets/postgres/src/core/codecs.ts`.\n *\n * Each codec ships as three artifacts:\n *\n * 1. A `SqliteXCodec` class extending {@link CodecImpl} that wraps the encode/decode/encodeJson/decodeJson conversions inline. SQLite's runtime conversions are simple enough that there is no shared helper module; the class bodies are the single source of truth. 2. A `SqliteXDescriptor` class extending {@link CodecDescriptorImpl} declaring the codec id, traits, target types, and params schema. SQLite codecs do not carry\n * `meta` (no per-target native-type meta today) and are all non-parameterized. 3. A per-codec column helper (`sqliteXColumn`) that calls `descriptor.factory()` directly and packages the result into a {@link ColumnSpec} via the framework {@link column} packager. The helper is tied to its descriptor with `satisfies ColumnHelperFor` + `ColumnHelperForStrict` (every SQLite codec's resolved type is well-defined).\n *\n * After TML-2357 this is the canonical source of SQLite codec metadata and runtime behaviour — the legacy `mkCodec` / `defineCodec` carriers (and the parallel `byScalar` / `codecDescriptorDefinitions` collection exports) retired with the deletion sweep.\n *\n * Audit: every SQLite codec is non-parameterized and parameter-stateless; `factory()` takes no params (`P = void`) and returns a fresh codec constructed solely from `this`.\n */\n\nimport type { JsonValue } from '@prisma-next/contract/types';\nimport {\n type AnyCodecDescriptor,\n type CodecCallContext,\n CodecDescriptorImpl,\n CodecImpl,\n type CodecInstanceContext,\n type ColumnHelperFor,\n type ColumnHelperForStrict,\n column,\n voidParamsSchema,\n} from '@prisma-next/framework-components/codec';\nimport {\n sqlCharDescriptor,\n sqlFloatDescriptor,\n sqlIntDescriptor,\n sqlVarcharDescriptor,\n} from '@prisma-next/sql-relational-core/ast';\nimport {\n SQLITE_BIGINT_CODEC_ID,\n SQLITE_BLOB_CODEC_ID,\n SQLITE_DATETIME_CODEC_ID,\n SQLITE_INTEGER_CODEC_ID,\n SQLITE_JSON_CODEC_ID,\n SQLITE_REAL_CODEC_ID,\n SQLITE_TEXT_CODEC_ID,\n} from './codec-ids';\n\nexport class SqliteTextCodec extends CodecImpl<\n typeof SQLITE_TEXT_CODEC_ID,\n readonly ['equality', 'order', 'textual'],\n string,\n string\n> {\n async encode(value: string, _ctx: CodecCallContext): Promise<string> {\n return value;\n }\n async decode(wire: string, _ctx: CodecCallContext): Promise<string> {\n return wire;\n }\n encodeJson(value: string): JsonValue {\n return value;\n }\n decodeJson(json: JsonValue): string {\n return json as string;\n }\n}\n\nexport class SqliteTextDescriptor extends CodecDescriptorImpl<void> {\n override readonly codecId = SQLITE_TEXT_CODEC_ID;\n override readonly traits = ['equality', 'order', 'textual'] as const;\n override readonly targetTypes = ['text'] as const;\n override readonly paramsSchema = voidParamsSchema;\n override factory(): (ctx: CodecInstanceContext) => SqliteTextCodec {\n return () => new SqliteTextCodec(this);\n }\n}\n\nexport const sqliteTextDescriptor = new SqliteTextDescriptor();\n\nexport const sqliteTextColumn = () =>\n column(sqliteTextDescriptor.factory(), sqliteTextDescriptor.codecId, undefined, 'text');\n\nsqliteTextColumn satisfies ColumnHelperFor<SqliteTextDescriptor>;\nsqliteTextColumn satisfies ColumnHelperForStrict<SqliteTextDescriptor>;\n\nexport class SqliteIntegerCodec extends CodecImpl<\n typeof SQLITE_INTEGER_CODEC_ID,\n readonly ['equality', 'order', 'numeric'],\n number,\n number\n> {\n async encode(value: number, _ctx: CodecCallContext): Promise<number> {\n return value;\n }\n async decode(wire: number, _ctx: CodecCallContext): Promise<number> {\n return wire;\n }\n encodeJson(value: number): JsonValue {\n return value;\n }\n decodeJson(json: JsonValue): number {\n return json as number;\n }\n}\n\nexport class SqliteIntegerDescriptor extends CodecDescriptorImpl<void> {\n override readonly codecId = SQLITE_INTEGER_CODEC_ID;\n override readonly traits = ['equality', 'order', 'numeric'] as const;\n override readonly targetTypes = ['integer'] as const;\n override readonly paramsSchema = voidParamsSchema;\n override factory(): (ctx: CodecInstanceContext) => SqliteIntegerCodec {\n return () => new SqliteIntegerCodec(this);\n }\n}\n\nexport const sqliteIntegerDescriptor = new SqliteIntegerDescriptor();\n\nexport const sqliteIntegerColumn = () =>\n column(sqliteIntegerDescriptor.factory(), sqliteIntegerDescriptor.codecId, undefined, 'integer');\n\nsqliteIntegerColumn satisfies ColumnHelperFor<SqliteIntegerDescriptor>;\nsqliteIntegerColumn satisfies ColumnHelperForStrict<SqliteIntegerDescriptor>;\n\nexport class SqliteRealCodec extends CodecImpl<\n typeof SQLITE_REAL_CODEC_ID,\n readonly ['equality', 'order', 'numeric'],\n number,\n number\n> {\n async encode(value: number, _ctx: CodecCallContext): Promise<number> {\n return value;\n }\n async decode(wire: number, _ctx: CodecCallContext): Promise<number> {\n return wire;\n }\n encodeJson(value: number): JsonValue {\n return value;\n }\n decodeJson(json: JsonValue): number {\n return json as number;\n }\n}\n\nexport class SqliteRealDescriptor extends CodecDescriptorImpl<void> {\n override readonly codecId = SQLITE_REAL_CODEC_ID;\n override readonly traits = ['equality', 'order', 'numeric'] as const;\n override readonly targetTypes = ['real'] as const;\n override readonly paramsSchema = voidParamsSchema;\n override factory(): (ctx: CodecInstanceContext) => SqliteRealCodec {\n return () => new SqliteRealCodec(this);\n }\n}\n\nexport const sqliteRealDescriptor = new SqliteRealDescriptor();\n\nexport const sqliteRealColumn = () =>\n column(sqliteRealDescriptor.factory(), sqliteRealDescriptor.codecId, undefined, 'real');\n\nsqliteRealColumn satisfies ColumnHelperFor<SqliteRealDescriptor>;\nsqliteRealColumn satisfies ColumnHelperForStrict<SqliteRealDescriptor>;\n\nexport class SqliteBlobCodec extends CodecImpl<\n typeof SQLITE_BLOB_CODEC_ID,\n readonly ['equality'],\n Uint8Array,\n Uint8Array\n> {\n async encode(value: Uint8Array, _ctx: CodecCallContext): Promise<Uint8Array> {\n return value;\n }\n async decode(wire: Uint8Array, _ctx: CodecCallContext): Promise<Uint8Array> {\n return wire;\n }\n encodeJson(value: Uint8Array): JsonValue {\n return Buffer.from(value).toString('base64');\n }\n decodeJson(json: JsonValue): Uint8Array {\n if (typeof json !== 'string') {\n throw new TypeError('sqlite/blob@1 contract value must be a base64 string');\n }\n return new Uint8Array(Buffer.from(json, 'base64'));\n }\n}\n\nexport class SqliteBlobDescriptor extends CodecDescriptorImpl<void> {\n override readonly codecId = SQLITE_BLOB_CODEC_ID;\n override readonly traits = ['equality'] as const;\n override readonly targetTypes = ['blob'] as const;\n override readonly paramsSchema = voidParamsSchema;\n override factory(): (ctx: CodecInstanceContext) => SqliteBlobCodec {\n return () => new SqliteBlobCodec(this);\n }\n}\n\nexport const sqliteBlobDescriptor = new SqliteBlobDescriptor();\n\nexport const sqliteBlobColumn = () =>\n column(sqliteBlobDescriptor.factory(), sqliteBlobDescriptor.codecId, undefined, 'blob');\n\nsqliteBlobColumn satisfies ColumnHelperFor<SqliteBlobDescriptor>;\nsqliteBlobColumn satisfies ColumnHelperForStrict<SqliteBlobDescriptor>;\n\nexport class SqliteDatetimeCodec extends CodecImpl<\n typeof SQLITE_DATETIME_CODEC_ID,\n readonly ['equality', 'order'],\n string,\n Date\n> {\n // Reject `Invalid Date` (NaN-time) at every decode ingress so consumers never receive a Date object whose downstream operations silently produce NaN. Mirrors the stricter ISO-8601 validation on the postgres timestamp helpers.\n private parseDate(value: string): Date {\n const date = new Date(value);\n if (Number.isNaN(date.getTime())) {\n throw new TypeError(`sqlite/datetime@1 value must be a valid ISO-8601 string: ${value}`);\n }\n return date;\n }\n async encode(value: Date, _ctx: CodecCallContext): Promise<string> {\n return value.toISOString();\n }\n async decode(wire: string, _ctx: CodecCallContext): Promise<Date> {\n return this.parseDate(wire);\n }\n encodeJson(value: Date): JsonValue {\n return value.toISOString();\n }\n decodeJson(json: JsonValue): Date {\n if (typeof json !== 'string') {\n throw new TypeError('sqlite/datetime@1 contract value must be an ISO-8601 string');\n }\n return this.parseDate(json);\n }\n}\n\nexport class SqliteDatetimeDescriptor extends CodecDescriptorImpl<void> {\n override readonly codecId = SQLITE_DATETIME_CODEC_ID;\n override readonly traits = ['equality', 'order'] as const;\n override readonly targetTypes = ['text'] as const;\n override readonly paramsSchema = voidParamsSchema;\n override factory(): (ctx: CodecInstanceContext) => SqliteDatetimeCodec {\n return () => new SqliteDatetimeCodec(this);\n }\n}\n\nexport const sqliteDatetimeDescriptor = new SqliteDatetimeDescriptor();\n\nexport const sqliteDatetimeColumn = () =>\n column(sqliteDatetimeDescriptor.factory(), sqliteDatetimeDescriptor.codecId, undefined, 'text');\n\nsqliteDatetimeColumn satisfies ColumnHelperFor<SqliteDatetimeDescriptor>;\nsqliteDatetimeColumn satisfies ColumnHelperForStrict<SqliteDatetimeDescriptor>;\n\nexport class SqliteJsonCodec extends CodecImpl<\n typeof SQLITE_JSON_CODEC_ID,\n readonly ['equality'],\n string | JsonValue,\n JsonValue\n> {\n async encode(value: JsonValue, _ctx: CodecCallContext): Promise<string> {\n return JSON.stringify(value);\n }\n async decode(wire: string | JsonValue, _ctx: CodecCallContext): Promise<JsonValue> {\n return typeof wire === 'string' ? (JSON.parse(wire) as JsonValue) : wire;\n }\n encodeJson(value: JsonValue): JsonValue {\n return value;\n }\n decodeJson(json: JsonValue): JsonValue {\n return json;\n }\n}\n\nexport class SqliteJsonDescriptor extends CodecDescriptorImpl<void> {\n override readonly codecId = SQLITE_JSON_CODEC_ID;\n override readonly traits = ['equality'] as const;\n override readonly targetTypes = ['text'] as const;\n override readonly paramsSchema = voidParamsSchema;\n override factory(): (ctx: CodecInstanceContext) => SqliteJsonCodec {\n return () => new SqliteJsonCodec(this);\n }\n}\n\nexport const sqliteJsonDescriptor = new SqliteJsonDescriptor();\n\nexport const sqliteJsonColumn = () =>\n column(sqliteJsonDescriptor.factory(), sqliteJsonDescriptor.codecId, undefined, 'text');\n\nsqliteJsonColumn satisfies ColumnHelperFor<SqliteJsonDescriptor>;\nsqliteJsonColumn satisfies ColumnHelperForStrict<SqliteJsonDescriptor>;\n\nexport class SqliteBigintCodec extends CodecImpl<\n typeof SQLITE_BIGINT_CODEC_ID,\n readonly ['equality', 'order', 'numeric'],\n number | bigint,\n bigint\n> {\n async encode(value: bigint, _ctx: CodecCallContext): Promise<number | bigint> {\n return value;\n }\n async decode(wire: number | bigint, _ctx: CodecCallContext): Promise<bigint> {\n return BigInt(wire);\n }\n encodeJson(value: bigint): JsonValue {\n return value.toString();\n }\n decodeJson(json: JsonValue): bigint {\n if (typeof json !== 'string' && typeof json !== 'number') {\n throw new TypeError('sqlite/bigint@1 contract value must be a string or number');\n }\n return BigInt(json);\n }\n}\n\nexport class SqliteBigintDescriptor extends CodecDescriptorImpl<void> {\n override readonly codecId = SQLITE_BIGINT_CODEC_ID;\n override readonly traits = ['equality', 'order', 'numeric'] as const;\n override readonly targetTypes = ['integer'] as const;\n override readonly paramsSchema = voidParamsSchema;\n override factory(): (ctx: CodecInstanceContext) => SqliteBigintCodec {\n return () => new SqliteBigintCodec(this);\n }\n}\n\nexport const sqliteBigintDescriptor = new SqliteBigintDescriptor();\n\nexport const sqliteBigintColumn = () =>\n column(sqliteBigintDescriptor.factory(), sqliteBigintDescriptor.codecId, undefined, 'integer');\n\nsqliteBigintColumn satisfies ColumnHelperFor<SqliteBigintDescriptor>;\nsqliteBigintColumn satisfies ColumnHelperForStrict<SqliteBigintDescriptor>;\n\nexport const codecDescriptors: readonly AnyCodecDescriptor[] = [\n sqlCharDescriptor,\n sqlVarcharDescriptor,\n sqlIntDescriptor,\n sqlFloatDescriptor,\n sqliteTextDescriptor,\n sqliteIntegerDescriptor,\n sqliteRealDescriptor,\n sqliteBlobDescriptor,\n sqliteDatetimeDescriptor,\n sqliteJsonDescriptor,\n sqliteBigintDescriptor,\n];\n"],"mappings":";;;;AAyCA,IAAa,kBAAb,cAAqC,UAKnC;CACA,MAA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CACjC,UAAqE;EACnE,aAAa,IAAI,kBAAkB,KAAK;;;AAI5C,MAAa,yBAAyB,IAAI,wBAAwB;AAElE,MAAa,2BACX,OAAO,uBAAuB,SAAS,EAAE,uBAAuB,SAAS,KAAA,GAAW,UAAU;AAKhG,MAAa,mBAAkD;CAC7D;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD"}
package/dist/codecs.d.mts CHANGED
@@ -1,3 +1,2 @@
1
- import "./codec-ids-DyLO2Rfx.mjs";
2
- import { a as SqliteIntegerDescriptor, c as SqliteTextDescriptor, d as sqliteDatetimeColumn, f as sqliteIntegerColumn, g as JsonValue, h as sqliteTextColumn, i as SqliteDatetimeDescriptor, l as sqliteBigintColumn, m as sqliteRealColumn, n as SqliteBigintDescriptor, o as SqliteJsonDescriptor, p as sqliteJsonColumn, r as SqliteBlobDescriptor, s as SqliteRealDescriptor, t as sqliteCodecRegistry, u as sqliteBlobColumn } from "./codecs-BqDitp2X.mjs";
1
+ import { a as SqliteIntegerDescriptor, c as SqliteTextDescriptor, d as sqliteDatetimeColumn, f as sqliteIntegerColumn, g as JsonValue, h as sqliteTextColumn, i as SqliteDatetimeDescriptor, l as sqliteBigintColumn, m as sqliteRealColumn, n as SqliteBigintDescriptor, o as SqliteJsonDescriptor, p as sqliteJsonColumn, r as SqliteBlobDescriptor, s as SqliteRealDescriptor, t as sqliteCodecRegistry, u as sqliteBlobColumn } from "./codecs-BAlEiSeP.mjs";
3
2
  export { JsonValue, SqliteBigintDescriptor, SqliteBlobDescriptor, SqliteDatetimeDescriptor, SqliteIntegerDescriptor, SqliteJsonDescriptor, SqliteRealDescriptor, SqliteTextDescriptor, sqliteBigintColumn, sqliteBlobColumn, sqliteCodecRegistry, sqliteDatetimeColumn, sqliteIntegerColumn, sqliteJsonColumn, sqliteRealColumn, sqliteTextColumn };
package/dist/codecs.mjs CHANGED
@@ -1,6 +1,5 @@
1
- import { a as sqliteIntegerColumn, c as sqliteTextColumn, i as sqliteDatetimeColumn, n as sqliteBigintColumn, o as sqliteJsonColumn, r as sqliteBlobColumn, s as sqliteRealColumn, t as codecDescriptors } from "./codecs-CDcidsHL.mjs";
1
+ import { a as sqliteIntegerColumn, c as sqliteTextColumn, i as sqliteDatetimeColumn, n as sqliteBigintColumn, o as sqliteJsonColumn, r as sqliteBlobColumn, s as sqliteRealColumn, t as codecDescriptors } from "./codecs-DVnHtVWW.mjs";
2
2
  import { buildCodecDescriptorRegistry } from "@prisma-next/sql-relational-core/codec-descriptor-registry";
3
-
4
3
  //#region src/core/registry.ts
5
4
  /**
6
5
  * Registry of every codec descriptor shipped by `@prisma-next/target-sqlite`.
@@ -8,7 +7,7 @@ import { buildCodecDescriptorRegistry } from "@prisma-next/sql-relational-core/c
8
7
  * Public consumer surface for the sqlite codec set: the sqlite adapter and any other consumer that needs to enumerate or look up a sqlite codec by id consumes this rather than the raw descriptor array. See ADR 208.
9
8
  */
10
9
  const sqliteCodecRegistry = buildCodecDescriptorRegistry(codecDescriptors);
11
-
12
10
  //#endregion
13
11
  export { sqliteBigintColumn, sqliteBlobColumn, sqliteCodecRegistry, sqliteDatetimeColumn, sqliteIntegerColumn, sqliteJsonColumn, sqliteRealColumn, sqliteTextColumn };
12
+
14
13
  //# sourceMappingURL=codecs.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"codecs.mjs","names":["sqliteCodecRegistry: CodecDescriptorRegistry"],"sources":["../src/core/registry.ts"],"sourcesContent":["import { buildCodecDescriptorRegistry } from '@prisma-next/sql-relational-core/codec-descriptor-registry';\nimport type { CodecDescriptorRegistry } from '@prisma-next/sql-relational-core/query-lane-context';\nimport { codecDescriptors } from './codecs';\n\n/**\n * Registry of every codec descriptor shipped by `@prisma-next/target-sqlite`.\n *\n * Public consumer surface for the sqlite codec set: the sqlite adapter and any other consumer that needs to enumerate or look up a sqlite codec by id consumes this rather than the raw descriptor array. See ADR 208.\n */\nexport const sqliteCodecRegistry: CodecDescriptorRegistry =\n buildCodecDescriptorRegistry(codecDescriptors);\n"],"mappings":";;;;;;;;;AASA,MAAaA,sBACX,6BAA6B,iBAAiB"}
1
+ {"version":3,"file":"codecs.mjs","names":[],"sources":["../src/core/registry.ts"],"sourcesContent":["import { buildCodecDescriptorRegistry } from '@prisma-next/sql-relational-core/codec-descriptor-registry';\nimport type { CodecDescriptorRegistry } from '@prisma-next/sql-relational-core/query-lane-context';\nimport { codecDescriptors } from './codecs';\n\n/**\n * Registry of every codec descriptor shipped by `@prisma-next/target-sqlite`.\n *\n * Public consumer surface for the sqlite codec set: the sqlite adapter and any other consumer that needs to enumerate or look up a sqlite codec by id consumes this rather than the raw descriptor array. See ADR 208.\n */\nexport const sqliteCodecRegistry: CodecDescriptorRegistry =\n buildCodecDescriptorRegistry(codecDescriptors);\n"],"mappings":";;;;;;;;AASA,MAAa,sBACX,6BAA6B,iBAAiB"}
@@ -1,4 +1,4 @@
1
- import { t as SqlitePlanTargetDetails } from "./planner-target-details-CtWRvse0.mjs";
1
+ import { t as SqlitePlanTargetDetails } from "./planner-target-details-vhvZDWK1.mjs";
2
2
  import { SqlControlTargetDescriptor } from "@prisma-next/family-sql/control";
3
3
 
4
4
  //#region src/core/control-target.d.ts
@@ -1 +1 @@
1
- {"version":3,"file":"control.d.mts","names":[],"sources":["../src/core/control-target.ts"],"sourcesContent":[],"mappings":";;;;cA4BM,+BAA+B,qCAAqC"}
1
+ {"version":3,"file":"control.d.mts","names":[],"sources":["../src/core/control-target.ts"],"mappings":";;;;cA4BM,6BAAA,EAA+B,0BAAA,WAAqC,uBAAA"}
package/dist/control.mjs CHANGED
@@ -1,20 +1,20 @@
1
- import { t as sqliteTargetDescriptorMeta } from "./descriptor-meta-BA2YAFQq.mjs";
2
- import { t as parseSqliteDefault } from "./default-normalizer-R-sQXAYt.mjs";
3
- import { t as normalizeSqliteNativeType } from "./native-type-normalizer-BMovohPm.mjs";
4
- import { d as renderDefaultLiteral } from "./tables-sKIg_lWE.mjs";
5
- import { n as createSqliteMigrationPlanner } from "./planner-DmOFOhoq.mjs";
6
- import { a as buildLedgerInsertStatement, c as ensureMarkerTableStatement, i as MARKER_TABLE_NAME, l as readMarkerStatement, o as buildWriteMarkerStatements, s as ensureLedgerTableStatement } from "./statement-builders-DobaAWnW.mjs";
1
+ import { t as sqliteTargetDescriptorMeta } from "./descriptor-meta-CE2Kbn9b.mjs";
2
+ import { t as parseSqliteDefault } from "./default-normalizer-3Fccw7yw.mjs";
3
+ import { t as normalizeSqliteNativeType } from "./native-type-normalizer-BlN5XfD-.mjs";
4
+ import { d as renderDefaultLiteral } from "./tables-D84zfPZI.mjs";
5
+ import { n as createSqliteMigrationPlanner } from "./planner-CIjeXa04.mjs";
6
+ import { a as buildLedgerInsertStatement, c as ensureMarkerTableStatement, i as MARKER_TABLE_NAME, l as readMarkerStatement, o as buildWriteMarkerStatements, s as ensureLedgerTableStatement } from "./statement-builders-DMT4ltXR.mjs";
7
7
  import { contractToSchemaIR, runnerFailure, runnerSuccess } from "@prisma-next/family-sql/control";
8
8
  import { verifySqlSchema } from "@prisma-next/family-sql/schema-verify";
9
9
  import { ok, okVoid } from "@prisma-next/utils/result";
10
10
  import { ifDefined } from "@prisma-next/utils/defined";
11
11
  import { parseContractMarkerRow } from "@prisma-next/family-sql/verify";
12
-
13
12
  //#region src/core/migrations/runner.ts
14
13
  function createSqliteMigrationRunner(family) {
15
14
  return new SqliteMigrationRunner(family);
16
15
  }
17
16
  var SqliteMigrationRunner = class {
17
+ family;
18
18
  constructor(family) {
19
19
  this.family = family;
20
20
  }
@@ -327,7 +327,6 @@ var SqliteMigrationRunner = class {
327
327
  await driver.query(statement.sql);
328
328
  }
329
329
  };
330
-
331
330
  //#endregion
332
331
  //#region src/core/control-target.ts
333
332
  function sqliteRenderDefault(def, _column) {
@@ -367,8 +366,7 @@ const sqliteControlTargetDescriptor = {
367
366
  return createSqliteMigrationRunner(family);
368
367
  }
369
368
  };
370
- var control_target_default = sqliteControlTargetDescriptor;
371
-
372
369
  //#endregion
373
- export { control_target_default as default };
370
+ export { sqliteControlTargetDescriptor as default };
371
+
374
372
  //# sourceMappingURL=control.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"control.mjs","names":["family: SqlControlFamilyInstance","operationsExecuted: number","executedOperations: readonly SqlMigrationPlanOperation<SqlitePlanTargetDetails>[]","executedOperations: Array<SqlMigrationPlanOperation<SqlitePlanTargetDetails>>","error: unknown","sqliteControlTargetDescriptor: SqlControlTargetDescriptor<'sqlite', SqlitePlanTargetDetails>"],"sources":["../src/core/migrations/runner.ts","../src/core/control-target.ts"],"sourcesContent":["import type { ContractMarkerRecord } from '@prisma-next/contract/types';\nimport type {\n MigrationOperationPolicy,\n SqlControlFamilyInstance,\n SqlMigrationPlanContractInfo,\n SqlMigrationPlanOperation,\n SqlMigrationPlanOperationStep,\n SqlMigrationRunner,\n SqlMigrationRunnerExecuteOptions,\n SqlMigrationRunnerFailure,\n SqlMigrationRunnerResult,\n} from '@prisma-next/family-sql/control';\nimport { runnerFailure, runnerSuccess } from '@prisma-next/family-sql/control';\nimport { verifySqlSchema } from '@prisma-next/family-sql/schema-verify';\nimport { type ContractMarkerRow, parseContractMarkerRow } from '@prisma-next/family-sql/verify';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport type { Result } from '@prisma-next/utils/result';\nimport { ok, okVoid } from '@prisma-next/utils/result';\nimport { parseSqliteDefault } from '../default-normalizer';\nimport { normalizeSqliteNativeType } from '../native-type-normalizer';\nimport type { SqlitePlanTargetDetails } from './planner-target-details';\nimport {\n buildLedgerInsertStatement,\n buildWriteMarkerStatements,\n ensureLedgerTableStatement,\n ensureMarkerTableStatement,\n MARKER_TABLE_NAME,\n readMarkerStatement,\n type SqlStatement,\n} from './statement-builders';\n\nexport function createSqliteMigrationRunner(\n family: SqlControlFamilyInstance,\n): SqlMigrationRunner<SqlitePlanTargetDetails> {\n return new SqliteMigrationRunner(family);\n}\n\nclass SqliteMigrationRunner implements SqlMigrationRunner<SqlitePlanTargetDetails> {\n constructor(private readonly family: SqlControlFamilyInstance) {}\n\n async execute(\n options: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>,\n ): Promise<SqlMigrationRunnerResult> {\n const driver = options.driver;\n\n const destinationCheck = this.ensurePlanMatchesDestinationContract(\n options.plan.destination,\n options.destinationContract,\n );\n if (!destinationCheck.ok) {\n return destinationCheck;\n }\n\n const policyCheck = this.enforcePolicyCompatibility(options.policy, options.plan.operations);\n if (!policyCheck.ok) {\n return policyCheck;\n }\n\n // SQLite recreate-table drops and rebuilds the table. If foreign_keys is ON,\n // dropping a referenced parent cascade-deletes child rows; we must disable FK\n // enforcement for the duration of the migration and validate integrity before\n // committing. PRAGMA foreign_keys is a no-op inside a transaction, so toggle\n // around BEGIN/COMMIT.\n const fkWasEnabled = await this.readForeignKeysEnabled(driver);\n if (fkWasEnabled) {\n await driver.query('PRAGMA foreign_keys = OFF');\n }\n\n try {\n await this.beginExclusiveTransaction(driver);\n let committed = false;\n try {\n const ensureResult = await this.ensureControlTables(driver);\n if (!ensureResult.ok) {\n return ensureResult;\n }\n const existingMarker = await this.readMarker(driver, options.plan.spaceId);\n\n const markerCheck = this.ensureMarkerCompatibility(existingMarker, options.plan);\n if (!markerCheck.ok) {\n return markerCheck;\n }\n\n const markerAtDestination = this.markerMatchesDestination(existingMarker, options.plan);\n const isSelfEdge =\n options.plan.origin?.storageHash === options.plan.destination.storageHash;\n const skipOperations = markerAtDestination && options.plan.origin != null && !isSelfEdge;\n\n let operationsExecuted: number;\n let executedOperations: readonly SqlMigrationPlanOperation<SqlitePlanTargetDetails>[];\n\n if (skipOperations) {\n operationsExecuted = 0;\n executedOperations = [];\n } else {\n const applyResult = await this.applyPlan(driver, options);\n if (!applyResult.ok) {\n return applyResult;\n }\n operationsExecuted = applyResult.value.operationsExecuted;\n executedOperations = applyResult.value.executedOperations;\n }\n\n const schemaIR = await this.family.introspect({\n driver,\n contract: options.destinationContract,\n });\n\n const schemaVerifyResult = verifySqlSchema({\n contract: options.destinationContract,\n schema: schemaIR,\n strict: options.strictVerification ?? true,\n context: options.context ?? {},\n typeMetadataRegistry: this.family.typeMetadataRegistry,\n frameworkComponents: options.frameworkComponents,\n normalizeDefault: parseSqliteDefault,\n normalizeNativeType: normalizeSqliteNativeType,\n });\n if (!schemaVerifyResult.ok) {\n return runnerFailure('SCHEMA_VERIFY_FAILED', schemaVerifyResult.summary, {\n why: 'The resulting database schema does not satisfy the destination contract.',\n meta: {\n issues: schemaVerifyResult.schema.issues,\n },\n });\n }\n\n // Self-edge no-op detection: a self-edge migration whose ops had no\n // ops to begin with and brings no new invariants produced no\n // observable change. Skip the marker + ledger writes so an idempotent\n // re-apply of a self-edge data transform doesn't churn updatedAt or\n // pile up empty ledger entries. db update no-ops still write a\n // ledger entry as audit trail.\n const incomingInvariants = options.plan.providedInvariants;\n const existingInvariants = new Set(existingMarker?.invariants ?? []);\n const incomingIsSubsetOfExisting = incomingInvariants.every((id) =>\n existingInvariants.has(id),\n );\n const isSelfEdgeNoOp = isSelfEdge && operationsExecuted === 0 && incomingIsSubsetOfExisting;\n\n if (!isSelfEdgeNoOp) {\n await this.upsertMarker(driver, options, existingMarker);\n await this.recordLedgerEntry(driver, options, existingMarker, executedOperations);\n }\n\n if (fkWasEnabled) {\n const fkIntegrityCheck = await this.verifyForeignKeyIntegrity(driver);\n if (!fkIntegrityCheck.ok) {\n return fkIntegrityCheck;\n }\n }\n\n await this.commitTransaction(driver);\n committed = true;\n return runnerSuccess({\n operationsPlanned: options.plan.operations.length,\n operationsExecuted,\n });\n } finally {\n if (!committed) {\n await this.rollbackTransaction(driver);\n }\n }\n } finally {\n if (fkWasEnabled) {\n await driver.query('PRAGMA foreign_keys = ON');\n }\n }\n }\n\n private async readForeignKeysEnabled(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n ): Promise<boolean> {\n const result = await driver.query<{ foreign_keys: number }>('PRAGMA foreign_keys');\n const row = result.rows[0];\n return row?.foreign_keys === 1;\n }\n\n private async verifyForeignKeyIntegrity(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n ): Promise<Result<void, SqlMigrationRunnerFailure>> {\n const result = await driver.query<Record<string, unknown>>('PRAGMA foreign_key_check');\n if (result.rows.length === 0) {\n return okVoid();\n }\n return runnerFailure(\n 'FOREIGN_KEY_VIOLATION',\n `Foreign key integrity check failed after migration: ${result.rows.length} violation(s).`,\n {\n why: 'PRAGMA foreign_key_check reported violations after applying recreate-table operations.',\n meta: { violations: result.rows },\n },\n );\n }\n\n private async applyPlan(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n options: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>,\n ): Promise<\n Result<\n {\n readonly operationsExecuted: number;\n readonly executedOperations: readonly SqlMigrationPlanOperation<SqlitePlanTargetDetails>[];\n },\n SqlMigrationRunnerFailure\n >\n > {\n const checks = options.executionChecks;\n const runPrechecks = checks?.prechecks !== false;\n const runPostchecks = checks?.postchecks !== false;\n const runIdempotency = checks?.idempotencyChecks !== false;\n\n let operationsExecuted = 0;\n const executedOperations: Array<SqlMigrationPlanOperation<SqlitePlanTargetDetails>> = [];\n\n for (const operation of options.plan.operations) {\n options.callbacks?.onOperationStart?.(operation);\n try {\n if (runPostchecks && runIdempotency) {\n const postcheckAlreadySatisfied = await this.expectationsAreSatisfied(\n driver,\n operation.postcheck,\n );\n if (postcheckAlreadySatisfied) {\n executedOperations.push(this.createSkipRecord(operation));\n continue;\n }\n }\n\n if (runPrechecks) {\n const precheckResult = await this.runExpectationSteps(\n driver,\n operation.precheck,\n operation,\n 'precheck',\n );\n if (!precheckResult.ok) {\n return precheckResult;\n }\n }\n\n const executeResult = await this.runExecuteSteps(driver, operation.execute, operation);\n if (!executeResult.ok) {\n return executeResult;\n }\n\n if (runPostchecks) {\n const postcheckResult = await this.runExpectationSteps(\n driver,\n operation.postcheck,\n operation,\n 'postcheck',\n );\n if (!postcheckResult.ok) {\n return postcheckResult;\n }\n }\n\n executedOperations.push(operation);\n operationsExecuted += 1;\n } finally {\n options.callbacks?.onOperationComplete?.(operation);\n }\n }\n return ok({ operationsExecuted, executedOperations });\n }\n\n private async ensureControlTables(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n ): Promise<Result<void, SqlMigrationRunnerFailure>> {\n // Pre-1.0 zero-range guardrail: detect a pre-cleanup single-row\n // marker table (no `space` column) and surface a structured failure\n // rather than silently rebuilding the table into the per-space\n // shape. See `specs/framework-mechanism.spec.md § 2`.\n const legacyDetection = await this.detectLegacyMarkerShape(driver);\n if (!legacyDetection.ok) {\n return legacyDetection;\n }\n await this.executeStatement(driver, ensureMarkerTableStatement);\n await this.executeStatement(driver, ensureLedgerTableStatement);\n return okVoid();\n }\n\n private async detectLegacyMarkerShape(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n ): Promise<Result<void, SqlMigrationRunnerFailure>> {\n const tableInfo = await driver.query<{ name: string }>(\n `PRAGMA table_info(\"${MARKER_TABLE_NAME}\")`,\n );\n if (tableInfo.rows.length === 0) {\n return okVoid();\n }\n const columns = new Set(tableInfo.rows.map((row) => row.name));\n if (columns.has('space')) {\n return okVoid();\n }\n return runnerFailure(\n 'LEGACY_MARKER_SHAPE',\n `Legacy marker-table shape detected on ${MARKER_TABLE_NAME} (no \\`space\\` column). ` +\n 'Prisma Next is in pre-1.0; the previous transitional auto-migration to the per-space-row schema has been removed. ' +\n `Drop \\`${MARKER_TABLE_NAME}\\` and re-run \\`dbInit\\` to reinitialise from a clean baseline.`,\n {\n meta: {\n table: MARKER_TABLE_NAME,\n columns: [...columns].sort(),\n },\n },\n );\n }\n\n private async readMarker(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n space: string,\n ): Promise<ContractMarkerRecord | null> {\n const stmt = readMarkerStatement(space);\n try {\n const result = await driver.query<ContractMarkerRow>(stmt.sql, stmt.params);\n const row = result.rows[0];\n if (!row) return null;\n // SQLite stores arrays as JSON-encoded TEXT (no native array type), so\n // the driver returns `invariants` as a string. Decode before delegating\n // to the shared row schema, which expects `string[]`.\n const invariants =\n typeof row.invariants === 'string'\n ? (JSON.parse(row.invariants) as unknown)\n : row.invariants;\n return parseContractMarkerRow({ ...row, invariants });\n } catch (error) {\n // Table might not exist yet\n if (error instanceof Error && error.message.includes('no such table')) {\n return null;\n }\n throw error;\n }\n }\n\n private async runExpectationSteps(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n steps: readonly SqlMigrationPlanOperationStep[],\n operation: SqlMigrationPlanOperation<SqlitePlanTargetDetails>,\n phase: 'precheck' | 'postcheck',\n ): Promise<Result<void, SqlMigrationRunnerFailure>> {\n for (const step of steps) {\n const result = await driver.query(step.sql, step.params ?? []);\n if (!this.stepResultIsTrue(result.rows)) {\n const code = phase === 'precheck' ? 'PRECHECK_FAILED' : 'POSTCHECK_FAILED';\n return runnerFailure(\n code,\n `Operation ${operation.id} failed during ${phase}: ${step.description}`,\n {\n meta: {\n operationId: operation.id,\n phase,\n stepDescription: step.description,\n },\n },\n );\n }\n }\n return okVoid();\n }\n\n private async runExecuteSteps(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n steps: readonly SqlMigrationPlanOperationStep[],\n operation: SqlMigrationPlanOperation<SqlitePlanTargetDetails>,\n ): Promise<Result<void, SqlMigrationRunnerFailure>> {\n for (const step of steps) {\n try {\n await driver.query(step.sql, step.params ?? []);\n } catch (error: unknown) {\n const message = error instanceof Error ? error.message : String(error);\n return runnerFailure(\n 'EXECUTION_FAILED',\n `Operation ${operation.id} failed during execution: ${step.description}`,\n {\n why: message,\n meta: {\n operationId: operation.id,\n stepDescription: step.description,\n sql: step.sql,\n },\n },\n );\n }\n }\n return okVoid();\n }\n\n private stepResultIsTrue(rows: readonly Record<string, unknown>[]): boolean {\n if (!rows || rows.length === 0) {\n return false;\n }\n const firstRow = rows[0];\n const firstValue = firstRow ? Object.values(firstRow)[0] : undefined;\n if (typeof firstValue === 'number') {\n return firstValue !== 0;\n }\n if (typeof firstValue === 'boolean') {\n return firstValue;\n }\n if (typeof firstValue === 'string') {\n const lower = firstValue.toLowerCase();\n if (lower === 'true' || lower === '1') return true;\n if (lower === 'false' || lower === '0') return false;\n return firstValue.length > 0;\n }\n return Boolean(firstValue);\n }\n\n private async expectationsAreSatisfied(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n steps: readonly SqlMigrationPlanOperationStep[],\n ): Promise<boolean> {\n if (steps.length === 0) {\n return false;\n }\n for (const step of steps) {\n const result = await driver.query(step.sql, step.params ?? []);\n if (!this.stepResultIsTrue(result.rows)) {\n return false;\n }\n }\n return true;\n }\n\n private createSkipRecord(\n operation: SqlMigrationPlanOperation<SqlitePlanTargetDetails>,\n ): SqlMigrationPlanOperation<SqlitePlanTargetDetails> {\n return Object.freeze({\n id: operation.id,\n label: operation.label,\n ...ifDefined('summary', operation.summary),\n operationClass: operation.operationClass,\n target: operation.target,\n precheck: Object.freeze([]),\n execute: Object.freeze([]),\n postcheck: Object.freeze([...operation.postcheck]),\n meta: Object.freeze({\n ...(operation.meta ?? {}),\n runner: Object.freeze({ skipped: true, reason: 'postcheck_pre_satisfied' }),\n }),\n });\n }\n\n private markerMatchesDestination(\n marker: ContractMarkerRecord | null,\n plan: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['plan'],\n ): boolean {\n if (!marker) return false;\n if (marker.storageHash !== plan.destination.storageHash) return false;\n if (plan.destination.profileHash && marker.profileHash !== plan.destination.profileHash) {\n return false;\n }\n return true;\n }\n\n private enforcePolicyCompatibility(\n policy: MigrationOperationPolicy,\n operations: readonly SqlMigrationPlanOperation<SqlitePlanTargetDetails>[],\n ): Result<void, SqlMigrationRunnerFailure> {\n const allowedClasses = new Set(policy.allowedOperationClasses);\n for (const operation of operations) {\n if (!allowedClasses.has(operation.operationClass)) {\n return runnerFailure(\n 'POLICY_VIOLATION',\n `Operation ${operation.id} has class \"${operation.operationClass}\" which is not allowed by policy.`,\n {\n why: `Policy only allows: ${policy.allowedOperationClasses.join(', ')}.`,\n meta: {\n operationId: operation.id,\n operationClass: operation.operationClass,\n allowedClasses: policy.allowedOperationClasses,\n },\n },\n );\n }\n }\n return okVoid();\n }\n\n private ensureMarkerCompatibility(\n marker: ContractMarkerRecord | null,\n plan: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['plan'],\n ): Result<void, SqlMigrationRunnerFailure> {\n const origin = plan.origin ?? null;\n if (!origin) {\n return okVoid();\n }\n if (!marker) {\n return runnerFailure(\n 'MARKER_ORIGIN_MISMATCH',\n `Missing contract marker: expected origin storage hash ${origin.storageHash}.`,\n { meta: { expectedOriginStorageHash: origin.storageHash } },\n );\n }\n if (marker.storageHash !== origin.storageHash) {\n return runnerFailure(\n 'MARKER_ORIGIN_MISMATCH',\n `Existing contract marker (${marker.storageHash}) does not match plan origin (${origin.storageHash}).`,\n {\n meta: {\n markerStorageHash: marker.storageHash,\n expectedOriginStorageHash: origin.storageHash,\n },\n },\n );\n }\n if (origin.profileHash && marker.profileHash !== origin.profileHash) {\n return runnerFailure(\n 'MARKER_ORIGIN_MISMATCH',\n `Existing contract marker profile hash (${marker.profileHash}) does not match plan origin profile hash (${origin.profileHash}).`,\n {\n meta: {\n markerProfileHash: marker.profileHash,\n expectedOriginProfileHash: origin.profileHash,\n },\n },\n );\n }\n return okVoid();\n }\n\n private ensurePlanMatchesDestinationContract(\n destination: SqlMigrationPlanContractInfo,\n contract: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['destinationContract'],\n ): Result<void, SqlMigrationRunnerFailure> {\n if (destination.storageHash !== contract.storage.storageHash) {\n return runnerFailure(\n 'DESTINATION_CONTRACT_MISMATCH',\n `Plan destination storage hash (${destination.storageHash}) does not match provided contract storage hash (${contract.storage.storageHash}).`,\n {\n meta: {\n planStorageHash: destination.storageHash,\n contractStorageHash: contract.storage.storageHash,\n },\n },\n );\n }\n if (\n destination.profileHash &&\n contract.profileHash &&\n destination.profileHash !== contract.profileHash\n ) {\n return runnerFailure(\n 'DESTINATION_CONTRACT_MISMATCH',\n `Plan destination profile hash (${destination.profileHash}) does not match provided contract profile hash (${contract.profileHash}).`,\n {\n meta: {\n planProfileHash: destination.profileHash,\n contractProfileHash: contract.profileHash,\n },\n },\n );\n }\n return okVoid();\n }\n\n private async upsertMarker(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n options: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>,\n existingMarker: ContractMarkerRecord | null,\n ): Promise<void> {\n // SQLite has no native array type, so we can't merge invariants in SQL\n // the way Postgres does. Merge client-side under the runner's\n // BEGIN EXCLUSIVE — sort + dedupe so the JSON-encoded value is stable.\n const merged = new Set<string>(existingMarker?.invariants ?? []);\n for (const inv of options.plan.providedInvariants) merged.add(inv);\n const invariants = Array.from(merged).sort();\n const writeStatements = buildWriteMarkerStatements({\n space: options.plan.spaceId,\n storageHash: options.plan.destination.storageHash,\n profileHash:\n options.plan.destination.profileHash ??\n options.destinationContract.profileHash ??\n options.plan.destination.storageHash,\n contractJson: options.destinationContract,\n canonicalVersion: null,\n meta: {},\n invariants,\n });\n const statement = existingMarker ? writeStatements.update : writeStatements.insert;\n await this.executeStatement(driver, statement);\n }\n\n private async recordLedgerEntry(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n options: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>,\n existingMarker: ContractMarkerRecord | null,\n executedOperations: readonly SqlMigrationPlanOperation<SqlitePlanTargetDetails>[],\n ): Promise<void> {\n const ledgerStatement = buildLedgerInsertStatement({\n originStorageHash: existingMarker?.storageHash ?? null,\n originProfileHash: existingMarker?.profileHash ?? null,\n destinationStorageHash: options.plan.destination.storageHash,\n destinationProfileHash:\n options.plan.destination.profileHash ??\n options.destinationContract.profileHash ??\n options.plan.destination.storageHash,\n contractJsonBefore: existingMarker?.contractJson ?? null,\n contractJsonAfter: options.destinationContract,\n operations: executedOperations,\n });\n await this.executeStatement(driver, ledgerStatement);\n }\n\n private async beginExclusiveTransaction(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n ): Promise<void> {\n await driver.query('BEGIN EXCLUSIVE');\n }\n\n private async commitTransaction(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n ): Promise<void> {\n await driver.query('COMMIT');\n }\n\n private async rollbackTransaction(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n ): Promise<void> {\n await driver.query('ROLLBACK');\n }\n\n private async executeStatement(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n statement: SqlStatement,\n ): Promise<void> {\n if (statement.params.length > 0) {\n await driver.query(statement.sql, statement.params);\n return;\n }\n await driver.query(statement.sql);\n }\n}\n","import type { ColumnDefault, Contract } from '@prisma-next/contract/types';\nimport type {\n SqlControlFamilyInstance,\n SqlControlTargetDescriptor,\n} from '@prisma-next/family-sql/control';\nimport { contractToSchemaIR } from '@prisma-next/family-sql/control';\nimport type {\n ControlTargetInstance,\n MigrationPlanner,\n MigrationRunner,\n} from '@prisma-next/framework-components/control';\nimport type { SqlStorage, StorageColumn } from '@prisma-next/sql-contract/types';\nimport { sqliteTargetDescriptorMeta } from './descriptor-meta';\nimport { createSqliteMigrationPlanner } from './migrations/planner';\nimport { renderDefaultLiteral } from './migrations/planner-ddl-builders';\nimport type { SqlitePlanTargetDetails } from './migrations/planner-target-details';\nimport { createSqliteMigrationRunner } from './migrations/runner';\n\nfunction sqliteRenderDefault(def: ColumnDefault, _column: StorageColumn): string {\n if (def.kind === 'function') {\n if (def.expression === 'now()') {\n return \"datetime('now')\";\n }\n return def.expression;\n }\n return renderDefaultLiteral(def.value);\n}\n\nconst sqliteControlTargetDescriptor: SqlControlTargetDescriptor<'sqlite', SqlitePlanTargetDetails> =\n {\n ...sqliteTargetDescriptorMeta,\n migrations: {\n createPlanner(_family: SqlControlFamilyInstance): MigrationPlanner<'sql', 'sqlite'> {\n return createSqliteMigrationPlanner();\n },\n createRunner(family) {\n return createSqliteMigrationRunner(family) as MigrationRunner<'sql', 'sqlite'>;\n },\n contractToSchema(contract, frameworkComponents) {\n return contractToSchemaIR(contract as Contract<SqlStorage> | null, {\n annotationNamespace: 'sqlite',\n renderDefault: sqliteRenderDefault,\n frameworkComponents: frameworkComponents ?? [],\n });\n },\n },\n create(): ControlTargetInstance<'sql', 'sqlite'> {\n return {\n familyId: 'sql',\n targetId: 'sqlite',\n };\n },\n createPlanner(_family: SqlControlFamilyInstance) {\n return createSqliteMigrationPlanner();\n },\n createRunner(family) {\n return createSqliteMigrationRunner(family);\n },\n };\n\nexport default sqliteControlTargetDescriptor;\n"],"mappings":";;;;;;;;;;;;;AA+BA,SAAgB,4BACd,QAC6C;AAC7C,QAAO,IAAI,sBAAsB,OAAO;;AAG1C,IAAM,wBAAN,MAAmF;CACjF,YAAY,AAAiBA,QAAkC;EAAlC;;CAE7B,MAAM,QACJ,SACmC;EACnC,MAAM,SAAS,QAAQ;EAEvB,MAAM,mBAAmB,KAAK,qCAC5B,QAAQ,KAAK,aACb,QAAQ,oBACT;AACD,MAAI,CAAC,iBAAiB,GACpB,QAAO;EAGT,MAAM,cAAc,KAAK,2BAA2B,QAAQ,QAAQ,QAAQ,KAAK,WAAW;AAC5F,MAAI,CAAC,YAAY,GACf,QAAO;EAQT,MAAM,eAAe,MAAM,KAAK,uBAAuB,OAAO;AAC9D,MAAI,aACF,OAAM,OAAO,MAAM,4BAA4B;AAGjD,MAAI;AACF,SAAM,KAAK,0BAA0B,OAAO;GAC5C,IAAI,YAAY;AAChB,OAAI;IACF,MAAM,eAAe,MAAM,KAAK,oBAAoB,OAAO;AAC3D,QAAI,CAAC,aAAa,GAChB,QAAO;IAET,MAAM,iBA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AI,IAAI,SAAS,YAAY;AAC3B,MAAI,IAAI,eAAe,QACrB,QAAO;AAET,SAAO,IAAI;;AAEb,QAAO,qBAAqB,IAAI,MAAM;;AAGxC,MAAMC,gCACJ;CACE,GAAG;CACH,YAAY;EACV,cAAc,SAAsE;AAClF,UAAO,8BAA8B;;EAEvC,aAAa,QAAQ;AACnB,UAAO,4BAA4B,OAAO;;EAE5C,iBAAiB,UAAU,qBAAqB;AAC9C,UAAO,mBAAmB,UAAyC;IACjE,qBAAqB;IACrB,eAAe;IACf,qBAAqB,uBAAuB,EAAE;IAC/C,CAAC;;EAEL;CACD,SAAiD;AAC/C,SAAO;GACL,UAAU;GACV,UAAU;GACX;;CAEH,cAAc,SAAmC;AAC/C,SAAO,8BAA8B;;CAEvC,aAAa,QAAQ;AACnB,SAAO,4BAA4B,OAAO;;CAE7C;AAEH,6BAAe"}
1
+ {"version":3,"file":"control.mjs","names":[],"sources":["../src/core/migrations/runner.ts","../src/core/control-target.ts"],"sourcesContent":["import type { ContractMarkerRecord } from '@prisma-next/contract/types';\nimport type {\n MigrationOperationPolicy,\n SqlControlFamilyInstance,\n SqlMigrationPlanContractInfo,\n SqlMigrationPlanOperation,\n SqlMigrationPlanOperationStep,\n SqlMigrationRunner,\n SqlMigrationRunnerExecuteOptions,\n SqlMigrationRunnerFailure,\n SqlMigrationRunnerResult,\n} from '@prisma-next/family-sql/control';\nimport { runnerFailure, runnerSuccess } from '@prisma-next/family-sql/control';\nimport { verifySqlSchema } from '@prisma-next/family-sql/schema-verify';\nimport { type ContractMarkerRow, parseContractMarkerRow } from '@prisma-next/family-sql/verify';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport type { Result } from '@prisma-next/utils/result';\nimport { ok, okVoid } from '@prisma-next/utils/result';\nimport { parseSqliteDefault } from '../default-normalizer';\nimport { normalizeSqliteNativeType } from '../native-type-normalizer';\nimport type { SqlitePlanTargetDetails } from './planner-target-details';\nimport {\n buildLedgerInsertStatement,\n buildWriteMarkerStatements,\n ensureLedgerTableStatement,\n ensureMarkerTableStatement,\n MARKER_TABLE_NAME,\n readMarkerStatement,\n type SqlStatement,\n} from './statement-builders';\n\nexport function createSqliteMigrationRunner(\n family: SqlControlFamilyInstance,\n): SqlMigrationRunner<SqlitePlanTargetDetails> {\n return new SqliteMigrationRunner(family);\n}\n\nclass SqliteMigrationRunner implements SqlMigrationRunner<SqlitePlanTargetDetails> {\n constructor(private readonly family: SqlControlFamilyInstance) {}\n\n async execute(\n options: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>,\n ): Promise<SqlMigrationRunnerResult> {\n const driver = options.driver;\n\n const destinationCheck = this.ensurePlanMatchesDestinationContract(\n options.plan.destination,\n options.destinationContract,\n );\n if (!destinationCheck.ok) {\n return destinationCheck;\n }\n\n const policyCheck = this.enforcePolicyCompatibility(options.policy, options.plan.operations);\n if (!policyCheck.ok) {\n return policyCheck;\n }\n\n // SQLite recreate-table drops and rebuilds the table. If foreign_keys is ON,\n // dropping a referenced parent cascade-deletes child rows; we must disable FK\n // enforcement for the duration of the migration and validate integrity before\n // committing. PRAGMA foreign_keys is a no-op inside a transaction, so toggle\n // around BEGIN/COMMIT.\n const fkWasEnabled = await this.readForeignKeysEnabled(driver);\n if (fkWasEnabled) {\n await driver.query('PRAGMA foreign_keys = OFF');\n }\n\n try {\n await this.beginExclusiveTransaction(driver);\n let committed = false;\n try {\n const ensureResult = await this.ensureControlTables(driver);\n if (!ensureResult.ok) {\n return ensureResult;\n }\n const existingMarker = await this.readMarker(driver, options.plan.spaceId);\n\n const markerCheck = this.ensureMarkerCompatibility(existingMarker, options.plan);\n if (!markerCheck.ok) {\n return markerCheck;\n }\n\n const markerAtDestination = this.markerMatchesDestination(existingMarker, options.plan);\n const isSelfEdge =\n options.plan.origin?.storageHash === options.plan.destination.storageHash;\n const skipOperations = markerAtDestination && options.plan.origin != null && !isSelfEdge;\n\n let operationsExecuted: number;\n let executedOperations: readonly SqlMigrationPlanOperation<SqlitePlanTargetDetails>[];\n\n if (skipOperations) {\n operationsExecuted = 0;\n executedOperations = [];\n } else {\n const applyResult = await this.applyPlan(driver, options);\n if (!applyResult.ok) {\n return applyResult;\n }\n operationsExecuted = applyResult.value.operationsExecuted;\n executedOperations = applyResult.value.executedOperations;\n }\n\n const schemaIR = await this.family.introspect({\n driver,\n contract: options.destinationContract,\n });\n\n const schemaVerifyResult = verifySqlSchema({\n contract: options.destinationContract,\n schema: schemaIR,\n strict: options.strictVerification ?? true,\n context: options.context ?? {},\n typeMetadataRegistry: this.family.typeMetadataRegistry,\n frameworkComponents: options.frameworkComponents,\n normalizeDefault: parseSqliteDefault,\n normalizeNativeType: normalizeSqliteNativeType,\n });\n if (!schemaVerifyResult.ok) {\n return runnerFailure('SCHEMA_VERIFY_FAILED', schemaVerifyResult.summary, {\n why: 'The resulting database schema does not satisfy the destination contract.',\n meta: {\n issues: schemaVerifyResult.schema.issues,\n },\n });\n }\n\n // Self-edge no-op detection: a self-edge migration whose ops had no\n // ops to begin with and brings no new invariants produced no\n // observable change. Skip the marker + ledger writes so an idempotent\n // re-apply of a self-edge data transform doesn't churn updatedAt or\n // pile up empty ledger entries. db update no-ops still write a\n // ledger entry as audit trail.\n const incomingInvariants = options.plan.providedInvariants;\n const existingInvariants = new Set(existingMarker?.invariants ?? []);\n const incomingIsSubsetOfExisting = incomingInvariants.every((id) =>\n existingInvariants.has(id),\n );\n const isSelfEdgeNoOp = isSelfEdge && operationsExecuted === 0 && incomingIsSubsetOfExisting;\n\n if (!isSelfEdgeNoOp) {\n await this.upsertMarker(driver, options, existingMarker);\n await this.recordLedgerEntry(driver, options, existingMarker, executedOperations);\n }\n\n if (fkWasEnabled) {\n const fkIntegrityCheck = await this.verifyForeignKeyIntegrity(driver);\n if (!fkIntegrityCheck.ok) {\n return fkIntegrityCheck;\n }\n }\n\n await this.commitTransaction(driver);\n committed = true;\n return runnerSuccess({\n operationsPlanned: options.plan.operations.length,\n operationsExecuted,\n });\n } finally {\n if (!committed) {\n await this.rollbackTransaction(driver);\n }\n }\n } finally {\n if (fkWasEnabled) {\n await driver.query('PRAGMA foreign_keys = ON');\n }\n }\n }\n\n private async readForeignKeysEnabled(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n ): Promise<boolean> {\n const result = await driver.query<{ foreign_keys: number }>('PRAGMA foreign_keys');\n const row = result.rows[0];\n return row?.foreign_keys === 1;\n }\n\n private async verifyForeignKeyIntegrity(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n ): Promise<Result<void, SqlMigrationRunnerFailure>> {\n const result = await driver.query<Record<string, unknown>>('PRAGMA foreign_key_check');\n if (result.rows.length === 0) {\n return okVoid();\n }\n return runnerFailure(\n 'FOREIGN_KEY_VIOLATION',\n `Foreign key integrity check failed after migration: ${result.rows.length} violation(s).`,\n {\n why: 'PRAGMA foreign_key_check reported violations after applying recreate-table operations.',\n meta: { violations: result.rows },\n },\n );\n }\n\n private async applyPlan(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n options: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>,\n ): Promise<\n Result<\n {\n readonly operationsExecuted: number;\n readonly executedOperations: readonly SqlMigrationPlanOperation<SqlitePlanTargetDetails>[];\n },\n SqlMigrationRunnerFailure\n >\n > {\n const checks = options.executionChecks;\n const runPrechecks = checks?.prechecks !== false;\n const runPostchecks = checks?.postchecks !== false;\n const runIdempotency = checks?.idempotencyChecks !== false;\n\n let operationsExecuted = 0;\n const executedOperations: Array<SqlMigrationPlanOperation<SqlitePlanTargetDetails>> = [];\n\n for (const operation of options.plan.operations) {\n options.callbacks?.onOperationStart?.(operation);\n try {\n if (runPostchecks && runIdempotency) {\n const postcheckAlreadySatisfied = await this.expectationsAreSatisfied(\n driver,\n operation.postcheck,\n );\n if (postcheckAlreadySatisfied) {\n executedOperations.push(this.createSkipRecord(operation));\n continue;\n }\n }\n\n if (runPrechecks) {\n const precheckResult = await this.runExpectationSteps(\n driver,\n operation.precheck,\n operation,\n 'precheck',\n );\n if (!precheckResult.ok) {\n return precheckResult;\n }\n }\n\n const executeResult = await this.runExecuteSteps(driver, operation.execute, operation);\n if (!executeResult.ok) {\n return executeResult;\n }\n\n if (runPostchecks) {\n const postcheckResult = await this.runExpectationSteps(\n driver,\n operation.postcheck,\n operation,\n 'postcheck',\n );\n if (!postcheckResult.ok) {\n return postcheckResult;\n }\n }\n\n executedOperations.push(operation);\n operationsExecuted += 1;\n } finally {\n options.callbacks?.onOperationComplete?.(operation);\n }\n }\n return ok({ operationsExecuted, executedOperations });\n }\n\n private async ensureControlTables(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n ): Promise<Result<void, SqlMigrationRunnerFailure>> {\n // Pre-1.0 zero-range guardrail: detect a pre-cleanup single-row\n // marker table (no `space` column) and surface a structured failure\n // rather than silently rebuilding the table into the per-space\n // shape. See `specs/framework-mechanism.spec.md § 2`.\n const legacyDetection = await this.detectLegacyMarkerShape(driver);\n if (!legacyDetection.ok) {\n return legacyDetection;\n }\n await this.executeStatement(driver, ensureMarkerTableStatement);\n await this.executeStatement(driver, ensureLedgerTableStatement);\n return okVoid();\n }\n\n private async detectLegacyMarkerShape(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n ): Promise<Result<void, SqlMigrationRunnerFailure>> {\n const tableInfo = await driver.query<{ name: string }>(\n `PRAGMA table_info(\"${MARKER_TABLE_NAME}\")`,\n );\n if (tableInfo.rows.length === 0) {\n return okVoid();\n }\n const columns = new Set(tableInfo.rows.map((row) => row.name));\n if (columns.has('space')) {\n return okVoid();\n }\n return runnerFailure(\n 'LEGACY_MARKER_SHAPE',\n `Legacy marker-table shape detected on ${MARKER_TABLE_NAME} (no \\`space\\` column). ` +\n 'Prisma Next is in pre-1.0; the previous transitional auto-migration to the per-space-row schema has been removed. ' +\n `Drop \\`${MARKER_TABLE_NAME}\\` and re-run \\`dbInit\\` to reinitialise from a clean baseline.`,\n {\n meta: {\n table: MARKER_TABLE_NAME,\n columns: [...columns].sort(),\n },\n },\n );\n }\n\n private async readMarker(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n space: string,\n ): Promise<ContractMarkerRecord | null> {\n const stmt = readMarkerStatement(space);\n try {\n const result = await driver.query<ContractMarkerRow>(stmt.sql, stmt.params);\n const row = result.rows[0];\n if (!row) return null;\n // SQLite stores arrays as JSON-encoded TEXT (no native array type), so\n // the driver returns `invariants` as a string. Decode before delegating\n // to the shared row schema, which expects `string[]`.\n const invariants =\n typeof row.invariants === 'string'\n ? (JSON.parse(row.invariants) as unknown)\n : row.invariants;\n return parseContractMarkerRow({ ...row, invariants });\n } catch (error) {\n // Table might not exist yet\n if (error instanceof Error && error.message.includes('no such table')) {\n return null;\n }\n throw error;\n }\n }\n\n private async runExpectationSteps(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n steps: readonly SqlMigrationPlanOperationStep[],\n operation: SqlMigrationPlanOperation<SqlitePlanTargetDetails>,\n phase: 'precheck' | 'postcheck',\n ): Promise<Result<void, SqlMigrationRunnerFailure>> {\n for (const step of steps) {\n const result = await driver.query(step.sql, step.params ?? []);\n if (!this.stepResultIsTrue(result.rows)) {\n const code = phase === 'precheck' ? 'PRECHECK_FAILED' : 'POSTCHECK_FAILED';\n return runnerFailure(\n code,\n `Operation ${operation.id} failed during ${phase}: ${step.description}`,\n {\n meta: {\n operationId: operation.id,\n phase,\n stepDescription: step.description,\n },\n },\n );\n }\n }\n return okVoid();\n }\n\n private async runExecuteSteps(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n steps: readonly SqlMigrationPlanOperationStep[],\n operation: SqlMigrationPlanOperation<SqlitePlanTargetDetails>,\n ): Promise<Result<void, SqlMigrationRunnerFailure>> {\n for (const step of steps) {\n try {\n await driver.query(step.sql, step.params ?? []);\n } catch (error: unknown) {\n const message = error instanceof Error ? error.message : String(error);\n return runnerFailure(\n 'EXECUTION_FAILED',\n `Operation ${operation.id} failed during execution: ${step.description}`,\n {\n why: message,\n meta: {\n operationId: operation.id,\n stepDescription: step.description,\n sql: step.sql,\n },\n },\n );\n }\n }\n return okVoid();\n }\n\n private stepResultIsTrue(rows: readonly Record<string, unknown>[]): boolean {\n if (!rows || rows.length === 0) {\n return false;\n }\n const firstRow = rows[0];\n const firstValue = firstRow ? Object.values(firstRow)[0] : undefined;\n if (typeof firstValue === 'number') {\n return firstValue !== 0;\n }\n if (typeof firstValue === 'boolean') {\n return firstValue;\n }\n if (typeof firstValue === 'string') {\n const lower = firstValue.toLowerCase();\n if (lower === 'true' || lower === '1') return true;\n if (lower === 'false' || lower === '0') return false;\n return firstValue.length > 0;\n }\n return Boolean(firstValue);\n }\n\n private async expectationsAreSatisfied(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n steps: readonly SqlMigrationPlanOperationStep[],\n ): Promise<boolean> {\n if (steps.length === 0) {\n return false;\n }\n for (const step of steps) {\n const result = await driver.query(step.sql, step.params ?? []);\n if (!this.stepResultIsTrue(result.rows)) {\n return false;\n }\n }\n return true;\n }\n\n private createSkipRecord(\n operation: SqlMigrationPlanOperation<SqlitePlanTargetDetails>,\n ): SqlMigrationPlanOperation<SqlitePlanTargetDetails> {\n return Object.freeze({\n id: operation.id,\n label: operation.label,\n ...ifDefined('summary', operation.summary),\n operationClass: operation.operationClass,\n target: operation.target,\n precheck: Object.freeze([]),\n execute: Object.freeze([]),\n postcheck: Object.freeze([...operation.postcheck]),\n meta: Object.freeze({\n ...(operation.meta ?? {}),\n runner: Object.freeze({ skipped: true, reason: 'postcheck_pre_satisfied' }),\n }),\n });\n }\n\n private markerMatchesDestination(\n marker: ContractMarkerRecord | null,\n plan: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['plan'],\n ): boolean {\n if (!marker) return false;\n if (marker.storageHash !== plan.destination.storageHash) return false;\n if (plan.destination.profileHash && marker.profileHash !== plan.destination.profileHash) {\n return false;\n }\n return true;\n }\n\n private enforcePolicyCompatibility(\n policy: MigrationOperationPolicy,\n operations: readonly SqlMigrationPlanOperation<SqlitePlanTargetDetails>[],\n ): Result<void, SqlMigrationRunnerFailure> {\n const allowedClasses = new Set(policy.allowedOperationClasses);\n for (const operation of operations) {\n if (!allowedClasses.has(operation.operationClass)) {\n return runnerFailure(\n 'POLICY_VIOLATION',\n `Operation ${operation.id} has class \"${operation.operationClass}\" which is not allowed by policy.`,\n {\n why: `Policy only allows: ${policy.allowedOperationClasses.join(', ')}.`,\n meta: {\n operationId: operation.id,\n operationClass: operation.operationClass,\n allowedClasses: policy.allowedOperationClasses,\n },\n },\n );\n }\n }\n return okVoid();\n }\n\n private ensureMarkerCompatibility(\n marker: ContractMarkerRecord | null,\n plan: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['plan'],\n ): Result<void, SqlMigrationRunnerFailure> {\n const origin = plan.origin ?? null;\n if (!origin) {\n return okVoid();\n }\n if (!marker) {\n return runnerFailure(\n 'MARKER_ORIGIN_MISMATCH',\n `Missing contract marker: expected origin storage hash ${origin.storageHash}.`,\n { meta: { expectedOriginStorageHash: origin.storageHash } },\n );\n }\n if (marker.storageHash !== origin.storageHash) {\n return runnerFailure(\n 'MARKER_ORIGIN_MISMATCH',\n `Existing contract marker (${marker.storageHash}) does not match plan origin (${origin.storageHash}).`,\n {\n meta: {\n markerStorageHash: marker.storageHash,\n expectedOriginStorageHash: origin.storageHash,\n },\n },\n );\n }\n if (origin.profileHash && marker.profileHash !== origin.profileHash) {\n return runnerFailure(\n 'MARKER_ORIGIN_MISMATCH',\n `Existing contract marker profile hash (${marker.profileHash}) does not match plan origin profile hash (${origin.profileHash}).`,\n {\n meta: {\n markerProfileHash: marker.profileHash,\n expectedOriginProfileHash: origin.profileHash,\n },\n },\n );\n }\n return okVoid();\n }\n\n private ensurePlanMatchesDestinationContract(\n destination: SqlMigrationPlanContractInfo,\n contract: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['destinationContract'],\n ): Result<void, SqlMigrationRunnerFailure> {\n if (destination.storageHash !== contract.storage.storageHash) {\n return runnerFailure(\n 'DESTINATION_CONTRACT_MISMATCH',\n `Plan destination storage hash (${destination.storageHash}) does not match provided contract storage hash (${contract.storage.storageHash}).`,\n {\n meta: {\n planStorageHash: destination.storageHash,\n contractStorageHash: contract.storage.storageHash,\n },\n },\n );\n }\n if (\n destination.profileHash &&\n contract.profileHash &&\n destination.profileHash !== contract.profileHash\n ) {\n return runnerFailure(\n 'DESTINATION_CONTRACT_MISMATCH',\n `Plan destination profile hash (${destination.profileHash}) does not match provided contract profile hash (${contract.profileHash}).`,\n {\n meta: {\n planProfileHash: destination.profileHash,\n contractProfileHash: contract.profileHash,\n },\n },\n );\n }\n return okVoid();\n }\n\n private async upsertMarker(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n options: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>,\n existingMarker: ContractMarkerRecord | null,\n ): Promise<void> {\n // SQLite has no native array type, so we can't merge invariants in SQL\n // the way Postgres does. Merge client-side under the runner's\n // BEGIN EXCLUSIVE — sort + dedupe so the JSON-encoded value is stable.\n const merged = new Set<string>(existingMarker?.invariants ?? []);\n for (const inv of options.plan.providedInvariants) merged.add(inv);\n const invariants = Array.from(merged).sort();\n const writeStatements = buildWriteMarkerStatements({\n space: options.plan.spaceId,\n storageHash: options.plan.destination.storageHash,\n profileHash:\n options.plan.destination.profileHash ??\n options.destinationContract.profileHash ??\n options.plan.destination.storageHash,\n contractJson: options.destinationContract,\n canonicalVersion: null,\n meta: {},\n invariants,\n });\n const statement = existingMarker ? writeStatements.update : writeStatements.insert;\n await this.executeStatement(driver, statement);\n }\n\n private async recordLedgerEntry(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n options: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>,\n existingMarker: ContractMarkerRecord | null,\n executedOperations: readonly SqlMigrationPlanOperation<SqlitePlanTargetDetails>[],\n ): Promise<void> {\n const ledgerStatement = buildLedgerInsertStatement({\n originStorageHash: existingMarker?.storageHash ?? null,\n originProfileHash: existingMarker?.profileHash ?? null,\n destinationStorageHash: options.plan.destination.storageHash,\n destinationProfileHash:\n options.plan.destination.profileHash ??\n options.destinationContract.profileHash ??\n options.plan.destination.storageHash,\n contractJsonBefore: existingMarker?.contractJson ?? null,\n contractJsonAfter: options.destinationContract,\n operations: executedOperations,\n });\n await this.executeStatement(driver, ledgerStatement);\n }\n\n private async beginExclusiveTransaction(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n ): Promise<void> {\n await driver.query('BEGIN EXCLUSIVE');\n }\n\n private async commitTransaction(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n ): Promise<void> {\n await driver.query('COMMIT');\n }\n\n private async rollbackTransaction(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n ): Promise<void> {\n await driver.query('ROLLBACK');\n }\n\n private async executeStatement(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n statement: SqlStatement,\n ): Promise<void> {\n if (statement.params.length > 0) {\n await driver.query(statement.sql, statement.params);\n return;\n }\n await driver.query(statement.sql);\n }\n}\n","import type { ColumnDefault, Contract } from '@prisma-next/contract/types';\nimport type {\n SqlControlFamilyInstance,\n SqlControlTargetDescriptor,\n} from '@prisma-next/family-sql/control';\nimport { contractToSchemaIR } from '@prisma-next/family-sql/control';\nimport type {\n ControlTargetInstance,\n MigrationPlanner,\n MigrationRunner,\n} from '@prisma-next/framework-components/control';\nimport type { SqlStorage, StorageColumn } from '@prisma-next/sql-contract/types';\nimport { sqliteTargetDescriptorMeta } from './descriptor-meta';\nimport { createSqliteMigrationPlanner } from './migrations/planner';\nimport { renderDefaultLiteral } from './migrations/planner-ddl-builders';\nimport type { SqlitePlanTargetDetails } from './migrations/planner-target-details';\nimport { createSqliteMigrationRunner } from './migrations/runner';\n\nfunction sqliteRenderDefault(def: ColumnDefault, _column: StorageColumn): string {\n if (def.kind === 'function') {\n if (def.expression === 'now()') {\n return \"datetime('now')\";\n }\n return def.expression;\n }\n return renderDefaultLiteral(def.value);\n}\n\nconst sqliteControlTargetDescriptor: SqlControlTargetDescriptor<'sqlite', SqlitePlanTargetDetails> =\n {\n ...sqliteTargetDescriptorMeta,\n migrations: {\n createPlanner(_family: SqlControlFamilyInstance): MigrationPlanner<'sql', 'sqlite'> {\n return createSqliteMigrationPlanner();\n },\n createRunner(family) {\n return createSqliteMigrationRunner(family) as MigrationRunner<'sql', 'sqlite'>;\n },\n contractToSchema(contract, frameworkComponents) {\n return contractToSchemaIR(contract as Contract<SqlStorage> | null, {\n annotationNamespace: 'sqlite',\n renderDefault: sqliteRenderDefault,\n frameworkComponents: frameworkComponents ?? [],\n });\n },\n },\n create(): ControlTargetInstance<'sql', 'sqlite'> {\n return {\n familyId: 'sql',\n targetId: 'sqlite',\n };\n },\n createPlanner(_family: SqlControlFamilyInstance) {\n return createSqliteMigrationPlanner();\n },\n createRunner(family) {\n return createSqliteMigrationRunner(family);\n },\n };\n\nexport default sqliteControlTargetDescriptor;\n"],"mappings":";;;;;;;;;;;;AA+BA,SAAgB,4BACd,QAC6C;CAC7C,OAAO,IAAI,sBAAsB,OAAO;;AAG1C,IAAM,wBAAN,MAAmF;CACpD;CAA7B,YAAY,QAAmD;EAAlC,KAAA,SAAA;;CAE7B,MAAM,QACJ,SACmC;EACnC,MAAM,SAAS,QAAQ;EAEvB,MAAM,mBAAmB,KAAK,qCAC5B,QAAQ,KAAK,aACb,QAAQ,oBACT;EACD,IAAI,CAAC,iBAAiB,IACpB,OAAO;EAGT,MAAM,cAAc,KAAK,2BAA2B,QAAQ,QAAQ,QAAQ,KAAK,WAAW;EAC5F,IAAI,CAAC,YAAY,IAC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;;CAGhC,MAAc,iBACZ,QACA,WACe;EACf,IAAI,UAAU,OAAO,SAAS,GAAG;GAC/B,MAAM,OAAO,MAAM,UAAU,KAAK,UAAU,OAAO;GACnD;;EAEF,MAAM,OAAO,MAAM,UAAU,IAAI;;;;;ACtmBrC,SAAS,oBAAoB,KAAoB,SAAgC;CAC/E,IAAI,IAAI,SAAS,YAAY;EAC3B,IAAI,IAAI,eAAe,SACrB,OAAO;EAET,OAAO,IAAI;;CAEb,OAAO,qBAAqB,IAAI,MAAM;;AAGxC,MAAM,gCACJ;CACE,GAAG;CACH,YAAY;EACV,cAAc,SAAsE;GAClF,OAAO,8BAA8B;;EAEvC,aAAa,QAAQ;GACnB,OAAO,4BAA4B,OAAO;;EAE5C,iBAAiB,UAAU,qBAAqB;GAC9C,OAAO,mBAAmB,UAAyC;IACjE,qBAAqB;IACrB,eAAe;IACf,qBAAqB,uBAAuB,EAAE;IAC/C,CAAC;;EAEL;CACD,SAAiD;EAC/C,OAAO;GACL,UAAU;GACV,UAAU;GACX;;CAEH,cAAc,SAAmC;EAC/C,OAAO,8BAA8B;;CAEvC,aAAa,QAAQ;EACnB,OAAO,4BAA4B,OAAO;;CAE7C"}
@@ -63,7 +63,7 @@ function parseSqliteDefault(rawDefault, nativeType) {
63
63
  expression: trimmed
64
64
  };
65
65
  }
66
-
67
66
  //#endregion
68
67
  export { stripOuterParens as n, parseSqliteDefault as t };
69
- //# sourceMappingURL=default-normalizer-R-sQXAYt.mjs.map
68
+
69
+ //# sourceMappingURL=default-normalizer-3Fccw7yw.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"default-normalizer-R-sQXAYt.mjs","names":[],"sources":["../src/core/default-normalizer.ts"],"sourcesContent":["/**\n * Normalizes SQLite's stored default expressions back into the\n * `ColumnDefault` shape the verifier compares against. Lives target-side\n * (mirroring Postgres's `target-postgres/src/core/default-normalizer.ts`)\n * so both the control adapter (`SqliteControlAdapter.introspect`) and the\n * planner / runner schema-verify path can consume it without\n * `target-sqlite` reaching into `adapter-sqlite`.\n */\n\nimport type { ColumnDefault } from '@prisma-next/contract/types';\n\nconst NULL_PATTERN = /^NULL$/i;\nconst INTEGER_PATTERN = /^-?\\d+$/;\nconst REAL_PATTERN = /^-?\\d+\\.\\d+(?:[eE][+-]?\\d+)?$/;\nconst HEX_PATTERN = /^0[xX][\\dA-Fa-f]+$/;\nconst STRING_LITERAL_PATTERN = /^'((?:[^']|'')*)'$/;\n\nfunction isNumericLiteral(value: string): boolean {\n return INTEGER_PATTERN.test(value) || REAL_PATTERN.test(value) || HEX_PATTERN.test(value);\n}\n\n/**\n * Strips a single matched wrapping pair of outer parens from `s`. Conservative:\n * only strips when the leading `(` is matched by the trailing `)` (so\n * `(a) + (b)` is returned unchanged). Mirrors SQLite's own\n * `pragma_table_info.dflt_value` normalization for expression defaults, and\n * is shared with the recreate-table postcheck builder so both sides agree\n * on the canonical form.\n */\nexport function stripOuterParens(s: string): string {\n if (!s.startsWith('(') || !s.endsWith(')')) return s;\n let depth = 0;\n for (let i = 0; i < s.length; i++) {\n if (s[i] === '(') depth += 1;\n else if (s[i] === ')') {\n depth -= 1;\n if (depth === 0 && i < s.length - 1) return s;\n }\n }\n return s.slice(1, -1);\n}\n\nexport function parseSqliteDefault(\n rawDefault: string,\n nativeType?: string,\n): ColumnDefault | undefined {\n let trimmed = rawDefault.trim();\n\n // Strip outer parentheses that SQLite adds around expressions. Iterate to\n // fixpoint so accidental double-wrapping (e.g. `((expr))`) collapses too.\n while (true) {\n const stripped = stripOuterParens(trimmed).trim();\n if (stripped === trimmed) break;\n trimmed = stripped;\n }\n\n // SQLite has several spellings for \"current timestamp\" — `CURRENT_TIMESTAMP`\n // (keyword) and `datetime('now')` / `datetime(\"now\")` (function call). The\n // contract authoring side canonicalizes `dbgenerated(\"CURRENT_TIMESTAMP\")`\n // (and friends) to `now()` via `lowerDbgenerated`; mirror that here so a\n // schema produced by either spelling round-trips to the same canonical\n // form for verification.\n const lower = trimmed.toLowerCase();\n if (lower === 'current_timestamp' || lower === \"datetime('now')\" || lower === 'datetime(\"now\")') {\n return { kind: 'function', expression: 'now()' };\n }\n\n if (NULL_PATTERN.test(trimmed)) {\n return { kind: 'literal', value: null };\n }\n\n // SQLite integers are 64-bit, so values outside the JS safe-integer range can't\n // be faithfully represented as `number`. Mirror `parsePostgresDefault`'s bigint\n // handling: parse as JS `number` when safe, fall back to the raw text otherwise.\n if (isNumericLiteral(trimmed)) {\n const num = Number(trimmed);\n if (!Number.isFinite(num)) return undefined;\n if (nativeType?.toLowerCase() === 'integer' && !Number.isSafeInteger(num)) {\n return { kind: 'literal', value: trimmed };\n }\n return { kind: 'literal', value: num };\n }\n\n const stringMatch = trimmed.match(STRING_LITERAL_PATTERN);\n if (stringMatch?.[1] !== undefined) {\n const unescaped = stringMatch[1].replace(/''/g, \"'\");\n return { kind: 'literal', value: unescaped };\n }\n\n // Unrecognized expression — preserve as function\n return { kind: 'function', expression: trimmed };\n}\n"],"mappings":";AAWA,MAAM,eAAe;AACrB,MAAM,kBAAkB;AACxB,MAAM,eAAe;AACrB,MAAM,cAAc;AACpB,MAAM,yBAAyB;AAE/B,SAAS,iBAAiB,OAAwB;AAChD,QAAO,gBAAgB,KAAK,MAAM,IAAI,aAAa,KAAK,MAAM,IAAI,YAAY,KAAK,MAAM;;;;;;;;;;AAW3F,SAAgB,iBAAiB,GAAmB;AAClD,KAAI,CAAC,EAAE,WAAW,IAAI,IAAI,CAAC,EAAE,SAAS,IAAI,CAAE,QAAO;CACnD,IAAI,QAAQ;AACZ,MAAK,IAAI,IAAI,GAAG,IAAI,EAAE,QAAQ,IAC5B,KAAI,EAAE,OAAO,IAAK,UAAS;UAClB,EAAE,OAAO,KAAK;AACrB,WAAS;AACT,MAAI,UAAU,KAAK,IAAI,EAAE,SAAS,EAAG,QAAO;;AAGhD,QAAO,EAAE,MAAM,GAAG,GAAG;;AAGvB,SAAgB,mBACd,YACA,YAC2B;CAC3B,IAAI,UAAU,WAAW,MAAM;AAI/B,QAAO,MAAM;EACX,MAAM,WAAW,iBAAiB,QAAQ,CAAC,MAAM;AACjD,MAAI,aAAa,QAAS;AAC1B,YAAU;;CASZ,MAAM,QAAQ,QAAQ,aAAa;AACnC,KAAI,UAAU,uBAAuB,UAAU,qBAAqB,UAAU,oBAC5E,QAAO;EAAE,MAAM;EAAY,YAAY;EAAS;AAGlD,KAAI,aAAa,KAAK,QAAQ,CAC5B,QAAO;EAAE,MAAM;EAAW,OAAO;EAAM;AAMzC,KAAI,iBAAiB,QAAQ,EAAE;EAC7B,MAAM,MAAM,OAAO,QAAQ;AAC3B,MAAI,CAAC,OAAO,SAAS,IAAI,CAAE,QAAO;AAClC,MAAI,YAAY,aAAa,KAAK,aAAa,CAAC,OAAO,cAAc,IAAI,CACvE,QAAO;GAAE,MAAM;GAAW,OAAO;GAAS;AAE5C,SAAO;GAAE,MAAM;GAAW,OAAO;GAAK;;CAGxC,MAAM,cAAc,QAAQ,MAAM,uBAAuB;AACzD,KAAI,cAAc,OAAO,OAEvB,QAAO;EAAE,MAAM;EAAW,OADR,YAAY,GAAG,QAAQ,OAAO,IAAI;EACR;AAI9C,QAAO;EAAE,MAAM;EAAY,YAAY;EAAS"}
1
+ {"version":3,"file":"default-normalizer-3Fccw7yw.mjs","names":[],"sources":["../src/core/default-normalizer.ts"],"sourcesContent":["/**\n * Normalizes SQLite's stored default expressions back into the\n * `ColumnDefault` shape the verifier compares against. Lives target-side\n * (mirroring Postgres's `target-postgres/src/core/default-normalizer.ts`)\n * so both the control adapter (`SqliteControlAdapter.introspect`) and the\n * planner / runner schema-verify path can consume it without\n * `target-sqlite` reaching into `adapter-sqlite`.\n */\n\nimport type { ColumnDefault } from '@prisma-next/contract/types';\n\nconst NULL_PATTERN = /^NULL$/i;\nconst INTEGER_PATTERN = /^-?\\d+$/;\nconst REAL_PATTERN = /^-?\\d+\\.\\d+(?:[eE][+-]?\\d+)?$/;\nconst HEX_PATTERN = /^0[xX][\\dA-Fa-f]+$/;\nconst STRING_LITERAL_PATTERN = /^'((?:[^']|'')*)'$/;\n\nfunction isNumericLiteral(value: string): boolean {\n return INTEGER_PATTERN.test(value) || REAL_PATTERN.test(value) || HEX_PATTERN.test(value);\n}\n\n/**\n * Strips a single matched wrapping pair of outer parens from `s`. Conservative:\n * only strips when the leading `(` is matched by the trailing `)` (so\n * `(a) + (b)` is returned unchanged). Mirrors SQLite's own\n * `pragma_table_info.dflt_value` normalization for expression defaults, and\n * is shared with the recreate-table postcheck builder so both sides agree\n * on the canonical form.\n */\nexport function stripOuterParens(s: string): string {\n if (!s.startsWith('(') || !s.endsWith(')')) return s;\n let depth = 0;\n for (let i = 0; i < s.length; i++) {\n if (s[i] === '(') depth += 1;\n else if (s[i] === ')') {\n depth -= 1;\n if (depth === 0 && i < s.length - 1) return s;\n }\n }\n return s.slice(1, -1);\n}\n\nexport function parseSqliteDefault(\n rawDefault: string,\n nativeType?: string,\n): ColumnDefault | undefined {\n let trimmed = rawDefault.trim();\n\n // Strip outer parentheses that SQLite adds around expressions. Iterate to\n // fixpoint so accidental double-wrapping (e.g. `((expr))`) collapses too.\n while (true) {\n const stripped = stripOuterParens(trimmed).trim();\n if (stripped === trimmed) break;\n trimmed = stripped;\n }\n\n // SQLite has several spellings for \"current timestamp\" — `CURRENT_TIMESTAMP`\n // (keyword) and `datetime('now')` / `datetime(\"now\")` (function call). The\n // contract authoring side canonicalizes `dbgenerated(\"CURRENT_TIMESTAMP\")`\n // (and friends) to `now()` via `lowerDbgenerated`; mirror that here so a\n // schema produced by either spelling round-trips to the same canonical\n // form for verification.\n const lower = trimmed.toLowerCase();\n if (lower === 'current_timestamp' || lower === \"datetime('now')\" || lower === 'datetime(\"now\")') {\n return { kind: 'function', expression: 'now()' };\n }\n\n if (NULL_PATTERN.test(trimmed)) {\n return { kind: 'literal', value: null };\n }\n\n // SQLite integers are 64-bit, so values outside the JS safe-integer range can't\n // be faithfully represented as `number`. Mirror `parsePostgresDefault`'s bigint\n // handling: parse as JS `number` when safe, fall back to the raw text otherwise.\n if (isNumericLiteral(trimmed)) {\n const num = Number(trimmed);\n if (!Number.isFinite(num)) return undefined;\n if (nativeType?.toLowerCase() === 'integer' && !Number.isSafeInteger(num)) {\n return { kind: 'literal', value: trimmed };\n }\n return { kind: 'literal', value: num };\n }\n\n const stringMatch = trimmed.match(STRING_LITERAL_PATTERN);\n if (stringMatch?.[1] !== undefined) {\n const unescaped = stringMatch[1].replace(/''/g, \"'\");\n return { kind: 'literal', value: unescaped };\n }\n\n // Unrecognized expression — preserve as function\n return { kind: 'function', expression: trimmed };\n}\n"],"mappings":";AAWA,MAAM,eAAe;AACrB,MAAM,kBAAkB;AACxB,MAAM,eAAe;AACrB,MAAM,cAAc;AACpB,MAAM,yBAAyB;AAE/B,SAAS,iBAAiB,OAAwB;CAChD,OAAO,gBAAgB,KAAK,MAAM,IAAI,aAAa,KAAK,MAAM,IAAI,YAAY,KAAK,MAAM;;;;;;;;;;AAW3F,SAAgB,iBAAiB,GAAmB;CAClD,IAAI,CAAC,EAAE,WAAW,IAAI,IAAI,CAAC,EAAE,SAAS,IAAI,EAAE,OAAO;CACnD,IAAI,QAAQ;CACZ,KAAK,IAAI,IAAI,GAAG,IAAI,EAAE,QAAQ,KAC5B,IAAI,EAAE,OAAO,KAAK,SAAS;MACtB,IAAI,EAAE,OAAO,KAAK;EACrB,SAAS;EACT,IAAI,UAAU,KAAK,IAAI,EAAE,SAAS,GAAG,OAAO;;CAGhD,OAAO,EAAE,MAAM,GAAG,GAAG;;AAGvB,SAAgB,mBACd,YACA,YAC2B;CAC3B,IAAI,UAAU,WAAW,MAAM;CAI/B,OAAO,MAAM;EACX,MAAM,WAAW,iBAAiB,QAAQ,CAAC,MAAM;EACjD,IAAI,aAAa,SAAS;EAC1B,UAAU;;CASZ,MAAM,QAAQ,QAAQ,aAAa;CACnC,IAAI,UAAU,uBAAuB,UAAU,qBAAqB,UAAU,qBAC5E,OAAO;EAAE,MAAM;EAAY,YAAY;EAAS;CAGlD,IAAI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