@prisma-next/target-postgres 0.14.0-dev.10 → 0.14.0-dev.12
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/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/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.d.mts +1 -1
- package/dist/control.mjs +4 -4
- package/dist/{data-transform-DDgWdB5o.d.mts → data-transform-qKy1U5V9.d.mts} +2 -2
- package/dist/{data-transform-DDgWdB5o.d.mts.map → data-transform-qKy1U5V9.d.mts.map} +1 -1
- package/dist/data-transform.d.mts +1 -1
- package/dist/{ddl-QDyOSeLc.mjs → ddl-BlsTIBeP.mjs} +54 -4
- package/dist/ddl-BlsTIBeP.mjs.map +1 -0
- package/dist/ddl.d.mts +3 -2
- package/dist/ddl.mjs +2 -2
- package/dist/descriptor-meta-b_SzXwen.mjs +239 -0
- package/dist/descriptor-meta-b_SzXwen.mjs.map +1 -0
- package/dist/{issue-planner-DL6g3CmE.mjs → issue-planner-CwoeupPM.mjs} +9 -6
- package/dist/{issue-planner-DL6g3CmE.mjs.map → issue-planner-CwoeupPM.mjs.map} +1 -1
- package/dist/issue-planner.d.mts +3 -3
- package/dist/issue-planner.d.mts.map +1 -1
- package/dist/issue-planner.mjs +1 -1
- package/dist/migration.d.mts +3 -3
- package/dist/migration.mjs +2 -2
- package/dist/{nodes-Bbhs2rwj.mjs → nodes-DhDIIhBT.mjs} +44 -2
- package/dist/nodes-DhDIIhBT.mjs.map +1 -0
- package/dist/{nodes-pLeLgdis.d.mts → nodes-YvdohJ2X.d.mts} +40 -3
- package/dist/nodes-YvdohJ2X.d.mts.map +1 -0
- package/dist/{op-factory-call-DmQEc3XV.d.mts → op-factory-call-DXHAIisl.d.mts} +37 -4
- package/dist/op-factory-call-DXHAIisl.d.mts.map +1 -0
- package/dist/{op-factory-call-D_p5vxwt.mjs → op-factory-call-tMksrGIq.mjs} +146 -4
- package/dist/op-factory-call-tMksrGIq.mjs.map +1 -0
- package/dist/op-factory-call.d.mts +1 -1
- package/dist/op-factory-call.mjs +1 -1
- package/dist/pack.d.mts +74 -1
- package/dist/pack.d.mts.map +1 -1
- package/dist/pack.mjs +1 -1
- package/dist/{planner-Bs_baQax.mjs → planner-BbSZJVW7.mjs} +114 -22
- package/dist/planner-BbSZJVW7.mjs.map +1 -0
- package/dist/{planner-produced-postgres-migration-Cji5vxUf.mjs → planner-produced-postgres-migration-C0FHnEsV.mjs} +2 -2
- package/dist/{planner-produced-postgres-migration-Cji5vxUf.mjs.map → planner-produced-postgres-migration-C0FHnEsV.mjs.map} +1 -1
- package/dist/{planner-produced-postgres-migration-QqHa2C2l.d.mts → planner-produced-postgres-migration-DfM5lBv1.d.mts} +3 -3
- package/dist/{planner-produced-postgres-migration-QqHa2C2l.d.mts.map → planner-produced-postgres-migration-DfM5lBv1.d.mts.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-CI6Z21mm.mjs} +2 -2
- package/dist/{planner-sql-checks-jqUUGyQR.mjs.map → planner-sql-checks-CI6Z21mm.mjs.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 +35 -3
- package/dist/planner.d.mts.map +1 -1
- package/dist/planner.mjs +2 -2
- package/dist/{postgres-contract-serializer-k3TAcPMY.mjs → postgres-contract-serializer-k5eg5ZUZ.mjs} +29 -16
- package/dist/postgres-contract-serializer-k5eg5ZUZ.mjs.map +1 -0
- package/dist/{postgres-migration-B5jKrXv3.mjs → postgres-migration-BJWxullf.mjs} +2 -2
- package/dist/{postgres-migration-B5jKrXv3.mjs.map → postgres-migration-BJWxullf.mjs.map} +1 -1
- package/dist/{postgres-migration-Y4YBJqkS.d.mts → postgres-migration-D22a2y0l.d.mts} +4 -4
- package/dist/{postgres-migration-Y4YBJqkS.d.mts.map → postgres-migration-D22a2y0l.d.mts.map} +1 -1
- package/dist/postgres-rls-policy-D_z1osEq.d.mts +60 -0
- package/dist/postgres-rls-policy-D_z1osEq.d.mts.map +1 -0
- package/dist/postgres-role-_CCuyPCQ.d.mts +33 -0
- package/dist/postgres-role-_CCuyPCQ.d.mts.map +1 -0
- package/dist/{postgres-schema-COGZ1ark.mjs → postgres-schema-BVDr_61a.mjs} +139 -3
- package/dist/postgres-schema-BVDr_61a.mjs.map +1 -0
- package/dist/postgres-schema-D0h4lsw2.d.mts +158 -0
- package/dist/postgres-schema-D0h4lsw2.d.mts.map +1 -0
- package/dist/postgres-schema-ir-BF0X8jit.mjs +66 -0
- package/dist/postgres-schema-ir-BF0X8jit.mjs.map +1 -0
- package/dist/postgres-schema-ir-BQ3RpZMz.d.mts +60 -0
- package/dist/postgres-schema-ir-BQ3RpZMz.d.mts.map +1 -0
- package/dist/postgres-schema-ir-annotations-El62Sywa.mjs +14 -0
- package/dist/postgres-schema-ir-annotations-El62Sywa.mjs.map +1 -0
- package/dist/render-ops.d.mts +1 -1
- package/dist/rls-canonicalize.d.mts +2 -0
- package/dist/rls-canonicalize.mjs +2 -0
- package/dist/runtime.d.mts +3 -2
- package/dist/runtime.d.mts.map +1 -1
- package/dist/runtime.mjs +2 -2
- package/dist/schema-ir-annotations.d.mts +8 -0
- package/dist/schema-ir-annotations.d.mts.map +1 -0
- package/dist/schema-ir-annotations.mjs +2 -0
- package/dist/types.d.mts +5 -140
- package/dist/types.mjs +3 -2
- package/package.json +21 -17
- package/src/contract-free/checks.ts +73 -0
- package/src/contract-free/ddl.ts +35 -0
- package/src/core/authoring.ts +115 -1
- package/src/core/ddl/nodes.ts +68 -1
- package/src/core/descriptor-meta.ts +4 -0
- package/src/core/entity-kinds.ts +16 -0
- package/src/core/migrations/control-policy.ts +3 -0
- package/src/core/migrations/issue-planner.ts +8 -0
- package/src/core/migrations/op-factory-call.ts +96 -0
- package/src/core/migrations/operations/rls.ts +106 -0
- package/src/core/migrations/planner-target-details.ts +3 -1
- package/src/core/migrations/planner.ts +99 -1
- package/src/core/migrations/verify-postgres-namespaces.ts +12 -15
- package/src/core/migrations/verify-postgres-rls-policies.ts +62 -0
- package/src/core/postgres-contract-serializer.ts +43 -19
- package/src/core/postgres-rls-policy.ts +103 -0
- package/src/core/postgres-role.ts +53 -0
- package/src/core/postgres-schema-ir-annotations.ts +22 -0
- package/src/core/postgres-schema-ir.ts +101 -0
- package/src/core/postgres-schema.ts +24 -4
- package/src/core/postgres-validators.ts +20 -0
- package/src/core/rls/canonicalize.ts +48 -0
- package/src/exports/ddl.ts +3 -0
- package/src/exports/planner.ts +1 -0
- package/src/exports/rls-canonicalize.ts +6 -0
- package/src/exports/schema-ir-annotations.ts +1 -0
- package/src/exports/types.ts +12 -0
- package/dist/ddl-QDyOSeLc.mjs.map +0 -1
- package/dist/descriptor-meta-CpGygXpI.mjs +0 -140
- package/dist/descriptor-meta-CpGygXpI.mjs.map +0 -1
- package/dist/nodes-Bbhs2rwj.mjs.map +0 -1
- 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.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-schema-COGZ1ark.mjs.map +0 -1
- package/dist/types.d.mts.map +0 -1
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { t as PostgresTableSource } from "./table-source-BvFo7gVs.mjs";
|
|
2
|
+
import { t as PostgresRlsPolicy } from "./postgres-rls-policy-D_z1osEq.mjs";
|
|
3
|
+
import { t as PostgresRole } from "./postgres-role-_CCuyPCQ.mjs";
|
|
4
|
+
import { NamespaceBase } from "@prisma-next/framework-components/ir";
|
|
5
|
+
import { SqlNamespaceEntries, SqlNamespaceTablesInput, SqlStorage, StorageTable, StorageValueSet } from "@prisma-next/sql-contract/types";
|
|
6
|
+
import { CfExpr } from "@prisma-next/sql-relational-core/contract-free";
|
|
7
|
+
|
|
8
|
+
//#region src/core/postgres-schema.d.ts
|
|
9
|
+
type PostgresNamespaceEntries = SqlNamespaceEntries & {
|
|
10
|
+
readonly policy?: Readonly<Record<string, PostgresRlsPolicy>>;
|
|
11
|
+
readonly role?: Readonly<Record<string, PostgresRole>>;
|
|
12
|
+
};
|
|
13
|
+
interface PostgresSchemaInput {
|
|
14
|
+
readonly id: string;
|
|
15
|
+
readonly entries: Readonly<Record<string, Readonly<Record<string, unknown>>>>;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Postgres target `Namespace` concretion — a Postgres schema (`CREATE
|
|
19
|
+
* SCHEMA …`). Each Postgres `SqlStorage` carries a
|
|
20
|
+
* `namespaces: Record<NamespaceId, PostgresSchema>` map populated by
|
|
21
|
+
* the Postgres PSL interpreter from `namespace { … }` AST buckets.
|
|
22
|
+
*
|
|
23
|
+
* `entries` holds entity-kind maps (`table`, `valueSet`). Qualifier
|
|
24
|
+
* emission is the rendering seam: DDL / SQL emission asks the namespace
|
|
25
|
+
* for its qualifier (`"<schema>"`) or for a qualified table name
|
|
26
|
+
* (`"<schema>"."<table>"`) and consumes the result polymorphically.
|
|
27
|
+
* The unbound singleton below overrides these methods to elide the
|
|
28
|
+
* prefix entirely — call sites stay polymorphic and never branch on
|
|
29
|
+
* `id === UNBOUND_NAMESPACE_ID`.
|
|
30
|
+
*/
|
|
31
|
+
declare class PostgresSchema extends NamespaceBase {
|
|
32
|
+
/**
|
|
33
|
+
* Stable singleton reference for the late-bound slot. Materialised
|
|
34
|
+
* lazily below the singleton subclass declaration so the static
|
|
35
|
+
* initialiser sees the subclass before assigning. Consumers always
|
|
36
|
+
* reach for `PostgresSchema.unbound` (or `PostgresUnboundSchema.instance`
|
|
37
|
+
* — same identity).
|
|
38
|
+
*/
|
|
39
|
+
static unbound: PostgresUnboundSchema;
|
|
40
|
+
readonly kind: 'schema';
|
|
41
|
+
readonly id: string;
|
|
42
|
+
readonly entries: PostgresNamespaceEntries;
|
|
43
|
+
constructor(input: PostgresSchemaInput);
|
|
44
|
+
get table(): Readonly<Record<string, StorageTable>>;
|
|
45
|
+
get valueSet(): Readonly<Record<string, StorageValueSet>> | undefined;
|
|
46
|
+
get policy(): Readonly<Record<string, PostgresRlsPolicy>>;
|
|
47
|
+
get role(): Readonly<Record<string, PostgresRole>>;
|
|
48
|
+
/**
|
|
49
|
+
* The bare schema qualifier as it would appear in a rendered SQL
|
|
50
|
+
* fragment (already quoted). The unbound-schema singleton overrides
|
|
51
|
+
* this to return `''`.
|
|
52
|
+
*/
|
|
53
|
+
qualifier(): string;
|
|
54
|
+
/**
|
|
55
|
+
* Qualify a table name with the schema prefix
|
|
56
|
+
* (`"<schema>"."<table>"`). The unbound-schema singleton overrides
|
|
57
|
+
* this to emit just `"<table>"` so the resolved DDL is unqualified
|
|
58
|
+
* and `search_path` decides where the object lands at runtime.
|
|
59
|
+
*/
|
|
60
|
+
qualifyTable(tableName: string): string;
|
|
61
|
+
/**
|
|
62
|
+
* Render a SQL string-literal containing the qualified-name form
|
|
63
|
+
* suitable for `to_regclass(...)` arguments (e.g. `'"public"."user"'`).
|
|
64
|
+
* The unbound singleton overrides this to elide the schema prefix
|
|
65
|
+
* (`'"user"'`) so `search_path` resolves the object at runtime.
|
|
66
|
+
*/
|
|
67
|
+
regclassLiteral(name: string): string;
|
|
68
|
+
/**
|
|
69
|
+
* Render a SQL expression that evaluates to this namespace's schema
|
|
70
|
+
* name at runtime, ready to drop into a `WHERE table_schema = …` /
|
|
71
|
+
* `WHERE n.nspname = …` clause. Named schemas emit a quoted SQL
|
|
72
|
+
* literal (`'public'`); the unbound singleton overrides this to emit
|
|
73
|
+
* `current_schema()` so catalog queries match whichever schema the
|
|
74
|
+
* connection's `search_path` resolved at runtime.
|
|
75
|
+
*/
|
|
76
|
+
schemaSqlExpression(): string;
|
|
77
|
+
/**
|
|
78
|
+
* Typed-AST counterpart of {@link schemaSqlExpression}: the expression a
|
|
79
|
+
* builder-built catalog check compares `n.nspname` / `table_schema`
|
|
80
|
+
* against. Named schemas bind the schema name as a text parameter; the
|
|
81
|
+
* unbound singleton overrides this to the opaque `current_schema()`
|
|
82
|
+
* expression so the live connection's `search_path` decides at runtime.
|
|
83
|
+
*/
|
|
84
|
+
schemaFilterExpression(): CfExpr;
|
|
85
|
+
/**
|
|
86
|
+
* Typed-AST counterpart of {@link qualifyTable}: the FROM source a
|
|
87
|
+
* builder-built check uses to address a user table in this namespace.
|
|
88
|
+
* Named schemas qualify (`"schema"."table"`); the unbound singleton
|
|
89
|
+
* overrides this to leave the table unqualified so `search_path`
|
|
90
|
+
* resolves it at runtime.
|
|
91
|
+
*/
|
|
92
|
+
tableSource(tableName: string, alias?: string): PostgresTableSource;
|
|
93
|
+
/**
|
|
94
|
+
* The bare schema name a DDL planner should target when emitting
|
|
95
|
+
* statements that need to identify this namespace in the live
|
|
96
|
+
* database (e.g. `CREATE TABLE "<ddlSchemaName>"."<table>" …`,
|
|
97
|
+
* catalog filters, planner conflict lookups). Named schemas resolve
|
|
98
|
+
* to their own id. The `PostgresUnboundSchema` singleton inherits
|
|
99
|
+
* this and returns `UNBOUND_NAMESPACE_ID` — callers that dispatch
|
|
100
|
+
* through `qualifyTableName` route through the polymorphic
|
|
101
|
+
* `PostgresUnboundSchema` overrides and produce unqualified
|
|
102
|
+
* (search-path-resolved) output automatically.
|
|
103
|
+
*/
|
|
104
|
+
ddlSchemaName(_storage: SqlStorage): string;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Singleton subclass for the reserved sentinel namespace id
|
|
108
|
+
* (`UNBOUND_NAMESPACE_ID`) — the late-bound Postgres slot whose binding
|
|
109
|
+
* the connection's `search_path` resolves at runtime. Overrides
|
|
110
|
+
* qualifier emission to elide the schema prefix; call sites that consume
|
|
111
|
+
* `qualifier()` / `qualifyTable()` get unqualified output without
|
|
112
|
+
* branching on the namespace id.
|
|
113
|
+
*
|
|
114
|
+
* This is the target-side materialization of "the framework provides
|
|
115
|
+
* affordances; targets implement specifics": the framework names the
|
|
116
|
+
* sentinel; Postgres decides what late-bound means here (the table
|
|
117
|
+
* name, naked — the schema is supplied by the live connection's
|
|
118
|
+
* `search_path`).
|
|
119
|
+
*
|
|
120
|
+
* `ddlSchemaName` is inherited from `PostgresSchema` and returns
|
|
121
|
+
* `UNBOUND_NAMESPACE_ID`. Downstream helpers such as `qualifyTableName`
|
|
122
|
+
* route through the polymorphic factory and produce unqualified output
|
|
123
|
+
* automatically.
|
|
124
|
+
*/
|
|
125
|
+
declare class PostgresUnboundSchema extends PostgresSchema {
|
|
126
|
+
static readonly instance: PostgresUnboundSchema;
|
|
127
|
+
constructor(input?: PostgresSchemaInput);
|
|
128
|
+
qualifier(): string;
|
|
129
|
+
qualifyTable(tableName: string): string;
|
|
130
|
+
schemaSqlExpression(): string;
|
|
131
|
+
schemaFilterExpression(): CfExpr;
|
|
132
|
+
tableSource(tableName: string, alias?: string): PostgresTableSource;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Narrow an arbitrary namespace (or `undefined`) to `PostgresSchema`
|
|
136
|
+
* so callers can dispatch to the polymorphic emission methods without
|
|
137
|
+
* branching at the call site. Uses the structural `kind` discriminator
|
|
138
|
+
* (`'schema'`) rather than `instanceof` so the check survives realm /
|
|
139
|
+
* bundle / hot-reload boundaries — matching the rest of the IR's
|
|
140
|
+
* narrowing convention. `PostgresUnboundSchema` passes through because
|
|
141
|
+
* it inherits the same `kind: 'schema'` from `PostgresSchema`.
|
|
142
|
+
*/
|
|
143
|
+
declare function isPostgresSchema(ns: unknown): ns is PostgresSchema;
|
|
144
|
+
/**
|
|
145
|
+
* Target-supplied `Namespace` factory the Postgres target plumbs
|
|
146
|
+
* through `defineContract({ createNamespace })` and the SQL PSL
|
|
147
|
+
* interpreter. Returns the unbound singleton for the framework
|
|
148
|
+
* sentinel and a fresh `PostgresSchema` for any other coordinate.
|
|
149
|
+
*
|
|
150
|
+
* The factory has no per-call state — every named id deterministically
|
|
151
|
+
* maps to a distinct schema instance — so callers can pass it through
|
|
152
|
+
* by reference and trust the resulting `SqlStorage.namespaces` map to
|
|
153
|
+
* be value-stable for a given input set.
|
|
154
|
+
*/
|
|
155
|
+
declare function postgresCreateNamespace(input: SqlNamespaceTablesInput): PostgresSchema;
|
|
156
|
+
//#endregion
|
|
157
|
+
export { postgresCreateNamespace as i, PostgresUnboundSchema as n, isPostgresSchema as r, PostgresSchema as t };
|
|
158
|
+
//# sourceMappingURL=postgres-schema-D0h4lsw2.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-schema-D0h4lsw2.d.mts","names":[],"sources":["../src/core/postgres-schema.ts"],"mappings":";;;;;;;;KAwBY,wBAAA,GAA2B,mBAAA;EAAA,SAC5B,MAAA,GAAS,QAAA,CAAS,MAAA,SAAe,iBAAA;EAAA,SACjC,IAAA,GAAO,QAAA,CAAS,MAAA,SAAe,YAAA;AAAA;AAAA,UAGzB,mBAAA;EAAA,SACN,EAAA;EAAA,SACA,OAAA,EAAS,QAAA,CAAS,MAAA,SAAe,QAAA,CAAS,MAAA;AAAA;;;;;;;;;;;;;;;cAiBxC,cAAA,SAAuB,aAAA;EAtBkB;AAAA;AAGtD;;;;;EAHsD,OA8B7C,OAAA,EAAS,qBAAA;EAAA,SAEC,IAAA;EAAA,SACR,EAAA;EAAA,SACA,OAAA,EAAS,wBAAA;cAEN,KAAA,EAAO,mBAAA;EAAA,IAgCf,KAAA,IAAS,QAAA,CAAS,MAAA,SAAe,YAAA;EAAA,IAIjC,QAAA,IAAY,QAAA,CAAS,MAAA,SAAe,eAAA;EAAA,IAIpC,MAAA,IAAU,QAAA,CAAS,MAAA,SAAe,iBAAA;EAAA,IAIlC,IAAA,IAAQ,QAAA,CAAS,MAAA,SAAe,YAAA;EA3Ee;;AAAM;AAiB3D;;EAmEE,SAAA;EA3DgB;;;;;;EAqEhB,YAAA,CAAa,SAAA;EA3BY;;;;;;EAqCzB,eAAA,CAAgB,IAAA;EA7BJ;;;;;;;;EAyCZ,mBAAA;EA3FgB;;;;;;;EAsGhB,sBAAA,IAA0B,MAAA;EAhEtB;;;;;;;EA2EJ,WAAA,CAAY,SAAA,UAAmB,KAAA,YAAiB,mBAAA;EAnE5C;;;;;;;;;;;EAsFJ,aAAA,CAAc,QAAA,EAAU,UAAA;AAAA;;;;;;;;;;;;AAAU;AAwBpC;;;;;;;cAAa,qBAAA,SAA8B,cAAA;EAAA,gBACzB,QAAA,EAAU,qBAAA;cAEd,KAAA,GAAQ,mBAAA;EAIX,SAAA;EAIA,YAAA,CAAa,SAAA;EAIb,mBAAA;EAIA,sBAAA,IAA0B,MAAA;EAI1B,WAAA,CAAY,SAAA,UAAmB,KAAA,YAAiB,mBAAA;AAAA;;;;;;;;;;iBAmB3C,gBAAA,CAAiB,EAAA,YAAc,EAAA,IAAM,cAAc;;AAnBW;AAmB9E;;;;;;;;AAAmE;iBAenD,uBAAA,CAAwB,KAAA,EAAO,uBAAA,GAA0B,cAAc"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { freezeNode } from "@prisma-next/framework-components/ir";
|
|
2
|
+
import { SqlSchemaIRNode, SqlTableIR } from "@prisma-next/sql-schema-ir/types";
|
|
3
|
+
//#region src/core/postgres-schema-ir.ts
|
|
4
|
+
/**
|
|
5
|
+
* Postgres-specific schema IR. Mirrors the structure of `SqlSchemaIR`
|
|
6
|
+
* (same `tables` + optional `annotations` fields) and adds typed fields for
|
|
7
|
+
* data the postgres adapter collects during introspection.
|
|
8
|
+
*
|
|
9
|
+
* Extends `SqlSchemaIRNode` directly rather than `SqlSchemaIR` because
|
|
10
|
+
* `SqlSchemaIR` calls `freezeNode` in its constructor, which prevents
|
|
11
|
+
* subclass field initialisation. `PostgresSchemaIR` replicates the minimal
|
|
12
|
+
* `SqlSchemaIR` structure and freezes itself at the end of its own
|
|
13
|
+
* constructor.
|
|
14
|
+
*
|
|
15
|
+
* RLS-specific fields (`rlsPolicies`, `roles`) are typed top-level fields on
|
|
16
|
+
* this class — no `Reflect.get`, no untyped annotation bag access. The
|
|
17
|
+
* `annotations.pg` bag is populated with only the subset the family layer
|
|
18
|
+
* reads (`nativeEnumTypeNames`, `existingSchemas`, `schema`) so family-layer
|
|
19
|
+
* PSL inference and namespace verification continue to work without knowing
|
|
20
|
+
* about RLS.
|
|
21
|
+
*
|
|
22
|
+
* Nothing RLS-specific leaks into the sql-family layer.
|
|
23
|
+
*/
|
|
24
|
+
var PostgresSchemaIR = class extends SqlSchemaIRNode {
|
|
25
|
+
nodeTarget = "postgres";
|
|
26
|
+
tables;
|
|
27
|
+
pgSchemaName;
|
|
28
|
+
pgVersion;
|
|
29
|
+
rlsPolicies;
|
|
30
|
+
roles;
|
|
31
|
+
existingSchemas;
|
|
32
|
+
nativeEnumTypeNames;
|
|
33
|
+
constructor(input) {
|
|
34
|
+
super();
|
|
35
|
+
this.tables = Object.freeze(Object.fromEntries(Object.entries(input.tables).map(([key, t]) => [key, t instanceof SqlTableIR ? t : new SqlTableIR(t)])));
|
|
36
|
+
this.pgSchemaName = input.pgSchemaName;
|
|
37
|
+
this.pgVersion = input.pgVersion;
|
|
38
|
+
this.rlsPolicies = Object.freeze([...input.rlsPolicies]);
|
|
39
|
+
this.roles = Object.freeze([...input.roles]);
|
|
40
|
+
this.existingSchemas = Object.freeze([...input.existingSchemas]);
|
|
41
|
+
this.nativeEnumTypeNames = Object.freeze([...input.nativeEnumTypeNames]);
|
|
42
|
+
this.annotations = { pg: {
|
|
43
|
+
schema: input.pgSchemaName,
|
|
44
|
+
...input.nativeEnumTypeNames.length > 0 && { nativeEnumTypeNames: input.nativeEnumTypeNames },
|
|
45
|
+
...input.existingSchemas.length > 0 && { existingSchemas: input.existingSchemas }
|
|
46
|
+
} };
|
|
47
|
+
freezeNode(this);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Structural guard for `PostgresSchemaIR`, narrowing on the `nodeTarget`
|
|
52
|
+
* discriminant rather than `instanceof`. `nodeTarget` is an enumerable own field
|
|
53
|
+
* (a plain class-field initializer), so it survives the `{ ...schema, tables }`
|
|
54
|
+
* spread the multi-space verify path (`projectSchemaToSpace`) produces — that
|
|
55
|
+
* projected object is not a class instance but retains every enumerable own
|
|
56
|
+
* property. The family-level `kind = 'sql-schema-ir'` discriminator is unusable
|
|
57
|
+
* here: it is shared by every SQL schema-IR node and is non-enumerable (dropped
|
|
58
|
+
* by the spread).
|
|
59
|
+
*/
|
|
60
|
+
function isPostgresSchemaIR(schema) {
|
|
61
|
+
return schema.nodeTarget === "postgres";
|
|
62
|
+
}
|
|
63
|
+
//#endregion
|
|
64
|
+
export { isPostgresSchemaIR as n, PostgresSchemaIR as t };
|
|
65
|
+
|
|
66
|
+
//# sourceMappingURL=postgres-schema-ir-BF0X8jit.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-schema-ir-BF0X8jit.mjs","names":[],"sources":["../src/core/postgres-schema-ir.ts"],"sourcesContent":["import { freezeNode } from '@prisma-next/framework-components/ir';\nimport {\n type SqlAnnotations,\n type SqlSchemaIR,\n SqlSchemaIRNode,\n type SqlSchemaTarget,\n SqlTableIR,\n type SqlTableIRInput,\n} from '@prisma-next/sql-schema-ir/types';\nimport type { PostgresRlsPolicy } from './postgres-rls-policy';\nimport type { PostgresRole } from './postgres-role';\n\nexport interface PostgresSchemaIRInput {\n readonly tables: Record<string, SqlTableIR | SqlTableIRInput>;\n readonly pgSchemaName: string;\n readonly pgVersion: string;\n readonly rlsPolicies: readonly PostgresRlsPolicy[];\n readonly roles: readonly PostgresRole[];\n readonly existingSchemas: readonly string[];\n readonly nativeEnumTypeNames: readonly string[];\n}\n\n/**\n * Postgres-specific schema IR. Mirrors the structure of `SqlSchemaIR`\n * (same `tables` + optional `annotations` fields) and adds typed fields for\n * data the postgres adapter collects during introspection.\n *\n * Extends `SqlSchemaIRNode` directly rather than `SqlSchemaIR` because\n * `SqlSchemaIR` calls `freezeNode` in its constructor, which prevents\n * subclass field initialisation. `PostgresSchemaIR` replicates the minimal\n * `SqlSchemaIR` structure and freezes itself at the end of its own\n * constructor.\n *\n * RLS-specific fields (`rlsPolicies`, `roles`) are typed top-level fields on\n * this class — no `Reflect.get`, no untyped annotation bag access. The\n * `annotations.pg` bag is populated with only the subset the family layer\n * reads (`nativeEnumTypeNames`, `existingSchemas`, `schema`) so family-layer\n * PSL inference and namespace verification continue to work without knowing\n * about RLS.\n *\n * Nothing RLS-specific leaks into the sql-family layer.\n */\nexport class PostgresSchemaIR extends SqlSchemaIRNode {\n readonly nodeTarget: SqlSchemaTarget = 'postgres';\n readonly tables: Readonly<Record<string, SqlTableIR>>;\n declare readonly annotations?: SqlAnnotations;\n readonly pgSchemaName: string;\n readonly pgVersion: string;\n readonly rlsPolicies: readonly PostgresRlsPolicy[];\n readonly roles: readonly PostgresRole[];\n readonly existingSchemas: readonly string[];\n readonly nativeEnumTypeNames: readonly string[];\n\n constructor(input: PostgresSchemaIRInput) {\n super();\n this.tables = Object.freeze(\n Object.fromEntries(\n Object.entries(input.tables).map(([key, t]) => [\n key,\n t instanceof SqlTableIR ? t : new SqlTableIR(t),\n ]),\n ),\n );\n this.pgSchemaName = input.pgSchemaName;\n this.pgVersion = input.pgVersion;\n this.rlsPolicies = Object.freeze([...input.rlsPolicies]);\n this.roles = Object.freeze([...input.roles]);\n this.existingSchemas = Object.freeze([...input.existingSchemas]);\n this.nativeEnumTypeNames = Object.freeze([...input.nativeEnumTypeNames]);\n // Populate the annotations.pg bag with only the subset the family layer\n // reads (nativeEnumTypeNames for PSL inference, existingSchemas for\n // namespace presence checks). rlsPolicies and roles are NOT placed here\n // — they are consumed directly via typed fields on this class.\n this.annotations = {\n pg: {\n schema: input.pgSchemaName,\n ...(input.nativeEnumTypeNames.length > 0 && {\n nativeEnumTypeNames: input.nativeEnumTypeNames,\n }),\n ...(input.existingSchemas.length > 0 && {\n existingSchemas: input.existingSchemas,\n }),\n },\n };\n freezeNode(this);\n }\n}\n\n/**\n * Structural guard for `PostgresSchemaIR`, narrowing on the `nodeTarget`\n * discriminant rather than `instanceof`. `nodeTarget` is an enumerable own field\n * (a plain class-field initializer), so it survives the `{ ...schema, tables }`\n * spread the multi-space verify path (`projectSchemaToSpace`) produces — that\n * projected object is not a class instance but retains every enumerable own\n * property. The family-level `kind = 'sql-schema-ir'` discriminator is unusable\n * here: it is shared by every SQL schema-IR node and is non-enumerable (dropped\n * by the spread).\n */\nexport function isPostgresSchemaIR(schema: SqlSchemaIR): schema is PostgresSchemaIR {\n return schema.nodeTarget === 'postgres';\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA0CA,IAAa,mBAAb,cAAsC,gBAAgB;CACpD,aAAuC;CACvC;CAEA;CACA;CACA;CACA;CACA;CACA;CAEA,YAAY,OAA8B;EACxC,MAAM;EACN,KAAK,SAAS,OAAO,OACnB,OAAO,YACL,OAAO,QAAQ,MAAM,MAAM,CAAC,CAAC,KAAK,CAAC,KAAK,OAAO,CAC7C,KACA,aAAa,aAAa,IAAI,IAAI,WAAW,CAAC,CAChD,CAAC,CACH,CACF;EACA,KAAK,eAAe,MAAM;EAC1B,KAAK,YAAY,MAAM;EACvB,KAAK,cAAc,OAAO,OAAO,CAAC,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,sBAAsB,OAAO,OAAO,CAAC,GAAG,MAAM,mBAAmB,CAAC;EAKvE,KAAK,cAAc,EACjB,IAAI;GACF,QAAQ,MAAM;GACd,GAAI,MAAM,oBAAoB,SAAS,KAAK,EAC1C,qBAAqB,MAAM,oBAC7B;GACA,GAAI,MAAM,gBAAgB,SAAS,KAAK,EACtC,iBAAiB,MAAM,gBACzB;EACF,EACF;EACA,WAAW,IAAI;CACjB;AACF;;;;;;;;;;;AAYA,SAAgB,mBAAmB,QAAiD;CAClF,OAAO,OAAO,eAAe;AAC/B"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { t as PostgresRlsPolicy } from "./postgres-rls-policy-D_z1osEq.mjs";
|
|
2
|
+
import { t as PostgresRole } from "./postgres-role-_CCuyPCQ.mjs";
|
|
3
|
+
import { SqlAnnotations, SqlSchemaIR, SqlSchemaIRNode, SqlSchemaTarget, SqlTableIR, SqlTableIRInput } from "@prisma-next/sql-schema-ir/types";
|
|
4
|
+
|
|
5
|
+
//#region src/core/postgres-schema-ir.d.ts
|
|
6
|
+
interface PostgresSchemaIRInput {
|
|
7
|
+
readonly tables: Record<string, SqlTableIR | SqlTableIRInput>;
|
|
8
|
+
readonly pgSchemaName: string;
|
|
9
|
+
readonly pgVersion: string;
|
|
10
|
+
readonly rlsPolicies: readonly PostgresRlsPolicy[];
|
|
11
|
+
readonly roles: readonly PostgresRole[];
|
|
12
|
+
readonly existingSchemas: readonly string[];
|
|
13
|
+
readonly nativeEnumTypeNames: readonly string[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Postgres-specific schema IR. Mirrors the structure of `SqlSchemaIR`
|
|
17
|
+
* (same `tables` + optional `annotations` fields) and adds typed fields for
|
|
18
|
+
* data the postgres adapter collects during introspection.
|
|
19
|
+
*
|
|
20
|
+
* Extends `SqlSchemaIRNode` directly rather than `SqlSchemaIR` because
|
|
21
|
+
* `SqlSchemaIR` calls `freezeNode` in its constructor, which prevents
|
|
22
|
+
* subclass field initialisation. `PostgresSchemaIR` replicates the minimal
|
|
23
|
+
* `SqlSchemaIR` structure and freezes itself at the end of its own
|
|
24
|
+
* constructor.
|
|
25
|
+
*
|
|
26
|
+
* RLS-specific fields (`rlsPolicies`, `roles`) are typed top-level fields on
|
|
27
|
+
* this class — no `Reflect.get`, no untyped annotation bag access. The
|
|
28
|
+
* `annotations.pg` bag is populated with only the subset the family layer
|
|
29
|
+
* reads (`nativeEnumTypeNames`, `existingSchemas`, `schema`) so family-layer
|
|
30
|
+
* PSL inference and namespace verification continue to work without knowing
|
|
31
|
+
* about RLS.
|
|
32
|
+
*
|
|
33
|
+
* Nothing RLS-specific leaks into the sql-family layer.
|
|
34
|
+
*/
|
|
35
|
+
declare class PostgresSchemaIR extends SqlSchemaIRNode {
|
|
36
|
+
readonly nodeTarget: SqlSchemaTarget;
|
|
37
|
+
readonly tables: Readonly<Record<string, SqlTableIR>>;
|
|
38
|
+
readonly annotations?: SqlAnnotations;
|
|
39
|
+
readonly pgSchemaName: string;
|
|
40
|
+
readonly pgVersion: string;
|
|
41
|
+
readonly rlsPolicies: readonly PostgresRlsPolicy[];
|
|
42
|
+
readonly roles: readonly PostgresRole[];
|
|
43
|
+
readonly existingSchemas: readonly string[];
|
|
44
|
+
readonly nativeEnumTypeNames: readonly string[];
|
|
45
|
+
constructor(input: PostgresSchemaIRInput);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Structural guard for `PostgresSchemaIR`, narrowing on the `nodeTarget`
|
|
49
|
+
* discriminant rather than `instanceof`. `nodeTarget` is an enumerable own field
|
|
50
|
+
* (a plain class-field initializer), so it survives the `{ ...schema, tables }`
|
|
51
|
+
* spread the multi-space verify path (`projectSchemaToSpace`) produces — that
|
|
52
|
+
* projected object is not a class instance but retains every enumerable own
|
|
53
|
+
* property. The family-level `kind = 'sql-schema-ir'` discriminator is unusable
|
|
54
|
+
* here: it is shared by every SQL schema-IR node and is non-enumerable (dropped
|
|
55
|
+
* by the spread).
|
|
56
|
+
*/
|
|
57
|
+
declare function isPostgresSchemaIR(schema: SqlSchemaIR): schema is PostgresSchemaIR;
|
|
58
|
+
//#endregion
|
|
59
|
+
export { PostgresSchemaIRInput as n, isPostgresSchemaIR as r, PostgresSchemaIR as t };
|
|
60
|
+
//# sourceMappingURL=postgres-schema-ir-BQ3RpZMz.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-schema-ir-BQ3RpZMz.d.mts","names":[],"sources":["../src/core/postgres-schema-ir.ts"],"mappings":";;;;;UAYiB,qBAAA;EAAA,SACN,MAAA,EAAQ,MAAA,SAAe,UAAA,GAAa,eAAA;EAAA,SACpC,YAAA;EAAA,SACA,SAAA;EAAA,SACA,WAAA,WAAsB,iBAAA;EAAA,SACtB,KAAA,WAAgB,YAAA;EAAA,SAChB,eAAA;EAAA,SACA,mBAAA;AAAA;;;;;;;;;;;;;;;;;AAAmB;AAuB9B;;;cAAa,gBAAA,SAAyB,eAAA;EAAA,SAC3B,UAAA,EAAY,eAAA;EAAA,SACZ,MAAA,EAAQ,QAAA,CAAS,MAAA,SAAe,UAAA;EAAA,SACxB,WAAA,GAAc,cAAA;EAAA,SACtB,YAAA;EAAA,SACA,SAAA;EAAA,SACA,WAAA,WAAsB,iBAAA;EAAA,SACtB,KAAA,WAAgB,YAAA;EAAA,SAChB,eAAA;EAAA,SACA,mBAAA;cAEG,KAAA,EAAO,qBAAA;AAAA;;;;;;;;;;;iBA6CL,kBAAA,CAAmB,MAAA,EAAQ,WAAA,GAAc,MAAA,IAAU,gBAAgB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { r as isPostgresSchema } from "./postgres-schema-BVDr_61a.mjs";
|
|
2
|
+
import { n as isPostgresSchemaIR } from "./postgres-schema-ir-BF0X8jit.mjs";
|
|
3
|
+
import { UNBOUND_NAMESPACE_ID } from "@prisma-next/framework-components/ir";
|
|
4
|
+
//#region src/core/postgres-schema-ir-annotations.ts
|
|
5
|
+
function resolveDdlSchemaForNamespaceStorage(storage, namespaceId, schemaIr) {
|
|
6
|
+
if (namespaceId === UNBOUND_NAMESPACE_ID) return (schemaIr && isPostgresSchemaIR(schemaIr) ? schemaIr.pgSchemaName : void 0) ?? "public";
|
|
7
|
+
const namespace = storage.namespaces[namespaceId];
|
|
8
|
+
if (namespace && isPostgresSchema(namespace)) return namespace.ddlSchemaName(storage);
|
|
9
|
+
return namespaceId;
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { resolveDdlSchemaForNamespaceStorage as t };
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=postgres-schema-ir-annotations-El62Sywa.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-schema-ir-annotations-El62Sywa.mjs","names":[],"sources":["../src/core/postgres-schema-ir-annotations.ts"],"sourcesContent":["import { UNBOUND_NAMESPACE_ID } from '@prisma-next/framework-components/ir';\nimport type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport type { SqlSchemaIR } from '@prisma-next/sql-schema-ir/types';\nimport { isPostgresSchema } from './postgres-schema';\nimport { isPostgresSchemaIR } from './postgres-schema-ir';\n\nexport function resolveDdlSchemaForNamespaceStorage(\n storage: SqlStorage,\n namespaceId: string,\n schemaIr?: SqlSchemaIR,\n): string {\n if (namespaceId === UNBOUND_NAMESPACE_ID) {\n return (\n (schemaIr && isPostgresSchemaIR(schemaIr) ? schemaIr.pgSchemaName : undefined) ?? 'public'\n );\n }\n const namespace = storage.namespaces[namespaceId];\n if (namespace && isPostgresSchema(namespace)) {\n return namespace.ddlSchemaName(storage);\n }\n return namespaceId;\n}\n"],"mappings":";;;;AAMA,SAAgB,oCACd,SACA,aACA,UACQ;CACR,IAAI,gBAAgB,sBAClB,QACG,YAAY,mBAAmB,QAAQ,IAAI,SAAS,eAAe,KAAA,MAAc;CAGtF,MAAM,YAAY,QAAQ,WAAW;CACrC,IAAI,aAAa,iBAAiB,SAAS,GACzC,OAAO,UAAU,cAAc,OAAO;CAExC,OAAO;AACT"}
|
package/dist/render-ops.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as PostgresPlanTargetDetails } from "./planner-target-details-
|
|
1
|
+
import { t as PostgresPlanTargetDetails } from "./planner-target-details-HkP4RrRO.mjs";
|
|
2
2
|
import { SqlMigrationPlanOperation } from "@prisma-next/family-sql/control";
|
|
3
3
|
import { OpFactoryCall } from "@prisma-next/framework-components/control";
|
|
4
4
|
import { ExecuteRequestLowerer } from "@prisma-next/family-sql/control-adapter";
|
package/dist/runtime.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AnyCodecDescriptor } from "@prisma-next/framework-components/codec";
|
|
2
|
-
import { Namespace } from "@prisma-next/framework-components/ir";
|
|
2
|
+
import { AnyEntityKindDescriptor, Namespace } from "@prisma-next/framework-components/ir";
|
|
3
3
|
import { SqlNamespaceTablesInput, SqlStorage } from "@prisma-next/sql-contract/types";
|
|
4
4
|
import { SqlContractSerializerBase } from "@prisma-next/family-sql/ir";
|
|
5
5
|
import { Contract } from "@prisma-next/contract/types";
|
|
@@ -8,11 +8,12 @@ import { JsonObject } from "@prisma-next/utils/json";
|
|
|
8
8
|
|
|
9
9
|
//#region src/core/postgres-contract-serializer.d.ts
|
|
10
10
|
declare class PostgresContractSerializer extends SqlContractSerializerBase<Contract<SqlStorage>> {
|
|
11
|
-
constructor();
|
|
11
|
+
constructor(extraPackEntityKinds?: readonly AnyEntityKindDescriptor[]);
|
|
12
12
|
protected get defaultNamespaceId(): string;
|
|
13
13
|
protected hydrateSqlNamespaceEntry(nsId: string, raw: Namespace | Record<string, unknown>): Namespace | SqlNamespaceTablesInput;
|
|
14
14
|
serializeContract(contract: Contract<SqlStorage>): JsonObject;
|
|
15
15
|
private serializePostgresNamespace;
|
|
16
|
+
private serializeJsonObject;
|
|
16
17
|
private serializeJsonValue;
|
|
17
18
|
}
|
|
18
19
|
//#endregion
|
package/dist/runtime.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.mts","names":[],"sources":["../src/core/postgres-contract-serializer.ts","../src/exports/runtime.ts"],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"runtime.d.mts","names":[],"sources":["../src/core/postgres-contract-serializer.ts","../src/exports/runtime.ts"],"mappings":";;;;;;;;;cAqEa,0BAAA,SAAmC,yBAAA,CAA0B,QAAA,CAAS,UAAA;cACrE,oBAAA,YAA+B,uBAAA;EAAA,cAKpB,kBAAA;EAAA,UAIJ,wBAAA,CACjB,IAAA,UACA,GAAA,EAAK,SAAA,GAAY,MAAA,oBAChB,SAAA,GAAY,uBAAA;EA4BN,iBAAA,CAAkB,QAAA,EAAU,QAAA,CAAS,UAAA,IAAc,UAAA;EAAA,QA0CpD,0BAAA;EAAA,QAgCA,mBAAA;EAAA,QAOA,kBAAA;AAAA;;;UCtLO,6BAAA,SAAsC,qBAAqB;;;;;AD4D5E;;cCpDM,+BAAA,EAAiC,uBAAA,oBAGrC,6BAAA;EAAA,SAES,MAAA,iBAAuB,kBAAA;AAAA"}
|
package/dist/runtime.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as postgresTargetDescriptorMetaRuntime } from "./descriptor-meta-
|
|
2
|
-
import { t as PostgresContractSerializer } from "./postgres-contract-serializer-
|
|
1
|
+
import { n as postgresTargetDescriptorMetaRuntime } from "./descriptor-meta-b_SzXwen.mjs";
|
|
2
|
+
import { t as PostgresContractSerializer } from "./postgres-contract-serializer-k5eg5ZUZ.mjs";
|
|
3
3
|
//#region src/exports/runtime.ts
|
|
4
4
|
/**
|
|
5
5
|
* Target-postgres deliberately does NOT import `SqlRuntimeTargetDescriptor` from `@prisma-next/sql-runtime`. The target package is a control-plane residence and must not pull the SQL execution-plane package into its dependency closure. The runtime descriptor here is shaped to satisfy the framework's `RuntimeTargetDescriptor` plus the structural `SqlStaticContributions` (`codecs:` returning a descriptor list) that
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SqlStorage } from "@prisma-next/sql-contract/types";
|
|
2
|
+
import { SqlSchemaIR } from "@prisma-next/sql-schema-ir/types";
|
|
3
|
+
|
|
4
|
+
//#region src/core/postgres-schema-ir-annotations.d.ts
|
|
5
|
+
declare function resolveDdlSchemaForNamespaceStorage(storage: SqlStorage, namespaceId: string, schemaIr?: SqlSchemaIR): string;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { resolveDdlSchemaForNamespaceStorage };
|
|
8
|
+
//# sourceMappingURL=schema-ir-annotations.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-ir-annotations.d.mts","names":[],"sources":["../src/core/postgres-schema-ir-annotations.ts"],"mappings":";;;;iBAMgB,mCAAA,CACd,OAAA,EAAS,UAAA,EACT,WAAA,UACA,QAAA,GAAW,WAAW"}
|
package/dist/types.d.mts
CHANGED
|
@@ -1,141 +1,6 @@
|
|
|
1
|
-
import { t as
|
|
1
|
+
import { n as PostgresRlsPolicyInput, r as RlsPolicyOperation, t as PostgresRlsPolicy } from "./postgres-rls-policy-D_z1osEq.mjs";
|
|
2
2
|
import { t as PostgresColumnDefault } from "./types-BDKkx8MA.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
//#region src/core/postgres-schema.d.ts
|
|
8
|
-
interface PostgresSchemaInput {
|
|
9
|
-
readonly id: string;
|
|
10
|
-
readonly entries: Readonly<Record<string, Readonly<Record<string, unknown>>>>;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Postgres target `Namespace` concretion — a Postgres schema (`CREATE
|
|
14
|
-
* SCHEMA …`). Each Postgres `SqlStorage` carries a
|
|
15
|
-
* `namespaces: Record<NamespaceId, PostgresSchema>` map populated by
|
|
16
|
-
* the Postgres PSL interpreter from `namespace { … }` AST buckets.
|
|
17
|
-
*
|
|
18
|
-
* `entries` holds entity-kind maps (`table`, `valueSet`). Qualifier
|
|
19
|
-
* emission is the rendering seam: DDL / SQL emission asks the namespace
|
|
20
|
-
* for its qualifier (`"<schema>"`) or for a qualified table name
|
|
21
|
-
* (`"<schema>"."<table>"`) and consumes the result polymorphically.
|
|
22
|
-
* The unbound singleton below overrides these methods to elide the
|
|
23
|
-
* prefix entirely — call sites stay polymorphic and never branch on
|
|
24
|
-
* `id === UNBOUND_NAMESPACE_ID`.
|
|
25
|
-
*/
|
|
26
|
-
declare class PostgresSchema extends NamespaceBase {
|
|
27
|
-
/**
|
|
28
|
-
* Stable singleton reference for the late-bound slot. Materialised
|
|
29
|
-
* lazily below the singleton subclass declaration so the static
|
|
30
|
-
* initialiser sees the subclass before assigning. Consumers always
|
|
31
|
-
* reach for `PostgresSchema.unbound` (or `PostgresUnboundSchema.instance`
|
|
32
|
-
* — same identity).
|
|
33
|
-
*/
|
|
34
|
-
static unbound: PostgresUnboundSchema;
|
|
35
|
-
readonly kind: 'schema';
|
|
36
|
-
readonly id: string;
|
|
37
|
-
readonly entries: SqlNamespaceEntries;
|
|
38
|
-
constructor(input: PostgresSchemaInput);
|
|
39
|
-
get table(): Readonly<Record<string, StorageTable>>;
|
|
40
|
-
get valueSet(): Readonly<Record<string, StorageValueSet>> | undefined;
|
|
41
|
-
/**
|
|
42
|
-
* The bare schema qualifier as it would appear in a rendered SQL
|
|
43
|
-
* fragment (already quoted). The unbound-schema singleton overrides
|
|
44
|
-
* this to return `''`.
|
|
45
|
-
*/
|
|
46
|
-
qualifier(): string;
|
|
47
|
-
/**
|
|
48
|
-
* Qualify a table name with the schema prefix
|
|
49
|
-
* (`"<schema>"."<table>"`). The unbound-schema singleton overrides
|
|
50
|
-
* this to emit just `"<table>"` so the resolved DDL is unqualified
|
|
51
|
-
* and `search_path` decides where the object lands at runtime.
|
|
52
|
-
*/
|
|
53
|
-
qualifyTable(tableName: string): string;
|
|
54
|
-
/**
|
|
55
|
-
* Render a SQL string-literal containing the qualified-name form
|
|
56
|
-
* suitable for `to_regclass(...)` arguments (e.g. `'"public"."user"'`).
|
|
57
|
-
* The unbound singleton overrides this to elide the schema prefix
|
|
58
|
-
* (`'"user"'`) so `search_path` resolves the object at runtime.
|
|
59
|
-
*/
|
|
60
|
-
regclassLiteral(name: string): string;
|
|
61
|
-
/**
|
|
62
|
-
* Render a SQL expression that evaluates to this namespace's schema
|
|
63
|
-
* name at runtime, ready to drop into a `WHERE table_schema = …` /
|
|
64
|
-
* `WHERE n.nspname = …` clause. Named schemas emit a quoted SQL
|
|
65
|
-
* literal (`'public'`); the unbound singleton overrides this to emit
|
|
66
|
-
* `current_schema()` so catalog queries match whichever schema the
|
|
67
|
-
* connection's `search_path` resolved at runtime.
|
|
68
|
-
*/
|
|
69
|
-
schemaSqlExpression(): string;
|
|
70
|
-
/**
|
|
71
|
-
* Typed-AST counterpart of {@link schemaSqlExpression}: the expression a
|
|
72
|
-
* builder-built catalog check compares `n.nspname` / `table_schema`
|
|
73
|
-
* against. Named schemas bind the schema name as a text parameter; the
|
|
74
|
-
* unbound singleton overrides this to the opaque `current_schema()`
|
|
75
|
-
* expression so the live connection's `search_path` decides at runtime.
|
|
76
|
-
*/
|
|
77
|
-
schemaFilterExpression(): CfExpr;
|
|
78
|
-
/**
|
|
79
|
-
* Typed-AST counterpart of {@link qualifyTable}: the FROM source a
|
|
80
|
-
* builder-built check uses to address a user table in this namespace.
|
|
81
|
-
* Named schemas qualify (`"schema"."table"`); the unbound singleton
|
|
82
|
-
* overrides this to leave the table unqualified so `search_path`
|
|
83
|
-
* resolves it at runtime.
|
|
84
|
-
*/
|
|
85
|
-
tableSource(tableName: string, alias?: string): PostgresTableSource;
|
|
86
|
-
/**
|
|
87
|
-
* The bare schema name a DDL planner should target when emitting
|
|
88
|
-
* statements that need to identify this namespace in the live
|
|
89
|
-
* database (e.g. `CREATE TABLE "<ddlSchemaName>"."<table>" …`,
|
|
90
|
-
* catalog filters, planner conflict lookups). Named schemas resolve
|
|
91
|
-
* to their own id. The `PostgresUnboundSchema` singleton inherits
|
|
92
|
-
* this and returns `UNBOUND_NAMESPACE_ID` — callers that dispatch
|
|
93
|
-
* through `qualifyTableName` route through the polymorphic
|
|
94
|
-
* `PostgresUnboundSchema` overrides and produce unqualified
|
|
95
|
-
* (search-path-resolved) output automatically.
|
|
96
|
-
*/
|
|
97
|
-
ddlSchemaName(_storage: SqlStorage): string;
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Singleton subclass for the reserved sentinel namespace id
|
|
101
|
-
* (`UNBOUND_NAMESPACE_ID`) — the late-bound Postgres slot whose binding
|
|
102
|
-
* the connection's `search_path` resolves at runtime. Overrides
|
|
103
|
-
* qualifier emission to elide the schema prefix; call sites that consume
|
|
104
|
-
* `qualifier()` / `qualifyTable()` get unqualified output without
|
|
105
|
-
* branching on the namespace id.
|
|
106
|
-
*
|
|
107
|
-
* This is the target-side materialization of "the framework provides
|
|
108
|
-
* affordances; targets implement specifics": the framework names the
|
|
109
|
-
* sentinel; Postgres decides what late-bound means here (the table
|
|
110
|
-
* name, naked — the schema is supplied by the live connection's
|
|
111
|
-
* `search_path`).
|
|
112
|
-
*
|
|
113
|
-
* `ddlSchemaName` is inherited from `PostgresSchema` and returns
|
|
114
|
-
* `UNBOUND_NAMESPACE_ID`. Downstream helpers such as `qualifyTableName`
|
|
115
|
-
* route through the polymorphic factory and produce unqualified output
|
|
116
|
-
* automatically.
|
|
117
|
-
*/
|
|
118
|
-
declare class PostgresUnboundSchema extends PostgresSchema {
|
|
119
|
-
static readonly instance: PostgresUnboundSchema;
|
|
120
|
-
constructor(input?: PostgresSchemaInput);
|
|
121
|
-
qualifier(): string;
|
|
122
|
-
qualifyTable(tableName: string): string;
|
|
123
|
-
schemaSqlExpression(): string;
|
|
124
|
-
schemaFilterExpression(): CfExpr;
|
|
125
|
-
tableSource(tableName: string, alias?: string): PostgresTableSource;
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Target-supplied `Namespace` factory the Postgres target plumbs
|
|
129
|
-
* through `defineContract({ createNamespace })` and the SQL PSL
|
|
130
|
-
* interpreter. Returns the unbound singleton for the framework
|
|
131
|
-
* sentinel and a fresh `PostgresSchema` for any other coordinate.
|
|
132
|
-
*
|
|
133
|
-
* The factory has no per-call state — every named id deterministically
|
|
134
|
-
* maps to a distinct schema instance — so callers can pass it through
|
|
135
|
-
* by reference and trust the resulting `SqlStorage.namespaces` map to
|
|
136
|
-
* be value-stable for a given input set.
|
|
137
|
-
*/
|
|
138
|
-
declare function postgresCreateNamespace(input: SqlNamespaceTablesInput): PostgresSchema;
|
|
139
|
-
//#endregion
|
|
140
|
-
export { type PostgresColumnDefault, PostgresSchema, PostgresUnboundSchema, postgresCreateNamespace };
|
|
141
|
-
//# sourceMappingURL=types.d.mts.map
|
|
3
|
+
import { n as PostgresRoleInput, t as PostgresRole } from "./postgres-role-_CCuyPCQ.mjs";
|
|
4
|
+
import { i as postgresCreateNamespace, n as PostgresUnboundSchema, r as isPostgresSchema, t as PostgresSchema } from "./postgres-schema-D0h4lsw2.mjs";
|
|
5
|
+
import { n as PostgresSchemaIRInput, r as isPostgresSchemaIR, t as PostgresSchemaIR } from "./postgres-schema-ir-BQ3RpZMz.mjs";
|
|
6
|
+
export { type PostgresColumnDefault, PostgresRlsPolicy, type PostgresRlsPolicyInput, PostgresRole, type PostgresRoleInput, PostgresSchema, PostgresSchemaIR, type PostgresSchemaIRInput, PostgresUnboundSchema, type RlsPolicyOperation, isPostgresSchema, isPostgresSchemaIR, postgresCreateNamespace };
|
package/dist/types.mjs
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import { i as postgresCreateNamespace, n as PostgresUnboundSchema, t as PostgresSchema } from "./postgres-schema-
|
|
2
|
-
|
|
1
|
+
import { d as PostgresRlsPolicy, i as postgresCreateNamespace, n as PostgresUnboundSchema, r as isPostgresSchema, t as PostgresSchema, u as PostgresRole } from "./postgres-schema-BVDr_61a.mjs";
|
|
2
|
+
import { n as isPostgresSchemaIR, t as PostgresSchemaIR } from "./postgres-schema-ir-BF0X8jit.mjs";
|
|
3
|
+
export { PostgresRlsPolicy, PostgresRole, PostgresSchema, PostgresSchemaIR, PostgresUnboundSchema, isPostgresSchema, isPostgresSchemaIR, postgresCreateNamespace };
|
package/package.json
CHANGED
|
@@ -1,32 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma-next/target-postgres",
|
|
3
|
-
"version": "0.14.0-dev.
|
|
3
|
+
"version": "0.14.0-dev.12",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"description": "Postgres target pack for Prisma Next",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@prisma-next/cli": "0.14.0-dev.
|
|
10
|
-
"@prisma-next/contract": "0.14.0-dev.
|
|
11
|
-
"@prisma-next/errors": "0.14.0-dev.
|
|
12
|
-
"@prisma-next/family-sql": "0.14.0-dev.
|
|
13
|
-
"@prisma-next/framework-components": "0.14.0-dev.
|
|
14
|
-
"@prisma-next/migration-tools": "0.14.0-dev.
|
|
15
|
-
"@prisma-next/ts-render": "0.14.0-dev.
|
|
16
|
-
"@prisma-next/sql-contract": "0.14.0-dev.
|
|
17
|
-
"@prisma-next/sql-errors": "0.14.0-dev.
|
|
18
|
-
"@prisma-next/sql-operations": "0.14.0-dev.
|
|
19
|
-
"@prisma-next/sql-relational-core": "0.14.0-dev.
|
|
20
|
-
"@prisma-next/sql-schema-ir": "0.14.0-dev.
|
|
21
|
-
"@prisma-next/utils": "0.14.0-dev.
|
|
9
|
+
"@prisma-next/cli": "0.14.0-dev.12",
|
|
10
|
+
"@prisma-next/contract": "0.14.0-dev.12",
|
|
11
|
+
"@prisma-next/errors": "0.14.0-dev.12",
|
|
12
|
+
"@prisma-next/family-sql": "0.14.0-dev.12",
|
|
13
|
+
"@prisma-next/framework-components": "0.14.0-dev.12",
|
|
14
|
+
"@prisma-next/migration-tools": "0.14.0-dev.12",
|
|
15
|
+
"@prisma-next/ts-render": "0.14.0-dev.12",
|
|
16
|
+
"@prisma-next/sql-contract": "0.14.0-dev.12",
|
|
17
|
+
"@prisma-next/sql-errors": "0.14.0-dev.12",
|
|
18
|
+
"@prisma-next/sql-operations": "0.14.0-dev.12",
|
|
19
|
+
"@prisma-next/sql-relational-core": "0.14.0-dev.12",
|
|
20
|
+
"@prisma-next/sql-schema-ir": "0.14.0-dev.12",
|
|
21
|
+
"@prisma-next/utils": "0.14.0-dev.12",
|
|
22
22
|
"@standard-schema/spec": "^1.1.0",
|
|
23
23
|
"arktype": "^2.2.0",
|
|
24
24
|
"pathe": "^2.0.3"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@prisma-next/
|
|
28
|
-
"@prisma-next/
|
|
29
|
-
"@prisma-next/
|
|
27
|
+
"@prisma-next/psl-parser": "0.14.0-dev.12",
|
|
28
|
+
"@prisma-next/sql-contract-psl": "0.14.0-dev.12",
|
|
29
|
+
"@prisma-next/test-utils": "0.14.0-dev.12",
|
|
30
|
+
"@prisma-next/tsconfig": "0.14.0-dev.12",
|
|
31
|
+
"@prisma-next/tsdown": "0.14.0-dev.12",
|
|
30
32
|
"tsdown": "0.22.1",
|
|
31
33
|
"typescript": "5.9.3",
|
|
32
34
|
"vitest": "4.1.8"
|
|
@@ -68,7 +70,9 @@
|
|
|
68
70
|
"./planner-target-details": "./dist/planner-target-details.mjs",
|
|
69
71
|
"./render-ops": "./dist/render-ops.mjs",
|
|
70
72
|
"./render-typescript": "./dist/render-typescript.mjs",
|
|
73
|
+
"./rls-canonicalize": "./dist/rls-canonicalize.mjs",
|
|
71
74
|
"./runtime": "./dist/runtime.mjs",
|
|
75
|
+
"./schema-ir-annotations": "./dist/schema-ir-annotations.mjs",
|
|
72
76
|
"./sql-utils": "./dist/sql-utils.mjs",
|
|
73
77
|
"./types": "./dist/types.mjs",
|
|
74
78
|
"./package.json": "./package.json"
|