adapty 0.1.5 → 0.2.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.
- package/README.md +12 -4
- package/dist/commands/access-levels/create.d.ts +2 -1
- package/dist/commands/access-levels/create.js +3 -2
- package/dist/commands/access-levels/get.d.ts +2 -7
- package/dist/commands/access-levels/list.d.ts +2 -7
- package/dist/commands/access-levels/update.d.ts +2 -1
- package/dist/commands/access-levels/update.js +3 -2
- package/dist/commands/apps/create.d.ts +2 -1
- package/dist/commands/apps/create.js +1 -2
- package/dist/commands/apps/get.d.ts +2 -11
- package/dist/commands/apps/list.d.ts +2 -7
- package/dist/commands/apps/update.d.ts +2 -8
- package/dist/commands/paywalls/create.d.ts +2 -1
- package/dist/commands/paywalls/create.js +3 -2
- package/dist/commands/paywalls/get.d.ts +2 -7
- package/dist/commands/paywalls/list.d.ts +2 -6
- package/dist/commands/paywalls/placements.d.ts +18 -0
- package/dist/commands/paywalls/placements.js +25 -0
- package/dist/commands/paywalls/update.d.ts +2 -1
- package/dist/commands/paywalls/update.js +3 -2
- package/dist/commands/placements/create.d.ts +4 -2
- package/dist/commands/placements/create.js +29 -6
- package/dist/commands/placements/get.d.ts +2 -8
- package/dist/commands/placements/list.d.ts +2 -7
- package/dist/commands/placements/update.d.ts +4 -2
- package/dist/commands/placements/update.js +32 -6
- package/dist/commands/products/create.d.ts +2 -1
- package/dist/commands/products/create.js +9 -1
- package/dist/commands/products/get.d.ts +2 -9
- package/dist/commands/products/list.d.ts +2 -7
- package/dist/commands/products/update.d.ts +2 -1
- package/dist/commands/segments/get.d.ts +14 -0
- package/dist/commands/segments/get.js +25 -0
- package/dist/commands/segments/list.d.ts +14 -0
- package/dist/commands/segments/list.js +20 -0
- package/dist/lib/api-schemas.d.ts +99 -0
- package/dist/lib/api-schemas.js +7 -0
- package/oclif.manifest.json +284 -122
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -97,10 +97,18 @@ adapty access-levels update --app UUID ACCESS_LEVEL_ID [flags]
|
|
|
97
97
|
|
|
98
98
|
## Environment Variables
|
|
99
99
|
|
|
100
|
-
| Variable | Description
|
|
101
|
-
| ---------------- |
|
|
102
|
-
| `ADAPTY_TOKEN` | Override stored auth token
|
|
103
|
-
| `ADAPTY_API_URL` | Override API base URL (default: `https://api.adapty.io/api/v1/developer`) |
|
|
100
|
+
| Variable | Description |
|
|
101
|
+
| ---------------- | ------------------------------------------------------------------------------- |
|
|
102
|
+
| `ADAPTY_TOKEN` | Override stored auth token |
|
|
103
|
+
| `ADAPTY_API_URL` | Override API base URL (default: `https://api-admin.adapty.io/api/v1/developer`) |
|
|
104
|
+
|
|
105
|
+
## Claude Code Skill
|
|
106
|
+
|
|
107
|
+
Install the Adapty CLI skill for Claude Code:
|
|
108
|
+
|
|
109
|
+
```sh
|
|
110
|
+
npx skills add adaptyteam/adapty-cli --skill adapty-cli
|
|
111
|
+
```
|
|
104
112
|
|
|
105
113
|
## Development
|
|
106
114
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
|
+
import type { AccessLevelDTO } from '../../lib/api-schemas.js';
|
|
2
3
|
export default class AccessLevelsCreate extends Command {
|
|
3
4
|
static description: string;
|
|
4
5
|
static enableJsonFlag: boolean;
|
|
@@ -8,5 +9,5 @@ export default class AccessLevelsCreate extends Command {
|
|
|
8
9
|
title: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
10
|
app: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
11
|
};
|
|
11
|
-
run(): Promise<
|
|
12
|
+
run(): Promise<AccessLevelDTO>;
|
|
12
13
|
}
|
|
@@ -16,10 +16,11 @@ export default class AccessLevelsCreate extends Command {
|
|
|
16
16
|
async run() {
|
|
17
17
|
const { flags } = await this.parse(AccessLevelsCreate);
|
|
18
18
|
const client = await createAuthenticatedClient(this.config);
|
|
19
|
-
const
|
|
19
|
+
const body = {
|
|
20
20
|
sdk_id: flags['sdk-id'],
|
|
21
21
|
title: flags.title,
|
|
22
|
-
}
|
|
22
|
+
};
|
|
23
|
+
const result = await client.post(`/apps/${flags.app}/access-levels`, body);
|
|
23
24
|
this.log('Access level created!');
|
|
24
25
|
printResponse(result, this.log.bind(this));
|
|
25
26
|
return result;
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
|
-
|
|
3
|
-
id: string;
|
|
4
|
-
sdk_id: string;
|
|
5
|
-
title: string;
|
|
6
|
-
}
|
|
2
|
+
import type { AccessLevelDTO } from '../../lib/api-schemas.js';
|
|
7
3
|
export default class AccessLevelsGet extends Command {
|
|
8
4
|
static args: {
|
|
9
5
|
access_level_id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
@@ -14,6 +10,5 @@ export default class AccessLevelsGet extends Command {
|
|
|
14
10
|
static flags: {
|
|
15
11
|
app: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
12
|
};
|
|
17
|
-
run(): Promise<
|
|
13
|
+
run(): Promise<AccessLevelDTO>;
|
|
18
14
|
}
|
|
19
|
-
export {};
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
|
+
import type { AccessLevelDTO } from '../../lib/api-schemas.js';
|
|
2
3
|
import { type PaginatedResponse } from '../../lib/flags.js';
|
|
3
|
-
interface AccessLevelItem {
|
|
4
|
-
id: string;
|
|
5
|
-
sdk_id: string;
|
|
6
|
-
title: string;
|
|
7
|
-
}
|
|
8
4
|
export default class AccessLevelsList extends Command {
|
|
9
5
|
static description: string;
|
|
10
6
|
static enableJsonFlag: boolean;
|
|
@@ -14,6 +10,5 @@ export default class AccessLevelsList extends Command {
|
|
|
14
10
|
'page-size': import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
11
|
app: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
12
|
};
|
|
17
|
-
run(): Promise<PaginatedResponse<
|
|
13
|
+
run(): Promise<PaginatedResponse<AccessLevelDTO>>;
|
|
18
14
|
}
|
|
19
|
-
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
|
+
import type { AccessLevelDTO } from '../../lib/api-schemas.js';
|
|
2
3
|
export default class AccessLevelsUpdate extends Command {
|
|
3
4
|
static args: {
|
|
4
5
|
access_level_id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
@@ -10,5 +11,5 @@ export default class AccessLevelsUpdate extends Command {
|
|
|
10
11
|
title: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
12
|
app: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
13
|
};
|
|
13
|
-
run(): Promise<
|
|
14
|
+
run(): Promise<AccessLevelDTO>;
|
|
14
15
|
}
|
|
@@ -21,9 +21,10 @@ export default class AccessLevelsUpdate extends Command {
|
|
|
21
21
|
this.error('Invalid access level ID format.', { exit: 2 });
|
|
22
22
|
}
|
|
23
23
|
const client = await createAuthenticatedClient(this.config);
|
|
24
|
-
const
|
|
24
|
+
const body = {
|
|
25
25
|
title: flags.title,
|
|
26
|
-
}
|
|
26
|
+
};
|
|
27
|
+
const result = await client.put(`/apps/${flags.app}/access-levels/${args.access_level_id}`, body);
|
|
27
28
|
this.log('Access level updated!');
|
|
28
29
|
printResponse(result, this.log.bind(this));
|
|
29
30
|
return result;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
|
+
import type { AppSummaryDTO } from '../../lib/api-schemas.js';
|
|
2
3
|
export default class AppsCreate extends Command {
|
|
3
4
|
static description: string;
|
|
4
5
|
static enableJsonFlag: boolean;
|
|
@@ -9,5 +10,5 @@ export default class AppsCreate extends Command {
|
|
|
9
10
|
platform: import("@oclif/core/interfaces").OptionFlag<string[], import("@oclif/core/interfaces").CustomOptions>;
|
|
10
11
|
title: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
12
|
};
|
|
12
|
-
run(): Promise<
|
|
13
|
+
run(): Promise<AppSummaryDTO>;
|
|
13
14
|
}
|
|
@@ -39,10 +39,9 @@ export default class AppsCreate extends Command {
|
|
|
39
39
|
const result = await client.post('/apps', body);
|
|
40
40
|
this.log('App created!');
|
|
41
41
|
printResponse(result, this.log.bind(this));
|
|
42
|
-
// Fetch default access level for the new app
|
|
43
42
|
try {
|
|
44
43
|
const accessLevels = await client.get(`/apps/${result.id}/access-levels`);
|
|
45
|
-
if (accessLevels.items?.length
|
|
44
|
+
if (accessLevels.items?.length) {
|
|
46
45
|
this.log('\nDefault access level:');
|
|
47
46
|
printResponse(accessLevels.items[0], this.log.bind(this));
|
|
48
47
|
}
|
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
|
-
|
|
3
|
-
apple_bundle_id?: string;
|
|
4
|
-
google_bundle_id?: string;
|
|
5
|
-
id: string;
|
|
6
|
-
platforms: string[];
|
|
7
|
-
sdk_key: string;
|
|
8
|
-
secret_key: string;
|
|
9
|
-
title: string;
|
|
10
|
-
}
|
|
2
|
+
import type { AppDetailDTO } from '../../lib/api-schemas.js';
|
|
11
3
|
export default class AppsGet extends Command {
|
|
12
4
|
static args: {
|
|
13
5
|
app_id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
@@ -15,6 +7,5 @@ export default class AppsGet extends Command {
|
|
|
15
7
|
static description: string;
|
|
16
8
|
static enableJsonFlag: boolean;
|
|
17
9
|
static examples: string[];
|
|
18
|
-
run(): Promise<
|
|
10
|
+
run(): Promise<AppDetailDTO>;
|
|
19
11
|
}
|
|
20
|
-
export {};
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
|
+
import type { AppSummaryDTO } from '../../lib/api-schemas.js';
|
|
2
3
|
import { type PaginatedResponse } from '../../lib/flags.js';
|
|
3
|
-
interface AppItem {
|
|
4
|
-
id: string;
|
|
5
|
-
sdk_key: string;
|
|
6
|
-
title: string;
|
|
7
|
-
}
|
|
8
4
|
export default class AppsList extends Command {
|
|
9
5
|
static description: string;
|
|
10
6
|
static enableJsonFlag: boolean;
|
|
@@ -13,6 +9,5 @@ export default class AppsList extends Command {
|
|
|
13
9
|
page: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
10
|
'page-size': import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
11
|
};
|
|
16
|
-
run(): Promise<PaginatedResponse<
|
|
12
|
+
run(): Promise<PaginatedResponse<AppSummaryDTO>>;
|
|
17
13
|
}
|
|
18
|
-
export {};
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
|
-
|
|
3
|
-
apple_bundle_id?: string;
|
|
4
|
-
google_bundle_id?: string;
|
|
5
|
-
id: string;
|
|
6
|
-
title: string;
|
|
7
|
-
}
|
|
2
|
+
import type { AppDetailDTO } from '../../lib/api-schemas.js';
|
|
8
3
|
export default class AppsUpdate extends Command {
|
|
9
4
|
static args: {
|
|
10
5
|
app_id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
@@ -17,6 +12,5 @@ export default class AppsUpdate extends Command {
|
|
|
17
12
|
'google-bundle-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
18
13
|
title: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
19
14
|
};
|
|
20
|
-
run(): Promise<
|
|
15
|
+
run(): Promise<AppDetailDTO>;
|
|
21
16
|
}
|
|
22
|
-
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
|
+
import type { PaywallDTO } from '../../lib/api-schemas.js';
|
|
2
3
|
export default class PaywallsCreate extends Command {
|
|
3
4
|
static description: string;
|
|
4
5
|
static enableJsonFlag: boolean;
|
|
@@ -8,5 +9,5 @@ export default class PaywallsCreate extends Command {
|
|
|
8
9
|
title: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
10
|
app: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
11
|
};
|
|
11
|
-
run(): Promise<
|
|
12
|
+
run(): Promise<PaywallDTO>;
|
|
12
13
|
}
|
|
@@ -20,10 +20,11 @@ export default class PaywallsCreate extends Command {
|
|
|
20
20
|
async run() {
|
|
21
21
|
const { flags } = await this.parse(PaywallsCreate);
|
|
22
22
|
const client = await createAuthenticatedClient(this.config);
|
|
23
|
-
const
|
|
23
|
+
const body = {
|
|
24
24
|
product_ids: flags['product-id'],
|
|
25
25
|
title: flags.title,
|
|
26
|
-
}
|
|
26
|
+
};
|
|
27
|
+
const result = await client.post(`/apps/${flags.app}/paywalls`, body);
|
|
27
28
|
this.log('Paywall created!');
|
|
28
29
|
printResponse(result, this.log.bind(this));
|
|
29
30
|
return result;
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
|
-
|
|
3
|
-
id: string;
|
|
4
|
-
product_ids: string[];
|
|
5
|
-
title: string;
|
|
6
|
-
}
|
|
2
|
+
import type { PaywallDTO } from '../../lib/api-schemas.js';
|
|
7
3
|
export default class PaywallsGet extends Command {
|
|
8
4
|
static args: {
|
|
9
5
|
paywall_id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
@@ -14,6 +10,5 @@ export default class PaywallsGet extends Command {
|
|
|
14
10
|
static flags: {
|
|
15
11
|
app: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
12
|
};
|
|
17
|
-
run(): Promise<
|
|
13
|
+
run(): Promise<PaywallDTO>;
|
|
18
14
|
}
|
|
19
|
-
export {};
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
|
+
import type { PaywallDTO } from '../../lib/api-schemas.js';
|
|
2
3
|
import { type PaginatedResponse } from '../../lib/flags.js';
|
|
3
|
-
interface PaywallItem {
|
|
4
|
-
id: string;
|
|
5
|
-
title: string;
|
|
6
|
-
}
|
|
7
4
|
export default class PaywallsList extends Command {
|
|
8
5
|
static description: string;
|
|
9
6
|
static enableJsonFlag: boolean;
|
|
@@ -13,6 +10,5 @@ export default class PaywallsList extends Command {
|
|
|
13
10
|
'page-size': import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
11
|
app: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
12
|
};
|
|
16
|
-
run(): Promise<PaginatedResponse<
|
|
13
|
+
run(): Promise<PaginatedResponse<PaywallDTO>>;
|
|
17
14
|
}
|
|
18
|
-
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
import type { PlacementSummaryDTO } from '../../lib/api-schemas.js';
|
|
3
|
+
interface PlacementsByPaywallResponse {
|
|
4
|
+
data: PlacementSummaryDTO[];
|
|
5
|
+
}
|
|
6
|
+
export default class PaywallsPlacements extends Command {
|
|
7
|
+
static args: {
|
|
8
|
+
paywall_id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
9
|
+
};
|
|
10
|
+
static description: string;
|
|
11
|
+
static enableJsonFlag: boolean;
|
|
12
|
+
static examples: string[];
|
|
13
|
+
static flags: {
|
|
14
|
+
app: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
+
};
|
|
16
|
+
run(): Promise<PlacementsByPaywallResponse>;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
import { printList } from '../../lib/output.js';
|
|
5
|
+
export default class PaywallsPlacements extends Command {
|
|
6
|
+
static args = {
|
|
7
|
+
paywall_id: Args.string({ description: 'Paywall ID (UUID)', required: true }),
|
|
8
|
+
};
|
|
9
|
+
static description = 'List placements that currently use this paywall';
|
|
10
|
+
static enableJsonFlag = true;
|
|
11
|
+
static examples = ['<%= config.bin %> paywalls placements --app UUID 770e8400-e29b-41d4-a716-446655440002'];
|
|
12
|
+
static flags = {
|
|
13
|
+
...appFlag,
|
|
14
|
+
};
|
|
15
|
+
async run() {
|
|
16
|
+
const { args, flags } = await this.parse(PaywallsPlacements);
|
|
17
|
+
if (!isValidUuid(args.paywall_id)) {
|
|
18
|
+
this.error('Invalid paywall ID format.', { exit: 2 });
|
|
19
|
+
}
|
|
20
|
+
const client = await createAuthenticatedClient(this.config);
|
|
21
|
+
const result = await client.get(`/apps/${flags.app}/paywalls/${args.paywall_id}/placements`);
|
|
22
|
+
printList(result.data, this.log.bind(this));
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
|
+
import type { PaywallDTO } from '../../lib/api-schemas.js';
|
|
2
3
|
export default class PaywallsUpdate extends Command {
|
|
3
4
|
static args: {
|
|
4
5
|
paywall_id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
@@ -11,5 +12,5 @@ export default class PaywallsUpdate extends Command {
|
|
|
11
12
|
title: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
13
|
app: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
14
|
};
|
|
14
|
-
run(): Promise<
|
|
15
|
+
run(): Promise<PaywallDTO>;
|
|
15
16
|
}
|
|
@@ -26,10 +26,11 @@ export default class PaywallsUpdate extends Command {
|
|
|
26
26
|
this.error('Invalid paywall ID format.', { exit: 2 });
|
|
27
27
|
}
|
|
28
28
|
const client = await createAuthenticatedClient(this.config);
|
|
29
|
-
const
|
|
29
|
+
const body = {
|
|
30
30
|
product_ids: flags['product-id'],
|
|
31
31
|
title: flags.title,
|
|
32
|
-
}
|
|
32
|
+
};
|
|
33
|
+
const result = await client.put(`/apps/${flags.app}/paywalls/${args.paywall_id}`, body);
|
|
33
34
|
this.log('Paywall updated!');
|
|
34
35
|
printResponse(result, this.log.bind(this));
|
|
35
36
|
return result;
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
|
+
import type { PlacementDetailDTO } from '../../lib/api-schemas.js';
|
|
2
3
|
export default class PlacementsCreate extends Command {
|
|
3
4
|
static description: string;
|
|
4
5
|
static enableJsonFlag: boolean;
|
|
5
6
|
static examples: string[];
|
|
6
7
|
static flags: {
|
|
8
|
+
audiences: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
9
|
'developer-id': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
-
'paywall-id': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
'paywall-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
11
|
title: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
12
|
app: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
13
|
};
|
|
12
|
-
run(): Promise<
|
|
14
|
+
run(): Promise<PlacementDetailDTO>;
|
|
13
15
|
}
|
|
@@ -6,22 +6,45 @@ export default class PlacementsCreate extends Command {
|
|
|
6
6
|
static description = 'Create a placement with a paywall';
|
|
7
7
|
static enableJsonFlag = true;
|
|
8
8
|
static examples = [
|
|
9
|
-
'<%= config.bin %> placements create --app UUID --title "Default" --developer-id default --
|
|
9
|
+
'<%= config.bin %> placements create --app UUID --title "Default" --developer-id default --audiences \'[{"segment_ids":[],"paywall_id":"PAYWALL_UUID","priority":0}]\'',
|
|
10
|
+
'<%= config.bin %> placements create --app UUID --title "Default" --developer-id default --paywall-id PAYWALL_UUID',
|
|
10
11
|
];
|
|
11
12
|
static flags = {
|
|
12
13
|
...appFlag,
|
|
14
|
+
audiences: Flags.string({
|
|
15
|
+
description: 'JSON array of audience entries: [{segment_ids, paywall_id, priority}]',
|
|
16
|
+
exactlyOne: ['paywall-id', 'audiences'],
|
|
17
|
+
}),
|
|
13
18
|
'developer-id': Flags.string({ description: 'Developer ID for the placement', required: true }),
|
|
14
|
-
'paywall-id': Flags.string({
|
|
19
|
+
'paywall-id': Flags.string({
|
|
20
|
+
description: 'Paywall ID (UUID). DEPRECATED: use --audiences.',
|
|
21
|
+
exactlyOne: ['paywall-id', 'audiences'],
|
|
22
|
+
}),
|
|
15
23
|
title: Flags.string({ description: 'Placement title', required: true }),
|
|
16
24
|
};
|
|
17
25
|
async run() {
|
|
18
26
|
const { flags } = await this.parse(PlacementsCreate);
|
|
19
|
-
const
|
|
20
|
-
|
|
27
|
+
const body = {
|
|
28
|
+
audiences: null,
|
|
21
29
|
developer_id: flags['developer-id'],
|
|
22
|
-
paywall_id:
|
|
30
|
+
paywall_id: null,
|
|
23
31
|
title: flags.title,
|
|
24
|
-
}
|
|
32
|
+
};
|
|
33
|
+
if (flags['paywall-id']) {
|
|
34
|
+
process.stderr.write('⚠️ --paywall-id is deprecated. Use --audiences instead.\n' +
|
|
35
|
+
' `paywall_id` will be removed from the API in a future release.\n');
|
|
36
|
+
body.paywall_id = flags['paywall-id'];
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
try {
|
|
40
|
+
body.audiences = JSON.parse(flags.audiences);
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
this.error(`Invalid --audiences JSON: ${error instanceof Error ? error.message : String(error)}`, { exit: 2 });
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
const client = await createAuthenticatedClient(this.config);
|
|
47
|
+
const result = await client.post(`/apps/${flags.app}/placements`, body);
|
|
25
48
|
this.log('Placement created!');
|
|
26
49
|
printResponse(result, this.log.bind(this));
|
|
27
50
|
return result;
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
|
-
|
|
3
|
-
developer_id: string;
|
|
4
|
-
id: string;
|
|
5
|
-
paywall_id: string;
|
|
6
|
-
title: string;
|
|
7
|
-
}
|
|
2
|
+
import type { PlacementDetailDTO } from '../../lib/api-schemas.js';
|
|
8
3
|
export default class PlacementsGet extends Command {
|
|
9
4
|
static args: {
|
|
10
5
|
placement_id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
@@ -15,6 +10,5 @@ export default class PlacementsGet extends Command {
|
|
|
15
10
|
static flags: {
|
|
16
11
|
app: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
12
|
};
|
|
18
|
-
run(): Promise<
|
|
13
|
+
run(): Promise<PlacementDetailDTO>;
|
|
19
14
|
}
|
|
20
|
-
export {};
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
|
+
import type { PlacementSummaryDTO } from '../../lib/api-schemas.js';
|
|
2
3
|
import { type PaginatedResponse } from '../../lib/flags.js';
|
|
3
|
-
interface PlacementItem {
|
|
4
|
-
developer_id: string;
|
|
5
|
-
id: string;
|
|
6
|
-
title: string;
|
|
7
|
-
}
|
|
8
4
|
export default class PlacementsList extends Command {
|
|
9
5
|
static description: string;
|
|
10
6
|
static enableJsonFlag: boolean;
|
|
@@ -14,6 +10,5 @@ export default class PlacementsList extends Command {
|
|
|
14
10
|
'page-size': import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
11
|
app: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
12
|
};
|
|
17
|
-
run(): Promise<PaginatedResponse<
|
|
13
|
+
run(): Promise<PaginatedResponse<PlacementSummaryDTO>>;
|
|
18
14
|
}
|
|
19
|
-
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
|
+
import type { PlacementDetailDTO } from '../../lib/api-schemas.js';
|
|
2
3
|
export default class PlacementsUpdate extends Command {
|
|
3
4
|
static args: {
|
|
4
5
|
placement_id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
@@ -7,10 +8,11 @@ export default class PlacementsUpdate extends Command {
|
|
|
7
8
|
static enableJsonFlag: boolean;
|
|
8
9
|
static examples: string[];
|
|
9
10
|
static flags: {
|
|
11
|
+
audiences: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
12
|
'developer-id': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
-
'paywall-id': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
'paywall-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
14
|
title: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
15
|
app: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
16
|
};
|
|
15
|
-
run(): Promise<
|
|
17
|
+
run(): Promise<PlacementDetailDTO>;
|
|
16
18
|
}
|
|
@@ -9,12 +9,20 @@ export default class PlacementsUpdate extends Command {
|
|
|
9
9
|
static description = 'Update a placement';
|
|
10
10
|
static enableJsonFlag = true;
|
|
11
11
|
static examples = [
|
|
12
|
-
'<%= config.bin %> placements update --app UUID 550e8400-... --title "Default" --developer-id default --
|
|
12
|
+
'<%= config.bin %> placements update --app UUID 550e8400-... --title "Default" --developer-id default --audiences \'[{"segment_ids":[],"paywall_id":"PAYWALL_UUID","priority":0}]\'',
|
|
13
|
+
'<%= config.bin %> placements update --app UUID 550e8400-... --title "Default" --developer-id default --paywall-id PAYWALL_UUID',
|
|
13
14
|
];
|
|
14
15
|
static flags = {
|
|
15
16
|
...appFlag,
|
|
17
|
+
audiences: Flags.string({
|
|
18
|
+
description: 'JSON array of audience entries: [{segment_ids, paywall_id, priority}]',
|
|
19
|
+
exactlyOne: ['paywall-id', 'audiences'],
|
|
20
|
+
}),
|
|
16
21
|
'developer-id': Flags.string({ description: 'Developer ID for the placement', required: true }),
|
|
17
|
-
'paywall-id': Flags.string({
|
|
22
|
+
'paywall-id': Flags.string({
|
|
23
|
+
description: 'Paywall ID (UUID). DEPRECATED: use --audiences.',
|
|
24
|
+
exactlyOne: ['paywall-id', 'audiences'],
|
|
25
|
+
}),
|
|
18
26
|
title: Flags.string({ description: 'Placement title', required: true }),
|
|
19
27
|
};
|
|
20
28
|
async run() {
|
|
@@ -22,12 +30,30 @@ export default class PlacementsUpdate extends Command {
|
|
|
22
30
|
if (!isValidUuid(args.placement_id)) {
|
|
23
31
|
this.error('Invalid placement ID format.', { exit: 2 });
|
|
24
32
|
}
|
|
25
|
-
const
|
|
26
|
-
|
|
33
|
+
const body = {
|
|
34
|
+
audiences: null,
|
|
27
35
|
developer_id: flags['developer-id'],
|
|
28
|
-
paywall_id:
|
|
36
|
+
paywall_id: null,
|
|
29
37
|
title: flags.title,
|
|
30
|
-
}
|
|
38
|
+
};
|
|
39
|
+
if (flags['paywall-id']) {
|
|
40
|
+
process.stderr.write('⚠️ --paywall-id is deprecated. Use --audiences instead.\n' +
|
|
41
|
+
' `paywall_id` will be removed from the API in a future release.\n');
|
|
42
|
+
process.stderr.write('⚠️ --paywall-id will rewrite all audiences on this placement.\n' +
|
|
43
|
+
' If the placement has segment-specific paywalls, they will be replaced\n' +
|
|
44
|
+
' by a single default audience. Use --audiences to preserve them.\n');
|
|
45
|
+
body.paywall_id = flags['paywall-id'];
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
try {
|
|
49
|
+
body.audiences = JSON.parse(flags.audiences);
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
this.error(`Invalid --audiences JSON: ${error instanceof Error ? error.message : String(error)}`, { exit: 2 });
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const client = await createAuthenticatedClient(this.config);
|
|
56
|
+
const result = await client.put(`/apps/${flags.app}/placements/${args.placement_id}`, body);
|
|
31
57
|
this.log('Placement updated!');
|
|
32
58
|
printResponse(result, this.log.bind(this));
|
|
33
59
|
return result;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
|
+
import type { ProductDTO } from '../../lib/api-schemas.js';
|
|
2
3
|
export default class ProductsCreate extends Command {
|
|
3
4
|
static description: string;
|
|
4
5
|
static enableJsonFlag: boolean;
|
|
@@ -12,5 +13,5 @@ export default class ProductsCreate extends Command {
|
|
|
12
13
|
title: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
14
|
app: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
15
|
};
|
|
15
|
-
run(): Promise<
|
|
16
|
+
run(): Promise<ProductDTO>;
|
|
16
17
|
}
|
|
@@ -2,7 +2,15 @@ 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
4
|
import { printResponse } from '../../lib/output.js';
|
|
5
|
-
const VALID_PERIODS = [
|
|
5
|
+
const VALID_PERIODS = [
|
|
6
|
+
'weekly',
|
|
7
|
+
'monthly',
|
|
8
|
+
'two_months',
|
|
9
|
+
'trimonthly',
|
|
10
|
+
'semiannual',
|
|
11
|
+
'annual',
|
|
12
|
+
'lifetime',
|
|
13
|
+
];
|
|
6
14
|
export default class ProductsCreate extends Command {
|
|
7
15
|
static description = 'Create a product with vendor products per platform';
|
|
8
16
|
static enableJsonFlag = true;
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
|
-
|
|
3
|
-
access_level_id: string;
|
|
4
|
-
id: string;
|
|
5
|
-
period: string;
|
|
6
|
-
title: string;
|
|
7
|
-
vendor_products: Record<string, unknown>;
|
|
8
|
-
}
|
|
2
|
+
import type { ProductDTO } from '../../lib/api-schemas.js';
|
|
9
3
|
export default class ProductsGet extends Command {
|
|
10
4
|
static args: {
|
|
11
5
|
product_id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
@@ -16,6 +10,5 @@ export default class ProductsGet extends Command {
|
|
|
16
10
|
static flags: {
|
|
17
11
|
app: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
18
12
|
};
|
|
19
|
-
run(): Promise<
|
|
13
|
+
run(): Promise<ProductDTO>;
|
|
20
14
|
}
|
|
21
|
-
export {};
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
|
+
import type { ProductDTO } from '../../lib/api-schemas.js';
|
|
2
3
|
import { type PaginatedResponse } from '../../lib/flags.js';
|
|
3
|
-
interface ProductItem {
|
|
4
|
-
id: string;
|
|
5
|
-
title: string;
|
|
6
|
-
vendor_products: Record<string, unknown>;
|
|
7
|
-
}
|
|
8
4
|
export default class ProductsList extends Command {
|
|
9
5
|
static description: string;
|
|
10
6
|
static enableJsonFlag: boolean;
|
|
@@ -14,6 +10,5 @@ export default class ProductsList extends Command {
|
|
|
14
10
|
'page-size': import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
11
|
app: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
12
|
};
|
|
17
|
-
run(): Promise<PaginatedResponse<
|
|
13
|
+
run(): Promise<PaginatedResponse<ProductDTO>>;
|
|
18
14
|
}
|
|
19
|
-
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
|
+
import type { ProductDTO } from '../../lib/api-schemas.js';
|
|
2
3
|
export default class ProductsUpdate extends Command {
|
|
3
4
|
static args: {
|
|
4
5
|
product_id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
@@ -11,5 +12,5 @@ export default class ProductsUpdate extends Command {
|
|
|
11
12
|
title: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
13
|
app: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
14
|
};
|
|
14
|
-
run(): Promise<
|
|
15
|
+
run(): Promise<ProductDTO>;
|
|
15
16
|
}
|