@prisma-next/target-postgres 0.15.0 → 0.16.0-dev.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (188) hide show
  1. package/dist/{authoring-BtsOWgI3.mjs → authoring-34L18kA1.mjs} +18 -8
  2. package/dist/authoring-34L18kA1.mjs.map +1 -0
  3. package/dist/canonicalize-D1F4vUnP.d.mts.map +1 -1
  4. package/dist/{codec-ids-CI144z7g.d.mts → codec-ids-BswpvvND.d.mts} +3 -3
  5. package/dist/codec-ids-BswpvvND.d.mts.map +1 -0
  6. package/dist/{codec-ids-B10ZZHzw.mjs → codec-ids-D3G8K0YM.mjs} +3 -2
  7. package/dist/codec-ids-D3G8K0YM.mjs.map +1 -0
  8. package/dist/codec-ids.d.mts +2 -2
  9. package/dist/codec-ids.mjs +2 -2
  10. package/dist/{codec-types-CTfT4U4O.d.mts → codec-types-CQ07nOz-.d.mts} +4 -5
  11. package/dist/codec-types-CQ07nOz-.d.mts.map +1 -0
  12. package/dist/codec-types.d.mts +1 -1
  13. package/dist/{codecs-D7W9O0Xx.d.mts → codecs-G4DTY0F_.d.mts} +35 -7
  14. package/dist/codecs-G4DTY0F_.d.mts.map +1 -0
  15. package/dist/{codecs-DRbb26Or.mjs → codecs-TCsGgW-Y.mjs} +77 -5
  16. package/dist/codecs-TCsGgW-Y.mjs.map +1 -0
  17. package/dist/codecs.d.mts +2 -3
  18. package/dist/codecs.d.mts.map +1 -1
  19. package/dist/codecs.mjs +2 -2
  20. package/dist/contract-free.d.mts +2 -3
  21. package/dist/contract-free.d.mts.map +1 -1
  22. package/dist/contract-free.mjs +3 -3
  23. package/dist/{control-policy-DtbkLLGv.mjs → control-policy-CZKdMztu.mjs} +44 -75
  24. package/dist/control-policy-CZKdMztu.mjs.map +1 -0
  25. package/dist/control.d.mts +0 -1
  26. package/dist/control.d.mts.map +1 -1
  27. package/dist/control.mjs +75 -25
  28. package/dist/control.mjs.map +1 -1
  29. package/dist/data-transform-BOWpliq8.mjs.map +1 -1
  30. package/dist/{data-transform-DPzwBMhW.d.mts → data-transform-CGvE8yGx.d.mts} +1 -2
  31. package/dist/data-transform-CGvE8yGx.d.mts.map +1 -0
  32. package/dist/data-transform.d.mts +1 -1
  33. package/dist/{ddl-GTTOvjx_.mjs → ddl-DHXKzQ99.mjs} +3 -3
  34. package/dist/{ddl-GTTOvjx_.mjs.map → ddl-DHXKzQ99.mjs.map} +1 -1
  35. package/dist/ddl.d.mts +1 -1
  36. package/dist/default-normalizer-B9ZUiyUE.mjs +264 -0
  37. package/dist/default-normalizer-B9ZUiyUE.mjs.map +1 -0
  38. package/dist/default-normalizer.d.mts +14 -2
  39. package/dist/default-normalizer.d.mts.map +1 -1
  40. package/dist/default-normalizer.mjs +2 -248
  41. package/dist/{descriptor-meta-CFQKLXl_.mjs → descriptor-meta-qubYaxQA.mjs} +9 -4
  42. package/dist/descriptor-meta-qubYaxQA.mjs.map +1 -0
  43. package/dist/{diff-database-schema-GncqMuSI.mjs → diff-database-schema-C-hnJ5mr.mjs} +92 -26
  44. package/dist/diff-database-schema-C-hnJ5mr.mjs.map +1 -0
  45. package/dist/diff-database-schema.d.mts +4 -13
  46. package/dist/diff-database-schema.d.mts.map +1 -1
  47. package/dist/diff-database-schema.mjs +1 -1
  48. package/dist/{errors-DO-w0EUS.mjs → errors-ByDS0xJL.mjs} +6 -6
  49. package/dist/errors-ByDS0xJL.mjs.map +1 -0
  50. package/dist/errors.d.mts +4 -4
  51. package/dist/errors.d.mts.map +1 -1
  52. package/dist/errors.mjs +1 -1
  53. package/dist/issue-planner.d.mts +1 -2
  54. package/dist/issue-planner.d.mts.map +1 -1
  55. package/dist/issue-planner.mjs +1 -1
  56. package/dist/migration.d.mts +3 -4
  57. package/dist/migration.d.mts.map +1 -1
  58. package/dist/migration.mjs +2 -2
  59. package/dist/native-type-normalizer.d.mts.map +1 -1
  60. package/dist/{nodes-Dv5eCSq9.d.mts → nodes-CQzM2hR0.d.mts} +1 -2
  61. package/dist/nodes-CQzM2hR0.d.mts.map +1 -0
  62. package/dist/{op-factory-call-Bn9zDx4_.d.mts → op-factory-call-DT7kdjVP.d.mts} +10 -7
  63. package/dist/op-factory-call-DT7kdjVP.d.mts.map +1 -0
  64. package/dist/{op-factory-call-C38NzvQD.mjs → op-factory-call-DuRj7WXX.mjs} +37 -16
  65. package/dist/{op-factory-call-C38NzvQD.mjs.map → op-factory-call-DuRj7WXX.mjs.map} +1 -1
  66. package/dist/op-factory-call.d.mts +2 -2
  67. package/dist/op-factory-call.mjs +2 -2
  68. package/dist/pack.d.mts +122 -6
  69. package/dist/pack.d.mts.map +1 -1
  70. package/dist/pack.mjs +1 -1
  71. package/dist/{planner-kql24i_F.mjs → planner-DPGxFcXo.mjs} +13 -13
  72. package/dist/planner-DPGxFcXo.mjs.map +1 -0
  73. package/dist/planner-ddl-builders.d.mts +1 -2
  74. package/dist/planner-ddl-builders.d.mts.map +1 -1
  75. package/dist/planner-identity-values.d.mts +0 -1
  76. package/dist/planner-identity-values.d.mts.map +1 -1
  77. package/dist/{planner-produced-postgres-migration-BEY1T0Xm.d.mts → planner-produced-postgres-migration-C-dwGdb2.d.mts} +2 -3
  78. package/dist/planner-produced-postgres-migration-C-dwGdb2.d.mts.map +1 -0
  79. package/dist/{planner-produced-postgres-migration-D7y-PEHK.mjs → planner-produced-postgres-migration-CFDpqWWE.mjs} +2 -2
  80. package/dist/planner-produced-postgres-migration-CFDpqWWE.mjs.map +1 -0
  81. package/dist/planner-produced-postgres-migration.d.mts +1 -1
  82. package/dist/planner-produced-postgres-migration.mjs +1 -1
  83. package/dist/planner-schema-lookup.d.mts +0 -1
  84. package/dist/planner-schema-lookup.d.mts.map +1 -1
  85. package/dist/{planner-sql-checks-zqNfs2XZ.mjs → planner-sql-checks-BuB877wH.mjs} +2 -2
  86. package/dist/{planner-sql-checks-zqNfs2XZ.mjs.map → planner-sql-checks-BuB877wH.mjs.map} +1 -1
  87. package/dist/planner-sql-checks.d.mts +0 -1
  88. package/dist/planner-sql-checks.d.mts.map +1 -1
  89. package/dist/planner-sql-checks.mjs +1 -1
  90. package/dist/planner-target-details-HkP4RrRO.d.mts.map +1 -1
  91. package/dist/planner.d.mts +3 -4
  92. package/dist/planner.d.mts.map +1 -1
  93. package/dist/planner.mjs +2 -2
  94. package/dist/{postgres-contract-view-C9j5cqP0.d.mts → postgres-contract-view-CeU7FJjW.d.mts} +4 -3
  95. package/dist/postgres-contract-view-CeU7FJjW.d.mts.map +1 -0
  96. package/dist/{postgres-contract-view-DM8sN1Ot.mjs → postgres-contract-view-DebHMqGR.mjs} +4 -4
  97. package/dist/{postgres-contract-view-DM8sN1Ot.mjs.map → postgres-contract-view-DebHMqGR.mjs.map} +1 -1
  98. package/dist/{postgres-database-schema-node-CJv5bfbs.d.mts → postgres-database-schema-node-DMXsIwAb.d.mts} +12 -4
  99. package/dist/postgres-database-schema-node-DMXsIwAb.d.mts.map +1 -0
  100. package/dist/{postgres-migration-arMSWU9b.mjs → postgres-migration-C_OPFhIF.mjs} +22 -6
  101. package/dist/postgres-migration-C_OPFhIF.mjs.map +1 -0
  102. package/dist/{postgres-migration-DbckK1su.d.mts → postgres-migration-DLIvzHjX.d.mts} +31 -7
  103. package/dist/postgres-migration-DLIvzHjX.d.mts.map +1 -0
  104. package/dist/{postgres-rls-policy--CSddvMR.d.mts → postgres-rls-policy-CYXdqG9B.d.mts} +1 -2
  105. package/dist/postgres-rls-policy-CYXdqG9B.d.mts.map +1 -0
  106. package/dist/{postgres-role-schema-node-Cm-j0ZGM.mjs → postgres-role-schema-node-bg32e7I-.mjs} +3 -2
  107. package/dist/postgres-role-schema-node-bg32e7I-.mjs.map +1 -0
  108. package/dist/{postgres-schema-Cm4DtiGA.mjs → postgres-schema-CewLYHB7.mjs} +2 -2
  109. package/dist/{postgres-schema-Cm4DtiGA.mjs.map → postgres-schema-CewLYHB7.mjs.map} +1 -1
  110. package/dist/{postgres-schema-DKq6s1P3.d.mts → postgres-schema-FdKRwe7X.d.mts} +3 -4
  111. package/dist/postgres-schema-FdKRwe7X.d.mts.map +1 -0
  112. package/dist/render-ops.d.mts +0 -1
  113. package/dist/render-ops.d.mts.map +1 -1
  114. package/dist/render-typescript.d.mts +0 -1
  115. package/dist/render-typescript.d.mts.map +1 -1
  116. package/dist/{resolve-ddl-schema-XyBaaenM.mjs → resolve-ddl-schema-D0wi_P9Q.mjs} +2 -2
  117. package/dist/{resolve-ddl-schema-XyBaaenM.mjs.map → resolve-ddl-schema-D0wi_P9Q.mjs.map} +1 -1
  118. package/dist/rls-canonicalize.d.mts +0 -1
  119. package/dist/rls-canonicalize.d.mts.map +1 -1
  120. package/dist/runtime.d.mts +1 -2
  121. package/dist/runtime.d.mts.map +1 -1
  122. package/dist/runtime.mjs +1 -1
  123. package/dist/schema-ir-annotations.d.mts +0 -1
  124. package/dist/schema-ir-annotations.d.mts.map +1 -1
  125. package/dist/schema-ir-annotations.mjs +1 -1
  126. package/dist/schema-node-kinds-DxvWh2Ic.d.mts +29 -0
  127. package/dist/schema-node-kinds-DxvWh2Ic.d.mts.map +1 -0
  128. package/dist/sql-utils.d.mts.map +1 -1
  129. package/dist/{table-source-BvFo7gVs.d.mts → table-source-D5c2fxAQ.d.mts} +1 -2
  130. package/dist/table-source-D5c2fxAQ.d.mts.map +1 -0
  131. package/dist/{types-BDKkx8MA.d.mts → types-D2MLzLBD.d.mts} +1 -2
  132. package/dist/types-D2MLzLBD.d.mts.map +1 -0
  133. package/dist/types.d.mts +6 -5
  134. package/dist/types.mjs +4 -4
  135. package/package.json +21 -21
  136. package/src/core/authoring.ts +18 -5
  137. package/src/core/codec-helpers.ts +53 -1
  138. package/src/core/codec-ids.ts +1 -0
  139. package/src/core/codecs.ts +56 -3
  140. package/src/core/default-normalizer.ts +22 -0
  141. package/src/core/descriptor-meta.ts +2 -0
  142. package/src/core/errors.ts +5 -5
  143. package/src/core/index-types.ts +15 -0
  144. package/src/core/migrations/contract-to-postgres-database-schema-node.ts +99 -19
  145. package/src/core/migrations/control-policy.ts +4 -3
  146. package/src/core/migrations/diff-database-schema.ts +6 -3
  147. package/src/core/migrations/issue-planner.ts +41 -80
  148. package/src/core/migrations/op-factory-call.ts +40 -16
  149. package/src/core/migrations/operations/data-transform.ts +1 -1
  150. package/src/core/migrations/planner-produced-postgres-migration.ts +1 -1
  151. package/src/core/migrations/planner-strategies.ts +6 -6
  152. package/src/core/migrations/planner.ts +5 -4
  153. package/src/core/migrations/postgres-migration.ts +62 -2
  154. package/src/core/migrations/runner.ts +12 -11
  155. package/src/core/migrations/verify-postgres-namespaces.ts +0 -1
  156. package/src/core/psl-infer/infer-psl-contract.ts +130 -12
  157. package/src/core/schema-ir/postgres-policy-schema-node.ts +12 -2
  158. package/src/exports/codecs.ts +2 -0
  159. package/src/exports/control.ts +2 -0
  160. package/src/exports/default-normalizer.ts +1 -1
  161. package/src/exports/op-factory-call.ts +5 -0
  162. package/src/exports/types.ts +1 -0
  163. package/dist/authoring-BtsOWgI3.mjs.map +0 -1
  164. package/dist/codec-ids-B10ZZHzw.mjs.map +0 -1
  165. package/dist/codec-ids-CI144z7g.d.mts.map +0 -1
  166. package/dist/codec-types-CTfT4U4O.d.mts.map +0 -1
  167. package/dist/codecs-D7W9O0Xx.d.mts.map +0 -1
  168. package/dist/codecs-DRbb26Or.mjs.map +0 -1
  169. package/dist/control-policy-DtbkLLGv.mjs.map +0 -1
  170. package/dist/data-transform-DPzwBMhW.d.mts.map +0 -1
  171. package/dist/default-normalizer.mjs.map +0 -1
  172. package/dist/descriptor-meta-CFQKLXl_.mjs.map +0 -1
  173. package/dist/diff-database-schema-GncqMuSI.mjs.map +0 -1
  174. package/dist/errors-DO-w0EUS.mjs.map +0 -1
  175. package/dist/nodes-Dv5eCSq9.d.mts.map +0 -1
  176. package/dist/op-factory-call-Bn9zDx4_.d.mts.map +0 -1
  177. package/dist/planner-kql24i_F.mjs.map +0 -1
  178. package/dist/planner-produced-postgres-migration-BEY1T0Xm.d.mts.map +0 -1
  179. package/dist/planner-produced-postgres-migration-D7y-PEHK.mjs.map +0 -1
  180. package/dist/postgres-contract-view-C9j5cqP0.d.mts.map +0 -1
  181. package/dist/postgres-database-schema-node-CJv5bfbs.d.mts.map +0 -1
  182. package/dist/postgres-migration-DbckK1su.d.mts.map +0 -1
  183. package/dist/postgres-migration-arMSWU9b.mjs.map +0 -1
  184. package/dist/postgres-rls-policy--CSddvMR.d.mts.map +0 -1
  185. package/dist/postgres-role-schema-node-Cm-j0ZGM.mjs.map +0 -1
  186. package/dist/postgres-schema-DKq6s1P3.d.mts.map +0 -1
  187. package/dist/table-source-BvFo7gVs.d.mts.map +0 -1
  188. package/dist/types-BDKkx8MA.d.mts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"resolve-ddl-schema-XyBaaenM.mjs","names":[],"sources":["../src/core/migrations/resolve-ddl-schema.ts"],"sourcesContent":["import { UNBOUND_NAMESPACE_ID } from '@prisma-next/framework-components/ir';\nimport type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport { DEFAULT_NAMESPACE_ID } from '../namespace-ids';\nimport { isPostgresSchema } from '../postgres-schema';\n\n/**\n * Given the contract's storage and a namespace id, returns the live Postgres\n * DDL schema name that namespace maps to. A named Postgres namespace dispatches\n * to its `ddlSchemaName(storage)`; the unbound sentinel resolves to\n * `DEFAULT_NAMESPACE_ID` (the search-path default for offline planning); a\n * bare object payload (used by some tests) falls back to the namespace id\n * itself.\n */\nexport function resolveDdlSchemaForNamespaceStorage(\n storage: SqlStorage,\n namespaceId: string,\n): string {\n if (namespaceId === UNBOUND_NAMESPACE_ID) {\n return DEFAULT_NAMESPACE_ID;\n }\n const namespace = storage.namespaces[namespaceId];\n if (namespace && isPostgresSchema(namespace)) {\n return namespace.ddlSchemaName(storage);\n }\n return namespaceId;\n}\n"],"mappings":";;;;;;;;;;;;AAaA,SAAgB,oCACd,SACA,aACQ;CACR,IAAI,gBAAgB,sBAClB,OAAO;CAET,MAAM,YAAY,QAAQ,WAAW;CACrC,IAAI,aAAa,iBAAiB,SAAS,GACzC,OAAO,UAAU,cAAc,OAAO;CAExC,OAAO;AACT"}
