@prisma-next/target-postgres 0.14.0-dev.3 → 0.14.0-dev.30

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 (166) hide show
  1. package/dist/canonicalize-Bn3BM1Cn.mjs +46 -0
  2. package/dist/canonicalize-Bn3BM1Cn.mjs.map +1 -0
  3. package/dist/canonicalize-CAbXtVtB.d.mts +37 -0
  4. package/dist/canonicalize-CAbXtVtB.d.mts.map +1 -0
  5. package/dist/{codec-types-DHCkwPKE.d.mts → codec-types-CueCoGD0.d.mts} +2 -2
  6. package/dist/{codec-types-DHCkwPKE.d.mts.map → codec-types-CueCoGD0.d.mts.map} +1 -1
  7. package/dist/codec-types.d.mts +1 -1
  8. package/dist/{codecs--0A5_4Bq.d.mts → codecs-Ca8upop6.d.mts} +12 -1
  9. package/dist/codecs-Ca8upop6.d.mts.map +1 -0
  10. package/dist/codecs.d.mts +1 -1
  11. package/dist/codecs.mjs +34 -1
  12. package/dist/codecs.mjs.map +1 -1
  13. package/dist/contract-free.d.mts +8 -3
  14. package/dist/contract-free.d.mts.map +1 -1
  15. package/dist/contract-free.mjs +3 -3
  16. package/dist/control.d.mts +1 -1
  17. package/dist/control.d.mts.map +1 -1
  18. package/dist/control.mjs +11 -10
  19. package/dist/control.mjs.map +1 -1
  20. package/dist/data-transform-BOWpliq8.mjs.map +1 -1
  21. package/dist/{data-transform-DDgWdB5o.d.mts → data-transform-qKy1U5V9.d.mts} +2 -2
  22. package/dist/{data-transform-DDgWdB5o.d.mts.map → data-transform-qKy1U5V9.d.mts.map} +1 -1
  23. package/dist/data-transform.d.mts +1 -1
  24. package/dist/{ddl-QDyOSeLc.mjs → ddl-CGf6UABz.mjs} +62 -5
  25. package/dist/ddl-CGf6UABz.mjs.map +1 -0
  26. package/dist/ddl.d.mts +3 -2
  27. package/dist/ddl.mjs +2 -2
  28. package/dist/{default-normalizer-DyyCHQWs.mjs → default-normalizer-CzV8-QSu.mjs} +58 -2
  29. package/dist/default-normalizer-CzV8-QSu.mjs.map +1 -0
  30. package/dist/default-normalizer.d.mts +1 -1
  31. package/dist/default-normalizer.d.mts.map +1 -1
  32. package/dist/default-normalizer.mjs +1 -1
  33. package/dist/descriptor-meta-Dvvpu_jU.mjs +17 -0
  34. package/dist/descriptor-meta-Dvvpu_jU.mjs.map +1 -0
  35. package/dist/descriptor-meta-runtime-D5zHFKUz.mjs +228 -0
  36. package/dist/descriptor-meta-runtime-D5zHFKUz.mjs.map +1 -0
  37. package/dist/{issue-planner-DL6g3CmE.mjs → issue-planner-D5H1VuVP.mjs} +11 -9
  38. package/dist/issue-planner-D5H1VuVP.mjs.map +1 -0
  39. package/dist/issue-planner.d.mts +3 -3
  40. package/dist/issue-planner.d.mts.map +1 -1
  41. package/dist/issue-planner.mjs +1 -1
  42. package/dist/migration.d.mts +3 -3
  43. package/dist/migration.mjs +2 -2
  44. package/dist/nodes-CSkPX3rI.d.mts +120 -0
  45. package/dist/nodes-CSkPX3rI.d.mts.map +1 -0
  46. package/dist/{nodes-Bbhs2rwj.mjs → nodes-Dh__NS58.mjs} +56 -2
  47. package/dist/nodes-Dh__NS58.mjs.map +1 -0
  48. package/dist/{op-factory-call-D_p5vxwt.mjs → op-factory-call-DIdBDwmO.mjs} +199 -28
  49. package/dist/op-factory-call-DIdBDwmO.mjs.map +1 -0
  50. package/dist/{op-factory-call-DmQEc3XV.d.mts → op-factory-call-DPJR7tJc.d.mts} +44 -13
  51. package/dist/op-factory-call-DPJR7tJc.d.mts.map +1 -0
  52. package/dist/op-factory-call.d.mts +1 -1
  53. package/dist/op-factory-call.mjs +1 -1
  54. package/dist/pack.d.mts +74 -2
  55. package/dist/pack.d.mts.map +1 -1
  56. package/dist/pack.mjs +1 -1
  57. package/dist/{planner-Bs_baQax.mjs → planner-BnNEtGYM.mjs} +156 -24
  58. package/dist/planner-BnNEtGYM.mjs.map +1 -0
  59. package/dist/{planner-ddl-builders-B2wOwLqI.mjs → planner-ddl-builders-B8Nn6nHN.mjs} +12 -27
  60. package/dist/planner-ddl-builders-B8Nn6nHN.mjs.map +1 -0
  61. package/dist/planner-ddl-builders.d.mts +2 -4
  62. package/dist/planner-ddl-builders.d.mts.map +1 -1
  63. package/dist/planner-ddl-builders.mjs +2 -2
  64. package/dist/{planner-produced-postgres-migration-QqHa2C2l.d.mts → planner-produced-postgres-migration-BO-frvvN.d.mts} +3 -3
  65. package/dist/{planner-produced-postgres-migration-QqHa2C2l.d.mts.map → planner-produced-postgres-migration-BO-frvvN.d.mts.map} +1 -1
  66. package/dist/{planner-produced-postgres-migration-Cji5vxUf.mjs → planner-produced-postgres-migration-DzvdQ-7K.mjs} +2 -2
  67. package/dist/{planner-produced-postgres-migration-Cji5vxUf.mjs.map → planner-produced-postgres-migration-DzvdQ-7K.mjs.map} +1 -1
  68. package/dist/planner-produced-postgres-migration.d.mts +1 -1
  69. package/dist/planner-produced-postgres-migration.mjs +1 -1
  70. package/dist/{planner-sql-checks-jqUUGyQR.mjs → planner-sql-checks-CyjaoKhm.mjs} +2 -2
  71. package/dist/{planner-sql-checks-jqUUGyQR.mjs.map → planner-sql-checks-CyjaoKhm.mjs.map} +1 -1
  72. package/dist/planner-sql-checks.mjs +1 -1
  73. package/dist/{planner-target-details-CIY6tLeo.d.mts → planner-target-details-HkP4RrRO.d.mts} +2 -2
  74. package/dist/planner-target-details-HkP4RrRO.d.mts.map +1 -0
  75. package/dist/planner-target-details.d.mts +1 -1
  76. package/dist/planner.d.mts +31 -4
  77. package/dist/planner.d.mts.map +1 -1
  78. package/dist/planner.mjs +2 -2
  79. package/dist/{postgres-contract-serializer-k3TAcPMY.mjs → postgres-contract-serializer-tGMiJcl4.mjs} +30 -21
  80. package/dist/postgres-contract-serializer-tGMiJcl4.mjs.map +1 -0
  81. package/dist/{postgres-migration-B5jKrXv3.mjs → postgres-migration-C8JZyTSJ.mjs} +2 -2
  82. package/dist/{postgres-migration-B5jKrXv3.mjs.map → postgres-migration-C8JZyTSJ.mjs.map} +1 -1
  83. package/dist/{postgres-migration-Y4YBJqkS.d.mts → postgres-migration-Cs7zMOe1.d.mts} +5 -5
  84. package/dist/{postgres-migration-Y4YBJqkS.d.mts.map → postgres-migration-Cs7zMOe1.d.mts.map} +1 -1
  85. package/dist/postgres-rls-policy-12wAEQhs.d.mts +60 -0
  86. package/dist/postgres-rls-policy-12wAEQhs.d.mts.map +1 -0
  87. package/dist/postgres-schema-DJUEkWg-.d.mts +190 -0
  88. package/dist/postgres-schema-DJUEkWg-.d.mts.map +1 -0
  89. package/dist/{postgres-schema-COGZ1ark.mjs → postgres-schema-DLcc3W2-.mjs} +138 -5
  90. package/dist/postgres-schema-DLcc3W2-.mjs.map +1 -0
  91. package/dist/postgres-schema-ir-BJl_a3J7.d.mts +102 -0
  92. package/dist/postgres-schema-ir-BJl_a3J7.d.mts.map +1 -0
  93. package/dist/postgres-schema-ir-I_FiUndw.mjs +133 -0
  94. package/dist/postgres-schema-ir-I_FiUndw.mjs.map +1 -0
  95. package/dist/postgres-schema-ir-annotations-BbDSiwx2.mjs +14 -0
  96. package/dist/postgres-schema-ir-annotations-BbDSiwx2.mjs.map +1 -0
  97. package/dist/render-ops.d.mts +1 -1
  98. package/dist/rls-canonicalize.d.mts +2 -0
  99. package/dist/rls-canonicalize.mjs +2 -0
  100. package/dist/runtime.d.mts +5 -5
  101. package/dist/runtime.d.mts.map +1 -1
  102. package/dist/runtime.mjs +2 -2
  103. package/dist/schema-ir-annotations.d.mts +8 -0
  104. package/dist/schema-ir-annotations.d.mts.map +1 -0
  105. package/dist/schema-ir-annotations.mjs +2 -0
  106. package/dist/types.d.mts +4 -140
  107. package/dist/types.mjs +3 -2
  108. package/package.json +21 -17
  109. package/src/contract-free/checks.ts +73 -0
  110. package/src/contract-free/ddl.ts +45 -1
  111. package/src/core/authoring.ts +115 -1
  112. package/src/core/codecs.ts +35 -1
  113. package/src/core/ddl/nodes.ts +94 -2
  114. package/src/core/default-normalizer.ts +60 -2
  115. package/src/core/descriptor-meta.ts +4 -0
  116. package/src/core/entity-kinds.ts +16 -0
  117. package/src/core/migrations/bound-schema.ts +10 -0
  118. package/src/core/migrations/contract-to-postgres-schema-ir.ts +91 -0
  119. package/src/core/migrations/control-policy.ts +3 -0
  120. package/src/core/migrations/diff-postgres-schema.ts +55 -0
  121. package/src/core/migrations/issue-planner.ts +8 -0
  122. package/src/core/migrations/op-factory-call.ts +106 -21
  123. package/src/core/migrations/operations/columns.ts +24 -12
  124. package/src/core/migrations/operations/data-transform.ts +6 -0
  125. package/src/core/migrations/operations/rls.ts +106 -0
  126. package/src/core/migrations/operations/shared.ts +0 -30
  127. package/src/core/migrations/planner-ddl-builders.ts +15 -56
  128. package/src/core/migrations/planner-recipes.ts +31 -13
  129. package/src/core/migrations/planner-strategies.ts +3 -11
  130. package/src/core/migrations/planner-target-details.ts +3 -1
  131. package/src/core/migrations/planner.ts +84 -1
  132. package/src/core/migrations/verify-postgres-namespaces.ts +12 -15
  133. package/src/core/postgres-contract-serializer.ts +48 -33
  134. package/src/core/postgres-schema.ts +37 -13
  135. package/src/core/postgres-validators.ts +20 -0
  136. package/src/core/rls/canonicalize.ts +48 -0
  137. package/src/core/schema-ir/postgres-rls-policy.ts +101 -0
  138. package/src/core/schema-ir/postgres-role.ts +52 -0
  139. package/src/core/schema-ir/postgres-schema-ir-annotations.ts +22 -0
  140. package/src/core/schema-ir/postgres-schema-ir.ts +138 -0
  141. package/src/core/schema-ir/postgres-table-ir.ts +96 -0
  142. package/src/exports/contract-free.ts +7 -1
  143. package/src/exports/control.ts +11 -12
  144. package/src/exports/ddl.ts +4 -0
  145. package/src/exports/planner-ddl-builders.ts +0 -2
  146. package/src/exports/planner.ts +5 -0
  147. package/src/exports/rls-canonicalize.ts +6 -0
  148. package/src/exports/schema-ir-annotations.ts +1 -0
  149. package/src/exports/types.ts +20 -0
  150. package/dist/codecs--0A5_4Bq.d.mts.map +0 -1
  151. package/dist/ddl-QDyOSeLc.mjs.map +0 -1
  152. package/dist/default-normalizer-DyyCHQWs.mjs.map +0 -1
  153. package/dist/descriptor-meta-CpGygXpI.mjs +0 -140
  154. package/dist/descriptor-meta-CpGygXpI.mjs.map +0 -1
  155. package/dist/issue-planner-DL6g3CmE.mjs.map +0 -1
  156. package/dist/nodes-Bbhs2rwj.mjs.map +0 -1
  157. package/dist/nodes-pLeLgdis.d.mts +0 -67
  158. package/dist/nodes-pLeLgdis.d.mts.map +0 -1
  159. package/dist/op-factory-call-D_p5vxwt.mjs.map +0 -1
  160. package/dist/op-factory-call-DmQEc3XV.d.mts.map +0 -1
  161. package/dist/planner-Bs_baQax.mjs.map +0 -1
  162. package/dist/planner-ddl-builders-B2wOwLqI.mjs.map +0 -1
  163. package/dist/planner-target-details-CIY6tLeo.d.mts.map +0 -1
  164. package/dist/postgres-contract-serializer-k3TAcPMY.mjs.map +0 -1
  165. package/dist/postgres-schema-COGZ1ark.mjs.map +0 -1
  166. package/dist/types.d.mts.map +0 -1
