@prisma-next/target-postgres 0.4.1 → 0.4.2

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 (178) hide show
  1. package/dist/codec-ids-CojIXVf9.mjs +29 -0
  2. package/dist/codec-ids-CojIXVf9.mjs.map +1 -0
  3. package/dist/codec-ids.d.mts +28 -0
  4. package/dist/codec-ids.d.mts.map +1 -0
  5. package/dist/codec-ids.mjs +3 -0
  6. package/dist/codec-types.d.mts +42 -0
  7. package/dist/codec-types.d.mts.map +1 -0
  8. package/dist/codec-types.mjs +3 -0
  9. package/dist/codecs-BoahtY_Q.mjs +385 -0
  10. package/dist/codecs-BoahtY_Q.mjs.map +1 -0
  11. package/dist/codecs-D-F2KJqt.d.mts +299 -0
  12. package/dist/codecs-D-F2KJqt.d.mts.map +1 -0
  13. package/dist/codecs.d.mts +2 -0
  14. package/dist/codecs.mjs +3 -0
  15. package/dist/control.d.mts +1 -1
  16. package/dist/control.mjs +9 -1982
  17. package/dist/control.mjs.map +1 -1
  18. package/dist/data-transform-CxFRBIUp.d.mts +32 -0
  19. package/dist/data-transform-CxFRBIUp.d.mts.map +1 -0
  20. package/dist/data-transform-VfEGzXWt.mjs +39 -0
  21. package/dist/data-transform-VfEGzXWt.mjs.map +1 -0
  22. package/dist/data-transform.d.mts +2 -0
  23. package/dist/data-transform.mjs +3 -0
  24. package/dist/default-normalizer-DNOpRoOF.mjs +131 -0
  25. package/dist/default-normalizer-DNOpRoOF.mjs.map +1 -0
  26. package/dist/default-normalizer.d.mts +19 -0
  27. package/dist/default-normalizer.d.mts.map +1 -0
  28. package/dist/default-normalizer.mjs +3 -0
  29. package/dist/{descriptor-meta-DkvCmY98.mjs → descriptor-meta-BVoVtyp-.mjs} +1 -1
  30. package/dist/{descriptor-meta-DkvCmY98.mjs.map → descriptor-meta-BVoVtyp-.mjs.map} +1 -1
  31. package/dist/errors-AFvEPZ1R.mjs +34 -0
  32. package/dist/errors-AFvEPZ1R.mjs.map +1 -0
  33. package/dist/errors.d.mts +27 -0
  34. package/dist/errors.d.mts.map +1 -0
  35. package/dist/errors.mjs +3 -0
  36. package/dist/issue-planner-CFjB0_oO.mjs +879 -0
  37. package/dist/issue-planner-CFjB0_oO.mjs.map +1 -0
  38. package/dist/issue-planner.d.mts +85 -0
  39. package/dist/issue-planner.d.mts.map +1 -0
  40. package/dist/issue-planner.mjs +3 -0
  41. package/dist/migration.d.mts +5 -79
  42. package/dist/migration.d.mts.map +1 -1
  43. package/dist/migration.mjs +6 -428
  44. package/dist/migration.mjs.map +1 -1
  45. package/dist/native-type-normalizer-CInai_oY.mjs +38 -0
  46. package/dist/native-type-normalizer-CInai_oY.mjs.map +1 -0
  47. package/dist/native-type-normalizer.d.mts +18 -0
  48. package/dist/native-type-normalizer.d.mts.map +1 -0
  49. package/dist/native-type-normalizer.mjs +3 -0
  50. package/dist/op-factory-call-BKlruaiC.mjs +605 -0
  51. package/dist/op-factory-call-BKlruaiC.mjs.map +1 -0
  52. package/dist/op-factory-call-C3bWXKSP.d.mts +304 -0
  53. package/dist/op-factory-call-C3bWXKSP.d.mts.map +1 -0
  54. package/dist/op-factory-call.d.mts +3 -0
  55. package/dist/op-factory-call.mjs +3 -0
  56. package/dist/pack.d.mts +1 -1
  57. package/dist/pack.mjs +1 -1
  58. package/dist/planner-CLUvVhUN.mjs +98 -0
  59. package/dist/planner-CLUvVhUN.mjs.map +1 -0
  60. package/dist/planner-ddl-builders-Dxvw1LHw.mjs +132 -0
  61. package/dist/planner-ddl-builders-Dxvw1LHw.mjs.map +1 -0
  62. package/dist/planner-ddl-builders.d.mts +22 -0
  63. package/dist/planner-ddl-builders.d.mts.map +1 -0
  64. package/dist/planner-ddl-builders.mjs +3 -0
  65. package/dist/planner-identity-values-Dju-o5GF.mjs +91 -0
  66. package/dist/planner-identity-values-Dju-o5GF.mjs.map +1 -0
  67. package/dist/planner-identity-values.d.mts +20 -0
  68. package/dist/planner-identity-values.d.mts.map +1 -0
  69. package/dist/planner-identity-values.mjs +3 -0
  70. package/dist/planner-produced-postgres-migration-CRRTno6Z.d.mts +20 -0
  71. package/dist/planner-produced-postgres-migration-CRRTno6Z.d.mts.map +1 -0
  72. package/dist/planner-produced-postgres-migration-DSSPq8QS.mjs +33 -0
  73. package/dist/planner-produced-postgres-migration-DSSPq8QS.mjs.map +1 -0
  74. package/dist/planner-produced-postgres-migration.d.mts +5 -0
  75. package/dist/planner-produced-postgres-migration.mjs +3 -0
  76. package/dist/planner-schema-lookup-B7lkypwn.mjs +29 -0
  77. package/dist/planner-schema-lookup-B7lkypwn.mjs.map +1 -0
  78. package/dist/planner-schema-lookup.d.mts +22 -0
  79. package/dist/planner-schema-lookup.d.mts.map +1 -0
  80. package/dist/planner-schema-lookup.mjs +3 -0
  81. package/dist/planner-sql-checks-7jkgm9TX.mjs +241 -0
  82. package/dist/planner-sql-checks-7jkgm9TX.mjs.map +1 -0
  83. package/dist/planner-sql-checks.d.mts +55 -0
  84. package/dist/planner-sql-checks.d.mts.map +1 -0
  85. package/dist/planner-sql-checks.mjs +3 -0
  86. package/dist/{planner-target-details-MXb3oeul.d.mts → planner-target-details-DH-azLu-.d.mts} +1 -1
  87. package/dist/{planner-target-details-MXb3oeul.d.mts.map → planner-target-details-DH-azLu-.d.mts.map} +1 -1
  88. package/dist/planner-target-details.d.mts +2 -0
  89. package/dist/planner-target-details.mjs +1 -0
  90. package/dist/planner.d.mts +68 -0
  91. package/dist/planner.d.mts.map +1 -0
  92. package/dist/planner.mjs +4 -0
  93. package/dist/postgres-migration-BjA3Zmts.d.mts +50 -0
  94. package/dist/postgres-migration-BjA3Zmts.d.mts.map +1 -0
  95. package/dist/postgres-migration-qtmtbONe.mjs +52 -0
  96. package/dist/postgres-migration-qtmtbONe.mjs.map +1 -0
  97. package/dist/render-ops-D6_DHdOK.mjs +8 -0
  98. package/dist/render-ops-D6_DHdOK.mjs.map +1 -0
  99. package/dist/render-ops.d.mts +11 -0
  100. package/dist/render-ops.d.mts.map +1 -0
  101. package/dist/render-ops.mjs +3 -0
  102. package/dist/render-typescript-1rF_SB4g.mjs +85 -0
  103. package/dist/render-typescript-1rF_SB4g.mjs.map +1 -0
  104. package/dist/render-typescript.d.mts +15 -0
  105. package/dist/render-typescript.d.mts.map +1 -0
  106. package/dist/render-typescript.mjs +3 -0
  107. package/dist/runtime.d.mts +15 -3
  108. package/dist/runtime.d.mts.map +1 -1
  109. package/dist/runtime.mjs +10 -1
  110. package/dist/runtime.mjs.map +1 -1
  111. package/dist/shared-Bxkt8pNO.d.mts +41 -0
  112. package/dist/shared-Bxkt8pNO.d.mts.map +1 -0
  113. package/dist/sql-utils-r-Lw535w.mjs +76 -0
  114. package/dist/sql-utils-r-Lw535w.mjs.map +1 -0
  115. package/dist/sql-utils.d.mts +59 -0
  116. package/dist/sql-utils.d.mts.map +1 -0
  117. package/dist/sql-utils.mjs +3 -0
  118. package/dist/statement-builders-BPnmt6wx.mjs +116 -0
  119. package/dist/statement-builders-BPnmt6wx.mjs.map +1 -0
  120. package/dist/statement-builders.d.mts +23 -0
  121. package/dist/statement-builders.d.mts.map +1 -0
  122. package/dist/statement-builders.mjs +3 -0
  123. package/dist/tables-BmdW_FWO.mjs +477 -0
  124. package/dist/tables-BmdW_FWO.mjs.map +1 -0
  125. package/dist/types-ClK03Ojd.d.mts +10 -0
  126. package/dist/types-ClK03Ojd.d.mts.map +1 -0
  127. package/dist/types.d.mts +2 -0
  128. package/dist/types.mjs +1 -0
  129. package/package.json +40 -20
  130. package/src/core/codec-ids.ts +30 -0
  131. package/src/core/codecs.ts +645 -0
  132. package/src/core/default-normalizer.ts +131 -0
  133. package/src/core/descriptor-meta.ts +1 -1
  134. package/src/core/errors.ts +33 -0
  135. package/src/core/json-schema-type-expression.ts +131 -0
  136. package/src/core/migrations/op-factory-call.ts +1 -5
  137. package/src/core/migrations/operations/columns.ts +1 -1
  138. package/src/core/migrations/operations/constraints.ts +1 -1
  139. package/src/core/migrations/operations/data-transform.ts +27 -21
  140. package/src/core/migrations/operations/dependencies.ts +1 -1
  141. package/src/core/migrations/operations/enums.ts +1 -1
  142. package/src/core/migrations/operations/indexes.ts +1 -1
  143. package/src/core/migrations/operations/shared.ts +1 -1
  144. package/src/core/migrations/operations/tables.ts +1 -1
  145. package/src/core/migrations/planner-ddl-builders.ts +1 -1
  146. package/src/core/migrations/planner-recipes.ts +1 -1
  147. package/src/core/migrations/planner-sql-checks.ts +1 -1
  148. package/src/core/migrations/planner.ts +2 -4
  149. package/src/core/migrations/postgres-migration.ts +54 -1
  150. package/src/core/migrations/render-typescript.ts +22 -12
  151. package/src/core/migrations/runner.ts +2 -4
  152. package/src/core/native-type-normalizer.ts +49 -0
  153. package/src/core/sql-utils.ts +104 -0
  154. package/src/exports/codec-ids.ts +1 -0
  155. package/src/exports/codec-types.ts +51 -0
  156. package/src/exports/codecs.ts +2 -0
  157. package/src/exports/data-transform.ts +1 -0
  158. package/src/exports/default-normalizer.ts +1 -0
  159. package/src/exports/errors.ts +1 -0
  160. package/src/exports/issue-planner.ts +1 -0
  161. package/src/exports/migration.ts +6 -0
  162. package/src/exports/native-type-normalizer.ts +1 -0
  163. package/src/exports/op-factory-call.ts +25 -0
  164. package/src/exports/planner-ddl-builders.ts +8 -0
  165. package/src/exports/planner-identity-values.ts +1 -0
  166. package/src/exports/planner-produced-postgres-migration.ts +1 -0
  167. package/src/exports/planner-schema-lookup.ts +6 -0
  168. package/src/exports/planner-sql-checks.ts +11 -0
  169. package/src/exports/planner-target-details.ts +1 -0
  170. package/src/exports/planner.ts +1 -0
  171. package/src/exports/render-ops.ts +1 -0
  172. package/src/exports/render-typescript.ts +1 -0
  173. package/src/exports/runtime.ts +19 -4
  174. package/src/exports/sql-utils.ts +7 -0
  175. package/src/exports/statement-builders.ts +7 -0
  176. package/src/exports/types.ts +1 -0
  177. package/dist/postgres-migration-BsHJHV9O.mjs +0 -2793
  178. package/dist/postgres-migration-BsHJHV9O.mjs.map +0 -1