1
+ {"version":3,"file":"resolve-ddl-schema-D0wi_P9Q.mjs","names":[],"sources":["../src/core/migrations/resolve-ddl-schema.ts"],"sourcesContent":["import { UNBOUND_NAMESPACE_ID } from '@prisma-next/framework-components/ir';\nimport type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport { DEFAULT_NAMESPACE_ID } from '../namespace-ids';\nimport { isPostgresSchema } from '../postgres-schema';\n\n/**\n * Given the contract's storage and a namespace id, returns the live Postgres\n * DDL schema name that namespace maps to. A named Postgres namespace dispatches\n * to its `ddlSchemaName(storage)`; the unbound sentinel resolves to\n * `DEFAULT_NAMESPACE_ID` (the search-path default for offline planning); a\n * bare object payload (used by some tests) falls back to the namespace id\n * itself.\n */\nexport function resolveDdlSchemaForNamespaceStorage(\n storage: SqlStorage,\n namespaceId: string,\n): string {\n if (namespaceId === UNBOUND_NAMESPACE_ID) {\n return DEFAULT_NAMESPACE_ID;\n }\n const namespace = storage.namespaces[namespaceId];\n if (namespace && isPostgresSchema(namespace)) {\n return namespace.ddlSchemaName(storage);\n }\n return namespaceId;\n}\n"],"mappings":";;;;;;;;;;;;AAaA,SAAgB,oCACd,SACA,aACQ;CACR,IAAI,gBAAgB,sBAClB,OAAO;CAET,MAAM,YAAY,QAAQ,WAAW;CACrC,IAAI,aAAa,iBAAiB,SAAS,GACzC,OAAO,UAAU,cAAc,OAAO;CAExC,OAAO;AACT"}
@@ -1,5 +1,4 @@
1
1
  import { a as normalizePredicate, i as computeContentHash, n as POLICY_OPERATION_PREDICATES, r as RlsPolicyOperation, t as ContentHashParts } from "./canonicalize-D1F4vUnP.mjs";
