@optima-chat/ads-cli 0.6.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/commands/account/check.d.ts.map +1 -1
- package/dist/commands/account/check.js +12 -62
- package/dist/commands/account/check.js.map +1 -1
- package/dist/commands/account/index.d.ts.map +1 -1
- package/dist/commands/account/index.js +2 -2
- package/dist/commands/account/index.js.map +1 -1
- package/dist/commands/account/link.d.ts +6 -0
- package/dist/commands/account/link.d.ts.map +1 -0
- package/dist/commands/account/link.js +57 -0
- package/dist/commands/account/link.js.map +1 -0
- package/dist/commands/ad/create.d.ts.map +1 -1
- package/dist/commands/ad/create.js +29 -28
- package/dist/commands/ad/create.js.map +1 -1
- package/dist/commands/ad/delete.d.ts.map +1 -1
- package/dist/commands/ad/delete.js +1 -28
- package/dist/commands/ad/delete.js.map +1 -1
- package/dist/commands/ad/info.d.ts.map +1 -1
- package/dist/commands/ad/info.js +3 -66
- package/dist/commands/ad/info.js.map +1 -1
- package/dist/commands/ad/list.d.ts.map +1 -1
- package/dist/commands/ad/list.js +1 -65
- package/dist/commands/ad/list.js.map +1 -1
- package/dist/commands/ad/update.d.ts.map +1 -1
- package/dist/commands/ad/update.js +8 -17
- package/dist/commands/ad/update.js.map +1 -1
- package/dist/commands/ad-group/create.d.ts.map +1 -1
- package/dist/commands/ad-group/create.js +1 -23
- package/dist/commands/ad-group/create.js.map +1 -1
- package/dist/commands/ad-group/delete.d.ts.map +1 -1
- package/dist/commands/ad-group/delete.js +1 -28
- package/dist/commands/ad-group/delete.js.map +1 -1
- package/dist/commands/ad-group/info.d.ts.map +1 -1
- package/dist/commands/ad-group/info.js +4 -37
- package/dist/commands/ad-group/info.js.map +1 -1
- package/dist/commands/ad-group/list.d.ts.map +1 -1
- package/dist/commands/ad-group/list.js +1 -57
- package/dist/commands/ad-group/list.js.map +1 -1
- package/dist/commands/ad-group/update.d.ts.map +1 -1
- package/dist/commands/ad-group/update.js +11 -28
- package/dist/commands/ad-group/update.js.map +1 -1
- package/dist/commands/auth/status.d.ts +0 -2
- package/dist/commands/auth/status.d.ts.map +1 -1
- package/dist/commands/auth/status.js +12 -47
- package/dist/commands/auth/status.js.map +1 -1
- package/dist/commands/campaign/create.d.ts.map +1 -1
- package/dist/commands/campaign/create.js +1 -24
- package/dist/commands/campaign/create.js.map +1 -1
- package/dist/commands/campaign/delete.d.ts.map +1 -1
- package/dist/commands/campaign/delete.js +1 -28
- package/dist/commands/campaign/delete.js.map +1 -1
- package/dist/commands/campaign/info.d.ts.map +1 -1
- package/dist/commands/campaign/info.js +3 -34
- package/dist/commands/campaign/info.js.map +1 -1
- package/dist/commands/campaign/list.d.ts.map +1 -1
- package/dist/commands/campaign/list.js +1 -46
- package/dist/commands/campaign/list.js.map +1 -1
- package/dist/commands/campaign/update.d.ts.map +1 -1
- package/dist/commands/campaign/update.js +11 -28
- package/dist/commands/campaign/update.js.map +1 -1
- package/dist/commands/config.d.ts.map +1 -1
- package/dist/commands/config.js +16 -72
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/keyword/add.d.ts.map +1 -1
- package/dist/commands/keyword/add.js +1 -20
- package/dist/commands/keyword/add.js.map +1 -1
- package/dist/commands/keyword/delete.d.ts.map +1 -1
- package/dist/commands/keyword/delete.js +1 -28
- package/dist/commands/keyword/delete.js.map +1 -1
- package/dist/commands/keyword/list.d.ts.map +1 -1
- package/dist/commands/keyword/list.js +1 -51
- package/dist/commands/keyword/list.js.map +1 -1
- package/dist/commands/keyword/update.d.ts.map +1 -1
- package/dist/commands/keyword/update.js +10 -24
- package/dist/commands/keyword/update.js.map +1 -1
- package/dist/index.js +0 -0
- package/package.json +9 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../src/commands/campaign/create.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;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@
|
|
|
1
|
-
{"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../src/commands/campaign/delete.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../src/commands/campaign/delete.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,eAAO,MAAM,aAAa,SActB,CAAC"}
|
|
@@ -2,45 +2,18 @@
|
|
|
2
2
|
* Campaign Delete Command - 删除广告系列
|
|
3
3
|
*/
|
|
4
4
|
import { Command } from 'commander';
|
|
5
|
-
import chalk from 'chalk';
|
|
6
|
-
import ora from 'ora';
|
|
7
|
-
import inquirer from 'inquirer';
|
|
8
5
|
import { getApiClient } from '../../lib/api-client.js';
|
|
9
6
|
import { handleError } from '../../utils/errors.js';
|
|
10
7
|
import { getCustomerId } from '../../utils/customer-id.js';
|
|
11
8
|
export const deleteCommand = new Command('delete')
|
|
12
9
|
.description('删除广告系列')
|
|
13
10
|
.requiredOption('--campaign-id <id>', '广告系列 ID')
|
|
14
|
-
.option('-y, --yes', '跳过确认')
|
|
15
|
-
.option('--json', '以 JSON 格式输出')
|
|
16
11
|
.action(async (options) => {
|
|
17
12
|
try {
|
|
18
13
|
const customerId = getCustomerId();
|
|
19
|
-
// 确认删除
|
|
20
|
-
if (!options.yes) {
|
|
21
|
-
const answer = await inquirer.prompt([
|
|
22
|
-
{
|
|
23
|
-
type: 'confirm',
|
|
24
|
-
name: 'confirm',
|
|
25
|
-
message: `确定要删除广告系列 ${options.campaignId} 吗?`,
|
|
26
|
-
default: false,
|
|
27
|
-
},
|
|
28
|
-
]);
|
|
29
|
-
if (!answer.confirm) {
|
|
30
|
-
console.log(chalk.yellow('已取消'));
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
const spinner = ora('删除广告系列...').start();
|
|
35
14
|
const client = getApiClient();
|
|
36
15
|
const result = await client.deleteCampaign(customerId, options.campaignId);
|
|
37
|
-
|
|
38
|
-
if (options.json) {
|
|
39
|
-
console.log(JSON.stringify(result, null, 2));
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
console.log(chalk.green(`\n✅ 广告系列 ${options.campaignId} 已删除`));
|
|
43
|
-
}
|
|
16
|
+
console.log(JSON.stringify(result, null, 2));
|
|
44
17
|
}
|
|
45
18
|
catch (error) {
|
|
46
19
|
handleError(error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delete.js","sourceRoot":"","sources":["../../../src/commands/campaign/delete.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,
|
|
1
|
+
{"version":3,"file":"delete.js","sourceRoot":"","sources":["../../../src/commands/campaign/delete.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC;KAC/C,WAAW,CAAC,QAAQ,CAAC;KACrB,cAAc,CAAC,oBAAoB,EAAE,SAAS,CAAC;KAC/C,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;IACxB,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,aAAa,EAAE,CAAC;QACnC,MAAM,MAAM,GAAG,YAAY,EAAE,CAAC;QAE9B,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;QAE3E,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAC/C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,WAAW,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC;AACH,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"info.d.ts","sourceRoot":"","sources":["../../../src/commands/campaign/info.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"info.d.ts","sourceRoot":"","sources":["../../../src/commands/campaign/info.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,eAAO,MAAM,WAAW,SAmBpB,CAAC"}
|
|
@@ -2,53 +2,22 @@
|
|
|
2
2
|
* Campaign Info Command - 查看广告系列详情
|
|
3
3
|
*/
|
|
4
4
|
import { Command } from 'commander';
|
|
5
|
-
import chalk from 'chalk';
|
|
6
|
-
import Table from 'cli-table3';
|
|
7
|
-
import ora from 'ora';
|
|
8
5
|
import { getApiClient } from '../../lib/api-client.js';
|
|
9
6
|
import { handleError } from '../../utils/errors.js';
|
|
10
|
-
import { error as logError } from '../../utils/logger.js';
|
|
11
7
|
import { getCustomerId } from '../../utils/customer-id.js';
|
|
12
8
|
export const infoCommand = new Command('info')
|
|
13
9
|
.description('查看广告系列详情')
|
|
14
10
|
.argument('<campaign-id>', '广告系列 ID')
|
|
15
|
-
.
|
|
16
|
-
.action(async (campaignId, options) => {
|
|
11
|
+
.action(async (campaignId) => {
|
|
17
12
|
try {
|
|
18
13
|
const customerId = getCustomerId();
|
|
19
14
|
const client = getApiClient();
|
|
20
|
-
const spinner = ora('正在获取广告系列信息...').start();
|
|
21
|
-
// 获取广告系列详情
|
|
22
15
|
const campaign = await client.getCampaign(customerId, campaignId);
|
|
23
|
-
spinner.stop();
|
|
24
16
|
if (!campaign) {
|
|
25
|
-
|
|
17
|
+
console.log(JSON.stringify({ error: 'not_found', campaign_id: campaignId }, null, 2));
|
|
26
18
|
process.exit(1);
|
|
27
19
|
}
|
|
28
|
-
|
|
29
|
-
if (options.json) {
|
|
30
|
-
console.log(JSON.stringify(campaign, null, 2));
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
const table = new Table({
|
|
34
|
-
head: [chalk.cyan('属性'), chalk.cyan('值')],
|
|
35
|
-
colWidths: [25, 55],
|
|
36
|
-
});
|
|
37
|
-
const cost = campaign.metrics?.cost_micros
|
|
38
|
-
? (campaign.metrics.cost_micros / 1000000).toFixed(2)
|
|
39
|
-
: '0.00';
|
|
40
|
-
const avgCpc = campaign.metrics?.average_cpc
|
|
41
|
-
? (campaign.metrics.average_cpc / 1000000).toFixed(2)
|
|
42
|
-
: '0.00';
|
|
43
|
-
const avgCpm = campaign.metrics?.average_cpm
|
|
44
|
-
? (campaign.metrics.average_cpm / 1000000).toFixed(2)
|
|
45
|
-
: '0.00';
|
|
46
|
-
const ctr = campaign.metrics?.ctr
|
|
47
|
-
? (campaign.metrics.ctr * 100).toFixed(2) + '%'
|
|
48
|
-
: '0.00%';
|
|
49
|
-
table.push(['广告系列 ID', campaign.campaign?.id || 'N/A'], ['名称', campaign.campaign?.name || '未命名'], ['状态', campaign.campaign?.status || 'N/A'], ['广告类型', campaign.campaign?.advertising_channel_type || 'N/A'], ['出价策略', campaign.campaign?.bidding_strategy_type || 'N/A'], ['开始日期', campaign.campaign?.start_date || '未设置'], ['结束日期', campaign.campaign?.end_date || '未设置'], ['---', '---'], ['展示量', campaign.metrics?.impressions || 0], ['点击量', campaign.metrics?.clicks || 0], ['费用', cost], ['转化次数', campaign.metrics?.conversions || 0], ['转化价值', campaign.metrics?.conversions_value || 0], ['平均每次点击费用', avgCpc], ['平均千次展示费用', avgCpm], ['点击率', ctr], ['优化得分', campaign.campaign?.optimization_score || 'N/A']);
|
|
50
|
-
console.log('\n' + table.toString() + '\n');
|
|
51
|
-
}
|
|
20
|
+
console.log(JSON.stringify(campaign, null, 2));
|
|
52
21
|
}
|
|
53
22
|
catch (error) {
|
|
54
23
|
handleError(error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"info.js","sourceRoot":"","sources":["../../../src/commands/campaign/info.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,
|
|
1
|
+
{"version":3,"file":"info.js","sourceRoot":"","sources":["../../../src/commands/campaign/info.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC;KAC3C,WAAW,CAAC,UAAU,CAAC;KACvB,QAAQ,CAAC,eAAe,EAAE,SAAS,CAAC;KACpC,MAAM,CAAC,KAAK,EAAE,UAAkB,EAAE,EAAE;IACnC,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,aAAa,EAAE,CAAC;QACnC,MAAM,MAAM,GAAG,YAAY,EAAE,CAAC;QAE9B,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;QAElE,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;YACtF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IACjD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,WAAW,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC;AACH,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/commands/campaign/list.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/commands/campaign/list.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,eAAO,MAAM,WAAW,SAkBpB,CAAC"}
|
|
@@ -2,67 +2,22 @@
|
|
|
2
2
|
* Campaign List Command - 列出广告系列
|
|
3
3
|
*/
|
|
4
4
|
import { Command } from 'commander';
|
|
5
|
-
import chalk from 'chalk';
|
|
6
|
-
import Table from 'cli-table3';
|
|
7
|
-
import ora from 'ora';
|
|
8
5
|
import { getApiClient } from '../../lib/api-client.js';
|
|
9
6
|
import { handleError } from '../../utils/errors.js';
|
|
10
|
-
import { warn } from '../../utils/logger.js';
|
|
11
7
|
import { getCustomerId } from '../../utils/customer-id.js';
|
|
12
8
|
export const listCommand = new Command('list')
|
|
13
9
|
.description('列出广告系列')
|
|
14
10
|
.option('--status <status>', '按状态过滤 (ENABLED/PAUSED/REMOVED)')
|
|
15
11
|
.option('--limit <number>', '限制返回数量', '50')
|
|
16
|
-
.option('--json', '以 JSON 格式输出')
|
|
17
12
|
.action(async (options) => {
|
|
18
13
|
try {
|
|
19
14
|
const customerId = getCustomerId();
|
|
20
15
|
const client = getApiClient();
|
|
21
|
-
const spinner = ora('正在获取广告系列列表...').start();
|
|
22
|
-
// 获取广告系列列表
|
|
23
16
|
const campaigns = await client.listCampaigns(customerId, {
|
|
24
17
|
status: options.status,
|
|
25
18
|
limit: parseInt(options.limit),
|
|
26
19
|
});
|
|
27
|
-
|
|
28
|
-
if (campaigns.length === 0) {
|
|
29
|
-
warn('未找到广告系列');
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
// 输出结果
|
|
33
|
-
if (options.json) {
|
|
34
|
-
console.log(JSON.stringify(campaigns, null, 2));
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
const table = new Table({
|
|
38
|
-
head: [
|
|
39
|
-
chalk.cyan('ID'),
|
|
40
|
-
chalk.cyan('名称'),
|
|
41
|
-
chalk.cyan('状态'),
|
|
42
|
-
chalk.cyan('类型'),
|
|
43
|
-
chalk.cyan('展示量'),
|
|
44
|
-
chalk.cyan('点击量'),
|
|
45
|
-
chalk.cyan('费用'),
|
|
46
|
-
],
|
|
47
|
-
colWidths: [12, 25, 10, 15, 12, 10, 15],
|
|
48
|
-
});
|
|
49
|
-
campaigns.forEach((campaign) => {
|
|
50
|
-
const cost = campaign.metrics?.cost_micros
|
|
51
|
-
? (campaign.metrics.cost_micros / 1000000).toFixed(2)
|
|
52
|
-
: '0.00';
|
|
53
|
-
table.push([
|
|
54
|
-
campaign.campaign?.id || 'N/A',
|
|
55
|
-
campaign.campaign?.name || '未命名',
|
|
56
|
-
campaign.campaign?.status || 'N/A',
|
|
57
|
-
campaign.campaign?.advertising_channel_type || 'N/A',
|
|
58
|
-
campaign.metrics?.impressions || 0,
|
|
59
|
-
campaign.metrics?.clicks || 0,
|
|
60
|
-
cost,
|
|
61
|
-
]);
|
|
62
|
-
});
|
|
63
|
-
console.log('\n' + table.toString() + '\n');
|
|
64
|
-
console.log(chalk.gray(`共 ${campaigns.length} 个广告系列\n`));
|
|
65
|
-
}
|
|
20
|
+
console.log(JSON.stringify(campaigns, null, 2));
|
|
66
21
|
}
|
|
67
22
|
catch (error) {
|
|
68
23
|
handleError(error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/commands/campaign/list.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/commands/campaign/list.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC;KAC3C,WAAW,CAAC,QAAQ,CAAC;KACrB,MAAM,CAAC,mBAAmB,EAAE,gCAAgC,CAAC;KAC7D,MAAM,CAAC,kBAAkB,EAAE,QAAQ,EAAE,IAAI,CAAC;KAC1C,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;IACxB,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,aAAa,EAAE,CAAC;QACnC,MAAM,MAAM,GAAG,YAAY,EAAE,CAAC;QAE9B,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,UAAU,EAAE;YACvD,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,KAAK,EAAE,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC;SAC/B,CAAC,CAAC;QAEH,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAClD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,WAAW,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC;AACH,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../src/commands/campaign/update.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../src/commands/campaign/update.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,eAAO,MAAM,aAAa,SA8BtB,CAAC"}
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
* Campaign Update Command - 更新广告系列
|
|
3
3
|
*/
|
|
4
4
|
import { Command } from 'commander';
|
|
5
|
-
import chalk from 'chalk';
|
|
6
|
-
import ora from 'ora';
|
|
7
5
|
import { getApiClient } from '../../lib/api-client.js';
|
|
8
6
|
import { handleError } from '../../utils/errors.js';
|
|
9
7
|
import { getCustomerId } from '../../utils/customer-id.js';
|
|
@@ -13,43 +11,28 @@ export const updateCommand = new Command('update')
|
|
|
13
11
|
.option('--status <status>', '状态 (ENABLED, PAUSED)')
|
|
14
12
|
.option('--name <name>', '新名称')
|
|
15
13
|
.option('--budget <amount>', '新每日预算(美元)')
|
|
16
|
-
.option('--json', '以 JSON 格式输出')
|
|
17
14
|
.action(async (options) => {
|
|
18
|
-
if (!options.status && !options.name && !options.budget) {
|
|
19
|
-
console.log(chalk.red('请至少指定一个要更新的字段: --status, --name, 或 --budget'));
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
const spinner = ora('更新广告系列...').start();
|
|
23
15
|
try {
|
|
16
|
+
if (!options.status && !options.name && !options.budget) {
|
|
17
|
+
console.log(JSON.stringify({
|
|
18
|
+
error: 'missing_fields',
|
|
19
|
+
message: '请至少指定一个要更新的字段: --status, --name, 或 --budget'
|
|
20
|
+
}, null, 2));
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
24
23
|
const customerId = getCustomerId();
|
|
25
24
|
const client = getApiClient();
|
|
26
25
|
const updateData = {};
|
|
27
|
-
if (options.status)
|
|
26
|
+
if (options.status)
|
|
28
27
|
updateData.status = options.status;
|
|
29
|
-
|
|
30
|
-
if (options.name) {
|
|
28
|
+
if (options.name)
|
|
31
29
|
updateData.name = options.name;
|
|
32
|
-
|
|
33
|
-
if (options.budget) {
|
|
30
|
+
if (options.budget)
|
|
34
31
|
updateData.budgetAmountMicros = Math.round(parseFloat(options.budget) * 1000000);
|
|
35
|
-
}
|
|
36
32
|
const result = await client.updateCampaign(customerId, options.campaignId, updateData);
|
|
37
|
-
|
|
38
|
-
if (options.json) {
|
|
39
|
-
console.log(JSON.stringify(result, null, 2));
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
console.log(chalk.green(`\n✅ 广告系列 ${options.campaignId} 已更新`));
|
|
43
|
-
if (options.status)
|
|
44
|
-
console.log(chalk.gray(`状态: ${options.status}`));
|
|
45
|
-
if (options.name)
|
|
46
|
-
console.log(chalk.gray(`名称: ${options.name}`));
|
|
47
|
-
if (options.budget)
|
|
48
|
-
console.log(chalk.gray(`预算: $${options.budget}/天`));
|
|
49
|
-
}
|
|
33
|
+
console.log(JSON.stringify(result, null, 2));
|
|
50
34
|
}
|
|
51
35
|
catch (error) {
|
|
52
|
-
spinner.fail('更新失败');
|
|
53
36
|
handleError(error);
|
|
54
37
|
}
|
|
55
38
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../../src/commands/campaign/update.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,
|
|
1
|
+
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../../src/commands/campaign/update.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,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M,GAAG,MAAM,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;QAEvF,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAC/C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,WAAW,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC;AACH,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/commands/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/commands/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,eAAO,MAAM,aAAa,SACC,CAAC"}
|
package/dist/commands/config.js
CHANGED
|
@@ -2,10 +2,7 @@
|
|
|
2
2
|
* Config Command - 配置管理
|
|
3
3
|
*/
|
|
4
4
|
import { Command } from 'commander';
|
|
5
|
-
import chalk from 'chalk';
|
|
6
5
|
import Conf from 'conf';
|
|
7
|
-
import Table from 'cli-table3';
|
|
8
|
-
import inquirer from 'inquirer';
|
|
9
6
|
const config = new Conf({ projectName: 'google-ads-cli' });
|
|
10
7
|
export const configCommand = new Command('config')
|
|
11
8
|
.description('管理 CLI 配置');
|
|
@@ -13,92 +10,39 @@ export const configCommand = new Command('config')
|
|
|
13
10
|
configCommand
|
|
14
11
|
.command('show')
|
|
15
12
|
.description('显示当前配置')
|
|
16
|
-
.
|
|
17
|
-
.action((options) => {
|
|
13
|
+
.action(() => {
|
|
18
14
|
const customerId = config.get('customerId');
|
|
19
15
|
const accountName = config.get('accountName');
|
|
20
16
|
const currency = config.get('currency');
|
|
21
17
|
const timezone = config.get('timezone');
|
|
22
18
|
const email = config.get('email');
|
|
23
19
|
const createdAt = config.get('createdAt');
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
created_at: createdAt,
|
|
37
|
-
config_path: config.path,
|
|
38
|
-
};
|
|
39
|
-
console.log(JSON.stringify(result, null, 2));
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
console.log(chalk.cyan.bold('\n📋 当前配置\n'));
|
|
43
|
-
const table = new Table({
|
|
44
|
-
chars: {
|
|
45
|
-
top: '─',
|
|
46
|
-
'top-mid': '┬',
|
|
47
|
-
'top-left': '┌',
|
|
48
|
-
'top-right': '┐',
|
|
49
|
-
bottom: '─',
|
|
50
|
-
'bottom-mid': '┴',
|
|
51
|
-
'bottom-left': '└',
|
|
52
|
-
'bottom-right': '┘',
|
|
53
|
-
left: '│',
|
|
54
|
-
'left-mid': '├',
|
|
55
|
-
mid: '─',
|
|
56
|
-
'mid-mid': '┼',
|
|
57
|
-
right: '│',
|
|
58
|
-
'right-mid': '┤',
|
|
59
|
-
middle: '│',
|
|
60
|
-
},
|
|
61
|
-
});
|
|
62
|
-
const formattedCustomerId = customerId.replace(/(\d{3})(\d{3})(\d{4})/, '$1-$2-$3');
|
|
63
|
-
table.push([chalk.gray('Customer ID'), chalk.white(formattedCustomerId)], [chalk.gray('账号名称'), chalk.white(accountName || 'N/A')], [chalk.gray('货币'), chalk.white(currency || 'N/A')], [chalk.gray('时区'), chalk.white(timezone || 'N/A')], [chalk.gray('邮箱'), chalk.white(email || 'N/A')], [chalk.gray('创建时间'), chalk.white(createdAt ? new Date(createdAt).toLocaleString() : 'N/A')]);
|
|
64
|
-
console.log(table.toString());
|
|
65
|
-
console.log(chalk.gray(`\n配置文件路径: ${config.path}\n`));
|
|
66
|
-
}
|
|
20
|
+
const linkedAt = config.get('linkedAt');
|
|
21
|
+
const result = {
|
|
22
|
+
customer_id: customerId || null,
|
|
23
|
+
account_name: accountName || null,
|
|
24
|
+
currency: currency || null,
|
|
25
|
+
timezone: timezone || null,
|
|
26
|
+
email: email || null,
|
|
27
|
+
created_at: createdAt || null,
|
|
28
|
+
linked_at: linkedAt || null,
|
|
29
|
+
config_path: config.path,
|
|
30
|
+
};
|
|
31
|
+
console.log(JSON.stringify(result, null, 2));
|
|
67
32
|
});
|
|
68
33
|
// config reset - 重置配置
|
|
69
34
|
configCommand
|
|
70
35
|
.command('reset')
|
|
71
36
|
.description('重置配置(删除所有已保存的配置)')
|
|
72
|
-
.
|
|
73
|
-
.action(async (options) => {
|
|
74
|
-
const customerId = config.get('customerId');
|
|
75
|
-
if (!customerId) {
|
|
76
|
-
console.log(chalk.yellow('\n⚠️ 当前没有配置需要重置\n'));
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
if (!options.force) {
|
|
80
|
-
const answers = await inquirer.prompt([
|
|
81
|
-
{
|
|
82
|
-
type: 'confirm',
|
|
83
|
-
name: 'confirm',
|
|
84
|
-
message: '确定要重置配置吗?这将删除所有已保存的账号信息。',
|
|
85
|
-
default: false,
|
|
86
|
-
},
|
|
87
|
-
]);
|
|
88
|
-
if (!answers.confirm) {
|
|
89
|
-
console.log(chalk.gray('\n已取消\n'));
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
37
|
+
.action(() => {
|
|
93
38
|
config.clear();
|
|
94
|
-
console.log(
|
|
95
|
-
console.log(chalk.gray('您可以重新运行: ') + chalk.cyan('google-ads account create\n'));
|
|
39
|
+
console.log(JSON.stringify({ success: true, message: '配置已重置' }, null, 2));
|
|
96
40
|
});
|
|
97
41
|
// config path - 显示配置文件路径
|
|
98
42
|
configCommand
|
|
99
43
|
.command('path')
|
|
100
44
|
.description('显示配置文件路径')
|
|
101
45
|
.action(() => {
|
|
102
|
-
console.log(config.path);
|
|
46
|
+
console.log(JSON.stringify({ path: config.path }, null, 2));
|
|
103
47
|
});
|
|
104
48
|
//# sourceMappingURL=config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/commands/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/commands/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,MAAM,MAAM,GAAG,IAAI,IAAI,CAAC,EAAE,WAAW,EAAE,gBAAgB,EAAE,CAAC,CAAC;AAE3D,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC;KAC/C,WAAW,CAAC,WAAW,CAAC,CAAC;AAE5B,uBAAuB;AACvB,aAAa;KACV,OAAO,CAAC,MAAM,CAAC;KACf,WAAW,CAAC,QAAQ,CAAC;KACrB,MAAM,CAAC,GAAG,EAAE;IACX,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,YAAY,CAAuB,CAAC;IAClE,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAC,aAAa,CAAuB,CAAC;IACpE,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,UAAU,CAAuB,CAAC;IAC9D,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,UAAU,CAAuB,CAAC;IAC9D,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,CAAuB,CAAC;IACxD,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,WAAW,CAAuB,CAAC;IAChE,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,UAAU,CAAuB,CAAC;IAE9D,MAAM,MAAM,GA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version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../../src/commands/keyword/add.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,eAAO,MAAM,UAAU,SA0BnB,CAAC"}
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
* Keyword Add Command - 添加关键词
|
|
3
3
|
*/
|
|
4
4
|
import { Command } from 'commander';
|
|
5
|
-
import chalk from 'chalk';
|
|
6
|
-
import ora from 'ora';
|
|
7
5
|
import { getApiClient } from '../../lib/api-client.js';
|
|
8
6
|
import { handleError } from '../../utils/errors.js';
|
|
9
7
|
import { getCustomerId } from '../../utils/customer-id.js';
|
|
@@ -12,36 +10,19 @@ export const addCommand = new Command('add')
|
|
|
12
10
|
.requiredOption('--ad-group-id <id>', '广告组 ID')
|
|
13
11
|
.requiredOption('-k, --keywords <keywords>', '关键词(逗号分隔)')
|
|
14
12
|
.option('--match-type <type>', '匹配类型 (BROAD, PHRASE, EXACT)', 'BROAD')
|
|
15
|
-
.option('--json', '以 JSON 格式输出')
|
|
16
13
|
.action(async (options) => {
|
|
17
|
-
const spinner = ora('添加关键词...').start();
|
|
18
14
|
try {
|
|
19
15
|
const customerId = getCustomerId();
|
|
20
16
|
const client = getApiClient();
|
|
21
|
-
// 解析关键词
|
|
22
17
|
const keywordTexts = options.keywords.split(',').map((k) => k.trim());
|
|
23
18
|
const keywords = keywordTexts.map((text) => ({
|
|
24
19
|
text,
|
|
25
20
|
matchType: options.matchType,
|
|
26
21
|
}));
|
|
27
22
|
const result = await client.addKeywords(customerId, options.adGroupId, keywords);
|
|
28
|
-
|
|
29
|
-
if (options.json) {
|
|
30
|
-
console.log(JSON.stringify(result, null, 2));
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
console.log(chalk.green(`\n✅ 已添加 ${keywordTexts.length} 个关键词`));
|
|
34
|
-
console.log(chalk.gray('匹配类型:'), chalk.white(options.matchType));
|
|
35
|
-
console.log(chalk.gray('\n关键词列表:'));
|
|
36
|
-
keywordTexts.forEach((text, index) => {
|
|
37
|
-
console.log(chalk.white(` ${index + 1}. ${text}`));
|
|
38
|
-
});
|
|
39
|
-
console.log(chalk.gray('\n💡 查看关键词:'));
|
|
40
|
-
console.log(chalk.cyan(` google-ads keyword list`));
|
|
41
|
-
}
|
|
23
|
+
console.log(JSON.stringify(result, null, 2));
|
|
42
24
|
}
|
|
43
25
|
catch (error) {
|
|
44
|
-
spinner.fail('添加失败');
|
|
45
26
|
handleError(error);
|
|
46
27
|
}
|
|
47
28
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add.js","sourceRoot":"","sources":["../../../src/commands/keyword/add.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,
|
|
1
|
+
{"version":3,"file":"add.js","sourceRoot":"","sources":["../../../src/commands/keyword/add.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,OAAO,CAAC,KAAK,CAAC;KACzC,WAAW,CAAC,OAAO,CAAC;KACpB,cAAc,CAAC,oBAAoB,EAAE,QAAQ,CAAC;KAC9C,cAAc,CAAC,2BAA2B,EAAE,WAAW,CAAC;KACxD,MAAM,CAAC,qBAAqB,EAAE,6BAA6B,EAAE,OAAO,CAAC;KACrE,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;IACxB,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,aAAa,EAAE,CAAC;QACnC,MAAM,MAAM,GAAG,YAAY,EAAE,CAAC;QAE9B,MAAM,YAAY,GAAG,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;QAC9E,MAAM,QAAQ,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,IAAY,EAAE,EAAE,CAAC,CAAC;YACnD,IAAI;YACJ,SAAS,EAAE,OAAO,CAAC,SAAS;SAC7B,CAAC,CAAC,CAAC;QAEJ,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,WAAW,CACrC,UAAU,EACV,OAAO,CAAC,SAAS,EACjB,QAAQ,CACT,CAAC;QAEF,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAC/C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,WAAW,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC;AACH,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../src/commands/keyword/delete.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../src/commands/keyword/delete.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,eAAO,MAAM,aAAa,SAmBtB,CAAC"}
|
|
@@ -2,9 +2,6 @@
|
|
|
2
2
|
* Keyword Delete Command - 删除关键词
|
|
3
3
|
*/
|
|
4
4
|
import { Command } from 'commander';
|
|
5
|
-
import chalk from 'chalk';
|
|
6
|
-
import ora from 'ora';
|
|
7
|
-
import inquirer from 'inquirer';
|
|
8
5
|
import { getApiClient } from '../../lib/api-client.js';
|
|
9
6
|
import { handleError } from '../../utils/errors.js';
|
|
10
7
|
import { getCustomerId } from '../../utils/customer-id.js';
|
|
@@ -12,36 +9,12 @@ export const deleteCommand = new Command('delete')
|
|
|
12
9
|
.description('删除关键词')
|
|
13
10
|
.requiredOption('--ad-group-id <id>', '广告组 ID')
|
|
14
11
|
.requiredOption('--criterion-id <id>', '关键词 Criterion ID')
|
|
15
|
-
.option('-y, --yes', '跳过确认')
|
|
16
|
-
.option('--json', '以 JSON 格式输出')
|
|
17
12
|
.action(async (options) => {
|
|
18
13
|
try {
|
|
19
14
|
const customerId = getCustomerId();
|
|
20
|
-
// 确认删除
|
|
21
|
-
if (!options.yes) {
|
|
22
|
-
const answer = await inquirer.prompt([
|
|
23
|
-
{
|
|
24
|
-
type: 'confirm',
|
|
25
|
-
name: 'confirm',
|
|
26
|
-
message: `确定要删除关键词 ${options.criterionId} 吗?`,
|
|
27
|
-
default: false,
|
|
28
|
-
},
|
|
29
|
-
]);
|
|
30
|
-
if (!answer.confirm) {
|
|
31
|
-
console.log(chalk.yellow('已取消'));
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
const spinner = ora('删除关键词...').start();
|
|
36
15
|
const client = getApiClient();
|
|
37
16
|
const result = await client.deleteKeyword(customerId, options.adGroupId, options.criterionId);
|
|
38
|
-
|
|
39
|
-
if (options.json) {
|
|
40
|
-
console.log(JSON.stringify(result, null, 2));
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
console.log(chalk.green(`\n✅ 关键词 ${options.criterionId} 已删除`));
|
|
44
|
-
}
|
|
17
|
+
console.log(JSON.stringify(result, null, 2));
|
|
45
18
|
}
|
|
46
19
|
catch (error) {
|
|
47
20
|
handleError(error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delete.js","sourceRoot":"","sources":["../../../src/commands/keyword/delete.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,
|
|
1
|
+
{"version":3,"file":"delete.js","sourceRoot":"","sources":["../../../src/commands/keyword/delete.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC;KAC/C,WAAW,CAAC,OAAO,CAAC;KACpB,cAAc,CAAC,oBAAoB,EAAE,QAAQ,CAAC;KAC9C,cAAc,CAAC,qBAAqB,EAAE,kBAAkB,CAAC;KACzD,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;IACxB,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,aAAa,EAAE,CAAC;QACnC,MAAM,MAAM,GAAG,YAAY,EAAE,CAAC;QAE9B,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,aAAa,CACvC,UAAU,EACV,OAAO,CAAC,SAAS,EACjB,OAAO,CAAC,WAAW,CACpB,CAAC;QAEF,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAC/C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,WAAW,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC;AACH,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/commands/keyword/list.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/commands/keyword/list.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,eAAO,MAAM,WAAW,SAoBpB,CAAC"}
|