@fluid-app/fluid-cli-assets 0.1.337 → 0.1.338

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { createDomainCommand, findProjectConfig, getAuthToken } from "@fluid-app/fluid-cli";
1
+ import { createDomainCommand, declareInputs, findProjectConfig, getAuthToken } from "@fluid-app/fluid-cli";
2
2
  import "commander";
3
3
  import { readFile, stat } from "node:fs/promises";
4
4
  import { basename } from "node:path";
@@ -64,156 +64,163 @@ function resolveToken(opts) {
64
64
  //#endregion
65
65
  //#region src/generated/primary.ts
66
66
  function registerPrimary(parent, ctx) {
67
- parent.command("get-asset-paths <code>").description("Lists asset paths for an existing asset").action(async (code) => {
67
+ declareInputs(parent.command("get-asset-paths <code>").description("Lists asset paths for an existing asset").action(async (code) => {
68
68
  const client = await ctx.getClient();
69
69
  if (ctx.verbose) process.stderr.write(`GET /api/dam/assets/${code}/asset_paths
70
70
  `);
71
71
  const result = await client.get(`/api/dam/assets/${code}/asset_paths`);
72
72
  ctx.output(result);
73
- });
74
- parent.command("create-asset-paths <code>").description("Creates asset paths for an existing asset").option("--body <json>", "Request body as JSON string").option("--body-file <path>", "Read request body from file").action(async (code, opts) => {
73
+ }), () => []);
74
+ declareInputs(parent.command("create-asset-paths <code>").description("Creates asset paths for an existing asset").option("--body <json>", "Request body as JSON string").option("--body-file <path>", "Read request body from file").action(async (code, opts) => {
75
75
  const client = await ctx.getClient();
76
76
  let body;
77
- if (opts.bodyFile) {
78
- const { readFileSync } = await import("fs");
79
- body = ctx.parseBody(readFileSync(opts.bodyFile, "utf-8"));
80
- } else if (opts.body) body = ctx.parseBody(opts.body);
77
+ if (opts.bodyFile) body = ctx.parseBody(ctx.inputs.readFile(opts.bodyFile, "utf-8"));
78
+ else if (opts.body) body = ctx.parseBody(opts.body);
81
79
  if (ctx.verbose) process.stderr.write(`POST /api/dam/assets/${code}/asset_paths
82
80
  `);
83
81
  const result = await client.post(`/api/dam/assets/${code}/asset_paths`, body);
84
82
  ctx.output(result);
85
- });
86
- parent.command("delete-asset-path <code> <id>").description("Destroys an asset path").action(async (code, id) => {
83
+ }), (opts) => opts.bodyFile ? [{
84
+ kind: "file",
85
+ path: String(opts.bodyFile)
86
+ }] : []);
87
+ declareInputs(parent.command("delete-asset-path <code> <id>").description("Destroys an asset path").action(async (code, id) => {
87
88
  const client = await ctx.getClient();
88
89
  if (ctx.verbose) process.stderr.write(`DELETE /api/dam/assets/${code}/asset_paths/${id}
89
90
  `);
90
91
  const result = await client.delete(`/api/dam/assets/${code}/asset_paths/${id}`);
91
92
  ctx.output(result);
92
- });
93
- parent.command("create-backfill-imagekit").description("Creates a DAM asset from ImageKit upload metadata").option("--body <json>", "Request body as JSON string").option("--body-file <path>", "Read request body from file").action(async (opts) => {
93
+ }), () => []);
94
+ declareInputs(parent.command("create-backfill-imagekit").description("Creates a DAM asset from ImageKit upload metadata").option("--body <json>", "Request body as JSON string").option("--body-file <path>", "Read request body from file").action(async (opts) => {
94
95
  const client = await ctx.getClient();
95
96
  let body;
96
- if (opts.bodyFile) {
97
- const { readFileSync } = await import("fs");
98
- body = ctx.parseBody(readFileSync(opts.bodyFile, "utf-8"));
99
- } else if (opts.body) body = ctx.parseBody(opts.body);
97
+ if (opts.bodyFile) body = ctx.parseBody(ctx.inputs.readFile(opts.bodyFile, "utf-8"));
98
+ else if (opts.body) body = ctx.parseBody(opts.body);
100
99
  if (ctx.verbose) process.stderr.write("POST /api/dam/assets/backfill_imagekit\n");
101
100
  const result = await client.post(`/api/dam/assets/backfill_imagekit`, body);
102
101
  ctx.output(result);
103
- });
104
- parent.command("create-asset-invalid-mixed-payload").description("Errors when multiple asset types are provided").option("--body <json>", "Request body as JSON string").option("--body-file <path>", "Read request body from file").action(async (opts) => {
102
+ }), (opts) => opts.bodyFile ? [{
103
+ kind: "file",
104
+ path: String(opts.bodyFile)
105
+ }] : []);
106
+ declareInputs(parent.command("create-asset-invalid-mixed-payload").description("Errors when multiple asset types are provided").option("--body <json>", "Request body as JSON string").option("--body-file <path>", "Read request body from file").action(async (opts) => {
105
107
  const client = await ctx.getClient();
106
108
  let body;
107
- if (opts.bodyFile) {
108
- const { readFileSync } = await import("fs");
109
- body = ctx.parseBody(readFileSync(opts.bodyFile, "utf-8"));
110
- } else if (opts.body) body = ctx.parseBody(opts.body);
109
+ if (opts.bodyFile) body = ctx.parseBody(ctx.inputs.readFile(opts.bodyFile, "utf-8"));
110
+ else if (opts.body) body = ctx.parseBody(opts.body);
111
111
  if (ctx.verbose) process.stderr.write("POST /api/dam/assets\n");
112
112
  const result = await client.post(`/api/dam/assets`, body);
113
113
  ctx.output(result);
114
- });
115
- parent.command("get-asset <code>").description("Retrieves an asset by code").action(async (code) => {
114
+ }), (opts) => opts.bodyFile ? [{
115
+ kind: "file",
116
+ path: String(opts.bodyFile)
117
+ }] : []);
118
+ declareInputs(parent.command("get-asset <code>").description("Retrieves an asset by code").action(async (code) => {
116
119
  const client = await ctx.getClient();
117
120
  if (ctx.verbose) process.stderr.write(`GET /api/dam/assets/${code}
118
121
  `);
119
122
  const result = await client.get(`/api/dam/assets/${code}`);
120
123
  ctx.output(result);
121
- });
122
- parent.command("update-asset <code>").description("Updates an existing asset").option("--body <json>", "Request body as JSON string").option("--body-file <path>", "Read request body from file").action(async (code, opts) => {
124
+ }), () => []);
125
+ declareInputs(parent.command("update-asset <code>").description("Updates an existing asset").option("--body <json>", "Request body as JSON string").option("--body-file <path>", "Read request body from file").action(async (code, opts) => {
123
126
  const client = await ctx.getClient();
124
127
  let body;
125
- if (opts.bodyFile) {
126
- const { readFileSync } = await import("fs");
127
- body = ctx.parseBody(readFileSync(opts.bodyFile, "utf-8"));
128
- } else if (opts.body) body = ctx.parseBody(opts.body);
128
+ if (opts.bodyFile) body = ctx.parseBody(ctx.inputs.readFile(opts.bodyFile, "utf-8"));
129
+ else if (opts.body) body = ctx.parseBody(opts.body);
129
130
  if (ctx.verbose) process.stderr.write(`PUT /api/dam/assets/${code}
130
131
  `);
131
132
  const result = await client.put(`/api/dam/assets/${code}`, body);
132
133
  ctx.output(result);
133
- });
134
- parent.command("delete-asset <code>").description("Deletes an asset").action(async (code) => {
134
+ }), (opts) => opts.bodyFile ? [{
135
+ kind: "file",
136
+ path: String(opts.bodyFile)
137
+ }] : []);
138
+ declareInputs(parent.command("delete-asset <code>").description("Deletes an asset").action(async (code) => {
135
139
  const client = await ctx.getClient();
136
140
  if (ctx.verbose) process.stderr.write(`DELETE /api/dam/assets/${code}
137
141
  `);
138
142
  const result = await client.delete(`/api/dam/assets/${code}`);
139
143
  ctx.output(result);
140
- });
141
- parent.command("discard-asset <code>").description("Discard an asset (soft delete)").action(async (code) => {
144
+ }), () => []);
145
+ declareInputs(parent.command("discard-asset <code>").description("Discard an asset (soft delete)").action(async (code) => {
142
146
  const client = await ctx.getClient();
143
147
  if (ctx.verbose) process.stderr.write(`PATCH /api/dam/assets/${code}/discard
144
148
  `);
145
149
  const result = await client.patch(`/api/dam/assets/${code}/discard`);
146
150
  ctx.output(result);
147
- });
148
- parent.command("create-imagekit-auth").description("Creates ImageKit authentication credentials for large file uploads").action(async () => {
151
+ }), () => []);
152
+ declareInputs(parent.command("create-imagekit-auth").description("Creates ImageKit authentication credentials for large file uploads").action(async () => {
149
153
  const client = await ctx.getClient();
150
154
  if (ctx.verbose) process.stderr.write("POST /api/dam/assets/imagekit_auth\n");
151
155
  const result = await client.post(`/api/dam/assets/imagekit_auth`);
152
156
  ctx.output(result);
153
- });
154
- parent.command("query-assets").description("Query DAM assets using tree paths and tags").option("--body <json>", "Request body as JSON string").option("--body-file <path>", "Read request body from file").action(async (opts) => {
157
+ }), () => []);
158
+ declareInputs(parent.command("query-assets").description("Query DAM assets using tree paths and tags").option("--body <json>", "Request body as JSON string").option("--body-file <path>", "Read request body from file").action(async (opts) => {
155
159
  const client = await ctx.getClient();
156
160
  let body;
157
- if (opts.bodyFile) {
158
- const { readFileSync } = await import("fs");
159
- body = ctx.parseBody(readFileSync(opts.bodyFile, "utf-8"));
160
- } else if (opts.body) body = ctx.parseBody(opts.body);
161
+ if (opts.bodyFile) body = ctx.parseBody(ctx.inputs.readFile(opts.bodyFile, "utf-8"));
162
+ else if (opts.body) body = ctx.parseBody(opts.body);
161
163
  if (ctx.verbose) process.stderr.write("POST /api/dam/query\n");
162
164
  const result = await client.post(`/api/dam/query`, body);
163
165
  ctx.output(result);
164
- });
165
- parent.command("list-variants <code>").description("Returns all variants for an existing asset").action(async (code) => {
166
+ }), (opts) => opts.bodyFile ? [{
167
+ kind: "file",
168
+ path: String(opts.bodyFile)
169
+ }] : []);
170
+ declareInputs(parent.command("list-variants <code>").description("Returns all variants for an existing asset").action(async (code) => {
166
171
  const client = await ctx.getClient();
167
172
  if (ctx.verbose) process.stderr.write(`GET /api/dam/assets/${code}/variants
168
173
  `);
169
174
  const result = await client.get(`/api/dam/assets/${code}/variants`);
170
175
  ctx.output(result);
171
- });
172
- parent.command("create-variants <code>").description("Creates variants for an existing asset").option("--body <json>", "Request body as JSON string").option("--body-file <path>", "Read request body from file").action(async (code, opts) => {
176
+ }), () => []);
177
+ declareInputs(parent.command("create-variants <code>").description("Creates variants for an existing asset").option("--body <json>", "Request body as JSON string").option("--body-file <path>", "Read request body from file").action(async (code, opts) => {
173
178
  const client = await ctx.getClient();
174
179
  let body;
175
- if (opts.bodyFile) {
176
- const { readFileSync } = await import("fs");
177
- body = ctx.parseBody(readFileSync(opts.bodyFile, "utf-8"));
178
- } else if (opts.body) body = ctx.parseBody(opts.body);
180
+ if (opts.bodyFile) body = ctx.parseBody(ctx.inputs.readFile(opts.bodyFile, "utf-8"));
181
+ else if (opts.body) body = ctx.parseBody(opts.body);
179
182
  if (ctx.verbose) process.stderr.write(`POST /api/dam/assets/${code}/variants
180
183
  `);
181
184
  const result = await client.post(`/api/dam/assets/${code}/variants`, body);
182
185
  ctx.output(result);
183
- });
184
- parent.command("get-variant <code> <id>").description("Returns a specific variant for an existing asset").action(async (code, id) => {
186
+ }), (opts) => opts.bodyFile ? [{
187
+ kind: "file",
188
+ path: String(opts.bodyFile)
189
+ }] : []);
190
+ declareInputs(parent.command("get-variant <code> <id>").description("Returns a specific variant for an existing asset").action(async (code, id) => {
185
191
  const client = await ctx.getClient();
186
192
  if (ctx.verbose) process.stderr.write(`GET /api/dam/assets/${code}/variants/${id}
187
193
  `);
188
194
  const result = await client.get(`/api/dam/assets/${code}/variants/${id}`);
189
195
  ctx.output(result);
190
- });
191
- parent.command("update-variant <code> <id>").description("Updates tags for a specific variant").option("--body <json>", "Request body as JSON string").option("--body-file <path>", "Read request body from file").action(async (code, id, opts) => {
196
+ }), () => []);
197
+ declareInputs(parent.command("update-variant <code> <id>").description("Updates tags for a specific variant").option("--body <json>", "Request body as JSON string").option("--body-file <path>", "Read request body from file").action(async (code, id, opts) => {
192
198
  const client = await ctx.getClient();
193
199
  let body;
194
- if (opts.bodyFile) {
195
- const { readFileSync } = await import("fs");
196
- body = ctx.parseBody(readFileSync(opts.bodyFile, "utf-8"));
197
- } else if (opts.body) body = ctx.parseBody(opts.body);
200
+ if (opts.bodyFile) body = ctx.parseBody(ctx.inputs.readFile(opts.bodyFile, "utf-8"));
201
+ else if (opts.body) body = ctx.parseBody(opts.body);
198
202
  if (ctx.verbose) process.stderr.write(`PUT /api/dam/assets/${code}/variants/${id}
199
203
  `);
200
204
  const result = await client.put(`/api/dam/assets/${code}/variants/${id}`, body);
201
205
  ctx.output(result);
202
- });
203
- parent.command("delete-variant <code> <id>").description("Destroys a variant for an existing asset").action(async (code, id) => {
206
+ }), (opts) => opts.bodyFile ? [{
207
+ kind: "file",
208
+ path: String(opts.bodyFile)
209
+ }] : []);
210
+ declareInputs(parent.command("delete-variant <code> <id>").description("Destroys a variant for an existing asset").action(async (code, id) => {
204
211
  const client = await ctx.getClient();
205
212
  if (ctx.verbose) process.stderr.write(`DELETE /api/dam/assets/${code}/variants/${id}
206
213
  `);
207
214
  const result = await client.delete(`/api/dam/assets/${code}/variants/${id}`);
208
215
  ctx.output(result);
209
- });
210
- parent.command("discard-variant <asset-code> <id>").description("Discards a variant for an existing asset (soft delete)").action(async (assetCode, id) => {
216
+ }), () => []);
217
+ declareInputs(parent.command("discard-variant <asset-code> <id>").description("Discards a variant for an existing asset (soft delete)").action(async (assetCode, id) => {
211
218
  const client = await ctx.getClient();
212
219
  if (ctx.verbose) process.stderr.write(`PATCH /api/dam/assets/${assetCode}/variants/${id}/discard
213
220
  `);
214
221
  const result = await client.patch(`/api/dam/assets/${assetCode}/variants/${id}/discard`);
215
222
  ctx.output(result);
216
- });
223
+ }), () => []);
217
224
  }
218
225
  //#endregion
219
226
  //#region src/generated/index.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-app/fluid-cli-assets",
3
- "version": "0.1.337",
3
+ "version": "0.1.338",
4
4
  "description": "Fluid CLI commands for digital asset management (DAM)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.mjs",
@@ -17,7 +17,7 @@
17
17
  "access": "public"
18
18
  },
