@koda-sl/baker-cli 0.868.0-dev.ebaaca9d0 → 0.869.0-dev.0631d8a3c
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/{account-assets-4EFV6A2D.js → account-assets-L6BX4YUQ.js} +6 -6
- package/dist/{account-level-7UOXIAB7.js → account-level-OX34JQ7C.js} +3 -3
- package/dist/{ads-B4HSLQMP.js → ads-VSU53JN3.js} +3 -3
- package/dist/{ads-FQKWQBVZ.js → ads-ZR5D7BZT.js} +10 -10
- package/dist/{adsets-BG3KZ53Y.js → adsets-3NIYL2GQ.js} +9 -9
- package/dist/{asset-writes-55AP6IJM.js → asset-writes-5ZKZDPQ4.js} +3 -3
- package/dist/{audience-writes-USX37PPI.js → audience-writes-NL6NRLLY.js} +2 -2
- package/dist/{audiences-G4GJZUIT.js → audiences-DL267GNQ.js} +6 -6
- package/dist/{campaigns-DNA7TN2T.js → campaigns-RXDC5FSQ.js} +9 -9
- package/dist/{catalogs-7AG7YVMI.js → catalogs-QAZ7ZZ5R.js} +2 -2
- package/dist/{chunk-SXKBGTX2.js → chunk-EGM42UKF.js} +2 -2
- package/dist/{chunk-ATVUGOXL.js → chunk-OMJ7DVFJ.js} +4 -5
- package/dist/{chunk-ATVUGOXL.js.map → chunk-OMJ7DVFJ.js.map} +1 -1
- package/dist/{chunk-J43KP5NE.js → chunk-UE5ZFTDL.js} +2 -2
- package/dist/{chunk-BPIHAIWB.js → chunk-XFTN3ARP.js} +22 -13
- package/dist/chunk-XFTN3ARP.js.map +1 -0
- package/dist/cli.js +1 -1
- package/dist/{copy-writes-NJSSVTGB.js → copy-writes-QYN6PBU2.js} +3 -3
- package/dist/{creatives-4AD65R3V.js → creatives-CPLH3KHQ.js} +4 -4
- package/dist/{custom-conversions-BDXRIYJW.js → custom-conversions-CTJVAZKC.js} +4 -4
- package/dist/{draft-ZUM2WKWP.js → draft-UU3F2VMJ.js} +8 -203
- package/dist/draft-UU3F2VMJ.js.map +1 -0
- package/dist/{instant-experiences-JBN26DUT.js → instant-experiences-EJWYFWDT.js} +2 -2
- package/dist/{leads-YWURF6YR.js → leads-FEEWX7OO.js} +2 -2
- package/dist/{linkedin-EBOTX37R.js → linkedin-RMZMQ2ZA.js} +8 -4
- package/dist/{linkedin-EBOTX37R.js.map → linkedin-RMZMQ2ZA.js.map} +1 -1
- package/dist/{media-BITGRDCO.js → media-PUOLJUN3.js} +3 -3
- package/dist/{meta-MY2CIGLA.js → meta-HOFABFAK.js} +31 -31
- package/dist/{page-photos-ZP7APYIE.js → page-photos-ZBMJLL5V.js} +2 -2
- package/dist/preview-4DDR337D.js +151 -0
- package/dist/preview-4DDR337D.js.map +1 -0
- package/dist/{preview-4GUQGDBD.js → preview-XXQ5AHXP.js} +134 -42
- package/dist/preview-XXQ5AHXP.js.map +1 -0
- package/dist/{rule-writes-GE5URXYA.js → rule-writes-6XP7G35U.js} +2 -2
- package/dist/{rules-6O5ALFJD.js → rules-BRULCGRV.js} +7 -7
- package/dist/{studies-LZ4RWESW.js → studies-357M2C2K.js} +5 -5
- package/dist/{study-writes-3WXJDSDU.js → study-writes-HXUQRPIK.js} +2 -2
- package/dist/{targeting-DEM7YHWM.js → targeting-7T7XHBIX.js} +2 -2
- package/dist/{write-commands-EQU4U746.js → write-commands-4KI6T2NF.js} +4 -4
- package/package.json +1 -1
- package/dist/chunk-BPIHAIWB.js.map +0 -1
- package/dist/draft-ZUM2WKWP.js.map +0 -1
- package/dist/preview-4GUQGDBD.js.map +0 -1
- package/dist/preview-HD3QAR53.js +0 -104
- package/dist/preview-HD3QAR53.js.map +0 -1
- /package/dist/{account-assets-4EFV6A2D.js.map → account-assets-L6BX4YUQ.js.map} +0 -0
- /package/dist/{account-level-7UOXIAB7.js.map → account-level-OX34JQ7C.js.map} +0 -0
- /package/dist/{ads-B4HSLQMP.js.map → ads-VSU53JN3.js.map} +0 -0
- /package/dist/{ads-FQKWQBVZ.js.map → ads-ZR5D7BZT.js.map} +0 -0
- /package/dist/{adsets-BG3KZ53Y.js.map → adsets-3NIYL2GQ.js.map} +0 -0
- /package/dist/{asset-writes-55AP6IJM.js.map → asset-writes-5ZKZDPQ4.js.map} +0 -0
- /package/dist/{audience-writes-USX37PPI.js.map → audience-writes-NL6NRLLY.js.map} +0 -0
- /package/dist/{audiences-G4GJZUIT.js.map → audiences-DL267GNQ.js.map} +0 -0
- /package/dist/{campaigns-DNA7TN2T.js.map → campaigns-RXDC5FSQ.js.map} +0 -0
- /package/dist/{catalogs-7AG7YVMI.js.map → catalogs-QAZ7ZZ5R.js.map} +0 -0
- /package/dist/{chunk-SXKBGTX2.js.map → chunk-EGM42UKF.js.map} +0 -0
- /package/dist/{chunk-J43KP5NE.js.map → chunk-UE5ZFTDL.js.map} +0 -0
- /package/dist/{copy-writes-NJSSVTGB.js.map → copy-writes-QYN6PBU2.js.map} +0 -0
- /package/dist/{creatives-4AD65R3V.js.map → creatives-CPLH3KHQ.js.map} +0 -0
- /package/dist/{custom-conversions-BDXRIYJW.js.map → custom-conversions-CTJVAZKC.js.map} +0 -0
- /package/dist/{instant-experiences-JBN26DUT.js.map → instant-experiences-EJWYFWDT.js.map} +0 -0
- /package/dist/{leads-YWURF6YR.js.map → leads-FEEWX7OO.js.map} +0 -0
- /package/dist/{media-BITGRDCO.js.map → media-PUOLJUN3.js.map} +0 -0
- /package/dist/{meta-MY2CIGLA.js.map → meta-HOFABFAK.js.map} +0 -0
- /package/dist/{page-photos-ZP7APYIE.js.map → page-photos-ZBMJLL5V.js.map} +0 -0
- /package/dist/{rule-writes-GE5URXYA.js.map → rule-writes-6XP7G35U.js.map} +0 -0
- /package/dist/{rules-6O5ALFJD.js.map → rules-BRULCGRV.js.map} +0 -0
- /package/dist/{studies-LZ4RWESW.js.map → studies-357M2C2K.js.map} +0 -0
- /package/dist/{study-writes-3WXJDSDU.js.map → study-writes-HXUQRPIK.js.map} +0 -0
- /package/dist/{targeting-DEM7YHWM.js.map → targeting-7T7XHBIX.js.map} +0 -0
- /package/dist/{write-commands-EQU4U746.js.map → write-commands-4KI6T2NF.js.map} +0 -0
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
loadJsonFileArg,
|
|
6
6
|
requireTarget,
|
|
7
7
|
stageOp
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-OMJ7DVFJ.js";
|
|
9
9
|
import "./chunk-3R62EYYX.js";
|
|
10
10
|
import "./chunk-GDFJOCDO.js";
|
|
11
11
|
import "./chunk-DP76WGDV.js";
|
|
@@ -472,4 +472,4 @@ export {
|
|
|
472
472
|
studiesUpdateCommand,
|
|
473
473
|
studyFlagsFromArgs
|
|
474
474
|
};
|
|
475
|
-
//# sourceMappingURL=study-writes-
|
|
475
|
+
//# sourceMappingURL=study-writes-HXUQRPIK.js.map
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from "./chunk-PRPSV4VB.js";
|
|
5
5
|
import {
|
|
6
6
|
loadJsonFileArg
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-OMJ7DVFJ.js";
|
|
8
8
|
import {
|
|
9
9
|
metaTargetingSchema
|
|
10
10
|
} from "./chunk-3R62EYYX.js";
|
|
@@ -774,4 +774,4 @@ Start here before writing interests, behaviors, places or languages into an ad s
|
|
|
774
774
|
export {
|
|
775
775
|
targetingCommand
|
|
776
776
|
};
|
|
777
|
-
//# sourceMappingURL=targeting-
|
|
777
|
+
//# sourceMappingURL=targeting-7T7XHBIX.js.map
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
budgetBoostsFromFlags,
|
|
8
8
|
clearArg,
|
|
9
9
|
clearFromFlags
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-EGM42UKF.js";
|
|
11
11
|
import {
|
|
12
12
|
bareAccountId,
|
|
13
13
|
failWriteValidation,
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
stageOp,
|
|
26
26
|
stageStatusChange,
|
|
27
27
|
upper
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-OMJ7DVFJ.js";
|
|
29
29
|
import {
|
|
30
30
|
buildCustomConversionRule
|
|
31
31
|
} from "./chunk-3R62EYYX.js";
|
|
@@ -481,7 +481,7 @@ Example: baker ads meta adsets create --campaign 6123 --name "Reach ES" --optimi
|
|
|
481
481
|
const file = loadJsonFileArg(args.file);
|
|
482
482
|
const payload = mergePayload(file, adSetPayloadFromFlags(args, rawArgs, file));
|
|
483
483
|
if (args["saved-audience"]) {
|
|
484
|
-
const { savedAudienceTargeting, targetingFromSavedAudience } = await import("./audience-writes-
|
|
484
|
+
const { savedAudienceTargeting, targetingFromSavedAudience } = await import("./audience-writes-NL6NRLLY.js");
|
|
485
485
|
const saved = await savedAudienceTargeting(accountId, String(args["saved-audience"]));
|
|
486
486
|
const merged = targetingFromSavedAudience(saved, payload.targeting);
|
|
487
487
|
if ("refusal" in merged) failWriteValidation(merged.refusal);
|
|
@@ -1258,4 +1258,4 @@ export {
|
|
|
1258
1258
|
retagSetPairs,
|
|
1259
1259
|
targetingFromFlags
|
|
1260
1260
|
};
|
|
1261
|
-
//# sourceMappingURL=write-commands-
|
|
1261
|
+
//# sourceMappingURL=write-commands-4KI6T2NF.js.map
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/commands/ads/ad-preview-images.ts"],"sourcesContent":["import { mkdirSync } from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { launchBrowser } from \"../../engine/landing-library/browser.ts\";\n\n/**\n * Opens a platform's preview iframe and returns what it displays: the text\n * people read (`shownText`) and a picture for questions text cannot answer.\n *\n * The API's fields say what is stored, not what shows. A Session paused seven\n * live ads because a stored headline read like an internal code, with no way to\n * check whether the feed showed it. The rendered text settles that; the picture\n * covers what is not text — words drawn into the artwork, cropping, layout.\n */\n\nexport interface AdPreviewInput {\n placement: string;\n /** Where the platform shows it (LinkedIn FEED, …) when one placement renders on several surfaces. */\n surface?: string;\n html: string;\n}\n\ntype AdPreviewWhere = { placement: string; surface?: string };\nexport type AdPreviewResult =\n | (AdPreviewWhere & { shownText: string[]; image: string })\n | (AdPreviewWhere & { error: string });\n\n/** Render `html` (a platform iframe): save a PNG at `file`, return the text it displays. */\nexport type DrawPreview = (html: string, file: string) => Promise<{ text: string }>;\n\nexport const AD_PREVIEW_DIR = join(tmpdir(), \"baker-ad-previews\");\n\n/**\n * The same folder as a sentence, for an arg description.\n *\n * `AD_PREVIEW_DIR` itself must never reach one: it is `tmpdir()` RESOLVED, which is\n * `/tmp/baker-ad-previews` on Linux and `/var/folders/<random>/T/baker-ad-previews` on a Mac — so\n * `catalog:export` wrote whichever machine ran it into `cli-catalog/families/ads-meta.json`, and\n * `catalog.test.ts` then failed for everyone else. The catalog is committed, so a description in it\n * has to be the same on every machine.\n */\nexport const AD_PREVIEW_DIR_LABEL = \"your system temp folder, under baker-ad-previews\";\n\nexport async function renderAdPreviews(\n inputs: readonly AdPreviewInput[],\n target: { dir: string; name: string },\n draw: DrawPreview = drawPreviewInChromium,\n): Promise<{ previews: AdPreviewResult[]; hints: string[] }> {\n mkdirSync(target.dir, { recursive: true });\n const previews: AdPreviewResult[] = [];\n const taken = new Map<string, number>();\n for (const input of inputs) {\n const where: AdPreviewWhere = input.surface\n ? { placement: input.placement, surface: input.surface }\n : { placement: input.placement };\n // One file per rendering: a shared name would leave two results pointing at the last picture drawn.\n const base = [target.name, input.placement, input.surface?.toLowerCase()].filter(Boolean).join(\"-\");\n const seen = (taken.get(base) ?? 0) + 1;\n taken.set(base, seen);\n const file = join(target.dir, `${seen > 1 ? `${base}-${seen}` : base}.png`);\n try {\n const { text } = await draw(input.html, file);\n previews.push({ ...where, shownText: shownLines(text), image: file });\n } catch (err) {\n previews.push({ ...where, error: err instanceof Error ? err.message : String(err) });\n }\n }\n return { previews, hints: previewHints(previews) };\n}\n\nfunction shownLines(text: string): string[] {\n return text\n .split(\"\\n\")\n .map((line) => line.replace(/\\s+/g, \" \").trim())\n .filter(Boolean);\n}\n\nfunction previewHints(previews: readonly AdPreviewResult[]): string[] {\n const hints: string[] = [];\n if (previews.some((p) => \"image\" in p)) {\n hints.push(\n \"shownText is what people see on the ad, in order — rendered by the platform itself, so it settles which text is displayed (headline under the image, button, cut-off intro). The API fields only say what is stored. Words drawn into the artwork are not in shownText: Read the image for those, and for cropping or how the ad looks.\",\n );\n }\n if (previews.some((p) => \"error\" in p)) {\n hints.push(\n \"Some previews could not be drawn. Do not describe how those look — say they could not be checked, and carry on with the rest.\",\n );\n }\n return hints;\n}\n\n/**\n * The platforms' iframes have a fixed window (Meta's 335×450) and scroll the rest,\n * which cuts the headline and button off a picture. The frame is grown to its\n * content's height first, so the picture holds the whole ad.\n */\nexport async function drawPreviewInChromium(html: string, file: string): Promise<{ text: string }> {\n const browser = await launchBrowser();\n try {\n const context = await browser.newContext({ viewport: { width: 900, height: 1200 }, deviceScaleFactor: 2 });\n const page = await context.newPage();\n await page.setContent(`<!doctype html><body style=\"margin:0;background:#fff\">${html}</body>`, {\n waitUntil: \"load\",\n timeout: 30_000,\n });\n await page.waitForLoadState(\"networkidle\", { timeout: 15_000 }).catch(() => undefined);\n const iframe = await page.$(\"iframe\");\n if (!iframe) throw new Error(\"the platform returned no preview frame\");\n const frame = await iframe.contentFrame();\n if (frame) {\n const height = await frame.evaluate(() =>\n Math.max(document.documentElement.scrollHeight, document.body?.scrollHeight ?? 0),\n );\n if (height > 0) {\n await iframe.evaluate((node, h) => {\n node.removeAttribute(\"height\");\n (node as HTMLElement).style.height = `${h}px`;\n }, height);\n await frame.waitForLoadState(\"networkidle\", { timeout: 10_000 }).catch(() => undefined);\n }\n }\n await iframe.screenshot({ path: file });\n // innerText follows the layout: hidden elements drop out, line breaks stay.\n const text = frame ? await frame.evaluate(() => document.body?.innerText ?? \"\") : \"\";\n return { text };\n } finally {\n await browser.close();\n }\n}\n"],"mappings":";;;;;AAAA,SA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SAAS,MAAM,SAAS,MAAM,aAAa,EAAE,IAAI;AAClF,WAAO,EAAE,KAAK;AAAA,EAChB,UAAE;AACA,UAAM,QAAQ,MAAM;AAAA,EACtB;AACF;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/commands/ads/meta/draft.ts","../src/commands/ads/meta/draft-stage.ts","../src/commands/ads/meta/draft-status.ts"],"sourcesContent":["import type {\n MetaDraftClearResponse,\n MetaDraftListResponse,\n MetaDraftRemoveResponse,\n MetaDraftShowResponse,\n} from \"@baker/api/ads-meta\";\nimport { defineCommand } from \"citty\";\nimport { apiPost } from \"../../../client.ts\";\nimport { requireChatId, resolveChatId } from \"../../../env.ts\";\nimport { registerSchema, withEffect } from \"../../../schemas.ts\";\nimport { CHAT_READ_ARG, DRAFT_FULL_ARG } from \"../../chat-arg.ts\";\nimport { draftRefs, removeDraftRefs } from \"../../draft-refs.ts\";\nimport { draftListWhere, LIST_WHERE_ARG, requireDraftWhere, wholeDraftHints } from \"../../draft-where.ts\";\nimport { SHOW_FULL_ARG, showEnvelope } from \"../draft-show.ts\";\nimport { hintLines, withHints } from \"../hints.ts\";\nimport { writeJsonEnvelope } from \"../output.ts\";\nimport { draftStageCommand } from \"./draft-stage.ts\";\nimport { renderDraftStatus } from \"./draft-status.ts\";\nimport { handleMetaError } from \"./shared.ts\";\n\nregisterSchema({\n command: \"ads.meta.draft\",\n routes: [\"POST /api/ads/meta/draft\"],\n effect: \"read\",\n description:\n \"Review every Meta op staged on this chat, one line each: ref · kind · summary · the ad set (or campaign) a staged ad (or ad set) goes into with the status it publishes under · what it waits on · ✗ blocked: <why> when publish would now refuse it, and after a publish ✓ applied → id or ✗ failed: <error>. `draft show <ref>` prints one op's payload (--full for lists over 50 items).\",\n args: {\n json: { type: \"boolean\", description: \"Raw JSON envelope instead of the readable list\", required: false },\n full: { type: \"boolean\", description: DRAFT_FULL_ARG.description, required: false },\n chat: { type: \"string\", description: \"Read another chat's draft instead of this one\", required: false },\n where: LIST_WHERE_ARG,\n },\n});\n\n/**\n * The readable one-line-per-op view is the default, like the Google, LinkedIn and X drafts;\n * `--json` (or `--output json`) returns the raw envelope for tools.\n */\nasync function listDraft(json: boolean, chat?: unknown, full = false, selector?: string): Promise<void> {\n const where = selector === undefined ? undefined : requireDraftWhere(selector);\n try {\n const chatId = resolveChatId(chat);\n const response = await apiPost<{ ok: boolean; data?: MetaDraftListResponse }>(\"/api/ads/meta/draft\", {\n chatId,\n ...(full || where ? { full: true } : {}),\n });\n if (where && selector !== undefined && response.ok && response.data) {\n const narrowed = draftListWhere(response.data, where, selector);\n writeJsonEnvelope(withHints({ ...response, data: narrowed.data }, narrowed.hints));\n return;\n }\n if (json || full || !response.ok || !response.data) {\n const whole = response.ok && response.data ? wholeDraftHints(response.data.ops, \"baker ads meta draft list\") : [];\n writeJsonEnvelope(withHints(response, whole));\n return;\n }\n process.stdout.write(`${renderDraftStatus(response.data)}${hintLines(response)}\\n`);\n } catch (err) {\n handleMetaError(err);\n }\n}\n\nconst listCommand = defineCommand({\n meta: {\n name: \"list\",\n description:\n \"Show every Meta write op staged in this chat, one line each (ref · kind · summary · parent ad set or campaign and its status · dependencies · post-publish result), with staged ads counted by their ad set's status; --json for the raw envelope, --full for every op's payload too. Publishing reaches the real ad account, so review this before you finish. Example: baker ads meta draft\",\n },\n args: {\n json: { type: \"boolean\", description: \"Print the raw JSON envelope instead of the readable list\" },\n full: DRAFT_FULL_ARG,\n chat: CHAT_READ_ARG,\n where: LIST_WHERE_ARG,\n },\n run: async ({ args }) => {\n await listDraft(\n args.json === true,\n args.chat,\n args.full === true,\n typeof args.where === \"string\" ? args.where : undefined,\n );\n },\n});\n\nconst showCommand = defineCommand({\n meta: {\n name: \"show\",\n description:\n \"Print the staged payload for one op — the receipt to verify a change looks right before publish. A list longer than 50 items (a customer list's members) prints as its count; --full prints every item. Example: baker ads meta draft show meta_temp_abc123\",\n },\n args: {\n ref: { type: \"positional\", description: \"Op ref (meta_temp_* for creates, target id for updates)\", required: true },\n // `show` always prints the envelope; `--json` is the spelling `list` taught, so it is accepted here too.\n json: { type: \"boolean\", description: \"Accepted for symmetry with list; show always prints the JSON envelope\" },\n chat: CHAT_READ_ARG,\n full: SHOW_FULL_ARG,\n },\n run: async ({ args }) => {\n try {\n const chatId = resolveChatId(args.chat);\n const response = await apiPost<{ ok: true; data: MetaDraftShowResponse }>(\"/api/ads/meta/draft/show\", {\n chatId,\n ref: args.ref,\n });\n writeJsonEnvelope(showEnvelope(response, args.full === true));\n } catch (err) {\n handleMetaError(err);\n }\n },\n});\n\nconst removeCommand = defineCommand({\n meta: {\n name: \"remove\",\n description:\n \"Drop staged Meta ops — one, or many in one call. Removing a create cascades to everything that depends on it. Example: baker ads meta draft remove meta_temp_abc123 meta_temp_def456\",\n },\n args: {\n ref: {\n type: \"positional\",\n description: \"Op ref(s) (meta_temp_* for creates, target id for updates) — several, space- or comma-separated\",\n required: true,\n },\n },\n run: async ({ args }) => {\n const refs = draftRefs(args._);\n if (refs.length > 1) {\n await removeDraftRefs(\"/api/ads/meta/draft/remove\", refs);\n return;\n }\n try {\n const chatId = requireChatId();\n const response = await apiPost<{ ok: true; data: MetaDraftRemoveResponse }>(\"/api/ads/meta/draft/remove\", {\n chatId,\n ref: args.ref,\n });\n writeJsonEnvelope(response);\n } catch (err) {\n handleMetaError(err);\n }\n },\n});\n\nconst clearCommand = defineCommand({\n meta: {\n name: \"clear\",\n description:\n \"Discard ALL staged Meta ops in this chat's draft — nothing will apply on publish. Example: baker ads meta draft clear\",\n },\n run: async () => {\n try {\n const chatId = requireChatId();\n const response = await apiPost<{ ok: true; data: MetaDraftClearResponse }>(\"/api/ads/meta/draft/clear\", {\n chatId,\n });\n writeJsonEnvelope(response);\n } catch (err) {\n handleMetaError(err);\n }\n },\n});\n\nwithEffect({ effect: \"read\", routes: [\"POST /api/ads/meta/draft\"] }, listCommand);\nwithEffect({ effect: \"read\", routes: [\"POST /api/ads/meta/draft/show\"] }, showCommand);\nwithEffect({ effect: \"unstage\", routes: [\"POST /api/ads/meta/draft/remove\"] }, removeCommand);\nwithEffect({ effect: \"unstage\", routes: [\"POST /api/ads/meta/draft/clear\"] }, clearCommand);\n\nexport const metaDraftCommand = defineCommand({\n meta: {\n name: \"draft\",\n description:\n \"Review and edit the Meta write ops staged in this chat BEFORE publish. Subcommands: list (default), show, remove, clear, and stage --file (many ops from one file in one call, names chaining creates). Ops never hit Meta until the chat is published. `list` and `show` take --chat <id> to read an earlier chat's changes instead.\",\n },\n // Declared on the parent too: `default: \"list\"` dispatches the bare `draft --chat <id>` form, and\n // citty prints help for a flag the parent does not know instead of forwarding it.\n args: {\n json: { type: \"boolean\", description: \"Print the raw JSON envelope instead of the readable list\" },\n full: DRAFT_FULL_ARG,\n chat: CHAT_READ_ARG,\n where: LIST_WHERE_ARG,\n },\n subCommands: {\n list: listCommand,\n show: showCommand,\n remove: removeCommand,\n clear: clearCommand,\n stage: draftStageCommand,\n },\n // `default` (not `run`) dispatches the bare invocation: citty falls through to `run`\n // after dispatching a subcommand, so a `run` here would list the draft a second time\n // on every `draft list` / `draft remove` / `draft clear`.\n default: \"list\",\n});\n","import type { MetaDraftOpInput, MetaDraftStageResponse } from \"@baker/api/ads-meta\";\nimport { defineCommand } from \"citty\";\nimport { ApiError, apiPost } from \"../../../client.ts\";\nimport { requireChatId } from \"../../../env.ts\";\nimport { registerSchema, withEffect } from \"../../../schemas.ts\";\nimport { adCopyHints } from \"../copy-hints.ts\";\nimport { loadJsonPayloads } from \"../google/write-shared.ts\";\nimport { writeJsonEnvelope } from \"../output.ts\";\nimport { handleMetaError } from \"./shared.ts\";\nimport { bareAccountId, failWriteValidation, preflightOp } from \"./write-shared.ts\";\n\n/**\n * `draft stage --file`: many Meta ops from one file, in one command. Pictures into ad sets is three\n * ops per ad (upload, creative, ad), each needing the ref the one before it returned, so without this\n * the agent wrote a script looping the CLI and parsing every envelope. Each op still goes through the\n * one-op stage route — Meta staging dry-runs each change, so a whole tree in one request would\n * outlast the request — but the names are resolved here, and a refusal takes back what the file\n * staged before it.\n */\n\nconst BATCH_MAX = 100;\n\n/** A name the file gives a create. Any length: it is replaced before anything is sent. */\nconst NAME = /^meta_temp_[A-Za-z0-9_-]+$/;\n\nconst STAGE_DESCRIPTION = `Stage many Meta changes from ONE file, in one call — any mix of kinds, up to ${BATCH_MAX} ops.\n\nStart here whenever a job is more than a few staged changes: N library pictures into M ad sets, a\nset of ads, a campaign tree. Never loop the single commands from a script.\n baker ads meta draft stage --file ops.json --account-id act_123\n\nThe file is a JSON array (or JSON Lines, one op per line). Each op is what the single commands\nbuild — kind, accountId (or --account-id for all), target for a change to something that exists,\npayload. A create can take a name in \"as\" (meta_temp_<anything>); later ops in the same file use\nthat name wherever a ref goes, and it becomes the real ref. Upload each picture once and reuse it:\n {\"kind\":\"media.upload\",\"as\":\"meta_temp_img1\",\"payload\":{\"kind\":\"image\",\"bakerImageId\":\"<id>\"}}\n {\"kind\":\"adCreative.create\",\"as\":\"meta_temp_cr1\",\"payload\":{\"creativeType\":\"single\",\"page_id\":\"555\",\n \"message\":\"…\",\"headline\":\"…\",\"link\":\"https://example.com\",\"imageRef\":\"meta_temp_img1\",\n \"call_to_action\":{\"type\":\"LEARN_MORE\"}}}\n {\"kind\":\"ad.create\",\"payload\":{\"name\":\"Ad 1\",\"adset_id\":\"6123\",\"creative\":{\"creative_id\":\"meta_temp_cr1\"},\"status\":\"PAUSED\"}}\n {\"kind\":\"ad.create\",\"payload\":{\"name\":\"Ad 1\",\"adset_id\":\"6124\",\"creative\":{\"creative_id\":\"meta_temp_cr1\"},\"status\":\"PAUSED\"}}\nEach kind's payload: \\`baker schema ads meta <group> create\\` (creatives create --variant placement for a\nplacement creative). Ops stage in file order, parents first.\nReturns count, refs (each \"as\" → its real ref; later calls use the real ref) and only the ops that\ncarry a warning; --full lists every op.\nAll-or-nothing: an op refused at staging takes back the ops this file staged before it, and the\nerror names the op. Fix it and run the whole file again.\nThen: baker ads meta draft`;\n\nconst FILE_ARG = {\n type: \"string\",\n description: \"JSON array or JSON Lines of ops ({kind, accountId?, target?, payload?, as?}), path or inline\",\n} as const;\nconst ACCOUNT_ARG = {\n type: \"string\",\n description: \"Ad account (act_123) for every op that does not name its own\",\n} as const;\nconst FULL_ARG = { type: \"boolean\", description: \"List every staged op, not only those with a warning\" } as const;\n\nregisterSchema({\n command: \"ads.meta.draft.stage\",\n routes: [\"POST /api/ads/meta/draft/stage\", \"POST /api/ads/meta/draft/remove\"],\n effect: \"stage\",\n description: STAGE_DESCRIPTION,\n args: {\n file: { ...FILE_ARG, required: true },\n \"account-id\": { ...ACCOUNT_ARG, required: false },\n full: { ...FULL_ARG, required: false },\n },\n});\n\ninterface FileOp {\n name?: string;\n op: Record<string, unknown>;\n}\n\n/** Every string in `value` equal to a key of `names`, swapped for its value: same shape otherwise. */\nfunction withNames(value: unknown, names: ReadonlyMap<string, string>): unknown {\n if (typeof value === \"string\") return names.get(value) ?? value;\n if (Array.isArray(value)) return value.map((item) => withNames(item, names));\n if (value !== null && typeof value === \"object\") {\n return Object.fromEntries(Object.entries(value).map(([key, child]) => [key, withNames(child, names)]));\n }\n return value;\n}\n\n/** The strings in `value` that a later op in the file names: refused, since that op is not staged yet. */\nfunction namesUsed(value: unknown, names: ReadonlySet<string>): string[] {\n if (typeof value === \"string\") return names.has(value) ? [value] : [];\n if (Array.isArray(value)) return value.flatMap((item) => namesUsed(item, names));\n if (value !== null && typeof value === \"object\") return Object.values(value).flatMap((v) => namesUsed(v, names));\n return [];\n}\n\n/** The file's ops, each with its name split off and the account filled in; the names checked before anything stages. */\nexport function fileOps(items: ReadonlyArray<Record<string, unknown>>, accountId: string | undefined): FileOp[] {\n if (items.length === 0) {\n failWriteValidation(\n 'pass --file with the ops to stage: a JSON array (or JSON Lines) of {\"kind\",\"accountId\"?,\"target\"?,\"payload\"?,\"as\"?}',\n );\n }\n if (items.length > BATCH_MAX) {\n failWriteValidation(`${items.length} ops exceeds the limit of ${BATCH_MAX} — split the file and run each part`);\n }\n const declared = new Map<string, number>();\n for (const [index, item] of items.entries()) {\n const { as: name } = item;\n if (name === undefined) continue;\n if (typeof name !== \"string\" || !NAME.test(name)) {\n failWriteValidation(`ops[${index}]: \"as\" must be meta_temp_<letters or digits>, e.g. meta_temp_img1`);\n }\n if (\"target\" in item) {\n failWriteValidation(`ops[${index}]: \"as\" names a create — a change to something that exists already has a ref`);\n }\n const earlier = declared.get(name);\n if (earlier !== undefined) {\n failWriteValidation(`ops[${index}]: ${name} already names ops[${earlier}] — give each create its own name`);\n }\n declared.set(name, index);\n }\n const standIns = new Map([...declared.keys()].map((name, at) => [name, `meta_temp_file${at}`]));\n return items.map(({ as: name, ...rest }, index) => {\n const later = new Set([...declared].filter(([, at]) => at >= index).map(([n]) => n));\n const [early] = namesUsed(rest, later);\n if (early !== undefined) {\n failWriteValidation(\n `ops[${index}] names ${early}, which ops[${declared.get(early)}] creates — put each create before the ops that name it`,\n );\n }\n const op = rest.accountId === undefined && accountId ? { ...rest, accountId } : rest;\n // Checked with each name standing in as a ref the contract takes; the real ref replaces it at staging.\n preflightOp(withNames(op, standIns) as Record<string, unknown>, `ops[${index}] (${String(op.kind)}): `);\n return { name: typeof name === \"string\" ? name : undefined, op };\n });\n}\n\ninterface StageEnvelope {\n ok: true;\n data: MetaDraftStageResponse;\n hints?: string[];\n}\n\n/** Drops what this file staged, newest first. A ref a cascade already took is not an error. */\nasync function takeBack(chatId: string, refs: readonly string[]): Promise<void> {\n for (const ref of [...refs].reverse()) {\n await apiPost(\"/api/ads/meta/draft/remove\", { chatId, ref }).catch(() => undefined);\n }\n}\n\n/**\n * A refused op ends the file: what it staged before is taken back, unless one of those ops amended an\n * op staged before this file ran, which removing cannot undo. The refusal names the op either way.\n */\nasync function refuseFile(\n chatId: string,\n staged: readonly MetaDraftStageResponse[],\n at: string,\n err: unknown,\n): Promise<never> {\n const created = new Set(staged.filter((entry) => !entry.amended).map((entry) => entry.ref));\n const keeps = staged.some((entry) => entry.amended && !created.has(entry.ref));\n if (!keeps) await takeBack(chatId, [...created]);\n if (!(err instanceof ApiError)) handleMetaError(err);\n const after = keeps\n ? `the ${staged.length} op(s) before it stay staged (${staged.map((entry) => entry.ref).join(\", \")}) because one changed an op staged earlier — review with \\`baker ads meta draft\\``\n : \"nothing from this file stayed staged — fix that op and run the whole file again\";\n handleMetaError(new ApiError(err.code, `${at}: ${err.message} — ${after}`, err.fix));\n}\n\nasync function stageFile(ops: readonly FileOp[], full: boolean): Promise<void> {\n const chatId = requireChatId();\n const names = new Map<string, string>();\n const staged: MetaDraftStageResponse[] = [];\n const hints: string[] = [];\n for (const [index, { name, op }] of ops.entries()) {\n const resolved = withNames(op, names) as MetaDraftOpInput;\n try {\n const response = await apiPost<StageEnvelope>(\"/api/ads/meta/draft/stage\", { chatId, op: resolved });\n staged.push(response.data);\n hints.push(...(response.hints ?? []));\n if (name !== undefined) names.set(name, response.data.ref);\n } catch (err) {\n await refuseFile(chatId, staged, `ops[${index}] (${String(op.kind)})`, err);\n }\n }\n const copy = await adCopyHints(ops.map(({ op }) => op.payload));\n const shown = full ? staged : staged.filter((entry) => entry.warnings.length > 0);\n const allHints = [...new Set([...hints, ...copy])];\n writeJsonEnvelope({\n ok: true,\n data: {\n staged: true,\n count: staged.length,\n refs: Object.fromEntries(names),\n ops: shown.map(({ ref, kind, summary, warnings }) => ({ ref, kind, summary, warnings })),\n },\n ...(allHints.length > 0 ? { hints: allHints } : {}),\n });\n}\n\nexport const draftStageCommand = withEffect(\n { effect: \"stage\", routes: [\"POST /api/ads/meta/draft/stage\", \"POST /api/ads/meta/draft/remove\"] },\n defineCommand({\n meta: { name: \"stage\", description: STAGE_DESCRIPTION },\n args: { file: FILE_ARG, \"account-id\": ACCOUNT_ARG, full: FULL_ARG },\n run: async ({ args }) => {\n const items = loadJsonPayloads(args.file);\n const needsAccount = items.some((item) => item.accountId === undefined);\n const accountId = needsAccount ? await bareAccountId(args as Record<string, unknown>) : undefined;\n await stageFile(fileOps(items, accountId), args.full === true);\n },\n }),\n);\n","import type { MetaDraftListResponse, MetaDraftOpView } from \"@baker/api/ads-meta\";\n\n/**\n * Render the staged Meta draft as one line per op — ref, kind, summary, what it\n * waits on and, after a publish, what happened to it. The Google, LinkedIn and\n * X drafts already print a readable view by default; Meta printed the pretty\n * JSON envelope, and agents piped every read through python to get these same\n * columns back. Pure: takes the draft-list response, returns text.\n */\n\nconst STATUS_HEADINGS: Record<MetaDraftListResponse[\"status\"], string> = {\n active: \"staged\",\n publishing: \"publishing\",\n applied: \"published\",\n partial: \"published with failures\",\n discarded: \"discarded\",\n none: \"none\",\n};\n\nfunction plural(count: number, word: string): string {\n return `${count} ${word}${count === 1 ? \"\" : \"s\"}`;\n}\n\nfunction headingLine(draft: MetaDraftListResponse): string {\n const heading = STATUS_HEADINGS[draft.status];\n if (draft.status === \"active\" || draft.status === \"discarded\") {\n return `Meta Ads — ${plural(draft.count, \"change\")} ${heading} · ${draft.mode}`;\n }\n const counts = new Map<string, number>();\n for (const op of draft.ops) {\n const status = op.result?.status ?? \"pending\";\n counts.set(status, (counts.get(status) ?? 0) + 1);\n }\n const summary = [...counts].map(([status, count]) => `${count} ${status}`).join(\", \");\n return `Meta Ads — ${heading} · ${summary} · ${draft.mode}`;\n}\n\n/** A failed op: why, and what of it already reached Meta. */\nfunction failedPart(result: NonNullable<MetaDraftOpView[\"result\"]>): string {\n const landed = result.landed ? ` (${result.landed})` : \"\";\n return `✗ failed: ${result.error ?? \"no reason recorded\"}${landed}`;\n}\n\nfunction resultPart(op: MetaDraftOpView): string | undefined {\n const result = op.result;\n if (!result) {\n return undefined;\n }\n if (result.status === \"failed\") {\n return failedPart(result);\n }\n if (result.status === \"skipped\") {\n // Publish records either the dependency ref that did not apply or a plain reason; either way the op is finished.\n const because = result.skippedBecause;\n if (because && op.dependsOn.includes(because)) {\n return `✗ skipped: ${because} did not apply`;\n }\n return `✗ skipped: ${because ?? \"a change it needs did not apply\"}`;\n }\n const id = result.id ?? result.hash;\n const applied = `✓ ${result.status}${id ? ` → ${id}` : \"\"}`;\n const verification = result.verification;\n if (verification && verification.status !== \"confirmed\") {\n return `${applied} (read-back ${verification.status}${verification.note ? `: ${verification.note}` : \"\"})`;\n }\n return applied;\n}\n\nconst PARENT_WORD: Record<string, string> = {\n \"ad.create\": \"ad set\",\n \"ad.copy\": \"ad set\",\n \"adSet.create\": \"campaign\",\n \"adSet.copy\": \"campaign\",\n};\n\nconst STAGED_AD_KINDS: ReadonlySet<string> = new Set([\"ad.create\", \"ad.copy\"]);\n\n/** Where a staged ad (or ad set) goes, and the status that parent publishes with. */\nfunction parentPart(op: MetaDraftOpView): string | undefined {\n const parent = op.parent;\n if (!parent) {\n return undefined;\n }\n const word = PARENT_WORD[op.kind] ?? \"parent\";\n const named = parent.name ? `\"${parent.name}\" (${parent.ref})` : parent.ref;\n const staged = parent.staged ? \", staged here\" : \"\";\n const status = parent.status\n ? `${parent.statusBefore ? `${parent.statusBefore} → ` : \"\"}${parent.status}`\n : \"status not recorded\";\n return `in ${word} ${named}${staged} ${status}`;\n}\n\n/** \"Which staged ads will run\" in one line: ads counted by the status of the ad set they go into. */\nfunction adParentStatusLine(ops: readonly MetaDraftOpView[]): string | undefined {\n const counts = new Map<string, number>();\n for (const op of ops) {\n if (STAGED_AD_KINDS.has(op.kind) && op.parent) {\n const status = op.parent.status ?? \"not recorded\";\n counts.set(status, (counts.get(status) ?? 0) + 1);\n }\n }\n if (counts.size === 0) {\n return undefined;\n }\n return `Staged ads by ad set status: ${[...counts].map(([status, count]) => `${count} ${status}`).join(\", \")}`;\n}\n\nfunction readinessLine(ops: readonly MetaDraftOpView[]): string {\n const blocked = ops.filter((op) => op.blocked);\n if (blocked.length === 0) {\n return \"Every change passed its checks when staged — no need to re-check them.\";\n }\n // A first publish holds every change beside a refused one; only the refused ones need fixing.\n const heldBack = blocked.filter((op) => op.heldBack).length;\n const refused = blocked.length - heldBack;\n const held =\n heldBack === 0\n ? \"\"\n : `; the other ${plural(heldBack, \"change\")} ${heldBack === 1 ? \"is\" : \"are\"} held back with ${refused === 1 ? \"it\" : \"them\"} and need${heldBack === 1 ? \"s\" : \"\"} nothing`;\n return `${plural(refused, \"change\")} passed its checks when staged but would be refused now (✗ blocked below) — fix or remove ${refused === 1 ? \"it\" : \"them\"} before publishing${held}.`;\n}\n\nfunction opLine(op: MetaDraftOpView, showAccount: boolean): string {\n const parts = [op.ref, op.kind, op.summary];\n if (op.target && op.target !== op.ref) {\n parts.push(`target ${op.target}`);\n }\n if (showAccount) {\n parts.push(`account ${op.accountId}`);\n }\n const parent = parentPart(op);\n if (parent) {\n parts.push(parent);\n }\n if (op.dependsOn.length > 0) {\n parts.push(`after ${op.dependsOn.join(\", \")}`);\n }\n if (op.blocked) {\n parts.push(`✗ blocked: ${op.blocked}`);\n }\n const result = resultPart(op);\n if (result) {\n parts.push(result);\n }\n // Creative copy and provider errors can carry line breaks; one op stays one line.\n return ` ${parts.join(\" · \").replace(/[\\r\\n]+/g, \" \")}`;\n}\n\nexport function renderDraftStatus(draft: MetaDraftListResponse): string {\n if (draft.status === \"none\" || draft.count === 0) {\n return \"No staged Meta changes on this chat.\";\n }\n const lines = [headingLine(draft)];\n if (draft.status === \"active\") {\n lines.push(\"Publishing makes every change real on the ad account.\", readinessLine(draft.ops));\n }\n const adParents = adParentStatusLine(draft.ops);\n if (adParents) {\n lines.push(adParents);\n }\n lines.push(\"\");\n // A draft may span several ad accounts; the account is only noise when there is one.\n const showAccount = new Set(draft.ops.map((op) => op.accountId)).size > 1;\n for (const op of draft.ops) {\n lines.push(opLine(op, showAccount));\n }\n if (draft.advisories.length > 0) {\n lines.push(\"\", \"Advisories\");\n for (const advisory of draft.advisories) {\n lines.push(` ! ${advisory.ref}: ${advisory.message}`);\n }\n }\n lines.push(\n \"\",\n \"Staged payload for one op: baker ads meta draft show <ref> (--full for lists over 50 items) · raw envelope: --json\",\n );\n return lines.join(\"\\n\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;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GA,MAAM;AAAA,IACJ,MAAM,EAAE,MAAM,WAAW,aAAa,2DAA2D;AAAA,IACjG,MAAM;AAAA,IACN,MAAM;AAAA,IACN,OAAO;AAAA,EACT;AAAA,EACA,aAAa;AAAA,IACX,MAAM;AAAA,IACN,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,OAAO;AAAA,IACP,OAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAIA,SAAS;AACX,CAAC;","names":["defineCommand","defineCommand"]}
|
|
@@ -1 +0,0 @@
|
|
|
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;AAA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,YAAY,KAAK,aAAa;AAAA,YAC9B,UAAU,KAAK;AAAA,UACjB,CAAC;AAAA,QACH;AAAA,MACF;AACA,YAAM,QAAQ,YACV;AAAA,QACE,YAAY,SAAS,iBAAiB,QAAQ;AAAA,QAC9C,GAAG,SAAS;AAAA,MACd,IACA,SAAS;AACb,wBAAkB;AAAA,QAChB,IAAI;AAAA,QACJ,MAAM,EAAE,UAAU,UAAU,SAAS,UAAU,GAAI,KAAK,UAAU,IAAI,EAAE,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":[]}
|
package/dist/preview-HD3QAR53.js
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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,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K,YAAY,UAAU,SAAS,SAAS;AAAA,QACjE,OAAO,SAAS;AAAA,MAClB,CAAC;AAAA,IACH,SAAS,KAAK;AACZ,0BAAoB,GAAG;AAAA,IACzB;AAAA,EACF;AACF,CAAC;","names":[]}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|