@prisma-next/family-sql 0.14.0-dev.9 → 0.14.0-dev.90
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-type-constructors-CjFfO6LM.mjs → authoring-type-constructors-CXd-8ydc.mjs} +7 -30
- package/dist/authoring-type-constructors-CXd-8ydc.mjs.map +1 -0
- package/dist/{control-adapter-Cmw9LvEP.d.mts → control-adapter-BQgad8Zc.d.mts} +30 -8
- package/dist/control-adapter-BQgad8Zc.d.mts.map +1 -0
- package/dist/control-adapter.d.mts +1 -1
- package/dist/control.d.mts +279 -34
- package/dist/control.d.mts.map +1 -1
- package/dist/control.mjs +378 -1005
- package/dist/control.mjs.map +1 -1
- package/dist/diff.d.mts +102 -0
- package/dist/diff.d.mts.map +1 -0
- package/dist/diff.mjs +14 -0
- package/dist/diff.mjs.map +1 -0
- package/dist/foreign-key-index-backing-BP71iI-Q.mjs +32 -0
- package/dist/foreign-key-index-backing-BP71iI-Q.mjs.map +1 -0
- package/dist/ir.d.mts +26 -9
- package/dist/ir.d.mts.map +1 -1
- package/dist/ir.mjs +2 -2
- package/dist/ir.mjs.map +1 -1
- package/dist/migration.d.mts +11 -2
- package/dist/migration.d.mts.map +1 -1
- package/dist/migration.mjs +7 -0
- package/dist/migration.mjs.map +1 -1
- package/dist/pack.mjs +1 -1
- package/dist/psl-infer.d.mts +119 -0
- package/dist/psl-infer.d.mts.map +1 -0
- package/dist/psl-infer.mjs +366 -0
- package/dist/psl-infer.mjs.map +1 -0
- package/dist/schema-differ-DnoopSXm.d.mts +45 -0
- package/dist/schema-differ-DnoopSXm.d.mts.map +1 -0
- package/dist/schema-verify-W3r631Jh.mjs +226 -0
- package/dist/schema-verify-W3r631Jh.mjs.map +1 -0
- package/dist/{sql-contract-serializer-BR2vC7Z-.mjs → sql-contract-serializer-C75cfMSS.mjs} +46 -20
- package/dist/sql-contract-serializer-C75cfMSS.mjs.map +1 -0
- package/dist/{types-kgstZ_Zd.d.mts → types-BPv_y7iS.d.mts} +36 -142
- package/dist/types-BPv_y7iS.d.mts.map +1 -0
- package/package.json +26 -26
- package/src/core/authoring-entity-types.ts +12 -37
- package/src/core/control-adapter.ts +11 -5
- package/src/core/control-instance.ts +212 -42
- package/src/core/control-target-descriptor.ts +98 -0
- package/src/core/diff/schema-verify.ts +324 -0
- package/src/core/diff/sql-schema-diff.ts +41 -0
- package/src/core/diff/verifier-disposition.ts +30 -0
- package/src/core/foreign-key-index-backing.ts +37 -0
- package/src/core/ir/sql-contract-serializer-base.ts +70 -56
- package/src/core/ir/sql-contract-serializer.ts +5 -7
- package/src/core/ir/sql-schema-verifier-base.ts +5 -5
- package/src/core/migrations/contract-to-schema-ir.ts +141 -37
- package/src/core/migrations/control-policy.ts +66 -115
- package/src/core/migrations/field-event-planner.ts +2 -2
- package/src/core/migrations/native-type-expander.ts +28 -0
- package/src/core/migrations/schema-differ.ts +41 -0
- package/src/core/migrations/types.ts +33 -37
- package/src/core/psl-contract-infer/name-transforms.ts +15 -0
- package/src/core/psl-contract-infer/printer-config.ts +14 -6
- package/src/core/psl-contract-infer/relation-inference.ts +27 -1
- package/src/core/sql-migration.ts +12 -1
- package/src/exports/control.ts +12 -2
- package/src/exports/diff.ts +25 -0
- package/src/exports/psl-infer.ts +40 -0
- package/dist/authoring-type-constructors-CjFfO6LM.mjs.map +0 -1
- package/dist/control-adapter-Cmw9LvEP.d.mts.map +0 -1
- package/dist/schema-verify.d.mts +0 -39
- package/dist/schema-verify.d.mts.map +0 -1
- package/dist/schema-verify.mjs +0 -2
- package/dist/sql-contract-serializer-BR2vC7Z-.mjs.map +0 -1
- package/dist/test-utils.d.mts +0 -2
- package/dist/test-utils.mjs +0 -2
- package/dist/types-kgstZ_Zd.d.mts.map +0 -1
- package/dist/verify-sql-schema-thU-jKpf.d.mts +0 -66
- package/dist/verify-sql-schema-thU-jKpf.d.mts.map +0 -1
- package/dist/verify-sql-schema-xT4udQLQ.mjs +0 -1501
- package/dist/verify-sql-schema-xT4udQLQ.mjs.map +0 -1
- package/src/core/psl-contract-infer/postgres-default-mapping.ts +0 -16
- package/src/core/psl-contract-infer/postgres-type-map.ts +0 -157
- package/src/core/psl-contract-infer/sql-schema-ir-to-psl-ast.ts +0 -795
- package/src/core/schema-verify/control-verify-emit.ts +0 -46
- package/src/core/schema-verify/verifier-disposition.ts +0 -58
- package/src/core/schema-verify/verify-helpers.ts +0 -820
- package/src/core/schema-verify/verify-sql-schema.ts +0 -1311
- package/src/exports/schema-verify.ts +0 -18
- package/src/exports/test-utils.ts +0 -9
|
@@ -1,123 +1,13 @@
|
|
|
1
|
-
import { r as SqlControlAdapter } from "./control-adapter-
|
|
2
|
-
import {
|
|
3
|
-
import { SqlControlDriverInstance, SqlStorage, StorageColumn, StorageTable, StorageTypeInstance } from "@prisma-next/sql-contract/types";
|
|
4
|
-
import { PslDocumentAst } from "@prisma-next/framework-components/psl-ast";
|
|
1
|
+
import { r as SqlControlAdapter } from "./control-adapter-BQgad8Zc.mjs";
|
|
2
|
+
import { ContractSpace, ControlAdapterDescriptor, ControlExtensionDescriptor, MigrationOperationPolicy, MigrationPlan, MigrationPlanOperation, MigrationPlannerConflict, MigrationPlannerFailureResult, MigrationPlannerSuccessResult, MigrationRunnerExecutionChecks, MigrationRunnerFailure, MigrationRunnerPerSpaceSuccessValue, MigrationRunnerResult, OpFactoryCall, OperationContext, SchemaDiffIssue, SchemaOwnership } from "@prisma-next/framework-components/control";
|
|
5
3
|
import { Contract } from "@prisma-next/contract/types";
|
|
4
|
+
import { SqlControlDriverInstance, SqlStorage, StorageColumn, StorageTable, StorageTypeInstance } from "@prisma-next/sql-contract/types";
|
|
5
|
+
import { SqlSchemaIRNode } from "@prisma-next/sql-schema-ir/types";
|
|
6
6
|
import { Result } from "@prisma-next/utils/result";
|
|
7
|
-
import { AnyQueryAst, DdlNode, LowererContext, SqlExecuteRequest } from "@prisma-next/sql-relational-core/ast";
|
|
8
|
-
import { SqlSchemaIR } from "@prisma-next/sql-schema-ir/types";
|
|
9
7
|
import { TargetBoundComponentDescriptor } from "@prisma-next/framework-components/components";
|
|
10
|
-
import { TypesImportSpec } from "@prisma-next/framework-components/emission";
|
|
11
8
|
import { AggregateMigrationEdgeRef } from "@prisma-next/migration-tools/aggregate";
|
|
12
9
|
import { SqlOperationDescriptors } from "@prisma-next/sql-operations";
|
|
13
10
|
|
|
14
|
-
//#region src/core/control-instance.d.ts
|
|
15
|
-
interface SqlTypeMetadata {
|
|
16
|
-
readonly typeId: string;
|
|
17
|
-
readonly familyId: 'sql';
|
|
18
|
-
readonly targetId: string;
|
|
19
|
-
readonly nativeType?: string;
|
|
20
|
-
}
|
|
21
|
-
type SqlTypeMetadataRegistry = Map<string, SqlTypeMetadata>;
|
|
22
|
-
interface SqlFamilyInstanceState {
|
|
23
|
-
readonly codecTypeImports: ReadonlyArray<TypesImportSpec>;
|
|
24
|
-
readonly extensionIds: ReadonlyArray<string>;
|
|
25
|
-
readonly typeMetadataRegistry: SqlTypeMetadataRegistry;
|
|
26
|
-
}
|
|
27
|
-
interface SqlControlFamilyInstance extends ControlFamilyInstance<'sql', SqlSchemaIR>, SchemaViewCapable<SqlSchemaIR>, PslContractInferCapable<SqlSchemaIR>, OperationPreviewCapable, SqlFamilyInstanceState {
|
|
28
|
-
/**
|
|
29
|
-
* The family seam-of-record for on-disk contract reads. Structurally
|
|
30
|
-
* validates the JSON envelope, then hydrates IR-class instances via
|
|
31
|
-
* the per-target ContractSerializer. The single named entry point
|
|
32
|
-
* every CLI on-disk read crosses (TML-2536) — `as Contract` casts
|
|
33
|
-
* in production package sources are a serializer-bypass smell guarded
|
|
34
|
-
* by `pnpm lint:no-contract-cast`.
|
|
35
|
-
*/
|
|
36
|
-
deserializeContract(contractJson: unknown): Contract;
|
|
37
|
-
verify(options: {
|
|
38
|
-
readonly driver: SqlControlDriverInstance<string>;
|
|
39
|
-
readonly contract: unknown;
|
|
40
|
-
readonly expectedTargetId: string;
|
|
41
|
-
readonly contractPath: string;
|
|
42
|
-
readonly configPath?: string;
|
|
43
|
-
}): Promise<VerifyDatabaseResult>;
|
|
44
|
-
/**
|
|
45
|
-
* Verify a contract against an already-introspected schema slice.
|
|
46
|
-
*
|
|
47
|
-
* Callers that need to verify against the live database compose
|
|
48
|
-
* `introspect({ driver })` + `verifySchema({ contract, schema, ... })`.
|
|
49
|
-
* The aggregate verifier projects each member's claimed slice via
|
|
50
|
-
* `projectSchemaToSpace` and hands the projected slice in — this
|
|
51
|
-
* keeps per-member verification from surfacing sibling-space tables
|
|
52
|
-
* as `extras`.
|
|
53
|
-
*/
|
|
54
|
-
verifySchema(options: {
|
|
55
|
-
readonly contract: unknown;
|
|
56
|
-
readonly schema: SqlSchemaIR;
|
|
57
|
-
readonly strict: boolean;
|
|
58
|
-
readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;
|
|
59
|
-
}): VerifyDatabaseSchemaResult;
|
|
60
|
-
sign(options: {
|
|
61
|
-
readonly driver: SqlControlDriverInstance<string>;
|
|
62
|
-
readonly contract: unknown;
|
|
63
|
-
readonly contractPath: string;
|
|
64
|
-
readonly configPath?: string;
|
|
65
|
-
}): Promise<SignDatabaseResult>;
|
|
66
|
-
introspect(options: {
|
|
67
|
-
readonly driver: SqlControlDriverInstance<string>;
|
|
68
|
-
readonly contract?: unknown;
|
|
69
|
-
}): Promise<SqlSchemaIR>;
|
|
70
|
-
inferPslContract(schemaIR: SqlSchemaIR): PslDocumentAst;
|
|
71
|
-
lowerAst(ast: AnyQueryAst | DdlNode, context: LowererContext<unknown>): Promise<SqlExecuteRequest>;
|
|
72
|
-
/**
|
|
73
|
-
* Inserts the initial marker row for `space` (upsert on `space`).
|
|
74
|
-
* Delegates to the target control adapter's write SPI; see
|
|
75
|
-
* `SqlControlAdapter.initMarker`.
|
|
76
|
-
*/
|
|
77
|
-
initMarker(options: {
|
|
78
|
-
readonly driver: SqlControlDriverInstance<string>;
|
|
79
|
-
readonly space: string;
|
|
80
|
-
readonly destination: {
|
|
81
|
-
readonly storageHash: string;
|
|
82
|
-
readonly profileHash: string;
|
|
83
|
-
readonly invariants?: readonly string[];
|
|
84
|
-
};
|
|
85
|
-
}): Promise<void>;
|
|
86
|
-
/**
|
|
87
|
-
* Compare-and-swap advance of the marker row for `space`. Returns `true`
|
|
88
|
-
* when the swap matched a row; see `SqlControlAdapter.updateMarker`.
|
|
89
|
-
*/
|
|
90
|
-
updateMarker(options: {
|
|
91
|
-
readonly driver: SqlControlDriverInstance<string>;
|
|
92
|
-
readonly space: string;
|
|
93
|
-
readonly expectedFrom: string;
|
|
94
|
-
readonly destination: {
|
|
95
|
-
readonly storageHash: string;
|
|
96
|
-
readonly profileHash: string;
|
|
97
|
-
readonly invariants?: readonly string[];
|
|
98
|
-
};
|
|
99
|
-
}): Promise<boolean>;
|
|
100
|
-
/**
|
|
101
|
-
* Appends a ledger entry for `space`; see
|
|
102
|
-
* `SqlControlAdapter.writeLedgerEntry`.
|
|
103
|
-
*/
|
|
104
|
-
writeLedgerEntry(options: {
|
|
105
|
-
readonly driver: SqlControlDriverInstance<string>;
|
|
106
|
-
readonly space: string;
|
|
107
|
-
readonly entry: {
|
|
108
|
-
readonly edgeId: string;
|
|
109
|
-
readonly from: string;
|
|
110
|
-
readonly to: string;
|
|
111
|
-
readonly migrationName: string;
|
|
112
|
-
readonly migrationHash: string;
|
|
113
|
-
readonly operations: readonly unknown[];
|
|
114
|
-
};
|
|
115
|
-
}): Promise<void>;
|
|
116
|
-
bootstrapControlTableQueries(): readonly DdlNode[];
|
|
117
|
-
bootstrapSignMarkerQueries(): readonly DdlNode[];
|
|
118
|
-
toOperationPreview(operations: readonly MigrationPlanOperation[]): OperationPreview;
|
|
119
|
-
}
|
|
120
|
-
//#endregion
|
|
121
11
|
//#region src/core/migrations/types.d.ts
|
|
122
12
|
type AnyRecord = Readonly<Record<string, unknown>>;
|
|
123
13
|
interface StorageTypePlanResult<TTargetDetails> {
|
|
@@ -180,20 +70,28 @@ interface FieldEventContext {
|
|
|
180
70
|
readonly newField?: StorageColumn;
|
|
181
71
|
}
|
|
182
72
|
interface CodecControlHooks<TTargetDetails = unknown> {
|
|
73
|
+
/**
|
|
74
|
+
* `schema` is typed as the family-level `SqlSchemaIRNode` (not the concrete
|
|
75
|
+
* `SqlSchemaIR` class) because the actual value handed in is whatever
|
|
76
|
+
* per-namespace node the calling target's tree shape produces — a flat
|
|
77
|
+
* `SqlSchemaIR` for SQLite, a `PostgresNamespaceSchemaNode` for Postgres —
|
|
78
|
+
* read structurally for its `tables`/`nativeEnums` fields. Hooks that need
|
|
79
|
+
* the concrete Postgres shape narrow via `PostgresNamespaceSchemaNode.is(schema)`.
|
|
80
|
+
*/
|
|
183
81
|
planTypeOperations?: (options: {
|
|
184
82
|
readonly typeName: string;
|
|
185
83
|
readonly typeInstance: StorageTypeInstance;
|
|
186
84
|
readonly contract: Contract<SqlStorage>;
|
|
187
|
-
readonly schema:
|
|
85
|
+
readonly schema: SqlSchemaIRNode;
|
|
188
86
|
readonly schemaName?: string;
|
|
189
87
|
readonly policy: MigrationOperationPolicy;
|
|
190
88
|
}) => StorageTypePlanResult<TTargetDetails>;
|
|
191
89
|
verifyType?: (options: {
|
|
192
90
|
readonly typeName: string;
|
|
193
91
|
readonly typeInstance: StorageTypeInstance;
|
|
194
|
-
readonly schema:
|
|
92
|
+
readonly schema: SqlSchemaIRNode;
|
|
195
93
|
readonly schemaName?: string;
|
|
196
|
-
}) => readonly
|
|
94
|
+
}) => readonly SchemaDiffIssue[];
|
|
197
95
|
introspectTypes?: (options: {
|
|
198
96
|
readonly driver: SqlControlDriverInstance<string>;
|
|
199
97
|
readonly schemaName?: string;
|
|
@@ -333,12 +231,12 @@ interface SqlMigrationPlan<TTargetDetails> extends MigrationPlan {
|
|
|
333
231
|
}
|
|
334
232
|
type SqlPlannerConflictKind = 'typeMismatch' | 'nullabilityConflict' | 'indexIncompatible' | 'foreignKeyConflict' | 'missingButNonAdditive' | 'unsupportedOperation' | 'controlPolicySuppressedCall';
|
|
335
233
|
interface SqlPlannerConflictLocation {
|
|
336
|
-
readonly
|
|
337
|
-
readonly
|
|
234
|
+
readonly namespaceId?: string;
|
|
235
|
+
readonly entityKind?: string;
|
|
236
|
+
readonly entityName?: string;
|
|
338
237
|
readonly column?: string;
|
|
339
238
|
readonly index?: string;
|
|
340
239
|
readonly constraint?: string;
|
|
341
|
-
readonly type?: string;
|
|
342
240
|
}
|
|
343
241
|
interface SqlPlannerConflict extends MigrationPlannerConflict {
|
|
344
242
|
readonly kind: SqlPlannerConflictKind;
|
|
@@ -356,7 +254,12 @@ interface SqlPlannerFailureResult extends Omit<MigrationPlannerFailureResult, 'c
|
|
|
356
254
|
type SqlPlannerResult<TTargetDetails> = SqlPlannerSuccessResult<TTargetDetails> | SqlPlannerFailureResult;
|
|
357
255
|
interface SqlMigrationPlannerPlanOptions {
|
|
358
256
|
readonly contract: Contract<SqlStorage>;
|
|
359
|
-
|
|
257
|
+
/**
|
|
258
|
+
* The "from"/live schema as the target's introspected node (SQLite a flat
|
|
259
|
+
* `SqlSchemaIR`, Postgres a `PostgresDatabaseSchemaNode` root). Structure-aware
|
|
260
|
+
* consumers narrow the concrete shape before walking it.
|
|
261
|
+
*/
|
|
262
|
+
readonly schema: SqlSchemaIRNode;
|
|
360
263
|
readonly policy: MigrationOperationPolicy;
|
|
361
264
|
readonly schemaName?: string;
|
|
362
265
|
/**
|
|
@@ -391,6 +294,16 @@ interface SqlMigrationPlannerPlanOptions {
|
|
|
391
294
|
* All components must have matching familyId ('sql') and targetId.
|
|
392
295
|
*/
|
|
393
296
|
readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;
|
|
297
|
+
/**
|
|
298
|
+
* Ownership oracle over the whole contract-space composition (the passive
|
|
299
|
+
* aggregate). The planner asks it, per live extra node, whether any space
|
|
300
|
+
* declares that entity: a sibling-owned node is left untouched, an unowned
|
|
301
|
+
* node is a genuine extra it may drop under a destructive policy. The
|
|
302
|
+
* planner holds no list of other spaces' names — ownership lives in the
|
|
303
|
+
* aggregate; it only asks. Absent for a single-space plan handed no
|
|
304
|
+
* aggregate. See {@link SchemaOwnership}.
|
|
305
|
+
*/
|
|
306
|
+
readonly ownership?: SchemaOwnership;
|
|
394
307
|
}
|
|
395
308
|
interface SqlMigrationPlanner<TTargetDetails> {
|
|
396
309
|
plan(options: SqlMigrationPlannerPlanOptions): SqlPlannerResult<TTargetDetails>;
|
|
@@ -479,25 +392,6 @@ interface SqlMigrationRunner<TTargetDetails> {
|
|
|
479
392
|
*/
|
|
480
393
|
executeOnConnection(options: SqlMigrationRunnerExecuteOptions<TTargetDetails>): Promise<SqlMigrationRunnerResult>;
|
|
481
394
|
}
|
|
482
|
-
interface SqlControlTargetDescriptor<TTargetId extends string, TTargetDetails, TContract extends Contract<SqlStorage> = Contract<SqlStorage>> extends MigratableTargetDescriptor<'sql', TTargetId, SqlControlFamilyInstance> {
|
|
483
|
-
readonly queryOperations?: () => SqlOperationDescriptors;
|
|
484
|
-
/**
|
|
485
|
-
* JSON ⇄ class boundary for the SQL target's contract. The descriptor
|
|
486
|
-
* composes a concrete `SqlContractSerializerBase` subclass; the rest
|
|
487
|
-
* of the control stack reaches `descriptor.contractSerializer` rather
|
|
488
|
-
* than importing a per-target deserialization function.
|
|
489
|
-
*/
|
|
490
|
-
readonly contractSerializer: ContractSerializer<TContract>;
|
|
491
|
-
/**
|
|
492
|
-
* Per-target schema verifier walking the contract against
|
|
493
|
-
* `SqlSchemaIR`. The descriptor composes a concrete
|
|
494
|
-
* `SqlSchemaVerifierBase` subclass; the family-shared walk lives on
|
|
495
|
-
* the base, the target-specific dispatch on the subclass.
|
|
496
|
-
*/
|
|
497
|
-
readonly schemaVerifier: SchemaVerifier<TContract, SqlSchemaIR>;
|
|
498
|
-
createPlanner(adapter: SqlControlAdapter<TTargetId>): SqlMigrationPlanner<TTargetDetails>;
|
|
499
|
-
createRunner(family: SqlControlFamilyInstance): SqlMigrationRunner<TTargetDetails>;
|
|
500
|
-
}
|
|
501
395
|
interface CreateSqlMigrationPlanOptions<TTargetDetails> {
|
|
502
396
|
readonly targetId: string;
|
|
503
397
|
/**
|
|
@@ -516,5 +410,5 @@ interface CreateSqlMigrationPlanOptions<TTargetDetails> {
|
|
|
516
410
|
readonly meta?: AnyRecord;
|
|
517
411
|
}
|
|
518
412
|
//#endregion
|
|
519
|
-
export {
|
|
520
|
-
//# sourceMappingURL=types-
|
|
413
|
+
export { SqlPlannerSuccessResult as A, SqlMigrationRunnerSuccessValue as C, SqlPlannerConflictLocation as D, SqlPlannerConflictKind as E, SqlPlannerFailureResult as O, SqlMigrationRunnerResult as S, SqlPlannerConflict as T, SqlMigrationRunner as _, FieldEvent as a, SqlMigrationRunnerExecuteOptions as b, SqlControlAdapterDescriptor as c, SqlMigrationPlanContractInfo as d, SqlMigrationPlanOperation as f, SqlMigrationPlannerPlanOptions as g, SqlMigrationPlanner as h, ExpandNativeTypeInput as i, StorageTypePlanResult as j, SqlPlannerResult as k, SqlControlExtensionDescriptor as l, SqlMigrationPlanOperationTarget as m, CodecControlHooks as n, FieldEventContext as o, SqlMigrationPlanOperationStep as p, CreateSqlMigrationPlanOptions as r, ResolveIdentityValueInput as s, AnyRecord as t, SqlMigrationPlan as u, SqlMigrationRunnerErrorCode as v, SqlPlanTargetDetails as w, SqlMigrationRunnerFailure as x, SqlMigrationRunnerExecuteCallbacks as y };
|
|
414
|
+
//# sourceMappingURL=types-BPv_y7iS.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-BPv_y7iS.d.mts","names":[],"sources":["../src/core/migrations/types.ts"],"mappings":";;;;;;;;;;;KAkCY,SAAA,GAAY,QAAQ,CAAC,MAAA;AAAA,UAEhB,qBAAA;EAAA,SACN,UAAA,WAAqB,yBAAyB,CAAC,cAAA;AAAA;;;AAHnB;UAStB,qBAAA;EAAA,SACN,UAAA;EAAA,SACA,OAAA;EAAA,SACA,UAAA,GAA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version": "0.14.0-dev.90",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"description": "SQL family descriptor for Prisma Next",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@prisma-next/contract": "0.14.0-dev.
|
|
10
|
-
"@prisma-next/emitter": "0.14.0-dev.
|
|
11
|
-
"@prisma-next/framework-components": "0.14.0-dev.
|
|
12
|
-
"@prisma-next/migration-tools": "0.14.0-dev.
|
|
13
|
-
"@prisma-next/operations": "0.14.0-dev.
|
|
14
|
-
"@prisma-next/sql-contract": "0.14.0-dev.
|
|
15
|
-
"@prisma-next/sql-contract-emitter": "0.14.0-dev.
|
|
16
|
-
"@prisma-next/sql-contract-ts": "0.14.0-dev.
|
|
17
|
-
"@prisma-next/sql-operations": "0.14.0-dev.
|
|
18
|
-
"@prisma-next/sql-relational-core": "0.14.0-dev.
|
|
19
|
-
"@prisma-next/sql-runtime": "0.14.0-dev.
|
|
20
|
-
"@prisma-next/sql-schema-ir": "0.14.0-dev.
|
|
21
|
-
"@prisma-next/utils": "0.14.0-dev.
|
|
22
|
-
"arktype": "^2.2.
|
|
9
|
+
"@prisma-next/contract": "0.14.0-dev.90",
|
|
10
|
+
"@prisma-next/emitter": "0.14.0-dev.90",
|
|
11
|
+
"@prisma-next/framework-components": "0.14.0-dev.90",
|
|
12
|
+
"@prisma-next/migration-tools": "0.14.0-dev.90",
|
|
13
|
+
"@prisma-next/operations": "0.14.0-dev.90",
|
|
14
|
+
"@prisma-next/sql-contract": "0.14.0-dev.90",
|
|
15
|
+
"@prisma-next/sql-contract-emitter": "0.14.0-dev.90",
|
|
16
|
+
"@prisma-next/sql-contract-ts": "0.14.0-dev.90",
|
|
17
|
+
"@prisma-next/sql-operations": "0.14.0-dev.90",
|
|
18
|
+
"@prisma-next/sql-relational-core": "0.14.0-dev.90",
|
|
19
|
+
"@prisma-next/sql-runtime": "0.14.0-dev.90",
|
|
20
|
+
"@prisma-next/sql-schema-ir": "0.14.0-dev.90",
|
|
21
|
+
"@prisma-next/utils": "0.14.0-dev.90",
|
|
22
|
+
"arktype": "^2.2.2"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@prisma-next/driver-postgres": "0.14.0-dev.
|
|
26
|
-
"@prisma-next/psl-parser": "0.14.0-dev.
|
|
27
|
-
"@prisma-next/psl-printer": "0.14.0-dev.
|
|
28
|
-
"@prisma-next/sql-contract-psl": "0.14.0-dev.
|
|
29
|
-
"@prisma-next/test-utils": "0.14.0-dev.
|
|
30
|
-
"@prisma-next/tsconfig": "0.14.0-dev.
|
|
31
|
-
"@prisma-next/tsdown": "0.14.0-dev.
|
|
32
|
-
"tsdown": "0.22.
|
|
25
|
+
"@prisma-next/driver-postgres": "0.14.0-dev.90",
|
|
26
|
+
"@prisma-next/psl-parser": "0.14.0-dev.90",
|
|
27
|
+
"@prisma-next/psl-printer": "0.14.0-dev.90",
|
|
28
|
+
"@prisma-next/sql-contract-psl": "0.14.0-dev.90",
|
|
29
|
+
"@prisma-next/test-utils": "0.14.0-dev.90",
|
|
30
|
+
"@prisma-next/tsconfig": "0.14.0-dev.90",
|
|
31
|
+
"@prisma-next/tsdown": "0.14.0-dev.90",
|
|
32
|
+
"tsdown": "0.22.3",
|
|
33
33
|
"typescript": "5.9.3",
|
|
34
|
-
"vitest": "4.1.
|
|
34
|
+
"vitest": "4.1.10"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"typescript": ">=5.9"
|
|
@@ -48,12 +48,12 @@
|
|
|
48
48
|
"exports": {
|
|
49
49
|
"./control": "./dist/control.mjs",
|
|
50
50
|
"./control-adapter": "./dist/control-adapter.mjs",
|
|
51
|
+
"./diff": "./dist/diff.mjs",
|
|
51
52
|
"./ir": "./dist/ir.mjs",
|
|
52
53
|
"./migration": "./dist/migration.mjs",
|
|
53
54
|
"./pack": "./dist/pack.mjs",
|
|
55
|
+
"./psl-infer": "./dist/psl-infer.mjs",
|
|
54
56
|
"./runtime": "./dist/runtime.mjs",
|
|
55
|
-
"./schema-verify": "./dist/schema-verify.mjs",
|
|
56
|
-
"./test-utils": "./dist/test-utils.mjs",
|
|
57
57
|
"./verify": "./dist/verify.mjs",
|
|
58
58
|
"./package.json": "./package.json"
|
|
59
59
|
},
|
|
@@ -1,21 +1,15 @@
|
|
|
1
1
|
import type { JsonValue } from '@prisma-next/contract/types';
|
|
2
|
-
import
|
|
3
|
-
AuthoringEntityContext,
|
|
4
|
-
AuthoringEntityTypeDescriptor,
|
|
5
|
-
AuthoringEntityTypeNamespace,
|
|
6
|
-
AuthoringPslBlockDescriptorNamespace,
|
|
7
|
-
PslExtensionBlock,
|
|
2
|
+
import {
|
|
3
|
+
type AuthoringEntityContext,
|
|
4
|
+
type AuthoringEntityTypeDescriptor,
|
|
5
|
+
type AuthoringEntityTypeNamespace,
|
|
6
|
+
type AuthoringPslBlockDescriptorNamespace,
|
|
7
|
+
type PslExtensionBlock,
|
|
8
|
+
resolveEnumCodecId,
|
|
8
9
|
} from '@prisma-next/framework-components/authoring';
|
|
9
10
|
import { type EnumTypeHandle, enumType } from '@prisma-next/sql-contract-ts/contract-builder';
|
|
10
11
|
import { blindCast } from '@prisma-next/utils/casts';
|
|
11
12
|
|
|
12
|
-
function parseQuotedString(raw: string): string | undefined {
|
|
13
|
-
if (raw.startsWith('"') && raw.endsWith('"') && raw.length >= 2) {
|
|
14
|
-
return raw.slice(1, -1);
|
|
15
|
-
}
|
|
16
|
-
return undefined;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
13
|
export const sqlFamilyEnumEntityDescriptor = {
|
|
20
14
|
kind: 'entity' as const,
|
|
21
15
|
discriminator: 'enum',
|
|
@@ -27,49 +21,30 @@ export const sqlFamilyEnumEntityDescriptor = {
|
|
|
27
21
|
const sourceId = ctx.sourceId ?? 'unknown';
|
|
28
22
|
const diagnostics = ctx.diagnostics;
|
|
29
23
|
|
|
30
|
-
const
|
|
31
|
-
if (
|
|
32
|
-
diagnostics?.push({
|
|
33
|
-
code: 'PSL_ENUM_MISSING_TYPE',
|
|
34
|
-
message: `enum "${block.name}" is missing a @@type("codecId") attribute`,
|
|
35
|
-
sourceId,
|
|
36
|
-
span: block.span,
|
|
37
|
-
});
|
|
38
|
-
return undefined;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const rawCodecArg = typeAttr.args[0]?.value;
|
|
42
|
-
const codecId = rawCodecArg !== undefined ? parseQuotedString(rawCodecArg) : undefined;
|
|
43
|
-
if (!codecId) {
|
|
44
|
-
diagnostics?.push({
|
|
45
|
-
code: 'PSL_ENUM_MISSING_TYPE',
|
|
46
|
-
message: `enum "${block.name}" @@type attribute must have a quoted codec id argument`,
|
|
47
|
-
sourceId,
|
|
48
|
-
span: typeAttr.span,
|
|
49
|
-
});
|
|
24
|
+
const resolved = resolveEnumCodecId(block, ctx);
|
|
25
|
+
if (resolved === undefined) {
|
|
50
26
|
return undefined;
|
|
51
27
|
}
|
|
28
|
+
const { codecId, codecSpan } = resolved;
|
|
52
29
|
|
|
53
30
|
const nativeType = ctx.codecLookup?.targetTypesFor(codecId)?.[0];
|
|
54
31
|
if (nativeType === undefined) {
|
|
55
|
-
const typeArgSpan = typeAttr.args[0]?.span ?? typeAttr.span;
|
|
56
32
|
diagnostics?.push({
|
|
57
33
|
code: 'PSL_EXTENSION_INVALID_VALUE',
|
|
58
34
|
message: `enum "${block.name}" @@type references unknown codec "${codecId}"`,
|
|
59
35
|
sourceId,
|
|
60
|
-
span:
|
|
36
|
+
span: codecSpan,
|
|
61
37
|
});
|
|
62
38
|
return undefined;
|
|
63
39
|
}
|
|
64
40
|
|
|
65
41
|
const codec = ctx.codecLookup?.get(codecId);
|
|
66
42
|
if (codec === undefined) {
|
|
67
|
-
const typeArgSpan = typeAttr.args[0]?.span ?? typeAttr.span;
|
|
68
43
|
diagnostics?.push({
|
|
69
44
|
code: 'PSL_EXTENSION_INVALID_VALUE',
|
|
70
45
|
message: `enum "${block.name}" @@type codec "${codecId}" resolves in targetTypesFor but is absent from codecLookup.get`,
|
|
71
46
|
sourceId,
|
|
72
|
-
span:
|
|
47
|
+
span: codecSpan,
|
|
73
48
|
});
|
|
74
49
|
return undefined;
|
|
75
50
|
}
|
|
@@ -11,8 +11,8 @@ import type {
|
|
|
11
11
|
LowererContext,
|
|
12
12
|
SqlExecuteRequest,
|
|
13
13
|
} from '@prisma-next/sql-relational-core/ast';
|
|
14
|
-
import type {
|
|
15
|
-
import type { DefaultNormalizer, NativeTypeNormalizer } from './
|
|
14
|
+
import type { SqlSchemaIRNode } from '@prisma-next/sql-schema-ir/types';
|
|
15
|
+
import type { DefaultNormalizer, NativeTypeNormalizer } from './diff/sql-schema-diff';
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Structural interface for anything that can lower a SQL/DDL AST node to a
|
|
@@ -153,26 +153,32 @@ export interface SqlControlAdapter<TTarget extends string = string>
|
|
|
153
153
|
readonly migrationName: string;
|
|
154
154
|
readonly migrationHash: string;
|
|
155
155
|
readonly operations: readonly unknown[];
|
|
156
|
+
readonly destinationContractJson?: unknown;
|
|
156
157
|
},
|
|
157
158
|
): Promise<void>;
|
|
158
159
|
|
|
159
160
|
/**
|
|
160
|
-
* Introspects a database schema and returns
|
|
161
|
+
* Introspects a database schema and returns the target's schema-IR node.
|
|
161
162
|
*
|
|
162
163
|
* This is a pure schema discovery operation that queries the database catalog
|
|
163
164
|
* and returns the schema structure without type mapping or contract enrichment.
|
|
164
165
|
* Type mapping and enrichment are handled separately by enrichment helpers.
|
|
165
166
|
*
|
|
167
|
+
* The return type is the family-base `SqlSchemaIRNode` so each target returns
|
|
168
|
+
* its own node shape: SQLite returns a flat `SqlSchemaIR`, Postgres returns a
|
|
169
|
+
* `PostgresDatabaseSchemaNode` tree root. Consumers `ensure` the concrete
|
|
170
|
+
* target type before walking it.
|
|
171
|
+
*
|
|
166
172
|
* @param driver - ControlDriverInstance instance for executing queries (target-specific)
|
|
167
173
|
* @param contract - Optional contract for contract-guided introspection (filtering, optimization)
|
|
168
174
|
* @param schema - Schema name to introspect (defaults to 'public')
|
|
169
|
-
* @returns Promise resolving to
|
|
175
|
+
* @returns Promise resolving to the live database schema node
|
|
170
176
|
*/
|
|
171
177
|
introspect(
|
|
172
178
|
driver: SqlControlDriverInstance<TTarget>,
|
|
173
179
|
contract?: unknown,
|
|
174
180
|
schema?: string,
|
|
175
|
-
): Promise<
|
|
181
|
+
): Promise<SqlSchemaIRNode>;
|
|
176
182
|
|
|
177
183
|
/**
|
|
178
184
|
* Optional target-specific normalizer for raw database default expressions.
|