@@ -1,2 +1,2 @@
1
- import { t as PostgresPlanTargetDetails } from "./planner-target-details-CIY6tLeo.mjs";
1
+ import { t as PostgresPlanTargetDetails } from "./planner-target-details-HkP4RrRO.mjs";
2
2
  export type { PostgresPlanTargetDetails };
@@ -1,10 +1,36 @@
1
- import { t as TypeScriptRenderablePostgresMigration } from "./planner-produced-postgres-migration-QqHa2C2l.mjs";
2
- import { MigrationOperationPolicy, SqlPlannerConflict, SqlPlannerFailureResult } from "@prisma-next/family-sql/control";
3
- import { MigrationPlanWithAuthoringSurface, MigrationPlanner, MigrationScaffoldContext } from "@prisma-next/framework-components/control";
1
+ import { t as PostgresContract } from "./postgres-schema-DJUEkWg-.mjs";
2
+ import { t as TypeScriptRenderablePostgresMigration } from "./planner-produced-postgres-migration-BO-frvvN.mjs";
3
+ import { t as PostgresSchemaIR } from "./postgres-schema-ir-BJl_a3J7.mjs";
4
+ import { ContractToSchemaIROptions, MigrationOperationPolicy, SqlPlannerConflict, SqlPlannerFailureResult } from "@prisma-next/family-sql/control";
5
+ import { MigrationPlanWithAuthoringSurface, MigrationPlanner, MigrationScaffoldContext, SchemaDiffIssue } from "@prisma-next/framework-components/control";
4
6
  import { Contract } from "@prisma-next/contract/types";
5
7
  import { ExecuteRequestLowerer } from "@prisma-next/family-sql/control-adapter";
6
8
  import { TargetBoundComponentDescriptor } from "@prisma-next/framework-components/components";
7
9
 
10
+ //#region src/core/migrations/contract-to-postgres-schema-ir.d.ts
11
+ declare function contractToPostgresSchemaIR(contract: PostgresContract | null, options: ContractToSchemaIROptions): PostgresSchemaIR;
12
+ //#endregion
13
+ //#region src/core/migrations/diff-postgres-schema.d.ts
14
+ /**
15
+ * Computes schema drift between two derived schema IRs.
16
+ *
17
+ * 1. Runs the framework total diff.
18
+ * 2. Filters to policy-subject issues only — this is transitional: the generic
19
+ * differ walks the whole tree, but the legacy relational verifier still owns
20
+ * table/column drift, so non-policy issues are dropped here.
21
+ * 3. Remaps the message to a human-readable policy reference.
22
+ *
23
+ * Ownership filtering (dropping `extra` issues in namespaces a contract doesn't
24
+ * own) is the caller's responsibility — use `filterIssuesByOwnership`.
25
+ */
26
+ declare function diffPostgresSchema(expected: PostgresSchemaIR, actual: PostgresSchemaIR): readonly SchemaDiffIssue[];
27
+ /**
28
+ * Filters `extra` policy issues to those in owned namespaces. Call after
29
+ * `diffPostgresSchema` with the union of namespace ids from the expected IR's
30
+ * policies and its `existingSchemas`.
31
+ */
32
+ declare function filterIssuesByOwnership(issues: readonly SchemaDiffIssue[], ownedSchemaNames: ReadonlySet<string>): readonly SchemaDiffIssue[];
33
+ //#endregion
8
34
  //#region src/core/migrations/planner.d.ts
9
35
  declare function createPostgresMigrationPlanner(lowerer: ExecuteRequestLowerer): PostgresMigrationPlanner;
