@erdoai/cli 0.158.0 → 0.160.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 +48 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -197,6 +197,8 @@ async function rawRequest(baseURL, token, orgId, projectId, method, path, body,
|
|
|
197
197
|
res = await fetch(`${baseURL}${path}`, {
|
|
198
198
|
method,
|
|
199
199
|
headers,
|
|
200
|
+
// A 307/308 redirect would replay a non-idempotent mutation too.
|
|
201
|
+
redirect: retryNetworkFailures ? "follow" : "error",
|
|
200
202
|
body: body !== void 0 ? JSON.stringify(body) : void 0
|
|
201
203
|
});
|
|
202
204
|
} catch (err) {
|
|
@@ -330,6 +332,28 @@ var ErdoClient = class {
|
|
|
330
332
|
me() {
|
|
331
333
|
return this.request("GET", "/v1/me");
|
|
332
334
|
}
|
|
335
|
+
creditBalance() {
|
|
336
|
+
return this.request("GET", "/v1/credits/balance");
|
|
337
|
+
}
|
|
338
|
+
async grantCredits(organization, amount, reason) {
|
|
339
|
+
try {
|
|
340
|
+
const result = await this.request(
|
|
341
|
+
"POST",
|
|
342
|
+
"/v1/admin/credits/grant",
|
|
343
|
+
{ organization, amount, reason },
|
|
344
|
+
false
|
|
345
|
+
);
|
|
346
|
+
if (!result || typeof result.organization_id !== "string" || !result.organization_id.trim() || result.amount !== amount || !Number.isInteger(result.balance)) {
|
|
347
|
+
throw new Error("Grant response did not include the committed target, amount, and balance.");
|
|
348
|
+
}
|
|
349
|
+
return result;
|
|
350
|
+
} catch (error) {
|
|
351
|
+
if (!(error instanceof ErdoApiError) || error.status >= 500 || error.status === 408) {
|
|
352
|
+
throw new Error(`Credit grant outcome unknown. Do not repeat the grant. Inspect the target organization's credit ledger in the staff billing UI first. ${error instanceof Error ? error.message : String(error)}`);
|
|
353
|
+
}
|
|
354
|
+
throw error;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
333
357
|
listOrganizations() {
|
|
334
358
|
return this.request("GET", "/v1/organizations");
|
|
335
359
|
}
|
|
@@ -2679,6 +2703,27 @@ function compactEvalRunAttribution(run) {
|
|
|
2679
2703
|
var program = new Command2();
|
|
2680
2704
|
program.name("erdo").description("Erdo CLI").version(pkg.version);
|
|
2681
2705
|
bindScopeFlags(program);
|
|
2706
|
+
var credits = program.command("credits").description("Read organization credits");
|
|
2707
|
+
credits.command("balance").description("Read the current organization's credit balance (use --org to select)").action(async () => {
|
|
2708
|
+
try {
|
|
2709
|
+
print(await new ErdoClient().creditBalance());
|
|
2710
|
+
} catch (error) {
|
|
2711
|
+
fail(error);
|
|
2712
|
+
}
|
|
2713
|
+
});
|
|
2714
|
+
var admin = program.command("admin").description("Erdo staff administration");
|
|
2715
|
+
admin.command("credits").description("Staff-only manual credit grants").command("grant <orgSlugOrId>").description("Grant non-expiring credits without payment; requires an authenticated staff user").requiredOption("--amount <integer>", "Positive integer credits to grant").requiredOption("--reason <text>", "Audit reason").action(async (organization, options) => {
|
|
2716
|
+
try {
|
|
2717
|
+
if (!/^[0-9]+$/.test(options.amount) || Number(options.amount) <= 0 || Number(options.amount) > 2147483647) {
|
|
2718
|
+
throw new Error("--amount must be a positive integer no greater than 2147483647");
|
|
2719
|
+
}
|
|
2720
|
+
if (!organization.trim()) throw new Error("Target organization is required");
|
|
2721
|
+
if (!options.reason.trim()) throw new Error("--reason must not be empty");
|
|
2722
|
+
print(await new ErdoClient().grantCredits(organization.trim(), Number(options.amount), options.reason.trim()));
|
|
2723
|
+
} catch (error) {
|
|
2724
|
+
fail(error);
|
|
2725
|
+
}
|
|
2726
|
+
});
|
|
2682
2727
|
async function doLogin(opts) {
|
|
2683
2728
|
let token;
|
|
2684
2729
|
let me;
|
|
@@ -7882,7 +7927,7 @@ Read one with: erdo datasets fetch ${res.dataset_slug} --revision <id> --sql "SE
|
|
|
7882
7927
|
});
|
|
7883
7928
|
datasetsCmd.command("schema <slug>").alias("describe").description(
|
|
7884
7929
|
"Show physical columns by default, or the declared write contract with --declared. File datasets read the stored `data` table; integration datasets show their discovered resource tables and columns. For an integration dataset, choose a resource/table explicitly when fetching: `datasets fetch <slug> --sql 'SELECT * FROM <table>'`."
|
|
7885
|
-
).option("--json", "print the raw JSON result instead of a table").option("--declared", "read the declared write contract (column names, type hints, required flags, semantic roles) instead of the physical columns").action(async (slug, opts) => {
|
|
7930
|
+
).option("--json", "print the raw JSON result instead of a table").option("--declared", "read the declared write contract (column names, type hints, required flags, semantic roles, currency) instead of the physical columns").action(async (slug, opts) => {
|
|
7886
7931
|
try {
|
|
7887
7932
|
const client = new ErdoClient();
|
|
7888
7933
|
if (opts.declared) {
|
|
@@ -7905,8 +7950,8 @@ datasetsCmd.command("schema <slug>").alias("describe").description(
|
|
|
7905
7950
|
return;
|
|
7906
7951
|
}
|
|
7907
7952
|
printAlignedTable(
|
|
7908
|
-
["column", "type", "required", "semantic role", "description"],
|
|
7909
|
-
schema.columns.map((column) => [column.name, column.type || "", column.required ? "yes" : "no", column.semantic_role || "", column.description || ""])
|
|
7953
|
+
["column", "type", "required", "semantic role", "currency", "description"],
|
|
7954
|
+
schema.columns.map((column) => [column.name, column.type || "", column.required ? "yes" : "no", column.semantic_role || "", column.currency || "", column.description || ""])
|
|
7910
7955
|
);
|
|
7911
7956
|
return;
|
|
7912
7957
|
}
|