@prisma/composer-cli 0.39.0-dev.1 → 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.
- package/dist/app-converge-C_YkTIBF-RmqGOR45.mjs +88 -0
- package/dist/app-converge-C_YkTIBF-RmqGOR45.mjs.map +1 -0
- package/dist/composer-config-QKdY85G--CEXrb2Uc.mjs +254 -0
- package/dist/composer-config-QKdY85G--CEXrb2Uc.mjs.map +1 -0
- package/dist/{validate-environment-D1BTCkTs-C5m4rL6t.mjs → deploy-Br1yvLe3.mjs} +335 -1091
- package/dist/deploy-Br1yvLe3.mjs.map +1 -0
- package/dist/dev-converge-messages-DML4rTz7-B6uxtpZG.mjs +256 -0
- package/dist/dev-converge-messages-DML4rTz7-B6uxtpZG.mjs.map +1 -0
- package/dist/dev-converge-worker.d.mts +1 -0
- package/dist/dev-converge-worker.mjs +143 -0
- package/dist/dev-converge-worker.mjs.map +1 -0
- package/dist/{dev-current-wD5YDLjA-CFI8XTAK.mjs → dev-current-DANgmcle-RwunETUJ.mjs} +12 -18
- package/dist/dev-current-DANgmcle-RwunETUJ.mjs.map +1 -0
- package/dist/dev-environment-name-6eEr5PW8-CCY7WNWz.mjs +43 -0
- package/dist/dev-environment-name-6eEr5PW8-CCY7WNWz.mjs.map +1 -0
- package/dist/{dist-D0rWRHos.mjs → dist-C0OGaDnj.mjs} +4 -3
- package/dist/{dist-D0rWRHos.mjs.map → dist-C0OGaDnj.mjs.map} +1 -1
- package/dist/errors-CVYwN2km.mjs +93 -0
- package/dist/errors-CVYwN2km.mjs.map +1 -0
- package/dist/{execute-deploy-destroy-DOzo2Psp-2iWcFbD9.mjs → execute-deploy-destroy-DIR9uvA_-Bk0HBMTz.mjs} +374 -141
- package/dist/execute-deploy-destroy-DIR9uvA_-Bk0HBMTz.mjs.map +1 -0
- package/dist/{execute-dev-BIyOI3Ys-DGpTd9rP.mjs → execute-dev-Cu9_LsQi-CsyIqphZ.mjs} +444 -128
- package/dist/execute-dev-Cu9_LsQi-CsyIqphZ.mjs.map +1 -0
- package/dist/{execute-dev-current-CKOzjWuO-DTOVqZzZ.mjs → execute-dev-current-Bs0lE_5--BU3A2hsC.mjs} +9 -6
- package/dist/{execute-dev-current-CKOzjWuO-DTOVqZzZ.mjs.map → execute-dev-current-Bs0lE_5--BU3A2hsC.mjs.map} +1 -1
- package/dist/{redaction-Bf8FvTFH-XGchRgrK.d.mts → family-DfwviKFj-CS1L-EvS.d.mts} +439 -204
- package/dist/family-DfwviKFj-CS1L-EvS.d.mts.map +1 -0
- package/dist/family.d.mts +1 -1
- package/dist/family.mjs +259 -269
- package/dist/family.mjs.map +1 -1
- package/dist/internal-error-Dfur7Zqt-B8J8e7ac.mjs +58 -0
- package/dist/internal-error-Dfur7Zqt-B8J8e7ac.mjs.map +1 -0
- package/dist/{list-deployed-BFJJxt_W.mjs → list-deployed-slo4P7dl.mjs} +6 -5
- package/dist/list-deployed-slo4P7dl.mjs.map +1 -0
- package/dist/local-target-CZzICh5R.mjs +34 -0
- package/dist/local-target-CZzICh5R.mjs.map +1 -0
- package/dist/{preflight-transport-DmmtoFPH-CZ0o7QPf.mjs → preflight-transport-2d6iIchu-ArIJUY1L.mjs} +7 -28
- package/dist/preflight-transport-2d6iIchu-ArIJUY1L.mjs.map +1 -0
- package/dist/{redaction-DXung4ip-Co_fv4Zl.mjs → redaction-DY6eDC12-BrK1aSN5.mjs} +33 -267
- package/dist/redaction-DY6eDC12-BrK1aSN5.mjs.map +1 -0
- package/dist/result-CttmabB6.mjs +91 -0
- package/dist/result-CttmabB6.mjs.map +1 -0
- package/dist/rolldown-runtime-C7HZzL1F.mjs +26 -0
- package/dist/steps-BZXNqW6U-BM2Aa8Bp.mjs +287 -0
- package/dist/steps-BZXNqW6U-BM2Aa8Bp.mjs.map +1 -0
- package/dist/testing.d.mts +4 -49
- package/dist/testing.d.mts.map +1 -1
- package/dist/testing.mjs +2 -75
- package/dist/testing.mjs.map +1 -1
- package/dist/validate-environment-DCZiNSlR-idVge-kq.mjs +983 -0
- package/dist/validate-environment-DCZiNSlR-idVge-kq.mjs.map +1 -0
- package/dist/value-reads-change-text-DcRCv7Zy-Ca8m3bal.mjs +15 -0
- package/dist/value-reads-change-text-DcRCv7Zy-Ca8m3bal.mjs.map +1 -0
- package/package.json +9 -9
- package/src/exports/dev-converge-worker.ts +2 -0
- package/src/exports/testing.ts +1 -4
- package/dist/app-configuration-file-CeJvBAti-DA4EKwFq.mjs +0 -140
- package/dist/app-configuration-file-CeJvBAti-DA4EKwFq.mjs.map +0 -1
- package/dist/dev-current-wD5YDLjA-CFI8XTAK.mjs.map +0 -1
- package/dist/dev-environment-name-6eEr5PW8-Bs4Dl0vW.mjs +0 -71
- package/dist/dev-environment-name-6eEr5PW8-Bs4Dl0vW.mjs.map +0 -1
- package/dist/execute-deploy-destroy-DOzo2Psp-2iWcFbD9.mjs.map +0 -1
- package/dist/execute-dev-BIyOI3Ys-DGpTd9rP.mjs.map +0 -1
- package/dist/generate-dev-stack-BV_n-X9n-DM5faH3-.mjs +0 -100
- package/dist/generate-dev-stack-BV_n-X9n-DM5faH3-.mjs.map +0 -1
- package/dist/list-deployed-BFJJxt_W.mjs.map +0 -1
- package/dist/preflight-transport-DmmtoFPH-CZ0o7QPf.mjs.map +0 -1
- package/dist/redaction-Bf8FvTFH-XGchRgrK.d.mts.map +0 -1
- package/dist/redaction-DXung4ip-Co_fv4Zl.mjs.map +0 -1
- package/dist/result-sR7PBi61.mjs +0 -229
- package/dist/result-sR7PBi61.mjs.map +0 -1
- package/dist/run-alchemy-CRLAyOtt-CwFLe4Zg.mjs +0 -236
- package/dist/run-alchemy-CRLAyOtt-CwFLe4Zg.mjs.map +0 -1
- package/dist/validate-environment-D1BTCkTs-C5m4rL6t.mjs.map +0 -1
|
@@ -1,39 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
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 {
|
|
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
|
|
12
|
-
import
|
|
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
|
|
49
|
-
|
|
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-
|
|
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)
|
|
815
|
-
*
|
|
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 {
|
|
@@ -833,6 +71,7 @@ function contractStyleOf(contract) {
|
|
|
833
71
|
}
|
|
834
72
|
const VALUE = blindCast(Symbol.for("prisma:value"));
|
|
835
73
|
const VALUE_ORIGIN = blindCast(Symbol.for("prisma:value-origin"));
|
|
74
|
+
const VALUE_RESOURCE = blindCast(Symbol.for("prisma:value-resource"));
|
|
836
75
|
/** True if `value` is a `Value`, a source included (checks the brand only, never a prototype). */
|
|
837
76
|
function isValue(value) {
|
|
838
77
|
return typeof value === "object" && value !== null && blindCast(value)[VALUE] === true;
|
|
@@ -953,13 +192,47 @@ function buildModuleInput(moduleAddress) {
|
|
|
953
192
|
*/
|
|
954
193
|
const NODE = Symbol.for("prisma:node");
|
|
955
194
|
const SECRET_SOURCE = blindCast(Symbol.for("prisma:secret-source"));
|
|
956
|
-
/** True if `value` is a secret source
|
|
195
|
+
/** True if `value` is a secret source. */
|
|
957
196
|
function isSecretSource(value) {
|
|
958
197
|
return typeof value === "object" && value !== null && blindCast(value)[SECRET_SOURCE] === true;
|
|
959
198
|
}
|
|
960
199
|
blindCast(Symbol.for("prisma:provision-need"));
|
|
961
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
|
+
}
|
|
962
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
|
+
}
|
|
963
236
|
/** True for the error a source throws when code turns it into text or a number. Internal to core. */
|
|
964
237
|
function isSourceMisuse(error) {
|
|
965
238
|
return error instanceof LoadError && sourceMisuses.has(error);
|
|
@@ -970,7 +243,7 @@ function sourceOriginOf(source) {
|
|
|
970
243
|
const origin = originOf(source);
|
|
971
244
|
return origin.kind === "source" ? origin : void 0;
|
|
972
245
|
}
|
|
973
|
-
/** True if `value` is a param source
|
|
246
|
+
/** True if `value` is a param source. */
|
|
974
247
|
function isParamSource(value) {
|
|
975
248
|
return typeof value === "object" && value !== null && blindCast(value)[PARAM_SOURCE] === true;
|
|
976
249
|
}
|
|
@@ -983,6 +256,18 @@ function isParamSource(value) {
|
|
|
983
256
|
function isConfigKeySegment(name) {
|
|
984
257
|
return /^[A-Za-z0-9]+$/.test(name);
|
|
985
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
|
+
}
|
|
986
271
|
/**
|
|
987
272
|
* True if `value` was constructed by this module's factories. Checks the
|
|
988
273
|
* brand only, never a prototype — a graph may mix nodes from a different
|
|
@@ -1124,10 +409,8 @@ function loadService(root, rootId) {
|
|
|
1124
409
|
inputBindings: [],
|
|
1125
410
|
params: [],
|
|
1126
411
|
secretSources: [],
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
configurationKeyText: {}
|
|
1130
|
-
}
|
|
412
|
+
valueReads: [],
|
|
413
|
+
appConfigurationRead: { rootInput: [] }
|
|
1131
414
|
};
|
|
1132
415
|
}
|
|
1133
416
|
function joinPath(path, key) {
|
|
@@ -1202,6 +485,14 @@ function jsonInexactKind(value) {
|
|
|
1202
485
|
}
|
|
1203
486
|
return describeNotPlain(value) ?? describeKind(value);
|
|
1204
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
|
+
};
|
|
1205
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.";
|
|
1206
497
|
function isThenable(value) {
|
|
1207
498
|
if (isValue(value)) return false;
|
|
@@ -1241,7 +532,7 @@ function checkResult(result, fnLabel) {
|
|
|
1241
532
|
const walk = (value, path) => {
|
|
1242
533
|
const atPath = path === "" ? "" : ` at "${path}"`;
|
|
1243
534
|
if (value === void 0) throw new LoadError(`${fnLabel} returned undefined${atPath}. Return a result for every environment; Composer never picks a default.`);
|
|
1244
|
-
if (isSecretSource(value) || isParamSource(value)) throw new LoadError(`${fnLabel} returned a source${atPath},
|
|
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.`);
|
|
1245
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.`);
|
|
1246
537
|
const notPlain = describeNotPlain(value);
|
|
1247
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.`);
|
|
@@ -1271,7 +562,7 @@ function firstPointer(value, path = [], seen = /* @__PURE__ */ new WeakSet()) {
|
|
|
1271
562
|
function refusePointerDependency(fnLabel, dependency, real) {
|
|
1272
563
|
const found = firstPointer(real);
|
|
1273
564
|
if (found === void 0) return;
|
|
1274
|
-
const label = sourceOriginOf(found.pointer)?.label ?? "a
|
|
565
|
+
const label = sourceOriginOf(found.pointer)?.label ?? "a source";
|
|
1275
566
|
const origin = originOf(dependency);
|
|
1276
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.`);
|
|
1277
568
|
const listed = `${inputFieldLabel(origin)} of module "${origin.module}"`;
|
|
@@ -1342,7 +633,7 @@ function refuseSecretBoxes(address, value, path) {
|
|
|
1342
633
|
address,
|
|
1343
634
|
kind: "moduleInput",
|
|
1344
635
|
path
|
|
1345
|
-
})} is bound to a SecretString. A secret's value never appears in the code; bind
|
|
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().`);
|
|
1346
637
|
if (Array.isArray(value)) {
|
|
1347
638
|
for (const [index, member] of value.entries()) refuseSecretBoxes(address, member, joinPath(path, index));
|
|
1348
639
|
return;
|
|
@@ -1350,10 +641,17 @@ function refuseSecretBoxes(address, value, path) {
|
|
|
1350
641
|
if (isPlainObject(value)) for (const [key, member] of Object.entries(value)) refuseSecretBoxes(address, member, joinPath(path, key));
|
|
1351
642
|
}
|
|
1352
643
|
/** The original source each runtime value in `value` names, by its path. */
|
|
1353
|
-
function sourcesByPath(value, path = "", found = /* @__PURE__ */ new Map()) {
|
|
1354
|
-
if (isSecretSource(value) || isParamSource(value))
|
|
1355
|
-
|
|
1356
|
-
|
|
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);
|
|
1357
655
|
return found;
|
|
1358
656
|
}
|
|
1359
657
|
function validateModuleInput(entry, resolved, environment) {
|
|
@@ -1386,11 +684,18 @@ function validateModuleInput(entry, resolved, environment) {
|
|
|
1386
684
|
};
|
|
1387
685
|
return restore(result.value, "");
|
|
1388
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
|
+
}
|
|
1389
694
|
function refusePointersInProps(address, props) {
|
|
1390
695
|
const seen = /* @__PURE__ */ new WeakSet();
|
|
1391
696
|
const walk = (value, path) => {
|
|
1392
697
|
if (isSecretSource(value) || isParamSource(value)) {
|
|
1393
|
-
const label = sourceOriginOf(value)?.label ??
|
|
698
|
+
const label = sourceOriginOf(value)?.label ?? "a source";
|
|
1394
699
|
throw new LoadError(`${describeSite({
|
|
1395
700
|
address,
|
|
1396
701
|
kind: "props",
|
|
@@ -1412,22 +717,12 @@ function refusePointersInProps(address, props) {
|
|
|
1412
717
|
function resolveValues(input) {
|
|
1413
718
|
const { environment } = input;
|
|
1414
719
|
const rootFields = /* @__PURE__ */ new Map();
|
|
1415
|
-
const keysRead = /* @__PURE__ */ new Map();
|
|
1416
|
-
/** The text the app configuration holds for `key`, recorded; `undefined` when it holds none or `''`. */
|
|
1417
|
-
const configurationText = (key, label, site) => {
|
|
1418
|
-
let raw;
|
|
1419
|
-
if (input.appConfigurationRead !== void 0) raw = input.appConfigurationRead.configurationKeyText[key];
|
|
1420
|
-
else if (input.configuration !== void 0) raw = input.configuration[key];
|
|
1421
|
-
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.`);
|
|
1422
|
-
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.`);
|
|
1423
|
-
const text = raw === void 0 || raw === "" ? void 0 : raw;
|
|
1424
|
-
keysRead.set(key, {
|
|
1425
|
-
label,
|
|
1426
|
-
text
|
|
1427
|
-
});
|
|
1428
|
-
return text;
|
|
1429
|
-
};
|
|
1430
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
|
+
});
|
|
1431
726
|
const recordSecret = (source, site) => {
|
|
1432
727
|
const canonical = canonicalSecret(source);
|
|
1433
728
|
if (secretUses.has(canonical)) return;
|
|
@@ -1437,8 +732,8 @@ function resolveValues(input) {
|
|
|
1437
732
|
nodeKind: nodeKindOf(site)
|
|
1438
733
|
});
|
|
1439
734
|
};
|
|
1440
|
-
const secretSourcesReceivedBy = (inputBindings
|
|
1441
|
-
for (const { serviceAddress, binding } of
|
|
735
|
+
const secretSourcesReceivedBy = (inputBindings) => {
|
|
736
|
+
for (const { serviceAddress, binding } of inputBindings) for (const pointer of pointersIn(binding)) {
|
|
1442
737
|
if (!isSecretSource(pointer)) continue;
|
|
1443
738
|
const canonical = canonicalSecret(pointer);
|
|
1444
739
|
if (secretUses.get(canonical)?.nodeKind === "service") continue;
|
|
@@ -1488,14 +783,11 @@ function resolveValues(input) {
|
|
|
1488
783
|
break;
|
|
1489
784
|
case "source":
|
|
1490
785
|
if (isSecretSource(origin.source)) recordSecret(origin.source, site);
|
|
1491
|
-
|
|
1492
|
-
else result = configurationText(origin.configurationKey, origin.label, site);
|
|
786
|
+
result = origin.source;
|
|
1493
787
|
break;
|
|
1494
788
|
case "computed": {
|
|
1495
789
|
const args = origin.dependencies.map((dependency) => {
|
|
1496
790
|
const real = resolveOne(dependency, site);
|
|
1497
|
-
const source = originOf(dependency);
|
|
1498
|
-
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.`);
|
|
1499
791
|
refusePointerDependency(fnLabelFor(site), dependency, real);
|
|
1500
792
|
return real;
|
|
1501
793
|
});
|
|
@@ -1518,7 +810,7 @@ function resolveValues(input) {
|
|
|
1518
810
|
}
|
|
1519
811
|
if (entry.checked !== void 0) {
|
|
1520
812
|
const field = entry.checked.find((candidate) => candidate.path.join("\0") === origin.path.join("\0"));
|
|
1521
|
-
if (field === void 0) throw new
|
|
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}`);
|
|
1522
814
|
result = field.value;
|
|
1523
815
|
} else {
|
|
1524
816
|
result = readPath(validatedInputOf(entry), origin);
|
|
@@ -1553,41 +845,17 @@ function resolveValues(input) {
|
|
|
1553
845
|
return validated;
|
|
1554
846
|
};
|
|
1555
847
|
const rootModuleAddress = () => input.moduleInputs.find((entry) => entry.isLoadRoot)?.moduleAddress ?? "";
|
|
1556
|
-
const appConfigurationReadOf = (
|
|
1557
|
-
if (input.configuration !== void 0 || input.appConfigurationRead !== void 0) {
|
|
1558
|
-
const kept = [...inputBindings.map(({ serviceAddress, binding }) => ({
|
|
1559
|
-
binding,
|
|
1560
|
-
site: {
|
|
1561
|
-
address: serviceAddress,
|
|
1562
|
-
kind: "serviceInput",
|
|
1563
|
-
path: ""
|
|
1564
|
-
}
|
|
1565
|
-
})), ...params.map(({ serviceAddress, slot, binding }) => ({
|
|
1566
|
-
binding,
|
|
1567
|
-
site: {
|
|
1568
|
-
address: serviceAddress,
|
|
1569
|
-
kind: "param",
|
|
1570
|
-
path: slot
|
|
1571
|
-
}
|
|
1572
|
-
}))];
|
|
1573
|
-
for (const { binding, site } of kept) for (const pointer of pointersIn(binding)) {
|
|
1574
|
-
if (!isParamSource(pointer)) continue;
|
|
1575
|
-
const origin = sourceOriginOf(pointer);
|
|
1576
|
-
if (origin?.sourceKind === "param" && origin.configurationKey !== void 0) configurationText(origin.configurationKey, origin.label, site);
|
|
1577
|
-
}
|
|
1578
|
-
}
|
|
848
|
+
const appConfigurationReadOf = (secretSources) => {
|
|
1579
849
|
for (const use of secretSources) {
|
|
1580
850
|
const origin = sourceOriginOf(use.source);
|
|
1581
851
|
if (origin?.sourceKind !== "secret") continue;
|
|
1582
852
|
const key = origin.secretsKey;
|
|
1583
|
-
const read = key === void 0 ? void 0 : keysRead.get(key);
|
|
1584
|
-
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.`);
|
|
1585
853
|
const field = [...rootFields.values()].find((candidate) => candidate.path[0] === key);
|
|
1586
854
|
if (key !== void 0 && field !== void 0) throw new LoadError(`${inputFieldLabel({
|
|
1587
855
|
kind: "input",
|
|
1588
856
|
module: rootModuleAddress(),
|
|
1589
857
|
path: field.path
|
|
1590
|
-
})} 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:
|
|
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.`);
|
|
1591
859
|
}
|
|
1592
860
|
for (const field of rootFields.values()) {
|
|
1593
861
|
const kind = "value" in field ? jsonInexactKind(field.value) : void 0;
|
|
@@ -1595,27 +863,23 @@ function resolveValues(input) {
|
|
|
1595
863
|
kind: "input",
|
|
1596
864
|
module: rootModuleAddress(),
|
|
1597
865
|
path: field.path
|
|
1598
|
-
})} of root module "${rootModuleAddress()}" holds ${kind}, which JSON cannot hold exactly.
|
|
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.`);
|
|
1599
867
|
}
|
|
1600
|
-
|
|
1601
|
-
for (const [key, { text }] of keysRead) if (text !== void 0) configurationKeyText[key] = text;
|
|
1602
|
-
return {
|
|
1603
|
-
rootInput: [...rootFields.values()],
|
|
1604
|
-
configurationKeyText
|
|
1605
|
-
};
|
|
868
|
+
return { rootInput: [...rootFields.values()] };
|
|
1606
869
|
};
|
|
1607
870
|
for (const entry of input.moduleInputs) validatedInputOf(entry);
|
|
1608
871
|
for (const { value, site } of found) resolveOne(value, site);
|
|
1609
872
|
const authoredProps = new Map([...input.resources].map(([address, resource]) => [address, resource.props]));
|
|
1610
873
|
if (found.length === 0) {
|
|
1611
874
|
for (const [address, props] of authoredProps) refusePointersInProps(address, props);
|
|
1612
|
-
|
|
875
|
+
refuseSourcesInParams(input.params);
|
|
876
|
+
const secretSources = secretSourcesReceivedBy(input.inputBindings);
|
|
1613
877
|
return {
|
|
1614
878
|
inputBindings: input.inputBindings,
|
|
1615
879
|
params: input.params,
|
|
1616
880
|
resourceProps: authoredProps,
|
|
1617
881
|
secretSources,
|
|
1618
|
-
appConfigurationRead: appConfigurationReadOf(
|
|
882
|
+
appConfigurationRead: appConfigurationReadOf(secretSources)
|
|
1619
883
|
};
|
|
1620
884
|
}
|
|
1621
885
|
const inProgress = /* @__PURE__ */ new WeakSet();
|
|
@@ -1641,15 +905,28 @@ function resolveValues(input) {
|
|
|
1641
905
|
binding
|
|
1642
906
|
}];
|
|
1643
907
|
});
|
|
1644
|
-
|
|
908
|
+
refuseSourcesInParams(params);
|
|
909
|
+
const secretSources = secretSourcesReceivedBy(inputBindings);
|
|
1645
910
|
return {
|
|
1646
911
|
resourceProps,
|
|
1647
912
|
inputBindings,
|
|
1648
913
|
params,
|
|
1649
914
|
secretSources,
|
|
1650
|
-
appConfigurationRead: appConfigurationReadOf(
|
|
915
|
+
appConfigurationRead: appConfigurationReadOf(secretSources)
|
|
1651
916
|
};
|
|
1652
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
|
+
}
|
|
1653
930
|
/**
|
|
1654
931
|
* Brands a ref-port with the AUTHORED endpoint it stands for — which port of
|
|
1655
932
|
* which node the author wired, before any forwarding chain resolves. Read
|
|
@@ -1721,6 +998,9 @@ function producerIdOf(ref) {
|
|
|
1721
998
|
* identity the branding copy creates, never on reading this back.
|
|
1722
999
|
*/
|
|
1723
1000
|
const MODULE_INPUT_KEY = Symbol("prisma:module-input-key");
|
|
1001
|
+
function describeNode(node) {
|
|
1002
|
+
return valueResourceOrigin(node)?.label ?? `${node.kind} "${node.name}"`;
|
|
1003
|
+
}
|
|
1724
1004
|
/** Whether `ref` carries a callable `satisfies` that accepts `required` truthily. */
|
|
1725
1005
|
function satisfiesRequired(ref, required) {
|
|
1726
1006
|
return typeof ref === "object" && ref !== null && "satisfies" in ref && typeof ref.satisfies === "function" && ref.satisfies(required);
|
|
@@ -1790,9 +1070,9 @@ function validateServiceParamBinding(child, id, paramWiring, enclosingModuleName
|
|
|
1790
1070
|
* children carry it as their `parent`, and this module's own boundary ports
|
|
1791
1071
|
* (and the authored edges touching them) are recorded against it.
|
|
1792
1072
|
*/
|
|
1793
|
-
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) {
|
|
1794
1074
|
ports.push(...boundaryPortsOf(selfId, moduleNode));
|
|
1795
|
-
const
|
|
1075
|
+
const localNodes = /* @__PURE__ */ new Map();
|
|
1796
1076
|
const used = /* @__PURE__ */ new Set();
|
|
1797
1077
|
const ctxInputs = {};
|
|
1798
1078
|
for (const key of Object.keys(moduleNode.deps)) {
|
|
@@ -1842,13 +1122,20 @@ function flatten(moduleNode, selfId, wiring, nodes, edges, pending, inputBinding
|
|
|
1842
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).`);
|
|
1843
1123
|
if (typeof id !== "string" || id.length === 0) throw new LoadError(`provision() requires a non-empty id (module "${moduleNode.name}").`);
|
|
1844
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.)`);
|
|
1845
|
-
|
|
1125
|
+
const fullAddress = `${selfId}.${id}`;
|
|
1846
1126
|
const untrusted = child;
|
|
1847
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).`);
|
|
1848
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.`);
|
|
1849
|
-
|
|
1850
|
-
|
|
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);
|
|
1851
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
|
+
}
|
|
1852
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().`);
|
|
1853
1140
|
if (provisionSecrets !== void 0) throw new LoadError(`provision("${id}") received secrets for a resource — a resource has no secret slots to satisfy.`);
|
|
1854
1141
|
if (provisionInput !== void 0) throw new LoadError(`provision("${id}") received an input binding for a resource — a resource declares no input schema.`);
|
|
@@ -1881,6 +1168,11 @@ function flatten(moduleNode, selfId, wiring, nodes, edges, pending, inputBinding
|
|
|
1881
1168
|
targetKind: "resource",
|
|
1882
1169
|
enclosingModuleName: moduleNode.name
|
|
1883
1170
|
});
|
|
1171
|
+
if (valueOrigin !== void 0) {
|
|
1172
|
+
const value = provisionedValue(valueOrigin, fullAddress);
|
|
1173
|
+
valueResources.set(fullAddress, value);
|
|
1174
|
+
return value;
|
|
1175
|
+
}
|
|
1884
1176
|
return refForResource(fullAddress, child);
|
|
1885
1177
|
}
|
|
1886
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).`);
|
|
@@ -1888,7 +1180,7 @@ function flatten(moduleNode, selfId, wiring, nodes, edges, pending, inputBinding
|
|
|
1888
1180
|
markUsed(Object.values(localWiring));
|
|
1889
1181
|
const localParams = { ...provisionParams ?? {} };
|
|
1890
1182
|
if (child.kind === "service") {
|
|
1891
|
-
if (provisionSecrets !== void 0) throw new LoadError(`provision("${id}") received secrets for a service — a service takes its secrets as
|
|
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.`);
|
|
1892
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.`);
|
|
1893
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}").`);
|
|
1894
1186
|
if (provisionInput !== void 0) inputBindings.push({
|
|
@@ -1940,7 +1232,7 @@ function flatten(moduleNode, selfId, wiring, nodes, edges, pending, inputBinding
|
|
|
1940
1232
|
targetKind: "module",
|
|
1941
1233
|
enclosingModuleName: moduleNode.name
|
|
1942
1234
|
});
|
|
1943
|
-
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);
|
|
1944
1236
|
nodes.push({
|
|
1945
1237
|
id: fullAddress,
|
|
1946
1238
|
parent: selfId,
|
|
@@ -2015,11 +1307,12 @@ function loadModule(root, opts) {
|
|
|
2015
1307
|
const inputBindings = [];
|
|
2016
1308
|
const paramBindings = [];
|
|
2017
1309
|
const byId = /* @__PURE__ */ new Map();
|
|
1310
|
+
const valueResources = /* @__PURE__ */ new Map();
|
|
2018
1311
|
const ports = [];
|
|
2019
1312
|
const authoredEdges = [];
|
|
2020
1313
|
const loading = { sealed: false };
|
|
2021
1314
|
try {
|
|
2022
|
-
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);
|
|
2023
1316
|
for (const entry of pending) validateWiring(entry, byId);
|
|
2024
1317
|
assertDependencyDag(edges);
|
|
2025
1318
|
} finally {
|
|
@@ -2029,12 +1322,11 @@ function loadModule(root, opts) {
|
|
|
2029
1322
|
for (const [address, node] of byId) if (node.kind === "resource") resources.set(address, node);
|
|
2030
1323
|
const resolved = resolveValues({
|
|
2031
1324
|
environment: opts?.environment,
|
|
2032
|
-
configuration: opts?.configuration,
|
|
2033
|
-
appConfigurationRead: opts?.appConfigurationRead,
|
|
2034
1325
|
inputBindings,
|
|
2035
1326
|
params: paramBindings,
|
|
2036
1327
|
moduleInputs,
|
|
2037
|
-
resources
|
|
1328
|
+
resources,
|
|
1329
|
+
valueResources
|
|
2038
1330
|
});
|
|
2039
1331
|
const resolvedNodes = nodes.map((entry) => {
|
|
2040
1332
|
const props = resolved.resourceProps.get(entry.id);
|
|
@@ -2058,6 +1350,7 @@ function loadModule(root, opts) {
|
|
|
2058
1350
|
inputBindings: resolved.inputBindings,
|
|
2059
1351
|
params: resolved.params,
|
|
2060
1352
|
secretSources: resolved.secretSources,
|
|
1353
|
+
valueReads: valueReadsOf(resolved.inputBindings),
|
|
2061
1354
|
appConfigurationRead: resolved.appConfigurationRead
|
|
2062
1355
|
};
|
|
2063
1356
|
}
|
|
@@ -2145,64 +1438,7 @@ function nodeAddresses(graph) {
|
|
|
2145
1438
|
return graph.nodes.map(({ id }) => id).sort();
|
|
2146
1439
|
}
|
|
2147
1440
|
//#endregion
|
|
2148
|
-
//#region ../../0-framework/3-tooling/cli/dist/
|
|
2149
|
-
function adapterInvalid(list, index, input, summary, fix) {
|
|
2150
|
-
return new CliStructuredError("CONFIG.ADAPTER_INVALID", summary, {
|
|
2151
|
-
fix,
|
|
2152
|
-
where: { path: input.configFile },
|
|
2153
|
-
meta: { field: `${list}[${index}]` }
|
|
2154
|
-
});
|
|
2155
|
-
}
|
|
2156
|
-
function isValues(value) {
|
|
2157
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2158
|
-
}
|
|
2159
|
-
function isText(values) {
|
|
2160
|
-
return Object.values(values).every((value) => typeof value === "string");
|
|
2161
|
-
}
|
|
2162
|
-
async function readAdapters(list, adapters, input) {
|
|
2163
|
-
const adapterInput = Object.freeze({
|
|
2164
|
-
environment: input.environment,
|
|
2165
|
-
configDirectory: path.dirname(input.configFile)
|
|
2166
|
-
});
|
|
2167
|
-
const merged = Object.create(null);
|
|
2168
|
-
for (const [index, adapter] of adapters.entries()) {
|
|
2169
|
-
const field = `composer.${list}[${index}]`;
|
|
2170
|
-
let values;
|
|
2171
|
-
try {
|
|
2172
|
-
values = await adapter(adapterInput);
|
|
2173
|
-
} catch (thrown) {
|
|
2174
|
-
throw new CliStructuredError("CONFIG.ADAPTER_FAILED", `\`${field}\` failed to read the values for the environment "${input.environment}".`, {
|
|
2175
|
-
why: `It threw: ${thrown instanceof Error ? thrown.message : String(thrown)}`,
|
|
2176
|
-
fix: `Fix the adapter, or remove it from \`composer.${list}\` in prisma.config.ts.`,
|
|
2177
|
-
where: { path: input.configFile },
|
|
2178
|
-
meta: { field: `${list}[${index}]` },
|
|
2179
|
-
cause: thrown
|
|
2180
|
-
});
|
|
2181
|
-
}
|
|
2182
|
-
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`.");
|
|
2183
|
-
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' }`.");
|
|
2184
|
-
for (const [key, value] of Object.entries(values)) {
|
|
2185
|
-
if (value === void 0) continue;
|
|
2186
|
-
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.");
|
|
2187
|
-
merged[key] = value;
|
|
2188
|
-
}
|
|
2189
|
-
}
|
|
2190
|
-
return Object.freeze(merged);
|
|
2191
|
-
}
|
|
2192
|
-
/** Calls the section's `config` adapters (default `[environmentVariables()]`) and merges what they return: the app configuration. */
|
|
2193
|
-
function readAppConfiguration(section, input) {
|
|
2194
|
-
return readAdapters("config", section.config ?? [environmentVariables()], input);
|
|
2195
|
-
}
|
|
2196
|
-
/**
|
|
2197
|
-
* Calls the section's `secrets` adapters (default `[environmentVariables()]`) and merges what they
|
|
2198
|
-
* return: the app secrets. Every value must be text. A value is a known secret only once the graph
|
|
2199
|
-
* names it, so this adds none.
|
|
2200
|
-
*/
|
|
2201
|
-
async function readAppSecrets(section, input) {
|
|
2202
|
-
const merged = await readAdapters("secrets", section.secrets ?? [environmentVariables()], input);
|
|
2203
|
-
if (!isText(merged)) throw new InternalError("readAdapters admitted a secret that is not text");
|
|
2204
|
-
return merged;
|
|
2205
|
-
}
|
|
1441
|
+
//#region ../../0-framework/3-tooling/cli/dist/load-entry-CEoVBdMj.mjs
|
|
2206
1442
|
/**
|
|
2207
1443
|
* Synchronous Node resolve hook so that entry modules may import relative
|
|
2208
1444
|
* files using the specifier forms TypeScript accepts by default —
|
|
@@ -2220,8 +1456,117 @@ async function readAppSecrets(section, input) {
|
|
|
2220
1456
|
*
|
|
2221
1457
|
* Bun resolves `./x.js` and `./x` to `x.ts` natively, so the hook is a
|
|
2222
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.
|
|
2223
1462
|
*/
|
|
2224
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
|
+
}
|
|
2225
1570
|
/**
|
|
2226
1571
|
* Registers the resolve hook once (idempotent). Call at the start of
|
|
2227
1572
|
* `loadEntry` so every module in the entry graph benefits, including those
|
|
@@ -2233,10 +1578,16 @@ function registerEntryResolution() {
|
|
|
2233
1578
|
registered = true;
|
|
2234
1579
|
mod.registerHooks({ resolve(specifier, context, nextResolve) {
|
|
2235
1580
|
try {
|
|
2236
|
-
|
|
1581
|
+
const resolved = nextResolve(specifier, context);
|
|
1582
|
+
record(resolved.url);
|
|
1583
|
+
return resolved;
|
|
2237
1584
|
} catch (error) {
|
|
2238
1585
|
if (!isRelativeSpecifier(specifier) || context.parentURL === void 0 || !isModuleNotFoundError(error)) throw error;
|
|
2239
|
-
for (const candidate of sourceCandidates(new URL(specifier, context.parentURL))) if (existsSync(fileURLToPath(candidate)))
|
|
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
|
+
}
|
|
2240
1591
|
throw error;
|
|
2241
1592
|
}
|
|
2242
1593
|
} });
|
|
@@ -2246,10 +1597,11 @@ function registerEntryResolution() {
|
|
|
2246
1597
|
* produce the source candidates to probe. Format-specific: `.mjs` maps only
|
|
2247
1598
|
* to `.mts`; `.cjs` maps only to `.cts`; `.js` and extensionless probe
|
|
2248
1599
|
* `.ts`, `.mts`, `.tsx` (keeping `.tsx` so the JSX diagnostic fires), then
|
|
2249
|
-
* `./index.ts`.
|
|
1600
|
+
* `./index.ts`. A URL that already has a TypeScript extension has none.
|
|
2250
1601
|
*/
|
|
2251
1602
|
function sourceCandidates(resolved) {
|
|
2252
1603
|
const href = resolved.href;
|
|
1604
|
+
if (/\.(ts|mts|cts|tsx)$/.test(href)) return [];
|
|
2253
1605
|
if (href.endsWith(".mjs")) {
|
|
2254
1606
|
const base = href.slice(0, -4);
|
|
2255
1607
|
return [new URL(`${base}.mts`)];
|
|
@@ -2267,7 +1619,7 @@ function sourceCandidates(resolved) {
|
|
|
2267
1619
|
];
|
|
2268
1620
|
}
|
|
2269
1621
|
function isRelativeSpecifier(specifier) {
|
|
2270
|
-
return specifier.startsWith("./") || specifier.startsWith("../");
|
|
1622
|
+
return specifier === "." || specifier === ".." || specifier.startsWith("./") || specifier.startsWith("../");
|
|
2271
1623
|
}
|
|
2272
1624
|
function isModuleNotFoundError(error) {
|
|
2273
1625
|
if (!(error instanceof Error)) return false;
|
|
@@ -2317,13 +1669,17 @@ function explainJsxLoadError(error, entryPath) {
|
|
|
2317
1669
|
* an app root built with `appRoot()`, or a module built with `module()`
|
|
2318
1670
|
* (ADR-0003).
|
|
2319
1671
|
*/
|
|
2320
|
-
/**
|
|
2321
|
-
|
|
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) {
|
|
2322
1677
|
registerEntryResolution();
|
|
2323
1678
|
const resolvedPath = path.resolve(cwd, entryArg);
|
|
2324
1679
|
let mod;
|
|
1680
|
+
let files;
|
|
2325
1681
|
try {
|
|
2326
|
-
mod = await import(pathToFileURL(resolvedPath).href);
|
|
1682
|
+
({value: mod, files} = await recordAppFiles(() => import(pathToFileURL(resolvedPath).href), recorded));
|
|
2327
1683
|
} catch (error) {
|
|
2328
1684
|
const explained = explainJsxLoadError(error, resolvedPath);
|
|
2329
1685
|
if (explained !== void 0) throw new CliStructuredError("COMPOSE.ENTRY_UNLOADABLE", explained.summary, {
|
|
@@ -2349,184 +1705,72 @@ async function loadEntry(entryArg, cwd, unloadableFix) {
|
|
|
2349
1705
|
});
|
|
2350
1706
|
return {
|
|
2351
1707
|
path: resolvedPath,
|
|
1708
|
+
files: [.../* @__PURE__ */ new Set([resolvedPath, ...files])],
|
|
2352
1709
|
root
|
|
2353
1710
|
};
|
|
2354
1711
|
}
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
if (ext === void 0) throw new CliStructuredError("CONFIG.EXTENSION_MISSING", `No extension "${extension}" is configured (needed by ${what}).`, {
|
|
2358
|
-
fix: "Add it to `extensions` in the `composer` section of prisma.config.ts (import its /control entry and list its descriptor).",
|
|
2359
|
-
meta: {
|
|
2360
|
-
extension,
|
|
2361
|
-
type
|
|
2362
|
-
}
|
|
2363
|
-
});
|
|
2364
|
-
const descriptor = ext.nodes[type];
|
|
2365
|
-
if (descriptor === void 0) throw new CliStructuredError("CONFIG.DESCRIPTOR_MISSING", `Extension "${extension}" has no descriptor for node type "${type}" (needed by ${what}).`, {
|
|
2366
|
-
why: `Known types: ${Object.keys(ext.nodes).join(", ")}.`,
|
|
2367
|
-
meta: {
|
|
2368
|
-
extension,
|
|
2369
|
-
type
|
|
2370
|
-
}
|
|
2371
|
-
});
|
|
2372
|
-
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: {
|
|
2373
|
-
extension,
|
|
2374
|
-
type,
|
|
2375
|
-
kind: descriptor.kind
|
|
2376
|
-
} });
|
|
2377
|
-
}
|
|
2378
|
-
/** Throws a structured CONFIG.* error on the first uncovered `(extension, type)`; silent when the config covers the whole graph. */
|
|
2379
|
-
function validateRegistryCoverage(graph, config) {
|
|
2380
|
-
const extensions = new Map(config.extensions.map((descriptor) => [descriptor.id, descriptor]));
|
|
2381
|
-
for (const { id, node } of graph.nodes) {
|
|
2382
|
-
if (node.kind === "resource") {
|
|
2383
|
-
lookup(extensions, node.extension, node.type, "resource", `resource node "${id}"`);
|
|
2384
|
-
continue;
|
|
2385
|
-
}
|
|
2386
|
-
if (node.kind !== "service") continue;
|
|
2387
|
-
lookup(extensions, node.extension, node.type, "service", `service node "${id}"`);
|
|
2388
|
-
lookup(extensions, node.build.extension, node.build.type, "build", `service node "${id}"'s build descriptor`);
|
|
2389
|
-
}
|
|
2390
|
-
}
|
|
2391
|
-
/**
|
|
2392
|
-
* The shared prefix of `deploy`/`destroy`/`dev` (deploy-cli.md § The
|
|
2393
|
-
* pipeline; local-dev spec § 6): entry load, Load,
|
|
2394
|
-
* registry coverage validation, name resolution, assemble. Deploy and dev
|
|
2395
|
-
* diverge after this — deploy resolves containers/preflight/stack file
|
|
2396
|
-
* against the hosted providers, dev against the local ones — so everything
|
|
2397
|
-
* up to and including assemble lives here once, consumed verbatim by both
|
|
2398
|
-
* `run()` (main.ts) and `runDev()` (dev/run-dev.ts), so the two pipelines
|
|
2399
|
-
* cannot drift.
|
|
2400
|
-
*/
|
|
2401
|
-
const NO_SECRETS = Object.freeze({});
|
|
2402
|
-
function configError(findings, file) {
|
|
2403
|
-
const [first] = findings;
|
|
2404
|
-
return new CliStructuredError(first.code, first.summary, {
|
|
2405
|
-
...first.why === void 0 ? {} : { why: first.why },
|
|
2406
|
-
fix: first.fix,
|
|
2407
|
-
where: { path: first.where ?? file },
|
|
2408
|
-
meta: {
|
|
2409
|
-
...first.field === void 0 ? {} : { field: first.field },
|
|
2410
|
-
findings
|
|
2411
|
-
}
|
|
2412
|
-
});
|
|
2413
|
-
}
|
|
2414
|
-
/**
|
|
2415
|
-
* Refuses a caller's config with the same findings, in the same order, as the CLI's section validator.
|
|
2416
|
-
* The error is the first finding and carries all of them in `meta.findings`. Returns the config with `file` resolved against `cwd`.
|
|
2417
|
-
*/
|
|
2418
|
-
function checkConfigSource(source, cwd) {
|
|
2419
|
-
const file = path.resolve(cwd, source.file);
|
|
2420
|
-
if (!fs.existsSync(file)) throw configError([configFileMissing(file)], file);
|
|
2421
|
-
const checked = checkComposerConfig(source.value, file);
|
|
2422
|
-
if (!checked.ok) throw configError(checked.findings, file);
|
|
2423
|
-
return {
|
|
2424
|
-
value: checked.value,
|
|
2425
|
-
file
|
|
2426
|
-
};
|
|
2427
|
-
}
|
|
2428
|
-
/**
|
|
2429
|
-
* Resolves the entry module. An override (`--entry`, or an operation's `entry` input) resolves
|
|
2430
|
-
* against `cwd`; the section's `entry` resolves against the directory of the file that declares it,
|
|
2431
|
-
* as the CLI engine resolves path fields in prisma.config.ts.
|
|
2432
|
-
*/
|
|
2433
|
-
function resolveEntryPath(override, source, cwd) {
|
|
2434
|
-
if (override !== void 0) return {
|
|
2435
|
-
path: path.resolve(cwd, override),
|
|
2436
|
-
fix: `Check the \`--entry\` path (the \`entry\` input when calling @prisma/composer/control) "${override}". It is relative to the current directory, ${cwd}.`
|
|
2437
|
-
};
|
|
2438
|
-
const configured = source.value.entry;
|
|
2439
|
-
if (configured === void 0) throw configError([entryMissing], source.file);
|
|
2440
|
-
return {
|
|
2441
|
-
path: path.resolve(path.dirname(source.file), configured),
|
|
2442
|
-
fix: `Check \`entry: "${configured}"\` in ${source.file}. It is relative to that file's directory.`
|
|
2443
|
-
};
|
|
2444
|
-
}
|
|
2445
|
-
/**
|
|
2446
|
-
* The pipeline's front — entry load and name resolution —
|
|
2447
|
-
* WITHOUT Load, coverage, or assemble. `log` needs only who the app is (its
|
|
2448
|
-
* config and resolved name) to reach the already-running local instance; it
|
|
2449
|
-
* neither builds nor provisions, so it must not require the user's built
|
|
2450
|
-
* output the way the full pipeline does.
|
|
2451
|
-
*/
|
|
2452
|
-
async function resolveAppIdentity(entry, overrideName, cwd, config) {
|
|
2453
|
-
const checked = checkConfigSource(config, cwd);
|
|
2454
|
-
const { value } = checked;
|
|
2455
|
-
const resolved = resolveEntryPath(entry, checked, cwd);
|
|
2456
|
-
const entryModule = await loadEntry(resolved.path, cwd, resolved.fix);
|
|
2457
|
-
const name = overrideName ?? entryModule.root.name;
|
|
2458
|
-
if (name.length === 0) throw new CliStructuredError("COMPOSE.NAME_MISSING", "The root node has no name.", { fix: "Name it at authoring, or pass --name." });
|
|
2459
|
-
assertAppName(name);
|
|
2460
|
-
return {
|
|
2461
|
-
config: value,
|
|
2462
|
-
name
|
|
2463
|
-
};
|
|
2464
|
-
}
|
|
1712
|
+
//#endregion
|
|
1713
|
+
//#region ../../0-framework/1-core/core/dist/deploy.mjs
|
|
2465
1714
|
/**
|
|
2466
|
-
*
|
|
2467
|
-
*
|
|
2468
|
-
*
|
|
2469
|
-
*
|
|
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.
|
|
2470
1725
|
*/
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
if (
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
environment,
|
|
2481
|
-
configFile: configSource.file
|
|
2482
|
-
};
|
|
2483
|
-
const secrets = deps.readSecrets === true ? await readAppSecrets(config, adapterInput) : NO_SECRETS;
|
|
2484
|
-
const configuration = await readAppConfiguration(config, adapterInput);
|
|
2485
|
-
redaction.addCredentialLookingValues(credentialLookingValues(configuration));
|
|
2486
|
-
const graph = Load(entryModule.root, {
|
|
2487
|
-
id: name,
|
|
2488
|
-
environment: { name: environment },
|
|
2489
|
-
configuration
|
|
2490
|
-
});
|
|
2491
|
-
redaction.addKnownSecrets(valuesUnderSecretsKeys(configuration, secrets, secretsKeys(graph)));
|
|
2492
|
-
checkGraph(graph, config.extensions);
|
|
2493
|
-
validateRegistryCoverage(graph, config);
|
|
2494
|
-
deps.onEvent?.({ kind: "loaded" });
|
|
2495
|
-
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);
|
|
2496
1735
|
try {
|
|
2497
|
-
|
|
2498
|
-
}
|
|
2499
|
-
|
|
2500
|
-
throw error;
|
|
1736
|
+
return objectAsData(value, (inner) => asData(inner, containing));
|
|
1737
|
+
} finally {
|
|
1738
|
+
containing.delete(value);
|
|
2501
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 };
|
|
2502
1760
|
return {
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
graph,
|
|
2506
|
-
name,
|
|
2507
|
-
assembled,
|
|
2508
|
-
configuration,
|
|
2509
|
-
secrets
|
|
1761
|
+
instance: value.constructor?.name,
|
|
1762
|
+
fields
|
|
2510
1763
|
};
|
|
2511
1764
|
}
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
}
|
|
2520
|
-
/** Letters, digits, `-` and `_`, starting with a letter or digit: always a valid git ref, so no `git` is needed to check it. */
|
|
2521
|
-
const PLAIN_ENVIRONMENT_NAME = /^[A-Za-z0-9][A-Za-z0-9_-]*$/;
|
|
2522
|
-
/** 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. */
|
|
2523
|
-
function validateEnvironmentName(environment, spawn = spawnSync) {
|
|
2524
|
-
if (PLAIN_ENVIRONMENT_NAME.test(environment)) return;
|
|
2525
|
-
const result = spawn("git", ["check-ref-format", `refs/heads/${environment}`], { stdio: "ignore" });
|
|
2526
|
-
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 });
|
|
2527
|
-
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;
|
|
2528
1772
|
}
|
|
2529
1773
|
//#endregion
|
|
2530
|
-
export {
|
|
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 };
|
|
2531
1775
|
|
|
2532
|
-
//# sourceMappingURL=
|
|
1776
|
+
//# sourceMappingURL=deploy-Br1yvLe3.mjs.map
|