adapty 0.6.1-beta.0 → 0.8.0-beta.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.
@@ -0,0 +1,16 @@
1
+ import { Command } from '@oclif/core';
2
+ import type { AsaBulkOperationListDTO } from '../../../lib/asa-schemas.js';
3
+ export default class AsaCampaignsBulkList extends Command {
4
+ static description: string;
5
+ static enableJsonFlag: boolean;
6
+ static examples: string[];
7
+ static flags: {
8
+ app: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
+ 'created-from': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
+ 'created-to': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
+ status: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
+ page: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
13
+ 'page-size': import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
14
+ };
15
+ run(): Promise<AsaBulkOperationListDTO>;
16
+ }
@@ -0,0 +1,54 @@
1
+ import { Command, Flags } from '@oclif/core';
2
+ import { createAsaClient } from '../../../lib/asa-client.js';
3
+ import { asaPaginationFlags, parseDate } from '../../../lib/asa-flags.js';
4
+ import { isValidUuid, paginationParams } from '../../../lib/flags.js';
5
+ import { printList } from '../../../lib/output.js';
6
+ async function parseAppId(input) {
7
+ if (!isValidUuid(input))
8
+ throw new Error('Invalid app ID format. Run `adapty asa apps list` to find your app ID.');
9
+ return input;
10
+ }
11
+ export default class AsaCampaignsBulkList extends Command {
12
+ static description = "This company's bulk operations, newest first; inspect one with bulk-status";
13
+ static enableJsonFlag = true;
14
+ static examples = [
15
+ '<%= config.bin %> asa campaigns bulk-list',
16
+ '<%= config.bin %> asa campaigns bulk-list --status partial --status failed',
17
+ '<%= config.bin %> asa campaigns bulk-list --created-from 2026-08-01 --created-to 2026-08-20',
18
+ ];
19
+ static flags = {
20
+ ...asaPaginationFlags,
21
+ app: Flags.string({ description: 'Keep only operations of this app (UUID)', parse: parseAppId }),
22
+ 'created-from': Flags.string({
23
+ description: 'Keep only operations created on or after this date (YYYY-MM-DD)',
24
+ parse: parseDate,
25
+ }),
26
+ 'created-to': Flags.string({
27
+ description: 'Keep only operations created on or before this date (YYYY-MM-DD)',
28
+ parse: parseDate,
29
+ }),
30
+ status: Flags.string({
31
+ description: 'Keep only operations in this state; repeatable',
32
+ multiple: true,
33
+ options: ['failed', 'partial', 'pending', 'running', 'success'],
34
+ }),
35
+ };
36
+ async run() {
37
+ const { flags } = await this.parse(AsaCampaignsBulkList);
38
+ const client = await createAsaClient(this.config);
39
+ const result = await client.get('/bulk-operations', {
40
+ ...paginationParams(flags),
41
+ app_id: flags.app,
42
+ created_from: flags['created-from'],
43
+ created_to: flags['created-to'],
44
+ status: flags.status,
45
+ });
46
+ const pages = Math.max(1, Math.ceil(result.total / result.limit));
47
+ printList(result.items, this.log.bind(this), {
48
+ count: result.total,
49
+ page: flags.page,
50
+ pages,
51
+ });
52
+ return result;
53
+ }
54
+ }
@@ -10,7 +10,6 @@ export default class FlowsConfigValidate extends Command {
10
10
  static flags: {
11
11
  config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
12
  'config-file': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
13
- source: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
14
13
  app: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
15
14
  };
16
15
  run(): Promise<FlowConfigValidationDTO>;
@@ -24,10 +24,6 @@ export default class FlowsConfigValidate extends Command {
24
24
  description: 'JSON file with the builder config, or - to read stdin',
25
25
  exactlyOne: ['config', 'config-file'],
26
26
  }),
27
- source: Flags.string({
28
- default: 'adapty-cli',
29
- description: 'Caller attribution, sent as X-Adapty-Source (e.g. byo-cli)',
30
- }),
31
27
  };
