@prisma-next/family-sql 0.12.0 → 0.13.0-dev.2
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-F4JpCJl7.mjs → authoring-type-constructors-D4lQ-qpj.mjs} +1 -1
- package/dist/{authoring-type-constructors-F4JpCJl7.mjs.map → authoring-type-constructors-D4lQ-qpj.mjs.map} +1 -1
- package/dist/control-adapter-CgIL9Vtx.d.mts +182 -0
- package/dist/control-adapter-CgIL9Vtx.d.mts.map +1 -0
- package/dist/control-adapter.d.mts +2 -109
- package/dist/control.d.mts +132 -4
- package/dist/control.d.mts.map +1 -1
- package/dist/control.mjs +277 -215
- package/dist/control.mjs.map +1 -1
- package/dist/ir.d.mts +4 -5
- package/dist/ir.d.mts.map +1 -1
- package/dist/ir.mjs +1 -1
- package/dist/migration.d.mts +1 -1
- package/dist/migration.d.mts.map +1 -1
- package/dist/pack.mjs +1 -1
- package/dist/runtime.d.mts +4 -2
- package/dist/runtime.d.mts.map +1 -1
- package/dist/runtime.mjs +4 -2
- 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/{sql-contract-serializer-8axtK4lg.mjs → sql-contract-serializer-CY7qnms7.mjs} +18 -36
- package/dist/sql-contract-serializer-CY7qnms7.mjs.map +1 -0
- package/dist/{timestamp-now-generator-r7BP5n3l.mjs → timestamp-now-generator-CloimujU.mjs} +2 -1
- package/dist/{timestamp-now-generator-r7BP5n3l.mjs.map → timestamp-now-generator-CloimujU.mjs.map} +1 -1
- package/dist/{types-CeeCStqw.d.mts → types-CbwQCzXY.d.mts} +70 -16
- package/dist/types-CbwQCzXY.d.mts.map +1 -0
- package/dist/{verify-Crewz6hG.mjs → verify-C-G0obRm.mjs} +1 -1
- package/dist/{verify-Crewz6hG.mjs.map → verify-C-G0obRm.mjs.map} +1 -1
- package/dist/{verify-sql-schema-CN7pPoTC.d.mts → verify-sql-schema-DcMaT5Zj.d.mts} +1 -1
- package/dist/{verify-sql-schema-CN7pPoTC.d.mts.map → verify-sql-schema-DcMaT5Zj.d.mts.map} +1 -1
- package/dist/{verify-sql-schema-CYLsGCFO.mjs → verify-sql-schema-DlAgBiT_.mjs} +756 -319
- package/dist/verify-sql-schema-DlAgBiT_.mjs.map +1 -0
- package/dist/verify.mjs +1 -1
- package/package.json +23 -23
- package/src/core/control-adapter.ts +116 -7
- package/src/core/control-instance.ts +269 -66
- package/src/core/default-namespace.ts +9 -0
- package/src/core/ir/sql-contract-serializer-base.ts +72 -56
- package/src/core/migrations/contract-to-schema-ir.ts +75 -9
- package/src/core/migrations/control-policy.ts +322 -0
- package/src/core/migrations/field-event-planner.ts +2 -2
- package/src/core/migrations/plan-helpers.ts +16 -0
- package/src/core/migrations/types.ts +17 -7
- package/src/core/psl-contract-infer/sql-schema-ir-to-psl-ast.ts +8 -6
- package/src/core/schema-verify/control-verify-emit.ts +46 -0
- package/src/core/schema-verify/verifier-disposition.ts +58 -0
- package/src/core/schema-verify/verify-helpers.ts +310 -111
- package/src/core/schema-verify/verify-sql-schema.ts +309 -178
- package/src/core/timestamp-now-generator.ts +1 -0
- package/src/exports/control-adapter.ts +5 -1
- package/src/exports/control.ts +7 -0
- package/src/exports/runtime.ts +7 -0
- package/dist/control-adapter.d.mts.map +0 -1
- package/dist/sql-contract-serializer-8axtK4lg.mjs.map +0 -1
- package/dist/types-CeeCStqw.d.mts.map +0 -1
- package/dist/verify-sql-schema-CYLsGCFO.mjs.map +0 -1
package/dist/{authoring-type-constructors-F4JpCJl7.mjs → authoring-type-constructors-D4lQ-qpj.mjs}
RENAMED
|
@@ -189,4 +189,4 @@ const sqlFamilyAuthoringTypes = { sql: { String: {
|
|
|
189
189
|
//#endregion
|
|
190
190
|
export { sqlFamilyAuthoringFieldPresets as n, sqlFamilyAuthoringTypes as t };
|
|
191
191
|
|
|
192
|
-
//# sourceMappingURL=authoring-type-constructors-
|
|
192
|
+
//# sourceMappingURL=authoring-type-constructors-D4lQ-qpj.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authoring-type-constructors-
|
|
1
|
+
{"version":3,"file":"authoring-type-constructors-D4lQ-qpj.mjs","names":[],"sources":["../src/core/authoring-field-presets.ts","../src/core/authoring-type-constructors.ts"],"sourcesContent":["import type { AuthoringFieldNamespace } from '@prisma-next/framework-components/authoring';\n\n/**\n * Family-level SQL authoring field presets.\n *\n * Only presets whose codec IDs align with the ID generator metadata live here\n * (see `@prisma-next/ids`). These presets are target-agnostic because the\n * generator metadata fixes their codec/native-type to `sql/char@1`\n * (`character`) regardless of target, and the PSL interpreter lets the\n * generator override the scalar descriptor.\n *\n * Scalar presets that map to target-specific codecs (e.g. `text`, `int`,\n * `boolean`, `dateTime`) are contributed by the target pack (see\n * `postgresAuthoringFieldPresets` in `@prisma-next/target-postgres`) so the\n * TS callback surface and the PSL scalar surface lower to byte-identical\n * contracts for the active target.\n */\n\nconst CHARACTER_CODEC_ID = 'sql/char@1';\nconst CHARACTER_NATIVE_TYPE = 'character';\n\nconst nanoidOptionsArgument = {\n kind: 'object',\n optional: true,\n properties: {\n size: {\n kind: 'number',\n optional: true,\n integer: true,\n minimum: 2,\n maximum: 255,\n },\n },\n} as const;\n\nexport const sqlFamilyAuthoringFieldPresets = {\n uuid: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 36,\n },\n },\n },\n ulid: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 26,\n },\n },\n },\n nanoid: {\n kind: 'fieldPreset',\n args: [nanoidOptionsArgument],\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: {\n kind: 'arg',\n index: 0,\n path: ['size'],\n default: 21,\n },\n },\n },\n },\n cuid2: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 24,\n },\n },\n },\n ksuid: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 27,\n },\n },\n },\n id: {\n uuidv4: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 36,\n },\n executionDefaults: {\n onCreate: {\n kind: 'generator',\n id: 'uuidv4',\n },\n },\n id: true,\n },\n },\n uuidv7: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 36,\n },\n executionDefaults: {\n onCreate: {\n kind: 'generator',\n id: 'uuidv7',\n },\n },\n id: true,\n },\n },\n ulid: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 26,\n },\n executionDefaults: {\n onCreate: {\n kind: 'generator',\n id: 'ulid',\n },\n },\n id: true,\n },\n },\n nanoid: {\n kind: 'fieldPreset',\n args: [nanoidOptionsArgument],\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: {\n kind: 'arg',\n index: 0,\n path: ['size'],\n default: 21,\n },\n },\n executionDefaults: {\n onCreate: {\n kind: 'generator',\n id: 'nanoid',\n params: {\n size: {\n kind: 'arg',\n index: 0,\n path: ['size'],\n },\n },\n },\n },\n id: true,\n },\n },\n cuid2: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 24,\n },\n executionDefaults: {\n onCreate: {\n kind: 'generator',\n id: 'cuid2',\n },\n },\n id: true,\n },\n },\n ksuid: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 27,\n },\n executionDefaults: {\n onCreate: {\n kind: 'generator',\n id: 'ksuid',\n },\n },\n id: true,\n },\n },\n },\n} as const satisfies AuthoringFieldNamespace;\n","import type { AuthoringTypeNamespace } from '@prisma-next/framework-components/authoring';\n\nexport const sqlFamilyAuthoringTypes = {\n sql: {\n String: {\n kind: 'typeConstructor',\n args: [{ kind: 'number', name: 'length', integer: true, minimum: 1, maximum: 10485760 }],\n output: {\n codecId: 'sql/varchar@1',\n nativeType: 'character varying',\n typeParams: {\n length: { kind: 'arg', index: 0 },\n },\n },\n },\n },\n} as const satisfies AuthoringTypeNamespace;\n"],"mappings":";;;;;;;;;;;;;;;;AAkBA,MAAM,qBAAqB;AAC3B,MAAM,wBAAwB;AAE9B,MAAM,wBAAwB;CAC5B,MAAM;CACN,UAAU;CACV,YAAY,EACV,MAAM;EACJ,MAAM;EACN,UAAU;EACV,SAAS;EACT,SAAS;EACT,SAAS;CACX,EACF;AACF;AAEA,MAAa,iCAAiC;CAC5C,MAAM;EACJ,MAAM;EACN,QAAQ;GACN,SAAS;GACT,YAAY;GACZ,YAAY,EACV,QAAQ,GACV;EACF;CACF;CACA,MAAM;EACJ,MAAM;EACN,QAAQ;GACN,SAAS;GACT,YAAY;GACZ,YAAY,EACV,QAAQ,GACV;EACF;CACF;CACA,QAAQ;EACN,MAAM;EACN,MAAM,CAAC,qBAAqB;EAC5B,QAAQ;GACN,SAAS;GACT,YAAY;GACZ,YAAY,EACV,QAAQ;IACN,MAAM;IACN,OAAO;IACP,MAAM,CAAC,MAAM;IACb,SAAS;GACX,EACF;EACF;CACF;CACA,OAAO;EACL,MAAM;EACN,QAAQ;GACN,SAAS;GACT,YAAY;GACZ,YAAY,EACV,QAAQ,GACV;EACF;CACF;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I;GACN;EACF;CACF;AACF;;;AC/MA,MAAa,0BAA0B,EACrC,KAAK,EACH,QAAQ;CACN,MAAM;CACN,MAAM,CAAC;EAAE,MAAM;EAAU,MAAM;EAAU,SAAS;EAAM,SAAS;EAAG,SAAS;CAAS,CAAC;CACvF,QAAQ;EACN,SAAS;EACT,YAAY;EACZ,YAAY,EACV,QAAQ;GAAE,MAAM;GAAO,OAAO;EAAE,EAClC;CACF;AACF,EACF,EACF"}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { n as NativeTypeNormalizer, t as DefaultNormalizer } from "./verify-sql-schema-DcMaT5Zj.mjs";
|
|
2
|
+
import { ControlAdapterInstance, ControlStack } from "@prisma-next/framework-components/control";
|
|
3
|
+
import { PostgresEnumStorageEntry, SqlControlDriverInstance, 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
|
+
* Structural interface for anything that can lower a SQL/DDL AST node to a
|
|
11
|
+
* `LoweredStatement`. `SqlControlAdapter` satisfies this interface; the
|
|
12
|
+
* migration planner and op-factory calls accept `Lowerer` rather than the
|
|
13
|
+
* full `SqlControlAdapter` so they are not coupled to the broader control
|
|
14
|
+
* adapter surface.
|
|
15
|
+
*/
|
|
16
|
+
interface Lowerer {
|
|
17
|
+
lower(ast: AnyQueryAst | DdlNode, context: LowererContext<unknown>): LoweredStatement;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* SQL control adapter interface for control-plane operations.
|
|
21
|
+
* Implemented by target-specific adapters (e.g., Postgres, MySQL).
|
|
22
|
+
*
|
|
23
|
+
* @template TTarget - The target ID (e.g., 'postgres', 'mysql')
|
|
24
|
+
*/
|
|
25
|
+
interface SqlControlAdapter<TTarget extends string = string> extends ControlAdapterInstance<'sql', TTarget> {
|
|
26
|
+
/**
|
|
27
|
+
* Reads the contract marker for `space` from the database, returning
|
|
28
|
+
* `null` if no marker row exists for that space (or if the marker
|
|
29
|
+
* table itself is missing). Implementations are responsible for the
|
|
30
|
+
* dialect-specific existence probe (e.g. Postgres
|
|
31
|
+
* `information_schema.tables` vs SQLite `sqlite_master`) and parameter
|
|
32
|
+
* placeholders.
|
|
33
|
+
*
|
|
34
|
+
* `space` is required so callers cannot accidentally fall through to
|
|
35
|
+
* the app's marker row when reading per-extension markers.
|
|
36
|
+
*
|
|
37
|
+
* @param driver - ControlDriverInstance for executing queries (target-specific)
|
|
38
|
+
* @param space - Contract space id whose marker row to read (e.g. `'app'`)
|
|
39
|
+
* @returns Resolved marker record, or `null` if not yet stamped.
|
|
40
|
+
*/
|
|
41
|
+
readMarker(driver: SqlControlDriverInstance<TTarget>, space: string): Promise<ContractMarkerRecord | null>;
|
|
42
|
+
/**
|
|
43
|
+
* Reads every marker row from `prisma_contract.marker` (one per
|
|
44
|
+
* contract space) and returns them keyed by `space`. Used by the
|
|
45
|
+
* per-space verifier to detect marker-vs-on-disk drift and orphan
|
|
46
|
+
* marker rows. Returns an empty map when the marker table does not
|
|
47
|
+
* yet exist (fresh database / never-signed project).
|
|
48
|
+
*/
|
|
49
|
+
readAllMarkers(driver: SqlControlDriverInstance<TTarget>): Promise<ReadonlyMap<string, ContractMarkerRecord>>;
|
|
50
|
+
/**
|
|
51
|
+
* Reads the per-migration ledger journal in apply order. When `space` is
|
|
52
|
+
* omitted, returns rows for every space.
|
|
53
|
+
*/
|
|
54
|
+
readLedger(driver: SqlControlDriverInstance<TTarget>, space?: string): Promise<readonly LedgerEntryRecord[]>;
|
|
55
|
+
/**
|
|
56
|
+
* Inserts the initial marker row for `space` (`INSERT` only). Fails when a
|
|
57
|
+
* row for that space already exists. Used by `sign()` so concurrent first-time
|
|
58
|
+
* stamps cannot silently overwrite each other. `updated_at` is DB-side
|
|
59
|
+
* (`now()` / `datetime('now')`). Mirrors `MongoControlAdapter.initMarker`.
|
|
60
|
+
*/
|
|
61
|
+
insertMarker(driver: SqlControlDriverInstance<TTarget>, space: string, destination: {
|
|
62
|
+
readonly storageHash: string;
|
|
63
|
+
readonly profileHash: string;
|
|
64
|
+
readonly invariants?: readonly string[];
|
|
65
|
+
}): Promise<void>;
|
|
66
|
+
/**
|
|
67
|
+
* Writes the initial marker row for `space` as an upsert (`INSERT … ON
|
|
68
|
+
* CONFLICT (space) DO UPDATE SET …`), so re-stamping a space overwrites the
|
|
69
|
+
* existing row rather than failing. `updated_at` is stamped with a DB-side
|
|
70
|
+
* time expression (`now()` / `datetime('now')`), never an app-side clock.
|
|
71
|
+
*/
|
|
72
|
+
initMarker(driver: SqlControlDriverInstance<TTarget>, space: string, destination: {
|
|
73
|
+
readonly storageHash: string;
|
|
74
|
+
readonly profileHash: string;
|
|
75
|
+
readonly invariants?: readonly string[];
|
|
76
|
+
}): Promise<void>;
|
|
77
|
+
/**
|
|
78
|
+
* Atomically advances the marker row for `space` (compare-and-swap on
|
|
79
|
+
* `core_hash = expectedFrom`). Returns `true` when the swap matched a row,
|
|
80
|
+
* `false` when another process advanced the marker first. `destination.invariants`
|
|
81
|
+
* is written verbatim when supplied (the union/dedupe policy lives upstream)
|
|
82
|
+
* and left untouched when omitted. Mirrors `MongoControlAdapter.updateMarker`.
|
|
83
|
+
*/
|
|
84
|
+
updateMarker(driver: SqlControlDriverInstance<TTarget>, space: string, expectedFrom: string, destination: {
|
|
85
|
+
readonly storageHash: string;
|
|
86
|
+
readonly profileHash: string;
|
|
87
|
+
readonly invariants?: readonly string[];
|
|
88
|
+
}): Promise<boolean>;
|
|
89
|
+
/**
|
|
90
|
+
* Appends a ledger entry for `space`. Mirrors `MongoControlAdapter.writeLedgerEntry`.
|
|
91
|
+
* The SQL ledger table keys rows by an autoincrement id and partitions reads
|
|
92
|
+
* by `space`, so `entry.edgeId` carries no dedicated column; `from` / `to`
|
|
93
|
+
* land in `origin_core_hash` / `destination_core_hash`.
|
|
94
|
+
*/
|
|
95
|
+
writeLedgerEntry(driver: SqlControlDriverInstance<TTarget>, space: string, entry: {
|
|
96
|
+
readonly edgeId: string;
|
|
97
|
+
readonly from: string;
|
|
98
|
+
readonly to: string;
|
|
99
|
+
readonly migrationName: string;
|
|
100
|
+
readonly migrationHash: string;
|
|
101
|
+
readonly operations: readonly unknown[];
|
|
102
|
+
}): Promise<void>;
|
|
103
|
+
/**
|
|
104
|
+
* Introspects a database schema and returns a raw SqlSchemaIR.
|
|
105
|
+
*
|
|
106
|
+
* This is a pure schema discovery operation that queries the database catalog
|
|
107
|
+
* and returns the schema structure without type mapping or contract enrichment.
|
|
108
|
+
* Type mapping and enrichment are handled separately by enrichment helpers.
|
|
109
|
+
*
|
|
110
|
+
* @param driver - ControlDriverInstance instance for executing queries (target-specific)
|
|
111
|
+
* @param contract - Optional contract for contract-guided introspection (filtering, optimization)
|
|
112
|
+
* @param schema - Schema name to introspect (defaults to 'public')
|
|
113
|
+
* @returns Promise resolving to SqlSchemaIR representing the live database schema
|
|
114
|
+
*/
|
|
115
|
+
introspect(driver: SqlControlDriverInstance<TTarget>, contract?: unknown, schema?: string): Promise<SqlSchemaIR>;
|
|
116
|
+
/**
|
|
117
|
+
* Optional target-specific normalizer for raw database default expressions.
|
|
118
|
+
* When provided, schema defaults (raw strings) are normalized before comparison
|
|
119
|
+
* with contract defaults (ColumnDefault objects) during schema verification.
|
|
120
|
+
*/
|
|
121
|
+
readonly normalizeDefault?: DefaultNormalizer;
|
|
122
|
+
/**
|
|
123
|
+
* Optional target-specific normalizer for schema native type names.
|
|
124
|
+
* When provided, schema native types (from introspection) are normalized
|
|
125
|
+
* before comparison with contract native types during schema verification.
|
|
126
|
+
*/
|
|
127
|
+
readonly normalizeNativeType?: NativeTypeNormalizer;
|
|
128
|
+
/**
|
|
129
|
+
* Optional bridging adapter for resolving the existing values of a
|
|
130
|
+
* native enum type from the introspected schema IR. Targets supply
|
|
131
|
+
* this so the family-level schema verifier can walk
|
|
132
|
+
* `PostgresEnumStorageEntry` entries natively without needing to
|
|
133
|
+
* know the target-specific `schema.annotations` shape
|
|
134
|
+
* (e.g. `schema.annotations.pg.storageTypes`).
|
|
135
|
+
*/
|
|
136
|
+
readonly resolveExistingEnumValues?: (schema: SqlSchemaIR, enumType: PostgresEnumStorageEntry, namespaceId: string) => readonly string[] | null;
|
|
137
|
+
/**
|
|
138
|
+
* Optional contract-scoped factory for {@link resolveExistingEnumValues}.
|
|
139
|
+
* Targets that need the contract storage to resolve namespace → DDL schema
|
|
140
|
+
* supply this; the family control instance prefers it over the bare adapter
|
|
141
|
+
* hook when present.
|
|
142
|
+
*/
|
|
143
|
+
readonly resolveExistingEnumValuesForContract?: (contract: Contract<SqlStorage>) => (schema: SqlSchemaIR, enumType: PostgresEnumStorageEntry, namespaceId: string) => readonly string[] | null;
|
|
144
|
+
/**
|
|
145
|
+
* Ordered DDL queries that bootstrap marker/ledger control tables for migration
|
|
146
|
+
* runners. Postgres includes `CREATE SCHEMA`; SQLite does not.
|
|
147
|
+
*/
|
|
148
|
+
bootstrapControlTableQueries(): readonly DdlNode[];
|
|
149
|
+
/**
|
|
150
|
+
* Ordered DDL queries that bootstrap the marker table (and Postgres schema) for
|
|
151
|
+
* `sign` — excludes the ledger table.
|
|
152
|
+
*/
|
|
153
|
+
bootstrapSignMarkerQueries(): readonly DdlNode[];
|
|
154
|
+
/**
|
|
155
|
+
* Lower a SQL query AST into a target-flavored `{ sql, params }` payload.
|
|
156
|
+
*
|
|
157
|
+
* Migration tooling (e.g. the `dataTransform` operation) needs to materialize
|
|
158
|
+
* SQL at emit/plan time without instantiating the runtime adapter. The control
|
|
159
|
+
* adapter's `lower` is byte-equivalent to the runtime adapter's `lower` for the
|
|
160
|
+
* same AST and contract, ensuring planned SQL matches what the runtime would
|
|
161
|
+
* emit.
|
|
162
|
+
*/
|
|
163
|
+
lower(ast: AnyQueryAst | DdlNode, context: LowererContext<unknown>): LoweredStatement;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* SQL control adapter descriptor interface.
|
|
167
|
+
* Provides a factory method to create control adapter instances.
|
|
168
|
+
*
|
|
169
|
+
* @template TTarget - The target ID (e.g., 'postgres', 'mysql')
|
|
170
|
+
*/
|
|
171
|
+
interface SqlControlAdapterDescriptor<TTarget extends string = string> {
|
|
172
|
+
/**
|
|
173
|
+
* Creates a SQL control adapter instance for control-plane operations.
|
|
174
|
+
*
|
|
175
|
+
* Receives the assembled `ControlStack` so adapters can read aggregated
|
|
176
|
+
* metadata (codec lookup, extension contributions) when materializing.
|
|
177
|
+
*/
|
|
178
|
+
create(stack: ControlStack<'sql', TTarget>): SqlControlAdapter<TTarget>;
|
|
179
|
+
}
|
|
180
|
+
//#endregion
|
|
181
|
+
export { SqlControlAdapter as n, SqlControlAdapterDescriptor as r, Lowerer as t };
|
|
182
|
+
//# sourceMappingURL=control-adapter-CgIL9Vtx.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"control-adapter-CgIL9Vtx.d.mts","names":[],"sources":["../src/core/control-adapter.ts"],"mappings":";;;;;;;;;;AA8BA;;;;;UAAiB,OAAA;EACf,KAAA,CAAM,GAAA,EAAK,WAAA,GAAc,OAAA,EAAS,OAAA,EAAS,cAAA,YAA0B,gBAAA;AAAA;;;;;;;UAStD,iBAAA,0CACP,sBAAA,QAA8B,OAAA;EAV+B;;AAAgB;AASvF;;;;;;;;;;;;EAiBE,UAAA,CACE,MAAA,EAAQ,wBAAA,CAAyB,OAAA,GACjC,KAAA,WACC,OAAA,CAAQ,oBAAA;EAkBwB;;;;;;;EATnC,cAAA,CACE,MAAA,EAAQ,wBAAA,CAAyB,OAAA,IAChC,OAAA,CAAQ,WAAA,SAAoB,oBAAA;EAkCrB;;;;EA5BV,UAAA,CACE,MAAA,EAAQ,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AlDN;;;;EAwDnC,0BAAA,aAAuC,OAAA;EArD5B;;;;;;;;;EAgEX,KAAA,CAAM,GAAA,EAAK,WAAA,GAAc,OAAA,EAAS,OAAA,EAAS,cAAA,YAA0B,gBAAA;AAAA;;;;;;;UAStD,2BAAA;EAlCb;;;;;;EAyCF,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 SqlControlAdapter, r as SqlControlAdapterDescriptor, t as Lowerer } from "./control-adapter-CgIL9Vtx.mjs";
|
|
2
|
+
export type { Lowerer, SqlControlAdapter, 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-CbwQCzXY.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";
|
|
@@ -286,6 +286,20 @@ type DefaultRenderer = (def: ColumnDefault, column: StorageColumn) => string;
|
|
|
286
286
|
* still emits keys that match the target's read side exactly.
|
|
287
287
|
*/
|
|
288
288
|
type EnumStorageKeyResolver = (storage: SqlStorage, namespaceId: string, nativeType: string) => string;
|
|
289
|
+
/**
|
|
290
|
+
* Resolves a `ValueSetRef` to its permitted values from the contract storage.
|
|
291
|
+
*
|
|
292
|
+
* Throws when the referenced namespace or value-set is absent — this indicates
|
|
293
|
+
* the contract was built incorrectly (the check and the value-set must be
|
|
294
|
+
* co-emitted by the lowering step). Used by `convertCheck` (schema-IR
|
|
295
|
+
* projection), `verifyCheckConstraints` (verification), and
|
|
296
|
+
* `checkConstraintPlanCallStrategy` (migration planning) so all three agree on
|
|
297
|
+
* the resolved values and the error behavior on a missing reference.
|
|
298
|
+
*/
|
|
299
|
+
declare function resolveValueSetValues(ref: {
|
|
300
|
+
readonly namespaceId: string;
|
|
301
|
+
readonly name: string;
|
|
302
|
+
}, storage: SqlStorage, contextLabel: string): readonly string[];
|
|
289
303
|
/**
|
|
290
304
|
* Detects destructive changes between two contract storages.
|
|
291
305
|
*
|
|
@@ -325,6 +339,120 @@ interface ContractToSchemaIROptions {
|
|
|
325
339
|
*/
|
|
326
340
|
declare function contractToSchemaIR(contract: Contract<SqlStorage> | null, options: ContractToSchemaIROptions): SqlSchemaIR;
|
|
327
341
|
//#endregion
|
|
342
|
+
//#region src/core/migrations/control-policy.d.ts
|
|
343
|
+
/**
|
|
344
|
+
* The target object a control policy governs for a single planner call,
|
|
345
|
+
* resolved from the target's own IR. `undefined` means the call's target
|
|
346
|
+
* object could not be positively established — a fail-closed signal: any
|
|
347
|
+
* policy stricter than `managed` drops such a call rather than emitting it.
|
|
348
|
+
*/
|
|
349
|
+
interface ControlPolicySubject {
|
|
350
|
+
readonly namespaceId: string;
|
|
351
|
+
readonly explicitNodeControlPolicy?: ControlPolicy;
|
|
352
|
+
readonly table?: string;
|
|
353
|
+
readonly column?: string;
|
|
354
|
+
readonly typeName?: string;
|
|
355
|
+
/**
|
|
356
|
+
* Whether the call creates a whole, previously-absent top-level storage
|
|
357
|
+
* object (e.g. a table or an enum/type), as opposed to modifying an
|
|
358
|
+
* existing object. This is the only thing `tolerated` permits: it is a
|
|
359
|
+
* create-if-absent policy, so an op that touches an existing object — add
|
|
360
|
+
* column, add index/constraint, alter, drop — is never allowed under it.
|
|
361
|
+
*/
|
|
362
|
+
readonly createsNewObject: boolean;
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* The control policy that governs a single call. The `external` default is an
|
|
366
|
+
* un-overridable namespace floor: when the contract default is `external`, no
|
|
367
|
+
* per-object `managed` override can escalate DDL above the floor, so the
|
|
368
|
+
* policy is forced to `external` regardless of the node's own declaration.
|
|
369
|
+
* Every other default defers to the node's effective control policy.
|
|
370
|
+
*/
|
|
371
|
+
declare function controlPolicyForCall(subject: ControlPolicySubject | undefined, defaultControlPolicy: ControlPolicy | undefined): ControlPolicy;
|
|
372
|
+
/**
|
|
373
|
+
* Partition the calls produced for a single set of subjects into those the
|
|
374
|
+
* effective control policy permits (`kept`) and a list of
|
|
375
|
+
* {@link SqlPlannerConflict} warnings describing the suppressed calls.
|
|
376
|
+
*
|
|
377
|
+
* **Prefer {@link partitionIssuesByControlPolicy}** for the schema-issue
|
|
378
|
+
* pipeline: it filters subjects out of the planner's *input* so the planner
|
|
379
|
+
* never has to reason about un-modeled state on `external`/`observed`
|
|
380
|
+
* subjects. This call-level helper remains for paths that bypass the issue
|
|
381
|
+
* pipeline — currently the codec-emitted field-event ops, which originate
|
|
382
|
+
* from declared contract fields rather than from introspected schema state
|
|
383
|
+
* and therefore cannot trip the diff engine.
|
|
384
|
+
*/
|
|
385
|
+
declare function partitionCallsByControlPolicy<TCall>(options: {
|
|
386
|
+
readonly calls: readonly TCall[];
|
|
387
|
+
readonly contract: Contract<SqlStorage>;
|
|
388
|
+
readonly resolveControlPolicySubject: (call: TCall) => ControlPolicySubject | undefined;
|
|
389
|
+
readonly resolveFactoryName: (call: TCall) => string;
|
|
390
|
+
readonly formatSubjectLabel?: (factoryName: string, subject: ControlPolicySubject | undefined) => string;
|
|
391
|
+
}): {
|
|
392
|
+
readonly kept: readonly TCall[];
|
|
393
|
+
readonly warnings: readonly SqlPlannerConflict[];
|
|
394
|
+
};
|
|
395
|
+
/**
|
|
396
|
+
* Partition a list of schema-issue-shaped inputs by the effective control
|
|
397
|
+
* policy of each issue's subject *before* the planner is invoked.
|
|
398
|
+
*
|
|
399
|
+
* `plannable` is the list of issues whose subject's effective policy permits
|
|
400
|
+
* the planner to act on them (`managed`, or `tolerated` for whole-object
|
|
401
|
+
* creation issues only). Issues for `external`/`observed` subjects, and
|
|
402
|
+
* non-creation issues for `tolerated` subjects, are dropped from the planner's
|
|
403
|
+
* input entirely — they never enter introspection-driven planning, never feed
|
|
404
|
+
* the diff engine, and never produce DDL calls that would have to be
|
|
405
|
+
* post-filtered. This sidesteps a class of failure where the diff engine
|
|
406
|
+
* cannot reason about the live shape of a subject the user marked as
|
|
407
|
+
* out-of-scope (`external`).
|
|
408
|
+
*
|
|
409
|
+
* `warnings` is one {@link SqlPlannerConflict} per suppressed subject (not per
|
|
410
|
+
* suppressed issue). `factoryName` is inferred from the subject's issue mix:
|
|
411
|
+
* if any of the subject's issues is whole-object creation, the warning takes
|
|
412
|
+
* the corresponding creation factoryName (e.g. `createTable`,
|
|
413
|
+
* `createEnumType`, `createSchema`); otherwise it falls back to
|
|
414
|
+
* `defaultModificationFactoryName(subject)` — a synthetic label that names
|
|
415
|
+
* the *kind* of mutation that would have run, since no concrete DDL call was
|
|
416
|
+
* generated.
|
|
417
|
+
*
|
|
418
|
+
* Unresolved-subject issues (`resolveControlPolicySubject` returns
|
|
419
|
+
* `undefined`) emit one warning each; they cannot be deduplicated because
|
|
420
|
+
* they carry no subject coordinate.
|
|
421
|
+
*/
|
|
422
|
+
declare function partitionIssuesByControlPolicy<TIssue>(options: {
|
|
423
|
+
readonly issues: readonly TIssue[];
|
|
424
|
+
readonly contract: Contract<SqlStorage>;
|
|
425
|
+
/**
|
|
426
|
+
* Resolve the subject targeted by this issue (or `undefined` to fail-closed:
|
|
427
|
+
* any policy stricter than `managed` drops the issue).
|
|
428
|
+
*/
|
|
429
|
+
readonly resolveControlPolicySubject: (issue: TIssue) => ControlPolicySubject | undefined;
|
|
430
|
+
/**
|
|
431
|
+
* Resolve a creation factoryName for this issue if it represents the
|
|
432
|
+
* absence of the whole top-level object (e.g. `'createTable'` for a
|
|
433
|
+
* missing-table issue). When the issue describes a modification to an
|
|
434
|
+
* existing object, return `undefined`. Both decisions feed off this signal:
|
|
435
|
+
*
|
|
436
|
+
* 1. Under `tolerated`, only issues whose `resolveCreationFactoryName`
|
|
437
|
+
* returns a value flow into the planner (create-if-absent).
|
|
438
|
+
* 2. Subjects that have at least one creation-flavoured issue use the
|
|
439
|
+
* resolved creation factoryName for their suppression warning;
|
|
440
|
+
* otherwise they fall back to `defaultModificationFactoryName`.
|
|
441
|
+
*/
|
|
442
|
+
readonly resolveCreationFactoryName: (issue: TIssue) => string | undefined;
|
|
443
|
+
/**
|
|
444
|
+
* Default modification factoryName for a suppressed subject whose issues
|
|
445
|
+
* are all non-creation (the subject exists but has a different shape).
|
|
446
|
+
* Defaults to `'alterTable'` / `'alterType'` / `'alterSchema'` based on the
|
|
447
|
+
* subject's populated coordinates.
|
|
448
|
+
*/
|
|
449
|
+
readonly defaultModificationFactoryName?: (subject: ControlPolicySubject) => string;
|
|
450
|
+
readonly formatSubjectLabel?: (factoryName: string, subject: ControlPolicySubject | undefined) => string;
|
|
451
|
+
}): {
|
|
452
|
+
readonly plannable: readonly TIssue[];
|
|
453
|
+
readonly warnings: readonly SqlPlannerConflict[];
|
|
454
|
+
};
|
|
455
|
+
//#endregion
|
|
328
456
|
//#region src/core/migrations/field-event-planner.d.ts
|
|
329
457
|
interface PlanFieldEventOperationsOptions {
|
|
330
458
|
/**
|
|
@@ -351,7 +479,7 @@ declare function planFieldEventOperations(options: PlanFieldEventOperationsOptio
|
|
|
351
479
|
//#endregion
|
|
352
480
|
//#region src/core/migrations/plan-helpers.d.ts
|
|
353
481
|
declare function createMigrationPlan<TTargetDetails>(options: CreateSqlMigrationPlanOptions<TTargetDetails>): SqlMigrationPlan<TTargetDetails>;
|
|
354
|
-
declare function plannerSuccess<TTargetDetails>(plan: SqlMigrationPlan<TTargetDetails
|
|
482
|
+
declare function plannerSuccess<TTargetDetails>(plan: SqlMigrationPlan<TTargetDetails>, warnings?: readonly SqlPlannerConflict[]): SqlPlannerSuccessResult<TTargetDetails>;
|
|
355
483
|
declare function plannerFailure(conflicts: readonly SqlPlannerConflict[]): SqlPlannerFailureResult;
|
|
356
484
|
/**
|
|
357
485
|
* Creates a successful migration runner result.
|
|
@@ -434,5 +562,5 @@ declare function temporalAuthoringPresets<const CodecId extends string, const Na
|
|
|
434
562
|
//#region src/exports/control.d.ts
|
|
435
563
|
declare const _default: SqlFamilyDescriptor;
|
|
436
564
|
//#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 };
|
|
565
|
+
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, controlPolicyForCall, createMigrationPlan, _default as default, detectDestructiveChanges, extractCodecControlHooks, partitionCallsByControlPolicy, partitionIssuesByControlPolicy, planFieldEventOperations, plannerFailure, plannerSuccess, resolveValueSetValues, runnerFailure, runnerSuccess, temporalAuthoringPresets, timestampNowControlDescriptor };
|
|
438
566
|
//# 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,
|
|
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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