19
19
  "dependencies": {
20
- "@fluid-app/fluid-cli": "0.1.349",
20
+ "@fluid-app/fluid-cli": "0.1.350",
21
21
  "commander": "^12.0.0"
22
22
  },
23
23
  "devDependencies": {
@@ -1,10 +1,10 @@
1
1
  // primary.ts — AUTO-GENERATED, DO NOT EDIT
2
2
  import { Command } from "commander";
3
- import type { CommandContext } from "@fluid-app/fluid-cli";
3
+ import { declareInputs, type CommandContext } from "@fluid-app/fluid-cli";
4
4
 
5
5
  export function registerPrimary(parent: Command, ctx: CommandContext): void {
6
6
 
7
- parent
7
+ declareInputs(parent
8
8
  .command("get-asset-paths <code>")
9
9
  .description("Lists asset paths for an existing asset")
10
10
  .action(async (code) => {
@@ -12,9 +12,9 @@ export function registerPrimary(parent: Command, ctx: CommandContext): void {
12
12
  if (ctx.verbose) process.stderr.write("GET " + `/api/dam/assets/${code}/asset_paths` + "\n");
13
13
  const result = await client.get(`/api/dam/assets/${code}/asset_paths`);
14
14
  ctx.output(result);
15
- });
15
+ }), () => []);
16
16
 
17
- parent
17
+ declareInputs(parent
18
18
  .command("create-asset-paths <code>")
19
19
  .description("Creates asset paths for an existing asset")
20
20
  .option("--body <json>", "Request body as JSON string")
@@ -23,17 +23,16 @@ export function registerPrimary(parent: Command, ctx: CommandContext): void {
23
23
  const client = await ctx.getClient();
24
24
  let body: unknown;
25
25
  if (opts.bodyFile) {
26
- const { readFileSync } = await import("fs");
27
- body = ctx.parseBody(readFileSync(opts.bodyFile, "utf-8"));
26
+ body = ctx.parseBody(ctx.inputs.readFile(opts.bodyFile, "utf-8"));
28
27
  } else if (opts.body) {
29
28
  body = ctx.parseBody(opts.body);
30
29
  }
31
30
  if (ctx.verbose) process.stderr.write("POST " + `/api/dam/assets/${code}/asset_paths` + "\n");
32
31
  const result = await client.post(`/api/dam/assets/${code}/asset_paths`, body);
33
32
  ctx.output(result);
34
- });
33
+ }), (opts) => (opts.bodyFile ? [{ kind: "file", path: String(opts.bodyFile) }] : []));
35
34
 
