@prisma/composer-cli 0.38.0 → 0.39.0-dev.10

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.
Files changed (74) hide show
  1. package/dist/app-converge-C_YkTIBF-RmqGOR45.mjs +88 -0
  2. package/dist/app-converge-C_YkTIBF-RmqGOR45.mjs.map +1 -0
  3. package/dist/composer-config-QKdY85G--CEXrb2Uc.mjs +254 -0
  4. package/dist/composer-config-QKdY85G--CEXrb2Uc.mjs.map +1 -0
  5. package/dist/{validate-environment-CpQLC3CA-Ct-PXoKN.mjs → deploy-Br1yvLe3.mjs} +341 -1082
  6. package/dist/deploy-Br1yvLe3.mjs.map +1 -0
  7. package/dist/dev-converge-messages-DML4rTz7-B6uxtpZG.mjs +256 -0
  8. package/dist/dev-converge-messages-DML4rTz7-B6uxtpZG.mjs.map +1 -0
  9. package/dist/dev-converge-worker.d.mts +1 -0
  10. package/dist/dev-converge-worker.mjs +143 -0
  11. package/dist/dev-converge-worker.mjs.map +1 -0
  12. package/dist/{dev-current-D-Qb6Yem-CvaY4xsk.mjs → dev-current-DANgmcle-RwunETUJ.mjs} +12 -18
  13. package/dist/dev-current-DANgmcle-RwunETUJ.mjs.map +1 -0
  14. package/dist/dev-environment-name-6eEr5PW8-CCY7WNWz.mjs +43 -0
  15. package/dist/dev-environment-name-6eEr5PW8-CCY7WNWz.mjs.map +1 -0
  16. package/dist/{dist-BH6HQ6zZ.mjs → dist-C0OGaDnj.mjs} +4 -3
  17. package/dist/{dist-BH6HQ6zZ.mjs.map → dist-C0OGaDnj.mjs.map} +1 -1
  18. package/dist/errors-CVYwN2km.mjs +93 -0
  19. package/dist/errors-CVYwN2km.mjs.map +1 -0
  20. package/dist/{execute-deploy-destroy-C6EsdmLz-DqdToZ_i.mjs → execute-deploy-destroy-DIR9uvA_-Bk0HBMTz.mjs} +385 -141
  21. package/dist/execute-deploy-destroy-DIR9uvA_-Bk0HBMTz.mjs.map +1 -0
  22. package/dist/{execute-dev-gjIKYybU-hRndPEgC.mjs → execute-dev-Cu9_LsQi-CsyIqphZ.mjs} +450 -127
  23. package/dist/execute-dev-Cu9_LsQi-CsyIqphZ.mjs.map +1 -0
  24. package/dist/{execute-dev-current-tBKmDAjV-DOOMGrl5.mjs → execute-dev-current-Bs0lE_5--BU3A2hsC.mjs} +9 -6
  25. package/dist/{execute-dev-current-tBKmDAjV-DOOMGrl5.mjs.map → execute-dev-current-Bs0lE_5--BU3A2hsC.mjs.map} +1 -1
  26. package/dist/{redaction-Bf8FvTFH-D0dXGsO8.d.mts → family-DfwviKFj-CS1L-EvS.d.mts} +484 -204
  27. package/dist/family-DfwviKFj-CS1L-EvS.d.mts.map +1 -0
  28. package/dist/family.d.mts +1 -1
  29. package/dist/family.mjs +350 -270
  30. package/dist/family.mjs.map +1 -1
  31. package/dist/internal-error-Dfur7Zqt-B8J8e7ac.mjs +58 -0
  32. package/dist/internal-error-Dfur7Zqt-B8J8e7ac.mjs.map +1 -0
  33. package/dist/{list-deployed-IL0MgmTX.mjs → list-deployed-slo4P7dl.mjs} +6 -5
  34. package/dist/list-deployed-slo4P7dl.mjs.map +1 -0
  35. package/dist/local-target-CZzICh5R.mjs +34 -0
  36. package/dist/local-target-CZzICh5R.mjs.map +1 -0
  37. package/dist/{config-DiZaanS3.mjs → preflight-transport-2d6iIchu-ArIJUY1L.mjs} +11 -19
  38. package/dist/preflight-transport-2d6iIchu-ArIJUY1L.mjs.map +1 -0
  39. package/dist/{redaction-HnbkSFrK-CCKJNRwi.mjs → redaction-DY6eDC12-BrK1aSN5.mjs} +55 -262
  40. package/dist/redaction-DY6eDC12-BrK1aSN5.mjs.map +1 -0
  41. package/dist/result-CttmabB6.mjs +91 -0
  42. package/dist/result-CttmabB6.mjs.map +1 -0
  43. package/dist/rolldown-runtime-C7HZzL1F.mjs +26 -0
  44. package/dist/steps-BZXNqW6U-BM2Aa8Bp.mjs +287 -0
  45. package/dist/steps-BZXNqW6U-BM2Aa8Bp.mjs.map +1 -0
  46. package/dist/testing.d.mts +4 -49
  47. package/dist/testing.d.mts.map +1 -1
  48. package/dist/testing.mjs +2 -75
  49. package/dist/testing.mjs.map +1 -1
  50. package/dist/validate-environment-DCZiNSlR-idVge-kq.mjs +983 -0
  51. package/dist/validate-environment-DCZiNSlR-idVge-kq.mjs.map +1 -0
  52. package/dist/value-reads-change-text-DcRCv7Zy-Ca8m3bal.mjs +15 -0
  53. package/dist/value-reads-change-text-DcRCv7Zy-Ca8m3bal.mjs.map +1 -0
  54. package/package.json +11 -11
  55. package/src/exports/dev-converge-worker.ts +2 -0
  56. package/src/exports/testing.ts +1 -4
  57. package/dist/app-configuration-file-CeJvBAti-Dk65W3Az.mjs +0 -140
  58. package/dist/app-configuration-file-CeJvBAti-Dk65W3Az.mjs.map +0 -1
  59. package/dist/config-DiZaanS3.mjs.map +0 -1
  60. package/dist/dev-current-D-Qb6Yem-CvaY4xsk.mjs.map +0 -1
  61. package/dist/dev-environment-name-6eEr5PW8-DpdGjmTb.mjs +0 -71
  62. package/dist/dev-environment-name-6eEr5PW8-DpdGjmTb.mjs.map +0 -1
  63. package/dist/execute-deploy-destroy-C6EsdmLz-DqdToZ_i.mjs.map +0 -1
  64. package/dist/execute-dev-gjIKYybU-hRndPEgC.mjs.map +0 -1
  65. package/dist/generate-dev-stack-BV_n-X9n-BDBjgphH.mjs +0 -100
  66. package/dist/generate-dev-stack-BV_n-X9n-BDBjgphH.mjs.map +0 -1
  67. package/dist/list-deployed-IL0MgmTX.mjs.map +0 -1
  68. package/dist/redaction-Bf8FvTFH-D0dXGsO8.d.mts.map +0 -1
  69. package/dist/redaction-HnbkSFrK-CCKJNRwi.mjs.map +0 -1
  70. package/dist/result-sR7PBi61.mjs +0 -229
  71. package/dist/result-sR7PBi61.mjs.map +0 -1
  72. package/dist/run-alchemy-OS_ix5g0-DSlHsv2p.mjs +0 -236
  73. package/dist/run-alchemy-OS_ix5g0-DSlHsv2p.mjs.map +0 -1
  74. package/dist/validate-environment-CpQLC3CA-Ct-PXoKN.mjs.map +0 -1
@@ -1,39 +1,14 @@
1
- import { d as configFileMissing, f as entryMissing, i as credentialLookingValues, l as valuesUnderSecretsKeys, n as SecretRedaction, u as checkComposerConfig } from "./redaction-HnbkSFrK-CCKJNRwi.mjs";
2
- import { a as InternalError, i as CliStructuredError, o as blindCast } from "./result-sR7PBi61.mjs";
1
+ import { n as blindCast, t as InternalError } from "./internal-error-Dfur7Zqt-B8J8e7ac.mjs";
2
+ import { t as CliStructuredError } from "./errors-CVYwN2km.mjs";
3
3
  import * as mod from "node:module";
4
- import { createRequire } from "node:module";
5
- import * as fs from "node:fs";
6
- import { existsSync } from "node:fs";
4
+ import { existsSync, statSync } from "node:fs";
7
5
  import * as path from "node:path";
6
+ import { fileURLToPath, pathToFileURL } from "node:url";
8
7
  import "alchemy";
9
8
  import "effect/Effect";
10
9
  import "effect/Layer";
11
- import { fileURLToPath, pathToFileURL } from "node:url";
12
- import { spawnSync } from "node:child_process";
13
- //#region \0rolldown/runtime.js
14
- var __create = Object.create;
15
- var __defProp = Object.defineProperty;
16
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
17
- var __getOwnPropNames = Object.getOwnPropertyNames;
18
- var __getProtoOf = Object.getPrototypeOf;
19
- var __hasOwnProp = Object.prototype.hasOwnProperty;
20
- var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
21
- var __copyProps = (to, from, except, desc) => {
22
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
23
- key = keys[i];
24
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
25
- get: ((k) => from[k]).bind(null, key),
26
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
27
- });
28
- }
29
- return to;
30
- };
31
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
32
- value: mod,
33
- enumerable: true
34
- }) : target, mod));
35
- var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
36
- //#endregion
10
+ import * as Data from "effect/Data";
11
+ import * as Predicate from "effect/Predicate";
37
12
  //#region ../../0-framework/0-foundation/foundation/dist/describe-kind-Cpm_euxo.mjs
38
13
  /** How an error names the kind of a value it did not expect, without printing the value. */
