@koda-sl/baker-cli 0.868.0-dev.5be0a9a76 → 0.868.0-dev.ebaaca9d0
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 +5 -3
- package/dist/{account-assets-L6BX4YUQ.js → account-assets-4EFV6A2D.js} +6 -6
- package/dist/{account-level-OX34JQ7C.js → account-level-7UOXIAB7.js} +3 -3
- package/dist/{add-TKHBYZF6.js → add-ZMOFKHFR.js} +2 -2
- package/dist/{ads-U33JFGCR.js → ads-B4HSLQMP.js} +2 -2
- package/dist/{ads-ZR5D7BZT.js → ads-FQKWQBVZ.js} +10 -10
- package/dist/{adsets-3NIYL2GQ.js → adsets-BG3KZ53Y.js} +9 -9
- package/dist/{asset-writes-5ZKZDPQ4.js → asset-writes-55AP6IJM.js} +3 -3
- package/dist/{audience-writes-NL6NRLLY.js → audience-writes-USX37PPI.js} +2 -2
- package/dist/{audiences-DL267GNQ.js → audiences-G4GJZUIT.js} +6 -6
- package/dist/{campaigns-RXDC5FSQ.js → campaigns-DNA7TN2T.js} +9 -9
- package/dist/{catalogs-QAZ7ZZ5R.js → catalogs-7AG7YVMI.js} +2 -2
- package/dist/{chunk-OMJ7DVFJ.js → chunk-ATVUGOXL.js} +5 -4
- package/dist/{chunk-OMJ7DVFJ.js.map → chunk-ATVUGOXL.js.map} +1 -1
- package/dist/{chunk-UE5ZFTDL.js → chunk-J43KP5NE.js} +2 -2
- package/dist/{chunk-TY4MTOTL.js → chunk-MIIY3MVK.js} +1 -22
- package/dist/chunk-MIIY3MVK.js.map +1 -0
- package/dist/{chunk-EGM42UKF.js → chunk-SXKBGTX2.js} +2 -2
- package/dist/cli.js +3 -3
- package/dist/cli.js.map +1 -1
- package/dist/{copy-writes-QYN6PBU2.js → copy-writes-NJSSVTGB.js} +3 -3
- package/dist/{creatives-CPLH3KHQ.js → creatives-4AD65R3V.js} +4 -4
- package/dist/{custom-conversions-CTJVAZKC.js → custom-conversions-BDXRIYJW.js} +4 -4
- package/dist/{draft-UU3F2VMJ.js → draft-ZUM2WKWP.js} +203 -8
- package/dist/draft-ZUM2WKWP.js.map +1 -0
- package/dist/{flows-FRWZWHXZ.js → flows-PP6BRBD7.js} +3 -3
- package/dist/{instant-experiences-EJWYFWDT.js → instant-experiences-JBN26DUT.js} +2 -2
- package/dist/{leads-FEEWX7OO.js → leads-YWURF6YR.js} +2 -2
- package/dist/{media-PUOLJUN3.js → media-BITGRDCO.js} +3 -3
- package/dist/{meta-SPPSYRMC.js → meta-MY2CIGLA.js} +30 -30
- package/dist/{page-photos-ZBMJLL5V.js → page-photos-ZP7APYIE.js} +2 -2
- package/dist/{rule-writes-6XP7G35U.js → rule-writes-GE5URXYA.js} +2 -2
- package/dist/{rules-BRULCGRV.js → rules-6O5ALFJD.js} +7 -7
- package/dist/{studies-357M2C2K.js → studies-LZ4RWESW.js} +5 -5
- package/dist/{study-writes-HXUQRPIK.js → study-writes-3WXJDSDU.js} +2 -2
- package/dist/{tags-DFCLKJX7.js → tags-IQ6BCRLE.js} +15 -26
- package/dist/tags-IQ6BCRLE.js.map +1 -0
- package/dist/{targeting-7T7XHBIX.js → targeting-DEM7YHWM.js} +2 -2
- package/dist/{write-commands-4KI6T2NF.js → write-commands-EQU4U746.js} +4 -4
- package/package.json +1 -1
- package/dist/chunk-TY4MTOTL.js.map +0 -1
- package/dist/draft-UU3F2VMJ.js.map +0 -1
- package/dist/tags-DFCLKJX7.js.map +0 -1
- /package/dist/{account-assets-L6BX4YUQ.js.map → account-assets-4EFV6A2D.js.map} +0 -0
- /package/dist/{account-level-OX34JQ7C.js.map → account-level-7UOXIAB7.js.map} +0 -0
- /package/dist/{add-TKHBYZF6.js.map → add-ZMOFKHFR.js.map} +0 -0
- /package/dist/{ads-U33JFGCR.js.map → ads-B4HSLQMP.js.map} +0 -0
- /package/dist/{ads-ZR5D7BZT.js.map → ads-FQKWQBVZ.js.map} +0 -0
- /package/dist/{adsets-3NIYL2GQ.js.map → adsets-BG3KZ53Y.js.map} +0 -0
- /package/dist/{asset-writes-5ZKZDPQ4.js.map → asset-writes-55AP6IJM.js.map} +0 -0
- /package/dist/{audience-writes-NL6NRLLY.js.map → audience-writes-USX37PPI.js.map} +0 -0
- /package/dist/{audiences-DL267GNQ.js.map → audiences-G4GJZUIT.js.map} +0 -0
- /package/dist/{campaigns-RXDC5FSQ.js.map → campaigns-DNA7TN2T.js.map} +0 -0
- /package/dist/{catalogs-QAZ7ZZ5R.js.map → catalogs-7AG7YVMI.js.map} +0 -0
- /package/dist/{chunk-UE5ZFTDL.js.map → chunk-J43KP5NE.js.map} +0 -0
- /package/dist/{chunk-EGM42UKF.js.map → chunk-SXKBGTX2.js.map} +0 -0
- /package/dist/{copy-writes-QYN6PBU2.js.map → copy-writes-NJSSVTGB.js.map} +0 -0
- /package/dist/{creatives-CPLH3KHQ.js.map → creatives-4AD65R3V.js.map} +0 -0
- /package/dist/{custom-conversions-CTJVAZKC.js.map → custom-conversions-BDXRIYJW.js.map} +0 -0
- /package/dist/{flows-FRWZWHXZ.js.map → flows-PP6BRBD7.js.map} +0 -0
- /package/dist/{instant-experiences-EJWYFWDT.js.map → instant-experiences-JBN26DUT.js.map} +0 -0
- /package/dist/{leads-FEEWX7OO.js.map → leads-YWURF6YR.js.map} +0 -0
- /package/dist/{media-PUOLJUN3.js.map → media-BITGRDCO.js.map} +0 -0
- /package/dist/{meta-SPPSYRMC.js.map → meta-MY2CIGLA.js.map} +0 -0
- /package/dist/{page-photos-ZBMJLL5V.js.map → page-photos-ZP7APYIE.js.map} +0 -0
- /package/dist/{rule-writes-6XP7G35U.js.map → rule-writes-GE5URXYA.js.map} +0 -0
- /package/dist/{rules-BRULCGRV.js.map → rules-6O5ALFJD.js.map} +0 -0
- /package/dist/{studies-357M2C2K.js.map → studies-LZ4RWESW.js.map} +0 -0
- /package/dist/{study-writes-HXUQRPIK.js.map → study-writes-3WXJDSDU.js.map} +0 -0
- /package/dist/{targeting-7T7XHBIX.js.map → targeting-DEM7YHWM.js.map} +0 -0
- /package/dist/{write-commands-4KI6T2NF.js.map → write-commands-EQU4U746.js.map} +0 -0
package/README.md
CHANGED
|
@@ -339,7 +339,7 @@ Use `--output` to change format:
|
|
|
339
339
|
| `csv` | RFC 4180 comma-separated values | Analysis tools | `baker research …` only |
|
|
340
340
|
| `jsonl` | One JSON object per line | Streaming/appending | `baker research …` only |
|
|
341
341
|
|
|
342
|
-
`--output json` is accepted even by a command that declares no `--output`: the envelope is already what it prints, and on a command whose default is a readable view (the `draft` commands) it becomes that command's `--json`. `baker canvas run` always prints its envelope alone on stdout and its progress lines on stderr — or, when stderr is not a terminal, in a log of its own (`canvas/.cache/logs/<slug>-<n>.log`), with only a `[log]` line naming it and its `[warn]`, `[autofix]` and `[viewer]` lines (each once, on one line) left on stderr, and a run that crashes still printing why as its envelope — so it takes it as already done; on `baker creatives publish`, whose own `--output` names the cover size, `--output json` is the envelope request and the cover keeps any other `--output` value. The few commands that print only text — `baker analytics sending-events`, `baker canvas sync-definition` — refuse it, as a command without its own `--output` refuses `files`. A bare `--json` is taken the same way: where the envelope is already the output (every family's `draft show`, `chats list`) it is dropped, and a command that declares `--json` keeps it. Every `draft` group lists when no subcommand is named (`baker ads google draft`, `baker ga4 draft`, `baker shopify draft`).
|
|
342
|
+
`--output json` is accepted even by a command that declares no `--output`: the envelope is already what it prints, and on a command whose default is a readable view (`baker tags list`, the `draft` commands) it becomes that command's `--json`. `baker canvas run` always prints its envelope alone on stdout and its progress lines on stderr — or, when stderr is not a terminal, in a log of its own (`canvas/.cache/logs/<slug>-<n>.log`), with only a `[log]` line naming it and its `[warn]`, `[autofix]` and `[viewer]` lines (each once, on one line) left on stderr, and a run that crashes still printing why as its envelope — so it takes it as already done; on `baker creatives publish`, whose own `--output` names the cover size, `--output json` is the envelope request and the cover keeps any other `--output` value. The few commands that print only text — `baker analytics sending-events`, `baker canvas sync-definition` — refuse it, as a command without its own `--output` refuses `files`. A bare `--json` is taken the same way: where the envelope is already the output (every family's `draft show`, `chats list`) it is dropped, and a command that declares `--json` keeps it. Every `draft` group lists when no subcommand is named (`baker ads google draft`, `baker ga4 draft`, `baker shopify draft`).
|
|
343
343
|
|
|
344
344
|
`--format <f>` is read as `--output <f>` (`--format table` as `--output md`) on any command without a `--format` of its own (`ads google ads create`, `images screenshot` keep theirs). A shared option written with no value (`--fields`, `--out`, `--output`) is refused as needing one, not as an unknown option.
|
|
345
345
|
|
|
@@ -1612,6 +1612,9 @@ baker ads meta creatives create --account-id act_123 --page 555 --instagram-us
|
|
|
1612
1612
|
baker ads meta ads create --account-id act_123 --name "Ad 1" --adset meta_temp_as --creative meta_temp_cr
|
|
1613
1613
|
# one ad, a 9:16 in Stories & Reels and a 4:5 everywhere else; "bodies"/"titles" (2–5 each) are texts Meta rotates
|
|
1614
1614
|
baker ads meta creatives create --account-id act_123 --file placement.json # {"creativeType":"placement","bodies":[…],"titles":[…],"assets":[…]}
|
|
1615
|
+
# many ops in one call (N pictures into M ad sets): ops stage in file order, "as" names a create for later ops,
|
|
1616
|
+
# and a refused op takes back what the file staged before it
|
|
1617
|
+
baker ads meta draft stage --account-id act_123 --file ops.json # [{"kind":"media.upload","as":"meta_temp_img1","payload":{…}}, …]
|
|
1615
1618
|
|
|
1616
1619
|
# review + edit before publish
|
|
1617
1620
|
baker ads meta draft # one line per op: ref · kind · summary · after <refs>, then advisories
|
|
@@ -4912,8 +4915,7 @@ Read the client's marketing/analytics tags (Meta pixel, ChatGPT Ads pixel, GA4,
|
|
|
4912
4915
|
`BAKER_CHAT_ID` must be set.
|
|
4913
4916
|
|
|
4914
4917
|
```bash
|
|
4915
|
-
baker tags list # effective view
|
|
4916
|
-
baker tags list --output md --full # readable, with custom code scripts whole (by default shown by size)
|
|
4918
|
+
baker tags list # effective view: production + staged, full readable config + secret status
|
|
4917
4919
|
baker tags draft # review the staged changes awaiting publish
|
|
4918
4920
|
baker tags unstage tag_temp_abc123 # take back one change this chat staged (or --all)
|
|
4919
4921
|
```
|
|
@@ -221,11 +221,11 @@ var labelsCommand = defineCommand({
|
|
|
221
221
|
},
|
|
222
222
|
subCommands: {
|
|
223
223
|
list: () => labelsListCommand,
|
|
224
|
-
create: () => import("./asset-writes-
|
|
225
|
-
rename: () => import("./asset-writes-
|
|
226
|
-
delete: () => import("./asset-writes-
|
|
227
|
-
attach: () => import("./asset-writes-
|
|
228
|
-
detach: () => import("./asset-writes-
|
|
224
|
+
create: () => import("./asset-writes-55AP6IJM.js").then((m) => m.labelsCreateCommand),
|
|
225
|
+
rename: () => import("./asset-writes-55AP6IJM.js").then((m) => m.labelsRenameCommand),
|
|
226
|
+
delete: () => import("./asset-writes-55AP6IJM.js").then((m) => m.labelsDeleteCommand),
|
|
227
|
+
attach: () => import("./asset-writes-55AP6IJM.js").then((m) => m.labelsAttachCommand),
|
|
228
|
+
detach: () => import("./asset-writes-55AP6IJM.js").then((m) => m.labelsDetachCommand)
|
|
229
229
|
},
|
|
230
230
|
args: labelsListArgs,
|
|
231
231
|
default: "list"
|
|
@@ -287,4 +287,4 @@ export {
|
|
|
287
287
|
instagramIdentityHints,
|
|
288
288
|
labelsCommand
|
|
289
289
|
};
|
|
290
|
-
//# sourceMappingURL=account-assets-
|
|
290
|
+
//# sourceMappingURL=account-assets-4EFV6A2D.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
dayPartingFromFlags
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-SXKBGTX2.js";
|
|
4
4
|
import {
|
|
5
5
|
bareAccountId,
|
|
6
6
|
failWriteValidation,
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
numberFlag,
|
|
9
9
|
requireTarget,
|
|
10
10
|
stageOp
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-ATVUGOXL.js";
|
|
12
12
|
import "./chunk-3R62EYYX.js";
|
|
13
13
|
import "./chunk-GDFJOCDO.js";
|
|
14
14
|
import {
|
|
@@ -612,4 +612,4 @@ export {
|
|
|
612
612
|
pagePostsCommand,
|
|
613
613
|
reachFrequencyCommand
|
|
614
614
|
};
|
|
615
|
-
//# sourceMappingURL=account-level-
|
|
615
|
+
//# sourceMappingURL=account-level-7UOXIAB7.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
failApi
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-MIIY3MVK.js";
|
|
4
4
|
import {
|
|
5
5
|
rebindReference
|
|
6
6
|
} from "./chunk-YUZGTNAO.js";
|
|
@@ -660,4 +660,4 @@ export {
|
|
|
660
660
|
secondPixelHint,
|
|
661
661
|
stepNameRefusal
|
|
662
662
|
};
|
|
663
|
-
//# sourceMappingURL=add-
|
|
663
|
+
//# sourceMappingURL=add-ZMOFKHFR.js.map
|
|
@@ -34,7 +34,7 @@ Full guides: __tooling__/docs/tools/baker/ads-<platform>.md (google|meta|linkedi
|
|
|
34
34
|
},
|
|
35
35
|
subCommands: {
|
|
36
36
|
google: () => import("./google-HHKFDH7I.js").then((m) => m.googleCommand),
|
|
37
|
-
meta: () => import("./meta-
|
|
37
|
+
meta: () => import("./meta-MY2CIGLA.js").then((m) => m.metaCommand),
|
|
38
38
|
linkedin: () => import("./linkedin-EBOTX37R.js").then((m) => m.linkedinCommand),
|
|
39
39
|
x: () => import("./x-JU6LF2MM.js").then((m) => m.xCommand),
|
|
40
40
|
chatgpt: () => import("./chatgpt-FV4PVN4W.js").then((m) => m.chatgptCommand),
|
|
@@ -45,4 +45,4 @@ Full guides: __tooling__/docs/tools/baker/ads-<platform>.md (google|meta|linkedi
|
|
|
45
45
|
export {
|
|
46
46
|
adsCommand
|
|
47
47
|
};
|
|
48
|
-
//# sourceMappingURL=ads-
|
|
48
|
+
//# sourceMappingURL=ads-B4HSLQMP.js.map
|
|
@@ -116,15 +116,15 @@ Examples:
|
|
|
116
116
|
},
|
|
117
117
|
subCommands: {
|
|
118
118
|
list: listCommand,
|
|
119
|
-
create: () => import("./write-commands-
|
|
120
|
-
update: () => import("./write-commands-
|
|
121
|
-
pause: () => import("./write-commands-
|
|
122
|
-
resume: () => import("./write-commands-
|
|
123
|
-
archive: () => import("./write-commands-
|
|
124
|
-
delete: () => import("./write-commands-
|
|
125
|
-
duplicate: () => import("./write-commands-
|
|
126
|
-
copy: () => import("./copy-writes-
|
|
127
|
-
retag: () => import("./write-commands-
|
|
119
|
+
create: () => import("./write-commands-EQU4U746.js").then((m) => m.adsCreateCommand),
|
|
120
|
+
update: () => import("./write-commands-EQU4U746.js").then((m) => m.adsUpdateCommand),
|
|
121
|
+
pause: () => import("./write-commands-EQU4U746.js").then((m) => m.adsPauseCommand),
|
|
122
|
+
resume: () => import("./write-commands-EQU4U746.js").then((m) => m.adsResumeCommand),
|
|
123
|
+
archive: () => import("./write-commands-EQU4U746.js").then((m) => m.adsArchiveCommand),
|
|
124
|
+
delete: () => import("./write-commands-EQU4U746.js").then((m) => m.adsDeleteCommand),
|
|
125
|
+
duplicate: () => import("./write-commands-EQU4U746.js").then((m) => m.adsDuplicateCommand),
|
|
126
|
+
copy: () => import("./copy-writes-NJSSVTGB.js").then((m) => m.adsCopyCommand),
|
|
127
|
+
retag: () => import("./write-commands-EQU4U746.js").then((m) => m.adsRetagCommand)
|
|
128
128
|
},
|
|
129
129
|
// `args` stays even though the parent has no `run`: citty scans rawArgs for the
|
|
130
130
|
// subcommand name using THIS command's arg defs, so without them `--account-id act_1`
|
|
@@ -136,4 +136,4 @@ Examples:
|
|
|
136
136
|
export {
|
|
137
137
|
adsListCommand
|
|
138
138
|
};
|
|
139
|
-
//# sourceMappingURL=ads-
|
|
139
|
+
//# sourceMappingURL=ads-FQKWQBVZ.js.map
|
|
@@ -176,14 +176,14 @@ Examples:
|
|
|
176
176
|
},
|
|
177
177
|
subCommands: {
|
|
178
178
|
list: listCommand,
|
|
179
|
-
create: () => import("./write-commands-
|
|
180
|
-
update: () => import("./write-commands-
|
|
181
|
-
pause: () => import("./write-commands-
|
|
182
|
-
resume: () => import("./write-commands-
|
|
183
|
-
archive: () => import("./write-commands-
|
|
184
|
-
delete: () => import("./write-commands-
|
|
185
|
-
duplicate: () => import("./write-commands-
|
|
186
|
-
copy: () => import("./copy-writes-
|
|
179
|
+
create: () => import("./write-commands-EQU4U746.js").then((m) => m.adSetsCreateCommand),
|
|
180
|
+
update: () => import("./write-commands-EQU4U746.js").then((m) => m.adSetsUpdateCommand),
|
|
181
|
+
pause: () => import("./write-commands-EQU4U746.js").then((m) => m.adSetsPauseCommand),
|
|
182
|
+
resume: () => import("./write-commands-EQU4U746.js").then((m) => m.adSetsResumeCommand),
|
|
183
|
+
archive: () => import("./write-commands-EQU4U746.js").then((m) => m.adSetsArchiveCommand),
|
|
184
|
+
delete: () => import("./write-commands-EQU4U746.js").then((m) => m.adSetsDeleteCommand),
|
|
185
|
+
duplicate: () => import("./write-commands-EQU4U746.js").then((m) => m.adSetsDuplicateCommand),
|
|
186
|
+
copy: () => import("./copy-writes-NJSSVTGB.js").then((m) => m.adSetsCopyCommand)
|
|
187
187
|
},
|
|
188
188
|
// `args` stays even though the parent has no `run`: citty scans rawArgs for the
|
|
189
189
|
// subcommand name using THIS command's arg defs, so without them `--account-id act_1`
|
|
@@ -195,4 +195,4 @@ Examples:
|
|
|
195
195
|
export {
|
|
196
196
|
adsetsCommand
|
|
197
197
|
};
|
|
198
|
-
//# sourceMappingURL=adsets-
|
|
198
|
+
//# sourceMappingURL=adsets-BG3KZ53Y.js.map
|
|
@@ -9,8 +9,8 @@ import {
|
|
|
9
9
|
labelsDetachCommand,
|
|
10
10
|
labelsRenameCommand,
|
|
11
11
|
mediaDeleteCommand
|
|
12
|
-
} from "./chunk-
|
|
13
|
-
import "./chunk-
|
|
12
|
+
} from "./chunk-J43KP5NE.js";
|
|
13
|
+
import "./chunk-ATVUGOXL.js";
|
|
14
14
|
import "./chunk-3R62EYYX.js";
|
|
15
15
|
import "./chunk-GDFJOCDO.js";
|
|
16
16
|
import "./chunk-DP76WGDV.js";
|
|
@@ -51,4 +51,4 @@ export {
|
|
|
51
51
|
labelsRenameCommand,
|
|
52
52
|
mediaDeleteCommand
|
|
53
53
|
};
|
|
54
|
-
//# sourceMappingURL=asset-writes-
|
|
54
|
+
//# sourceMappingURL=asset-writes-55AP6IJM.js.map
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
repeatedListFlag,
|
|
11
11
|
requireTarget,
|
|
12
12
|
stageOp
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-ATVUGOXL.js";
|
|
14
14
|
import {
|
|
15
15
|
CUSTOMER_LIST_BATCH_ROWS,
|
|
16
16
|
CUSTOMER_LIST_MAX_BATCHES,
|
|
@@ -328,4 +328,4 @@ export {
|
|
|
328
328
|
savedAudiencesCommand,
|
|
329
329
|
targetingFromSavedAudience
|
|
330
330
|
};
|
|
331
|
-
//# sourceMappingURL=audience-writes-
|
|
331
|
+
//# sourceMappingURL=audience-writes-USX37PPI.js.map
|
|
@@ -98,11 +98,11 @@ Examples:
|
|
|
98
98
|
},
|
|
99
99
|
subCommands: {
|
|
100
100
|
list: listCommand,
|
|
101
|
-
create: () => import("./write-commands-
|
|
102
|
-
update: () => import("./write-commands-
|
|
103
|
-
delete: () => import("./audience-writes-
|
|
104
|
-
members: () => import("./audience-writes-
|
|
105
|
-
saved: () => import("./audience-writes-
|
|
101
|
+
create: () => import("./write-commands-EQU4U746.js").then((m) => m.audiencesCreateCommand),
|
|
102
|
+
update: () => import("./write-commands-EQU4U746.js").then((m) => m.audiencesUpdateCommand),
|
|
103
|
+
delete: () => import("./audience-writes-USX37PPI.js").then((m) => m.audiencesDeleteCommand),
|
|
104
|
+
members: () => import("./audience-writes-USX37PPI.js").then((m) => m.audiencesMembersCommand),
|
|
105
|
+
saved: () => import("./audience-writes-USX37PPI.js").then((m) => m.savedAudiencesCommand)
|
|
106
106
|
},
|
|
107
107
|
// `args` stays even though the parent has no `run`: citty scans rawArgs for the
|
|
108
108
|
// subcommand name using THIS command's arg defs, so without them `--account-id act_1`
|
|
@@ -114,4 +114,4 @@ Examples:
|
|
|
114
114
|
export {
|
|
115
115
|
audiencesCommand
|
|
116
116
|
};
|
|
117
|
-
//# sourceMappingURL=audiences-
|
|
117
|
+
//# sourceMappingURL=audiences-G4GJZUIT.js.map
|
|
@@ -116,14 +116,14 @@ Examples:
|
|
|
116
116
|
},
|
|
117
117
|
subCommands: {
|
|
118
118
|
list: listCommand,
|
|
119
|
-
create: () => import("./write-commands-
|
|
120
|
-
update: () => import("./write-commands-
|
|
121
|
-
pause: () => import("./write-commands-
|
|
122
|
-
resume: () => import("./write-commands-
|
|
123
|
-
archive: () => import("./write-commands-
|
|
124
|
-
delete: () => import("./write-commands-
|
|
125
|
-
duplicate: () => import("./write-commands-
|
|
126
|
-
copy: () => import("./copy-writes-
|
|
119
|
+
create: () => import("./write-commands-EQU4U746.js").then((m) => m.campaignsCreateCommand),
|
|
120
|
+
update: () => import("./write-commands-EQU4U746.js").then((m) => m.campaignsUpdateCommand),
|
|
121
|
+
pause: () => import("./write-commands-EQU4U746.js").then((m) => m.campaignsPauseCommand),
|
|
122
|
+
resume: () => import("./write-commands-EQU4U746.js").then((m) => m.campaignsResumeCommand),
|
|
123
|
+
archive: () => import("./write-commands-EQU4U746.js").then((m) => m.campaignsArchiveCommand),
|
|
124
|
+
delete: () => import("./write-commands-EQU4U746.js").then((m) => m.campaignsDeleteCommand),
|
|
125
|
+
duplicate: () => import("./write-commands-EQU4U746.js").then((m) => m.campaignsDuplicateCommand),
|
|
126
|
+
copy: () => import("./copy-writes-NJSSVTGB.js").then((m) => m.campaignsCopyCommand)
|
|
127
127
|
},
|
|
128
128
|
// `args` stays even though the parent has no `run`: citty scans rawArgs for the
|
|
129
129
|
// subcommand name using THIS command's arg defs, so without them `--account-id act_1`
|
|
@@ -136,4 +136,4 @@ export {
|
|
|
136
136
|
advantagePlusHints,
|
|
137
137
|
campaignsCommand
|
|
138
138
|
};
|
|
139
|
-
//# sourceMappingURL=campaigns-
|
|
139
|
+
//# sourceMappingURL=campaigns-DNA7TN2T.js.map
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
requireTarget,
|
|
9
9
|
stageOp,
|
|
10
10
|
upper
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-ATVUGOXL.js";
|
|
12
12
|
import {
|
|
13
13
|
retailerIdFilter
|
|
14
14
|
} from "./chunk-3R62EYYX.js";
|
|
@@ -783,4 +783,4 @@ export {
|
|
|
783
783
|
productFieldsFromArgs,
|
|
784
784
|
productSetFilterFromArgs
|
|
785
785
|
};
|
|
786
|
-
//# sourceMappingURL=catalogs-
|
|
786
|
+
//# sourceMappingURL=catalogs-7AG7YVMI.js.map
|
|
@@ -153,7 +153,7 @@ function requireTarget(args, entity) {
|
|
|
153
153
|
}
|
|
154
154
|
return target;
|
|
155
155
|
}
|
|
156
|
-
function preflightOp(raw) {
|
|
156
|
+
function preflightOp(raw, at = "") {
|
|
157
157
|
const preflight = metaDraftOpInputSchema.safeParse(raw);
|
|
158
158
|
if (!preflight.success) {
|
|
159
159
|
const fields = preflight.error.issues.map((issue) => ({ path: issue.path.join("."), message: issue.message }));
|
|
@@ -161,7 +161,7 @@ function preflightOp(raw) {
|
|
|
161
161
|
ok: false,
|
|
162
162
|
error: {
|
|
163
163
|
code: "VALIDATION_ERROR",
|
|
164
|
-
message: fields.map((field) => field.path ? `${field.path}: ${field.message}` : field.message).join("; ")
|
|
164
|
+
message: `${at}${fields.map((field) => field.path ? `${field.path}: ${field.message}` : field.message).join("; ")}`,
|
|
165
165
|
fields,
|
|
166
166
|
fix: payloadFix("meta-ads", metaDraftOpInputSchema, raw)
|
|
167
167
|
}
|
|
@@ -182,7 +182,7 @@ async function stageOp(raw, extraHints = []) {
|
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
184
|
async function stageOps(raws) {
|
|
185
|
-
const ops = raws.map(preflightOp);
|
|
185
|
+
const ops = raws.map((raw) => preflightOp(raw));
|
|
186
186
|
const chatId = requireChatId();
|
|
187
187
|
const staged = [];
|
|
188
188
|
for (const op of ops) {
|
|
@@ -223,8 +223,9 @@ export {
|
|
|
223
223
|
upper,
|
|
224
224
|
numberFlag,
|
|
225
225
|
requireTarget,
|
|
226
|
+
preflightOp,
|
|
226
227
|
stageOp,
|
|
227
228
|
stageOps,
|
|
228
229
|
stageStatusChange
|
|
229
230
|
};
|
|
230
|
-
//# sourceMappingURL=chunk-
|
|
231
|
+
//# sourceMappingURL=chunk-ATVUGOXL.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/commands/ads/meta/write-shared.ts"],"sourcesContent":["import { readFileSync } from \"node:fs\";\nimport { type MetaDraftOpInput, type MetaDraftStageResponse, metaDraftOpInputSchema } from \"@baker/api/ads-meta\";\nimport { apiPost } from \"../../../client.ts\";\nimport { requireChatId } from \"../../../env.ts\";\nimport { repeatedValues } from \"../../../lib/repeatedFlags.ts\";\nimport { type CommandEffectDeclaration, payloadArg } from \"../../../schemas.ts\";\nimport { payloadFix } from \"../../capabilities/fix.ts\";\nimport { booleanWordPositionalError } from \"../boolean-word-positional.ts\";\nimport { adCopyHints } from \"../copy-hints.ts\";\nimport { withHints } from \"../hints.ts\";\nimport { writeJsonEnvelope } from \"../output.ts\";\nimport { handleMetaError, resolveAccountIdArg } from \"./shared.ts\";\n\n/**\n * Shared plumbing for the staged Meta write commands. Writes NEVER hit Meta\n * directly: every command stages an op against this chat's draft\n * (`/api/ads/meta/draft/stage`), the dashboard shows it as a pending Meta\n * change, and it applies when the chat is published.\n */\n\n/** `--file` for a command that stages one `kind` op; `baker schema` prints that op's payload shape. */\nexport function fileArg(kind: MetaDraftOpInput[\"kind\"], description: string) {\n return {\n file: payloadArg(\n {\n type: \"string\" as const,\n description: `${description} — run \\`baker schema\\` on this command for every field the payload takes`,\n },\n () => ({ union: metaDraftOpInputSchema, kind }),\n ),\n };\n}\n\n/** Backend account ids are bare numeric — strip the `act_` prefix resolveAccountIdArg adds. */\nexport async function bareAccountId(args: Record<string, unknown>): Promise<string> {\n return (await resolveAccountIdArg(args)).replace(/^act_/, \"\");\n}\n\n/** What every staged Meta write command does: one op onto this chat's draft, for the account it names or the only one. */\nexport const META_STAGED: CommandEffectDeclaration = {\n effect: \"stage\",\n routes: [\"POST /api/ads/meta/draft/stage\", \"GET /api/ads/meta/accounts\"],\n};\n\n/** A staged Meta write command, with the kinds of op it stages: what Baker's API offers it as (`@baker/api/agent-engine/found-ads-meta`). */\nexport function metaStages(...kinds: string[]): CommandEffectDeclaration {\n return { ...META_STAGED, stages: kinds };\n}\n\nexport function failWriteValidation(message: string): never {\n writeJsonEnvelope({ ok: false, error: { code: \"VALIDATION_ERROR\", message } });\n process.exit(1);\n}\n\n/** Deleting is permanent, so it only stages through `delete`, whose description carries that warning. */\nexport function refuseDeleteByUpdate(payload: Record<string, unknown>, group: \"campaigns\" | \"adsets\" | \"ads\"): void {\n if (payload.status === \"DELETED\") {\n failWriteValidation(\n `update does not delete — deleting is permanent. Use \\`baker ads meta ${group} delete <id>\\` if the user asked to delete; otherwise pause or archive.`,\n );\n }\n}\n\n/**\n * `--file`: a JSON file path, or the JSON itself when it starts with `{` — the shape Google's\n * `--file` already takes and the one an agent writes first for a short payload (a customer list of\n * a few people).\n */\nexport function loadJsonFileArg(path: unknown): Record<string, unknown> {\n if (typeof path !== \"string\" || path.length === 0) {\n return {};\n }\n const inline = /^\\s*\\{/.test(path);\n const source = inline ? \"inline JSON\" : path;\n try {\n const parsed = JSON.parse(inline ? path : readFileSync(path, \"utf8\")) as unknown;\n if (parsed === null || typeof parsed !== \"object\" || Array.isArray(parsed)) {\n failWriteValidation(`${source} must contain a JSON object`);\n }\n return parsed as Record<string, unknown>;\n } catch (err) {\n if (err instanceof SyntaxError) {\n failWriteValidation(`${source} is not valid JSON: ${err.message}`);\n }\n throw err;\n }\n}\n\n/** Flags override file keys — the file is the base, flags are the overrides. */\nexport function mergePayload(file: Record<string, unknown>, flags: Record<string, unknown>): Record<string, unknown> {\n const merged: Record<string, unknown> = { ...file };\n for (const [key, value] of Object.entries(flags)) {\n if (value !== undefined) {\n merged[key] = value;\n }\n }\n return merged;\n}\n\nexport function parseMoneyFlag(\n amount: unknown,\n currency: unknown,\n flag: string,\n): { amount: string; currencyCode?: string } | undefined {\n if (amount === undefined || amount === null || amount === \"\") {\n return undefined;\n }\n if (currency === undefined || currency === null || currency === \"\") {\n // Meta ad accounts are single-currency — the backend fills it in.\n return { amount: String(amount) };\n }\n if (typeof currency !== \"string\" || currency.length !== 3) {\n failWriteValidation(`${flag} got an invalid --currency (expected a 3-letter code like USD)`);\n }\n return { amount: String(amount), currencyCode: currency.toUpperCase() };\n}\n\n/** Accepts ISO dates (2026-07-10), ISO datetimes, or epoch millis. */\nexport function parseDateFlag(value: unknown, flag: string): number | undefined {\n if (value === undefined || value === null || value === \"\") {\n return undefined;\n }\n const raw = String(value);\n if (/^\\d{10,}$/.test(raw)) {\n return Number(raw);\n }\n const parsed = Date.parse(raw);\n if (Number.isNaN(parsed)) {\n failWriteValidation(`${flag} must be an ISO date (2026-07-10) or epoch milliseconds`);\n }\n return parsed;\n}\n\n/** Split a comma-separated flag into a trimmed, non-empty array. */\nexport function listFlag(value: unknown): string[] | undefined {\n if (typeof value !== \"string\" || value.trim().length === 0) {\n return undefined;\n }\n const items = value\n .split(\",\")\n .map((item) => item.trim())\n .filter(Boolean);\n return items.length > 0 ? items : undefined;\n}\n\n/**\n * A list flag that may be repeated as well as comma-separated\n * (`--countries ES,FR --countries DE`). citty keeps only a repeated flag's last\n * value, so the values are read from the command line (`repeatedValues`).\n */\nexport function repeatedListFlag(\n rawArgs: readonly string[] | undefined,\n flag: string,\n parsed: unknown,\n): string[] | undefined {\n const items = repeatedValues(rawArgs, flag, parsed)\n .flatMap((value) => value.split(\",\"))\n .map((item) => item.trim())\n .filter(Boolean);\n return items.length > 0 ? items : undefined;\n}\n\nexport function upper(value: unknown): string | undefined {\n return typeof value === \"string\" && value.length > 0 ? value.toUpperCase() : undefined;\n}\n\nexport function numberFlag(value: unknown, flag: string): number | undefined {\n if (value === undefined || value === null || value === \"\") {\n return undefined;\n }\n const n = Number(value);\n if (!Number.isFinite(n)) {\n failWriteValidation(`${flag} must be a number`);\n }\n return n;\n}\n\n/**\n * Accepts whichever positional the command declared (`id`, `target`, `ref`) or the raw positional.\n *\n * `--flag false` is refused first: citty turns it into the flag set to TRUE plus a stray positional,\n * so on `campaigns duplicate 6123 --replace false` the copy stages AND the live original is staged\n * for pause — the opposite of what was typed, with an \"ok\" receipt. This is the only place on this\n * surface that reads positionals, and every target-taking command goes through it.\n */\nexport function requireTarget(args: Record<string, unknown>, entity: string): string {\n const inverted = booleanWordPositionalError(args, entity);\n if (inverted !== undefined) {\n failWriteValidation(inverted);\n }\n const positional = Array.isArray(args._) ? args._[0] : undefined;\n const target = args.id ?? args.target ?? args.ref ?? positional;\n if (typeof target !== \"string\" || target.length === 0) {\n failWriteValidation(`pass the ${entity} id as the positional argument`);\n }\n return target;\n}\n\ninterface StageEnvelope extends Record<string, unknown> {\n ok: true;\n data: MetaDraftStageResponse;\n}\n\n/**\n * Preflight-validates the op against the shared `@baker/api/ads-meta` contract\n * (same schema the backend enforces), then stages it. Prints the staged\n * envelope — ref, mode (always `live`: publishing reaches the real ad account),\n * summary, warnings.\n */\n/** The op parsed against the shared contract, or the validation envelope printed and the process ended. */\nfunction preflightOp(raw: Record<string, unknown>) {\n const preflight = metaDraftOpInputSchema.safeParse(raw);\n if (!preflight.success) {\n const fields = preflight.error.issues.map((issue) => ({ path: issue.path.join(\".\"), message: issue.message }));\n writeJsonEnvelope({\n ok: false,\n error: {\n code: \"VALIDATION_ERROR\",\n message: fields.map((field) => (field.path ? `${field.path}: ${field.message}` : field.message)).join(\"; \"),\n fields,\n fix: payloadFix(\"meta-ads\", metaDraftOpInputSchema, raw),\n },\n });\n process.exit(1);\n }\n return preflight.data;\n}\n\nexport async function stageOp(raw: Record<string, unknown>, extraHints: readonly string[] = []): Promise<void> {\n const op = preflightOp(raw);\n try {\n const chatId = requireChatId();\n const response = await apiPost<StageEnvelope>(\"/api/ads/meta/draft/stage\", { chatId, op });\n const copyHints = await adCopyHints(op);\n writeJsonEnvelope(withHints(response, [...copyHints, ...extraHints]));\n } catch (err) {\n handleMetaError(err);\n }\n}\n\n/**\n * Stage several ops as one command and print one envelope: each staged op's\n * receipt, in order. Stops at the first refusal, which names the op it was —\n * the ones before it stay staged, and the envelope says which.\n */\nexport async function stageOps(raws: readonly Record<string, unknown>[]): Promise<void> {\n const ops = raws.map(preflightOp);\n const chatId = requireChatId();\n const staged: MetaDraftStageResponse[] = [];\n for (const op of ops) {\n try {\n const response = await apiPost<StageEnvelope>(\"/api/ads/meta/draft/stage\", { chatId, op });\n staged.push(response.data);\n } catch (err) {\n if (staged.length > 0) {\n process.stderr.write(`staged before the refusal: ${staged.map((entry) => entry.ref).join(\", \")}\\n`);\n }\n handleMetaError(err);\n }\n }\n writeJsonEnvelope({ ok: true, data: staged });\n}\n\nexport async function stageStatusChange(input: {\n kind: \"campaign.update\" | \"adSet.update\" | \"adCreative.update\" | \"ad.update\" | \"customAudience.update\";\n accountId: string;\n target: string;\n status: \"ACTIVE\" | \"PAUSED\" | \"ARCHIVED\" | \"DELETED\";\n}): Promise<void> {\n await stageOp({\n kind: input.kind,\n accountId: input.accountId,\n target: input.target,\n payload: { status: input.status },\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,oBAAoB;AAqBtB,SAAS,QAAQ,MAAgC,aAAqB;AAC3E,SAAO;AAAA,IACL,MAAM;AAAA,MACJ;AAAA,QACE,MAAM;AAAA,QACN,aAAa,GAAG,WAAW;AAAA,MAC7B;AAAA,MACA,OAAO,EAAE,OAAO,wBAAwB,KAAK;AAAA,IAC/C;AAAA,EACF;AACF;AAGA,eAAsB,cAAc,MAAgD;AAClF,UAAQ,MAAM,oBAAoB,IAAI,GAAG,QAAQ,SAAS,EAAE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AAY,GAAG;AAC1B,MAAI;AACF,UAAM,SAAS,cAAc;AAC7B,UAAM,WAAW,MAAM,QAAuB,6BAA6B,EAAE,QAAQ,GAAG,CAAC;AACzF,UAAM,YAAY,MAAM,YAAY,EAAE;AACtC,sBAAkB,UAAU,UAAU,CAAC,GAAG,WAAW,GAAG,UAAU,CAAC,CAAC;AAAA,EACtE,SAAS,KAAK;AACZ,oBAAgB,GAAG;AAAA,EACrB;AACF;AAOA,eAAsB,SAAS,MAAyD;AACtF,QAAM,MAAM,KAAK,IAAI,WAAW;AAChC,QAAM,SAAS,cAAc;AAC7B,QAAM,SAAmC,CAAC;AAC1C,aAAW,MAAM,KAAK;AACpB,QAAI;AACF,YAAM,WAAW,MAAM,QAAuB,6BAA6B,EAAE,QAAQ,GAAG,CAAC;AACzF,aAAO,KAAK,SAAS,IAAI;AAAA,IAC3B,SAAS,KAAK;AACZ,UAAI,OAAO,SAAS,GAAG;AACrB,gBAAQ,OAAO,MAAM,8BAA8B,OAAO,IAAI,CAAC,UAAU,MAAM,GAAG,EAAE,KAAK,IAAI,CAAC;AAAA,CAAI;AAAA,MACpG;AACA,sBAAgB,GAAG;AAAA,IACrB;AAAA,EACF;AACA,oBAAkB,EAAE,IAAI,MAAM,MAAM,OAAO,CAAC;AAC9C;AAEA,eAAsB,kBAAkB,OAKtB;AAChB,QAAM,QAAQ;AAAA,IACZ,MAAM,MAAM;AAAA,IACZ,WAAW,MAAM;AAAA,IACjB,QAAQ,MAAM;AAAA,IACd,SAAS,EAAE,QAAQ,MAAM,OAAO;AAAA,EAClC,CAAC;AACH;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/commands/ads/meta/write-shared.ts"],"sourcesContent":["import { readFileSync } from \"node:fs\";\nimport { type MetaDraftOpInput, type MetaDraftStageResponse, metaDraftOpInputSchema } from \"@baker/api/ads-meta\";\nimport { apiPost } from \"../../../client.ts\";\nimport { requireChatId } from \"../../../env.ts\";\nimport { repeatedValues } from \"../../../lib/repeatedFlags.ts\";\nimport { type CommandEffectDeclaration, payloadArg } from \"../../../schemas.ts\";\nimport { payloadFix } from \"../../capabilities/fix.ts\";\nimport { booleanWordPositionalError } from \"../boolean-word-positional.ts\";\nimport { adCopyHints } from \"../copy-hints.ts\";\nimport { withHints } from \"../hints.ts\";\nimport { writeJsonEnvelope } from \"../output.ts\";\nimport { handleMetaError, resolveAccountIdArg } from \"./shared.ts\";\n\n/**\n * Shared plumbing for the staged Meta write commands. Writes NEVER hit Meta\n * directly: every command stages an op against this chat's draft\n * (`/api/ads/meta/draft/stage`), the dashboard shows it as a pending Meta\n * change, and it applies when the chat is published.\n */\n\n/** `--file` for a command that stages one `kind` op; `baker schema` prints that op's payload shape. */\nexport function fileArg(kind: MetaDraftOpInput[\"kind\"], description: string) {\n return {\n file: payloadArg(\n {\n type: \"string\" as const,\n description: `${description} — run \\`baker schema\\` on this command for every field the payload takes`,\n },\n () => ({ union: metaDraftOpInputSchema, kind }),\n ),\n };\n}\n\n/** Backend account ids are bare numeric — strip the `act_` prefix resolveAccountIdArg adds. */\nexport async function bareAccountId(args: Record<string, unknown>): Promise<string> {\n return (await resolveAccountIdArg(args)).replace(/^act_/, \"\");\n}\n\n/** What every staged Meta write command does: one op onto this chat's draft, for the account it names or the only one. */\nexport const META_STAGED: CommandEffectDeclaration = {\n effect: \"stage\",\n routes: [\"POST /api/ads/meta/draft/stage\", \"GET /api/ads/meta/accounts\"],\n};\n\n/** A staged Meta write command, with the kinds of op it stages: what Baker's API offers it as (`@baker/api/agent-engine/found-ads-meta`). */\nexport function metaStages(...kinds: string[]): CommandEffectDeclaration {\n return { ...META_STAGED, stages: kinds };\n}\n\nexport function failWriteValidation(message: string): never {\n writeJsonEnvelope({ ok: false, error: { code: \"VALIDATION_ERROR\", message } });\n process.exit(1);\n}\n\n/** Deleting is permanent, so it only stages through `delete`, whose description carries that warning. */\nexport function refuseDeleteByUpdate(payload: Record<string, unknown>, group: \"campaigns\" | \"adsets\" | \"ads\"): void {\n if (payload.status === \"DELETED\") {\n failWriteValidation(\n `update does not delete — deleting is permanent. Use \\`baker ads meta ${group} delete <id>\\` if the user asked to delete; otherwise pause or archive.`,\n );\n }\n}\n\n/**\n * `--file`: a JSON file path, or the JSON itself when it starts with `{` — the shape Google's\n * `--file` already takes and the one an agent writes first for a short payload (a customer list of\n * a few people).\n */\nexport function loadJsonFileArg(path: unknown): Record<string, unknown> {\n if (typeof path !== \"string\" || path.length === 0) {\n return {};\n }\n const inline = /^\\s*\\{/.test(path);\n const source = inline ? \"inline JSON\" : path;\n try {\n const parsed = JSON.parse(inline ? path : readFileSync(path, \"utf8\")) as unknown;\n if (parsed === null || typeof parsed !== \"object\" || Array.isArray(parsed)) {\n failWriteValidation(`${source} must contain a JSON object`);\n }\n return parsed as Record<string, unknown>;\n } catch (err) {\n if (err instanceof SyntaxError) {\n failWriteValidation(`${source} is not valid JSON: ${err.message}`);\n }\n throw err;\n }\n}\n\n/** Flags override file keys — the file is the base, flags are the overrides. */\nexport function mergePayload(file: Record<string, unknown>, flags: Record<string, unknown>): Record<string, unknown> {\n const merged: Record<string, unknown> = { ...file };\n for (const [key, value] of Object.entries(flags)) {\n if (value !== undefined) {\n merged[key] = value;\n }\n }\n return merged;\n}\n\nexport function parseMoneyFlag(\n amount: unknown,\n currency: unknown,\n flag: string,\n): { amount: string; currencyCode?: string } | undefined {\n if (amount === undefined || amount === null || amount === \"\") {\n return undefined;\n }\n if (currency === undefined || currency === null || currency === \"\") {\n // Meta ad accounts are single-currency — the backend fills it in.\n return { amount: String(amount) };\n }\n if (typeof currency !== \"string\" || currency.length !== 3) {\n failWriteValidation(`${flag} got an invalid --currency (expected a 3-letter code like USD)`);\n }\n return { amount: String(amount), currencyCode: currency.toUpperCase() };\n}\n\n/** Accepts ISO dates (2026-07-10), ISO datetimes, or epoch millis. */\nexport function parseDateFlag(value: unknown, flag: string): number | undefined {\n if (value === undefined || value === null || value === \"\") {\n return undefined;\n }\n const raw = String(value);\n if (/^\\d{10,}$/.test(raw)) {\n return Number(raw);\n }\n const parsed = Date.parse(raw);\n if (Number.isNaN(parsed)) {\n failWriteValidation(`${flag} must be an ISO date (2026-07-10) or epoch milliseconds`);\n }\n return parsed;\n}\n\n/** Split a comma-separated flag into a trimmed, non-empty array. */\nexport function listFlag(value: unknown): string[] | undefined {\n if (typeof value !== \"string\" || value.trim().length === 0) {\n return undefined;\n }\n const items = value\n .split(\",\")\n .map((item) => item.trim())\n .filter(Boolean);\n return items.length > 0 ? items : undefined;\n}\n\n/**\n * A list flag that may be repeated as well as comma-separated\n * (`--countries ES,FR --countries DE`). citty keeps only a repeated flag's last\n * value, so the values are read from the command line (`repeatedValues`).\n */\nexport function repeatedListFlag(\n rawArgs: readonly string[] | undefined,\n flag: string,\n parsed: unknown,\n): string[] | undefined {\n const items = repeatedValues(rawArgs, flag, parsed)\n .flatMap((value) => value.split(\",\"))\n .map((item) => item.trim())\n .filter(Boolean);\n return items.length > 0 ? items : undefined;\n}\n\nexport function upper(value: unknown): string | undefined {\n return typeof value === \"string\" && value.length > 0 ? value.toUpperCase() : undefined;\n}\n\nexport function numberFlag(value: unknown, flag: string): number | undefined {\n if (value === undefined || value === null || value === \"\") {\n return undefined;\n }\n const n = Number(value);\n if (!Number.isFinite(n)) {\n failWriteValidation(`${flag} must be a number`);\n }\n return n;\n}\n\n/**\n * Accepts whichever positional the command declared (`id`, `target`, `ref`) or the raw positional.\n *\n * `--flag false` is refused first: citty turns it into the flag set to TRUE plus a stray positional,\n * so on `campaigns duplicate 6123 --replace false` the copy stages AND the live original is staged\n * for pause — the opposite of what was typed, with an \"ok\" receipt. This is the only place on this\n * surface that reads positionals, and every target-taking command goes through it.\n */\nexport function requireTarget(args: Record<string, unknown>, entity: string): string {\n const inverted = booleanWordPositionalError(args, entity);\n if (inverted !== undefined) {\n failWriteValidation(inverted);\n }\n const positional = Array.isArray(args._) ? args._[0] : undefined;\n const target = args.id ?? args.target ?? args.ref ?? positional;\n if (typeof target !== \"string\" || target.length === 0) {\n failWriteValidation(`pass the ${entity} id as the positional argument`);\n }\n return target;\n}\n\ninterface StageEnvelope extends Record<string, unknown> {\n ok: true;\n data: MetaDraftStageResponse;\n}\n\n/**\n * Preflight-validates the op against the shared `@baker/api/ads-meta` contract\n * (same schema the backend enforces), then stages it. Prints the staged\n * envelope — ref, mode (always `live`: publishing reaches the real ad account),\n * summary, warnings.\n */\n/** The op parsed against the shared contract, or the validation envelope printed and the process ended. */\nexport function preflightOp(raw: Record<string, unknown>, at = \"\") {\n const preflight = metaDraftOpInputSchema.safeParse(raw);\n if (!preflight.success) {\n const fields = preflight.error.issues.map((issue) => ({ path: issue.path.join(\".\"), message: issue.message }));\n writeJsonEnvelope({\n ok: false,\n error: {\n code: \"VALIDATION_ERROR\",\n message: `${at}${fields.map((field) => (field.path ? `${field.path}: ${field.message}` : field.message)).join(\"; \")}`,\n fields,\n fix: payloadFix(\"meta-ads\", metaDraftOpInputSchema, raw),\n },\n });\n process.exit(1);\n }\n return preflight.data;\n}\n\nexport async function stageOp(raw: Record<string, unknown>, extraHints: readonly string[] = []): Promise<void> {\n const op = preflightOp(raw);\n try {\n const chatId = requireChatId();\n const response = await apiPost<StageEnvelope>(\"/api/ads/meta/draft/stage\", { chatId, op });\n const copyHints = await adCopyHints(op);\n writeJsonEnvelope(withHints(response, [...copyHints, ...extraHints]));\n } catch (err) {\n handleMetaError(err);\n }\n}\n\n/**\n * Stage several ops as one command and print one envelope: each staged op's\n * receipt, in order. Stops at the first refusal, which names the op it was —\n * the ones before it stay staged, and the envelope says which.\n */\nexport async function stageOps(raws: readonly Record<string, unknown>[]): Promise<void> {\n const ops = raws.map((raw) => preflightOp(raw));\n const chatId = requireChatId();\n const staged: MetaDraftStageResponse[] = [];\n for (const op of ops) {\n try {\n const response = await apiPost<StageEnvelope>(\"/api/ads/meta/draft/stage\", { chatId, op });\n staged.push(response.data);\n } catch (err) {\n if (staged.length > 0) {\n process.stderr.write(`staged before the refusal: ${staged.map((entry) => entry.ref).join(\", \")}\\n`);\n }\n handleMetaError(err);\n }\n }\n writeJsonEnvelope({ ok: true, data: staged });\n}\n\nexport async function stageStatusChange(input: {\n kind: \"campaign.update\" | \"adSet.update\" | \"adCreative.update\" | \"ad.update\" | \"customAudience.update\";\n accountId: string;\n target: string;\n status: \"ACTIVE\" | \"PAUSED\" | \"ARCHIVED\" | \"DELETED\";\n}): Promise<void> {\n await stageOp({\n kind: input.kind,\n accountId: input.accountId,\n target: input.target,\n payload: { status: input.status },\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,oBAAoB;AAqBtB,SAAS,QAAQ,MAAgC,aAAqB;AAC3E,SAAO;AAAA,IACL,MAAM;AAAA,MACJ;AAAA,QACE,MAAM;AAAA,QACN,aAAa,GAAG,WAAW;AAAA,MAC7B;AAAA,MACA,OAAO,EAAE,OAAO,wBAAwB,KAAK;AAAA,IAC/C;AAAA,EACF;AACF;AAGA,eAAsB,cAAc,MAAgD;AAClF,UAAQ,MAAM,oBAAoB,IAAI,GAAG,QAAQ,SAAS,EAAE;AAC9D;AAGO,IAAM,cAAwC;AAAA,EACnD,QAAQ;AAAA,EACR,QAAQ,CAAC,kCAAkC,4BAA4B;AACzE;AAGO,SAAS,cAAc,OAA2C;AACvE,SAAO,EAAE,GAAG,aAAa,QAAQ,MAAM;AACzC;AAEO,SAAS,oBAAoB,SAAwB;AAC1D,oBAAkB,EAAE,IAAI,OAAO,OAAO,EAAE,MAAM,oBAAoB,QAAQ,EAAE,CAAC;AAC7E,UAAQ,KAAK,CAAC;AAChB;AAGO,SAAS,qBAAqB,SAAkC,OAA6C;AAClH,MAAI,QAAQ,WAAW,WAAW;AAChC;AAAA,MACE,6EAAwE,KAAK;AAAA,IAC/E;AAAA,EACF;AACF;AAOO,SAAS,gBAAgB,MAAwC;AACtE,MAAI,OAAO,SAAS,YAAY,KAAK,WAAW,GAAG;AACjD,WAAO,CAAC;AAAA,EACV;AACA,QAAM,SAAS,SAAS,KAA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,KAAK,SAAS,IAAI;AAAA,IAC3B,SAAS,KAAK;AACZ,UAAI,OAAO,SAAS,GAAG;AACrB,gBAAQ,OAAO,MAAM,8BAA8B,OAAO,IAAI,CAAC,UAAU,MAAM,GAAG,EAAE,KAAK,IAAI,CAAC;AAAA,CAAI;AAAA,MACpG;AACA,sBAAgB,GAAG;AAAA,IACrB;AAAA,EACF;AACA,oBAAkB,EAAE,IAAI,MAAM,MAAM,OAAO,CAAC;AAC9C;AAEA,eAAsB,kBAAkB,OAKtB;AAChB,QAAM,QAAQ;AAAA,IACZ,MAAM,MAAM;AAAA,IACZ,WAAW,MAAM;AAAA,IACjB,QAAQ,MAAM;AAAA,IACd,SAAS,EAAE,QAAQ,MAAM,OAAO;AAAA,EAClC,CAAC;AACH;","names":[]}
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
requireTarget,
|
|
6
6
|
stageOp,
|
|
7
7
|
stageOps
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-ATVUGOXL.js";
|
|
9
9
|
import {
|
|
10
10
|
repeatedValues
|
|
11
11
|
} from "./chunk-ERSX3MKH.js";
|
|
@@ -216,4 +216,4 @@ export {
|
|
|
216
216
|
labelsAttachCommand,
|
|
217
217
|
labelsDetachCommand
|
|
218
218
|
};
|
|
219
|
-
//# sourceMappingURL=chunk-
|
|
219
|
+
//# sourceMappingURL=chunk-J43KP5NE.js.map
|
|
@@ -28,22 +28,6 @@ function failValidation(message) {
|
|
|
28
28
|
function renderConfigValue(value) {
|
|
29
29
|
return value.includes("\n") ? value.replace(/\n/g, "\n ") : value;
|
|
30
30
|
}
|
|
31
|
-
var LONG_VALUE_CHARS = 200;
|
|
32
|
-
function sizeOf(value) {
|
|
33
|
-
const lines = value.split("\n").length;
|
|
34
|
-
return `${lines} ${lines === 1 ? "line" : "lines"}, ${value.length} chars`;
|
|
35
|
-
}
|
|
36
|
-
function listedTag(entry) {
|
|
37
|
-
const long = Object.entries(entry.config).filter(
|
|
38
|
-
([, value]) => value.includes("\n") || value.length > LONG_VALUE_CHARS
|
|
39
|
-
);
|
|
40
|
-
if (long.length === 0) {
|
|
41
|
-
return entry;
|
|
42
|
-
}
|
|
43
|
-
const config = Object.fromEntries(Object.entries(entry.config).filter(([key]) => !long.some(([k]) => k === key)));
|
|
44
|
-
return { ...entry, config, collapsed: Object.fromEntries(long.map(([key, value]) => [key, sizeOf(value)])) };
|
|
45
|
-
}
|
|
46
|
-
var COLLAPSED_HINT = "A long config value (a custom `code` script) shows as its size under `collapsed`; `baker tags list --full` prints it whole, to reuse in a follow-up change.";
|
|
47
31
|
function renderEffectiveEntry(entry) {
|
|
48
32
|
const parts = [entry.ref, entry.type];
|
|
49
33
|
if (entry.identifier !== void 0) {
|
|
@@ -62,9 +46,6 @@ function renderEffectiveEntry(entry) {
|
|
|
62
46
|
const header = parts.join(" ");
|
|
63
47
|
const identifyingField = TAG_IDENTIFYING_FIELD[entry.type];
|
|
64
48
|
const configLines = Object.entries(entry.config).filter(([key]) => key !== identifyingField).map(([key, value]) => ` ${key}: ${renderConfigValue(value)}`);
|
|
65
|
-
for (const [key, size] of Object.entries(entry.collapsed ?? {})) {
|
|
66
|
-
configLines.push(` ${key}: (${size} \u2014 --full prints it)`);
|
|
67
|
-
}
|
|
68
49
|
return configLines.length > 0 ? `${header}
|
|
69
50
|
${configLines.join("\n")}` : header;
|
|
70
51
|
}
|
|
@@ -78,9 +59,7 @@ function tagsListHints() {
|
|
|
78
59
|
export {
|
|
79
60
|
failApi,
|
|
80
61
|
failValidation,
|
|
81
|
-
listedTag,
|
|
82
|
-
COLLAPSED_HINT,
|
|
83
62
|
renderEffectiveEntry,
|
|
84
63
|
tagsListHints
|
|
85
64
|
};
|
|
86
|
-
//# sourceMappingURL=chunk-
|
|
65
|
+
//# sourceMappingURL=chunk-MIIY3MVK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/tags/shared.ts"],"sourcesContent":["import { TAG_IDENTIFYING_FIELD, type TagsEffectiveEntry } from \"@baker/api\";\nimport { ApiError } from \"../../client.ts\";\nimport { writeJson } from \"../../output.ts\";\n\nexport function failApi(err: unknown): never {\n if (err instanceof ApiError) {\n writeJson({ ok: false, error: { code: err.code, message: err.message } });\n process.exit(1);\n }\n if (err instanceof Error) {\n writeJson({ ok: false, error: { code: \"INTERNAL_ERROR\", message: err.message } });\n process.exit(1);\n }\n writeJson({ ok: false, error: { code: \"INTERNAL_ERROR\", message: \"Unexpected error\" } });\n process.exit(1);\n}\n\nexport function failValidation(message: string): never {\n writeJson({ ok: false, error: { code: \"VALIDATION_ERROR\", message } });\n process.exit(1);\n}\n\n/** Indent a possibly multi-line config value so long snippets (the `code` tag) stay readable. */\nfunction renderConfigValue(value: string): string {\n return value.includes(\"\\n\") ? value.replace(/\\n/g, \"\\n \") : value;\n}\n\nexport function renderEffectiveEntry(entry: TagsEffectiveEntry): string {\n const parts = [entry.ref, entry.type];\n if (entry.identifier !== undefined) {\n parts.push(entry.identifier);\n }\n if (entry.staged !== undefined) {\n parts.push(`[staged: ${entry.staged}]`);\n }\n const secretBits = [\n ...entry.secretsSet.map((field) => `${field} ✓ set`),\n ...entry.secretsPending.map((field) => `${field} ⏳ pending`),\n ];\n if (secretBits.length > 0) {\n parts.push(`[secrets: ${secretBits.join(\", \")}]`);\n }\n const header = parts.join(\" \");\n // All config values here are already redacted server-side (secrets stripped),\n // so every field printed is safe to read and reuse. Printing them in full lets\n // the agent auto-populate a follow-up change (e.g. the Clarity projectId or the\n // whole custom `code` snippet) instead of asking the user for a value we store.\n // Skip the identifying field — it's already on the header line as `identifier`.\n const identifyingField = TAG_IDENTIFYING_FIELD[entry.type];\n const configLines = Object.entries(entry.config)\n .filter(([key]) => key !== identifyingField)\n .map(([key, value]) => ` ${key}: ${renderConfigValue(value)}`);\n return configLines.length > 0 ? `${header}\\n${configLines.join(\"\\n\")}` : header;\n}\n\n/**\n * The write path, restated on every read.\n *\n * This family is read-only, so `list` is where a chat decides what to do about\n * a tag — and a production chat decided, from its tool list alone, that the\n * approval form did not exist, never called it, and filed the change as a Task\n * the user had to carry out by hand. The form is attached to every turn\n * (`baker_ui` rides along on each query), so \"it isn't there\" is a conclusion\n * only a failed call may reach.\n */\nexport function tagsListHints(): string[] {\n return [\n \"To create, edit or delete a tag, call the `request_tag_input` approval form (tool `mcp__baker_ui__request_tag_input`, server `baker_ui`) — it is attached to every turn of this chat and collects any secret values itself.\",\n \"Don't conclude the form is unavailable from your tool list: call it, and report what it returns. And never file a tag change as a Task — a Task hands the user work this chat can stage in one call.\",\n ];\n}\n"],"mappings":";;;;;;;;;;;AAIO,SAAS,QAAQ,KAAqB;AAC3C,MAAI,eAAe,UAAU;AAC3B,cAAU,EAAE,IAAI,OAAO,OAAO,EAAE,MAAM,IAAI,MAAM,SAAS,IAAI,QAAQ,EAAE,CAAC;AACxE,YAAQ,KAAK,CAAC;AAAA,EAChB;AACA,MAAI,eAAe,OAAO;AACxB,cAAU,EAAE,IAAI,OAAO,OAAO,EAAE,MAAM,kBAAkB,SAAS,IAAI,QAAQ,EAAE,CAAC;AAChF,YAAQ,KAAK,CAAC;AAAA,EAChB;AACA,YAAU,EAAE,IAAI,OAAO,OAAO,EAAE,MAAM,kBAAkB,SAAS,mBAAmB,EAAE,CAAC;AACvF,UAAQ,KAAK,CAAC;AAChB;AAEO,SAAS,eAAe,SAAwB;AACrD,YAAU,EAAE,IAAI,OAAO,OAAO,EAAE,MAAM,oBAAoB,QAAQ,EAAE,CAAC;AACrE,UAAQ,KAAK,CAAC;AAChB;AAGA,SAAS,kBAAkB,OAAuB;AAChD,SAAO,MAAM,SAAS,IAAI,IAAI,MAAM,QAAQ,OAAO,UAAU,IAAI;AACnE;AAEO,SAAS,qBAAqB,OAAmC;AACtE,QAAM,QAAQ,CAAC,MAAM,KAAK,MAAM,IAAI;AACpC,MAAI,MAAM,eAAe,QAAW;AAClC,UAAM,KAAK,MAAM,UAAU;AAAA,EAC7B;AACA,MAAI,MAAM,WAAW,QAAW;AAC9B,UAAM,KAAK,YAAY,MAAM,MAAM,GAAG;AAAA,EACxC;AACA,QAAM,aAAa;AAAA,IACjB,GAAG,MAAM,WAAW,IAAI,CAAC,UAAU,GAAG,KAAK,aAAQ;AAAA,IACnD,GAAG,MAAM,eAAe,IAAI,CAAC,UAAU,GAAG,KAAK,iBAAY;AAAA,EAC7D;AACA,MAAI,WAAW,SAAS,GAAG;AACzB,UAAM,KAAK,aAAa,WAAW,KAAK,IAAI,CAAC,GAAG;AAAA,EAClD;AACA,QAAM,SAAS,MAAM,KAAK,IAAI;AAM9B,QAAM,mBAAmB,sBAAsB,MAAM,IAAI;AACzD,QAAM,cAAc,OAAO,QAAQ,MAAM,MAAM,EAC5C,OAAO,CAAC,CAAC,GAAG,MAAM,QAAQ,gBAAgB,EAC1C,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM,OAAO,GAAG,KAAK,kBAAkB,KAAK,CAAC,EAAE;AAClE,SAAO,YAAY,SAAS,IAAI,GAAG,MAAM;AAAA,EAAK,YAAY,KAAK,IAAI,CAAC,KAAK;AAC3E;AAYO,SAAS,gBAA0B;AACxC,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
failWriteValidation,
|
|
3
3
|
parseDateFlag,
|
|
4
4
|
parseMoneyFlag
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-ATVUGOXL.js";
|
|
6
6
|
import {
|
|
7
7
|
repeatedValues
|
|
8
8
|
} from "./chunk-ERSX3MKH.js";
|
|
@@ -284,4 +284,4 @@ export {
|
|
|
284
284
|
clearFromFlags,
|
|
285
285
|
clearArg
|
|
286
286
|
};
|
|
287
|
-
//# sourceMappingURL=chunk-
|
|
287
|
+
//# sourceMappingURL=chunk-SXKBGTX2.js.map
|
package/dist/cli.js
CHANGED
|
@@ -625,7 +625,7 @@ Introspection: Run 'baker schema <command>' to inspect argument schemas.`
|
|
|
625
625
|
capabilities: () => import("./capabilities-FJAYWDY6.js").then((m) => m.capabilitiesCommand),
|
|
626
626
|
actions: () => import("./actions-PO35WQVS.js").then((m) => m.actionsCommand),
|
|
627
627
|
"scheduled-agents": () => import("./scheduled-agents-4UNG26CX.js").then((m) => m.scheduledAgentsCommand),
|
|
628
|
-
ads: () => import("./ads-
|
|
628
|
+
ads: () => import("./ads-B4HSLQMP.js").then((m) => m.adsCommand),
|
|
629
629
|
brand: () => import("./brand-ARJMSWJA.js").then((m) => m.brandCommand),
|
|
630
630
|
analytics: () => import("./analytics-EM4NNEG5.js").then((m) => m.analyticsCommand),
|
|
631
631
|
experiment: () => import("./experiment-KOCG7PPI.js").then((m) => m.experimentCommand),
|
|
@@ -638,7 +638,7 @@ Introspection: Run 'baker schema <command>' to inspect argument schemas.`
|
|
|
638
638
|
creatives: () => import("./creatives-EWTMQK7H.js").then((m) => m.creativesCommand),
|
|
639
639
|
rules: () => import("./rules-EPNUXMHG.js").then((m) => m.rulesCommand),
|
|
640
640
|
files: () => import("./files-4BWOK6EW.js").then((m) => m.filesCommand),
|
|
641
|
-
flows: () => import("./flows-
|
|
641
|
+
flows: () => import("./flows-PP6BRBD7.js").then((m) => m.flowsCommand),
|
|
642
642
|
funnel: () => import("./funnel-BFVSY5A6.js").then((m) => m.funnelCommand),
|
|
643
643
|
images: () => import("./images-R3EK4BDH.js").then((m) => m.imagesCommand),
|
|
644
644
|
studio: () => import("./studio-VU7CEAEU.js").then((m) => m.studioCommand),
|
|
@@ -647,7 +647,7 @@ Introspection: Run 'baker schema <command>' to inspect argument schemas.`
|
|
|
647
647
|
videos: () => import("./videos-FG64T3XK.js").then((m) => m.videosCommand),
|
|
648
648
|
testimonials: () => import("./testimonials-UCVT5VQY.js").then((m) => m.testimonialsCommand),
|
|
649
649
|
canvas: () => import("./canvas-NJV6RSX3.js").then((m) => m.canvasCommand),
|
|
650
|
-
tags: () => import("./tags-
|
|
650
|
+
tags: () => import("./tags-IQ6BCRLE.js").then((m) => m.tagsCommand),
|
|
651
651
|
"tag-manager": () => import("./tag-manager-UJDARCXH.js").then((m) => m.tagManagerCommand),
|
|
652
652
|
chats: () => import("./chats-65GTXYEC.js").then((m) => m.chatsCommand),
|
|
653
653
|
history: () => import("./history-K5ULNTEM.js").then((m) => m.historyCommand),
|