@prisma-next/target-postgres 0.14.0-dev.2 → 0.14.0-dev.21

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 (155) 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/codecs.mjs.map +1 -1
  6. package/dist/contract-free.d.mts +8 -3
  7. package/dist/contract-free.d.mts.map +1 -1
  8. package/dist/contract-free.mjs +3 -3
  9. package/dist/control.d.mts +1 -1
  10. package/dist/control.mjs +6 -6
  11. package/dist/data-transform-BOWpliq8.mjs.map +1 -1
  12. package/dist/{data-transform-DDgWdB5o.d.mts → data-transform-qKy1U5V9.d.mts} +2 -2
  13. package/dist/{data-transform-DDgWdB5o.d.mts.map → data-transform-qKy1U5V9.d.mts.map} +1 -1
  14. package/dist/data-transform.d.mts +1 -1
  15. package/dist/{ddl-QDyOSeLc.mjs → ddl-BJPdPsT3.mjs} +62 -5
  16. package/dist/ddl-BJPdPsT3.mjs.map +1 -0
  17. package/dist/ddl.d.mts +3 -2
  18. package/dist/ddl.mjs +2 -2
  19. package/dist/{default-normalizer-DyyCHQWs.mjs → default-normalizer-CzV8-QSu.mjs} +58 -2
  20. package/dist/default-normalizer-CzV8-QSu.mjs.map +1 -0
  21. package/dist/default-normalizer.d.mts +1 -1
  22. package/dist/default-normalizer.d.mts.map +1 -1
  23. package/dist/default-normalizer.mjs +1 -1
  24. package/dist/descriptor-meta-CKpjK2Nv.mjs +17 -0
  25. package/dist/descriptor-meta-CKpjK2Nv.mjs.map +1 -0
  26. package/dist/descriptor-meta-runtime-DiVla56r.mjs +228 -0
  27. package/dist/descriptor-meta-runtime-DiVla56r.mjs.map +1 -0
  28. package/dist/{issue-planner-DL6g3CmE.mjs → issue-planner-YwXUKGZ1.mjs} +11 -9
  29. package/dist/issue-planner-YwXUKGZ1.mjs.map +1 -0
  30. package/dist/issue-planner.d.mts +3 -3
  31. package/dist/issue-planner.d.mts.map +1 -1
  32. package/dist/issue-planner.mjs +1 -1
  33. package/dist/migration.d.mts +3 -3
  34. package/dist/migration.mjs +2 -2
  35. package/dist/nodes-CSkPX3rI.d.mts +120 -0
  36. package/dist/nodes-CSkPX3rI.d.mts.map +1 -0
  37. package/dist/{nodes-Bbhs2rwj.mjs → nodes-Dh__NS58.mjs} +56 -2
  38. package/dist/nodes-Dh__NS58.mjs.map +1 -0
  39. package/dist/{op-factory-call-DmQEc3XV.d.mts → op-factory-call-CQ4P40QC.d.mts} +44 -13
  40. package/dist/op-factory-call-CQ4P40QC.d.mts.map +1 -0
  41. package/dist/{op-factory-call-D_p5vxwt.mjs → op-factory-call-DcY4BHNh.mjs} +199 -28
  42. package/dist/op-factory-call-DcY4BHNh.mjs.map +1 -0
  43. package/dist/op-factory-call.d.mts +1 -1
  44. package/dist/op-factory-call.mjs +1 -1
  45. package/dist/pack.d.mts +74 -1
  46. package/dist/pack.d.mts.map +1 -1
  47. package/dist/pack.mjs +1 -1
  48. package/dist/{planner-Bs_baQax.mjs → planner-_ZHpIQ1-.mjs} +115 -23
  49. package/dist/planner-_ZHpIQ1-.mjs.map +1 -0
  50. package/dist/{planner-ddl-builders-B2wOwLqI.mjs → planner-ddl-builders-B8Nn6nHN.mjs} +12 -27
  51. package/dist/planner-ddl-builders-B8Nn6nHN.mjs.map +1 -0
  52. package/dist/planner-ddl-builders.d.mts +2 -4
  53. package/dist/planner-ddl-builders.d.mts.map +1 -1
  54. package/dist/planner-ddl-builders.mjs +2 -2
  55. package/dist/{planner-produced-postgres-migration-QqHa2C2l.d.mts → planner-produced-postgres-migration-CNTSCMl7.d.mts} +3 -3
  56. package/dist/{planner-produced-postgres-migration-QqHa2C2l.d.mts.map → planner-produced-postgres-migration-CNTSCMl7.d.mts.map} +1 -1
  57. package/dist/{planner-produced-postgres-migration-Cji5vxUf.mjs → planner-produced-postgres-migration-Dv5ZAvHt.mjs} +2 -2
  58. package/dist/{planner-produced-postgres-migration-Cji5vxUf.mjs.map → planner-produced-postgres-migration-Dv5ZAvHt.mjs.map} +1 -1
  59. package/dist/planner-produced-postgres-migration.d.mts +1 -1
  60. package/dist/planner-produced-postgres-migration.mjs +1 -1
  61. package/dist/{planner-sql-checks-jqUUGyQR.mjs → planner-sql-checks-C7nLjabn.mjs} +2 -2
  62. package/dist/{planner-sql-checks-jqUUGyQR.mjs.map → planner-sql-checks-C7nLjabn.mjs.map} +1 -1
  63. package/dist/planner-sql-checks.mjs +1 -1
  64. package/dist/{planner-target-details-CIY6tLeo.d.mts → planner-target-details-HkP4RrRO.d.mts} +2 -2
  65. package/dist/planner-target-details-HkP4RrRO.d.mts.map +1 -0
  66. package/dist/planner-target-details.d.mts +1 -1
  67. package/dist/planner.d.mts +35 -3
  68. package/dist/planner.d.mts.map +1 -1
  69. package/dist/planner.mjs +2 -2
  70. package/dist/{postgres-contract-serializer-k3TAcPMY.mjs → postgres-contract-serializer-DJDGaS0q.mjs} +30 -21
  71. package/dist/postgres-contract-serializer-DJDGaS0q.mjs.map +1 -0
  72. package/dist/{postgres-migration-B5jKrXv3.mjs → postgres-migration-Bj0olfl3.mjs} +2 -2
  73. package/dist/{postgres-migration-B5jKrXv3.mjs.map → postgres-migration-Bj0olfl3.mjs.map} +1 -1
  74. package/dist/{postgres-migration-Y4YBJqkS.d.mts → postgres-migration-DJNJHcdP.d.mts} +4 -4
  75. package/dist/{postgres-migration-Y4YBJqkS.d.mts.map → postgres-migration-DJNJHcdP.d.mts.map} +1 -1
  76. package/dist/postgres-rls-policy-D_z1osEq.d.mts +60 -0
  77. package/dist/postgres-rls-policy-D_z1osEq.d.mts.map +1 -0
  78. package/dist/postgres-role-_CCuyPCQ.d.mts +33 -0
  79. package/dist/postgres-role-_CCuyPCQ.d.mts.map +1 -0
  80. package/dist/postgres-schema-Bn4tsMuo.d.mts +157 -0
  81. package/dist/postgres-schema-Bn4tsMuo.d.mts.map +1 -0
  82. package/dist/{postgres-schema-COGZ1ark.mjs → postgres-schema-DfuJq-q_.mjs} +141 -5
  83. package/dist/postgres-schema-DfuJq-q_.mjs.map +1 -0
  84. package/dist/postgres-schema-ir-BF0X8jit.mjs +66 -0
  85. package/dist/postgres-schema-ir-BF0X8jit.mjs.map +1 -0
  86. package/dist/postgres-schema-ir-BQ3RpZMz.d.mts +60 -0
  87. package/dist/postgres-schema-ir-BQ3RpZMz.d.mts.map +1 -0
  88. package/dist/postgres-schema-ir-annotations-CWHQ-H9Y.mjs +14 -0
  89. package/dist/postgres-schema-ir-annotations-CWHQ-H9Y.mjs.map +1 -0
  90. package/dist/render-ops.d.mts +1 -1
  91. package/dist/rls-canonicalize.d.mts +2 -0
  92. package/dist/rls-canonicalize.mjs +2 -0
  93. package/dist/runtime.d.mts +5 -5
  94. package/dist/runtime.d.mts.map +1 -1
  95. package/dist/runtime.mjs +2 -2
  96. package/dist/schema-ir-annotations.d.mts +8 -0
  97. package/dist/schema-ir-annotations.d.mts.map +1 -0
  98. package/dist/schema-ir-annotations.mjs +2 -0
  99. package/dist/types.d.mts +5 -140
  100. package/dist/types.mjs +3 -2
  101. package/package.json +21 -17
  102. package/src/contract-free/checks.ts +73 -0
  103. package/src/contract-free/ddl.ts +45 -1
  104. package/src/core/authoring.ts +115 -1
  105. package/src/core/codecs.ts +1 -1
  106. package/src/core/ddl/nodes.ts +94 -2
  107. package/src/core/default-normalizer.ts +60 -2
  108. package/src/core/descriptor-meta.ts +4 -0
  109. package/src/core/entity-kinds.ts +16 -0
  110. package/src/core/migrations/bound-schema.ts +10 -0
  111. package/src/core/migrations/control-policy.ts +3 -0
  112. package/src/core/migrations/issue-planner.ts +8 -0
  113. package/src/core/migrations/op-factory-call.ts +106 -21
  114. package/src/core/migrations/operations/columns.ts +24 -12
  115. package/src/core/migrations/operations/data-transform.ts +6 -0
  116. package/src/core/migrations/operations/rls.ts +106 -0
  117. package/src/core/migrations/operations/shared.ts +0 -30
  118. package/src/core/migrations/planner-ddl-builders.ts +15 -56
  119. package/src/core/migrations/planner-recipes.ts +31 -13
  120. package/src/core/migrations/planner-strategies.ts +3 -11
  121. package/src/core/migrations/planner-target-details.ts +3 -1
  122. package/src/core/migrations/planner.ts +99 -1
  123. package/src/core/migrations/verify-postgres-namespaces.ts +12 -15
  124. package/src/core/migrations/verify-postgres-rls-policies.ts +62 -0
  125. package/src/core/postgres-contract-serializer.ts +48 -33
  126. package/src/core/postgres-rls-policy.ts +103 -0
  127. package/src/core/postgres-role.ts +53 -0
  128. package/src/core/postgres-schema-ir-annotations.ts +22 -0
  129. package/src/core/postgres-schema-ir.ts +101 -0
  130. package/src/core/postgres-schema.ts +33 -13
  131. package/src/core/postgres-validators.ts +20 -0
  132. package/src/core/rls/canonicalize.ts +48 -0
  133. package/src/exports/contract-free.ts +7 -1
  134. package/src/exports/ddl.ts +4 -0
  135. package/src/exports/planner-ddl-builders.ts +0 -2
  136. package/src/exports/planner.ts +1 -0
  137. package/src/exports/rls-canonicalize.ts +6 -0
  138. package/src/exports/schema-ir-annotations.ts +1 -0
  139. package/src/exports/types.ts +12 -0
  140. package/dist/ddl-QDyOSeLc.mjs.map +0 -1
  141. package/dist/default-normalizer-DyyCHQWs.mjs.map +0 -1
  142. package/dist/descriptor-meta-CpGygXpI.mjs +0 -140
  143. package/dist/descriptor-meta-CpGygXpI.mjs.map +0 -1
  144. package/dist/issue-planner-DL6g3CmE.mjs.map +0 -1
  145. package/dist/nodes-Bbhs2rwj.mjs.map +0 -1
  146. package/dist/nodes-pLeLgdis.d.mts +0 -67
  147. package/dist/nodes-pLeLgdis.d.mts.map +0 -1
  148. package/dist/op-factory-call-D_p5vxwt.mjs.map +0 -1
  149. package/dist/op-factory-call-DmQEc3XV.d.mts.map +0 -1
  150. package/dist/planner-Bs_baQax.mjs.map +0 -1
  151. package/dist/planner-ddl-builders-B2wOwLqI.mjs.map +0 -1
  152. package/dist/planner-target-details-CIY6tLeo.d.mts.map +0 -1
  153. package/dist/postgres-contract-serializer-k3TAcPMY.mjs.map +0 -1
  154. package/dist/postgres-schema-COGZ1ark.mjs.map +0 -1
  155. package/dist/types.d.mts.map +0 -1