32
28
  async run() {
33
29
  const { args, flags } = await this.parse(FlowsConfigValidate);
@@ -37,7 +33,7 @@ export default class FlowsConfigValidate extends Command {
37
33
  const config = await this.readConfig(flags);
38
34
  const body = { config };
39
35
  const client = await createAuthenticatedClient(this.config);
40
- const result = await client.post(`/apps/${flags.app}/flows/${args.flow_id}/config/validate`, body, undefined, { headers: { 'X-Adapty-Source': flags.source } });
36
+ const result = await client.post(`/apps/${flags.app}/flows/${args.flow_id}/config/validate`, body);
41
37
  this.log(result.valid ? 'Config is publishable.' : 'Config is NOT publishable.');
42
38
  printResponse(result, this.log.bind(this));
43
39
  // Advisory endpoint always returns HTTP 200; surface the verdict as an exit code so scripts and agents
@@ -0,0 +1,14 @@
1
+ import { Command } from '@oclif/core';
2
+ import type { MediaDTO } from '../../../lib/api-schemas.js';
3
+ export default class FlowsMediaUpload extends Command {
4
+ static args: {
5
+ file: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
6
+ };
7
+ static description: string;
8
+ static enableJsonFlag: boolean;
9
+ static examples: string[];
10
+ static flags: {
11
+ app: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
12
+ };
13
+ run(): Promise<MediaDTO>;
14
+ }
@@ -0,0 +1,46 @@
1
+ import { Args, Command } from '@oclif/core';
2
+ import { readFile } from 'node:fs/promises';
3
+ import { basename, extname } from 'node:path';
4
+ import { createAuthenticatedClient } from '../../../lib/client-from-config.js';
5
+ import { appFlag } from '../../../lib/flags.js';
6
+ import { printResponse } from '../../../lib/output.js';
7
+ const IMAGE_MIME_TYPES = {
8
+ '.gif': 'image/gif',
9
+ '.heic': 'image/heic',
10
+ '.jpeg': 'image/jpeg',
11
+ '.jpg': 'image/jpeg',
12
+ '.png': 'image/png',
13
+ '.svg': 'image/svg+xml',
14
+ '.webp': 'image/webp',
15
+ };
16
+ export default class FlowsMediaUpload extends Command {
17
+ static args = {
18
+ file: Args.string({ description: 'Path to the image file to upload', required: true }),
19
+ };
20
+ static description = 'Upload an image as a flow builder asset; prints the CDN URL to reference from a flow config';
21
+ static enableJsonFlag = true;
22
+ static examples = ['<%= config.bin %> flows media upload --app UUID ./onboarding-hero.png'];
23
+ static flags = {
24
+ ...appFlag,
25
+ };
26
+ async run() {
27
+ const { args, flags } = await this.parse(FlowsMediaUpload);
28
+ let content;
29
+ try {
30
+ content = await readFile(args.file);
31
+ }
32
+ catch {
33
+ this.error(`Cannot read file: ${args.file}`, { exit: 2 });
34
+ }
35
+ const name = basename(args.file);
36
+ const type = IMAGE_MIME_TYPES[extname(name).toLowerCase()] ?? 'application/octet-stream';
37
+ const form = new FormData();
38
+ form.append('file', new Blob([new Uint8Array(content)], { type }), name);
39
+ const client = await createAuthenticatedClient(this.config);
40
+ const result = await client.postForm(`/apps/${flags.app}/flows/media/images`, form);
41
+ this.log('Image uploaded!');
42
+ // `preview_base64` is a long data blob with no value in human output; --json still returns it in full.
43
+ printResponse({ id: result.id, name: result.name, url: result.url }, this.log.bind(this));
44
+ return result;
45
+ }
46
+ }
@@ -116,6 +116,14 @@ export interface FlowConfigValidationDTO {
116
116
  issues: FlowConfigIssueDTO[];
117
117
  valid: boolean;
118
118
  }
119
+ export interface MediaDTO {
120
+ id: number;
121
+ name: string;
122
+ /** Base64-encoded preview thumbnail; absent when no preview was generated. */
123
+ preview_base64?: null | string;
124
+ /** CDN URL to reference from a flow config. */
125
+ url: string;
126
+ }
119
127
  export interface SegmentDTO {
120
128
  description: null | string;
121
129
  id: string;
@@ -11,6 +11,7 @@ export declare const asaPaginationFlags: {
11
11
  export declare const byDaysFlag: {
12
12
  'by-days': import("@oclif/core/interfaces").OptionFlag<number[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
13
13
  };
14
+ export declare function parseDate(input: string): Promise<string>;
14
15
  export declare const periodFlags: {
15
16
  'date-from': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
16
17
  'date-to': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
@@ -26,7 +26,7 @@ export const byDaysFlag = {
26
26
  multiple: true,
27
27
  }),
28
28
  };
29
- async function parseDate(input) {
29
+ export async function parseDate(input) {
30
30
  if (!DATE_REGEX.test(input))
31
31
  throw new Error('Dates must be written as YYYY-MM-DD.');
32
32
  return input;
@@ -314,6 +314,21 @@ export interface AsaBulkOperationStateDTO {
314
314
  started_at: null | string;
315
315
  status: AsaBulkOperationStatus;
316
316
  }
317
+ export interface AsaBulkOperationListItemDTO {
318
+ app_id: string;
319
+ created_at: string;
320
+ error: null | string;
321
+ finished_at: null | string;
322
+ operation_id: string;
323
+ started_at: null | string;
324
+ status: AsaBulkOperationStatus;
325
+ }
326
+ export interface AsaBulkOperationListDTO {
327
+ items: AsaBulkOperationListItemDTO[];
328
+ limit: number;
329
+ offset: number;
330
+ total: number;
331
+ }
317
332
  export interface AsaTemplateIssueDTO {
318
333
  column: null | string;
319
334
  message: string;