@prisma-next/target-postgres 0.14.0 → 0.15.0-dev.10
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.
- package/dist/authoring-BtsOWgI3.mjs +674 -0
- package/dist/authoring-BtsOWgI3.mjs.map +1 -0
- package/dist/canonicalize-D1F4vUnP.d.mts +48 -0
- package/dist/canonicalize-D1F4vUnP.d.mts.map +1 -0
- package/dist/{codec-ids-BvytN2P8.mjs → codec-ids-B10ZZHzw.mjs} +4 -2
- package/dist/codec-ids-B10ZZHzw.mjs.map +1 -0
- package/dist/{codec-ids-CnXu9Qy3.d.mts → codec-ids-CI144z7g.d.mts} +4 -2
- package/dist/codec-ids-CI144z7g.d.mts.map +1 -0
- package/dist/codec-ids.d.mts +2 -2
- package/dist/codec-ids.mjs +2 -2
- package/dist/{codec-types-DHCkwPKE.d.mts → codec-types-CTfT4U4O.d.mts} +4 -2
- package/dist/codec-types-CTfT4U4O.d.mts.map +1 -0
- package/dist/codec-types.d.mts +1 -1
- package/dist/{codecs--0A5_4Bq.d.mts → codecs-D7W9O0Xx.d.mts} +134 -4
- package/dist/codecs-D7W9O0Xx.d.mts.map +1 -0
- package/dist/codecs-DRbb26Or.mjs +955 -0
- package/dist/codecs-DRbb26Or.mjs.map +1 -0
- package/dist/codecs.d.mts +2 -2
- package/dist/codecs.mjs +3 -757
- package/dist/codecs.mjs.map +1 -1
- package/dist/contract-free.d.mts +33 -3
- package/dist/contract-free.d.mts.map +1 -1
- package/dist/contract-free.mjs +23 -7
- package/dist/contract-free.mjs.map +1 -1
- package/dist/control-policy-DaLdbcYE.mjs +1254 -0
- package/dist/control-policy-DaLdbcYE.mjs.map +1 -0
- package/dist/control.d.mts +2 -2
- package/dist/control.d.mts.map +1 -1
- package/dist/control.mjs +880 -36
- package/dist/control.mjs.map +1 -1
- package/dist/data-transform-BOWpliq8.mjs.map +1 -1
- package/dist/{data-transform-DDgWdB5o.d.mts → data-transform-DPzwBMhW.d.mts} +3 -3
- package/dist/{data-transform-DDgWdB5o.d.mts.map → data-transform-DPzwBMhW.d.mts.map} +1 -1
- package/dist/data-transform.d.mts +1 -1
- package/dist/{ddl-QDyOSeLc.mjs → ddl-GTTOvjx_.mjs} +128 -6
- package/dist/ddl-GTTOvjx_.mjs.map +1 -0
- package/dist/ddl.d.mts +3 -2
- package/dist/ddl.mjs +2 -2
- package/dist/default-normalizer.d.mts +1 -1
- package/dist/default-normalizer.d.mts.map +1 -1
- package/dist/default-normalizer.mjs +247 -1
- package/dist/default-normalizer.mjs.map +1 -0
- package/dist/descriptor-meta-CFQKLXl_.mjs +23 -0
- package/dist/descriptor-meta-CFQKLXl_.mjs.map +1 -0
- package/dist/descriptor-meta-runtime-UwYdV8fD.mjs +12 -0
- package/dist/descriptor-meta-runtime-UwYdV8fD.mjs.map +1 -0
- package/dist/diff-database-schema-oY3brcLj.mjs +368 -0
- package/dist/diff-database-schema-oY3brcLj.mjs.map +1 -0
- package/dist/diff-database-schema.d.mts +37 -0
- package/dist/diff-database-schema.d.mts.map +1 -0
- package/dist/diff-database-schema.mjs +2 -0
- package/dist/errors-DO-w0EUS.mjs +35 -0
- package/dist/errors-DO-w0EUS.mjs.map +1 -0
- package/dist/errors.d.mts +11 -9
- package/dist/errors.d.mts.map +1 -1
- package/dist/errors.mjs +1 -1
- package/dist/issue-planner.d.mts +35 -11
- package/dist/issue-planner.d.mts.map +1 -1
- package/dist/issue-planner.mjs +2 -2
- package/dist/migration.d.mts +5 -5
- package/dist/migration.d.mts.map +1 -1
- package/dist/migration.mjs +4 -4
- package/dist/namespace-ids-xtp_ZY86.mjs +7 -0
- package/dist/namespace-ids-xtp_ZY86.mjs.map +1 -0
- package/dist/native-type-normalizer.mjs +37 -1
- package/dist/native-type-normalizer.mjs.map +1 -0
- package/dist/nodes-DJC5B8Id.mjs +192 -0
- package/dist/nodes-DJC5B8Id.mjs.map +1 -0
- package/dist/nodes-Dv5eCSq9.d.mts +170 -0
- package/dist/nodes-Dv5eCSq9.d.mts.map +1 -0
- package/dist/{op-factory-call-DmQEc3XV.d.mts → op-factory-call-CvH0JeBW.d.mts} +119 -17
- package/dist/op-factory-call-CvH0JeBW.d.mts.map +1 -0
- package/dist/{op-factory-call-D_p5vxwt.mjs → op-factory-call-tBcLo_B8.mjs} +496 -38
- package/dist/op-factory-call-tBcLo_B8.mjs.map +1 -0
- package/dist/op-factory-call.d.mts +2 -2
- package/dist/op-factory-call.mjs +2 -2
- package/dist/pack.d.mts +321 -3
- package/dist/pack.d.mts.map +1 -1
- package/dist/pack.mjs +1 -1
- package/dist/{planner-ddl-builders-B2wOwLqI.mjs → planner-ddl-builders-BKlmGDJl.mjs} +17 -28
- package/dist/planner-ddl-builders-BKlmGDJl.mjs.map +1 -0
- package/dist/planner-ddl-builders.d.mts +4 -6
- package/dist/planner-ddl-builders.d.mts.map +1 -1
- package/dist/planner-ddl-builders.mjs +2 -2
- package/dist/planner-identity-values-CJPha2Sz.mjs.map +1 -1
- package/dist/planner-identity-values.d.mts +8 -2
- package/dist/planner-identity-values.d.mts.map +1 -1
- package/dist/planner-identity-values.mjs +2 -2
- package/dist/planner-ootbxGty.mjs +390 -0
- package/dist/planner-ootbxGty.mjs.map +1 -0
- package/dist/{planner-produced-postgres-migration-Cji5vxUf.mjs → planner-produced-postgres-migration-DVsaobdV.mjs} +3 -3
- package/dist/{planner-produced-postgres-migration-Cji5vxUf.mjs.map → planner-produced-postgres-migration-DVsaobdV.mjs.map} +1 -1
- package/dist/{planner-produced-postgres-migration-QqHa2C2l.d.mts → planner-produced-postgres-migration-k33bb9Sm.d.mts} +4 -4
- package/dist/{planner-produced-postgres-migration-QqHa2C2l.d.mts.map → planner-produced-postgres-migration-k33bb9Sm.d.mts.map} +1 -1
- package/dist/planner-produced-postgres-migration.d.mts +1 -1
- package/dist/planner-produced-postgres-migration.mjs +1 -1
- package/dist/{planner-sql-checks-jqUUGyQR.mjs → planner-sql-checks-zqNfs2XZ.mjs} +5 -5
- package/dist/{planner-sql-checks-jqUUGyQR.mjs.map → planner-sql-checks-zqNfs2XZ.mjs.map} +1 -1
- package/dist/planner-sql-checks.d.mts +2 -2
- package/dist/planner-sql-checks.d.mts.map +1 -1
- package/dist/planner-sql-checks.mjs +1 -1
- package/dist/{planner-target-details-CIY6tLeo.d.mts → planner-target-details-HkP4RrRO.d.mts} +2 -2
- package/dist/planner-target-details-HkP4RrRO.d.mts.map +1 -0
- package/dist/planner-target-details.d.mts +1 -1
- package/dist/planner.d.mts +72 -17
- package/dist/planner.d.mts.map +1 -1
- package/dist/planner.mjs +3 -2
- package/dist/postgres-contract-view-C9j5cqP0.d.mts +34 -0
- package/dist/postgres-contract-view-C9j5cqP0.d.mts.map +1 -0
- package/dist/{postgres-contract-serializer-k3TAcPMY.mjs → postgres-contract-view-DM8sN1Ot.mjs} +45 -41
- package/dist/postgres-contract-view-DM8sN1Ot.mjs.map +1 -0
- package/dist/postgres-database-schema-node-DJOTywwQ.d.mts +271 -0
- package/dist/postgres-database-schema-node-DJOTywwQ.d.mts.map +1 -0
- package/dist/postgres-migration-Bt3sXoID.mjs +194 -0
- package/dist/postgres-migration-Bt3sXoID.mjs.map +1 -0
- package/dist/{postgres-migration-Y4YBJqkS.d.mts → postgres-migration-ulfqRGA1.d.mts} +83 -9
- package/dist/postgres-migration-ulfqRGA1.d.mts.map +1 -0
- package/dist/postgres-native-enum-BwVNf0Ku.mjs +45 -0
- package/dist/postgres-native-enum-BwVNf0Ku.mjs.map +1 -0
- package/dist/postgres-rls-policy--CSddvMR.d.mts +52 -0
- package/dist/postgres-rls-policy--CSddvMR.d.mts.map +1 -0
- package/dist/postgres-role-schema-node-bg32e7I-.mjs +191 -0
- package/dist/postgres-role-schema-node-bg32e7I-.mjs.map +1 -0
- package/dist/{postgres-schema-COGZ1ark.mjs → postgres-schema-Cm4DtiGA.mjs} +200 -11
- package/dist/postgres-schema-Cm4DtiGA.mjs.map +1 -0
- package/dist/postgres-schema-DKq6s1P3.d.mts +269 -0
- package/dist/postgres-schema-DKq6s1P3.d.mts.map +1 -0
- package/dist/postgres-table-schema-node-D6LvInCe.mjs +216 -0
- package/dist/postgres-table-schema-node-D6LvInCe.mjs.map +1 -0
- package/dist/render-ops.d.mts +1 -1
- package/dist/{render-typescript-KMgosran.mjs → render-typescript-7yqILcwr.mjs} +45 -16
- package/dist/render-typescript-7yqILcwr.mjs.map +1 -0
- package/dist/render-typescript.mjs +1 -1
- package/dist/resolve-ddl-schema-XyBaaenM.mjs +22 -0
- package/dist/resolve-ddl-schema-XyBaaenM.mjs.map +1 -0
- package/dist/rls-canonicalize.d.mts +27 -0
- package/dist/rls-canonicalize.d.mts.map +1 -0
- package/dist/rls-canonicalize.mjs +2 -0
- package/dist/runtime.d.mts +6 -8
- package/dist/runtime.d.mts.map +1 -1
- package/dist/runtime.mjs +3 -3
- package/dist/runtime.mjs.map +1 -1
- package/dist/schema-ir-annotations.d.mts +15 -0
- package/dist/schema-ir-annotations.d.mts.map +1 -0
- package/dist/schema-ir-annotations.mjs +2 -0
- package/dist/schema-node-kinds-CrYzCR1i.d.mts +30 -0
- package/dist/schema-node-kinds-CrYzCR1i.d.mts.map +1 -0
- package/dist/{sql-utils-DcfMz4MQ.mjs → sql-utils-SU4FDvIV.mjs} +12 -3
- package/dist/{sql-utils-DcfMz4MQ.mjs.map → sql-utils-SU4FDvIV.mjs.map} +1 -1
- package/dist/sql-utils.d.mts +8 -1
- package/dist/sql-utils.d.mts.map +1 -1
- package/dist/sql-utils.mjs +2 -2
- package/dist/types.d.mts +5 -140
- package/dist/types.mjs +5 -2
- package/dist/wire-name-DbQ9-2RC.mjs +104 -0
- package/dist/wire-name-DbQ9-2RC.mjs.map +1 -0
- package/package.json +26 -20
- package/src/contract-free/checks.ts +153 -0
- package/src/contract-free/control-bootstrap.ts +20 -3
- package/src/contract-free/ddl.ts +98 -1
- package/src/core/authoring.ts +726 -2
- package/src/core/codec-helpers.ts +33 -7
- package/src/core/codec-ids.ts +2 -0
- package/src/core/codec-type-map.ts +4 -0
- package/src/core/codecs.ts +236 -12
- package/src/core/ddl/nodes.ts +185 -2
- package/src/core/default-normalizer.ts +122 -2
- package/src/core/descriptor-meta.ts +12 -1
- package/src/core/entity-kinds.ts +41 -0
- package/src/core/errors.ts +14 -12
- package/src/core/migrations/bound-schema.ts +10 -0
- package/src/core/migrations/column-ddl-rendering.ts +117 -0
- package/src/core/migrations/contract-to-postgres-database-schema-node.ts +269 -0
- package/src/core/migrations/control-policy.ts +218 -65
- package/src/core/migrations/diff-database-schema.ts +252 -0
- package/src/core/migrations/issue-planner.ts +782 -660
- package/src/core/migrations/op-factory-call.ts +415 -31
- package/src/core/migrations/operations/columns.ts +24 -12
- package/src/core/migrations/operations/constraints.ts +1 -1
- package/src/core/migrations/operations/data-transform.ts +6 -0
- package/src/core/migrations/operations/dependencies.ts +2 -1
- package/src/core/migrations/operations/native-enum-types.ts +62 -0
- package/src/core/migrations/operations/rls.ts +187 -0
- package/src/core/migrations/operations/shared.ts +0 -30
- package/src/core/migrations/planner-ddl-builders.ts +31 -59
- package/src/core/migrations/planner-identity-values.ts +1 -1
- package/src/core/migrations/planner-recipes.ts +31 -13
- package/src/core/migrations/planner-sql-checks.ts +1 -1
- package/src/core/migrations/planner-strategies.ts +250 -218
- package/src/core/migrations/planner-target-details.ts +3 -1
- package/src/core/migrations/planner.ts +358 -67
- package/src/core/migrations/postgres-migration.ts +178 -86
- package/src/core/migrations/render-typescript.ts +42 -15
- package/src/core/migrations/resolve-ddl-schema.ts +26 -0
- package/src/core/migrations/runner.ts +11 -16
- package/src/core/migrations/verify-postgres-namespaces.ts +45 -31
- package/src/core/namespace-ids.ts +3 -0
- package/src/core/postgres-contract-serializer.ts +46 -71
- package/src/core/postgres-contract-view.ts +48 -0
- package/src/core/postgres-native-enum.ts +61 -0
- package/src/core/postgres-rls-enablement.ts +34 -0
- package/src/core/postgres-rls-policy.ts +64 -0
- package/src/core/postgres-role.ts +59 -0
- package/src/core/postgres-schema-verifier.ts +10 -7
- package/src/core/postgres-schema.ts +85 -15
- package/src/core/postgres-validators.ts +34 -0
- package/src/core/psl-infer/infer-psl-contract.ts +1290 -0
- package/src/core/psl-infer/postgres-default-mapping.ts +16 -0
- package/src/core/psl-infer/postgres-type-map.ts +129 -0
- package/src/core/rls/canonicalize.ts +65 -0
- package/src/core/rls/wire-name.ts +33 -0
- package/src/core/schema-ir/node-storage-coordinate.ts +26 -0
- package/src/core/schema-ir/postgres-database-schema-node.ts +61 -0
- package/src/core/schema-ir/postgres-namespace-schema-node.ts +70 -0
- package/src/core/schema-ir/postgres-native-enum-schema-node.ts +83 -0
- package/src/core/schema-ir/postgres-policy-schema-node.ts +100 -0
- package/src/core/schema-ir/postgres-role-schema-node.ts +65 -0
- package/src/core/schema-ir/postgres-table-schema-node.ts +140 -0
- package/src/core/schema-ir/schema-node-kinds.ts +122 -0
- package/src/core/sql-utils.ts +15 -2
- package/src/exports/codecs.ts +5 -0
- package/src/exports/contract-free.ts +11 -1
- package/src/exports/control.ts +27 -33
- package/src/exports/ddl.ts +8 -0
- package/src/exports/diff-database-schema.ts +7 -0
- package/src/exports/issue-planner.ts +1 -1
- package/src/exports/migration.ts +1 -0
- package/src/exports/op-factory-call.ts +9 -0
- package/src/exports/planner-ddl-builders.ts +0 -2
- package/src/exports/planner-identity-values.ts +4 -1
- package/src/exports/planner.ts +1 -0
- package/src/exports/rls-canonicalize.ts +12 -0
- package/src/exports/runtime.ts +1 -0
- package/src/exports/schema-ir-annotations.ts +1 -0
- package/src/exports/sql-utils.ts +1 -0
- package/src/exports/types.ts +38 -0
- package/dist/codec-ids-BvytN2P8.mjs.map +0 -1
- package/dist/codec-ids-CnXu9Qy3.d.mts.map +0 -1
- package/dist/codec-types-DHCkwPKE.d.mts.map +0 -1
- package/dist/codecs--0A5_4Bq.d.mts.map +0 -1
- package/dist/ddl-QDyOSeLc.mjs.map +0 -1
- package/dist/default-normalizer-DyyCHQWs.mjs +0 -131
- package/dist/default-normalizer-DyyCHQWs.mjs.map +0 -1
- package/dist/descriptor-meta-CpGygXpI.mjs +0 -140
- package/dist/descriptor-meta-CpGygXpI.mjs.map +0 -1
- package/dist/errors-CUk87ByX.mjs +0 -33
- package/dist/errors-CUk87ByX.mjs.map +0 -1
- package/dist/issue-planner-DL6g3CmE.mjs +0 -824
- package/dist/issue-planner-DL6g3CmE.mjs.map +0 -1
- package/dist/native-type-normalizer-Bc9XJzWC.mjs +0 -38
- package/dist/native-type-normalizer-Bc9XJzWC.mjs.map +0 -1
- package/dist/nodes-Bbhs2rwj.mjs +0 -76
- package/dist/nodes-Bbhs2rwj.mjs.map +0 -1
- package/dist/nodes-pLeLgdis.d.mts +0 -67
- package/dist/nodes-pLeLgdis.d.mts.map +0 -1
- package/dist/op-factory-call-D_p5vxwt.mjs.map +0 -1
- package/dist/op-factory-call-DmQEc3XV.d.mts.map +0 -1
- package/dist/planner-Bs_baQax.mjs +0 -324
- package/dist/planner-Bs_baQax.mjs.map +0 -1
- package/dist/planner-ddl-builders-B2wOwLqI.mjs.map +0 -1
- package/dist/planner-target-details-CIY6tLeo.d.mts.map +0 -1
- package/dist/postgres-contract-serializer-k3TAcPMY.mjs.map +0 -1
- package/dist/postgres-migration-B5jKrXv3.mjs +0 -145
- package/dist/postgres-migration-B5jKrXv3.mjs.map +0 -1
- package/dist/postgres-migration-Y4YBJqkS.d.mts.map +0 -1
- package/dist/postgres-schema-COGZ1ark.mjs.map +0 -1
- package/dist/render-typescript-KMgosran.mjs.map +0 -1
- package/dist/types.d.mts.map +0 -1
- package/src/core/postgres-enum-type-schema.ts +0 -17
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"planner-sql-checks.d.mts","names":[],"sources":["../src/core/migrations/planner-sql-checks.ts"],"mappings":";;;;;;AAiBA;;;;AAA8D;AAgI9D;;;;iBAhIgB,gBAAA,CAAiB,MAAA,UAAgB,KAAa;AAAA,iBAgI9C,uBAAA,CACd,MAAA,EAAQ,aAAA,EACR,UAAA,EAAY,
|
|
1
|
+
{"version":3,"file":"planner-sql-checks.d.mts","names":[],"sources":["../src/core/migrations/planner-sql-checks.ts"],"mappings":";;;;;;AAiBA;;;;AAA8D;AAgI9D;;;;iBAhIgB,gBAAA,CAAiB,MAAA,UAAgB,KAAa;AAAA,iBAgI9C,uBAAA,CACd,MAAA,EAAQ,aAAA,EACR,UAAA,EAAY,WAAA,SAAoB,iBAAA,GAChC,YAAA,GAAc,MAAA,SAAe,mBAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as qualifyTableName, t as buildExpectedFormatType } from "./planner-sql-checks-
|
|
1
|
+
import { n as qualifyTableName, t as buildExpectedFormatType } from "./planner-sql-checks-zqNfs2XZ.mjs";
|
|
2
2
|
export { buildExpectedFormatType, qualifyTableName };
|
package/dist/{planner-target-details-CIY6tLeo.d.mts → planner-target-details-HkP4RrRO.d.mts}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region src/core/migrations/planner-target-details.d.ts
|
|
2
|
-
type OperationClass = 'dependency' | 'type' | 'table' | 'column' | 'primaryKey' | 'unique' | 'index' | 'foreignKey' | 'checkConstraint';
|
|
2
|
+
type OperationClass = 'dependency' | 'type' | 'table' | 'column' | 'primaryKey' | 'unique' | 'index' | 'foreignKey' | 'checkConstraint' | 'rlsPolicy' | 'rowLevelSecurity';
|
|
3
3
|
interface PostgresPlanTargetDetails {
|
|
4
4
|
readonly schema: string;
|
|
5
5
|
readonly objectType: OperationClass;
|
|
@@ -8,4 +8,4 @@ interface PostgresPlanTargetDetails {
|
|
|
8
8
|
}
|
|
9
9
|
//#endregion
|
|
10
10
|
export { PostgresPlanTargetDetails as t };
|
|
11
|
-
//# sourceMappingURL=planner-target-details-
|
|
11
|
+
//# sourceMappingURL=planner-target-details-HkP4RrRO.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"planner-target-details-HkP4RrRO.d.mts","names":[],"sources":["../src/core/migrations/planner-target-details.ts"],"mappings":";KAEY,cAAA;AAAA,UAaK,yBAAA;EAAA,SACN,MAAA;EAAA,SACA,UAAA,EAAY,cAAc;EAAA,SAC1B,IAAA;EAAA,SACA,KAAA;AAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as PostgresPlanTargetDetails } from "./planner-target-details-
|
|
1
|
+
import { t as PostgresPlanTargetDetails } from "./planner-target-details-HkP4RrRO.mjs";
|
|
2
2
|
export type { PostgresPlanTargetDetails };
|
package/dist/planner.d.mts
CHANGED
|
@@ -1,10 +1,35 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { t as PostgresDatabaseSchemaNode } from "./postgres-database-schema-node-DJOTywwQ.mjs";
|
|
2
|
+
import { t as PostgresContract } from "./postgres-schema-DKq6s1P3.mjs";
|
|
3
|
+
import { t as TypeScriptRenderablePostgresMigration } from "./planner-produced-postgres-migration-k33bb9Sm.mjs";
|
|
4
|
+
import { ContractToSchemaIROptions, MigrationOperationPolicy, SqlPlannerConflict, SqlPlannerFailureResult } from "@prisma-next/family-sql/control";
|
|
5
|
+
import { MigrationPlanWithAuthoringSurface, MigrationPlanner, MigrationScaffoldContext, SchemaOwnership } from "@prisma-next/framework-components/control";
|
|
4
6
|
import { Contract } from "@prisma-next/contract/types";
|
|
5
7
|
import { ExecuteRequestLowerer } from "@prisma-next/family-sql/control-adapter";
|
|
6
8
|
import { TargetBoundComponentDescriptor } from "@prisma-next/framework-components/components";
|
|
7
9
|
|
|
10
|
+
//#region src/core/migrations/contract-to-postgres-database-schema-node.d.ts
|
|
11
|
+
/**
|
|
12
|
+
* Projects a Postgres contract into the expected schema-diff tree: a
|
|
13
|
+
* `PostgresDatabaseSchemaNode` root holding one `PostgresNamespaceSchemaNode`
|
|
14
|
+
* per Postgres namespace, each holding its `PostgresTableSchemaNode`s with
|
|
15
|
+
* their `PostgresPolicySchemaNode`s, plus the database roles on the root.
|
|
16
|
+
*
|
|
17
|
+
* Not a duplicate of the family's `contractToSchemaIR`: that builds a flat,
|
|
18
|
+
* single `{ tables }` map (and throws on cross-namespace name collisions, with
|
|
19
|
+
* no RLS/role concept) for SQLite's single-schema world. This is the
|
|
20
|
+
* Postgres-specific *tree* shape — multi-schema, RLS-policy-aware, role-aware.
|
|
21
|
+
* It reuses the family's per-namespace table conversion (`contractNamespaceToSchemaIR`)
|
|
22
|
+
* for column/FK/index building and only adds the Postgres tree/policy/role shape.
|
|
23
|
+
*
|
|
24
|
+
* Tables are grouped by their owning namespace (resolved DDL schema name) so
|
|
25
|
+
* the tree mirrors Postgres's object hierarchy. The DDL schema name is
|
|
26
|
+
* resolved once per namespace.
|
|
27
|
+
*
|
|
28
|
+
* A policy that references a table absent from its namespace is a malformed
|
|
29
|
+
* contract — the loop throws rather than fabricating a stub table.
|
|
30
|
+
*/
|
|
31
|
+
declare function contractToPostgresDatabaseSchemaNode(contract: PostgresContract | null, options: ContractToSchemaIROptions): PostgresDatabaseSchemaNode;
|
|
32
|
+
//#endregion
|
|
8
33
|
//#region src/core/migrations/planner.d.ts
|
|
9
34
|
declare function createPostgresMigrationPlanner(lowerer: ExecuteRequestLowerer): PostgresMigrationPlanner;
|
|
10
35
|
/**
|
|
@@ -22,18 +47,20 @@ type PostgresPlanResult = {
|
|
|
22
47
|
/**
|
|
23
48
|
* Postgres migration planner — a thin wrapper over `planIssues`.
|
|
24
49
|
*
|
|
25
|
-
* `plan()`
|
|
26
|
-
* `
|
|
27
|
-
* `
|
|
28
|
-
* type-change, nullable-tightening, codec-hook
|
|
29
|
-
* component-declared dependency installs, and
|
|
30
|
-
* empty-table-guarded NOT-NULL add-column. The same
|
|
31
|
-
* `migration plan`, `db update`, and `db init`;
|
|
32
|
-
* `policy.allowedOperationClasses` (the
|
|
33
|
-
* when `'data'` is excluded). The issue
|
|
34
|
-
* policy gates and emits a single
|
|
35
|
-
* the runtime-ops view (via
|
|
36
|
-
* authoring surface.
|
|
50
|
+
* `plan()` diffs the target contract against the live schema via the one
|
|
51
|
+
* differ (`buildPostgresPlanDiff`, producing node-typed `SchemaDiffIssue[]`)
|
|
52
|
+
* and delegates to `planIssues` with the unified `postgresPlannerStrategies`
|
|
53
|
+
* list: NOT-NULL backfill, type-change, nullable-tightening, codec-hook
|
|
54
|
+
* storage types, component-declared dependency installs, and
|
|
55
|
+
* shared-temp-default / empty-table-guarded NOT-NULL add-column. The same
|
|
56
|
+
* strategy list runs for `migration plan`, `db update`, and `db init`;
|
|
57
|
+
* behavior diverges purely on `policy.allowedOperationClasses` (the
|
|
58
|
+
* data-safe strategies short-circuit when `'data'` is excluded). The issue
|
|
59
|
+
* planner applies operation-class policy gates and emits a single
|
|
60
|
+
* `PostgresOpFactoryCall[]` that drives both the runtime-ops view (via
|
|
61
|
+
* `renderOps`) and the `renderTypeScript()` authoring surface. RLS policy
|
|
62
|
+
* drift (the structural half of the same one-differ tree) is handled
|
|
63
|
+
* separately via `planPostgresSchemaDiff`.
|
|
37
64
|
*/
|
|
38
65
|
declare class PostgresMigrationPlanner implements MigrationPlanner<'sql', 'postgres'> {
|
|
39
66
|
#private;
|
|
@@ -65,12 +92,40 @@ declare class PostgresMigrationPlanner implements MigrationPlanner<'sql', 'postg
|
|
|
65
92
|
* the marker row by the right space.
|
|
66
93
|
*/
|
|
67
94
|
readonly spaceId: string;
|
|
95
|
+
/**
|
|
96
|
+
* Ownership oracle over the contract-space composition — see
|
|
97
|
+
* {@link SqlMigrationPlannerPlanOptions.ownership}.
|
|
98
|
+
*/
|
|
99
|
+
readonly ownership?: SchemaOwnership;
|
|
68
100
|
}): PostgresPlanResult;
|
|
69
101
|
emptyMigration(context: MigrationScaffoldContext, spaceId: string): MigrationPlanWithAuthoringSurface;
|
|
70
102
|
private planSql;
|
|
103
|
+
/**
|
|
104
|
+
* Maps the RLS policy presence findings of the one combined tree diff
|
|
105
|
+
* (`buildPostgresPlanDiff`, already ownership-filtered) into
|
|
106
|
+
* `CREATE POLICY` / `DROP POLICY` / `ALTER POLICY … RENAME TO` ops. It
|
|
107
|
+
* does not re-diff — it consumes exactly the policy-node subset of the
|
|
108
|
+
* shared diff's issues. Enablement is NOT decided here: `ENABLE`/`DISABLE
|
|
109
|
+
* ROW LEVEL SECURITY` derive from the table's marker-driven `rlsEnabled`
|
|
110
|
+
* attribute diff on the relational side.
|
|
111
|
+
*
|
|
112
|
+
* Rename post-pass: a `not-found` and a `not-expected` policy on the SAME
|
|
113
|
+
* table whose wire-name content hashes match but prefixes differ are one
|
|
114
|
+
* prefix-only rename, collapsed into a single non-destructive
|
|
115
|
+
* `RenamePostgresRlsPolicyCall`. Multi-candidate hash groups pair
|
|
116
|
+
* deterministically by sorted wire name; leftovers proceed as
|
|
117
|
+
* create/drop. Unparseable wire names never pair.
|
|
118
|
+
*
|
|
119
|
+
* The pairing runs only when the policy allows `widening` (rename's
|
|
120
|
+
* class). Without it (db-init's additive-only set), pairing degrades
|
|
121
|
+
* deliberately to the additive half: the new name is CREATEd and the old
|
|
122
|
+
* policy survives live until a widening/destructive-allowed plan runs —
|
|
123
|
+
* emitting an ungated widening rename would only fail at the runner's
|
|
124
|
+
* class re-enforcement.
|
|
125
|
+
*/
|
|
126
|
+
private planPostgresSchemaDiff;
|
|
71
127
|
private ensureAdditivePolicy;
|
|
72
|
-
private collectSchemaIssues;
|
|
73
128
|
}
|
|
74
129
|
//#endregion
|
|
75
|
-
export { createPostgresMigrationPlanner };
|
|
130
|
+
export { contractToPostgresDatabaseSchemaNode, createPostgresMigrationPlanner };
|
|
76
131
|
//# sourceMappingURL=planner.d.mts.map
|
package/dist/planner.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"planner.d.mts","names":[],"sources":["../src/core/migrations/planner.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"planner.d.mts","names":[],"sources":["../src/core/migrations/contract-to-postgres-database-schema-node.ts","../src/core/migrations/planner.ts"],"mappings":";;;;;;;;;;;;;;;;;AA6FA;;;;;;;;;;;;;iBAAgB,oCAAA,CACd,QAAA,EAAU,gBAAA,SACV,OAAA,EAAS,yBAAA,GACR,0BAAA;;;iBC/Ba,8BAAA,CACd,OAAA,EAAS,qBAAA,GACR,wBAAwB;;;;AD0B3B;;;;KCfY,kBAAA;EAAA,SAEG,IAAA;EAAA,SACA,IAAA,EAAM,qCAAA;EAAA,SACN,QAAA,YAAoB,kBAAA;AAAA,IAE/B,uBAAA;;;;;;ADYyB;;;;AC/B7B;;;;;;;;AAE2B;cAqCd,wBAAA,YAAoC,gBAAA;EAAA;cAGnC,OAAA,GAAU,qBAAA;EAItB,IAAA,CAAK,OAAA;IAAA,SACM,QAAA;IAAA,SACA,MAAA;IAAA,SACA,MAAA,EAAQ,wBAAA;IA9BM;;;;;;;;AAAA;AAoB3B;;;;;IApB2B,SA6Cd,YAAA,EAAc,QAAA;IAAA,SACd,UAAA;IAAA,SACA,mBAAA,EAAqB,aAAA,CAAc,8BAAA;IAWvB;;;;;IAAA,SALZ,OAAA;IAjCoD;;;;IAAA,SAsCpD,SAAA,GAAY,eAAA;EAAA,IACnB,kBAAA;EAIJ,cAAA,CACE,OAAA,EAAS,wBAAA,EACT,OAAA,WACC,iCAAA;EAAA,QAYK,OAAA;EAjDG;;;;;;;;;;;;;;;;;;;;;;;EAAA,QAiPH,sBAAA;EAAA,QAiHA,oBAAA;AAAA"}
|
package/dist/planner.mjs
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { r as contractToPostgresDatabaseSchemaNode } from "./diff-database-schema-oY3brcLj.mjs";
|
|
2
|
+
import { t as createPostgresMigrationPlanner } from "./planner-ootbxGty.mjs";
|
|
3
|
+
export { contractToPostgresDatabaseSchemaNode, createPostgresMigrationPlanner };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { SqlStorage } from "@prisma-next/sql-contract/types";
|
|
2
|
+
import { SqlSchemaQualifiedView } from "@prisma-next/sql-contract/contract-view";
|
|
3
|
+
import { Contract } from "@prisma-next/contract/types";
|
|
4
|
+
|
|
5
|
+
//#region src/core/postgres-contract-view.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* A schema-qualified Postgres contract view: the deserialized contract
|
|
8
|
+
* intersected with a single `namespace` member holding every schema by id. It is
|
|
9
|
+
* substitutable for `Contract` (carries `storage`, `domain`, …) and reaches each
|
|
10
|
+
* schema's entities through `view.namespace.<schema>`:
|
|
11
|
+
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* const view = PostgresContractView.fromJson<Contract>(contractJson);
|
|
14
|
+
* view.namespace.public.table.users // typed table leaf in the public schema
|
|
15
|
+
* view.namespace.auth.table.users // the auth schema's own users table
|
|
16
|
+
* view.namespace.public.entries.policy.X // pack-contributed kind (RLS / #771 path)
|
|
17
|
+
* view.namespace.__unbound__.table.X // default schema, keyed by its raw id
|
|
18
|
+
* view.storage // the full contract is still present
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* This mirrors the runtime `db.enums.<ns>` keying exactly (the default schema
|
|
22
|
+
* keeps its literal `__unbound__` id). Schema names are NOT promoted to the
|
|
23
|
+
* contract root, so there is no collision with contract envelope fields — a
|
|
24
|
+
* schema named `storage` is `view.namespace.storage`, while `view.storage`
|
|
25
|
+
* stays the contract's `storage`.
|
|
26
|
+
*/
|
|
27
|
+
type PostgresContractView<TContract extends Contract<SqlStorage> = Contract<SqlStorage>> = SqlSchemaQualifiedView<TContract>;
|
|
28
|
+
declare const PostgresContractView: {
|
|
29
|
+
/** Wrap an already-deserialized Postgres contract in a schema-qualified view. */from<TContract extends Contract<SqlStorage>>(contract: TContract): PostgresContractView<TContract>; /** Deserialize a Postgres contract JSON envelope and wrap it in a view. */
|
|
30
|
+
fromJson<TContract extends Contract<SqlStorage> = Contract<SqlStorage<string>>>(json: unknown): PostgresContractView<TContract>;
|
|
31
|
+
};
|
|
32
|
+
//#endregion
|
|
33
|
+
export { PostgresContractView as t };
|
|
34
|
+
//# sourceMappingURL=postgres-contract-view-C9j5cqP0.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-contract-view-C9j5cqP0.d.mts","names":[],"sources":["../src/core/postgres-contract-view.ts"],"mappings":";;;;;;;AA6BA;;;;;;;;;;;;;;;;;;;KAAY,oBAAA,mBAAuC,QAAA,CAAS,UAAA,IAAc,QAAA,CAAS,UAAA,KACjF,sBAAA,CAAuB,SAAA;AAAA,cAEZ,oBAAA;EAeZ,wGAbwB,QAAA,CAAS,UAAA,GAAW,QAAA,EAC/B,SAAA,GACT,oBAAA,CAAqB,SAAA,GAFQ;6BAOL,QAAA,CAAS,UAAA,IAAW,QAAA,CAAA,UAAA,WAAA,IAAA,YAE5C,oBAAA,CAAqB,SAAA;AAAA"}
|
package/dist/{postgres-contract-serializer-k3TAcPMY.mjs → postgres-contract-view-DM8sN1Ot.mjs}
RENAMED
|
@@ -1,16 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { m as PG_INT_CODEC_ID, y as PG_TEXT_CODEC_ID } from "./codec-ids-B10ZZHzw.mjs";
|
|
2
|
+
import { a as nativeEnumEntityKind, c as roleEntityKind, o as policyEntityKind, s as rlsEnablementEntityKind, t as PostgresSchema } from "./postgres-schema-Cm4DtiGA.mjs";
|
|
3
|
+
import { t as postgresAuthoringEntityTypes } from "./authoring-BtsOWgI3.mjs";
|
|
4
|
+
import { UNBOUND_NAMESPACE_ID } from "@prisma-next/framework-components/ir";
|
|
3
5
|
import { blindCast } from "@prisma-next/utils/casts";
|
|
4
|
-
import {
|
|
6
|
+
import { buildSqlSchemaQualifiedView } from "@prisma-next/sql-contract/contract-view";
|
|
5
7
|
import { SqlContractSerializerBase } from "@prisma-next/family-sql/ir";
|
|
6
8
|
import { isAuthoringEntityTypeDescriptor } from "@prisma-next/framework-components/authoring";
|
|
7
9
|
//#region src/core/postgres-contract-serializer.ts
|
|
8
10
|
const POSTGRES_AUTHORING_CTX = {
|
|
9
11
|
family: "sql",
|
|
10
|
-
target: "postgres"
|
|
12
|
+
target: "postgres",
|
|
13
|
+
enumInferenceCodecs: {
|
|
14
|
+
text: PG_TEXT_CODEC_ID,
|
|
15
|
+
int: PG_INT_CODEC_ID
|
|
16
|
+
}
|
|
11
17
|
};
|
|
12
18
|
function isAuthoringEntityTypeFactoryOutput(output) {
|
|
13
|
-
return typeof output === "object" && output !== null && typeof output.factory === "function";
|
|
19
|
+
return typeof output === "object" && output !== null && "factory" in output && typeof output.factory === "function";
|
|
14
20
|
}
|
|
15
21
|
/**
|
|
16
22
|
* Walks a pack's entity-type namespace tree and emits hydration factories
|
|
@@ -36,20 +42,22 @@ function collectStorageTypesHydrators(namespace) {
|
|
|
36
42
|
return registry;
|
|
37
43
|
}
|
|
38
44
|
var PostgresContractSerializer = class extends SqlContractSerializerBase {
|
|
39
|
-
constructor() {
|
|
45
|
+
constructor(extraPackEntityKinds = []) {
|
|
40
46
|
const storageTypesHydrators = collectStorageTypesHydrators(postgresAuthoringEntityTypes);
|
|
41
|
-
super(storageTypesHydrators
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
47
|
+
super(storageTypesHydrators, [
|
|
48
|
+
policyEntityKind,
|
|
49
|
+
roleEntityKind,
|
|
50
|
+
rlsEnablementEntityKind,
|
|
51
|
+
nativeEnumEntityKind,
|
|
52
|
+
...extraPackEntityKinds
|
|
53
|
+
]);
|
|
45
54
|
}
|
|
46
55
|
hydrateSqlNamespaceEntry(nsId, raw) {
|
|
47
|
-
if (raw instanceof NamespaceBase) return raw;
|
|
48
56
|
const { id, entries } = blindCast(super.hydrateSqlNamespaceEntry(nsId, raw));
|
|
57
|
+
const allSlotsEmpty = Object.values(entries).every((slot) => slot === void 0 || Object.keys(slot).length === 0);
|
|
58
|
+
if (id === UNBOUND_NAMESPACE_ID && allSlotsEmpty) return PostgresSchema.unbound;
|
|
49
59
|
const valueSetSlot = entries["valueSet"];
|
|
50
60
|
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
61
|
return new PostgresSchema({
|
|
54
62
|
id,
|
|
55
63
|
entries: {
|
|
@@ -62,46 +70,42 @@ var PostgresContractSerializer = class extends SqlContractSerializerBase {
|
|
|
62
70
|
serializeContract(contract) {
|
|
63
71
|
const { storage, ...rest } = contract;
|
|
64
72
|
const namespacesJson = {};
|
|
65
|
-
for (const [nsId, ns] of Object.entries(storage.namespaces))
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
73
|
+
for (const [nsId, ns] of Object.entries(storage.namespaces)) {
|
|
74
|
+
const isUnboundSlot = ns.id === UNBOUND_NAMESPACE_ID;
|
|
75
|
+
namespacesJson[nsId] = {
|
|
76
|
+
id: ns.id,
|
|
77
|
+
kind: isUnboundSlot ? "postgres-unbound-schema" : "postgres-schema",
|
|
78
|
+
entries: this.serializeNamespaceEntries(ns.entries)
|
|
79
|
+
};
|
|
80
|
+
}
|
|
71
81
|
const storageOut = {
|
|
72
82
|
storageHash: String(storage.storageHash),
|
|
73
83
|
namespaces: namespacesJson
|
|
74
84
|
};
|
|
75
85
|
if (storage.types !== void 0) {
|
|
76
86
|
const typesOut = {};
|
|
77
|
-
for (const [name, entry] of Object.entries(storage.types)) typesOut[name] = this.
|
|
87
|
+
for (const [name, entry] of Object.entries(storage.types)) typesOut[name] = this.serializeJsonObject(entry);
|
|
78
88
|
storageOut["types"] = typesOut;
|
|
79
89
|
}
|
|
80
|
-
return {
|
|
90
|
+
return blindCast({
|
|
81
91
|
...rest,
|
|
82
92
|
storage: storageOut
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
serializePostgresNamespace(ns, isUnboundSlot) {
|
|
86
|
-
const tablesOut = {};
|
|
87
|
-
for (const [tableName, table] of Object.entries(ns.table)) tablesOut[tableName] = this.serializeJsonValue(table);
|
|
88
|
-
const valueSetEntries = ns.valueSet;
|
|
89
|
-
const valueSetOut = {};
|
|
90
|
-
if (valueSetEntries !== void 0) for (const [valueSetName, valueSet] of Object.entries(valueSetEntries)) valueSetOut[valueSetName] = blindCast(this.serializeJsonValue(valueSet));
|
|
91
|
-
return {
|
|
92
|
-
id: ns.id,
|
|
93
|
-
kind: isUnboundSlot ? "postgres-unbound-schema" : "postgres-schema",
|
|
94
|
-
entries: {
|
|
95
|
-
table: tablesOut,
|
|
96
|
-
...Object.keys(valueSetOut).length > 0 ? { valueSet: valueSetOut } : {}
|
|
97
|
-
}
|
|
98
|
-
};
|
|
93
|
+
});
|
|
99
94
|
}
|
|
100
|
-
|
|
101
|
-
|
|
95
|
+
};
|
|
96
|
+
//#endregion
|
|
97
|
+
//#region src/core/postgres-contract-view.ts
|
|
98
|
+
const PostgresContractView = {
|
|
99
|
+
/** Wrap an already-deserialized Postgres contract in a schema-qualified view. */
|
|
100
|
+
from(contract) {
|
|
101
|
+
return buildSqlSchemaQualifiedView(contract);
|
|
102
|
+
},
|
|
103
|
+
/** Deserialize a Postgres contract JSON envelope and wrap it in a view. */
|
|
104
|
+
fromJson(json) {
|
|
105
|
+
return buildSqlSchemaQualifiedView(new PostgresContractSerializer().deserializeContract(json));
|
|
102
106
|
}
|
|
103
107
|
};
|
|
104
108
|
//#endregion
|
|
105
|
-
export { PostgresContractSerializer as t };
|
|
109
|
+
export { PostgresContractSerializer as n, PostgresContractView as t };
|
|
106
110
|
|
|
107
|
-
//# sourceMappingURL=postgres-contract-
|
|
111
|
+
//# sourceMappingURL=postgres-contract-view-DM8sN1Ot.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-contract-view-DM8sN1Ot.mjs","names":[],"sources":["../src/core/postgres-contract-serializer.ts","../src/core/postgres-contract-view.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 } from '@prisma-next/utils/json';\nimport { postgresAuthoringEntityTypes } from './authoring';\nimport { PG_INT_CODEC_ID, PG_TEXT_CODEC_ID } from './codec-ids';\nimport {\n nativeEnumEntityKind,\n policyEntityKind,\n rlsEnablementEntityKind,\n roleEntityKind,\n} from './entity-kinds';\nimport { PostgresSchema } from './postgres-schema';\n\nconst POSTGRES_AUTHORING_CTX: AuthoringEntityContext = {\n family: 'sql',\n target: 'postgres',\n enumInferenceCodecs: { text: PG_TEXT_CODEC_ID, int: PG_INT_CODEC_ID },\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, [\n policyEntityKind,\n roleEntityKind,\n rlsEnablementEntityKind,\n nativeEnumEntityKind,\n ...extraPackEntityKinds,\n ]);\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 // Each namespace serializes to its id, its schema-kind tag, and the\n // base's generic entries walk — every enumerable kind on\n // `PostgresSchema.entries`, including `native_enum`.\n for (const [nsId, ns] of Object.entries(storage.namespaces)) {\n const isUnboundSlot = ns.id === UNBOUND_NAMESPACE_ID;\n namespacesJson[nsId] = {\n id: ns.id,\n kind: isUnboundSlot ? 'postgres-unbound-schema' : 'postgres-schema',\n entries: this.serializeNamespaceEntries(ns.entries),\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","import type { Contract } from '@prisma-next/contract/types';\nimport {\n buildSqlSchemaQualifiedView,\n type SqlSchemaQualifiedView,\n} from '@prisma-next/sql-contract/contract-view';\nimport type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport { PostgresContractSerializer } from './postgres-contract-serializer';\n\n/**\n * A schema-qualified Postgres contract view: the deserialized contract\n * intersected with a single `namespace` member holding every schema by id. It is\n * substitutable for `Contract` (carries `storage`, `domain`, …) and reaches each\n * schema's entities through `view.namespace.<schema>`:\n *\n * ```ts\n * const view = PostgresContractView.fromJson<Contract>(contractJson);\n * view.namespace.public.table.users // typed table leaf in the public schema\n * view.namespace.auth.table.users // the auth schema's own users table\n * view.namespace.public.entries.policy.X // pack-contributed kind (RLS / #771 path)\n * view.namespace.__unbound__.table.X // default schema, keyed by its raw id\n * view.storage // the full contract is still present\n * ```\n *\n * This mirrors the runtime `db.enums.<ns>` keying exactly (the default schema\n * keeps its literal `__unbound__` id). Schema names are NOT promoted to the\n * contract root, so there is no collision with contract envelope fields — a\n * schema named `storage` is `view.namespace.storage`, while `view.storage`\n * stays the contract's `storage`.\n */\nexport type PostgresContractView<TContract extends Contract<SqlStorage> = Contract<SqlStorage>> =\n SqlSchemaQualifiedView<TContract>;\n\nexport const PostgresContractView = {\n /** Wrap an already-deserialized Postgres contract in a schema-qualified view. */\n from<TContract extends Contract<SqlStorage>>(\n contract: TContract,\n ): PostgresContractView<TContract> {\n return buildSqlSchemaQualifiedView(contract);\n },\n\n /** Deserialize a Postgres contract JSON envelope and wrap it in a view. */\n fromJson<TContract extends Contract<SqlStorage> = Contract<SqlStorage>>(\n json: unknown,\n ): PostgresContractView<TContract> {\n const contract = new PostgresContractSerializer().deserializeContract<TContract>(json);\n return buildSqlSchemaQualifiedView(contract);\n },\n};\n"],"mappings":";;;;;;;;;AA6BA,MAAM,yBAAiD;CACrD,QAAQ;CACR,QAAQ;CACR,qBAAqB;EAAE,MAAM;EAAkB,KAAK;CAAgB;AACtE;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;GAC3B;GACA;GACA;GACA;GACA,GAAG;EACL,CAAC;CACH;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,YAAY,CAAC,CAAC,SAAS;EACtF,OAAO,IAAI,eAAe;GACxB;GACA,SAAS;IACP,GAAG;IACH,OAAO,QAAQ,YAAY,CAAC;IAC5B,GAAI,eAAe,EAAE,UAAU,aAAa,IAAI,CAAC;GACnD;EACF,CAAC;CACH;CAEA,kBAA2B,UAA4C;EACrE,MAAM,EAAE,SAAS,GAAG,SAAS;EAC7B,MAAM,iBAA6C,CAAC;EAIpD,KAAK,MAAM,CAAC,MAAM,OAAO,OAAO,QAAQ,QAAQ,UAAU,GAAG;GAC3D,MAAM,gBAAgB,GAAG,OAAO;GAChC,eAAe,QAAQ;IACrB,IAAI,GAAG;IACP,MAAM,gBAAgB,4BAA4B;IAClD,SAAS,KAAK,0BAA0B,GAAG,OAAO;GACpD;EACF;EACA,MAAM,aAAsC;GAC1C,aAAa,OAAO,QAAQ,WAAW;GACvC,YAAY;EACd;EACA,IAAI,QAAQ,UAAU,KAAA,GAAW;GAC/B,MAAM,WAAuC,CAAC;GAC9C,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,QAAQ,KAAK,GACtD,SAAS,QAAQ,KAAK,oBAAoB,KAAK;GAEjD,WAAW,WAAW;EACxB;EACA,OAAO,UAGL;GACA,GAAG;GACH,SAAS;EACX,CAAC;CACH;AACF;;;ACnHA,MAAa,uBAAuB;;CAElC,KACE,UACiC;EACjC,OAAO,4BAA4B,QAAQ;CAC7C;;CAGA,SACE,MACiC;EAEjC,OAAO,4BADU,IAAI,2BAA2B,CAAC,CAAC,oBAA+B,IACvC,CAAC;CAC7C;AACF"}
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import { r as RlsPolicyOperation } from "./postgres-rls-policy--CSddvMR.mjs";
|
|
2
|
+
import { PrimaryKey, SqlAnnotations, SqlCheckConstraintIR, SqlColumnIR, SqlForeignKeyIR, SqlIndexIR, SqlSchemaIRNode, SqlTableIRInput, SqlUniqueIR } from "@prisma-next/sql-schema-ir/types";
|
|
3
|
+
import { DiffableNode, SchemaNodeRef } from "@prisma-next/framework-components/control";
|
|
4
|
+
import { ControlPolicy } from "@prisma-next/contract/types";
|
|
5
|
+
|
|
6
|
+
//#region src/core/schema-ir/postgres-native-enum-schema-node.d.ts
|
|
7
|
+
interface PostgresNativeEnumSchemaNodeInput {
|
|
8
|
+
/** The Postgres type name (`CREATE TYPE <typeName> AS ENUM (…)`). */
|
|
9
|
+
readonly typeName: string;
|
|
10
|
+
/** The owning DDL schema name — enum types are schema-scoped. */
|
|
11
|
+
readonly namespaceId: string;
|
|
12
|
+
/** Member values in declaration (`pg_enum.enumsortorder`) order. */
|
|
13
|
+
readonly members: readonly string[];
|
|
14
|
+
/** The contract entity's control grade — expected-side nodes only. */
|
|
15
|
+
readonly control?: ControlPolicy;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Schema-diff leaf node for a native Postgres enum type.
|
|
19
|
+
*
|
|
20
|
+
* This is a derived, transient node walked by the differ — it is NEVER
|
|
21
|
+
* serialized. Both sides derive it on the namespace node: the expected side
|
|
22
|
+
* from the contract's hydrated `entries.native_enum` entities, the actual
|
|
23
|
+
* side from the adapter's introspected `nativeEnums`.
|
|
24
|
+
*
|
|
25
|
+
* Enum types are schema-scoped, so identity is (namespace, type name): the
|
|
26
|
+
* namespace coordinate comes from tree position (the differ pairs enum nodes
|
|
27
|
+
* only inside an already-paired namespace) and `id` carries the type name,
|
|
28
|
+
* prefixed with the entries-kind vocabulary (`native_enum:<typeName>`) so it
|
|
29
|
+
* cannot collide with a sibling table of the same name — the same
|
|
30
|
+
* sibling-prefix convention relational column nodes use (`column:<name>`).
|
|
31
|
+
*
|
|
32
|
+
* `isEqualTo` compares members POSITIONALLY — `['a','b'] ≠ ['b','a']` —
|
|
33
|
+
* because Postgres enum sort order is semantic. `control` is contract
|
|
34
|
+
* metadata, not database state, and does not participate in equality.
|
|
35
|
+
*/
|
|
36
|
+
declare class PostgresNativeEnumSchemaNode extends SqlSchemaIRNode implements DiffableNode {
|
|
37
|
+
readonly nodeKind: "postgres-native-enum";
|
|
38
|
+
readonly typeName: string;
|
|
39
|
+
readonly namespaceId: string;
|
|
40
|
+
readonly members: readonly string[];
|
|
41
|
+
readonly control?: ControlPolicy;
|
|
42
|
+
constructor(input: PostgresNativeEnumSchemaNodeInput);
|
|
43
|
+
get id(): string;
|
|
44
|
+
children(): readonly DiffableNode[];
|
|
45
|
+
isEqualTo(other: DiffableNode): boolean;
|
|
46
|
+
static is(node: SqlSchemaIRNode): node is PostgresNativeEnumSchemaNode;
|
|
47
|
+
static assert(node: SqlSchemaIRNode): asserts node is PostgresNativeEnumSchemaNode;
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
//#region src/core/schema-ir/postgres-policy-schema-node.d.ts
|
|
51
|
+
interface PostgresPolicySchemaNodeInput {
|
|
52
|
+
/** Full wire name: `<prefix>_<8hex>`. */
|
|
53
|
+
readonly name: string;
|
|
54
|
+
/** User-supplied prefix (the part before the `_<8hex>` suffix). */
|
|
55
|
+
readonly prefix: string;
|
|
56
|
+
/** Name of the table this policy attaches to, by name within the same schema. */
|
|
57
|
+
readonly tableName: string;
|
|
58
|
+
/** Namespace coordinate (schema name). */
|
|
59
|
+
readonly namespaceId: string;
|
|
60
|
+
readonly operation: RlsPolicyOperation;
|
|
61
|
+
/** Sorted role names rendered in `TO <roles>`. */
|
|
62
|
+
readonly roles: readonly string[];
|
|
63
|
+
/** USING predicate SQL string, if present. */
|
|
64
|
+
readonly using?: string;
|
|
65
|
+
/** WITH CHECK predicate SQL string, if present. */
|
|
66
|
+
readonly withCheck?: string;
|
|
67
|
+
/** `true` = `AS PERMISSIVE`, `false` = `AS RESTRICTIVE`. */
|
|
68
|
+
readonly permissive: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* This policy's table node, plus one entry per role it grants to — each
|
|
71
|
+
* as the root-anchored chain the differ pairs siblings with. Stamped by
|
|
72
|
+
* the derivation, which holds the parent (database/namespace) context.
|
|
73
|
+
* Never compared by `isEqualTo`.
|
|
74
|
+
*/
|
|
75
|
+
readonly dependsOn?: readonly SchemaNodeRef[];
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Schema-diff leaf node for a Postgres row-level security policy.
|
|
79
|
+
*
|
|
80
|
+
* This is a derived, transient node walked by the differ — it is NEVER serialized.
|
|
81
|
+
* Built by project-from-contract and project-from-database from their respective
|
|
82
|
+
* `PostgresRlsPolicy` contract entities / introspected rows.
|
|
83
|
+
*
|
|
84
|
+
* `id` is the wire name (`<prefix>_<sha256(body)[0..8]>`), so name-equality is
|
|
85
|
+
* body-equality. `isEqualTo` compares names only — never byte-compare predicate
|
|
86
|
+
* bodies, because Postgres reprints them.
|
|
87
|
+
*/
|
|
88
|
+
declare class PostgresPolicySchemaNode extends SqlSchemaIRNode implements DiffableNode {
|
|
89
|
+
readonly nodeKind: "postgres-policy";
|
|
90
|
+
readonly name: string;
|
|
91
|
+
readonly prefix: string;
|
|
92
|
+
readonly tableName: string;
|
|
93
|
+
readonly namespaceId: string;
|
|
94
|
+
readonly operation: RlsPolicyOperation;
|
|
95
|
+
readonly roles: readonly string[];
|
|
96
|
+
readonly using?: string;
|
|
97
|
+
readonly withCheck?: string;
|
|
98
|
+
readonly permissive: boolean;
|
|
99
|
+
/** See {@link PostgresPolicySchemaNodeInput.dependsOn}. Non-enumerable so it stays out of JSON and structural equality, matching `SqlColumnIR.codecRef`. */
|
|
100
|
+
readonly dependsOn?: readonly SchemaNodeRef[];
|
|
101
|
+
constructor(input: PostgresPolicySchemaNodeInput);
|
|
102
|
+
get id(): string;
|
|
103
|
+
children(): readonly DiffableNode[];
|
|
104
|
+
isEqualTo(other: DiffableNode): boolean;
|
|
105
|
+
static is(node: SqlSchemaIRNode): node is PostgresPolicySchemaNode;
|
|
106
|
+
static assert(node: SqlSchemaIRNode | undefined): asserts node is PostgresPolicySchemaNode;
|
|
107
|
+
}
|
|
108
|
+
//#endregion
|
|
109
|
+
//#region src/core/schema-ir/postgres-table-schema-node.d.ts
|
|
110
|
+
interface PostgresTableSchemaNodeInput extends SqlTableIRInput {
|
|
111
|
+
readonly policies?: readonly PostgresPolicySchemaNode[];
|
|
112
|
+
/**
|
|
113
|
+
* Whether row-level security is enabled on this table. Expected side:
|
|
114
|
+
* stamped from the contract's `entries.rls` marker (never from the
|
|
115
|
+
* policy set). Actual side: stamped from `pg_class.relrowsecurity` at
|
|
116
|
+
* introspection. Required with no default so every construction site
|
|
117
|
+
* supplies a deliberate value.
|
|
118
|
+
*/
|
|
119
|
+
readonly rlsEnabled: boolean;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Postgres-specific table schema-diff node. Carries all `SqlTableIR` fields
|
|
123
|
+
* plus `policies`, and implements `DiffableNode` so the table instance is
|
|
124
|
+
* directly the diff-tree node — no separate wrapper needed.
|
|
125
|
+
*
|
|
126
|
+
* Extends `SqlSchemaIRNode` directly rather than `SqlTableIR` because
|
|
127
|
+
* `SqlTableIR` calls `freezeNode` in its own constructor, which prevents
|
|
128
|
+
* subclass field initialisation.
|
|
129
|
+
*
|
|
130
|
+
* `id` is the table name. `isEqualTo` compares id + `rlsEnabled` — the
|
|
131
|
+
* table's one own diffable attribute; all other structural drift is
|
|
132
|
+
* expressed by its children. `children()` returns every column, the primary
|
|
133
|
+
* key (when present), every foreign key, unique, index, and check constraint,
|
|
134
|
+
* plus the policy nodes — one flat list, so a drifted column and a drifted
|
|
135
|
+
* policy are both reported by the same walk. Order is deterministic (object
|
|
136
|
+
* key order for columns, array order for the rest) so two structurally equal
|
|
137
|
+
* tables always produce the same child list.
|
|
138
|
+
*/
|
|
139
|
+
declare class PostgresTableSchemaNode extends SqlSchemaIRNode implements DiffableNode {
|
|
140
|
+
readonly nodeKind: "postgres-table";
|
|
141
|
+
readonly name: string;
|
|
142
|
+
readonly columns: Readonly<Record<string, SqlColumnIR>>;
|
|
143
|
+
readonly foreignKeys: ReadonlyArray<SqlForeignKeyIR>;
|
|
144
|
+
readonly uniques: ReadonlyArray<SqlUniqueIR>;
|
|
145
|
+
readonly indexes: ReadonlyArray<SqlIndexIR>;
|
|
146
|
+
readonly primaryKey?: PrimaryKey;
|
|
147
|
+
readonly annotations?: SqlAnnotations;
|
|
148
|
+
readonly checks?: ReadonlyArray<SqlCheckConstraintIR>;
|
|
149
|
+
readonly policies: readonly PostgresPolicySchemaNode[];
|
|
150
|
+
readonly rlsEnabled: boolean;
|
|
151
|
+
constructor(input: PostgresTableSchemaNodeInput);
|
|
152
|
+
get id(): string;
|
|
153
|
+
/**
|
|
154
|
+
* Equal iff the ids (names) match AND `rlsEnabled` matches — the table's
|
|
155
|
+
* one own attribute in the diff; all other structural drift is expressed
|
|
156
|
+
* by children. A paired `not-equal` therefore always means enablement
|
|
157
|
+
* drift, which the planner maps to ENABLE/DISABLE ROW LEVEL SECURITY.
|
|
158
|
+
*/
|
|
159
|
+
isEqualTo(other: DiffableNode): boolean;
|
|
160
|
+
children(): readonly DiffableNode[];
|
|
161
|
+
static is(node: SqlSchemaIRNode): node is PostgresTableSchemaNode;
|
|
162
|
+
static assert(node: SqlSchemaIRNode): asserts node is PostgresTableSchemaNode;
|
|
163
|
+
}
|
|
164
|
+
//#endregion
|
|
165
|
+
//#region src/core/schema-ir/postgres-namespace-schema-node.d.ts
|
|
166
|
+
interface PostgresNamespaceSchemaNodeInput {
|
|
167
|
+
readonly schemaName: string;
|
|
168
|
+
readonly tables: Readonly<Record<string, PostgresTableSchemaNode>>;
|
|
169
|
+
/**
|
|
170
|
+
* The native-enum diff nodes belonging to this namespace, member values in
|
|
171
|
+
* `pg_enum.enumsortorder` (declaration) order. The expected
|
|
172
|
+
* (contract-projected) side attaches each node's `control` (the contract
|
|
173
|
+
* entity's grade); introspection builds nodes with no `control`.
|
|
174
|
+
*/
|
|
175
|
+
readonly nativeEnums?: readonly PostgresNativeEnumSchemaNode[];
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* One-per-Postgres-schema diff-tree node. Groups the tables belonging to a
|
|
179
|
+
* single namespace. Per-schema consumers (the relational planner,
|
|
180
|
+
* toSchemaView) read this node's `tables` field structurally via
|
|
181
|
+
* `blindCast`/`SqlSchemaIRNode` — not through a static `SqlSchemaIR`
|
|
182
|
+
* assignment — because `nodeKind` carries this node's own literal
|
|
183
|
+
* (`postgres-namespace`), distinct from `SqlSchemaIR`'s own (`sql-schema`).
|
|
184
|
+
*
|
|
185
|
+
* `id` is the schema name; `isEqualTo` is identity on it; `children()` returns
|
|
186
|
+
* the table nodes plus `nativeEnums`.
|
|
187
|
+
*
|
|
188
|
+
* `nativeEnums` is the diff-tree representation of native enum types the
|
|
189
|
+
* differ pairs — the sole enum carrier, built directly by both sides: the
|
|
190
|
+
* expected (contract-projected) side and introspection alike hand in
|
|
191
|
+
* `PostgresNativeEnumSchemaNode`s.
|
|
192
|
+
*/
|
|
193
|
+
declare class PostgresNamespaceSchemaNode extends SqlSchemaIRNode implements DiffableNode {
|
|
194
|
+
readonly nodeKind: "postgres-namespace";
|
|
195
|
+
readonly schemaName: string;
|
|
196
|
+
readonly tables: Readonly<Record<string, PostgresTableSchemaNode>>;
|
|
197
|
+
readonly nativeEnums: readonly PostgresNativeEnumSchemaNode[];
|
|
198
|
+
constructor(input: PostgresNamespaceSchemaNodeInput);
|
|
199
|
+
get id(): string;
|
|
200
|
+
isEqualTo(other: DiffableNode): boolean;
|
|
201
|
+
children(): readonly DiffableNode[];
|
|
202
|
+
static is(node: SqlSchemaIRNode): node is PostgresNamespaceSchemaNode;
|
|
203
|
+
static assert(node: SqlSchemaIRNode): asserts node is PostgresNamespaceSchemaNode;
|
|
204
|
+
}
|
|
205
|
+
//#endregion
|
|
206
|
+
//#region src/core/schema-ir/postgres-role-schema-node.d.ts
|
|
207
|
+
interface PostgresRoleSchemaNodeInput {
|
|
208
|
+
readonly name: string;
|
|
209
|
+
/**
|
|
210
|
+
* Namespace coordinate. Roles are cluster-scoped; callers pass
|
|
211
|
+
* `UNBOUND_NAMESPACE_ID` from `@prisma-next/framework-components/ir`.
|
|
212
|
+
*/
|
|
213
|
+
readonly namespaceId: string;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Schema-diff leaf node for a Postgres database role.
|
|
217
|
+
*
|
|
218
|
+
* This is a derived, transient node walked by the differ — it is NEVER serialized.
|
|
219
|
+
* Built by project-from-contract and project-from-database from their respective
|
|
220
|
+
* `PostgresRole` contract entities / introspected rows.
|
|
221
|
+
*
|
|
222
|
+
* Roles are cluster-scoped, so `id` is the bare role name. The differ pairs
|
|
223
|
+
* siblings by `(nodeKind, id)`, so a role and a namespace may share a name
|
|
224
|
+
* (role `public`, schema `public`) without colliding. `isEqualTo` compares
|
|
225
|
+
* ids — name-equality is role-equality for cluster-scoped objects.
|
|
226
|
+
*/
|
|
227
|
+
declare class PostgresRoleSchemaNode extends SqlSchemaIRNode implements DiffableNode {
|
|
228
|
+
readonly nodeKind: "postgres-role";
|
|
229
|
+
readonly name: string;
|
|
230
|
+
readonly namespaceId: string;
|
|
231
|
+
constructor(input: PostgresRoleSchemaNodeInput);
|
|
232
|
+
get id(): string;
|
|
233
|
+
children(): readonly DiffableNode[];
|
|
234
|
+
isEqualTo(other: DiffableNode): boolean;
|
|
235
|
+
static is(node: SqlSchemaIRNode): node is PostgresRoleSchemaNode;
|
|
236
|
+
static assert(node: SqlSchemaIRNode): asserts node is PostgresRoleSchemaNode;
|
|
237
|
+
}
|
|
238
|
+
//#endregion
|
|
239
|
+
//#region src/core/schema-ir/postgres-database-schema-node.d.ts
|
|
240
|
+
interface PostgresDatabaseSchemaNodeInput {
|
|
241
|
+
readonly namespaces: Readonly<Record<string, PostgresNamespaceSchemaNode>>;
|
|
242
|
+
readonly roles: readonly PostgresRoleSchemaNode[];
|
|
243
|
+
readonly existingSchemas: readonly string[];
|
|
244
|
+
readonly pgVersion: string;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* The root of the Postgres schema-diff tree: one node per database.
|
|
248
|
+
*
|
|
249
|
+
* `id` is the fixed sentinel `'database'` — the root has no siblings and
|
|
250
|
+
* the value is never emitted into migration paths. `isEqualTo` is identity
|
|
251
|
+
* (roots always share the `'database'` id). `children()` yields the namespace
|
|
252
|
+
* nodes followed by the role nodes — both are root-level diff subjects. The
|
|
253
|
+
* differ pairs siblings by `(nodeKind, id)`, so a role and a namespace may
|
|
254
|
+
* share a name without colliding.
|
|
255
|
+
*/
|
|
256
|
+
declare class PostgresDatabaseSchemaNode extends SqlSchemaIRNode implements DiffableNode {
|
|
257
|
+
readonly nodeKind: "postgres-database";
|
|
258
|
+
readonly namespaces: Readonly<Record<string, PostgresNamespaceSchemaNode>>;
|
|
259
|
+
readonly roles: readonly PostgresRoleSchemaNode[];
|
|
260
|
+
readonly existingSchemas: readonly string[];
|
|
261
|
+
readonly pgVersion: string;
|
|
262
|
+
constructor(input: PostgresDatabaseSchemaNodeInput);
|
|
263
|
+
get id(): string;
|
|
264
|
+
isEqualTo(other: DiffableNode): boolean;
|
|
265
|
+
children(): readonly DiffableNode[];
|
|
266
|
+
static is(node: SqlSchemaIRNode): node is PostgresDatabaseSchemaNode;
|
|
267
|
+
static assert(node: SqlSchemaIRNode): asserts node is PostgresDatabaseSchemaNode;
|
|
268
|
+
}
|
|
269
|
+
//#endregion
|
|
270
|
+
export { PostgresNamespaceSchemaNode as a, PostgresTableSchemaNodeInput as c, PostgresNativeEnumSchemaNode as d, PostgresNativeEnumSchemaNodeInput as f, PostgresRoleSchemaNodeInput as i, PostgresPolicySchemaNode as l, PostgresDatabaseSchemaNodeInput as n, PostgresNamespaceSchemaNodeInput as o, PostgresRoleSchemaNode as r, PostgresTableSchemaNode as s, PostgresDatabaseSchemaNode as t, PostgresPolicySchemaNodeInput as u };
|
|
271
|
+
//# sourceMappingURL=postgres-database-schema-node-DJOTywwQ.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-database-schema-node-DJOTywwQ.d.mts","names":[],"sources":["../src/core/schema-ir/postgres-native-enum-schema-node.ts","../src/core/schema-ir/postgres-policy-schema-node.ts","../src/core/schema-ir/postgres-table-schema-node.ts","../src/core/schema-ir/postgres-namespace-schema-node.ts","../src/core/schema-ir/postgres-role-schema-node.ts","../src/core/schema-ir/postgres-database-schema-node.ts"],"mappings":"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"}
|