@@ -1,6 +1,8 @@
1
- import { t as TypeScriptRenderablePostgresMigration } from "./planner-produced-postgres-migration-QqHa2C2l.mjs";
1
+ import { t as TypeScriptRenderablePostgresMigration } from "./planner-produced-postgres-migration-CNTSCMl7.mjs";
2
+ import { t as PostgresSchemaIR } from "./postgres-schema-ir-BQ3RpZMz.mjs";
2
3
  import { MigrationOperationPolicy, SqlPlannerConflict, SqlPlannerFailureResult } from "@prisma-next/family-sql/control";
3
- import { MigrationPlanWithAuthoringSurface, MigrationPlanner, MigrationScaffoldContext } from "@prisma-next/framework-components/control";
4
+ import { SqlStorage } from "@prisma-next/sql-contract/types";
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";
@@ -68,9 +70,39 @@ declare class PostgresMigrationPlanner implements MigrationPlanner<'sql', 'postg
68
70
  }): PostgresPlanResult;
69
71
  emptyMigration(context: MigrationScaffoldContext, spaceId: string): MigrationPlanWithAuthoringSurface;
70
72
  private planSql;
73
+ private planRlsDiff;
71
74
  private ensureAdditivePolicy;
72
75
  private collectSchemaIssues;
73
76
  }
