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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/dist/app-converge-C_YkTIBF-RmqGOR45.mjs +88 -0
  2. package/dist/app-converge-C_YkTIBF-RmqGOR45.mjs.map +1 -0
  3. package/dist/composer-config-QKdY85G--CEXrb2Uc.mjs +254 -0
  4. package/dist/composer-config-QKdY85G--CEXrb2Uc.mjs.map +1 -0
  5. package/dist/{validate-environment-CpQLC3CA-Ct-PXoKN.mjs → deploy-Br1yvLe3.mjs} +341 -1082
  6. package/dist/deploy-Br1yvLe3.mjs.map +1 -0
  7. package/dist/dev-converge-messages-DML4rTz7-B6uxtpZG.mjs +256 -0
  8. package/dist/dev-converge-messages-DML4rTz7-B6uxtpZG.mjs.map +1 -0
  9. package/dist/dev-converge-worker.d.mts +1 -0
  10. package/dist/dev-converge-worker.mjs +143 -0
  11. package/dist/dev-converge-worker.mjs.map +1 -0
  12. package/dist/{dev-current-D-Qb6Yem-CvaY4xsk.mjs → dev-current-DANgmcle-RwunETUJ.mjs} +12 -18
  13. package/dist/dev-current-DANgmcle-RwunETUJ.mjs.map +1 -0
  14. package/dist/dev-environment-name-6eEr5PW8-CCY7WNWz.mjs +43 -0
  15. package/dist/dev-environment-name-6eEr5PW8-CCY7WNWz.mjs.map +1 -0
  16. package/dist/{dist-BH6HQ6zZ.mjs → dist-C0OGaDnj.mjs} +4 -3
  17. package/dist/{dist-BH6HQ6zZ.mjs.map → dist-C0OGaDnj.mjs.map} +1 -1
  18. package/dist/errors-CVYwN2km.mjs +93 -0
  19. package/dist/errors-CVYwN2km.mjs.map +1 -0
  20. package/dist/{execute-deploy-destroy-C6EsdmLz-DqdToZ_i.mjs → execute-deploy-destroy-DIR9uvA_-Bk0HBMTz.mjs} +385 -141
  21. package/dist/execute-deploy-destroy-DIR9uvA_-Bk0HBMTz.mjs.map +1 -0
  22. package/dist/{execute-dev-gjIKYybU-hRndPEgC.mjs → execute-dev-Cu9_LsQi-CsyIqphZ.mjs} +450 -127
  23. package/dist/execute-dev-Cu9_LsQi-CsyIqphZ.mjs.map +1 -0
  24. package/dist/{execute-dev-current-tBKmDAjV-DOOMGrl5.mjs → execute-dev-current-Bs0lE_5--BU3A2hsC.mjs} +9 -6
  25. package/dist/{execute-dev-current-tBKmDAjV-DOOMGrl5.mjs.map → execute-dev-current-Bs0lE_5--BU3A2hsC.mjs.map} +1 -1
  26. package/dist/{redaction-Bf8FvTFH-D0dXGsO8.d.mts → family-DfwviKFj-CS1L-EvS.d.mts} +484 -204
  27. package/dist/family-DfwviKFj-CS1L-EvS.d.mts.map +1 -0
  28. package/dist/family.d.mts +1 -1
  29. package/dist/family.mjs +350 -270
  30. package/dist/family.mjs.map +1 -1
  31. package/dist/internal-error-Dfur7Zqt-B8J8e7ac.mjs +58 -0
  32. package/dist/internal-error-Dfur7Zqt-B8J8e7ac.mjs.map +1 -0
  33. package/dist/{list-deployed-IL0MgmTX.mjs → list-deployed-slo4P7dl.mjs} +6 -5
  34. package/dist/list-deployed-slo4P7dl.mjs.map +1 -0
  35. package/dist/local-target-CZzICh5R.mjs +34 -0
  36. package/dist/local-target-CZzICh5R.mjs.map +1 -0
  37. package/dist/{config-DiZaanS3.mjs → preflight-transport-2d6iIchu-ArIJUY1L.mjs} +11 -19
  38. package/dist/preflight-transport-2d6iIchu-ArIJUY1L.mjs.map +1 -0
  39. package/dist/{redaction-HnbkSFrK-CCKJNRwi.mjs → redaction-DY6eDC12-BrK1aSN5.mjs} +55 -262
  40. package/dist/redaction-DY6eDC12-BrK1aSN5.mjs.map +1 -0
  41. package/dist/result-CttmabB6.mjs +91 -0
  42. package/dist/result-CttmabB6.mjs.map +1 -0
  43. package/dist/rolldown-runtime-C7HZzL1F.mjs +26 -0
  44. package/dist/steps-BZXNqW6U-BM2Aa8Bp.mjs +287 -0
  45. package/dist/steps-BZXNqW6U-BM2Aa8Bp.mjs.map +1 -0
  46. package/dist/testing.d.mts +4 -49
  47. package/dist/testing.d.mts.map +1 -1
  48. package/dist/testing.mjs +2 -75
  49. package/dist/testing.mjs.map +1 -1
  50. package/dist/validate-environment-DCZiNSlR-idVge-kq.mjs +983 -0
  51. package/dist/validate-environment-DCZiNSlR-idVge-kq.mjs.map +1 -0
  52. package/dist/value-reads-change-text-DcRCv7Zy-Ca8m3bal.mjs +15 -0
  53. package/dist/value-reads-change-text-DcRCv7Zy-Ca8m3bal.mjs.map +1 -0
  54. package/package.json +11 -11
  55. package/src/exports/dev-converge-worker.ts +2 -0
  56. package/src/exports/testing.ts +1 -4
  57. package/dist/app-configuration-file-CeJvBAti-Dk65W3Az.mjs +0 -140
  58. package/dist/app-configuration-file-CeJvBAti-Dk65W3Az.mjs.map +0 -1
  59. package/dist/config-DiZaanS3.mjs.map +0 -1
  60. package/dist/dev-current-D-Qb6Yem-CvaY4xsk.mjs.map +0 -1
  61. package/dist/dev-environment-name-6eEr5PW8-DpdGjmTb.mjs +0 -71
  62. package/dist/dev-environment-name-6eEr5PW8-DpdGjmTb.mjs.map +0 -1
  63. package/dist/execute-deploy-destroy-C6EsdmLz-DqdToZ_i.mjs.map +0 -1
  64. package/dist/execute-dev-gjIKYybU-hRndPEgC.mjs.map +0 -1
  65. package/dist/generate-dev-stack-BV_n-X9n-BDBjgphH.mjs +0 -100
  66. package/dist/generate-dev-stack-BV_n-X9n-BDBjgphH.mjs.map +0 -1
  67. package/dist/list-deployed-IL0MgmTX.mjs.map +0 -1
  68. package/dist/redaction-Bf8FvTFH-D0dXGsO8.d.mts.map +0 -1
  69. package/dist/redaction-HnbkSFrK-CCKJNRwi.mjs.map +0 -1
  70. package/dist/result-sR7PBi61.mjs +0 -229
  71. package/dist/result-sR7PBi61.mjs.map +0 -1
  72. package/dist/run-alchemy-OS_ix5g0-DSlHsv2p.mjs +0 -236
  73. package/dist/run-alchemy-OS_ix5g0-DSlHsv2p.mjs.map +0 -1
  74. package/dist/validate-environment-CpQLC3CA-Ct-PXoKN.mjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preflight-transport-2d6iIchu-ArIJUY1L.mjs","names":[],"sources":["../../../0-framework/1-core/core/dist/preflight-transport-2d6iIchu.mjs"],"sourcesContent":["//#region src/container-transport.ts\n/** '@prisma/composer-prisma-cloud' → 'PRISMA_COMPOSER_PRISMA_CLOUD': uppercased, every non-alphanumeric run replaced by one underscore. */\nfunction envVarSafeExtensionId(extensionId) {\n\treturn extensionId.toUpperCase().replace(/[^A-Z0-9]+/g, \"_\").replace(/^_+|_+$/g, \"\");\n}\n/** '@prisma/composer-prisma-cloud' → 'PRISMA_COMPOSER_CONTAINER_PRISMA_COMPOSER_PRISMA_CLOUD' */\nfunction containerEnvVarName(extensionId) {\n\treturn `PRISMA_COMPOSER_CONTAINER_${envVarSafeExtensionId(extensionId)}`;\n}\nfunction collisionError(a, b, varName) {\n\treturn /* @__PURE__ */ new Error(`Extension ids \"${a}\" and \"${b}\" both map to the container transport variable \"${varName}\" — rename one of the extensions.`);\n}\nfunction emptySerializeError(extensionId) {\n\treturn /* @__PURE__ */ new Error(`Extension \"${extensionId}\"'s container instance serialized to an empty string — ContainerInstance.serialize() must return a non-empty string.`);\n}\n/** The env entries the CLI sets on the alchemy process: `{ [containerEnvVarName(id)]: instance.serialize() }` for every resolved instance. */\nfunction containerEnv(instances) {\n\tconst env = {};\n\tconst ownerByVarName = /* @__PURE__ */ new Map();\n\tfor (const [extensionId, instance] of instances) {\n\t\tconst varName = containerEnvVarName(extensionId);\n\t\tconst owner = ownerByVarName.get(varName);\n\t\tif (owner !== void 0) throw collisionError(owner, extensionId, varName);\n\t\townerByVarName.set(varName, extensionId);\n\t\tconst serialized = instance.serialize();\n\t\tif (serialized.length === 0) throw emptySerializeError(extensionId);\n\t\tenv[varName] = serialized;\n\t}\n\treturn env;\n}\n/**\n* The alchemy-process side: for each extension with a container descriptor\n* whose var is present in `env`, call its deserialize. Absent var → no entry.\n*/\nfunction deserializeContainers(extensions, env) {\n\tconst instances = /* @__PURE__ */ new Map();\n\tfor (const extension of extensions) {\n\t\tconst descriptor = extension.container;\n\t\tif (descriptor === void 0) continue;\n\t\tconst serialized = env[containerEnvVarName(extension.id)];\n\t\tif (serialized === void 0) continue;\n\t\tinstances.set(extension.id, descriptor.deserialize(serialized));\n\t}\n\treturn instances;\n}\n//#endregion\n//#region src/preflight-transport.ts\n/**\n* Carries an extension's preflight payload from the CLI process to\n* `destroy`'s alchemy child (which re-imports the config from scratch); `deploy`\n* and `prisma dev` pass it to `lower()` as a value — one env var per\n* extension, same channel as containers (container-transport.ts), filled by\n* whichever preflight the run executed: the deploy preflight or the local\n* target's dev preflight. The framework never reads the contents, so an\n* extension that implements both must tell its own payload kinds apart.\n* Payloads carry metadata only, never secret values: the child's environment\n* is not a secret store.\n*/\n/** '@prisma/composer-prisma-cloud' → 'PRISMA_COMPOSER_PREFLIGHT_PRISMA_COMPOSER_PRISMA_CLOUD' */\nfunction preflightEnvVarName(extensionId) {\n\treturn `PRISMA_COMPOSER_PREFLIGHT_${envVarSafeExtensionId(extensionId)}`;\n}\n/** The env entries the CLI sets on the alchemy process: `{ [preflightEnvVarName(id)]: payload }` for every extension whose preflight returned one. */\nfunction preflightEnv(payloads) {\n\tconst env = {};\n\tconst ownerByVarName = /* @__PURE__ */ new Map();\n\tfor (const [extensionId, payload] of payloads) {\n\t\tif (payload.length === 0) continue;\n\t\tconst varName = preflightEnvVarName(extensionId);\n\t\tconst owner = ownerByVarName.get(varName);\n\t\tif (owner !== void 0) throw new Error(`Extension ids \"${owner}\" and \"${extensionId}\" both use the environment variable \"${varName}\". Rename one of the extensions.`);\n\t\townerByVarName.set(varName, extensionId);\n\t\tenv[varName] = payload;\n\t}\n\treturn env;\n}\n/** The alchemy-process side: the payload this extension's own preflight wrote, or `undefined` when it wrote none (or when nothing ran a preflight at all). */\nfunction readPreflightPayload(extensionId, env) {\n\tconst payload = env[preflightEnvVarName(extensionId)];\n\treturn payload === void 0 || payload.length === 0 ? void 0 : payload;\n}\n/** One reader as the deploy prints it, for example `read by service \"shop.email\", field \"apiKey\"`. */\nfunction platformVariableReaderText(reader) {\n\tswitch (reader.kind) {\n\t\tcase \"field\": return `read by service \"${reader.service}\", field \"${reader.path === \"\" ? \"(root)\" : reader.path}\"`;\n\t\tcase \"unread\": return `named by resource \"${reader.node}\", read by no service`;\n\t}\n}\n//#endregion\nexport { containerEnv as a, readPreflightPayload as i, preflightEnv as n, containerEnvVarName as o, preflightEnvVarName as r, deserializeContainers as s, platformVariableReaderText as t };\n\n//# sourceMappingURL=preflight-transport-2d6iIchu.mjs.map"],"mappings":";;AAEA,SAAS,sBAAsB,aAAa;CAC3C,OAAO,YAAY,YAAY,CAAC,CAAC,QAAQ,eAAe,GAAG,CAAC,CAAC,QAAQ,YAAY,EAAE;AACpF;;AAEA,SAAS,oBAAoB,aAAa;CACzC,OAAO,6BAA6B,sBAAsB,WAAW;AACtE;AACA,SAAS,eAAe,GAAG,GAAG,SAAS;CACtC,uBAAuB,IAAI,MAAM,kBAAkB,EAAE,SAAS,EAAE,kDAAkD,QAAQ,kCAAkC;AAC7J;AACA,SAAS,oBAAoB,aAAa;CACzC,uBAAuB,IAAI,MAAM,cAAc,YAAY,qHAAqH;AACjL;;AAEA,SAAS,aAAa,WAAW;CAChC,MAAM,MAAM,CAAC;CACb,MAAM,iCAAiC,IAAI,IAAI;CAC/C,KAAK,MAAM,CAAC,aAAa,aAAa,WAAW;EAChD,MAAM,UAAU,oBAAoB,WAAW;EAC/C,MAAM,QAAQ,eAAe,IAAI,OAAO;EACxC,IAAI,UAAU,KAAK,GAAG,MAAM,eAAe,OAAO,aAAa,OAAO;EACtE,eAAe,IAAI,SAAS,WAAW;EACvC,MAAM,aAAa,SAAS,UAAU;EACtC,IAAI,WAAW,WAAW,GAAG,MAAM,oBAAoB,WAAW;EAClE,IAAI,WAAW;CAChB;CACA,OAAO;AACR;;;;;;;;;;;;;AA8BA,SAAS,oBAAoB,aAAa;CACzC,OAAO,6BAA6B,sBAAsB,WAAW;AACtE;;AAqBA,SAAS,2BAA2B,QAAQ;CAC3C,QAAQ,OAAO,MAAf;EACC,KAAK,SAAS,OAAO,oBAAoB,OAAO,QAAQ,YAAY,OAAO,SAAS,KAAK,WAAW,OAAO,KAAK;EAChH,KAAK,UAAU,OAAO,sBAAsB,OAAO,KAAK;CACzD;AACD"}
