siluzan-tso-cli 1.1.69-beta.3 → 1.1.69
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -2
- package/dist/index.js +1148 -73
- package/dist/skill/AGENTS.md +1 -1
- package/dist/skill/SKILL.md +21 -15
- package/dist/skill/_meta.json +2 -2
- package/dist/skill/references/README.md +1 -1
- 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/account-analytics.md +3 -1
- package/dist/skill/references/analytics/rag.md +1 -1
- package/dist/skill/references/analytics/reporting.md +5 -5
- package/dist/skill/references/core/intent-routing.md +4 -2
- package/dist/skill/references/core/playbooks.md +1 -1
- package/dist/skill/references/core/setup.md +5 -5
- package/dist/skill/references/core/workflows.md +16 -5
- package/dist/skill/references/google-ads/demand-gen-api.md +1 -1
- package/dist/skill/references/google-ads/google-ads-campaign-plan.md +1 -1
- package/dist/skill/references/google-ads/google-ads-write.md +34 -7
- package/dist/skill/references/google-ads/google-ads.md +5 -4
- package/dist/skill/references/meta-ads/meta-ads-migrate.md +42 -0
- package/dist/skill/references/meta-ads/meta-ads-read.md +3 -0
- package/dist/skill/references/meta-ads/meta-ads-write.md +12 -4
- package/dist/skill/references/meta-ads/meta-ads.md +10 -7
- package/dist/skill/references/misc/tso-home.md +2 -2
- package/dist/skill/references/operations/ad-gap.md +387 -19
- package/dist/skill/references/report-templates/google-period-report-excel.md +1 -1
- package/dist/skill/references/report-templates/google-period-report.md +1 -1
- package/dist/skill/report-templates/google-period-report-excel.md +1 -1
- package/dist/skill/report-templates/google-period-report.md +1 -1
- package/dist/skill/scripts/install.ps1 +3 -3
- package/dist/skill/scripts/install.sh +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2397,7 +2397,7 @@ function rawRequest(url, options) {
|
|
|
2397
2397
|
stream = res.pipe(zlib.createBrotliDecompress());
|
|
2398
2398
|
}
|
|
2399
2399
|
let failed = false;
|
|
2400
|
-
const
|
|
2400
|
+
const fail9 = (err) => {
|
|
2401
2401
|
if (failed) return;
|
|
2402
2402
|
failed = true;
|
|
2403
2403
|
res.destroy();
|
|
@@ -2416,7 +2416,7 @@ function rawRequest(url, options) {
|
|
|
2416
2416
|
reject(err);
|
|
2417
2417
|
};
|
|
2418
2418
|
const onStreamError = (err) => {
|
|
2419
|
-
|
|
2419
|
+
fail9(new Error(`\u54CD\u5E94\u89E3\u538B\u5931\u8D25\uFF08${encoding || "identity"}\uFF09\uFF1A${err.message}`));
|
|
2420
2420
|
};
|
|
2421
2421
|
if (stream !== res) stream.on("error", onStreamError);
|
|
2422
2422
|
res.on("error", onStreamError);
|
|
@@ -2427,7 +2427,7 @@ function rawRequest(url, options) {
|
|
|
2427
2427
|
const buf = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
2428
2428
|
byteLen += buf.length;
|
|
2429
2429
|
if (maxBytes > 0 && byteLen > maxBytes) {
|
|
2430
|
-
|
|
2430
|
+
fail9(
|
|
2431
2431
|
new Error(`\u54CD\u5E94\u4F53\u8D85\u8FC7\u4E0A\u9650\uFF08${(maxBytes / 1024 / 1024).toFixed(0)} MB\uFF09\uFF0C\u5DF2\u4E2D\u65AD\u8FDE\u63A5`)
|
|
2432
2432
|
);
|
|
2433
2433
|
return;
|
|
@@ -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
|
|
4107
|
+
DEFAULT_API_BASE = "https://tso-api.siluzan.com";
|
|
4108
4108
|
}
|
|
4109
4109
|
});
|
|
4110
4110
|
|
|
@@ -105143,18 +105143,18 @@ import fs32 from "fs";
|
|
|
105143
105143
|
import fsPromises2 from "fs/promises";
|
|
105144
105144
|
import path37 from "path";
|
|
105145
105145
|
import { fileURLToPath as fileURLToPath9 } from "url";
|
|
105146
|
-
function resolveSkillTemplatePath3(
|
|
105146
|
+
function resolveSkillTemplatePath3(basename14) {
|
|
105147
105147
|
const dir = path37.dirname(fileURLToPath9(import.meta.url));
|
|
105148
105148
|
const candidates = [
|
|
105149
|
-
path37.join(dir, "skill", "report-templates",
|
|
105150
|
-
path37.join(dir, "skill", "siluzan-ads", "report-templates",
|
|
105151
|
-
path37.join(dir, "..", "..", "..", "assets", "siluzan-ads", "report-templates",
|
|
105152
|
-
path37.join(dir, "..", "..", "assets", "siluzan-ads", "report-templates",
|
|
105149
|
+
path37.join(dir, "skill", "report-templates", basename14),
|
|
105150
|
+
path37.join(dir, "skill", "siluzan-ads", "report-templates", basename14),
|
|
105151
|
+
path37.join(dir, "..", "..", "..", "assets", "siluzan-ads", "report-templates", basename14),
|
|
105152
|
+
path37.join(dir, "..", "..", "assets", "siluzan-ads", "report-templates", basename14)
|
|
105153
105153
|
];
|
|
105154
105154
|
for (const candidate of candidates) {
|
|
105155
105155
|
if (fs32.existsSync(candidate)) return candidate;
|
|
105156
105156
|
}
|
|
105157
|
-
return path37.join(dir, "skill", "report-templates",
|
|
105157
|
+
return path37.join(dir, "skill", "report-templates", basename14);
|
|
105158
105158
|
}
|
|
105159
105159
|
function demandGenReportTemplatePath() {
|
|
105160
105160
|
return resolveSkillTemplatePath3(TEMPLATE_BASENAME);
|
|
@@ -106940,12 +106940,12 @@ import fs37 from "fs";
|
|
|
106940
106940
|
import fsPromises3 from "fs/promises";
|
|
106941
106941
|
import path42 from "path";
|
|
106942
106942
|
import { fileURLToPath as fileURLToPath10 } from "url";
|
|
106943
|
-
function resolveSkillTemplatePath4(
|
|
106943
|
+
function resolveSkillTemplatePath4(basename14) {
|
|
106944
106944
|
const dir = path42.dirname(fileURLToPath10(import.meta.url));
|
|
106945
106945
|
const candidates = [
|
|
106946
|
-
path42.join(dir, "skill", "report-templates",
|
|
106947
|
-
path42.join(dir, "skill", "siluzan-ads", "report-templates",
|
|
106948
|
-
path42.join(dir, "..", "..", "assets", "siluzan-ads", "report-templates",
|
|
106946
|
+
path42.join(dir, "skill", "report-templates", basename14),
|
|
106947
|
+
path42.join(dir, "skill", "siluzan-ads", "report-templates", basename14),
|
|
106948
|
+
path42.join(dir, "..", "..", "assets", "siluzan-ads", "report-templates", basename14)
|
|
106949
106949
|
];
|
|
106950
106950
|
for (const p of candidates) {
|
|
106951
106951
|
if (fs37.existsSync(p)) return p;
|
|
@@ -107497,8 +107497,8 @@ var init_batch_runner = __esm({
|
|
|
107497
107497
|
shouldDowngrade(now = Date.now()) {
|
|
107498
107498
|
if (this.window.length < this.opts.windowSize) return false;
|
|
107499
107499
|
if (now - this.lastDowngradeAt < this.opts.cooldownMs) return false;
|
|
107500
|
-
const
|
|
107501
|
-
const rate2 =
|
|
107500
|
+
const fail9 = this.window.filter((s) => !s).length;
|
|
107501
|
+
const rate2 = fail9 / this.window.length;
|
|
107502
107502
|
if (rate2 >= this.opts.errorRateThreshold) {
|
|
107503
107503
|
this.lastDowngradeAt = now;
|
|
107504
107504
|
this.window.length = 0;
|
|
@@ -129860,6 +129860,143 @@ function registerDemandGen(adCmd) {
|
|
|
129860
129860
|
).action(runDemandGenConversionsValidate);
|
|
129861
129861
|
}
|
|
129862
129862
|
|
|
129863
|
+
// src/commands/ad/coverage.ts
|
|
129864
|
+
init_shared();
|
|
129865
|
+
var COVERAGE_REFUSED = {
|
|
129866
|
+
smart: "Smart \u5E7F\u544A\u5B98\u65B9\u5DF2\u4E0D\u518D\u5EFA\u8BAE\u65B0\u5EFA\uFF0C\u8BF7\u6539\u7528 Performance Max\u3002",
|
|
129867
|
+
"call-only": "\u4EC5\u7535\u8BDD\u5E7F\u544A\u5B98\u65B9\u5DF2\u505C\u6B62\u65B0\u5EFA\u3002\u8BF7\u7528\u81EA\u9002\u5E94\u641C\u7D22\u5E7F\u544A\u52A0\u7535\u8BDD\u7D20\u6750\u3002",
|
|
129868
|
+
"demand-gen-shared-budget": "Demand Gen \u4F7F\u7528\u7CFB\u5217\u4E13\u7528\u9884\u7B97\uFF0C\u5B98\u65B9\u4E0D\u652F\u6301\u5171\u4EAB\u9884\u7B97\u3002",
|
|
129869
|
+
"demand-gen-asset-group": "Demand Gen \u6CA1\u6709\u7D20\u6750\u7EC4\u3002\u7D20\u6750\u7EC4\u53EA\u5C5E\u4E8E Performance Max\u3002"
|
|
129870
|
+
};
|
|
129871
|
+
var YUAN_KEYS = ["budget", "targetCpa", "manualCpa", "defaultCpc"];
|
|
129872
|
+
function prepareCoverageBody(body) {
|
|
129873
|
+
const next = { ...body };
|
|
129874
|
+
for (const key of YUAN_KEYS) {
|
|
129875
|
+
const value = next[key];
|
|
129876
|
+
if (typeof value === "number") next[key] = toCentAmount(value);
|
|
129877
|
+
}
|
|
129878
|
+
if (Array.isArray(next["offerings"])) {
|
|
129879
|
+
next["offerings"] = next["offerings"].map((item) => {
|
|
129880
|
+
if (!item || typeof item !== "object" || Array.isArray(item)) return item;
|
|
129881
|
+
const offering = { ...item };
|
|
129882
|
+
if (typeof offering["price"] === "number") offering["price"] = toCentAmount(offering["price"]);
|
|
129883
|
+
return offering;
|
|
129884
|
+
});
|
|
129885
|
+
}
|
|
129886
|
+
return next;
|
|
129887
|
+
}
|
|
129888
|
+
function coverageRefusal(kind) {
|
|
129889
|
+
const normalized = (kind ?? "").trim().toLowerCase();
|
|
129890
|
+
return COVERAGE_REFUSED[normalized];
|
|
129891
|
+
}
|
|
129892
|
+
function coverageUrl(googleApiUrl, accountId, path61) {
|
|
129893
|
+
return `${googleApiUrl.replace(/\/$/, "")}/accounts/${accountId}/ads-coverage/${path61}`;
|
|
129894
|
+
}
|
|
129895
|
+
function fail5(message) {
|
|
129896
|
+
console.error(`
|
|
129897
|
+
\u274C ${message}
|
|
129898
|
+
`);
|
|
129899
|
+
process.exit(1);
|
|
129900
|
+
}
|
|
129901
|
+
async function postCoverage(opts, path61, section, commandLabel) {
|
|
129902
|
+
const accountId = requireAccountId(opts.account);
|
|
129903
|
+
const raw = loadPmaxJsonFile(opts.configFile);
|
|
129904
|
+
const kind = String(opts.kind ?? raw["kind"] ?? "");
|
|
129905
|
+
const refused = coverageRefusal(kind);
|
|
129906
|
+
if (refused) fail5(refused);
|
|
129907
|
+
const body = prepareCoverageBody({ ...raw, kind: kind || raw["kind"] });
|
|
129908
|
+
await withGoogleApi(opts, async (config, googleApiUrl) => {
|
|
129909
|
+
let data;
|
|
129910
|
+
try {
|
|
129911
|
+
data = await pmaxApiFetch(
|
|
129912
|
+
coverageUrl(googleApiUrl, accountId, path61),
|
|
129913
|
+
config,
|
|
129914
|
+
{ method: "POST", body: JSON.stringify(body) },
|
|
129915
|
+
opts.verbose
|
|
129916
|
+
);
|
|
129917
|
+
} catch (err) {
|
|
129918
|
+
fail5(err instanceof Error ? err.message : String(err));
|
|
129919
|
+
}
|
|
129920
|
+
await emitPmaxResult({ ...opts, account: accountId }, section, commandLabel, data, accountId);
|
|
129921
|
+
});
|
|
129922
|
+
}
|
|
129923
|
+
async function runCoverageKinds(opts) {
|
|
129924
|
+
const accountId = requireAccountId(opts.account);
|
|
129925
|
+
await withGoogleApi(opts, async (config, googleApiUrl) => {
|
|
129926
|
+
let data;
|
|
129927
|
+
try {
|
|
129928
|
+
data = await pmaxApiFetch(coverageUrl(googleApiUrl, accountId, "kinds"), config, {}, opts.verbose);
|
|
129929
|
+
} catch (err) {
|
|
129930
|
+
fail5(err instanceof Error ? err.message : String(err));
|
|
129931
|
+
}
|
|
129932
|
+
await emitPmaxResult({ ...opts, account: accountId }, "ad-coverage-kinds", "ad coverage kinds", data, accountId);
|
|
129933
|
+
});
|
|
129934
|
+
}
|
|
129935
|
+
async function runCoverageCampaignValidate(opts) {
|
|
129936
|
+
await postCoverage(opts, "campaigns/validate", "ad-coverage-validate", "ad coverage campaign-validate");
|
|
129937
|
+
}
|
|
129938
|
+
async function runCoverageCampaignCreate(opts) {
|
|
129939
|
+
await postCoverage(opts, "campaigns", "ad-coverage-create", "ad coverage campaign-create");
|
|
129940
|
+
}
|
|
129941
|
+
async function runCoverageApply(opts) {
|
|
129942
|
+
await postCoverage(
|
|
129943
|
+
opts,
|
|
129944
|
+
"operations",
|
|
129945
|
+
"ad-coverage-apply",
|
|
129946
|
+
`ad coverage apply --kind ${opts.kind}`
|
|
129947
|
+
);
|
|
129948
|
+
}
|
|
129949
|
+
async function runCoverageBidSimulation(opts) {
|
|
129950
|
+
const accountId = requireAccountId(opts.account);
|
|
129951
|
+
const campaignId = opts.campaignId.trim();
|
|
129952
|
+
if (!/^\d+$/.test(campaignId)) fail5("campaignId \u5FC5\u987B\u662F\u6570\u5B57\u3002");
|
|
129953
|
+
await withGoogleApi(opts, async (config, googleApiUrl) => {
|
|
129954
|
+
let data;
|
|
129955
|
+
try {
|
|
129956
|
+
data = await pmaxApiFetch(
|
|
129957
|
+
`${coverageUrl(googleApiUrl, accountId, "bid-simulations")}?campaignId=${campaignId}`,
|
|
129958
|
+
config,
|
|
129959
|
+
{},
|
|
129960
|
+
opts.verbose
|
|
129961
|
+
);
|
|
129962
|
+
} catch (err) {
|
|
129963
|
+
fail5(err instanceof Error ? err.message : String(err));
|
|
129964
|
+
}
|
|
129965
|
+
await emitPmaxResult(
|
|
129966
|
+
{ ...opts, account: accountId },
|
|
129967
|
+
"ad-coverage-bid-simulation",
|
|
129968
|
+
"ad coverage bid-simulation",
|
|
129969
|
+
data,
|
|
129970
|
+
accountId
|
|
129971
|
+
);
|
|
129972
|
+
});
|
|
129973
|
+
}
|
|
129974
|
+
|
|
129975
|
+
// src/commands/ad/coverage-register.ts
|
|
129976
|
+
function withCommon2(cmd) {
|
|
129977
|
+
return cmd.option("-t, --token <token>", "Auth Token").option("--json-out <path>", "\u843D\u76D8\u54CD\u5E94\u5E76\u66F4\u65B0 cli-manifest").option("--verbose", "\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false);
|
|
129978
|
+
}
|
|
129979
|
+
function registerCoverage(adCmd) {
|
|
129980
|
+
const coverage = adCmd.command("coverage").description(
|
|
129981
|
+
"Google \u5C1A\u672A\u63A5\u5230\u641C\u7D22/PMax/Demand Gen \u4E3B\u6D41\u7A0B\u91CC\u7684\u5E7F\u544A\u7BA1\u7406\u3002\n \u521B\u5EFA\u56FA\u5B9A\u6682\u505C\u3002JSON \u91D1\u989D\u586B\u5143\u3002Smart\u3001\u4EC5\u7535\u8BDD\u5E7F\u544A\u3001Demand Gen \u5171\u4EAB\u9884\u7B97\u548C\u7D20\u6750\u7EC4\u4F1A\u76F4\u63A5\u62D2\u7EDD\u3002"
|
|
129982
|
+
);
|
|
129983
|
+
withCommon2(
|
|
129984
|
+
coverage.command("kinds").description("\u5217\u51FA\u53EF\u521B\u5EFA\u7684\u7CFB\u5217\u3001\u53EF\u5199\u7684\u64CD\u4F5C\uFF0C\u4EE5\u53CA\u5B98\u65B9\u4E0D\u5EFA\u8BAE\u63A5\u5165\u7684 kind\u3002").requiredOption("-a, --account <id>", "Google \u5A92\u4F53\u5BA2\u6237 ID")
|
|
129985
|
+
).action(runCoverageKinds);
|
|
129986
|
+
withCommon2(
|
|
129987
|
+
coverage.command("campaign-validate").description("\u53EA\u6821\u9A8C\uFF0C\u4E0D\u521B\u5EFA\u3002kind \u89C1 kinds\u3002").requiredOption("-a, --account <id>", "Google \u5A92\u4F53\u5BA2\u6237 ID").requiredOption("--config-file <path>", "JSON \u914D\u7F6E\uFF0C\u91D1\u989D\u586B\u5143")
|
|
129988
|
+
).action(runCoverageCampaignValidate);
|
|
129989
|
+
withCommon2(
|
|
129990
|
+
coverage.command("campaign-create").description("\u6309\u5B98\u65B9\u7ED3\u6784\u521B\u5EFA\u7CFB\u5217\uFF0C\u7ED3\u679C\u662F\u6682\u505C\u3002\u5199\u64CD\u4F5C\u987B --commit\u3002").requiredOption("-a, --account <id>", "Google \u5A92\u4F53\u5BA2\u6237 ID").requiredOption("--config-file <path>", "JSON \u914D\u7F6E\uFF0C\u91D1\u989D\u586B\u5143")
|
|
129991
|
+
).action(runCoverageCampaignCreate);
|
|
129992
|
+
withCommon2(
|
|
129993
|
+
coverage.command("apply").description("\u5199\u4E00\u6761\u7BA1\u7406\u64CD\u4F5C\u3002--kind \u89C1 kinds \u7684 operations\u3002\u5199\u64CD\u4F5C\u987B --commit\u3002").requiredOption("-a, --account <id>", "Google \u5A92\u4F53\u5BA2\u6237 ID").requiredOption("--kind <kind>", "\u64CD\u4F5C\u7C7B\u578B").requiredOption("--config-file <path>", "JSON \u914D\u7F6E\uFF0C\u91D1\u989D\u586B\u5143")
|
|
129994
|
+
).action(runCoverageApply);
|
|
129995
|
+
withCommon2(
|
|
129996
|
+
coverage.command("bid-simulation").description("\u8BFB\u7CFB\u5217\u51FA\u4EF7\u6A21\u62DF\u3002\u53EA\u8BFB\u3002").requiredOption("-a, --account <id>", "Google \u5A92\u4F53\u5BA2\u6237 ID").requiredOption("--campaign-id <id>", "\u7CFB\u5217 ID")
|
|
129997
|
+
).action(runCoverageBidSimulation);
|
|
129998
|
+
}
|
|
129999
|
+
|
|
129863
130000
|
// src/commands/ad/_register.ts
|
|
129864
130001
|
function parseOptionalMatchType(raw) {
|
|
129865
130002
|
if (!raw?.trim()) return void 0;
|
|
@@ -131216,6 +131353,7 @@ function register21(program2) {
|
|
|
131216
131353
|
}
|
|
131217
131354
|
);
|
|
131218
131355
|
registerDemandGen(adCmd);
|
|
131356
|
+
registerCoverage(adCmd);
|
|
131219
131357
|
registerAccountOps(adCmd);
|
|
131220
131358
|
registerProtection(adCmd);
|
|
131221
131359
|
}
|
|
@@ -131736,6 +131874,12 @@ function buildUploadImageBody(opts) {
|
|
|
131736
131874
|
else if (opts.imageUrl) body.image_url = opts.imageUrl;
|
|
131737
131875
|
return body;
|
|
131738
131876
|
}
|
|
131877
|
+
function buildUploadVideoBody(opts) {
|
|
131878
|
+
const body = { name: opts.name };
|
|
131879
|
+
if (opts.bytesBase64) body.bytes = opts.bytesBase64;
|
|
131880
|
+
else if (opts.fileUrl) body.file_url = opts.fileUrl;
|
|
131881
|
+
return body;
|
|
131882
|
+
}
|
|
131739
131883
|
function buildCreateCampaignBody(opts) {
|
|
131740
131884
|
const c = opts.campaign;
|
|
131741
131885
|
const body = {
|
|
@@ -132919,6 +133063,395 @@ async function runMetaAdFormCreate(opts) {
|
|
|
132919
133063
|
`);
|
|
132920
133064
|
}
|
|
132921
133065
|
|
|
133066
|
+
// src/commands/meta-ad/videos.ts
|
|
133067
|
+
import { closeSync as closeSync2, openSync as openSync2, readSync as readSync2, statSync as statSync2 } from "fs";
|
|
133068
|
+
import { basename as basename11 } from "path";
|
|
133069
|
+
var VIDEO_CHUNK_BYTES = 8 * 1024 * 1024;
|
|
133070
|
+
var MAX_VIDEO_UPLOAD_BYTES = 10 * 1024 * 1024 * 1024;
|
|
133071
|
+
function assertVideoFileSize(size) {
|
|
133072
|
+
if (!Number.isFinite(size) || size < 1 || size > MAX_VIDEO_UPLOAD_BYTES) {
|
|
133073
|
+
throw new Error(`\u89C6\u9891\u5927\u5C0F\u987B\u4E3A 1 \u5B57\u8282\uFF5E${MAX_VIDEO_UPLOAD_BYTES} \u5B57\u8282\uFF0C\u5F53\u524D ${size} \u5B57\u8282`);
|
|
133074
|
+
}
|
|
133075
|
+
}
|
|
133076
|
+
function videoSliceEnd(fileSize, startOffset, endOffset) {
|
|
133077
|
+
const windowEnd = endOffset > startOffset ? endOffset : fileSize;
|
|
133078
|
+
return Math.min(fileSize, startOffset + VIDEO_CHUNK_BYTES, windowEnd);
|
|
133079
|
+
}
|
|
133080
|
+
function readVideoSlice(file, start, end) {
|
|
133081
|
+
const buf = Buffer.alloc(end - start);
|
|
133082
|
+
const got = readSync2(file, buf, 0, buf.length, start);
|
|
133083
|
+
if (got !== buf.length) {
|
|
133084
|
+
throw new Error(`\u89C6\u9891\u5728 ${start} \u5904\u8BFB\u5230 ${got} \u5B57\u8282\uFF0C\u671F\u671B ${buf.length} \u5B57\u8282`);
|
|
133085
|
+
}
|
|
133086
|
+
return buf;
|
|
133087
|
+
}
|
|
133088
|
+
function offsetOf(value, fallback) {
|
|
133089
|
+
const n = Number(value);
|
|
133090
|
+
return Number.isFinite(n) && n >= 0 ? n : fallback;
|
|
133091
|
+
}
|
|
133092
|
+
async function uploadLocalVideo(facebookApiUrl, digits, config, videoPath, name2, verbose) {
|
|
133093
|
+
let size;
|
|
133094
|
+
try {
|
|
133095
|
+
size = statSync2(videoPath).size;
|
|
133096
|
+
assertVideoFileSize(size);
|
|
133097
|
+
} catch (err) {
|
|
133098
|
+
console.error(`
|
|
133099
|
+
\u274C \u8BFB\u53D6\u672C\u5730\u89C6\u9891\u5931\u8D25\uFF1A${err instanceof Error ? err.message : String(err)}
|
|
133100
|
+
`);
|
|
133101
|
+
process.exit(1);
|
|
133102
|
+
}
|
|
133103
|
+
const post = (operation, body) => metaAdPost(
|
|
133104
|
+
adsUrl(facebookApiUrl, digits, `/coverage/${operation}`),
|
|
133105
|
+
config,
|
|
133106
|
+
body,
|
|
133107
|
+
verbose,
|
|
133108
|
+
"\u4E0A\u4F20\u5E7F\u544A\u89C6\u9891\u5931\u8D25"
|
|
133109
|
+
);
|
|
133110
|
+
const started = await post("video-start", { file_size: String(size), title: name2 });
|
|
133111
|
+
const session = typeof started.upload_session_id === "string" ? started.upload_session_id : "";
|
|
133112
|
+
const videoId = typeof started.video_id === "string" ? started.video_id : "";
|
|
133113
|
+
if (!session || !videoId) {
|
|
133114
|
+
console.error("\n\u274C \u4E0A\u4F20\u5E7F\u544A\u89C6\u9891\u5931\u8D25\uFF1A\u6CA1\u6709\u8FD4\u56DE upload_session_id \u6216 video_id\n");
|
|
133115
|
+
process.exit(1);
|
|
133116
|
+
}
|
|
133117
|
+
let offset = offsetOf(started.start_offset, 0);
|
|
133118
|
+
let end = offsetOf(started.end_offset, size);
|
|
133119
|
+
const file = openSync2(videoPath, "r");
|
|
133120
|
+
try {
|
|
133121
|
+
while (offset < size) {
|
|
133122
|
+
const sliceEnd = videoSliceEnd(size, offset, end);
|
|
133123
|
+
if (sliceEnd <= offset) {
|
|
133124
|
+
console.error("\n\u274C \u4E0A\u4F20\u5E7F\u544A\u89C6\u9891\u5931\u8D25\uFF1A\u5206\u7247\u7A97\u53E3\u6CA1\u6709\u524D\u8FDB\n");
|
|
133125
|
+
process.exit(1);
|
|
133126
|
+
}
|
|
133127
|
+
let chunk;
|
|
133128
|
+
try {
|
|
133129
|
+
chunk = readVideoSlice(file, offset, sliceEnd);
|
|
133130
|
+
} catch (err) {
|
|
133131
|
+
console.error(`
|
|
133132
|
+
\u274C \u8BFB\u53D6\u672C\u5730\u89C6\u9891\u5931\u8D25\uFF1A${err instanceof Error ? err.message : String(err)}
|
|
133133
|
+
`);
|
|
133134
|
+
process.exit(1);
|
|
133135
|
+
}
|
|
133136
|
+
const transferred = await post("video-transfer", {
|
|
133137
|
+
upload_session_id: session,
|
|
133138
|
+
start_offset: String(offset),
|
|
133139
|
+
video_file_chunk_base64: chunk.toString("base64")
|
|
133140
|
+
});
|
|
133141
|
+
const next = offsetOf(transferred.start_offset, offset);
|
|
133142
|
+
if (next <= offset) {
|
|
133143
|
+
console.error("\n\u274C \u4E0A\u4F20\u5E7F\u544A\u89C6\u9891\u5931\u8D25\uFF1A\u5206\u7247\u6CA1\u6709\u88AB\u63A5\u53D7\n");
|
|
133144
|
+
process.exit(1);
|
|
133145
|
+
}
|
|
133146
|
+
offset = next;
|
|
133147
|
+
end = offsetOf(transferred.end_offset, size);
|
|
133148
|
+
}
|
|
133149
|
+
} finally {
|
|
133150
|
+
closeSync2(file);
|
|
133151
|
+
}
|
|
133152
|
+
await post("video-finish", { upload_session_id: session, title: name2 });
|
|
133153
|
+
return { id: videoId, video_id: videoId, title: name2 };
|
|
133154
|
+
}
|
|
133155
|
+
async function runMetaAdVideoUpload(opts) {
|
|
133156
|
+
const { digits } = resolveMetaAccountId(opts.account);
|
|
133157
|
+
const hasUrl = Boolean(opts.videoUrl?.trim());
|
|
133158
|
+
const hasPath = Boolean(opts.videoPath?.trim());
|
|
133159
|
+
if (hasUrl === hasPath) {
|
|
133160
|
+
console.error("\n\u274C --video-url \u4E0E --video-path \u987B\u4E8C\u9009\u4E00\n");
|
|
133161
|
+
process.exit(1);
|
|
133162
|
+
}
|
|
133163
|
+
if (hasUrl && !isHttpUrl(opts.videoUrl.trim())) {
|
|
133164
|
+
console.error("\n\u274C --video-url \u987B\u4E3A\u516C\u7F51 http/https\n");
|
|
133165
|
+
process.exit(1);
|
|
133166
|
+
}
|
|
133167
|
+
let name2 = opts.name?.trim();
|
|
133168
|
+
if (hasPath) {
|
|
133169
|
+
name2 = name2 || basename11(opts.videoPath);
|
|
133170
|
+
}
|
|
133171
|
+
if (!name2) {
|
|
133172
|
+
console.error("\n\u274C --name \u5FC5\u586B\uFF08\u6216\u4ECE --video-path \u63A8\u65AD\uFF09\n");
|
|
133173
|
+
process.exit(1);
|
|
133174
|
+
}
|
|
133175
|
+
const { config, facebookApiUrl } = metaAdContext(opts.token);
|
|
133176
|
+
const data = hasPath ? await uploadLocalVideo(facebookApiUrl, digits, config, opts.videoPath, name2, opts.verbose) : await metaAdPost(
|
|
133177
|
+
adsUrl(facebookApiUrl, digits, "/videos"),
|
|
133178
|
+
config,
|
|
133179
|
+
buildUploadVideoBody({ name: name2, fileUrl: opts.videoUrl.trim() }),
|
|
133180
|
+
opts.verbose,
|
|
133181
|
+
"\u4E0A\u4F20\u5E7F\u544A\u89C6\u9891\u5931\u8D25"
|
|
133182
|
+
);
|
|
133183
|
+
const id = extractCreatedId(data);
|
|
133184
|
+
const payload = { ...data, id, title: data.title ?? name2 };
|
|
133185
|
+
if (await emitMetaJson(opts, "meta-ad-video-upload", "meta-ad video-upload", payload, digits)) {
|
|
133186
|
+
return;
|
|
133187
|
+
}
|
|
133188
|
+
console.log(`
|
|
133189
|
+
\u2705 \u89C6\u9891\u5DF2\u4E0A\u4F20 id=${id ?? "\u2014"}
|
|
133190
|
+
`);
|
|
133191
|
+
}
|
|
133192
|
+
|
|
133193
|
+
// src/commands/meta-ad/media-download.ts
|
|
133194
|
+
import { createWriteStream } from "fs";
|
|
133195
|
+
import { mkdir as mkdir7, rename as rename2, rm as rm3, writeFile as writeFile7 } from "fs/promises";
|
|
133196
|
+
import { dirname as dirname15, join as join14 } from "path";
|
|
133197
|
+
var MAX_MEDIA_BATCH = 50;
|
|
133198
|
+
var MAX_IMAGE_BYTES = 30 * 1024 * 1024;
|
|
133199
|
+
var MAX_VIDEO_BYTES = 512 * 1024 * 1024;
|
|
133200
|
+
function parseMediaIds(raw, kind) {
|
|
133201
|
+
if (!raw?.trim()) return [];
|
|
133202
|
+
const seen = /* @__PURE__ */ new Set();
|
|
133203
|
+
const items3 = [];
|
|
133204
|
+
for (const part of raw.split(/[,\s]+/)) {
|
|
133205
|
+
const item = part.trim();
|
|
133206
|
+
if (!item) continue;
|
|
133207
|
+
if (kind === "image") {
|
|
133208
|
+
if (!/^[0-9a-fA-F]{32,64}$/.test(item)) {
|
|
133209
|
+
throw new Error(`image hash \u987B\u4E3A 32 \u5230 64 \u4F4D\u5341\u516D\u8FDB\u5236\uFF1A${item}`);
|
|
133210
|
+
}
|
|
133211
|
+
} else if (!/^\d{5,32}$/.test(item)) {
|
|
133212
|
+
throw new Error(`video id \u987B\u4E3A\u6570\u5B57\uFF1A${item}`);
|
|
133213
|
+
}
|
|
133214
|
+
const key = kind === "image" ? item.toLowerCase() : item;
|
|
133215
|
+
if (seen.has(key)) continue;
|
|
133216
|
+
seen.add(key);
|
|
133217
|
+
items3.push(key);
|
|
133218
|
+
}
|
|
133219
|
+
if (items3.length > MAX_MEDIA_BATCH) {
|
|
133220
|
+
throw new Error(`\u4E00\u6B21\u6700\u591A ${MAX_MEDIA_BATCH} \u4E2A`);
|
|
133221
|
+
}
|
|
133222
|
+
return items3;
|
|
133223
|
+
}
|
|
133224
|
+
function extensionForMedia(contentType, head, kind) {
|
|
133225
|
+
const type = (contentType ?? "").split(";")[0].trim().toLowerCase();
|
|
133226
|
+
if (kind === "image") {
|
|
133227
|
+
if (type === "image/png" || startsWith(head, [137, 80, 78, 71])) return "png";
|
|
133228
|
+
if (type === "image/gif" || startsWith(head, [71, 73, 70])) return "gif";
|
|
133229
|
+
if (type === "image/webp" || isWebp(head)) return "webp";
|
|
133230
|
+
return "jpg";
|
|
133231
|
+
}
|
|
133232
|
+
if (type === "video/webm" || startsWith(head, [26, 69, 223, 163])) return "webm";
|
|
133233
|
+
if (type === "video/quicktime") return "mov";
|
|
133234
|
+
return "mp4";
|
|
133235
|
+
}
|
|
133236
|
+
function publicMediaManifest(manifest) {
|
|
133237
|
+
return {
|
|
133238
|
+
account: manifest.account,
|
|
133239
|
+
images: manifest.images.map((item) => ({
|
|
133240
|
+
hash: item.hash,
|
|
133241
|
+
name: item.name,
|
|
133242
|
+
path: item.path,
|
|
133243
|
+
bytes: item.bytes
|
|
133244
|
+
})),
|
|
133245
|
+
videos: manifest.videos.map((item) => ({
|
|
133246
|
+
id: item.id,
|
|
133247
|
+
title: item.title,
|
|
133248
|
+
length: item.length,
|
|
133249
|
+
path: item.path,
|
|
133250
|
+
bytes: item.bytes
|
|
133251
|
+
})),
|
|
133252
|
+
missing: {
|
|
133253
|
+
images: [...manifest.missing.images],
|
|
133254
|
+
videos: [...manifest.missing.videos]
|
|
133255
|
+
},
|
|
133256
|
+
failed: manifest.failed.map((item) => ({
|
|
133257
|
+
kind: item.kind,
|
|
133258
|
+
id: item.id,
|
|
133259
|
+
reason: item.reason
|
|
133260
|
+
}))
|
|
133261
|
+
};
|
|
133262
|
+
}
|
|
133263
|
+
async function downloadPublicFile(fileUrl, dest, maxBytes) {
|
|
133264
|
+
let parsed;
|
|
133265
|
+
try {
|
|
133266
|
+
parsed = new URL(fileUrl);
|
|
133267
|
+
} catch {
|
|
133268
|
+
throw new Error("\u6587\u4EF6\u5730\u5740\u4E0D\u662F http(s)");
|
|
133269
|
+
}
|
|
133270
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
|
|
133271
|
+
throw new Error("\u6587\u4EF6\u5730\u5740\u4E0D\u662F http(s)");
|
|
133272
|
+
}
|
|
133273
|
+
const response = await fetch(fileUrl, { redirect: "follow" });
|
|
133274
|
+
if (!response.ok || !response.body) {
|
|
133275
|
+
throw new Error(`\u4E0B\u8F7D\u5931\u8D25 HTTP ${response.status}`);
|
|
133276
|
+
}
|
|
133277
|
+
const declared = Number(response.headers.get("content-length") ?? "");
|
|
133278
|
+
if (Number.isFinite(declared) && declared > maxBytes) {
|
|
133279
|
+
throw new Error(`\u6587\u4EF6\u8D85\u8FC7 ${maxBytes} \u5B57\u8282`);
|
|
133280
|
+
}
|
|
133281
|
+
await mkdir7(dirname15(dest), { recursive: true });
|
|
133282
|
+
const reader = response.body.getReader();
|
|
133283
|
+
const ws = createWriteStream(dest);
|
|
133284
|
+
const headParts = [];
|
|
133285
|
+
let headLen = 0;
|
|
133286
|
+
let total = 0;
|
|
133287
|
+
try {
|
|
133288
|
+
while (true) {
|
|
133289
|
+
const { done, value } = await reader.read();
|
|
133290
|
+
if (done) break;
|
|
133291
|
+
const chunk = Buffer.from(value);
|
|
133292
|
+
total += chunk.length;
|
|
133293
|
+
if (total > maxBytes) {
|
|
133294
|
+
await reader.cancel();
|
|
133295
|
+
throw new Error(`\u6587\u4EF6\u8D85\u8FC7 ${maxBytes} \u5B57\u8282`);
|
|
133296
|
+
}
|
|
133297
|
+
if (headLen < 16) {
|
|
133298
|
+
headParts.push(chunk.subarray(0, 16 - headLen));
|
|
133299
|
+
headLen += chunk.length;
|
|
133300
|
+
}
|
|
133301
|
+
if (!ws.write(chunk)) {
|
|
133302
|
+
await new Promise((resolve27) => ws.once("drain", resolve27));
|
|
133303
|
+
}
|
|
133304
|
+
}
|
|
133305
|
+
if (total < 1) throw new Error("\u6587\u4EF6\u4E3A\u7A7A");
|
|
133306
|
+
await new Promise((resolve27, reject) => {
|
|
133307
|
+
ws.once("error", reject);
|
|
133308
|
+
ws.end(() => resolve27());
|
|
133309
|
+
});
|
|
133310
|
+
} catch (err) {
|
|
133311
|
+
ws.destroy();
|
|
133312
|
+
await rm3(dest, { force: true });
|
|
133313
|
+
throw err;
|
|
133314
|
+
}
|
|
133315
|
+
return {
|
|
133316
|
+
bytes: total,
|
|
133317
|
+
contentType: response.headers.get("content-type"),
|
|
133318
|
+
head: Buffer.concat(headParts).subarray(0, 16)
|
|
133319
|
+
};
|
|
133320
|
+
}
|
|
133321
|
+
async function runMetaAdMediaDownload(opts) {
|
|
133322
|
+
let hashes;
|
|
133323
|
+
let videoIds;
|
|
133324
|
+
try {
|
|
133325
|
+
hashes = parseMediaIds(opts.imageHashes, "image");
|
|
133326
|
+
videoIds = parseMediaIds(opts.videoIds, "video");
|
|
133327
|
+
} catch (err) {
|
|
133328
|
+
console.error(`
|
|
133329
|
+
\u274C ${err instanceof Error ? err.message : String(err)}
|
|
133330
|
+
`);
|
|
133331
|
+
process.exit(1);
|
|
133332
|
+
}
|
|
133333
|
+
if (hashes.length === 0 && videoIds.length === 0) {
|
|
133334
|
+
console.error("\n\u274C --image-hashes \u4E0E --video-ids \u81F3\u5C11\u586B\u4E00\u4E2A\n");
|
|
133335
|
+
process.exit(1);
|
|
133336
|
+
}
|
|
133337
|
+
const outDir = opts.out?.trim();
|
|
133338
|
+
if (!outDir) {
|
|
133339
|
+
console.error("\n\u274C --out \u5FC5\u586B\uFF0C\u539F\u6587\u4EF6\u8981\u7ACB\u523B\u5B58\u5230\u8FD9\u4E2A\u76EE\u5F55\n");
|
|
133340
|
+
process.exit(1);
|
|
133341
|
+
}
|
|
133342
|
+
const { digits } = resolveMetaAccountId(opts.account);
|
|
133343
|
+
const { config, facebookApiUrl } = metaAdContext(opts.token);
|
|
133344
|
+
const images = [];
|
|
133345
|
+
const videos = [];
|
|
133346
|
+
const failed = [];
|
|
133347
|
+
let missingImages = [];
|
|
133348
|
+
let missingVideos = [];
|
|
133349
|
+
if (hashes.length > 0) {
|
|
133350
|
+
const listed = await metaAdGet(
|
|
133351
|
+
adsUrl(facebookApiUrl, digits, `/images?hashes=${encodeURIComponent(hashes.join(","))}`),
|
|
133352
|
+
config,
|
|
133353
|
+
opts.verbose,
|
|
133354
|
+
"\u8BFB\u53D6\u5E7F\u544A\u56FE\u7247\u5931\u8D25"
|
|
133355
|
+
);
|
|
133356
|
+
const byHash = /* @__PURE__ */ new Map();
|
|
133357
|
+
for (const row of listed.images ?? []) {
|
|
133358
|
+
const hash = row.hash?.trim().toLowerCase();
|
|
133359
|
+
if (hash) byHash.set(hash, row);
|
|
133360
|
+
}
|
|
133361
|
+
missingImages = (listed.missing ?? []).map((hash) => hash.toLowerCase());
|
|
133362
|
+
for (const hash of hashes) {
|
|
133363
|
+
const row = byHash.get(hash);
|
|
133364
|
+
const fileUrl = row?.url?.trim();
|
|
133365
|
+
if (!fileUrl) {
|
|
133366
|
+
if (!missingImages.includes(hash)) missingImages.push(hash);
|
|
133367
|
+
continue;
|
|
133368
|
+
}
|
|
133369
|
+
try {
|
|
133370
|
+
const saved = await saveNamedFile(fileUrl, join14(outDir, "images"), hash, "image", MAX_IMAGE_BYTES);
|
|
133371
|
+
images.push({ hash, name: row?.name?.trim() || null, path: saved.path, bytes: saved.bytes });
|
|
133372
|
+
missingImages = missingImages.filter((item) => item !== hash);
|
|
133373
|
+
} catch (err) {
|
|
133374
|
+
failed.push({ kind: "image", id: hash, reason: err instanceof Error ? err.message : String(err) });
|
|
133375
|
+
}
|
|
133376
|
+
}
|
|
133377
|
+
}
|
|
133378
|
+
if (videoIds.length > 0) {
|
|
133379
|
+
const listed = await metaAdGet(
|
|
133380
|
+
adsUrl(facebookApiUrl, digits, `/videos?ids=${encodeURIComponent(videoIds.join(","))}`),
|
|
133381
|
+
config,
|
|
133382
|
+
opts.verbose,
|
|
133383
|
+
"\u8BFB\u53D6\u5E7F\u544A\u89C6\u9891\u5931\u8D25"
|
|
133384
|
+
);
|
|
133385
|
+
const byId = /* @__PURE__ */ new Map();
|
|
133386
|
+
for (const row of listed.videos ?? []) {
|
|
133387
|
+
const id = row.id?.trim();
|
|
133388
|
+
if (id) byId.set(id, row);
|
|
133389
|
+
}
|
|
133390
|
+
missingVideos = [...listed.missing ?? []];
|
|
133391
|
+
for (const id of videoIds) {
|
|
133392
|
+
const row = byId.get(id);
|
|
133393
|
+
const fileUrl = row?.source?.trim();
|
|
133394
|
+
if (!fileUrl) {
|
|
133395
|
+
if (!missingVideos.includes(id)) missingVideos.push(id);
|
|
133396
|
+
continue;
|
|
133397
|
+
}
|
|
133398
|
+
try {
|
|
133399
|
+
const saved = await saveNamedFile(fileUrl, join14(outDir, "videos"), id, "video", MAX_VIDEO_BYTES);
|
|
133400
|
+
videos.push({
|
|
133401
|
+
id,
|
|
133402
|
+
title: row?.title?.trim() || null,
|
|
133403
|
+
length: typeof row?.length === "number" ? row.length : null,
|
|
133404
|
+
path: saved.path,
|
|
133405
|
+
bytes: saved.bytes
|
|
133406
|
+
});
|
|
133407
|
+
missingVideos = missingVideos.filter((item) => item !== id);
|
|
133408
|
+
} catch (err) {
|
|
133409
|
+
failed.push({ kind: "video", id, reason: err instanceof Error ? err.message : String(err) });
|
|
133410
|
+
}
|
|
133411
|
+
}
|
|
133412
|
+
}
|
|
133413
|
+
const manifest = publicMediaManifest({
|
|
133414
|
+
account: digits,
|
|
133415
|
+
images,
|
|
133416
|
+
videos,
|
|
133417
|
+
missing: { images: missingImages, videos: missingVideos },
|
|
133418
|
+
failed
|
|
133419
|
+
});
|
|
133420
|
+
await mkdir7(outDir, { recursive: true });
|
|
133421
|
+
await writeFile7(join14(outDir, "manifest.json"), `${JSON.stringify(manifest, null, 2)}
|
|
133422
|
+
`, "utf8");
|
|
133423
|
+
if (await emitMetaJson(opts, "meta-ad-media-download", "meta-ad media-download", manifest, digits, {
|
|
133424
|
+
images: images.length,
|
|
133425
|
+
videos: videos.length,
|
|
133426
|
+
missing: missingImages.length + missingVideos.length,
|
|
133427
|
+
failed: failed.length
|
|
133428
|
+
})) {
|
|
133429
|
+
return;
|
|
133430
|
+
}
|
|
133431
|
+
console.log(
|
|
133432
|
+
`
|
|
133433
|
+
\u2705 \u56FE\u7247 ${images.length}\uFF0C\u89C6\u9891 ${videos.length}\uFF0C\u7F3A\u5931 ${missingImages.length + missingVideos.length}\uFF0C\u5931\u8D25 ${failed.length}
|
|
133434
|
+
\u76EE\u5F55 ${outDir}
|
|
133435
|
+
`
|
|
133436
|
+
);
|
|
133437
|
+
}
|
|
133438
|
+
async function saveNamedFile(fileUrl, dir, id, kind, maxBytes) {
|
|
133439
|
+
const temp = join14(dir, `${id}.part`);
|
|
133440
|
+
const saved = await downloadPublicFile(fileUrl, temp, maxBytes);
|
|
133441
|
+
const ext = extensionForMedia(saved.contentType, saved.head, kind);
|
|
133442
|
+
const path61 = join14(dir, `${id}.${ext}`);
|
|
133443
|
+
await rm3(path61, { force: true });
|
|
133444
|
+
await rename2(temp, path61);
|
|
133445
|
+
return { path: path61, bytes: saved.bytes };
|
|
133446
|
+
}
|
|
133447
|
+
function startsWith(head, magic) {
|
|
133448
|
+
if (head.length < magic.length) return false;
|
|
133449
|
+
return magic.every((byte, index) => head[index] === byte);
|
|
133450
|
+
}
|
|
133451
|
+
function isWebp(head) {
|
|
133452
|
+
return head.length >= 12 && head[0] === 82 && head[1] === 73 && head[2] === 70 && head[3] === 70 && head[8] === 87 && head[9] === 69 && head[10] === 66 && head[11] === 80;
|
|
133453
|
+
}
|
|
133454
|
+
|
|
132922
133455
|
// src/commands/meta-ad/plan-render.ts
|
|
132923
133456
|
init_xlsx_style_engine();
|
|
132924
133457
|
import fs15 from "fs";
|
|
@@ -134154,6 +134687,24 @@ function register22(program2) {
|
|
|
134154
134687
|
await runMetaAdImageUpload(opts);
|
|
134155
134688
|
}
|
|
134156
134689
|
);
|
|
134690
|
+
addCommon(
|
|
134691
|
+
addAccount(
|
|
134692
|
+
meta.command("video-upload").description("\u4E0A\u4F20\u5E7F\u544A\u89C6\u9891\u5230\u5F53\u524D\u5E7F\u544A\u8D26\u6237\uFF0C\u8FD4\u56DE video id\uFF08\u521B\u610F\u5FC5\u987B\u7528\u8FD9\u4E2A id\uFF09").option("--name <name>", "\u6807\u9898").option("--video-url <url>", "\u516C\u7F51\u89C6\u9891 URL").option("--video-path <path>", "\u672C\u5730\u89C6\u9891\u8DEF\u5F84")
|
|
134693
|
+
)
|
|
134694
|
+
).action(
|
|
134695
|
+
async (opts) => {
|
|
134696
|
+
await runMetaAdVideoUpload(opts);
|
|
134697
|
+
}
|
|
134698
|
+
);
|
|
134699
|
+
addCommon(
|
|
134700
|
+
addAccount(
|
|
134701
|
+
meta.command("media-download").description("\u6309 hash / \u89C6\u9891 ID \u628A\u5E7F\u544A\u7D20\u6750\u539F\u6587\u4EF6\u4E0B\u8F7D\u5230\u672C\u5730\uFF08\u4E34\u65F6\u94FE\u63A5\u4E0D\u5199\u5165\u7ED3\u679C\uFF09").option("--image-hashes <hashes>", "\u5E7F\u544A\u56FE hash\uFF0C\u9017\u53F7\u5206\u9694\uFF0C\u6700\u591A 50 \u4E2A").option("--video-ids <ids>", "\u5E7F\u544A\u89C6\u9891 ID\uFF0C\u9017\u53F7\u5206\u9694\uFF0C\u6700\u591A 50 \u4E2A").requiredOption("--out <dir>", "\u4FDD\u5B58\u76EE\u5F55\uFF0C\u56FE\u7247\u8FDB images/\uFF0C\u89C6\u9891\u8FDB videos/")
|
|
134702
|
+
)
|
|
134703
|
+
).action(
|
|
134704
|
+
async (opts) => {
|
|
134705
|
+
await runMetaAdMediaDownload(opts);
|
|
134706
|
+
}
|
|
134707
|
+
);
|
|
134157
134708
|
addCommon(
|
|
134158
134709
|
addAccount(
|
|
134159
134710
|
meta.command("campaign").description("\u6309 ID \u8BFB\u7CFB\u5217\uFF08\u65E0\u5217\u8868\u53E3\uFF09").requiredOption("--id <campaignId>", "\u7CFB\u5217 ID")
|
|
@@ -139842,12 +140393,12 @@ var TEMPLATE_BASENAMES = {
|
|
|
139842
140393
|
html: "website-diagnosis-report.html",
|
|
139843
140394
|
runtime: "website-diagnosis-report.runtime.js"
|
|
139844
140395
|
};
|
|
139845
|
-
function resolveSkillTemplatePath(
|
|
140396
|
+
function resolveSkillTemplatePath(basename14) {
|
|
139846
140397
|
const dir = path25.dirname(fileURLToPath4(import.meta.url));
|
|
139847
140398
|
const candidates = [
|
|
139848
|
-
path25.join(dir, "skill", "report-templates",
|
|
139849
|
-
path25.join(dir, "skill", "siluzan-ads", "report-templates",
|
|
139850
|
-
path25.join(dir, "..", "..", "assets", "siluzan-ads", "report-templates",
|
|
140399
|
+
path25.join(dir, "skill", "report-templates", basename14),
|
|
140400
|
+
path25.join(dir, "skill", "siluzan-ads", "report-templates", basename14),
|
|
140401
|
+
path25.join(dir, "..", "..", "assets", "siluzan-ads", "report-templates", basename14)
|
|
139851
140402
|
];
|
|
139852
140403
|
for (const p of candidates) {
|
|
139853
140404
|
if (fs20.existsSync(p)) return p;
|
|
@@ -140813,13 +141364,13 @@ function buildGoogleAdsDiagnosisNarrativeChecks() {
|
|
|
140813
141364
|
return checks;
|
|
140814
141365
|
}
|
|
140815
141366
|
var GOOGLE_ADS_DIAGNOSIS_NARRATIVE_CHECKS = buildGoogleAdsDiagnosisNarrativeChecks();
|
|
140816
|
-
function resolveSkillTemplatePath2(
|
|
141367
|
+
function resolveSkillTemplatePath2(basename14) {
|
|
140817
141368
|
const dir = path27.dirname(fileURLToPath5(import.meta.url));
|
|
140818
141369
|
const candidates = [
|
|
140819
|
-
path27.join(dir, "skill", "report-templates",
|
|
140820
|
-
path27.join(dir, "skill", "siluzan-ads", "report-templates",
|
|
140821
|
-
path27.join(dir, "..", "..", "assets", "siluzan-ads", "report-templates",
|
|
140822
|
-
path27.join(dir, "..", "..", "..", "assets", "siluzan-ads", "report-templates",
|
|
141370
|
+
path27.join(dir, "skill", "report-templates", basename14),
|
|
141371
|
+
path27.join(dir, "skill", "siluzan-ads", "report-templates", basename14),
|
|
141372
|
+
path27.join(dir, "..", "..", "assets", "siluzan-ads", "report-templates", basename14),
|
|
141373
|
+
path27.join(dir, "..", "..", "..", "assets", "siluzan-ads", "report-templates", basename14)
|
|
140823
141374
|
];
|
|
140824
141375
|
for (const p of candidates) {
|
|
140825
141376
|
if (fs22.existsSync(p)) return p;
|
|
@@ -145413,12 +145964,12 @@ var TEMPLATE_BASENAMES2 = {
|
|
|
145413
145964
|
html: "meta-period-report.html"
|
|
145414
145965
|
};
|
|
145415
145966
|
var INJECT_MARKER2 = "window.__META_PERIOD_REPORT__ = window.__META_PERIOD_REPORT__ || null;";
|
|
145416
|
-
function resolveSkillTemplatePath5(
|
|
145967
|
+
function resolveSkillTemplatePath5(basename14) {
|
|
145417
145968
|
const dir = path47.dirname(fileURLToPath11(import.meta.url));
|
|
145418
145969
|
const candidates = [
|
|
145419
|
-
path47.join(dir, "skill", "report-templates",
|
|
145420
|
-
path47.join(dir, "skill", "siluzan-ads", "report-templates",
|
|
145421
|
-
path47.join(dir, "..", "..", "assets", "siluzan-ads", "report-templates",
|
|
145970
|
+
path47.join(dir, "skill", "report-templates", basename14),
|
|
145971
|
+
path47.join(dir, "skill", "siluzan-ads", "report-templates", basename14),
|
|
145972
|
+
path47.join(dir, "..", "..", "assets", "siluzan-ads", "report-templates", basename14)
|
|
145422
145973
|
];
|
|
145423
145974
|
for (const p of candidates) {
|
|
145424
145975
|
if (fs40.existsSync(p)) return p;
|
|
@@ -145893,12 +146444,12 @@ init_lang();
|
|
|
145893
146444
|
init_html();
|
|
145894
146445
|
var TEMPLATE_BASENAME3 = "meta-account-diagnosis-report.html";
|
|
145895
146446
|
var INJECT_MARKER3 = "window.__META_DIAGNOSIS_REPORT__ = window.__META_DIAGNOSIS_REPORT__ || null;";
|
|
145896
|
-
function resolveSkillTemplatePath6(
|
|
146447
|
+
function resolveSkillTemplatePath6(basename14) {
|
|
145897
146448
|
const dir = path49.dirname(fileURLToPath12(import.meta.url));
|
|
145898
146449
|
const candidates = [
|
|
145899
|
-
path49.join(dir, "skill", "report-templates",
|
|
145900
|
-
path49.join(dir, "skill", "siluzan-ads", "report-templates",
|
|
145901
|
-
path49.join(dir, "..", "..", "assets", "siluzan-ads", "report-templates",
|
|
146450
|
+
path49.join(dir, "skill", "report-templates", basename14),
|
|
146451
|
+
path49.join(dir, "skill", "siluzan-ads", "report-templates", basename14),
|
|
146452
|
+
path49.join(dir, "..", "..", "assets", "siluzan-ads", "report-templates", basename14)
|
|
145902
146453
|
];
|
|
145903
146454
|
for (const p of candidates) {
|
|
145904
146455
|
if (fs42.existsSync(p)) return p;
|
|
@@ -146315,7 +146866,7 @@ function sumActionArray(raw) {
|
|
|
146315
146866
|
}
|
|
146316
146867
|
|
|
146317
146868
|
// src/commands/facebook-analysis/entities.ts
|
|
146318
|
-
function
|
|
146869
|
+
function fail6(label2, err) {
|
|
146319
146870
|
const msg = err instanceof Error ? err.message : String(err);
|
|
146320
146871
|
console.error(`
|
|
146321
146872
|
\u274C ${label2}\uFF1A${msg}
|
|
@@ -146343,7 +146894,7 @@ async function runFacebookAccountStatus(opts) {
|
|
|
146343
146894
|
try {
|
|
146344
146895
|
row = await fetchFacebookAccount(config, manifestId, !!opts.verbose);
|
|
146345
146896
|
} catch (err) {
|
|
146346
|
-
|
|
146897
|
+
fail6("\u67E5\u8BE2 Facebook \u8D26\u6237\u5931\u8D25", err);
|
|
146347
146898
|
}
|
|
146348
146899
|
const payload = { account: manifestId, ...row };
|
|
146349
146900
|
if (await emitCliJsonOrSnapshot(opts, {
|
|
@@ -146393,7 +146944,7 @@ async function runFacebookEntityList(opts, kind) {
|
|
|
146393
146944
|
try {
|
|
146394
146945
|
effectiveStatus = parseEffectiveStatusFilter(opts.effectiveStatus);
|
|
146395
146946
|
} catch (err) {
|
|
146396
|
-
|
|
146947
|
+
fail6("\u53C2\u6570\u9519\u8BEF", err);
|
|
146397
146948
|
}
|
|
146398
146949
|
const pageSize = resolveFacebookPageSize(opts.pageSize);
|
|
146399
146950
|
const config = loadConfig(opts.token);
|
|
@@ -146418,7 +146969,7 @@ async function runFacebookEntityList(opts, kind) {
|
|
|
146418
146969
|
adsetId: opts.adsetId?.trim() || void 0
|
|
146419
146970
|
});
|
|
146420
146971
|
} catch (err) {
|
|
146421
|
-
|
|
146972
|
+
fail6(`\u67E5\u8BE2 ${meta.title} \u5931\u8D25`, err);
|
|
146422
146973
|
}
|
|
146423
146974
|
const payload = wrapListJson({
|
|
146424
146975
|
page: 1,
|
|
@@ -146539,7 +147090,7 @@ async function runFacebookInsights(opts) {
|
|
|
146539
147090
|
breakdown = resolveFacebookBreakdown(opts.breakdown);
|
|
146540
147091
|
timeIncrement = parseOptionalNumber2(opts.timeIncrement);
|
|
146541
147092
|
} catch (err) {
|
|
146542
|
-
|
|
147093
|
+
fail6("\u53C2\u6570\u9519\u8BEF", err);
|
|
146543
147094
|
}
|
|
146544
147095
|
const config = loadConfig(opts.token);
|
|
146545
147096
|
let items3;
|
|
@@ -146555,7 +147106,7 @@ async function runFacebookInsights(opts) {
|
|
|
146555
147106
|
adIds: opts.adIds?.trim() || void 0
|
|
146556
147107
|
});
|
|
146557
147108
|
} catch (err) {
|
|
146558
|
-
|
|
147109
|
+
fail6("\u67E5\u8BE2 Facebook Insights \u5931\u8D25", err);
|
|
146559
147110
|
}
|
|
146560
147111
|
const payload = {
|
|
146561
147112
|
account: manifestId,
|
|
@@ -148031,12 +148582,12 @@ init_lang();
|
|
|
148031
148582
|
init_html();
|
|
148032
148583
|
var TEMPLATE_BASENAME4 = "bing-period-report.html";
|
|
148033
148584
|
var INJECT_MARKER4 = "window.__BING_PERIOD_REPORT__ = window.__BING_PERIOD_REPORT__ || null;";
|
|
148034
|
-
function resolveSkillTemplatePath7(
|
|
148585
|
+
function resolveSkillTemplatePath7(basename14) {
|
|
148035
148586
|
const dir = path53.dirname(fileURLToPath13(import.meta.url));
|
|
148036
148587
|
const candidates = [
|
|
148037
|
-
path53.join(dir, "skill", "report-templates",
|
|
148038
|
-
path53.join(dir, "skill", "siluzan-ads", "report-templates",
|
|
148039
|
-
path53.join(dir, "..", "..", "assets", "siluzan-ads", "report-templates",
|
|
148588
|
+
path53.join(dir, "skill", "report-templates", basename14),
|
|
148589
|
+
path53.join(dir, "skill", "siluzan-ads", "report-templates", basename14),
|
|
148590
|
+
path53.join(dir, "..", "..", "assets", "siluzan-ads", "report-templates", basename14)
|
|
148040
148591
|
];
|
|
148041
148592
|
for (const p of candidates) {
|
|
148042
148593
|
if (fs44.existsSync(p)) return p;
|
|
@@ -149046,12 +149597,12 @@ init_lang();
|
|
|
149046
149597
|
init_html();
|
|
149047
149598
|
var TEMPLATE_BASENAME5 = "tiktok-period-report.html";
|
|
149048
149599
|
var INJECT_MARKER5 = "window.__TIKTOK_PERIOD_REPORT__ = window.__TIKTOK_PERIOD_REPORT__ || null;";
|
|
149049
|
-
function resolveSkillTemplatePath8(
|
|
149600
|
+
function resolveSkillTemplatePath8(basename14) {
|
|
149050
149601
|
const dir = path56.dirname(fileURLToPath14(import.meta.url));
|
|
149051
149602
|
const candidates = [
|
|
149052
|
-
path56.join(dir, "skill", "report-templates",
|
|
149053
|
-
path56.join(dir, "skill", "siluzan-ads", "report-templates",
|
|
149054
|
-
path56.join(dir, "..", "..", "assets", "siluzan-ads", "report-templates",
|
|
149603
|
+
path56.join(dir, "skill", "report-templates", basename14),
|
|
149604
|
+
path56.join(dir, "skill", "siluzan-ads", "report-templates", basename14),
|
|
149605
|
+
path56.join(dir, "..", "..", "assets", "siluzan-ads", "report-templates", basename14)
|
|
149055
149606
|
];
|
|
149056
149607
|
for (const p of candidates) {
|
|
149057
149608
|
if (fs46.existsSync(p)) return p;
|
|
@@ -149495,7 +150046,7 @@ async function fetchOfficialReport(config, opts) {
|
|
|
149495
150046
|
}
|
|
149496
150047
|
|
|
149497
150048
|
// src/commands/tiktok-analysis/entities.ts
|
|
149498
|
-
function
|
|
150049
|
+
function fail7(label2, err) {
|
|
149499
150050
|
const msg = err instanceof Error ? err.message : String(err);
|
|
149500
150051
|
console.error(`
|
|
149501
150052
|
\u274C ${label2}\uFF1A${msg}
|
|
@@ -149509,7 +150060,7 @@ async function runTikTokAccountStatus(opts) {
|
|
|
149509
150060
|
try {
|
|
149510
150061
|
rows = await fetchAdvertiserInfoList(config, id, !!opts.verbose);
|
|
149511
150062
|
} catch (err) {
|
|
149512
|
-
|
|
150063
|
+
fail7("\u67E5\u8BE2 TikTok \u8D26\u6237\u4FE1\u606F\u5931\u8D25\uFF08\u987B\u62E5\u6709\u8BE5\u5E7F\u544A\u4E3B\uFF0C\u5217\u8868\u53EF\u89C1\u4E0D\u591F\uFF09", err);
|
|
149513
150064
|
}
|
|
149514
150065
|
const payload = wrapListJson({
|
|
149515
150066
|
page: 1,
|
|
@@ -149564,7 +150115,7 @@ async function runTikTokCampaignEntities(opts) {
|
|
|
149564
150115
|
verbose: !!opts.verbose
|
|
149565
150116
|
});
|
|
149566
150117
|
} catch (err) {
|
|
149567
|
-
|
|
150118
|
+
fail7("\u67E5\u8BE2 TikTok \u7CFB\u5217\u5931\u8D25", err);
|
|
149568
150119
|
}
|
|
149569
150120
|
const payload = wrapListJson({
|
|
149570
150121
|
page: 1,
|
|
@@ -149626,7 +150177,7 @@ async function runTikTokAdGroupEntities(opts) {
|
|
|
149626
150177
|
verbose: !!opts.verbose
|
|
149627
150178
|
});
|
|
149628
150179
|
} catch (err) {
|
|
149629
|
-
|
|
150180
|
+
fail7("\u67E5\u8BE2 TikTok \u5E7F\u544A\u7EC4\u5931\u8D25", err);
|
|
149630
150181
|
}
|
|
149631
150182
|
const payload = wrapListJson({
|
|
149632
150183
|
page: 1,
|
|
@@ -149693,7 +150244,7 @@ async function runTikTokAdEntities(opts) {
|
|
|
149693
150244
|
verbose: !!opts.verbose
|
|
149694
150245
|
});
|
|
149695
150246
|
} catch (err) {
|
|
149696
|
-
|
|
150247
|
+
fail7("\u67E5\u8BE2 TikTok \u5E7F\u544A\u5931\u8D25", err);
|
|
149697
150248
|
}
|
|
149698
150249
|
const payload = wrapListJson({
|
|
149699
150250
|
page: 1,
|
|
@@ -149767,7 +150318,7 @@ async function runTikTokOfficialReport(opts) {
|
|
|
149767
150318
|
verbose: !!opts.verbose
|
|
149768
150319
|
});
|
|
149769
150320
|
} catch (err) {
|
|
149770
|
-
|
|
150321
|
+
fail7("\u67E5\u8BE2 TikTok \u5B98\u65B9\u62A5\u8868\u5931\u8D25", err);
|
|
149771
150322
|
}
|
|
149772
150323
|
const totals = summarizeTikTokOfficialReport(result.items);
|
|
149773
150324
|
const payload = {
|
|
@@ -151009,12 +151560,12 @@ init_lang();
|
|
|
151009
151560
|
init_html();
|
|
151010
151561
|
var TEMPLATE_BASENAME6 = "yandex-period-report.html";
|
|
151011
151562
|
var INJECT_MARKER6 = "window.__YANDEX_PERIOD_REPORT__ = window.__YANDEX_PERIOD_REPORT__ || null;";
|
|
151012
|
-
function resolveSkillTemplatePath9(
|
|
151563
|
+
function resolveSkillTemplatePath9(basename14) {
|
|
151013
151564
|
const dir = path59.dirname(fileURLToPath15(import.meta.url));
|
|
151014
151565
|
const candidates = [
|
|
151015
|
-
path59.join(dir, "skill", "report-templates",
|
|
151016
|
-
path59.join(dir, "skill", "siluzan-ads", "report-templates",
|
|
151017
|
-
path59.join(dir, "..", "..", "assets", "siluzan-ads", "report-templates",
|
|
151566
|
+
path59.join(dir, "skill", "report-templates", basename14),
|
|
151567
|
+
path59.join(dir, "skill", "siluzan-ads", "report-templates", basename14),
|
|
151568
|
+
path59.join(dir, "..", "..", "assets", "siluzan-ads", "report-templates", basename14)
|
|
151018
151569
|
];
|
|
151019
151570
|
for (const p of candidates) {
|
|
151020
151571
|
if (fs48.existsSync(p)) return p;
|
|
@@ -151264,7 +151815,7 @@ function asRecord43(raw) {
|
|
|
151264
151815
|
}
|
|
151265
151816
|
|
|
151266
151817
|
// src/commands/yandex-analysis/entities.ts
|
|
151267
|
-
function
|
|
151818
|
+
function fail8(label2, err) {
|
|
151268
151819
|
const msg = err instanceof Error ? err.message : String(err);
|
|
151269
151820
|
console.error(`
|
|
151270
151821
|
\u274C ${label2}\uFF1A${msg}
|
|
@@ -151336,7 +151887,7 @@ async function runYandexAccountStatus(opts) {
|
|
|
151336
151887
|
try {
|
|
151337
151888
|
result = await fetchPath(opts, "overview", {});
|
|
151338
151889
|
} catch (err) {
|
|
151339
|
-
|
|
151890
|
+
fail8("\u67E5\u8BE2 Yandex \u8D26\u6237\u603B\u89C8\u5931\u8D25", err);
|
|
151340
151891
|
}
|
|
151341
151892
|
const row = asRecord43(result.raw);
|
|
151342
151893
|
await emitOrTable(opts, {
|
|
@@ -151378,7 +151929,7 @@ async function runYandexCampaignEntities(opts) {
|
|
|
151378
151929
|
network: flags.network
|
|
151379
151930
|
});
|
|
151380
151931
|
} catch (err) {
|
|
151381
|
-
|
|
151932
|
+
fail8("\u67E5\u8BE2 Yandex \u7CFB\u5217\u5931\u8D25", err);
|
|
151382
151933
|
}
|
|
151383
151934
|
const items3 = unwrapYandexItems(result.raw);
|
|
151384
151935
|
await emitOrTable(opts, {
|
|
@@ -151424,7 +151975,7 @@ async function runYandexAdGroupEntities(opts) {
|
|
|
151424
151975
|
campaignId: flags.campaignId
|
|
151425
151976
|
});
|
|
151426
151977
|
} catch (err) {
|
|
151427
|
-
|
|
151978
|
+
fail8("\u67E5\u8BE2 Yandex \u5E7F\u544A\u7EC4\u5931\u8D25", err);
|
|
151428
151979
|
}
|
|
151429
151980
|
const items3 = unwrapYandexItems(result.raw);
|
|
151430
151981
|
await emitOrTable(opts, {
|
|
@@ -151474,7 +152025,7 @@ async function runYandexAdEntities(opts) {
|
|
|
151474
152025
|
adGroupId: flags.adGroupId
|
|
151475
152026
|
});
|
|
151476
152027
|
} catch (err) {
|
|
151477
|
-
|
|
152028
|
+
fail8("\u67E5\u8BE2 Yandex \u5E7F\u544A\u5931\u8D25", err);
|
|
151478
152029
|
}
|
|
151479
152030
|
const items3 = unwrapYandexItems(result.raw);
|
|
151480
152031
|
const filtered = flags.status != null;
|
|
@@ -151526,7 +152077,7 @@ async function runYandexInsights(opts) {
|
|
|
151526
152077
|
adGroupId: flags.adGroupId
|
|
151527
152078
|
});
|
|
151528
152079
|
} catch (err) {
|
|
151529
|
-
|
|
152080
|
+
fail8("\u67E5\u8BE2 Yandex insights \u5931\u8D25", err);
|
|
151530
152081
|
}
|
|
151531
152082
|
const items3 = unwrapYandexItems(result.raw);
|
|
151532
152083
|
await emitOrTable(opts, {
|
|
@@ -151776,6 +152327,152 @@ var bing = (path61, needsBody = true) => ({
|
|
|
151776
152327
|
path: `/reporting/media-account/BingV2/{account}/library/${path61}`,
|
|
151777
152328
|
needsBody
|
|
151778
152329
|
});
|
|
152330
|
+
var BING_COVERAGE_WRITES = [
|
|
152331
|
+
"shopping-campaign",
|
|
152332
|
+
"shopping-brands-campaign",
|
|
152333
|
+
"shopping-smart-campaign",
|
|
152334
|
+
"audience-campaign",
|
|
152335
|
+
"audience-video-campaign",
|
|
152336
|
+
"pmax-campaign",
|
|
152337
|
+
"hotel-campaign",
|
|
152338
|
+
"app-campaign",
|
|
152339
|
+
"dynamic-search-setting",
|
|
152340
|
+
"dynamic-ad-group",
|
|
152341
|
+
"dynamic-search-ad",
|
|
152342
|
+
"campaign-budget",
|
|
152343
|
+
"campaign-tracking",
|
|
152344
|
+
"campaign-schedule",
|
|
152345
|
+
"campaign-location-exclude",
|
|
152346
|
+
"campaign-radius",
|
|
152347
|
+
"campaign-device",
|
|
152348
|
+
"campaign-location-intent",
|
|
152349
|
+
"campaign-webpage",
|
|
152350
|
+
"campaign-age",
|
|
152351
|
+
"campaign-gender",
|
|
152352
|
+
"campaign-audience",
|
|
152353
|
+
"update-ad-group",
|
|
152354
|
+
"ad-group-webpage",
|
|
152355
|
+
"ad-group-placement",
|
|
152356
|
+
"ad-group-profile",
|
|
152357
|
+
"ad-group-genre",
|
|
152358
|
+
"hotel-advance-booking",
|
|
152359
|
+
"hotel-check-in-date",
|
|
152360
|
+
"hotel-check-in-day",
|
|
152361
|
+
"hotel-length-of-stay",
|
|
152362
|
+
"hotel-date-selection",
|
|
152363
|
+
"product-ad",
|
|
152364
|
+
"responsive-ad",
|
|
152365
|
+
"hotel-ad",
|
|
152366
|
+
"app-install-ad",
|
|
152367
|
+
"update-responsive-ad",
|
|
152368
|
+
"update-keyword",
|
|
152369
|
+
"link-extension",
|
|
152370
|
+
"unlink-extension",
|
|
152371
|
+
"delete-extensions",
|
|
152372
|
+
"location-extension",
|
|
152373
|
+
"image-extension",
|
|
152374
|
+
"action-extension",
|
|
152375
|
+
"review-extension",
|
|
152376
|
+
"filter-link-extension",
|
|
152377
|
+
"flyer-extension",
|
|
152378
|
+
"video-extension",
|
|
152379
|
+
"disclaimer-extension",
|
|
152380
|
+
"app-extension",
|
|
152381
|
+
"unlink-negative-keyword-list",
|
|
152382
|
+
"delete-negative-keyword-list-items",
|
|
152383
|
+
"website-exclusion-list",
|
|
152384
|
+
"website-exclusion-items",
|
|
152385
|
+
"link-website-exclusion",
|
|
152386
|
+
"unlink-website-exclusion",
|
|
152387
|
+
"update-experiment",
|
|
152388
|
+
"url-goal",
|
|
152389
|
+
"duration-goal",
|
|
152390
|
+
"pages-goal",
|
|
152391
|
+
"app-goal",
|
|
152392
|
+
"offline-goal",
|
|
152393
|
+
"instore-goal",
|
|
152394
|
+
"update-conversion-goal",
|
|
152395
|
+
"update-uet-tag",
|
|
152396
|
+
"update-seasonality",
|
|
152397
|
+
"delete-seasonality",
|
|
152398
|
+
"update-data-exclusion",
|
|
152399
|
+
"delete-data-exclusion",
|
|
152400
|
+
"update-conversion-value-rule",
|
|
152401
|
+
"conversion-value-rule-status",
|
|
152402
|
+
"remarketing-list",
|
|
152403
|
+
"remarketing-event",
|
|
152404
|
+
"combined-list",
|
|
152405
|
+
"similar-list",
|
|
152406
|
+
"custom-audience",
|
|
152407
|
+
"in-market-audience",
|
|
152408
|
+
"product-audience",
|
|
152409
|
+
"impression-list",
|
|
152410
|
+
"customer-list-crm",
|
|
152411
|
+
"max-conversions-strategy",
|
|
152412
|
+
"max-conversion-value-strategy",
|
|
152413
|
+
"target-impression-share",
|
|
152414
|
+
"update-bid-strategy",
|
|
152415
|
+
"update-video",
|
|
152416
|
+
"update-asset-group",
|
|
152417
|
+
"listing-group",
|
|
152418
|
+
"product-partition",
|
|
152419
|
+
"hotel-group",
|
|
152420
|
+
"new-customer-goal",
|
|
152421
|
+
"update-new-customer-goal",
|
|
152422
|
+
"brand-kit",
|
|
152423
|
+
"update-brand-kit",
|
|
152424
|
+
"delete-brand-kits",
|
|
152425
|
+
"import-job",
|
|
152426
|
+
"delete-import-jobs",
|
|
152427
|
+
"offline-conversion-adjustment",
|
|
152428
|
+
"online-conversion-adjustment",
|
|
152429
|
+
"account-properties",
|
|
152430
|
+
"expanded-text",
|
|
152431
|
+
"text-ad",
|
|
152432
|
+
"dynamic-search-ads-campaign",
|
|
152433
|
+
"customer-list-phone",
|
|
152434
|
+
"html5",
|
|
152435
|
+
"linkedin-segment",
|
|
152436
|
+
"apply-recommendations",
|
|
152437
|
+
"objective-based-campaign"
|
|
152438
|
+
];
|
|
152439
|
+
var BING_COVERAGE_READS = [
|
|
152440
|
+
"ad-groups",
|
|
152441
|
+
"keywords",
|
|
152442
|
+
"negative-keywords",
|
|
152443
|
+
"negative-sites",
|
|
152444
|
+
"ad-group-negative-sites",
|
|
152445
|
+
"editorial-reasons",
|
|
152446
|
+
"extensions",
|
|
152447
|
+
"audiences",
|
|
152448
|
+
"asset-groups",
|
|
152449
|
+
"experiments",
|
|
152450
|
+
"uet-tags",
|
|
152451
|
+
"conversion-goals",
|
|
152452
|
+
"shared-entities",
|
|
152453
|
+
"budgets",
|
|
152454
|
+
"bid-strategies",
|
|
152455
|
+
"seasonality",
|
|
152456
|
+
"data-exclusions",
|
|
152457
|
+
"conversion-value-rules",
|
|
152458
|
+
"videos",
|
|
152459
|
+
"media",
|
|
152460
|
+
"labels",
|
|
152461
|
+
"new-customer-goals",
|
|
152462
|
+
"brand-kits",
|
|
152463
|
+
"account-properties",
|
|
152464
|
+
"bmc-stores",
|
|
152465
|
+
"bsc-countries",
|
|
152466
|
+
"campaign-criterions",
|
|
152467
|
+
"ad-group-criterions",
|
|
152468
|
+
"import-jobs"
|
|
152469
|
+
];
|
|
152470
|
+
function bingCoverage() {
|
|
152471
|
+
const actions = {};
|
|
152472
|
+
for (const name2 of BING_COVERAGE_WRITES) actions[`bing.${name2}`] = bing(`coverage/${name2}`);
|
|
152473
|
+
for (const name2 of BING_COVERAGE_READS) actions[`bing.read-${name2}`] = bing(`coverage-read/${name2}`);
|
|
152474
|
+
return actions;
|
|
152475
|
+
}
|
|
151779
152476
|
var yandex = (path61, extra) => ({
|
|
151780
152477
|
service: "yandex",
|
|
151781
152478
|
method: "POST",
|
|
@@ -151783,6 +152480,80 @@ var yandex = (path61, extra) => ({
|
|
|
151783
152480
|
needsBody: true,
|
|
151784
152481
|
...extra
|
|
151785
152482
|
});
|
|
152483
|
+
var YANDEX_COVERAGE_WRITES = [
|
|
152484
|
+
"unified-campaign",
|
|
152485
|
+
"mobile-app-campaign",
|
|
152486
|
+
"cpm-banner-campaign",
|
|
152487
|
+
"dynamic-campaign",
|
|
152488
|
+
"smart-campaign",
|
|
152489
|
+
"unarchive-campaign",
|
|
152490
|
+
"campaign-negatives",
|
|
152491
|
+
"campaign-schedule",
|
|
152492
|
+
"campaign-end-date",
|
|
152493
|
+
"unified-ad-group",
|
|
152494
|
+
"dynamic-ad-group",
|
|
152495
|
+
"dynamic-feed-ad-group",
|
|
152496
|
+
"smart-ad-group",
|
|
152497
|
+
"mobile-app-ad-group",
|
|
152498
|
+
"cpm-keywords-ad-group",
|
|
152499
|
+
"cpm-profile-ad-group",
|
|
152500
|
+
"cpm-video-ad-group",
|
|
152501
|
+
"text-feed-ad-group",
|
|
152502
|
+
"update-ad-group",
|
|
152503
|
+
"update-text-ad",
|
|
152504
|
+
"text-image-ad",
|
|
152505
|
+
"text-ad-builder",
|
|
152506
|
+
"cpm-banner-ad",
|
|
152507
|
+
"cpm-video-ad",
|
|
152508
|
+
"shopping-ad",
|
|
152509
|
+
"listing-ad",
|
|
152510
|
+
"responsive-ad",
|
|
152511
|
+
"archive-ad",
|
|
152512
|
+
"unarchive-ad",
|
|
152513
|
+
"keyword-bids-auto",
|
|
152514
|
+
"bid-modifier",
|
|
152515
|
+
"set-bid-modifier",
|
|
152516
|
+
"suspend-audience-target",
|
|
152517
|
+
"resume-audience-target",
|
|
152518
|
+
"audience-target-bids",
|
|
152519
|
+
"update-retargeting-list",
|
|
152520
|
+
"update-feed",
|
|
152521
|
+
"smart-ad-target",
|
|
152522
|
+
"keywords-deduplicate",
|
|
152523
|
+
"keywords-has-search-volume",
|
|
152524
|
+
"changes-campaigns",
|
|
152525
|
+
"changes-dictionaries",
|
|
152526
|
+
"mc-banner-campaign",
|
|
152527
|
+
"cpm-deals-campaign",
|
|
152528
|
+
"cpm-frontpage-campaign",
|
|
152529
|
+
"cpm-price-campaign",
|
|
152530
|
+
"ad-group-suspend"
|
|
152531
|
+
];
|
|
152532
|
+
var YANDEX_COVERAGE_READS = [
|
|
152533
|
+
"campaigns",
|
|
152534
|
+
"ad-groups",
|
|
152535
|
+
"ads",
|
|
152536
|
+
"keywords",
|
|
152537
|
+
"sitelinks",
|
|
152538
|
+
"ad-images",
|
|
152539
|
+
"creatives",
|
|
152540
|
+
"extensions",
|
|
152541
|
+
"feeds",
|
|
152542
|
+
"retargeting-lists",
|
|
152543
|
+
"audience-targets",
|
|
152544
|
+
"bid-modifiers",
|
|
152545
|
+
"strategies",
|
|
152546
|
+
"vcards",
|
|
152547
|
+
"businesses",
|
|
152548
|
+
"turbo-pages",
|
|
152549
|
+
"negative-keyword-sets"
|
|
152550
|
+
];
|
|
152551
|
+
function yandexCoverage() {
|
|
152552
|
+
const actions = {};
|
|
152553
|
+
for (const name2 of YANDEX_COVERAGE_WRITES) actions[`yandex.${name2}`] = yandex(`coverage/${name2}`);
|
|
152554
|
+
for (const name2 of YANDEX_COVERAGE_READS) actions[`yandex.read-${name2}`] = yandex(`coverage-read/${name2}`);
|
|
152555
|
+
return actions;
|
|
152556
|
+
}
|
|
151786
152557
|
var facebook = (path61, extra) => ({
|
|
151787
152558
|
service: "facebook",
|
|
151788
152559
|
method: "POST",
|
|
@@ -151790,6 +152561,164 @@ var facebook = (path61, extra) => ({
|
|
|
151790
152561
|
needsBody: true,
|
|
151791
152562
|
...extra
|
|
151792
152563
|
});
|
|
152564
|
+
var META_COVERAGE_WRITES = [
|
|
152565
|
+
["campaign"],
|
|
152566
|
+
["adset"],
|
|
152567
|
+
["ad"],
|
|
152568
|
+
["creative"],
|
|
152569
|
+
["custom-audience"],
|
|
152570
|
+
["pixel"],
|
|
152571
|
+
["custom-conversion"],
|
|
152572
|
+
["ad-rule"],
|
|
152573
|
+
["ad-study"],
|
|
152574
|
+
["ad-label"],
|
|
152575
|
+
["saved-audience"],
|
|
152576
|
+
["block-list"],
|
|
152577
|
+
["reach-frequency"],
|
|
152578
|
+
["preview"],
|
|
152579
|
+
["insights-export"],
|
|
152580
|
+
["video-start"],
|
|
152581
|
+
["video-transfer"],
|
|
152582
|
+
["video-finish"],
|
|
152583
|
+
["form", { needsParent: true }],
|
|
152584
|
+
["canvas", { needsParent: true }],
|
|
152585
|
+
["product-catalog", { needsParent: true }],
|
|
152586
|
+
["product-set", { needsParent: true }],
|
|
152587
|
+
["product", { needsParent: true }],
|
|
152588
|
+
["product-feed", { needsParent: true }],
|
|
152589
|
+
["client-catalog", { needsParent: true }],
|
|
152590
|
+
["update-campaign", { needsId: true }],
|
|
152591
|
+
["update-adset", { needsId: true }],
|
|
152592
|
+
["update-ad", { needsId: true }],
|
|
152593
|
+
["update-creative", { needsId: true }],
|
|
152594
|
+
["update-audience", { needsId: true }],
|
|
152595
|
+
["update-pixel", { needsId: true }],
|
|
152596
|
+
["update-custom-conversion", { needsId: true }],
|
|
152597
|
+
["update-ad-rule", { needsId: true }],
|
|
152598
|
+
["update-ad-study", { needsId: true }],
|
|
152599
|
+
["update-label", { needsId: true }],
|
|
152600
|
+
["update-saved-audience", { needsId: true }],
|
|
152601
|
+
["update-block-list", { needsId: true }],
|
|
152602
|
+
["update-reach-frequency", { needsId: true }],
|
|
152603
|
+
["update-catalog", { needsId: true }],
|
|
152604
|
+
["update-product-set", { needsId: true }],
|
|
152605
|
+
["update-product", { needsId: true }],
|
|
152606
|
+
["update-product-feed", { needsId: true }],
|
|
152607
|
+
["test-leads", { needsId: true, needsParent: true }],
|
|
152608
|
+
["update-form", { needsId: true, needsParent: true }],
|
|
152609
|
+
["update-canvas", { needsId: true, needsParent: true }],
|
|
152610
|
+
["copy-campaign", { needsId: true }],
|
|
152611
|
+
["copy-adset", { needsId: true }],
|
|
152612
|
+
["copy-ad", { needsId: true }],
|
|
152613
|
+
["audience-users", { needsId: true }],
|
|
152614
|
+
["share-audience", { needsId: true }],
|
|
152615
|
+
["pixel-events", { needsId: true }],
|
|
152616
|
+
["share-pixel", { needsId: true }],
|
|
152617
|
+
["delete-campaign", { needsId: true, needsBody: false }],
|
|
152618
|
+
["delete-adset", { needsId: true, needsBody: false }],
|
|
152619
|
+
["delete-ad", { needsId: true, needsBody: false }],
|
|
152620
|
+
["delete-creative", { needsId: true, needsBody: false }],
|
|
152621
|
+
["delete-audience", { needsId: true, needsBody: false }],
|
|
152622
|
+
["delete-custom-conversion", { needsId: true, needsBody: false }],
|
|
152623
|
+
["delete-ad-rule", { needsId: true, needsBody: false }],
|
|
152624
|
+
["delete-ad-study", { needsId: true, needsBody: false }],
|
|
152625
|
+
["delete-label", { needsId: true, needsBody: false }],
|
|
152626
|
+
["delete-saved-audience", { needsId: true, needsBody: false }],
|
|
152627
|
+
["delete-block-list", { needsId: true, needsBody: false }],
|
|
152628
|
+
["delete-video", { needsId: true, needsBody: false }],
|
|
152629
|
+
["delete-catalog", { needsId: true, needsBody: false }],
|
|
152630
|
+
["delete-product-set", { needsId: true, needsBody: false }],
|
|
152631
|
+
["delete-product", { needsId: true, needsBody: false }],
|
|
152632
|
+
["delete-product-feed", { needsId: true, needsBody: false }],
|
|
152633
|
+
["delete-canvas", { needsId: true, needsParent: true, needsBody: false }],
|
|
152634
|
+
["delete-image"],
|
|
152635
|
+
["audience-users-remove", { needsId: true }]
|
|
152636
|
+
];
|
|
152637
|
+
var META_COVERAGE_READS = [
|
|
152638
|
+
["campaigns"],
|
|
152639
|
+
["adsets"],
|
|
152640
|
+
["ads"],
|
|
152641
|
+
["creatives"],
|
|
152642
|
+
["audiences"],
|
|
152643
|
+
["saved-audiences"],
|
|
152644
|
+
["pixels"],
|
|
152645
|
+
["custom-conversions"],
|
|
152646
|
+
["ad-rules"],
|
|
152647
|
+
["ad-studies"],
|
|
152648
|
+
["ad-labels"],
|
|
152649
|
+
["activities"],
|
|
152650
|
+
["insights"],
|
|
152651
|
+
["reach-estimate"],
|
|
152652
|
+
["targeting-search"],
|
|
152653
|
+
["targeting-browse"],
|
|
152654
|
+
["targeting-validation"],
|
|
152655
|
+
["images"],
|
|
152656
|
+
["videos"],
|
|
152657
|
+
["instagram-accounts"],
|
|
152658
|
+
["connected-instagram-accounts"],
|
|
152659
|
+
["applications"],
|
|
152660
|
+
["promote-pages"],
|
|
152661
|
+
["minimum-budgets"],
|
|
152662
|
+
["ads-volume"],
|
|
152663
|
+
["block-lists"],
|
|
152664
|
+
["reach-frequency"],
|
|
152665
|
+
["broad-targeting"],
|
|
152666
|
+
["users"],
|
|
152667
|
+
["agencies"],
|
|
152668
|
+
["offline-datasets"],
|
|
152669
|
+
["assigned-users"],
|
|
152670
|
+
["campaign", { needsId: true }],
|
|
152671
|
+
["campaign-adsets", { needsId: true }],
|
|
152672
|
+
["campaign-ads", { needsId: true }],
|
|
152673
|
+
["adset-ads", { needsId: true }],
|
|
152674
|
+
["ad-creatives", { needsId: true }],
|
|
152675
|
+
["adset", { needsId: true }],
|
|
152676
|
+
["ad", { needsId: true }],
|
|
152677
|
+
["creative", { needsId: true }],
|
|
152678
|
+
["audience", { needsId: true }],
|
|
152679
|
+
["pixel", { needsId: true }],
|
|
152680
|
+
["custom-conversion", { needsId: true }],
|
|
152681
|
+
["ad-rule", { needsId: true }],
|
|
152682
|
+
["ad-study", { needsId: true }],
|
|
152683
|
+
["label", { needsId: true }],
|
|
152684
|
+
["saved-audience", { needsId: true }],
|
|
152685
|
+
["video", { needsId: true }],
|
|
152686
|
+
["delivery-estimate", { needsId: true }],
|
|
152687
|
+
["previews", { needsId: true }],
|
|
152688
|
+
["ad-leads", { needsId: true }],
|
|
152689
|
+
["video-thumbnails", { needsId: true }],
|
|
152690
|
+
["ad-rule-history", { needsId: true }],
|
|
152691
|
+
["pixel-stats", { needsId: true }],
|
|
152692
|
+
["pixel-shared-accounts", { needsId: true }],
|
|
152693
|
+
["async-job", { needsId: true }],
|
|
152694
|
+
["object-insights", { needsId: true }],
|
|
152695
|
+
["catalog", { needsId: true }],
|
|
152696
|
+
["form", { needsId: true, needsParent: true }],
|
|
152697
|
+
["canvas", { needsId: true, needsParent: true }],
|
|
152698
|
+
["form-leads", { needsId: true, needsParent: true }],
|
|
152699
|
+
["product-sets", { needsParent: true }],
|
|
152700
|
+
["products", { needsParent: true }],
|
|
152701
|
+
["product-feeds", { needsParent: true }],
|
|
152702
|
+
["client-catalogs", { needsParent: true }]
|
|
152703
|
+
];
|
|
152704
|
+
function metaCoverage() {
|
|
152705
|
+
const actions = {};
|
|
152706
|
+
for (const [name2, flag] of META_COVERAGE_WRITES) {
|
|
152707
|
+
actions[`meta.${name2}`] = facebook(`coverage/${name2}`, {
|
|
152708
|
+
needsId: flag?.needsId,
|
|
152709
|
+
needsParent: flag?.needsParent,
|
|
152710
|
+
needsBody: flag?.needsBody !== false
|
|
152711
|
+
});
|
|
152712
|
+
}
|
|
152713
|
+
for (const [name2, flag] of META_COVERAGE_READS) {
|
|
152714
|
+
actions[`meta.read-${name2}`] = facebook(`coverage-read/${name2}`, {
|
|
152715
|
+
needsId: flag?.needsId,
|
|
152716
|
+
needsParent: flag?.needsParent,
|
|
152717
|
+
needsBody: false
|
|
152718
|
+
});
|
|
152719
|
+
}
|
|
152720
|
+
return actions;
|
|
152721
|
+
}
|
|
151793
152722
|
var tiktok = (path61) => ({
|
|
151794
152723
|
service: "tiktok",
|
|
151795
152724
|
method: "POST",
|
|
@@ -151814,6 +152743,7 @@ var GAP_ACTIONS = {
|
|
|
151814
152743
|
"bing.keyword-bids": bing("keywords/bids"),
|
|
151815
152744
|
"bing.delete-keywords": bing("keywords/delete"),
|
|
151816
152745
|
"bing.negative-keywords": bing("negative-keywords"),
|
|
152746
|
+
"bing.delete-negative-keywords": bing("negative-keywords/delete"),
|
|
151817
152747
|
"bing.campaign-negative-sites": bing("negative-sites/campaigns"),
|
|
151818
152748
|
"bing.ad-group-negative-sites": bing("negative-sites/ad-groups"),
|
|
151819
152749
|
"bing.location": bing("locations"),
|
|
@@ -151821,20 +152751,50 @@ var GAP_ACTIONS = {
|
|
|
151821
152751
|
"bing.budget": bing("budgets"),
|
|
151822
152752
|
"bing.delete-budgets": bing("budgets/delete"),
|
|
151823
152753
|
"bing.sitelink": bing("sitelinks"),
|
|
152754
|
+
"bing.delete-sitelinks": bing("sitelinks/delete"),
|
|
151824
152755
|
"bing.link-sitelink": bing("sitelinks/link"),
|
|
152756
|
+
"bing.unlink-sitelink": bing("sitelinks/unlink"),
|
|
151825
152757
|
"bing.customer-list": bing("customer-lists"),
|
|
152758
|
+
"bing.delete-customer-lists": bing("customer-lists/delete"),
|
|
151826
152759
|
"bing.customer-list-items": bing("customer-lists/items"),
|
|
151827
152760
|
"bing.uet-tag": bing("uet-tags"),
|
|
151828
152761
|
"bing.conversion-goal": bing("conversion-goals"),
|
|
151829
152762
|
"bing.offline-conversions": bing("offline-conversions"),
|
|
151830
152763
|
"bing.label": bing("labels"),
|
|
152764
|
+
"bing.delete-labels": bing("labels/delete"),
|
|
151831
152765
|
"bing.link-labels": bing("labels/link"),
|
|
152766
|
+
"bing.unlink-labels": bing("labels/unlink"),
|
|
151832
152767
|
"bing.experiment": bing("experiments"),
|
|
152768
|
+
"bing.delete-experiments": bing("experiments/delete"),
|
|
151833
152769
|
"bing.asset-group": bing("asset-groups"),
|
|
152770
|
+
"bing.delete-asset-groups": bing("asset-groups/delete"),
|
|
151834
152771
|
"bing.max-clicks": bing("bid-strategies"),
|
|
152772
|
+
"bing.delete-bid-strategies": bing("bid-strategies/delete"),
|
|
151835
152773
|
"bing.appeal": bing("editorial-appeals"),
|
|
151836
152774
|
"bing.image": bing("media"),
|
|
152775
|
+
"bing.delete-images": bing("media/delete"),
|
|
151837
152776
|
"bing.video": bing("videos"),
|
|
152777
|
+
"bing.delete-videos": bing("videos/delete"),
|
|
152778
|
+
"bing.negative-keyword-list": bing("negative-keyword-lists"),
|
|
152779
|
+
"bing.negative-keyword-list-items": bing("negative-keyword-lists/items"),
|
|
152780
|
+
"bing.link-negative-keyword-list": bing("negative-keyword-lists/link"),
|
|
152781
|
+
"bing.delete-negative-keyword-lists": bing("negative-keyword-lists/delete"),
|
|
152782
|
+
"bing.callout": bing("callouts"),
|
|
152783
|
+
"bing.snippet": bing("snippets"),
|
|
152784
|
+
"bing.price-extension": bing("price-extensions"),
|
|
152785
|
+
"bing.promotion-extension": bing("promotion-extensions"),
|
|
152786
|
+
"bing.call-extension": bing("call-extensions"),
|
|
152787
|
+
"bing.ad-group-device": bing("ad-group-devices"),
|
|
152788
|
+
"bing.ad-group-age": bing("ad-group-ages"),
|
|
152789
|
+
"bing.ad-group-gender": bing("ad-group-genders"),
|
|
152790
|
+
"bing.ad-group-audience": bing("ad-group-audiences"),
|
|
152791
|
+
"bing.rename-campaign": bing("campaigns/name"),
|
|
152792
|
+
"bing.campaign-settings": bing("campaigns/settings"),
|
|
152793
|
+
"bing.update-ad-copy": bing("ads/copy"),
|
|
152794
|
+
"bing.seasonality": bing("seasonality"),
|
|
152795
|
+
"bing.data-exclusion": bing("data-exclusions"),
|
|
152796
|
+
"bing.conversion-value-rule": bing("conversion-value-rules"),
|
|
152797
|
+
...bingCoverage(),
|
|
151838
152798
|
"yandex.text-campaign": yandex("campaigns"),
|
|
151839
152799
|
"yandex.rename-campaign": yandex("campaigns/{id}/name", { needsId: true }),
|
|
151840
152800
|
"yandex.archive-campaign": yandex("campaigns/{id}/archive", { needsId: true, needsBody: false }),
|
|
@@ -151868,6 +152828,23 @@ var GAP_ACTIONS = {
|
|
|
151868
152828
|
"yandex.changes": yandex("changes"),
|
|
151869
152829
|
"yandex.dictionaries": yandex("dictionaries"),
|
|
151870
152830
|
"yandex.leads": yandex("leads"),
|
|
152831
|
+
"yandex.vcard": yandex("vcards"),
|
|
152832
|
+
"yandex.delete-vcard": yandex("vcards/{id}/delete", { needsId: true, needsBody: false }),
|
|
152833
|
+
"yandex.negative-keyword-set": yandex("negative-keyword-sets"),
|
|
152834
|
+
"yandex.update-negative-keyword-set": yandex("negative-keyword-sets/{id}", { needsId: true }),
|
|
152835
|
+
"yandex.delete-negative-keyword-set": yandex("negative-keyword-sets/{id}/delete", { needsId: true, needsBody: false }),
|
|
152836
|
+
"yandex.link-negative-keyword-sets": yandex("adgroups/{id}/negative-keyword-sets", { needsId: true }),
|
|
152837
|
+
"yandex.strategy": yandex("strategies"),
|
|
152838
|
+
"yandex.update-strategy": yandex("strategies/{id}", { needsId: true }),
|
|
152839
|
+
"yandex.archive-strategy": yandex("strategies/{id}/archive", { needsId: true, needsBody: false }),
|
|
152840
|
+
"yandex.video": yandex("videos"),
|
|
152841
|
+
"yandex.video-status": yandex("videos/{id}", { needsId: true, needsBody: false }),
|
|
152842
|
+
"yandex.dynamic-target": yandex("dynamic-text-targets"),
|
|
152843
|
+
"yandex.dynamic-target-bids": yandex("dynamic-text-targets/bids"),
|
|
152844
|
+
"yandex.suspend-dynamic-target": yandex("dynamic-text-targets/{id}/suspend", { needsId: true, needsBody: false }),
|
|
152845
|
+
"yandex.resume-dynamic-target": yandex("dynamic-text-targets/{id}/resume", { needsId: true, needsBody: false }),
|
|
152846
|
+
"yandex.delete-dynamic-target": yandex("dynamic-text-targets/{id}/delete", { needsId: true, needsBody: false }),
|
|
152847
|
+
...yandexCoverage(),
|
|
151871
152848
|
"tiktok.audience-file": tiktok("audiences/file"),
|
|
151872
152849
|
"tiktok.audience-rule": tiktok("audiences/rule"),
|
|
151873
152850
|
"tiktok.campaign-copy": tiktok("campaign-copies"),
|
|
@@ -151875,14 +152852,33 @@ var GAP_ACTIONS = {
|
|
|
151875
152852
|
"tiktok.smart-plus": tiktok("smart-plus"),
|
|
151876
152853
|
"tiktok.negative-keywords": tiktok("negative-keywords"),
|
|
151877
152854
|
"tiktok.split-test": tiktok("split-tests"),
|
|
152855
|
+
"tiktok.campaign": tiktok("campaigns"),
|
|
152856
|
+
"tiktok.ad-group": tiktok("ad-groups"),
|
|
152857
|
+
"tiktok.ad": tiktok("ads"),
|
|
152858
|
+
"tiktok.smart-creative": tiktok("smart-creatives"),
|
|
151878
152859
|
"meta.outcome-campaign": facebook("outcome-campaigns"),
|
|
151879
152860
|
"meta.outcome-campaign-update": facebook("outcome-campaigns/{id}", { needsId: true }),
|
|
152861
|
+
"meta.advantage-campaign": facebook("advantage-campaigns"),
|
|
152862
|
+
"meta.outcome-adset": facebook("outcome-adsets"),
|
|
152863
|
+
"meta.advantage-adset": facebook("advantage-adsets"),
|
|
152864
|
+
"meta.outcome-creative": facebook("outcome-creatives"),
|
|
152865
|
+
"meta.outcome-ad": facebook("outcome-ads"),
|
|
152866
|
+
...metaCoverage(),
|
|
151880
152867
|
"google.create-conversion-action": google("POST", "/conversion-actions/{account}"),
|
|
151881
152868
|
"google.update-conversion-action": google("PUT", "/conversion-actions/{account}/{id}", { needsId: true }),
|
|
151882
152869
|
"google.remove-conversion-action": google("DELETE", "/conversion-actions/{account}/{id}", { needsId: true, needsBody: false }),
|
|
151883
152870
|
"google.upload-clicks": google("POST", "/conversion-uploads/{account}/clicks"),
|
|
151884
152871
|
"google.upload-enhanced-clicks": google("POST", "/conversion-uploads/{account}/enhanced-clicks"),
|
|
152872
|
+
"google.upload-adjustment": google("POST", "/conversion-uploads/{account}/adjustments"),
|
|
152873
|
+
"google.campaign-negative-set": google("POST", "/shared-sets/{account}"),
|
|
152874
|
+
"google.campaign-negative-keywords": google("POST", "/shared-sets/{account}/{id}/keywords", { needsId: true }),
|
|
152875
|
+
"google.attach-campaign-negative-set": google("POST", "/shared-sets/{account}/{id}/campaigns/{parent}", {
|
|
152876
|
+
needsId: true,
|
|
152877
|
+
needsParent: true,
|
|
152878
|
+
needsBody: false
|
|
152879
|
+
}),
|
|
151885
152880
|
"google.customer-match-list": google("POST", "/customer-match/{account}/user-lists"),
|
|
152881
|
+
"google.remove-customer-match-list": google("DELETE", "/customer-match/{account}/user-lists/{id}", { needsId: true, needsBody: false }),
|
|
151886
152882
|
"google.customer-match-job": google("POST", "/customer-match/{account}/jobs?userListId={id}", { needsId: true, needsBody: false }),
|
|
151887
152883
|
"google.customer-match-operations": google("POST", "/customer-match/{account}/jobs/{id}/operations", { needsId: true }),
|
|
151888
152884
|
"google.customer-match-run": google("POST", "/customer-match/{account}/jobs/{id}/run", { needsId: true }),
|
|
@@ -151894,8 +152890,12 @@ var GAP_ACTIONS = {
|
|
|
151894
152890
|
"google.remove-data-exclusion": google("DELETE", "/bidding-data-exclusions/{account}/{id}", { needsId: true, needsBody: false }),
|
|
151895
152891
|
"google.campaign-simulations": google("GET", "/bid-simulations/{account}/campaigns/{id}", { needsId: true, needsBody: false }),
|
|
151896
152892
|
"google.experiment": google("POST", "/experiments/{account}"),
|
|
152893
|
+
"google.experiment-arm": google("POST", "/experiments/{account}/{id}/arms", { needsId: true }),
|
|
151897
152894
|
"google.end-experiment": google("POST", "/experiments/{account}/{id}/end", { needsId: true, needsBody: false }),
|
|
152895
|
+
"google.schedule-experiment": google("POST", "/experiments/{account}/{id}/schedule", { needsId: true, needsBody: false }),
|
|
152896
|
+
"google.promote-experiment": google("POST", "/experiments/{account}/{id}/promote", { needsId: true, needsBody: false }),
|
|
151898
152897
|
"google.label": google("POST", "/labels/{account}"),
|
|
152898
|
+
"google.remove-label": google("DELETE", "/labels/{account}/{id}", { needsId: true, needsBody: false }),
|
|
151899
152899
|
"google.link-campaign-label": google("POST", "/labels/{account}/campaigns/{parent}", { needsParent: true }),
|
|
151900
152900
|
"google.unlink-campaign-label": google("DELETE", "/labels/{account}/campaigns/{parent}/{id}", { needsParent: true, needsId: true, needsBody: false }),
|
|
151901
152901
|
"google.link-ad-group-label": google("POST", "/labels/{account}/ad-groups/{parent}", { needsParent: true }),
|
|
@@ -151905,6 +152905,7 @@ var GAP_ACTIONS = {
|
|
|
151905
152905
|
"google.link-criterion-label": google("POST", "/labels/{account}/ad-groups/{parent}/criteria/{id}", { needsParent: true, needsId: true }),
|
|
151906
152906
|
"google.unlink-criterion-label": google("DELETE", "/labels/{account}/ad-groups/{parent}/criteria/{id}/{label}", { needsParent: true, needsId: true, needsLabel: true, needsBody: false }),
|
|
151907
152907
|
"google.customizer-attribute": google("POST", "/customizer-attributes/{account}"),
|
|
152908
|
+
"google.remove-customizer-attribute": google("DELETE", "/customizer-attributes/{account}/{id}", { needsId: true, needsBody: false }),
|
|
151908
152909
|
"google.customer-customizer": google("POST", "/customizers/{account}"),
|
|
151909
152910
|
"google.criterion-bid": google("PUT", "/ad-groups/{account}/{parent}/criteria/{id}/bid", { needsParent: true, needsId: true }),
|
|
151910
152911
|
"google.shopping-campaign": google("POST", "/campaigns/{account}/shopping"),
|
|
@@ -151922,7 +152923,7 @@ function resolveGapPath(actionName, target) {
|
|
|
151922
152923
|
if (!action) {
|
|
151923
152924
|
throw new Error(`\u672A\u77E5 action\uFF1A${actionName}`);
|
|
151924
152925
|
}
|
|
151925
|
-
if (action.path.includes("catalog")) {
|
|
152926
|
+
if (action.service === "tiktok" && action.path.toLowerCase().includes("catalog")) {
|
|
151926
152927
|
throw new Error("\u5546\u54C1\u76EE\u5F55\u8DEF\u5F84\u672A\u63A5\u5165");
|
|
151927
152928
|
}
|
|
151928
152929
|
const account = requireToken(target.account, "account");
|
|
@@ -151936,6 +152937,12 @@ function resolveGapPath(actionName, target) {
|
|
|
151936
152937
|
if (action.service === "yandex") {
|
|
151937
152938
|
path61 += `${path61.includes("?") ? "&" : "?"}account=${encodeURIComponent(account)}`;
|
|
151938
152939
|
}
|
|
152940
|
+
if (action.service === "facebook" && action.path.includes("/coverage")) {
|
|
152941
|
+
const extra = [];
|
|
152942
|
+
if (action.needsId) extra.push(`id=${encodeURIComponent(id)}`);
|
|
152943
|
+
if (action.needsParent) extra.push(`parent=${encodeURIComponent(parent)}`);
|
|
152944
|
+
if (extra.length > 0) path61 += `${path61.includes("?") ? "&" : "?"}${extra.join("&")}`;
|
|
152945
|
+
}
|
|
151939
152946
|
return { action, path: path61 };
|
|
151940
152947
|
}
|
|
151941
152948
|
function requireToken(value, label2) {
|
|
@@ -151993,7 +153000,8 @@ var META_OUTCOME_OBJECTIVES = /* @__PURE__ */ new Set([
|
|
|
151993
153000
|
"OUTCOME_TRAFFIC",
|
|
151994
153001
|
"OUTCOME_ENGAGEMENT",
|
|
151995
153002
|
"OUTCOME_APP_PROMOTION",
|
|
151996
|
-
"OUTCOME_SALES"
|
|
153003
|
+
"OUTCOME_SALES",
|
|
153004
|
+
"OUTCOME_LEADS"
|
|
151997
153005
|
]);
|
|
151998
153006
|
function assertMetaOutcome(action, body) {
|
|
151999
153007
|
const record2 = body;
|
|
@@ -152001,31 +153009,98 @@ function assertMetaOutcome(action, body) {
|
|
|
152001
153009
|
if (status && status !== "PAUSED") {
|
|
152002
153010
|
throw new Error("\u8FD9\u6761\u8DEF\u5F84\u53EA\u63A5\u53D7 PAUSED\uFF0C\u4E0D\u80FD\u5728\u8FD9\u91CC\u6253\u5F00\u6295\u653E");
|
|
152003
153011
|
}
|
|
152004
|
-
if (action === "meta.outcome-campaign") {
|
|
153012
|
+
if (action === "meta.outcome-campaign" || action === "meta.advantage-campaign") {
|
|
152005
153013
|
const objective = String(record2.objective ?? "").trim().toUpperCase();
|
|
152006
|
-
if (objective === "OUTCOME_LEADS") {
|
|
152007
|
-
throw new Error("\u7EBF\u7D22\u7CFB\u5217\u8BF7\u7528 meta-ad\uFF0C\u4E0D\u8981\u7528 meta.outcome-campaign");
|
|
152008
|
-
}
|
|
152009
153014
|
if (!META_OUTCOME_OBJECTIVES.has(objective)) {
|
|
152010
|
-
throw new Error("objective \u53EA\u63A5\u53D7\u8BA4\u77E5\u3001\u6D41\u91CF\u3001\u4E92\u52A8\u3001\u5E94\u7528\u63A8\u5E7F\u3001\u9500\u552E\u8FD9\
|
|
153015
|
+
throw new Error("objective \u53EA\u63A5\u53D7\u8BA4\u77E5\u3001\u6D41\u91CF\u3001\u4E92\u52A8\u3001\u5E94\u7528\u63A8\u5E7F\u3001\u9500\u552E\u3001\u7EBF\u7D22\u8FD9\u516D\u4E2A\u76EE\u6807");
|
|
152011
153016
|
}
|
|
152012
153017
|
if (!Array.isArray(record2.special_ad_categories)) {
|
|
152013
153018
|
throw new Error("special_ad_categories \u5FC5\u586B\uFF0C\u6CA1\u6709\u7279\u6B8A\u5206\u7C7B\u65F6\u4F20\u7A7A\u6570\u7EC4");
|
|
152014
153019
|
}
|
|
153020
|
+
if (typeof record2.smart_promotion_type === "string" && record2.smart_promotion_type.trim()) {
|
|
153021
|
+
throw new Error("\u4E0D\u8981\u4F20 smart_promotion_type");
|
|
153022
|
+
}
|
|
153023
|
+
}
|
|
153024
|
+
if (action === "meta.advantage-campaign") {
|
|
153025
|
+
const daily = typeof record2.daily_budget === "string" ? record2.daily_budget.trim() : "";
|
|
153026
|
+
const lifetime = typeof record2.lifetime_budget === "string" ? record2.lifetime_budget.trim() : "";
|
|
153027
|
+
if (!daily && !lifetime) {
|
|
153028
|
+
throw new Error("Advantage+ \u9700\u8981\u7CFB\u5217\u9884\u7B97");
|
|
153029
|
+
}
|
|
153030
|
+
}
|
|
153031
|
+
if (action === "meta.outcome-adset" || action === "meta.advantage-adset") {
|
|
153032
|
+
const goal = String(record2.optimization_goal ?? "").trim().toUpperCase();
|
|
153033
|
+
const destination = String(record2.destination_type ?? "").trim().toUpperCase();
|
|
153034
|
+
const messaging = destination === "MESSENGER" || destination === "WHATSAPP" || destination === "INSTAGRAM_DIRECT" || destination === "PHONE_CALL" || destination === "LEAD_FROM_MESSENGER" || destination === "LEAD_FROM_IG_DIRECT" || destination.startsWith("MESSAGING_");
|
|
153035
|
+
if (goal === "QUALITY_LEAD" || goal === "LEAD_GENERATION" && !messaging) {
|
|
153036
|
+
throw new Error("\u5373\u65F6\u8868\u5355\u8BF7\u7528 meta-ad\u3002\u6D88\u606F\u6216\u7535\u8BDD\u7EBF\u7D22\u8981\u5E26 destination_type");
|
|
153037
|
+
}
|
|
152015
153038
|
}
|
|
152016
153039
|
if (action === "meta.outcome-campaign-update" && ("objective" in record2 || "buying_type" in record2 || "special_ad_categories" in record2)) {
|
|
152017
153040
|
throw new Error("\u8FD9\u91CC\u4E0D\u80FD\u6539 objective\u3001buying_type \u6216 special_ad_categories");
|
|
152018
153041
|
}
|
|
152019
153042
|
}
|
|
153043
|
+
function rewriteOutcomeAdSet(action, body) {
|
|
153044
|
+
if (action !== "meta.outcome-adset" || body == null || typeof body !== "object" || Array.isArray(body)) {
|
|
153045
|
+
return null;
|
|
153046
|
+
}
|
|
153047
|
+
const record2 = body;
|
|
153048
|
+
const goal = String(record2.optimization_goal ?? "").trim().toUpperCase();
|
|
153049
|
+
const destination = String(record2.destination_type ?? "").trim().toUpperCase();
|
|
153050
|
+
const video = goal === "THRUPLAY" || destination === "ON_VIDEO";
|
|
153051
|
+
const website = (goal === "LINK_CLICKS" || goal === "LANDING_PAGE_VIEWS") && (destination === "" || destination === "WEBSITE");
|
|
153052
|
+
if (!video && !website) return null;
|
|
153053
|
+
if (video && goal && goal !== "THRUPLAY") {
|
|
153054
|
+
throw new Error("\u89C6\u9891\u64AD\u653E\u5E7F\u544A\u7EC4\u7684 optimization_goal \u7528 THRUPLAY");
|
|
153055
|
+
}
|
|
153056
|
+
const pageId = String(record2.page_id ?? "").trim();
|
|
153057
|
+
if (video && !/^\d+$/.test(pageId)) {
|
|
153058
|
+
throw new Error("\u89C6\u9891\u64AD\u653E\u5E7F\u544A\u7EC4\u8981\u5E26\u6570\u5B57 page_id");
|
|
153059
|
+
}
|
|
153060
|
+
if (pageId && !/^\d+$/.test(pageId)) {
|
|
153061
|
+
throw new Error("page_id \u5FC5\u987B\u662F\u6570\u5B57");
|
|
153062
|
+
}
|
|
153063
|
+
if (!Array.isArray(record2.countries) || record2.countries.length === 0) {
|
|
153064
|
+
throw new Error("\u5E7F\u544A\u7EC4\u8981\u5E26 countries");
|
|
153065
|
+
}
|
|
153066
|
+
const advantage = record2.advantage_audience === 1 ? 1 : 0;
|
|
153067
|
+
const targeting = {
|
|
153068
|
+
geo_locations: { countries: record2.countries },
|
|
153069
|
+
targeting_automation: { advantage_audience: advantage }
|
|
153070
|
+
};
|
|
153071
|
+
if (record2.age_min != null) targeting.age_min = record2.age_min;
|
|
153072
|
+
if (record2.age_max != null) targeting.age_max = record2.age_max;
|
|
153073
|
+
const next = {
|
|
153074
|
+
name: record2.name,
|
|
153075
|
+
campaign_id: record2.campaign_id,
|
|
153076
|
+
status: "PAUSED",
|
|
153077
|
+
optimization_goal: video ? "THRUPLAY" : goal,
|
|
153078
|
+
billing_event: "IMPRESSIONS",
|
|
153079
|
+
bid_strategy: "LOWEST_COST_WITHOUT_CAP",
|
|
153080
|
+
destination_type: video ? "ON_VIDEO" : "WEBSITE",
|
|
153081
|
+
targeting
|
|
153082
|
+
};
|
|
153083
|
+
if (/^\d+$/.test(pageId)) {
|
|
153084
|
+
next.promoted_object = { page_id: pageId };
|
|
153085
|
+
}
|
|
153086
|
+
const budget = String(record2.daily_budget ?? "").trim();
|
|
153087
|
+
if (budget) next.daily_budget = budget;
|
|
153088
|
+
return { action: "meta.adset", body: next };
|
|
153089
|
+
}
|
|
152020
153090
|
async function runAdGap(opts) {
|
|
152021
|
-
|
|
152022
|
-
|
|
153091
|
+
let resolved = resolveGapPath(opts.action, opts);
|
|
153092
|
+
let body = readGapBody(opts, resolved.action.needsBody);
|
|
152023
153093
|
if (resolved.action.service === "tiktok") {
|
|
152024
153094
|
assertTikTokAdvertiser(opts.account, body);
|
|
152025
153095
|
}
|
|
152026
|
-
if (resolved.action.service === "facebook") {
|
|
153096
|
+
if (resolved.action.service === "facebook" && (opts.action.startsWith("meta.outcome") || opts.action.startsWith("meta.advantage"))) {
|
|
152027
153097
|
assertMetaOutcome(opts.action, body);
|
|
152028
153098
|
}
|
|
153099
|
+
const rewritten = rewriteOutcomeAdSet(opts.action, body);
|
|
153100
|
+
if (rewritten) {
|
|
153101
|
+
resolved = resolveGapPath(rewritten.action, opts);
|
|
153102
|
+
body = rewritten.body;
|
|
153103
|
+
}
|
|
152029
153104
|
const config = loadConfig(opts.token);
|
|
152030
153105
|
const url = serviceBase(resolved.action.service, config) + resolved.path;
|
|
152031
153106
|
const payload = await apiFetch2(
|