@koda-sl/baker-cli 0.869.0-dev.0631d8a3c → 0.869.0-dev.49bba5255
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/README.md +2 -3
- package/dist/{ads-VSU53JN3.js → ads-CEF5MSJ6.js} +5 -5
- package/dist/{analytics-EM4NNEG5.js → analytics-3IS4CCFL.js} +26 -14
- package/dist/analytics-3IS4CCFL.js.map +1 -0
- package/dist/{chunk-7YHMZVKM.js → chunk-6SMIAFH2.js} +2 -2
- package/dist/{chunk-T7GAC2WG.js → chunk-7JM5OH6I.js} +32 -3
- package/dist/chunk-7JM5OH6I.js.map +1 -0
- package/dist/{chunk-XFTN3ARP.js → chunk-BPIHAIWB.js} +13 -22
- package/dist/chunk-BPIHAIWB.js.map +1 -0
- package/dist/{chunk-4YQ46MM4.js → chunk-E5US4SNS.js} +2 -2
- package/dist/{chunk-HORX3JLB.js → chunk-KFFAH3TX.js} +2 -2
- package/dist/{chunk-LMVSHRIS.js → chunk-VMZ2XBU7.js} +2 -2
- package/dist/{chunk-EVNRBJML.js → chunk-VT4GYO3E.js} +3 -3
- package/dist/cli.js +3 -3
- package/dist/{funnel-BFVSY5A6.js → funnel-G4JVDQUE.js} +3 -3
- package/dist/{google-HHKFDH7I.js → google-ZFRRYSFZ.js} +2 -2
- package/dist/{linkedin-RMZMQ2ZA.js → linkedin-EBOTX37R.js} +4 -8
- package/dist/{linkedin-RMZMQ2ZA.js.map → linkedin-EBOTX37R.js.map} +1 -1
- package/dist/{lookup-NWIDMQ5B.js → lookup-P5NID3LV.js} +4 -4
- package/dist/{meta-HOFABFAK.js → meta-SPPSYRMC.js} +2 -2
- package/dist/{performance-Y2S5FDGI.js → performance-L44CGNTO.js} +2 -2
- package/dist/{plan-F3LGGPUT.js → plan-OTRYXYVC.js} +3 -3
- package/dist/{preview-XXQ5AHXP.js → preview-4GUQGDBD.js} +42 -134
- package/dist/preview-4GUQGDBD.js.map +1 -0
- package/dist/preview-HD3QAR53.js +104 -0
- package/dist/preview-HD3QAR53.js.map +1 -0
- package/dist/{questionnaire-XRQKZDTC.js → questionnaire-AFTRG3QM.js} +3 -3
- package/dist/{sends-KAFVQSQQ.js → sends-V4MRXQSO.js} +3 -3
- package/dist/{sources-FPWA4AJN.js → sources-OTOVMOJ5.js} +4 -4
- package/dist/{unstage-FLZFPQ36.js → unstage-E32YHRML.js} +3 -3
- package/dist/{url-options-BANFHIHH.js → url-options-ETN75DT5.js} +2 -2
- package/package.json +1 -1
- package/dist/analytics-EM4NNEG5.js.map +0 -1
- package/dist/chunk-T7GAC2WG.js.map +0 -1
- package/dist/chunk-XFTN3ARP.js.map +0 -1
- package/dist/preview-4DDR337D.js +0 -151
- package/dist/preview-4DDR337D.js.map +0 -1
- package/dist/preview-XXQ5AHXP.js.map +0 -1
- /package/dist/{ads-VSU53JN3.js.map → ads-CEF5MSJ6.js.map} +0 -0
- /package/dist/{chunk-7YHMZVKM.js.map → chunk-6SMIAFH2.js.map} +0 -0
- /package/dist/{chunk-4YQ46MM4.js.map → chunk-E5US4SNS.js.map} +0 -0
- /package/dist/{chunk-HORX3JLB.js.map → chunk-KFFAH3TX.js.map} +0 -0
- /package/dist/{chunk-LMVSHRIS.js.map → chunk-VMZ2XBU7.js.map} +0 -0
- /package/dist/{chunk-EVNRBJML.js.map → chunk-VT4GYO3E.js.map} +0 -0
- /package/dist/{funnel-BFVSY5A6.js.map → funnel-G4JVDQUE.js.map} +0 -0
- /package/dist/{google-HHKFDH7I.js.map → google-ZFRRYSFZ.js.map} +0 -0
- /package/dist/{lookup-NWIDMQ5B.js.map → lookup-P5NID3LV.js.map} +0 -0
- /package/dist/{meta-HOFABFAK.js.map → meta-SPPSYRMC.js.map} +0 -0
- /package/dist/{performance-Y2S5FDGI.js.map → performance-L44CGNTO.js.map} +0 -0
- /package/dist/{plan-F3LGGPUT.js.map → plan-OTRYXYVC.js.map} +0 -0
- /package/dist/{questionnaire-XRQKZDTC.js.map → questionnaire-AFTRG3QM.js.map} +0 -0
- /package/dist/{sends-KAFVQSQQ.js.map → sends-V4MRXQSO.js.map} +0 -0
- /package/dist/{sources-FPWA4AJN.js.map → sources-OTOVMOJ5.js.map} +0 -0
- /package/dist/{unstage-FLZFPQ36.js.map → unstage-E32YHRML.js.map} +0 -0
- /package/dist/{url-options-BANFHIHH.js.map → url-options-ETN75DT5.js.map} +0 -0
|
@@ -3,9 +3,9 @@ import {
|
|
|
3
3
|
lookupReport,
|
|
4
4
|
peopleArgs,
|
|
5
5
|
peopleLimitError
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-VT4GYO3E.js";
|
|
7
|
+
import "./chunk-VMZ2XBU7.js";
|
|
8
|
+
import "./chunk-7JM5OH6I.js";
|
|
9
9
|
import "./chunk-5TURKO4J.js";
|
|
10
10
|
import "./chunk-NYUWPJ4K.js";
|
|
11
11
|
import "./chunk-NKQWDEB7.js";
|
|
@@ -23,4 +23,4 @@ export {
|
|
|
23
23
|
peopleArgs,
|
|
24
24
|
peopleLimitError
|
|
25
25
|
};
|
|
26
|
-
//# sourceMappingURL=lookup-
|
|
26
|
+
//# sourceMappingURL=lookup-P5NID3LV.js.map
|
|
@@ -122,7 +122,7 @@ Full guide: __tooling__/docs/tools/baker/ads-meta.md`
|
|
|
122
122
|
pixels: () => import("./pixels-EX6FHVHW.js").then((m) => m.pixelsCommand),
|
|
123
123
|
activities: () => import("./activities-LC64DAAK.js").then((m) => m.activitiesCommand),
|
|
124
124
|
insights: () => import("./insights-QU5A4XBO.js").then((m) => m.insightsCommand),
|
|
125
|
-
preview: () => import("./preview-
|
|
125
|
+
preview: () => import("./preview-4GUQGDBD.js").then((m) => m.previewCommand),
|
|
126
126
|
videos: () => import("./videos-TJG5CA7N.js").then((m) => m.videosCommand),
|
|
127
127
|
targeting: () => import("./targeting-7T7XHBIX.js").then((m) => m.targetingCommand),
|
|
128
128
|
"instagram-accounts": () => import("./account-assets-L6BX4YUQ.js").then((m) => m.instagramAccountsCommand),
|
|
@@ -149,4 +149,4 @@ Full guide: __tooling__/docs/tools/baker/ads-meta.md`
|
|
|
149
149
|
export {
|
|
150
150
|
metaCommand
|
|
151
151
|
};
|
|
152
|
-
//# sourceMappingURL=meta-
|
|
152
|
+
//# sourceMappingURL=meta-SPPSYRMC.js.map
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
ANALYTICS_BUSY_FIX,
|
|
6
6
|
isAnalyticsBusy,
|
|
7
7
|
retryOnceIfBusy
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-7JM5OH6I.js";
|
|
9
9
|
import "./chunk-5TURKO4J.js";
|
|
10
10
|
import {
|
|
11
11
|
withWindowSpellings
|
|
@@ -6358,4 +6358,4 @@ Full guide: __tooling__/docs/tools/baker/ads-performance.md`
|
|
|
6358
6358
|
export {
|
|
6359
6359
|
performanceCommand
|
|
6360
6360
|
};
|
|
6361
|
-
//# sourceMappingURL=performance-
|
|
6361
|
+
//# sourceMappingURL=performance-L44CGNTO.js.map
|
|
@@ -6,10 +6,10 @@ import {
|
|
|
6
6
|
} from "./chunk-YCSWGVNA.js";
|
|
7
7
|
import {
|
|
8
8
|
trackingPlanErrorEnvelope
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-VMZ2XBU7.js";
|
|
10
10
|
import {
|
|
11
11
|
ANALYTICS_EVENT_DOORS
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-7JM5OH6I.js";
|
|
13
13
|
import "./chunk-5TURKO4J.js";
|
|
14
14
|
import "./chunk-RHN5FEWA.js";
|
|
15
15
|
import "./chunk-D5FY4FAK.js";
|
|
@@ -210,4 +210,4 @@ var planCommand = defineCommand({
|
|
|
210
210
|
export {
|
|
211
211
|
planCommand
|
|
212
212
|
};
|
|
213
|
-
//# sourceMappingURL=plan-
|
|
213
|
+
//# sourceMappingURL=plan-OTRYXYVC.js.map
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
AD_PREVIEW_DIR,
|
|
3
3
|
AD_PREVIEW_DIR_LABEL,
|
|
4
4
|
renderAdPreviews
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-BPIHAIWB.js";
|
|
6
6
|
import "./chunk-VN3WDB4O.js";
|
|
7
7
|
import {
|
|
8
8
|
FACEBOOK_PREVIEW_FORMATS,
|
|
@@ -15,10 +15,6 @@ import {
|
|
|
15
15
|
handleMetaError
|
|
16
16
|
} from "./chunk-DP76WGDV.js";
|
|
17
17
|
import "./chunk-QALAJNBG.js";
|
|
18
|
-
import {
|
|
19
|
-
apiFailure,
|
|
20
|
-
eachTarget
|
|
21
|
-
} from "./chunk-EMW6TSSB.js";
|
|
22
18
|
import {
|
|
23
19
|
NO_CACHE_ARG
|
|
24
20
|
} from "./chunk-TBT6NWDX.js";
|
|
@@ -151,93 +147,10 @@ function previewFileName(target) {
|
|
|
151
147
|
if (id) return `meta-${id}`;
|
|
152
148
|
return `meta-draft-${createHash("sha256").update(target.creative ?? "").digest("hex").slice(0, 12)}`;
|
|
153
149
|
}
|
|
154
|
-
var MAX_PREVIEWS = 24;
|
|
155
|
-
function listArg(value) {
|
|
156
|
-
if (typeof value !== "string") return [];
|
|
157
|
-
return [...new Set(value.split(",").map((item) => item.trim()))].filter(Boolean);
|
|
158
|
-
}
|
|
159
|
-
function previewSubjects(args) {
|
|
160
|
-
const subjects = [
|
|
161
|
-
...listArg(args["creative-id"]).map((creativeId) => ({ creativeId })),
|
|
162
|
-
...listArg(args["ad-id"]).map((adId) => ({ adId }))
|
|
163
|
-
];
|
|
164
|
-
if (subjects.length > 0) return subjects;
|
|
165
|
-
const text = (value) => typeof value === "string" ? value : void 0;
|
|
166
|
-
return [{ accountId: text(args["account-id"]), creative: text(args.creative) }];
|
|
167
|
-
}
|
|
168
|
-
function previewFormats(placements, args) {
|
|
169
|
-
const formats = placements.length > 0 ? placements.map((p) => resolvePlacement(p, args.platform)) : listArg(args["ad-format"]);
|
|
170
|
-
if (formats.length === 0) {
|
|
171
|
-
failPreviewValidation("pass --ad-format or --placement (see --list-formats)");
|
|
172
|
-
}
|
|
173
|
-
const invalid = formats.find((adFormat) => !VALID_AD_FORMATS.includes(adFormat));
|
|
174
|
-
if (invalid) {
|
|
175
|
-
failPreviewValidation(
|
|
176
|
-
`Invalid --ad-format "${invalid}". Meta's ad_format values: ${VALID_AD_FORMATS.join(", ")}. To preview a placement you saw in an insights breakdown, pass --placement <platform_position> instead of guessing a format name.`
|
|
177
|
-
);
|
|
178
|
-
}
|
|
179
|
-
return formats;
|
|
180
|
-
}
|
|
181
|
-
async function fetchPreviews(pairs, skipCache) {
|
|
182
|
-
const refusals = [];
|
|
183
|
-
const fetched = await eachTarget(
|
|
184
|
-
pairs.map((_, i) => String(i)),
|
|
185
|
-
(i) => {
|
|
186
|
-
const { subject, adFormat } = pairs[Number(i)];
|
|
187
|
-
return apiPost("/api/ads/meta/preview", {
|
|
188
|
-
...subject,
|
|
189
|
-
adFormat,
|
|
190
|
-
...skipCache ? { skipCache: true } : {}
|
|
191
|
-
});
|
|
192
|
-
},
|
|
193
|
-
(err) => {
|
|
194
|
-
refusals.push(err);
|
|
195
|
-
return apiFailure(err);
|
|
196
|
-
}
|
|
197
|
-
);
|
|
198
|
-
if (refusals.length === pairs.length) {
|
|
199
|
-
handleMetaError(refusals[0]);
|
|
200
|
-
}
|
|
201
|
-
return fetched;
|
|
202
|
-
}
|
|
203
|
-
function previewInputs(pairs, fetched, several) {
|
|
204
|
-
const inputs = [];
|
|
205
|
-
const owners = [];
|
|
206
|
-
const refused = [];
|
|
207
|
-
for (const [index, outcome] of fetched.entries()) {
|
|
208
|
-
const { subject, adFormat } = pairs[index];
|
|
209
|
-
const owner = several ? subjectId(subject) : {};
|
|
210
|
-
if (!outcome.ok) {
|
|
211
|
-
refused.push({ index: inputs.length, entry: { ...owner, placement: adFormat, error: outcome.error.message } });
|
|
212
|
-
continue;
|
|
213
|
-
}
|
|
214
|
-
if (outcome.data.length === 0) {
|
|
215
|
-
refused.push({
|
|
216
|
-
index: inputs.length,
|
|
217
|
-
entry: { ...owner, placement: adFormat, error: "Meta returned no preview for this placement" }
|
|
218
|
-
});
|
|
219
|
-
continue;
|
|
220
|
-
}
|
|
221
|
-
for (const [i, d] of outcome.data.entries()) {
|
|
222
|
-
inputs.push({
|
|
223
|
-
placement: outcome.data.length > 1 ? `${adFormat}-${i + 1}` : adFormat,
|
|
224
|
-
html: d.body,
|
|
225
|
-
name: previewFileName(subject)
|
|
226
|
-
});
|
|
227
|
-
owners.push(owner);
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
return { inputs, owners, refused };
|
|
231
|
-
}
|
|
232
|
-
function subjectId(subject) {
|
|
233
|
-
if ("creativeId" in subject) return { creativeId: subject.creativeId };
|
|
234
|
-
if ("adId" in subject) return { adId: subject.adId };
|
|
235
|
-
return {};
|
|
236
|
-
}
|
|
237
150
|
var previewCommand = defineCommand({
|
|
238
151
|
meta: {
|
|
239
152
|
name: "preview",
|
|
240
|
-
description: `See
|
|
153
|
+
description: `See a creative or ad as Meta renders it in one placement: shownText (the text people see, in order)
|
|
241
154
|
plus a picture to Read for what text cannot tell (words in the artwork, cropping, how it looks).
|
|
242
155
|
--out-file also saves Meta's raw iframe HTML (its URL holds a short-lived access token \u2014 treat as secret).
|
|
243
156
|
|
|
@@ -246,31 +159,22 @@ image, the button). Start here too when you need to know what a creative looks l
|
|
|
246
159
|
Meta's own renderer, so it settles "does my video show as a still image there?" without guessing.
|
|
247
160
|
Pass the placement straight from an insights breakdown with --placement (a platform_position value),
|
|
248
161
|
or a Meta ad_format with --ad-format. Run --list-formats to see both sets.
|
|
249
|
-
To compare several creatives or placements, pass comma lists in ONE call \u2014 never loop the command:
|
|
250
|
-
every creative \xD7 format pair comes back as its own preview, fetched and drawn in parallel (at most ${MAX_PREVIEWS}).
|
|
251
162
|
|
|
252
163
|
Examples:
|
|
253
164
|
baker ads meta preview --creative-id 6123 --ad-format MOBILE_FEED_STANDARD
|
|
254
|
-
baker ads meta preview --creative-id 6123,6124 --ad-format MOBILE_FEED_STANDARD,INSTAGRAM_STORY,INSTAGRAM_REELS
|
|
255
165
|
baker ads meta preview --creative-id 6123 --placement facebook_reels_overlay --platform facebook
|
|
256
166
|
baker ads meta preview --ad-id 9988 --ad-format INSTAGRAM_REELS --out-dir /tmp/review
|
|
257
167
|
baker ads meta preview --account-id act_123 --creative '{"object_story_spec":{...}}' --ad-format MOBILE_FEED_STANDARD`
|
|
258
168
|
},
|
|
259
169
|
args: {
|
|
260
|
-
"creative-id": {
|
|
261
|
-
|
|
262
|
-
description: "Existing creative ID, or several comma-separated: --creative-id 6123,6124"
|
|
263
|
-
},
|
|
264
|
-
"ad-id": { type: "string", description: "Existing ad ID, or several comma-separated: --ad-id 9988,9989" },
|
|
170
|
+
"creative-id": { type: "string", description: "Existing creative ID" },
|
|
171
|
+
"ad-id": { type: "string", description: "Existing ad ID" },
|
|
265
172
|
"account-id": { type: "string", description: "Required when previewing an unpublished --creative spec" },
|
|
266
173
|
creative: { type: "string", description: "JSON spec of an unpublished creative (e.g. object_story_spec)" },
|
|
267
|
-
"ad-format": {
|
|
268
|
-
type: "string",
|
|
269
|
-
description: "Meta ad_format value, or several comma-separated: --ad-format MOBILE_FEED_STANDARD,INSTAGRAM_REELS (--list-formats to see them)"
|
|
270
|
-
},
|
|
174
|
+
"ad-format": { type: "string", description: "Meta ad_format enum value (--list-formats to see them)" },
|
|
271
175
|
placement: {
|
|
272
176
|
type: "string",
|
|
273
|
-
description: "platform_position from an insights breakdown (e.g. facebook_reels_overlay)
|
|
177
|
+
description: "platform_position from an insights breakdown (e.g. facebook_reels_overlay) \u2014 resolved to an ad_format"
|
|
274
178
|
},
|
|
275
179
|
platform: { type: "string", description: "facebook|instagram \u2014 required for --placement feed, which both report" },
|
|
276
180
|
"list-formats": { type: "boolean", description: "Print the ad_format values and placement mappings, then exit" },
|
|
@@ -289,50 +193,54 @@ Examples:
|
|
|
289
193
|
});
|
|
290
194
|
return;
|
|
291
195
|
}
|
|
292
|
-
const
|
|
293
|
-
const
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
196
|
+
const placement = args.placement;
|
|
197
|
+
const adFormat = placement ? resolvePlacement(placement, args.platform) : args["ad-format"];
|
|
198
|
+
if (!adFormat) {
|
|
199
|
+
failPreviewValidation("pass --ad-format or --placement (see --list-formats)");
|
|
200
|
+
}
|
|
201
|
+
if (!VALID_AD_FORMATS.includes(adFormat)) {
|
|
297
202
|
failPreviewValidation(
|
|
298
|
-
|
|
203
|
+
`Invalid --ad-format "${adFormat}". Meta's ad_format values: ${VALID_AD_FORMATS.join(", ")}. To preview a placement you saw in an insights breakdown, pass --placement <platform_position> instead of guessing a format name.`
|
|
299
204
|
);
|
|
300
205
|
}
|
|
301
|
-
const
|
|
302
|
-
|
|
303
|
-
|
|
206
|
+
const body = { adFormat };
|
|
207
|
+
if (args["creative-id"]) body.creativeId = args["creative-id"];
|
|
208
|
+
if (args["ad-id"]) body.adId = args["ad-id"];
|
|
209
|
+
if (args["account-id"]) body.accountId = args["account-id"];
|
|
210
|
+
if (args.creative) body.creative = args.creative;
|
|
211
|
+
if (args["no-cache"]) body.skipCache = true;
|
|
304
212
|
try {
|
|
213
|
+
const data = await apiPost("/api/ads/meta/preview", body);
|
|
305
214
|
if (args["out-file"]) {
|
|
306
|
-
writeFileSync(args["out-file"],
|
|
215
|
+
writeFileSync(args["out-file"], data.map((d) => d.body).join("\n"), "utf-8");
|
|
307
216
|
}
|
|
308
|
-
rendered = await renderAdPreviews(
|
|
217
|
+
const rendered = await renderAdPreviews(
|
|
218
|
+
data.map((d, i) => ({ placement: data.length > 1 ? `${adFormat}-${i + 1}` : adFormat, html: d.body })),
|
|
219
|
+
{
|
|
220
|
+
dir: args["out-dir"] ? String(args["out-dir"]) : AD_PREVIEW_DIR,
|
|
221
|
+
name: previewFileName({
|
|
222
|
+
adId: args["ad-id"],
|
|
223
|
+
creativeId: args["creative-id"],
|
|
224
|
+
creative: args.creative
|
|
225
|
+
})
|
|
226
|
+
}
|
|
227
|
+
);
|
|
228
|
+
const hints = placement ? [
|
|
229
|
+
`Rendered ${placement} as ad_format ${adFormat}. Meta does not document what it renders for a creative a placement cannot take, so the picture is the evidence.`,
|
|
230
|
+
...rendered.hints
|
|
231
|
+
] : rendered.hints;
|
|
232
|
+
writeJsonEnvelope({
|
|
233
|
+
ok: true,
|
|
234
|
+
data: { adFormat, previews: rendered.previews, ...args["out-file"] ? { file: args["out-file"] } : {} },
|
|
235
|
+
hints
|
|
236
|
+
});
|
|
309
237
|
} catch (err) {
|
|
310
238
|
handleMetaError(err);
|
|
311
239
|
}
|
|
312
|
-
const previews = rendered.previews.map((p, i) => ({ ...owners[i], ...p }));
|
|
313
|
-
for (const { index, entry } of refused.reverse()) previews.splice(index, 0, entry);
|
|
314
|
-
const hints = [
|
|
315
|
-
...placements.map(
|
|
316
|
-
(p, i) => `Rendered ${p} as ad_format ${formats[i]}. Meta does not document what it renders for a creative a placement cannot take, so the picture is the evidence.`
|
|
317
|
-
),
|
|
318
|
-
...rendered.hints,
|
|
319
|
-
...refused.length > 0 ? [
|
|
320
|
-
"Meta refused or returned nothing for some previews (each says why in its error). Say those could not be checked; the rest are real."
|
|
321
|
-
] : []
|
|
322
|
-
];
|
|
323
|
-
writeJsonEnvelope({
|
|
324
|
-
ok: true,
|
|
325
|
-
data: {
|
|
326
|
-
...formats.length === 1 ? { adFormat: formats[0] } : { adFormats: formats },
|
|
327
|
-
previews,
|
|
328
|
-
...args["out-file"] ? { file: args["out-file"] } : {}
|
|
329
|
-
},
|
|
330
|
-
hints
|
|
331
|
-
});
|
|
332
240
|
}
|
|
333
241
|
});
|
|
334
242
|
export {
|
|
335
243
|
previewCommand,
|
|
336
244
|
previewFileName
|
|
337
245
|
};
|
|
338
|
-
//# sourceMappingURL=preview-
|
|
246
|
+
//# sourceMappingURL=preview-4GUQGDBD.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/ads/meta/preview.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport { writeFileSync } from \"node:fs\";\nimport {\n FACEBOOK_PREVIEW_FORMATS,\n INSTAGRAM_PREVIEW_FORMATS,\n PLATFORM_SCOPED_POSITIONS,\n previewFormatForPosition,\n} from \"@baker/api/ads-meta\";\nimport { defineCommand } from \"citty\";\nimport { NO_CACHE_ARG } from \"../../../cache-flag.ts\";\nimport { apiPost } from \"../../../client.ts\";\nimport { AD_PREVIEW_DIR, AD_PREVIEW_DIR_LABEL, renderAdPreviews } from \"../ad-preview-images.ts\";\nimport { writeAdsJson, writeJsonEnvelope } from \"../output.ts\";\nimport { handleMetaError } from \"./shared.ts\";\n\n/**\n * The `ad_format` enum of `generatepreviews` as Meta's reference lists it (every value rendered live on v26.0, 2026-10-15)\n * (read 2026-10-14), plus INSTAGRAM_SHOP — dropped from that list yet still\n * rendered live the same day, so a format an older answer named keeps working.\n */\nconst VALID_AD_FORMATS = [\n \"AUDIENCE_NETWORK_INSTREAM_VIDEO\",\n \"AUDIENCE_NETWORK_INSTREAM_VIDEO_MOBILE\",\n \"AUDIENCE_NETWORK_OUTSTREAM_VIDEO\",\n \"AUDIENCE_NETWORK_REWARDED_VIDEO\",\n \"BIZ_DISCO_FEED_MOBILE\",\n \"DESKTOP_FEED_STANDARD\",\n \"FACEBOOK_IFU_REELS_MOBILE\",\n \"FACEBOOK_PROFILE_FEED_DESKTOP\",\n \"FACEBOOK_PROFILE_FEED_MOBILE\",\n \"FACEBOOK_PROFILE_REELS_MOBILE\",\n \"FACEBOOK_REELS_BANNER\",\n \"FACEBOOK_REELS_BANNER_DESKTOP\",\n \"FACEBOOK_REELS_BANNER_FEED_ANDROID\",\n \"FACEBOOK_REELS_BANNER_FEED_ANDROID_LARGE\",\n \"FACEBOOK_REELS_BANNER_FULLSCREEN_IOS\",\n \"FACEBOOK_REELS_BANNER_FULLSCREEN_MOBILE\",\n \"FACEBOOK_REELS_MOBILE\",\n \"FACEBOOK_REELS_POSTLOOP\",\n \"FACEBOOK_REELS_POSTLOOP_FEED\",\n \"FACEBOOK_REELS_SIMILAR_PRODUCTS_MOBILE\",\n \"FACEBOOK_REELS_STICKER\",\n \"FACEBOOK_STORY_MOBILE\",\n \"FACEBOOK_STORY_STICKER_MOBILE\",\n \"INSTAGRAM_EXPLORE_CONTEXTUAL\",\n \"INSTAGRAM_EXPLORE_GRID_HOME\",\n \"INSTAGRAM_EXPLORE_IMMERSIVE\",\n \"INSTAGRAM_FEED_WEB\",\n \"INSTAGRAM_FEED_WEB_M_SITE\",\n \"INSTAGRAM_LEAD_GEN_MULTI_SUBMIT_ADS\",\n \"INSTAGRAM_PROFILE_FEED\",\n \"INSTAGRAM_PROFILE_REELS\",\n \"INSTAGRAM_REELS\",\n \"INSTAGRAM_REELS_OVERLAY\",\n \"INSTAGRAM_REELS_WEB\",\n \"INSTAGRAM_REELS_WEB_M_SITE\",\n \"INSTAGRAM_SEARCH_CHAIN\",\n \"INSTAGRAM_SEARCH_GRID\",\n \"INSTAGRAM_SHOP\",\n \"INSTAGRAM_STANDARD\",\n \"INSTAGRAM_STORY\",\n \"INSTAGRAM_STORY_EFFECT_TRAY\",\n \"INSTAGRAM_STORY_WEB\",\n \"INSTAGRAM_STORY_WEB_M_SITE\",\n \"INSTANT_ARTICLE_RECIRCULATION_AD\",\n \"INSTANT_ARTICLE_STANDARD\",\n \"INSTREAM_BANNER_DESKTOP\",\n \"INSTREAM_BANNER_FEED_IOS\",\n \"INSTREAM_BANNER_FULLSCREEN_IOS\",\n \"INSTREAM_BANNER_FULLSCREEN_MOBILE\",\n \"INSTREAM_BANNER_IMMERSIVE_MOBILE\",\n \"INSTREAM_BANNER_MOBILE\",\n \"INSTREAM_VIDEO_DESKTOP\",\n \"INSTREAM_VIDEO_FULLSCREEN_IOS\",\n \"INSTREAM_VIDEO_FULLSCREEN_MOBILE\",\n \"INSTREAM_VIDEO_IMAGE\",\n \"INSTREAM_VIDEO_IMMERSIVE_MOBILE\",\n \"INSTREAM_VIDEO_MOBILE\",\n \"JOB_BROWSER_DESKTOP\",\n \"JOB_BROWSER_MOBILE\",\n \"MARKETPLACE_MOBILE\",\n \"MESSENGER_MOBILE_INBOX_MEDIA\",\n \"MESSENGER_MOBILE_STORY_MEDIA\",\n \"MOBILE_BANNER\",\n \"MOBILE_FEED_BASIC\",\n \"MOBILE_FEED_STANDARD\",\n \"MOBILE_FULLWIDTH\",\n \"MOBILE_INTERSTITIAL\",\n \"MOBILE_MEDIUM_RECTANGLE\",\n \"MOBILE_NATIVE\",\n \"RIGHT_COLUMN_STANDARD\",\n \"SUGGESTED_VIDEO_DESKTOP\",\n \"SUGGESTED_VIDEO_FULLSCREEN_MOBILE\",\n \"SUGGESTED_VIDEO_IMMERSIVE_MOBILE\",\n \"SUGGESTED_VIDEO_MOBILE\",\n \"WATCH_FEED_HOME\",\n \"WATCH_FEED_MOBILE\",\n \"WHATSAPP_STATUS_MEDIA\",\n];\n\n/** A bad flag is not a network failure — mislabelling it invites a retry of the same doomed call. */\nfunction failPreviewValidation(message: string): never {\n writeAdsJson({ ok: false, error: { code: \"VALIDATION_ERROR\", message } });\n process.exit(1);\n}\n\n/**\n * Preview is the free way to see what Meta actually renders for a creative in a\n * given surface — the check that turns \"this placement must be showing a still\"\n * from a claim into an observation. It was being used by guessing format names,\n * so both doors are open now: the Meta `ad_format` enum via `--ad-format`, and\n * the `platform_position` an insights breakdown reports via `--placement`.\n */\nfunction resolvePlacement(position: string, platform: unknown): string {\n const platformArg = typeof platform === \"string\" ? platform.toLowerCase() : undefined;\n if (platformArg && platformArg !== \"facebook\" && platformArg !== \"instagram\") {\n failPreviewValidation(\"--platform must be facebook or instagram\");\n }\n const format = previewFormatForPosition(position, platformArg);\n if (format) {\n return format;\n }\n if (PLATFORM_SCOPED_POSITIONS.has(position) && !platformArg) {\n failPreviewValidation(\n `--placement ${position} names a different surface on Facebook and on Instagram — add --platform facebook or --platform instagram (the breakdown row's publisher_platform)`,\n );\n }\n failPreviewValidation(\n `No Meta preview format is published for placement \"${position}\". Meta does not document one for every placement (facebook_notification among them), so this placement cannot be previewed — report it as unverified rather than inferring what it renders. Pass the platform_position exactly as the insights breakdown spelled it: targeting names a few surfaces differently (story, reels, explore_home) and those names never appear in a breakdown. Previewable placements: ${listPlacements()}`,\n );\n}\n\nfunction listPlacements(): string {\n const facebook = Object.keys(FACEBOOK_PREVIEW_FORMATS).join(\", \");\n const instagram = Object.keys(INSTAGRAM_PREVIEW_FORMATS).join(\", \");\n return `facebook — ${facebook}; instagram — ${instagram}`;\n}\n\n/** File name for a preview's picture. An unpublished spec has no id, so its content names it. */\nexport function previewFileName(target: { adId?: string; creativeId?: string; creative?: string }): string {\n const id = target.adId ?? target.creativeId;\n if (id) return `meta-${id}`;\n return `meta-draft-${createHash(\"sha256\")\n .update(target.creative ?? \"\")\n .digest(\"hex\")\n .slice(0, 12)}`;\n}\n\nexport const previewCommand = defineCommand({\n meta: {\n name: \"preview\",\n description: `See a creative or ad as Meta renders it in one placement: shownText (the text people see, in order)\nplus a picture to Read for what text cannot tell (words in the artwork, cropping, how it looks).\n--out-file also saves Meta's raw iframe HTML (its URL holds a short-lived access token — treat as secret).\n\nStart here before saying anything about how an ad LOOKS (which text shows, the headline under the\nimage, the button). Start here too when you need to know what a creative looks like in one specific placement — this is\nMeta's own renderer, so it settles \"does my video show as a still image there?\" without guessing.\nPass the placement straight from an insights breakdown with --placement (a platform_position value),\nor a Meta ad_format with --ad-format. Run --list-formats to see both sets.\n\nExamples:\n baker ads meta preview --creative-id 6123 --ad-format MOBILE_FEED_STANDARD\n baker ads meta preview --creative-id 6123 --placement facebook_reels_overlay --platform facebook\n baker ads meta preview --ad-id 9988 --ad-format INSTAGRAM_REELS --out-dir /tmp/review\n baker ads meta preview --account-id act_123 --creative '{\"object_story_spec\":{...}}' --ad-format MOBILE_FEED_STANDARD`,\n },\n args: {\n \"creative-id\": { type: \"string\", description: \"Existing creative ID\" },\n \"ad-id\": { type: \"string\", description: \"Existing ad ID\" },\n \"account-id\": { type: \"string\", description: \"Required when previewing an unpublished --creative spec\" },\n creative: { type: \"string\", description: \"JSON spec of an unpublished creative (e.g. object_story_spec)\" },\n \"ad-format\": { type: \"string\", description: \"Meta ad_format enum value (--list-formats to see them)\" },\n placement: {\n type: \"string\",\n description:\n \"platform_position from an insights breakdown (e.g. facebook_reels_overlay) — resolved to an ad_format\",\n },\n platform: { type: \"string\", description: \"facebook|instagram — required for --placement feed, which both report\" },\n \"list-formats\": { type: \"boolean\", description: \"Print the ad_format values and placement mappings, then exit\" },\n \"out-file\": { type: \"string\", description: \"Also save Meta's iframe HTML to this path\" },\n \"out-dir\": { type: \"string\", description: `Folder for the picture (default: ${AD_PREVIEW_DIR_LABEL})` },\n \"no-cache\": NO_CACHE_ARG,\n },\n run: async ({ args }) => {\n if (args[\"list-formats\"]) {\n writeAdsJson({\n ok: true,\n data: {\n adFormats: VALID_AD_FORMATS,\n placements: { facebook: FACEBOOK_PREVIEW_FORMATS, instagram: INSTAGRAM_PREVIEW_FORMATS },\n },\n });\n return;\n }\n\n const placement = args.placement as string | undefined;\n const adFormat = placement ? resolvePlacement(placement, args.platform) : (args[\"ad-format\"] as string);\n if (!adFormat) {\n failPreviewValidation(\"pass --ad-format or --placement (see --list-formats)\");\n }\n if (!VALID_AD_FORMATS.includes(adFormat)) {\n failPreviewValidation(\n `Invalid --ad-format \"${adFormat}\". Meta's ad_format values: ${VALID_AD_FORMATS.join(\", \")}. To preview a placement you saw in an insights breakdown, pass --placement <platform_position> instead of guessing a format name.`,\n );\n }\n const body: Record<string, unknown> = { adFormat };\n if (args[\"creative-id\"]) body.creativeId = args[\"creative-id\"];\n if (args[\"ad-id\"]) body.adId = args[\"ad-id\"];\n if (args[\"account-id\"]) body.accountId = args[\"account-id\"];\n if (args.creative) body.creative = args.creative;\n if (args[\"no-cache\"]) body.skipCache = true;\n\n try {\n const data = await apiPost<Array<{ body: string }>>(\"/api/ads/meta/preview\", body);\n if (args[\"out-file\"]) {\n writeFileSync(args[\"out-file\"] as string, data.map((d) => d.body).join(\"\\n\"), \"utf-8\");\n }\n const rendered = await renderAdPreviews(\n data.map((d, i) => ({ placement: data.length > 1 ? `${adFormat}-${i + 1}` : adFormat, html: d.body })),\n {\n dir: args[\"out-dir\"] ? String(args[\"out-dir\"]) : AD_PREVIEW_DIR,\n name: previewFileName({\n adId: args[\"ad-id\"] as string | undefined,\n creativeId: args[\"creative-id\"] as string | undefined,\n creative: args.creative as string | undefined,\n }),\n },\n );\n const hints = placement\n ? [\n `Rendered ${placement} as ad_format ${adFormat}. Meta does not document what it renders for a creative a placement cannot take, so the picture is the evidence.`,\n ...rendered.hints,\n ]\n : rendered.hints;\n writeJsonEnvelope({\n ok: true,\n data: { adFormat, previews: rendered.previews, ...(args[\"out-file\"] ? { file: args[\"out-file\"] } : {}) },\n hints,\n });\n } catch (err) {\n handleMetaError(err);\n }\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,kBAAkB;AAC3B,SAAS,qBAAqB;AAO9B,SAAS,qBAAqB;AAY9B,IAAM,mBAAmB;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA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AE,MAAM,KAAK,UAAU,EAAE,IAAI,CAAC,EAAG;AAAA,QACvG;AAAA,MACF,CAAC;AAAA,IACH,SAAS,KAAK;AACZ,sBAAgB,GAAG;AAAA,IACrB;AAAA,EACF;AACF,CAAC;","names":[]}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import {
|
|
2
|
+
handleLinkedinError,
|
|
3
|
+
resolveAccountIdArg
|
|
4
|
+
} from "./chunk-SBID6GZZ.js";
|
|
5
|
+
import {
|
|
6
|
+
AD_PREVIEW_DIR,
|
|
7
|
+
AD_PREVIEW_DIR_LABEL,
|
|
8
|
+
renderAdPreviews
|
|
9
|
+
} from "./chunk-BPIHAIWB.js";
|
|
10
|
+
import "./chunk-VN3WDB4O.js";
|
|
11
|
+
import {
|
|
12
|
+
writeJsonEnvelope
|
|
13
|
+
} from "./chunk-NX4EB2TK.js";
|
|
14
|
+
import "./chunk-JGXB7NBP.js";
|
|
15
|
+
import "./chunk-RJHGIRU2.js";
|
|
16
|
+
import "./chunk-WCU362Z6.js";
|
|
17
|
+
import "./chunk-P7YPWBEV.js";
|
|
18
|
+
import "./chunk-GIWHHCD6.js";
|
|
19
|
+
import "./chunk-PNGXJPM5.js";
|
|
20
|
+
import "./chunk-SOPVIIUW.js";
|
|
21
|
+
import "./chunk-G4FG5EQO.js";
|
|
22
|
+
import "./chunk-CS4VA3GQ.js";
|
|
23
|
+
import "./chunk-CVAQZO4I.js";
|
|
24
|
+
import {
|
|
25
|
+
apiPost
|
|
26
|
+
} from "./chunk-EHEPW3O2.js";
|
|
27
|
+
import "./chunk-4OF7Q356.js";
|
|
28
|
+
import "./chunk-RNSC5JPH.js";
|
|
29
|
+
import "./chunk-2RTB2DDO.js";
|
|
30
|
+
import "./chunk-YQSBHWOI.js";
|
|
31
|
+
|
|
32
|
+
// src/commands/ads/linkedin/preview.ts
|
|
33
|
+
import { writeFileSync } from "fs";
|
|
34
|
+
import { defineCommand } from "citty";
|
|
35
|
+
var previewCommand = defineCommand({
|
|
36
|
+
meta: {
|
|
37
|
+
name: "preview",
|
|
38
|
+
description: `See an existing LinkedIn ad exactly as people see it in the feed \u2014 LinkedIn's own renderer,
|
|
39
|
+
for desktop and mobile. Returns shownText (the text displayed, in order) and a picture of each;
|
|
40
|
+
Read the picture only for what text cannot tell (words in the artwork, cropping, how it looks).
|
|
41
|
+
|
|
42
|
+
Start here before saying anything about how an ad LOOKS (which text shows, whether the headline
|
|
43
|
+
appears under the image, what the button says): the API fields say what is stored, the preview
|
|
44
|
+
shows what is displayed. Works for single image, carousel, video, event and job ads that already
|
|
45
|
+
exist on LinkedIn; staged (unpublished) ads have no preview yet.
|
|
46
|
+
|
|
47
|
+
Examples:
|
|
48
|
+
baker ads linkedin preview 1611562694 --account-id 503001492
|
|
49
|
+
baker ads linkedin preview 1611562694 --placement mobile
|
|
50
|
+
baker ads linkedin preview 1611562694 --out-dir /tmp/review`
|
|
51
|
+
},
|
|
52
|
+
args: {
|
|
53
|
+
id: { type: "positional", description: "Creative id or urn:li:sponsoredCreative:N", required: true },
|
|
54
|
+
"account-id": { type: "string", description: "Numeric account ID or urn:li:sponsoredAccount:N" },
|
|
55
|
+
"account-urn": { type: "string", description: "Alias for --account-id" },
|
|
56
|
+
placement: { type: "string", description: "desktop|mobile|both (default: both)", default: "both" },
|
|
57
|
+
"out-dir": { type: "string", description: `Folder for the pictures (default: ${AD_PREVIEW_DIR_LABEL})` },
|
|
58
|
+
"html-file": { type: "string", description: "Also save LinkedIn's raw preview iframes to this file" }
|
|
59
|
+
},
|
|
60
|
+
run: async ({ args }) => {
|
|
61
|
+
const accountId = resolveAccountIdArg(args);
|
|
62
|
+
const placement = String(args.placement);
|
|
63
|
+
if (!["desktop", "mobile", "both"].includes(placement)) {
|
|
64
|
+
writeJsonEnvelope({
|
|
65
|
+
ok: false,
|
|
66
|
+
error: { code: "VALIDATION_ERROR", message: "--placement must be desktop, mobile or both" }
|
|
67
|
+
});
|
|
68
|
+
process.exit(1);
|
|
69
|
+
}
|
|
70
|
+
try {
|
|
71
|
+
const body = { accountId, creativeId: String(args.id) };
|
|
72
|
+
const data = await apiPost("/api/ads/linkedin/preview", body);
|
|
73
|
+
const wanted = data.previews.filter((p) => placement === "both" || p.placement === placement);
|
|
74
|
+
if (wanted.length === 0) {
|
|
75
|
+
writeJsonEnvelope({
|
|
76
|
+
ok: true,
|
|
77
|
+
data: { creativeId: data.creativeId, previews: [] },
|
|
78
|
+
hints: [
|
|
79
|
+
"LinkedIn returned no preview for this ad (its format may not support one). Say its look could not be checked; do not describe it from the API fields."
|
|
80
|
+
]
|
|
81
|
+
});
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (args["html-file"]) {
|
|
85
|
+
writeFileSync(String(args["html-file"]), wanted.map((p) => p.html).join("\n"), "utf-8");
|
|
86
|
+
}
|
|
87
|
+
const rendered = await renderAdPreviews(wanted, {
|
|
88
|
+
dir: args["out-dir"] ? String(args["out-dir"]) : AD_PREVIEW_DIR,
|
|
89
|
+
name: `linkedin-${data.creativeId}`
|
|
90
|
+
});
|
|
91
|
+
writeJsonEnvelope({
|
|
92
|
+
ok: true,
|
|
93
|
+
data: { creativeId: data.creativeId, previews: rendered.previews },
|
|
94
|
+
hints: rendered.hints
|
|
95
|
+
});
|
|
96
|
+
} catch (err) {
|
|
97
|
+
handleLinkedinError(err);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
export {
|
|
102
|
+
previewCommand
|
|
103
|
+
};
|
|
104
|
+
//# sourceMappingURL=preview-HD3QAR53.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/ads/linkedin/preview.ts"],"sourcesContent":["import { writeFileSync } from \"node:fs\";\nimport type { LinkedinAdPreviewRequest, LinkedinAdPreviewResponse } from \"@baker/api/ads-linkedin/preview\";\nimport { defineCommand } from \"citty\";\nimport { apiPost } from \"../../../client.ts\";\nimport { AD_PREVIEW_DIR, AD_PREVIEW_DIR_LABEL, renderAdPreviews } from \"../ad-preview-images.ts\";\nimport { writeJsonEnvelope } from \"../output.ts\";\nimport { handleLinkedinError, resolveAccountIdArg } from \"./shared.ts\";\n\nexport const previewCommand = defineCommand({\n meta: {\n name: \"preview\",\n description: `See an existing LinkedIn ad exactly as people see it in the feed — LinkedIn's own renderer,\nfor desktop and mobile. Returns shownText (the text displayed, in order) and a picture of each;\nRead the picture only for what text cannot tell (words in the artwork, cropping, how it looks).\n\nStart here before saying anything about how an ad LOOKS (which text shows, whether the headline\nappears under the image, what the button says): the API fields say what is stored, the preview\nshows what is displayed. Works for single image, carousel, video, event and job ads that already\nexist on LinkedIn; staged (unpublished) ads have no preview yet.\n\nExamples:\n baker ads linkedin preview 1611562694 --account-id 503001492\n baker ads linkedin preview 1611562694 --placement mobile\n baker ads linkedin preview 1611562694 --out-dir /tmp/review`,\n },\n args: {\n id: { type: \"positional\", description: \"Creative id or urn:li:sponsoredCreative:N\", required: true },\n \"account-id\": { type: \"string\", description: \"Numeric account ID or urn:li:sponsoredAccount:N\" },\n \"account-urn\": { type: \"string\", description: \"Alias for --account-id\" },\n placement: { type: \"string\", description: \"desktop|mobile|both (default: both)\", default: \"both\" },\n \"out-dir\": { type: \"string\", description: `Folder for the pictures (default: ${AD_PREVIEW_DIR_LABEL})` },\n \"html-file\": { type: \"string\", description: \"Also save LinkedIn's raw preview iframes to this file\" },\n },\n run: async ({ args }) => {\n const accountId = resolveAccountIdArg(args);\n const placement = String(args.placement);\n if (![\"desktop\", \"mobile\", \"both\"].includes(placement)) {\n writeJsonEnvelope({\n ok: false,\n error: { code: \"VALIDATION_ERROR\", message: \"--placement must be desktop, mobile or both\" },\n });\n process.exit(1);\n }\n try {\n const body: LinkedinAdPreviewRequest = { accountId, creativeId: String(args.id) };\n const data = await apiPost<LinkedinAdPreviewResponse>(\"/api/ads/linkedin/preview\", body);\n const wanted = data.previews.filter((p) => placement === \"both\" || p.placement === placement);\n if (wanted.length === 0) {\n writeJsonEnvelope({\n ok: true,\n data: { creativeId: data.creativeId, previews: [] },\n hints: [\n \"LinkedIn returned no preview for this ad (its format may not support one). Say its look could not be checked; do not describe it from the API fields.\",\n ],\n });\n return;\n }\n if (args[\"html-file\"]) {\n writeFileSync(String(args[\"html-file\"]), wanted.map((p) => p.html).join(\"\\n\"), \"utf-8\");\n }\n const rendered = await renderAdPreviews(wanted, {\n dir: args[\"out-dir\"] ? String(args[\"out-dir\"]) : AD_PREVIEW_DIR,\n name: `linkedin-${data.creativeId}`,\n });\n writeJsonEnvelope({\n ok: true,\n data: { creativeId: data.creativeId, previews: rendered.previews },\n hints: rendered.hints,\n });\n } catch (err) {\n handleLinkedinError(err);\n }\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,qBAAqB;AAE9B,SAAS,qBAAqB;AAMvB,IAAM,iBAAiB,cAAc;AAAA,EAC1C,MAAM;AAAA,IACJ,MAAM;AAAA,IACN,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaf;AAAA,EACA,MAAM;AAAA,IACJ,IAAI,EAAE,MAAM,cAAc,aAAa,6CAA6C,UAAU,KAAK;AAAA,IACnG,cAAc,EAAE,MAAM,UAAU,aAAa,kDAAkD;AAAA,IAC/F,eAAe,EAAE,MAAM,UAAU,aAAa,yBAAyB;AAAA,IACvE,WAAW,EAAE,MAAM,UAAU,aAAa,uCAAuC,SAAS,OAAO;AAAA,IACjG,WAAW,EAAE,MAAM,UAAU,aAAa,qCAAqC,oBAAoB,IAAI;AAAA,IACvG,aAAa,EAAE,MAAM,UAAU,aAAa,wDAAwD;AAAA,EACtG;AAAA,EACA,KAAK,OAAO,EAAE,KAAK,MAAM;AACvB,UAAM,YAAY,oBAAoB,IAAI;AAC1C,UAAM,YAAY,OAAO,KAAK,SAAS;AACvC,QAAI,CAAC,CAAC,WAAW,UAAU,MAAM,EAAE,SAAS,SAAS,GAAG;A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-7JM5OH6I.js";
|
|
5
5
|
import "./chunk-5TURKO4J.js";
|
|
6
6
|
import "./chunk-NYUWPJ4K.js";
|
|
7
7
|
import "./chunk-NKQWDEB7.js";
|
|
@@ -100,4 +100,4 @@ var questionnaireCommand = defineCommand({
|
|
|
100
100
|
export {
|
|
101
101
|
questionnaireCommand
|
|
102
102
|
};
|
|
103
|
-
//# sourceMappingURL=questionnaire-
|
|
103
|
+
//# sourceMappingURL=questionnaire-AFTRG3QM.js.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ConversionArgsError,
|
|
3
3
|
onlyOnce
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-KFFAH3TX.js";
|
|
5
5
|
import {
|
|
6
6
|
sendsRequestSchema
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-7JM5OH6I.js";
|
|
8
8
|
import "./chunk-5TURKO4J.js";
|
|
9
9
|
import {
|
|
10
10
|
SEND_PLATFORMS,
|
|
@@ -402,4 +402,4 @@ export {
|
|
|
402
402
|
sendsView,
|
|
403
403
|
sendsWrite
|
|
404
404
|
};
|
|
405
|
-
//# sourceMappingURL=sends-
|
|
405
|
+
//# sourceMappingURL=sends-V4MRXQSO.js.map
|
|
@@ -5,13 +5,13 @@ import {
|
|
|
5
5
|
import {
|
|
6
6
|
hubspotRefusal
|
|
7
7
|
} from "./chunk-D4MNDYPX.js";
|
|
8
|
-
import "./chunk-
|
|
8
|
+
import "./chunk-6SMIAFH2.js";
|
|
9
9
|
import {
|
|
10
10
|
ConversionArgsError,
|
|
11
11
|
onlyOnce
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-KFFAH3TX.js";
|
|
13
13
|
import "./chunk-GRQ2AXDX.js";
|
|
14
|
-
import "./chunk-
|
|
14
|
+
import "./chunk-7JM5OH6I.js";
|
|
15
15
|
import "./chunk-5TURKO4J.js";
|
|
16
16
|
import "./chunk-NYUWPJ4K.js";
|
|
17
17
|
import {
|
|
@@ -467,4 +467,4 @@ export {
|
|
|
467
467
|
sourcesCommand,
|
|
468
468
|
sourcesRequest
|
|
469
469
|
};
|
|
470
|
-
//# sourceMappingURL=sources-
|
|
470
|
+
//# sourceMappingURL=sources-OTOVMOJ5.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
analyticsErrorEnvelope
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-VMZ2XBU7.js";
|
|
4
4
|
import {
|
|
5
5
|
ANALYTICS_UNSTAGE_KINDS
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-7JM5OH6I.js";
|
|
7
7
|
import "./chunk-5TURKO4J.js";
|
|
8
8
|
import "./chunk-NYUWPJ4K.js";
|
|
9
9
|
import "./chunk-NKQWDEB7.js";
|
|
@@ -98,4 +98,4 @@ export {
|
|
|
98
98
|
unstageBody,
|
|
99
99
|
unstageCommand
|
|
100
100
|
};
|
|
101
|
-
//# sourceMappingURL=unstage-
|
|
101
|
+
//# sourceMappingURL=unstage-E32YHRML.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
mappingCommandFor,
|
|
3
3
|
proposeMappingFromTemplate
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-7JM5OH6I.js";
|
|
5
5
|
import "./chunk-5TURKO4J.js";
|
|
6
6
|
import {
|
|
7
7
|
parseApiError
|
|
@@ -134,4 +134,4 @@ Examples:
|
|
|
134
134
|
export {
|
|
135
135
|
urlOptionsCommand
|
|
136
136
|
};
|
|
137
|
-
//# sourceMappingURL=url-options-
|
|
137
|
+
//# sourceMappingURL=url-options-ETN75DT5.js.map
|
package/package.json
CHANGED