@manfred-kunze-dev/backbone-cli 2.6.0-dev.4

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 (50) hide show
  1. package/LICENSE +19 -0
  2. package/dist/commands/ai.d.ts +3 -0
  3. package/dist/commands/ai.js +72 -0
  4. package/dist/commands/analytics.d.ts +3 -0
  5. package/dist/commands/analytics.js +120 -0
  6. package/dist/commands/auth.d.ts +3 -0
  7. package/dist/commands/auth.js +115 -0
  8. package/dist/commands/billing.d.ts +3 -0
  9. package/dist/commands/billing.js +100 -0
  10. package/dist/commands/config.d.ts +3 -0
  11. package/dist/commands/config.js +70 -0
  12. package/dist/commands/convert.d.ts +3 -0
  13. package/dist/commands/convert.js +123 -0
  14. package/dist/commands/extractions.d.ts +3 -0
  15. package/dist/commands/extractions.js +143 -0
  16. package/dist/commands/projects.d.ts +3 -0
  17. package/dist/commands/projects.js +83 -0
  18. package/dist/commands/prompt-labels.d.ts +3 -0
  19. package/dist/commands/prompt-labels.js +72 -0
  20. package/dist/commands/prompt-versions.d.ts +3 -0
  21. package/dist/commands/prompt-versions.js +70 -0
  22. package/dist/commands/prompts.d.ts +3 -0
  23. package/dist/commands/prompts.js +170 -0
  24. package/dist/commands/providers.d.ts +3 -0
  25. package/dist/commands/providers.js +115 -0
  26. package/dist/commands/schema-labels.d.ts +3 -0
  27. package/dist/commands/schema-labels.js +72 -0
  28. package/dist/commands/schema-versions.d.ts +3 -0
  29. package/dist/commands/schema-versions.js +71 -0
  30. package/dist/commands/schemas.d.ts +3 -0
  31. package/dist/commands/schemas.js +168 -0
  32. package/dist/commands/transcribe.d.ts +3 -0
  33. package/dist/commands/transcribe.js +65 -0
  34. package/dist/index.d.ts +3 -0
  35. package/dist/index.js +38 -0
  36. package/dist/lib/client.d.ts +12 -0
  37. package/dist/lib/client.js +52 -0
  38. package/dist/lib/config.d.ts +20 -0
  39. package/dist/lib/config.js +68 -0
  40. package/dist/lib/context.d.ts +7 -0
  41. package/dist/lib/context.js +14 -0
  42. package/dist/lib/errors.d.ts +14 -0
  43. package/dist/lib/errors.js +53 -0
  44. package/dist/lib/multipart.d.ts +10 -0
  45. package/dist/lib/multipart.js +57 -0
  46. package/dist/lib/output.d.ts +29 -0
  47. package/dist/lib/output.js +107 -0
  48. package/dist/lib/pagination.d.ts +21 -0
  49. package/dist/lib/pagination.js +21 -0
  50. package/package.json +52 -0
