@prisma-next/target-postgres 0.14.0-dev.8 → 0.14.0-dev.80
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-Bi9aa8zG.mjs +574 -0
- package/dist/authoring-Bi9aa8zG.mjs.map +1 -0
- package/dist/canonicalize-CAbXtVtB.d.mts +37 -0
- package/dist/canonicalize-CAbXtVtB.d.mts.map +1 -0
- package/dist/{codec-ids-CnXu9Qy3.d.mts → codec-ids-BzrFF-I4.d.mts} +3 -2
- package/dist/codec-ids-BzrFF-I4.d.mts.map +1 -0
- package/dist/{codec-ids-BvytN2P8.mjs → codec-ids-C_-Hj6bL.mjs} +3 -2
- package/dist/codec-ids-C_-Hj6bL.mjs.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-BiIWziRO.d.mts} +3 -2
- package/dist/codec-types-BiIWziRO.d.mts.map +1 -0
- package/dist/codec-types.d.mts +1 -1
- package/dist/codecs-BemGS69L.mjs +927 -0
- package/dist/codecs-BemGS69L.mjs.map +1 -0
- package/dist/{codecs--0A5_4Bq.d.mts → codecs-Cm-nS4mQ.d.mts} +111 -4
- package/dist/codecs-Cm-nS4mQ.d.mts.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-5LE2kwfb.mjs +1285 -0
- package/dist/control-policy-5LE2kwfb.mjs.map +1 -0
- package/dist/control.d.mts +2 -2
- package/dist/control.d.mts.map +1 -1
- package/dist/control.mjs +866 -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-BQzITB_e.mjs} +128 -6
- package/dist/ddl-BQzITB_e.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-DzL6vXAz.mjs +22 -0
- package/dist/descriptor-meta-DzL6vXAz.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-DULhiCNM.mjs +305 -0
- package/dist/diff-database-schema-DULhiCNM.mjs.map +1 -0
- package/dist/diff-database-schema.d.mts +46 -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-Bc2N3tMy.d.mts +170 -0
- package/dist/nodes-Bc2N3tMy.d.mts.map +1 -0
- package/dist/nodes-DJC5B8Id.mjs +192 -0
- package/dist/nodes-DJC5B8Id.mjs.map +1 -0
- package/dist/{op-factory-call-DmQEc3XV.d.mts → op-factory-call-Bn9zDx4_.d.mts} +114 -15
- package/dist/op-factory-call-Bn9zDx4_.d.mts.map +1 -0
- package/dist/{op-factory-call-D_p5vxwt.mjs → op-factory-call-D6yu-PlS.mjs} +469 -32
- package/dist/op-factory-call-D6yu-PlS.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 +300 -3
- package/dist/pack.d.mts.map +1 -1
- package/dist/pack.mjs +1 -1
- package/dist/planner-DwDxdYxi.mjs +390 -0
- package/dist/planner-DwDxdYxi.mjs.map +1 -0
- 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-produced-postgres-migration-QqHa2C2l.d.mts → planner-produced-postgres-migration-BEY1T0Xm.d.mts} +4 -4
- package/dist/{planner-produced-postgres-migration-QqHa2C2l.d.mts.map → planner-produced-postgres-migration-BEY1T0Xm.d.mts.map} +1 -1
- package/dist/{planner-produced-postgres-migration-Cji5vxUf.mjs → planner-produced-postgres-migration-BGPpq56_.mjs} +3 -3
- package/dist/{planner-produced-postgres-migration-Cji5vxUf.mjs.map → planner-produced-postgres-migration-BGPpq56_.mjs.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-CDXn2uaS.mjs} +5 -5
- package/dist/{planner-sql-checks-jqUUGyQR.mjs.map → planner-sql-checks-CDXn2uaS.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-serializer-k3TAcPMY.mjs → postgres-contract-view-C3LPCLP_.mjs} +45 -41
- package/dist/postgres-contract-view-C3LPCLP_.mjs.map +1 -0
- package/dist/postgres-contract-view-C9j5cqP0.d.mts +34 -0
- package/dist/postgres-contract-view-C9j5cqP0.d.mts.map +1 -0
- package/dist/postgres-database-schema-node-CJv5bfbs.d.mts +262 -0
- package/dist/postgres-database-schema-node-CJv5bfbs.d.mts.map +1 -0
- package/dist/{postgres-migration-Y4YBJqkS.d.mts → postgres-migration-DbckK1su.d.mts} +58 -9
- package/dist/postgres-migration-DbckK1su.d.mts.map +1 -0
- package/dist/{postgres-migration-B5jKrXv3.mjs → postgres-migration-et1td40f.mjs} +78 -45
- package/dist/postgres-migration-et1td40f.mjs.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-Cm-j0ZGM.mjs +190 -0
- package/dist/postgres-role-schema-node-Cm-j0ZGM.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-schema-COGZ1ark.mjs → postgres-schema-DYATroNx.mjs} +200 -11
- package/dist/postgres-schema-DYATroNx.mjs.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-DpGte50u.mjs +22 -0
- package/dist/resolve-ddl-schema-DpGte50u.mjs.map +1 -0
- package/dist/rls-canonicalize.d.mts +20 -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/{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 +4 -140
- package/dist/types.mjs +5 -2
- package/dist/wire-name-rHHtr1h0.mjs +75 -0
- package/dist/wire-name-rHHtr1h0.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 +509 -2
- package/src/core/codec-helpers.ts +33 -7
- package/src/core/codec-ids.ts +1 -0
- package/src/core/codec-type-map.ts +2 -0
- package/src/core/codecs.ts +193 -12
- package/src/core/ddl/nodes.ts +185 -2
- package/src/core/default-normalizer.ts +122 -2
- package/src/core/descriptor-meta.ts +10 -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 +189 -0
- package/src/core/migrations/control-policy.ts +217 -65
- package/src/core/migrations/diff-database-schema.ts +252 -0
- package/src/core/migrations/issue-planner.ts +817 -656
- package/src/core/migrations/op-factory-call.ts +383 -23
- 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 +248 -216
- package/src/core/migrations/planner-target-details.ts +3 -1
- package/src/core/migrations/planner.ts +357 -67
- package/src/core/migrations/postgres-migration.ts +118 -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 +46 -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 +1273 -0
- package/src/core/psl-infer/postgres-default-mapping.ts +16 -0
- package/src/core/psl-infer/postgres-type-map.ts +128 -0
- package/src/core/rls/canonicalize.ts +48 -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 +90 -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 +3 -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 +4 -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 +7 -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 +37 -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.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-identity-values-CJPha2Sz.mjs","names":[],"sources":["../src/core/migrations/planner-identity-values.ts"],"sourcesContent":["import type { CodecControlHooks } from '@prisma-next/family-sql/control';\nimport type { StorageColumn, StorageTypeInstance } from '@prisma-next/sql-contract/types';\nimport { ifDefined } from '@prisma-next/utils/defined';\n\n/**\n * Resolves the identity value (monoid neutral element) as a SQL literal for a column's type.\n * Checks codec hooks first (extensions can provide type-specific identity values),\n * then falls back to the built-in map.\n */\nexport function resolveIdentityValue(\n column: StorageColumn,\n codecHooks:
|
|
1
|
+
{"version":3,"file":"planner-identity-values-CJPha2Sz.mjs","names":[],"sources":["../src/core/migrations/planner-identity-values.ts"],"sourcesContent":["import type { CodecControlHooks } from '@prisma-next/family-sql/control';\nimport type { StorageColumn, StorageTypeInstance } from '@prisma-next/sql-contract/types';\nimport { ifDefined } from '@prisma-next/utils/defined';\n\n/**\n * Resolves the identity value (monoid neutral element) as a SQL literal for a column's type.\n * Checks codec hooks first (extensions can provide type-specific identity values),\n * then falls back to the built-in map.\n */\nexport function resolveIdentityValue(\n column: StorageColumn,\n codecHooks: ReadonlyMap<string, CodecControlHooks>,\n storageTypes: Record<string, StorageTypeInstance> = {},\n): string | null {\n const referencedType = column.typeRef ? storageTypes[column.typeRef] : undefined;\n const codecId = referencedType?.codecId ?? column.codecId;\n const nativeType = referencedType?.nativeType ?? column.nativeType;\n const typeParams = referencedType?.typeParams ?? column.typeParams;\n\n if (codecId) {\n const hookDefault = codecHooks.get(codecId)?.resolveIdentityValue?.({\n nativeType,\n codecId,\n ...ifDefined('typeParams', typeParams),\n });\n if (hookDefault !== undefined) {\n return hookDefault;\n }\n }\n\n return buildBuiltinIdentityValue(nativeType, typeParams);\n}\n\n/**\n * Returns the built-in identity value (monoid neutral element) as a SQL literal for the given\n * PostgreSQL native type — e.g. 0 for integers, '' for text, false for booleans.\n *\n * This is the planner's fallback when no codec hook provides a type-specific identity value.\n *\n * Returns null for unrecognized types (for example enums and extension-owned types without a\n * hook), which causes the planner to fall back to the empty-table precheck.\n *\n * @internal Exported for testing only.\n */\nexport function buildBuiltinIdentityValue(\n nativeType: string,\n typeParams?: Record<string, unknown>,\n): string | null {\n const normalizedNativeType = normalizeIdentityValueNativeType(nativeType);\n\n if (normalizedNativeType.endsWith('[]')) {\n return \"'{}'\";\n }\n\n switch (normalizedNativeType) {\n case 'text':\n case 'character':\n case 'bpchar':\n case 'character varying':\n case 'varchar':\n return \"''\";\n\n case 'int2':\n case 'int4':\n case 'int8':\n case 'integer':\n case 'bigint':\n case 'smallint':\n case 'float4':\n case 'float8':\n case 'real':\n case 'double precision':\n case 'numeric':\n case 'decimal':\n return '0';\n\n case 'bool':\n case 'boolean':\n return 'false';\n\n case 'uuid':\n return \"'00000000-0000-0000-0000-000000000000'\";\n\n case 'json':\n return \"'{}'::json\";\n case 'jsonb':\n return \"'{}'::jsonb\";\n\n case 'date':\n case 'timestamp':\n case 'timestamptz':\n case 'timestamp with time zone':\n case 'timestamp without time zone':\n return \"'epoch'\";\n\n case 'time':\n case 'time without time zone':\n return \"'00:00:00'\";\n case 'timetz':\n case 'time with time zone':\n return \"'00:00:00+00'\";\n\n case 'interval':\n return \"'0'\";\n\n case 'bytea':\n return \"''::bytea\";\n case 'tsvector':\n return \"''::tsvector\";\n\n case 'bit':\n return buildBitIdentityValue(typeParams);\n case 'bit varying':\n case 'varbit':\n return \"B''\";\n\n default:\n return null;\n }\n}\n\nfunction normalizeIdentityValueNativeType(nativeType: string): string {\n return nativeType.trim().toLowerCase().replace(/\\s+/g, ' ');\n}\n\nfunction buildBitIdentityValue(typeParams?: Record<string, unknown>): string | null {\n const length = typeParams?.['length'];\n if (length === undefined) {\n return \"B'0'\";\n }\n if (typeof length !== 'number' || !Number.isInteger(length) || length <= 0) {\n return null;\n }\n return `B'${'0'.repeat(length)}'`;\n}\n"],"mappings":";;;;;;;AASA,SAAgB,qBACd,QACA,YACA,eAAoD,CAAC,GACtC;CACf,MAAM,iBAAiB,OAAO,UAAU,aAAa,OAAO,WAAW,KAAA;CACvE,MAAM,UAAU,gBAAgB,WAAW,OAAO;CAClD,MAAM,aAAa,gBAAgB,cAAc,OAAO;CACxD,MAAM,aAAa,gBAAgB,cAAc,OAAO;CAExD,IAAI,SAAS;EACX,MAAM,cAAc,WAAW,IAAI,OAAO,CAAC,EAAE,uBAAuB;GAClE;GACA;GACA,GAAG,UAAU,cAAc,UAAU;EACvC,CAAC;EACD,IAAI,gBAAgB,KAAA,GAClB,OAAO;CAEX;CAEA,OAAO,0BAA0B,YAAY,UAAU;AACzD;;;;;;;;;;;;AAaA,SAAgB,0BACd,YACA,YACe;CACf,MAAM,uBAAuB,iCAAiC,UAAU;CAExE,IAAI,qBAAqB,SAAS,IAAI,GACpC,OAAO;CAGT,QAAQ,sBAAR;EACE,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,WACH,OAAO;EAET,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,WACH,OAAO;EAET,KAAK;EACL,KAAK,WACH,OAAO;EAET,KAAK,QACH,OAAO;EAET,KAAK,QACH,OAAO;EACT,KAAK,SACH,OAAO;EAET,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,+BACH,OAAO;EAET,KAAK;EACL,KAAK,0BACH,OAAO;EACT,KAAK;EACL,KAAK,uBACH,OAAO;EAET,KAAK,YACH,OAAO;EAET,KAAK,SACH,OAAO;EACT,KAAK,YACH,OAAO;EAET,KAAK,OACH,OAAO,sBAAsB,UAAU;EACzC,KAAK;EACL,KAAK,UACH,OAAO;EAET,SACE,OAAO;CACX;AACF;AAEA,SAAS,iCAAiC,YAA4B;CACpE,OAAO,WAAW,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC,QAAQ,QAAQ,GAAG;AAC5D;AAEA,SAAS,sBAAsB,YAAqD;CAClF,MAAM,SAAS,aAAa;CAC5B,IAAI,WAAW,KAAA,GACb,OAAO;CAET,IAAI,OAAO,WAAW,YAAY,CAAC,OAAO,UAAU,MAAM,KAAK,UAAU,GACvE,OAAO;CAET,OAAO,KAAK,IAAI,OAAO,MAAM,EAAE;AACjC"}
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
import { CodecControlHooks } from "@prisma-next/family-sql/control";
|
|
2
1
|
import { StorageColumn, StorageTypeInstance } from "@prisma-next/sql-contract/types";
|
|
2
|
+
import { CodecControlHooks } from "@prisma-next/family-sql/control";
|
|
3
3
|
|
|
4
4
|
//#region src/core/migrations/planner-identity-values.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Resolves the identity value (monoid neutral element) as a SQL literal for a column's type.
|
|
7
|
+
* Checks codec hooks first (extensions can provide type-specific identity values),
|
|
8
|
+
* then falls back to the built-in map.
|
|
9
|
+
*/
|
|
10
|
+
declare function resolveIdentityValue(column: StorageColumn, codecHooks: ReadonlyMap<string, CodecControlHooks>, storageTypes?: Record<string, StorageTypeInstance>): string | null;
|
|
5
11
|
/**
|
|
6
12
|
* Returns the built-in identity value (monoid neutral element) as a SQL literal for the given
|
|
7
13
|
* PostgreSQL native type — e.g. 0 for integers, '' for text, false for booleans.
|
|
@@ -15,5 +21,5 @@ import { StorageColumn, StorageTypeInstance } from "@prisma-next/sql-contract/ty
|
|
|
15
21
|
*/
|
|
16
22
|
declare function buildBuiltinIdentityValue(nativeType: string, typeParams?: Record<string, unknown>): string | null;
|
|
17
23
|
//#endregion
|
|
18
|
-
export { buildBuiltinIdentityValue };
|
|
24
|
+
export { buildBuiltinIdentityValue, resolveIdentityValue };
|
|
19
25
|
//# sourceMappingURL=planner-identity-values.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"planner-identity-values.d.mts","names":[],"sources":["../src/core/migrations/planner-identity-values.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"planner-identity-values.d.mts","names":[],"sources":["../src/core/migrations/planner-identity-values.ts"],"mappings":";;;;;;AASA;;;iBAAgB,oBAAA,CACd,MAAA,EAAQ,aAAA,EACR,UAAA,EAAY,WAAA,SAAoB,iBAAA,GAChC,YAAA,GAAc,MAAA,SAAe,mBAAA;;;;;;;;;;;;iBAgCf,yBAAA,CACd,UAAA,UACA,UAAA,GAAa,MAAM"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as buildBuiltinIdentityValue } from "./planner-identity-values-CJPha2Sz.mjs";
|
|
2
|
-
export { buildBuiltinIdentityValue };
|
|
1
|
+
import { n as resolveIdentityValue, t as buildBuiltinIdentityValue } from "./planner-identity-values-CJPha2Sz.mjs";
|
|
2
|
+
export { buildBuiltinIdentityValue, resolveIdentityValue };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { t as PostgresPlanTargetDetails } from "./planner-target-details-
|
|
2
|
-
import { t as PostgresMigration } from "./postgres-migration-
|
|
1
|
+
import { t as PostgresPlanTargetDetails } from "./planner-target-details-HkP4RrRO.mjs";
|
|
2
|
+
import { t as PostgresMigration } from "./postgres-migration-DbckK1su.mjs";
|
|
3
3
|
import { SqlMigrationPlanOperation } from "@prisma-next/family-sql/control";
|
|
4
4
|
import { MigrationPlanWithAuthoringSurface, OpFactoryCall } from "@prisma-next/framework-components/control";
|
|
5
|
-
import { ExecuteRequestLowerer } from "@prisma-next/family-sql/control-adapter";
|
|
6
5
|
import { MigrationMeta } from "@prisma-next/migration-tools/migration";
|
|
6
|
+
import { ExecuteRequestLowerer } from "@prisma-next/family-sql/control-adapter";
|
|
7
7
|
|
|
8
8
|
//#region src/core/migrations/planner-produced-postgres-migration.d.ts
|
|
9
9
|
declare class TypeScriptRenderablePostgresMigration extends PostgresMigration implements MigrationPlanWithAuthoringSurface {
|
|
@@ -21,4 +21,4 @@ declare class TypeScriptRenderablePostgresMigration extends PostgresMigration im
|
|
|
21
21
|
}
|
|
22
22
|
//#endregion
|
|
23
23
|
export { TypeScriptRenderablePostgresMigration as t };
|
|
24
|
-
//# sourceMappingURL=planner-produced-postgres-migration-
|
|
24
|
+
//# sourceMappingURL=planner-produced-postgres-migration-BEY1T0Xm.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"planner-produced-postgres-migration-
|
|
1
|
+
{"version":3,"file":"planner-produced-postgres-migration-BEY1T0Xm.d.mts","names":[],"sources":["../src/core/migrations/planner-produced-postgres-migration.ts"],"mappings":";;;;;;;;cAqCa,qCAAA,SACH,iBAAA,YACG,iCAAA;EAAA;cAcT,KAAA,WAAgB,aAAA,IAChB,IAAA,EAAM,aAAA,EACN,OAAA,UACA,OAAA,GAAU,qBAAA;EAAA,IASC,UAAA,cACT,yBAAA,CAA0B,yBAAA,IAC1B,OAAA,CAAQ,yBAAA,CAA0B,yBAAA;EAM7B,QAAA,IAAY,aAAA;EARR;;;;;EAAA,IAiBT,OAAA;EAIJ,gBAAA;AAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as PostgresMigration } from "./postgres-migration-
|
|
1
|
+
import { t as PostgresMigration } from "./postgres-migration-et1td40f.mjs";
|
|
2
2
|
import { t as renderOps } from "./render-ops-BREh1kHe.mjs";
|
|
3
|
-
import { t as renderCallsToTypeScript } from "./render-typescript-
|
|
3
|
+
import { t as renderCallsToTypeScript } from "./render-typescript-7yqILcwr.mjs";
|
|
4
4
|
//#region src/core/migrations/planner-produced-postgres-migration.ts
|
|
5
5
|
var TypeScriptRenderablePostgresMigration = class extends PostgresMigration {
|
|
6
6
|
#calls;
|
|
@@ -40,4 +40,4 @@ var TypeScriptRenderablePostgresMigration = class extends PostgresMigration {
|
|
|
40
40
|
//#endregion
|
|
41
41
|
export { TypeScriptRenderablePostgresMigration as t };
|
|
42
42
|
|
|
43
|
-
//# sourceMappingURL=planner-produced-postgres-migration-
|
|
43
|
+
//# sourceMappingURL=planner-produced-postgres-migration-BGPpq56_.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"planner-produced-postgres-migration-
|
|
1
|
+
{"version":3,"file":"planner-produced-postgres-migration-BGPpq56_.mjs","names":["#calls","#meta","#spaceId","#lowerer","#operationsCache"],"sources":["../src/core/migrations/planner-produced-postgres-migration.ts"],"sourcesContent":["/**\n * Planner-produced Postgres migration.\n *\n * Returned by `PostgresMigrationPlanner.plan(...)` and `emptyMigration(...)`.\n * Holds the migration IR (`PostgresOpFactoryCall[]`) alongside\n * `MigrationMeta` and exposes both the runtime-ops view (`get operations`)\n * and the TypeScript authoring view (`renderTypeScript()`). Satisfies\n * `MigrationPlanWithAuthoringSurface` so the CLI can uniformly serialize any\n * planner result back to `migration.ts`.\n *\n * Extends the family-level `SqlMigration` alias rather than the target-local\n * migration base directly — mirrors Mongo's `PlannerProducedMongoMigration`\n * shape and keeps CLI wiring one step removed from target internals.\n *\n * Placeholder-bearing plans: `renderTypeScript()` always succeeds and embeds\n * `() => placeholder(\"slot\")` at each stub. `operations`, in contrast, is\n * _not safe to enumerate_ on a stub-bearing plan — `DataTransformCall.toOp()`\n * throws `PN-MIG-2001` because a planner-stubbed closure cannot be lowered\n * to a runtime op. Callers that know a plan may carry stubs must render to\n * `migration.ts`, let the user fill the slots, and re-load the edited\n * migration before enumerating ops. The walk-schema planner does not emit\n * `DataTransformCall`s today, so this asymmetry is invisible until the\n * issue-planner integration lands in Phase 2.\n */\n\nimport type { SqlMigrationPlanOperation } from '@prisma-next/family-sql/control';\nimport type { ExecuteRequestLowerer } from '@prisma-next/family-sql/control-adapter';\nimport type {\n MigrationPlanWithAuthoringSurface,\n OpFactoryCall,\n} from '@prisma-next/framework-components/control';\nimport type { MigrationMeta } from '@prisma-next/migration-tools/migration';\nimport type { PostgresPlanTargetDetails } from './planner-target-details';\nimport { PostgresMigration } from './postgres-migration';\nimport { renderOps } from './render-ops';\nimport { renderCallsToTypeScript } from './render-typescript';\n\nexport class TypeScriptRenderablePostgresMigration\n extends PostgresMigration\n implements MigrationPlanWithAuthoringSurface\n{\n readonly #calls: readonly OpFactoryCall[];\n readonly #meta: MigrationMeta;\n readonly #spaceId: string;\n readonly #lowerer: ExecuteRequestLowerer | undefined;\n #operationsCache:\n | readonly (\n | SqlMigrationPlanOperation<PostgresPlanTargetDetails>\n | Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>>\n )[]\n | undefined;\n\n constructor(\n calls: readonly OpFactoryCall[],\n meta: MigrationMeta,\n spaceId: string,\n lowerer?: ExecuteRequestLowerer,\n ) {\n super();\n this.#calls = calls;\n this.#meta = meta;\n this.#spaceId = spaceId;\n this.#lowerer = lowerer;\n }\n\n override get operations(): readonly (\n | SqlMigrationPlanOperation<PostgresPlanTargetDetails>\n | Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>>\n )[] {\n this.#operationsCache ??= renderOps(this.#calls, this.#lowerer);\n return this.#operationsCache;\n }\n\n override describe(): MigrationMeta {\n return this.#meta;\n }\n\n /**\n * Contract space this planner-produced plan applies to. Threaded\n * from the planner options so the runner keys the marker row by\n * the right space when executing the plan.\n */\n get spaceId(): string {\n return this.#spaceId;\n }\n\n renderTypeScript(): string {\n return renderCallsToTypeScript(this.#calls, { from: this.#meta.from, to: this.#meta.to });\n }\n}\n"],"mappings":";;;;AAqCA,IAAa,wCAAb,cACU,kBAEV;CACE;CACA;CACA;CACA;CACA;CAOA,YACE,OACA,MACA,SACA,SACA;EACA,MAAM;EACN,KAAKA,SAAS;EACd,KAAKC,QAAQ;EACb,KAAKC,WAAW;EAChB,KAAKC,WAAW;CAClB;CAEA,IAAa,aAGT;EACF,KAAKC,qBAAqB,UAAU,KAAKJ,QAAQ,KAAKG,QAAQ;EAC9D,OAAO,KAAKC;CACd;CAEA,WAAmC;EACjC,OAAO,KAAKH;CACd;;;;;;CAOA,IAAI,UAAkB;EACpB,OAAO,KAAKC;CACd;CAEA,mBAA2B;EACzB,OAAO,wBAAwB,KAAKF,QAAQ;GAAE,MAAM,KAAKC,MAAM;GAAM,IAAI,KAAKA,MAAM;EAAG,CAAC;CAC1F;AACF"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as TypeScriptRenderablePostgresMigration } from "./planner-produced-postgres-migration-
|
|
1
|
+
import { t as TypeScriptRenderablePostgresMigration } from "./planner-produced-postgres-migration-BEY1T0Xm.mjs";
|
|
2
2
|
export { TypeScriptRenderablePostgresMigration };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as TypeScriptRenderablePostgresMigration } from "./planner-produced-postgres-migration-
|
|
1
|
+
import { t as TypeScriptRenderablePostgresMigration } from "./planner-produced-postgres-migration-BGPpq56_.mjs";
|
|
2
2
|
export { TypeScriptRenderablePostgresMigration };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as postgresCreateNamespace } from "./postgres-schema-
|
|
2
|
-
import { i as quoteIdentifier } from "./sql-utils-
|
|
1
|
+
import { i as postgresCreateNamespace } from "./postgres-schema-DYATroNx.mjs";
|
|
2
|
+
import { i as quoteIdentifier } from "./sql-utils-SU4FDvIV.mjs";
|
|
3
3
|
import { t as resolveColumnTypeMetadata } from "./planner-type-resolution-Bt2f_q-F.mjs";
|
|
4
4
|
//#region src/core/migrations/planner-sql-checks.ts
|
|
5
5
|
/**
|
|
@@ -19,7 +19,7 @@ function qualifyTableName(schema, table) {
|
|
|
19
19
|
entries: { table: {} }
|
|
20
20
|
}).qualifyTable(table);
|
|
21
21
|
}
|
|
22
|
-
const FORMAT_TYPE_DISPLAY = new Map([
|
|
22
|
+
const FORMAT_TYPE_DISPLAY = /* @__PURE__ */ new Map([
|
|
23
23
|
["int2", "smallint"],
|
|
24
24
|
["int4", "integer"],
|
|
25
25
|
["int8", "bigint"],
|
|
@@ -32,7 +32,7 @@ const FORMAT_TYPE_DISPLAY = new Map([
|
|
|
32
32
|
["timetz", "time with time zone"]
|
|
33
33
|
]);
|
|
34
34
|
const UNQUOTED_POSTGRES_IDENTIFIER_PATTERN = /^[a-z_][a-z0-9_$]*$/;
|
|
35
|
-
const POSTGRES_RESERVED_IDENTIFIER_WORDS = new Set([
|
|
35
|
+
const POSTGRES_RESERVED_IDENTIFIER_WORDS = /* @__PURE__ */ new Set([
|
|
36
36
|
"all",
|
|
37
37
|
"analyse",
|
|
38
38
|
"analyze",
|
|
@@ -149,4 +149,4 @@ function buildExpectedFormatType(column, codecHooks, storageTypes = {}) {
|
|
|
149
149
|
//#endregion
|
|
150
150
|
export { qualifyTableName as n, buildExpectedFormatType as t };
|
|
151
151
|
|
|
152
|
-
//# sourceMappingURL=planner-sql-checks-
|
|
152
|
+
//# sourceMappingURL=planner-sql-checks-CDXn2uaS.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"planner-sql-checks-
|
|
1
|
+
{"version":3,"file":"planner-sql-checks-CDXn2uaS.mjs","names":[],"sources":["../src/core/migrations/planner-sql-checks.ts"],"sourcesContent":["import type { CodecControlHooks } from '@prisma-next/family-sql/control';\nimport type { StorageColumn, StorageTypeInstance } from '@prisma-next/sql-contract/types';\nimport { postgresCreateNamespace } from '../postgres-schema';\nimport { quoteIdentifier } from '../sql-utils';\nimport { resolveColumnTypeMetadata } from './planner-type-resolution';\n\n/**\n * String-keyed entry points the migration ops use to render\n * schema-qualified DDL and catalog checks. The `schema` argument is\n * interpreted as a namespace coordinate: the framework `__unbound__`\n * sentinel resolves to the late-bound `PostgresUnboundSchema` singleton\n * (which elides the qualifier so `search_path` decides at runtime); any\n * other id materialises a `PostgresSchema(id)` whose qualifier is the\n * named schema. Helpers route through these `Namespace` concretions so\n * the unbound branch lives in the polymorphic override, not the call\n * site.\n */\nexport function qualifyTableName(schema: string, table: string): string {\n return postgresCreateNamespace({ id: schema, entries: { table: {} } }).qualifyTable(table);\n}\n\nconst FORMAT_TYPE_DISPLAY: ReadonlyMap<string, string> = new Map([\n ['int2', 'smallint'],\n ['int4', 'integer'],\n ['int8', 'bigint'],\n ['float4', 'real'],\n ['float8', 'double precision'],\n ['bool', 'boolean'],\n ['timestamp', 'timestamp without time zone'],\n ['timestamptz', 'timestamp with time zone'],\n ['time', 'time without time zone'],\n ['timetz', 'time with time zone'],\n]);\n\nconst UNQUOTED_POSTGRES_IDENTIFIER_PATTERN = /^[a-z_][a-z0-9_$]*$/;\n\nconst POSTGRES_RESERVED_IDENTIFIER_WORDS = new Set([\n 'all',\n 'analyse',\n 'analyze',\n 'and',\n 'any',\n 'array',\n 'as',\n 'asc',\n 'asymmetric',\n 'authorization',\n 'between',\n 'binary',\n 'both',\n 'case',\n 'cast',\n 'check',\n 'collate',\n 'column',\n 'constraint',\n 'create',\n 'current_catalog',\n 'current_date',\n 'current_role',\n 'current_time',\n 'current_timestamp',\n 'current_user',\n 'default',\n 'deferrable',\n 'desc',\n 'distinct',\n 'do',\n 'else',\n 'end',\n 'except',\n 'false',\n 'fetch',\n 'for',\n 'foreign',\n 'freeze',\n 'from',\n 'full',\n 'grant',\n 'group',\n 'having',\n 'ilike',\n 'in',\n 'initially',\n 'inner',\n 'intersect',\n 'into',\n 'is',\n 'isnull',\n 'join',\n 'lateral',\n 'leading',\n 'left',\n 'like',\n 'limit',\n 'localtime',\n 'localtimestamp',\n 'natural',\n 'not',\n 'notnull',\n 'null',\n 'offset',\n 'on',\n 'only',\n 'or',\n 'order',\n 'outer',\n 'overlaps',\n 'placing',\n 'primary',\n 'references',\n 'right',\n 'select',\n 'session_user',\n 'similar',\n 'some',\n 'symmetric',\n 'table',\n 'then',\n 'to',\n 'trailing',\n 'true',\n 'union',\n 'unique',\n 'user',\n 'using',\n 'variadic',\n 'verbose',\n 'when',\n 'where',\n 'window',\n 'with',\n]);\n\nfunction formatUserDefinedTypeName(identifier: string): string {\n if (\n UNQUOTED_POSTGRES_IDENTIFIER_PATTERN.test(identifier) &&\n !POSTGRES_RESERVED_IDENTIFIER_WORDS.has(identifier)\n ) {\n return identifier;\n }\n\n return quoteIdentifier(identifier);\n}\n\nexport function buildExpectedFormatType(\n column: StorageColumn,\n codecHooks: ReadonlyMap<string, CodecControlHooks>,\n storageTypes: Record<string, StorageTypeInstance> = {},\n): string {\n const resolved = resolveColumnTypeMetadata(column, storageTypes);\n\n if (resolved.typeParams && resolved.codecId) {\n const hooks = codecHooks.get(resolved.codecId);\n if (hooks?.expandNativeType) {\n return hooks.expandNativeType({\n nativeType: resolved.nativeType,\n codecId: resolved.codecId,\n typeParams: resolved.typeParams,\n });\n }\n }\n\n if (column.typeRef) {\n return formatUserDefinedTypeName(resolved.nativeType);\n }\n\n return FORMAT_TYPE_DISPLAY.get(resolved.nativeType) ?? resolved.nativeType;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAiBA,SAAgB,iBAAiB,QAAgB,OAAuB;CACtE,OAAO,wBAAwB;EAAE,IAAI;EAAQ,SAAS,EAAE,OAAO,CAAC,EAAE;CAAE,CAAC,CAAC,CAAC,aAAa,KAAK;AAC3F;AAEA,MAAM,sCAAmD,IAAI,IAAI;CAC/D,CAAC,QAAQ,UAAU;CACnB,CAAC,QAAQ,SAAS;CAClB,CAAC,QAAQ,QAAQ;CACjB,CAAC,UAAU,MAAM;CACjB,CAAC,UAAU,kBAAkB;CAC7B,CAAC,QAAQ,SAAS;CAClB,CAAC,aAAa,6BAA6B;CAC3C,CAAC,eAAe,0BAA0B;CAC1C,CAAC,QAAQ,wBAAwB;CACjC,CAAC,UAAU,qBAAqB;AAClC,CAAC;AAED,MAAM,uCAAuC;AAE7C,MAAM,qDAAqC,IAAI,IAAI;CACjD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAAS,0BAA0B,YAA4B;CAC7D,IACE,qCAAqC,KAAK,UAAU,KACpD,CAAC,mCAAmC,IAAI,UAAU,GAElD,OAAO;CAGT,OAAO,gBAAgB,UAAU;AACnC;AAEA,SAAgB,wBACd,QACA,YACA,eAAoD,CAAC,GAC7C;CACR,MAAM,WAAW,0BAA0B,QAAQ,YAAY;CAE/D,IAAI,SAAS,cAAc,SAAS,SAAS;EAC3C,MAAM,QAAQ,WAAW,IAAI,SAAS,OAAO;EAC7C,IAAI,OAAO,kBACT,OAAO,MAAM,iBAAiB;GAC5B,YAAY,SAAS;GACrB,SAAS,SAAS;GAClB,YAAY,SAAS;EACvB,CAAC;CAEL;CAEA,IAAI,OAAO,SACT,OAAO,0BAA0B,SAAS,UAAU;CAGtD,OAAO,oBAAoB,IAAI,SAAS,UAAU,KAAK,SAAS;AAClE"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CodecControlHooks } from "@prisma-next/family-sql/control";
|
|
2
1
|
import { StorageColumn, StorageTypeInstance } from "@prisma-next/sql-contract/types";
|
|
2
|
+
import { CodecControlHooks } from "@prisma-next/family-sql/control";
|
|
3
3
|
|
|
4
4
|
//#region src/core/migrations/planner-sql-checks.d.ts
|
|
5
5
|
/**
|
|
@@ -14,7 +14,7 @@ import { StorageColumn, StorageTypeInstance } from "@prisma-next/sql-contract/ty
|
|
|
14
14
|
* site.
|
|
15
15
|
*/
|
|
16
16
|
declare function qualifyTableName(schema: string, table: string): string;
|
|
17
|
-
declare function buildExpectedFormatType(column: StorageColumn, codecHooks:
|
|
17
|
+
declare function buildExpectedFormatType(column: StorageColumn, codecHooks: ReadonlyMap<string, CodecControlHooks>, storageTypes?: Record<string, StorageTypeInstance>): string;
|
|
18
18
|
//#endregion
|
|
19
19
|
export { buildExpectedFormatType, qualifyTableName };
|
|
20
20
|
//# sourceMappingURL=planner-sql-checks.d.mts.map
|
|
@@ -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-CDXn2uaS.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-CJv5bfbs.mjs";
|
|
2
|
+
import { t as PostgresContract } from "./postgres-schema-DKq6s1P3.mjs";
|
|
3
|
+
import { t as TypeScriptRenderablePostgresMigration } from "./planner-produced-postgres-migration-BEY1T0Xm.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":";;;;;;;;;;;;;;;;;AAkDA;;;;;;;;;;;;;iBAAgB,oCAAA,CACd,QAAA,EAAU,gBAAA,SACV,OAAA,EAAS,yBAAA,GACR,0BAAA;;;iBCWa,8BAAA,CACd,OAAA,EAAS,qBAAA,GACR,wBAAwB;;;;ADhB3B;;;;KC2BY,kBAAA;EAAA,SAEG,IAAA;EAAA,SACA,IAAA,EAAM,qCAAA;EAAA,SACN,QAAA,YAAoB,kBAAA;AAAA,IAE/B,uBAAA;;;;;;AD9ByB;;;;ACW7B;;;;;;;;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-DULhiCNM.mjs";
|
|
2
|
+
import { t as createPostgresMigrationPlanner } from "./planner-DwDxdYxi.mjs";
|
|
3
|
+
export { contractToPostgresDatabaseSchemaNode, createPostgresMigrationPlanner };
|
package/dist/{postgres-contract-serializer-k3TAcPMY.mjs → postgres-contract-view-C3LPCLP_.mjs}
RENAMED
|
@@ -1,16 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { p as PG_INT_CODEC_ID, v as PG_TEXT_CODEC_ID } from "./codec-ids-C_-Hj6bL.mjs";
|
|
2
|
+
import { a as nativeEnumEntityKind, c as roleEntityKind, o as policyEntityKind, s as rlsEnablementEntityKind, t as PostgresSchema } from "./postgres-schema-DYATroNx.mjs";
|
|
3
|
+
import { t as postgresAuthoringEntityTypes } from "./authoring-Bi9aa8zG.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-C3LPCLP_.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-contract-view-C3LPCLP_.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,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"}
|