@prisma-next/target-postgres 0.15.0-dev.9 → 0.15.0
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/{control-policy-UPteqwtU.mjs → control-policy-DtbkLLGv.mjs} +72 -41
- package/dist/control-policy-DtbkLLGv.mjs.map +1 -0
- package/dist/control.mjs +3 -3
- package/dist/{diff-database-schema-47526Pv2.mjs → diff-database-schema-GncqMuSI.mjs} +22 -85
- package/dist/diff-database-schema-GncqMuSI.mjs.map +1 -0
- package/dist/diff-database-schema.d.mts +12 -3
- package/dist/diff-database-schema.d.mts.map +1 -1
- package/dist/diff-database-schema.mjs +1 -1
- package/dist/issue-planner.d.mts.map +1 -1
- package/dist/issue-planner.mjs +1 -1
- package/dist/{planner-uHcFFWkx.mjs → planner-kql24i_F.mjs} +9 -9
- package/dist/planner-kql24i_F.mjs.map +1 -0
- package/dist/planner.d.mts +1 -1
- package/dist/planner.d.mts.map +1 -1
- package/dist/planner.mjs +2 -2
- package/dist/{postgres-database-schema-node-DJOTywwQ.d.mts → postgres-database-schema-node-CJv5bfbs.d.mts} +2 -11
- package/dist/postgres-database-schema-node-CJv5bfbs.d.mts.map +1 -0
- package/dist/{postgres-role-schema-node-bg32e7I-.mjs → postgres-role-schema-node-Cm-j0ZGM.mjs} +2 -3
- package/dist/postgres-role-schema-node-Cm-j0ZGM.mjs.map +1 -0
- package/dist/types.d.mts +2 -3
- package/dist/types.mjs +3 -3
- package/package.json +20 -20
- package/src/core/migrations/contract-to-postgres-database-schema-node.ts +19 -99
- package/src/core/migrations/control-policy.ts +3 -4
- package/src/core/migrations/diff-database-schema.ts +3 -3
- package/src/core/migrations/issue-planner.ts +80 -41
- package/src/core/migrations/planner-strategies.ts +6 -6
- package/src/core/migrations/planner.ts +4 -5
- package/src/core/migrations/verify-postgres-namespaces.ts +1 -0
- package/src/core/schema-ir/postgres-policy-schema-node.ts +2 -12
- package/src/exports/types.ts +0 -1
- package/dist/control-policy-UPteqwtU.mjs.map +0 -1
- package/dist/diff-database-schema-47526Pv2.mjs.map +0 -1
- package/dist/planner-uHcFFWkx.mjs.map +0 -1
- package/dist/postgres-database-schema-node-DJOTywwQ.d.mts.map +0 -1
- package/dist/postgres-role-schema-node-bg32e7I-.mjs.map +0 -1
- package/dist/schema-node-kinds-CrYzCR1i.d.mts +0 -30
- package/dist/schema-node-kinds-CrYzCR1i.d.mts.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
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;;;;;;;;;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AC;CACV;CAEA,UAAU,OAA8B;EACtC,MAAM,OAAO,UAGX,KAAK;EACP,yBAAyB,OAAO,IAAI;EACpC,OAAO,KAAK,OAAO,KAAK;CAC1B;CAEA,OAAO,GAAG,MAAyD;EACjE,OAAO,KAAK,aAAa,uBAAuB;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,30 +0,0 @@
|
|
|
1
|
-
import { SqlSchemaIRNode } from "@prisma-next/sql-schema-ir/types";
|
|
2
|
-
import { DiffableNode } from "@prisma-next/framework-components/control";
|
|
3
|
-
|
|
4
|
-
//#region src/core/schema-ir/schema-node-kinds.d.ts
|
|
5
|
-
/**
|
|
6
|
-
* A Postgres schema-diff-tree node: a `SqlSchemaIRNode` that also implements
|
|
7
|
-
* `DiffableNode` (the five `Postgres*SchemaNode` classes). `SqlSchemaIRNode`
|
|
8
|
-
* alone is not a `DiffableNode` — its relational subclasses (`SqlColumnIR`, …)
|
|
9
|
-
* carry no `id`/`isEqualTo`/`children` — so this intersection is the honest node
|
|
10
|
-
* type the differ produces and the planner consumes (`SchemaDiff<SqlSchemaDiffNode>`).
|
|
11
|
-
*/
|
|
12
|
-
type SqlSchemaDiffNode = SqlSchemaIRNode & DiffableNode;
|
|
13
|
-
/**
|
|
14
|
-
* The `nodeKind` discriminant for each Postgres schema-diff node. Each node
|
|
15
|
-
* carries a unique value; the static `is`/`assert` guards compare against these
|
|
16
|
-
* identifiers rather than spelling the string inline or using `instanceof`. The
|
|
17
|
-
* field is an enumerable own property carried on every node instance.
|
|
18
|
-
*/
|
|
19
|
-
declare const PostgresSchemaNodeKind: {
|
|
20
|
-
readonly database: "postgres-database";
|
|
21
|
-
readonly namespace: "postgres-namespace";
|
|
22
|
-
readonly table: "postgres-table";
|
|
23
|
-
readonly policy: "postgres-policy";
|
|
24
|
-
readonly role: "postgres-role";
|
|
25
|
-
readonly nativeEnum: "postgres-native-enum";
|
|
26
|
-
};
|
|
27
|
-
type PostgresSchemaNodeKind = (typeof PostgresSchemaNodeKind)[keyof typeof PostgresSchemaNodeKind];
|
|
28
|
-
//#endregion
|
|
29
|
-
export { SqlSchemaDiffNode as n, PostgresSchemaNodeKind as t };
|
|
30
|
-
//# sourceMappingURL=schema-node-kinds-CrYzCR1i.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schema-node-kinds-CrYzCR1i.d.mts","names":[],"sources":["../src/core/schema-ir/schema-node-kinds.ts"],"mappings":";;;;;;AAiBA;;;;AAA8D;KAAlD,iBAAA,GAAoB,eAAA,GAAkB,YAAY;;;;;;;cAQjD,sBAAA;EAAA;;;;;;;KASD,sBAAA,WACF,sBAAA,eAAqC,sBAAsB"}
|