74
77
  //#endregion
75
- export { createPostgresMigrationPlanner };
78
+ //#region src/core/migrations/verify-postgres-rls-policies.d.ts
79
+ /**
80
+ * Computes RLS policy drift between the contract and the live DB schema using
81
+ * the generic {@link diffNodes} differ. Returns `SchemaDiffIssue[]` keyed by
82
+ * the full `EntityCoordinate` (plane + namespaceId + entityKind + entityName).
83
+ *
84
+ * Both sides supply `PostgresRlsPolicy` nodes that implement `DiffableNode`
85
+ * with a concrete namespace coordinate — the contract carries explicit
86
+ * `namespaceId` set during lowering (e.g. `'public'`); the introspected schema
87
+ * carries the resolved DDL schema name. The differ matches purely on coordinate
88
+ * identity; no namespace interpretation happens here.
89
+ *
90
+ * The diff is scoped to the namespaces the verified contract owns. The live
91
+ * schema introspection returns every policy across all DB schemas, but a policy
92
+ * in a namespace this contract does not own belongs to another contract space
93
+ * (or is external) and must not be reported as extra. Without this scope a space
94
+ * that owns only `auth`/`storage` (e.g. the supabase extension space) would flag
95
+ * the application space's `public.*` policies as extra during verify.
96
+ *
97
+ * Ownership is the set of namespaces the contract declares (its
98
+ * `storage.namespaces` slot keys), with the late-bound `__unbound__` slot
99
+ * resolved to the Postgres default `public` so a single-namespace contract still
100
+ * owns — and diffs — its `public` policies.
101
+ */
102
+ declare function diffPostgresRlsPolicies(input: {
103
+ readonly contract: Contract<SqlStorage>;
104
+ readonly schema: PostgresSchemaIR;
105
+ }): readonly SchemaDiffIssue[];
106
+ //#endregion
107
+ export { createPostgresMigrationPlanner, diffPostgresRlsPolicies };
76
108
  //# 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/planner.ts","../src/core/migrations/verify-postgres-rls-policies.ts"],"mappings":";;;;;;;;;;iBA+DgB,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;AANJ;;;;;;;;;;;;;;;AAM2B;AAN3B,cAwBa,wBAAA,YAAoC,gBAAA;EAAA;cAGnC,OAAA,GAAU,qBAAA;EAItB,IAAA,CAAK,OAAA;IAAA,SACM,QAAA;IAAA,SACA,MAAA;IAAA,SACA,MAAA,EAAQ,wBAAA;IAiBa;;;;;;;;;;;;;;IAAA,SAFrB,YAAA,EAAc,QAAA;IAAA,SACd,UAAA;IAAA,SACA,mBAAA,EAAqB,aAAA,CAAc,8BAAA;IAFnC;;;;;IAAA,SAQA,OAAA;EAAA,IACP,kBAAA;EAIJ,cAAA,CACE,OAAA,EAAS,wBAAA,EACT,OAAA,WACC,iCAAA;EAAA,QAYK,OAAA;EAAA,QA0IA,WAAA;EAAA,QAgDA,oBAAA;EAAA,QAaA,mBAAA;AAAA;;;;;;;;;AAjSV;;;;;;;;AAE2B;AAW3B;;;;;;;;iBClCgB,uBAAA,CAAwB,KAAA;EAAA,SAC7B,QAAA,EAAU,QAAA,CAAS,UAAA;EAAA,SACnB,MAAA,EAAQ,gBAAA;AAAA,aACN,eAAA"}
