@koda-sl/baker-cli 0.2.0 → 0.4.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/README.md +52 -62
- package/dist/cli.js +2 -4
- package/dist/cli.js.map +1 -1
- package/dist/commands/images/index.d.ts.map +1 -1
- package/dist/commands/images/index.js +2 -4
- package/dist/commands/images/index.js.map +1 -1
- package/dist/commands/images/search.d.ts +8 -4
- package/dist/commands/images/search.d.ts.map +1 -1
- package/dist/commands/images/search.js +19 -6
- package/dist/commands/images/search.js.map +1 -1
- package/dist/output.d.ts +7 -5
- package/dist/output.d.ts.map +1 -1
- package/dist/output.js +39 -2
- package/dist/output.js.map +1 -1
- package/dist/output.test.js +69 -6
- package/dist/output.test.js.map +1 -1
- package/package.json +1 -1
- package/dist/commands/images/list.d.ts +0 -45
- package/dist/commands/images/list.d.ts.map +0 -1
- package/dist/commands/images/list.js +0 -71
- package/dist/commands/images/list.js.map +0 -1
- package/dist/commands/status.d.ts +0 -2
- package/dist/commands/status.d.ts.map +0 -1
- package/dist/commands/status.js +0 -36
- package/dist/commands/status.js.map +0 -1
package/README.md
CHANGED
|
@@ -56,42 +56,35 @@ baker status
|
|
|
56
56
|
# { "ok": true, "data": { "authenticated": true, "apiUrl": "https://..." } }
|
|
57
57
|
```
|
|
58
58
|
|
|
59
|
-
### `baker images
|
|
59
|
+
### `baker images search <query>`
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
Semantic search using hybrid BM25 + vector + reranking. Only returns ready images.
|
|
62
62
|
|
|
63
63
|
```bash
|
|
64
|
-
#
|
|
65
|
-
baker images
|
|
66
|
-
|
|
67
|
-
# Filter by tags and limit results
|
|
68
|
-
baker images list --tags logo,illustration --limit 10
|
|
69
|
-
|
|
70
|
-
# Compact tab-separated output
|
|
71
|
-
baker images list --output files
|
|
64
|
+
# Basic search
|
|
65
|
+
baker images search "hero banner"
|
|
72
66
|
|
|
73
|
-
#
|
|
74
|
-
baker images
|
|
67
|
+
# Filter by aspect ratio and tags
|
|
68
|
+
baker images search "logo" --aspect-ratio 1:1 --tags logo
|
|
75
69
|
|
|
76
|
-
#
|
|
77
|
-
baker images
|
|
70
|
+
# Limit results and set minimum relevance
|
|
71
|
+
baker images search "team photo" --limit 5 --min-score 0.3
|
|
78
72
|
|
|
79
|
-
#
|
|
80
|
-
baker images
|
|
73
|
+
# Full metadata with markdown output
|
|
74
|
+
baker images search "product shot" --full --output md
|
|
81
75
|
```
|
|
82
76
|
|
|
83
77
|
**Flags:**
|
|
84
78
|
|
|
85
|
-
| Flag
|
|
86
|
-
|
|
87
|
-
| `--
|
|
88
|
-
| `--
|
|
89
|
-
| `--
|
|
90
|
-
| `--
|
|
91
|
-
| `--
|
|
92
|
-
| `--
|
|
93
|
-
| `--
|
|
94
|
-
| `--full` | Include full metadata |
|
|
79
|
+
| Flag | Description |
|
|
80
|
+
|------------------|--------------------------------------------------------------------------|
|
|
81
|
+
| `--limit` | Max results (default 20) |
|
|
82
|
+
| `--min-score` | Minimum relevance score, 0-1 |
|
|
83
|
+
| `--aspect-ratio` | Filter by aspect ratio (1:1, 16:9, 9:16, 2:3, 3:4, 1:2, 2:1, 4:5, 3:2, 4:3) |
|
|
84
|
+
| `--tags` | Comma-separated tag names to filter by |
|
|
85
|
+
| `--output` | Output format: `json` \| `files` \| `md` |
|
|
86
|
+
| `--fields` | Comma-separated field names to include |
|
|
87
|
+
| `--full` | Include full metadata |
|
|
95
88
|
|
|
96
89
|
### `baker images get <id>`
|
|
97
90
|
|
|
@@ -107,34 +100,14 @@ baker images get j571abc123def --full
|
|
|
107
100
|
baker images get --image-id j571abc123def
|
|
108
101
|
```
|
|
109
102
|
|
|
110
|
-
### `baker images search <query>`
|
|
111
|
-
|
|
112
|
-
Semantic search using hybrid BM25 + vector + reranking.
|
|
113
|
-
|
|
114
|
-
```bash
|
|
115
|
-
# Basic search
|
|
116
|
-
baker images search "hero banner"
|
|
117
|
-
|
|
118
|
-
# Limit results and set minimum relevance
|
|
119
|
-
baker images search "team photo" --limit 5 --min-score 0.3
|
|
120
|
-
|
|
121
|
-
# Include scoring explanation (BM25, vector, rerank scores)
|
|
122
|
-
baker images search "logo" --explain
|
|
123
|
-
|
|
124
|
-
# Full metadata with markdown output
|
|
125
|
-
baker images search "product shot" --full --output md
|
|
126
|
-
```
|
|
127
|
-
|
|
128
103
|
**Flags:**
|
|
129
104
|
|
|
130
|
-
| Flag
|
|
131
|
-
|
|
132
|
-
| `--
|
|
133
|
-
| `--
|
|
134
|
-
| `--
|
|
135
|
-
| `--
|
|
136
|
-
| `--fields` | Comma-separated field names to include |
|
|
137
|
-
| `--full` | Include full metadata |
|
|
105
|
+
| Flag | Description |
|
|
106
|
+
|--------------|----------------------------------------------|
|
|
107
|
+
| `--image-id` | Image ID (alternative to positional arg) |
|
|
108
|
+
| `--output` | Output format: `json` \| `files` \| `md` |
|
|
109
|
+
| `--fields` | Comma-separated field names to include |
|
|
110
|
+
| `--full` | Include full metadata |
|
|
138
111
|
|
|
139
112
|
### `baker images upload <file>`
|
|
140
113
|
|
|
@@ -158,9 +131,9 @@ baker images upload ./logo.png --dry-run
|
|
|
158
131
|
|
|
159
132
|
| Flag | Description |
|
|
160
133
|
|------------------|------------------------------------------------|
|
|
161
|
-
| `--source` | Source identifier
|
|
134
|
+
| `--source` | Source identifier |
|
|
162
135
|
| `--content-type` | MIME type (auto-detected from extension) |
|
|
163
|
-
| `--dry-run` | Preview the operation without executing
|
|
136
|
+
| `--dry-run` | Preview the operation without executing |
|
|
164
137
|
|
|
165
138
|
Supported extensions: `.png`, `.jpg`, `.jpeg`, `.gif`, `.webp`, `.svg`, `.avif`
|
|
166
139
|
|
|
@@ -179,9 +152,10 @@ baker images delete j571abc123def
|
|
|
179
152
|
|
|
180
153
|
**Flags:**
|
|
181
154
|
|
|
182
|
-
| Flag
|
|
183
|
-
|
|
184
|
-
| `--
|
|
155
|
+
| Flag | Description |
|
|
156
|
+
|--------------|----------------------------------------------|
|
|
157
|
+
| `--image-id` | Image ID (alternative to positional arg) |
|
|
158
|
+
| `--dry-run` | Preview the operation without executing |
|
|
185
159
|
|
|
186
160
|
### `baker schema [command]`
|
|
187
161
|
|
|
@@ -190,7 +164,7 @@ Inspect command argument schemas for AI agent introspection.
|
|
|
190
164
|
```bash
|
|
191
165
|
# List all available commands
|
|
192
166
|
baker schema
|
|
193
|
-
# { "ok": true, "data": { "commands": ["images.
|
|
167
|
+
# { "ok": true, "data": { "commands": ["images.search", "images.get", ...] } }
|
|
194
168
|
|
|
195
169
|
# Get schema for a specific command
|
|
196
170
|
baker schema images.search
|
|
@@ -201,10 +175,10 @@ baker schema images.search
|
|
|
201
175
|
|
|
202
176
|
By default, image responses include only essential fields to minimize token usage:
|
|
203
177
|
|
|
204
|
-
| Mode | Fields
|
|
205
|
-
|
|
206
|
-
| Default | `_id`, `name`, `imageUrl`, `
|
|
207
|
-
| `--full` | All fields:
|
|
178
|
+
| Mode | Fields |
|
|
179
|
+
|-----------|------------------------------------------------------------|
|
|
180
|
+
| Default | `_id`, `name`, `imageUrl`, `description`, `tags` |
|
|
181
|
+
| `--full` | All fields: width, height, aspectRatio, dominantColor, imagePalette, source, createdAt |
|
|
208
182
|
|
|
209
183
|
## Error Codes
|
|
210
184
|
|
|
@@ -217,6 +191,22 @@ By default, image responses include only essential fields to minimize token usag
|
|
|
217
191
|
| `NETWORK_ERROR` | Connection failed |
|
|
218
192
|
| `INTERNAL_ERROR` | Unexpected server error |
|
|
219
193
|
|
|
194
|
+
## Available Image Tags
|
|
195
|
+
|
|
196
|
+
Use these with `--tags` to filter image search results. Multiple tags can be comma-separated.
|
|
197
|
+
|
|
198
|
+
| Tag | Description |
|
|
199
|
+
|--------------------|--------------------------------------------------------------|
|
|
200
|
+
| `logo` | Singular company, product, or organizational logo |
|
|
201
|
+
| `profile-picture` | Portrait-style image featuring a person's face |
|
|
202
|
+
| `illustration` | Stylized, drawn, or vector artwork |
|
|
203
|
+
| `software` | UI, dashboards, app interfaces, or software captures |
|
|
204
|
+
| `product-shot` | Focused depiction of a tangible product |
|
|
205
|
+
| `team-photo` | Group of people posed together, such as company team imagery |
|
|
206
|
+
| `environment` | Backgrounds or scenes showcasing locations, offices, spaces |
|
|
207
|
+
| `iconography` | Icons, symbols, or small graphical elements |
|
|
208
|
+
| `textures` | Patterns, textures, or abstract visual surfaces |
|
|
209
|
+
|
|
220
210
|
## For AI Agents
|
|
221
211
|
|
|
222
212
|
This CLI is designed for AI agent consumption. Key patterns:
|
package/dist/cli.js
CHANGED
|
@@ -2,12 +2,11 @@
|
|
|
2
2
|
import { defineCommand, runMain } from "citty";
|
|
3
3
|
import { imagesCommand } from "./commands/images/index.js";
|
|
4
4
|
import { schemaCommand } from "./commands/schema.js";
|
|
5
|
-
import { statusCommand } from "./commands/status.js";
|
|
6
5
|
const main = defineCommand({
|
|
7
6
|
meta: {
|
|
8
7
|
name: "baker",
|
|
9
|
-
version: "0.
|
|
10
|
-
description: `AI-agent
|
|
8
|
+
version: "0.4.0",
|
|
9
|
+
description: `AI-agent CLI for finding and managing images in Baker.
|
|
11
10
|
|
|
12
11
|
Auth: Set BAKER_API_KEY (starts with bk_) and BAKER_API_URL environment variables.
|
|
13
12
|
Output: All commands return JSON envelopes: { ok: true, data: ... } or { ok: false, error: { code, message } }.
|
|
@@ -17,7 +16,6 @@ Introspection: Run 'baker schema <command>' to inspect argument schemas.`,
|
|
|
17
16
|
subCommands: {
|
|
18
17
|
images: imagesCommand,
|
|
19
18
|
schema: schemaCommand,
|
|
20
|
-
status: statusCommand,
|
|
21
19
|
},
|
|
22
20
|
});
|
|
23
21
|
runMain(main);
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,MAAM,IAAI,GAAG,aAAa,CAAC;IACzB,IAAI,EAAE;QACJ,IAAI,EAAE,OAAO;QACb,OAAO,EAAE,OAAO;QAChB,WAAW,EAAE;;;;;yEAKwD;KACtE;IACD,WAAW,EAAE;QACX,MAAM,EAAE,aAAa;QACrB,MAAM,EAAE,aAAa;KACtB;CACF,CAAC,CAAC;AAEH,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/images/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/images/index.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,aAAa,qDAkBxB,CAAC"}
|
|
@@ -1,23 +1,21 @@
|
|
|
1
1
|
import { defineCommand } from "citty";
|
|
2
2
|
import { deleteCommand } from "./delete.js";
|
|
3
3
|
import { getCommand } from "./get.js";
|
|
4
|
-
import { listCommand } from "./list.js";
|
|
5
4
|
import { searchCommand } from "./search.js";
|
|
6
5
|
import { uploadCommand } from "./upload.js";
|
|
7
6
|
export const imagesCommand = defineCommand({
|
|
8
7
|
meta: {
|
|
9
8
|
name: "images",
|
|
10
|
-
description: `
|
|
9
|
+
description: `Find and manage images in Baker. Subcommands: search, get, upload, delete.
|
|
11
10
|
|
|
12
11
|
Examples:
|
|
13
|
-
baker images list --status ready
|
|
14
12
|
baker images search "hero banner" --limit 5
|
|
13
|
+
baker images search "logo" --aspect-ratio 1:1 --tags logo
|
|
15
14
|
baker images get <image-id>
|
|
16
15
|
baker images upload ./logo.png --source uploaded
|
|
17
16
|
baker images delete <image-id> --dry-run`,
|
|
18
17
|
},
|
|
19
18
|
subCommands: {
|
|
20
|
-
list: listCommand,
|
|
21
19
|
get: getCommand,
|
|
22
20
|
search: searchCommand,
|
|
23
21
|
upload: uploadCommand,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/images/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/images/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,CAAC,MAAM,aAAa,GAAG,aAAa,CAAC;IACzC,IAAI,EAAE;QACJ,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE;;;;;;;2CAO0B;KACxC;IACD,WAAW,EAAE;QACX,GAAG,EAAE,UAAU;QACf,MAAM,EAAE,aAAa;QACrB,MAAM,EAAE,aAAa;QACrB,MAAM,EAAE,aAAa;KACtB;CACF,CAAC,CAAC"}
|
|
@@ -14,11 +14,15 @@ export declare const searchCommand: import("citty").CommandDef<{
|
|
|
14
14
|
readonly description: "Minimum relevance score (0-1)";
|
|
15
15
|
readonly required: false;
|
|
16
16
|
};
|
|
17
|
-
readonly
|
|
18
|
-
readonly type: "
|
|
19
|
-
readonly description: "
|
|
17
|
+
readonly "aspect-ratio": {
|
|
18
|
+
readonly type: "string";
|
|
19
|
+
readonly description: "Filter by aspect ratio (1:1, 16:9, 9:16, 2:3, 3:4, 1:2, 2:1, 4:5, 3:2, 4:3)";
|
|
20
|
+
readonly required: false;
|
|
21
|
+
};
|
|
22
|
+
readonly tags: {
|
|
23
|
+
readonly type: "string";
|
|
24
|
+
readonly description: "Comma-separated tags to filter by";
|
|
20
25
|
readonly required: false;
|
|
21
|
-
readonly default: false;
|
|
22
26
|
};
|
|
23
27
|
readonly output: {
|
|
24
28
|
readonly type: "string";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../../src/commands/images/search.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../../src/commands/images/search.ts"],"names":[],"mappings":"AAqBA,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0DxB,CAAC"}
|
|
@@ -4,24 +4,34 @@ import { writeJson, writeOutput } from "../../output.js";
|
|
|
4
4
|
import { registerSchema } from "../../schemas.js";
|
|
5
5
|
registerSchema({
|
|
6
6
|
command: "images.search",
|
|
7
|
-
description: "Search images by text query",
|
|
7
|
+
description: "Search images by text query. Only returns ready images.",
|
|
8
8
|
args: {
|
|
9
9
|
query: { type: "string", description: "Search query text", required: true },
|
|
10
10
|
limit: { type: "number", description: "Maximum results to return", required: false, default: 20 },
|
|
11
11
|
"min-score": { type: "number", description: "Minimum relevance score (0-1)", required: false },
|
|
12
|
-
|
|
12
|
+
"aspect-ratio": {
|
|
13
|
+
type: "string",
|
|
14
|
+
description: "Filter by aspect ratio (1:1, 16:9, 9:16, 2:3, 3:4, 1:2, 2:1, 4:5, 3:2, 4:3)",
|
|
15
|
+
required: false,
|
|
16
|
+
},
|
|
17
|
+
tags: { type: "string", description: "Comma-separated tags to filter by", required: false },
|
|
13
18
|
},
|
|
14
19
|
});
|
|
15
20
|
export const searchCommand = defineCommand({
|
|
16
21
|
meta: {
|
|
17
22
|
name: "search",
|
|
18
|
-
description: "Semantic search images by text query. Uses hybrid BM25 + vector + reranking. Example: baker images search 'hero banner' --
|
|
23
|
+
description: "Semantic search images by text query. Uses hybrid BM25 + vector + reranking. Example: baker images search 'hero banner' --aspect-ratio 16:9 --tags logo",
|
|
19
24
|
},
|
|
20
25
|
args: {
|
|
21
26
|
query: { type: "positional", description: "Search query text", required: false },
|
|
22
27
|
limit: { type: "string", description: "Max results (default 20)", required: false },
|
|
23
28
|
"min-score": { type: "string", description: "Minimum relevance score (0-1)", required: false },
|
|
24
|
-
|
|
29
|
+
"aspect-ratio": {
|
|
30
|
+
type: "string",
|
|
31
|
+
description: "Filter by aspect ratio (1:1, 16:9, 9:16, 2:3, 3:4, 1:2, 2:1, 4:5, 3:2, 4:3)",
|
|
32
|
+
required: false,
|
|
33
|
+
},
|
|
34
|
+
tags: { type: "string", description: "Comma-separated tags to filter by", required: false },
|
|
25
35
|
output: { type: "string", description: "Output format: json|files|md", required: false, default: "json" },
|
|
26
36
|
fields: { type: "string", description: "Comma-separated field names to include", required: false },
|
|
27
37
|
full: { type: "boolean", description: "Include full metadata", required: false, default: false },
|
|
@@ -40,8 +50,11 @@ export const searchCommand = defineCommand({
|
|
|
40
50
|
if (args["min-score"]) {
|
|
41
51
|
body.minScore = Number(args["min-score"]);
|
|
42
52
|
}
|
|
43
|
-
if (args
|
|
44
|
-
body.
|
|
53
|
+
if (args["aspect-ratio"]) {
|
|
54
|
+
body.aspectRatio = args["aspect-ratio"];
|
|
55
|
+
}
|
|
56
|
+
if (args.tags) {
|
|
57
|
+
body.tags = args.tags.split(",").filter(Boolean);
|
|
45
58
|
}
|
|
46
59
|
const data = await apiPost("/api/images/search", body);
|
|
47
60
|
writeOutput({ ok: true, data }, args.output || "json", args.fields ? args.fields.split(",") : undefined, args.full);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.js","sourceRoot":"","sources":["../../../src/commands/images/search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAqB,SAAS,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,cAAc,CAAC;IACb,OAAO,EAAE,eAAe;IACxB,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"search.js","sourceRoot":"","sources":["../../../src/commands/images/search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAqB,SAAS,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,cAAc,CAAC;IACb,OAAO,EAAE,eAAe;IACxB,WAAW,EAAE,yDAAyD;IACtE,IAAI,EAAE;QACJ,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,mBAAmB,EAAE,QAAQ,EAAE,IAAI,EAAE;QAC3E,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,2BAA2B,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE;QACjG,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,+BAA+B,EAAE,QAAQ,EAAE,KAAK,EAAE;QAC9F,cAAc,EAAE;YACd,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,6EAA6E;YAC1F,QAAQ,EAAE,KAAK;SAChB;QACD,IAAI,EAAE,EAAE,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E,CAAC;gBAC5B,SAAS,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;gBAC1E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAClB,CAAC;YACD,SAAS,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,kBAAkB,EAAE,EAAE,CAAC,CAAC;YACzF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;CACF,CAAC,CAAC"}
|
package/dist/output.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type OutputFormat = "json" | "files" | "md";
|
|
2
|
-
|
|
2
|
+
interface SuccessEnvelope<T> {
|
|
3
3
|
ok: true;
|
|
4
4
|
data: T;
|
|
5
5
|
meta?: {
|
|
@@ -8,28 +8,30 @@ export interface SuccessEnvelope<T> {
|
|
|
8
8
|
count?: number;
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
|
-
|
|
11
|
+
interface ErrorEnvelope {
|
|
12
12
|
ok: false;
|
|
13
13
|
error: {
|
|
14
14
|
code: string;
|
|
15
15
|
message: string;
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
|
-
|
|
18
|
+
interface DryRunEnvelope {
|
|
19
19
|
ok: true;
|
|
20
20
|
dryRun: true;
|
|
21
21
|
operation: string;
|
|
22
22
|
params: Record<string, unknown>;
|
|
23
23
|
}
|
|
24
|
-
|
|
24
|
+
type Envelope<T> = SuccessEnvelope<T> | ErrorEnvelope | DryRunEnvelope;
|
|
25
|
+
export declare function formatAspectRatio(ratio: number | undefined): string | null;
|
|
25
26
|
interface ImageCompact {
|
|
26
27
|
_id: string;
|
|
27
28
|
name: string;
|
|
28
29
|
imageUrl: string;
|
|
29
|
-
|
|
30
|
+
description: string;
|
|
30
31
|
tags: unknown[];
|
|
31
32
|
}
|
|
32
33
|
export declare function compactImage(image: Record<string, unknown>): ImageCompact;
|
|
34
|
+
export declare function fullImage(image: Record<string, unknown>): Record<string, unknown>;
|
|
33
35
|
export declare function applyFieldMask<T extends Record<string, unknown>>(data: T, fields: string[]): Partial<T>;
|
|
34
36
|
export declare function writeJson<T>(envelope: Envelope<T>): void;
|
|
35
37
|
export declare function writeOutput<T>(envelope: Envelope<T>, format: OutputFormat, fields?: string[], full?: boolean): void;
|
package/dist/output.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../src/output.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AAEnD,
|
|
1
|
+
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../src/output.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AAEnD,UAAU,eAAe,CAAC,CAAC;IACzB,EAAE,EAAE,IAAI,CAAC;IACT,IAAI,EAAE,CAAC,CAAC;IACR,IAAI,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAC/D;AAED,UAAU,aAAa;IACrB,EAAE,EAAE,KAAK,CAAC;IACV,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CAC1C;AAED,UAAU,cAAc;IACtB,EAAE,EAAE,IAAI,CAAC;IACT,MAAM,EAAE,IAAI,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAED,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4,
|
|
7
|
+
"1:2": 1 / 2,
|
|
8
|
+
"2:1": 2,
|
|
9
|
+
"4:5": 4 / 5,
|
|
10
|
+
"3:2": 3 / 2,
|
|
11
|
+
"4:3": 4 / 3,
|
|
12
|
+
};
|
|
13
|
+
const ASPECT_RATIO_TOLERANCE = 0.08;
|
|
14
|
+
export function formatAspectRatio(ratio) {
|
|
15
|
+
if (ratio === undefined || ratio === null) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
for (const [label, value] of Object.entries(ASPECT_RATIO_MAP)) {
|
|
19
|
+
if (Math.abs(ratio - value) / value < ASPECT_RATIO_TOLERANCE) {
|
|
20
|
+
return label;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
1
25
|
export function compactImage(image) {
|
|
2
26
|
return {
|
|
3
27
|
_id: String(image._id ?? ""),
|
|
4
28
|
name: String(image.name ?? ""),
|
|
5
29
|
imageUrl: String(image.imageUrl ?? ""),
|
|
6
|
-
|
|
30
|
+
description: String(image.description ?? ""),
|
|
7
31
|
tags: Array.isArray(image.tags) ? image.tags : [],
|
|
8
32
|
};
|
|
9
33
|
}
|
|
34
|
+
export function fullImage(image) {
|
|
35
|
+
const compact = compactImage(image);
|
|
36
|
+
return {
|
|
37
|
+
...compact,
|
|
38
|
+
width: image.width ?? null,
|
|
39
|
+
height: image.height ?? null,
|
|
40
|
+
aspectRatio: formatAspectRatio(image.aspectRatio),
|
|
41
|
+
dominantColor: image.dominantColor ?? null,
|
|
42
|
+
imagePalette: Array.isArray(image.imagePalette) ? image.imagePalette : [],
|
|
43
|
+
source: String(image.source ?? ""),
|
|
44
|
+
createdAt: image.createdAt ?? null,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
10
47
|
export function applyFieldMask(data, fields) {
|
|
11
48
|
const result = {};
|
|
12
49
|
for (const field of fields) {
|
|
@@ -46,7 +83,7 @@ function normalizeData(envelope, fields, full) {
|
|
|
46
83
|
const items = raw.map((item) => {
|
|
47
84
|
const record = item;
|
|
48
85
|
if (full) {
|
|
49
|
-
return record;
|
|
86
|
+
return fullImage(record);
|
|
50
87
|
}
|
|
51
88
|
return compactImage(record);
|
|
52
89
|
});
|
package/dist/output.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output.js","sourceRoot":"","sources":["../src/output.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"output.js","sourceRoot":"","sources":["../src/output.ts"],"names":[],"mappings":"AAsBA,MAAM,gBAAgB,GAA2B;IAC/C,KAAK,EAAE,CAAC;IACR,MAAM,EAAE,EAAE,GAAG,CAAC;IACd,MAAM,EAAE,CAAC,GAAG,EAAE;IACd,KAAK,EAAE,CAAC,GAAG,CAAC;IACZ,KAAK,EAAE,CAAC,GAAG,CAAC;IACZ,KAAK,EAAE,CAAC,GAAG,CAAC;IACZ,KAAK,EAAE,CAAC;IACR,KAAK,EAAE,CAAC,GAAG,CAAC;IACZ,KAAK,EAAE,CAAC,GAAG,CAAC;IACZ,KAAK,EAAE,CAAC,GAAG,CAAC;CACb,CAAC;AAEF,MAAM,sBAAsB,GAAG,IAAI,CAAC;AAEpC,MAAM,UAAU,iBAAiB,CAAC,KAAyB;IACzD,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAC1C,OAAO,IAAI,CAAC;IACd,CAAC;IACD,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAAE,CAAC;QAC9D,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,KAAK,CAAC,GAAG,KAAK,GAAG,sBAAsB,EAAE,CAAC;YAC7D,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAUD,MAAM,UAAU,YAAY,CAAC,KAA8B;IACzD,OAAO;QACL,GAAG,EAAE,MAAM,CAAC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C,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAE5D,IAAI,MAAM,KAAK,OAAO,EAAE,CAAC;QACvB,UAAU,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;QACjC,OAAO;IACT,CAAC;IAED,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QACpB,OAAO,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;IAChC,CAAC;AACH,CAAC"}
|
package/dist/output.test.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { applyFieldMask, compactImage } from "./output.js";
|
|
2
|
+
import { applyFieldMask, compactImage, formatAspectRatio, fullImage } from "./output.js";
|
|
3
3
|
describe("compactImage", () => {
|
|
4
4
|
it("extracts compact fields from full image record", () => {
|
|
5
5
|
const full = {
|
|
6
6
|
_id: "abc123",
|
|
7
7
|
name: "hero-banner",
|
|
8
8
|
imageUrl: "https://r2.example.com/images/hero.png",
|
|
9
|
-
status: "ready",
|
|
10
|
-
tags: ["logo", "illustration"],
|
|
11
9
|
description: "A detailed hero banner",
|
|
10
|
+
tags: ["logo", "illustration"],
|
|
11
|
+
status: "ready",
|
|
12
12
|
width: 1920,
|
|
13
13
|
height: 1080,
|
|
14
14
|
source: "uploaded",
|
|
@@ -18,7 +18,7 @@ describe("compactImage", () => {
|
|
|
18
18
|
_id: "abc123",
|
|
19
19
|
name: "hero-banner",
|
|
20
20
|
imageUrl: "https://r2.example.com/images/hero.png",
|
|
21
|
-
|
|
21
|
+
description: "A detailed hero banner",
|
|
22
22
|
tags: ["logo", "illustration"],
|
|
23
23
|
});
|
|
24
24
|
});
|
|
@@ -28,14 +28,77 @@ describe("compactImage", () => {
|
|
|
28
28
|
_id: "",
|
|
29
29
|
name: "",
|
|
30
30
|
imageUrl: "",
|
|
31
|
-
|
|
31
|
+
description: "",
|
|
32
32
|
tags: [],
|
|
33
33
|
});
|
|
34
34
|
});
|
|
35
35
|
});
|
|
36
|
+
describe("fullImage", () => {
|
|
37
|
+
it("includes compact fields plus design details", () => {
|
|
38
|
+
const record = {
|
|
39
|
+
_id: "abc123",
|
|
40
|
+
name: "hero-banner",
|
|
41
|
+
imageUrl: "https://r2.example.com/images/hero.png",
|
|
42
|
+
description: "A detailed hero banner",
|
|
43
|
+
tags: ["logo"],
|
|
44
|
+
width: 1920,
|
|
45
|
+
height: 1080,
|
|
46
|
+
aspectRatio: 16 / 9,
|
|
47
|
+
dominantColor: "rgb(255, 0, 0)",
|
|
48
|
+
imagePalette: ["rgb(255, 0, 0)", "rgb(0, 0, 255)"],
|
|
49
|
+
source: "uploaded",
|
|
50
|
+
createdAt: 1700000000000,
|
|
51
|
+
};
|
|
52
|
+
const result = fullImage(record);
|
|
53
|
+
expect(result).toEqual({
|
|
54
|
+
_id: "abc123",
|
|
55
|
+
name: "hero-banner",
|
|
56
|
+
imageUrl: "https://r2.example.com/images/hero.png",
|
|
57
|
+
description: "A detailed hero banner",
|
|
58
|
+
tags: ["logo"],
|
|
59
|
+
width: 1920,
|
|
60
|
+
height: 1080,
|
|
61
|
+
aspectRatio: "16:9",
|
|
62
|
+
dominantColor: "rgb(255, 0, 0)",
|
|
63
|
+
imagePalette: ["rgb(255, 0, 0)", "rgb(0, 0, 255)"],
|
|
64
|
+
source: "uploaded",
|
|
65
|
+
createdAt: 1700000000000,
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
it("handles missing optional fields", () => {
|
|
69
|
+
const result = fullImage({ _id: "x", name: "test", imageUrl: "url", description: "desc", tags: [] });
|
|
70
|
+
expect(result).toMatchObject({
|
|
71
|
+
width: null,
|
|
72
|
+
height: null,
|
|
73
|
+
aspectRatio: null,
|
|
74
|
+
dominantColor: null,
|
|
75
|
+
imagePalette: [],
|
|
76
|
+
source: "",
|
|
77
|
+
createdAt: null,
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
describe("formatAspectRatio", () => {
|
|
82
|
+
it("returns label for known ratios", () => {
|
|
83
|
+
expect(formatAspectRatio(16 / 9)).toBe("16:9");
|
|
84
|
+
expect(formatAspectRatio(1)).toBe("1:1");
|
|
85
|
+
expect(formatAspectRatio(9 / 16)).toBe("9:16");
|
|
86
|
+
expect(formatAspectRatio(4 / 3)).toBe("4:3");
|
|
87
|
+
});
|
|
88
|
+
it("matches within tolerance", () => {
|
|
89
|
+
expect(formatAspectRatio(1.78)).toBe("16:9");
|
|
90
|
+
expect(formatAspectRatio(0.99)).toBe("1:1");
|
|
91
|
+
});
|
|
92
|
+
it("returns null for unknown ratios", () => {
|
|
93
|
+
expect(formatAspectRatio(3.5)).toBeNull();
|
|
94
|
+
});
|
|
95
|
+
it("returns null for undefined", () => {
|
|
96
|
+
expect(formatAspectRatio(undefined)).toBeNull();
|
|
97
|
+
});
|
|
98
|
+
});
|
|
36
99
|
describe("applyFieldMask", () => {
|
|
37
100
|
it("filters object to only requested fields", () => {
|
|
38
|
-
const data = { _id: "abc", name: "test",
|
|
101
|
+
const data = { _id: "abc", name: "test", imageUrl: "https://example.com" };
|
|
39
102
|
const result = applyFieldMask(data, ["_id", "name"]);
|
|
40
103
|
expect(result).toEqual({ _id: "abc", name: "test" });
|
|
41
104
|
});
|
package/dist/output.test.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output.test.js","sourceRoot":"","sources":["../src/output.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"output.test.js","sourceRoot":"","sources":["../src/output.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,iBAAiB,EAAE,SA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EAAE,QAAQ,EAAE,qBAAqB,EAAE,CAAC;QAC3E,MAAM,MAAM,GAAG,cAAc,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;QAErD,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,kCAAkC,EAAE,GAAG,EAAE;QAC1C,MAAM,IAAI,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QAC1C,MAAM,MAAM,GAAG,cAAc,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC;QAE5D,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,2CAA2C,EAAE,GAAG,EAAE;QACnD,MAAM,IAAI,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QAC1C,MAAM,MAAM,GAAG,cAAc,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAExC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
export declare const listCommand: import("citty").CommandDef<{
|
|
2
|
-
readonly status: {
|
|
3
|
-
readonly type: "string";
|
|
4
|
-
readonly description: "Filter by status (ready|processing|uploading|error)";
|
|
5
|
-
readonly required: false;
|
|
6
|
-
};
|
|
7
|
-
readonly tags: {
|
|
8
|
-
readonly type: "string";
|
|
9
|
-
readonly description: "Comma-separated tag names";
|
|
10
|
-
readonly required: false;
|
|
11
|
-
};
|
|
12
|
-
readonly source: {
|
|
13
|
-
readonly type: "string";
|
|
14
|
-
readonly description: "Filter by source";
|
|
15
|
-
readonly required: false;
|
|
16
|
-
};
|
|
17
|
-
readonly limit: {
|
|
18
|
-
readonly type: "string";
|
|
19
|
-
readonly description: "Max results (default 50)";
|
|
20
|
-
readonly required: false;
|
|
21
|
-
};
|
|
22
|
-
readonly cursor: {
|
|
23
|
-
readonly type: "string";
|
|
24
|
-
readonly description: "Pagination cursor";
|
|
25
|
-
readonly required: false;
|
|
26
|
-
};
|
|
27
|
-
readonly output: {
|
|
28
|
-
readonly type: "string";
|
|
29
|
-
readonly description: "Output format: json|files|md";
|
|
30
|
-
readonly required: false;
|
|
31
|
-
readonly default: "json";
|
|
32
|
-
};
|
|
33
|
-
readonly fields: {
|
|
34
|
-
readonly type: "string";
|
|
35
|
-
readonly description: "Comma-separated field names to include";
|
|
36
|
-
readonly required: false;
|
|
37
|
-
};
|
|
38
|
-
readonly full: {
|
|
39
|
-
readonly type: "boolean";
|
|
40
|
-
readonly description: "Include full metadata";
|
|
41
|
-
readonly required: false;
|
|
42
|
-
readonly default: false;
|
|
43
|
-
};
|
|
44
|
-
}>;
|
|
45
|
-
//# sourceMappingURL=list.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/commands/images/list.ts"],"names":[],"mappings":"AAsBA,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsDtB,CAAC"}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { defineCommand } from "citty";
|
|
2
|
-
import { ApiError, apiGet } from "../../client.js";
|
|
3
|
-
import { writeJson, writeOutput } from "../../output.js";
|
|
4
|
-
import { registerSchema } from "../../schemas.js";
|
|
5
|
-
registerSchema({
|
|
6
|
-
command: "images.list",
|
|
7
|
-
description: "List images with optional filters",
|
|
8
|
-
args: {
|
|
9
|
-
status: {
|
|
10
|
-
type: "string",
|
|
11
|
-
description: "Filter by status",
|
|
12
|
-
required: false,
|
|
13
|
-
enum: ["ready", "processing", "uploading", "error"],
|
|
14
|
-
},
|
|
15
|
-
tags: { type: "string", description: "Comma-separated tag names to filter by", required: false },
|
|
16
|
-
source: { type: "string", description: "Filter by source", required: false },
|
|
17
|
-
limit: { type: "number", description: "Maximum results to return", required: false, default: 50 },
|
|
18
|
-
cursor: { type: "string", description: "Pagination cursor from previous response", required: false },
|
|
19
|
-
},
|
|
20
|
-
});
|
|
21
|
-
export const listCommand = defineCommand({
|
|
22
|
-
meta: {
|
|
23
|
-
name: "list",
|
|
24
|
-
description: "List images with optional filters. Example: baker images list --status ready --tags logo --limit 10",
|
|
25
|
-
},
|
|
26
|
-
args: {
|
|
27
|
-
status: {
|
|
28
|
-
type: "string",
|
|
29
|
-
description: "Filter by status (ready|processing|uploading|error)",
|
|
30
|
-
required: false,
|
|
31
|
-
},
|
|
32
|
-
tags: { type: "string", description: "Comma-separated tag names", required: false },
|
|
33
|
-
source: { type: "string", description: "Filter by source", required: false },
|
|
34
|
-
limit: { type: "string", description: "Max results (default 50)", required: false },
|
|
35
|
-
cursor: { type: "string", description: "Pagination cursor", required: false },
|
|
36
|
-
output: { type: "string", description: "Output format: json|files|md", required: false, default: "json" },
|
|
37
|
-
fields: { type: "string", description: "Comma-separated field names to include", required: false },
|
|
38
|
-
full: { type: "boolean", description: "Include full metadata", required: false, default: false },
|
|
39
|
-
},
|
|
40
|
-
run: async ({ args }) => {
|
|
41
|
-
try {
|
|
42
|
-
const params = {};
|
|
43
|
-
if (args.status) {
|
|
44
|
-
params.status = args.status;
|
|
45
|
-
}
|
|
46
|
-
if (args.tags) {
|
|
47
|
-
params.tags = args.tags;
|
|
48
|
-
}
|
|
49
|
-
if (args.source) {
|
|
50
|
-
params.source = args.source;
|
|
51
|
-
}
|
|
52
|
-
if (args.limit) {
|
|
53
|
-
params.limit = args.limit;
|
|
54
|
-
}
|
|
55
|
-
if (args.cursor) {
|
|
56
|
-
params.cursor = args.cursor;
|
|
57
|
-
}
|
|
58
|
-
const data = await apiGet("/api/images", params);
|
|
59
|
-
writeOutput({ ok: true, data }, args.output || "json", args.fields ? args.fields.split(",") : undefined, args.full);
|
|
60
|
-
}
|
|
61
|
-
catch (err) {
|
|
62
|
-
if (err instanceof ApiError) {
|
|
63
|
-
writeJson({ ok: false, error: { code: err.code, message: err.message } });
|
|
64
|
-
process.exit(1);
|
|
65
|
-
}
|
|
66
|
-
writeJson({ ok: false, error: { code: "INTERNAL_ERROR", message: "Unexpected error" } });
|
|
67
|
-
process.exit(1);
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
});
|
|
71
|
-
//# sourceMappingURL=list.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/commands/images/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAqB,SAAS,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,cAAc,CAAC;IACb,OAAO,EAAE,aAAa;IACtB,WAAW,EAAE,mCAAmC;IAChD,IAAI,EAAE;QACJ,MAAM,EAAE;YACN,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,kBAAkB;YAC/B,QAAQ,EAAE,KAAK;YACf,IAAI,EAAE,CAAC,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,OAAO,CAAC;SACpD;QACD,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,wCAAwC,EAAE,QAAQ,EAAE,KAAK,EAAE;QAChG,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,kBAAkB,EAAE,QAAQ,EAA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AAE,EAAE,CAAC,CAAC;gBAC1E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAClB,CAAC;YACD,SAAS,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,kBAAkB,EAAE,EAAE,CAAC,CAAC;YACzF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../src/commands/status.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,aAAa,gCAuBxB,CAAC"}
|
package/dist/commands/status.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { defineCommand } from "citty";
|
|
2
|
-
import { ApiError, apiGet } from "../client.js";
|
|
3
|
-
import { getEnv } from "../env.js";
|
|
4
|
-
import { writeJson } from "../output.js";
|
|
5
|
-
import { registerSchema } from "../schemas.js";
|
|
6
|
-
registerSchema({
|
|
7
|
-
command: "status",
|
|
8
|
-
description: "Check API connectivity and authentication",
|
|
9
|
-
args: {},
|
|
10
|
-
});
|
|
11
|
-
export const statusCommand = defineCommand({
|
|
12
|
-
meta: { name: "status", description: "Check API key validity and connection health. Example: baker status" },
|
|
13
|
-
args: {},
|
|
14
|
-
run: async () => {
|
|
15
|
-
try {
|
|
16
|
-
await apiGet("/api/images", { limit: "0" });
|
|
17
|
-
const envelope = {
|
|
18
|
-
ok: true,
|
|
19
|
-
data: {
|
|
20
|
-
authenticated: true,
|
|
21
|
-
apiUrl: getEnv().BAKER_API_URL,
|
|
22
|
-
},
|
|
23
|
-
};
|
|
24
|
-
writeJson(envelope);
|
|
25
|
-
}
|
|
26
|
-
catch (err) {
|
|
27
|
-
if (err instanceof ApiError) {
|
|
28
|
-
writeJson({ ok: false, error: { code: err.code, message: err.message } });
|
|
29
|
-
process.exit(1);
|
|
30
|
-
}
|
|
31
|
-
writeJson({ ok: false, error: { code: "INTERNAL_ERROR", message: "Unexpected error" } });
|
|
32
|
-
process.exit(1);
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
});
|
|
36
|
-
//# sourceMappingURL=status.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../src/commands/status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAiB,SAAS,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,cAAc,CAAC;IACb,OAAO,EAAE,QAAQ;IACjB,WAAW,EAAE,2CAA2C;IACxD,IAAI,EAAE,EAAE;CACT,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,aAAa,GAAG,aAAa,CAAC;IACzC,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,qEAAqE,EAAE;IAC5G,IAAI,EAAE,EAAE;IACR,GAAG,EAAE,KAAK,IAAI,EAAE;QACd,IAAI,CAAC;YACH,MAAM,MAAM,CAAC,aAAa,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;YAC5C,MAAM,QAAQ,GAAsD;gBAClE,EAAE,EAAE,IAAI;gBACR,IAAI,EAAE;oBACJ,aAAa,EAAE,IAAI;oBACnB,MAAM,EAAE,MAAM,EAAE,CAAC,aAAa;iBAC/B;aACF,CAAC;YACF,SAAS,CAAC,QAAQ,CAAC,CAAC;QACtB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,GAAG,YAAY,QAAQ,EAAE,CAAC;gBAC5B,SAAS,CAAC,EAAE,EAAE,E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