@todoforai/cli 0.1.36 → 0.1.38
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/todoforai-cli.js +42 -43
- package/package.json +1 -1
package/dist/todoforai-cli.js
CHANGED
|
@@ -42893,8 +42893,8 @@ class ApiClient {
|
|
|
42893
42893
|
form.append("file", file, filename);
|
|
42894
42894
|
form.append("todoId", todoId);
|
|
42895
42895
|
for (const [k, v] of Object.entries(opts))
|
|
42896
|
-
if (v)
|
|
42897
|
-
form.append(k, v);
|
|
42896
|
+
if (v !== undefined && v !== "")
|
|
42897
|
+
form.append(k, String(v));
|
|
42898
42898
|
const url = `${this.apiUrl}${restBasePath(this.apiKey)}/resources/show`;
|
|
42899
42899
|
const res = await fetch(url, {
|
|
42900
42900
|
method: "POST",
|
|
@@ -42932,6 +42932,26 @@ class ApiClient {
|
|
|
42932
42932
|
throw new Error(`API GET /resources/show failed: ${res.status} ${await res.text()}`);
|
|
42933
42933
|
return res.json();
|
|
42934
42934
|
}
|
|
42935
|
+
async patchSite(siteId, body) {
|
|
42936
|
+
const res = await fetch(`${this.apiUrl}${restBasePath(this.apiKey)}/resources/sites/${siteId}`, {
|
|
42937
|
+
method: "PATCH",
|
|
42938
|
+
headers: { "x-api-key": this.apiKey, "Content-Type": "application/json" },
|
|
42939
|
+
body: JSON.stringify(body),
|
|
42940
|
+
signal: AbortSignal.timeout(30000)
|
|
42941
|
+
});
|
|
42942
|
+
if (!res.ok)
|
|
42943
|
+
throw new Error(`API PATCH site failed: ${res.status} ${await res.text()}`);
|
|
42944
|
+
return res.json();
|
|
42945
|
+
}
|
|
42946
|
+
async deleteSite(siteId) {
|
|
42947
|
+
const res = await fetch(`${this.apiUrl}${restBasePath(this.apiKey)}/resources/sites/${siteId}`, {
|
|
42948
|
+
method: "DELETE",
|
|
42949
|
+
headers: { "x-api-key": this.apiKey },
|
|
42950
|
+
signal: AbortSignal.timeout(30000)
|
|
42951
|
+
});
|
|
42952
|
+
if (!res.ok)
|
|
42953
|
+
throw new Error(`API DELETE site failed: ${res.status} ${await res.text()}`);
|
|
42954
|
+
}
|
|
42935
42955
|
async upsertCard(projectId, name, html, opts = {}) {
|
|
42936
42956
|
const form = new FormData;
|
|
42937
42957
|
form.append("file", html, `${name}.html`);
|
|
@@ -44303,7 +44323,7 @@ import { parseArgs } from "util";
|
|
|
44303
44323
|
// package.json
|
|
44304
44324
|
var package_default = {
|
|
44305
44325
|
name: "@todoforai/cli",
|
|
44306
|
-
version: "0.1.
|
|
44326
|
+
version: "0.1.38",
|
|
44307
44327
|
type: "module",
|
|
44308
44328
|
bin: {
|
|
44309
44329
|
"todoforai-cli": "bin/todoforai-cli.js",
|
|
@@ -44363,12 +44383,10 @@ Usage:
|
|
|
44363
44383
|
tfa-cli show <file|-> [todo-id] # Show a file in the chat (rendered by mimetype; - reads stdin)
|
|
44364
44384
|
# [--title T] [--alias A] [--mime M] [--card <name>] [--link] [--json]
|
|
44365
44385
|
# --link = compact chip (name+size+download) instead of inline render
|
|
44366
|
-
# The
|
|
44367
|
-
#
|
|
44368
|
-
#
|
|
44369
|
-
tfa-cli show
|
|
44370
|
-
tfa-cli show get <site-id> [out] [--rev <att>] # Fetch its bytes (latest, or a given version)
|
|
44371
|
-
tfa-cli show rm <site-id> # Delete it and all its versions
|
|
44386
|
+
# The file gets a stable public url: sites.todofor.ai/<site-id>
|
|
44387
|
+
# (latest; /<site-id>/<attachment-id> = frozen version). --site <id>
|
|
44388
|
+
# pushes a new version to an existing url (from any todo).
|
|
44389
|
+
tfa-cli show rm <site-id> # Take a shown file down (all versions)
|
|
44372
44390
|
tfa-cli show list [todo-id] # List show blocks (ref, title, mime/url, card)
|
|
44373
44391
|
# [--project <id>] [--card <name>] [--json]
|
|
44374
44392
|
# no todo-id + --project (or $TODOFORAI_PROJECT_ID) = every todo
|
|
@@ -44463,9 +44481,6 @@ function parseCliArgs() {
|
|
|
44463
44481
|
card: { type: "string" },
|
|
44464
44482
|
link: { type: "boolean", default: false },
|
|
44465
44483
|
site: { type: "string" },
|
|
44466
|
-
public: { type: "boolean", default: false },
|
|
44467
|
-
rev: { type: "string" },
|
|
44468
|
-
off: { type: "boolean", default: false },
|
|
44469
44484
|
direction: { type: "string" },
|
|
44470
44485
|
"business-context": { type: "string" },
|
|
44471
44486
|
seed: { type: "string" },
|
|
@@ -47650,11 +47665,23 @@ Cancelled by user (Ctrl+C)
|
|
|
47650
47665
|
}
|
|
47651
47666
|
return;
|
|
47652
47667
|
}
|
|
47668
|
+
if (positionals[0] === "show" && positionals[1] === "rm") {
|
|
47669
|
+
const id = positionals[2];
|
|
47670
|
+
if (!id) {
|
|
47671
|
+
process.stderr.write(`${RED}Usage: tfa-cli show rm <site-id>${RESET}
|
|
47672
|
+
`);
|
|
47673
|
+
process.exit(2);
|
|
47674
|
+
}
|
|
47675
|
+
await api.deleteSite(id);
|
|
47676
|
+
process.stderr.write(`${GREEN}\u2705 deleted ${id}${RESET}
|
|
47677
|
+
`);
|
|
47678
|
+
return;
|
|
47679
|
+
}
|
|
47653
47680
|
if (positionals[0] === "show") {
|
|
47654
47681
|
const [, filePath, todoArg] = positionals;
|
|
47655
47682
|
const todoId = todoArg || getEnv("TODO_ID") || cfgScope.data.last_todo_id;
|
|
47656
47683
|
if (!filePath || !todoId) {
|
|
47657
|
-
process.stderr.write(`${RED}Usage: tfa-cli show <file|-> [todo-id] [--title T] [--alias A] [--mime M] [--card <name>] [--link] [--site <id>]
|
|
47684
|
+
process.stderr.write(`${RED}Usage: tfa-cli show <file|-> [todo-id] [--title T] [--alias A] [--mime M] [--card <name>] [--link] [--site <id>]${RESET}
|
|
47658
47685
|
`);
|
|
47659
47686
|
process.exit(2);
|
|
47660
47687
|
}
|
|
@@ -47683,40 +47710,12 @@ Cancelled by user (Ctrl+C)
|
|
|
47683
47710
|
mime: args.mime,
|
|
47684
47711
|
card: args.card,
|
|
47685
47712
|
display: args.link ? "link" : undefined,
|
|
47686
|
-
site: args.site
|
|
47687
|
-
public: args.public ? true : undefined
|
|
47713
|
+
site: args.site
|
|
47688
47714
|
});
|
|
47689
47715
|
if (args.json)
|
|
47690
47716
|
console.log(JSON.stringify(res, null, 2));
|
|
47691
47717
|
else
|
|
47692
|
-
console.log(res.
|
|
47693
|
-
return;
|
|
47694
|
-
}
|
|
47695
|
-
if (positionals[0] === "show" && ["public", "get", "rm"].includes(positionals[1] ?? "")) {
|
|
47696
|
-
const sub = positionals[1];
|
|
47697
|
-
const id = positionals[2];
|
|
47698
|
-
if (!id) {
|
|
47699
|
-
process.stderr.write(`${RED}Usage: tfa-cli show public <site-id> [--off] | get <site-id> [out] [--rev <att>] | rm <site-id>${RESET}
|
|
47700
|
-
`);
|
|
47701
|
-
process.exit(2);
|
|
47702
|
-
}
|
|
47703
|
-
if (sub === "public") {
|
|
47704
|
-
const site = await api.patchSite(id, { isPublic: !args.off });
|
|
47705
|
-
console.log(site.url ?? `${site.id} (private)`);
|
|
47706
|
-
} else if (sub === "rm") {
|
|
47707
|
-
await api.deleteSite(id);
|
|
47708
|
-
process.stderr.write(`${GREEN}\u2705 deleted ${id}${RESET}
|
|
47709
|
-
`);
|
|
47710
|
-
} else {
|
|
47711
|
-
const bytes = await api.getSiteBytes(id, args.rev);
|
|
47712
|
-
const out = positionals[3];
|
|
47713
|
-
if (out && out !== "-") {
|
|
47714
|
-
await Bun.write(resolve3(out), bytes);
|
|
47715
|
-
process.stderr.write(`${GREEN}\u2705 ${out}${RESET}
|
|
47716
|
-
`);
|
|
47717
|
-
} else
|
|
47718
|
-
process.stdout.write(new Uint8Array(bytes));
|
|
47719
|
-
}
|
|
47718
|
+
console.log(res.url ? `${res.ref} site=${res.siteId} ${res.url}` : res.ref);
|
|
47720
47719
|
return;
|
|
47721
47720
|
}
|
|
47722
47721
|
if (positionals[0] === "open") {
|