siluzan-tso-cli 1.1.75-beta.1 → 1.1.75-beta.2

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.
Files changed (28) hide show
  1. package/README.md +1 -1
  2. package/dist/index.js +1784 -1651
  3. package/dist/skill/SKILL.md +6 -8
  4. package/dist/skill/_meta.json +2 -2
  5. package/dist/skill/assets/pmax-create-template.md +2 -16
  6. package/dist/skill/references/README.md +0 -1
  7. package/dist/skill/references/analytics/account-analytics.md +0 -33
  8. package/dist/skill/references/core/agent-conventions.md +9 -3
  9. package/dist/skill/references/core/workflows.md +3 -3
  10. package/dist/skill/references/google-ads/demand-gen-api.md +6 -7
  11. package/dist/skill/references/google-ads/google-ads-campaign-plan.md +1 -1
  12. package/dist/skill/references/google-ads/google-ads-read.md +1 -1
  13. package/dist/skill/references/google-ads/google-ads-write.md +11 -19
  14. package/dist/skill/references/google-ads/google-ads.md +1 -1
  15. package/dist/skill/references/google-ads/pmax-api.md +1 -3
  16. package/dist/skill/references/google-ads/rules/README.md +1 -1
  17. package/dist/skill/references/google-ads/rules/google-ads-audience-strategy.md +33 -33
  18. package/dist/skill/references/google-ads/rules/google-ads-launch-plan-template.md +1 -1
  19. package/dist/skill/references/google-ads/rules/google-ads-pmax-guide.md +22 -24
  20. package/dist/skill/references/google-ads/rules/google-ads-pmax-launch-plan-template.md +2 -13
  21. package/dist/skill/references/operations/ad-gap.md +14 -120
  22. package/dist/skill/references/operations/hosted-automation-optimize-scale.md +1 -1
  23. package/dist/skill/scripts/install.ps1 +1 -1
  24. package/dist/skill/scripts/install.sh +1 -1
  25. package/eval/cases/write-readback-budget-mismatch.scenario.json +19 -0
  26. package/eval/cases/write-readback-extra-country.scenario.json +19 -0
  27. package/package.json +2 -1
  28. package/dist/skill/references/analytics/ga4-report.md +0 -41
package/dist/index.js CHANGED
@@ -1967,7 +1967,6 @@ import * as fs from "fs";
1967
1967
  import * as path from "path";
1968
1968
  import * as os from "os";
1969
1969
  import lockfile from "proper-lockfile";
1970
- import { randomBytes } from "crypto";
1971
1970
  import * as https from "https";
1972
1971
  import * as http from "http";
1973
1972
  import * as zlib from "zlib";
@@ -2398,7 +2397,7 @@ function rawRequest(url, options) {
2398
2397
  stream = res.pipe(zlib.createBrotliDecompress());
2399
2398
  }
2400
2399
  let failed = false;
2401
- const fail10 = (err) => {
2400
+ const fail9 = (err) => {
2402
2401
  if (failed) return;
2403
2402
  failed = true;
2404
2403
  res.destroy();
@@ -2417,7 +2416,7 @@ function rawRequest(url, options) {
2417
2416
  reject(err);
2418
2417
  };
2419
2418
  const onStreamError = (err) => {
2420
- fail10(new Error(`\u54CD\u5E94\u89E3\u538B\u5931\u8D25\uFF08${encoding || "identity"}\uFF09\uFF1A${err.message}`));
2419
+ fail9(new Error(`\u54CD\u5E94\u89E3\u538B\u5931\u8D25\uFF08${encoding || "identity"}\uFF09\uFF1A${err.message}`));
2421
2420
  };
2422
2421
  if (stream !== res) stream.on("error", onStreamError);
2423
2422
  res.on("error", onStreamError);
@@ -2428,7 +2427,7 @@ function rawRequest(url, options) {
2428
2427
  const buf = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
2429
2428
  byteLen += buf.length;
2430
2429
  if (maxBytes > 0 && byteLen > maxBytes) {
2431
- fail10(
2430
+ fail9(
2432
2431
  new Error(`\u54CD\u5E94\u4F53\u8D85\u8FC7\u4E0A\u9650\uFF08${(maxBytes / 1024 / 1024).toFixed(0)} MB\uFF09\uFF0C\u5DF2\u4E2D\u65AD\u8FDE\u63A5`)
2433
2432
  );
2434
2433
  return;
@@ -2608,40 +2607,6 @@ function formatHttpError(status, rawBody, opts) {
2608
2607
  function buildAuthHeaders(config) {
2609
2608
  return buildSiluzanAuthHeaders(config);
2610
2609
  }
2611
- function buildMultipartBody(fields, files) {
2612
- const boundary = `----SiluzanForm${randomBytes(16).toString("hex")}`;
2613
- const chunks = [];
2614
- for (const [name2, value] of Object.entries(fields)) {
2615
- chunks.push(
2616
- Buffer.from(
2617
- `--${boundary}\r
2618
- Content-Disposition: form-data; name="${name2}"\r
2619
- \r
2620
- ${value}\r
2621
- `
2622
- )
2623
- );
2624
- }
2625
- for (const file of files) {
2626
- chunks.push(
2627
- Buffer.from(
2628
- `--${boundary}\r
2629
- Content-Disposition: form-data; name="${file.field}"; filename="${file.filename}"\r
2630
- Content-Type: ${file.contentType}\r
2631
- \r
2632
- `
2633
- )
2634
- );
2635
- chunks.push(file.data);
2636
- chunks.push(Buffer.from("\r\n"));
2637
- }
2638
- chunks.push(Buffer.from(`--${boundary}--\r
2639
- `));
2640
- return {
2641
- body: Buffer.concat(chunks),
2642
- contentType: `multipart/form-data; boundary=${boundary}`
2643
- };
2644
- }
2645
2610
  async function parseApiResponse(status, text5, verbose) {
2646
2611
  if (status < 200 || status >= 300) {
2647
2612
  const err = new Error(formatHttpError(status, text5, { verbose }));
@@ -2702,22 +2667,6 @@ async function apiFetch(url, config, options = {}, verbose = false, timeoutMs) {
2702
2667
  });
2703
2668
  return parseApiResponse(res.status, res.text, verbose);
2704
2669
  }
2705
- async function apiFetchMultipart(url, config, payload, verbose = false) {
2706
- const packed = buildMultipartBody(payload.fields ?? {}, payload.files);
2707
- const reqHeaders = {
2708
- "Content-Type": packed.contentType,
2709
- "Accept-Language": "zh-CN",
2710
- "Accept-Encoding": "gzip, deflate, br",
2711
- ...buildAuthHeaders(config),
2712
- Datapermission: config.dataPermission ?? ""
2713
- };
2714
- const res = await rawRequest(url, {
2715
- method: "POST",
2716
- headers: reqHeaders,
2717
- body: packed.body
2718
- });
2719
- return parseApiResponse(res.status, res.text, verbose);
2720
- }
2721
2670
  async function apiFetchWithHeaders(url, config, options = {}, verbose = false) {
2722
2671
  const method = options.method ?? "GET";
2723
2672
  const reqHeaders = {
@@ -4466,11 +4415,6 @@ async function apiFetch2(url, config, options = {}, verbose = false, timeoutMs)
4466
4415
  value: await apiFetch(url, config, options, verbose, timeoutMs)
4467
4416
  }));
4468
4417
  }
4469
- async function apiFetchMultipart2(url, config, payload, verbose = false) {
4470
- return withWriteAudit({ config, url, method: "POST", verbose }, async () => ({
4471
- value: await apiFetchMultipart(url, config, payload, verbose)
4472
- }));
4473
- }
4474
4418
  async function apiFetchWithHeaders2(url, config, options = {}, verbose = false) {
4475
4419
  const method = options.method ?? "GET";
4476
4420
  if (!isMutatingHttpMethod(method)) {
@@ -6431,6 +6375,7 @@ function negativeKeywordSlimListUrl(googleApiUrl, accountId, query) {
6431
6375
  if (query?.appliedLevel) params.set("appliedlevel", query.appliedLevel);
6432
6376
  if (query?.readDeleted) params.set("readDeleted", "true");
6433
6377
  if (query?.excludePaused) params.set("excludePaused", "true");
6378
+ if (query?.newest) params.set("newest", "true");
6434
6379
  const text5 = query?.keywordText?.trim();
6435
6380
  if (text5) params.set("keywordtext", text5);
6436
6381
  if (query?.matchType) params.set("matchtype", query.matchType);
@@ -6457,11 +6402,11 @@ function toDisplayMoney(raw) {
6457
6402
  if (!Number.isFinite(n)) return null;
6458
6403
  return n / 100;
6459
6404
  }
6460
- function toCentAmount(displayValue) {
6461
- if (!Number.isFinite(displayValue)) {
6462
- throw new Error(`toCentAmount: \u8F93\u5165\u5FC5\u987B\u662F\u6709\u9650\u6570\u5B57\uFF0C\u6536\u5230 ${displayValue}`);
6405
+ function toCentAmount(displayValue2) {
6406
+ if (!Number.isFinite(displayValue2)) {
6407
+ throw new Error(`toCentAmount: \u8F93\u5165\u5FC5\u987B\u662F\u6709\u9650\u6570\u5B57\uFF0C\u6536\u5230 ${displayValue2}`);
6463
6408
  }
6464
- return Math.round(displayValue * 100);
6409
+ return Math.round(displayValue2 * 100);
6465
6410
  }
6466
6411
  function convertBatchMoneyTreeFromYuan(value) {
6467
6412
  return convertBatchMoneyTreeFromYuanInner(value);
@@ -105574,18 +105519,18 @@ import fs32 from "fs";
105574
105519
  import fsPromises2 from "fs/promises";
105575
105520
  import path37 from "path";
105576
105521
  import { fileURLToPath as fileURLToPath9 } from "url";
105577
- function resolveSkillTemplatePath3(basename15) {
105522
+ function resolveSkillTemplatePath3(basename14) {
105578
105523
  const dir = path37.dirname(fileURLToPath9(import.meta.url));
105579
105524
  const candidates = [
105580
- path37.join(dir, "skill", "report-templates", basename15),
105581
- path37.join(dir, "skill", "siluzan-ads", "report-templates", basename15),
105582
- path37.join(dir, "..", "..", "..", "assets", "siluzan-ads", "report-templates", basename15),
105583
- path37.join(dir, "..", "..", "assets", "siluzan-ads", "report-templates", basename15)
105525
+ path37.join(dir, "skill", "report-templates", basename14),
105526
+ path37.join(dir, "skill", "siluzan-ads", "report-templates", basename14),
105527
+ path37.join(dir, "..", "..", "..", "assets", "siluzan-ads", "report-templates", basename14),
105528
+ path37.join(dir, "..", "..", "assets", "siluzan-ads", "report-templates", basename14)
105584
105529
  ];
105585
105530
  for (const candidate of candidates) {
105586
105531
  if (fs32.existsSync(candidate)) return candidate;
105587
105532
  }
105588
- return path37.join(dir, "skill", "report-templates", basename15);
105533
+ return path37.join(dir, "skill", "report-templates", basename14);
105589
105534
  }
105590
105535
  function demandGenReportTemplatePath() {
105591
105536
  return resolveSkillTemplatePath3(TEMPLATE_BASENAME);
@@ -107386,12 +107331,12 @@ import fs37 from "fs";
107386
107331
  import fsPromises3 from "fs/promises";
107387
107332
  import path42 from "path";
107388
107333
  import { fileURLToPath as fileURLToPath10 } from "url";
107389
- function resolveSkillTemplatePath4(basename15) {
107334
+ function resolveSkillTemplatePath4(basename14) {
107390
107335
  const dir = path42.dirname(fileURLToPath10(import.meta.url));
107391
107336
  const candidates = [
107392
- path42.join(dir, "skill", "report-templates", basename15),
107393
- path42.join(dir, "skill", "siluzan-ads", "report-templates", basename15),
107394
- path42.join(dir, "..", "..", "assets", "siluzan-ads", "report-templates", basename15)
107337
+ path42.join(dir, "skill", "report-templates", basename14),
107338
+ path42.join(dir, "skill", "siluzan-ads", "report-templates", basename14),
107339
+ path42.join(dir, "..", "..", "assets", "siluzan-ads", "report-templates", basename14)
107395
107340
  ];
107396
107341
  for (const p of candidates) {
107397
107342
  if (fs37.existsSync(p)) return p;
@@ -107952,8 +107897,8 @@ var init_batch_runner = __esm({
107952
107897
  shouldDowngrade(now = Date.now()) {
107953
107898
  if (this.window.length < this.opts.windowSize) return false;
107954
107899
  if (now - this.lastDowngradeAt < this.opts.cooldownMs) return false;
107955
- const fail10 = this.window.filter((s) => !s).length;
107956
- const rate2 = fail10 / this.window.length;
107900
+ const fail9 = this.window.filter((s) => !s).length;
107901
+ const rate2 = fail9 / this.window.length;
107957
107902
  if (rate2 >= this.opts.errorRateThreshold) {
107958
107903
  this.lastDowngradeAt = now;
107959
107904
  this.window.length = 0;
@@ -113630,6 +113575,263 @@ async function runReportDelete(opts) {
113630
113575
  init_auth();
113631
113576
  init_cli_table();
113632
113577
  init_cli_json_snapshot();
113578
+
113579
+ // src/commands/account-readback.ts
113580
+ init_auth();
113581
+
113582
+ // src/commands/write-receipt-record.ts
113583
+ init_auth();
113584
+ import { spawnSync as spawnSync2 } from "child_process";
113585
+ var POST_SCRIPT = `
113586
+ fetch(process.env.RECEIPT_URL, {
113587
+ method: "POST",
113588
+ headers: {
113589
+ "content-type": "application/json",
113590
+ [process.env.RECEIPT_AUTH_NAME]: process.env.RECEIPT_AUTH_VALUE,
113591
+ },
113592
+ body: require("node:fs").readFileSync(0, "utf8"),
113593
+ signal: AbortSignal.timeout(2000),
113594
+ }).then(async (response) => {
113595
+ let state = "";
113596
+ try { state = JSON.parse(await response.text()).state; } catch { state = ""; }
113597
+ process.exit(response.ok && state === "ok" ? 0 : 2);
113598
+ }).catch(() => process.exit(1));
113599
+ `;
113600
+ function flagValue(argv, flags) {
113601
+ for (let i = 0; i < argv.length; i += 1) {
113602
+ const token = argv[i] ?? "";
113603
+ for (const flag of flags) {
113604
+ if (token === flag) {
113605
+ const next = argv[i + 1] ?? "";
113606
+ return next.startsWith("-") ? "" : next;
113607
+ }
113608
+ if (token.startsWith(`${flag}=`)) return token.slice(flag.length + 1);
113609
+ }
113610
+ }
113611
+ return "";
113612
+ }
113613
+ function commandContextFromArgv(argv) {
113614
+ const parts = [];
113615
+ for (const token of argv) {
113616
+ if (!token || token.includes("node") || token.endsWith("index.js") || token.endsWith("index.ts") || token.endsWith("cli.mjs")) {
113617
+ continue;
113618
+ }
113619
+ if (token.startsWith("-")) break;
113620
+ parts.push(token);
113621
+ if (parts.length >= 3) break;
113622
+ }
113623
+ return {
113624
+ command: parts.join(" "),
113625
+ accountId: flagValue(argv, ["-a", "--account"]),
113626
+ resourceId: flagValue(argv, ["--id"])
113627
+ };
113628
+ }
113629
+ function buildWriteReadSnapshot(verification, lines, argv) {
113630
+ const expected = {};
113631
+ const read = {};
113632
+ for (const line of lines) {
113633
+ expected[line.label] = line.expected;
113634
+ read[line.label] = line.actual;
113635
+ }
113636
+ const command = commandContextFromArgv(argv);
113637
+ return {
113638
+ verification,
113639
+ command: command.command,
113640
+ accountId: command.accountId,
113641
+ resourceId: command.resourceId,
113642
+ threadId: process.env.DEERFLOW_THREAD_ID?.trim() ?? "",
113643
+ runId: process.env.DEERFLOW_RUN_ID?.trim() ?? "",
113644
+ expected,
113645
+ read,
113646
+ lines
113647
+ };
113648
+ }
113649
+ function resolveReceiptPost(config) {
113650
+ const base2 = config.mainApiUrl?.trim().replace(/\/$/, "") ?? "";
113651
+ if (!base2) return null;
113652
+ const apiKey = config.apiKey?.trim();
113653
+ if (apiKey) {
113654
+ return { url: `${base2}/command/write-read-receipt`, authName: "x-api-key", authValue: apiKey };
113655
+ }
113656
+ const token = config.authToken?.trim();
113657
+ if (!token) return null;
113658
+ return { url: `${base2}/command/write-read-receipt`, authName: "Authorization", authValue: `Bearer ${token}` };
113659
+ }
113660
+ function postWriteReadSnapshot(url, authName, authValue, body, spawn3 = spawnSync2) {
113661
+ return spawn3(process.execPath, ["-e", POST_SCRIPT], {
113662
+ input: body,
113663
+ timeout: 2500,
113664
+ encoding: "utf8",
113665
+ env: { ...process.env, RECEIPT_URL: url, RECEIPT_AUTH_NAME: authName, RECEIPT_AUTH_VALUE: authValue }
113666
+ });
113667
+ }
113668
+ function recordWriteReadReceipt(verification, lines, load = loadConfig, spawn3 = spawnSync2) {
113669
+ let target;
113670
+ try {
113671
+ target = resolveReceiptPost(load());
113672
+ } catch {
113673
+ console.error("write-read receipt \u672A\u8BB0\u4E0B");
113674
+ return;
113675
+ }
113676
+ if (!target) return;
113677
+ const snapshot = buildWriteReadSnapshot(verification, lines, process.argv);
113678
+ const result = postWriteReadSnapshot(target.url, target.authName, target.authValue, JSON.stringify(snapshot), spawn3);
113679
+ if (result.status !== 0) {
113680
+ console.error("write-read receipt \u672A\u8BB0\u4E0B");
113681
+ }
113682
+ }
113683
+
113684
+ // src/commands/write-receipt.ts
113685
+ var UNREAD = "\uFF08\u672A\u8BFB\u5230\uFF09";
113686
+ var CENT_YUAN_FIELDS = {
113687
+ budget: "\u65E5\u9884\u7B97",
113688
+ targetCpa_BidingAmount: "\u76EE\u6807CPA",
113689
+ targetSpend_BidCeilingAmount: "CPC\u4E0A\u9650"
113690
+ };
113691
+ var FIELD_LABELS = {
113692
+ statusV2: "\u72B6\u6001",
113693
+ biddingStrategyTypeV2: "\u51FA\u4EF7\u7B56\u7565",
113694
+ targetRoas: "\u76EE\u6807ROAS",
113695
+ positiveGeoTargetTypeV2: "\u4F4D\u7F6E\u9009\u9879",
113696
+ negativeGeoTargetTypeV2: "\u6392\u9664\u4F4D\u7F6E\u9009\u9879",
113697
+ name: "\u540D\u79F0",
113698
+ daily_budget: "\u65E5\u9884\u7B97",
113699
+ status: "\u72B6\u6001",
113700
+ countries: "\u56FD\u5BB6",
113701
+ finalUrl: "\u843D\u5730\u9875",
113702
+ finalURL: "\u843D\u5730\u9875"
113703
+ };
113704
+ function yuanLabel(amount) {
113705
+ const rounded = Math.round(amount * 100) / 100;
113706
+ return `${rounded} \u5143`;
113707
+ }
113708
+ function displayValue(value) {
113709
+ if (value == null || value === "") return "\uFF08\u7A7A\uFF09";
113710
+ if (typeof value === "number" && Number.isFinite(value)) {
113711
+ const rounded = Math.round(value * 100) / 100;
113712
+ return String(rounded);
113713
+ }
113714
+ if (typeof value === "boolean") return value ? "\u662F" : "\u5426";
113715
+ if (Array.isArray(value)) return value.map((item) => displayValue(item)).join(",");
113716
+ return String(value);
113717
+ }
113718
+ function receiptLine(label2, expected, actual) {
113719
+ return {
113720
+ label: label2,
113721
+ expected: displayValue(expected),
113722
+ actual: actual === void 0 ? UNREAD : displayValue(actual)
113723
+ };
113724
+ }
113725
+ function receiptLinesFromFieldChecks(checks) {
113726
+ return checks.map((check) => {
113727
+ const yuanLabelName = CENT_YUAN_FIELDS[check.field];
113728
+ const label2 = yuanLabelName ?? FIELD_LABELS[check.field] ?? check.field;
113729
+ const unread = check.state === "unread";
113730
+ if (yuanLabelName) {
113731
+ const expectedYuan = centsToYuan(check.expected);
113732
+ const actualYuan = unread ? void 0 : centsToYuan(check.actual);
113733
+ return receiptLine(
113734
+ label2,
113735
+ expectedYuan == null ? check.expected : yuanLabel(expectedYuan),
113736
+ actualYuan == null ? unread ? void 0 : check.actual : yuanLabel(actualYuan)
113737
+ );
113738
+ }
113739
+ return receiptLine(label2, check.expected, unread ? void 0 : check.actual);
113740
+ });
113741
+ }
113742
+ function centsToYuan(value) {
113743
+ if (typeof value !== "number" || !Number.isFinite(value)) return null;
113744
+ return value / 100;
113745
+ }
113746
+ function judgeReceipt(lines, readFailed = false) {
113747
+ if (lines.length === 0) return "submitted";
113748
+ if (readFailed || lines.some((line) => line.actual === UNREAD)) return "unknown";
113749
+ if (lines.every((line) => line.expected === line.actual)) return "verified";
113750
+ return "partial";
113751
+ }
113752
+ function formatWriteReceipt(verification, lines) {
113753
+ const body = lines.length ? lines.map((line) => `${line.label}\uFF1A\u671F\u671B ${line.expected}\uFF0C\u8BFB\u56DE ${line.actual}`).join("\n") : verification === "verified" ? "\u5DF2\u6838\u5BF9" : "\u5DF2\u63D0\u4EA4\uFF0C\u5C1A\u672A\u6838\u9A8C";
113754
+ return `\u6838\u5BF9
113755
+ verification=${verification}
113756
+ ${body}`;
113757
+ }
113758
+ function printWriteReceipt(verification, lines) {
113759
+ console.log(`
113760
+ ${formatWriteReceipt(verification, lines)}
113761
+ `);
113762
+ try {
113763
+ recordWriteReadReceipt(verification, lines);
113764
+ } catch {
113765
+ }
113766
+ }
113767
+ function payloadHasExact(payload, value) {
113768
+ const text5 = JSON.stringify(payload ?? null);
113769
+ if (text5.includes(JSON.stringify(value))) return true;
113770
+ if (/^-?\d+(\.\d+)?$/.test(value)) {
113771
+ const token = value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
113772
+ return new RegExp(`(?<=[:\\[,]\\s*)${token}(?=[,}\\]])`).test(text5);
113773
+ }
113774
+ return false;
113775
+ }
113776
+ function receiptFromNeedles(needles, payload) {
113777
+ if (payload === void 0) {
113778
+ const lines2 = needles.map((needle) => receiptLine(needle.label, needle.value, void 0));
113779
+ return { verification: "unknown", lines: lines2 };
113780
+ }
113781
+ const lines = needles.map(
113782
+ (needle) => receiptLine(needle.label, needle.value, payloadHasExact(payload, needle.value) ? needle.value : "\u672A\u627E\u5230")
113783
+ );
113784
+ return { verification: judgeReceipt(lines), lines };
113785
+ }
113786
+ function receiptForAbsence(label2, id, payload) {
113787
+ if (payload === void 0) {
113788
+ return {
113789
+ verification: "unknown",
113790
+ lines: [receiptLine(label2, "\u5DF2\u4E0D\u5728", void 0)]
113791
+ };
113792
+ }
113793
+ const stillThere = payloadHasExact(payload, id);
113794
+ const lines = [receiptLine(label2, "\u5DF2\u4E0D\u5728", stillThere ? "\u4ECD\u5728" : "\u5DF2\u4E0D\u5728")];
113795
+ return { verification: stillThere ? "partial" : "verified", lines };
113796
+ }
113797
+
113798
+ // src/commands/account-readback.ts
113799
+ async function fetchAccountsByKeyword(config, media, keyword, verbose) {
113800
+ try {
113801
+ const platform = media ? PLATFORM_CONFIG[media] : void 0;
113802
+ const params = new URLSearchParams();
113803
+ if (platform) {
113804
+ for (const [key, value] of Object.entries(platform.fixedParams)) {
113805
+ params.set(key, String(value));
113806
+ }
113807
+ params.set(platform.pageParam, "1");
113808
+ } else {
113809
+ params.set("pageNo", "1");
113810
+ }
113811
+ params.set("pageSize", "20");
113812
+ applyListAccountsSearchKeyword(params, keyword);
113813
+ const path61 = platform?.path ?? "/query/media-account/";
113814
+ const url = `${config.apiBaseUrl}${path61}?${params}`;
113815
+ if (!platform || platform.responseType === "array") {
113816
+ const res = await apiFetchWithHeaders2(url, config, {}, verbose);
113817
+ return res.data;
113818
+ }
113819
+ return await apiFetch2(url, config, {}, verbose);
113820
+ } catch {
113821
+ return void 0;
113822
+ }
113823
+ }
113824
+ async function printAccountAbsence(config, media, keyword, label2, verbose) {
113825
+ const listed = await fetchAccountsByKeyword(config, media, keyword, verbose);
113826
+ const judged = receiptForAbsence(label2, keyword, listed);
113827
+ printWriteReceipt(judged.verification, judged.lines);
113828
+ }
113829
+ function printApplicationNeedles(needles, payload) {
113830
+ const judged = receiptFromNeedles(needles, payload);
113831
+ printWriteReceipt(judged.verification, judged.lines);
113832
+ }
113833
+
113834
+ // src/commands/report/push.ts
113633
113835
  async function runReportPushList(opts) {
113634
113836
  assertReportPushMedia(opts.media);
113635
113837
  const config = await ensureDataPermission(loadConfig(opts.token));
@@ -113732,8 +113934,56 @@ async function runReportPushDelete(opts) {
113732
113934
  `);
113733
113935
  process.exit(1);
113734
113936
  }
113937
+ let listed;
113938
+ try {
113939
+ const params = new URLSearchParams();
113940
+ params.set("pageIndex", "1");
113941
+ params.set("pageSize", "20");
113942
+ params.set("Name", "");
113943
+ params.set("ReportType", "");
113944
+ params.set("startDate", "");
113945
+ params.set("endDate", "");
113946
+ listed = await apiFetch2(
113947
+ `${config.apiBaseUrl}/query/report-push/settings/${opts.media}?${params}`,
113948
+ config,
113949
+ {},
113950
+ opts.verbose
113951
+ );
113952
+ } catch {
113953
+ listed = void 0;
113954
+ }
113955
+ const gone = receiptForAbsence("\u63A8\u9001\u914D\u7F6E", opts.id, listed);
113956
+ printWriteReceipt(gone.verification, gone.lines);
113735
113957
  console.log("\n\u2705 \u63A8\u9001\u5DF2\u5220\u9664\n");
113736
113958
  }
113959
+ async function printReportPushReceipt(config, opts) {
113960
+ let listed;
113961
+ try {
113962
+ const params = new URLSearchParams();
113963
+ params.set("pageIndex", "1");
113964
+ params.set("pageSize", "20");
113965
+ params.set("Name", opts.name);
113966
+ params.set("ReportType", "");
113967
+ params.set("startDate", "");
113968
+ params.set("endDate", "");
113969
+ listed = await apiFetch2(
113970
+ `${config.apiBaseUrl}/query/report-push/settings/${opts.media}?${params}`,
113971
+ config,
113972
+ {},
113973
+ opts.verbose
113974
+ );
113975
+ } catch {
113976
+ listed = void 0;
113977
+ }
113978
+ printApplicationNeedles(
113979
+ [
113980
+ { label: "\u540D\u79F0", value: opts.name },
113981
+ { label: "\u6536\u4EF6\u4EBA", value: opts.receiveEmails[0] ?? "" },
113982
+ { label: "\u8D26\u6237", value: opts.mediaAccounts[0] ?? "" }
113983
+ ].filter((item) => item.value),
113984
+ listed
113985
+ );
113986
+ }
113737
113987
  async function runReportPushCreate(opts) {
113738
113988
  assertReportPushMedia(opts.media);
113739
113989
  const config = await ensureDataPermission(loadConfig(opts.token));
@@ -113754,6 +114004,7 @@ async function runReportPushCreate(opts) {
113754
114004
  `);
113755
114005
  process.exit(1);
113756
114006
  }
114007
+ await printReportPushReceipt(config, opts);
113757
114008
  console.log("\n\u2705 \u63A8\u9001\u914D\u7F6E\u5DF2\u521B\u5EFA\n");
113758
114009
  }
113759
114010
  async function runReportPushUpdate(opts) {
@@ -113777,6 +114028,7 @@ async function runReportPushUpdate(opts) {
113777
114028
  `);
113778
114029
  process.exit(1);
113779
114030
  }
114031
+ await printReportPushReceipt(config, opts);
113780
114032
  console.log("\n\u2705 \u63A8\u9001\u914D\u7F6E\u5DF2\u66F4\u65B0\n");
113781
114033
  }
113782
114034
  async function runReportPushHistory(opts) {
@@ -114110,6 +114362,28 @@ async function runTransferCreate(opts) {
114110
114362
  `);
114111
114363
  process.exit(1);
114112
114364
  }
114365
+ let listed;
114366
+ try {
114367
+ const params = new URLSearchParams();
114368
+ params.set("pageNumber", "1");
114369
+ params.set("pageSize", "20");
114370
+ listed = await apiFetch2(
114371
+ `${config.apiBaseUrl}/query/accounttransfer/${mediaToPath(opts.media)}/search?${params}`,
114372
+ config,
114373
+ {},
114374
+ opts.verbose
114375
+ );
114376
+ } catch {
114377
+ listed = void 0;
114378
+ }
114379
+ printApplicationNeedles(
114380
+ [
114381
+ { label: "\u8F6C\u51FA\u8D26\u6237", value: opts.outAccount },
114382
+ { label: "\u8F6C\u5165\u8D26\u6237", value: opts.inAccount },
114383
+ { label: "\u7533\u8BF7\u91D1\u989D", value: String(opts.amount) }
114384
+ ],
114385
+ listed
114386
+ );
114113
114387
  if (await emitCliJsonOrSnapshot(opts, {
114114
114388
  section: `transfer-create-${mediaToPath(opts.media)}`,
114115
114389
  commandLabel: "transfer create",
@@ -114588,7 +114862,7 @@ async function runInvoiceApply(opts) {
114588
114862
  } else {
114589
114863
  const cnName = opts.companyName?.trim() ?? "";
114590
114864
  const tax = opts.taxId?.trim() ?? "";
114591
- const title = opts.title?.trim() ?? "";
114865
+ const title2 = opts.title?.trim() ?? "";
114592
114866
  const landline = opts.companyPhone?.trim() ?? "";
114593
114867
  if (!cnName) {
114594
114868
  console.error("\n\u274C VATI/VATSI \u9700\u8981 --company-name\uFF08\u4E2D\u6587\u516C\u53F8\u540D\uFF09\n");
@@ -114598,7 +114872,7 @@ async function runInvoiceApply(opts) {
114598
114872
  console.error("\n\u274C VATI/VATSI \u9700\u8981 --tax-id\uFF08\u4F01\u4E1A\u7A0E\u53F7\uFF09\n");
114599
114873
  process.exit(1);
114600
114874
  }
114601
- if (!title) {
114875
+ if (!title2) {
114602
114876
  console.error("\n\u274C VATI/VATSI \u9700\u8981 --title\uFF08\u53D1\u7968\u62AC\u5934\uFF09\n");
114603
114877
  process.exit(1);
114604
114878
  }
@@ -114609,7 +114883,7 @@ async function runInvoiceApply(opts) {
114609
114883
  invoiceInfomation = {
114610
114884
  CompanyName: cnName,
114611
114885
  TaxIdentificationNumber: tax,
114612
- Title: title,
114886
+ Title: title2,
114613
114887
  Phone: landline
114614
114888
  };
114615
114889
  }
@@ -114641,6 +114915,31 @@ async function runInvoiceApply(opts) {
114641
114915
  `);
114642
114916
  process.exit(1);
114643
114917
  }
114918
+ const end = /* @__PURE__ */ new Date();
114919
+ const start = /* @__PURE__ */ new Date();
114920
+ start.setMonth(start.getMonth() - 3);
114921
+ const params = new URLSearchParams();
114922
+ params.set("pageIndex", "1");
114923
+ params.set("pageSize", "20");
114924
+ params.set("searchValue", opts.billIds[0] ?? "");
114925
+ params.set("startDate", start.toISOString().slice(0, 10));
114926
+ params.set("endDate", end.toISOString().slice(0, 10));
114927
+ let listed;
114928
+ try {
114929
+ listed = await apiFetch2(`${config.apiBaseUrl}/invoice-request?${params}`, config, {}, opts.verbose);
114930
+ } catch {
114931
+ listed = void 0;
114932
+ }
114933
+ const info = invoiceInfomation;
114934
+ const title = String(info.Title || info.CompanyName || info.CompanyNameEn || "");
114935
+ printApplicationNeedles(
114936
+ [
114937
+ { label: "\u8BA2\u5355", value: opts.billIds[0] ?? "" },
114938
+ { label: "\u7968\u79CD", value: opts.invoiceType },
114939
+ ...title ? [{ label: "\u62AC\u5934", value: title }] : []
114940
+ ],
114941
+ listed
114942
+ );
114644
114943
  if (await emitCliJsonOrSnapshot(opts, {
114645
114944
  section: "invoice-apply",
114646
114945
  commandLabel: "invoice apply",
@@ -115555,6 +115854,19 @@ async function runForewarningDelete(opts) {
115555
115854
  `);
115556
115855
  process.exit(1);
115557
115856
  }
115857
+ let listed;
115858
+ try {
115859
+ listed = await apiFetch2(
115860
+ `${config.apiBaseUrl}/query/smart-strategy/settings/${opts.media}?PageIndex=1&PageSize=20`,
115861
+ config,
115862
+ {},
115863
+ opts.verbose
115864
+ );
115865
+ } catch {
115866
+ listed = void 0;
115867
+ }
115868
+ const gone = receiptForAbsence("\u9884\u8B66\u89C4\u5219", opts.id, listed);
115869
+ printWriteReceipt(gone.verification, gone.lines);
115558
115870
  console.log("\n\u2705 \u9884\u8B66\u89C4\u5219\u5DF2\u5220\u9664\n");
115559
115871
  }
115560
115872
  async function runForewarningGet(opts) {
@@ -115742,6 +116054,21 @@ async function runForewarningCreate(opts) {
115742
116054
  `);
115743
116055
  process.exit(1);
115744
116056
  }
116057
+ let listed;
116058
+ try {
116059
+ const url2 = opts.id ? `${config.apiBaseUrl}/query/smart-strategy/settings/${opts.media}/${opts.id}` : `${config.apiBaseUrl}/query/smart-strategy/settings/${opts.media}?PageIndex=1&PageSize=20&Name=${encodeURIComponent(opts.name)}`;
116060
+ listed = await apiFetch2(url2, config, {}, opts.verbose);
116061
+ } catch {
116062
+ listed = void 0;
116063
+ }
116064
+ printApplicationNeedles(
116065
+ [
116066
+ { label: "\u540D\u79F0", value: opts.name },
116067
+ { label: "\u5B57\u6BB5", value: opts.field },
116068
+ { label: "\u9608\u503C", value: String(opts.value) }
116069
+ ],
116070
+ listed
116071
+ );
115745
116072
  console.log(`
115746
116073
  \u2705 \u9884\u8B66\u89C4\u5219\u5DF2${isUpdate ? "\u66F4\u65B0" : "\u521B\u5EFA"}\uFF1A${opts.name}
115747
116074
  `);
@@ -116704,17 +117031,8 @@ function campaignEditPatchPairs(input) {
116704
117031
  if (input.negativeGeoTargetType !== void 0) {
116705
117032
  pairs.push(["negativeGeoTargetType", input.negativeGeoTargetType]);
116706
117033
  }
116707
- if (input.audienceTargeting !== void 0) {
116708
- pairs.push(["audienceTargeting", input.audienceTargeting]);
116709
- }
116710
117034
  return pairs;
116711
117035
  }
116712
- function parseAudienceTargeting(raw) {
116713
- const text5 = raw.trim().replace(/[_-]/g, "").toLowerCase();
116714
- if (text5 === "observation") return "Observation";
116715
- if (text5 === "targeting") return "Targeting";
116716
- return void 0;
116717
- }
116718
117036
  function campaignStatusPatchPairs(status) {
116719
117037
  return [["status", status]];
116720
117038
  }
@@ -116957,6 +117275,18 @@ function summarizeNegativeKeywordCreate(requested, response, listItems) {
116957
117275
  }
116958
117276
 
116959
117277
  // src/commands/ad/keyword.ts
117278
+ async function printIdGone(label2, listUrl, config, id, verbose) {
117279
+ try {
117280
+ await findItemInList(listUrl, config, id, verbose);
117281
+ printWriteReceipt("partial", [receiptLine(label2, "\u5DF2\u5220\u9664", "\u4ECD\u5728")]);
117282
+ } catch (err) {
117283
+ const message = err instanceof Error ? err.message : String(err);
117284
+ const gone = message.includes("\u672A\u5728\u5217\u8868\u4E2D\u627E\u5230");
117285
+ printWriteReceipt(gone ? "verified" : "unknown", [
117286
+ receiptLine(label2, "\u5DF2\u5220\u9664", gone ? "\u5DF2\u5220\u9664" : void 0)
117287
+ ]);
117288
+ }
117289
+ }
116960
117290
  function unwrapKeywordDisplayTextForEdit(raw) {
116961
117291
  const t = raw.trim();
116962
117292
  if (t.length >= 2 && t.startsWith('"') && t.endsWith('"')) {
@@ -117272,6 +117602,37 @@ async function runAdKeywordCreate(opts) {
117272
117602
  `);
117273
117603
  process.exit(1);
117274
117604
  }
117605
+ const listParams = new URLSearchParams();
117606
+ listParams.set("startDate", toGoogleDate(void 0, -30));
117607
+ listParams.set("endDate", toGoogleDate(void 0, 0));
117608
+ listParams.set("newest", "true");
117609
+ let listItems = null;
117610
+ try {
117611
+ const listed = await apiFetch2(
117612
+ `${googleApiUrl}/keywordmanagement/v2/list/${opts.account}?${listParams}`,
117613
+ config,
117614
+ {},
117615
+ opts.verbose
117616
+ );
117617
+ listItems = listed.data ?? [];
117618
+ } catch {
117619
+ listItems = null;
117620
+ }
117621
+ const summary = summarizeNegativeKeywordCreate(keywords, response, listItems);
117622
+ const matched = new Set(summary.matched.map((item) => item.text));
117623
+ const lines = keywords.map(
117624
+ (text5) => receiptLine("\u5173\u952E\u8BCD", text5, listItems == null ? void 0 : matched.has(text5) ? text5 : "\u672A\u627E\u5230")
117625
+ );
117626
+ if (opts.finalUrl) {
117627
+ const hit = listItems?.find((item) => {
117628
+ const cores = [item["finalURL"], item["finalUrl"], item["FinalUrl"]].map(
117629
+ (value) => value == null ? "" : String(value)
117630
+ );
117631
+ return cores.includes(opts.finalUrl);
117632
+ });
117633
+ lines.push(receiptLine("\u843D\u5730\u9875", opts.finalUrl, listItems == null ? void 0 : hit ? opts.finalUrl : "\u672A\u627E\u5230"));
117634
+ }
117635
+ printWriteReceipt(listItems == null ? "unknown" : judgeReceipt(lines), lines);
117275
117636
  if (await emitCliJsonOrSnapshot(opts, {
117276
117637
  section: `ad-keyword-create-${opts.account}-${opts.adgroupId}`,
117277
117638
  commandLabel: "ad keyword-create",
@@ -117362,7 +117723,7 @@ async function runAdNegativeKeywordCreate(opts) {
117362
117723
  `);
117363
117724
  process.exit(1);
117364
117725
  }
117365
- const listUrl = negativeKeywordSlimListUrl(googleApiUrl, opts.account);
117726
+ const listUrl = negativeKeywordSlimListUrl(googleApiUrl, opts.account, { newest: true });
117366
117727
  const readList = async () => {
117367
117728
  try {
117368
117729
  const listed = await apiFetch2(
@@ -117386,6 +117747,13 @@ async function runAdNegativeKeywordCreate(opts) {
117386
117747
  const nextQuery = `siluzan-tso ad keywords -a ${opts.account} --negative --json-out ./snap`;
117387
117748
  const detail = summary.verification === "verified" ? `\u5DF2\u6838\u9A8C\u6DFB\u52A0 ${summary.matchedCount} \u4E2A\u5426\u5B9A\u5173\u952E\u8BCD\uFF08${negativeKeywordLevelLabel[level]}\uFF09` : `\u8BF7\u6C42 ${keywords.length} \u4E2A\uFF0C\u5BF9\u4E0A ${summary.matchedCount} \u4E2A${summary.pending.length ? `\uFF0C\u5C1A\u672A\u6838\u9A8C\uFF1A${summary.pending.join("\u3001")}` : ""}`;
117388
117749
  const headline = writeVerificationHeadline(summary.verification, detail);
117750
+ const matchedTexts = new Set(summary.matched.map((item) => item.text));
117751
+ printWriteReceipt(
117752
+ summary.verification,
117753
+ keywords.map(
117754
+ (text5) => receiptLine("\u5426\u5B9A\u5173\u952E\u8BCD", text5, listItems == null ? void 0 : matchedTexts.has(text5) ? text5 : "\u672A\u627E\u5230")
117755
+ )
117756
+ );
117389
117757
  if (summary.verification !== "verified") {
117390
117758
  console.error(`
117391
117759
  ${headline}
@@ -117433,6 +117801,17 @@ async function runAdKeywordDelete(opts) {
117433
117801
  `);
117434
117802
  process.exit(1);
117435
117803
  }
117804
+ const goneParams = new URLSearchParams();
117805
+ goneParams.set("startDate", toGoogleDate(void 0, -30));
117806
+ goneParams.set("endDate", toGoogleDate(void 0, 0));
117807
+ goneParams.set("newest", "true");
117808
+ await printIdGone(
117809
+ "\u5173\u952E\u8BCD",
117810
+ `${googleApiUrl}/keywordmanagement/v2/list/${opts.account}?${goneParams}`,
117811
+ config,
117812
+ opts.id,
117813
+ opts.verbose
117814
+ );
117436
117815
  console.log(`
117437
117816
  \u2705 \u5173\u952E\u8BCD ${opts.id} \u5DF2\u5220\u9664
117438
117817
  `);
@@ -117449,7 +117828,7 @@ function findKeywordEditMismatches(requested, returned, changed) {
117449
117828
  const expectedCents = Number(requested["maxCPC"]);
117450
117829
  const actualCents = returned["maxCPC"];
117451
117830
  mismatches.push(
117452
- `maxCPC\uFF1A\u671F\u671B ${expectedCents / 100} \u5143\uFF0C\u5217\u8868\u4ECD\u662F ${actualCents / 100} \u5143\u3002\u5173\u952E\u8BCD\u5217\u8868\u6309\u8D26\u6237\u548C\u65E5\u671F\u7F13\u5B58\u7EA6 60 \u79D2\uFF0C\u4E14\u6CA1\u6709 --fresh\uFF0C\u8FD9\u6B21\u56DE\u8BFB\u53EF\u80FD\u4ECD\u662F\u5199\u5165\u524D\u7684\u503C\u3002\u4E0D\u8981\u7ACB\u523B\u91CD\u8DD1 keyword-edit\uFF0C\u4E5F\u4E0D\u8981\u5220\u8BCD\u91CD\u5EFA\u3002\u7EA6 60 \u79D2\u540E\u7528 ad keywords --json-out \u770B\u8BE5 id \u7684 maxCPCYuan\uFF0C\u5DF2\u7ECF\u662F\u76EE\u6807\u503C\u5C31\u5F53\u6210\u529F\u3002`
117831
+ `maxCPC\uFF1A\u671F\u671B ${expectedCents / 100} \u5143\uFF0C\u5217\u8868\u4ECD\u662F ${actualCents / 100} \u5143\u3002\u8FD9\u6B21\u56DE\u8BFB\u5DF2\u8DF3\u8FC7\u7F51\u5173\u5217\u8868\u7F13\u5B58\uFF0C\u8FD9\u662F\u5F53\u524D\u8BFB\u5230\u7684\u51FA\u4EF7\u3002\u4E0D\u8981\u7ACB\u523B\u91CD\u8DD1 keyword-edit\uFF0C\u4E5F\u4E0D\u8981\u5220\u8BCD\u91CD\u5EFA\u3002`
117453
117832
  );
117454
117833
  }
117455
117834
  if (changed.status !== void 0 && typeof returned["userStatusV2"] === "string" && str3(returned["userStatusV2"]).toLowerCase() !== changed.status.toLowerCase()) {
@@ -117477,6 +117856,7 @@ async function runAdKeywordEdit(opts) {
117477
117856
  const params = new URLSearchParams();
117478
117857
  params.set("startDate", toGoogleDate(opts.startDate, -30));
117479
117858
  params.set("endDate", toGoogleDate(opts.endDate, 0));
117859
+ params.set("newest", "true");
117480
117860
  const listUrl = `${googleApiUrl}/keywordmanagement/v2/list/${opts.account}?${params}`;
117481
117861
  const notAppliedHint = ` \u8BF7\u52FF\u6539\u7528\u300C\u5220\u9664\u540E\u91CD\u5EFA\u300D\u7ED5\u8FC7\uFF08\u4F1A\u4E22\u5931\u5173\u952E\u8BCD id \u4E0E\u5386\u53F2\u6570\u636E\uFF09\uFF0C\u8BF7\u53CD\u9988\u5E73\u53F0\u6392\u67E5\u3002
117482
117862
  `;
@@ -117572,6 +117952,19 @@ async function runAdKeywordEdit(opts) {
117572
117952
  process.exit(1);
117573
117953
  }
117574
117954
  const mismatches = findKeywordEditMismatches(readbackExpected, fresh, opts);
117955
+ const editLines = [];
117956
+ if (opts.finalUrl !== void 0) {
117957
+ editLines.push(receiptLine("\u843D\u5730\u9875", opts.finalUrl, fresh["finalURL"] ?? fresh["FinalUrl"]));
117958
+ }
117959
+ if (opts.maxCpc !== void 0) {
117960
+ const cents = fresh["maxCPC"] ?? fresh["maxCpc"];
117961
+ const yuan = typeof cents === "number" ? cents / 100 : void 0;
117962
+ editLines.push(receiptLine("CPC\u4E0A\u9650", yuanLabel(opts.maxCpc), yuan == null ? void 0 : yuanLabel(yuan)));
117963
+ }
117964
+ if (opts.status !== void 0) {
117965
+ editLines.push(receiptLine("\u72B6\u6001", opts.status, fresh["userStatusV2"] ?? fresh["status"]));
117966
+ }
117967
+ printWriteReceipt(mismatches.length > 0 ? "partial" : judgeReceipt(editLines), editLines);
117575
117968
  if (mismatches.length > 0) {
117576
117969
  console.error(
117577
117970
  `
@@ -117689,7 +118082,7 @@ async function runAdNegativeKeywordDelete(opts) {
117689
118082
  opts = withResolvedAdAccount(opts);
117690
118083
  const config = loadConfig(opts.token);
117691
118084
  const googleApiUrl = requireGoogleApi(config);
117692
- const listUrl = negativeKeywordSlimListUrl(googleApiUrl, opts.account);
118085
+ const listUrl = negativeKeywordSlimListUrl(googleApiUrl, opts.account, { newest: true });
117693
118086
  let keyword;
117694
118087
  try {
117695
118088
  keyword = await findItemInList(listUrl, config, opts.id, opts.verbose);
@@ -117711,6 +118104,7 @@ async function runAdNegativeKeywordDelete(opts) {
117711
118104
  `);
117712
118105
  process.exit(1);
117713
118106
  }
118107
+ await printIdGone("\u5426\u5B9A\u5173\u952E\u8BCD", listUrl, config, opts.id, opts.verbose);
117714
118108
  console.log(`
117715
118109
  \u2705 \u5426\u5B9A\u5173\u952E\u8BCD ${opts.id} \u5DF2\u5220\u9664
117716
118110
  `);
@@ -119406,9 +119800,13 @@ function unwrapCampaign(res) {
119406
119800
  }
119407
119801
  return res;
119408
119802
  }
119803
+ function campaignReadUrl(detailUrl) {
119804
+ if (/[?&]newest=/.test(detailUrl)) return detailUrl;
119805
+ return `${detailUrl}${detailUrl.includes("?") ? "&" : "?"}newest=true`;
119806
+ }
119409
119807
  async function fetchCampaignRecord(detailUrl, config, verbose) {
119410
119808
  const res = await apiFetch2(
119411
- detailUrl,
119809
+ campaignReadUrl(detailUrl),
119412
119810
  config,
119413
119811
  {},
119414
119812
  verbose
@@ -119465,6 +119863,7 @@ async function reportFailedCampaignPut(opts) {
119465
119863
  });
119466
119864
  }
119467
119865
  async function reportCampaignWrite(opts) {
119866
+ printWriteReceipt(opts.verification, receiptLinesFromFieldChecks(opts.checks));
119468
119867
  const nextQuery = `siluzan-tso ad campaigns -a ${opts.account} --json-out ./snap`;
119469
119868
  const unmatched = describeUnmatchedChecks(opts.checks);
119470
119869
  const text5 = opts.verification === "verified" ? opts.detail : unmatched || opts.detail;
@@ -119510,7 +119909,7 @@ async function runAdCampaignStatus(opts) {
119510
119909
  let campaign;
119511
119910
  try {
119512
119911
  const res = await apiFetch2(
119513
- detailUrl,
119912
+ campaignReadUrl(detailUrl),
119514
119913
  config,
119515
119914
  {},
119516
119915
  opts.verbose
@@ -119577,7 +119976,7 @@ async function runAdCampaignDelete(opts) {
119577
119976
  let campaign;
119578
119977
  try {
119579
119978
  const res = await apiFetch2(
119580
- detailUrl,
119979
+ campaignReadUrl(detailUrl),
119581
119980
  config,
119582
119981
  {},
119583
119982
  opts.verbose
@@ -119612,9 +120011,32 @@ async function runAdCampaignDelete(opts) {
119612
120011
  `);
119613
120012
  process.exit(1);
119614
120013
  }
119615
- console.log(`
120014
+ let removed = false;
120015
+ let stillStatus;
120016
+ try {
120017
+ const again = await apiFetch2(
120018
+ campaignReadUrl(detailUrl),
120019
+ config,
120020
+ {},
120021
+ opts.verbose
120022
+ );
120023
+ const row = again.data ?? again;
120024
+ const status = String(row["statusV2"] ?? row["status"] ?? "");
120025
+ removed = /removed/i.test(status);
120026
+ if (!removed) stillStatus = status || "\u4ECD\u5728";
120027
+ } catch (err) {
120028
+ const message = err instanceof Error ? err.message : String(err);
120029
+ removed = /404|未找到|not found|不存在/i.test(message);
120030
+ }
120031
+ const verification = removed ? "verified" : stillStatus ? "partial" : "unknown";
120032
+ printWriteReceipt(verification, [
120033
+ receiptLine("\u7CFB\u5217", "\u5DF2\u5220\u9664", removed ? "\u5DF2\u5220\u9664" : stillStatus)
120034
+ ]);
120035
+ if (verification === "verified") {
120036
+ console.log(`
119616
120037
  \u2705 \u5E7F\u544A\u7CFB\u5217 ${opts.id} \u5DF2\u5220\u9664
119617
120038
  `);
120039
+ }
119618
120040
  }
119619
120041
  async function runAdCampaignCreate(opts) {
119620
120042
  const cfg = loadCampaignCreateConfig(opts.configFile);
@@ -119810,22 +120232,8 @@ async function runAdCampaignBiddingStrategies(opts) {
119810
120232
  `
119811
120233
  );
119812
120234
  }
119813
- function parseCampaignAudienceTargeting(raw) {
119814
- if (raw === void 0) return void 0;
119815
- const parsed = parseAudienceTargeting(raw);
119816
- if (!parsed) {
119817
- console.error("\n\u274C --audience-targeting \u65E0\u6548\uFF0C\u5408\u6CD5\u503C\uFF1AObservation | Targeting\n");
119818
- process.exit(1);
119819
- }
119820
- return parsed;
119821
- }
119822
- function isSearchChannel(channel) {
119823
- const text5 = String(channel ?? "").trim();
119824
- if (!text5) return true;
119825
- return text5.replace(/[_-]/g, "").toUpperCase() === "SEARCH";
119826
- }
119827
120235
  function parseCampaignEditGeoTargetTypes(opts) {
119828
- const fail10 = (flag, value, allowed) => {
120236
+ const fail9 = (flag, value, allowed) => {
119829
120237
  console.error(`
119830
120238
  \u274C ${flag} \u65E0\u6548\uFF08${value}\uFF09\uFF0C\u5408\u6CD5\u503C\uFF1A${allowed}
119831
120239
  `);
@@ -119836,13 +120244,13 @@ function parseCampaignEditGeoTargetTypes(opts) {
119836
120244
  if (opts.geoTargetType !== void 0) {
119837
120245
  positive = parsePositiveGeoTargetType(opts.geoTargetType) ?? void 0;
119838
120246
  if (!positive) {
119839
- fail10("--geo-target-type", opts.geoTargetType, Object.keys(GEO_TARGET_TYPE_CLI_VALUES).join(" | "));
120247
+ fail9("--geo-target-type", opts.geoTargetType, Object.keys(GEO_TARGET_TYPE_CLI_VALUES).join(" | "));
119840
120248
  }
119841
120249
  }
119842
120250
  if (opts.negativeGeoTargetType !== void 0) {
119843
120251
  negative = parseNegativeGeoTargetType(opts.negativeGeoTargetType) ?? void 0;
119844
120252
  if (!negative) {
119845
- fail10("--negative-geo-target-type", opts.negativeGeoTargetType, "presence | presence-or-interest");
120253
+ fail9("--negative-geo-target-type", opts.negativeGeoTargetType, "presence | presence-or-interest");
119846
120254
  }
119847
120255
  }
119848
120256
  return { positive, negative };
@@ -119877,14 +120285,13 @@ async function runAdCampaignEdit(opts) {
119877
120285
  opts = withResolvedAdAccount(opts);
119878
120286
  validateCampaignEditBidding(opts);
119879
120287
  const geoTargetTypes = parseCampaignEditGeoTargetTypes(opts);
119880
- const audienceTargeting = parseCampaignAudienceTargeting(opts.audienceTargeting);
119881
120288
  const config = loadConfig(opts.token);
119882
120289
  const googleApiUrl = requireGoogleApi(config);
119883
120290
  const detailUrl = `${googleApiUrl}/campaignmanagement/campaign/${opts.account}/${opts.id}`;
119884
120291
  let campaign;
119885
120292
  try {
119886
120293
  const res = await apiFetch2(
119887
- detailUrl,
120294
+ campaignReadUrl(detailUrl),
119888
120295
  config,
119889
120296
  {},
119890
120297
  opts.verbose
@@ -119909,20 +120316,10 @@ async function runAdCampaignEdit(opts) {
119909
120316
  targetSearchNetwork: opts.targetSearchNetwork,
119910
120317
  targetContentNetwork: opts.targetContentNetwork,
119911
120318
  positiveGeoTargetType: geoTargetTypes.positive,
119912
- negativeGeoTargetType: geoTargetTypes.negative,
119913
- audienceTargeting
120319
+ negativeGeoTargetType: geoTargetTypes.negative
119914
120320
  });
119915
120321
  if (patchPairs.length === 0) {
119916
- console.error("\n\u274C \u8BF7\u81F3\u5C11\u6307\u5B9A\u4E00\u4E2A\u4FEE\u6539\u9879\uFF08--name / --budget / --bidding / --geo-target-type / --audience-targeting / \u2026\uFF09\n");
119917
- process.exit(1);
119918
- }
119919
- if (audienceTargeting && !isSearchChannel(campaign.channelTypeV2 ?? campaign.ChannelTypeV2)) {
119920
- const channel = String(campaign.channelTypeV2 ?? campaign.ChannelTypeV2 ?? "");
119921
- console.error(
119922
- `
119923
- \u274C --audience-targeting \u53EA\u7528\u4E8E\u641C\u7D22\u7CFB\u5217\u3002\u5F53\u524D\u6E20\u9053\u662F ${channel || "\u672A\u77E5"}\u3002
119924
- `
119925
- );
120322
+ console.error("\n\u274C \u8BF7\u81F3\u5C11\u6307\u5B9A\u4E00\u4E2A\u4FEE\u6539\u9879\uFF08--name / --budget / --bidding / --geo-target-type / \u2026\uFF09\n");
119926
120323
  process.exit(1);
119927
120324
  }
119928
120325
  if (opts.budget !== void 0 && readBudgetSharedFlag(campaign) === true) {
@@ -119971,9 +120368,6 @@ async function runAdCampaignEdit(opts) {
119971
120368
  parts.push(`\u4F4D\u7F6E\u9009\u9879\u2192${GEO_TARGET_TYPE_LABEL[geoTargetTypes.positive]}`);
119972
120369
  }
119973
120370
  if (geoTargetTypes.negative) parts.push(`\u6392\u9664\u4F4D\u7F6E\u9009\u9879\u2192${geoTargetTypes.negative}`);
119974
- if (audienceTargeting) {
119975
- parts.push(`\u53D7\u4F17\u2192${audienceTargeting === "Observation" ? "\u89C2\u5BDF" : "\u5B9A\u5411"}`);
119976
- }
119977
120371
  const judged = await verifyCampaignAfterPut(
119978
120372
  detailUrl,
119979
120373
  config,
@@ -120520,6 +120914,7 @@ async function runAdDelete(opts) {
120520
120914
  const params = new URLSearchParams();
120521
120915
  params.set("startDate", toGoogleDate(opts.startDate, -30));
120522
120916
  params.set("endDate", toGoogleDate(opts.endDate, 0));
120917
+ params.set("newest", "true");
120523
120918
  const listUrl = `${googleApiUrl}/admanagement/v2/list/${opts.account}?${params}`;
120524
120919
  let ad;
120525
120920
  try {
@@ -120539,6 +120934,18 @@ async function runAdDelete(opts) {
120539
120934
  `);
120540
120935
  process.exit(1);
120541
120936
  }
120937
+ let gone = false;
120938
+ let still = false;
120939
+ try {
120940
+ await findItemInList(listUrl, config, opts.id, opts.verbose);
120941
+ still = true;
120942
+ } catch (err) {
120943
+ const message = err instanceof Error ? err.message : String(err);
120944
+ gone = message.includes("\u672A\u5728\u5217\u8868\u4E2D\u627E\u5230");
120945
+ }
120946
+ printWriteReceipt(gone ? "verified" : still ? "partial" : "unknown", [
120947
+ receiptLine("\u5E7F\u544A", "\u5DF2\u5220\u9664", gone ? "\u5DF2\u5220\u9664" : still ? "\u4ECD\u5728" : void 0)
120948
+ ]);
120542
120949
  console.log(`
120543
120950
  \u2705 \u5E7F\u544A ${opts.id} \u5DF2\u5220\u9664
120544
120951
  `);
@@ -120588,6 +120995,31 @@ async function runAdEdit(opts) {
120588
120995
  `);
120589
120996
  process.exit(1);
120590
120997
  }
120998
+ const readParams = new URLSearchParams();
120999
+ readParams.set("startDate", toGoogleDate(void 0, -30));
121000
+ readParams.set("endDate", toGoogleDate(void 0, 0));
121001
+ readParams.set("newest", "true");
121002
+ let fresh;
121003
+ try {
121004
+ fresh = await findItemInList(
121005
+ `${googleApiUrl}/admanagement/v2/list/${opts.account}?${readParams}`,
121006
+ config,
121007
+ opts.id,
121008
+ opts.verbose
121009
+ );
121010
+ } catch {
121011
+ fresh = void 0;
121012
+ }
121013
+ const lines = [];
121014
+ if (opts.finalUrl !== void 0) {
121015
+ lines.push(receiptLine("\u843D\u5730\u9875", opts.finalUrl, fresh?.["finalUrl"] ?? fresh?.["Finalurl"] ?? fresh?.["FinalUrl"]));
121016
+ }
121017
+ if (opts.status !== void 0) {
121018
+ lines.push(receiptLine("\u72B6\u6001", opts.status, fresh?.["status"] ?? fresh?.["statusV2"]));
121019
+ }
121020
+ if (lines.length > 0) {
121021
+ printWriteReceipt(fresh ? judgeReceipt(lines) : "unknown", lines);
121022
+ }
120591
121023
  console.log(`
120592
121024
  \u2705 \u5E7F\u544A ${opts.id} \u5DF2\u66F4\u65B0
120593
121025
  `);
@@ -120604,8 +121036,7 @@ var EXCLUSION_TYPES = [
120604
121036
  "youtube-channel",
120605
121037
  "youtube-video",
120606
121038
  "app",
120607
- "app-category",
120608
- "user-list"
121039
+ "app-category"
120609
121040
  ];
120610
121041
  var RESERVED_PLACEMENT_SUFFIXES = [".invalid", ".example", ".test", ".localhost"];
120611
121042
  function normalizePlacementUrl(raw) {
@@ -120643,7 +121074,7 @@ function buildExclusionCreateBody(input) {
120643
121074
  const type = input.type.trim().toLowerCase();
120644
121075
  if (!EXCLUSION_TYPES.includes(type)) {
120645
121076
  throw new Error(
120646
- "type \u987B\u4E3A content-label | placement | youtube-channel | youtube-video | app | app-category | user-list"
121077
+ "type \u987B\u4E3A content-label | placement | youtube-channel | youtube-video | app | app-category"
120647
121078
  );
120648
121079
  }
120649
121080
  const filled = [
@@ -120652,11 +121083,10 @@ function buildExclusionCreateBody(input) {
120652
121083
  input.channelId,
120653
121084
  input.videoId,
120654
121085
  input.appId,
120655
- input.appCategoryId,
120656
- input.userListId
121086
+ input.appCategoryId
120657
121087
  ].filter((value) => value != null && String(value).trim() !== "");
120658
121088
  if (filled.length !== 1) {
120659
- throw new Error("\u4E00\u6B21\u53EA\u586B\u4E00\u79CD\u503C\uFF1A\u5185\u5BB9\u6807\u7B7E\u3001\u7F51\u5740\u3001\u9891\u9053\u3001\u89C6\u9891\u3001\u5E94\u7528\u3001\u5E94\u7528\u7C7B\u522B\u6216\u7528\u6237\u5217\u8868 id");
121089
+ throw new Error("\u4E00\u6B21\u53EA\u586B\u4E00\u79CD\u503C\uFF1A\u5185\u5BB9\u6807\u7B7E\u3001\u7F51\u5740\u3001\u9891\u9053\u3001\u89C6\u9891\u3001\u5E94\u7528\u6216\u5E94\u7528\u7C7B\u522B id");
120660
121090
  }
120661
121091
  if (type === "content-label") {
120662
121092
  const contentLabel = input.contentLabel?.trim() ?? "";
@@ -120683,18 +121113,11 @@ function buildExclusionCreateBody(input) {
120683
121113
  }
120684
121114
  return { type, appId };
120685
121115
  }
120686
- if (type === "app-category") {
120687
- const appCategoryId = input.appCategoryId?.trim() ?? "";
120688
- if (!/^\d+$/.test(appCategoryId)) {
120689
- throw new Error("app-category \u9700\u8981 app-categories \u8FD4\u56DE\u7684\u6570\u5B57 --app-category-id");
120690
- }
120691
- return { type, appCategoryId };
120692
- }
120693
- const userListId = input.userListId?.trim() ?? "";
120694
- if (!/^\d+$/.test(userListId)) {
120695
- throw new Error("user-list \u9700\u8981\u5DF2\u6709\u7528\u6237\u5217\u8868\u7684\u6570\u5B57 --user-list-id\u3002\u4E0A\u4F20\u540D\u5355\u8D70 Customer Match\uFF0C\u4E0D\u5728\u8FD9\u91CC\u505A\u3002");
121116
+ const appCategoryId = input.appCategoryId?.trim() ?? "";
121117
+ if (!/^\d+$/.test(appCategoryId)) {
121118
+ throw new Error("app-category \u9700\u8981 app-categories \u8FD4\u56DE\u7684\u6570\u5B57 --app-category-id");
120696
121119
  }
120697
- return { type, userListId };
121120
+ return { type, appCategoryId };
120698
121121
  }
120699
121122
  function exclusionsUrl(googleApiUrl, accountId) {
120700
121123
  return `${googleApiUrl}/campaignmanagement/accounts/${accountId}/exclusions`;
@@ -120786,6 +121209,15 @@ async function runAdExclusionsAdd(opts) {
120786
121209
  process.exit(1);
120787
121210
  }
120788
121211
  const payload = { account: opts.account, request: body, response: created };
121212
+ let listed;
121213
+ try {
121214
+ listed = await apiFetch2(url, config, {}, opts.verbose);
121215
+ } catch {
121216
+ listed = void 0;
121217
+ }
121218
+ const needle = Object.values(body).map(String).find((value) => value && value !== body.type) ?? body.type;
121219
+ const added = receiptFromNeedles([{ label: "\u6392\u9664", value: needle }], listed);
121220
+ printWriteReceipt(added.verification, added.lines);
120789
121221
  if (await emitCliJsonOrSnapshot(opts, {
120790
121222
  section: "ad-exclusions-add",
120791
121223
  commandLabel: "ad exclusions add",
@@ -120816,6 +121248,14 @@ async function runAdExclusionsRemove(opts) {
120816
121248
  `);
120817
121249
  process.exit(1);
120818
121250
  }
121251
+ let listed;
121252
+ try {
121253
+ listed = await apiFetch2(exclusionsUrl(requireGoogleApi(config), opts.account), config, {}, opts.verbose);
121254
+ } catch {
121255
+ listed = void 0;
121256
+ }
121257
+ const gone = receiptForAbsence("\u6392\u9664", opts.criterionId.trim(), listed);
121258
+ printWriteReceipt(gone.verification, gone.lines);
120819
121259
  console.log(`
120820
121260
  \u2705 \u5DF2\u5220\u9664\u5185\u5BB9\u6392\u9664 ${opts.criterionId}
120821
121261
  `);
@@ -121941,10 +122381,11 @@ function extensionRowsFromResponse(res) {
121941
122381
  (row) => !!row && typeof row === "object" && row["sectionHeadMode"] !== true
121942
122382
  );
121943
122383
  }
121944
- function accountExtensionListUrl(googleApiUrl, account, startDate, endDate) {
122384
+ function accountExtensionListUrl(googleApiUrl, account, startDate, endDate, newest = false) {
121945
122385
  const params = new URLSearchParams();
121946
122386
  params.set("startDate", toGoogleDate(startDate, -30));
121947
122387
  params.set("endDate", toGoogleDate(endDate, 0));
122388
+ if (newest) params.set("newest", "true");
121948
122389
  return `${googleApiUrl}/extensionmanagement/v2/list/${account}?${params}`;
121949
122390
  }
121950
122391
  function campaignExtensionListUrl(googleApiUrl, account, campaignId) {
@@ -121955,7 +122396,8 @@ async function fetchAccountExtensions(config, account, opts = {}) {
121955
122396
  requireGoogleApi(config),
121956
122397
  account,
121957
122398
  opts.startDate,
121958
- opts.endDate
122399
+ opts.endDate,
122400
+ opts.newest
121959
122401
  );
121960
122402
  return extensionRowsFromResponse(await apiFetch2(url, config, {}, opts.verbose));
121961
122403
  }
@@ -121975,7 +122417,7 @@ async function fetchCampaignExtensions(config, account, campaignId, opts = {}) {
121975
122417
  } catch (err) {
121976
122418
  if (!isNotFound(err)) throw err;
121977
122419
  }
121978
- const rows = (await fetchAccountExtensions(config, account, opts)).filter(
122420
+ const rows = (await fetchAccountExtensions(config, account, { ...opts, newest: true })).filter(
121979
122421
  (row) => String(row["campaignId"] ?? "") === cid
121980
122422
  );
121981
122423
  return { rows, source: "account-fallback" };
@@ -122909,8 +123351,8 @@ async function runAdGeoSearch(opts) {
122909
123351
  name: geoItemDisplayName(item) || null,
122910
123352
  targetType: geoItemType(item) || null
122911
123353
  }));
122912
- const pick3 = pickGeoCandidate(opts.query, items3);
122913
- const picked = pick3.picked;
123354
+ const pick2 = pickGeoCandidate(opts.query, items3);
123355
+ const picked = pick2.picked;
122914
123356
  const pickedId = picked ? String(picked["id"] ?? "") || null : null;
122915
123357
  const payload = {
122916
123358
  account: opts.account,
@@ -122918,8 +123360,8 @@ async function runAdGeoSearch(opts) {
122918
123360
  itemCount: rows.length,
122919
123361
  items: rows,
122920
123362
  /** ok=同名候选(Country 优先);needs_review=无同名候选未自动选;unserved=Google 不投放地区 */
122921
- pickStatus: pick3.status,
122922
- pickNote: pick3.note ?? null,
123363
+ pickStatus: pick2.status,
123364
+ pickNote: pick2.note ?? null,
122923
123365
  picked: picked ? {
122924
123366
  id: pickedId,
122925
123367
  name: geoItemDisplayName(picked) || null,
@@ -122962,7 +123404,7 @@ async function runAdGeoSearch(opts) {
122962
123404
  );
122963
123405
  } else {
122964
123406
  console.log(`
122965
- \u26A0\uFE0F \u672A\u81EA\u52A8\u9009\u62E9\uFF1A${pick3.note ?? "\u65E0\u540C\u540D\u5019\u9009"}
123407
+ \u26A0\uFE0F \u672A\u81EA\u52A8\u9009\u62E9\uFF1A${pick2.note ?? "\u65E0\u540C\u540D\u5019\u9009"}
122966
123408
  `);
122967
123409
  }
122968
123410
  }
@@ -123007,17 +123449,17 @@ function parseGeoResolveQueries(opts) {
123007
123449
  }
123008
123450
  var GEO_RESOLVE_CONCURRENCY = 6;
123009
123451
  function buildGeoResolveRow(query, items3) {
123010
- const pick3 = pickGeoCandidate(query, items3);
123452
+ const pick2 = pickGeoCandidate(query, items3);
123011
123453
  const row = {
123012
123454
  query,
123013
- id: pick3.picked ? String(pick3.picked["id"] ?? "") || null : null,
123014
- name: pick3.picked ? geoItemDisplayName(pick3.picked) || null : null,
123015
- targetType: pick3.picked ? geoItemType(pick3.picked) || null : null,
123016
- status: pick3.status,
123455
+ id: pick2.picked ? String(pick2.picked["id"] ?? "") || null : null,
123456
+ name: pick2.picked ? geoItemDisplayName(pick2.picked) || null : null,
123457
+ targetType: pick2.picked ? geoItemType(pick2.picked) || null : null,
123458
+ status: pick2.status,
123017
123459
  candidates: items3.length
123018
123460
  };
123019
- if (pick3.note) row.note = pick3.note;
123020
- if (pick3.status === "needs_review") {
123461
+ if (pick2.note) row.note = pick2.note;
123462
+ if (pick2.status === "needs_review") {
123021
123463
  row.topCandidates = items3.slice(0, 5).map((it) => ({
123022
123464
  id: String(it["id"] ?? ""),
123023
123465
  name: geoItemDisplayName(it)
@@ -123214,6 +123656,7 @@ async function runAdGeoAdd(opts) {
123214
123656
  `);
123215
123657
  process.exit(1);
123216
123658
  }
123659
+ await printGeoPresence(config, googleApiUrl, opts, true);
123217
123660
  const label2 = opts.exclude ? "\u5DF2\u6392\u9664" : "\u5DF2\u6DFB\u52A0\u5B9A\u4F4D";
123218
123661
  console.log(`
123219
123662
  \u2705 \u5730\u7406\u4F4D\u7F6E ${opts.locationId} ${label2}\uFF08\u5E7F\u544A\u7CFB\u5217\uFF1A${opts.campaignId}\uFF09
@@ -123233,14 +123676,50 @@ async function runAdGeoRemove(opts) {
123233
123676
  `);
123234
123677
  process.exit(1);
123235
123678
  }
123679
+ await printGeoPresence(config, googleApiUrl, opts, false);
123236
123680
  console.log(`
123237
123681
  \u2705 \u5730\u7406\u4F4D\u7F6E ${opts.locationId} \u5DF2\u4ECE\u5E7F\u544A\u7CFB\u5217 ${opts.campaignId} \u4E2D\u79FB\u9664
123238
123682
  `);
123239
123683
  }
123684
+ async function printGeoPresence(config, googleApiUrl, opts, shouldExist) {
123685
+ const params = new URLSearchParams({
123686
+ startDate: toGoogleDate(void 0, -30),
123687
+ endDate: toGoogleDate(void 0, 0),
123688
+ newest: "true"
123689
+ });
123690
+ const kinds = opts.exclude ? ["excludedlocations"] : shouldExist ? ["targetedlocations"] : ["targetedlocations", "excludedlocations"];
123691
+ let present;
123692
+ try {
123693
+ present = false;
123694
+ for (const kind of kinds) {
123695
+ const data = await apiFetch2(
123696
+ `${googleApiUrl}/campaignmanagement/v2/${kind}/${opts.account}?${params}`,
123697
+ config,
123698
+ {},
123699
+ opts.verbose
123700
+ );
123701
+ const rows = (data.data ?? []).filter(
123702
+ (row) => String(row["campaignId"] ?? row["CampaignId"] ?? "") === opts.campaignId
123703
+ );
123704
+ if (rows.some(
123705
+ (row) => [row["id"], row["Id"], row["locationId"], row["criterionId"]].map(String).includes(opts.locationId)
123706
+ )) {
123707
+ present = true;
123708
+ }
123709
+ }
123710
+ } catch {
123711
+ present = void 0;
123712
+ }
123713
+ const expected = shouldExist ? "\u5728\u5217\u8868\u4E2D" : "\u5DF2\u4E0D\u5728";
123714
+ const actual = present === void 0 ? void 0 : present ? "\u5728\u5217\u8868\u4E2D" : "\u5DF2\u4E0D\u5728";
123715
+ const lines = [receiptLine("\u5730\u533A", expected, actual)];
123716
+ printWriteReceipt(present === void 0 ? "unknown" : judgeReceipt(lines), lines);
123717
+ }
123240
123718
  async function fetchTargetedGeoRows(config, googleApiUrl, account, campaignId, verbose) {
123241
123719
  const params = new URLSearchParams({
123242
123720
  startDate: toGoogleDate(void 0, -30),
123243
- endDate: toGoogleDate(void 0, 0)
123721
+ endDate: toGoogleDate(void 0, 0),
123722
+ newest: "true"
123244
123723
  });
123245
123724
  const url = `${googleApiUrl}/campaignmanagement/v2/targetedlocations/${account}?${params}`;
123246
123725
  const data = await apiFetch2(url, config, {}, verbose);
@@ -123778,6 +124257,73 @@ function listPlannedRsaAssets(ad, groupPath, adIndex, adGroupName) {
123778
124257
  }
123779
124258
  return out;
123780
124259
  }
124260
+ function plannedLocationIds(value) {
124261
+ if (!Array.isArray(value)) return [];
124262
+ const ids = [];
124263
+ for (const item of value) {
124264
+ if (typeof item === "string" || typeof item === "number") {
124265
+ ids.push(String(item));
124266
+ continue;
124267
+ }
124268
+ if (item && typeof item === "object") {
124269
+ const id = pickString2(
124270
+ item["id"],
124271
+ item["Id"]
124272
+ );
124273
+ if (id) ids.push(id);
124274
+ }
124275
+ }
124276
+ return [...new Set(ids)].sort();
124277
+ }
124278
+ function firstPlannedFinalUrl(campaign) {
124279
+ const groups = campaign["AdGroupsForBatchJob"];
124280
+ if (!Array.isArray(groups)) return "";
124281
+ for (const group of groups) {
124282
+ if (!group || typeof group !== "object") continue;
124283
+ const ads = group["AdsForBatchJob"];
124284
+ if (!Array.isArray(ads)) continue;
124285
+ for (const ad of ads) {
124286
+ if (!ad || typeof ad !== "object") continue;
124287
+ const url = pickString2(
124288
+ ad["Finalurl"],
124289
+ ad["DestinationUrl"]
124290
+ );
124291
+ if (url) return url;
124292
+ }
124293
+ }
124294
+ return "";
124295
+ }
124296
+ function buildSearchCreateReceiptLines(campaign, live) {
124297
+ const lines = [];
124298
+ const plannedBudget = Number(campaign["Budget"] ?? campaign["budget"]);
124299
+ if (Number.isFinite(plannedBudget) && plannedBudget > 0) {
124300
+ lines.push(
124301
+ receiptLine(
124302
+ "\u65E5\u9884\u7B97",
124303
+ yuanLabel(plannedBudget),
124304
+ live.budgetYuan == null ? void 0 : yuanLabel(live.budgetYuan)
124305
+ )
124306
+ );
124307
+ }
124308
+ const plannedStatus = pickString2(campaign["StatusV2"], campaign["statusV2"]);
124309
+ if (plannedStatus) {
124310
+ lines.push(receiptLine("\u72B6\u6001", plannedStatus, live.statusV2));
124311
+ }
124312
+ const plannedIds = plannedLocationIds(campaign["targetedLocations"]);
124313
+ if (plannedIds.length > 0) {
124314
+ const liveIds = [...new Set((live.targetedLocations ?? []).map((row) => liveLocationId(row)).filter(Boolean))].sort();
124315
+ lines.push(receiptLine("\u6295\u653E\u56FD\u5BB6", plannedIds.join(","), live.campaignFound ? liveIds.join(",") : void 0));
124316
+ }
124317
+ const plannedGeo = resolveCampaignGeoTargetTypes(campaign);
124318
+ if (plannedGeo.positive) {
124319
+ lines.push(receiptLine("\u4F4D\u7F6E\u9009\u9879", plannedGeo.positive, live.positiveGeoTargetType));
124320
+ }
124321
+ const plannedUrl = firstPlannedFinalUrl(campaign);
124322
+ if (plannedUrl) {
124323
+ lines.push(receiptLine("\u843D\u5730\u9875", plannedUrl, live.landingUrl));
124324
+ }
124325
+ return lines;
124326
+ }
123781
124327
  function liveLocationId(item) {
123782
124328
  return pickString2(
123783
124329
  item["id"],
@@ -124521,7 +125067,7 @@ async function fetchLiveSnapshotForCampaign(config, accountId, campaignId, campa
124521
125067
  ),
124522
125068
  fetchList(
124523
125069
  config,
124524
- negativeKeywordSlimListUrl(googleApiUrl, accountId),
125070
+ negativeKeywordSlimListUrl(googleApiUrl, accountId, { newest: true }),
124525
125071
  verbose
124526
125072
  ),
124527
125073
  fetchList(
@@ -124555,9 +125101,19 @@ async function fetchLiveSnapshotForCampaign(config, accountId, campaignId, campa
124555
125101
  const liveCampaign = campaigns.find((c) => pickString2(c["id"], c["Id"]) === campaignId) ?? campaigns.find((c) => pickString2(c["name"], c["Name"]) === campaignName);
124556
125102
  const campaignFound = liveCampaign !== void 0;
124557
125103
  const liveGeoTargetTypes = liveCampaign ? readLiveGeoTargetTypes(liveCampaign) : {};
125104
+ const budgetYuan2 = liveCampaign ? toDisplayMoney(liveCampaign["budget"] ?? liveCampaign["Budget"]) ?? void 0 : void 0;
125105
+ const campaignAds = ads.filter((row) => belongsToCampaign(row, campaignId, campaignName));
125106
+ const landingUrl = pickString2(
125107
+ campaignAds[0]?.["Finalurl"],
125108
+ campaignAds[0]?.["finalUrl"],
125109
+ campaignAds[0]?.["DestinationUrl"]
125110
+ );
124558
125111
  return {
124559
125112
  campaignFound,
124560
125113
  campaignName,
125114
+ budgetYuan: budgetYuan2,
125115
+ statusV2: liveCampaign ? pickString2(liveCampaign["statusV2"], liveCampaign["StatusV2"]) : void 0,
125116
+ landingUrl: landingUrl || void 0,
124561
125117
  positiveGeoTargetType: liveGeoTargetTypes.positive,
124562
125118
  negativeGeoTargetType: liveGeoTargetTypes.negative,
124563
125119
  adGroups: adGroups.filter((g) => belongsToCampaign(g, campaignId, campaignName)),
@@ -125154,6 +125710,7 @@ async function runCampaignBatchDiff(opts) {
125154
125710
  const params = new URLSearchParams();
125155
125711
  params.set("startDate", toGoogleDate(void 0, -30));
125156
125712
  params.set("endDate", toGoogleDate(void 0, 0));
125713
+ params.set("newest", "true");
125157
125714
  const campaigns = await fetchList(
125158
125715
  config,
125159
125716
  `${googleApiUrl}/campaignmanagement/v2/list/${accountId}?${params}`,
@@ -125198,6 +125755,8 @@ async function runCampaignBatchDiff(opts) {
125198
125755
  ...result,
125199
125756
  ...report
125200
125757
  };
125758
+ const receiptLines = buildSearchCreateReceiptLines(campaign, live);
125759
+ printWriteReceipt(judgeReceipt(receiptLines, !live.campaignFound), receiptLines);
125201
125760
  printBatchDiffUserDeliveryMarkdown(report);
125202
125761
  if (await emitCliJsonOrSnapshot(
125203
125762
  { jsonOut: opts.jsonOut },
@@ -125582,6 +126141,23 @@ async function runAiCreationPublish(opts) {
125582
126141
  `);
125583
126142
  process.exit(1);
125584
126143
  }
126144
+ let again;
126145
+ try {
126146
+ again = await apiFetch2(`${queryBase}/${opts.id}`, config, {}, opts.verbose);
126147
+ } catch {
126148
+ again = void 0;
126149
+ }
126150
+ const submittedCampaign = body["campaign"] ?? {};
126151
+ const readCampaign = again?.["campaign"] ?? {};
126152
+ const status = again ? String(again["status"] ?? again["draftStatus"] ?? "") : "";
126153
+ const leftDraft = status !== "" && status !== "Draft";
126154
+ const campaignId = again ? resolveCampaignIdFromBatch(again) : "";
126155
+ const lines = [
126156
+ receiptLine("\u53D1\u5E03\u72B6\u6001", "\u5DF2\u79BB\u5F00\u8349\u7A3F", again ? leftDraft ? "\u5DF2\u79BB\u5F00\u8349\u7A3F" : status || "Draft" : void 0),
126157
+ receiptLine("\u7CFB\u5217\u9884\u7B97", submittedCampaign["Budget"], again ? readCampaign["Budget"] : void 0),
126158
+ receiptLine("\u7CFB\u5217", "\u5DF2\u751F\u6210", again ? campaignId || "\u5C1A\u672A\u751F\u6210" : void 0)
126159
+ ];
126160
+ printWriteReceipt(again ? judgeReceipt(lines) : "unknown", lines);
125585
126161
  console.log(
125586
126162
  `
125587
126163
  \u2705 \u8349\u7A3F\u5DF2\u63D0\u4EA4\u53D1\u5E03\uFF0CGoogle \u5C06\u5728\u540E\u53F0\u5F02\u6B65\u6267\u884C\u521B\u5EFA\uFF0C\u53EF\u901A\u8FC7 ad batch list \u67E5\u770B\u6700\u65B0\u72B6\u6001
@@ -127548,345 +128124,6 @@ async function linkPmaxVideoAfterCreate(opts) {
127548
128124
  }
127549
128125
  }
127550
128126
 
127551
- // src/commands/ad/pmax-create.ts
127552
- function printVideoLinkRecoveryHint(accountId, assetGroupId, campaignId, youtubeTarget) {
127553
- const cid = campaignId != null ? ` --campaign-id ${campaignId}` : "";
127554
- const yt = youtubeTarget ? ` --youtube "${youtubeTarget}"` : ` --video-path "<path>"`;
127555
- console.error(
127556
- ` \u53EF\u624B\u52A8\uFF1Asiluzan-tso ad pmax-youtube-link -a ${accountId} --asset-group-id ${assetGroupId}${cid}${yt}
127557
- \u6D3B\u52A8\u5DF2\u7ECF\u521B\u5EFA\u6210\u529F\uFF0C\u4E0D\u8981\u518D\u6267\u884C pmax-create\u3002
127558
- `
127559
- );
127560
- }
127561
- async function runAdPmaxCreate(opts) {
127562
- const cfg = loadPmaxCreateConfig(opts.configFile);
127563
- const rawCfg = loadPmaxCreateConfigRaw(opts.configFile) ?? {};
127564
- const deprecatedVideoKeys = detectDeprecatedPmaxVideoKeys(rawCfg);
127565
- const {
127566
- errors: cfgErrors,
127567
- warnings: cfgWarnings,
127568
- lengthViolations: cfgLengthViolations
127569
- } = runPmaxCreateValidation(cfg);
127570
- const { errors: imgErrors, warnings: imgWarnings } = await runPmaxImageValidation(
127571
- opts.configFile,
127572
- cfg
127573
- );
127574
- const { errors: videoErrors, warnings: videoWarnings } = runPmaxVideoValidation(
127575
- opts.configFile,
127576
- cfg
127577
- );
127578
- const { errors: extErrors, warnings: extWarnings } = validatePmaxCampaignExtensions(
127579
- cfg.campaignExtensions,
127580
- {
127581
- skipCampaignExtensions: cfg.skipCampaignExtensions,
127582
- rawConfig: rawCfg
127583
- }
127584
- );
127585
- const errors = [...deprecatedVideoKeys, ...cfgErrors, ...imgErrors, ...videoErrors, ...extErrors];
127586
- const warnings = [...cfgWarnings, ...imgWarnings, ...videoWarnings, ...extWarnings];
127587
- if (warnings.length > 0) {
127588
- console.warn("\n\u26A0\uFE0F PMax \u914D\u7F6E\u8B66\u544A\uFF08\u4E0D\u963B\u65AD\u63D0\u4EA4\uFF09\uFF1A");
127589
- for (const w of warnings) console.warn(` \u2022 ${w}`);
127590
- }
127591
- if (errors.length > 0) {
127592
- console.error("\n\u274C PMax \u914D\u7F6E\u6821\u9A8C\u5931\u8D25\uFF1A");
127593
- for (const e of errors) console.error(` \u2022 ${e}`);
127594
- const lengthReport = formatLengthViolationsReport(cfgLengthViolations, {
127595
- revalidateCommand: "pmax-validate"
127596
- });
127597
- if (lengthReport) console.error(lengthReport);
127598
- console.error();
127599
- process.exit(1);
127600
- }
127601
- const config = await ensureDataPermission(loadConfig(opts.token));
127602
- const googleApiUrl = requireGoogleApi(config);
127603
- const accountId = resolveAdAccountId(cfg.account.toString(), "account");
127604
- cfg.account = accountId;
127605
- let imageSlots;
127606
- try {
127607
- imageSlots = await resolvePmaxImageSlots(
127608
- opts.configFile,
127609
- cfg,
127610
- accountId,
127611
- config,
127612
- googleApiUrl,
127613
- { verbose: opts.verbose, logUploads: !opts.jsonOut }
127614
- );
127615
- } catch (err) {
127616
- console.error(`
127617
- \u274C \u56FE\u7247\u4E0A\u4F20/\u89E3\u6790\u5931\u8D25\uFF1A${err instanceof Error ? err.message : String(err)}
127618
- `);
127619
- process.exit(1);
127620
- }
127621
- let body;
127622
- try {
127623
- body = buildPmaxCreateApiBody(cfg, imageSlots);
127624
- } catch (err) {
127625
- console.error(`
127626
- \u274C \u6784\u5EFA\u8BF7\u6C42\u4F53\u5931\u8D25\uFF1A${err instanceof Error ? err.message : String(err)}
127627
- `);
127628
- process.exit(1);
127629
- }
127630
- const url = buildPmaxCreateUrl(googleApiUrl, accountId);
127631
- let data;
127632
- try {
127633
- data = await apiFetch2(
127634
- url,
127635
- config,
127636
- { method: "POST", body: JSON.stringify(body) },
127637
- opts.verbose
127638
- );
127639
- } catch (err) {
127640
- const failure = parsePmaxCreateFailureBody(readHttpRawBody(err));
127641
- if (failure) {
127642
- const advice = pmaxCreateRetryAdvice(cfg, failure);
127643
- console.error(`
127644
- \u274C \u521B\u5EFA PMax \u5E7F\u544A\u7CFB\u5217\u5931\u8D25\uFF1A${failure.message}`);
127645
- console.error(` budgetId\uFF1A${failure.budgetId ?? "null"}`);
127646
- console.error(` campaignId\uFF1A${failure.campaignId ?? "null"}`);
127647
- console.error(` assetGroupId\uFF1A${failure.assetGroupId ?? "null"}`);
127648
- if (advice === "resume") {
127649
- console.error(
127650
- " \u7EED\u8DD1\uFF1A\u628A\u975E\u7A7A\u7F16\u53F7\u6309\u540C\u540D\u5199\u56DE\u8FD9\u4EFD JSON\uFF0C\u5176\u4F59\u5185\u5BB9\u4E0D\u8981\u6539\uFF0C\u518D\u6267\u884C\u4E00\u6B21 pmax-create\u3002\u7F16\u53F7\u6309\u9884\u7B97\u3001\u7CFB\u5217\u3001\u7D20\u6750\u7EC4\u5E26\u3002\u540C\u4E00\u6B65\u518D\u5931\u8D25\u5C31\u505C\u3002\n"
127651
- );
127652
- } else if (advice === "stop-same-step") {
127653
- console.error(" \u540C\u4E00\u6B65\u518D\u5931\u8D25\uFF0C\u505C\u6B62\u3002\u4E0D\u8981\u518D\u6267\u884C pmax-create\u3002\n");
127654
- } else {
127655
- console.error(" \u8FD9\u6B21\u8FD8\u6CA1\u6709\u5EFA\u6210\u9884\u7B97\u3001\u7CFB\u5217\u6216\u7D20\u6750\u7EC4\u3002\u4FEE\u6B63\u539F\u56E0\u540E\u7528\u539F JSON \u518D\u63D0\u4EA4\uFF0C\u4E0D\u8981\u586B\u8FD9\u4E09\u4E2A\u7F16\u53F7\u3002\n");
127656
- }
127657
- await emitCliJsonOrSnapshot(opts, {
127658
- section: `ad-pmax-create-${accountId}`,
127659
- commandLabel: "ad pmax-create",
127660
- commandHint: accountId,
127661
- payload: { ok: false, retryCreate: advice === "resume", ...failure },
127662
- idSuffix: accountId,
127663
- summaryExtras: {
127664
- ok: false,
127665
- retryCreate: advice === "resume",
127666
- budgetId: failure.budgetId,
127667
- campaignId: failure.campaignId,
127668
- assetGroupId: failure.assetGroupId
127669
- }
127670
- });
127671
- process.exit(1);
127672
- }
127673
- const raw = err instanceof Error ? err.message : String(err);
127674
- console.error(`
127675
- \u274C \u521B\u5EFA PMax \u5E7F\u544A\u7CFB\u5217\u5931\u8D25\uFF1A${classifyPmaxCreateHttpError(raw)}
127676
- `);
127677
- process.exit(1);
127678
- }
127679
- const campaignId = data["campaignId"] ?? data["campaign_id"];
127680
- const assetGroupId = data["assetGroupId"] ?? data["asset_group_id"];
127681
- const budgetId = data["budgetId"] ?? data["budget_id"];
127682
- const videoResult = await linkPmaxVideoAfterCreate({
127683
- config,
127684
- googleApiUrl,
127685
- accountId,
127686
- configFile: opts.configFile,
127687
- cfg,
127688
- campaignId,
127689
- assetGroupId,
127690
- verbose: opts.verbose,
127691
- logProgress: !opts.jsonOut
127692
- });
127693
- let extensionsResult;
127694
- if (campaignId != null && cfg.campaignExtensions) {
127695
- if (!opts.jsonOut) {
127696
- console.log("\n \u6302\u8F7D Campaign \u9644\u52A0\u8D44\u4EA7\u2026");
127697
- }
127698
- extensionsResult = await attachPmaxCampaignExtensions({
127699
- config,
127700
- googleApiUrl,
127701
- accountId,
127702
- campaignId: String(campaignId),
127703
- extensions: cfg.campaignExtensions,
127704
- verbose: opts.verbose,
127705
- logProgress: !opts.jsonOut
127706
- });
127707
- }
127708
- const payload = {
127709
- ...data,
127710
- _brandGuidelinesEnabled: cfg.brandGuidelinesEnabled !== false,
127711
- _agentBrandHint: cfg.brandGuidelinesEnabled === false ? "\u54C1\u724C\u5728 AssetGroup \u7EA7\uFF1B\u6539\u54C1\u724C\u7528 pmax-assets-update" : "\u54C1\u724C\u5728 Campaign \u7EA7 brandAssets[]\uFF1B\u6539\u54C1\u724C\u7528 pmax-brand-assets-edit\uFF1B\u8FFD\u52A0 AG \u53EF\u7701\u7565 Logo/\u5546\u5BB6\u540D",
127712
- videoLink: {
127713
- ok: Boolean(videoResult.youtubeLink && !videoResult.uploadError && !videoResult.linkError),
127714
- youtubeTarget: videoResult.youtubeTarget,
127715
- assetResourceName: videoResult.youtubeLink?.["assetResourceName"],
127716
- uploadError: videoResult.uploadError,
127717
- linkError: videoResult.linkError,
127718
- skippedReason: videoResult.skippedReason
127719
- },
127720
- campaignExtensions: extensionsResult ?? {
127721
- allOk: true,
127722
- skippedReason: "\u672A\u914D\u7F6E campaignExtensions"
127723
- }
127724
- };
127725
- if (videoResult.uploadError) {
127726
- console.error(`
127727
- \u26A0\uFE0F \u6D3B\u52A8\u5DF2\u521B\u5EFA\uFF0C\u4F46\u672C\u5730\u89C6\u9891\u4E0A\u4F20\u5931\u8D25\uFF1A${videoResult.uploadError}`);
127728
- if (assetGroupId != null) {
127729
- printVideoLinkRecoveryHint(
127730
- accountId,
127731
- assetGroupId,
127732
- campaignId,
127733
- void 0
127734
- );
127735
- }
127736
- console.error(" \u6D3B\u52A8\u5DF2\u7ECF\u521B\u5EFA\u6210\u529F\uFF0C\u4E0D\u8981\u518D\u6267\u884C pmax-create\u3002\n");
127737
- } else if (videoResult.linkError) {
127738
- console.error(`
127739
- \u26A0\uFE0F \u6D3B\u52A8\u5DF2\u521B\u5EFA\uFF0C\u4F46 YouTube \u94FE\u63A5\u5931\u8D25\uFF1A${videoResult.linkError}`);
127740
- if (assetGroupId != null) {
127741
- printVideoLinkRecoveryHint(
127742
- accountId,
127743
- assetGroupId,
127744
- campaignId,
127745
- videoResult.youtubeTarget
127746
- );
127747
- }
127748
- console.error(" \u6D3B\u52A8\u5DF2\u7ECF\u521B\u5EFA\u6210\u529F\uFF0C\u4E0D\u8981\u518D\u6267\u884C pmax-create\u3002\n");
127749
- } else if (videoResult.skippedReason) {
127750
- console.error(`
127751
- \u26A0\uFE0F \u6D3B\u52A8\u5DF2\u521B\u5EFA\uFF0C\u4F46\u89C6\u9891\u672A\u94FE\u63A5\uFF1A${videoResult.skippedReason}
127752
- `);
127753
- }
127754
- if (extensionsResult && !extensionsResult.allOk) {
127755
- console.error("\n\u26A0\uFE0F \u6D3B\u52A8\u5DF2\u521B\u5EFA\uFF0C\u4F46\u90E8\u5206\u9644\u52A0\u8D44\u4EA7\u6302\u8F7D\u5931\u8D25\uFF1A");
127756
- for (const msg of formatPmaxExtensionsAttachErrors(extensionsResult)) {
127757
- console.error(` \u2022 ${msg}`);
127758
- }
127759
- console.error(
127760
- ` \u53EF\u624B\u52A8\u8865\u6302\uFF1Asiluzan-tso ad extension callout|snippet|lead-form -a ${accountId} --campaign-id ${campaignId} \u2026
127761
- \u6D3B\u52A8\u5DF2\u7ECF\u521B\u5EFA\u6210\u529F\uFF0C\u4E0D\u8981\u518D\u6267\u884C pmax-create\u3002
127762
- `
127763
- );
127764
- } else if (extensionsResult?.allOk && extensionsResult.callouts.length + extensionsResult.structuredSnippets.length + extensionsResult.sitelinks.length + (extensionsResult.leadForm ? 1 : 0) + (extensionsResult.whatsapp ? 1 : 0) > 0) {
127765
- if (!opts.jsonOut) {
127766
- console.log("\n\u2705 Campaign \u9644\u52A0\u8D44\u4EA7\u5DF2\u6302\u8F7D");
127767
- }
127768
- }
127769
- const followUpFailed = pmaxCreateFollowUpFailed({
127770
- uploadError: videoResult.uploadError,
127771
- linkError: videoResult.linkError,
127772
- extensionsAllOk: extensionsResult ? extensionsResult.allOk : void 0
127773
- });
127774
- if (followUpFailed) {
127775
- payload["created"] = true;
127776
- payload["retryCreate"] = false;
127777
- }
127778
- if (await emitCliJsonOrSnapshot(opts, {
127779
- section: `ad-pmax-create-${accountId}`,
127780
- commandLabel: "ad pmax-create",
127781
- commandHint: accountId,
127782
- payload,
127783
- idSuffix: accountId,
127784
- summaryExtras: followUpFailed ? { created: true, retryCreate: false } : void 0
127785
- })) {
127786
- return;
127787
- }
127788
- if (videoResult.youtubeTarget && videoResult.youtubeLink) {
127789
- console.log(`
127790
- \u2705 \u5DF2\u94FE\u63A5 YouTube\uFF1A${videoResult.youtubeTarget}`);
127791
- const arn = videoResult.youtubeLink["assetResourceName"];
127792
- if (arn != null) console.log(` assetResourceName\uFF1A${arn}`);
127793
- }
127794
- console.log("\n\u2705 PMax \u5E7F\u544A\u7CFB\u5217\u5DF2\u521B\u5EFA\uFF08\u540C\u6B65\uFF09");
127795
- console.log(` \u6D3B\u52A8\u540D\u79F0\uFF1A${cfg.name}`);
127796
- if (campaignId != null) console.log(` campaignId\uFF1A${campaignId}`);
127797
- if (assetGroupId != null) console.log(` assetGroupId\uFF1A${assetGroupId}`);
127798
- if (budgetId != null) console.log(` budgetId\uFF1A${budgetId}`);
127799
- console.log(
127800
- `
127801
- \u590D\u6838\uFF1Asiluzan-tso ad campaigns -a ${accountId} --json-out # channelTypeV2 \u5E94\u4E3A PERFORMANCE_MAX`
127802
- );
127803
- if (!cfg.videoPath?.trim() && !cfg.youtubeUrlOrId?.trim()) {
127804
- console.log(
127805
- " \u89C6\u9891\uFF1A\u914D\u7F6E videoPath\uFF08\u672C\u5730\uFF09\u6216 youtubeUrlOrId \u53EF\u5728\u521B\u5EFA\u65F6\u81EA\u52A8\u94FE\u63A5\uFF1B\u6216\u521B\u5EFA\u540E ad pmax-youtube-link"
127806
- );
127807
- }
127808
- console.log();
127809
- }
127810
-
127811
- // src/commands/ad/pmax-validate.ts
127812
- import { writeFileSync as writeFileSync3 } from "fs";
127813
- init_cli_json_snapshot();
127814
- async function runAdPmaxValidate(opts) {
127815
- const cfg = loadPmaxCreateConfig(opts.configFile);
127816
- const rawCfg = loadPmaxCreateConfigRaw(opts.configFile) ?? {};
127817
- const deprecatedVideoKeys = detectDeprecatedPmaxVideoKeys(rawCfg);
127818
- const {
127819
- errors: cfgErrors,
127820
- warnings: cfgWarnings,
127821
- lengthViolations: cfgLengthViolations
127822
- } = runPmaxCreateValidation(cfg);
127823
- const { errors: imgErrors, warnings: imgWarnings } = await runPmaxImageValidation(
127824
- opts.configFile,
127825
- cfg
127826
- );
127827
- const { errors: videoErrors, warnings: videoWarnings } = runPmaxVideoValidation(
127828
- opts.configFile,
127829
- cfg
127830
- );
127831
- const { errors: extErrors, warnings: extWarnings } = validatePmaxCampaignExtensions(
127832
- cfg.campaignExtensions,
127833
- {
127834
- skipCampaignExtensions: cfg.skipCampaignExtensions,
127835
- rawConfig: rawCfg
127836
- }
127837
- );
127838
- const errors = [...deprecatedVideoKeys, ...cfgErrors, ...imgErrors, ...videoErrors, ...extErrors];
127839
- const warnings = [...cfgWarnings, ...imgWarnings, ...videoWarnings, ...extWarnings];
127840
- const lengthViolations = cfgLengthViolations;
127841
- if (opts.writeNormalized) {
127842
- const toWrite = stripMetaKeysForExport(cfg);
127843
- writeFileSync3(opts.writeNormalized, `${JSON.stringify(toWrite, null, 2)}
127844
- `, "utf8");
127845
- }
127846
- const payload = {
127847
- ok: errors.length === 0,
127848
- configFile: opts.configFile,
127849
- account: cfg.account?.toString().trim() || void 0,
127850
- errors,
127851
- warnings,
127852
- lengthViolations,
127853
- agentHint: lengthViolations.length > 0 ? lengthViolationAgentHint("pmax-validate") : void 0
127854
- };
127855
- const accountSuffix = payload.account;
127856
- if (await emitCliJsonOrSnapshot(opts, {
127857
- section: "ad-pmax-validate",
127858
- commandLabel: "ad pmax-validate",
127859
- commandHint: opts.configFile,
127860
- payload,
127861
- idSuffix: accountSuffix
127862
- })) {
127863
- if (!payload.ok) process.exit(1);
127864
- return;
127865
- }
127866
- if (warnings.length > 0) {
127867
- console.warn("\n\u26A0\uFE0F PMax \u914D\u7F6E\u8B66\u544A\uFF1A");
127868
- for (const w of warnings) console.warn(` \u2022 ${w}`);
127869
- }
127870
- if (errors.length > 0) {
127871
- console.error("\n\u274C PMax \u914D\u7F6E\u6821\u9A8C\u5931\u8D25\uFF1A");
127872
- for (const e of errors) console.error(` \u2022 ${e}`);
127873
- const lengthReport = formatLengthViolationsReport(lengthViolations, {
127874
- revalidateCommand: "pmax-validate"
127875
- });
127876
- if (lengthReport) console.error(lengthReport);
127877
- console.error();
127878
- process.exit(1);
127879
- }
127880
- console.log("\n\u2705 PMax \u914D\u7F6E\u6821\u9A8C\u901A\u8FC7");
127881
- if (opts.writeNormalized) {
127882
- console.log(` \u5DF2\u5199\u5165\uFF1A${opts.writeNormalized}`);
127883
- }
127884
- console.log();
127885
- }
127886
-
127887
- // src/commands/ad/pmax-mgmt.ts
127888
- import { basename as basename7, isAbsolute as isAbsolute6 } from "path";
127889
-
127890
128127
  // src/commands/ad/pmax-brand-guidelines.ts
127891
128128
  var PMAX_CAMPAIGN_BRAND_FIELD_TYPES = /* @__PURE__ */ new Set(["BUSINESS_NAME", "LOGO", "LANDSCAPE_LOGO"]);
127892
128129
  function isPmaxBrandGuidelinesActive(detail) {
@@ -127918,6 +128155,34 @@ async function fetchPmaxCampaignDetail(config, googleApiUrl, accountId, campaign
127918
128155
  }
127919
128156
  return { data: raw };
127920
128157
  }
128158
+ function printPmaxWriteReceipt(expected, detail, liveCountryIds) {
128159
+ const lines = [];
128160
+ if (expected.budgetYuan != null) {
128161
+ const raw = detail?.["budget"] ?? detail?.["Budget"];
128162
+ const actual = typeof raw === "number" && Number.isFinite(raw) ? raw / 100 : void 0;
128163
+ lines.push(
128164
+ receiptLine(
128165
+ "\u65E5\u9884\u7B97",
128166
+ yuanLabel(expected.budgetYuan),
128167
+ actual == null ? void 0 : yuanLabel(actual)
128168
+ )
128169
+ );
128170
+ }
128171
+ if (expected.status) {
128172
+ lines.push(receiptLine("\u72B6\u6001", expected.status, detail?.["statusV2"] ?? detail?.["status"]));
128173
+ }
128174
+ if (expected.finalUrl) {
128175
+ const urls = detail?.["finalUrls"] ?? detail?.["finalurls"];
128176
+ const actual = Array.isArray(urls) ? urls[0] : detail?.["finalUrl"];
128177
+ lines.push(receiptLine("\u843D\u5730\u9875", expected.finalUrl, actual));
128178
+ }
128179
+ if (expected.countryIds && expected.countryIds.length > 0) {
128180
+ const expectedIds = [...expected.countryIds].map(String).sort().join(",");
128181
+ const actualIds = liveCountryIds ? [...liveCountryIds].map(String).sort().join(",") : void 0;
128182
+ lines.push(receiptLine("\u6295\u653E\u56FD\u5BB6", expectedIds, actualIds));
128183
+ }
128184
+ printWriteReceipt(detail ? judgeReceipt(lines) : "unknown", lines);
128185
+ }
127921
128186
  function hasBrandImageSource(cfg, slot) {
127922
128187
  if (slot === "logo") {
127923
128188
  return Boolean(
@@ -128054,7 +128319,387 @@ async function buildEnableBrandGuidelinesApiBody(configFile, cfg, accountId, con
128054
128319
  return body;
128055
128320
  }
128056
128321
 
128322
+ // src/commands/ad/pmax-create.ts
128323
+ function printVideoLinkRecoveryHint(accountId, assetGroupId, campaignId, youtubeTarget) {
128324
+ const cid = campaignId != null ? ` --campaign-id ${campaignId}` : "";
128325
+ const yt = youtubeTarget ? ` --youtube "${youtubeTarget}"` : ` --video-path "<path>"`;
128326
+ console.error(
128327
+ ` \u53EF\u624B\u52A8\uFF1Asiluzan-tso ad pmax-youtube-link -a ${accountId} --asset-group-id ${assetGroupId}${cid}${yt}
128328
+ \u6D3B\u52A8\u5DF2\u7ECF\u521B\u5EFA\u6210\u529F\uFF0C\u4E0D\u8981\u518D\u6267\u884C pmax-create\u3002
128329
+ `
128330
+ );
128331
+ }
128332
+ async function runAdPmaxCreate(opts) {
128333
+ const cfg = loadPmaxCreateConfig(opts.configFile);
128334
+ const rawCfg = loadPmaxCreateConfigRaw(opts.configFile) ?? {};
128335
+ const deprecatedVideoKeys = detectDeprecatedPmaxVideoKeys(rawCfg);
128336
+ const {
128337
+ errors: cfgErrors,
128338
+ warnings: cfgWarnings,
128339
+ lengthViolations: cfgLengthViolations
128340
+ } = runPmaxCreateValidation(cfg);
128341
+ const { errors: imgErrors, warnings: imgWarnings } = await runPmaxImageValidation(
128342
+ opts.configFile,
128343
+ cfg
128344
+ );
128345
+ const { errors: videoErrors, warnings: videoWarnings } = runPmaxVideoValidation(
128346
+ opts.configFile,
128347
+ cfg
128348
+ );
128349
+ const { errors: extErrors, warnings: extWarnings } = validatePmaxCampaignExtensions(
128350
+ cfg.campaignExtensions,
128351
+ {
128352
+ skipCampaignExtensions: cfg.skipCampaignExtensions,
128353
+ rawConfig: rawCfg
128354
+ }
128355
+ );
128356
+ const errors = [...deprecatedVideoKeys, ...cfgErrors, ...imgErrors, ...videoErrors, ...extErrors];
128357
+ const warnings = [...cfgWarnings, ...imgWarnings, ...videoWarnings, ...extWarnings];
128358
+ if (warnings.length > 0) {
128359
+ console.warn("\n\u26A0\uFE0F PMax \u914D\u7F6E\u8B66\u544A\uFF08\u4E0D\u963B\u65AD\u63D0\u4EA4\uFF09\uFF1A");
128360
+ for (const w of warnings) console.warn(` \u2022 ${w}`);
128361
+ }
128362
+ if (errors.length > 0) {
128363
+ console.error("\n\u274C PMax \u914D\u7F6E\u6821\u9A8C\u5931\u8D25\uFF1A");
128364
+ for (const e of errors) console.error(` \u2022 ${e}`);
128365
+ const lengthReport = formatLengthViolationsReport(cfgLengthViolations, {
128366
+ revalidateCommand: "pmax-validate"
128367
+ });
128368
+ if (lengthReport) console.error(lengthReport);
128369
+ console.error();
128370
+ process.exit(1);
128371
+ }
128372
+ const config = await ensureDataPermission(loadConfig(opts.token));
128373
+ const googleApiUrl = requireGoogleApi(config);
128374
+ const accountId = resolveAdAccountId(cfg.account.toString(), "account");
128375
+ cfg.account = accountId;
128376
+ let imageSlots;
128377
+ try {
128378
+ imageSlots = await resolvePmaxImageSlots(
128379
+ opts.configFile,
128380
+ cfg,
128381
+ accountId,
128382
+ config,
128383
+ googleApiUrl,
128384
+ { verbose: opts.verbose, logUploads: !opts.jsonOut }
128385
+ );
128386
+ } catch (err) {
128387
+ console.error(`
128388
+ \u274C \u56FE\u7247\u4E0A\u4F20/\u89E3\u6790\u5931\u8D25\uFF1A${err instanceof Error ? err.message : String(err)}
128389
+ `);
128390
+ process.exit(1);
128391
+ }
128392
+ let body;
128393
+ try {
128394
+ body = buildPmaxCreateApiBody(cfg, imageSlots);
128395
+ } catch (err) {
128396
+ console.error(`
128397
+ \u274C \u6784\u5EFA\u8BF7\u6C42\u4F53\u5931\u8D25\uFF1A${err instanceof Error ? err.message : String(err)}
128398
+ `);
128399
+ process.exit(1);
128400
+ }
128401
+ const url = buildPmaxCreateUrl(googleApiUrl, accountId);
128402
+ let data;
128403
+ try {
128404
+ data = await apiFetch2(
128405
+ url,
128406
+ config,
128407
+ { method: "POST", body: JSON.stringify(body) },
128408
+ opts.verbose
128409
+ );
128410
+ } catch (err) {
128411
+ const failure = parsePmaxCreateFailureBody(readHttpRawBody(err));
128412
+ if (failure) {
128413
+ const advice = pmaxCreateRetryAdvice(cfg, failure);
128414
+ console.error(`
128415
+ \u274C \u521B\u5EFA PMax \u5E7F\u544A\u7CFB\u5217\u5931\u8D25\uFF1A${failure.message}`);
128416
+ console.error(` budgetId\uFF1A${failure.budgetId ?? "null"}`);
128417
+ console.error(` campaignId\uFF1A${failure.campaignId ?? "null"}`);
128418
+ console.error(` assetGroupId\uFF1A${failure.assetGroupId ?? "null"}`);
128419
+ if (advice === "resume") {
128420
+ console.error(
128421
+ " \u7EED\u8DD1\uFF1A\u628A\u975E\u7A7A\u7F16\u53F7\u6309\u540C\u540D\u5199\u56DE\u8FD9\u4EFD JSON\uFF0C\u5176\u4F59\u5185\u5BB9\u4E0D\u8981\u6539\uFF0C\u518D\u6267\u884C\u4E00\u6B21 pmax-create\u3002\u7F16\u53F7\u6309\u9884\u7B97\u3001\u7CFB\u5217\u3001\u7D20\u6750\u7EC4\u5E26\u3002\u540C\u4E00\u6B65\u518D\u5931\u8D25\u5C31\u505C\u3002\n"
128422
+ );
128423
+ } else if (advice === "stop-same-step") {
128424
+ console.error(" \u540C\u4E00\u6B65\u518D\u5931\u8D25\uFF0C\u505C\u6B62\u3002\u4E0D\u8981\u518D\u6267\u884C pmax-create\u3002\n");
128425
+ } else {
128426
+ console.error(" \u8FD9\u6B21\u8FD8\u6CA1\u6709\u5EFA\u6210\u9884\u7B97\u3001\u7CFB\u5217\u6216\u7D20\u6750\u7EC4\u3002\u4FEE\u6B63\u539F\u56E0\u540E\u7528\u539F JSON \u518D\u63D0\u4EA4\uFF0C\u4E0D\u8981\u586B\u8FD9\u4E09\u4E2A\u7F16\u53F7\u3002\n");
128427
+ }
128428
+ await emitCliJsonOrSnapshot(opts, {
128429
+ section: `ad-pmax-create-${accountId}`,
128430
+ commandLabel: "ad pmax-create",
128431
+ commandHint: accountId,
128432
+ payload: { ok: false, retryCreate: advice === "resume", ...failure },
128433
+ idSuffix: accountId,
128434
+ summaryExtras: {
128435
+ ok: false,
128436
+ retryCreate: advice === "resume",
128437
+ budgetId: failure.budgetId,
128438
+ campaignId: failure.campaignId,
128439
+ assetGroupId: failure.assetGroupId
128440
+ }
128441
+ });
128442
+ process.exit(1);
128443
+ }
128444
+ const raw = err instanceof Error ? err.message : String(err);
128445
+ console.error(`
128446
+ \u274C \u521B\u5EFA PMax \u5E7F\u544A\u7CFB\u5217\u5931\u8D25\uFF1A${classifyPmaxCreateHttpError(raw)}
128447
+ `);
128448
+ process.exit(1);
128449
+ }
128450
+ const campaignId = data["campaignId"] ?? data["campaign_id"];
128451
+ const assetGroupId = data["assetGroupId"] ?? data["asset_group_id"];
128452
+ const budgetId = data["budgetId"] ?? data["budget_id"];
128453
+ const videoResult = await linkPmaxVideoAfterCreate({
128454
+ config,
128455
+ googleApiUrl,
128456
+ accountId,
128457
+ configFile: opts.configFile,
128458
+ cfg,
128459
+ campaignId,
128460
+ assetGroupId,
128461
+ verbose: opts.verbose,
128462
+ logProgress: !opts.jsonOut
128463
+ });
128464
+ let extensionsResult;
128465
+ if (campaignId != null && cfg.campaignExtensions) {
128466
+ if (!opts.jsonOut) {
128467
+ console.log("\n \u6302\u8F7D Campaign \u9644\u52A0\u8D44\u4EA7\u2026");
128468
+ }
128469
+ extensionsResult = await attachPmaxCampaignExtensions({
128470
+ config,
128471
+ googleApiUrl,
128472
+ accountId,
128473
+ campaignId: String(campaignId),
128474
+ extensions: cfg.campaignExtensions,
128475
+ verbose: opts.verbose,
128476
+ logProgress: !opts.jsonOut
128477
+ });
128478
+ }
128479
+ const payload = {
128480
+ ...data,
128481
+ _brandGuidelinesEnabled: cfg.brandGuidelinesEnabled !== false,
128482
+ _agentBrandHint: cfg.brandGuidelinesEnabled === false ? "\u54C1\u724C\u5728 AssetGroup \u7EA7\uFF1B\u6539\u54C1\u724C\u7528 pmax-assets-update" : "\u54C1\u724C\u5728 Campaign \u7EA7 brandAssets[]\uFF1B\u6539\u54C1\u724C\u7528 pmax-brand-assets-edit\uFF1B\u8FFD\u52A0 AG \u53EF\u7701\u7565 Logo/\u5546\u5BB6\u540D",
128483
+ videoLink: {
128484
+ ok: Boolean(videoResult.youtubeLink && !videoResult.uploadError && !videoResult.linkError),
128485
+ youtubeTarget: videoResult.youtubeTarget,
128486
+ assetResourceName: videoResult.youtubeLink?.["assetResourceName"],
128487
+ uploadError: videoResult.uploadError,
128488
+ linkError: videoResult.linkError,
128489
+ skippedReason: videoResult.skippedReason
128490
+ },
128491
+ campaignExtensions: extensionsResult ?? {
128492
+ allOk: true,
128493
+ skippedReason: "\u672A\u914D\u7F6E campaignExtensions"
128494
+ }
128495
+ };
128496
+ if (videoResult.uploadError) {
128497
+ console.error(`
128498
+ \u26A0\uFE0F \u6D3B\u52A8\u5DF2\u521B\u5EFA\uFF0C\u4F46\u672C\u5730\u89C6\u9891\u4E0A\u4F20\u5931\u8D25\uFF1A${videoResult.uploadError}`);
128499
+ if (assetGroupId != null) {
128500
+ printVideoLinkRecoveryHint(
128501
+ accountId,
128502
+ assetGroupId,
128503
+ campaignId,
128504
+ void 0
128505
+ );
128506
+ }
128507
+ console.error(" \u6D3B\u52A8\u5DF2\u7ECF\u521B\u5EFA\u6210\u529F\uFF0C\u4E0D\u8981\u518D\u6267\u884C pmax-create\u3002\n");
128508
+ } else if (videoResult.linkError) {
128509
+ console.error(`
128510
+ \u26A0\uFE0F \u6D3B\u52A8\u5DF2\u521B\u5EFA\uFF0C\u4F46 YouTube \u94FE\u63A5\u5931\u8D25\uFF1A${videoResult.linkError}`);
128511
+ if (assetGroupId != null) {
128512
+ printVideoLinkRecoveryHint(
128513
+ accountId,
128514
+ assetGroupId,
128515
+ campaignId,
128516
+ videoResult.youtubeTarget
128517
+ );
128518
+ }
128519
+ console.error(" \u6D3B\u52A8\u5DF2\u7ECF\u521B\u5EFA\u6210\u529F\uFF0C\u4E0D\u8981\u518D\u6267\u884C pmax-create\u3002\n");
128520
+ } else if (videoResult.skippedReason) {
128521
+ console.error(`
128522
+ \u26A0\uFE0F \u6D3B\u52A8\u5DF2\u521B\u5EFA\uFF0C\u4F46\u89C6\u9891\u672A\u94FE\u63A5\uFF1A${videoResult.skippedReason}
128523
+ `);
128524
+ }
128525
+ if (extensionsResult && !extensionsResult.allOk) {
128526
+ console.error("\n\u26A0\uFE0F \u6D3B\u52A8\u5DF2\u521B\u5EFA\uFF0C\u4F46\u90E8\u5206\u9644\u52A0\u8D44\u4EA7\u6302\u8F7D\u5931\u8D25\uFF1A");
128527
+ for (const msg of formatPmaxExtensionsAttachErrors(extensionsResult)) {
128528
+ console.error(` \u2022 ${msg}`);
128529
+ }
128530
+ console.error(
128531
+ ` \u53EF\u624B\u52A8\u8865\u6302\uFF1Asiluzan-tso ad extension callout|snippet|lead-form -a ${accountId} --campaign-id ${campaignId} \u2026
128532
+ \u6D3B\u52A8\u5DF2\u7ECF\u521B\u5EFA\u6210\u529F\uFF0C\u4E0D\u8981\u518D\u6267\u884C pmax-create\u3002
128533
+ `
128534
+ );
128535
+ } else if (extensionsResult?.allOk && extensionsResult.callouts.length + extensionsResult.structuredSnippets.length + extensionsResult.sitelinks.length + (extensionsResult.leadForm ? 1 : 0) + (extensionsResult.whatsapp ? 1 : 0) > 0) {
128536
+ if (!opts.jsonOut) {
128537
+ console.log("\n\u2705 Campaign \u9644\u52A0\u8D44\u4EA7\u5DF2\u6302\u8F7D");
128538
+ }
128539
+ }
128540
+ const followUpFailed = pmaxCreateFollowUpFailed({
128541
+ uploadError: videoResult.uploadError,
128542
+ linkError: videoResult.linkError,
128543
+ extensionsAllOk: extensionsResult ? extensionsResult.allOk : void 0
128544
+ });
128545
+ if (followUpFailed) {
128546
+ payload["created"] = true;
128547
+ payload["retryCreate"] = false;
128548
+ }
128549
+ if (campaignId != null) {
128550
+ let detail;
128551
+ try {
128552
+ detail = await fetchPmaxCampaignDetail(
128553
+ config,
128554
+ googleApiUrl,
128555
+ accountId,
128556
+ String(campaignId),
128557
+ opts.verbose
128558
+ );
128559
+ } catch {
128560
+ detail = void 0;
128561
+ }
128562
+ let liveCountryIds;
128563
+ const plannedCountries = (cfg.targetedLocations ?? []).map((loc) => String(loc.id));
128564
+ if (plannedCountries.length > 0) {
128565
+ try {
128566
+ const params = new URLSearchParams({
128567
+ startDate: toGoogleDate(void 0, -30),
128568
+ endDate: toGoogleDate(void 0, 0),
128569
+ newest: "true"
128570
+ });
128571
+ const listed = await apiFetch2(
128572
+ `${googleApiUrl}/campaignmanagement/v2/targetedlocations/${accountId}?${params}`,
128573
+ config,
128574
+ {},
128575
+ opts.verbose
128576
+ );
128577
+ liveCountryIds = (listed.data ?? []).filter((row) => String(row["campaignId"] ?? row["CampaignId"] ?? "") === String(campaignId)).map((row) => String(row["id"] ?? row["locationId"] ?? row["Id"] ?? "")).filter(Boolean);
128578
+ } catch {
128579
+ liveCountryIds = void 0;
128580
+ }
128581
+ }
128582
+ printPmaxWriteReceipt(
128583
+ {
128584
+ budgetYuan: cfg.budget,
128585
+ finalUrl: cfg.finalUrls?.[0],
128586
+ countryIds: plannedCountries
128587
+ },
128588
+ detail,
128589
+ liveCountryIds
128590
+ );
128591
+ }
128592
+ if (await emitCliJsonOrSnapshot(opts, {
128593
+ section: `ad-pmax-create-${accountId}`,
128594
+ commandLabel: "ad pmax-create",
128595
+ commandHint: accountId,
128596
+ payload,
128597
+ idSuffix: accountId,
128598
+ summaryExtras: followUpFailed ? { created: true, retryCreate: false } : void 0
128599
+ })) {
128600
+ return;
128601
+ }
128602
+ if (videoResult.youtubeTarget && videoResult.youtubeLink) {
128603
+ console.log(`
128604
+ \u2705 \u5DF2\u94FE\u63A5 YouTube\uFF1A${videoResult.youtubeTarget}`);
128605
+ const arn = videoResult.youtubeLink["assetResourceName"];
128606
+ if (arn != null) console.log(` assetResourceName\uFF1A${arn}`);
128607
+ }
128608
+ console.log("\n\u2705 PMax \u5E7F\u544A\u7CFB\u5217\u5DF2\u521B\u5EFA\uFF08\u540C\u6B65\uFF09");
128609
+ console.log(` \u6D3B\u52A8\u540D\u79F0\uFF1A${cfg.name}`);
128610
+ if (campaignId != null) console.log(` campaignId\uFF1A${campaignId}`);
128611
+ if (assetGroupId != null) console.log(` assetGroupId\uFF1A${assetGroupId}`);
128612
+ if (budgetId != null) console.log(` budgetId\uFF1A${budgetId}`);
128613
+ console.log(
128614
+ `
128615
+ \u590D\u6838\uFF1Asiluzan-tso ad campaigns -a ${accountId} --json-out # channelTypeV2 \u5E94\u4E3A PERFORMANCE_MAX`
128616
+ );
128617
+ if (!cfg.videoPath?.trim() && !cfg.youtubeUrlOrId?.trim()) {
128618
+ console.log(
128619
+ " \u89C6\u9891\uFF1A\u914D\u7F6E videoPath\uFF08\u672C\u5730\uFF09\u6216 youtubeUrlOrId \u53EF\u5728\u521B\u5EFA\u65F6\u81EA\u52A8\u94FE\u63A5\uFF1B\u6216\u521B\u5EFA\u540E ad pmax-youtube-link"
128620
+ );
128621
+ }
128622
+ console.log();
128623
+ }
128624
+
128625
+ // src/commands/ad/pmax-validate.ts
128626
+ import { writeFileSync as writeFileSync3 } from "fs";
128627
+ init_cli_json_snapshot();
128628
+ async function runAdPmaxValidate(opts) {
128629
+ const cfg = loadPmaxCreateConfig(opts.configFile);
128630
+ const rawCfg = loadPmaxCreateConfigRaw(opts.configFile) ?? {};
128631
+ const deprecatedVideoKeys = detectDeprecatedPmaxVideoKeys(rawCfg);
128632
+ const {
128633
+ errors: cfgErrors,
128634
+ warnings: cfgWarnings,
128635
+ lengthViolations: cfgLengthViolations
128636
+ } = runPmaxCreateValidation(cfg);
128637
+ const { errors: imgErrors, warnings: imgWarnings } = await runPmaxImageValidation(
128638
+ opts.configFile,
128639
+ cfg
128640
+ );
128641
+ const { errors: videoErrors, warnings: videoWarnings } = runPmaxVideoValidation(
128642
+ opts.configFile,
128643
+ cfg
128644
+ );
128645
+ const { errors: extErrors, warnings: extWarnings } = validatePmaxCampaignExtensions(
128646
+ cfg.campaignExtensions,
128647
+ {
128648
+ skipCampaignExtensions: cfg.skipCampaignExtensions,
128649
+ rawConfig: rawCfg
128650
+ }
128651
+ );
128652
+ const errors = [...deprecatedVideoKeys, ...cfgErrors, ...imgErrors, ...videoErrors, ...extErrors];
128653
+ const warnings = [...cfgWarnings, ...imgWarnings, ...videoWarnings, ...extWarnings];
128654
+ const lengthViolations = cfgLengthViolations;
128655
+ if (opts.writeNormalized) {
128656
+ const toWrite = stripMetaKeysForExport(cfg);
128657
+ writeFileSync3(opts.writeNormalized, `${JSON.stringify(toWrite, null, 2)}
128658
+ `, "utf8");
128659
+ }
128660
+ const payload = {
128661
+ ok: errors.length === 0,
128662
+ configFile: opts.configFile,
128663
+ account: cfg.account?.toString().trim() || void 0,
128664
+ errors,
128665
+ warnings,
128666
+ lengthViolations,
128667
+ agentHint: lengthViolations.length > 0 ? lengthViolationAgentHint("pmax-validate") : void 0
128668
+ };
128669
+ const accountSuffix = payload.account;
128670
+ if (await emitCliJsonOrSnapshot(opts, {
128671
+ section: "ad-pmax-validate",
128672
+ commandLabel: "ad pmax-validate",
128673
+ commandHint: opts.configFile,
128674
+ payload,
128675
+ idSuffix: accountSuffix
128676
+ })) {
128677
+ if (!payload.ok) process.exit(1);
128678
+ return;
128679
+ }
128680
+ if (warnings.length > 0) {
128681
+ console.warn("\n\u26A0\uFE0F PMax \u914D\u7F6E\u8B66\u544A\uFF1A");
128682
+ for (const w of warnings) console.warn(` \u2022 ${w}`);
128683
+ }
128684
+ if (errors.length > 0) {
128685
+ console.error("\n\u274C PMax \u914D\u7F6E\u6821\u9A8C\u5931\u8D25\uFF1A");
128686
+ for (const e of errors) console.error(` \u2022 ${e}`);
128687
+ const lengthReport = formatLengthViolationsReport(lengthViolations, {
128688
+ revalidateCommand: "pmax-validate"
128689
+ });
128690
+ if (lengthReport) console.error(lengthReport);
128691
+ console.error();
128692
+ process.exit(1);
128693
+ }
128694
+ console.log("\n\u2705 PMax \u914D\u7F6E\u6821\u9A8C\u901A\u8FC7");
128695
+ if (opts.writeNormalized) {
128696
+ console.log(` \u5DF2\u5199\u5165\uFF1A${opts.writeNormalized}`);
128697
+ }
128698
+ console.log();
128699
+ }
128700
+
128057
128701
  // src/commands/ad/pmax-mgmt.ts
128702
+ import { basename as basename7, isAbsolute as isAbsolute6 } from "path";
128058
128703
  init_shared();
128059
128704
  function buildReportQuery(opts) {
128060
128705
  const params = new URLSearchParams();
@@ -128229,6 +128874,22 @@ async function runAdPmaxEdit(opts) {
128229
128874
  );
128230
128875
  process.exit(1);
128231
128876
  }
128877
+ let detail;
128878
+ try {
128879
+ detail = await fetchPmaxCampaignDetail(config, googleApiUrl, accountId, campaignId, opts.verbose);
128880
+ } catch {
128881
+ detail = void 0;
128882
+ }
128883
+ const budgetCents = body["budget"];
128884
+ const finalUrls = body["finalUrls"];
128885
+ printPmaxWriteReceipt(
128886
+ {
128887
+ budgetYuan: typeof budgetCents === "number" ? budgetCents / 100 : void 0,
128888
+ status: body["statusV2"] != null ? String(body["statusV2"]) : void 0,
128889
+ finalUrl: Array.isArray(finalUrls) ? String(finalUrls[0] ?? "") : void 0
128890
+ },
128891
+ detail
128892
+ );
128232
128893
  if (await emitPmaxResult(
128233
128894
  { ...opts, account: accountId },
128234
128895
  `ad-pmax-edit-${accountId}`,
@@ -129478,6 +130139,35 @@ function budgetYuan(item) {
129478
130139
  const yuan = toDisplayMoney(typeof raw === "number" ? raw : Number(raw));
129479
130140
  return yuan == null ? "" : String(yuan);
129480
130141
  }
130142
+ async function printSharedBudgetReceipt(opts, expected) {
130143
+ try {
130144
+ const listed = await listBudgets(opts);
130145
+ const item = expected.id ? listed.items.find((row) => field5(row, "id", "Id") === expected.id) : listed.items.find((row) => field5(row, "name", "Name") === (expected.name ?? ""));
130146
+ if (expected.gone) {
130147
+ printWriteReceipt(item ? "partial" : "verified", [
130148
+ receiptLine("\u5171\u4EAB\u9884\u7B97", "\u5DF2\u5220\u9664", item ? "\u4ECD\u5728" : "\u5DF2\u5220\u9664")
130149
+ ]);
130150
+ return;
130151
+ }
130152
+ const lines = [];
130153
+ if (expected.name) {
130154
+ lines.push(receiptLine("\u540D\u79F0", expected.name, item ? field5(item, "name", "Name") : void 0));
130155
+ }
130156
+ if (expected.amountYuan != null) {
130157
+ const read = item ? Number(budgetYuan(item)) : void 0;
130158
+ lines.push(
130159
+ receiptLine(
130160
+ "\u65E5\u9884\u7B97",
130161
+ yuanLabel(expected.amountYuan),
130162
+ read != null && Number.isFinite(read) ? yuanLabel(read) : void 0
130163
+ )
130164
+ );
130165
+ }
130166
+ printWriteReceipt(item ? judgeReceipt(lines) : "unknown", lines);
130167
+ } catch {
130168
+ printWriteReceipt("unknown", [receiptLine("\u5171\u4EAB\u9884\u7B97", expected.gone ? "\u5DF2\u5220\u9664" : "\u5DF2\u5199\u5165", void 0)]);
130169
+ }
130170
+ }
129481
130171
  async function runAdSharedBudgetList(opts) {
129482
130172
  let items3;
129483
130173
  let account = opts.account;
@@ -129533,6 +130223,7 @@ async function runAdSharedBudgetCreate(opts) {
129533
130223
  } catch (err) {
129534
130224
  fail3(err, "\u521B\u5EFA\u5171\u4EAB\u9884\u7B97\u5931\u8D25");
129535
130225
  }
130226
+ await printSharedBudgetReceipt(opts, { name: name2, amountYuan: opts.amount });
129536
130227
  console.log(`
129537
130228
  \u2705 \u5DF2\u521B\u5EFA\u5171\u4EAB\u9884\u7B97\u300C${name2}\u300D\uFF0C\u65E5\u9884\u7B97 ${opts.amount}\u3002\u628A\u7CFB\u5217\u6302\u5230\u5B83\u4E0A\u9762\u9700\u8981\u7CFB\u5217\u7F16\u8F91\u91CC\u7684\u9884\u7B97 id\uFF0C\u672C\u547D\u4EE4\u4E0D\u6539\u5DF2\u6709\u7CFB\u5217\u3002
129538
130229
  `);
@@ -129573,29 +130264,15 @@ async function runAdSharedBudgetUpdate(opts) {
129573
130264
  } catch (err) {
129574
130265
  fail3(err, "\u4FEE\u6539\u5171\u4EAB\u9884\u7B97\u5931\u8D25");
129575
130266
  }
130267
+ await printSharedBudgetReceipt(opts, {
130268
+ id: budgetId,
130269
+ name: name2,
130270
+ amountYuan: amountCents / 100
130271
+ });
129576
130272
  console.log(`
129577
130273
  \u2705 \u5DF2\u4FEE\u6539\u5171\u4EAB\u9884\u7B97 ${budgetId}\u300C${name2}\u300D\u3002\u540C\u4E00\u9884\u7B97\u4E0B\u7684\u7CFB\u5217\u4F1A\u4E00\u8D77\u53D8\u3002
129578
130274
  `);
129579
130275
  }
129580
- function sharedBudgetAttachUrl(base2, account, campaignId, budgetId) {
129581
- return `${base2}/campaignmanagement/campaign/${account}/${campaignId}/shared-budget/${budgetId}`;
129582
- }
129583
- async function runAdSharedBudgetAttach(opts) {
129584
- const campaignId = (opts.campaignId ?? "").trim();
129585
- const budgetId = (opts.budgetId ?? "").trim();
129586
- if (!/^\d+$/.test(campaignId)) fail3(new Error("--campaign-id \u987B\u4E3A\u6570\u5B57"), "\u53C2\u6570");
129587
- if (!/^\d+$/.test(budgetId)) fail3(new Error("--budget-id \u987B\u4E3A\u6570\u5B57"), "\u53C2\u6570");
129588
- const { config, base: base2, account } = accountBase3(opts);
129589
- const url = sharedBudgetAttachUrl(base2, account, campaignId, budgetId);
129590
- try {
129591
- await apiFetch2(url, config, { method: "POST" }, opts.verbose);
129592
- } catch (err) {
129593
- fail3(err, "\u628A\u7CFB\u5217\u6302\u5230\u5171\u4EAB\u9884\u7B97\u5931\u8D25");
129594
- }
129595
- console.log(`
129596
- \u2705 \u7CFB\u5217 ${campaignId} \u5DF2\u6539\u6302\u5230\u9884\u7B97 ${budgetId}\u3002\u91D1\u989D\u6CA1\u6709\u6539\u3002Demand Gen \u4F1A\u88AB\u62D2\u7EDD\u3002
129597
- `);
129598
- }
129599
130276
  async function runAdSharedBudgetDelete(opts) {
129600
130277
  const budgetId = (opts.budgetId ?? "").trim();
129601
130278
  if (!/^\d+$/.test(budgetId)) fail3(new Error("--budget-id \u987B\u4E3A\u6570\u5B57"), "\u53C2\u6570");
@@ -129607,6 +130284,7 @@ async function runAdSharedBudgetDelete(opts) {
129607
130284
  } catch (err) {
129608
130285
  fail3(err, "\u5220\u9664\u5171\u4EAB\u9884\u7B97\u5931\u8D25");
129609
130286
  }
130287
+ await printSharedBudgetReceipt(opts, { id: budgetId, gone: true });
129610
130288
  console.log(`
129611
130289
  \u2705 \u5DF2\u5220\u9664\u5171\u4EAB\u9884\u7B97 ${budgetId}\u3002\u4ECD\u88AB\u7CFB\u5217\u4F7F\u7528\u65F6 Google \u4F1A\u62D2\u7EDD\uFF0C\u8FD9\u4E0D\u662F CLI \u91CD\u8BD5\u80FD\u89E3\u51B3\u7684\u3002
129612
130290
  `);
@@ -129706,6 +130384,9 @@ async function runAdScheduleReplace(opts) {
129706
130384
  );
129707
130385
  }
129708
130386
 
130387
+ // src/commands/ad/demand-gen.ts
130388
+ init_shared();
130389
+
129709
130390
  // src/commands/ad/demand-gen-body.ts
129710
130391
  init_shared();
129711
130392
  var WRITE_CENT_KEYS = ["budget", "targetCpa_BidingAmount", "currencyMinimumBudget"];
@@ -129941,7 +130622,6 @@ function demandGenChannelReportUrl(googleApiUrl, accountId, campaignId, startDat
129941
130622
  }
129942
130623
 
129943
130624
  // src/commands/ad/demand-gen.ts
129944
- init_shared();
129945
130625
  var MONEY_HINT = "budget / targetCpa_BidingAmount / minimumDailyBudget \u662F\u5206\uFF08500 = 5 \u5143\uFF09\u3002\u770B\u65C1\u8FB9\u7684 *Yuan\u3002\u5199\u5165 --budget / JSON \u586B\u5143\uFF1B\u82E5\u540C\u65F6\u6709 *Yuan\uFF0C\u4EE5 Yuan \u4E3A\u51C6\u3002targetRoas \u662F\u6BD4\u7387\u3002\u62A5\u8868 spend \u5DF2\u662F\u8D26\u6237\u5E01\u79CD\uFF0C\u4E0D\u8981\u62FF\u53BB\u5F53\u9884\u7B97\u3002";
129946
130626
  function fail4(message) {
129947
130627
  console.error(`
@@ -129949,6 +130629,73 @@ function fail4(message) {
129949
130629
  `);
129950
130630
  process.exit(1);
129951
130631
  }
130632
+ async function readLocationIds(config, googleApiUrl, accountId, campaignId, verbose) {
130633
+ try {
130634
+ const params = new URLSearchParams({
130635
+ startDate: toGoogleDate(void 0, -30),
130636
+ endDate: toGoogleDate(void 0, 0),
130637
+ newest: "true"
130638
+ });
130639
+ const listed = await pmaxApiFetch(
130640
+ `${googleApiUrl}/campaignmanagement/v2/targetedlocations/${accountId}?${params}`,
130641
+ config,
130642
+ {},
130643
+ verbose
130644
+ );
130645
+ const rows = listed && typeof listed === "object" && Array.isArray(listed.data) ? listed.data : [];
130646
+ return rows.filter((row) => String(row["campaignId"] ?? "") === campaignId).map((row) => String(row["id"] ?? row["locationId"] ?? "")).filter(Boolean);
130647
+ } catch {
130648
+ return void 0;
130649
+ }
130650
+ }
130651
+ function plannedLocationIds2(value) {
130652
+ if (!Array.isArray(value)) return [];
130653
+ return value.map((item) => {
130654
+ if (typeof item === "string" || typeof item === "number") return String(item);
130655
+ if (item && typeof item === "object") {
130656
+ const id = item["id"] ?? item["Id"];
130657
+ return id == null ? "" : String(id);
130658
+ }
130659
+ return "";
130660
+ }).filter(Boolean);
130661
+ }
130662
+ async function printDemandGenCampaignReceipt(config, googleApiUrl, accountId, campaignId, expected, verbose) {
130663
+ let detail;
130664
+ try {
130665
+ detail = asRecord5(
130666
+ decorateDemandGenRead(
130667
+ await pmaxApiFetch(demandGenCampaignUrl(googleApiUrl, accountId, campaignId), config, {}, verbose)
130668
+ )
130669
+ );
130670
+ } catch {
130671
+ detail = void 0;
130672
+ }
130673
+ const lines = [];
130674
+ if (expected.budgetCents != null) {
130675
+ const actual = typeof detail?.["budgetYuan"] === "number" ? detail["budgetYuan"] : void 0;
130676
+ lines.push(
130677
+ receiptLine(
130678
+ "\u65E5\u9884\u7B97",
130679
+ yuanLabel(expected.budgetCents / 100),
130680
+ actual == null ? void 0 : yuanLabel(actual)
130681
+ )
130682
+ );
130683
+ }
130684
+ if (expected.status) {
130685
+ lines.push(receiptLine("\u72B6\u6001", expected.status, detail?.["statusV2"]));
130686
+ }
130687
+ if (expected.countryIds && expected.countryIds.length > 0) {
130688
+ const live = detail ? await readLocationIds(config, googleApiUrl, accountId, campaignId, verbose) : void 0;
130689
+ lines.push(
130690
+ receiptLine(
130691
+ "\u6295\u653E\u56FD\u5BB6",
130692
+ [...expected.countryIds].sort().join(","),
130693
+ live ? [...live].sort().join(",") : void 0
130694
+ )
130695
+ );
130696
+ }
130697
+ printWriteReceipt(detail ? judgeReceipt(lines) : "unknown", lines);
130698
+ }
129952
130699
  function asRecord5(value) {
129953
130700
  return value && typeof value === "object" && !Array.isArray(value) ? value : { data: value };
129954
130701
  }
@@ -130062,6 +130809,27 @@ async function postCreate(opts, path61, commandLabel) {
130062
130809
  fail4(explainCreateError(err));
130063
130810
  }
130064
130811
  const payload = decorateDemandGenRead(data);
130812
+ if (path61 !== "validate") {
130813
+ const created = asRecord5(payload);
130814
+ const createdId = String(created["id"] ?? created["campaignId"] ?? "");
130815
+ const countries = plannedLocationIds2(body["targetedLocations"]);
130816
+ if (createdId) {
130817
+ await printDemandGenCampaignReceipt(
130818
+ config,
130819
+ googleApiUrl,
130820
+ accountId,
130821
+ createdId,
130822
+ {
130823
+ budgetCents: typeof body["budget"] === "number" ? body["budget"] : void 0,
130824
+ status: "Paused",
130825
+ countryIds: countries
130826
+ },
130827
+ opts.verbose
130828
+ );
130829
+ } else {
130830
+ printWriteReceipt("unknown", [receiptLine("\u7CFB\u5217", "\u5DF2\u521B\u5EFA", void 0)]);
130831
+ }
130832
+ }
130065
130833
  if (await emit({ ...opts, account: accountId }, `ad-demand-gen-${path61 || "create"}`, commandLabel, payload, accountId)) {
130066
130834
  return;
130067
130835
  }
@@ -130298,6 +131066,18 @@ async function runDemandGenEdit(opts) {
130298
131066
  } catch (err) {
130299
131067
  fail4(`\u66F4\u65B0 Demand Gen \u5931\u8D25\uFF1A${err instanceof Error ? err.message : String(err)}`);
130300
131068
  }
131069
+ await printDemandGenCampaignReceipt(
131070
+ config,
131071
+ googleApiUrl,
131072
+ accountId,
131073
+ campaignId,
131074
+ {
131075
+ budgetCents: typeof body["budget"] === "number" ? body["budget"] : void 0,
131076
+ status: typeof body["statusV2"] === "string" ? body["statusV2"] : void 0,
131077
+ countryIds: plannedLocationIds2(body["targetedLocations"])
131078
+ },
131079
+ opts.verbose
131080
+ );
130301
131081
  const payload = { ok: true, campaignId, patch: body };
130302
131082
  if (await emit({ ...opts, account: accountId }, "ad-demand-gen-edit", "ad demand-gen edit", payload, campaignId)) {
130303
131083
  return;
@@ -130401,6 +131181,16 @@ async function putStatus(opts, kind) {
130401
131181
  } catch (err) {
130402
131182
  fail4(`\u66F4\u65B0\u72B6\u6001\u5931\u8D25\uFF1A${err instanceof Error ? err.message : String(err)}`);
130403
131183
  }
131184
+ let readStatus;
131185
+ try {
131186
+ const readUrl2 = url.replace(/\/status$/, "");
131187
+ const raw = asRecord5(await pmaxApiFetch(readUrl2, config, {}, opts.verbose));
131188
+ readStatus = raw["status"] ?? raw["statusV2"];
131189
+ } catch {
131190
+ readStatus = void 0;
131191
+ }
131192
+ const lines = [receiptLine("\u72B6\u6001", status, readStatus)];
131193
+ printWriteReceipt(readStatus === void 0 ? "unknown" : judgeReceipt(lines), lines);
130404
131194
  console.log(`
130405
131195
  \u2705 \u5DF2\u8BBE\u4E3A ${status}\u3002\u7CFB\u5217\u72B6\u6001\u4E0D\u4F1A\u8DDF\u7740\u53D8\u3002
130406
131196
  `);
@@ -131599,7 +132389,7 @@ function register21(program2) {
131599
132389
  verbose: opts.verbose
131600
132390
  });
131601
132391
  });
131602
- adCmd.command("campaign-edit").description("\u7F16\u8F91\u641C\u7D22\u5E7F\u544A\u7CFB\u5217\u3002\u540D\u79F0\u3001\u9884\u7B97\u3001\u51FA\u4EF7\u3001\u6295\u653E\u7F51\u7EDC\u3001\u4F4D\u7F6E\u9009\u9879\u3001\u53D7\u4F17\u89C2\u5BDF/\u5B9A\u5411\u90FD\u8D70\u5B57\u6BB5\u7EA7 PATCH\u3002\u81F3\u5C11\u4F20\u4E00\u4E2A\u4FEE\u6539\u9879").requiredOption("-a, --account <id>", "Google \u8D26\u6237 mediaCustomerId").requiredOption("--id <campaignId>", "\u5E7F\u544A\u7CFB\u5217 ID").option("--name <name>", "\u65B0\u540D\u79F0").option(
132392
+ adCmd.command("campaign-edit").description("\u7F16\u8F91\u641C\u7D22\u5E7F\u544A\u7CFB\u5217\u3002\u540D\u79F0\u3001\u9884\u7B97\u3001\u51FA\u4EF7\u3001\u6295\u653E\u7F51\u7EDC\u3001\u4F4D\u7F6E\u9009\u9879\u90FD\u8D70\u5B57\u6BB5\u7EA7 PATCH\u3002\u81F3\u5C11\u4F20\u4E00\u4E2A\u4FEE\u6539\u9879").requiredOption("-a, --account <id>", "Google \u8D26\u6237 mediaCustomerId").requiredOption("--id <campaignId>", "\u5E7F\u544A\u7CFB\u5217 ID").option("--name <name>", "\u65B0\u540D\u79F0").option(
131603
132393
  "--budget <amount>",
131604
132394
  "\u65B0\u9884\u7B97\uFF0C\u4E3B\u5E01\u79CD\u91D1\u989D\uFF08\u5982 100 \u8868\u793A \xA5100\uFF1B\u652F\u6301\u5C0F\u6570\uFF1BCLI \u5185\u90E8\u81EA\u52A8 \xD7100 \u5199\u5165\u300C\u5206\u300D\u5B57\u6BB5\uFF09",
131605
132395
  parseFloat
@@ -131632,9 +132422,6 @@ function register21(program2) {
131632
132422
  ).option(
131633
132423
  "--negative-geo-target-type <type>",
131634
132424
  "\u4F4D\u7F6E\u9009\u9879\uFF08\u6392\u9664\uFF09\uFF1Apresence\uFF08\u6392\u9664\u8EAB\u5904\u8BE5\u5730\u7684\u4EBA\uFF09| presence-or-interest\uFF08\u8EAB\u5904\u6216\u5173\u6CE8\u8BE5\u5730\u7684\u4EBA\u90FD\u6392\u9664\uFF09"
131635
- ).option(
131636
- "--audience-targeting <mode>",
131637
- "\u641C\u7D22\u53D7\u4F17\uFF1AObservation\uFF08\u89C2\u5BDF\uFF0C\u4ECD\u53EF\u6295\u7ED9\u5176\u4ED6\u4EBA\uFF09| Targeting\uFF08\u5B9A\u5411\uFF0C\u53EA\u6295\u7ED9\u5DF2\u52A0\u7684\u53D7\u4F17\uFF09\u3002\u975E\u641C\u7D22\u7CFB\u5217\u62D2\u7EDD"
131638
132425
  ).option("--json-out <path>", "\u843D\u76D8\u6838\u9A8C\u7ED3\u679C\uFF08writeScope=search-field-patch\uFF09").option("-t, --token <token>", "Auth Token").option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(
131639
132426
  async (opts) => {
131640
132427
  await runAdCampaignEdit({
@@ -131652,7 +132439,6 @@ function register21(program2) {
131652
132439
  targetContentNetwork: opts.contentNetwork,
131653
132440
  geoTargetType: opts.geoTargetType,
131654
132441
  negativeGeoTargetType: opts.negativeGeoTargetType,
131655
- audienceTargeting: opts.audienceTargeting,
131656
132442
  jsonOut: opts.jsonOut,
131657
132443
  verbose: opts.verbose
131658
132444
  });
@@ -132220,21 +133006,21 @@ function register21(program2) {
132220
133006
  }
132221
133007
  function registerAccountOps(adCmd) {
132222
133008
  const exclusions = adCmd.command("exclusions").description(
132223
- "\u8D26\u6237\u7EA7\u5185\u5BB9\u9002\u5B9C\u6027\u6392\u9664\uFF08\u654F\u611F\u5185\u5BB9\u3001\u7C7B\u578B\u548C\u6807\u7B7E\u3001\u5185\u5BB9\u4E3B\u9898\u3001\u7F51\u7AD9\u3001YouTube\u3001\u5E94\u7528\u3001\u5E94\u7528\u7C7B\u522B\uFF09\u3002user-list \u4F1A\u5728\u7F51\u5173\u62D2\u7EDD\uFF1A\u5BA2\u6237\u7EA7\u5426\u5B9A\u51C6\u5219\u6CA1\u6709\u7528\u6237\u5217\u8868\u5B57\u6BB5\u3002\u5168\u8D26\u6237\u751F\u6548\u3002\u4E0D\u662F\u5C55\u793A\u5E7F\u544A\u521B\u5EFA\uFF0C\u4E5F\u4E0D\u662F\u641C\u7D22\u5426\u8BCD\u6216\u5185\u5BB9\u5173\u952E\u5B57"
133009
+ "\u8D26\u6237\u7EA7\u5185\u5BB9\u9002\u5B9C\u6027\u6392\u9664\uFF08\u654F\u611F\u5185\u5BB9\u3001\u7C7B\u578B\u548C\u6807\u7B7E\u3001\u5185\u5BB9\u4E3B\u9898\u3001\u7F51\u7AD9\u3001YouTube\u3001\u5E94\u7528\u3001\u5E94\u7528\u7C7B\u522B\uFF09\u3002\u5168\u8D26\u6237\u751F\u6548\u3002\u4E0D\u662F\u5C55\u793A\u5E7F\u544A\u521B\u5EFA\uFF0C\u4E5F\u4E0D\u662F\u641C\u7D22\u5426\u8BCD\u6216\u5185\u5BB9\u5173\u952E\u5B57"
132224
133010
  );
132225
133011
  exclusions.command("list").description("\u5217\u51FA\u5DF2\u751F\u6548\u7684\u8D26\u6237\u7EA7\u5185\u5BB9\u6392\u9664").requiredOption("-a, --account <id>", "Google \u8D26\u6237 mediaCustomerId").option(
132226
133012
  "--type <type>",
132227
- "content-label | placement | youtube-channel | youtube-video | app | app-category | user-list"
133013
+ "content-label | placement | youtube-channel | youtube-video | app | app-category"
132228
133014
  ).option("--json-out <path>", "\u843D\u76D8").option("-t, --token <token>", "Auth Token").option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(async (opts) => {
132229
133015
  await runAdExclusionsList(opts);
132230
133016
  });
132231
133017
  exclusions.command("add").description("\u6DFB\u52A0\u4E00\u6761\u8D26\u6237\u7EA7\u6392\u9664\u3002\u4E00\u6B21\u4E00\u79CD\u7C7B\u578B\u3002\u5199\u64CD\u4F5C\u987B --commit\u3002\u5148 list\uFF0C\u5E76\u5411\u7528\u6237\u786E\u8BA4").requiredOption("-a, --account <id>", "Google \u8D26\u6237 mediaCustomerId").requiredOption(
132232
133018
  "--type <type>",
132233
- "content-label | placement | youtube-channel | youtube-video | app | app-category | user-list"
133019
+ "content-label | placement | youtube-channel | youtube-video | app | app-category"
132234
133020
  ).option(
132235
133021
  "--content-label <name>",
132236
133022
  "\u5185\u5BB9\u6807\u7B7E proto \u540D\uFF0C\u6765\u81EA content-labels\uFF0C\u5982 BRAND_SUITABILITY_GAMES_FIGHTING"
132237
- ).option("--url <url>", "\u8981\u6392\u9664\u7684\u7F51\u7AD9").option("--channel-id <id>", "YouTube \u9891\u9053 ID").option("--video-id <id>", "YouTube \u89C6\u9891 ID").option("--app-id <id>", "\u5E94\u7528 ID\uFF1A1-\u6570\u5B57 \u6216 2-\u5305\u540D").option("--app-category-id <id>", "\u5E94\u7528\u7C7B\u522B\u6570\u5B57 id\uFF0C\u6765\u81EA app-categories").option("--user-list-id <id>", "\u5DF2\u6709\u7528\u6237\u5217\u8868\u7684\u6570\u5B57 id\u3002\u4E0D\u4E0A\u4F20\u540D\u5355").option("--json-out <path>", "\u843D\u76D8").option("-t, --token <token>", "Auth Token").option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(async (opts) => {
133023
+ ).option("--url <url>", "\u8981\u6392\u9664\u7684\u7F51\u7AD9").option("--channel-id <id>", "YouTube \u9891\u9053 ID").option("--video-id <id>", "YouTube \u89C6\u9891 ID").option("--app-id <id>", "\u5E94\u7528 ID\uFF1A1-\u6570\u5B57 \u6216 2-\u5305\u540D").option("--app-category-id <id>", "\u5E94\u7528\u7C7B\u522B\u6570\u5B57 id\uFF0C\u6765\u81EA app-categories").option("--json-out <path>", "\u843D\u76D8").option("-t, --token <token>", "Auth Token").option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(async (opts) => {
132238
133024
  await runAdExclusionsAdd({
132239
133025
  token: opts.token,
132240
133026
  account: opts.account,
@@ -132245,7 +133031,6 @@ function registerAccountOps(adCmd) {
132245
133031
  videoId: opts.videoId,
132246
133032
  appId: opts.appId,
132247
133033
  appCategoryId: opts.appCategoryId,
132248
- userListId: opts.userListId,
132249
133034
  jsonOut: opts.jsonOut,
132250
133035
  verbose: opts.verbose
132251
133036
  });
@@ -132365,9 +133150,6 @@ function registerProtection(adCmd) {
132365
133150
  sharedBudget.command("update").description("\u6539\u4E00\u4EFD\u5171\u4EAB\u9884\u7B97\u7684\u540D\u79F0\u6216\u91D1\u989D\u3002\u540C\u4E00\u9884\u7B97\u4E0B\u7684\u7CFB\u5217\u4F1A\u4E00\u8D77\u53D8\u3002\u5199\u64CD\u4F5C\u987B --commit").requiredOption("-a, --account <id>", "Google \u8D26\u6237 mediaCustomerId").requiredOption("--budget-id <id>", "list \u91CC\u7684 id").option("--name <name>", "\u65B0\u540D\u79F0\uFF0C\u4E0D\u4F20\u5219\u4FDD\u6301\u539F\u540D").option("--amount <yuan>", "\u65B0\u65E5\u9884\u7B97\uFF0C\u4E3B\u5E01\u79CD\u5143", (value) => Number(value)).option("-t, --token <token>", "Auth Token").option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(async (opts) => {
132366
133151
  await runAdSharedBudgetUpdate(opts);
132367
133152
  });
132368
- sharedBudget.command("attach").description("\u628A\u5DF2\u6709\u7CFB\u5217\u6539\u6302\u5230\u4E00\u4EFD\u5171\u4EAB\u9884\u7B97\u3002\u4E0D\u6539\u91D1\u989D\u3002Demand Gen \u4F1A\u62D2\u7EDD\u3002\u5199\u64CD\u4F5C\u987B --commit").requiredOption("-a, --account <id>", "Google \u8D26\u6237 mediaCustomerId").requiredOption("--campaign-id <id>", "\u8981\u6539\u6302\u7684\u7CFB\u5217 id").requiredOption("--budget-id <id>", "list \u91CC\u7684\u5171\u4EAB\u9884\u7B97 id").option("-t, --token <token>", "Auth Token").option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(async (opts) => {
132369
- await runAdSharedBudgetAttach(opts);
132370
- });
132371
133153
  sharedBudget.command("delete").description("\u5220\u9664\u5171\u4EAB\u9884\u7B97\u3002\u987B --i-confirm\u3002\u4ECD\u88AB\u7CFB\u5217\u4F7F\u7528\u65F6 Google \u4F1A\u62D2\u7EDD").requiredOption("-a, --account <id>", "Google \u8D26\u6237 mediaCustomerId").requiredOption("--budget-id <id>", "list \u91CC\u7684 id").option("--i-confirm", "\u7528\u6237\u5DF2\u786E\u8BA4\u5220\u9664", false).option("-t, --token <token>", "Auth Token").option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(async (opts) => {
132372
133154
  await runAdSharedBudgetDelete(opts);
132373
133155
  });
@@ -133107,6 +133889,52 @@ function formHasPredefinedQuestion(form) {
133107
133889
  return (form.questions ?? []).some((q) => isPredefinedQuestionType(q.type));
133108
133890
  }
133109
133891
 
133892
+ // src/commands/meta-ad/readback.ts
133893
+ init_auth();
133894
+ async function tryReadMeta(facebookApiUrl, account, path61, config, verbose) {
133895
+ try {
133896
+ const data = await apiFetch2(adsUrl(facebookApiUrl, account, path61), config, {}, verbose);
133897
+ if (data && typeof data === "object" && !Array.isArray(data)) return data;
133898
+ return void 0;
133899
+ } catch {
133900
+ return void 0;
133901
+ }
133902
+ }
133903
+ function countriesOf(row) {
133904
+ const targeting = row?.["targeting"];
133905
+ if (!targeting || typeof targeting !== "object") return void 0;
133906
+ const geo = targeting["geo_locations"];
133907
+ if (!geo || typeof geo !== "object") return void 0;
133908
+ const countries = geo["countries"];
133909
+ if (!Array.isArray(countries)) return void 0;
133910
+ return countries.map((item) => String(item).toUpperCase()).sort().join(",");
133911
+ }
133912
+ function printMetaObjectReceipt(expected, row) {
133913
+ const lines = [];
133914
+ if (expected.status) {
133915
+ lines.push(receiptLine("\u72B6\u6001", expected.status, row?.["status"]));
133916
+ }
133917
+ if (expected.dailyBudget) {
133918
+ lines.push(receiptLine("\u65E5\u9884\u7B97", expected.dailyBudget, row?.["daily_budget"]));
133919
+ }
133920
+ if (expected.countries && expected.countries.length > 0) {
133921
+ lines.push(
133922
+ receiptLine(
133923
+ "\u56FD\u5BB6",
133924
+ expected.countries.map((item) => item.toUpperCase()).sort().join(","),
133925
+ countriesOf(row)
133926
+ )
133927
+ );
133928
+ }
133929
+ if (expected.link) {
133930
+ const spec = row?.["object_story_spec"];
133931
+ const linkData = spec && typeof spec === "object" ? spec["link_data"] : void 0;
133932
+ const link = linkData && typeof linkData === "object" ? linkData["link"] : row?.["link"];
133933
+ lines.push(receiptLine("\u843D\u5730\u9875", expected.link, link));
133934
+ }
133935
+ printWriteReceipt(row ? judgeReceipt(lines) : "unknown", lines);
133936
+ }
133937
+
133110
133938
  // src/commands/meta-ad/load.ts
133111
133939
  import { readFileSync as readFileSync16 } from "fs";
133112
133940
  function stripMetaKeys2(value) {
@@ -133758,6 +134586,18 @@ async function runMetaAdCreate(opts) {
133758
134586
  process.exit(1);
133759
134587
  }
133760
134588
  progress.ok = true;
134589
+ const adsetRow = progress.adSetId ? await tryReadMeta(facebookApiUrl, digits, `/adsets/${progress.adSetId}`, config, opts.verbose) : void 0;
134590
+ const creativeRow = progress.creativeId ? await tryReadMeta(facebookApiUrl, digits, `/adcreatives/${progress.creativeId}`, config, opts.verbose) : void 0;
134591
+ const daily = cfg.adset.dailyBudget != null ? toMinorUnitString(cfg.adset.dailyBudget, currency) : void 0;
134592
+ printMetaObjectReceipt(
134593
+ {
134594
+ status: "PAUSED",
134595
+ dailyBudget: daily,
134596
+ countries: cfg.adset.countries,
134597
+ link: cfg.creative.link
134598
+ },
134599
+ adsetRow ? { ...adsetRow, ...creativeRow ?? {} } : void 0
134600
+ );
133761
134601
  if (await emitProgress()) return;
133762
134602
  console.log("\n\u2705 Meta Instant Form \u7EBF\u7D22\u5E7F\u544A\u5DF2\u521B\u5EFA\uFF08\u9ED8\u8BA4 PAUSED\uFF09\n");
133763
134603
  console.log(` formId ${progress.formId}`);
@@ -134892,6 +135732,20 @@ async function runMetaAdCampaignEdit(opts) {
134892
135732
  "\u6539\u7CFB\u5217\u5931\u8D25"
134893
135733
  );
134894
135734
  const payload = { id: extractCreatedId(data) ?? opts.id, ...data };
135735
+ const read = await tryReadMeta(
135736
+ facebookApiUrl,
135737
+ digits,
135738
+ `/campaigns/${encodeURIComponent(opts.id)}`,
135739
+ config,
135740
+ opts.verbose
135741
+ );
135742
+ printMetaObjectReceipt(
135743
+ {
135744
+ status: typeof body.status === "string" ? body.status : void 0,
135745
+ dailyBudget: typeof body.daily_budget === "string" ? body.daily_budget : void 0
135746
+ },
135747
+ read
135748
+ );
134895
135749
  if (await emitMetaJson(opts, "meta-ad-campaign-edit", "meta-ad campaign-edit", payload, digits)) {
134896
135750
  return;
134897
135751
  }
@@ -134914,6 +135768,14 @@ async function runMetaAdCampaignStatus(opts) {
134914
135768
  "\u6539\u7CFB\u5217\u72B6\u6001\u5931\u8D25"
134915
135769
  );
134916
135770
  const payload = { id: extractCreatedId(data) ?? opts.id, status: opts.status.trim(), ...data };
135771
+ const read = await tryReadMeta(
135772
+ facebookApiUrl,
135773
+ digits,
135774
+ `/campaigns/${encodeURIComponent(opts.id)}`,
135775
+ config,
135776
+ opts.verbose
135777
+ );
135778
+ printMetaObjectReceipt({ status: opts.status.trim().toUpperCase() }, read);
134917
135779
  if (await emitMetaJson(opts, "meta-ad-campaign-status", "meta-ad campaign-status", payload, digits)) {
134918
135780
  return;
134919
135781
  }
@@ -135306,6 +136168,7 @@ async function runMetaAdAdsetEdit(opts) {
135306
136168
  const unmatched = describeUnmatchedChecks(judged.checks);
135307
136169
  const detail = verification === "verified" ? `\u5E7F\u544A\u7EC4 ${opts.id} \u5DF2\u6838\u9A8C` : unmatched || `\u5E7F\u544A\u7EC4 ${opts.id} \u7684\u5199\u5165\u7ED3\u679C\u5C1A\u672A\u6838\u9A8C`;
135308
136170
  const headline = writeVerificationHeadline(verification, detail);
136171
+ printWriteReceipt(verification, receiptLinesFromFieldChecks(judged.checks));
135309
136172
  if (verification !== "verified") {
135310
136173
  console.error(`
135311
136174
  ${headline}
@@ -135346,6 +136209,14 @@ async function runMetaAdAdsetStatus(opts) {
135346
136209
  "\u6539\u5E7F\u544A\u7EC4\u72B6\u6001\u5931\u8D25"
135347
136210
  );
135348
136211
  const payload = { id: extractCreatedId(data) ?? opts.id, status: opts.status.trim(), ...data };
136212
+ const read = await tryReadMeta(
136213
+ facebookApiUrl,
136214
+ digits,
136215
+ `/adsets/${encodeURIComponent(opts.id)}`,
136216
+ config,
136217
+ opts.verbose
136218
+ );
136219
+ printMetaObjectReceipt({ status: opts.status.trim().toUpperCase() }, read);
135349
136220
  if (await emitMetaJson(opts, "meta-ad-adset-status", "meta-ad adset-status", payload, digits)) {
135350
136221
  return;
135351
136222
  }
@@ -135500,6 +136371,14 @@ async function runMetaAdStatus(opts) {
135500
136371
  "\u6539\u5E7F\u544A\u72B6\u6001\u5931\u8D25"
135501
136372
  );
135502
136373
  const payload = { id: extractCreatedId(data) ?? opts.id, status: opts.status.trim(), ...data };
136374
+ const read = await tryReadMeta(
136375
+ facebookApiUrl,
136376
+ digits,
136377
+ `/ads/${encodeURIComponent(opts.id)}`,
136378
+ config,
136379
+ opts.verbose
136380
+ );
136381
+ printMetaObjectReceipt({ status: opts.status.trim().toUpperCase() }, read);
135503
136382
  if (await emitMetaJson(opts, "meta-ad-ad-status", "meta-ad ad-status", payload, digits)) return;
135504
136383
  console.log(`
135505
136384
  \u2705 \u5E7F\u544A ${opts.id} \u72B6\u6001\u5DF2\u8BBE\u4E3A ${opts.status.trim()}
@@ -136990,6 +137869,16 @@ async function runAccountMccUnbind(opts) {
136990
137869
  process.exit(1);
136991
137870
  }
136992
137871
  }
137872
+ for (const { customerId, response } of results) {
137873
+ const failed = managerIds.filter((mid) => !mccResponseHasSuccess(response, mid));
137874
+ const listed = await fetchAccountsByKeyword(config, "Google", customerId, opts.verbose);
137875
+ const stillListed = JSON.stringify(listed ?? "").includes(customerId);
137876
+ const lines = [
137877
+ receiptLine("MCC", managerIds.join(","), failed.length ? `\u672A\u6210\u529F ${failed.join(",")}` : managerIds.join(",")),
137878
+ receiptLine("\u8D26\u6237", "\u4ECD\u5728\u5217\u8868", listed === void 0 ? void 0 : stillListed ? "\u4ECD\u5728\u5217\u8868" : "\u5DF2\u4E0D\u5728")
137879
+ ];
137880
+ printWriteReceipt(listed === void 0 ? "unknown" : judgeReceipt(lines), lines);
137881
+ }
136993
137882
  if (await emitCliJsonOrSnapshot(opts, {
136994
137883
  section: "account-mcc-unbind",
136995
137884
  commandLabel: "account mcc-unbind",
@@ -137347,6 +138236,9 @@ async function runAccountDelink(opts) {
137347
138236
  `);
137348
138237
  process.exit(1);
137349
138238
  }
138239
+ for (const id of opts.ids) {
138240
+ await printAccountAbsence(config, void 0, id, "\u8D26\u6237", opts.verbose);
138241
+ }
137350
138242
  console.log(`
137351
138243
  \u2705 \u5DF2\u6279\u91CF\u65AD\u5F00 ${opts.ids.length} \u4E2A\u8D26\u6237\u7684\u5173\u8054\u5173\u7CFB
137352
138244
  `);
@@ -137366,6 +138258,7 @@ async function runAccountDelink(opts) {
137366
138258
  `);
137367
138259
  process.exit(1);
137368
138260
  }
138261
+ await printAccountAbsence(config, void 0, entityId, "\u8D26\u6237", opts.verbose);
137369
138262
  console.log(`
137370
138263
  \u2705 \u8D26\u6237 ${entityId} \u5DF2\u65AD\u5F00\u5173\u8054
137371
138264
  `);
@@ -137419,6 +138312,27 @@ async function runAccountShare(opts) {
137419
138312
  `);
137420
138313
  process.exit(1);
137421
138314
  }
138315
+ let detail;
138316
+ try {
138317
+ const listed = await apiFetch2(
138318
+ `${config.apiBaseUrl}/query/media-account/?keyword=${encodeURIComponent(opts.id)}&pageNo=1&pageSize=5`,
138319
+ config,
138320
+ {},
138321
+ opts.verbose
138322
+ );
138323
+ const mediaId = JSON.stringify(listed ?? "").match(/"mediaCustomerId"\s*:\s*"([^"]+)"/)?.[1];
138324
+ if (mediaId && config.mainApiUrl) {
138325
+ detail = await apiFetch2(
138326
+ `${config.mainApiUrl}/query/account/GetAccountsByMediaAcountId?mediaAcountId=${encodeURIComponent(mediaId)}`,
138327
+ config,
138328
+ {},
138329
+ opts.verbose
138330
+ );
138331
+ }
138332
+ } catch {
138333
+ detail = void 0;
138334
+ }
138335
+ printApplicationNeedles([{ label: "\u88AB\u5206\u4EAB\u4EBA", value: userId }], detail);
137422
138336
  console.log(`
137423
138337
  \u2705 \u8D26\u6237\u5DF2\u6210\u529F\u5206\u4EAB\u7ED9\u624B\u673A\u53F7 ${phone} \u7684\u7528\u6237\uFF08AccountId: ${userId}\uFF09
137424
138338
  `);
@@ -137440,6 +138354,29 @@ async function runAccountUnshare(opts) {
137440
138354
  `);
137441
138355
  process.exit(1);
137442
138356
  }
138357
+ let detail;
138358
+ try {
138359
+ const listed = await apiFetch2(
138360
+ `${config.apiBaseUrl}/query/media-account/?keyword=${encodeURIComponent(opts.id)}&pageNo=1&pageSize=5`,
138361
+ config,
138362
+ {},
138363
+ opts.verbose
138364
+ );
138365
+ const text5 = JSON.stringify(listed ?? "");
138366
+ const mediaId = text5.match(/"mediaCustomerId"\s*:\s*"([^"]+)"/)?.[1];
138367
+ if (mediaId && config.mainApiUrl) {
138368
+ detail = await apiFetch2(
138369
+ `${config.mainApiUrl}/query/account/GetAccountsByMediaAcountId?mediaAcountId=${encodeURIComponent(mediaId)}`,
138370
+ config,
138371
+ {},
138372
+ opts.verbose
138373
+ );
138374
+ }
138375
+ } catch {
138376
+ detail = void 0;
138377
+ }
138378
+ const gone = receiptForAbsence("\u5206\u4EAB", opts.accountId, detail);
138379
+ printWriteReceipt(gone.verification, gone.lines);
137443
138380
  console.log(`
137444
138381
  \u2705 \u5DF2\u53D6\u6D88\u8D26\u6237 ${opts.id} \u5BF9\u7528\u6237 ${opts.accountId} \u7684\u5206\u4EAB
137445
138382
  `);
@@ -137694,6 +138631,9 @@ async function runAccountClose(opts) {
137694
138631
  console.error("");
137695
138632
  process.exit(1);
137696
138633
  }
138634
+ for (const id of mediaIds) {
138635
+ await printAccountAbsence(config, "TikTok", id, "\u8D26\u6237", opts.verbose);
138636
+ }
137697
138637
  console.log(`
137698
138638
  \u2705 TikTok \u5173\u6237\u5DF2\u6210\u529F\u63D0\u4EA4\uFF0CmediaCustomerId\uFF1A${mediaIds.join("\u3001")}
137699
138639
  `);
@@ -137902,6 +138842,13 @@ async function runAccountWithdrawSubmit(opts) {
137902
138842
  `);
137903
138843
  process.exit(1);
137904
138844
  }
138845
+ printApplicationNeedles(
138846
+ body.flatMap((item) => [
138847
+ { label: "\u7533\u8BF7\u8D26\u6237", value: item.MediaCustomerId },
138848
+ { label: "\u7533\u8BF7\u91D1\u989D", value: item.Amounts }
138849
+ ]),
138850
+ result
138851
+ );
137905
138852
  if (await emitCliJsonOrSnapshot(opts, {
137906
138853
  section: "account-withdraw-submit",
137907
138854
  commandLabel: "account withdraw submit",
@@ -138005,6 +138952,17 @@ async function runAccountBcUnbind(opts) {
138005
138952
  `);
138006
138953
  process.exit(1);
138007
138954
  }
138955
+ const failedIds = result && typeof result === "object" && !Array.isArray(result) ? Object.keys(result) : [];
138956
+ for (const customerId of opts.customers) {
138957
+ const listed = await fetchAccountsByKeyword(config, "TikTok", customerId, opts.verbose);
138958
+ const stillListed = JSON.stringify(listed ?? "").includes(customerId);
138959
+ const unbound = !failedIds.includes(customerId);
138960
+ const lines = [
138961
+ receiptLine("BC\u89E3\u7ED1", "\u5DF2\u89E3\u7ED1", unbound ? "\u5DF2\u89E3\u7ED1" : "\u5931\u8D25"),
138962
+ receiptLine("\u8D26\u6237", "\u4ECD\u5728\u5217\u8868", listed === void 0 ? void 0 : stillListed ? "\u4ECD\u5728\u5217\u8868" : "\u5DF2\u4E0D\u5728")
138963
+ ];
138964
+ printWriteReceipt(listed === void 0 ? "unknown" : judgeReceipt(lines), lines);
138965
+ }
138008
138966
  if (await emitCliJsonOrSnapshot(opts, {
138009
138967
  section: `account-bc-unbind-${opts.bcId}`,
138010
138968
  commandLabel: "account bc-unbind",
@@ -138015,11 +138973,11 @@ async function runAccountBcUnbind(opts) {
138015
138973
  return;
138016
138974
  }
138017
138975
  const failedMap = result && typeof result === "object" && !Array.isArray(result) ? result : {};
138018
- const failedIds = Object.keys(failedMap);
138019
- if (failedIds.length > 0) {
138976
+ const failedMessages = Object.keys(failedMap);
138977
+ if (failedMessages.length > 0) {
138020
138978
  console.warn(`
138021
138979
  \u26A0\uFE0F \u4EE5\u4E0B\u8D26\u6237\u89E3\u7ED1\u5931\u8D25\uFF1A`);
138022
- for (const id of failedIds) {
138980
+ for (const id of failedMessages) {
138023
138981
  console.warn(` ${id}: ${failedMap[id]}`);
138024
138982
  }
138025
138983
  } else {
@@ -138256,6 +139214,14 @@ async function runAccountEmailDeauth(opts) {
138256
139214
  `);
138257
139215
  process.exit(1);
138258
139216
  }
139217
+ let listed;
139218
+ try {
139219
+ listed = await fetchCustomerUserAccessInvitationList(config, opts.customerId, opts.verbose, opts.agentType);
139220
+ } catch {
139221
+ listed = void 0;
139222
+ }
139223
+ const gone = receiptForAbsence("\u90AE\u7BB1\u6388\u6743", opts.invitationId, listed);
139224
+ printWriteReceipt(gone.verification, gone.lines);
138259
139225
  if (await emitCliJsonOrSnapshot(opts, {
138260
139226
  section: `account-email-deauth-${opts.customerId}-${opts.invitationId}`,
138261
139227
  commandLabel: "account email-deauth",
@@ -138954,6 +139920,41 @@ async function resolveGoogleMediaAccountGroupId(config, opts) {
138954
139920
 
138955
139921
  // src/commands/open-account/yandex.ts
138956
139922
  init_auth();
139923
+
139924
+ // src/commands/open-account/readback.ts
139925
+ init_auth();
139926
+ async function printOpenAccountReceipt(config, media, company, verbose) {
139927
+ const params = new URLSearchParams();
139928
+ params.set("MediaType", media);
139929
+ params.set("keyword", company);
139930
+ params.set("pageIndex", "0");
139931
+ params.set("pageSize", "20");
139932
+ params.set(
139933
+ "mediaAccountState",
139934
+ media === "Google" ? "Created,Approved,Denied,Inactive" : "Created,Approved,Denied"
139935
+ );
139936
+ let listed;
139937
+ try {
139938
+ const res = await apiFetchWithHeaders2(
139939
+ `${config.apiBaseUrl}/query/media-account/?${params}`,
139940
+ config,
139941
+ {},
139942
+ verbose
139943
+ );
139944
+ listed = res.data;
139945
+ } catch {
139946
+ listed = void 0;
139947
+ }
139948
+ printApplicationNeedles(
139949
+ [
139950
+ { label: "\u5A92\u4F53", value: media },
139951
+ { label: "\u516C\u53F8", value: company }
139952
+ ],
139953
+ listed
139954
+ );
139955
+ }
139956
+
139957
+ // src/commands/open-account/yandex.ts
138957
139958
  async function runOpenAccountYandex(opts) {
138958
139959
  const config = loadConfig(opts.token);
138959
139960
  const magKey = await resolveGenericMagKey(
@@ -138988,6 +139989,7 @@ async function runOpenAccountYandex(opts) {
138988
139989
  { method: "POST", body: JSON.stringify(body) },
138989
139990
  opts.verbose
138990
139991
  );
139992
+ await printOpenAccountReceipt(config, "Yandex", opts.company, opts.verbose);
138991
139993
  console.log("\n\u2705 Yandex \u5F00\u6237\u7533\u8BF7\u5DF2\u63D0\u4EA4\u6210\u529F\uFF0C\u8BF7\u5728\u300C\u5F00\u6237\u8BB0\u5F55\u300D\u9875\u9762\u67E5\u770B\u5BA1\u6838\u72B6\u6001\u3002\n");
138992
139994
  logAccountOpeningHistoryWebUrl(config.apiBaseUrl, "Yandex");
138993
139995
  if (opts.verbose && res != null) {
@@ -139257,6 +140259,7 @@ async function runOpenAccountBing(opts) {
139257
140259
  { method: "POST", body: JSON.stringify(body) },
139258
140260
  opts.verbose
139259
140261
  );
140262
+ await printOpenAccountReceipt(config, "BingV2", opts.advertiserName, opts.verbose);
139260
140263
  console.log("\n\u2705 Bing \u5F00\u6237\u7533\u8BF7\u5DF2\u63D0\u4EA4\u6210\u529F\uFF0C\u8BF7\u5728\u300C\u5F00\u6237\u8BB0\u5F55\u300D\u9875\u9762\u67E5\u770B\u5BA1\u6838\u72B6\u6001\u3002\n");
139261
140264
  logAccountOpeningHistoryWebUrl(config.apiBaseUrl, "BingV2");
139262
140265
  } catch (err) {
@@ -139473,12 +140476,12 @@ async function runOpenAccountGoogleWizard(opts) {
139473
140476
  ` \u2026 \u5171 ${rows.length} \u6761\uFF0C\u4E5F\u53EF\u7528\uFF1Asiluzan-tso open-account google-timezones --keyword Tokyo
139474
140477
  `
139475
140478
  );
139476
- const pick3 = await q("\n\u8F93\u5165\u5E8F\u53F7\uFF081-60\uFF09\u6216\u76F4\u63A5\u7C98\u8D34 Code\uFF1A");
139477
- const n = parseInt(pick3, 10);
140479
+ const pick2 = await q("\n\u8F93\u5165\u5E8F\u53F7\uFF081-60\uFF09\u6216\u76F4\u63A5\u7C98\u8D34 Code\uFF1A");
140480
+ const n = parseInt(pick2, 10);
139478
140481
  if (!Number.isNaN(n) && n >= 1 && n <= Math.min(60, rows.length)) {
139479
140482
  timezone = String(rows[n - 1]?.Code ?? timezone);
139480
- } else if (pick3) {
139481
- timezone = pick3;
140483
+ } else if (pick2) {
140484
+ timezone = pick2;
139482
140485
  }
139483
140486
  } else if (tzAns) {
139484
140487
  timezone = tzAns;
@@ -139598,6 +140601,7 @@ async function runOpenAccountGoogle(opts) {
139598
140601
  },
139599
140602
  opts.verbose
139600
140603
  );
140604
+ await printOpenAccountReceipt(config, "Google", opts.company, opts.verbose);
139601
140605
  console.log(
139602
140606
  `
139603
140607
  \u2705 Google \u5F00\u6237\u7533\u8BF7\u5DF2\u63D0\u4EA4\uFF08\u5171 ${counts} \u4E2A\uFF09\uFF0C\u9080\u8BF7\u90AE\u4EF6\u5C06\u53D1\u9001\u5230 ${inviteEmail}\u3002
@@ -139805,6 +140809,7 @@ async function runOpenAccountTikTok(opts) {
139805
140809
  },
139806
140810
  opts.verbose
139807
140811
  );
140812
+ await printOpenAccountReceipt(config, "TikTok", opts.company, opts.verbose);
139808
140813
  console.log(
139809
140814
  `
139810
140815
  \u2705 TikTok \u5F00\u6237\u7533\u8BF7\u5DF2\u63D0\u4EA4\uFF08\u5171 ${counts} \u4E2A\uFF09\u3002
@@ -141284,12 +142289,12 @@ var TEMPLATE_BASENAMES = {
141284
142289
  html: "website-diagnosis-report.html",
141285
142290
  runtime: "website-diagnosis-report.runtime.js"
141286
142291
  };
141287
- function resolveSkillTemplatePath(basename15) {
142292
+ function resolveSkillTemplatePath(basename14) {
141288
142293
  const dir = path25.dirname(fileURLToPath4(import.meta.url));
141289
142294
  const candidates = [
141290
- path25.join(dir, "skill", "report-templates", basename15),
141291
- path25.join(dir, "skill", "siluzan-ads", "report-templates", basename15),
141292
- path25.join(dir, "..", "..", "assets", "siluzan-ads", "report-templates", basename15)
142295
+ path25.join(dir, "skill", "report-templates", basename14),
142296
+ path25.join(dir, "skill", "siluzan-ads", "report-templates", basename14),
142297
+ path25.join(dir, "..", "..", "assets", "siluzan-ads", "report-templates", basename14)
141293
142298
  ];
141294
142299
  for (const p of candidates) {
141295
142300
  if (fs20.existsSync(p)) return p;
@@ -142255,13 +143260,13 @@ function buildGoogleAdsDiagnosisNarrativeChecks() {
142255
143260
  return checks;
142256
143261
  }
142257
143262
  var GOOGLE_ADS_DIAGNOSIS_NARRATIVE_CHECKS = buildGoogleAdsDiagnosisNarrativeChecks();
142258
- function resolveSkillTemplatePath2(basename15) {
143263
+ function resolveSkillTemplatePath2(basename14) {
142259
143264
  const dir = path27.dirname(fileURLToPath5(import.meta.url));
142260
143265
  const candidates = [
142261
- path27.join(dir, "skill", "report-templates", basename15),
142262
- path27.join(dir, "skill", "siluzan-ads", "report-templates", basename15),
142263
- path27.join(dir, "..", "..", "assets", "siluzan-ads", "report-templates", basename15),
142264
- path27.join(dir, "..", "..", "..", "assets", "siluzan-ads", "report-templates", basename15)
143266
+ path27.join(dir, "skill", "report-templates", basename14),
143267
+ path27.join(dir, "skill", "siluzan-ads", "report-templates", basename14),
143268
+ path27.join(dir, "..", "..", "assets", "siluzan-ads", "report-templates", basename14),
143269
+ path27.join(dir, "..", "..", "..", "assets", "siluzan-ads", "report-templates", basename14)
142265
143270
  ];
142266
143271
  for (const p of candidates) {
142267
143272
  if (fs22.existsSync(p)) return p;
@@ -143463,7 +144468,7 @@ function getCollectIntegrityWarnings(reportData) {
143463
144468
  }
143464
144469
 
143465
144470
  // src/commands/google-ads-diagnosis/invoke-google-analysis.ts
143466
- import { spawnSync as spawnSync2 } from "child_process";
144471
+ import { spawnSync as spawnSync3 } from "child_process";
143467
144472
  function invokeGoogleAnalysisCli(opts) {
143468
144473
  const cliEntry = process.argv[1];
143469
144474
  if (!cliEntry) {
@@ -143487,7 +144492,7 @@ function invokeGoogleAnalysisCli(opts) {
143487
144492
  if (typeof opts.taskTimeoutMs === "number") {
143488
144493
  args.push("--task-timeout-ms", String(opts.taskTimeoutMs));
143489
144494
  }
143490
- const result = spawnSync2(process.execPath, args, {
144495
+ const result = spawnSync3(process.execPath, args, {
143491
144496
  encoding: "utf8",
143492
144497
  stdio: ["ignore", "pipe", "inherit"],
143493
144498
  timeout: opts.timeoutMs && opts.timeoutMs > 0 ? opts.timeoutMs : void 0
@@ -144632,7 +145637,7 @@ function channelBucket(channelTypeV2) {
144632
145637
  if (raw === "DISPLAY") return "\u5C55\u793A";
144633
145638
  return "\u5176\u4ED6";
144634
145639
  }
144635
- function isSearchChannel2(channelTypeV2) {
145640
+ function isSearchChannel(channelTypeV2) {
144636
145641
  return channelBucket(channelTypeV2) === "\u641C\u7D22";
144637
145642
  }
144638
145643
  function spendByChannel(rows) {
@@ -145298,7 +146303,7 @@ function pickSpecialAds(videos, campaigns) {
145298
146303
  return { source: "pmax", label: "\u6548\u679C\u6700\u5927\u5316", items: pmax };
145299
146304
  }
145300
146305
  const other = sortBySpend(
145301
- campaigns.filter((row) => !isSearchChannel2(row.channelTypeV2) && hasTraffic(row)).map(fromCampaign)
146306
+ campaigns.filter((row) => !isSearchChannel(row.channelTypeV2) && hasTraffic(row)).map(fromCampaign)
145302
146307
  );
145303
146308
  if (other.length > 0) {
145304
146309
  return { source: "other", label: "\u975E\u641C\u7D22\u5E7F\u544A", items: other };
@@ -145943,237 +146948,6 @@ function registerGoogleQuarterlyCommands(program2) {
145943
146948
  );
145944
146949
  }
145945
146950
 
145946
- // src/commands/ga4.ts
145947
- init_auth();
145948
- init_cli_json_snapshot();
145949
- init_cli_table();
145950
- init_shared();
145951
- var GA4_REPORT_DIMENSIONS = [
145952
- "date",
145953
- "eventName",
145954
- "sessionDefaultChannelGroup",
145955
- "pagePath",
145956
- "deviceCategory",
145957
- "country",
145958
- "sessionSourceMedium"
145959
- ];
145960
- var GA4_REPORT_METRICS = [
145961
- "sessions",
145962
- "newUsers",
145963
- "totalUsers",
145964
- "activeUsers",
145965
- "eventCount",
145966
- "keyEvents",
145967
- "bounceRate",
145968
- "screenPageViews",
145969
- "screenPageViewsPerUser",
145970
- "averageSessionDuration"
145971
- ];
145972
- var GA4_PATH = {
145973
- overview: "AnalysisDataReportDataOverview",
145974
- channels: "AnalysisDataReportSessionDefaultChannelGroup",
145975
- pages: "AnalysisDataReportPagePath",
145976
- report: "AnalysisDataReport"
145977
- };
145978
- var PRESET_DIMENSIONS = {
145979
- overview: ["date"],
145980
- channels: ["sessionDefaultChannelGroup"],
145981
- pages: ["pagePath"]
145982
- };
145983
- function normalizeGa4PropertyId(raw) {
145984
- const text5 = (raw ?? "").trim().replace(/^properties\//i, "");
145985
- if (!/^\d+$/.test(text5)) {
145986
- throw new Error(`--property \u987B\u4E3A GA4 \u6570\u5B57\u8D44\u6E90 ID\uFF0C\u6536\u5230\u300C${raw ?? ""}\u300D`);
145987
- }
145988
- return text5;
145989
- }
145990
- function parseIsoDate2(raw, label2) {
145991
- const value = (raw ?? "").trim();
145992
- if (!/^\d{4}-\d{2}-\d{2}$/.test(value)) {
145993
- throw new Error(`${label2} \u987B\u4E3A YYYY-MM-DD\uFF0C\u6536\u5230\u300C${raw ?? ""}\u300D`);
145994
- }
145995
- const [year, month, day] = value.split("-").map((part) => Number(part));
145996
- const date = new Date(Date.UTC(year, month - 1, day));
145997
- if (date.getUTCFullYear() !== year || date.getUTCMonth() !== month - 1 || date.getUTCDate() !== day) {
145998
- throw new Error(`${label2} \u4E0D\u662F\u6709\u6548\u65E5\u671F\uFF1A${value}`);
145999
- }
146000
- return value;
146001
- }
146002
- function parseGa4FieldList(raw, allow, kind) {
146003
- const names = (raw ?? "").split(",").map((part) => part.trim()).filter(Boolean);
146004
- if (names.length === 0) {
146005
- throw new Error(`--${kind === "\u7EF4\u5EA6" ? "dimensions" : "metrics"} \u4E0D\u80FD\u4E3A\u7A7A\u3002\u5141\u8BB8\uFF1A${allow.join(", ")}`);
146006
- }
146007
- const allowed = new Set(allow);
146008
- const seen = /* @__PURE__ */ new Set();
146009
- for (const name2 of names) {
146010
- if (!allowed.has(name2)) {
146011
- throw new Error(`\u4E0D\u652F\u6301\u7684${kind}\u300C${name2}\u300D\u3002\u5141\u8BB8\uFF1A${allow.join(", ")}`);
146012
- }
146013
- if (seen.has(name2)) {
146014
- throw new Error(`${kind}\u300C${name2}\u300D\u91CD\u590D`);
146015
- }
146016
- seen.add(name2);
146017
- }
146018
- return names;
146019
- }
146020
- function buildGa4ReportUrl(googleApiUrl, kind, input) {
146021
- const account = input.account.trim();
146022
- if (!account) {
146023
- throw new Error("\u9700\u8981 --account\uFF1A\u5DF2\u7ED1\u5B9A\u7684 GoogleGA4 \u5A92\u4F53\u8D26\u53F7\uFF0C\u4E0D\u662F\u5E7F\u544A\u5BA2\u6237 ID");
146024
- }
146025
- const propertyId = normalizeGa4PropertyId(input.property);
146026
- const startDate = parseIsoDate2(input.start, "--start");
146027
- const endDate = parseIsoDate2(input.end, "--end");
146028
- if (startDate > endDate) {
146029
- throw new Error("--start \u4E0D\u80FD\u665A\u4E8E --end");
146030
- }
146031
- const dimensions = kind === "report" ? parseGa4FieldList(input.dimensions, GA4_REPORT_DIMENSIONS, "\u7EF4\u5EA6") : [...PRESET_DIMENSIONS[kind]];
146032
- const metrics = kind === "report" ? parseGa4FieldList(input.metrics, GA4_REPORT_METRICS, "\u6307\u6807") : [];
146033
- const params = new URLSearchParams();
146034
- params.set("mediaAccountId", account);
146035
- params.set("propertyId", propertyId);
146036
- params.set("startDate", startDate);
146037
- params.set("endDate", endDate);
146038
- if (kind === "report") {
146039
- params.set("dimensions", dimensions.join(","));
146040
- params.set("metrics", metrics.join(","));
146041
- }
146042
- const base2 = googleApiUrl.replace(/\/+$/, "");
146043
- return {
146044
- url: `${base2}/analysisreporting/media-account/${GA4_PATH[kind]}?${params.toString()}`,
146045
- query: { propertyId, startDate, endDate, dimensions, metrics }
146046
- };
146047
- }
146048
- function cellValue(cell5) {
146049
- return cell5?.value ?? cell5?.Value ?? "";
146050
- }
146051
- function periodRows(period) {
146052
- if (!period) return [];
146053
- return period.analyticsDataInfos ?? period.AnalyticsDataInfos ?? [];
146054
- }
146055
- function isPlaceholder(row, dimensionNames) {
146056
- const dimensions = row.dimension ?? row.Dimension ?? [];
146057
- const metrics = row.mtricInfos ?? row.MtricInfos ?? [];
146058
- if (dimensions.length === 0 || dimensions.length !== dimensionNames.length) return false;
146059
- const dimensionsMatch = dimensions.every((cell5, index) => cellValue(cell5) === dimensionNames[index]);
146060
- const metricsMatch = metrics.every((cell5) => {
146061
- const name2 = cell5.metric ?? cell5.Metric ?? "";
146062
- return name2 !== "" && cellValue(cell5) === name2;
146063
- });
146064
- return dimensionsMatch && metricsMatch;
146065
- }
146066
- function flattenGa4Rows(period, dimensionNames) {
146067
- const rows = [];
146068
- for (const info of periodRows(period)) {
146069
- if (isPlaceholder(info, dimensionNames)) continue;
146070
- const record2 = {};
146071
- const dimensions = info.dimension ?? info.Dimension ?? [];
146072
- dimensionNames.forEach((name2, index) => {
146073
- record2[name2] = cellValue(dimensions[index]);
146074
- });
146075
- for (const metric of info.mtricInfos ?? info.MtricInfos ?? []) {
146076
- const name2 = metric.metric ?? metric.Metric;
146077
- if (name2) record2[name2] = cellValue(metric);
146078
- }
146079
- rows.push(record2);
146080
- }
146081
- return rows;
146082
- }
146083
- function readEnvelope2(data) {
146084
- return {
146085
- current: data.analyticsDataReport ?? data.AnalyticsDataReport,
146086
- previous: data.lastAnalyticsDataReport ?? data.LastAnalyticsDataReport
146087
- };
146088
- }
146089
- function printPeriod(title, rows, dimensionNames) {
146090
- console.log(`
146091
- ${title}\uFF08${rows.length} \u884C\uFF09`);
146092
- if (rows.length === 0) {
146093
- console.log(" \u6CA1\u6709\u6570\u636E\u884C\u3002\n");
146094
- return;
146095
- }
146096
- const metricNames = [];
146097
- for (const row of rows) {
146098
- for (const key of Object.keys(row)) {
146099
- if (!dimensionNames.includes(key) && !metricNames.includes(key)) metricNames.push(key);
146100
- }
146101
- }
146102
- printCliTable(
146103
- rows,
146104
- [...dimensionNames, ...metricNames].map((key) => ({ key, header: key }))
146105
- );
146106
- }
146107
- async function runGa4(opts) {
146108
- let built;
146109
- try {
146110
- const config = loadConfig(opts.token);
146111
- built = buildGa4ReportUrl(requireGoogleApi(config), opts.kind, opts);
146112
- const data = await apiFetch2(built.url, config, { method: "GET" }, opts.verbose);
146113
- const { current, previous } = readEnvelope2(data ?? {});
146114
- const dimensions = built.query.dimensions;
146115
- const rows = flattenGa4Rows(current, dimensions);
146116
- const previousRows = flattenGa4Rows(previous, dimensions);
146117
- const payload = {
146118
- account: opts.account.trim(),
146119
- propertyId: built.query.propertyId,
146120
- startDate: built.query.startDate,
146121
- endDate: built.query.endDate,
146122
- dimensions,
146123
- rows,
146124
- previousRows
146125
- };
146126
- if (await emitCliJsonOrSnapshot(opts, {
146127
- section: `ga4-${opts.kind}`,
146128
- commandLabel: `ga4 ${opts.kind}`,
146129
- payload,
146130
- summaryExtras: { rows: rows.length, previousRows: previousRows.length }
146131
- })) {
146132
- return;
146133
- }
146134
- console.log(
146135
- `GA4 ${opts.kind} property=${built.query.propertyId} ${built.query.startDate} ~ ${built.query.endDate}`
146136
- );
146137
- console.log("\u6307\u6807\u4FDD\u6301 GA4 \u539F\u503C\u3002\u4E0A\u4E00\u5468\u671F\u7531\u7F51\u5173\u6309\u7B49\u957F\u533A\u95F4\u81EA\u52A8\u67E5\u8BE2\u3002");
146138
- printPeriod("\u672C\u671F", rows, dimensions);
146139
- printPeriod("\u4E0A\u4E00\u5468\u671F", previousRows, dimensions);
146140
- } catch (err) {
146141
- const message = err instanceof Error ? err.message : String(err);
146142
- console.error(`
146143
- \u274C GA4 \u62A5\u8868\u5931\u8D25\uFF1A${message}
146144
- `);
146145
- if (opts.verbose && err instanceof Error && err.stack) console.error(err.stack);
146146
- process.exit(1);
146147
- }
146148
- }
146149
- function addGa4QueryOptions(cmd) {
146150
- attachJsonOutOption(cmd);
146151
- return cmd.requiredOption("--account <id>", "\u5DF2\u7ED1\u5B9A\u7684 GoogleGA4 \u5A92\u4F53\u8D26\u53F7\u3002\u7528\u6765\u53D6\u6388\u6743\uFF0C\u4E0D\u662F\u5E7F\u544A\u5BA2\u6237 ID").requiredOption("--property <id>", "GA4 \u6570\u5B57\u8D44\u6E90 ID\uFF0C\u4F8B\u5982 123456789").requiredOption("--start <date>", "\u5F00\u59CB\u65E5\u671F YYYY-MM-DD").requiredOption("--end <date>", "\u7ED3\u675F\u65E5\u671F YYYY-MM-DD").option("--verbose", "\u8F93\u51FA\u8BE6\u7EC6\u9519\u8BEF\u5806\u6808").option("--token <jwt>", "\u4E34\u65F6\u4F7F\u7528\u7684 JWT Token\uFF08\u8986\u76D6 ~/.siluzan/config.json\uFF09");
146152
- }
146153
- function register28(program2) {
146154
- const ga4 = program2.command("ga4").description("GA4 \u53EA\u8BFB\u6307\u6807\uFF08\u4F1A\u8BDD\u3001\u7528\u6237\u3001\u4E8B\u4EF6\u3001\u6E20\u9053\u3001\u9875\u9762\uFF09\u3002\u8D26\u53F7\u662F\u5DF2\u7ED1\u5B9A\u7684 GoogleGA4\uFF0C\u4E0D\u662F\u5E7F\u544A\u5BA2\u6237 ID");
146155
- addGa4QueryOptions(
146156
- ga4.command("overview").description("\u6309\u65E5\u7684\u4F1A\u8BDD\u3001\u7528\u6237\u3001\u4E8B\u4EF6\u3001\u5173\u952E\u4E8B\u4EF6\u3001\u8DF3\u51FA\u7387\u548C\u505C\u7559\u65F6\u957F\uFF0C\u542B\u4E0A\u4E00\u5468\u671F")
146157
- ).action(async (opts) => {
146158
- await runGa4({ ...opts, kind: "overview" });
146159
- });
146160
- addGa4QueryOptions(
146161
- ga4.command("channels").description("\u6309\u9ED8\u8BA4\u6E20\u9053\u5206\u7EC4\u7684\u4F1A\u8BDD\u548C\u4E8B\u4EF6\uFF0C\u542B\u4E0A\u4E00\u5468\u671F")
146162
- ).action(async (opts) => {
146163
- await runGa4({ ...opts, kind: "channels" });
146164
- });
146165
- addGa4QueryOptions(
146166
- ga4.command("pages").description("\u6309\u9875\u9762\u8DEF\u5F84\u7684\u4F1A\u8BDD\u548C\u4E8B\u4EF6\uFF0C\u542B\u4E0A\u4E00\u5468\u671F")
146167
- ).action(async (opts) => {
146168
- await runGa4({ ...opts, kind: "pages" });
146169
- });
146170
- addGa4QueryOptions(
146171
- ga4.command("report").description("\u6309\u767D\u540D\u5355\u91CC\u7684\u7EF4\u5EA6\u548C\u6307\u6807\u67E5 GA4\u3002\u4E8B\u4EF6\u793A\u4F8B\uFF1A--dimensions eventName --metrics eventCount,keyEvents")
146172
- ).requiredOption("--dimensions <names>", `\u7EF4\u5EA6\uFF0C\u9017\u53F7\u5206\u9694\u3002\u5141\u8BB8\uFF1A${GA4_REPORT_DIMENSIONS.join(", ")}`).requiredOption("--metrics <names>", `\u6307\u6807\uFF0C\u9017\u53F7\u5206\u9694\u3002\u5141\u8BB8\uFF1A${GA4_REPORT_METRICS.join(", ")}`).action(async (opts) => {
146173
- await runGa4({ ...opts, kind: "report" });
146174
- });
146175
- }
146176
-
146177
146951
  // src/index.ts
146178
146952
  init_google_analysis3();
146179
146953
  init_google_analysis_batch();
@@ -147097,12 +147871,12 @@ var TEMPLATE_BASENAMES2 = {
147097
147871
  html: "meta-period-report.html"
147098
147872
  };
147099
147873
  var INJECT_MARKER2 = "window.__META_PERIOD_REPORT__ = window.__META_PERIOD_REPORT__ || null;";
147100
- function resolveSkillTemplatePath5(basename15) {
147874
+ function resolveSkillTemplatePath5(basename14) {
147101
147875
  const dir = path47.dirname(fileURLToPath11(import.meta.url));
147102
147876
  const candidates = [
147103
- path47.join(dir, "skill", "report-templates", basename15),
147104
- path47.join(dir, "skill", "siluzan-ads", "report-templates", basename15),
147105
- path47.join(dir, "..", "..", "assets", "siluzan-ads", "report-templates", basename15)
147877
+ path47.join(dir, "skill", "report-templates", basename14),
147878
+ path47.join(dir, "skill", "siluzan-ads", "report-templates", basename14),
147879
+ path47.join(dir, "..", "..", "assets", "siluzan-ads", "report-templates", basename14)
147106
147880
  ];
147107
147881
  for (const p of candidates) {
147108
147882
  if (fs40.existsSync(p)) return p;
@@ -147577,12 +148351,12 @@ init_lang();
147577
148351
  init_html();
147578
148352
  var TEMPLATE_BASENAME3 = "meta-account-diagnosis-report.html";
147579
148353
  var INJECT_MARKER3 = "window.__META_DIAGNOSIS_REPORT__ = window.__META_DIAGNOSIS_REPORT__ || null;";
147580
- function resolveSkillTemplatePath6(basename15) {
148354
+ function resolveSkillTemplatePath6(basename14) {
147581
148355
  const dir = path49.dirname(fileURLToPath12(import.meta.url));
147582
148356
  const candidates = [
147583
- path49.join(dir, "skill", "report-templates", basename15),
147584
- path49.join(dir, "skill", "siluzan-ads", "report-templates", basename15),
147585
- path49.join(dir, "..", "..", "assets", "siluzan-ads", "report-templates", basename15)
148357
+ path49.join(dir, "skill", "report-templates", basename14),
148358
+ path49.join(dir, "skill", "siluzan-ads", "report-templates", basename14),
148359
+ path49.join(dir, "..", "..", "assets", "siluzan-ads", "report-templates", basename14)
147586
148360
  ];
147587
148361
  for (const p of candidates) {
147588
148362
  if (fs42.existsSync(p)) return p;
@@ -149715,12 +150489,12 @@ init_lang();
149715
150489
  init_html();
149716
150490
  var TEMPLATE_BASENAME4 = "bing-period-report.html";
149717
150491
  var INJECT_MARKER4 = "window.__BING_PERIOD_REPORT__ = window.__BING_PERIOD_REPORT__ || null;";
149718
- function resolveSkillTemplatePath7(basename15) {
150492
+ function resolveSkillTemplatePath7(basename14) {
149719
150493
  const dir = path53.dirname(fileURLToPath13(import.meta.url));
149720
150494
  const candidates = [
149721
- path53.join(dir, "skill", "report-templates", basename15),
149722
- path53.join(dir, "skill", "siluzan-ads", "report-templates", basename15),
149723
- path53.join(dir, "..", "..", "assets", "siluzan-ads", "report-templates", basename15)
150495
+ path53.join(dir, "skill", "report-templates", basename14),
150496
+ path53.join(dir, "skill", "siluzan-ads", "report-templates", basename14),
150497
+ path53.join(dir, "..", "..", "assets", "siluzan-ads", "report-templates", basename14)
149724
150498
  ];
149725
150499
  for (const p of candidates) {
149726
150500
  if (fs44.existsSync(p)) return p;
@@ -150730,12 +151504,12 @@ init_lang();
150730
151504
  init_html();
150731
151505
  var TEMPLATE_BASENAME5 = "tiktok-period-report.html";
150732
151506
  var INJECT_MARKER5 = "window.__TIKTOK_PERIOD_REPORT__ = window.__TIKTOK_PERIOD_REPORT__ || null;";
150733
- function resolveSkillTemplatePath8(basename15) {
151507
+ function resolveSkillTemplatePath8(basename14) {
150734
151508
  const dir = path56.dirname(fileURLToPath14(import.meta.url));
150735
151509
  const candidates = [
150736
- path56.join(dir, "skill", "report-templates", basename15),
150737
- path56.join(dir, "skill", "siluzan-ads", "report-templates", basename15),
150738
- path56.join(dir, "..", "..", "assets", "siluzan-ads", "report-templates", basename15)
151510
+ path56.join(dir, "skill", "report-templates", basename14),
151511
+ path56.join(dir, "skill", "siluzan-ads", "report-templates", basename14),
151512
+ path56.join(dir, "..", "..", "assets", "siluzan-ads", "report-templates", basename14)
150739
151513
  ];
150740
151514
  for (const p of candidates) {
150741
151515
  if (fs46.existsSync(p)) return p;
@@ -150983,29 +151757,6 @@ function daysInclusive(start, end) {
150983
151757
  const b = new Date(end.getFullYear(), end.getMonth(), end.getDate());
150984
151758
  return Math.floor((b.getTime() - a.getTime()) / 864e5) + 1;
150985
151759
  }
150986
- var REPORT_LEVEL_ID = {
150987
- AUCTION_ADVERTISER: "",
150988
- AUCTION_CAMPAIGN: "campaign_id",
150989
- AUCTION_ADGROUP: "adgroup_id",
150990
- AUCTION_AD: "ad_id"
150991
- };
150992
- var REPORT_ENTITY_IDS = ["campaign_id", "adgroup_id", "ad_id"];
150993
- function tiktokReportDimensionError(dataLevel, dimensions) {
150994
- const level = dataLevel.trim();
150995
- if (!Object.prototype.hasOwnProperty.call(REPORT_LEVEL_ID, level)) {
150996
- return "data-level \u53EA\u63A5\u53D7 AUCTION_ADVERTISER\u3001AUCTION_CAMPAIGN\u3001AUCTION_ADGROUP\u3001AUCTION_AD";
150997
- }
150998
- const dims = dimensions.split(",").map((item) => item.trim()).filter(Boolean);
150999
- const own = REPORT_LEVEL_ID[level] ?? "";
151000
- if (own && !dims.includes(own)) {
151001
- return `${level} \u7684 dimensions \u5FC5\u987B\u5305\u542B ${own}`;
151002
- }
151003
- const extra = REPORT_ENTITY_IDS.filter((name2) => name2 !== own && dims.includes(name2));
151004
- if (extra.length > 0) {
151005
- return own ? `${level} \u4E0D\u80FD\u5E26 ${extra.join("\u3001")}` : "AUCTION_ADVERTISER \u4E0D\u80FD\u5E26 campaign_id\u3001adgroup_id \u6216 ad_id";
151006
- }
151007
- return void 0;
151008
- }
151009
151760
  function assertTikTokOfficialReportRange(startDate, endDate, dimensions) {
151010
151761
  const start = startDate.trim();
151011
151762
  const end = endDate.trim();
@@ -151051,8 +151802,7 @@ function unwrapTikTokEnvelope(raw, label2) {
151051
151802
  if (code !== 0 && code !== void 0) {
151052
151803
  throw new Error(`${label2} \u4E1A\u52A1\u5931\u8D25 code=${code}\uFF1A${env.message ?? "\u672A\u77E5\u9519\u8BEF"}`);
151053
151804
  }
151054
- const data = env.data;
151055
- const list = Array.isArray(data?.list) ? data.list : Array.isArray(data?.pixels) ? data.pixels : [];
151805
+ const list = Array.isArray(env.data?.list) ? env.data.list : [];
151056
151806
  const info = env.data?.page_info ?? {};
151057
151807
  const page = parseTikTokNumber(info.page) ?? 1;
151058
151808
  const pageSize = parseTikTokNumber(info.page_size) ?? list.length;
@@ -151457,13 +152207,6 @@ async function runTikTokOfficialReport(opts) {
151457
152207
  console.error("\n\u274C --data-level / --dimensions / --metrics \u5747\u4E3A\u5FC5\u586B\u3002\n");
151458
152208
  process.exit(1);
151459
152209
  }
151460
- const dimensionError = tiktokReportDimensionError(dataLevel, dimensions);
151461
- if (dimensionError) {
151462
- console.error(`
151463
- \u274C ${dimensionError}
151464
- `);
151465
- process.exit(1);
151466
- }
151467
152210
  const { startDate, endDate } = assertTikTokOfficialReportRange(opts.start, opts.end, dimensions);
151468
152211
  const serviceType = (opts.serviceType ?? "AUCTION").trim() || "AUCTION";
151469
152212
  const pageSize = resolveTikTokPageSize(opts.pageSize, TIKTOK_REPORT_PAGE_SIZE_DEFAULT);
@@ -151707,700 +152450,12 @@ async function runTikTokAdStatus(opts) {
151707
152450
  );
151708
152451
  }
151709
152452
 
151710
- // src/commands/tiktok-analysis/media-run.ts
151711
- init_dist();
151712
- init_auth();
151713
- init_cli_json_snapshot();
151714
- import { readFileSync as readFileSync21 } from "fs";
151715
- import { basename as basename14 } from "path";
151716
- init_cli_table();
151717
-
151718
- // src/commands/tiktok-analysis/media.ts
151719
- var TIKTOK_IDENTITY_TYPES = [
151720
- "CUSTOMIZED_USER",
151721
- "AUTH_CODE",
151722
- "TT_USER",
151723
- "BC_AUTH_TT"
151724
- ];
151725
- var PIXEL_PAGE_SIZE_MAX = 20;
151726
- var LIST_PAGE_SIZE_DEFAULT = 100;
151727
- function assertHttpsAssetUrl(raw, label2) {
151728
- const text5 = (raw ?? "").trim();
151729
- let parsed;
151730
- try {
151731
- parsed = new URL(text5);
151732
- } catch {
151733
- throw new Error(`${label2} \u5FC5\u987B\u662F https \u5730\u5740\u3002\u7F51\u5173\u4E0D\u63A5\u6536\u672C\u5730\u6587\u4EF6`);
151734
- }
151735
- if (parsed.protocol !== "https:") {
151736
- throw new Error(`${label2} \u5FC5\u987B\u662F https \u5730\u5740\u3002\u7F51\u5173\u4E0D\u63A5\u6536\u672C\u5730\u6587\u4EF6`);
151737
- }
151738
- return text5;
151739
- }
151740
- function imageUploadBody(advertiserId, imageUrl) {
151741
- return {
151742
- advertiser_id: advertiserId,
151743
- upload_type: "UPLOAD_BY_URL",
151744
- image_url: assertHttpsAssetUrl(imageUrl, "\u56FE\u7247\u5730\u5740")
151745
- };
151746
- }
151747
- function imageUploadPath(account) {
151748
- return `tiktokadmanagement/ad/UploadImage/${TIKTOK_MEDIA_TYPE}/${encodeURIComponent(account)}`;
151749
- }
151750
- function videoUploadBody(advertiserId, videoUrl, fileName) {
151751
- const name2 = fileName?.trim();
151752
- return {
151753
- advertiser_id: advertiserId,
151754
- upload_type: "UPLOAD_BY_URL",
151755
- video_url: assertHttpsAssetUrl(videoUrl, "\u89C6\u9891\u5730\u5740"),
151756
- ...name2 ? { file_name: name2 } : {},
151757
- flaw_detect: false,
151758
- auto_fix_enabled: false,
151759
- auto_bind_enabled: false
151760
- };
151761
- }
151762
- function videoUploadPath() {
151763
- return `tiktokadmanagement/ad/UploadVideo/${TIKTOK_MEDIA_TYPE}`;
151764
- }
151765
- function videoUploadByUrlBody(advertiserId, videoUrl, videoName) {
151766
- const name2 = videoName?.trim();
151767
- return {
151768
- MediaCustomerId: advertiserId,
151769
- VideoUrl: assertHttpsAssetUrl(videoUrl, "\u89C6\u9891\u5730\u5740"),
151770
- ...name2 ? { VideoName: name2 } : {}
151771
- };
151772
- }
151773
- function videoUploadByUrlPath() {
151774
- return `tiktokadmanagement/ad/UploadVideoByUrl/${TIKTOK_MEDIA_TYPE}`;
151775
- }
151776
- function videoInfoQuery(account, videoIds, materialIds) {
151777
- const videos = splitIds(videoIds, "video-ids");
151778
- const materials = splitIds(materialIds, "material-ids");
151779
- if (videos.length === 0 && materials.length === 0) {
151780
- throw new Error("video-info \u8981 --video-ids \u6216 --material-ids");
151781
- }
151782
- const q = new URLSearchParams({ mediacustomerId: account });
151783
- if (videos.length > 0) q.set("videoIds", videos.join(","));
151784
- if (materials.length > 0) q.set("material_ids", materials.join(","));
151785
- return `tiktokadmanagement/ad/getvideoinfo/${TIKTOK_MEDIA_TYPE}?${q}`;
151786
- }
151787
- function parseIdentityType(raw) {
151788
- const text5 = (raw ?? "").trim();
151789
- if (!text5) return void 0;
151790
- const value = text5.toUpperCase();
151791
- if (!TIKTOK_IDENTITY_TYPES.includes(value)) {
151792
- throw new Error(`identity-type \u53EA\u63A5\u53D7 ${TIKTOK_IDENTITY_TYPES.join(" / ")}`);
151793
- }
151794
- return value;
151795
- }
151796
- function identityListPath(account, pageNum, pageSize, identityType) {
151797
- const q = new URLSearchParams({
151798
- mediacustomerId: account,
151799
- pageNum: String(pageNum),
151800
- pageSize: String(pageSize)
151801
- });
151802
- const type = parseIdentityType(identityType);
151803
- if (type) q.set("IdentityType", type);
151804
- return `tiktokadmanagement/ad/${TIKTOK_MEDIA_TYPE}/GetIdentityIdList?${q}`;
151805
- }
151806
- function identityCreateBody(advertiserId, displayName, imageUri) {
151807
- const display_name = (displayName ?? "").trim();
151808
- const image_uri = (imageUri ?? "").trim();
151809
- if (!display_name) throw new Error("display-name \u4E0D\u80FD\u4E3A\u7A7A");
151810
- if (!image_uri) {
151811
- throw new Error("image-uri \u4E0D\u80FD\u4E3A\u7A7A\u3002\u5148 image-upload\uFF0C\u7528\u8FD4\u56DE\u7684 image_id");
151812
- }
151813
- return { advertiser_id: advertiserId, display_name, image_uri };
151814
- }
151815
- function identityCreatePath() {
151816
- return `tiktokadmanagement/ad/CreateIdentity/${TIKTOK_MEDIA_TYPE}`;
151817
- }
151818
- function audienceListPath(account, pageNum, pageSize, audienceIds) {
151819
- const q = new URLSearchParams({
151820
- mediacustomerId: account,
151821
- pageNum: String(pageNum),
151822
- pageSize: String(pageSize)
151823
- });
151824
- const ids = splitIds(audienceIds, "audience-ids");
151825
- if (ids.length > 0) q.set("customAudienceIds", ids.join(","));
151826
- return `tiktokadgroupmanagement/adgroup/${TIKTOK_MEDIA_TYPE}/GetCustomAudienceList?${q}`;
151827
- }
151828
- function pixelListPath(account, pageNum, pageSize, filter) {
151829
- const q = new URLSearchParams({
151830
- mediacustomerId: account,
151831
- pageNum: String(pageNum),
151832
- pageSize: String(pageSize)
151833
- });
151834
- const code = filter?.code?.trim();
151835
- const pixelId = filter?.pixelId?.trim();
151836
- const name2 = filter?.name?.trim();
151837
- if (code) q.set("code", code);
151838
- if (pixelId) q.set("pixelId", pixelId);
151839
- if (name2) q.set("name", name2);
151840
- return `tiktokadgroupmanagement/adgroup/${TIKTOK_MEDIA_TYPE}/GetPixelList?${q}`;
151841
- }
151842
- function pixelCreateBody(advertiserId, name2, category) {
151843
- const pixel_name = (name2 ?? "").trim();
151844
- const pixel_category = (category ?? "").trim();
151845
- if (!pixel_name || pixel_name.length > 40) {
151846
- throw new Error("\u50CF\u7D20\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A\uFF0C\u4E14\u4E0D\u8D85\u8FC7 40 \u4E2A\u5B57\u7B26");
151847
- }
151848
- if (!pixel_category) throw new Error("pixel-category \u4E0D\u80FD\u4E3A\u7A7A");
151849
- return { advertiser_id: advertiserId, pixel_name, pixel_category };
151850
- }
151851
- function pixelCreatePath(account) {
151852
- return `tiktokadgroupmanagement/adgroup/CreatePixel/${TIKTOK_MEDIA_TYPE}/${encodeURIComponent(account)}`;
151853
- }
151854
- function parsePixelEvents(raw) {
151855
- const text5 = (raw ?? "").trim();
151856
- if (!text5) throw new Error("pixel \u4E8B\u4EF6\u9700\u8981 --events\uFF0C\u5185\u5BB9\u662F\u975E\u7A7A JSON \u6570\u7EC4");
151857
- let parsed;
151858
- try {
151859
- parsed = JSON.parse(text5);
151860
- } catch {
151861
- throw new Error("pixel \u4E8B\u4EF6\u4E0D\u662F\u5408\u6CD5 JSON");
151862
- }
151863
- if (!Array.isArray(parsed) || parsed.length < 1) {
151864
- throw new Error("pixel \u4E8B\u4EF6\u5FC5\u987B\u662F\u975E\u7A7A JSON \u6570\u7EC4");
151865
- }
151866
- return parsed;
151867
- }
151868
- function pixelEventBody(advertiserId, pixelId, events) {
151869
- const pixel_id = (pixelId ?? "").trim();
151870
- if (!pixel_id) throw new Error("pixel-id \u4E0D\u80FD\u4E3A\u7A7A");
151871
- if (events.length < 1) throw new Error("pixel \u4E8B\u4EF6\u5FC5\u987B\u662F\u975E\u7A7A JSON \u6570\u7EC4");
151872
- return { advertiser_id: advertiserId, pixel_id, pixel_events: events };
151873
- }
151874
- function pixelEventPath() {
151875
- return `tiktokadgroupmanagement/adgroup/CreatePixelEvent/${TIKTOK_MEDIA_TYPE}`;
151876
- }
151877
- function assertPixelStatsRange(start, end) {
151878
- const startDate = start.trim();
151879
- const endDate = end.trim();
151880
- if (!/^\d{4}-\d{2}-\d{2}$/.test(startDate) || !/^\d{4}-\d{2}-\d{2}$/.test(endDate)) {
151881
- throw new Error("pixel \u7EDF\u8BA1\u7684 start / end \u987B\u662F YYYY-MM-DD");
151882
- }
151883
- const startMs = Date.parse(`${startDate}T00:00:00Z`);
151884
- const endMs = Date.parse(`${endDate}T00:00:00Z`);
151885
- if (Number.isNaN(startMs) || Number.isNaN(endMs) || endMs < startMs) {
151886
- throw new Error("pixel \u7EDF\u8BA1\u7684 end \u4E0D\u80FD\u65E9\u4E8E start");
151887
- }
151888
- const days = Math.round((endMs - startMs) / 864e5);
151889
- if (days > 30) throw new Error("pixel \u7EDF\u8BA1\u533A\u95F4\u8DE8\u5EA6\u5FC5\u987B \u2264 30 \u5929");
151890
- return { start: startDate, end: endDate };
151891
- }
151892
- function pixelStatsPath(account, pixelIdsRaw, start, end) {
151893
- const ids = splitIds(pixelIdsRaw, "pixel-ids");
151894
- if (ids.length < 1 || ids.length > 10) {
151895
- throw new Error("pixel-ids \u9700\u8981 1 \u5230 10 \u4E2A\u50CF\u7D20 ID");
151896
- }
151897
- const range = assertPixelStatsRange(start, end);
151898
- const q = new URLSearchParams({
151899
- advertiser_id: account,
151900
- PixelIds: ids.join(","),
151901
- "date_range.start_date": range.start,
151902
- "date_range.end_date": range.end
151903
- });
151904
- return `tiktokadgroupmanagement/adgroup/GetPixelStats/${TIKTOK_MEDIA_TYPE}/${encodeURIComponent(account)}?${q}`;
151905
- }
151906
- function ctaPortfolioPath(account, contentType, assetType) {
151907
- const content = (contentType ?? "").trim();
151908
- const asset = (assetType ?? "").trim();
151909
- if (!content || !asset) throw new Error("content-type \u548C asset-type \u90FD\u4E0D\u80FD\u4E3A\u7A7A");
151910
- const q = new URLSearchParams({
151911
- mediacustomerId: account,
151912
- contentType: content,
151913
- assetType: asset
151914
- });
151915
- return `tiktokadmanagement/ad/${TIKTOK_MEDIA_TYPE}/GetPortfolio?${q}`;
151916
- }
151917
- function smartTextBody(advertiserId, input) {
151918
- const keywords = splitIds(input.keywords, "keywords");
151919
- const adgroup_id = input.adgroupId?.trim();
151920
- const industry_id = input.industryId?.trim();
151921
- if (!adgroup_id) {
151922
- throw new Error("\u667A\u80FD\u6587\u6848\u5FC5\u987B\u5E26 adgroup-id\uFF0C\u5B98\u65B9\u63A5\u53E3\u4E0D\u63A5\u53D7\u53EA\u6709\u5173\u952E\u8BCD\u6216\u884C\u4E1A\u7684\u8BF7\u6C42");
151923
- }
151924
- const language = input.language?.trim();
151925
- const param_type = input.paramType?.trim();
151926
- let limit;
151927
- if (input.limit != null && input.limit.trim() !== "") {
151928
- limit = Number(input.limit.trim());
151929
- if (!Number.isInteger(limit) || limit <= 0) throw new Error("limit \u5FC5\u987B\u662F\u5927\u4E8E 0 \u7684\u6574\u6570");
151930
- }
151931
- return {
151932
- advertiser_id: advertiserId,
151933
- ...adgroup_id ? { adgroup_id } : {},
151934
- ...param_type ? { param_type } : {},
151935
- ...language ? { language } : {},
151936
- ...industry_id ? { industry_id } : {},
151937
- ...keywords.length > 0 ? { keywords } : {},
151938
- ...limit != null ? { limit } : {}
151939
- };
151940
- }
151941
- function smartTextPath() {
151942
- return `tiktokadmanagement/ad/${TIKTOK_MEDIA_TYPE}/GetSmartText`;
151943
- }
151944
- function resolveMediaPageSize(raw, kind) {
151945
- const fallback = kind === "pixel" ? PIXEL_PAGE_SIZE_MAX : LIST_PAGE_SIZE_DEFAULT;
151946
- const size = resolveTikTokPageSize(raw, fallback);
151947
- return kind === "pixel" ? Math.min(size, PIXEL_PAGE_SIZE_MAX) : size;
151948
- }
151949
- function splitIds(raw, label2) {
151950
- if (raw == null || raw.trim() === "") return [];
151951
- const ids = raw.split(",").map((part) => part.trim()).filter(Boolean);
151952
- if (raw.trim() !== "" && ids.length === 0) {
151953
- throw new Error(`${label2} \u4E0D\u80FD\u662F\u7A7A\u5217\u8868`);
151954
- }
151955
- return ids;
151956
- }
151957
-
151958
- // src/commands/tiktok-analysis/media-run.ts
151959
- function fail8(label2, err) {
151960
- const msg = err instanceof Error ? err.message : String(err);
151961
- console.error(`
151962
- \u274C ${label2}\uFF1A${msg}
151963
- `);
151964
- process.exit(1);
151965
- }
151966
- function assertBusinessOk(payload, label2) {
151967
- if (!payload || typeof payload !== "object") return;
151968
- const code = payload.code;
151969
- if (code === void 0 || code === 0 || code === "0") return;
151970
- const message = payload.message ?? "\u672A\u77E5\u9519\u8BEF";
151971
- throw new Error(`${label2} \u4E1A\u52A1\u5931\u8D25 code=${String(code)}\uFF1A${message}`);
151972
- }
151973
- async function requestTikTok(method, path61, body, opts, section, commandLabel) {
151974
- const advertiserId = assertTikTokAccountId(opts.account);
151975
- const config = loadConfig(opts.token);
151976
- const url = `${requireTikTokApiUrl(config)}/${path61}`;
151977
- const payload = await apiFetch2(
151978
- url,
151979
- config,
151980
- method === "POST" ? { method: "POST", body: JSON.stringify(body) } : {},
151981
- opts.verbose
151982
- );
151983
- assertBusinessOk(payload, commandLabel);
151984
- const emitted = await emitCliJsonOrSnapshot(
151985
- { jsonOut: opts.jsonOut },
151986
- { section, commandLabel, payload, idSuffix: advertiserId }
151987
- );
151988
- if (emitted) return;
151989
- console.log(`
151990
- \u2705 ${commandLabel}
151991
- `);
151992
- console.log(JSON.stringify(payload, null, 2));
151993
- console.log();
151994
- }
151995
- async function requestTikTokList(buildPath, opts, kind, section, commandLabel, columns) {
151996
- const advertiserId = assertTikTokAccountId(opts.account);
151997
- const config = loadConfig(opts.token);
151998
- const base2 = requireTikTokApiUrl(config);
151999
- const pageSize = resolveMediaPageSize(opts.pageSize, kind);
152000
- let result;
152001
- try {
152002
- result = await fetchTikTokPagedList(
152003
- config,
152004
- (pageNum, size) => `${base2}/${buildPath(pageNum, size)}`,
152005
- { pageSize, verbose: !!opts.verbose, label: commandLabel }
152006
- );
152007
- } catch (err) {
152008
- fail8(commandLabel, err);
152009
- }
152010
- const payload = wrapListJson({
152011
- page: 1,
152012
- pageSize,
152013
- total: result.totalNumber,
152014
- items: result.items
152015
- });
152016
- if (await emitCliJsonOrSnapshot(
152017
- { jsonOut: opts.jsonOut },
152018
- { section, commandLabel, payload, idSuffix: advertiserId }
152019
- )) {
152020
- return;
152021
- }
152022
- console.log(`
152023
- ${commandLabel}\uFF08${advertiserId}\uFF0C\u5171 ${result.totalNumber} \u6761\uFF09
152024
- `);
152025
- if (result.items.length === 0) {
152026
- console.log(" \u6682\u65E0\u6570\u636E\u3002\n");
152027
- return;
152028
- }
152029
- printCliTable(
152030
- result.items.map((row) => {
152031
- const out = {};
152032
- for (const column of columns) out[column.key] = pick2(row, column.fields);
152033
- return out;
152034
- }),
152035
- columns.map((column) => ({ key: column.key, header: column.header }))
152036
- );
152037
- }
152038
- function pick2(row, fields) {
152039
- for (const field6 of fields) {
152040
- const value = row[field6];
152041
- if (value != null && value !== "") return String(value);
152042
- }
152043
- return "";
152044
- }
152045
- function assertCtaCommit() {
152046
- if (isWriteAuditCommitRequiredSatisfied()) return;
152047
- console.error(
152048
- '\n\u274C \u8FD9\u6761\u547D\u4EE4\u4F1A\u521B\u5EFA CTA \u7EC4\u5408\uFF0C\u5FC5\u987B\u63D0\u4F9B\u8BF4\u660E\uFF1A\u8BF7\u5728\u547D\u4EE4\u672B\u5C3E\u52A0 --commit "\u7B80\u77ED\u8BF4\u660E"\n'
152049
- );
152050
- process.exit(1);
152051
- }
152052
- async function runTikTokImageUpload(opts) {
152053
- const account = assertTikTokAccountId(opts.account);
152054
- let body;
152055
- try {
152056
- body = imageUploadBody(account, opts.imageUrl);
152057
- } catch (err) {
152058
- fail8("\u4E0A\u4F20\u56FE\u7247\u5931\u8D25", err);
152059
- }
152060
- try {
152061
- await requestTikTok("POST", imageUploadPath(account), body, opts, "tiktok-image-upload", "tiktok-analysis image-upload");
152062
- } catch (err) {
152063
- fail8("\u4E0A\u4F20\u56FE\u7247\u5931\u8D25", err);
152064
- }
152065
- }
152066
- async function runTikTokVideoUpload(opts) {
152067
- const account = assertTikTokAccountId(opts.account);
152068
- let body;
152069
- try {
152070
- body = videoUploadBody(account, opts.videoUrl, opts.name);
152071
- } catch (err) {
152072
- fail8("\u4E0A\u4F20\u89C6\u9891\u5931\u8D25", err);
152073
- }
152074
- try {
152075
- await requestTikTok("POST", videoUploadPath(), body, opts, "tiktok-video-upload", "tiktok-analysis video-upload");
152076
- } catch (err) {
152077
- fail8("\u4E0A\u4F20\u89C6\u9891\u5931\u8D25", err);
152078
- }
152079
- }
152080
- async function runTikTokVideoUploadByUrl(opts) {
152081
- const account = assertTikTokAccountId(opts.account);
152082
- let body;
152083
- try {
152084
- body = videoUploadByUrlBody(account, opts.videoUrl, opts.name);
152085
- } catch (err) {
152086
- fail8("\u4E0A\u4F20\u89C6\u9891\u5931\u8D25", err);
152087
- }
152088
- try {
152089
- await requestTikTok(
152090
- "POST",
152091
- videoUploadByUrlPath(),
152092
- body,
152093
- opts,
152094
- "tiktok-video-upload-url",
152095
- "tiktok-analysis video-upload-url"
152096
- );
152097
- } catch (err) {
152098
- fail8("\u4E0A\u4F20\u89C6\u9891\u5931\u8D25", err);
152099
- }
152100
- }
152101
- async function runTikTokVideoInfo(opts) {
152102
- const account = assertTikTokAccountId(opts.account);
152103
- let path61;
152104
- try {
152105
- path61 = videoInfoQuery(account, opts.videoIds, opts.materialIds);
152106
- } catch (err) {
152107
- fail8("\u67E5\u8BE2\u89C6\u9891\u5931\u8D25", err);
152108
- }
152109
- try {
152110
- await requestTikTok("GET", path61, void 0, opts, "tiktok-video-info", "tiktok-analysis video-info");
152111
- } catch (err) {
152112
- fail8("\u67E5\u8BE2\u89C6\u9891\u5931\u8D25", err);
152113
- }
152114
- }
152115
- async function runTikTokIdentityList(opts) {
152116
- const account = assertTikTokAccountId(opts.account);
152117
- try {
152118
- await requestTikTokList(
152119
- (pageNum, pageSize) => identityListPath(account, pageNum, pageSize, opts.identityType),
152120
- opts,
152121
- "list",
152122
- "tiktok-identity-list",
152123
- "tiktok-analysis identity-list",
152124
- [
152125
- { key: "identityId", header: "\u8EAB\u4EFDID", fields: ["identity_id", "identityId"] },
152126
- { key: "identityType", header: "\u7C7B\u578B", fields: ["identity_type", "identityType"] },
152127
- { key: "displayName", header: "\u540D\u79F0", fields: ["display_name", "displayName"] }
152128
- ]
152129
- );
152130
- } catch (err) {
152131
- fail8("\u67E5\u8BE2\u8EAB\u4EFD\u5931\u8D25", err);
152132
- }
152133
- }
152134
- async function runTikTokIdentityCreate(opts) {
152135
- const account = assertTikTokAccountId(opts.account);
152136
- let body;
152137
- try {
152138
- body = identityCreateBody(account, opts.displayName, opts.imageUri);
152139
- } catch (err) {
152140
- fail8("\u521B\u5EFA\u8EAB\u4EFD\u5931\u8D25", err);
152141
- }
152142
- try {
152143
- await requestTikTok(
152144
- "POST",
152145
- identityCreatePath(),
152146
- body,
152147
- opts,
152148
- "tiktok-identity-create",
152149
- "tiktok-analysis identity-create"
152150
- );
152151
- } catch (err) {
152152
- fail8("\u521B\u5EFA\u8EAB\u4EFD\u5931\u8D25", err);
152153
- }
152154
- }
152155
- async function runTikTokAudienceList(opts) {
152156
- const account = assertTikTokAccountId(opts.account);
152157
- try {
152158
- await requestTikTokList(
152159
- (pageNum, pageSize) => audienceListPath(account, pageNum, pageSize, opts.audienceIds),
152160
- opts,
152161
- "list",
152162
- "tiktok-audience-list",
152163
- "tiktok-analysis audience-list",
152164
- [
152165
- { key: "audienceId", header: "\u53D7\u4F17ID", fields: ["audience_id", "custom_audience_id"] },
152166
- { key: "name", header: "\u540D\u79F0", fields: ["name", "custom_audience_name"] },
152167
- { key: "audienceType", header: "\u7C7B\u578B", fields: ["audience_type"] }
152168
- ]
152169
- );
152170
- } catch (err) {
152171
- fail8("\u67E5\u8BE2\u53D7\u4F17\u5931\u8D25", err);
152172
- }
152173
- }
152174
- async function runTikTokPixelList(opts) {
152175
- const account = assertTikTokAccountId(opts.account);
152176
- try {
152177
- await requestTikTokList(
152178
- (pageNum, pageSize) => pixelListPath(account, pageNum, pageSize, {
152179
- code: opts.code,
152180
- pixelId: opts.pixelId,
152181
- name: opts.name
152182
- }),
152183
- opts,
152184
- "pixel",
152185
- "tiktok-pixel-list",
152186
- "tiktok-analysis pixel-list",
152187
- [
152188
- { key: "pixelId", header: "\u50CF\u7D20ID", fields: ["pixel_id"] },
152189
- { key: "name", header: "\u540D\u79F0", fields: ["pixel_name", "name"] },
152190
- { key: "code", header: "\u4EE3\u7801", fields: ["pixel_code", "code"] }
152191
- ]
152192
- );
152193
- } catch (err) {
152194
- fail8("\u67E5\u8BE2\u50CF\u7D20\u5931\u8D25", err);
152195
- }
152196
- }
152197
- async function runTikTokPixelCreate(opts) {
152198
- const account = assertTikTokAccountId(opts.account);
152199
- let body;
152200
- try {
152201
- body = pixelCreateBody(account, opts.name, opts.pixelCategory);
152202
- } catch (err) {
152203
- fail8("\u521B\u5EFA\u50CF\u7D20\u5931\u8D25", err);
152204
- }
152205
- try {
152206
- await requestTikTok(
152207
- "POST",
152208
- pixelCreatePath(account),
152209
- body,
152210
- opts,
152211
- "tiktok-pixel-create",
152212
- "tiktok-analysis pixel-create"
152213
- );
152214
- } catch (err) {
152215
- fail8("\u521B\u5EFA\u50CF\u7D20\u5931\u8D25", err);
152216
- }
152217
- }
152218
- async function runTikTokPixelEventCreate(opts) {
152219
- const account = assertTikTokAccountId(opts.account);
152220
- let body;
152221
- try {
152222
- body = pixelEventBody(account, opts.pixelId, parsePixelEvents(opts.events));
152223
- } catch (err) {
152224
- fail8("\u521B\u5EFA\u50CF\u7D20\u4E8B\u4EF6\u5931\u8D25", err);
152225
- }
152226
- try {
152227
- await requestTikTok(
152228
- "POST",
152229
- pixelEventPath(),
152230
- body,
152231
- opts,
152232
- "tiktok-pixel-event-create",
152233
- "tiktok-analysis pixel-event-create"
152234
- );
152235
- } catch (err) {
152236
- fail8("\u521B\u5EFA\u50CF\u7D20\u4E8B\u4EF6\u5931\u8D25", err);
152237
- }
152238
- }
152239
- async function runTikTokPixelStats(opts) {
152240
- const account = assertTikTokAccountId(opts.account);
152241
- let path61;
152242
- try {
152243
- path61 = pixelStatsPath(account, opts.pixelIds, opts.start, opts.end);
152244
- } catch (err) {
152245
- fail8("\u67E5\u8BE2\u50CF\u7D20\u7EDF\u8BA1\u5931\u8D25", err);
152246
- }
152247
- try {
152248
- await requestTikTok("GET", path61, void 0, opts, "tiktok-pixel-stats", "tiktok-analysis pixel-stats");
152249
- } catch (err) {
152250
- fail8("\u67E5\u8BE2\u50CF\u7D20\u7EDF\u8BA1\u5931\u8D25", err);
152251
- }
152252
- }
152253
- async function runTikTokCtaRecommendCreate(opts) {
152254
- assertCtaCommit();
152255
- const account = assertTikTokAccountId(opts.account);
152256
- let path61;
152257
- try {
152258
- path61 = ctaPortfolioPath(account, opts.contentType, opts.assetType);
152259
- } catch (err) {
152260
- fail8("\u521B\u5EFA CTA \u7EC4\u5408\u5931\u8D25", err);
152261
- }
152262
- try {
152263
- await requestTikTok(
152264
- "GET",
152265
- path61,
152266
- void 0,
152267
- opts,
152268
- "tiktok-cta-recommend-create",
152269
- "tiktok-analysis cta-recommend-create"
152270
- );
152271
- } catch (err) {
152272
- fail8("\u521B\u5EFA CTA \u7EC4\u5408\u5931\u8D25", err);
152273
- }
152274
- }
152275
- var AUDIENCE_FILE_MAX_BYTES = 50 * 1024 * 1024;
152276
- function audienceFileContentType(filename) {
152277
- const lower = filename.toLowerCase();
152278
- if (lower.endsWith(".csv")) return "text/csv";
152279
- if (lower.endsWith(".txt")) return "text/plain";
152280
- return "application/octet-stream";
152281
- }
152282
- async function runTikTokAudienceFileUpload(opts) {
152283
- const account = assertTikTokAccountId(opts.account);
152284
- const calculate = (opts.calculateType ?? "").trim();
152285
- const filePath = (opts.file ?? "").trim();
152286
- if (!calculate || calculate.length > 40) {
152287
- fail8("\u4E0A\u4F20\u53D7\u4F17\u6587\u4EF6\u5931\u8D25", new Error("calculate-type \u957F\u5EA6\u5FC5\u987B\u662F 1 \u5230 40"));
152288
- }
152289
- if (!filePath) {
152290
- fail8("\u4E0A\u4F20\u53D7\u4F17\u6587\u4EF6\u5931\u8D25", new Error("\u53D7\u4F17\u6587\u4EF6\u8DEF\u5F84\u4E0D\u80FD\u4E3A\u7A7A"));
152291
- }
152292
- let data;
152293
- try {
152294
- data = readFileSync21(filePath);
152295
- } catch (err) {
152296
- fail8("\u4E0A\u4F20\u53D7\u4F17\u6587\u4EF6\u5931\u8D25", err);
152297
- }
152298
- if (data.length <= 0 || data.length > AUDIENCE_FILE_MAX_BYTES) {
152299
- fail8("\u4E0A\u4F20\u53D7\u4F17\u6587\u4EF6\u5931\u8D25", new Error("\u53D7\u4F17\u6587\u4EF6\u5FC5\u987B\u5927\u4E8E 0\uFF0C\u4E14\u4E0D\u8D85\u8FC7 50MB"));
152300
- }
152301
- const filename = basename14(filePath);
152302
- try {
152303
- const config = loadConfig(opts.token);
152304
- const url = `${requireTikTokApiUrl(config)}/tiktokgap/audiences/file-upload`;
152305
- const payload = await apiFetchMultipart2(
152306
- url,
152307
- config,
152308
- {
152309
- fields: { advertiser_id: account, calculate_type: calculate },
152310
- files: [{ field: "file", filename, contentType: audienceFileContentType(filename), data }]
152311
- },
152312
- !!opts.verbose
152313
- );
152314
- assertBusinessOk(payload, "tiktok-analysis audience-file-upload");
152315
- const emitted = await emitCliJsonOrSnapshot(
152316
- { jsonOut: opts.jsonOut },
152317
- {
152318
- section: "tiktok-audience-file-upload",
152319
- commandLabel: "tiktok-analysis audience-file-upload",
152320
- payload,
152321
- idSuffix: account
152322
- }
152323
- );
152324
- if (emitted) return;
152325
- console.log("\n\u2705 tiktok-analysis audience-file-upload\n");
152326
- console.log(JSON.stringify(payload, null, 2));
152327
- console.log();
152328
- } catch (err) {
152329
- fail8("\u4E0A\u4F20\u53D7\u4F17\u6587\u4EF6\u5931\u8D25", err);
152330
- }
152331
- }
152332
- async function runTikTokSmartText(opts) {
152333
- const account = assertTikTokAccountId(opts.account);
152334
- let body;
152335
- try {
152336
- body = smartTextBody(account, opts);
152337
- } catch (err) {
152338
- fail8("\u751F\u6210\u667A\u80FD\u6587\u6848\u5931\u8D25", err);
152339
- }
152340
- try {
152341
- await requestTikTok("POST", smartTextPath(), body, opts, "tiktok-smart-text", "tiktok-analysis smart-text");
152342
- } catch (err) {
152343
- fail8("\u751F\u6210\u667A\u80FD\u6587\u6848\u5931\u8D25", err);
152344
- }
152345
- }
152346
-
152347
- // src/commands/tiktok-analysis/register-media.ts
152453
+ // src/commands/tiktok-analysis/register-cli.ts
152348
152454
  var ACCOUNT_OPTION3 = [
152349
152455
  "-a, --account <id>",
152350
152456
  "TikTok \u5E7F\u544A\u4E3B mediaCustomerId\uFF08\u6570\u5B57\uFF0C\u4E0E list-accounts -m TikTok \u4E00\u81F4\uFF09"
152351
152457
  ];
152352
152458
  var JSON_OUT_OPTION_DESC3 = "\u843D\u76D8\uFF08\u76EE\u5F55\u6216 *.json \u6587\u4EF6\u8DEF\u5F84\uFF09\u5E76\u66F4\u65B0 cli-manifest[-<\u67E5\u8BE2id>].json\uFF1Bstdout \u4E00\u884C\u6458\u8981 JSON";
152353
- function registerTikTokMediaCommands(root) {
152354
- root.command("image-upload").description("\u7528\u516C\u7F51 https \u5730\u5740\u4E0A\u4F20\u5E7F\u544A\u56FE\u7247\uFF08UPLOAD_BY_URL\uFF09\u3002\u8FD4\u56DE\u7684 image_id \u624D\u80FD\u5F53\u8EAB\u4EFD\u5934\u50CF\u6216\u7D20\u6750\u3002\u4E0D\u6536\u672C\u5730\u6587\u4EF6\u3002\u5199\u64CD\u4F5C\u987B --commit").requiredOption(...ACCOUNT_OPTION3).requiredOption("--image-url <url>", "https \u56FE\u7247\u5730\u5740").option("-t, --token <token>", "Auth Token").option("--json-out <path>", JSON_OUT_OPTION_DESC3).option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(async (opts) => {
152355
- await runTikTokImageUpload(opts);
152356
- });
152357
- root.command("video-upload").description("\u7528\u516C\u7F51 https \u5730\u5740\u76F4\u63A5\u4E0A\u4F20\u5E7F\u544A\u89C6\u9891\uFF08UPLOAD_BY_URL\uFF09\uFF0C\u5E76\u5173\u95ED\u81EA\u52A8\u4FEE\u590D\u3002\u4E0D\u6536\u672C\u5730\u6587\u4EF6\uFF0C\u4E0D\u8981\u81EA\u5DF1\u62C6\u7247\u3002\u5199\u64CD\u4F5C\u987B --commit").requiredOption(...ACCOUNT_OPTION3).requiredOption("--video-url <url>", "https \u89C6\u9891\u5730\u5740").option("--name <name>", "\u6587\u4EF6\u540D").option("-t, --token <token>", "Auth Token").option("--json-out <path>", JSON_OUT_OPTION_DESC3).option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(async (opts) => {
152358
- await runTikTokVideoUpload(opts);
152359
- });
152360
- root.command("video-upload-url").description("\u7528\u516C\u7F51 https \u5730\u5740\u7ECF\u7F51\u5173\u4E34\u65F6\u6587\u4EF6\u4E2D\u8F6C\u540E\u7ED1\u5B9A\u89C6\u9891\uFF0C\u5355\u6587\u4EF6 100MB\u3002\u4E0D\u6536\u672C\u5730\u6587\u4EF6\u3002\u5199\u64CD\u4F5C\u987B --commit").requiredOption(...ACCOUNT_OPTION3).requiredOption("--video-url <url>", "https \u89C6\u9891\u5730\u5740").option("--name <name>", "\u89C6\u9891\u540D\u79F0").option("-t, --token <token>", "Auth Token").option("--json-out <path>", JSON_OUT_OPTION_DESC3).option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(async (opts) => {
152361
- await runTikTokVideoUploadByUrl(opts);
152362
- });
152363
- root.command("video-info").description("\u6309\u89C6\u9891 ID \u6216\u7D20\u6750 ID \u67E5\u89C6\u9891\u4FE1\u606F\u3002\u4E0D\u662F\u7D20\u6750\u5E93\u5217\u8868\uFF0C\u4E24\u4E2A ID \u81F3\u5C11\u7ED9\u4E00\u4E2A").requiredOption(...ACCOUNT_OPTION3).option("--video-ids <ids>", "\u9017\u53F7\u5206\u9694\u7684 video_id").option("--material-ids <ids>", "\u9017\u53F7\u5206\u9694\u7684 material_id").option("-t, --token <token>", "Auth Token").option("--json-out <path>", JSON_OUT_OPTION_DESC3).option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(async (opts) => {
152364
- await runTikTokVideoInfo({ ...opts, materialIds: opts.materialIds });
152365
- });
152366
- root.command("identity-list").description("\u5E7F\u544A\u8EAB\u4EFD\u5217\u8868\uFF08/identity/get/\uFF09\u3002\u53EF\u9009\u6309 identity-type \u8FC7\u6EE4").requiredOption(...ACCOUNT_OPTION3).option("--identity-type <type>", "CUSTOMIZED_USER / AUTH_CODE / TT_USER / BC_AUTH_TT").option("--page-size <n>", "\u6BCF\u9875\u6761\u6570\uFF0C\u9ED8\u8BA4 100\uFF0C\u4E0A\u9650 1000", (v) => parseInt(v, 10)).option("-t, --token <token>", "Auth Token").option("--json-out <path>", JSON_OUT_OPTION_DESC3).option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(async (opts) => {
152367
- await runTikTokIdentityList(opts);
152368
- });
152369
- root.command("identity-create").description("\u521B\u5EFA CUSTOMIZED_USER \u8EAB\u4EFD\u3002--image-uri \u5FC5\u987B\u662F\u672C\u8D26\u6237 image-upload \u8FD4\u56DE\u7684 image_id\uFF0C\u7F51\u5173\u4E0D\u518D\u4EE3\u586B\u5934\u50CF\u3002\u5199\u64CD\u4F5C\u987B --commit").requiredOption(...ACCOUNT_OPTION3).requiredOption("--display-name <name>", "\u8EAB\u4EFD\u663E\u793A\u540D").requiredOption("--image-uri <id>", "image-upload \u8FD4\u56DE\u7684 image_id").option("-t, --token <token>", "Auth Token").option("--json-out <path>", JSON_OUT_OPTION_DESC3).option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(async (opts) => {
152370
- await runTikTokIdentityCreate(opts);
152371
- });
152372
- root.command("audience-list").description("\u81EA\u5B9A\u4E49\u53D7\u4F17\u5217\u8868\u3002\u4E0D\u662F Lookalike \u521B\u5EFA\u6216\u91CD\u53E0\u5206\u6790").requiredOption(...ACCOUNT_OPTION3).option("--audience-ids <ids>", "\u9017\u53F7\u5206\u9694\u7684\u53D7\u4F17 ID").option("--page-size <n>", "\u6BCF\u9875\u6761\u6570\uFF0C\u9ED8\u8BA4 100\uFF0C\u4E0A\u9650 1000", (v) => parseInt(v, 10)).option("-t, --token <token>", "Auth Token").option("--json-out <path>", JSON_OUT_OPTION_DESC3).option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(async (opts) => {
152373
- await runTikTokAudienceList(opts);
152374
- });
152375
- root.command("pixel-list").description("\u50CF\u7D20\u5217\u8868\u3002\u6BCF\u9875\u6700\u591A 20 \u6761").requiredOption(...ACCOUNT_OPTION3).option("--code <code>", "\u6309 pixel code \u8FC7\u6EE4").option("--pixel-id <id>", "\u6309\u50CF\u7D20 ID \u8FC7\u6EE4").option("--name <name>", "\u6309\u540D\u79F0\u8FC7\u6EE4").option("--page-size <n>", "\u6BCF\u9875\u6761\u6570\uFF0C\u9ED8\u8BA4 20\uFF0C\u4E0A\u9650 20", (v) => parseInt(v, 10)).option("-t, --token <token>", "Auth Token").option("--json-out <path>", JSON_OUT_OPTION_DESC3).option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(async (opts) => {
152376
- await runTikTokPixelList(opts);
152377
- });
152378
- root.command("pixel-create").description("\u521B\u5EFA\u50CF\u7D20\u3002\u540D\u79F0\u4E0D\u8D85\u8FC7 40 \u4E2A\u5B57\u7B26\u3002\u5199\u64CD\u4F5C\u987B --commit").requiredOption(...ACCOUNT_OPTION3).requiredOption("--name <name>", "\u50CF\u7D20\u540D\u79F0").requiredOption("--pixel-category <category>", "\u5B98\u65B9 pixel_category").option("-t, --token <token>", "Auth Token").option("--json-out <path>", JSON_OUT_OPTION_DESC3).option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(async (opts) => {
152379
- await runTikTokPixelCreate(opts);
152380
- });
152381
- root.command("pixel-event-create").description("\u7ED9\u50CF\u7D20\u52A0\u4E8B\u4EF6\u3002--events \u662F\u5B98\u65B9 pixel_events \u7684 JSON \u6570\u7EC4\u3002\u5199\u64CD\u4F5C\u987B --commit").requiredOption(...ACCOUNT_OPTION3).requiredOption("--pixel-id <id>", "\u50CF\u7D20 ID").requiredOption("--events <json>", "\u975E\u7A7A JSON \u6570\u7EC4").option("-t, --token <token>", "Auth Token").option("--json-out <path>", JSON_OUT_OPTION_DESC3).option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(async (opts) => {
152382
- await runTikTokPixelEventCreate(opts);
152383
- });
152384
- root.command("pixel-stats").description("\u50CF\u7D20\u4E8B\u4EF6\u7EDF\u8BA1\u3002\u533A\u95F4\u8DE8\u5EA6\u4E0D\u8D85\u8FC7 30 \u5929\uFF0C\u4E00\u6B21 1 \u5230 10 \u4E2A\u50CF\u7D20").requiredOption(...ACCOUNT_OPTION3).requiredOption("--pixel-ids <ids>", "\u9017\u53F7\u5206\u9694\uFF0C1 \u5230 10 \u4E2A").requiredOption("--start <date>", "YYYY-MM-DD").requiredOption("--end <date>", "YYYY-MM-DD").option("-t, --token <token>", "Auth Token").option("--json-out <path>", JSON_OUT_OPTION_DESC3).option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(async (opts) => {
152385
- await runTikTokPixelStats(opts);
152386
- });
152387
- root.command("cta-recommend-create").description("\u6309\u63A8\u8350 CTA \u7ACB\u523B\u521B\u5EFA\u7EC4\u5408\uFF08\u4E0D\u662F\u5217\u8868\uFF09\u3002\u7F51\u5173\u5148\u62C9\u63A8\u8350\u518D\u521B\u5EFA\u3002\u5199\u64CD\u4F5C\u987B --commit").requiredOption(...ACCOUNT_OPTION3).requiredOption("--content-type <type>", "\u5B98\u65B9 content_type\uFF0C\u5982 LANDING_PAGE").requiredOption("--asset-type <type>", "\u5B98\u65B9 asset_type").option("-t, --token <token>", "Auth Token").option("--json-out <path>", JSON_OUT_OPTION_DESC3).option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(async (opts) => {
152388
- await runTikTokCtaRecommendCreate(opts);
152389
- });
152390
- root.command("smart-text").description("\u751F\u6210\u667A\u80FD\u6587\u6848\u3002\u5B98\u65B9\u8981\u6C42\u5E7F\u544A\u7EC4 ID\u3002\u5199\u64CD\u4F5C\u987B --commit").requiredOption(...ACCOUNT_OPTION3).requiredOption("--adgroup-id <id>", "\u5E7F\u544A\u7EC4 ID").option("--param-type <type>", "\u5B98\u65B9 param_type").option("--language <lang>", "\u6587\u6848\u8BED\u8A00").option("--industry-id <id>", "\u884C\u4E1A ID").option("--keywords <list>", "\u9017\u53F7\u5206\u9694\u5173\u952E\u8BCD").option("--limit <n>", "\u6761\u6570\uFF0C\u5927\u4E8E 0 \u7684\u6574\u6570").option("-t, --token <token>", "Auth Token").option("--json-out <path>", JSON_OUT_OPTION_DESC3).option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(async (opts) => {
152391
- await runTikTokSmartText(opts);
152392
- });
152393
- root.command("audience-file-upload").description("\u628A\u672C\u5730\u53D7\u4F17\u6587\u4EF6\u4E0A\u4F20\u5230 TikTok\u3002\u8FD4\u56DE\u7684\u8DEF\u5F84\u624D\u80FD\u7ED9 tiktok.audience-file \u7684 file_paths\u3002\u5355\u6587\u4EF6 50MB\u3002\u5199\u64CD\u4F5C\u987B --commit").requiredOption(...ACCOUNT_OPTION3).requiredOption("--file <path>", "\u672C\u5730 csv \u6216 txt").requiredOption("--calculate-type <type>", "\u5B98\u65B9 calculate_type\uFF0C\u5982 EMAIL_SHA256").option("-t, --token <token>", "Auth Token").option("--json-out <path>", JSON_OUT_OPTION_DESC3).option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(async (opts) => {
152394
- await runTikTokAudienceFileUpload(opts);
152395
- });
152396
- }
152397
-
152398
- // src/commands/tiktok-analysis/register-cli.ts
152399
- var ACCOUNT_OPTION4 = [
152400
- "-a, --account <id>",
152401
- "TikTok \u5E7F\u544A\u4E3B mediaCustomerId\uFF08\u6570\u5B57\uFF0C\u4E0E list-accounts -m TikTok \u4E00\u81F4\uFF09"
152402
- ];
152403
- var JSON_OUT_OPTION_DESC4 = "\u843D\u76D8\uFF08\u76EE\u5F55\u6216 *.json \u6587\u4EF6\u8DEF\u5F84\uFF09\u5E76\u66F4\u65B0 cli-manifest[-<\u67E5\u8BE2id>].json\uFF1Bstdout \u4E00\u884C\u6458\u8981 JSON";
152404
152459
  function registerBatchCommand3(sectionHelp, aliasHelp) {
152405
152460
  return new Command4("run").description(
152406
152461
  "\u6279\u91CF\u62C9\u53D6 TSO reporting/media-account/TikTok Section \u6570\u636E\uFF08\u7701\u7565\u5B50\u547D\u4EE4\u540D\u65F6\u9ED8\u8BA4\u6267\u884C\u672C\u547D\u4EE4\uFF09"
@@ -152422,7 +152477,7 @@ function registerTikTokAnalysisCommands(program2) {
152422
152477
  const sectionHelp = TIKTOK_SECTION_NAMES.join(", ");
152423
152478
  const aliasHelp = Object.keys(TIKTOK_SECTION_ALIASES).join(", ");
152424
152479
  const root = program2.command("tiktok-analysis").description(
152425
- "TikTok \u8D26\u6237\u5206\u6790\uFF1A\u6279\u91CF\u62C9\u53D6 TSO \u770B\u677F Section\uFF08\u9ED8\u8BA4\uFF09\u3001render \u5468\u671F HTML\uFF0C\u67E5\u8BE2\u8D26\u6237\u72B6\u6001/\u7CFB\u5217/\u7EC4/\u5E7F\u544A/\u5B98\u65B9\u62A5\u8868\uFF0C\u4EE5\u53CA\u516C\u7F51\u7D20\u6750\u3001\u8EAB\u4EFD\u3001\u50CF\u7D20\u3001\u53D7\u4F17\u5217\u8868\u3001CTA \u7EC4\u5408\u3001\u667A\u80FD\u6587\u6848"
152480
+ "TikTok \u8D26\u6237\u5206\u6790\uFF1A\u6279\u91CF\u62C9\u53D6 TSO \u770B\u677F Section\uFF08\u9ED8\u8BA4\uFF09\u3001render \u5468\u671F HTML\uFF0C\u6216\u67E5\u8BE2 TikTokAPI \u8D26\u6237\u72B6\u6001/\u7CFB\u5217/\u7EC4/\u5E7F\u544A/\u5B98\u65B9\u62A5\u8868\uFF08\u53EA\u8BFB\u8FD0\u8425\uFF09"
152426
152481
  );
152427
152482
  root.addCommand(registerBatchCommand3(sectionHelp, aliasHelp), { isDefault: true });
152428
152483
  root.command("render").description(
@@ -152499,25 +152554,25 @@ function registerTikTokAnalysisCommands(program2) {
152499
152554
  );
152500
152555
  root.command("account-status").description(
152501
152556
  "\u8D26\u6237\u72B6\u6001/\u4F59\u989D/\u65F6\u533A\uFF08GET \u2026/GetAdvertiserInfo/Tiktok\uFF1BSTATUS_ENABLE \u4E3A\u6B63\u5E38\uFF1B\u987B\u62E5\u6709\u8BE5\u5E7F\u544A\u4E3B\uFF09"
152502
- ).requiredOption(...ACCOUNT_OPTION4).option("-t, --token <token>", "Auth Token").option("--json-out <path>", JSON_OUT_OPTION_DESC4).option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(
152557
+ ).requiredOption(...ACCOUNT_OPTION3).option("-t, --token <token>", "Auth Token").option("--json-out <path>", JSON_OUT_OPTION_DESC3).option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(
152503
152558
  async (opts) => {
152504
152559
  await runTikTokAccountStatus(opts);
152505
152560
  }
152506
152561
  );
152507
152562
  root.command("campaign-entities").description(
152508
152563
  "\u7CFB\u5217\u539F\u59CB\u5B9E\u4F53\uFF08GET \u2026/campaign/Tiktok\uFF1Abudget/budget_mode/CBO/operation_status\uFF1B\u4E0E `run --sections campaigns` \u7684\u770B\u677F\u82B1\u8D39\u4E0D\u540C\uFF09"
152509
- ).requiredOption(...ACCOUNT_OPTION4).option("--campaign-ids <ids>", "\u9017\u53F7\u5206\u9694\u7CFB\u5217 ID\uFF0C\u5199\u5165 filtering.CampaignIds").option(
152564
+ ).requiredOption(...ACCOUNT_OPTION3).option("--campaign-ids <ids>", "\u9017\u53F7\u5206\u9694\u7CFB\u5217 ID\uFF0C\u5199\u5165 filtering.CampaignIds").option(
152510
152565
  "--page-size <n>",
152511
152566
  "\u6BCF\u9875\u6761\u6570\uFF0C\u9ED8\u8BA4 100\uFF0C\u4E0A\u9650 1000\uFF08\u5FC5\u987B\u663E\u5F0F\u4F20\u7ED9\u7F51\u5173\uFF09",
152512
152567
  (v) => parseInt(v, 10)
152513
- ).option("-t, --token <token>", "Auth Token").option("--json-out <path>", JSON_OUT_OPTION_DESC4).option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(
152568
+ ).option("-t, --token <token>", "Auth Token").option("--json-out <path>", JSON_OUT_OPTION_DESC3).option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(
152514
152569
  async (opts) => {
152515
152570
  await runTikTokCampaignEntities(opts);
152516
152571
  }
152517
152572
  );
152518
152573
  root.command("adgroup-entities").description(
152519
152574
  "\u5E7F\u544A\u7EC4\u539F\u59CB\u5B9E\u4F53\uFF08GET \u2026/adgroup/Tiktok\uFF1Abid_type \u4E0E\u5BF9\u5E94\u51FA\u4EF7\u3001\u7EC4\u9884\u7B97\uFF1BCBO \u65F6\u7EC4\u9884\u7B97\u4E3A 0\uFF09"
152520
- ).requiredOption(...ACCOUNT_OPTION4).option("--campaign-ids <ids>", "\u9017\u53F7\u5206\u9694\u7CFB\u5217 ID").option("--adgroup-ids <ids>", "\u9017\u53F7\u5206\u9694\u5E7F\u544A\u7EC4 ID").option("--page-size <n>", "\u6BCF\u9875\u6761\u6570\uFF0C\u9ED8\u8BA4 100\uFF0C\u4E0A\u9650 1000", (v) => parseInt(v, 10)).option("-t, --token <token>", "Auth Token").option("--json-out <path>", JSON_OUT_OPTION_DESC4).option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(
152575
+ ).requiredOption(...ACCOUNT_OPTION3).option("--campaign-ids <ids>", "\u9017\u53F7\u5206\u9694\u7CFB\u5217 ID").option("--adgroup-ids <ids>", "\u9017\u53F7\u5206\u9694\u5E7F\u544A\u7EC4 ID").option("--page-size <n>", "\u6BCF\u9875\u6761\u6570\uFF0C\u9ED8\u8BA4 100\uFF0C\u4E0A\u9650 1000", (v) => parseInt(v, 10)).option("-t, --token <token>", "Auth Token").option("--json-out <path>", JSON_OUT_OPTION_DESC3).option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(
152521
152576
  async (opts) => {
152522
152577
  await runTikTokAdGroupEntities({
152523
152578
  ...opts,
@@ -152527,10 +152582,10 @@ function registerTikTokAnalysisCommands(program2) {
152527
152582
  );
152528
152583
  root.command("ad-entities").description(
152529
152584
  `\u5E7F\u544A\u539F\u59CB\u5B9E\u4F53\uFF08GET \u2026/ad/Tiktok\uFF1A\u843D\u5730\u9875/\u62D2\u5BA1\uFF1B\u62D2\u5BA1\u4F20 --secondary-status ${TIKTOK_AD_AUDIT_DENY}\uFF09`
152530
- ).requiredOption(...ACCOUNT_OPTION4).option("--campaign-ids <ids>", "\u9017\u53F7\u5206\u9694\u7CFB\u5217 ID").option("--adgroup-ids <ids>", "\u9017\u53F7\u5206\u9694\u5E7F\u544A\u7EC4 ID").option("--ad-ids <ids>", "\u9017\u53F7\u5206\u9694\u5E7F\u544A ID").option(
152585
+ ).requiredOption(...ACCOUNT_OPTION3).option("--campaign-ids <ids>", "\u9017\u53F7\u5206\u9694\u7CFB\u5217 ID").option("--adgroup-ids <ids>", "\u9017\u53F7\u5206\u9694\u5E7F\u544A\u7EC4 ID").option("--ad-ids <ids>", "\u9017\u53F7\u5206\u9694\u5E7F\u544A ID").option(
152531
152586
  "--secondary-status <status>",
152532
152587
  `\u5B98\u65B9 secondary_status \u5355\u503C\uFF0C\u5982 ${TIKTOK_AD_AUDIT_DENY}\uFF1B\u52FF\u4F20\u9EC4\u6761 REVIEW_PARTIALLY_APPROVED`
152533
- ).option("--page-size <n>", "\u6BCF\u9875\u6761\u6570\uFF0C\u9ED8\u8BA4 100\uFF0C\u4E0A\u9650 1000", (v) => parseInt(v, 10)).option("-t, --token <token>", "Auth Token").option("--json-out <path>", JSON_OUT_OPTION_DESC4).option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(
152588
+ ).option("--page-size <n>", "\u6BCF\u9875\u6761\u6570\uFF0C\u9ED8\u8BA4 100\uFF0C\u4E0A\u9650 1000", (v) => parseInt(v, 10)).option("-t, --token <token>", "Auth Token").option("--json-out <path>", JSON_OUT_OPTION_DESC3).option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(
152534
152589
  async (opts) => {
152535
152590
  await runTikTokAdEntities({
152536
152591
  ...opts,
@@ -152540,35 +152595,34 @@ function registerTikTokAnalysisCommands(program2) {
152540
152595
  );
152541
152596
  root.command("official-report").description(
152542
152597
  "TikTokAPI \u5B98\u65B9\u62A5\u8868\uFF08GET \u2026/query/report/Tiktok/search\uFF1B\u53EF\u542B\u4ECA\u5929/\u5C0F\u65F6\uFF1B\u4E0E `run` \u7684 TSO \u770B\u677F\u5468\u671F\u62A5\u8868\u4E0D\u540C\u3002ServiceType/DataLevel/Dimensions/Metrics/\u65E5\u671F/PageSize \u5FC5\u586B\uFF09"
152543
- ).requiredOption(...ACCOUNT_OPTION4).requiredOption("--start <date>", "\u5F00\u59CB\u65E5\u671F YYYY-MM-DD\uFF08\u6309\u5E7F\u544A\u4E3B timezone \u81EA\u7136\u65E5\uFF09").requiredOption("--end <date>", "\u7ED3\u675F\u65E5\u671F YYYY-MM-DD").requiredOption("--data-level <level>", "AUCTION_CAMPAIGN / AUCTION_ADGROUP / AUCTION_AD").requiredOption("--dimensions <list>", "\u9017\u53F7\u5206\u9694\uFF0C\u5982 campaign_id \u6216 adgroup_id,stat_time_hour").requiredOption(
152598
+ ).requiredOption(...ACCOUNT_OPTION3).requiredOption("--start <date>", "\u5F00\u59CB\u65E5\u671F YYYY-MM-DD\uFF08\u6309\u5E7F\u544A\u4E3B timezone \u81EA\u7136\u65E5\uFF09").requiredOption("--end <date>", "\u7ED3\u675F\u65E5\u671F YYYY-MM-DD").requiredOption("--data-level <level>", "AUCTION_CAMPAIGN / AUCTION_ADGROUP / AUCTION_AD").requiredOption("--dimensions <list>", "\u9017\u53F7\u5206\u9694\uFF0C\u5982 campaign_id \u6216 adgroup_id,stat_time_hour").requiredOption(
152544
152599
  "--metrics <list>",
152545
152600
  "\u9017\u53F7\u5206\u9694\uFF0C\u82B1\u8D39\u987B\u7528 spend\uFF08\u4E0D\u8981 stat_cost\uFF09\u3002complete_payment \u662F\u7F51\u9875\u5B8C\u4ED8\u6B21\u6570\u3002\u542B\u5B8C\u4ED8/ROAS \u65F6\u81EA\u52A8\u9644\u5E26 total_purchase_value,complete_payment_roas,total_active_pay_roas"
152546
- ).option("--service-type <type>", "AUCTION\uFF08\u9ED8\u8BA4\uFF09\u6216 RESERVATION", "AUCTION").option("--page-size <n>", "\u6BCF\u9875\u6761\u6570\uFF0C\u9ED8\u8BA4 200\uFF0C\u4E0A\u9650 1000", (v) => parseInt(v, 10)).option("-t, --token <token>", "Auth Token").option("--json-out <path>", JSON_OUT_OPTION_DESC4).option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(
152601
+ ).option("--service-type <type>", "AUCTION\uFF08\u9ED8\u8BA4\uFF09\u6216 RESERVATION", "AUCTION").option("--page-size <n>", "\u6BCF\u9875\u6761\u6570\uFF0C\u9ED8\u8BA4 200\uFF0C\u4E0A\u9650 1000", (v) => parseInt(v, 10)).option("-t, --token <token>", "Auth Token").option("--json-out <path>", JSON_OUT_OPTION_DESC3).option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(
152547
152602
  async (opts) => {
152548
152603
  await runTikTokOfficialReport(opts);
152549
152604
  }
152550
152605
  );
152551
- root.command("campaign-status").description("\u542F\u505C\u63A8\u5E7F\u7CFB\u5217\uFF08PUT \u2026/campaign/updatestatus/Tiktok\uFF1BENABLE \u6216 DISABLE\uFF09").requiredOption(...ACCOUNT_OPTION4).requiredOption("--campaign-id <id>", "\u63A8\u5E7F\u7CFB\u5217 ID").requiredOption("--status <status>", "ENABLE \u6216 DISABLE").option("-t, --token <token>", "Auth Token").option("--json-out <path>", JSON_OUT_OPTION_DESC4).option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(async (opts) => {
152606
+ root.command("campaign-status").description("\u542F\u505C\u63A8\u5E7F\u7CFB\u5217\uFF08PUT \u2026/campaign/updatestatus/Tiktok\uFF1BENABLE \u6216 DISABLE\uFF09").requiredOption(...ACCOUNT_OPTION3).requiredOption("--campaign-id <id>", "\u63A8\u5E7F\u7CFB\u5217 ID").requiredOption("--status <status>", "ENABLE \u6216 DISABLE").option("-t, --token <token>", "Auth Token").option("--json-out <path>", JSON_OUT_OPTION_DESC3).option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(async (opts) => {
152552
152607
  await runTikTokCampaignStatus(opts);
152553
152608
  });
152554
152609
  root.command("campaign-budget").description(
152555
152610
  "\u6539\u63A8\u5E7F\u7CFB\u5217\u9884\u7B97\uFF08PUT \u2026/campaign/update/Tiktok\uFF1B\u65E5\u9884\u7B97\u4E0E\u603B\u9884\u7B97\u4E0D\u80FD\u4E92\u5207\uFF0C\u4E0D\u652F\u6301\u4E0D\u9650\u9884\u7B97\uFF09"
152556
- ).requiredOption(...ACCOUNT_OPTION4).requiredOption("--campaign-id <id>", "\u63A8\u5E7F\u7CFB\u5217 ID").requiredOption("--budget <amount>", "\u9884\u7B97\uFF0C\u5E7F\u544A\u4E3B\u5E01\u79CD\uFF0C\u5FC5\u987B\u5927\u4E8E 0").requiredOption(
152611
+ ).requiredOption(...ACCOUNT_OPTION3).requiredOption("--campaign-id <id>", "\u63A8\u5E7F\u7CFB\u5217 ID").requiredOption("--budget <amount>", "\u9884\u7B97\uFF0C\u5E7F\u544A\u4E3B\u5E01\u79CD\uFF0C\u5FC5\u987B\u5927\u4E8E 0").requiredOption(
152557
152612
  "--budget-mode <mode>",
152558
152613
  "BUDGET_MODE_DAY / BUDGET_MODE_TOTAL / BUDGET_MODE_DYNAMIC_DAILY_BUDGET"
152559
- ).option("-t, --token <token>", "Auth Token").option("--json-out <path>", JSON_OUT_OPTION_DESC4).option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(async (opts) => {
152614
+ ).option("-t, --token <token>", "Auth Token").option("--json-out <path>", JSON_OUT_OPTION_DESC3).option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(async (opts) => {
152560
152615
  await runTikTokCampaignBudget(opts);
152561
152616
  });
152562
- root.command("adgroup-status").description("\u542F\u505C\u5E7F\u544A\u7EC4\uFF08PUT \u2026/adgroup/UpdateStatus/Tiktok/{entityId}\uFF1BentityId \u6309\u5E7F\u544A\u4E3B\u81EA\u52A8\u67E5\uFF09").requiredOption(...ACCOUNT_OPTION4).requiredOption("--adgroup-id <id>", "\u5E7F\u544A\u7EC4 ID").requiredOption("--status <status>", "ENABLE \u6216 DISABLE").option("-t, --token <token>", "Auth Token").option("--json-out <path>", JSON_OUT_OPTION_DESC4).option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(async (opts) => {
152617
+ root.command("adgroup-status").description("\u542F\u505C\u5E7F\u544A\u7EC4\uFF08PUT \u2026/adgroup/UpdateStatus/Tiktok/{entityId}\uFF1BentityId \u6309\u5E7F\u544A\u4E3B\u81EA\u52A8\u67E5\uFF09").requiredOption(...ACCOUNT_OPTION3).requiredOption("--adgroup-id <id>", "\u5E7F\u544A\u7EC4 ID").requiredOption("--status <status>", "ENABLE \u6216 DISABLE").option("-t, --token <token>", "Auth Token").option("--json-out <path>", JSON_OUT_OPTION_DESC3).option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(async (opts) => {
152563
152618
  await runTikTokAdGroupStatus({ ...opts, adGroupId: opts.adgroupId });
152564
152619
  });
152565
- root.command("adgroup-budget").description("\u6539\u5E7F\u544A\u7EC4\u9884\u7B97\uFF08PUT \u2026/adgroup/UpdateBudget\uFF1BCBO \u6216\u65E0\u9650\u9884\u7B97\u65F6\u7EC4\u9884\u7B97\u53EF\u80FD\u6539\u4E0D\u52A8\uFF09").requiredOption(...ACCOUNT_OPTION4).requiredOption("--adgroup-id <id>", "\u5E7F\u544A\u7EC4 ID").requiredOption("--budget <amount>", "\u9884\u7B97\uFF0C\u5E7F\u544A\u4E3B\u5E01\u79CD\uFF0C\u5FC5\u987B\u5927\u4E8E 0").option("-t, --token <token>", "Auth Token").option("--json-out <path>", JSON_OUT_OPTION_DESC4).option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(async (opts) => {
152620
+ root.command("adgroup-budget").description("\u6539\u5E7F\u544A\u7EC4\u9884\u7B97\uFF08PUT \u2026/adgroup/UpdateBudget\uFF1BCBO \u6216\u65E0\u9650\u9884\u7B97\u65F6\u7EC4\u9884\u7B97\u53EF\u80FD\u6539\u4E0D\u52A8\uFF09").requiredOption(...ACCOUNT_OPTION3).requiredOption("--adgroup-id <id>", "\u5E7F\u544A\u7EC4 ID").requiredOption("--budget <amount>", "\u9884\u7B97\uFF0C\u5E7F\u544A\u4E3B\u5E01\u79CD\uFF0C\u5FC5\u987B\u5927\u4E8E 0").option("-t, --token <token>", "Auth Token").option("--json-out <path>", JSON_OUT_OPTION_DESC3).option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(async (opts) => {
152566
152621
  await runTikTokAdGroupBudget({ ...opts, adGroupId: opts.adgroupId });
152567
152622
  });
152568
- root.command("ad-status").description("\u542F\u505C\u5E7F\u544A\uFF08PUT \u2026/ad/updatestatus/Tiktok\uFF1BENABLE \u6216 DISABLE\uFF09").requiredOption(...ACCOUNT_OPTION4).requiredOption("--ad-id <id>", "\u5E7F\u544A ID").requiredOption("--status <status>", "ENABLE \u6216 DISABLE").option("-t, --token <token>", "Auth Token").option("--json-out <path>", JSON_OUT_OPTION_DESC4).option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(async (opts) => {
152623
+ root.command("ad-status").description("\u542F\u505C\u5E7F\u544A\uFF08PUT \u2026/ad/updatestatus/Tiktok\uFF1BENABLE \u6216 DISABLE\uFF09").requiredOption(...ACCOUNT_OPTION3).requiredOption("--ad-id <id>", "\u5E7F\u544A ID").requiredOption("--status <status>", "ENABLE \u6216 DISABLE").option("-t, --token <token>", "Auth Token").option("--json-out <path>", JSON_OUT_OPTION_DESC3).option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(async (opts) => {
152569
152624
  await runTikTokAdStatus(opts);
152570
152625
  });
152571
- registerTikTokMediaCommands(root);
152572
152626
  }
152573
152627
 
152574
152628
  // src/commands/yandex-analysis/register-cli.ts
@@ -153413,12 +153467,12 @@ init_lang();
153413
153467
  init_html();
153414
153468
  var TEMPLATE_BASENAME6 = "yandex-period-report.html";
153415
153469
  var INJECT_MARKER6 = "window.__YANDEX_PERIOD_REPORT__ = window.__YANDEX_PERIOD_REPORT__ || null;";
153416
- function resolveSkillTemplatePath9(basename15) {
153470
+ function resolveSkillTemplatePath9(basename14) {
153417
153471
  const dir = path59.dirname(fileURLToPath15(import.meta.url));
153418
153472
  const candidates = [
153419
- path59.join(dir, "skill", "report-templates", basename15),
153420
- path59.join(dir, "skill", "siluzan-ads", "report-templates", basename15),
153421
- path59.join(dir, "..", "..", "assets", "siluzan-ads", "report-templates", basename15)
153473
+ path59.join(dir, "skill", "report-templates", basename14),
153474
+ path59.join(dir, "skill", "siluzan-ads", "report-templates", basename14),
153475
+ path59.join(dir, "..", "..", "assets", "siluzan-ads", "report-templates", basename14)
153422
153476
  ];
153423
153477
  for (const p of candidates) {
153424
153478
  if (fs48.existsSync(p)) return p;
@@ -153668,7 +153722,7 @@ function asRecord43(raw) {
153668
153722
  }
153669
153723
 
153670
153724
  // src/commands/yandex-analysis/entities.ts
153671
- function fail9(label2, err) {
153725
+ function fail8(label2, err) {
153672
153726
  const msg = err instanceof Error ? err.message : String(err);
153673
153727
  console.error(`
153674
153728
  \u274C ${label2}\uFF1A${msg}
@@ -153740,7 +153794,7 @@ async function runYandexAccountStatus(opts) {
153740
153794
  try {
153741
153795
  result = await fetchPath(opts, "overview", {});
153742
153796
  } catch (err) {
153743
- fail9("\u67E5\u8BE2 Yandex \u8D26\u6237\u603B\u89C8\u5931\u8D25", err);
153797
+ fail8("\u67E5\u8BE2 Yandex \u8D26\u6237\u603B\u89C8\u5931\u8D25", err);
153744
153798
  }
153745
153799
  const row = asRecord43(result.raw);
153746
153800
  await emitOrTable(opts, {
@@ -153782,7 +153836,7 @@ async function runYandexCampaignEntities(opts) {
153782
153836
  network: flags.network
153783
153837
  });
153784
153838
  } catch (err) {
153785
- fail9("\u67E5\u8BE2 Yandex \u7CFB\u5217\u5931\u8D25", err);
153839
+ fail8("\u67E5\u8BE2 Yandex \u7CFB\u5217\u5931\u8D25", err);
153786
153840
  }
153787
153841
  const items3 = unwrapYandexItems(result.raw);
153788
153842
  await emitOrTable(opts, {
@@ -153828,7 +153882,7 @@ async function runYandexAdGroupEntities(opts) {
153828
153882
  campaignId: flags.campaignId
153829
153883
  });
153830
153884
  } catch (err) {
153831
- fail9("\u67E5\u8BE2 Yandex \u5E7F\u544A\u7EC4\u5931\u8D25", err);
153885
+ fail8("\u67E5\u8BE2 Yandex \u5E7F\u544A\u7EC4\u5931\u8D25", err);
153832
153886
  }
153833
153887
  const items3 = unwrapYandexItems(result.raw);
153834
153888
  await emitOrTable(opts, {
@@ -153878,7 +153932,7 @@ async function runYandexAdEntities(opts) {
153878
153932
  adGroupId: flags.adGroupId
153879
153933
  });
153880
153934
  } catch (err) {
153881
- fail9("\u67E5\u8BE2 Yandex \u5E7F\u544A\u5931\u8D25", err);
153935
+ fail8("\u67E5\u8BE2 Yandex \u5E7F\u544A\u5931\u8D25", err);
153882
153936
  }
153883
153937
  const items3 = unwrapYandexItems(result.raw);
153884
153938
  const filtered = flags.status != null;
@@ -153930,7 +153984,7 @@ async function runYandexInsights(opts) {
153930
153984
  adGroupId: flags.adGroupId
153931
153985
  });
153932
153986
  } catch (err) {
153933
- fail9("\u67E5\u8BE2 Yandex insights \u5931\u8D25", err);
153987
+ fail8("\u67E5\u8BE2 Yandex insights \u5931\u8D25", err);
153934
153988
  }
153935
153989
  const items3 = unwrapYandexItems(result.raw);
153936
153990
  await emitOrTable(opts, {
@@ -154067,11 +154121,11 @@ async function runYandexKeywordBid(opts) {
154067
154121
  }
154068
154122
 
154069
154123
  // src/commands/yandex-analysis/register-cli.ts
154070
- var ACCOUNT_OPTION5 = [
154124
+ var ACCOUNT_OPTION4 = [
154071
154125
  "-a, --account <id>",
154072
154126
  "Yandex Client-Login / mediaCustomerId\uFF08\u5982 porg-xxx\uFF0C\u4E0E list-accounts -m Yandex \u4E00\u81F4\uFF09"
154073
154127
  ];
154074
- var JSON_OUT_OPTION_DESC5 = "\u843D\u76D8\uFF08\u76EE\u5F55\u6216 *.json \u6587\u4EF6\u8DEF\u5F84\uFF09\u5E76\u66F4\u65B0 cli-manifest[-<\u67E5\u8BE2id>].json\uFF1Bstdout \u4E00\u884C\u6458\u8981 JSON";
154128
+ var JSON_OUT_OPTION_DESC4 = "\u843D\u76D8\uFF08\u76EE\u5F55\u6216 *.json \u6587\u4EF6\u8DEF\u5F84\uFF09\u5E76\u66F4\u65B0 cli-manifest[-<\u67E5\u8BE2id>].json\uFF1Bstdout \u4E00\u884C\u6458\u8981 JSON";
154075
154129
  var START_OPTION = [
154076
154130
  "--start <date>",
154077
154131
  "\u5F00\u59CB\u65E5\u671F YYYY-MM-DD\uFF08\u4E0E --end \u540C\u4F20\u6216\u540C\u7701\u7565\uFF1B\u7701\u7565=\u5F53\u5929\uFF09"
@@ -154120,55 +154174,55 @@ function registerYandexAnalysisCommands(program2) {
154120
154174
  });
154121
154175
  root.command("account-status").description(
154122
154176
  "\u8D26\u6237\u5F52\u6863/\u4F59\u989D/\u533A\u95F4 KPI\uFF08GET /overview\uFF1Barchived=true \u4E3A\u5DF2\u5F52\u6863\uFF1B\u5B98\u65B9\u65E0\u5C01\u6237\u539F\u56E0\uFF1B\u7701\u7565\u65E5\u671F=\u5F53\u5929\uFF09"
154123
- ).requiredOption(...ACCOUNT_OPTION5).option(...START_OPTION).option(...END_OPTION).option("-t, --token <token>", "Auth Token").option("--json-out <path>", JSON_OUT_OPTION_DESC5).option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(
154177
+ ).requiredOption(...ACCOUNT_OPTION4).option(...START_OPTION).option(...END_OPTION).option("-t, --token <token>", "Auth Token").option("--json-out <path>", JSON_OUT_OPTION_DESC4).option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(
154124
154178
  async (opts) => {
154125
154179
  await runYandexAccountStatus(opts);
154126
154180
  }
154127
154181
  );
154128
154182
  root.command("campaign-entities").description(
154129
154183
  "\u7CFB\u5217\u7EE9\u6548+\u9884\u7B97/\u7B56\u7565\uFF08GET /campaigns\uFF1Aspend/weeklyBudget/budget/strategy/targetCpa\uFF1B\u5168\u6E20\u9053\u82B1\u8D39\u987B --network ALL\uFF1B\u53EF --time-increment 1 \u6309\u65E5\uFF09"
154130
- ).requiredOption(...ACCOUNT_OPTION5).option(...START_OPTION).option(...END_OPTION).option("--time-increment <n>", "\u4F20 1 \u6309\u65E5\u5207\u5206\uFF1B\u4E0D\u4F20=\u533A\u95F4\u6C47\u603B\u3002Direct \u65E0\u5C0F\u65F6\u7EF4\u5EA6").option("--network <value>", "SEARCH\uFF08\u9ED8\u8BA4\uFF09\u6216 ALL\uFF08\u5168\u7F51\u4E00\u884C\u5408\u8BA1\uFF0C\u884C\u5185 network \u4E3A null\uFF09").option("--limit <n>", "\u6761\u6570\u4E0A\u9650\uFF08\u9ED8\u8BA4\u7F51\u5173 100\uFF0C\u6700\u5927 10000\uFF09", (v) => parseInt(v, 10)).option("-t, --token <token>", "Auth Token").option("--json-out <path>", JSON_OUT_OPTION_DESC5).option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(
154184
+ ).requiredOption(...ACCOUNT_OPTION4).option(...START_OPTION).option(...END_OPTION).option("--time-increment <n>", "\u4F20 1 \u6309\u65E5\u5207\u5206\uFF1B\u4E0D\u4F20=\u533A\u95F4\u6C47\u603B\u3002Direct \u65E0\u5C0F\u65F6\u7EF4\u5EA6").option("--network <value>", "SEARCH\uFF08\u9ED8\u8BA4\uFF09\u6216 ALL\uFF08\u5168\u7F51\u4E00\u884C\u5408\u8BA1\uFF0C\u884C\u5185 network \u4E3A null\uFF09").option("--limit <n>", "\u6761\u6570\u4E0A\u9650\uFF08\u9ED8\u8BA4\u7F51\u5173 100\uFF0C\u6700\u5927 10000\uFF09", (v) => parseInt(v, 10)).option("-t, --token <token>", "Auth Token").option("--json-out <path>", JSON_OUT_OPTION_DESC4).option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(
154131
154185
  async (opts) => {
154132
154186
  await runYandexCampaignEntities(opts);
154133
154187
  }
154134
154188
  );
154135
154189
  root.command("adgroup-entities").description(
154136
154190
  "\u5E7F\u544A\u7EC4\u7EE9\u6548+\u7CFB\u5217\u76EE\u6807 CPA/\u5468\u9884\u7B97\uFF08GET /adgroups\uFF1B\u9ED8\u8BA4\u5168\u7F51\uFF1BCPA \u98D9\u5347\u770B\u8FD1 3 \u65E5\u533A\u95F4\u6C47\u603B\uFF0C\u4E0D\u8981\u4F20 timeIncrement\uFF09"
154137
- ).requiredOption(...ACCOUNT_OPTION5).option(...START_OPTION).option(...END_OPTION).option("--time-increment <n>", "\u4F20 1 \u6309\u65E5\u5207\u5206\uFF1B\u4E0D\u4F20=\u533A\u95F4\u6C47\u603B").option("--campaign-id <id>", "\u53EA\u62C9\u8BE5\u7CFB\u5217\u4E0B\u7684\u7EC4").option("--limit <n>", "\u6761\u6570\u4E0A\u9650\uFF08\u9ED8\u8BA4\u7F51\u5173 100\uFF0C\u6700\u5927 10000\uFF09", (v) => parseInt(v, 10)).option("-t, --token <token>", "Auth Token").option("--json-out <path>", JSON_OUT_OPTION_DESC5).option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(
154191
+ ).requiredOption(...ACCOUNT_OPTION4).option(...START_OPTION).option(...END_OPTION).option("--time-increment <n>", "\u4F20 1 \u6309\u65E5\u5207\u5206\uFF1B\u4E0D\u4F20=\u533A\u95F4\u6C47\u603B").option("--campaign-id <id>", "\u53EA\u62C9\u8BE5\u7CFB\u5217\u4E0B\u7684\u7EC4").option("--limit <n>", "\u6761\u6570\u4E0A\u9650\uFF08\u9ED8\u8BA4\u7F51\u5173 100\uFF0C\u6700\u5927 10000\uFF09", (v) => parseInt(v, 10)).option("-t, --token <token>", "Auth Token").option("--json-out <path>", JSON_OUT_OPTION_DESC4).option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(
154138
154192
  async (opts) => {
154139
154193
  await runYandexAdGroupEntities(opts);
154140
154194
  }
154141
154195
  );
154142
154196
  root.command("ad-entities").description(
154143
154197
  `\u5E7F\u544A\u7EE9\u6548+\u843D\u5730\u9875/\u62D2\u5BA1\uFF08GET /ads\uFF1B\u62D2\u5BA1\u4F20 --status REJECTED\uFF1B\u5408\u6CD5\uFF1A${YANDEX_AD_STATUSES.join(",")}\uFF1B\u4E0E --time-increment \u4E92\u65A5\uFF09`
154144
- ).requiredOption(...ACCOUNT_OPTION5).option(...START_OPTION).option(...END_OPTION).option("--time-increment <n>", "\u4F20 1 \u6309\u65E5\u5207\u5206\uFF1B\u4E0D\u4F20=\u533A\u95F4\u6C47\u603B\u3002\u4E0D\u8981\u548C --status \u540C\u65F6\u4F20").option(
154198
+ ).requiredOption(...ACCOUNT_OPTION4).option(...START_OPTION).option(...END_OPTION).option("--time-increment <n>", "\u4F20 1 \u6309\u65E5\u5207\u5206\uFF1B\u4E0D\u4F20=\u533A\u95F4\u6C47\u603B\u3002\u4E0D\u8981\u548C --status \u540C\u65F6\u4F20").option(
154145
154199
  "--status <list>",
154146
154200
  "\u5BA1\u6838\u6001\u9017\u53F7\u5206\u9694\uFF0C\u5982 REJECTED \u6216 MODERATION,REJECTED\uFF1B\u5E26 status \u65F6\u4E0D\u62C9\u7EE9\u6548\uFF08spend=0\uFF09"
154147
- ).option("--campaign-id <id>", "\u53EA\u62C9\u8BE5\u7CFB\u5217\u4E0B\u7684\u5E7F\u544A").option("--adgroup-id <id>", "\u53EA\u62C9\u8BE5\u7EC4\u4E0B\u7684\u5E7F\u544A").option("--limit <n>", "\u6761\u6570\u4E0A\u9650\uFF08\u9ED8\u8BA4\u7F51\u5173 100\uFF0C\u6700\u5927 10000\uFF09", (v) => parseInt(v, 10)).option("-t, --token <token>", "Auth Token").option("--json-out <path>", JSON_OUT_OPTION_DESC5).option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(
154201
+ ).option("--campaign-id <id>", "\u53EA\u62C9\u8BE5\u7CFB\u5217\u4E0B\u7684\u5E7F\u544A").option("--adgroup-id <id>", "\u53EA\u62C9\u8BE5\u7EC4\u4E0B\u7684\u5E7F\u544A").option("--limit <n>", "\u6761\u6570\u4E0A\u9650\uFF08\u9ED8\u8BA4\u7F51\u5173 100\uFF0C\u6700\u5927 10000\uFF09", (v) => parseInt(v, 10)).option("-t, --token <token>", "Auth Token").option("--json-out <path>", JSON_OUT_OPTION_DESC4).option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(
154148
154202
  async (opts) => {
154149
154203
  await runYandexAdEntities(opts);
154150
154204
  }
154151
154205
  );
154152
154206
  root.command("insights").description(
154153
154207
  "YandexAPI \u62A5\u8868\u5207\u7247\uFF08GET /daily|/geo|/devices|/keywords \u6216 campaigns/adgroups/ads\uFF1B\u53EF\u542B\u4ECA\u5929\uFF1B\u65E0\u5C0F\u65F6\u7EF4\u5EA6\u3002geo/devices \u5168\u7F51\u987B --network ALL\uFF09"
154154
- ).requiredOption(...ACCOUNT_OPTION5).requiredOption("--level <level>", YANDEX_INSIGHTS_LEVELS.join(" / ")).option(...START_OPTION).option(...END_OPTION).option("--time-increment <n>", "\u4EC5 campaigns/adgroups/ads\uFF1A\u4F20 1 \u6309\u65E5\uFF1B\u4E0D\u8981\u548C --status \u540C\u65F6\u4F20").option("--network <value>", "\u4EC5 campaigns/geo/devices\uFF1ASEARCH \u6216 ALL").option("--status <list>", "\u4EC5 --level ads\uFF1A\u5BA1\u6838\u6001\u8FC7\u6EE4").option("--campaign-id <id>", "\u4EC5 adgroups/ads").option("--adgroup-id <id>", "\u4EC5 ads").option("--limit <n>", "\u6709 limit \u7684 path\uFF1A\u9ED8\u8BA4\u7F51\u5173 100\uFF0C\u6700\u5927 10000", (v) => parseInt(v, 10)).option("-t, --token <token>", "Auth Token").option("--json-out <path>", JSON_OUT_OPTION_DESC5).option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(
154208
+ ).requiredOption(...ACCOUNT_OPTION4).requiredOption("--level <level>", YANDEX_INSIGHTS_LEVELS.join(" / ")).option(...START_OPTION).option(...END_OPTION).option("--time-increment <n>", "\u4EC5 campaigns/adgroups/ads\uFF1A\u4F20 1 \u6309\u65E5\uFF1B\u4E0D\u8981\u548C --status \u540C\u65F6\u4F20").option("--network <value>", "\u4EC5 campaigns/geo/devices\uFF1ASEARCH \u6216 ALL").option("--status <list>", "\u4EC5 --level ads\uFF1A\u5BA1\u6838\u6001\u8FC7\u6EE4").option("--campaign-id <id>", "\u4EC5 adgroups/ads").option("--adgroup-id <id>", "\u4EC5 ads").option("--limit <n>", "\u6709 limit \u7684 path\uFF1A\u9ED8\u8BA4\u7F51\u5173 100\uFF0C\u6700\u5927 10000", (v) => parseInt(v, 10)).option("-t, --token <token>", "Auth Token").option("--json-out <path>", JSON_OUT_OPTION_DESC4).option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(
154155
154209
  async (opts) => {
154156
154210
  await runYandexInsights(opts);
154157
154211
  }
154158
154212
  );
154159
- root.command("campaign-state").description("\u6682\u505C\u6216\u6062\u590D\u7CFB\u5217\uFF08Direct campaigns.suspend / campaigns.resume\uFF09").requiredOption(...ACCOUNT_OPTION5).requiredOption("--campaign-id <id>", "\u7CFB\u5217 ID").requiredOption("--action <action>", "suspend \u6216 resume").option("-t, --token <token>", "Auth Token").option("--json-out <path>", JSON_OUT_OPTION_DESC5).option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(async (opts) => {
154213
+ root.command("campaign-state").description("\u6682\u505C\u6216\u6062\u590D\u7CFB\u5217\uFF08Direct campaigns.suspend / campaigns.resume\uFF09").requiredOption(...ACCOUNT_OPTION4).requiredOption("--campaign-id <id>", "\u7CFB\u5217 ID").requiredOption("--action <action>", "suspend \u6216 resume").option("-t, --token <token>", "Auth Token").option("--json-out <path>", JSON_OUT_OPTION_DESC4).option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(async (opts) => {
154160
154214
  await runYandexCampaignState(opts);
154161
154215
  });
154162
- root.command("campaign-budget").description("\u6539\u7CFB\u5217\u65E5\u9884\u7B97\uFF08Direct campaigns.update DailyBudget\uFF1B\u91D1\u989D\u662F\u8D26\u6237\u5E01\u79CD\uFF0C\u7F51\u5173\u6362\u7B97 micros\uFF09").requiredOption(...ACCOUNT_OPTION5).requiredOption("--campaign-id <id>", "\u7CFB\u5217 ID").requiredOption("--daily-budget <amount>", "\u65E5\u9884\u7B97\uFF0C\u8D26\u6237\u5E01\u79CD\uFF0C\u5FC5\u987B\u5927\u4E8E 0").option("--mode <mode>", "STANDARD\uFF08\u9ED8\u8BA4\uFF09\u6216 DISTRIBUTED").option("-t, --token <token>", "Auth Token").option("--json-out <path>", JSON_OUT_OPTION_DESC5).option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(async (opts) => {
154216
+ root.command("campaign-budget").description("\u6539\u7CFB\u5217\u65E5\u9884\u7B97\uFF08Direct campaigns.update DailyBudget\uFF1B\u91D1\u989D\u662F\u8D26\u6237\u5E01\u79CD\uFF0C\u7F51\u5173\u6362\u7B97 micros\uFF09").requiredOption(...ACCOUNT_OPTION4).requiredOption("--campaign-id <id>", "\u7CFB\u5217 ID").requiredOption("--daily-budget <amount>", "\u65E5\u9884\u7B97\uFF0C\u8D26\u6237\u5E01\u79CD\uFF0C\u5FC5\u987B\u5927\u4E8E 0").option("--mode <mode>", "STANDARD\uFF08\u9ED8\u8BA4\uFF09\u6216 DISTRIBUTED").option("-t, --token <token>", "Auth Token").option("--json-out <path>", JSON_OUT_OPTION_DESC4).option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(async (opts) => {
154163
154217
  await runYandexCampaignBudget(opts);
154164
154218
  });
154165
- root.command("adgroup-state").description("\u5E7F\u544A\u7EC4\u4E0D\u80FD\u5355\u72EC\u542F\u505C\uFF08Direct \u7684 AdGroups \u6CA1\u6709 suspend/resume\uFF1B\u8BF7\u7528 ad-state \u6216 campaign-state\uFF09").requiredOption(...ACCOUNT_OPTION5).requiredOption("--adgroup-id <id>", "\u5E7F\u544A\u7EC4 ID").requiredOption("--action <action>", "suspend \u6216 resume").option("-t, --token <token>", "Auth Token").option("--json-out <path>", JSON_OUT_OPTION_DESC5).option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(async (opts) => {
154219
+ root.command("adgroup-state").description("\u5E7F\u544A\u7EC4\u4E0D\u80FD\u5355\u72EC\u542F\u505C\uFF08Direct \u7684 AdGroups \u6CA1\u6709 suspend/resume\uFF1B\u8BF7\u7528 ad-state \u6216 campaign-state\uFF09").requiredOption(...ACCOUNT_OPTION4).requiredOption("--adgroup-id <id>", "\u5E7F\u544A\u7EC4 ID").requiredOption("--action <action>", "suspend \u6216 resume").option("-t, --token <token>", "Auth Token").option("--json-out <path>", JSON_OUT_OPTION_DESC4).option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(async (opts) => {
154166
154220
  await runYandexAdGroupState({ ...opts, adGroupId: opts.adgroupId });
154167
154221
  });
154168
- root.command("ad-state").description("\u6682\u505C\u6216\u6062\u590D\u5E7F\u544A\uFF08Direct ads.suspend / ads.resume\uFF09").requiredOption(...ACCOUNT_OPTION5).requiredOption("--ad-id <id>", "\u5E7F\u544A ID").requiredOption("--action <action>", "suspend \u6216 resume").option("-t, --token <token>", "Auth Token").option("--json-out <path>", JSON_OUT_OPTION_DESC5).option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(async (opts) => {
154222
+ root.command("ad-state").description("\u6682\u505C\u6216\u6062\u590D\u5E7F\u544A\uFF08Direct ads.suspend / ads.resume\uFF09").requiredOption(...ACCOUNT_OPTION4).requiredOption("--ad-id <id>", "\u5E7F\u544A ID").requiredOption("--action <action>", "suspend \u6216 resume").option("-t, --token <token>", "Auth Token").option("--json-out <path>", JSON_OUT_OPTION_DESC4).option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(async (opts) => {
154169
154223
  await runYandexAdState(opts);
154170
154224
  });
154171
- root.command("keyword-bid").description("\u6539\u5173\u952E\u8BCD\u641C\u7D22\u51FA\u4EF7\uFF08Direct keywordbids.set SearchBid\uFF1B\u91D1\u989D\u662F\u8D26\u6237\u5E01\u79CD\uFF09").requiredOption(...ACCOUNT_OPTION5).requiredOption("--keyword-id <id>", "\u5173\u952E\u8BCD ID").requiredOption("--search-bid <amount>", "\u641C\u7D22\u51FA\u4EF7\uFF0C\u8D26\u6237\u5E01\u79CD\uFF0C\u5FC5\u987B\u5927\u4E8E 0").option("-t, --token <token>", "Auth Token").option("--json-out <path>", JSON_OUT_OPTION_DESC5).option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(async (opts) => {
154225
+ root.command("keyword-bid").description("\u6539\u5173\u952E\u8BCD\u641C\u7D22\u51FA\u4EF7\uFF08Direct keywordbids.set SearchBid\uFF1B\u91D1\u989D\u662F\u8D26\u6237\u5E01\u79CD\uFF09").requiredOption(...ACCOUNT_OPTION4).requiredOption("--keyword-id <id>", "\u5173\u952E\u8BCD ID").requiredOption("--search-bid <amount>", "\u641C\u7D22\u51FA\u4EF7\uFF0C\u8D26\u6237\u5E01\u79CD\uFF0C\u5FC5\u987B\u5927\u4E8E 0").option("-t, --token <token>", "Auth Token").option("--json-out <path>", JSON_OUT_OPTION_DESC4).option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(async (opts) => {
154172
154226
  await runYandexKeywordBid(opts);
154173
154227
  });
154174
154228
  }
@@ -154214,6 +154268,7 @@ var BING_COVERAGE_WRITES = [
154214
154268
  "hotel-length-of-stay",
154215
154269
  "hotel-date-selection",
154216
154270
  "product-ad",
154271
+ "responsive-ad",
154217
154272
  "hotel-ad",
154218
154273
  "app-install-ad",
154219
154274
  "update-responsive-ad",
@@ -154645,9 +154700,7 @@ var GAP_ACTIONS = {
154645
154700
  "bing.delete-campaigns": bing("campaigns/delete"),
154646
154701
  "bing.ad-group": bing("ad-groups"),
154647
154702
  "bing.delete-ad-groups": bing("ad-groups/delete"),
154648
- // 搜索响应式广告走 library/ads。受众广告是 bing.responsive-audience-ad。
154649
154703
  "bing.responsive-ad": bing("ads"),
154650
- "bing.responsive-audience-ad": bing("coverage/responsive-ad"),
154651
154704
  "bing.delete-ads": bing("ads/delete"),
154652
154705
  "bing.keywords": bing("keywords"),
154653
154706
  "bing.keyword-bids": bing("keywords/bids"),
@@ -154795,88 +154848,6 @@ var GAP_ACTIONS = {
154795
154848
  "tiktok.ad-group": tiktok("ad-groups"),
154796
154849
  "tiktok.ad": tiktok("ads"),
154797
154850
  "tiktok.smart-creative": tiktok("smart-creatives"),
154798
- "tiktok.rename-campaign": tiktok("campaign-names"),
154799
- "tiktok.rename-ad-group": tiktok("ad-group-names"),
154800
- "tiktok.rename-ad": tiktok("ad-names"),
154801
- "tiktok.rename-advertiser": tiktok("advertiser-names"),
154802
- "tiktok.video-library": tiktok("video-library"),
154803
- "tiktok.image-library": tiktok("image-library"),
154804
- "tiktok.suggest-cover": tiktok("suggest-covers"),
154805
- "tiktok.lookalike": tiktok("lookalikes"),
154806
- "tiktok.refresh-lookalike": tiktok("lookalikes/refresh"),
154807
- "tiktok.audience-detail": tiktok("audiences/detail"),
154808
- "tiktok.audience-overlap": tiktok("audiences/overlap"),
154809
- "tiktok.diagnosis": tiktok("diagnosis"),
154810
- "tiktok.creative-fatigue": tiktok("creative-fatigue"),
154811
- "tiktok.search-keywords": tiktok("search-keywords"),
154812
- "tiktok.keyword-ideas": tiktok("keyword-ideas"),
154813
- "tiktok.search-health": tiktok("search-health"),
154814
- "tiktok.negative-keyword-list": tiktok("negative-keywords/list"),
154815
- "tiktok.delete-negative-keywords": tiktok("negative-keywords/delete"),
154816
- "tiktok.read-campaigns": tiktok("campaigns/raw"),
154817
- "tiktok.read-ad-groups": tiktok("ad-groups/raw"),
154818
- "tiktok.read-ads": tiktok("ads/raw"),
154819
- "tiktok.smart-plus-ad-group": tiktok("smart-plus/ad-groups"),
154820
- "tiktok.smart-plus-ad": tiktok("smart-plus/ads"),
154821
- "tiktok.smart-plus-campaign-status": tiktok("smart-plus/campaign-status"),
154822
- "tiktok.smart-plus-ad-group-status": tiktok("smart-plus/ad-group-status"),
154823
- "tiktok.smart-plus-ad-status": tiktok("smart-plus/ad-status"),
154824
- "tiktok.read-smart-creative": tiktok("smart-creatives/raw"),
154825
- "tiktok.update-smart-creative": tiktok("smart-creatives/update"),
154826
- "tiktok.catalog": tiktok("catalogs"),
154827
- "tiktok.update-catalog": tiktok("catalogs/update"),
154828
- "tiktok.delete-catalog": tiktok("catalogs/delete"),
154829
- "tiktok.read-catalogs": tiktok("catalogs/list"),
154830
- "tiktok.catalog-countries": tiktok("catalog-countries"),
154831
- "tiktok.catalog-products": tiktok("catalog-products"),
154832
- "tiktok.catalog-product-log": tiktok("catalog-product-logs"),
154833
- "tiktok.catalog-set": tiktok("catalog-sets"),
154834
- "tiktok.read-catalog-sets": tiktok("catalog-sets/list"),
154835
- "tiktok.catalog-feed": tiktok("catalog-feeds"),
154836
- "tiktok.read-catalog-feeds": tiktok("catalog-feeds/list"),
154837
- "tiktok.catalog-diagnosis": tiktok("catalog-diagnosis"),
154838
- "tiktok.catalog-overview": tiktok("catalog-overviews"),
154839
- "tiktok.catalog-event-bind": tiktok("catalog-events"),
154840
- "tiktok.store-products": tiktok("store-products"),
154841
- "tiktok.read-gmv-max": tiktok("gmv-max/info"),
154842
- "tiktok.update-gmv-max": tiktok("gmv-max/update"),
154843
- "tiktok.gmv-max-stores": tiktok("gmv-max/stores"),
154844
- "tiktok.gmv-max-report": tiktok("gmv-max/report"),
154845
- "tiktok.rule": tiktok("rules"),
154846
- "tiktok.update-rule": tiktok("rules/update"),
154847
- "tiktok.rule-status": tiktok("rules/status"),
154848
- "tiktok.read-rules": tiktok("rules/list"),
154849
- "tiktok.rule-results": tiktok("rules/results"),
154850
- "tiktok.comments": tiktok("comments"),
154851
- "tiktok.comment-reply": tiktok("comments/reply"),
154852
- "tiktok.blocked-words": tiktok("blocked-words"),
154853
- "tiktok.create-blocked-words": tiktok("blocked-words/create"),
154854
- "tiktok.delete-blocked-words": tiktok("blocked-words/delete"),
154855
- "tiktok.spark-auth": tiktok("spark/authorize"),
154856
- "tiktok.spark-posts": tiktok("spark/posts"),
154857
- "tiktok.spark-unbind": tiktok("spark/unbind"),
154858
- "tiktok.playables": tiktok("playables"),
154859
- "tiktok.report-task": tiktok("report-tasks"),
154860
- "tiktok.report-task-check": tiktok("report-tasks/check"),
154861
- "tiktok.copy-task": tiktok("copy-tasks"),
154862
- "tiktok.update-split-test": tiktok("split-tests/update"),
154863
- "tiktok.end-split-test": tiktok("split-tests/end"),
154864
- "tiktok.split-test-result": tiktok("split-tests/result"),
154865
- "tiktok.promote-split-test": tiktok("split-tests/promote"),
154866
- "tiktok.saved-audience": tiktok("saved-audiences"),
154867
- "tiktok.read-saved-audiences": tiktok("saved-audiences/list"),
154868
- "tiktok.delete-saved-audience": tiktok("saved-audiences/delete"),
154869
- "tiktok.update-pixel": tiktok("pixels/update"),
154870
- "tiktok.delete-pixel": tiktok("pixels/delete"),
154871
- "tiktok.update-pixel-event": tiktok("pixel-events/update"),
154872
- "tiktok.delete-pixel-event": tiktok("pixel-events/delete"),
154873
- "tiktok.custom-conversion": tiktok("custom-conversions"),
154874
- "tiktok.read-custom-conversions": tiktok("custom-conversions/list"),
154875
- "tiktok.update-custom-conversion": tiktok("custom-conversions/update"),
154876
- "tiktok.delete-custom-conversion": tiktok("custom-conversions/delete"),
154877
- "tiktok.ad-review": tiktok("ad-reviews"),
154878
- "tiktok.ad-group-review": tiktok("ad-group-reviews"),
154879
- "tiktok.ad-appeal": tiktok("ad-appeals"),
154880
154851
  "meta.outcome-campaign": facebook("outcome-campaigns"),
154881
154852
  "meta.outcome-campaign-update": facebook("outcome-campaigns/{id}", { needsId: true }),
154882
154853
  "meta.advantage-campaign": facebook("advantage-campaigns"),
@@ -154899,8 +154870,6 @@ var GAP_ACTIONS = {
154899
154870
  needsBody: false
154900
154871
  }),
154901
154872
  "google.customer-match-list": google("POST", "/customer-match/{account}/user-lists"),
154902
- "google.lookalike-list": google("POST", "/lookalike-user-lists/{account}?seedUserListId={id}", { needsId: true }),
154903
- "google.ga4-link": google("POST", "/ga4-links/{account}"),
154904
154873
  "google.remove-customer-match-list": google("DELETE", "/customer-match/{account}/user-lists/{id}", { needsId: true, needsBody: false }),
154905
154874
  "google.customer-match-job": google("POST", "/customer-match/{account}/jobs?userListId={id}", { needsId: true, needsBody: false }),
154906
154875
  "google.customer-match-operations": google("POST", "/customer-match/{account}/jobs/{id}/operations", { needsId: true }),
@@ -155010,11 +154979,46 @@ var GAP_ACTIONS = {
155010
154979
  function gapActionNames() {
155011
154980
  return Object.keys(GAP_ACTIONS).sort();
155012
154981
  }
154982
+ var READ_AFTER_WRITE = {
154983
+ "meta.outcome-campaign": "meta.read-campaign",
154984
+ "meta.outcome-campaign-update": "meta.read-campaign",
154985
+ "meta.advantage-campaign": "meta.read-campaign",
154986
+ "meta.outcome-adset": "meta.read-adset",
154987
+ "meta.advantage-adset": "meta.read-adset",
154988
+ "meta.outcome-ad": "meta.read-ad",
154989
+ "meta.copy-campaign": "meta.read-campaign",
154990
+ "meta.copy-adset": "meta.read-adset",
154991
+ "meta.copy-ad": "meta.read-ad",
154992
+ "bing.campaign-budget": "bing.read-budgets",
154993
+ "yandex.unified-campaign": "yandex.read-campaigns"
154994
+ };
154995
+ function findReadbackAction(writeName) {
154996
+ const named = READ_AFTER_WRITE[writeName];
154997
+ if (named && GAP_ACTIONS[named]) return named;
154998
+ const write = GAP_ACTIONS[writeName];
154999
+ if (!write || write.method === "GET") return null;
155000
+ const dot = writeName.indexOf(".");
155001
+ if (dot < 0) return null;
155002
+ const prefix = writeName.slice(0, dot + 1);
155003
+ const rest = writeName.slice(dot + 1).replace(/^(update-|delete-)/, "");
155004
+ for (const name2 of [`${prefix}read-${rest}`, `${prefix}read-${rest}s`]) {
155005
+ if (GAP_ACTIONS[name2]) return name2;
155006
+ }
155007
+ for (const [name2, action] of Object.entries(GAP_ACTIONS)) {
155008
+ if (name2 !== writeName && action.service === write.service && action.path === write.path && action.method === "GET") {
155009
+ return name2;
155010
+ }
155011
+ }
155012
+ return null;
155013
+ }
155013
155014
  function resolveGapPath(actionName, target) {
155014
155015
  const action = GAP_ACTIONS[actionName];
155015
155016
  if (!action) {
155016
155017
  throw new Error(`\u672A\u77E5 action\uFF1A${actionName}`);
155017
155018
  }
155019
+ if (action.service === "tiktok" && action.path.toLowerCase().includes("catalog")) {
155020
+ throw new Error("\u5546\u54C1\u76EE\u5F55\u8DEF\u5F84\u672A\u63A5\u5165");
155021
+ }
155018
155022
  const account = requireToken(target.account, "account");
155019
155023
  const parent = action.needsParent ? requireToken(target.parent, "parent") : target.parent?.trim() ?? "";
155020
155024
  const id = action.needsId ? requireToken(target.id, "id") : target.id?.trim() ?? "";
@@ -155046,7 +155050,123 @@ function requireToken(value, label2) {
155046
155050
  init_auth();
155047
155051
  init_cli_json_snapshot();
155048
155052
  init_shared();
155049
- import { readFileSync as readFileSync22 } from "fs";
155053
+ import { readFileSync as readFileSync21 } from "fs";
155054
+
155055
+ // src/commands/ad-gap/readback.ts
155056
+ init_auth();
155057
+ var COMPARE_KEYS = ["budget", "daily_budget", "amount", "status", "statusV2", "name", "countries"];
155058
+ function readCreatedId(payload) {
155059
+ if (!payload || typeof payload !== "object") return "";
155060
+ const row = payload;
155061
+ for (const key of ["id", "Id", "campaign_id", "campaignId", "adset_id", "ad_id"]) {
155062
+ const value = row[key];
155063
+ if (typeof value === "string" && value.trim()) return value.trim();
155064
+ if (typeof value === "number" && Number.isFinite(value)) return String(value);
155065
+ }
155066
+ if (row["data"] && typeof row["data"] === "object") return readCreatedId(row["data"]);
155067
+ return "";
155068
+ }
155069
+ function findDeep(value, key, depth = 0) {
155070
+ if (value == null || depth > 6) return void 0;
155071
+ if (Array.isArray(value)) {
155072
+ for (const item of value) {
155073
+ const hit = findDeep(item, key, depth + 1);
155074
+ if (hit !== void 0) return hit;
155075
+ }
155076
+ return void 0;
155077
+ }
155078
+ if (typeof value !== "object") return void 0;
155079
+ const row = value;
155080
+ if (Object.prototype.hasOwnProperty.call(row, key) && row[key] != null) {
155081
+ if (typeof row[key] !== "object" || Array.isArray(row[key])) return row[key];
155082
+ }
155083
+ for (const child of Object.values(row)) {
155084
+ const hit = findDeep(child, key, depth + 1);
155085
+ if (hit !== void 0) return hit;
155086
+ }
155087
+ return void 0;
155088
+ }
155089
+ function displayList(value) {
155090
+ if (Array.isArray(value)) return value.map((item) => String(item)).sort().join(",");
155091
+ return String(value);
155092
+ }
155093
+ function compareGapBody(body, payload, deleted) {
155094
+ if (deleted) {
155095
+ if (payload == null) {
155096
+ return [receiptLine("\u5BF9\u8C61", "\u5DF2\u5220\u9664", void 0)];
155097
+ }
155098
+ const status = findDeep(payload, "status") ?? findDeep(payload, "statusV2");
155099
+ const gone = status == null || /delete|removed|archive/i.test(String(status));
155100
+ return [receiptLine("\u5BF9\u8C61", "\u5DF2\u5220\u9664", gone ? "\u5DF2\u5220\u9664" : status)];
155101
+ }
155102
+ if (!body || typeof body !== "object" || Array.isArray(body)) {
155103
+ return [receiptLine("\u5199\u5165", "\u5DF2\u63D0\u4EA4", payload == null ? void 0 : "\u5DF2\u8BFB\u56DE")];
155104
+ }
155105
+ const lines = [];
155106
+ const record2 = body;
155107
+ for (const key of COMPARE_KEYS) {
155108
+ if (record2[key] == null || typeof record2[key] === "object" && !Array.isArray(record2[key])) continue;
155109
+ const expected = Array.isArray(record2[key]) ? displayList(record2[key]) : record2[key];
155110
+ const actualRaw = findDeep(payload, key);
155111
+ const actual = actualRaw == null ? void 0 : Array.isArray(actualRaw) ? displayList(actualRaw) : actualRaw;
155112
+ lines.push(receiptLine(key, expected, actual));
155113
+ }
155114
+ if (lines.length === 0) {
155115
+ lines.push(receiptLine("\u5199\u5165", "\u5DF2\u63D0\u4EA4", payload == null ? void 0 : "\u5DF2\u8BFB\u56DE"));
155116
+ }
155117
+ return lines;
155118
+ }
155119
+ async function printAdGapReadback(opts) {
155120
+ const readName = findReadbackAction(opts.action);
155121
+ if (!readName) {
155122
+ printWriteReceipt("unknown", [receiptLine("\u8BFB\u56DE", "\u6709\u914D\u5BF9\u67E5\u8BE2", void 0)]);
155123
+ return;
155124
+ }
155125
+ const createdId = readCreatedId(opts.payload) || opts.id || "";
155126
+ const deleted = opts.action.includes("delete");
155127
+ let path61;
155128
+ let method;
155129
+ let needsBody;
155130
+ try {
155131
+ const resolved = resolveGapPath(readName, {
155132
+ account: opts.account,
155133
+ parent: opts.parent,
155134
+ id: createdId,
155135
+ label: opts.label
155136
+ });
155137
+ path61 = resolved.path;
155138
+ method = resolved.action.method;
155139
+ needsBody = resolved.action.needsBody !== false;
155140
+ } catch {
155141
+ printWriteReceipt("unknown", [receiptLine("\u8BFB\u56DE", readName, void 0)]);
155142
+ return;
155143
+ }
155144
+ const config = loadConfig(opts.token);
155145
+ let readPayload;
155146
+ try {
155147
+ readPayload = await apiFetch2(
155148
+ opts.serviceBase(resolveGapPath(readName, { account: opts.account, id: createdId, parent: opts.parent, label: opts.label }).action.service, config) + path61,
155149
+ config,
155150
+ {
155151
+ method,
155152
+ body: needsBody ? JSON.stringify(opts.body ?? {}) : void 0
155153
+ },
155154
+ opts.verbose
155155
+ );
155156
+ } catch (err) {
155157
+ const message = err instanceof Error ? err.message : String(err);
155158
+ if (deleted && /404|未找到|not found/i.test(message)) {
155159
+ printWriteReceipt("verified", [receiptLine("\u5BF9\u8C61", "\u5DF2\u5220\u9664", "\u5DF2\u5220\u9664")]);
155160
+ return;
155161
+ }
155162
+ printWriteReceipt("unknown", [receiptLine("\u8BFB\u56DE", readName, void 0)]);
155163
+ return;
155164
+ }
155165
+ const lines = compareGapBody(opts.body, readPayload, deleted);
155166
+ printWriteReceipt(judgeReceipt(lines), lines);
155167
+ }
155168
+
155169
+ // src/commands/ad-gap/run.ts
155050
155170
  function readGapBody(opts, required) {
155051
155171
  const inline = opts.body?.trim();
155052
155172
  const file = opts.bodyFile?.trim();
@@ -155057,7 +155177,7 @@ function readGapBody(opts, required) {
155057
155177
  if (!required) return void 0;
155058
155178
  throw new Error("\u8FD9\u4E2A action \u9700\u8981 --body \u6216 --body-file");
155059
155179
  }
155060
- const raw = file ? readFileSync22(file, "utf8") : inline;
155180
+ const raw = file ? readFileSync21(file, "utf8") : inline;
155061
155181
  let parsed;
155062
155182
  try {
155063
155183
  parsed = JSON.parse(raw);
@@ -155204,6 +155324,20 @@ async function runAdGap(opts) {
155204
155324
  if (resolved.action.service === "tiktok") {
155205
155325
  assertTikTokAccepted(payload);
155206
155326
  }
155327
+ if (resolved.action.method !== "GET") {
155328
+ await printAdGapReadback({
155329
+ action: opts.action,
155330
+ account: opts.account,
155331
+ parent: opts.parent,
155332
+ id: opts.id,
155333
+ label: opts.label,
155334
+ token: opts.token,
155335
+ verbose: opts.verbose,
155336
+ body,
155337
+ payload,
155338
+ serviceBase
155339
+ });
155340
+ }
155207
155341
  const emitted = await emitCliJsonOrSnapshot(
155208
155342
  { jsonOut: opts.jsonOut },
155209
155343
  {
@@ -155453,7 +155587,7 @@ configureCliJsonSnapshot({
155453
155587
  configureSiluzanClientIdentity({ client: "tso-cli", resolveVersion: getVersion });
155454
155588
  var program = new Command6();
155455
155589
  program.name("siluzan-tso").description(
155456
- "Siluzan \u5E7F\u544A\u8D26\u6237\u7BA1\u7406\uFF1A\u8D26\u6237\u67E5\u8BE2\u3001\u4F59\u989D\u3001\u6295\u653E\u6570\u636E\u3001\u5F00\u6237\u7533\u8BF7\uFF08Google/TikTok/Yandex/Bing/Meta\uFF09\u3001\n\u8D26\u53F7\u5206\u4EAB/\u89E3\u7ED1\u3001\u4F18\u5316\u62A5\u544A\u3001Google/Meta/TikTok/Bing/Yandex \u8D26\u6237\u5206\u6790\u3001GA4 \u6307\u6807\uFF08ga4\uFF09\u3001Google \u5E7F\u544A\u8BCA\u65AD\u62A5\u544A\uFF08google-ads-diagnosis render\uFF09\u3001Google \u5B63\u5EA6\u7ECF\u8425\u62A5\u544A\uFF08google-quarterly\uFF09\u3001\u7F51\u7AD9\u8BCA\u65AD\uFF08website-diagnosis\uFF09\u3001\u6218\u7565\u5E02\u573A\u5206\u6790\uFF08market-analysis\uFF0CAgent \u751F\u6210\u62A5\u544A\uFF09\u3001\u5145\u503C\u8F6C\u8D26\u3001\u5F00\u7968\u3001\u667A\u80FD\u9884\u8B66\u3001Google \u5E7F\u544A\u7BA1\u7406\uFF08Search/PMax\uFF0C\u542B\u5F02\u6B65\u6279\u91CF\uFF09\u3001Meta Instant Form \u7EBF\u7D22\u5E7F\u544A\uFF08meta-ad\uFF09\u3001Bing/Yandex/TikTok \u542F\u505C\u4E0E\u9884\u7B97\u3002"
155590
+ "Siluzan \u5E7F\u544A\u8D26\u6237\u7BA1\u7406\uFF1A\u8D26\u6237\u67E5\u8BE2\u3001\u4F59\u989D\u3001\u6295\u653E\u6570\u636E\u3001\u5F00\u6237\u7533\u8BF7\uFF08Google/TikTok/Yandex/Bing/Meta\uFF09\u3001\n\u8D26\u53F7\u5206\u4EAB/\u89E3\u7ED1\u3001\u4F18\u5316\u62A5\u544A\u3001Google/Meta/TikTok/Bing/Yandex \u8D26\u6237\u5206\u6790\u3001Google \u5E7F\u544A\u8BCA\u65AD\u62A5\u544A\uFF08google-ads-diagnosis render\uFF09\u3001Google \u5B63\u5EA6\u7ECF\u8425\u62A5\u544A\uFF08google-quarterly\uFF09\u3001\u7F51\u7AD9\u8BCA\u65AD\uFF08website-diagnosis\uFF09\u3001\u6218\u7565\u5E02\u573A\u5206\u6790\uFF08market-analysis\uFF0CAgent \u751F\u6210\u62A5\u544A\uFF09\u3001\u5145\u503C\u8F6C\u8D26\u3001\u5F00\u7968\u3001\u667A\u80FD\u9884\u8B66\u3001Google \u5E7F\u544A\u7BA1\u7406\uFF08Search/PMax\uFF0C\u542B\u5F02\u6B65\u6279\u91CF\uFF09\u3001Meta Instant Form \u7EBF\u7D22\u5E7F\u544A\uFF08meta-ad\uFF09\u3001Bing/Yandex/TikTok \u542F\u505C\u4E0E\u9884\u7B97\u3002"
155457
155591
  ).version(getVersion());
155458
155592
  program.option("--commit <text>", "\u5199\u64CD\u4F5C\u8BF4\u660E\uFF1B\u8BB0\u5165\u672C\u673A\u5199\u5BA1\u8BA1 JSONL");
155459
155593
  program.hook("preAction", async () => {
@@ -155484,7 +155618,6 @@ var REGISTRARS = [
155484
155618
  register13,
155485
155619
  register14,
155486
155620
  registerGoogleAnalysisCommands,
155487
- register28,
155488
155621
  registerGoogleAnalysisBatchCommands,
155489
155622
  registerFacebookAnalysisCommands,
155490
155623
  registerBingAnalysisCommands,