@prisma-next/target-postgres 0.14.0-dev.60 → 0.14.0-dev.62
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{authoring-WkqG_MkU.mjs → authoring-CdIZ0yvD.mjs} +147 -38
- package/dist/authoring-CdIZ0yvD.mjs.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-policy-Co_13Hxa.mjs → control-policy-DKp0HKpY.mjs} +203 -45
- package/dist/control-policy-DKp0HKpY.mjs.map +1 -0
- package/dist/control.mjs +22 -25
- package/dist/control.mjs.map +1 -1
- package/dist/{ddl-B-krEXY1.mjs → ddl-gmxHf68z.mjs} +20 -4
- package/dist/{ddl-B-krEXY1.mjs.map → ddl-gmxHf68z.mjs.map} +1 -1
- package/dist/ddl.d.mts +2 -2
- package/dist/ddl.mjs +2 -2
- package/dist/{descriptor-meta-BOcKPaLE.mjs → descriptor-meta-DEuXJfpR.mjs} +3 -3
- package/dist/{descriptor-meta-BOcKPaLE.mjs.map → descriptor-meta-DEuXJfpR.mjs.map} +1 -1
- package/dist/{diff-database-schema-BOsDnH64.mjs → diff-database-schema-D2sjvMw9.mjs} +55 -19
- package/dist/diff-database-schema-D2sjvMw9.mjs.map +1 -0
- package/dist/diff-database-schema.d.mts +4 -4
- package/dist/diff-database-schema.d.mts.map +1 -1
- package/dist/diff-database-schema.mjs +1 -1
- package/dist/issue-planner.d.mts +1 -1
- package/dist/issue-planner.d.mts.map +1 -1
- package/dist/issue-planner.mjs +1 -1
- package/dist/migration.d.mts +2 -2
- package/dist/migration.mjs +2 -2
- package/dist/{nodes-BtQyZha6.d.mts → nodes-Bc2N3tMy.d.mts} +27 -3
- package/dist/nodes-Bc2N3tMy.d.mts.map +1 -0
- package/dist/{nodes-B815pj_X.mjs → nodes-DJC5B8Id.mjs} +32 -2
- package/dist/nodes-DJC5B8Id.mjs.map +1 -0
- package/dist/{op-factory-call-DxNNKUeZ.mjs → op-factory-call-C4flTtTG.mjs} +105 -6
- package/dist/op-factory-call-C4flTtTG.mjs.map +1 -0
- package/dist/{op-factory-call-D6_7-7Vc.d.mts → op-factory-call-CSIg5XDu.d.mts} +26 -3
- package/dist/{op-factory-call-D6_7-7Vc.d.mts.map → op-factory-call-CSIg5XDu.d.mts.map} +1 -1
- package/dist/op-factory-call.d.mts +2 -2
- package/dist/op-factory-call.mjs +2 -2
- package/dist/pack.d.mts +146 -3
- package/dist/pack.d.mts.map +1 -1
- package/dist/pack.mjs +1 -1
- package/dist/{planner-CNrc1Odu.mjs → planner-BtEd5LMr.mjs} +32 -64
- package/dist/planner-BtEd5LMr.mjs.map +1 -0
- package/dist/{planner-ddl-builders-B8Nn6nHN.mjs → planner-ddl-builders-BKlmGDJl.mjs} +7 -3
- package/dist/planner-ddl-builders-BKlmGDJl.mjs.map +1 -0
- package/dist/planner-ddl-builders.d.mts.map +1 -1
- package/dist/planner-ddl-builders.mjs +1 -1
- package/dist/{planner-produced-postgres-migration-a-tjfKsA.d.mts → planner-produced-postgres-migration-CXue-6M9.d.mts} +2 -2
- package/dist/{planner-produced-postgres-migration-a-tjfKsA.d.mts.map → planner-produced-postgres-migration-CXue-6M9.d.mts.map} +1 -1
- package/dist/{planner-produced-postgres-migration-NI-oGKcw.mjs → planner-produced-postgres-migration-Jat3hg4u.mjs} +2 -2
- package/dist/{planner-produced-postgres-migration-NI-oGKcw.mjs.map → planner-produced-postgres-migration-Jat3hg4u.mjs.map} +1 -1
- package/dist/planner-produced-postgres-migration.d.mts +1 -1
- package/dist/planner-produced-postgres-migration.mjs +1 -1
- package/dist/{planner-sql-checks-AXoxB1Jl.mjs → planner-sql-checks-Br1c_QsH.mjs} +3 -3
- package/dist/{planner-sql-checks-AXoxB1Jl.mjs.map → planner-sql-checks-Br1c_QsH.mjs.map} +1 -1
- package/dist/planner-sql-checks.mjs +1 -1
- package/dist/planner.d.mts +3 -3
- package/dist/planner.d.mts.map +1 -1
- package/dist/planner.mjs +2 -2
- package/dist/{postgres-contract-view-Dg-N7KA7.mjs → postgres-contract-view-BAPW0ec1.mjs} +3 -3
- package/dist/{postgres-contract-view-Dg-N7KA7.mjs.map → postgres-contract-view-BAPW0ec1.mjs.map} +1 -1
- package/dist/{postgres-database-schema-node-CfdTY-Qs.d.mts → postgres-database-schema-node-CJv5bfbs.d.mts} +70 -26
- package/dist/postgres-database-schema-node-CJv5bfbs.d.mts.map +1 -0
- package/dist/{postgres-migration-ChyRsWvE.mjs → postgres-migration-ChLMQRd-.mjs} +19 -3
- package/dist/postgres-migration-ChLMQRd-.mjs.map +1 -0
- package/dist/{postgres-migration-Bzzi0Asr.d.mts → postgres-migration-DkmgGNcv.d.mts} +21 -2
- package/dist/postgres-migration-DkmgGNcv.d.mts.map +1 -0
- package/dist/{postgres-role-schema-node-BiSTCTNg.mjs → postgres-role-schema-node-Cm-j0ZGM.mjs} +20 -25
- package/dist/postgres-role-schema-node-Cm-j0ZGM.mjs.map +1 -0
- package/dist/{postgres-schema-DTLA_aRi.mjs → postgres-schema-DWQ0-CPb.mjs} +32 -4
- package/dist/postgres-schema-DWQ0-CPb.mjs.map +1 -0
- package/dist/{postgres-schema-CU4gF6QZ.d.mts → postgres-schema-DsrtYp2v.d.mts} +13 -1
- package/dist/postgres-schema-DsrtYp2v.d.mts.map +1 -0
- package/dist/{postgres-table-schema-node-9FCtCUz2.mjs → postgres-table-schema-node-D6LvInCe.mjs} +71 -8
- package/dist/postgres-table-schema-node-D6LvInCe.mjs.map +1 -0
- package/dist/{resolve-ddl-schema-Ca88Tg6W.mjs → resolve-ddl-schema-CAza65Iy.mjs} +2 -2
- package/dist/{resolve-ddl-schema-Ca88Tg6W.mjs.map → resolve-ddl-schema-CAza65Iy.mjs.map} +1 -1
- package/dist/runtime.mjs +1 -1
- package/dist/schema-ir-annotations.mjs +1 -1
- package/dist/{sql-utils-DcfMz4MQ.mjs → sql-utils-SU4FDvIV.mjs} +12 -3
- package/dist/{sql-utils-DcfMz4MQ.mjs.map → sql-utils-SU4FDvIV.mjs.map} +1 -1
- package/dist/sql-utils.d.mts +8 -1
- package/dist/sql-utils.d.mts.map +1 -1
- package/dist/sql-utils.mjs +2 -2
- package/dist/types.d.mts +3 -3
- package/dist/types.mjs +4 -4
- package/package.json +20 -20
- package/src/contract-free/ddl.ts +27 -0
- package/src/core/authoring.ts +136 -25
- package/src/core/ddl/nodes.ts +44 -0
- package/src/core/migrations/contract-to-postgres-database-schema-node.ts +12 -1
- package/src/core/migrations/control-policy.ts +172 -45
- package/src/core/migrations/diff-database-schema.ts +48 -13
- package/src/core/migrations/issue-planner.ts +77 -4
- package/src/core/migrations/op-factory-call.ts +84 -0
- package/src/core/migrations/operations/native-enum-types.ts +62 -0
- package/src/core/migrations/planner-ddl-builders.ts +12 -2
- package/src/core/migrations/planner.ts +30 -62
- package/src/core/migrations/postgres-migration.ts +31 -0
- package/src/core/migrations/verify-postgres-namespaces.ts +0 -1
- package/src/core/postgres-role.ts +22 -0
- package/src/core/postgres-schema.ts +22 -1
- package/src/core/postgres-validators.ts +1 -0
- package/src/core/psl-infer/infer-psl-contract.ts +7 -16
- package/src/core/schema-ir/node-storage-coordinate.ts +26 -0
- package/src/core/schema-ir/postgres-database-schema-node.ts +5 -4
- package/src/core/schema-ir/postgres-namespace-schema-node.ts +18 -27
- package/src/core/schema-ir/postgres-native-enum-schema-node.ts +83 -0
- package/src/core/schema-ir/postgres-role-schema-node.ts +4 -2
- package/src/core/schema-ir/schema-node-kinds.ts +19 -3
- package/src/core/sql-utils.ts +15 -2
- package/src/exports/ddl.ts +2 -0
- package/src/exports/op-factory-call.ts +2 -0
- package/src/exports/sql-utils.ts +1 -0
- package/src/exports/types.ts +4 -1
- package/dist/authoring-WkqG_MkU.mjs.map +0 -1
- package/dist/control-policy-Co_13Hxa.mjs.map +0 -1
- package/dist/diff-database-schema-BOsDnH64.mjs.map +0 -1
- package/dist/nodes-B815pj_X.mjs.map +0 -1
- package/dist/nodes-BtQyZha6.d.mts.map +0 -1
- package/dist/op-factory-call-DxNNKUeZ.mjs.map +0 -1
- package/dist/planner-CNrc1Odu.mjs.map +0 -1
- package/dist/planner-ddl-builders-B8Nn6nHN.mjs.map +0 -1
- package/dist/postgres-database-schema-node-CfdTY-Qs.d.mts.map +0 -1
- package/dist/postgres-migration-Bzzi0Asr.d.mts.map +0 -1
- package/dist/postgres-migration-ChyRsWvE.mjs.map +0 -1
- package/dist/postgres-role-schema-node-BiSTCTNg.mjs.map +0 -1
- package/dist/postgres-schema-CU4gF6QZ.d.mts.map +0 -1
- package/dist/postgres-schema-DTLA_aRi.mjs.map +0 -1
- package/dist/postgres-table-schema-node-9FCtCUz2.mjs.map +0 -1
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import type { DiffableNode } from '@prisma-next/framework-components/control';
|
|
2
2
|
import { freezeNode } from '@prisma-next/framework-components/ir';
|
|
3
3
|
import { assertNode, SqlSchemaIRNode } from '@prisma-next/sql-schema-ir/types';
|
|
4
|
+
import type { PostgresNativeEnumSchemaNode } from './postgres-native-enum-schema-node';
|
|
4
5
|
import type { PostgresTableSchemaNode } from './postgres-table-schema-node';
|
|
5
6
|
import { PostgresSchemaNodeKind } from './schema-node-kinds';
|
|
6
7
|
|
|
7
|
-
/** One introspected native Postgres enum type, in `pg_enum.enumsortorder` (declaration) order. */
|
|
8
|
-
export interface PostgresNativeEnumIntrospection {
|
|
9
|
-
readonly typeName: string;
|
|
10
|
-
readonly values: readonly string[];
|
|
11
|
-
}
|
|
12
|
-
|
|
13
8
|
export interface PostgresNamespaceSchemaNodeInput {
|
|
14
9
|
readonly schemaName: string;
|
|
15
10
|
readonly tables: Readonly<Record<string, PostgresTableSchemaNode>>;
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
/**
|
|
12
|
+
* The native-enum diff nodes belonging to this namespace, member values in
|
|
13
|
+
* `pg_enum.enumsortorder` (declaration) order. The expected
|
|
14
|
+
* (contract-projected) side attaches each node's `control` (the contract
|
|
15
|
+
* entity's grade); introspection builds nodes with no `control`.
|
|
16
|
+
*/
|
|
17
|
+
readonly nativeEnums?: readonly PostgresNativeEnumSchemaNode[];
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
/**
|
|
@@ -22,38 +22,29 @@ export interface PostgresNamespaceSchemaNodeInput {
|
|
|
22
22
|
* single namespace. Per-schema consumers (the relational planner,
|
|
23
23
|
* toSchemaView) read this node's `tables` field structurally via
|
|
24
24
|
* `blindCast`/`SqlSchemaIRNode` — not through a static `SqlSchemaIR`
|
|
25
|
-
* assignment — because `nodeKind`
|
|
25
|
+
* assignment — because `nodeKind` carries this node's own literal
|
|
26
26
|
* (`postgres-namespace`), distinct from `SqlSchemaIR`'s own (`sql-schema`).
|
|
27
27
|
*
|
|
28
|
-
* `id` is the schema name
|
|
29
|
-
*
|
|
30
|
-
* nodes. Per-schema metadata is carried on the typed `nativeEnumTypeNames`
|
|
31
|
-
* field, not an annotations bag.
|
|
28
|
+
* `id` is the schema name; `isEqualTo` is identity on it; `children()` returns
|
|
29
|
+
* the table nodes plus `nativeEnums`.
|
|
32
30
|
*
|
|
33
|
-
* `nativeEnums`
|
|
34
|
-
*
|
|
35
|
-
* (
|
|
36
|
-
*
|
|
37
|
-
* hooks, the infer throw) so none of them need the values to keep working.
|
|
31
|
+
* `nativeEnums` is the diff-tree representation of native enum types the
|
|
32
|
+
* differ pairs — the sole enum carrier, built directly by both sides: the
|
|
33
|
+
* expected (contract-projected) side and introspection alike hand in
|
|
34
|
+
* `PostgresNativeEnumSchemaNode`s.
|
|
38
35
|
*/
|
|
39
36
|
export class PostgresNamespaceSchemaNode extends SqlSchemaIRNode implements DiffableNode {
|
|
40
37
|
override readonly nodeKind = PostgresSchemaNodeKind.namespace;
|
|
41
38
|
|
|
42
39
|
readonly schemaName: string;
|
|
43
40
|
readonly tables: Readonly<Record<string, PostgresTableSchemaNode>>;
|
|
44
|
-
readonly
|
|
45
|
-
readonly nativeEnums: readonly PostgresNativeEnumIntrospection[];
|
|
41
|
+
readonly nativeEnums: readonly PostgresNativeEnumSchemaNode[];
|
|
46
42
|
|
|
47
43
|
constructor(input: PostgresNamespaceSchemaNodeInput) {
|
|
48
44
|
super();
|
|
49
45
|
this.schemaName = input.schemaName;
|
|
50
46
|
this.tables = Object.freeze({ ...input.tables });
|
|
51
|
-
this.
|
|
52
|
-
this.nativeEnums = Object.freeze(
|
|
53
|
-
(input.nativeEnums ?? []).map((entry) =>
|
|
54
|
-
Object.freeze({ typeName: entry.typeName, values: Object.freeze([...entry.values]) }),
|
|
55
|
-
),
|
|
56
|
-
);
|
|
47
|
+
this.nativeEnums = Object.freeze([...(input.nativeEnums ?? [])]);
|
|
57
48
|
freezeNode(this);
|
|
58
49
|
}
|
|
59
50
|
|
|
@@ -66,7 +57,7 @@ export class PostgresNamespaceSchemaNode extends SqlSchemaIRNode implements Diff
|
|
|
66
57
|
}
|
|
67
58
|
|
|
68
59
|
children(): readonly DiffableNode[] {
|
|
69
|
-
return Object.values(this.tables);
|
|
60
|
+
return [...Object.values(this.tables), ...this.nativeEnums];
|
|
70
61
|
}
|
|
71
62
|
|
|
72
63
|
static is(node: SqlSchemaIRNode): node is PostgresNamespaceSchemaNode {
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { ControlPolicy } from '@prisma-next/contract/types';
|
|
2
|
+
import type { DiffableNode } from '@prisma-next/framework-components/control';
|
|
3
|
+
import { freezeNode } from '@prisma-next/framework-components/ir';
|
|
4
|
+
import { assertNode, SqlSchemaIRNode } from '@prisma-next/sql-schema-ir/types';
|
|
5
|
+
import { blindCast } from '@prisma-next/utils/casts';
|
|
6
|
+
import { PostgresSchemaNodeKind } from './schema-node-kinds';
|
|
7
|
+
|
|
8
|
+
export interface PostgresNativeEnumSchemaNodeInput {
|
|
9
|
+
/** The Postgres type name (`CREATE TYPE <typeName> AS ENUM (…)`). */
|
|
10
|
+
readonly typeName: string;
|
|
11
|
+
/** The owning DDL schema name — enum types are schema-scoped. */
|
|
12
|
+
readonly namespaceId: string;
|
|
13
|
+
/** Member values in declaration (`pg_enum.enumsortorder`) order. */
|
|
14
|
+
readonly members: readonly string[];
|
|
15
|
+
/** The contract entity's control grade — expected-side nodes only. */
|
|
16
|
+
readonly control?: ControlPolicy;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Schema-diff leaf node for a native Postgres enum type.
|
|
21
|
+
*
|
|
22
|
+
* This is a derived, transient node walked by the differ — it is NEVER
|
|
23
|
+
* serialized. Both sides derive it on the namespace node: the expected side
|
|
24
|
+
* from the contract's hydrated `entries.native_enum` entities, the actual
|
|
25
|
+
* side from the adapter's introspected `nativeEnums`.
|
|
26
|
+
*
|
|
27
|
+
* Enum types are schema-scoped, so identity is (namespace, type name): the
|
|
28
|
+
* namespace coordinate comes from tree position (the differ pairs enum nodes
|
|
29
|
+
* only inside an already-paired namespace) and `id` carries the type name,
|
|
30
|
+
* prefixed with the entries-kind vocabulary (`native_enum:<typeName>`) so it
|
|
31
|
+
* cannot collide with a sibling table of the same name — the same
|
|
32
|
+
* sibling-prefix convention relational column nodes use (`column:<name>`).
|
|
33
|
+
*
|
|
34
|
+
* `isEqualTo` compares members POSITIONALLY — `['a','b'] ≠ ['b','a']` —
|
|
35
|
+
* because Postgres enum sort order is semantic. `control` is contract
|
|
36
|
+
* metadata, not database state, and does not participate in equality.
|
|
37
|
+
*/
|
|
38
|
+
export class PostgresNativeEnumSchemaNode extends SqlSchemaIRNode implements DiffableNode {
|
|
39
|
+
override readonly nodeKind = PostgresSchemaNodeKind.nativeEnum;
|
|
40
|
+
|
|
41
|
+
readonly typeName: string;
|
|
42
|
+
readonly namespaceId: string;
|
|
43
|
+
readonly members: readonly string[];
|
|
44
|
+
declare readonly control?: ControlPolicy;
|
|
45
|
+
|
|
46
|
+
constructor(input: PostgresNativeEnumSchemaNodeInput) {
|
|
47
|
+
super();
|
|
48
|
+
this.typeName = input.typeName;
|
|
49
|
+
this.namespaceId = input.namespaceId;
|
|
50
|
+
this.members = Object.freeze([...input.members]);
|
|
51
|
+
if (input.control !== undefined) this.control = input.control;
|
|
52
|
+
freezeNode(this);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
get id(): string {
|
|
56
|
+
return `native_enum:${this.typeName}`;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
children(): readonly DiffableNode[] {
|
|
60
|
+
return [];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
isEqualTo(other: DiffableNode): boolean {
|
|
64
|
+
const node = blindCast<
|
|
65
|
+
SqlSchemaIRNode,
|
|
66
|
+
'every diff-tree node the differ pairs is a SqlSchemaIRNode; the guard rejects non-enum kinds'
|
|
67
|
+
>(other);
|
|
68
|
+
PostgresNativeEnumSchemaNode.assert(node);
|
|
69
|
+
return (
|
|
70
|
+
this.typeName === node.typeName &&
|
|
71
|
+
this.members.length === node.members.length &&
|
|
72
|
+
this.members.every((member, index) => member === node.members[index])
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
static is(node: SqlSchemaIRNode): node is PostgresNativeEnumSchemaNode {
|
|
77
|
+
return node.nodeKind === PostgresSchemaNodeKind.nativeEnum;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
static assert(node: SqlSchemaIRNode): asserts node is PostgresNativeEnumSchemaNode {
|
|
81
|
+
assertNode(node, 'PostgresNativeEnumSchemaNode', PostgresNativeEnumSchemaNode.is);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -20,8 +20,10 @@ export interface PostgresRoleSchemaNodeInput {
|
|
|
20
20
|
* Built by project-from-contract and project-from-database from their respective
|
|
21
21
|
* `PostgresRole` contract entities / introspected rows.
|
|
22
22
|
*
|
|
23
|
-
* Roles are cluster-scoped, so `id` is the role name
|
|
24
|
-
*
|
|
23
|
+
* Roles are cluster-scoped, so `id` is the bare role name. The differ pairs
|
|
24
|
+
* siblings by `(nodeKind, id)`, so a role and a namespace may share a name
|
|
25
|
+
* (role `public`, schema `public`) without colliding. `isEqualTo` compares
|
|
26
|
+
* ids — name-equality is role-equality for cluster-scoped objects.
|
|
25
27
|
*/
|
|
26
28
|
export class PostgresRoleSchemaNode extends SqlSchemaIRNode implements DiffableNode {
|
|
27
29
|
override readonly nodeKind = PostgresSchemaNodeKind.role;
|
|
@@ -29,6 +29,7 @@ export const PostgresSchemaNodeKind = {
|
|
|
29
29
|
table: 'postgres-table',
|
|
30
30
|
policy: 'postgres-policy',
|
|
31
31
|
role: 'postgres-role',
|
|
32
|
+
nativeEnum: 'postgres-native-enum',
|
|
32
33
|
} as const;
|
|
33
34
|
|
|
34
35
|
export type PostgresSchemaNodeKind =
|
|
@@ -45,8 +46,16 @@ const POSTGRES_NODE_GRANULARITY: Readonly<Record<PostgresSchemaNodeKind, DiffSub
|
|
|
45
46
|
[PostgresSchemaNodeKind.database]: 'structural',
|
|
46
47
|
[PostgresSchemaNodeKind.namespace]: 'namespace',
|
|
47
48
|
[PostgresSchemaNodeKind.table]: 'entity',
|
|
49
|
+
// A policy set is owned by the managed table it attaches to; a role is
|
|
50
|
+
// referenced by the contract but not owned (the framework names it in a
|
|
51
|
+
// policy but never owns the cluster's role list). Both classify as
|
|
52
|
+
// `structural`. The asymmetry for roles — a missing declared one fails, an
|
|
53
|
+
// undeclared live one is tolerated unconditionally — comes from the
|
|
54
|
+
// control policy the diff resolves a role issue against (`external`),
|
|
55
|
+
// not from the granularity.
|
|
48
56
|
[PostgresSchemaNodeKind.policy]: 'structural',
|
|
49
57
|
[PostgresSchemaNodeKind.role]: 'structural',
|
|
58
|
+
[PostgresSchemaNodeKind.nativeEnum]: 'entity',
|
|
50
59
|
};
|
|
51
60
|
|
|
52
61
|
function isPostgresSchemaNodeKind(nodeKind: string): nodeKind is PostgresSchemaNodeKind {
|
|
@@ -75,15 +84,22 @@ export function postgresDiffSubjectGranularity(nodeKind: string): DiffSubjectGra
|
|
|
75
84
|
}
|
|
76
85
|
|
|
77
86
|
/**
|
|
78
|
-
* The
|
|
79
|
-
*
|
|
80
|
-
*
|
|
87
|
+
* The map from a Postgres-specific `nodeKind` to its storage `entityKind` — the
|
|
88
|
+
* same vocabulary the contract storage's `entries` dictionary keys use. The
|
|
89
|
+
* whole-table and native-enum kinds each have an entity of their own;
|
|
81
90
|
* database/namespace/policy/role nodes map to nothing here (a namespace is
|
|
82
91
|
* addressed by id, not by an `entries` kind; policies and roles are
|
|
83
92
|
* structural, never a sibling space's unclaimed entity).
|
|
93
|
+
*
|
|
94
|
+
* The native enum keys under its PHYSICAL type name in `entries.native_enum`
|
|
95
|
+
* (ADR 221), so its diff node's `typeName` addresses the entity on the generic
|
|
96
|
+
* coordinate directly — no by-type-name walk needed. This lets the framework's
|
|
97
|
+
* unclaimed-elements sweep classify enum ownership the same coordinate way it
|
|
98
|
+
* classifies tables.
|
|
84
99
|
*/
|
|
85
100
|
const POSTGRES_NODE_ENTITY_KIND: Partial<Readonly<Record<PostgresSchemaNodeKind, string>>> = {
|
|
86
101
|
[PostgresSchemaNodeKind.table]: 'table',
|
|
102
|
+
[PostgresSchemaNodeKind.nativeEnum]: 'native_enum',
|
|
87
103
|
};
|
|
88
104
|
|
|
89
105
|
/** Looks up the storage entityKind for a Postgres-specific `nodeKind`. */
|
package/src/core/sql-utils.ts
CHANGED
|
@@ -81,6 +81,19 @@ export function qualifyName(schemaName: string, objectName: string): string {
|
|
|
81
81
|
return `${quoteIdentifier(schemaName)}.${quoteIdentifier(objectName)}`;
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
+
/**
|
|
85
|
+
* Quotes a possibly dot-qualified name segment-by-segment:
|
|
86
|
+
* `order_status` -> `"order_status"`, `auth.aal_level` -> `"auth"."aal_level"`.
|
|
87
|
+
* A single-segment name round-trips to exactly {@link quoteIdentifier}; whole-
|
|
88
|
+
* string quoting (`"auth.aal_level"`) would be one wrong identifier.
|
|
89
|
+
*/
|
|
90
|
+
export function quoteQualifiedName(name: string): string {
|
|
91
|
+
return name
|
|
92
|
+
.split('.')
|
|
93
|
+
.map((segment) => quoteIdentifier(segment))
|
|
94
|
+
.join('.');
|
|
95
|
+
}
|
|
96
|
+
|
|
84
97
|
/**
|
|
85
98
|
* Validates that an enum value doesn't exceed PostgreSQL's label length limit.
|
|
86
99
|
*
|
|
@@ -93,10 +106,10 @@ export function qualifyName(schemaName: string, objectName: string): string {
|
|
|
93
106
|
* @throws {SqlEscapeError} If the value exceeds the maximum length
|
|
94
107
|
*/
|
|
95
108
|
export function validateEnumValueLength(value: string, enumTypeName: string): void {
|
|
96
|
-
if (value.length > MAX_IDENTIFIER_LENGTH) {
|
|
109
|
+
if (new TextEncoder().encode(value).length > MAX_IDENTIFIER_LENGTH) {
|
|
97
110
|
throw new SqlEscapeError(
|
|
98
111
|
`Enum value "${value.slice(0, 20)}..." for type "${enumTypeName}" exceeds PostgreSQL's ` +
|
|
99
|
-
`${MAX_IDENTIFIER_LENGTH}-
|
|
112
|
+
`${MAX_IDENTIFIER_LENGTH}-byte label limit`,
|
|
100
113
|
value,
|
|
101
114
|
'literal',
|
|
102
115
|
);
|
package/src/exports/ddl.ts
CHANGED
|
@@ -9,9 +9,11 @@ export {
|
|
|
9
9
|
PostgresCreatePolicy,
|
|
10
10
|
PostgresCreateSchema,
|
|
11
11
|
PostgresCreateTable,
|
|
12
|
+
PostgresCreateType,
|
|
12
13
|
PostgresDdlNode,
|
|
13
14
|
type PostgresDdlVisitor,
|
|
14
15
|
PostgresDisableRowLevelSecurity,
|
|
15
16
|
PostgresDropPolicy,
|
|
17
|
+
PostgresDropType,
|
|
16
18
|
type RlsPolicyOperation,
|
|
17
19
|
} from '../core/ddl/nodes';
|
|
@@ -8,6 +8,7 @@ export {
|
|
|
8
8
|
AlterColumnTypeCall,
|
|
9
9
|
CreateExtensionCall,
|
|
10
10
|
CreateIndexCall,
|
|
11
|
+
CreateNativeEnumTypeCall,
|
|
11
12
|
CreateSchemaCall,
|
|
12
13
|
CreateTableCall,
|
|
13
14
|
DataTransformCall,
|
|
@@ -16,6 +17,7 @@ export {
|
|
|
16
17
|
DropConstraintCall,
|
|
17
18
|
DropDefaultCall,
|
|
18
19
|
DropIndexCall,
|
|
20
|
+
DropNativeEnumTypeCall,
|
|
19
21
|
DropNotNullCall,
|
|
20
22
|
DropTableCall,
|
|
21
23
|
RawSqlCall,
|
package/src/exports/sql-utils.ts
CHANGED
package/src/exports/types.ts
CHANGED
|
@@ -23,8 +23,11 @@ export {
|
|
|
23
23
|
export {
|
|
24
24
|
PostgresNamespaceSchemaNode,
|
|
25
25
|
type PostgresNamespaceSchemaNodeInput,
|
|
26
|
-
type PostgresNativeEnumIntrospection,
|
|
27
26
|
} from '../core/schema-ir/postgres-namespace-schema-node';
|
|
27
|
+
export {
|
|
28
|
+
PostgresNativeEnumSchemaNode,
|
|
29
|
+
type PostgresNativeEnumSchemaNodeInput,
|
|
30
|
+
} from '../core/schema-ir/postgres-native-enum-schema-node';
|
|
28
31
|
export {
|
|
29
32
|
PostgresPolicySchemaNode,
|
|
30
33
|
type PostgresPolicySchemaNodeInput,
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"authoring-WkqG_MkU.mjs","names":[],"sources":["../src/core/authoring.ts"],"sourcesContent":["import { temporalAuthoringPresets } from '@prisma-next/family-sql/control';\nimport type {\n AuthoringEntityContext,\n AuthoringEntityTypeFactoryOutput,\n AuthoringEntityTypeNamespace,\n AuthoringFieldNamespace,\n AuthoringModelAttributeContext,\n AuthoringModelAttributeDescriptorNamespace,\n AuthoringPslBlockDescriptorNamespace,\n AuthoringTypeNamespace,\n PslExtensionBlock,\n} from '@prisma-next/framework-components/authoring';\nimport { modelAttribute } from '@prisma-next/psl-parser';\nimport type { SqlValueSetDerivingEntityTypeOutput } from '@prisma-next/sql-contract/value-set-derivation-hook';\nimport { PG_ENUM_CODEC_ID } from './codec-ids';\nimport { PostgresNativeEnum } from './postgres-native-enum';\nimport { PostgresRlsEnablement, type PostgresRlsEnablementInput } from './postgres-rls-enablement';\nimport { PostgresRlsPolicy } from './postgres-rls-policy';\nimport { PostgresRole, type PostgresRoleInput } from './postgres-role';\nimport {\n PostgresNativeEnumSchema,\n PostgresRlsEnablementSchema,\n PostgresRlsPolicySchema,\n PostgresRoleSchema,\n} from './postgres-validators';\nimport { computeContentHash, normalizePredicate } from './rls/canonicalize';\nimport { formatRlsPolicyWireName } from './rls/wire-name';\n\n/**\n * `pg.enum(<ref>)` registers as an ordinary type constructor whose sole\n * positional argument names a `native_enum` entity instead of carrying a\n * literal value. The interpreter resolves the ref to the `native_enum`\n * entity generically (driven by `entityRefArg`); the `pg/enum@1` codec\n * descriptor's `columnFromEntity` hook (see `codecs.ts`) converts that\n * entity into the column's `typeParams` and native type.\n */\nexport const postgresAuthoringTypes = {\n pg: {\n enum: {\n kind: 'typeConstructor',\n entityRefArg: { index: 0, entityKind: 'native_enum' },\n output: {\n codecId: PG_ENUM_CODEC_ID,\n },\n },\n },\n} as const satisfies AuthoringTypeNamespace;\n\nexport interface RlsPolicyExtensionBlock extends PslExtensionBlock {\n readonly namespaceId: string;\n}\n\nfunction readRefParam(block: PslExtensionBlock, key: string): string | undefined {\n const param = block.parameters[key];\n return param?.kind === 'ref' ? param.identifier : undefined;\n}\n\nfunction readValueParam(block: PslExtensionBlock, key: string): string | undefined {\n const param = block.parameters[key];\n return param?.kind === 'value' ? param.raw : undefined;\n}\n\nfunction readListRefParams(block: PslExtensionBlock, key: string): string[] {\n const param = block.parameters[key];\n if (param?.kind !== 'list') return [];\n return param.items.flatMap((item) => (item.kind === 'ref' ? [item.identifier] : []));\n}\n\n/**\n * Unwraps a quoted PSL string argument, inverting the printer's\n * `escapePslString` escapes (`\\\\`, `\\\"`, `\\n`, `\\r`). An unknown escape\n * sequence is kept verbatim, matching the printer-side `unescapePslString`\n * convention.\n */\nfunction unwrapQuotedString(raw: string): string {\n if (!(raw.startsWith('\"') && raw.endsWith('\"') && raw.length >= 2)) {\n return raw;\n }\n const inner = raw.slice(1, -1);\n let result = '';\n for (let i = 0; i < inner.length; i++) {\n if (inner[i] !== '\\\\' || i + 1 >= inner.length) {\n result += inner[i];\n continue;\n }\n const next = inner[i + 1];\n if (next === '\\\\' || next === '\"') {\n result += next;\n } else if (next === 'n') {\n result += '\\n';\n } else if (next === 'r') {\n result += '\\r';\n } else {\n result += '\\\\';\n result += next;\n }\n i++;\n }\n return result;\n}\n\nfunction lowerRlsPolicyFromBlock(\n block: RlsPolicyExtensionBlock,\n _ctx: AuthoringEntityContext,\n): PostgresRlsPolicy {\n const prefix = block.name;\n const targetModelName = readRefParam(block, 'target') ?? '';\n const tableName = targetModelName.charAt(0).toLowerCase() + targetModelName.slice(1);\n const roles = [...readListRefParams(block, 'roles')].sort();\n const using = unwrapQuotedString(readValueParam(block, 'using') ?? '');\n\n const wireHash = computeContentHash({\n using: normalizePredicate(using),\n roles,\n operation: 'select',\n permissive: true,\n });\n const wireName = formatRlsPolicyWireName(prefix, wireHash);\n\n return new PostgresRlsPolicy({\n name: wireName,\n prefix,\n tableName,\n namespaceId: block.namespaceId,\n operation: 'select',\n roles,\n using,\n permissive: true,\n });\n}\n\n/**\n * Lowers a `native_enum { memberName = \"value\" … @@map(\"type_name\") }` block\n * into a {@link PostgresNativeEnum}. Members must be authored as explicit\n * `key = \"value\"` pairs — a bare (value-less) member is a diagnostic, not\n * accepted (authoring-design.md §2.1). The parsed `memberName` is only used\n * to duplicate-check and report diagnostics; the lowered entity carries just\n * the member values (a native enum is value-only — the member \"name\" isn't\n * a separate authoring concept from the value). `typeName` comes from\n * `@@map` or defaults to the block name verbatim.\n */\nfunction lowerNativeEnumFromBlock(\n block: PslExtensionBlock,\n ctx: AuthoringEntityContext,\n): PostgresNativeEnum | undefined {\n const sourceId = ctx.sourceId ?? 'unknown';\n const diagnostics = ctx.diagnostics;\n\n const mapAttr = block.blockAttributes.find((a) => a.name === 'map');\n let typeName = block.name;\n if (mapAttr) {\n const rawArg = mapAttr.args[0]?.value;\n const mapped = rawArg !== undefined ? unwrapQuotedString(rawArg) : undefined;\n if (mapped === undefined) {\n diagnostics?.push({\n code: 'PSL_NATIVE_ENUM_INVALID_MAP',\n message: `native_enum \"${block.name}\" @@map attribute must have a quoted type-name argument`,\n sourceId,\n span: mapAttr.span,\n });\n return undefined;\n }\n typeName = mapped;\n }\n\n let memberError = false;\n const seenValues = new Set<string>();\n const members: string[] = [];\n for (const [memberName, paramValue] of Object.entries(block.parameters)) {\n if (paramValue.kind === 'bare') {\n diagnostics?.push({\n code: 'PSL_NATIVE_ENUM_BARE_MEMBER',\n message: `native_enum \"${block.name}\" member \"${memberName}\" has no value; members must be authored as \"${memberName} = \\\\\"value\\\\\"\"`,\n sourceId,\n span: paramValue.span,\n });\n memberError = true;\n continue;\n }\n if (paramValue.kind !== 'value') continue;\n\n let jsonValue: unknown;\n try {\n jsonValue = JSON.parse(paramValue.raw);\n } catch {\n diagnostics?.push({\n code: 'PSL_EXTENSION_INVALID_VALUE',\n message: `native_enum \"${block.name}\" member \"${memberName}\" value \"${paramValue.raw}\" is not valid JSON`,\n sourceId,\n span: paramValue.span,\n });\n memberError = true;\n continue;\n }\n if (typeof jsonValue !== 'string') {\n diagnostics?.push({\n code: 'PSL_EXTENSION_INVALID_VALUE',\n message: `native_enum \"${block.name}\" member \"${memberName}\" value must be a string`,\n sourceId,\n span: paramValue.span,\n });\n memberError = true;\n continue;\n }\n if (seenValues.has(jsonValue)) {\n diagnostics?.push({\n code: 'PSL_NATIVE_ENUM_DUPLICATE_MEMBER_VALUE',\n message: `native_enum \"${block.name}\": duplicate member value \"${jsonValue}\"`,\n sourceId,\n span: paramValue.span,\n });\n memberError = true;\n continue;\n }\n seenValues.add(jsonValue);\n members.push(jsonValue);\n }\n\n if (memberError) return undefined;\n\n if (members.length === 0) {\n diagnostics?.push({\n code: 'PSL_NATIVE_ENUM_MISSING_MEMBERS',\n message: `native_enum \"${block.name}\" must have at least one member`,\n sourceId,\n span: block.span,\n });\n return undefined;\n }\n\n // `control` stays unset — the effective grade is resolved at read time via `effectiveControlPolicy`, like `StorageTable`/`StorageColumn`.\n return new PostgresNativeEnum({ typeName, members });\n}\n\n/**\n * `native_enum`'s entity-type factory output, checked separately from the assembled\n * `postgresAuthoringEntityTypes` map below: `deriveValueSet` is SQL-family surface\n * ({@link SqlValueSetDerivingEntityTypeOutput}), not part of the framework\n * `AuthoringEntityTypeFactoryOutput` shape, so folding it directly into the map's single\n * `satisfies AuthoringEntityTypeNamespace` check would trip an excess-property error. Checking it\n * here against the intersection of both shapes keeps it structurally valid against each without\n * widening the map's own check.\n */\nconst nativeEnumEntityTypeOutput = {\n factory: lowerNativeEnumFromBlock,\n deriveValueSet: (entity: PostgresNativeEnum) => ({\n kind: 'valueSet' as const,\n values: [...entity.members],\n }),\n} satisfies AuthoringEntityTypeFactoryOutput<PslExtensionBlock, PostgresNativeEnum | undefined> &\n SqlValueSetDerivingEntityTypeOutput;\n\nexport const postgresAuthoringEntityTypes = {\n role: {\n kind: 'entity',\n discriminator: 'role',\n validatorSchema: PostgresRoleSchema,\n output: {\n factory: (input: PostgresRoleInput): PostgresRole => new PostgresRole(input),\n },\n },\n rls: {\n kind: 'entity',\n discriminator: 'rls',\n validatorSchema: PostgresRlsEnablementSchema,\n output: {\n factory: (input: PostgresRlsEnablementInput): PostgresRlsEnablement =>\n new PostgresRlsEnablement(input),\n },\n },\n policy: {\n kind: 'entity',\n discriminator: 'policy',\n validatorSchema: PostgresRlsPolicySchema,\n output: {\n factory: lowerRlsPolicyFromBlock,\n },\n },\n native_enum: {\n kind: 'entity',\n discriminator: 'native_enum',\n validatorSchema: PostgresNativeEnumSchema,\n output: nativeEnumEntityTypeOutput,\n },\n} as const satisfies AuthoringEntityTypeNamespace;\n\n/**\n * Field presets contributed by the Postgres target pack.\n *\n * These mirror the PSL scalar-to-codec mapping used by the Postgres adapter\n * (see `createPostgresPslScalarTypeDescriptors`), so that authoring a field\n * via the TS callback surface (e.g. `field.int()`) and via the PSL scalar\n * surface (e.g. `Int`) lowers to byte-identical contracts.\n *\n * The `uuidNative` / `id.uuidv4Native` / `id.uuidv7Native` presets use the\n * native Postgres `uuid` type (codecId `pg/uuid@1`). For cross-target\n * portability use `uuidString` / `id.uuidv4String` / `id.uuidv7String` from\n * the family pack instead.\n */\n/**\n * PSL block descriptor for `policy_select`.\n *\n * The parser learns the block shape from this descriptor; lowering from\n * `PslExtensionBlock` to `PostgresRlsPolicy` is wired in the PSL\n * interpreter (a later dispatch). The `discriminator` matches\n * `PostgresRlsPolicy.kind` so the parsed block node carries the same\n * discriminant as the IR class it will lower to.\n *\n * The `roles` list uses `scope:'cross-space'` because same-namespace\n * role ref resolution requires PSL namespace entries keyed by `refKind`\n * (i.e. `'role'`), which in turn requires the role block discriminator to\n * equal `'role'`. Aligning discriminator with refKind is tracked for\n * slice 4 (cross-space roles). Until then cross-space passes validation\n * unconditionally and the authored role names flow through unchanged.\n */\nexport const postgresAuthoringPslBlockDescriptors = {\n policy_select: {\n kind: 'pslBlock',\n keyword: 'policy_select',\n discriminator: 'policy',\n name: { required: true },\n parameters: {\n target: { kind: 'ref', refKind: 'model', scope: 'same-namespace', required: true },\n roles: {\n kind: 'list',\n of: { kind: 'ref', refKind: 'role', scope: 'cross-space' },\n },\n using: { kind: 'value', codecId: 'pg/text@1', required: true },\n },\n // A policy may only target an RLS-controlled model: the model named by\n // `target` must declare `@@rls`, or the load fails with a diagnostic\n // naming the model and the policy prefix.\n requiresModelAttribute: { parameter: 'target', attribute: 'rls' },\n },\n /**\n * PSL block descriptor for `native_enum`.\n *\n * Reuses the existing variadic-block mechanism (the same shape the SQL\n * family's `enum` block ships): the body is an open `memberName = \"value\"`\n * list. `variadicParameters: true` opens the block to arbitrary keys\n * beyond the declared (empty) `parameters` set — the lowering factory\n * (`lowerNativeEnumFromBlock`) turns the variadic entries into ordered\n * members and rejects a bare (value-less) member.\n */\n native_enum: {\n kind: 'pslBlock',\n keyword: 'native_enum',\n discriminator: 'native_enum',\n name: { required: true },\n parameters: {},\n variadicParameters: true,\n },\n} as const satisfies AuthoringPslBlockDescriptorNamespace;\n\n/**\n * `@@` model attributes contributed by the Postgres target pack.\n *\n * `@@rls` is argument-less: presence marks the model's table\n * RLS-controlled. It lowers to a {@link PostgresRlsEnablement} marker in\n * the namespace's `entries.rls`, keyed by the model's table name — the\n * marker (never the policy set) is what drives\n * `ENABLE`/`DISABLE ROW LEVEL SECURITY` planning.\n */\nexport const postgresAuthoringModelAttributes = {\n rls: {\n kind: 'modelAttribute',\n attribute: 'rls',\n spec: modelAttribute('rls', {}),\n lower: (_parsed: Record<never, never>, ctx: AuthoringModelAttributeContext) => ({\n key: ctx.storageName,\n entity: new PostgresRlsEnablement({\n tableName: ctx.storageName,\n namespaceId: ctx.namespaceId,\n }),\n }),\n },\n} as const satisfies AuthoringModelAttributeDescriptorNamespace;\n\nexport const postgresAuthoringFieldPresets = {\n text: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/text@1',\n nativeType: 'text',\n },\n },\n int: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/int4@1',\n nativeType: 'int4',\n },\n },\n bigint: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/int8@1',\n nativeType: 'int8',\n },\n },\n float: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/float8@1',\n nativeType: 'float8',\n },\n },\n decimal: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/numeric@1',\n nativeType: 'numeric',\n },\n },\n boolean: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/bool@1',\n nativeType: 'bool',\n },\n },\n json: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/jsonb@1',\n nativeType: 'jsonb',\n },\n },\n bytes: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/bytea@1',\n nativeType: 'bytea',\n },\n },\n dateTime: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/timestamptz@1',\n nativeType: 'timestamptz',\n },\n },\n temporal: /* @__PURE__ */ temporalAuthoringPresets({\n codecId: 'pg/timestamptz@1',\n nativeType: 'timestamptz',\n }),\n uuidNative: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/uuid@1',\n nativeType: 'uuid',\n },\n },\n id: {\n uuidv4Native: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/uuid@1',\n nativeType: 'uuid',\n executionDefaults: {\n onCreate: {\n kind: 'generator',\n id: 'uuidv4',\n },\n },\n id: true,\n },\n },\n uuidv7Native: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/uuid@1',\n nativeType: 'uuid',\n executionDefaults: {\n onCreate: {\n kind: 'generator',\n id: 'uuidv7',\n },\n },\n id: true,\n },\n },\n },\n} as const satisfies AuthoringFieldNamespace;\n"],"mappings":";;;;;;;;;;;;;;;AAoCA,MAAa,yBAAyB,EACpC,IAAI,EACF,MAAM;CACJ,MAAM;CACN,cAAc;EAAE,OAAO;EAAG,YAAY;CAAc;CACpD,QAAQ,EACN,SAAS,iBACX;AACF,EACF,EACF;AAMA,SAAS,aAAa,OAA0B,KAAiC;CAC/E,MAAM,QAAQ,MAAM,WAAW;CAC/B,OAAO,OAAO,SAAS,QAAQ,MAAM,aAAa,KAAA;AACpD;AAEA,SAAS,eAAe,OAA0B,KAAiC;CACjF,MAAM,QAAQ,MAAM,WAAW;CAC/B,OAAO,OAAO,SAAS,UAAU,MAAM,MAAM,KAAA;AAC/C;AAEA,SAAS,kBAAkB,OAA0B,KAAuB;CAC1E,MAAM,QAAQ,MAAM,WAAW;CAC/B,IAAI,OAAO,SAAS,QAAQ,OAAO,CAAC;CACpC,OAAO,MAAM,MAAM,SAAS,SAAU,KAAK,SAAS,QAAQ,CAAC,KAAK,UAAU,IAAI,CAAC,CAAE;AACrF;;;;;;;AAQA,SAAS,mBAAmB,KAAqB;CAC/C,IAAI,EAAE,IAAI,WAAW,IAAG,KAAK,IAAI,SAAS,IAAG,KAAK,IAAI,UAAU,IAC9D,OAAO;CAET,MAAM,QAAQ,IAAI,MAAM,GAAG,EAA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