@prisma-next/target-postgres 0.14.0-dev.5 → 0.14.0-dev.51
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
|
@@ -1,24 +1,38 @@
|
|
|
1
|
+
import type { Contract } from '@prisma-next/contract/types';
|
|
1
2
|
import {
|
|
2
3
|
freezeNode,
|
|
3
4
|
hydrateNamespaceEntities,
|
|
4
|
-
NamespaceBase,
|
|
5
5
|
UNBOUND_NAMESPACE_ID,
|
|
6
6
|
} from '@prisma-next/framework-components/ir';
|
|
7
7
|
import { composeSqlEntityKinds } from '@prisma-next/sql-contract/entity-kinds';
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
import {
|
|
9
|
+
SqlNamespaceBase,
|
|
10
|
+
type SqlNamespaceEntries,
|
|
11
|
+
type SqlNamespaceInput,
|
|
12
|
+
type SqlStorage,
|
|
13
|
+
type StorageTable,
|
|
14
|
+
type StorageValueSet,
|
|
14
15
|
} from '@prisma-next/sql-contract/types';
|
|
16
|
+
|
|
15
17
|
import { type CfExpr, cfExpr } from '@prisma-next/sql-relational-core/contract-free';
|
|
16
18
|
import { blindCast } from '@prisma-next/utils/casts';
|
|
17
19
|
import { ifDefined } from '@prisma-next/utils/defined';
|
|
18
20
|
import { PostgresTableSource } from './ast/table-source';
|
|
19
21
|
import { PG_TEXT_CODEC_ID } from './codec-ids';
|
|
22
|
+
import { nativeEnumEntityKind, policyEntityKind, roleEntityKind } from './entity-kinds';
|
|
23
|
+
import type { PostgresNativeEnum } from './postgres-native-enum';
|
|
24
|
+
import type { PostgresRlsPolicy } from './postgres-rls-policy';
|
|
25
|
+
import type { PostgresRole } from './postgres-role';
|
|
20
26
|
import { escapeLiteral } from './sql-utils';
|
|
21
27
|
|
|
28
|
+
export type PostgresContract = Contract<SqlStorage> & { readonly target: 'postgres' };
|
|
29
|
+
|
|
30
|
+
export type PostgresNamespaceEntries = SqlNamespaceEntries & {
|
|
31
|
+
readonly policy?: Readonly<Record<string, PostgresRlsPolicy>>;
|
|
32
|
+
readonly role?: Readonly<Record<string, PostgresRole>>;
|
|
33
|
+
readonly native_enum?: Readonly<Record<string, PostgresNativeEnum>>;
|
|
34
|
+
};
|
|
35
|
+
|
|
22
36
|
export interface PostgresSchemaInput {
|
|
23
37
|
readonly id: string;
|
|
24
38
|
readonly entries: Readonly<Record<string, Readonly<Record<string, unknown>>>>;
|
|
@@ -38,7 +52,7 @@ export interface PostgresSchemaInput {
|
|
|
38
52
|
* prefix entirely — call sites stay polymorphic and never branch on
|
|
39
53
|
* `id === UNBOUND_NAMESPACE_ID`.
|
|
40
54
|
*/
|
|
41
|
-
export class PostgresSchema extends
|
|
55
|
+
export class PostgresSchema extends SqlNamespaceBase {
|
|
42
56
|
/**
|
|
43
57
|
* Stable singleton reference for the late-bound slot. Materialised
|
|
44
58
|
* lazily below the singleton subclass declaration so the static
|
|
@@ -50,13 +64,17 @@ export class PostgresSchema extends NamespaceBase {
|
|
|
50
64
|
|
|
51
65
|
declare readonly kind: 'schema';
|
|
52
66
|
readonly id: string;
|
|
53
|
-
readonly entries:
|
|
67
|
+
readonly entries: PostgresNamespaceEntries;
|
|
54
68
|
|
|
55
69
|
constructor(input: PostgresSchemaInput) {
|
|
56
70
|
super();
|
|
57
71
|
this.id = input.id;
|
|
58
72
|
|
|
59
|
-
const dispatched = hydrateNamespaceEntities(
|
|
73
|
+
const dispatched = hydrateNamespaceEntities(
|
|
74
|
+
input.entries,
|
|
75
|
+
composeSqlEntityKinds([policyEntityKind, roleEntityKind, nativeEnumEntityKind]),
|
|
76
|
+
'carry',
|
|
77
|
+
);
|
|
60
78
|
|
|
61
79
|
// Drop an empty valueSet so presence signals non-emptiness.
|
|
62
80
|
const valueSetRaw = dispatched['valueSet'];
|
|
@@ -65,11 +83,33 @@ export class PostgresSchema extends NamespaceBase {
|
|
|
65
83
|
? { ...dispatched, valueSet: undefined }
|
|
66
84
|
: dispatched;
|
|
67
85
|
|
|
86
|
+
// `native_enum` is authoring-time-only (`PostgresContractSerializer`
|
|
87
|
+
// never re-emits it; its member values live on via the `valueSet`
|
|
88
|
+
// entry it derives). Carried as a non-enumerable property — like
|
|
89
|
+
// `kind` below — so `JSON.stringify` (the hashing pipeline's
|
|
90
|
+
// canonicalization step, `computeStorageHash` via `hashContract`)
|
|
91
|
+
// walks past it and the storage hash matches what actually gets
|
|
92
|
+
// serialized. Direct property access (`ns.entries.native_enum`)
|
|
93
|
+
// still resolves normally; only enumeration is affected.
|
|
94
|
+
const nativeEnumRaw = dispatched['native_enum'];
|
|
95
|
+
const entriesInput: Record<string, Readonly<Record<string, unknown>> | undefined> = {
|
|
96
|
+
...withPresence,
|
|
97
|
+
};
|
|
98
|
+
delete entriesInput['native_enum'];
|
|
99
|
+
if (nativeEnumRaw !== undefined) {
|
|
100
|
+
Object.defineProperty(entriesInput, 'native_enum', {
|
|
101
|
+
value: nativeEnumRaw,
|
|
102
|
+
enumerable: false,
|
|
103
|
+
writable: false,
|
|
104
|
+
configurable: true,
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
|
|
68
108
|
this.entries = Object.freeze(
|
|
69
109
|
blindCast<
|
|
70
|
-
|
|
71
|
-
'composeSqlEntityKinds() supplies table→StorageTable
|
|
72
|
-
>(
|
|
110
|
+
PostgresNamespaceEntries,
|
|
111
|
+
'composeSqlEntityKinds([policyEntityKind, roleEntityKind, nativeEnumEntityKind]) supplies table→StorageTable, valueSet→StorageValueSet, policy→PostgresRlsPolicy, role→PostgresRole, native_enum→PostgresNativeEnum descriptors'
|
|
112
|
+
>(entriesInput),
|
|
73
113
|
);
|
|
74
114
|
Object.defineProperty(this, 'kind', {
|
|
75
115
|
value: 'schema',
|
|
@@ -88,6 +128,14 @@ export class PostgresSchema extends NamespaceBase {
|
|
|
88
128
|
return this.entries.valueSet;
|
|
89
129
|
}
|
|
90
130
|
|
|
131
|
+
get policy(): Readonly<Record<string, PostgresRlsPolicy>> {
|
|
132
|
+
return this.entries.policy ?? Object.freeze({});
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
get role(): Readonly<Record<string, PostgresRole>> {
|
|
136
|
+
return this.entries.role ?? Object.freeze({});
|
|
137
|
+
}
|
|
138
|
+
|
|
91
139
|
/**
|
|
92
140
|
* The bare schema qualifier as it would appear in a rendered SQL
|
|
93
141
|
* fragment (already quoted). The unbound-schema singleton overrides
|
|
@@ -247,7 +295,7 @@ export function isPostgresSchema(ns: unknown): ns is PostgresSchema {
|
|
|
247
295
|
* by reference and trust the resulting `SqlStorage.namespaces` map to
|
|
248
296
|
* be value-stable for a given input set.
|
|
249
297
|
*/
|
|
250
|
-
export function postgresCreateNamespace(input:
|
|
298
|
+
export function postgresCreateNamespace(input: SqlNamespaceInput): PostgresSchema {
|
|
251
299
|
const schemaInput: PostgresSchemaInput = {
|
|
252
300
|
id: input.id,
|
|
253
301
|
entries: {
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type } from 'arktype';
|
|
2
|
+
|
|
3
|
+
export const PostgresRoleSchema = type({
|
|
4
|
+
kind: "'role'",
|
|
5
|
+
name: 'string',
|
|
6
|
+
namespaceId: 'string',
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export const PostgresRlsPolicySchema = type({
|
|
10
|
+
kind: "'policy'",
|
|
11
|
+
name: 'string',
|
|
12
|
+
prefix: 'string',
|
|
13
|
+
tableName: 'string',
|
|
14
|
+
namespaceId: 'string',
|
|
15
|
+
operation: "'select' | 'insert' | 'update' | 'delete' | 'all'",
|
|
16
|
+
roles: type.string.array().readonly(),
|
|
17
|
+
'using?': 'string',
|
|
18
|
+
'withCheck?': 'string',
|
|
19
|
+
permissive: 'boolean',
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export const PostgresNativeEnumSchema = type({
|
|
23
|
+
kind: "'postgres-enum'",
|
|
24
|
+
typeName: 'string',
|
|
25
|
+
members: type.string.array().readonly(),
|
|
26
|
+
'control?': "'managed' | 'tolerated' | 'external' | 'observed'",
|
|
27
|
+
});
|