36
- parent
35
+ declareInputs(parent
37
36
  .command("delete-asset-path <code> <id>")
38
37
  .description("Destroys an asset path")
39
38
  .action(async (code, id) => {
@@ -41,9 +40,9 @@ export function registerPrimary(parent: Command, ctx: CommandContext): void {
41
40
  if (ctx.verbose) process.stderr.write("DELETE " + `/api/dam/assets/${code}/asset_paths/${id}` + "\n");
42
41
  const result = await client.delete(`/api/dam/assets/${code}/asset_paths/${id}`);
43
42
  ctx.output(result);
44
- });
43
+ }), () => []);
45
44
 
46
- parent
45
+ declareInputs(parent
47
46
  .command("create-backfill-imagekit")
48
47
  .description("Creates a DAM asset from ImageKit upload metadata")
49
48
  .option("--body <json>", "Request body as JSON string")
@@ -52,17 +51,16 @@ export function registerPrimary(parent: Command, ctx: CommandContext): void {
52
51
  const client = await ctx.getClient();
53
52
  let body: unknown;
54
53
  if (opts.bodyFile) {
55
- const { readFileSync } = await import("fs");
56
- body = ctx.parseBody(readFileSync(opts.bodyFile, "utf-8"));
54
+ body = ctx.parseBody(ctx.inputs.readFile(opts.bodyFile, "utf-8"));
57
55
  } else if (opts.body) {
58
56
  body = ctx.parseBody(opts.body);
59
57
  }
60
58
  if (ctx.verbose) process.stderr.write("POST " + `/api/dam/assets/backfill_imagekit` + "\n");
61
59
  const result = await client.post(`/api/dam/assets/backfill_imagekit`, body);
62
60
  ctx.output(result);
63
- });
61
+ }), (opts) => (opts.bodyFile ? [{ kind: "file", path: String(opts.bodyFile) }] : []));
64
62
 
