@fluid-app/fluid-cli-assets 0.1.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/.turbo/turbo-build.log +18 -0
- package/dist/index.d.mts +7 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +173 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +42 -0
- package/scripts/generate.ts +12 -0
- package/src/generated/index.ts +12 -0
- package/src/generated/primary.ts +297 -0
- package/src/index.ts +20 -0
- package/tsconfig.json +10 -0
- package/tsdown.config.ts +12 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
|
|
2
|
+
> @fluid-app/fluid-cli-assets@0.1.0 build /home/runner/_work/fluid-mono/fluid-mono/packages/cli/assets
|
|
3
|
+
> tsdown
|
|
4
|
+
|
|
5
|
+
[34mℹ[39m tsdown [2mv0.21.0[22m powered by rolldown [2mv1.0.0-rc.7[22m
|
|
6
|
+
[34mℹ[39m config file: [4m/home/runner/_work/fluid-mono/fluid-mono/packages/cli/assets/tsdown.config.ts[24m
|
|
7
|
+
[34mℹ[39m entry: [34msrc/index.ts[39m
|
|
8
|
+
[34mℹ[39m target: [34mnode18[39m
|
|
9
|
+
[34mℹ[39m tsconfig: [34mtsconfig.json[39m
|
|
10
|
+
[34mℹ[39m Build start
|
|
11
|
+
[34mℹ[39m [2mdist/[22m[1mindex.mjs[22m [2m 8.76 kB[22m [2m│ gzip: 1.28 kB[22m
|
|
12
|
+
[33m[PLUGIN_TIMINGS] Warning:[0m Your build spent significant time in plugin `rolldown-plugin-dts:generate`. See https://rolldown.rs/options/checks#plugintimings for more details.
|
|
13
|
+
|
|
14
|
+
[34mℹ[39m [2mdist/[22mindex.mjs.map [2m17.08 kB[22m [2m│ gzip: 2.44 kB[22m
|
|
15
|
+
[34mℹ[39m [2mdist/[22mindex.d.mts.map [2m 0.11 kB[22m [2m│ gzip: 0.12 kB[22m
|
|
16
|
+
[34mℹ[39m [2mdist/[22m[32m[1mindex.d.mts[22m[39m [2m 0.19 kB[22m [2m│ gzip: 0.16 kB[22m
|
|
17
|
+
[34mℹ[39m 4 files, total: 26.15 kB
|
|
18
|
+
[32m✔[39m Build complete in [32m3336ms[39m
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;cAKM,MAAA,EAAQ,WAAA"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { createDomainCommand } from "@fluid-app/fluid-cli";
|
|
2
|
+
import "commander";
|
|
3
|
+
//#region src/generated/primary.ts
|
|
4
|
+
function registerPrimary(parent, ctx) {
|
|
5
|
+
parent.command("get-asset-paths <code>").description("Lists asset paths for an existing asset").action(async (code) => {
|
|
6
|
+
const client = await ctx.getClient();
|
|
7
|
+
if (ctx.verbose) process.stderr.write(`GET /api/dam/assets/${code}/asset_paths
|
|
8
|
+
`);
|
|
9
|
+
const result = await client.get(`/api/dam/assets/${code}/asset_paths`);
|
|
10
|
+
ctx.output(result);
|
|
11
|
+
});
|
|
12
|
+
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) => {
|
|
13
|
+
const client = await ctx.getClient();
|
|
14
|
+
let body;
|
|
15
|
+
if (opts.bodyFile) {
|
|
16
|
+
const { readFileSync } = await import("fs");
|
|
17
|
+
body = ctx.parseBody(readFileSync(opts.bodyFile, "utf-8"));
|
|
18
|
+
} else if (opts.body) body = ctx.parseBody(opts.body);
|
|
19
|
+
if (ctx.verbose) process.stderr.write(`POST /api/dam/assets/${code}/asset_paths
|
|
20
|
+
`);
|
|
21
|
+
const result = await client.post(`/api/dam/assets/${code}/asset_paths`, body);
|
|
22
|
+
ctx.output(result);
|
|
23
|
+
});
|
|
24
|
+
parent.command("delete-asset-path <code> <id>").description("Destroys an asset path").action(async (code, id) => {
|
|
25
|
+
const client = await ctx.getClient();
|
|
26
|
+
if (ctx.verbose) process.stderr.write(`DELETE /api/dam/assets/${code}/asset_paths/${id}
|
|
27
|
+
`);
|
|
28
|
+
const result = await client.delete(`/api/dam/assets/${code}/asset_paths/${id}`);
|
|
29
|
+
ctx.output(result);
|
|
30
|
+
});
|
|
31
|
+
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) => {
|
|
32
|
+
const client = await ctx.getClient();
|
|
33
|
+
let body;
|
|
34
|
+
if (opts.bodyFile) {
|
|
35
|
+
const { readFileSync } = await import("fs");
|
|
36
|
+
body = ctx.parseBody(readFileSync(opts.bodyFile, "utf-8"));
|
|
37
|
+
} else if (opts.body) body = ctx.parseBody(opts.body);
|
|
38
|
+
if (ctx.verbose) process.stderr.write("POST /api/dam/assets/backfill_imagekit\n");
|
|
39
|
+
const result = await client.post(`/api/dam/assets/backfill_imagekit`, body);
|
|
40
|
+
ctx.output(result);
|
|
41
|
+
});
|
|
42
|
+
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) => {
|
|
43
|
+
const client = await ctx.getClient();
|
|
44
|
+
let body;
|
|
45
|
+
if (opts.bodyFile) {
|
|
46
|
+
const { readFileSync } = await import("fs");
|
|
47
|
+
body = ctx.parseBody(readFileSync(opts.bodyFile, "utf-8"));
|
|
48
|
+
} else if (opts.body) body = ctx.parseBody(opts.body);
|
|
49
|
+
if (ctx.verbose) process.stderr.write("POST /api/dam/assets\n");
|
|
50
|
+
const result = await client.post(`/api/dam/assets`, body);
|
|
51
|
+
ctx.output(result);
|
|
52
|
+
});
|
|
53
|
+
parent.command("get-asset <code>").description("Retrieves an asset by code").action(async (code) => {
|
|
54
|
+
const client = await ctx.getClient();
|
|
55
|
+
if (ctx.verbose) process.stderr.write(`GET /api/dam/assets/${code}
|
|
56
|
+
`);
|
|
57
|
+
const result = await client.get(`/api/dam/assets/${code}`);
|
|
58
|
+
ctx.output(result);
|
|
59
|
+
});
|
|
60
|
+
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) => {
|
|
61
|
+
const client = await ctx.getClient();
|
|
62
|
+
let body;
|
|
63
|
+
if (opts.bodyFile) {
|
|
64
|
+
const { readFileSync } = await import("fs");
|
|
65
|
+
body = ctx.parseBody(readFileSync(opts.bodyFile, "utf-8"));
|
|
66
|
+
} else if (opts.body) body = ctx.parseBody(opts.body);
|
|
67
|
+
if (ctx.verbose) process.stderr.write(`PUT /api/dam/assets/${code}
|
|
68
|
+
`);
|
|
69
|
+
const result = await client.put(`/api/dam/assets/${code}`, body);
|
|
70
|
+
ctx.output(result);
|
|
71
|
+
});
|
|
72
|
+
parent.command("delete-asset <code>").description("Deletes an asset").action(async (code) => {
|
|
73
|
+
const client = await ctx.getClient();
|
|
74
|
+
if (ctx.verbose) process.stderr.write(`DELETE /api/dam/assets/${code}
|
|
75
|
+
`);
|
|
76
|
+
const result = await client.delete(`/api/dam/assets/${code}`);
|
|
77
|
+
ctx.output(result);
|
|
78
|
+
});
|
|
79
|
+
parent.command("discard-asset <code>").description("Discard an asset (soft delete)").action(async (code) => {
|
|
80
|
+
const client = await ctx.getClient();
|
|
81
|
+
if (ctx.verbose) process.stderr.write(`PATCH /api/dam/assets/${code}/discard
|
|
82
|
+
`);
|
|
83
|
+
const result = await client.patch(`/api/dam/assets/${code}/discard`);
|
|
84
|
+
ctx.output(result);
|
|
85
|
+
});
|
|
86
|
+
parent.command("create-imagekit-auth").description("Creates ImageKit authentication credentials for large file uploads").action(async () => {
|
|
87
|
+
const client = await ctx.getClient();
|
|
88
|
+
if (ctx.verbose) process.stderr.write("POST /api/dam/assets/imagekit_auth\n");
|
|
89
|
+
const result = await client.post(`/api/dam/assets/imagekit_auth`);
|
|
90
|
+
ctx.output(result);
|
|
91
|
+
});
|
|
92
|
+
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) => {
|
|
93
|
+
const client = await ctx.getClient();
|
|
94
|
+
let body;
|
|
95
|
+
if (opts.bodyFile) {
|
|
96
|
+
const { readFileSync } = await import("fs");
|
|
97
|
+
body = ctx.parseBody(readFileSync(opts.bodyFile, "utf-8"));
|
|
98
|
+
} else if (opts.body) body = ctx.parseBody(opts.body);
|
|
99
|
+
if (ctx.verbose) process.stderr.write("POST /api/dam/query\n");
|
|
100
|
+
const result = await client.post(`/api/dam/query`, body);
|
|
101
|
+
ctx.output(result);
|
|
102
|
+
});
|
|
103
|
+
parent.command("list-variants <code>").description("Returns all variants for an existing asset").action(async (code) => {
|
|
104
|
+
const client = await ctx.getClient();
|
|
105
|
+
if (ctx.verbose) process.stderr.write(`GET /api/dam/assets/${code}/variants
|
|
106
|
+
`);
|
|
107
|
+
const result = await client.get(`/api/dam/assets/${code}/variants`);
|
|
108
|
+
ctx.output(result);
|
|
109
|
+
});
|
|
110
|
+
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) => {
|
|
111
|
+
const client = await ctx.getClient();
|
|
112
|
+
let body;
|
|
113
|
+
if (opts.bodyFile) {
|
|
114
|
+
const { readFileSync } = await import("fs");
|
|
115
|
+
body = ctx.parseBody(readFileSync(opts.bodyFile, "utf-8"));
|
|
116
|
+
} else if (opts.body) body = ctx.parseBody(opts.body);
|
|
117
|
+
if (ctx.verbose) process.stderr.write(`POST /api/dam/assets/${code}/variants
|
|
118
|
+
`);
|
|
119
|
+
const result = await client.post(`/api/dam/assets/${code}/variants`, body);
|
|
120
|
+
ctx.output(result);
|
|
121
|
+
});
|
|
122
|
+
parent.command("get-variant <code> <id>").description("Returns a specific variant for an existing asset").action(async (code, id) => {
|
|
123
|
+
const client = await ctx.getClient();
|
|
124
|
+
if (ctx.verbose) process.stderr.write(`GET /api/dam/assets/${code}/variants/${id}
|
|
125
|
+
`);
|
|
126
|
+
const result = await client.get(`/api/dam/assets/${code}/variants/${id}`);
|
|
127
|
+
ctx.output(result);
|
|
128
|
+
});
|
|
129
|
+
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) => {
|
|
130
|
+
const client = await ctx.getClient();
|
|
131
|
+
let body;
|
|
132
|
+
if (opts.bodyFile) {
|
|
133
|
+
const { readFileSync } = await import("fs");
|
|
134
|
+
body = ctx.parseBody(readFileSync(opts.bodyFile, "utf-8"));
|
|
135
|
+
} else if (opts.body) body = ctx.parseBody(opts.body);
|
|
136
|
+
if (ctx.verbose) process.stderr.write(`PUT /api/dam/assets/${code}/variants/${id}
|
|
137
|
+
`);
|
|
138
|
+
const result = await client.put(`/api/dam/assets/${code}/variants/${id}`, body);
|
|
139
|
+
ctx.output(result);
|
|
140
|
+
});
|
|
141
|
+
parent.command("delete-variant <code> <id>").description("Destroys a variant for an existing asset").action(async (code, id) => {
|
|
142
|
+
const client = await ctx.getClient();
|
|
143
|
+
if (ctx.verbose) process.stderr.write(`DELETE /api/dam/assets/${code}/variants/${id}
|
|
144
|
+
`);
|
|
145
|
+
const result = await client.delete(`/api/dam/assets/${code}/variants/${id}`);
|
|
146
|
+
ctx.output(result);
|
|
147
|
+
});
|
|
148
|
+
parent.command("discard-variant <asset-code> <id>").description("Discards a variant for an existing asset (soft delete)").action(async (assetCode, id) => {
|
|
149
|
+
const client = await ctx.getClient();
|
|
150
|
+
if (ctx.verbose) process.stderr.write(`PATCH /api/dam/assets/${assetCode}/variants/${id}/discard
|
|
151
|
+
`);
|
|
152
|
+
const result = await client.patch(`/api/dam/assets/${assetCode}/variants/${id}/discard`);
|
|
153
|
+
ctx.output(result);
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
//#endregion
|
|
157
|
+
//#region src/generated/index.ts
|
|
158
|
+
function registerAllCommands(parent, ctx) {
|
|
159
|
+
registerPrimary(parent, ctx);
|
|
160
|
+
}
|
|
161
|
+
//#endregion
|
|
162
|
+
//#region src/index.ts
|
|
163
|
+
const plugin = {
|
|
164
|
+
name: "@fluid-app/fluid-cli-assets",
|
|
165
|
+
version: "0.1.0",
|
|
166
|
+
register(ctx) {
|
|
167
|
+
ctx.program.addCommand(createDomainCommand("assets", "Manage Fluid digital assets (DAM)", registerAllCommands));
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
//#endregion
|
|
171
|
+
export { plugin as default };
|
|
172
|
+
|
|
173
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/generated/primary.ts","../src/generated/index.ts","../src/index.ts"],"sourcesContent":["// primary.ts — AUTO-GENERATED, DO NOT EDIT\nimport { Command } from \"commander\";\nimport type { CommandContext } from \"@fluid-app/fluid-cli\";\n\nexport function registerPrimary(parent: Command, ctx: CommandContext): void {\n parent\n .command(\"get-asset-paths <code>\")\n .description(\"Lists asset paths for an existing asset\")\n .action(async (code) => {\n const client = await ctx.getClient();\n if (ctx.verbose)\n process.stderr.write(\n \"GET \" + `/api/dam/assets/${code}/asset_paths` + \"\\n\",\n );\n const result = await client.get(`/api/dam/assets/${code}/asset_paths`);\n ctx.output(result);\n });\n\n parent\n .command(\"create-asset-paths <code>\")\n .description(\"Creates asset paths for an existing asset\")\n .option(\"--body <json>\", \"Request body as JSON string\")\n .option(\"--body-file <path>\", \"Read request body from file\")\n .action(async (code, opts) => {\n const client = await ctx.getClient();\n let body: unknown;\n if (opts.bodyFile) {\n const { readFileSync } = await import(\"fs\");\n body = ctx.parseBody(readFileSync(opts.bodyFile, \"utf-8\"));\n } else if (opts.body) {\n body = ctx.parseBody(opts.body);\n }\n if (ctx.verbose)\n process.stderr.write(\n \"POST \" + `/api/dam/assets/${code}/asset_paths` + \"\\n\",\n );\n const result = await client.post(\n `/api/dam/assets/${code}/asset_paths`,\n body,\n );\n ctx.output(result);\n });\n\n parent\n .command(\"delete-asset-path <code> <id>\")\n .description(\"Destroys an asset path\")\n .action(async (code, id) => {\n const client = await ctx.getClient();\n if (ctx.verbose)\n process.stderr.write(\n \"DELETE \" + `/api/dam/assets/${code}/asset_paths/${id}` + \"\\n\",\n );\n const result = await client.delete(\n `/api/dam/assets/${code}/asset_paths/${id}`,\n );\n ctx.output(result);\n });\n\n parent\n .command(\"create-backfill-imagekit\")\n .description(\"Creates a DAM asset from ImageKit upload metadata\")\n .option(\"--body <json>\", \"Request body as JSON string\")\n .option(\"--body-file <path>\", \"Read request body from file\")\n .action(async (opts) => {\n const client = await ctx.getClient();\n let body: unknown;\n if (opts.bodyFile) {\n const { readFileSync } = await import(\"fs\");\n body = ctx.parseBody(readFileSync(opts.bodyFile, \"utf-8\"));\n } else if (opts.body) {\n body = ctx.parseBody(opts.body);\n }\n if (ctx.verbose)\n process.stderr.write(\n \"POST \" + `/api/dam/assets/backfill_imagekit` + \"\\n\",\n );\n const result = await client.post(\n `/api/dam/assets/backfill_imagekit`,\n body,\n );\n ctx.output(result);\n });\n\n parent\n .command(\"create-asset-invalid-mixed-payload\")\n .description(\"Errors when multiple asset types are provided\")\n .option(\"--body <json>\", \"Request body as JSON string\")\n .option(\"--body-file <path>\", \"Read request body from file\")\n .action(async (opts) => {\n const client = await ctx.getClient();\n let body: unknown;\n if (opts.bodyFile) {\n const { readFileSync } = await import(\"fs\");\n body = ctx.parseBody(readFileSync(opts.bodyFile, \"utf-8\"));\n } else if (opts.body) {\n body = ctx.parseBody(opts.body);\n }\n if (ctx.verbose) process.stderr.write(\"POST \" + `/api/dam/assets` + \"\\n\");\n const result = await client.post(`/api/dam/assets`, body);\n ctx.output(result);\n });\n\n parent\n .command(\"get-asset <code>\")\n .description(\"Retrieves an asset by code\")\n .action(async (code) => {\n const client = await ctx.getClient();\n if (ctx.verbose)\n process.stderr.write(\"GET \" + `/api/dam/assets/${code}` + \"\\n\");\n const result = await client.get(`/api/dam/assets/${code}`);\n ctx.output(result);\n });\n\n parent\n .command(\"update-asset <code>\")\n .description(\"Updates an existing asset\")\n .option(\"--body <json>\", \"Request body as JSON string\")\n .option(\"--body-file <path>\", \"Read request body from file\")\n .action(async (code, opts) => {\n const client = await ctx.getClient();\n let body: unknown;\n if (opts.bodyFile) {\n const { readFileSync } = await import(\"fs\");\n body = ctx.parseBody(readFileSync(opts.bodyFile, \"utf-8\"));\n } else if (opts.body) {\n body = ctx.parseBody(opts.body);\n }\n if (ctx.verbose)\n process.stderr.write(\"PUT \" + `/api/dam/assets/${code}` + \"\\n\");\n const result = await client.put(`/api/dam/assets/${code}`, body);\n ctx.output(result);\n });\n\n parent\n .command(\"delete-asset <code>\")\n .description(\"Deletes an asset\")\n .action(async (code) => {\n const client = await ctx.getClient();\n if (ctx.verbose)\n process.stderr.write(\"DELETE \" + `/api/dam/assets/${code}` + \"\\n\");\n const result = await client.delete(`/api/dam/assets/${code}`);\n ctx.output(result);\n });\n\n parent\n .command(\"discard-asset <code>\")\n .description(\"Discard an asset (soft delete)\")\n .action(async (code) => {\n const client = await ctx.getClient();\n if (ctx.verbose)\n process.stderr.write(\n \"PATCH \" + `/api/dam/assets/${code}/discard` + \"\\n\",\n );\n const result = await client.patch(`/api/dam/assets/${code}/discard`);\n ctx.output(result);\n });\n\n parent\n .command(\"create-imagekit-auth\")\n .description(\n \"Creates ImageKit authentication credentials for large file uploads\",\n )\n .action(async () => {\n const client = await ctx.getClient();\n if (ctx.verbose)\n process.stderr.write(\"POST \" + `/api/dam/assets/imagekit_auth` + \"\\n\");\n const result = await client.post(`/api/dam/assets/imagekit_auth`);\n ctx.output(result);\n });\n\n parent\n .command(\"query-assets\")\n .description(\"Query DAM assets using tree paths and tags\")\n .option(\"--body <json>\", \"Request body as JSON string\")\n .option(\"--body-file <path>\", \"Read request body from file\")\n .action(async (opts) => {\n const client = await ctx.getClient();\n let body: unknown;\n if (opts.bodyFile) {\n const { readFileSync } = await import(\"fs\");\n body = ctx.parseBody(readFileSync(opts.bodyFile, \"utf-8\"));\n } else if (opts.body) {\n body = ctx.parseBody(opts.body);\n }\n if (ctx.verbose) process.stderr.write(\"POST \" + `/api/dam/query` + \"\\n\");\n const result = await client.post(`/api/dam/query`, body);\n ctx.output(result);\n });\n\n parent\n .command(\"list-variants <code>\")\n .description(\"Returns all variants for an existing asset\")\n .action(async (code) => {\n const client = await ctx.getClient();\n if (ctx.verbose)\n process.stderr.write(\n \"GET \" + `/api/dam/assets/${code}/variants` + \"\\n\",\n );\n const result = await client.get(`/api/dam/assets/${code}/variants`);\n ctx.output(result);\n });\n\n parent\n .command(\"create-variants <code>\")\n .description(\"Creates variants for an existing asset\")\n .option(\"--body <json>\", \"Request body as JSON string\")\n .option(\"--body-file <path>\", \"Read request body from file\")\n .action(async (code, opts) => {\n const client = await ctx.getClient();\n let body: unknown;\n if (opts.bodyFile) {\n const { readFileSync } = await import(\"fs\");\n body = ctx.parseBody(readFileSync(opts.bodyFile, \"utf-8\"));\n } else if (opts.body) {\n body = ctx.parseBody(opts.body);\n }\n if (ctx.verbose)\n process.stderr.write(\n \"POST \" + `/api/dam/assets/${code}/variants` + \"\\n\",\n );\n const result = await client.post(\n `/api/dam/assets/${code}/variants`,\n body,\n );\n ctx.output(result);\n });\n\n parent\n .command(\"get-variant <code> <id>\")\n .description(\"Returns a specific variant for an existing asset\")\n .action(async (code, id) => {\n const client = await ctx.getClient();\n if (ctx.verbose)\n process.stderr.write(\n \"GET \" + `/api/dam/assets/${code}/variants/${id}` + \"\\n\",\n );\n const result = await client.get(`/api/dam/assets/${code}/variants/${id}`);\n ctx.output(result);\n });\n\n parent\n .command(\"update-variant <code> <id>\")\n .description(\"Updates tags for a specific variant\")\n .option(\"--body <json>\", \"Request body as JSON string\")\n .option(\"--body-file <path>\", \"Read request body from file\")\n .action(async (code, id, opts) => {\n const client = await ctx.getClient();\n let body: unknown;\n if (opts.bodyFile) {\n const { readFileSync } = await import(\"fs\");\n body = ctx.parseBody(readFileSync(opts.bodyFile, \"utf-8\"));\n } else if (opts.body) {\n body = ctx.parseBody(opts.body);\n }\n if (ctx.verbose)\n process.stderr.write(\n \"PUT \" + `/api/dam/assets/${code}/variants/${id}` + \"\\n\",\n );\n const result = await client.put(\n `/api/dam/assets/${code}/variants/${id}`,\n body,\n );\n ctx.output(result);\n });\n\n parent\n .command(\"delete-variant <code> <id>\")\n .description(\"Destroys a variant for an existing asset\")\n .action(async (code, id) => {\n const client = await ctx.getClient();\n if (ctx.verbose)\n process.stderr.write(\n \"DELETE \" + `/api/dam/assets/${code}/variants/${id}` + \"\\n\",\n );\n const result = await client.delete(\n `/api/dam/assets/${code}/variants/${id}`,\n );\n ctx.output(result);\n });\n\n parent\n .command(\"discard-variant <asset-code> <id>\")\n .description(\"Discards a variant for an existing asset (soft delete)\")\n .action(async (assetCode, id) => {\n const client = await ctx.getClient();\n if (ctx.verbose)\n process.stderr.write(\n \"PATCH \" +\n `/api/dam/assets/${assetCode}/variants/${id}/discard` +\n \"\\n\",\n );\n const result = await client.patch(\n `/api/dam/assets/${assetCode}/variants/${id}/discard`,\n );\n ctx.output(result);\n });\n}\n","// index.ts — AUTO-GENERATED, DO NOT EDIT\nimport { Command } from \"commander\";\nimport type { CommandContext } from \"@fluid-app/fluid-cli\";\n\nimport { registerPrimary } from \"./primary.js\";\n\nexport function registerAllCommands(\n parent: Command,\n ctx: CommandContext,\n): void {\n registerPrimary(parent, ctx);\n}\n","import type { FluidPlugin } from \"@fluid-app/fluid-cli\";\nimport { createDomainCommand } from \"@fluid-app/fluid-cli\";\n\nimport { registerAllCommands } from \"./generated/index.js\";\n\nconst plugin: FluidPlugin = {\n name: \"@fluid-app/fluid-cli-assets\",\n version: \"0.1.0\",\n register(ctx) {\n ctx.program.addCommand(\n createDomainCommand(\n \"assets\",\n \"Manage Fluid digital assets (DAM)\",\n registerAllCommands,\n ),\n );\n },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AClB;;;;ACjSN,SAAgB,oBACd,QACA,KACM;AACN,iBAAgB,QAAQ,IAAI;;;;ACL9B,MAAM,SAAsB;CAC1B,MAAM;CACN,SAAS;CACT,SAAS,KAAK;AACZ,MAAI,QAAQ,WACV,oBACE,UACA,qCACA,oBACD,CACF;;CAEJ"}
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@fluid-app/fluid-cli-assets",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Fluid CLI commands for digital asset management (DAM)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.mjs",
|
|
7
|
+
"types": "./dist/index.d.mts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": {
|
|
11
|
+
"types": "./dist/index.d.mts",
|
|
12
|
+
"default": "./dist/index.mjs"
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public"
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"commander": "^12.0.0",
|
|
21
|
+
"@fluid-app/fluid-cli": "0.1.0"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@types/node": "^24",
|
|
25
|
+
"tsdown": "^0.21.0",
|
|
26
|
+
"tsx": "^4.21.0",
|
|
27
|
+
"typescript": "^5",
|
|
28
|
+
"@fluid-app/api-client-scripts": "0.0.0",
|
|
29
|
+
"@fluid-app/typescript-config": "0.0.0"
|
|
30
|
+
},
|
|
31
|
+
"engines": {
|
|
32
|
+
"node": ">=18.0.0"
|
|
33
|
+
},
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "tsdown",
|
|
36
|
+
"dev": "tsdown --watch",
|
|
37
|
+
"generate": "tsx scripts/generate.ts",
|
|
38
|
+
"lint": "oxlint",
|
|
39
|
+
"lint:fix": "oxlint --fix",
|
|
40
|
+
"typecheck": "tsgo --noEmit"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { resolve } from "path";
|
|
2
|
+
import { generateCLICommands } from "@fluid-app/api-client-scripts";
|
|
3
|
+
|
|
4
|
+
const packageDir = resolve(import.meta.dirname, "..");
|
|
5
|
+
const specPath = resolve(packageDir, "..", "specs", "swagger.json");
|
|
6
|
+
|
|
7
|
+
await generateCLICommands({
|
|
8
|
+
packageDir,
|
|
9
|
+
specPath,
|
|
10
|
+
contextImportPath: "@fluid-app/fluid-cli",
|
|
11
|
+
primaryTags: ["DAM"],
|
|
12
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// index.ts — AUTO-GENERATED, DO NOT EDIT
|
|
2
|
+
import { Command } from "commander";
|
|
3
|
+
import type { CommandContext } from "@fluid-app/fluid-cli";
|
|
4
|
+
|
|
5
|
+
import { registerPrimary } from "./primary.js";
|
|
6
|
+
|
|
7
|
+
export function registerAllCommands(
|
|
8
|
+
parent: Command,
|
|
9
|
+
ctx: CommandContext,
|
|
10
|
+
): void {
|
|
11
|
+
registerPrimary(parent, ctx);
|
|
12
|
+
}
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
// primary.ts — AUTO-GENERATED, DO NOT EDIT
|
|
2
|
+
import { Command } from "commander";
|
|
3
|
+
import type { CommandContext } from "@fluid-app/fluid-cli";
|
|
4
|
+
|
|
5
|
+
export function registerPrimary(parent: Command, ctx: CommandContext): void {
|
|
6
|
+
parent
|
|
7
|
+
.command("get-asset-paths <code>")
|
|
8
|
+
.description("Lists asset paths for an existing asset")
|
|
9
|
+
.action(async (code) => {
|
|
10
|
+
const client = await ctx.getClient();
|
|
11
|
+
if (ctx.verbose)
|
|
12
|
+
process.stderr.write(
|
|
13
|
+
"GET " + `/api/dam/assets/${code}/asset_paths` + "\n",
|
|
14
|
+
);
|
|
15
|
+
const result = await client.get(`/api/dam/assets/${code}/asset_paths`);
|
|
16
|
+
ctx.output(result);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
parent
|
|
20
|
+
.command("create-asset-paths <code>")
|
|
21
|
+
.description("Creates asset paths for an existing asset")
|
|
22
|
+
.option("--body <json>", "Request body as JSON string")
|
|
23
|
+
.option("--body-file <path>", "Read request body from file")
|
|
24
|
+
.action(async (code, opts) => {
|
|
25
|
+
const client = await ctx.getClient();
|
|
26
|
+
let body: unknown;
|
|
27
|
+
if (opts.bodyFile) {
|
|
28
|
+
const { readFileSync } = await import("fs");
|
|
29
|
+
body = ctx.parseBody(readFileSync(opts.bodyFile, "utf-8"));
|
|
30
|
+
} else if (opts.body) {
|
|
31
|
+
body = ctx.parseBody(opts.body);
|
|
32
|
+
}
|
|
33
|
+
if (ctx.verbose)
|
|
34
|
+
process.stderr.write(
|
|
35
|
+
"POST " + `/api/dam/assets/${code}/asset_paths` + "\n",
|
|
36
|
+
);
|
|
37
|
+
const result = await client.post(
|
|
38
|
+
`/api/dam/assets/${code}/asset_paths`,
|
|
39
|
+
body,
|
|
40
|
+
);
|
|
41
|
+
ctx.output(result);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
parent
|
|
45
|
+
.command("delete-asset-path <code> <id>")
|
|
46
|
+
.description("Destroys an asset path")
|
|
47
|
+
.action(async (code, id) => {
|
|
48
|
+
const client = await ctx.getClient();
|
|
49
|
+
if (ctx.verbose)
|
|
50
|
+
process.stderr.write(
|
|
51
|
+
"DELETE " + `/api/dam/assets/${code}/asset_paths/${id}` + "\n",
|
|
52
|
+
);
|
|
53
|
+
const result = await client.delete(
|
|
54
|
+
`/api/dam/assets/${code}/asset_paths/${id}`,
|
|
55
|
+
);
|
|
56
|
+
ctx.output(result);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
parent
|
|
60
|
+
.command("create-backfill-imagekit")
|
|
61
|
+
.description("Creates a DAM asset from ImageKit upload metadata")
|
|
62
|
+
.option("--body <json>", "Request body as JSON string")
|
|
63
|
+
.option("--body-file <path>", "Read request body from file")
|
|
64
|
+
.action(async (opts) => {
|
|
65
|
+
const client = await ctx.getClient();
|
|
66
|
+
let body: unknown;
|
|
67
|
+
if (opts.bodyFile) {
|
|
68
|
+
const { readFileSync } = await import("fs");
|
|
69
|
+
body = ctx.parseBody(readFileSync(opts.bodyFile, "utf-8"));
|
|
70
|
+
} else if (opts.body) {
|
|
71
|
+
body = ctx.parseBody(opts.body);
|
|
72
|
+
}
|
|
73
|
+
if (ctx.verbose)
|
|
74
|
+
process.stderr.write(
|
|
75
|
+
"POST " + `/api/dam/assets/backfill_imagekit` + "\n",
|
|
76
|
+
);
|
|
77
|
+
const result = await client.post(
|
|
78
|
+
`/api/dam/assets/backfill_imagekit`,
|
|
79
|
+
body,
|
|
80
|
+
);
|
|
81
|
+
ctx.output(result);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
parent
|
|
85
|
+
.command("create-asset-invalid-mixed-payload")
|
|
86
|
+
.description("Errors when multiple asset types are provided")
|
|
87
|
+
.option("--body <json>", "Request body as JSON string")
|
|
88
|
+
.option("--body-file <path>", "Read request body from file")
|
|
89
|
+
.action(async (opts) => {
|
|
90
|
+
const client = await ctx.getClient();
|
|
91
|
+
let body: unknown;
|
|
92
|
+
if (opts.bodyFile) {
|
|
93
|
+
const { readFileSync } = await import("fs");
|
|
94
|
+
body = ctx.parseBody(readFileSync(opts.bodyFile, "utf-8"));
|
|
95
|
+
} else if (opts.body) {
|
|
96
|
+
body = ctx.parseBody(opts.body);
|
|
97
|
+
}
|
|
98
|
+
if (ctx.verbose) process.stderr.write("POST " + `/api/dam/assets` + "\n");
|
|
99
|
+
const result = await client.post(`/api/dam/assets`, body);
|
|
100
|
+
ctx.output(result);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
parent
|
|
104
|
+
.command("get-asset <code>")
|
|
105
|
+
.description("Retrieves an asset by code")
|
|
106
|
+
.action(async (code) => {
|
|
107
|
+
const client = await ctx.getClient();
|
|
108
|
+
if (ctx.verbose)
|
|
109
|
+
process.stderr.write("GET " + `/api/dam/assets/${code}` + "\n");
|
|
110
|
+
const result = await client.get(`/api/dam/assets/${code}`);
|
|
111
|
+
ctx.output(result);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
parent
|
|
115
|
+
.command("update-asset <code>")
|
|
116
|
+
.description("Updates an existing asset")
|
|
117
|
+
.option("--body <json>", "Request body as JSON string")
|
|
118
|
+
.option("--body-file <path>", "Read request body from file")
|
|
119
|
+
.action(async (code, opts) => {
|
|
120
|
+
const client = await ctx.getClient();
|
|
121
|
+
let body: unknown;
|
|
122
|
+
if (opts.bodyFile) {
|
|
123
|
+
const { readFileSync } = await import("fs");
|
|
124
|
+
body = ctx.parseBody(readFileSync(opts.bodyFile, "utf-8"));
|
|
125
|
+
} else if (opts.body) {
|
|
126
|
+
body = ctx.parseBody(opts.body);
|
|
127
|
+
}
|
|
128
|
+
if (ctx.verbose)
|
|
129
|
+
process.stderr.write("PUT " + `/api/dam/assets/${code}` + "\n");
|
|
130
|
+
const result = await client.put(`/api/dam/assets/${code}`, body);
|
|
131
|
+
ctx.output(result);
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
parent
|
|
135
|
+
.command("delete-asset <code>")
|
|
136
|
+
.description("Deletes an asset")
|
|
137
|
+
.action(async (code) => {
|
|
138
|
+
const client = await ctx.getClient();
|
|
139
|
+
if (ctx.verbose)
|
|
140
|
+
process.stderr.write("DELETE " + `/api/dam/assets/${code}` + "\n");
|
|
141
|
+
const result = await client.delete(`/api/dam/assets/${code}`);
|
|
142
|
+
ctx.output(result);
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
parent
|
|
146
|
+
.command("discard-asset <code>")
|
|
147
|
+
.description("Discard an asset (soft delete)")
|
|
148
|
+
.action(async (code) => {
|
|
149
|
+
const client = await ctx.getClient();
|
|
150
|
+
if (ctx.verbose)
|
|
151
|
+
process.stderr.write(
|
|
152
|
+
"PATCH " + `/api/dam/assets/${code}/discard` + "\n",
|
|
153
|
+
);
|
|
154
|
+
const result = await client.patch(`/api/dam/assets/${code}/discard`);
|
|
155
|
+
ctx.output(result);
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
parent
|
|
159
|
+
.command("create-imagekit-auth")
|
|
160
|
+
.description(
|
|
161
|
+
"Creates ImageKit authentication credentials for large file uploads",
|
|
162
|
+
)
|
|
163
|
+
.action(async () => {
|
|
164
|
+
const client = await ctx.getClient();
|
|
165
|
+
if (ctx.verbose)
|
|
166
|
+
process.stderr.write("POST " + `/api/dam/assets/imagekit_auth` + "\n");
|
|
167
|
+
const result = await client.post(`/api/dam/assets/imagekit_auth`);
|
|
168
|
+
ctx.output(result);
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
parent
|
|
172
|
+
.command("query-assets")
|
|
173
|
+
.description("Query DAM assets using tree paths and tags")
|
|
174
|
+
.option("--body <json>", "Request body as JSON string")
|
|
175
|
+
.option("--body-file <path>", "Read request body from file")
|
|
176
|
+
.action(async (opts) => {
|
|
177
|
+
const client = await ctx.getClient();
|
|
178
|
+
let body: unknown;
|
|
179
|
+
if (opts.bodyFile) {
|
|
180
|
+
const { readFileSync } = await import("fs");
|
|
181
|
+
body = ctx.parseBody(readFileSync(opts.bodyFile, "utf-8"));
|
|
182
|
+
} else if (opts.body) {
|
|
183
|
+
body = ctx.parseBody(opts.body);
|
|
184
|
+
}
|
|
185
|
+
if (ctx.verbose) process.stderr.write("POST " + `/api/dam/query` + "\n");
|
|
186
|
+
const result = await client.post(`/api/dam/query`, body);
|
|
187
|
+
ctx.output(result);
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
parent
|
|
191
|
+
.command("list-variants <code>")
|
|
192
|
+
.description("Returns all variants for an existing asset")
|
|
193
|
+
.action(async (code) => {
|
|
194
|
+
const client = await ctx.getClient();
|
|
195
|
+
if (ctx.verbose)
|
|
196
|
+
process.stderr.write(
|
|
197
|
+
"GET " + `/api/dam/assets/${code}/variants` + "\n",
|
|
198
|
+
);
|
|
199
|
+
const result = await client.get(`/api/dam/assets/${code}/variants`);
|
|
200
|
+
ctx.output(result);
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
parent
|
|
204
|
+
.command("create-variants <code>")
|
|
205
|
+
.description("Creates variants for an existing asset")
|
|
206
|
+
.option("--body <json>", "Request body as JSON string")
|
|
207
|
+
.option("--body-file <path>", "Read request body from file")
|
|
208
|
+
.action(async (code, opts) => {
|
|
209
|
+
const client = await ctx.getClient();
|
|
210
|
+
let body: unknown;
|
|
211
|
+
if (opts.bodyFile) {
|
|
212
|
+
const { readFileSync } = await import("fs");
|
|
213
|
+
body = ctx.parseBody(readFileSync(opts.bodyFile, "utf-8"));
|
|
214
|
+
} else if (opts.body) {
|
|
215
|
+
body = ctx.parseBody(opts.body);
|
|
216
|
+
}
|
|
217
|
+
if (ctx.verbose)
|
|
218
|
+
process.stderr.write(
|
|
219
|
+
"POST " + `/api/dam/assets/${code}/variants` + "\n",
|
|
220
|
+
);
|
|
221
|
+
const result = await client.post(
|
|
222
|
+
`/api/dam/assets/${code}/variants`,
|
|
223
|
+
body,
|
|
224
|
+
);
|
|
225
|
+
ctx.output(result);
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
parent
|
|
229
|
+
.command("get-variant <code> <id>")
|
|
230
|
+
.description("Returns a specific variant for an existing asset")
|
|
231
|
+
.action(async (code, id) => {
|
|
232
|
+
const client = await ctx.getClient();
|
|
233
|
+
if (ctx.verbose)
|
|
234
|
+
process.stderr.write(
|
|
235
|
+
"GET " + `/api/dam/assets/${code}/variants/${id}` + "\n",
|
|
236
|
+
);
|
|
237
|
+
const result = await client.get(`/api/dam/assets/${code}/variants/${id}`);
|
|
238
|
+
ctx.output(result);
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
parent
|
|
242
|
+
.command("update-variant <code> <id>")
|
|
243
|
+
.description("Updates tags for a specific variant")
|
|
244
|
+
.option("--body <json>", "Request body as JSON string")
|
|
245
|
+
.option("--body-file <path>", "Read request body from file")
|
|
246
|
+
.action(async (code, id, opts) => {
|
|
247
|
+
const client = await ctx.getClient();
|
|
248
|
+
let body: unknown;
|
|
249
|
+
if (opts.bodyFile) {
|
|
250
|
+
const { readFileSync } = await import("fs");
|
|
251
|
+
body = ctx.parseBody(readFileSync(opts.bodyFile, "utf-8"));
|
|
252
|
+
} else if (opts.body) {
|
|
253
|
+
body = ctx.parseBody(opts.body);
|
|
254
|
+
}
|
|
255
|
+
if (ctx.verbose)
|
|
256
|
+
process.stderr.write(
|
|
257
|
+
"PUT " + `/api/dam/assets/${code}/variants/${id}` + "\n",
|
|
258
|
+
);
|
|
259
|
+
const result = await client.put(
|
|
260
|
+
`/api/dam/assets/${code}/variants/${id}`,
|
|
261
|
+
body,
|
|
262
|
+
);
|
|
263
|
+
ctx.output(result);
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
parent
|
|
267
|
+
.command("delete-variant <code> <id>")
|
|
268
|
+
.description("Destroys a variant for an existing asset")
|
|
269
|
+
.action(async (code, id) => {
|
|
270
|
+
const client = await ctx.getClient();
|
|
271
|
+
if (ctx.verbose)
|
|
272
|
+
process.stderr.write(
|
|
273
|
+
"DELETE " + `/api/dam/assets/${code}/variants/${id}` + "\n",
|
|
274
|
+
);
|
|
275
|
+
const result = await client.delete(
|
|
276
|
+
`/api/dam/assets/${code}/variants/${id}`,
|
|
277
|
+
);
|
|
278
|
+
ctx.output(result);
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
parent
|
|
282
|
+
.command("discard-variant <asset-code> <id>")
|
|
283
|
+
.description("Discards a variant for an existing asset (soft delete)")
|
|
284
|
+
.action(async (assetCode, id) => {
|
|
285
|
+
const client = await ctx.getClient();
|
|
286
|
+
if (ctx.verbose)
|
|
287
|
+
process.stderr.write(
|
|
288
|
+
"PATCH " +
|
|
289
|
+
`/api/dam/assets/${assetCode}/variants/${id}/discard` +
|
|
290
|
+
"\n",
|
|
291
|
+
);
|
|
292
|
+
const result = await client.patch(
|
|
293
|
+
`/api/dam/assets/${assetCode}/variants/${id}/discard`,
|
|
294
|
+
);
|
|
295
|
+
ctx.output(result);
|
|
296
|
+
});
|
|
297
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { FluidPlugin } from "@fluid-app/fluid-cli";
|
|
2
|
+
import { createDomainCommand } from "@fluid-app/fluid-cli";
|
|
3
|
+
|
|
4
|
+
import { registerAllCommands } from "./generated/index.js";
|
|
5
|
+
|
|
6
|
+
const plugin: FluidPlugin = {
|
|
7
|
+
name: "@fluid-app/fluid-cli-assets",
|
|
8
|
+
version: "0.1.0",
|
|
9
|
+
register(ctx) {
|
|
10
|
+
ctx.program.addCommand(
|
|
11
|
+
createDomainCommand(
|
|
12
|
+
"assets",
|
|
13
|
+
"Manage Fluid digital assets (DAM)",
|
|
14
|
+
registerAllCommands,
|
|
15
|
+
),
|
|
16
|
+
);
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export default plugin;
|
package/tsconfig.json
ADDED
package/tsdown.config.ts
ADDED