@prisma-next/target-postgres 0.5.0-dev.9 → 0.5.0

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 (184) hide show
  1. package/dist/{codec-ids-CojIXVf9.mjs → codec-ids-C5qzBqus.mjs} +4 -4
  2. package/dist/{codec-ids-CojIXVf9.mjs.map → codec-ids-C5qzBqus.mjs.map} +1 -1
  3. package/dist/codec-ids-CplrEfmx.d.mts +29 -0
  4. package/dist/codec-ids-CplrEfmx.d.mts.map +1 -0
  5. package/dist/codec-ids.d.mts +2 -28
  6. package/dist/codec-ids.mjs +2 -3
  7. package/dist/codec-types-lrsb3N07.d.mts +79 -0
  8. package/dist/codec-types-lrsb3N07.d.mts.map +1 -0
  9. package/dist/codec-types.d.mts +2 -42
  10. package/dist/codec-types.mjs +1 -3
  11. package/dist/codecs-Cue97Xqf.d.mts +558 -0
  12. package/dist/codecs-Cue97Xqf.d.mts.map +1 -0
  13. package/dist/codecs.d.mts +13 -2
  14. package/dist/codecs.d.mts.map +1 -0
  15. package/dist/codecs.mjs +738 -2
  16. package/dist/codecs.mjs.map +1 -0
  17. package/dist/control.d.mts +1 -1
  18. package/dist/control.d.mts.map +1 -1
  19. package/dist/control.mjs +131 -94
  20. package/dist/control.mjs.map +1 -1
  21. package/dist/{data-transform-VfEGzXWt.mjs → data-transform-DKWXdHuZ.mjs} +25 -7
  22. package/dist/data-transform-DKWXdHuZ.mjs.map +1 -0
  23. package/dist/data-transform-bIeAcZIJ.d.mts +38 -0
  24. package/dist/data-transform-bIeAcZIJ.d.mts.map +1 -0
  25. package/dist/data-transform.d.mts +1 -1
  26. package/dist/data-transform.mjs +2 -3
  27. package/dist/{default-normalizer-DNOpRoOF.mjs → default-normalizer-C8XyZj85.mjs} +2 -2
  28. package/dist/{default-normalizer-DNOpRoOF.mjs.map → default-normalizer-C8XyZj85.mjs.map} +1 -1
  29. package/dist/default-normalizer.d.mts +0 -1
  30. package/dist/default-normalizer.d.mts.map +1 -1
  31. package/dist/default-normalizer.mjs +2 -3
  32. package/dist/descriptor-meta-Dde_BS3K.mjs +99 -0
  33. package/dist/descriptor-meta-Dde_BS3K.mjs.map +1 -0
  34. package/dist/{errors-AFvEPZ1R.mjs → errors-Chm2bKcS.mjs} +2 -3
  35. package/dist/{errors-AFvEPZ1R.mjs.map → errors-Chm2bKcS.mjs.map} +1 -1
  36. package/dist/errors.d.mts +0 -1
  37. package/dist/errors.d.mts.map +1 -1
  38. package/dist/errors.mjs +2 -3
  39. package/dist/{issue-planner-CFjB0_oO.mjs → issue-planner-CiNmA4ls.mjs} +20 -16
  40. package/dist/issue-planner-CiNmA4ls.mjs.map +1 -0
  41. package/dist/issue-planner.d.mts +2 -4
  42. package/dist/issue-planner.d.mts.map +1 -1
  43. package/dist/issue-planner.mjs +2 -3
  44. package/dist/migration.d.mts +8 -4
  45. package/dist/migration.d.mts.map +1 -1
  46. package/dist/migration.mjs +4 -5
  47. package/dist/migration.mjs.map +1 -1
  48. package/dist/{native-type-normalizer-CInai_oY.mjs → native-type-normalizer-Cry4QoLf.mjs} +2 -2
  49. package/dist/native-type-normalizer-Cry4QoLf.mjs.map +1 -0
  50. package/dist/native-type-normalizer.d.mts.map +1 -1
  51. package/dist/native-type-normalizer.mjs +2 -3
  52. package/dist/{op-factory-call-C3bWXKSP.d.mts → op-factory-call-BUhxZuUA.d.mts} +9 -5
  53. package/dist/op-factory-call-BUhxZuUA.d.mts.map +1 -0
  54. package/dist/{op-factory-call-BKlruaiC.mjs → op-factory-call-Bs3HWhvG.mjs} +25 -7
  55. package/dist/op-factory-call-Bs3HWhvG.mjs.map +1 -0
  56. package/dist/op-factory-call.d.mts +1 -2
  57. package/dist/op-factory-call.mjs +2 -3
  58. package/dist/pack.d.mts +28 -9
  59. package/dist/pack.d.mts.map +1 -1
  60. package/dist/pack.mjs +2 -3
  61. package/dist/{planner-CLUvVhUN.mjs → planner-Lhacw3uU.mjs} +22 -16
  62. package/dist/planner-Lhacw3uU.mjs.map +1 -0
  63. package/dist/{planner-ddl-builders-Dxvw1LHw.mjs → planner-ddl-builders-CLB7Umhh.mjs} +4 -5
  64. package/dist/planner-ddl-builders-CLB7Umhh.mjs.map +1 -0
  65. package/dist/planner-ddl-builders.d.mts +1 -1
  66. package/dist/planner-ddl-builders.d.mts.map +1 -1
  67. package/dist/planner-ddl-builders.mjs +2 -3
  68. package/dist/{planner-identity-values-Dju-o5GF.mjs → planner-identity-values-DTx0gePL.mjs} +2 -3
  69. package/dist/{planner-identity-values-Dju-o5GF.mjs.map → planner-identity-values-DTx0gePL.mjs.map} +1 -1
  70. package/dist/planner-identity-values.d.mts +0 -1
  71. package/dist/planner-identity-values.d.mts.map +1 -1
  72. package/dist/planner-identity-values.mjs +2 -3
  73. package/dist/{planner-produced-postgres-migration-CRRTno6Z.d.mts → planner-produced-postgres-migration-CjxWIVgh.d.mts} +11 -7
  74. package/dist/planner-produced-postgres-migration-CjxWIVgh.d.mts.map +1 -0
  75. package/dist/{planner-produced-postgres-migration-DSSPq8QS.mjs → planner-produced-postgres-migration-DphktB2N.mjs} +16 -8
  76. package/dist/planner-produced-postgres-migration-DphktB2N.mjs.map +1 -0
  77. package/dist/planner-produced-postgres-migration.d.mts +1 -4
  78. package/dist/planner-produced-postgres-migration.mjs +2 -3
  79. package/dist/{planner-schema-lookup-B7lkypwn.mjs → planner-schema-lookup-B1ags8ys.mjs} +2 -2
  80. package/dist/{planner-schema-lookup-B7lkypwn.mjs.map → planner-schema-lookup-B1ags8ys.mjs.map} +1 -1
  81. package/dist/planner-schema-lookup.d.mts +0 -1
  82. package/dist/planner-schema-lookup.d.mts.map +1 -1
  83. package/dist/planner-schema-lookup.mjs +2 -3
  84. package/dist/{planner-sql-checks-7jkgm9TX.mjs → planner-sql-checks-DwZvGlV4.mjs} +3 -5
  85. package/dist/planner-sql-checks-DwZvGlV4.mjs.map +1 -0
  86. package/dist/planner-sql-checks.d.mts.map +1 -1
  87. package/dist/planner-sql-checks.mjs +2 -3
  88. package/dist/{planner-target-details-DH-azLu-.d.mts → planner-target-details-bVVcanWh.d.mts} +1 -1
  89. package/dist/planner-target-details-bVVcanWh.d.mts.map +1 -0
  90. package/dist/planner-target-details.d.mts +1 -1
  91. package/dist/planner-target-details.mjs +1 -1
  92. package/dist/planner.d.mts +21 -12
  93. package/dist/planner.d.mts.map +1 -1
  94. package/dist/planner.mjs +2 -4
  95. package/dist/{postgres-migration-qtmtbONe.mjs → postgres-migration-Bkv140RW.mjs} +4 -5
  96. package/dist/postgres-migration-Bkv140RW.mjs.map +1 -0
  97. package/dist/{postgres-migration-BjA3Zmts.d.mts → postgres-migration-UkcHfZAA.d.mts} +6 -6
  98. package/dist/postgres-migration-UkcHfZAA.d.mts.map +1 -0
  99. package/dist/render-ops--1nnfNus.mjs +23 -0
  100. package/dist/render-ops--1nnfNus.mjs.map +1 -0
  101. package/dist/render-ops.d.mts +3 -4
  102. package/dist/render-ops.d.mts.map +1 -1
  103. package/dist/render-ops.mjs +2 -3
  104. package/dist/{render-typescript-1rF_SB4g.mjs → render-typescript-D3doH-vX.mjs} +2 -14
  105. package/dist/render-typescript-D3doH-vX.mjs.map +1 -0
  106. package/dist/render-typescript.d.mts +3 -6
  107. package/dist/render-typescript.d.mts.map +1 -1
  108. package/dist/render-typescript.mjs +2 -3
  109. package/dist/runtime.d.mts +5 -9
  110. package/dist/runtime.d.mts.map +1 -1
  111. package/dist/runtime.mjs +7 -14
  112. package/dist/runtime.mjs.map +1 -1
  113. package/dist/{shared-Bxkt8pNO.d.mts → shared-MpwjwAjM.d.mts} +2 -2
  114. package/dist/shared-MpwjwAjM.d.mts.map +1 -0
  115. package/dist/{sql-utils-r-Lw535w.mjs → sql-utils-CggjWNij.mjs} +4 -2
  116. package/dist/sql-utils-CggjWNij.mjs.map +1 -0
  117. package/dist/sql-utils.d.mts.map +1 -1
  118. package/dist/sql-utils.mjs +2 -3
  119. package/dist/{statement-builders-BPnmt6wx.mjs → statement-builders-BT889jV0.mjs} +28 -13
  120. package/dist/statement-builders-BT889jV0.mjs.map +1 -0
  121. package/dist/statement-builders.d.mts +31 -3
  122. package/dist/statement-builders.d.mts.map +1 -1
  123. package/dist/statement-builders.mjs +2 -3
  124. package/dist/{tables-BmdW_FWO.mjs → tables-r9Zk1y-Y.mjs} +18 -13
  125. package/dist/tables-r9Zk1y-Y.mjs.map +1 -0
  126. package/dist/{types-ClK03Ojd.d.mts → types-CTqpysRY.d.mts} +1 -1
  127. package/dist/types-CTqpysRY.d.mts.map +1 -0
  128. package/dist/types.d.mts +1 -1
  129. package/dist/types.mjs +1 -1
  130. package/package.json +21 -19
  131. package/src/core/authoring.ts +5 -11
  132. package/src/core/codec-helpers.ts +135 -0
  133. package/src/core/codec-ids.ts +1 -0
  134. package/src/core/codec-type-map.ts +81 -0
  135. package/src/core/codecs.ts +941 -547
  136. package/src/core/descriptor-meta.ts +1 -1
  137. package/src/core/migrations/issue-planner.ts +15 -3
  138. package/src/core/migrations/op-factory-call.ts +24 -2
  139. package/src/core/migrations/operations/data-transform.ts +86 -21
  140. package/src/core/migrations/operations/indexes.ts +27 -2
  141. package/src/core/migrations/planner-produced-postgres-migration.ts +17 -5
  142. package/src/core/migrations/planner.ts +62 -20
  143. package/src/core/migrations/postgres-migration.ts +3 -6
  144. package/src/core/migrations/render-ops.ts +26 -3
  145. package/src/core/migrations/render-typescript.ts +5 -9
  146. package/src/core/migrations/runner.ts +172 -151
  147. package/src/core/migrations/statement-builders.ts +49 -10
  148. package/src/core/registry.ts +11 -0
  149. package/src/exports/codec-types.ts +4 -13
  150. package/src/exports/codecs.ts +49 -2
  151. package/src/exports/runtime.ts +6 -11
  152. package/src/exports/statement-builders.ts +2 -1
  153. package/dist/codec-ids.d.mts.map +0 -1
  154. package/dist/codec-types.d.mts.map +0 -1
  155. package/dist/codecs-BQEm9_oo.d.mts +0 -319
  156. package/dist/codecs-BQEm9_oo.d.mts.map +0 -1
  157. package/dist/codecs-BoahtY_Q.mjs +0 -385
  158. package/dist/codecs-BoahtY_Q.mjs.map +0 -1
  159. package/dist/data-transform-CxFRBIUp.d.mts +0 -32
  160. package/dist/data-transform-CxFRBIUp.d.mts.map +0 -1
  161. package/dist/data-transform-VfEGzXWt.mjs.map +0 -1
  162. package/dist/descriptor-meta-BVoVtyp-.mjs +0 -120
  163. package/dist/descriptor-meta-BVoVtyp-.mjs.map +0 -1
  164. package/dist/issue-planner-CFjB0_oO.mjs.map +0 -1
  165. package/dist/native-type-normalizer-CInai_oY.mjs.map +0 -1
  166. package/dist/op-factory-call-BKlruaiC.mjs.map +0 -1
  167. package/dist/op-factory-call-C3bWXKSP.d.mts.map +0 -1
  168. package/dist/planner-CLUvVhUN.mjs.map +0 -1
  169. package/dist/planner-ddl-builders-Dxvw1LHw.mjs.map +0 -1
  170. package/dist/planner-produced-postgres-migration-CRRTno6Z.d.mts.map +0 -1
  171. package/dist/planner-produced-postgres-migration-DSSPq8QS.mjs.map +0 -1
  172. package/dist/planner-sql-checks-7jkgm9TX.mjs.map +0 -1
  173. package/dist/planner-target-details-DH-azLu-.d.mts.map +0 -1
  174. package/dist/postgres-migration-BjA3Zmts.d.mts.map +0 -1
  175. package/dist/postgres-migration-qtmtbONe.mjs.map +0 -1
  176. package/dist/render-ops-D6_DHdOK.mjs +0 -8
  177. package/dist/render-ops-D6_DHdOK.mjs.map +0 -1
  178. package/dist/render-typescript-1rF_SB4g.mjs.map +0 -1
  179. package/dist/shared-Bxkt8pNO.d.mts.map +0 -1
  180. package/dist/sql-utils-r-Lw535w.mjs.map +0 -1
  181. package/dist/statement-builders-BPnmt6wx.mjs.map +0 -1
  182. package/dist/tables-BmdW_FWO.mjs.map +0 -1
  183. package/dist/types-ClK03Ojd.d.mts.map +0 -1
  184. package/src/core/json-schema-type-expression.ts +0 -131
