adapty 0.8.4 → 0.8.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/bin/dev.js +2 -2
- package/bin/run.js +2 -2
- package/dist/commands/access-levels/create.js +1 -1
- package/dist/commands/access-levels/list.d.ts +1 -1
- package/dist/commands/apps/create.js +9 -6
- package/dist/commands/apps/list.d.ts +1 -1
- package/dist/commands/apps/update.js +7 -4
- package/dist/commands/asa/ad-groups/create.js +9 -7
- package/dist/commands/asa/ad-groups/get.js +3 -2
- package/dist/commands/asa/ad-groups/list.d.ts +1 -1
- package/dist/commands/asa/ad-groups/list.js +1 -1
- package/dist/commands/asa/ad-groups/update.js +22 -12
- package/dist/commands/asa/ads/create.js +7 -5
- package/dist/commands/asa/ads/get.js +3 -2
- package/dist/commands/asa/ads/list.d.ts +1 -1
- package/dist/commands/asa/ads/list.js +1 -1
- package/dist/commands/asa/ads/update.js +9 -5
- package/dist/commands/asa/apps/list.d.ts +1 -1
- package/dist/commands/asa/apps/list.js +1 -1
- package/dist/commands/asa/automations/create.js +9 -6
- package/dist/commands/asa/automations/get.js +3 -2
- package/dist/commands/asa/automations/list.d.ts +1 -1
- package/dist/commands/asa/automations/list.js +1 -1
- package/dist/commands/asa/automations/run.js +5 -3
- package/dist/commands/asa/automations/runs.d.ts +1 -1
- package/dist/commands/asa/automations/runs.js +4 -4
- package/dist/commands/asa/automations/update.js +17 -9
- package/dist/commands/asa/campaigns/bulk-create.js +31 -18
- package/dist/commands/asa/campaigns/bulk-list.js +7 -5
- package/dist/commands/asa/campaigns/bulk-status.js +3 -2
- package/dist/commands/asa/campaigns/create.js +10 -8
- package/dist/commands/asa/campaigns/get.js +3 -2
- package/dist/commands/asa/campaigns/list.d.ts +1 -1
- package/dist/commands/asa/campaigns/list.js +1 -1
- package/dist/commands/asa/campaigns/update.js +25 -15
- package/dist/commands/asa/competitors/summary.js +5 -5
- package/dist/commands/asa/connect.js +5 -3
- package/dist/commands/asa/creatives/list.d.ts +1 -1
- package/dist/commands/asa/creatives/list.js +1 -1
- package/dist/commands/asa/keywords/add.js +13 -10
- package/dist/commands/asa/keywords/list.d.ts +1 -1
- package/dist/commands/asa/keywords/list.js +1 -1
- package/dist/commands/asa/keywords/update.js +15 -10
- package/dist/commands/asa/metrics/index.d.ts +2 -2
- package/dist/commands/asa/metrics/index.js +22 -8
- package/dist/commands/asa/metrics/overview.js +3 -3
- package/dist/commands/asa/negative-keywords/add.js +10 -7
- package/dist/commands/asa/negative-keywords/list.d.ts +1 -1
- package/dist/commands/asa/negative-keywords/list.js +1 -1
- package/dist/commands/asa/orgs/list.d.ts +1 -1
- package/dist/commands/asa/orgs/list.js +1 -1
- package/dist/commands/asa/product-pages/list.d.ts +1 -1
- package/dist/commands/asa/product-pages/list.js +1 -1
- package/dist/commands/asa/product-pages/sync.js +1 -1
- package/dist/commands/asa/search-terms/list.d.ts +1 -1
- package/dist/commands/asa/search-terms/list.js +1 -1
- package/dist/commands/asa/whoami.js +7 -2
- package/dist/commands/auth/login.js +3 -1
- package/dist/commands/flows/config/get.js +2 -2
- package/dist/commands/flows/config/preview.d.ts +2 -2
- package/dist/commands/flows/config/preview.js +6 -4
- package/dist/commands/flows/config/update.js +5 -3
- package/dist/commands/flows/config/validate.js +5 -3
- package/dist/commands/flows/list.d.ts +1 -1
- package/dist/commands/flows/media/upload.js +1 -1
- package/dist/commands/flows/publish.js +5 -5
- package/dist/commands/paywalls/create.js +1 -1
- package/dist/commands/paywalls/list.d.ts +1 -1
- package/dist/commands/paywalls/placements.d.ts +2 -2
- package/dist/commands/paywalls/update.js +1 -1
- package/dist/commands/placements/create.js +17 -12
- package/dist/commands/placements/list.d.ts +1 -1
- package/dist/commands/placements/update.js +20 -15
- package/dist/commands/products/create.js +20 -13
- package/dist/commands/products/list.d.ts +1 -1
- package/dist/commands/products/update.js +1 -1
- package/dist/commands/segments/list.d.ts +1 -1
- package/dist/lib/api-client.d.ts +10 -6
- package/dist/lib/api-client.js +56 -35
- package/dist/lib/api-schemas.d.ts +56 -56
- package/dist/lib/app-url.js +2 -1
- package/dist/lib/asa-client.d.ts +13 -8
- package/dist/lib/asa-client.js +9 -4
- package/dist/lib/asa-flags.d.ts +19 -19
- package/dist/lib/asa-flags.js +38 -25
- package/dist/lib/asa-keyword-action.d.ts +10 -10
- package/dist/lib/asa-keyword-action.js +40 -25
- package/dist/lib/asa-schemas.d.ts +100 -80
- package/dist/lib/auth.js +2 -1
- package/dist/lib/client-from-config.d.ts +1 -1
- package/dist/lib/client-from-config.js +2 -1
- package/dist/lib/config.d.ts +2 -2
- package/dist/lib/confirm.d.ts +4 -4
- package/dist/lib/confirm.js +12 -7
- package/dist/lib/errors.d.ts +18 -18
- package/dist/lib/errors.js +12 -9
- package/dist/lib/flags.d.ts +3 -3
- package/dist/lib/flags.js +2 -1
- package/dist/lib/flow-help.js +11 -6
- package/dist/lib/output.js +23 -12
- package/dist/lib/preview.d.ts +5 -5
- package/dist/lib/preview.js +2 -1
- package/oclif.manifest.json +131 -131
- package/package.json +10 -8
package/README.md
CHANGED
package/bin/dev.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env -S node --loader ts-node/esm --disable-warning=ExperimentalWarning
|
|
2
2
|
|
|
3
|
-
import {execute} from '@oclif/core'
|
|
3
|
+
import { execute } from '@oclif/core';
|
|
4
4
|
|
|
5
|
-
await execute({development: true, dir: import.meta.url})
|
|
5
|
+
await execute({ development: true, dir: import.meta.url });
|
package/bin/run.js
CHANGED
|
@@ -11,7 +11,7 @@ export default class AccessLevelsCreate extends Command {
|
|
|
11
11
|
static flags = {
|
|
12
12
|
...appFlag,
|
|
13
13
|
'sdk-id': Flags.string({ description: 'Access level SDK identifier', required: true }),
|
|
14
|
-
title: Flags.string({ description: 'Access level title', required: true }),
|
|
14
|
+
'title': Flags.string({ description: 'Access level title', required: true }),
|
|
15
15
|
};
|
|
16
16
|
async run() {
|
|
17
17
|
const { flags } = await this.parse(AccessLevelsCreate);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
2
|
import type { AccessLevelDTO } from '../../lib/api-schemas.js';
|
|
3
|
-
import {
|
|
3
|
+
import type { PaginatedResponse } from '../../lib/flags.js';
|
|
4
4
|
export default class AccessLevelsList extends Command {
|
|
5
5
|
static description: string;
|
|
6
6
|
static enableJsonFlag: boolean;
|
|
@@ -11,13 +11,13 @@ export default class AppsCreate extends Command {
|
|
|
11
11
|
static flags = {
|
|
12
12
|
'apple-bundle-id': Flags.string({ description: 'Apple bundle ID (required with --platform ios)' }),
|
|
13
13
|
'google-bundle-id': Flags.string({ description: 'Google bundle ID (required with --platform android)' }),
|
|
14
|
-
platform: Flags.string({
|
|
14
|
+
'platform': Flags.string({
|
|
15
15
|
description: 'Platform (ios, android). Repeat for multiple.',
|
|
16
16
|
multiple: true,
|
|
17
17
|
options: ['ios', 'android'],
|
|
18
18
|
required: true,
|
|
19
19
|
}),
|
|
20
|
-
title: Flags.string({ description: 'App title', required: true }),
|
|
20
|
+
'title': Flags.string({ description: 'App title', required: true }),
|
|
21
21
|
};
|
|
22
22
|
async run() {
|
|
23
23
|
const { flags } = await this.parse(AppsCreate);
|
|
@@ -32,18 +32,21 @@ export default class AppsCreate extends Command {
|
|
|
32
32
|
platforms: flags.platform,
|
|
33
33
|
title: flags.title,
|
|
34
34
|
};
|
|
35
|
-
if (flags['apple-bundle-id'])
|
|
35
|
+
if (flags['apple-bundle-id']) {
|
|
36
36
|
body.apple_bundle_id = flags['apple-bundle-id'];
|
|
37
|
-
|
|
37
|
+
}
|
|
38
|
+
if (flags['google-bundle-id']) {
|
|
38
39
|
body.google_bundle_id = flags['google-bundle-id'];
|
|
40
|
+
}
|
|
39
41
|
const result = await client.post('/apps', body);
|
|
40
42
|
this.log('App created!');
|
|
41
43
|
printResponse(result, this.log.bind(this));
|
|
42
44
|
try {
|
|
43
45
|
const accessLevels = await client.get(`/apps/${result.id}/access-levels`);
|
|
44
|
-
|
|
46
|
+
const [defaultAccessLevel] = accessLevels.items ?? [];
|
|
47
|
+
if (defaultAccessLevel) {
|
|
45
48
|
this.log('\nDefault access level:');
|
|
46
|
-
printResponse(
|
|
49
|
+
printResponse(defaultAccessLevel, this.log.bind(this));
|
|
47
50
|
}
|
|
48
51
|
}
|
|
49
52
|
catch {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
2
|
import type { AppSummaryDTO } from '../../lib/api-schemas.js';
|
|
3
|
-
import {
|
|
3
|
+
import type { PaginatedResponse } from '../../lib/flags.js';
|
|
4
4
|
export default class AppsList extends Command {
|
|
5
5
|
static description: string;
|
|
6
6
|
static enableJsonFlag: boolean;
|
|
@@ -12,7 +12,7 @@ export default class AppsUpdate extends Command {
|
|
|
12
12
|
static flags = {
|
|
13
13
|
'apple-bundle-id': Flags.string({ description: 'Apple bundle ID' }),
|
|
14
14
|
'google-bundle-id': Flags.string({ description: 'Google bundle ID' }),
|
|
15
|
-
title: Flags.string({ description: 'App title' }),
|
|
15
|
+
'title': Flags.string({ description: 'App title' }),
|
|
16
16
|
};
|
|
17
17
|
async run() {
|
|
18
18
|
const { args, flags } = await this.parse(AppsUpdate);
|
|
@@ -24,12 +24,15 @@ export default class AppsUpdate extends Command {
|
|
|
24
24
|
}
|
|
25
25
|
const client = await createAuthenticatedClient(this.config);
|
|
26
26
|
const body = {};
|
|
27
|
-
if (flags.title)
|
|
27
|
+
if (flags.title) {
|
|
28
28
|
body.title = flags.title;
|
|
29
|
-
|
|
29
|
+
}
|
|
30
|
+
if (flags['apple-bundle-id']) {
|
|
30
31
|
body.apple_bundle_id = flags['apple-bundle-id'];
|
|
31
|
-
|
|
32
|
+
}
|
|
33
|
+
if (flags['google-bundle-id']) {
|
|
32
34
|
body.google_bundle_id = flags['google-bundle-id'];
|
|
35
|
+
}
|
|
33
36
|
const result = await client.put(`/apps/${args.app_id}`, body);
|
|
34
37
|
this.log('App updated!');
|
|
35
38
|
printResponse(result, this.log.bind(this));
|
|
@@ -18,21 +18,22 @@ export default class AsaAdGroupsCreate extends Command {
|
|
|
18
18
|
...pricingModelFlag,
|
|
19
19
|
...confirmFlags,
|
|
20
20
|
...idempotencyFlags,
|
|
21
|
-
automated: Flags.boolean({
|
|
21
|
+
'automated': Flags.boolean({
|
|
22
22
|
description: 'Create the automated ad group a Max Conversions campaign needs (no bid, no schedule, always ENABLED)',
|
|
23
23
|
exclusive: ['automated-keywords'],
|
|
24
24
|
}),
|
|
25
25
|
'automated-keywords': Flags.boolean({ allowNo: true, description: 'Let Apple add keywords automatically' }),
|
|
26
|
-
campaign: Flags.string({ description: 'Campaign ID (UUID)', required: true }),
|
|
26
|
+
'campaign': Flags.string({ description: 'Campaign ID (UUID)', required: true }),
|
|
27
27
|
'cpa-goal': moneyFlag('CPA goal'),
|
|
28
28
|
'default-bid': moneyFlag('Default bid; required unless --automated is set'),
|
|
29
|
-
name: Flags.string({ description: 'Ad group name', required: true }),
|
|
30
|
-
status: Flags.string({ description: 'Initial status', options: ['ENABLED', 'PAUSED'] }),
|
|
29
|
+
'name': Flags.string({ description: 'Ad group name', required: true }),
|
|
30
|
+
'status': Flags.string({ description: 'Initial status', options: ['ENABLED', 'PAUSED'] }),
|
|
31
31
|
};
|
|
32
32
|
async run() {
|
|
33
33
|
const { flags } = await this.parse(AsaAdGroupsCreate);
|
|
34
|
-
if (!isValidUuid(flags.campaign))
|
|
34
|
+
if (!isValidUuid(flags.campaign)) {
|
|
35
35
|
this.error('Invalid campaign ID format.', { exit: 2 });
|
|
36
|
+
}
|
|
36
37
|
if (!flags.automated && flags['default-bid'] === undefined) {
|
|
37
38
|
this.error('--default-bid is required unless --automated is set.', { exit: 2 });
|
|
38
39
|
}
|
|
@@ -55,14 +56,15 @@ export default class AsaAdGroupsCreate extends Command {
|
|
|
55
56
|
status: flags.status,
|
|
56
57
|
};
|
|
57
58
|
await confirmMutation(this, { body, method: 'POST', path: '/ad-groups/', summary: `Create ad group ${flags.name}` }, flags.yes);
|
|
58
|
-
const client = await createAsaClient(this
|
|
59
|
+
const client = await createAsaClient(this);
|
|
59
60
|
const { replayed, result } = await asaWrite(client, 'post', '/ad-groups', {
|
|
60
61
|
body,
|
|
61
62
|
idempotencyKey: flags['idempotency-key'],
|
|
62
63
|
});
|
|
63
64
|
noteReplay(replayed, this.log.bind(this));
|
|
64
|
-
if (result.ad_group && !replayed)
|
|
65
|
+
if (result.ad_group && !replayed) {
|
|
65
66
|
this.log('Ad group created!');
|
|
67
|
+
}
|
|
66
68
|
printResponse(result, this.log.bind(this));
|
|
67
69
|
return result;
|
|
68
70
|
}
|
|
@@ -11,9 +11,10 @@ export default class AsaAdGroupsGet extends Command {
|
|
|
11
11
|
static examples = ['<%= config.bin %> asa ad-groups get 550e8400-e29b-41d4-a716-446655440000'];
|
|
12
12
|
async run() {
|
|
13
13
|
const { args } = await this.parse(AsaAdGroupsGet);
|
|
14
|
-
if (!isValidUuid(args.ad_group_id))
|
|
14
|
+
if (!isValidUuid(args.ad_group_id)) {
|
|
15
15
|
this.error('Invalid ad group ID format.', { exit: 2 });
|
|
16
|
-
|
|
16
|
+
}
|
|
17
|
+
const client = await createAsaClient(this);
|
|
17
18
|
const result = await client.get(`/ad-groups/${args.ad_group_id}`);
|
|
18
19
|
printResponse(result, this.log.bind(this));
|
|
19
20
|
return result;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
2
|
import type { AsaAdGroupDTO } from '../../../lib/asa-schemas.js';
|
|
3
|
-
import {
|
|
3
|
+
import type { PaginatedResponse } from '../../../lib/flags.js';
|
|
4
4
|
export default class AsaAdGroupsList extends Command {
|
|
5
5
|
static description: string;
|
|
6
6
|
static enableJsonFlag: boolean;
|
|
@@ -13,7 +13,7 @@ export default class AsaAdGroupsList extends Command {
|
|
|
13
13
|
static flags = { ...asaPaginationFlags, ...campaignScopeFlags, ...statusFilter(['ENABLED', 'PAUSED']) };
|
|
14
14
|
async run() {
|
|
15
15
|
const { flags } = await this.parse(AsaAdGroupsList);
|
|
16
|
-
const client = await createAsaClient(this
|
|
16
|
+
const client = await createAsaClient(this);
|
|
17
17
|
const result = await client.get('/ad-groups', {
|
|
18
18
|
...paginationParams(flags),
|
|
19
19
|
...scopeParams(flags),
|
|
@@ -22,40 +22,50 @@ export default class AsaAdGroupsUpdate extends Command {
|
|
|
22
22
|
'automated-keywords': Flags.boolean({ allowNo: true, description: 'Let Apple add keywords automatically' }),
|
|
23
23
|
'cpa-goal': moneyFlag('CPA goal'),
|
|
24
24
|
'default-bid': moneyFlag('Default bid'),
|
|
25
|
-
name: Flags.string({ description: 'Ad group name' }),
|
|
26
|
-
status: Flags.string({ description: 'Ad group status', options: ['ENABLED', 'PAUSED'] }),
|
|
25
|
+
'name': Flags.string({ description: 'Ad group name' }),
|
|
26
|
+
'status': Flags.string({ description: 'Ad group status', options: ['ENABLED', 'PAUSED'] }),
|
|
27
27
|
};
|
|
28
28
|
async run() {
|
|
29
29
|
const { args, flags } = await this.parse(AsaAdGroupsUpdate);
|
|
30
|
-
if (!isValidUuid(args.ad_group_id))
|
|
30
|
+
if (!isValidUuid(args.ad_group_id)) {
|
|
31
31
|
this.error('Invalid ad group ID format.', { exit: 2 });
|
|
32
|
+
}
|
|
32
33
|
const body = {};
|
|
33
|
-
if (flags.name !== undefined)
|
|
34
|
+
if (flags.name !== undefined) {
|
|
34
35
|
body.name = flags.name;
|
|
35
|
-
|
|
36
|
+
}
|
|
37
|
+
if (flags.status !== undefined) {
|
|
36
38
|
body.status = flags.status;
|
|
37
|
-
|
|
39
|
+
}
|
|
40
|
+
if (flags['default-bid'] !== undefined) {
|
|
38
41
|
body.default_bid_amount = money(flags['default-bid'], flags.currency);
|
|
39
|
-
|
|
42
|
+
}
|
|
43
|
+
if (flags['cpa-goal'] !== undefined) {
|
|
40
44
|
body.cpa_goal = money(flags['cpa-goal'], flags.currency);
|
|
41
|
-
|
|
45
|
+
}
|
|
46
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- FIXME if you see this
|
|
47
|
+
if (flags['automated-keywords'] !== undefined) {
|
|
42
48
|
body.automated_keywords_opt_in = flags['automated-keywords'];
|
|
43
|
-
|
|
49
|
+
}
|
|
50
|
+
if (flags['start-time'] !== undefined) {
|
|
44
51
|
body.start_time = startOfDayUtc(flags['start-time']);
|
|
45
|
-
|
|
52
|
+
}
|
|
53
|
+
if (flags['end-time'] !== undefined) {
|
|
46
54
|
body.end_time = startOfDayUtc(flags['end-time']);
|
|
55
|
+
}
|
|
47
56
|
if (Object.keys(body).length === 0) {
|
|
48
57
|
this.error('Nothing to change. Pass at least one field, e.g. --status PAUSED.', { exit: 2 });
|
|
49
58
|
}
|
|
50
59
|
await confirmMutation(this, { body, method: 'PUT', path: `/ad-groups/${args.ad_group_id}/`, summary: 'Update ad group' }, flags.yes);
|
|
51
|
-
const client = await createAsaClient(this
|
|
60
|
+
const client = await createAsaClient(this);
|
|
52
61
|
const { replayed, result } = await asaWrite(client, 'put', `/ad-groups/${args.ad_group_id}`, {
|
|
53
62
|
body,
|
|
54
63
|
idempotencyKey: flags['idempotency-key'],
|
|
55
64
|
});
|
|
56
65
|
noteReplay(replayed, this.log.bind(this));
|
|
57
|
-
if (result.ad_group && !replayed)
|
|
66
|
+
if (result.ad_group && !replayed) {
|
|
58
67
|
this.log('Ad group updated!');
|
|
68
|
+
}
|
|
59
69
|
printResponse(result, this.log.bind(this));
|
|
60
70
|
return result;
|
|
61
71
|
}
|
|
@@ -13,13 +13,14 @@ export default class AsaAdsCreate extends Command {
|
|
|
13
13
|
...idempotencyFlags,
|
|
14
14
|
'ad-group': Flags.string({ description: 'Ad group ID (UUID) — the campaign is resolved from it', required: true }),
|
|
15
15
|
'creative-id': Flags.integer({ description: 'Apple creative ID from a product page or the default set', required: true }),
|
|
16
|
-
name: Flags.string({ description: 'Ad name', required: true }),
|
|
17
|
-
status: Flags.string({ description: 'Initial status', options: ['ENABLED', 'PAUSED'] }),
|
|
16
|
+
'name': Flags.string({ description: 'Ad name', required: true }),
|
|
17
|
+
'status': Flags.string({ description: 'Initial status', options: ['ENABLED', 'PAUSED'] }),
|
|
18
18
|
};
|
|
19
19
|
async run() {
|
|
20
20
|
const { flags } = await this.parse(AsaAdsCreate);
|
|
21
|
-
if (!isValidUuid(flags['ad-group']))
|
|
21
|
+
if (!isValidUuid(flags['ad-group'])) {
|
|
22
22
|
this.error('Invalid ad group ID format.', { exit: 2 });
|
|
23
|
+
}
|
|
23
24
|
const body = {
|
|
24
25
|
ad_group_id: flags['ad-group'],
|
|
25
26
|
creative_id: flags['creative-id'],
|
|
@@ -27,14 +28,15 @@ export default class AsaAdsCreate extends Command {
|
|
|
27
28
|
...(flags.status === undefined ? {} : { status: flags.status }),
|
|
28
29
|
};
|
|
29
30
|
await confirmMutation(this, { body, method: 'POST', path: '/ads/', summary: `Create ad ${flags.name}` }, flags.yes);
|
|
30
|
-
const client = await createAsaClient(this
|
|
31
|
+
const client = await createAsaClient(this);
|
|
31
32
|
const { replayed, result } = await asaWrite(client, 'post', '/ads', {
|
|
32
33
|
body,
|
|
33
34
|
idempotencyKey: flags['idempotency-key'],
|
|
34
35
|
});
|
|
35
36
|
noteReplay(replayed, this.log.bind(this));
|
|
36
|
-
if (result.ad && !replayed)
|
|
37
|
+
if (result.ad && !replayed) {
|
|
37
38
|
this.log('Ad created!');
|
|
39
|
+
}
|
|
38
40
|
printResponse(result, this.log.bind(this));
|
|
39
41
|
return result;
|
|
40
42
|
}
|
|
@@ -11,9 +11,10 @@ export default class AsaAdsGet extends Command {
|
|
|
11
11
|
static examples = ['<%= config.bin %> asa ads get 550e8400-e29b-41d4-a716-446655440000'];
|
|
12
12
|
async run() {
|
|
13
13
|
const { args } = await this.parse(AsaAdsGet);
|
|
14
|
-
if (!isValidUuid(args.ad_id))
|
|
14
|
+
if (!isValidUuid(args.ad_id)) {
|
|
15
15
|
this.error('Invalid ad ID format.', { exit: 2 });
|
|
16
|
-
|
|
16
|
+
}
|
|
17
|
+
const client = await createAsaClient(this);
|
|
17
18
|
const result = await client.get(`/ads/${args.ad_id}`);
|
|
18
19
|
printResponse(result, this.log.bind(this));
|
|
19
20
|
return result;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
2
|
import type { AsaAdDTO } from '../../../lib/asa-schemas.js';
|
|
3
|
-
import {
|
|
3
|
+
import type { PaginatedResponse } from '../../../lib/flags.js';
|
|
4
4
|
export default class AsaAdsList extends Command {
|
|
5
5
|
static description: string;
|
|
6
6
|
static enableJsonFlag: boolean;
|
|
@@ -13,7 +13,7 @@ export default class AsaAdsList extends Command {
|
|
|
13
13
|
static flags = { ...asaPaginationFlags, ...adScopeFlags, ...statusFilter(['ENABLED', 'PAUSED']) };
|
|
14
14
|
async run() {
|
|
15
15
|
const { flags } = await this.parse(AsaAdsList);
|
|
16
|
-
const client = await createAsaClient(this
|
|
16
|
+
const client = await createAsaClient(this);
|
|
17
17
|
const result = await client.get('/ads', {
|
|
18
18
|
...paginationParams(flags),
|
|
19
19
|
...scopeParams(flags),
|
|
@@ -19,25 +19,29 @@ export default class AsaAdsUpdate extends Command {
|
|
|
19
19
|
};
|
|
20
20
|
async run() {
|
|
21
21
|
const { args, flags } = await this.parse(AsaAdsUpdate);
|
|
22
|
-
if (!isValidUuid(args.ad_id))
|
|
22
|
+
if (!isValidUuid(args.ad_id)) {
|
|
23
23
|
this.error('Invalid ad ID format.', { exit: 2 });
|
|
24
|
+
}
|
|
24
25
|
const body = {};
|
|
25
|
-
if (flags.name !== undefined)
|
|
26
|
+
if (flags.name !== undefined) {
|
|
26
27
|
body.name = flags.name;
|
|
27
|
-
|
|
28
|
+
}
|
|
29
|
+
if (flags.status !== undefined) {
|
|
28
30
|
body.status = flags.status;
|
|
31
|
+
}
|
|
29
32
|
if (Object.keys(body).length === 0) {
|
|
30
33
|
this.error('Nothing to change. Pass --name or --status.', { exit: 2 });
|
|
31
34
|
}
|
|
32
35
|
await confirmMutation(this, { body, method: 'PUT', path: `/ads/${args.ad_id}/`, summary: 'Update ad' }, flags.yes);
|
|
33
|
-
const client = await createAsaClient(this
|
|
36
|
+
const client = await createAsaClient(this);
|
|
34
37
|
const { replayed, result } = await asaWrite(client, 'put', `/ads/${args.ad_id}`, {
|
|
35
38
|
body,
|
|
36
39
|
idempotencyKey: flags['idempotency-key'],
|
|
37
40
|
});
|
|
38
41
|
noteReplay(replayed, this.log.bind(this));
|
|
39
|
-
if (result.ad && !replayed)
|
|
42
|
+
if (result.ad && !replayed) {
|
|
40
43
|
this.log('Ad updated!');
|
|
44
|
+
}
|
|
41
45
|
printResponse(result, this.log.bind(this));
|
|
42
46
|
return result;
|
|
43
47
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
2
|
import type { AsaAppDTO } from '../../../lib/asa-schemas.js';
|
|
3
|
-
import {
|
|
3
|
+
import type { PaginatedResponse } from '../../../lib/flags.js';
|
|
4
4
|
export default class AsaAppsList extends Command {
|
|
5
5
|
static description: string;
|
|
6
6
|
static enableJsonFlag: boolean;
|
|
@@ -10,7 +10,7 @@ export default class AsaAppsList extends Command {
|
|
|
10
10
|
static flags = { ...asaPaginationFlags };
|
|
11
11
|
async run() {
|
|
12
12
|
const { flags } = await this.parse(AsaAppsList);
|
|
13
|
-
const client = await createAsaClient(this
|
|
13
|
+
const client = await createAsaClient(this);
|
|
14
14
|
const result = await client.get('/apps', paginationParams(flags));
|
|
15
15
|
printList(result.data, this.log.bind(this), result.meta.pagination);
|
|
16
16
|
return result;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Command, Flags } from '@oclif/core';
|
|
2
1
|
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { Command, Flags } from '@oclif/core';
|
|
3
3
|
import { asaWrite, createAsaClient, noteReplay } from '../../../lib/asa-client.js';
|
|
4
4
|
import { addKeywordActionFlags, idempotencyFlags } from '../../../lib/asa-flags.js';
|
|
5
5
|
import { hasAddKeywordActionFlags, rebuildAddKeywordAction, requireSingleAction, } from '../../../lib/asa-keyword-action.js';
|
|
@@ -18,18 +18,19 @@ export default class AsaAutomationsCreate extends Command {
|
|
|
18
18
|
...addKeywordActionFlags,
|
|
19
19
|
...confirmFlags,
|
|
20
20
|
...idempotencyFlags,
|
|
21
|
-
file: Flags.string({ description: 'JSON file with the rule body, or - to read stdin', required: true }),
|
|
21
|
+
'file': Flags.string({ description: 'JSON file with the rule body, or - to read stdin', required: true }),
|
|
22
22
|
'run-now': Flags.boolean({ description: 'Queue the first run right after the rule is stored' }),
|
|
23
23
|
};
|
|
24
24
|
async run() {
|
|
25
25
|
const { flags } = await this.parse(AsaAutomationsCreate);
|
|
26
26
|
const body = await this.readRule(flags.file);
|
|
27
|
-
if (flags['run-now'])
|
|
27
|
+
if (flags['run-now']) {
|
|
28
28
|
body.run_immediately = true;
|
|
29
|
+
}
|
|
29
30
|
this.applyActionFlags(body, flags);
|
|
30
31
|
const summary = flags['run-now'] ? 'Create automation rule and run it immediately' : 'Create automation rule';
|
|
31
32
|
await confirmMutation(this, { body, method: 'POST', path: '/automations/', summary }, flags.yes);
|
|
32
|
-
const client = await createAsaClient(this
|
|
33
|
+
const client = await createAsaClient(this);
|
|
33
34
|
const { replayed, result } = await asaWrite(client, 'post', '/automations', {
|
|
34
35
|
body,
|
|
35
36
|
idempotencyKey: flags['idempotency-key'],
|
|
@@ -44,8 +45,9 @@ export default class AsaAutomationsCreate extends Command {
|
|
|
44
45
|
applyActionFlags(body, flags) {
|
|
45
46
|
try {
|
|
46
47
|
requireSingleAction(body.actions);
|
|
47
|
-
if (!hasAddKeywordActionFlags(flags))
|
|
48
|
+
if (!hasAddKeywordActionFlags(flags)) {
|
|
48
49
|
return;
|
|
50
|
+
}
|
|
49
51
|
body.actions = rebuildAddKeywordAction(body.actions, body.operate_with, flags);
|
|
50
52
|
}
|
|
51
53
|
catch (error) {
|
|
@@ -69,8 +71,9 @@ export default class AsaAutomationsCreate extends Command {
|
|
|
69
71
|
}
|
|
70
72
|
async readStdin() {
|
|
71
73
|
const chunks = [];
|
|
72
|
-
for await (const chunk of process.stdin)
|
|
74
|
+
for await (const chunk of process.stdin) {
|
|
73
75
|
chunks.push(chunk);
|
|
76
|
+
}
|
|
74
77
|
return Buffer.concat(chunks).toString('utf8');
|
|
75
78
|
}
|
|
76
79
|
}
|
|
@@ -11,9 +11,10 @@ export default class AsaAutomationsGet extends Command {
|
|
|
11
11
|
static examples = ['<%= config.bin %> asa automations get 550e8400-e29b-41d4-a716-446655440000'];
|
|
12
12
|
async run() {
|
|
13
13
|
const { args } = await this.parse(AsaAutomationsGet);
|
|
14
|
-
if (!isValidUuid(args.automation_id))
|
|
14
|
+
if (!isValidUuid(args.automation_id)) {
|
|
15
15
|
this.error('Invalid automation ID format.', { exit: 2 });
|
|
16
|
-
|
|
16
|
+
}
|
|
17
|
+
const client = await createAsaClient(this);
|
|
17
18
|
const result = await client.get(`/automations/${args.automation_id}`);
|
|
18
19
|
printResponse(result, this.log.bind(this));
|
|
19
20
|
return result;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
2
|
import type { AsaAutomationDTO } from '../../../lib/asa-schemas.js';
|
|
3
|
-
import {
|
|
3
|
+
import type { PaginatedResponse } from '../../../lib/flags.js';
|
|
4
4
|
export default class AsaAutomationsList extends Command {
|
|
5
5
|
static description: string;
|
|
6
6
|
static enableJsonFlag: boolean;
|
|
@@ -10,7 +10,7 @@ export default class AsaAutomationsList extends Command {
|
|
|
10
10
|
static flags = { ...asaPaginationFlags };
|
|
11
11
|
async run() {
|
|
12
12
|
const { flags } = await this.parse(AsaAutomationsList);
|
|
13
|
-
const client = await createAsaClient(this
|
|
13
|
+
const client = await createAsaClient(this);
|
|
14
14
|
const result = await client.get('/automations', paginationParams(flags));
|
|
15
15
|
printList(result.data, this.log.bind(this), result.meta.pagination);
|
|
16
16
|
return result;
|
|
@@ -20,8 +20,9 @@ export default class AsaAutomationsRun extends Command {
|
|
|
20
20
|
};
|
|
21
21
|
async run() {
|
|
22
22
|
const { args, flags } = await this.parse(AsaAutomationsRun);
|
|
23
|
-
if (!isValidUuid(args.automation_id))
|
|
23
|
+
if (!isValidUuid(args.automation_id)) {
|
|
24
24
|
this.error('Invalid automation ID format.', { exit: 2 });
|
|
25
|
+
}
|
|
25
26
|
if (!flags['dry-run']) {
|
|
26
27
|
await confirmMutation(this, {
|
|
27
28
|
method: 'POST',
|
|
@@ -29,11 +30,12 @@ export default class AsaAutomationsRun extends Command {
|
|
|
29
30
|
summary: 'Run the rule for real — it applies its actions to Apple',
|
|
30
31
|
}, flags.yes);
|
|
31
32
|
}
|
|
32
|
-
const client = await createAsaClient(this
|
|
33
|
+
const client = await createAsaClient(this);
|
|
33
34
|
const { replayed, result } = await asaWrite(client, 'post', `/automations/${args.automation_id}/run`, { idempotencyKey: flags['idempotency-key'], params: flags['dry-run'] ? { dry_run: 'true' } : undefined });
|
|
34
35
|
noteReplay(replayed, this.log.bind(this));
|
|
35
|
-
if (!replayed)
|
|
36
|
+
if (!replayed) {
|
|
36
37
|
this.log(flags['dry-run'] ? 'Dry run queued.' : 'Run queued.');
|
|
38
|
+
}
|
|
37
39
|
this.log(`Run ID: ${result.run_id ?? 'unknown'}`);
|
|
38
40
|
this.log(`Follow it with: ${this.config.bin} asa automations runs ${args.automation_id}`);
|
|
39
41
|
return result;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
2
|
import type { AsaAutomationRunDTO } from '../../../lib/asa-schemas.js';
|
|
3
|
-
import {
|
|
3
|
+
import type { PaginatedResponse } from '../../../lib/flags.js';
|
|
4
4
|
export default class AsaAutomationsRuns extends Command {
|
|
5
5
|
static args: {
|
|
6
6
|
automation_id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Args, Command } from '@oclif/core';
|
|
2
2
|
import { createAsaClient } from '../../../lib/asa-client.js';
|
|
3
3
|
import { asaPaginationFlags } from '../../../lib/asa-flags.js';
|
|
4
|
-
import { isValidUuid } from '../../../lib/flags.js';
|
|
5
|
-
import { paginationParams } from '../../../lib/flags.js';
|
|
4
|
+
import { isValidUuid, paginationParams } from '../../../lib/flags.js';
|
|
6
5
|
import { printList } from '../../../lib/output.js';
|
|
7
6
|
export default class AsaAutomationsRuns extends Command {
|
|
8
7
|
static args = {
|
|
@@ -14,9 +13,10 @@ export default class AsaAutomationsRuns extends Command {
|
|
|
14
13
|
static flags = { ...asaPaginationFlags };
|
|
15
14
|
async run() {
|
|
16
15
|
const { args, flags } = await this.parse(AsaAutomationsRuns);
|
|
17
|
-
if (!isValidUuid(args.automation_id))
|
|
16
|
+
if (!isValidUuid(args.automation_id)) {
|
|
18
17
|
this.error('Invalid automation ID format.', { exit: 2 });
|
|
19
|
-
|
|
18
|
+
}
|
|
19
|
+
const client = await createAsaClient(this);
|
|
20
20
|
const result = await client.get(`/automations/${args.automation_id}/runs`, paginationParams(flags));
|
|
21
21
|
printList(result.data, this.log.bind(this), result.meta.pagination);
|
|
22
22
|
return result;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Args, Command, Flags } from '@oclif/core';
|
|
2
1
|
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { Args, Command, Flags } from '@oclif/core';
|
|
3
3
|
import { asaWrite, createAsaClient, noteReplay } from '../../../lib/asa-client.js';
|
|
4
4
|
import { addKeywordActionFlags, idempotencyFlags } from '../../../lib/asa-flags.js';
|
|
5
5
|
import { hasAddKeywordActionFlags, rebuildAddKeywordAction, } from '../../../lib/asa-keyword-action.js';
|
|
@@ -28,15 +28,19 @@ export default class AsaAutomationsUpdate extends Command {
|
|
|
28
28
|
};
|
|
29
29
|
async run() {
|
|
30
30
|
const { args, flags } = await this.parse(AsaAutomationsUpdate);
|
|
31
|
-
if (!isValidUuid(args.automation_id))
|
|
31
|
+
if (!isValidUuid(args.automation_id)) {
|
|
32
32
|
this.error('Invalid automation ID format.', { exit: 2 });
|
|
33
|
+
}
|
|
33
34
|
const body = flags.file ? await this.readRule(flags.file) : {};
|
|
34
|
-
if (flags.name !== undefined)
|
|
35
|
+
if (flags.name !== undefined) {
|
|
35
36
|
body.name = flags.name;
|
|
36
|
-
|
|
37
|
+
}
|
|
38
|
+
if (flags.start) {
|
|
37
39
|
body.status = 1;
|
|
38
|
-
|
|
40
|
+
}
|
|
41
|
+
if (flags.stop) {
|
|
39
42
|
body.status = 0;
|
|
43
|
+
}
|
|
40
44
|
const actionFlags = hasAddKeywordActionFlags(flags);
|
|
41
45
|
if (Object.keys(body).length === 0 && !actionFlags) {
|
|
42
46
|
this.error('Nothing to change. Pass --stop, --start, --name, --file or an action flag.', { exit: 2 });
|
|
@@ -44,14 +48,16 @@ export default class AsaAutomationsUpdate extends Command {
|
|
|
44
48
|
if ('internal_id' in body) {
|
|
45
49
|
this.error('Remove internal_id from the file: the rule ID comes from the command line.', { exit: 2 });
|
|
46
50
|
}
|
|
47
|
-
const client = await createAsaClient(this
|
|
48
|
-
if (actionFlags)
|
|
51
|
+
const client = await createAsaClient(this);
|
|
52
|
+
if (actionFlags) {
|
|
49
53
|
await this.rebuildAction(client, args.automation_id, body, flags);
|
|
54
|
+
}
|
|
50
55
|
await confirmMutation(this, { body, method: 'PUT', path: `/automations/${args.automation_id}/`, summary: 'Update automation rule' }, flags.yes);
|
|
51
56
|
const { replayed, result } = await asaWrite(client, 'put', `/automations/${args.automation_id}`, { body, idempotencyKey: flags['idempotency-key'] });
|
|
52
57
|
noteReplay(replayed, this.log.bind(this));
|
|
53
|
-
if (result.automation && !replayed)
|
|
58
|
+
if (result.automation && !replayed) {
|
|
54
59
|
this.log('Automation updated!');
|
|
60
|
+
}
|
|
55
61
|
printResponse(result, this.log.bind(this));
|
|
56
62
|
return result;
|
|
57
63
|
}
|
|
@@ -72,14 +78,16 @@ export default class AsaAutomationsUpdate extends Command {
|
|
|
72
78
|
}
|
|
73
79
|
async readStdin() {
|
|
74
80
|
const chunks = [];
|
|
75
|
-
for await (const chunk of process.stdin)
|
|
81
|
+
for await (const chunk of process.stdin) {
|
|
76
82
|
chunks.push(chunk);
|
|
83
|
+
}
|
|
77
84
|
return Buffer.concat(chunks).toString('utf8');
|
|
78
85
|
}
|
|
79
86
|
// Read-modify-write: the API replaces `actions` wholesale, so the whole list has to be sent back.
|
|
80
87
|
async rebuildAction(client, automationId, body, flags) {
|
|
81
88
|
const rule = await client.get(`/automations/${automationId}`);
|
|
82
89
|
try {
|
|
90
|
+
// eslint-disable-next-line @stylistic/max-len -- FIXME if you see this
|
|
83
91
|
body.actions = rebuildAddKeywordAction(body.actions ?? rule.actions, body.operate_with ?? rule.operate_with, flags);
|
|
84
92
|
}
|
|
85
93
|
catch (error) {
|