@prisma-next/target-postgres 0.14.0-dev.61 → 0.14.0-dev.62
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-BLkL4fFG.mjs → authoring-CdIZ0yvD.mjs} +2 -2
- package/dist/{authoring-BLkL4fFG.mjs.map → authoring-CdIZ0yvD.mjs.map} +1 -1
- package/dist/contract-free.d.mts +1 -1
- package/dist/contract-free.d.mts.map +1 -1
- package/dist/contract-free.mjs +2 -2
- package/dist/{control-policy-BpmChlAK.mjs → control-policy-DKp0HKpY.mjs} +180 -45
- package/dist/control-policy-DKp0HKpY.mjs.map +1 -0
- package/dist/control.mjs +21 -25
- package/dist/control.mjs.map +1 -1
- package/dist/{ddl-BovUVFVi.mjs → ddl-gmxHf68z.mjs} +20 -4
- package/dist/{ddl-BovUVFVi.mjs.map → ddl-gmxHf68z.mjs.map} +1 -1
- package/dist/ddl.d.mts +2 -2
- package/dist/ddl.mjs +2 -2
- package/dist/{descriptor-meta-C1T4BXJ8.mjs → descriptor-meta-DEuXJfpR.mjs} +3 -3
- package/dist/{descriptor-meta-C1T4BXJ8.mjs.map → descriptor-meta-DEuXJfpR.mjs.map} +1 -1
- package/dist/{diff-database-schema-RMwnSOnz.mjs → diff-database-schema-D2sjvMw9.mjs} +14 -10
- package/dist/diff-database-schema-D2sjvMw9.mjs.map +1 -0
- package/dist/diff-database-schema.d.mts +1 -1
- package/dist/diff-database-schema.d.mts.map +1 -1
- package/dist/diff-database-schema.mjs +1 -1
- package/dist/issue-planner.d.mts +1 -1
- package/dist/issue-planner.d.mts.map +1 -1
- package/dist/issue-planner.mjs +1 -1
- package/dist/migration.d.mts +2 -2
- package/dist/migration.mjs +2 -2
- package/dist/{nodes-BtQyZha6.d.mts → nodes-Bc2N3tMy.d.mts} +27 -3
- package/dist/nodes-Bc2N3tMy.d.mts.map +1 -0
- package/dist/{nodes-B815pj_X.mjs → nodes-DJC5B8Id.mjs} +32 -2
- package/dist/nodes-DJC5B8Id.mjs.map +1 -0
- package/dist/{op-factory-call-CI00nS4z.mjs → op-factory-call-C4flTtTG.mjs} +105 -6
- package/dist/op-factory-call-C4flTtTG.mjs.map +1 -0
- package/dist/{op-factory-call-D6_7-7Vc.d.mts → op-factory-call-CSIg5XDu.d.mts} +26 -3
- package/dist/{op-factory-call-D6_7-7Vc.d.mts.map → op-factory-call-CSIg5XDu.d.mts.map} +1 -1
- package/dist/op-factory-call.d.mts +2 -2
- package/dist/op-factory-call.mjs +2 -2
- package/dist/pack.mjs +1 -1
- package/dist/{planner-CAHZN1Ez.mjs → planner-BtEd5LMr.mjs} +32 -64
- package/dist/planner-BtEd5LMr.mjs.map +1 -0
- package/dist/{planner-ddl-builders-B8Nn6nHN.mjs → planner-ddl-builders-BKlmGDJl.mjs} +7 -3
- package/dist/planner-ddl-builders-BKlmGDJl.mjs.map +1 -0
- package/dist/planner-ddl-builders.d.mts.map +1 -1
- package/dist/planner-ddl-builders.mjs +1 -1
- package/dist/{planner-produced-postgres-migration-a-tjfKsA.d.mts → planner-produced-postgres-migration-CXue-6M9.d.mts} +2 -2
- package/dist/{planner-produced-postgres-migration-a-tjfKsA.d.mts.map → planner-produced-postgres-migration-CXue-6M9.d.mts.map} +1 -1
- package/dist/{planner-produced-postgres-migration-flkG4Y7n.mjs → planner-produced-postgres-migration-Jat3hg4u.mjs} +2 -2
- package/dist/{planner-produced-postgres-migration-flkG4Y7n.mjs.map → planner-produced-postgres-migration-Jat3hg4u.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-C1-Kk3Eu.mjs → planner-sql-checks-Br1c_QsH.mjs} +3 -3
- package/dist/{planner-sql-checks-C1-Kk3Eu.mjs.map → planner-sql-checks-Br1c_QsH.mjs.map} +1 -1
- package/dist/planner-sql-checks.mjs +1 -1
- package/dist/planner.d.mts +2 -2
- package/dist/planner.d.mts.map +1 -1
- package/dist/planner.mjs +2 -2
- package/dist/{postgres-contract-view-DWLNQbdR.mjs → postgres-contract-view-BAPW0ec1.mjs} +3 -3
- package/dist/{postgres-contract-view-DWLNQbdR.mjs.map → postgres-contract-view-BAPW0ec1.mjs.map} +1 -1
- package/dist/{postgres-database-schema-node-BVdOffjC.d.mts → postgres-database-schema-node-CJv5bfbs.d.mts} +62 -21
- package/dist/postgres-database-schema-node-CJv5bfbs.d.mts.map +1 -0
- package/dist/{postgres-migration-C92swCzd.mjs → postgres-migration-ChLMQRd-.mjs} +19 -3
- package/dist/postgres-migration-ChLMQRd-.mjs.map +1 -0
- package/dist/{postgres-migration-Bzzi0Asr.d.mts → postgres-migration-DkmgGNcv.d.mts} +21 -2
- package/dist/postgres-migration-DkmgGNcv.d.mts.map +1 -0
- package/dist/{postgres-role-schema-node-BmCboEa_.mjs → postgres-role-schema-node-Cm-j0ZGM.mjs} +11 -19
- package/dist/postgres-role-schema-node-Cm-j0ZGM.mjs.map +1 -0
- package/dist/{postgres-schema-COEca21H.mjs → postgres-schema-DWQ0-CPb.mjs} +13 -2
- package/dist/postgres-schema-DWQ0-CPb.mjs.map +1 -0
- package/dist/postgres-schema-DsrtYp2v.d.mts.map +1 -1
- package/dist/{postgres-table-schema-node-9FCtCUz2.mjs → postgres-table-schema-node-D6LvInCe.mjs} +71 -8
- package/dist/postgres-table-schema-node-D6LvInCe.mjs.map +1 -0
- package/dist/{resolve-ddl-schema-ZkKxt2Fm.mjs → resolve-ddl-schema-CAza65Iy.mjs} +2 -2
- package/dist/{resolve-ddl-schema-ZkKxt2Fm.mjs.map → resolve-ddl-schema-CAza65Iy.mjs.map} +1 -1
- package/dist/runtime.mjs +1 -1
- package/dist/schema-ir-annotations.mjs +1 -1
- 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 +2 -2
- package/dist/types.mjs +4 -4
- package/package.json +20 -20
- package/src/contract-free/ddl.ts +27 -0
- package/src/core/ddl/nodes.ts +44 -0
- package/src/core/migrations/contract-to-postgres-database-schema-node.ts +12 -1
- package/src/core/migrations/control-policy.ts +143 -45
- package/src/core/migrations/diff-database-schema.ts +1 -2
- package/src/core/migrations/issue-planner.ts +77 -4
- package/src/core/migrations/op-factory-call.ts +84 -0
- package/src/core/migrations/operations/native-enum-types.ts +62 -0
- package/src/core/migrations/planner-ddl-builders.ts +12 -2
- package/src/core/migrations/planner.ts +25 -62
- package/src/core/migrations/postgres-migration.ts +31 -0
- package/src/core/migrations/verify-postgres-namespaces.ts +0 -1
- package/src/core/postgres-schema.ts +22 -1
- package/src/core/psl-infer/infer-psl-contract.ts +6 -16
- package/src/core/schema-ir/node-storage-coordinate.ts +26 -0
- package/src/core/schema-ir/postgres-namespace-schema-node.ts +18 -27
- package/src/core/schema-ir/postgres-native-enum-schema-node.ts +83 -0
- package/src/core/schema-ir/schema-node-kinds.ts +12 -3
- package/src/core/sql-utils.ts +15 -2
- package/src/exports/ddl.ts +2 -0
- package/src/exports/op-factory-call.ts +2 -0
- package/src/exports/sql-utils.ts +1 -0
- package/src/exports/types.ts +4 -1
- package/dist/control-policy-BpmChlAK.mjs.map +0 -1
- package/dist/diff-database-schema-RMwnSOnz.mjs.map +0 -1
- package/dist/nodes-B815pj_X.mjs.map +0 -1
- package/dist/nodes-BtQyZha6.d.mts.map +0 -1
- package/dist/op-factory-call-CI00nS4z.mjs.map +0 -1
- package/dist/planner-CAHZN1Ez.mjs.map +0 -1
- package/dist/planner-ddl-builders-B8Nn6nHN.mjs.map +0 -1
- package/dist/postgres-database-schema-node-BVdOffjC.d.mts.map +0 -1
- package/dist/postgres-migration-Bzzi0Asr.d.mts.map +0 -1
- package/dist/postgres-migration-C92swCzd.mjs.map +0 -1
- package/dist/postgres-role-schema-node-BmCboEa_.mjs.map +0 -1
- package/dist/postgres-schema-COEca21H.mjs.map +0 -1
- package/dist/postgres-table-schema-node-9FCtCUz2.mjs.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as PG_ENUM_CODEC_ID } from "./codec-ids-C_-Hj6bL.mjs";
|
|
2
2
|
import { t as PostgresNativeEnum } from "./postgres-native-enum-xdiqmBf_.mjs";
|
|
3
|
-
import { _ as PostgresRlsEnablement, d as PostgresRlsEnablementSchema, f as PostgresRlsPolicySchema, g as PostgresRlsPolicy, m as PostgresRole, p as PostgresRoleSchema, u as PostgresNativeEnumSchema } from "./postgres-schema-
|
|
3
|
+
import { _ as PostgresRlsEnablement, d as PostgresRlsEnablementSchema, f as PostgresRlsPolicySchema, g as PostgresRlsPolicy, m as PostgresRole, p as PostgresRoleSchema, u as PostgresNativeEnumSchema } from "./postgres-schema-DWQ0-CPb.mjs";
|
|
4
4
|
import { i as normalizePredicate, r as computeContentHash, t as formatRlsPolicyWireName } from "./wire-name-rHHtr1h0.mjs";
|
|
5
5
|
import { temporalAuthoringPresets } from "@prisma-next/family-sql/control";
|
|
6
6
|
import { ifDefined } from "@prisma-next/utils/defined";
|
|
@@ -525,4 +525,4 @@ const postgresAuthoringFieldPresets = {
|
|
|
525
525
|
//#endregion
|
|
526
526
|
export { postgresAuthoringTypes as a, postgresAuthoringPslBlockDescriptors as i, postgresAuthoringFieldPresets as n, postgresAuthoringModelAttributes as r, postgresAuthoringEntityTypes as t };
|
|
527
527
|
|
|
528
|
-
//# sourceMappingURL=authoring-
|
|
528
|
+
//# sourceMappingURL=authoring-CdIZ0yvD.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authoring-BLkL4fFG.mjs","names":[],"sources":["../src/core/authoring.ts"],"sourcesContent":["import { temporalAuthoringPresets } from '@prisma-next/family-sql/control';\nimport type {\n AuthoringEntityContext,\n AuthoringEntityTypeFactoryOutput,\n AuthoringEntityTypeNamespace,\n AuthoringFieldNamespace,\n AuthoringModelAttributeContext,\n AuthoringModelAttributeDescriptorNamespace,\n AuthoringPslBlockDescriptorNamespace,\n AuthoringTypeNamespace,\n PslExtensionBlock,\n} from '@prisma-next/framework-components/authoring';\nimport { modelAttribute } from '@prisma-next/psl-parser';\nimport type { SqlValueSetDerivingEntityTypeOutput } from '@prisma-next/sql-contract/value-set-derivation-hook';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport { PG_ENUM_CODEC_ID } from './codec-ids';\nimport { PostgresNativeEnum } from './postgres-native-enum';\nimport { PostgresRlsEnablement, type PostgresRlsEnablementInput } from './postgres-rls-enablement';\nimport { PostgresRlsPolicy, type RlsPolicyOperation } from './postgres-rls-policy';\nimport { PostgresRole, type PostgresRoleInput } from './postgres-role';\nimport {\n PostgresNativeEnumSchema,\n PostgresRlsEnablementSchema,\n PostgresRlsPolicySchema,\n PostgresRoleSchema,\n} from './postgres-validators';\nimport { computeContentHash, normalizePredicate } from './rls/canonicalize';\nimport { formatRlsPolicyWireName } from './rls/wire-name';\n\n/**\n * `pg.enum(<ref>)` registers as an ordinary type constructor whose sole\n * positional argument names a `native_enum` entity instead of carrying a\n * literal value. The interpreter resolves the ref to the `native_enum`\n * entity generically (driven by `entityRefArg`); the `pg/enum@1` codec\n * descriptor's `columnFromEntity` hook (see `codecs.ts`) converts that\n * entity into the column's `typeParams` and native type.\n */\nexport const postgresAuthoringTypes = {\n pg: {\n enum: {\n kind: 'typeConstructor',\n entityRefArg: { index: 0, entityKind: 'native_enum' },\n output: {\n codecId: PG_ENUM_CODEC_ID,\n },\n },\n },\n} as const satisfies AuthoringTypeNamespace;\n\nexport interface RlsPolicyExtensionBlock extends PslExtensionBlock {\n readonly namespaceId: string;\n}\n\n/**\n * Maps a `policy_<op>` keyword to the RLS operation it authors. The keyword\n * IS the operation (per the project's rejection of a `policy { operation = … }`\n * conditional block).\n */\nconst POLICY_KEYWORD_OPERATION: Readonly<Record<string, RlsPolicyOperation>> = {\n policy_select: 'select',\n policy_insert: 'insert',\n policy_update: 'update',\n policy_delete: 'delete',\n policy_all: 'all',\n};\n\n/**\n * Which predicate each RLS operation admits, mirroring Postgres: SELECT and\n * DELETE decide row visibility/eligibility with `USING` only; INSERT validates\n * the new row with `WITH CHECK` only; UPDATE and ALL take both. A predicate\n * outside this set is a load-time error (see {@link lowerRlsPolicyFromBlock}).\n */\nconst POLICY_OPERATION_PREDICATES: Readonly<\n Record<RlsPolicyOperation, { readonly using: boolean; readonly withCheck: boolean }>\n> = {\n select: { using: true, withCheck: false },\n insert: { using: false, withCheck: true },\n update: { using: true, withCheck: true },\n delete: { using: true, withCheck: false },\n all: { using: true, withCheck: true },\n};\n\nfunction readRefParam(block: PslExtensionBlock, key: string): string | undefined {\n const param = block.parameters[key];\n return param?.kind === 'ref' ? param.identifier : undefined;\n}\n\nfunction readValueParam(block: PslExtensionBlock, key: string): string | undefined {\n const param = block.parameters[key];\n return param?.kind === 'value' ? param.raw : undefined;\n}\n\nfunction readListRefParams(block: PslExtensionBlock, key: string): string[] {\n const param = block.parameters[key];\n if (param?.kind !== 'list') return [];\n return param.items.flatMap((item) => (item.kind === 'ref' ? [item.identifier] : []));\n}\n\n/**\n * Unwraps a quoted PSL string argument, inverting the printer's\n * `escapePslString` escapes (`\\\\`, `\\\"`, `\\n`, `\\r`). An unknown escape\n * sequence is kept verbatim, matching the printer-side `unescapePslString`\n * convention.\n */\nfunction unwrapQuotedString(raw: string): string {\n if (!(raw.startsWith('\"') && raw.endsWith('\"') && raw.length >= 2)) {\n return raw;\n }\n const inner = raw.slice(1, -1);\n let result = '';\n for (let i = 0; i < inner.length; i++) {\n if (inner[i] !== '\\\\' || i + 1 >= inner.length) {\n result += inner[i];\n continue;\n }\n const next = inner[i + 1];\n if (next === '\\\\' || next === '\"') {\n result += next;\n } else if (next === 'n') {\n result += '\\n';\n } else if (next === 'r') {\n result += '\\r';\n } else {\n result += '\\\\';\n result += next;\n }\n i++;\n }\n return result;\n}\n\nfunction lowerRlsPolicyFromBlock(\n block: RlsPolicyExtensionBlock,\n ctx: AuthoringEntityContext,\n): PostgresRlsPolicy | undefined {\n const prefix = block.name;\n const operation = POLICY_KEYWORD_OPERATION[block.keyword] ?? 'select';\n const targetModelName = readRefParam(block, 'target') ?? '';\n const tableName = targetModelName.charAt(0).toLowerCase() + targetModelName.slice(1);\n const roles = [...readListRefParams(block, 'roles')].sort();\n\n const usingRaw = readValueParam(block, 'using');\n const withCheckRaw = readValueParam(block, 'withCheck');\n\n // Reject a predicate the operation does not take (e.g. `using` on INSERT, or\n // `withCheck` on SELECT/DELETE). The descriptor's param set already omits it,\n // but the generic descriptor validator is not wired into the SQL-family\n // interpreter, so the lowering enforces the per-operation predicate matrix\n // directly — a wrong predicate is a load-time diagnostic, not a silent drop.\n const support = POLICY_OPERATION_PREDICATES[operation];\n const rejectPredicate = (predicate: 'using' | 'withCheck'): undefined => {\n ctx.diagnostics?.push({\n code: 'PSL_RLS_PREDICATE_NOT_FOR_OPERATION',\n message: `\\`${block.keyword}\\` policy \"${block.name}\" does not take a \\`${predicate}\\` predicate; the ${operation.toUpperCase()} operation uses ${support.using ? '`using`' : '`withCheck`'}${support.using && support.withCheck ? ' and `withCheck`' : ' only'}.`,\n sourceId: ctx.sourceId ?? 'unknown',\n span: block.parameters[predicate]?.span ?? block.span,\n });\n return undefined;\n };\n if (usingRaw !== undefined && !support.using) return rejectPredicate('using');\n if (withCheckRaw !== undefined && !support.withCheck) return rejectPredicate('withCheck');\n\n const using = usingRaw !== undefined ? unwrapQuotedString(usingRaw) : undefined;\n const withCheck = withCheckRaw !== undefined ? unwrapQuotedString(withCheckRaw) : undefined;\n\n const wireHash = computeContentHash({\n ...ifDefined('using', using !== undefined ? normalizePredicate(using) : undefined),\n ...ifDefined('withCheck', withCheck !== undefined ? normalizePredicate(withCheck) : undefined),\n roles,\n operation,\n permissive: true,\n });\n const wireName = formatRlsPolicyWireName(prefix, wireHash);\n\n return new PostgresRlsPolicy({\n name: wireName,\n prefix,\n tableName,\n namespaceId: block.namespaceId,\n operation,\n roles,\n ...ifDefined('using', using),\n ...ifDefined('withCheck', withCheck),\n permissive: true,\n });\n}\n\n/**\n * Lowers a `native_enum { memberName = \"value\" … @@map(\"type_name\") }` block\n * into a {@link PostgresNativeEnum}. Members must be authored as explicit\n * `key = \"value\"` pairs — a bare (value-less) member is a diagnostic, not\n * accepted (authoring-design.md §2.1). The parsed `memberName` is only used\n * to duplicate-check and report diagnostics; the lowered entity carries just\n * the member values (a native enum is value-only — the member \"name\" isn't\n * a separate authoring concept from the value). `typeName` comes from\n * `@@map` or defaults to the block name verbatim.\n */\nfunction lowerNativeEnumFromBlock(\n block: PslExtensionBlock,\n ctx: AuthoringEntityContext,\n): PostgresNativeEnum | undefined {\n const sourceId = ctx.sourceId ?? 'unknown';\n const diagnostics = ctx.diagnostics;\n\n const mapAttr = block.blockAttributes.find((a) => a.name === 'map');\n let typeName = block.name;\n if (mapAttr) {\n const rawArg = mapAttr.args[0]?.value;\n const mapped = rawArg !== undefined ? unwrapQuotedString(rawArg) : undefined;\n if (mapped === undefined) {\n diagnostics?.push({\n code: 'PSL_NATIVE_ENUM_INVALID_MAP',\n message: `native_enum \"${block.name}\" @@map attribute must have a quoted type-name argument`,\n sourceId,\n span: mapAttr.span,\n });\n return undefined;\n }\n typeName = mapped;\n }\n\n let memberError = false;\n const seenValues = new Set<string>();\n const members: string[] = [];\n for (const [memberName, paramValue] of Object.entries(block.parameters)) {\n if (paramValue.kind === 'bare') {\n diagnostics?.push({\n code: 'PSL_NATIVE_ENUM_BARE_MEMBER',\n message: `native_enum \"${block.name}\" member \"${memberName}\" has no value; members must be authored as \"${memberName} = \\\\\"value\\\\\"\"`,\n sourceId,\n span: paramValue.span,\n });\n memberError = true;\n continue;\n }\n if (paramValue.kind !== 'value') continue;\n\n let jsonValue: unknown;\n try {\n jsonValue = JSON.parse(paramValue.raw);\n } catch {\n diagnostics?.push({\n code: 'PSL_EXTENSION_INVALID_VALUE',\n message: `native_enum \"${block.name}\" member \"${memberName}\" value \"${paramValue.raw}\" is not valid JSON`,\n sourceId,\n span: paramValue.span,\n });\n memberError = true;\n continue;\n }\n if (typeof jsonValue !== 'string') {\n diagnostics?.push({\n code: 'PSL_EXTENSION_INVALID_VALUE',\n message: `native_enum \"${block.name}\" member \"${memberName}\" value must be a string`,\n sourceId,\n span: paramValue.span,\n });\n memberError = true;\n continue;\n }\n if (seenValues.has(jsonValue)) {\n diagnostics?.push({\n code: 'PSL_NATIVE_ENUM_DUPLICATE_MEMBER_VALUE',\n message: `native_enum \"${block.name}\": duplicate member value \"${jsonValue}\"`,\n sourceId,\n span: paramValue.span,\n });\n memberError = true;\n continue;\n }\n seenValues.add(jsonValue);\n members.push(jsonValue);\n }\n\n if (memberError) return undefined;\n\n if (members.length === 0) {\n diagnostics?.push({\n code: 'PSL_NATIVE_ENUM_MISSING_MEMBERS',\n message: `native_enum \"${block.name}\" must have at least one member`,\n sourceId,\n span: block.span,\n });\n return undefined;\n }\n\n // `control` stays unset — the effective grade is resolved at read time via `effectiveControlPolicy`, like `StorageTable`/`StorageColumn`.\n return new PostgresNativeEnum({ typeName, members });\n}\n\n/**\n * `native_enum`'s entity-type factory output, checked separately from the assembled\n * `postgresAuthoringEntityTypes` map below: `deriveValueSet` is SQL-family surface\n * ({@link SqlValueSetDerivingEntityTypeOutput}), not part of the framework\n * `AuthoringEntityTypeFactoryOutput` shape, so folding it directly into the map's single\n * `satisfies AuthoringEntityTypeNamespace` check would trip an excess-property error. Checking it\n * here against the intersection of both shapes keeps it structurally valid against each without\n * widening the map's own check.\n */\nconst nativeEnumEntityTypeOutput = {\n factory: lowerNativeEnumFromBlock,\n deriveValueSet: (entity: PostgresNativeEnum) => ({\n kind: 'valueSet' as const,\n values: [...entity.members],\n }),\n} satisfies AuthoringEntityTypeFactoryOutput<PslExtensionBlock, PostgresNativeEnum | undefined> &\n SqlValueSetDerivingEntityTypeOutput;\n\nexport const postgresAuthoringEntityTypes = {\n role: {\n kind: 'entity',\n discriminator: 'role',\n validatorSchema: PostgresRoleSchema,\n output: {\n factory: (input: PostgresRoleInput): PostgresRole => new PostgresRole(input),\n },\n },\n rls: {\n kind: 'entity',\n discriminator: 'rls',\n validatorSchema: PostgresRlsEnablementSchema,\n output: {\n factory: (input: PostgresRlsEnablementInput): PostgresRlsEnablement =>\n new PostgresRlsEnablement(input),\n },\n },\n policy: {\n kind: 'entity',\n discriminator: 'policy',\n validatorSchema: PostgresRlsPolicySchema,\n output: {\n factory: lowerRlsPolicyFromBlock,\n },\n },\n native_enum: {\n kind: 'entity',\n discriminator: 'native_enum',\n validatorSchema: PostgresNativeEnumSchema,\n output: nativeEnumEntityTypeOutput,\n },\n} as const satisfies AuthoringEntityTypeNamespace;\n\n/**\n * Field presets contributed by the Postgres target pack.\n *\n * These mirror the PSL scalar-to-codec mapping used by the Postgres adapter\n * (see `createPostgresPslScalarTypeDescriptors`), so that authoring a field\n * via the TS callback surface (e.g. `field.int()`) and via the PSL scalar\n * surface (e.g. `Int`) lowers to byte-identical contracts.\n *\n * The `uuidNative` / `id.uuidv4Native` / `id.uuidv7Native` presets use the\n * native Postgres `uuid` type (codecId `pg/uuid@1`). For cross-target\n * portability use `uuidString` / `id.uuidv4String` / `id.uuidv7String` from\n * the family pack instead.\n */\n/**\n * Shared parameter descriptors for the five `policy_<op>` PSL block\n * keywords. All five share the `policy` discriminator — the parser\n * dispatches by keyword (see the framework's PSL-block SPI), and every\n * keyword's factory lowers to `PostgresRlsPolicy` via `lowerRlsPolicyFromBlock`.\n *\n * The `roles` list uses `scope:'cross-space'` because same-namespace\n * role ref resolution requires PSL namespace entries keyed by `refKind`\n * (i.e. `'role'`), which in turn requires the role block discriminator to\n * equal `'role'`. Aligning discriminator with refKind is tracked for\n * slice 4 (cross-space roles). Until then cross-space passes validation\n * unconditionally and the authored role names flow through unchanged.\n */\nconst policyTargetParam = {\n kind: 'ref',\n refKind: 'model',\n scope: 'same-namespace',\n required: true,\n} as const;\nconst policyRolesParam = {\n kind: 'list',\n of: { kind: 'ref', refKind: 'role', scope: 'cross-space' },\n} as const;\nconst policyPredicateParam = { kind: 'value', codecId: 'pg/text@1', required: true } as const;\n// A policy may only target an RLS-controlled model: the model named by\n// `target` must declare `@@rls`, or the load fails with a diagnostic naming\n// the model and the policy prefix.\nconst policyRequiresRls = { parameter: 'target', attribute: 'rls' } as const;\n\nexport const postgresAuthoringPslBlockDescriptors = {\n // The predicate param set per keyword mirrors Postgres: SELECT/DELETE take\n // USING only; INSERT takes WITH CHECK only; UPDATE/ALL take both. The\n // per-operation predicate matrix is enforced in `lowerRlsPolicyFromBlock`\n // (a wrong predicate for the operation is a load-time diagnostic there),\n // since the generic descriptor validator is not wired into the SQL-family\n // interpreter.\n policy_select: {\n kind: 'pslBlock',\n keyword: 'policy_select',\n discriminator: 'policy',\n name: { required: true },\n parameters: { target: policyTargetParam, roles: policyRolesParam, using: policyPredicateParam },\n requiresModelAttribute: policyRequiresRls,\n },\n policy_delete: {\n kind: 'pslBlock',\n keyword: 'policy_delete',\n discriminator: 'policy',\n name: { required: true },\n parameters: { target: policyTargetParam, roles: policyRolesParam, using: policyPredicateParam },\n requiresModelAttribute: policyRequiresRls,\n },\n policy_insert: {\n kind: 'pslBlock',\n keyword: 'policy_insert',\n discriminator: 'policy',\n name: { required: true },\n parameters: {\n target: policyTargetParam,\n roles: policyRolesParam,\n withCheck: policyPredicateParam,\n },\n requiresModelAttribute: policyRequiresRls,\n },\n policy_update: {\n kind: 'pslBlock',\n keyword: 'policy_update',\n discriminator: 'policy',\n name: { required: true },\n parameters: {\n target: policyTargetParam,\n roles: policyRolesParam,\n using: policyPredicateParam,\n withCheck: policyPredicateParam,\n },\n requiresModelAttribute: policyRequiresRls,\n },\n policy_all: {\n kind: 'pslBlock',\n keyword: 'policy_all',\n discriminator: 'policy',\n name: { required: true },\n parameters: {\n target: policyTargetParam,\n roles: policyRolesParam,\n using: policyPredicateParam,\n withCheck: policyPredicateParam,\n },\n requiresModelAttribute: policyRequiresRls,\n },\n /**\n * PSL block descriptor for `native_enum`.\n *\n * Reuses the existing variadic-block mechanism (the same shape the SQL\n * family's `enum` block ships): the body is an open `memberName = \"value\"`\n * list. `variadicParameters: true` opens the block to arbitrary keys\n * beyond the declared (empty) `parameters` set — the lowering factory\n * (`lowerNativeEnumFromBlock`) turns the variadic entries into ordered\n * members and rejects a bare (value-less) member.\n */\n native_enum: {\n kind: 'pslBlock',\n keyword: 'native_enum',\n discriminator: 'native_enum',\n name: { required: true },\n parameters: {},\n variadicParameters: true,\n },\n} as const satisfies AuthoringPslBlockDescriptorNamespace;\n\n/**\n * `@@` model attributes contributed by the Postgres target pack.\n *\n * `@@rls` is argument-less: presence marks the model's table\n * RLS-controlled. It lowers to a {@link PostgresRlsEnablement} marker in\n * the namespace's `entries.rls`, keyed by the model's table name — the\n * marker (never the policy set) is what drives\n * `ENABLE`/`DISABLE ROW LEVEL SECURITY` planning.\n */\nexport const postgresAuthoringModelAttributes = {\n rls: {\n kind: 'modelAttribute',\n attribute: 'rls',\n spec: modelAttribute('rls', {}),\n lower: (_parsed: Record<never, never>, ctx: AuthoringModelAttributeContext) => ({\n key: ctx.storageName,\n entity: new PostgresRlsEnablement({\n tableName: ctx.storageName,\n namespaceId: ctx.namespaceId,\n }),\n }),\n },\n} as const satisfies AuthoringModelAttributeDescriptorNamespace;\n\nexport const postgresAuthoringFieldPresets = {\n text: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/text@1',\n nativeType: 'text',\n },\n },\n int: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/int4@1',\n nativeType: 'int4',\n },\n },\n bigint: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/int8@1',\n nativeType: 'int8',\n },\n },\n float: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/float8@1',\n nativeType: 'float8',\n },\n },\n decimal: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/numeric@1',\n nativeType: 'numeric',\n },\n },\n boolean: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/bool@1',\n nativeType: 'bool',\n },\n },\n json: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/jsonb@1',\n nativeType: 'jsonb',\n },\n },\n bytes: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/bytea@1',\n nativeType: 'bytea',\n },\n },\n dateTime: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/timestamptz@1',\n nativeType: 'timestamptz',\n },\n },\n temporal: /* @__PURE__ */ temporalAuthoringPresets({\n codecId: 'pg/timestamptz@1',\n nativeType: 'timestamptz',\n }),\n uuidNative: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/uuid@1',\n nativeType: 'uuid',\n },\n },\n id: {\n uuidv4Native: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/uuid@1',\n nativeType: 'uuid',\n executionDefaults: {\n onCreate: {\n kind: 'generator',\n id: 'uuidv4',\n },\n },\n id: true,\n },\n },\n uuidv7Native: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/uuid@1',\n nativeType: 'uuid',\n executionDefaults: {\n onCreate: {\n kind: 'generator',\n id: 'uuidv7',\n },\n },\n id: true,\n },\n },\n },\n} as const satisfies AuthoringFieldNamespace;\n"],"mappings":";;;;;;;;;;;;;;;;AAqCA,MAAa,yBAAyB,EACpC,IAAI,EACF,MAAM;CACJ,MAAM;CACN,cAAc;EAAE,OAAO;EAAG,YAAY;CAAc;CACpD,QAAQ,EACN,SAAS,iBACX;AACF,EACF,EACF;;;;;;AAWA,MAAM,2BAAyE;CAC7E,eAAe;CACf,eAAe;CACf,eAAe;CACf,eAAe;CACf,YAAY;AACd;;;;;;;AAQA,MAAM,8BAEF;CACF,QAAQ;EAAE,OAAO;EAAM,WAAW;CAAM;CACxC,QAAQ;EAAE,OAAO;EAAO,WAAW;CAAK;CACxC,QAAQ;EAAE,OAAO;EAAM,WAAW;CAAK;CACvC,QAAQ;EAAE,OAA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MAAM;EACN,QAAQ;GACN,SAAS;GACT,YAAY;EACd;CACF;CACA,OAAO;EACL,MAAM;EACN,QAAQ;GACN,SAAS;GACT,YAAY;EACd;CACF;CACA,SAAS;EACP,MAAM;EACN,QAAQ;GACN,SAAS;GACT,YAAY;EACd;CACF;CACA,SAAS;EACP,MAAM;EACN,QAAQ;GACN,SAAS;GACT,YAAY;EACd;CACF;CACA,MAAM;EACJ,MAAM;EACN,QAAQ;GACN,SAAS;GACT,YAAY;EACd;CACF;CACA,OAAO;EACL,MAAM;EACN,QAAQ;GACN,SAAS;GACT,YAAY;EACd;CACF;CACA,UAAU;EACR,MAAM;EACN,QAAQ;GACN,SAAS;GACT,YAAY;EACd;CACF;CACA,UAA0B,yCAAyB;EACjD,SAAS;EACT,YAAY;CACd,CAAC;CACD,YAAY;EACV,MAAM;EACN,QAAQ;GACN,SAAS;GACT,YAAY;EACd;CACF;CACA,IAAI;EACF,cAAc;GACZ,MAAM;GACN,QAAQ;IACN,SAAS;IACT,YAAY;IACZ,mBAAmB,EACjB,UAAU;KACR,MAAM;KACN,IAAI;IACN,EACF;IACA,IAAI;GACN;EACF;EACA,cAAc;GACZ,MAAM;GACN,QAAQ;IACN,SAAS;IACT,YAAY;IACZ,mBAAmB,EACjB,UAAU;KACR,MAAM;KACN,IAAI;IACN,EACF;IACA,IAAI;GACN;EACF;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"authoring-CdIZ0yvD.mjs","names":[],"sources":["../src/core/authoring.ts"],"sourcesContent":["import { temporalAuthoringPresets } from '@prisma-next/family-sql/control';\nimport type {\n AuthoringEntityContext,\n AuthoringEntityTypeFactoryOutput,\n AuthoringEntityTypeNamespace,\n AuthoringFieldNamespace,\n AuthoringModelAttributeContext,\n AuthoringModelAttributeDescriptorNamespace,\n AuthoringPslBlockDescriptorNamespace,\n AuthoringTypeNamespace,\n PslExtensionBlock,\n} from '@prisma-next/framework-components/authoring';\nimport { modelAttribute } from '@prisma-next/psl-parser';\nimport type { SqlValueSetDerivingEntityTypeOutput } from '@prisma-next/sql-contract/value-set-derivation-hook';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport { PG_ENUM_CODEC_ID } from './codec-ids';\nimport { PostgresNativeEnum } from './postgres-native-enum';\nimport { PostgresRlsEnablement, type PostgresRlsEnablementInput } from './postgres-rls-enablement';\nimport { PostgresRlsPolicy, type RlsPolicyOperation } from './postgres-rls-policy';\nimport { PostgresRole, type PostgresRoleInput } from './postgres-role';\nimport {\n PostgresNativeEnumSchema,\n PostgresRlsEnablementSchema,\n PostgresRlsPolicySchema,\n PostgresRoleSchema,\n} from './postgres-validators';\nimport { computeContentHash, normalizePredicate } from './rls/canonicalize';\nimport { formatRlsPolicyWireName } from './rls/wire-name';\n\n/**\n * `pg.enum(<ref>)` registers as an ordinary type constructor whose sole\n * positional argument names a `native_enum` entity instead of carrying a\n * literal value. The interpreter resolves the ref to the `native_enum`\n * entity generically (driven by `entityRefArg`); the `pg/enum@1` codec\n * descriptor's `columnFromEntity` hook (see `codecs.ts`) converts that\n * entity into the column's `typeParams` and native type.\n */\nexport const postgresAuthoringTypes = {\n pg: {\n enum: {\n kind: 'typeConstructor',\n entityRefArg: { index: 0, entityKind: 'native_enum' },\n output: {\n codecId: PG_ENUM_CODEC_ID,\n },\n },\n },\n} as const satisfies AuthoringTypeNamespace;\n\nexport interface RlsPolicyExtensionBlock extends PslExtensionBlock {\n readonly namespaceId: string;\n}\n\n/**\n * Maps a `policy_<op>` keyword to the RLS operation it authors. The keyword\n * IS the operation (per the project's rejection of a `policy { operation = … }`\n * conditional block).\n */\nconst POLICY_KEYWORD_OPERATION: Readonly<Record<string, RlsPolicyOperation>> = {\n policy_select: 'select',\n policy_insert: 'insert',\n policy_update: 'update',\n policy_delete: 'delete',\n policy_all: 'all',\n};\n\n/**\n * Which predicate each RLS operation admits, mirroring Postgres: SELECT and\n * DELETE decide row visibility/eligibility with `USING` only; INSERT validates\n * the new row with `WITH CHECK` only; UPDATE and ALL take both. A predicate\n * outside this set is a load-time error (see {@link lowerRlsPolicyFromBlock}).\n */\nconst POLICY_OPERATION_PREDICATES: Readonly<\n Record<RlsPolicyOperation, { readonly using: boolean; readonly withCheck: boolean }>\n> = {\n select: { using: true, withCheck: false },\n insert: { using: false, withCheck: true },\n update: { using: true, withCheck: true },\n delete: { using: true, withCheck: false },\n all: { using: true, withCheck: true },\n};\n\nfunction readRefParam(block: PslExtensionBlock, key: string): string | undefined {\n const param = block.parameters[key];\n return param?.kind === 'ref' ? param.identifier : undefined;\n}\n\nfunction readValueParam(block: PslExtensionBlock, key: string): string | undefined {\n const param = block.parameters[key];\n return param?.kind === 'value' ? param.raw : undefined;\n}\n\nfunction readListRefParams(block: PslExtensionBlock, key: string): string[] {\n const param = block.parameters[key];\n if (param?.kind !== 'list') return [];\n return param.items.flatMap((item) => (item.kind === 'ref' ? [item.identifier] : []));\n}\n\n/**\n * Unwraps a quoted PSL string argument, inverting the printer's\n * `escapePslString` escapes (`\\\\`, `\\\"`, `\\n`, `\\r`). An unknown escape\n * sequence is kept verbatim, matching the printer-side `unescapePslString`\n * convention.\n */\nfunction unwrapQuotedString(raw: string): string {\n if (!(raw.startsWith('\"') && raw.endsWith('\"') && raw.length >= 2)) {\n return raw;\n }\n const inner = raw.slice(1, -1);\n let result = '';\n for (let i = 0; i < inner.length; i++) {\n if (inner[i] !== '\\\\' || i + 1 >= inner.length) {\n result += inner[i];\n continue;\n }\n const next = inner[i + 1];\n if (next === '\\\\' || next === '\"') {\n result += next;\n } else if (next === 'n') {\n result += '\\n';\n } else if (next === 'r') {\n result += '\\r';\n } else {\n result += '\\\\';\n result += next;\n }\n i++;\n }\n return result;\n}\n\nfunction lowerRlsPolicyFromBlock(\n block: RlsPolicyExtensionBlock,\n ctx: AuthoringEntityContext,\n): PostgresRlsPolicy | undefined {\n const prefix = block.name;\n const operation = POLICY_KEYWORD_OPERATION[block.keyword] ?? 'select';\n const targetModelName = readRefParam(block, 'target') ?? '';\n const tableName = targetModelName.charAt(0).toLowerCase() + targetModelName.slice(1);\n const roles = [...readListRefParams(block, 'roles')].sort();\n\n const usingRaw = readValueParam(block, 'using');\n const withCheckRaw = readValueParam(block, 'withCheck');\n\n // Reject a predicate the operation does not take (e.g. `using` on INSERT, or\n // `withCheck` on SELECT/DELETE). The descriptor's param set already omits it,\n // but the generic descriptor validator is not wired into the SQL-family\n // interpreter, so the lowering enforces the per-operation predicate matrix\n // directly — a wrong predicate is a load-time diagnostic, not a silent drop.\n const support = POLICY_OPERATION_PREDICATES[operation];\n const rejectPredicate = (predicate: 'using' | 'withCheck'): undefined => {\n ctx.diagnostics?.push({\n code: 'PSL_RLS_PREDICATE_NOT_FOR_OPERATION',\n message: `\\`${block.keyword}\\` policy \"${block.name}\" does not take a \\`${predicate}\\` predicate; the ${operation.toUpperCase()} operation uses ${support.using ? '`using`' : '`withCheck`'}${support.using && support.withCheck ? ' and `withCheck`' : ' only'}.`,\n sourceId: ctx.sourceId ?? 'unknown',\n span: block.parameters[predicate]?.span ?? block.span,\n });\n return undefined;\n };\n if (usingRaw !== undefined && !support.using) return rejectPredicate('using');\n if (withCheckRaw !== undefined && !support.withCheck) return rejectPredicate('withCheck');\n\n const using = usingRaw !== undefined ? unwrapQuotedString(usingRaw) : undefined;\n const withCheck = withCheckRaw !== undefined ? unwrapQuotedString(withCheckRaw) : undefined;\n\n const wireHash = computeContentHash({\n ...ifDefined('using', using !== undefined ? normalizePredicate(using) : undefined),\n ...ifDefined('withCheck', withCheck !== undefined ? normalizePredicate(withCheck) : undefined),\n roles,\n operation,\n permissive: true,\n });\n const wireName = formatRlsPolicyWireName(prefix, wireHash);\n\n return new PostgresRlsPolicy({\n name: wireName,\n prefix,\n tableName,\n namespaceId: block.namespaceId,\n operation,\n roles,\n ...ifDefined('using', using),\n ...ifDefined('withCheck', withCheck),\n permissive: true,\n });\n}\n\n/**\n * Lowers a `native_enum { memberName = \"value\" … @@map(\"type_name\") }` block\n * into a {@link PostgresNativeEnum}. Members must be authored as explicit\n * `key = \"value\"` pairs — a bare (value-less) member is a diagnostic, not\n * accepted (authoring-design.md §2.1). The parsed `memberName` is only used\n * to duplicate-check and report diagnostics; the lowered entity carries just\n * the member values (a native enum is value-only — the member \"name\" isn't\n * a separate authoring concept from the value). `typeName` comes from\n * `@@map` or defaults to the block name verbatim.\n */\nfunction lowerNativeEnumFromBlock(\n block: PslExtensionBlock,\n ctx: AuthoringEntityContext,\n): PostgresNativeEnum | undefined {\n const sourceId = ctx.sourceId ?? 'unknown';\n const diagnostics = ctx.diagnostics;\n\n const mapAttr = block.blockAttributes.find((a) => a.name === 'map');\n let typeName = block.name;\n if (mapAttr) {\n const rawArg = mapAttr.args[0]?.value;\n const mapped = rawArg !== undefined ? unwrapQuotedString(rawArg) : undefined;\n if (mapped === undefined) {\n diagnostics?.push({\n code: 'PSL_NATIVE_ENUM_INVALID_MAP',\n message: `native_enum \"${block.name}\" @@map attribute must have a quoted type-name argument`,\n sourceId,\n span: mapAttr.span,\n });\n return undefined;\n }\n typeName = mapped;\n }\n\n let memberError = false;\n const seenValues = new Set<string>();\n const members: string[] = [];\n for (const [memberName, paramValue] of Object.entries(block.parameters)) {\n if (paramValue.kind === 'bare') {\n diagnostics?.push({\n code: 'PSL_NATIVE_ENUM_BARE_MEMBER',\n message: `native_enum \"${block.name}\" member \"${memberName}\" has no value; members must be authored as \"${memberName} = \\\\\"value\\\\\"\"`,\n sourceId,\n span: paramValue.span,\n });\n memberError = true;\n continue;\n }\n if (paramValue.kind !== 'value') continue;\n\n let jsonValue: unknown;\n try {\n jsonValue = JSON.parse(paramValue.raw);\n } catch {\n diagnostics?.push({\n code: 'PSL_EXTENSION_INVALID_VALUE',\n message: `native_enum \"${block.name}\" member \"${memberName}\" value \"${paramValue.raw}\" is not valid JSON`,\n sourceId,\n span: paramValue.span,\n });\n memberError = true;\n continue;\n }\n if (typeof jsonValue !== 'string') {\n diagnostics?.push({\n code: 'PSL_EXTENSION_INVALID_VALUE',\n message: `native_enum \"${block.name}\" member \"${memberName}\" value must be a string`,\n sourceId,\n span: paramValue.span,\n });\n memberError = true;\n continue;\n }\n if (seenValues.has(jsonValue)) {\n diagnostics?.push({\n code: 'PSL_NATIVE_ENUM_DUPLICATE_MEMBER_VALUE',\n message: `native_enum \"${block.name}\": duplicate member value \"${jsonValue}\"`,\n sourceId,\n span: paramValue.span,\n });\n memberError = true;\n continue;\n }\n seenValues.add(jsonValue);\n members.push(jsonValue);\n }\n\n if (memberError) return undefined;\n\n if (members.length === 0) {\n diagnostics?.push({\n code: 'PSL_NATIVE_ENUM_MISSING_MEMBERS',\n message: `native_enum \"${block.name}\" must have at least one member`,\n sourceId,\n span: block.span,\n });\n return undefined;\n }\n\n // `control` stays unset — the effective grade is resolved at read time via `effectiveControlPolicy`, like `StorageTable`/`StorageColumn`.\n return new PostgresNativeEnum({ typeName, members });\n}\n\n/**\n * `native_enum`'s entity-type factory output, checked separately from the assembled\n * `postgresAuthoringEntityTypes` map below: `deriveValueSet` is SQL-family surface\n * ({@link SqlValueSetDerivingEntityTypeOutput}), not part of the framework\n * `AuthoringEntityTypeFactoryOutput` shape, so folding it directly into the map's single\n * `satisfies AuthoringEntityTypeNamespace` check would trip an excess-property error. Checking it\n * here against the intersection of both shapes keeps it structurally valid against each without\n * widening the map's own check.\n */\nconst nativeEnumEntityTypeOutput = {\n factory: lowerNativeEnumFromBlock,\n deriveValueSet: (entity: PostgresNativeEnum) => ({\n kind: 'valueSet' as const,\n values: [...entity.members],\n }),\n} satisfies AuthoringEntityTypeFactoryOutput<PslExtensionBlock, PostgresNativeEnum | undefined> &\n SqlValueSetDerivingEntityTypeOutput;\n\nexport const postgresAuthoringEntityTypes = {\n role: {\n kind: 'entity',\n discriminator: 'role',\n validatorSchema: PostgresRoleSchema,\n output: {\n factory: (input: PostgresRoleInput): PostgresRole => new PostgresRole(input),\n },\n },\n rls: {\n kind: 'entity',\n discriminator: 'rls',\n validatorSchema: PostgresRlsEnablementSchema,\n output: {\n factory: (input: PostgresRlsEnablementInput): PostgresRlsEnablement =>\n new PostgresRlsEnablement(input),\n },\n },\n policy: {\n kind: 'entity',\n discriminator: 'policy',\n validatorSchema: PostgresRlsPolicySchema,\n output: {\n factory: lowerRlsPolicyFromBlock,\n },\n },\n native_enum: {\n kind: 'entity',\n discriminator: 'native_enum',\n validatorSchema: PostgresNativeEnumSchema,\n output: nativeEnumEntityTypeOutput,\n },\n} as const satisfies AuthoringEntityTypeNamespace;\n\n/**\n * Field presets contributed by the Postgres target pack.\n *\n * These mirror the PSL scalar-to-codec mapping used by the Postgres adapter\n * (see `createPostgresPslScalarTypeDescriptors`), so that authoring a field\n * via the TS callback surface (e.g. `field.int()`) and via the PSL scalar\n * surface (e.g. `Int`) lowers to byte-identical contracts.\n *\n * The `uuidNative` / `id.uuidv4Native` / `id.uuidv7Native` presets use the\n * native Postgres `uuid` type (codecId `pg/uuid@1`). For cross-target\n * portability use `uuidString` / `id.uuidv4String` / `id.uuidv7String` from\n * the family pack instead.\n */\n/**\n * Shared parameter descriptors for the five `policy_<op>` PSL block\n * keywords. All five share the `policy` discriminator — the parser\n * dispatches by keyword (see the framework's PSL-block SPI), and every\n * keyword's factory lowers to `PostgresRlsPolicy` via `lowerRlsPolicyFromBlock`.\n *\n * The `roles` list uses `scope:'cross-space'` because same-namespace\n * role ref resolution requires PSL namespace entries keyed by `refKind`\n * (i.e. `'role'`), which in turn requires the role block discriminator to\n * equal `'role'`. Aligning discriminator with refKind is tracked for\n * slice 4 (cross-space roles). Until then cross-space passes validation\n * unconditionally and the authored role names flow through unchanged.\n */\nconst policyTargetParam = {\n kind: 'ref',\n refKind: 'model',\n scope: 'same-namespace',\n required: true,\n} as const;\nconst policyRolesParam = {\n kind: 'list',\n of: { kind: 'ref', refKind: 'role', scope: 'cross-space' },\n} as const;\nconst policyPredicateParam = { kind: 'value', codecId: 'pg/text@1', required: true } as const;\n// A policy may only target an RLS-controlled model: the model named by\n// `target` must declare `@@rls`, or the load fails with a diagnostic naming\n// the model and the policy prefix.\nconst policyRequiresRls = { parameter: 'target', attribute: 'rls' } as const;\n\nexport const postgresAuthoringPslBlockDescriptors = {\n // The predicate param set per keyword mirrors Postgres: SELECT/DELETE take\n // USING only; INSERT takes WITH CHECK only; UPDATE/ALL take both. The\n // per-operation predicate matrix is enforced in `lowerRlsPolicyFromBlock`\n // (a wrong predicate for the operation is a load-time diagnostic there),\n // since the generic descriptor validator is not wired into the SQL-family\n // interpreter.\n policy_select: {\n kind: 'pslBlock',\n keyword: 'policy_select',\n discriminator: 'policy',\n name: { required: true },\n parameters: { target: policyTargetParam, roles: policyRolesParam, using: policyPredicateParam },\n requiresModelAttribute: policyRequiresRls,\n },\n policy_delete: {\n kind: 'pslBlock',\n keyword: 'policy_delete',\n discriminator: 'policy',\n name: { required: true },\n parameters: { target: policyTargetParam, roles: policyRolesParam, using: policyPredicateParam },\n requiresModelAttribute: policyRequiresRls,\n },\n policy_insert: {\n kind: 'pslBlock',\n keyword: 'policy_insert',\n discriminator: 'policy',\n name: { required: true },\n parameters: {\n target: policyTargetParam,\n roles: policyRolesParam,\n withCheck: policyPredicateParam,\n },\n requiresModelAttribute: policyRequiresRls,\n },\n policy_update: {\n kind: 'pslBlock',\n keyword: 'policy_update',\n discriminator: 'policy',\n name: { required: true },\n parameters: {\n target: policyTargetParam,\n roles: policyRolesParam,\n using: policyPredicateParam,\n withCheck: policyPredicateParam,\n },\n requiresModelAttribute: policyRequiresRls,\n },\n policy_all: {\n kind: 'pslBlock',\n keyword: 'policy_all',\n discriminator: 'policy',\n name: { required: true },\n parameters: {\n target: policyTargetParam,\n roles: policyRolesParam,\n using: policyPredicateParam,\n withCheck: policyPredicateParam,\n },\n requiresModelAttribute: policyRequiresRls,\n },\n /**\n * PSL block descriptor for `native_enum`.\n *\n * Reuses the existing variadic-block mechanism (the same shape the SQL\n * family's `enum` block ships): the body is an open `memberName = \"value\"`\n * list. `variadicParameters: true` opens the block to arbitrary keys\n * beyond the declared (empty) `parameters` set — the lowering factory\n * (`lowerNativeEnumFromBlock`) turns the variadic entries into ordered\n * members and rejects a bare (value-less) member.\n */\n native_enum: {\n kind: 'pslBlock',\n keyword: 'native_enum',\n discriminator: 'native_enum',\n name: { required: true },\n parameters: {},\n variadicParameters: true,\n },\n} as const satisfies AuthoringPslBlockDescriptorNamespace;\n\n/**\n * `@@` model attributes contributed by the Postgres target pack.\n *\n * `@@rls` is argument-less: presence marks the model's table\n * RLS-controlled. It lowers to a {@link PostgresRlsEnablement} marker in\n * the namespace's `entries.rls`, keyed by the model's table name — the\n * marker (never the policy set) is what drives\n * `ENABLE`/`DISABLE ROW LEVEL SECURITY` planning.\n */\nexport const postgresAuthoringModelAttributes = {\n rls: {\n kind: 'modelAttribute',\n attribute: 'rls',\n spec: modelAttribute('rls', {}),\n lower: (_parsed: Record<never, never>, ctx: AuthoringModelAttributeContext) => ({\n key: ctx.storageName,\n entity: new PostgresRlsEnablement({\n tableName: ctx.storageName,\n namespaceId: ctx.namespaceId,\n }),\n }),\n },\n} as const satisfies AuthoringModelAttributeDescriptorNamespace;\n\nexport const postgresAuthoringFieldPresets = {\n text: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/text@1',\n nativeType: 'text',\n },\n },\n int: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/int4@1',\n nativeType: 'int4',\n },\n },\n bigint: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/int8@1',\n nativeType: 'int8',\n },\n },\n float: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/float8@1',\n nativeType: 'float8',\n },\n },\n decimal: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/numeric@1',\n nativeType: 'numeric',\n },\n },\n boolean: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/bool@1',\n nativeType: 'bool',\n },\n },\n json: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/jsonb@1',\n nativeType: 'jsonb',\n },\n },\n bytes: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/bytea@1',\n nativeType: 'bytea',\n },\n },\n dateTime: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/timestamptz@1',\n nativeType: 'timestamptz',\n },\n },\n temporal: /* @__PURE__ */ temporalAuthoringPresets({\n codecId: 'pg/timestamptz@1',\n nativeType: 'timestamptz',\n }),\n uuidNative: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/uuid@1',\n nativeType: 'uuid',\n },\n },\n id: {\n uuidv4Native: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/uuid@1',\n nativeType: 'uuid',\n executionDefaults: {\n onCreate: {\n kind: 'generator',\n id: 'uuidv4',\n },\n },\n id: true,\n },\n },\n uuidv7Native: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/uuid@1',\n nativeType: 'uuid',\n executionDefaults: {\n onCreate: {\n kind: 'generator',\n id: 'uuidv7',\n },\n },\n id: true,\n },\n },\n },\n} as const satisfies AuthoringFieldNamespace;\n"],"mappings":";;;;;;;;;;;;;;;;AAqCA,MAAa,yBAAyB,EACpC,IAAI,EACF,MAAM;CACJ,MAAM;CACN,cAAc;EAAE,OAAO;EAAG,YAAY;CAAc;CACpD,QAAQ,EACN,SAAS,iBACX;AACF,EACF,EACF;;;;;;AAWA,MAAM,2BAAyE;CAC7E,eAAe;CACf,eAAe;CACf,eAAe;CACf,eAAe;CACf,YAAY;AACd;;;;;;;AAQA,MAAM,8BAEF;CACF,QAAQ;EAAE,OAAO;EAAM,WAAW;CAAM;CACxC,QAAQ;EAAE,OAAO;EAAO,WAAW;CAAK;CACxC,QAAQ;EAAE,OAAO;EAAM,WAAW;CAAK;CACvC,QAAQ;EAAE,OAAO;EAAM,WAAW;CAAM;CACxC,KAAK;EAAE,OAAO;EAAM,WAAW;CAAK;AACtC;AAEA,SAAS,aAAa,OAA0B,KAAiC;CAC/E,MAAM,QAAQ,MAAM,WAAW;CAC/B,OAAO,OAAO,SAAS,QAAQ,MAAM,aAAa,KAAA;AACpD;AAEA,SAAS,eAAe,OAA0B,K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,SAAS;GACT,YAAY;EACd;CACF;CACA,MAAM;EACJ,MAAM;EACN,QAAQ;GACN,SAAS;GACT,YAAY;EACd;CACF;CACA,OAAO;EACL,MAAM;EACN,QAAQ;GACN,SAAS;GACT,YAAY;EACd;CACF;CACA,UAAU;EACR,MAAM;EACN,QAAQ;GACN,SAAS;GACT,YAAY;EACd;CACF;CACA,UAA0B,yCAAyB;EACjD,SAAS;EACT,YAAY;CACd,CAAC;CACD,YAAY;EACV,MAAM;EACN,QAAQ;GACN,SAAS;GACT,YAAY;EACd;CACF;CACA,IAAI;EACF,cAAc;GACZ,MAAM;GACN,QAAQ;IACN,SAAS;IACT,YAAY;IACZ,mBAAmB,EACjB,UAAU;KACR,MAAM;KACN,IAAI;IACN,EACF;IACA,IAAI;GACN;EACF;EACA,cAAc;GACZ,MAAM;GACN,QAAQ;IACN,SAAS;IACT,YAAY;IACZ,mBAAmB,EACjB,UAAU;KACR,MAAM;KACN,IAAI;IACN,EACF;IACA,IAAI;GACN;EACF;CACF;AACF"}
|
package/dist/contract-free.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as DropDefaultAction, l as PostgresCreateSchema, r as AnyAlterTableAction, s as PostgresAlterTable, t as AddColumnAction, u as PostgresCreateTable } from "./nodes-
|
|
1
|
+
import { a as DropDefaultAction, l as PostgresCreateSchema, r as AnyAlterTableAction, s as PostgresAlterTable, t as AddColumnAction, u as PostgresCreateTable } from "./nodes-Bc2N3tMy.mjs";
|
|
2
2
|
import { t as PostgresTableSource } from "./table-source-BvFo7gVs.mjs";
|
|
3
3
|
import { DdlColumn, DdlNode, DdlTableConstraint, SelectAst } from "@prisma-next/sql-relational-core/ast";
|
|
4
4
|
import { CfExpr, ColumnDescriptor, ColumnSchema, TableHandle } from "@prisma-next/sql-relational-core/contract-free";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract-free.d.mts","names":[],"sources":["../src/contract-free/checks.ts","../src/contract-free/columns.ts","../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A,GAAO,OAAA,KAAU,gBACR;ADZoB;AASzD;;;;;;;;;AAE2B;AAY3B;AAvByD,iBC0BzC,OAAA,gBAAuB,YAAA,EACrC,MAAA;EAAA,SAAmB,IAAA;EAAA,SAAuB,MAAA;EAAA,SAA0B,KAAA;AAAA,GACpE,OAAA,EAAS,MAAA,GACR,WAAA,CAAY,MAAA;;;iBCEC,+BAAA,aAA4C,OAAO;AAAA,iBAInD,iCAAA,aAA8C,OAAO;;;;;;;AFnCrE;;;;AAAyD;AASzD;;;;;
|
|
1
|
+
{"version":3,"file":"contract-free.d.mts","names":[],"sources":["../src/contract-free/checks.ts","../src/contract-free/columns.ts","../src/contract-free/control-bootstrap.ts","../src/contract-free/ddl.ts"],"mappings":";;;;;;;;;;AAiBA;iBAAgB,UAAA,CAAW,aAAA,WAAwB,MAAM;AAAA,UASxC,uBAAA;EACf,WAAA,IAAe,SAAA;EACf,YAAA,IAAgB,SAAS;AAAA;;;;;;;;;AAAA;iBAYX,cAAA,CAAe,MAAA,UAAgB,KAAA,WAAgB,uBAAuB;AAAA,UAWrE,4BAAA;EACf,iBAAA,IAAqB,SAAA;EACrB,gBAAA,IAAoB,SAAS;AAAA;;;;AAbuD;AAWtF;;;;;;;;;AAE+B;iBAiBf,mBAAA,CAAoB,OAAA;EAAA,SACzB,cAAA;EAAA,SACA,MAAA;EAAA,SACA,KAAA;AAAA,IACP,4BAA4B;AAAA,UAuDf,wBAAA;EACf,aAAA,IAAiB,SAAA;EACjB,YAAA,IAAgB,SAAS;AAAA;;AAzDK;AAuDhC;;;iBAUgB,eAAA,CAAgB,OAAA;EAAA,SACrB,MAAA;EAAA,SACA,KAAA;EAAA,SACA,MAAA;AAAA,IACP,wBAAwB;;AAZD;AAQ3B;;iBAgBgB,oBAAA,CAAqB,OAAA;EAAA,SAC1B,MAAA;EAAA,SACA,KAAA;EAAA,SACA,MAAA;EAAA,SACA,QAAA;AAAA,IACP,SAAS;AAAA,UAUI,yBAAA;EACf,cAAA,IAAkB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,kBAAkB"}
|
package/dist/contract-free.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { _ as PG_TEXT_ARRAY_CODEC_ID, d as PG_INT8_CODEC_ID, m as PG_JSONB_CODEC_ID, u as PG_INT4_CODEC_ID, v as PG_TEXT_CODEC_ID, y as PG_TIMESTAMPTZ_CODEC_ID } from "./codec-ids-C_-Hj6bL.mjs";
|
|
2
|
-
import { l as PostgresTableSource } from "./postgres-schema-
|
|
3
|
-
import { C as
|
|
2
|
+
import { l as PostgresTableSource } from "./postgres-schema-DWQ0-CPb.mjs";
|
|
3
|
+
import { C as tableIsEmptyAst, S as tableExistsAst, T as toRegclass, _ as extensionExistsAst, a as createSchema, b as rlsEnabledAst, f as columnDefaultAst, g as constraintExistsAst, h as columnTypeAst, l as dropDefaultAction, m as columnNullabilityAst, o as createTable, p as columnExistsAst, r as alterTable, t as addColumnAction, v as indexExistsAst, w as tablePrimaryKeyAst, x as rlsPolicyExistsAst, y as noNullValuesAst } from "./ddl-gmxHf68z.mjs";
|
|
4
4
|
import { col, fn, lit, table } from "@prisma-next/sql-relational-core/contract-free";
|
|
5
5
|
import { APP_SPACE_ID } from "@prisma-next/framework-components/control";
|
|
6
6
|
//#region src/contract-free/columns.ts
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { r as isPostgresSchema } from "./postgres-schema-
|
|
2
|
-
import { i as quoteIdentifier } from "./sql-utils-
|
|
3
|
-
import { n as PostgresSchemaNodeKind, t as PostgresTableSchemaNode } from "./postgres-table-schema-node-
|
|
4
|
-
import { A as
|
|
5
|
-
import { t as buildExpectedFormatType } from "./planner-sql-checks-
|
|
6
|
-
import { n as buildColumnTypeSql, t as buildColumnDefaultSql } from "./planner-ddl-builders-
|
|
1
|
+
import { r as isPostgresSchema } from "./postgres-schema-DWQ0-CPb.mjs";
|
|
2
|
+
import { i as quoteIdentifier } from "./sql-utils-SU4FDvIV.mjs";
|
|
3
|
+
import { n as PostgresNativeEnumSchemaNode, o as postgresNodeEntityKind, r as PostgresSchemaNodeKind, t as PostgresTableSchemaNode } from "./postgres-table-schema-node-D6LvInCe.mjs";
|
|
4
|
+
import { A as SetNotNullCall, C as DropNotNullCall, D as RawSqlCall, E as EnableRowLevelSecurityCall, M as buildTargetDetails, S as DropNativeEnumTypeCall, T as DropTableCall, _ as DropCheckConstraintCall, a as AddNotNullColumnWithTempDefaultCall, b as DropDefaultCall, c as AlterColumnTypeCall, d as CreateNativeEnumTypeCall, g as DisableRowLevelSecurityCall, h as DataTransformCall, i as AddNotNullColumnDirectCall, j as postgresDefaultToDdlColumnDefault, k as SetDefaultCall, m as CreateTableCall, n as AddColumnCall, o as AddPrimaryKeyCall, p as CreateSchemaCall, r as AddForeignKeyCall, s as AddUniqueCall, t as AddCheckConstraintCall, u as CreateIndexCall, v as DropColumnCall, x as DropIndexCall, y as DropConstraintCall } from "./op-factory-call-C4flTtTG.mjs";
|
|
5
|
+
import { t as buildExpectedFormatType } from "./planner-sql-checks-Br1c_QsH.mjs";
|
|
6
|
+
import { n as buildColumnTypeSql, t as buildColumnDefaultSql } from "./planner-ddl-builders-BKlmGDJl.mjs";
|
|
7
7
|
import { n as resolveIdentityValue } from "./planner-identity-values-CJPha2Sz.mjs";
|
|
8
8
|
import { i as hasUniqueConstraint, n as hasForeignKey, t as buildSchemaLookupMap } from "./planner-schema-lookup-CiVaAQP-.mjs";
|
|
9
9
|
import { UNBOUND_NAMESPACE_ID, entityAt } from "@prisma-next/framework-components/ir";
|
|
@@ -15,6 +15,31 @@ import * as contractFree from "@prisma-next/sql-relational-core/contract-free";
|
|
|
15
15
|
import { RelationalSchemaNodeKind, SqlSchemaIR } from "@prisma-next/sql-schema-ir/types";
|
|
16
16
|
import { defaultIndexName } from "@prisma-next/sql-schema-ir/naming";
|
|
17
17
|
import { notOk, ok } from "@prisma-next/utils/result";
|
|
18
|
+
//#region src/core/schema-ir/node-storage-coordinate.ts
|
|
19
|
+
/**
|
|
20
|
+
* The storage-`entries` coordinate `(entityKind, entityName)` a Postgres diff
|
|
21
|
+
* node addresses — a table by its name, a native enum by its physical type
|
|
22
|
+
* name. `undefined` for a node that is not a whole storage entity (a namespace,
|
|
23
|
+
* a column, a policy). Lets ownership/subject resolution treat every entity kind
|
|
24
|
+
* uniformly, the node self-describing its storage identity.
|
|
25
|
+
*/
|
|
26
|
+
function postgresNodeStorageCoordinate(node) {
|
|
27
|
+
if (PostgresTableSchemaNode.is(node)) {
|
|
28
|
+
const entityKind = postgresNodeEntityKind(node.nodeKind);
|
|
29
|
+
return entityKind === void 0 ? void 0 : {
|
|
30
|
+
entityKind,
|
|
31
|
+
entityName: node.name
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
if (PostgresNativeEnumSchemaNode.is(node)) {
|
|
35
|
+
const entityKind = postgresNodeEntityKind(node.nodeKind);
|
|
36
|
+
return entityKind === void 0 ? void 0 : {
|
|
37
|
+
entityKind,
|
|
38
|
+
entityName: node.typeName
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
//#endregion
|
|
18
43
|
//#region src/core/migrations/column-ddl-rendering.ts
|
|
19
44
|
/**
|
|
20
45
|
* Reconstructs the `StorageColumn`-shaped fields the DDL builder functions
|
|
@@ -542,8 +567,10 @@ function issueConflict(kind, summary, location) {
|
|
|
542
567
|
function classifyCall(call) {
|
|
543
568
|
switch (call.factoryName) {
|
|
544
569
|
case "createExtension":
|
|
545
|
-
case "createSchema":
|
|
570
|
+
case "createSchema":
|
|
571
|
+
case "createNativeEnumType": return "dep";
|
|
546
572
|
case "dropTable":
|
|
573
|
+
case "dropNativeEnumType":
|
|
547
574
|
case "dropColumn":
|
|
548
575
|
case "dropConstraint":
|
|
549
576
|
case "dropCheckConstraint":
|
|
@@ -594,11 +621,16 @@ function conflictKindForCall(call) {
|
|
|
594
621
|
function locationForCall(call) {
|
|
595
622
|
const anyCall = call;
|
|
596
623
|
const location = {};
|
|
597
|
-
if (anyCall.tableName)
|
|
624
|
+
if (anyCall.tableName) {
|
|
625
|
+
location.entityKind = "table";
|
|
626
|
+
location.entityName = anyCall.tableName;
|
|
627
|
+
} else if (anyCall.typeName) {
|
|
628
|
+
location.entityKind = "native_enum";
|
|
629
|
+
location.entityName = anyCall.typeName;
|
|
630
|
+
}
|
|
598
631
|
if (anyCall.columnName) location.column = anyCall.columnName;
|
|
599
632
|
if (anyCall.indexName) location.index = anyCall.indexName;
|
|
600
633
|
if (anyCall.constraintName) location.constraint = anyCall.constraintName;
|
|
601
|
-
if (anyCall.typeName) location.type = anyCall.typeName;
|
|
602
634
|
return Object.keys(location).length > 0 ? location : void 0;
|
|
603
635
|
}
|
|
604
636
|
function conflictForDisallowedCall(call, allowed) {
|
|
@@ -674,6 +706,7 @@ function nodeIssueOrder(issue) {
|
|
|
674
706
|
if (node === void 0) return 99;
|
|
675
707
|
switch (node.nodeKind) {
|
|
676
708
|
case PostgresSchemaNodeKind.namespace: return 1;
|
|
709
|
+
case PostgresSchemaNodeKind.nativeEnum: return issue.reason === "not-expected" ? 17 : 2;
|
|
677
710
|
case RelationalSchemaNodeKind.foreignKey: return issue.reason === "not-expected" ? 10 : 60;
|
|
678
711
|
case RelationalSchemaNodeKind.unique: return issue.reason === "not-expected" ? 11 : 51;
|
|
679
712
|
case RelationalSchemaNodeKind.primaryKey: return issue.reason === "not-expected" ? 12 : 50;
|
|
@@ -759,6 +792,27 @@ function buildCreateTableCallsFromNode(schemaName, ddlSchemaName, table, codecHo
|
|
|
759
792
|
function nodeConflict(kind, message) {
|
|
760
793
|
return issueConflict(kind, message);
|
|
761
794
|
}
|
|
795
|
+
/**
|
|
796
|
+
* Managed native-enum issue -> op lowering. A missing declared type creates
|
|
797
|
+
* it; an unclaimed live type drops it (ownership-scoped upstream by
|
|
798
|
+
* `retainUnownedExtras`, destructiveness gated by the operation-class
|
|
799
|
+
* policy); a paired member-value mismatch is a NAMED unsupported diagnostic
|
|
800
|
+
* — never a silent no-op and never a drop-and-recreate. Slice B replaces the
|
|
801
|
+
* diagnostic with order-aware `ALTER TYPE ... ADD VALUE` / refusal semantics.
|
|
802
|
+
*/
|
|
803
|
+
function mapNativeEnumNodeIssue(issue, ctx) {
|
|
804
|
+
const ddlSchemaName = issueSchemaName(issue);
|
|
805
|
+
if (ddlSchemaName === void 0) return notOk(nodeConflict("unsupportedOperation", `Enum issue has no schema in its path: ${issue.path.join("/")}`));
|
|
806
|
+
const schemaName = emissionSchemaName(ctx, ddlSchemaName);
|
|
807
|
+
if (issue.reason === "not-found") {
|
|
808
|
+
const expected = blindCast(issue.expected);
|
|
809
|
+
return ok([new CreateNativeEnumTypeCall(schemaName, expected.typeName, expected.members)]);
|
|
810
|
+
}
|
|
811
|
+
if (issue.reason === "not-expected") return ok([new DropNativeEnumTypeCall(schemaName, blindCast(issue.actual).typeName)]);
|
|
812
|
+
const expected = blindCast(issue.expected);
|
|
813
|
+
const actualMembers = blindCast(issue.actual).members;
|
|
814
|
+
return notOk(nodeConflict("unsupportedOperation", `Native enum type "${ddlSchemaName}"."${expected.typeName}" member values changed (contract declares [${expected.members.join(", ")}], database has [${actualMembers.join(", ")}]); enum value changes are not auto-migrated yet. Author the change manually with \`migration new\`.`));
|
|
815
|
+
}
|
|
762
816
|
function mapTableNodeIssue(issue, schemaName, ddlSchemaName, codecHooks) {
|
|
763
817
|
if (issue.reason === "not-found") return ok(buildCreateTableCallsFromNode(schemaName, ddlSchemaName, blindCast(issue.expected), codecHooks));
|
|
764
818
|
if (issue.reason === "not-expected") return ok([new DropTableCall(schemaName, blindCast(issue.actual).name)]);
|
|
@@ -853,6 +907,7 @@ function mapNodeIssueToCall(issue, ctx) {
|
|
|
853
907
|
if (issue.reason !== "not-found") return notOk(nodeConflict("unsupportedOperation", `Unexpected namespace drift: ${issue.path.join("/")}`));
|
|
854
908
|
return ok([new CreateSchemaCall(blindCast(issue.expected).schemaName)]);
|
|
855
909
|
}
|
|
910
|
+
if (node.nodeKind === PostgresSchemaNodeKind.nativeEnum) return mapNativeEnumNodeIssue(issue, ctx);
|
|
856
911
|
const ddlSchemaName = issueSchemaName(issue);
|
|
857
912
|
const tableName = issueTableName(issue);
|
|
858
913
|
if (ddlSchemaName === void 0 || tableName === void 0) return notOk(nodeConflict("unsupportedOperation", `Issue has no schema/table in its path: ${issue.path.join("/")}`));
|
|
@@ -972,13 +1027,16 @@ function planIssues(options) {
|
|
|
972
1027
|
* and is fail-closed. Any call not listed here — including future or
|
|
973
1028
|
* extension-contributed factories — is treated as NOT object-creation, so it
|
|
974
1029
|
* is suppressed under `tolerated` rather than permissively emitted.
|
|
1030
|
+
*
|
|
1031
|
+
* Lists the creation factories that actually reach the call-side resolver
|
|
1032
|
+
* (`resolvePostgresCallControlPolicySubject`) — today only RLS policy
|
|
1033
|
+
* creation, from `planPostgresSchemaDiff`. Every other whole-object create
|
|
1034
|
+
* (table, schema, native enum, and RLS enablement) is constructed inside
|
|
1035
|
+
* `planIssues` and graded on the node side by
|
|
1036
|
+
* `resolvePostgresNodeIssueCreationFactoryName`, so none of them are listed
|
|
1037
|
+
* here.
|
|
975
1038
|
*/
|
|
976
|
-
const OBJECT_CREATION_FACTORIES = new Set([
|
|
977
|
-
"createTable",
|
|
978
|
-
"createSchema",
|
|
979
|
-
"createRlsPolicy",
|
|
980
|
-
"enableRowLevelSecurity"
|
|
981
|
-
]);
|
|
1039
|
+
const OBJECT_CREATION_FACTORIES = new Set(["createRlsPolicy"]);
|
|
982
1040
|
function createsNewTopLevelObject(call) {
|
|
983
1041
|
return OBJECT_CREATION_FACTORIES.has(call.factoryName);
|
|
984
1042
|
}
|
|
@@ -986,17 +1044,33 @@ function ddlSchemaNameForNamespace(contract, namespaceId) {
|
|
|
986
1044
|
const namespace = contract.storage.namespaces[namespaceId];
|
|
987
1045
|
return isPostgresSchema(namespace) ? namespace.ddlSchemaName(contract.storage) : namespaceId;
|
|
988
1046
|
}
|
|
989
|
-
|
|
1047
|
+
/**
|
|
1048
|
+
* Resolve the namespace a declared storage entity lives in by walking every
|
|
1049
|
+
* namespace for one whose `entries` map actually contains the coordinate —
|
|
1050
|
+
* a table by its name, a native enum by its physical type name (see
|
|
1051
|
+
* {@link postgresNodeStorageCoordinate}). When `ddlSchemaName` is given, the
|
|
1052
|
+
* match must also land in that DDL schema (disambiguates same-named entities
|
|
1053
|
+
* declared under different namespaces); when omitted, the first namespace
|
|
1054
|
+
* that declares the entity wins. Falls back to {@link UNBOUND_NAMESPACE_ID}
|
|
1055
|
+
* when no namespace declares it — e.g. an extra/dropped entity the contract
|
|
1056
|
+
* doesn't claim at all.
|
|
1057
|
+
*/
|
|
1058
|
+
function resolveNamespaceIdForEntity(contract, coordinate, ddlSchemaName) {
|
|
990
1059
|
for (const namespaceId of Object.keys(contract.storage.namespaces)) {
|
|
991
1060
|
if (!entityAt(contract.storage, {
|
|
992
1061
|
namespaceId,
|
|
993
|
-
|
|
994
|
-
entityName: tableName
|
|
1062
|
+
...coordinate
|
|
995
1063
|
})) continue;
|
|
996
1064
|
if (ddlSchemaName === void 0 || ddlSchemaNameForNamespace(contract, namespaceId) === ddlSchemaName) return namespaceId;
|
|
997
1065
|
}
|
|
998
1066
|
return UNBOUND_NAMESPACE_ID;
|
|
999
1067
|
}
|
|
1068
|
+
function resolveNamespaceIdForTable(contract, tableName, ddlSchemaName) {
|
|
1069
|
+
return resolveNamespaceIdForEntity(contract, {
|
|
1070
|
+
entityKind: "table",
|
|
1071
|
+
entityName: tableName
|
|
1072
|
+
}, ddlSchemaName);
|
|
1073
|
+
}
|
|
1000
1074
|
function resolveNamespaceIdForDdlSchema(contract, ddlSchemaName) {
|
|
1001
1075
|
for (const namespaceId of Object.keys(contract.storage.namespaces)) {
|
|
1002
1076
|
const ns = contract.storage.namespaces[namespaceId];
|
|
@@ -1012,9 +1086,42 @@ function postgresCallFields(call) {
|
|
|
1012
1086
|
...ifDefined("columnName", "columnName" in call ? call.columnName : void 0)
|
|
1013
1087
|
};
|
|
1014
1088
|
}
|
|
1015
|
-
function
|
|
1016
|
-
if (subject
|
|
1017
|
-
|
|
1089
|
+
function formatSuppressionSubjectLabel(subject, contract) {
|
|
1090
|
+
if (subject === void 0) return "unknown";
|
|
1091
|
+
const ddlSchema = ddlSchemaNameForNamespace(contract, subject.namespaceId);
|
|
1092
|
+
if (subject.entityKind !== void 0 && subject.entityName !== void 0) return `${subject.entityKind} "${ddlSchema}.${subject.entityName}"`;
|
|
1093
|
+
return `namespace "${ddlSchema}"`;
|
|
1094
|
+
}
|
|
1095
|
+
function postgresSuppressionSummary(subjectLabel, subject, policy) {
|
|
1096
|
+
const namespace = subject?.namespaceId ?? "unknown";
|
|
1097
|
+
const declared = subject?.explicitNodeControlPolicy;
|
|
1098
|
+
if (policy === "external" && declared === "managed") return `control policy suppressed: ${subjectLabel} — namespace '${namespace}' has effective control 'external' but declared 'managed'`;
|
|
1099
|
+
return `control policy suppressed: ${subjectLabel} — namespace '${namespace}' has effective control '${policy}'${declared ? ` but declared '${declared}'` : ""}`;
|
|
1100
|
+
}
|
|
1101
|
+
/**
|
|
1102
|
+
* Render one family {@link SuppressionRecord} into a target `SqlPlannerConflict`.
|
|
1103
|
+
* The family decides *that* a subject is suppressed and hands over the raw
|
|
1104
|
+
* coordinate + policy; the label, message, and location are rendered here,
|
|
1105
|
+
* driven entirely by the subject's own `(entityKind, entityName)` coordinate
|
|
1106
|
+
* — no target-owned table-vs-enum vocabulary.
|
|
1107
|
+
*/
|
|
1108
|
+
function renderPostgresSuppression(record, contract) {
|
|
1109
|
+
const subject = record.subject;
|
|
1110
|
+
return {
|
|
1111
|
+
kind: "controlPolicySuppressedCall",
|
|
1112
|
+
summary: postgresSuppressionSummary(formatSuppressionSubjectLabel(subject, contract), subject, record.policy),
|
|
1113
|
+
location: {
|
|
1114
|
+
...ifDefined("namespaceId", subject?.namespaceId),
|
|
1115
|
+
...ifDefined("entityKind", subject?.entityKind),
|
|
1116
|
+
...ifDefined("entityName", subject?.entityName),
|
|
1117
|
+
...ifDefined("column", subject?.column)
|
|
1118
|
+
},
|
|
1119
|
+
meta: {
|
|
1120
|
+
controlPolicy: record.policy,
|
|
1121
|
+
...ifDefined("factoryName", record.factoryName),
|
|
1122
|
+
...ifDefined("declaredControlPolicy", subject?.explicitNodeControlPolicy)
|
|
1123
|
+
}
|
|
1124
|
+
};
|
|
1018
1125
|
}
|
|
1019
1126
|
function resolvePostgresCallControlPolicySubject(call, contract) {
|
|
1020
1127
|
const callFields = postgresCallFields(call);
|
|
@@ -1032,9 +1139,10 @@ function resolvePostgresCallControlPolicySubject(call, contract) {
|
|
|
1032
1139
|
})?.control;
|
|
1033
1140
|
return {
|
|
1034
1141
|
namespaceId,
|
|
1035
|
-
|
|
1036
|
-
|
|
1142
|
+
entityKind: "table",
|
|
1143
|
+
entityName: callFields.tableName,
|
|
1037
1144
|
...ifDefined("column", callFields.columnName),
|
|
1145
|
+
...ifDefined("explicitNodeControlPolicy", tableControlPolicy),
|
|
1038
1146
|
createsNewObject
|
|
1039
1147
|
};
|
|
1040
1148
|
}
|
|
@@ -1044,10 +1152,10 @@ function resolvePostgresCallControlPolicySubject(call, contract) {
|
|
|
1044
1152
|
};
|
|
1045
1153
|
}
|
|
1046
1154
|
/**
|
|
1047
|
-
* Node kinds
|
|
1048
|
-
* object
|
|
1049
|
-
*
|
|
1050
|
-
*
|
|
1155
|
+
* Node kinds whose *absence* is the creation of a whole, top-level Postgres
|
|
1156
|
+
* object: a namespace, a table, or a native enum. Used by
|
|
1157
|
+
* {@link resolvePostgresNodeIssueCreationFactoryName} to decide whether a
|
|
1158
|
+
* `tolerated` subject permits the issue to flow into the planner
|
|
1051
1159
|
* (create-if-absent) and to seed the suppressed-subject warning's
|
|
1052
1160
|
* `factoryName` when the planner is skipped. RLS policy creation is not
|
|
1053
1161
|
* listed here — policy issues never reach this issue-based partition (they
|
|
@@ -1056,13 +1164,15 @@ function resolvePostgresCallControlPolicySubject(call, contract) {
|
|
|
1056
1164
|
*/
|
|
1057
1165
|
const POSTGRES_NODE_CREATION_FACTORY = Object.freeze({
|
|
1058
1166
|
[PostgresSchemaNodeKind.namespace]: "createSchema",
|
|
1059
|
-
[PostgresSchemaNodeKind.table]: "createTable"
|
|
1167
|
+
[PostgresSchemaNodeKind.table]: "createTable",
|
|
1168
|
+
[PostgresSchemaNodeKind.nativeEnum]: "createNativeEnumType"
|
|
1060
1169
|
});
|
|
1061
1170
|
/**
|
|
1062
1171
|
* A table `not-equal` issue whose `rlsEnabled` flips OFF→ON (expected on,
|
|
1063
|
-
* actual off) is enablement toward `ENABLE ROW LEVEL SECURITY
|
|
1064
|
-
* creation-class
|
|
1065
|
-
*
|
|
1172
|
+
* actual off) is enablement toward `ENABLE ROW LEVEL SECURITY`. It is
|
|
1173
|
+
* creation-class on the node side because `isEnablementCreationIssue` and
|
|
1174
|
+
* {@link resolvePostgresNodeIssueCreationFactoryName} treat this OFF→ON delta
|
|
1175
|
+
* as a creation: enabling RLS establishes the fail-closed guard the declared
|
|
1066
1176
|
* policy set attaches to, the same grant `tolerated` extends to creating the
|
|
1067
1177
|
* policies themselves. The opposite direction (`DISABLE`) is a modification
|
|
1068
1178
|
* and stays managed-only. Keying on the actual delta (not just the expected
|
|
@@ -1087,15 +1197,25 @@ function resolvePostgresNodeIssueCreationFactoryName(issue) {
|
|
|
1087
1197
|
* {@link SchemaDiffIssue}. Mirrors the resolution
|
|
1088
1198
|
* `resolvePostgresCallControlPolicySubject` performs for a generated DDL
|
|
1089
1199
|
* call, but works *off the issue* — so the planner can partition issues by
|
|
1090
|
-
* effective policy before the diff engine runs.
|
|
1091
|
-
* derived from the node kind + reason: a `not-found` schema/table describes
|
|
1092
|
-
* a brand-new top-level object; everything else touches an existing object.
|
|
1200
|
+
* effective policy before the diff engine runs.
|
|
1093
1201
|
*
|
|
1094
|
-
* A
|
|
1095
|
-
*
|
|
1096
|
-
* `
|
|
1097
|
-
*
|
|
1098
|
-
*
|
|
1202
|
+
* A whole storage entity (table or native enum) resolves generically off
|
|
1203
|
+
* {@link postgresNodeStorageCoordinate} — the node self-describes its
|
|
1204
|
+
* `(entityKind, entityName)`, so table and enum issues share one code path
|
|
1205
|
+
* with no per-kind branch. A sub-entity issue (a column/constraint drift
|
|
1206
|
+
* inside an owned table) carries no such coordinate on its own node, so it
|
|
1207
|
+
* falls back to reading the enclosing table name off the issue path.
|
|
1208
|
+
*
|
|
1209
|
+
* `createsNewObject` is delegated to {@link resolvePostgresNodeIssueCreationFactoryName}
|
|
1210
|
+
* in every branch below — that function already encodes exactly which
|
|
1211
|
+
* node-kind/reason combinations describe a brand-new top-level object
|
|
1212
|
+
* (a `not-found` table/enum, or an RLS-enablement `not-equal`).
|
|
1213
|
+
*
|
|
1214
|
+
* A `not-expected` (extra/dropped) entity carries no contract namespace
|
|
1215
|
+
* coordinate — the live object isn't claimed by any contract namespace — so
|
|
1216
|
+
* the subject's `namespaceId` falls back to {@link UNBOUND_NAMESPACE_ID} via
|
|
1217
|
+
* `resolveNamespaceIdForEntity`'s own fallback, matching how the call-side
|
|
1218
|
+
* resolver treats the `DropTableCall`/`DropNativeEnumTypeCall` it produces.
|
|
1099
1219
|
*
|
|
1100
1220
|
* A role node resolves against the `PostgresRole` contract entity at that
|
|
1101
1221
|
* role's name (roles are root-level diff subjects, so the name is the
|
|
@@ -1127,6 +1247,21 @@ function resolvePostgresNodeIssueControlPolicySubject(issue, contract) {
|
|
|
1127
1247
|
createsNewObject: false
|
|
1128
1248
|
};
|
|
1129
1249
|
}
|
|
1250
|
+
const coordinate = postgresNodeStorageCoordinate(node);
|
|
1251
|
+
if (coordinate !== void 0) {
|
|
1252
|
+
const namespaceId = resolveNamespaceIdForEntity(contract, coordinate, issue.path[1]);
|
|
1253
|
+
const entityControl = entityAt(contract.storage, {
|
|
1254
|
+
namespaceId,
|
|
1255
|
+
...coordinate
|
|
1256
|
+
})?.control;
|
|
1257
|
+
return {
|
|
1258
|
+
namespaceId,
|
|
1259
|
+
...coordinate,
|
|
1260
|
+
...ifDefined("column", issueColumnName(issue)),
|
|
1261
|
+
...ifDefined("explicitNodeControlPolicy", entityControl),
|
|
1262
|
+
createsNewObject: resolvePostgresNodeIssueCreationFactoryName(issue) !== void 0
|
|
1263
|
+
};
|
|
1264
|
+
}
|
|
1130
1265
|
const tableName = issue.path[2];
|
|
1131
1266
|
if (tableName === void 0) return void 0;
|
|
1132
1267
|
const ddlSchemaName = issue.path[1];
|
|
@@ -1136,16 +1271,16 @@ function resolvePostgresNodeIssueControlPolicySubject(issue, contract) {
|
|
|
1136
1271
|
entityKind: "table",
|
|
1137
1272
|
entityName: tableName
|
|
1138
1273
|
});
|
|
1139
|
-
const createsNewObject = node.nodeKind === PostgresSchemaNodeKind.table && issue.reason === "not-found" || isEnablementCreationIssue(issue);
|
|
1140
1274
|
return {
|
|
1141
1275
|
namespaceId,
|
|
1142
|
-
|
|
1143
|
-
|
|
1276
|
+
entityKind: "table",
|
|
1277
|
+
entityName: tableName,
|
|
1144
1278
|
...ifDefined("column", issueColumnName(issue)),
|
|
1145
|
-
|
|
1279
|
+
...ifDefined("explicitNodeControlPolicy", table?.control),
|
|
1280
|
+
createsNewObject: resolvePostgresNodeIssueCreationFactoryName(issue) !== void 0
|
|
1146
1281
|
};
|
|
1147
1282
|
}
|
|
1148
1283
|
//#endregion
|
|
1149
|
-
export { resolvePostgresNodeIssueCreationFactoryName as a, issueSchemaName as c,
|
|
1284
|
+
export { resolvePostgresNodeIssueCreationFactoryName as a, issueSchemaName as c, postgresNodeStorageCoordinate as d, resolvePostgresNodeIssueControlPolicySubject as i, planIssues as l, resolveNamespaceIdForDdlSchema as n, coalesceSubtreeIssues as o, resolvePostgresCallControlPolicySubject as r, issueNode as s, renderPostgresSuppression as t, postgresPlannerStrategies as u };
|
|
1150
1285
|
|
|
1151
|
-
//# sourceMappingURL=control-policy-
|
|
1286
|
+
//# sourceMappingURL=control-policy-DKp0HKpY.mjs.map
|