@@ -1,5 +1,4 @@
1
- import { i as quoteIdentifier, n as escapeLiteral } from "./sql-utils-r-Lw535w.mjs";
2
-
1
+ import { i as quoteIdentifier, n as escapeLiteral } from "./sql-utils-CggjWNij.mjs";
3
2
  //#region src/core/migrations/planner-type-resolution.ts
4
3
  function resolveColumnTypeMetadata(column, storageTypes) {
5
4
  if (!column.typeRef) return column;
@@ -11,7 +10,6 @@ function resolveColumnTypeMetadata(column, storageTypes) {
11
10
  typeParams: referencedType.typeParams
12
11
  };
13
12
  }
14
-
15
13
  //#endregion
16
14
  //#region src/core/migrations/planner-sql-checks.ts
17
15
  function qualifyTableName(schema, table) {
@@ -235,7 +233,7 @@ function tableHasPrimaryKeyCheck(schema, table, exists, constraintName) {
235
233
  ${constraintFilter}
236
234
  )`;
237
235
  }
238
-
239
236
  //#endregion
240
237
  export { columnNullabilityCheck as a, qualifyTableName as c, toRegclassLiteral as d, resolveColumnTypeMetadata as f, columnHasNoDefaultCheck as i, tableHasPrimaryKeyCheck as l, columnDefaultExistsCheck as n, columnTypeCheck as o, columnExistsCheck as r, constraintExistsCheck as s, buildExpectedFormatType as t, tableIsEmptyCheck as u };
241
- //# sourceMappingURL=planner-sql-checks-7jkgm9TX.mjs.map
238
+
239
+ //# sourceMappingURL=planner-sql-checks-DwZvGlV4.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"planner-sql-checks-DwZvGlV4.mjs","names":[],"sources":["../src/core/migrations/planner-type-resolution.ts","../src/core/migrations/planner-sql-checks.ts"],"sourcesContent":["import type { StorageColumn, StorageTypeInstance } from '@prisma-next/sql-contract/types';\n\nexport type ResolvedColumnTypeMetadata = Pick<\n StorageColumn,\n 'nativeType' | 'codecId' | 'typeParams'\n>;\n\nexport function resolveColumnTypeMetadata(\n column: StorageColumn,\n storageTypes: Record<string, StorageTypeInstance>,\n): ResolvedColumnTypeMetadata {\n if (!column.typeRef) {\n return column;\n }\n\n const referencedType = storageTypes[column.typeRef];\n if (!referencedType) {\n return column;\n }\n\n return {\n codecId: referencedType.codecId,\n nativeType: referencedType.nativeType,\n typeParams: referencedType.typeParams,\n };\n}\n","import type { CodecControlHooks } from '@prisma-next/family-sql/control';\nimport type { StorageColumn, StorageTypeInstance } from '@prisma-next/sql-contract/types';\nimport { escapeLiteral, quoteIdentifier } from '../sql-utils';\nimport { resolveColumnTypeMetadata } from './planner-type-resolution';\n\nexport function qualifyTableName(schema: string, table: string): string {\n return `${quoteIdentifier(schema)}.${quoteIdentifier(table)}`;\n}\n\nexport function toRegclassLiteral(schema: string, name: string): string {\n const regclass = `${quoteIdentifier(schema)}.${quoteIdentifier(name)}`;\n return `'${escapeLiteral(regclass)}'`;\n}\n\n/**\n * When `table` is omitted the check matches by name + schema across all tables.\n * Pass `table` to scope the check to a single table (prevents false matches on\n * identically-named constraints in different tables).\n */\nexport function constraintExistsCheck({\n constraintName,\n schema,\n table,\n exists = true,\n}: {\n constraintName: string;\n schema: string;\n table?: string;\n exists?: boolean;\n}): string {\n const existsClause = exists ? 'EXISTS' : 'NOT EXISTS';\n const tableFilter = table\n ? `AND c.conrelid = to_regclass(${toRegclassLiteral(schema, table)})`\n : '';\n return `SELECT ${existsClause} (\n SELECT 1 FROM pg_constraint c\n JOIN pg_namespace n ON c.connamespace = n.oid\n WHERE c.conname = '${escapeLiteral(constraintName)}'\n AND n.nspname = '${escapeLiteral(schema)}'\n ${tableFilter}\n)`;\n}\n\nexport function columnExistsCheck({\n schema,\n table,\n column,\n exists = true,\n}: {\n schema: string;\n table: string;\n column: string;\n exists?: boolean;\n}): string {\n const existsClause = exists ? '' : 'NOT ';\n return `SELECT ${existsClause}EXISTS (\n SELECT 1\n FROM information_schema.columns\n WHERE table_schema = '${escapeLiteral(schema)}'\n AND table_name = '${escapeLiteral(table)}'\n AND column_name = '${escapeLiteral(column)}'\n)`;\n}\n\nexport function columnNullabilityCheck({\n schema,\n table,\n column,\n nullable,\n}: {\n schema: string;\n table: string;\n column: string;\n nullable: boolean;\n}): string {\n const expected = nullable ? 'YES' : 'NO';\n return `SELECT EXISTS (\n SELECT 1\n FROM information_schema.columns\n WHERE table_schema = '${escapeLiteral(schema)}'\n AND table_name = '${escapeLiteral(table)}'\n AND column_name = '${escapeLiteral(column)}'\n AND is_nullable = '${expected}'\n)`;\n}\n\nexport function tableIsEmptyCheck(qualifiedTableName: string): string {\n return `SELECT NOT EXISTS (SELECT 1 FROM ${qualifiedTableName} LIMIT 1)`;\n}\n\nexport function columnHasNoDefaultCheck(opts: {\n schema: string;\n table: string;\n column: string;\n}): string {\n return `SELECT NOT EXISTS (\n SELECT 1\n FROM information_schema.columns\n WHERE table_schema = '${escapeLiteral(opts.schema)}'\n AND table_name = '${escapeLiteral(opts.table)}'\n AND column_name = '${escapeLiteral(opts.column)}'\n AND column_default IS NOT NULL\n)`;\n}\n\nconst FORMAT_TYPE_DISPLAY: ReadonlyMap<string, string> = new Map([\n ['int2', 'smallint'],\n ['int4', 'integer'],\n ['int8', 'bigint'],\n ['float4', 'real'],\n ['float8', 'double precision'],\n ['bool', 'boolean'],\n ['timestamp', 'timestamp without time zone'],\n ['timestamptz', 'timestamp with time zone'],\n ['time', 'time without time zone'],\n ['timetz', 'time with time zone'],\n]);\n\nconst UNQUOTED_POSTGRES_IDENTIFIER_PATTERN = /^[a-z_][a-z0-9_$]*$/;\n\nconst POSTGRES_RESERVED_IDENTIFIER_WORDS = new Set([\n 'all',\n 'analyse',\n 'analyze',\n 'and',\n 'any',\n 'array',\n 'as',\n 'asc',\n 'asymmetric',\n 'authorization',\n 'between',\n 'binary',\n 'both',\n 'case',\n 'cast',\n 'check',\n 'collate',\n 'column',\n 'constraint',\n 'create',\n 'current_catalog',\n 'current_date',\n 'current_role',\n 'current_time',\n 'current_timestamp',\n 'current_user',\n 'default',\n 'deferrable',\n 'desc',\n 'distinct',\n 'do',\n 'else',\n 'end',\n 'except',\n 'false',\n 'fetch',\n 'for',\n 'foreign',\n 'freeze',\n 'from',\n 'full',\n 'grant',\n 'group',\n 'having',\n 'ilike',\n 'in',\n 'initially',\n 'inner',\n 'intersect',\n 'into',\n 'is',\n 'isnull',\n 'join',\n 'lateral',\n 'leading',\n 'left',\n 'like',\n 'limit',\n 'localtime',\n 'localtimestamp',\n 'natural',\n 'not',\n 'notnull',\n 'null',\n 'offset',\n 'on',\n 'only',\n 'or',\n 'order',\n 'outer',\n 'overlaps',\n 'placing',\n 'primary',\n 'references',\n 'right',\n 'select',\n 'session_user',\n 'similar',\n 'some',\n 'symmetric',\n 'table',\n 'then',\n 'to',\n 'trailing',\n 'true',\n 'union',\n 'unique',\n 'user',\n 'using',\n 'variadic',\n 'verbose',\n 'when',\n 'where',\n 'window',\n 'with',\n]);\n\nfunction formatUserDefinedTypeName(identifier: string): string {\n if (\n UNQUOTED_POSTGRES_IDENTIFIER_PATTERN.test(identifier) &&\n !POSTGRES_RESERVED_IDENTIFIER_WORDS.has(identifier)\n ) {\n return identifier;\n }\n\n return quoteIdentifier(identifier);\n}\n\nexport function buildExpectedFormatType(\n column: StorageColumn,\n codecHooks: Map<string, CodecControlHooks>,\n storageTypes: Record<string, StorageTypeInstance> = {},\n): string {\n const resolved = resolveColumnTypeMetadata(column, storageTypes);\n\n if (resolved.typeParams && resolved.codecId) {\n const hooks = codecHooks.get(resolved.codecId);\n if (hooks?.expandNativeType) {\n return hooks.expandNativeType({\n nativeType: resolved.nativeType,\n codecId: resolved.codecId,\n typeParams: resolved.typeParams,\n });\n }\n }\n\n if (column.typeRef) {\n return formatUserDefinedTypeName(resolved.nativeType);\n }\n\n return FORMAT_TYPE_DISPLAY.get(resolved.nativeType) ?? resolved.nativeType;\n}\n\nexport function columnTypeCheck({\n schema,\n table,\n column,\n expectedType,\n}: {\n schema: string;\n table: string;\n column: string;\n expectedType: string;\n}): string {\n return `SELECT EXISTS (\n SELECT 1\n FROM pg_attribute a\n JOIN pg_class c ON c.oid = a.attrelid\n JOIN pg_namespace n ON n.oid = c.relnamespace\n WHERE n.nspname = '${escapeLiteral(schema)}'\n AND c.relname = '${escapeLiteral(table)}'\n AND a.attname = '${escapeLiteral(column)}'\n AND format_type(a.atttypid, a.atttypmod) = '${escapeLiteral(expectedType)}'\n AND NOT a.attisdropped\n)`;\n}\n\nexport function columnDefaultExistsCheck({\n schema,\n table,\n column,\n exists = true,\n}: {\n schema: string;\n table: string;\n column: string;\n exists?: boolean;\n}): string {\n const nullCheck = exists ? 'IS NOT NULL' : 'IS NULL';\n return `SELECT EXISTS (\n SELECT 1\n FROM information_schema.columns\n WHERE table_schema = '${escapeLiteral(schema)}'\n AND table_name = '${escapeLiteral(table)}'\n AND column_name = '${escapeLiteral(column)}'\n AND column_default ${nullCheck}\n)`;\n}\n\nexport function tableHasPrimaryKeyCheck(\n schema: string,\n table: string,\n exists: boolean,\n constraintName?: string,\n): string {\n const comparison = exists ? '' : 'NOT ';\n const constraintFilter = constraintName\n ? `AND c2.relname = '${escapeLiteral(constraintName)}'`\n : '';\n return `SELECT ${comparison}EXISTS (\n SELECT 1\n FROM pg_index i\n JOIN pg_class c ON c.oid = i.indrelid\n JOIN pg_namespace n ON n.oid = c.relnamespace\n LEFT JOIN pg_class c2 ON c2.oid = i.indexrelid\n WHERE n.nspname = '${escapeLiteral(schema)}'\n AND c.relname = '${escapeLiteral(table)}'\n AND i.indisprimary\n ${constraintFilter}\n)`;\n}\n"],"mappings":"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"}
@@ -1 +1 @@
1
- {"version":3,"file":"planner-sql-checks.d.mts","names":[],"sources":["../src/core/migrations/planner-sql-checks.ts"],"sourcesContent":[],"mappings":";;;;iBAKgB,gBAAA;iBAIA,iBAAA;AAJhB;AAIA;AAUA;;;AAGE,iBAHc,qBAAA,CAGd;EAAA,cAAA;EAAA,MAAA;EAAA,KAAA;EAAA;CAAA,EAAA;EACA,cAAA,EAAA,MAAA;EAAa,MAAA,EAAA,MAAA;EAoBC,KAAA,CAAA,EAAA,MAAA;EACd,MAAA,CAAA,EAAA,OAAA;CACA,CAAA,EAAA,MAAA;AACA,iBAHc,iBAAA,CAGd;EAAA,MAAA;EAAA,KAAA;EAAA,MAAA;EAAA;CAAA,EAAA;EACA,MAAA,EAAA,MAAA;EAAa,KAAA,EAAA,MAAA;EAiBC,MAAA,EAAA,MAAA;EACd,MAAA,CAAA,EAAA,OAAA;CACA,CAAA,EAAA,MAAA;AACA,iBAHc,sBAAA,CAGd;EAAA,MAAA;EAAA,KAAA;EAAA,MAAA;EAAA;AAkKF,CAlKE,EAAA;EACA,MAAA,EAAA,MAAA;EAAQ,KAAA,EAAA,MAAA;EAkBM,MAAA,EAAA,MAAA;EAIA,QAAA,EAAA,OAAA;AA2IhB,CAAA,CAAA,EAAgB,MAAA;AACN,iBAhJM,iBAAA,CAgJN,kBAAA,EAAA,MAAA,CAAA,EAAA,MAAA;AACgB,iBA7IV,uBAAA,CA6IU,IAAA,EAAA;EAAZ,MAAA,EAAA,MAAA;EACiB,KAAA,EAAA,MAAA;EAAf,MAAA,EAAA,MAAA;CAAM,CAAA,EAAA,MAAA;AAoEN,iBAvEA,uBAAA,CAuEuB,MAAA,EAtE7B,aAsE6B,EAAA,UAAA,EArEzB,GAqEyB,CAAA,MAAA,EArEb,iBAqEa,CAAA,EAAA,YAAA,CAAA,EApEvB,MAoEuB,CAAA,MAAA,EApER,mBAoEQ,CAAA,CAAA,EAAA,MAAA;iBAAvB,uBAAA"}
1
+ {"version":3,"file":"planner-sql-checks.d.mts","names":[],"sources":["../src/core/migrations/planner-sql-checks.ts"],"mappings":";;;;iBAKgB,gBAAA,CAAiB,MAAA,UAAgB,KAAA;AAAA,iBAIjC,iBAAA,CAAkB,MAAA,UAAgB,IAAA;AAJlD;;;;;AAAA,iBAcgB,qBAAA,CAAA;EACd,cAAA;EACA,MAAA;EACA,KAAA;EACA;AAAA;EAEA,cAAA;EACA,MAAA;EACA,KAAA;EACA,MAAA;AAAA;AAAA,iBAec,iBAAA,CAAA;EACd,MAAA;EACA,KAAA;EACA,MAAA;EACA;AAAA;EAEA,MAAA;EACA,KAAA;EACA,MAAA;EACA,MAAA;AAAA;AAAA,iBAYc,sBAAA,CAAA;EACd,MAAA;EACA,KAAA;EACA,MAAA;EACA;AAAA;EAEA,MAAA;EACA,KAAA;EACA,MAAA;EACA,QAAA;AAAA;AAAA,iBAac,iBAAA,CAAkB,kBAAA;AAAA,iBAIlB,uBAAA,CAAwB,IAAA;EACtC,MAAA;EACA,KAAA;EACA,MAAA;AAAA;AAAA,iBAwIc,uBAAA,CACd,MAAA,EAAQ,aAAA,EACR,UAAA,EAAY,GAAA,SAAY,iBAAA,GACxB,YAAA,GAAc,MAAA,SAAe,mBAAA;AAAA,iBAoEf,uBAAA,CACd,MAAA,UACA,KAAA,UACA,MAAA,WACA,cAAA"}
@@ -1,3 +1,2 @@
1
- import { a as columnNullabilityCheck, c as qualifyTableName, d as toRegclassLiteral, i as columnHasNoDefaultCheck, l as tableHasPrimaryKeyCheck, r as columnExistsCheck, s as constraintExistsCheck, t as buildExpectedFormatType, u as tableIsEmptyCheck } from "./planner-sql-checks-7jkgm9TX.mjs";
2
-
3
- export { buildExpectedFormatType, columnExistsCheck, columnHasNoDefaultCheck, columnNullabilityCheck, constraintExistsCheck, qualifyTableName, tableHasPrimaryKeyCheck, tableIsEmptyCheck, toRegclassLiteral };
1
+ import { a as columnNullabilityCheck, c as qualifyTableName, d as toRegclassLiteral, i as columnHasNoDefaultCheck, l as tableHasPrimaryKeyCheck, r as columnExistsCheck, s as constraintExistsCheck, t as buildExpectedFormatType, u as tableIsEmptyCheck } from "./planner-sql-checks-DwZvGlV4.mjs";
2
+ export { buildExpectedFormatType, columnExistsCheck, columnHasNoDefaultCheck, columnNullabilityCheck, constraintExistsCheck, qualifyTableName, tableHasPrimaryKeyCheck, tableIsEmptyCheck, toRegclassLiteral };
@@ -8,4 +8,4 @@ interface PostgresPlanTargetDetails {
8
8
  }
9
9
  //#endregion
10
10
  export { PostgresPlanTargetDetails as t };
11
- //# sourceMappingURL=planner-target-details-DH-azLu-.d.mts.map
11
+ //# sourceMappingURL=planner-target-details-bVVcanWh.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"planner-target-details-bVVcanWh.d.mts","names":[],"sources":["../src/core/migrations/planner-target-details.ts"],"mappings":";KAEY,cAAA;AAAA,UAUK,yBAAA;EAAA,SACN,MAAA;EAAA,SACA,UAAA,EAAY,cAAA;EAAA,SACZ,IAAA;EAAA,SACA,KAAA;AAAA"}
@@ -1,2 +1,2 @@
1
- import { t as PostgresPlanTargetDetails } from "./planner-target-details-DH-azLu-.mjs";
1
+ import { t as PostgresPlanTargetDetails } from "./planner-target-details-bVVcanWh.mjs";
2
2
  export { type PostgresPlanTargetDetails };
@@ -1 +1 @@
1
- export { };
1
+ export {};
@@ -1,9 +1,7 @@
1
- import "./shared-Bxkt8pNO.mjs";
2
- import "./op-factory-call-C3bWXKSP.mjs";
3
- import "./postgres-migration-BjA3Zmts.mjs";
4
- import { t as TypeScriptRenderablePostgresMigration } from "./planner-produced-postgres-migration-CRRTno6Z.mjs";
1
+ import { t as TypeScriptRenderablePostgresMigration } from "./planner-produced-postgres-migration-CjxWIVgh.mjs";
5
2
  import { MigrationOperationPolicy, SqlPlannerFailureResult } from "@prisma-next/family-sql/control";
6
3
  import { MigrationPlanWithAuthoringSurface, MigrationPlanner, MigrationScaffoldContext } from "@prisma-next/framework-components/control";
4
+ import { Contract } from "@prisma-next/contract/types";
7
5
  import { TargetBoundComponentDescriptor } from "@prisma-next/framework-components/components";
8
6
 
9
7
  //#region src/core/migrations/planner.d.ts
@@ -45,20 +43,31 @@ declare class PostgresMigrationPlanner implements MigrationPlanner<'sql', 'postg
45
43
  readonly contract: unknown;
46
44
  readonly schema: unknown;
47
45
  readonly policy: MigrationOperationPolicy;
48
- readonly fromHash?: string;
49
46
  /**
50
47
  * The "from" contract (state the planner assumes the database starts
51
- * at). Only `migration plan` supplies this; `db update` / `db init`
52
- * reconcile against the live schema with no old contract. When present
53
- * alongside the `'data'` operation class, strategies that need from/to
54
- * column shape comparisons (unsafe type change, nullability tightening)
55
- * activate.
48
+ * at), or `null` for reconciliation flows. Only `migration plan` ever
49
+ * supplies a non-null value; `db update` / `db init` reconcile against
50
+ * the live schema and pass `null`. When present alongside the
51
+ * `'data'` operation class, strategies that need from/to column-shape
52
+ * comparisons (unsafe type change, nullability tightening) activate.
53
+ *
54
+ * Typed as the framework `Contract | null` to satisfy the
55
+ * `MigrationPlanner` interface contract; `planSql` narrows to the SQL
56
+ * shape via `SqlMigrationPlannerPlanOptions`. Used to populate
57
+ * `describe().from` on the produced plan as
58
+ * `fromContract?.storage.storageHash ?? null`.
56
59
  */
57
- readonly fromContract?: unknown;
60
+ readonly fromContract: Contract | null;
58
61
  readonly schemaName?: string;
59
62
  readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;
63
+ /**
64
+ * Contract space this plan applies to. Stamped onto the produced
65
+ * {@link TypeScriptRenderablePostgresMigration.spaceId} so the runner keys
66
+ * the marker row by the right space.
67
+ */
68
+ readonly spaceId: string;
60
69
  }): PostgresPlanResult;
61
- emptyMigration(context: MigrationScaffoldContext): MigrationPlanWithAuthoringSurface;
70
+ emptyMigration(context: MigrationScaffoldContext, spaceId: string): MigrationPlanWithAuthoringSurface;
62
71
  private planSql;
63
72
  private ensureAdditivePolicy;
64
73
  private collectSchemaIssues;
@@ -1 +1 @@
1
- {"version":3,"file":"planner.d.mts","names":[],"sources":["../src/core/migrations/planner.ts"],"sourcesContent":[],"mappings":";;;;;;;;;UAkCU,aAAA;;;iBAQM,8BAAA,UACN,QAAQ,iBACf;;AA3B2F;AAyB9F;;;;;AAgBY,KAAA,kBAAA,GAAkB;EAoBjB,SAAA,IAAA,EAAA,SAAA;EAC0B,SAAA,IAAA,EApBQ,qCAoBR;CAKlB,GAxBjB,uBAwBiB;;;;;;;;;;;;;;;;;cANR,wBAAA,YAAoC;;sBACV;;;;qBAKlB;;;;;;;;;;;;kCAYa,cAAc;MAC1C;0BAIoB,2BAA2B"}
1
+ {"version":3,"file":"planner.d.mts","names":[],"sources":["../src/core/migrations/planner.ts"],"mappings":";;;;;;;UAuCU,aAAA;EAAA,SACC,aAAA;AAAA;AAAA,iBAOK,8BAAA,CACd,MAAA,GAAQ,OAAA,CAAQ,aAAA,IACf,wBAAA;;;;AAFH;;;;KAgBY,kBAAA;EAAA,SACG,IAAA;EAAA,SAA0B,IAAA,EAAM,qCAAA;AAAA,IAC3C,uBAAA;;;;;;;AAFJ;;;;;;;;;;cAoBa,wBAAA,YAAoC,gBAAA;EAAA,iBAClB,MAAA;cAAA,MAAA,EAAQ,aAAA;EAErC,IAAA,CAAK,OAAA;IAAA,SACM,QAAA;IAAA,SACA,MAAA;IAAA,SACA,MAAA,EAAQ,wBAAA;IAiBa;;;;;;;;;;;;;;IAAA,SAFrB,YAAA,EAAc,QAAA;IAAA,SACd,UAAA;IAAA,SACA,mBAAA,EAAqB,aAAA,CAAc,8BAAA;IAFnC;;;;;IAAA,SAQA,OAAA;EAAA,IACP,kBAAA;EAIJ,cAAA,CACE,OAAA,EAAS,wBAAA,EACT,OAAA,WACC,iCAAA;EAAA,QAWK,OAAA;EAAA,QA6DA,oBAAA;EAAA,QAaA,mBAAA;AAAA"}
package/dist/planner.mjs CHANGED
@@ -1,4 +1,2 @@
1
- import "./issue-planner-CFjB0_oO.mjs";
2
- import { t as createPostgresMigrationPlanner } from "./planner-CLUvVhUN.mjs";
3
-
4
- export { createPostgresMigrationPlanner };
1
+ import { t as createPostgresMigrationPlanner } from "./planner-Lhacw3uU.mjs";
2
+ export { createPostgresMigrationPlanner };
@@ -1,7 +1,6 @@
1
- import { t as errorPostgresMigrationStackMissing } from "./errors-AFvEPZ1R.mjs";
2
- import { t as dataTransform } from "./data-transform-VfEGzXWt.mjs";
1
+ import { t as errorPostgresMigrationStackMissing } from "./errors-Chm2bKcS.mjs";
2
+ import { t as dataTransform } from "./data-transform-DKWXdHuZ.mjs";
3
3
  import { Migration } from "@prisma-next/family-sql/migration";
4
-
5
4
  //#region src/core/migrations/postgres-migration.ts
6
5
  /**
7
6
  * Target-owned base class for Postgres migrations.
@@ -46,7 +45,7 @@ var PostgresMigration = class extends Migration {
46
45
  return dataTransform(contract, name, options, this.controlAdapter);
47
46
  }
48
47
  };
49
-
50
48
  //#endregion
51
49
  export { PostgresMigration as t };
52
- //# sourceMappingURL=postgres-migration-qtmtbONe.mjs.map
50
+
51
+ //# sourceMappingURL=postgres-migration-Bkv140RW.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-migration-Bkv140RW.mjs","names":["SqlMigration"],"sources":["../src/core/migrations/postgres-migration.ts"],"sourcesContent":["import type { Contract } from '@prisma-next/contract/types';\nimport type { SqlMigrationPlanOperation } from '@prisma-next/family-sql/control';\nimport type { SqlControlAdapter } from '@prisma-next/family-sql/control-adapter';\nimport { Migration as SqlMigration } from '@prisma-next/family-sql/migration';\nimport type { ControlStack } from '@prisma-next/framework-components/control';\nimport type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport { errorPostgresMigrationStackMissing } from '../errors';\nimport { type DataTransformOptions, dataTransform } from './operations/data-transform';\nimport type { PostgresPlanTargetDetails } from './planner-target-details';\n\n/**\n * Target-owned base class for Postgres migrations.\n *\n * Fixes the `SqlMigration` generic to `PostgresPlanTargetDetails` and the\n * abstract `targetId` to the Postgres target-id string literal, so both\n * user-authored migrations and renderer-generated scaffolds (the output of\n * `renderCallsToTypeScript`) can extend `PostgresMigration` directly without\n * redeclaring target-local identity.\n *\n * Mirrors `MongoMigration` in `@prisma-next/family-mongo`: the renderer\n * emits `extends Migration` against a target-specific re-export of this\n * class from `@prisma-next/target-postgres/migration`, keeping the\n * authoring surface target-scoped rather than family-scoped.\n *\n * The constructor materializes a single Postgres `SqlControlAdapter` from\n * `stack.adapter.create(stack)` and stores it; the protected `dataTransform`\n * instance method forwards to the free `dataTransform` factory with that\n * stored adapter, so user migrations can write `this.dataTransform(...)`\n * without threading the adapter through every call.\n */\nexport abstract class PostgresMigration extends SqlMigration<\n PostgresPlanTargetDetails,\n 'postgres'\n> {\n readonly targetId = 'postgres' as const;\n\n /**\n * Materialized Postgres control adapter, created once per migration\n * instance from the injected stack. `undefined` only when the migration\n * was instantiated without a stack (test fixtures); `dataTransform`\n * throws in that case to surface the misuse.\n */\n protected readonly controlAdapter: SqlControlAdapter<'postgres'> | undefined;\n\n constructor(stack?: ControlStack<'sql', 'postgres'>) {\n super(stack);\n // The descriptor `create()` is typed as the wider `ControlAdapterInstance`;\n // the Postgres descriptor concretely returns a `SqlControlAdapter<'postgres'>`,\n // so the cast holds for any Postgres-target stack assembled at runtime.\n this.controlAdapter = stack?.adapter\n ? (stack.adapter.create(stack) as SqlControlAdapter<'postgres'>)\n : undefined;\n }\n\n /**\n * Instance-method wrapper around the free `dataTransform` factory that\n * supplies the stored control adapter. Authors call this from inside\n * `get operations()`; the adapter argument is hidden from the call site.\n */\n protected dataTransform<TContract extends Contract<SqlStorage>>(\n contract: TContract,\n name: string,\n options: DataTransformOptions,\n ): SqlMigrationPlanOperation<PostgresPlanTargetDetails> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return dataTransform(contract, name, options, this.controlAdapter);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA8BA,IAAsB,oBAAtB,cAAgDA,UAG9C;CACA,WAAoB;;;;;;;CAQpB;CAEA,YAAY,OAAyC;EACnD,MAAM,MAAM;EAIZ,KAAK,iBAAiB,OAAO,UACxB,MAAM,QAAQ,OAAO,MAAM,GAC5B,KAAA;;;;;;;CAQN,cACE,UACA,MACA,SACsD;EACtD,IAAI,CAAC,KAAK,gBACR,MAAM,oCAAoC;EAE5C,OAAO,cAAc,UAAU,MAAM,SAAS,KAAK,eAAe"}
@@ -1,13 +1,13 @@
1
- import { t as PostgresPlanTargetDetails } from "./planner-target-details-DH-azLu-.mjs";
2
- import { n as DataTransformOptions, r as PostgresDataTransformOperation } from "./data-transform-CxFRBIUp.mjs";
1
+ import { t as PostgresPlanTargetDetails } from "./planner-target-details-bVVcanWh.mjs";
2
+ import { n as DataTransformOptions } from "./data-transform-bIeAcZIJ.mjs";
3
+ import { SqlMigrationPlanOperation } from "@prisma-next/family-sql/control";
3
4
  import { Migration } from "@prisma-next/family-sql/migration";
5
+ import { ControlStack } from "@prisma-next/framework-components/control";
4
6
  import { Contract } from "@prisma-next/contract/types";
5
7
  import { SqlStorage } from "@prisma-next/sql-contract/types";
6
8
  import { SqlControlAdapter } from "@prisma-next/family-sql/control-adapter";
7
- import { ControlStack } from "@prisma-next/framework-components/control";
8
9
 
9
10
  //#region src/core/migrations/postgres-migration.d.ts
10
-
11
11
  /**
12
12
  * Target-owned base class for Postgres migrations.
13
13
  *
@@ -43,8 +43,8 @@ declare abstract class PostgresMigration extends Migration<PostgresPlanTargetDet
43
43
  * supplies the stored control adapter. Authors call this from inside
44
44
  * `get operations()`; the adapter argument is hidden from the call site.
45
45
  */
46
- protected dataTransform<TContract extends Contract<SqlStorage>>(contract: TContract, name: string, options: DataTransformOptions): PostgresDataTransformOperation;
46
+ protected dataTransform<TContract extends Contract<SqlStorage>>(contract: TContract, name: string, options: DataTransformOptions): SqlMigrationPlanOperation<PostgresPlanTargetDetails>;
47
47
  }
48
48
  //#endregion
49
49
  export { PostgresMigration as t };
50
- //# sourceMappingURL=postgres-migration-BjA3Zmts.d.mts.map
50
+ //# sourceMappingURL=postgres-migration-UkcHfZAA.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-migration-UkcHfZAA.d.mts","names":[],"sources":["../src/core/migrations/postgres-migration.ts"],"mappings":";;;;;;;;;;;;AA8BA;;;;;;;;;;;;;;;;;;uBAAsB,iBAAA,SAA0B,SAAA,CAC9C,yBAAA;EAAA,SAGS,QAAA;;;;;;;qBAQU,cAAA,EAAgB,iBAAA;cAEvB,KAAA,GAAQ,YAAA;EAgBlB;;;;;EAAA,UADQ,aAAA,mBAAgC,QAAA,CAAS,UAAA,EAAA,CACjD,QAAA,EAAU,SAAA,EACV,IAAA,UACA,OAAA,EAAS,oBAAA,GACR,yBAAA,CAA0B,yBAAA;AAAA"}
@@ -0,0 +1,23 @@
1
+ //#region src/core/migrations/render-ops.ts
2
+ /**
3
+ * Asserts an op materialised by an `OpFactoryCall` targets postgres. The
4
+ * extension surface lets any contributor emit calls, so this is the
5
+ * integration boundary where a stray non-postgres op would otherwise
6
+ * silently flow through to postgres-shaped renderers — exactly the
7
+ * place to fail loudly with op metadata (`id` + `target.id`).
8
+ */
9
+ function assertPostgresOp(op, callFactoryName) {
10
+ const targetId = op.target?.id;
11
+ if (targetId !== "postgres") throw new Error(`renderOps: expected postgres op but got target.id="${String(targetId)}" for op.id="${op.id}" (factoryName="${callFactoryName}"). An OpFactoryCall produced an op for a different target on the postgres planner path; check the call's target binding.`);
12
+ }
13
+ function renderOps(calls) {
14
+ return calls.map((c) => {
15
+ const op = c.toOp();
16
+ assertPostgresOp(op, c.factoryName);
17
+ return op;
18
+ });
19
+ }
20
+ //#endregion
21
+ export { renderOps as t };
22
+
23
+ //# sourceMappingURL=render-ops--1nnfNus.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-ops--1nnfNus.mjs","names":[],"sources":["../src/core/migrations/render-ops.ts"],"sourcesContent":["import type { SqlMigrationPlanOperation } from '@prisma-next/family-sql/control';\nimport type { OpFactoryCall } from '@prisma-next/framework-components/control';\nimport type { PostgresPlanTargetDetails } from './planner-target-details';\n\ntype Op = SqlMigrationPlanOperation<PostgresPlanTargetDetails>;\n\n/**\n * Asserts an op materialised by an `OpFactoryCall` targets postgres. The\n * extension surface lets any contributor emit calls, so this is the\n * integration boundary where a stray non-postgres op would otherwise\n * silently flow through to postgres-shaped renderers — exactly the\n * place to fail loudly with op metadata (`id` + `target.id`).\n */\nfunction assertPostgresOp(\n op: ReturnType<OpFactoryCall['toOp']>,\n callFactoryName: string,\n): asserts op is Op {\n const targetId = (op as Partial<Op>).target?.id;\n if (targetId !== 'postgres') {\n throw new Error(\n `renderOps: expected postgres op but got target.id=\"${String(targetId)}\" for op.id=\"${op.id}\" (factoryName=\"${callFactoryName}\"). An OpFactoryCall produced an op for a different target on the postgres planner path; check the call's target binding.`,\n );\n }\n}\n\nexport function renderOps(calls: readonly OpFactoryCall[]): Op[] {\n return calls.map((c) => {\n const op = c.toOp();\n assertPostgresOp(op, c.factoryName);\n return op;\n });\n}\n"],"mappings":";;;;;;;;AAaA,SAAS,iBACP,IACA,iBACkB;CAClB,MAAM,WAAY,GAAmB,QAAQ;CAC7C,IAAI,aAAa,YACf,MAAM,IAAI,MACR,sDAAsD,OAAO,SAAS,CAAC,eAAe,GAAG,GAAG,kBAAkB,gBAAgB,2HAC/H;;AAIL,SAAgB,UAAU,OAAuC;CAC/D,OAAO,MAAM,KAAK,MAAM;EACtB,MAAM,KAAK,EAAE,MAAM;EACnB,iBAAiB,IAAI,EAAE,YAAY;EACnC,OAAO;GACP"}
@@ -1,11 +1,10 @@
1
- import { t as PostgresPlanTargetDetails } from "./planner-target-details-DH-azLu-.mjs";
2
- import "./shared-Bxkt8pNO.mjs";
3
- import { b as PostgresOpFactoryCall } from "./op-factory-call-C3bWXKSP.mjs";
1
+ import { t as PostgresPlanTargetDetails } from "./planner-target-details-bVVcanWh.mjs";
4
2
  import { SqlMigrationPlanOperation } from "@prisma-next/family-sql/control";
