@imbrace/cli 0.3.0 → 0.4.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.
- package/dist/base-command.js +20 -18
- package/dist/commands/ai-agent/create.js +8 -7
- package/dist/commands/ai-agent/delete.js +6 -4
- package/dist/commands/ai-agent/get.js +5 -5
- package/dist/commands/ai-agent/list-files.js +7 -5
- package/dist/commands/ai-agent/list-folders.js +7 -6
- package/dist/commands/ai-agent/list-models.js +5 -5
- package/dist/commands/ai-agent/list-providers.js +5 -5
- package/dist/commands/ai-agent/list.js +7 -5
- package/dist/commands/ai-agent/update.js +5 -4
- package/dist/commands/data-board/create-field.js +6 -4
- package/dist/commands/data-board/create-item.js +10 -8
- package/dist/commands/data-board/create.js +8 -6
- package/dist/commands/data-board/delete-item.js +6 -4
- package/dist/commands/data-board/export-csv.js +3 -2
- package/dist/commands/data-board/list-items.js +9 -11
- package/dist/commands/data-board/list.js +7 -5
- package/dist/commands/data-board/update-item.js +8 -6
- package/dist/commands/login.d.ts +0 -1
- package/dist/commands/login.js +39 -55
- package/dist/commands/whoami.js +0 -2
- package/dist/commands/workflow/conn/create.js +33 -16
- package/dist/commands/workflow/conn/delete.js +6 -4
- package/dist/commands/workflow/conn/get.js +5 -4
- package/dist/commands/workflow/conn/list.js +7 -5
- package/dist/commands/workflow/create.js +16 -14
- package/dist/commands/workflow/delete.js +6 -4
- package/dist/commands/workflow/disable.js +9 -4
- package/dist/commands/workflow/enable.js +9 -4
- package/dist/commands/workflow/folder/create.js +11 -10
- package/dist/commands/workflow/folder/delete.js +6 -4
- package/dist/commands/workflow/folder/get.js +5 -4
- package/dist/commands/workflow/folder/list.js +7 -5
- package/dist/commands/workflow/folder/update.js +6 -4
- package/dist/commands/workflow/get.js +5 -4
- package/dist/commands/workflow/list.js +8 -6
- package/dist/commands/workflow/mcp/create.js +10 -9
- package/dist/commands/workflow/mcp/delete.js +6 -4
- package/dist/commands/workflow/mcp/get.js +5 -4
- package/dist/commands/workflow/mcp/list.js +9 -5
- package/dist/commands/workflow/mcp/rotate-token.js +7 -5
- package/dist/commands/workflow/move.js +10 -4
- package/dist/commands/workflow/node/add-raw.js +6 -4
- package/dist/commands/workflow/node/add.js +70 -21
- package/dist/commands/workflow/node/delete.js +12 -4
- package/dist/commands/workflow/node/list.js +8 -5
- package/dist/commands/workflow/node/update.js +44 -8
- package/dist/commands/workflow/piece/detail.js +5 -4
- package/dist/commands/workflow/piece/list.js +22 -6
- package/dist/commands/workflow/publish.js +9 -4
- package/dist/commands/workflow/run-detail.js +5 -4
- package/dist/commands/workflow/run.js +10 -7
- package/dist/commands/workflow/runs.js +7 -5
- package/dist/config.d.ts +5 -5
- package/dist/config.js +6 -12
- package/dist/lib/ai-agent.d.ts +40 -0
- package/dist/lib/ai-agent.js +150 -0
- package/dist/lib/client.d.ts +7 -0
- package/dist/lib/client.js +21 -0
- package/dist/lib/gateway.d.ts +3 -0
- package/dist/lib/gateway.js +31 -0
- package/dist/lib/workflow.d.ts +20 -0
- package/dist/lib/workflow.js +71 -0
- package/dist/select-board.js +4 -3
- package/llms.txt +1 -0
- package/package.json +2 -2
- package/dist/http.d.ts +0 -9
- package/dist/http.js +0 -40
package/dist/base-command.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Command, Flags } from "@oclif/core";
|
|
2
2
|
import { select, input, password } from "@inquirer/prompts";
|
|
3
|
+
import { ImbraceClient } from "@imbrace/sdk";
|
|
3
4
|
import { getCredential, saveCredential } from "./config.js";
|
|
4
|
-
import {
|
|
5
|
+
import { resetClient } from "./lib/client.js";
|
|
5
6
|
export class BaseCommand extends Command {
|
|
6
7
|
// Enable -h as alias for --help on every command (helps coding agents discover usage)
|
|
7
8
|
static baseFlags = {
|
|
@@ -22,24 +23,25 @@ export class BaseCommand extends Command {
|
|
|
22
23
|
{ name: "Email + Password", value: "password" },
|
|
23
24
|
],
|
|
24
25
|
});
|
|
25
|
-
let body;
|
|
26
|
-
if (method === "api-key") {
|
|
27
|
-
const apiKey = await input({ message: "API Key (sk-...):" });
|
|
28
|
-
body = { apiKey };
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
const email = await input({ message: "Email:" });
|
|
32
|
-
const pass = await password({ message: "Password:" });
|
|
33
|
-
body = { email, password: pass };
|
|
34
|
-
}
|
|
35
26
|
try {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
27
|
+
if (method === "api-key") {
|
|
28
|
+
const apiKey = await input({ message: "API Key (api_... or sk-...):" });
|
|
29
|
+
const client = new ImbraceClient({ apiKey });
|
|
30
|
+
await client.boards.list();
|
|
31
|
+
saveCredential({ credential: apiKey, method: "api-key" });
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
const email = await input({ message: "Email:" });
|
|
35
|
+
const pass = await password({ message: "Password:" });
|
|
36
|
+
const client = new ImbraceClient();
|
|
37
|
+
await client.login(email, pass);
|
|
38
|
+
const token = client.tokenManager?.getToken();
|
|
39
|
+
if (!token)
|
|
40
|
+
throw new Error("No token issued");
|
|
41
|
+
saveCredential({ credential: token, method: "password", email });
|
|
42
|
+
}
|
|
43
|
+
resetClient();
|
|
44
|
+
this.log(`\n✅ Logged in\n`);
|
|
43
45
|
}
|
|
44
46
|
catch (error) {
|
|
45
47
|
this.error(`Login failed: ${error.message}`);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Flags } from "@oclif/core";
|
|
2
2
|
import { BaseCommand } from "../../base-command.js";
|
|
3
3
|
import { input } from "@inquirer/prompts";
|
|
4
|
-
import {
|
|
4
|
+
import { createAgent } from "../../lib/ai-agent.js";
|
|
5
5
|
export default class AiAgentCreate extends BaseCommand {
|
|
6
6
|
static description = "Create a new AI agent";
|
|
7
7
|
static examples = [
|
|
@@ -76,18 +76,19 @@ export default class AiAgentCreate extends BaseCommand {
|
|
|
76
76
|
...(flags["use-memory"] !== undefined && { use_memory: flags["use-memory"] }),
|
|
77
77
|
};
|
|
78
78
|
try {
|
|
79
|
-
const
|
|
79
|
+
const data = await createAgent(body);
|
|
80
|
+
const message = `AI Agent "${name}" created`;
|
|
80
81
|
if (flags["id-only"]) {
|
|
81
|
-
this.log(
|
|
82
|
+
this.log(data?._id ?? "");
|
|
82
83
|
return;
|
|
83
84
|
}
|
|
84
85
|
if (flags.json) {
|
|
85
|
-
this.log(JSON.stringify(
|
|
86
|
+
this.log(JSON.stringify({ ok: true, message, data }, null, 2));
|
|
86
87
|
return;
|
|
87
88
|
}
|
|
88
|
-
this.log(`\n✅ ${
|
|
89
|
-
if (
|
|
90
|
-
this.log(` ID: ${
|
|
89
|
+
this.log(`\n✅ ${message}`);
|
|
90
|
+
if (data?._id)
|
|
91
|
+
this.log(` ID: ${data._id}`);
|
|
91
92
|
this.log("");
|
|
92
93
|
}
|
|
93
94
|
catch (error) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Args, Flags } from "@oclif/core";
|
|
2
2
|
import { BaseCommand } from "../../base-command.js";
|
|
3
3
|
import { input, confirm } from "@inquirer/prompts";
|
|
4
|
-
import {
|
|
4
|
+
import { getClient } from "../../lib/client.js";
|
|
5
5
|
export default class AiAgentDelete extends BaseCommand {
|
|
6
6
|
static description = "Delete an AI agent";
|
|
7
7
|
static examples = [
|
|
@@ -25,12 +25,14 @@ export default class AiAgentDelete extends BaseCommand {
|
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
try {
|
|
28
|
-
const
|
|
28
|
+
const client = getClient();
|
|
29
|
+
await client.agent.delete(id);
|
|
30
|
+
const message = "AI Agent deleted";
|
|
29
31
|
if (flags.json) {
|
|
30
|
-
this.log(JSON.stringify(
|
|
32
|
+
this.log(JSON.stringify({ ok: true, message }, null, 2));
|
|
31
33
|
return;
|
|
32
34
|
}
|
|
33
|
-
this.log(`\n✅ ${
|
|
35
|
+
this.log(`\n✅ ${message}\n`);
|
|
34
36
|
}
|
|
35
37
|
catch (error) {
|
|
36
38
|
this.error(`Failed: ${error.message}`);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Args, Flags } from "@oclif/core";
|
|
2
2
|
import { BaseCommand } from "../../base-command.js";
|
|
3
3
|
import { input } from "@inquirer/prompts";
|
|
4
|
-
import {
|
|
4
|
+
import { getClient } from "../../lib/client.js";
|
|
5
5
|
export default class AiAgentGet extends BaseCommand {
|
|
6
6
|
static description = "Get details of an AI agent";
|
|
7
7
|
static examples = [
|
|
@@ -18,13 +18,13 @@ export default class AiAgentGet extends BaseCommand {
|
|
|
18
18
|
const { args, flags } = await this.parse(AiAgentGet);
|
|
19
19
|
const id = args.id ?? (flags.json ? this.error("ID is required") : await input({ message: "Agent ID:" }));
|
|
20
20
|
try {
|
|
21
|
-
const
|
|
21
|
+
const client = getClient();
|
|
22
|
+
const data = await client.agent.get(id);
|
|
22
23
|
if (flags.json) {
|
|
23
|
-
this.log(JSON.stringify(
|
|
24
|
+
this.log(JSON.stringify({ ok: true, data }, null, 2));
|
|
24
25
|
return;
|
|
25
26
|
}
|
|
26
|
-
|
|
27
|
-
const a = res.data?.data || res.data || {};
|
|
27
|
+
const a = data?.data || data || {};
|
|
28
28
|
this.log(`\n ID: ${a._id || a.id || ""}`);
|
|
29
29
|
this.log(` Title: ${a.title || a.name || ""}`);
|
|
30
30
|
this.log(` Type: ${a.agent_type || ""}`);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Flags } from "@oclif/core";
|
|
2
2
|
import { BaseCommand } from "../../base-command.js";
|
|
3
|
-
import {
|
|
3
|
+
import { getClient } from "../../lib/client.js";
|
|
4
4
|
export default class AiAgentListFiles extends BaseCommand {
|
|
5
5
|
static description = "List files inside a Knowledge Hub folder (use IDs with --file-ids on create/update)";
|
|
6
6
|
static examples = [
|
|
@@ -17,15 +17,17 @@ export default class AiAgentListFiles extends BaseCommand {
|
|
|
17
17
|
async run() {
|
|
18
18
|
const { flags } = await this.parse(AiAgentListFiles);
|
|
19
19
|
try {
|
|
20
|
-
const
|
|
20
|
+
const client = getClient();
|
|
21
|
+
const r = await client.boards.searchFiles({ folderId: flags["folder-id"] });
|
|
22
|
+
const data = (Array.isArray(r) ? r : r?.data) || [];
|
|
21
23
|
if (flags.json) {
|
|
22
|
-
this.log(JSON.stringify(
|
|
24
|
+
this.log(JSON.stringify({ ok: true, count: data.length, data }, null, 2));
|
|
23
25
|
return;
|
|
24
26
|
}
|
|
25
|
-
this.log(`\n Found ${
|
|
27
|
+
this.log(`\n Found ${data.length} file(s) in folder "${flags["folder-id"]}":\n`);
|
|
26
28
|
this.log(" ID NAME STATUS");
|
|
27
29
|
this.log(" ─────────────────────────────────────────────────────────────────────────────────────");
|
|
28
|
-
for (const f of
|
|
30
|
+
for (const f of data) {
|
|
29
31
|
const id = (f._id || f.id || "").padEnd(40);
|
|
30
32
|
const name = (f.original_name || f.name || "").padEnd(36);
|
|
31
33
|
const status = f.embedding_status || f.status || "";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Flags } from "@oclif/core";
|
|
2
2
|
import { BaseCommand } from "../../base-command.js";
|
|
3
|
-
import {
|
|
3
|
+
import { getClient } from "../../lib/client.js";
|
|
4
4
|
export default class AiAgentListFolders extends BaseCommand {
|
|
5
5
|
static description = "List Knowledge Hub folders (use IDs with --folder-ids on create/update)";
|
|
6
6
|
static examples = [
|
|
@@ -14,17 +14,18 @@ export default class AiAgentListFolders extends BaseCommand {
|
|
|
14
14
|
};
|
|
15
15
|
async run() {
|
|
16
16
|
const { flags } = await this.parse(AiAgentListFolders);
|
|
17
|
-
const qs = flags.search ? `?q=${encodeURIComponent(flags.search)}` : "";
|
|
18
17
|
try {
|
|
19
|
-
const
|
|
18
|
+
const client = getClient();
|
|
19
|
+
const r = await client.boards.searchFolders(flags.search ? { q: flags.search } : undefined);
|
|
20
|
+
const data = (Array.isArray(r) ? r : r?.data) || [];
|
|
20
21
|
if (flags.json) {
|
|
21
|
-
this.log(JSON.stringify(
|
|
22
|
+
this.log(JSON.stringify({ ok: true, count: data.length, data }, null, 2));
|
|
22
23
|
return;
|
|
23
24
|
}
|
|
24
|
-
this.log(`\n Found ${
|
|
25
|
+
this.log(`\n Found ${data.length} folder(s):\n`);
|
|
25
26
|
this.log(" ID NAME FILES");
|
|
26
27
|
this.log(" ──────────────────────────────────────────────────────────────────────────────");
|
|
27
|
-
for (const f of
|
|
28
|
+
for (const f of data) {
|
|
28
29
|
const id = (f._id || f.id || "").padEnd(40);
|
|
29
30
|
const name = (f.name || "").padEnd(28);
|
|
30
31
|
const files = String(f.file_count ?? 0).padStart(5);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Flags } from "@oclif/core";
|
|
2
2
|
import { BaseCommand } from "../../base-command.js";
|
|
3
|
-
import {
|
|
3
|
+
import { listProviderModels } from "../../lib/ai-agent.js";
|
|
4
4
|
export default class AiAgentListModels extends BaseCommand {
|
|
5
5
|
static description = "List LLM models available for a specific provider";
|
|
6
6
|
static examples = [
|
|
@@ -18,13 +18,13 @@ export default class AiAgentListModels extends BaseCommand {
|
|
|
18
18
|
async run() {
|
|
19
19
|
const { flags } = await this.parse(AiAgentListModels);
|
|
20
20
|
try {
|
|
21
|
-
const
|
|
21
|
+
const data = await listProviderModels(flags["provider-id"]);
|
|
22
22
|
if (flags.json) {
|
|
23
|
-
this.log(JSON.stringify(
|
|
23
|
+
this.log(JSON.stringify({ ok: true, count: data.length, data }, null, 2));
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
26
|
-
this.log(`\n Found ${
|
|
27
|
-
for (const m of
|
|
26
|
+
this.log(`\n Found ${data.length} model(s) for provider "${flags["provider-id"]}":\n`);
|
|
27
|
+
for (const m of data) {
|
|
28
28
|
this.log(` ${m}`);
|
|
29
29
|
}
|
|
30
30
|
this.log("");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Flags } from "@oclif/core";
|
|
2
2
|
import { BaseCommand } from "../../base-command.js";
|
|
3
|
-
import {
|
|
3
|
+
import { listProviders } from "../../lib/ai-agent.js";
|
|
4
4
|
export default class AiAgentListProviders extends BaseCommand {
|
|
5
5
|
static description = "List LLM providers (system + custom) configured for the org";
|
|
6
6
|
static examples = [
|
|
@@ -13,15 +13,15 @@ export default class AiAgentListProviders extends BaseCommand {
|
|
|
13
13
|
async run() {
|
|
14
14
|
const { flags } = await this.parse(AiAgentListProviders);
|
|
15
15
|
try {
|
|
16
|
-
const
|
|
16
|
+
const data = await listProviders();
|
|
17
17
|
if (flags.json) {
|
|
18
|
-
this.log(JSON.stringify(
|
|
18
|
+
this.log(JSON.stringify({ ok: true, count: data.length, data }, null, 2));
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
21
|
-
this.log(`\n Found ${
|
|
21
|
+
this.log(`\n Found ${data.length} provider(s):\n`);
|
|
22
22
|
this.log(" ID NAME TYPE MODELS");
|
|
23
23
|
this.log(" ─────────────────────────────────────────────────────────────────────────────");
|
|
24
|
-
for (const p of
|
|
24
|
+
for (const p of data) {
|
|
25
25
|
const id = (p.id || p.provider_id || p._id || "").padEnd(40);
|
|
26
26
|
const name = (p.name || "").padEnd(16);
|
|
27
27
|
const type = (p.type || "").padEnd(11);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Flags } from "@oclif/core";
|
|
2
2
|
import { BaseCommand } from "../../base-command.js";
|
|
3
|
-
import {
|
|
3
|
+
import { getClient } from "../../lib/client.js";
|
|
4
4
|
export default class AiAgentList extends BaseCommand {
|
|
5
5
|
static description = "List all AI agents";
|
|
6
6
|
static examples = [
|
|
@@ -13,15 +13,17 @@ export default class AiAgentList extends BaseCommand {
|
|
|
13
13
|
async run() {
|
|
14
14
|
const { flags } = await this.parse(AiAgentList);
|
|
15
15
|
try {
|
|
16
|
-
const
|
|
16
|
+
const client = getClient();
|
|
17
|
+
const res = await client.agent.list();
|
|
18
|
+
const data = (res?.data ?? res ?? []);
|
|
17
19
|
if (flags.json) {
|
|
18
|
-
this.log(JSON.stringify(
|
|
20
|
+
this.log(JSON.stringify({ ok: true, count: data.length, data }, null, 2));
|
|
19
21
|
return;
|
|
20
22
|
}
|
|
21
|
-
this.log(`\n Found ${
|
|
23
|
+
this.log(`\n Found ${data.length} agent(s):\n`);
|
|
22
24
|
this.log(" ID TITLE TYPE");
|
|
23
25
|
this.log(" ──────────────────────────────────────────────────────────────────");
|
|
24
|
-
for (const agent of
|
|
26
|
+
for (const agent of data) {
|
|
25
27
|
const id = (agent._id || agent.id || "").padEnd(38);
|
|
26
28
|
const title = (agent.title || agent.name || "").padEnd(22);
|
|
27
29
|
const type = agent.agent_type || "";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Args, Flags } from "@oclif/core";
|
|
2
2
|
import { BaseCommand } from "../../base-command.js";
|
|
3
3
|
import { input } from "@inquirer/prompts";
|
|
4
|
-
import {
|
|
4
|
+
import { updateAgent } from "../../lib/ai-agent.js";
|
|
5
5
|
export default class AiAgentUpdate extends BaseCommand {
|
|
6
6
|
static description = "Update an AI agent. Pass any subset of flags — others stay unchanged.";
|
|
7
7
|
static examples = [
|
|
@@ -102,12 +102,13 @@ export default class AiAgentUpdate extends BaseCommand {
|
|
|
102
102
|
this.error("Provide at least one field to update. See: imbrace ai-agent update -h");
|
|
103
103
|
}
|
|
104
104
|
try {
|
|
105
|
-
const
|
|
105
|
+
const data = await updateAgent(id, body);
|
|
106
|
+
const message = "AI Agent updated";
|
|
106
107
|
if (flags.json) {
|
|
107
|
-
this.log(JSON.stringify(
|
|
108
|
+
this.log(JSON.stringify({ ok: true, message, data }, null, 2));
|
|
108
109
|
return;
|
|
109
110
|
}
|
|
110
|
-
this.log(`\n✅ ${
|
|
111
|
+
this.log(`\n✅ ${message}\n`);
|
|
111
112
|
}
|
|
112
113
|
catch (error) {
|
|
113
114
|
this.error(`Failed: ${error.message}`);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Args, Flags } from "@oclif/core";
|
|
2
2
|
import { BaseCommand } from "../../base-command.js";
|
|
3
3
|
import { input, select } from "@inquirer/prompts";
|
|
4
|
-
import {
|
|
4
|
+
import { getClient } from "../../lib/client.js";
|
|
5
5
|
const FIELD_TYPES = [
|
|
6
6
|
"ShortText", "LongText", "Number", "Date",
|
|
7
7
|
"Email", "Phone", "Currency",
|
|
@@ -32,12 +32,14 @@ export default class DataBoardCreateField extends BaseCommand {
|
|
|
32
32
|
choices: FIELD_TYPES.map((t) => ({ name: t, value: t })),
|
|
33
33
|
});
|
|
34
34
|
try {
|
|
35
|
-
const
|
|
35
|
+
const client = getClient();
|
|
36
|
+
const data = await client.boards.createField(boardId, { name, type });
|
|
37
|
+
const message = `Field "${name}" created`;
|
|
36
38
|
if (flags.json) {
|
|
37
|
-
this.log(JSON.stringify(
|
|
39
|
+
this.log(JSON.stringify({ ok: true, message, data }, null, 2));
|
|
38
40
|
return;
|
|
39
41
|
}
|
|
40
|
-
this.log(`\n✅ ${
|
|
42
|
+
this.log(`\n✅ ${message}\n`);
|
|
41
43
|
}
|
|
42
44
|
catch (error) {
|
|
43
45
|
this.error(`Failed: ${error.message}`);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Args, Flags } from "@oclif/core";
|
|
2
2
|
import { BaseCommand } from "../../base-command.js";
|
|
3
3
|
import { input } from "@inquirer/prompts";
|
|
4
|
-
import {
|
|
4
|
+
import { getClient } from "../../lib/client.js";
|
|
5
5
|
export default class DataBoardCreateItem extends BaseCommand {
|
|
6
6
|
static description = "Create board items (records). Format: { fields: [{ board_field_id, value }, ...] }";
|
|
7
7
|
static examples = [
|
|
@@ -21,6 +21,7 @@ export default class DataBoardCreateItem extends BaseCommand {
|
|
|
21
21
|
async run() {
|
|
22
22
|
const { args, flags } = await this.parse(DataBoardCreateItem);
|
|
23
23
|
const boardId = args.boardId ?? (await input({ message: "Board ID:" }));
|
|
24
|
+
const client = getClient();
|
|
24
25
|
let fields;
|
|
25
26
|
if (flags.fields) {
|
|
26
27
|
try {
|
|
@@ -31,8 +32,8 @@ export default class DataBoardCreateItem extends BaseCommand {
|
|
|
31
32
|
}
|
|
32
33
|
}
|
|
33
34
|
else {
|
|
34
|
-
const
|
|
35
|
-
const boardFields =
|
|
35
|
+
const board = await client.boards.get(boardId);
|
|
36
|
+
const boardFields = board?.fields || board?.data?.fields || [];
|
|
36
37
|
if (!boardFields.length)
|
|
37
38
|
this.error("Board has no fields. Run: imbrace data-board create-field");
|
|
38
39
|
this.log("\n Fill in the fields:\n");
|
|
@@ -47,14 +48,15 @@ export default class DataBoardCreateItem extends BaseCommand {
|
|
|
47
48
|
}
|
|
48
49
|
}
|
|
49
50
|
try {
|
|
50
|
-
const
|
|
51
|
+
const data = await client.boards.createItem(boardId, { fields });
|
|
52
|
+
const message = "Item created";
|
|
51
53
|
if (flags.json) {
|
|
52
|
-
this.log(JSON.stringify(
|
|
54
|
+
this.log(JSON.stringify({ ok: true, message, data }, null, 2));
|
|
53
55
|
return;
|
|
54
56
|
}
|
|
55
|
-
this.log(`\n✅ ${
|
|
56
|
-
if (
|
|
57
|
-
this.log(` ID: ${
|
|
57
|
+
this.log(`\n✅ ${message}`);
|
|
58
|
+
if (data?._id)
|
|
59
|
+
this.log(` ID: ${data._id}`);
|
|
58
60
|
this.log("");
|
|
59
61
|
}
|
|
60
62
|
catch (error) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Flags } from "@oclif/core";
|
|
2
2
|
import { BaseCommand } from "../../base-command.js";
|
|
3
3
|
import { input, confirm } from "@inquirer/prompts";
|
|
4
|
-
import {
|
|
4
|
+
import { getClient } from "../../lib/client.js";
|
|
5
5
|
export default class DataBoardCreate extends BaseCommand {
|
|
6
6
|
static description = "Create a new data board";
|
|
7
7
|
static examples = [
|
|
@@ -28,14 +28,16 @@ export default class DataBoardCreate extends BaseCommand {
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
try {
|
|
31
|
-
const
|
|
31
|
+
const client = getClient();
|
|
32
|
+
const data = await client.boards.create(body);
|
|
33
|
+
const message = `Board "${name}" created`;
|
|
32
34
|
if (flags.json) {
|
|
33
|
-
this.log(JSON.stringify(
|
|
35
|
+
this.log(JSON.stringify({ ok: true, message, data }, null, 2));
|
|
34
36
|
return;
|
|
35
37
|
}
|
|
36
|
-
this.log(`\n✅ ${
|
|
37
|
-
if (
|
|
38
|
-
this.log(` ID: ${
|
|
38
|
+
this.log(`\n✅ ${message}`);
|
|
39
|
+
if (data?._id)
|
|
40
|
+
this.log(` ID: ${data._id}`);
|
|
39
41
|
this.log("");
|
|
40
42
|
}
|
|
41
43
|
catch (error) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Args, Flags } from "@oclif/core";
|
|
2
2
|
import { BaseCommand } from "../../base-command.js";
|
|
3
3
|
import { input, confirm } from "@inquirer/prompts";
|
|
4
|
-
import {
|
|
4
|
+
import { getClient } from "../../lib/client.js";
|
|
5
5
|
export default class DataBoardDeleteItem extends BaseCommand {
|
|
6
6
|
static description = "Delete an item from a board";
|
|
7
7
|
static examples = [
|
|
@@ -28,12 +28,14 @@ export default class DataBoardDeleteItem extends BaseCommand {
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
try {
|
|
31
|
-
const
|
|
31
|
+
const client = getClient();
|
|
32
|
+
await client.boards.deleteItem(boardId, itemId);
|
|
33
|
+
const message = "Item deleted";
|
|
32
34
|
if (flags.json) {
|
|
33
|
-
this.log(JSON.stringify(
|
|
35
|
+
this.log(JSON.stringify({ ok: true, message }, null, 2));
|
|
34
36
|
return;
|
|
35
37
|
}
|
|
36
|
-
this.log(`\n✅ ${
|
|
38
|
+
this.log(`\n✅ ${message}\n`);
|
|
37
39
|
}
|
|
38
40
|
catch (error) {
|
|
39
41
|
this.error(`Failed: ${error.message}`);
|
|
@@ -2,7 +2,7 @@ import { Flags } from "@oclif/core";
|
|
|
2
2
|
import { BaseCommand } from "../../base-command.js";
|
|
3
3
|
import { input } from "@inquirer/prompts";
|
|
4
4
|
import { writeFileSync } from "fs";
|
|
5
|
-
import {
|
|
5
|
+
import { getClient } from "../../lib/client.js";
|
|
6
6
|
export default class DataBoardExportCsv extends BaseCommand {
|
|
7
7
|
static description = "Export a board to CSV";
|
|
8
8
|
static examples = [
|
|
@@ -18,7 +18,8 @@ export default class DataBoardExportCsv extends BaseCommand {
|
|
|
18
18
|
const boardId = flags["board-id"] ?? await input({ message: "Board ID:" });
|
|
19
19
|
const out = flags.out ?? await input({ message: "Save to file path (leave empty to print):", default: "" });
|
|
20
20
|
try {
|
|
21
|
-
const
|
|
21
|
+
const client = getClient();
|
|
22
|
+
const csv = await client.boards.exportCsv(boardId);
|
|
22
23
|
if (out) {
|
|
23
24
|
writeFileSync(out, csv);
|
|
24
25
|
this.log(`\n✅ Exported to ${out}\n`);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Flags } from "@oclif/core";
|
|
2
2
|
import { BaseCommand } from "../../base-command.js";
|
|
3
3
|
import { input } from "@inquirer/prompts";
|
|
4
|
-
import {
|
|
4
|
+
import { getClient } from "../../lib/client.js";
|
|
5
5
|
export default class DataBoardListItems extends BaseCommand {
|
|
6
6
|
static description = "List or search items (records) in a board";
|
|
7
7
|
static examples = [
|
|
@@ -22,20 +22,18 @@ export default class DataBoardListItems extends BaseCommand {
|
|
|
22
22
|
const q = flags.q ?? (flags.json ? "" : await input({ message: "Search query (press Enter to list all):", default: "" }));
|
|
23
23
|
const limit = flags.limit ?? (flags.json ? 20 : Number(await input({ message: "Limit (press Enter for 20):", default: "20" })));
|
|
24
24
|
const skip = flags.skip ?? (flags.json || q ? 0 : Number(await input({ message: "Skip (press Enter for 0):", default: "0" })));
|
|
25
|
-
const params = new URLSearchParams();
|
|
26
|
-
if (q)
|
|
27
|
-
params.set("q", q);
|
|
28
|
-
params.set("limit", String(limit));
|
|
29
|
-
if (!q)
|
|
30
|
-
params.set("skip", String(skip));
|
|
31
25
|
try {
|
|
32
|
-
const
|
|
26
|
+
const client = getClient();
|
|
27
|
+
const res = q
|
|
28
|
+
? await client.boards.search(boardId, { q, limit })
|
|
29
|
+
: await client.boards.listItems(boardId, { limit, skip });
|
|
30
|
+
const data = res?.data ?? res ?? [];
|
|
33
31
|
if (flags.json) {
|
|
34
|
-
this.log(JSON.stringify(
|
|
32
|
+
this.log(JSON.stringify({ ok: true, count: data.length, data }, null, 2));
|
|
35
33
|
return;
|
|
36
34
|
}
|
|
37
|
-
this.log(`\n Found ${
|
|
38
|
-
for (const item of
|
|
35
|
+
this.log(`\n Found ${data.length} item(s):\n`);
|
|
36
|
+
for (const item of data) {
|
|
39
37
|
this.log(` ${item._id}`);
|
|
40
38
|
}
|
|
41
39
|
this.log("");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Flags } from "@oclif/core";
|
|
2
2
|
import { BaseCommand } from "../../base-command.js";
|
|
3
|
-
import {
|
|
3
|
+
import { getClient } from "../../lib/client.js";
|
|
4
4
|
export default class DataBoardList extends BaseCommand {
|
|
5
5
|
static description = "List all boards — use this to get Board IDs";
|
|
6
6
|
static examples = [
|
|
@@ -13,15 +13,17 @@ export default class DataBoardList extends BaseCommand {
|
|
|
13
13
|
async run() {
|
|
14
14
|
const { flags } = await this.parse(DataBoardList);
|
|
15
15
|
try {
|
|
16
|
-
const
|
|
16
|
+
const client = getClient();
|
|
17
|
+
const res = await client.boards.list();
|
|
18
|
+
const data = res?.data ?? [];
|
|
17
19
|
if (flags.json) {
|
|
18
|
-
this.log(JSON.stringify(
|
|
20
|
+
this.log(JSON.stringify({ ok: true, count: data.length, data }, null, 2));
|
|
19
21
|
return;
|
|
20
22
|
}
|
|
21
|
-
this.log(`\n Found ${
|
|
23
|
+
this.log(`\n Found ${data.length} board(s):\n`);
|
|
22
24
|
this.log(" ID NAME");
|
|
23
25
|
this.log(" ──────────────────────────────────────────────────────");
|
|
24
|
-
for (const board of
|
|
26
|
+
for (const board of data) {
|
|
25
27
|
this.log(` ${(board._id || "").padEnd(38)} ${board.name || ""}`);
|
|
26
28
|
}
|
|
27
29
|
this.log("");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Args, Flags } from "@oclif/core";
|
|
2
2
|
import { BaseCommand } from "../../base-command.js";
|
|
3
3
|
import { input } from "@inquirer/prompts";
|
|
4
|
-
import {
|
|
4
|
+
import { getClient } from "../../lib/client.js";
|
|
5
5
|
export default class DataBoardUpdateItem extends BaseCommand {
|
|
6
6
|
static description = "Update an item in a board. Fetches fields and prompts per field.";
|
|
7
7
|
static examples = [
|
|
@@ -20,6 +20,7 @@ export default class DataBoardUpdateItem extends BaseCommand {
|
|
|
20
20
|
const { args, flags } = await this.parse(DataBoardUpdateItem);
|
|
21
21
|
const boardId = args.boardId ?? await input({ message: "Board ID:" });
|
|
22
22
|
const itemId = args.itemId ?? await input({ message: "Item ID:" });
|
|
23
|
+
const client = getClient();
|
|
23
24
|
let data;
|
|
24
25
|
if (flags.data) {
|
|
25
26
|
try {
|
|
@@ -30,8 +31,8 @@ export default class DataBoardUpdateItem extends BaseCommand {
|
|
|
30
31
|
}
|
|
31
32
|
}
|
|
32
33
|
else {
|
|
33
|
-
const
|
|
34
|
-
const boardFields =
|
|
34
|
+
const board = await client.boards.get(boardId);
|
|
35
|
+
const boardFields = board?.fields || board?.data?.fields || [];
|
|
35
36
|
if (!boardFields.length)
|
|
36
37
|
this.error("Board has no fields.");
|
|
37
38
|
this.log("\n Update fields (leave empty to skip):\n");
|
|
@@ -43,12 +44,13 @@ export default class DataBoardUpdateItem extends BaseCommand {
|
|
|
43
44
|
}
|
|
44
45
|
}
|
|
45
46
|
try {
|
|
46
|
-
const
|
|
47
|
+
const item = await client.boards.updateItem(boardId, itemId, { data });
|
|
48
|
+
const message = "Item updated";
|
|
47
49
|
if (flags.json) {
|
|
48
|
-
this.log(JSON.stringify(
|
|
50
|
+
this.log(JSON.stringify({ ok: true, message, data: item }, null, 2));
|
|
49
51
|
return;
|
|
50
52
|
}
|
|
51
|
-
this.log(`\n✅ ${
|
|
53
|
+
this.log(`\n✅ ${message}\n`);
|
|
52
54
|
}
|
|
53
55
|
catch (error) {
|
|
54
56
|
this.error(`Failed: ${error.message}`);
|
package/dist/commands/login.d.ts
CHANGED
|
@@ -6,7 +6,6 @@ export default class Login extends Command {
|
|
|
6
6
|
email: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
7
|
password: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
8
|
"api-key": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
-
"api-url": import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
9
|
};
|
|
11
10
|
run(): Promise<void>;
|
|
12
11
|
}
|