adapty 0.8.3 → 0.8.4-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -132
- package/dist/commands/asa/ad-groups/create.js +1 -1
- package/dist/commands/asa/ad-groups/update.js +1 -1
- package/dist/commands/asa/ads/create.js +1 -1
- package/dist/commands/asa/ads/update.js +1 -1
- package/dist/commands/asa/automations/create.d.ts +0 -9
- package/dist/commands/asa/automations/create.js +3 -19
- package/dist/commands/asa/automations/run.js +1 -1
- package/dist/commands/asa/automations/update.d.ts +0 -9
- package/dist/commands/asa/automations/update.js +6 -22
- package/dist/commands/asa/campaigns/bulk-create.js +1 -1
- package/dist/commands/asa/campaigns/create.js +1 -1
- package/dist/commands/asa/campaigns/update.js +1 -1
- package/dist/commands/asa/keywords/add.js +1 -1
- package/dist/commands/asa/keywords/update.js +1 -1
- package/dist/commands/asa/metrics/index.d.ts +1 -4
- package/dist/commands/asa/metrics/index.js +8 -18
- package/dist/commands/asa/negative-keywords/add.js +1 -1
- package/dist/commands/asa/product-pages/sync.js +1 -1
- package/dist/commands/flows/config/get.js +2 -1
- package/dist/commands/flows/publish.d.ts +15 -0
- package/dist/commands/flows/publish.js +52 -0
- package/dist/commands/flows/update.d.ts +15 -0
- package/dist/commands/flows/update.js +28 -0
- package/dist/commands/placements/create.js +29 -4
- package/dist/commands/placements/update.js +29 -4
- package/dist/lib/api-schemas.d.ts +20 -1
- package/dist/lib/asa-flags.d.ts +0 -24
- package/dist/lib/asa-flags.js +0 -54
- package/dist/lib/errors.js +1 -2
- package/dist/lib/flow-help.d.ts +12 -0
- package/dist/lib/flow-help.js +27 -0
- package/dist/lib/placement-audiences.d.ts +6 -0
- package/dist/lib/placement-audiences.js +25 -0
- package/oclif.manifest.json +601 -664
- package/package.json +3 -2
- package/dist/lib/asa-keyword-action.d.ts +0 -18
- package/dist/lib/asa-keyword-action.js +0 -160
- /package/dist/lib/{asa-confirm.d.ts → confirm.d.ts} +0 -0
- /package/dist/lib/{asa-confirm.js → confirm.js} +0 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "adapty",
|
|
3
3
|
"description": "Adapty command line interface",
|
|
4
|
-
"version": "0.8.
|
|
4
|
+
"version": "0.8.4-beta.1",
|
|
5
5
|
"author": "Adapty team <support@adapty.io>",
|
|
6
6
|
"bin": {
|
|
7
7
|
"adapty": "./bin/run.js"
|
|
@@ -143,7 +143,8 @@
|
|
|
143
143
|
"prepack": "oclif manifest && oclif readme",
|
|
144
144
|
"prepublishOnly": "pnpm build && oclif manifest",
|
|
145
145
|
"test": "mocha --forbid-only \"test/**/*.test.ts\"",
|
|
146
|
-
"version": "oclif readme && git add README.md"
|
|
146
|
+
"version": "oclif readme && git add README.md",
|
|
147
|
+
"publish:beta": "npm publish --tag beta"
|
|
147
148
|
},
|
|
148
149
|
"types": "dist/index.d.ts"
|
|
149
150
|
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export declare const ADD_AS_KEYWORD_ACTION = "add-as-keyword-to";
|
|
2
|
-
export declare const CPT_BID_TYPES: string[];
|
|
3
|
-
export declare const KEYWORD_MATCH_TYPES: string[];
|
|
4
|
-
export declare const NEGATE_TYPES: string[];
|
|
5
|
-
export interface AddKeywordActionFlags {
|
|
6
|
-
'cpt-bid'?: string;
|
|
7
|
-
'cpt-bid-type'?: string;
|
|
8
|
-
'match-type'?: string;
|
|
9
|
-
negate?: string;
|
|
10
|
-
'no-negate'?: boolean;
|
|
11
|
-
'pause-original'?: boolean;
|
|
12
|
-
'skip-enable-duplicates'?: boolean;
|
|
13
|
-
'target-ad-group'?: string[];
|
|
14
|
-
}
|
|
15
|
-
export declare function hasAddKeywordActionFlags(flags: AddKeywordActionFlags): boolean;
|
|
16
|
-
export declare function buildAddKeywordParams(operateWith: unknown, stored: unknown, flags: AddKeywordActionFlags): Record<string, unknown>;
|
|
17
|
-
export declare function requireSingleAction(actions: unknown): Record<string, unknown>;
|
|
18
|
-
export declare function rebuildAddKeywordAction(actions: unknown, operateWith: unknown, flags: AddKeywordActionFlags): Record<string, unknown>[];
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
import { isValidUuid } from './flags.js';
|
|
2
|
-
export const ADD_AS_KEYWORD_ACTION = 'add-as-keyword-to';
|
|
3
|
-
export const CPT_BID_TYPES = ['ad_group_default_bid', 'keyword_current_bid', 'search_term_current_cpt', 'set_to'];
|
|
4
|
-
export const KEYWORD_MATCH_TYPES = ['BROAD', 'EXACT'];
|
|
5
|
-
export const NEGATE_TYPES = ['ad-group', 'campaign'];
|
|
6
|
-
const SEARCH_TERM = 'search-term';
|
|
7
|
-
const TARGETING_KEYWORD = 'targeting-keyword';
|
|
8
|
-
const BID_TYPE_IGNORING_VALUE = 'ad_group_default_bid';
|
|
9
|
-
const BID_TYPES_READING_MARKUP = new Set(['keyword_current_bid', 'search_term_current_cpt']);
|
|
10
|
-
// KeywordMatchType also carries AUTO. --match-type never offers it — an automation creates a
|
|
11
|
-
// keyword, and AUTO is not something a keyword can be — but a rule that already stores AUTO keeps
|
|
12
|
-
// it rather than being pushed onto another match type by an edit that never mentioned match types.
|
|
13
|
-
const STORED_MATCH_TYPES = new Set(['AUTO', ...KEYWORD_MATCH_TYPES]);
|
|
14
|
-
const SHARED_FLAGS = ['target-ad-group', 'match-type', 'cpt-bid-type', 'cpt-bid'];
|
|
15
|
-
const SEARCH_TERM_FLAGS = ['negate', 'no-negate', 'skip-enable-duplicates'];
|
|
16
|
-
const TARGETING_KEYWORD_FLAGS = ['pause-original'];
|
|
17
|
-
const ALL_FLAGS = [...SHARED_FLAGS, ...SEARCH_TERM_FLAGS, ...TARGETING_KEYWORD_FLAGS];
|
|
18
|
-
const MISSING_REASONS = {
|
|
19
|
-
'cpt-bid': 'the bid to set, required by --cpt-bid-type set_to',
|
|
20
|
-
'cpt-bid-type': 'where the bid of the new keyword comes from; the API has no default',
|
|
21
|
-
'match-type': 'BROAD or EXACT; the API has no default',
|
|
22
|
-
'target-ad-group': 'the ad groups the keyword is added to; a rule with none does nothing',
|
|
23
|
-
};
|
|
24
|
-
function dashed(name) {
|
|
25
|
-
return `--${name}`;
|
|
26
|
-
}
|
|
27
|
-
function asRecord(value) {
|
|
28
|
-
return typeof value === 'object' && value !== null && !Array.isArray(value) ? value : {};
|
|
29
|
-
}
|
|
30
|
-
function isFlagSet(flags, name) {
|
|
31
|
-
const value = flags[name];
|
|
32
|
-
if (value === undefined)
|
|
33
|
-
return false;
|
|
34
|
-
if (Array.isArray(value))
|
|
35
|
-
return value.length > 0;
|
|
36
|
-
// --no-negate has no negated form of its own, so only a true means it was passed.
|
|
37
|
-
return name === 'no-negate' ? value === true : true;
|
|
38
|
-
}
|
|
39
|
-
export function hasAddKeywordActionFlags(flags) {
|
|
40
|
-
return ALL_FLAGS.some((name) => isFlagSet(flags, name));
|
|
41
|
-
}
|
|
42
|
-
// Params are rebuilt, not patched: a rule may store the add-as-negative-keyword shape
|
|
43
|
-
// ({target_type, ids}) under an add-as-keyword-to action, and the API picks the params variant by
|
|
44
|
-
// shape without a discriminator — so every stray key silently changes which action gets run.
|
|
45
|
-
// Only what fits the expected shape is carried over; the rest has to come from the flags.
|
|
46
|
-
function storedInternalIds(params) {
|
|
47
|
-
const ids = asRecord(params.targets).internal_ids;
|
|
48
|
-
return Array.isArray(ids) ? ids.filter((id) => typeof id === 'string' && isValidUuid(id)) : [];
|
|
49
|
-
}
|
|
50
|
-
function storedMatchType(params) {
|
|
51
|
-
const matchType = params.match_type;
|
|
52
|
-
return typeof matchType === 'string' && STORED_MATCH_TYPES.has(matchType) ? matchType : undefined;
|
|
53
|
-
}
|
|
54
|
-
function storedCptBidType(params) {
|
|
55
|
-
const { type } = asRecord(params.cpt_bid);
|
|
56
|
-
return typeof type === 'string' && CPT_BID_TYPES.includes(type) ? type : undefined;
|
|
57
|
-
}
|
|
58
|
-
function storedCptBidValue(params) {
|
|
59
|
-
const { value } = asRecord(params.cpt_bid);
|
|
60
|
-
return typeof value === 'number' && Number.isFinite(value) ? value : undefined;
|
|
61
|
-
}
|
|
62
|
-
function storedBoolean(value) {
|
|
63
|
-
return typeof value === 'boolean' ? value : undefined;
|
|
64
|
-
}
|
|
65
|
-
function storedNegate(params) {
|
|
66
|
-
const { enabled, type } = asRecord(params.negate);
|
|
67
|
-
if (typeof enabled !== 'boolean')
|
|
68
|
-
return undefined;
|
|
69
|
-
if (type === null || type === undefined)
|
|
70
|
-
return { enabled, type: null };
|
|
71
|
-
return typeof type === 'string' && NEGATE_TYPES.includes(type) ? { enabled, type } : undefined;
|
|
72
|
-
}
|
|
73
|
-
function resolveNegate(flags, params) {
|
|
74
|
-
if (flags.negate !== undefined)
|
|
75
|
-
return { enabled: true, type: flags.negate };
|
|
76
|
-
if (flags['no-negate'] === true)
|
|
77
|
-
return { enabled: false, type: null };
|
|
78
|
-
return storedNegate(params) ?? { enabled: false, type: null };
|
|
79
|
-
}
|
|
80
|
-
function resolveCptBidValue(cptBidType, bid, params) {
|
|
81
|
-
if (cptBidType === 'set_to')
|
|
82
|
-
return bid === undefined ? storedCptBidValue(params) : Number(bid);
|
|
83
|
-
if (cptBidType !== undefined && BID_TYPES_READING_MARKUP.has(cptBidType)) {
|
|
84
|
-
return bid === undefined ? (storedCptBidValue(params) ?? null) : Number(bid);
|
|
85
|
-
}
|
|
86
|
-
return null;
|
|
87
|
-
}
|
|
88
|
-
function isSearchTermRule(operateWith) {
|
|
89
|
-
if (operateWith === SEARCH_TERM)
|
|
90
|
-
return true;
|
|
91
|
-
if (operateWith === TARGETING_KEYWORD)
|
|
92
|
-
return false;
|
|
93
|
-
const shown = typeof operateWith === 'string' && operateWith.length > 0 ? `"${operateWith}"` : 'missing';
|
|
94
|
-
throw new Error(`${ADD_AS_KEYWORD_ACTION} runs on a "${SEARCH_TERM}" or "${TARGETING_KEYWORD}" rule only; this rule's operate_with is ${shown}.`);
|
|
95
|
-
}
|
|
96
|
-
function rejectForeignFlags(searchTerm, flags) {
|
|
97
|
-
const foreign = (searchTerm ? TARGETING_KEYWORD_FLAGS : SEARCH_TERM_FLAGS).filter((name) => isFlagSet(flags, name));
|
|
98
|
-
if (foreign.length === 0)
|
|
99
|
-
return;
|
|
100
|
-
const applicable = [...SHARED_FLAGS, ...(searchTerm ? SEARCH_TERM_FLAGS : TARGETING_KEYWORD_FLAGS)];
|
|
101
|
-
throw new Error(`${foreign.map((name) => dashed(name)).join(', ')} ${foreign.length === 1 ? 'has' : 'have'} no place in the params of an ` +
|
|
102
|
-
`operate_with "${searchTerm ? SEARCH_TERM : TARGETING_KEYWORD}" rule, and the API drops params it cannot ` +
|
|
103
|
-
`place. Applicable action flags: ${applicable.map((name) => dashed(name)).join(', ')}.`);
|
|
104
|
-
}
|
|
105
|
-
function missingFlagsError(missing) {
|
|
106
|
-
const lines = missing.map((name) => ` ${dashed(name)} — ${MISSING_REASONS[name]}`);
|
|
107
|
-
return new Error(`The ${ADD_AS_KEYWORD_ACTION} params are incomplete. Pass:\n${lines.join('\n')}`);
|
|
108
|
-
}
|
|
109
|
-
export function buildAddKeywordParams(operateWith, stored, flags) {
|
|
110
|
-
const searchTerm = isSearchTermRule(operateWith);
|
|
111
|
-
rejectForeignFlags(searchTerm, flags);
|
|
112
|
-
const params = asRecord(stored);
|
|
113
|
-
const missing = [];
|
|
114
|
-
const internalIds = flags['target-ad-group'] ?? storedInternalIds(params);
|
|
115
|
-
if (internalIds.length === 0)
|
|
116
|
-
missing.push('target-ad-group');
|
|
117
|
-
const matchType = flags['match-type'] ?? storedMatchType(params);
|
|
118
|
-
if (matchType === undefined)
|
|
119
|
-
missing.push('match-type');
|
|
120
|
-
const cptBidType = flags['cpt-bid-type'] ?? storedCptBidType(params);
|
|
121
|
-
if (cptBidType === undefined)
|
|
122
|
-
missing.push('cpt-bid-type');
|
|
123
|
-
const bid = flags['cpt-bid'];
|
|
124
|
-
if (bid !== undefined && cptBidType === BID_TYPE_IGNORING_VALUE) {
|
|
125
|
-
throw new Error(`--cpt-bid has no meaning with --cpt-bid-type ${BID_TYPE_IGNORING_VALUE}; that type copies the target ad group's default bid.`);
|
|
126
|
-
}
|
|
127
|
-
const cptBidValue = resolveCptBidValue(cptBidType, bid, params);
|
|
128
|
-
if (cptBidValue === undefined)
|
|
129
|
-
missing.push('cpt-bid');
|
|
130
|
-
if (missing.length > 0)
|
|
131
|
-
throw missingFlagsError(missing);
|
|
132
|
-
const built = {
|
|
133
|
-
cpt_bid: { type: cptBidType, value: cptBidValue ?? null },
|
|
134
|
-
match_type: matchType,
|
|
135
|
-
targets: { internal_ids: internalIds, type: 'ad-group' },
|
|
136
|
-
};
|
|
137
|
-
if (searchTerm) {
|
|
138
|
-
built.negate = resolveNegate(flags, params);
|
|
139
|
-
built.skip_enable_duplicate_keywords =
|
|
140
|
-
flags['skip-enable-duplicates'] ?? storedBoolean(params.skip_enable_duplicate_keywords) ?? false;
|
|
141
|
-
}
|
|
142
|
-
else {
|
|
143
|
-
built.pause_in_original_ad_group =
|
|
144
|
-
flags['pause-original'] ?? storedBoolean(params.pause_in_original_ad_group) ?? false;
|
|
145
|
-
}
|
|
146
|
-
return built;
|
|
147
|
-
}
|
|
148
|
-
export function requireSingleAction(actions) {
|
|
149
|
-
if (!Array.isArray(actions) || actions.length !== 1) {
|
|
150
|
-
throw new Error('A rule needs exactly one action: the API stores one action and one condition per rule.');
|
|
151
|
-
}
|
|
152
|
-
return asRecord(actions[0]);
|
|
153
|
-
}
|
|
154
|
-
export function rebuildAddKeywordAction(actions, operateWith, flags) {
|
|
155
|
-
const action = requireSingleAction(actions);
|
|
156
|
-
if (action.type !== ADD_AS_KEYWORD_ACTION) {
|
|
157
|
-
throw new Error(`The action flags only apply to an ${ADD_AS_KEYWORD_ACTION} action; this rule's action is "${String(action.type)}".`);
|
|
158
|
-
}
|
|
159
|
-
return [{ ...action, params: buildAddKeywordParams(operateWith, action.params, flags) }];
|
|
160
|
-
}
|
|
File without changes
|
|
File without changes
|