@@ -0,0 +1,68 @@
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";
5
+ import { MigrationOperationPolicy, SqlPlannerFailureResult } from "@prisma-next/family-sql/control";
6
+ import { MigrationPlanWithAuthoringSurface, MigrationPlanner, MigrationScaffoldContext } from "@prisma-next/framework-components/control";
7
+ import { TargetBoundComponentDescriptor } from "@prisma-next/framework-components/components";
8
+
9
+ //#region src/core/migrations/planner.d.ts
10
+ interface PlannerConfig {
11
+ readonly defaultSchema: string;
12
+ }
13
+ declare function createPostgresMigrationPlanner(config?: Partial<PlannerConfig>): PostgresMigrationPlanner;
14
+ /**
15
+ * Result of `PostgresMigrationPlanner.plan()`. A discriminated union whose
16
+ * success variant carries a `TypeScriptRenderablePostgresMigration` — a
17
+ * migration object that both the CLI (via `renderTypeScript()`) and the
18
+ * SQL-typed callers (via `operations`, `describe()`, etc.) consume
19
+ * uniformly.
20
+ */
21
+ type PostgresPlanResult = {
22
+ readonly kind: 'success';
23
+ readonly plan: TypeScriptRenderablePostgresMigration;
24
+ } | SqlPlannerFailureResult;
25
+ /**
26
+ * Postgres migration planner — a thin wrapper over `planIssues`.
27
+ *
28
+ * `plan()` verifies the live schema against the target contract (producing
29
+ * `SchemaIssue[]`) and delegates to `planIssues` with the unified
30
+ * `postgresPlannerStrategies` list: enum-change, NOT-NULL backfill,
31
+ * type-change, nullable-tightening, codec-hook storage types,
32
+ * component-declared dependency installs, and shared-temp-default /
33
+ * empty-table-guarded NOT-NULL add-column. The same strategy list runs for
34
+ * `migration plan`, `db update`, and `db init`; behavior diverges purely on
35
+ * `policy.allowedOperationClasses` (the data-safe strategies short-circuit
36
+ * when `'data'` is excluded). The issue planner applies operation-class
37
+ * policy gates and emits a single `PostgresOpFactoryCall[]` that drives both
38
+ * the runtime-ops view (via `renderOps`) and the `renderTypeScript()`
39
+ * authoring surface.
40
+ */
41
+ declare class PostgresMigrationPlanner implements MigrationPlanner<'sql', 'postgres'> {
42
+ private readonly config;
43
+ constructor(config: PlannerConfig);
44
+ plan(options: {
45
+ readonly contract: unknown;
46
+ readonly schema: unknown;
47
+ readonly policy: MigrationOperationPolicy;
48
+ readonly fromHash?: string;
49
+ /**
50
+ * 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.
56
+ */
57
+ readonly fromContract?: unknown;
58
+ readonly schemaName?: string;
59
+ readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;
60
+ }): PostgresPlanResult;
61
+ emptyMigration(context: MigrationScaffoldContext): MigrationPlanWithAuthoringSurface;
62
+ private planSql;
63
+ private ensureAdditivePolicy;
64
+ private collectSchemaIssues;
65
+ }
66
+ //#endregion
67
+ export { createPostgresMigrationPlanner };
68
+ //# sourceMappingURL=planner.d.mts.map
@@ -0,0 +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"}
@@ -0,0 +1,4 @@
1
+ import "./issue-planner-CFjB0_oO.mjs";
2
+ import { t as createPostgresMigrationPlanner } from "./planner-CLUvVhUN.mjs";
3
+
4
+ export { createPostgresMigrationPlanner };
@@ -0,0 +1,50 @@
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";
3
+ import { Migration } from "@prisma-next/family-sql/migration";
4
+ import { Contract } from "@prisma-next/contract/types";
5
+ import { SqlStorage } from "@prisma-next/sql-contract/types";
6
+ import { SqlControlAdapter } from "@prisma-next/family-sql/control-adapter";
7
+ import { ControlStack } from "@prisma-next/framework-components/control";
8
+
9
+ //#region src/core/migrations/postgres-migration.d.ts
10
+
11
+ /**
12
+ * Target-owned base class for Postgres migrations.
13
+ *
14
+ * Fixes the `SqlMigration` generic to `PostgresPlanTargetDetails` and the
15
+ * abstract `targetId` to the Postgres target-id string literal, so both
16
+ * user-authored migrations and renderer-generated scaffolds (the output of
17
+ * `renderCallsToTypeScript`) can extend `PostgresMigration` directly without
18
+ * redeclaring target-local identity.
19
+ *
20
+ * Mirrors `MongoMigration` in `@prisma-next/family-mongo`: the renderer
21
+ * emits `extends Migration` against a target-specific re-export of this
22
+ * class from `@prisma-next/target-postgres/migration`, keeping the
23
+ * authoring surface target-scoped rather than family-scoped.
24
+ *
25
+ * The constructor materializes a single Postgres `SqlControlAdapter` from
26
+ * `stack.adapter.create(stack)` and stores it; the protected `dataTransform`
27
+ * instance method forwards to the free `dataTransform` factory with that
28
+ * stored adapter, so user migrations can write `this.dataTransform(...)`
29
+ * without threading the adapter through every call.
30
+ */
31
+ declare abstract class PostgresMigration extends Migration<PostgresPlanTargetDetails, 'postgres'> {
32
+ readonly targetId: "postgres";
33
+ /**
34
+ * Materialized Postgres control adapter, created once per migration
35
+ * instance from the injected stack. `undefined` only when the migration
36
+ * was instantiated without a stack (test fixtures); `dataTransform`
37
+ * throws in that case to surface the misuse.
38
+ */
39
+ protected readonly controlAdapter: SqlControlAdapter<'postgres'> | undefined;
40
+ constructor(stack?: ControlStack<'sql', 'postgres'>);
41
+ /**
42
+ * Instance-method wrapper around the free `dataTransform` factory that
43
+ * supplies the stored control adapter. Authors call this from inside
44
+ * `get operations()`; the adapter argument is hidden from the call site.
45
+ */
46
+ protected dataTransform<TContract extends Contract<SqlStorage>>(contract: TContract, name: string, options: DataTransformOptions): PostgresDataTransformOperation;
47
+ }
48
+ //#endregion
49
+ export { PostgresMigration as t };
50
+ //# sourceMappingURL=postgres-migration-BjA3Zmts.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-migration-BjA3Zmts.d.mts","names":[],"sources":["../src/core/migrations/postgres-migration.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;AAiCA;;;;;;;;;;;;;;;;;;uBAAsB,iBAAA,SAA0B,UAC9C;;;;;;;;qCAWmC;sBAEf;;;;;;4CAesB,SAAS,uBACvC,kCAED,uBACR"}
@@ -0,0 +1,52 @@
1
+ import { t as errorPostgresMigrationStackMissing } from "./errors-AFvEPZ1R.mjs";
2
+ import { t as dataTransform } from "./data-transform-VfEGzXWt.mjs";
3
+ import { Migration } from "@prisma-next/family-sql/migration";
4
+
5
+ //#region src/core/migrations/postgres-migration.ts
6
+ /**
7
+ * Target-owned base class for Postgres migrations.
8
+ *
9
+ * Fixes the `SqlMigration` generic to `PostgresPlanTargetDetails` and the
10
+ * abstract `targetId` to the Postgres target-id string literal, so both
11
+ * user-authored migrations and renderer-generated scaffolds (the output of
12
+ * `renderCallsToTypeScript`) can extend `PostgresMigration` directly without
13
+ * redeclaring target-local identity.
14
+ *
15
+ * Mirrors `MongoMigration` in `@prisma-next/family-mongo`: the renderer
16
+ * emits `extends Migration` against a target-specific re-export of this
17
+ * class from `@prisma-next/target-postgres/migration`, keeping the
18
+ * authoring surface target-scoped rather than family-scoped.
19
+ *
20
+ * The constructor materializes a single Postgres `SqlControlAdapter` from
21
+ * `stack.adapter.create(stack)` and stores it; the protected `dataTransform`
22
+ * instance method forwards to the free `dataTransform` factory with that
23
+ * stored adapter, so user migrations can write `this.dataTransform(...)`
24
+ * without threading the adapter through every call.
25
+ */
26
+ var PostgresMigration = class extends Migration {
27
+ targetId = "postgres";
28
+ /**
29
+ * Materialized Postgres control adapter, created once per migration
30
+ * instance from the injected stack. `undefined` only when the migration
31
+ * was instantiated without a stack (test fixtures); `dataTransform`
32
+ * throws in that case to surface the misuse.
33
+ */
34
+ controlAdapter;
35
+ constructor(stack) {
36
+ super(stack);
37
+ this.controlAdapter = stack?.adapter ? stack.adapter.create(stack) : void 0;
38
+ }
39
+ /**
40
+ * Instance-method wrapper around the free `dataTransform` factory that
41
+ * supplies the stored control adapter. Authors call this from inside
42
+ * `get operations()`; the adapter argument is hidden from the call site.
43
+ */
44
+ dataTransform(contract, name, options) {
45
+ if (!this.controlAdapter) throw errorPostgresMigrationStackMissing();
46
+ return dataTransform(contract, name, options, this.controlAdapter);
47
+ }
48
+ };
49
+
50
+ //#endregion
51
+ export { PostgresMigration as t };
52
+ //# sourceMappingURL=postgres-migration-qtmtbONe.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-migration-qtmtbONe.mjs","names":["SqlMigration"],"sources":["../src/core/migrations/postgres-migration.ts"],"sourcesContent":["import type { Contract } from '@prisma-next/contract/types';\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 {\n type DataTransformOptions,\n dataTransform,\n type PostgresDataTransformOperation,\n} 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 ): PostgresDataTransformOperation {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return dataTransform(contract, name, options, this.controlAdapter);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,IAAsB,oBAAtB,cAAgDA,UAG9C;CACA,AAAS,WAAW;;;;;;;CAQpB,AAAmB;CAEnB,YAAY,OAAyC;AACnD,QAAM,MAAM;AAIZ,OAAK,iBAAiB,OAAO,UACxB,MAAM,QAAQ,OAAO,MAAM,GAC5B;;;;;;;CAQN,AAAU,cACR,UACA,MACA,SACgC;AAChC,MAAI,CAAC,KAAK,eACR,OAAM,oCAAoC;AAE5C,SAAO,cAAc,UAAU,MAAM,SAAS,KAAK,eAAe"}
@@ -0,0 +1,8 @@
1
+ //#region src/core/migrations/render-ops.ts
2
+ function renderOps(calls) {
3
+ return calls.map((c) => c.toOp());
4
+ }
5
+
6
+ //#endregion
7
+ export { renderOps as t };
8
+ //# sourceMappingURL=render-ops-D6_DHdOK.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-ops-D6_DHdOK.mjs","names":[],"sources":["../src/core/migrations/render-ops.ts"],"sourcesContent":["import type { SqlMigrationPlanOperation } from '@prisma-next/family-sql/control';\nimport type { PostgresOpFactoryCall } from './op-factory-call';\nimport type { PostgresPlanTargetDetails } from './planner-target-details';\n\ntype Op = SqlMigrationPlanOperation<PostgresPlanTargetDetails>;\n\nexport function renderOps(calls: readonly PostgresOpFactoryCall[]): Op[] {\n return calls.map((c) => c.toOp());\n}\n"],"mappings":";AAMA,SAAgB,UAAU,OAA+C;AACvE,QAAO,MAAM,KAAK,MAAM,EAAE,MAAM,CAAC"}
@@ -0,0 +1,11 @@
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";
4
+ import { SqlMigrationPlanOperation } from "@prisma-next/family-sql/control";
5
+
6
+ //#region src/core/migrations/render-ops.d.ts
7
+ type Op = SqlMigrationPlanOperation<PostgresPlanTargetDetails>;
8
+ declare function renderOps(calls: readonly PostgresOpFactoryCall[]): Op[];
9
+ //#endregion
10
+ export { renderOps };
11
+ //# sourceMappingURL=render-ops.d.mts.map
@@ -0,0 +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"}
@@ -0,0 +1,3 @@
1
+ import { t as renderOps } from "./render-ops-D6_DHdOK.mjs";
2
+
3
+ export { renderOps };
@@ -0,0 +1,85 @@
1
+ import { jsonToTsSource, renderImports } from "@prisma-next/ts-render";
2
+ import { detectScaffoldRuntime, shebangLineFor } from "@prisma-next/migration-tools/migration-ts";
3
+
4
+ //#region src/core/migrations/render-typescript.ts
5
+ /**
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
+ * Always-present base imports for the rendered scaffold. Both come from
17
+ * `@prisma-next/target-postgres/migration` so an authored Postgres
18
+ * `migration.ts` only needs a single dependency for its base class and
19
+ * its CLI entrypoint:
20
+ *
21
+ * - `Migration` — the target-owned re-export fixes the `SqlMigration`
22
+ * generic to `PostgresPlanTargetDetails` and the abstract `targetId`
23
+ * to `'postgres'`, so user-authored migrations don't need to thread
24
+ * target-details or redeclare `targetId`.
25
+ * - `MigrationCLI` — the migration-file CLI entrypoint, re-exported from
26
+ * `@prisma-next/cli/migration-cli`. Loads `prisma-next.config.ts`,
27
+ * assembles a `ControlStack`, and instantiates the migration class.
28
+ * The migration file owns this dependency directly: pulling CLI
29
+ * machinery in at script run time is acceptable because the script's
30
+ * whole purpose is to be invoked from the project that owns the
31
+ * config.
32
+ */
33
+ const BASE_IMPORTS = [{
34
+ moduleSpecifier: "@prisma-next/target-postgres/migration",
35
+ symbol: "Migration"
36
+ }, {
37
+ moduleSpecifier: "@prisma-next/target-postgres/migration",
38
+ symbol: "MigrationCLI"
39
+ }];
40
+ function renderCallsToTypeScript(calls, meta) {
41
+ const imports = buildImports(calls);
42
+ const operationsBody = calls.map((c) => c.renderTypeScript()).join(",\n");
43
+ return [
44
+ shebangLineFor(detectScaffoldRuntime()),
45
+ imports,
46
+ "",
47
+ "export default class M extends Migration {",
48
+ buildDescribeMethod(meta),
49
+ " override get operations() {",
50
+ " return [",
51
+ indent(operationsBody, 6),
52
+ " ];",
53
+ " }",
54
+ "}",
55
+ "",
56
+ "MigrationCLI.run(import.meta.url, M);",
57
+ ""
58
+ ].join("\n");
59
+ }
60
+ function buildImports(calls) {
61
+ const requirements = [...BASE_IMPORTS];
62
+ for (const call of calls) for (const req of call.importRequirements()) requirements.push(req);
63
+ return renderImports(requirements);
64
+ }
65
+ function buildDescribeMethod(meta) {
66
+ const lines = [];
67
+ lines.push(" override describe() {");
68
+ lines.push(" return {");
69
+ lines.push(` from: ${JSON.stringify(meta.from)},`);
70
+ lines.push(` to: ${JSON.stringify(meta.to)},`);
71
+ if (meta.kind) lines.push(` kind: ${JSON.stringify(meta.kind)},`);
72
+ if (meta.labels && meta.labels.length > 0) lines.push(` labels: ${jsonToTsSource(meta.labels)},`);
73
+ lines.push(" };");
74
+ lines.push(" }");
75
+ lines.push("");
76
+ return lines.join("\n");
77
+ }
78
+ function indent(text, spaces) {
79
+ const pad = " ".repeat(spaces);
80
+ return text.split("\n").map((line) => line.trim() ? `${pad}${line}` : line).join("\n");
81
+ }
82
+
83
+ //#endregion
84
+ export { renderCallsToTypeScript as t };
85
+ //# sourceMappingURL=render-typescript-1rF_SB4g.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-typescript-1rF_SB4g.mjs","names":["BASE_IMPORTS: readonly ImportRequirement[]","requirements: ImportRequirement[]","lines: string[]"],"sources":["../src/core/migrations/render-typescript.ts"],"sourcesContent":["/**\n * Polymorphic TypeScript emitter for the Postgres migration IR.\n *\n * Each `PostgresOpFactoryCall` 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 { detectScaffoldRuntime, shebangLineFor } from '@prisma-next/migration-tools/migration-ts';\nimport { type ImportRequirement, jsonToTsSource, renderImports } from '@prisma-next/ts-render';\nimport type { PostgresOpFactoryCall } from './op-factory-call';\n\nexport interface RenderMigrationMeta {\n readonly from: string;\n readonly to: string;\n readonly kind?: 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<PostgresOpFactoryCall>,\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<PostgresOpFactoryCall>): 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.kind) {\n lines.push(` kind: ${JSON.stringify(meta.kind)},`);\n }\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,MAAMA,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;AAEzE,QAAO;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,OAAqD;CACzE,MAAMC,eAAoC,CAAC,GAAG,aAAa;AAC3D,MAAK,MAAM,QAAQ,MACjB,MAAK,MAAM,OAAO,KAAK,oBAAoB,CACzC,cAAa,KAAK,IAAI;AAG1B,QAAO,cAAc,aAAa;;AAGpC,SAAS,oBAAoB,MAAmC;CAC9D,MAAMC,QAAkB,EAAE;AAC1B,OAAM,KAAK,0BAA0B;AACrC,OAAM,KAAK,eAAe;AAC1B,OAAM,KAAK,eAAe,KAAK,UAAU,KAAK,KAAK,CAAC,GAAG;AACvD,OAAM,KAAK,aAAa,KAAK,UAAU,KAAK,GAAG,CAAC,GAAG;AACnD,KAAI,KAAK,KACP,OAAM,KAAK,eAAe,KAAK,UAAU,KAAK,KAAK,CAAC,GAAG;AAEzD,KAAI,KAAK,UAAU,KAAK,OAAO,SAAS,EACtC,OAAM,KAAK,iBAAiB,eAAe,KAAK,OAAO,CAAC,GAAG;AAE7D,OAAM,KAAK,SAAS;AACpB,OAAM,KAAK,MAAM;AACjB,OAAM,KAAK,GAAG;AACd,QAAO,MAAM,KAAK,KAAK;;AAGzB,SAAS,OAAO,MAAc,QAAwB;CACpD,MAAM,MAAM,IAAI,OAAO,OAAO;AAC9B,QAAO,KACJ,MAAM,KAAK,CACX,KAAK,SAAU,KAAK,MAAM,GAAG,GAAG,MAAM,SAAS,KAAM,CACrD,KAAK,KAAK"}
@@ -0,0 +1,15 @@
1
+ import "./shared-Bxkt8pNO.mjs";
2
+ import { b as PostgresOpFactoryCall } from "./op-factory-call-C3bWXKSP.mjs";
3
+
4
+ //#region src/core/migrations/render-typescript.d.ts
5
+
6
+ interface RenderMigrationMeta {
7
+ readonly from: string;
8
+ readonly to: string;
9
+ readonly kind?: string;
10
+ readonly labels?: readonly string[];
11
+ }
12
+ declare function renderCallsToTypeScript(calls: ReadonlyArray<PostgresOpFactoryCall>, meta: RenderMigrationMeta): string;
13
+ //#endregion
14
+ export { renderCallsToTypeScript };
15
+ //# sourceMappingURL=render-typescript.d.mts.map
@@ -0,0 +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"}
@@ -0,0 +1,3 @@
1
+ import { t as renderCallsToTypeScript } from "./render-typescript-1rF_SB4g.mjs";
2
+
3
+ export { renderCallsToTypeScript };
@@ -1,9 +1,21 @@
1
- import { SqlRuntimeTargetDescriptor } from "@prisma-next/sql-runtime";
2
- import { RuntimeTargetInstance } from "@prisma-next/framework-components/execution";
1
+ import { createCodecRegistry } from "@prisma-next/sql-relational-core/ast";
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
- declare const postgresRuntimeTargetDescriptor: SqlRuntimeTargetDescriptor<'postgres', PostgresRuntimeTargetInstance>;
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
13
+ * `@prisma-next/sql-runtime` consumers narrow to at composition time.
14
+ */
15
+ declare const postgresRuntimeTargetDescriptor: RuntimeTargetDescriptor<'sql', 'postgres', PostgresRuntimeTargetInstance> & {
16
+ readonly codecs: () => ReturnType<typeof createCodecRegistry>;
17
+ readonly parameterizedCodecs: () => readonly never[];
18
+ };
7
19
  //#endregion
