@prisma-next/family-sql 0.14.0-dev.4 → 0.14.0-dev.40
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/contract-to-schema-ir-S-evq8E6.mjs +264 -0
- package/dist/contract-to-schema-ir-S-evq8E6.mjs.map +1 -0
- package/dist/{control-adapter-Cmw9LvEP.d.mts → control-adapter-DHYFuOBy.d.mts} +12 -7
- package/dist/{control-adapter-Cmw9LvEP.d.mts.map → control-adapter-DHYFuOBy.d.mts.map} +1 -1
- package/dist/control-adapter.d.mts +1 -1
- package/dist/control.d.mts +18 -3
- package/dist/control.d.mts.map +1 -1
- package/dist/control.mjs +81 -943
- package/dist/control.mjs.map +1 -1
- package/dist/{schema-verify.d.mts → diff.d.mts} +5 -5
- package/dist/diff.d.mts.map +1 -0
- package/dist/{verify-sql-schema-xT4udQLQ.mjs → diff.mjs} +169 -253
- package/dist/diff.mjs.map +1 -0
- package/dist/ir.d.mts +9 -6
- package/dist/ir.d.mts.map +1 -1
- package/dist/ir.mjs +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 +80 -0
- package/dist/psl-infer.d.mts.map +1 -0
- package/dist/psl-infer.mjs +334 -0
- package/dist/psl-infer.mjs.map +1 -0
- package/dist/{sql-contract-serializer-BR2vC7Z-.mjs → sql-contract-serializer-CYtXg_zs.mjs} +17 -20
- package/dist/sql-contract-serializer-CYtXg_zs.mjs.map +1 -0
- package/dist/{verify-sql-schema-thU-jKpf.d.mts → sql-schema-diff-6z36dZt6.d.mts} +44 -5
- package/dist/sql-schema-diff-6z36dZt6.d.mts.map +1 -0
- package/dist/{types-kgstZ_Zd.d.mts → types-CkOIJXxU.d.mts} +84 -17
- package/dist/types-CkOIJXxU.d.mts.map +1 -0
- package/package.json +23 -23
- package/src/core/authoring-entity-types.ts +12 -37
- package/src/core/control-adapter.ts +10 -5
- package/src/core/control-instance.ts +174 -41
- package/src/core/{schema-verify/verify-sql-schema.ts → diff/sql-schema-diff.ts} +208 -16
- package/src/core/{schema-verify → diff}/verify-helpers.ts +12 -0
- package/src/core/ir/sql-contract-serializer-base.ts +23 -55
- package/src/core/ir/sql-contract-serializer.ts +5 -7
- package/src/core/migrations/contract-to-schema-ir.ts +49 -12
- package/src/core/migrations/field-event-planner.ts +2 -2
- package/src/core/migrations/schema-differ.ts +40 -0
- package/src/core/migrations/types.ts +43 -2
- package/src/core/psl-contract-infer/printer-config.ts +0 -6
- package/src/core/sql-migration.ts +12 -1
- package/src/exports/control.ts +1 -0
- package/src/exports/diff.ts +18 -0
- package/src/exports/psl-infer.ts +36 -0
- package/dist/authoring-type-constructors-CjFfO6LM.mjs.map +0 -1
- 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.map +0 -1
- 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/exports/schema-verify.ts +0 -18
- package/src/exports/test-utils.ts +0 -9
- /package/src/core/{schema-verify → diff}/control-verify-emit.ts +0 -0
- /package/src/core/{schema-verify → diff}/verifier-disposition.ts +0 -0
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { r as SqlControlAdapter } from "./control-adapter-
|
|
2
|
-
import {
|
|
1
|
+
import { r as SqlControlAdapter } from "./control-adapter-DHYFuOBy.mjs";
|
|
2
|
+
import { Contract, ControlPolicy } from "@prisma-next/contract/types";
|
|
3
|
+
import { ContractSerializer, ContractSpace, ControlAdapterDescriptor, ControlExtensionDescriptor, ControlFamilyInstance, ControlStack, DiffIssue, MigratableTargetDescriptor, MigrationOperationPolicy, MigrationPlan, MigrationPlanOperation, MigrationPlannerConflict, MigrationPlannerFailureResult, MigrationPlannerSuccessResult, MigrationRunnerExecutionChecks, MigrationRunnerFailure, MigrationRunnerPerSpaceSuccessValue, MigrationRunnerResult, OpFactoryCall, OperationContext, OperationPreview, OperationPreviewCapable, PslContractInferCapable, SchemaDiffer, SchemaIssue, SchemaVerifier, SchemaViewCapable, SignDatabaseResult, VerifyDatabaseResult, VerifyDatabaseSchemaResult } from "@prisma-next/framework-components/control";
|
|
3
4
|
import { SqlControlDriverInstance, SqlStorage, StorageColumn, StorageTable, StorageTypeInstance } from "@prisma-next/sql-contract/types";
|
|
4
|
-
import { PslDocumentAst } from "@prisma-next/framework-components/psl-ast";
|
|
5
|
-
import { Contract } from "@prisma-next/contract/types";
|
|
6
5
|
import { Result } from "@prisma-next/utils/result";
|
|
7
6
|
import { AnyQueryAst, DdlNode, LowererContext, SqlExecuteRequest } from "@prisma-next/sql-relational-core/ast";
|
|
8
|
-
import { SqlSchemaIR } from "@prisma-next/sql-schema-ir/types";
|
|
7
|
+
import { SqlSchemaIR, SqlSchemaIRNode } from "@prisma-next/sql-schema-ir/types";
|
|
9
8
|
import { TargetBoundComponentDescriptor } from "@prisma-next/framework-components/components";
|
|
10
9
|
import { TypesImportSpec } from "@prisma-next/framework-components/emission";
|
|
10
|
+
import { PslDocumentAst } from "@prisma-next/framework-components/psl-ast";
|
|
11
11
|
import { AggregateMigrationEdgeRef } from "@prisma-next/migration-tools/aggregate";
|
|
12
12
|
import { SqlOperationDescriptors } from "@prisma-next/sql-operations";
|
|
13
13
|
|
|
@@ -24,7 +24,7 @@ interface SqlFamilyInstanceState {
|
|
|
24
24
|
readonly extensionIds: ReadonlyArray<string>;
|
|
25
25
|
readonly typeMetadataRegistry: SqlTypeMetadataRegistry;
|
|
26
26
|
}
|
|
27
|
-
interface SqlControlFamilyInstance extends ControlFamilyInstance<'sql',
|
|
27
|
+
interface SqlControlFamilyInstance extends ControlFamilyInstance<'sql', SqlSchemaIRNode>, SchemaViewCapable<SqlSchemaIRNode>, PslContractInferCapable<SqlSchemaIRNode>, OperationPreviewCapable, SqlFamilyInstanceState {
|
|
28
28
|
/**
|
|
29
29
|
* The family seam-of-record for on-disk contract reads. Structurally
|
|
30
30
|
* validates the JSON envelope, then hydrates IR-class instances via
|
|
@@ -42,18 +42,17 @@ interface SqlControlFamilyInstance extends ControlFamilyInstance<'sql', SqlSchem
|
|
|
42
42
|
readonly configPath?: string;
|
|
43
43
|
}): Promise<VerifyDatabaseResult>;
|
|
44
44
|
/**
|
|
45
|
-
* Verify a contract against an already-introspected schema
|
|
45
|
+
* Verify a contract against an already-introspected schema.
|
|
46
46
|
*
|
|
47
47
|
* Callers that need to verify against the live database compose
|
|
48
48
|
* `introspect({ driver })` + `verifySchema({ contract, schema, ... })`.
|
|
49
|
-
* The aggregate verifier
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
* as `extras`.
|
|
49
|
+
* The aggregate verifier hands in the full introspected schema and scopes
|
|
50
|
+
* the returned result to each member's contract space afterwards — so
|
|
51
|
+
* sibling-space tables never survive as `extras`.
|
|
53
52
|
*/
|
|
54
53
|
verifySchema(options: {
|
|
55
54
|
readonly contract: unknown;
|
|
56
|
-
readonly schema:
|
|
55
|
+
readonly schema: SqlSchemaIRNode;
|
|
57
56
|
readonly strict: boolean;
|
|
58
57
|
readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;
|
|
59
58
|
}): VerifyDatabaseSchemaResult;
|
|
@@ -66,8 +65,8 @@ interface SqlControlFamilyInstance extends ControlFamilyInstance<'sql', SqlSchem
|
|
|
66
65
|
introspect(options: {
|
|
67
66
|
readonly driver: SqlControlDriverInstance<string>;
|
|
68
67
|
readonly contract?: unknown;
|
|
69
|
-
}): Promise<
|
|
70
|
-
inferPslContract(schemaIR:
|
|
68
|
+
}): Promise<SqlSchemaIRNode>;
|
|
69
|
+
inferPslContract(schemaIR: SqlSchemaIRNode): PslDocumentAst;
|
|
71
70
|
lowerAst(ast: AnyQueryAst | DdlNode, context: LowererContext<unknown>): Promise<SqlExecuteRequest>;
|
|
72
71
|
/**
|
|
73
72
|
* Inserts the initial marker row for `space` (upsert on `space`).
|
|
@@ -114,10 +113,40 @@ interface SqlControlFamilyInstance extends ControlFamilyInstance<'sql', SqlSchem
|
|
|
114
113
|
};
|
|
115
114
|
}): Promise<void>;
|
|
116
115
|
bootstrapControlTableQueries(): readonly DdlNode[];
|
|
117
|
-
bootstrapSignMarkerQueries(): readonly DdlNode[];
|
|
118
116
|
toOperationPreview(operations: readonly MigrationPlanOperation[]): OperationPreview;
|
|
119
117
|
}
|
|
120
118
|
//#endregion
|
|
119
|
+
//#region src/core/migrations/schema-differ.d.ts
|
|
120
|
+
/**
|
|
121
|
+
* Inputs to a SQL target's schema-differ (`diffDatabaseSchema` /
|
|
122
|
+
* `verifyDatabaseSchema` on the descriptor): the contract (the expected side
|
|
123
|
+
* derives from it), the introspected actual schema node, and the resolution
|
|
124
|
+
* context the relational diff needs.
|
|
125
|
+
*/
|
|
126
|
+
interface DiffDatabaseSchemaInput {
|
|
127
|
+
readonly contract: Contract<SqlStorage>;
|
|
128
|
+
readonly schema: SqlSchemaIRNode;
|
|
129
|
+
readonly strict: boolean;
|
|
130
|
+
readonly typeMetadataRegistry: ReadonlyMap<string, {
|
|
131
|
+
readonly nativeType?: string;
|
|
132
|
+
}>;
|
|
133
|
+
readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* The `SchemaDiffer` a SQL target implements: the black-box comparison of the
|
|
137
|
+
* contract's expected schema against the introspected actual schema, projected
|
|
138
|
+
* to the two issue lists. How it computes them is private to the target.
|
|
139
|
+
*/
|
|
140
|
+
type SqlDiffDatabaseSchema = SchemaDiffer<DiffDatabaseSchemaInput>['diff'];
|
|
141
|
+
/**
|
|
142
|
+
* The same combined comparison as {@link SqlDiffDatabaseSchema}, wrapped in the
|
|
143
|
+
* verify envelope (`ok`/`summary`/`code`/`target`/`timings`) plus the
|
|
144
|
+
* pass/warn/fail tree the CLI renders. Verify calls this instead of the diff so
|
|
145
|
+
* the relational walk that produces the tree runs once per verify, not once for
|
|
146
|
+
* the diff and again for the tree.
|
|
147
|
+
*/
|
|
148
|
+
type SqlVerifyDatabaseSchema = (input: DiffDatabaseSchemaInput) => VerifyDatabaseSchemaResult;
|
|
149
|
+
//#endregion
|
|
121
150
|
//#region src/core/migrations/types.d.ts
|
|
122
151
|
type AnyRecord = Readonly<Record<string, unknown>>;
|
|
123
152
|
interface StorageTypePlanResult<TTargetDetails> {
|
|
@@ -356,7 +385,12 @@ interface SqlPlannerFailureResult extends Omit<MigrationPlannerFailureResult, 'c
|
|
|
356
385
|
type SqlPlannerResult<TTargetDetails> = SqlPlannerSuccessResult<TTargetDetails> | SqlPlannerFailureResult;
|
|
357
386
|
interface SqlMigrationPlannerPlanOptions {
|
|
358
387
|
readonly contract: Contract<SqlStorage>;
|
|
359
|
-
|
|
388
|
+
/**
|
|
389
|
+
* The "from"/live schema as the target's introspected node (SQLite a flat
|
|
390
|
+
* `SqlSchemaIR`, Postgres a `PostgresDatabaseSchemaNode` root). Structure-aware
|
|
391
|
+
* consumers narrow the concrete shape before walking it.
|
|
392
|
+
*/
|
|
393
|
+
readonly schema: SqlSchemaIRNode;
|
|
360
394
|
readonly policy: MigrationOperationPolicy;
|
|
361
395
|
readonly schemaName?: string;
|
|
362
396
|
/**
|
|
@@ -391,6 +425,16 @@ interface SqlMigrationPlannerPlanOptions {
|
|
|
391
425
|
* All components must have matching familyId ('sql') and targetId.
|
|
392
426
|
*/
|
|
393
427
|
readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;
|
|
428
|
+
/**
|
|
429
|
+
* Caller-supplied keep-predicate the planner applies to its schema diff
|
|
430
|
+
* (via `SchemaDiff.filter`) before building operations. The orchestration
|
|
431
|
+
* constructs it so the diff findings reaching op-building are exactly the
|
|
432
|
+
* contract space's own — e.g. dropping the `extra` findings for elements a
|
|
433
|
+
* sibling contract space declares, so the planner never emits DROP ops
|
|
434
|
+
* against another space's tables. The planner applies it blindly and holds
|
|
435
|
+
* no ownership logic. Absent for single-space plans.
|
|
436
|
+
*/
|
|
437
|
+
readonly keepDiffIssue?: (issue: DiffIssue) => boolean;
|
|
394
438
|
}
|
|
395
439
|
interface SqlMigrationPlanner<TTargetDetails> {
|
|
396
440
|
plan(options: SqlMigrationPlannerPlanOptions): SqlPlannerResult<TTargetDetails>;
|
|
@@ -495,6 +539,29 @@ interface SqlControlTargetDescriptor<TTargetId extends string, TTargetDetails, T
|
|
|
495
539
|
* the base, the target-specific dispatch on the subclass.
|
|
496
540
|
*/
|
|
497
541
|
readonly schemaVerifier: SchemaVerifier<TContract, SqlSchemaIR>;
|
|
542
|
+
/**
|
|
543
|
+
* Database→PSL inference for `contract infer`. Target logic (owns the dialect
|
|
544
|
+
* maps), so it lives on the descriptor. Optional: targets without `contract
|
|
545
|
+
* infer` (Mongo) omit it, and the family instance throws when it is absent.
|
|
546
|
+
*/
|
|
547
|
+
readonly inferPslContract?: (schema: SqlSchemaIRNode) => PslDocumentAst;
|
|
548
|
+
/**
|
|
549
|
+
* The single combined database-schema diff of two derived representations —
|
|
550
|
+
* the target's black-box comparison. Every SQL target provides it (Postgres
|
|
551
|
+
* returns relational + policy issues; SQLite returns relational only). It is
|
|
552
|
+
* schema logic on the target, not database I/O, so it lives here rather than
|
|
553
|
+
* on the control adapter. How it computes the two issue sets is private.
|
|
554
|
+
* See {@link SqlDiffDatabaseSchema} / {@link SqlVerifyDatabaseSchema}.
|
|
555
|
+
*/
|
|
556
|
+
readonly diffDatabaseSchema: SqlDiffDatabaseSchema;
|
|
557
|
+
/**
|
|
558
|
+
* The same combined comparison as {@link diffDatabaseSchema}, wrapped in the
|
|
559
|
+
* verify envelope (`ok`/`summary`/`code`/`target`/`timings`) plus the
|
|
560
|
+
* pass/warn/fail tree the CLI renders. Verify calls this instead of
|
|
561
|
+
* `diffDatabaseSchema` so the relational walk that produces the tree runs
|
|
562
|
+
* once per verify, not once for the diff and again for the tree.
|
|
563
|
+
*/
|
|
564
|
+
readonly verifyDatabaseSchema: SqlVerifyDatabaseSchema;
|
|
498
565
|
createPlanner(adapter: SqlControlAdapter<TTargetId>): SqlMigrationPlanner<TTargetDetails>;
|
|
499
566
|
createRunner(family: SqlControlFamilyInstance): SqlMigrationRunner<TTargetDetails>;
|
|
500
567
|
}
|
|
@@ -517,4 +584,4 @@ interface CreateSqlMigrationPlanOptions<TTargetDetails> {
|
|
|
517
584
|
}
|
|
518
585
|
//#endregion
|
|
519
586
|
export { SqlPlannerResult as A, SqlMigrationRunnerResult as C, SqlPlannerConflictKind as D, SqlPlannerConflict as E, StorageTypePlanResult as M, SqlControlFamilyInstance as N, SqlPlannerConflictLocation as O, SqlMigrationRunnerFailure as S, SqlPlanTargetDetails as T, SqlMigrationPlannerPlanOptions as _, FieldEvent as a, SqlMigrationRunnerExecuteCallbacks as b, SqlControlAdapterDescriptor as c, SqlMigrationPlan as d, SqlMigrationPlanContractInfo as f, SqlMigrationPlanner as g, SqlMigrationPlanOperationTarget as h, ExpandNativeTypeInput as i, SqlPlannerSuccessResult as j, SqlPlannerFailureResult as k, SqlControlExtensionDescriptor as l, SqlMigrationPlanOperationStep as m, CodecControlHooks as n, FieldEventContext as o, SqlMigrationPlanOperation as p, CreateSqlMigrationPlanOptions as r, ResolveIdentityValueInput as s, AnyRecord as t, SqlControlTargetDescriptor as u, SqlMigrationRunner as v, SqlMigrationRunnerSuccessValue as w, SqlMigrationRunnerExecuteOptions as x, SqlMigrationRunnerErrorCode as y };
|
|
520
|
-
//# sourceMappingURL=types-
|
|
587
|
+
//# sourceMappingURL=types-CkOIJXxU.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-CkOIJXxU.d.mts","names":[],"sources":["../src/core/control-instance.ts","../src/core/migrations/schema-differ.ts","../src/core/migrations/types.ts"],"mappings":";;;;;;;;;;;;;;UAiLU,eAAA;EAAA,SACC,MAAA;EAAA,SACA,QAAA;EAAA,SACA,QAAA;EAAA,SACA,UAAA;AAAA;AAAA,KAGN,uBAAA,GAA0B,GAAG,SAAS,eAAA;AAAA,UAEjC,sBAAA;EAAA,SACC,gBAAA,EAAkB,aAAA,CAAc,eAAA;EAAA,SAChC,YAAA,EAAc,aAAA;EAAA,SACd,oBAAA,EAAsB,uBAAA;AAAA;AAAA,UAGhB,wBAAA,SACP,qBAAA,QAA6B,eAAA,GACnC,iBAAA,CAAkB,eAAA,GAClB,uBAAA,CAAwB,eAAA,GACxB,uBAAA,EACA,sBAAA;EAhBO;;AAAU;AAAA;;;;AAGqC;EAsBxD,mBAAA,CAAoB,YAAA,YAAwB,QAAA;EAE5C,MAAA,CAAO,OAAA;IAAA,SACI,MAAA,EAAQ,wBAAA;IAAA,SACR,QAAA;IAAA,SACA,gBAAA;IAAA,SACA,YAAA;IAAA,SACA,UAAA;EAAA,IACP,OAAA,CAAQ,oBAAA;EAzB0C;;;;;;;;;EAoCtD,YAAA,CAAa,OAAA;IAAA,SACF,QAAA;IAAA,SACA,MAAA,EAAQ,eAAA;IAAA,SACR,MAAA;IAAA,SACA,mBAAA,EAAqB,aAAA,CAAc,8BAAA;EAAA,IAC1C,0BAAA;EAEJ,IAAA,CAAK,OAAA;IAAA,SACM,MAAA,EAAQ,wBAAA;IAAA,SACR,QAAA;IAAA,SACA,YAAA;IAAA,SACA,UAAA;EAAA,IACP,OAAA,CAAQ,kBAAA;EAE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EAAoB,kBAAA,CAAmB,SAAA;EAlTf;;;;;;EAAA,SAyTxB,cAAA,EAAgB,cAAA,CAAe,SAAA,EAAW,WAAA;EA1TA;;;;;EAAA,SAgU1C,gBAAA,IAAoB,MAAA,EAAQ,eAAA,KAAoB,cAAA;EA5T1C;;;;;;;;EAAA,SAqUN,kBAAA,EAAoB,qBAAA;EAzTJ;AAAA;AAU3B;;;;AAEe;EAZY,SAiUhB,oBAAA,EAAsB,uBAAA;EAC/B,aAAA,CAAc,OAAA,EAAS,iBAAA,CAAkB,SAAA,IAAa,mBAAA,CAAoB,cAAA;EAC1E,YAAA,CAAa,MAAA,EAAQ,wBAAA,GAA2B,kBAAA,CAAmB,cAAA;AAAA;AAAA,UAGpD,6BAAA;EAAA,SACN,QAAA;EAtTA;;;EAAA,SA0TA,OAAA;EAAA,SACA,MAAA,GAAS,4BAAA;EAAA,SACT,WAAA,EAAa,4BAAA;EAAA,SACb,UAAA,WAAqB,yBAAA,CAA0B,cAAA;EAxTP;;;;;EAAA,SA8TxC,kBAAA;EAAA,SACA,IAAA,GAAO,SAAA;AAAA"}
|
package/package.json
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma-next/family-sql",
|
|
3
|
-
"version": "0.14.0-dev.
|
|
3
|
+
"version": "0.14.0-dev.40",
|
|
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.
|
|
9
|
+
"@prisma-next/contract": "0.14.0-dev.40",
|
|
10
|
+
"@prisma-next/emitter": "0.14.0-dev.40",
|
|
11
|
+
"@prisma-next/framework-components": "0.14.0-dev.40",
|
|
12
|
+
"@prisma-next/migration-tools": "0.14.0-dev.40",
|
|
13
|
+
"@prisma-next/operations": "0.14.0-dev.40",
|
|
14
|
+
"@prisma-next/sql-contract": "0.14.0-dev.40",
|
|
15
|
+
"@prisma-next/sql-contract-emitter": "0.14.0-dev.40",
|
|
16
|
+
"@prisma-next/sql-contract-ts": "0.14.0-dev.40",
|
|
17
|
+
"@prisma-next/sql-operations": "0.14.0-dev.40",
|
|
18
|
+
"@prisma-next/sql-relational-core": "0.14.0-dev.40",
|
|
19
|
+
"@prisma-next/sql-runtime": "0.14.0-dev.40",
|
|
20
|
+
"@prisma-next/sql-schema-ir": "0.14.0-dev.40",
|
|
21
|
+
"@prisma-next/utils": "0.14.0-dev.40",
|
|
22
22
|
"arktype": "^2.2.0"
|
|
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.
|
|
25
|
+
"@prisma-next/driver-postgres": "0.14.0-dev.40",
|
|
26
|
+
"@prisma-next/psl-parser": "0.14.0-dev.40",
|
|
27
|
+
"@prisma-next/psl-printer": "0.14.0-dev.40",
|
|
28
|
+
"@prisma-next/sql-contract-psl": "0.14.0-dev.40",
|
|
29
|
+
"@prisma-next/test-utils": "0.14.0-dev.40",
|
|
30
|
+
"@prisma-next/tsconfig": "0.14.0-dev.40",
|
|
31
|
+
"@prisma-next/tsdown": "0.14.0-dev.40",
|
|
32
32
|
"tsdown": "0.22.1",
|
|
33
33
|
"typescript": "5.9.3",
|
|
34
34
|
"vitest": "4.1.8"
|
|
@@ -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
|
|
@@ -157,22 +157,27 @@ export interface SqlControlAdapter<TTarget extends string = string>
|
|
|
157
157
|
): Promise<void>;
|
|
158
158
|
|
|
159
159
|
/**
|
|
160
|
-
* Introspects a database schema and returns
|
|
160
|
+
* Introspects a database schema and returns the target's schema-IR node.
|
|
161
161
|
*
|
|
162
162
|
* This is a pure schema discovery operation that queries the database catalog
|
|
163
163
|
* and returns the schema structure without type mapping or contract enrichment.
|
|
164
164
|
* Type mapping and enrichment are handled separately by enrichment helpers.
|
|
165
165
|
*
|
|
166
|
+
* The return type is the family-base `SqlSchemaIRNode` so each target returns
|
|
167
|
+
* its own node shape: SQLite returns a flat `SqlSchemaIR`, Postgres returns a
|
|
168
|
+
* `PostgresDatabaseSchemaNode` tree root. Consumers `ensure` the concrete
|
|
169
|
+
* target type before walking it.
|
|
170
|
+
*
|
|
166
171
|
* @param driver - ControlDriverInstance instance for executing queries (target-specific)
|
|
167
172
|
* @param contract - Optional contract for contract-guided introspection (filtering, optimization)
|
|
168
173
|
* @param schema - Schema name to introspect (defaults to 'public')
|
|
169
|
-
* @returns Promise resolving to
|
|
174
|
+
* @returns Promise resolving to the live database schema node
|
|
170
175
|
*/
|
|
171
176
|
introspect(
|
|
172
177
|
driver: SqlControlDriverInstance<TTarget>,
|
|
173
178
|
contract?: unknown,
|
|
174
179
|
schema?: string,
|
|
175
|
-
): Promise<
|
|
180
|
+
): Promise<SqlSchemaIRNode>;
|
|
176
181
|
|
|
177
182
|
/**
|
|
178
183
|
* Optional target-specific normalizer for raw database default expressions.
|