@prisma-next/cli 0.3.0-dev.17 → 0.3.0-dev.19
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/{chunk-ZG5T6OB5.js → chunk-AGOTG4L3.js} +43 -1
- package/dist/chunk-AGOTG4L3.js.map +1 -0
- package/dist/chunk-HLLI4YL7.js +180 -0
- package/dist/chunk-HLLI4YL7.js.map +1 -0
- package/dist/chunk-VG2R7DGF.js +735 -0
- package/dist/chunk-VG2R7DGF.js.map +1 -0
- package/dist/cli.js +1621 -1382
- package/dist/cli.js.map +1 -1
- package/dist/commands/contract-emit.d.ts.map +1 -1
- package/dist/commands/contract-emit.js +3 -4
- package/dist/commands/db-init.js +4 -49
- package/dist/commands/db-init.js.map +1 -1
- package/dist/commands/db-introspect.d.ts.map +1 -1
- package/dist/commands/db-introspect.js +106 -136
- package/dist/commands/db-introspect.js.map +1 -1
- package/dist/commands/db-schema-verify.d.ts.map +1 -1
- package/dist/commands/db-schema-verify.js +118 -110
- package/dist/commands/db-schema-verify.js.map +1 -1
- package/dist/commands/db-sign.d.ts.map +1 -1
- package/dist/commands/db-sign.js +150 -153
- package/dist/commands/db-sign.js.map +1 -1
- package/dist/commands/db-verify.d.ts.map +1 -1
- package/dist/commands/db-verify.js +140 -119
- package/dist/commands/db-verify.js.map +1 -1
- package/dist/control-api/client.d.ts.map +1 -1
- package/dist/control-api/types.d.ts +132 -1
- package/dist/control-api/types.d.ts.map +1 -1
- package/dist/exports/control-api.d.ts +1 -1
- package/dist/exports/control-api.d.ts.map +1 -1
- package/dist/exports/control-api.js +1 -3
- package/dist/exports/index.js +3 -4
- package/dist/exports/index.js.map +1 -1
- package/package.json +10 -10
- package/src/commands/contract-emit.ts +179 -102
- package/src/commands/db-introspect.ts +151 -178
- package/src/commands/db-schema-verify.ts +150 -143
- package/src/commands/db-sign.ts +202 -196
- package/src/commands/db-verify.ts +179 -149
- package/src/control-api/client.ts +352 -22
- package/src/control-api/types.ts +149 -1
- package/src/exports/control-api.ts +9 -0
- package/dist/chunk-5MPKZYVI.js +0 -47
- package/dist/chunk-5MPKZYVI.js.map +0 -1
- package/dist/chunk-6EPKRATC.js +0 -91
- package/dist/chunk-6EPKRATC.js.map +0 -1
- package/dist/chunk-74IELXRA.js +0 -371
- package/dist/chunk-74IELXRA.js.map +0 -1
- package/dist/chunk-U6QI3AZ3.js +0 -133
- package/dist/chunk-U6QI3AZ3.js.map +0 -1
- package/dist/chunk-VI2YETW7.js +0 -38
- package/dist/chunk-VI2YETW7.js.map +0 -1
- package/dist/chunk-ZG5T6OB5.js.map +0 -1
- package/dist/utils/action.d.ts +0 -16
- package/dist/utils/action.d.ts.map +0 -1
- package/dist/utils/spinner.d.ts +0 -29
- package/dist/utils/spinner.d.ts.map +0 -1
- package/src/utils/action.ts +0 -43
- package/src/utils/spinner.ts +0 -67
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/action.ts","../src/utils/spinner.ts"],"sourcesContent":["import type { Result } from '@prisma-next/utils/result';\nimport { notOk, ok } from '@prisma-next/utils/result';\nimport { CliStructuredError } from './cli-errors';\n\nexport type CliResult<T> = Result<T, CliStructuredError>;\n\n/**\n * Performs an async action and catches structured errors, returning a Result.\n * Only catches CliStructuredError instances - other errors are allowed to propagate (fail fast).\n * If the function throws a CliStructuredError, it's caught and converted to a NotOk result.\n */\nexport async function performAction<T>(fn: () => Promise<T>): Promise<CliResult<T>> {\n try {\n const value = await fn();\n return ok(value);\n } catch (error) {\n // Only catch structured errors - let other errors propagate (fail fast)\n if (error instanceof CliStructuredError) {\n return notOk(error);\n }\n // Re-throw non-structured errors to fail fast\n throw error;\n }\n}\n\n/**\n * Wraps a synchronous function to catch structured errors and return a Result.\n * Only catches CliStructuredError instances - other errors are allowed to propagate (fail fast).\n * If the function throws a CliStructuredError, it's caught and converted to a NotOk result.\n */\nexport function wrapSync<T>(fn: () => T): CliResult<T> {\n try {\n const value = fn();\n return ok(value);\n } catch (error) {\n // Only catch structured errors - let other errors propagate (fail fast)\n if (error instanceof CliStructuredError) {\n return notOk(error);\n }\n // Re-throw non-structured errors to fail fast\n throw error;\n }\n}\n","import ora from 'ora';\nimport type { GlobalFlags } from './global-flags';\n\n/**\n * Options for the withSpinner helper function.\n */\ninterface WithSpinnerOptions {\n /**\n * The message to display in the spinner.\n */\n readonly message: string;\n /**\n * Global flags that control spinner behavior (quiet, json, color).\n */\n readonly flags: GlobalFlags;\n}\n\n/**\n * Wraps an async operation with a spinner.\n *\n * The spinner respects:\n * - `flags.quiet`: No spinner if quiet mode is enabled\n * - `flags.json === 'object'`: No spinner if JSON output is enabled\n * - Non-TTY environments: No spinner if stdout is not a TTY\n *\n * @param operation - The async operation to execute\n * @param options - Spinner configuration options\n * @returns The result of the operation\n */\nexport async function withSpinner<T>(\n operation: () => Promise<T>,\n options: WithSpinnerOptions,\n): Promise<T> {\n const { message, flags } = options;\n\n // Skip spinner if quiet, JSON output, or non-TTY\n const shouldShowSpinner = !flags.quiet && flags.json !== 'object' && process.stdout.isTTY;\n\n if (!shouldShowSpinner) {\n // Just execute the operation without spinner\n return operation();\n }\n\n // Start spinner immediately\n const startTime = Date.now();\n const spinner = ora({\n text: message,\n color: flags.color !== false ? 'cyan' : false,\n }).start();\n\n try {\n // Execute the operation\n const result = await operation();\n\n // Mark spinner as succeeded\n const elapsed = Date.now() - startTime;\n spinner.succeed(`${message} (${elapsed}ms)`);\n\n return result;\n } catch (error) {\n // Mark spinner as failed\n spinner.fail(`${message} failed: ${error instanceof Error ? error.message : String(error)}`);\n\n // Re-throw the error\n throw error;\n }\n}\n"],"mappings":";;;;;AACA,SAAS,OAAO,UAAU;AAU1B,eAAsB,cAAiB,IAA6C;AAClF,MAAI;AACF,UAAM,QAAQ,MAAM,GAAG;AACvB,WAAO,GAAG,KAAK;AAAA,EACjB,SAAS,OAAO;AAEd,QAAI,iBAAiB,oBAAoB;AACvC,aAAO,MAAM,KAAK;AAAA,IACpB;AAEA,UAAM;AAAA,EACR;AACF;;;ACvBA,OAAO,SAAS;AA6BhB,eAAsB,YACpB,WACA,SACY;AACZ,QAAM,EAAE,SAAS,MAAM,IAAI;AAG3B,QAAM,oBAAoB,CAAC,MAAM,SAAS,MAAM,SAAS,YAAY,QAAQ,OAAO;AAEpF,MAAI,CAAC,mBAAmB;AAEtB,WAAO,UAAU;AAAA,EACnB;AAGA,QAAM,YAAY,KAAK,IAAI;AAC3B,QAAM,UAAU,IAAI;AAAA,IAClB,MAAM;AAAA,IACN,OAAO,MAAM,UAAU,QAAQ,SAAS;AAAA,EAC1C,CAAC,EAAE,MAAM;AAET,MAAI;AAEF,UAAM,SAAS,MAAM,UAAU;AAG/B,UAAM,UAAU,KAAK,IAAI,IAAI;AAC7B,YAAQ,QAAQ,GAAG,OAAO,KAAK,OAAO,KAAK;AAE3C,WAAO;AAAA,EACT,SAAS,OAAO;AAEd,YAAQ,KAAK,GAAG,OAAO,YAAY,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC,EAAE;AAG3F,UAAM;AAAA,EACR;AACF;","names":[]}
|
package/dist/chunk-6EPKRATC.js
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
errorConfigValidation,
|
|
3
|
-
errorContractMissingExtensionPacks
|
|
4
|
-
} from "./chunk-VI2YETW7.js";
|
|
5
|
-
|
|
6
|
-
// src/utils/framework-components.ts
|
|
7
|
-
import {
|
|
8
|
-
checkContractComponentRequirements
|
|
9
|
-
} from "@prisma-next/contract/framework-components";
|
|
10
|
-
function assertFrameworkComponentsCompatible(expectedFamilyId, expectedTargetId, frameworkComponents) {
|
|
11
|
-
for (let i = 0; i < frameworkComponents.length; i++) {
|
|
12
|
-
const component = frameworkComponents[i];
|
|
13
|
-
if (typeof component !== "object" || component === null) {
|
|
14
|
-
throw errorConfigValidation("frameworkComponents[]", {
|
|
15
|
-
why: `Framework component at index ${i} must be an object`
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
const record = component;
|
|
19
|
-
if (!Object.hasOwn(record, "kind")) {
|
|
20
|
-
throw errorConfigValidation("frameworkComponents[].kind", {
|
|
21
|
-
why: `Framework component at index ${i} must have 'kind' property`
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
const kind = record["kind"];
|
|
25
|
-
if (kind !== "target" && kind !== "adapter" && kind !== "extension" && kind !== "driver") {
|
|
26
|
-
throw errorConfigValidation("frameworkComponents[].kind", {
|
|
27
|
-
why: `Framework component at index ${i} has invalid kind '${String(kind)}' (must be 'target', 'adapter', 'extension', or 'driver')`
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
if (!Object.hasOwn(record, "familyId")) {
|
|
31
|
-
throw errorConfigValidation("frameworkComponents[].familyId", {
|
|
32
|
-
why: `Framework component at index ${i} (kind: ${String(kind)}) must have 'familyId' property`
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
const familyId = record["familyId"];
|
|
36
|
-
if (familyId !== expectedFamilyId) {
|
|
37
|
-
throw errorConfigValidation("frameworkComponents[].familyId", {
|
|
38
|
-
why: `Framework component at index ${i} (kind: ${String(kind)}) has familyId '${String(familyId)}' but expected '${expectedFamilyId}'`
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
if (!Object.hasOwn(record, "targetId")) {
|
|
42
|
-
throw errorConfigValidation("frameworkComponents[].targetId", {
|
|
43
|
-
why: `Framework component at index ${i} (kind: ${String(kind)}) must have 'targetId' property`
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
const targetId = record["targetId"];
|
|
47
|
-
if (targetId !== expectedTargetId) {
|
|
48
|
-
throw errorConfigValidation("frameworkComponents[].targetId", {
|
|
49
|
-
why: `Framework component at index ${i} (kind: ${String(kind)}) has targetId '${String(targetId)}' but expected '${expectedTargetId}'`
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return frameworkComponents;
|
|
54
|
-
}
|
|
55
|
-
function assertContractRequirementsSatisfied({
|
|
56
|
-
contract,
|
|
57
|
-
stack
|
|
58
|
-
}) {
|
|
59
|
-
const providedComponentIds = /* @__PURE__ */ new Set([stack.target.id, stack.adapter.id]);
|
|
60
|
-
for (const extension of stack.extensionPacks) {
|
|
61
|
-
providedComponentIds.add(extension.id);
|
|
62
|
-
}
|
|
63
|
-
const result = checkContractComponentRequirements({
|
|
64
|
-
contract,
|
|
65
|
-
expectedTargetFamily: stack.target.familyId,
|
|
66
|
-
expectedTargetId: stack.target.targetId,
|
|
67
|
-
providedComponentIds
|
|
68
|
-
});
|
|
69
|
-
if (result.familyMismatch) {
|
|
70
|
-
throw errorConfigValidation("contract.targetFamily", {
|
|
71
|
-
why: `Contract was emitted for family '${result.familyMismatch.actual}' but CLI config is wired to '${result.familyMismatch.expected}'.`
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
if (result.targetMismatch) {
|
|
75
|
-
throw errorConfigValidation("contract.target", {
|
|
76
|
-
why: `Contract target '${result.targetMismatch.actual}' does not match CLI target '${result.targetMismatch.expected}'.`
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
if (result.missingExtensionPackIds.length > 0) {
|
|
80
|
-
throw errorContractMissingExtensionPacks({
|
|
81
|
-
missingExtensionPacks: result.missingExtensionPackIds,
|
|
82
|
-
providedComponentIds: [...providedComponentIds]
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export {
|
|
88
|
-
assertFrameworkComponentsCompatible,
|
|
89
|
-
assertContractRequirementsSatisfied
|
|
90
|
-
};
|
|
91
|
-
//# sourceMappingURL=chunk-6EPKRATC.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/framework-components.ts"],"sourcesContent":["import {\n checkContractComponentRequirements,\n type TargetBoundComponentDescriptor,\n} from '@prisma-next/contract/framework-components';\nimport type { ContractIR } from '@prisma-next/contract/ir';\nimport type { ControlPlaneStack } from '@prisma-next/core-control-plane/types';\nimport { errorConfigValidation, errorContractMissingExtensionPacks } from './cli-errors';\n\n/**\n * Asserts that all framework components are compatible with the expected family and target.\n *\n * This function validates that each component in the framework components array:\n * - Has kind 'target', 'adapter', 'extension', or 'driver'\n * - Has familyId matching expectedFamilyId\n * - Has targetId matching expectedTargetId\n *\n * This validation happens at the CLI composition boundary, before passing components\n * to typed planner/runner instances. It fills the gap between runtime validation\n * (via `validateConfig()`) and compile-time type enforcement.\n *\n * @param expectedFamilyId - The expected family ID (e.g., 'sql')\n * @param expectedTargetId - The expected target ID (e.g., 'postgres')\n * @param frameworkComponents - Array of framework components to validate\n * @returns The same array typed as TargetBoundComponentDescriptor\n * @throws CliStructuredError if any component is incompatible\n *\n * @example\n * ```ts\n * const config = await loadConfig();\n * const frameworkComponents = [config.target, config.adapter, ...(config.extensionPacks ?? [])];\n *\n * // Validate and type-narrow components before passing to planner\n * const typedComponents = assertFrameworkComponentsCompatible(\n * config.family.familyId,\n * config.target.targetId,\n * frameworkComponents\n * );\n *\n * const planner = target.migrations.createPlanner(familyInstance);\n * planner.plan({ contract, schema, policy, frameworkComponents: typedComponents });\n * ```\n */\nexport function assertFrameworkComponentsCompatible<\n TFamilyId extends string,\n TTargetId extends string,\n>(\n expectedFamilyId: TFamilyId,\n expectedTargetId: TTargetId,\n frameworkComponents: ReadonlyArray<unknown>,\n): ReadonlyArray<TargetBoundComponentDescriptor<TFamilyId, TTargetId>> {\n for (let i = 0; i < frameworkComponents.length; i++) {\n const component = frameworkComponents[i];\n\n // Check that component is an object\n if (typeof component !== 'object' || component === null) {\n throw errorConfigValidation('frameworkComponents[]', {\n why: `Framework component at index ${i} must be an object`,\n });\n }\n\n const record = component as Record<string, unknown>;\n\n // Check kind\n if (!Object.hasOwn(record, 'kind')) {\n throw errorConfigValidation('frameworkComponents[].kind', {\n why: `Framework component at index ${i} must have 'kind' property`,\n });\n }\n\n const kind = record['kind'];\n if (kind !== 'target' && kind !== 'adapter' && kind !== 'extension' && kind !== 'driver') {\n throw errorConfigValidation('frameworkComponents[].kind', {\n why: `Framework component at index ${i} has invalid kind '${String(kind)}' (must be 'target', 'adapter', 'extension', or 'driver')`,\n });\n }\n\n // Check familyId\n if (!Object.hasOwn(record, 'familyId')) {\n throw errorConfigValidation('frameworkComponents[].familyId', {\n why: `Framework component at index ${i} (kind: ${String(kind)}) must have 'familyId' property`,\n });\n }\n\n const familyId = record['familyId'];\n if (familyId !== expectedFamilyId) {\n throw errorConfigValidation('frameworkComponents[].familyId', {\n why: `Framework component at index ${i} (kind: ${String(kind)}) has familyId '${String(familyId)}' but expected '${expectedFamilyId}'`,\n });\n }\n\n // Check targetId\n if (!Object.hasOwn(record, 'targetId')) {\n throw errorConfigValidation('frameworkComponents[].targetId', {\n why: `Framework component at index ${i} (kind: ${String(kind)}) must have 'targetId' property`,\n });\n }\n\n const targetId = record['targetId'];\n if (targetId !== expectedTargetId) {\n throw errorConfigValidation('frameworkComponents[].targetId', {\n why: `Framework component at index ${i} (kind: ${String(kind)}) has targetId '${String(targetId)}' but expected '${expectedTargetId}'`,\n });\n }\n }\n\n // Type assertion is safe because we've validated all components above\n return frameworkComponents as ReadonlyArray<TargetBoundComponentDescriptor<TFamilyId, TTargetId>>;\n}\n\n/**\n * Validates that a contract is compatible with the configured target, adapter,\n * and extension packs. Throws on family/target mismatches or missing extension packs.\n *\n * This check ensures the emitted contract matches the CLI config before running\n * commands that depend on the contract (e.g., db verify, db sign).\n *\n * @param contract - The contract IR to validate (must include targetFamily, target, extensionPacks).\n * @param stack - The control plane stack (target, adapter, driver, extensionPacks).\n *\n * @throws {CliStructuredError} errorConfigValidation when contract.targetFamily or contract.target\n * doesn't match the configured family/target.\n * @throws {CliStructuredError} errorContractMissingExtensionPacks when the contract requires\n * extension packs that are not provided in the config (includes all missing packs in error.meta).\n *\n * @example\n * ```ts\n * import { assertContractRequirementsSatisfied } from './framework-components';\n *\n * const config = await loadConfig();\n * const contractIR = await loadContractJson(config.contract.output);\n * const stack = createControlPlaneStack({ target: config.target, adapter: config.adapter, ... });\n *\n * // Throws if contract is incompatible with config\n * assertContractRequirementsSatisfied({ contract: contractIR, stack });\n * ```\n */\nexport function assertContractRequirementsSatisfied<\n TFamilyId extends string,\n TTargetId extends string,\n>({\n contract,\n stack,\n}: {\n readonly contract: Pick<ContractIR, 'targetFamily' | 'target' | 'extensionPacks'>;\n readonly stack: ControlPlaneStack<TFamilyId, TTargetId>;\n}): void {\n const providedComponentIds = new Set<string>([stack.target.id, stack.adapter.id]);\n for (const extension of stack.extensionPacks) {\n providedComponentIds.add(extension.id);\n }\n\n const result = checkContractComponentRequirements({\n contract,\n expectedTargetFamily: stack.target.familyId,\n expectedTargetId: stack.target.targetId,\n providedComponentIds,\n });\n\n if (result.familyMismatch) {\n throw errorConfigValidation('contract.targetFamily', {\n why: `Contract was emitted for family '${result.familyMismatch.actual}' but CLI config is wired to '${result.familyMismatch.expected}'.`,\n });\n }\n\n if (result.targetMismatch) {\n throw errorConfigValidation('contract.target', {\n why: `Contract target '${result.targetMismatch.actual}' does not match CLI target '${result.targetMismatch.expected}'.`,\n });\n }\n\n if (result.missingExtensionPackIds.length > 0) {\n throw errorContractMissingExtensionPacks({\n missingExtensionPacks: result.missingExtensionPackIds,\n providedComponentIds: [...providedComponentIds],\n });\n }\n}\n"],"mappings":";;;;;;AAAA;AAAA,EACE;AAAA,OAEK;AAuCA,SAAS,oCAId,kBACA,kBACA,qBACqE;AACrE,WAAS,IAAI,GAAG,IAAI,oBAAoB,QAAQ,KAAK;AACnD,UAAM,YAAY,oBAAoB,CAAC;AAGvC,QAAI,OAAO,cAAc,YAAY,cAAc,MAAM;AACvD,YAAM,sBAAsB,yBAAyB;AAAA,QACnD,KAAK,gCAAgC,CAAC;AAAA,MACxC,CAAC;AAAA,IACH;AAEA,UAAM,SAAS;AAGf,QAAI,CAAC,OAAO,OAAO,QAAQ,MAAM,GAAG;AAClC,YAAM,sBAAsB,8BAA8B;AAAA,QACxD,KAAK,g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,UAAU,EAAE;AAAA,EACvC;AAEA,QAAM,SAAS,mCAAmC;AAAA,IAChD;AAAA,IACA,sBAAsB,MAAM,OAAO;AAAA,IACnC,kBAAkB,MAAM,OAAO;AAAA,IAC/B;AAAA,EACF,CAAC;AAED,MAAI,OAAO,gBAAgB;AACzB,UAAM,sBAAsB,yBAAyB;AAAA,MACnD,KAAK,oCAAoC,OAAO,eAAe,MAAM,iCAAiC,OAAO,eAAe,QAAQ;AAAA,IACtI,CAAC;AAAA,EACH;AAEA,MAAI,OAAO,gBAAgB;AACzB,UAAM,sBAAsB,mBAAmB;AAAA,MAC7C,KAAK,oBAAoB,OAAO,eAAe,MAAM,gCAAgC,OAAO,eAAe,QAAQ;AAAA,IACrH,CAAC;AAAA,EACH;AAEA,MAAI,OAAO,wBAAwB,SAAS,GAAG;AAC7C,UAAM,mCAAmC;AAAA,MACvC,uBAAuB,OAAO;AAAA,MAC9B,sBAAsB,CAAC,GAAG,oBAAoB;AAAA,IAChD,CAAC;AAAA,EACH;AACF;","names":[]}
|
package/dist/chunk-74IELXRA.js
DELETED
|
@@ -1,371 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
assertFrameworkComponentsCompatible
|
|
3
|
-
} from "./chunk-6EPKRATC.js";
|
|
4
|
-
|
|
5
|
-
// src/control-api/client.ts
|
|
6
|
-
import { createControlPlaneStack } from "@prisma-next/core-control-plane/stack";
|
|
7
|
-
|
|
8
|
-
// src/control-api/operations/db-init.ts
|
|
9
|
-
import { notOk, ok } from "@prisma-next/utils/result";
|
|
10
|
-
async function executeDbInit(options) {
|
|
11
|
-
const { driver, familyInstance, contractIR, mode, migrations, frameworkComponents, onProgress } = options;
|
|
12
|
-
const planner = migrations.createPlanner(familyInstance);
|
|
13
|
-
const runner = migrations.createRunner(familyInstance);
|
|
14
|
-
const introspectSpanId = "introspect";
|
|
15
|
-
onProgress?.({
|
|
16
|
-
action: "dbInit",
|
|
17
|
-
kind: "spanStart",
|
|
18
|
-
spanId: introspectSpanId,
|
|
19
|
-
label: "Introspecting database schema"
|
|
20
|
-
});
|
|
21
|
-
const schemaIR = await familyInstance.introspect({ driver });
|
|
22
|
-
onProgress?.({
|
|
23
|
-
action: "dbInit",
|
|
24
|
-
kind: "spanEnd",
|
|
25
|
-
spanId: introspectSpanId,
|
|
26
|
-
outcome: "ok"
|
|
27
|
-
});
|
|
28
|
-
const policy = { allowedOperationClasses: ["additive"] };
|
|
29
|
-
const planSpanId = "plan";
|
|
30
|
-
onProgress?.({
|
|
31
|
-
action: "dbInit",
|
|
32
|
-
kind: "spanStart",
|
|
33
|
-
spanId: planSpanId,
|
|
34
|
-
label: "Planning migration"
|
|
35
|
-
});
|
|
36
|
-
const plannerResult = await planner.plan({
|
|
37
|
-
contract: contractIR,
|
|
38
|
-
schema: schemaIR,
|
|
39
|
-
policy,
|
|
40
|
-
frameworkComponents
|
|
41
|
-
});
|
|
42
|
-
if (plannerResult.kind === "failure") {
|
|
43
|
-
onProgress?.({
|
|
44
|
-
action: "dbInit",
|
|
45
|
-
kind: "spanEnd",
|
|
46
|
-
spanId: planSpanId,
|
|
47
|
-
outcome: "error"
|
|
48
|
-
});
|
|
49
|
-
return notOk({
|
|
50
|
-
code: "PLANNING_FAILED",
|
|
51
|
-
summary: "Migration planning failed due to conflicts",
|
|
52
|
-
conflicts: plannerResult.conflicts,
|
|
53
|
-
why: void 0,
|
|
54
|
-
meta: void 0
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
const migrationPlan = plannerResult.plan;
|
|
58
|
-
onProgress?.({
|
|
59
|
-
action: "dbInit",
|
|
60
|
-
kind: "spanEnd",
|
|
61
|
-
spanId: planSpanId,
|
|
62
|
-
outcome: "ok"
|
|
63
|
-
});
|
|
64
|
-
const checkMarkerSpanId = "checkMarker";
|
|
65
|
-
onProgress?.({
|
|
66
|
-
action: "dbInit",
|
|
67
|
-
kind: "spanStart",
|
|
68
|
-
spanId: checkMarkerSpanId,
|
|
69
|
-
label: "Checking contract marker"
|
|
70
|
-
});
|
|
71
|
-
const existingMarker = await familyInstance.readMarker({ driver });
|
|
72
|
-
if (existingMarker) {
|
|
73
|
-
const markerMatchesDestination = existingMarker.coreHash === migrationPlan.destination.coreHash && (!migrationPlan.destination.profileHash || existingMarker.profileHash === migrationPlan.destination.profileHash);
|
|
74
|
-
if (markerMatchesDestination) {
|
|
75
|
-
onProgress?.({
|
|
76
|
-
action: "dbInit",
|
|
77
|
-
kind: "spanEnd",
|
|
78
|
-
spanId: checkMarkerSpanId,
|
|
79
|
-
outcome: "skipped"
|
|
80
|
-
});
|
|
81
|
-
const result2 = {
|
|
82
|
-
mode,
|
|
83
|
-
plan: { operations: [] },
|
|
84
|
-
...mode === "apply" ? {
|
|
85
|
-
execution: { operationsPlanned: 0, operationsExecuted: 0 },
|
|
86
|
-
marker: {
|
|
87
|
-
coreHash: existingMarker.coreHash,
|
|
88
|
-
profileHash: existingMarker.profileHash
|
|
89
|
-
}
|
|
90
|
-
} : {},
|
|
91
|
-
summary: "Database already at target contract state"
|
|
92
|
-
};
|
|
93
|
-
return ok(result2);
|
|
94
|
-
}
|
|
95
|
-
onProgress?.({
|
|
96
|
-
action: "dbInit",
|
|
97
|
-
kind: "spanEnd",
|
|
98
|
-
spanId: checkMarkerSpanId,
|
|
99
|
-
outcome: "error"
|
|
100
|
-
});
|
|
101
|
-
return notOk({
|
|
102
|
-
code: "MARKER_ORIGIN_MISMATCH",
|
|
103
|
-
summary: "Existing contract marker does not match plan destination",
|
|
104
|
-
marker: {
|
|
105
|
-
coreHash: existingMarker.coreHash,
|
|
106
|
-
profileHash: existingMarker.profileHash
|
|
107
|
-
},
|
|
108
|
-
destination: {
|
|
109
|
-
coreHash: migrationPlan.destination.coreHash,
|
|
110
|
-
profileHash: migrationPlan.destination.profileHash
|
|
111
|
-
},
|
|
112
|
-
why: void 0,
|
|
113
|
-
conflicts: void 0,
|
|
114
|
-
meta: void 0
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
onProgress?.({
|
|
118
|
-
action: "dbInit",
|
|
119
|
-
kind: "spanEnd",
|
|
120
|
-
spanId: checkMarkerSpanId,
|
|
121
|
-
outcome: "ok"
|
|
122
|
-
});
|
|
123
|
-
if (mode === "plan") {
|
|
124
|
-
const result2 = {
|
|
125
|
-
mode: "plan",
|
|
126
|
-
plan: { operations: migrationPlan.operations },
|
|
127
|
-
summary: `Planned ${migrationPlan.operations.length} operation(s)`
|
|
128
|
-
};
|
|
129
|
-
return ok(result2);
|
|
130
|
-
}
|
|
131
|
-
const applySpanId = "apply";
|
|
132
|
-
onProgress?.({
|
|
133
|
-
action: "dbInit",
|
|
134
|
-
kind: "spanStart",
|
|
135
|
-
spanId: applySpanId,
|
|
136
|
-
label: "Applying migration plan"
|
|
137
|
-
});
|
|
138
|
-
const callbacks = onProgress ? {
|
|
139
|
-
onOperationStart: (op) => {
|
|
140
|
-
onProgress({
|
|
141
|
-
action: "dbInit",
|
|
142
|
-
kind: "spanStart",
|
|
143
|
-
spanId: `operation:${op.id}`,
|
|
144
|
-
parentSpanId: applySpanId,
|
|
145
|
-
label: op.label
|
|
146
|
-
});
|
|
147
|
-
},
|
|
148
|
-
onOperationComplete: (op) => {
|
|
149
|
-
onProgress({
|
|
150
|
-
action: "dbInit",
|
|
151
|
-
kind: "spanEnd",
|
|
152
|
-
spanId: `operation:${op.id}`,
|
|
153
|
-
outcome: "ok"
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
} : void 0;
|
|
157
|
-
const runnerResult = await runner.execute({
|
|
158
|
-
plan: migrationPlan,
|
|
159
|
-
driver,
|
|
160
|
-
destinationContract: contractIR,
|
|
161
|
-
policy,
|
|
162
|
-
...callbacks ? { callbacks } : {},
|
|
163
|
-
// db init plans and applies back-to-back from a fresh introspection, so per-operation
|
|
164
|
-
// pre/postchecks and the idempotency probe are usually redundant overhead. We still
|
|
165
|
-
// enforce marker/origin compatibility and a full schema verification after apply.
|
|
166
|
-
executionChecks: {
|
|
167
|
-
prechecks: false,
|
|
168
|
-
postchecks: false,
|
|
169
|
-
idempotencyChecks: false
|
|
170
|
-
},
|
|
171
|
-
frameworkComponents
|
|
172
|
-
});
|
|
173
|
-
if (!runnerResult.ok) {
|
|
174
|
-
onProgress?.({
|
|
175
|
-
action: "dbInit",
|
|
176
|
-
kind: "spanEnd",
|
|
177
|
-
spanId: applySpanId,
|
|
178
|
-
outcome: "error"
|
|
179
|
-
});
|
|
180
|
-
return notOk({
|
|
181
|
-
code: "RUNNER_FAILED",
|
|
182
|
-
summary: runnerResult.failure.summary,
|
|
183
|
-
why: runnerResult.failure.why,
|
|
184
|
-
meta: runnerResult.failure.meta,
|
|
185
|
-
conflicts: void 0
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
const execution = runnerResult.value;
|
|
189
|
-
onProgress?.({
|
|
190
|
-
action: "dbInit",
|
|
191
|
-
kind: "spanEnd",
|
|
192
|
-
spanId: applySpanId,
|
|
193
|
-
outcome: "ok"
|
|
194
|
-
});
|
|
195
|
-
const result = {
|
|
196
|
-
mode: "apply",
|
|
197
|
-
plan: { operations: migrationPlan.operations },
|
|
198
|
-
execution: {
|
|
199
|
-
operationsPlanned: execution.operationsPlanned,
|
|
200
|
-
operationsExecuted: execution.operationsExecuted
|
|
201
|
-
},
|
|
202
|
-
marker: migrationPlan.destination.profileHash ? {
|
|
203
|
-
coreHash: migrationPlan.destination.coreHash,
|
|
204
|
-
profileHash: migrationPlan.destination.profileHash
|
|
205
|
-
} : { coreHash: migrationPlan.destination.coreHash },
|
|
206
|
-
summary: `Applied ${execution.operationsExecuted} operation(s), marker written`
|
|
207
|
-
};
|
|
208
|
-
return ok(result);
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
// src/control-api/client.ts
|
|
212
|
-
function createControlClient(options) {
|
|
213
|
-
return new ControlClientImpl(options);
|
|
214
|
-
}
|
|
215
|
-
var ControlClientImpl = class {
|
|
216
|
-
options;
|
|
217
|
-
stack = null;
|
|
218
|
-
driver = null;
|
|
219
|
-
familyInstance = null;
|
|
220
|
-
frameworkComponents = null;
|
|
221
|
-
initialized = false;
|
|
222
|
-
defaultConnection;
|
|
223
|
-
constructor(options) {
|
|
224
|
-
this.options = options;
|
|
225
|
-
this.defaultConnection = options.connection;
|
|
226
|
-
}
|
|
227
|
-
init() {
|
|
228
|
-
if (this.initialized) {
|
|
229
|
-
return;
|
|
230
|
-
}
|
|
231
|
-
this.stack = createControlPlaneStack({
|
|
232
|
-
target: this.options.target,
|
|
233
|
-
adapter: this.options.adapter,
|
|
234
|
-
driver: this.options.driver,
|
|
235
|
-
extensionPacks: this.options.extensionPacks
|
|
236
|
-
});
|
|
237
|
-
this.familyInstance = this.options.family.create(this.stack);
|
|
238
|
-
const rawComponents = [
|
|
239
|
-
this.options.target,
|
|
240
|
-
this.options.adapter,
|
|
241
|
-
...this.options.extensionPacks ?? []
|
|
242
|
-
];
|
|
243
|
-
this.frameworkComponents = assertFrameworkComponentsCompatible(
|
|
244
|
-
this.options.family.familyId,
|
|
245
|
-
this.options.target.targetId,
|
|
246
|
-
rawComponents
|
|
247
|
-
);
|
|
248
|
-
this.initialized = true;
|
|
249
|
-
}
|
|
250
|
-
async connect(connection) {
|
|
251
|
-
this.init();
|
|
252
|
-
if (this.driver) {
|
|
253
|
-
throw new Error("Already connected. Call close() before reconnecting.");
|
|
254
|
-
}
|
|
255
|
-
const resolvedConnection = connection ?? this.defaultConnection;
|
|
256
|
-
if (resolvedConnection === void 0) {
|
|
257
|
-
throw new Error(
|
|
258
|
-
"No connection provided. Pass a connection to connect() or provide a default connection when creating the client."
|
|
259
|
-
);
|
|
260
|
-
}
|
|
261
|
-
if (!this.stack?.driver) {
|
|
262
|
-
throw new Error(
|
|
263
|
-
"Driver is not configured. Pass a driver descriptor when creating the control client to enable database operations."
|
|
264
|
-
);
|
|
265
|
-
}
|
|
266
|
-
this.driver = await this.stack?.driver.create(resolvedConnection);
|
|
267
|
-
}
|
|
268
|
-
async close() {
|
|
269
|
-
if (this.driver) {
|
|
270
|
-
await this.driver.close();
|
|
271
|
-
this.driver = null;
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
async ensureConnected() {
|
|
275
|
-
this.init();
|
|
276
|
-
if (!this.driver && this.defaultConnection !== void 0) {
|
|
277
|
-
await this.connect(this.defaultConnection);
|
|
278
|
-
}
|
|
279
|
-
if (!this.driver || !this.familyInstance || !this.frameworkComponents) {
|
|
280
|
-
throw new Error("Not connected. Call connect(connection) first.");
|
|
281
|
-
}
|
|
282
|
-
return {
|
|
283
|
-
driver: this.driver,
|
|
284
|
-
familyInstance: this.familyInstance,
|
|
285
|
-
frameworkComponents: this.frameworkComponents
|
|
286
|
-
};
|
|
287
|
-
}
|
|
288
|
-
async verify(options) {
|
|
289
|
-
const { driver, familyInstance } = await this.ensureConnected();
|
|
290
|
-
const contractIR = familyInstance.validateContractIR(options.contractIR);
|
|
291
|
-
return familyInstance.verify({
|
|
292
|
-
driver,
|
|
293
|
-
contractIR,
|
|
294
|
-
expectedTargetId: this.options.target.targetId,
|
|
295
|
-
contractPath: ""
|
|
296
|
-
});
|
|
297
|
-
}
|
|
298
|
-
async schemaVerify(options) {
|
|
299
|
-
const { driver, familyInstance, frameworkComponents } = await this.ensureConnected();
|
|
300
|
-
const contractIR = familyInstance.validateContractIR(options.contractIR);
|
|
301
|
-
return familyInstance.schemaVerify({
|
|
302
|
-
driver,
|
|
303
|
-
contractIR,
|
|
304
|
-
strict: options.strict ?? false,
|
|
305
|
-
contractPath: "",
|
|
306
|
-
frameworkComponents
|
|
307
|
-
});
|
|
308
|
-
}
|
|
309
|
-
async sign(options) {
|
|
310
|
-
const { driver, familyInstance } = await this.ensureConnected();
|
|
311
|
-
const contractIR = familyInstance.validateContractIR(options.contractIR);
|
|
312
|
-
return familyInstance.sign({
|
|
313
|
-
driver,
|
|
314
|
-
contractIR,
|
|
315
|
-
contractPath: ""
|
|
316
|
-
});
|
|
317
|
-
}
|
|
318
|
-
async dbInit(options) {
|
|
319
|
-
const { onProgress } = options;
|
|
320
|
-
if (options.connection !== void 0) {
|
|
321
|
-
onProgress?.({
|
|
322
|
-
action: "dbInit",
|
|
323
|
-
kind: "spanStart",
|
|
324
|
-
spanId: "connect",
|
|
325
|
-
label: "Connecting to database..."
|
|
326
|
-
});
|
|
327
|
-
try {
|
|
328
|
-
await this.connect(options.connection);
|
|
329
|
-
onProgress?.({
|
|
330
|
-
action: "dbInit",
|
|
331
|
-
kind: "spanEnd",
|
|
332
|
-
spanId: "connect",
|
|
333
|
-
outcome: "ok"
|
|
334
|
-
});
|
|
335
|
-
} catch (error) {
|
|
336
|
-
onProgress?.({
|
|
337
|
-
action: "dbInit",
|
|
338
|
-
kind: "spanEnd",
|
|
339
|
-
spanId: "connect",
|
|
340
|
-
outcome: "error"
|
|
341
|
-
});
|
|
342
|
-
throw error;
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
const { driver, familyInstance, frameworkComponents } = await this.ensureConnected();
|
|
346
|
-
if (!this.options.target.migrations) {
|
|
347
|
-
throw new Error(`Target "${this.options.target.targetId}" does not support migrations`);
|
|
348
|
-
}
|
|
349
|
-
const contractIR = familyInstance.validateContractIR(options.contractIR);
|
|
350
|
-
return executeDbInit({
|
|
351
|
-
driver,
|
|
352
|
-
familyInstance,
|
|
353
|
-
contractIR,
|
|
354
|
-
mode: options.mode,
|
|
355
|
-
migrations: this.options.target.migrations,
|
|
356
|
-
frameworkComponents,
|
|
357
|
-
...onProgress ? { onProgress } : {}
|
|
358
|
-
});
|
|
359
|
-
}
|
|
360
|
-
async introspect(options) {
|
|
361
|
-
const { driver, familyInstance } = await this.ensureConnected();
|
|
362
|
-
const _schema = options?.schema;
|
|
363
|
-
void _schema;
|
|
364
|
-
return familyInstance.introspect({ driver });
|
|
365
|
-
}
|
|
366
|
-
};
|
|
367
|
-
|
|
368
|
-
export {
|
|
369
|
-
createControlClient
|
|
370
|
-
};
|
|
371
|
-
//# sourceMappingURL=chunk-74IELXRA.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/control-api/client.ts","../src/control-api/operations/db-init.ts"],"sourcesContent":["import type { TargetBoundComponentDescriptor } from '@prisma-next/contract/framework-components';\nimport { createControlPlaneStack } from '@prisma-next/core-control-plane/stack';\nimport type {\n ControlDriverInstance,\n ControlFamilyInstance,\n ControlPlaneStack,\n SignDatabaseResult,\n VerifyDatabaseResult,\n VerifyDatabaseSchemaResult,\n} from '@prisma-next/core-control-plane/types';\nimport { assertFrameworkComponentsCompatible } from '../utils/framework-components';\nimport { executeDbInit } from './operations/db-init';\nimport type {\n ControlClient,\n ControlClientOptions,\n DbInitOptions,\n DbInitResult,\n IntrospectOptions,\n SchemaVerifyOptions,\n SignOptions,\n VerifyOptions,\n} from './types';\n\n/**\n * Creates a programmatic control client for Prisma Next operations.\n *\n * The client accepts framework component descriptors at creation time,\n * manages driver lifecycle via connect()/close(), and exposes domain\n * operations that delegate to the existing family instance methods.\n *\n * @see {@link ControlClient} for the client interface\n * @see README.md \"Programmatic Control API\" section for usage examples\n */\nexport function createControlClient(options: ControlClientOptions): ControlClient {\n return new ControlClientImpl(options);\n}\n\n/**\n * Implementation of ControlClient.\n * Manages initialization and connection state, delegates operations to family instance.\n */\nclass ControlClientImpl implements ControlClient {\n private readonly options: ControlClientOptions;\n private stack: ControlPlaneStack<string, string> | null = null;\n private driver: ControlDriverInstance<string, string> | null = null;\n private familyInstance: ControlFamilyInstance<string> | null = null;\n private frameworkComponents: ReadonlyArray<\n TargetBoundComponentDescriptor<string, string>\n > | null = null;\n private initialized = false;\n private readonly defaultConnection: unknown;\n\n constructor(options: ControlClientOptions) {\n this.options = options;\n this.defaultConnection = options.connection;\n }\n\n init(): void {\n if (this.initialized) {\n return; // Idempotent\n }\n\n // Create the control plane stack\n this.stack = createControlPlaneStack({\n target: this.options.target,\n adapter: this.options.adapter,\n driver: this.options.driver,\n extensionPacks: this.options.extensionPacks,\n });\n\n // Create family instance using the stack\n this.familyInstance = this.options.family.create(this.stack);\n\n // Validate and type-narrow framework components\n const rawComponents = [\n this.options.target,\n this.options.adapter,\n ...(this.options.extensionPacks ?? []),\n ];\n this.frameworkComponents = assertFrameworkComponentsCompatible(\n this.options.family.familyId,\n this.options.target.targetId,\n rawComponents,\n );\n\n this.initialized = true;\n }\n\n async connect(connection?: unknown): Promise<void> {\n // Auto-init if needed\n this.init();\n\n if (this.driver) {\n throw new Error('Already connected. Call close() before reconnecting.');\n }\n\n // Resolve connection: argument > default from options\n const resolvedConnection = connection ?? this.defaultConnection;\n if (resolvedConnection === undefined) {\n throw new Error(\n 'No connection provided. Pass a connection to connect() or provide a default connection when creating the client.',\n );\n }\n\n // Check for driver descriptor\n if (!this.stack?.driver) {\n throw new Error(\n 'Driver is not configured. Pass a driver descriptor when creating the control client to enable database operations.',\n );\n }\n\n // Create driver instance\n // Cast through any since connection type is driver-specific at runtime.\n // The driver descriptor is typed with any for TConnection in ControlClientOptions,\n // but createControlPlaneStack defaults it to string. We bridge this at runtime.\n // biome-ignore lint/suspicious/noExplicitAny: required for runtime connection type flexibility\n this.driver = await this.stack?.driver.create(resolvedConnection as any);\n }\n\n async close(): Promise<void> {\n if (this.driver) {\n await this.driver.close();\n this.driver = null;\n }\n }\n\n private async ensureConnected(): Promise<{\n driver: ControlDriverInstance<string, string>;\n familyInstance: ControlFamilyInstance<string>;\n frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<string, string>>;\n }> {\n // Auto-init if needed\n this.init();\n\n // Auto-connect if not connected and default connection is available\n if (!this.driver && this.defaultConnection !== undefined) {\n await this.connect(this.defaultConnection);\n }\n\n if (!this.driver || !this.familyInstance || !this.frameworkComponents) {\n throw new Error('Not connected. Call connect(connection) first.');\n }\n return {\n driver: this.driver,\n familyInstance: this.familyInstance,\n frameworkComponents: this.frameworkComponents,\n };\n }\n\n async verify(options: VerifyOptions): Promise<VerifyDatabaseResult> {\n const { driver, familyInstance } = await this.ensureConnected();\n\n // Validate contract using family instance\n const contractIR = familyInstance.validateContractIR(options.contractIR);\n\n // Delegate to family instance verify method\n // Note: We pass empty strings for contractPath/configPath since the programmatic\n // API doesn't deal with file paths. The family instance accepts these as optional\n // metadata for error reporting.\n return familyInstance.verify({\n driver,\n contractIR,\n expectedTargetId: this.options.target.targetId,\n contractPath: '',\n });\n }\n\n async schemaVerify(options: SchemaVerifyOptions): Promise<VerifyDatabaseSchemaResult> {\n const { driver, familyInstance, frameworkComponents } = await this.ensureConnected();\n\n // Validate contract using family instance\n const contractIR = familyInstance.validateContractIR(options.contractIR);\n\n // Delegate to family instance schemaVerify method\n return familyInstance.schemaVerify({\n driver,\n contractIR,\n strict: options.strict ?? false,\n contractPath: '',\n frameworkComponents,\n });\n }\n\n async sign(options: SignOptions): Promise<SignDatabaseResult> {\n const { driver, familyInstance } = await this.ensureConnected();\n\n // Validate contract using family instance\n const contractIR = familyInstance.validateContractIR(options.contractIR);\n\n // Delegate to family instance sign method\n return familyInstance.sign({\n driver,\n contractIR,\n contractPath: '',\n });\n }\n\n async dbInit(options: DbInitOptions): Promise<DbInitResult> {\n const { onProgress } = options;\n\n // Connect with progress span if connection provided\n if (options.connection !== undefined) {\n onProgress?.({\n action: 'dbInit',\n kind: 'spanStart',\n spanId: 'connect',\n label: 'Connecting to database...',\n });\n try {\n await this.connect(options.connection);\n onProgress?.({\n action: 'dbInit',\n kind: 'spanEnd',\n spanId: 'connect',\n outcome: 'ok',\n });\n } catch (error) {\n onProgress?.({\n action: 'dbInit',\n kind: 'spanEnd',\n spanId: 'connect',\n outcome: 'error',\n });\n throw error;\n }\n }\n\n const { driver, familyInstance, frameworkComponents } = await this.ensureConnected();\n\n // Check target supports migrations\n if (!this.options.target.migrations) {\n throw new Error(`Target \"${this.options.target.targetId}\" does not support migrations`);\n }\n\n // Validate contract using family instance\n const contractIR = familyInstance.validateContractIR(options.contractIR);\n\n // Delegate to extracted dbInit operation\n return executeDbInit({\n driver,\n familyInstance,\n contractIR,\n mode: options.mode,\n migrations: this.options.target.migrations,\n frameworkComponents,\n ...(onProgress ? { onProgress } : {}),\n });\n }\n\n async introspect(options?: IntrospectOptions): Promise<unknown> {\n const { driver, familyInstance } = await this.ensureConnected();\n\n // TODO: Pass schema option to familyInstance.introspect when schema filtering is implemented\n const _schema = options?.schema;\n void _schema;\n\n return familyInstance.introspect({ driver });\n }\n}\n","import type { TargetBoundComponentDescriptor } from '@prisma-next/contract/framework-components';\nimport type { ContractIR } from '@prisma-next/contract/ir';\nimport type {\n ControlDriverInstance,\n ControlFamilyInstance,\n MigrationPlan,\n MigrationPlannerResult,\n MigrationPlanOperation,\n MigrationRunnerResult,\n TargetMigrationsCapability,\n} from '@prisma-next/core-control-plane/types';\nimport { notOk, ok } from '@prisma-next/utils/result';\nimport type { DbInitResult, DbInitSuccess, OnControlProgress } from '../types';\n\n/**\n * Options for executing dbInit operation.\n */\nexport interface ExecuteDbInitOptions<TFamilyId extends string, TTargetId extends string> {\n readonly driver: ControlDriverInstance<TFamilyId, TTargetId>;\n readonly familyInstance: ControlFamilyInstance<TFamilyId>;\n readonly contractIR: ContractIR;\n readonly mode: 'plan' | 'apply';\n readonly migrations: TargetMigrationsCapability<\n TFamilyId,\n TTargetId,\n ControlFamilyInstance<TFamilyId>\n >;\n readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<TFamilyId, TTargetId>>;\n /** Optional progress callback for observing operation progress */\n readonly onProgress?: OnControlProgress;\n}\n\n/**\n * Executes the dbInit operation.\n *\n * This is the core logic extracted from the CLI command, without any file I/O,\n * process.exit(), or console output. It uses the Result pattern to return\n * success or failure details.\n *\n * @param options - The options for executing dbInit\n * @returns Result with DbInitSuccess on success, DbInitFailure on failure\n */\nexport async function executeDbInit<TFamilyId extends string, TTargetId extends string>(\n options: ExecuteDbInitOptions<TFamilyId, TTargetId>,\n): Promise<DbInitResult> {\n const { driver, familyInstance, contractIR, mode, migrations, frameworkComponents, onProgress } =\n options;\n\n // Create planner and runner from target migrations capability\n const planner = migrations.createPlanner(familyInstance);\n const runner = migrations.createRunner(familyInstance);\n\n // Introspect live schema\n const introspectSpanId = 'introspect';\n onProgress?.({\n action: 'dbInit',\n kind: 'spanStart',\n spanId: introspectSpanId,\n label: 'Introspecting database schema',\n });\n const schemaIR = await familyInstance.introspect({ driver });\n onProgress?.({\n action: 'dbInit',\n kind: 'spanEnd',\n spanId: introspectSpanId,\n outcome: 'ok',\n });\n\n // Policy for init mode (additive only)\n const policy = { allowedOperationClasses: ['additive'] as const };\n\n // Plan migration\n const planSpanId = 'plan';\n onProgress?.({\n action: 'dbInit',\n kind: 'spanStart',\n spanId: planSpanId,\n label: 'Planning migration',\n });\n const plannerResult: MigrationPlannerResult = await planner.plan({\n contract: contractIR,\n schema: schemaIR,\n policy,\n frameworkComponents,\n });\n\n if (plannerResult.kind === 'failure') {\n onProgress?.({\n action: 'dbInit',\n kind: 'spanEnd',\n spanId: planSpanId,\n outcome: 'error',\n });\n return notOk({\n code: 'PLANNING_FAILED' as const,\n summary: 'Migration planning failed due to conflicts',\n conflicts: plannerResult.conflicts,\n why: undefined,\n meta: undefined,\n });\n }\n\n const migrationPlan: MigrationPlan = plannerResult.plan;\n onProgress?.({\n action: 'dbInit',\n kind: 'spanEnd',\n spanId: planSpanId,\n outcome: 'ok',\n });\n\n // Check for existing marker - handle idempotency and mismatch errors\n const checkMarkerSpanId = 'checkMarker';\n onProgress?.({\n action: 'dbInit',\n kind: 'spanStart',\n spanId: checkMarkerSpanId,\n label: 'Checking contract marker',\n });\n const existingMarker = await familyInstance.readMarker({ driver });\n if (existingMarker) {\n const markerMatchesDestination =\n existingMarker.coreHash === migrationPlan.destination.coreHash &&\n (!migrationPlan.destination.profileHash ||\n existingMarker.profileHash === migrationPlan.destination.profileHash);\n\n if (markerMatchesDestination) {\n // Already at destination - return success with no operations\n onProgress?.({\n action: 'dbInit',\n kind: 'spanEnd',\n spanId: checkMarkerSpanId,\n outcome: 'skipped',\n });\n const result: DbInitSuccess = {\n mode,\n plan: { operations: [] },\n ...(mode === 'apply'\n ? {\n execution: { operationsPlanned: 0, operationsExecuted: 0 },\n marker: {\n coreHash: existingMarker.coreHash,\n profileHash: existingMarker.profileHash,\n },\n }\n : {}),\n summary: 'Database already at target contract state',\n };\n return ok(result);\n }\n\n // Marker exists but doesn't match destination - fail\n onProgress?.({\n action: 'dbInit',\n kind: 'spanEnd',\n spanId: checkMarkerSpanId,\n outcome: 'error',\n });\n return notOk({\n code: 'MARKER_ORIGIN_MISMATCH' as const,\n summary: 'Existing contract marker does not match plan destination',\n marker: {\n coreHash: existingMarker.coreHash,\n profileHash: existingMarker.profileHash,\n },\n destination: {\n coreHash: migrationPlan.destination.coreHash,\n profileHash: migrationPlan.destination.profileHash,\n },\n why: undefined,\n conflicts: undefined,\n meta: undefined,\n });\n }\n\n onProgress?.({\n action: 'dbInit',\n kind: 'spanEnd',\n spanId: checkMarkerSpanId,\n outcome: 'ok',\n });\n\n // Plan mode - don't execute\n if (mode === 'plan') {\n const result: DbInitSuccess = {\n mode: 'plan',\n plan: { operations: migrationPlan.operations },\n summary: `Planned ${migrationPlan.operations.length} operation(s)`,\n };\n return ok(result);\n }\n\n // Apply mode - execute runner\n const applySpanId = 'apply';\n onProgress?.({\n action: 'dbInit',\n kind: 'spanStart',\n spanId: applySpanId,\n label: 'Applying migration plan',\n });\n\n const callbacks = onProgress\n ? {\n onOperationStart: (op: MigrationPlanOperation) => {\n onProgress({\n action: 'dbInit',\n kind: 'spanStart',\n spanId: `operation:${op.id}`,\n parentSpanId: applySpanId,\n label: op.label,\n });\n },\n onOperationComplete: (op: MigrationPlanOperation) => {\n onProgress({\n action: 'dbInit',\n kind: 'spanEnd',\n spanId: `operation:${op.id}`,\n outcome: 'ok',\n });\n },\n }\n : undefined;\n\n const runnerResult: MigrationRunnerResult = await runner.execute({\n plan: migrationPlan,\n driver,\n destinationContract: contractIR,\n policy,\n ...(callbacks ? { callbacks } : {}),\n // db init plans and applies back-to-back from a fresh introspection, so per-operation\n // pre/postchecks and the idempotency probe are usually redundant overhead. We still\n // enforce marker/origin compatibility and a full schema verification after apply.\n executionChecks: {\n prechecks: false,\n postchecks: false,\n idempotencyChecks: false,\n },\n frameworkComponents,\n });\n\n if (!runnerResult.ok) {\n onProgress?.({\n action: 'dbInit',\n kind: 'spanEnd',\n spanId: applySpanId,\n outcome: 'error',\n });\n return notOk({\n code: 'RUNNER_FAILED' as const,\n summary: runnerResult.failure.summary,\n why: runnerResult.failure.why,\n meta: runnerResult.failure.meta,\n conflicts: undefined,\n });\n }\n\n const execution = runnerResult.value;\n\n onProgress?.({\n action: 'dbInit',\n kind: 'spanEnd',\n spanId: applySpanId,\n outcome: 'ok',\n });\n\n const result: DbInitSuccess = {\n mode: 'apply',\n plan: { operations: migrationPlan.operations },\n execution: {\n operationsPlanned: execution.operationsPlanned,\n operationsExecuted: execution.operationsExecuted,\n },\n marker: migrationPlan.destination.profileHash\n ? {\n coreHash: migrationPlan.destination.coreHash,\n profileHash: migrationPlan.destination.profileHash,\n }\n : { coreHash: migrationPlan.destination.coreHash },\n summary: `Applied ${execution.operationsExecuted} operation(s), marker written`,\n };\n return ok(result);\n}\n"],"mappings":";;;;;AACA,SAAS,+BAA+B;;;ACUxC,SAAS,OAAO,UAAU;AA+B1B,eAAsB,cACpB,SACuB;AACvB,QAAM,EAAE,QAAQ,gBAAgB,YAAY,MAAM,YAAY,qBAAqB,WAAW,IAC5F;AAGF,QAAM,UAAU,WAAW,cAAc,cAAc;AACvD,QAAM,SAAS,WAAW,aAAa,cAAc;AAGrD,QAAM,mBAAmB;AACzB,eAAa;AAAA,IACX,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,OAAO;AAAA,EACT,CAAC;AACD,QAAM,WAAW,MAAM,eAAe,WAAW,EAAE,OAAO,CAAC;AAC3D,eAAa;AAAA,IACX,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,SAAS;AAAA,EACX,CAAC;AAGD,QAAM,SAAS,EAAE,yBAAyB,CA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