@koda-sl/baker-cli 0.22.0-dev.ecc541fb → 0.25.0-dev.f89d9a60
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 +75 -9
- package/dist/cli.js +1 -1
- package/dist/commands/actions/create.d.ts +0 -5
- package/dist/commands/actions/create.d.ts.map +1 -1
- package/dist/commands/actions/create.js +0 -15
- package/dist/commands/actions/create.js.map +1 -1
- package/dist/commands/actions/update.d.ts +0 -5
- package/dist/commands/actions/update.d.ts.map +1 -1
- package/dist/commands/actions/update.js +3 -14
- package/dist/commands/actions/update.js.map +1 -1
- package/dist/commands/ads/index.d.ts.map +1 -1
- package/dist/commands/ads/index.js +8 -3
- package/dist/commands/ads/index.js.map +1 -1
- package/dist/commands/ads/x/accounts.d.ts +14 -0
- package/dist/commands/ads/x/accounts.d.ts.map +1 -0
- package/dist/commands/ads/x/accounts.js +73 -0
- package/dist/commands/ads/x/accounts.js.map +1 -0
- package/dist/commands/ads/x/active-entities.d.ts +43 -0
- package/dist/commands/ads/x/active-entities.d.ts.map +1 -0
- package/dist/commands/ads/x/active-entities.js +88 -0
- package/dist/commands/ads/x/active-entities.js.map +1 -0
- package/dist/commands/ads/x/audiences.d.ts +19 -0
- package/dist/commands/ads/x/audiences.d.ts.map +1 -0
- package/dist/commands/ads/x/audiences.js +65 -0
- package/dist/commands/ads/x/audiences.js.map +1 -0
- package/dist/commands/ads/x/campaigns.d.ts +34 -0
- package/dist/commands/ads/x/campaigns.d.ts.map +1 -0
- package/dist/commands/ads/x/campaigns.js +56 -0
- package/dist/commands/ads/x/campaigns.js.map +1 -0
- package/dist/commands/ads/x/cards.d.ts +19 -0
- package/dist/commands/ads/x/cards.d.ts.map +1 -0
- package/dist/commands/ads/x/cards.js +65 -0
- package/dist/commands/ads/x/cards.js.map +1 -0
- package/dist/commands/ads/x/error-parser.d.ts +3 -0
- package/dist/commands/ads/x/error-parser.d.ts.map +1 -0
- package/dist/commands/ads/x/error-parser.js +80 -0
- package/dist/commands/ads/x/error-parser.js.map +1 -0
- package/dist/commands/ads/x/funding.d.ts +19 -0
- package/dist/commands/ads/x/funding.d.ts.map +1 -0
- package/dist/commands/ads/x/funding.js +65 -0
- package/dist/commands/ads/x/funding.js.map +1 -0
- package/dist/commands/ads/x/index.d.ts +2 -0
- package/dist/commands/ads/x/index.d.ts.map +1 -0
- package/dist/commands/ads/x/index.js +50 -0
- package/dist/commands/ads/x/index.js.map +1 -0
- package/dist/commands/ads/x/line-items.d.ts +34 -0
- package/dist/commands/ads/x/line-items.d.ts.map +1 -0
- package/dist/commands/ads/x/line-items.js +55 -0
- package/dist/commands/ads/x/line-items.js.map +1 -0
- package/dist/commands/ads/x/media.d.ts +24 -0
- package/dist/commands/ads/x/media.d.ts.map +1 -0
- package/dist/commands/ads/x/media.js +70 -0
- package/dist/commands/ads/x/media.js.map +1 -0
- package/dist/commands/ads/x/output.d.ts +13 -0
- package/dist/commands/ads/x/output.d.ts.map +1 -0
- package/dist/commands/ads/x/output.js +75 -0
- package/dist/commands/ads/x/output.js.map +1 -0
- package/dist/commands/ads/x/presets.d.ts +15 -0
- package/dist/commands/ads/x/presets.d.ts.map +1 -0
- package/dist/commands/ads/x/presets.js +60 -0
- package/dist/commands/ads/x/presets.js.map +1 -0
- package/dist/commands/ads/x/promoted-tweets.d.ts +29 -0
- package/dist/commands/ads/x/promoted-tweets.d.ts.map +1 -0
- package/dist/commands/ads/x/promoted-tweets.js +74 -0
- package/dist/commands/ads/x/promoted-tweets.js.map +1 -0
- package/dist/commands/ads/x/run-list.d.ts +17 -0
- package/dist/commands/ads/x/run-list.d.ts.map +1 -0
- package/dist/commands/ads/x/run-list.js +60 -0
- package/dist/commands/ads/x/run-list.js.map +1 -0
- package/dist/commands/ads/x/stats/index.d.ts +2 -0
- package/dist/commands/ads/x/stats/index.d.ts.map +1 -0
- package/dist/commands/ads/x/stats/index.js +32 -0
- package/dist/commands/ads/x/stats/index.js.map +1 -0
- package/dist/commands/ads/x/stats/job-create.d.ts +58 -0
- package/dist/commands/ads/x/stats/job-create.d.ts.map +1 -0
- package/dist/commands/ads/x/stats/job-create.js +95 -0
- package/dist/commands/ads/x/stats/job-create.js.map +1 -0
- package/dist/commands/ads/x/stats/job-status.d.ts +18 -0
- package/dist/commands/ads/x/stats/job-status.d.ts.map +1 -0
- package/dist/commands/ads/x/stats/job-status.js +58 -0
- package/dist/commands/ads/x/stats/job-status.js.map +1 -0
- package/dist/commands/ads/x/stats/job.d.ts +63 -0
- package/dist/commands/ads/x/stats/job.d.ts.map +1 -0
- package/dist/commands/ads/x/stats/job.js +183 -0
- package/dist/commands/ads/x/stats/job.js.map +1 -0
- package/dist/commands/ads/x/stats/sync.d.ts +73 -0
- package/dist/commands/ads/x/stats/sync.d.ts.map +1 -0
- package/dist/commands/ads/x/stats/sync.js +151 -0
- package/dist/commands/ads/x/stats/sync.js.map +1 -0
- package/dist/commands/ads/x/targeting-constants.d.ts +34 -0
- package/dist/commands/ads/x/targeting-constants.d.ts.map +1 -0
- package/dist/commands/ads/x/targeting-constants.js +80 -0
- package/dist/commands/ads/x/targeting-constants.js.map +1 -0
- package/dist/commands/ads/x/targeting-criteria.d.ts +24 -0
- package/dist/commands/ads/x/targeting-criteria.d.ts.map +1 -0
- package/dist/commands/ads/x/targeting-criteria.js +69 -0
- package/dist/commands/ads/x/targeting-criteria.js.map +1 -0
- package/dist/env.d.ts +1 -0
- package/dist/env.d.ts.map +1 -1
- package/dist/env.js +4 -0
- package/dist/env.js.map +1 -1
- package/dist/error-handler.d.ts +1 -1
- package/dist/error-handler.d.ts.map +1 -1
- package/dist/error-handler.js +3 -0
- package/dist/error-handler.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -27,6 +27,9 @@ export BAKER_GA4_PROPERTY_ID="properties/123456789"
|
|
|
27
27
|
# Optional: default GSC site URL
|
|
28
28
|
export BAKER_GSC_SITE_URL="https://example.com/"
|
|
29
29
|
|
|
30
|
+
# Optional: default X Ads account ID (base36)
|
|
31
|
+
export BAKER_X_ADS_ACCOUNT_ID="18ce53xyz"
|
|
32
|
+
|
|
30
33
|
# Required for `baker actions ...` commands that stage against a chat
|
|
31
34
|
export BAKER_CHAT_ID="<chat-id>"
|
|
32
35
|
```
|
|
@@ -36,6 +39,7 @@ export BAKER_CHAT_ID="<chat-id>"
|
|
|
36
39
|
- `BAKER_GOOGLE_ADS_CUSTOMER_ID` — default Google Ads customer ID (10 digits). Used when `--customer-id` is not passed. If neither is set and the account has exactly one Google Ads customer, it is auto-selected.
|
|
37
40
|
- `BAKER_GA4_PROPERTY_ID` — default GA4 property ID. Used when `--property-id` is not passed. If neither is set and exactly one property is connected, it is auto-selected.
|
|
38
41
|
- `BAKER_GSC_SITE_URL` — default GSC site URL. Used when `--site-url` is not passed. If neither is set and exactly one site is verified, it is auto-selected.
|
|
42
|
+
- `BAKER_X_ADS_ACCOUNT_ID` — default X Ads account ID (base36). Used when `--account-id` is not passed. If neither is set and exactly one X Ads account is connected, it is auto-selected.
|
|
39
43
|
|
|
40
44
|
## Output Format
|
|
41
45
|
|
|
@@ -688,6 +692,75 @@ All errors include a `fix` object with `action`, `correctedCommand` (when applic
|
|
|
688
692
|
|
|
689
693
|
---
|
|
690
694
|
|
|
695
|
+
### X (Twitter) Ads (`baker ads x`)
|
|
696
|
+
|
|
697
|
+
Read X Ads campaigns, line items, promoted tweets, creatives, audiences, and analytics. Powered by the X Ads API v12.
|
|
698
|
+
|
|
699
|
+
**Environment:**
|
|
700
|
+
- `BAKER_X_ADS_ACCOUNT_ID` — default account ID (base36). Used when `--account-id` is not passed. If neither is set and exactly one X Ads account is connected, it's auto-selected.
|
|
701
|
+
|
|
702
|
+
**Subcommands:**
|
|
703
|
+
|
|
704
|
+
| Subcommand | What it returns |
|
|
705
|
+
|---|---|
|
|
706
|
+
| `accounts` | All accessible X Ads accounts |
|
|
707
|
+
| `funding` | Funding instruments for an account |
|
|
708
|
+
| `campaigns` | Campaigns (filter by `--funding-instrument-ids`, `--campaign-ids`) |
|
|
709
|
+
| `line-items` | Line items / ad groups (filter by `--campaign-ids`, `--line-item-ids`) |
|
|
710
|
+
| `promoted-tweets` | Promoted tweets (filter by `--line-item-ids`) |
|
|
711
|
+
| `cards` | Website cards, video cards, carousels |
|
|
712
|
+
| `media` | Media library (images / GIFs / videos) — `--media-type IMAGE\|GIF\|VIDEO` |
|
|
713
|
+
| `audiences` | Custom audiences (size, targetable status) |
|
|
714
|
+
| `targeting-criteria` | Targeting attached to line items |
|
|
715
|
+
| `targeting-constants` | Lookup locations / interests / events / devices etc. — `--constant <name> --q "Madrid"` |
|
|
716
|
+
| `active-entities` | Entities with metric activity in a time range |
|
|
717
|
+
| `stats sync` | Synchronous analytics (≤7 days, no segmentation) |
|
|
718
|
+
| `stats job` | Async stats end-to-end (creates + polls + downloads + decompresses). Must run in the background (the harness enforces this). Use for ranges >7 days, segmented stats, or when sync limits are hit. |
|
|
719
|
+
| `stats job-create` | Low-level: create async stats job, return ID immediately |
|
|
720
|
+
| `stats job-status` | Low-level: poll job status / get download URL |
|
|
721
|
+
|
|
722
|
+
**Examples:**
|
|
723
|
+
|
|
724
|
+
```bash
|
|
725
|
+
baker ads x accounts
|
|
726
|
+
baker ads x campaigns --account-id 18ce53xyz
|
|
727
|
+
baker ads x line-items --account-id 18ce53xyz --campaign-ids abc
|
|
728
|
+
baker ads x promoted-tweets --account-id 18ce53xyz
|
|
729
|
+
|
|
730
|
+
# Sync analytics with a preset (saves tokens)
|
|
731
|
+
baker ads x stats sync --preset campaign-engagement-7d --entity-ids abc,def
|
|
732
|
+
|
|
733
|
+
# Free-form sync stats
|
|
734
|
+
baker ads x stats sync --account-id 18ce53xyz --entity LINE_ITEM \
|
|
735
|
+
--entity-ids abc,def --start-time 2026-05-01T00:00:00Z --end-time 2026-05-07T00:00:00Z \
|
|
736
|
+
--metric-groups ENGAGEMENT,BILLING --granularity DAY
|
|
737
|
+
|
|
738
|
+
# Async job, sync from the CLI's perspective (creates → polls → downloads → returns).
|
|
739
|
+
# Must be invoked with run_in_background: true. The harness will block otherwise.
|
|
740
|
+
baker ads x stats job --account-id 18ce53xyz --entity CAMPAIGN \
|
|
741
|
+
--entity-ids abc --start-time 2026-04-01T00:00:00Z --end-time 2026-05-01T00:00:00Z \
|
|
742
|
+
--metric-groups ENGAGEMENT,BILLING --segmentation-type LOCATIONS
|
|
743
|
+
|
|
744
|
+
# Low-level (don't wait, manage polling yourself):
|
|
745
|
+
baker ads x stats job-create --account-id 18ce53xyz --entity CAMPAIGN \
|
|
746
|
+
--entity-ids abc --start-time 2026-04-01T00:00:00Z --end-time 2026-05-01T00:00:00Z \
|
|
747
|
+
--metric-groups ENGAGEMENT,BILLING --segmentation-type LOCATIONS
|
|
748
|
+
baker ads x stats job-status --account-id 18ce53xyz --job-id <jobId>
|
|
749
|
+
|
|
750
|
+
# List sync presets
|
|
751
|
+
baker ads x stats sync --list-presets
|
|
752
|
+
|
|
753
|
+
# Targeting lookups
|
|
754
|
+
baker ads x targeting-constants --constant locations --q "Madrid" --country-code ES
|
|
755
|
+
baker ads x targeting-constants --constant interests
|
|
756
|
+
```
|
|
757
|
+
|
|
758
|
+
**Caching:** account list 1h · campaigns/line items/promoted tweets 1h (date-keyed) · cards/media/audiences 6h · stats sync 1h · targeting constants 7 days. Pass `--no-cache` to bypass.
|
|
759
|
+
|
|
760
|
+
**Rate limits:** server-side buckets (`xAds:read`, `xAds:write`, `xAds:analyticsSync`, `xAds:analyticsAsync`, `xAds:audiences`) sit well under X's published quotas; 429s honor `x-account-rate-limit-reset` / `x-rate-limit-reset` headers.
|
|
761
|
+
|
|
762
|
+
---
|
|
763
|
+
|
|
691
764
|
### Google Analytics 4 (`baker ga4`)
|
|
692
765
|
|
|
693
766
|
GA4 commands for multi-channel audits. Playbook-aligned presets, property health audits, and free-form Data API queries.
|
|
@@ -1374,8 +1447,8 @@ baker actions get <action-id>
|
|
|
1374
1447
|
baker actions claim <action-id> # live — required before update/complete/discard
|
|
1375
1448
|
baker actions release <action-id>
|
|
1376
1449
|
|
|
1377
|
-
baker actions create --name "Build hero" --description "..." --
|
|
1378
|
-
baker actions update <action-id> --name "Better name"
|
|
1450
|
+
baker actions create --name "Build hero" --description "..." --tag copy,landing
|
|
1451
|
+
baker actions update <action-id> --name "Better name"
|
|
1379
1452
|
baker actions complete <action-id> --note "What was done" # stages — applies on chat publish
|
|
1380
1453
|
baker actions discard <action-id> --reason "obsolete"
|
|
1381
1454
|
|
|
@@ -1397,13 +1470,6 @@ Permissions enforced server-side:
|
|
|
1397
1470
|
- Claiming an action already claimed by another chat returns `CONFLICT` with the other chat's title — pick a different action.
|
|
1398
1471
|
- All staged ops are reverted automatically when the chat is discarded.
|
|
1399
1472
|
|
|
1400
|
-
`--executor` (required on `create`):
|
|
1401
|
-
|
|
1402
|
-
- `agent` — the action can be executed end-to-end by an AI agent inside the sandbox (repo edits, Baker CLI, knowledge writes).
|
|
1403
|
-
- `human` — the action requires a human: UI access (Google Ads, HubSpot), credentials/OAuth setup, billing, contracts, in-person work, or business judgment. Surfaces in the `humanOnly` bucket of `baker actions list` — agents must not claim these.
|
|
1404
|
-
|
|
1405
|
-
If you discover after claiming that an action actually needs the other type, run `baker actions update <id> --executor human|agent` and `release` so the right party can pick it up.
|
|
1406
|
-
|
|
1407
1473
|
---
|
|
1408
1474
|
|
|
1409
1475
|
### `baker schema [command]`
|
package/dist/cli.js
CHANGED
|
@@ -12,7 +12,7 @@ import { videosCommand } from "./commands/videos/index.js";
|
|
|
12
12
|
const main = defineCommand({
|
|
13
13
|
meta: {
|
|
14
14
|
name: "baker",
|
|
15
|
-
version: "0.
|
|
15
|
+
version: "0.25.0",
|
|
16
16
|
description: `AI-agent CLI for finding and managing images, videos, testimonials, action items, and ad platform data in Baker.
|
|
17
17
|
|
|
18
18
|
Auth: Set BAKER_API_KEY (starts with bk_) and BAKER_API_URL environment variables.
|
|
@@ -10,11 +10,6 @@ export declare const createCommand: import("citty").CommandDef<{
|
|
|
10
10
|
readonly required: false;
|
|
11
11
|
readonly default: "";
|
|
12
12
|
};
|
|
13
|
-
readonly executor: {
|
|
14
|
-
readonly type: "string";
|
|
15
|
-
readonly description: "'agent' or 'human' — who can execute this action. Required.";
|
|
16
|
-
readonly required: false;
|
|
17
|
-
};
|
|
18
13
|
readonly tag: {
|
|
19
14
|
readonly type: "string";
|
|
20
15
|
readonly description: "Tag slugs (comma-separated, repeatable)";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/commands/actions/create.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/commands/actions/create.ts"],"names":[],"mappings":"AAuBA,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;EAsCxB,CAAC"}
|
|
@@ -14,11 +14,6 @@ registerSchema({
|
|
|
14
14
|
description: "Context-complete description: what / why / where / done-when",
|
|
15
15
|
required: false,
|
|
16
16
|
},
|
|
17
|
-
executor: {
|
|
18
|
-
type: "string",
|
|
19
|
-
description: "Who can execute this: 'agent' (sandbox-doable: repo edits, baker CLI, knowledge writes) or 'human' (UI access, OAuth, billing, contracts, in-person, business judgment). Required.",
|
|
20
|
-
required: true,
|
|
21
|
-
},
|
|
22
17
|
tag: { type: "string", description: "Tag slugs (comma-separated)", required: false },
|
|
23
18
|
"temp-id": { type: "string", description: "Custom tempId (auto-generated if omitted)", required: false },
|
|
24
19
|
},
|
|
@@ -31,11 +26,6 @@ export const createCommand = defineCommand({
|
|
|
31
26
|
args: {
|
|
32
27
|
name: { type: "string", description: "Action name", required: false },
|
|
33
28
|
description: { type: "string", description: "Description", required: false, default: "" },
|
|
34
|
-
executor: {
|
|
35
|
-
type: "string",
|
|
36
|
-
description: "'agent' or 'human' — who can execute this action. Required.",
|
|
37
|
-
required: false,
|
|
38
|
-
},
|
|
39
29
|
tag: { type: "string", description: "Tag slugs (comma-separated, repeatable)", required: false },
|
|
40
30
|
"temp-id": { type: "string", description: "Optional custom tempId", required: false },
|
|
41
31
|
},
|
|
@@ -45,10 +35,6 @@ export const createCommand = defineCommand({
|
|
|
45
35
|
if (!name || name.trim().length === 0) {
|
|
46
36
|
failValidation("--name is required.");
|
|
47
37
|
}
|
|
48
|
-
const executor = args.executor;
|
|
49
|
-
if (executor !== "agent" && executor !== "human") {
|
|
50
|
-
failValidation("--executor is required: 'agent' (sandbox-doable) or 'human' (UI access, OAuth, billing, contracts, in-person, judgment).");
|
|
51
|
-
}
|
|
52
38
|
const chatId = requireChatId();
|
|
53
39
|
const tempId = args["temp-id"] || generateTempId();
|
|
54
40
|
const tagSlugs = args.tag
|
|
@@ -62,7 +48,6 @@ export const createCommand = defineCommand({
|
|
|
62
48
|
tempId,
|
|
63
49
|
name,
|
|
64
50
|
description: args.description ?? "",
|
|
65
|
-
requiresHuman: executor === "human",
|
|
66
51
|
tagSlugs,
|
|
67
52
|
});
|
|
68
53
|
writeJson(response);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../src/commands/actions/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAEtE,cAAc,CAAC;IACb,OAAO,EAAE,gBAAgB;IACzB,WAAW,EACT,kIAAkI;IACpI,IAAI,EAAE;QACJ,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,4CAA4C,EAAE,QAAQ,EAAE,IAAI,EAAE;QACnG,W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EAAE,CAAC;YACb,OAAO,CAAC,GAAG,CAAC,CAAC;QACf,CAAC;IACH,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -19,10 +19,5 @@ export declare const updateCommand: import("citty").CommandDef<{
|
|
|
19
19
|
readonly description: "New description";
|
|
20
20
|
readonly required: false;
|
|
21
21
|
};
|
|
22
|
-
readonly executor: {
|
|
23
|
-
readonly type: "string";
|
|
24
|
-
readonly description: "Reclassify: 'agent' or 'human'";
|
|
25
|
-
readonly required: false;
|
|
26
|
-
};
|
|
27
22
|
}>;
|
|
28
23
|
//# sourceMappingURL=update.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../src/commands/actions/update.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../src/commands/actions/update.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;EAiCxB,CAAC"}
|
|
@@ -5,16 +5,11 @@ import { registerSchema } from "../../schemas.js";
|
|
|
5
5
|
import { failApi, failValidation, writeOk } from "./shared.js";
|
|
6
6
|
registerSchema({
|
|
7
7
|
command: "actions.update",
|
|
8
|
-
description: "Stage an update on a claimed action (name
|
|
8
|
+
description: "Stage an update on a claimed action (name and/or description). Applies on publish.",
|
|
9
9
|
args: {
|
|
10
10
|
id: { type: "string", description: "Action ID (must be claimed by current chat)", required: true },
|
|
11
11
|
name: { type: "string", description: "New name", required: false },
|
|
12
12
|
description: { type: "string", description: "New description", required: false },
|
|
13
|
-
executor: {
|
|
14
|
-
type: "string",
|
|
15
|
-
description: "Reclassify executor: 'agent' or 'human'.",
|
|
16
|
-
required: false,
|
|
17
|
-
},
|
|
18
13
|
},
|
|
19
14
|
});
|
|
20
15
|
export const updateCommand = defineCommand({
|
|
@@ -27,7 +22,6 @@ export const updateCommand = defineCommand({
|
|
|
27
22
|
"action-id": { type: "string", description: "Action ID", required: false },
|
|
28
23
|
name: { type: "string", description: "New name", required: false },
|
|
29
24
|
description: { type: "string", description: "New description", required: false },
|
|
30
|
-
executor: { type: "string", description: "Reclassify: 'agent' or 'human'", required: false },
|
|
31
25
|
},
|
|
32
26
|
run: async ({ args }) => {
|
|
33
27
|
try {
|
|
@@ -36,12 +30,8 @@ export const updateCommand = defineCommand({
|
|
|
36
30
|
failValidation("Action ID is required.");
|
|
37
31
|
}
|
|
38
32
|
validateConvexId(id);
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
failValidation("--executor must be 'agent' or 'human'.");
|
|
42
|
-
}
|
|
43
|
-
if (args.name === undefined && args.description === undefined && executor === undefined) {
|
|
44
|
-
failValidation("Provide at least one of --name, --description, --executor.");
|
|
33
|
+
if (args.name === undefined && args.description === undefined) {
|
|
34
|
+
failValidation("Provide at least one of --name, --description.");
|
|
45
35
|
}
|
|
46
36
|
const chatId = requireChatId();
|
|
47
37
|
await apiPost("/api/actions/update", {
|
|
@@ -49,7 +39,6 @@ export const updateCommand = defineCommand({
|
|
|
49
39
|
actionId: id,
|
|
50
40
|
name: args.name,
|
|
51
41
|
description: args.description,
|
|
52
|
-
...(executor !== undefined ? { requiresHuman: executor === "human" } : {}),
|
|
53
42
|
});
|
|
54
43
|
writeOk();
|
|
55
44
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../../src/commands/actions/update.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE/D,cAAc,CAAC;IACb,OAAO,EAAE,gB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QAClE,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,iBAAiB,EAAE,QAAQ,EAAE,KAAK,EAAE;KACjF;IACD,GAAG,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;QACtB,IAAI,CAAC;YACH,MAAM,EAAE,GAAI,IAAI,CAAC,EAAyB,IAAK,IAAI,CAAC,WAAW,CAAwB,CAAC;YACxF,IAAI,CAAC,EAAE,EAAE,CAAC;gBACR,cAAc,CAAC,wBAAwB,CAAC,CAAC;YAC3C,CAAC;YACD,gBAAgB,CAAC,EAAE,CAAC,CAAC;YACrB,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;gBAC9D,cAAc,CAAC,gDAAgD,CAAC,CAAC;YACnE,CAAC;YACD,MAAM,MAAM,GAAG,aAAa,EAAE,CAAC;YAC/B,MAAM,OAAO,CAAe,qBAAqB,EAAE;gBACjD,MAAM;gBACN,QAAQ,EAAE,EAAE;gBACZ,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,WAAW,EAAE,IAAI,CAAC,WAAW;aAC9B,CAAC,CAAC;YACH,OAAO,EAAE,CAAC;QACZ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,CAAC,GAAG,CAAC,CAAC;QACf,CAAC;IACH,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/ads/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/ads/index.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,UAAU,qDAmBrB,CAAC"}
|
|
@@ -1,19 +1,24 @@
|
|
|
1
1
|
import { defineCommand } from "citty";
|
|
2
2
|
import { googleCommand } from "./google/index.js";
|
|
3
|
+
import { xCommand } from "./x/index.js";
|
|
3
4
|
export const adsCommand = defineCommand({
|
|
4
5
|
meta: {
|
|
5
6
|
name: "ads",
|
|
6
|
-
description: `Ad platform commands.
|
|
7
|
+
description: `Ad platform commands. Supports Google Ads and X (Twitter) Ads.
|
|
7
8
|
|
|
8
9
|
Platforms:
|
|
9
|
-
google — Google Ads (GAQL queries, keywords, accounts)
|
|
10
|
+
google — Google Ads (GAQL queries, keywords, accounts, ad library)
|
|
11
|
+
x — X (Twitter) Ads (campaigns, line items, promoted tweets, analytics)
|
|
10
12
|
|
|
11
13
|
Examples:
|
|
12
14
|
baker ads google accounts
|
|
13
|
-
baker ads google query --preset campaign-performance --customer-id 1234567890
|
|
15
|
+
baker ads google query --preset campaign-performance --customer-id 1234567890
|
|
16
|
+
baker ads x accounts
|
|
17
|
+
baker ads x stats sync --preset campaign-engagement-7d --entity-ids abc,def`,
|
|
14
18
|
},
|
|
15
19
|
subCommands: {
|
|
16
20
|
google: googleCommand,
|
|
21
|
+
x: xCommand,
|
|
17
22
|
},
|
|
18
23
|
});
|
|
19
24
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/ads/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/ads/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,MAAM,CAAC,MAAM,UAAU,GAAG,aAAa,CAAC;IACtC,IAAI,EAAE;QACJ,IAAI,EAAE,KAAK;QACX,WAAW,EAAE;;;;;;;;;;8EAU6D;KAC3E;IACD,WAAW,EAAE;QACX,MAAM,EAAE,aAAa;QACrB,CAAC,EAAE,QAAQ;KACZ;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const accountsCommand: import("citty").CommandDef<{
|
|
2
|
+
readonly "no-cache": {
|
|
3
|
+
readonly type: "boolean";
|
|
4
|
+
readonly description: "Skip cache";
|
|
5
|
+
readonly required: false;
|
|
6
|
+
};
|
|
7
|
+
readonly output: {
|
|
8
|
+
readonly type: "string";
|
|
9
|
+
readonly description: "Format: json|csv|md";
|
|
10
|
+
readonly required: false;
|
|
11
|
+
readonly default: "json";
|
|
12
|
+
};
|
|
13
|
+
}>;
|
|
14
|
+
//# sourceMappingURL=accounts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accounts.d.ts","sourceRoot":"","sources":["../../../../src/commands/ads/x/accounts.ts"],"names":[],"mappings":"AAuCA,eAAO,MAAM,eAAe;;;;;;;;;;;;EAqC1B,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { defineCommand } from "citty";
|
|
2
|
+
import { ApiError, apiGet } from "../../../client.js";
|
|
3
|
+
import { handleConnectionError } from "../../../error-handler.js";
|
|
4
|
+
import { registerSchema } from "../../../schemas.js";
|
|
5
|
+
import { cacheGet, cacheSet } from "../cache.js";
|
|
6
|
+
import { writeAdsJson, writeAdsOutput } from "../output.js";
|
|
7
|
+
registerSchema({
|
|
8
|
+
command: "ads.x.accounts",
|
|
9
|
+
description: "List all accessible X Ads accounts. Returns accounts with id (base36), name, approval_status, timezone, currency. Run this first to find account IDs for other commands.",
|
|
10
|
+
args: {
|
|
11
|
+
"no-cache": { type: "boolean", description: "Skip cache, hit API directly", required: false },
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
function handleAccountsError(err) {
|
|
15
|
+
if (err instanceof ApiError) {
|
|
16
|
+
if (err.code === "UNAUTHORIZED" || err.code === "NOT_FOUND") {
|
|
17
|
+
handleConnectionError("x_ads", err.message);
|
|
18
|
+
}
|
|
19
|
+
const envelope = {
|
|
20
|
+
ok: false,
|
|
21
|
+
error: {
|
|
22
|
+
code: err.code,
|
|
23
|
+
message: err.message,
|
|
24
|
+
fix: { action: "reject", explanation: err.message },
|
|
25
|
+
retryable: false,
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
writeAdsJson(envelope);
|
|
29
|
+
process.exit(1);
|
|
30
|
+
}
|
|
31
|
+
writeAdsJson({ ok: false, error: { code: "NETWORK_ERROR", message: "Unexpected error" } });
|
|
32
|
+
process.exit(1);
|
|
33
|
+
}
|
|
34
|
+
export const accountsCommand = defineCommand({
|
|
35
|
+
meta: {
|
|
36
|
+
name: "accounts",
|
|
37
|
+
description: `List accessible X Ads accounts. Returns account IDs needed for all other commands.
|
|
38
|
+
|
|
39
|
+
Examples:
|
|
40
|
+
baker ads x accounts`,
|
|
41
|
+
},
|
|
42
|
+
args: {
|
|
43
|
+
"no-cache": { type: "boolean", description: "Skip cache", required: false },
|
|
44
|
+
output: { type: "string", description: "Format: json|csv|md", required: false, default: "json" },
|
|
45
|
+
},
|
|
46
|
+
run: async ({ args }) => {
|
|
47
|
+
const useCache = !args["no-cache"];
|
|
48
|
+
if (useCache) {
|
|
49
|
+
const cached = cacheGet("x-accounts", "list");
|
|
50
|
+
if (cached) {
|
|
51
|
+
writeAdsJson({ ok: true, data: cached.data, cached: true });
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
try {
|
|
56
|
+
const params = !useCache ? { "skip-cache": "true" } : undefined;
|
|
57
|
+
const data = await apiGet("/api/ads/x/accounts", params);
|
|
58
|
+
if (useCache) {
|
|
59
|
+
cacheSet("x-accounts", "list", data, 60 * 60 * 1000);
|
|
60
|
+
}
|
|
61
|
+
const format = args.output || "json";
|
|
62
|
+
if (format !== "json") {
|
|
63
|
+
writeAdsOutput(data, format);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
writeAdsJson({ ok: true, data });
|
|
67
|
+
}
|
|
68
|
+
catch (err) {
|
|
69
|
+
handleAccountsError(err);
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
//# sourceMappingURL=accounts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accounts.js","sourceRoot":"","sources":["../../../../src/commands/ads/x/accounts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAI5D,cAAc,CAAC;IACb,OAAO,EAAE,gBAAgB;IACzB,WAAW,EACT,0KAA0K;IAC5K,IAAI,EAAE;QACJ,UAAU,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,8BAA8B,EAAE,QAAQ,EAAE,KAAK,EAAE;KAC9F;CACF,CAAC,CAAC;AAEH,SAAS,mBAAmB,CAAC,GAAY;IACvC,IAAI,GAAG,YAAY,QAAQ,EAAE,CAAC;QAC5B,IAAI,GAAG,CAAC,IAAI,KAAK,cAAc,IAAI,GAAG,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;YAC5D,qBAAqB,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;QAC9C,CAAC;QACD,MAAM,QAAQ,GAAqB;YACjC,EAAE,EAAE,KAAK;YACT,KAAK,EAAE;gBACL,IAAI,EAAE,GAAG,CAAC,IAAI;gBACd,OAAO,EAAE,GAAG,CAAC,OAAO;gBACpB,GAAG,EAAE,EAA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,CAAC,CAAC,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;YAChE,MAAM,IAAI,GAAG,MAAM,MAAM,CAAiB,qBAAqB,EAAE,MAAM,CAAC,CAAC;YACzE,IAAI,QAAQ,EAAE,CAAC;gBACb,QAAQ,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;YACvD,CAAC;YACD,MAAM,MAAM,GAAI,IAAI,CAAC,MAAiB,IAAI,MAAM,CAAC;YACjD,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;gBACtB,cAAc,CAAC,IAAiD,EAAE,MAAM,CAAC,CAAC;gBAC1E,OAAO;YACT,CAAC;YACD,YAAY,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QACnC,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,mBAAmB,CAAC,GAAG,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export declare const activeEntitiesCommand: import("citty").CommandDef<{
|
|
2
|
+
readonly "account-id": {
|
|
3
|
+
readonly type: "string";
|
|
4
|
+
readonly description: "X Ads account ID";
|
|
5
|
+
readonly required: false;
|
|
6
|
+
};
|
|
7
|
+
readonly entity: {
|
|
8
|
+
readonly type: "string";
|
|
9
|
+
readonly description: "CAMPAIGN | LINE_ITEM | PROMOTED_TWEET";
|
|
10
|
+
readonly required: true;
|
|
11
|
+
};
|
|
12
|
+
readonly "start-time": {
|
|
13
|
+
readonly type: "string";
|
|
14
|
+
readonly description: "ISO 8601 hour-aligned start";
|
|
15
|
+
readonly required: true;
|
|
16
|
+
};
|
|
17
|
+
readonly "end-time": {
|
|
18
|
+
readonly type: "string";
|
|
19
|
+
readonly description: "ISO 8601 hour-aligned end";
|
|
20
|
+
readonly required: true;
|
|
21
|
+
};
|
|
22
|
+
readonly "campaign-ids": {
|
|
23
|
+
readonly type: "string";
|
|
24
|
+
readonly description: "CSV of campaign IDs";
|
|
25
|
+
readonly required: false;
|
|
26
|
+
};
|
|
27
|
+
readonly "line-item-ids": {
|
|
28
|
+
readonly type: "string";
|
|
29
|
+
readonly description: "CSV of line item IDs";
|
|
30
|
+
readonly required: false;
|
|
31
|
+
};
|
|
32
|
+
readonly "funding-instrument-ids": {
|
|
33
|
+
readonly type: "string";
|
|
34
|
+
readonly description: "CSV of funding instrument IDs";
|
|
35
|
+
readonly required: false;
|
|
36
|
+
};
|
|
37
|
+
readonly "no-cache": {
|
|
38
|
+
readonly type: "boolean";
|
|
39
|
+
readonly description: "Skip cache";
|
|
40
|
+
readonly required: false;
|
|
41
|
+
};
|
|
42
|
+
}>;
|
|
43
|
+
//# sourceMappingURL=active-entities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"active-entities.d.ts","sourceRoot":"","sources":["../../../../src/commands/ads/x/active-entities.ts"],"names":[],"mappings":"AAiCA,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuDhC,CAAC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { defineCommand } from "citty";
|
|
2
|
+
import { ApiError, apiPost } from "../../../client.js";
|
|
3
|
+
import { registerSchema } from "../../../schemas.js";
|
|
4
|
+
import { cacheGet, cacheSet } from "../cache.js";
|
|
5
|
+
import { writeAdsJson } from "../output.js";
|
|
6
|
+
import { parseXApiError } from "./error-parser.js";
|
|
7
|
+
import { resolveXAccountId } from "./output.js";
|
|
8
|
+
registerSchema({
|
|
9
|
+
command: "ads.x.activeEntities",
|
|
10
|
+
description: "List entities (campaigns/line items) that had metric activity within a time range. Use this to narrow which entities to query for stats. Time range max 90 days. Times must be ISO 8601 hour-aligned.",
|
|
11
|
+
args: {
|
|
12
|
+
"account-id": { type: "string", description: "X Ads account ID", required: false },
|
|
13
|
+
entity: { type: "string", description: "CAMPAIGN | LINE_ITEM | PROMOTED_TWEET", required: true },
|
|
14
|
+
"start-time": { type: "string", description: "ISO 8601 hour-aligned start", required: true },
|
|
15
|
+
"end-time": { type: "string", description: "ISO 8601 hour-aligned end", required: true },
|
|
16
|
+
"campaign-ids": { type: "string", description: "CSV of campaign IDs", required: false },
|
|
17
|
+
"line-item-ids": { type: "string", description: "CSV of line item IDs", required: false },
|
|
18
|
+
"funding-instrument-ids": { type: "string", description: "CSV of funding instrument IDs", required: false },
|
|
19
|
+
"no-cache": { type: "boolean", description: "Skip cache", required: false },
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
function parseCsv(v) {
|
|
23
|
+
if (typeof v !== "string" || v.length === 0)
|
|
24
|
+
return undefined;
|
|
25
|
+
const parts = v
|
|
26
|
+
.split(",")
|
|
27
|
+
.map((s) => s.trim())
|
|
28
|
+
.filter(Boolean);
|
|
29
|
+
return parts.length > 0 ? parts : undefined;
|
|
30
|
+
}
|
|
31
|
+
export const activeEntitiesCommand = defineCommand({
|
|
32
|
+
meta: {
|
|
33
|
+
name: "active-entities",
|
|
34
|
+
description: `List entities with metric activity in a time range.
|
|
35
|
+
|
|
36
|
+
Examples:
|
|
37
|
+
baker ads x active-entities --account-id 18ce53xyz --entity LINE_ITEM \\
|
|
38
|
+
--start-time 2026-04-30T00:00:00Z --end-time 2026-05-07T00:00:00Z`,
|
|
39
|
+
},
|
|
40
|
+
args: {
|
|
41
|
+
"account-id": { type: "string", description: "X Ads account ID", required: false },
|
|
42
|
+
entity: { type: "string", description: "CAMPAIGN | LINE_ITEM | PROMOTED_TWEET", required: true },
|
|
43
|
+
"start-time": { type: "string", description: "ISO 8601 hour-aligned start", required: true },
|
|
44
|
+
"end-time": { type: "string", description: "ISO 8601 hour-aligned end", required: true },
|
|
45
|
+
"campaign-ids": { type: "string", description: "CSV of campaign IDs", required: false },
|
|
46
|
+
"line-item-ids": { type: "string", description: "CSV of line item IDs", required: false },
|
|
47
|
+
"funding-instrument-ids": { type: "string", description: "CSV of funding instrument IDs", required: false },
|
|
48
|
+
"no-cache": { type: "boolean", description: "Skip cache", required: false },
|
|
49
|
+
},
|
|
50
|
+
run: async ({ args }) => {
|
|
51
|
+
const accountId = await resolveXAccountId(args);
|
|
52
|
+
const useCache = !args["no-cache"];
|
|
53
|
+
const body = {
|
|
54
|
+
accountId,
|
|
55
|
+
entity: args.entity,
|
|
56
|
+
startTime: args["start-time"],
|
|
57
|
+
endTime: args["end-time"],
|
|
58
|
+
fundingInstrumentIds: parseCsv(args["funding-instrument-ids"]),
|
|
59
|
+
campaignIds: parseCsv(args["campaign-ids"]),
|
|
60
|
+
lineItemIds: parseCsv(args["line-item-ids"]),
|
|
61
|
+
skipCache: !useCache || undefined,
|
|
62
|
+
};
|
|
63
|
+
const cacheKey = `active-entities:${JSON.stringify(body)}`;
|
|
64
|
+
if (useCache) {
|
|
65
|
+
const cached = cacheGet("x-account-data", cacheKey);
|
|
66
|
+
if (cached) {
|
|
67
|
+
writeAdsJson({ ok: true, data: cached.data, cached: true });
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
try {
|
|
72
|
+
const data = await apiPost("/api/ads/x/active-entities", body);
|
|
73
|
+
if (useCache) {
|
|
74
|
+
cacheSet("x-account-data", cacheKey, data, 5 * 60 * 1000);
|
|
75
|
+
}
|
|
76
|
+
writeAdsJson({ ok: true, data });
|
|
77
|
+
}
|
|
78
|
+
catch (err) {
|
|
79
|
+
if (err instanceof ApiError) {
|
|
80
|
+
writeAdsJson(parseXApiError(err.message, accountId));
|
|
81
|
+
process.exit(1);
|
|
82
|
+
}
|
|
83
|
+
writeAdsJson({ ok: false, error: { code: "NETWORK_ERROR", message: "Unexpected error" } });
|
|
84
|
+
process.exit(1);
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
//# sourceMappingURL=active-entities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
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AC;QACH,CAAC;QACD,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,OAAO,CAAY,4BAA4B,EAAE,IAAI,CAAC,CAAC;YAC1E,IAAI,QAAQ,EAAE,CAAC;gBACb,QAAQ,CAAC,gBAAgB,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;YAC5D,CAAC;YACD,YAAY,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QACnC,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,GAAG,YAAY,QAAQ,EAAE,CAAC;gBAC5B,YAAY,CAAC,cAAc,CAAC,GAAG,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC;gBACrD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAClB,CAAC;YACD,YAAY,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,kBAAkB,EAAE,EAAE,CAAC,CAAC;YAC3F,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare const audiencesCommand: import("citty").CommandDef<{
|
|
2
|
+
readonly "account-id": {
|
|
3
|
+
readonly type: "string";
|
|
4
|
+
readonly description: "X Ads account ID";
|
|
5
|
+
readonly required: false;
|
|
6
|
+
};
|
|
7
|
+
readonly "no-cache": {
|
|
8
|
+
readonly type: "boolean";
|
|
9
|
+
readonly description: "Skip cache";
|
|
10
|
+
readonly required: false;
|
|
11
|
+
};
|
|
12
|
+
readonly output: {
|
|
13
|
+
readonly type: "string";
|
|
14
|
+
readonly description: "Format: json|csv|md";
|
|
15
|
+
readonly required: false;
|
|
16
|
+
readonly default: "json";
|
|
17
|
+
};
|
|
18
|
+
}>;
|
|
19
|
+
//# sourceMappingURL=audiences.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audiences.d.ts","sourceRoot":"","sources":["../../../../src/commands/ads/x/audiences.ts"],"names":[],"mappings":"AAkBA,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;EA+C3B,CAAC"}
|