3
+ import { OpFactoryCall } from "@prisma-next/framework-components/control";
5
4
 
6
5
  //#region src/core/migrations/render-ops.d.ts
7
6
  type Op = SqlMigrationPlanOperation<PostgresPlanTargetDetails>;
8
- declare function renderOps(calls: readonly PostgresOpFactoryCall[]): Op[];
7
+ declare function renderOps(calls: readonly OpFactoryCall[]): Op[];
9
8
  //#endregion
10
9
  export { renderOps };
11
10
  //# sourceMappingURL=render-ops.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"render-ops.d.mts","names":[],"sources":["../src/core/migrations/render-ops.ts"],"sourcesContent":[],"mappings":";;;;;;KAIK,EAAA,GAAK,0BAA0B;iBAEpB,SAAA,iBAA0B,0BAA0B"}
1
+ {"version":3,"file":"render-ops.d.mts","names":[],"sources":["../src/core/migrations/render-ops.ts"],"mappings":";;;;;KAIK,EAAA,GAAK,yBAAA,CAA0B,yBAAA;AAAA,iBAqBpB,SAAA,CAAU,KAAA,WAAgB,aAAA,KAAkB,EAAA"}
@@ -1,3 +1,2 @@
1
- import { t as renderOps } from "./render-ops-D6_DHdOK.mjs";
2
-
3
- export { renderOps };
1
+ import { t as renderOps } from "./render-ops--1nnfNus.mjs";
2
+ export { renderOps };
@@ -1,18 +1,7 @@
1
1
  import { jsonToTsSource, renderImports } from "@prisma-next/ts-render";
