aemdm 0.3.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/dist/cli.js CHANGED
@@ -347,7 +347,7 @@ function buildProgram(runtime) {
347
347
  program
348
348
  .name("aemdm")
349
349
  .description("CLI for Adobe Dynamic Media with OpenAPI")
350
- .version("0.3.0")
350
+ .version("0.4.0")
351
351
  .showHelpAfterError()
352
352
  .option("-v, --verbose", "Show additional diagnostic output")
353
353
  .configureOutput({
@@ -1,7 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { CliError } from "./client.js";
3
3
  export const DEFAULT_SEO_NAME = "asset";
4
- export const TRANSFORM_FALLBACK_FORMAT = "avif";
4
+ export const TRANSFORM_FALLBACK_FORMAT = "png";
5
5
  export const deliveryFormatSchema = z.enum(["gif", "png", "jpg", "jpeg", "webp", "avif"]);
6
6
  const qualitySchema = z.number().int().min(1).max(100);
7
7
  const dimensionSchema = z.number().int().min(1);
@@ -39,12 +39,12 @@ export function resolveDimensions(size, width, height) {
39
39
  };
40
40
  }
41
41
  export function buildMetadataUrl(baseUrl, assetId) {
42
- return `${baseUrl.replace(/\/+$/, "")}/${encodeURIComponent(assetId)}/metadata`;
42
+ return `${baseUrl.replace(/\/+$/, "")}/${assetId}/metadata`;
43
43
  }
44
44
  export function buildAssetUrl(baseUrl, options) {
45
45
  const seoName = options.seoName ?? DEFAULT_SEO_NAME;
46
46
  const normalizedBase = baseUrl.replace(/\/+$/, "");
47
- const encodedAssetId = encodeURIComponent(options.assetId);
47
+ const encodedAssetId = options.assetId;
48
48
  const encodedSeoName = encodeURIComponent(seoName);
49
49
  if (options.quality !== undefined) {
50
50
  qualitySchema.parse(options.quality);
@@ -66,22 +66,23 @@ export function buildAssetUrl(baseUrl, options) {
66
66
  options.height !== undefined ||
67
67
  options.quality !== undefined ||
68
68
  options.maxQuality !== undefined;
69
+ const format = options.format ?? TRANSFORM_FALLBACK_FORMAT;
69
70
  if (!shouldUseTransformRoute) {
70
- return `${normalizedBase}/${encodedAssetId}`;
71
+ return `${normalizedBase}/${encodedAssetId}/as/${encodedSeoName}.${format}`;
71
72
  }
72
- const format = options.format ?? TRANSFORM_FALLBACK_FORMAT;
73
- const url = new URL(`${normalizedBase}/${encodedAssetId}/as/${encodedSeoName}.${format}`);
73
+ const base = `${normalizedBase}/${encodedAssetId}/as/${encodedSeoName}.${format}`;
74
+ const params = [];
74
75
  if (options.width !== undefined) {
75
- url.searchParams.set("width", String(options.width));
76
+ params.push(`width=${options.width}`);
76
77
  }
77
78
  if (options.height !== undefined) {
78
- url.searchParams.set("height", String(options.height));
79
+ params.push(`height=${options.height}`);
79
80
  }
80
81
  if (options.quality !== undefined) {
81
- url.searchParams.set("quality", String(options.quality));
82
+ params.push(`quality=${options.quality}`);
82
83
  }
83
84
  if (options.maxQuality !== undefined) {
84
- url.searchParams.set("max-quality", String(options.maxQuality));
85
+ params.push(`max-quality=${options.maxQuality}`);
85
86
  }
86
- return url.toString();
87
+ return params.length > 0 ? `${base}?${params.join("&")}` : base;
87
88
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aemdm",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "CLI for Adobe Dynamic Media with OpenAPI",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Chris Pilsworth",