39
14
  function describeKind(value) {
@@ -45,746 +20,8 @@ function describeKind(value) {
45
20
  return `a ${typeof value}`;
46
21
  }
47
22
  //#endregion
48
- //#region ../../../node_modules/dotenv-flow/node_modules/dotenv/package.json
49
- var require_package$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
50
- module.exports = {
51
- "name": "dotenv",
52
- "version": "16.6.1",
53
- "description": "Loads environment variables from .env file",
54
- "main": "lib/main.js",
55
- "types": "lib/main.d.ts",
56
- "exports": {
57
- ".": {
58
- "types": "./lib/main.d.ts",
59
- "require": "./lib/main.js",
60
- "default": "./lib/main.js"
61
- },
62
- "./config": "./config.js",
63
- "./config.js": "./config.js",
64
- "./lib/env-options": "./lib/env-options.js",
65
- "./lib/env-options.js": "./lib/env-options.js",
66
- "./lib/cli-options": "./lib/cli-options.js",
67
- "./lib/cli-options.js": "./lib/cli-options.js",
68
- "./package.json": "./package.json"
69
- },
70
- "scripts": {
71
- "dts-check": "tsc --project tests/types/tsconfig.json",
72
- "lint": "standard",
73
- "pretest": "npm run lint && npm run dts-check",
74
- "test": "tap run --allow-empty-coverage --disable-coverage --timeout=60000",
75
- "test:coverage": "tap run --show-full-coverage --timeout=60000 --coverage-report=text --coverage-report=lcov",
76
- "prerelease": "npm test",
77
- "release": "standard-version"
78
- },
79
- "repository": {
80
- "type": "git",
81
- "url": "git://github.com/motdotla/dotenv.git"
82
- },
83
- "homepage": "https://github.com/motdotla/dotenv#readme",
84
- "funding": "https://dotenvx.com",
85
- "keywords": [
86
- "dotenv",
87
- "env",
88
- ".env",
89
- "environment",
90
- "variables",
91
- "config",
92
- "settings"
93
- ],
94
- "readmeFilename": "README.md",
95
- "license": "BSD-2-Clause",
96
- "devDependencies": {
97
- "@types/node": "^18.11.3",
98
- "decache": "^4.6.2",
99
- "sinon": "^14.0.1",
100
- "standard": "^17.0.0",
101
- "standard-version": "^9.5.0",
102
- "tap": "^19.2.0",
103
- "typescript": "^4.8.4"
104
- },
105
- "engines": { "node": ">=12" },
106
- "browser": { "fs": false }
107
- };
108
- }));
109
- //#endregion
110
- //#region ../../../node_modules/dotenv-flow/node_modules/dotenv/lib/main.js
111
- var require_main = /* @__PURE__ */ __commonJSMin(((exports, module) => {
112
- const fs$2 = __require("fs");
113
- const path$1 = __require("path");
114
- const os = __require("os");
115
- const crypto = __require("crypto");
116
- const version = require_package$1().version;
117
- const LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm;
118
- function parse(src) {
119
- const obj = {};
120
- let lines = src.toString();
121
- lines = lines.replace(/\r\n?/gm, "\n");
122
- let match;
123
- while ((match = LINE.exec(lines)) != null) {
124
- const key = match[1];
125
- let value = match[2] || "";
126
- value = value.trim();
127
- const maybeQuote = value[0];
128
- value = value.replace(/^(['"`])([\s\S]*)\1$/gm, "$2");
129
- if (maybeQuote === "\"") {
130
- value = value.replace(/\\n/g, "\n");
131
- value = value.replace(/\\r/g, "\r");
132
- }
133
- obj[key] = value;
134
- }
135
- return obj;
136
- }
137
- function _parseVault(options) {
138
- options = options || {};
139
- const vaultPath = _vaultPath(options);
140
- options.path = vaultPath;
141
- const result = DotenvModule.configDotenv(options);
142
- if (!result.parsed) {
143
- const err = /* @__PURE__ */ new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
144
- err.code = "MISSING_DATA";
145
- throw err;
146
- }
147
- const keys = _dotenvKey(options).split(",");
148
- const length = keys.length;
149
- let decrypted;
150
- for (let i = 0; i < length; i++) try {
151
- const attrs = _instructions(result, keys[i].trim());
152
- decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
153
- break;
154
- } catch (error) {
155
- if (i + 1 >= length) throw error;
156
- }
157
- return DotenvModule.parse(decrypted);
158
- }
159
- function _warn(message) {
160
- console.log(`[dotenv@${version}][WARN] ${message}`);
161
- }
162
- function _debug(message) {
163
- console.log(`[dotenv@${version}][DEBUG] ${message}`);
164
- }
165
- function _log(message) {
166
- console.log(`[dotenv@${version}] ${message}`);
167
- }
168
- function _dotenvKey(options) {
169
- if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) return options.DOTENV_KEY;
170
- if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) return process.env.DOTENV_KEY;
171
- return "";
172
- }
173
- function _instructions(result, dotenvKey) {
174
- let uri;
175
- try {
176
- uri = new URL(dotenvKey);
177
- } catch (error) {
178
- if (error.code === "ERR_INVALID_URL") {
179
- const err = /* @__PURE__ */ new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");
180
- err.code = "INVALID_DOTENV_KEY";
181
- throw err;
182
- }
183
- throw error;
184
- }
185
- const key = uri.password;
186
- if (!key) {
187
- const err = /* @__PURE__ */ new Error("INVALID_DOTENV_KEY: Missing key part");
188
- err.code = "INVALID_DOTENV_KEY";
189
- throw err;
190
- }
191
- const environment = uri.searchParams.get("environment");
192
- if (!environment) {
193
- const err = /* @__PURE__ */ new Error("INVALID_DOTENV_KEY: Missing environment part");
194
- err.code = "INVALID_DOTENV_KEY";
195
- throw err;
196
- }
197
- const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
198
- const ciphertext = result.parsed[environmentKey];
199
- if (!ciphertext) {
200
- const err = /* @__PURE__ */ new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
201
- err.code = "NOT_FOUND_DOTENV_ENVIRONMENT";
202
- throw err;
203
- }
204
- return {
205
- ciphertext,
206
- key
207
- };
208
- }
209
- function _vaultPath(options) {
210
- let possibleVaultPath = null;
211
- if (options && options.path && options.path.length > 0) if (Array.isArray(options.path)) {
212
- for (const filepath of options.path) if (fs$2.existsSync(filepath)) possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
213
- } else possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
214
- else possibleVaultPath = path$1.resolve(process.cwd(), ".env.vault");
215
- if (fs$2.existsSync(possibleVaultPath)) return possibleVaultPath;
216
- return null;
217
- }
218
- function _resolveHome(envPath) {
219
- return envPath[0] === "~" ? path$1.join(os.homedir(), envPath.slice(1)) : envPath;
220
- }
221
- function _configVault(options) {
222
- const debug = Boolean(options && options.debug);
223
- const quiet = options && "quiet" in options ? options.quiet : true;
224
- if (debug || !quiet) _log("Loading env from encrypted .env.vault");
225
- const parsed = DotenvModule._parseVault(options);
226
- let processEnv = process.env;
227
- if (options && options.processEnv != null) processEnv = options.processEnv;
228
- DotenvModule.populate(processEnv, parsed, options);
229
- return { parsed };
230
- }
231
- function configDotenv(options) {
232
- const dotenvPath = path$1.resolve(process.cwd(), ".env");
233
- let encoding = "utf8";
234
- const debug = Boolean(options && options.debug);
235
- const quiet = options && "quiet" in options ? options.quiet : true;
236
- if (options && options.encoding) encoding = options.encoding;
237
- else if (debug) _debug("No encoding is specified. UTF-8 is used by default");
238
- let optionPaths = [dotenvPath];
239
- if (options && options.path) if (!Array.isArray(options.path)) optionPaths = [_resolveHome(options.path)];
240
- else {
241
- optionPaths = [];
242
- for (const filepath of options.path) optionPaths.push(_resolveHome(filepath));
243
- }
244
- let lastError;
245
- const parsedAll = {};
246
- for (const path of optionPaths) try {
247
- const parsed = DotenvModule.parse(fs$2.readFileSync(path, { encoding }));
248
- DotenvModule.populate(parsedAll, parsed, options);
249
- } catch (e) {
250
- if (debug) _debug(`Failed to load ${path} ${e.message}`);
251
- lastError = e;
252
- }
253
- let processEnv = process.env;
254
- if (options && options.processEnv != null) processEnv = options.processEnv;
255
- DotenvModule.populate(processEnv, parsedAll, options);
256
- if (debug || !quiet) {
257
- const keysCount = Object.keys(parsedAll).length;
258
- const shortPaths = [];
259
- for (const filePath of optionPaths) try {
260
- const relative = path$1.relative(process.cwd(), filePath);
261
- shortPaths.push(relative);
262
- } catch (e) {
263
- if (debug) _debug(`Failed to load ${filePath} ${e.message}`);
264
- lastError = e;
265
- }
266
- _log(`injecting env (${keysCount}) from ${shortPaths.join(",")}`);
267
- }
268
- if (lastError) return {
269
- parsed: parsedAll,
270
- error: lastError
271
- };
272
- else return { parsed: parsedAll };
273
- }
274
- function config(options) {
275
- if (_dotenvKey(options).length === 0) return DotenvModule.configDotenv(options);
276
- const vaultPath = _vaultPath(options);
277
- if (!vaultPath) {
278
- _warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`);
279
- return DotenvModule.configDotenv(options);
280
- }
281
- return DotenvModule._configVault(options);
282
- }
283
- function decrypt(encrypted, keyStr) {
284
- const key = Buffer.from(keyStr.slice(-64), "hex");
285
- let ciphertext = Buffer.from(encrypted, "base64");
286
- const nonce = ciphertext.subarray(0, 12);
287
- const authTag = ciphertext.subarray(-16);
288
- ciphertext = ciphertext.subarray(12, -16);
289
- try {
290
- const aesgcm = crypto.createDecipheriv("aes-256-gcm", key, nonce);
291
- aesgcm.setAuthTag(authTag);
292
- return `${aesgcm.update(ciphertext)}${aesgcm.final()}`;
293
- } catch (error) {
294
- const isRange = error instanceof RangeError;
295
- const invalidKeyLength = error.message === "Invalid key length";
296
- const decryptionFailed = error.message === "Unsupported state or unable to authenticate data";
297
- if (isRange || invalidKeyLength) {
298
- const err = /* @__PURE__ */ new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");
299
- err.code = "INVALID_DOTENV_KEY";
300
- throw err;
301
- } else if (decryptionFailed) {
302
- const err = /* @__PURE__ */ new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");
303
- err.code = "DECRYPTION_FAILED";
304
- throw err;
305
- } else throw error;
306
- }
307
- }
308
- function populate(processEnv, parsed, options = {}) {
309
- const debug = Boolean(options && options.debug);
310
- const override = Boolean(options && options.override);
311
- if (typeof parsed !== "object") {
312
- const err = /* @__PURE__ */ new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
313
- err.code = "OBJECT_REQUIRED";
314
- throw err;
315
- }
316
- for (const key of Object.keys(parsed)) if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
317
- if (override === true) processEnv[key] = parsed[key];
318
- if (debug) if (override === true) _debug(`"${key}" is already defined and WAS overwritten`);
319
- else _debug(`"${key}" is already defined and was NOT overwritten`);
320
- } else processEnv[key] = parsed[key];
321
- }
322
- const DotenvModule = {
323
- configDotenv,
324
- _configVault,
325
- _parseVault,
326
- config,
327
- decrypt,
328
- parse,
329
- populate
330
- };
331
- module.exports.configDotenv = DotenvModule.configDotenv;
332
- module.exports._configVault = DotenvModule._configVault;
333
- module.exports._parseVault = DotenvModule._parseVault;
334
- module.exports.config = DotenvModule.config;
335
- module.exports.decrypt = DotenvModule.decrypt;
336
- module.exports.parse = DotenvModule.parse;
337
- module.exports.populate = DotenvModule.populate;
338
- module.exports = DotenvModule;
339
- }));
340
- //#endregion
341
- //#region ../../../node_modules/dotenv-flow/package.json
342
- var require_package = /* @__PURE__ */ __commonJSMin(((exports, module) => {
343
- module.exports = {
344
- "name": "dotenv-flow",
345
- "version": "4.1.0",
346
- "description": "Loads environment variables from `.env.[development|test|production][.local]` files",
347
- "keywords": [
348
- "dotenv",
349
- "node_env",
350
- "development",
351
- "test",
352
- "production",
353
- "local",
354
- "env",
355
- "environment",
356
- "variables"
357
- ],
358
- "homepage": "https://github.com/kerimdzhanov/dotenv-flow#readme",
359
- "repository": {
360
- "type": "git",
361
- "url": "git+https://github.com/kerimdzhanov/dotenv-flow.git"
362
- },
363
- "bugs": { "url": "https://github.com/kerimdzhanov/dotenv-flow/issues" },
364
- "main": "lib/dotenv-flow.js",
365
- "types": "lib/dotenv-flow.d.ts",
366
- "exports": {
367
- ".": "./lib/dotenv-flow.js",
368
- "./config": {
369
- "require": "./config.js",
370
- "node": "./config.js"
371
- },
372
- "./package.json": "./package.json"
373
- },
374
- "files": [
375
- "lib/cli-options.js",
376
- "lib/dotenv-flow.d.ts",
377
- "lib/env-options.js",
378
- "config.d.ts",
379
- "config.js"
380
- ],
381
- "dependencies": { "dotenv": "^16.0.0" },
382
- "devDependencies": {
383
- "@types/node": "^20.6.2",
384
- "chai": "^4.3.7",
385
- "conventional-changelog-cli": "^2.0.35",
386
- "mocha": "^10.2.0",
387
- "sinon": "^15.2.0",
388
- "sinon-chai": "^3.7.0",
389
- "tmp": "^0.2.1",
390
- "typescript": "^5.2.2"
391
- },
392
- "engines": { "node": ">= 12.0.0" },
393
- "scripts": {
394
- "test": "yarn run test:unit && yarn run test:integration && yarn run test:types",
395
- "test:unit": "mocha -r mocha.conf.js test/unit/*.spec.js",
396
- "test:integration": "mocha -r mocha.conf.js test/integration/*.spec.{m,}js",
397
- "test:types": "tsc",
398
- "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s"
399
- },
400
- "author": "Dan Kerimdzhanov",
401
- "license": "MIT"
402
- };
403
- }));
404
- (/* @__PURE__ */ __commonJSMin(((exports, module) => {
405
- const fs$1 = __require("fs");
406
- const p = __require("path");
407
- const dotenv = require_main();
408
- const { version } = require_package();
409
- const DEFAULT_PATTERN = ".env[.node_env][.local]";
410
- const LOCAL_PLACEHOLDER_REGEX = /\[(\W*\blocal\b\W*)]/g;
411
- const NODE_ENV_PLACEHOLDER_REGEX = /\[(\W*\b)node_env(\b\W*)]/g;
412
- /**
413
- * Compose a filename from a given `patten`.
414
- *
415
- * @param {string} pattern
416
- * @param {object} [options]
417
- * @param {boolean} [options.local]
418
- * @param {string} [options.node_env]
419
- * @return {string} filename
420
- */
421
- function composeFilename(pattern, options) {
422
- let filename = pattern;
423
- filename = filename.replace(LOCAL_PLACEHOLDER_REGEX, options && options.local ? "$1" : "");
424
- filename = filename.replace(NODE_ENV_PLACEHOLDER_REGEX, options && options.node_env ? `$1${options.node_env}$2` : "");
425
- return filename;
426
- }
427
- /**
428
- * Returns a list of existing `.env*` filenames depending on the given `options`.
429
- *
430
- * The resulting list is ordered by the env files'
431
- * variables overwriting priority from lowest to highest.
432
- *
433
- * This can also be referenced as "env files' environment cascade"
434
- * or "order of ascending priority."
435
- *
436
- * ⚠️ Note that the `.env.local` file is not listed for "test" environment,
437
- * since normally you expect tests to produce the same results for everyone.
438
- *
439
- * @param {object} [options] - `.env*` files listing options
440
- * @param {string} [options.node_env] - node environment (development/test/production/etc.)
441
- * @param {string} [options.path] - path to the working directory (default: `process.cwd()`)
442
- * @param {string} [options.pattern] - `.env*` files' naming convention pattern
443
- * (default: ".env[.node_env][.local]")
444
- * @param {boolean} [options.debug] - turn on debug messages
445
- * @return {string[]}
446
- */
447
- function listFiles(options = {}) {
448
- options.debug && debug("listing effective `.env*` files…");
449
- const { node_env, path = process.cwd(), pattern = DEFAULT_PATTERN } = options;
450
- const hasLocalPlaceholder = LOCAL_PLACEHOLDER_REGEX.test(pattern);
451
- const filenames = {};
452
- if (pattern === DEFAULT_PATTERN) filenames[".env.defaults"] = ".env.defaults";
453
- filenames[".env"] = composeFilename(pattern);
454
- if (hasLocalPlaceholder) {
455
- const envlocal = composeFilename(pattern, { local: true });
456
- if (node_env !== "test") filenames[".env.local"] = envlocal;
457
- else if (options.debug && fs$1.existsSync(p.resolve(path, envlocal))) debug("[!] note that `%s` is being skipped for \"test\" environment", envlocal);
458
- }
459
- if (node_env && NODE_ENV_PLACEHOLDER_REGEX.test(pattern)) {
460
- filenames[".env.node_env"] = composeFilename(pattern, { node_env });
461
- if (hasLocalPlaceholder) filenames[".env.node_env.local"] = composeFilename(pattern, {
462
- node_env,
463
- local: true
464
- });
465
- }
466
- return [
467
- ".env.defaults",
468
- ".env",
469
- ".env.local",
470
- ".env.node_env",
471
- ".env.node_env.local"
472
- ].reduce((list, basename) => {
473
- if (!filenames[basename]) return list;
474
- const filename = p.resolve(path, filenames[basename]);
475
- if (fs$1.existsSync(filename)) {
476
- options.debug && debug(">> %s", filename);
477
- list.push(filename);
478
- }
479
- return list;
480
- }, []);
481
- }
482
- /**
483
- * Parses a given file or a list of files.
484
- *
485
- * When a list of filenames is given, the files will be parsed and merged in the same order as given.
486
- *
487
- * @param {string|string[]} filenames - filename or a list of filenames to parse and merge
488
- * @param {{ encoding?: string, debug?: boolean }} [options] - parse options
489
- * @return {Object<string, string>} the resulting map of `{ env_var: value }` as an object
490
- */
491
- function parse(filenames, options = {}) {
492
- if (typeof filenames === "string") {
493
- options.debug && debug("parsing \"%s\"…", filenames);
494
- const parsed = dotenv.parse(fs$1.readFileSync(filenames, options.encoding && { encoding: options.encoding }));
495
- if (options.debug) Object.keys(parsed).forEach((varname) => debug(">> %s", varname));
496
- return parsed;
497
- }
498
- return filenames.reduce((result, filename) => {
499
- const parsed = parse(filename, options);
500
- if (options.debug) Object.keys(parsed).filter((varname) => result.hasOwnProperty(varname)).forEach((varname) => debug("`%s` is being overwritten by merge from \"%s\"", varname, filename));
501
- return Object.assign(result, parsed);
502
- }, {});
503
- }
504
- /**
505
- * Parses variables defined in given file(s) and assigns them to `process.env`.
506
- *
507
- * Variables that are already defined in `process.env` will not be overwritten,
508
- * thus giving a higher priority to environment variables predefined by the shell.
509
- *
510
- * If the loading is successful, an object with `parsed` property is returned.
511
- * The `parsed` property contains parsed variables' `key => value` pairs merged in order using
512
- * the "overwrite merge" strategy.
513
- *
514
- * If parsing fails for any of the given files, `process.env` is being left untouched,
515
- * and an object with `error` property is returned.
516
- * The `error` property, if present, references to the occurred error.
517
- *
518
- * @param {string|string[]} filenames - filename or a list of filenames to parse and merge
519
- * @param {object} [options] - file loading options
520
- * @param {string} [options.encoding="utf8"] - encoding of `.env*` files
521
- * @param {boolean} [options.debug=false] - turn on debug messages
522
- * @param {boolean} [options.silent=false] - suppress console errors and warnings
523
- * @return {{ error: Error } | { parsed: Object<string, string> }}
524
- */
525
- function load(filenames, options = {}) {
526
- try {
527
- const parsed = parse(filenames, {
528
- encoding: options.encoding,
529
- debug: options.debug
530
- });
531
- options.debug && debug("safe-merging parsed environment variables into `process.env`…");
532
- for (const varname of Object.keys(parsed)) if (!process.env.hasOwnProperty(varname)) {
533
- options.debug && debug(">> process.env.%s", varname);
534
- process.env[varname] = parsed[varname];
535
- } else if (options.debug && process.env[varname] !== parsed[varname]) debug("environment variable `%s` is predefined and not being overwritten", varname);
536
- return { parsed };
537
- } catch (error) {
538
- return failure(error, options);
539
- }
540
- }
541
- /**
542
- * Unload variables defined in a given file(s) from `process.env`.
543
- *
544
- * This function can gracefully resolve the following issue:
545
- *
546
- * In some cases, the original "dotenv" library can be used by one of the dependent npm modules.
547
- * It causes calling the original `dotenv.config()` that loads the `.env` file from your project before you can call `dotenv-flow.config()`.
548
- * Such cases break `.env*` files priority because the previously loaded environment variables are treated as shell-defined thus having a higher priority.
549
- *
550
- * Unloading the previously loaded `.env` file can be activated when using the `dotenv-flow.config()` with the `purge_dotenv` option set to `true`.
551
- *
552
- * @param {string|string[]} filenames - filename or a list of filenames to unload
553
- * @param {object} [options] - `fs.readFileSync` options
554
- */
555
- function unload(filenames, options = {}) {
556
- const parsed = parse(filenames, options);
557
- Object.keys(parsed).forEach((key) => {
558
- if (process.env[key] === parsed[key]) delete process.env[key];
559
- });
560
- }
561
- /**
562
- * Returns effective (computed) `node_env`.
563
- *
564
- * @param {object} [options]
565
- * @param {string} [options.node_env]
566
- * @param {string} [options.default_node_env]
567
- * @param {boolean} [options.debug]
568
- * @return {string|undefined} node_env
569
- */
570
- function getEffectiveNodeEnv(options = {}) {
571
- if (options.node_env) {
572
- options.debug && debug(`operating in "${options.node_env}" environment (set by \`options.node_env\`)`);
573
- return options.node_env;
574
- }
575
- if (process.env.NODE_ENV) {
576
- options.debug && debug(`operating in "${process.env.NODE_ENV}" environment (as per \`process.env.NODE_ENV\`)`);
577
- return process.env.NODE_ENV;
578
- }
579
- if (options.default_node_env) {
580
- options.debug && debug(`operating in "${options.default_node_env}" environment (taken from \`options.default_node_env\`)`);
581
- return options.default_node_env;
582
- }
583
- options.debug && debug("operating in \"no environment\" mode (no environment-related options are set)");
584
- }
585
- const CONFIG_OPTION_KEYS = [
586
- "node_env",
587
- "default_node_env",
588
- "path",
589
- "pattern",
590
- "files",
591
- "encoding",
592
- "purge_dotenv",
593
- "silent"
594
- ];
595
- /**
596
- * "dotenv-flow" initialization function (API entry point).
597
- *
598
- * Allows configuring dotenv-flow programmatically.
599
- *
600
- * @param {object} [options] - configuration options
601
- * @param {string} [options.node_env=process.env.NODE_ENV] - node environment (development/test/production/etc.)
602
- * @param {string} [options.default_node_env] - the default node environment
603
- * @param {string} [options.path=process.cwd()] - path to `.env*` files directory
604
- * @param {string} [options.pattern=".env[.node_env][.local]"] - `.env*` files' naming convention pattern
605
- * @param {string[]} [options.files] - an explicit list of `.env*` files to load (note that `options.[default_]node_env` and `options.pattern` are ignored in this case)
606
- * @param {string} [options.encoding="utf8"] - encoding of `.env*` files
607
- * @param {boolean} [options.purge_dotenv=false] - perform the `.env` file {@link unload}
608
- * @param {boolean} [options.debug=false] - turn on detailed logging to help debug why certain variables are not being set as you expect
609
- * @param {boolean} [options.silent=false] - suppress all kinds of warnings including ".env*" files' loading errors
610
- * @return {{ parsed?: object, error?: Error }} with a `parsed` key containing the loaded content or an `error` key with an error that is occurred
611
- */
612
- function config(options = {}) {
613
- if (options.debug) {
614
- debug("initializing…");
615
- CONFIG_OPTION_KEYS.filter((key) => key in options).forEach((key) => debug(`| options.${key} =`, options[key]));
616
- }
617
- const { path = process.cwd(), pattern = DEFAULT_PATTERN } = options;
618
- if (options.purge_dotenv) {
619
- options.debug && debug("`options.purge_dotenv` is enabled, unloading potentially pre-loaded `.env`…");
620
- const dotenvFile = p.resolve(path, ".env");
621
- try {
622
- fs$1.existsSync(dotenvFile) && unload(dotenvFile, { encoding: options.encoding });
623
- } catch (error) {
624
- !options.silent && warn("unloading failed: ", error);
625
- }
626
- }
627
- try {
628
- let filenames;
629
- if (options.files) {
630
- options.debug && debug("using explicit list of `.env*` files: %s…", options.files.join(", "));
631
- filenames = options.files.reduce((list, basename) => {
632
- const filename = p.resolve(path, basename);
633
- if (fs$1.existsSync(filename)) list.push(filename);
634
- else if (options.debug) debug(">> %s does not exist, skipping…", filename);
635
- return list;
636
- }, []);
637
- } else {
638
- const node_env = getEffectiveNodeEnv(options);
639
- filenames = listFiles({
640
- node_env,
641
- path,
642
- pattern,
643
- debug: options.debug
644
- });
645
- if (filenames.length === 0) {
646
- const _pattern = node_env ? pattern.replace(NODE_ENV_PLACEHOLDER_REGEX, `[$1${node_env}$2]`) : pattern;
647
- return failure(/* @__PURE__ */ new Error(`no ".env*" files matching pattern "${_pattern}" in "${path}" dir`), options);
648
- }
649
- }
650
- const result = load(filenames, {
651
- encoding: options.encoding,
652
- debug: options.debug,
653
- silent: options.silent
654
- });
655
- options.debug && debug("initialization completed.");
656
- return result;
657
- } catch (error) {
658
- return failure(error, options);
659
- }
660
- }
661
- function failure(error, options) {
662
- if (!options.silent) warn(`".env*" files loading failed: ${error.message || error}`);
663
- return { error };
664
- }
665
- function warn(message, error) {
666
- if (error) message += ": %s";
667
- console.warn(`[dotenv-flow@${version}]: ${message}`, error);
668
- }
669
- function debug(message, ...values) {
670
- console.debug(`[dotenv-flow@${version}]: ${message}`, ...values);
671
- }
672
- module.exports = {
673
- DEFAULT_PATTERN,
674
- listFiles,
675
- parse,
676
- load,
677
- unload,
678
- config
679
- };
680
- })))();
681
- /** Reads the process environment when called: every variable whose value is a string. The default for both `config` and `secrets`. */
682
- function environmentVariables() {
683
- return () => {
684
- const values = {};
685
- for (const [name, value] of Object.entries(process.env)) if (typeof value === "string") values[name] = value;
686
- return values;
687
- };
688
- }
689
- //#endregion
690
- //#region ../../0-framework/3-tooling/assemble/dist/index.mjs
691
- /**
692
- * A user-facing assembly failure, structured at origin (base-type rule 6):
693
- * a `CliStructuredError` whose code names which way assembly went wrong.
694
- * This package's second consumer is the programmatic deploy API, not just
695
- * the CLI — hosts branch on `error.code`, the CLI renders the envelope.
696
- */
697
- var AssembleError = class extends CliStructuredError {
698
- constructor(code, summary, options) {
699
- super(code, summary, options);
700
- }
701
- };
702
- /**
703
- * The registry route for one service's build: extension by
704
- * `build.extension`, node descriptor by `build.type`, kind must be "build".
705
- * The CLI's coverage validation reports the same misses earlier with the
706
- * config fix; these errors are the backstop for programmatic callers.
707
- */
708
- function buildDescriptorAssemble(config, node, address, cwd, report) {
709
- const { extension, type } = node.build;
710
- const extensionDescriptor = config.extensions.find((candidate) => candidate.id === extension);
711
- if (extensionDescriptor === void 0) throw new AssembleError("ASSEMBLE.EXTENSION_MISSING", `No extension "${extension}" is configured (needed by service "${node.name}"'s build).`, { fix: "Add it to `extensions` in the `composer` section of prisma.config.ts." });
712
- const nodeDescriptor = extensionDescriptor.nodes[type];
713
- if (nodeDescriptor === void 0) throw new AssembleError("ASSEMBLE.DESCRIPTOR_MISSING", `Extension "${extension}" has no descriptor for build type "${type}".`, { why: `Known types: ${Object.keys(extensionDescriptor.nodes).join(", ")}.` });
714
- if (nodeDescriptor.kind !== "build") throw new AssembleError("ASSEMBLE.DESCRIPTOR_KIND_MISMATCH", `Extension "${extension}"'s descriptor for type "${type}" is a "${nodeDescriptor.kind}" descriptor.`, { why: "Assembling a service build needs a \"build\" descriptor." });
715
- return nodeDescriptor.assemble({
716
- build: node.build,
717
- address,
718
- cwd,
719
- report
720
- });
721
- }
722
- /**
723
- * The dev server a service's build descriptor declares, or `undefined` when it
724
- * declares none — including when the registry route misses, which the
725
- * assemble that follows reports with its own pinned error.
726
- */
727
- async function buildDescriptorServe(config, node, address) {
728
- const { extension, type } = node.build;
729
- const nodeDescriptor = config.extensions.find((candidate) => candidate.id === extension)?.nodes[type];
730
- if (nodeDescriptor?.kind !== "build" || nodeDescriptor.serve === void 0) return void 0;
731
- try {
732
- return await nodeDescriptor.serve({
733
- build: node.build,
734
- address
735
- });
736
- } catch (error) {
737
- if (CliStructuredError.is(error)) throw error;
738
- throw new CliStructuredError("DEV.DEV_SERVER_UNAVAILABLE", `service "${address}" cannot run its dev server: ${error instanceof Error ? error.message : String(error)}`, {
739
- meta: { address },
740
- cause: error
741
- });
742
- }
743
- }
744
- async function assembleServices(graph, config, cwd, run, onEvent, options = {}) {
745
- const runAssembler = run ?? ((node, address, nodeCwd, report) => buildDescriptorAssemble(config, node, address, nodeCwd, report));
746
- const serviceNodes = graph.nodes.filter((n) => n.node.kind === "service");
747
- if (serviceNodes.length === 0) throw new AssembleError("ASSEMBLE.SERVICE_MISSING", "The loaded graph has no service to assemble.");
748
- const bundles = {};
749
- const devServers = {};
750
- for (const { id, node } of serviceNodes) {
751
- if (options.devServers === true) {
752
- const server = await buildDescriptorServe(config, node, id);
753
- if (server !== void 0) {
754
- devServers[id] = server;
755
- continue;
756
- }
757
- }
758
- onEvent?.({
759
- kind: "service-started",
760
- address: id
761
- });
762
- const data = {};
763
- let artifact;
764
- try {
765
- artifact = await runAssembler(node, id, cwd, (reported) => Object.assign(data, reported));
766
- } catch (error) {
767
- if (CliStructuredError.is(error)) throw error;
768
- throw new AssembleError("ASSEMBLE.BUILD_FAILED", error instanceof Error ? error.message : String(error), {
769
- meta: { address: id },
770
- cause: error
771
- });
772
- }
773
- bundles[id] = artifact;
774
- onEvent?.({
775
- kind: "service-assembled",
776
- address: id,
777
- data
778
- });
779
- }
780
- return {
781
- bundles,
782
- devServers
783
- };
784
- }
785
- //#endregion
786
- //#region ../../0-framework/0-foundation/foundation/dist/pointer-Cw3E-nrh.mjs
787
- /** A pointer: what a value known only at boot holds at deploy. It names the platform variable the service reads at boot, and records whether that variable holds a secret. */
23
+ //#region ../../0-framework/0-foundation/foundation/dist/pointer-B3LgR6R4.mjs
24
+ /** A pointer: what a value known only at boot holds at deploy. It names the variable on the platform that the service reads at boot, and records whether that variable holds a secret. */
788
25
  const POINTER = blindCast(Symbol.for("prisma:pointer"));
