@prisma/composer 0.36.0-dev.1 → 0.36.0-dev.3
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/{app-config-DNnd7Zu--BQ1vHaMK.d.mts → app-config-8nfo_ECP-DngN6Z3i.d.mts} +6 -4
- package/dist/{app-config-DNnd7Zu--BQ1vHaMK.d.mts.map → app-config-8nfo_ECP-DngN6Z3i.d.mts.map} +1 -1
- package/dist/config-cJwLd_Uj.d.mts +1 -0
- package/dist/config.d.mts +2 -2
- package/dist/control.d.mts +12 -7
- package/dist/control.d.mts.map +1 -1
- package/dist/control.mjs +3 -3
- package/dist/control.mjs.map +1 -1
- package/dist/deploy-cJwLd_Uj.d.mts +1 -0
- package/dist/deploy.d.mts +2 -2
- package/dist/deploy.mjs +1 -1
- package/dist/deploy.mjs.map +1 -1
- package/dist/{deployment-summary-p88NV5m5-SaPCCX2C.d.mts → deployment-summary-p88NV5m5-BZ4RWg1k.d.mts} +3 -3
- package/dist/{deployment-summary-p88NV5m5-SaPCCX2C.d.mts.map → deployment-summary-p88NV5m5-BZ4RWg1k.d.mts.map} +1 -1
- package/dist/{dev-current-Brb4qugP-CG0_96FZ.mjs → dev-current-BNoPkDRU-qQ5hObmB.mjs} +5 -5
- package/dist/{dev-current-Brb4qugP-CG0_96FZ.mjs.map → dev-current-BNoPkDRU-qQ5hObmB.mjs.map} +1 -1
- package/dist/{dist-CZ_yEZ7F.mjs → dist-CQVqb52E.mjs} +2 -3
- package/dist/{dist-CZ_yEZ7F.mjs.map → dist-CQVqb52E.mjs.map} +1 -1
- package/dist/{execute-deploy-destroy-CNt-xpE7-CYaa3sYk.mjs → execute-deploy-destroy-BIqwt1RF-B83XdRmn.mjs} +4 -4
- package/dist/{execute-deploy-destroy-CNt-xpE7-CYaa3sYk.mjs.map → execute-deploy-destroy-BIqwt1RF-B83XdRmn.mjs.map} +1 -1
- package/dist/{execute-dev-BUk-XWBJ-ZHX5A8cR.mjs → execute-dev-DIEyloWn-L5AXbxEF.mjs} +9 -5
- package/dist/{execute-dev-BUk-XWBJ-ZHX5A8cR.mjs.map → execute-dev-DIEyloWn-L5AXbxEF.mjs.map} +1 -1
- package/dist/{execute-dev-current-BdEqeKAB-BLUs2eQv.mjs → execute-dev-current-CeKI-tiC-BMAsygzx.mjs} +4 -4
- package/dist/{execute-dev-current-BdEqeKAB-BLUs2eQv.mjs.map → execute-dev-current-CeKI-tiC-BMAsygzx.mjs.map} +1 -1
- package/dist/{execute-log-aiHhujIh-C_aXmb6j.mjs → execute-log-DA5AAQAA-CBNrz-1p.mjs} +4 -4
- package/dist/{execute-log-aiHhujIh-C_aXmb6j.mjs.map → execute-log-DA5AAQAA-CBNrz-1p.mjs.map} +1 -1
- package/dist/{graph-BzTSXnoQ-BvGVq0bm.d.mts → graph-Dahnws6W-yKmoqSdc.d.mts} +3 -3
- package/dist/graph-Dahnws6W-yKmoqSdc.d.mts.map +1 -0
- package/dist/{graph-MGOZJdDt-CyI8-9r7.mjs → graph-KEuXGBfJ-BfR6EMoN.mjs} +228 -19
- package/dist/graph-KEuXGBfJ-BfR6EMoN.mjs.map +1 -0
- package/dist/{graph-types-DfsG9Rkg-D_ARjMo7.d.mts → graph-types-Bn3tSF4x-BuHwUsq4.d.mts} +70 -32
- package/dist/graph-types-Bn3tSF4x-BuHwUsq4.d.mts.map +1 -0
- package/dist/http.d.mts +2 -2
- package/dist/http.mjs +2 -2
- package/dist/{index-D89ftK2z.d.mts → index-Ba2dpziF.d.mts} +3 -3
- package/dist/{index-D89ftK2z.d.mts.map → index-Ba2dpziF.d.mts.map} +1 -1
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +2 -2
- package/dist/local-target.d.mts +1 -1
- package/dist/{nextjs-DLyeRR7M-BeiYsLuZ.d.mts → nextjs-DLyeRR7M-CNdHQRgH.d.mts} +3 -3
- package/dist/{nextjs-DLyeRR7M-BeiYsLuZ.d.mts.map → nextjs-DLyeRR7M-CNdHQRgH.d.mts.map} +1 -1
- package/dist/nextjs-control.d.mts +4 -4
- package/dist/nextjs.d.mts +1 -1
- package/dist/node-control.d.mts +3 -3
- package/dist/node.d.mts +2 -2
- package/dist/report.d.mts +3 -3
- package/dist/service-rpc.d.mts +2 -2
- package/dist/service-rpc.mjs +2 -2
- package/dist/testing.d.mts +1 -1
- package/dist/{validate-environment-CEhUSEg2-DmAtiQhe.mjs → validate-environment-CEhUSEg2-D3vECWQz.mjs} +3 -3
- package/dist/{validate-environment-CEhUSEg2-DmAtiQhe.mjs.map → validate-environment-CEhUSEg2-D3vECWQz.mjs.map} +1 -1
- package/package.json +11 -11
- package/skills/prisma-composer-core-concepts/SKILL.md +35 -6
- package/dist/config-RKyUvtGC.d.mts +0 -1
- package/dist/deploy-RKyUvtGC.d.mts +0 -1
- package/dist/graph-BzTSXnoQ-BvGVq0bm.d.mts.map +0 -1
- package/dist/graph-MGOZJdDt-CyI8-9r7.mjs.map +0 -1
- package/dist/graph-types-DfsG9Rkg-D_ARjMo7.d.mts.map +0 -1
package/dist/{execute-dev-current-BdEqeKAB-BLUs2eQv.mjs → execute-dev-current-CeKI-tiC-BMAsygzx.mjs}
RENAMED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { t as InternalError } from "./internal-error-Dfur7Zqt-D96dWHZK.mjs";
|
|
2
2
|
import { t as CliStructuredError } from "./errors-0e8IVwzi.mjs";
|
|
3
3
|
import { i as devEnvironmentDir } from "./app-config-CErnR6NK-D9NgSBH4.mjs";
|
|
4
|
-
import { c as toStructured, l as notOk, u as ok } from "./dev-current-
|
|
4
|
+
import { c as toStructured, l as notOk, u as ok } from "./dev-current-BNoPkDRU-qQ5hObmB.mjs";
|
|
5
5
|
import { r as resolveLocalTargets } from "./local-target-DySKw61w.mjs";
|
|
6
|
-
import { i as validateEnvironmentName, n as resolveAppIdentity, t as checkConfigSource } from "./validate-environment-CEhUSEg2-
|
|
6
|
+
import { i as validateEnvironmentName, n as resolveAppIdentity, t as checkConfigSource } from "./validate-environment-CEhUSEg2-D3vECWQz.mjs";
|
|
7
7
|
import { n as requireDevEnvironmentName } from "./dev-environment-name-6eEr5PW8-CGk1ijP7.mjs";
|
|
8
8
|
import * as path$1 from "node:path";
|
|
9
|
-
//#region ../../0-framework/3-tooling/cli/dist/execute-dev-current-
|
|
9
|
+
//#region ../../0-framework/3-tooling/cli/dist/execute-dev-current-CeKI-tiC.mjs
|
|
10
10
|
/**
|
|
11
11
|
* The `devUrl` and `devStop` executor: config → each extension's local
|
|
12
12
|
* target → the app's local copy in the environment, read from that
|
|
@@ -163,4 +163,4 @@ async function executeDevStop(input, cwd) {
|
|
|
163
163
|
//#endregion
|
|
164
164
|
export { executeDevStop, executeDevUrl };
|
|
165
165
|
|
|
166
|
-
//# sourceMappingURL=execute-dev-current-
|
|
166
|
+
//# sourceMappingURL=execute-dev-current-CeKI-tiC-BMAsygzx.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute-dev-current-BdEqeKAB-BLUs2eQv.mjs","names":["path"],"sources":["../../../0-framework/3-tooling/cli/dist/execute-dev-current-BdEqeKAB.mjs"],"sourcesContent":["import { n as checkConfigSource, r as resolveAppIdentity, t as validateEnvironmentName } from \"./validate-environment-CEhUSEg2.mjs\";\nimport { d as toStructured } from \"./dev-current-Brb4qugP.mjs\";\nimport { n as requireDevEnvironmentName } from \"./dev-environment-name-6eEr5PW8.mjs\";\nimport * as path from \"node:path\";\nimport { CliStructuredError, InternalError } from \"@internal/foundation/errors\";\nimport { notOk, ok } from \"@internal/foundation/result\";\nimport { devEnvironmentDir, resolveLocalTargets } from \"@internal/core/local-target\";\n//#region src/operations/execute-dev-current.ts\n/**\n* The `devUrl` and `devStop` executor: config → each extension's local\n* target → the app's local copy in the environment, read from that\n* environment's dev state. Reached only by lazy import from dev-current.ts —\n* resolving the local targets loads their descriptors, whose graphs reach\n* alchemy's provider tree.\n*/\nfunction platformUnsupported() {\n\treturn new CliStructuredError(\"DEV.PLATFORM_UNSUPPORTED\", \"local dev is not supported on Windows yet.\");\n}\n/** The `prisma dev` command that runs `environment`. */\nfunction runDev(environment) {\n\treturn environment === \"dev\" ? \"`prisma dev`\" : `\\`prisma dev --environment ${environment}\\``;\n}\n/** A call into an extension's local target; its failures that carry no code are the emulator's. */\nasync function fromTarget(call) {\n\ttry {\n\t\treturn await call();\n\t} catch (error) {\n\t\tthrow toStructured(\"DEV.EMULATOR_FAILED\", error);\n\t}\n}\n/** Every extension's record of the app in the environment; fails when none recorded it. */\nasync function currentApps(copy, cwd) {\n\tconst { app, environment } = copy;\n\tconst { value } = checkConfigSource(copy.config, cwd);\n\tconst devDir = path.join(cwd, devEnvironmentDir(environment));\n\trequireDevEnvironmentName(devDir, environment);\n\tconst apps = [];\n\tfor (const target of (await resolveLocalTargets(value)).values()) {\n\t\tconst current = await fromTarget(async () => target.current?.({\n\t\t\tdevDir,\n\t\t\tapp,\n\t\t\tenvironment\n\t\t}));\n\t\tif (current !== void 0) apps.push(current);\n\t}\n\tif (apps.length === 0) throw new CliStructuredError(\"DEV.NOT_STARTED_HERE\", `\\`prisma dev\\` has not run ${app} in the environment ${environment} in ${cwd}.`, {\n\t\twhy: `The local services, databases and buckets of an app are recorded in ${devDir} when \\`prisma dev\\` runs it in the environment ${environment}, and ${app} has no such record.`,\n\t\tfix: `Run ${runDev(environment)} for ${app} in this directory.`,\n\t\tmeta: {\n\t\t\tcwd,\n\t\t\tapp,\n\t\t\tenvironment\n\t\t}\n\t});\n\treturn apps;\n}\n/** The app a full address starts with: `shop.api` belongs to `shop`. */\nfunction appOfAddress(address) {\n\tconst dot = address.indexOf(\".\");\n\treturn dot === -1 ? address : address.slice(0, dot);\n}\nasync function locate(input, cwd) {\n\tconst environment = input.environment ?? \"dev\";\n\tvalidateEnvironmentName(environment);\n\tconst app = appOfAddress(input.address);\n\tconst apps = await currentApps({\n\t\tconfig: input.config,\n\t\tapp,\n\t\tenvironment\n\t}, cwd);\n\tconst recorded = apps.find((candidate) => candidate.addresses.includes(input.address));\n\tif (recorded === void 0) {\n\t\tconst known = apps.flatMap((candidate) => candidate.addresses).sort();\n\t\tthrow new CliStructuredError(\"DEV.ADDRESS_UNKNOWN\", `\"${app}\" has no node at \"${input.address}\" in the environment ${environment}.`, {\n\t\t\twhy: `The addresses recorded for ${app} in the environment ${environment} are: ${known.join(\", \")}.`,\n\t\t\tfix: \"Pass one of those addresses. A nested node has a dotted address, such as `shop.catalog.database`.\",\n\t\t\tmeta: {\n\t\t\t\taddress: input.address,\n\t\t\t\tknown\n\t\t\t}\n\t\t});\n\t}\n\tconst location = await fromTarget(() => recorded.locate(input.address));\n\tif (location === void 0) throw new InternalError(`the local target recorded \"${input.address}\" but cannot locate it`);\n\tif (location.emulator === \"not-running\") throw new CliStructuredError(\"DEV.EMULATOR_UNREACHABLE\", `The local ${location.kind} emulator that runs \"${input.address}\" is not running.`, {\n\t\twhy: \"The local emulators run your services, databases and buckets on this machine; `prisma dev` starts the ones an app needs.\",\n\t\tfix: `Run ${runDev(environment)} in this directory.`,\n\t\tmeta: {\n\t\t\taddress: input.address,\n\t\t\tkind: location.kind\n\t\t}\n\t});\n\tif (location.condition !== \"running\") throw notRunning(input.address, environment, location);\n\tif (location.url === void 0) throw new InternalError(`the local target reports \"${input.address}\" running with no URL`);\n\tconst runs = location.command !== void 0 ? \"dev-server\" : location.kind === \"service\" ? \"artifact\" : void 0;\n\treturn {\n\t\taddress: input.address,\n\t\tkind: location.kind,\n\t\turl: location.url,\n\t\tstate: location.state,\n\t\t...runs !== void 0 ? { runs } : {}\n\t};\n}\nfunction notRunning(address, environment, location) {\n\tconst rerun = `Run ${runDev(environment)} in this directory.`;\n\tconst { kind, state, condition, logPath } = location;\n\tconst meta = {\n\t\taddress,\n\t\tkind,\n\t\tstate,\n\t\t...logPath === void 0 ? {} : { logPath }\n\t};\n\tconst message = `The ${kind} \"${address}\" is not running (${state}).`;\n\tif (condition === \"crashing\") return new CliStructuredError(\"DEV.NOT_RUNNING\", message, {\n\t\twhy: \"It exited after it started, and it is being restarted or was held after repeated crashes.\",\n\t\tfix: logPath === void 0 ? \"Read its output in the `prisma dev` terminal, fix the cause, and rebuild.\" : `Read its log at ${logPath}, fix the cause, and rebuild.`,\n\t\tmeta\n\t});\n\tif (condition === \"missing\") return new CliStructuredError(\"DEV.NOT_RUNNING\", message, {\n\t\twhy: \"The local emulator no longer has it, for example because a Composer upgrade discarded the emulator’s state.\",\n\t\tfix: `${rerun} It creates the ${kind} again, empty.`,\n\t\tmeta\n\t});\n\treturn new CliStructuredError(\"DEV.NOT_RUNNING\", `The ${kind} \"${address}\" is stopped.`, {\n\t\twhy: \"`prisma dev stop` and `prisma dev` ending both stop an app's services and database servers, and a stopped node has no URL that answers.\",\n\t\tfix: rerun,\n\t\tmeta\n\t});\n}\nasync function executeDevUrl(input, cwd) {\n\tif (process.platform === \"win32\") return notOk(platformUnsupported());\n\ttry {\n\t\treturn ok(await locate(input, cwd));\n\t} catch (error) {\n\t\tif (CliStructuredError.is(error)) return notOk(error);\n\t\tthrow error;\n\t}\n}\nasync function executeDevStop(input, cwd) {\n\tif (process.platform === \"win32\") return notOk(platformUnsupported());\n\ttry {\n\t\tconst environment = input.environment ?? \"dev\";\n\t\tvalidateEnvironmentName(environment);\n\t\tconst { name: app } = await resolveAppIdentity(input.entry, input.name, cwd, input.config);\n\t\tconst apps = await currentApps({\n\t\t\tconfig: input.config,\n\t\t\tapp,\n\t\t\tenvironment\n\t\t}, cwd);\n\t\tconst stopped = [];\n\t\tfor (const recorded of apps) stopped.push(...await fromTarget(() => recorded.stop()));\n\t\treturn ok({\n\t\t\tapp,\n\t\t\tenvironment,\n\t\t\tstopped\n\t\t});\n\t} catch (error) {\n\t\tif (CliStructuredError.is(error)) return notOk(error);\n\t\tthrow error;\n\t}\n}\n//#endregion\nexport { executeDevStop, executeDevUrl };\n\n//# sourceMappingURL=execute-dev-current-BdEqeKAB.mjs.map"],"mappings":";;;;;;;;;;;;;;;;AAeA,SAAS,s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B,SAAS,KAAK,CAAC,CAAC;EACpF,OAAO,GAAG;GACT;GACA;GACA;EACD,CAAC;CACF,SAAS,OAAO;EACf,IAAI,mBAAmB,GAAG,KAAK,GAAG,OAAO,MAAM,KAAK;EACpD,MAAM;CACP;AACD"}
|
|
1
|
+
{"version":3,"file":"execute-dev-current-CeKI-tiC-BMAsygzx.mjs","names":["path"],"sources":["../../../0-framework/3-tooling/cli/dist/execute-dev-current-CeKI-tiC.mjs"],"sourcesContent":["import { n as checkConfigSource, r as resolveAppIdentity, t as validateEnvironmentName } from \"./validate-environment-CEhUSEg2.mjs\";\nimport { d as toStructured } from \"./dev-current-BNoPkDRU.mjs\";\nimport { n as requireDevEnvironmentName } from \"./dev-environment-name-6eEr5PW8.mjs\";\nimport * as path from \"node:path\";\nimport { CliStructuredError, InternalError } from \"@internal/foundation/errors\";\nimport { notOk, ok } from \"@internal/foundation/result\";\nimport { devEnvironmentDir, resolveLocalTargets } from \"@internal/core/local-target\";\n//#region src/operations/execute-dev-current.ts\n/**\n* The `devUrl` and `devStop` executor: config → each extension's local\n* target → the app's local copy in the environment, read from that\n* environment's dev state. Reached only by lazy import from dev-current.ts —\n* resolving the local targets loads their descriptors, whose graphs reach\n* alchemy's provider tree.\n*/\nfunction platformUnsupported() {\n\treturn new CliStructuredError(\"DEV.PLATFORM_UNSUPPORTED\", \"local dev is not supported on Windows yet.\");\n}\n/** The `prisma dev` command that runs `environment`. */\nfunction runDev(environment) {\n\treturn environment === \"dev\" ? \"`prisma dev`\" : `\\`prisma dev --environment ${environment}\\``;\n}\n/** A call into an extension's local target; its failures that carry no code are the emulator's. */\nasync function fromTarget(call) {\n\ttry {\n\t\treturn await call();\n\t} catch (error) {\n\t\tthrow toStructured(\"DEV.EMULATOR_FAILED\", error);\n\t}\n}\n/** Every extension's record of the app in the environment; fails when none recorded it. */\nasync function currentApps(copy, cwd) {\n\tconst { app, environment } = copy;\n\tconst { value } = checkConfigSource(copy.config, cwd);\n\tconst devDir = path.join(cwd, devEnvironmentDir(environment));\n\trequireDevEnvironmentName(devDir, environment);\n\tconst apps = [];\n\tfor (const target of (await resolveLocalTargets(value)).values()) {\n\t\tconst current = await fromTarget(async () => target.current?.({\n\t\t\tdevDir,\n\t\t\tapp,\n\t\t\tenvironment\n\t\t}));\n\t\tif (current !== void 0) apps.push(current);\n\t}\n\tif (apps.length === 0) throw new CliStructuredError(\"DEV.NOT_STARTED_HERE\", `\\`prisma dev\\` has not run ${app} in the environment ${environment} in ${cwd}.`, {\n\t\twhy: `The local services, databases and buckets of an app are recorded in ${devDir} when \\`prisma dev\\` runs it in the environment ${environment}, and ${app} has no such record.`,\n\t\tfix: `Run ${runDev(environment)} for ${app} in this directory.`,\n\t\tmeta: {\n\t\t\tcwd,\n\t\t\tapp,\n\t\t\tenvironment\n\t\t}\n\t});\n\treturn apps;\n}\n/** The app a full address starts with: `shop.api` belongs to `shop`. */\nfunction appOfAddress(address) {\n\tconst dot = address.indexOf(\".\");\n\treturn dot === -1 ? address : address.slice(0, dot);\n}\nasync function locate(input, cwd) {\n\tconst environment = input.environment ?? \"dev\";\n\tvalidateEnvironmentName(environment);\n\tconst app = appOfAddress(input.address);\n\tconst apps = await currentApps({\n\t\tconfig: input.config,\n\t\tapp,\n\t\tenvironment\n\t}, cwd);\n\tconst recorded = apps.find((candidate) => candidate.addresses.includes(input.address));\n\tif (recorded === void 0) {\n\t\tconst known = apps.flatMap((candidate) => candidate.addresses).sort();\n\t\tthrow new CliStructuredError(\"DEV.ADDRESS_UNKNOWN\", `\"${app}\" has no node at \"${input.address}\" in the environment ${environment}.`, {\n\t\t\twhy: `The addresses recorded for ${app} in the environment ${environment} are: ${known.join(\", \")}.`,\n\t\t\tfix: \"Pass one of those addresses. A nested node has a dotted address, such as `shop.catalog.database`.\",\n\t\t\tmeta: {\n\t\t\t\taddress: input.address,\n\t\t\t\tknown\n\t\t\t}\n\t\t});\n\t}\n\tconst location = await fromTarget(() => recorded.locate(input.address));\n\tif (location === void 0) throw new InternalError(`the local target recorded \"${input.address}\" but cannot locate it`);\n\tif (location.emulator === \"not-running\") throw new CliStructuredError(\"DEV.EMULATOR_UNREACHABLE\", `The local ${location.kind} emulator that runs \"${input.address}\" is not running.`, {\n\t\twhy: \"The local emulators run your services, databases and buckets on this machine; `prisma dev` starts the ones an app needs.\",\n\t\tfix: `Run ${runDev(environment)} in this directory.`,\n\t\tmeta: {\n\t\t\taddress: input.address,\n\t\t\tkind: location.kind\n\t\t}\n\t});\n\tif (location.condition !== \"running\") throw notRunning(input.address, environment, location);\n\tif (location.url === void 0) throw new InternalError(`the local target reports \"${input.address}\" running with no URL`);\n\tconst runs = location.command !== void 0 ? \"dev-server\" : location.kind === \"service\" ? \"artifact\" : void 0;\n\treturn {\n\t\taddress: input.address,\n\t\tkind: location.kind,\n\t\turl: location.url,\n\t\tstate: location.state,\n\t\t...runs !== void 0 ? { runs } : {}\n\t};\n}\nfunction notRunning(address, environment, location) {\n\tconst rerun = `Run ${runDev(environment)} in this directory.`;\n\tconst { kind, state, condition, logPath } = location;\n\tconst meta = {\n\t\taddress,\n\t\tkind,\n\t\tstate,\n\t\t...logPath === void 0 ? {} : { logPath }\n\t};\n\tconst message = `The ${kind} \"${address}\" is not running (${state}).`;\n\tif (condition === \"crashing\") return new CliStructuredError(\"DEV.NOT_RUNNING\", message, {\n\t\twhy: \"It exited after it started, and it is being restarted or was held after repeated crashes.\",\n\t\tfix: logPath === void 0 ? \"Read its output in the `prisma dev` terminal, fix the cause, and rebuild.\" : `Read its log at ${logPath}, fix the cause, and rebuild.`,\n\t\tmeta\n\t});\n\tif (condition === \"missing\") return new CliStructuredError(\"DEV.NOT_RUNNING\", message, {\n\t\twhy: \"The local emulator no longer has it, for example because a Composer upgrade discarded the emulator’s state.\",\n\t\tfix: `${rerun} It creates the ${kind} again, empty.`,\n\t\tmeta\n\t});\n\treturn new CliStructuredError(\"DEV.NOT_RUNNING\", `The ${kind} \"${address}\" is stopped.`, {\n\t\twhy: \"`prisma dev stop` and `prisma dev` ending both stop an app's services and database servers, and a stopped node has no URL that answers.\",\n\t\tfix: rerun,\n\t\tmeta\n\t});\n}\nasync function executeDevUrl(input, cwd) {\n\tif (process.platform === \"win32\") return notOk(platformUnsupported());\n\ttry {\n\t\treturn ok(await locate(input, cwd));\n\t} catch (error) {\n\t\tif (CliStructuredError.is(error)) return notOk(error);\n\t\tthrow error;\n\t}\n}\nasync function executeDevStop(input, cwd) {\n\tif (process.platform === \"win32\") return notOk(platformUnsupported());\n\ttry {\n\t\tconst environment = input.environment ?? \"dev\";\n\t\tvalidateEnvironmentName(environment);\n\t\tconst { name: app } = await resolveAppIdentity(input.entry, input.name, cwd, input.config);\n\t\tconst apps = await currentApps({\n\t\t\tconfig: input.config,\n\t\t\tapp,\n\t\t\tenvironment\n\t\t}, cwd);\n\t\tconst stopped = [];\n\t\tfor (const recorded of apps) stopped.push(...await fromTarget(() => recorded.stop()));\n\t\treturn ok({\n\t\t\tapp,\n\t\t\tenvironment,\n\t\t\tstopped\n\t\t});\n\t} catch (error) {\n\t\tif (CliStructuredError.is(error)) return notOk(error);\n\t\tthrow error;\n\t}\n}\n//#endregion\nexport { executeDevStop, executeDevUrl };\n\n//# sourceMappingURL=execute-dev-current-CeKI-tiC.mjs.map"],"mappings":";;;;;;;;;;;;;;;;AAeA,SAAS,sBAAsB;CAC9B,OAAO,IAAI,mBAAmB,4BAA4B,4CAA4C;AACvG;;AAEA,SAAS,OAAO,aAAa;CAC5B,OAAO,gBAAgB,QAAQ,iBAAiB,8BAA8B,YAAY;AAC3F;;AAEA,eAAe,WAAW,MAAM;CAC/B,IAAI;EACH,OAAO,MAAM,KAAK;CACnB,SAAS,OAAO;EACf,MAAM,aAAa,uBAAuB,KAAK;CAChD;AACD;;AAEA,eAAe,YAAY,MAAM,KAAK;CACrC,MAAM,EAAE,KAAK,gBAAgB;CAC7B,MAAM,EAAE,UAAU,kBAAkB,KAAK,QAAQ,GAAG;CACpD,MAAM,SAASA,OAAK,KAAK,KAAK,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;EACtF,KAAK;EACL,KAAK,GAAG,MAAM,kBAAkB,KAAK;EACrC;CACD,CAAC;CACD,OAAO,IAAI,mBAAmB,mBAAmB,OAAO,KAAK,IAAI,QAAQ,gBAAgB;EACxF,KAAK;EACL,KAAK;EACL;CACD,CAAC;AACF;AACA,eAAe,cAAc,OAAO,KAAK;CACxC,IAAI,QAAQ,aAAa,SAAS,OAAO,MAAM,oBAAoB,CAAC;CACpE,IAAI;EACH,OAAO,GAAG,MAAM,OAAO,OAAO,GAAG,CAAC;CACnC,SAAS,OAAO;EACf,IAAI,mBAAmB,GAAG,KAAK,GAAG,OAAO,MAAM,KAAK;EACpD,MAAM;CACP;AACD;AACA,eAAe,eAAe,OAAO,KAAK;CACzC,IAAI,QAAQ,aAAa,SAAS,OAAO,MAAM,oBAAoB,CAAC;CACpE,IAAI;EACH,MAAM,cAAc,MAAM,eAAe;EACzC,wBAAwB,WAAW;EACnC,MAAM,EAAE,MAAM,QAAQ,MAAM,mBAAmB,MAAM,OAAO,MAAM,MAAM,KAAK,MAAM,MAAM;EACzF,MAAM,OAAO,MAAM,YAAY;GAC9B,QAAQ,MAAM;GACd;GACA;EACD,GAAG,GAAG;EACN,MAAM,UAAU,CAAC;EACjB,KAAK,MAAM,YAAY,MAAM,QAAQ,KAAK,GAAG,MAAM,iBAAiB,SAAS,KAAK,CAAC,CAAC;EACpF,OAAO,GAAG;GACT;GACA;GACA;EACD,CAAC;CACF,SAAS,OAAO;EACf,IAAI,mBAAmB,GAAG,KAAK,GAAG,OAAO,MAAM,KAAK;EACpD,MAAM;CACP;AACD"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { t as CliStructuredError } from "./errors-0e8IVwzi.mjs";
|
|
2
2
|
import { i as devEnvironmentDir } from "./app-config-CErnR6NK-D9NgSBH4.mjs";
|
|
3
|
-
import { c as toStructured, l as notOk, u as ok } from "./dev-current-
|
|
3
|
+
import { c as toStructured, l as notOk, u as ok } from "./dev-current-BNoPkDRU-qQ5hObmB.mjs";
|
|
4
4
|
import { r as resolveLocalTargets } from "./local-target-DySKw61w.mjs";
|
|
5
|
-
import { i as validateEnvironmentName, n as resolveAppIdentity } from "./validate-environment-CEhUSEg2-
|
|
5
|
+
import { i as validateEnvironmentName, n as resolveAppIdentity } from "./validate-environment-CEhUSEg2-D3vECWQz.mjs";
|
|
6
6
|
import { n as requireDevEnvironmentName } from "./dev-environment-name-6eEr5PW8-CGk1ijP7.mjs";
|
|
7
7
|
import { t as withEmulatorRetry } from "./emulator-retry-CV8rl69G-BgUzkxc-.mjs";
|
|
8
8
|
import * as path$1 from "node:path";
|
|
9
|
-
//#region ../../0-framework/3-tooling/cli/dist/execute-log-
|
|
9
|
+
//#region ../../0-framework/3-tooling/cli/dist/execute-log-DA5AAQAA.mjs
|
|
10
10
|
/**
|
|
11
11
|
* The log executor — run-log.ts's attach-and-tail (config → localTarget →
|
|
12
12
|
* container → attach → logs) with console and signal handling removed: the
|
|
@@ -158,4 +158,4 @@ async function executeLog(input, deps, cwd) {
|
|
|
158
158
|
//#endregion
|
|
159
159
|
export { LOG_QUEUE_LIMIT, executeLog };
|
|
160
160
|
|
|
161
|
-
//# sourceMappingURL=execute-log-
|
|
161
|
+
//# sourceMappingURL=execute-log-DA5AAQAA-CBNrz-1p.mjs.map
|
package/dist/{execute-log-aiHhujIh-C_aXmb6j.mjs.map → execute-log-DA5AAQAA-CBNrz-1p.mjs.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute-log-
|
|
1
|
+
{"version":3,"file":"execute-log-DA5AAQAA-CBNrz-1p.mjs","names":["path"],"sources":["../../../0-framework/3-tooling/cli/dist/execute-log-DA5AAQAA.mjs"],"sourcesContent":["import { r as resolveAppIdentity, t as validateEnvironmentName } from \"./validate-environment-CEhUSEg2.mjs\";\nimport { d as toStructured } from \"./dev-current-BNoPkDRU.mjs\";\nimport { n as requireDevEnvironmentName } from \"./dev-environment-name-6eEr5PW8.mjs\";\nimport { t as withEmulatorRetry } from \"./emulator-retry-CV8rl69G.mjs\";\nimport * as path from \"node:path\";\nimport { CliStructuredError } from \"@internal/foundation/errors\";\nimport { notOk, ok } from \"@internal/foundation/result\";\nimport { devEnvironmentDir, resolveLocalTargets } from \"@internal/core/local-target\";\n//#region src/operations/execute-log.ts\n/**\n* The log executor — run-log.ts's attach-and-tail (config → localTarget →\n* container → attach → logs) with console and signal handling removed: the\n* merged stream comes back as an AsyncIterable, ended by the caller's\n* AbortSignal. Reached only by lazy import from log.ts — this module's\n* static graph transitively loads alchemy's provider tree, so the control\n* entry must never import it statically.\n*/\nfunction failureMessage(error) {\n\treturn error instanceof Error ? error.message : String(error);\n}\n/** The merge queue's bound: past this, the oldest line is dropped and the\n* consumer is told via a `lines-dropped` event — a log viewer tolerates loss\n* better than the host tolerates unbounded memory growth. Exported so tests\n* can size their floods relative to the bound. */\nconst LOG_QUEUE_LIMIT = 1e4;\n/**\n* Merges every attachment's log stream into one iterable: one pump per\n* attachment pushing into a shared bounded queue. A pump's throw becomes a\n* `stream-failed` event and ends that pump only; the merged iterable ends\n* when `input.signal` aborts, when every pump ends, or when the consumer\n* stops iterating (an early `break` aborts an internal controller so the\n* pumps tear down — the generator never waits on a source that will not\n* end). No event is delivered after the iterable has ended. Address\n* filtering and `tail` apply exactly as the CLI always has.\n*/\nasync function* mergeLogStreams(attachments, input) {\n\tconst controller = new AbortController();\n\tconst { signal } = controller;\n\tconst abortInternal = () => controller.abort();\n\tif (input.signal?.aborted === true) controller.abort();\n\tinput.signal?.addEventListener(\"abort\", abortInternal, { once: true });\n\tconst queue = [];\n\tlet dropped = 0;\n\tlet done = false;\n\tlet active = attachments.length;\n\tlet wake;\n\tconst notify = () => {\n\t\twake?.();\n\t\twake = void 0;\n\t};\n\tsignal.addEventListener(\"abort\", notify, { once: true });\n\tconst emit = (event) => {\n\t\tif (done) return;\n\t\ttry {\n\t\t\tinput.onEvent?.(event);\n\t\t} catch {}\n\t};\n\tconst pump = async (attachment) => {\n\t\ttry {\n\t\t\tfor await (const { service, line } of attachment.logs(signal, { tail: input.tail ?? 0 })) {\n\t\t\t\tif (signal.aborted) return;\n\t\t\t\tif (input.address !== void 0 && service !== input.address) continue;\n\t\t\t\tif (queue.length >= 1e4) {\n\t\t\t\t\tqueue.shift();\n\t\t\t\t\tdropped += 1;\n\t\t\t\t}\n\t\t\t\tqueue.push({\n\t\t\t\t\tservice,\n\t\t\t\t\tline\n\t\t\t\t});\n\t\t\t\tnotify();\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tif (!signal.aborted) emit({\n\t\t\t\tkind: \"stream-failed\",\n\t\t\t\tmessage: failureMessage(error)\n\t\t\t});\n\t\t} finally {\n\t\t\tactive -= 1;\n\t\t\tnotify();\n\t\t}\n\t};\n\tfor (const attachment of attachments) pump(attachment);\n\ttry {\n\t\twhile (true) {\n\t\t\tlet next = queue.shift();\n\t\t\twhile (next !== void 0) {\n\t\t\t\tif (dropped > 0) {\n\t\t\t\t\tconst count = dropped;\n\t\t\t\t\tdropped = 0;\n\t\t\t\t\temit({\n\t\t\t\t\t\tkind: \"lines-dropped\",\n\t\t\t\t\t\tcount\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tyield next;\n\t\t\t\tnext = queue.shift();\n\t\t\t}\n\t\t\tif (signal.aborted || active === 0) break;\n\t\t\tawait new Promise((resolve) => {\n\t\t\t\twake = resolve;\n\t\t\t});\n\t\t}\n\t} finally {\n\t\tdone = true;\n\t\tcontroller.abort();\n\t\tsignal.removeEventListener(\"abort\", notify);\n\t\tinput.signal?.removeEventListener(\"abort\", abortInternal);\n\t}\n}\n/** Resolves the running app and attaches to its log streams; the caller consumes `lines`. */\nasync function executeLog(input, deps, cwd) {\n\tif (process.platform === \"win32\") return notOk(new CliStructuredError(\"LOG.PLATFORM_UNSUPPORTED\", \"local dev is not supported on Windows yet.\"));\n\tconst environment = input.environment ?? \"dev\";\n\tconst devDir = path.join(cwd, devEnvironmentDir(environment));\n\tlet name;\n\tconst attachments = [];\n\tlet services;\n\ttry {\n\t\tvalidateEnvironmentName(environment);\n\t\trequireDevEnvironmentName(devDir, environment);\n\t\tconst identity = deps.identity ?? await resolveAppIdentity(input.entry, input.name, cwd, input.config);\n\t\tname = identity.name;\n\t\tconst resolved = await resolveLocalTargets(identity.config);\n\t\tfor (const target of resolved.values()) try {\n\t\t\tconst container = await target.container.ensure({\n\t\t\t\tappName: name,\n\t\t\t\tenvironment\n\t\t\t});\n\t\t\tattachments.push(await withEmulatorRetry(() => target.attach({\n\t\t\t\tcontainer,\n\t\t\t\tdevDir\n\t\t\t})));\n\t\t} catch (error) {\n\t\t\tthrow toStructured(\"LOG.ATTACH_FAILED\", error);\n\t\t}\n\t\ttry {\n\t\t\tservices = (await Promise.all(attachments.map((a) => withEmulatorRetry(() => a.endpoints())))).flat();\n\t\t} catch (error) {\n\t\t\tthrow toStructured(\"LOG.ATTACH_FAILED\", error);\n\t\t}\n\t} catch (error) {\n\t\tif (CliStructuredError.is(error)) return notOk(error);\n\t\tthrow error;\n\t}\n\tif (services.length === 0) return ok({\n\t\tappName: name,\n\t\tservices: [],\n\t\tlines: mergeLogStreams([], input)\n\t});\n\tif (input.address !== void 0 && !services.some((s) => s.address === input.address)) return notOk(new CliStructuredError(\"LOG.ADDRESS_UNKNOWN\", `no service \"${input.address}\" in \"${name}\" — running services: ${services.map((s) => s.address).join(\", \")}.`));\n\treturn ok({\n\t\tappName: name,\n\t\tservices,\n\t\tlines: mergeLogStreams(attachments, input)\n\t});\n}\n//#endregion\nexport { LOG_QUEUE_LIMIT, executeLog };\n\n//# sourceMappingURL=execute-log-DA5AAQAA.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,SAAS,eAAe,OAAO;CAC9B,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAC7D;;;;;AAKA,MAAM,kBAAkB;;;;;;;;;;;AAWxB,gBAAgB,gBAAgB,aAAa,OAAO;CACnD,MAAM,aAAa,IAAI,gBAAgB;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C,SAAS;EACT,UAAU,CAAC;EACX,OAAO,gBAAgB,CAAC,GAAG,KAAK;CACjC,CAAC;CACD,IAAI,MAAM,YAAY,KAAK,KAAK,CAAC,SAAS,MAAM,MAAM,EAAE,YAAY,MAAM,OAAO,GAAG,OAAO,MAAM,IAAI,mBAAmB,uBAAuB,eAAe,MAAM,QAAQ,QAAQ,KAAK,wBAAwB,SAAS,KAAK,MAAM,EAAE,OAAO,CAAC,CAAC,KAAK,IAAI,EAAE,EAAE,CAAC;CAC9P,OAAO,GAAG;EACT,SAAS;EACT;EACA,OAAO,gBAAgB,aAAa,KAAK;CAC1C,CAAC;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
//#region ../../0-framework/1-core/core/dist/graph-
|
|
1
|
+
import { T as LoadOptions, at as ServiceNode, g as Graph, j as ModuleNode } from "./graph-types-Bn3tSF4x-BuHwUsq4.mjs";
|
|
2
|
+
//#region ../../0-framework/1-core/core/dist/graph-Dahnws6W.d.mts
|
|
3
3
|
//#region src/graph.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Throws unless `name` can be an app name: the root's address and the first segment of every
|
|
@@ -19,4 +19,4 @@ declare function assertAppName(name: string): void;
|
|
|
19
19
|
declare function Load(root: ServiceNode | ModuleNode, opts?: LoadOptions): Graph;
|
|
20
20
|
//#endregion
|
|
21
21
|
export { assertAppName as n, Load as t };
|
|
22
|
-
//# sourceMappingURL=graph-
|
|
22
|
+
//# sourceMappingURL=graph-Dahnws6W-yKmoqSdc.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph-Dahnws6W-yKmoqSdc.d.mts","names":[],"sources":["../../../0-framework/1-core/core/dist/graph-Dahnws6W.d.mts"],"mappings":";;;;;;;iBAMiB,cAAc;;;;;;;;;;;iBAWd,KAAK,MAAM,cAAc,YAAY,OAAO,cAAc"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { t as blindCast } from "./casts-DpaahrlC-C5XMnP9S.mjs";
|
|
2
|
+
import { n as isSecretString, t as SecretBox } from "./secret-DoWGmN7m-DO5Brq1Y.mjs";
|
|
2
3
|
import { t as InternalError } from "./internal-error-Dfur7Zqt-D96dWHZK.mjs";
|
|
3
4
|
import { t as CliStructuredError } from "./errors-0e8IVwzi.mjs";
|
|
4
|
-
//#region ../../0-framework/1-core/core/dist/graph-
|
|
5
|
+
//#region ../../0-framework/1-core/core/dist/graph-KEuXGBfJ.mjs
|
|
5
6
|
/** The reserved name of a resource's single anonymous output port. Rejected as a user-declared port name (node.ts). */
|
|
6
7
|
const RESOURCE_OUT_PORT = "$out";
|
|
7
8
|
/**
|
|
@@ -306,12 +307,16 @@ function module(name, boundaryOrBody, maybeBody) {
|
|
|
306
307
|
const boundary = closedRoot ? {} : boundaryOrBody;
|
|
307
308
|
requireNotReservedPortNames(Object.keys(boundary.deps ?? {}), "module");
|
|
308
309
|
requireNotReservedPortNames(Object.keys(boundary.expose ?? {}), "module");
|
|
310
|
+
if (boundary.input !== void 0 && typeof boundary.input["~standard"]?.validate !== "function") throw new Error("module() `input` must be a Standard Schema (an object with a \"~standard\".validate function) — see https://standardschema.dev (ADR-0061).");
|
|
309
311
|
const deps = frozenShallowCopy(boundary.deps ?? {});
|
|
310
312
|
const secretSlots = frozenShallowCopy(boundary.secrets ?? {});
|
|
311
313
|
const paramSlots = frozenShallowCopy(boundary.params ?? {});
|
|
312
314
|
const expose = frozenShallowCopy(boundary.expose ?? {});
|
|
313
315
|
const body = closedRoot ? (ctx) => {
|
|
314
|
-
boundaryOrBody(
|
|
316
|
+
boundaryOrBody({
|
|
317
|
+
...ctx,
|
|
318
|
+
input: void 0
|
|
319
|
+
});
|
|
315
320
|
return {};
|
|
316
321
|
} : maybeBody;
|
|
317
322
|
return Object.freeze({
|
|
@@ -321,6 +326,7 @@ function module(name, boundaryOrBody, maybeBody) {
|
|
|
321
326
|
deps,
|
|
322
327
|
secretSlots,
|
|
323
328
|
paramSlots,
|
|
329
|
+
inputSchema: boundary.input,
|
|
324
330
|
expose,
|
|
325
331
|
body
|
|
326
332
|
});
|
|
@@ -467,12 +473,102 @@ function loadService(root, rootId) {
|
|
|
467
473
|
params: []
|
|
468
474
|
};
|
|
469
475
|
}
|
|
476
|
+
const INSPECT = Symbol.for("nodejs.util.inspect.custom");
|
|
477
|
+
/** `input` or `input.a.b`: how an error names an input field. */
|
|
478
|
+
function inputFieldLabel(origin) {
|
|
479
|
+
return origin.path.length === 0 ? "input" : `input.${origin.path.join(".")}`;
|
|
480
|
+
}
|
|
481
|
+
function misuse(origin, what) {
|
|
482
|
+
const field = inputFieldLabel(origin);
|
|
483
|
+
return new LoadError(`${field} of module "${origin.module}" is a value, not its real value, and ${what}. A module body can only pass an input field on: into a provision() binding or as a resolve() dependency. To compute with it, list it: resolve([${field}], ([v]) => …).`);
|
|
484
|
+
}
|
|
485
|
+
function primitiveMisuse(hint) {
|
|
486
|
+
switch (hint) {
|
|
487
|
+
case "string": return "it was turned into text (a template literal or String())";
|
|
488
|
+
case "number": return "it was turned into a number (arithmetic, or a comparison such as <)";
|
|
489
|
+
default: return "it was combined with + or compared with ==";
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* Builds the `input` a module body receives. Every property access returns a
|
|
494
|
+
* value recording its key path, and the same path always returns the same
|
|
495
|
+
* object, so Load's identity-keyed maps see one value per field. Any way of
|
|
496
|
+
* reading the real value throws a LoadError naming the field.
|
|
497
|
+
*/
|
|
498
|
+
function buildModuleInput(moduleAddress) {
|
|
499
|
+
const byPath = /* @__PURE__ */ new Map();
|
|
500
|
+
const valueAt = (path) => {
|
|
501
|
+
const key = JSON.stringify(path);
|
|
502
|
+
const existing = byPath.get(key);
|
|
503
|
+
if (existing !== void 0) return existing;
|
|
504
|
+
const origin = Object.freeze({
|
|
505
|
+
kind: "input",
|
|
506
|
+
module: moduleAddress,
|
|
507
|
+
path: Object.freeze([...path])
|
|
508
|
+
});
|
|
509
|
+
const thrower = (what) => () => {
|
|
510
|
+
throw misuse(origin, what);
|
|
511
|
+
};
|
|
512
|
+
const handler = {
|
|
513
|
+
get(_target, property) {
|
|
514
|
+
if (property === VALUE) return true;
|
|
515
|
+
if (property === VALUE_ORIGIN) return origin;
|
|
516
|
+
if (property === Symbol.toPrimitive) return (hint) => {
|
|
517
|
+
throw misuse(origin, primitiveMisuse(hint));
|
|
518
|
+
};
|
|
519
|
+
if (property === "toString") return thrower("its toString() was called");
|
|
520
|
+
if (property === "valueOf") return thrower("its valueOf() was called");
|
|
521
|
+
if (property === "toJSON") return thrower("it was serialized with JSON.stringify");
|
|
522
|
+
if (property === Symbol.iterator || property === Symbol.asyncIterator) return thrower("it was iterated (array spread, for…of or array destructuring)");
|
|
523
|
+
if (typeof property === "symbol") return void 0;
|
|
524
|
+
return valueAt([...path, property]);
|
|
525
|
+
},
|
|
526
|
+
has(_target, property) {
|
|
527
|
+
if (property === VALUE || property === VALUE_ORIGIN) return true;
|
|
528
|
+
if (typeof property === "symbol") return false;
|
|
529
|
+
throw misuse(origin, `it was checked with the in operator ("${property}" in …)`);
|
|
530
|
+
},
|
|
531
|
+
ownKeys() {
|
|
532
|
+
throw misuse(origin, "its keys were listed (Object.keys, object spread, for…in or Object.entries)");
|
|
533
|
+
},
|
|
534
|
+
getOwnPropertyDescriptor() {
|
|
535
|
+
throw misuse(origin, "its properties were inspected");
|
|
536
|
+
},
|
|
537
|
+
set(_target, property) {
|
|
538
|
+
throw misuse(origin, `its field "${String(property)}" was assigned to`);
|
|
539
|
+
},
|
|
540
|
+
defineProperty(_target, property) {
|
|
541
|
+
throw misuse(origin, `its field "${String(property)}" was assigned to`);
|
|
542
|
+
},
|
|
543
|
+
deleteProperty() {
|
|
544
|
+
throw misuse(origin, "a property was deleted from it");
|
|
545
|
+
},
|
|
546
|
+
setPrototypeOf() {
|
|
547
|
+
throw misuse(origin, "its prototype was changed");
|
|
548
|
+
},
|
|
549
|
+
preventExtensions() {
|
|
550
|
+
throw misuse(origin, "it was frozen or sealed");
|
|
551
|
+
}
|
|
552
|
+
};
|
|
553
|
+
const target = Object.create(null);
|
|
554
|
+
Object.defineProperty(target, INSPECT, {
|
|
555
|
+
value: () => `[${inputFieldLabel(origin)} of module "${origin.module}"]`,
|
|
556
|
+
configurable: true
|
|
557
|
+
});
|
|
558
|
+
const proxy = new Proxy(target, handler);
|
|
559
|
+
byPath.set(key, proxy);
|
|
560
|
+
return proxy;
|
|
561
|
+
};
|
|
562
|
+
return blindCast(valueAt([]));
|
|
563
|
+
}
|
|
564
|
+
const SENTINEL_SOURCE = Symbol("prisma:module-input-sentinel");
|
|
470
565
|
function joinPath(path, key) {
|
|
471
566
|
return path === "" ? String(key) : `${path}.${key}`;
|
|
472
567
|
}
|
|
473
568
|
function describeSite(site) {
|
|
474
569
|
switch (site.kind) {
|
|
475
|
-
case "
|
|
570
|
+
case "serviceInput": return site.path === "" ? `the input binding of service "${site.address}"` : `input key "${site.path}" of service "${site.address}"`;
|
|
571
|
+
case "moduleInput": return site.path === "" ? `the input binding of module "${site.address}"` : `input key "${site.path}" of module "${site.address}"`;
|
|
476
572
|
case "param": return `param "${site.path}" of service "${site.address}"`;
|
|
477
573
|
case "props": return site.path === "" ? `the props of resource "${site.address}"` : `prop "${site.path}" of resource "${site.address}"`;
|
|
478
574
|
}
|
|
@@ -509,6 +605,7 @@ function describeNotPlain(value) {
|
|
|
509
605
|
}
|
|
510
606
|
}
|
|
511
607
|
function isThenable(value) {
|
|
608
|
+
if (isValue(value)) return false;
|
|
512
609
|
return typeof value === "object" && value !== null && "then" in value && typeof value.then === "function";
|
|
513
610
|
}
|
|
514
611
|
function checkResult(result, fnLabel) {
|
|
@@ -544,14 +641,80 @@ function substitute(value, results, inProgress) {
|
|
|
544
641
|
const rebuilt = {};
|
|
545
642
|
let changed = false;
|
|
546
643
|
for (const [key, member] of Object.entries(value)) {
|
|
547
|
-
|
|
548
|
-
if (
|
|
644
|
+
const real = substitute(member, results, inProgress);
|
|
645
|
+
if (real === void 0 && isValue(member)) {
|
|
646
|
+
changed = true;
|
|
647
|
+
continue;
|
|
648
|
+
}
|
|
649
|
+
rebuilt[key] = real;
|
|
650
|
+
if (real !== member) changed = true;
|
|
549
651
|
}
|
|
550
652
|
inProgress.delete(value);
|
|
551
653
|
return changed ? rebuilt : value;
|
|
552
654
|
}
|
|
553
655
|
return value;
|
|
554
656
|
}
|
|
657
|
+
function describeData(value) {
|
|
658
|
+
if (Array.isArray(value)) return "an array";
|
|
659
|
+
if (isSecretSource(value)) return "a secret";
|
|
660
|
+
if (typeof value === "object") return "an object that is not plain data";
|
|
661
|
+
return `a ${typeof value}`;
|
|
662
|
+
}
|
|
663
|
+
/** The data at `origin`'s path inside a validated input; `undefined` where a key or a parent is absent. */
|
|
664
|
+
function readPath(data, origin) {
|
|
665
|
+
let current = data;
|
|
666
|
+
for (const [index, key] of origin.path.entries()) {
|
|
667
|
+
if (current === void 0 || current === null) return void 0;
|
|
668
|
+
if (!isPlainObject(current) || isSecretSource(current)) {
|
|
669
|
+
const parent = inputFieldLabel({
|
|
670
|
+
...origin,
|
|
671
|
+
path: origin.path.slice(0, index)
|
|
672
|
+
});
|
|
673
|
+
throw new LoadError(`${inputFieldLabel(origin)} of module "${origin.module}" does not exist: ${parent} is ${describeData(current)}, not a plain object, so it has no fields. To compute with it, list it: resolve([${parent}], ([v]) => …).`);
|
|
674
|
+
}
|
|
675
|
+
if (!Object.hasOwn(current, key)) return void 0;
|
|
676
|
+
current = current[key];
|
|
677
|
+
}
|
|
678
|
+
return current;
|
|
679
|
+
}
|
|
680
|
+
function validateModuleInput(entry, resolved) {
|
|
681
|
+
const address = entry.moduleAddress;
|
|
682
|
+
const withSentinels = (value, path) => {
|
|
683
|
+
if (isSecretSource(value)) {
|
|
684
|
+
const sentinel = new SecretBox("");
|
|
685
|
+
Object.defineProperty(sentinel, SENTINEL_SOURCE, { value });
|
|
686
|
+
return sentinel;
|
|
687
|
+
}
|
|
688
|
+
if (isParamSource(value)) throw new LoadError(`${describeSite({
|
|
689
|
+
address,
|
|
690
|
+
kind: "moduleInput",
|
|
691
|
+
path
|
|
692
|
+
})} is bound to a param source, such as envParam(). A module's input does not take a param source yet; bind it on the service's input inside the module, or forward it through the module's params slot.`);
|
|
693
|
+
if (isSecretString(value)) throw new LoadError(`${describeSite({
|
|
694
|
+
address,
|
|
695
|
+
kind: "moduleInput",
|
|
696
|
+
path
|
|
697
|
+
})} is bound to a SecretString. A secret's value never appears in the code; bind envSecret('NAME'), or pass on an input field typed secretString().`);
|
|
698
|
+
if (Array.isArray(value)) return value.map((member, index) => withSentinels(member, joinPath(path, index)));
|
|
699
|
+
if (isPlainObject(value)) return Object.fromEntries(Object.entries(value).map(([key, member]) => [key, withSentinels(member, joinPath(path, key))]));
|
|
700
|
+
return value;
|
|
701
|
+
};
|
|
702
|
+
const result = entry.schema["~standard"].validate(withSentinels(resolved, ""));
|
|
703
|
+
if (result instanceof Promise) throw new LoadError(`The input schema of module "${address}" returned a Promise from validate(). A module's input is validated synchronously at Load; use a schema with no asynchronous checks.`);
|
|
704
|
+
if (result.issues !== void 0) throw new LoadError(`The input binding of module "${address}" does not match the module's input schema: ${result.issues.map((issue) => issue.message).join("; ")}`);
|
|
705
|
+
const restore = (value, path) => {
|
|
706
|
+
if (isSecretString(value)) {
|
|
707
|
+
const source = blindCast(value)[SENTINEL_SOURCE];
|
|
708
|
+
if (isSecretSource(source)) return source;
|
|
709
|
+
const atPath = path === "" ? "" : ` at "${path}"`;
|
|
710
|
+
throw new LoadError(`The input schema of module "${address}" produced a SecretString${atPath} that its binding did not supply. A module's schema may check a secret field, never create one.`);
|
|
711
|
+
}
|
|
712
|
+
if (Array.isArray(value)) return value.map((member, index) => restore(member, joinPath(path, index)));
|
|
713
|
+
if (isPlainObject(value)) return Object.fromEntries(Object.entries(value).map(([key, member]) => [key, restore(member, joinPath(path, key))]));
|
|
714
|
+
return value;
|
|
715
|
+
};
|
|
716
|
+
return restore(result.value, "");
|
|
717
|
+
}
|
|
555
718
|
/**
|
|
556
719
|
* Resolves every value the graph binds, dependency-first, once each, and
|
|
557
720
|
* returns each binding with its values replaced by their real values.
|
|
@@ -561,7 +724,7 @@ function resolveValues(input) {
|
|
|
561
724
|
const found = [];
|
|
562
725
|
for (const { serviceAddress, binding } of input.inputBindings) collect(binding, {
|
|
563
726
|
address: serviceAddress,
|
|
564
|
-
kind: "
|
|
727
|
+
kind: "serviceInput",
|
|
565
728
|
path: ""
|
|
566
729
|
}, found, /* @__PURE__ */ new WeakSet());
|
|
567
730
|
for (const { serviceAddress, slot, binding } of input.params) collect(binding, {
|
|
@@ -577,6 +740,9 @@ function resolveValues(input) {
|
|
|
577
740
|
};
|
|
578
741
|
collect(resource.props, site, found, /* @__PURE__ */ new WeakSet());
|
|
579
742
|
}
|
|
743
|
+
const moduleInputByAddress = new Map(input.moduleInputs.map((entry) => [entry.moduleAddress, entry]));
|
|
744
|
+
const validatedInputs = /* @__PURE__ */ new Map();
|
|
745
|
+
const validating = /* @__PURE__ */ new Set();
|
|
580
746
|
const results = /* @__PURE__ */ new Map();
|
|
581
747
|
const visiting = [];
|
|
582
748
|
const fnLabelFor = (site) => visiting.length === 1 ? `The resolve() function for ${describeSite(site)}` : `A resolve() function that ${describeSite(site)} depends on`;
|
|
@@ -603,11 +769,35 @@ function resolveValues(input) {
|
|
|
603
769
|
checkResult(result, fnLabelFor(site));
|
|
604
770
|
break;
|
|
605
771
|
}
|
|
772
|
+
case "input": {
|
|
773
|
+
const entry = moduleInputByAddress.get(origin.module);
|
|
774
|
+
if (entry === void 0) throw new LoadError(`${describeSite(site)} depends on ${inputFieldLabel(origin)} of module "${origin.module}", which this Load does not provision. An input field can be passed on only inside the body of the module that received it.`);
|
|
775
|
+
result = readPath(validatedInputOf(entry), origin);
|
|
776
|
+
break;
|
|
777
|
+
}
|
|
606
778
|
}
|
|
607
779
|
visiting.pop();
|
|
608
780
|
results.set(value, result);
|
|
609
781
|
return result;
|
|
610
782
|
};
|
|
783
|
+
const validatedInputOf = (entry) => {
|
|
784
|
+
if (validatedInputs.has(entry.moduleAddress)) return validatedInputs.get(entry.moduleAddress);
|
|
785
|
+
if (validating.has(entry.moduleAddress)) throw new LoadError(`The input binding of module "${entry.moduleAddress}" depends on that module's own input. Remove the cycle.`);
|
|
786
|
+
validating.add(entry.moduleAddress);
|
|
787
|
+
const site = {
|
|
788
|
+
address: entry.moduleAddress,
|
|
789
|
+
kind: "moduleInput",
|
|
790
|
+
path: ""
|
|
791
|
+
};
|
|
792
|
+
const values = [];
|
|
793
|
+
collect(entry.binding, site, values, /* @__PURE__ */ new WeakSet());
|
|
794
|
+
for (const { value, site: valueSite } of values) resolveOne(value, valueSite);
|
|
795
|
+
const validated = validateModuleInput(entry, substitute(entry.binding, results, /* @__PURE__ */ new WeakSet()));
|
|
796
|
+
validating.delete(entry.moduleAddress);
|
|
797
|
+
validatedInputs.set(entry.moduleAddress, validated);
|
|
798
|
+
return validated;
|
|
799
|
+
};
|
|
800
|
+
for (const entry of input.moduleInputs) validatedInputOf(entry);
|
|
611
801
|
for (const { value, site } of found) resolveOne(value, site);
|
|
612
802
|
const authoredProps = new Map([...input.resources].map(([address, resource]) => [address, resource.props]));
|
|
613
803
|
if (found.length === 0) return {
|
|
@@ -630,12 +820,13 @@ function resolveValues(input) {
|
|
|
630
820
|
binding: blindCast(binding)
|
|
631
821
|
};
|
|
632
822
|
}),
|
|
633
|
-
params: input.params.
|
|
823
|
+
params: input.params.flatMap((entry) => {
|
|
634
824
|
const binding = substitute(entry.binding, results, inProgress);
|
|
635
|
-
|
|
825
|
+
if (binding === void 0 && isValue(entry.binding)) return [];
|
|
826
|
+
return [binding === entry.binding ? entry : {
|
|
636
827
|
...entry,
|
|
637
828
|
binding
|
|
638
|
-
};
|
|
829
|
+
}];
|
|
639
830
|
})
|
|
640
831
|
};
|
|
641
832
|
}
|
|
@@ -751,16 +942,16 @@ function validateWiring(pending, byId) {
|
|
|
751
942
|
* Flattens a value into itself plus every nested object/array member value —
|
|
752
943
|
* identity fodder for the ctx.secrets/ctx.params usage marking, which must
|
|
753
944
|
* see a forwarded source wherever it sits inside an input binding (ADR-0042).
|
|
754
|
-
* A secret/param source is an opaque leaf: it is pushed (a
|
|
755
|
-
* such a source, so identity-matching still needs it) but
|
|
756
|
-
* into, so a ref buried in an unrelated source's payload is
|
|
757
|
-
* as used. `seen` guards object cycles so a self-referential binding cannot
|
|
945
|
+
* A value or a secret/param source is an opaque leaf: it is pushed (a
|
|
946
|
+
* forwarded ref IS such a source, so identity-matching still needs it) but
|
|
947
|
+
* never descended into, so a ref buried in an unrelated source's payload is
|
|
948
|
+
* not falsely seen as used. `seen` guards object cycles so a self-referential binding cannot
|
|
758
949
|
* recurse forever.
|
|
759
950
|
*/
|
|
760
951
|
function deepValues(value, out, seen = /* @__PURE__ */ new WeakSet()) {
|
|
761
952
|
out.push(value);
|
|
762
953
|
if (typeof value !== "object" || value === null) return;
|
|
763
|
-
if (isSecretSource(value) || isParamSource(value)) return;
|
|
954
|
+
if (isValue(value) || isSecretSource(value) || isParamSource(value)) return;
|
|
764
955
|
if (seen.has(value)) return;
|
|
765
956
|
seen.add(value);
|
|
766
957
|
const members = Array.isArray(value) ? value : Object.values(value);
|
|
@@ -835,7 +1026,7 @@ function validateParamNeedBinding(child, id, address, paramWiring, enclosingModu
|
|
|
835
1026
|
* children carry it as their `parent`, and this module's own boundary ports
|
|
836
1027
|
* (and the authored edges touching them) are recorded against it.
|
|
837
1028
|
*/
|
|
838
|
-
function flatten(moduleNode, selfId, wiring, secretWiring, paramWiring, nodes, edges, pending, inputBindings, paramBindings, byId, ports, authoredEdges, loading) {
|
|
1029
|
+
function flatten(moduleNode, selfId, wiring, secretWiring, paramWiring, nodes, edges, pending, inputBindings, paramBindings, moduleInputs, byId, ports, authoredEdges, loading) {
|
|
839
1030
|
ports.push(...boundaryPortsOf(selfId, moduleNode));
|
|
840
1031
|
const localIds = /* @__PURE__ */ new Set();
|
|
841
1032
|
const used = /* @__PURE__ */ new Set();
|
|
@@ -997,7 +1188,20 @@ function flatten(moduleNode, selfId, wiring, secretWiring, paramWiring, nodes, e
|
|
|
997
1188
|
byId.set(fullAddress, child);
|
|
998
1189
|
return refFor(fullAddress, child);
|
|
999
1190
|
}
|
|
1000
|
-
|
|
1191
|
+
const childInputSchema = child.inputSchema;
|
|
1192
|
+
if (childInputSchema === void 0 && provisionInput !== void 0) throw new LoadError(`provision("${id}") received an input binding, but the module declares no input schema (module "${moduleNode.name}").`);
|
|
1193
|
+
if (childInputSchema !== void 0 && provisionInput === void 0) throw new LoadError(`Input of provisioned module "${id}" is not bound (module "${moduleNode.name}") — the module declares an input schema; bind it with \`input: { … }\` on its provision() call.`);
|
|
1194
|
+
if (childInputSchema !== void 0) {
|
|
1195
|
+
const leaves = [];
|
|
1196
|
+
deepValues(provisionInput, leaves);
|
|
1197
|
+
markSecretsUsed(leaves);
|
|
1198
|
+
markParamsUsed(leaves);
|
|
1199
|
+
moduleInputs.push({
|
|
1200
|
+
moduleAddress: fullAddress,
|
|
1201
|
+
schema: childInputSchema,
|
|
1202
|
+
binding: provisionInput
|
|
1203
|
+
});
|
|
1204
|
+
}
|
|
1001
1205
|
validateSecretBinding(child, id, fullAddress, localSecrets, moduleNode.name);
|
|
1002
1206
|
validateParamNeedBinding(child, id, fullAddress, localParams, moduleNode.name);
|
|
1003
1207
|
edges.push(...wiringEdges(localWiring, fullAddress));
|
|
@@ -1009,7 +1213,7 @@ function flatten(moduleNode, selfId, wiring, secretWiring, paramWiring, nodes, e
|
|
|
1009
1213
|
targetKind: "module",
|
|
1010
1214
|
enclosingModuleName: moduleNode.name
|
|
1011
1215
|
});
|
|
1012
|
-
const childOutputs = flatten(child, fullAddress, localWiring, localSecrets, localParams, nodes, edges, pending, inputBindings, paramBindings, byId, ports, authoredEdges, loading);
|
|
1216
|
+
const childOutputs = flatten(child, fullAddress, localWiring, localSecrets, localParams, nodes, edges, pending, inputBindings, paramBindings, moduleInputs, byId, ports, authoredEdges, loading);
|
|
1013
1217
|
nodes.push({
|
|
1014
1218
|
id: fullAddress,
|
|
1015
1219
|
parent: selfId,
|
|
@@ -1033,6 +1237,7 @@ function flatten(moduleNode, selfId, wiring, secretWiring, paramWiring, nodes, e
|
|
|
1033
1237
|
deps: ctxInputs,
|
|
1034
1238
|
secrets: ctxSecrets,
|
|
1035
1239
|
params: ctxParams,
|
|
1240
|
+
input: moduleNode.inputSchema === void 0 ? void 0 : buildModuleInput(selfId),
|
|
1036
1241
|
environment: environmentFacts,
|
|
1037
1242
|
provision: blindCast(provision)
|
|
1038
1243
|
});
|
|
@@ -1044,6 +1249,7 @@ function flatten(moduleNode, selfId, wiring, secretWiring, paramWiring, nodes, e
|
|
|
1044
1249
|
for (const [key, contract] of Object.entries(moduleNode.expose)) {
|
|
1045
1250
|
const port = outputs[key];
|
|
1046
1251
|
if (port === void 0) throw new LoadError(`Module "${moduleNode.name}" declares expose "${key}" but its body did not return a port for it.`);
|
|
1252
|
+
if (isValue(port)) throw new LoadError(`Module "${moduleNode.name}" returned a value for expose "${key}". A value can configure a node, never decide its edges: return a port of a node the body provisions.`);
|
|
1047
1253
|
if (!satisfiesRequired(port, contract)) throw new LoadError(`Module "${moduleNode.name}"'s returned port for expose "${key}" does not satisfy its declared contract.`);
|
|
1048
1254
|
const from = authoredSourceOf(port);
|
|
1049
1255
|
if (from !== void 0) authoredEdges.push({
|
|
@@ -1074,17 +1280,19 @@ function loadModule(root, opts) {
|
|
|
1074
1280
|
const names = rootParamKeys.map((k) => `"${k}"`).join(", ");
|
|
1075
1281
|
throw new LoadError(`Module "${root.name}" declares param${rootParamKeys.length > 1 ? "s" : ""} ${names} but is being deployed as the root — a root has no enclosing scope to bind them; the root binds params directly on each provision() call, it does not declare param-forwarding slots of its own.`);
|
|
1076
1282
|
}
|
|
1283
|
+
if (root.inputSchema !== void 0) throw new LoadError(`Module "${root.name}" declares input but is being deployed as the root. Composer cannot fill a root's input yet; provision "${root.name}" from another module and bind its input there.`);
|
|
1077
1284
|
const nodes = [];
|
|
1078
1285
|
const edges = [];
|
|
1079
1286
|
const pending = [];
|
|
1080
1287
|
const inputBindings = [];
|
|
1081
1288
|
const paramBindings = [];
|
|
1289
|
+
const moduleInputs = [];
|
|
1082
1290
|
const byId = /* @__PURE__ */ new Map();
|
|
1083
1291
|
const ports = [];
|
|
1084
1292
|
const authoredEdges = [];
|
|
1085
1293
|
const loading = { sealed: false };
|
|
1086
1294
|
try {
|
|
1087
|
-
flatten(root, rootId, {}, {}, {}, nodes, edges, pending, inputBindings, paramBindings, byId, ports, authoredEdges, loading);
|
|
1295
|
+
flatten(root, rootId, {}, {}, {}, nodes, edges, pending, inputBindings, paramBindings, moduleInputs, byId, ports, authoredEdges, loading);
|
|
1088
1296
|
for (const entry of pending) validateWiring(entry, byId);
|
|
1089
1297
|
assertDependencyDag(edges);
|
|
1090
1298
|
} finally {
|
|
@@ -1096,6 +1304,7 @@ function loadModule(root, opts) {
|
|
|
1096
1304
|
environment: opts?.environment,
|
|
1097
1305
|
inputBindings,
|
|
1098
1306
|
params: paramBindings,
|
|
1307
|
+
moduleInputs,
|
|
1099
1308
|
resources
|
|
1100
1309
|
});
|
|
1101
1310
|
const resolvedNodes = nodes.map((entry) => {
|
|
@@ -1193,4 +1402,4 @@ function Load(root, opts) {
|
|
|
1193
1402
|
//#endregion
|
|
1194
1403
|
export { slotsOf as S, resolve as _, assertAppName as a, secretSource as b, isNode as c, isSecretSource as d, isValue as f, provisionNeed as g, paramSource as h, ResourceNodeBase as i, isParamSource as l, paramNeed as m, LoadError as n, dependency as o, module as p, RESOURCE_OUT_PORT as r, freezeNode as s, Load as t, isProvisionNeed as u, resource as v, service as x, secret as y };
|
|
1195
1404
|
|
|
1196
|
-
//# sourceMappingURL=graph-
|
|
1405
|
+
//# sourceMappingURL=graph-KEuXGBfJ-BfR6EMoN.mjs.map
|