@cimplify/cli 0.6.12 → 0.6.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/{add-UZRM3FSU.mjs → add-6KEKFXOW.mjs} +1 -1
  2. package/dist/{assets-EBEMMENZ.mjs → assets-74SK63TR.mjs} +73 -24
  3. package/dist/chunk-DEWCHGWU.mjs +5707 -0
  4. package/dist/{chunk-A2L5IV57.mjs → chunk-JLSDFVML.mjs} +1 -1
  5. package/dist/{chunk-E7P6GL73.mjs → chunk-OSS47KZP.mjs} +2 -2
  6. package/dist/dispatcher.mjs +10 -10
  7. package/dist/{doctor-Q6DWYG4D.mjs → doctor-WL25JRS3.mjs} +2 -2
  8. package/dist/{explain-RA3PQCUF.mjs → explain-NY5A533M.mjs} +8 -1
  9. package/dist/{introspect-HKNLBZ73.mjs → introspect-J7GVKQK7.mjs} +2 -2
  10. package/dist/{list-U67HVMX5.mjs → list-FXOFYX4H.mjs} +1 -1
  11. package/dist/{update-UT46Z6X4.mjs → update-WNZKECFJ.mjs} +1 -1
  12. package/package.json +2 -2
  13. package/templates/storefront-auto/app/api/revalidate/route.ts +5 -0
  14. package/templates/storefront-auto/app/products/[slug]/page.tsx +8 -3
  15. package/templates/storefront-auto/bun.lock +10 -681
  16. package/templates/storefront-auto/package.json +1 -1
  17. package/templates/storefront-bakery/app/api/revalidate/route.ts +5 -0
  18. package/templates/storefront-bakery/bun.lock +10 -681
  19. package/templates/storefront-bakery/package.json +1 -1
  20. package/templates/storefront-fashion/app/api/revalidate/route.ts +5 -0
  21. package/templates/storefront-fashion/app/products/[slug]/page.tsx +8 -3
  22. package/templates/storefront-fashion/bun.lock +12 -683
  23. package/templates/storefront-fashion/package.json +1 -1
  24. package/templates/storefront-grocery/app/api/revalidate/route.ts +5 -0
  25. package/templates/storefront-grocery/bun.lock +10 -681
  26. package/templates/storefront-grocery/package.json +1 -1
  27. package/templates/storefront-pharmacy/app/api/revalidate/route.ts +5 -0
  28. package/templates/storefront-pharmacy/app/products/[slug]/page.tsx +8 -3
  29. package/templates/storefront-pharmacy/bun.lock +10 -681
  30. package/templates/storefront-pharmacy/package.json +1 -1
  31. package/templates/storefront-restaurant/app/api/revalidate/route.ts +5 -0
  32. package/templates/storefront-restaurant/bun.lock +10 -681
  33. package/templates/storefront-restaurant/package.json +1 -1
  34. package/templates/storefront-retail/app/api/revalidate/route.ts +5 -0
  35. package/templates/storefront-retail/app/products/[slug]/page.tsx +8 -3
  36. package/templates/storefront-retail/bun.lock +10 -681
  37. package/templates/storefront-retail/package.json +1 -1
  38. package/templates/storefront-services/app/api/revalidate/route.ts +5 -0
  39. package/templates/storefront-services/bun.lock +10 -681
  40. package/templates/storefront-services/package.json +1 -1
  41. package/dist/chunk-VOQJ7GYE.mjs +0 -5707
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { REGISTRY_INDEX, REGISTRY } from './chunk-VOQJ7GYE.mjs';
2
+ import { REGISTRY_INDEX, REGISTRY } from './chunk-DEWCHGWU.mjs';
3
3
  import { promptYesNo } from './chunk-ITAFAORS.mjs';
4
4
  import { parseArgs, flagString, flagBool } from './chunk-C4M3DXKC.mjs';
5
5
  import { CliError, CLI_ERROR_CODE, info, bold, dim, success, result, yellow } from './chunk-E2T2SBP5.mjs';
@@ -32,6 +32,13 @@ function endpointInit(businessId) {
32
32
  function endpointConfirm(businessId) {
33
33
  return `/v1/businesses/${encodeURIComponent(businessId)}/assets/confirm`;
34
34
  }
35
+ function endpointList(businessId) {
36
+ return `/v1/businesses/${encodeURIComponent(businessId)}/assets`;
37
+ }
38
+ function endpointAsset(businessId, uploadId) {
39
+ return `/v1/businesses/${encodeURIComponent(businessId)}/assets/${encodeURIComponent(uploadId)}`;
40
+ }
41
+ var SERVER_LIST_PAGE_LIMIT = 100;
35
42
  function manifestPath(cwd = process.cwd()) {
36
43
  return path.join(cwd, MANIFEST_FILE);
37
44
  }
@@ -172,37 +179,79 @@ async function runUpload(args) {
172
179
  });
173
180
  }