789
26
  function kindOf(value) {
790
27
  if (typeof value !== "object" || value === null) return void 0;
@@ -806,13 +43,14 @@ function isSecretString(value) {
806
43
  return typeof value === "object" && value !== null && blindCast(value)[SECRET_BOX] === true;
807
44
  }
808
45
  //#endregion
809
- //#region ../../0-framework/1-core/core/dist/graph-CBt9CRBT.mjs
46
+ //#region ../../0-framework/1-core/core/dist/graph-D2WMLL43.mjs
810
47
  /** The reserved name of a resource's single anonymous output port. Rejected as a user-declared port name (node.ts). */
811
48
  const RESOURCE_OUT_PORT = "$out";
812
49
  /**
813
50
  * Thrown by Load when the graph is malformed. Structured at origin
814
- * (base-type rule 6): one type-level code covers every raise site until a
815
- * finer per-site taxonomy is carved out. The `name` stays
51
+ * (base-type rule 6) under one type-level code. Not every error Load throws
52
+ * is one: a Load that needs a root input field an earlier Load did not read
53
+ * throws an error whose name is the value of `ROOT_INPUT_UNREAD_ERROR`. The `name` stays
816
54
  * `CliStructuredError` — structural recognition depends on it.
817
55
  */
818
56
  var LoadError = class extends CliStructuredError {
@@ -820,6 +58,12 @@ var LoadError = class extends CliStructuredError {
820
58
  super("COMPOSE.GRAPH_INVALID", message, options);
821
59
  }
822
60
  };
61
+ /** What an extension's `checkGraph` throws to refuse a graph it cannot deploy. Any other throw from the hook is a bug (ADR-0044). The CLI adds the refusing extension's id as `meta.extension`. */
62
+ var GraphCheckError = class extends CliStructuredError {
63
+ constructor(message, options) {
64
+ super("COMPOSE.GRAPH_INVALID", message, options?.extension === void 0 ? void 0 : { meta: { extension: options.extension } });
65
+ }
66
+ };
823
67
  /** The declared style of an untrusted contract value, or `undefined` when it declares none. */
824
68
  function contractStyleOf(contract) {
825
69
  if (typeof contract !== "object" || contract === null || !("style" in contract)) return void 0;
@@ -827,6 +71,7 @@ function contractStyleOf(contract) {
827
71
  }
828
72
  const VALUE = blindCast(Symbol.for("prisma:value"));
829
73
  const VALUE_ORIGIN = blindCast(Symbol.for("prisma:value-origin"));
74
+ const VALUE_RESOURCE = blindCast(Symbol.for("prisma:value-resource"));
830
75
  /** True if `value` is a `Value`, a source included (checks the brand only, never a prototype). */
831
76
  function isValue(value) {
832
77
  return typeof value === "object" && value !== null && blindCast(value)[VALUE] === true;
@@ -947,13 +192,47 @@ function buildModuleInput(moduleAddress) {
947
192
  */
948
193
  const NODE = Symbol.for("prisma:node");
949
194
  const SECRET_SOURCE = blindCast(Symbol.for("prisma:secret-source"));
950
- /** True if `value` is a secret source, such as an `envSecret()` result. */
195
+ /** True if `value` is a secret source. */
951
196
  function isSecretSource(value) {
952
197
  return typeof value === "object" && value !== null && blindCast(value)[SECRET_SOURCE] === true;
953
198
  }
954
199
  blindCast(Symbol.for("prisma:provision-need"));
955
200
  const PARAM_SOURCE = blindCast(Symbol.for("prisma:param-source"));
201
+ function buildSource(brand, payload, origin, kind, hidden = {}) {
202
+ const source = {
203
+ [VALUE]: true,
204
+ [VALUE_ORIGIN]: origin,
205
+ [brand]: true,
206
+ [POINTER]: kind,
207
+ payload
208
+ };
209
+ Object.defineProperty(origin, "source", { value: source });
210
+ Object.defineProperties(source, {
211
+ ...coercions(origin),
212
+ ...hidden
213
+ });
214
+ Object.freeze(origin);
215
+ return Object.freeze(source);
216
+ }
217
+ function coercions(origin) {
218
+ const thrower = (what) => () => {
219
+ throw sourceMisuse(origin, what);
220
+ };
221
+ return {
222
+ toString: { value: thrower("its toString() was called") },
223
+ valueOf: { value: thrower("its valueOf() was called") },
224
+ [Symbol.toPrimitive]: { value: (hint) => {
225
+ throw sourceMisuse(origin, primitiveMisuse(hint));
226
+ } }
227
+ };
228
+ }
956
229
  const sourceMisuses = /* @__PURE__ */ new WeakSet();
230
+ function sourceMisuse(origin, what) {
231
+ const { label } = origin;
232
+ const error = new LoadError(`${label} is known only at boot: the deploy holds a pointer to it, never its value, and ${what}. A module body can only pass it on, into a provision() binding; to compute with the value, do it in the service that reads it.`);
233
+ sourceMisuses.add(error);
234
+ return error;
235
+ }
957
236
  /** True for the error a source throws when code turns it into text or a number. Internal to core. */
958
237
  function isSourceMisuse(error) {
959
238
  return error instanceof LoadError && sourceMisuses.has(error);
@@ -964,7 +243,7 @@ function sourceOriginOf(source) {
964
243
  const origin = originOf(source);
965
244
  return origin.kind === "source" ? origin : void 0;
966
245
  }
967
- /** True if `value` is a param source, such as an `envParam()` result. */
246
+ /** True if `value` is a param source. */
968
247
  function isParamSource(value) {
969
248
  return typeof value === "object" && value !== null && blindCast(value)[PARAM_SOURCE] === true;
970
249
  }
@@ -977,6 +256,18 @@ function isParamSource(value) {
977
256
  function isConfigKeySegment(name) {
978
257
  return /^[A-Za-z0-9]+$/.test(name);
979
258
  }
259
+ function valueResourceOrigin(node) {
260
+ if (!isNode(node) || node.kind !== "resource" || !(VALUE_RESOURCE in node)) return void 0;
261
+ const value = node[VALUE_RESOURCE];
262
+ return isSecretSource(value) || isParamSource(value) ? sourceOriginOf(value) : void 0;
263
+ }
264
+ function provisionedValue(origin, address) {
265
+ const { source, ...kept } = origin;
266
+ return blindCast(buildSource(isSecretSource(source) ? SECRET_SOURCE : PARAM_SOURCE, source.payload, {
267
+ ...kept,
268
+ resource: address
269
+ }, isSecretPointer(source) ? "secret" : "plain", { id: { value: address } }));
270
+ }
980
271
  /**
981
272
  * True if `value` was constructed by this module's factories. Checks the
982
273
  * brand only, never a prototype — a graph may mix nodes from a different
@@ -1118,10 +409,8 @@ function loadService(root, rootId) {
1118
409
  inputBindings: [],
1119
410
  params: [],
1120
411
  secretSources: [],
1121
- appConfigurationRead: {
1122
- rootInput: [],
1123
- configurationKeyText: {}
1124
- }
412
+ valueReads: [],
413
+ appConfigurationRead: { rootInput: [] }
1125
414
  };
1126
415
  }
1127
416
  function joinPath(path, key) {
@@ -1196,6 +485,14 @@ function jsonInexactKind(value) {
1196
485
  }
1197
486
  return describeNotPlain(value) ?? describeKind(value);
1198
487
  }
488
+ /** The `name` of the error a Load that takes what an earlier Load read fails with when it needs a root input field that Load did not read. */
489
+ const ROOT_INPUT_UNREAD_ERROR = "RootInputUnreadError";
490
+ var RootInputUnreadError = class extends Error {
491
+ constructor(message) {
492
+ super(message);
493
+ this.name = ROOT_INPUT_UNREAD_ERROR;
494
+ }
495
+ };
1199
496
  const SAME_GRAPH_ADVICE = "A module body must build the same graph every time; one that reads the process environment, a file or the clock can build a different one.";
1200
497
  function isThenable(value) {
1201
498
  if (isValue(value)) return false;
@@ -1235,7 +532,7 @@ function checkResult(result, fnLabel) {
1235
532
  const walk = (value, path) => {
1236
533
  const atPath = path === "" ? "" : ` at "${path}"`;
1237
534
  if (value === void 0) throw new LoadError(`${fnLabel} returned undefined${atPath}. Return a result for every environment; Composer never picks a default.`);
1238
- if (isSecretSource(value) || isParamSource(value)) throw new LoadError(`${fnLabel} returned a source${atPath}, such as envSecret() or envParam() called inside the function. resolve() returns plain data; bind a source directly.`);
535
+ if (isSecretSource(value) || isParamSource(value)) throw new LoadError(`${fnLabel} returned a source${atPath}, a value known only at boot. resolve() returns plain data; bind the source directly.`);
1239
536
  if (isValue(value)) throw new LoadError(`${fnLabel} returned a value${atPath}, not a real value. List that value as a dependency; fn receives its real value.`);
1240
537
  const notPlain = describeNotPlain(value);
1241
538
  if (notPlain !== void 0) throw new LoadError(`${fnLabel} returned ${notPlain}${atPath}. resolve() returns plain data: strings, finite numbers, booleans, null, arrays and plain objects.`);
@@ -1265,7 +562,7 @@ function firstPointer(value, path = [], seen = /* @__PURE__ */ new WeakSet()) {
1265
562
  function refusePointerDependency(fnLabel, dependency, real) {
1266
563
  const found = firstPointer(real);
1267
564
  if (found === void 0) return;
1268
- const label = sourceOriginOf(found.pointer)?.label ?? "a value known only at boot";
565
+ const label = sourceOriginOf(found.pointer)?.label ?? "a source";
1269
566
  const origin = originOf(dependency);
1270
567
  if (origin.kind !== "input") throw new LoadError(`${fnLabel} lists ${label}, which is known only at boot. A resolve() dependency must be a deploy-time value. Bind ${label} directly into the input of the service that reads it.`);
1271
568
  const listed = `${inputFieldLabel(origin)} of module "${origin.module}"`;
@@ -1336,7 +633,7 @@ function refuseSecretBoxes(address, value, path) {
1336
633
  address,
1337
634
  kind: "moduleInput",
1338
635
  path
1339
- })} 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().`);
636
+ })} is bound to a SecretString. A secret's value never appears in the code; bind a secret source, or pass on an input field typed secretString().`);
1340
637
  if (Array.isArray(value)) {
1341
638
  for (const [index, member] of value.entries()) refuseSecretBoxes(address, member, joinPath(path, index));
1342
639
  return;
@@ -1344,10 +641,17 @@ function refuseSecretBoxes(address, value, path) {
1344
641
  if (isPlainObject(value)) for (const [key, member] of Object.entries(value)) refuseSecretBoxes(address, member, joinPath(path, key));
1345
642
  }
1346
643
  /** The original source each runtime value in `value` names, by its path. */
1347
- function sourcesByPath(value, path = "", found = /* @__PURE__ */ new Map()) {
1348
- if (isSecretSource(value) || isParamSource(value)) found.set(path, sourceOriginOf(value)?.source ?? value);
1349
- else if (Array.isArray(value)) for (const [index, member] of value.entries()) sourcesByPath(member, joinPath(path, index), found);
1350
- else if (isPlainObject(value)) for (const [key, member] of Object.entries(value)) sourcesByPath(member, joinPath(path, key), found);
644
+ function sourcesByPath(value, path = "", found = /* @__PURE__ */ new Map(), ancestors = /* @__PURE__ */ new Set()) {
645
+ if (isSecretSource(value) || isParamSource(value)) {
646
+ found.set(path, sourceOriginOf(value)?.source ?? value);
647
+ return found;
648
+ }
649
+ if (!Array.isArray(value) && !isPlainObject(value)) return found;
650
+ if (ancestors.has(value)) return found;
651
+ ancestors.add(value);
652
+ const entries = Array.isArray(value) ? value.map((member, index) => [index, member]) : Object.entries(value);
653
+ for (const [key, member] of entries) sourcesByPath(member, joinPath(path, key), found, ancestors);
654
+ ancestors.delete(value);
1351
655
  return found;
1352
656
  }
1353
657
  function validateModuleInput(entry, resolved, environment) {
@@ -1380,11 +684,18 @@ function validateModuleInput(entry, resolved, environment) {
1380
684
  };
1381
685
  return restore(result.value, "");
1382
686
  }
687
+ function refuseSourcesInParams(params) {
688
+ for (const { serviceAddress, slot, binding } of params) {
689
+ const [source] = pointersIn(binding);
690
+ if (source === void 0) continue;
691
+ throw new LoadError(`Service "${serviceAddress}" binds its param "${slot}" to ${sourceOriginOf(source)?.label ?? "a source"}, a value known only at boot. A param takes a literal or a value the deploy has. Bind the value to a field of the service's input instead.`);
692
+ }
693
+ }
1383
694
  function refusePointersInProps(address, props) {
1384
695
  const seen = /* @__PURE__ */ new WeakSet();
1385
696
  const walk = (value, path) => {
1386
697
  if (isSecretSource(value) || isParamSource(value)) {
1387
- const label = sourceOriginOf(value)?.label ?? (isSecretSource(value) ? "a secret source" : "a param source");
698
+ const label = sourceOriginOf(value)?.label ?? "a source";
1388
699
  throw new LoadError(`${describeSite({
1389
700
  address,
1390
701
  kind: "props",
@@ -1406,22 +717,12 @@ function refusePointersInProps(address, props) {
1406
717
  function resolveValues(input) {
1407
718
  const { environment } = input;
1408
719
  const rootFields = /* @__PURE__ */ new Map();
1409
- const keysRead = /* @__PURE__ */ new Map();
1410
- /** The text the app configuration holds for `key`, recorded; `undefined` when it holds none or `''`. */
1411
- const configurationText = (key, label, site) => {
1412
- let raw;
1413
- if (input.appConfigurationRead !== void 0) raw = input.appConfigurationRead.configurationKeyText[key];
1414
- else if (input.configuration !== void 0) raw = input.configuration[key];
1415
- else throw new LoadError(`${describeSite(site)} depends on ${label}, but Load was given no app configuration to read "${key}" from. Pass { configuration } to Load; the deploy and dev commands pass the values the \`config\` adapters return.`);
1416
- if (raw !== void 0 && raw !== "" && typeof raw !== "string") throw new LoadError(`${describeSite(site)} depends on ${label}, which reads "${key}" from the values the \`config\` adapters return, but they return ${describeKind(raw)} for it, not text. ${label} reads text; to pass other data, declare it in the root module's input.`);
1417
- const text = raw === void 0 || raw === "" ? void 0 : raw;
1418
- keysRead.set(key, {
1419
- label,
1420
- text
1421
- });
1422
- return text;
1423
- };
1424
720
  const secretUses = /* @__PURE__ */ new Map();
721
+ for (const [address, value] of input.valueResources) if (isSecretSource(value)) secretUses.set(value, {
722
+ source: value,
723
+ address,
724
+ nodeKind: "resource"
725
+ });
1425
726
  const recordSecret = (source, site) => {
1426
727
  const canonical = canonicalSecret(source);
1427
728
  if (secretUses.has(canonical)) return;
@@ -1431,8 +732,8 @@ function resolveValues(input) {
1431
732
  nodeKind: nodeKindOf(site)
1432
733
  });
1433
734
  };
1434
- const secretSourcesReceivedBy = (inputBindings, params) => {
1435
- for (const { serviceAddress, binding } of [...inputBindings, ...params]) for (const pointer of pointersIn(binding)) {
735
+ const secretSourcesReceivedBy = (inputBindings) => {
736
+ for (const { serviceAddress, binding } of inputBindings) for (const pointer of pointersIn(binding)) {
1436
737
  if (!isSecretSource(pointer)) continue;
1437
738
  const canonical = canonicalSecret(pointer);
1438
739
  if (secretUses.get(canonical)?.nodeKind === "service") continue;
@@ -1482,14 +783,11 @@ function resolveValues(input) {
1482
783
  break;
1483
784
  case "source":
1484
785
  if (isSecretSource(origin.source)) recordSecret(origin.source, site);
1485
- if (origin.sourceKind === "secret" || origin.configurationKey === void 0) result = origin.source;
1486
- else result = configurationText(origin.configurationKey, origin.label, site);
786
+ result = origin.source;
1487
787
  break;
1488
788
  case "computed": {
1489
789
  const args = origin.dependencies.map((dependency) => {
1490
790
  const real = resolveOne(dependency, site);
1491
- const source = originOf(dependency);
1492
- if (real === void 0 && source.kind === "source" && source.sourceKind === "param") throw new LoadError(`${fnLabelFor(site)} lists ${source.label}, but "${source.configurationKey}" is unset or empty, so it has no real value. Set "${source.configurationKey}", or bind ${source.label} directly into an input binding, where an absent value leaves the key out and the schema decides.`);
1493
791
  refusePointerDependency(fnLabelFor(site), dependency, real);
1494
792
  return real;
1495
793
  });
@@ -1512,7 +810,7 @@ function resolveValues(input) {
1512
810
  }
1513
811
  if (entry.checked !== void 0) {
1514
812
  const field = entry.checked.find((candidate) => candidate.path.join("\0") === origin.path.join("\0"));
1515
- if (field === void 0) throw new LoadError(`${inputFieldLabel(origin)} of root module "${origin.module}" is not in the app configuration file. The first process's root body did not pass it on, so the deploy's two processes built different graphs. ${SAME_GRAPH_ADVICE}`);
813
+ if (field === void 0) throw new RootInputUnreadError(`${inputFieldLabel(origin)} of root module "${origin.module}" was not read when this command started, so it has no value here. ${SAME_GRAPH_ADVICE}`);
1516
814
  result = field.value;
1517
815
  } else {
1518
816
  result = readPath(validatedInputOf(entry), origin);
@@ -1547,41 +845,17 @@ function resolveValues(input) {
1547
845
  return validated;
1548
846
  };
1549
847
  const rootModuleAddress = () => input.moduleInputs.find((entry) => entry.isLoadRoot)?.moduleAddress ?? "";
1550
- const appConfigurationReadOf = (inputBindings, params, secretSources) => {
1551
- if (input.configuration !== void 0 || input.appConfigurationRead !== void 0) {
1552
- const kept = [...inputBindings.map(({ serviceAddress, binding }) => ({
1553
- binding,
1554
- site: {
1555
- address: serviceAddress,
1556
- kind: "serviceInput",
1557
- path: ""
1558
- }
1559
- })), ...params.map(({ serviceAddress, slot, binding }) => ({
1560
- binding,
1561
- site: {
1562
- address: serviceAddress,
1563
- kind: "param",
1564
- path: slot
1565
- }
1566
- }))];
1567
- for (const { binding, site } of kept) for (const pointer of pointersIn(binding)) {
1568
- if (!isParamSource(pointer)) continue;
1569
- const origin = sourceOriginOf(pointer);
1570
- if (origin?.sourceKind === "param" && origin.configurationKey !== void 0) configurationText(origin.configurationKey, origin.label, site);
1571
- }
1572
- }
848
+ const appConfigurationReadOf = (secretSources) => {
1573
849
  for (const use of secretSources) {
1574
850
  const origin = sourceOriginOf(use.source);
1575
851
  if (origin?.sourceKind !== "secret") continue;
1576
852
  const key = origin.secretsKey;
1577
- const read = key === void 0 ? void 0 : keysRead.get(key);
1578
- if (key !== void 0 && read !== void 0) throw new LoadError(`${read.label} reads "${key}" from the app configuration, and ${origin.label} names "${key}" as a secret. A name is a plain value or a secret, not both: Composer hands the deploy's second process every plain value it reads, in a file, and never writes a secret to a file. Give the plain value and the secret different names.`);
1579
853
  const field = [...rootFields.values()].find((candidate) => candidate.path[0] === key);
1580
854
  if (key !== void 0 && field !== void 0) throw new LoadError(`${inputFieldLabel({
1581
855
  kind: "input",
1582
856
  module: rootModuleAddress(),
1583
857
  path: field.path
1584
- })} of root module "${rootModuleAddress()}" reads "${key}" from the app configuration, and ${origin.label} names "${key}" as a secret. A name is a plain value or a secret, not both: Composer hands the deploy's second process every root input field the root's body passes on, in a file, and never writes a secret to a file. Read the secret with ${origin.label} only, or give the plain value a different name.`);
858
+ })} of root module "${rootModuleAddress()}" reads "${key}" from the app configuration, and ${origin.label} names "${key}" as a secret. A name is a plain value or a secret, not both: a root input field is a plain value, which \`prisma deploy\` sends to the platform as plain configuration, \`prisma dev\` gives to the local services as plain configuration, and \`destroy\` writes to a file. Read the secret with ${origin.label} only, or give the plain value a different name.`);
1585
859
  }
1586
860
  for (const field of rootFields.values()) {
1587
861
  const kind = "value" in field ? jsonInexactKind(field.value) : void 0;
@@ -1589,27 +863,23 @@ function resolveValues(input) {
1589
863
  kind: "input",
1590
864
  module: rootModuleAddress(),
1591
865
  path: field.path
1592
- })} of root module "${rootModuleAddress()}" holds ${kind}, which JSON cannot hold exactly. The deploy hands the root's input to its second process in a JSON file, so a field the root's body passes on must hold text, a finite number, a boolean, null, or arrays and plain objects of these.`);
866
+ })} of root module "${rootModuleAddress()}" holds ${kind}, which JSON cannot hold exactly. \`destroy\` hands the root's input to its second process in a JSON file, so a field the root's body passes on must hold text, a finite number, a boolean, null, or arrays and plain objects of these.`);
1593
867
  }
1594
- const configurationKeyText = {};
1595
- for (const [key, { text }] of keysRead) if (text !== void 0) configurationKeyText[key] = text;
1596
- return {
1597
- rootInput: [...rootFields.values()],
1598
- configurationKeyText
1599
- };
868
+ return { rootInput: [...rootFields.values()] };
1600
869
  };
1601
870
  for (const entry of input.moduleInputs) validatedInputOf(entry);
1602
871
  for (const { value, site } of found) resolveOne(value, site);
1603
872
  const authoredProps = new Map([...input.resources].map(([address, resource]) => [address, resource.props]));
1604
873
  if (found.length === 0) {
1605
874
  for (const [address, props] of authoredProps) refusePointersInProps(address, props);
1606
- const secretSources = secretSourcesReceivedBy(input.inputBindings, input.params);
875
+ refuseSourcesInParams(input.params);
876
+ const secretSources = secretSourcesReceivedBy(input.inputBindings);
1607
877
  return {
1608
878
  inputBindings: input.inputBindings,
1609
879
  params: input.params,
1610
880
  resourceProps: authoredProps,
1611
881
  secretSources,
1612
- appConfigurationRead: appConfigurationReadOf(input.inputBindings, input.params, secretSources)
882
+ appConfigurationRead: appConfigurationReadOf(secretSources)
1613
883
  };
1614
884
  }
1615
885
  const inProgress = /* @__PURE__ */ new WeakSet();
@@ -1635,15 +905,28 @@ function resolveValues(input) {
1635
905
  binding
1636
906
  }];
1637
907
  });
1638
- const secretSources = secretSourcesReceivedBy(inputBindings, params);
908
+ refuseSourcesInParams(params);
909
+ const secretSources = secretSourcesReceivedBy(inputBindings);
1639
910
  return {
1640
911
  resourceProps,
1641
912
  inputBindings,
1642
913
  params,
1643
914
  secretSources,
1644
- appConfigurationRead: appConfigurationReadOf(inputBindings, params, secretSources)
915
+ appConfigurationRead: appConfigurationReadOf(secretSources)
1645
916
  };
1646
917
  }
918
+ function valueReadsOf(inputBindings) {
919
+ const reads = [];
920
+ for (const { serviceAddress, binding } of inputBindings) for (const [path, source] of sourcesByPath(binding)) {
921
+ const resource = sourceOriginOf(source)?.resource;
922
+ if (resource !== void 0) reads.push({
923
+ reader: serviceAddress,
924
+ resource,
925
+ path
926
+ });
927
+ }
928
+ return reads;
929
+ }
1647
930
  /**
1648
931
  * Brands a ref-port with the AUTHORED endpoint it stands for — which port of
1649
932
  * which node the author wired, before any forwarding chain resolves. Read
@@ -1715,6 +998,9 @@ function producerIdOf(ref) {
1715
998
  * identity the branding copy creates, never on reading this back.
1716
999
  */
1717
1000
  const MODULE_INPUT_KEY = Symbol("prisma:module-input-key");
1001
+ function describeNode(node) {
1002
+ return valueResourceOrigin(node)?.label ?? `${node.kind} "${node.name}"`;
1003
+ }
1718
1004
  /** Whether `ref` carries a callable `satisfies` that accepts `required` truthily. */
1719
1005
  function satisfiesRequired(ref, required) {
1720
1006
  return typeof ref === "object" && ref !== null && "satisfies" in ref && typeof ref.satisfies === "function" && ref.satisfies(required);
@@ -1784,9 +1070,9 @@ function validateServiceParamBinding(child, id, paramWiring, enclosingModuleName
1784
1070
  * children carry it as their `parent`, and this module's own boundary ports
1785
1071
  * (and the authored edges touching them) are recorded against it.
1786
1072
  */
1787
- function flatten(moduleNode, selfId, wiring, nodes, edges, pending, inputBindings, paramBindings, moduleInputs, byId, ports, authoredEdges, loading) {
1073
+ function flatten(moduleNode, selfId, wiring, nodes, edges, pending, inputBindings, paramBindings, moduleInputs, byId, valueResources, ports, authoredEdges, loading) {
1788
1074
  ports.push(...boundaryPortsOf(selfId, moduleNode));
1789
- const localIds = /* @__PURE__ */ new Set();
1075
+ const localNodes = /* @__PURE__ */ new Map();
1790
1076
  const used = /* @__PURE__ */ new Set();
1791
1077
  const ctxInputs = {};
1792
1078
  for (const key of Object.keys(moduleNode.deps)) {
@@ -1836,13 +1122,20 @@ function flatten(moduleNode, selfId, wiring, nodes, edges, pending, inputBinding
1836
1122
  if (isValue(id)) throw new LoadError(`provision() received a value as its id (module "${moduleNode.name}"). A value can configure a node, never decide its address: the graph is the same whatever inputs Composer is given (ADR-0062).`);
1837
1123
  if (typeof id !== "string" || id.length === 0) throw new LoadError(`provision() requires a non-empty id (module "${moduleNode.name}").`);
1838
1124
  if (!isConfigKeySegment(id)) throw new LoadError(`provision() id "${id}" (module "${moduleNode.name}") must contain only ASCII letters and digits ([A-Za-z0-9]) — the id becomes an address segment, and addresses derive deterministic config keys (segments uppercased and joined with "_"). "${id}" would put "${id.toUpperCase()}" inside the derived key. ("_" collides with the key separator and "." with the address separator.)`);
1839
- if (localIds.has(id)) throw new LoadError(`Duplicate provision id "${id}" in module "${moduleNode.name}".`);
1125
+ const fullAddress = `${selfId}.${id}`;
1840
1126
  const untrusted = child;
1841
1127
  if (!isNode(untrusted) || untrusted.kind !== "service" && untrusted.kind !== "resource" && untrusted.kind !== "module") throw new LoadError(`provision("${id}") expects a branded service, resource, or module node (construct it with the service()/resource()/module() factories or a pack's own).`);
1842
1128
  if (untrusted.kind === "module" && typeof untrusted.isRoot === "function" && untrusted.isRoot()) throw new LoadError(`Module "${selfId}" provisions the app root "${untrusted.name}". An app root is the deploy's entry and cannot be provisioned. Build the module with module() instead.`);
1843
- localIds.add(id);
1844
- const fullAddress = `${selfId}.${id}`;
1129
+ const holder = localNodes.get(id);
1130
+ if (holder !== void 0) throw new LoadError(`Duplicate provision id "${id}" in module "${selfId}": "${fullAddress}" already holds ${describeNode(holder)}, and ${describeNode(child)} takes the same id. Give one of them a different id with provision(node, { id: '…' }).`);
1131
+ localNodes.set(id, child);
1845
1132
  if (child.kind === "resource") {
1133
+ const valueOrigin = valueResourceOrigin(child);
1134
+ if (valueOrigin !== void 0) {
1135
+ if (typeof moduleNode.isRoot !== "function" || !moduleNode.isRoot()) throw new LoadError(`Module "${selfId}" provisions "${id}", a resource that is a value. Only the app root, built with appRoot(), can provision one. Provision it in the root and pass its value down through this module's input.`);
1136
+ const also = child.provides !== void 0 ? "provides a contract" : Object.keys(slotsOf(child)).length > 0 ? "declares dependency slots" : void 0;
1137
+ if (also !== void 0) throw new LoadError(`Resource "${fullAddress}" is a value and also ${also}. A resource that is a value provides no contract and has no dependencies.`);
1138
+ }
1846
1139
  if (provisionWiring !== void 0) throw new LoadError(`provision("${id}") received deps for a resource — a resource's slots are wired when it is constructed, not at provision().`);
1847
1140
  if (provisionSecrets !== void 0) throw new LoadError(`provision("${id}") received secrets for a resource — a resource has no secret slots to satisfy.`);
1848
1141
  if (provisionInput !== void 0) throw new LoadError(`provision("${id}") received an input binding for a resource — a resource declares no input schema.`);
@@ -1875,6 +1168,11 @@ function flatten(moduleNode, selfId, wiring, nodes, edges, pending, inputBinding
1875
1168
  targetKind: "resource",
1876
1169
  enclosingModuleName: moduleNode.name
1877
1170
  });
1171
+ if (valueOrigin !== void 0) {
1172
+ const value = provisionedValue(valueOrigin, fullAddress);
1173
+ valueResources.set(fullAddress, value);
1174
+ return value;
1175
+ }
1878
1176
  return refForResource(fullAddress, child);
1879
1177
  }
1880
1178
  for (const [input, ref] of Object.entries(provisionWiring ?? {})) if (isValue(ref)) throw new LoadError(`The deps for "${fullAddress}.${input}" are bound to a value. A value can configure a node, never decide its edges: the graph is the same whatever inputs Composer is given (ADR-0062).`);
@@ -1882,7 +1180,7 @@ function flatten(moduleNode, selfId, wiring, nodes, edges, pending, inputBinding
1882
1180
  markUsed(Object.values(localWiring));
1883
1181
  const localParams = { ...provisionParams ?? {} };
1884
1182
  if (child.kind === "service") {
1885
- if (provisionSecrets !== void 0) throw new LoadError(`provision("${id}") received secrets for a service — a service takes its secrets as envSecret(...) leaves of its \`input\` binding (ADR-0042), not a secrets map.`);
1183
+ if (provisionSecrets !== void 0) throw new LoadError(`provision("${id}") received secrets for a service — a service takes its secrets as values bound to secretString() fields of its \`input\` binding, not a secrets map.`);
1886
1184
  if (child.inputSchema !== void 0 && provisionInput === void 0) throw new LoadError(`Input of provisioned service "${id}" is not bound (module "${moduleNode.name}") — the service declares an input schema; bind it with \`input: { … }\` on its provision() call.`);
1887
1185
  if (child.inputSchema === void 0 && provisionInput !== void 0) throw new LoadError(`provision("${id}") received an input binding, but the service declares no input schema (module "${moduleNode.name}").`);
1888
1186
  if (provisionInput !== void 0) inputBindings.push({
@@ -1934,7 +1232,7 @@ function flatten(moduleNode, selfId, wiring, nodes, edges, pending, inputBinding
1934
1232
  targetKind: "module",
1935
1233
  enclosingModuleName: moduleNode.name
1936
1234
  });
1937
- const childOutputs = flatten(child, fullAddress, localWiring, nodes, edges, pending, inputBindings, paramBindings, moduleInputs, byId, ports, authoredEdges, loading);
1235
+ const childOutputs = flatten(child, fullAddress, localWiring, nodes, edges, pending, inputBindings, paramBindings, moduleInputs, byId, valueResources, ports, authoredEdges, loading);
1938
1236
  nodes.push({
1939
1237
  id: fullAddress,
1940
1238
  parent: selfId,
@@ -2009,11 +1307,12 @@ function loadModule(root, opts) {
2009
1307
  const inputBindings = [];
2010
1308
  const paramBindings = [];
2011
1309
  const byId = /* @__PURE__ */ new Map();
1310
+ const valueResources = /* @__PURE__ */ new Map();
2012
1311
  const ports = [];
2013
1312
  const authoredEdges = [];
2014
1313
  const loading = { sealed: false };
2015
1314
  try {
2016
- flatten(root, rootId, {}, nodes, edges, pending, inputBindings, paramBindings, moduleInputs, byId, ports, authoredEdges, loading);
1315
+ flatten(root, rootId, {}, nodes, edges, pending, inputBindings, paramBindings, moduleInputs, byId, valueResources, ports, authoredEdges, loading);
2017
1316
  for (const entry of pending) validateWiring(entry, byId);
2018
1317
  assertDependencyDag(edges);
2019
1318
  } finally {
@@ -2023,12 +1322,11 @@ function loadModule(root, opts) {
2023
1322
  for (const [address, node] of byId) if (node.kind === "resource") resources.set(address, node);
2024
1323
  const resolved = resolveValues({
2025
1324
  environment: opts?.environment,
2026
- configuration: opts?.configuration,
2027
- appConfigurationRead: opts?.appConfigurationRead,
2028
1325
  inputBindings,
2029
1326
  params: paramBindings,
2030
1327
  moduleInputs,
2031
- resources
1328
+ resources,
1329
+ valueResources
2032
1330
  });
2033
1331
  const resolvedNodes = nodes.map((entry) => {
2034
1332
  const props = resolved.resourceProps.get(entry.id);
@@ -2052,6 +1350,7 @@ function loadModule(root, opts) {
2052
1350
  inputBindings: resolved.inputBindings,
2053
1351
  params: resolved.params,
2054
1352
  secretSources: resolved.secretSources,
1353
+ valueReads: valueReadsOf(resolved.inputBindings),
2055
1354
  appConfigurationRead: resolved.appConfigurationRead
2056
1355
  };
2057
1356
  }
@@ -2139,64 +1438,7 @@ function nodeAddresses(graph) {
2139
1438
  return graph.nodes.map(({ id }) => id).sort();
2140
1439
  }
2141
1440
  //#endregion
2142
- //#region ../../0-framework/3-tooling/cli/dist/validate-environment-CpQLC3CA.mjs
2143
- function adapterInvalid(list, index, input, summary, fix) {
2144
- return new CliStructuredError("CONFIG.ADAPTER_INVALID", summary, {
2145
- fix,
2146
- where: { path: input.configFile },
2147
- meta: { field: `${list}[${index}]` }
2148
- });
2149
- }
2150
- function isValues(value) {
2151
- return typeof value === "object" && value !== null && !Array.isArray(value);
2152
- }
2153
- function isText(values) {
2154
- return Object.values(values).every((value) => typeof value === "string");
2155
- }
2156
- async function readAdapters(list, adapters, input) {
2157
- const adapterInput = Object.freeze({
2158
- environment: input.environment,
2159
- configDirectory: path.dirname(input.configFile)
2160
- });
2161
- const merged = Object.create(null);
2162
- for (const [index, adapter] of adapters.entries()) {
2163
- const field = `composer.${list}[${index}]`;
2164
- let values;
2165
- try {
2166
- values = await adapter(adapterInput);
2167
- } catch (thrown) {
2168
- throw new CliStructuredError("CONFIG.ADAPTER_FAILED", `\`${field}\` failed to read the values for the environment "${input.environment}".`, {
2169
- why: `It threw: ${thrown instanceof Error ? thrown.message : String(thrown)}`,
2170
- fix: `Fix the adapter, or remove it from \`composer.${list}\` in prisma.config.ts.`,
2171
- where: { path: input.configFile },
2172
- meta: { field: `${list}[${index}]` },
2173
- cause: thrown
2174
- });
2175
- }
2176
- if (typeof values === "function") throw adapterInvalid(list, index, input, `\`${field}\` returned a function, not an object of values.`, "An adapter factory was put in the list instead of the adapter it makes: write `dotenv()`, not `dotenv`.");
2177
- if (!isValues(values)) throw adapterInvalid(list, index, input, `\`${field}\` returned ${describeKind(values)}, not an object of values.`, "Return an object whose keys are the names of the values, e.g. `{ EMAIL_FROM: 'shop@example.com' }`.");
2178
- for (const [key, value] of Object.entries(values)) {
2179
- if (value === void 0) continue;
2180
- if (list === "secrets" && typeof value !== "string") throw adapterInvalid(list, index, input, `\`${field}\` returned ${describeKind(value)} for "${key}", but a secret is text.`, "Return the secret as a string. A platform variable holds text.");
2181
- merged[key] = value;
2182
- }
2183
- }
2184
- return Object.freeze(merged);
2185
- }
2186
- /** Calls the section's `config` adapters (default `[environmentVariables()]`) and merges what they return: the app configuration. */
2187
- function readAppConfiguration(section, input) {
2188
- return readAdapters("config", section.config ?? [environmentVariables()], input);
2189
- }
2190
- /**
2191
- * Calls the section's `secrets` adapters (default `[environmentVariables()]`) and merges what they
2192
- * return: the app secrets. Every value must be text. A value is a known secret only once the graph
2193
- * names it, so this adds none.
2194
- */
2195
- async function readAppSecrets(section, input) {
2196
- const merged = await readAdapters("secrets", section.secrets ?? [environmentVariables()], input);
2197
- if (!isText(merged)) throw new InternalError("readAdapters admitted a secret that is not text");
2198
- return merged;
2199
- }
1441
+ //#region ../../0-framework/3-tooling/cli/dist/load-entry-CEoVBdMj.mjs
2200
1442
  /**
2201
1443
  * Synchronous Node resolve hook so that entry modules may import relative
2202
1444
  * files using the specifier forms TypeScript accepts by default —
@@ -2214,8 +1456,117 @@ async function readAppSecrets(section, input) {
2214
1456
  *
2215
1457
  * Bun resolves `./x.js` and `./x` to `x.ts` natively, so the hook is a
2216
1458
  * no-op under Bun. Nothing is registered there.
1459
+ *
1460
+ * The hook also observes, without changing anything: `recordAppFiles` uses
1461
+ * it to learn which app files an entry import loaded.
2217
1462
  */
2218
1463
  let registered = false;
1464
+ let recording;
1465
+ /** An app file: a `file:` module outside every `node_modules` directory. */
1466
+ function appFile(url) {
1467
+ if (!url.startsWith("file:")) return void 0;
1468
+ const file = fileURLToPath(url);
1469
+ return file.split(path.sep).includes("node_modules") ? void 0 : file;
1470
+ }
1471
+ function record(url) {
1472
+ const file = recording === void 0 ? void 0 : appFile(url);
1473
+ if (file !== void 0) recording?.add(file);
1474
+ }
1475
+ /**
1476
+ * Runs `load` and returns the app files it imported: every module outside
1477
+ * `node_modules` that the runtime loaded for the first time while it ran,
1478
+ * static and dynamic imports alike. Under Node the resolve hook records them;
1479
+ * under Bun they are the modules `require.cache` gained, which includes ES
1480
+ * modules. A module already loaded before `load` started, and what only it
1481
+ * imports, is not recorded. Each file is also added to `recorded` as it is
1482
+ * found, so a caller still has them when `load` throws.
1483
+ */
1484
+ async function recordAppFiles(load, recorded = /* @__PURE__ */ new Set()) {
1485
+ if (typeof process.versions.bun === "string") {
1486
+ const cache = mod.createRequire(import.meta.url).cache;
1487
+ const before = new Set(Object.keys(cache));
1488
+ const files = [];
1489
+ try {
1490
+ return {
1491
+ value: await load(),
1492
+ files
1493
+ };
1494
+ } finally {
1495
+ for (const key of Object.keys(cache)) {
1496
+ if (before.has(key) || !path.isAbsolute(key)) continue;
1497
+ if (key.split(path.sep).includes("node_modules")) continue;
1498
+ files.push(key);
1499
+ recorded.add(key);
1500
+ }
1501
+ }
1502
+ }
1503
+ registerEntryResolution();
1504
+ const files = /* @__PURE__ */ new Set();
1505
+ recording = files;
1506
+ try {
1507
+ return {
1508
+ value: await load(),
1509
+ files: [...files]
1510
+ };
1511
+ } finally {
1512
+ recording = void 0;
1513
+ for (const file of files) recorded.add(file);
1514
+ }
1515
+ }
1516
+ /** The path of a `file:` URL, or `undefined` for one that names no local file, such as one with a host. */
1517
+ function pathOfFileUrl(url) {
1518
+ try {
1519
+ return fileURLToPath(url);
1520
+ } catch {
1521
+ return;
1522
+ }
1523
+ }
1524
+ /**
1525
+ * The app files an import error names: the module that could not be found, or the file that did
1526
+ * not parse, when the runtime says which. A module that could not be found comes with every file
1527
+ * the resolve hook would try for it, since the user may create any of them. A directory is never
1528
+ * returned: in its place come the files the hook would try inside it. Follows `cause`.
1529
+ */
1530
+ function appFilesNamedBy(error) {
1531
+ const named = appPathNamedBy(error);
1532
+ return named === void 0 ? [] : filesFor(named);
1533
+ }
1534
+ /** Whether an import error names a directory of the app that holds an `index.ts`, which the import should have loaded. */
1535
+ function namesDirectoryWithIndex(error) {
1536
+ const named = appPathNamedBy(error);
1537
+ return named !== void 0 && isDirectory(named) && filesFor(named).some(existsSync);
1538
+ }
1539
+ function appPathNamedBy(error) {
1540
+ const visited = /* @__PURE__ */ new Set();
1541
+ for (let current = error; typeof current === "object" && current !== null;) {
1542
+ if (visited.has(current)) break;
1543
+ visited.add(current);
1544
+ const named = fileNamedBy(current);
1545
+ if (named !== void 0 && !named.split(path.sep).includes("node_modules")) return path.resolve(named);
1546
+ current = "cause" in current ? current.cause : void 0;
1547
+ }
1548
+ }
1549
+ function filesFor(named) {
1550
+ const candidates = () => sourceCandidates(pathToFileURL(named)).map((url) => fileURLToPath(url));
1551
+ if (isDirectory(named)) return candidates().filter((candidate) => candidate.startsWith(named + path.sep));
1552
+ if (existsSync(named)) return [named];
1553
+ return [named, ...candidates()];
1554
+ }
1555
+ function isDirectory(file) {
1556
+ try {
1557
+ return statSync(file).isDirectory();
1558
+ } catch {
1559
+ return false;
1560
+ }
1561
+ }
1562
+ function fileNamedBy(error) {
1563
+ if ("url" in error && typeof error.url === "string" && error.url.startsWith("file:")) return pathOfFileUrl(error.url);
1564
+ if ("specifier" in error && typeof error.specifier === "string" && "referrer" in error && typeof error.referrer === "string" && isRelativeSpecifier(error.specifier)) {
1565
+ const referrer = error.referrer.startsWith("file:") ? pathOfFileUrl(error.referrer) : error.referrer;
1566
+ return referrer === void 0 ? void 0 : path.resolve(path.dirname(referrer), error.specifier);
1567
+ }
1568
+ if ("position" in error && typeof error.position === "object" && error.position !== null && "file" in error.position && typeof error.position.file === "string" && path.isAbsolute(error.position.file)) return error.position.file;
1569
+ }
2219
1570
  /**
2220
1571
  * Registers the resolve hook once (idempotent). Call at the start of
2221
1572
  * `loadEntry` so every module in the entry graph benefits, including those
@@ -2227,10 +1578,16 @@ function registerEntryResolution() {
2227
1578
  registered = true;
2228
1579
  mod.registerHooks({ resolve(specifier, context, nextResolve) {
2229
1580
  try {
2230
- return nextResolve(specifier, context);
1581
+ const resolved = nextResolve(specifier, context);
1582
+ record(resolved.url);
1583
+ return resolved;
2231
1584
  } catch (error) {
2232
1585
  if (!isRelativeSpecifier(specifier) || context.parentURL === void 0 || !isModuleNotFoundError(error)) throw error;
2233
- for (const candidate of sourceCandidates(new URL(specifier, context.parentURL))) if (existsSync(fileURLToPath(candidate))) return nextResolve(candidate.href, context);
1586
+ for (const candidate of sourceCandidates(new URL(specifier, context.parentURL))) if (existsSync(fileURLToPath(candidate))) {
1587
+ const resolved = nextResolve(candidate.href, context);
1588
+ record(resolved.url);
1589
+ return resolved;
1590
+ }
2234
1591
  throw error;
2235
1592
  }
2236
1593
  } });
@@ -2240,10 +1597,11 @@ function registerEntryResolution() {
2240
1597
  * produce the source candidates to probe. Format-specific: `.mjs` maps only
2241
1598
  * to `.mts`; `.cjs` maps only to `.cts`; `.js` and extensionless probe
2242
1599
  * `.ts`, `.mts`, `.tsx` (keeping `.tsx` so the JSX diagnostic fires), then
2243
- * `./index.ts`.
1600
+ * `./index.ts`. A URL that already has a TypeScript extension has none.
2244
1601
  */
2245
1602
  function sourceCandidates(resolved) {
2246
1603
  const href = resolved.href;
1604
+ if (/\.(ts|mts|cts|tsx)$/.test(href)) return [];
2247
1605
  if (href.endsWith(".mjs")) {
2248
1606
  const base = href.slice(0, -4);
2249
1607
  return [new URL(`${base}.mts`)];
@@ -2261,7 +1619,7 @@ function sourceCandidates(resolved) {
2261
1619
  ];
2262
1620
  }
2263
1621
  function isRelativeSpecifier(specifier) {
2264
- return specifier.startsWith("./") || specifier.startsWith("../");
1622
+ return specifier === "." || specifier === ".." || specifier.startsWith("./") || specifier.startsWith("../");
2265
1623
  }
2266
1624
  function isModuleNotFoundError(error) {
2267
1625
  if (!(error instanceof Error)) return false;
@@ -2311,13 +1669,17 @@ function explainJsxLoadError(error, entryPath) {
2311
1669
  * an app root built with `appRoot()`, or a module built with `module()`
2312
1670
  * (ADR-0003).
2313
1671
  */
2314
- /** `unloadableFix`, when given, says where the path came from, so a wrong path names its source. */
2315
- async function loadEntry(entryArg, cwd, unloadableFix) {
1672
+ /**
1673
+ * `unloadableFix`, when given, says where the path came from, so a wrong path names its source.
1674
+ * `recorded` receives each app file the import loads, so a caller has them when it throws.
1675
+ */
1676
+ async function loadEntry(entryArg, cwd, unloadableFix, recorded) {
2316
1677
  registerEntryResolution();
2317
1678
  const resolvedPath = path.resolve(cwd, entryArg);
2318
1679
  let mod;
1680
+ let files;
2319
1681
  try {
2320
- mod = await import(pathToFileURL(resolvedPath).href);
1682
+ ({value: mod, files} = await recordAppFiles(() => import(pathToFileURL(resolvedPath).href), recorded));
2321
1683
  } catch (error) {
2322
1684
  const explained = explainJsxLoadError(error, resolvedPath);
2323
1685
  if (explained !== void 0) throw new CliStructuredError("COMPOSE.ENTRY_UNLOADABLE", explained.summary, {
@@ -2343,175 +1705,72 @@ async function loadEntry(entryArg, cwd, unloadableFix) {
2343
1705
  });
2344
1706
  return {
2345
1707
  path: resolvedPath,
1708
+ files: [.../* @__PURE__ */ new Set([resolvedPath, ...files])],
2346
1709
  root
2347
1710
  };
2348
1711
  }
2349
- function lookup(extensions, extension, type, expectedKind, what) {
2350
- const ext = extensions.get(extension);
2351
- if (ext === void 0) throw new CliStructuredError("CONFIG.EXTENSION_MISSING", `No extension "${extension}" is configured (needed by ${what}).`, {
2352
- fix: "Add it to `extensions` in the `composer` section of prisma.config.ts (import its /control entry and list its descriptor).",
2353
- meta: {
2354
- extension,
2355
- type
2356
- }
2357
- });
2358
- const descriptor = ext.nodes[type];
2359
- if (descriptor === void 0) throw new CliStructuredError("CONFIG.DESCRIPTOR_MISSING", `Extension "${extension}" has no descriptor for node type "${type}" (needed by ${what}).`, {
2360
- why: `Known types: ${Object.keys(ext.nodes).join(", ")}.`,
2361
- meta: {
2362
- extension,
2363
- type
2364
- }
2365
- });
2366
- if (descriptor.kind !== expectedKind) throw new CliStructuredError("CONFIG.DESCRIPTOR_KIND_MISMATCH", `Extension "${extension}"'s descriptor for node type "${type}" is a "${descriptor.kind}" descriptor — ${what} needs a "${expectedKind}" descriptor.`, { meta: {
2367
- extension,
2368
- type,
2369
- kind: descriptor.kind
2370
- } });
2371
- }
2372
- /** Throws a structured CONFIG.* error on the first uncovered `(extension, type)`; silent when the config covers the whole graph. */
2373
- function validateRegistryCoverage(graph, config) {
2374
- const extensions = new Map(config.extensions.map((descriptor) => [descriptor.id, descriptor]));
2375
- for (const { id, node } of graph.nodes) {
2376
- if (node.kind === "resource") {
2377
- lookup(extensions, node.extension, node.type, "resource", `resource node "${id}"`);
2378
- continue;
2379
- }
2380
- if (node.kind !== "service") continue;
2381
- lookup(extensions, node.extension, node.type, "service", `service node "${id}"`);
2382
- lookup(extensions, node.build.extension, node.build.type, "build", `service node "${id}"'s build descriptor`);
2383
- }
2384
- }
2385
- /**
2386
- * The shared prefix of `deploy`/`destroy`/`dev` (deploy-cli.md § The
2387
- * pipeline; local-dev spec § 6): entry load, Load,
2388
- * registry coverage validation, name resolution, assemble. Deploy and dev
2389
- * diverge after this — deploy resolves containers/preflight/stack file
2390
- * against the hosted providers, dev against the local ones — so everything
2391
- * up to and including assemble lives here once, consumed verbatim by both
2392
- * `run()` (main.ts) and `runDev()` (dev/run-dev.ts), so the two pipelines
2393
- * cannot drift.
2394
- */
2395
- const NO_SECRETS = Object.freeze({});
2396
- function configError(findings, file) {
2397
- const [first] = findings;
2398
- return new CliStructuredError(first.code, first.summary, {
2399
- ...first.why === void 0 ? {} : { why: first.why },
2400
- fix: first.fix,
2401
- where: { path: first.where ?? file },
2402
- meta: {
2403
- ...first.field === void 0 ? {} : { field: first.field },
2404
- findings
2405
- }
2406
- });
2407
- }
2408
- /**
2409
- * Refuses a caller's config with the same findings, in the same order, as the CLI's section validator.
2410
- * The error is the first finding and carries all of them in `meta.findings`. Returns the config with `file` resolved against `cwd`.
2411
- */
2412
- function checkConfigSource(source, cwd) {
2413
- const file = path.resolve(cwd, source.file);
2414
- if (!fs.existsSync(file)) throw configError([configFileMissing(file)], file);
2415
- const checked = checkComposerConfig(source.value, file);
2416
- if (!checked.ok) throw configError(checked.findings, file);
2417
- return {
2418
- value: checked.value,
2419
- file
2420
- };
2421
- }
2422
- /**
2423
- * Resolves the entry module. An override (`--entry`, or an operation's `entry` input) resolves
2424
- * against `cwd`; the section's `entry` resolves against the directory of the file that declares it,
2425
- * as the CLI engine resolves path fields in prisma.config.ts.
2426
- */
2427
- function resolveEntryPath(override, source, cwd) {
2428
- if (override !== void 0) return {
2429
- path: path.resolve(cwd, override),
2430
- fix: `Check the \`--entry\` path (the \`entry\` input when calling @prisma/composer/control) "${override}". It is relative to the current directory, ${cwd}.`
2431
- };
2432
- const configured = source.value.entry;
2433
- if (configured === void 0) throw configError([entryMissing], source.file);
2434
- return {
2435
- path: path.resolve(path.dirname(source.file), configured),
2436
- fix: `Check \`entry: "${configured}"\` in ${source.file}. It is relative to that file's directory.`
2437
- };
2438
- }
2439
- /**
2440
- * The pipeline's front — entry load and name resolution —
2441
- * WITHOUT Load, coverage, or assemble. `log` needs only who the app is (its
2442
- * config and resolved name) to reach the already-running local instance; it
2443
- * neither builds nor provisions, so it must not require the user's built
2444
- * output the way the full pipeline does.
2445
- */
2446
- async function resolveAppIdentity(entry, overrideName, cwd, config) {
2447
- const checked = checkConfigSource(config, cwd);
2448
- const { value } = checked;
2449
- const resolved = resolveEntryPath(entry, checked, cwd);
2450
- const entryModule = await loadEntry(resolved.path, cwd, resolved.fix);
2451
- const name = overrideName ?? entryModule.root.name;
2452
- if (name.length === 0) throw new CliStructuredError("COMPOSE.NAME_MISSING", "The root node has no name.", { fix: "Name it at authoring, or pass --name." });
2453
- assertAppName(name);
2454
- return {
2455
- config: value,
2456
- name
2457
- };
2458
- }
1712
+ //#endregion
1713
+ //#region ../../0-framework/1-core/core/dist/deploy.mjs
2459
1714
  /**
2460
- * Runs entry load, name resolution, Load, registry coverage, and assemble — steps 1–5 of `run()`. `onAssembleError`, when
2461
- * given, lets a caller decorate an assemble failure with command-specific
2462
- * guidance (destroy's "build first" hint) without this shared step knowing
2463
- * about any one command.
1715
+ * Resource props as plain data that `structuredClone` copies unchanged, so two props compare by
1716
+ * content with `isDeepStrictEqual` even after one crossed a thread. Every object or array is
1717
+ * tagged by what it was, so no two different props give the same data:
1718
+ *
1719
+ * - a `Value` is described by what core knows of it: a source by its kind, pointer kind, label,
1720
+ * secrets key and payload; any other value only as derived, with the kind of its origin;
1721
+ * - a `Date`, `RegExp`, `Map` or `Set` keeps its content;
1722
+ * - an instance of another class keeps its class name and own enumerable fields;
1723
+ * - a function or symbol becomes its text;
1724
+ * - a reference back to an object that contains it becomes a cycle marker.
2464
1725
  */
2465
- async function runPipeline(entry, overrideName, environment, cwd, source, deps = {}, onAssembleError) {
2466
- const configSource = checkConfigSource(source, cwd);
2467
- const config = configSource.value;
2468
- const resolved = resolveEntryPath(entry, configSource, cwd);
2469
- const entryModule = await loadEntry(resolved.path, cwd, resolved.fix);
2470
- const name = overrideName ?? entryModule.root.name;
2471
- if (name.length === 0) throw new CliStructuredError("COMPOSE.NAME_MISSING", "The root node has no name.", { fix: "Name it at authoring, or pass --name." });
2472
- const redaction = deps.redaction ?? new SecretRedaction(process.env);
2473
- const adapterInput = {
2474
- environment,
2475
- configFile: configSource.file
2476
- };
2477
- const secrets = deps.readSecrets === true ? await readAppSecrets(config, adapterInput) : NO_SECRETS;
2478
- const configuration = await readAppConfiguration(config, adapterInput);
2479
- redaction.addCredentialLookingValues(credentialLookingValues(configuration));
2480
- const graph = Load(entryModule.root, {
2481
- id: name,
2482
- environment: { name: environment },
2483
- configuration
2484
- });
2485
- redaction.addKnownSecrets(valuesUnderSecretsKeys(configuration, secrets, secretsKeys(graph)));
2486
- validateRegistryCoverage(graph, config);
2487
- deps.onEvent?.({ kind: "loaded" });
2488
- let assembled;
1726
+ function comparableProps(props) {
1727
+ return asData(props, /* @__PURE__ */ new Set());
1728
+ }
1729
+ function asData(value, containing) {
1730
+ if (typeof value === "function") return { function: String(value) };
1731
+ if (typeof value === "symbol") return { symbol: String(value) };
1732
+ if (typeof value !== "object" || value === null) return value;
1733
+ if (containing.has(value)) return { cycle: true };
1734
+ containing.add(value);
2489
1735
  try {
2490
- assembled = await assembleServices(graph, config, cwd, deps.runAssembler, deps.onEvent, { devServers: deps.devServers === true });
2491
- } catch (error) {
2492
- if (onAssembleError !== void 0 && error instanceof Error) throw onAssembleError(error);
2493
- throw error;
1736
+ return objectAsData(value, (inner) => asData(inner, containing));
1737
+ } finally {
1738
+ containing.delete(value);
2494
1739
  }
1740
+ }
1741
+ function objectAsData(value, inner) {
1742
+ if (isValue(value)) {
1743
+ const origin = originOf(value);
1744
+ if (origin.kind !== "source") return { value: { derived: origin.kind } };
1745
+ return { value: {
1746
+ sourceKind: origin.sourceKind,
1747
+ pointer: Reflect.get(value, POINTER),
1748
+ label: origin.label,
1749
+ secretsKey: origin.sourceKind === "secret" ? origin.secretsKey : void 0,
1750
+ payload: inner(Reflect.get(value, "payload"))
1751
+ } };
1752
+ }
1753
+ if (Array.isArray(value)) return { array: value.map(inner) };
1754
+ if (value instanceof Date) return { date: value.getTime() };
1755
+ if (value instanceof RegExp) return { regexp: String(value) };
1756
+ if (value instanceof Map) return { map: [...value].map(([key, entry]) => [inner(key), inner(entry)]) };
1757
+ if (value instanceof Set) return { set: [...value].map(inner) };
1758
+ const fields = Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, inner(entry)]));
1759
+ if (isPlainObject(value)) return { object: fields };
2495
1760
  return {
2496
- configSource,
2497
- entryModule,
2498
- graph,
2499
- name,
2500
- assembled,
2501
- configuration,
2502
- secrets
1761
+ instance: value.constructor?.name,
1762
+ fields
2503
1763
  };
2504
1764
  }
2505
- /** Letters, digits, `-` and `_`, starting with a letter or digit: always a valid git ref, so no `git` is needed to check it. */
2506
- const PLAIN_ENVIRONMENT_NAME = /^[A-Za-z0-9][A-Za-z0-9_-]*$/;
2507
- /** An environment name must be a valid git ref (deploy-cli.md) — checked via `git check-ref-format`, never silently normalized. Runs before anything platform-specific. */
2508
- function validateEnvironmentName(environment, spawn = spawnSync) {
2509
- if (PLAIN_ENVIRONMENT_NAME.test(environment)) return;
2510
- const result = spawn("git", ["check-ref-format", `refs/heads/${environment}`], { stdio: "ignore" });
2511
- if (result.error) throw new CliStructuredError("DEPLOY.ENVIRONMENT_UNVALIDATABLE", `git is required to validate --environment "${environment}" (git check-ref-format): ${result.error.message}.`, { cause: result.error });
2512
- if (result.status !== 0) throw new CliStructuredError("DEPLOY.ENVIRONMENT_INVALID", `Invalid --environment "${environment}": must be a valid git ref name (git check-ref-format rejected "refs/heads/${environment}").`);
1765
+ /** The `name` of the error `lower()` fails with when it builds a graph whose node addresses differ from `firstProcessNodeAddresses`. */
1766
+ const GRAPH_CHANGED_ERROR = "GraphChangedError";
1767
+ const PROVIDER_FAILURE_TAG = "ProviderFailure";
1768
+ Data.TaggedError(PROVIDER_FAILURE_TAG);
1769
+ /** The original error of a provider failure `toProviderError` wrapped, or `undefined` for any other error. */
1770
+ function wrappedProviderError(error) {
1771
+ return Predicate.isTagged(error, PROVIDER_FAILURE_TAG) && "cause" in error ? error.cause : void 0;
2513
1772
  }
2514
1773
  //#endregion
2515
- export { nodeAddresses as a, __require as c, validateEnvironmentName as i, __toESM as l, resolveAppIdentity as n, secretsKeys as o, runPipeline as r, __commonJSMin as s, checkConfigSource as t };
1774
+ export { loadEntry as a, GraphCheckError as c, assertAppName as d, nodeAddresses as f, appFilesNamedBy as i, Load as l, describeKind as m, comparableProps as n, namesDirectoryWithIndex as o, secretsKeys as p, wrappedProviderError as r, registerEntryResolution as s, GRAPH_CHANGED_ERROR as t, ROOT_INPUT_UNREAD_ERROR as u };
2516
1775
 
2517
- //# sourceMappingURL=validate-environment-CpQLC3CA-Ct-PXoKN.mjs.map
1776
+ //# sourceMappingURL=deploy-Br1yvLe3.mjs.map