8
20
  export { PostgresRuntimeTargetInstance, postgresRuntimeTargetDescriptor as default };
9
21
  //# sourceMappingURL=runtime.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.mts","names":[],"sources":["../src/exports/runtime.ts"],"sourcesContent":[],"mappings":";;;;UAKiB,6BAAA,SAAsC;AAAvD,cAEM,+BAFyC,EAER,0BAFqC,CAAA,UAAA,EAI1E,6BAJ0E,CAAA"}
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"}
package/dist/runtime.mjs CHANGED
@@ -1,7 +1,16 @@
1
- import { t as postgresTargetDescriptorMeta } from "./descriptor-meta-DkvCmY98.mjs";
1
+ import { t as postgresTargetDescriptorMeta } from "./descriptor-meta-BVoVtyp-.mjs";
2
2
  import { createCodecRegistry } from "@prisma-next/sql-relational-core/ast";
3
3
 
4
4
  //#region src/exports/runtime.ts
5
+ /**
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
12
+ * `@prisma-next/sql-runtime` consumers narrow to at composition time.
13
+ */
5
14
  const postgresRuntimeTargetDescriptor = {
6
15
  ...postgresTargetDescriptorMeta,
7
16
  codecs: () => createCodecRegistry(),
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.mjs","names":["postgresRuntimeTargetDescriptor: SqlRuntimeTargetDescriptor<\n 'postgres',\n PostgresRuntimeTargetInstance\n>"],"sources":["../src/exports/runtime.ts"],"sourcesContent":["import type { RuntimeTargetInstance } from '@prisma-next/framework-components/execution';\nimport { createCodecRegistry } from '@prisma-next/sql-relational-core/ast';\nimport type { SqlRuntimeTargetDescriptor } from '@prisma-next/sql-runtime';\nimport { postgresTargetDescriptorMeta } from '../core/descriptor-meta';\n\nexport interface PostgresRuntimeTargetInstance extends RuntimeTargetInstance<'sql', 'postgres'> {}\n\nconst postgresRuntimeTargetDescriptor: SqlRuntimeTargetDescriptor<\n 'postgres',\n PostgresRuntimeTargetInstance\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":";;;;AAOA,MAAMA,kCAGF;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":["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"}
@@ -0,0 +1,41 @@
1
+ import { t as PostgresPlanTargetDetails } from "./planner-target-details-DH-azLu-.mjs";
2
+ import { SqlMigrationPlanOperation } from "@prisma-next/family-sql/control";
3
+ import { ReferentialAction } from "@prisma-next/sql-contract/types";
4
+
5
+ //#region src/core/migrations/operations/shared.d.ts
6
+ type Op = SqlMigrationPlanOperation<PostgresPlanTargetDetails>;
7
+ /**
8
+ * Literal-args shape for a column definition consumed by `createTable` and
9
+ * `addColumn`. Fully materialized: codec expansion and default rendering have
10
+ * already happened in the wrapper.
11
+ *
12
+ * - `typeSql` is the column's DDL type string (e.g. `"integer"`, `"SERIAL"`,
13
+ * `"varchar(100)"`), already produced by `buildColumnTypeSql` in the
14
+ * call-factory wrapper.
15
+ * - `defaultSql` is the full `DEFAULT …` clause (e.g. `"DEFAULT 42"`) or an
16
+ * empty string when the column has no default, matching
17
+ * `buildColumnDefaultSql`'s output.
18
+ */
19
+ interface ColumnSpec {
20
+ readonly name: string;
21
+ readonly typeSql: string;
22
+ readonly defaultSql: string;
23
+ readonly nullable: boolean;
24
+ }
25
+ /**
26
+ * Literal-args shape for a foreign key definition. The referenced table is
27
+ * assumed to live in the same schema as the constrained table.
28
+ */
29
+ interface ForeignKeySpec {
30
+ readonly name: string;
31
+ readonly columns: readonly string[];
32
+ readonly references: {
33
+ readonly table: string;
34
+ readonly columns: readonly string[];
35
+ };
36
+ readonly onDelete?: ReferentialAction;
37
+ readonly onUpdate?: ReferentialAction;
38
+ }
39
+ //#endregion
40
+ export { ForeignKeySpec as n, Op as r, ColumnSpec as t };
41
+ //# sourceMappingURL=shared-Bxkt8pNO.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared-Bxkt8pNO.d.mts","names":[],"sources":["../src/core/migrations/operations/shared.ts"],"sourcesContent":[],"mappings":";;;;;KAMY,EAAA,GAAK,0BAA0B;;AAA3C;AAcA;AAWA;;;;;;;;;UAXiB,UAAA;;;;;;;;;;UAWA,cAAA;;;;;;;sBAOK;sBACA"}
@@ -0,0 +1,76 @@
1
+ //#region src/core/sql-utils.ts
2
+ /**
3
+ * Shared SQL utility functions for the Postgres target.
4
+ *
5
+ * These functions handle safe SQL identifier and literal escaping
6
+ * with security validations to prevent injection and encoding issues.
7
+ *
8
+ * They live in `target-postgres` because both the control adapter (used at
9
+ * emit time) and the runtime adapter (used at execute time) need the same
10
+ * escaping/validation behavior, and the target package is the natural shared
11
+ * home that both adapters can depend on without crossing planes.
12
+ */
13
+ var SqlEscapeError = class extends Error {
14
+ constructor(message, value, kind) {
15
+ super(message);
16
+ this.value = value;
17
+ this.kind = kind;
18
+ this.name = "SqlEscapeError";
19
+ }
20
+ };
21
+ const MAX_IDENTIFIER_LENGTH = 63;
22
+ /**
23
+ * Validates and quotes a PostgreSQL identifier (table, column, type, schema names).
24
+ *
25
+ * Security validations:
26
+ * - Rejects null bytes which could cause truncation or unexpected behavior
27
+ * - Rejects empty identifiers
28
+ * - Warns on identifiers exceeding PostgreSQL's 63-character limit
29
+ *
30
+ * @throws {SqlEscapeError} If the identifier contains null bytes or is empty
31
+ */
32
+ function quoteIdentifier(identifier) {
33
+ if (identifier.length === 0) throw new SqlEscapeError("Identifier cannot be empty", identifier, "identifier");
34
+ if (identifier.includes("\0")) throw new SqlEscapeError("Identifier cannot contain null bytes", identifier.replace(/\0/g, "\\0"), "identifier");
35
+ if (identifier.length > MAX_IDENTIFIER_LENGTH) console.warn(`Identifier "${identifier.slice(0, 20)}..." exceeds PostgreSQL's ${MAX_IDENTIFIER_LENGTH}-character limit and will be truncated`);
36
+ return `"${identifier.replace(/"/g, "\"\"")}"`;
37
+ }
38
+ /**
39
+ * Escapes a string literal for safe use in SQL statements.
40
+ *
41
+ * Security validations:
42
+ * - Rejects null bytes which could cause truncation or unexpected behavior
43
+ *
44
+ * Note: This assumes PostgreSQL's `standard_conforming_strings` is ON (default since PG 9.1).
45
+ * Backslashes are treated as literal characters, not escape sequences.
46
+ *
47
+ * @throws {SqlEscapeError} If the value contains null bytes
48
+ */
49
+ function escapeLiteral(value) {
50
+ if (value.includes("\0")) throw new SqlEscapeError("Literal value cannot contain null bytes", value.replace(/\0/g, "\\0"), "literal");
51
+ return value.replace(/'/g, "''");
52
+ }
53
+ /**
54
+ * Builds a qualified name (schema.object) with proper quoting.
55
+ */
56
+ function qualifyName(schemaName, objectName) {
57
+ return `${quoteIdentifier(schemaName)}.${quoteIdentifier(objectName)}`;
58
+ }
59
+ /**
60
+ * Validates that an enum value doesn't exceed PostgreSQL's label length limit.
61
+ *
62
+ * PostgreSQL enum labels have a maximum length of NAMEDATALEN-1 (63 bytes by default).
63
+ * Unlike identifiers, enum labels that exceed this limit cause an error rather than
64
+ * silent truncation.
65
+ *
66
+ * @param value - The enum value to validate
67
+ * @param enumTypeName - Name of the enum type (for error messages)
68
+ * @throws {SqlEscapeError} If the value exceeds the maximum length
69
+ */
70
+ function validateEnumValueLength(value, enumTypeName) {
71
+ 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
+ }
73
+
74
+ //#endregion
75
+ export { validateEnumValueLength as a, quoteIdentifier as i, escapeLiteral as n, qualifyName as r, SqlEscapeError as t };
76
+ //# sourceMappingURL=sql-utils-r-Lw535w.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sql-utils-r-Lw535w.mjs","names":["value: string","kind: 'identifier' | 'literal'"],"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;CACxC,YACE,SACA,AAAgBA,OAChB,AAAgBC,MAChB;AACA,QAAM,QAAQ;EAHE;EACA;AAGhB,OAAK,OAAO;;;AAIhB,MAAM,wBAAwB;;;;;;;;;;;AAY9B,SAAgB,gBAAgB,YAA4B;AAC1D,KAAI,WAAW,WAAW,EACxB,OAAM,IAAI,eAAe,8BAA8B,YAAY,aAAa;AAElF,KAAI,WAAW,SAAS,KAAK,CAC3B,OAAM,IAAI,eACR,wCACA,WAAW,QAAQ,OAAO,MAAM,EAChC,aACD;AAEH,KAAI,WAAW,SAAS,sBACtB,SAAQ,KACN,eAAe,WAAW,MAAM,GAAG,GAAG,CAAC,4BAA4B,sBAAsB,wCAC1F;AAEH,QAAO,IAAI,WAAW,QAAQ,MAAM,OAAK,CAAC;;;;;;;;;;;;;AAc5C,SAAgB,cAAc,OAAuB;AACnD,KAAI,MAAM,SAAS,KAAK,CACtB,OAAM,IAAI,eACR,2CACA,MAAM,QAAQ,OAAO,MAAM,EAC3B,UACD;AAEH,QAAO,MAAM,QAAQ,MAAM,KAAK;;;;;AAMlC,SAAgB,YAAY,YAAoB,YAA4B;AAC1E,QAAO,GAAG,gBAAgB,WAAW,CAAC,GAAG,gBAAgB,WAAW;;;;;;;;;;;;;AActE,SAAgB,wBAAwB,OAAe,cAA4B;AACjF,KAAI,MAAM,SAAS,sBACjB,OAAM,IAAI,eACR,eAAe,MAAM,MAAM,GAAG,GAAG,CAAC,iBAAiB,aAAa,yBAC3D,sBAAsB,yBAC3B,OACA,UACD"}
@@ -0,0 +1,59 @@
1
+ //#region src/core/sql-utils.d.ts
2
+ /**
3
+ * Shared SQL utility functions for the Postgres target.
4
+ *
5
+ * These functions handle safe SQL identifier and literal escaping
6
+ * with security validations to prevent injection and encoding issues.
7
+ *
8
+ * They live in `target-postgres` because both the control adapter (used at
9
+ * emit time) and the runtime adapter (used at execute time) need the same
10
+ * escaping/validation behavior, and the target package is the natural shared
11
+ * home that both adapters can depend on without crossing planes.
12
+ */
13
+ declare class SqlEscapeError extends Error {
14
+ readonly value: string;
15
+ readonly kind: 'identifier' | 'literal';
16
+ constructor(message: string, value: string, kind: 'identifier' | 'literal');
17
+ }
18
+ /**
19
+ * Validates and quotes a PostgreSQL identifier (table, column, type, schema names).
20
+ *
21
+ * Security validations:
22
+ * - Rejects null bytes which could cause truncation or unexpected behavior
23
+ * - Rejects empty identifiers
24
+ * - Warns on identifiers exceeding PostgreSQL's 63-character limit
25
+ *
26
+ * @throws {SqlEscapeError} If the identifier contains null bytes or is empty
27
+ */
28
+ declare function quoteIdentifier(identifier: string): string;
29
+ /**
30
+ * Escapes a string literal for safe use in SQL statements.
31
+ *
32
+ * Security validations:
33
+ * - Rejects null bytes which could cause truncation or unexpected behavior
34
+ *
35
+ * Note: This assumes PostgreSQL's `standard_conforming_strings` is ON (default since PG 9.1).
36
+ * Backslashes are treated as literal characters, not escape sequences.
37
+ *
38
+ * @throws {SqlEscapeError} If the value contains null bytes
39
+ */
40
+ declare function escapeLiteral(value: string): string;
41
+ /**
42
+ * Builds a qualified name (schema.object) with proper quoting.
43
+ */
44
+ declare function qualifyName(schemaName: string, objectName: string): string;
45
+ /**
46
+ * Validates that an enum value doesn't exceed PostgreSQL's label length limit.
47
+ *
48
+ * PostgreSQL enum labels have a maximum length of NAMEDATALEN-1 (63 bytes by default).
49
+ * Unlike identifiers, enum labels that exceed this limit cause an error rather than
50
+ * silent truncation.
51
+ *
52
+ * @param value - The enum value to validate
53
+ * @param enumTypeName - Name of the enum type (for error messages)
54
+ * @throws {SqlEscapeError} If the value exceeds the maximum length
55
+ */
56
+ declare function validateEnumValueLength(value: string, enumTypeName: string): void;
57
+ //#endregion
58
+ export { SqlEscapeError, escapeLiteral, qualifyName, quoteIdentifier, validateEnumValueLength };
59
+ //# sourceMappingURL=sql-utils.d.mts.map
@@ -0,0 +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"}
@@ -0,0 +1,3 @@
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 };