2
-
3
2
  //#region src/core/rls/wire-name.d.ts
4
3
  interface RlsPolicyWireName {
5
4
  /** The user-supplied part before the `_<8hex>` suffix. */
@@ -1 +1 @@
1
- {"version":3,"file":"rls-canonicalize.d.mts","names":[],"sources":["../src/core/rls/wire-name.ts"],"mappings":";;;UAAiB,iBAAA;;WAEN,MAAA;EAFM;EAAA,SAIN,IAAI;AAAA;;AAAA;AAWf;;;;iBAAgB,uBAAA,CAAwB,MAAA,UAAgB,IAAY;AAWpE;;;;AAAuE;;;AAAvE,iBAAgB,sBAAA,CAAuB,IAAA,WAAe,iBAAiB"}
1
+ {"version":3,"file":"rls-canonicalize.d.mts","names":[],"sources":["../src/core/rls/wire-name.ts"],"mappings":";;UAAiB;;WAEN;;WAEA;;;;;;;;iBAWK,wBAAwB,gBAAgB;;;;;;;;iBAWxC,uBAAuB,eAAe"}
@@ -1,4 +1,4 @@
1
- import { t as PostgresContractView } from "./postgres-contract-view-C9j5cqP0.mjs";
1
+ import { t as PostgresContractView } from "./postgres-contract-view-CeU7FJjW.mjs";
2
2
  import { AnyCodecDescriptor } from "@prisma-next/framework-components/codec";
3
3
  import { AnyEntityKindDescriptor, Namespace } from "@prisma-next/framework-components/ir";
4
4
  import { SqlNamespaceInput, SqlStorage } from "@prisma-next/sql-contract/types";
@@ -6,7 +6,6 @@ import { SqlContractSerializerBase } from "@prisma-next/family-sql/ir";
6
6
  import { Contract } from "@prisma-next/contract/types";
7
7
  import { RuntimeTargetDescriptor, RuntimeTargetInstance } from "@prisma-next/framework-components/execution";
8
8
  import { JsonObject } from "@prisma-next/utils/json";
9
-
10
9
  //#region src/core/postgres-contract-serializer.d.ts
11
10
  declare class PostgresContractSerializer extends SqlContractSerializerBase<Contract<SqlStorage>> {
12
11
  constructor(extraPackEntityKinds?: readonly AnyEntityKindDescriptor[]);
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.mts","names":[],"sources":["../src/core/postgres-contract-serializer.ts","../src/exports/runtime.ts"],"mappings":";;;;;;;;;;cA0Ea,0BAAA,SAAmC,yBAAA,CAA0B,QAAA,CAAS,UAAA;cACrE,oBAAA,YAA+B,uBAAA;EAAA,UAWxB,wBAAA,CACjB,IAAA,UACA,GAAA,EAAK,MAAA,oBACJ,SAAA,GAAY,iBAAA;EAyBN,iBAAA,CAAkB,QAAA,EAAU,QAAA,CAAS,UAAA,IAAc,UAAA;AAAA;;;UCxG7C,6BAAA,SAAsC,qBAAqB;;;;;ADgE5E;;cCxDM,+BAAA,EAAiC,uBAAA,oBAGrC,6BAAA;EAAA,SAES,MAAA,iBAAuB,kBAAA;AAAA"}
1
+ {"version":3,"file":"runtime.d.mts","names":[],"sources":["../src/core/postgres-contract-serializer.ts","../src/exports/runtime.ts"],"mappings":";;;;;;;;;cA0Ea,mCAAmC,0BAA0B,SAAS;cACrE,gCAA+B;YAWxB,yBACjB,cACA,KAAK,0BACJ,YAAY;EAyBN,kBAAkB,UAAU,SAAS,cAAc;;;;UCxG7C,sCAAsC;;;;;;;cAQjD,iCAAiC,2CAGrC;WAES,uBAAuB"}
package/dist/runtime.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { t as postgresTargetDescriptorMetaRuntime } from "./descriptor-meta-runtime-UwYdV8fD.mjs";
2
- import { n as PostgresContractSerializer, t as PostgresContractView } from "./postgres-contract-view-DM8sN1Ot.mjs";
2
+ import { n as PostgresContractSerializer, t as PostgresContractView } from "./postgres-contract-view-DebHMqGR.mjs";
3
3
  //#region src/exports/runtime.ts
4
4
  /**
5
5
  * Target-postgres deliberately does NOT import `SqlRuntimeTargetDescriptor` from `@prisma-next/sql-runtime`. The target package is a control-plane residence and must not pull the SQL execution-plane package into its dependency closure. The runtime descriptor here is shaped to satisfy the framework's `RuntimeTargetDescriptor` plus the structural `SqlStaticContributions` (`codecs:` returning a descriptor list) that
@@ -1,5 +1,4 @@
1
1
  import { SqlStorage } from "@prisma-next/sql-contract/types";
2
-
3
2
  //#region src/core/migrations/resolve-ddl-schema.d.ts
4
3
  /**
5
4
  * Given the contract's storage and a namespace id, returns the live Postgres
@@ -1 +1 @@
1
- {"version":3,"file":"schema-ir-annotations.d.mts","names":[],"sources":["../src/core/migrations/resolve-ddl-schema.ts"],"mappings":";;;;;AAaA;;;;;;iBAAgB,mCAAA,CACd,OAAA,EAAS,UAAU,EACnB,WAAA"}
1
+ {"version":3,"file":"schema-ir-annotations.d.mts","names":[],"sources":["../src/core/migrations/resolve-ddl-schema.ts"],"mappings":";;;;;;;;;;iBAagB,oCACd,SAAS,YACT"}
@@ -1,2 +1,2 @@
1
- import { t as resolveDdlSchemaForNamespaceStorage } from "./resolve-ddl-schema-XyBaaenM.mjs";
1
+ import { t as resolveDdlSchemaForNamespaceStorage } from "./resolve-ddl-schema-D0wi_P9Q.mjs";
2
2
  export { resolveDdlSchemaForNamespaceStorage };
@@ -0,0 +1,29 @@
1
+ import { SqlSchemaIRNode } from "@prisma-next/sql-schema-ir/types";
2
+ import { DiffableNode } from "@prisma-next/framework-components/control";
3
+ //#region src/core/schema-ir/schema-node-kinds.d.ts
4
+ /**
5
+ * A Postgres schema-diff-tree node: a `SqlSchemaIRNode` that also implements
6
+ * `DiffableNode` (the five `Postgres*SchemaNode` classes). `SqlSchemaIRNode`
7
+ * alone is not a `DiffableNode` — its relational subclasses (`SqlColumnIR`, …)
8
+ * carry no `id`/`isEqualTo`/`children` — so this intersection is the honest node
9
+ * type the differ produces and the planner consumes (`SchemaDiff<SqlSchemaDiffNode>`).
10
+ */
11
+ type SqlSchemaDiffNode = SqlSchemaIRNode & DiffableNode;
12
+ /**
13
+ * The `nodeKind` discriminant for each Postgres schema-diff node. Each node
14
+ * carries a unique value; the static `is`/`assert` guards compare against these
15
+ * identifiers rather than spelling the string inline or using `instanceof`. The
16
+ * field is an enumerable own property carried on every node instance.
17
+ */
18
+ declare const PostgresSchemaNodeKind: {
19
+ readonly database: "postgres-database";
20
+ readonly namespace: "postgres-namespace";
21
+ readonly table: "postgres-table";
22
+ readonly policy: "postgres-policy";
23
+ readonly role: "postgres-role";
24
+ readonly nativeEnum: "postgres-native-enum";
25
+ };
26
+ type PostgresSchemaNodeKind = (typeof PostgresSchemaNodeKind)[keyof typeof PostgresSchemaNodeKind];
27
+ //#endregion
28
+ export { SqlSchemaDiffNode as n, PostgresSchemaNodeKind as t };
29
+ //# sourceMappingURL=schema-node-kinds-DxvWh2Ic.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-node-kinds-DxvWh2Ic.d.mts","names":[],"sources":["../src/core/schema-ir/schema-node-kinds.ts"],"mappings":";;;;;;;;;;KAiBY,oBAAoB,kBAAkB;;;;;;;cAQrC;;;;;;;;KASD,iCACF,qCAAqC"}
@@ -1 +1 @@
1
- {"version":3,"file":"sql-utils.d.mts","names":[],"sources":["../src/core/sql-utils.ts"],"mappings":";;AAYA;;;;;;;;;;cAAa,cAAA,SAAuB,KAAK;EAAA,SAGrB,KAAA;EAAA,SACA,IAAA;cAFhB,OAAA,UACgB,KAAA,UACA,IAAA;AAAA;;;AAmB8B;AA8BlD;;;;AAA2C;AAc3C;;iBA5CgB,eAAA,CAAgB,UAAkB;;AA4CgB;AAUlE;;;;AAA+C;AAkB/C;;;;iBA1CgB,aAAA,CAAc,KAAa;;;;iBAc3B,WAAA,CAAY,UAAA,UAAoB,UAAkB;;;;;;;iBAUlD,kBAAA,CAAmB,IAAY;;;;;;;;;;;;iBAkB/B,uBAAA,CAAwB,KAAA,UAAe,YAAoB"}
1
+ {"version":3,"file":"sql-utils.d.mts","names":[],"sources":["../src/core/sql-utils.ts"],"mappings":";;;;;;;;;;;;cAYa,uBAAuB;WAGhB;WACA;cAFhB,iBACgB,eACA;;;;;;;;;;;;iBAmBJ,gBAAgB;;;;;;;;;;;;iBA8BhB,cAAc;;;;iBAcd,YAAY,oBAAoB;;;;;;;iBAUhC,mBAAmB;;;;;;;;;;;;iBAkBnB,wBAAwB,eAAe"}
@@ -1,5 +1,4 @@
1
1
  import { AnyFromSource, AstRewriter, TableSource } from "@prisma-next/sql-relational-core/ast";
2
-
3
2
  //#region src/core/ast/table-source.d.ts
4
3
  declare class PostgresTableSource extends TableSource {
5
4
  readonly schema: string | undefined;
@@ -12,4 +11,4 @@ declare class PostgresTableSource extends TableSource {
12
11
  }
13
12
  //#endregion
14
13
  export { PostgresTableSource as t };
15
- //# sourceMappingURL=table-source-BvFo7gVs.d.mts.map
14
+ //# sourceMappingURL=table-source-D5c2fxAQ.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table-source-D5c2fxAQ.d.mts","names":[],"sources":["../src/core/ast/table-source.ts"],"mappings":";;cAMa,4BAA4B;WAC9B;cAEG;aACD;aACA;aACA;;EAOF,QAAQ,UAAU,cAAc"}
@@ -1,5 +1,4 @@
1
1
  import { ColumnDefault } from "@prisma-next/contract/types";
2
-
3
2
  //#region src/core/types.d.ts
4
3
  type PostgresColumnDefault = ColumnDefault | {
5
4
  readonly kind: 'sequence';
@@ -7,4 +6,4 @@ type PostgresColumnDefault = ColumnDefault | {
7
6
  };
8
7
  //#endregion
9
8
  export { PostgresColumnDefault as t };
10
- //# sourceMappingURL=types-BDKkx8MA.d.mts.map
9
+ //# sourceMappingURL=types-D2MLzLBD.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-D2MLzLBD.d.mts","names":[],"sources":["../src/core/types.ts"],"mappings":";;KAEY,wBACR;WACW;WAA2B"}
package/dist/types.d.mts CHANGED
@@ -1,5 +1,6 @@
1
- import { a as PostgresNamespaceSchemaNode, c as PostgresTableSchemaNodeInput, d as PostgresNativeEnumSchemaNode, f as PostgresNativeEnumSchemaNodeInput, i as PostgresRoleSchemaNodeInput, l as PostgresPolicySchemaNode, n as PostgresDatabaseSchemaNodeInput, o as PostgresNamespaceSchemaNodeInput, r as PostgresRoleSchemaNode, s as PostgresTableSchemaNode, t as PostgresDatabaseSchemaNode, u as PostgresPolicySchemaNodeInput } from "./postgres-database-schema-node-CJv5bfbs.mjs";
2
- import { n as PostgresRlsPolicyInput, r as RlsPolicyOperation, t as PostgresRlsPolicy } from "./postgres-rls-policy--CSddvMR.mjs";
3
- import { t as PostgresColumnDefault } from "./types-BDKkx8MA.mjs";
4
- import { a as postgresCreateNamespace, c as PostgresRlsEnablement, d as PostgresNativeEnumInput, i as isPostgresSchema, l as PostgresRlsEnablementInput, n as PostgresSchema, o as PostgresRole, r as PostgresUnboundSchema, s as PostgresRoleInput, t as PostgresContract, u as PostgresNativeEnum } from "./postgres-schema-DKq6s1P3.mjs";
5
- export { type PostgresColumnDefault, type PostgresContract, PostgresDatabaseSchemaNode, type PostgresDatabaseSchemaNodeInput, PostgresNamespaceSchemaNode, type PostgresNamespaceSchemaNodeInput, PostgresNativeEnum, type PostgresNativeEnumInput, PostgresNativeEnumSchemaNode, type PostgresNativeEnumSchemaNodeInput, PostgresPolicySchemaNode, type PostgresPolicySchemaNodeInput, PostgresRlsEnablement, type PostgresRlsEnablementInput, PostgresRlsPolicy, type PostgresRlsPolicyInput, PostgresRole, type PostgresRoleInput, PostgresRoleSchemaNode, type PostgresRoleSchemaNodeInput, PostgresSchema, PostgresTableSchemaNode, type PostgresTableSchemaNodeInput, PostgresUnboundSchema, type RlsPolicyOperation, isPostgresSchema, postgresCreateNamespace };
1
+ import { a as PostgresNamespaceSchemaNode, c as PostgresTableSchemaNodeInput, d as PostgresNativeEnumSchemaNode, f as PostgresNativeEnumSchemaNodeInput, i as PostgresRoleSchemaNodeInput, l as PostgresPolicySchemaNode, n as PostgresDatabaseSchemaNodeInput, o as PostgresNamespaceSchemaNodeInput, r as PostgresRoleSchemaNode, s as PostgresTableSchemaNode, t as PostgresDatabaseSchemaNode, u as PostgresPolicySchemaNodeInput } from "./postgres-database-schema-node-DMXsIwAb.mjs";
2
+ import { n as PostgresRlsPolicyInput, r as RlsPolicyOperation, t as PostgresRlsPolicy } from "./postgres-rls-policy-CYXdqG9B.mjs";
3
+ import { t as PostgresSchemaNodeKind } from "./schema-node-kinds-DxvWh2Ic.mjs";
4
+ import { t as PostgresColumnDefault } from "./types-D2MLzLBD.mjs";
5
+ import { a as postgresCreateNamespace, c as PostgresRlsEnablement, d as PostgresNativeEnumInput, i as isPostgresSchema, l as PostgresRlsEnablementInput, n as PostgresSchema, o as PostgresRole, r as PostgresUnboundSchema, s as PostgresRoleInput, t as PostgresContract, u as PostgresNativeEnum } from "./postgres-schema-FdKRwe7X.mjs";
6
+ export { type PostgresColumnDefault, type PostgresContract, PostgresDatabaseSchemaNode, type PostgresDatabaseSchemaNodeInput, PostgresNamespaceSchemaNode, type PostgresNamespaceSchemaNodeInput, PostgresNativeEnum, type PostgresNativeEnumInput, PostgresNativeEnumSchemaNode, type PostgresNativeEnumSchemaNodeInput, PostgresPolicySchemaNode, type PostgresPolicySchemaNodeInput, PostgresRlsEnablement, type PostgresRlsEnablementInput, PostgresRlsPolicy, type PostgresRlsPolicyInput, PostgresRole, type PostgresRoleInput, PostgresRoleSchemaNode, type PostgresRoleSchemaNodeInput, PostgresSchema, PostgresSchemaNodeKind, PostgresTableSchemaNode, type PostgresTableSchemaNodeInput, PostgresUnboundSchema, type RlsPolicyOperation, isPostgresSchema, postgresCreateNamespace };
package/dist/types.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { t as PostgresNativeEnum } from "./postgres-native-enum-BwVNf0Ku.mjs";
2
- import { _ as PostgresRlsEnablement, g as PostgresRlsPolicy, i as postgresCreateNamespace, m as PostgresRole, n as PostgresUnboundSchema, r as isPostgresSchema, t as PostgresSchema } from "./postgres-schema-Cm4DtiGA.mjs";
3
- import { n as PostgresNativeEnumSchemaNode, t as PostgresTableSchemaNode } from "./postgres-table-schema-node-D6LvInCe.mjs";
4
- import { i as PostgresDatabaseSchemaNode, n as PostgresPolicySchemaNode, r as PostgresNamespaceSchemaNode, t as PostgresRoleSchemaNode } from "./postgres-role-schema-node-Cm-j0ZGM.mjs";
5
- export { PostgresDatabaseSchemaNode, PostgresNamespaceSchemaNode, PostgresNativeEnum, PostgresNativeEnumSchemaNode, PostgresPolicySchemaNode, PostgresRlsEnablement, PostgresRlsPolicy, PostgresRole, PostgresRoleSchemaNode, PostgresSchema, PostgresTableSchemaNode, PostgresUnboundSchema, isPostgresSchema, postgresCreateNamespace };
2
+ import { _ as PostgresRlsEnablement, g as PostgresRlsPolicy, i as postgresCreateNamespace, m as PostgresRole, n as PostgresUnboundSchema, r as isPostgresSchema, t as PostgresSchema } from "./postgres-schema-CewLYHB7.mjs";
3
+ import { n as PostgresNativeEnumSchemaNode, r as PostgresSchemaNodeKind, t as PostgresTableSchemaNode } from "./postgres-table-schema-node-D6LvInCe.mjs";
4
+ import { i as PostgresDatabaseSchemaNode, n as PostgresPolicySchemaNode, r as PostgresNamespaceSchemaNode, t as PostgresRoleSchemaNode } from "./postgres-role-schema-node-bg32e7I-.mjs";
5
+ export { PostgresDatabaseSchemaNode, PostgresNamespaceSchemaNode, PostgresNativeEnum, PostgresNativeEnumSchemaNode, PostgresPolicySchemaNode, PostgresRlsEnablement, PostgresRlsPolicy, PostgresRole, PostgresRoleSchemaNode, PostgresSchema, PostgresSchemaNodeKind, PostgresTableSchemaNode, PostgresUnboundSchema, isPostgresSchema, postgresCreateNamespace };
package/package.json CHANGED
@@ -1,36 +1,36 @@
1
1
  {
2
2
  "name": "@prisma-next/target-postgres",
3
- "version": "0.15.0",
3
+ "version": "0.16.0-dev.2",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "description": "Postgres target pack for Prisma Next",
8
8
  "dependencies": {
9
- "@prisma-next/cli": "0.15.0",
10
- "@prisma-next/contract": "0.15.0",
11
- "@prisma-next/errors": "0.15.0",
12
- "@prisma-next/family-sql": "0.15.0",
13
- "@prisma-next/framework-components": "0.15.0",
14
- "@prisma-next/migration-tools": "0.15.0",
15
- "@prisma-next/psl-parser": "0.15.0",
16
- "@prisma-next/sql-contract": "0.15.0",
17
- "@prisma-next/sql-errors": "0.15.0",
18
- "@prisma-next/sql-operations": "0.15.0",
19
- "@prisma-next/sql-relational-core": "0.15.0",
20
- "@prisma-next/sql-schema-ir": "0.15.0",
21
- "@prisma-next/ts-render": "0.15.0",
22
- "@prisma-next/utils": "0.15.0",
9
+ "@prisma-next/cli": "0.16.0-dev.2",
10
+ "@prisma-next/contract": "0.16.0-dev.2",
11
+ "@prisma-next/errors": "0.16.0-dev.2",
12
+ "@prisma-next/family-sql": "0.16.0-dev.2",
13
+ "@prisma-next/framework-components": "0.16.0-dev.2",
14
+ "@prisma-next/migration-tools": "0.16.0-dev.2",
15
+ "@prisma-next/psl-parser": "0.16.0-dev.2",
16
+ "@prisma-next/sql-contract": "0.16.0-dev.2",
17
+ "@prisma-next/sql-errors": "0.16.0-dev.2",
18
+ "@prisma-next/sql-operations": "0.16.0-dev.2",
19
+ "@prisma-next/sql-relational-core": "0.16.0-dev.2",
20
+ "@prisma-next/sql-schema-ir": "0.16.0-dev.2",
21
+ "@prisma-next/ts-render": "0.16.0-dev.2",
22
+ "@prisma-next/utils": "0.16.0-dev.2",
23
23
  "@standard-schema/spec": "^1.1.0",
24
24
  "arktype": "^2.2.2",
25
25
  "pathe": "^2.0.3"
26
26
  },
27
27
  "devDependencies": {
28
- "@prisma-next/psl-printer": "0.15.0",
29
- "@prisma-next/sql-contract-psl": "0.15.0",
30
- "@prisma-next/test-utils": "0.15.0",
31
- "@prisma-next/tsconfig": "0.15.0",
32
- "@prisma-next/tsdown": "0.15.0",
33
- "tsdown": "0.22.3",
28
+ "@prisma-next/psl-printer": "0.16.0-dev.2",
29
+ "@prisma-next/sql-contract-psl": "0.16.0-dev.2",
30
+ "@prisma-next/test-utils": "0.16.0-dev.2",
31
+ "@prisma-next/tsconfig": "0.16.0-dev.2",
32
+ "@prisma-next/tsdown": "0.16.0-dev.2",
33
+ "tsdown": "0.22.8",
34
34
  "typescript": "5.9.3",
35
35
  "vitest": "4.1.10"
36
36
  },
@@ -1,4 +1,7 @@
1
- import { temporalAuthoringPresets } from '@prisma-next/family-sql/control';
1
+ import {
2
+ temporalAuthoringPresets,
3
+ temporalCodecPresetWithPrecision,
4
+ } from '@prisma-next/family-sql/control';
2
5
  import type {
3
6
  AuthoringEntityContext,
4
7
  AuthoringEntityTypeFactoryOutput,
@@ -627,10 +630,20 @@ export const postgresAuthoringFieldPresets = {
627
630
  nativeType: 'timestamptz',
628
631
  },
629
632
  },
630
- temporal: /* @__PURE__ */ temporalAuthoringPresets({
631
- codecId: 'pg/timestamptz@1',
632
- nativeType: 'timestamptz',
633
- }),
633
+ temporal: {
634
+ .../* @__PURE__ */ temporalAuthoringPresets({
635
+ codecId: 'pg/timestamptz@1',
636
+ nativeType: 'timestamptz',
637
+ }),
638
+ timestamp: /* @__PURE__ */ temporalCodecPresetWithPrecision({
639
+ codecId: 'pg/timestamp@1',
640
+ nativeType: 'timestamp',
641
+ }),
642
+ timestamptz: /* @__PURE__ */ temporalCodecPresetWithPrecision({
643
+ codecId: 'pg/timestamptz@1',
644
+ nativeType: 'timestamptz',
645
+ }),
646
+ },
634
647
  uuidNative: {
635
648
  kind: 'fieldPreset',
636
649
  output: {
@@ -47,7 +47,7 @@ export const pgNumericDecode = (wire: string | number): string => {
47
47
  };
48
48
 
49
49
  export const pgNumericRenderOutputType = (typeParams: {
50
- readonly precision: number;
50
+ readonly precision?: number;
51
51
  readonly scale?: number;
52
52
  }): string | undefined => {
53
53
  const precision = typeParams.precision;
@@ -106,6 +106,58 @@ export const pgTimestamptzDecodeJson = (json: JsonValue): Date => {
106
106
  return date;
107
107
  };
108
108
 
109
+ const ISO_8601_DATE = /^(\d{4})-(\d{2})-(\d{2})$/;
110
+
111
+ function formatDateOnly(year: number, month: number, day: number): string {
112
+ return `${String(year).padStart(4, '0')}-${String(month).padStart(2, '0')}-${String(day).padStart(2, '0')}`;
113
+ }
114
+
115
+ /**
116
+ * A Postgres `date` has no time-of-day or timezone component, so `pg/date@1`
117
+ * canonicalizes its JS-level value as a `Date` at UTC midnight
118
+ * (`Date.UTC(y, m, d)`), independent of the process's local timezone.
119
+ *
120
+ * `pgDateEncode` reads the calendar date via UTC getters (matching that
121
+ * canonical form) and formats it as `YYYY-MM-DD` directly, bypassing the pg
122
+ * driver's own `Date` serialization (`dateToString`), which reads *local*
123
+ * getters and would shift the calendar day near midnight in negative-UTC-offset
124
+ * environments.
125
+ */
126
+ export const pgDateEncode = (value: Date): string =>
127
+ formatDateOnly(value.getUTCFullYear(), value.getUTCMonth() + 1, value.getUTCDate());
128
+
129
+ /**
130
+ * Normalizes the pg driver's already-parsed `Date` for a `date` column into
131
+ * the canonical UTC-midnight form. The driver (via `postgres-date`) builds
132
+ * that `Date` at *local* midnight from the wire text; reading it back with the
133
+ * same (local) getters recovers the exact calendar date the driver parsed,
134
+ * and reconstructing via `Date.UTC` makes the result's instant independent of
135
+ * the process's timezone.
136
+ */
137
+ export const pgDateDecode = (wire: Date): Date =>
138
+ new Date(Date.UTC(wire.getFullYear(), wire.getMonth(), wire.getDate()));
139
+
140
+ export const pgDateEncodeJson = (value: Date): JsonValue => pgDateEncode(value);
141
+
142
+ export const pgDateDecodeJson = (json: JsonValue): Date => {
143
+ if (typeof json !== 'string') {
144
+ throw new Error(`Expected date string for pg/date@1, got ${typeof json}`);
145
+ }
146
+ const match = ISO_8601_DATE.exec(json);
147
+ if (!match) {
148
+ throw new Error(`Invalid date string for pg/date@1: ${json}`);
149
+ }
150
+ const [, yearText, monthText, dayText] = match;
151
+ const year = Number(yearText);
152
+ const month = Number(monthText) - 1;
153
+ const day = Number(dayText);
154
+ const date = new Date(Date.UTC(year, month, day));
155
+ if (date.getUTCFullYear() !== year || date.getUTCMonth() !== month || date.getUTCDate() !== day) {
156
+ throw new Error(`Invalid date string for pg/date@1: ${json}`);
157
+ }
158
+ return date;
159
+ };
160
+
109
161
  export const pgIntervalDecode = (wire: string | Record<string, unknown>): string => {
110
162
  if (typeof wire === 'string') return wire;
111
163
  return JSON.stringify(wire);
@@ -22,6 +22,7 @@ export const PG_NUMERIC_CODEC_ID = 'pg/numeric@1' as const;
22
22
  export const PG_BOOL_CODEC_ID = 'pg/bool@1' as const;
23
23
  export const PG_BIT_CODEC_ID = 'pg/bit@1' as const;
24
24
  export const PG_VARBIT_CODEC_ID = 'pg/varbit@1' as const;
25
+ export const PG_DATE_CODEC_ID = 'pg/date@1' as const;
25
26
  export const PG_TIMESTAMP_CODEC_ID = 'pg/timestamp@1' as const;
26
27
  export const PG_TIMESTAMPTZ_CODEC_ID = 'pg/timestamptz@1' as const;
27
28
  export const PG_TIME_CODEC_ID = 'pg/time@1' as const;
@@ -45,6 +45,10 @@ import { type as arktype } from 'arktype';
45
45
  import {
46
46
  pgByteaDecodeJson,
47
47
  pgByteaEncodeJson,
48
+ pgDateDecode,
49
+ pgDateDecodeJson,
50
+ pgDateEncode,
51
+ pgDateEncodeJson,
48
52
  pgIntervalDecode,
49
53
  pgJsonbDecode,
50
54
  pgJsonbEncode,
@@ -64,6 +68,7 @@ import {
64
68
  PG_BOOL_CODEC_ID,
65
69
  PG_BYTEA_CODEC_ID,
66
70
  PG_CHAR_CODEC_ID,
71
+ PG_DATE_CODEC_ID,
67
72
  PG_ENUM_CODEC_ID,
68
73
  PG_FLOAT_CODEC_ID,
69
74
  PG_FLOAT4_CODEC_ID,
@@ -92,14 +97,14 @@ import { PostgresNativeEnum } from './postgres-native-enum';
92
97
 
93
98
  type LengthParams = { readonly length?: number };
94
99
  type PrecisionParams = { readonly precision?: number };
95
- type NumericParams = { readonly precision: number; readonly scale?: number };
100
+ type NumericParams = { readonly precision?: number; readonly scale?: number };
96
101
 
97
102
  const lengthParamsSchema = arktype({
98
103
  'length?': 'number.integer > 0',
99
104
  }) satisfies StandardSchemaV1<LengthParams>;
100
105
 
101
106
  const numericParamsSchema = arktype({
102
- precision: 'number.integer > 0 & number.integer <= 1000',
107
+ 'precision?': 'number.integer > 0 & number.integer <= 1000',
103
108
  'scale?': 'number.integer >= 0',
104
109
  }) satisfies StandardSchemaV1<NumericParams>;
105
110
 
@@ -115,6 +120,7 @@ const PG_INT8_META = { db: { sql: { postgres: { nativeType: 'bigint' } } } } as
115
120
  const PG_FLOAT4_META = { db: { sql: { postgres: { nativeType: 'real' } } } } as const;
116
121
  const PG_FLOAT8_META = { db: { sql: { postgres: { nativeType: 'double precision' } } } } as const;
117
122
  const PG_NUMERIC_META = { db: { sql: { postgres: { nativeType: 'numeric' } } } } as const;
123
+ const PG_DATE_META = { db: { sql: { postgres: { nativeType: 'date' } } } } as const;
118
124
  const PG_TIMESTAMP_META = {
119
125
  db: { sql: { postgres: { nativeType: 'timestamp without time zone' } } },
120
126
  } as const;
@@ -648,12 +654,57 @@ export class PgNumericDescriptor extends CodecDescriptorImpl<NumericParams> {
648
654
 
649
655
  export const pgNumericDescriptor = new PgNumericDescriptor();
650
656
 
651
- export const pgNumericColumn = (params: NumericParams) =>
657
+ export const pgNumericColumn = (params: NumericParams = {}) =>
652
658
  column(pgNumericDescriptor.factory(params), pgNumericDescriptor.codecId, params, 'numeric');
653
659
 
654
660
  pgNumericColumn satisfies ColumnHelperFor<PgNumericDescriptor>;
655
661
  pgNumericColumn satisfies ColumnHelperForStrict<PgNumericDescriptor>;
656
662
 
663
+ /**
664
+ * A Postgres `date` has no time-of-day or timezone component. This codec
665
+ * canonicalizes its JS-level value as a `Date` at UTC midnight, so its
666
+ * round-trip is independent of the process's local timezone — see
667
+ * `pgDateEncode`/`pgDateDecode` in `codec-helpers.ts`.
668
+ */
669
+ export class PgDateCodec extends CodecImpl<
670
+ typeof PG_DATE_CODEC_ID,
671
+ readonly ['equality', 'order'],
672
+ Date | string,
673
+ Date
674
+ > {
675
+ async encode(value: Date, _ctx: CodecCallContext): Promise<string> {
676
+ return pgDateEncode(value);
677
+ }
678
+ async decode(wire: Date, _ctx: CodecCallContext): Promise<Date> {
679
+ return pgDateDecode(wire);
680
+ }
681
+ encodeJson(value: Date): JsonValue {
682
+ return pgDateEncodeJson(value);
683
+ }
684
+ decodeJson(json: JsonValue): Date {
685
+ return pgDateDecodeJson(json);
686
+ }
687
+ }
688
+
689
+ export class PgDateDescriptor extends CodecDescriptorImpl<void> {
690
+ override readonly codecId = PG_DATE_CODEC_ID;
691
+ override readonly traits = ['equality', 'order'] as const;
692
+ override readonly targetTypes = ['date'] as const;
693
+ override readonly meta = PG_DATE_META;
694
+ override readonly paramsSchema: StandardSchemaV1<void> = voidParamsSchema;
695
+ override factory(): (ctx: CodecInstanceContext) => PgDateCodec {
696
+ return () => new PgDateCodec(this);
697
+ }
698
+ }
699
+
700
+ export const pgDateDescriptor = new PgDateDescriptor();
701
+
702
+ export const pgDateColumn = () =>
703
+ column(pgDateDescriptor.factory(), pgDateDescriptor.codecId, undefined, 'date');
704
+
705
+ pgDateColumn satisfies ColumnHelperFor<PgDateDescriptor>;
706
+ pgDateColumn satisfies ColumnHelperForStrict<PgDateDescriptor>;
707
+
657
708
  export class PgTimestampCodec extends CodecImpl<
658
709
  typeof PG_TIMESTAMP_CODEC_ID,
659
710
  readonly ['equality', 'order'],
@@ -1285,6 +1336,8 @@ export const codecDescriptors: readonly AnyCodecDescriptor[] = [
1285
1336
  pgFloat4Descriptor,
1286
1337
  pgFloat8Descriptor,
1287
1338
  pgNumericDescriptor,
1339
+ // PSL `@db.Date` binding is deferred to remove-db-attributes' `Date` type; pin it via codecId, not a second targetTypes activation here.
1340
+ pgDateDescriptor,
1288
1341
  pgTimestampDescriptor,
1289
1342
  pgTimestamptzDescriptor,
1290
1343
  pgTimeDescriptor,
@@ -249,3 +249,25 @@ export function parsePostgresDefault(
249
249
 
250
250
  return { kind: 'function', expression: trimmed };
251
251
  }
252
+
253
+ /**
254
+ * Normalizes a contract-declared default through {@link parsePostgresDefault}
255
+ * — the same parser introspection uses — so a function-shaped default the
256
+ * parser recognizes as a literal (e.g. `dbgenerated("'{}'::jsonb")`)
257
+ * resolves to the same `resolvedDefault` shape a live introspected column
258
+ * would produce. Compensates once, at `SchemaIR` construction of the
259
+ * expected (contract-derived) side (`contractToSchemaIR`'s `resolveDefault`
260
+ * hook), instead of at every site that later compares the two sides. A
261
+ * literal default, or a function form the parser doesn't recognize, passes
262
+ * through unchanged; `nextval(...)` normalizes to `autoincrement()` on both
263
+ * sides, matching a `serial`/identity column's introspected counterpart.
264
+ */
265
+ export function postgresResolveDefault(
266
+ def: ColumnDefault,
267
+ resolvedNativeType: string,
268
+ ): ColumnDefault {
269
+ if (def.kind !== 'function') {
270
+ return def;
271
+ }
272
+ return parsePostgresDefault(def.expression, resolvedNativeType) ?? def;
273
+ }
@@ -9,12 +9,14 @@ import {
9
9
  } from './authoring';
10
10
  import { postgresQualifyColumnType } from './codecs';
11
11
  import { postgresTargetDescriptorMetaRuntime } from './descriptor-meta-runtime';
12
+ import { postgresIndexTypes } from './index-types';
12
13
  import { DEFAULT_NAMESPACE_ID } from './namespace-ids';
13
14
  import { postgresCreateNamespace } from './postgres-schema';
14
15
 
15
16
  const postgresTargetDescriptorMetaBase = {
16
17
  ...postgresTargetDescriptorMetaRuntime,
17
18
  defaultNamespaceId: DEFAULT_NAMESPACE_ID,
19
+ indexTypes: postgresIndexTypes,
18
20
  authoring: {
19
21
  type: postgresAuthoringTypes,
20
22
  field: postgresAuthoringFieldPresets,
@@ -12,9 +12,10 @@ import { CliStructuredError } from '@prisma-next/errors/control';
12
12
  * The `operation` argument is required so every throw site names the operation
13
13
  * that actually failed; a new operation cannot inherit a misattributed message.
14
14
  *
15
- * Distinct from `PN-MIG-2001` (placeholder not filled) and `PN-MIG-2005`
16
- * (data-transform query plan against wrong contract) because the missing
17
- * input is the stack itself, not the per-operation contract.
15
+ * Distinct from `MIGRATION.UNFILLED_PLACEHOLDER` (placeholder not filled)
16
+ * and `MIGRATION.DATA_TRANSFORM_CONTRACT_MISMATCH` (data-transform query
17
+ * plan against wrong contract) because the missing input is the stack
18
+ * itself, not the per-operation contract.
18
19
  *
19
20
  * Lives in `@prisma-next/target-postgres/errors` rather than the shared
20
21
  * framework migration errors module because the failure is target-specific:
@@ -23,10 +24,9 @@ import { CliStructuredError } from '@prisma-next/errors/control';
23
24
  */
24
25
  export function errorPostgresMigrationStackMissing(operation: string): CliStructuredError {
25
26
  return new CliStructuredError(
26
- '2007',
27
+ 'MIGRATION.POSTGRES_CONTROL_STACK_MISSING',
27
28
  `PostgresMigration.${operation} requires a control adapter`,
28
29
  {
29
- domain: 'MIG',
30
30
  why: `PostgresMigration.${operation} was invoked on an instance constructed without a ControlStack, so the stored controlAdapter is undefined and the operation cannot lower its plan.`,
31
31
  fix: 'Construct the migration via the migration CLI entrypoint (which assembles a ControlStack from the loaded prisma-next.config.ts), or pass a ControlStack containing a Postgres adapter to the migration constructor in test fixtures.',
32
32
  meta: { operation },
@@ -0,0 +1,15 @@
1
+ import { defineIndexTypes } from '@prisma-next/sql-contract/index-types';
2
+ import { type } from 'arktype';
3
+
4
+ // Postgres's built-in index access methods (`CREATE INDEX ... USING <method>`).
5
+ // Per-method option validation (e.g. `gin` operator classes) is out of scope;
6
+ // every method accepts any options object until a later slice narrows it.
7
+ export const postgresIndexTypes = defineIndexTypes()
8
+ .add('btree', { options: type('object') })
9
+ .add('hash', { options: type('object') })
10
+ .add('gin', { options: type('object') })
11
+ .add('gist', { options: type('object') })
12
+ .add('spgist', { options: type('object') })
13
+ .add('brin', { options: type('object') });
14
+
15
+ export type IndexTypes = typeof postgresIndexTypes.IndexTypes;