@@ -1,256 +1,6 @@
1
- import { i as CliStructuredError } from "./result-sR7PBi61.mjs";
2
- import * as fs from "node:fs";
3
- import * as path from "node:path";
4
- //#region ../../0-framework/3-tooling/cli/dist/composer-config-QKdY85G-.mjs
5
- /**
6
- * What makes a `composer` section valid, shared by the CLI's section validator and the programmatic operations.
7
- * It imports nothing from the CLI engine, because `@prisma/composer` must not depend on it.
8
- */
9
- const SECTION_FIX = "Write `composer: composer({ entry: './module.ts', extensions: [...], state: ... })` in prisma.config.ts, with `import { defineConfig as composer } from '@prisma/composer/config'`.";
10
- const MOVE_TO_SECTION_FIX = `${SECTION_FIX} If the project has a prisma-composer.config.ts, move its extensions and state into that section and delete the file.`;
11
- const SECTION_IS_THE_ONLY_SOURCE = "Composer reads its configuration only from the `composer` section of prisma.config.ts.";
12
- const DESCRIPTOR_FIX = "Use the descriptor the extension factory returns, unchanged, instead of building one by hand.";
13
- const RETIRED_FILE_NAMES = [
14
- "ts",
15
- "mts",
16
- "mjs",
17
- "js"
18
- ].map((extension) => `prisma-composer.config.${extension}`);
19
- const sectionMissing = {
20
- code: "CONFIG.SECTION_MISSING",
21
- summary: "No loaded prisma.config.ts declares a `composer` section.",
22
- why: `${SECTION_IS_THE_ONLY_SOURCE} A prisma-composer.config.ts file is no longer read.`,
23
- fix: MOVE_TO_SECTION_FIX
24
- };
25
- /** What the generated stack file throws when the file it imports has no `composer` export. */
26
- function noComposerExportMessage(configFile) {
27
- return `${configFile} declares no \`composer\` section. Pass the prisma.config.ts that declares it.`;
28
- }
29
- function configFileMissing(file) {
30
- return {
31
- code: "CONFIG.FILE_MISSING",
32
- summary: `${file} does not exist.`,
33
- fix: "Pass the path of the prisma.config.ts that declares the `composer` section.",
34
- where: file
35
- };
36
- }
37
- /** A prisma-composer.config.* beside the declaring file would otherwise be silently ignored. */
38
- /** The path with symlinks resolved; the path itself when it cannot be resolved, so the check never throws. */
39
- function realPath(file) {
40
- try {
41
- return fs.realpathSync(file);
42
- } catch {
43
- return file;
44
- }
45
- }
46
- function retiredFileFinding(configFile) {
47
- const directory = path.dirname(realPath(configFile));
48
- const found = RETIRED_FILE_NAMES.map((name) => path.join(directory, name)).find((file) => fs.existsSync(file));
49
- if (found === void 0) return void 0;
50
- return {
51
- code: "CONFIG.FILE_RETIRED",
52
- summary: `${found} is no longer read.`,
53
- why: SECTION_IS_THE_ONLY_SOURCE,
54
- fix: MOVE_TO_SECTION_FIX,
55
- where: found
56
- };
57
- }
58
- function isObject(value) {
59
- return typeof value === "object" && value !== null && !Array.isArray(value);
60
- }
61
- function isExtensionDescriptor(value) {
62
- return isObject(value) && typeof value["id"] === "string" && value["id"].length > 0 && isObject(value["nodes"]);
63
- }
64
- function isStateDescriptor(value) {
65
- return isObject(value) && typeof value["extension"] === "string" && typeof value["create"] === "function";
66
- }
67
- const stateInvalid = {
68
- code: "CONFIG.FIELD_INVALID",
69
- summary: "`composer.state` must be a state descriptor with a string `extension` and a `create` function.",
70
- fix: "Set `state` to the state descriptor an extension provides, e.g. `state: prismaState()`.",
71
- field: "state"
72
- };
73
- const SECTION_FIELDS = /* @__PURE__ */ new Set([
74
- "entry",
75
- "extensions",
76
- "state",
77
- "config",
78
- "secrets"
79
- ]);
80
- const entryInvalid = {
81
- code: "CONFIG.FIELD_INVALID",
82
- summary: "`composer.entry` must be a non-empty string: the path to the module whose default export is the app.",
83
- fix: "Set `entry` to that module's path, relative to prisma.config.ts, e.g. `entry: './module.ts'`.",
84
- field: "entry"
85
- };
86
- /** Neither the section's `entry` nor an override names the module whose default export is the app. */
87
- const entryMissing = {
88
- code: "CONFIG.ENTRY_MISSING",
89
- summary: "No entry module is set, so there is no app to load.",
90
- why: "The entry is the module whose default export is the app root, built with appRoot(...).",
91
- fix: "Set `entry: './module.ts'` in the `composer` section of prisma.config.ts, or pass `--entry <path>` (the `entry` input when calling @prisma/composer/control).",
92
- field: "entry"
93
- };
94
- function unknownField(key) {
95
- return {
96
- code: "CONFIG.FIELD_UNKNOWN",
97
- summary: `The \`composer\` section has no field \`${key}\`.`,
98
- fix: key === "composer" ? "Pass the `composer` property of the prisma.config.ts export, not the whole export. The section takes only `entry`, `extensions`, `state`, `config` and `secrets`." : `Remove \`${key}\`. The section takes only \`entry\`, \`extensions\`, \`state\`, \`config\` and \`secrets\`.`,
99
- field: key
100
- };
101
- }
102
- function checkExtensions(value) {
103
- if (!Array.isArray(value)) return {
104
- extensions: [],
105
- findings: [{
106
- code: "CONFIG.FIELD_INVALID",
107
- summary: "`composer.extensions` must be an array of extension descriptors.",
108
- fix: "Set `extensions` to the descriptors your extensions provide, e.g. `extensions: [nodeBuild()]`.",
109
- field: "extensions"
110
- }]
111
- };
112
- const findings = [];
113
- const extensions = [];
114
- const seen = /* @__PURE__ */ new Set();
115
- for (const [index, entry] of value.entries()) {
116
- const field = `extensions[${index}]`;
117
- if (!isObject(entry)) {
118
- findings.push({
119
- code: "CONFIG.FIELD_INVALID",
120
- summary: `\`composer.${field}\` must be an extension descriptor object.`,
121
- fix: "Put the descriptor an extension factory returns here, e.g. `nodeBuild()`, not the factory itself.",
122
- field
123
- });
124
- continue;
125
- }
126
- const id = entry["id"];
127
- if (typeof id !== "string" || id.length === 0) findings.push({
128
- code: "CONFIG.FIELD_INVALID",
129
- summary: `\`composer.${field}.id\` must be a non-empty string (the extension package name).`,
130
- fix: DESCRIPTOR_FIX,
131
- field: `${field}.id`
132
- });
133
- else if (seen.has(id)) findings.push({
134
- code: "CONFIG.EXTENSION_DUPLICATE",
135
- summary: `Extension "${id}" is listed more than once in \`composer.extensions\`.`,
136
- fix: `Remove the repeated "${id}" entry from \`extensions\`.`,
137
- field: `${field}.id`
138
- });
139
- else seen.add(id);
140
- if (!isObject(entry["nodes"])) findings.push({
141
- code: "CONFIG.FIELD_INVALID",
142
- summary: `\`composer.${field}.nodes\` must be an object (the node-ID → control registry).`,
143
- fix: DESCRIPTOR_FIX,
144
- field: `${field}.nodes`
145
- });
146
- if (isExtensionDescriptor(entry)) extensions.push(entry);
147
- }
148
- return {
149
- findings,
150
- extensions
151
- };
152
- }
153
- function isAdapterList(value) {
154
- return Array.isArray(value) && value.every((entry) => typeof entry === "function");
155
- }
156
- function checkAdapters(list, value) {
157
- if (value === void 0) return [];
158
- if (!Array.isArray(value)) return [{
159
- code: "CONFIG.FIELD_INVALID",
160
- summary: `\`composer.${list}\` must be an array of adapters.`,
161
- fix: `Set \`${list}\` to a list of adapters, e.g. \`${list}: [dotenv(), environmentVariables()]\`, imported from '@prisma/composer/config'.`,
162
- field: list
163
- }];
164
- return value.flatMap((entry, index) => typeof entry === "function" ? [] : [{
165
- code: "CONFIG.FIELD_INVALID",
166
- summary: `\`composer.${list}[${index}]\` must be an adapter: a function that receives the environment and returns its values.`,
167
- fix: "Put an adapter here, e.g. `dotenv()`.",
168
- field: `${list}[${index}]`
169
- }]);
170
- }
171
- function checkFields(section) {
172
- if (Object.hasOwn(section, "configPath")) return {
173
- ok: false,
174
- findings: [{
175
- code: "CONFIG.FIELD_RETIRED",
176
- summary: "`composer.configPath` is no longer supported: prisma-composer.config.ts is no longer read.",
177
- why: SECTION_IS_THE_ONLY_SOURCE,
178
- fix: `Replace \`configPath\` with the section itself. ${MOVE_TO_SECTION_FIX}`,
179
- field: "configPath"
180
- }]
181
- };
182
- if (Object.hasOwn(section, "composer")) return {
183
- ok: false,
184
- findings: [unknownField("composer")]
185
- };
186
- const findings = Object.keys(section).filter((key) => !SECTION_FIELDS.has(key)).map(unknownField);
187
- const checked = checkExtensions(section["extensions"]);
188
- findings.push(...checked.findings);
189
- const state = section["state"];
190
- if (!isStateDescriptor(state)) findings.push(stateInvalid);
191
- const entry = section["entry"];
192
- const entryValid = entry === void 0 || typeof entry === "string" && entry.length > 0;
193
- if (!entryValid) findings.push(entryInvalid);
194
- const config = section["config"];
195
- const secrets = section["secrets"];
196
- findings.push(...checkAdapters("config", config), ...checkAdapters("secrets", secrets));
197
- const [first, ...rest] = findings;
198
- if (first === void 0 && isStateDescriptor(state) && entryValid && (config === void 0 || isAdapterList(config)) && (secrets === void 0 || isAdapterList(secrets))) return {
199
- ok: true,
200
- value: {
201
- extensions: checked.extensions,
202
- state,
203
- ...entry === void 0 ? {} : { entry },
204
- ...config === void 0 ? {} : { config },
205
- ...secrets === void 0 ? {} : { secrets }
206
- }
207
- };
208
- return {
209
- ok: false,
210
- findings: [first ?? stateInvalid, ...rest]
211
- };
212
- }
213
- /**
214
- * Checks the fields that identify each descriptor and returns the descriptors as the config file's own objects.
215
- * Never throws: a section's values are user code, and a throwing getter or Proxy trap becomes a finding.
216
- */
217
- function checkComposerSection(raw) {
218
- if (!isObject(raw)) return {
219
- ok: false,
220
- findings: [{
221
- code: "CONFIG.FIELD_INVALID",
222
- summary: "The `composer` section of prisma.config.ts must be an object.",
223
- fix: SECTION_FIX
224
- }]
225
- };
226
- try {
227
- return checkFields({ ...raw });
228
- } catch (cause) {
229
- return {
230
- ok: false,
231
- findings: [{
232
- code: "CONFIG.FIELD_INVALID",
233
- summary: "The `composer` section of prisma.config.ts could not be read.",
234
- why: `Reading it threw: ${cause instanceof Error ? cause.message : String(cause)}`,
235
- fix: SECTION_FIX
236
- }]
237
- };
238
- }
239
- }
240
- /**
241
- * The whole check, shared by the section validator and the programmatic operations so both report the same findings in the same order: the retired file beside the declaring `configFile` (resolved through symlinks), then every field finding.
242
- */
243
- function checkComposerConfig(raw, configFile) {
244
- const retired = retiredFileFinding(configFile);
245
- const checked = checkComposerSection(raw);
246
- if (retired === void 0) return checked;
247
- return {
248
- ok: false,
249
- findings: checked.ok ? [retired] : [retired, ...checked.findings]
250
- };
251
- }
252
- //#endregion
253
- //#region ../../0-framework/3-tooling/cli/dist/redaction-HnbkSFrK.mjs
1
+ import { t as CliStructuredError } from "./errors-CVYwN2km.mjs";
2
+ import { inspect } from "node:util";
3
+ //#region ../../0-framework/3-tooling/cli/dist/redaction-DY6eDC12.mjs
254
4
  const REDACTED = "[redacted]";