65
- parent
63
+ declareInputs(parent
66
64
  .command("create-asset-invalid-mixed-payload")
67
65
  .description("Errors when multiple asset types are provided")
68
66
  .option("--body <json>", "Request body as JSON string")
@@ -71,17 +69,16 @@ export function registerPrimary(parent: Command, ctx: CommandContext): void {
71
69
  const client = await ctx.getClient();
72
70
  let body: unknown;
73
71
  if (opts.bodyFile) {
74
- const { readFileSync } = await import("fs");
75
- body = ctx.parseBody(readFileSync(opts.bodyFile, "utf-8"));
72
+ body = ctx.parseBody(ctx.inputs.readFile(opts.bodyFile, "utf-8"));
76
73
  } else if (opts.body) {
77
74
  body = ctx.parseBody(opts.body);
78
75
  }
79
76
  if (ctx.verbose) process.stderr.write("POST " + `/api/dam/assets` + "\n");
80
77
  const result = await client.post(`/api/dam/assets`, body);
81
78
  ctx.output(result);
82
- });
79
+ }), (opts) => (opts.bodyFile ? [{ kind: "file", path: String(opts.bodyFile) }] : []));
83
80
 
84
- parent
81
+ declareInputs(parent
85
82
  .command("get-asset <code>")
86
83
  .description("Retrieves an asset by code")
87
84
  .action(async (code) => {
@@ -89,9 +86,9 @@ export function registerPrimary(parent: Command, ctx: CommandContext): void {
89
86
  if (ctx.verbose) process.stderr.write("GET " + `/api/dam/assets/${code}` + "\n");
90
87
  const result = await client.get(`/api/dam/assets/${code}`);
91
88
  ctx.output(result);
92
- });
89
+ }), () => []);
93
90
 
