@prisma-next/family-sql 0.3.0-pr.93.4 → 0.3.0-pr.94.1
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.d.mts +47 -0
- package/dist/control-adapter.d.mts.map +1 -0
- package/dist/control-adapter.mjs +1 -0
- package/dist/control.d.mts +65 -0
- package/dist/control.d.mts.map +1 -0
- package/dist/control.mjs +136 -0
- package/dist/control.mjs.map +1 -0
- package/dist/instance-B_PdDN4y.mjs +525 -0
- package/dist/instance-B_PdDN4y.mjs.map +1 -0
- package/dist/instance-wm4TrZN0.d.mts +130 -0
- package/dist/instance-wm4TrZN0.d.mts.map +1 -0
- package/dist/runtime.d.mts +70 -0
- package/dist/runtime.d.mts.map +1 -0
- package/dist/runtime.mjs +74 -0
- package/dist/runtime.mjs.map +1 -0
- package/dist/schema-verify.d.mts +85 -0
- package/dist/schema-verify.d.mts.map +1 -0
- package/dist/schema-verify.mjs +3 -0
- package/dist/test-utils.d.mts +31 -0
- package/dist/test-utils.d.mts.map +1 -0
- package/dist/test-utils.mjs +5 -0
- package/dist/types-D5CPT9N4.d.mts +270 -0
- package/dist/types-D5CPT9N4.d.mts.map +1 -0
- package/dist/verify-DhFytkFC.mjs +108 -0
- package/dist/verify-DhFytkFC.mjs.map +1 -0
- package/dist/verify-sql-schema-BnLVoeWI.mjs +686 -0
- package/dist/verify-sql-schema-BnLVoeWI.mjs.map +1 -0
- package/dist/verify.d.mts +31 -0
- package/dist/verify.d.mts.map +1 -0
- package/dist/verify.mjs +3 -0
- package/package.json +30 -43
- package/dist/chunk-F27CR6XZ.js +0 -589
- package/dist/chunk-F27CR6XZ.js.map +0 -1
- package/dist/chunk-SU7LN2UH.js +0 -96
- package/dist/chunk-SU7LN2UH.js.map +0 -1
- package/dist/chunk-XH2Y5NTD.js +0 -715
- package/dist/chunk-XH2Y5NTD.js.map +0 -1
- package/dist/core/assembly.d.ts +0 -25
- package/dist/core/assembly.d.ts.map +0 -1
- package/dist/core/control-adapter.d.ts +0 -42
- package/dist/core/control-adapter.d.ts.map +0 -1
- package/dist/core/descriptor.d.ts +0 -24
- package/dist/core/descriptor.d.ts.map +0 -1
- package/dist/core/instance.d.ts +0 -140
- package/dist/core/instance.d.ts.map +0 -1
- package/dist/core/migrations/plan-helpers.d.ts +0 -20
- package/dist/core/migrations/plan-helpers.d.ts.map +0 -1
- package/dist/core/migrations/policies.d.ts +0 -6
- package/dist/core/migrations/policies.d.ts.map +0 -1
- package/dist/core/migrations/types.d.ts +0 -280
- package/dist/core/migrations/types.d.ts.map +0 -1
- package/dist/core/runtime-descriptor.d.ts +0 -19
- package/dist/core/runtime-descriptor.d.ts.map +0 -1
- package/dist/core/runtime-instance.d.ts +0 -54
- package/dist/core/runtime-instance.d.ts.map +0 -1
- package/dist/core/schema-verify/verify-helpers.d.ts +0 -96
- package/dist/core/schema-verify/verify-helpers.d.ts.map +0 -1
- package/dist/core/schema-verify/verify-sql-schema.d.ts +0 -45
- package/dist/core/schema-verify/verify-sql-schema.d.ts.map +0 -1
- package/dist/core/verify.d.ts +0 -39
- package/dist/core/verify.d.ts.map +0 -1
- package/dist/exports/control-adapter.d.ts +0 -2
- package/dist/exports/control-adapter.d.ts.map +0 -1
- package/dist/exports/control-adapter.js +0 -1
- package/dist/exports/control-adapter.js.map +0 -1
- package/dist/exports/control.d.ts +0 -13
- package/dist/exports/control.d.ts.map +0 -1
- package/dist/exports/control.js +0 -149
- package/dist/exports/control.js.map +0 -1
- package/dist/exports/runtime.d.ts +0 -8
- package/dist/exports/runtime.d.ts.map +0 -1
- package/dist/exports/runtime.js +0 -64
- package/dist/exports/runtime.js.map +0 -1
- package/dist/exports/schema-verify.d.ts +0 -11
- package/dist/exports/schema-verify.d.ts.map +0 -1
- package/dist/exports/schema-verify.js +0 -15
- package/dist/exports/schema-verify.js.map +0 -1
- package/dist/exports/test-utils.d.ts +0 -7
- package/dist/exports/test-utils.d.ts.map +0 -1
- package/dist/exports/test-utils.js +0 -17
- package/dist/exports/test-utils.js.map +0 -1
- package/dist/exports/verify.d.ts +0 -2
- package/dist/exports/verify.d.ts.map +0 -1
- package/dist/exports/verify.js +0 -11
- package/dist/exports/verify.js.map +0 -1
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { ControlAdapterInstance, ControlDriverInstance } from "@prisma-next/core-control-plane/types";
|
|
2
|
+
import { SqlSchemaIR } from "@prisma-next/sql-schema-ir/types";
|
|
3
|
+
|
|
4
|
+
//#region src/core/control-adapter.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* SQL control adapter interface for control-plane operations.
|
|
8
|
+
* Implemented by target-specific adapters (e.g., Postgres, MySQL).
|
|
9
|
+
*
|
|
10
|
+
* @template TTarget - The target ID (e.g., 'postgres', 'mysql')
|
|
11
|
+
*/
|
|
12
|
+
interface SqlControlAdapter<TTarget extends string = string> extends ControlAdapterInstance<'sql', TTarget> {
|
|
13
|
+
/**
|
|
14
|
+
* The target ID this adapter implements.
|
|
15
|
+
* Used for type tracking and runtime validation.
|
|
16
|
+
* @deprecated Use targetId from ControlAdapterInstance instead
|
|
17
|
+
*/
|
|
18
|
+
readonly target: TTarget;
|
|
19
|
+
/**
|
|
20
|
+
* Introspects a database schema and returns a raw SqlSchemaIR.
|
|
21
|
+
*
|
|
22
|
+
* This is a pure schema discovery operation that queries the database catalog
|
|
23
|
+
* and returns the schema structure without type mapping or contract enrichment.
|
|
24
|
+
* Type mapping and enrichment are handled separately by enrichment helpers.
|
|
25
|
+
*
|
|
26
|
+
* @param driver - ControlDriverInstance instance for executing queries (target-specific)
|
|
27
|
+
* @param contractIR - Optional contract IR for contract-guided introspection (filtering, optimization)
|
|
28
|
+
* @param schema - Schema name to introspect (defaults to 'public')
|
|
29
|
+
* @returns Promise resolving to SqlSchemaIR representing the live database schema
|
|
30
|
+
*/
|
|
31
|
+
introspect(driver: ControlDriverInstance<'sql', TTarget>, contractIR?: unknown, schema?: string): Promise<SqlSchemaIR>;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* SQL control adapter descriptor interface.
|
|
35
|
+
* Provides a factory method to create control adapter instances.
|
|
36
|
+
*
|
|
37
|
+
* @template TTarget - The target ID (e.g., 'postgres', 'mysql')
|
|
38
|
+
*/
|
|
39
|
+
interface SqlControlAdapterDescriptor<TTarget extends string = string> {
|
|
40
|
+
/**
|
|
41
|
+
* Creates a SQL control adapter instance for control-plane operations.
|
|
42
|
+
*/
|
|
43
|
+
create(): SqlControlAdapter<TTarget>;
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
export { type SqlControlAdapter, type SqlControlAdapterDescriptor };
|
|
47
|
+
//# sourceMappingURL=control-adapter.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"control-adapter.d.mts","names":[],"sources":["../src/core/control-adapter.ts"],"sourcesContent":[],"mappings":";;;;;;;AAYA;;;;AAsBY,UAtBK,iBAsBL,CAAA,gBAAA,MAAA,GAAA,MAAA,CAAA,SArBF,sBAqBE,CAAA,KAAA,EArB4B,OAqB5B,CAAA,CAAA;EAGC;;;;AASb;mBA3BmB;;;;;;;;;;;;;qBAeP,6BAA6B,kDAGpC,QAAQ;;;;;;;;UASI;;;;YAIL,kBAAkB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { n as SqlControlFamilyInstance, t as SchemaVerifyOptions } from "./instance-wm4TrZN0.mjs";
|
|
2
|
+
import { C as SqlPlannerConflictLocation, E as SqlPlannerSuccessResult, S as SqlPlannerConflictKind, T as SqlPlannerResult, _ as SqlMigrationRunnerExecuteOptions, a as SqlControlExtensionDescriptor, b as SqlMigrationRunnerSuccessValue, c as SqlMigrationPlanContractInfo, d as SqlMigrationPlanOperationTarget, f as SqlMigrationPlanner, g as SqlMigrationRunnerExecuteCallbacks, h as SqlMigrationRunnerErrorCode, i as CreateSqlMigrationPlanOptions, l as SqlMigrationPlanOperation, m as SqlMigrationRunner, n as ComponentDatabaseDependencies, o as SqlControlTargetDescriptor, p as SqlMigrationPlannerPlanOptions, r as ComponentDatabaseDependency, s as SqlMigrationPlan, t as AnyRecord, u as SqlMigrationPlanOperationStep, v as SqlMigrationRunnerFailure, w as SqlPlannerFailureResult, x as SqlPlannerConflict, y as SqlMigrationRunnerResult } from "./types-D5CPT9N4.mjs";
|
|
3
|
+
import { NotOk, Ok } from "@prisma-next/utils/result";
|
|
4
|
+
import { ControlFamilyDescriptor, ControlPlaneStack, MigrationOperationClass, MigrationOperationPolicy, MigrationOperationPolicy as MigrationOperationPolicy$1, MigrationPlan, MigrationPlanOperation, MigrationPlanner, MigrationPlannerConflict, MigrationPlannerResult, TargetMigrationsCapability } from "@prisma-next/core-control-plane/types";
|
|
5
|
+
import * as _prisma_next_contract_ir0 from "@prisma-next/contract/ir";
|
|
6
|
+
import * as _prisma_next_contract_types0 from "@prisma-next/contract/types";
|
|
7
|
+
import * as _prisma_next_sql_contract_types0 from "@prisma-next/sql-contract/types";
|
|
8
|
+
|
|
9
|
+
//#region src/core/descriptor.d.ts
|
|
10
|
+
/**
|
|
11
|
+
* SQL family descriptor implementation.
|
|
12
|
+
* Provides the SQL family hook and factory method.
|
|
13
|
+
*/
|
|
14
|
+
declare class SqlFamilyDescriptor implements ControlFamilyDescriptor<'sql', SqlControlFamilyInstance> {
|
|
15
|
+
readonly kind: "family";
|
|
16
|
+
readonly id = "sql";
|
|
17
|
+
readonly familyId: "sql";
|
|
18
|
+
readonly version = "0.0.1";
|
|
19
|
+
readonly hook: {
|
|
20
|
+
readonly id: "sql";
|
|
21
|
+
readonly validateTypes: (ir: _prisma_next_contract_ir0.ContractIR, _ctx: _prisma_next_contract_types0.ValidationContext) => void;
|
|
22
|
+
readonly validateStructure: (ir: _prisma_next_contract_ir0.ContractIR) => void;
|
|
23
|
+
readonly generateContractTypes: (ir: _prisma_next_contract_ir0.ContractIR, codecTypeImports: ReadonlyArray<_prisma_next_contract_types0.TypesImportSpec>, operationTypeImports: ReadonlyArray<_prisma_next_contract_types0.TypesImportSpec>) => string;
|
|
24
|
+
readonly generateStorageType: (storage: _prisma_next_sql_contract_types0.SqlStorage) => string;
|
|
25
|
+
readonly generateModelsType: (models: Record<string, _prisma_next_sql_contract_types0.ModelDefinition> | undefined, storage: _prisma_next_sql_contract_types0.SqlStorage) => string;
|
|
26
|
+
readonly generateRelationsType: (relations: Record<string, unknown> | undefined) => string;
|
|
27
|
+
readonly generateMappingsType: (models: Record<string, _prisma_next_sql_contract_types0.ModelDefinition> | undefined, storage: _prisma_next_sql_contract_types0.SqlStorage, codecTypes: string, operationTypes: string) => string;
|
|
28
|
+
};
|
|
29
|
+
create<TTargetId extends string>(stack: ControlPlaneStack<'sql', TTargetId>): SqlControlFamilyInstance;
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/core/migrations/plan-helpers.d.ts
|
|
33
|
+
declare function createMigrationPlan<TTargetDetails>(options: CreateSqlMigrationPlanOptions<TTargetDetails>): SqlMigrationPlan<TTargetDetails>;
|
|
34
|
+
declare function plannerSuccess<TTargetDetails>(plan: SqlMigrationPlan<TTargetDetails>): SqlPlannerSuccessResult<TTargetDetails>;
|
|
35
|
+
declare function plannerFailure(conflicts: readonly SqlPlannerConflict[]): SqlPlannerFailureResult;
|
|
36
|
+
/**
|
|
37
|
+
* Creates a successful migration runner result.
|
|
38
|
+
*/
|
|
39
|
+
declare function runnerSuccess(value: {
|
|
40
|
+
operationsPlanned: number;
|
|
41
|
+
operationsExecuted: number;
|
|
42
|
+
}): Ok<SqlMigrationRunnerSuccessValue>;
|
|
43
|
+
/**
|
|
44
|
+
* Creates a failed migration runner result.
|
|
45
|
+
*/
|
|
46
|
+
declare function runnerFailure(code: SqlMigrationRunnerErrorCode, summary: string, options?: {
|
|
47
|
+
why?: string;
|
|
48
|
+
meta?: AnyRecord;
|
|
49
|
+
}): NotOk<SqlMigrationRunnerFailure>;
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region src/core/migrations/policies.d.ts
|
|
52
|
+
/**
|
|
53
|
+
* Policy used by `db init`: additive-only operations, no widening/destructive steps.
|
|
54
|
+
*/
|
|
55
|
+
declare const INIT_ADDITIVE_POLICY: MigrationOperationPolicy$1;
|
|
56
|
+
//#endregion
|
|
57
|
+
//#region src/exports/control.d.ts
|
|
58
|
+
/**
|
|
59
|
+
* SQL family descriptor for control plane (CLI/config).
|
|
60
|
+
* Provides the SQL family hook and conversion helpers.
|
|
61
|
+
*/
|
|
62
|
+
declare const _default: SqlFamilyDescriptor;
|
|
63
|
+
//#endregion
|
|
64
|
+
export { type ComponentDatabaseDependencies, type ComponentDatabaseDependency, type CreateSqlMigrationPlanOptions, INIT_ADDITIVE_POLICY, type MigrationOperationClass, type MigrationOperationPolicy, type MigrationPlan, type MigrationPlanOperation, type MigrationPlanner, type MigrationPlannerConflict, type MigrationPlannerResult, type SchemaVerifyOptions, 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 SqlPlannerConflict, type SqlPlannerConflictKind, type SqlPlannerConflictLocation, type SqlPlannerFailureResult, type SqlPlannerResult, type SqlPlannerSuccessResult, type TargetMigrationsCapability, createMigrationPlan, _default as default, plannerFailure, plannerSuccess, runnerFailure, runnerSuccess };
|
|
65
|
+
//# sourceMappingURL=control.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"control.d.mts","names":[],"sources":["../src/core/descriptor.ts","../src/core/migrations/plan-helpers.ts","../src/core/migrations/policies.ts","../src/exports/control.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;cAWa,mBAAA,YACA,+BAA+B;;;EAD/B,SAAA,QAAA,EAAA,KACX;EAA0C,SAAA,OAAA,GAAA,OAAA;EAAwB,SAAA,IAAA,EAAA;;iCAAA,yBAAA,CAAA;;;;;;;;0CASzD,yBAAyB,aAC/B;;;;iBCuEW,6CACL,8BAA8B,kBACtC,iBAAiB;iBAYJ,qCACR,iBAAiB,kBACtB,wBAAwB;iBAOX,cAAA,qBAAmC,uBAAuB;;;;iBAoB1D,aAAA;ED7HH,iBAAA,EAAA,MACX;EAA0C,kBAAA,EAAA,MAAA;CAAwB,CAAA,EC+HhE,ED/HgE,CC+H7D,8BD/H6D,CAAA;;;;iBC2IpD,aAAA,OACR;;SAE2B;IAChC,MAAM;;;;;;cCtJI,sBAAsB;;;;;;AFMnC;cGsCkC,QHrCU,EGqCV,mBHrCU"}
|
package/dist/control.mjs
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { n as createSqlFamilyInstance } from "./instance-B_PdDN4y.mjs";
|
|
2
|
+
import "./verify-sql-schema-BnLVoeWI.mjs";
|
|
3
|
+
import "./verify-DhFytkFC.mjs";
|
|
4
|
+
import { sqlTargetFamilyHook } from "@prisma-next/sql-contract-emitter";
|
|
5
|
+
import { notOk, ok } from "@prisma-next/utils/result";
|
|
6
|
+
|
|
7
|
+
//#region src/core/descriptor.ts
|
|
8
|
+
/**
|
|
9
|
+
* SQL family descriptor implementation.
|
|
10
|
+
* Provides the SQL family hook and factory method.
|
|
11
|
+
*/
|
|
12
|
+
var SqlFamilyDescriptor = class {
|
|
13
|
+
kind = "family";
|
|
14
|
+
id = "sql";
|
|
15
|
+
familyId = "sql";
|
|
16
|
+
version = "0.0.1";
|
|
17
|
+
hook = sqlTargetFamilyHook;
|
|
18
|
+
create(stack) {
|
|
19
|
+
return createSqlFamilyInstance({
|
|
20
|
+
target: stack.target,
|
|
21
|
+
adapter: stack.adapter,
|
|
22
|
+
extensionPacks: stack.extensionPacks
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/core/migrations/plan-helpers.ts
|
|
29
|
+
const readOnlyEmptyObject = Object.freeze({});
|
|
30
|
+
function cloneRecord(value) {
|
|
31
|
+
if (value === readOnlyEmptyObject) return value;
|
|
32
|
+
return Object.freeze({ ...value });
|
|
33
|
+
}
|
|
34
|
+
function freezeSteps(steps) {
|
|
35
|
+
if (steps.length === 0) return Object.freeze([]);
|
|
36
|
+
return Object.freeze(steps.map((step) => Object.freeze({
|
|
37
|
+
description: step.description,
|
|
38
|
+
sql: step.sql,
|
|
39
|
+
...step.meta ? { meta: cloneRecord(step.meta) } : {}
|
|
40
|
+
})));
|
|
41
|
+
}
|
|
42
|
+
function freezeDetailsValue(value) {
|
|
43
|
+
if (value === null || value === void 0) return value;
|
|
44
|
+
if (typeof value !== "object") return value;
|
|
45
|
+
if (Array.isArray(value)) return Object.freeze([...value]);
|
|
46
|
+
return Object.freeze({ ...value });
|
|
47
|
+
}
|
|
48
|
+
function freezeTargetDetails(target) {
|
|
49
|
+
return Object.freeze({
|
|
50
|
+
id: target.id,
|
|
51
|
+
...target.details !== void 0 ? { details: freezeDetailsValue(target.details) } : {}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
function freezeOperation(operation) {
|
|
55
|
+
return Object.freeze({
|
|
56
|
+
id: operation.id,
|
|
57
|
+
label: operation.label,
|
|
58
|
+
...operation.summary ? { summary: operation.summary } : {},
|
|
59
|
+
operationClass: operation.operationClass,
|
|
60
|
+
target: freezeTargetDetails(operation.target),
|
|
61
|
+
precheck: freezeSteps(operation.precheck),
|
|
62
|
+
execute: freezeSteps(operation.execute),
|
|
63
|
+
postcheck: freezeSteps(operation.postcheck),
|
|
64
|
+
...operation.meta ? { meta: cloneRecord(operation.meta) } : {}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
function freezeOperations(operations) {
|
|
68
|
+
if (operations.length === 0) return Object.freeze([]);
|
|
69
|
+
return Object.freeze(operations.map((operation) => freezeOperation(operation)));
|
|
70
|
+
}
|
|
71
|
+
function createMigrationPlan(options) {
|
|
72
|
+
return Object.freeze({
|
|
73
|
+
targetId: options.targetId,
|
|
74
|
+
...options.origin !== void 0 ? { origin: options.origin ? Object.freeze({ ...options.origin }) : null } : {},
|
|
75
|
+
destination: Object.freeze({ ...options.destination }),
|
|
76
|
+
operations: freezeOperations(options.operations),
|
|
77
|
+
...options.meta ? { meta: cloneRecord(options.meta) } : {}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
function plannerSuccess(plan) {
|
|
81
|
+
return Object.freeze({
|
|
82
|
+
kind: "success",
|
|
83
|
+
plan
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
function plannerFailure(conflicts) {
|
|
87
|
+
return Object.freeze({
|
|
88
|
+
kind: "failure",
|
|
89
|
+
conflicts: Object.freeze(conflicts.map((conflict) => Object.freeze({
|
|
90
|
+
kind: conflict.kind,
|
|
91
|
+
summary: conflict.summary,
|
|
92
|
+
...conflict.why ? { why: conflict.why } : {},
|
|
93
|
+
...conflict.location ? { location: Object.freeze({ ...conflict.location }) } : {},
|
|
94
|
+
...conflict.meta ? { meta: cloneRecord(conflict.meta) } : {}
|
|
95
|
+
})))
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Creates a successful migration runner result.
|
|
100
|
+
*/
|
|
101
|
+
function runnerSuccess(value) {
|
|
102
|
+
return ok(Object.freeze({
|
|
103
|
+
operationsPlanned: value.operationsPlanned,
|
|
104
|
+
operationsExecuted: value.operationsExecuted
|
|
105
|
+
}));
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Creates a failed migration runner result.
|
|
109
|
+
*/
|
|
110
|
+
function runnerFailure(code, summary, options) {
|
|
111
|
+
return notOk(Object.freeze({
|
|
112
|
+
code,
|
|
113
|
+
summary,
|
|
114
|
+
...options?.why ? { why: options.why } : {},
|
|
115
|
+
...options?.meta ? { meta: cloneRecord(options.meta) } : {}
|
|
116
|
+
}));
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
//#endregion
|
|
120
|
+
//#region src/core/migrations/policies.ts
|
|
121
|
+
/**
|
|
122
|
+
* Policy used by `db init`: additive-only operations, no widening/destructive steps.
|
|
123
|
+
*/
|
|
124
|
+
const INIT_ADDITIVE_POLICY = Object.freeze({ allowedOperationClasses: Object.freeze(["additive"]) });
|
|
125
|
+
|
|
126
|
+
//#endregion
|
|
127
|
+
//#region src/exports/control.ts
|
|
128
|
+
/**
|
|
129
|
+
* SQL family descriptor for control plane (CLI/config).
|
|
130
|
+
* Provides the SQL family hook and conversion helpers.
|
|
131
|
+
*/
|
|
132
|
+
var control_default = new SqlFamilyDescriptor();
|
|
133
|
+
|
|
134
|
+
//#endregion
|
|
135
|
+
export { INIT_ADDITIVE_POLICY, createMigrationPlan, control_default as default, plannerFailure, plannerSuccess, runnerFailure, runnerSuccess };
|
|
136
|
+
//# sourceMappingURL=control.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"control.mjs","names":["readOnlyEmptyObject: Record<string, never>","INIT_ADDITIVE_POLICY: MigrationOperationPolicy"],"sources":["../src/core/descriptor.ts","../src/core/migrations/plan-helpers.ts","../src/core/migrations/policies.ts","../src/exports/control.ts"],"sourcesContent":["import type {\n ControlFamilyDescriptor,\n ControlPlaneStack,\n} from '@prisma-next/core-control-plane/types';\nimport { sqlTargetFamilyHook } from '@prisma-next/sql-contract-emitter';\nimport { createSqlFamilyInstance, type SqlControlFamilyInstance } from './instance';\n\n/**\n * SQL family descriptor implementation.\n * Provides the SQL family hook and factory method.\n */\nexport class SqlFamilyDescriptor\n implements ControlFamilyDescriptor<'sql', SqlControlFamilyInstance>\n{\n readonly kind = 'family' as const;\n readonly id = 'sql';\n readonly familyId = 'sql' as const;\n readonly version = '0.0.1';\n readonly hook = sqlTargetFamilyHook;\n\n create<TTargetId extends string>(\n stack: ControlPlaneStack<'sql', TTargetId>,\n ): SqlControlFamilyInstance {\n // Note: driver is not passed here because SqlFamilyInstance operations\n // (validate, emit, etc.) don't require DB connectivity. Commands that\n // need the driver (verify, introspect) get it directly from the stack.\n return createSqlFamilyInstance({\n target: stack.target,\n adapter: stack.adapter,\n extensionPacks: stack.extensionPacks,\n });\n }\n}\n","import type { NotOk, Ok } from '@prisma-next/utils/result';\nimport { notOk, ok } from '@prisma-next/utils/result';\nimport type {\n AnyRecord,\n CreateSqlMigrationPlanOptions,\n SqlMigrationPlan,\n SqlMigrationPlanOperation,\n SqlMigrationPlanOperationStep,\n SqlMigrationPlanOperationTarget,\n SqlMigrationRunnerErrorCode,\n SqlMigrationRunnerFailure,\n SqlMigrationRunnerSuccessValue,\n SqlPlannerConflict,\n SqlPlannerFailureResult,\n SqlPlannerSuccessResult,\n} from './types';\n\nconst readOnlyEmptyObject: Record<string, never> = Object.freeze({});\n\nfunction cloneRecord<T extends AnyRecord>(value: T): T {\n if (value === readOnlyEmptyObject) {\n return value;\n }\n return Object.freeze({ ...value }) as T;\n}\n\nfunction freezeSteps(\n steps: readonly SqlMigrationPlanOperationStep[],\n): readonly SqlMigrationPlanOperationStep[] {\n if (steps.length === 0) {\n return Object.freeze([]);\n }\n return Object.freeze(\n steps.map((step) =>\n Object.freeze({\n description: step.description,\n sql: step.sql,\n ...(step.meta ? { meta: cloneRecord(step.meta) } : {}),\n }),\n ),\n );\n}\n\nfunction freezeDetailsValue<T>(value: T): T {\n // Primitives and null/undefined are already immutable, return as-is\n if (value === null || value === undefined) {\n return value;\n }\n if (typeof value !== 'object') {\n return value;\n }\n // Arrays: shallow clone and freeze\n if (Array.isArray(value)) {\n return Object.freeze([...value]) as T;\n }\n // Objects: shallow clone and freeze (matching cloneRecord pattern)\n return Object.freeze({ ...value }) as T;\n}\n\nfunction freezeTargetDetails<TTargetDetails>(\n target: SqlMigrationPlanOperationTarget<TTargetDetails>,\n): SqlMigrationPlanOperationTarget<TTargetDetails> {\n return Object.freeze({\n id: target.id,\n ...(target.details !== undefined ? { details: freezeDetailsValue(target.details) } : {}),\n });\n}\n\nfunction freezeOperation<TTargetDetails>(\n operation: SqlMigrationPlanOperation<TTargetDetails>,\n): SqlMigrationPlanOperation<TTargetDetails> {\n return Object.freeze({\n id: operation.id,\n label: operation.label,\n ...(operation.summary ? { summary: operation.summary } : {}),\n operationClass: operation.operationClass,\n target: freezeTargetDetails(operation.target),\n precheck: freezeSteps(operation.precheck),\n execute: freezeSteps(operation.execute),\n postcheck: freezeSteps(operation.postcheck),\n ...(operation.meta ? { meta: cloneRecord(operation.meta) } : {}),\n });\n}\n\nfunction freezeOperations<TTargetDetails>(\n operations: readonly SqlMigrationPlanOperation<TTargetDetails>[],\n): readonly SqlMigrationPlanOperation<TTargetDetails>[] {\n if (operations.length === 0) {\n return Object.freeze([]);\n }\n return Object.freeze(operations.map((operation) => freezeOperation(operation)));\n}\n\nexport function createMigrationPlan<TTargetDetails>(\n options: CreateSqlMigrationPlanOptions<TTargetDetails>,\n): SqlMigrationPlan<TTargetDetails> {\n return Object.freeze({\n targetId: options.targetId,\n ...(options.origin !== undefined\n ? { origin: options.origin ? Object.freeze({ ...options.origin }) : null }\n : {}),\n destination: Object.freeze({ ...options.destination }),\n operations: freezeOperations(options.operations),\n ...(options.meta ? { meta: cloneRecord(options.meta) } : {}),\n });\n}\n\nexport function plannerSuccess<TTargetDetails>(\n plan: SqlMigrationPlan<TTargetDetails>,\n): SqlPlannerSuccessResult<TTargetDetails> {\n return Object.freeze({\n kind: 'success',\n plan,\n });\n}\n\nexport function plannerFailure(conflicts: readonly SqlPlannerConflict[]): SqlPlannerFailureResult {\n return Object.freeze({\n kind: 'failure' as const,\n conflicts: Object.freeze(\n conflicts.map((conflict) =>\n Object.freeze({\n kind: conflict.kind,\n summary: conflict.summary,\n ...(conflict.why ? { why: conflict.why } : {}),\n ...(conflict.location ? { location: Object.freeze({ ...conflict.location }) } : {}),\n ...(conflict.meta ? { meta: cloneRecord(conflict.meta) } : {}),\n }),\n ),\n ),\n });\n}\n\n/**\n * Creates a successful migration runner result.\n */\nexport function runnerSuccess(value: {\n operationsPlanned: number;\n operationsExecuted: number;\n}): Ok<SqlMigrationRunnerSuccessValue> {\n return ok(\n Object.freeze({\n operationsPlanned: value.operationsPlanned,\n operationsExecuted: value.operationsExecuted,\n }),\n );\n}\n\n/**\n * Creates a failed migration runner result.\n */\nexport function runnerFailure(\n code: SqlMigrationRunnerErrorCode,\n summary: string,\n options?: { why?: string; meta?: AnyRecord },\n): NotOk<SqlMigrationRunnerFailure> {\n const failure: SqlMigrationRunnerFailure = Object.freeze({\n code,\n summary,\n ...(options?.why ? { why: options.why } : {}),\n ...(options?.meta ? { meta: cloneRecord(options.meta) } : {}),\n });\n return notOk(failure);\n}\n","import type { MigrationOperationPolicy } from '@prisma-next/core-control-plane/types';\n\n/**\n * Policy used by `db init`: additive-only operations, no widening/destructive steps.\n */\nexport const INIT_ADDITIVE_POLICY: MigrationOperationPolicy = Object.freeze({\n allowedOperationClasses: Object.freeze(['additive'] as const),\n});\n","import { SqlFamilyDescriptor } from '../core/descriptor';\n\n// Re-export core types from canonical source\nexport type {\n MigrationOperationClass,\n MigrationOperationPolicy,\n MigrationPlan,\n MigrationPlanner,\n MigrationPlannerConflict,\n MigrationPlannerResult,\n MigrationPlanOperation,\n TargetMigrationsCapability,\n} from '@prisma-next/core-control-plane/types';\nexport type { SchemaVerifyOptions, SqlControlFamilyInstance } from '../core/instance';\nexport {\n createMigrationPlan,\n plannerFailure,\n plannerSuccess,\n runnerFailure,\n runnerSuccess,\n} from '../core/migrations/plan-helpers';\nexport { INIT_ADDITIVE_POLICY } from '../core/migrations/policies';\n// SQL-specific types\nexport type {\n ComponentDatabaseDependencies,\n ComponentDatabaseDependency,\n CreateSqlMigrationPlanOptions,\n SqlControlExtensionDescriptor,\n SqlControlTargetDescriptor,\n SqlMigrationPlan,\n SqlMigrationPlanContractInfo,\n SqlMigrationPlanner,\n SqlMigrationPlannerPlanOptions,\n SqlMigrationPlanOperation,\n SqlMigrationPlanOperationStep,\n SqlMigrationPlanOperationTarget,\n SqlMigrationRunner,\n SqlMigrationRunnerErrorCode,\n SqlMigrationRunnerExecuteCallbacks,\n SqlMigrationRunnerExecuteOptions,\n SqlMigrationRunnerFailure,\n SqlMigrationRunnerResult,\n SqlMigrationRunnerSuccessValue,\n SqlPlannerConflict,\n SqlPlannerConflictKind,\n SqlPlannerConflictLocation,\n SqlPlannerFailureResult,\n SqlPlannerResult,\n SqlPlannerSuccessResult,\n} from '../core/migrations/types';\n\n/**\n * SQL family descriptor for control plane (CLI/config).\n * Provides the SQL family hook and conversion helpers.\n */\nexport default new SqlFamilyDescriptor();\n"],"mappings":";;;;;;;;;;;AAWA,IAAa,sBAAb,MAEA;CACE,AAAS,OAAO;CAChB,AAAS,KAAK;CACd,AAAS,WAAW;CACpB,AAAS,UAAU;CACnB,AAAS,OAAO;CAEhB,OACE,OAC0B;AAI1B,SAAO,wBAAwB;GAC7B,QAAQ,MAAM;GACd,SAAS,MAAM;GACf,gBAAgB,MAAM;GACvB,CAAC;;;;;;ACbN,MAAMA,sBAA6C,OAAO,OAAO,EAAE,CAAC;AAEpE,SAAS,YAAiC,OAAa;AACrD,KAAI,UAAU,oBACZ,QAAO;AAET,QAAO,OAAO,OAAO,EAAE,GAAG,OAAO,CAAC;;AAGpC,SAAS,YACP,OAC0C;AAC1C,KAAI,MAAM,WAAW,EACnB,QAAO,OAAO,OAAO,EAAE,CAAC;AAE1B,QAAO,OAAO,OACZ,MAAM,KAAK,SACT,OAAO,OAAO;EACZ,aAAa,KAAK;EAClB,KAAK,KAAK;EACV,GAAI,KAAK,OAAO,EAAE,MAAM,YAAY,KAAK,KAAK,EAAE,GAAG,EAAE;EACtD,CAAC,CACH,CACF;;AAGH,SAAS,mBAAsB,OAAa;AAE1C,KAAI,UA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