aemdm 0.3.0 → 0.4.1
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 +5 -2
- package/dist/lib/delivery.js +12 -11
- package/package.json +2 -1
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
|
+
import { createRequire } from "node:module";
|
|
3
4
|
import { realpathSync } from "node:fs";
|
|
5
|
+
const require = createRequire(import.meta.url);
|
|
6
|
+
const pkg = require("../package.json");
|
|
4
7
|
import { Command, CommanderError, Option } from "commander";
|
|
5
8
|
import { z } from "zod";
|
|
6
9
|
import { CliError, normalizeBucket, request, requestJson, resolveBucket, resolveOptionalImsToken, resolveSearchAuth, } from "./lib/client.js";
|
|
@@ -346,8 +349,8 @@ function buildProgram(runtime) {
|
|
|
346
349
|
const program = new Command();
|
|
347
350
|
program
|
|
348
351
|
.name("aemdm")
|
|
349
|
-
.description(
|
|
350
|
-
.version(
|
|
352
|
+
.description(`CLI for Adobe Dynamic Media with OpenAPI v${pkg.version}`)
|
|
353
|
+
.version(pkg.version)
|
|
351
354
|
.showHelpAfterError()
|
|
352
355
|
.option("-v, --verbose", "Show additional diagnostic output")
|
|
353
356
|
.configureOutput({
|
package/dist/lib/delivery.js
CHANGED
|
@@ -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 = "
|
|
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(/\/+$/, "")}/${
|
|
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 =
|
|
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
|
|
73
|
-
const
|
|
73
|
+
const base = `${normalizedBase}/${encodedAssetId}/as/${encodedSeoName}.${format}`;
|
|
74
|
+
const params = [];
|
|
74
75
|
if (options.width !== undefined) {
|
|
75
|
-
|
|
76
|
+
params.push(`width=${options.width}`);
|
|
76
77
|
}
|
|
77
78
|
if (options.height !== undefined) {
|
|
78
|
-
|
|
79
|
+
params.push(`height=${options.height}`);
|
|
79
80
|
}
|
|
80
81
|
if (options.quality !== undefined) {
|
|
81
|
-
|
|
82
|
+
params.push(`quality=${options.quality}`);
|
|
82
83
|
}
|
|
83
84
|
if (options.maxQuality !== undefined) {
|
|
84
|
-
|
|
85
|
+
params.push(`max-quality=${options.maxQuality}`);
|
|
85
86
|
}
|
|
86
|
-
return
|
|
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
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "CLI for Adobe Dynamic Media with OpenAPI",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Chris Pilsworth",
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"node": ">=20"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
+
"aemdm": "^0.4.0",
|
|
44
45
|
"commander": "^14.0.1",
|
|
45
46
|
"zod": "^4.1.12"
|
|
46
47
|
},
|