@prisma/orm-toolchain 8.0.0-rc.3-dev.1 → 8.0.0-rc.3-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/cli-telemetry.mjs +1 -1
- package/dist/cli.mjs +6 -6
- package/dist/cli.mjs.map +1 -1
- package/dist/cli__control-api.d.mts +1 -1
- package/dist/cli__control-api.mjs +1 -1
- package/dist/cli__migration-cli.mjs +3 -3
- package/dist/cli__migration-cli.mjs.map +1 -1
- package/dist/config-loader.d.mts +1 -1
- package/dist/config-loader.mjs +1 -1
- package/dist/{exports-8ZUN43ve.mjs → exports-DLDFkjNv.mjs} +2 -2
- package/dist/{exports-8ZUN43ve.mjs.map → exports-DLDFkjNv.mjs.map} +1 -1
- package/dist/{exports-BZaG8_w_.mjs → exports-UjssmDwy.mjs} +16 -2
- package/dist/exports-UjssmDwy.mjs.map +1 -0
- package/dist/{index-DRs7L6N0.d.mts → index-BRjNSwL-.d.mts} +1 -10
- package/dist/index-BRjNSwL-.d.mts.map +1 -0
- package/dist/{migration-hspPIEeV.mjs → migration-BB4LDjuS.mjs} +2 -2
- package/dist/{migration-hspPIEeV.mjs.map → migration-BB4LDjuS.mjs.map} +1 -1
- package/dist/migration-tools.mjs +1 -1
- package/dist/migration-tools__migration.mjs +1 -1
- package/dist/{ref-h6InR6dO-rGfl18Jv.mjs → ref-BdSSbD2i-7HxlZIdl.mjs} +3 -3
- package/dist/{ref-h6InR6dO-rGfl18Jv.mjs.map → ref-BdSSbD2i-7HxlZIdl.mjs.map} +1 -1
- package/dist/vite-plugin-contract-emit.mjs +2 -2
- package/package.json +12 -12
- package/dist/exports-BZaG8_w_.mjs.map +0 -1
- package/dist/index-DRs7L6N0.d.mts.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exports-UjssmDwy.mjs","names":[],"sources":["../../../../1-framework/3-tooling/config-loader/dist/exports/index.mjs"],"sourcesContent":["import { createRequire } from \"node:module\";\nimport { hasCurrentConfigFormatVersion, normalizeContractConfig } from \"@internal/config/config-types\";\nimport { basename, dirname, join, resolve } from \"pathe\";\nimport { realpathSync } from \"node:fs\";\nimport { access } from \"node:fs/promises\";\nimport { pathToFileURL } from \"node:url\";\nimport { collectConfigIssues } from \"@internal/config/config-validation\";\nimport { getEmittedArtifactPaths } from \"@internal/emitter\";\nimport { CliStructuredError, errorConfigEvaluationFailed, errorConfigFileNotFound, errorConfigValidation, errorConfigVersionMarkerMissing } from \"@internal/errors/control\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { notOk, ok } from \"@internal/utils/result\";\nimport { isStructuredError } from \"@internal/utils/structured-error\";\n//#region src/finalize-config.ts\nfunction finalizeContractSource(source, configDir) {\n\tconst resolvedInputs = source.inputs?.map((input) => resolve(configDir, input));\n\tif (resolvedInputs === void 0) return source;\n\treturn {\n\t\t...source,\n\t\tinputs: resolvedInputs\n\t};\n}\n/** Normalizes a contract section and resolves its paths against `configDir`. */\nfunction finalizeContractConfig(contract, configDir) {\n\tconst normalized = normalizeContractConfig(contract);\n\treturn {\n\t\t...normalized,\n\t\tsource: finalizeContractSource(normalized.source, configDir),\n\t\toutput: resolve(configDir, normalized.output)\n\t};\n}\nconst DEFAULT_MIGRATIONS_DIR = \"migrations\";\n/**\n* Resolves the migrations directory against `configDir`, which is what `migrations.dir` is\n* documented to be relative to. The default is applied here too, so no caller re-derives it\n* against a different base — a command run from one directory with `--config` naming a project in\n* another would otherwise read the wrong `migrations/`.\n*/\nfunction finalizeMigrationsConfig(migrations, configDir) {\n\treturn {\n\t\t...migrations,\n\t\tdir: resolve(configDir, migrations?.dir ?? DEFAULT_MIGRATIONS_DIR)\n\t};\n}\nfunction finalizeConfig(config, configDir) {\n\treturn {\n\t\t...config,\n\t\t...config.contract ? { contract: finalizeContractConfig(config.contract, configDir) } : void 0,\n\t\tmigrations: finalizeMigrationsConfig(config.migrations, configDir)\n\t};\n}\n//#endregion\n//#region src/load.ts\nconst CONFIG_FILENAME = \"prisma.config.ts\";\nconst DEPRECATED_CONFIG_FILENAME = \"prisma-next.config.ts\";\nfunction deprecatedFilenameWarning() {\n\treturn {\n\t\tcode: \"CONFIG.DEPRECATED_FILENAME\",\n\t\tmessage: `${DEPRECATED_CONFIG_FILENAME} is deprecated; rename the file to ${CONFIG_FILENAME}.`\n\t};\n}\nfunction deprecatedShapeWarning() {\n\treturn {\n\t\tcode: \"CONFIG.DEPRECATED_SHAPE\",\n\t\tmessage: \"The flat Prisma Next config shape is deprecated; wrap it in an `orm` section with defineConfig from @prisma/cli-engine: export default defineConfig({ orm: { … } }).\"\n\t};\n}\nasync function findNearestConfigPathForFile(filePath) {\n\tlet current = dirname(resolve(process.cwd(), filePath));\n\twhile (true) {\n\t\tfor (const filename of [CONFIG_FILENAME, DEPRECATED_CONFIG_FILENAME]) {\n\t\t\tconst candidate = join(current, filename);\n\t\t\tif (await fileExists(candidate)) return candidate;\n\t\t}\n\t\tconst parent = dirname(current);\n\t\tif (parent === current) return;\n\t\tcurrent = parent;\n\t}\n}\nasync function fileExists(path) {\n\ttry {\n\t\tawait access(path);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\nfunction isRecord(value) {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\nfunction collectArtifactCollisionDiagnostics(contract) {\n\tconst inputs = contract.source.inputs;\n\tconst output = contract.output;\n\tif (inputs === void 0 || output === void 0) return [];\n\tlet emittedArtifactPaths;\n\ttry {\n\t\temittedArtifactPaths = getEmittedArtifactPaths(output);\n\t} catch (error) {\n\t\treturn [errorConfigValidation(\"contract.output\", {\n\t\t\t/* v8 ignore next -- getEmittedArtifactPaths only ever throws an Error */\n\t\t\twhy: error instanceof Error ? error.message : String(error),\n\t\t\tsection: \"contract\"\n\t\t})];\n\t}\n\tconst emittedPaths = /* @__PURE__ */ new Set([emittedArtifactPaths.jsonPath, emittedArtifactPaths.dtsPath]);\n\tif (inputs.some((input) => emittedPaths.has(input))) return [errorConfigValidation(\"contract.source.inputs[]\", {\n\t\twhy: \"Config.contract.source.inputs must not include emitted artifact paths derived from contract.output\",\n\t\tsection: \"contract\"\n\t})];\n\treturn [];\n}\nfunction buildLoadedConfig(rawConfig, configDir) {\n\tconst issues = collectConfigIssues(rawConfig);\n\tconst diagnostics = issues.map((issue) => errorConfigValidation(issue.field, {\n\t\twhy: issue.message,\n\t\tsection: issue.section\n\t}));\n\tconst raw = blindCast(rawConfig);\n\tconst config = issues.some((issue) => issue.section === \"migrations\") ? raw : {\n\t\t...raw,\n\t\tmigrations: finalizeMigrationsConfig(raw.migrations, configDir)\n\t};\n\tif (config.contract === void 0 || issues.some((issue) => issue.section === \"contract\")) return {\n\t\tconfig,\n\t\tdiagnostics\n\t};\n\tconst contract = finalizeContractConfig(config.contract, configDir);\n\tdiagnostics.push(...collectArtifactCollisionDiagnostics(contract));\n\treturn {\n\t\tconfig: {\n\t\t\t...config,\n\t\t\tcontract\n\t\t},\n\t\tdiagnostics\n\t};\n}\nfunction toConfigLoadFailure(error, configPath) {\n\tif (CliStructuredError.is(error)) return error;\n\tconst resolvedPath = configPath ? resolve(process.cwd(), configPath) : void 0;\n\tif (isStructuredError(error)) return new CliStructuredError(error.code, error.message, {\n\t\t...ifDefined(\"why\", error.why),\n\t\t...ifDefined(\"fix\", error.fix),\n\t\t...ifDefined(\"where\", error.where),\n\t\t...ifDefined(\"meta\", error.meta),\n\t\tcause: error\n\t});\n\tif (error instanceof Error) return errorConfigEvaluationFailed(resolvedPath, {\n\t\twhy: error.message,\n\t\tcause: error\n\t});\n\treturn errorConfigEvaluationFailed(resolvedPath, { why: String(error) });\n}\n/**\n* Loads and finalizes the Prisma Next config.\n*\n* Failures that prevent evaluation entirely — missing file, module that does\n* not evaluate (`CONFIG.FILE_NOT_FOUND`, `CONFIG.EVALUATION_FAILED`) — are the\n* `Result` failure. Structural problems inside an evaluated config do not\n* fail the load: they are returned as section-tagged diagnostics so commands\n* fail only on the sections they read (via {@link requireConfigSections}).\n*/\n/**\n* Imports c12 by the realpath of its entry file. Under pnpm, resolving the\n* bare specifier can pin c12 at its symlinked node_modules path — Node's\n* synchronous ESM linker and some resolver states skip the realpath step —\n* and from that path c12's own dependencies (`dotenv`) do not resolve, which\n* fails every config load with CONFIG.EVALUATION_FAILED. Anchoring the import\n* at the real on-disk location keeps every transitive resolution working.\n*/\nasync function importC12() {\n\treturn await import(pathToFileURL(realpathSync(createRequire(import.meta.url).resolve(\"c12\"))).href);\n}\nasync function loadConfig(configPath, options) {\n\tconst cwd = options?.cwd ?? process.cwd();\n\tconst resolvedConfigPath = configPath ? resolve(cwd, configPath) : void 0;\n\tconst configCwd = resolvedConfigPath ? dirname(resolvedConfigPath) : cwd;\n\tconst deprecations = [];\n\tlet discoveryName = \"prisma\";\n\tif (resolvedConfigPath === void 0) {\n\t\tif (!await fileExists(join(configCwd, CONFIG_FILENAME)) && await fileExists(join(configCwd, DEPRECATED_CONFIG_FILENAME))) {\n\t\t\tdiscoveryName = \"prisma-next\";\n\t\t\tdeprecations.push(deprecatedFilenameWarning());\n\t\t}\n\t} else if (basename(resolvedConfigPath) === DEPRECATED_CONFIG_FILENAME) deprecations.push(deprecatedFilenameWarning());\n\tlet result;\n\ttry {\n\t\tresult = await (await importC12()).loadConfig({\n\t\t\tname: discoveryName,\n\t\t\t...ifDefined(\"configFile\", resolvedConfigPath),\n\t\t\tcwd: configCwd\n\t\t});\n\t} catch (error) {\n\t\treturn notOk(toConfigLoadFailure(error, configPath));\n\t}\n\tif (resolvedConfigPath && result.configFile !== resolvedConfigPath) return notOk(errorConfigFileNotFound(resolvedConfigPath));\n\tif (!result.config || Object.keys(result.config).length === 0) return notOk(errorConfigFileNotFound(result.configFile || resolvedConfigPath || configPath));\n\t/* v8 ignore next -- @preserve */\n\tconst loadedConfigDir = result.configFile ? dirname(result.configFile) : configCwd;\n\t/* v8 ignore next -- c12 always returns layers for a config it evaluated */\n\tconst [requestedLayer] = result.layers ?? [];\n\tconst layerConfig = requestedLayer?.config;\n\tconst engineMarker = isRecord(layerConfig) ? layerConfig[\"$prismaConfig\"] : void 0;\n\tif (engineMarker !== void 0) {\n\t\tif (engineMarker !== 1)\n /* v8 ignore next -- a config that evaluated always carries its resolved path */\n\t\treturn notOk(errorConfigVersionMarkerMissing(result.configFile ?? resolvedConfigPath));\n\t\tconst orm = result.config[\"orm\"];\n\t\tif (orm !== void 0 && !isRecord(orm)) return ok({\n\t\t\tconfig: buildLoadedConfig({}, loadedConfigDir).config,\n\t\t\tdiagnostics: [errorConfigValidation(\"orm\", { why: `The orm section of ${CONFIG_FILENAME} must be an object` })],\n\t\t\tdeprecations\n\t\t});\n\t\treturn ok({\n\t\t\t...buildLoadedConfig(orm ?? {}, loadedConfigDir),\n\t\t\tdeprecations\n\t\t});\n\t}\n\tif (hasCurrentConfigFormatVersion(layerConfig)) {\n\t\tdeprecations.push(deprecatedShapeWarning());\n\t\treturn ok({\n\t\t\t...buildLoadedConfig(result.config, loadedConfigDir),\n\t\t\tdeprecations\n\t\t});\n\t}\n\t/* v8 ignore next -- a config that evaluated always carries its resolved path */\n\treturn notOk(errorConfigVersionMarkerMissing(result.configFile ?? resolvedConfigPath));\n}\n/**\n* Narrows a {@link LoadedConfig} to the sections a command reads. Fails with\n* the first diagnostic concerning a required section; diagnostics on other\n* sections are ignored so unrelated commands keep working.\n*/\nfunction requireConfigSections(loaded, sections) {\n\tconst blocking = loaded.diagnostics.find((diagnostic) => {\n\t\tconst section = diagnostic.meta?.[\"section\"];\n\t\treturn typeof section !== \"string\" || sections.some((required) => required === section);\n\t});\n\treturn blocking ? notOk(blocking) : ok(loaded.config);\n}\n/**\n* Convenience composition of {@link loadConfig} and\n* {@link requireConfigSections} for commands that read a fixed set of\n* sections and have no use for diagnostics outside them.\n*/\nasync function loadConfigForSections(configPath, sections, options) {\n\tconst loaded = await loadConfig(configPath);\n\tif (!loaded.ok) return loaded;\n\tif (options?.onDeprecation) for (const deprecation of loaded.value.deprecations) options.onDeprecation(deprecation);\n\treturn requireConfigSections(loaded.value, sections);\n}\nasync function loadConfigForFile(filePath) {\n\tconst configPath = await findNearestConfigPathForFile(filePath);\n\tif (configPath === void 0) return notOk(errorConfigFileNotFound(join(dirname(resolve(process.cwd(), filePath)), CONFIG_FILENAME)));\n\treturn loadConfig(configPath);\n}\n//#endregion\nexport { finalizeConfig, findNearestConfigPathForFile, loadConfig, loadConfigForFile, loadConfigForSections, requireConfigSections };\n\n//# sourceMappingURL=index.mjs.map"],"mappings":";;;;;;;;;;;;;;AAcA,SAAS,uBAAuB,QAAQ,WAAW;CAClD,MAAM,iBAAiB,OAAO,QAAQ,KAAK,UAAU,QAAQ,WAAW,KAAK,CAAC;CAC9E,IAAI,mBAAmB,KAAK,GAAG,OAAO;CACtC,OAAO;EACN,GAAG;EACH,QAAQ;CACT;AACD;;AAEA,SAAS,uBAAuB,UAAU,WAAW;CACpD,MAAM,aAAa,wBAAwB,QAAQ;CACnD,OAAO;EACN,GAAG;EACH,QAAQ,uBAAuB,WAAW,QAAQ,SAAS;EAC3D,QAAQ,QAAQ,WAAW,WAAW,MAAM;CAC7C;AACD;AACA,MAAM,yBAAyB;;;;;;;AAO/B,SAAS,yBAAyB,YAAY,WAAW;CACxD,OAAO;EACN,GAAG;EACH,KAAK,QAAQ,WAAW,YAAY,OAAO,sBAAsB;CAClE;AACD;AACA,SAAS,eAAe,QAAQ,WAAW;CAC1C,OAAO;EACN,GAAG;EACH,GAAG,OAAO,WAAW,EAAE,UAAU,uBAAuB,OAAO,UAAU,SAAS,EAAE,IAAI,KAAK;EAC7F,YAAY,yBAAyB,OAAO,YAAY,SAAS;CAClE;AACD;AAGA,MAAM,kBAAkB;AACxB,MAAM,6BAA6B;AACnC,SAAS,4BAA4B;CACpC,OAAO;EACN,MAAM;EACN,SAAS,GAAG,2BAA2B,qCAAqC,gBAAgB;CAC7F;AACD;AACA,SAAS,yBAAyB;CACjC,OAAO;EACN,MAAM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|
|
27
27
|
declare function findNearestConfigPathForFile(filePath: string): Promise<string | undefined>;
|
|
28
|
-
/**
|
|
29
|
-
* Loads and finalizes the Prisma Next config.
|
|
30
|
-
*
|
|
31
|
-
* Failures that prevent evaluation entirely — missing file, module that does
|
|
32
|
-
* not evaluate (`CONFIG.FILE_NOT_FOUND`, `CONFIG.EVALUATION_FAILED`) — are the
|
|
33
|
-
* `Result` failure. Structural problems inside an evaluated config do not
|
|
34
|
-
* fail the load: they are returned as section-tagged diagnostics so commands
|
|
35
|
-
* fail only on the sections they read (via {@link requireConfigSections}).
|
|
36
|
-
*/
|
|
37
28
|
declare function loadConfig(configPath?: string, options?: {
|
|
38
29
|
readonly cwd?: string;
|
|
39
30
|
}): Promise<Result<LoadedConfig, CliStructuredError>>;
|
|
@@ -54,4 +45,4 @@ declare function loadConfigForSections(configPath: string | undefined, sections:
|
|
|
54
45
|
declare function loadConfigForFile(filePath: string): Promise<Result<LoadedConfig, CliStructuredError>>;
|
|
55
46
|
//#endregion
|
|
56
47
|
export { findNearestConfigPathForFile as a, loadConfigForSections as c, finalizeConfig as i, requireConfigSections as l, LoadedConfig as n, loadConfig as o, PrismaNextConfig$1 as r, loadConfigForFile as s, ConfigSection as t };
|
|
57
|
-
//# sourceMappingURL=index-
|
|
48
|
+
//# sourceMappingURL=index-BRjNSwL-.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-BRjNSwL-.d.mts","names":[],"sources":["../../../../1-framework/3-tooling/config-loader/dist/exports/index.d.mts"],"mappings":";;;;;;iBAKiB,eAAe,QAAQ,kBAAoB,oBAAoB;;;;UAItE;WACC;WACA;;;;;;;;;UASD;WACC,QAAQ;WACR,sBAAsB;WACtB,uBAAuB;;iBAEjB,6BAA6B,mBAAmB;iBAChD,WAAW,qBAAqB;WACtC;IACP,QAAQ,OAAO,cAAc;;;;;;iBAMhB,sBAAsB,QAAQ,cAAc,mBAAmB,kBAAkB,OAAO,kBAAoB;;;;;;iBAM5G,sBAAsB,gCAAgC,mBAAmB,iBAAiB;WAChG,iBAAiB,aAAa;IACrC,QAAQ,OAAO,kBAAoB;iBACtB,kBAAkB,mBAAmB,QAAQ,OAAO,cAAc"}
|
|
@@ -2,8 +2,8 @@ import { A as errorOperationsNotArray, c as errorDescribeMissingEndContract, s a
|
|
|
2
2
|
import { t as computeMigrationHash } from "./hash-DH8hl5Rq-BpM2t3Nu.mjs";
|
|
3
3
|
import { t as deriveProvidedInvariants } from "./invariants-CTHy88OP-CYI2a8IO.mjs";
|
|
4
4
|
import { t as MigrationOpSchema } from "./op-schema-BSVHzEQN-DIWt28D8.mjs";
|
|
5
|
-
import { type } from "arktype";
|
|
6
5
|
import { realpathSync } from "node:fs";
|
|
6
|
+
import { type } from "arktype";
|
|
7
7
|
import { fileURLToPath } from "node:url";
|
|
8
8
|
//#region ../../../1-framework/3-tooling/migration/dist/exports/migration.mjs
|
|
9
9
|
const MigrationMetaSchema = type({
|
|
@@ -206,4 +206,4 @@ async function buildMigrationArtifacts(instance, existing) {
|
|
|
206
206
|
//#endregion
|
|
207
207
|
export { isDirectEntrypoint as i, MigrationContractViews as n, buildMigrationArtifacts as r, Migration as t };
|
|
208
208
|
|
|
209
|
-
//# sourceMappingURL=migration-
|
|
209
|
+
//# sourceMappingURL=migration-BB4LDjuS.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration-hspPIEeV.mjs","names":["#endView","#startView"],"sources":["../../../../1-framework/3-tooling/migration/dist/exports/migration.mjs"],"sourcesContent":["import { A as errorOperationsNotArray, c as errorDescribeMissingEndContract, s as errorDescribeInvalidMetadata, v as errorInvalidOperationEntry, w as errorMigrationContractViewMissing } from \"../errors-CXbGUWGu.mjs\";\nimport { t as computeMigrationHash } from \"../hash-DH8hl5Rq.mjs\";\nimport { t as deriveProvidedInvariants } from \"../invariants-CTHy88OP.mjs\";\nimport { t as MigrationOpSchema } from \"../op-schema-BSVHzEQN.mjs\";\nimport { type } from \"arktype\";\nimport { realpathSync } from \"node:fs\";\nimport { fileURLToPath } from \"node:url\";\n//#region src/migration-base.ts\nconst MigrationMetaSchema = type({\n\tfrom: \"string > 0 | null\",\n\tto: \"string\"\n});\n/**\n* Base class for migrations.\n*\n* A `Migration` subclass is itself a `MigrationPlan`: CLI commands and the\n* runner can consume it directly via `targetId`, `operations`, `origin`, and\n* `destination`.\n*\n* The from/to identities come from `describe()`. A migration provides them in\n* one of two ways:\n* - **Contract-derived (default):** assign the `contract.json` imports from\n* the snapshot store (`migrations/snapshots/<hex>/contract.json`) to\n* `startContractJson` / `endContractJson`; the concrete `describe()` below\n* derives `to`/`from` from their\n* `storage.storageHash`. The family bases additionally expose typed view\n* getters (`startContract` / `endContract`) over the same JSON.\n* - **Override (e.g. extension migrations that carry no contract):** override\n* `describe()` directly; the override wins and the JSON fields are unused.\n*\n* The `Start` / `End` generics carry each migration's precise contract types so\n* the family-base view getters resolve to fully-typed views.\n*/\nvar Migration = class {\n\t/**\n\t* The migration's end-state contract JSON (the `contract.json` import from\n\t* the snapshot store). When set, the derived `describe()` reads `to` from its\n\t* `storage.storageHash`. Family bases build the typed `endContract` view from\n\t* it. Optional so `describe()`-overriding migrations (no contract) compile.\n\t*\n\t* Typed with a plain `storageHash: string`, not the branded\n\t* `StorageHashBase`, so a raw `contract.json` import — whose `storageHash`\n\t* is an untyped string literal — is assignable without a cast. The full\n\t* `Start`/`End` contract typing is applied downstream in the family bases'\n\t* view getters (via `<Family>ContractView.fromJson<…>`).\n\t*/\n\tendContractJson;\n\t/**\n\t* The migration's start-state contract JSON (the `contract.json` import\n\t* from the snapshot store). Absent for a baseline migration (`from`\n\t* derives to `null`). Family bases build the typed `startContract` view from\n\t* it.\n\t*/\n\tstartContractJson;\n\t/**\n\t* Assembled `ControlStack` injected by the orchestrator (`runMigration`).\n\t*\n\t* Subclasses (e.g. `PostgresMigration`) read the stack to materialize their\n\t* adapter once per instance. Optional at the abstract level so unit tests can\n\t* construct `Migration` instances purely for `operations` / `describe`\n\t* assertions without needing a real stack; concrete subclasses that need the\n\t* stack at runtime should narrow the parameter to required.\n\t*/\n\tstack;\n\tconstructor(stack) {\n\t\tthis.stack = stack;\n\t}\n\t/**\n\t* Metadata inputs used to build `migration.json` and to derive the plan's\n\t* origin/destination identities.\n\t*\n\t* Default derivation: `to = endContractJson.storage.storageHash`,\n\t* `from = startContractJson?.storage.storageHash ?? null`. A migration that\n\t* carries no contract JSON (e.g. an extension migration) must override this;\n\t* otherwise it throws, since `migration.json` requires a `to` identity.\n\t*/\n\tdescribe() {\n\t\tconst end = this.endContractJson;\n\t\tif (end === void 0) throw errorDescribeMissingEndContract();\n\t\treturn {\n\t\t\tfrom: this.startContractJson?.storage.storageHash ?? null,\n\t\t\tto: end.storage.storageHash\n\t\t};\n\t}\n\tget origin() {\n\t\tconst from = this.describe().from;\n\t\treturn from === null ? null : { storageHash: from };\n\t}\n\tget destination() {\n\t\treturn { storageHash: this.describe().to };\n\t}\n};\n/**\n* Lazy-memoized `endContract` / `startContract` view accessors, one instance\n* held per migration. Each target base (`MongoMigration`, `SqliteMigration`,\n* `PostgresMigration`) creates one `MigrationContractViews` field from\n* `this` — passing its own `<Family>ContractView.fromJson<…>` as `fromJson`\n* and a name for error messages — and forwards its\n* `endContract`/`startContract` getters to it.\n*\n* `endContract` throws `MIGRATION.CONTRACT_VIEW_MISSING` when the migration\n* has no `endContractJson` (mirrors `describe()`'s own requirement).\n* `startContract` returns `null` for a baseline migration (no\n* `startContractJson`) instead of throwing.\n*/\nvar MigrationContractViews = class {\n\tmigration;\n\tclassName;\n\tfromJson;\n\t#endView;\n\t#startView;\n\tconstructor(migration, className, fromJson) {\n\t\tthis.migration = migration;\n\t\tthis.className = className;\n\t\tthis.fromJson = fromJson;\n\t}\n\tget endContract() {\n\t\tif (this.#endView === void 0) {\n\t\t\tconst json = this.migration.endContractJson;\n\t\t\tif (json === void 0) throw errorMigrationContractViewMissing(this.className, \"endContract\", \"endContractJson\");\n\t\t\tthis.#endView = this.fromJson(json);\n\t\t}\n\t\treturn this.#endView;\n\t}\n\tget startContract() {\n\t\tif (this.#startView === void 0) {\n\t\t\tconst json = this.migration.startContractJson;\n\t\t\tthis.#startView = json === void 0 ? null : this.fromJson(json);\n\t\t}\n\t\treturn this.#startView;\n\t}\n};\n/**\n* Returns true when `import.meta.url` resolves to the same file that was\n* invoked as the node entrypoint (`process.argv[1]`). Used by\n* `MigrationCLI.run` (in `@internal/cli/migration-cli`) to no-op when\n* the migration module is being imported (e.g. by another script) rather\n* than executed directly.\n*/\nfunction isDirectEntrypoint(importMetaUrl) {\n\tconst metaFilename = fileURLToPath(importMetaUrl);\n\tconst argv1 = process.argv[1];\n\tif (!argv1) return false;\n\ttry {\n\t\treturn realpathSync(metaFilename) === realpathSync(argv1);\n\t} catch {\n\t\treturn false;\n\t}\n}\n/**\n* Build the attested metadata from `describe()`-derived metadata, the\n* operations list, and the previously-scaffolded metadata (if any).\n*\n* When a `migration.json` already exists for this package (the common\n* case: it was scaffolded by `migration plan`), preserve `createdAt`\n* set there — that field is owned by the CLI scaffolder, not the authored\n* class. Only the `describe()`-derived fields (`from`, `to`) and the\n* operations change as the author iterates. When no metadata exists yet\n* (a bare `migration.ts` run from scratch), synthesize a minimal but\n* schema-conformant record so the resulting package can still be read,\n* verified, and applied.\n*\n* The `migrationHash` is recomputed against the current metadata + ops so\n* the on-disk artifacts are always fully attested.\n*/\nfunction buildAttestedMetadata(meta, ops, existing) {\n\tconst baseMetadata = {\n\t\tfrom: meta.from,\n\t\tto: meta.to,\n\t\tprovidedInvariants: deriveProvidedInvariants(ops),\n\t\tcreatedAt: existing?.createdAt ?? (/* @__PURE__ */ new Date()).toISOString()\n\t};\n\tconst migrationHash = computeMigrationHash(baseMetadata, ops);\n\treturn {\n\t\t...baseMetadata,\n\t\tmigrationHash\n\t};\n}\n/**\n* Pure conversion from a `Migration` instance (plus the previously\n* scaffolded metadata, when one exists on disk) to the in-memory\n* artifacts that downstream tooling persists. Owns metadata validation,\n* metadata synthesis/preservation, and the content-addressed\n* `migrationHash` computation, but performs no file I/O — callers handle\n* reads (to source `existing`) and writes (to persist `opsJson` /\n* `metadataJson`).\n*/\nasync function buildMigrationArtifacts(instance, existing) {\n\tconst rawOps = instance.operations;\n\tif (!Array.isArray(rawOps)) throw errorOperationsNotArray();\n\tconst ops = await Promise.all(rawOps);\n\tfor (let index = 0; index < ops.length; index++) {\n\t\tconst result = MigrationOpSchema(ops[index]);\n\t\tif (result instanceof type.errors) throw errorInvalidOperationEntry(index, result.summary);\n\t}\n\tconst rawMeta = instance.describe();\n\tconst parsed = MigrationMetaSchema(rawMeta);\n\tif (parsed instanceof type.errors) throw errorDescribeInvalidMetadata(parsed.summary);\n\tconst metadata = buildAttestedMetadata(parsed, ops, existing);\n\treturn {\n\t\topsJson: JSON.stringify(ops, null, 2),\n\t\tmetadata,\n\t\tmetadataJson: JSON.stringify(metadata, null, 2)\n\t};\n}\n//#endregion\nexport { Migration, MigrationContractViews, buildMigrationArtifacts, isDirectEntrypoint };\n\n//# sourceMappingURL=migration.mjs.map"],"mappings":";;;;;;;;AAQA,MAAM,sBAAsB,KAAK;CAChC,MAAM;CACN,IAAI;AACL,CAAC;;;;;;;;;;;;;;;;;;;;;;AAsBD,IAAI,YAAY,MAAM;;;;;;;;;;;;;CAarB;;;;;;;CAOA;;;;;;;;;;CAUA;CACA,YAAY,OAAO;EAClB,KAAK,QAAQ;CACd;;;;;;;;;;CAUA,WAAW;EACV,MAAM,MAAM,KAAK;EACjB,IAAI,QAAQ,KAAK,GAAG,MAAM,gCAAgC;EAC1D,OAAO;GACN,MAAM,KAAK,mBAAmB,QAAQ,eAAe;GACrD,IAAI,IAAI,QAAQ;EACjB;CACD;CACA,IAAI,SAAS;EACZ,MAAM,OAAO,KAAK,SAAS,CAAC,CAAC;EAC7B,OAAO,SAAS,OAAO,OAAO,EAAE,aAAa,KAAK;CACnD;CACA,IAAI,cAAc;EACjB,OAAO,EAAE,aAAa,KAAK,SAA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MAAM,MAAM,MAAM,QAAQ,IAAI,MAAM;CACpC,KAAK,IAAI,QAAQ,GAAG,QAAQ,IAAI,QAAQ,SAAS;EAChD,MAAM,SAAS,kBAAkB,IAAI,MAAM;EAC3C,IAAI,kBAAkB,KAAK,QAAQ,MAAM,2BAA2B,OAAO,OAAO,OAAO;CAC1F;CACA,MAAM,UAAU,SAAS,SAAS;CAClC,MAAM,SAAS,oBAAoB,OAAO;CAC1C,IAAI,kBAAkB,KAAK,QAAQ,MAAM,6BAA6B,OAAO,OAAO;CACpF,MAAM,WAAW,sBAAsB,QAAQ,KAAK,QAAQ;CAC5D,OAAO;EACN,SAAS,KAAK,UAAU,KAAK,MAAM,CAAC;EACpC;EACA,cAAc,KAAK,UAAU,UAAU,MAAM,CAAC;CAC/C;AACD"}
|
|
1
|
+
{"version":3,"file":"migration-BB4LDjuS.mjs","names":["#endView","#startView"],"sources":["../../../../1-framework/3-tooling/migration/dist/exports/migration.mjs"],"sourcesContent":["import { A as errorOperationsNotArray, c as errorDescribeMissingEndContract, s as errorDescribeInvalidMetadata, v as errorInvalidOperationEntry, w as errorMigrationContractViewMissing } from \"../errors-CXbGUWGu.mjs\";\nimport { t as computeMigrationHash } from \"../hash-DH8hl5Rq.mjs\";\nimport { t as deriveProvidedInvariants } from \"../invariants-CTHy88OP.mjs\";\nimport { t as MigrationOpSchema } from \"../op-schema-BSVHzEQN.mjs\";\nimport { type } from \"arktype\";\nimport { realpathSync } from \"node:fs\";\nimport { fileURLToPath } from \"node:url\";\n//#region src/migration-base.ts\nconst MigrationMetaSchema = type({\n\tfrom: \"string > 0 | null\",\n\tto: \"string\"\n});\n/**\n* Base class for migrations.\n*\n* A `Migration` subclass is itself a `MigrationPlan`: CLI commands and the\n* runner can consume it directly via `targetId`, `operations`, `origin`, and\n* `destination`.\n*\n* The from/to identities come from `describe()`. A migration provides them in\n* one of two ways:\n* - **Contract-derived (default):** assign the `contract.json` imports from\n* the snapshot store (`migrations/snapshots/<hex>/contract.json`) to\n* `startContractJson` / `endContractJson`; the concrete `describe()` below\n* derives `to`/`from` from their\n* `storage.storageHash`. The family bases additionally expose typed view\n* getters (`startContract` / `endContract`) over the same JSON.\n* - **Override (e.g. extension migrations that carry no contract):** override\n* `describe()` directly; the override wins and the JSON fields are unused.\n*\n* The `Start` / `End` generics carry each migration's precise contract types so\n* the family-base view getters resolve to fully-typed views.\n*/\nvar Migration = class {\n\t/**\n\t* The migration's end-state contract JSON (the `contract.json` import from\n\t* the snapshot store). When set, the derived `describe()` reads `to` from its\n\t* `storage.storageHash`. Family bases build the typed `endContract` view from\n\t* it. Optional so `describe()`-overriding migrations (no contract) compile.\n\t*\n\t* Typed with a plain `storageHash: string`, not the branded\n\t* `StorageHashBase`, so a raw `contract.json` import — whose `storageHash`\n\t* is an untyped string literal — is assignable without a cast. The full\n\t* `Start`/`End` contract typing is applied downstream in the family bases'\n\t* view getters (via `<Family>ContractView.fromJson<…>`).\n\t*/\n\tendContractJson;\n\t/**\n\t* The migration's start-state contract JSON (the `contract.json` import\n\t* from the snapshot store). Absent for a baseline migration (`from`\n\t* derives to `null`). Family bases build the typed `startContract` view from\n\t* it.\n\t*/\n\tstartContractJson;\n\t/**\n\t* Assembled `ControlStack` injected by the orchestrator (`runMigration`).\n\t*\n\t* Subclasses (e.g. `PostgresMigration`) read the stack to materialize their\n\t* adapter once per instance. Optional at the abstract level so unit tests can\n\t* construct `Migration` instances purely for `operations` / `describe`\n\t* assertions without needing a real stack; concrete subclasses that need the\n\t* stack at runtime should narrow the parameter to required.\n\t*/\n\tstack;\n\tconstructor(stack) {\n\t\tthis.stack = stack;\n\t}\n\t/**\n\t* Metadata inputs used to build `migration.json` and to derive the plan's\n\t* origin/destination identities.\n\t*\n\t* Default derivation: `to = endContractJson.storage.storageHash`,\n\t* `from = startContractJson?.storage.storageHash ?? null`. A migration that\n\t* carries no contract JSON (e.g. an extension migration) must override this;\n\t* otherwise it throws, since `migration.json` requires a `to` identity.\n\t*/\n\tdescribe() {\n\t\tconst end = this.endContractJson;\n\t\tif (end === void 0) throw errorDescribeMissingEndContract();\n\t\treturn {\n\t\t\tfrom: this.startContractJson?.storage.storageHash ?? null,\n\t\t\tto: end.storage.storageHash\n\t\t};\n\t}\n\tget origin() {\n\t\tconst from = this.describe().from;\n\t\treturn from === null ? null : { storageHash: from };\n\t}\n\tget destination() {\n\t\treturn { storageHash: this.describe().to };\n\t}\n};\n/**\n* Lazy-memoized `endContract` / `startContract` view accessors, one instance\n* held per migration. Each target base (`MongoMigration`, `SqliteMigration`,\n* `PostgresMigration`) creates one `MigrationContractViews` field from\n* `this` — passing its own `<Family>ContractView.fromJson<…>` as `fromJson`\n* and a name for error messages — and forwards its\n* `endContract`/`startContract` getters to it.\n*\n* `endContract` throws `MIGRATION.CONTRACT_VIEW_MISSING` when the migration\n* has no `endContractJson` (mirrors `describe()`'s own requirement).\n* `startContract` returns `null` for a baseline migration (no\n* `startContractJson`) instead of throwing.\n*/\nvar MigrationContractViews = class {\n\tmigration;\n\tclassName;\n\tfromJson;\n\t#endView;\n\t#startView;\n\tconstructor(migration, className, fromJson) {\n\t\tthis.migration = migration;\n\t\tthis.className = className;\n\t\tthis.fromJson = fromJson;\n\t}\n\tget endContract() {\n\t\tif (this.#endView === void 0) {\n\t\t\tconst json = this.migration.endContractJson;\n\t\t\tif (json === void 0) throw errorMigrationContractViewMissing(this.className, \"endContract\", \"endContractJson\");\n\t\t\tthis.#endView = this.fromJson(json);\n\t\t}\n\t\treturn this.#endView;\n\t}\n\tget startContract() {\n\t\tif (this.#startView === void 0) {\n\t\t\tconst json = this.migration.startContractJson;\n\t\t\tthis.#startView = json === void 0 ? null : this.fromJson(json);\n\t\t}\n\t\treturn this.#startView;\n\t}\n};\n/**\n* Returns true when `import.meta.url` resolves to the same file that was\n* invoked as the node entrypoint (`process.argv[1]`). Used by\n* `MigrationCLI.run` (in `@internal/cli/migration-cli`) to no-op when\n* the migration module is being imported (e.g. by another script) rather\n* than executed directly.\n*/\nfunction isDirectEntrypoint(importMetaUrl) {\n\tconst metaFilename = fileURLToPath(importMetaUrl);\n\tconst argv1 = process.argv[1];\n\tif (!argv1) return false;\n\ttry {\n\t\treturn realpathSync(metaFilename) === realpathSync(argv1);\n\t} catch {\n\t\treturn false;\n\t}\n}\n/**\n* Build the attested metadata from `describe()`-derived metadata, the\n* operations list, and the previously-scaffolded metadata (if any).\n*\n* When a `migration.json` already exists for this package (the common\n* case: it was scaffolded by `migration plan`), preserve `createdAt`\n* set there — that field is owned by the CLI scaffolder, not the authored\n* class. Only the `describe()`-derived fields (`from`, `to`) and the\n* operations change as the author iterates. When no metadata exists yet\n* (a bare `migration.ts` run from scratch), synthesize a minimal but\n* schema-conformant record so the resulting package can still be read,\n* verified, and applied.\n*\n* The `migrationHash` is recomputed against the current metadata + ops so\n* the on-disk artifacts are always fully attested.\n*/\nfunction buildAttestedMetadata(meta, ops, existing) {\n\tconst baseMetadata = {\n\t\tfrom: meta.from,\n\t\tto: meta.to,\n\t\tprovidedInvariants: deriveProvidedInvariants(ops),\n\t\tcreatedAt: existing?.createdAt ?? (/* @__PURE__ */ new Date()).toISOString()\n\t};\n\tconst migrationHash = computeMigrationHash(baseMetadata, ops);\n\treturn {\n\t\t...baseMetadata,\n\t\tmigrationHash\n\t};\n}\n/**\n* Pure conversion from a `Migration` instance (plus the previously\n* scaffolded metadata, when one exists on disk) to the in-memory\n* artifacts that downstream tooling persists. Owns metadata validation,\n* metadata synthesis/preservation, and the content-addressed\n* `migrationHash` computation, but performs no file I/O — callers handle\n* reads (to source `existing`) and writes (to persist `opsJson` /\n* `metadataJson`).\n*/\nasync function buildMigrationArtifacts(instance, existing) {\n\tconst rawOps = instance.operations;\n\tif (!Array.isArray(rawOps)) throw errorOperationsNotArray();\n\tconst ops = await Promise.all(rawOps);\n\tfor (let index = 0; index < ops.length; index++) {\n\t\tconst result = MigrationOpSchema(ops[index]);\n\t\tif (result instanceof type.errors) throw errorInvalidOperationEntry(index, result.summary);\n\t}\n\tconst rawMeta = instance.describe();\n\tconst parsed = MigrationMetaSchema(rawMeta);\n\tif (parsed instanceof type.errors) throw errorDescribeInvalidMetadata(parsed.summary);\n\tconst metadata = buildAttestedMetadata(parsed, ops, existing);\n\treturn {\n\t\topsJson: JSON.stringify(ops, null, 2),\n\t\tmetadata,\n\t\tmetadataJson: JSON.stringify(metadata, null, 2)\n\t};\n}\n//#endregion\nexport { Migration, MigrationContractViews, buildMigrationArtifacts, isDirectEntrypoint };\n\n//# sourceMappingURL=migration.mjs.map"],"mappings":";;;;;;;;AAQA,MAAM,sBAAsB,KAAK;CAChC,MAAM;CACN,IAAI;AACL,CAAC;;;;;;;;;;;;;;;;;;;;;;AAsBD,IAAI,YAAY,MAAM;;;;;;;;;;;;;CAarB;;;;;;;CAOA;;;;;;;;;;CAUA;CACA,YAAY,OAAO;EAClB,KAAK,QAAQ;CACd;;;;;;;;;;CAUA,WAAW;EACV,MAAM,MAAM,KAAK;EACjB,IAAI,QAAQ,KAAK,GAAG,MAAM,gCAAgC;EAC1D,OAAO;GACN,MAAM,KAAK,mBAAmB,QAAQ,eAAe;GACrD,IAAI,IAAI,QAAQ;EACjB;CACD;CACA,IAAI,SAAS;EACZ,MAAM,OAAO,KAAK,SAAS,CAAC,CAAC;EAC7B,OAAO,SAAS,OAAO,OAAO,EAAE,aAAa,KAAK;CACnD;CACA,IAAI,cAAc;EACjB,OAAO,EAAE,aAAa,KAAK,SAAS,CAAC,CAAC,GAAG;CAC1C;AACD;;;;;;;;;;;;;;AAcA,IAAI,yBAAyB,MAAM;CAClC;CACA;CACA;CACA;CACA;CACA,YAAY,WAAW,WAAW,UAAU;EAC3C,KAAK,YAAY;EACjB,KAAK,YAAY;EACjB,KAAK,WAAW;CACjB;CACA,IAAI,cAAc;EACjB,IAAI,KAAKA,aAAa,KAAK,GAAG;GAC7B,MAAM,OAAO,KAAK,UAAU;GAC5B,IAAI,SAAS,KAAK,GAAG,MAAM,kCAAkC,KAAK,WAAW,eAAe,iBAAiB;GAC7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AsB,QAAQ,KAAK,QAAQ;CAC5D,OAAO;EACN,SAAS,KAAK,UAAU,KAAK,MAAM,CAAC;EACpC;EACA,cAAc,KAAK,UAAU,UAAU,MAAM,CAAC;CAC/C;AACD"}
|
package/dist/migration-tools.mjs
CHANGED
|
@@ -12,6 +12,6 @@ import { a as createAggregateContractSpace, c as loadProblemToViolation, d as re
|
|
|
12
12
|
import { a as gatherDiskContractSpaceState, i as emitContractSpaceArtifacts, n as computeExtensionSpaceApplyPath, o as planAllSpaces, r as contractSpaceFromJson, t as assertDescriptorSelfConsistency } from "./spaces-4qMOAYE9.mjs";
|
|
13
13
|
import { n as parseContractRef, r as parseMigrationRef, t as findEdgeByDirName } from "./ref-resolution-HeNBXW53.mjs";
|
|
14
14
|
import { i as writeMigrationTs, n as hasMigrationTs, r as shebangLineFor, t as detectScaffoldRuntime } from "./migration-ts-DdVm0rws.mjs";
|
|
15
|
-
import { i as isDirectEntrypoint, n as MigrationContractViews, r as buildMigrationArtifacts, t as Migration } from "./migration-
|
|
15
|
+
import { i as isDirectEntrypoint, n as MigrationContractViews, r as buildMigrationArtifacts, t as Migration } from "./migration-BB4LDjuS.mjs";
|
|
16
16
|
import { t as ledgerOriginFromStored } from "./ledger-origin-D7PN4Fon.mjs";
|
|
17
17
|
export { APP_SPACE_ID, EMPTY_CONTRACT_HASH, HEAD_REF_NAME, Migration, MigrationContractViews, MigrationToolsError, RESERVED_SPACE_SUBDIR_NAMES, SPACE_REFS_DIRNAME, allStorageElementsExternal, assertDescriptorSelfConsistency, assertHashIsGraphNode, assertValidSpaceId, buildFabricatedMigrationEdge, buildMigrationArtifacts, collectAggregateNamespaces, computeExtensionSpaceApplyPath, computeIntegrityViolations, computeMigrationHash, contractSnapshotDir, contractSpaceFromJson, copyFilesWithRename, createAggregateContractSpace, createContractSpaceAggregate, deleteRef, deriveProvidedInvariants, detectCycles, detectOrphans, detectScaffoldRuntime, emitContractSpaceArtifacts, errorContractDeserializationFailed, errorContractSnapshotHashMismatch, errorContractSnapshotMissing, errorDescriptorHeadHashMismatch, errorInvalidJson, errorInvalidRefName, errorNoInvariantPath, errorUnknownInvariant, findEdgeByDirName, findLatestMigration, findLeaf, findPath, findPathWithDecision, findPathWithInvariants, findReachableLeaves, formatMigrationDirName, gatherDiskContractSpaceState, hasMigrationTs, isDirectEntrypoint, isGraphNode, isValidSpaceId, ledgerOriginFromStored, listContractSpaceDirectories, loadContractSpaceAggregate, loadProblemToViolation, materialiseExtensionMigrationPackageIfMissing, materialiseMigrationPackage, parseContractRef, parseMigrationRef, planAllSpaces, planMigration, readContractSnapshotDts, readContractSnapshotJson, readContractSnapshotJsonTolerant, readContractSpaceHeadRef, readMigrationPackage, readMigrationsDir, readRef, readRefs, reconstructGraph, refsByContractHash, requireHeadRef, resolveRecordedPath, resolveRef, resolveRefsByContractHash, shebangLineFor, snapshotsImportPathFrom, spaceMigrationDirectory, spaceRefsDirectory, validateInvariantId, validateRefName, validateRefValue, verifyContractSpaces, verifyMigration, verifyMigrationHash, writeContractSnapshot, writeMigrationMetadata, writeMigrationOps, writeMigrationPackage, writeMigrationTs, writeRef };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as isDirectEntrypoint, n as MigrationContractViews, r as buildMigrationArtifacts, t as Migration } from "./migration-
|
|
1
|
+
import { i as isDirectEntrypoint, n as MigrationContractViews, r as buildMigrationArtifacts, t as Migration } from "./migration-BB4LDjuS.mjs";
|
|
2
2
|
export { Migration, MigrationContractViews, buildMigrationArtifacts, isDirectEntrypoint };
|
|
@@ -15,6 +15,7 @@ import { c as internalImportRoot, o as importRootForDependencies, r as createImp
|
|
|
15
15
|
import { n as parseContractRef, r as parseMigrationRef } from "./ref-resolution-HeNBXW53.mjs";
|
|
16
16
|
import { i as writeMigrationTs } from "./migration-ts-DdVm0rws.mjs";
|
|
17
17
|
import { createRequire } from "node:module";
|
|
18
|
+
import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
|
|
18
19
|
import { ifDefined } from "@prisma/orm-framework/utils/defined";
|
|
19
20
|
import { structuredError } from "@prisma/orm-framework/utils/structured-error";
|
|
20
21
|
import { blindCast, castAs } from "@prisma/orm-framework/utils/casts";
|
|
@@ -30,8 +31,7 @@ import { mkdir, readFile, rename, rm, writeFile } from "node:fs/promises";
|
|
|
30
31
|
import { createHash } from "node:crypto";
|
|
31
32
|
import { canonicalizeJson } from "@prisma/orm-framework/components/utils";
|
|
32
33
|
import { abortable } from "@prisma/orm-framework/utils/abortable";
|
|
33
|
-
|
|
34
|
-
//#region ../../../1-framework/3-tooling/cli/dist/ref-h6InR6dO.mjs
|
|
34
|
+
//#region ../../../1-framework/3-tooling/cli/dist/ref-BdSSbD2i.mjs
|
|
35
35
|
/**
|
|
36
36
|
* The typed remediation the CLI attaches to its own errors and findings.
|
|
37
37
|
* Constructors live here rather than in any library the CLI calls: naming a
|
|
@@ -4683,4 +4683,4 @@ async function executeRefListCommand(options) {
|
|
|
4683
4683
|
//#endregion
|
|
4684
4684
|
export { loadContractRawSafely as $, errorMigrationPlanningFailed as A, statusForMigrationHash as At, executeDbUpdate as B, errorDestructiveChanges as C, resolveRefAdvancementFields as Ct, errorLegendHumanOnly as D, runMigrationCheck as Dt, errorHashMismatch as E, runContractSpaceSeedPhase as Et, errorTargetMigrationNotSupported as F, executeRefAdvancement as G, executeMigrateShowPlan as H, errorTargetMismatch as I, executeRefSetCommand as J, executeRefDeleteCommand as K, errorUnexpected as L, errorPathUnreachable as M, toDeclaredExtensionsFromRaw as Mt, errorRunnerFailed as N, errorMarkerMissing as O, runMigrationList as Ot, errorRuntime as P, loadAggregateIntegrityViolations as Q, executeContractEmit as R, errorDatabaseConnectionRequired as S, resolveMigrationRef as St, errorFileNotFound as T, runCommandAction as Tt, executeMigrationNewCommand as U, executeDbVerify as V, executeMigrationPlanCommand as W, hasMigrationPath as X, findPackageByDirPath as Y, listRefsByContractHash as Z, enumerateCheckSpaces as _, requireLiveDatabase as _t, buildContractSpaceAggregate as a, maskConnectionUrl as at, errorContractArgConflict as b, resolveContractRefToSnapshot as bt, buildRefAdvancementFields as c, readContractEnvelope as ct, closeQuietly as d, refuseContractSpaceIntegrity as dt, loadContractSpaceAggregateForCli as et, computeRefAdvancementName as f, refuseDeclaredExtensionTargetMismatch as ft, enrichContract as g, refuseUnknownInvariants as gt, disposeEmitQueue as h, refusePackageCorruptionOnAggregate as ht, appliedHashesFromLedger as i, mapIntegrityViolations as it, errorNoMigrations as j, targetSupportsMigrations as jt, errorMigrationPackageNotFound as k, sanitizeErrorMessage as kt, checkSingleTarget as l, readContractIR as lt, deriveStatusEdgeAnnotations as m, refuseMissingInvariantPath as mt, advanceRefSafely as n, mapCaughtMigrationError as nt, buildMigrationSpaceGraphEntries as o, migrationSpaceListEntriesFromAggregate as ot, createControlClient as p, refuseMarkerOutsideGraph as pt, executeRefListCommand as q, appContractStandInFromIdentity as r, mapContractAtError as rt, buildReadAggregate as s, originHashForStatus as st, CliStructuredError$1 as t, looksLikePath as tt, chooseAction as u, readMigrationRefs as ut, errorConfigValidation$1 as v, resolveAppTargetPath as vt, errorDriverRequired as w, resolveToForPlan as wt, errorContractValidationFailed as x, resolveFromForPlan as xt, errorConsentPlanMismatch as y, resolveContractRef$1 as yt, executeDbInit as z };
|
|
4685
4685
|
|
|
4686
|
-
//# sourceMappingURL=ref-
|
|
4686
|
+
//# sourceMappingURL=ref-BdSSbD2i-7HxlZIdl.mjs.map
|