@eudiplo/cli 10.1.0-main.58bb535 → 10.1.0-main.61b9ca8

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/index.js CHANGED
@@ -7515,8 +7515,8 @@ var require_formats = __commonJS({
7515
7515
  "use strict";
7516
7516
  Object.defineProperty(exports, "__esModule", { value: true });
7517
7517
  exports.formatNames = exports.fastFormats = exports.fullFormats = void 0;
7518
- function fmtDef(validate, compare) {
7519
- return { validate, compare };
7518
+ function fmtDef(validate, compare2) {
7519
+ return { validate, compare: compare2 };
7520
7520
  }
7521
7521
  exports.fullFormats = {
7522
7522
  // date: http://tools.ietf.org/html/rfc3339#section-5.6
@@ -23315,6 +23315,120 @@ async function atomicWriteFile(path2, data) {
23315
23315
  }
23316
23316
  }
23317
23317
 
23318
+ // src/services/backend-checks.ts
23319
+ function compareVersions(cliVersion, backendVersion2) {
23320
+ const name = "version compatibility";
23321
+ const cli = parse3(cliVersion);
23322
+ const backend = parse3(backendVersion2);
23323
+ if (!cli || !backend) {
23324
+ return {
23325
+ name,
23326
+ status: "warn",
23327
+ message: `CLI ${cliVersion} and backend ${backendVersion2} cannot be compared as versions.`
23328
+ };
23329
+ }
23330
+ if (cli.major !== backend.major) {
23331
+ return {
23332
+ name,
23333
+ status: "fail",
23334
+ message: `CLI ${cliVersion} and backend ${backendVersion2} are different major versions. Install a matching CLI with npm install -g @eudiplo/cli@${backend.major}.`
23335
+ };
23336
+ }
23337
+ if (cli.minor !== backend.minor) {
23338
+ return {
23339
+ name,
23340
+ status: "warn",
23341
+ message: `CLI ${cliVersion} and backend ${backendVersion2} differ in minor version; some commands may not be supported.`
23342
+ };
23343
+ }
23344
+ if (compare(cli, LAST_RELEASE_WITHOUT_ESCAPED_FORM) > 0 && compare(backend, LAST_RELEASE_WITHOUT_ESCAPED_FORM) <= 0) {
23345
+ return {
23346
+ name,
23347
+ status: "warn",
23348
+ message: `CLI ${cliVersion} and backend ${backendVersion2} read the escaped form $\${ of configuration files differently; config plan and import of a tenant folder store values containing \${ or $\${ differently. Upgrade the backend to match the CLI.`
23349
+ };
23350
+ }
23351
+ return {
23352
+ name,
23353
+ status: "pass",
23354
+ message: `CLI ${cliVersion} matches backend ${backendVersion2}.`
23355
+ };
23356
+ }
23357
+ var LAST_RELEASE_WITHOUT_ESCAPED_FORM = {
23358
+ major: 10,
23359
+ minor: 1,
23360
+ patch: 0
23361
+ };
23362
+ function escapedFormWarning(backendVersion2) {
23363
+ const backend = backendVersion2 ? parse3(backendVersion2) : void 0;
23364
+ if (!backend || compare(backend, LAST_RELEASE_WITHOUT_ESCAPED_FORM) > 0)
23365
+ return void 0;
23366
+ return `Warning: the backend (${backendVersion2}) does not read the escaped form $\${ of configuration files, which this CLI sends: values containing \${ or $\${ will be stored differently from what the files say. Upgrade the CLI and the backend together.`;
23367
+ }
23368
+ function compare(left, right) {
23369
+ return left.major - right.major || left.minor - right.minor || left.patch - right.patch;
23370
+ }
23371
+ function readBackendVersion(body) {
23372
+ if (typeof body === "object" && body !== null && "version" in body) {
23373
+ const version = body.version;
23374
+ return typeof version === "string" && version ? version : void 0;
23375
+ }
23376
+ return void 0;
23377
+ }
23378
+ function readProviderHealth(body) {
23379
+ if (!Array.isArray(body)) {
23380
+ throw new Error("the provider health response was not a list");
23381
+ }
23382
+ return body.map((entry) => {
23383
+ const record = entry;
23384
+ return {
23385
+ providerId: String(record.providerId ?? "unknown"),
23386
+ type: String(record.type ?? "unknown"),
23387
+ ok: record.ok === true,
23388
+ latencyMs: typeof record.latencyMs === "number" ? record.latencyMs : void 0,
23389
+ error: typeof record.error === "string" ? record.error : void 0
23390
+ };
23391
+ });
23392
+ }
23393
+ function summarizeProviderHealth(providers) {
23394
+ const name = "KMS providers";
23395
+ if (providers.length === 0) {
23396
+ return {
23397
+ name,
23398
+ status: "warn",
23399
+ message: "No KMS providers are registered for this tenant."
23400
+ };
23401
+ }
23402
+ const failing = providers.filter((provider) => !provider.ok);
23403
+ if (failing.length > 0) {
23404
+ return {
23405
+ name,
23406
+ status: "fail",
23407
+ message: `${failing.length}/${providers.length} provider(s) unhealthy: ${failing.map(
23408
+ (provider) => `${provider.providerId} (${provider.type})${provider.error ? ", health check reported an error" : ""}`
23409
+ ).join(", ")}`
23410
+ };
23411
+ }
23412
+ return {
23413
+ name,
23414
+ status: "pass",
23415
+ message: `${providers.length} provider(s) healthy: ${providers.map(
23416
+ (provider) => `${provider.providerId} (${provider.type}${provider.latencyMs === void 0 ? "" : `, ${provider.latencyMs}ms`})`
23417
+ ).join(", ")}`
23418
+ };
23419
+ }
23420
+ function parse3(version) {
23421
+ const match = /^v?(\d+)\.(\d+)\.(\d+)/.exec(version.trim());
23422
+ if (!match) {
23423
+ return void 0;
23424
+ }
23425
+ return {
23426
+ major: Number(match[1]),
23427
+ minor: Number(match[2]),
23428
+ patch: Number(match[3])
23429
+ };
23430
+ }
23431
+
23318
23432
  // src/services/instance-selection.ts
23319
23433
  function resolveInstance(config, parsed) {
23320
23434
  const name = readStringFlag(parsed.flags, "instance") ?? config.defaultInstance;
@@ -43494,104 +43608,99 @@ var CONFIG_SCHEMAS = [
43494
43608
  }
43495
43609
  ];
43496
43610
 
43497
- // ../../packages/eudiplo-config-format/dist/config-validator.js
43498
- var DISPLAY_COLOR_PATH = /^\/spec\/config\/display\/\d+\/(?:background|text)_color$/;
43499
- var ajv = new import__.Ajv2020({
43500
- allErrors: true,
43501
- strict: false,
43502
- validateFormats: false
43503
- });
43504
- for (const schema of CONFIG_SCHEMAS)
43505
- ajv.addSchema(schema);
43506
- function validateConfigDocument(document) {
43507
- const file = serializeDocument(document);
43508
- const validate = ajv.getSchema(file.$schema);
43509
- if (!validate)
43510
- throw new Error(`No bundled validator for ${file.$schema}`);
43511
- const issues = [];
43512
- if (!validate(file)) {
43513
- for (const issue of validate.errors ?? [])
43514
- issues.push({
43515
- severity: "error",
43516
- code: "CONFIG_SCHEMA_VALIDATION_FAILED",
43517
- path: issue.instancePath || "/",
43518
- message: issue.keyword === "additionalProperties" ? `Unknown property: ${String(issue.params.additionalProperty)}` : issue.keyword === "pattern" && DISPLAY_COLOR_PATH.test(issue.instancePath) ? DISPLAY_COLOR_MESSAGE : issue.message ?? "Invalid configuration",
43519
- resource: { kind: document.kind, id: resourceId(document) }
43520
- });
43521
- }
43522
- const id = document.kind === "Client" ? document.spec.clientId : document.spec.id;
43523
- if (id !== void 0 && id !== resourceId(document))
43524
- issues.push({
43525
- severity: "error",
43526
- code: "RESOURCE_ID_MISMATCH",
43527
- path: document.kind === "Client" ? "/spec/clientId" : "/spec/id",
43528
- message: "Resource identifier does not match metadata.id"
43529
- });
43530
- issues.push(...configRuleIssues(document));
43531
- return issues;
43532
- }
43533
- function configRuleIssues(document) {
43534
- const display = document.spec.config?.display;
43535
- if (document.kind !== "CredentialConfig" || resolveConfigIdentity(serializeDocument(document)).version < 4 || !Array.isArray(display))
43536
- return [];
43537
- return findDuplicateDisplayLocales(display).map((duplicate) => ({
43538
- severity: "error",
43539
- code: "DISPLAY_LOCALE_DUPLICATE",
43540
- path: `/spec/config/display/${duplicate.index}/locale`,
43541
- message: duplicateDisplayLocaleMessage(duplicate),
43542
- resource: { kind: document.kind, id: resourceId(document) }
43543
- }));
43544
- }
43545
-
43546
43611
  // ../../packages/eudiplo-config-format/dist/config-values.js
43547
43612
  var isVariableChar = (char) => char >= "A" && char <= "Z" || char >= "0" && char <= "9" || char === "_";
43548
- function replacePlaceholders(input, replace) {
43613
+ var isLower = (char) => char >= "a" && char <= "z";
43614
+ var isSourceChar = (char) => isLower(char) || char >= "0" && char <= "9" || char === "-";
43615
+ var LOCATOR_CHARS = new Set("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._~/:@+=,#-");
43616
+ var escapeText = (text) => text.replaceAll("${", () => "$${");
43617
+ function replacePlaceholders(input, replace, escapes = "resolve") {
43549
43618
  let output = "";
43619
+ let text = "";
43620
+ const flush = () => {
43621
+ output += escapes === "keep" ? escapeText(text) : text;
43622
+ text = "";
43623
+ };
43550
43624
  let copied = 0;
43625
+ let noClosingBrace = false;
43551
43626
  let start = input.indexOf("${");
43552
43627
  while (start !== -1) {
43553
- let cursor = start + 2;
43554
- while (cursor < input.length && isVariableChar(input[cursor]))
43555
- cursor++;
43556
- const variable = input.slice(start + 2, cursor);
43628
+ if (escapes !== "none" && start > copied && input[start - 1] === "$") {
43629
+ text += `${input.slice(copied, start - 1)}\${`;
43630
+ copied = start + 2;
43631
+ start = input.indexOf("${", copied);
43632
+ continue;
43633
+ }
43634
+ let token;
43557
43635
  let end = -1;
43558
- let fallback;
43559
- if (variable && input[cursor] === "}")
43560
- end = cursor;
43561
- else if (variable && input[cursor] === ":") {
43562
- end = input.indexOf("}", cursor + 1);
43563
- if (end === -1)
43564
- break;
43565
- fallback = input.slice(cursor + 1, end);
43636
+ let cursor = start + 2;
43637
+ if (isLower(input[cursor] ?? "")) {
43638
+ while (cursor < input.length && isSourceChar(input[cursor]))
43639
+ cursor++;
43640
+ const source = input.slice(start + 2, cursor);
43641
+ if (input[cursor] === ":") {
43642
+ const locatorStart = cursor + 1;
43643
+ cursor = locatorStart;
43644
+ while (cursor < input.length && LOCATOR_CHARS.has(input[cursor]))
43645
+ cursor++;
43646
+ if (cursor > locatorStart && input[cursor] === "}") {
43647
+ end = cursor;
43648
+ token = {
43649
+ type: "reference",
43650
+ match: input.slice(start, end + 1),
43651
+ source,
43652
+ locator: input.slice(locatorStart, end)
43653
+ };
43654
+ }
43655
+ }
43656
+ } else {
43657
+ while (cursor < input.length && isVariableChar(input[cursor]))
43658
+ cursor++;
43659
+ const variable = input.slice(start + 2, cursor);
43660
+ let fallback;
43661
+ if (variable && input[cursor] === "}")
43662
+ end = cursor;
43663
+ else if (variable && input[cursor] === ":" && !noClosingBrace) {
43664
+ end = input.indexOf("}", cursor + 1);
43665
+ if (end === -1)
43666
+ noClosingBrace = true;
43667
+ else
43668
+ fallback = input.slice(cursor + 1, end);
43669
+ }
43670
+ if (end !== -1)
43671
+ token = {
43672
+ type: "variable",
43673
+ match: input.slice(start, end + 1),
43674
+ variable,
43675
+ fallback
43676
+ };
43566
43677
  }
43567
- if (end === -1) {
43678
+ if (!token) {
43568
43679
  start = input.indexOf("${", start + 2);
43569
43680
  continue;
43570
43681
  }
43571
- output += input.slice(copied, start);
43572
- output += replace(input.slice(start, end + 1), variable, fallback);
43682
+ const { match } = token;
43683
+ const replacement = replace(token);
43684
+ text += input.slice(copied, start);
43685
+ if (replacement !== void 0)
43686
+ text += replacement;
43687
+ else if (escapes === "keep") {
43688
+ flush();
43689
+ output += match;
43690
+ } else
43691
+ text += match;
43573
43692
  copied = end + 1;
43574
43693
  start = input.indexOf("${", copied);
43575
43694
  }
43576
- return output + input.slice(copied);
43695
+ text += input.slice(copied);
43696
+ flush();
43697
+ return output;
43577
43698
  }
43578
- function resolveConfigVariables(input, env) {
43579
- const issues = [];
43699
+ function mapStrings(input, change) {
43580
43700
  const seen = /* @__PURE__ */ new WeakMap();
43581
43701
  function visit2(value, path2) {
43582
43702
  if (typeof value === "string")
43583
- return replacePlaceholders(value, (match, variable, fallback) => {
43584
- if (env[variable] !== void 0 && env[variable] !== "")
43585
- return env[variable];
43586
- if (fallback !== void 0)
43587
- return fallback;
43588
- issues.push({
43589
- path: path2 || "/",
43590
- variable,
43591
- message: `Unresolved placeholder \${${variable}}: no environment value or default is available`
43592
- });
43593
- return match;
43594
- });
43703
+ return change(value, path2 || "/");
43595
43704
  if (!value || typeof value !== "object" || value instanceof Uint8Array)
43596
43705
  return value;
43597
43706
  if (seen.has(value))
@@ -43607,7 +43716,30 @@ function resolveConfigVariables(input, env) {
43607
43716
  });
43608
43717
  return output;
43609
43718
  }
43610
- return { value: visit2(input, ""), issues };
43719
+ return visit2(input, "");
43720
+ }
43721
+ function resolveConfigVariables(input, env, escapes = "resolve") {
43722
+ const issues = [];
43723
+ const value = mapStrings(input, (text, path2) => replacePlaceholders(text, (token) => {
43724
+ if (token.type === "reference")
43725
+ return void 0;
43726
+ const { variable, fallback } = token;
43727
+ const found = env[variable];
43728
+ if (found !== void 0 && found !== "")
43729
+ return found;
43730
+ if (fallback !== void 0)
43731
+ return fallback;
43732
+ issues.push({
43733
+ path: path2,
43734
+ variable,
43735
+ message: `Unresolved placeholder \${${variable}}: no environment value or default is available`
43736
+ });
43737
+ return void 0;
43738
+ }, escapes));
43739
+ return { value, issues };
43740
+ }
43741
+ function escapeConfigPlaceholders(input) {
43742
+ return mapStrings(input, escapeText);
43611
43743
  }
43612
43744
  function stableConfigJson(value) {
43613
43745
  function sort(item) {
@@ -43673,6 +43805,55 @@ function configChanges(before, after, sensitivePaths = [], prefix = "") {
43673
43805
  return changes;
43674
43806
  }
43675
43807
 
43808
+ // ../../packages/eudiplo-config-format/dist/config-validator.js
43809
+ var DISPLAY_COLOR_PATH = /^\/spec\/config\/display\/\d+\/(?:background|text)_color$/;
43810
+ var ajv = new import__.Ajv2020({
43811
+ allErrors: true,
43812
+ strict: false,
43813
+ validateFormats: false
43814
+ });
43815
+ for (const schema of CONFIG_SCHEMAS)
43816
+ ajv.addSchema(schema);
43817
+ function validateConfigDocument(document) {
43818
+ const file = serializeDocument(document);
43819
+ const validate = ajv.getSchema(file.$schema);
43820
+ if (!validate)
43821
+ throw new Error(`No bundled validator for ${file.$schema}`);
43822
+ const issues = [];
43823
+ if (!validate(file)) {
43824
+ for (const issue of validate.errors ?? [])
43825
+ issues.push({
43826
+ severity: "error",
43827
+ code: "CONFIG_SCHEMA_VALIDATION_FAILED",
43828
+ path: issue.instancePath || "/",
43829
+ message: issue.keyword === "additionalProperties" ? `Unknown property: ${String(issue.params.additionalProperty)}` : issue.keyword === "pattern" && DISPLAY_COLOR_PATH.test(issue.instancePath) ? DISPLAY_COLOR_MESSAGE : issue.message ?? "Invalid configuration",
43830
+ resource: { kind: document.kind, id: resourceId(document) }
43831
+ });
43832
+ }
43833
+ const id = document.kind === "Client" ? document.spec.clientId : document.spec.id;
43834
+ if (id !== void 0 && id !== resourceId(document))
43835
+ issues.push({
43836
+ severity: "error",
43837
+ code: "RESOURCE_ID_MISMATCH",
43838
+ path: document.kind === "Client" ? "/spec/clientId" : "/spec/id",
43839
+ message: "Resource identifier does not match metadata.id"
43840
+ });
43841
+ issues.push(...configRuleIssues(document));
43842
+ return issues;
43843
+ }
43844
+ function configRuleIssues(document) {
43845
+ const display = document.spec.config?.display;
43846
+ if (document.kind !== "CredentialConfig" || resolveConfigIdentity(serializeDocument(document)).version < 4 || !Array.isArray(display))
43847
+ return [];
43848
+ return findDuplicateDisplayLocales(display).map((duplicate) => ({
43849
+ severity: "error",
43850
+ code: "DISPLAY_LOCALE_DUPLICATE",
43851
+ path: `/spec/config/display/${duplicate.index}/locale`,
43852
+ message: duplicateDisplayLocaleMessage(duplicate),
43853
+ resource: { kind: document.kind, id: resourceId(document) }
43854
+ }));
43855
+ }
43856
+
43676
43857
  // ../../packages/eudiplo-config-format/dist/tenant-folder.js
43677
43858
  var TENANT_FOLDER_IMAGES = "images";
43678
43859
  var IMAGE_CONTENT_TYPES = {
@@ -43705,7 +43886,7 @@ async function discoverTenantDirectories(rootPath) {
43705
43886
  const entries = await readdir(rootPath, { withFileTypes: true });
43706
43887
  return entries.filter((entry) => entry.isDirectory()).map((entry) => entry.name).sort(compareCodePoints);
43707
43888
  }
43708
- async function validateTenantsRoot(rootPath, schemas, env) {
43889
+ async function validateTenantsRoot(rootPath, schemas, env, options = {}) {
43709
43890
  if (!existsSync(rootPath)) {
43710
43891
  throw new Error(`Configuration root not found: ${rootPath}`);
43711
43892
  }
@@ -43717,7 +43898,8 @@ async function validateTenantsRoot(rootPath, schemas, env) {
43717
43898
  join4(rootPath, tenantId),
43718
43899
  tenantId,
43719
43900
  schemas,
43720
- env
43901
+ env,
43902
+ options
43721
43903
  )
43722
43904
  );
43723
43905
  }
@@ -43732,7 +43914,9 @@ async function validateTenantDirectory(tenantPath, tenantId, schemas, env, optio
43732
43914
  env,
43733
43915
  errors: [],
43734
43916
  unresolved: [],
43917
+ warnings: [],
43735
43918
  allowUnresolvedPlaceholders: options.allowUnresolvedPlaceholders,
43919
+ folderVariablePolicy: options.folderVariablePolicy,
43736
43920
  resourceCounts: {},
43737
43921
  files: 0
43738
43922
  };
@@ -43743,9 +43927,12 @@ async function validateTenantDirectory(tenantPath, tenantId, schemas, env, optio
43743
43927
  await validateDirectoryEntry(tenantPath, entry, state);
43744
43928
  }
43745
43929
  }
43746
- const warnings = RETIRED_TENANT_FOLDER_FILES.filter(
43747
- ({ file }) => existsSync(join4(tenantPath, file))
43748
- ).map(({ file, issue }) => ({ file, message: issue.message }));
43930
+ const warnings = [
43931
+ ...RETIRED_TENANT_FOLDER_FILES.filter(
43932
+ ({ file }) => existsSync(join4(tenantPath, file))
43933
+ ).map(({ file, issue }) => ({ file, message: issue.message })),
43934
+ ...state.warnings
43935
+ ];
43749
43936
  return {
43750
43937
  id: tenantId,
43751
43938
  valid: state.errors.length === 0,
@@ -43826,16 +44013,15 @@ async function recordValidationOutcome(filePath, relativeFile, resourceType, sch
43826
44013
  filePath,
43827
44014
  relativeFile,
43828
44015
  schemaFile,
43829
- state.getValidator,
43830
- state.env,
43831
- state.errors,
43832
- state.allowUnresolvedPlaceholders ? state.unresolved : state.errors
44016
+ state
43833
44017
  );
43834
44018
  if (isValid) {
43835
44019
  state.resourceCounts[resourceType] = (state.resourceCounts[resourceType] ?? 0) + 1;
43836
44020
  }
43837
44021
  }
43838
- async function validateResourceFile(filePath, relativeFile, schemaFile, getValidator, env, errors, placeholderIssues) {
44022
+ async function validateResourceFile(filePath, relativeFile, schemaFile, state) {
44023
+ const { errors, getValidator } = state;
44024
+ const kind = kindForSchemaFile(schemaFile);
43839
44025
  let raw;
43840
44026
  try {
43841
44027
  raw = await readFile4(filePath, "utf8");
@@ -43854,12 +44040,7 @@ async function validateResourceFile(filePath, relativeFile, schemaFile, getValid
43854
44040
  return false;
43855
44041
  }
43856
44042
  const errorsBefore = errors.length;
43857
- let resolved = resolvePlaceholders(
43858
- payload,
43859
- env,
43860
- relativeFile,
43861
- placeholderIssues
43862
- );
44043
+ let resolved = resolvePlaceholders(payload, relativeFile, kind, state);
43863
44044
  if (errors.length > errorsBefore) {
43864
44045
  return false;
43865
44046
  }
@@ -43887,7 +44068,6 @@ async function validateResourceFile(filePath, relativeFile, schemaFile, getValid
43887
44068
  return false;
43888
44069
  }
43889
44070
  } else {
43890
- const kind = kindForSchemaFile(schemaFile);
43891
44071
  if (kind && resolved && typeof resolved === "object" && !Array.isArray(resolved)) {
43892
44072
  const spec = structuredClone(resolved);
43893
44073
  if (kind === "KeyChain" && spec.key && !spec.keySource) {
@@ -43948,17 +44128,62 @@ function formatErrorPath(issue) {
43948
44128
  const missingProperty = issue.params?.missingProperty;
43949
44129
  return missingProperty;
43950
44130
  }
43951
- function resolvePlaceholders(value, env, file, errors) {
43952
- const result = resolveConfigVariables(value, env);
44131
+ function resolvePlaceholders(value, file, kind, state) {
44132
+ const kms = kind === "KmsConfig";
44133
+ const named = /* @__PURE__ */ new Set();
44134
+ const env = new Proxy(state.env, {
44135
+ get: (target, name) => {
44136
+ if (typeof name !== "string") return void 0;
44137
+ named.add(name);
44138
+ return target[name];
44139
+ }
44140
+ });
44141
+ const result = resolveConfigVariables(value, env, kms ? "none" : "resolve");
44142
+ const refused = /* @__PURE__ */ new Set();
44143
+ if (state.folderVariablePolicy)
44144
+ for (const variable of [...named].sort(compareCodePoints)) {
44145
+ const check = checkFolderVariable(variable, kms);
44146
+ if (check?.refused) {
44147
+ refused.add(variable);
44148
+ state.errors.push({ file, message: check.message, variable });
44149
+ } else if (check)
44150
+ state.warnings.push({ file, message: check.message, variable });
44151
+ }
44152
+ const placeholderIssues = state.allowUnresolvedPlaceholders ? state.unresolved : state.errors;
43953
44153
  for (const issue of result.issues)
43954
- errors.push({
43955
- file,
43956
- path: issue.path,
43957
- message: issue.message,
43958
- variable: issue.variable
43959
- });
44154
+ if (!refused.has(issue.variable))
44155
+ placeholderIssues.push({
44156
+ file,
44157
+ path: issue.path,
44158
+ message: issue.message,
44159
+ variable: issue.variable
44160
+ });
43960
44161
  return result.value;
43961
44162
  }
44163
+ var CLOUD_CREDENTIAL_VARIABLES = /* @__PURE__ */ new Map([
44164
+ ["AWS_ACCESS_KEY_ID", "AWS"],
44165
+ ["AWS_SECRET_ACCESS_KEY", "AWS"],
44166
+ ["AWS_SESSION_TOKEN", "AWS"],
44167
+ ["AWS_CONTAINER_AUTHORIZATION_TOKEN", "AWS"],
44168
+ ["AZURE_CLIENT_SECRET", "Azure"],
44169
+ ["AZURE_CLIENT_CERTIFICATE_PASSWORD", "Azure"],
44170
+ ["AZURE_PASSWORD", "Azure"]
44171
+ ]);
44172
+ function checkFolderVariable(variable, kms) {
44173
+ if (variable === "PUBLIC_URL") return void 0;
44174
+ if (kms)
44175
+ return {
44176
+ refused: false,
44177
+ message: `\${${variable}} is resolved only if the instance lists ${variable} in KMS_TENANT_VARIABLES, which cannot name a setting of EUDIPLO itself`
44178
+ };
44179
+ const provider = CLOUD_CREDENTIAL_VARIABLES.get(variable);
44180
+ if (provider)
44181
+ return {
44182
+ refused: true,
44183
+ message: `\${${variable}} holds the ${provider} credentials of the instance, which a file of a tenant folder cannot use`
44184
+ };
44185
+ return void 0;
44186
+ }
43962
44187
 
43963
44188
  // src/commands/config/portability/folder-bundle.ts
43964
44189
  import { createHash as createHash3 } from "node:crypto";
@@ -43996,7 +44221,7 @@ function upgradeDocument(input) {
43996
44221
 
43997
44222
  // src/commands/config/portability/upgrade.ts
43998
44223
  var codec = new ConfigBundleCodec();
43999
- function parse3(text, path2) {
44224
+ function parse4(text, path2) {
44000
44225
  try {
44001
44226
  return JSON.parse(text);
44002
44227
  } catch {
@@ -44129,7 +44354,7 @@ async function upgradeFolder(source, parsed, context) {
44129
44354
  for (const file of await folderFiles(source)) {
44130
44355
  if (extname(file) !== ".json" || relative2(source, file).split(sep2).includes("images"))
44131
44356
  continue;
44132
- const input = parse3(await readFile5(file, "utf8"), file);
44357
+ const input = parse4(await readFile5(file, "utf8"), file);
44133
44358
  const path2 = relative2(source, file).split(sep2).join("/");
44134
44359
  const retired = RETIRED_TENANT_FOLDER_FILES.find(
44135
44360
  (entry) => path2 === entry.file || path2.endsWith(`/${entry.file}`)
@@ -44219,7 +44444,7 @@ async function upgradeFile(parsed, context) {
44219
44444
  );
44220
44445
  if (info.isDirectory()) return upgradeFolder(source, parsed, context);
44221
44446
  const zipped = extname(source).toLowerCase() === ".zip";
44222
- const input = zipped ? codec.decode(await readFile5(source)) : parse3(await readFile5(source, "utf8"), source);
44447
+ const input = zipped ? codec.decode(await readFile5(source)) : parse4(await readFile5(source, "utf8"), source);
44223
44448
  const output = upgradeJson(input, source, context);
44224
44449
  const changed = report(input, output, name, parsed, context);
44225
44450
  if (parsed.flags.check === true) return changed ? 1 : 0;
@@ -44270,10 +44495,14 @@ function folderEnvironment(allowList, source) {
44270
44495
  }
44271
44496
  var VALUE_KEYS = /* @__PURE__ */ new Set(["before", "after", "message"]);
44272
44497
  function maskFilledText(text, filled) {
44273
- const secrets = [...filled].map(([variable, secret]) => ({
44274
- secret,
44275
- placeholder: `\${${variable}}`
44276
- })).sort((left, right) => right.secret.length - left.secret.length);
44498
+ const secrets = [...filled].flatMap(([variable, secret]) => {
44499
+ const placeholder = `\${${variable}}`;
44500
+ const escaped = escapeConfigPlaceholders(secret);
44501
+ return escaped === secret ? [{ secret, placeholder }] : [
44502
+ { secret, placeholder },
44503
+ { secret: escaped, placeholder }
44504
+ ];
44505
+ }).sort((left, right) => right.secret.length - left.secret.length);
44277
44506
  for (const { secret, placeholder } of secrets) {
44278
44507
  if (text === secret) return placeholder;
44279
44508
  if (secret.length >= MIN_MASKED_LENGTH)
@@ -44402,7 +44631,11 @@ async function resourceFiles(tenantRoot, resource) {
44402
44631
  }
44403
44632
  async function loadDocument(tenantRoot, file, kind, env) {
44404
44633
  const payload = JSON.parse(await readFile6(join6(tenantRoot, file), "utf8"));
44405
- const resolved = resolveConfigVariables(payload, env).value;
44634
+ const resolved = resolveConfigVariables(
44635
+ payload,
44636
+ env,
44637
+ kind === "KmsConfig" ? "none" : "keep"
44638
+ ).value;
44406
44639
  const document = normalizeDocument(
44407
44640
  isConfigDocument(resolved) ? resolved : wrapBare(kind, resolved, file)
44408
44641
  );
@@ -44622,7 +44855,7 @@ async function runPortabilityCommand(action, config, parsed, context) {
44622
44855
  const allowEnv = readStringFlag(parsed.flags, "allow-env");
44623
44856
  if (allowEnv !== void 0 && !folder)
44624
44857
  throw new Error(
44625
- "--allow-env applies to a tenant folder only; a bundle's placeholders are resolved by the server."
44858
+ "--allow-env applies to a tenant folder only; replace the placeholders of a bundle with their values."
44626
44859
  );
44627
44860
  const folderEnv = folderEnvironment(allowEnv, context.env);
44628
44861
  if (folder) {
@@ -44695,6 +44928,13 @@ async function runPortabilityCommand(action, config, parsed, context) {
44695
44928
  body = JSON.stringify(bundle);
44696
44929
  headers = { ...headers, "content-type": "application/json" };
44697
44930
  }
44931
+ if (folder) {
44932
+ const warning = escapedFormWarning(
44933
+ await backendVersion(baseUrl, authHeaders, context)
44934
+ );
44935
+ if (warning) context.stderr.write(`${warning}
44936
+ `);
44937
+ }
44698
44938
  const response = await context.fetch(
44699
44939
  `${baseUrl}/api/config-bundles/${endpoint}?${query}`,
44700
44940
  { method: "POST", headers, body }
@@ -44756,6 +44996,17 @@ async function runPortabilityCommand(action, config, parsed, context) {
44756
44996
  `);
44757
44997
  return result.applicable === false ? 1 : 0;
44758
44998
  }
44999
+ async function backendVersion(baseUrl, headers, context) {
45000
+ try {
45001
+ const response = await context.fetch(`${baseUrl}/api/version`, {
45002
+ headers
45003
+ });
45004
+ if (!response.ok) return void 0;
45005
+ return readBackendVersion(await response.json());
45006
+ } catch {
45007
+ return void 0;
45008
+ }
45009
+ }
44759
45010
  async function exportFolder(baseUrl, headers, output, context) {
44760
45011
  const response = await context.fetch(
44761
45012
  `${baseUrl}/api/config-bundles/export?format=zip`,
@@ -45272,9 +45523,13 @@ async function validateTenantConfig(scope, parsed, context) {
45272
45523
  rootPath,
45273
45524
  basename6(rootPath),
45274
45525
  schemas,
45275
- context.env
45526
+ context.env,
45527
+ // As the backend loads the folder from CONFIG_FOLDER.
45528
+ { folderVariablePolicy: true }
45276
45529
  )
45277
- ] : await validateTenantsRoot(rootPath, schemas, context.env);
45530
+ ] : await validateTenantsRoot(rootPath, schemas, context.env, {
45531
+ folderVariablePolicy: true
45532
+ });
45278
45533
  context.stdout.write(
45279
45534
  format2 === "json" ? `${JSON.stringify(buildJsonReport(results), null, 2)}
45280
45535
  ` : formatTextReport(scope, rootPath, results)
@@ -46946,7 +47201,7 @@ function createDeploymentCommands(context, setExitCode) {
46946
47201
  // package.json
46947
47202
  var package_default = {
46948
47203
  name: "@eudiplo/cli",
46949
- version: "10.1.0-main.58bb535",
47204
+ version: "10.1.0-main.61b9ca8",
46950
47205
  description: "Deployment-aware command line tools for EUDIPLO",
46951
47206
  private: false,
46952
47207
  type: "module",
@@ -47007,12 +47262,12 @@ var package_default = {
47007
47262
  "jsonc-parser": "^3.3.1"
47008
47263
  },
47009
47264
  devDependencies: {
47010
- "@biomejs/biome": "2.6.8",
47011
- "@types/node": "^26.6.6",
47265
+ "@biomejs/biome": "2.6.9",
47266
+ "@types/node": "^26.6.7",
47012
47267
  esbuild: "^0.28.2",
47013
47268
  tsx: "^4.23.15",
47014
47269
  typescript: "^7.0.2",
47015
- vitest: "5.1.0"
47270
+ vitest: "5.1.1"
47016
47271
  }
47017
47272
  };
47018
47273
 
@@ -47084,99 +47339,6 @@ function withTrailingSlash(url) {
47084
47339
  return url.href.endsWith("/") ? url : new URL(`${url.href}/`);
47085
47340
  }
47086
47341
 
47087
- // src/services/backend-checks.ts
47088
- function compareVersions(cliVersion, backendVersion) {
47089
- const name = "version compatibility";
47090
- const cli = parse4(cliVersion);
47091
- const backend = parse4(backendVersion);
47092
- if (!cli || !backend) {
47093
- return {
47094
- name,
47095
- status: "warn",
47096
- message: `CLI ${cliVersion} and backend ${backendVersion} cannot be compared as versions.`
47097
- };
47098
- }
47099
- if (cli.major !== backend.major) {
47100
- return {
47101
- name,
47102
- status: "fail",
47103
- message: `CLI ${cliVersion} and backend ${backendVersion} are different major versions. Install a matching CLI with npm install -g @eudiplo/cli@${backend.major}.`
47104
- };
47105
- }
47106
- if (cli.minor !== backend.minor) {
47107
- return {
47108
- name,
47109
- status: "warn",
47110
- message: `CLI ${cliVersion} and backend ${backendVersion} differ in minor version; some commands may not be supported.`
47111
- };
47112
- }
47113
- return {
47114
- name,
47115
- status: "pass",
47116
- message: `CLI ${cliVersion} matches backend ${backendVersion}.`
47117
- };
47118
- }
47119
- function readBackendVersion(body) {
47120
- if (typeof body === "object" && body !== null && "version" in body) {
47121
- const version = body.version;
47122
- return typeof version === "string" && version ? version : void 0;
47123
- }
47124
- return void 0;
47125
- }
47126
- function readProviderHealth(body) {
47127
- if (!Array.isArray(body)) {
47128
- throw new Error("the provider health response was not a list");
47129
- }
47130
- return body.map((entry) => {
47131
- const record = entry;
47132
- return {
47133
- providerId: String(record.providerId ?? "unknown"),
47134
- type: String(record.type ?? "unknown"),
47135
- ok: record.ok === true,
47136
- latencyMs: typeof record.latencyMs === "number" ? record.latencyMs : void 0,
47137
- error: typeof record.error === "string" ? record.error : void 0
47138
- };
47139
- });
47140
- }
47141
- function summarizeProviderHealth(providers) {
47142
- const name = "KMS providers";
47143
- if (providers.length === 0) {
47144
- return {
47145
- name,
47146
- status: "warn",
47147
- message: "No KMS providers are registered for this tenant."
47148
- };
47149
- }
47150
- const failing = providers.filter((provider) => !provider.ok);
47151
- if (failing.length > 0) {
47152
- return {
47153
- name,
47154
- status: "fail",
47155
- message: `${failing.length}/${providers.length} provider(s) unhealthy: ${failing.map(
47156
- (provider) => `${provider.providerId} (${provider.type})${provider.error ? ", health check reported an error" : ""}`
47157
- ).join(", ")}`
47158
- };
47159
- }
47160
- return {
47161
- name,
47162
- status: "pass",
47163
- message: `${providers.length} provider(s) healthy: ${providers.map(
47164
- (provider) => `${provider.providerId} (${provider.type}${provider.latencyMs === void 0 ? "" : `, ${provider.latencyMs}ms`})`
47165
- ).join(", ")}`
47166
- };
47167
- }
47168
- function parse4(version) {
47169
- const match = /^v?(\d+)\.(\d+)\.(\d+)/.exec(version.trim());
47170
- if (!match) {
47171
- return void 0;
47172
- }
47173
- return {
47174
- major: Number(match[1]),
47175
- minor: Number(match[2]),
47176
- patch: Number(match[3])
47177
- };
47178
- }
47179
-
47180
47342
  // src/services/tls-expiry.ts
47181
47343
  import { connect } from "node:tls";
47182
47344
  var defaultExpiryWarningDays = 30;
@@ -47356,15 +47518,15 @@ var versionCompatibilityCheck = {
47356
47518
  message: `The backend version could not be read: ${response.reason}`
47357
47519
  };
47358
47520
  }
47359
- const backendVersion = readBackendVersion(response.body);
47360
- if (!backendVersion) {
47521
+ const backendVersion2 = readBackendVersion(response.body);
47522
+ if (!backendVersion2) {
47361
47523
  return {
47362
47524
  name: "version compatibility",
47363
47525
  status: "warn",
47364
47526
  message: "The backend did not report a version."
47365
47527
  };
47366
47528
  }
47367
- return compareVersions(package_default.version, backendVersion);
47529
+ return compareVersions(package_default.version, backendVersion2);
47368
47530
  })
47369
47531
  };
47370
47532
  var kmsHealthCheck = {