255
5
  /** Env var names whose values are credentials: the service token, preflight payloads, and the usual secret spellings. */
256
6
  const SECRET_ENV_NAME = /TOKEN|SECRET|PASSWORD|PASSWD|PRIVATE|CREDENTIAL|AUTH|API_?KEY|ACCESS_?KEY|_KEY$|DATABASE_URL|_DSN$|^PRISMA_COMPOSER_PREFLIGHT_/i;
@@ -262,17 +12,26 @@ const SECRET_ENV_NAME = /TOKEN|SECRET|PASSWORD|PASSWD|PRIVATE|CREDENTIAL|AUTH|AP
262
12
  function credentialLookingValues(variables) {
263
13
  return Object.entries(variables).flatMap(([name, value]) => SECRET_ENV_NAME.test(name) && typeof value === "string" && value.length >= 8 ? [value] : []);
264
14
  }
15
+ /** `value` as it appears inside a string that `JSON.stringify` or `util.inspect` printed, where a newline, quote or backslash is escaped. */
16
+ function escapedForms(value) {
17
+ return [
18
+ value,
19
+ JSON.stringify(value).slice(1, -1),
20
+ inspect(value).slice(1, -1)
21
+ ];
22
+ }
265
23
  /**
266
- * Finds every secret in a text: one regular expression for all of them, built once. A match
267
- * is the span of the longest secret that starts at a position, and spans that overlap are
268
- * merged, so two overlapping secrets are hidden whole.
24
+ * Finds every secret in a text, as written or as `JSON.stringify` and `util.format` escape it:
25
+ * one regular expression for all of them, built once. A match is the span of the longest
26
+ * secret that starts at a position, and spans that overlap are merged, so two overlapping
27
+ * secrets are hidden whole.
269
28
  */