@@ -0,0 +1,115 @@
1
+ import { Command } from "commander";
2
+ import { getClient, runAction } from "../lib/client.js";
3
+ import { isJsonOutput } from "../lib/config.js";
4
+ import { formatPage, formatDetail, formatList, formatSuccess } from "../lib/output.js";
5
+ import { addPaginationOptions, paginationParams } from "../lib/pagination.js";
6
+ export function makeProvidersCommand() {
7
+ const cmd = new Command("providers").description("Manage AI providers");
8
+ const list = new Command("list").description("List providers");
9
+ addPaginationOptions(list);
10
+ list.option("-s, --search <term>", "Filter by name");
11
+ list.action(async (opts, command) => {
12
+ await runAction(command, async () => {
13
+ const client = getClient(command);
14
+ const { data } = await client.GET("/v1/providers", {
15
+ params: { query: { search: opts.search, ...paginationParams(opts) } },
16
+ });
17
+ formatPage(data, command, ["id", "name", "type", "enabled", "createdAt"]);
18
+ });
19
+ });
20
+ cmd.addCommand(list);
21
+ cmd
22
+ .command("get")
23
+ .description("Get a provider by ID")
24
+ .argument("<id>", "Provider ID")
25
+ .action(async (id, _opts, command) => {
26
+ await runAction(command, async () => {
27
+ const client = getClient(command);
28
+ const { data } = await client.GET("/v1/providers/{id}", {
29
+ params: { path: { id } },
30
+ });
31
+ formatDetail(data, command);
32
+ });
33
+ });
34
+ cmd
35
+ .command("create")
36
+ .description("Create a new provider")
37
+ .requiredOption("-n, --name <name>", "Provider name")
38
+ .requiredOption("--type <type>", "Provider type (openai, azure, anthropic, vertex, ollama)")
39
+ .requiredOption("--api-key <key>", "Provider API key")
40
+ .option("-c, --config <json>", "Provider config as JSON")
41
+ .action(async (opts, command) => {
42
+ await runAction(command, async () => {
43
+ const client = getClient(command);
44
+ const config = opts.config ? JSON.parse(opts.config) : {};
45
+ const { data } = await client.POST("/v1/providers", {
46
+ body: { name: opts.name, provider: opts.type.toUpperCase(), apiKey: opts.apiKey, config },
47
+ });
48
+ formatDetail(data, command);
49
+ });
50
+ });
51
+ cmd
52
+ .command("update")
53
+ .description("Update a provider")
54
+ .argument("<id>", "Provider ID")
55
+ .option("-n, --name <name>", "New name")
56
+ .option("--type <type>", "New type")
57
+ .option("--enabled <bool>", "Enable/disable")
58
+ .option("-c, --config <json>", "New config as JSON")
59
+ .action(async (id, opts, command) => {
60
+ await runAction(command, async () => {
61
+ const client = getClient(command);
62
+ const body = {};
63
+ if (opts.name)
64
+ body.name = opts.name;
65
+ if (opts.type)
66
+ body.provider = opts.type.toUpperCase();
67
+ if (opts.enabled !== undefined)
68
+ body.enabled = opts.enabled === "true";
69
+ if (opts.config)
70
+ body.config = JSON.parse(opts.config);
71
+ const { data } = await client.PATCH("/v1/providers/{id}", {
72
+ params: { path: { id } },
73
+ body: body,
74
+ });
75
+ formatDetail(data, command);
76
+ });
77
+ });
78
+ cmd
79
+ .command("delete")
80
+ .description("Delete a provider")
81
+ .argument("<id>", "Provider ID")
82
+ .action(async (id, _opts, command) => {
83
+ await runAction(command, async () => {
84
+ const client = getClient(command);
85
+ await client.DELETE("/v1/providers/{id}", {
86
+ params: { path: { id } },
87
+ });
88
+ formatSuccess(`Provider ${id} deleted.`, command);
89
+ });
90
+ });
91
+ cmd
92
+ .command("models")
93
+ .description("List available models across all providers")
94
+ .action(async (_opts, command) => {
95
+ await runAction(command, async () => {
96
+ const client = getClient(command);
97
+ const { data } = await client.GET("/v1/providers/models");
98
+ const json = isJsonOutput(command);
99
+ if (json) {
100
+ console.log(JSON.stringify(data, null, 2));
101
+ }
102
+ else {
103
+ const models = data?.data ?? [];
104
+ formatList(models, command, [
105
+ "id",
106
+ "provider",
107
+ "name",
108
+ "capabilities",
109
+ ]);
110
+ }
111
+ });
112
+ });
113
+ return cmd;
114
+ }
115
+ //# sourceMappingURL=providers.js.map
@@ -0,0 +1,3 @@
1
+ import { Command } from "commander";
2
+ export declare function makeSchemaLabelsCommand(): Command;
3
+ //# sourceMappingURL=schema-labels.d.ts.map
@@ -0,0 +1,72 @@
1
+ import { Command } from "commander";
2
+ import { getClient, runAction } from "../lib/client.js";
3
+ import { requireProjectId } from "../lib/context.js";
4
+ import { formatList, formatDetail, formatSuccess } from "../lib/output.js";
5
+ export function makeSchemaLabelsCommand() {
6
+ const cmd = new Command("labels").description("Manage schema labels");
7
+ cmd
8
+ .command("list")
9
+ .description("List labels for a schema")
10
+ .requiredOption("--schema <id>", "Schema ID")
11
+ .action(async (opts, command) => {
12
+ await runAction(command, async () => {
13
+ const projectId = requireProjectId(command);
14
+ const client = getClient(command);
15
+ const { data } = await client.GET("/v1/projects/{projectId}/schemas/{schemaId}/labels", { params: { path: { projectId, schemaId: opts.schema } } });
16
+ formatList(data, command, [
17
+ "name",
18
+ "schemaVersionId",
19
+ "createdAt",
20
+ ]);
21
+ });
22
+ });
23
+ cmd
24
+ .command("create")
25
+ .description("Create a label for a schema version")
26
+ .requiredOption("--schema <id>", "Schema ID")
27
+ .requiredOption("-n, --name <name>", "Label name")
28
+ .requiredOption("--version-id <id>", "Schema version ID to label")
29
+ .action(async (opts, command) => {
30
+ await runAction(command, async () => {
31
+ const projectId = requireProjectId(command);
32
+ const client = getClient(command);
33
+ const { data } = await client.POST("/v1/projects/{projectId}/schemas/{schemaId}/labels", {
34
+ params: { path: { projectId, schemaId: opts.schema } },
35
+ body: { name: opts.name, schemaVersionId: opts.versionId },
36
+ });
37
+ formatDetail(data, command);
38
+ });
39
+ });
40
+ cmd
41
+ .command("update")
42
+ .description("Update a label to point to a different version")
43
+ .argument("<labelName>", "Label name")
44
+ .requiredOption("--schema <id>", "Schema ID")
45
+ .requiredOption("--version-id <id>", "New schema version ID")
46
+ .action(async (labelName, opts, command) => {
47
+ await runAction(command, async () => {
48
+ const projectId = requireProjectId(command);
49
+ const client = getClient(command);
50
+ const { data } = await client.PUT("/v1/projects/{projectId}/schemas/{schemaId}/labels/{labelName}", {
51
+ params: { path: { projectId, schemaId: opts.schema, labelName } },
52
+ body: { schemaVersionId: opts.versionId },
53
+ });
54
+ formatDetail(data, command);
55
+ });
56
+ });
57
+ cmd
58
+ .command("delete")
59
+ .description("Delete a schema label")
60
+ .argument("<labelName>", "Label name")
61
+ .requiredOption("--schema <id>", "Schema ID")
62
+ .action(async (labelName, opts, command) => {
63
+ await runAction(command, async () => {
64
+ const projectId = requireProjectId(command);
65
+ const client = getClient(command);
66
+ await client.DELETE("/v1/projects/{projectId}/schemas/{schemaId}/labels/{labelName}", { params: { path: { projectId, schemaId: opts.schema, labelName } } });
67
+ formatSuccess(`Label "${labelName}" deleted.`, command);
68
+ });
69
+ });
70
+ return cmd;
71
+ }
72
+ //# sourceMappingURL=schema-labels.js.map
@@ -0,0 +1,3 @@
1
+ import { Command } from "commander";
2
+ export declare function makeSchemaVersionsCommand(): Command;
3
+ //# sourceMappingURL=schema-versions.d.ts.map
@@ -0,0 +1,71 @@
1
+ import { Command } from "commander";
2
+ import { getClient, runAction } from "../lib/client.js";
3
+ import { requireProjectId } from "../lib/context.js";
4
+ import { formatPage, formatDetail } from "../lib/output.js";
5
+ import { addPaginationOptions, paginationParams } from "../lib/pagination.js";
6
+ export function makeSchemaVersionsCommand() {
7
+ const cmd = new Command("versions").description("Manage schema versions");
8
+ const list = new Command("list").description("List versions of a schema");
9
+ addPaginationOptions(list);
10
+ list.requiredOption("--schema <id>", "Schema ID");
11
+ list.action(async (opts, command) => {
12
+ await runAction(command, async () => {
13
+ const projectId = requireProjectId(command);
14
+ const client = getClient(command);
15
+ const { data } = await client.GET("/v1/projects/{projectId}/schemas/{schemaId}/versions", {
16
+ params: {
17
+ path: { projectId, schemaId: opts.schema },
18
+ query: paginationParams(opts),
19
+ },
20
+ });
21
+ formatPage(data, command, ["id", "version", "active", "changeDescription", "createdAt"]);
22
+ });
23
+ });
24
+ cmd.addCommand(list);
25
+ cmd
26
+ .command("get")
27
+ .description("Get a specific schema version")
28
+ .argument("<versionId>", "Version ID")
29
+ .requiredOption("--schema <id>", "Schema ID")
30
+ .action(async (versionId, opts, command) => {
31
+ await runAction(command, async () => {
32
+ const projectId = requireProjectId(command);
33
+ const client = getClient(command);
34
+ const { data } = await client.GET("/v1/projects/{projectId}/schemas/{schemaId}/versions/{versionId}", { params: { path: { projectId, schemaId: opts.schema, versionId } } });
35
+ formatDetail(data, command);
36
+ });
37
+ });
38
+ cmd
39
+ .command("create")
40
+ .description("Create a new schema version")
41
+ .requiredOption("--schema <id>", "Schema ID")
42
+ .requiredOption("-c, --content <json>", "JSON Schema content")
43
+ .option("-m, --message <text>", "Change description")
44
+ .action(async (opts, command) => {
45
+ await runAction(command, async () => {
46
+ const projectId = requireProjectId(command);
47
+ const client = getClient(command);
48
+ const content = JSON.parse(opts.content);
49
+ const { data } = await client.POST("/v1/projects/{projectId}/schemas/{schemaId}/versions", {
50
+ params: { path: { projectId, schemaId: opts.schema } },
51
+ body: { jsonSchema: content, changeDescription: opts.message },
52
+ });
53
+ formatDetail(data, command);
54
+ });
55
+ });
56
+ cmd
57
+ .command("activate")
58
+ .description("Activate a schema version")
59
+ .argument("<versionId>", "Version ID")
60
+ .requiredOption("--schema <id>", "Schema ID")
61
+ .action(async (versionId, opts, command) => {
62
+ await runAction(command, async () => {
63
+ const projectId = requireProjectId(command);
64
+ const client = getClient(command);
65
+ const { data } = await client.PUT("/v1/projects/{projectId}/schemas/{schemaId}/versions/{versionId}/activate", { params: { path: { projectId, schemaId: opts.schema, versionId } } });
66
+ formatDetail(data, command);
67
+ });
68
+ });
69
+ return cmd;
70
+ }
71
+ //# sourceMappingURL=schema-versions.js.map
@@ -0,0 +1,3 @@
1
+ import { Command } from "commander";
2
+ export declare function makeSchemasCommand(): Command;
3
+ //# sourceMappingURL=schemas.d.ts.map
@@ -0,0 +1,168 @@
1
+ import { Command } from "commander";
2
+ import { getClient, runAction } from "../lib/client.js";
3
+ import { isJsonOutput } from "../lib/config.js";
4
+ import { requireProjectId } from "../lib/context.js";
5
+ import { formatPage, formatDetail, formatSuccess } from "../lib/output.js";
6
+ import { addPaginationOptions, paginationParams } from "../lib/pagination.js";
7
+ import { makeSchemaVersionsCommand } from "./schema-versions.js";
8
+ import { makeSchemaLabelsCommand } from "./schema-labels.js";
9
+ export function makeSchemasCommand() {
10
+ const cmd = new Command("schemas").description("Manage schemas");
11
+ const list = new Command("list").description("List schemas");
12
+ addPaginationOptions(list);
13
+ list.option("-s, --search <term>", "Filter by name");
14
+ list.action(async (opts, command) => {
15
+ await runAction(command, async () => {
16
+ const projectId = requireProjectId(command);
17
+ const client = getClient(command);
18
+ const { data } = await client.GET("/v1/projects/{projectId}/schemas", {
19
+ params: {
20
+ path: { projectId },
21
+ query: { search: opts.search, ...paginationParams(opts) },
22
+ },
23
+ });
24
+ formatPage(data, command, ["id", "name", "description", "activeVersionId", "createdAt"]);
25
+ });
26
+ });
27
+ cmd.addCommand(list);
28
+ cmd
29
+ .command("get")
30
+ .description("Get a schema by ID")
31
+ .argument("<id>", "Schema ID")
32
+ .action(async (id, _opts, command) => {
33
+ await runAction(command, async () => {
34
+ const projectId = requireProjectId(command);
35
+ const client = getClient(command);
36
+ const { data } = await client.GET("/v1/projects/{projectId}/schemas/{id}", {
37
+ params: { path: { projectId, id } },
38
+ });
39
+ formatDetail(data, command);
40
+ });
41
+ });
42
+ cmd
43
+ .command("create")
44
+ .description("Create a new schema")
45
+ .requiredOption("-n, --name <name>", "Schema name")
46
+ .option("-d, --description <text>", "Schema description")
47
+ .action(async (opts, command) => {
48
+ await runAction(command, async () => {
49
+ const projectId = requireProjectId(command);
50
+ const client = getClient(command);
51
+ const { data } = await client.POST("/v1/projects/{projectId}/schemas", {
52
+ params: { path: { projectId } },
53
+ body: { name: opts.name, description: opts.description },
54
+ });
55
+ formatDetail(data, command);
56
+ });
57
+ });
58
+ cmd
59
+ .command("update")
60
+ .description("Update a schema")
61
+ .argument("<id>", "Schema ID")
62
+ .option("-n, --name <name>", "New name")
63
+ .option("-d, --description <text>", "New description")
64
+ .action(async (id, opts, command) => {
65
+ await runAction(command, async () => {
66
+ const projectId = requireProjectId(command);
67
+ const client = getClient(command);
68
+ const body = {};
69
+ if (opts.name)
70
+ body.name = opts.name;
71
+ if (opts.description !== undefined)
72
+ body.description = opts.description;
73
+ const { data } = await client.PUT("/v1/projects/{projectId}/schemas/{id}", {
74
+ params: { path: { projectId, id } },
75
+ body: body,
76
+ });
77
+ formatDetail(data, command);
78
+ });
79
+ });
80
+ cmd
81
+ .command("delete")
82
+ .description("Delete a schema")
83
+ .argument("<id>", "Schema ID")
84
+ .action(async (id, _opts, command) => {
85
+ await runAction(command, async () => {
86
+ const projectId = requireProjectId(command);
87
+ const client = getClient(command);
88
+ await client.DELETE("/v1/projects/{projectId}/schemas/{id}", {
89
+ params: { path: { projectId, id } },
90
+ });
91
+ formatSuccess(`Schema ${id} deleted.`, command);
92
+ });
93
+ });
94
+ cmd
95
+ .command("validate")
96
+ .description("Validate a JSON schema without saving")
97
+ .argument("<schemaId>", "Schema ID")
98
+ .requiredOption("-c, --content <json>", "JSON Schema content")
99
+ .action(async (schemaId, opts, command) => {
100
+ await runAction(command, async () => {
101
+ const projectId = requireProjectId(command);
102
+ const client = getClient(command);
103
+ const content = JSON.parse(opts.content);
104
+ const { data } = await client.POST("/v1/projects/{projectId}/schemas/{schemaId}/validate", {
105
+ params: { path: { projectId, schemaId } },
106
+ body: { jsonSchema: content },
107
+ });
108
+ if (isJsonOutput(command)) {
109
+ console.log(JSON.stringify(data, null, 2));
110
+ }
111
+ else if (data?.valid) {
112
+ formatSuccess("Schema is valid.", command);
113
+ if (data.warnings?.length) {
114
+ console.log(`Warnings: ${data.warnings.join(", ")}`);
115
+ }
116
+ }
117
+ else {
118
+ console.error("Schema is invalid:");
119
+ for (const err of data?.errors ?? [])
120
+ console.error(` - ${err}`);
121
+ }
122
+ });
123
+ });
124
+ cmd
125
+ .command("test")
126
+ .description("Test a schema with sample text")
127
+ .argument("<schemaId>", "Schema ID")
128
+ .requiredOption("-t, --text <text>", "Sample text to extract from")
129
+ .requiredOption("-m, --model <model>", "Model to use (provider/model)")
130
+ .option("--version-id <id>", "Schema version ID")
131
+ .option("-l, --label <name>", "Schema label")
132
+ .action(async (schemaId, opts, command) => {
133
+ await runAction(command, async () => {
134
+ const projectId = requireProjectId(command);
135
+ const client = getClient(command);
136
+ const { data } = await client.POST("/v1/projects/{projectId}/schemas/{schemaId}/test", {
137
+ params: { path: { projectId, schemaId } },
138
+ body: {
139
+ sampleText: opts.text,
140
+ model: opts.model,
141
+ },
142
+ });
143
+ formatDetail(data, command);
144
+ });
145
+ });
146
+ cmd
147
+ .command("resolve")
148
+ .description("Resolve schema content (latest or by label)")
149
+ .argument("<schemaId>", "Schema ID")
150
+ .option("-l, --label <name>", "Label to resolve")
151
+ .action(async (schemaId, opts, command) => {
152
+ await runAction(command, async () => {
153
+ const projectId = requireProjectId(command);
154
+ const client = getClient(command);
155
+ const { data } = await client.GET("/v1/projects/{projectId}/schemas/{schemaId}/resolve", {
156
+ params: {
157
+ path: { projectId, schemaId },
158
+ query: { label: opts.label },
159
+ },
160
+ });
161
+ formatDetail(data, command);
162
+ });
163
+ });
164
+ cmd.addCommand(makeSchemaVersionsCommand());
165
+ cmd.addCommand(makeSchemaLabelsCommand());
166
+ return cmd;
167
+ }
168
+ //# sourceMappingURL=schemas.js.map
@@ -0,0 +1,3 @@
1
+ import { Command } from "commander";
2
+ export declare function makeTranscribeCommand(): Command;
3
+ //# sourceMappingURL=transcribe.d.ts.map
@@ -0,0 +1,65 @@
1
+ import { Command } from "commander";
2
+ import { resolveConfig, isJsonOutput } from "../lib/config.js";
3
+ import { handleError } from "../lib/errors.js";
4
+ import { formatDetail, withSpinner } from "../lib/output.js";
5
+ import { fileToBlob } from "../lib/multipart.js";
6
+ import { BackboneApiError } from "../lib/errors.js";
7
+ export function makeTranscribeCommand() {
8
+ const cmd = new Command("transcribe")
9
+ .description("Transcribe an audio file")
10
+ .argument("<file>", "Audio file path")
11
+ .requiredOption("-m, --model <model>", "Model (e.g., openai/whisper-1)")
12
+ .option("--language <code>", "Language code (e.g., en, de)")
13
+ .option("--prompt <text>", "Optional prompt to guide transcription")
14
+ .option("--format <fmt>", "Response format (json, text, srt, verbose_json, vtt)")
15
+ .option("--temperature <n>", "Temperature")
16
+ .action(async (file, opts, command) => {
17
+ const json = isJsonOutput(command);
18
+ try {
19
+ const config = resolveConfig(command);
20
+ const { blob, filename } = fileToBlob(file);
21
+ const formData = new FormData();
22
+ formData.append("file", blob, filename);
23
+ formData.append("model", opts.model);
24
+ if (opts.language)
25
+ formData.append("language", opts.language);
26
+ if (opts.prompt)
27
+ formData.append("prompt", opts.prompt);
28
+ if (opts.format)
29
+ formData.append("response_format", opts.format);
30
+ if (opts.temperature)
31
+ formData.append("temperature", opts.temperature);
32
+ const baseUrl = config.baseUrl.replace(/\/+$/, "");
33
+ const url = `${baseUrl}/v1/audio/transcriptions`;
34
+ const data = await withSpinner("Transcribing...", async () => {
35
+ const res = await fetch(url, {
36
+ method: "POST",
37
+ headers: { Authorization: `Bearer ${config.apiKey}` },
38
+ body: formData,
39
+ });
40
+ if (!res.ok) {
41
+ let body;
42
+ try {
43
+ body = await res.json();
44
+ }
45
+ catch {
46
+ body = {
47
+ error: res.statusText,
48
+ message: `HTTP ${res.status}: ${res.statusText}`,
49
+ status: res.status,
50
+ timestamp: new Date().toISOString(),
51
+ };
52
+ }
53
+ throw new BackboneApiError(body);
54
+ }
55
+ return res.json();
56
+ });
57
+ formatDetail(data, command);
58
+ }
59
+ catch (err) {
60
+ handleError(err, json);
61
+ }
62
+ });
63
+ return cmd;
64
+ }
65
+ //# sourceMappingURL=transcribe.js.map
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=index.d.ts.map
package/dist/index.js ADDED
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env node
2
+ import { Command } from "commander";
3
+ import { makeAuthCommand } from "./commands/auth.js";
4
+ import { makeConfigCommand } from "./commands/config.js";
5
+ import { makeProjectsCommand } from "./commands/projects.js";
6
+ import { makeSchemasCommand } from "./commands/schemas.js";
7
+ import { makePromptsCommand } from "./commands/prompts.js";
8
+ import { makeExtractionsCommand } from "./commands/extractions.js";
9
+ import { makeConvertCommand } from "./commands/convert.js";
10
+ import { makeAiCommand } from "./commands/ai.js";
11
+ import { makeTranscribeCommand } from "./commands/transcribe.js";
12
+ import { makeProvidersCommand } from "./commands/providers.js";
13
+ import { makeAnalyticsCommand } from "./commands/analytics.js";
14
+ import { makeBillingCommand } from "./commands/billing.js";
15
+ const program = new Command();
16
+ program
17
+ .name("backbone")
18
+ .description("CLI for the Backbone AI platform")
19
+ .version("1.0.0")
20
+ .option("--api-key <key>", "API key (overrides config)")
21
+ .option("--base-url <url>", "Base URL (overrides config)")
22
+ .option("--project <id>", "Project ID (overrides config)")
23
+ .option("--json", "Output as JSON")
24
+ .option("--no-color", "Disable colored output");
25
+ program.addCommand(makeAuthCommand());
26
+ program.addCommand(makeConfigCommand());
27
+ program.addCommand(makeProjectsCommand());
28
+ program.addCommand(makeSchemasCommand());
29
+ program.addCommand(makePromptsCommand());
30
+ program.addCommand(makeExtractionsCommand());
31
+ program.addCommand(makeConvertCommand());
32
+ program.addCommand(makeAiCommand());
33
+ program.addCommand(makeTranscribeCommand());
34
+ program.addCommand(makeProvidersCommand());
35
+ program.addCommand(makeAnalyticsCommand());
36
+ program.addCommand(makeBillingCommand());
37
+ program.parse();
38
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,12 @@
1
+ import type { paths } from "../generated/openapi.js";
2
+ import type { Command } from "commander";
3
+ /**
4
+ * Create a typed openapi-fetch client from the resolved config.
5
+ * Attaches Bearer auth and error middleware automatically.
6
+ */
7
+ export declare function getClient(command: Command): import("openapi-fetch").Client<paths, `${string}/${string}`>;
8
+ /**
9
+ * Convenience: run an async action with consistent error handling.
10
+ */
11
+ export declare function runAction(command: Command, action: () => Promise<void>): Promise<void>;
12
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1,52 @@
1
+ import createClient from "openapi-fetch";
2
+ import { resolveConfig, isJsonOutput } from "./config.js";
3
+ import { BackboneApiError, handleError } from "./errors.js";
4
+ /**
5
+ * Error-handling middleware: intercepts non-ok responses and throws BackboneApiError.
6
+ */
7
+ const errorMiddleware = {
8
+ async onResponse({ response }) {
9
+ if (response.ok)
10
+ return undefined;
11
+ let body;
12
+ try {
13
+ body = await response.clone().json();
14
+ }
15
+ catch {
16
+ body = {};
17
+ }
18
+ throw new BackboneApiError({
19
+ status: body.status ?? response.status,
20
+ error: body.error ?? response.statusText,
21
+ message: body.message ?? `HTTP ${response.status}: ${response.statusText}`,
22
+ timestamp: body.timestamp ?? new Date().toISOString(),
23
+ });
24
+ },
25
+ };
26
+ /**
27
+ * Create a typed openapi-fetch client from the resolved config.
28
+ * Attaches Bearer auth and error middleware automatically.
29
+ */
30
+ export function getClient(command) {
31
+ const config = resolveConfig(command);
32
+ const client = createClient({
33
+ baseUrl: config.baseUrl.replace(/\/+$/, ""),
34
+ headers: {
35
+ Authorization: `Bearer ${config.apiKey}`,
36
+ },
37
+ });
38
+ client.use(errorMiddleware);
39
+ return client;
40
+ }
41
+ /**
42
+ * Convenience: run an async action with consistent error handling.
43
+ */
44
+ export async function runAction(command, action) {
45
+ try {
46
+ await action();
47
+ }
48
+ catch (err) {
49
+ handleError(err, isJsonOutput(command));
50
+ }
51
+ }
52
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1,20 @@
1
+ import Conf from "conf";
2
+ import type { Command } from "commander";
3
+ export interface BackboneConfig {
4
+ apiKey: string;
5
+ baseUrl: string;
6
+ project?: string;
7
+ }
8
+ declare const store: Conf<Partial<BackboneConfig>>;
9
+ export { store };
10
+ /**
11
+ * Resolve configuration with priority:
12
+ * 1. CLI flags (--api-key, --base-url, --project)
13
+ * 2. Environment variables (BACKBONE_API_KEY, BACKBONE_BASE_URL, BACKBONE_PROJECT)
14
+ * 3. Local .backbone file
15
+ * 4. Config store (~/.config/backbone/config.json)
16
+ */
17
+ export declare function resolveConfig(command: Command): BackboneConfig;
18
+ /** Check if --json flag is set on root command */
19
+ export declare function isJsonOutput(command: Command): boolean;
20
+ //# sourceMappingURL=config.d.ts.map