adapty 0.1.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.
Files changed (71) hide show
  1. package/README.md +110 -0
  2. package/bin/dev.cmd +3 -0
  3. package/bin/dev.js +5 -0
  4. package/bin/run.cmd +3 -0
  5. package/bin/run.js +5 -0
  6. package/dist/commands/access-levels/create.d.ts +18 -0
  7. package/dist/commands/access-levels/create.js +28 -0
  8. package/dist/commands/access-levels/get.d.ts +19 -0
  9. package/dist/commands/access-levels/get.js +26 -0
  10. package/dist/commands/access-levels/list.d.ts +19 -0
  11. package/dist/commands/access-levels/list.js +20 -0
  12. package/dist/commands/access-levels/update.d.ts +20 -0
  13. package/dist/commands/access-levels/update.js +32 -0
  14. package/dist/commands/apps/create.d.ts +25 -0
  15. package/dist/commands/apps/create.js +47 -0
  16. package/dist/commands/apps/get.d.ts +20 -0
  17. package/dist/commands/apps/get.js +29 -0
  18. package/dist/commands/apps/list.d.ts +18 -0
  19. package/dist/commands/apps/list.js +19 -0
  20. package/dist/commands/apps/update.d.ts +22 -0
  21. package/dist/commands/apps/update.js +42 -0
  22. package/dist/commands/auth/login.d.ts +6 -0
  23. package/dist/commands/auth/login.js +106 -0
  24. package/dist/commands/auth/logout.d.ts +9 -0
  25. package/dist/commands/auth/logout.js +18 -0
  26. package/dist/commands/auth/status.d.ts +7 -0
  27. package/dist/commands/auth/status.js +26 -0
  28. package/dist/commands/auth/whoami.d.ts +16 -0
  29. package/dist/commands/auth/whoami.js +21 -0
  30. package/dist/commands/paywalls/create.d.ts +17 -0
  31. package/dist/commands/paywalls/create.js +31 -0
  32. package/dist/commands/paywalls/get.d.ts +19 -0
  33. package/dist/commands/paywalls/get.js +26 -0
  34. package/dist/commands/paywalls/list.d.ts +18 -0
  35. package/dist/commands/paywalls/list.js +20 -0
  36. package/dist/commands/paywalls/update.d.ts +20 -0
  37. package/dist/commands/paywalls/update.js +37 -0
  38. package/dist/commands/placements/create.d.ts +19 -0
  39. package/dist/commands/placements/create.js +30 -0
  40. package/dist/commands/placements/get.d.ts +20 -0
  41. package/dist/commands/placements/get.js +27 -0
  42. package/dist/commands/placements/list.d.ts +19 -0
  43. package/dist/commands/placements/list.js +20 -0
  44. package/dist/commands/placements/update.d.ts +22 -0
  45. package/dist/commands/placements/update.js +36 -0
  46. package/dist/commands/products/create.d.ts +33 -0
  47. package/dist/commands/products/create.js +59 -0
  48. package/dist/commands/products/get.d.ts +32 -0
  49. package/dist/commands/products/get.js +34 -0
  50. package/dist/commands/products/list.d.ts +30 -0
  51. package/dist/commands/products/list.js +31 -0
  52. package/dist/commands/products/update.d.ts +36 -0
  53. package/dist/commands/products/update.js +65 -0
  54. package/dist/index.d.ts +1 -0
  55. package/dist/index.js +1 -0
  56. package/dist/lib/api-client.d.ts +15 -0
  57. package/dist/lib/api-client.js +75 -0
  58. package/dist/lib/auth.d.ts +1 -0
  59. package/dist/lib/auth.js +8 -0
  60. package/dist/lib/client-from-config.d.ts +4 -0
  61. package/dist/lib/client-from-config.js +15 -0
  62. package/dist/lib/config.d.ts +9 -0
  63. package/dist/lib/config.js +22 -0
  64. package/dist/lib/errors.d.ts +23 -0
  65. package/dist/lib/errors.js +63 -0
  66. package/dist/lib/flags.d.ts +22 -0
  67. package/dist/lib/flags.js +36 -0
  68. package/dist/lib/output.d.ts +6 -0
  69. package/dist/lib/output.js +18 -0
  70. package/oclif.manifest.json +1284 -0
  71. package/package.json +100 -0