94
- parent
91
+ declareInputs(parent
95
92
  .command("update-asset <code>")
96
93
  .description("Updates an existing asset")
97
94
  .option("--body <json>", "Request body as JSON string")
@@ -100,17 +97,16 @@ export function registerPrimary(parent: Command, ctx: CommandContext): void {
100
97
  const client = await ctx.getClient();
101
98
  let body: unknown;
102
99
  if (opts.bodyFile) {
103
- const { readFileSync } = await import("fs");
104
- body = ctx.parseBody(readFileSync(opts.bodyFile, "utf-8"));
100
+ body = ctx.parseBody(ctx.inputs.readFile(opts.bodyFile, "utf-8"));
105
101
  } else if (opts.body) {
106
102
  body = ctx.parseBody(opts.body);
107
103
  }
108
104
  if (ctx.verbose) process.stderr.write("PUT " + `/api/dam/assets/${code}` + "\n");
109
105
  const result = await client.put(`/api/dam/assets/${code}`, body);
110
106
  ctx.output(result);
111
- });
107
+ }), (opts) => (opts.bodyFile ? [{ kind: "file", path: String(opts.bodyFile) }] : []));
112
108
 
113
- parent
109
+ declareInputs(parent
114
110
  .command("delete-asset <code>")
115
111
  .description("Deletes an asset")
116
112
  .action(async (code) => {
@@ -118,9 +114,9 @@ export function registerPrimary(parent: Command, ctx: CommandContext): void {
118
114
  if (ctx.verbose) process.stderr.write("DELETE " + `/api/dam/assets/${code}` + "\n");
119
115
  const result = await client.delete(`/api/dam/assets/${code}`);
120
116
  ctx.output(result);
121
- });
117
+ }), () => []);
122
118
 