package/dist/planner.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { t as createPostgresMigrationPlanner } from "./planner-Bs_baQax.mjs";
2
- export { createPostgresMigrationPlanner };
1
+ import { n as diffPostgresRlsPolicies, t as createPostgresMigrationPlanner } from "./planner-_ZHpIQ1-.mjs";
2
+ export { createPostgresMigrationPlanner, diffPostgresRlsPolicies };
@@ -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-DfuJq-q_.mjs";
2
+ import { n as postgresAuthoringEntityTypes } from "./descriptor-meta-runtime-DiVla56r.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-DJDGaS0q.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-contract-serializer-DJDGaS0q.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;CAChD,MAAM,2BAAW,IAAI,IAAuC;CAC5D,MAAM,QAAQ,SAA6C;EACzD,KAAK,MAAM,SAAS,OAAO,OAAO,IAAI,GAAG;GACvC,IAAI,gCAAgC,KAAK,GAAG;IAC1C,IAAI,mCAAmC,MAAM,MAAM,GAAG;KACpD,MAAM,EAAE,YAAY,MAAM;KAC1B,SAAS,IAAI,MAAM,gBAAgB,QAAQ,QAAQ,KAAK,sBAAsB,CAAC;IACjF;IACA;GACF;GACA,IAAI,OAAO,UAAU,YAAY,UAAU,MACzC,KAAK,KAAK;EAEd;CACF;CACA,KAAK,SAAS;CACd,OAAO;AACT;AAEA,IAAa,6BAAb,cAAgD,0BAAgD;CAC9F,YAAY,uBAA2D,CAAC,GAAG;EACzE,MAAM,wBAAwB,6BAA6B,4BAA4B;EACvF,MAAM,uBAAuB;GAAC;GAAkB;GAAgB,GAAG;EAAoB,CAAC;CAC1F;CAEA,yBACE,MACA,KAC+B;EAK/B,MAAM,EAAE,IAAI,YAJK,UAGf,MAAM,yBAAyB,MAAM,GAAG,CACX;EAE/B,MAAM,gBAAgB,OAAO,OAAO,OAAO,CAAC,CAAC,OAC1C,SAAS,SAAS,KAAA,KAAa,OAAO,KAAK,IAAI,CAAC,CAAC,WAAW,CAC/D;EACA,IAAI,OAAO,wBAAwB,eACjC,OAAO,eAAe;EAExB,MAAM,eAAe,QAAQ;EAC7B,MAAM,eAAe,iBAAiB,KAAA,KAAa,OAAO,KAAK,Y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aAAa,OAAO,QAAQ,eAAe,GACnE,YAAY,gBAAgB,KAAK,oBAAoB,QAAQ;EAGjE,MAAM,UAAsC,CAAC;EAC7C,KAAK,MAAM,CAAC,UAAU,SAAS,OAAO,QAAQ,GAAG,IAAI,GACnD,QAAQ,YAAY,KAAK,oBAAoB,IAAI;EAEnD,MAAM,YAAwC,CAAC;EAC/C,KAAK,MAAM,CAAC,YAAY,WAAW,OAAO,QAAQ,GAAG,MAAM,GACzD,UAAU,cAAc,KAAK,oBAAoB,MAAM;EAEzD,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-DcY4BHNh.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-Bj0olfl3.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;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AEA,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,WAAqB,SAM6C;EAChE,IAAI,CAAC,KAAK,gBACR,MAAM,mCAAmC;EAE3C,OAAO,IAAI,eACT,QAAQ,QACR,QAAQ,OACR,QAAQ,QACR,QAAQ,YACR,QAAQ,cACV,CAAC,CAAC,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-Bj0olfl3.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,OAAO,IAAI,gBACT,QAAQ,QACR,QAAQ,OACR,QAAQ,SACR,QAAQ,WACV,CAAC,CAAC,KAAK,KAAK,cAAc;CAC5B;;;;;;CAOA,aAAuB,SAG2C;EAChE,IAAI,CAAC,KAAK,gBACR,MAAM,mCAAmC;EAE3C,OAAO,IAAI,iBAAiB,QAAQ,MAAM,CAAC,CAAC,KAAK,KAAK,cAAc;CACtE;CAEA,UAAoB,SAI8C;EAChE,IAAI,CAAC,KAAK,gBACR,MAAM,mCAAmC;EAE3C,OAAO,IAAI,cAAc,QAAQ,QAAQ,QAAQ,OAAO,QAAQ,MAAM,CAAC,CAAC,KACtE,KAAK,cACP;CACF;CAEA,cAAwB,SAK0C;EAChE,IAA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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,6 +1,6 @@
1
- import { t as PostgresPlanTargetDetails } from "./planner-target-details-CIY6tLeo.mjs";
2
- import { n as DataTransformOptions } from "./data-transform-DDgWdB5o.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-CQ4P40QC.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";
@@ -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-DJNJHcdP.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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A,MAAA;EAAA,IACP,OAAA,CAAQ,yBAAA,CAA0B,yBAAA;EAAA,UAS5B,WAAA,CAAY,OAAA;IAAA,SACX,MAAA;IAAA,SACA,KAAA;IAAA,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-DJNJHcdP.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,OA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;IAAA,SACA,WAAA;IAAA,SACA,EAAA;IAAA,SACA,KAAA;EAAA,IACP,OAAA,CAAQ,yBAAA,CAA0B,yBAAA;AAAA"}
@@ -0,0 +1,60 @@
1
+ import { EntityCoordinate } from "@prisma-next/framework-components/ir";
2
+ import { SqlNode } from "@prisma-next/sql-contract/types";
3
+ import { DiffableNode } from "@prisma-next/framework-components/control";
4
+
5
+ //#region src/core/postgres-rls-policy.d.ts
6
+ type RlsPolicyOperation = 'select' | 'insert' | 'update' | 'delete' | 'all';
7
+ interface PostgresRlsPolicyInput {
8
+ /** Full wire name: `<prefix>_<8hex>`. Stored as-is; hashing is not this class's job. */
9
+ readonly name: string;
10
+ /** User-supplied prefix (the part before the `_<8hex>` suffix). */
11
+ readonly prefix: string;
12
+ /** Name of the table this policy attaches to, by name within the same schema. */
13
+ readonly tableName: string;
14
+ /** Namespace coordinate (schema name). Policies are schema-scoped. */
15
+ readonly namespaceId: string;
16
+ readonly operation: RlsPolicyOperation;
17
+ /** Sorted role names rendered in `TO <roles>`. Plain strings in this slice. */
18
+ readonly roles: readonly string[];
19
+ /** USING predicate SQL string, if present. */
20
+ readonly using?: string;
21
+ /** WITH CHECK predicate SQL string, if present. */
22
+ readonly withCheck?: string;
23
+ /** `true` = `AS PERMISSIVE`, `false` = `AS RESTRICTIVE`. */
24
+ readonly permissive: boolean;
25
+ }
26
+ /**
27
+ * Postgres IR class for a row-level security policy (`CREATE POLICY … ON …`).
28
+ *
29
+ * Target-only concept — no SQL-family abstract. Extends `SqlNode` directly.
30
+ * Frozen at construction via `freezeNode(this)`. The `kind: 'policy'`
31
+ * discriminant is enumerable (overrides SqlNode's non-enumerable `'sql'`) so it
32
+ * survives JSON serialization and enables dispatch. The literal matches the
33
+ * entries key (one-string rule: node.kind === entries key === entity kind).
34
+ */
35
+ declare class PostgresRlsPolicy extends SqlNode implements DiffableNode {
36
+ readonly kind: "policy";
37
+ readonly name: string;
38
+ readonly prefix: string;
39
+ readonly tableName: string;
40
+ readonly namespaceId: string;
41
+ readonly operation: RlsPolicyOperation;
42
+ readonly roles: readonly string[];
43
+ readonly using?: string;
44
+ readonly withCheck?: string;
45
+ readonly permissive: boolean;
46
+ constructor(input: PostgresRlsPolicyInput);
47
+ identity(): EntityCoordinate;
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-D_z1osEq.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-rls-policy-D_z1osEq.d.mts","names":[],"sources":["../src/core/postgres-rls-policy.ts"],"mappings":";;;;;KAKY,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;EAcnB,QAAA,IAAY,gBAAA;EApBQ;;;;;;;;EAqCpB,SAAA,CAAU,KAAA,EAAO,YAAA;AAAA"}
@@ -0,0 +1,33 @@
1
+ import { EntityCoordinate } from "@prisma-next/framework-components/ir";
2
+ import { SqlNode } from "@prisma-next/sql-contract/types";
3
+ import { DiffableNode } from "@prisma-next/framework-components/control";
4
+
5
+ //#region src/core/postgres-role.d.ts
6
+ interface PostgresRoleInput {
7
+ readonly name: string;
8
+ /**
9
+ * Namespace coordinate. Roles are cluster-scoped; pass `UNBOUND_NAMESPACE_ID`
10
+ * from `@prisma-next/framework-components/ir`.
11
+ */
12
+ readonly namespaceId: string;
13
+ }
14
+ /**
15
+ * Postgres IR class for a database role (`CREATE ROLE …`).
16
+ *
17
+ * Roles are cluster-scoped, so their namespace coordinate is always
18
+ * `UNBOUND_NAMESPACE_ID`. Target-only concept — no SQL-family abstract.
19
+ * Extends `SqlNode` directly, frozen at construction via `freezeNode(this)`.
20
+ * The `kind: 'role'` discriminant is enumerable so it survives JSON.
21
+ * Matches the entries key (one-string rule).
22
+ */
23
+ declare class PostgresRole extends SqlNode implements DiffableNode {
24
+ readonly kind: "role";
25
+ readonly name: string;
26
+ readonly namespaceId: string;
27
+ constructor(input: PostgresRoleInput);
28
+ identity(): EntityCoordinate;
29
+ isEqualTo(other: DiffableNode): boolean;
30
+ }
31
+ //#endregion
32
+ export { PostgresRoleInput as n, PostgresRole as t };
33
+ //# sourceMappingURL=postgres-role-_CCuyPCQ.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-role-_CCuyPCQ.d.mts","names":[],"sources":["../src/core/postgres-role.ts"],"mappings":";;;;;UAKiB,iBAAA;EAAA,SACN,IAAA;EADM;;;;EAAA,SAMN,WAAW;AAAA;;;;;;;;;;cAYT,YAAA,SAAqB,OAAA,YAAmB,YAAA;EAAA,SACjC,IAAA;EAAA,SACT,IAAA;EAAA,SACA,WAAA;cAEG,KAAA,EAAO,iBAAA;EAOnB,QAAA,IAAY,gBAAA;EASZ,SAAA,CAAU,KAAA,EAAO,YAAA;AAAA"}
@@ -0,0 +1,157 @@
1
+ import { t as PostgresTableSource } from "./table-source-BvFo7gVs.mjs";
2
+ import { t as PostgresRlsPolicy } from "./postgres-rls-policy-D_z1osEq.mjs";
3
+ import { t as PostgresRole } from "./postgres-role-_CCuyPCQ.mjs";
4
+ import { SqlNamespaceBase, SqlNamespaceEntries, SqlNamespaceInput, SqlStorage, StorageTable, StorageValueSet } from "@prisma-next/sql-contract/types";
5
+ import { CfExpr } from "@prisma-next/sql-relational-core/contract-free";
6
+
7
+ //#region src/core/postgres-schema.d.ts
8
+ type PostgresNamespaceEntries = SqlNamespaceEntries & {
9
+ readonly policy?: Readonly<Record<string, PostgresRlsPolicy>>;
10
+ readonly role?: Readonly<Record<string, PostgresRole>>;
11
+ };
12
+ interface PostgresSchemaInput {
13
+ readonly id: string;
14
+ readonly entries: Readonly<Record<string, Readonly<Record<string, unknown>>>>;
15
+ }
16
+ /**
17
+ * Postgres target `Namespace` concretion — a Postgres schema (`CREATE
18
+ * SCHEMA …`). Each Postgres `SqlStorage` carries a
19
+ * `namespaces: Record<NamespaceId, PostgresSchema>` map populated by
20
+ * the Postgres PSL interpreter from `namespace { … }` AST buckets.
21
+ *
22
+ * `entries` holds entity-kind maps (`table`, `valueSet`). Qualifier
23
+ * emission is the rendering seam: DDL / SQL emission asks the namespace
24
+ * for its qualifier (`"<schema>"`) or for a qualified table name
25
+ * (`"<schema>"."<table>"`) and consumes the result polymorphically.
26
+ * The unbound singleton below overrides these methods to elide the
27
+ * prefix entirely — call sites stay polymorphic and never branch on
28
+ * `id === UNBOUND_NAMESPACE_ID`.
29
+ */
30
+ declare class PostgresSchema extends SqlNamespaceBase {
31
+ /**
32
+ * Stable singleton reference for the late-bound slot. Materialised
33
+ * lazily below the singleton subclass declaration so the static
34
+ * initialiser sees the subclass before assigning. Consumers always
35
+ * reach for `PostgresSchema.unbound` (or `PostgresUnboundSchema.instance`
36
+ * — same identity).
37
+ */
38
+ static unbound: PostgresUnboundSchema;
39
+ readonly kind: 'schema';
40
+ readonly id: string;
41
+ readonly entries: PostgresNamespaceEntries;
42
+ constructor(input: PostgresSchemaInput);
43
+ get table(): Readonly<Record<string, StorageTable>>;
44
+ get valueSet(): Readonly<Record<string, StorageValueSet>> | undefined;
45
+ get policy(): Readonly<Record<string, PostgresRlsPolicy>>;
46
+ get role(): Readonly<Record<string, PostgresRole>>;
47
+ /**
48
+ * The bare schema qualifier as it would appear in a rendered SQL
49
+ * fragment (already quoted). The unbound-schema singleton overrides
50
+ * this to return `''`.
51
+ */
52
+ qualifier(): string;
53
+ /**
54
+ * Qualify a table name with the schema prefix
55
+ * (`"<schema>"."<table>"`). The unbound-schema singleton overrides
56
+ * this to emit just `"<table>"` so the resolved DDL is unqualified
57
+ * and `search_path` decides where the object lands at runtime.
58
+ */
59
+ qualifyTable(tableName: string): string;
60
+ /**
61
+ * Render a SQL string-literal containing the qualified-name form
62
+ * suitable for `to_regclass(...)` arguments (e.g. `'"public"."user"'`).
63
+ * The unbound singleton overrides this to elide the schema prefix
64
+ * (`'"user"'`) so `search_path` resolves the object at runtime.
65
+ */
66
+ regclassLiteral(name: string): string;
67
+ /**
68
+ * Render a SQL expression that evaluates to this namespace's schema
69
+ * name at runtime, ready to drop into a `WHERE table_schema = …` /
70
+ * `WHERE n.nspname = …` clause. Named schemas emit a quoted SQL
71
+ * literal (`'public'`); the unbound singleton overrides this to emit
72
+ * `current_schema()` so catalog queries match whichever schema the
73
+ * connection's `search_path` resolved at runtime.
74
+ */
75
+ schemaSqlExpression(): string;
76
+ /**
77
+ * Typed-AST counterpart of {@link schemaSqlExpression}: the expression a
78
+ * builder-built catalog check compares `n.nspname` / `table_schema`
79
+ * against. Named schemas bind the schema name as a text parameter; the
80
+ * unbound singleton overrides this to the opaque `current_schema()`
81
+ * expression so the live connection's `search_path` decides at runtime.
82
+ */
83
+ schemaFilterExpression(): CfExpr;
84
+ /**
85
+ * Typed-AST counterpart of {@link qualifyTable}: the FROM source a
86
+ * builder-built check uses to address a user table in this namespace.
87
+ * Named schemas qualify (`"schema"."table"`); the unbound singleton
88
+ * overrides this to leave the table unqualified so `search_path`
89
+ * resolves it at runtime.
90
+ */
91
+ tableSource(tableName: string, alias?: string): PostgresTableSource;
92
+ /**
93
+ * The bare schema name a DDL planner should target when emitting
94
+ * statements that need to identify this namespace in the live
95
+ * database (e.g. `CREATE TABLE "<ddlSchemaName>"."<table>" …`,
96
+ * catalog filters, planner conflict lookups). Named schemas resolve
97
+ * to their own id. The `PostgresUnboundSchema` singleton inherits
98
+ * this and returns `UNBOUND_NAMESPACE_ID` — callers that dispatch
99
+ * through `qualifyTableName` route through the polymorphic
100
+ * `PostgresUnboundSchema` overrides and produce unqualified
101
+ * (search-path-resolved) output automatically.
102
+ */
103
+ ddlSchemaName(_storage: SqlStorage): string;
104
+ }
105
+ /**
106
+ * Singleton subclass for the reserved sentinel namespace id
107
+ * (`UNBOUND_NAMESPACE_ID`) — the late-bound Postgres slot whose binding
108
+ * the connection's `search_path` resolves at runtime. Overrides
109
+ * qualifier emission to elide the schema prefix; call sites that consume
110
+ * `qualifier()` / `qualifyTable()` get unqualified output without
111
+ * branching on the namespace id.
112
+ *
113
+ * This is the target-side materialization of "the framework provides
114
+ * affordances; targets implement specifics": the framework names the
115
+ * sentinel; Postgres decides what late-bound means here (the table
116
+ * name, naked — the schema is supplied by the live connection's
117
+ * `search_path`).
118
+ *
119
+ * `ddlSchemaName` is inherited from `PostgresSchema` and returns
120
+ * `UNBOUND_NAMESPACE_ID`. Downstream helpers such as `qualifyTableName`
121
+ * route through the polymorphic factory and produce unqualified output
122
+ * automatically.
123
+ */
124
+ declare class PostgresUnboundSchema extends PostgresSchema {
125
+ static readonly instance: PostgresUnboundSchema;
126
+ constructor(input?: PostgresSchemaInput);
127
+ qualifier(): string;
128
+ qualifyTable(tableName: string): string;
129
+ schemaSqlExpression(): string;
130
+ schemaFilterExpression(): CfExpr;
131
+ tableSource(tableName: string, alias?: string): PostgresTableSource;
132
+ }
133
+ /**
134
+ * Narrow an arbitrary namespace (or `undefined`) to `PostgresSchema`
135
+ * so callers can dispatch to the polymorphic emission methods without
136
+ * branching at the call site. Uses the structural `kind` discriminator
137
+ * (`'schema'`) rather than `instanceof` so the check survives realm /
138
+ * bundle / hot-reload boundaries — matching the rest of the IR's
139
+ * narrowing convention. `PostgresUnboundSchema` passes through because
140
+ * it inherits the same `kind: 'schema'` from `PostgresSchema`.
141
+ */
142
+ declare function isPostgresSchema(ns: unknown): ns is PostgresSchema;
143
+ /**
144
+ * Target-supplied `Namespace` factory the Postgres target plumbs
145
+ * through `defineContract({ createNamespace })` and the SQL PSL
146
+ * interpreter. Returns the unbound singleton for the framework
147
+ * sentinel and a fresh `PostgresSchema` for any other coordinate.
148
+ *
149
+ * The factory has no per-call state — every named id deterministically
150
+ * maps to a distinct schema instance — so callers can pass it through
151
+ * by reference and trust the resulting `SqlStorage.namespaces` map to
152
+ * be value-stable for a given input set.
153
+ */
154
+ declare function postgresCreateNamespace(input: SqlNamespaceInput): PostgresSchema;
155
+ //#endregion
156
+ export { postgresCreateNamespace as i, PostgresUnboundSchema as n, isPostgresSchema as r, PostgresSchema as t };
157
+ //# sourceMappingURL=postgres-schema-Bn4tsMuo.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-schema-Bn4tsMuo.d.mts","names":[],"sources":["../src/core/postgres-schema.ts"],"mappings":";;;;;;;KAwBY,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;EAtBkB;AAAA;AAGtD;;;;;EAHsD,OA8B7C,OAAA,EAAS,qBAAA;EAA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