package/README.md ADDED
@@ -0,0 +1,110 @@
1
+ # adapty-cli
2
+
3
+ CLI for the [Adapty Developer API](https://docs.adapty.io/docs/developer-api). Manage apps, products, paywalls, placements, and access levels from your terminal.
4
+
5
+ ## Installation
6
+
7
+ ```sh
8
+ npm install -g adapty-cli
9
+ ```
10
+
11
+ Requires Node.js >= 18.
12
+
13
+ ## Authentication
14
+
15
+ ```sh
16
+ adapty auth login
17
+ ```
18
+
19
+ Opens browser for OAuth device flow. Token is stored in `~/.config/adapty/config.json`.
20
+
21
+ Override with `ADAPTY_TOKEN` environment variable:
22
+
23
+ ```sh
24
+ ADAPTY_TOKEN=your-token adapty apps list
25
+ ```
26
+
27
+ Other auth commands:
28
+
29
+ ```sh
30
+ adapty auth whoami # verify token, show user info
31
+ adapty auth status # show local auth state
32
+ adapty auth logout # clear stored token
33
+ ```
34
+
35
+ ## Commands
36
+
37
+ All resource commands require `--app APP_ID` (UUID). Use `adapty apps list` to find your app ID.
38
+
39
+ ### Apps
40
+
41
+ ```sh
42
+ adapty apps list [--page N] [--page-size N]
43
+ adapty apps get APP_ID
44
+ adapty apps create --name "My App" --platform ios --ios-bundle-id com.example.app
45
+ adapty apps update APP_ID [flags]
46
+ ```
47
+
48
+ ### Products
49
+
50
+ ```sh
51
+ adapty products list --app UUID [--page N] [--page-size N]
52
+ adapty products get --app UUID PRODUCT_ID
53
+ adapty products create --app UUID [flags]
54
+ adapty products update --app UUID PRODUCT_ID [flags]
55
+ ```
56
+
57
+ ### Paywalls
58
+
59
+ ```sh
60
+ adapty paywalls list --app UUID [--page N] [--page-size N]
61
+ adapty paywalls get --app UUID PAYWALL_ID
62
+ adapty paywalls create --app UUID --name "Name" --product-id UUID1 [--product-id UUID2]
63
+ adapty paywalls update --app UUID PAYWALL_ID [flags]
64
+ ```
65
+
66
+ ### Placements
67
+
68
+ ```sh
69
+ adapty placements list --app UUID [--page N] [--page-size N]
70
+ adapty placements get --app UUID PLACEMENT_ID
71
+ adapty placements create --app UUID [flags]
72
+ adapty placements update --app UUID PLACEMENT_ID [flags]
73
+ ```
74
+
75
+ ### Access Levels
76
+
77
+ ```sh
78
+ adapty access-levels list --app UUID [--page N] [--page-size N]
79
+ adapty access-levels get --app UUID ACCESS_LEVEL_ID
80
+ adapty access-levels create --app UUID [flags]
81
+ adapty access-levels update --app UUID ACCESS_LEVEL_ID [flags]
82
+ ```
83
+
84
+ ### Global Flags
85
+
86
+ | Flag | Description |
87
+ |------|-------------|
88
+ | `--json` | Output as JSON |
89
+ | `--help` | Show help |
90
+ | `--page` | Page number (default: 1) |
91
+ | `--page-size` | Items per page (default: 20, max: 100) |
92
+
93
+ ## Environment Variables
94
+
95
+ | Variable | Description |
96
+ |----------|-------------|
97
+ | `ADAPTY_TOKEN` | Override stored auth token |
98
+ | `ADAPTY_API_URL` | Override API base URL (default: `https://api.adapty.io/api/v1/developer`) |
99
+
100
+ ## Development
101
+
102
+ ```sh
103
+ pnpm install
104
+ pnpm build
105
+ ./bin/run.js apps list
106
+ ```
107
+
108
+ ## License
109
+
110
+ MIT
package/bin/dev.cmd ADDED
@@ -0,0 +1,3 @@
1
+ @echo off
2
+
3
+ node --loader ts-node/esm --no-warnings=ExperimentalWarning "%~dp0\dev" %*
package/bin/dev.js ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env -S node --loader ts-node/esm --disable-warning=ExperimentalWarning
2
+
3
+ import {execute} from '@oclif/core'
4
+
5
+ await execute({development: true, dir: import.meta.url})
package/bin/run.cmd ADDED
@@ -0,0 +1,3 @@
1
+ @echo off
2
+
3
+ node "%~dp0\run" %*
package/bin/run.js ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+
3
+ import {execute} from '@oclif/core'
4
+
5
+ await execute({dir: import.meta.url})
@@ -0,0 +1,18 @@
1
+ import { Command } from '@oclif/core';
2
+ interface AccessLevelResponse {
3
+ id: string;
4
+ sdk_id: string;
5
+ title: string;
6
+ }
7
+ export default class AccessLevelsCreate extends Command {
8
+ static description: string;
9
+ static enableJsonFlag: boolean;
10
+ static examples: string[];
11
+ static flags: {
12
+ 'sdk-id': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
13
+ title: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
14
+ app: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
15
+ };
16
+ run(): Promise<AccessLevelResponse>;
17
+ }
18
+ export {};
@@ -0,0 +1,28 @@
1
+ import { Command, Flags } from '@oclif/core';
2
+ import { createAuthenticatedClient } from '../../lib/client-from-config.js';
3
+ import { appFlag } from '../../lib/flags.js';
4
+ export default class AccessLevelsCreate extends Command {
5
+ static description = 'Create a custom access level';
6
+ static enableJsonFlag = true;
7
+ static examples = [
8
+ '<%= config.bin %> access-levels create --app 550e8400-... --sdk-id vip --title "VIP Access"',
9
+ ];
10
+ static flags = {
11
+ ...appFlag,
12
+ 'sdk-id': Flags.string({ description: 'Access level SDK identifier', required: true }),
13
+ title: Flags.string({ description: 'Access level title', required: true }),
14
+ };
15
+ async run() {
16
+ const { flags } = await this.parse(AccessLevelsCreate);
17
+ const client = await createAuthenticatedClient(this.config);
18
+ const result = await client.post(`/apps/${flags.app}/access-levels`, {
19
+ sdk_id: flags['sdk-id'],
20
+ title: flags.title,
21
+ });
22
+ this.log('Access level created!');
23
+ this.log(`ID: ${result.id}`);
24
+ this.log(`SDK ID: ${result.sdk_id}`);
25
+ this.log(`Title: ${result.title}`);
26
+ return result;
27
+ }
28
+ }
@@ -0,0 +1,19 @@
1
+ import { Command } from '@oclif/core';
2
+ interface AccessLevelDetailResponse {
3
+ id: string;
4
+ sdk_id: string;
5
+ title: string;
6
+ }
7
+ export default class AccessLevelsGet extends Command {
8
+ static args: {
9
+ access_level_id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
10
+ };
11
+ static description: string;
12
+ static enableJsonFlag: boolean;
13
+ static examples: string[];
14
+ static flags: {
15
+ app: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
16
+ };
17
+ run(): Promise<AccessLevelDetailResponse>;
18
+ }
19
+ export {};
@@ -0,0 +1,26 @@
1
+ import { Args, Command } from '@oclif/core';
2
+ import { createAuthenticatedClient } from '../../lib/client-from-config.js';
3
+ import { appFlag, isValidUuid } from '../../lib/flags.js';
4
+ export default class AccessLevelsGet extends Command {
5
+ static args = {
6
+ access_level_id: Args.string({ description: 'Access Level ID (UUID)', required: true }),
7
+ };
8
+ static description = 'Get access level details';
9
+ static enableJsonFlag = true;
10
+ static examples = ['<%= config.bin %> access-levels get --app UUID 550e8400-e29b-41d4-a716-446655440000'];
11
+ static flags = {
12
+ ...appFlag,
13
+ };
14
+ async run() {
15
+ const { args, flags } = await this.parse(AccessLevelsGet);
16
+ if (!isValidUuid(args.access_level_id)) {
17
+ this.error('Invalid access level ID format.', { exit: 2 });
18
+ }
19
+ const client = await createAuthenticatedClient(this.config);
20
+ const result = await client.get(`/apps/${flags.app}/access-levels/${args.access_level_id}`);
21
+ this.log(`ID: ${result.id}`);
22
+ this.log(`SDK ID: ${result.sdk_id}`);
23
+ this.log(`Title: ${result.title}`);
24
+ return result;
25
+ }
26
+ }
@@ -0,0 +1,19 @@
1
+ import { Command } from '@oclif/core';
2
+ import { type PaginatedResponse } from '../../lib/flags.js';
3
+ interface AccessLevelItem {
4
+ id: string;
5
+ sdk_id: string;
6
+ title: string;
7
+ }
8
+ export default class AccessLevelsList extends Command {
9
+ static description: string;
10
+ static enableJsonFlag: boolean;
11
+ static examples: string[];
12
+ static flags: {
13
+ page: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
14
+ 'page-size': import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
15
+ app: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
16
+ };
17
+ run(): Promise<PaginatedResponse<AccessLevelItem>>;
18
+ }
19
+ export {};
@@ -0,0 +1,20 @@
1
+ import { Command } from '@oclif/core';
2
+ import { createAuthenticatedClient } from '../../lib/client-from-config.js';
3
+ import { appFlag, paginationFlags, paginationParams } from '../../lib/flags.js';
4
+ import { printList } from '../../lib/output.js';
5
+ export default class AccessLevelsList extends Command {
6
+ static description = 'List access levels for an app';
7
+ static enableJsonFlag = true;
8
+ static examples = ['<%= config.bin %> access-levels list --app 550e8400-e29b-41d4-a716-446655440000'];
9
+ static flags = {
10
+ ...appFlag,
11
+ ...paginationFlags,
12
+ };
13
+ async run() {
14
+ const { flags } = await this.parse(AccessLevelsList);
15
+ const client = await createAuthenticatedClient(this.config);
16
+ const result = await client.get(`/apps/${flags.app}/access-levels`, paginationParams(flags));
17
+ printList(result.data.map((al) => ({ ID: al.id, 'SDK ID': al.sdk_id, Title: al.title })), this.log.bind(this), result.meta.pagination);
18
+ return result;
19
+ }
20
+ }
@@ -0,0 +1,20 @@
1
+ import { Command } from '@oclif/core';
2
+ interface AccessLevelResponse {
3
+ id: string;
4
+ sdk_id: string;
5
+ title: string;
6
+ }
7
+ export default class AccessLevelsUpdate extends Command {
8
+ static args: {
9
+ access_level_id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
10
+ };
11
+ static description: string;
12
+ static enableJsonFlag: boolean;
13
+ static examples: string[];
14
+ static flags: {
15
+ title: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
16
+ app: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
17
+ };
18
+ run(): Promise<AccessLevelResponse>;
19
+ }
20
+ export {};
@@ -0,0 +1,32 @@
1
+ import { Args, Command, Flags } from '@oclif/core';
2
+ import { createAuthenticatedClient } from '../../lib/client-from-config.js';
3
+ import { appFlag, isValidUuid } from '../../lib/flags.js';
4
+ export default class AccessLevelsUpdate extends Command {
5
+ static args = {
6
+ access_level_id: Args.string({ description: 'Access Level ID (UUID)', required: true }),
7
+ };
8
+ static description = 'Update an access level';
9
+ static enableJsonFlag = true;
10
+ static examples = [
11
+ '<%= config.bin %> access-levels update --app UUID 550e8400-... --title "VIP Access"',
12
+ ];
13
+ static flags = {
14
+ ...appFlag,
15
+ title: Flags.string({ description: 'Access level title', required: true }),
16
+ };
17
+ async run() {
18
+ const { args, flags } = await this.parse(AccessLevelsUpdate);
19
+ if (!isValidUuid(args.access_level_id)) {
20
+ this.error('Invalid access level ID format.', { exit: 2 });
21
+ }
22
+ const client = await createAuthenticatedClient(this.config);
23
+ const result = await client.put(`/apps/${flags.app}/access-levels/${args.access_level_id}`, {
24
+ title: flags.title,
25
+ });
26
+ this.log('Access level updated!');
27
+ this.log(`ID: ${result.id}`);
28
+ this.log(`SDK ID: ${result.sdk_id}`);
29
+ this.log(`Title: ${result.title}`);
30
+ return result;
31
+ }
32
+ }
@@ -0,0 +1,25 @@
1
+ import { Command } from '@oclif/core';
2
+ interface AppCreateResponse {
3
+ app: {
4
+ id: string;
5
+ name: string;
6
+ sdk_key: string;
7
+ };
8
+ default_access_level: {
9
+ id: string;
10
+ sdk_id: string;
11
+ };
12
+ }
13
+ export default class AppsCreate extends Command {
14
+ static description: string;
15
+ static enableJsonFlag: boolean;
16
+ static examples: string[];
17
+ static flags: {
18
+ 'android-bundle-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
19
+ 'ios-bundle-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
20
+ name: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
21
+ platform: import("@oclif/core/interfaces").OptionFlag<string[], import("@oclif/core/interfaces").CustomOptions>;
22
+ };
23
+ run(): Promise<AppCreateResponse>;
24
+ }
25
+ export {};
@@ -0,0 +1,47 @@
1
+ import { Command, Flags } from '@oclif/core';
2
+ import { createAuthenticatedClient } from '../../lib/client-from-config.js';
3
+ export default class AppsCreate extends Command {
4
+ static description = 'Create a new Adapty app';
5
+ static enableJsonFlag = true;
6
+ static examples = [
7
+ '<%= config.bin %> apps create --name "My App" --platform ios --ios-bundle-id com.example.app',
8
+ '<%= config.bin %> apps create --name "My App" --platform ios --platform android --ios-bundle-id com.example.app --android-bundle-id com.example.app',
9
+ ];
10
+ static flags = {
11
+ 'android-bundle-id': Flags.string({ description: 'Android bundle ID (required with --platform android)' }),
12
+ 'ios-bundle-id': Flags.string({ description: 'iOS bundle ID (required with --platform ios)' }),
13
+ name: Flags.string({ description: 'App name', required: true }),
14
+ platform: Flags.string({
15
+ description: 'Platform (ios, android). Repeat for multiple.',
16
+ multiple: true,
17
+ options: ['ios', 'android'],
18
+ required: true,
19
+ }),
20
+ };
21
+ async run() {
22
+ const { flags } = await this.parse(AppsCreate);
23
+ if (flags.platform.includes('ios') && !flags['ios-bundle-id']) {
24
+ this.error('--ios-bundle-id is required when --platform ios is specified', { exit: 2 });
25
+ }
26
+ if (flags.platform.includes('android') && !flags['android-bundle-id']) {
27
+ this.error('--android-bundle-id is required when --platform android is specified', { exit: 2 });
28
+ }
29
+ const client = await createAuthenticatedClient(this.config);
30
+ const body = {
31
+ app_name: flags.name,
32
+ platforms: flags.platform,
33
+ };
34
+ if (flags['ios-bundle-id'])
35
+ body.ios_bundle_id = flags['ios-bundle-id'];
36
+ if (flags['android-bundle-id'])
37
+ body.android_bundle_id = flags['android-bundle-id'];
38
+ const result = await client.post('/apps', body);
39
+ this.log('App created!');
40
+ this.log(`ID: ${result.app.id}`);
41
+ this.log(`Name: ${result.app.name}`);
42
+ this.log(`SDK Key: ${result.app.sdk_key}`);
43
+ this.log(`Default Access Level ID: ${result.default_access_level.id}`);
44
+ this.log(`Default Access Level SDK ID: ${result.default_access_level.sdk_id}`);
45
+ return result;
46
+ }
47
+ }
@@ -0,0 +1,20 @@
1
+ import { Command } from '@oclif/core';
2
+ interface AppDetailResponse {
3
+ android_bundle_id?: string;
4
+ id: string;
5
+ ios_bundle_id?: string;
6
+ name: string;
7
+ platforms: string[];
8
+ sdk_key: string;
9
+ secret_key: string;
10
+ }
11
+ export default class AppsGet extends Command {
12
+ static args: {
13
+ app_id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
14
+ };
15
+ static description: string;
16
+ static enableJsonFlag: boolean;
17
+ static examples: string[];
18
+ run(): Promise<AppDetailResponse>;
19
+ }
20
+ export {};
@@ -0,0 +1,29 @@
1
+ import { Args, Command } from '@oclif/core';
2
+ import { createAuthenticatedClient } from '../../lib/client-from-config.js';
3
+ import { isValidUuid } from '../../lib/flags.js';
4
+ export default class AppsGet extends Command {
5
+ static args = {
6
+ app_id: Args.string({ description: 'App ID (UUID)', required: true }),
7
+ };
8
+ static description = 'Get app details';
9
+ static enableJsonFlag = true;
10
+ static examples = ['<%= config.bin %> apps get 550e8400-e29b-41d4-a716-446655440000'];
11
+ async run() {
12
+ const { args } = await this.parse(AppsGet);
13
+ if (!isValidUuid(args.app_id)) {
14
+ this.error('Invalid app ID format. Run `adapty apps list` to find your app ID.', { exit: 2 });
15
+ }
16
+ const client = await createAuthenticatedClient(this.config);
17
+ const result = await client.get(`/apps/${args.app_id}`);
18
+ this.log(`ID: ${result.id}`);
19
+ this.log(`Name: ${result.name}`);
20
+ this.log(`SDK Key: ${result.sdk_key}`);
21
+ this.log(`Secret Key: ${result.secret_key}`);
22
+ this.log(`Platforms: ${result.platforms.join(', ')}`);
23
+ if (result.ios_bundle_id)
24
+ this.log(`iOS Bundle ID: ${result.ios_bundle_id}`);
25
+ if (result.android_bundle_id)
26
+ this.log(`Android Bundle ID: ${result.android_bundle_id}`);
27
+ return result;
28
+ }
29
+ }
@@ -0,0 +1,18 @@
1
+ import { Command } from '@oclif/core';
2
+ import { type PaginatedResponse } from '../../lib/flags.js';
3
+ interface AppItem {
4
+ id: string;
5
+ name: string;
6
+ sdk_key: string;
7
+ }
8
+ export default class AppsList extends Command {
9
+ static description: string;
10
+ static enableJsonFlag: boolean;
11
+ static examples: string[];
12
+ static flags: {
13
+ page: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
14
+ 'page-size': import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
15
+ };
16
+ run(): Promise<PaginatedResponse<AppItem>>;
17
+ }
18
+ export {};
@@ -0,0 +1,19 @@
1
+ import { Command } from '@oclif/core';
2
+ import { createAuthenticatedClient } from '../../lib/client-from-config.js';
3
+ import { paginationFlags, paginationParams } from '../../lib/flags.js';
4
+ import { printList } from '../../lib/output.js';
5
+ export default class AppsList extends Command {
6
+ static description = 'List Adapty apps';
7
+ static enableJsonFlag = true;
8
+ static examples = ['<%= config.bin %> apps list', '<%= config.bin %> apps list --page 2 --page-size 10'];
9
+ static flags = {
10
+ ...paginationFlags,
11
+ };
12
+ async run() {
13
+ const { flags } = await this.parse(AppsList);
14
+ const client = await createAuthenticatedClient(this.config);
15
+ const result = await client.get('/apps', paginationParams(flags));
16
+ printList(result.data.map((app) => ({ ID: app.id, Name: app.name, 'SDK Key': app.sdk_key })), this.log.bind(this), result.meta.pagination);
17
+ return result;
18
+ }
19
+ }
@@ -0,0 +1,22 @@
1
+ import { Command } from '@oclif/core';
2
+ interface AppResponse {
3
+ android_bundle_id?: string;
4
+ id: string;
5
+ ios_bundle_id?: string;
6
+ name: string;
7
+ }
8
+ export default class AppsUpdate extends Command {
9
+ static args: {
10
+ app_id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
11
+ };
12
+ static description: string;
13
+ static enableJsonFlag: boolean;
14
+ static examples: string[];
15
+ static flags: {
16
+ 'android-bundle-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
17
+ 'ios-bundle-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
18
+ name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
19
+ };
20
+ run(): Promise<AppResponse>;
21
+ }
22
+ export {};
@@ -0,0 +1,42 @@
1
+ import { Args, Command, Flags } from '@oclif/core';
2
+ import { createAuthenticatedClient } from '../../lib/client-from-config.js';
3
+ import { isValidUuid } from '../../lib/flags.js';
4
+ export default class AppsUpdate extends Command {
5
+ static args = {
6
+ app_id: Args.string({ description: 'App ID (UUID)', required: true }),
7
+ };
8
+ static description = 'Update an app';
9
+ static enableJsonFlag = true;
10
+ static examples = ['<%= config.bin %> apps update 550e8400-... --name "My App"'];
11
+ static flags = {
12
+ 'android-bundle-id': Flags.string({ description: 'Android bundle ID' }),
13
+ 'ios-bundle-id': Flags.string({ description: 'iOS bundle ID' }),
14
+ name: Flags.string({ description: 'App name' }),
15
+ };
16
+ async run() {
17
+ const { args, flags } = await this.parse(AppsUpdate);
18
+ if (!isValidUuid(args.app_id)) {
19
+ this.error('Invalid app ID format. Run `adapty apps list` to find your app ID.', { exit: 2 });
20
+ }
21
+ if (!flags.name && !flags['ios-bundle-id'] && !flags['android-bundle-id']) {
22
+ this.error('At least one of --name, --ios-bundle-id, or --android-bundle-id is required', { exit: 2 });
23
+ }
24
+ const client = await createAuthenticatedClient(this.config);
25
+ const body = {};
26
+ if (flags.name)
27
+ body.name = flags.name;
28
+ if (flags['ios-bundle-id'])
29
+ body.ios_bundle_id = flags['ios-bundle-id'];
30
+ if (flags['android-bundle-id'])
31
+ body.android_bundle_id = flags['android-bundle-id'];
32
+ const result = await client.put(`/apps/${args.app_id}`, body);
33
+ this.log('App updated!');
34
+ this.log(`ID: ${result.id}`);
35
+ this.log(`Name: ${result.name}`);
36
+ if (result.ios_bundle_id)
37
+ this.log(`iOS Bundle ID: ${result.ios_bundle_id}`);
38
+ if (result.android_bundle_id)
39
+ this.log(`Android Bundle ID: ${result.android_bundle_id}`);
40
+ return result;
41
+ }
42
+ }
@@ -0,0 +1,6 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class AuthLogin extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ run(): Promise<void>;
6
+ }