10
36
  /**
@@ -68,9 +94,10 @@ declare class PostgresMigrationPlanner implements MigrationPlanner<'sql', 'postg
68
94
  }): PostgresPlanResult;
69
95
  emptyMigration(context: MigrationScaffoldContext, spaceId: string): MigrationPlanWithAuthoringSurface;
70
96
  private planSql;
97
+ private planPostgresSchemaDiff;
71
98
  private ensureAdditivePolicy;
72
99
  private collectSchemaIssues;
73
100
  }
74
101
  //#endregion
75
- export { createPostgresMigrationPlanner };
102
+ export { contractToPostgresSchemaIR, createPostgresMigrationPlanner, diffPostgresSchema, filterIssuesByOwnership };
76
103
  //# sourceMappingURL=planner.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"planner.d.mts","names":[],"sources":["../src/core/migrations/planner.ts"],"mappings":";;;;;;;;iBAqDgB,8BAAA,CACd,OAAA,EAAS,qBAAA,GACR,wBAAwB;;AAF3B;;;;;;KAaY,kBAAA;EAAA,SAEG,IAAA;EAAA,SACA,IAAA,EAAM,qCAAA;EAAA,SACN,QAAA,YAAoB,kBAAA;AAAA,IAE/B,uBAAA;;;;;;;;;;;;;;AAAuB;AAkB3B;;cAAa,wBAAA,YAAoC,gBAAA;EAAA;cAGnC,OAAA,GAAU,qBAAA;EAItB,IAAA,CAAK,OAAA;IAAA,SACM,QAAA;IAAA,SACA,MAAA;IAAA,SACA,MAAA,EAAQ,wBAAA;IA6BR;;;;;;;;;;;;;;IAAA,SAdA,YAAA,EAAc,QAAA;IAAA,SACd,UAAA;IAAA,SACA,mBAAA,EAAqB,aAAA,CAAc,8BAAA;IADnC;;;;;IAAA,SAOA,OAAA;EAAA,IACP,kBAAA;EAIJ,cAAA,CACE,OAAA,EAAS,wBAAA,EACT,OAAA,WACC,iCAAA;EAAA,QAYK,OAAA;EAAA,QAmGA,oBAAA;EAAA,QAaA,mBAAA;AAAA"}
1
+ {"version":3,"file":"planner.d.mts","names":[],"sources":["../src/core/migrations/contract-to-postgres-schema-ir.ts","../src/core/migrations/diff-postgres-schema.ts","../src/core/migrations/planner.ts"],"mappings":";;;;;;;;;;iBAUgB,0BAAA,CACd,QAAA,EAAU,gBAAA,SACV,OAAA,EAAS,yBAAA,GACR,gBAAA;;;;;;;;;;;AAHH;;;;iBCcgB,kBAAA,CACd,QAAA,EAAU,gBAAA,EACV,MAAA,EAAQ,gBAAA,YACE,eAAA;;;;;;iBAkBI,uBAAA,CACd,MAAA,WAAiB,eAAA,IACjB,gBAAA,EAAkB,WAAA,oBACR,eAAA;;;iBCgBI,8BAAA,CACd,OAAA,EAAS,qBAAA,GACR,wBAAwB;;;;AFxD3B;;;;KEmEY,kBAAA;EAAA,SAEG,IAAA;EAAA,SACA,IAAA,EAAM,qCAAA;EAAA,SACN,QAAA,YAAoB,kBAAA;AAAA,IAE/B,uBAAA;;;;;;AFtEe;;;;ACWnB;;;;;;;cC6Ea,wBAAA,YAAoC,gBAAA;EAAA;cAGnC,OAAA,GAAU,qBAAA;EAItB,IAAA,CAAK,OAAA;IAAA,SACM,QAAA;IAAA,SACA,MAAA;IAAA,SACA,MAAA,EAAQ,wBAAA;IDpFM;AAkB3B;;;;;;;;;;;;;IAlB2B,SCmGd,YAAA,EAAc,QAAA;IAAA,SACd,UAAA;IAAA,SACA,mBAAA,EAAqB,aAAA,CAAc,8BAAA;;;AAhEhD;;;aAsEa,OAAA;EAAA,IACP,kBAAA;EAIJ,cAAA,CACE,OAAA,EAAS,wBAAA,EACT,OAAA,WACC,iCAAA;EAAA,QAYK,OAAA;EAAA,QA+GA,sBAAA;EAAA,QA2DA,oBAAA;EAAA,QAaA,mBAAA;AAAA"}
package/dist/planner.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { t as createPostgresMigrationPlanner } from "./planner-Bs_baQax.mjs";
2
- export { createPostgresMigrationPlanner };
1
+ import { i as contractToPostgresSchemaIR, n as diffPostgresSchema, r as filterIssuesByOwnership, t as createPostgresMigrationPlanner } from "./planner-BnNEtGYM.mjs";
2
+ export { contractToPostgresSchemaIR, createPostgresMigrationPlanner, diffPostgresSchema, filterIssuesByOwnership };
@@ -1,7 +1,7 @@
1
- import { r as postgresAuthoringEntityTypes, t as postgresTargetDescriptorMeta } from "./descriptor-meta-CpGygXpI.mjs";
2
- import { r as isPostgresSchema, t as PostgresSchema } from "./postgres-schema-COGZ1ark.mjs";
1
+ import { a as policyEntityKind, o as roleEntityKind, r as isPostgresSchema, t as PostgresSchema } from "./postgres-schema-DLcc3W2-.mjs";
2
+ import { n as postgresAuthoringEntityTypes } from "./descriptor-meta-runtime-D5zHFKUz.mjs";
3
3
  import { blindCast } from "@prisma-next/utils/casts";
4
- import { NamespaceBase, UNBOUND_NAMESPACE_ID } from "@prisma-next/framework-components/ir";
4
+ import { UNBOUND_NAMESPACE_ID } from "@prisma-next/framework-components/ir";
5
5
  import { SqlContractSerializerBase } from "@prisma-next/family-sql/ir";
6
6
  import { isAuthoringEntityTypeDescriptor } from "@prisma-next/framework-components/authoring";
7
7
  //#region src/core/postgres-contract-serializer.ts
@@ -10,7 +10,7 @@ const POSTGRES_AUTHORING_CTX = {
10
10
  target: "postgres"
11
11
  };
12
12
  function isAuthoringEntityTypeFactoryOutput(output) {
13
- return typeof output === "object" && output !== null && typeof output.factory === "function";
13
+ return typeof output === "object" && output !== null && "factory" in output && typeof output.factory === "function";
14
14
  }
15
15
  /**
16
16
  * Walks a pack's entity-type namespace tree and emits hydration factories
@@ -36,20 +36,20 @@ function collectStorageTypesHydrators(namespace) {
36
36
  return registry;
37
37
  }
38
38
  var PostgresContractSerializer = class extends SqlContractSerializerBase {
39
- constructor() {
39
+ constructor(extraPackEntityKinds = []) {
40
40
  const storageTypesHydrators = collectStorageTypesHydrators(postgresAuthoringEntityTypes);
41
- super(storageTypesHydrators);
42
- }
43
- get defaultNamespaceId() {
44
- return postgresTargetDescriptorMeta.defaultNamespaceId;
41
+ super(storageTypesHydrators, [
42
+ policyEntityKind,
43
+ roleEntityKind,
44
+ ...extraPackEntityKinds
45
+ ]);
45
46
  }
46
47
  hydrateSqlNamespaceEntry(nsId, raw) {
47
- if (raw instanceof NamespaceBase) return raw;
48
48
  const { id, entries } = blindCast(super.hydrateSqlNamespaceEntry(nsId, raw));
49
+ const allSlotsEmpty = Object.values(entries).every((slot) => slot === void 0 || Object.keys(slot).length === 0);
50
+ if (id === UNBOUND_NAMESPACE_ID && allSlotsEmpty) return PostgresSchema.unbound;
49
51
  const valueSetSlot = entries["valueSet"];
50
52
  const hasValueSets = valueSetSlot !== void 0 && Object.keys(valueSetSlot).length > 0;
51
- const emptyTables = Object.keys(entries["table"] ?? {}).length === 0;
52
- if (id === UNBOUND_NAMESPACE_ID && emptyTables && !hasValueSets) return PostgresSchema.unbound;
53
53
  return new PostgresSchema({
54
54
  id,
55
55
  entries: {
@@ -66,7 +66,7 @@ var PostgresContractSerializer = class extends SqlContractSerializerBase {
66
66
  else namespacesJson[nsId] = {
67
67
  id: nsId,
68
68
  kind: nsId === UNBOUND_NAMESPACE_ID ? "postgres-unbound-schema" : "postgres-schema",
69
- entries: { table: Object.fromEntries(Object.entries(ns.entries.table ?? {}).map(([tableName, table]) => [tableName, this.serializeJsonValue(table)])) }
69
+ entries: { table: Object.fromEntries(Object.entries(ns.entries.table ?? {}).map(([tableName, table]) => [tableName, this.serializeJsonObject(table)])) }
70
70
  };
71
71
  const storageOut = {
72
72
  storageHash: String(storage.storageHash),
@@ -74,34 +74,43 @@ var PostgresContractSerializer = class extends SqlContractSerializerBase {
74
74
  };
75
75
  if (storage.types !== void 0) {
76
76
  const typesOut = {};
77
- for (const [name, entry] of Object.entries(storage.types)) typesOut[name] = this.serializeJsonValue(entry);
77
+ for (const [name, entry] of Object.entries(storage.types)) typesOut[name] = this.serializeJsonObject(entry);
78
78
  storageOut["types"] = typesOut;
79
79
  }
80
- return {
80
+ return blindCast({
81
81
  ...rest,
82
82
  storage: storageOut
83
- };
83
+ });
84
84
  }
85
85
  serializePostgresNamespace(ns, isUnboundSlot) {
86
86
  const tablesOut = {};
87
- for (const [tableName, table] of Object.entries(ns.table)) tablesOut[tableName] = this.serializeJsonValue(table);
87
+ for (const [tableName, table] of Object.entries(ns.table)) tablesOut[tableName] = this.serializeJsonObject(table);
88
88
  const valueSetEntries = ns.valueSet;
89
89
  const valueSetOut = {};
90
- if (valueSetEntries !== void 0) for (const [valueSetName, valueSet] of Object.entries(valueSetEntries)) valueSetOut[valueSetName] = blindCast(this.serializeJsonValue(valueSet));
90
+ if (valueSetEntries !== void 0) for (const [valueSetName, valueSet] of Object.entries(valueSetEntries)) valueSetOut[valueSetName] = this.serializeJsonObject(valueSet);
91
+ const roleOut = {};
92
+ for (const [roleName, role] of Object.entries(ns.role)) roleOut[roleName] = this.serializeJsonObject(role);
93
+ const policyOut = {};
94
+ for (const [policyName, policy] of Object.entries(ns.policy)) policyOut[policyName] = this.serializeJsonObject(policy);
91
95
  return {
92
96
  id: ns.id,
93
97
  kind: isUnboundSlot ? "postgres-unbound-schema" : "postgres-schema",
94
98
  entries: {
95
99
  table: tablesOut,
96
- ...Object.keys(valueSetOut).length > 0 ? { valueSet: valueSetOut } : {}
100
+ ...Object.keys(valueSetOut).length > 0 ? { valueSet: valueSetOut } : {},
101
+ ...Object.keys(roleOut).length > 0 ? { role: roleOut } : {},
102
+ ...Object.keys(policyOut).length > 0 ? { policy: policyOut } : {}
97
103
  }
98
104
  };
99
105
  }
106
+ serializeJsonObject(value) {
107
+ return blindCast(this.serializeJsonValue(value));
108
+ }
100
109
  serializeJsonValue(value) {
101
- return JSON.parse(JSON.stringify(value));
110
+ return blindCast(JSON.parse(JSON.stringify(value)));
102
111
  }
103
112
  };
104
113
  //#endregion
105
114
  export { PostgresContractSerializer as t };
106
115
 
107
- //# sourceMappingURL=postgres-contract-serializer-k3TAcPMY.mjs.map
116
+ //# sourceMappingURL=postgres-contract-serializer-tGMiJcl4.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-contract-serializer-tGMiJcl4.mjs","names":[],"sources":["../src/core/postgres-contract-serializer.ts"],"sourcesContent":["import type { Contract } from '@prisma-next/contract/types';\nimport {\n SqlContractSerializerBase,\n type SqlEntityHydrationFactory,\n} from '@prisma-next/family-sql/ir';\nimport {\n type AuthoringEntityContext,\n type AuthoringEntityTypeFactoryOutput,\n type AuthoringEntityTypeNamespace,\n isAuthoringEntityTypeDescriptor,\n} from '@prisma-next/framework-components/authoring';\nimport {\n type AnyEntityKindDescriptor,\n type Namespace,\n UNBOUND_NAMESPACE_ID,\n} from '@prisma-next/framework-components/ir';\nimport type { SqlNamespaceInput, SqlStorage } from '@prisma-next/sql-contract/types';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport type { JsonObject, JsonValue } from '@prisma-next/utils/json';\nimport { postgresAuthoringEntityTypes } from './authoring';\nimport { policyEntityKind, roleEntityKind } from './entity-kinds';\nimport { isPostgresSchema, PostgresSchema } from './postgres-schema';\n\nconst POSTGRES_AUTHORING_CTX: AuthoringEntityContext = {\n family: 'sql',\n target: 'postgres',\n};\n\nfunction isAuthoringEntityTypeFactoryOutput(\n output: unknown,\n): output is AuthoringEntityTypeFactoryOutput<unknown, unknown> {\n return (\n typeof output === 'object' &&\n output !== null &&\n 'factory' in output &&\n typeof output.factory === 'function'\n );\n}\n\n/**\n * Walks a pack's entity-type namespace tree and emits hydration factories\n * keyed by the descriptor's `discriminator`. Used for `storage.types`\n * (codec-triple hydration). Namespace entries hydration dispatches by\n * entries key, not discriminator — handled by `hydrateNamespaceEntities`.\n */\nfunction collectStorageTypesHydrators(\n namespace: AuthoringEntityTypeNamespace,\n): ReadonlyMap<string, SqlEntityHydrationFactory> {\n const registry = new Map<string, SqlEntityHydrationFactory>();\n const walk = (node: AuthoringEntityTypeNamespace): void => {\n for (const value of Object.values(node)) {\n if (isAuthoringEntityTypeDescriptor(value)) {\n if (isAuthoringEntityTypeFactoryOutput(value.output)) {\n const { factory } = value.output;\n registry.set(value.discriminator, (raw) => factory(raw, POSTGRES_AUTHORING_CTX));\n }\n continue;\n }\n if (typeof value === 'object' && value !== null) {\n walk(value);\n }\n }\n };\n walk(namespace);\n return registry;\n}\n\nexport class PostgresContractSerializer extends SqlContractSerializerBase<Contract<SqlStorage>> {\n constructor(extraPackEntityKinds: readonly AnyEntityKindDescriptor[] = []) {\n const storageTypesHydrators = collectStorageTypesHydrators(postgresAuthoringEntityTypes);\n super(storageTypesHydrators, [policyEntityKind, roleEntityKind, ...extraPackEntityKinds]);\n }\n\n protected override hydrateSqlNamespaceEntry(\n nsId: string,\n raw: Record<string, unknown>,\n ): Namespace | SqlNamespaceInput {\n const hydrated = blindCast<\n SqlNamespaceInput,\n 'raw is always plain JSON, so super.hydrateSqlNamespaceEntry returns SqlNamespaceInput'\n >(super.hydrateSqlNamespaceEntry(nsId, raw));\n const { id, entries } = hydrated;\n\n const allSlotsEmpty = Object.values(entries).every(\n (slot) => slot === undefined || Object.keys(slot).length === 0,\n );\n if (id === UNBOUND_NAMESPACE_ID && allSlotsEmpty) {\n return PostgresSchema.unbound;\n }\n const valueSetSlot = entries['valueSet'];\n const hasValueSets = valueSetSlot !== undefined && Object.keys(valueSetSlot).length > 0;\n return new PostgresSchema({\n id,\n entries: {\n ...entries,\n table: entries['table'] ?? {},\n ...(hasValueSets ? { valueSet: valueSetSlot } : {}),\n },\n });\n }\n\n override serializeContract(contract: Contract<SqlStorage>): JsonObject {\n const { storage, ...rest } = contract;\n const namespacesJson: Record<string, JsonObject> = {};\n for (const [nsId, ns] of Object.entries(storage.namespaces)) {\n if (isPostgresSchema(ns)) {\n namespacesJson[nsId] = this.serializePostgresNamespace(ns, ns.id === UNBOUND_NAMESPACE_ID);\n } else {\n const isUnboundSlot = nsId === UNBOUND_NAMESPACE_ID;\n namespacesJson[nsId] = {\n id: nsId,\n kind: isUnboundSlot ? 'postgres-unbound-schema' : 'postgres-schema',\n entries: {\n table: Object.fromEntries(\n Object.entries(ns.entries.table ?? {}).map(([tableName, table]) => [\n tableName,\n this.serializeJsonObject(table),\n ]),\n ),\n },\n };\n }\n }\n const storageOut: Record<string, unknown> = {\n storageHash: String(storage.storageHash),\n namespaces: namespacesJson,\n };\n if (storage.types !== undefined) {\n const typesOut: Record<string, JsonObject> = {};\n for (const [name, entry] of Object.entries(storage.types)) {\n typesOut[name] = this.serializeJsonObject(entry);\n }\n storageOut['types'] = typesOut;\n }\n return blindCast<\n JsonObject,\n 'contract minus storage plus a JSON-shaped storageOut is a JsonObject'\n >({\n ...rest,\n storage: storageOut,\n });\n }\n\n private serializePostgresNamespace(ns: PostgresSchema, isUnboundSlot: boolean): JsonObject {\n const tablesOut: Record<string, JsonObject> = {};\n for (const [tableName, table] of Object.entries(ns.table)) {\n tablesOut[tableName] = this.serializeJsonObject(table);\n }\n const valueSetEntries = ns.valueSet;\n const valueSetOut: Record<string, JsonObject> = {};\n if (valueSetEntries !== undefined) {\n for (const [valueSetName, valueSet] of Object.entries(valueSetEntries)) {\n valueSetOut[valueSetName] = this.serializeJsonObject(valueSet);\n }\n }\n const roleOut: Record<string, JsonObject> = {};\n for (const [roleName, role] of Object.entries(ns.role)) {\n roleOut[roleName] = this.serializeJsonObject(role);\n }\n const policyOut: Record<string, JsonObject> = {};\n for (const [policyName, policy] of Object.entries(ns.policy)) {\n policyOut[policyName] = this.serializeJsonObject(policy);\n }\n return {\n id: ns.id,\n kind: isUnboundSlot ? 'postgres-unbound-schema' : 'postgres-schema',\n entries: {\n table: tablesOut,\n ...(Object.keys(valueSetOut).length > 0 ? { valueSet: valueSetOut } : {}),\n ...(Object.keys(roleOut).length > 0 ? { role: roleOut } : {}),\n ...(Object.keys(policyOut).length > 0 ? { policy: policyOut } : {}),\n },\n };\n }\n\n private serializeJsonObject(value: unknown): JsonObject {\n return blindCast<\n JsonObject,\n 'serializeJsonValue round-trips an IR node through JSON, yielding a JsonObject'\n >(this.serializeJsonValue(value));\n }\n\n private serializeJsonValue(value: unknown): JsonValue {\n return blindCast<JsonValue, 'JSON.parse(JSON.stringify(x)) yields a JsonValue'>(\n JSON.parse(JSON.stringify(value)),\n );\n }\n}\n"],"mappings":";;;;;;;AAuBA,MAAM,yBAAiD;CACrD,QAAQ;CACR,QAAQ;AACV;AAEA,SAAS,mCACP,QAC8D;CAC9D,OACE,OAAO,WAAW,YAClB,WAAW,QACX,aAAa,UACb,OAAO,OAAO,YAAY;AAE9B;;;;;;;AAQA,SAAS,6BACP,WACgD;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zD,OAAO;GACL,IAAI,GAAG;GACP,MAAM,gBAAgB,4BAA4B;GAClD,SAAS;IACP,OAAO;IACP,GAAI,OAAO,KAAK,WAAW,CAAC,CAAC,SAAS,IAAI,EAAE,UAAU,YAAY,IAAI,CAAC;IACvE,GAAI,OAAO,KAAK,OAAO,CAAC,CAAC,SAAS,IAAI,EAAE,MAAM,QAAQ,IAAI,CAAC;IAC3D,GAAI,OAAO,KAAK,SAAS,CAAC,CAAC,SAAS,IAAI,EAAE,QAAQ,UAAU,IAAI,CAAC;GACnE;EACF;CACF;CAEA,oBAA4B,OAA4B;EACtD,OAAO,UAGL,KAAK,mBAAmB,KAAK,CAAC;CAClC;CAEA,mBAA2B,OAA2B;EACpD,OAAO,UACL,KAAK,MAAM,KAAK,UAAU,KAAK,CAAC,CAClC;CACF;AACF"}
@@ -1,4 +1,4 @@
1
- import { C as SetNotNullCall, D as installExtension, S as SetDefaultCall, _ as DropDefaultCall, b as DropTableCall, c as AlterColumnTypeCall, d as CreateSchemaCall, f as CreateTableCall, g as DropConstraintCall, h as DropColumnCall, m as DropCheckConstraintCall, n as AddColumnCall, o as AddPrimaryKeyCall, r as AddForeignKeyCall, s as AddUniqueCall, t as AddCheckConstraintCall, u as CreateIndexCall, v as DropIndexCall, y as DropNotNullCall } from "./op-factory-call-D_p5vxwt.mjs";
1
+ import { A as installExtension, E as SetNotNullCall, S as DropTableCall, T as SetDefaultCall, _ as DropConstraintCall, b as DropNotNullCall, c as AlterColumnTypeCall, f as CreateSchemaCall, g as DropColumnCall, h as DropCheckConstraintCall, n as AddColumnCall, o as AddPrimaryKeyCall, p as CreateTableCall, r as AddForeignKeyCall, s as AddUniqueCall, t as AddCheckConstraintCall, u as CreateIndexCall, v as DropDefaultCall, y as DropIndexCall } from "./op-factory-call-DIdBDwmO.mjs";
2
2
  import { t as errorPostgresMigrationStackMissing } from "./errors-CUk87ByX.mjs";
