adapty 0.1.2 → 0.1.3
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 +4 -3
- package/dist/commands/access-levels/create.d.ts +1 -7
- package/dist/commands/access-levels/create.js +2 -3
- package/dist/commands/access-levels/get.js +2 -3
- package/dist/commands/access-levels/list.js +1 -1
- package/dist/commands/access-levels/update.d.ts +1 -7
- package/dist/commands/access-levels/update.js +2 -3
- package/dist/commands/apps/create.d.ts +4 -16
- package/dist/commands/apps/create.js +27 -19
- package/dist/commands/apps/get.d.ts +3 -3
- package/dist/commands/apps/get.js +2 -9
- package/dist/commands/apps/list.d.ts +1 -1
- package/dist/commands/apps/list.js +1 -1
- package/dist/commands/apps/update.d.ts +6 -6
- package/dist/commands/apps/update.js +14 -18
- package/dist/commands/auth/login.js +2 -1
- package/dist/commands/auth/revoke.d.ts +9 -0
- package/dist/commands/auth/revoke.js +21 -0
- package/dist/commands/auth/whoami.d.ts +1 -10
- package/dist/commands/auth/whoami.js +2 -8
- package/dist/commands/paywalls/create.d.ts +2 -7
- package/dist/commands/paywalls/create.js +5 -5
- package/dist/commands/paywalls/get.d.ts +1 -1
- package/dist/commands/paywalls/get.js +2 -3
- package/dist/commands/paywalls/list.d.ts +1 -1
- package/dist/commands/paywalls/list.js +1 -1
- package/dist/commands/paywalls/update.d.ts +2 -7
- package/dist/commands/paywalls/update.js +5 -5
- package/dist/commands/placements/create.d.ts +2 -8
- package/dist/commands/placements/create.js +5 -6
- package/dist/commands/placements/get.d.ts +1 -1
- package/dist/commands/placements/get.js +2 -4
- package/dist/commands/placements/list.d.ts +1 -1
- package/dist/commands/placements/list.js +1 -1
- package/dist/commands/placements/update.d.ts +2 -8
- package/dist/commands/placements/update.js +5 -6
- package/dist/commands/products/create.d.ts +2 -19
- package/dist/commands/products/create.js +7 -14
- package/dist/commands/products/get.d.ts +2 -13
- package/dist/commands/products/get.js +2 -11
- package/dist/commands/products/list.d.ts +2 -13
- package/dist/commands/products/list.js +1 -12
- package/dist/commands/products/update.d.ts +2 -23
- package/dist/commands/products/update.js +6 -37
- package/dist/lib/output.d.ts +1 -1
- package/dist/lib/output.js +35 -4
- package/oclif.manifest.json +183 -180
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -29,7 +29,8 @@ Other auth commands:
|
|
|
29
29
|
```sh
|
|
30
30
|
adapty auth whoami # verify token, show user info
|
|
31
31
|
adapty auth status # show local auth state
|
|
32
|
-
adapty auth logout # clear stored token
|
|
32
|
+
adapty auth logout # clear stored token (local only)
|
|
33
|
+
adapty auth revoke # revoke token server-side and clear local
|
|
33
34
|
```
|
|
34
35
|
|
|
35
36
|
## Commands
|
|
@@ -41,7 +42,7 @@ All resource commands require `--app APP_ID` (UUID). Use `adapty apps list` to f
|
|
|
41
42
|
```sh
|
|
42
43
|
adapty apps list [--page N] [--page-size N]
|
|
43
44
|
adapty apps get APP_ID
|
|
44
|
-
adapty apps create --
|
|
45
|
+
adapty apps create --title "My App" --platform ios --apple-bundle-id com.example.app
|
|
45
46
|
adapty apps update APP_ID [flags]
|
|
46
47
|
```
|
|
47
48
|
|
|
@@ -59,7 +60,7 @@ adapty products update --app UUID PRODUCT_ID [flags]
|
|
|
59
60
|
```sh
|
|
60
61
|
adapty paywalls list --app UUID [--page N] [--page-size N]
|
|
61
62
|
adapty paywalls get --app UUID PAYWALL_ID
|
|
62
|
-
adapty paywalls create --app UUID --
|
|
63
|
+
adapty paywalls create --app UUID --title "Name" --product-id UUID1 [--product-id UUID2]
|
|
63
64
|
adapty paywalls update --app UUID PAYWALL_ID [flags]
|
|
64
65
|
```
|
|
65
66
|
|
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
|
-
interface AccessLevelResponse {
|
|
3
|
-
id: string;
|
|
4
|
-
sdk_id: string;
|
|
5
|
-
title: string;
|
|
6
|
-
}
|
|
7
2
|
export default class AccessLevelsCreate extends Command {
|
|
8
3
|
static description: string;
|
|
9
4
|
static enableJsonFlag: boolean;
|
|
@@ -13,6 +8,5 @@ export default class AccessLevelsCreate extends Command {
|
|
|
13
8
|
title: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
9
|
app: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
10
|
};
|
|
16
|
-
run(): Promise<
|
|
11
|
+
run(): Promise<Record<string, unknown>>;
|
|
17
12
|
}
|
|
18
|
-
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Command, Flags } from '@oclif/core';
|
|
2
2
|
import { createAuthenticatedClient } from '../../lib/client-from-config.js';
|
|
3
3
|
import { appFlag } from '../../lib/flags.js';
|
|
4
|
+
import { printResponse } from '../../lib/output.js';
|
|
4
5
|
export default class AccessLevelsCreate extends Command {
|
|
5
6
|
static description = 'Create a custom access level';
|
|
6
7
|
static enableJsonFlag = true;
|
|
@@ -20,9 +21,7 @@ export default class AccessLevelsCreate extends Command {
|
|
|
20
21
|
title: flags.title,
|
|
21
22
|
});
|
|
22
23
|
this.log('Access level created!');
|
|
23
|
-
this.log(
|
|
24
|
-
this.log(`SDK ID: ${result.sdk_id}`);
|
|
25
|
-
this.log(`Title: ${result.title}`);
|
|
24
|
+
printResponse(result, this.log.bind(this));
|
|
26
25
|
return result;
|
|
27
26
|
}
|
|
28
27
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Args, Command } from '@oclif/core';
|
|
2
2
|
import { createAuthenticatedClient } from '../../lib/client-from-config.js';
|
|
3
3
|
import { appFlag, isValidUuid } from '../../lib/flags.js';
|
|
4
|
+
import { printResponse } from '../../lib/output.js';
|
|
4
5
|
export default class AccessLevelsGet extends Command {
|
|
5
6
|
static args = {
|
|
6
7
|
access_level_id: Args.string({ description: 'Access Level ID (UUID)', required: true }),
|
|
@@ -18,9 +19,7 @@ export default class AccessLevelsGet extends Command {
|
|
|
18
19
|
}
|
|
19
20
|
const client = await createAuthenticatedClient(this.config);
|
|
20
21
|
const result = await client.get(`/apps/${flags.app}/access-levels/${args.access_level_id}`);
|
|
21
|
-
this.log(
|
|
22
|
-
this.log(`SDK ID: ${result.sdk_id}`);
|
|
23
|
-
this.log(`Title: ${result.title}`);
|
|
22
|
+
printResponse(result, this.log.bind(this));
|
|
24
23
|
return result;
|
|
25
24
|
}
|
|
26
25
|
}
|
|
@@ -14,7 +14,7 @@ export default class AccessLevelsList extends Command {
|
|
|
14
14
|
const { flags } = await this.parse(AccessLevelsList);
|
|
15
15
|
const client = await createAuthenticatedClient(this.config);
|
|
16
16
|
const result = await client.get(`/apps/${flags.app}/access-levels`, paginationParams(flags));
|
|
17
|
-
printList(result.data
|
|
17
|
+
printList(result.data, this.log.bind(this), result.meta.pagination);
|
|
18
18
|
return result;
|
|
19
19
|
}
|
|
20
20
|
}
|
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
|
-
interface AccessLevelResponse {
|
|
3
|
-
id: string;
|
|
4
|
-
sdk_id: string;
|
|
5
|
-
title: string;
|
|
6
|
-
}
|
|
7
2
|
export default class AccessLevelsUpdate extends Command {
|
|
8
3
|
static args: {
|
|
9
4
|
access_level_id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
@@ -15,6 +10,5 @@ export default class AccessLevelsUpdate extends Command {
|
|
|
15
10
|
title: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
11
|
app: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
12
|
};
|
|
18
|
-
run(): Promise<
|
|
13
|
+
run(): Promise<Record<string, unknown>>;
|
|
19
14
|
}
|
|
20
|
-
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Args, Command, Flags } from '@oclif/core';
|
|
2
2
|
import { createAuthenticatedClient } from '../../lib/client-from-config.js';
|
|
3
3
|
import { appFlag, isValidUuid } from '../../lib/flags.js';
|
|
4
|
+
import { printResponse } from '../../lib/output.js';
|
|
4
5
|
export default class AccessLevelsUpdate extends Command {
|
|
5
6
|
static args = {
|
|
6
7
|
access_level_id: Args.string({ description: 'Access Level ID (UUID)', required: true }),
|
|
@@ -24,9 +25,7 @@ export default class AccessLevelsUpdate extends Command {
|
|
|
24
25
|
title: flags.title,
|
|
25
26
|
});
|
|
26
27
|
this.log('Access level updated!');
|
|
27
|
-
this.log(
|
|
28
|
-
this.log(`SDK ID: ${result.sdk_id}`);
|
|
29
|
-
this.log(`Title: ${result.title}`);
|
|
28
|
+
printResponse(result, this.log.bind(this));
|
|
30
29
|
return result;
|
|
31
30
|
}
|
|
32
31
|
}
|
|
@@ -1,25 +1,13 @@
|
|
|
1
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
2
|
export default class AppsCreate extends Command {
|
|
14
3
|
static description: string;
|
|
15
4
|
static enableJsonFlag: boolean;
|
|
16
5
|
static examples: string[];
|
|
17
6
|
static flags: {
|
|
18
|
-
'
|
|
19
|
-
'
|
|
20
|
-
name: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
'apple-bundle-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
'google-bundle-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
21
9
|
platform: import("@oclif/core/interfaces").OptionFlag<string[], import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
title: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
22
11
|
};
|
|
23
|
-
run(): Promise<
|
|
12
|
+
run(): Promise<Record<string, unknown>>;
|
|
24
13
|
}
|
|
25
|
-
export {};
|
|
@@ -1,47 +1,55 @@
|
|
|
1
1
|
import { Command, Flags } from '@oclif/core';
|
|
2
2
|
import { createAuthenticatedClient } from '../../lib/client-from-config.js';
|
|
3
|
+
import { printResponse } from '../../lib/output.js';
|
|
3
4
|
export default class AppsCreate extends Command {
|
|
4
5
|
static description = 'Create a new Adapty app';
|
|
5
6
|
static enableJsonFlag = true;
|
|
6
7
|
static examples = [
|
|
7
|
-
'<%= config.bin %> apps create --
|
|
8
|
-
'<%= config.bin %> apps create --
|
|
8
|
+
'<%= config.bin %> apps create --title "My App" --platform ios --apple-bundle-id com.example.app',
|
|
9
|
+
'<%= config.bin %> apps create --title "My App" --platform ios --platform android --apple-bundle-id com.example.app --google-bundle-id com.example.app',
|
|
9
10
|
];
|
|
10
11
|
static flags = {
|
|
11
|
-
'
|
|
12
|
-
'
|
|
13
|
-
name: Flags.string({ description: 'App name', required: true }),
|
|
12
|
+
'apple-bundle-id': Flags.string({ description: 'Apple bundle ID (required with --platform ios)' }),
|
|
13
|
+
'google-bundle-id': Flags.string({ description: 'Google bundle ID (required with --platform android)' }),
|
|
14
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
21
|
};
|
|
21
22
|
async run() {
|
|
22
23
|
const { flags } = await this.parse(AppsCreate);
|
|
23
|
-
if (flags.platform.includes('ios') && !flags['
|
|
24
|
-
this.error('--
|
|
24
|
+
if (flags.platform.includes('ios') && !flags['apple-bundle-id']) {
|
|
25
|
+
this.error('--apple-bundle-id is required when --platform ios is specified', { exit: 2 });
|
|
25
26
|
}
|
|
26
|
-
if (flags.platform.includes('android') && !flags['
|
|
27
|
-
this.error('--
|
|
27
|
+
if (flags.platform.includes('android') && !flags['google-bundle-id']) {
|
|
28
|
+
this.error('--google-bundle-id is required when --platform android is specified', { exit: 2 });
|
|
28
29
|
}
|
|
29
30
|
const client = await createAuthenticatedClient(this.config);
|
|
30
31
|
const body = {
|
|
31
|
-
app_name: flags.name,
|
|
32
32
|
platforms: flags.platform,
|
|
33
|
+
title: flags.title,
|
|
33
34
|
};
|
|
34
|
-
if (flags['
|
|
35
|
-
body.
|
|
36
|
-
if (flags['
|
|
37
|
-
body.
|
|
35
|
+
if (flags['apple-bundle-id'])
|
|
36
|
+
body.apple_bundle_id = flags['apple-bundle-id'];
|
|
37
|
+
if (flags['google-bundle-id'])
|
|
38
|
+
body.google_bundle_id = flags['google-bundle-id'];
|
|
38
39
|
const result = await client.post('/apps', body);
|
|
39
40
|
this.log('App created!');
|
|
40
|
-
this.log(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
printResponse(result, this.log.bind(this));
|
|
42
|
+
// Fetch default access level for the new app
|
|
43
|
+
try {
|
|
44
|
+
const accessLevels = await client.get(`/apps/${result.id}/access-levels`);
|
|
45
|
+
if (accessLevels.items?.length > 0) {
|
|
46
|
+
this.log('\nDefault access level:');
|
|
47
|
+
printResponse(accessLevels.items[0], this.log.bind(this));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
this.warn('Could not fetch access levels for new app');
|
|
52
|
+
}
|
|
45
53
|
return result;
|
|
46
54
|
}
|
|
47
55
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
2
|
interface AppDetailResponse {
|
|
3
|
-
|
|
3
|
+
apple_bundle_id?: string;
|
|
4
|
+
google_bundle_id?: string;
|
|
4
5
|
id: string;
|
|
5
|
-
ios_bundle_id?: string;
|
|
6
|
-
name: string;
|
|
7
6
|
platforms: string[];
|
|
8
7
|
sdk_key: string;
|
|
9
8
|
secret_key: string;
|
|
9
|
+
title: string;
|
|
10
10
|
}
|
|
11
11
|
export default class AppsGet extends Command {
|
|
12
12
|
static args: {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Args, Command } from '@oclif/core';
|
|
2
2
|
import { createAuthenticatedClient } from '../../lib/client-from-config.js';
|
|
3
3
|
import { isValidUuid } from '../../lib/flags.js';
|
|
4
|
+
import { printResponse } from '../../lib/output.js';
|
|
4
5
|
export default class AppsGet extends Command {
|
|
5
6
|
static args = {
|
|
6
7
|
app_id: Args.string({ description: 'App ID (UUID)', required: true }),
|
|
@@ -15,15 +16,7 @@ export default class AppsGet extends Command {
|
|
|
15
16
|
}
|
|
16
17
|
const client = await createAuthenticatedClient(this.config);
|
|
17
18
|
const result = await client.get(`/apps/${args.app_id}`);
|
|
18
|
-
this.log(
|
|
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}`);
|
|
19
|
+
printResponse(result, this.log.bind(this));
|
|
27
20
|
return result;
|
|
28
21
|
}
|
|
29
22
|
}
|
|
@@ -2,8 +2,8 @@ import { Command } from '@oclif/core';
|
|
|
2
2
|
import { type PaginatedResponse } from '../../lib/flags.js';
|
|
3
3
|
interface AppItem {
|
|
4
4
|
id: string;
|
|
5
|
-
name: string;
|
|
6
5
|
sdk_key: string;
|
|
6
|
+
title: string;
|
|
7
7
|
}
|
|
8
8
|
export default class AppsList extends Command {
|
|
9
9
|
static description: string;
|
|
@@ -13,7 +13,7 @@ export default class AppsList extends Command {
|
|
|
13
13
|
const { flags } = await this.parse(AppsList);
|
|
14
14
|
const client = await createAuthenticatedClient(this.config);
|
|
15
15
|
const result = await client.get('/apps', paginationParams(flags));
|
|
16
|
-
printList(result.data
|
|
16
|
+
printList(result.data, this.log.bind(this), result.meta.pagination);
|
|
17
17
|
return result;
|
|
18
18
|
}
|
|
19
19
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
2
|
interface AppResponse {
|
|
3
|
-
|
|
3
|
+
apple_bundle_id?: string;
|
|
4
|
+
google_bundle_id?: string;
|
|
4
5
|
id: string;
|
|
5
|
-
|
|
6
|
-
name: string;
|
|
6
|
+
title: string;
|
|
7
7
|
}
|
|
8
8
|
export default class AppsUpdate extends Command {
|
|
9
9
|
static args: {
|
|
@@ -13,9 +13,9 @@ export default class AppsUpdate extends Command {
|
|
|
13
13
|
static enableJsonFlag: boolean;
|
|
14
14
|
static examples: string[];
|
|
15
15
|
static flags: {
|
|
16
|
-
'
|
|
17
|
-
'
|
|
18
|
-
|
|
16
|
+
'apple-bundle-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
|
+
'google-bundle-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
18
|
+
title: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
19
19
|
};
|
|
20
20
|
run(): Promise<AppResponse>;
|
|
21
21
|
}
|
|
@@ -1,42 +1,38 @@
|
|
|
1
1
|
import { Args, Command, Flags } from '@oclif/core';
|
|
2
2
|
import { createAuthenticatedClient } from '../../lib/client-from-config.js';
|
|
3
3
|
import { isValidUuid } from '../../lib/flags.js';
|
|
4
|
+
import { printResponse } from '../../lib/output.js';
|
|
4
5
|
export default class AppsUpdate extends Command {
|
|
5
6
|
static args = {
|
|
6
7
|
app_id: Args.string({ description: 'App ID (UUID)', required: true }),
|
|
7
8
|
};
|
|
8
9
|
static description = 'Update an app';
|
|
9
10
|
static enableJsonFlag = true;
|
|
10
|
-
static examples = ['<%= config.bin %> apps update 550e8400-... --
|
|
11
|
+
static examples = ['<%= config.bin %> apps update 550e8400-... --title "My App"'];
|
|
11
12
|
static flags = {
|
|
12
|
-
'
|
|
13
|
-
'
|
|
14
|
-
|
|
13
|
+
'apple-bundle-id': Flags.string({ description: 'Apple bundle ID' }),
|
|
14
|
+
'google-bundle-id': Flags.string({ description: 'Google bundle ID' }),
|
|
15
|
+
title: Flags.string({ description: 'App title' }),
|
|
15
16
|
};
|
|
16
17
|
async run() {
|
|
17
18
|
const { args, flags } = await this.parse(AppsUpdate);
|
|
18
19
|
if (!isValidUuid(args.app_id)) {
|
|
19
20
|
this.error('Invalid app ID format. Run `adapty apps list` to find your app ID.', { exit: 2 });
|
|
20
21
|
}
|
|
21
|
-
if (!flags.
|
|
22
|
-
this.error('At least one of --
|
|
22
|
+
if (!flags.title && !flags['apple-bundle-id'] && !flags['google-bundle-id']) {
|
|
23
|
+
this.error('At least one of --title, --apple-bundle-id, or --google-bundle-id is required', { exit: 2 });
|
|
23
24
|
}
|
|
24
25
|
const client = await createAuthenticatedClient(this.config);
|
|
25
26
|
const body = {};
|
|
26
|
-
if (flags.
|
|
27
|
-
body.
|
|
28
|
-
if (flags['
|
|
29
|
-
body.
|
|
30
|
-
if (flags['
|
|
31
|
-
body.
|
|
27
|
+
if (flags.title)
|
|
28
|
+
body.title = flags.title;
|
|
29
|
+
if (flags['apple-bundle-id'])
|
|
30
|
+
body.apple_bundle_id = flags['apple-bundle-id'];
|
|
31
|
+
if (flags['google-bundle-id'])
|
|
32
|
+
body.google_bundle_id = flags['google-bundle-id'];
|
|
32
33
|
const result = await client.put(`/apps/${args.app_id}`, body);
|
|
33
34
|
this.log('App updated!');
|
|
34
|
-
this.log(
|
|
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}`);
|
|
35
|
+
printResponse(result, this.log.bind(this));
|
|
40
36
|
return result;
|
|
41
37
|
}
|
|
42
38
|
}
|
|
@@ -36,7 +36,7 @@ export default class AuthLogin extends Command {
|
|
|
36
36
|
// browser open failed silently — URL already printed
|
|
37
37
|
}
|
|
38
38
|
this.log('Waiting for authorization...');
|
|
39
|
-
let interval = Math.max((device.
|
|
39
|
+
let interval = Math.max((device.interval_seconds || 5) * 1000, 5000);
|
|
40
40
|
const deadline = Date.now() + device.expires_in * 1000;
|
|
41
41
|
let consecutiveErrors = 0;
|
|
42
42
|
// Handle Ctrl+C
|
|
@@ -51,6 +51,7 @@ export default class AuthLogin extends Command {
|
|
|
51
51
|
let result;
|
|
52
52
|
try {
|
|
53
53
|
result = await client.post('/auth/token', {
|
|
54
|
+
client_id: 'adapty-cli',
|
|
54
55
|
device_code: device.device_code,
|
|
55
56
|
grant_type: 'urn:ietf:params:oauth:grant-type:device_code',
|
|
56
57
|
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
import { createAuthenticatedClient } from '../../lib/client-from-config.js';
|
|
3
|
+
import { readConfig, writeConfig } from '../../lib/config.js';
|
|
4
|
+
export default class AuthRevoke extends Command {
|
|
5
|
+
static description = 'Revoke the current authentication token';
|
|
6
|
+
static enableJsonFlag = true;
|
|
7
|
+
static examples = ['<%= config.bin %> auth revoke'];
|
|
8
|
+
async run() {
|
|
9
|
+
await this.parse(AuthRevoke);
|
|
10
|
+
const config = await readConfig(this.config.configDir);
|
|
11
|
+
if (!config.access_token) {
|
|
12
|
+
this.log('Not currently authenticated.');
|
|
13
|
+
return { status: 'not_authenticated' };
|
|
14
|
+
}
|
|
15
|
+
const client = await createAuthenticatedClient(this.config);
|
|
16
|
+
await client.post('/auth/tokens/revoke', { token: config.access_token });
|
|
17
|
+
await writeConfig({}, this.config.configDir);
|
|
18
|
+
this.log('Token revoked and logged out.');
|
|
19
|
+
return { status: 'revoked' };
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -1,16 +1,7 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
|
-
interface MeResponse {
|
|
3
|
-
companies: Array<{
|
|
4
|
-
id: string;
|
|
5
|
-
title: string;
|
|
6
|
-
}>;
|
|
7
|
-
email: string;
|
|
8
|
-
name: string;
|
|
9
|
-
}
|
|
10
2
|
export default class AuthWhoami extends Command {
|
|
11
3
|
static description: string;
|
|
12
4
|
static enableJsonFlag: boolean;
|
|
13
5
|
static examples: string[];
|
|
14
|
-
run(): Promise<
|
|
6
|
+
run(): Promise<Record<string, unknown>>;
|
|
15
7
|
}
|
|
16
|
-
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
2
|
import { createAuthenticatedClient } from '../../lib/client-from-config.js';
|
|
3
|
+
import { printResponse } from '../../lib/output.js';
|
|
3
4
|
export default class AuthWhoami extends Command {
|
|
4
5
|
static description = 'Show current user info from server (verifies token)';
|
|
5
6
|
static enableJsonFlag = true;
|
|
@@ -8,14 +9,7 @@ export default class AuthWhoami extends Command {
|
|
|
8
9
|
await this.parse(AuthWhoami);
|
|
9
10
|
const client = await createAuthenticatedClient(this.config);
|
|
10
11
|
const me = await client.get('/me');
|
|
11
|
-
this.log(
|
|
12
|
-
this.log(`Name: ${me.name}`);
|
|
13
|
-
if (me.companies.length > 0) {
|
|
14
|
-
this.log('Companies:');
|
|
15
|
-
for (const company of me.companies) {
|
|
16
|
-
this.log(` ${company.title} (${company.id})`);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
12
|
+
printResponse(me, this.log.bind(this));
|
|
19
13
|
return me;
|
|
20
14
|
}
|
|
21
15
|
}
|
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
|
-
interface PaywallResponse {
|
|
3
|
-
id: string;
|
|
4
|
-
name: string;
|
|
5
|
-
}
|
|
6
2
|
export default class PaywallsCreate extends Command {
|
|
7
3
|
static description: string;
|
|
8
4
|
static enableJsonFlag: boolean;
|
|
9
5
|
static examples: string[];
|
|
10
6
|
static flags: {
|
|
11
|
-
name: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
7
|
'product-id': import("@oclif/core/interfaces").OptionFlag<string[], import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
title: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
9
|
app: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
10
|
};
|
|
15
|
-
run(): Promise<
|
|
11
|
+
run(): Promise<Record<string, unknown>>;
|
|
16
12
|
}
|
|
17
|
-
export {};
|
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
import { Command, Flags } from '@oclif/core';
|
|
2
2
|
import { createAuthenticatedClient } from '../../lib/client-from-config.js';
|
|
3
3
|
import { appFlag } from '../../lib/flags.js';
|
|
4
|
+
import { printResponse } from '../../lib/output.js';
|
|
4
5
|
export default class PaywallsCreate extends Command {
|
|
5
6
|
static description = 'Create a paywall with products';
|
|
6
7
|
static enableJsonFlag = true;
|
|
7
8
|
static examples = [
|
|
8
|
-
'<%= config.bin %> paywalls create --app UUID --
|
|
9
|
+
'<%= config.bin %> paywalls create --app UUID --title "Default Paywall" --product-id UUID1 --product-id UUID2',
|
|
9
10
|
];
|
|
10
11
|
static flags = {
|
|
11
12
|
...appFlag,
|
|
12
|
-
name: Flags.string({ description: 'Paywall name', required: true }),
|
|
13
13
|
'product-id': Flags.string({
|
|
14
14
|
description: 'Product ID (UUID). Repeat for multiple.',
|
|
15
15
|
multiple: true,
|
|
16
16
|
required: true,
|
|
17
17
|
}),
|
|
18
|
+
title: Flags.string({ description: 'Paywall title', required: true }),
|
|
18
19
|
};
|
|
19
20
|
async run() {
|
|
20
21
|
const { flags } = await this.parse(PaywallsCreate);
|
|
21
22
|
const client = await createAuthenticatedClient(this.config);
|
|
22
23
|
const result = await client.post(`/apps/${flags.app}/paywalls`, {
|
|
23
|
-
name: flags.name,
|
|
24
24
|
product_ids: flags['product-id'],
|
|
25
|
+
title: flags.title,
|
|
25
26
|
});
|
|
26
27
|
this.log('Paywall created!');
|
|
27
|
-
this.log(
|
|
28
|
-
this.log(`Name: ${result.name}`);
|
|
28
|
+
printResponse(result, this.log.bind(this));
|
|
29
29
|
return result;
|
|
30
30
|
}
|
|
31
31
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Args, Command } from '@oclif/core';
|
|
2
2
|
import { createAuthenticatedClient } from '../../lib/client-from-config.js';
|
|
3
3
|
import { appFlag, isValidUuid } from '../../lib/flags.js';
|
|
4
|
+
import { printResponse } from '../../lib/output.js';
|
|
4
5
|
export default class PaywallsGet extends Command {
|
|
5
6
|
static args = {
|
|
6
7
|
paywall_id: Args.string({ description: 'Paywall ID (UUID)', required: true }),
|
|
@@ -18,9 +19,7 @@ export default class PaywallsGet extends Command {
|
|
|
18
19
|
}
|
|
19
20
|
const client = await createAuthenticatedClient(this.config);
|
|
20
21
|
const result = await client.get(`/apps/${flags.app}/paywalls/${args.paywall_id}`);
|
|
21
|
-
this.log(
|
|
22
|
-
this.log(`Name: ${result.name}`);
|
|
23
|
-
this.log(`Product IDs: ${result.product_ids.join(', ')}`);
|
|
22
|
+
printResponse(result, this.log.bind(this));
|
|
24
23
|
return result;
|
|
25
24
|
}
|
|
26
25
|
}
|
|
@@ -14,7 +14,7 @@ export default class PaywallsList extends Command {
|
|
|
14
14
|
const { flags } = await this.parse(PaywallsList);
|
|
15
15
|
const client = await createAuthenticatedClient(this.config);
|
|
16
16
|
const result = await client.get(`/apps/${flags.app}/paywalls`, paginationParams(flags));
|
|
17
|
-
printList(result.data
|
|
17
|
+
printList(result.data, this.log.bind(this), result.meta.pagination);
|
|
18
18
|
return result;
|
|
19
19
|
}
|
|
20
20
|
}
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
|
-
interface PaywallResponse {
|
|
3
|
-
id: string;
|
|
4
|
-
name: string;
|
|
5
|
-
}
|
|
6
2
|
export default class PaywallsUpdate extends Command {
|
|
7
3
|
static args: {
|
|
8
4
|
paywall_id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
@@ -11,10 +7,9 @@ export default class PaywallsUpdate extends Command {
|
|
|
11
7
|
static enableJsonFlag: boolean;
|
|
12
8
|
static examples: string[];
|
|
13
9
|
static flags: {
|
|
14
|
-
name: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
10
|
'product-id': import("@oclif/core/interfaces").OptionFlag<string[], import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
title: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
12
|
app: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
13
|
};
|
|
18
|
-
run(): Promise<
|
|
14
|
+
run(): Promise<Record<string, unknown>>;
|
|
19
15
|
}
|
|
20
|
-
export {};
|