@prisma-next/target-postgres 0.14.0-dev.49 → 0.14.0-dev.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/control-policy-DUFgy9jO.mjs +1103 -0
- package/dist/control-policy-DUFgy9jO.mjs.map +1 -0
- package/dist/control.d.mts.map +1 -1
- package/dist/control.mjs +19 -40
- package/dist/control.mjs.map +1 -1
- package/dist/default-normalizer.mjs +247 -1
- package/dist/default-normalizer.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 +34 -10
- package/dist/issue-planner.d.mts.map +1 -1
- package/dist/issue-planner.mjs +2 -2
- package/dist/migration.d.mts +2 -2
- package/dist/migration.mjs +2 -2
- package/dist/native-type-normalizer.mjs +37 -1
- package/dist/native-type-normalizer.mjs.map +1 -0
- package/dist/{op-factory-call-BuoGT5UI.mjs → op-factory-call-BKRnMgrB.mjs} +2 -2
- package/dist/op-factory-call-BKRnMgrB.mjs.map +1 -0
- package/dist/{op-factory-call-Caqus-Qg.d.mts → op-factory-call-Dt-Jx5JS.d.mts} +2 -2
- package/dist/{op-factory-call-Caqus-Qg.d.mts.map → op-factory-call-Dt-Jx5JS.d.mts.map} +1 -1
- package/dist/op-factory-call.d.mts +2 -2
- package/dist/op-factory-call.mjs +2 -2
- package/dist/planner-BMBRPzsv.mjs +367 -0
- package/dist/planner-BMBRPzsv.mjs.map +1 -0
- package/dist/planner-ddl-builders-B8Nn6nHN.mjs.map +1 -1
- package/dist/planner-ddl-builders.d.mts +2 -2
- package/dist/planner-ddl-builders.d.mts.map +1 -1
- package/dist/planner-identity-values-CJPha2Sz.mjs.map +1 -1
- package/dist/planner-identity-values.d.mts +7 -1
- package/dist/planner-identity-values.d.mts.map +1 -1
- package/dist/planner-identity-values.mjs +2 -2
- package/dist/{planner-produced-postgres-migration-CtJi4sgS.d.mts → planner-produced-postgres-migration-C0a7I1-e.d.mts} +2 -2
- package/dist/{planner-produced-postgres-migration-CtJi4sgS.d.mts.map → planner-produced-postgres-migration-C0a7I1-e.d.mts.map} +1 -1
- package/dist/{planner-produced-postgres-migration-C2_H6Vvl.mjs → planner-produced-postgres-migration-Dp6IO_gj.mjs} +2 -2
- package/dist/{planner-produced-postgres-migration-C2_H6Vvl.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-Cze3vMfe.mjs.map +1 -1
- package/dist/planner-sql-checks.d.mts +1 -1
- package/dist/planner-sql-checks.d.mts.map +1 -1
- package/dist/planner.d.mts +27 -67
- package/dist/planner.d.mts.map +1 -1
- package/dist/planner.mjs +3 -2
- package/dist/{postgres-database-schema-node-os8ogEap.d.mts → postgres-database-schema-node-C9bTuMrd.d.mts} +14 -7
- package/dist/postgres-database-schema-node-C9bTuMrd.d.mts.map +1 -0
- package/dist/{postgres-migration-D0QIVE-p.mjs → postgres-migration-D0jwzYDT.mjs} +2 -2
- package/dist/{postgres-migration-D0QIVE-p.mjs.map → postgres-migration-D0jwzYDT.mjs.map} +1 -1
- package/dist/{postgres-migration-CfyKDT7b.d.mts → postgres-migration-DFaxuRyI.d.mts} +2 -2
- package/dist/{postgres-migration-CfyKDT7b.d.mts.map → postgres-migration-DFaxuRyI.d.mts.map} +1 -1
- package/dist/{postgres-table-schema-node-Clei_xel.mjs → postgres-table-schema-node-BgaSrxYN.mjs} +30 -29
- package/dist/postgres-table-schema-node-BgaSrxYN.mjs.map +1 -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 +1 -1
- package/dist/types.mjs +1 -1
- package/package.json +21 -20
- package/src/core/migrations/column-ddl-rendering.ts +117 -0
- package/src/core/migrations/contract-to-postgres-database-schema-node.ts +25 -1
- package/src/core/migrations/control-policy.ts +68 -48
- package/src/core/migrations/diff-database-schema.ts +242 -153
- package/src/core/migrations/issue-planner.ts +621 -667
- package/src/core/migrations/operations/constraints.ts +1 -1
- package/src/core/migrations/planner-ddl-builders.ts +5 -2
- package/src/core/migrations/planner-identity-values.ts +1 -1
- package/src/core/migrations/planner-sql-checks.ts +1 -1
- package/src/core/migrations/planner-strategies.ts +248 -208
- package/src/core/migrations/planner.ts +180 -74
- package/src/core/migrations/runner.ts +1 -4
- package/src/core/migrations/verify-postgres-namespaces.ts +26 -15
- package/src/core/postgres-schema-verifier.ts +10 -7
- package/src/core/psl-infer/infer-psl-contract.ts +5 -10
- package/src/core/schema-ir/postgres-database-schema-node.ts +3 -6
- package/src/core/schema-ir/postgres-namespace-schema-node.ts +8 -9
- package/src/core/schema-ir/postgres-policy-schema-node.ts +3 -6
- package/src/core/schema-ir/postgres-role-schema-node.ts +3 -6
- package/src/core/schema-ir/postgres-table-schema-node.ts +20 -9
- package/src/core/schema-ir/schema-node-kinds.ts +80 -2
- package/src/exports/control.ts +10 -43
- package/src/exports/diff-database-schema.ts +7 -0
- package/src/exports/issue-planner.ts +1 -1
- package/src/exports/op-factory-call.ts +1 -0
- package/src/exports/planner-identity-values.ts +4 -1
- package/src/exports/planner.ts +0 -1
- package/dist/default-normalizer-Dug8Fez9.mjs +0 -248
- package/dist/default-normalizer-Dug8Fez9.mjs.map +0 -1
- package/dist/issue-planner-Cbh-xTEr.mjs +0 -849
- package/dist/issue-planner-Cbh-xTEr.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/op-factory-call-BuoGT5UI.mjs.map +0 -1
- package/dist/planner-Bq0Z2sVO.mjs +0 -641
- package/dist/planner-Bq0Z2sVO.mjs.map +0 -1
- package/dist/postgres-database-schema-node-os8ogEap.d.mts.map +0 -1
- package/dist/postgres-table-schema-node-Clei_xel.mjs.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { DiffableNode } from '@prisma-next/framework-components/control';
|
|
2
2
|
import { freezeNode } from '@prisma-next/framework-components/ir';
|
|
3
|
-
import { SqlSchemaIRNode } from '@prisma-next/sql-schema-ir/types';
|
|
3
|
+
import { assertNode, SqlSchemaIRNode } from '@prisma-next/sql-schema-ir/types';
|
|
4
4
|
import { blindCast } from '@prisma-next/utils/casts';
|
|
5
5
|
import { PostgresSchemaNodeKind } from './schema-node-kinds';
|
|
6
6
|
|
|
@@ -25,6 +25,7 @@ export interface PostgresRoleSchemaNodeInput {
|
|
|
25
25
|
*/
|
|
26
26
|
export class PostgresRoleSchemaNode extends SqlSchemaIRNode implements DiffableNode {
|
|
27
27
|
override readonly nodeKind = PostgresSchemaNodeKind.role;
|
|
28
|
+
|
|
28
29
|
readonly name: string;
|
|
29
30
|
readonly namespaceId: string;
|
|
30
31
|
|
|
@@ -57,10 +58,6 @@ export class PostgresRoleSchemaNode extends SqlSchemaIRNode implements DiffableN
|
|
|
57
58
|
}
|
|
58
59
|
|
|
59
60
|
static assert(node: SqlSchemaIRNode): asserts node is PostgresRoleSchemaNode {
|
|
60
|
-
|
|
61
|
-
throw new Error(
|
|
62
|
-
`Expected a PostgresRoleSchemaNode but got nodeKind=${node.nodeKind ?? 'undefined'}`,
|
|
63
|
-
);
|
|
64
|
-
}
|
|
61
|
+
assertNode(node, 'PostgresRoleSchemaNode', PostgresRoleSchemaNode.is);
|
|
65
62
|
}
|
|
66
63
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { DiffableNode } from '@prisma-next/framework-components/control';
|
|
2
2
|
import { freezeNode } from '@prisma-next/framework-components/ir';
|
|
3
3
|
import {
|
|
4
|
+
assertNode,
|
|
4
5
|
PrimaryKey,
|
|
5
6
|
type SqlAnnotations,
|
|
6
7
|
SqlCheckConstraintIR,
|
|
@@ -27,12 +28,18 @@ export interface PostgresTableSchemaNodeInput extends SqlTableIRInput {
|
|
|
27
28
|
* `SqlTableIR` calls `freezeNode` in its own constructor, which prevents
|
|
28
29
|
* subclass field initialisation.
|
|
29
30
|
*
|
|
30
|
-
* `id` is the table name. `
|
|
31
|
-
*
|
|
32
|
-
*
|
|
31
|
+
* `id` is the table name. `isEqualTo` is identity — two table nodes are equal
|
|
32
|
+
* iff their ids (names) match; the table's own structural drift is entirely
|
|
33
|
+
* expressed by its children. `children()` returns every column, the primary
|
|
34
|
+
* key (when present), every foreign key, unique, index, and check constraint,
|
|
35
|
+
* plus the policy nodes — one flat list, so a drifted column and a drifted
|
|
36
|
+
* policy are both reported by the same walk. Order is deterministic (object
|
|
37
|
+
* key order for columns, array order for the rest) so two structurally equal
|
|
38
|
+
* tables always produce the same child list.
|
|
33
39
|
*/
|
|
34
40
|
export class PostgresTableSchemaNode extends SqlSchemaIRNode implements DiffableNode {
|
|
35
41
|
override readonly nodeKind = PostgresSchemaNodeKind.table;
|
|
42
|
+
|
|
36
43
|
readonly name: string;
|
|
37
44
|
readonly columns: Readonly<Record<string, SqlColumnIR>>;
|
|
38
45
|
readonly foreignKeys: ReadonlyArray<SqlForeignKeyIR>;
|
|
@@ -90,7 +97,15 @@ export class PostgresTableSchemaNode extends SqlSchemaIRNode implements Diffable
|
|
|
90
97
|
}
|
|
91
98
|
|
|
92
99
|
children(): readonly DiffableNode[] {
|
|
93
|
-
return
|
|
100
|
+
return [
|
|
101
|
+
...Object.values(this.columns),
|
|
102
|
+
...(this.primaryKey ? [this.primaryKey] : []),
|
|
103
|
+
...this.foreignKeys,
|
|
104
|
+
...this.uniques,
|
|
105
|
+
...this.indexes,
|
|
106
|
+
...(this.checks ?? []),
|
|
107
|
+
...this.policies,
|
|
108
|
+
];
|
|
94
109
|
}
|
|
95
110
|
|
|
96
111
|
static is(node: SqlSchemaIRNode): node is PostgresTableSchemaNode {
|
|
@@ -98,10 +113,6 @@ export class PostgresTableSchemaNode extends SqlSchemaIRNode implements Diffable
|
|
|
98
113
|
}
|
|
99
114
|
|
|
100
115
|
static assert(node: SqlSchemaIRNode): asserts node is PostgresTableSchemaNode {
|
|
101
|
-
|
|
102
|
-
throw new Error(
|
|
103
|
-
`Expected a PostgresTableSchemaNode but got nodeKind=${node.nodeKind ?? 'undefined'}`,
|
|
104
|
-
);
|
|
105
|
-
}
|
|
116
|
+
assertNode(node, 'PostgresTableSchemaNode', PostgresTableSchemaNode.is);
|
|
106
117
|
}
|
|
107
118
|
}
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type {
|
|
2
|
+
DiffableNode,
|
|
3
|
+
DiffSubjectGranularity,
|
|
4
|
+
} from '@prisma-next/framework-components/control';
|
|
5
|
+
import {
|
|
6
|
+
relationalNodeEntityKind,
|
|
7
|
+
relationalNodeGranularity,
|
|
8
|
+
type SqlSchemaIRNode,
|
|
9
|
+
} from '@prisma-next/sql-schema-ir/types';
|
|
3
10
|
|
|
4
11
|
/**
|
|
5
12
|
* A Postgres schema-diff-tree node: a `SqlSchemaIRNode` that also implements
|
|
@@ -26,3 +33,74 @@ export const PostgresSchemaNodeKind = {
|
|
|
26
33
|
|
|
27
34
|
export type PostgresSchemaNodeKind =
|
|
28
35
|
(typeof PostgresSchemaNodeKind)[keyof typeof PostgresSchemaNodeKind];
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The one real map from a Postgres-specific `nodeKind` to the
|
|
39
|
+
* framework-neutral {@link DiffSubjectGranularity} its diff issues carry —
|
|
40
|
+
* resolution is by `nodeKind` equality against this map, never a
|
|
41
|
+
* `nodeKind`-suffix string match and never anything stamped on the node.
|
|
42
|
+
*/
|
|
43
|
+
const POSTGRES_NODE_GRANULARITY: Readonly<Record<PostgresSchemaNodeKind, DiffSubjectGranularity>> =
|
|
44
|
+
{
|
|
45
|
+
[PostgresSchemaNodeKind.database]: 'structural',
|
|
46
|
+
[PostgresSchemaNodeKind.namespace]: 'namespace',
|
|
47
|
+
[PostgresSchemaNodeKind.table]: 'entity',
|
|
48
|
+
[PostgresSchemaNodeKind.policy]: 'structural',
|
|
49
|
+
[PostgresSchemaNodeKind.role]: 'structural',
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
function isPostgresSchemaNodeKind(nodeKind: string): nodeKind is PostgresSchemaNodeKind {
|
|
53
|
+
return Object.hasOwn(POSTGRES_NODE_GRANULARITY, nodeKind);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Looks up the subject granularity for a Postgres-specific `nodeKind`. */
|
|
57
|
+
export function postgresNodeGranularity(nodeKind: PostgresSchemaNodeKind): DiffSubjectGranularity {
|
|
58
|
+
return POSTGRES_NODE_GRANULARITY[nodeKind];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* The subject granularity for any node kind that appears in a Postgres diff
|
|
63
|
+
* tree — the tree mixes Postgres-specific kinds (database/namespace/table/
|
|
64
|
+
* policy/role) with the relational leaf kinds (columns, constraints, indexes,
|
|
65
|
+
* …), so this dispatches to whichever family/target map owns the kind. Called
|
|
66
|
+
* on demand by consumers (the family verdict, the framework aggregate's
|
|
67
|
+
* unclaimed-elements sweep, via the {@link
|
|
68
|
+
* import('@prisma-next/framework-components/control').SchemaSubjectClassifierCapable}
|
|
69
|
+
* capability) — never stamped onto the issue or the node.
|
|
70
|
+
*/
|
|
71
|
+
export function postgresDiffSubjectGranularity(nodeKind: string): DiffSubjectGranularity {
|
|
72
|
+
return isPostgresSchemaNodeKind(nodeKind)
|
|
73
|
+
? postgresNodeGranularity(nodeKind)
|
|
74
|
+
: relationalNodeGranularity(nodeKind);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* The one real map from a Postgres-specific `nodeKind` to its storage
|
|
79
|
+
* `entityKind` — the same vocabulary the contract storage's `entries`
|
|
80
|
+
* dictionary keys use. Only the whole-table kind has an entity of its own;
|
|
81
|
+
* database/namespace/policy/role nodes map to nothing here (a namespace is
|
|
82
|
+
* addressed by id, not by an `entries` kind; policies and roles are
|
|
83
|
+
* structural, never a sibling space's unclaimed entity).
|
|
84
|
+
*/
|
|
85
|
+
const POSTGRES_NODE_ENTITY_KIND: Partial<Readonly<Record<PostgresSchemaNodeKind, string>>> = {
|
|
86
|
+
[PostgresSchemaNodeKind.table]: 'table',
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
/** Looks up the storage entityKind for a Postgres-specific `nodeKind`. */
|
|
90
|
+
export function postgresNodeEntityKind(nodeKind: PostgresSchemaNodeKind): string | undefined {
|
|
91
|
+
return POSTGRES_NODE_ENTITY_KIND[nodeKind];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* The storage `entityKind` for any node kind that appears in a Postgres diff
|
|
96
|
+
* tree — sibling of {@link postgresDiffSubjectGranularity}, dispatching the
|
|
97
|
+
* same way to whichever family/target map owns the kind. Called on demand by
|
|
98
|
+
* the framework aggregate's unclaimed-elements sweep via the {@link
|
|
99
|
+
* import('@prisma-next/framework-components/control').SchemaSubjectClassifierCapable}
|
|
100
|
+
* capability — never stamped onto the issue or the node.
|
|
101
|
+
*/
|
|
102
|
+
export function postgresDiffSubjectEntityKind(nodeKind: string): string | undefined {
|
|
103
|
+
return isPostgresSchemaNodeKind(nodeKind)
|
|
104
|
+
? postgresNodeEntityKind(nodeKind)
|
|
105
|
+
: relationalNodeEntityKind(nodeKind);
|
|
106
|
+
}
|
package/src/exports/control.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { ColumnDefault } from '@prisma-next/contract/types';
|
|
2
2
|
import type { SqlControlTargetDescriptor } from '@prisma-next/family-sql/control';
|
|
3
|
-
import {
|
|
3
|
+
import { buildNativeTypeExpander } from '@prisma-next/family-sql/control';
|
|
4
4
|
import type { SqlControlAdapter } from '@prisma-next/family-sql/control-adapter';
|
|
5
|
-
import type { TargetBoundComponentDescriptor } from '@prisma-next/framework-components/components';
|
|
6
5
|
import type {
|
|
7
6
|
ControlTargetInstance,
|
|
8
7
|
MigrationRunner,
|
|
@@ -12,10 +11,7 @@ import { blindCast } from '@prisma-next/utils/casts';
|
|
|
12
11
|
import { ifDefined } from '@prisma-next/utils/defined';
|
|
13
12
|
import { postgresTargetDescriptorMeta } from '../core/descriptor-meta';
|
|
14
13
|
import { contractToPostgresDatabaseSchemaNode } from '../core/migrations/contract-to-postgres-database-schema-node';
|
|
15
|
-
import {
|
|
16
|
-
diffPostgresDatabaseSchema,
|
|
17
|
-
verifyPostgresDatabaseSchema,
|
|
18
|
-
} from '../core/migrations/diff-database-schema';
|
|
14
|
+
import { diffPostgresSchema } from '../core/migrations/diff-database-schema';
|
|
19
15
|
import { createPostgresMigrationPlanner } from '../core/migrations/planner';
|
|
20
16
|
import { renderDefaultLiteral } from '../core/migrations/planner-ddl-builders';
|
|
21
17
|
import type { PostgresPlanTargetDetails } from '../core/migrations/planner-target-details';
|
|
@@ -25,26 +21,10 @@ import type { PostgresContract } from '../core/postgres-schema';
|
|
|
25
21
|
import { PostgresSchemaVerifier } from '../core/postgres-schema-verifier';
|
|
26
22
|
import { inferPostgresPslContract } from '../core/psl-infer/infer-psl-contract';
|
|
27
23
|
import { PostgresDatabaseSchemaNode } from '../core/schema-ir/postgres-database-schema-node';
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
if (!frameworkComponents) {
|
|
33
|
-
return undefined;
|
|
34
|
-
}
|
|
35
|
-
const codecHooks = extractCodecControlHooks(frameworkComponents);
|
|
36
|
-
return (input: {
|
|
37
|
-
readonly nativeType: string;
|
|
38
|
-
readonly codecId?: string;
|
|
39
|
-
readonly typeParams?: Record<string, unknown>;
|
|
40
|
-
}) => {
|
|
41
|
-
if (!input.typeParams) return input.nativeType;
|
|
42
|
-
if (!input.codecId) return input.nativeType;
|
|
43
|
-
const hooks = codecHooks.get(input.codecId);
|
|
44
|
-
if (!hooks?.expandNativeType) return input.nativeType;
|
|
45
|
-
return hooks.expandNativeType(input);
|
|
46
|
-
};
|
|
47
|
-
}
|
|
24
|
+
import {
|
|
25
|
+
postgresDiffSubjectEntityKind,
|
|
26
|
+
postgresDiffSubjectGranularity,
|
|
27
|
+
} from '../core/schema-ir/schema-node-kinds';
|
|
48
28
|
|
|
49
29
|
export function postgresRenderDefault(def: ColumnDefault, column: StorageColumn): string {
|
|
50
30
|
if (def.kind === 'function') {
|
|
@@ -62,24 +42,11 @@ const postgresTargetDescriptor: SqlControlTargetDescriptor<'postgres', PostgresP
|
|
|
62
42
|
PostgresDatabaseSchemaNode.assert(schema);
|
|
63
43
|
return inferPostgresPslContract(schema, describedContracts);
|
|
64
44
|
},
|
|
65
|
-
|
|
66
|
-
return
|
|
67
|
-
contract: input.contract,
|
|
68
|
-
actualSchema: input.schema,
|
|
69
|
-
strict: input.strict,
|
|
70
|
-
typeMetadataRegistry: input.typeMetadataRegistry,
|
|
71
|
-
frameworkComponents: input.frameworkComponents,
|
|
72
|
-
});
|
|
73
|
-
},
|
|
74
|
-
verifyDatabaseSchema(input) {
|
|
75
|
-
return verifyPostgresDatabaseSchema({
|
|
76
|
-
contract: input.contract,
|
|
77
|
-
actualSchema: input.schema,
|
|
78
|
-
strict: input.strict,
|
|
79
|
-
typeMetadataRegistry: input.typeMetadataRegistry,
|
|
80
|
-
frameworkComponents: input.frameworkComponents,
|
|
81
|
-
});
|
|
45
|
+
diffSchema(input) {
|
|
46
|
+
return diffPostgresSchema(input);
|
|
82
47
|
},
|
|
48
|
+
classifySubjectGranularity: postgresDiffSubjectGranularity,
|
|
49
|
+
classifyEntityKind: postgresDiffSubjectEntityKind,
|
|
83
50
|
migrations: {
|
|
84
51
|
createPlanner(adapter: SqlControlAdapter<'postgres'>) {
|
|
85
52
|
return createPostgresMigrationPlanner(adapter);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Own entry point (rather than folded into `exports/planner.ts`) because
|
|
3
|
+
* cross-package tests need `buildPostgresPlanDiff` as a public import to
|
|
4
|
+
* drive the one-differ path directly — they cannot reach it via a relative
|
|
5
|
+
* `src` import.
|
|
6
|
+
*/
|
|
7
|
+
export { buildPostgresPlanDiff } from '../core/migrations/diff-database-schema';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { planIssues } from '../core/migrations/issue-planner';
|
|
1
|
+
export { coalesceSubtreeIssues, planIssues } from '../core/migrations/issue-planner';
|
package/src/exports/planner.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
export { contractToPostgresDatabaseSchemaNode } from '../core/migrations/contract-to-postgres-database-schema-node';
|
|
2
|
-
export { diffPostgresDatabaseSchema } from '../core/migrations/diff-database-schema';
|
|
3
2
|
export { createPostgresMigrationPlanner } from '../core/migrations/planner';
|
|
@@ -1,248 +0,0 @@
|
|
|
1
|
-
//#region src/core/default-normalizer.ts
|
|
2
|
-
/**
|
|
3
|
-
* Pre-compiled regex patterns for performance.
|
|
4
|
-
* These are compiled once at module load time rather than on each function call.
|
|
5
|
-
*/
|
|
6
|
-
const NEXTVAL_PATTERN = /^nextval\s*\(/i;
|
|
7
|
-
const NOW_FUNCTION_PATTERN = /^(now\s*\(\s*\)|CURRENT_TIMESTAMP)$/i;
|
|
8
|
-
const CLOCK_TIMESTAMP_PATTERN = /^clock_timestamp\s*\(\s*\)$/i;
|
|
9
|
-
const TIMESTAMP_CAST_SUFFIX = /::timestamp(?:tz|\s+(?:with|without)\s+time\s+zone)?$/i;
|
|
10
|
-
const TEXT_CAST_SUFFIX = /::text$/i;
|
|
11
|
-
const NOW_LITERAL_PATTERN = /^'now'$/i;
|
|
12
|
-
const UUID_PATTERN = /^gen_random_uuid\s*\(\s*\)$/i;
|
|
13
|
-
const UUID_OSSP_PATTERN = /^uuid_generate_v4\s*\(\s*\)$/i;
|
|
14
|
-
const NULL_PATTERN = /^NULL(?:::.+)?$/i;
|
|
15
|
-
const TRUE_PATTERN = /^true$/i;
|
|
16
|
-
const FALSE_PATTERN = /^false$/i;
|
|
17
|
-
const NUMERIC_PATTERN = /^-?\d+(\.\d+)?$/;
|
|
18
|
-
const STRING_LITERAL_PATTERN = /^'((?:[^']|'')*)'(?:::(?:"[^"]+"|[\w\s]+)(?:\(\d+\))?)?$/;
|
|
19
|
-
/**
|
|
20
|
-
* Matches a Postgres array literal default of the form `'{...}'::elemtype[]`.
|
|
21
|
-
* The literal body is captured in group 1; the cast (including `[]`) is optional.
|
|
22
|
-
* Examples: `'{}'::text[]`, `'{1,2}'::integer[]`, `'{}'`
|
|
23
|
-
*/
|
|
24
|
-
const ARRAY_LITERAL_PATTERN = /^'(\{.*\})'(?:::.+\[\])?$/;
|
|
25
|
-
/**
|
|
26
|
-
* Returns the canonical expression for a timestamp default function, or undefined
|
|
27
|
-
* if the expression is not a recognized timestamp default.
|
|
28
|
-
*
|
|
29
|
-
* Keeps now()/CURRENT_TIMESTAMP and clock_timestamp() distinct:
|
|
30
|
-
* - now(), CURRENT_TIMESTAMP, ('now'::text)::timestamp... → 'now()'
|
|
31
|
-
* - clock_timestamp(), clock_timestamp()::timestamptz → 'clock_timestamp()'
|
|
32
|
-
*
|
|
33
|
-
* These are semantically different in Postgres: now() returns the transaction
|
|
34
|
-
* start time (constant within a transaction), while clock_timestamp() returns
|
|
35
|
-
* the actual wall-clock time (can differ across rows in a single INSERT).
|
|
36
|
-
*/
|
|
37
|
-
function canonicalizeTimestampDefault(expr) {
|
|
38
|
-
if (NOW_FUNCTION_PATTERN.test(expr)) return "now()";
|
|
39
|
-
if (CLOCK_TIMESTAMP_PATTERN.test(expr)) return "clock_timestamp()";
|
|
40
|
-
if (!TIMESTAMP_CAST_SUFFIX.test(expr)) return void 0;
|
|
41
|
-
let inner = expr.replace(TIMESTAMP_CAST_SUFFIX, "").trim();
|
|
42
|
-
if (inner.startsWith("(") && inner.endsWith(")")) inner = inner.slice(1, -1).trim();
|
|
43
|
-
if (NOW_FUNCTION_PATTERN.test(inner)) return "now()";
|
|
44
|
-
if (CLOCK_TIMESTAMP_PATTERN.test(inner)) return "clock_timestamp()";
|
|
45
|
-
inner = inner.replace(TEXT_CAST_SUFFIX, "").trim();
|
|
46
|
-
if (NOW_LITERAL_PATTERN.test(inner)) return "now()";
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Splits a Postgres array literal body (without the enclosing braces) into its
|
|
50
|
-
* element tokens, honouring quoting. A comma only separates elements when it is
|
|
51
|
-
* outside double quotes; inside a quoted element a doubled quote (`""`) or a
|
|
52
|
-
* backslash-escaped quote (`\"`) is a literal quote, and a backslash escapes the
|
|
53
|
-
* next character. Returns undefined if the body is malformed (e.g. an unbalanced
|
|
54
|
-
* quote).
|
|
55
|
-
*/
|
|
56
|
-
function splitArrayElements(inner) {
|
|
57
|
-
const tokens = [];
|
|
58
|
-
let current = "";
|
|
59
|
-
let inQuotes = false;
|
|
60
|
-
let quoted = false;
|
|
61
|
-
for (let i = 0; i < inner.length; i++) {
|
|
62
|
-
const char = inner[i];
|
|
63
|
-
if (inQuotes) {
|
|
64
|
-
if (char === "\\") {
|
|
65
|
-
const next = inner[i + 1];
|
|
66
|
-
if (next === void 0) return void 0;
|
|
67
|
-
current += next;
|
|
68
|
-
i++;
|
|
69
|
-
continue;
|
|
70
|
-
}
|
|
71
|
-
if (char === "\"") {
|
|
72
|
-
if (inner[i + 1] === "\"") {
|
|
73
|
-
current += "\"";
|
|
74
|
-
i++;
|
|
75
|
-
continue;
|
|
76
|
-
}
|
|
77
|
-
inQuotes = false;
|
|
78
|
-
continue;
|
|
79
|
-
}
|
|
80
|
-
current += char;
|
|
81
|
-
continue;
|
|
82
|
-
}
|
|
83
|
-
if (char === "\"") {
|
|
84
|
-
inQuotes = true;
|
|
85
|
-
quoted = true;
|
|
86
|
-
continue;
|
|
87
|
-
}
|
|
88
|
-
if (char === ",") {
|
|
89
|
-
tokens.push({
|
|
90
|
-
value: current,
|
|
91
|
-
quoted
|
|
92
|
-
});
|
|
93
|
-
current = "";
|
|
94
|
-
quoted = false;
|
|
95
|
-
continue;
|
|
96
|
-
}
|
|
97
|
-
current += char;
|
|
98
|
-
}
|
|
99
|
-
if (inQuotes) return void 0;
|
|
100
|
-
tokens.push({
|
|
101
|
-
value: current,
|
|
102
|
-
quoted
|
|
103
|
-
});
|
|
104
|
-
return tokens;
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Parses a Postgres array literal body (`{...}`) into a JS array of primitives.
|
|
108
|
-
* Returns undefined if the body cannot be reliably parsed.
|
|
109
|
-
*
|
|
110
|
-
* Handles:
|
|
111
|
-
* - `{}` → `[]`
|
|
112
|
-
* - `{elem1,elem2,...}` → `[elem1, elem2, ...]` with numeric and string element coercion
|
|
113
|
-
* - quoted elements that contain commas, doubled/escaped quotes, and the literal
|
|
114
|
-
* strings `NULL`/`true`/`false` (a quoted token is always a string)
|
|
115
|
-
*/
|
|
116
|
-
function parseArrayLiteralBody(body) {
|
|
117
|
-
const inner = body.slice(1, -1).trim();
|
|
118
|
-
if (inner === "") return [];
|
|
119
|
-
const tokens = splitArrayElements(inner);
|
|
120
|
-
if (tokens === void 0) return void 0;
|
|
121
|
-
const result = [];
|
|
122
|
-
for (const token of tokens) {
|
|
123
|
-
if (token.quoted) {
|
|
124
|
-
result.push(token.value);
|
|
125
|
-
continue;
|
|
126
|
-
}
|
|
127
|
-
const el = token.value.trim();
|
|
128
|
-
if (el.toUpperCase() === "NULL") {
|
|
129
|
-
result.push(null);
|
|
130
|
-
continue;
|
|
131
|
-
}
|
|
132
|
-
if (el === "true") {
|
|
133
|
-
result.push(true);
|
|
134
|
-
continue;
|
|
135
|
-
}
|
|
136
|
-
if (el === "false") {
|
|
137
|
-
result.push(false);
|
|
138
|
-
continue;
|
|
139
|
-
}
|
|
140
|
-
if (NUMERIC_PATTERN.test(el)) {
|
|
141
|
-
result.push(Number(el));
|
|
142
|
-
continue;
|
|
143
|
-
}
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
return result;
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* Parses a raw Postgres column default expression into a normalized ColumnDefault.
|
|
150
|
-
* This enables semantic comparison between contract defaults and introspected schema defaults.
|
|
151
|
-
*
|
|
152
|
-
* Used by the migration diff layer to normalize raw database defaults during comparison,
|
|
153
|
-
* keeping the introspection layer focused on faithful data capture.
|
|
154
|
-
*
|
|
155
|
-
* @param rawDefault - Raw default expression from information_schema.columns.column_default
|
|
156
|
-
* @param nativeType - Native column type, used for type-aware parsing (array, bigint, JSON)
|
|
157
|
-
* @returns Normalized ColumnDefault or undefined if the expression cannot be parsed
|
|
158
|
-
*/
|
|
159
|
-
function parsePostgresDefault(rawDefault, nativeType) {
|
|
160
|
-
const trimmed = rawDefault.trim();
|
|
161
|
-
const normalizedType = nativeType?.toLowerCase();
|
|
162
|
-
const isBigInt = normalizedType === "bigint" || normalizedType === "int8";
|
|
163
|
-
const isArrayType = normalizedType?.endsWith("[]") ?? false;
|
|
164
|
-
if (NEXTVAL_PATTERN.test(trimmed)) return {
|
|
165
|
-
kind: "function",
|
|
166
|
-
expression: "autoincrement()"
|
|
167
|
-
};
|
|
168
|
-
if (isArrayType) {
|
|
169
|
-
const arrayMatch = trimmed.match(ARRAY_LITERAL_PATTERN);
|
|
170
|
-
if (arrayMatch?.[1] !== void 0) {
|
|
171
|
-
const parsed = parseArrayLiteralBody(arrayMatch[1]);
|
|
172
|
-
if (parsed !== void 0) return {
|
|
173
|
-
kind: "literal",
|
|
174
|
-
value: parsed
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
const canonicalTimestamp = canonicalizeTimestampDefault(trimmed);
|
|
179
|
-
if (canonicalTimestamp) return {
|
|
180
|
-
kind: "function",
|
|
181
|
-
expression: canonicalTimestamp
|
|
182
|
-
};
|
|
183
|
-
if (UUID_PATTERN.test(trimmed)) return {
|
|
184
|
-
kind: "function",
|
|
185
|
-
expression: "gen_random_uuid()"
|
|
186
|
-
};
|
|
187
|
-
if (UUID_OSSP_PATTERN.test(trimmed)) return {
|
|
188
|
-
kind: "function",
|
|
189
|
-
expression: "gen_random_uuid()"
|
|
190
|
-
};
|
|
191
|
-
if (NULL_PATTERN.test(trimmed)) return {
|
|
192
|
-
kind: "literal",
|
|
193
|
-
value: null
|
|
194
|
-
};
|
|
195
|
-
if (TRUE_PATTERN.test(trimmed)) return {
|
|
196
|
-
kind: "literal",
|
|
197
|
-
value: true
|
|
198
|
-
};
|
|
199
|
-
if (FALSE_PATTERN.test(trimmed)) return {
|
|
200
|
-
kind: "literal",
|
|
201
|
-
value: false
|
|
202
|
-
};
|
|
203
|
-
if (NUMERIC_PATTERN.test(trimmed)) {
|
|
204
|
-
const num = Number(trimmed);
|
|
205
|
-
if (!Number.isFinite(num)) return void 0;
|
|
206
|
-
if (isBigInt && !Number.isSafeInteger(num)) return {
|
|
207
|
-
kind: "literal",
|
|
208
|
-
value: trimmed
|
|
209
|
-
};
|
|
210
|
-
return {
|
|
211
|
-
kind: "literal",
|
|
212
|
-
value: num
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
|
-
const stringMatch = trimmed.match(STRING_LITERAL_PATTERN);
|
|
216
|
-
if (stringMatch?.[1] !== void 0) {
|
|
217
|
-
const unescaped = stringMatch[1].replace(/''/g, "'");
|
|
218
|
-
if (normalizedType === "json" || normalizedType === "jsonb") try {
|
|
219
|
-
return {
|
|
220
|
-
kind: "literal",
|
|
221
|
-
value: JSON.parse(unescaped)
|
|
222
|
-
};
|
|
223
|
-
} catch {}
|
|
224
|
-
if (isBigInt && NUMERIC_PATTERN.test(unescaped)) {
|
|
225
|
-
const num = Number(unescaped);
|
|
226
|
-
if (Number.isSafeInteger(num)) return {
|
|
227
|
-
kind: "literal",
|
|
228
|
-
value: num
|
|
229
|
-
};
|
|
230
|
-
return {
|
|
231
|
-
kind: "literal",
|
|
232
|
-
value: unescaped
|
|
233
|
-
};
|
|
234
|
-
}
|
|
235
|
-
return {
|
|
236
|
-
kind: "literal",
|
|
237
|
-
value: unescaped
|
|
238
|
-
};
|
|
239
|
-
}
|
|
240
|
-
return {
|
|
241
|
-
kind: "function",
|
|
242
|
-
expression: trimmed
|
|
243
|
-
};
|
|
244
|
-
}
|
|
245
|
-
//#endregion
|
|
246
|
-
export { parsePostgresDefault as t };
|
|
247
|
-
|
|
248
|
-
//# sourceMappingURL=default-normalizer-Dug8Fez9.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"default-normalizer-Dug8Fez9.mjs","names":[],"sources":["../src/core/default-normalizer.ts"],"sourcesContent":["import type { ColumnDefault, JsonValue } from '@prisma-next/contract/types';\n\n/**\n * Pre-compiled regex patterns for performance.\n * These are compiled once at module load time rather than on each function call.\n */\nconst NEXTVAL_PATTERN = /^nextval\\s*\\(/i;\nconst NOW_FUNCTION_PATTERN = /^(now\\s*\\(\\s*\\)|CURRENT_TIMESTAMP)$/i;\nconst CLOCK_TIMESTAMP_PATTERN = /^clock_timestamp\\s*\\(\\s*\\)$/i;\nconst TIMESTAMP_CAST_SUFFIX = /::timestamp(?:tz|\\s+(?:with|without)\\s+time\\s+zone)?$/i;\nconst TEXT_CAST_SUFFIX = /::text$/i;\nconst NOW_LITERAL_PATTERN = /^'now'$/i;\nconst UUID_PATTERN = /^gen_random_uuid\\s*\\(\\s*\\)$/i;\nconst UUID_OSSP_PATTERN = /^uuid_generate_v4\\s*\\(\\s*\\)$/i;\nconst NULL_PATTERN = /^NULL(?:::.+)?$/i;\nconst TRUE_PATTERN = /^true$/i;\nconst FALSE_PATTERN = /^false$/i;\nconst NUMERIC_PATTERN = /^-?\\d+(\\.\\d+)?$/;\nconst STRING_LITERAL_PATTERN = /^'((?:[^']|'')*)'(?:::(?:\"[^\"]+\"|[\\w\\s]+)(?:\\(\\d+\\))?)?$/;\n\n/**\n * Matches a Postgres array literal default of the form `'{...}'::elemtype[]`.\n * The literal body is captured in group 1; the cast (including `[]`) is optional.\n * Examples: `'{}'::text[]`, `'{1,2}'::integer[]`, `'{}'`\n */\nconst ARRAY_LITERAL_PATTERN = /^'(\\{.*\\})'(?:::.+\\[\\])?$/;\n\n/**\n * Returns the canonical expression for a timestamp default function, or undefined\n * if the expression is not a recognized timestamp default.\n *\n * Keeps now()/CURRENT_TIMESTAMP and clock_timestamp() distinct:\n * - now(), CURRENT_TIMESTAMP, ('now'::text)::timestamp... → 'now()'\n * - clock_timestamp(), clock_timestamp()::timestamptz → 'clock_timestamp()'\n *\n * These are semantically different in Postgres: now() returns the transaction\n * start time (constant within a transaction), while clock_timestamp() returns\n * the actual wall-clock time (can differ across rows in a single INSERT).\n */\nfunction canonicalizeTimestampDefault(expr: string): string | undefined {\n if (NOW_FUNCTION_PATTERN.test(expr)) return 'now()';\n if (CLOCK_TIMESTAMP_PATTERN.test(expr)) return 'clock_timestamp()';\n\n if (!TIMESTAMP_CAST_SUFFIX.test(expr)) return undefined;\n\n let inner = expr.replace(TIMESTAMP_CAST_SUFFIX, '').trim();\n\n if (inner.startsWith('(') && inner.endsWith(')')) {\n inner = inner.slice(1, -1).trim();\n }\n\n if (NOW_FUNCTION_PATTERN.test(inner)) return 'now()';\n if (CLOCK_TIMESTAMP_PATTERN.test(inner)) return 'clock_timestamp()';\n\n inner = inner.replace(TEXT_CAST_SUFFIX, '').trim();\n if (NOW_LITERAL_PATTERN.test(inner)) return 'now()';\n\n return undefined;\n}\n\ntype ArrayElementToken = { readonly value: string; readonly quoted: boolean };\n\n/**\n * Splits a Postgres array literal body (without the enclosing braces) into its\n * element tokens, honouring quoting. A comma only separates elements when it is\n * outside double quotes; inside a quoted element a doubled quote (`\"\"`) or a\n * backslash-escaped quote (`\\\"`) is a literal quote, and a backslash escapes the\n * next character. Returns undefined if the body is malformed (e.g. an unbalanced\n * quote).\n */\nfunction splitArrayElements(inner: string): readonly ArrayElementToken[] | undefined {\n const tokens: ArrayElementToken[] = [];\n let current = '';\n let inQuotes = false;\n let quoted = false;\n\n for (let i = 0; i < inner.length; i++) {\n const char = inner[i];\n if (inQuotes) {\n if (char === '\\\\') {\n const next = inner[i + 1];\n if (next === undefined) return undefined;\n current += next;\n i++;\n continue;\n }\n if (char === '\"') {\n if (inner[i + 1] === '\"') {\n current += '\"';\n i++;\n continue;\n }\n inQuotes = false;\n continue;\n }\n current += char;\n continue;\n }\n if (char === '\"') {\n inQuotes = true;\n quoted = true;\n continue;\n }\n if (char === ',') {\n tokens.push({ value: current, quoted });\n current = '';\n quoted = false;\n continue;\n }\n current += char;\n }\n\n if (inQuotes) return undefined;\n tokens.push({ value: current, quoted });\n return tokens;\n}\n\n/**\n * Parses a Postgres array literal body (`{...}`) into a JS array of primitives.\n * Returns undefined if the body cannot be reliably parsed.\n *\n * Handles:\n * - `{}` → `[]`\n * - `{elem1,elem2,...}` → `[elem1, elem2, ...]` with numeric and string element coercion\n * - quoted elements that contain commas, doubled/escaped quotes, and the literal\n * strings `NULL`/`true`/`false` (a quoted token is always a string)\n */\nfunction parseArrayLiteralBody(body: string): readonly JsonValue[] | undefined {\n const inner = body.slice(1, -1).trim();\n if (inner === '') return [];\n const tokens = splitArrayElements(inner);\n if (tokens === undefined) return undefined;\n const result: JsonValue[] = [];\n for (const token of tokens) {\n if (token.quoted) {\n // A quoted token is always a string — `\"NULL\"`, `\"true\"`, `\"1\"` are the\n // literal text, never the keyword/number.\n result.push(token.value);\n continue;\n }\n const el = token.value.trim();\n if (el.toUpperCase() === 'NULL') {\n result.push(null);\n continue;\n }\n if (el === 'true') {\n result.push(true);\n continue;\n }\n if (el === 'false') {\n result.push(false);\n continue;\n }\n if (NUMERIC_PATTERN.test(el)) {\n result.push(Number(el));\n continue;\n }\n return undefined;\n }\n return result;\n}\n\n/**\n * Parses a raw Postgres column default expression into a normalized ColumnDefault.\n * This enables semantic comparison between contract defaults and introspected schema defaults.\n *\n * Used by the migration diff layer to normalize raw database defaults during comparison,\n * keeping the introspection layer focused on faithful data capture.\n *\n * @param rawDefault - Raw default expression from information_schema.columns.column_default\n * @param nativeType - Native column type, used for type-aware parsing (array, bigint, JSON)\n * @returns Normalized ColumnDefault or undefined if the expression cannot be parsed\n */\nexport function parsePostgresDefault(\n rawDefault: string,\n nativeType?: string,\n): ColumnDefault | undefined {\n const trimmed = rawDefault.trim();\n const normalizedType = nativeType?.toLowerCase();\n const isBigInt = normalizedType === 'bigint' || normalizedType === 'int8';\n const isArrayType = normalizedType?.endsWith('[]') ?? false;\n\n if (NEXTVAL_PATTERN.test(trimmed)) {\n return { kind: 'function', expression: 'autoincrement()' };\n }\n\n if (isArrayType) {\n const arrayMatch = trimmed.match(ARRAY_LITERAL_PATTERN);\n if (arrayMatch?.[1] !== undefined) {\n const parsed = parseArrayLiteralBody(arrayMatch[1]);\n if (parsed !== undefined) {\n return { kind: 'literal', value: parsed };\n }\n }\n }\n\n const canonicalTimestamp = canonicalizeTimestampDefault(trimmed);\n if (canonicalTimestamp) {\n return { kind: 'function', expression: canonicalTimestamp };\n }\n\n if (UUID_PATTERN.test(trimmed)) {\n return { kind: 'function', expression: 'gen_random_uuid()' };\n }\n\n if (UUID_OSSP_PATTERN.test(trimmed)) {\n return { kind: 'function', expression: 'gen_random_uuid()' };\n }\n\n if (NULL_PATTERN.test(trimmed)) {\n return { kind: 'literal', value: null };\n }\n\n if (TRUE_PATTERN.test(trimmed)) {\n return { kind: 'literal', value: true };\n }\n if (FALSE_PATTERN.test(trimmed)) {\n return { kind: 'literal', value: false };\n }\n\n if (NUMERIC_PATTERN.test(trimmed)) {\n const num = Number(trimmed);\n if (!Number.isFinite(num)) return undefined;\n if (isBigInt && !Number.isSafeInteger(num)) {\n return { kind: 'literal', value: trimmed };\n }\n return { kind: 'literal', value: num };\n }\n\n const stringMatch = trimmed.match(STRING_LITERAL_PATTERN);\n if (stringMatch?.[1] !== undefined) {\n const unescaped = stringMatch[1].replace(/''/g, \"'\");\n if (normalizedType === 'json' || normalizedType === 'jsonb') {\n try {\n return { kind: 'literal', value: JSON.parse(unescaped) };\n } catch {\n // Keep legacy behavior for malformed/non-JSON string content.\n }\n }\n if (isBigInt && NUMERIC_PATTERN.test(unescaped)) {\n const num = Number(unescaped);\n if (Number.isSafeInteger(num)) {\n return { kind: 'literal', value: num };\n }\n return { kind: 'literal', value: unescaped };\n }\n return { kind: 'literal', value: unescaped };\n }\n\n return { kind: 'function', expression: trimmed };\n}\n"],"mappings":";;;;;AAMA,MAAM,kBAAkB;AACxB,MAAM,uBAAuB;AAC7B,MAAM,0BAA0B;AAChC,MAAM,wBAAwB;AAC9B,MAAM,mBAAmB;AACzB,MAAM,sBAAsB;AAC5B,MAAM,eAAe;AACrB,MAAM,oBAAoB;AAC1B,MAAM,eAAe;AACrB,MAAM,eAAe;AACrB,MAAM,gBAAgB;AACtB,MAAM,kBAAkB;AACxB,MAAM,yBAAyB;;;;;;AAO/B,MAAM,wBAAwB;;;;;;;;;;;;;AAc9B,SAAS,6BAA6B,MAAkC;CACtE,IAAI,qBAAqB,KAAK,IAAI,GAAG,OAAO;CAC5C,IAAI,wBAAwB,KAAK,IAAI,GAAG,OAAO;CAE/C,IAAI,CAAC,sBAAsB,KAAK,IAAI,GAAG,OAAO,KAAA;CAE9C,IAAI,QAAQ,KAAK,QAAQ,uBAAuB,EAAE,CAAC,CAAC,KAAK;CAEzD,IAAI,MAAM,WAAW,GAAG,KAAK,MAAM,SAAS,GAAG,GAC7C,QAAQ,MAAM,MAAM,GAAG,EAAE,CAAC,CAAC,KAAK;CAGlC,IAAI,qBAAqB,KAAK,KAAK,GAAG,OAAO;CAC7C,IAAI,wBAAwB,KAAK,KAAK,GAAG,OAAO;CAEhD,QAAQ,MAAM,QAAQ,kBAAkB,EAAE,CAAC,CAAC,KAAK;CACjD,IAAI,oBAAoB,KAAK,KAAK,GAAG,OAAO;AAG9C;;;;;;;;;AAYA,SAAS,mBAAmB,OAAyD;CACnF,MAAM,SAA8B,CAAC;CACrC,IAAI,UAAU;CACd,IAAI,WAAW;CACf,IAA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