adapty 0.1.5 → 0.3.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.
- 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 +6 -1
- package/dist/commands/products/create.js +36 -6
- 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 +103 -0
- package/dist/lib/api-schemas.js +7 -0
- package/oclif.manifest.json +396 -199
- package/package.json +4 -1
|
@@ -2,7 +2,16 @@ 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
|
+
];
|
|
14
|
+
const xor = (a, b) => (a === undefined) !== (b === undefined);
|
|
6
15
|
export default class ProductsCreate extends Command {
|
|
7
16
|
static description = 'Create a product with vendor products per platform';
|
|
8
17
|
static enableJsonFlag = true;
|
|
@@ -12,13 +21,17 @@ export default class ProductsCreate extends Command {
|
|
|
12
21
|
static flags = {
|
|
13
22
|
...appFlag,
|
|
14
23
|
'access-level-id': Flags.string({ description: 'Access level ID (UUID)', required: true }),
|
|
15
|
-
'android-base-plan-id': Flags.string({ description: 'Android base plan ID' }),
|
|
16
|
-
'android-product-id': Flags.string({ description: 'Android product ID' }),
|
|
17
|
-
'ios-product-id': Flags.string({ description: 'iOS product ID' }),
|
|
24
|
+
'android-base-plan-id': Flags.string({ description: 'Android base plan ID', helpGroup: 'STORE BINDINGS' }),
|
|
25
|
+
'android-product-id': Flags.string({ description: 'Android product ID', helpGroup: 'STORE BINDINGS' }),
|
|
26
|
+
'ios-product-id': Flags.string({ description: 'iOS product ID', helpGroup: 'STORE BINDINGS' }),
|
|
27
|
+
'paddle-price-id': Flags.string({ description: 'Paddle price ID (requires --paddle-product-id)', helpGroup: 'STORE BINDINGS' }),
|
|
28
|
+
'paddle-product-id': Flags.string({ description: 'Paddle product ID (requires --paddle-price-id)', helpGroup: 'STORE BINDINGS' }),
|
|
18
29
|
period: Flags.string({
|
|
19
30
|
description: 'Subscription period (weekly, monthly, two_months, trimonthly, semiannual, annual, lifetime)',
|
|
20
31
|
required: true,
|
|
21
32
|
}),
|
|
33
|
+
'stripe-price-id': Flags.string({ description: 'Stripe price ID (requires --stripe-product-id)', helpGroup: 'STORE BINDINGS' }),
|
|
34
|
+
'stripe-product-id': Flags.string({ description: 'Stripe product ID (requires --stripe-price-id)', helpGroup: 'STORE BINDINGS' }),
|
|
22
35
|
title: Flags.string({ description: 'Product title', required: true }),
|
|
23
36
|
};
|
|
24
37
|
async run() {
|
|
@@ -26,8 +39,17 @@ export default class ProductsCreate extends Command {
|
|
|
26
39
|
if (!VALID_PERIODS.includes(flags.period)) {
|
|
27
40
|
this.error(`Invalid period. Must be one of: ${VALID_PERIODS.join(', ')}`, { exit: 2 });
|
|
28
41
|
}
|
|
29
|
-
if (
|
|
30
|
-
this.error('
|
|
42
|
+
if (xor(flags['stripe-product-id'], flags['stripe-price-id'])) {
|
|
43
|
+
this.error('--stripe-product-id and --stripe-price-id are required together', { exit: 2 });
|
|
44
|
+
}
|
|
45
|
+
if (xor(flags['paddle-product-id'], flags['paddle-price-id'])) {
|
|
46
|
+
this.error('--paddle-product-id and --paddle-price-id are required together', { exit: 2 });
|
|
47
|
+
}
|
|
48
|
+
if (!flags['ios-product-id'] &&
|
|
49
|
+
!flags['android-product-id'] &&
|
|
50
|
+
!flags['stripe-product-id'] &&
|
|
51
|
+
!flags['paddle-product-id']) {
|
|
52
|
+
this.error('At least one store binding is required (ios/android/stripe/paddle)', { exit: 2 });
|
|
31
53
|
}
|
|
32
54
|
if (flags['android-product-id'] && !flags['android-base-plan-id'] && flags.period !== 'lifetime') {
|
|
33
55
|
this.error('--android-base-plan-id is required with --android-product-id for subscriptions', { exit: 2 });
|
|
@@ -44,6 +66,14 @@ export default class ProductsCreate extends Command {
|
|
|
44
66
|
body.android_product_id = flags['android-product-id'];
|
|
45
67
|
if (flags['android-base-plan-id'])
|
|
46
68
|
body.android_base_plan_id = flags['android-base-plan-id'];
|
|
69
|
+
if (flags['stripe-product-id'])
|
|
70
|
+
body.stripe_product_id = flags['stripe-product-id'];
|
|
71
|
+
if (flags['stripe-price-id'])
|
|
72
|
+
body.stripe_price_id = flags['stripe-price-id'];
|
|
73
|
+
if (flags['paddle-product-id'])
|
|
74
|
+
body.paddle_product_id = flags['paddle-product-id'];
|
|
75
|
+
if (flags['paddle-price-id'])
|
|
76
|
+
body.paddle_price_id = flags['paddle-price-id'];
|
|
47
77
|
const result = await client.post(`/apps/${flags.app}/products`, body);
|
|
48
78
|
this.log('Product created!');
|
|
49
79
|
printResponse(result, this.log.bind(this));
|
|
@@ -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
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
import type { SegmentDTO } from '../../lib/api-schemas.js';
|
|
3
|
+
export default class SegmentsGet extends Command {
|
|
4
|
+
static args: {
|
|
5
|
+
segment_id: 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<SegmentDTO>;
|
|
14
|
+
}
|
|
@@ -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 { printResponse } from '../../lib/output.js';
|
|
5
|
+
export default class SegmentsGet extends Command {
|
|
6
|
+
static args = {
|
|
7
|
+
segment_id: Args.string({ description: 'Segment ID (UUID)', required: true }),
|
|
8
|
+
};
|
|
9
|
+
static description = 'Get segment details';
|
|
10
|
+
static enableJsonFlag = true;
|
|
11
|
+
static examples = ['<%= config.bin %> segments get --app UUID 550e8400-e29b-41d4-a716-446655440000'];
|
|
12
|
+
static flags = {
|
|
13
|
+
...appFlag,
|
|
14
|
+
};
|
|
15
|
+
async run() {
|
|
16
|
+
const { args, flags } = await this.parse(SegmentsGet);
|
|
17
|
+
if (!isValidUuid(args.segment_id)) {
|
|
18
|
+
this.error('Invalid segment ID format.', { exit: 2 });
|
|
19
|
+
}
|
|
20
|
+
const client = await createAuthenticatedClient(this.config);
|
|
21
|
+
const result = await client.get(`/apps/${flags.app}/segments/${args.segment_id}`);
|
|
22
|
+
printResponse(result, this.log.bind(this));
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
import type { SegmentDTO } from '../../lib/api-schemas.js';
|
|
3
|
+
import { type PaginatedResponse } from '../../lib/flags.js';
|
|
4
|
+
export default class SegmentsList extends Command {
|
|
5
|
+
static description: string;
|
|
6
|
+
static enableJsonFlag: boolean;
|
|
7
|
+
static examples: string[];
|
|
8
|
+
static flags: {
|
|
9
|
+
page: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
'page-size': import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
app: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
};
|
|
13
|
+
run(): Promise<PaginatedResponse<SegmentDTO>>;
|
|
14
|
+
}
|
|
@@ -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 SegmentsList extends Command {
|
|
6
|
+
static description = 'List segments for an app';
|
|
7
|
+
static enableJsonFlag = true;
|
|
8
|
+
static examples = ['<%= config.bin %> segments list --app 550e8400-...'];
|
|
9
|
+
static flags = {
|
|
10
|
+
...appFlag,
|
|
11
|
+
...paginationFlags,
|
|
12
|
+
};
|
|
13
|
+
async run() {
|
|
14
|
+
const { flags } = await this.parse(SegmentsList);
|
|
15
|
+
const client = await createAuthenticatedClient(this.config);
|
|
16
|
+
const result = await client.get(`/apps/${flags.app}/segments`, paginationParams(flags));
|
|
17
|
+
printList(result.data, this.log.bind(this), result.meta.pagination);
|
|
18
|
+
return result;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
export type ProductPeriod = 'annual' | 'consumable' | 'lifetime' | 'monthly' | 'nonsubscriptions' | 'semiannual' | 'trimonthly' | 'two_months' | 'uncategorised' | 'weekly';
|
|
2
|
+
export interface VendorProductDTO {
|
|
3
|
+
base_plan_id: null | string;
|
|
4
|
+
id: null | string;
|
|
5
|
+
product_id: null | string;
|
|
6
|
+
}
|
|
7
|
+
export interface AppSummaryDTO {
|
|
8
|
+
id: string;
|
|
9
|
+
sdk_key: null | string;
|
|
10
|
+
title: string;
|
|
11
|
+
}
|
|
12
|
+
export interface AppDetailDTO {
|
|
13
|
+
apple_bundle_id: null | string;
|
|
14
|
+
google_bundle_id: null | string;
|
|
15
|
+
id: string;
|
|
16
|
+
platforms: string[];
|
|
17
|
+
sdk_key: null | string;
|
|
18
|
+
secret_key: null | string;
|
|
19
|
+
title: string;
|
|
20
|
+
}
|
|
21
|
+
export interface AppCreateRequestDTO {
|
|
22
|
+
apple_bundle_id?: null | string;
|
|
23
|
+
google_bundle_id?: null | string;
|
|
24
|
+
title: string;
|
|
25
|
+
}
|
|
26
|
+
export interface AppUpdateRequestDTO {
|
|
27
|
+
apple_bundle_id?: null | string;
|
|
28
|
+
google_bundle_id?: null | string;
|
|
29
|
+
title?: null | string;
|
|
30
|
+
}
|
|
31
|
+
export interface AccessLevelDTO {
|
|
32
|
+
id: string;
|
|
33
|
+
sdk_id: string;
|
|
34
|
+
title: null | string;
|
|
35
|
+
}
|
|
36
|
+
export interface AccessLevelCreateRequestDTO {
|
|
37
|
+
sdk_id: string;
|
|
38
|
+
title?: null | string;
|
|
39
|
+
}
|
|
40
|
+
export interface AccessLevelUpdateRequestDTO {
|
|
41
|
+
title?: null | string;
|
|
42
|
+
}
|
|
43
|
+
export interface ProductDTO {
|
|
44
|
+
access_level_id: string;
|
|
45
|
+
id: string;
|
|
46
|
+
period: ProductPeriod;
|
|
47
|
+
title: string;
|
|
48
|
+
vendor_products: Record<string, VendorProductDTO>;
|
|
49
|
+
}
|
|
50
|
+
export interface ProductCreateRequestDTO {
|
|
51
|
+
access_level_id: string;
|
|
52
|
+
android_base_plan_id?: null | string;
|
|
53
|
+
android_product_id?: null | string;
|
|
54
|
+
ios_product_id?: null | string;
|
|
55
|
+
paddle_price_id?: null | string;
|
|
56
|
+
paddle_product_id?: null | string;
|
|
57
|
+
period: ProductPeriod;
|
|
58
|
+
price_usd?: null | number;
|
|
59
|
+
stripe_price_id?: null | string;
|
|
60
|
+
stripe_product_id?: null | string;
|
|
61
|
+
title: string;
|
|
62
|
+
}
|
|
63
|
+
export interface ProductUpdateRequestDTO {
|
|
64
|
+
access_level_id: string;
|
|
65
|
+
title: string;
|
|
66
|
+
}
|
|
67
|
+
export interface PaywallDTO {
|
|
68
|
+
id: string;
|
|
69
|
+
product_ids: string[];
|
|
70
|
+
title: string;
|
|
71
|
+
}
|
|
72
|
+
export interface PaywallWriteRequestDTO {
|
|
73
|
+
product_ids?: string[];
|
|
74
|
+
title: string;
|
|
75
|
+
}
|
|
76
|
+
export interface SegmentDTO {
|
|
77
|
+
description: null | string;
|
|
78
|
+
id: string;
|
|
79
|
+
title: string;
|
|
80
|
+
}
|
|
81
|
+
export interface PlacementAudienceEntryDTO {
|
|
82
|
+
paywall_id: string;
|
|
83
|
+
priority: number;
|
|
84
|
+
segment_ids?: string[];
|
|
85
|
+
}
|
|
86
|
+
export interface PlacementSummaryDTO {
|
|
87
|
+
developer_id: string;
|
|
88
|
+
id: string;
|
|
89
|
+
title: string;
|
|
90
|
+
}
|
|
91
|
+
export interface PlacementDetailDTO {
|
|
92
|
+
audiences?: PlacementAudienceEntryDTO[];
|
|
93
|
+
developer_id: string;
|
|
94
|
+
id: string;
|
|
95
|
+
title: string;
|
|
96
|
+
}
|
|
97
|
+
export interface PlacementWriteRequestDTO {
|
|
98
|
+
audiences: null | PlacementAudienceEntryDTO[];
|
|
99
|
+
developer_id: string;
|
|
100
|
+
/** @deprecated use `audiences` */
|
|
101
|
+
paywall_id: null | string;
|
|
102
|
+
title: string;
|
|
103
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Hand-picked DTOs from the Adapty Developer API OpenAPI schema. Kept in
|
|
2
|
+
// lockstep with the server-side `portal.developer_api_context.domains.data_transfer_objects.resource_data.*` types.
|
|
3
|
+
//
|
|
4
|
+
// To refresh after a backend change, fetch the spec with:
|
|
5
|
+
// curl -H 'Referer: /api/v1/developer/' http://localhost:8000/api/v1/swagger/schema/
|
|
6
|
+
// and update the affected definitions here.
|
|
7
|
+
export {};
|