123
- parent
119
+ declareInputs(parent
124
120
  .command("discard-asset <code>")
125
121
  .description("Discard an asset (soft delete)")
126
122
  .action(async (code) => {
@@ -128,9 +124,9 @@ export function registerPrimary(parent: Command, ctx: CommandContext): void {
128
124
  if (ctx.verbose) process.stderr.write("PATCH " + `/api/dam/assets/${code}/discard` + "\n");
129
125
  const result = await client.patch(`/api/dam/assets/${code}/discard`);
130
126
  ctx.output(result);
131
- });
127
+ }), () => []);
132
128
 
133
- parent
129
+ declareInputs(parent
134
130
  .command("create-imagekit-auth")
135
131
  .description("Creates ImageKit authentication credentials for large file uploads")
136
132
  .action(async () => {
@@ -138,9 +134,9 @@ export function registerPrimary(parent: Command, ctx: CommandContext): void {
138
134
  if (ctx.verbose) process.stderr.write("POST " + `/api/dam/assets/imagekit_auth` + "\n");
139
135
  const result = await client.post(`/api/dam/assets/imagekit_auth`);
140
136
  ctx.output(result);
141
- });
137
+ }), () => []);
142
138
 
143
- parent
139
+ declareInputs(parent
144
140
  .command("query-assets")
145
141
  .description("Query DAM assets using tree paths and tags")
146
142
  .option("--body <json>", "Request body as JSON string")
@@ -149,17 +145,16 @@ export function registerPrimary(parent: Command, ctx: CommandContext): void {
149
145
  const client = await ctx.getClient();
150
146
  let body: unknown;
151
147
  if (opts.bodyFile) {
152
- const { readFileSync } = await import("fs");
153
- body = ctx.parseBody(readFileSync(opts.bodyFile, "utf-8"));
148
+ body = ctx.parseBody(ctx.inputs.readFile(opts.bodyFile, "utf-8"));
154
149
  } else if (opts.body) {
155
150
  body = ctx.parseBody(opts.body);
156
151
  }
157
152
  if (ctx.verbose) process.stderr.write("POST " + `/api/dam/query` + "\n");
158
153
  const result = await client.post(`/api/dam/query`, body);
159
154
  ctx.output(result);
160
- });
155
+ }), (opts) => (opts.bodyFile ? [{ kind: "file", path: String(opts.bodyFile) }] : []));
161
156
 
