@prisma-next/target-postgres 0.15.0 → 0.16.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 → authoring-34L18kA1.mjs} +18 -8
- package/dist/authoring-34L18kA1.mjs.map +1 -0
- package/dist/canonicalize-D1F4vUnP.d.mts.map +1 -1
- package/dist/{codec-ids-CI144z7g.d.mts → codec-ids-BswpvvND.d.mts} +3 -3
- package/dist/codec-ids-BswpvvND.d.mts.map +1 -0
- package/dist/{codec-ids-B10ZZHzw.mjs → codec-ids-D3G8K0YM.mjs} +3 -2
- package/dist/codec-ids-D3G8K0YM.mjs.map +1 -0
- package/dist/codec-ids.d.mts +2 -2
- package/dist/codec-ids.mjs +2 -2
- package/dist/{codec-types-CTfT4U4O.d.mts → codec-types-CQ07nOz-.d.mts} +4 -5
- package/dist/codec-types-CQ07nOz-.d.mts.map +1 -0
- package/dist/codec-types.d.mts +1 -1
- package/dist/{codecs-D7W9O0Xx.d.mts → codecs-G4DTY0F_.d.mts} +35 -7
- package/dist/codecs-G4DTY0F_.d.mts.map +1 -0
- package/dist/{codecs-DRbb26Or.mjs → codecs-TCsGgW-Y.mjs} +77 -5
- package/dist/codecs-TCsGgW-Y.mjs.map +1 -0
- package/dist/codecs.d.mts +2 -3
- package/dist/codecs.d.mts.map +1 -1
- package/dist/codecs.mjs +2 -2
- package/dist/contract-free.d.mts +2 -3
- package/dist/contract-free.d.mts.map +1 -1
- package/dist/contract-free.mjs +3 -3
- package/dist/{control-policy-DtbkLLGv.mjs → control-policy-S7XBe07W.mjs} +44 -75
- package/dist/control-policy-S7XBe07W.mjs.map +1 -0
- package/dist/control.d.mts +0 -1
- package/dist/control.d.mts.map +1 -1
- package/dist/control.mjs +75 -25
- package/dist/control.mjs.map +1 -1
- package/dist/data-transform-BOWpliq8.mjs.map +1 -1
- package/dist/{data-transform-DPzwBMhW.d.mts → data-transform-CGvE8yGx.d.mts} +1 -2
- package/dist/data-transform-CGvE8yGx.d.mts.map +1 -0
- package/dist/data-transform.d.mts +1 -1
- package/dist/{ddl-GTTOvjx_.mjs → ddl-DHXKzQ99.mjs} +3 -3
- package/dist/{ddl-GTTOvjx_.mjs.map → ddl-DHXKzQ99.mjs.map} +1 -1
- package/dist/ddl.d.mts +1 -1
- package/dist/default-normalizer-B9ZUiyUE.mjs +264 -0
- package/dist/default-normalizer-B9ZUiyUE.mjs.map +1 -0
- package/dist/default-normalizer.d.mts +14 -2
- package/dist/default-normalizer.d.mts.map +1 -1
- package/dist/default-normalizer.mjs +2 -248
- package/dist/{descriptor-meta-CFQKLXl_.mjs → descriptor-meta-qubYaxQA.mjs} +9 -4
- package/dist/descriptor-meta-qubYaxQA.mjs.map +1 -0
- package/dist/{diff-database-schema-GncqMuSI.mjs → diff-database-schema-BRxq7l98.mjs} +92 -26
- package/dist/diff-database-schema-BRxq7l98.mjs.map +1 -0
- package/dist/diff-database-schema.d.mts +4 -13
- package/dist/diff-database-schema.d.mts.map +1 -1
- package/dist/diff-database-schema.mjs +1 -1
- package/dist/{errors-DO-w0EUS.mjs → errors-ByDS0xJL.mjs} +6 -6
- package/dist/errors-ByDS0xJL.mjs.map +1 -0
- package/dist/errors.d.mts +4 -4
- package/dist/errors.d.mts.map +1 -1
- package/dist/errors.mjs +1 -1
- package/dist/issue-planner.d.mts +1 -2
- package/dist/issue-planner.d.mts.map +1 -1
- package/dist/issue-planner.mjs +1 -1
- package/dist/migration.d.mts +3 -4
- package/dist/migration.d.mts.map +1 -1
- package/dist/migration.mjs +2 -2
- package/dist/native-type-normalizer.d.mts.map +1 -1
- package/dist/{nodes-Dv5eCSq9.d.mts → nodes-CQzM2hR0.d.mts} +1 -2
- package/dist/nodes-CQzM2hR0.d.mts.map +1 -0
- package/dist/{op-factory-call-C38NzvQD.mjs → op-factory-call-Ci3H6InB.mjs} +37 -21
- package/dist/op-factory-call-Ci3H6InB.mjs.map +1 -0
- package/dist/{op-factory-call-Bn9zDx4_.d.mts → op-factory-call-DT7kdjVP.d.mts} +10 -7
- package/dist/op-factory-call-DT7kdjVP.d.mts.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 +122 -6
- package/dist/pack.d.mts.map +1 -1
- package/dist/pack.mjs +1 -1
- package/dist/{planner-kql24i_F.mjs → planner-BpL7uktH.mjs} +15 -15
- package/dist/planner-BpL7uktH.mjs.map +1 -0
- package/dist/planner-ddl-builders.d.mts +1 -2
- package/dist/planner-ddl-builders.d.mts.map +1 -1
- package/dist/planner-identity-values.d.mts +0 -1
- package/dist/planner-identity-values.d.mts.map +1 -1
- package/dist/{planner-produced-postgres-migration-BEY1T0Xm.d.mts → planner-produced-postgres-migration-8QP8eMph.d.mts} +3 -4
- package/dist/planner-produced-postgres-migration-8QP8eMph.d.mts.map +1 -0
- package/dist/{planner-produced-postgres-migration-D7y-PEHK.mjs → planner-produced-postgres-migration-D8exrrxA.mjs} +8 -5
- package/dist/planner-produced-postgres-migration-D8exrrxA.mjs.map +1 -0
- package/dist/planner-produced-postgres-migration.d.mts +1 -1
- package/dist/planner-produced-postgres-migration.mjs +1 -1
- package/dist/planner-schema-lookup.d.mts +0 -1
- package/dist/planner-schema-lookup.d.mts.map +1 -1
- package/dist/{planner-sql-checks-zqNfs2XZ.mjs → planner-sql-checks-BuB877wH.mjs} +2 -2
- package/dist/{planner-sql-checks-zqNfs2XZ.mjs.map → planner-sql-checks-BuB877wH.mjs.map} +1 -1
- package/dist/planner-sql-checks.d.mts +0 -1
- package/dist/planner-sql-checks.d.mts.map +1 -1
- package/dist/planner-sql-checks.mjs +1 -1
- package/dist/planner-target-details-HkP4RrRO.d.mts.map +1 -1
- package/dist/planner.d.mts +9 -4
- package/dist/planner.d.mts.map +1 -1
- package/dist/planner.mjs +2 -2
- package/dist/{postgres-contract-view-C9j5cqP0.d.mts → postgres-contract-view-CeU7FJjW.d.mts} +4 -3
- package/dist/postgres-contract-view-CeU7FJjW.d.mts.map +1 -0
- package/dist/{postgres-contract-view-DM8sN1Ot.mjs → postgres-contract-view-DebHMqGR.mjs} +4 -4
- package/dist/{postgres-contract-view-DM8sN1Ot.mjs.map → postgres-contract-view-DebHMqGR.mjs.map} +1 -1
- package/dist/{postgres-database-schema-node-CJv5bfbs.d.mts → postgres-database-schema-node-DMXsIwAb.d.mts} +12 -4
- package/dist/postgres-database-schema-node-DMXsIwAb.d.mts.map +1 -0
- package/dist/{postgres-migration-arMSWU9b.mjs → postgres-migration-Bn3fj1I4.mjs} +22 -6
- package/dist/postgres-migration-Bn3fj1I4.mjs.map +1 -0
- package/dist/{postgres-migration-DbckK1su.d.mts → postgres-migration-DLIvzHjX.d.mts} +31 -7
- package/dist/postgres-migration-DLIvzHjX.d.mts.map +1 -0
- package/dist/{postgres-rls-policy--CSddvMR.d.mts → postgres-rls-policy-CYXdqG9B.d.mts} +1 -2
- package/dist/postgres-rls-policy-CYXdqG9B.d.mts.map +1 -0
- package/dist/{postgres-role-schema-node-Cm-j0ZGM.mjs → postgres-role-schema-node-bg32e7I-.mjs} +3 -2
- package/dist/postgres-role-schema-node-bg32e7I-.mjs.map +1 -0
- package/dist/{postgres-schema-Cm4DtiGA.mjs → postgres-schema-CewLYHB7.mjs} +2 -2
- package/dist/{postgres-schema-Cm4DtiGA.mjs.map → postgres-schema-CewLYHB7.mjs.map} +1 -1
- package/dist/{postgres-schema-DKq6s1P3.d.mts → postgres-schema-FdKRwe7X.d.mts} +3 -4
- package/dist/postgres-schema-FdKRwe7X.d.mts.map +1 -0
- package/dist/render-ops.d.mts +0 -1
- package/dist/render-ops.d.mts.map +1 -1
- package/dist/{render-typescript-7yqILcwr.mjs → render-typescript-Ta7_6CGf.mjs} +20 -8
- package/dist/render-typescript-Ta7_6CGf.mjs.map +1 -0
- package/dist/render-typescript.d.mts +2 -1
- package/dist/render-typescript.d.mts.map +1 -1
- package/dist/render-typescript.mjs +1 -1
- package/dist/{resolve-ddl-schema-XyBaaenM.mjs → resolve-ddl-schema-D0wi_P9Q.mjs} +2 -2
- package/dist/{resolve-ddl-schema-XyBaaenM.mjs.map → resolve-ddl-schema-D0wi_P9Q.mjs.map} +1 -1
- package/dist/rls-canonicalize.d.mts +0 -1
- package/dist/rls-canonicalize.d.mts.map +1 -1
- package/dist/runtime.d.mts +1 -2
- package/dist/runtime.d.mts.map +1 -1
- package/dist/runtime.mjs +1 -1
- package/dist/schema-ir-annotations.d.mts +0 -1
- package/dist/schema-ir-annotations.d.mts.map +1 -1
- package/dist/schema-ir-annotations.mjs +1 -1
- package/dist/schema-node-kinds-DxvWh2Ic.d.mts +29 -0
- package/dist/schema-node-kinds-DxvWh2Ic.d.mts.map +1 -0
- package/dist/sql-utils.d.mts.map +1 -1
- package/dist/{table-source-BvFo7gVs.d.mts → table-source-D5c2fxAQ.d.mts} +1 -2
- package/dist/table-source-D5c2fxAQ.d.mts.map +1 -0
- package/dist/{types-BDKkx8MA.d.mts → types-D2MLzLBD.d.mts} +1 -2
- package/dist/types-D2MLzLBD.d.mts.map +1 -0
- package/dist/types.d.mts +6 -5
- package/dist/types.mjs +4 -4
- package/package.json +21 -21
- package/src/core/authoring.ts +18 -5
- package/src/core/codec-helpers.ts +53 -1
- package/src/core/codec-ids.ts +1 -0
- package/src/core/codecs.ts +56 -3
- package/src/core/default-normalizer.ts +22 -0
- package/src/core/descriptor-meta.ts +2 -0
- package/src/core/errors.ts +5 -5
- package/src/core/index-types.ts +15 -0
- package/src/core/migrations/contract-to-postgres-database-schema-node.ts +99 -19
- package/src/core/migrations/control-policy.ts +4 -3
- package/src/core/migrations/diff-database-schema.ts +6 -3
- package/src/core/migrations/issue-planner.ts +41 -80
- package/src/core/migrations/op-factory-call.ts +41 -22
- package/src/core/migrations/operations/data-transform.ts +2 -2
- package/src/core/migrations/planner-produced-postgres-migration.ts +9 -2
- package/src/core/migrations/planner-strategies.ts +6 -6
- package/src/core/migrations/planner.ts +13 -4
- package/src/core/migrations/postgres-migration.ts +62 -2
- package/src/core/migrations/render-typescript.ts +20 -8
- package/src/core/migrations/runner.ts +12 -11
- package/src/core/migrations/verify-postgres-namespaces.ts +0 -1
- package/src/core/psl-infer/infer-psl-contract.ts +130 -12
- package/src/core/schema-ir/postgres-policy-schema-node.ts +12 -2
- package/src/exports/codecs.ts +2 -0
- package/src/exports/control.ts +2 -0
- package/src/exports/default-normalizer.ts +1 -1
- package/src/exports/op-factory-call.ts +5 -0
- package/src/exports/types.ts +1 -0
- package/dist/authoring-BtsOWgI3.mjs.map +0 -1
- package/dist/codec-ids-B10ZZHzw.mjs.map +0 -1
- package/dist/codec-ids-CI144z7g.d.mts.map +0 -1
- package/dist/codec-types-CTfT4U4O.d.mts.map +0 -1
- package/dist/codecs-D7W9O0Xx.d.mts.map +0 -1
- package/dist/codecs-DRbb26Or.mjs.map +0 -1
- package/dist/control-policy-DtbkLLGv.mjs.map +0 -1
- package/dist/data-transform-DPzwBMhW.d.mts.map +0 -1
- package/dist/default-normalizer.mjs.map +0 -1
- package/dist/descriptor-meta-CFQKLXl_.mjs.map +0 -1
- package/dist/diff-database-schema-GncqMuSI.mjs.map +0 -1
- package/dist/errors-DO-w0EUS.mjs.map +0 -1
- package/dist/nodes-Dv5eCSq9.d.mts.map +0 -1
- package/dist/op-factory-call-Bn9zDx4_.d.mts.map +0 -1
- package/dist/op-factory-call-C38NzvQD.mjs.map +0 -1
- package/dist/planner-kql24i_F.mjs.map +0 -1
- package/dist/planner-produced-postgres-migration-BEY1T0Xm.d.mts.map +0 -1
- package/dist/planner-produced-postgres-migration-D7y-PEHK.mjs.map +0 -1
- package/dist/postgres-contract-view-C9j5cqP0.d.mts.map +0 -1
- package/dist/postgres-database-schema-node-CJv5bfbs.d.mts.map +0 -1
- package/dist/postgres-migration-DbckK1su.d.mts.map +0 -1
- package/dist/postgres-migration-arMSWU9b.mjs.map +0 -1
- package/dist/postgres-rls-policy--CSddvMR.d.mts.map +0 -1
- package/dist/postgres-role-schema-node-Cm-j0ZGM.mjs.map +0 -1
- package/dist/postgres-schema-DKq6s1P3.d.mts.map +0 -1
- package/dist/render-typescript-7yqILcwr.mjs.map +0 -1
- package/dist/table-source-BvFo7gVs.d.mts.map +0 -1
- package/dist/types-BDKkx8MA.d.mts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"planner-sql-checks-
|
|
1
|
+
{"version":3,"file":"planner-sql-checks-BuB877wH.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,6 +1,5 @@
|
|
|
1
1
|
import { StorageColumn, StorageTypeInstance } from "@prisma-next/sql-contract/types";
|
|
2
2
|
import { CodecControlHooks } from "@prisma-next/family-sql/control";
|
|
3
|
-
|
|
4
3
|
//#region src/core/migrations/planner-sql-checks.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* String-keyed entry points the migration ops use to render
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"planner-sql-checks.d.mts","names":[],"sources":["../src/core/migrations/planner-sql-checks.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"planner-sql-checks.d.mts","names":[],"sources":["../src/core/migrations/planner-sql-checks.ts"],"mappings":";;;;;;;;;;;;;;iBAiBgB,iBAAiB,gBAAgB;iBAgIjC,wBACd,QAAQ,eACR,YAAY,oBAAoB,oBAChC,eAAc,eAAe"}
|
|
@@ -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-BuB877wH.mjs";
|
|
2
2
|
export { buildExpectedFormatType, qualifyTableName };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"planner-target-details-HkP4RrRO.d.mts","names":[],"sources":["../src/core/migrations/planner-target-details.ts"],"mappings":";KAEY
|
|
1
|
+
{"version":3,"file":"planner-target-details-HkP4RrRO.d.mts","names":[],"sources":["../src/core/migrations/planner-target-details.ts"],"mappings":";KAEY;UAaK;WACN;WACA,YAAY;WACZ;WACA"}
|
package/dist/planner.d.mts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { t as PostgresDatabaseSchemaNode } from "./postgres-database-schema-node-
|
|
2
|
-
import { t as PostgresContract } from "./postgres-schema-
|
|
3
|
-
import { t as TypeScriptRenderablePostgresMigration } from "./planner-produced-postgres-migration-
|
|
1
|
+
import { t as PostgresDatabaseSchemaNode } from "./postgres-database-schema-node-DMXsIwAb.mjs";
|
|
2
|
+
import { t as PostgresContract } from "./postgres-schema-FdKRwe7X.mjs";
|
|
3
|
+
import { t as TypeScriptRenderablePostgresMigration } from "./planner-produced-postgres-migration-8QP8eMph.mjs";
|
|
4
4
|
import { ContractToSchemaIROptions, MigrationOperationPolicy, SqlPlannerConflict, SqlPlannerFailureResult } from "@prisma-next/family-sql/control";
|
|
5
5
|
import { MigrationPlanWithAuthoringSurface, MigrationPlanner, MigrationScaffoldContext, SchemaOwnership } from "@prisma-next/framework-components/control";
|
|
6
6
|
import { Contract } from "@prisma-next/contract/types";
|
|
7
7
|
import { ExecuteRequestLowerer } from "@prisma-next/family-sql/control-adapter";
|
|
8
8
|
import { TargetBoundComponentDescriptor } from "@prisma-next/framework-components/components";
|
|
9
|
-
|
|
10
9
|
//#region src/core/migrations/contract-to-postgres-database-schema-node.d.ts
|
|
11
10
|
/**
|
|
12
11
|
* Projects a Postgres contract into the expected schema-diff tree: a
|
|
@@ -97,6 +96,12 @@ declare class PostgresMigrationPlanner implements MigrationPlanner<'sql', 'postg
|
|
|
97
96
|
* {@link SqlMigrationPlannerPlanOptions.ownership}.
|
|
98
97
|
*/
|
|
99
98
|
readonly ownership?: SchemaOwnership;
|
|
99
|
+
/**
|
|
100
|
+
* POSIX-relative path from the migration package dir to
|
|
101
|
+
* `migrations/snapshots` — see
|
|
102
|
+
* {@link SqlMigrationPlannerPlanOptions.snapshotsImportPath}.
|
|
103
|
+
*/
|
|
104
|
+
readonly snapshotsImportPath: string;
|
|
100
105
|
}): PostgresPlanResult;
|
|
101
106
|
emptyMigration(context: MigrationScaffoldContext, spaceId: string): MigrationPlanWithAuthoringSurface;
|
|
102
107
|
private planSql;
|
package/dist/planner.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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":"
|
|
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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA6FgB,qCACd,UAAU,yBACV,SAAS,4BACR;;;iBC/Ba,+BACd,SAAS,wBACR;;;;;;;;KAWS;WAEG;WACA,MAAM;WACN,oBAAoB;IAE/B;;;;;;;;;;;;;;;;;;;cAoBS,oCAAoC;;cAGnC,UAAU;EAItB,KAAK;aACM;aACA;aACA,QAAQ;;;;;;;;;;;;;;;aAeR,cAAc;aACd;aACA,qBAAqB,cAAc;;;;;;aAMnC;;;;;aAKA,YAAY;;;;;;aAMZ;MACP;EAIJ,eACE,SAAS,0BACT,kBACC;UAaK;;;;;;;;;;;;;;;;;;;;;;;;UAiMA;UAiHA"}
|
package/dist/planner.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { r as contractToPostgresDatabaseSchemaNode } from "./diff-database-schema-
|
|
2
|
-
import { t as createPostgresMigrationPlanner } from "./planner-
|
|
1
|
+
import { r as contractToPostgresDatabaseSchemaNode } from "./diff-database-schema-BRxq7l98.mjs";
|
|
2
|
+
import { t as createPostgresMigrationPlanner } from "./planner-BpL7uktH.mjs";
|
|
3
3
|
export { contractToPostgresDatabaseSchemaNode, createPostgresMigrationPlanner };
|
package/dist/{postgres-contract-view-C9j5cqP0.d.mts → postgres-contract-view-CeU7FJjW.d.mts}
RENAMED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { SqlStorage } from "@prisma-next/sql-contract/types";
|
|
2
2
|
import { SqlSchemaQualifiedView } from "@prisma-next/sql-contract/contract-view";
|
|
3
3
|
import { Contract } from "@prisma-next/contract/types";
|
|
4
|
-
|
|
5
4
|
//#region src/core/postgres-contract-view.d.ts
|
|
6
5
|
/**
|
|
7
6
|
* A schema-qualified Postgres contract view: the deserialized contract
|
|
@@ -26,9 +25,11 @@ import { Contract } from "@prisma-next/contract/types";
|
|
|
26
25
|
*/
|
|
27
26
|
type PostgresContractView<TContract extends Contract<SqlStorage> = Contract<SqlStorage>> = SqlSchemaQualifiedView<TContract>;
|
|
28
27
|
declare const PostgresContractView: {
|
|
29
|
-
/** Wrap an already-deserialized Postgres contract in a schema-qualified view. */
|
|
28
|
+
/** Wrap an already-deserialized Postgres contract in a schema-qualified view. */
|
|
29
|
+
from<TContract extends Contract<SqlStorage>>(contract: TContract): PostgresContractView<TContract>;
|
|
30
|
+
/** Deserialize a Postgres contract JSON envelope and wrap it in a view. */
|
|
30
31
|
fromJson<TContract extends Contract<SqlStorage> = Contract<SqlStorage<string>>>(json: unknown): PostgresContractView<TContract>;
|
|
31
32
|
};
|
|
32
33
|
//#endregion
|
|
33
34
|
export { PostgresContractView as t };
|
|
34
|
-
//# sourceMappingURL=postgres-contract-view-
|
|
35
|
+
//# sourceMappingURL=postgres-contract-view-CeU7FJjW.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-contract-view-CeU7FJjW.d.mts","names":[],"sources":["../src/core/postgres-contract-view.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;KA6BY,qBAAqB,kBAAkB,SAAS,cAAc,SAAS,eACjF,uBAAuB;cAEZ;;OAEN,kBAAkB,SAAS,aAAW,UAC/B,YACT,qBAAqB;;WAKf,kBAAkB,SAAS,cAAW,SAAA,qBAAA,gBAE5C,qBAAqB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as nativeEnumEntityKind, c as roleEntityKind, o as policyEntityKind, s as rlsEnablementEntityKind, t as PostgresSchema } from "./postgres-schema-
|
|
3
|
-
import { t as postgresAuthoringEntityTypes } from "./authoring-
|
|
1
|
+
import { b as PG_TEXT_CODEC_ID, h as PG_INT_CODEC_ID } from "./codec-ids-D3G8K0YM.mjs";
|
|
2
|
+
import { a as nativeEnumEntityKind, c as roleEntityKind, o as policyEntityKind, s as rlsEnablementEntityKind, t as PostgresSchema } from "./postgres-schema-CewLYHB7.mjs";
|
|
3
|
+
import { t as postgresAuthoringEntityTypes } from "./authoring-34L18kA1.mjs";
|
|
4
4
|
import { UNBOUND_NAMESPACE_ID } from "@prisma-next/framework-components/ir";
|
|
5
5
|
import { blindCast } from "@prisma-next/utils/casts";
|
|
6
6
|
import { buildSqlSchemaQualifiedView } from "@prisma-next/sql-contract/contract-view";
|
|
@@ -108,4 +108,4 @@ const PostgresContractView = {
|
|
|
108
108
|
//#endregion
|
|
109
109
|
export { PostgresContractSerializer as n, PostgresContractView as t };
|
|
110
110
|
|
|
111
|
-
//# sourceMappingURL=postgres-contract-view-
|
|
111
|
+
//# sourceMappingURL=postgres-contract-view-DebHMqGR.mjs.map
|
package/dist/{postgres-contract-view-DM8sN1Ot.mjs.map → postgres-contract-view-DebHMqGR.mjs.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgres-contract-view-
|
|
1
|
+
{"version":3,"file":"postgres-contract-view-DebHMqGR.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"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { r as RlsPolicyOperation } from "./postgres-rls-policy
|
|
1
|
+
import { r as RlsPolicyOperation } from "./postgres-rls-policy-CYXdqG9B.mjs";
|
|
2
2
|
import { PrimaryKey, SqlAnnotations, SqlCheckConstraintIR, SqlColumnIR, SqlForeignKeyIR, SqlIndexIR, SqlSchemaIRNode, SqlTableIRInput, SqlUniqueIR } from "@prisma-next/sql-schema-ir/types";
|
|
3
|
-
import { DiffableNode } from "@prisma-next/framework-components/control";
|
|
3
|
+
import { DiffableNode, SchemaNodeRef } from "@prisma-next/framework-components/control";
|
|
4
4
|
import { ControlPolicy } from "@prisma-next/contract/types";
|
|
5
|
-
|
|
6
5
|
//#region src/core/schema-ir/postgres-native-enum-schema-node.d.ts
|
|
7
6
|
interface PostgresNativeEnumSchemaNodeInput {
|
|
8
7
|
/** The Postgres type name (`CREATE TYPE <typeName> AS ENUM (…)`). */
|
|
@@ -66,6 +65,13 @@ interface PostgresPolicySchemaNodeInput {
|
|
|
66
65
|
readonly withCheck?: string;
|
|
67
66
|
/** `true` = `AS PERMISSIVE`, `false` = `AS RESTRICTIVE`. */
|
|
68
67
|
readonly permissive: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* This policy's table node, plus one entry per role it grants to — each
|
|
70
|
+
* as the root-anchored chain the differ pairs siblings with. Stamped by
|
|
71
|
+
* the derivation, which holds the parent (database/namespace) context.
|
|
72
|
+
* Never compared by `isEqualTo`.
|
|
73
|
+
*/
|
|
74
|
+
readonly dependsOn?: readonly SchemaNodeRef[];
|
|
69
75
|
}
|
|
70
76
|
/**
|
|
71
77
|
* Schema-diff leaf node for a Postgres row-level security policy.
|
|
@@ -89,6 +95,8 @@ declare class PostgresPolicySchemaNode extends SqlSchemaIRNode implements Diffab
|
|
|
89
95
|
readonly using?: string;
|
|
90
96
|
readonly withCheck?: string;
|
|
91
97
|
readonly permissive: boolean;
|
|
98
|
+
/** See {@link PostgresPolicySchemaNodeInput.dependsOn}. Non-enumerable so it stays out of JSON and structural equality, matching `SqlColumnIR.codecRef`. */
|
|
99
|
+
readonly dependsOn?: readonly SchemaNodeRef[];
|
|
92
100
|
constructor(input: PostgresPolicySchemaNodeInput);
|
|
93
101
|
get id(): string;
|
|
94
102
|
children(): readonly DiffableNode[];
|
|
@@ -259,4 +267,4 @@ declare class PostgresDatabaseSchemaNode extends SqlSchemaIRNode implements Diff
|
|
|
259
267
|
}
|
|
260
268
|
//#endregion
|
|
261
269
|
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 };
|
|
262
|
-
//# sourceMappingURL=postgres-database-schema-node-
|
|
270
|
+
//# sourceMappingURL=postgres-database-schema-node-DMXsIwAb.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-database-schema-node-DMXsIwAb.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":";;;;;UAOiB;;WAEN;;WAEA;;WAEA;;WAEA,UAAU;;;;;;;;;;;;;;;;;;;;;cAsBR,qCAAqC,2BAA2B;WACzD;WAET;WACA;WACA;WACQ,UAAU;cAEf,OAAO;MASf;EAIJ,qBAAqB;EAIrB,UAAU,OAAO;SAaV,GAAG,MAAM,kBAAkB,QAAQ;SAInC,OAAO,MAAM,0BAA0B,QAAQ;;;;UCxEvC;;WAEN;;WAEA;;WAEA;;WAEA;WACA,WAAW;;WAEX;;WAEA;;WAEA;;WAEA;;;;;;;WAOA,qBAAqB;;;;;;;;;;;;;cAcnB,iCAAiC,2BAA2B;WACrD;WAET;WACA;WACA;WACA;WACA,WAAW;WACX;WACQ;WACA;WACR;;WAEQ,qBAAqB;cAE1B,OAAO;MAef;E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@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as
|
|
3
|
-
import { t as
|
|
1
|
+
import { g as PostgresRlsPolicy } from "./postgres-schema-CewLYHB7.mjs";
|
|
2
|
+
import { A as SetDefaultCall, C as DropNativeEnumTypeCall, D as EnableRowLevelSecurityCall, E as DropTableCall, F as installExtension, S as DropIndexCall, T as DropPostgresRlsPolicyCall, _ as DisableRowLevelSecurityCall, b as DropConstraintCall, c as AddUniqueCall, d as CreateIndexCall, f as CreateNativeEnumTypeCall, h as CreateTableCall, i as AddNativeEnumValueCall, j as SetNotNullCall, k as RenamePostgresRlsPolicyCall, l as AlterColumnTypeCall, m as CreateSchemaCall, n as AddColumnCall, p as CreatePostgresRlsPolicyCall, r as AddForeignKeyCall, s as AddPrimaryKeyCall, t as AddCheckConstraintCall, v as DropCheckConstraintCall, w as DropNotNullCall, x as DropDefaultCall, y as DropColumnCall } from "./op-factory-call-Ci3H6InB.mjs";
|
|
3
|
+
import { t as errorPostgresMigrationStackMissing } from "./errors-ByDS0xJL.mjs";
|
|
4
|
+
import { t as PostgresContractView } from "./postgres-contract-view-DebHMqGR.mjs";
|
|
4
5
|
import { t as dataTransform } from "./data-transform-BOWpliq8.mjs";
|
|
5
6
|
import { Migration } from "@prisma-next/family-sql/migration";
|
|
6
7
|
import { MigrationContractViews } from "@prisma-next/migration-tools/migration";
|
|
@@ -38,7 +39,7 @@ var PostgresMigration = class extends Migration {
|
|
|
38
39
|
* Materialized Postgres control adapter, created once per migration
|
|
39
40
|
* instance from the injected stack. `undefined` only when the migration
|
|
40
41
|
* was instantiated without a stack (test fixtures); `controlAdapterFor`
|
|
41
|
-
* throws a
|
|
42
|
+
* throws a MIGRATION.POSTGRES_CONTROL_STACK_MISSING in that case to surface the misuse.
|
|
42
43
|
*/
|
|
43
44
|
controlAdapter;
|
|
44
45
|
#endView = new MigrationContractViews(this, "PostgresMigration", (json) => PostgresContractView.fromJson(json));
|
|
@@ -48,7 +49,7 @@ var PostgresMigration = class extends Migration {
|
|
|
48
49
|
this.controlAdapter = stack?.adapter ? stack.adapter.create(stack) : void 0;
|
|
49
50
|
}
|
|
50
51
|
/**
|
|
51
|
-
* Returns the materialized control adapter, or throws a
|
|
52
|
+
* Returns the materialized control adapter, or throws a MIGRATION.POSTGRES_CONTROL_STACK_MISSING naming
|
|
52
53
|
* `operation` when the migration was constructed without a `ControlStack`.
|
|
53
54
|
* Single home for the null-check that every DDL/DML method shares.
|
|
54
55
|
*/
|
|
@@ -171,8 +172,23 @@ var PostgresMigration = class extends Migration {
|
|
|
171
172
|
installExtension(options) {
|
|
172
173
|
return installExtension(options, this.controlAdapterFor("installExtension"));
|
|
173
174
|
}
|
|
175
|
+
enableRowLevelSecurity(options) {
|
|
176
|
+
return new EnableRowLevelSecurityCall(options.schema, options.table).toOp(this.controlAdapterFor("enableRowLevelSecurity"));
|
|
177
|
+
}
|
|
178
|
+
disableRowLevelSecurity(options) {
|
|
179
|
+
return new DisableRowLevelSecurityCall(options.schema, options.table).toOp(this.controlAdapterFor("disableRowLevelSecurity"));
|
|
180
|
+
}
|
|
181
|
+
createRlsPolicy(options) {
|
|
182
|
+
return new CreatePostgresRlsPolicyCall(options.schema, options.table, new PostgresRlsPolicy(options.policy)).toOp(this.controlAdapterFor("createRlsPolicy"));
|
|
183
|
+
}
|
|
184
|
+
dropRlsPolicy(options) {
|
|
185
|
+
return new DropPostgresRlsPolicyCall(options.schema, options.table, options.policy).toOp(this.controlAdapterFor("dropRlsPolicy"));
|
|
186
|
+
}
|
|
187
|
+
renameRlsPolicy(options) {
|
|
188
|
+
return new RenamePostgresRlsPolicyCall(options.schema, options.table, options.from, options.to).toOp(this.controlAdapterFor("renameRlsPolicy"));
|
|
189
|
+
}
|
|
174
190
|
};
|
|
175
191
|
//#endregion
|
|
176
192
|
export { PostgresMigration as t };
|
|
177
193
|
|
|
178
|
-
//# sourceMappingURL=postgres-migration-
|
|
194
|
+
//# sourceMappingURL=postgres-migration-Bn3fj1I4.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-migration-Bn3fj1I4.mjs","names":["SqlMigration","#endView","#startView"],"sources":["../src/core/migrations/postgres-migration.ts"],"sourcesContent":["import type { Contract } from '@prisma-next/contract/types';\nimport type { SqlMigrationPlanOperation } from '@prisma-next/family-sql/control';\nimport type { SqlControlAdapter } from '@prisma-next/family-sql/control-adapter';\nimport { Migration as SqlMigration } from '@prisma-next/family-sql/migration';\nimport type { ControlStack } from '@prisma-next/framework-components/control';\nimport { MigrationContractViews } from '@prisma-next/migration-tools/migration';\nimport type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport type { DdlColumn, DdlTableConstraint } from '@prisma-next/sql-relational-core/ast';\nimport { errorPostgresMigrationStackMissing } from '../errors';\nimport { PostgresContractView } from '../postgres-contract-view';\nimport { PostgresRlsPolicy, type PostgresRlsPolicyInput } from '../postgres-rls-policy';\nimport {\n AddCheckConstraintCall,\n AddColumnCall,\n AddForeignKeyCall,\n AddNativeEnumValueCall,\n AddPrimaryKeyCall,\n AddUniqueCall,\n AlterColumnTypeCall,\n type AlterColumnTypeOptions,\n CreateIndexCall,\n CreateNativeEnumTypeCall,\n CreatePostgresRlsPolicyCall,\n CreateSchemaCall,\n CreateTableCall,\n DisableRowLevelSecurityCall,\n DropCheckConstraintCall,\n DropColumnCall,\n DropConstraintCall,\n DropDefaultCall,\n DropIndexCall,\n DropNativeEnumTypeCall,\n DropNotNullCall,\n DropPostgresRlsPolicyCall,\n DropTableCall,\n EnableRowLevelSecurityCall,\n RenamePostgresRlsPolicyCall,\n SetDefaultCall,\n SetNotNullCall,\n} from './op-factory-call';\nimport { type DataTransformOptions, dataTransform } from './operations/data-transform';\nimport { installExtension } from './operations/dependencies';\nimport type { CreateIndexExtras } from './operations/indexes';\nimport type { ForeignKeySpec } from './operations/shared';\nimport type { PostgresPlanTargetDetails } from './planner-target-details';\n\n/**\n * Target-owned base class for Postgres migrations.\n *\n * Fixes the `SqlMigration` generic to `PostgresPlanTargetDetails` and the\n * abstract `targetId` to the Postgres target-id string literal, so both\n * user-authored migrations and renderer-generated scaffolds (the output of\n * `renderCallsToTypeScript`) can extend `PostgresMigration` directly without\n * redeclaring target-local identity.\n *\n * Mirrors `MongoMigration` in `@prisma-next/family-mongo`: the renderer\n * emits `extends Migration` against a facade re-export of this class\n * from `@prisma-next/postgres/migration`, keeping the authoring surface\n * target-scoped rather than family-scoped.\n *\n * The constructor materializes a single Postgres `SqlControlAdapter` from\n * `stack.adapter.create(stack)` and stores it; the protected `dataTransform`\n * instance method forwards to the free `dataTransform` factory with that\n * stored adapter, so user migrations can write `this.dataTransform(...)`\n * without threading the adapter through every call.\n *\n * Every method requires an explicit `schema`. Postgres migrations name their\n * schema deliberately — there is no default and no `search_path`-relative\n * option. A migration that left the schema unspecified would resolve against\n * whatever `search_path` the connection happened to carry, and that ambiguity\n * is an antipattern in a migration. (The unbound/unspecified namespace concept\n * remains for SQLite, which has no schemas, and for Mongo's connection `db`.)\n */\nexport abstract class PostgresMigration<\n Start extends Contract<SqlStorage> = Contract<SqlStorage>,\n End extends Contract<SqlStorage> = Contract<SqlStorage>,\n> extends SqlMigration<PostgresPlanTargetDetails, 'postgres', Start, End> {\n readonly targetId = 'postgres' as const;\n\n /**\n * Materialized Postgres control adapter, created once per migration\n * instance from the injected stack. `undefined` only when the migration\n * was instantiated without a stack (test fixtures); `controlAdapterFor`\n * throws a MIGRATION.POSTGRES_CONTROL_STACK_MISSING in that case to surface the misuse.\n */\n protected readonly controlAdapter: SqlControlAdapter<'postgres'> | undefined;\n\n #endView = new MigrationContractViews<PostgresContractView<End>>(\n this,\n 'PostgresMigration',\n (json) => PostgresContractView.fromJson<End>(json),\n );\n #startView = new MigrationContractViews<PostgresContractView<Start>>(\n this,\n 'PostgresMigration',\n (json) => PostgresContractView.fromJson<Start>(json),\n );\n\n constructor(stack?: ControlStack<'sql', 'postgres'>) {\n super(stack);\n // The descriptor `create()` is typed as the wider `ControlAdapterInstance`;\n // the Postgres descriptor concretely returns a `SqlControlAdapter<'postgres'>`,\n // so the cast holds for any Postgres-target stack assembled at runtime.\n this.controlAdapter = stack?.adapter\n ? (stack.adapter.create(stack) as SqlControlAdapter<'postgres'>)\n : undefined;\n }\n\n /**\n * Returns the materialized control adapter, or throws a MIGRATION.POSTGRES_CONTROL_STACK_MISSING naming\n * `operation` when the migration was constructed without a `ControlStack`.\n * Single home for the null-check that every DDL/DML method shares.\n */\n private controlAdapterFor(operation: string): SqlControlAdapter<'postgres'> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing(operation);\n }\n return this.controlAdapter;\n }\n\n /**\n * The typed, schema-qualified Postgres view over this migration's end-state\n * contract — `this.endContract.namespace.<schema>.table.<name>`, etc. Throws\n * if no `endContractJson` was provided.\n */\n get endContract(): PostgresContractView<End> {\n return this.#endView.endContract;\n }\n\n /**\n * The typed Postgres view over this migration's start-state contract, or\n * `null` for a baseline migration (no `startContractJson`).\n */\n get startContract(): PostgresContractView<Start> | null {\n return this.#startView.startContract;\n }\n\n /**\n * Instance-method wrapper around the free `dataTransform` factory that\n * supplies the stored control adapter. Authors call this from inside\n * `get operations()`; the adapter argument is hidden from the call site.\n */\n protected dataTransform<TContract extends Contract<SqlStorage>>(\n contract: TContract,\n name: string,\n options: DataTransformOptions,\n ): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return dataTransform(contract, name, options, this.controlAdapterFor('dataTransform'));\n }\n\n /**\n * Emit a `CREATE TABLE` migration operation. Builds a typed DDL node from\n * the supplied options and lowers it through the stored control adapter.\n * Throws if no adapter is present (i.e. migration instantiated without a stack).\n */\n protected createTable(options: {\n readonly schema: string;\n readonly table: string;\n readonly ifNotExists?: boolean;\n readonly columns: readonly DdlColumn[];\n readonly constraints?: readonly DdlTableConstraint[];\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new CreateTableCall(\n options.schema,\n options.table,\n options.columns,\n options.constraints,\n ).toOp(this.controlAdapterFor('createTable'));\n }\n\n /**\n * Emit a `CREATE SCHEMA` migration operation. Builds a typed DDL node from\n * the supplied options and lowers it through the stored control adapter.\n * Throws if no adapter is present (i.e. migration instantiated without a stack).\n */\n protected createSchema(options: {\n readonly schema: string;\n readonly ifNotExists?: boolean;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new CreateSchemaCall(options.schema).toOp(this.controlAdapterFor('createSchema'));\n }\n\n /**\n * Emit a `CREATE TYPE ... AS ENUM (...)` migration operation for a managed\n * native enum. Builds a typed DDL node and lowers it through the stored\n * control adapter (members render in declaration order). Throws if no adapter\n * is present.\n */\n protected createNativeEnumType(options: {\n readonly schema: string;\n readonly typeName: string;\n readonly members: readonly string[];\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new CreateNativeEnumTypeCall(options.schema, options.typeName, options.members).toOp(\n this.controlAdapterFor('createNativeEnumType'),\n );\n }\n\n /**\n * Emit a `DROP TYPE` migration operation for a managed native enum, lowered\n * through the stored control adapter. Throws if no adapter is present.\n */\n protected dropNativeEnumType(options: {\n readonly schema: string;\n readonly typeName: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new DropNativeEnumTypeCall(options.schema, options.typeName).toOp(\n this.controlAdapterFor('dropNativeEnumType'),\n );\n }\n\n /**\n * Emit an `ALTER TYPE ... ADD VALUE` migration operation appending one\n * member to a managed native enum, lowered through the stored control\n * adapter. Throws if no adapter is present. Every appended value is its\n * own operation — call this once per value to append more than one.\n */\n protected addNativeEnumValue(options: {\n readonly schema: string;\n readonly typeName: string;\n readonly value: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new AddNativeEnumValueCall(options.schema, options.typeName, options.value).toOp(\n this.controlAdapterFor('addNativeEnumValue'),\n );\n }\n\n protected addColumn(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: DdlColumn;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new AddColumnCall(options.schema, options.table, options.column).toOp(\n this.controlAdapterFor('addColumn'),\n );\n }\n\n protected addPrimaryKey(options: {\n readonly schema: string;\n readonly table: string;\n readonly constraint: string;\n readonly columns: readonly string[];\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new AddPrimaryKeyCall(\n options.schema,\n options.table,\n options.constraint,\n options.columns,\n ).toOp(this.controlAdapterFor('addPrimaryKey'));\n }\n\n protected addUnique(options: {\n readonly schema: string;\n readonly table: string;\n readonly constraint: string;\n readonly columns: readonly string[];\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new AddUniqueCall(\n options.schema,\n options.table,\n options.constraint,\n options.columns,\n ).toOp(this.controlAdapterFor('addUnique'));\n }\n\n protected addForeignKey(options: {\n readonly schema: string;\n readonly table: string;\n readonly foreignKey: ForeignKeySpec;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new AddForeignKeyCall(options.schema, options.table, options.foreignKey).toOp(\n this.controlAdapterFor('addForeignKey'),\n );\n }\n\n protected addCheckConstraint(options: {\n readonly schema: string;\n readonly table: string;\n readonly constraint: string;\n readonly column: string;\n readonly values: readonly string[];\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new AddCheckConstraintCall(\n options.schema,\n options.table,\n options.constraint,\n options.column,\n options.values,\n ).toOp(this.controlAdapterFor('addCheckConstraint'));\n }\n\n protected dropCheckConstraint(options: {\n readonly schema: string;\n readonly table: string;\n readonly constraint: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new DropCheckConstraintCall(options.schema, options.table, options.constraint).toOp(\n this.controlAdapterFor('dropCheckConstraint'),\n );\n }\n\n protected dropConstraint(options: {\n readonly schema: string;\n readonly table: string;\n readonly constraint: string;\n readonly kind?: 'foreignKey' | 'unique' | 'primaryKey';\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new DropConstraintCall(\n options.schema,\n options.table,\n options.constraint,\n options.kind ?? 'unique',\n ).toOp(this.controlAdapterFor('dropConstraint'));\n }\n\n protected dropTable(options: {\n readonly schema: string;\n readonly table: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new DropTableCall(options.schema, options.table).toOp(\n this.controlAdapterFor('dropTable'),\n );\n }\n\n protected dropColumn(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new DropColumnCall(options.schema, options.table, options.column).toOp(\n this.controlAdapterFor('dropColumn'),\n );\n }\n\n protected alterColumnType(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n readonly options: AlterColumnTypeOptions;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new AlterColumnTypeCall(\n options.schema,\n options.table,\n options.column,\n options.options,\n ).toOp(this.controlAdapterFor('alterColumnType'));\n }\n\n protected setNotNull(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new SetNotNullCall(options.schema, options.table, options.column).toOp(\n this.controlAdapterFor('setNotNull'),\n );\n }\n\n protected dropNotNull(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new DropNotNullCall(options.schema, options.table, options.column).toOp(\n this.controlAdapterFor('dropNotNull'),\n );\n }\n\n protected setDefault(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n readonly defaultSql: string;\n readonly operationClass?: 'additive' | 'widening';\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new SetDefaultCall(\n options.schema,\n options.table,\n options.column,\n options.defaultSql,\n options.operationClass,\n ).toOp(this.controlAdapterFor('setDefault'));\n }\n\n protected dropDefault(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new DropDefaultCall(options.schema, options.table, options.column).toOp(\n this.controlAdapterFor('dropDefault'),\n );\n }\n\n protected createIndex(options: {\n readonly schema: string;\n readonly table: string;\n readonly index: string;\n readonly columns: readonly string[];\n readonly extras?: CreateIndexExtras;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new CreateIndexCall(\n options.schema,\n options.table,\n options.index,\n options.columns,\n options.extras,\n ).toOp(this.controlAdapterFor('createIndex'));\n }\n\n protected dropIndex(options: {\n readonly schema: string;\n readonly table: string;\n readonly index: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new DropIndexCall(options.schema, options.table, options.index).toOp(\n this.controlAdapterFor('dropIndex'),\n );\n }\n\n protected installExtension(options: {\n readonly extensionName: string;\n readonly invariantId: string;\n readonly id: string;\n readonly label?: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return installExtension(options, this.controlAdapterFor('installExtension'));\n }\n\n protected enableRowLevelSecurity(options: {\n readonly schema: string;\n readonly table: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new EnableRowLevelSecurityCall(options.schema, options.table).toOp(\n this.controlAdapterFor('enableRowLevelSecurity'),\n );\n }\n\n protected disableRowLevelSecurity(options: {\n readonly schema: string;\n readonly table: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new DisableRowLevelSecurityCall(options.schema, options.table).toOp(\n this.controlAdapterFor('disableRowLevelSecurity'),\n );\n }\n\n protected createRlsPolicy(options: {\n readonly schema: string;\n readonly table: string;\n readonly policy: PostgresRlsPolicyInput;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new CreatePostgresRlsPolicyCall(\n options.schema,\n options.table,\n new PostgresRlsPolicy(options.policy),\n ).toOp(this.controlAdapterFor('createRlsPolicy'));\n }\n\n protected dropRlsPolicy(options: {\n readonly schema: string;\n readonly table: string;\n readonly policy: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new DropPostgresRlsPolicyCall(options.schema, options.table, options.policy).toOp(\n this.controlAdapterFor('dropRlsPolicy'),\n );\n }\n\n protected renameRlsPolicy(options: {\n readonly schema: string;\n readonly table: string;\n readonly from: string;\n readonly to: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new RenamePostgresRlsPolicyCall(\n options.schema,\n options.table,\n options.from,\n options.to,\n ).toOp(this.controlAdapterFor('renameRlsPolicy'));\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyEA,IAAsB,oBAAtB,cAGUA,UAAgE;CACxE,WAAoB;;;;;;;CAQpB;CAEA,WAAW,IAAI,uBACb,MACA,sBACC,SAAS,qBAAqB,SAAc,IAAI,CACnD;CACA,aAAa,IAAI,uBACf,MACA,sBACC,SAAS,qBAAqB,SAAgB,IAAI,CACrD;CAEA,YAAY,OAAyC;EACnD,MAAM,KAAK;EAIX,KAAK,iBAAiB,OAAO,UACxB,MAAM,QAAQ,OAAO,KAAK,IAC3B,KAAA;CACN;;;;;;CAOA,kBAA0B,WAAkD;EAC1E,IAAI,CAAC,KAAK,gBACR,MAAM,mCAAmC,SAAS;EAEpD,OAAO,KAAK;CACd;;;;;;CAOA,IAAI,cAAyC;EAC3C,OAAO,KAAKC,SAAS;CACvB;;;;;CAMA,IAAI,gBAAoD;EACtD,OAAO,KAAKC,WAAW;CACzB;;;;;;CAOA,cACE,UACA,MACA,SAC+D;EAC/D,OAAO,cAAc,UAAU,MAAM,SAAS,KAAK,kBAAkB,eAAe,CAAC;CACvF;;;;;;CAOA,YAAsB,SAM4C;EAChE,OAAO,IAAI,gBACT,QAAQ,QACR,QAAQ,OACR,QAAQ,SACR,QAAQ,WACV,CAAC,CAAC,KAAK,KAAK,kBAAkB,aAAa,CAAC;CAC9C;;;;;;CAOA,aAAuB,SA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ransformOptions } from "./data-transform-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { n as DataTransformOptions } from "./data-transform-CGvE8yGx.mjs";
|
|
3
|
+
import { n as PostgresRlsPolicyInput } from "./postgres-rls-policy-CYXdqG9B.mjs";
|
|
4
|
+
import { N as ForeignKeySpec, l as AlterColumnTypeOptions } from "./op-factory-call-DT7kdjVP.mjs";
|
|
5
|
+
import { t as PostgresContractView } from "./postgres-contract-view-CeU7FJjW.mjs";
|
|
5
6
|
import { DdlColumn, DdlTableConstraint } from "@prisma-next/sql-relational-core/ast";
|
|
6
7
|
import { SqlStorage } from "@prisma-next/sql-contract/types";
|
|
7
8
|
import { SqlMigrationPlanOperation } from "@prisma-next/family-sql/control";
|
|
@@ -9,7 +10,6 @@ import { ControlStack } from "@prisma-next/framework-components/control";
|
|
|
9
10
|
import { Migration } from "@prisma-next/family-sql/migration";
|
|
10
11
|
import { Contract } from "@prisma-next/contract/types";
|
|
11
12
|
import { ExecuteRequestLowerer, SqlControlAdapter } from "@prisma-next/family-sql/control-adapter";
|
|
12
|
-
|
|
13
13
|
//#region src/core/migrations/operations/indexes.d.ts
|
|
14
14
|
interface CreateIndexExtras {
|
|
15
15
|
readonly type?: string;
|
|
@@ -51,12 +51,12 @@ declare abstract class PostgresMigration<Start extends Contract<SqlStorage> = Co
|
|
|
51
51
|
* Materialized Postgres control adapter, created once per migration
|
|
52
52
|
* instance from the injected stack. `undefined` only when the migration
|
|
53
53
|
* was instantiated without a stack (test fixtures); `controlAdapterFor`
|
|
54
|
-
* throws a
|
|
54
|
+
* throws a MIGRATION.POSTGRES_CONTROL_STACK_MISSING in that case to surface the misuse.
|
|
55
55
|
*/
|
|
56
56
|
protected readonly controlAdapter: SqlControlAdapter<'postgres'> | undefined;
|
|
57
57
|
constructor(stack?: ControlStack<'sql', 'postgres'>);
|
|
58
58
|
/**
|
|
59
|
-
* Returns the materialized control adapter, or throws a
|
|
59
|
+
* Returns the materialized control adapter, or throws a MIGRATION.POSTGRES_CONTROL_STACK_MISSING naming
|
|
60
60
|
* `operation` when the migration was constructed without a `ControlStack`.
|
|
61
61
|
* Single home for the null-check that every DDL/DML method shares.
|
|
62
62
|
*/
|
|
@@ -224,7 +224,31 @@ declare abstract class PostgresMigration<Start extends Contract<SqlStorage> = Co
|
|
|
224
224
|
readonly id: string;
|
|
225
225
|
readonly label?: string;
|
|
226
226
|
}): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>>;
|
|
227
|
+
protected enableRowLevelSecurity(options: {
|
|
228
|
+
readonly schema: string;
|
|
229
|
+
readonly table: string;
|
|
230
|
+
}): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>>;
|
|
231
|
+
protected disableRowLevelSecurity(options: {
|
|
232
|
+
readonly schema: string;
|
|
233
|
+
readonly table: string;
|
|
234
|
+
}): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>>;
|
|
235
|
+
protected createRlsPolicy(options: {
|
|
236
|
+
readonly schema: string;
|
|
237
|
+
readonly table: string;
|
|
238
|
+
readonly policy: PostgresRlsPolicyInput;
|
|
239
|
+
}): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>>;
|
|
240
|
+
protected dropRlsPolicy(options: {
|
|
241
|
+
readonly schema: string;
|
|
242
|
+
readonly table: string;
|
|
243
|
+
readonly policy: string;
|
|
244
|
+
}): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>>;
|
|
245
|
+
protected renameRlsPolicy(options: {
|
|
246
|
+
readonly schema: string;
|
|
247
|
+
readonly table: string;
|
|
248
|
+
readonly from: string;
|
|
249
|
+
readonly to: string;
|
|
250
|
+
}): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>>;
|
|
227
251
|
}
|
|
228
252
|
//#endregion
|
|
229
253
|
export { PostgresMigration as t };
|
|
230
|
-
//# sourceMappingURL=postgres-migration-
|
|
254
|
+
//# sourceMappingURL=postgres-migration-DLIvzHjX.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-migration-DLIvzHjX.d.mts","names":[],"sources":["../src/core/migrations/operations/indexes.ts","../src/core/migrations/postgres-migration.ts"],"mappings":";;;;;;;;;;;;;UAmBiB;WACN;WACA,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBCoDC,kBACpB,cAAc,SAAS,cAAc,SAAS,aAC9C,YAAY,SAAS,cAAc,SAAS,qBACpC,UAAa,uCAAuC,OAAO;;WAC1D;;;;;;;qBAQU,gBAAgB;cAavB,QAAQ;;;;;;UAeZ;;;;;;MAYJ,eAAe,qBAAqB;;;;;MAQpC,iBAAiB,qBAAqB;;;;;;YAShC,cAAc,kBAAkB,SAAS,aACjD,UAAU,WACV,cACA,SAAS,uBACR,QAAQ,0BAA0B;;;;;;YAS3B,YAAY;aACX;aACA;aACA;aACA,kBAAkB;aAClB,uBAAuB;MAC9B,QAAQ,0BAA0B;;;;;;YAc5B,aAAa;aACZ;aACA;MACP,QAAQ,0BAA0B;;;;;;;YAU5B,qBAAqB;aACpB;aACA;aACA;MACP,QAAQ,0BAA0B;;;;;YAU5B,mBAAmB;aAClB;aACA;MACP,QAAQ,0BAA0B;;;;;;;YAY5B,mBAAmB;aAClB;aACA;aACA;MACP,QAAQ,0BAA0B;YAM5B,UAAU;aACT;aACA;aACA,QAAQ;MACf,QAAQ,0BAA0B;YAM5B,cAAc;aACb;aACA;aACA;aACA;MACP,QAAQ,0BAA0B;YAS5B,UAAU;aACT;aACA;aACA;aACA;MACP,QAAQ,0BAA0B;YAS5B,cAAc;aACb;aACA;aACA,YAAY;MACnB,QAAQ,0BAA0B;YAM5B,mBAAmB;aAClB;aACA;aACA;aACA;aACA;MACP,QAAQ,0BAA0B;YAU5B,oBAAoB;aACnB;aACA;aACA;MACP,QAAQ,0BAA0B;YAM5B,eAAe;aACd;aACA;aACA;aACA;MACP,QAAQ,0BAA0B;YAS5B,UAAU;aACT;aACA;MACP,QAAQ,0BAA0B;YAM5B,WAAW;aACV;aACA;aACA;MACP,QAAQ,0BAA0B;YAM5B,gBAAgB;aACf;aACA;aACA;aACA,SAAS;MAChB,QAAQ,0BAA0B;YAS5B,WAAW;aACV;aACA;aACA;MACP,QAAQ,0BAA0B;YAM5B,YAAY;aACX;aACA;aACA;MACP,QAAQ,0BAA0B;YAM5B,WAAW;aACV;aACA;aACA;aACA;aACA;MACP,QAAQ,0BAA0B;YAU5B,YAAY;aACX;aACA;aACA;MACP,QAAQ,0BAA0B;YAM5B,YAAY;aACX;aACA;aACA;aACA;aACA,SAAS;MAChB,QAAQ,0BAA0B;YAU5B,UAAU;aACT;aACA;aACA;MACP,QAAQ,0BAA0B;YAM5B,iBAAiB;aAChB;aACA;aACA;aACA;MACP,QAAQ,0BAA0B;YAI5B,uBAAuB;aACtB;aACA;MACP,QAAQ,0BAA0B;YAM5B,wBAAwB;aACvB;aACA;MACP,QAAQ,0BAA0B;YAM5B,gBAAgB;aACf;aACA;aACA,QAAQ;MACf,QAAQ,0BAA0B;YAQ5B,cAAc;aACb;aACA;aACA;MACP,QAAQ,0BAA0B;YAM5B,gBAAgB;aACf;aACA;aACA;aACA;MACP,QAAQ,0BAA0B"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { SqlNode } from "@prisma-next/sql-contract/types";
|
|
2
|
-
|
|
3
2
|
//#region src/core/postgres-rls-policy.d.ts
|
|
4
3
|
type RlsPolicyOperation = 'select' | 'insert' | 'update' | 'delete' | 'all';
|
|
5
4
|
interface PostgresRlsPolicyInput {
|
|
@@ -49,4 +48,4 @@ declare class PostgresRlsPolicy extends SqlNode {
|
|
|
49
48
|
}
|
|
50
49
|
//#endregion
|
|
51
50
|
export { PostgresRlsPolicyInput as n, RlsPolicyOperation as r, PostgresRlsPolicy as t };
|
|
52
|
-
//# sourceMappingURL=postgres-rls-policy
|
|
51
|
+
//# sourceMappingURL=postgres-rls-policy-CYXdqG9B.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-rls-policy-CYXdqG9B.d.mts","names":[],"sources":["../src/core/postgres-rls-policy.ts"],"mappings":";;KAGY;UAEK;;WAEN;;WAEA;;WAEA;;WAEA;WACA,WAAW;;WAEX;;WAEA;;WAEA;;WAEA;;;;;;;;;;;;;;;cAgBE,0BAA0B;WACnB;WACT;WACA;WACA;WACA;WACA,WAAW;WACX;WACQ;WACA;WACR;cAEG,OAAO"}
|
package/dist/{postgres-role-schema-node-Cm-j0ZGM.mjs → postgres-role-schema-node-bg32e7I-.mjs}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { r as PostgresSchemaNodeKind } from "./postgres-table-schema-node-D6LvInCe.mjs";
|
|
2
2
|
import { freezeNode } from "@prisma-next/framework-components/ir";
|
|
3
3
|
import { blindCast } from "@prisma-next/utils/casts";
|
|
4
|
-
import { SqlSchemaIRNode, assertNode } from "@prisma-next/sql-schema-ir/types";
|
|
4
|
+
import { SqlSchemaIRNode, assertNode, defineNonEnumerable } from "@prisma-next/sql-schema-ir/types";
|
|
5
5
|
//#region src/core/schema-ir/postgres-database-schema-node.ts
|
|
6
6
|
/**
|
|
7
7
|
* The root of the Postgres schema-diff tree: one node per database.
|
|
@@ -122,6 +122,7 @@ var PostgresPolicySchemaNode = class PostgresPolicySchemaNode extends SqlSchemaI
|
|
|
122
122
|
if (input.using !== void 0) this.using = input.using;
|
|
123
123
|
if (input.withCheck !== void 0) this.withCheck = input.withCheck;
|
|
124
124
|
this.permissive = input.permissive;
|
|
125
|
+
defineNonEnumerable(this, "dependsOn", input.dependsOn);
|
|
125
126
|
freezeNode(this);
|
|
126
127
|
}
|
|
127
128
|
get id() {
|
|
@@ -187,4 +188,4 @@ var PostgresRoleSchemaNode = class PostgresRoleSchemaNode extends SqlSchemaIRNod
|
|
|
187
188
|
//#endregion
|
|
188
189
|
export { PostgresDatabaseSchemaNode as i, PostgresPolicySchemaNode as n, PostgresNamespaceSchemaNode as r, PostgresRoleSchemaNode as t };
|
|
189
190
|
|
|
190
|
-
//# sourceMappingURL=postgres-role-schema-node-
|
|
191
|
+
//# sourceMappingURL=postgres-role-schema-node-bg32e7I-.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-role-schema-node-bg32e7I-.mjs","names":[],"sources":["../src/core/schema-ir/postgres-database-schema-node.ts","../src/core/schema-ir/postgres-namespace-schema-node.ts","../src/core/schema-ir/postgres-policy-schema-node.ts","../src/core/schema-ir/postgres-role-schema-node.ts"],"sourcesContent":["import type { DiffableNode } from '@prisma-next/framework-components/control';\nimport { freezeNode } from '@prisma-next/framework-components/ir';\nimport { assertNode, SqlSchemaIRNode } from '@prisma-next/sql-schema-ir/types';\nimport type { PostgresNamespaceSchemaNode } from './postgres-namespace-schema-node';\nimport type { PostgresRoleSchemaNode } from './postgres-role-schema-node';\nimport { PostgresSchemaNodeKind } from './schema-node-kinds';\n\nexport interface PostgresDatabaseSchemaNodeInput {\n readonly namespaces: Readonly<Record<string, PostgresNamespaceSchemaNode>>;\n readonly roles: readonly PostgresRoleSchemaNode[];\n readonly existingSchemas: readonly string[];\n readonly pgVersion: string;\n}\n\n/**\n * The root of the Postgres schema-diff tree: one node per database.\n *\n * `id` is the fixed sentinel `'database'` — the root has no siblings and\n * the value is never emitted into migration paths. `isEqualTo` is identity\n * (roots always share the `'database'` id). `children()` yields the namespace\n * nodes followed by the role nodes — both are root-level diff subjects. The\n * differ pairs siblings by `(nodeKind, id)`, so a role and a namespace may\n * share a name without colliding.\n */\nexport class PostgresDatabaseSchemaNode extends SqlSchemaIRNode implements DiffableNode {\n override readonly nodeKind = PostgresSchemaNodeKind.database;\n\n readonly namespaces: Readonly<Record<string, PostgresNamespaceSchemaNode>>;\n readonly roles: readonly PostgresRoleSchemaNode[];\n readonly existingSchemas: readonly string[];\n readonly pgVersion: string;\n\n constructor(input: PostgresDatabaseSchemaNodeInput) {\n super();\n this.namespaces = Object.freeze({ ...input.namespaces });\n this.roles = Object.freeze([...input.roles]);\n this.existingSchemas = Object.freeze([...input.existingSchemas]);\n this.pgVersion = input.pgVersion;\n freezeNode(this);\n }\n\n get id(): string {\n return 'database';\n }\n\n isEqualTo(other: DiffableNode): boolean {\n return this.id === other.id;\n }\n\n children(): readonly DiffableNode[] {\n return [...Object.values(this.namespaces), ...this.roles];\n }\n\n static is(node: SqlSchemaIRNode): node is PostgresDatabaseSchemaNode {\n return node.nodeKind === PostgresSchemaNodeKind.database;\n }\n\n static assert(node: SqlSchemaIRNode): asserts node is PostgresDatabaseSchemaNode {\n assertNode(node, 'PostgresDatabaseSchemaNode', PostgresDatabaseSchemaNode.is);\n }\n}\n","import type { DiffableNode } from '@prisma-next/framework-components/control';\nimport { freezeNode } from '@prisma-next/framework-components/ir';\nimport { assertNode, SqlSchemaIRNode } from '@prisma-next/sql-schema-ir/types';\nimport type { PostgresNativeEnumSchemaNode } from './postgres-native-enum-schema-node';\nimport type { PostgresTableSchemaNode } from './postgres-table-schema-node';\nimport { PostgresSchemaNodeKind } from './schema-node-kinds';\n\nexport interface PostgresNamespaceSchemaNodeInput {\n readonly schemaName: string;\n readonly tables: Readonly<Record<string, PostgresTableSchemaNode>>;\n /**\n * The native-enum diff nodes belonging to this namespace, member values in\n * `pg_enum.enumsortorder` (declaration) order. The expected\n * (contract-projected) side attaches each node's `control` (the contract\n * entity's grade); introspection builds nodes with no `control`.\n */\n readonly nativeEnums?: readonly PostgresNativeEnumSchemaNode[];\n}\n\n/**\n * One-per-Postgres-schema diff-tree node. Groups the tables belonging to a\n * single namespace. Per-schema consumers (the relational planner,\n * toSchemaView) read this node's `tables` field structurally via\n * `blindCast`/`SqlSchemaIRNode` — not through a static `SqlSchemaIR`\n * assignment — because `nodeKind` carries this node's own literal\n * (`postgres-namespace`), distinct from `SqlSchemaIR`'s own (`sql-schema`).\n *\n * `id` is the schema name; `isEqualTo` is identity on it; `children()` returns\n * the table nodes plus `nativeEnums`.\n *\n * `nativeEnums` is the diff-tree representation of native enum types the\n * differ pairs — the sole enum carrier, built directly by both sides: the\n * expected (contract-projected) side and introspection alike hand in\n * `PostgresNativeEnumSchemaNode`s.\n */\nexport class PostgresNamespaceSchemaNode extends SqlSchemaIRNode implements DiffableNode {\n override readonly nodeKind = PostgresSchemaNodeKind.namespace;\n\n readonly schemaName: string;\n readonly tables: Readonly<Record<string, PostgresTableSchemaNode>>;\n readonly nativeEnums: readonly PostgresNativeEnumSchemaNode[];\n\n constructor(input: PostgresNamespaceSchemaNodeInput) {\n super();\n this.schemaName = input.schemaName;\n this.tables = Object.freeze({ ...input.tables });\n this.nativeEnums = Object.freeze([...(input.nativeEnums ?? [])]);\n freezeNode(this);\n }\n\n get id(): string {\n return this.schemaName;\n }\n\n isEqualTo(other: DiffableNode): boolean {\n return this.id === other.id;\n }\n\n children(): readonly DiffableNode[] {\n return [...Object.values(this.tables), ...this.nativeEnums];\n }\n\n static is(node: SqlSchemaIRNode): node is PostgresNamespaceSchemaNode {\n return node.nodeKind === PostgresSchemaNodeKind.namespace;\n }\n\n static assert(node: SqlSchemaIRNode): asserts node is PostgresNamespaceSchemaNode {\n assertNode(node, 'PostgresNamespaceSchemaNode', PostgresNamespaceSchemaNode.is);\n }\n}\n","import type { DiffableNode, SchemaNodeRef } from '@prisma-next/framework-components/control';\nimport { freezeNode } from '@prisma-next/framework-components/ir';\nimport { assertNode, defineNonEnumerable, SqlSchemaIRNode } from '@prisma-next/sql-schema-ir/types';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport type { RlsPolicyOperation } from '../postgres-rls-policy';\nimport { PostgresSchemaNodeKind } from './schema-node-kinds';\n\nexport interface PostgresPolicySchemaNodeInput {\n /** Full wire name: `<prefix>_<8hex>`. */\n readonly name: string;\n /** User-supplied prefix (the part before the `_<8hex>` suffix). */\n readonly prefix: string;\n /** Name of the table this policy attaches to, by name within the same schema. */\n readonly tableName: string;\n /** Namespace coordinate (schema name). */\n readonly namespaceId: string;\n readonly operation: RlsPolicyOperation;\n /** Sorted role names rendered in `TO <roles>`. */\n readonly roles: readonly string[];\n /** USING predicate SQL string, if present. */\n readonly using?: string;\n /** WITH CHECK predicate SQL string, if present. */\n readonly withCheck?: string;\n /** `true` = `AS PERMISSIVE`, `false` = `AS RESTRICTIVE`. */\n readonly permissive: boolean;\n /**\n * This policy's table node, plus one entry per role it grants to — each\n * as the root-anchored chain the differ pairs siblings with. Stamped by\n * the derivation, which holds the parent (database/namespace) context.\n * Never compared by `isEqualTo`.\n */\n readonly dependsOn?: readonly SchemaNodeRef[];\n}\n\n/**\n * Schema-diff leaf node for a Postgres row-level security policy.\n *\n * This is a derived, transient node walked by the differ — it is NEVER serialized.\n * Built by project-from-contract and project-from-database from their respective\n * `PostgresRlsPolicy` contract entities / introspected rows.\n *\n * `id` is the wire name (`<prefix>_<sha256(body)[0..8]>`), so name-equality is\n * body-equality. `isEqualTo` compares names only — never byte-compare predicate\n * bodies, because Postgres reprints them.\n */\nexport class PostgresPolicySchemaNode extends SqlSchemaIRNode implements DiffableNode {\n override readonly nodeKind = PostgresSchemaNodeKind.policy;\n\n readonly name: string;\n readonly prefix: string;\n readonly tableName: string;\n readonly namespaceId: string;\n readonly operation: RlsPolicyOperation;\n readonly roles: readonly string[];\n declare readonly using?: string;\n declare readonly withCheck?: string;\n readonly permissive: boolean;\n /** See {@link PostgresPolicySchemaNodeInput.dependsOn}. Non-enumerable so it stays out of JSON and structural equality, matching `SqlColumnIR.codecRef`. */\n declare readonly dependsOn?: readonly SchemaNodeRef[];\n\n constructor(input: PostgresPolicySchemaNodeInput) {\n super();\n this.name = input.name;\n this.prefix = input.prefix;\n this.tableName = input.tableName;\n this.namespaceId = input.namespaceId;\n this.operation = input.operation;\n this.roles = Object.freeze([...input.roles]);\n if (input.using !== undefined) this.using = input.using;\n if (input.withCheck !== undefined) this.withCheck = input.withCheck;\n this.permissive = input.permissive;\n defineNonEnumerable(this, 'dependsOn', input.dependsOn);\n freezeNode(this);\n }\n\n get id(): string {\n return this.name;\n }\n\n children(): readonly DiffableNode[] {\n return [];\n }\n\n isEqualTo(other: DiffableNode): boolean {\n const node = blindCast<\n SqlSchemaIRNode,\n 'every diff-tree node the differ pairs is a SqlSchemaIRNode; the guard rejects non-policy kinds'\n >(other);\n PostgresPolicySchemaNode.assert(node);\n return this.id === node.id;\n }\n\n static is(node: SqlSchemaIRNode): node is PostgresPolicySchemaNode {\n return node.nodeKind === PostgresSchemaNodeKind.policy;\n }\n\n static assert(node: SqlSchemaIRNode | undefined): asserts node is PostgresPolicySchemaNode {\n assertNode(node, 'PostgresPolicySchemaNode', PostgresPolicySchemaNode.is);\n }\n}\n","import type { DiffableNode } from '@prisma-next/framework-components/control';\nimport { freezeNode } from '@prisma-next/framework-components/ir';\nimport { assertNode, SqlSchemaIRNode } from '@prisma-next/sql-schema-ir/types';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport { PostgresSchemaNodeKind } from './schema-node-kinds';\n\nexport interface PostgresRoleSchemaNodeInput {\n readonly name: string;\n /**\n * Namespace coordinate. Roles are cluster-scoped; callers pass\n * `UNBOUND_NAMESPACE_ID` from `@prisma-next/framework-components/ir`.\n */\n readonly namespaceId: string;\n}\n\n/**\n * Schema-diff leaf node for a Postgres database role.\n *\n * This is a derived, transient node walked by the differ — it is NEVER serialized.\n * Built by project-from-contract and project-from-database from their respective\n * `PostgresRole` contract entities / introspected rows.\n *\n * Roles are cluster-scoped, so `id` is the bare role name. The differ pairs\n * siblings by `(nodeKind, id)`, so a role and a namespace may share a name\n * (role `public`, schema `public`) without colliding. `isEqualTo` compares\n * ids — name-equality is role-equality for cluster-scoped objects.\n */\nexport class PostgresRoleSchemaNode extends SqlSchemaIRNode implements DiffableNode {\n override readonly nodeKind = PostgresSchemaNodeKind.role;\n\n readonly name: string;\n readonly namespaceId: string;\n\n constructor(input: PostgresRoleSchemaNodeInput) {\n super();\n this.name = input.name;\n this.namespaceId = input.namespaceId;\n freezeNode(this);\n }\n\n get id(): string {\n return this.name;\n }\n\n children(): readonly DiffableNode[] {\n return [];\n }\n\n isEqualTo(other: DiffableNode): boolean {\n const node = blindCast<\n SqlSchemaIRNode,\n 'every diff-tree node the differ pairs is a SqlSchemaIRNode; the guard rejects non-role kinds'\n >(other);\n PostgresRoleSchemaNode.assert(node);\n return this.id === node.id;\n }\n\n static is(node: SqlSchemaIRNode): node is PostgresRoleSchemaNode {\n return node.nodeKind === PostgresSchemaNodeKind.role;\n }\n\n static assert(node: SqlSchemaIRNode): asserts node is PostgresRoleSchemaNode {\n assertNode(node, 'PostgresRoleSchemaNode', PostgresRoleSchemaNode.is);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAwBA,IAAa,6BAAb,MAAa,mCAAmC,gBAAwC;CACtF,WAA6B,uBAAuB;CAEpD;CACA;CACA;CACA;CAEA,YAAY,OAAwC;EAClD,MAAM;EACN,KAAK,aAAa,OAAO,OAAO,EAAE,GAAG,MAAM,WAAW,CAAC;EACvD,KAAK,QAAQ,OAAO,OAAO,CAAC,GAAG,MAAM,KAAK,CAAC;EAC3C,KAAK,kBAAkB,OAAO,OAAO,CAAC,GAAG,MAAM,eAAe,CAAC;EAC/D,KAAK,YAAY,MAAM;EACvB,WAAW,IAAI;CACjB;CAEA,IAAI,KAAa;EACf,OAAO;CACT;CAEA,UAAU,OAA8B;EACtC,OAAO,KAAK,OAAO,MAAM;CAC3B;CAEA,WAAoC;EAClC,OAAO,CAAC,GAAG,OAAO,OAAO,KAAK,UAAU,GAAG,GAAG,KAAK,KAAK;CAC1D;CAEA,OAAO,GAAG,MAA2D;EACnE,OAAO,KAAK,aAAa,uBAAuB;CAClD;CAEA,OAAO,OAAO,MAAmE;EAC/E,WAAW,MAAM,8BAA8B,2BAA2B,EAAE;CAC9E;AACF;;;;;;;;;;;;;;;;;;;ACzBA,IAAa,8BAAb,MAAa,oCAAoC,gBAAwC;CACvF,WAA6B,uBAAuB;CAEpD;CACA;CACA;CAEA,YAAY,OAAyC;EACnD,MAAM;EACN,KAAK,aAAa,MAAM;EACxB,KAAK,SAAS,OAAO,OA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uB;CAClD;CAEA,OAAO,OAAO,MAA6E;EACzF,WAAW,MAAM,4BAA4B,yBAAyB,EAAE;CAC1E;AACF;;;;;;;;;;;;;;;ACxEA,IAAa,yBAAb,MAAa,+BAA+B,gBAAwC;CAClF,WAA6B,uBAAuB;CAEpD;CACA;CAEA,YAAY,OAAoC;EAC9C,MAAM;EACN,KAAK,OAAO,MAAM;EAClB,KAAK,cAAc,MAAM;EACzB,WAAW,IAAI;CACjB;CAEA,IAAI,KAAa;EACf,OAAO,KAAK;CACd;CAEA,WAAoC;EAClC,OAAO,CAAC;CACV;CAEA,UAAU,OAA8B;EACtC,MAAM,OAAO,UAGX,KAAK;EACP,uBAAuB,OAAO,IAAI;EAClC,OAAO,KAAK,OAAO,KAAK;CAC1B;CAEA,OAAO,GAAG,MAAuD;EAC/D,OAAO,KAAK,aAAa,uBAAuB;CAClD;CAEA,OAAO,OAAO,MAA+D;EAC3E,WAAW,MAAM,0BAA0B,uBAAuB,EAAE;CACtE;AACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { b as PG_TEXT_CODEC_ID } from "./codec-ids-D3G8K0YM.mjs";
|
|
2
2
|
import { t as PostgresNativeEnum } from "./postgres-native-enum-BwVNf0Ku.mjs";
|
|
3
3
|
import { n as escapeLiteral } from "./sql-utils-SU4FDvIV.mjs";
|
|
4
4
|
import { TableSource } from "@prisma-next/sql-relational-core/ast";
|
|
@@ -421,4 +421,4 @@ function postgresCreateNamespace(input) {
|
|
|
421
421
|
//#endregion
|
|
422
422
|
export { PostgresRlsEnablement as _, nativeEnumEntityKind as a, roleEntityKind as c, PostgresRlsEnablementSchema as d, PostgresRlsPolicySchema as f, PostgresRlsPolicy as g, ROLE_DEFAULT_CONTROL_POLICY as h, postgresCreateNamespace as i, PostgresTableSource as l, PostgresRole as m, PostgresUnboundSchema as n, policyEntityKind as o, PostgresRoleSchema as p, isPostgresSchema as r, rlsEnablementEntityKind as s, PostgresSchema as t, PostgresNativeEnumSchema as u };
|
|
423
423
|
|
|
424
|
-
//# sourceMappingURL=postgres-schema-
|
|
424
|
+
//# sourceMappingURL=postgres-schema-CewLYHB7.mjs.map
|