@erdoai/cli 0.41.0 → 0.42.0

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 +25 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -127,9 +127,10 @@ function networkErrorFor(method, path, err) {
127
127
  return new ErdoNetworkError(`${method} ${path} failed: ${detail}`, cause);
128
128
  }
129
129
  var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
130
- async function rawRequest(baseURL, token, orgId, method, path, body) {
130
+ async function rawRequest(baseURL, token, orgId, projectId, method, path, body) {
131
131
  const headers = { Authorization: `Bearer ${token}` };
132
132
  if (orgId) headers["X-Organization-ID"] = orgId;
133
+ if (projectId) headers["X-Project-ID"] = projectId;
133
134
  if (body !== void 0) headers["Content-Type"] = "application/json";
134
135
  const upper = method.toUpperCase();
135
136
  const maxRetries = upper === "GET" || upper === "HEAD" ? 2 : 1;
@@ -178,13 +179,21 @@ function looksLikeHTML(text) {
178
179
  return head.startsWith("<!doctype html") || head.startsWith("<html") || head.includes("<head>");
179
180
  }
180
181
  function fetchMe(token, orgId) {
181
- return rawRequest(resolveApiUrl(), token, orgId, "GET", "/v1/me");
182
+ return rawRequest(
183
+ resolveApiUrl(),
184
+ token,
185
+ orgId,
186
+ void 0,
187
+ "GET",
188
+ "/v1/me"
189
+ );
182
190
  }
183
191
  var announcedOrg = false;
184
192
  var ErdoClient = class {
185
193
  baseURL;
186
194
  token;
187
195
  orgId;
196
+ projectId;
188
197
  orgPinned;
189
198
  orgName;
190
199
  constructor(orgOverride) {
@@ -196,6 +205,7 @@ var ErdoClient = class {
196
205
  }
197
206
  this.token = token;
198
207
  this.orgId = resolveOrgId(acct, orgOverride);
208
+ this.projectId = process.env.ERDO_PROJECT?.trim() || void 0;
199
209
  this.orgPinned = Boolean(orgOverride || process.env.ERDO_ORG);
200
210
  this.orgName = acct?.organizationName;
201
211
  }
@@ -217,7 +227,15 @@ var ErdoClient = class {
217
227
  }
218
228
  request(method, path, body) {
219
229
  this.announceOrgOnce(method);
220
- return rawRequest(this.baseURL, this.token, this.orgId, method, path, body);
230
+ return rawRequest(
231
+ this.baseURL,
232
+ this.token,
233
+ this.orgId,
234
+ this.projectId,
235
+ method,
236
+ path,
237
+ body
238
+ );
221
239
  }
222
240
  me() {
223
241
  return this.request("GET", "/v1/me");
@@ -1168,10 +1186,12 @@ function summariseResults(results, cases = []) {
1168
1186
  }
1169
1187
  }
1170
1188
  var program = new Command();
1171
- program.name("erdo").description("Erdo CLI").version(pkg.version).option("--org <idOrSlug>", "org to target for this command (overrides the active org)");
1189
+ program.name("erdo").description("Erdo CLI").version(pkg.version).option("--org <idOrSlug>", "org to target for this command (overrides the active org)").option("--project <uuid>", "project context for this command (must belong to the active org)");
1172
1190
  program.hook("preAction", (thisCommand) => {
1173
- const org2 = thisCommand.opts().org;
1191
+ const opts = thisCommand.opts();
1192
+ const org2 = opts.org;
1174
1193
  if (org2) process.env.ERDO_ORG = org2;
1194
+ if (opts.project) process.env.ERDO_PROJECT = opts.project;
1175
1195
  });
1176
1196
  async function doLogin(opts) {
1177
1197
  let token;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@erdoai/cli",
3
- "version": "0.41.0",
3
+ "version": "0.42.0",
4
4
  "description": "Erdo CLI \u2014 drive datasets, pages, and evals from the terminal or CI",
5
5
  "type": "module",
6
6
  "bin": {