@prisma-next/family-sql 0.12.0-dev.2 → 0.12.0-dev.20
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-adapter-8tV9WgWK.d.mts +134 -0
- package/dist/control-adapter-8tV9WgWK.d.mts.map +1 -0
- package/dist/control-adapter.d.mts +2 -109
- package/dist/control.d.mts +31 -3
- package/dist/control.d.mts.map +1 -1
- package/dist/control.mjs +62 -14
- package/dist/control.mjs.map +1 -1
- package/dist/migration.d.mts +1 -1
- package/dist/runtime.d.mts +3 -1
- package/dist/runtime.d.mts.map +1 -1
- package/dist/runtime.mjs +3 -1
- package/dist/runtime.mjs.map +1 -1
- package/dist/schema-verify.d.mts +2 -1
- package/dist/schema-verify.d.mts.map +1 -1
- package/dist/schema-verify.mjs +1 -1
- package/dist/{types-CeeCStqw.d.mts → types-BQiqw6kR.d.mts} +14 -5
- package/dist/types-BQiqw6kR.d.mts.map +1 -0
- package/dist/{verify-sql-schema-CYLsGCFO.mjs → verify-sql-schema-CXW_D9dW.mjs} +403 -310
- package/dist/verify-sql-schema-CXW_D9dW.mjs.map +1 -0
- package/dist/{verify-sql-schema-CN7pPoTC.d.mts → verify-sql-schema-Cj3c2t5Z.d.mts} +8 -2
- package/dist/verify-sql-schema-Cj3c2t5Z.d.mts.map +1 -0
- package/package.json +21 -21
- package/src/core/control-adapter.ts +44 -3
- package/src/core/control-instance.ts +40 -41
- package/src/core/default-namespace.ts +9 -0
- package/src/core/migrations/control-policy.ts +89 -0
- package/src/core/migrations/types.ts +8 -1
- package/src/core/schema-verify/control-verify-emit.ts +46 -0
- package/src/core/schema-verify/verifier-disposition.ts +53 -0
- package/src/core/schema-verify/verify-helpers.ts +151 -110
- package/src/core/schema-verify/verify-sql-schema.ts +291 -155
- package/src/exports/control.ts +2 -0
- package/src/exports/runtime.ts +7 -0
- package/dist/control-adapter.d.mts.map +0 -1
- package/dist/types-CeeCStqw.d.mts.map +0 -1
- package/dist/verify-sql-schema-CN7pPoTC.d.mts.map +0 -1
- package/dist/verify-sql-schema-CYLsGCFO.mjs.map +0 -1
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { n as DefaultNormalizer, r as NativeTypeNormalizer, t as ColumnsCompatible } from "./verify-sql-schema-Cj3c2t5Z.mjs";
|
|
2
|
+
import { ControlAdapterInstance, ControlDriverInstance, ControlStack } from "@prisma-next/framework-components/control";
|
|
3
|
+
import { PostgresEnumStorageEntry, SqlStorage } from "@prisma-next/sql-contract/types";
|
|
4
|
+
import { Contract, ContractMarkerRecord, LedgerEntryRecord } from "@prisma-next/contract/types";
|
|
5
|
+
import { AnyQueryAst, DdlNode, LoweredStatement, LowererContext } from "@prisma-next/sql-relational-core/ast";
|
|
6
|
+
import { SqlSchemaIR } from "@prisma-next/sql-schema-ir/types";
|
|
7
|
+
|
|
8
|
+
//#region src/core/control-adapter.d.ts
|
|
9
|
+
/**
|
|
10
|
+
* SQL control adapter interface for control-plane operations.
|
|
11
|
+
* Implemented by target-specific adapters (e.g., Postgres, MySQL).
|
|
12
|
+
*
|
|
13
|
+
* @template TTarget - The target ID (e.g., 'postgres', 'mysql')
|
|
14
|
+
*/
|
|
15
|
+
interface SqlControlAdapter<TTarget extends string = string> extends ControlAdapterInstance<'sql', TTarget> {
|
|
16
|
+
/**
|
|
17
|
+
* Reads the contract marker for `space` from the database, returning
|
|
18
|
+
* `null` if no marker row exists for that space (or if the marker
|
|
19
|
+
* table itself is missing). Implementations are responsible for the
|
|
20
|
+
* dialect-specific existence probe (e.g. Postgres
|
|
21
|
+
* `information_schema.tables` vs SQLite `sqlite_master`) and parameter
|
|
22
|
+
* placeholders.
|
|
23
|
+
*
|
|
24
|
+
* `space` is required so callers cannot accidentally fall through to
|
|
25
|
+
* the app's marker row when reading per-extension markers.
|
|
26
|
+
*
|
|
27
|
+
* @param driver - ControlDriverInstance for executing queries (target-specific)
|
|
28
|
+
* @param space - Contract space id whose marker row to read (e.g. `'app'`)
|
|
29
|
+
* @returns Resolved marker record, or `null` if not yet stamped.
|
|
30
|
+
*/
|
|
31
|
+
readMarker(driver: ControlDriverInstance<'sql', TTarget>, space: string): Promise<ContractMarkerRecord | null>;
|
|
32
|
+
/**
|
|
33
|
+
* Reads every marker row from `prisma_contract.marker` (one per
|
|
34
|
+
* contract space) and returns them keyed by `space`. Used by the
|
|
35
|
+
* per-space verifier to detect marker-vs-on-disk drift and orphan
|
|
36
|
+
* marker rows. Returns an empty map when the marker table does not
|
|
37
|
+
* yet exist (fresh database / never-signed project).
|
|
38
|
+
*/
|
|
39
|
+
readAllMarkers(driver: ControlDriverInstance<'sql', TTarget>): Promise<ReadonlyMap<string, ContractMarkerRecord>>;
|
|
40
|
+
/**
|
|
41
|
+
* Reads the per-migration ledger journal for `space` in apply order.
|
|
42
|
+
* Returns an empty array when the ledger store does not yet exist or
|
|
43
|
+
* has no rows for that space.
|
|
44
|
+
*/
|
|
45
|
+
readLedger(driver: ControlDriverInstance<'sql', TTarget>, space: string): Promise<readonly LedgerEntryRecord[]>;
|
|
46
|
+
/**
|
|
47
|
+
* Introspects a database schema and returns a raw SqlSchemaIR.
|
|
48
|
+
*
|
|
49
|
+
* This is a pure schema discovery operation that queries the database catalog
|
|
50
|
+
* and returns the schema structure without type mapping or contract enrichment.
|
|
51
|
+
* Type mapping and enrichment are handled separately by enrichment helpers.
|
|
52
|
+
*
|
|
53
|
+
* @param driver - ControlDriverInstance instance for executing queries (target-specific)
|
|
54
|
+
* @param contract - Optional contract for contract-guided introspection (filtering, optimization)
|
|
55
|
+
* @param schema - Schema name to introspect (defaults to 'public')
|
|
56
|
+
* @returns Promise resolving to SqlSchemaIR representing the live database schema
|
|
57
|
+
*/
|
|
58
|
+
introspect(driver: ControlDriverInstance<'sql', TTarget>, contract?: unknown, schema?: string): Promise<SqlSchemaIR>;
|
|
59
|
+
/**
|
|
60
|
+
* Optional target-specific normalizer for raw database default expressions.
|
|
61
|
+
* When provided, schema defaults (raw strings) are normalized before comparison
|
|
62
|
+
* with contract defaults (ColumnDefault objects) during schema verification.
|
|
63
|
+
*/
|
|
64
|
+
readonly normalizeDefault?: DefaultNormalizer;
|
|
65
|
+
/**
|
|
66
|
+
* Optional target-specific normalizer for schema native type names.
|
|
67
|
+
* When provided, schema native types (from introspection) are normalized
|
|
68
|
+
* before comparison with contract native types during schema verification.
|
|
69
|
+
*/
|
|
70
|
+
readonly normalizeNativeType?: NativeTypeNormalizer;
|
|
71
|
+
/**
|
|
72
|
+
* Optional target-supplied compatible-shape relation for column native types.
|
|
73
|
+
* When provided, schema verification uses it under the `external` control
|
|
74
|
+
* policy to decide whether a declared column type is compatible with the
|
|
75
|
+
* live type (instead of exact equality). Threading the same relation the
|
|
76
|
+
* migration planner/runner use keeps runtime verify and migration verify in
|
|
77
|
+
* agreement; when omitted, verification falls back to exact equality.
|
|
78
|
+
*/
|
|
79
|
+
readonly columnsCompatible?: ColumnsCompatible;
|
|
80
|
+
/**
|
|
81
|
+
* Optional bridging adapter for resolving the existing values of a
|
|
82
|
+
* native enum type from the introspected schema IR. Targets supply
|
|
83
|
+
* this so the family-level schema verifier can walk
|
|
84
|
+
* `PostgresEnumStorageEntry` entries natively without needing to
|
|
85
|
+
* know the target-specific `schema.annotations` shape
|
|
86
|
+
* (e.g. `schema.annotations.pg.storageTypes`).
|
|
87
|
+
*/
|
|
88
|
+
readonly resolveExistingEnumValues?: (schema: SqlSchemaIR, enumType: PostgresEnumStorageEntry, namespaceId: string) => readonly string[] | null;
|
|
89
|
+
/**
|
|
90
|
+
* Optional contract-scoped factory for {@link resolveExistingEnumValues}.
|
|
91
|
+
* Targets that need the contract storage to resolve namespace → DDL schema
|
|
92
|
+
* supply this; the family control instance prefers it over the bare adapter
|
|
93
|
+
* hook when present.
|
|
94
|
+
*/
|
|
95
|
+
readonly resolveExistingEnumValuesForContract?: (contract: Contract<SqlStorage>) => (schema: SqlSchemaIR, enumType: PostgresEnumStorageEntry, namespaceId: string) => readonly string[] | null;
|
|
96
|
+
/**
|
|
97
|
+
* Ordered DDL queries that bootstrap marker/ledger control tables for migration
|
|
98
|
+
* runners. Postgres includes `CREATE SCHEMA`; SQLite does not.
|
|
99
|
+
*/
|
|
100
|
+
bootstrapControlTableQueries(): readonly DdlNode[];
|
|
101
|
+
/**
|
|
102
|
+
* Ordered DDL queries that bootstrap the marker table (and Postgres schema) for
|
|
103
|
+
* `sign` — excludes the ledger table.
|
|
104
|
+
*/
|
|
105
|
+
bootstrapSignMarkerQueries(): readonly DdlNode[];
|
|
106
|
+
/**
|
|
107
|
+
* Lower a SQL query AST into a target-flavored `{ sql, params }` payload.
|
|
108
|
+
*
|
|
109
|
+
* Migration tooling (e.g. the `dataTransform` operation) needs to materialize
|
|
110
|
+
* SQL at emit/plan time without instantiating the runtime adapter. The control
|
|
111
|
+
* adapter's `lower` is byte-equivalent to the runtime adapter's `lower` for the
|
|
112
|
+
* same AST and contract, ensuring planned SQL matches what the runtime would
|
|
113
|
+
* emit.
|
|
114
|
+
*/
|
|
115
|
+
lower(ast: AnyQueryAst | DdlNode, context: LowererContext<unknown>): LoweredStatement;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* SQL control adapter descriptor interface.
|
|
119
|
+
* Provides a factory method to create control adapter instances.
|
|
120
|
+
*
|
|
121
|
+
* @template TTarget - The target ID (e.g., 'postgres', 'mysql')
|
|
122
|
+
*/
|
|
123
|
+
interface SqlControlAdapterDescriptor<TTarget extends string = string> {
|
|
124
|
+
/**
|
|
125
|
+
* Creates a SQL control adapter instance for control-plane operations.
|
|
126
|
+
*
|
|
127
|
+
* Receives the assembled `ControlStack` so adapters can read aggregated
|
|
128
|
+
* metadata (codec lookup, extension contributions) when materializing.
|
|
129
|
+
*/
|
|
130
|
+
create(stack: ControlStack<'sql', TTarget>): SqlControlAdapter<TTarget>;
|
|
131
|
+
}
|
|
132
|
+
//#endregion
|
|
133
|
+
export { SqlControlAdapterDescriptor as n, SqlControlAdapter as t };
|
|
134
|
+
//# sourceM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;;;;EAA9D,MAAA,CAAO,KAAA,EAAO,YAAA,QAAoB,OAAA,IAAW,iBAAA,CAAkB,OAAA;AAAA"}
|
|
@@ -1,109 +1,2 @@
|
|
|
1
|
-
import { n as
|
|
2
|
-
|
|
3
|
-
import { PostgresEnumStorageEntry, SqlStorage } from "@prisma-next/sql-contract/types";
|
|
4
|
-
import { Contract, ContractMarkerRecord } from "@prisma-next/contract/types";
|
|
5
|
-
import { AnyQueryAst, LoweredStatement, LowererContext } from "@prisma-next/sql-relational-core/ast";
|
|
6
|
-
import { SqlSchemaIR } from "@prisma-next/sql-schema-ir/types";
|
|
7
|
-
|
|
8
|
-
//#region src/core/control-adapter.d.ts
|
|
9
|
-
/**
|
|
10
|
-
* SQL control adapter interface for control-plane operations.
|
|
11
|
-
* Implemented by target-specific adapters (e.g., Postgres, MySQL).
|
|
12
|
-
*
|
|
13
|
-
* @template TTarget - The target ID (e.g., 'postgres', 'mysql')
|
|
14
|
-
*/
|
|
15
|
-
interface SqlControlAdapter<TTarget extends string = string> extends ControlAdapterInstance<'sql', TTarget> {
|
|
16
|
-
/**
|
|
17
|
-
* Reads the contract marker for `space` from the database, returning
|
|
18
|
-
* `null` if no marker row exists for that space (or if the marker
|
|
19
|
-
* table itself is missing). Implementations are responsible for the
|
|
20
|
-
* dialect-specific existence probe (e.g. Postgres
|
|
21
|
-
* `information_schema.tables` vs SQLite `sqlite_master`) and parameter
|
|
22
|
-
* placeholders.
|
|
23
|
-
*
|
|
24
|
-
* `space` is required so callers cannot accidentally fall through to
|
|
25
|
-
* the app's marker row when reading per-extension markers.
|
|
26
|
-
*
|
|
27
|
-
* @param driver - ControlDriverInstance for executing queries (target-specific)
|
|
28
|
-
* @param space - Contract space id whose marker row to read (e.g. `'app'`)
|
|
29
|
-
* @returns Resolved marker record, or `null` if not yet stamped.
|
|
30
|
-
*/
|
|
31
|
-
readMarker(driver: ControlDriverInstance<'sql', TTarget>, space: string): Promise<ContractMarkerRecord | null>;
|
|
32
|
-
/**
|
|
33
|
-
* Reads every marker row from `prisma_contract.marker` (one per
|
|
34
|
-
* contract space) and returns them keyed by `space`. Used by the
|
|
35
|
-
* per-space verifier to detect marker-vs-on-disk drift and orphan
|
|
36
|
-
* marker rows. Returns an empty map when the marker table does not
|
|
37
|
-
* yet exist (fresh database / never-signed project).
|
|
38
|
-
*/
|
|
39
|
-
readAllMarkers(driver: ControlDriverInstance<'sql', TTarget>): Promise<ReadonlyMap<string, ContractMarkerRecord>>;
|
|
40
|
-
/**
|
|
41
|
-
* Introspects a database schema and returns a raw SqlSchemaIR.
|
|
42
|
-
*
|
|
43
|
-
* This is a pure schema discovery operation that queries the database catalog
|
|
44
|
-
* and returns the schema structure without type mapping or contract enrichment.
|
|
45
|
-
* Type mapping and enrichment are handled separately by enrichment helpers.
|
|
46
|
-
*
|
|
47
|
-
* @param driver - ControlDriverInstance instance for executing queries (target-specific)
|
|
48
|
-
* @param contract - Optional contract for contract-guided introspection (filtering, optimization)
|
|
49
|
-
* @param schema - Schema name to introspect (defaults to 'public')
|
|
50
|
-
* @returns Promise resolving to SqlSchemaIR representing the live database schema
|
|
51
|
-
*/
|
|
52
|
-
introspect(driver: ControlDriverInstance<'sql', TTarget>, contract?: unknown, schema?: string): Promise<SqlSchemaIR>;
|
|
53
|
-
/**
|
|
54
|
-
* Optional target-specific normalizer for raw database default expressions.
|
|
55
|
-
* When provided, schema defaults (raw strings) are normalized before comparison
|
|
56
|
-
* with contract defaults (ColumnDefault objects) during schema verification.
|
|
57
|
-
*/
|
|
58
|
-
readonly normalizeDefault?: DefaultNormalizer;
|
|
59
|
-
/**
|
|
60
|
-
* Optional target-specific normalizer for schema native type names.
|
|
61
|
-
* When provided, schema native types (from introspection) are normalized
|
|
62
|
-
* before comparison with contract native types during schema verification.
|
|
63
|
-
*/
|
|
64
|
-
readonly normalizeNativeType?: NativeTypeNormalizer;
|
|
65
|
-
/**
|
|
66
|
-
* Optional bridging adapter for resolving the existing values of a
|
|
67
|
-
* native enum type from the introspected schema IR. Targets supply
|
|
68
|
-
* this so the family-level schema verifier can walk
|
|
69
|
-
* `PostgresEnumStorageEntry` entries natively without needing to
|
|
70
|
-
* know the target-specific `schema.annotations` shape
|
|
71
|
-
* (e.g. `schema.annotations.pg.storageTypes`).
|
|
72
|
-
*/
|
|
73
|
-
readonly resolveExistingEnumValues?: (schema: SqlSchemaIR, enumType: PostgresEnumStorageEntry, namespaceId: string) => readonly string[] | null;
|
|
74
|
-
/**
|
|
75
|
-
* Optional contract-scoped factory for {@link resolveExistingEnumValues}.
|
|
76
|
-
* Targets that need the contract storage to resolve namespace → DDL schema
|
|
77
|
-
* supply this; the family control instance prefers it over the bare adapter
|
|
78
|
-
* hook when present.
|
|
79
|
-
*/
|
|
80
|
-
readonly resolveExistingEnumValuesForContract?: (contract: Contract<SqlStorage>) => (schema: SqlSchemaIR, enumType: PostgresEnumStorageEntry, namespaceId: string) => readonly string[] | null;
|
|
81
|
-
/**
|
|
82
|
-
* Lower a SQL query AST into a target-flavored `{ sql, params }` payload.
|
|
83
|
-
*
|
|
84
|
-
* Migration tooling (e.g. the `dataTransform` operation) needs to materialize
|
|
85
|
-
* SQL at emit/plan time without instantiating the runtime adapter. The control
|
|
86
|
-
* adapter's `lower` is byte-equivalent to the runtime adapter's `lower` for the
|
|
87
|
-
* same AST and contract, ensuring planned SQL matches what the runtime would
|
|
88
|
-
* emit.
|
|
89
|
-
*/
|
|
90
|
-
lower(ast: AnyQueryAst, context: LowererContext<unknown>): LoweredStatement;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* SQL control adapter descriptor interface.
|
|
94
|
-
* Provides a factory method to create control adapter instances.
|
|
95
|
-
*
|
|
96
|
-
* @template TTarget - The target ID (e.g., 'postgres', 'mysql')
|
|
97
|
-
*/
|
|
98
|
-
interface SqlControlAdapterDescriptor<TTarget extends string = string> {
|
|
99
|
-
/**
|
|
100
|
-
* Creates a SQL control adapter instance for control-plane operations.
|
|
101
|
-
*
|
|
102
|
-
* Receives the assembled `ControlStack` so adapters can read aggregated
|
|
103
|
-
* metadata (codec lookup, extension contributions) when materializing.
|
|
104
|
-
*/
|
|
105
|
-
create(stack: ControlStack<'sql', TTarget>): SqlControlAdapter<TTarget>;
|
|
106
|
-
}
|
|
107
|
-
//#endregion
|
|
108
|
-
export { type SqlControlAdapter, type SqlControlAdapterDescriptor };
|
|
109
|
-
//# sourceMappingURL=control-adapter.d.mts.map
|
|
1
|
+
import { n as SqlControlAdapterDescriptor, t as SqlControlAdapter } from "./control-adapter-8tV9WgWK.mjs";
|
|
2
|
+
export { type SqlControlAdapter, type SqlControlAdapterDescriptor };
|
package/dist/control.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { A as SqlPlannerResult, C as SqlMigrationRunnerResult, D as SqlPlannerConflictKind, E as SqlPlannerConflict, M as StorageTypePlanResult, N as SqlControlFamilyInstance, O as SqlPlannerConflictLocation, S as SqlMigrationRunnerFailure, T as SqlPlanTargetDetails, _ as SqlMigrationPlannerPlanOptions, a as FieldEvent, b as SqlMigrationRunnerExecuteCallbacks, c as SqlControlAdapterDescriptor, d as SqlMigrationPlan, f as SqlMigrationPlanContractInfo, g as SqlMigrationPlanner, h as SqlMigrationPlanOperationTarget, i as ExpandNativeTypeInput, j as SqlPlannerSuccessResult, k as SqlPlannerFailureResult, l as SqlControlExtensionDescriptor, m as SqlMigrationPlanOperationStep, n as CodecControlHooks, o as FieldEventContext, p as SqlMigrationPlanOperation, r as CreateSqlMigrationPlanOptions, s as ResolveIdentityValueInput, t as AnyRecord, u as SqlControlTargetDescriptor, v as SqlMigrationRunner, w as SqlMigrationRunnerSuccessValue, x as SqlMigrationRunnerExecuteOptions, y as SqlMigrationRunnerErrorCode } from "./types-
|
|
1
|
+
import { A as SqlPlannerResult, C as SqlMigrationRunnerResult, D as SqlPlannerConflictKind, E as SqlPlannerConflict, M as StorageTypePlanResult, N as SqlControlFamilyInstance, O as SqlPlannerConflictLocation, S as SqlMigrationRunnerFailure, T as SqlPlanTargetDetails, _ as SqlMigrationPlannerPlanOptions, a as FieldEvent, b as SqlMigrationRunnerExecuteCallbacks, c as SqlControlAdapterDescriptor, d as SqlMigrationPlan, f as SqlMigrationPlanContractInfo, g as SqlMigrationPlanner, h as SqlMigrationPlanOperationTarget, i as ExpandNativeTypeInput, j as SqlPlannerSuccessResult, k as SqlPlannerFailureResult, l as SqlControlExtensionDescriptor, m as SqlMigrationPlanOperationStep, n as CodecControlHooks, o as FieldEventContext, p as SqlMigrationPlanOperation, r as CreateSqlMigrationPlanOptions, s as ResolveIdentityValueInput, t as AnyRecord, u as SqlControlTargetDescriptor, v as SqlMigrationRunner, w as SqlMigrationRunnerSuccessValue, x as SqlMigrationRunnerExecuteOptions, y as SqlMigrationRunnerErrorCode } from "./types-BQiqw6kR.mjs";
|
|
2
2
|
import { ControlFamilyDescriptor, ControlStack, MigrationOperationClass, MigrationOperationPolicy, MigrationOperationPolicy as MigrationOperationPolicy$1, MigrationPlan, MigrationPlanOperation, MigrationPlanner, MigrationPlannerConflict, MigrationPlannerConflict as MigrationPlannerConflict$1, MigrationPlannerResult, MutationDefaultGeneratorDescriptor, OpFactoryCall, TargetMigrationsCapability, assembleAuthoringContributions } from "@prisma-next/framework-components/control";
|
|
3
3
|
import { SqlStorage, StorageColumn } from "@prisma-next/sql-contract/types";
|
|
4
|
+
import { ColumnDefault, Contract, ControlPolicy } from "@prisma-next/contract/types";
|
|
4
5
|
import { NotOk, Ok } from "@prisma-next/utils/result";
|
|
5
|
-
import { ColumnDefault, Contract } from "@prisma-next/contract/types";
|
|
6
6
|
import { SqlSchemaIR } from "@prisma-next/sql-schema-ir/types";
|
|
7
7
|
import { TargetBoundComponentDescriptor } from "@prisma-next/framework-components/components";
|
|
8
8
|
import { EmissionSpi } from "@prisma-next/framework-components/emission";
|
|
@@ -325,6 +325,34 @@ interface ContractToSchemaIROptions {
|
|
|
325
325
|
*/
|
|
326
326
|
declare function contractToSchemaIR(contract: Contract<SqlStorage> | null, options: ContractToSchemaIROptions): SqlSchemaIR;
|
|
327
327
|
//#endregion
|
|
328
|
+
//#region src/core/migrations/control-policy.d.ts
|
|
329
|
+
/**
|
|
330
|
+
* The target object a control policy governs for a single planner call,
|
|
331
|
+
* resolved from the target's own IR. `undefined` means the call's target
|
|
332
|
+
* object could not be positively established — a fail-closed signal: any
|
|
333
|
+
* policy stricter than `managed` drops such a call rather than emitting it.
|
|
334
|
+
*/
|
|
335
|
+
interface ControlPolicySubject {
|
|
336
|
+
readonly namespaceId: string;
|
|
337
|
+
readonly explicitNodeControlPolicy?: ControlPolicy;
|
|
338
|
+
readonly table?: string;
|
|
339
|
+
readonly column?: string;
|
|
340
|
+
readonly typeName?: string;
|
|
341
|
+
/**
|
|
342
|
+
* Whether the call creates a whole, previously-absent top-level storage
|
|
343
|
+
* object (e.g. a table or an enum/type), as opposed to modifying an
|
|
344
|
+
* existing object. This is the only thing `tolerated` permits: it is a
|
|
345
|
+
* create-if-absent policy, so an op that touches an existing object — add
|
|
346
|
+
* column, add index/constraint, alter, drop — is never allowed under it.
|
|
347
|
+
*/
|
|
348
|
+
readonly createsNewObject: boolean;
|
|
349
|
+
}
|
|
350
|
+
declare function filterCallsByControlPolicy<TCall>(options: {
|
|
351
|
+
readonly calls: readonly TCall[];
|
|
352
|
+
readonly contract: Contract<SqlStorage>;
|
|
353
|
+
readonly resolveControlPolicySubject: (call: TCall) => ControlPolicySubject | undefined;
|
|
354
|
+
}): readonly TCall[];
|
|
355
|
+
//#endregion
|
|
328
356
|
//#region src/core/migrations/field-event-planner.d.ts
|
|
329
357
|
interface PlanFieldEventOperationsOptions {
|
|
330
358
|
/**
|
|
@@ -434,5 +462,5 @@ declare function temporalAuthoringPresets<const CodecId extends string, const Na
|
|
|
434
462
|
//#region src/exports/control.d.ts
|
|
435
463
|
declare const _default: SqlFamilyDescriptor;
|
|
436
464
|
//#endregion
|
|
437
|
-
export { type CodecControlHooks, type ContractToSchemaIROptions, type CreateSqlMigrationPlanOptions, type DefaultRenderer, type EnumStorageKeyResolver, type ExpandNativeTypeInput, type FieldEvent, type FieldEventContext, INIT_ADDITIVE_POLICY, type MigrationOperationClass, type MigrationOperationPolicy, type MigrationPlan, type MigrationPlanOperation, type MigrationPlanner, type MigrationPlannerConflict, type MigrationPlannerResult, type NativeTypeExpander, type PlanFieldEventOperationsOptions, type ResolveIdentityValueInput, type SqlControlAdapterDescriptor, type SqlControlExtensionDescriptor, type SqlControlFamilyInstance, type SqlControlTargetDescriptor, type SqlMigrationPlan, type SqlMigrationPlanContractInfo, type SqlMigrationPlanOperation, type SqlMigrationPlanOperationStep, type SqlMigrationPlanOperationTarget, type SqlMigrationPlanner, type SqlMigrationPlannerPlanOptions, type SqlMigrationRunner, type SqlMigrationRunnerErrorCode, type SqlMigrationRunnerExecuteCallbacks, type SqlMigrationRunnerExecuteOptions, type SqlMigrationRunnerFailure, type SqlMigrationRunnerResult, type SqlMigrationRunnerSuccessValue, type SqlPlanTargetDetails, type SqlPlannerConflict, type SqlPlannerConflictKind, type SqlPlannerConflictLocation, type SqlPlannerFailureResult, type SqlPlannerResult, type SqlPlannerSuccessResult, type StorageTypePlanResult, type TargetMigrationsCapability, assembleAuthoringContributions, contractToSchemaIR, createMigrationPlan, _default as default, detectDestructiveChanges, extractCodecControlHooks, planFieldEventOperations, plannerFailure, plannerSuccess, runnerFailure, runnerSuccess, temporalAuthoringPresets, timestampNowControlDescriptor };
|
|
465
|
+
export { type CodecControlHooks, type ContractToSchemaIROptions, type ControlPolicySubject, type CreateSqlMigrationPlanOptions, type DefaultRenderer, type EnumStorageKeyResolver, type ExpandNativeTypeInput, type FieldEvent, type FieldEventContext, INIT_ADDITIVE_POLICY, type MigrationOperationClass, type MigrationOperationPolicy, type MigrationPlan, type MigrationPlanOperation, type MigrationPlanner, type MigrationPlannerConflict, type MigrationPlannerResult, type NativeTypeExpander, type PlanFieldEventOperationsOptions, type ResolveIdentityValueInput, type SqlControlAdapterDescriptor, type SqlControlExtensionDescriptor, type SqlControlFamilyInstance, type SqlControlTargetDescriptor, type SqlMigrationPlan, type SqlMigrationPlanContractInfo, type SqlMigrationPlanOperation, type SqlMigrationPlanOperationStep, type SqlMigrationPlanOperationTarget, type SqlMigrationPlanner, type SqlMigrationPlannerPlanOptions, type SqlMigrationRunner, type SqlMigrationRunnerErrorCode, type SqlMigrationRunnerExecuteCallbacks, type SqlMigrationRunnerExecuteOptions, type SqlMigrationRunnerFailure, type SqlMigrationRunnerResult, type SqlMigrationRunnerSuccessValue, type SqlPlanTargetDetails, type SqlPlannerConflict, type SqlPlannerConflictKind, type SqlPlannerConflictLocation, type SqlPlannerFailureResult, type SqlPlannerResult, type SqlPlannerSuccessResult, type StorageTypePlanResult, type TargetMigrationsCapability, assembleAuthoringContributions, contractToSchemaIR, createMigrationPlan, _default as default, detectDestructiveChanges, extractCodecControlHooks, filterCallsByControlPolicy, planFieldEventOperations, plannerFailure, plannerSuccess, runnerFailure, runnerSuccess, temporalAuthoringPresets, timestampNowControlDescriptor };
|
|
438
466
|
//# sourceMappingURL=control.d.mts.map
|
package/dist/control.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"control.d.mts","names":[],"sources":["../src/core/control-descriptor.ts","../src/core/assembly.ts","../src/core/migrations/contract-to-schema-ir.ts","../src/core/migrations/field-event-planner.ts","../src/core/migrations/plan-helpers.ts","../src/core/migrations/policies.ts","../src/core/timestamp-now-generator.ts","../src/exports/control.ts"],"mappings":";;;;;;;;;;cAUa,mBAAA,YACA,uBAAA,QAA+B,wBAAA;EAAA,SAEjC,IAAA;EAAA,SACA,EAAA;EAAA,SACA,QAAA;EAAA,SACA,OAAA;EAAA,SACA,QAAA,EAAU,WAAA;EAAA,SACV,SAAA;IAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAKT,MAAA,0BAAA,CACE,KAAA,EAAO,YAAA,QAAoB,SAAA,IAC1B,wBAAA;AAAA;;;iBCHW,wBAAA,CACd,WAAA,EAAa,aAAA,CAAc,8BAAA,mBAC1B,GAAA,SAAY,iBAAA;;;;;;;;;ADdf;;;;KE4BY,kBAAA,IAAsB,KAAA;EAAA,SACvB,UAAA;EAAA,SACA,OAAA;EAAA,SACA,UAAA,GAAa,MAAM;AAAA;;;;;;;;;;KAYlB,eAAA,IAAmB,GAAA,EAAK,aAAA,EAAe,MAAA,EAAQ,aAAa;;;;;;;;;;;;;;;KAgB5D,sBAAA,IACV,OAAA,EAAS,UAAU,EACnB,WAAA,UACA,UAAA;;;;;;;;;;iBAmKc,wBAAA,CACd,IAAA,EAAM,UAAA,SACN,EAAA,EAAI,UAAA,YACM,0BAAA;AAAA,UA8CK,yBAAA;EAAA,SACN,mBAAA;EAAA,SACA,gBAAA,GAAmB,kBAAA;EAAA,SACnB,aAAA,GAAgB,eAAA;;;;;;;;WAQhB,qBAAA,GAAwB,sBAAA;AAAA;;;;;;;;;;;;;;;iBAiBnB,kBAAA,CACd,QAAA,EAAU,QAAA,CAAS,UAAA,UACnB,OAAA,EAAS,yBAAA,GACR,WAAA;;;
|
|
1
|
+
{"version":3,"file":"control.d.mts","names":[],"sources":["../src/core/control-descriptor.ts","../src/core/assembly.ts","../src/core/migrations/contract-to-schema-ir.ts","../src/core/migrations/control-policy.ts","../src/core/migrations/field-event-planner.ts","../src/core/migrations/plan-helpers.ts","../src/core/migrations/policies.ts","../src/core/timestamp-now-generator.ts","../src/exports/control.ts"],"mappings":";;;;;;;;;;cAUa,mBAAA,YACA,uBAAA,QAA+B,wBAAA;EAAA,SAEjC,IAAA;EAAA,SACA,EAAA;EAAA,SACA,QAAA;EAAA,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ilyAuthoringFieldPresets, t as sqlFamilyAuthoringTypes } from "./authoring-type-constructors-F4JpCJl7.mjs";
|
|
2
2
|
import { t as SqlContractSerializer } from "./sql-contract-serializer-8axtK4lg.mjs";
|
|
3
|
-
import { a as extractCodecControlHooks, t as verifySqlSchema } from "./verify-sql-schema-
|
|
3
|
+
import { a as extractCodecControlHooks, t as verifySqlSchema } from "./verify-sql-schema-CXW_D9dW.mjs";
|
|
4
4
|
import { t as collectSupportedCodecTypeIds } from "./verify-Crewz6hG.mjs";
|
|
5
5
|
import { n as temporalAuthoringPresets, r as timestampNowControlDescriptor } from "./timestamp-now-generator-BkjCQIde.mjs";
|
|
6
6
|
import { sqlEmission } from "@prisma-next/sql-contract-emitter";
|
|
7
7
|
import { APP_SPACE_ID, SchemaTreeNode, VERIFY_CODE_HASH_MISMATCH, VERIFY_CODE_MARKER_MISSING, VERIFY_CODE_TARGET_MISMATCH, assembleAuthoringContributions } from "@prisma-next/framework-components/control";
|
|
8
8
|
import { assertDescriptorSelfConsistency } from "@prisma-next/migration-tools/spaces";
|
|
9
9
|
import { sqlContractCanonicalizationHooks } from "@prisma-next/sql-contract/canonicalization-hooks";
|
|
10
|
-
import {
|
|
10
|
+
import { writeContractMarker } from "@prisma-next/sql-runtime";
|
|
11
11
|
import { defaultIndexName } from "@prisma-next/sql-schema-ir/naming";
|
|
12
12
|
import { ifDefined } from "@prisma-next/utils/defined";
|
|
13
13
|
import { UNBOUND_NAMESPACE_ID } from "@prisma-next/framework-components/ir";
|
|
14
14
|
import { StorageTable, isPostgresEnumStorageEntry, isStorageTypeInstance, toStorageTypeInstance } from "@prisma-next/sql-contract/types";
|
|
15
15
|
import { UNSPECIFIED_PSL_NAMESPACE_ID } from "@prisma-next/framework-components/psl-ast";
|
|
16
|
+
import { effectiveControlPolicy } from "@prisma-next/contract/types";
|
|
16
17
|
import { notOk, ok } from "@prisma-next/utils/result";
|
|
17
18
|
//#region src/core/operation-preview.ts
|
|
18
19
|
function isDdlStatement(sqlStatement) {
|
|
@@ -1057,9 +1058,6 @@ function createVerifyResult(options) {
|
|
|
1057
1058
|
if (options.codecCoverageSkipped) result.codecCoverageSkipped = options.codecCoverageSkipped;
|
|
1058
1059
|
return result;
|
|
1059
1060
|
}
|
|
1060
|
-
function isSqlControlAdapter(value) {
|
|
1061
|
-
return typeof value === "object" && value !== null && "introspect" in value && typeof value.introspect === "function" && "readMarker" in value && typeof value.readMarker === "function" && "readAllMarkers" in value && typeof value.readAllMarkers === "function" && "lower" in value && typeof value.lower === "function";
|
|
1062
|
-
}
|
|
1063
1061
|
function buildSqlTypeMetadataRegistry(options) {
|
|
1064
1062
|
const { target, adapter, extensionPacks: extensions } = options;
|
|
1065
1063
|
const registry = /* @__PURE__ */ new Map();
|
|
@@ -1103,11 +1101,7 @@ function createSqlFamilyInstance(stack) {
|
|
|
1103
1101
|
adapter,
|
|
1104
1102
|
extensionPacks: extensions
|
|
1105
1103
|
});
|
|
1106
|
-
const getControlAdapter = () =>
|
|
1107
|
-
const controlAdapter = adapter.create(stack);
|
|
1108
|
-
if (!isSqlControlAdapter(controlAdapter)) throw new Error("Adapter does not implement SqlControlAdapter (missing introspect, readMarker, or readAllMarkers)");
|
|
1109
|
-
return controlAdapter;
|
|
1110
|
-
};
|
|
1104
|
+
const getControlAdapter = () => adapter.create(stack);
|
|
1111
1105
|
const targetSerializer = target.contractSerializer;
|
|
1112
1106
|
const deserializeWithTargetSerializer = (contractJson) => {
|
|
1113
1107
|
return (targetSerializer ?? new SqlContractSerializer()).deserializeContract(contractJson);
|
|
@@ -1223,6 +1217,7 @@ function createSqlFamilyInstance(stack) {
|
|
|
1223
1217
|
frameworkComponents: options.frameworkComponents,
|
|
1224
1218
|
...ifDefined("normalizeDefault", controlAdapter.normalizeDefault),
|
|
1225
1219
|
...ifDefined("normalizeNativeType", controlAdapter.normalizeNativeType),
|
|
1220
|
+
...ifDefined("columnsCompatible", controlAdapter.columnsCompatible),
|
|
1226
1221
|
...ifDefined("resolveExistingEnumValues", resolveExistingEnumValues)
|
|
1227
1222
|
});
|
|
1228
1223
|
},
|
|
@@ -1233,9 +1228,13 @@ function createSqlFamilyInstance(stack) {
|
|
|
1233
1228
|
const contractStorageHash = contract.storage.storageHash;
|
|
1234
1229
|
const contractProfileHash = "profileHash" in contract && typeof contract.profileHash === "string" ? contract.profileHash : contractStorageHash;
|
|
1235
1230
|
const contractTarget = contract.target;
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
const
|
|
1231
|
+
const controlAdapter = getControlAdapter();
|
|
1232
|
+
const lowererContext = { contract };
|
|
1233
|
+
for (const query of controlAdapter.bootstrapSignMarkerQueries()) {
|
|
1234
|
+
const lowered = controlAdapter.lower(query, lowererContext);
|
|
1235
|
+
await driver.query(lowered.sql, lowered.params);
|
|
1236
|
+
}
|
|
1237
|
+
const existingMarker = await controlAdapter.readMarker(driver, APP_SPACE_ID);
|
|
1239
1238
|
let markerCreated = false;
|
|
1240
1239
|
let markerUpdated = false;
|
|
1241
1240
|
let previousHashes;
|
|
@@ -1302,6 +1301,9 @@ function createSqlFamilyInstance(stack) {
|
|
|
1302
1301
|
async readAllMarkers(options) {
|
|
1303
1302
|
return getControlAdapter().readAllMarkers(options.driver);
|
|
1304
1303
|
},
|
|
1304
|
+
async readLedger(options) {
|
|
1305
|
+
return getControlAdapter().readLedger(options.driver, options.space);
|
|
1306
|
+
},
|
|
1305
1307
|
async introspect(options) {
|
|
1306
1308
|
return getControlAdapter().introspect(options.driver, options.contract);
|
|
1307
1309
|
},
|
|
@@ -1311,6 +1313,12 @@ function createSqlFamilyInstance(stack) {
|
|
|
1311
1313
|
lowerAst(ast, context) {
|
|
1312
1314
|
return getControlAdapter().lower(ast, context);
|
|
1313
1315
|
},
|
|
1316
|
+
bootstrapControlTableQueries() {
|
|
1317
|
+
return getControlAdapter().bootstrapControlTableQueries();
|
|
1318
|
+
},
|
|
1319
|
+
bootstrapSignMarkerQueries() {
|
|
1320
|
+
return getControlAdapter().bootstrapSignMarkerQueries();
|
|
1321
|
+
},
|
|
1314
1322
|
toOperationPreview(operations) {
|
|
1315
1323
|
return sqlOperationsToPreview(operations);
|
|
1316
1324
|
},
|
|
@@ -1616,6 +1624,46 @@ function deriveAnnotations(storage, annotationNamespace, resolveEnumStorageKey)
|
|
|
1616
1624
|
return { [annotationNamespace]: { storageTypes } };
|
|
1617
1625
|
}
|
|
1618
1626
|
//#endregion
|
|
1627
|
+
//#region src/core/migrations/control-policy.ts
|
|
1628
|
+
/**
|
|
1629
|
+
* The control policy that governs a single call. The `external` default is an
|
|
1630
|
+
* un-overridable namespace floor: when the contract default is `external`, no
|
|
1631
|
+
* per-object `managed` override can escalate DDL above the floor, so the
|
|
1632
|
+
* policy is forced to `external` regardless of the node's own declaration.
|
|
1633
|
+
* Every other default defers to the node's effective control policy.
|
|
1634
|
+
*/
|
|
1635
|
+
function controlPolicyForCall(subject, defaultControl) {
|
|
1636
|
+
if (defaultControl === "external") return "external";
|
|
1637
|
+
return effectiveControlPolicy(subject?.explicitNodeControlPolicy, defaultControl);
|
|
1638
|
+
}
|
|
1639
|
+
/**
|
|
1640
|
+
* Whether a call is allowed to emit under a given control policy.
|
|
1641
|
+
*
|
|
1642
|
+
* - `managed` — full lifecycle, every op allowed.
|
|
1643
|
+
* - `tolerated` — create-if-absent only: allowed iff the call creates a whole
|
|
1644
|
+
* new top-level object (and its subject was positively resolved). Anything
|
|
1645
|
+
* that modifies an existing object, and anything whose subject could not be
|
|
1646
|
+
* resolved, is suppressed.
|
|
1647
|
+
* - `external` / `observed` — no DDL at all.
|
|
1648
|
+
*/
|
|
1649
|
+
function callAllowedUnderControlPolicy(policy, subject) {
|
|
1650
|
+
switch (policy) {
|
|
1651
|
+
case "managed": return true;
|
|
1652
|
+
case "tolerated": return subject?.createsNewObject === true;
|
|
1653
|
+
case "external":
|
|
1654
|
+
case "observed": return false;
|
|
1655
|
+
}
|
|
1656
|
+
}
|
|
1657
|
+
function filterCallsByControlPolicy(options) {
|
|
1658
|
+
const defaultControl = options.contract.defaultControl;
|
|
1659
|
+
const kept = [];
|
|
1660
|
+
for (const call of options.calls) {
|
|
1661
|
+
const subject = options.resolveControlPolicySubject(call);
|
|
1662
|
+
if (callAllowedUnderControlPolicy(controlPolicyForCall(subject, defaultControl), subject)) kept.push(call);
|
|
1663
|
+
}
|
|
1664
|
+
return Object.freeze(kept);
|
|
1665
|
+
}
|
|
1666
|
+
//#endregion
|
|
1619
1667
|
//#region src/core/migrations/field-event-planner.ts
|
|
1620
1668
|
function planFieldEventOperations(options) {
|
|
1621
1669
|
const priorContract = options.priorContract;
|
|
@@ -1844,6 +1892,6 @@ const INIT_ADDITIVE_POLICY = Object.freeze({ allowedOperationClasses: Object.fre
|
|
|
1844
1892
|
//#region src/exports/control.ts
|
|
1845
1893
|
var control_default = new SqlFamilyDescriptor();
|
|
1846
1894
|
//#endregion
|
|
1847
|
-
export { INIT_ADDITIVE_POLICY, assembleAuthoringContributions, contractToSchemaIR, createMigrationPlan, control_default as default, detectDestructiveChanges, extractCodecControlHooks, planFieldEventOperations, plannerFailure, plannerSuccess, runnerFailure, runnerSuccess, temporalAuthoringPresets, timestampNowControlDescriptor };
|
|
1895
|
+
export { INIT_ADDITIVE_POLICY, assembleAuthoringContributions, contractToSchemaIR, createMigrationPlan, control_default as default, detectDestructiveChanges, extractCodecControlHooks, filterCallsByControlPolicy, planFieldEventOperations, plannerFailure, plannerSuccess, runnerFailure, runnerSuccess, temporalAuthoringPresets, timestampNowControlDescriptor };
|
|
1848
1896
|
|
|
1849
1897
|
//# sourceMappingURL=control.mjs.map
|