@koda-sl/baker-cli 0.100.0 → 0.101.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 +36 -31
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -12144,8 +12144,8 @@ async function uploadLocalImage(args, deps = defaultImageApiDeps) {
|
|
|
12144
12144
|
function getImage(deps, imageId) {
|
|
12145
12145
|
return deps.get("/api/images/get", { id: imageId });
|
|
12146
12146
|
}
|
|
12147
|
-
function
|
|
12148
|
-
return deps.post("/api/
|
|
12147
|
+
function publishImageAsCreative(deps, args) {
|
|
12148
|
+
return deps.post("/api/creatives/publish", args);
|
|
12149
12149
|
}
|
|
12150
12150
|
async function waitForReadyImage(deps, imageId, opts = {}) {
|
|
12151
12151
|
const timeoutMs = opts.timeoutMs ?? imageProcessingTimeoutMs;
|
|
@@ -12167,15 +12167,19 @@ async function waitForReadyImage(deps, imageId, opts = {}) {
|
|
|
12167
12167
|
}
|
|
12168
12168
|
|
|
12169
12169
|
// src/commands/creatives/publish.ts
|
|
12170
|
-
var creativeTag = "creative";
|
|
12171
12170
|
var creativeContentTypes = ["image/png", "image/jpeg", "image/webp"];
|
|
12172
12171
|
registerSchema({
|
|
12173
12172
|
command: "creatives.publish",
|
|
12174
|
-
description: "Publish a final static creative image to Baker
|
|
12173
|
+
description: "Publish a final static creative image to Baker Creatives and return a creative reference.",
|
|
12175
12174
|
args: {
|
|
12176
12175
|
file: { type: "string", description: "Local PNG/JPG/WebP creative image path", required: true },
|
|
12177
12176
|
title: { type: "string", description: "Human title for the creative output", required: true },
|
|
12178
|
-
context: { type: "string", description: "Optional describe context for the image
|
|
12177
|
+
context: { type: "string", description: "Optional describe context for the image asset", required: false },
|
|
12178
|
+
sourceReferenceUrl: {
|
|
12179
|
+
type: "string",
|
|
12180
|
+
description: "Optional URL of the original reference ad",
|
|
12181
|
+
required: false
|
|
12182
|
+
}
|
|
12179
12183
|
}
|
|
12180
12184
|
});
|
|
12181
12185
|
function detectCreativeContentType(filePath) {
|
|
@@ -12184,29 +12188,22 @@ function detectCreativeContentType(filePath) {
|
|
|
12184
12188
|
unsupportedMessage: "Unsupported creative image extension. Use PNG, JPG, or WebP."
|
|
12185
12189
|
});
|
|
12186
12190
|
}
|
|
12187
|
-
function
|
|
12188
|
-
if (
|
|
12189
|
-
|
|
12191
|
+
function parseOptionalUrl(value) {
|
|
12192
|
+
if (value === void 0 || value.trim() === "") {
|
|
12193
|
+
return void 0;
|
|
12194
|
+
}
|
|
12195
|
+
try {
|
|
12196
|
+
return new URL(value).toString();
|
|
12197
|
+
} catch {
|
|
12198
|
+
throw new ApiError("VALIDATION_ERROR", "--source-reference-url must be a valid URL");
|
|
12190
12199
|
}
|
|
12191
|
-
return {
|
|
12192
|
-
type: "image",
|
|
12193
|
-
slug: image._id,
|
|
12194
|
-
title,
|
|
12195
|
-
tags: image.tags?.includes(creativeTag) ? image.tags : [...image.tags ?? [], creativeTag],
|
|
12196
|
-
imageUrl: image.imageUrl,
|
|
12197
|
-
thumbnailUrl: image.thumbnailUrl ?? image.imageUrl,
|
|
12198
|
-
storageKey: image.storageKey,
|
|
12199
|
-
width: image.width,
|
|
12200
|
-
height: image.height,
|
|
12201
|
-
aspectRatio: image.aspectRatio,
|
|
12202
|
-
source: image.source
|
|
12203
|
-
};
|
|
12204
12200
|
}
|
|
12205
12201
|
async function publishCreative(args, deps = defaultImageApiDeps) {
|
|
12206
12202
|
const title = args.title.trim();
|
|
12207
12203
|
if (!title) {
|
|
12208
12204
|
throw new ApiError("VALIDATION_ERROR", "--title is required");
|
|
12209
12205
|
}
|
|
12206
|
+
const sourceReferenceUrl = parseOptionalUrl(args.sourceReferenceUrl);
|
|
12210
12207
|
const contentType = detectCreativeContentType(args.file);
|
|
12211
12208
|
const upload = await uploadLocalImage(
|
|
12212
12209
|
{
|
|
@@ -12217,24 +12214,27 @@ async function publishCreative(args, deps = defaultImageApiDeps) {
|
|
|
12217
12214
|
},
|
|
12218
12215
|
deps
|
|
12219
12216
|
);
|
|
12220
|
-
|
|
12221
|
-
|
|
12222
|
-
|
|
12223
|
-
|
|
12224
|
-
|
|
12217
|
+
await waitForReadyImage(deps, upload.imageId, { timeoutMs: imageProcessingTimeoutMs });
|
|
12218
|
+
return publishImageAsCreative(deps, {
|
|
12219
|
+
imageId: upload.imageId,
|
|
12220
|
+
title,
|
|
12221
|
+
sourceReferenceUrl
|
|
12225
12222
|
});
|
|
12226
|
-
const taggedImage = await getImage(deps, upload.imageId);
|
|
12227
|
-
return { imageId: upload.imageId, reference: imageToCreativeReference({ ...readyImage, ...taggedImage }, title) };
|
|
12228
12223
|
}
|
|
12229
12224
|
var publishCommand = defineCommand87({
|
|
12230
12225
|
meta: {
|
|
12231
12226
|
name: "publish",
|
|
12232
|
-
description: "Publish a final static creative image to Baker
|
|
12227
|
+
description: "Publish a final static creative image to Baker Creatives and print the creative reference JSON."
|
|
12233
12228
|
},
|
|
12234
12229
|
args: {
|
|
12235
12230
|
file: { type: "positional", description: "Local PNG/JPG/WebP creative image path", required: false },
|
|
12236
12231
|
title: { type: "string", description: "Human title for the creative output", required: false },
|
|
12237
|
-
context: { type: "string", description: "Optional describe context for the image
|
|
12232
|
+
context: { type: "string", description: "Optional describe context for the image asset", required: false },
|
|
12233
|
+
sourceReferenceUrl: {
|
|
12234
|
+
type: "string",
|
|
12235
|
+
description: "Optional URL of the original reference ad",
|
|
12236
|
+
required: false
|
|
12237
|
+
}
|
|
12238
12238
|
},
|
|
12239
12239
|
run: async ({ args }) => {
|
|
12240
12240
|
try {
|
|
@@ -12248,7 +12248,12 @@ var publishCommand = defineCommand87({
|
|
|
12248
12248
|
writeJson({ ok: false, error: { code: "VALIDATION_ERROR", message: "--title is required" } });
|
|
12249
12249
|
process.exit(1);
|
|
12250
12250
|
}
|
|
12251
|
-
const data = await publishCreative({
|
|
12251
|
+
const data = await publishCreative({
|
|
12252
|
+
file,
|
|
12253
|
+
title,
|
|
12254
|
+
context: args.context,
|
|
12255
|
+
sourceReferenceUrl: args.sourceReferenceUrl
|
|
12256
|
+
});
|
|
12252
12257
|
writeJson({ ok: true, data });
|
|
12253
12258
|
} catch (err) {
|
|
12254
12259
|
if (err instanceof ApiError) {
|