@koda-sl/baker-cli 0.886.0 → 0.887.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/activities-YXZ6PLZU.js +141 -0
- package/dist/activities-YXZ6PLZU.js.map +1 -0
- package/dist/{ads-UFZBMSLN.js → ads-EPFWBJ5V.js} +2 -2
- package/dist/cli.js +1 -1
- package/dist/{meta-ZQXCUKHQ.js → meta-6QC6KAPS.js} +2 -2
- package/package.json +1 -1
- package/dist/activities-DYI25TF4.js +0 -93
- package/dist/activities-DYI25TF4.js.map +0 -1
- /package/dist/{ads-UFZBMSLN.js.map → ads-EPFWBJ5V.js.map} +0 -0
- /package/dist/{meta-ZQXCUKHQ.js.map → meta-6QC6KAPS.js.map} +0 -0
package/README.md
CHANGED
|
@@ -1755,7 +1755,7 @@ Status changes are `pause|resume|archive|delete` subcommands on `campaigns`/`ads
|
|
|
1755
1755
|
|
|
1756
1756
|
To find one entity by name, pass `--name-contains <text>` to `campaigns`, `adsets` or `ads`: Meta matches it server-side (case-insensitive), so only the matching rows are read instead of the whole account.
|
|
1757
1757
|
|
|
1758
|
-
**`activities`** prints the 50 newest events, with a hint when there are more; `--limit <n>` prints more (one read returns at most 5000 — narrow `--days` past that).
|
|
1758
|
+
**`activities`** prints the 50 newest events, with a hint when there are more; `--limit <n>` prints more (one read returns at most 5000 — narrow `--days` past that). To find something instead of reading the whole log, filter it server-side: `--object-id <id,id>` keeps those campaigns', ad sets' or ads' own events (a campaign's id does not bring its ad sets' or ads' events — name their ids too), `--search <text>` keeps the events holding that text in any field (`--search dsa`, any case), and `--exclude-system` keeps only the changes people made, leaving out Meta's own, its automated rules' (`asa_auto`) and billing. Filters look through the 5000 newest events of the window; a hint says when it held more, so narrow `--days`.
|
|
1759
1759
|
|
|
1760
1760
|
**Pagination** is auto-drained (no manual cursor handling).
|
|
1761
1761
|
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import {
|
|
2
|
+
META_LIST_SHAPE_ARGS,
|
|
3
|
+
registerMetaListSchema,
|
|
4
|
+
shapeMetaListRows,
|
|
5
|
+
writeMetaListRows
|
|
6
|
+
} from "./chunk-AMCW2IG7.js";
|
|
7
|
+
import "./chunk-PRPSV4VB.js";
|
|
8
|
+
import {
|
|
9
|
+
LISTING_ACCOUNT_ARG,
|
|
10
|
+
accountsInScope,
|
|
11
|
+
csvOrJson,
|
|
12
|
+
handleMetaError,
|
|
13
|
+
loggedAt,
|
|
14
|
+
readEachAccount
|
|
15
|
+
} from "./chunk-LDL5VBBD.js";
|
|
16
|
+
import "./chunk-QALAJNBG.js";
|
|
17
|
+
import {
|
|
18
|
+
NO_CACHE_ARG
|
|
19
|
+
} from "./chunk-IHH672FX.js";
|
|
20
|
+
import "./chunk-7CILUDW2.js";
|
|
21
|
+
import "./chunk-7W5KGO5H.js";
|
|
22
|
+
import {
|
|
23
|
+
apiGetWithHeaders
|
|
24
|
+
} from "./chunk-NRJ6A3IF.js";
|
|
25
|
+
import "./chunk-GJBDT4AD.js";
|
|
26
|
+
import "./chunk-7AEQWLLO.js";
|
|
27
|
+
import "./chunk-WZDUKGGN.js";
|
|
28
|
+
import "./chunk-YQSBHWOI.js";
|
|
29
|
+
|
|
30
|
+
// src/commands/ads/meta/activities.ts
|
|
31
|
+
import { defineCommand } from "citty";
|
|
32
|
+
var SHOWN_EVENTS = 50;
|
|
33
|
+
var READ_CAP = 5e3;
|
|
34
|
+
var SEARCH_CAPPED_HEADER = "X-Baker-Search-Capped";
|
|
35
|
+
function readHints(returned, shown, filtered, searchedOnly, severalAccounts) {
|
|
36
|
+
const window = Math.min(shown, READ_CAP);
|
|
37
|
+
const more = returned > window && window === shown ? [
|
|
38
|
+
`Showing the ${shown} newest events; there are more. --limit <n> prints more, ${filtered ? "or narrow --days." : "or keep only what you need with --object-id <id>, --search <text> or --exclude-system."}`
|
|
39
|
+
] : returned >= READ_CAP ? [`Showing the ${READ_CAP} newest events, the most one read returns; there may be more. Narrow --days.`] : [];
|
|
40
|
+
return [
|
|
41
|
+
...more,
|
|
42
|
+
...searchedOnly.map(
|
|
43
|
+
({ accountId, scanned }) => `Searched only the ${scanned} newest events of the window${severalAccounts ? ` in ${accountId}` : ""}, the most one read looks through; older events were not searched. Narrow --days to search them.`
|
|
44
|
+
)
|
|
45
|
+
];
|
|
46
|
+
}
|
|
47
|
+
var listArgs = {
|
|
48
|
+
"account-id": LISTING_ACCOUNT_ARG,
|
|
49
|
+
days: { type: "string", description: "Lookback days (default 7)" },
|
|
50
|
+
limit: {
|
|
51
|
+
type: "string",
|
|
52
|
+
description: `Events to print, newest first (default ${SHOWN_EVENTS}); a hint says when there are more`
|
|
53
|
+
},
|
|
54
|
+
"object-id": {
|
|
55
|
+
type: "string",
|
|
56
|
+
description: "Only the events on these objects (CSV of campaign, ad set or ad ids), e.g. --object-id 120211,120212"
|
|
57
|
+
},
|
|
58
|
+
search: {
|
|
59
|
+
type: "string",
|
|
60
|
+
description: "Only the events holding this text in any field (event type, names, the raw change), any case, e.g. --search dsa or --search budget"
|
|
61
|
+
},
|
|
62
|
+
"exclude-system": {
|
|
63
|
+
type: "boolean",
|
|
64
|
+
description: "Only the changes people made: leaves out the events Meta itself, its automated rules (asa_auto) and billing made"
|
|
65
|
+
},
|
|
66
|
+
"no-cache": NO_CACHE_ARG,
|
|
67
|
+
...META_LIST_SHAPE_ARGS
|
|
68
|
+
};
|
|
69
|
+
registerMetaListSchema(
|
|
70
|
+
"activities",
|
|
71
|
+
"Account change log, as a table by default, one row per event: event_time, event_type, actor_name, object_type, object_name, object_id, and change ('old \u2192 new' when the change is a single value). Prints the 50 newest events; a hint says when there are more (--limit <n>). Start here: baker ads meta activities --account-id act_123 --days 2. To find something, filter rather than read everything: --object-id <id,id> keeps those objects' own events (a campaign's id does not bring its ad sets' or ads' events: name them too), --search <text> keeps the events holding that text (event type, names, the raw change), --exclude-system keeps only the changes people made. --fields event_time,object_name,extra_data or --full for the raw change payload; --output json returns the rows in the envelope. With no --account-id and several accounts connected, every account is read and each row leads with its account_id.",
|
|
72
|
+
listArgs
|
|
73
|
+
);
|
|
74
|
+
var activitiesCommand = defineCommand({
|
|
75
|
+
meta: {
|
|
76
|
+
name: "activities",
|
|
77
|
+
description: `Audit log of recent ad-account changes (created, paused, edited). Default lookback 7 days,
|
|
78
|
+
~90 day retention server-side. Prints the 50 newest events (--limit for more); a hint says when there are more.
|
|
79
|
+
|
|
80
|
+
A table by default, one row per event: event_time, event_type, actor_name, object_type,
|
|
81
|
+
object_name, object_id, and change ("old \u2192 new" when the change is a single value: status,
|
|
82
|
+
name, budget, goal). --fields takes dotted paths (extra_data holds the raw change); --full returns
|
|
83
|
+
every field Meta sent; --output json returns the rows as JSON.
|
|
84
|
+
|
|
85
|
+
To find something, filter instead of printing everything: --object-id keeps the events on
|
|
86
|
+
those campaigns, ad sets or ads themselves (a campaign's id does not bring its ad sets' or ads'
|
|
87
|
+
events: name their ids too); --search keeps the events holding that text in any field (event
|
|
88
|
+
type, names, the raw change), any case; --exclude-system keeps only the changes people made,
|
|
89
|
+
leaving out Meta's own, its automated rules' (asa_auto) and billing. Filters look through the
|
|
90
|
+
5000 newest events of the window; a hint says when it held more.
|
|
91
|
+
|
|
92
|
+
Examples:
|
|
93
|
+
baker ads meta activities --account-id act_123 --days 14
|
|
94
|
+
baker ads meta activities --account-id act_123 --days 2 --output json
|
|
95
|
+
baker ads meta activities --account-id act_123 --days 30 --object-id 120211
|
|
96
|
+
baker ads meta activities --account-id act_123 --days 90 --search dsa
|
|
97
|
+
baker ads meta activities --account-id act_123 --days 10 --exclude-system
|
|
98
|
+
baker ads meta activities --account-id act_123 --fields event_time,object_name,extra_data`
|
|
99
|
+
},
|
|
100
|
+
args: listArgs,
|
|
101
|
+
run: async ({ args }) => {
|
|
102
|
+
const accounts = await accountsInScope(args);
|
|
103
|
+
try {
|
|
104
|
+
const params = {};
|
|
105
|
+
if (args.days) params.days = args.days;
|
|
106
|
+
if (args["object-id"]) params["object-id"] = args["object-id"];
|
|
107
|
+
if (args.search) params.search = args.search;
|
|
108
|
+
if (args["exclude-system"]) params["exclude-system"] = "true";
|
|
109
|
+
const filtered = Boolean(args["object-id"] || args.search || args["exclude-system"]);
|
|
110
|
+
const shown = Number(args.limit ?? SHOWN_EVENTS);
|
|
111
|
+
if (!Number.isInteger(shown) || shown < 1) handleMetaError(new Error("--limit must be a whole number of events"));
|
|
112
|
+
params.limit = String(Math.min(shown + 1, READ_CAP));
|
|
113
|
+
if (args["no-cache"]) params["skip-cache"] = "true";
|
|
114
|
+
const searchedOnly = [];
|
|
115
|
+
const read = await readEachAccount(
|
|
116
|
+
accounts,
|
|
117
|
+
async (accountId) => {
|
|
118
|
+
const { data: data2, headers } = await apiGetWithHeaders(
|
|
119
|
+
"/api/ads/meta/activities",
|
|
120
|
+
{ ...params, "account-id": accountId }
|
|
121
|
+
);
|
|
122
|
+
const scanned = headers.get(SEARCH_CAPPED_HEADER);
|
|
123
|
+
if (scanned) searchedOnly.push({ accountId, scanned });
|
|
124
|
+
return data2;
|
|
125
|
+
},
|
|
126
|
+
{ time: (row) => loggedAt(row.event_time) }
|
|
127
|
+
);
|
|
128
|
+
const { rows: data, accountOf } = read;
|
|
129
|
+
const window = Math.min(shown, READ_CAP);
|
|
130
|
+
const shaped = shapeMetaListRows("activities", data.slice(0, window), args, accountOf?.slice(0, window));
|
|
131
|
+
const hints = readHints(data.length, shown, filtered, searchedOnly, accounts.length > 1);
|
|
132
|
+
writeMetaListRows("activities", shaped, csvOrJson(args), [...read.hints, ...hints]);
|
|
133
|
+
} catch (err) {
|
|
134
|
+
handleMetaError(err);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
export {
|
|
139
|
+
activitiesCommand
|
|
140
|
+
};
|
|
141
|
+
//# sourceMappingURL=activities-YXZ6PLZU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/ads/meta/activities.ts"],"sourcesContent":["import { defineCommand } from \"citty\";\nimport { NO_CACHE_ARG } from \"../../../cache-flag.ts\";\nimport { apiGetWithHeaders } from \"../../../client.ts\";\nimport { META_LIST_SHAPE_ARGS, registerMetaListSchema, shapeMetaListRows, writeMetaListRows } from \"./list-rows.ts\";\nimport {\n accountsInScope,\n csvOrJson,\n handleMetaError,\n LISTING_ACCOUNT_ARG,\n loggedAt,\n readEachAccount,\n} from \"./shared.ts\";\n\n/** Events printed unless --limit names another number: a busy month printed 96 KB the agent cut with head (BAKER-1222). */\nconst SHOWN_EVENTS = 50;\n\n/** The most events one read returns (the activities route's cap): a read that reaches it may have left older ones out. */\nconst READ_CAP = 5000;\n\n/** Set by the route on a filtered read that searched only the newest events of the window: older ones went unsearched. */\nconst SEARCH_CAPPED_HEADER = \"X-Baker-Search-Capped\";\n\n/**\n * What a read left out: more events than printed, a read at its cap, or a filtered read that searched only the\n * newest events of a window holding more (`searchedOnly`, from the route), so \"no match\" never reads as \"never\".\n */\nfunction readHints(\n returned: number,\n shown: number,\n filtered: boolean,\n searchedOnly: ReadonlyArray<{ accountId: string; scanned: string }>,\n severalAccounts: boolean,\n): string[] {\n const window = Math.min(shown, READ_CAP);\n const more =\n returned > window && window === shown\n ? [\n `Showing the ${shown} newest events; there are more. --limit <n> prints more, ${\n filtered\n ? \"or narrow --days.\"\n : \"or keep only what you need with --object-id <id>, --search <text> or --exclude-system.\"\n }`,\n ]\n : returned >= READ_CAP\n ? [`Showing the ${READ_CAP} newest events, the most one read returns; there may be more. Narrow --days.`]\n : [];\n return [\n ...more,\n ...searchedOnly.map(\n ({ accountId, scanned }) =>\n `Searched only the ${scanned} newest events of the window${severalAccounts ? ` in ${accountId}` : \"\"}, the most one read looks through; older events were not searched. Narrow --days to search them.`,\n ),\n ];\n}\n\nconst listArgs = {\n \"account-id\": LISTING_ACCOUNT_ARG,\n days: { type: \"string\", description: \"Lookback days (default 7)\" },\n limit: {\n type: \"string\",\n description: `Events to print, newest first (default ${SHOWN_EVENTS}); a hint says when there are more`,\n },\n \"object-id\": {\n type: \"string\",\n description: \"Only the events on these objects (CSV of campaign, ad set or ad ids), e.g. --object-id 120211,120212\",\n },\n search: {\n type: \"string\",\n description:\n \"Only the events holding this text in any field (event type, names, the raw change), any case, e.g. --search dsa or --search budget\",\n },\n \"exclude-system\": {\n type: \"boolean\",\n description:\n \"Only the changes people made: leaves out the events Meta itself, its automated rules (asa_auto) and billing made\",\n },\n \"no-cache\": NO_CACHE_ARG,\n ...META_LIST_SHAPE_ARGS,\n} as const;\n\nregisterMetaListSchema(\n \"activities\",\n \"Account change log, as a table by default, one row per event: event_time, event_type, actor_name, object_type, object_name, object_id, and change ('old → new' when the change is a single value). Prints the 50 newest events; a hint says when there are more (--limit <n>). Start here: baker ads meta activities --account-id act_123 --days 2. To find something, filter rather than read everything: --object-id <id,id> keeps those objects' own events (a campaign's id does not bring its ad sets' or ads' events: name them too), --search <text> keeps the events holding that text (event type, names, the raw change), --exclude-system keeps only the changes people made. --fields event_time,object_name,extra_data or --full for the raw change payload; --output json returns the rows in the envelope. With no --account-id and several accounts connected, every account is read and each row leads with its account_id.\",\n listArgs,\n);\n\nexport const activitiesCommand = defineCommand({\n meta: {\n name: \"activities\",\n description: `Audit log of recent ad-account changes (created, paused, edited). Default lookback 7 days,\n~90 day retention server-side. Prints the 50 newest events (--limit for more); a hint says when there are more.\n\nA table by default, one row per event: event_time, event_type, actor_name, object_type,\nobject_name, object_id, and change (\"old → new\" when the change is a single value: status,\nname, budget, goal). --fields takes dotted paths (extra_data holds the raw change); --full returns\nevery field Meta sent; --output json returns the rows as JSON.\n\nTo find something, filter instead of printing everything: --object-id keeps the events on\nthose campaigns, ad sets or ads themselves (a campaign's id does not bring its ad sets' or ads'\nevents: name their ids too); --search keeps the events holding that text in any field (event\ntype, names, the raw change), any case; --exclude-system keeps only the changes people made,\nleaving out Meta's own, its automated rules' (asa_auto) and billing. Filters look through the\n5000 newest events of the window; a hint says when it held more.\n\nExamples:\n baker ads meta activities --account-id act_123 --days 14\n baker ads meta activities --account-id act_123 --days 2 --output json\n baker ads meta activities --account-id act_123 --days 30 --object-id 120211\n baker ads meta activities --account-id act_123 --days 90 --search dsa\n baker ads meta activities --account-id act_123 --days 10 --exclude-system\n baker ads meta activities --account-id act_123 --fields event_time,object_name,extra_data`,\n },\n args: listArgs,\n run: async ({ args }) => {\n const accounts = await accountsInScope(args);\n try {\n const params: Record<string, string> = {};\n if (args.days) params.days = args.days as string;\n if (args[\"object-id\"]) params[\"object-id\"] = args[\"object-id\"] as string;\n if (args.search) params.search = args.search as string;\n if (args[\"exclude-system\"]) params[\"exclude-system\"] = \"true\";\n const filtered = Boolean(args[\"object-id\"] || args.search || args[\"exclude-system\"]);\n const shown = Number(args.limit ?? SHOWN_EVENTS);\n if (!Number.isInteger(shown) || shown < 1) handleMetaError(new Error(\"--limit must be a whole number of events\"));\n // One event past the ones printed says whether there are more, without reading them all.\n params.limit = String(Math.min(shown + 1, READ_CAP));\n if (args[\"no-cache\"]) params[\"skip-cache\"] = \"true\";\n // Which accounts' reads searched only the newest events of their window, and how many they searched.\n const searchedOnly: Array<{ accountId: string; scanned: string }> = [];\n const read = await readEachAccount(\n accounts,\n async (accountId) => {\n const { data, headers } = await apiGetWithHeaders<Array<Record<string, unknown>>>(\n \"/api/ads/meta/activities\",\n { ...params, \"account-id\": accountId },\n );\n const scanned = headers.get(SEARCH_CAPPED_HEADER);\n if (scanned) searchedOnly.push({ accountId, scanned });\n return data;\n },\n { time: (row) => loggedAt(row.event_time) },\n );\n const { rows: data, accountOf } = read;\n // Each account read stops at READ_CAP, so the merged log is newest-first only that far.\n const window = Math.min(shown, READ_CAP);\n const shaped = shapeMetaListRows(\"activities\", data.slice(0, window), args, accountOf?.slice(0, window));\n const hints = readHints(data.length, shown, filtered, searchedOnly, accounts.length > 1);\n writeMetaListRows(\"activities\", shaped, csvOrJson(args), [...read.hints, ...hints]);\n } catch (err) {\n handleMetaError(err);\n }\n },\n});\n"],"mappings":";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OAAO,UAAU,cAAc,SAAS,SAAS,CAAC;AACvF,wBAAkB,cAAc,QAAQ,UAAU,IAAI,GAAG,CAAC,GAAG,KAAK,OAAO,GAAG,KAAK,CAAC;AAAA,IACpF,SAAS,KAAK;AACZ,sBAAgB,GAAG;AAAA,IACrB;AAAA,EACF;AACF,CAAC;","names":["data"]}
|
|
@@ -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-F77XV4ZC.js").then((m) => m.googleCommand),
|
|
37
|
-
meta: () => import("./meta-
|
|
37
|
+
meta: () => import("./meta-6QC6KAPS.js").then((m) => m.metaCommand),
|
|
38
38
|
linkedin: () => import("./linkedin-FWD4I2FS.js").then((m) => m.linkedinCommand),
|
|
39
39
|
x: () => import("./x-TLVCXW5Y.js").then((m) => m.xCommand),
|
|
40
40
|
chatgpt: () => import("./chatgpt-2UCND7NY.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-EPFWBJ5V.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-5W5GCNPZ.js").then((m) => m.capabilitiesCommand),
|
|
626
626
|
actions: () => import("./actions-XA2BNQ2M.js").then((m) => m.actionsCommand),
|
|
627
627
|
"scheduled-agents": () => import("./scheduled-agents-IHJERGZW.js").then((m) => m.scheduledAgentsCommand),
|
|
628
|
-
ads: () => import("./ads-
|
|
628
|
+
ads: () => import("./ads-EPFWBJ5V.js").then((m) => m.adsCommand),
|
|
629
629
|
brand: () => import("./brand-CMKT6D25.js").then((m) => m.brandCommand),
|
|
630
630
|
analytics: () => import("./analytics-HFJESHLA.js").then((m) => m.analyticsCommand),
|
|
631
631
|
experiment: () => import("./experiment-YV7TWSRP.js").then((m) => m.experimentCommand),
|
|
@@ -120,7 +120,7 @@ Full guide: __tooling__/docs/tools/baker/ads-meta.md`
|
|
|
120
120
|
audiences: () => import("./audiences-7TGXZS3M.js").then((m) => m.audiencesCommand),
|
|
121
121
|
"custom-conversions": () => import("./custom-conversions-RZB2622Q.js").then((m) => m.customConversionsCommand),
|
|
122
122
|
pixels: () => import("./pixels-I7S5N76B.js").then((m) => m.pixelsCommand),
|
|
123
|
-
activities: () => import("./activities-
|
|
123
|
+
activities: () => import("./activities-YXZ6PLZU.js").then((m) => m.activitiesCommand),
|
|
124
124
|
insights: () => import("./insights-PBJODKMY.js").then((m) => m.insightsCommand),
|
|
125
125
|
preview: () => import("./preview-5CK5INGO.js").then((m) => m.previewCommand),
|
|
126
126
|
videos: () => import("./videos-OF6PAPP2.js").then((m) => m.videosCommand),
|
|
@@ -149,4 +149,4 @@ Full guide: __tooling__/docs/tools/baker/ads-meta.md`
|
|
|
149
149
|
export {
|
|
150
150
|
metaCommand
|
|
151
151
|
};
|
|
152
|
-
//# sourceMappingURL=meta-
|
|
152
|
+
//# sourceMappingURL=meta-6QC6KAPS.js.map
|
package/package.json
CHANGED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
META_LIST_SHAPE_ARGS,
|
|
3
|
-
registerMetaListSchema,
|
|
4
|
-
shapeMetaListRows,
|
|
5
|
-
writeMetaListRows
|
|
6
|
-
} from "./chunk-AMCW2IG7.js";
|
|
7
|
-
import "./chunk-PRPSV4VB.js";
|
|
8
|
-
import {
|
|
9
|
-
LISTING_ACCOUNT_ARG,
|
|
10
|
-
accountsInScope,
|
|
11
|
-
csvOrJson,
|
|
12
|
-
handleMetaError,
|
|
13
|
-
loggedAt,
|
|
14
|
-
readEachAccount
|
|
15
|
-
} from "./chunk-LDL5VBBD.js";
|
|
16
|
-
import "./chunk-QALAJNBG.js";
|
|
17
|
-
import {
|
|
18
|
-
NO_CACHE_ARG
|
|
19
|
-
} from "./chunk-IHH672FX.js";
|
|
20
|
-
import "./chunk-7CILUDW2.js";
|
|
21
|
-
import "./chunk-7W5KGO5H.js";
|
|
22
|
-
import {
|
|
23
|
-
apiGet
|
|
24
|
-
} from "./chunk-NRJ6A3IF.js";
|
|
25
|
-
import "./chunk-GJBDT4AD.js";
|
|
26
|
-
import "./chunk-7AEQWLLO.js";
|
|
27
|
-
import "./chunk-WZDUKGGN.js";
|
|
28
|
-
import "./chunk-YQSBHWOI.js";
|
|
29
|
-
|
|
30
|
-
// src/commands/ads/meta/activities.ts
|
|
31
|
-
import { defineCommand } from "citty";
|
|
32
|
-
var SHOWN_EVENTS = 50;
|
|
33
|
-
var READ_CAP = 5e3;
|
|
34
|
-
var listArgs = {
|
|
35
|
-
"account-id": LISTING_ACCOUNT_ARG,
|
|
36
|
-
days: { type: "string", description: "Lookback days (default 7)" },
|
|
37
|
-
limit: {
|
|
38
|
-
type: "string",
|
|
39
|
-
description: `Events to print, newest first (default ${SHOWN_EVENTS}); a hint says when there are more`
|
|
40
|
-
},
|
|
41
|
-
"no-cache": NO_CACHE_ARG,
|
|
42
|
-
...META_LIST_SHAPE_ARGS
|
|
43
|
-
};
|
|
44
|
-
registerMetaListSchema(
|
|
45
|
-
"activities",
|
|
46
|
-
"Account change log, as a table by default, one row per event: event_time, event_type, actor_name, object_type, object_name, object_id, and change ('old \u2192 new' when the change is a single value). Prints the 50 newest events; a hint says when there are more (--limit <n>). Start here: baker ads meta activities --account-id act_123 --days 2. --fields event_time,object_name,extra_data or --full for the raw change payload; --output json returns the rows in the envelope. With no --account-id and several accounts connected, every account is read and each row leads with its account_id.",
|
|
47
|
-
listArgs
|
|
48
|
-
);
|
|
49
|
-
var activitiesCommand = defineCommand({
|
|
50
|
-
meta: {
|
|
51
|
-
name: "activities",
|
|
52
|
-
description: `Audit log of recent ad-account changes (created, paused, edited). Default lookback 7 days,
|
|
53
|
-
~90 day retention server-side. Prints the 50 newest events (--limit for more); a hint says when there are more.
|
|
54
|
-
|
|
55
|
-
A table by default, one row per event: event_time, event_type, actor_name, object_type,
|
|
56
|
-
object_name, object_id, and change ("old \u2192 new" when the change is a single value: status,
|
|
57
|
-
name, budget, goal). --fields takes dotted paths (extra_data holds the raw change); --full returns
|
|
58
|
-
every field Meta sent; --output json returns the rows as JSON.
|
|
59
|
-
|
|
60
|
-
Examples:
|
|
61
|
-
baker ads meta activities --account-id act_123 --days 14
|
|
62
|
-
baker ads meta activities --account-id act_123 --days 2 --output json
|
|
63
|
-
baker ads meta activities --account-id act_123 --fields event_time,object_name,extra_data`
|
|
64
|
-
},
|
|
65
|
-
args: listArgs,
|
|
66
|
-
run: async ({ args }) => {
|
|
67
|
-
const accounts = await accountsInScope(args);
|
|
68
|
-
try {
|
|
69
|
-
const params = {};
|
|
70
|
-
if (args.days) params.days = args.days;
|
|
71
|
-
const shown = Number(args.limit ?? SHOWN_EVENTS);
|
|
72
|
-
if (!Number.isInteger(shown) || shown < 1) handleMetaError(new Error("--limit must be a whole number of events"));
|
|
73
|
-
params.limit = String(Math.min(shown + 1, READ_CAP));
|
|
74
|
-
if (args["no-cache"]) params["skip-cache"] = "true";
|
|
75
|
-
const read = await readEachAccount(
|
|
76
|
-
accounts,
|
|
77
|
-
(accountId) => apiGet("/api/ads/meta/activities", { ...params, "account-id": accountId }),
|
|
78
|
-
{ time: (row) => loggedAt(row.event_time) }
|
|
79
|
-
);
|
|
80
|
-
const { rows: data, accountOf } = read;
|
|
81
|
-
const window = Math.min(shown, READ_CAP);
|
|
82
|
-
const shaped = shapeMetaListRows("activities", data.slice(0, window), args, accountOf?.slice(0, window));
|
|
83
|
-
const more = data.length > window && window === shown ? [`Showing the ${shown} newest events; there are more. --limit <n> prints more, or narrow --days.`] : data.length >= READ_CAP ? [`Showing the ${READ_CAP} newest events, the most one read returns; there may be more. Narrow --days.`] : [];
|
|
84
|
-
writeMetaListRows("activities", shaped, csvOrJson(args), [...read.hints, ...more]);
|
|
85
|
-
} catch (err) {
|
|
86
|
-
handleMetaError(err);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
export {
|
|
91
|
-
activitiesCommand
|
|
92
|
-
};
|
|
93
|
-
//# sourceMappingURL=activities-DYI25TF4.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/commands/ads/meta/activities.ts"],"sourcesContent":["import { defineCommand } from \"citty\";\nimport { NO_CACHE_ARG } from \"../../../cache-flag.ts\";\nimport { apiGet } from \"../../../client.ts\";\nimport { META_LIST_SHAPE_ARGS, registerMetaListSchema, shapeMetaListRows, writeMetaListRows } from \"./list-rows.ts\";\nimport {\n accountsInScope,\n csvOrJson,\n handleMetaError,\n LISTING_ACCOUNT_ARG,\n loggedAt,\n readEachAccount,\n} from \"./shared.ts\";\n\n/** Events printed unless --limit names another number: a busy month printed 96 KB the agent cut with head (BAKER-1222). */\nconst SHOWN_EVENTS = 50;\n\n/** The most events one read returns (the activities route's cap): a read that reaches it may have left older ones out. */\nconst READ_CAP = 5000;\n\nconst listArgs = {\n \"account-id\": LISTING_ACCOUNT_ARG,\n days: { type: \"string\", description: \"Lookback days (default 7)\" },\n limit: {\n type: \"string\",\n description: `Events to print, newest first (default ${SHOWN_EVENTS}); a hint says when there are more`,\n },\n \"no-cache\": NO_CACHE_ARG,\n ...META_LIST_SHAPE_ARGS,\n} as const;\n\nregisterMetaListSchema(\n \"activities\",\n \"Account change log, as a table by default, one row per event: event_time, event_type, actor_name, object_type, object_name, object_id, and change ('old → new' when the change is a single value). Prints the 50 newest events; a hint says when there are more (--limit <n>). Start here: baker ads meta activities --account-id act_123 --days 2. --fields event_time,object_name,extra_data or --full for the raw change payload; --output json returns the rows in the envelope. With no --account-id and several accounts connected, every account is read and each row leads with its account_id.\",\n listArgs,\n);\n\nexport const activitiesCommand = defineCommand({\n meta: {\n name: \"activities\",\n description: `Audit log of recent ad-account changes (created, paused, edited). Default lookback 7 days,\n~90 day retention server-side. Prints the 50 newest events (--limit for more); a hint says when there are more.\n\nA table by default, one row per event: event_time, event_type, actor_name, object_type,\nobject_name, object_id, and change (\"old → new\" when the change is a single value: status,\nname, budget, goal). --fields takes dotted paths (extra_data holds the raw change); --full returns\nevery field Meta sent; --output json returns the rows as JSON.\n\nExamples:\n baker ads meta activities --account-id act_123 --days 14\n baker ads meta activities --account-id act_123 --days 2 --output json\n baker ads meta activities --account-id act_123 --fields event_time,object_name,extra_data`,\n },\n args: listArgs,\n run: async ({ args }) => {\n const accounts = await accountsInScope(args);\n try {\n const params: Record<string, string> = {};\n if (args.days) params.days = args.days as string;\n const shown = Number(args.limit ?? SHOWN_EVENTS);\n if (!Number.isInteger(shown) || shown < 1) handleMetaError(new Error(\"--limit must be a whole number of events\"));\n // One event past the ones printed says whether there are more, without reading them all.\n params.limit = String(Math.min(shown + 1, READ_CAP));\n if (args[\"no-cache\"]) params[\"skip-cache\"] = \"true\";\n const read = await readEachAccount(\n accounts,\n (accountId) =>\n apiGet<Array<Record<string, unknown>>>(\"/api/ads/meta/activities\", { ...params, \"account-id\": accountId }),\n { time: (row) => loggedAt(row.event_time) },\n );\n const { rows: data, accountOf } = read;\n // Each account read stops at READ_CAP, so the merged log is newest-first only that far.\n const window = Math.min(shown, READ_CAP);\n const shaped = shapeMetaListRows(\"activities\", data.slice(0, window), args, accountOf?.slice(0, window));\n const more =\n data.length > window && window === shown\n ? [`Showing the ${shown} newest events; there are more. --limit <n> prints more, or narrow --days.`]\n : data.length >= READ_CAP\n ? [`Showing the ${READ_CAP} newest events, the most one read returns; there may be more. Narrow --days.`]\n : [];\n writeMetaListRows(\"activities\", shaped, csvOrJson(args), [...read.hints, ...more]);\n } catch (err) {\n handleMetaError(err);\n }\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,qBAAqB;AAc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