@prisma-next/target-postgres 0.14.0-dev.5 → 0.14.0-dev.50
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-DzHOdWTl.mjs +364 -0
- package/dist/authoring-DzHOdWTl.mjs.map +1 -0
- package/dist/canonicalize-Bn3BM1Cn.mjs +46 -0
- package/dist/canonicalize-Bn3BM1Cn.mjs.map +1 -0
- package/dist/canonicalize-CAbXtVtB.d.mts +37 -0
- package/dist/canonicalize-CAbXtVtB.d.mts.map +1 -0
- package/dist/{codec-ids-CnXu9Qy3.d.mts → codec-ids-BzrFF-I4.d.mts} +3 -2
- package/dist/codec-ids-BzrFF-I4.d.mts.map +1 -0
- package/dist/{codec-ids-BvytN2P8.mjs → codec-ids-C_-Hj6bL.mjs} +3 -2
- package/dist/codec-ids-C_-Hj6bL.mjs.map +1 -0
- package/dist/codec-ids.d.mts +2 -2
- package/dist/codec-ids.mjs +2 -2
- package/dist/{codec-types-DHCkwPKE.d.mts → codec-types-BDVmvKAW.d.mts} +3 -2
- package/dist/codec-types-BDVmvKAW.d.mts.map +1 -0
- package/dist/codec-types.d.mts +1 -1
- package/dist/{codecs--0A5_4Bq.d.mts → codecs-Dk2sxGLv.d.mts} +77 -4
- package/dist/codecs-Dk2sxGLv.d.mts.map +1 -0
- package/dist/codecs.d.mts +1 -1
- package/dist/codecs.mjs +117 -2
- package/dist/codecs.mjs.map +1 -1
- package/dist/contract-free.d.mts +8 -3
- package/dist/contract-free.d.mts.map +1 -1
- package/dist/contract-free.mjs +4 -4
- package/dist/control-policy-DUFgy9jO.mjs +1103 -0
- package/dist/control-policy-DUFgy9jO.mjs.map +1 -0
- package/dist/control.d.mts +2 -2
- package/dist/control.d.mts.map +1 -1
- package/dist/control.mjs +757 -35
- package/dist/control.mjs.map +1 -1
- package/dist/data-transform-BOWpliq8.mjs.map +1 -1
- package/dist/{data-transform-DDgWdB5o.d.mts → data-transform-DPzwBMhW.d.mts} +3 -3
- package/dist/{data-transform-DDgWdB5o.d.mts.map → data-transform-DPzwBMhW.d.mts.map} +1 -1
- package/dist/data-transform.d.mts +1 -1
- package/dist/{ddl-QDyOSeLc.mjs → ddl-ujxH2A7r.mjs} +63 -6
- package/dist/ddl-ujxH2A7r.mjs.map +1 -0
- package/dist/ddl.d.mts +3 -2
- package/dist/ddl.mjs +2 -2
- package/dist/default-normalizer.d.mts +1 -1
- package/dist/default-normalizer.d.mts.map +1 -1
- package/dist/default-normalizer.mjs +247 -1
- package/dist/default-normalizer.mjs.map +1 -0
- package/dist/descriptor-meta-CuGDsrG4.mjs +19 -0
- package/dist/descriptor-meta-CuGDsrG4.mjs.map +1 -0
- package/dist/descriptor-meta-runtime-UwYdV8fD.mjs +12 -0
- package/dist/descriptor-meta-runtime-UwYdV8fD.mjs.map +1 -0
- package/dist/diff-database-schema-BmSmWcaY.mjs +313 -0
- package/dist/diff-database-schema-BmSmWcaY.mjs.map +1 -0
- package/dist/diff-database-schema.d.mts +46 -0
- package/dist/diff-database-schema.d.mts.map +1 -0
- package/dist/diff-database-schema.mjs +2 -0
- package/dist/issue-planner.d.mts +35 -11
- package/dist/issue-planner.d.mts.map +1 -1
- package/dist/issue-planner.mjs +2 -2
- package/dist/migration.d.mts +5 -5
- package/dist/migration.d.mts.map +1 -1
- package/dist/migration.mjs +4 -4
- package/dist/namespace-ids-xtp_ZY86.mjs +7 -0
- package/dist/namespace-ids-xtp_ZY86.mjs.map +1 -0
- package/dist/native-type-normalizer.mjs +37 -1
- package/dist/native-type-normalizer.mjs.map +1 -0
- package/dist/nodes-CSkPX3rI.d.mts +120 -0
- package/dist/nodes-CSkPX3rI.d.mts.map +1 -0
- package/dist/{nodes-Bbhs2rwj.mjs → nodes-Dh__NS58.mjs} +56 -2
- package/dist/nodes-Dh__NS58.mjs.map +1 -0
- package/dist/{op-factory-call-D_p5vxwt.mjs → op-factory-call-BKRnMgrB.mjs} +205 -31
- package/dist/op-factory-call-BKRnMgrB.mjs.map +1 -0
- package/dist/{op-factory-call-DmQEc3XV.d.mts → op-factory-call-Dt-Jx5JS.d.mts} +46 -15
- package/dist/op-factory-call-Dt-Jx5JS.d.mts.map +1 -0
- package/dist/op-factory-call.d.mts +2 -2
- package/dist/op-factory-call.mjs +2 -2
- package/dist/pack.d.mts +115 -3
- package/dist/pack.d.mts.map +1 -1
- package/dist/pack.mjs +1 -1
- package/dist/planner-BMBRPzsv.mjs +367 -0
- package/dist/planner-BMBRPzsv.mjs.map +1 -0
- package/dist/{planner-ddl-builders-B2wOwLqI.mjs → planner-ddl-builders-B8Nn6nHN.mjs} +12 -27
- package/dist/planner-ddl-builders-B8Nn6nHN.mjs.map +1 -0
- package/dist/planner-ddl-builders.d.mts +4 -6
- package/dist/planner-ddl-builders.d.mts.map +1 -1
- package/dist/planner-ddl-builders.mjs +2 -2
- package/dist/planner-identity-values-CJPha2Sz.mjs.map +1 -1
- package/dist/planner-identity-values.d.mts +8 -2
- package/dist/planner-identity-values.d.mts.map +1 -1
- package/dist/planner-identity-values.mjs +2 -2
- package/dist/{planner-produced-postgres-migration-QqHa2C2l.d.mts → planner-produced-postgres-migration-C0a7I1-e.d.mts} +4 -4
- package/dist/{planner-produced-postgres-migration-QqHa2C2l.d.mts.map → planner-produced-postgres-migration-C0a7I1-e.d.mts.map} +1 -1
- package/dist/{planner-produced-postgres-migration-Cji5vxUf.mjs → planner-produced-postgres-migration-Dp6IO_gj.mjs} +3 -3
- package/dist/{planner-produced-postgres-migration-Cji5vxUf.mjs.map → planner-produced-postgres-migration-Dp6IO_gj.mjs.map} +1 -1
- package/dist/planner-produced-postgres-migration.d.mts +1 -1
- package/dist/planner-produced-postgres-migration.mjs +1 -1
- package/dist/{planner-sql-checks-jqUUGyQR.mjs → planner-sql-checks-Cze3vMfe.mjs} +2 -2
- package/dist/{planner-sql-checks-jqUUGyQR.mjs.map → planner-sql-checks-Cze3vMfe.mjs.map} +1 -1
- package/dist/planner-sql-checks.d.mts +2 -2
- package/dist/planner-sql-checks.d.mts.map +1 -1
- package/dist/planner-sql-checks.mjs +1 -1
- package/dist/{planner-target-details-CIY6tLeo.d.mts → planner-target-details-HkP4RrRO.d.mts} +2 -2
- package/dist/planner-target-details-HkP4RrRO.d.mts.map +1 -0
- package/dist/planner-target-details.d.mts +1 -1
- package/dist/planner.d.mts +55 -17
- package/dist/planner.d.mts.map +1 -1
- package/dist/planner.mjs +3 -2
- package/dist/{postgres-contract-serializer-k3TAcPMY.mjs → postgres-contract-view-3xfUgjnC.mjs} +44 -41
- package/dist/postgres-contract-view-3xfUgjnC.mjs.map +1 -0
- package/dist/postgres-contract-view-C9j5cqP0.d.mts +34 -0
- package/dist/postgres-contract-view-C9j5cqP0.d.mts.map +1 -0
- package/dist/postgres-database-schema-node-C9bTuMrd.d.mts +190 -0
- package/dist/postgres-database-schema-node-C9bTuMrd.d.mts.map +1 -0
- package/dist/{postgres-migration-B5jKrXv3.mjs → postgres-migration-D0jwzYDT.mjs} +21 -2
- package/dist/postgres-migration-D0jwzYDT.mjs.map +1 -0
- package/dist/{postgres-migration-Y4YBJqkS.d.mts → postgres-migration-DFaxuRyI.d.mts} +20 -7
- package/dist/postgres-migration-DFaxuRyI.d.mts.map +1 -0
- package/dist/postgres-native-enum-xdiqmBf_.mjs +41 -0
- package/dist/postgres-native-enum-xdiqmBf_.mjs.map +1 -0
- package/dist/postgres-rls-policy--CSddvMR.d.mts +52 -0
- package/dist/postgres-rls-policy--CSddvMR.d.mts.map +1 -0
- package/dist/{postgres-schema-COGZ1ark.mjs → postgres-schema-CajYAwny.mjs} +135 -7
- package/dist/postgres-schema-CajYAwny.mjs.map +1 -0
- package/dist/postgres-schema-DqnhQRvR.d.mts +226 -0
- package/dist/postgres-schema-DqnhQRvR.d.mts.map +1 -0
- package/dist/postgres-table-schema-node-BgaSrxYN.mjs +249 -0
- package/dist/postgres-table-schema-node-BgaSrxYN.mjs.map +1 -0
- package/dist/render-ops.d.mts +1 -1
- package/dist/{render-typescript-KMgosran.mjs → render-typescript-7yqILcwr.mjs} +45 -16
- package/dist/render-typescript-7yqILcwr.mjs.map +1 -0
- package/dist/render-typescript.mjs +1 -1
- package/dist/resolve-ddl-schema-Bv1ZvjX8.mjs +22 -0
- package/dist/resolve-ddl-schema-Bv1ZvjX8.mjs.map +1 -0
- package/dist/rls-canonicalize.d.mts +2 -0
- package/dist/rls-canonicalize.mjs +2 -0
- package/dist/runtime.d.mts +6 -8
- package/dist/runtime.d.mts.map +1 -1
- package/dist/runtime.mjs +3 -3
- package/dist/runtime.mjs.map +1 -1
- package/dist/schema-ir-annotations.d.mts +15 -0
- package/dist/schema-ir-annotations.d.mts.map +1 -0
- package/dist/schema-ir-annotations.mjs +2 -0
- package/dist/schema-node-kinds-ClScchhi.mjs +76 -0
- package/dist/schema-node-kinds-ClScchhi.mjs.map +1 -0
- package/dist/types.d.mts +4 -140
- package/dist/types.mjs +3 -2
- package/package.json +23 -17
- package/src/contract-free/checks.ts +73 -0
- package/src/contract-free/ddl.ts +45 -1
- package/src/core/authoring.ts +287 -2
- package/src/core/codec-ids.ts +1 -0
- package/src/core/codec-type-map.ts +2 -0
- package/src/core/codecs.ts +141 -1
- package/src/core/ddl/nodes.ts +94 -2
- package/src/core/default-normalizer.ts +122 -2
- package/src/core/descriptor-meta.ts +6 -1
- package/src/core/entity-kinds.ts +30 -0
- package/src/core/migrations/bound-schema.ts +10 -0
- package/src/core/migrations/column-ddl-rendering.ts +117 -0
- package/src/core/migrations/contract-to-postgres-database-schema-node.ts +149 -0
- package/src/core/migrations/control-policy.ts +70 -47
- package/src/core/migrations/diff-database-schema.ts +280 -0
- package/src/core/migrations/issue-planner.ts +647 -652
- package/src/core/migrations/op-factory-call.ts +109 -21
- package/src/core/migrations/operations/columns.ts +24 -12
- package/src/core/migrations/operations/constraints.ts +1 -1
- package/src/core/migrations/operations/data-transform.ts +6 -0
- package/src/core/migrations/operations/dependencies.ts +2 -1
- package/src/core/migrations/operations/rls.ts +106 -0
- package/src/core/migrations/operations/shared.ts +0 -30
- package/src/core/migrations/planner-ddl-builders.ts +20 -58
- package/src/core/migrations/planner-identity-values.ts +1 -1
- package/src/core/migrations/planner-recipes.ts +31 -13
- package/src/core/migrations/planner-sql-checks.ts +1 -1
- package/src/core/migrations/planner-strategies.ts +248 -216
- package/src/core/migrations/planner-target-details.ts +3 -1
- package/src/core/migrations/planner.ts +297 -59
- package/src/core/migrations/postgres-migration.ts +34 -4
- package/src/core/migrations/render-typescript.ts +42 -15
- package/src/core/migrations/resolve-ddl-schema.ts +26 -0
- package/src/core/migrations/runner.ts +10 -16
- package/src/core/migrations/verify-postgres-namespaces.ts +47 -30
- package/src/core/namespace-ids.ts +3 -0
- package/src/core/postgres-contract-serializer.ts +41 -71
- package/src/core/postgres-contract-view.ts +48 -0
- package/src/core/postgres-native-enum.ts +51 -0
- package/src/core/postgres-rls-policy.ts +64 -0
- package/src/core/postgres-role.ts +37 -0
- package/src/core/postgres-schema-verifier.ts +10 -7
- package/src/core/postgres-schema.ts +62 -14
- package/src/core/postgres-validators.ts +27 -0
- package/src/core/psl-infer/infer-psl-contract.ts +1068 -0
- package/src/core/psl-infer/postgres-default-mapping.ts +16 -0
- package/src/core/psl-infer/postgres-type-map.ts +157 -0
- package/src/core/rls/canonicalize.ts +48 -0
- package/src/core/schema-ir/postgres-database-schema-node.ts +60 -0
- package/src/core/schema-ir/postgres-namespace-schema-node.ts +60 -0
- package/src/core/schema-ir/postgres-policy-schema-node.ts +90 -0
- package/src/core/schema-ir/postgres-role-schema-node.ts +63 -0
- package/src/core/schema-ir/postgres-table-schema-node.ts +118 -0
- package/src/core/schema-ir/schema-node-kinds.ts +106 -0
- package/src/exports/contract-free.ts +7 -1
- package/src/exports/control.ts +27 -33
- package/src/exports/ddl.ts +4 -0
- package/src/exports/diff-database-schema.ts +7 -0
- package/src/exports/issue-planner.ts +1 -1
- package/src/exports/migration.ts +1 -0
- package/src/exports/op-factory-call.ts +1 -0
- package/src/exports/planner-ddl-builders.ts +0 -2
- package/src/exports/planner-identity-values.ts +4 -1
- package/src/exports/planner.ts +1 -0
- package/src/exports/rls-canonicalize.ts +6 -0
- package/src/exports/runtime.ts +1 -0
- package/src/exports/schema-ir-annotations.ts +1 -0
- package/src/exports/types.ts +28 -0
- package/dist/codec-ids-BvytN2P8.mjs.map +0 -1
- package/dist/codec-ids-CnXu9Qy3.d.mts.map +0 -1
- package/dist/codec-types-DHCkwPKE.d.mts.map +0 -1
- package/dist/codecs--0A5_4Bq.d.mts.map +0 -1
- package/dist/ddl-QDyOSeLc.mjs.map +0 -1
- package/dist/default-normalizer-DyyCHQWs.mjs +0 -131
- package/dist/default-normalizer-DyyCHQWs.mjs.map +0 -1
- package/dist/descriptor-meta-CpGygXpI.mjs +0 -140
- package/dist/descriptor-meta-CpGygXpI.mjs.map +0 -1
- package/dist/issue-planner-DL6g3CmE.mjs +0 -824
- package/dist/issue-planner-DL6g3CmE.mjs.map +0 -1
- package/dist/native-type-normalizer-Bc9XJzWC.mjs +0 -38
- package/dist/native-type-normalizer-Bc9XJzWC.mjs.map +0 -1
- package/dist/nodes-Bbhs2rwj.mjs.map +0 -1
- package/dist/nodes-pLeLgdis.d.mts +0 -67
- package/dist/nodes-pLeLgdis.d.mts.map +0 -1
- package/dist/op-factory-call-D_p5vxwt.mjs.map +0 -1
- package/dist/op-factory-call-DmQEc3XV.d.mts.map +0 -1
- package/dist/planner-Bs_baQax.mjs +0 -324
- package/dist/planner-Bs_baQax.mjs.map +0 -1
- package/dist/planner-ddl-builders-B2wOwLqI.mjs.map +0 -1
- package/dist/planner-target-details-CIY6tLeo.d.mts.map +0 -1
- package/dist/postgres-contract-serializer-k3TAcPMY.mjs.map +0 -1
- package/dist/postgres-migration-B5jKrXv3.mjs.map +0 -1
- package/dist/postgres-migration-Y4YBJqkS.d.mts.map +0 -1
- package/dist/postgres-schema-COGZ1ark.mjs.map +0 -1
- package/dist/render-typescript-KMgosran.mjs.map +0 -1
- package/dist/types.d.mts.map +0 -1
- package/src/core/postgres-enum-type-schema.ts +0 -17
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { r as RlsPolicyOperation } from "./postgres-rls-policy--CSddvMR.mjs";
|
|
2
|
+
import { PrimaryKey, SqlAnnotations, SqlCheckConstraintIR, SqlColumnIR, SqlForeignKeyIR, SqlIndexIR, SqlSchemaIRNode, SqlTableIRInput, SqlUniqueIR } from "@prisma-next/sql-schema-ir/types";
|
|
3
|
+
import { DiffableNode } from "@prisma-next/framework-components/control";
|
|
4
|
+
|
|
5
|
+
//#region src/core/schema-ir/postgres-policy-schema-node.d.ts
|
|
6
|
+
interface PostgresPolicySchemaNodeInput {
|
|
7
|
+
/** Full wire name: `<prefix>_<8hex>`. */
|
|
8
|
+
readonly name: string;
|
|
9
|
+
/** User-supplied prefix (the part before the `_<8hex>` suffix). */
|
|
10
|
+
readonly prefix: string;
|
|
11
|
+
/** Name of the table this policy attaches to, by name within the same schema. */
|
|
12
|
+
readonly tableName: string;
|
|
13
|
+
/** Namespace coordinate (schema name). */
|
|
14
|
+
readonly namespaceId: string;
|
|
15
|
+
readonly operation: RlsPolicyOperation;
|
|
16
|
+
/** Sorted role names rendered in `TO <roles>`. */
|
|
17
|
+
readonly roles: readonly string[];
|
|
18
|
+
/** USING predicate SQL string, if present. */
|
|
19
|
+
readonly using?: string;
|
|
20
|
+
/** WITH CHECK predicate SQL string, if present. */
|
|
21
|
+
readonly withCheck?: string;
|
|
22
|
+
/** `true` = `AS PERMISSIVE`, `false` = `AS RESTRICTIVE`. */
|
|
23
|
+
readonly permissive: boolean;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Schema-diff leaf node for a Postgres row-level security policy.
|
|
27
|
+
*
|
|
28
|
+
* This is a derived, transient node walked by the differ — it is NEVER serialized.
|
|
29
|
+
* Built by project-from-contract and project-from-database from their respective
|
|
30
|
+
* `PostgresRlsPolicy` contract entities / introspected rows.
|
|
31
|
+
*
|
|
32
|
+
* `id` is the wire name (`<prefix>_<sha256(body)[0..8]>`), so name-equality is
|
|
33
|
+
* body-equality. `isEqualTo` compares names only — never byte-compare predicate
|
|
34
|
+
* bodies, because Postgres reprints them.
|
|
35
|
+
*/
|
|
36
|
+
declare class PostgresPolicySchemaNode extends SqlSchemaIRNode implements DiffableNode {
|
|
37
|
+
readonly nodeKind: "postgres-policy";
|
|
38
|
+
readonly name: string;
|
|
39
|
+
readonly prefix: string;
|
|
40
|
+
readonly tableName: string;
|
|
41
|
+
readonly namespaceId: string;
|
|
42
|
+
readonly operation: RlsPolicyOperation;
|
|
43
|
+
readonly roles: readonly string[];
|
|
44
|
+
readonly using?: string;
|
|
45
|
+
readonly withCheck?: string;
|
|
46
|
+
readonly permissive: boolean;
|
|
47
|
+
constructor(input: PostgresPolicySchemaNodeInput);
|
|
48
|
+
get id(): string;
|
|
49
|
+
children(): readonly DiffableNode[];
|
|
50
|
+
isEqualTo(other: DiffableNode): boolean;
|
|
51
|
+
static is(node: SqlSchemaIRNode): node is PostgresPolicySchemaNode;
|
|
52
|
+
static assert(node: SqlSchemaIRNode | undefined): asserts node is PostgresPolicySchemaNode;
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region src/core/schema-ir/postgres-table-schema-node.d.ts
|
|
56
|
+
interface PostgresTableSchemaNodeInput extends SqlTableIRInput {
|
|
57
|
+
readonly policies?: readonly PostgresPolicySchemaNode[];
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Postgres-specific table schema-diff node. Carries all `SqlTableIR` fields
|
|
61
|
+
* plus `policies`, and implements `DiffableNode` so the table instance is
|
|
62
|
+
* directly the diff-tree node — no separate wrapper needed.
|
|
63
|
+
*
|
|
64
|
+
* Extends `SqlSchemaIRNode` directly rather than `SqlTableIR` because
|
|
65
|
+
* `SqlTableIR` calls `freezeNode` in its own constructor, which prevents
|
|
66
|
+
* subclass field initialisation.
|
|
67
|
+
*
|
|
68
|
+
* `id` is the table name. `isEqualTo` is identity — two table nodes are equal
|
|
69
|
+
* iff their ids (names) match; the table's own structural drift is entirely
|
|
70
|
+
* expressed by its children. `children()` returns every column, the primary
|
|
71
|
+
* key (when present), every foreign key, unique, index, and check constraint,
|
|
72
|
+
* plus the policy nodes — one flat list, so a drifted column and a drifted
|
|
73
|
+
* policy are both reported by the same walk. Order is deterministic (object
|
|
74
|
+
* key order for columns, array order for the rest) so two structurally equal
|
|
75
|
+
* tables always produce the same child list.
|
|
76
|
+
*/
|
|
77
|
+
declare class PostgresTableSchemaNode extends SqlSchemaIRNode implements DiffableNode {
|
|
78
|
+
readonly nodeKind: "postgres-table";
|
|
79
|
+
readonly name: string;
|
|
80
|
+
readonly columns: Readonly<Record<string, SqlColumnIR>>;
|
|
81
|
+
readonly foreignKeys: ReadonlyArray<SqlForeignKeyIR>;
|
|
82
|
+
readonly uniques: ReadonlyArray<SqlUniqueIR>;
|
|
83
|
+
readonly indexes: ReadonlyArray<SqlIndexIR>;
|
|
84
|
+
readonly primaryKey?: PrimaryKey;
|
|
85
|
+
readonly annotations?: SqlAnnotations;
|
|
86
|
+
readonly checks?: ReadonlyArray<SqlCheckConstraintIR>;
|
|
87
|
+
readonly policies: readonly PostgresPolicySchemaNode[];
|
|
88
|
+
constructor(input: PostgresTableSchemaNodeInput);
|
|
89
|
+
get id(): string;
|
|
90
|
+
isEqualTo(other: DiffableNode): boolean;
|
|
91
|
+
children(): readonly DiffableNode[];
|
|
92
|
+
static is(node: SqlSchemaIRNode): node is PostgresTableSchemaNode;
|
|
93
|
+
static assert(node: SqlSchemaIRNode): asserts node is PostgresTableSchemaNode;
|
|
94
|
+
}
|
|
95
|
+
//#endregion
|
|
96
|
+
//#region src/core/schema-ir/postgres-namespace-schema-node.d.ts
|
|
97
|
+
interface PostgresNamespaceSchemaNodeInput {
|
|
98
|
+
readonly schemaName: string;
|
|
99
|
+
readonly tables: Readonly<Record<string, PostgresTableSchemaNode>>;
|
|
100
|
+
readonly nativeEnumTypeNames: readonly string[];
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* One-per-Postgres-schema diff-tree node. Groups the tables belonging to a
|
|
104
|
+
* single namespace. Per-schema consumers (the relational planner,
|
|
105
|
+
* toSchemaView) read this node's `tables` field structurally via
|
|
106
|
+
* `blindCast`/`SqlSchemaIRNode` — not through a static `SqlSchemaIR`
|
|
107
|
+
* assignment — because `nodeKind` now carries this node's own literal
|
|
108
|
+
* (`postgres-namespace`), distinct from `SqlSchemaIR`'s own (`sql-schema`).
|
|
109
|
+
*
|
|
110
|
+
* `id` is the schema name. `isEqualTo` is identity — two namespace nodes are
|
|
111
|
+
* equal iff their ids (schema names) match. `children()` returns the table
|
|
112
|
+
* nodes. Per-schema metadata is carried on the typed `nativeEnumTypeNames`
|
|
113
|
+
* field, not an annotations bag.
|
|
114
|
+
*/
|
|
115
|
+
declare class PostgresNamespaceSchemaNode extends SqlSchemaIRNode implements DiffableNode {
|
|
116
|
+
readonly nodeKind: "postgres-namespace";
|
|
117
|
+
readonly schemaName: string;
|
|
118
|
+
readonly tables: Readonly<Record<string, PostgresTableSchemaNode>>;
|
|
119
|
+
readonly nativeEnumTypeNames: readonly string[];
|
|
120
|
+
constructor(input: PostgresNamespaceSchemaNodeInput);
|
|
121
|
+
get id(): string;
|
|
122
|
+
isEqualTo(other: DiffableNode): boolean;
|
|
123
|
+
children(): readonly DiffableNode[];
|
|
124
|
+
static is(node: SqlSchemaIRNode): node is PostgresNamespaceSchemaNode;
|
|
125
|
+
static assert(node: SqlSchemaIRNode): asserts node is PostgresNamespaceSchemaNode;
|
|
126
|
+
}
|
|
127
|
+
//#endregion
|
|
128
|
+
//#region src/core/schema-ir/postgres-role-schema-node.d.ts
|
|
129
|
+
interface PostgresRoleSchemaNodeInput {
|
|
130
|
+
readonly name: string;
|
|
131
|
+
/**
|
|
132
|
+
* Namespace coordinate. Roles are cluster-scoped; callers pass
|
|
133
|
+
* `UNBOUND_NAMESPACE_ID` from `@prisma-next/framework-components/ir`.
|
|
134
|
+
*/
|
|
135
|
+
readonly namespaceId: string;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Schema-diff leaf node for a Postgres database role.
|
|
139
|
+
*
|
|
140
|
+
* This is a derived, transient node walked by the differ — it is NEVER serialized.
|
|
141
|
+
* Built by project-from-contract and project-from-database from their respective
|
|
142
|
+
* `PostgresRole` contract entities / introspected rows.
|
|
143
|
+
*
|
|
144
|
+
* Roles are cluster-scoped, so `id` is the role name alone. `isEqualTo` compares
|
|
145
|
+
* names — name-equality is role-equality for cluster-scoped objects.
|
|
146
|
+
*/
|
|
147
|
+
declare class PostgresRoleSchemaNode extends SqlSchemaIRNode implements DiffableNode {
|
|
148
|
+
readonly nodeKind: "postgres-role";
|
|
149
|
+
readonly name: string;
|
|
150
|
+
readonly namespaceId: string;
|
|
151
|
+
constructor(input: PostgresRoleSchemaNodeInput);
|
|
152
|
+
get id(): string;
|
|
153
|
+
children(): readonly DiffableNode[];
|
|
154
|
+
isEqualTo(other: DiffableNode): boolean;
|
|
155
|
+
static is(node: SqlSchemaIRNode): node is PostgresRoleSchemaNode;
|
|
156
|
+
static assert(node: SqlSchemaIRNode): asserts node is PostgresRoleSchemaNode;
|
|
157
|
+
}
|
|
158
|
+
//#endregion
|
|
159
|
+
//#region src/core/schema-ir/postgres-database-schema-node.d.ts
|
|
160
|
+
interface PostgresDatabaseSchemaNodeInput {
|
|
161
|
+
readonly namespaces: Readonly<Record<string, PostgresNamespaceSchemaNode>>;
|
|
162
|
+
readonly roles: readonly PostgresRoleSchemaNode[];
|
|
163
|
+
readonly existingSchemas: readonly string[];
|
|
164
|
+
readonly pgVersion: string;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* The root of the Postgres schema-diff tree: one node per database.
|
|
168
|
+
*
|
|
169
|
+
* `id` is the fixed sentinel `'database'` — the root has no siblings and
|
|
170
|
+
* the value is never emitted into migration paths. `isEqualTo` is identity
|
|
171
|
+
* (roots always share the `'database'` id). `children()` returns namespace
|
|
172
|
+
* nodes only; roles are held on the root but not yielded (role diffing is a
|
|
173
|
+
* later slice).
|
|
174
|
+
*/
|
|
175
|
+
declare class PostgresDatabaseSchemaNode extends SqlSchemaIRNode implements DiffableNode {
|
|
176
|
+
readonly nodeKind: "postgres-database";
|
|
177
|
+
readonly namespaces: Readonly<Record<string, PostgresNamespaceSchemaNode>>;
|
|
178
|
+
readonly roles: readonly PostgresRoleSchemaNode[];
|
|
179
|
+
readonly existingSchemas: readonly string[];
|
|
180
|
+
readonly pgVersion: string;
|
|
181
|
+
constructor(input: PostgresDatabaseSchemaNodeInput);
|
|
182
|
+
get id(): string;
|
|
183
|
+
isEqualTo(other: DiffableNode): boolean;
|
|
184
|
+
children(): readonly DiffableNode[];
|
|
185
|
+
static is(node: SqlSchemaIRNode): node is PostgresDatabaseSchemaNode;
|
|
186
|
+
static assert(node: SqlSchemaIRNode): asserts node is PostgresDatabaseSchemaNode;
|
|
187
|
+
}
|
|
188
|
+
//#endregion
|
|
189
|
+
export { PostgresNamespaceSchemaNode as a, PostgresTableSchemaNodeInput as c, PostgresRoleSchemaNodeInput as i, PostgresPolicySchemaNode as l, PostgresDatabaseSchemaNodeInput as n, PostgresNamespaceSchemaNodeInput as o, PostgresRoleSchemaNode as r, PostgresTableSchemaNode as s, PostgresDatabaseSchemaNode as t, PostgresPolicySchemaNodeInput as u };
|
|
190
|
+
//# sourceMappingURL=postgres-database-schema-node-C9bTuMrd.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-database-schema-node-C9bTuMrd.d.mts","names":[],"sources":["../src/core/schema-ir/postgres-policy-schema-node.ts","../src/core/schema-ir/postgres-table-schema-node.ts","../src/core/schema-ir/postgres-namespace-schema-node.ts","../src/core/schema-ir/postgres-role-schema-node.ts","../src/core/schema-ir/postgres-database-schema-node.ts"],"mappings":";;;;;UAOiB,6BAAA;;WAEN,IAAA;EAFmC;EAAA,SAInC,MAAA;EAK6B;EAAA,SAH7B,SAAA;EAFA;EAAA,SAIA,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AAA;AAAA;;;;;;;;;;cAYE,0BAAA,SAAmC,eAAA,YAA2B,YAAA;EAAA,SACvD,QAAA;EAAA,SAET,UAAA,EAAY,QAAA,CAAS,MAAA,SAAe,2BAAA;EAAA,SACpC,KAAA,WAAgB,sBAAA;EAAA,SAChB,eAAA;EAAA,SACA,SAAA;cAEG,KAAA,EAAO,+BAAA;EAAA,IASf,EAAA;EAIJ,SAAA,CAAU,KAAA,EAAO,YAAA;EAIjB,QAAA,aAAqB,YAAA;EAAA,OAId,EAAA,CAAG,IAAA,EAAM,eAAA,GAAkB,IAAA,IAAQ,0BAAA;EAAA,OAInC,MAAA,CAAO,IAAA,EAAM,eAAA,WAA0B,IAAA,IAAQ,0BAAA;AAAA"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as installExtension, E as SetNotNullCall, S as DropTableCall, T as SetDefaultCall, _ as DropConstraintCall, b as DropNotNullCall, c as AlterColumnTypeCall, f as CreateSchemaCall, g as DropColumnCall, h as DropCheckConstraintCall, n as AddColumnCall, o as AddPrimaryKeyCall, p as CreateTableCall, r as AddForeignKeyCall, s as AddUniqueCall, t as AddCheckConstraintCall, u as CreateIndexCall, v as DropDefaultCall, y as DropIndexCall } from "./op-factory-call-BKRnMgrB.mjs";
|
|
2
2
|
import { t as errorPostgresMigrationStackMissing } from "./errors-CUk87ByX.mjs";
|
|
3
|
+
import { t as PostgresContractView } from "./postgres-contract-view-3xfUgjnC.mjs";
|
|
3
4
|
import { t as dataTransform } from "./data-transform-BOWpliq8.mjs";
|
|
4
5
|
import { Migration } from "@prisma-next/family-sql/migration";
|
|
6
|
+
import { MigrationContractViews } from "@prisma-next/migration-tools/migration";
|
|
5
7
|
//#region src/core/migrations/postgres-migration.ts
|
|
6
8
|
/**
|
|
7
9
|
* Target-owned base class for Postgres migrations.
|
|
@@ -39,11 +41,28 @@ var PostgresMigration = class extends Migration {
|
|
|
39
41
|
* throws in that case to surface the misuse.
|
|
40
42
|
*/
|
|
41
43
|
controlAdapter;
|
|
44
|
+
#endView = new MigrationContractViews(this, "PostgresMigration", (json) => PostgresContractView.fromJson(json));
|
|
45
|
+
#startView = new MigrationContractViews(this, "PostgresMigration", (json) => PostgresContractView.fromJson(json));
|
|
42
46
|
constructor(stack) {
|
|
43
47
|
super(stack);
|
|
44
48
|
this.controlAdapter = stack?.adapter ? stack.adapter.create(stack) : void 0;
|
|
45
49
|
}
|
|
46
50
|
/**
|
|
51
|
+
* The typed, schema-qualified Postgres view over this migration's end-state
|
|
52
|
+
* contract — `this.endContract.namespace.<schema>.table.<name>`, etc. Throws
|
|
53
|
+
* if no `endContractJson` was provided.
|
|
54
|
+
*/
|
|
55
|
+
get endContract() {
|
|
56
|
+
return this.#endView.endContract;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The typed Postgres view over this migration's start-state contract, or
|
|
60
|
+
* `null` for a baseline migration (no `startContractJson`).
|
|
61
|
+
*/
|
|
62
|
+
get startContract() {
|
|
63
|
+
return this.#startView.startContract;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
47
66
|
* Instance-method wrapper around the free `dataTransform` factory that
|
|
48
67
|
* supplies the stored control adapter. Authors call this from inside
|
|
49
68
|
* `get operations()`; the adapter argument is hidden from the call site.
|
|
@@ -142,4 +161,4 @@ var PostgresMigration = class extends Migration {
|
|
|
142
161
|
//#endregion
|
|
143
162
|
export { PostgresMigration as t };
|
|
144
163
|
|
|
145
|
-
//# sourceMappingURL=postgres-migration-
|
|
164
|
+
//# sourceMappingURL=postgres-migration-D0jwzYDT.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-migration-D0jwzYDT.mjs","names":["SqlMigration","#endView","#startView"],"sources":["../src/core/migrations/postgres-migration.ts"],"sourcesContent":["import type { Contract } from '@prisma-next/contract/types';\nimport type { SqlMigrationPlanOperation } from '@prisma-next/family-sql/control';\nimport type { SqlControlAdapter } from '@prisma-next/family-sql/control-adapter';\nimport { Migration as SqlMigration } from '@prisma-next/family-sql/migration';\nimport type { ControlStack } from '@prisma-next/framework-components/control';\nimport { MigrationContractViews } from '@prisma-next/migration-tools/migration';\nimport type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport type { DdlColumn, DdlTableConstraint } from '@prisma-next/sql-relational-core/ast';\nimport { errorPostgresMigrationStackMissing } from '../errors';\nimport { PostgresContractView } from '../postgres-contract-view';\nimport {\n AddCheckConstraintCall,\n AddColumnCall,\n AddForeignKeyCall,\n AddPrimaryKeyCall,\n AddUniqueCall,\n AlterColumnTypeCall,\n type AlterColumnTypeOptions,\n CreateIndexCall,\n CreateSchemaCall,\n CreateTableCall,\n DropCheckConstraintCall,\n DropColumnCall,\n DropConstraintCall,\n DropDefaultCall,\n DropIndexCall,\n DropNotNullCall,\n DropTableCall,\n SetDefaultCall,\n SetNotNullCall,\n} from './op-factory-call';\nimport { type DataTransformOptions, dataTransform } from './operations/data-transform';\nimport { installExtension } from './operations/dependencies';\nimport type { CreateIndexExtras } from './operations/indexes';\nimport type { ForeignKeySpec } from './operations/shared';\nimport type { PostgresPlanTargetDetails } from './planner-target-details';\n\n/**\n * Target-owned base class for Postgres migrations.\n *\n * Fixes the `SqlMigration` generic to `PostgresPlanTargetDetails` and the\n * abstract `targetId` to the Postgres target-id string literal, so both\n * user-authored migrations and renderer-generated scaffolds (the output of\n * `renderCallsToTypeScript`) can extend `PostgresMigration` directly without\n * redeclaring target-local identity.\n *\n * Mirrors `MongoMigration` in `@prisma-next/family-mongo`: the renderer\n * emits `extends Migration` against a facade re-export of this class\n * from `@prisma-next/postgres/migration`, keeping the authoring surface\n * target-scoped rather than family-scoped.\n *\n * The constructor materializes a single Postgres `SqlControlAdapter` from\n * `stack.adapter.create(stack)` and stores it; the protected `dataTransform`\n * instance method forwards to the free `dataTransform` factory with that\n * stored adapter, so user migrations can write `this.dataTransform(...)`\n * without threading the adapter through every call.\n *\n * Every method requires an explicit `schema`. Postgres migrations name their\n * schema deliberately — there is no default and no `search_path`-relative\n * option. A migration that left the schema unspecified would resolve against\n * whatever `search_path` the connection happened to carry, and that ambiguity\n * is an antipattern in a migration. (The unbound/unspecified namespace concept\n * remains for SQLite, which has no schemas, and for Mongo's connection `db`.)\n */\nexport abstract class PostgresMigration<\n Start extends Contract<SqlStorage> = Contract<SqlStorage>,\n End extends Contract<SqlStorage> = Contract<SqlStorage>,\n> extends SqlMigration<PostgresPlanTargetDetails, 'postgres', Start, End> {\n readonly targetId = 'postgres' as const;\n\n /**\n * Materialized Postgres control adapter, created once per migration\n * instance from the injected stack. `undefined` only when the migration\n * was instantiated without a stack (test fixtures); `dataTransform`\n * throws in that case to surface the misuse.\n */\n protected readonly controlAdapter: SqlControlAdapter<'postgres'> | undefined;\n\n #endView = new MigrationContractViews<PostgresContractView<End>>(\n this,\n 'PostgresMigration',\n (json) => PostgresContractView.fromJson<End>(json),\n );\n #startView = new MigrationContractViews<PostgresContractView<Start>>(\n this,\n 'PostgresMigration',\n (json) => PostgresContractView.fromJson<Start>(json),\n );\n\n constructor(stack?: ControlStack<'sql', 'postgres'>) {\n super(stack);\n // The descriptor `create()` is typed as the wider `ControlAdapterInstance`;\n // the Postgres descriptor concretely returns a `SqlControlAdapter<'postgres'>`,\n // so the cast holds for any Postgres-target stack assembled at runtime.\n this.controlAdapter = stack?.adapter\n ? (stack.adapter.create(stack) as SqlControlAdapter<'postgres'>)\n : undefined;\n }\n\n /**\n * The typed, schema-qualified Postgres view over this migration's end-state\n * contract — `this.endContract.namespace.<schema>.table.<name>`, etc. Throws\n * if no `endContractJson` was provided.\n */\n get endContract(): PostgresContractView<End> {\n return this.#endView.endContract;\n }\n\n /**\n * The typed Postgres view over this migration's start-state contract, or\n * `null` for a baseline migration (no `startContractJson`).\n */\n get startContract(): PostgresContractView<Start> | null {\n return this.#startView.startContract;\n }\n\n /**\n * Instance-method wrapper around the free `dataTransform` factory that\n * supplies the stored control adapter. Authors call this from inside\n * `get operations()`; the adapter argument is hidden from the call site.\n */\n protected dataTransform<TContract extends Contract<SqlStorage>>(\n contract: TContract,\n name: string,\n options: DataTransformOptions,\n ): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return dataTransform(contract, name, options, this.controlAdapter);\n }\n\n /**\n * Emit a `CREATE TABLE` migration operation. Builds a typed DDL node from\n * the supplied options and lowers it through the stored control adapter.\n * Throws if no adapter is present (i.e. migration instantiated without a stack).\n */\n protected createTable(options: {\n readonly schema: string;\n readonly table: string;\n readonly ifNotExists?: boolean;\n readonly columns: readonly DdlColumn[];\n readonly constraints?: readonly DdlTableConstraint[];\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new CreateTableCall(\n options.schema,\n options.table,\n options.columns,\n options.constraints,\n ).toOp(this.controlAdapter);\n }\n\n /**\n * Emit a `CREATE SCHEMA` migration operation. Builds a typed DDL node from\n * the supplied options and lowers it through the stored control adapter.\n * Throws if no adapter is present (i.e. migration instantiated without a stack).\n */\n protected createSchema(options: {\n readonly schema: string;\n readonly ifNotExists?: boolean;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new CreateSchemaCall(options.schema).toOp(this.controlAdapter);\n }\n\n protected addColumn(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: DdlColumn;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new AddColumnCall(options.schema, options.table, options.column).toOp(\n this.controlAdapter,\n );\n }\n\n protected addPrimaryKey(options: {\n readonly schema: string;\n readonly table: string;\n readonly constraint: string;\n readonly columns: readonly string[];\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new AddPrimaryKeyCall(\n options.schema,\n options.table,\n options.constraint,\n options.columns,\n ).toOp(this.controlAdapter);\n }\n\n protected addUnique(options: {\n readonly schema: string;\n readonly table: string;\n readonly constraint: string;\n readonly columns: readonly string[];\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new AddUniqueCall(\n options.schema,\n options.table,\n options.constraint,\n options.columns,\n ).toOp(this.controlAdapter);\n }\n\n protected addForeignKey(options: {\n readonly schema: string;\n readonly table: string;\n readonly foreignKey: ForeignKeySpec;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new AddForeignKeyCall(options.schema, options.table, options.foreignKey).toOp(\n this.controlAdapter,\n );\n }\n\n protected addCheckConstraint(options: {\n readonly schema: string;\n readonly table: string;\n readonly constraint: string;\n readonly column: string;\n readonly values: readonly string[];\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new AddCheckConstraintCall(\n options.schema,\n options.table,\n options.constraint,\n options.column,\n options.values,\n ).toOp(this.controlAdapter);\n }\n\n protected dropCheckConstraint(options: {\n readonly schema: string;\n readonly table: string;\n readonly constraint: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new DropCheckConstraintCall(options.schema, options.table, options.constraint).toOp(\n this.controlAdapter,\n );\n }\n\n protected dropConstraint(options: {\n readonly schema: string;\n readonly table: string;\n readonly constraint: string;\n readonly kind?: 'foreignKey' | 'unique' | 'primaryKey';\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new DropConstraintCall(\n options.schema,\n options.table,\n options.constraint,\n options.kind ?? 'unique',\n ).toOp(this.controlAdapter);\n }\n\n protected dropTable(options: {\n readonly schema: string;\n readonly table: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new DropTableCall(options.schema, options.table).toOp(this.controlAdapter);\n }\n\n protected dropColumn(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new DropColumnCall(options.schema, options.table, options.column).toOp(\n this.controlAdapter,\n );\n }\n\n protected alterColumnType(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n readonly options: AlterColumnTypeOptions;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new AlterColumnTypeCall(\n options.schema,\n options.table,\n options.column,\n options.options,\n ).toOp(this.controlAdapter);\n }\n\n protected setNotNull(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new SetNotNullCall(options.schema, options.table, options.column).toOp(\n this.controlAdapter,\n );\n }\n\n protected dropNotNull(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new DropNotNullCall(options.schema, options.table, options.column).toOp(\n this.controlAdapter,\n );\n }\n\n protected setDefault(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n readonly defaultSql: string;\n readonly operationClass?: 'additive' | 'widening';\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new SetDefaultCall(\n options.schema,\n options.table,\n options.column,\n options.defaultSql,\n options.operationClass,\n ).toOp(this.controlAdapter);\n }\n\n protected dropDefault(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new DropDefaultCall(options.schema, options.table, options.column).toOp(\n this.controlAdapter,\n );\n }\n\n protected createIndex(options: {\n readonly schema: string;\n readonly table: string;\n readonly index: string;\n readonly columns: readonly string[];\n readonly extras?: CreateIndexExtras;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new CreateIndexCall(\n options.schema,\n options.table,\n options.index,\n options.columns,\n options.extras,\n ).toOp(this.controlAdapter);\n }\n\n protected dropIndex(options: {\n readonly schema: string;\n readonly table: string;\n readonly index: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new DropIndexCall(options.schema, options.table, options.index).toOp(\n this.controlAdapter,\n );\n }\n\n protected installExtension(options: {\n readonly extensionName: string;\n readonly invariantId: string;\n readonly id: string;\n readonly label?: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return installExtension(options, this.controlAdapter);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgEA,IAAsB,oBAAtB,cAGUA,UAAgE;CACxE,WAAoB;;;;;;;CAQpB;CAEA,WAAW,IAAI,uBACb,MACA,sBACC,SAAS,qBAAqB,SAAc,IAAI,CACnD;CACA,aAAa,IAAI,uBACf,MACA,sBACC,SAAS,qBAAqB,SAAgB,IAAI,CACrD;CAEA,YAAY,OAAyC;EACnD,MAA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AI,eAAe,QAAQ,QAAQ,QAAQ,OAAO,QAAQ,MAAM,CAAC,CAAC,KACvE,KAAK,cACP;CACF;CAEA,YAAsB,SAI4C;EAChE,IAAI,CAAC,KAAK,gBACR,MAAM,mCAAmC;EAE3C,OAAO,IAAI,gBAAgB,QAAQ,QAAQ,QAAQ,OAAO,QAAQ,MAAM,CAAC,CAAC,KACxE,KAAK,cACP;CACF;CAEA,WAAqB,SAM6C;EAChE,IAAI,CAAC,KAAK,gBACR,MAAM,mCAAmC;EAE3C,OAAO,IAAI,eACT,QAAQ,QACR,QAAQ,OACR,QAAQ,QACR,QAAQ,YACR,QAAQ,cACV,CAAC,CAAC,KAAK,KAAK,cAAc;CAC5B;CAEA,YAAsB,SAI4C;EAChE,IAAI,CAAC,KAAK,gBACR,MAAM,mCAAmC;EAE3C,OAAO,IAAI,gBAAgB,QAAQ,QAAQ,QAAQ,OAAO,QAAQ,MAAM,CAAC,CAAC,KACxE,KAAK,cACP;CACF;CAEA,YAAsB,SAM4C;EAChE,IAAI,CAAC,KAAK,gBACR,MAAM,mCAAmC;EAE3C,OAAO,IAAI,gBACT,QAAQ,QACR,QAAQ,OACR,QAAQ,OACR,QAAQ,SACR,QAAQ,MACV,CAAC,CAAC,KAAK,KAAK,cAAc;CAC5B;CAEA,UAAoB,SAI8C;EAChE,IAAI,CAAC,KAAK,gBACR,MAAM,mCAAmC;EAE3C,OAAO,IAAI,cAAc,QAAQ,QAAQ,QAAQ,OAAO,QAAQ,KAAK,CAAC,CAAC,KACrE,KAAK,cACP;CACF;CAEA,iBAA2B,SAKuC;EAChE,IAAI,CAAC,KAAK,gBACR,MAAM,mCAAmC;EAE3C,OAAO,iBAAiB,SAAS,KAAK,cAAc;CACtD;AACF"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { t as PostgresPlanTargetDetails } from "./planner-target-details-
|
|
2
|
-
import { n as DataTransformOptions } from "./data-transform-
|
|
3
|
-
import {
|
|
1
|
+
import { t as PostgresPlanTargetDetails } from "./planner-target-details-HkP4RrRO.mjs";
|
|
2
|
+
import { n as DataTransformOptions } from "./data-transform-DPzwBMhW.mjs";
|
|
3
|
+
import { T as ForeignKeySpec, c as AlterColumnTypeOptions } from "./op-factory-call-Dt-Jx5JS.mjs";
|
|
4
|
+
import { t as PostgresContractView } from "./postgres-contract-view-C9j5cqP0.mjs";
|
|
4
5
|
import { DdlColumn, DdlTableConstraint } from "@prisma-next/sql-relational-core/ast";
|
|
5
|
-
import { SqlMigrationPlanOperation } from "@prisma-next/family-sql/control";
|
|
6
6
|
import { SqlStorage } from "@prisma-next/sql-contract/types";
|
|
7
|
-
import {
|
|
7
|
+
import { SqlMigrationPlanOperation } from "@prisma-next/family-sql/control";
|
|
8
8
|
import { ControlStack } from "@prisma-next/framework-components/control";
|
|
9
|
+
import { Migration } from "@prisma-next/family-sql/migration";
|
|
9
10
|
import { Contract } from "@prisma-next/contract/types";
|
|
10
11
|
import { ExecuteRequestLowerer, SqlControlAdapter } from "@prisma-next/family-sql/control-adapter";
|
|
11
12
|
|
|
@@ -43,7 +44,8 @@ interface CreateIndexExtras {
|
|
|
43
44
|
* is an antipattern in a migration. (The unbound/unspecified namespace concept
|
|
44
45
|
* remains for SQLite, which has no schemas, and for Mongo's connection `db`.)
|
|
45
46
|
*/
|
|
46
|
-
declare abstract class PostgresMigration extends Migration<PostgresPlanTargetDetails, 'postgres'> {
|
|
47
|
+
declare abstract class PostgresMigration<Start extends Contract<SqlStorage> = Contract<SqlStorage>, End extends Contract<SqlStorage> = Contract<SqlStorage>> extends Migration<PostgresPlanTargetDetails, 'postgres', Start, End> {
|
|
48
|
+
#private;
|
|
47
49
|
readonly targetId: "postgres";
|
|
48
50
|
/**
|
|
49
51
|
* Materialized Postgres control adapter, created once per migration
|
|
@@ -53,6 +55,17 @@ declare abstract class PostgresMigration extends Migration<PostgresPlanTargetDet
|
|
|
53
55
|
*/
|
|
54
56
|
protected readonly controlAdapter: SqlControlAdapter<'postgres'> | undefined;
|
|
55
57
|
constructor(stack?: ControlStack<'sql', 'postgres'>);
|
|
58
|
+
/**
|
|
59
|
+
* The typed, schema-qualified Postgres view over this migration's end-state
|
|
60
|
+
* contract — `this.endContract.namespace.<schema>.table.<name>`, etc. Throws
|
|
61
|
+
* if no `endContractJson` was provided.
|
|
62
|
+
*/
|
|
63
|
+
get endContract(): PostgresContractView<End>;
|
|
64
|
+
/**
|
|
65
|
+
* The typed Postgres view over this migration's start-state contract, or
|
|
66
|
+
* `null` for a baseline migration (no `startContractJson`).
|
|
67
|
+
*/
|
|
68
|
+
get startContract(): PostgresContractView<Start> | null;
|
|
56
69
|
/**
|
|
57
70
|
* Instance-method wrapper around the free `dataTransform` factory that
|
|
58
71
|
* supplies the stored control adapter. Authors call this from inside
|
|
@@ -178,4 +191,4 @@ declare abstract class PostgresMigration extends Migration<PostgresPlanTargetDet
|
|
|
178
191
|
}
|
|
179
192
|
//#endregion
|
|
180
193
|
export { PostgresMigration as t };
|
|
181
|
-
//# sourceMappingURL=postgres-migration-
|
|
194
|
+
//# sourceMappingURL=postgres-migration-DFaxuRyI.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-migration-DFaxuRyI.d.mts","names":[],"sources":["../src/core/migrations/operations/indexes.ts","../src/core/migrations/postgres-migration.ts"],"mappings":";;;;;;;;;;;;;UAmBiB,iBAAA;EAAA,SACN,IAAA;EAAA,SACA,OAAA,GAAU,MAAM;AAAA;;;AAF3B;;;;;;;;AAE2B;;;;AC2C3B;;;;;;;;;;;;;;;AD7CA,uBC6CsB,iBAAA,eACN,QAAA,CAAS,UAAA,IAAc,QAAA,CAAS,UAAA,eAClC,QAAA,CAAS,UAAA,IAAc,QAAA,CAAS,UAAA,WACpC,SAAA,CAAa,yBAAA,cAAuC,KAAA,EAAO,GAAA;EAAA;WAC1D,QAAA;EA4CiC;;;;;;EAAA,mBApCvB,cAAA,EAAgB,iBAAA;cAavB,KAAA,GAAQ,YAAA;EAoCjB;;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A;IAAA,SACA,KAAA;IAAA,SACA,MAAA;EAAA,IACP,OAAA,CAAQ,yBAAA,CAA0B,yBAAA;EAAA,UAS5B,WAAA,CAAY,OAAA;IAAA,SACX,MAAA;IAAA,SACA,KAAA;IAAA,SACA,KAAA;IAAA,SACA,OAAA;IAAA,SACA,MAAA,GAAS,iBAAA;EAAA,IAChB,OAAA,CAAQ,yBAAA,CAA0B,yBAAA;EAAA,UAa5B,SAAA,CAAU,OAAA;IAAA,SACT,MAAA;IAAA,SACA,KAAA;IAAA,SACA,KAAA;EAAA,IACP,OAAA,CAAQ,yBAAA,CAA0B,yBAAA;EAAA,UAS5B,gBAAA,CAAiB,OAAA;IAAA,SAChB,aAAA;IAAA,SACA,WAAA;IAAA,SACA,EAAA;IAAA,SACA,KAAA;EAAA,IACP,OAAA,CAAQ,yBAAA,CAA0B,yBAAA;AAAA"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { freezeNode } from "@prisma-next/framework-components/ir";
|
|
2
|
+
import { SqlNode } from "@prisma-next/sql-contract/types";
|
|
3
|
+
//#region src/core/postgres-native-enum.ts
|
|
4
|
+
/**
|
|
5
|
+
* Postgres contract-IR class for a native enum type (`CREATE TYPE … AS ENUM (…)`).
|
|
6
|
+
*
|
|
7
|
+
* This is an authored, serialized Contract-IR entity — it is registered as an entity
|
|
8
|
+
* kind, extends `SqlNode`, and is stored in `contract.json`. It is NOT a DiffableNode;
|
|
9
|
+
* the schema-diff tree will use `PostgresNativeEnumSchemaNode` when the managed phase
|
|
10
|
+
* builds it.
|
|
11
|
+
*
|
|
12
|
+
* A member is a value, not a name→value pair — matching `CREATE TYPE … AS ENUM
|
|
13
|
+
* ('a', 'b')`, which has no separate member name.
|
|
14
|
+
*
|
|
15
|
+
* Target-only concept — no SQL-family abstract. Extends `SqlNode` directly,
|
|
16
|
+
* frozen at construction via `freezeNode(this)`. The `kind: 'postgres-enum'`
|
|
17
|
+
* discriminant is enumerable so it survives JSON. Lives at
|
|
18
|
+
* `storage.namespaces[ns].entries.native_enum[HandleName]`; the entries key
|
|
19
|
+
* (`native_enum`) is the entity-kind descriptor's `kind`, decoupled from this
|
|
20
|
+
* node's own `kind` literal — the same shape as `table`/`StorageTable` and
|
|
21
|
+
* `valueSet`/`StorageValueSet`.
|
|
22
|
+
*/
|
|
23
|
+
var PostgresNativeEnum = class extends SqlNode {
|
|
24
|
+
static is(node) {
|
|
25
|
+
return typeof node === "object" && node !== null && "kind" in node && node.kind === "postgres-enum";
|
|
26
|
+
}
|
|
27
|
+
kind = "postgres-enum";
|
|
28
|
+
typeName;
|
|
29
|
+
members;
|
|
30
|
+
constructor(input) {
|
|
31
|
+
super();
|
|
32
|
+
this.typeName = input.typeName;
|
|
33
|
+
this.members = Object.freeze([...input.members]);
|
|
34
|
+
if (input.control !== void 0) this.control = input.control;
|
|
35
|
+
freezeNode(this);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
//#endregion
|
|
39
|
+
export { PostgresNativeEnum as t };
|
|
40
|
+
|
|
41
|
+
//# sourceMappingURL=postgres-native-enum-xdiqmBf_.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-native-enum-xdiqmBf_.mjs","names":[],"sources":["../src/core/postgres-native-enum.ts"],"sourcesContent":["import type { ControlPolicy } from '@prisma-next/contract/types';\nimport { freezeNode } from '@prisma-next/framework-components/ir';\nimport { SqlNode } from '@prisma-next/sql-contract/types';\n\nexport interface PostgresNativeEnumInput {\n /** The Postgres type name (`CREATE TYPE <typeName> AS ENUM (…)`). */\n readonly typeName: string;\n /** Member values in declaration order — this is the Postgres enum sort order. */\n readonly members: readonly string[];\n readonly control?: ControlPolicy;\n}\n\n/**\n * Postgres contract-IR class for a native enum type (`CREATE TYPE … AS ENUM (…)`).\n *\n * This is an authored, serialized Contract-IR entity — it is registered as an entity\n * kind, extends `SqlNode`, and is stored in `contract.json`. It is NOT a DiffableNode;\n * the schema-diff tree will use `PostgresNativeEnumSchemaNode` when the managed phase\n * builds it.\n *\n * A member is a value, not a name→value pair — matching `CREATE TYPE … AS ENUM\n * ('a', 'b')`, which has no separate member name.\n *\n * Target-only concept — no SQL-family abstract. Extends `SqlNode` directly,\n * frozen at construction via `freezeNode(this)`. The `kind: 'postgres-enum'`\n * discriminant is enumerable so it survives JSON. Lives at\n * `storage.namespaces[ns].entries.native_enum[HandleName]`; the entries key\n * (`native_enum`) is the entity-kind descriptor's `kind`, decoupled from this\n * node's own `kind` literal — the same shape as `table`/`StorageTable` and\n * `valueSet`/`StorageValueSet`.\n */\nexport class PostgresNativeEnum extends SqlNode {\n static is(node: unknown): node is PostgresNativeEnum {\n return (\n typeof node === 'object' && node !== null && 'kind' in node && node.kind === 'postgres-enum'\n );\n }\n\n override readonly kind = 'postgres-enum' as const;\n readonly typeName: string;\n readonly members: readonly string[];\n declare readonly control?: ControlPolicy;\n\n constructor(input: PostgresNativeEnumInput) {\n super();\n this.typeName = input.typeName;\n this.members = Object.freeze([...input.members]);\n if (input.control !== undefined) this.control = input.control;\n freezeNode(this);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA+BA,IAAa,qBAAb,cAAwC,QAAQ;CAC9C,OAAO,GAAG,MAA2C;EACnD,OACE,OAAO,SAAS,YAAY,SAAS,QAAQ,UAAU,QAAQ,KAAK,SAAS;CAEjF;CAEA,OAAyB;CACzB;CACA;CAGA,YAAY,OAAgC;EAC1C,MAAM;EACN,KAAK,WAAW,MAAM;EACtB,KAAK,UAAU,OAAO,OAAO,CAAC,GAAG,MAAM,OAAO,CAAC;EAC/C,IAAI,MAAM,YAAY,KAAA,GAAW,KAAK,UAAU,MAAM;EACtD,WAAW,IAAI;CACjB;AACF"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { SqlNode } from "@prisma-next/sql-contract/types";
|
|
2
|
+
|
|
3
|
+
//#region src/core/postgres-rls-policy.d.ts
|
|
4
|
+
type RlsPolicyOperation = 'select' | 'insert' | 'update' | 'delete' | 'all';
|
|
5
|
+
interface PostgresRlsPolicyInput {
|
|
6
|
+
/** Full wire name: `<prefix>_<8hex>`. Stored as-is; hashing is not this class's job. */
|
|
7
|
+
readonly name: string;
|
|
8
|
+
/** User-supplied prefix (the part before the `_<8hex>` suffix). */
|
|
9
|
+
readonly prefix: string;
|
|
10
|
+
/** Name of the table this policy attaches to, by name within the same schema. */
|
|
11
|
+
readonly tableName: string;
|
|
12
|
+
/** Namespace coordinate (schema name). Policies are schema-scoped. */
|
|
13
|
+
readonly namespaceId: string;
|
|
14
|
+
readonly operation: RlsPolicyOperation;
|
|
15
|
+
/** Sorted role names rendered in `TO <roles>`. Plain strings in this slice. */
|
|
16
|
+
readonly roles: readonly string[];
|
|
17
|
+
/** USING predicate SQL string, if present. */
|
|
18
|
+
readonly using?: string;
|
|
19
|
+
/** WITH CHECK predicate SQL string, if present. */
|
|
20
|
+
readonly withCheck?: string;
|
|
21
|
+
/** `true` = `AS PERMISSIVE`, `false` = `AS RESTRICTIVE`. */
|
|
22
|
+
readonly permissive: boolean;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Postgres contract-IR class for a row-level security policy (`CREATE POLICY … ON …`).
|
|
26
|
+
*
|
|
27
|
+
* This is an authored, serialized Contract-IR entity — it is registered as an entity
|
|
28
|
+
* kind, extends `SqlNode`, and is stored in `contract.json`. It is NOT a DiffableNode;
|
|
29
|
+
* the schema-diff tree uses `PostgresPolicySchemaNode` for that role.
|
|
30
|
+
*
|
|
31
|
+
* Target-only concept — no SQL-family abstract. Extends `SqlNode` directly.
|
|
32
|
+
* Frozen at construction via `freezeNode(this)`. The `kind: 'policy'`
|
|
33
|
+
* discriminant is enumerable (overrides SqlNode's non-enumerable `'sql'`) so it
|
|
34
|
+
* survives JSON serialization and enables dispatch. The literal matches the
|
|
35
|
+
* entries key (one-string rule: node.kind === entries key === entity kind).
|
|
36
|
+
*/
|
|
37
|
+
declare class PostgresRlsPolicy extends SqlNode {
|
|
38
|
+
readonly kind: "policy";
|
|
39
|
+
readonly name: string;
|
|
40
|
+
readonly prefix: string;
|
|
41
|
+
readonly tableName: string;
|
|
42
|
+
readonly namespaceId: string;
|
|
43
|
+
readonly operation: RlsPolicyOperation;
|
|
44
|
+
readonly roles: readonly string[];
|
|
45
|
+
readonly using?: string;
|
|
46
|
+
readonly withCheck?: string;
|
|
47
|
+
readonly permissive: boolean;
|
|
48
|
+
constructor(input: PostgresRlsPolicyInput);
|
|
49
|
+
}
|
|
50
|
+
//#endregion
|
|
51
|
+
export { PostgresRlsPolicyInput as n, RlsPolicyOperation as r, PostgresRlsPolicy as t };
|
|
52
|
+
//# sourceMappingURL=postgres-rls-policy--CSddvMR.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-rls-policy--CSddvMR.d.mts","names":[],"sources":["../src/core/postgres-rls-policy.ts"],"mappings":";;;KAGY,kBAAA;AAAA,UAEK,sBAAA;EAFL;EAAA,SAID,IAAA;;WAEA,MAAA;EANmB;EAAA,SAQnB,SAAA;EAN4B;EAAA,SAQ5B,WAAA;EAAA,SACA,SAAA,EAAW,kBAAkB;EAP7B;EAAA,SASA,KAAA;EALA;EAAA,SAOA,KAAA;EAJA;EAAA,SAMA,SAAA;EAJA;EAAA,SAMA,UAAA;AAAA;;;AAAU;AAgBrB;;;;;;;;;;cAAa,iBAAA,SAA0B,OAAA;EAAA,SACnB,IAAA;EAAA,SACT,IAAA;EAAA,SACA,MAAA;EAAA,SACA,SAAA;EAAA,SACA,WAAA;EAAA,SACA,SAAA,EAAW,kBAAA;EAAA,SACX,KAAA;EAAA,SACQ,KAAA;EAAA,SACA,SAAA;EAAA,SACR,UAAA;cAEG,KAAA,EAAO,sBAAA;AAAA"}
|
|
@@ -1,11 +1,103 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { v as PG_TEXT_CODEC_ID } from "./codec-ids-C_-Hj6bL.mjs";
|
|
2
|
+
import { t as PostgresNativeEnum } from "./postgres-native-enum-xdiqmBf_.mjs";
|
|
2
3
|
import { n as escapeLiteral } from "./sql-utils-DcfMz4MQ.mjs";
|
|
3
4
|
import { TableSource } from "@prisma-next/sql-relational-core/ast";
|
|
5
|
+
import { UNBOUND_NAMESPACE_ID, freezeNode, hydrateNamespaceEntities } from "@prisma-next/framework-components/ir";
|
|
4
6
|
import { blindCast } from "@prisma-next/utils/casts";
|
|
7
|
+
import { type } from "arktype";
|
|
8
|
+
import { SqlNamespaceBase, SqlNode } from "@prisma-next/sql-contract/types";
|
|
5
9
|
import { ifDefined } from "@prisma-next/utils/defined";
|
|
6
|
-
import { NamespaceBase, UNBOUND_NAMESPACE_ID, freezeNode, hydrateNamespaceEntities } from "@prisma-next/framework-components/ir";
|
|
7
10
|
import { composeSqlEntityKinds } from "@prisma-next/sql-contract/entity-kinds";
|
|
8
11
|
import { cfExpr } from "@prisma-next/sql-relational-core/contract-free";
|
|
12
|
+
//#region src/core/postgres-rls-policy.ts
|
|
13
|
+
/**
|
|
14
|
+
* Postgres contract-IR class for a row-level security policy (`CREATE POLICY … ON …`).
|
|
15
|
+
*
|
|
16
|
+
* This is an authored, serialized Contract-IR entity — it is registered as an entity
|
|
17
|
+
* kind, extends `SqlNode`, and is stored in `contract.json`. It is NOT a DiffableNode;
|
|
18
|
+
* the schema-diff tree uses `PostgresPolicySchemaNode` for that role.
|
|
19
|
+
*
|
|
20
|
+
* Target-only concept — no SQL-family abstract. Extends `SqlNode` directly.
|
|
21
|
+
* Frozen at construction via `freezeNode(this)`. The `kind: 'policy'`
|
|
22
|
+
* discriminant is enumerable (overrides SqlNode's non-enumerable `'sql'`) so it
|
|
23
|
+
* survives JSON serialization and enables dispatch. The literal matches the
|
|
24
|
+
* entries key (one-string rule: node.kind === entries key === entity kind).
|
|
25
|
+
*/
|
|
26
|
+
var PostgresRlsPolicy = class extends SqlNode {
|
|
27
|
+
kind = "policy";
|
|
28
|
+
name;
|
|
29
|
+
prefix;
|
|
30
|
+
tableName;
|
|
31
|
+
namespaceId;
|
|
32
|
+
operation;
|
|
33
|
+
roles;
|
|
34
|
+
permissive;
|
|
35
|
+
constructor(input) {
|
|
36
|
+
super();
|
|
37
|
+
this.name = input.name;
|
|
38
|
+
this.prefix = input.prefix;
|
|
39
|
+
this.tableName = input.tableName;
|
|
40
|
+
this.namespaceId = input.namespaceId;
|
|
41
|
+
this.operation = input.operation;
|
|
42
|
+
this.roles = Object.freeze([...input.roles]);
|
|
43
|
+
if (input.using !== void 0) this.using = input.using;
|
|
44
|
+
if (input.withCheck !== void 0) this.withCheck = input.withCheck;
|
|
45
|
+
this.permissive = input.permissive;
|
|
46
|
+
freezeNode(this);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
//#endregion
|
|
50
|
+
//#region src/core/postgres-role.ts
|
|
51
|
+
/**
|
|
52
|
+
* Postgres contract-IR class for a database role (`CREATE ROLE …`).
|
|
53
|
+
*
|
|
54
|
+
* This is an authored, serialized Contract-IR entity — it is registered as an entity
|
|
55
|
+
* kind, extends `SqlNode`, and is stored in `contract.json`. It is NOT a DiffableNode;
|
|
56
|
+
* the schema-diff tree uses `PostgresRoleSchemaNode` for that role.
|
|
57
|
+
*
|
|
58
|
+
* Roles are cluster-scoped, so their namespace coordinate is always
|
|
59
|
+
* `UNBOUND_NAMESPACE_ID`. Target-only concept — no SQL-family abstract.
|
|
60
|
+
* Extends `SqlNode` directly, frozen at construction via `freezeNode(this)`.
|
|
61
|
+
* The `kind: 'role'` discriminant is enumerable so it survives JSON.
|
|
62
|
+
* Matches the entries key (one-string rule).
|
|
63
|
+
*/
|
|
64
|
+
var PostgresRole = class extends SqlNode {
|
|
65
|
+
kind = "role";
|
|
66
|
+
name;
|
|
67
|
+
namespaceId;
|
|
68
|
+
constructor(input) {
|
|
69
|
+
super();
|
|
70
|
+
this.name = input.name;
|
|
71
|
+
this.namespaceId = input.namespaceId;
|
|
72
|
+
freezeNode(this);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
//#endregion
|
|
76
|
+
//#region src/core/postgres-validators.ts
|
|
77
|
+
const PostgresRoleSchema = type({
|
|
78
|
+
kind: "'role'",
|
|
79
|
+
name: "string",
|
|
80
|
+
namespaceId: "string"
|
|
81
|
+
});
|
|
82
|
+
const PostgresRlsPolicySchema = type({
|
|
83
|
+
kind: "'policy'",
|
|
84
|
+
name: "string",
|
|
85
|
+
prefix: "string",
|
|
86
|
+
tableName: "string",
|
|
87
|
+
namespaceId: "string",
|
|
88
|
+
operation: "'select' | 'insert' | 'update' | 'delete' | 'all'",
|
|
89
|
+
roles: type.string.array().readonly(),
|
|
90
|
+
"using?": "string",
|
|
91
|
+
"withCheck?": "string",
|
|
92
|
+
permissive: "boolean"
|
|
93
|
+
});
|
|
94
|
+
const PostgresNativeEnumSchema = type({
|
|
95
|
+
kind: "'postgres-enum'",
|
|
96
|
+
typeName: "string",
|
|
97
|
+
members: type.string.array().readonly(),
|
|
98
|
+
"control?": "'managed' | 'tolerated' | 'external' | 'observed'"
|
|
99
|
+
});
|
|
100
|
+
//#endregion
|
|
9
101
|
//#region src/core/ast/table-source.ts
|
|
10
102
|
var PostgresTableSource = class extends TableSource {
|
|
11
103
|
schema;
|
|
@@ -19,6 +111,23 @@ var PostgresTableSource = class extends TableSource {
|
|
|
19
111
|
}
|
|
20
112
|
};
|
|
21
113
|
//#endregion
|
|
114
|
+
//#region src/core/entity-kinds.ts
|
|
115
|
+
const policyEntityKind = {
|
|
116
|
+
kind: "policy",
|
|
117
|
+
schema: PostgresRlsPolicySchema,
|
|
118
|
+
construct: (input) => new PostgresRlsPolicy(input)
|
|
119
|
+
};
|
|
120
|
+
const roleEntityKind = {
|
|
121
|
+
kind: "role",
|
|
122
|
+
schema: PostgresRoleSchema,
|
|
123
|
+
construct: (input) => new PostgresRole(input)
|
|
124
|
+
};
|
|
125
|
+
const nativeEnumEntityKind = {
|
|
126
|
+
kind: "native_enum",
|
|
127
|
+
schema: PostgresNativeEnumSchema,
|
|
128
|
+
construct: (input) => new PostgresNativeEnum(input)
|
|
129
|
+
};
|
|
130
|
+
//#endregion
|
|
22
131
|
//#region src/core/postgres-schema.ts
|
|
23
132
|
/**
|
|
24
133
|
* Postgres target `Namespace` concretion — a Postgres schema (`CREATE
|
|
@@ -34,7 +143,7 @@ var PostgresTableSource = class extends TableSource {
|
|
|
34
143
|
* prefix entirely — call sites stay polymorphic and never branch on
|
|
35
144
|
* `id === UNBOUND_NAMESPACE_ID`.
|
|
36
145
|
*/
|
|
37
|
-
var PostgresSchema = class extends
|
|
146
|
+
var PostgresSchema = class extends SqlNamespaceBase {
|
|
38
147
|
/**
|
|
39
148
|
* Stable singleton reference for the late-bound slot. Materialised
|
|
40
149
|
* lazily below the singleton subclass declaration so the static
|
|
@@ -48,13 +157,26 @@ var PostgresSchema = class extends NamespaceBase {
|
|
|
48
157
|
constructor(input) {
|
|
49
158
|
super();
|
|
50
159
|
this.id = input.id;
|
|
51
|
-
const dispatched = hydrateNamespaceEntities(input.entries, composeSqlEntityKinds(
|
|
160
|
+
const dispatched = hydrateNamespaceEntities(input.entries, composeSqlEntityKinds([
|
|
161
|
+
policyEntityKind,
|
|
162
|
+
roleEntityKind,
|
|
163
|
+
nativeEnumEntityKind
|
|
164
|
+
]), "carry");
|
|
52
165
|
const valueSetRaw = dispatched["valueSet"];
|
|
53
166
|
const withPresence = valueSetRaw !== void 0 && Object.keys(valueSetRaw).length === 0 ? {
|
|
54
167
|
...dispatched,
|
|
55
168
|
valueSet: void 0
|
|
56
169
|
} : dispatched;
|
|
57
|
-
|
|
170
|
+
const nativeEnumRaw = dispatched["native_enum"];
|
|
171
|
+
const entriesInput = { ...withPresence };
|
|
172
|
+
delete entriesInput["native_enum"];
|
|
173
|
+
if (nativeEnumRaw !== void 0) Object.defineProperty(entriesInput, "native_enum", {
|
|
174
|
+
value: nativeEnumRaw,
|
|
175
|
+
enumerable: false,
|
|
176
|
+
writable: false,
|
|
177
|
+
configurable: true
|
|
178
|
+
});
|
|
179
|
+
this.entries = Object.freeze(blindCast(entriesInput));
|
|
58
180
|
Object.defineProperty(this, "kind", {
|
|
59
181
|
value: "schema",
|
|
60
182
|
writable: false,
|
|
@@ -69,6 +191,12 @@ var PostgresSchema = class extends NamespaceBase {
|
|
|
69
191
|
get valueSet() {
|
|
70
192
|
return this.entries.valueSet;
|
|
71
193
|
}
|
|
194
|
+
get policy() {
|
|
195
|
+
return this.entries.policy ?? Object.freeze({});
|
|
196
|
+
}
|
|
197
|
+
get role() {
|
|
198
|
+
return this.entries.role ?? Object.freeze({});
|
|
199
|
+
}
|
|
72
200
|
/**
|
|
73
201
|
* The bare schema qualifier as it would appear in a rendered SQL
|
|
74
202
|
* fragment (already quoted). The unbound-schema singleton overrides
|
|
@@ -230,6 +358,6 @@ function postgresCreateNamespace(input) {
|
|
|
230
358
|
return new PostgresSchema(schemaInput);
|
|
231
359
|
}
|
|
232
360
|
//#endregion
|
|
233
|
-
export {
|
|
361
|
+
export { nativeEnumEntityKind as a, PostgresTableSource as c, PostgresRoleSchema as d, PostgresRole as f, postgresCreateNamespace as i, PostgresNativeEnumSchema as l, PostgresUnboundSchema as n, policyEntityKind as o, PostgresRlsPolicy as p, isPostgresSchema as r, roleEntityKind as s, PostgresSchema as t, PostgresRlsPolicySchema as u };
|
|
234
362
|
|
|
235
|
-
//# sourceMappingURL=postgres-schema-
|
|
363
|
+
//# sourceMappingURL=postgres-schema-CajYAwny.mjs.map
|