adapty 0.9.4 → 0.9.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 +40 -0
- package/dist/cli/input/segment.d.ts +20 -0
- package/dist/cli/input/segment.js +61 -0
- package/dist/commands/asa/segments/create.d.ts +17 -0
- package/dist/commands/asa/segments/create.js +53 -0
- package/dist/commands/asa/segments/list.d.ts +16 -0
- package/dist/commands/asa/segments/list.js +59 -0
- package/dist/commands/asa/segments/update.d.ts +20 -0
- package/dist/commands/asa/segments/update.js +60 -0
- package/dist/commands/segments/create.d.ts +14 -0
- package/dist/commands/segments/create.js +30 -0
- package/dist/commands/segments/update.d.ts +17 -0
- package/dist/commands/segments/update.js +35 -0
- package/dist/lib/api-schemas.d.ts +24 -0
- package/dist/lib/asa-client.d.ts +3 -0
- package/dist/lib/asa-client.js +26 -0
- package/dist/lib/asa-flags.d.ts +31 -0
- package/dist/lib/asa-flags.js +69 -0
- package/oclif.manifest.json +1963 -1599
- package/package.json +1 -1
package/dist/lib/asa-flags.js
CHANGED
|
@@ -247,3 +247,72 @@ export function reportBulkOutcome({ applied, errors, isValidationFailure, kind }
|
|
|
247
247
|
log(` ${describeListedError(error).text}`);
|
|
248
248
|
}
|
|
249
249
|
}
|
|
250
|
+
export const asaSegmentSourceFlags = {
|
|
251
|
+
'ad-group': idFilter('ad group'),
|
|
252
|
+
'campaign': idFilter('campaign'),
|
|
253
|
+
'keyword': idFilter('keyword'),
|
|
254
|
+
};
|
|
255
|
+
export function resolveAsaSegmentSource(flags) {
|
|
256
|
+
const keywords = flags.keyword ?? [];
|
|
257
|
+
const adGroups = flags['ad-group'] ?? [];
|
|
258
|
+
const campaigns = flags.campaign ?? [];
|
|
259
|
+
if (keywords.length > 0) {
|
|
260
|
+
const [scopeAdGroup] = adGroups;
|
|
261
|
+
if (campaigns.length > 0 || adGroups.length !== 1 || scopeAdGroup === undefined) {
|
|
262
|
+
throw new Error('--keyword takes exactly one --ad-group as the lookup scope and no --campaign.');
|
|
263
|
+
}
|
|
264
|
+
return { ids: [...new Set(keywords)], scopeAdGroup, source: 'keyword' };
|
|
265
|
+
}
|
|
266
|
+
if (campaigns.length > 0 && adGroups.length > 0) {
|
|
267
|
+
throw new Error('Pass either --campaign or --ad-group, not both: a segment is built from one kind of entity.');
|
|
268
|
+
}
|
|
269
|
+
if (campaigns.length > 0) {
|
|
270
|
+
return { ids: [...new Set(campaigns)], scopeAdGroup: undefined, source: 'campaign' };
|
|
271
|
+
}
|
|
272
|
+
if (adGroups.length > 0) {
|
|
273
|
+
return { ids: [...new Set(adGroups)], scopeAdGroup: undefined, source: 'ad-group' };
|
|
274
|
+
}
|
|
275
|
+
throw new Error('Pass at least one --campaign, --ad-group or --keyword.');
|
|
276
|
+
}
|
|
277
|
+
export const ASA_SEGMENT_FIELD = {
|
|
278
|
+
'ad-group': 'ad_group',
|
|
279
|
+
'campaign': 'campaign',
|
|
280
|
+
// The portal calls a keyword attribution "creative"
|
|
281
|
+
'keyword': 'creative',
|
|
282
|
+
};
|
|
283
|
+
const ASA_TITLE_MAX = 120;
|
|
284
|
+
const ASA_DESCRIPTION_MAX = 240;
|
|
285
|
+
const ASA_PREVIEW_COUNT = 3;
|
|
286
|
+
const ASA_SOURCE_WORDS = {
|
|
287
|
+
'ad-group': { many: 'ad groups', one: 'ad group', title: 'Ad group' },
|
|
288
|
+
'campaign': { many: 'campaigns', one: 'campaign', title: 'Campaign' },
|
|
289
|
+
'keyword': { many: 'keywords', one: 'keyword', title: 'Keyword' },
|
|
290
|
+
};
|
|
291
|
+
function truncate(text, max) {
|
|
292
|
+
if (text.length <= max) {
|
|
293
|
+
return text;
|
|
294
|
+
}
|
|
295
|
+
return max <= 3 ? text.slice(0, max) : `${text.slice(0, max - 3)}...`;
|
|
296
|
+
}
|
|
297
|
+
function withRest(preview, rest) {
|
|
298
|
+
return rest > 0 ? `${preview} +${rest}...` : preview;
|
|
299
|
+
}
|
|
300
|
+
/** The dashboard's own title and description for an Ads Manager segment, so it recognises the segment as its own. */
|
|
301
|
+
export function buildAsaSegmentNaming(source, entities) {
|
|
302
|
+
const words = ASA_SOURCE_WORDS[source];
|
|
303
|
+
if (entities.length === 1) {
|
|
304
|
+
const [entity] = entities;
|
|
305
|
+
return {
|
|
306
|
+
description: truncate(`Created from Apple Search Ads ${words.one} "${entity.name}".\n\nID: ${entity.id}`, ASA_DESCRIPTION_MAX),
|
|
307
|
+
title: truncate(`[ASA] ${words.title}: ${entity.name}`, ASA_TITLE_MAX),
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
const shown = entities.slice(0, ASA_PREVIEW_COUNT);
|
|
311
|
+
const rest = entities.length - shown.length;
|
|
312
|
+
const names = withRest(shown.map(entity => entity.name).join(', '), rest);
|
|
313
|
+
const ids = withRest(shown.map(entity => entity.id).join(', '), rest);
|
|
314
|
+
return {
|
|
315
|
+
description: truncate(`Created from Apple Search Ads ${words.many} (${entities.length}).\n\nPreview: ${names}\n\nIDs: ${ids}`, ASA_DESCRIPTION_MAX),
|
|
316
|
+
title: truncate(`[ASA] ${entities.length} ${words.many}: ${names}`, ASA_TITLE_MAX),
|
|
317
|
+
};
|
|
318
|
+
}
|