3
3
  import { t as dataTransform } from "./data-transform-BOWpliq8.mjs";
4
4
  import { Migration } from "@prisma-next/family-sql/migration";
@@ -142,4 +142,4 @@ var PostgresMigration = class extends Migration {
142
142
  //#endregion
143
143
  export { PostgresMigration as t };
144
144
 
145
- //# sourceMappingURL=postgres-migration-B5jKrXv3.mjs.map
145
+ //# sourceMappingURL=postgres-migration-C8JZyTSJ.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"postgres-migration-B5jKrXv3.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 type { DdlColumn, DdlTableConstraint } from '@prisma-next/sql-relational-core/ast';\nimport { errorPostgresMigrationStackMissing } from '../errors';\nimport {\n AddCheckConstraintCall,\n AddColumnCall,\n AddForeignKeyCall,\n AddPrimaryKeyCall,\n AddUniqueCall,\n AlterColumnTypeCall,\n type AlterColumnTypeOptions,\n CreateIndexCall,\n CreateSchemaCall,\n CreateTableCall,\n DropCheckConstraintCall,\n DropColumnCall,\n DropConstraintCall,\n DropDefaultCall,\n DropIndexCall,\n DropNotNullCall,\n DropTableCall,\n SetDefaultCall,\n SetNotNullCall,\n} from './op-factory-call';\nimport { type DataTransformOptions, dataTransform } from './operations/data-transform';\nimport { installExtension } from './operations/dependencies';\nimport type { CreateIndexExtras } from './operations/indexes';\nimport type { ForeignKeySpec } from './operations/shared';\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 facade re-export of this class\n * from `@prisma-next/postgres/migration`, keeping the authoring surface\n * 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 *\n * Every method requires an explicit `schema`. Postgres migrations name their\n * schema deliberately — there is no default and no `search_path`-relative\n * option. A migration that left the schema unspecified would resolve against\n * whatever `search_path` the connection happened to carry, and that ambiguity\n * is an antipattern in a migration. (The unbound/unspecified namespace concept\n * remains for SQLite, which has no schemas, and for Mongo's connection `db`.)\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 ): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return dataTransform(contract, name, options, this.controlAdapter);\n }\n\n /**\n * Emit a `CREATE TABLE` migration operation. Builds a typed DDL node from\n * the supplied options and lowers it through the stored control adapter.\n * Throws if no adapter is present (i.e. migration instantiated without a stack).\n */\n protected createTable(options: {\n readonly schema: string;\n readonly table: string;\n readonly ifNotExists?: boolean;\n readonly columns: readonly DdlColumn[];\n readonly constraints?: readonly DdlTableConstraint[];\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new CreateTableCall(\n options.schema,\n options.table,\n options.columns,\n options.constraints,\n ).toOp(this.controlAdapter);\n }\n\n /**\n * Emit a `CREATE SCHEMA` migration operation. Builds a typed DDL node from\n * the supplied options and lowers it through the stored control adapter.\n * Throws if no adapter is present (i.e. migration instantiated without a stack).\n */\n protected createSchema(options: {\n readonly schema: string;\n readonly ifNotExists?: boolean;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new CreateSchemaCall(options.schema).toOp(this.controlAdapter);\n }\n\n protected addColumn(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: DdlColumn;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new AddColumnCall(options.schema, options.table, options.column).toOp(\n this.controlAdapter,\n );\n }\n\n protected addPrimaryKey(options: {\n readonly schema: string;\n readonly table: string;\n readonly constraint: string;\n readonly columns: readonly string[];\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new AddPrimaryKeyCall(\n options.schema,\n options.table,\n options.constraint,\n options.columns,\n ).toOp(this.controlAdapter);\n }\n\n protected addUnique(options: {\n readonly schema: string;\n readonly table: string;\n readonly constraint: string;\n readonly columns: readonly string[];\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new AddUniqueCall(\n options.schema,\n options.table,\n options.constraint,\n options.columns,\n ).toOp(this.controlAdapter);\n }\n\n protected addForeignKey(options: {\n readonly schema: string;\n readonly table: string;\n readonly foreignKey: ForeignKeySpec;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new AddForeignKeyCall(options.schema, options.table, options.foreignKey).toOp(\n this.controlAdapter,\n );\n }\n\n protected addCheckConstraint(options: {\n readonly schema: string;\n readonly table: string;\n readonly constraint: string;\n readonly column: string;\n readonly values: readonly string[];\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new AddCheckConstraintCall(\n options.schema,\n options.table,\n options.constraint,\n options.column,\n options.values,\n ).toOp(this.controlAdapter);\n }\n\n protected dropCheckConstraint(options: {\n readonly schema: string;\n readonly table: string;\n readonly constraint: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new DropCheckConstraintCall(options.schema, options.table, options.constraint).toOp(\n this.controlAdapter,\n );\n }\n\n protected dropConstraint(options: {\n readonly schema: string;\n readonly table: string;\n readonly constraint: string;\n readonly kind?: 'foreignKey' | 'unique' | 'primaryKey';\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new DropConstraintCall(\n options.schema,\n options.table,\n options.constraint,\n options.kind ?? 'unique',\n ).toOp(this.controlAdapter);\n }\n\n protected dropTable(options: {\n readonly schema: string;\n readonly table: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new DropTableCall(options.schema, options.table).toOp(this.controlAdapter);\n }\n\n protected dropColumn(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new DropColumnCall(options.schema, options.table, options.column).toOp(\n this.controlAdapter,\n );\n }\n\n protected alterColumnType(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n readonly options: AlterColumnTypeOptions;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new AlterColumnTypeCall(\n options.schema,\n options.table,\n options.column,\n options.options,\n ).toOp(this.controlAdapter);\n }\n\n protected setNotNull(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new SetNotNullCall(options.schema, options.table, options.column).toOp(\n this.controlAdapter,\n );\n }\n\n protected dropNotNull(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new DropNotNullCall(options.schema, options.table, options.column).toOp(\n this.controlAdapter,\n );\n }\n\n protected setDefault(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n readonly defaultSql: string;\n readonly operationClass?: 'additive' | 'widening';\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new SetDefaultCall(\n options.schema,\n options.table,\n options.column,\n options.defaultSql,\n options.operationClass,\n ).toOp(this.controlAdapter);\n }\n\n protected dropDefault(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new DropDefaultCall(options.schema, options.table, options.column).toOp(\n this.controlAdapter,\n );\n }\n\n protected createIndex(options: {\n readonly schema: string;\n readonly table: string;\n readonly index: string;\n readonly columns: readonly string[];\n readonly extras?: CreateIndexExtras;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new CreateIndexCall(\n options.schema,\n options.table,\n options.index,\n options.columns,\n options.extras,\n ).toOp(this.controlAdapter);\n }\n\n protected dropIndex(options: {\n readonly schema: string;\n readonly table: string;\n readonly index: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new DropIndexCall(options.schema, options.table, options.index).toOp(\n this.controlAdapter,\n );\n }\n\n protected installExtension(options: {\n readonly extensionName: string;\n readonly invariantId: string;\n readonly id: string;\n readonly label?: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return installExtension(options, this.controlAdapter);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8DA,IAAsB,oBAAtB,cAAgDA,UAG9C;CACA,WAAoB;;;;;;;CAQpB;CAEA,YAAY,OAAyC;EACnD,MAAM,KAAK;EAIX,KAAK,iBAAiB,OAAO,UACxB,MAAM,QAAQ,OAAO,KAAK,IAC3B,KAAA;CACN;;;;;;CAOA,cACE,UACA,MACA,SAC+D;EAC/D,IAAI,CAAC,KAAK,gBACR,MAAM,mCAAmC;EAE3C,OAAO,cAAc,UAAU,MAAM,SAAS,KAAK,cAAc;CACnE;;;;;;CAOA,YAAsB,SAM4C;EAChE,IAAI,CAAC,KAAK,gBACR,MAAM,mCAAmC;EAE3C,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,KAAK,KAAK,cAAc;CAC5B;CAEA,YAAsB,SAI4C;EAChE,IAAI,CAAC,KAAK,gBACR,MAAM,mCAAmC;EAE3C,OAAO,IAAI,gBAAgB,QAAQ,QAAQ,QAAQ,OAAO,QAAQ,MAAM,CAAC,CAAC,KACxE,KAAK,cACP;CACF;CAEA,YAAsB,SAM4C;EAChE,IAAI,CAAC,KAAK,gBACR,MAAM,mCAAmC;EAE3C,OAAO,IAAI,gBACT,QAAQ,QACR,QAAQ,OACR,QAAQ,OACR,QAAQ,SACR,QAAQ,MACV,CAAC,CAAC,KAAK,KAAK,cAAc;CAC5B;CAEA,UAAoB,SAI8C;EAChE,IAAI,CAAC,KAAK,gBACR,MAAM,mCAAmC;EAE3C,OAAO,IAAI,cAAc,QAAQ,QAAQ,QAAQ,OAAO,QAAQ,KAAK,CAAC,CAAC,KACrE,KAAK,cACP;CACF;CAEA,iBAA2B,SAKuC;EAChE,IAAI,CAAC,KAAK,gBACR,MAAM,mCAAmC;EAE3C,OAAO,iBAAiB,SAAS,KAAK,cAAc;CACtD;AACF"}
1
+ {"version":3,"file":"postgres-migration-C8JZyTSJ.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 type { DdlColumn, DdlTableConstraint } from '@prisma-next/sql-relational-core/ast';\nimport { errorPostgresMigrationStackMissing } from '../errors';\nimport {\n AddCheckConstraintCall,\n AddColumnCall,\n AddForeignKeyCall,\n AddPrimaryKeyCall,\n AddUniqueCall,\n AlterColumnTypeCall,\n type AlterColumnTypeOptions,\n CreateIndexCall,\n CreateSchemaCall,\n CreateTableCall,\n DropCheckConstraintCall,\n DropColumnCall,\n DropConstraintCall,\n DropDefaultCall,\n DropIndexCall,\n DropNotNullCall,\n DropTableCall,\n SetDefaultCall,\n SetNotNullCall,\n} from './op-factory-call';\nimport { type DataTransformOptions, dataTransform } from './operations/data-transform';\nimport { installExtension } from './operations/dependencies';\nimport type { CreateIndexExtras } from './operations/indexes';\nimport type { ForeignKeySpec } from './operations/shared';\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 facade re-export of this class\n * from `@prisma-next/postgres/migration`, keeping the authoring surface\n * 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 *\n * Every method requires an explicit `schema`. Postgres migrations name their\n * schema deliberately — there is no default and no `search_path`-relative\n * option. A migration that left the schema unspecified would resolve against\n * whatever `search_path` the connection happened to carry, and that ambiguity\n * is an antipattern in a migration. (The unbound/unspecified namespace concept\n * remains for SQLite, which has no schemas, and for Mongo's connection `db`.)\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 ): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return dataTransform(contract, name, options, this.controlAdapter);\n }\n\n /**\n * Emit a `CREATE TABLE` migration operation. Builds a typed DDL node from\n * the supplied options and lowers it through the stored control adapter.\n * Throws if no adapter is present (i.e. migration instantiated without a stack).\n */\n protected createTable(options: {\n readonly schema: string;\n readonly table: string;\n readonly ifNotExists?: boolean;\n readonly columns: readonly DdlColumn[];\n readonly constraints?: readonly DdlTableConstraint[];\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new CreateTableCall(\n options.schema,\n options.table,\n options.columns,\n options.constraints,\n ).toOp(this.controlAdapter);\n }\n\n /**\n * Emit a `CREATE SCHEMA` migration operation. Builds a typed DDL node from\n * the supplied options and lowers it through the stored control adapter.\n * Throws if no adapter is present (i.e. migration instantiated without a stack).\n */\n protected createSchema(options: {\n readonly schema: string;\n readonly ifNotExists?: boolean;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new CreateSchemaCall(options.schema).toOp(this.controlAdapter);\n }\n\n protected addColumn(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: DdlColumn;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new AddColumnCall(options.schema, options.table, options.column).toOp(\n this.controlAdapter,\n );\n }\n\n protected addPrimaryKey(options: {\n readonly schema: string;\n readonly table: string;\n readonly constraint: string;\n readonly columns: readonly string[];\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new AddPrimaryKeyCall(\n options.schema,\n options.table,\n options.constraint,\n options.columns,\n ).toOp(this.controlAdapter);\n }\n\n protected addUnique(options: {\n readonly schema: string;\n readonly table: string;\n readonly constraint: string;\n readonly columns: readonly string[];\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new AddUniqueCall(\n options.schema,\n options.table,\n options.constraint,\n options.columns,\n ).toOp(this.controlAdapter);\n }\n\n protected addForeignKey(options: {\n readonly schema: string;\n readonly table: string;\n readonly foreignKey: ForeignKeySpec;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new AddForeignKeyCall(options.schema, options.table, options.foreignKey).toOp(\n this.controlAdapter,\n );\n }\n\n protected addCheckConstraint(options: {\n readonly schema: string;\n readonly table: string;\n readonly constraint: string;\n readonly column: string;\n readonly values: readonly string[];\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new AddCheckConstraintCall(\n options.schema,\n options.table,\n options.constraint,\n options.column,\n options.values,\n ).toOp(this.controlAdapter);\n }\n\n protected dropCheckConstraint(options: {\n readonly schema: string;\n readonly table: string;\n readonly constraint: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new DropCheckConstraintCall(options.schema, options.table, options.constraint).toOp(\n this.controlAdapter,\n );\n }\n\n protected dropConstraint(options: {\n readonly schema: string;\n readonly table: string;\n readonly constraint: string;\n readonly kind?: 'foreignKey' | 'unique' | 'primaryKey';\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new DropConstraintCall(\n options.schema,\n options.table,\n options.constraint,\n options.kind ?? 'unique',\n ).toOp(this.controlAdapter);\n }\n\n protected dropTable(options: {\n readonly schema: string;\n readonly table: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new DropTableCall(options.schema, options.table).toOp(this.controlAdapter);\n }\n\n protected dropColumn(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new DropColumnCall(options.schema, options.table, options.column).toOp(\n this.controlAdapter,\n );\n }\n\n protected alterColumnType(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n readonly options: AlterColumnTypeOptions;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new AlterColumnTypeCall(\n options.schema,\n options.table,\n options.column,\n options.options,\n ).toOp(this.controlAdapter);\n }\n\n protected setNotNull(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new SetNotNullCall(options.schema, options.table, options.column).toOp(\n this.controlAdapter,\n );\n }\n\n protected dropNotNull(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new DropNotNullCall(options.schema, options.table, options.column).toOp(\n this.controlAdapter,\n );\n }\n\n protected setDefault(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n readonly defaultSql: string;\n readonly operationClass?: 'additive' | 'widening';\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new SetDefaultCall(\n options.schema,\n options.table,\n options.column,\n options.defaultSql,\n options.operationClass,\n ).toOp(this.controlAdapter);\n }\n\n protected dropDefault(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new DropDefaultCall(options.schema, options.table, options.column).toOp(\n this.controlAdapter,\n );\n }\n\n protected createIndex(options: {\n readonly schema: string;\n readonly table: string;\n readonly index: string;\n readonly columns: readonly string[];\n readonly extras?: CreateIndexExtras;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new CreateIndexCall(\n options.schema,\n options.table,\n options.index,\n options.columns,\n options.extras,\n ).toOp(this.controlAdapter);\n }\n\n protected dropIndex(options: {\n readonly schema: string;\n readonly table: string;\n readonly index: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new DropIndexCall(options.schema, options.table, options.index).toOp(\n this.controlAdapter,\n );\n }\n\n protected installExtension(options: {\n readonly extensionName: string;\n readonly invariantId: string;\n readonly id: string;\n readonly label?: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return installExtension(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WdB5o.mjs";
3
- import { s as AlterColumnTypeOptions, w as ForeignKeySpec } from "./op-factory-call-DmQEc3XV.mjs";
1
+ import { t as PostgresPlanTargetDetails } from "./planner-target-details-HkP4RrRO.mjs";
2
+ import { n as DataTransformOptions } from "./data-transform-qKy1U5V9.mjs";
3
+ import { s as AlterColumnTypeOptions, w as ForeignKeySpec } from "./op-factory-call-DPJR7tJc.mjs";
4
4
  import { DdlColumn, DdlTableConstraint } from "@prisma-next/sql-relational-core/ast";
5
5
  import { SqlMigrationPlanOperation } from "@prisma-next/family-sql/control";
6
6
  import { SqlStorage } from "@prisma-next/sql-contract/types";
7
- import { Migration } from "@prisma-next/family-sql/migration";
8
7
  import { ControlStack } from "@prisma-next/framework-components/control";
8
+ import { Migration } from "@prisma-next/family-sql/migration";
9
9
  import { Contract } from "@prisma-next/contract/types";
10
10
  import { ExecuteRequestLowerer, SqlControlAdapter } from "@prisma-next/family-sql/control-adapter";
11
11
 
@@ -178,4 +178,4 @@ declare abstract class PostgresMigration extends Migration<PostgresPlanTargetDet
178
178
  }
179
179
  //#endregion
180
180
  export { PostgresMigration as t };
181
- //# sourceMappingURL=postgres-migration-Y4YBJqkS.d.mts.map
181
+ //# sourceMappingURL=postgres-migration-Cs7zMOe1.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"postgres-migration-Y4YBJqkS.d.mts","names":[],"sources":["../src/core/migrations/operations/indexes.ts","../src/core/migrations/postgres-migration.ts"],"mappings":";;;;;;;;;;;;UAmBiB,iBAAA;EAAA,SACN,IAAA;EAAA,SACA,OAAA,GAAU,MAAM;AAAA;;;AAF3B;;;;;;;;AAE2B;;;;ACyC3B;;;;;;;;;;;;;;;AD3CA,uBC2CsB,iBAAA,SAA0B,SAAA,CAC9C,yBAAA;EAAA,SAGS,QAAA;EA+CL;;;;;;EAAA,mBAvCe,cAAA,EAAgB,iBAAA;cAEvB,KAAA,GAAQ,YAAA;EAkFkB;;;;;EAAA,UAnE5B,aAAA,mBAAgC,QAA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AA,SACA,KAAA;IAAA,SACA,OAAA;IAAA,SACA,MAAA,GAAS,iBAAA;EAAA,IAChB,OAAA,CAAQ,yBAAA,CAA0B,yBAAA;EAAA,UAa5B,SAAA,CAAU,OAAA;IAAA,SACT,MAAA;IAAA,SACA,KAAA;IAAA,SACA,KAAA;EAAA,IACP,OAAA,CAAQ,yBAAA,CAA0B,yBAAA;EAAA,UAS5B,gBAAA,CAAiB,OAAA;IAAA,SAChB,aAAA;IAAA,SACA,WAAA;IAAA,SACA,EAAA;IAAA,SACA,KAAA;EAAA,IACP,OAAA,CAAQ,yBAAA,CAA0B,yBAAA;AAAA"}
1
+ {"version":3,"file":"postgres-migration-Cs7zMOe1.d.mts","names":[],"sources":["../src/core/migrations/operations/indexes.ts","../src/core/migrations/postgres-migration.ts"],"mappings":";;;;;;;;;;;;UAmBiB,iBAAA;EAAA,SACN,IAAA;EAAA,SACA,OAAA,GAAU,MAAM;AAAA;;;AAF3B;;;;;;;;AAE2B;;;;ACyC3B;;;;;;;;;;;;;;;AD3CA,uBC2CsB,iBAAA,SAA0B,SAAA,CAC9C,yBAAA;EAAA,SAGS,QAAA;EA+CL;;;;;;EAAA,mBAvCe,cAAA,EAAgB,iBAAA;cAEvB,KAAA,GAAQ,YAAA;EAkFkB;;;;;EAAA,UAnE5B,aAAA,mBAAgC,QAAA,CAAS,UAAA,GACjD,QAAA,EAAU,SAAA,EACV,IAAA,UACA,OAAA,EAAS,oBAAA,GACR,OAAA,CAAQ,yBAAA,CAA0B,yBAAA;EA+Fd;;;;;EAAA,UAnFb,WAAA,CAAY,OAAA;IAAA,SACX,MAAA;IAAA,SACA,KAAA;IAAA,SACA,WAAA;IAAA,SACA,OAAA,WAAkB,SAAA;IAAA,SAClB,WAAA,YAAuB,kBAAA;EAAA,IAC9B,OAAA,CAAQ,yBAAA,CAA0B,yBAAA;EA4HlC;;;;;EAAA,UA3GM,YAAA,CAAa,OAAA;IAAA,SACZ,MAAA;IAAA,SACA,WAAA;EAAA,IAC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 @@
1
+ import { SqlNode } from "@prisma-next/sql-contract/types";
2
+ import { DiffableNode } from "@prisma-next/framework-components/control";
3
+
4
+ //#region src/core/schema-ir/postgres-rls-policy.d.ts
5
+ type RlsPolicyOperation = 'select' | 'insert' | 'update' | 'delete' | 'all';
6
+ interface PostgresRlsPolicyInput {
7
+ /** Full wire name: `<prefix>_<8hex>`. Stored as-is; hashing is not this class's job. */
8
+ readonly name: string;
9
+ /** User-supplied prefix (the part before the `_<8hex>` suffix). */
10
+ readonly prefix: string;
11
+ /** Name of the table this policy attaches to, by name within the same schema. */
12
+ readonly tableName: string;
13
+ /** Namespace coordinate (schema name). Policies are schema-scoped. */
14
+ readonly namespaceId: string;
15
+ readonly operation: RlsPolicyOperation;
16
+ /** Sorted role names rendered in `TO <roles>`. Plain strings in this slice. */
17
+ readonly roles: readonly string[];
18
+ /** USING predicate SQL string, if present. */
19
+ readonly using?: string;
20
+ /** WITH CHECK predicate SQL string, if present. */
21
+ readonly withCheck?: string;
22
+ /** `true` = `AS PERMISSIVE`, `false` = `AS RESTRICTIVE`. */
23
+ readonly permissive: boolean;
24
+ }
25
+ /**
26
+ * Postgres IR class for a row-level security policy (`CREATE POLICY … ON …`).
27
+ *
28
+ * Target-only concept — no SQL-family abstract. Extends `SqlNode` directly.
29
+ * Frozen at construction via `freezeNode(this)`. The `kind: 'policy'`
30
+ * discriminant is enumerable (overrides SqlNode's non-enumerable `'sql'`) so it
31
+ * survives JSON serialization and enables dispatch. The literal matches the
32
+ * entries key (one-string rule: node.kind === entries key === entity kind).
33
+ */
34
+ declare class PostgresRlsPolicy extends SqlNode implements DiffableNode {
35
+ readonly kind: "policy";
36
+ readonly name: string;
37
+ readonly prefix: string;
38
+ readonly tableName: string;
39
+ readonly namespaceId: string;
40
+ readonly operation: RlsPolicyOperation;
41
+ readonly roles: readonly string[];
42
+ readonly using?: string;
43
+ readonly withCheck?: string;
44
+ readonly permissive: boolean;
45
+ constructor(input: PostgresRlsPolicyInput);
46
+ get id(): string;
47
+ children(): readonly DiffableNode[];
48
+ /**
49
+ * Equality by wire name only. The wire name is `<prefix>_<sha256(body)[0..8]>`,
50
+ * so name-equality IS body-equality — two policies with different bodies
51
+ * have different hashes and therefore different names. We deliberately
52
+ * skip comparing bodies directly because Postgres reprints predicate
53
+ * expressions (e.g. strips outer parentheses), so a byte-compare against
54
+ * the authored body would produce false mismatches on a clean re-verify.
55
+ */
56
+ isEqualTo(other: DiffableNode): boolean;
57
+ }
58
+ //#endregion
59
+ export { PostgresRlsPolicyInput as n, RlsPolicyOperation as r, PostgresRlsPolicy as t };
60
+ //# sourceMappingURL=postgres-rls-policy-12wAEQhs.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-rls-policy-12wAEQhs.d.mts","names":[],"sources":["../src/core/schema-ir/postgres-rls-policy.ts"],"mappings":";;;;KAIY,kBAAA;AAAA,UAEK,sBAAA;EAFL;EAAA,SAID,IAAA;;WAEA,MAAA;EANmB;EAAA,SAQnB,SAAA;EAN4B;EAAA,SAQ5B,WAAA;EAAA,SACA,SAAA,EAAW,kBAAkB;EAP7B;EAAA,SASA,KAAA;EALA;EAAA,SAOA,KAAA;EAJA;EAAA,SAMA,SAAA;EAJA;EAAA,SAMA,UAAA;AAAA;;;AAAU;AAYrB;;;;;;cAAa,iBAAA,SAA0B,OAAA,YAAmB,YAAA;EAAA,SACtC,IAAA;EAAA,SACT,IAAA;EAAA,SACA,MAAA;EAAA,SACA,SAAA;EAAA,SACA,WAAA;EAAA,SACA,SAAA,EAAW,kBAAA;EAAA,SACX,KAAA;EAAA,SACQ,KAAA;EAAA,SACA,SAAA;EAAA,SACR,UAAA;cAEG,KAAA,EAAO,sBAAA;EAAA,IAcf,EAAA;EAIJ,QAAA,aAAqB,YAAA;EAvBZ;;;;;;;;EAmCT,SAAA,CAAU,KAAA,EAAO,YAAA;AAAA"}
@@ -0,0 +1,190 @@
1
+ import { t as PostgresTableSource } from "./table-source-BvFo7gVs.mjs";
2
+ import { t as PostgresRlsPolicy } from "./postgres-rls-policy-12wAEQhs.mjs";
3
+ import { SqlNamespaceBase, SqlNamespaceEntries, SqlNamespaceInput, SqlNode, SqlStorage, StorageTable, StorageValueSet } from "@prisma-next/sql-contract/types";
4
+ import { CfExpr } from "@prisma-next/sql-relational-core/contract-free";
5
+ import { DiffableNode } from "@prisma-next/framework-components/control";
6
+ import { Contract } from "@prisma-next/contract/types";
7
+
8
+ //#region src/core/schema-ir/postgres-role.d.ts
9
+ interface PostgresRoleInput {
10
+ readonly name: string;
11
+ /**
12
+ * Namespace coordinate. Roles are cluster-scoped; pass `UNBOUND_NAMESPACE_ID`
13
+ * from `@prisma-next/framework-components/ir`.
14
+ */
15
+ readonly namespaceId: string;
16
+ }
17
+ /**
18
+ * Postgres IR class for a database role (`CREATE ROLE …`).
19
+ *
20
+ * Roles are cluster-scoped, so their namespace coordinate is always
21
+ * `UNBOUND_NAMESPACE_ID`. Target-only concept — no SQL-family abstract.
22
+ * Extends `SqlNode` directly, frozen at construction via `freezeNode(this)`.
23
+ * The `kind: 'role'` discriminant is enumerable so it survives JSON.
24
+ * Matches the entries key (one-string rule).
25
+ */
26
+ declare class PostgresRole extends SqlNode implements DiffableNode {
27
+ readonly kind: "role";
28
+ readonly name: string;
29
+ readonly namespaceId: string;
30
+ constructor(input: PostgresRoleInput);
31
+ /** Roles are cluster-unique; the name alone is sufficient as the id. */
32
+ get id(): string;
33
+ children(): readonly DiffableNode[];
34
+ isEqualTo(other: DiffableNode): boolean;
35
+ }
36
+ //#endregion
37
+ //#region src/core/postgres-schema.d.ts
38
+ type PostgresContract = Contract<SqlStorage> & {
39
+ readonly target: 'postgres';
40
+ };
41
+ type PostgresNamespaceEntries = SqlNamespaceEntries & {
42
+ readonly policy?: Readonly<Record<string, PostgresRlsPolicy>>;
43
+ readonly role?: Readonly<Record<string, PostgresRole>>;
44
+ };
45
+ interface PostgresSchemaInput {
46
+ readonly id: string;
47
+ readonly entries: Readonly<Record<string, Readonly<Record<string, unknown>>>>;
48
+ }
49
+ /**
50
+ * Postgres target `Namespace` concretion — a Postgres schema (`CREATE
51
+ * SCHEMA …`). Each Postgres `SqlStorage` carries a
52
+ * `namespaces: Record<NamespaceId, PostgresSchema>` map populated by
53
+ * the Postgres PSL interpreter from `namespace { … }` AST buckets.
54
+ *
55
+ * `entries` holds entity-kind maps (`table`, `valueSet`). Qualifier
56
+ * emission is the rendering seam: DDL / SQL emission asks the namespace
57
+ * for its qualifier (`"<schema>"`) or for a qualified table name
58
+ * (`"<schema>"."<table>"`) and consumes the result polymorphically.
59
+ * The unbound singleton below overrides these methods to elide the
60
+ * prefix entirely — call sites stay polymorphic and never branch on
61
+ * `id === UNBOUND_NAMESPACE_ID`.
62
+ */
63
+ declare class PostgresSchema extends SqlNamespaceBase {
64
+ /**
65
+ * Stable singleton reference for the late-bound slot. Materialised
66
+ * lazily below the singleton subclass declaration so the static
67
+ * initialiser sees the subclass before assigning. Consumers always
68
+ * reach for `PostgresSchema.unbound` (or `PostgresUnboundSchema.instance`
69
+ * — same identity).
70
+ */
71
+ static unbound: PostgresUnboundSchema;
72
+ readonly kind: 'schema';
73
+ readonly id: string;
74
+ readonly entries: PostgresNamespaceEntries;
75
+ constructor(input: PostgresSchemaInput);
76
+ get table(): Readonly<Record<string, StorageTable>>;
77
+ get valueSet(): Readonly<Record<string, StorageValueSet>> | undefined;
78
+ get policy(): Readonly<Record<string, PostgresRlsPolicy>>;
79
+ get role(): Readonly<Record<string, PostgresRole>>;
80
+ /**
81
+ * The bare schema qualifier as it would appear in a rendered SQL
82
+ * fragment (already quoted). The unbound-schema singleton overrides
83
+ * this to return `''`.
84
+ */
85
+ qualifier(): string;
86
+ /**
87
+ * Qualify a table name with the schema prefix
88
+ * (`"<schema>"."<table>"`). The unbound-schema singleton overrides
89
+ * this to emit just `"<table>"` so the resolved DDL is unqualified
90
+ * and `search_path` decides where the object lands at runtime.
91
+ */
92
+ qualifyTable(tableName: string): string;
93
+ /**
94
+ * Render a SQL string-literal containing the qualified-name form
95
+ * suitable for `to_regclass(...)` arguments (e.g. `'"public"."user"'`).
96
+ * The unbound singleton overrides this to elide the schema prefix
97
+ * (`'"user"'`) so `search_path` resolves the object at runtime.
98
+ */
99
+ regclassLiteral(name: string): string;
100
+ /**
101
+ * Render a SQL expression that evaluates to this namespace's schema
102
+ * name at runtime, ready to drop into a `WHERE table_schema = …` /
103
+ * `WHERE n.nspname = …` clause. Named schemas emit a quoted SQL
104
+ * literal (`'public'`); the unbound singleton overrides this to emit
105
+ * `current_schema()` so catalog queries match whichever schema the
106
+ * connection's `search_path` resolved at runtime.
107
+ */
108
+ schemaSqlExpression(): string;
109
+ /**
110
+ * Typed-AST counterpart of {@link schemaSqlExpression}: the expression a
111
+ * builder-built catalog check compares `n.nspname` / `table_schema`
112
+ * against. Named schemas bind the schema name as a text parameter; the
113
+ * unbound singleton overrides this to the opaque `current_schema()`
114
+ * expression so the live connection's `search_path` decides at runtime.
115
+ */
116
+ schemaFilterExpression(): CfExpr;
117
+ /**
118
+ * Typed-AST counterpart of {@link qualifyTable}: the FROM source a
119
+ * builder-built check uses to address a user table in this namespace.
120
+ * Named schemas qualify (`"schema"."table"`); the unbound singleton
121
+ * overrides this to leave the table unqualified so `search_path`
122
+ * resolves it at runtime.
123
+ */
124
+ tableSource(tableName: string, alias?: string): PostgresTableSource;
125
+ /**
126
+ * The bare schema name a DDL planner should target when emitting
127
+ * statements that need to identify this namespace in the live
128
+ * database (e.g. `CREATE TABLE "<ddlSchemaName>"."<table>" …`,
129
+ * catalog filters, planner conflict lookups). Named schemas resolve
130
+ * to their own id. The `PostgresUnboundSchema` singleton inherits
131
+ * this and returns `UNBOUND_NAMESPACE_ID` — callers that dispatch
132
+ * through `qualifyTableName` route through the polymorphic
133
+ * `PostgresUnboundSchema` overrides and produce unqualified
134
+ * (search-path-resolved) output automatically.
135
+ */
136
+ ddlSchemaName(_storage: SqlStorage): string;
137
+ }
138
+ /**
139
+ * Singleton subclass for the reserved sentinel namespace id
140
+ * (`UNBOUND_NAMESPACE_ID`) — the late-bound Postgres slot whose binding
141
+ * the connection's `search_path` resolves at runtime. Overrides
142
+ * qualifier emission to elide the schema prefix; call sites that consume
143
+ * `qualifier()` / `qualifyTable()` get unqualified output without
144
+ * branching on the namespace id.
145
+ *
146
+ * This is the target-side materialization of "the framework provides
147
+ * affordances; targets implement specifics": the framework names the
148
+ * sentinel; Postgres decides what late-bound means here (the table
149
+ * name, naked — the schema is supplied by the live connection's
150
+ * `search_path`).
151
+ *
152
+ * `ddlSchemaName` is inherited from `PostgresSchema` and returns
153
+ * `UNBOUND_NAMESPACE_ID`. Downstream helpers such as `qualifyTableName`
154
+ * route through the polymorphic factory and produce unqualified output
155
+ * automatically.
156
+ */
157
+ declare class PostgresUnboundSchema extends PostgresSchema {
158
+ static readonly instance: PostgresUnboundSchema;
159
+ constructor(input?: PostgresSchemaInput);
160
+ qualifier(): string;
161
+ qualifyTable(tableName: string): string;
162
+ schemaSqlExpression(): string;
163
+ schemaFilterExpression(): CfExpr;
164
+ tableSource(tableName: string, alias?: string): PostgresTableSource;
165
+ }
166
+ /**
167
+ * Narrow an arbitrary namespace (or `undefined`) to `PostgresSchema`
168
+ * so callers can dispatch to the polymorphic emission methods without
169
+ * branching at the call site. Uses the structural `kind` discriminator
170
+ * (`'schema'`) rather than `instanceof` so the check survives realm /
171
+ * bundle / hot-reload boundaries — matching the rest of the IR's
172
+ * narrowing convention. `PostgresUnboundSchema` passes through because
173
+ * it inherits the same `kind: 'schema'` from `PostgresSchema`.
174
+ */
175
+ declare function isPostgresSchema(ns: unknown): ns is PostgresSchema;
176
+ /**
177
+ * Target-supplied `Namespace` factory the Postgres target plumbs
178
+ * through `defineContract({ createNamespace })` and the SQL PSL
179
+ * interpreter. Returns the unbound singleton for the framework
180
+ * sentinel and a fresh `PostgresSchema` for any other coordinate.
181
+ *
182
+ * The factory has no per-call state — every named id deterministically
183
+ * maps to a distinct schema instance — so callers can pass it through
184
+ * by reference and trust the resulting `SqlStorage.namespaces` map to
185
+ * be value-stable for a given input set.
186
+ */
187
+ declare function postgresCreateNamespace(input: SqlNamespaceInput): PostgresSchema;
188
+ //#endregion
189
+ export { postgresCreateNamespace as a, isPostgresSchema as i, PostgresSchema as n, PostgresRole as o, PostgresUnboundSchema as r, PostgresRoleInput as s, PostgresContract as t };
190
+ //# sourceMappingURL=postgres-schema-DJUEkWg-.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-schema-DJUEkWg-.d.mts","names":[],"sources":["../src/core/schema-ir/postgres-role.ts","../src/core/postgres-schema.ts"],"mappings":";;;;;;;;UAIiB,iBAAA;EAAA,SACN,IAAA;;;;;WAKA,WAAW;AAAA;;;AAAA;AAYtB;;;;;;cAAa,YAAA,SAAqB,OAAA,YAAmB,YAAA;EAAA,SACjC,IAAA;EAAA,SACT,IAAA;EAAA,SACA,WAAA;cAEG,KAAA,EAAO,iBAAA;EALgC;EAAA,IAa/C,EAAA;EAIJ,QAAA,aAAqB,YAAA;EAIrB,SAAA,CAAU,KAAA,EAAO,YAAA;AAAA;;;KCjBP,gBAAA,GAAmB,QAAQ,CAAC,UAAA;EAAA,SAAyB,MAAA;AAAA;AAAA,KAErD,wBAAA,GAA2B,mBAAA;EAAA,SAC5B,MAAA,GAAS,QAAA,CAAS,MAAA,SAAe,iBAAA;EAAA,SACjC,IAAA,GAAO,QAAA,CAAS,MAAA,SAAe,YAAA;AAAA;AAAA,UAGzB,mBAAA;EAAA,SACN,EAAA;EAAA,SACA,OAAA,EAAS,QAAA,CAAS,MAAA,SAAe,QAAA,CAAS,MAAA;AAAA;;;;;;;;;;;;;;;cAiBxC,cAAA,SAAuB,gBAAA;EDblC;;;;;;AAI6B;EAJ7B,OCqBO,OAAA,EAAS,qBAAA;EAAA,SAEC,IAAA;EAAA,SACR,EAAA;EAAA,SACA,OAAA,EAAS,wBAAA;cAEN,KAAA,EAAO,mBAAA;EAAA,IAgCf,KAAA,IAAS,QAAA,CAAS,MAAA,SAAe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