162
- parent
157
+ declareInputs(parent
163
158
  .command("list-variants <code>")
164
159
  .description("Returns all variants for an existing asset")
165
160
  .action(async (code) => {
@@ -167,9 +162,9 @@ export function registerPrimary(parent: Command, ctx: CommandContext): void {
167
162
  if (ctx.verbose) process.stderr.write("GET " + `/api/dam/assets/${code}/variants` + "\n");
168
163
  const result = await client.get(`/api/dam/assets/${code}/variants`);
169
164
  ctx.output(result);
170
- });
165
+ }), () => []);
171
166
 
172
- parent
167
+ declareInputs(parent
173
168
  .command("create-variants <code>")
174
169
  .description("Creates variants for an existing asset")
175
170
  .option("--body <json>", "Request body as JSON string")
@@ -178,17 +173,16 @@ export function registerPrimary(parent: Command, ctx: CommandContext): void {
178
173
  const client = await ctx.getClient();
179
174
  let body: unknown;
180
175
  if (opts.bodyFile) {
181
- const { readFileSync } = await import("fs");
182
- body = ctx.parseBody(readFileSync(opts.bodyFile, "utf-8"));
176
+ body = ctx.parseBody(ctx.inputs.readFile(opts.bodyFile, "utf-8"));
183
177
  } else if (opts.body) {
184
178
  body = ctx.parseBody(opts.body);
185
179
  }
186
180
  if (ctx.verbose) process.stderr.write("POST " + `/api/dam/assets/${code}/variants` + "\n");
187
181
  const result = await client.post(`/api/dam/assets/${code}/variants`, body);
188
182
  ctx.output(result);
189
- });
183
+ }), (opts) => (opts.bodyFile ? [{ kind: "file", path: String(opts.bodyFile) }] : []));
190
184
 
