@formigio/fazemos-cli 0.10.41 → 0.10.42

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
@@ -7959,20 +7959,34 @@ apiKeys
7959
7959
  .requiredOption('-n, --name <name>', 'Key name (e.g., joe-orchestrator)')
7960
7960
  .requiredOption('-m, --member <id>', 'Member ID to bind the key to')
7961
7961
  .option('-d, --description <desc>', 'Description')
7962
+ .option('--scope <scope>', 'Key scope: org (cross-project, owner/admin only) or project (default, today\'s behavior). --scope org mints a key that works across all projects the member belongs to; active project is ignored.', 'project')
7962
7963
  .action(async (opts) => {
7963
7964
  try {
7964
7965
  const body = { name: opts.name, memberId: opts.member };
7965
7966
  if (opts.description)
7966
7967
  body.description = opts.description;
7968
+ // F45 — pass scope in POST body; 'project' preserves today's back-compat behavior
7969
+ body.scope = opts.scope;
7967
7970
  const data = await api('POST', '/api/api-keys', body);
7971
+ const scope = data.apiKey.scope ?? opts.scope;
7968
7972
  console.log(chalk.green(`API key created: ${opts.name}`));
7969
- console.log(` Key: ${chalk.yellow(data.rawKey)}`);
7970
- console.log(` ID: ${data.apiKey.id}`);
7973
+ console.log(` Key: ${chalk.yellow(data.rawKey)}`);
7974
+ console.log(` ID: ${data.apiKey.id}`);
7975
+ console.log(` Scope: ${scope === 'org' ? chalk.cyan('org') : scope}`);
7971
7976
  console.log('');
7972
7977
  console.log(chalk.red(' ⚠ Save this key now — it will not be shown again.'));
7973
7978
  }
7974
7979
  catch (err) {
7975
- console.error(chalk.red(err.message));
7980
+ // F45 — map specific API error codes to friendly messages
7981
+ if (err.code === 'INSUFFICIENT_ROLE') {
7982
+ console.error(chalk.red('Error: Only org owners and admins can mint org-scoped keys'));
7983
+ }
7984
+ else if (err.code === 'INVALID_SCOPE') {
7985
+ console.error(chalk.red("Error: --scope must be 'org' or 'project'"));
7986
+ }
7987
+ else {
7988
+ console.error(chalk.red(err.message));
7989
+ }
7976
7990
  process.exit(1);
7977
7991
  }
7978
7992
  });
@@ -7987,7 +8001,9 @@ apiKeys
7987
8001
  return;
7988
8002
  }
7989
8003
  for (const k of data.apiKeys) {
7990
- console.log(` ${chalk.cyan(k.name)}${k.id} (created ${k.created_at})`);
8004
+ // F45 show scope field (org or project) alongside existing fields
8005
+ const scopeLabel = k.scope === 'org' ? ` [${chalk.cyan('org-scoped')}]` : '';
8006
+ console.log(` ${chalk.cyan(k.name)}${scopeLabel} — ${k.id} (created ${k.created_at})`);
7991
8007
  }
7992
8008
  }
7993
8009
  catch (err) {