174
181
  async function runLs(args) {
175
- const prefix = flagString(args, "prefix");
176
- const manifest = await readManifest();
177
- const entries = Object.entries(manifest).filter(([k]) => prefix ? k.startsWith(prefix) : true).sort(([a], [b]) => a.localeCompare(b));
178
- if (entries.length === 0) {
179
- info(dim("No assets uploaded yet."));
182
+ const folder = flagString(args, "prefix") ?? flagString(args, "folder");
183
+ const mimePrefix = flagString(args, "type");
184
+ const auth = await readAuth();
185
+ const client = ApiClient.fromAuth(auth);
186
+ const assets = [];
187
+ let page = 1;
188
+ let total = 0;
189
+ for (; ; ) {
190
+ const response = await client.get(endpointList(auth.businessId), {
191
+ query: {
192
+ page,
193
+ limit: SERVER_LIST_PAGE_LIMIT,
194
+ ...folder ? { folder } : {},
195
+ ...mimePrefix ? { mime_prefix: mimePrefix } : {}
196
+ }
197
+ });
198
+ assets.push(...response.assets);
199
+ total = response.pagination.total;
200
+ if (response.assets.length < SERVER_LIST_PAGE_LIMIT) break;
201
+ page += 1;
202
+ }
203
+ if (assets.length === 0) {
204
+ info(dim("No storefront assets uploaded yet."));
180
205
  } else {
181
- info(bold(`Assets in ${MANIFEST_FILE}:`));
182
- for (const [key, entry] of entries) {
183
- info(` ${green("\u25CF")} ${key} ${dim(`\u2192 ${entry.url}`)}`);
206
+ info(bold(`Storefront assets (${total} total):`));
207
+ for (const a of assets) {
208
+ const key = a.folder_path ? `${a.folder_path}/${a.filename}` : a.filename;
209
+ info(
210
+ ` ${green("\u25CF")} ${key.padEnd(36)} ${dim(a.content_type.padEnd(24))} ${dim(
211
+ formatBytes(a.size_bytes).padStart(10)
212
+ )} ${dim(a.id)} ${dim(`\u2192 ${a.url}`)}`
213
+ );
184
214
  }
185
215
  }
186
- result({
187
- count: entries.length,
188
- assets: entries.map(([key, entry]) => ({ key, ...entry }))
189
- });
216
+ result({ count: assets.length, total, assets });
217
+ }
218
+ function formatBytes(n) {
219
+ if (n < 1024) return `${n} B`;
220
+ if (n < 1024 * 1024) return `${(n / 1024).toFixed(1)} KB`;
221
+ return `${(n / (1024 * 1024)).toFixed(2)} MB`;
190
222
  }
191
223
  async function runRm(args) {
192
- const key = args.positional[1];
193
- if (!key) {
194
- throw new CliError(CLI_ERROR_CODE.INVALID_INPUT, "Usage: cimplify assets rm <key>");
224
+ const target = args.positional[1];
225
+ if (!target) {
226
+ throw new CliError(
227
+ CLI_ERROR_CODE.INVALID_INPUT,
228
+ "Usage: cimplify assets rm <upload_id-or-key>"
229
+ );
195
230
  }
231
+ const auth = await readAuth();
232
+ const client = ApiClient.fromAuth(auth);
196
233
  const manifest = await readManifest();
197
- if (!(key in manifest)) {
198
- throw new CliError(CLI_ERROR_CODE.NOT_FOUND, `Key not found in manifest: ${key}`);
234
+ let uploadId;
235
+ let resolvedKey = null;
236
+ if (target.startsWith("upl_")) {
237
+ uploadId = target;
238
+ resolvedKey = Object.entries(manifest).find(([, e]) => e.upload_id === target)?.[0] ?? null;
239
+ } else if (target in manifest) {
240
+ uploadId = manifest[target].upload_id;
241
+ resolvedKey = target;
242
+ } else {
243
+ throw new CliError(
244
+ CLI_ERROR_CODE.NOT_FOUND,
245
+ `Not found locally: ${target}. Pass an upload_id from \`cimplify assets ls\` instead.`
246
+ );
199
247
  }
200
- const removed = manifest[key];
201
- delete manifest[key];
202
- await writeManifest(manifest);
203
- success(`Removed ${key} from manifest`);
204
- info(dim("Note: remote blob is not deleted in v1 \u2014 only the manifest entry."));
205
- result({ removed_key: key, removed_url: removed.url });
248
+ await client.delete(endpointAsset(auth.businessId, uploadId));
249
+ if (resolvedKey) {
250
+ delete manifest[resolvedKey];
251
+ await writeManifest(manifest);
252
+ }
253
+ success(`Removed ${resolvedKey ?? uploadId}`);
254
+ result({ removed_upload_id: uploadId, removed_key: resolvedKey });
206
255
  }
207
256
 
208
- export { run as default, endpointConfirm, endpointInit, mimeOf, readManifest, sha256Hex, walkFiles, writeManifest };
257
+ export { run as default, endpointAsset, endpointConfirm, endpointInit, endpointList, mimeOf, readManifest, sha256Hex, walkFiles, writeManifest };