2
2
  import { detectScaffoldRuntime, shebangLineFor } from "@prisma-next/migration-tools/migration-ts";
3
-
4
3
  //#region src/core/migrations/render-typescript.ts
5
4
  /**
6
- * Polymorphic TypeScript emitter for the Postgres migration IR.
7
- *
8
- * Each `PostgresOpFactoryCall` renders itself via `renderTypeScript()` and
9
- * declares its own `importRequirements()`; this file just composes the module
10
- * source around those contributions. The design mirrors the Mongo target's
11
- * `render-typescript.ts` deliberately — byte-for-byte alignment isn't required
12
- * (different factory module specifiers, different base-class name) but the
13
- * shape is, so future consolidation to a framework-level helper is mechanical.
14
- */
15
- /**
16
5
  * Always-present base imports for the rendered scaffold. Both come from
17
6
  * `@prisma-next/target-postgres/migration` so an authored Postgres
18
7
  * `migration.ts` only needs a single dependency for its base class and
@@ -68,7 +57,6 @@ function buildDescribeMethod(meta) {
68
57
  lines.push(" return {");
69
58
  lines.push(` from: ${JSON.stringify(meta.from)},`);
70
59
  lines.push(` to: ${JSON.stringify(meta.to)},`);
71
- if (meta.kind) lines.push(` kind: ${JSON.stringify(meta.kind)},`);
72
60
  if (meta.labels && meta.labels.length > 0) lines.push(` labels: ${jsonToTsSource(meta.labels)},`);
73
61
  lines.push(" };");
74
62
  lines.push(" }");
@@ -79,7 +67,7 @@ function indent(text, spaces) {
79
67
  const pad = " ".repeat(spaces);
80
68
  return text.split("\n").map((line) => line.trim() ? `${pad}${line}` : line).join("\n");
81
69
  }
82
-
83
70
  //#endregion
84
71
  export { renderCallsToTypeScript as t };
85
- //# sourceMappingURL=render-typescript-1rF_SB4g.mjs.map
72
+
73
+ //# sourceMappingURL=render-typescript-D3doH-vX.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-typescript-D3doH-vX.mjs","names":[],"sources":["../src/core/migrations/render-typescript.ts"],"sourcesContent":["/**\n * Polymorphic TypeScript emitter for the Postgres migration IR.\n *\n * Each `OpFactoryCall` renders itself via `renderTypeScript()` and\n * declares its own `importRequirements()`; this file just composes the module\n * source around those contributions. The design mirrors the Mongo target's\n * `render-typescript.ts` deliberately — byte-for-byte alignment isn't required\n * (different factory module specifiers, different base-class name) but the\n * shape is, so future consolidation to a framework-level helper is mechanical.\n */\n\nimport type { OpFactoryCall } from '@prisma-next/framework-components/control';\nimport { detectScaffoldRuntime, shebangLineFor } from '@prisma-next/migration-tools/migration-ts';\nimport { type ImportRequirement, jsonToTsSource, renderImports } from '@prisma-next/ts-render';\n\nexport interface RenderMigrationMeta {\n readonly from: string | null;\n readonly to: string;\n readonly labels?: readonly string[];\n}\n\n/**\n * Always-present base imports for the rendered scaffold. Both come from\n * `@prisma-next/target-postgres/migration` so an authored Postgres\n * `migration.ts` only needs a single dependency for its base class and\n * its CLI entrypoint:\n *\n * - `Migration` — the target-owned re-export fixes the `SqlMigration`\n * generic to `PostgresPlanTargetDetails` and the abstract `targetId`\n * to `'postgres'`, so user-authored migrations don't need to thread\n * target-details or redeclare `targetId`.\n * - `MigrationCLI` — the migration-file CLI entrypoint, re-exported from\n * `@prisma-next/cli/migration-cli`. Loads `prisma-next.config.ts`,\n * assembles a `ControlStack`, and instantiates the migration class.\n * The migration file owns this dependency directly: pulling CLI\n * machinery in at script run time is acceptable because the script's\n * whole purpose is to be invoked from the project that owns the\n * config.\n */\nconst BASE_IMPORTS: readonly ImportRequirement[] = [\n { moduleSpecifier: '@prisma-next/target-postgres/migration', symbol: 'Migration' },\n { moduleSpecifier: '@prisma-next/target-postgres/migration', symbol: 'MigrationCLI' },\n];\n\nexport function renderCallsToTypeScript(\n calls: ReadonlyArray<OpFactoryCall>,\n meta: RenderMigrationMeta,\n): string {\n const imports = buildImports(calls);\n const operationsBody = calls.map((c) => c.renderTypeScript()).join(',\\n');\n\n return [\n shebangLineFor(detectScaffoldRuntime()),\n imports,\n '',\n 'export default class M extends Migration {',\n buildDescribeMethod(meta),\n ' override get operations() {',\n ' return [',\n indent(operationsBody, 6),\n ' ];',\n ' }',\n '}',\n '',\n 'MigrationCLI.run(import.meta.url, M);',\n '',\n ].join('\\n');\n}\n\nfunction buildImports(calls: ReadonlyArray<OpFactoryCall>): string {\n const requirements: ImportRequirement[] = [...BASE_IMPORTS];\n for (const call of calls) {\n for (const req of call.importRequirements()) {\n requirements.push(req);\n }\n }\n return renderImports(requirements);\n}\n\nfunction buildDescribeMethod(meta: RenderMigrationMeta): string {\n const lines: string[] = [];\n lines.push(' override describe() {');\n lines.push(' return {');\n lines.push(` from: ${JSON.stringify(meta.from)},`);\n lines.push(` to: ${JSON.stringify(meta.to)},`);\n if (meta.labels && meta.labels.length > 0) {\n lines.push(` labels: ${jsonToTsSource(meta.labels)},`);\n }\n lines.push(' };');\n lines.push(' }');\n lines.push('');\n return lines.join('\\n');\n}\n\nfunction indent(text: string, spaces: number): string {\n const pad = ' '.repeat(spaces);\n return text\n .split('\\n')\n .map((line) => (line.trim() ? `${pad}${line}` : line))\n .join('\\n');\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAuCA,MAAM,eAA6C,CACjD;CAAE,iBAAiB;CAA0C,QAAQ;CAAa,EAClF;CAAE,iBAAiB;CAA0C,QAAQ;CAAgB,CACtF;AAED,SAAgB,wBACd,OACA,MACQ;CACR,MAAM,UAAU,aAAa,MAAM;CACnC,MAAM,iBAAiB,MAAM,KAAK,MAAM,EAAE,kBAAkB,CAAC,CAAC,KAAK,MAAM;CAEzE,OAAO;EACL,eAAe,uBAAuB,CAAC;EACvC;EACA;EACA;EACA,oBAAoB,KAAK;EACzB;EACA;EACA,OAAO,gBAAgB,EAAE;EACzB;EACA;EACA;EACA;EACA;EACA;EACD,CAAC,KAAK,KAAK;;AAGd,SAAS,aAAa,OAA6C;CACjE,MAAM,eAAoC,CAAC,GAAG,aAAa;CAC3D,KAAK,MAAM,QAAQ,OACjB,KAAK,MAAM,OAAO,KAAK,oBAAoB,EACzC,aAAa,KAAK,IAAI;CAG1B,OAAO,cAAc,aAAa;;AAGpC,SAAS,oBAAoB,MAAmC;CAC9D,MAAM,QAAkB,EAAE;CAC1B,MAAM,KAAK,0BAA0B;CACrC,MAAM,KAAK,eAAe;CAC1B,MAAM,KAAK,eAAe,KAAK,UAAU,KAAK,KAAK,CAAC,GAAG;CACvD,MAAM,KAAK,aAAa,KAAK,UAAU,KAAK,GAAG,CAAC,GAAG;CACnD,IAAI,KAAK,UAAU,KAAK,OAAO,SAAS,GACtC,MAAM,KAAK,iBAAiB,eAAe,KAAK,OAAO,CAAC,GAAG;CAE7D,MAAM,KAAK,SAAS;CACpB,MAAM,KAAK,MAAM;CACjB,MAAM,KAAK,GAAG;CACd,OAAO,MAAM,KAAK,KAAK;;AAGzB,SAAS,OAAO,MAAc,QAAwB;CACpD,MAAM,MAAM,IAAI,OAAO,OAAO;CAC9B,OAAO,KACJ,MAAM,KAAK,CACX,KAAK,SAAU,KAAK,MAAM,GAAG,GAAG,MAAM,SAAS,KAAM,CACrD,KAAK,KAAK"}
@@ -1,15 +1,12 @@
1
- import "./shared-Bxkt8pNO.mjs";
2
- import { b as PostgresOpFactoryCall } from "./op-factory-call-C3bWXKSP.mjs";
1
+ import { OpFactoryCall } from "@prisma-next/framework-components/control";
3
2
 
4
3
  //#region src/core/migrations/render-typescript.d.ts
5
-
6
4
  interface RenderMigrationMeta {
7
- readonly from: string;
5
+ readonly from: string | null;
8
6
  readonly to: string;
9
- readonly kind?: string;
10
7
  readonly labels?: readonly string[];
11
8
  }
12
- declare function renderCallsToTypeScript(calls: ReadonlyArray<PostgresOpFactoryCall>, meta: RenderMigrationMeta): string;
9
+ declare function renderCallsToTypeScript(calls: ReadonlyArray<OpFactoryCall>, meta: RenderMigrationMeta): string;
13
10
  //#endregion
14
11
  export { renderCallsToTypeScript };
15
12
  //# sourceMappingURL=render-typescript.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"render-typescript.d.mts","names":[],"sources":["../src/core/migrations/render-typescript.ts"],"sourcesContent":[],"mappings":";;;;;UAeiB,mBAAA;;;;;;iBA8BD,uBAAA,QACP,cAAc,8BACf"}
1
+ {"version":3,"file":"render-typescript.d.mts","names":[],"sources":["../src/core/migrations/render-typescript.ts"],"mappings":";;;UAeiB,mBAAA;EAAA,SACN,IAAA;EAAA,SACA,EAAA;EAAA,SACA,MAAA;AAAA;AAAA,iBA0BK,uBAAA,CACd,KAAA,EAAO,aAAA,CAAc,aAAA,GACrB,IAAA,EAAM,mBAAA"}
@@ -1,3 +1,2 @@
1
- import { t as renderCallsToTypeScript } from "./render-typescript-1rF_SB4g.mjs";
2
-
3
- export { renderCallsToTypeScript };
1
+ import { t as renderCallsToTypeScript } from "./render-typescript-D3doH-vX.mjs";
2
+ export { renderCallsToTypeScript };
@@ -1,20 +1,16 @@
1
- import { createCodecRegistry } from "@prisma-next/sql-relational-core/ast";
1
+ import { AnyCodecDescriptor } from "@prisma-next/framework-components/codec";
2
2
  import { RuntimeTargetDescriptor, RuntimeTargetInstance } from "@prisma-next/framework-components/execution";
3
3
 
4
4
  //#region src/exports/runtime.d.ts
5
5
  interface PostgresRuntimeTargetInstance extends RuntimeTargetInstance<'sql', 'postgres'> {}
6
6
  /**
7
- * Target-postgres deliberately does NOT import `SqlRuntimeTargetDescriptor`
8
- * from `@prisma-next/sql-runtime`. The target package is a control-plane
9
- * residence and must not pull the SQL execution-plane package into its
10
- * dependency closure. The runtime descriptor here is shaped to satisfy the
11
- * framework's `RuntimeTargetDescriptor` plus the structural
12
- * `SqlStaticContributions` (`codecs`, `parameterizedCodecs`) that
7
+ * Target-postgres deliberately does NOT import `SqlRuntimeTargetDescriptor` from `@prisma-next/sql-runtime`. The target package is a control-plane residence and must not pull the SQL execution-plane package into its dependency closure. The runtime descriptor here is shaped to satisfy the framework's `RuntimeTargetDescriptor` plus the structural `SqlStaticContributions` (`codecs:` returning a descriptor list) that
13
8
  * `@prisma-next/sql-runtime` consumers narrow to at composition time.
9
+ *
10
+ * The target itself contributes no codecs — postgres-specific codecs ship from the postgres adapter and from extension packs (pgvector, arktype-json, etc.).
14
11
  */
15
12
  declare const postgresRuntimeTargetDescriptor: RuntimeTargetDescriptor<'sql', 'postgres', PostgresRuntimeTargetInstance> & {
16
- readonly codecs: () => ReturnType<typeof createCodecRegistry>;
17
- readonly parameterizedCodecs: () => readonly never[];
13
+ readonly codecs: () => readonly AnyCodecDescriptor[];
18
14
  };
19
15
  //#endregion
20
16
  export { PostgresRuntimeTargetInstance, postgresRuntimeTargetDescriptor as default };
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.mts","names":[],"sources":["../src/exports/runtime.ts"],"sourcesContent":[],"mappings":";;;;UAOiB,6BAAA,SAAsC;AAAvD;AAAkG;;;;;;;;cAW5F,iCAAiC,2CAGrC;yBAEuB,kBAAkB"}
1
+ {"version":3,"file":"runtime.d.mts","names":[],"sources":["../src/exports/runtime.ts"],"mappings":";;;;UAOiB,6BAAA,SAAsC,qBAAA;AAAvD;;;;;AAAkG;AAAlG,cAQM,+BAAA,EAAiC,uBAAA,oBAGrC,6BAAA;EAAA,SAES,MAAA,iBAAuB,kBAAA;AAAA"}
package/dist/runtime.mjs CHANGED
@@ -1,20 +1,14 @@
1
- import { t as postgresTargetDescriptorMeta } from "./descriptor-meta-BVoVtyp-.mjs";
2
- import { createCodecRegistry } from "@prisma-next/sql-relational-core/ast";
3
-
1
+ import { t as postgresTargetDescriptorMeta } from "./descriptor-meta-Dde_BS3K.mjs";
4
2
  //#region src/exports/runtime.ts
5
3
  /**
6
- * Target-postgres deliberately does NOT import `SqlRuntimeTargetDescriptor`
7
- * from `@prisma-next/sql-runtime`. The target package is a control-plane
8
- * residence and must not pull the SQL execution-plane package into its
9
- * dependency closure. The runtime descriptor here is shaped to satisfy the
10
- * framework's `RuntimeTargetDescriptor` plus the structural
11
- * `SqlStaticContributions` (`codecs`, `parameterizedCodecs`) that
4
+ * Target-postgres deliberately does NOT import `SqlRuntimeTargetDescriptor` from `@prisma-next/sql-runtime`. The target package is a control-plane residence and must not pull the SQL execution-plane package into its dependency closure. The runtime descriptor here is shaped to satisfy the framework's `RuntimeTargetDescriptor` plus the structural `SqlStaticContributions` (`codecs:` returning a descriptor list) that
12
5
  * `@prisma-next/sql-runtime` consumers narrow to at composition time.
6
+ *
7
+ * The target itself contributes no codecs — postgres-specific codecs ship from the postgres adapter and from extension packs (pgvector, arktype-json, etc.).
13
8
  */
14
9
  const postgresRuntimeTargetDescriptor = {
15
10
  ...postgresTargetDescriptorMeta,
16
- codecs: () => createCodecRegistry(),
17
- parameterizedCodecs: () => [],
11
+ codecs: () => [],
18
12
  create() {
19
13
  return {
20
14
  familyId: "sql",
@@ -22,8 +16,7 @@ const postgresRuntimeTargetDescriptor = {
22
16
  };
23
17
  }
24
18
  };
25
- var runtime_default = postgresRuntimeTargetDescriptor;
26
-
27
19
  //#endregion
28
- export { runtime_default as default };
20
+ export { postgresRuntimeTargetDescriptor as default };
21
+
29
22
  //# sourceMappingURL=runtime.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.mjs","names":["postgresRuntimeTargetDescriptor: RuntimeTargetDescriptor<\n 'sql',\n 'postgres',\n PostgresRuntimeTargetInstance\n> & {\n readonly codecs: () => ReturnType<typeof createCodecRegistry>;\n readonly parameterizedCodecs: () => readonly never[];\n}"],"sources":["../src/exports/runtime.ts"],"sourcesContent":["import type {\n RuntimeTargetDescriptor,\n RuntimeTargetInstance,\n} from '@prisma-next/framework-components/execution';\nimport { createCodecRegistry } from '@prisma-next/sql-relational-core/ast';\nimport { postgresTargetDescriptorMeta } from '../core/descriptor-meta';\n\nexport interface PostgresRuntimeTargetInstance extends RuntimeTargetInstance<'sql', 'postgres'> {}\n\n/**\n * Target-postgres deliberately does NOT import `SqlRuntimeTargetDescriptor`\n * from `@prisma-next/sql-runtime`. The target package is a control-plane\n * residence and must not pull the SQL execution-plane package into its\n * dependency closure. The runtime descriptor here is shaped to satisfy the\n * framework's `RuntimeTargetDescriptor` plus the structural\n * `SqlStaticContributions` (`codecs`, `parameterizedCodecs`) that\n * `@prisma-next/sql-runtime` consumers narrow to at composition time.\n */\nconst postgresRuntimeTargetDescriptor: RuntimeTargetDescriptor<\n 'sql',\n 'postgres',\n PostgresRuntimeTargetInstance\n> & {\n readonly codecs: () => ReturnType<typeof createCodecRegistry>;\n readonly parameterizedCodecs: () => readonly never[];\n} = {\n ...postgresTargetDescriptorMeta,\n codecs: () => createCodecRegistry(),\n parameterizedCodecs: () => [],\n create(): PostgresRuntimeTargetInstance {\n return {\n familyId: 'sql',\n targetId: 'postgres',\n };\n },\n};\n\nexport default postgresRuntimeTargetDescriptor;\n"],"mappings":";;;;;;;;;;;;;AAkBA,MAAMA,kCAOF;CACF,GAAG;CACH,cAAc,qBAAqB;CACnC,2BAA2B,EAAE;CAC7B,SAAwC;AACtC,SAAO;GACL,UAAU;GACV,UAAU;GACX;;CAEJ;AAED,sBAAe"}
1
+ {"version":3,"file":"runtime.mjs","names":[],"sources":["../src/exports/runtime.ts"],"sourcesContent":["import type { AnyCodecDescriptor } from '@prisma-next/framework-components/codec';\nimport type {\n RuntimeTargetDescriptor,\n RuntimeTargetInstance,\n} from '@prisma-next/framework-components/execution';\nimport { postgresTargetDescriptorMeta } from '../core/descriptor-meta';\n\nexport interface PostgresRuntimeTargetInstance extends RuntimeTargetInstance<'sql', 'postgres'> {}\n\n/**\n * Target-postgres deliberately does NOT import `SqlRuntimeTargetDescriptor` from `@prisma-next/sql-runtime`. The target package is a control-plane residence and must not pull the SQL execution-plane package into its dependency closure. The runtime descriptor here is shaped to satisfy the framework's `RuntimeTargetDescriptor` plus the structural `SqlStaticContributions` (`codecs:` returning a descriptor list) that\n * `@prisma-next/sql-runtime` consumers narrow to at composition time.\n *\n * The target itself contributes no codecs — postgres-specific codecs ship from the postgres adapter and from extension packs (pgvector, arktype-json, etc.).\n */\nconst postgresRuntimeTargetDescriptor: RuntimeTargetDescriptor<\n 'sql',\n 'postgres',\n PostgresRuntimeTargetInstance\n> & {\n readonly codecs: () => readonly AnyCodecDescriptor[];\n} = {\n ...postgresTargetDescriptorMeta,\n codecs: () => [],\n create(): PostgresRuntimeTargetInstance {\n return {\n familyId: 'sql',\n targetId: 'postgres',\n };\n },\n};\n\nexport default postgresRuntimeTargetDescriptor;\n"],"mappings":";;;;;;;;AAeA,MAAM,kCAMF;CACF,GAAG;CACH,cAAc,EAAE;CAChB,SAAwC;EACtC,OAAO;GACL,UAAU;GACV,UAAU;GACX;;CAEJ"}
@@ -1,4 +1,4 @@
1
- import { t as PostgresPlanTargetDetails } from "./planner-target-details-DH-azLu-.mjs";
1
+ import { t as PostgresPlanTargetDetails } from "./planner-target-details-bVVcanWh.mjs";
2
2
  import { SqlMigrationPlanOperation } from "@prisma-next/family-sql/control";
3
3
  import { ReferentialAction } from "@prisma-next/sql-contract/types";
4
4
 
@@ -38,4 +38,4 @@ interface ForeignKeySpec {
38
38
  }
39
39
  //#endregion
40
40
  export { ForeignKeySpec as n, Op as r, ColumnSpec as t };
41
- //# sourceMappingURL=shared-Bxkt8pNO.d.mts.map
41
+ //# sourceMappingURL=shared-MpwjwAjM.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared-MpwjwAjM.d.mts","names":[],"sources":["../src/core/migrations/operations/shared.ts"],"mappings":";;;;;KAMY,EAAA,GAAK,yBAAA,CAA0B,yBAAA;;AAA3C;;;;;AAcA;;;;;;UAAiB,UAAA;EAAA,SACN,IAAA;EAAA,SACA,OAAA;EAAA,SACA,UAAA;EAAA,SACA,QAAA;AAAA;;;;;UAOM,cAAA;EAAA,SACN,IAAA;EAAA,SACA,OAAA;EAAA,SACA,UAAA;IAAA,SACE,KAAA;IAAA,SACA,OAAA;EAAA;EAAA,SAEF,QAAA,GAAW,iBAAA;EAAA,SACX,QAAA,GAAW,iBAAA;AAAA"}
@@ -11,6 +11,8 @@
11
11
  * home that both adapters can depend on without crossing planes.
12
12
  */
13
13
  var SqlEscapeError = class extends Error {
14
+ value;
15
+ kind;
14
16
  constructor(message, value, kind) {
15
17
  super(message);
16
18
  this.value = value;
@@ -70,7 +72,7 @@ function qualifyName(schemaName, objectName) {
70
72
  function validateEnumValueLength(value, enumTypeName) {
71
73
  if (value.length > MAX_IDENTIFIER_LENGTH) throw new SqlEscapeError(`Enum value "${value.slice(0, 20)}..." for type "${enumTypeName}" exceeds PostgreSQL's ${MAX_IDENTIFIER_LENGTH}-character label limit`, value, "literal");
72
74
  }
73
-
74
75
  //#endregion
75
76
  export { validateEnumValueLength as a, quoteIdentifier as i, escapeLiteral as n, qualifyName as r, SqlEscapeError as t };
76
- //# sourceMappingURL=sql-utils-r-Lw535w.mjs.map
77
+
78
+ //# sourceMappingURL=sql-utils-CggjWNij.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sql-utils-CggjWNij.mjs","names":[],"sources":["../src/core/sql-utils.ts"],"sourcesContent":["/**\n * Shared SQL utility functions for the Postgres target.\n *\n * These functions handle safe SQL identifier and literal escaping\n * with security validations to prevent injection and encoding issues.\n *\n * They live in `target-postgres` because both the control adapter (used at\n * emit time) and the runtime adapter (used at execute time) need the same\n * escaping/validation behavior, and the target package is the natural shared\n * home that both adapters can depend on without crossing planes.\n */\n\nexport class SqlEscapeError extends Error {\n constructor(\n message: string,\n public readonly value: string,\n public readonly kind: 'identifier' | 'literal',\n ) {\n super(message);\n this.name = 'SqlEscapeError';\n }\n}\n\nconst MAX_IDENTIFIER_LENGTH = 63;\n\n/**\n * Validates and quotes a PostgreSQL identifier (table, column, type, schema names).\n *\n * Security validations:\n * - Rejects null bytes which could cause truncation or unexpected behavior\n * - Rejects empty identifiers\n * - Warns on identifiers exceeding PostgreSQL's 63-character limit\n *\n * @throws {SqlEscapeError} If the identifier contains null bytes or is empty\n */\nexport function quoteIdentifier(identifier: string): string {\n if (identifier.length === 0) {\n throw new SqlEscapeError('Identifier cannot be empty', identifier, 'identifier');\n }\n if (identifier.includes('\\0')) {\n throw new SqlEscapeError(\n 'Identifier cannot contain null bytes',\n identifier.replace(/\\0/g, '\\\\0'),\n 'identifier',\n );\n }\n if (identifier.length > MAX_IDENTIFIER_LENGTH) {\n console.warn(\n `Identifier \"${identifier.slice(0, 20)}...\" exceeds PostgreSQL's ${MAX_IDENTIFIER_LENGTH}-character limit and will be truncated`,\n );\n }\n return `\"${identifier.replace(/\"/g, '\"\"')}\"`;\n}\n\n/**\n * Escapes a string literal for safe use in SQL statements.\n *\n * Security validations:\n * - Rejects null bytes which could cause truncation or unexpected behavior\n *\n * Note: This assumes PostgreSQL's `standard_conforming_strings` is ON (default since PG 9.1).\n * Backslashes are treated as literal characters, not escape sequences.\n *\n * @throws {SqlEscapeError} If the value contains null bytes\n */\nexport function escapeLiteral(value: string): string {\n if (value.includes('\\0')) {\n throw new SqlEscapeError(\n 'Literal value cannot contain null bytes',\n value.replace(/\\0/g, '\\\\0'),\n 'literal',\n );\n }\n return value.replace(/'/g, \"''\");\n}\n\n/**\n * Builds a qualified name (schema.object) with proper quoting.\n */\nexport function qualifyName(schemaName: string, objectName: string): string {\n return `${quoteIdentifier(schemaName)}.${quoteIdentifier(objectName)}`;\n}\n\n/**\n * Validates that an enum value doesn't exceed PostgreSQL's label length limit.\n *\n * PostgreSQL enum labels have a maximum length of NAMEDATALEN-1 (63 bytes by default).\n * Unlike identifiers, enum labels that exceed this limit cause an error rather than\n * silent truncation.\n *\n * @param value - The enum value to validate\n * @param enumTypeName - Name of the enum type (for error messages)\n * @throws {SqlEscapeError} If the value exceeds the maximum length\n */\nexport function validateEnumValueLength(value: string, enumTypeName: string): void {\n if (value.length > MAX_IDENTIFIER_LENGTH) {\n throw new SqlEscapeError(\n `Enum value \"${value.slice(0, 20)}...\" for type \"${enumTypeName}\" exceeds PostgreSQL's ` +\n `${MAX_IDENTIFIER_LENGTH}-character label limit`,\n value,\n 'literal',\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;AAYA,IAAa,iBAAb,cAAoC,MAAM;CAGtB;CACA;CAHlB,YACE,SACA,OACA,MACA;EACA,MAAM,QAAQ;EAHE,KAAA,QAAA;EACA,KAAA,OAAA;EAGhB,KAAK,OAAO;;;AAIhB,MAAM,wBAAwB;;;;;;;;;;;AAY9B,SAAgB,gBAAgB,YAA4B;CAC1D,IAAI,WAAW,WAAW,GACxB,MAAM,IAAI,eAAe,8BAA8B,YAAY,aAAa;CAElF,IAAI,WAAW,SAAS,KAAK,EAC3B,MAAM,IAAI,eACR,wCACA,WAAW,QAAQ,OAAO,MAAM,EAChC,aACD;CAEH,IAAI,WAAW,SAAS,uBACtB,QAAQ,KACN,eAAe,WAAW,MAAM,GAAG,GAAG,CAAC,4BAA4B,sBAAsB,wCAC1F;CAEH,OAAO,IAAI,WAAW,QAAQ,MAAM,OAAK,CAAC;;;;;;;;;;;;;AAc5C,SAAgB,cAAc,OAAuB;CACnD,IAAI,MAAM,SAAS,KAAK,EACtB,MAAM,IAAI,eACR,2CACA,MAAM,QAAQ,OAAO,MAAM,EAC3B,UACD;CAEH,OAAO,MAAM,QAAQ,MAAM,KAAK;;;;;AAMlC,SAAgB,YAAY,YAAoB,YAA4B;CAC1E,OAAO,GAAG,gBAAgB,WAAW,CAAC,GAAG,gBAAgB,WAAW;;;;;;;;;;;;;AActE,SAAgB,wBAAwB,OAAe,cAA4B;CACjF,IAAI,MAAM,SAAS,uBACjB,MAAM,IAAI,eACR,eAAe,MAAM,MAAM,GAAG,GAAG,CAAC,iBAAiB,aAAa,yBAC3D,sBAAsB,yBAC3B,OACA,UACD"}
@@ -1 +1 @@
1
- {"version":3,"file":"sql-utils.d.mts","names":[],"sources":["../src/core/sql-utils.ts"],"sourcesContent":[],"mappings":";;AAYA;AAuBA;AA8BA;AAcA;AAeA;;;;;;cAlFa,cAAA,SAAuB,KAAA;;;;;;;;;;;;;;;iBAuBpB,eAAA;;;;;;;;;;;;iBA8BA,aAAA;;;;iBAcA,WAAA;;;;;;;;;;;;iBAeA,uBAAA"}
1
+ {"version":3,"file":"sql-utils.d.mts","names":[],"sources":["../src/core/sql-utils.ts"],"mappings":";;AAYA;;;;;;;;;;cAAa,cAAA,SAAuB,KAAA;EAAA,SAGhB,KAAA;EAAA,SACA,IAAA;cAFhB,OAAA,UACgB,KAAA,UACA,IAAA;AAAA;;;;AAiDpB;;;;;AAcA;;iBA5CgB,eAAA,CAAgB,UAAA;;;AA2DhC;;;;;;;;;iBA7BgB,aAAA,CAAc,KAAA;;;;iBAcd,WAAA,CAAY,UAAA,UAAoB,UAAA;;;;;;;;;;;;iBAehC,uBAAA,CAAwB,KAAA,UAAe,YAAA"}
@@ -1,3 +1,2 @@
1
- import { a as validateEnumValueLength, i as quoteIdentifier, n as escapeLiteral, r as qualifyName, t as SqlEscapeError } from "./sql-utils-r-Lw535w.mjs";
2
-
3
- export { SqlEscapeError, escapeLiteral, qualifyName, quoteIdentifier, validateEnumValueLength };
1
+ import { a as validateEnumValueLength, i as quoteIdentifier, n as escapeLiteral, r as qualifyName, t as SqlEscapeError } from "./sql-utils-CggjWNij.mjs";
2
+ export { SqlEscapeError, escapeLiteral, qualifyName, quoteIdentifier, validateEnumValueLength };