@erdoai/cli 0.41.0 → 0.43.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.
- package/dist/index.js +35 -9
- package/package.json +2 -2
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(
|
|
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(
|
|
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");
|
|
@@ -754,8 +772,11 @@ var ErdoClient = class {
|
|
|
754
772
|
);
|
|
755
773
|
}
|
|
756
774
|
// --- knowledge ---
|
|
757
|
-
listKnowledge() {
|
|
758
|
-
|
|
775
|
+
listKnowledge(visibility) {
|
|
776
|
+
const params = new URLSearchParams();
|
|
777
|
+
if (visibility) params.set("visibility", visibility);
|
|
778
|
+
const qs = params.toString();
|
|
779
|
+
return this.request("GET", `/v1/knowledge${qs ? `?${qs}` : ""}`);
|
|
759
780
|
}
|
|
760
781
|
searchKnowledge(query, limit) {
|
|
761
782
|
const params = new URLSearchParams({ query });
|
|
@@ -1168,10 +1189,12 @@ function summariseResults(results, cases = []) {
|
|
|
1168
1189
|
}
|
|
1169
1190
|
}
|
|
1170
1191
|
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)");
|
|
1192
|
+
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
1193
|
program.hook("preAction", (thisCommand) => {
|
|
1173
|
-
const
|
|
1194
|
+
const opts = thisCommand.opts();
|
|
1195
|
+
const org2 = opts.org;
|
|
1174
1196
|
if (org2) process.env.ERDO_ORG = org2;
|
|
1197
|
+
if (opts.project) process.env.ERDO_PROJECT = opts.project;
|
|
1175
1198
|
});
|
|
1176
1199
|
async function doLogin(opts) {
|
|
1177
1200
|
let token;
|
|
@@ -3112,9 +3135,12 @@ pipelinesCmd.command("executions <slug>").description("Show an event pipeline's
|
|
|
3112
3135
|
}
|
|
3113
3136
|
});
|
|
3114
3137
|
var knowledgeCmd = program.command("knowledge").description("Knowledge objects");
|
|
3115
|
-
knowledgeCmd.command("list").description("List knowledge objects").
|
|
3138
|
+
knowledgeCmd.command("list").description("List knowledge objects").option(
|
|
3139
|
+
"--public",
|
|
3140
|
+
"only entries opted into anonymous external surfaces (website widgets)"
|
|
3141
|
+
).action(async (opts) => {
|
|
3116
3142
|
try {
|
|
3117
|
-
print(await new ErdoClient().listKnowledge());
|
|
3143
|
+
print(await new ErdoClient().listKnowledge(opts.public ? "public" : void 0));
|
|
3118
3144
|
} catch (e) {
|
|
3119
3145
|
fail(e);
|
|
3120
3146
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@erdoai/cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Erdo CLI
|
|
3
|
+
"version": "0.43.0",
|
|
4
|
+
"description": "Erdo CLI — drive datasets, pages, and evals from the terminal or CI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"erdo": "dist/index.js"
|