siluzan-tso-cli 1.1.74 → 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.
- package/README.md +2 -1
- package/dist/index.js +1492 -196
- package/dist/skill/_meta.json +2 -2
- package/dist/skill/references/accounts/accounts-list.md +1 -1
- package/dist/skill/references/accounts/accounts-permissions.md +2 -2
- package/dist/skill/references/accounts/finance.md +1 -1
- package/dist/skill/references/accounts/open-account-by-media.md +1 -1
- package/dist/skill/references/accounts/open-account-google-ui.md +1 -1
- package/dist/skill/references/analytics/rag.md +1 -1
- package/dist/skill/references/analytics/reporting.md +5 -5
- package/dist/skill/references/core/agent-conventions.md +9 -1
- package/dist/skill/references/core/setup.md +5 -5
- package/dist/skill/references/google-ads/google-ads-read.md +1 -1
- package/dist/skill/references/google-ads/google-ads-write.md +1 -1
- package/dist/skill/references/google-ads/google-ads.md +1 -1
- package/dist/skill/references/misc/tso-home.md +2 -2
- package/dist/skill/references/operations/hosted-automation-optimize-scale.md +1 -1
- package/dist/skill/scripts/install.ps1 +3 -3
- package/dist/skill/scripts/install.sh +3 -3
- package/eval/cases/write-readback-budget-mismatch.scenario.json +19 -0
- package/eval/cases/write-readback-extra-country.scenario.json +19 -0
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -4104,7 +4104,7 @@ var DEFAULT_API_BASE;
|
|
|
4104
4104
|
var init_defaults = __esm({
|
|
4105
4105
|
"src/config/defaults.ts"() {
|
|
4106
4106
|
"use strict";
|
|
4107
|
-
DEFAULT_API_BASE = "https://tso-api.siluzan.com";
|
|
4107
|
+
DEFAULT_API_BASE = "https://tso-api-ci.siluzan.com";
|
|
4108
4108
|
}
|
|
4109
4109
|
});
|
|
4110
4110
|
|
|
@@ -6375,6 +6375,7 @@ function negativeKeywordSlimListUrl(googleApiUrl, accountId, query) {
|
|
|
6375
6375
|
if (query?.appliedLevel) params.set("appliedlevel", query.appliedLevel);
|
|
6376
6376
|
if (query?.readDeleted) params.set("readDeleted", "true");
|
|
6377
6377
|
if (query?.excludePaused) params.set("excludePaused", "true");
|
|
6378
|
+
if (query?.newest) params.set("newest", "true");
|
|
6378
6379
|
const text5 = query?.keywordText?.trim();
|
|
6379
6380
|
if (text5) params.set("keywordtext", text5);
|
|
6380
6381
|
if (query?.matchType) params.set("matchtype", query.matchType);
|
|
@@ -6401,11 +6402,11 @@ function toDisplayMoney(raw) {
|
|
|
6401
6402
|
if (!Number.isFinite(n)) return null;
|
|
6402
6403
|
return n / 100;
|
|
6403
6404
|
}
|
|
6404
|
-
function toCentAmount(
|
|
6405
|
-
if (!Number.isFinite(
|
|
6406
|
-
throw new Error(`toCentAmount: \u8F93\u5165\u5FC5\u987B\u662F\u6709\u9650\u6570\u5B57\uFF0C\u6536\u5230 ${
|
|
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}`);
|
|
6407
6408
|
}
|
|
6408
|
-
return Math.round(
|
|
6409
|
+
return Math.round(displayValue2 * 100);
|
|
6409
6410
|
}
|
|
6410
6411
|
function convertBatchMoneyTreeFromYuan(value) {
|
|
6411
6412
|
return convertBatchMoneyTreeFromYuanInner(value);
|
|
@@ -113574,6 +113575,263 @@ async function runReportDelete(opts) {
|
|
|
113574
113575
|
init_auth();
|
|
113575
113576
|
init_cli_table();
|
|
113576
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
|
|
113577
113835
|
async function runReportPushList(opts) {
|
|
113578
113836
|
assertReportPushMedia(opts.media);
|
|
113579
113837
|
const config = await ensureDataPermission(loadConfig(opts.token));
|
|
@@ -113676,8 +113934,56 @@ async function runReportPushDelete(opts) {
|
|
|
113676
113934
|
`);
|
|
113677
113935
|
process.exit(1);
|
|
113678
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);
|
|
113679
113957
|
console.log("\n\u2705 \u63A8\u9001\u5DF2\u5220\u9664\n");
|
|
113680
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
|
+
}
|
|
113681
113987
|
async function runReportPushCreate(opts) {
|
|
113682
113988
|
assertReportPushMedia(opts.media);
|
|
113683
113989
|
const config = await ensureDataPermission(loadConfig(opts.token));
|
|
@@ -113698,6 +114004,7 @@ async function runReportPushCreate(opts) {
|
|
|
113698
114004
|
`);
|
|
113699
114005
|
process.exit(1);
|
|
113700
114006
|
}
|
|
114007
|
+
await printReportPushReceipt(config, opts);
|
|
113701
114008
|
console.log("\n\u2705 \u63A8\u9001\u914D\u7F6E\u5DF2\u521B\u5EFA\n");
|
|
113702
114009
|
}
|
|
113703
114010
|
async function runReportPushUpdate(opts) {
|
|
@@ -113721,6 +114028,7 @@ async function runReportPushUpdate(opts) {
|
|
|
113721
114028
|
`);
|
|
113722
114029
|
process.exit(1);
|
|
113723
114030
|
}
|
|
114031
|
+
await printReportPushReceipt(config, opts);
|
|
113724
114032
|
console.log("\n\u2705 \u63A8\u9001\u914D\u7F6E\u5DF2\u66F4\u65B0\n");
|
|
113725
114033
|
}
|
|
113726
114034
|
async function runReportPushHistory(opts) {
|
|
@@ -114054,6 +114362,28 @@ async function runTransferCreate(opts) {
|
|
|
114054
114362
|
`);
|
|
114055
114363
|
process.exit(1);
|
|
114056
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
|
+
);
|
|
114057
114387
|
if (await emitCliJsonOrSnapshot(opts, {
|
|
114058
114388
|
section: `transfer-create-${mediaToPath(opts.media)}`,
|
|
114059
114389
|
commandLabel: "transfer create",
|
|
@@ -114532,7 +114862,7 @@ async function runInvoiceApply(opts) {
|
|
|
114532
114862
|
} else {
|
|
114533
114863
|
const cnName = opts.companyName?.trim() ?? "";
|
|
114534
114864
|
const tax = opts.taxId?.trim() ?? "";
|
|
114535
|
-
const
|
|
114865
|
+
const title2 = opts.title?.trim() ?? "";
|
|
114536
114866
|
const landline = opts.companyPhone?.trim() ?? "";
|
|
114537
114867
|
if (!cnName) {
|
|
114538
114868
|
console.error("\n\u274C VATI/VATSI \u9700\u8981 --company-name\uFF08\u4E2D\u6587\u516C\u53F8\u540D\uFF09\n");
|
|
@@ -114542,7 +114872,7 @@ async function runInvoiceApply(opts) {
|
|
|
114542
114872
|
console.error("\n\u274C VATI/VATSI \u9700\u8981 --tax-id\uFF08\u4F01\u4E1A\u7A0E\u53F7\uFF09\n");
|
|
114543
114873
|
process.exit(1);
|
|
114544
114874
|
}
|
|
114545
|
-
if (!
|
|
114875
|
+
if (!title2) {
|
|
114546
114876
|
console.error("\n\u274C VATI/VATSI \u9700\u8981 --title\uFF08\u53D1\u7968\u62AC\u5934\uFF09\n");
|
|
114547
114877
|
process.exit(1);
|
|
114548
114878
|
}
|
|
@@ -114553,7 +114883,7 @@ async function runInvoiceApply(opts) {
|
|
|
114553
114883
|
invoiceInfomation = {
|
|
114554
114884
|
CompanyName: cnName,
|
|
114555
114885
|
TaxIdentificationNumber: tax,
|
|
114556
|
-
Title:
|
|
114886
|
+
Title: title2,
|
|
114557
114887
|
Phone: landline
|
|
114558
114888
|
};
|
|
114559
114889
|
}
|
|
@@ -114585,6 +114915,31 @@ async function runInvoiceApply(opts) {
|
|
|
114585
114915
|
`);
|
|
114586
114916
|
process.exit(1);
|
|
114587
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
|
+
);
|
|
114588
114943
|
if (await emitCliJsonOrSnapshot(opts, {
|
|
114589
114944
|
section: "invoice-apply",
|
|
114590
114945
|
commandLabel: "invoice apply",
|
|
@@ -115499,6 +115854,19 @@ async function runForewarningDelete(opts) {
|
|
|
115499
115854
|
`);
|
|
115500
115855
|
process.exit(1);
|
|
115501
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);
|
|
115502
115870
|
console.log("\n\u2705 \u9884\u8B66\u89C4\u5219\u5DF2\u5220\u9664\n");
|
|
115503
115871
|
}
|
|
115504
115872
|
async function runForewarningGet(opts) {
|
|
@@ -115686,6 +116054,21 @@ async function runForewarningCreate(opts) {
|
|
|
115686
116054
|
`);
|
|
115687
116055
|
process.exit(1);
|
|
115688
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
|
+
);
|
|
115689
116072
|
console.log(`
|
|
115690
116073
|
\u2705 \u9884\u8B66\u89C4\u5219\u5DF2${isUpdate ? "\u66F4\u65B0" : "\u521B\u5EFA"}\uFF1A${opts.name}
|
|
115691
116074
|
`);
|
|
@@ -116892,6 +117275,18 @@ function summarizeNegativeKeywordCreate(requested, response, listItems) {
|
|
|
116892
117275
|
}
|
|
116893
117276
|
|
|
116894
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
|
+
}
|
|
116895
117290
|
function unwrapKeywordDisplayTextForEdit(raw) {
|
|
116896
117291
|
const t = raw.trim();
|
|
116897
117292
|
if (t.length >= 2 && t.startsWith('"') && t.endsWith('"')) {
|
|
@@ -117207,6 +117602,37 @@ async function runAdKeywordCreate(opts) {
|
|
|
117207
117602
|
`);
|
|
117208
117603
|
process.exit(1);
|
|
117209
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);
|
|
117210
117636
|
if (await emitCliJsonOrSnapshot(opts, {
|
|
117211
117637
|
section: `ad-keyword-create-${opts.account}-${opts.adgroupId}`,
|
|
117212
117638
|
commandLabel: "ad keyword-create",
|
|
@@ -117297,7 +117723,7 @@ async function runAdNegativeKeywordCreate(opts) {
|
|
|
117297
117723
|
`);
|
|
117298
117724
|
process.exit(1);
|
|
117299
117725
|
}
|
|
117300
|
-
const listUrl = negativeKeywordSlimListUrl(googleApiUrl, opts.account);
|
|
117726
|
+
const listUrl = negativeKeywordSlimListUrl(googleApiUrl, opts.account, { newest: true });
|
|
117301
117727
|
const readList = async () => {
|
|
117302
117728
|
try {
|
|
117303
117729
|
const listed = await apiFetch2(
|
|
@@ -117321,6 +117747,13 @@ async function runAdNegativeKeywordCreate(opts) {
|
|
|
117321
117747
|
const nextQuery = `siluzan-tso ad keywords -a ${opts.account} --negative --json-out ./snap`;
|
|
117322
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")}` : ""}`;
|
|
117323
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
|
+
);
|
|
117324
117757
|
if (summary.verification !== "verified") {
|
|
117325
117758
|
console.error(`
|
|
117326
117759
|
${headline}
|
|
@@ -117368,6 +117801,17 @@ async function runAdKeywordDelete(opts) {
|
|
|
117368
117801
|
`);
|
|
117369
117802
|
process.exit(1);
|
|
117370
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
|
+
);
|
|
117371
117815
|
console.log(`
|
|
117372
117816
|
\u2705 \u5173\u952E\u8BCD ${opts.id} \u5DF2\u5220\u9664
|
|
117373
117817
|
`);
|
|
@@ -117384,7 +117828,7 @@ function findKeywordEditMismatches(requested, returned, changed) {
|
|
|
117384
117828
|
const expectedCents = Number(requested["maxCPC"]);
|
|
117385
117829
|
const actualCents = returned["maxCPC"];
|
|
117386
117830
|
mismatches.push(
|
|
117387
|
-
`maxCPC\uFF1A\u671F\u671B ${expectedCents / 100} \u5143\uFF0C\u5217\u8868\u4ECD\u662F ${actualCents / 100} \u5143\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`
|
|
117388
117832
|
);
|
|
117389
117833
|
}
|
|
117390
117834
|
if (changed.status !== void 0 && typeof returned["userStatusV2"] === "string" && str3(returned["userStatusV2"]).toLowerCase() !== changed.status.toLowerCase()) {
|
|
@@ -117412,6 +117856,7 @@ async function runAdKeywordEdit(opts) {
|
|
|
117412
117856
|
const params = new URLSearchParams();
|
|
117413
117857
|
params.set("startDate", toGoogleDate(opts.startDate, -30));
|
|
117414
117858
|
params.set("endDate", toGoogleDate(opts.endDate, 0));
|
|
117859
|
+
params.set("newest", "true");
|
|
117415
117860
|
const listUrl = `${googleApiUrl}/keywordmanagement/v2/list/${opts.account}?${params}`;
|
|
117416
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
|
|
117417
117862
|
`;
|
|
@@ -117507,6 +117952,19 @@ async function runAdKeywordEdit(opts) {
|
|
|
117507
117952
|
process.exit(1);
|
|
117508
117953
|
}
|
|
117509
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);
|
|
117510
117968
|
if (mismatches.length > 0) {
|
|
117511
117969
|
console.error(
|
|
117512
117970
|
`
|
|
@@ -117624,7 +118082,7 @@ async function runAdNegativeKeywordDelete(opts) {
|
|
|
117624
118082
|
opts = withResolvedAdAccount(opts);
|
|
117625
118083
|
const config = loadConfig(opts.token);
|
|
117626
118084
|
const googleApiUrl = requireGoogleApi(config);
|
|
117627
|
-
const listUrl = negativeKeywordSlimListUrl(googleApiUrl, opts.account);
|
|
118085
|
+
const listUrl = negativeKeywordSlimListUrl(googleApiUrl, opts.account, { newest: true });
|
|
117628
118086
|
let keyword;
|
|
117629
118087
|
try {
|
|
117630
118088
|
keyword = await findItemInList(listUrl, config, opts.id, opts.verbose);
|
|
@@ -117646,6 +118104,7 @@ async function runAdNegativeKeywordDelete(opts) {
|
|
|
117646
118104
|
`);
|
|
117647
118105
|
process.exit(1);
|
|
117648
118106
|
}
|
|
118107
|
+
await printIdGone("\u5426\u5B9A\u5173\u952E\u8BCD", listUrl, config, opts.id, opts.verbose);
|
|
117649
118108
|
console.log(`
|
|
117650
118109
|
\u2705 \u5426\u5B9A\u5173\u952E\u8BCD ${opts.id} \u5DF2\u5220\u9664
|
|
117651
118110
|
`);
|
|
@@ -119341,9 +119800,13 @@ function unwrapCampaign(res) {
|
|
|
119341
119800
|
}
|
|
119342
119801
|
return res;
|
|
119343
119802
|
}
|
|
119803
|
+
function campaignReadUrl(detailUrl) {
|
|
119804
|
+
if (/[?&]newest=/.test(detailUrl)) return detailUrl;
|
|
119805
|
+
return `${detailUrl}${detailUrl.includes("?") ? "&" : "?"}newest=true`;
|
|
119806
|
+
}
|
|
119344
119807
|
async function fetchCampaignRecord(detailUrl, config, verbose) {
|
|
119345
119808
|
const res = await apiFetch2(
|
|
119346
|
-
detailUrl,
|
|
119809
|
+
campaignReadUrl(detailUrl),
|
|
119347
119810
|
config,
|
|
119348
119811
|
{},
|
|
119349
119812
|
verbose
|
|
@@ -119400,6 +119863,7 @@ async function reportFailedCampaignPut(opts) {
|
|
|
119400
119863
|
});
|
|
119401
119864
|
}
|
|
119402
119865
|
async function reportCampaignWrite(opts) {
|
|
119866
|
+
printWriteReceipt(opts.verification, receiptLinesFromFieldChecks(opts.checks));
|
|
119403
119867
|
const nextQuery = `siluzan-tso ad campaigns -a ${opts.account} --json-out ./snap`;
|
|
119404
119868
|
const unmatched = describeUnmatchedChecks(opts.checks);
|
|
119405
119869
|
const text5 = opts.verification === "verified" ? opts.detail : unmatched || opts.detail;
|
|
@@ -119445,7 +119909,7 @@ async function runAdCampaignStatus(opts) {
|
|
|
119445
119909
|
let campaign;
|
|
119446
119910
|
try {
|
|
119447
119911
|
const res = await apiFetch2(
|
|
119448
|
-
detailUrl,
|
|
119912
|
+
campaignReadUrl(detailUrl),
|
|
119449
119913
|
config,
|
|
119450
119914
|
{},
|
|
119451
119915
|
opts.verbose
|
|
@@ -119512,7 +119976,7 @@ async function runAdCampaignDelete(opts) {
|
|
|
119512
119976
|
let campaign;
|
|
119513
119977
|
try {
|
|
119514
119978
|
const res = await apiFetch2(
|
|
119515
|
-
detailUrl,
|
|
119979
|
+
campaignReadUrl(detailUrl),
|
|
119516
119980
|
config,
|
|
119517
119981
|
{},
|
|
119518
119982
|
opts.verbose
|
|
@@ -119547,9 +120011,32 @@ async function runAdCampaignDelete(opts) {
|
|
|
119547
120011
|
`);
|
|
119548
120012
|
process.exit(1);
|
|
119549
120013
|
}
|
|
119550
|
-
|
|
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(`
|
|
119551
120037
|
\u2705 \u5E7F\u544A\u7CFB\u5217 ${opts.id} \u5DF2\u5220\u9664
|
|
119552
120038
|
`);
|
|
120039
|
+
}
|
|
119553
120040
|
}
|
|
119554
120041
|
async function runAdCampaignCreate(opts) {
|
|
119555
120042
|
const cfg = loadCampaignCreateConfig(opts.configFile);
|
|
@@ -119804,7 +120291,7 @@ async function runAdCampaignEdit(opts) {
|
|
|
119804
120291
|
let campaign;
|
|
119805
120292
|
try {
|
|
119806
120293
|
const res = await apiFetch2(
|
|
119807
|
-
detailUrl,
|
|
120294
|
+
campaignReadUrl(detailUrl),
|
|
119808
120295
|
config,
|
|
119809
120296
|
{},
|
|
119810
120297
|
opts.verbose
|
|
@@ -120427,6 +120914,7 @@ async function runAdDelete(opts) {
|
|
|
120427
120914
|
const params = new URLSearchParams();
|
|
120428
120915
|
params.set("startDate", toGoogleDate(opts.startDate, -30));
|
|
120429
120916
|
params.set("endDate", toGoogleDate(opts.endDate, 0));
|
|
120917
|
+
params.set("newest", "true");
|
|
120430
120918
|
const listUrl = `${googleApiUrl}/admanagement/v2/list/${opts.account}?${params}`;
|
|
120431
120919
|
let ad;
|
|
120432
120920
|
try {
|
|
@@ -120446,6 +120934,18 @@ async function runAdDelete(opts) {
|
|
|
120446
120934
|
`);
|
|
120447
120935
|
process.exit(1);
|
|
120448
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
|
+
]);
|
|
120449
120949
|
console.log(`
|
|
120450
120950
|
\u2705 \u5E7F\u544A ${opts.id} \u5DF2\u5220\u9664
|
|
120451
120951
|
`);
|
|
@@ -120495,6 +120995,31 @@ async function runAdEdit(opts) {
|
|
|
120495
120995
|
`);
|
|
120496
120996
|
process.exit(1);
|
|
120497
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
|
+
}
|
|
120498
121023
|
console.log(`
|
|
120499
121024
|
\u2705 \u5E7F\u544A ${opts.id} \u5DF2\u66F4\u65B0
|
|
120500
121025
|
`);
|
|
@@ -120684,6 +121209,15 @@ async function runAdExclusionsAdd(opts) {
|
|
|
120684
121209
|
process.exit(1);
|
|
120685
121210
|
}
|
|
120686
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);
|
|
120687
121221
|
if (await emitCliJsonOrSnapshot(opts, {
|
|
120688
121222
|
section: "ad-exclusions-add",
|
|
120689
121223
|
commandLabel: "ad exclusions add",
|
|
@@ -120714,6 +121248,14 @@ async function runAdExclusionsRemove(opts) {
|
|
|
120714
121248
|
`);
|
|
120715
121249
|
process.exit(1);
|
|
120716
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);
|
|
120717
121259
|
console.log(`
|
|
120718
121260
|
\u2705 \u5DF2\u5220\u9664\u5185\u5BB9\u6392\u9664 ${opts.criterionId}
|
|
120719
121261
|
`);
|
|
@@ -121839,10 +122381,11 @@ function extensionRowsFromResponse(res) {
|
|
|
121839
122381
|
(row) => !!row && typeof row === "object" && row["sectionHeadMode"] !== true
|
|
121840
122382
|
);
|
|
121841
122383
|
}
|
|
121842
|
-
function accountExtensionListUrl(googleApiUrl, account, startDate, endDate) {
|
|
122384
|
+
function accountExtensionListUrl(googleApiUrl, account, startDate, endDate, newest = false) {
|
|
121843
122385
|
const params = new URLSearchParams();
|
|
121844
122386
|
params.set("startDate", toGoogleDate(startDate, -30));
|
|
121845
122387
|
params.set("endDate", toGoogleDate(endDate, 0));
|
|
122388
|
+
if (newest) params.set("newest", "true");
|
|
121846
122389
|
return `${googleApiUrl}/extensionmanagement/v2/list/${account}?${params}`;
|
|
121847
122390
|
}
|
|
121848
122391
|
function campaignExtensionListUrl(googleApiUrl, account, campaignId) {
|
|
@@ -121853,7 +122396,8 @@ async function fetchAccountExtensions(config, account, opts = {}) {
|
|
|
121853
122396
|
requireGoogleApi(config),
|
|
121854
122397
|
account,
|
|
121855
122398
|
opts.startDate,
|
|
121856
|
-
opts.endDate
|
|
122399
|
+
opts.endDate,
|
|
122400
|
+
opts.newest
|
|
121857
122401
|
);
|
|
121858
122402
|
return extensionRowsFromResponse(await apiFetch2(url, config, {}, opts.verbose));
|
|
121859
122403
|
}
|
|
@@ -121873,7 +122417,7 @@ async function fetchCampaignExtensions(config, account, campaignId, opts = {}) {
|
|
|
121873
122417
|
} catch (err) {
|
|
121874
122418
|
if (!isNotFound(err)) throw err;
|
|
121875
122419
|
}
|
|
121876
|
-
const rows = (await fetchAccountExtensions(config, account, opts)).filter(
|
|
122420
|
+
const rows = (await fetchAccountExtensions(config, account, { ...opts, newest: true })).filter(
|
|
121877
122421
|
(row) => String(row["campaignId"] ?? "") === cid
|
|
121878
122422
|
);
|
|
121879
122423
|
return { rows, source: "account-fallback" };
|
|
@@ -123112,6 +123656,7 @@ async function runAdGeoAdd(opts) {
|
|
|
123112
123656
|
`);
|
|
123113
123657
|
process.exit(1);
|
|
123114
123658
|
}
|
|
123659
|
+
await printGeoPresence(config, googleApiUrl, opts, true);
|
|
123115
123660
|
const label2 = opts.exclude ? "\u5DF2\u6392\u9664" : "\u5DF2\u6DFB\u52A0\u5B9A\u4F4D";
|
|
123116
123661
|
console.log(`
|
|
123117
123662
|
\u2705 \u5730\u7406\u4F4D\u7F6E ${opts.locationId} ${label2}\uFF08\u5E7F\u544A\u7CFB\u5217\uFF1A${opts.campaignId}\uFF09
|
|
@@ -123131,14 +123676,50 @@ async function runAdGeoRemove(opts) {
|
|
|
123131
123676
|
`);
|
|
123132
123677
|
process.exit(1);
|
|
123133
123678
|
}
|
|
123679
|
+
await printGeoPresence(config, googleApiUrl, opts, false);
|
|
123134
123680
|
console.log(`
|
|
123135
123681
|
\u2705 \u5730\u7406\u4F4D\u7F6E ${opts.locationId} \u5DF2\u4ECE\u5E7F\u544A\u7CFB\u5217 ${opts.campaignId} \u4E2D\u79FB\u9664
|
|
123136
123682
|
`);
|
|
123137
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
|
+
}
|
|
123138
123718
|
async function fetchTargetedGeoRows(config, googleApiUrl, account, campaignId, verbose) {
|
|
123139
123719
|
const params = new URLSearchParams({
|
|
123140
123720
|
startDate: toGoogleDate(void 0, -30),
|
|
123141
|
-
endDate: toGoogleDate(void 0, 0)
|
|
123721
|
+
endDate: toGoogleDate(void 0, 0),
|
|
123722
|
+
newest: "true"
|
|
123142
123723
|
});
|
|
123143
123724
|
const url = `${googleApiUrl}/campaignmanagement/v2/targetedlocations/${account}?${params}`;
|
|
123144
123725
|
const data = await apiFetch2(url, config, {}, verbose);
|
|
@@ -123676,6 +124257,73 @@ function listPlannedRsaAssets(ad, groupPath, adIndex, adGroupName) {
|
|
|
123676
124257
|
}
|
|
123677
124258
|
return out;
|
|
123678
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
|
+
}
|
|
123679
124327
|
function liveLocationId(item) {
|
|
123680
124328
|
return pickString2(
|
|
123681
124329
|
item["id"],
|
|
@@ -124419,7 +125067,7 @@ async function fetchLiveSnapshotForCampaign(config, accountId, campaignId, campa
|
|
|
124419
125067
|
),
|
|
124420
125068
|
fetchList(
|
|
124421
125069
|
config,
|
|
124422
|
-
negativeKeywordSlimListUrl(googleApiUrl, accountId),
|
|
125070
|
+
negativeKeywordSlimListUrl(googleApiUrl, accountId, { newest: true }),
|
|
124423
125071
|
verbose
|
|
124424
125072
|
),
|
|
124425
125073
|
fetchList(
|
|
@@ -124453,9 +125101,19 @@ async function fetchLiveSnapshotForCampaign(config, accountId, campaignId, campa
|
|
|
124453
125101
|
const liveCampaign = campaigns.find((c) => pickString2(c["id"], c["Id"]) === campaignId) ?? campaigns.find((c) => pickString2(c["name"], c["Name"]) === campaignName);
|
|
124454
125102
|
const campaignFound = liveCampaign !== void 0;
|
|
124455
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
|
+
);
|
|
124456
125111
|
return {
|
|
124457
125112
|
campaignFound,
|
|
124458
125113
|
campaignName,
|
|
125114
|
+
budgetYuan: budgetYuan2,
|
|
125115
|
+
statusV2: liveCampaign ? pickString2(liveCampaign["statusV2"], liveCampaign["StatusV2"]) : void 0,
|
|
125116
|
+
landingUrl: landingUrl || void 0,
|
|
124459
125117
|
positiveGeoTargetType: liveGeoTargetTypes.positive,
|
|
124460
125118
|
negativeGeoTargetType: liveGeoTargetTypes.negative,
|
|
124461
125119
|
adGroups: adGroups.filter((g) => belongsToCampaign(g, campaignId, campaignName)),
|
|
@@ -125052,6 +125710,7 @@ async function runCampaignBatchDiff(opts) {
|
|
|
125052
125710
|
const params = new URLSearchParams();
|
|
125053
125711
|
params.set("startDate", toGoogleDate(void 0, -30));
|
|
125054
125712
|
params.set("endDate", toGoogleDate(void 0, 0));
|
|
125713
|
+
params.set("newest", "true");
|
|
125055
125714
|
const campaigns = await fetchList(
|
|
125056
125715
|
config,
|
|
125057
125716
|
`${googleApiUrl}/campaignmanagement/v2/list/${accountId}?${params}`,
|
|
@@ -125096,6 +125755,8 @@ async function runCampaignBatchDiff(opts) {
|
|
|
125096
125755
|
...result,
|
|
125097
125756
|
...report
|
|
125098
125757
|
};
|
|
125758
|
+
const receiptLines = buildSearchCreateReceiptLines(campaign, live);
|
|
125759
|
+
printWriteReceipt(judgeReceipt(receiptLines, !live.campaignFound), receiptLines);
|
|
125099
125760
|
printBatchDiffUserDeliveryMarkdown(report);
|
|
125100
125761
|
if (await emitCliJsonOrSnapshot(
|
|
125101
125762
|
{ jsonOut: opts.jsonOut },
|
|
@@ -125480,6 +126141,23 @@ async function runAiCreationPublish(opts) {
|
|
|
125480
126141
|
`);
|
|
125481
126142
|
process.exit(1);
|
|
125482
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);
|
|
125483
126161
|
console.log(
|
|
125484
126162
|
`
|
|
125485
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
|
|
@@ -127446,6 +128124,201 @@ async function linkPmaxVideoAfterCreate(opts) {
|
|
|
127446
128124
|
}
|
|
127447
128125
|
}
|
|
127448
128126
|
|
|
128127
|
+
// src/commands/ad/pmax-brand-guidelines.ts
|
|
128128
|
+
var PMAX_CAMPAIGN_BRAND_FIELD_TYPES = /* @__PURE__ */ new Set(["BUSINESS_NAME", "LOGO", "LANDSCAPE_LOGO"]);
|
|
128129
|
+
function isPmaxBrandGuidelinesActive(detail) {
|
|
128130
|
+
if (detail["brandGuidelinesEnabled"] === true) return true;
|
|
128131
|
+
const assets = detail["brandAssets"];
|
|
128132
|
+
if (!Array.isArray(assets)) return false;
|
|
128133
|
+
return assets.some((row) => {
|
|
128134
|
+
if (!row || typeof row !== "object") return false;
|
|
128135
|
+
const ft = String(row["fieldType"] ?? "").toUpperCase();
|
|
128136
|
+
return PMAX_CAMPAIGN_BRAND_FIELD_TYPES.has(ft);
|
|
128137
|
+
});
|
|
128138
|
+
}
|
|
128139
|
+
function brandEditAgentHint(bgActive) {
|
|
128140
|
+
return bgActive ? "\u6539\u5546\u5BB6\u540D/Logo/\u6837\u5F0F\uFF1Aad pmax-brand-assets-edit\uFF08\u52FF\u5BF9 AssetGroup \u7528 pmax-assets-update \u6539 BUSINESS_NAME/LOGO\uFF09" : "\u6539\u54C1\u724C\uFF1Aad pmax-assets-update\uFF08AssetGroup \u7EA7\uFF09\uFF1B\u6216 ad pmax-brand-guidelines-enable \u542F\u7528 BG \u540E\u8D70 ad pmax-brand-assets-edit";
|
|
128141
|
+
}
|
|
128142
|
+
function enrichPmaxDetailForAgent(detail) {
|
|
128143
|
+
const bgActive = isPmaxBrandGuidelinesActive(detail);
|
|
128144
|
+
return {
|
|
128145
|
+
...detail,
|
|
128146
|
+
_brandGuidelinesActive: bgActive,
|
|
128147
|
+
_agentBrandHint: brandEditAgentHint(bgActive)
|
|
128148
|
+
};
|
|
128149
|
+
}
|
|
128150
|
+
async function fetchPmaxCampaignDetail(config, googleApiUrl, accountId, campaignId, verbose) {
|
|
128151
|
+
const url = pmaxCampaignUrl(googleApiUrl, accountId, campaignId);
|
|
128152
|
+
const raw = await pmaxApiFetch(url, config, {}, verbose);
|
|
128153
|
+
if (raw && typeof raw === "object" && !Array.isArray(raw)) {
|
|
128154
|
+
return raw;
|
|
128155
|
+
}
|
|
128156
|
+
return { data: raw };
|
|
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
|
+
}
|
|
128186
|
+
function hasBrandImageSource(cfg, slot) {
|
|
128187
|
+
if (slot === "logo") {
|
|
128188
|
+
return Boolean(
|
|
128189
|
+
cfg.logoImageAssetId?.trim() || cfg.logoImageBase64?.trim() || cfg.imagePaths?.logo?.trim()
|
|
128190
|
+
);
|
|
128191
|
+
}
|
|
128192
|
+
return Boolean(
|
|
128193
|
+
cfg.landscapeLogoImageAssetId?.trim() || cfg.landscapeLogoImageBase64?.trim() || cfg.imagePaths?.landscapeLogo?.trim()
|
|
128194
|
+
);
|
|
128195
|
+
}
|
|
128196
|
+
function validateBrandAssetsPatchBody(cfg, opts) {
|
|
128197
|
+
const errors = [];
|
|
128198
|
+
const style = cfg.brandGuidelines;
|
|
128199
|
+
const hasMain = Boolean(style?.mainColor?.trim());
|
|
128200
|
+
const hasAccent = Boolean(style?.accentColor?.trim());
|
|
128201
|
+
if (hasMain !== hasAccent) {
|
|
128202
|
+
errors.push("brandGuidelines.mainColor \u4E0E accentColor \u987B\u6210\u5BF9\u4F20\u5165");
|
|
128203
|
+
}
|
|
128204
|
+
const hasAny = Boolean(cfg.businessName?.trim()) || hasBrandImageSource(cfg, "logo") || hasBrandImageSource(cfg, "landscapeLogo") || Boolean(style?.predefinedFontFamily?.trim()) || hasMain;
|
|
128205
|
+
if (opts?.requireAtLeastOne !== false && !hasAny) {
|
|
128206
|
+
errors.push(
|
|
128207
|
+
"\u81F3\u5C11\u4F20\u4E00\u9879\uFF1AbusinessName\u3001logoImage*\u3001landscapeLogoImage* \u6216 brandGuidelines \u6837\u5F0F\u5B57\u6BB5"
|
|
128208
|
+
);
|
|
128209
|
+
}
|
|
128210
|
+
return errors;
|
|
128211
|
+
}
|
|
128212
|
+
function validateEnableBrandGuidelinesBody(cfg) {
|
|
128213
|
+
const errors = validateBrandAssetsPatchBody(cfg, {
|
|
128214
|
+
requireAtLeastOne: cfg.autoPopulateBrandAssets !== true
|
|
128215
|
+
});
|
|
128216
|
+
if (cfg.autoPopulateBrandAssets !== true) {
|
|
128217
|
+
if (!cfg.businessName?.trim()) {
|
|
128218
|
+
errors.push("autoPopulateBrandAssets=false \u65F6 businessName \u5FC5\u586B");
|
|
128219
|
+
}
|
|
128220
|
+
if (!hasBrandImageSource(cfg, "logo")) {
|
|
128221
|
+
errors.push("autoPopulateBrandAssets=false \u65F6 Logo\uFF08logoImage* / imagePaths.logo\uFF09\u5FC5\u586B");
|
|
128222
|
+
}
|
|
128223
|
+
}
|
|
128224
|
+
return errors;
|
|
128225
|
+
}
|
|
128226
|
+
function detectAssetGroupBrandLinkBlocked(body, bgActive) {
|
|
128227
|
+
if (!bgActive) return [];
|
|
128228
|
+
const errors = [];
|
|
128229
|
+
const links = body["assetsToLink"];
|
|
128230
|
+
if (Array.isArray(links)) {
|
|
128231
|
+
for (const item of links) {
|
|
128232
|
+
if (!item || typeof item !== "object") continue;
|
|
128233
|
+
const ft = String(item["fieldType"] ?? "").toUpperCase();
|
|
128234
|
+
if (PMAX_CAMPAIGN_BRAND_FIELD_TYPES.has(ft)) {
|
|
128235
|
+
errors.push(
|
|
128236
|
+
`Brand Guidelines \u5DF2\u751F\u6548\uFF0C\u7981\u6B62\u5728 AssetGroup PUT ${ft}\uFF1B\u8BF7\u7528 ad pmax-brand-assets-edit`
|
|
128237
|
+
);
|
|
128238
|
+
}
|
|
128239
|
+
}
|
|
128240
|
+
}
|
|
128241
|
+
const replace = body["replaceFieldTypes"];
|
|
128242
|
+
if (Array.isArray(replace)) {
|
|
128243
|
+
for (const ft of replace) {
|
|
128244
|
+
const upper = String(ft ?? "").toUpperCase();
|
|
128245
|
+
if (PMAX_CAMPAIGN_BRAND_FIELD_TYPES.has(upper)) {
|
|
128246
|
+
errors.push(
|
|
128247
|
+
`Brand Guidelines \u5DF2\u751F\u6548\uFF0CreplaceFieldTypes \u542B ${upper}\uFF1B\u8BF7\u7528 ad pmax-brand-assets-edit`
|
|
128248
|
+
);
|
|
128249
|
+
}
|
|
128250
|
+
}
|
|
128251
|
+
}
|
|
128252
|
+
return errors;
|
|
128253
|
+
}
|
|
128254
|
+
async function buildBrandAssetsApiBody(configFile, cfg, accountId, config, googleApiUrl, verbose) {
|
|
128255
|
+
const body = {};
|
|
128256
|
+
if (cfg.businessName?.trim()) body["businessName"] = cfg.businessName.trim();
|
|
128257
|
+
const logoCfg = {
|
|
128258
|
+
logoImageAssetId: cfg.logoImageAssetId,
|
|
128259
|
+
logoImageBase64: cfg.logoImageBase64,
|
|
128260
|
+
imagePaths: cfg.imagePaths?.logo ? { logo: cfg.imagePaths.logo } : void 0
|
|
128261
|
+
};
|
|
128262
|
+
const needsLogo = cfg.logoImageAssetId?.trim() || cfg.logoImageBase64?.trim() || cfg.imagePaths?.logo?.trim();
|
|
128263
|
+
if (needsLogo) {
|
|
128264
|
+
const slots = await resolvePmaxImageSlots(
|
|
128265
|
+
configFile,
|
|
128266
|
+
logoCfg,
|
|
128267
|
+
accountId,
|
|
128268
|
+
config,
|
|
128269
|
+
googleApiUrl,
|
|
128270
|
+
{ verbose, logUploads: false, requiredKinds: ["logo"] }
|
|
128271
|
+
);
|
|
128272
|
+
if (slots.logoImageAssetId) body["logoImageAssetId"] = slots.logoImageAssetId;
|
|
128273
|
+
else if (slots.logoImageBase64) body["logoImageBase64"] = slots.logoImageBase64;
|
|
128274
|
+
}
|
|
128275
|
+
const needsLandscape = cfg.landscapeLogoImageAssetId?.trim() || cfg.landscapeLogoImageBase64?.trim() || cfg.imagePaths?.landscapeLogo?.trim();
|
|
128276
|
+
if (needsLandscape) {
|
|
128277
|
+
const landscapeCfg = {
|
|
128278
|
+
logoImageAssetId: cfg.landscapeLogoImageAssetId,
|
|
128279
|
+
logoImageBase64: cfg.landscapeLogoImageBase64,
|
|
128280
|
+
imagePaths: cfg.imagePaths?.landscapeLogo ? { logo: cfg.imagePaths.landscapeLogo } : void 0
|
|
128281
|
+
};
|
|
128282
|
+
const slots = await resolvePmaxImageSlots(
|
|
128283
|
+
configFile,
|
|
128284
|
+
landscapeCfg,
|
|
128285
|
+
accountId,
|
|
128286
|
+
config,
|
|
128287
|
+
googleApiUrl,
|
|
128288
|
+
{ verbose, logUploads: false, requiredKinds: ["logo"] }
|
|
128289
|
+
);
|
|
128290
|
+
if (slots.logoImageAssetId) body["landscapeLogoImageAssetId"] = slots.logoImageAssetId;
|
|
128291
|
+
else if (slots.logoImageBase64) body["landscapeLogoImageBase64"] = slots.logoImageBase64;
|
|
128292
|
+
}
|
|
128293
|
+
if (cfg.brandGuidelines && typeof cfg.brandGuidelines === "object") {
|
|
128294
|
+
const style = {};
|
|
128295
|
+
const src = cfg.brandGuidelines;
|
|
128296
|
+
if (src.mainColor?.trim()) style["mainColor"] = src.mainColor.trim();
|
|
128297
|
+
if (src.accentColor?.trim()) style["accentColor"] = src.accentColor.trim();
|
|
128298
|
+
if (src.predefinedFontFamily?.trim()) {
|
|
128299
|
+
style["predefinedFontFamily"] = src.predefinedFontFamily.trim();
|
|
128300
|
+
}
|
|
128301
|
+
if (Object.keys(style).length > 0) body["brandGuidelines"] = style;
|
|
128302
|
+
}
|
|
128303
|
+
return body;
|
|
128304
|
+
}
|
|
128305
|
+
async function buildEnableBrandGuidelinesApiBody(configFile, cfg, accountId, config, googleApiUrl, verbose) {
|
|
128306
|
+
const body = await buildBrandAssetsApiBody(
|
|
128307
|
+
configFile,
|
|
128308
|
+
cfg,
|
|
128309
|
+
accountId,
|
|
128310
|
+
config,
|
|
128311
|
+
googleApiUrl,
|
|
128312
|
+
verbose
|
|
128313
|
+
);
|
|
128314
|
+
if (cfg.autoPopulateBrandAssets === true) {
|
|
128315
|
+
body["autoPopulateBrandAssets"] = true;
|
|
128316
|
+
} else {
|
|
128317
|
+
body["autoPopulateBrandAssets"] = false;
|
|
128318
|
+
}
|
|
128319
|
+
return body;
|
|
128320
|
+
}
|
|
128321
|
+
|
|
127449
128322
|
// src/commands/ad/pmax-create.ts
|
|
127450
128323
|
function printVideoLinkRecoveryHint(accountId, assetGroupId, campaignId, youtubeTarget) {
|
|
127451
128324
|
const cid = campaignId != null ? ` --campaign-id ${campaignId}` : "";
|
|
@@ -127673,6 +128546,49 @@ async function runAdPmaxCreate(opts) {
|
|
|
127673
128546
|
payload["created"] = true;
|
|
127674
128547
|
payload["retryCreate"] = false;
|
|
127675
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
|
+
}
|
|
127676
128592
|
if (await emitCliJsonOrSnapshot(opts, {
|
|
127677
128593
|
section: `ad-pmax-create-${accountId}`,
|
|
127678
128594
|
commandLabel: "ad pmax-create",
|
|
@@ -127784,175 +128700,6 @@ async function runAdPmaxValidate(opts) {
|
|
|
127784
128700
|
|
|
127785
128701
|
// src/commands/ad/pmax-mgmt.ts
|
|
127786
128702
|
import { basename as basename7, isAbsolute as isAbsolute6 } from "path";
|
|
127787
|
-
|
|
127788
|
-
// src/commands/ad/pmax-brand-guidelines.ts
|
|
127789
|
-
var PMAX_CAMPAIGN_BRAND_FIELD_TYPES = /* @__PURE__ */ new Set(["BUSINESS_NAME", "LOGO", "LANDSCAPE_LOGO"]);
|
|
127790
|
-
function isPmaxBrandGuidelinesActive(detail) {
|
|
127791
|
-
if (detail["brandGuidelinesEnabled"] === true) return true;
|
|
127792
|
-
const assets = detail["brandAssets"];
|
|
127793
|
-
if (!Array.isArray(assets)) return false;
|
|
127794
|
-
return assets.some((row) => {
|
|
127795
|
-
if (!row || typeof row !== "object") return false;
|
|
127796
|
-
const ft = String(row["fieldType"] ?? "").toUpperCase();
|
|
127797
|
-
return PMAX_CAMPAIGN_BRAND_FIELD_TYPES.has(ft);
|
|
127798
|
-
});
|
|
127799
|
-
}
|
|
127800
|
-
function brandEditAgentHint(bgActive) {
|
|
127801
|
-
return bgActive ? "\u6539\u5546\u5BB6\u540D/Logo/\u6837\u5F0F\uFF1Aad pmax-brand-assets-edit\uFF08\u52FF\u5BF9 AssetGroup \u7528 pmax-assets-update \u6539 BUSINESS_NAME/LOGO\uFF09" : "\u6539\u54C1\u724C\uFF1Aad pmax-assets-update\uFF08AssetGroup \u7EA7\uFF09\uFF1B\u6216 ad pmax-brand-guidelines-enable \u542F\u7528 BG \u540E\u8D70 ad pmax-brand-assets-edit";
|
|
127802
|
-
}
|
|
127803
|
-
function enrichPmaxDetailForAgent(detail) {
|
|
127804
|
-
const bgActive = isPmaxBrandGuidelinesActive(detail);
|
|
127805
|
-
return {
|
|
127806
|
-
...detail,
|
|
127807
|
-
_brandGuidelinesActive: bgActive,
|
|
127808
|
-
_agentBrandHint: brandEditAgentHint(bgActive)
|
|
127809
|
-
};
|
|
127810
|
-
}
|
|
127811
|
-
async function fetchPmaxCampaignDetail(config, googleApiUrl, accountId, campaignId, verbose) {
|
|
127812
|
-
const url = pmaxCampaignUrl(googleApiUrl, accountId, campaignId);
|
|
127813
|
-
const raw = await pmaxApiFetch(url, config, {}, verbose);
|
|
127814
|
-
if (raw && typeof raw === "object" && !Array.isArray(raw)) {
|
|
127815
|
-
return raw;
|
|
127816
|
-
}
|
|
127817
|
-
return { data: raw };
|
|
127818
|
-
}
|
|
127819
|
-
function hasBrandImageSource(cfg, slot) {
|
|
127820
|
-
if (slot === "logo") {
|
|
127821
|
-
return Boolean(
|
|
127822
|
-
cfg.logoImageAssetId?.trim() || cfg.logoImageBase64?.trim() || cfg.imagePaths?.logo?.trim()
|
|
127823
|
-
);
|
|
127824
|
-
}
|
|
127825
|
-
return Boolean(
|
|
127826
|
-
cfg.landscapeLogoImageAssetId?.trim() || cfg.landscapeLogoImageBase64?.trim() || cfg.imagePaths?.landscapeLogo?.trim()
|
|
127827
|
-
);
|
|
127828
|
-
}
|
|
127829
|
-
function validateBrandAssetsPatchBody(cfg, opts) {
|
|
127830
|
-
const errors = [];
|
|
127831
|
-
const style = cfg.brandGuidelines;
|
|
127832
|
-
const hasMain = Boolean(style?.mainColor?.trim());
|
|
127833
|
-
const hasAccent = Boolean(style?.accentColor?.trim());
|
|
127834
|
-
if (hasMain !== hasAccent) {
|
|
127835
|
-
errors.push("brandGuidelines.mainColor \u4E0E accentColor \u987B\u6210\u5BF9\u4F20\u5165");
|
|
127836
|
-
}
|
|
127837
|
-
const hasAny = Boolean(cfg.businessName?.trim()) || hasBrandImageSource(cfg, "logo") || hasBrandImageSource(cfg, "landscapeLogo") || Boolean(style?.predefinedFontFamily?.trim()) || hasMain;
|
|
127838
|
-
if (opts?.requireAtLeastOne !== false && !hasAny) {
|
|
127839
|
-
errors.push(
|
|
127840
|
-
"\u81F3\u5C11\u4F20\u4E00\u9879\uFF1AbusinessName\u3001logoImage*\u3001landscapeLogoImage* \u6216 brandGuidelines \u6837\u5F0F\u5B57\u6BB5"
|
|
127841
|
-
);
|
|
127842
|
-
}
|
|
127843
|
-
return errors;
|
|
127844
|
-
}
|
|
127845
|
-
function validateEnableBrandGuidelinesBody(cfg) {
|
|
127846
|
-
const errors = validateBrandAssetsPatchBody(cfg, {
|
|
127847
|
-
requireAtLeastOne: cfg.autoPopulateBrandAssets !== true
|
|
127848
|
-
});
|
|
127849
|
-
if (cfg.autoPopulateBrandAssets !== true) {
|
|
127850
|
-
if (!cfg.businessName?.trim()) {
|
|
127851
|
-
errors.push("autoPopulateBrandAssets=false \u65F6 businessName \u5FC5\u586B");
|
|
127852
|
-
}
|
|
127853
|
-
if (!hasBrandImageSource(cfg, "logo")) {
|
|
127854
|
-
errors.push("autoPopulateBrandAssets=false \u65F6 Logo\uFF08logoImage* / imagePaths.logo\uFF09\u5FC5\u586B");
|
|
127855
|
-
}
|
|
127856
|
-
}
|
|
127857
|
-
return errors;
|
|
127858
|
-
}
|
|
127859
|
-
function detectAssetGroupBrandLinkBlocked(body, bgActive) {
|
|
127860
|
-
if (!bgActive) return [];
|
|
127861
|
-
const errors = [];
|
|
127862
|
-
const links = body["assetsToLink"];
|
|
127863
|
-
if (Array.isArray(links)) {
|
|
127864
|
-
for (const item of links) {
|
|
127865
|
-
if (!item || typeof item !== "object") continue;
|
|
127866
|
-
const ft = String(item["fieldType"] ?? "").toUpperCase();
|
|
127867
|
-
if (PMAX_CAMPAIGN_BRAND_FIELD_TYPES.has(ft)) {
|
|
127868
|
-
errors.push(
|
|
127869
|
-
`Brand Guidelines \u5DF2\u751F\u6548\uFF0C\u7981\u6B62\u5728 AssetGroup PUT ${ft}\uFF1B\u8BF7\u7528 ad pmax-brand-assets-edit`
|
|
127870
|
-
);
|
|
127871
|
-
}
|
|
127872
|
-
}
|
|
127873
|
-
}
|
|
127874
|
-
const replace = body["replaceFieldTypes"];
|
|
127875
|
-
if (Array.isArray(replace)) {
|
|
127876
|
-
for (const ft of replace) {
|
|
127877
|
-
const upper = String(ft ?? "").toUpperCase();
|
|
127878
|
-
if (PMAX_CAMPAIGN_BRAND_FIELD_TYPES.has(upper)) {
|
|
127879
|
-
errors.push(
|
|
127880
|
-
`Brand Guidelines \u5DF2\u751F\u6548\uFF0CreplaceFieldTypes \u542B ${upper}\uFF1B\u8BF7\u7528 ad pmax-brand-assets-edit`
|
|
127881
|
-
);
|
|
127882
|
-
}
|
|
127883
|
-
}
|
|
127884
|
-
}
|
|
127885
|
-
return errors;
|
|
127886
|
-
}
|
|
127887
|
-
async function buildBrandAssetsApiBody(configFile, cfg, accountId, config, googleApiUrl, verbose) {
|
|
127888
|
-
const body = {};
|
|
127889
|
-
if (cfg.businessName?.trim()) body["businessName"] = cfg.businessName.trim();
|
|
127890
|
-
const logoCfg = {
|
|
127891
|
-
logoImageAssetId: cfg.logoImageAssetId,
|
|
127892
|
-
logoImageBase64: cfg.logoImageBase64,
|
|
127893
|
-
imagePaths: cfg.imagePaths?.logo ? { logo: cfg.imagePaths.logo } : void 0
|
|
127894
|
-
};
|
|
127895
|
-
const needsLogo = cfg.logoImageAssetId?.trim() || cfg.logoImageBase64?.trim() || cfg.imagePaths?.logo?.trim();
|
|
127896
|
-
if (needsLogo) {
|
|
127897
|
-
const slots = await resolvePmaxImageSlots(
|
|
127898
|
-
configFile,
|
|
127899
|
-
logoCfg,
|
|
127900
|
-
accountId,
|
|
127901
|
-
config,
|
|
127902
|
-
googleApiUrl,
|
|
127903
|
-
{ verbose, logUploads: false, requiredKinds: ["logo"] }
|
|
127904
|
-
);
|
|
127905
|
-
if (slots.logoImageAssetId) body["logoImageAssetId"] = slots.logoImageAssetId;
|
|
127906
|
-
else if (slots.logoImageBase64) body["logoImageBase64"] = slots.logoImageBase64;
|
|
127907
|
-
}
|
|
127908
|
-
const needsLandscape = cfg.landscapeLogoImageAssetId?.trim() || cfg.landscapeLogoImageBase64?.trim() || cfg.imagePaths?.landscapeLogo?.trim();
|
|
127909
|
-
if (needsLandscape) {
|
|
127910
|
-
const landscapeCfg = {
|
|
127911
|
-
logoImageAssetId: cfg.landscapeLogoImageAssetId,
|
|
127912
|
-
logoImageBase64: cfg.landscapeLogoImageBase64,
|
|
127913
|
-
imagePaths: cfg.imagePaths?.landscapeLogo ? { logo: cfg.imagePaths.landscapeLogo } : void 0
|
|
127914
|
-
};
|
|
127915
|
-
const slots = await resolvePmaxImageSlots(
|
|
127916
|
-
configFile,
|
|
127917
|
-
landscapeCfg,
|
|
127918
|
-
accountId,
|
|
127919
|
-
config,
|
|
127920
|
-
googleApiUrl,
|
|
127921
|
-
{ verbose, logUploads: false, requiredKinds: ["logo"] }
|
|
127922
|
-
);
|
|
127923
|
-
if (slots.logoImageAssetId) body["landscapeLogoImageAssetId"] = slots.logoImageAssetId;
|
|
127924
|
-
else if (slots.logoImageBase64) body["landscapeLogoImageBase64"] = slots.logoImageBase64;
|
|
127925
|
-
}
|
|
127926
|
-
if (cfg.brandGuidelines && typeof cfg.brandGuidelines === "object") {
|
|
127927
|
-
const style = {};
|
|
127928
|
-
const src = cfg.brandGuidelines;
|
|
127929
|
-
if (src.mainColor?.trim()) style["mainColor"] = src.mainColor.trim();
|
|
127930
|
-
if (src.accentColor?.trim()) style["accentColor"] = src.accentColor.trim();
|
|
127931
|
-
if (src.predefinedFontFamily?.trim()) {
|
|
127932
|
-
style["predefinedFontFamily"] = src.predefinedFontFamily.trim();
|
|
127933
|
-
}
|
|
127934
|
-
if (Object.keys(style).length > 0) body["brandGuidelines"] = style;
|
|
127935
|
-
}
|
|
127936
|
-
return body;
|
|
127937
|
-
}
|
|
127938
|
-
async function buildEnableBrandGuidelinesApiBody(configFile, cfg, accountId, config, googleApiUrl, verbose) {
|
|
127939
|
-
const body = await buildBrandAssetsApiBody(
|
|
127940
|
-
configFile,
|
|
127941
|
-
cfg,
|
|
127942
|
-
accountId,
|
|
127943
|
-
config,
|
|
127944
|
-
googleApiUrl,
|
|
127945
|
-
verbose
|
|
127946
|
-
);
|
|
127947
|
-
if (cfg.autoPopulateBrandAssets === true) {
|
|
127948
|
-
body["autoPopulateBrandAssets"] = true;
|
|
127949
|
-
} else {
|
|
127950
|
-
body["autoPopulateBrandAssets"] = false;
|
|
127951
|
-
}
|
|
127952
|
-
return body;
|
|
127953
|
-
}
|
|
127954
|
-
|
|
127955
|
-
// src/commands/ad/pmax-mgmt.ts
|
|
127956
128703
|
init_shared();
|
|
127957
128704
|
function buildReportQuery(opts) {
|
|
127958
128705
|
const params = new URLSearchParams();
|
|
@@ -128127,6 +128874,22 @@ async function runAdPmaxEdit(opts) {
|
|
|
128127
128874
|
);
|
|
128128
128875
|
process.exit(1);
|
|
128129
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
|
+
);
|
|
128130
128893
|
if (await emitPmaxResult(
|
|
128131
128894
|
{ ...opts, account: accountId },
|
|
128132
128895
|
`ad-pmax-edit-${accountId}`,
|
|
@@ -129376,6 +130139,35 @@ function budgetYuan(item) {
|
|
|
129376
130139
|
const yuan = toDisplayMoney(typeof raw === "number" ? raw : Number(raw));
|
|
129377
130140
|
return yuan == null ? "" : String(yuan);
|
|
129378
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
|
+
}
|
|
129379
130171
|
async function runAdSharedBudgetList(opts) {
|
|
129380
130172
|
let items3;
|
|
129381
130173
|
let account = opts.account;
|
|
@@ -129431,6 +130223,7 @@ async function runAdSharedBudgetCreate(opts) {
|
|
|
129431
130223
|
} catch (err) {
|
|
129432
130224
|
fail3(err, "\u521B\u5EFA\u5171\u4EAB\u9884\u7B97\u5931\u8D25");
|
|
129433
130225
|
}
|
|
130226
|
+
await printSharedBudgetReceipt(opts, { name: name2, amountYuan: opts.amount });
|
|
129434
130227
|
console.log(`
|
|
129435
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
|
|
129436
130229
|
`);
|
|
@@ -129471,6 +130264,11 @@ async function runAdSharedBudgetUpdate(opts) {
|
|
|
129471
130264
|
} catch (err) {
|
|
129472
130265
|
fail3(err, "\u4FEE\u6539\u5171\u4EAB\u9884\u7B97\u5931\u8D25");
|
|
129473
130266
|
}
|
|
130267
|
+
await printSharedBudgetReceipt(opts, {
|
|
130268
|
+
id: budgetId,
|
|
130269
|
+
name: name2,
|
|
130270
|
+
amountYuan: amountCents / 100
|
|
130271
|
+
});
|
|
129474
130272
|
console.log(`
|
|
129475
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
|
|
129476
130274
|
`);
|
|
@@ -129486,6 +130284,7 @@ async function runAdSharedBudgetDelete(opts) {
|
|
|
129486
130284
|
} catch (err) {
|
|
129487
130285
|
fail3(err, "\u5220\u9664\u5171\u4EAB\u9884\u7B97\u5931\u8D25");
|
|
129488
130286
|
}
|
|
130287
|
+
await printSharedBudgetReceipt(opts, { id: budgetId, gone: true });
|
|
129489
130288
|
console.log(`
|
|
129490
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
|
|
129491
130290
|
`);
|
|
@@ -129585,6 +130384,9 @@ async function runAdScheduleReplace(opts) {
|
|
|
129585
130384
|
);
|
|
129586
130385
|
}
|
|
129587
130386
|
|
|
130387
|
+
// src/commands/ad/demand-gen.ts
|
|
130388
|
+
init_shared();
|
|
130389
|
+
|
|
129588
130390
|
// src/commands/ad/demand-gen-body.ts
|
|
129589
130391
|
init_shared();
|
|
129590
130392
|
var WRITE_CENT_KEYS = ["budget", "targetCpa_BidingAmount", "currencyMinimumBudget"];
|
|
@@ -129820,7 +130622,6 @@ function demandGenChannelReportUrl(googleApiUrl, accountId, campaignId, startDat
|
|
|
129820
130622
|
}
|
|
129821
130623
|
|
|
129822
130624
|
// src/commands/ad/demand-gen.ts
|
|
129823
|
-
init_shared();
|
|
129824
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";
|
|
129825
130626
|
function fail4(message) {
|
|
129826
130627
|
console.error(`
|
|
@@ -129828,6 +130629,73 @@ function fail4(message) {
|
|
|
129828
130629
|
`);
|
|
129829
130630
|
process.exit(1);
|
|
129830
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
|
+
}
|
|
129831
130699
|
function asRecord5(value) {
|
|
129832
130700
|
return value && typeof value === "object" && !Array.isArray(value) ? value : { data: value };
|
|
129833
130701
|
}
|
|
@@ -129941,6 +130809,27 @@ async function postCreate(opts, path61, commandLabel) {
|
|
|
129941
130809
|
fail4(explainCreateError(err));
|
|
129942
130810
|
}
|
|
129943
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
|
+
}
|
|
129944
130833
|
if (await emit({ ...opts, account: accountId }, `ad-demand-gen-${path61 || "create"}`, commandLabel, payload, accountId)) {
|
|
129945
130834
|
return;
|
|
129946
130835
|
}
|
|
@@ -130177,6 +131066,18 @@ async function runDemandGenEdit(opts) {
|
|
|
130177
131066
|
} catch (err) {
|
|
130178
131067
|
fail4(`\u66F4\u65B0 Demand Gen \u5931\u8D25\uFF1A${err instanceof Error ? err.message : String(err)}`);
|
|
130179
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
|
+
);
|
|
130180
131081
|
const payload = { ok: true, campaignId, patch: body };
|
|
130181
131082
|
if (await emit({ ...opts, account: accountId }, "ad-demand-gen-edit", "ad demand-gen edit", payload, campaignId)) {
|
|
130182
131083
|
return;
|
|
@@ -130280,6 +131181,16 @@ async function putStatus(opts, kind) {
|
|
|
130280
131181
|
} catch (err) {
|
|
130281
131182
|
fail4(`\u66F4\u65B0\u72B6\u6001\u5931\u8D25\uFF1A${err instanceof Error ? err.message : String(err)}`);
|
|
130282
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);
|
|
130283
131194
|
console.log(`
|
|
130284
131195
|
\u2705 \u5DF2\u8BBE\u4E3A ${status}\u3002\u7CFB\u5217\u72B6\u6001\u4E0D\u4F1A\u8DDF\u7740\u53D8\u3002
|
|
130285
131196
|
`);
|
|
@@ -132978,6 +133889,52 @@ function formHasPredefinedQuestion(form) {
|
|
|
132978
133889
|
return (form.questions ?? []).some((q) => isPredefinedQuestionType(q.type));
|
|
132979
133890
|
}
|
|
132980
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
|
+
|
|
132981
133938
|
// src/commands/meta-ad/load.ts
|
|
132982
133939
|
import { readFileSync as readFileSync16 } from "fs";
|
|
132983
133940
|
function stripMetaKeys2(value) {
|
|
@@ -133629,6 +134586,18 @@ async function runMetaAdCreate(opts) {
|
|
|
133629
134586
|
process.exit(1);
|
|
133630
134587
|
}
|
|
133631
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
|
+
);
|
|
133632
134601
|
if (await emitProgress()) return;
|
|
133633
134602
|
console.log("\n\u2705 Meta Instant Form \u7EBF\u7D22\u5E7F\u544A\u5DF2\u521B\u5EFA\uFF08\u9ED8\u8BA4 PAUSED\uFF09\n");
|
|
133634
134603
|
console.log(` formId ${progress.formId}`);
|
|
@@ -134763,6 +135732,20 @@ async function runMetaAdCampaignEdit(opts) {
|
|
|
134763
135732
|
"\u6539\u7CFB\u5217\u5931\u8D25"
|
|
134764
135733
|
);
|
|
134765
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
|
+
);
|
|
134766
135749
|
if (await emitMetaJson(opts, "meta-ad-campaign-edit", "meta-ad campaign-edit", payload, digits)) {
|
|
134767
135750
|
return;
|
|
134768
135751
|
}
|
|
@@ -134785,6 +135768,14 @@ async function runMetaAdCampaignStatus(opts) {
|
|
|
134785
135768
|
"\u6539\u7CFB\u5217\u72B6\u6001\u5931\u8D25"
|
|
134786
135769
|
);
|
|
134787
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);
|
|
134788
135779
|
if (await emitMetaJson(opts, "meta-ad-campaign-status", "meta-ad campaign-status", payload, digits)) {
|
|
134789
135780
|
return;
|
|
134790
135781
|
}
|
|
@@ -135177,6 +136168,7 @@ async function runMetaAdAdsetEdit(opts) {
|
|
|
135177
136168
|
const unmatched = describeUnmatchedChecks(judged.checks);
|
|
135178
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`;
|
|
135179
136170
|
const headline = writeVerificationHeadline(verification, detail);
|
|
136171
|
+
printWriteReceipt(verification, receiptLinesFromFieldChecks(judged.checks));
|
|
135180
136172
|
if (verification !== "verified") {
|
|
135181
136173
|
console.error(`
|
|
135182
136174
|
${headline}
|
|
@@ -135217,6 +136209,14 @@ async function runMetaAdAdsetStatus(opts) {
|
|
|
135217
136209
|
"\u6539\u5E7F\u544A\u7EC4\u72B6\u6001\u5931\u8D25"
|
|
135218
136210
|
);
|
|
135219
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);
|
|
135220
136220
|
if (await emitMetaJson(opts, "meta-ad-adset-status", "meta-ad adset-status", payload, digits)) {
|
|
135221
136221
|
return;
|
|
135222
136222
|
}
|
|
@@ -135371,6 +136371,14 @@ async function runMetaAdStatus(opts) {
|
|
|
135371
136371
|
"\u6539\u5E7F\u544A\u72B6\u6001\u5931\u8D25"
|
|
135372
136372
|
);
|
|
135373
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);
|
|
135374
136382
|
if (await emitMetaJson(opts, "meta-ad-ad-status", "meta-ad ad-status", payload, digits)) return;
|
|
135375
136383
|
console.log(`
|
|
135376
136384
|
\u2705 \u5E7F\u544A ${opts.id} \u72B6\u6001\u5DF2\u8BBE\u4E3A ${opts.status.trim()}
|
|
@@ -136861,6 +137869,16 @@ async function runAccountMccUnbind(opts) {
|
|
|
136861
137869
|
process.exit(1);
|
|
136862
137870
|
}
|
|
136863
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
|
+
}
|
|
136864
137882
|
if (await emitCliJsonOrSnapshot(opts, {
|
|
136865
137883
|
section: "account-mcc-unbind",
|
|
136866
137884
|
commandLabel: "account mcc-unbind",
|
|
@@ -137218,6 +138236,9 @@ async function runAccountDelink(opts) {
|
|
|
137218
138236
|
`);
|
|
137219
138237
|
process.exit(1);
|
|
137220
138238
|
}
|
|
138239
|
+
for (const id of opts.ids) {
|
|
138240
|
+
await printAccountAbsence(config, void 0, id, "\u8D26\u6237", opts.verbose);
|
|
138241
|
+
}
|
|
137221
138242
|
console.log(`
|
|
137222
138243
|
\u2705 \u5DF2\u6279\u91CF\u65AD\u5F00 ${opts.ids.length} \u4E2A\u8D26\u6237\u7684\u5173\u8054\u5173\u7CFB
|
|
137223
138244
|
`);
|
|
@@ -137237,6 +138258,7 @@ async function runAccountDelink(opts) {
|
|
|
137237
138258
|
`);
|
|
137238
138259
|
process.exit(1);
|
|
137239
138260
|
}
|
|
138261
|
+
await printAccountAbsence(config, void 0, entityId, "\u8D26\u6237", opts.verbose);
|
|
137240
138262
|
console.log(`
|
|
137241
138263
|
\u2705 \u8D26\u6237 ${entityId} \u5DF2\u65AD\u5F00\u5173\u8054
|
|
137242
138264
|
`);
|
|
@@ -137290,6 +138312,27 @@ async function runAccountShare(opts) {
|
|
|
137290
138312
|
`);
|
|
137291
138313
|
process.exit(1);
|
|
137292
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);
|
|
137293
138336
|
console.log(`
|
|
137294
138337
|
\u2705 \u8D26\u6237\u5DF2\u6210\u529F\u5206\u4EAB\u7ED9\u624B\u673A\u53F7 ${phone} \u7684\u7528\u6237\uFF08AccountId: ${userId}\uFF09
|
|
137295
138338
|
`);
|
|
@@ -137311,6 +138354,29 @@ async function runAccountUnshare(opts) {
|
|
|
137311
138354
|
`);
|
|
137312
138355
|
process.exit(1);
|
|
137313
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);
|
|
137314
138380
|
console.log(`
|
|
137315
138381
|
\u2705 \u5DF2\u53D6\u6D88\u8D26\u6237 ${opts.id} \u5BF9\u7528\u6237 ${opts.accountId} \u7684\u5206\u4EAB
|
|
137316
138382
|
`);
|
|
@@ -137565,6 +138631,9 @@ async function runAccountClose(opts) {
|
|
|
137565
138631
|
console.error("");
|
|
137566
138632
|
process.exit(1);
|
|
137567
138633
|
}
|
|
138634
|
+
for (const id of mediaIds) {
|
|
138635
|
+
await printAccountAbsence(config, "TikTok", id, "\u8D26\u6237", opts.verbose);
|
|
138636
|
+
}
|
|
137568
138637
|
console.log(`
|
|
137569
138638
|
\u2705 TikTok \u5173\u6237\u5DF2\u6210\u529F\u63D0\u4EA4\uFF0CmediaCustomerId\uFF1A${mediaIds.join("\u3001")}
|
|
137570
138639
|
`);
|
|
@@ -137773,6 +138842,13 @@ async function runAccountWithdrawSubmit(opts) {
|
|
|
137773
138842
|
`);
|
|
137774
138843
|
process.exit(1);
|
|
137775
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
|
+
);
|
|
137776
138852
|
if (await emitCliJsonOrSnapshot(opts, {
|
|
137777
138853
|
section: "account-withdraw-submit",
|
|
137778
138854
|
commandLabel: "account withdraw submit",
|
|
@@ -137876,6 +138952,17 @@ async function runAccountBcUnbind(opts) {
|
|
|
137876
138952
|
`);
|
|
137877
138953
|
process.exit(1);
|
|
137878
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
|
+
}
|
|
137879
138966
|
if (await emitCliJsonOrSnapshot(opts, {
|
|
137880
138967
|
section: `account-bc-unbind-${opts.bcId}`,
|
|
137881
138968
|
commandLabel: "account bc-unbind",
|
|
@@ -137886,11 +138973,11 @@ async function runAccountBcUnbind(opts) {
|
|
|
137886
138973
|
return;
|
|
137887
138974
|
}
|
|
137888
138975
|
const failedMap = result && typeof result === "object" && !Array.isArray(result) ? result : {};
|
|
137889
|
-
const
|
|
137890
|
-
if (
|
|
138976
|
+
const failedMessages = Object.keys(failedMap);
|
|
138977
|
+
if (failedMessages.length > 0) {
|
|
137891
138978
|
console.warn(`
|
|
137892
138979
|
\u26A0\uFE0F \u4EE5\u4E0B\u8D26\u6237\u89E3\u7ED1\u5931\u8D25\uFF1A`);
|
|
137893
|
-
for (const id of
|
|
138980
|
+
for (const id of failedMessages) {
|
|
137894
138981
|
console.warn(` ${id}: ${failedMap[id]}`);
|
|
137895
138982
|
}
|
|
137896
138983
|
} else {
|
|
@@ -138127,6 +139214,14 @@ async function runAccountEmailDeauth(opts) {
|
|
|
138127
139214
|
`);
|
|
138128
139215
|
process.exit(1);
|
|
138129
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);
|
|
138130
139225
|
if (await emitCliJsonOrSnapshot(opts, {
|
|
138131
139226
|
section: `account-email-deauth-${opts.customerId}-${opts.invitationId}`,
|
|
138132
139227
|
commandLabel: "account email-deauth",
|
|
@@ -138825,6 +139920,41 @@ async function resolveGoogleMediaAccountGroupId(config, opts) {
|
|
|
138825
139920
|
|
|
138826
139921
|
// src/commands/open-account/yandex.ts
|
|
138827
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
|
|
138828
139958
|
async function runOpenAccountYandex(opts) {
|
|
138829
139959
|
const config = loadConfig(opts.token);
|
|
138830
139960
|
const magKey = await resolveGenericMagKey(
|
|
@@ -138859,6 +139989,7 @@ async function runOpenAccountYandex(opts) {
|
|
|
138859
139989
|
{ method: "POST", body: JSON.stringify(body) },
|
|
138860
139990
|
opts.verbose
|
|
138861
139991
|
);
|
|
139992
|
+
await printOpenAccountReceipt(config, "Yandex", opts.company, opts.verbose);
|
|
138862
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");
|
|
138863
139994
|
logAccountOpeningHistoryWebUrl(config.apiBaseUrl, "Yandex");
|
|
138864
139995
|
if (opts.verbose && res != null) {
|
|
@@ -139128,6 +140259,7 @@ async function runOpenAccountBing(opts) {
|
|
|
139128
140259
|
{ method: "POST", body: JSON.stringify(body) },
|
|
139129
140260
|
opts.verbose
|
|
139130
140261
|
);
|
|
140262
|
+
await printOpenAccountReceipt(config, "BingV2", opts.advertiserName, opts.verbose);
|
|
139131
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");
|
|
139132
140264
|
logAccountOpeningHistoryWebUrl(config.apiBaseUrl, "BingV2");
|
|
139133
140265
|
} catch (err) {
|
|
@@ -139469,6 +140601,7 @@ async function runOpenAccountGoogle(opts) {
|
|
|
139469
140601
|
},
|
|
139470
140602
|
opts.verbose
|
|
139471
140603
|
);
|
|
140604
|
+
await printOpenAccountReceipt(config, "Google", opts.company, opts.verbose);
|
|
139472
140605
|
console.log(
|
|
139473
140606
|
`
|
|
139474
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
|
|
@@ -139676,6 +140809,7 @@ async function runOpenAccountTikTok(opts) {
|
|
|
139676
140809
|
},
|
|
139677
140810
|
opts.verbose
|
|
139678
140811
|
);
|
|
140812
|
+
await printOpenAccountReceipt(config, "TikTok", opts.company, opts.verbose);
|
|
139679
140813
|
console.log(
|
|
139680
140814
|
`
|
|
139681
140815
|
\u2705 TikTok \u5F00\u6237\u7533\u8BF7\u5DF2\u63D0\u4EA4\uFF08\u5171 ${counts} \u4E2A\uFF09\u3002
|
|
@@ -143334,7 +144468,7 @@ function getCollectIntegrityWarnings(reportData) {
|
|
|
143334
144468
|
}
|
|
143335
144469
|
|
|
143336
144470
|
// src/commands/google-ads-diagnosis/invoke-google-analysis.ts
|
|
143337
|
-
import { spawnSync as
|
|
144471
|
+
import { spawnSync as spawnSync3 } from "child_process";
|
|
143338
144472
|
function invokeGoogleAnalysisCli(opts) {
|
|
143339
144473
|
const cliEntry = process.argv[1];
|
|
143340
144474
|
if (!cliEntry) {
|
|
@@ -143358,7 +144492,7 @@ function invokeGoogleAnalysisCli(opts) {
|
|
|
143358
144492
|
if (typeof opts.taskTimeoutMs === "number") {
|
|
143359
144493
|
args.push("--task-timeout-ms", String(opts.taskTimeoutMs));
|
|
143360
144494
|
}
|
|
143361
|
-
const result =
|
|
144495
|
+
const result = spawnSync3(process.execPath, args, {
|
|
143362
144496
|
encoding: "utf8",
|
|
143363
144497
|
stdio: ["ignore", "pipe", "inherit"],
|
|
143364
144498
|
timeout: opts.timeoutMs && opts.timeoutMs > 0 ? opts.timeoutMs : void 0
|
|
@@ -153845,6 +154979,38 @@ var GAP_ACTIONS = {
|
|
|
153845
154979
|
function gapActionNames() {
|
|
153846
154980
|
return Object.keys(GAP_ACTIONS).sort();
|
|
153847
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
|
+
}
|
|
153848
155014
|
function resolveGapPath(actionName, target) {
|
|
153849
155015
|
const action = GAP_ACTIONS[actionName];
|
|
153850
155016
|
if (!action) {
|
|
@@ -153885,6 +155051,122 @@ init_auth();
|
|
|
153885
155051
|
init_cli_json_snapshot();
|
|
153886
155052
|
init_shared();
|
|
153887
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
|
|
153888
155170
|
function readGapBody(opts, required) {
|
|
153889
155171
|
const inline = opts.body?.trim();
|
|
153890
155172
|
const file = opts.bodyFile?.trim();
|
|
@@ -154042,6 +155324,20 @@ async function runAdGap(opts) {
|
|
|
154042
155324
|
if (resolved.action.service === "tiktok") {
|
|
154043
155325
|
assertTikTokAccepted(payload);
|
|
154044
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
|
+
}
|
|
154045
155341
|
const emitted = await emitCliJsonOrSnapshot(
|
|
154046
155342
|
{ jsonOut: opts.jsonOut },
|
|
154047
155343
|
{
|