191
- parent
185
+ declareInputs(parent
192
186
  .command("get-variant <code> <id>")
193
187
  .description("Returns a specific variant for an existing asset")
194
188
  .action(async (code, id) => {
@@ -196,9 +190,9 @@ export function registerPrimary(parent: Command, ctx: CommandContext): void {
196
190
  if (ctx.verbose) process.stderr.write("GET " + `/api/dam/assets/${code}/variants/${id}` + "\n");
197
191
  const result = await client.get(`/api/dam/assets/${code}/variants/${id}`);
198
192
  ctx.output(result);
199
- });
193
+ }), () => []);
200
194
 
201
- parent
195
+ declareInputs(parent
202
196
  .command("update-variant <code> <id>")
203
197
  .description("Updates tags for a specific variant")
204
198
  .option("--body <json>", "Request body as JSON string")
@@ -207,17 +201,16 @@ export function registerPrimary(parent: Command, ctx: CommandContext): void {
207
201
  const client = await ctx.getClient();
208
202
  let body: unknown;
209
203
  if (opts.bodyFile) {
210
- const { readFileSync } = await import("fs");
211
- body = ctx.parseBody(readFileSync(opts.bodyFile, "utf-8"));
204
+ body = ctx.parseBody(ctx.inputs.readFile(opts.bodyFile, "utf-8"));
212
205
  } else if (opts.body) {
213
206
  body = ctx.parseBody(opts.body);
214
207
  }
215
208
  if (ctx.verbose) process.stderr.write("PUT " + `/api/dam/assets/${code}/variants/${id}` + "\n");
216
209
  const result = await client.put(`/api/dam/assets/${code}/variants/${id}`, body);
217
210
  ctx.output(result);
218
- });
211
+ }), (opts) => (opts.bodyFile ? [{ kind: "file", path: String(opts.bodyFile) }] : []));
219
212
 
220
- parent
213
+ declareInputs(parent
221
214
  .command("delete-variant <code> <id>")
222
215
  .description("Destroys a variant for an existing asset")
223
216
  .action(async (code, id) => {
@@ -225,9 +218,9 @@ export function registerPrimary(parent: Command, ctx: CommandContext): void {
225
218
  if (ctx.verbose) process.stderr.write("DELETE " + `/api/dam/assets/${code}/variants/${id}` + "\n");
226
219
  const result = await client.delete(`/api/dam/assets/${code}/variants/${id}`);
227
220
  ctx.output(result);
228
- });
221
+ }), () => []);
229
222
 
230
- parent
223
+ declareInputs(parent
231
224
  .command("discard-variant <asset-code> <id>")
232
225
  .description("Discards a variant for an existing asset (soft delete)")
233
226
  .action(async (assetCode, id) => {
@@ -235,6 +228,6 @@ export function registerPrimary(parent: Command, ctx: CommandContext): void {
235
228
  if (ctx.verbose) process.stderr.write("PATCH " + `/api/dam/assets/${assetCode}/variants/${id}/discard` + "\n");
236
229
  const result = await client.patch(`/api/dam/assets/${assetCode}/variants/${id}/discard`);
237
230
  ctx.output(result);
238
- });
231
+ }), () => []);
239
232
 
240
233
  }