@erdoai/cli 0.84.0 → 0.85.1

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 (2) hide show
  1. package/dist/index.js +33 -11
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1225,10 +1225,11 @@ var ErdoClient = class {
1225
1225
  `/v1/integrations/${encodeURIComponent(integrationId)}`
1226
1226
  );
1227
1227
  }
1228
- getConnectionScope(integrationId) {
1228
+ getConnectionScope(integrationId, params = {}) {
1229
+ const query = params.include_options === void 0 ? "" : `?include_options=${params.include_options}`;
1229
1230
  return this.request(
1230
1231
  "GET",
1231
- `/v1/integrations/${encodeURIComponent(integrationId)}/connection-scope`
1232
+ `/v1/integrations/${encodeURIComponent(integrationId)}/connection-scope${query}`
1232
1233
  );
1233
1234
  }
1234
1235
  setConnectionScope(integrationId, accountId) {
@@ -1737,6 +1738,12 @@ async function resolveSecretInput(options) {
1737
1738
  return void 0;
1738
1739
  }
1739
1740
 
1741
+ // src/integrations.ts
1742
+ function formatIntegrationListRow(i) {
1743
+ const provided = i.provided_by_organization_slug ? ` provided by ${i.provided_by_organization_slug}` : "";
1744
+ return `${i.app} ${i.status} ${i.auth_type} ${i.name} ${i.id}${provided}`;
1745
+ }
1746
+
1740
1747
  // src/scope.ts
1741
1748
  import { Option } from "commander";
1742
1749
  var ORG_ENV = "ERDO_ORG";
@@ -6029,13 +6036,10 @@ filterCmd.command("list <slug>").description("List the default filters on a data
6029
6036
  }
6030
6037
  });
6031
6038
  var integrationsCmd = program.command("integrations").description("Connect and inspect integrations");
6032
- integrationsCmd.command("list").description("List connected integrations").action(async () => {
6039
+ integrationsCmd.command("list").description("List connected integrations \u2014 app, status, auth type, name, then the connection's id (what --from-connection takes)").action(async () => {
6033
6040
  try {
6034
6041
  const { integrations } = await new ErdoClient().listIntegrations();
6035
- for (const i of integrations) {
6036
- const provided = i.provided_by_organization_slug ? ` provided by ${i.provided_by_organization_slug}` : "";
6037
- console.log(`${i.app} ${i.status} ${i.auth_type} ${i.name}${provided}`);
6038
- }
6042
+ for (const i of integrations) console.log(formatIntegrationListRow(i));
6039
6043
  } catch (e) {
6040
6044
  fail(e);
6041
6045
  }
@@ -6051,8 +6055,21 @@ integrationsCmd.command("apps [query]").description("Search connectable apps (na
6051
6055
  integrationsCmd.command("connect <app>").description("Connect an app \u2014 pass its API key or other credentials with -c, or omit them to get a browser connect URL for OAuth apps").option("-c, --credential <key=value...>", "credential field, e.g. -c api_key=\u2026 (repeatable); rejected by OAuth apps, which have no credential to pass", (v, acc) => acc.concat(v), []).option("-n, --name <name>", "display name for the connection").option("--rotate", "replace the credentials of the app's existing connection instead of adding a second one \u2014 for a key that was rotated at the provider; requires -c").option("--share", "share the connection with the whole organization instead of keeping it private to you \u2014 for org-level credentials teammates and agents should see").option(
6052
6056
  "--provide-to-managed",
6053
6057
  "let the organizations you manage use this connection as if it were their own \u2014 for a vendor key your agency pays for. Key-authenticated native integrations only, connected in a manager organization"
6058
+ ).option(
6059
+ "--from-connection <integration-id>",
6060
+ "reuse a credential you verifiably supplied \u2014 find its connection id in column 5 of `erdo integrations list --org <that-org>`. The credential is copied inside Erdo and never shown. Legacy keys without supplier records require an authenticated credential update"
6054
6061
  ).action(async (app, opts) => {
6055
6062
  try {
6063
+ if (opts.fromConnection && opts.credential.length) {
6064
+ fail(new Error("pass either -c or --from-connection, not both \u2014 otherwise the connection would hold a credential you did not choose"));
6065
+ }
6066
+ if (opts.fromConnection && opts.rotate) {
6067
+ fail(
6068
+ new Error(
6069
+ "--from-connection creates a new connection from a credential you already hold, so it cannot be combined with --rotate, which replaces the credential on an existing one"
6070
+ )
6071
+ );
6072
+ }
6056
6073
  let credentials;
6057
6074
  if (opts.credential.length) {
6058
6075
  credentials = {};
@@ -6068,7 +6085,8 @@ integrationsCmd.command("connect <app>").description("Connect an app \u2014 pass
6068
6085
  credentials,
6069
6086
  rotate_credentials: opts.rotate || void 0,
6070
6087
  share_with_org: opts.share || void 0,
6071
- managed_access: opts.provideToManaged ? "managed_organizations" : void 0
6088
+ managed_access: opts.provideToManaged ? "managed_organizations" : void 0,
6089
+ credentials_from_integration_id: opts.fromConnection || void 0
6072
6090
  });
6073
6091
  print(res);
6074
6092
  const notes = [];
@@ -6130,20 +6148,24 @@ integrationsCmd.command("status <app>").description("Check whether an app is con
6130
6148
  }
6131
6149
  });
6132
6150
  var accountCmd = integrationsCmd.command("account").description("Read or set which provider account a connection operates");
6133
- accountCmd.command("show <integration-id>").description("Show which account a connection operates, and which it could (see: erdo integrations list)").action(async (integrationId) => {
6151
+ accountCmd.command("show <integration-id>").description("Show which account a connection operates, and which it could (see: erdo integrations list)").option("--no-options", "Read the stored account without contacting the provider").action(async (integrationId, opts) => {
6134
6152
  try {
6135
- const scope = await new ErdoClient().getConnectionScope(integrationId);
6153
+ const scope = await new ErdoClient().getConnectionScope(integrationId, { include_options: opts.options });
6136
6154
  if (!scope.has_connection_scope) {
6137
6155
  console.log("This integration does not choose a provider account per connection.");
6138
6156
  return;
6139
6157
  }
6140
6158
  console.log(scope.description);
6141
6159
  const selected = new Set(scope.selected.map((a) => a.id));
6142
- for (const account of scope.options) {
6160
+ for (const account of opts.options ? scope.options : scope.selected) {
6143
6161
  const marker = selected.has(account.id) ? "*" : " ";
6144
6162
  const owner = account.parent ? ` ${account.parent}` : "";
6145
6163
  console.log(`${marker} ${account.id} ${account.name} ${account.type}${owner}`);
6146
6164
  }
6165
+ if (!opts.options) {
6166
+ if (scope.selected.length === 0) console.error("No account recorded on this connection.");
6167
+ return;
6168
+ }
6147
6169
  if (scope.options.length === 0) {
6148
6170
  console.error(
6149
6171
  `
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@erdoai/cli",
3
- "version": "0.84.0",
3
+ "version": "0.85.1",
4
4
  "description": "Erdo CLI — drive datasets, pages, and evals from the terminal or CI",
5
5
  "type": "module",
6
6
  "bin": {