@mesh-tech/mesh-cli 0.18.0 → 0.18.2

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/bin/mesh.js CHANGED
@@ -809,8 +809,8 @@ var init_seed = __esm({
809
809
  // libs/mesh-cli/src/commands/local/helpers.ts
810
810
  import * as net from "net";
811
811
  async function upsertLocalSecret(secretId, value, client) {
812
- const { SecretsManagerClient: SecretsManagerClient9, CreateSecretCommand: CreateSecretCommand4, PutSecretValueCommand: PutSecretValueCommand4 } = await import("@aws-sdk/client-secrets-manager");
813
- const sm = client ?? new SecretsManagerClient9(LOCAL_AWS_CONFIG);
812
+ const { SecretsManagerClient: SecretsManagerClient10, CreateSecretCommand: CreateSecretCommand4, PutSecretValueCommand: PutSecretValueCommand4 } = await import("@aws-sdk/client-secrets-manager");
813
+ const sm = client ?? new SecretsManagerClient10(LOCAL_AWS_CONFIG);
814
814
  const secretString = JSON.stringify(value);
815
815
  try {
816
816
  await sm.send(new CreateSecretCommand4({ Name: secretId, SecretString: secretString }));
@@ -6316,12 +6316,12 @@ async function fetchRemoteExternalCredentials(tenant, env, external, profile) {
6316
6316
  const region = process.env.MESH_PLATFORM_REGION ?? process.env.AWS_REGION ?? "us-east-2";
6317
6317
  const fallbackProfile = !process.env.AWS_ACCESS_KEY_ID && !process.env.AWS_PROFILE ? process.env.MESH_AWS_PROFILE ?? profile : void 0;
6318
6318
  try {
6319
- const { SecretsManagerClient: SecretsManagerClient9, GetSecretValueCommand: GetSecretValueCommand9 } = await import("@aws-sdk/client-secrets-manager");
6319
+ const { SecretsManagerClient: SecretsManagerClient10, GetSecretValueCommand: GetSecretValueCommand10 } = await import("@aws-sdk/client-secrets-manager");
6320
6320
  if (fallbackProfile) process.env.AWS_PROFILE = fallbackProfile;
6321
- const sm = new SecretsManagerClient9({ region });
6321
+ const sm = new SecretsManagerClient10({ region });
6322
6322
  let res;
6323
6323
  try {
6324
- res = await sm.send(new GetSecretValueCommand9({ SecretId: secretId }));
6324
+ res = await sm.send(new GetSecretValueCommand10({ SecretId: secretId }));
6325
6325
  } finally {
6326
6326
  if (fallbackProfile) delete process.env.AWS_PROFILE;
6327
6327
  }
@@ -6976,13 +6976,13 @@ async function writeRegistryParams(cliClientId, awsConfig) {
6976
6976
  }
6977
6977
  async function ensureOpsHubAdmin(pat, awsConfig) {
6978
6978
  const {
6979
- SecretsManagerClient: SecretsManagerClient9,
6980
- GetSecretValueCommand: GetSecretValueCommand9,
6979
+ SecretsManagerClient: SecretsManagerClient10,
6980
+ GetSecretValueCommand: GetSecretValueCommand10,
6981
6981
  CreateSecretCommand: CreateSecretCommand4,
6982
6982
  PutSecretValueCommand: PutSecretValueCommand4
6983
6983
  } = await import("@aws-sdk/client-secrets-manager");
6984
- const sm = new SecretsManagerClient9(awsConfig);
6985
- const existing = await sm.send(new GetSecretValueCommand9({ SecretId: OPS_HUB_SECRET_ID })).catch(() => null);
6984
+ const sm = new SecretsManagerClient10(awsConfig);
6985
+ const existing = await sm.send(new GetSecretValueCommand10({ SecretId: OPS_HUB_SECRET_ID })).catch(() => null);
6986
6986
  if (existing?.SecretString) {
6987
6987
  logSuccess("Hub admin key already provisioned (Zitadel writes enabled)");
6988
6988
  return;
@@ -7242,9 +7242,9 @@ async function ensureM2mCaller(pat, tenant, app, orgId, projectId, roles) {
7242
7242
  return false;
7243
7243
  }
7244
7244
  async function authSecretExists(tenant, app, service) {
7245
- const { SecretsManagerClient: SecretsManagerClient9, GetSecretValueCommand: GetSecretValueCommand9 } = await import("@aws-sdk/client-secrets-manager");
7246
- const sm = new SecretsManagerClient9(LOCAL_AWS_CONFIG);
7247
- return sm.send(new GetSecretValueCommand9({ SecretId: authSecretPath(tenant, app, service) })).then(
7245
+ const { SecretsManagerClient: SecretsManagerClient10, GetSecretValueCommand: GetSecretValueCommand10 } = await import("@aws-sdk/client-secrets-manager");
7246
+ const sm = new SecretsManagerClient10(LOCAL_AWS_CONFIG);
7247
+ return sm.send(new GetSecretValueCommand10({ SecretId: authSecretPath(tenant, app, service) })).then(
7248
7248
  () => true,
7249
7249
  () => false
7250
7250
  );
@@ -17500,25 +17500,63 @@ var init_exec2 = __esm({
17500
17500
  }
17501
17501
  });
17502
17502
 
17503
+ // libs/secrets/src/index.ts
17504
+ import {
17505
+ SecretsManagerClient as SecretsManagerClient5,
17506
+ GetSecretValueCommand as GetSecretValueCommand5
17507
+ } from "@aws-sdk/client-secrets-manager";
17508
+ function instanceIndexSecretId(secretPrefix) {
17509
+ return `${secretPrefix}/${INSTANCE_INDEX_SUFFIX}`;
17510
+ }
17511
+ function isInstanceKey(key) {
17512
+ return key.length > 0 && !key.includes("/") && !key.startsWith(".") && !key.endsWith(".config");
17513
+ }
17514
+ function instanceKeyFromSecretName(secretPrefix, secretName) {
17515
+ if (!secretName.startsWith(`${secretPrefix}/`)) return null;
17516
+ const key = secretName.slice(secretPrefix.length + 1);
17517
+ return isInstanceKey(key) ? key : null;
17518
+ }
17519
+ function parseInstanceIndex(secretString) {
17520
+ let parsed;
17521
+ try {
17522
+ parsed = JSON.parse(secretString);
17523
+ } catch {
17524
+ parsed = void 0;
17525
+ }
17526
+ const instances = parsed?.instances;
17527
+ if (!Array.isArray(instances) || !instances.every((k) => typeof k === "string")) {
17528
+ throw new Error(
17529
+ `Malformed instance index (expected {"instances": string[]}). Rebuild it with: mesh secrets reindex external/<name>`
17530
+ );
17531
+ }
17532
+ return instances.filter(isInstanceKey);
17533
+ }
17534
+ function buildInstanceIndexValue(keys) {
17535
+ const instances = [...new Set([...keys].filter(isInstanceKey))].sort();
17536
+ const index = { version: 1, instances };
17537
+ return JSON.stringify(index);
17538
+ }
17539
+ var INSTANCE_INDEX_SUFFIX;
17540
+ var init_src3 = __esm({
17541
+ "libs/secrets/src/index.ts"() {
17542
+ "use strict";
17543
+ INSTANCE_INDEX_SUFFIX = ".index";
17544
+ }
17545
+ });
17546
+
17503
17547
  // libs/mesh-cli/src/commands/secrets/set.ts
17504
17548
  import {
17505
17549
  SSMClient as SSMClient2,
17506
17550
  GetParametersByPathCommand
17507
17551
  } from "@aws-sdk/client-ssm";
17508
17552
  import {
17509
- SecretsManagerClient as SecretsManagerClient5,
17510
- GetSecretValueCommand as GetSecretValueCommand5,
17553
+ SecretsManagerClient as SecretsManagerClient6,
17554
+ GetSecretValueCommand as GetSecretValueCommand6,
17511
17555
  PutSecretValueCommand,
17512
17556
  CreateSecretCommand
17513
17557
  } from "@aws-sdk/client-secrets-manager";
17514
17558
  import input from "@inquirer/input";
17515
17559
  import password from "@inquirer/password";
17516
- import {
17517
- buildInstanceIndexValue,
17518
- instanceIndexSecretId,
17519
- isInstanceKey,
17520
- parseInstanceIndex
17521
- } from "@mesh-tech/secrets";
17522
17560
  async function ensureAwsCredentialsForStack(stack) {
17523
17561
  if (process.env.AWS_ACCESS_KEY_ID || process.env.AWS_SESSION_TOKEN) return;
17524
17562
  if (!stack) return;
@@ -17658,7 +17696,7 @@ async function setCommand(servicePath, opts) {
17658
17696
  const region = opts.region ?? process.env.AWS_REGION ?? "us-east-2";
17659
17697
  await ensureAwsCredentialsForStack(stackOpt ?? context.stage);
17660
17698
  const ssmClient = new SSMClient2({ region });
17661
- const smClient = new SecretsManagerClient5({ region });
17699
+ const smClient = new SecretsManagerClient6({ region });
17662
17700
  const services = await discoverExternalServices(
17663
17701
  ssmClient,
17664
17702
  context.tenant,
@@ -17712,7 +17750,7 @@ Usage: mesh secrets set external/<name>`);
17712
17750
  let existing = {};
17713
17751
  try {
17714
17752
  const response = await smClient.send(
17715
- new GetSecretValueCommand5({ SecretId: secretId })
17753
+ new GetSecretValueCommand6({ SecretId: secretId })
17716
17754
  );
17717
17755
  if (response.SecretString) {
17718
17756
  existing = JSON.parse(response.SecretString);
@@ -17824,7 +17862,7 @@ async function addKeyToInstanceIndex(client, secretPrefix, key, serviceName) {
17824
17862
  try {
17825
17863
  let keys = [];
17826
17864
  try {
17827
- const res = await client.send(new GetSecretValueCommand5({ SecretId: indexId }));
17865
+ const res = await client.send(new GetSecretValueCommand6({ SecretId: indexId }));
17828
17866
  keys = parseInstanceIndex(res.SecretString ?? "");
17829
17867
  } catch (err) {
17830
17868
  if (!isResourceNotFound(err)) throw err;
@@ -17891,6 +17929,7 @@ async function writeConfigMirror(client, secretId, schema, merged, meta) {
17891
17929
  var init_set = __esm({
17892
17930
  "libs/mesh-cli/src/commands/secrets/set.ts"() {
17893
17931
  "use strict";
17932
+ init_src3();
17894
17933
  init_context();
17895
17934
  init_log();
17896
17935
  init_stack_flag();
@@ -17902,18 +17941,12 @@ var init_set = __esm({
17902
17941
  // libs/mesh-cli/src/commands/secrets/reindex.ts
17903
17942
  import { SSMClient as SSMClient3 } from "@aws-sdk/client-ssm";
17904
17943
  import {
17905
- SecretsManagerClient as SecretsManagerClient6,
17944
+ SecretsManagerClient as SecretsManagerClient7,
17906
17945
  ListSecretsCommand,
17907
- GetSecretValueCommand as GetSecretValueCommand6,
17946
+ GetSecretValueCommand as GetSecretValueCommand7,
17908
17947
  PutSecretValueCommand as PutSecretValueCommand2,
17909
17948
  CreateSecretCommand as CreateSecretCommand2
17910
17949
  } from "@aws-sdk/client-secrets-manager";
17911
- import {
17912
- buildInstanceIndexValue as buildInstanceIndexValue2,
17913
- instanceIndexSecretId as instanceIndexSecretId2,
17914
- instanceKeyFromSecretName,
17915
- parseInstanceIndex as parseInstanceIndex2
17916
- } from "@mesh-tech/secrets";
17917
17950
  async function scanInstanceKeys(client, secretPrefix) {
17918
17951
  const keys = [];
17919
17952
  let nextToken;
@@ -17941,7 +17974,7 @@ async function reindexCommand(servicePath, opts) {
17941
17974
  const region = opts.region ?? process.env.AWS_REGION ?? "us-east-2";
17942
17975
  await ensureAwsCredentialsForStack(stackOpt ?? context.stage);
17943
17976
  const ssmClient = new SSMClient3({ region });
17944
- const smClient = new SecretsManagerClient6({ region });
17977
+ const smClient = new SecretsManagerClient7({ region });
17945
17978
  const services = await discoverExternalServices(
17946
17979
  ssmClient,
17947
17980
  context.tenant,
@@ -17970,15 +18003,15 @@ Usage: mesh secrets reindex external/<name>`);
17970
18003
  process.exit(1);
17971
18004
  }
17972
18005
  const secretPrefix = svc.meta.secretPrefix;
17973
- const indexId = instanceIndexSecretId2(secretPrefix);
18006
+ const indexId = instanceIndexSecretId(secretPrefix);
17974
18007
  const actual = [...new Set(await scanInstanceKeys(smClient, secretPrefix))].sort();
17975
18008
  let listed = [];
17976
18009
  let indexExists = true;
17977
18010
  let malformed = false;
17978
18011
  try {
17979
- const res = await smClient.send(new GetSecretValueCommand6({ SecretId: indexId }));
18012
+ const res = await smClient.send(new GetSecretValueCommand7({ SecretId: indexId }));
17980
18013
  try {
17981
- listed = parseInstanceIndex2(res.SecretString ?? "");
18014
+ listed = parseInstanceIndex(res.SecretString ?? "");
17982
18015
  } catch {
17983
18016
  malformed = true;
17984
18017
  logInfo(`Existing index at ${indexId} is malformed \u2014 rebuilding from scratch.`);
@@ -18005,8 +18038,8 @@ Usage: mesh secrets reindex external/<name>`);
18005
18038
  logSuccess(`Index rebuilt: ${indexId} now lists ${actual.length} instance(s).`);
18006
18039
  }
18007
18040
  async function writeInstanceIndex(client, secretPrefix, serviceName, keys) {
18008
- const indexId = instanceIndexSecretId2(secretPrefix);
18009
- const secretString = buildInstanceIndexValue2(keys);
18041
+ const indexId = instanceIndexSecretId(secretPrefix);
18042
+ const secretString = buildInstanceIndexValue(keys);
18010
18043
  try {
18011
18044
  await client.send(
18012
18045
  new PutSecretValueCommand2({ SecretId: indexId, SecretString: secretString })
@@ -18032,6 +18065,7 @@ async function writeInstanceIndex(client, secretPrefix, serviceName, keys) {
18032
18065
  var init_reindex = __esm({
18033
18066
  "libs/mesh-cli/src/commands/secrets/reindex.ts"() {
18034
18067
  "use strict";
18068
+ init_src3();
18035
18069
  init_context();
18036
18070
  init_log();
18037
18071
  init_stack_flag();
@@ -18045,8 +18079,8 @@ import {
18045
18079
  GetParametersByPathCommand as GetParametersByPathCommand2
18046
18080
  } from "@aws-sdk/client-ssm";
18047
18081
  import {
18048
- SecretsManagerClient as SecretsManagerClient7,
18049
- GetSecretValueCommand as GetSecretValueCommand7,
18082
+ SecretsManagerClient as SecretsManagerClient8,
18083
+ GetSecretValueCommand as GetSecretValueCommand8,
18050
18084
  PutSecretValueCommand as PutSecretValueCommand3,
18051
18085
  CreateSecretCommand as CreateSecretCommand3,
18052
18086
  ListSecretsCommand as ListSecretsCommand2
@@ -18135,7 +18169,7 @@ function isResourceNotFound2(err) {
18135
18169
  }
18136
18170
  async function readSecret(client, secretId) {
18137
18171
  try {
18138
- const res = await client.send(new GetSecretValueCommand7({ SecretId: secretId }));
18172
+ const res = await client.send(new GetSecretValueCommand8({ SecretId: secretId }));
18139
18173
  return res.SecretString ? JSON.parse(res.SecretString) : null;
18140
18174
  } catch (err) {
18141
18175
  if (isResourceNotFound2(err)) return null;
@@ -18161,7 +18195,7 @@ async function writeSecret2(client, secretId, values, description) {
18161
18195
  }
18162
18196
  async function secretExists(client, secretId) {
18163
18197
  try {
18164
- await client.send(new GetSecretValueCommand7({ SecretId: secretId }));
18198
+ await client.send(new GetSecretValueCommand8({ SecretId: secretId }));
18165
18199
  return true;
18166
18200
  } catch (err) {
18167
18201
  if (isResourceNotFound2(err)) return false;
@@ -18241,7 +18275,7 @@ async function migrateConfigCommand(opts) {
18241
18275
  const context = detectContext(resolveStackOption(opts));
18242
18276
  const region = opts.region ?? process.env.AWS_REGION ?? "us-east-2";
18243
18277
  const ssmClient = new SSMClient4({ region });
18244
- const smClient = new SecretsManagerClient7({ region });
18278
+ const smClient = new SecretsManagerClient8({ region });
18245
18279
  logInfo(`Migrating .config mirrors for ${context.tenant}/${context.platformEnv}`);
18246
18280
  if (opts.dryRun) logInfo("DRY-RUN mode \u2014 no writes");
18247
18281
  if (opts.force) logInfo("FORCE mode \u2014 overwrite existing .config");
@@ -20174,8 +20208,8 @@ import * as fs35 from "fs";
20174
20208
  import * as os12 from "os";
20175
20209
  import * as path42 from "path";
20176
20210
  import {
20177
- SecretsManagerClient as SecretsManagerClient8,
20178
- GetSecretValueCommand as GetSecretValueCommand8
20211
+ SecretsManagerClient as SecretsManagerClient9,
20212
+ GetSecretValueCommand as GetSecretValueCommand9
20179
20213
  } from "@aws-sdk/client-secrets-manager";
20180
20214
  function resolveTenantEnv(options) {
20181
20215
  if (options.tenant && options.env) {
@@ -20438,10 +20472,10 @@ async function tunnelExternal(name, options) {
20438
20472
  const { appTenant, appStage } = resolveCredentialAxis(options);
20439
20473
  const secretId = externalSecretId(appTenant, appStage, name, key);
20440
20474
  const setHint = `mesh secrets set external/${name}${key ? ` --key=${key}` : ""}`;
20441
- const sm = new SecretsManagerClient8({});
20475
+ const sm = new SecretsManagerClient9({});
20442
20476
  let creds;
20443
20477
  try {
20444
- const out = await sm.send(new GetSecretValueCommand8({ SecretId: secretId }));
20478
+ const out = await sm.send(new GetSecretValueCommand9({ SecretId: secretId }));
20445
20479
  creds = JSON.parse(out.SecretString ?? "{}");
20446
20480
  } catch (err) {
20447
20481
  logError(
@@ -22436,7 +22470,7 @@ __export(src_exports2, {
22436
22470
  validateWorkflowPatches: () => validateWorkflowPatches,
22437
22471
  walkProcessNodes: () => walkProcessNodes
22438
22472
  });
22439
- var init_src3 = __esm({
22473
+ var init_src4 = __esm({
22440
22474
  "libs/workflow-model/src/index.ts"() {
22441
22475
  "use strict";
22442
22476
  init_workflow_ir();
@@ -22805,8 +22839,8 @@ function registerWorkflowCommands(program2) {
22805
22839
  let parseProcessArtifact2;
22806
22840
  let lintProcess2;
22807
22841
  try {
22808
- ({ parseProcessArtifact: parseProcessArtifact2 } = await Promise.resolve().then(() => (init_src3(), src_exports2)));
22809
- ({ lintProcess: lintProcess2 } = await Promise.resolve().then(() => (init_src3(), src_exports2)));
22842
+ ({ parseProcessArtifact: parseProcessArtifact2 } = await Promise.resolve().then(() => (init_src4(), src_exports2)));
22843
+ ({ lintProcess: lintProcess2 } = await Promise.resolve().then(() => (init_src4(), src_exports2)));
22810
22844
  } catch {
22811
22845
  logError(
22812
22846
  "Cannot resolve @mesh-tech/workflow-model (parseProcessArtifact / lintProcess).\nIt is bundled into the published CLI \u2014 on a registry install this means a broken install; reinstall the CLI. In the monorepo, run the scoped install (pnpm bootstrap:worktree @mesh-tech/mesh-cli)."