270
29
  var SecretMatcher = class {
271
30
  starts;
272
31
  prefixes = /* @__PURE__ */ new Set();
273
32
  longestPrefix;
274
33
  constructor(values) {
275
- const sorted = [...new Set(values)].filter((value) => value.length > 0).sort((a, b) => b.length - a.length);
34
+ const sorted = [...new Set([...values].flatMap(escapedForms))].filter((value) => value.length > 0).sort((a, b) => b.length - a.length);
276
35
  this.starts = sorted.length === 0 ? void 0 : new RegExp(`(?=(${sorted.map((value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|")}))`, "g");
277
36
  for (const value of sorted) for (let length = 1; length < value.length; length++) this.prefixes.add(value.slice(0, length));
278
37
  this.longestPrefix = Math.max(0, (sorted[0]?.length ?? 0) - 1);
@@ -306,9 +65,9 @@ var SecretMatcher = class {
306
65
  return from === 0 ? text : out + text.slice(from);
307
66
  }
308
67
  };
309
- /** `text` with bearer and basic tokens, JWTs, the password in a URL, and `token=…`-style pairs replaced by `[redacted]`. */
68
+ /** `text` with bearer and basic tokens, JWTs, the password in a URL, and `token=…`-style pairs replaced by `[redacted]`. The `<value>` placeholder in a printed command is kept. */
310
69
  function redactShapes(text) {
311
- return text.replace(/\b(Bearer|Basic)\s+[\w.~+/=-]+/gi, `$1 ${REDACTED}`).replace(/\beyJ[\w-]+\.[\w-]+\.[\w-]*/g, REDACTED).replace(/(\b[a-z][\w+.-]*:\/\/[^\s:/@]*:)[^\s/@]+@/gi, `$1${REDACTED}@`).replace(/\b((?:[\w-]*[_-])?(?:token|secret|password|passwd|api[_-]?key|access[_-]?key|private[_-]?key)["']?\s*[:=]\s*["']?)[^\s"',;&]+/gi, `$1${REDACTED}`);
70
+ return text.replace(/\b(Bearer|Basic)\s+[\w.~+/=-]+/gi, `$1 ${REDACTED}`).replace(/\beyJ[\w-]+\.[\w-]+\.[\w-]*/g, REDACTED).replace(/(\b[a-z][\w+.-]*:\/\/[^\s:/@]*:)[^\s/@]+@/gi, `$1${REDACTED}@`).replace(/\b((?:[\w-]*[_-])?(?:token|secret|password|passwd|api[_-]?key|access[_-]?key|private[_-]?key)["']?\s*[:=]\s*["']?)(?!<value>(?:[\s"',;&]|$))[^\s"',;&]+/gi, `$1${REDACTED}`);
312
71
  }
313
72
  /**
314
73
  * The known secrets of one command: the values under the secrets keys the graph names, in the app
@@ -375,6 +134,27 @@ function valuesUnderSecretsKeys(configuration, secrets, secretsKeys) {
375
134
  value
376
135
  }] : []));
377
136
  }
137
+ function redactReader(reader, redaction) {
138
+ switch (reader.kind) {
139
+ case "field": return {
140
+ kind: "field",
141
+ service: redaction.redact(reader.service),
142
+ path: redaction.redact(reader.path)
143
+ };
144
+ case "unread": return {
145
+ kind: "unread",
146
+ node: redaction.redact(reader.node)
147
+ };
148
+ }
149
+ }
150
+ /** `variable` with every text in it redacted: its name, each reader's names and each command. */
151
+ function redactUnsetPlatformVariable(variable, redaction) {
152
+ return {
153
+ name: redaction.redact(variable.name),
154
+ readers: variable.readers.map((reader) => redactReader(reader, redaction)),
155
+ commands: variable.commands.map((command) => redaction.redact(command))
156
+ };
157
+ }
378
158
  function redactData(value, redaction) {
379
159
  if (typeof value === "string") return redaction.redact(value);
380
160
  if (Array.isArray(value)) return value.map((member) => redactData(member, redaction));
@@ -454,7 +234,7 @@ function redactErrorChain(error, redaction, seen) {
454
234
  return copy;
455
235
  }
456
236
  }
457
- /** `event` with every value `redaction` hides removed from the text it carries: a message, or a dev server's output line. */
237
+ /** `event` with every value `redaction` hides removed from the text it carries: a message, an Alchemy log line, a converge failure's reasons, or a dev server's output line. */
458
238
  function redactDevEvent(event, redaction) {
459
239
  switch (event.kind) {
460
240
  case "target-warning":
@@ -464,6 +244,18 @@ function redactDevEvent(event, redaction) {
464
244
  ...event,
465
245
  message: redaction.redact(event.message)
466
246
  };
247
+ case "message": return {
248
+ ...event,
249
+ text: redaction.redact(event.text)
250
+ };
251
+ case "converge-failed": return {
252
+ ...event,
253
+ message: redaction.redact(event.message),
254
+ reasons: event.reasons.map(({ tag, message }) => ({
255
+ tag,
256
+ message: redaction.redact(message)
257
+ }))
258
+ };
467
259
  case "dev-server-output": return {
468
260
  ...event,
469
261
  line: redaction.redact(event.line)
@@ -476,6 +268,7 @@ function redactSummary(summary, redaction) {
476
268
  if (summary === void 0) return void 0;
477
269
  return {
478
270
  app: summary.app,
271
+ findings: { unset: summary.findings.unset.map((variable) => redactUnsetPlatformVariable(variable, redaction)) },
479
272
  nodes: summary.nodes.map((node) => ({
480
273
  address: node.address,
481
274
  entities: node.entities.map((entity) => ({
@@ -529,6 +322,6 @@ var StreamRedactor = class {
529
322
  }
530
323
  };
531
324
  //#endregion
532
- export { redactDevEvent as a, redactThrown as c, configFileMissing as d, entryMissing as f, credentialLookingValues as i, valuesUnderSecretsKeys as l, sectionMissing as m, SecretRedaction as n, redactError as o, noComposerExportMessage as p, StreamRedactor as r, redactSummary as s, KnownSecrets as t, checkComposerConfig as u };
325
+ export { redactError as a, redactUnsetPlatformVariable as c, redactDevEvent as i, valuesUnderSecretsKeys as l, StreamRedactor as n, redactSummary as o, credentialLookingValues as r, redactThrown as s, SecretRedaction as t };
533
326
 
534
- //# sourceMappingURL=redaction-HnbkSFrK-CCKJNRwi.mjs.map
327
+ //# sourceMappingURL=redaction-DY6eDC12-BrK1aSN5.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redaction-DY6eDC12-BrK1aSN5.mjs","names":["#names"],"sources":["../../../0-framework/3-tooling/cli/dist/redaction-DY6eDC12.mjs"],"sourcesContent":["import { CliStructuredError } from \"@internal/foundation/errors\";\nimport { inspect } from \"node:util\";\n//#region src/redaction.ts\nconst REDACTED = \"[redacted]\";\n/** Env var names whose values are credentials: the service token, preflight payloads, and the usual secret spellings. */\nconst SECRET_ENV_NAME = /TOKEN|SECRET|PASSWORD|PASSWD|PRIVATE|CREDENTIAL|AUTH|API_?KEY|ACCESS_?KEY|_KEY$|DATABASE_URL|_DSN$|^PRISMA_COMPOSER_PREFLIGHT_/i;\n/**\n* The credential-looking values in `variables`: text of eight characters or more under a name\n* that looks like a credential's. The length limit keeps a one-letter placeholder from blanking\n* every matching letter.\n*/\nfunction credentialLookingValues(variables) {\n\treturn Object.entries(variables).flatMap(([name, value]) => SECRET_ENV_NAME.test(name) && typeof value === \"string\" && value.length >= 8 ? [value] : []);\n}\n/** `value` as it appears inside a string that `JSON.stringify` or `util.inspect` printed, where a newline, quote or backslash is escaped. */\nfunction escapedForms(value) {\n\treturn [\n\t\tvalue,\n\t\tJSON.stringify(value).slice(1, -1),\n\t\tinspect(value).slice(1, -1)\n\t];\n}\n/**\n* Finds every secret in a text, as written or as `JSON.stringify` and `util.format` escape it:\n* one regular expression for all of them, built once. A match is the span of the longest\n* secret that starts at a position, and spans that overlap are merged, so two overlapping\n* secrets are hidden whole.\n*/\nvar SecretMatcher = class {\n\tstarts;\n\tprefixes = /* @__PURE__ */ new Set();\n\tlongestPrefix;\n\tconstructor(values) {\n\t\tconst sorted = [...new Set([...values].flatMap(escapedForms))].filter((value) => value.length > 0).sort((a, b) => b.length - a.length);\n\t\tthis.starts = sorted.length === 0 ? void 0 : new RegExp(`(?=(${sorted.map((value) => value.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\")).join(\"|\")}))`, \"g\");\n\t\tfor (const value of sorted) for (let length = 1; length < value.length; length++) this.prefixes.add(value.slice(0, length));\n\t\tthis.longestPrefix = Math.max(0, (sorted[0]?.length ?? 0) - 1);\n\t}\n\t/** The merged spans of every secret in `text`, in order, as `[start, end)`. */\n\tspans(text) {\n\t\tconst spans = [];\n\t\tif (this.starts === void 0) return spans;\n\t\tfor (const match of text.matchAll(this.starts)) {\n\t\t\tconst start = match.index;\n\t\t\tconst end = start + (match[1]?.length ?? 0);\n\t\t\tconst last = spans.at(-1);\n\t\t\tif (last !== void 0 && start < last[1]) last[1] = Math.max(last[1], end);\n\t\t\telse spans.push([start, end]);\n\t\t}\n\t\treturn spans;\n\t}\n\t/** The length of the longest end of `text` that is the start, not the whole, of a secret. */\n\tstartOfSecretAtEnd(text) {\n\t\tfor (let length = Math.min(this.longestPrefix, text.length); length > 0; length--) if (this.prefixes.has(text.slice(text.length - length))) return length;\n\t\treturn 0;\n\t}\n\t/** `text` with each span replaced by `[redacted]`. */\n\tredact(text) {\n\t\tlet out = \"\";\n\t\tlet from = 0;\n\t\tfor (const [start, end] of this.spans(text)) {\n\t\t\tout += text.slice(from, start) + REDACTED;\n\t\t\tfrom = end;\n\t\t}\n\t\treturn from === 0 ? text : out + text.slice(from);\n\t}\n};\n/** `text` with each value in `values` replaced by `[redacted]`, at any length; an empty one is skipped. Overlapping values are hidden whole. */\nfunction redactValues(text, values) {\n\treturn new SecretMatcher(values).redact(text);\n}\n/** `text` with bearer and basic tokens, JWTs, the password in a URL, and `token=…`-style pairs replaced by `[redacted]`. The `<value>` placeholder in a printed command is kept. */\nfunction redactShapes(text) {\n\treturn text.replace(/\\b(Bearer|Basic)\\s+[\\w.~+/=-]+/gi, `$1 ${REDACTED}`).replace(/\\beyJ[\\w-]+\\.[\\w-]+\\.[\\w-]*/g, REDACTED).replace(/(\\b[a-z][\\w+.-]*:\\/\\/[^\\s:/@]*:)[^\\s/@]+@/gi, `$1${REDACTED}@`).replace(/\\b((?:[\\w-]*[_-])?(?:token|secret|password|passwd|api[_-]?key|access[_-]?key|private[_-]?key)[\"']?\\s*[:=]\\s*[\"']?)(?!<value>(?:[\\s\"',;&]|$))[^\\s\"',;&]+/gi, `$1${REDACTED}`);\n}\n/**\n* `text` with the credential-looking values of `env` and the credential shapes replaced by\n* `[redacted]`. For a process that has no `SecretRedaction`; `SecretRedaction.redact` hides\n* the known secrets too.\n*/\nfunction redactCredentialLooking(text, env) {\n\treturn redactShapes(redactValues(text, credentialLookingValues(env)));\n}\n/**\n* The known secrets of one command: the values under the secrets keys the graph names, in the app\n* secrets and the app configuration (ADR-0062). The app configuration file must not hold any of them.\n*/\nvar KnownSecrets = class {\n\t#names = /* @__PURE__ */ new Map();\n\tconstructor(secrets = []) {\n\t\tthis.add(secrets);\n\t}\n\t/** Adds each secret whose value is not empty. A value already known keeps its first name. */\n\tadd(secrets) {\n\t\tfor (const { name, value } of secrets) if (value.length > 0 && !this.#names.has(value)) this.#names.set(value, name);\n\t}\n\tvalues() {\n\t\treturn new Set(this.#names.keys());\n\t}\n\t/**\n\t* The name of a known secret `text` holds, or undefined. A secret of\n\t* `MIN_SECRET_LENGTH_INSIDE_A_VALUE` characters or more is found anywhere in `text`; a shorter\n\t* one only when it is all of `text`.\n\t*/\n\tnameIn(text) {\n\t\tfor (const [value, name] of this.#names) if (value.length >= 8 ? text.includes(value) : text === value) return name;\n\t}\n};\n/**\n* What one command hides from everything it prints, returns or reports (ADR-0062): its known\n* secrets, and the credential-looking values, which only look like secrets by the name of the\n* variable they are under. It starts with the credential-looking values of the process\n* environment.\n*/\nvar SecretRedaction = class {\n\tknownSecrets = new KnownSecrets();\n\tcredentialLooking = /* @__PURE__ */ new Set();\n\tmatcher;\n\tconstructor(env) {\n\t\tthis.addCredentialLookingValues(credentialLookingValues(env));\n\t}\n\taddKnownSecrets(secrets) {\n\t\tthis.knownSecrets.add(secrets);\n\t}\n\taddCredentialLookingValues(values) {\n\t\tfor (const value of values) if (value.length > 0) this.credentialLooking.add(value);\n\t}\n\t/** The known secrets and the credential-looking values, longest first. */\n\tallValues() {\n\t\treturn [.../* @__PURE__ */ new Set([...this.knownSecrets.values(), ...this.credentialLooking])].sort((a, b) => b.length - a.length);\n\t}\n\t/** `text` with every known secret and credential-looking value replaced by `[redacted]` at any length, then bearer tokens, JWTs, URL passwords and `token=…` pairs. */\n\tredact(text) {\n\t\tconst size = this.knownSecrets.values().size + this.credentialLooking.size;\n\t\tif (this.matcher?.size !== size) this.matcher = {\n\t\t\tsize,\n\t\t\tmatcher: new SecretMatcher(this.allValues())\n\t\t};\n\t\treturn redactShapes(this.matcher.matcher.redact(text));\n\t}\n};\n/** The text under each name in `secretsKeys`, in the app configuration and in the app secrets, at any length. */\nfunction valuesUnderSecretsKeys(configuration, secrets, secretsKeys) {\n\treturn secretsKeys.flatMap((name) => [configuration[name], secrets[name]].flatMap((value) => typeof value === \"string\" ? [{\n\t\tname,\n\t\tvalue\n\t}] : []));\n}\nfunction redactReader(reader, redaction) {\n\tswitch (reader.kind) {\n\t\tcase \"field\": return {\n\t\t\tkind: \"field\",\n\t\t\tservice: redaction.redact(reader.service),\n\t\t\tpath: redaction.redact(reader.path)\n\t\t};\n\t\tcase \"unread\": return {\n\t\t\tkind: \"unread\",\n\t\t\tnode: redaction.redact(reader.node)\n\t\t};\n\t}\n}\n/** `variable` with every text in it redacted: its name, each reader's names and each command. */\nfunction redactUnsetPlatformVariable(variable, redaction) {\n\treturn {\n\t\tname: redaction.redact(variable.name),\n\t\treaders: variable.readers.map((reader) => redactReader(reader, redaction)),\n\t\tcommands: variable.commands.map((command) => redaction.redact(command))\n\t};\n}\nfunction redactData(value, redaction) {\n\tif (typeof value === \"string\") return redaction.redact(value);\n\tif (Array.isArray(value)) return value.map((member) => redactData(member, redaction));\n\tif (typeof value === \"object\" && value !== null && Object.getPrototypeOf(value) === Object.prototype) return Object.fromEntries(Object.entries(value).map(([key, member]) => [key, redactData(member, redaction)]));\n\treturn value;\n}\n/**\n* `error` with every value `redaction` hides removed from its summary, `why`, `fix` and every string in\n* its `meta`. The code, severity, `where` and docs link are kept. The cause is dropped, because\n* it holds the same text unredacted and a renderer may print it.\n*/\nfunction redactError(error, redaction) {\n\treturn new CliStructuredError(error.code, redaction.redact(error.message), {\n\t\tseverity: error.severity,\n\t\t...error.why === void 0 ? {} : { why: redaction.redact(error.why) },\n\t\t...error.fix === void 0 ? {} : { fix: redaction.redact(error.fix) },\n\t\t...error.where === void 0 ? {} : { where: error.where },\n\t\t...error.meta === void 0 ? {} : { meta: Object.fromEntries(Object.entries(error.meta).map(([key, value]) => [key, redactData(value, redaction)])) },\n\t\t...error.docsUrl === void 0 ? {} : { docsUrl: error.docsUrl }\n\t});\n}\nfunction setOwn(error, name, value) {\n\tObject.defineProperty(error, name, {\n\t\tvalue,\n\t\twritable: true,\n\t\tconfigurable: true\n\t});\n}\nconst UNPRINTABLE = \"A value was thrown that cannot be turned into text.\";\nfunction safeString(value) {\n\ttry {\n\t\treturn String(value);\n\t} catch {\n\t\ttry {\n\t\t\treturn Object.prototype.toString.call(value);\n\t\t} catch {\n\t\t\treturn UNPRINTABLE;\n\t\t}\n\t}\n}\n/**\n* The error to rethrow in place of a thrown defect, with every secret removed from its message\n* and stack, and from those of each error in its `cause` chain and in an `AggregateError`'s\n* `errors`. A cause that is text or plain data becomes a redacted copy. Each error is redacted\n* in place where it can be. One whose properties cannot change, such as a frozen error, is\n* replaced by a new error with the redacted message, stack and cause. A thrown value that is not\n* an `Error` becomes an `Error` whose message is its redacted text. Never throws: when reading\n* the error fails, the result is a new `Error` holding the redacted text of what was thrown.\n*/\nfunction redactThrown(thrown, redaction) {\n\ttry {\n\t\treturn thrown instanceof Error ? redactErrorChain(thrown, redaction, /* @__PURE__ */ new Map()) : new Error(redaction.redact(safeString(thrown)));\n\t} catch {\n\t\treturn new Error(redaction.redact(safeString(thrown)));\n\t}\n}\nfunction redactErrorChain(error, redaction, seen) {\n\tconst done = seen.get(error);\n\tif (done !== void 0) return done;\n\tseen.set(error, error);\n\tconst message = redaction.redact(typeof error.message === \"string\" ? error.message : safeString(error.message));\n\tconst stack = typeof error.stack === \"string\" ? redaction.redact(error.stack) : void 0;\n\tconst cause = error.cause instanceof Error ? redactErrorChain(error.cause, redaction, seen) : redactData(error.cause, redaction);\n\tconst members = error instanceof AggregateError ? error.errors.map((member) => member instanceof Error ? redactErrorChain(member, redaction, seen) : redactData(member, redaction)) : void 0;\n\ttry {\n\t\tsetOwn(error, \"message\", message);\n\t\tif (stack !== void 0) setOwn(error, \"stack\", stack);\n\t\tif (error.cause !== void 0) setOwn(error, \"cause\", cause);\n\t\tif (members !== void 0) setOwn(error, \"errors\", members);\n\t\treturn error;\n\t} catch {\n\t\tconst options = cause === void 0 ? void 0 : { cause };\n\t\tconst copy = members === void 0 ? new Error(message, options) : new AggregateError(members, message, options);\n\t\tcopy.name = error.name;\n\t\tsetOwn(copy, \"stack\", stack ?? `${error.name}: ${message}`);\n\t\tseen.set(error, copy);\n\t\treturn copy;\n\t}\n}\n/** `event` with every value `redaction` hides removed from the text it carries: a message, an Alchemy log line, a converge failure's reasons, or a dev server's output line. */\nfunction redactDevEvent(event, redaction) {\n\tswitch (event.kind) {\n\t\tcase \"target-warning\":\n\t\tcase \"rebuild-failed\":\n\t\tcase \"watch-error\":\n\t\tcase \"stop-error\": return {\n\t\t\t...event,\n\t\t\tmessage: redaction.redact(event.message)\n\t\t};\n\t\tcase \"message\": return {\n\t\t\t...event,\n\t\t\ttext: redaction.redact(event.text)\n\t\t};\n\t\tcase \"converge-failed\": return {\n\t\t\t...event,\n\t\t\tmessage: redaction.redact(event.message),\n\t\t\treasons: event.reasons.map(({ tag, message }) => ({\n\t\t\t\ttag,\n\t\t\t\tmessage: redaction.redact(message)\n\t\t\t}))\n\t\t};\n\t\tcase \"dev-server-output\": return {\n\t\t\t...event,\n\t\t\tline: redaction.redact(event.line)\n\t\t};\n\t\tdefault: return event;\n\t}\n}\n/** `summary` with every value `redaction` hides removed from each entity's id, url and details. */\nfunction redactSummary(summary, redaction) {\n\tif (summary === void 0) return void 0;\n\treturn {\n\t\tapp: summary.app,\n\t\tfindings: { unset: summary.findings.unset.map((variable) => redactUnsetPlatformVariable(variable, redaction)) },\n\t\tnodes: summary.nodes.map((node) => ({\n\t\t\taddress: node.address,\n\t\t\tentities: node.entities.map((entity) => ({\n\t\t\t\t...entity,\n\t\t\t\tid: redaction.redact(entity.id),\n\t\t\t\t...entity.url === void 0 ? {} : { url: redaction.redact(entity.url) },\n\t\t\t\t...entity.details === void 0 ? {} : { details: Object.fromEntries(Object.entries(entity.details).map(([key, value]) => [key, redaction.redact(value)])) }\n\t\t\t}))\n\t\t}))\n\t};\n}\nfunction isHighSurrogate(code) {\n\treturn code >= 55296 && code <= 56319;\n}\n/**\n* Redacts a stream of text chunk by chunk: every value in `values` becomes `[redacted]`, and\n* overlapping values are hidden whole. It holds back only the end of the text that could still\n* be part of a value: the longest end that could start one, or a match that a later value could\n* extend. So a value split across two chunks is still replaced, and text that cannot start one,\n* such as a prompt, is returned at once. It never splits a surrogate pair. `push` returns the\n* text that is ready; `end` returns the rest.\n*/\nvar StreamRedactor = class {\n\theld = \"\";\n\tmatcher;\n\tconstructor(values) {\n\t\tthis.matcher = new SecretMatcher(values);\n\t}\n\tpush(chunk) {\n\t\tconst text = this.held + chunk;\n\t\tconst cut = text.length - this.matcher.startOfSecretAtEnd(text);\n\t\tlet out = \"\";\n\t\tlet from = 0;\n\t\tlet ready = cut;\n\t\tfor (const [start, end] of this.matcher.spans(text)) {\n\t\t\tif (end > cut) {\n\t\t\t\tready = Math.min(cut, start);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout += text.slice(from, start) + REDACTED;\n\t\t\tfrom = end;\n\t\t}\n\t\tif (ready > from && ready < text.length && isHighSurrogate(text.charCodeAt(ready - 1))) ready -= 1;\n\t\tthis.held = text.slice(ready);\n\t\treturn out + text.slice(from, ready);\n\t}\n\tend() {\n\t\tconst text = this.held;\n\t\tthis.held = \"\";\n\t\treturn this.matcher.redact(text);\n\t}\n};\n//#endregion\nexport { redactDevEvent as a, redactThrown as c, redactCredentialLooking as i, redactUnsetPlatformVariable as l, StreamRedactor as n, redactError as o, credentialLookingValues as r, redactSummary as s, SecretRedaction as t, valuesUnderSecretsKeys as u };\n\n//# sourceMappingURL=redaction-DY6eDC12.mjs.map"],"mappings":";;;AAGA,MAAM,WAAW;;AAEjB,MAAM,kBAAkB;;;;;;AAMxB,SAAS,wBAAwB,WAAW;CAC3C,OAAO,OAAO,QAAQ,SAAS,CAAC,CAAC,SAAS,CAAC,MAAM,WAAW,gBAAgB,KAAK,IAAI,KAAK,OAAO,UAAU,YAAY,MAAM,UAAU,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC;AACxJ;;AAEA,SAAS,aAAa,OAAO;CAC5B,OAAO;EACN;EACA,KAAK,UAAU,KAAK,CAAC,CAAC,MAAM,GAAG,EAAE;EACjC,QAAQ,KAAK,CAAC,CAAC,MAAM,GAAG,EAAE;CAC3B;AACD;;;;;;;AAOA,IAAI,gBAAgB,MAAM;CACzB;CACA,2BAA2B,IAAI,IAAI;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AE;CACH;AACD;AACA,SAAS,gBAAgB,MAAM;CAC9B,OAAO,QAAQ,SAAS,QAAQ;AACjC;;;;;;;;;AASA,IAAI,iBAAiB,MAAM;CAC1B,OAAO;CACP;CACA,YAAY,QAAQ;EACnB,KAAK,UAAU,IAAI,cAAc,MAAM;CACxC;CACA,KAAK,OAAO;EACX,MAAM,OAAO,KAAK,OAAO;EACzB,MAAM,MAAM,KAAK,SAAS,KAAK,QAAQ,mBAAmB,IAAI;EAC9D,IAAI,MAAM;EACV,IAAI,OAAO;EACX,IAAI,QAAQ;EACZ,KAAK,MAAM,CAAC,OAAO,QAAQ,KAAK,QAAQ,MAAM,IAAI,GAAG;GACpD,IAAI,MAAM,KAAK;IACd,QAAQ,KAAK,IAAI,KAAK,KAAK;IAC3B;GACD;GACA,OAAO,KAAK,MAAM,MAAM,KAAK,IAAI;GACjC,OAAO;EACR;EACA,IAAI,QAAQ,QAAQ,QAAQ,KAAK,UAAU,gBAAgB,KAAK,WAAW,QAAQ,CAAC,CAAC,GAAG,SAAS;EACjG,KAAK,OAAO,KAAK,MAAM,KAAK;EAC5B,OAAO,MAAM,KAAK,MAAM,MAAM,KAAK;CACpC;CACA,MAAM;EACL,MAAM,OAAO,KAAK;EAClB,KAAK,OAAO;EACZ,OAAO,KAAK,QAAQ,OAAO,IAAI;CAChC;AACD"}
@@ -0,0 +1,91 @@
1
+ import { n as blindCast, t as InternalError } from "./internal-error-Dfur7Zqt-B8J8e7ac.mjs";
2
+ //#region ../../0-framework/0-foundation/foundation/dist/result.mjs
3
+ /**
4
+ * Generic Result type for representing success or failure outcomes.
5
+ *
6
+ * This is the standard way to return "expected failures" as values rather than
7
+ * throwing exceptions. See docs/Error Handling.md for the full taxonomy.
8
+ *
9
+ * Naming rationale:
10
+ * - `Ok<T>` / `NotOk<F>` mirror the `ok: true/false` discriminator
11
+ * - `NotOk` avoids collision with domain types like "Failure" or "Error"
12
+ * - `failure` property distinguishes from JS Error semantics
13
+ */
14
+ /**
15
+ * Result class that implements both Ok and NotOk variants.
16
+ */
17
+ var ResultImpl = class ResultImpl {
18
+ ok;
19
+ _value;
20
+ _failure;
21
+ constructor(ok, valueOrFailure) {
22
+ this.ok = ok;
23
+ if (ok) this._value = blindCast(valueOrFailure);
24
+ else this._failure = blindCast(valueOrFailure);
25
+ Object.freeze(this);
26
+ }
27
+ get value() {
28
+ if (!this.ok) throw new InternalError("Cannot access value on NotOk result");
29
+ return this._value;
30
+ }
31
+ get failure() {
32
+ if (this.ok) throw new InternalError("Cannot access failure on Ok result");
33
+ return this._failure;
34
+ }
35
+ /**
36
+ * Creates a successful result.
37
+ */
38
+ static ok(value) {
39
+ return blindCast(new ResultImpl(true, value));
40
+ }
41
+ /**
42
+ * Creates an unsuccessful result.
43
+ */
44
+ static notOk(failure) {
45
+ return blindCast(new ResultImpl(false, failure));
46
+ }
47
+ /**
48
+ * Asserts that this result is Ok and returns the value.
49
+ * Throws if the result is NotOk.
50
+ */
51
+ assertOk() {
52
+ if (!this.ok) throw new InternalError("Expected Ok result but got NotOk");
53
+ return this.value;
54
+ }
55
+ /**
56
+ * Asserts that this result is NotOk and returns the failure.
57
+ * Throws if the result is Ok.
58
+ */
59
+ assertNotOk() {
60
+ if (this.ok) throw new InternalError("Expected NotOk result but got Ok");
61
+ return this.failure;
62
+ }
63
+ };
64
+ /**
65
+ * Creates a successful result.
66
+ */
67
+ function ok(value) {
68
+ return ResultImpl.ok(value);
69
+ }
70
+ /**
71
+ * Creates an unsuccessful result.
72
+ */
73
+ function notOk(failure) {
74
+ return ResultImpl.notOk(failure);
75
+ }
76
+ /**
77
+ * Singleton for void success results.
78
+ * Use this for validation checks that don't produce a value.
79
+ */
80
+ const OK_VOID = ResultImpl.ok(void 0);
81
+ /**
82
+ * Returns a successful void result.
83
+ * Use this for validation checks that don't produce a value.
84
+ */
85
+ function okVoid() {
86
+ return OK_VOID;
87
+ }
88
+ //#endregion
89
+ export { ok as n, okVoid as r, notOk as t };
90
+
91
+ //# sourceMappingURL=result-CttmabB6.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"result-CttmabB6.mjs","names":[],"sources":["../../../0-framework/0-foundation/foundation/dist/result.mjs"],"sourcesContent":["import { t as blindCast } from \"./casts-DpaahrlC.mjs\";\nimport { t as InternalError } from \"./internal-error-Dfur7Zqt.mjs\";\n//#region src/result.ts\n/**\n* Generic Result type for representing success or failure outcomes.\n*\n* This is the standard way to return \"expected failures\" as values rather than\n* throwing exceptions. See docs/Error Handling.md for the full taxonomy.\n*\n* Naming rationale:\n* - `Ok<T>` / `NotOk<F>` mirror the `ok: true/false` discriminator\n* - `NotOk` avoids collision with domain types like \"Failure\" or \"Error\"\n* - `failure` property distinguishes from JS Error semantics\n*/\n/**\n* Result class that implements both Ok and NotOk variants.\n*/\nvar ResultImpl = class ResultImpl {\n\tok;\n\t_value;\n\t_failure;\n\tconstructor(ok, valueOrFailure) {\n\t\tthis.ok = ok;\n\t\tif (ok) this._value = blindCast(valueOrFailure);\n\t\telse this._failure = blindCast(valueOrFailure);\n\t\tObject.freeze(this);\n\t}\n\tget value() {\n\t\tif (!this.ok) throw new InternalError(\"Cannot access value on NotOk result\");\n\t\treturn this._value;\n\t}\n\tget failure() {\n\t\tif (this.ok) throw new InternalError(\"Cannot access failure on Ok result\");\n\t\treturn this._failure;\n\t}\n\t/**\n\t* Creates a successful result.\n\t*/\n\tstatic ok(value) {\n\t\treturn blindCast(new ResultImpl(true, value));\n\t}\n\t/**\n\t* Creates an unsuccessful result.\n\t*/\n\tstatic notOk(failure) {\n\t\treturn blindCast(new ResultImpl(false, failure));\n\t}\n\t/**\n\t* Asserts that this result is Ok and returns the value.\n\t* Throws if the result is NotOk.\n\t*/\n\tassertOk() {\n\t\tif (!this.ok) throw new InternalError(\"Expected Ok result but got NotOk\");\n\t\treturn this.value;\n\t}\n\t/**\n\t* Asserts that this result is NotOk and returns the failure.\n\t* Throws if the result is Ok.\n\t*/\n\tassertNotOk() {\n\t\tif (this.ok) throw new InternalError(\"Expected NotOk result but got Ok\");\n\t\treturn this.failure;\n\t}\n};\n/**\n* Creates a successful result.\n*/\nfunction ok(value) {\n\treturn ResultImpl.ok(value);\n}\n/**\n* Creates an unsuccessful result.\n*/\nfunction notOk(failure) {\n\treturn ResultImpl.notOk(failure);\n}\n/**\n* Singleton for void success results.\n* Use this for validation checks that don't produce a value.\n*/\nconst OK_VOID = ResultImpl.ok(void 0);\n/**\n* Returns a successful void result.\n* Use this for validation checks that don't produce a value.\n*/\nfunction okVoid() {\n\treturn OK_VOID;\n}\n//#endregion\nexport { notOk, ok, okVoid };\n\n//# sourceMappingURL=result.mjs.map"],"mappings":";;;;;;;;;;;;;;;;AAiBA,IAAI,aAAa,MAAM,WAAW;CACjC;CACA;CACA;CACA,YAAY,IAAI,gBAAgB;EAC/B,KAAK,KAAK;EACV,IAAI,IAAI,KAAK,SAAS,UAAU,cAAc;OACzC,KAAK,WAAW,UAAU,cAAc;EAC7C,OAAO,OAAO,IAAI;CACnB;CACA,IAAI,QAAQ;EACX,IAAI,CAAC,KAAK,IAAI,MAAM,IAAI,cAAc,qCAAqC;EAC3E,OAAO,KAAK;CACb;CACA,IAAI,UAAU;EACb,IAAI,KAAK,IAAI,MAAM,IAAI,cAAc,oCAAoC;EACzE,OAAO,KAAK;CACb;;;;CAIA,OAAO,GAAG,OAAO;EAChB,OAAO,UAAU,IAAI,WAAW,MAAM,KAAK,CAAC;CAC7C;;;;CAIA,OAAO,MAAM,SAAS;EACrB,OAAO,UAAU,IAAI,WAAW,OAAO,OAAO,CAAC;CAChD;;;;;CAKA,WAAW;EACV,IAAI,CAAC,KAAK,IAAI,MAAM,IAAI,cAAc,kCAAkC;EACxE,OAAO,KAAK;CACb;;;;;CAKA,cAAc;EACb,IAAI,KAAK,IAAI,MAAM,IAAI,cAAc,kCAAkC;EACvE,OAAO,KAAK;CACb;AACD;;;;AAIA,SAAS,GAAG,OAAO;CAClB,OAAO,WAAW,GAAG,KAAK;AAC3B;;;;AAIA,SAAS,MAAM,SAAS;CACvB,OAAO,WAAW,MAAM,OAAO;AAChC;;;;;AAKA,MAAM,UAAU,WAAW,GAAG,KAAK,CAAC;;;;;AAKpC,SAAS,SAAS;CACjB,OAAO;AACR"}
@@ -0,0 +1,26 @@
1
+ import { createRequire } from "node:module";
2
+ //#region \0rolldown/runtime.js
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
12
+ key = keys[i];
13
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
14
+ get: ((k) => from[k]).bind(null, key),
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
21
+ value: mod,
22
+ enumerable: true
23
+ }) : target, mod));
24
+ var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
25
+ //#endregion
26
+ export { __require as n, __toESM as r, __commonJSMin as t };