@metamask-previews/subscription-controller 6.2.2-preview-58a4a8b71 → 6.2.2-preview-4c8a5dfcb
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/CHANGELOG.md +8 -1
- package/dist/SubscriptionController.cjs +18 -26
- package/dist/SubscriptionController.cjs.map +1 -1
- package/dist/SubscriptionController.d.cts +5 -9
- package/dist/SubscriptionController.d.cts.map +1 -1
- package/dist/SubscriptionController.d.mts +5 -9
- package/dist/SubscriptionController.d.mts.map +1 -1
- package/dist/SubscriptionController.mjs +18 -26
- package/dist/SubscriptionController.mjs.map +1 -1
- package/dist/SubscriptionService-method-action-types.cjs +7 -0
- package/dist/SubscriptionService-method-action-types.cjs.map +1 -0
- package/dist/SubscriptionService-method-action-types.d.cts +151 -0
- package/dist/SubscriptionService-method-action-types.d.cts.map +1 -0
- package/dist/SubscriptionService-method-action-types.d.mts +151 -0
- package/dist/SubscriptionService-method-action-types.d.mts.map +1 -0
- package/dist/SubscriptionService-method-action-types.mjs +6 -0
- package/dist/SubscriptionService-method-action-types.mjs.map +1 -0
- package/dist/SubscriptionService-structs.cjs +135 -0
- package/dist/SubscriptionService-structs.cjs.map +1 -0
- package/dist/SubscriptionService-structs.d.cts +773 -0
- package/dist/SubscriptionService-structs.d.cts.map +1 -0
- package/dist/SubscriptionService-structs.d.mts +773 -0
- package/dist/SubscriptionService-structs.d.mts.map +1 -0
- package/dist/SubscriptionService-structs.mjs +132 -0
- package/dist/SubscriptionService-structs.mjs.map +1 -0
- package/dist/SubscriptionService.cjs +257 -87
- package/dist/SubscriptionService.cjs.map +1 -1
- package/dist/SubscriptionService.d.cts +90 -10
- package/dist/SubscriptionService.d.cts.map +1 -1
- package/dist/SubscriptionService.d.mts +90 -10
- package/dist/SubscriptionService.d.mts.map +1 -1
- package/dist/SubscriptionService.mjs +257 -87
- package/dist/SubscriptionService.mjs.map +1 -1
- package/dist/index.cjs +3 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -3
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +4 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -2
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is auto generated.
|
|
3
|
+
* Do not edit manually.
|
|
4
|
+
*/
|
|
5
|
+
import type { SubscriptionService } from "./SubscriptionService.mjs";
|
|
6
|
+
/**
|
|
7
|
+
* Fetches the user's subscriptions.
|
|
8
|
+
*
|
|
9
|
+
* @returns The subscriptions response.
|
|
10
|
+
*/
|
|
11
|
+
export type SubscriptionServiceGetSubscriptionsAction = {
|
|
12
|
+
type: `SubscriptionService:getSubscriptions`;
|
|
13
|
+
handler: SubscriptionService['getSubscriptions'];
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Cancels a subscription.
|
|
17
|
+
*
|
|
18
|
+
* @param params - The cancel subscription request.
|
|
19
|
+
* @returns The updated subscription.
|
|
20
|
+
*/
|
|
21
|
+
export type SubscriptionServiceCancelSubscriptionAction = {
|
|
22
|
+
type: `SubscriptionService:cancelSubscription`;
|
|
23
|
+
handler: SubscriptionService['cancelSubscription'];
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Reverses a pending subscription cancellation.
|
|
27
|
+
*
|
|
28
|
+
* @param params - The uncancel subscription request.
|
|
29
|
+
* @param params.subscriptionId - The subscription ID to uncancel.
|
|
30
|
+
* @returns The updated subscription.
|
|
31
|
+
*/
|
|
32
|
+
export type SubscriptionServiceUnCancelSubscriptionAction = {
|
|
33
|
+
type: `SubscriptionService:unCancelSubscription`;
|
|
34
|
+
handler: SubscriptionService['unCancelSubscription'];
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Starts a subscription with a card payment method.
|
|
38
|
+
*
|
|
39
|
+
* @param request - The start subscription request.
|
|
40
|
+
* @returns The checkout session response.
|
|
41
|
+
*/
|
|
42
|
+
export type SubscriptionServiceStartSubscriptionWithCardAction = {
|
|
43
|
+
type: `SubscriptionService:startSubscriptionWithCard`;
|
|
44
|
+
handler: SubscriptionService['startSubscriptionWithCard'];
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Starts a subscription with a crypto payment method.
|
|
48
|
+
*
|
|
49
|
+
* @param request - The start crypto subscription request.
|
|
50
|
+
* @returns The created subscription response.
|
|
51
|
+
*/
|
|
52
|
+
export type SubscriptionServiceStartSubscriptionWithCryptoAction = {
|
|
53
|
+
type: `SubscriptionService:startSubscriptionWithCrypto`;
|
|
54
|
+
handler: SubscriptionService['startSubscriptionWithCrypto'];
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Updates a subscription's card payment method.
|
|
58
|
+
*
|
|
59
|
+
* @param request - The update payment method request.
|
|
60
|
+
* @returns The redirect URL response.
|
|
61
|
+
*/
|
|
62
|
+
export type SubscriptionServiceUpdatePaymentMethodCardAction = {
|
|
63
|
+
type: `SubscriptionService:updatePaymentMethodCard`;
|
|
64
|
+
handler: SubscriptionService['updatePaymentMethodCard'];
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Updates a subscription's crypto payment method.
|
|
68
|
+
*
|
|
69
|
+
* @param request - The update payment method request.
|
|
70
|
+
*/
|
|
71
|
+
export type SubscriptionServiceUpdatePaymentMethodCryptoAction = {
|
|
72
|
+
type: `SubscriptionService:updatePaymentMethodCrypto`;
|
|
73
|
+
handler: SubscriptionService['updatePaymentMethodCrypto'];
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Get the eligibility for a shield subscription.
|
|
77
|
+
*
|
|
78
|
+
* @param request - Optional request object containing user balance category to check cohort eligibility
|
|
79
|
+
* @returns The eligibility for a shield subscription
|
|
80
|
+
*/
|
|
81
|
+
export type SubscriptionServiceGetSubscriptionsEligibilitiesAction = {
|
|
82
|
+
type: `SubscriptionService:getSubscriptionsEligibilities`;
|
|
83
|
+
handler: SubscriptionService['getSubscriptionsEligibilities'];
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Submit a user event. (e.g. shield modal viewed)
|
|
87
|
+
*
|
|
88
|
+
* @param request - Request object containing the event to submit.
|
|
89
|
+
* @example { event: SubscriptionUserEvent.ShieldEntryModalViewed, cohort: 'post_tx' }
|
|
90
|
+
*/
|
|
91
|
+
export type SubscriptionServiceSubmitUserEventAction = {
|
|
92
|
+
type: `SubscriptionService:submitUserEvent`;
|
|
93
|
+
handler: SubscriptionService['submitUserEvent'];
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Assign user to a cohort.
|
|
97
|
+
*
|
|
98
|
+
* @param request - Request object containing the cohort to assign the user to.
|
|
99
|
+
* @example { cohort: 'post_tx' }
|
|
100
|
+
*/
|
|
101
|
+
export type SubscriptionServiceAssignUserToCohortAction = {
|
|
102
|
+
type: `SubscriptionService:assignUserToCohort`;
|
|
103
|
+
handler: SubscriptionService['assignUserToCohort'];
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* Submit sponsorship intents to the Subscription Service backend.
|
|
107
|
+
*
|
|
108
|
+
* This is intended to be used together with the crypto subscription flow.
|
|
109
|
+
* When the user has enabled the smart transaction feature, we will sponsor the gas fees for the subscription approval transaction.
|
|
110
|
+
*
|
|
111
|
+
* @param request - Request object containing the address and products.
|
|
112
|
+
* @example { address: '0x1234567890123456789012345678901234567890', products: [ProductType.Shield] }
|
|
113
|
+
*/
|
|
114
|
+
export type SubscriptionServiceSubmitSponsorshipIntentsAction = {
|
|
115
|
+
type: `SubscriptionService:submitSponsorshipIntents`;
|
|
116
|
+
handler: SubscriptionService['submitSponsorshipIntents'];
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* Link rewards to a subscription.
|
|
120
|
+
*
|
|
121
|
+
* @param request - Request object containing the reward account ID.
|
|
122
|
+
* @example { rewardAccountId: 'eip155:1:0x1234567890123456789012345678901234567890' }
|
|
123
|
+
* @returns The response from the API.
|
|
124
|
+
*/
|
|
125
|
+
export type SubscriptionServiceLinkRewardsAction = {
|
|
126
|
+
type: `SubscriptionService:linkRewards`;
|
|
127
|
+
handler: SubscriptionService['linkRewards'];
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* Fetches subscription pricing information.
|
|
131
|
+
*
|
|
132
|
+
* @returns The pricing response.
|
|
133
|
+
*/
|
|
134
|
+
export type SubscriptionServiceGetPricingAction = {
|
|
135
|
+
type: `SubscriptionService:getPricing`;
|
|
136
|
+
handler: SubscriptionService['getPricing'];
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* Fetches the billing portal URL.
|
|
140
|
+
*
|
|
141
|
+
* @returns The billing portal response.
|
|
142
|
+
*/
|
|
143
|
+
export type SubscriptionServiceGetBillingPortalUrlAction = {
|
|
144
|
+
type: `SubscriptionService:getBillingPortalUrl`;
|
|
145
|
+
handler: SubscriptionService['getBillingPortalUrl'];
|
|
146
|
+
};
|
|
147
|
+
/**
|
|
148
|
+
* Union of all SubscriptionService action types.
|
|
149
|
+
*/
|
|
150
|
+
export type SubscriptionServiceMethodActions = SubscriptionServiceGetSubscriptionsAction | SubscriptionServiceCancelSubscriptionAction | SubscriptionServiceUnCancelSubscriptionAction | SubscriptionServiceStartSubscriptionWithCardAction | SubscriptionServiceStartSubscriptionWithCryptoAction | SubscriptionServiceUpdatePaymentMethodCardAction | SubscriptionServiceUpdatePaymentMethodCryptoAction | SubscriptionServiceGetSubscriptionsEligibilitiesAction | SubscriptionServiceSubmitUserEventAction | SubscriptionServiceAssignUserToCohortAction | SubscriptionServiceSubmitSponsorshipIntentsAction | SubscriptionServiceLinkRewardsAction | SubscriptionServiceGetPricingAction | SubscriptionServiceGetBillingPortalUrlAction;
|
|
151
|
+
//# sourceMappingURL=SubscriptionService-method-action-types.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SubscriptionService-method-action-types.d.mts","sourceR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file":"SubscriptionService-method-action-types.mjs","sourceRoot":"","sources":["../src/SubscriptionService-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { SubscriptionService } from './SubscriptionService.js';\n\n/**\n * Fetches the user's subscriptions.\n *\n * @returns The subscriptions response.\n */\nexport type SubscriptionServiceGetSubscriptionsAction = {\n type: `SubscriptionService:getSubscriptions`;\n handler: SubscriptionService['getSubscriptions'];\n};\n\n/**\n * Cancels a subscription.\n *\n * @param params - The cancel subscription request.\n * @returns The updated subscription.\n */\nexport type SubscriptionServiceCancelSubscriptionAction = {\n type: `SubscriptionService:cancelSubscription`;\n handler: SubscriptionService['cancelSubscription'];\n};\n\n/**\n * Reverses a pending subscription cancellation.\n *\n * @param params - The uncancel subscription request.\n * @param params.subscriptionId - The subscription ID to uncancel.\n * @returns The updated subscription.\n */\nexport type SubscriptionServiceUnCancelSubscriptionAction = {\n type: `SubscriptionService:unCancelSubscription`;\n handler: SubscriptionService['unCancelSubscription'];\n};\n\n/**\n * Starts a subscription with a card payment method.\n *\n * @param request - The start subscription request.\n * @returns The checkout session response.\n */\nexport type SubscriptionServiceStartSubscriptionWithCardAction = {\n type: `SubscriptionService:startSubscriptionWithCard`;\n handler: SubscriptionService['startSubscriptionWithCard'];\n};\n\n/**\n * Starts a subscription with a crypto payment method.\n *\n * @param request - The start crypto subscription request.\n * @returns The created subscription response.\n */\nexport type SubscriptionServiceStartSubscriptionWithCryptoAction = {\n type: `SubscriptionService:startSubscriptionWithCrypto`;\n handler: SubscriptionService['startSubscriptionWithCrypto'];\n};\n\n/**\n * Updates a subscription's card payment method.\n *\n * @param request - The update payment method request.\n * @returns The redirect URL response.\n */\nexport type SubscriptionServiceUpdatePaymentMethodCardAction = {\n type: `SubscriptionService:updatePaymentMethodCard`;\n handler: SubscriptionService['updatePaymentMethodCard'];\n};\n\n/**\n * Updates a subscription's crypto payment method.\n *\n * @param request - The update payment method request.\n */\nexport type SubscriptionServiceUpdatePaymentMethodCryptoAction = {\n type: `SubscriptionService:updatePaymentMethodCrypto`;\n handler: SubscriptionService['updatePaymentMethodCrypto'];\n};\n\n/**\n * Get the eligibility for a shield subscription.\n *\n * @param request - Optional request object containing user balance category to check cohort eligibility\n * @returns The eligibility for a shield subscription\n */\nexport type SubscriptionServiceGetSubscriptionsEligibilitiesAction = {\n type: `SubscriptionService:getSubscriptionsEligibilities`;\n handler: SubscriptionService['getSubscriptionsEligibilities'];\n};\n\n/**\n * Submit a user event. (e.g. shield modal viewed)\n *\n * @param request - Request object containing the event to submit.\n * @example { event: SubscriptionUserEvent.ShieldEntryModalViewed, cohort: 'post_tx' }\n */\nexport type SubscriptionServiceSubmitUserEventAction = {\n type: `SubscriptionService:submitUserEvent`;\n handler: SubscriptionService['submitUserEvent'];\n};\n\n/**\n * Assign user to a cohort.\n *\n * @param request - Request object containing the cohort to assign the user to.\n * @example { cohort: 'post_tx' }\n */\nexport type SubscriptionServiceAssignUserToCohortAction = {\n type: `SubscriptionService:assignUserToCohort`;\n handler: SubscriptionService['assignUserToCohort'];\n};\n\n/**\n * Submit sponsorship intents to the Subscription Service backend.\n *\n * This is intended to be used together with the crypto subscription flow.\n * When the user has enabled the smart transaction feature, we will sponsor the gas fees for the subscription approval transaction.\n *\n * @param request - Request object containing the address and products.\n * @example { address: '0x1234567890123456789012345678901234567890', products: [ProductType.Shield] }\n */\nexport type SubscriptionServiceSubmitSponsorshipIntentsAction = {\n type: `SubscriptionService:submitSponsorshipIntents`;\n handler: SubscriptionService['submitSponsorshipIntents'];\n};\n\n/**\n * Link rewards to a subscription.\n *\n * @param request - Request object containing the reward account ID.\n * @example { rewardAccountId: 'eip155:1:0x1234567890123456789012345678901234567890' }\n * @returns The response from the API.\n */\nexport type SubscriptionServiceLinkRewardsAction = {\n type: `SubscriptionService:linkRewards`;\n handler: SubscriptionService['linkRewards'];\n};\n\n/**\n * Fetches subscription pricing information.\n *\n * @returns The pricing response.\n */\nexport type SubscriptionServiceGetPricingAction = {\n type: `SubscriptionService:getPricing`;\n handler: SubscriptionService['getPricing'];\n};\n\n/**\n * Fetches the billing portal URL.\n *\n * @returns The billing portal response.\n */\nexport type SubscriptionServiceGetBillingPortalUrlAction = {\n type: `SubscriptionService:getBillingPortalUrl`;\n handler: SubscriptionService['getBillingPortalUrl'];\n};\n\n/**\n * Union of all SubscriptionService action types.\n */\nexport type SubscriptionServiceMethodActions =\n | SubscriptionServiceGetSubscriptionsAction\n | SubscriptionServiceCancelSubscriptionAction\n | SubscriptionServiceUnCancelSubscriptionAction\n | SubscriptionServiceStartSubscriptionWithCardAction\n | SubscriptionServiceStartSubscriptionWithCryptoAction\n | SubscriptionServiceUpdatePaymentMethodCardAction\n | SubscriptionServiceUpdatePaymentMethodCryptoAction\n | SubscriptionServiceGetSubscriptionsEligibilitiesAction\n | SubscriptionServiceSubmitUserEventAction\n | SubscriptionServiceAssignUserToCohortAction\n | SubscriptionServiceSubmitSponsorshipIntentsAction\n | SubscriptionServiceLinkRewardsAction\n | SubscriptionServiceGetPricingAction\n | SubscriptionServiceGetBillingPortalUrlAction;\n"]}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SubscriptionEligibilityArrayStruct = exports.SubscriptionEligibilityStruct = exports.PricingResponseStruct = exports.SubscriptionApiGeneralResponseStruct = exports.BillingPortalResponseStruct = exports.UpdatePaymentMethodCardResponseStruct = exports.StartCryptoSubscriptionResponseStruct = exports.StartSubscriptionResponseStruct = exports.GetSubscriptionsResponseStruct = exports.SubscriptionStruct = void 0;
|
|
4
|
+
const superstruct_1 = require("@metamask/superstruct");
|
|
5
|
+
const utils_1 = require("@metamask/utils");
|
|
6
|
+
const types_js_1 = require("./types.cjs");
|
|
7
|
+
const ProductTypeStruct = (0, superstruct_1.enums)(Object.values(types_js_1.PRODUCT_TYPES));
|
|
8
|
+
const PaymentTypeStruct = (0, superstruct_1.enums)(Object.values(types_js_1.PAYMENT_TYPES));
|
|
9
|
+
const RecurringIntervalStruct = (0, superstruct_1.enums)(Object.values(types_js_1.RECURRING_INTERVALS));
|
|
10
|
+
const SubscriptionStatusStruct = (0, superstruct_1.enums)(Object.values(types_js_1.SUBSCRIPTION_STATUSES));
|
|
11
|
+
const CancelTypeStruct = (0, superstruct_1.enums)(Object.values(types_js_1.CANCEL_TYPES));
|
|
12
|
+
const CryptoPaymentMethodErrorStruct = (0, superstruct_1.enums)(Object.values(types_js_1.CRYPTO_PAYMENT_METHOD_ERRORS));
|
|
13
|
+
const ProductStruct = (0, superstruct_1.type)({
|
|
14
|
+
name: ProductTypeStruct,
|
|
15
|
+
currency: (0, superstruct_1.enums)(['usd']),
|
|
16
|
+
unitAmount: (0, superstruct_1.number)(),
|
|
17
|
+
unitDecimals: (0, superstruct_1.number)(),
|
|
18
|
+
});
|
|
19
|
+
const SubscriptionCardPaymentMethodStruct = (0, superstruct_1.type)({
|
|
20
|
+
type: (0, superstruct_1.enums)([types_js_1.PAYMENT_TYPES.byCard]),
|
|
21
|
+
card: (0, superstruct_1.type)({
|
|
22
|
+
brand: (0, superstruct_1.string)(),
|
|
23
|
+
displayBrand: (0, superstruct_1.string)(),
|
|
24
|
+
last4: (0, superstruct_1.string)(),
|
|
25
|
+
}),
|
|
26
|
+
});
|
|
27
|
+
const SubscriptionCryptoPaymentMethodStruct = (0, superstruct_1.type)({
|
|
28
|
+
type: (0, superstruct_1.enums)([types_js_1.PAYMENT_TYPES.byCrypto]),
|
|
29
|
+
crypto: (0, superstruct_1.type)({
|
|
30
|
+
payerAddress: utils_1.StrictHexStruct,
|
|
31
|
+
chainId: utils_1.StrictHexStruct,
|
|
32
|
+
tokenSymbol: (0, superstruct_1.string)(),
|
|
33
|
+
error: (0, superstruct_1.optional)(CryptoPaymentMethodErrorStruct),
|
|
34
|
+
}),
|
|
35
|
+
});
|
|
36
|
+
const SubscriptionPaymentMethodStruct = (0, superstruct_1.union)([
|
|
37
|
+
SubscriptionCardPaymentMethodStruct,
|
|
38
|
+
SubscriptionCryptoPaymentMethodStruct,
|
|
39
|
+
]);
|
|
40
|
+
exports.SubscriptionStruct = (0, superstruct_1.type)({
|
|
41
|
+
id: (0, superstruct_1.string)(),
|
|
42
|
+
products: (0, superstruct_1.array)(ProductStruct),
|
|
43
|
+
currentPeriodStart: (0, superstruct_1.string)(),
|
|
44
|
+
currentPeriodEnd: (0, superstruct_1.string)(),
|
|
45
|
+
cancelAtPeriodEnd: (0, superstruct_1.optional)((0, superstruct_1.boolean)()),
|
|
46
|
+
status: SubscriptionStatusStruct,
|
|
47
|
+
interval: RecurringIntervalStruct,
|
|
48
|
+
paymentMethod: SubscriptionPaymentMethodStruct,
|
|
49
|
+
trialPeriodDays: (0, superstruct_1.optional)((0, superstruct_1.number)()),
|
|
50
|
+
trialStart: (0, superstruct_1.optional)((0, superstruct_1.string)()),
|
|
51
|
+
trialEnd: (0, superstruct_1.optional)((0, superstruct_1.string)()),
|
|
52
|
+
endDate: (0, superstruct_1.optional)((0, superstruct_1.string)()),
|
|
53
|
+
canceledAt: (0, superstruct_1.optional)((0, superstruct_1.string)()),
|
|
54
|
+
cancelType: CancelTypeStruct,
|
|
55
|
+
inactiveAt: (0, superstruct_1.optional)((0, superstruct_1.string)()),
|
|
56
|
+
isEligibleForSupport: (0, superstruct_1.boolean)(),
|
|
57
|
+
billingCycles: (0, superstruct_1.optional)((0, superstruct_1.number)()),
|
|
58
|
+
});
|
|
59
|
+
exports.GetSubscriptionsResponseStruct = (0, superstruct_1.type)({
|
|
60
|
+
customerId: (0, superstruct_1.optional)((0, superstruct_1.string)()),
|
|
61
|
+
subscriptions: (0, superstruct_1.array)(exports.SubscriptionStruct),
|
|
62
|
+
trialedProducts: (0, superstruct_1.array)(ProductTypeStruct),
|
|
63
|
+
lastSubscription: (0, superstruct_1.optional)(exports.SubscriptionStruct),
|
|
64
|
+
rewardAccountId: (0, superstruct_1.optional)(utils_1.CaipAccountIdStruct),
|
|
65
|
+
});
|
|
66
|
+
exports.StartSubscriptionResponseStruct = (0, superstruct_1.type)({
|
|
67
|
+
checkoutSessionUrl: (0, superstruct_1.string)(),
|
|
68
|
+
});
|
|
69
|
+
exports.StartCryptoSubscriptionResponseStruct = (0, superstruct_1.type)({
|
|
70
|
+
subscriptionId: (0, superstruct_1.string)(),
|
|
71
|
+
status: SubscriptionStatusStruct,
|
|
72
|
+
});
|
|
73
|
+
exports.UpdatePaymentMethodCardResponseStruct = (0, superstruct_1.type)({
|
|
74
|
+
redirectUrl: (0, superstruct_1.string)(),
|
|
75
|
+
});
|
|
76
|
+
exports.BillingPortalResponseStruct = (0, superstruct_1.type)({
|
|
77
|
+
url: (0, superstruct_1.string)(),
|
|
78
|
+
});
|
|
79
|
+
exports.SubscriptionApiGeneralResponseStruct = (0, superstruct_1.type)({
|
|
80
|
+
success: (0, superstruct_1.boolean)(),
|
|
81
|
+
message: (0, superstruct_1.optional)((0, superstruct_1.string)()),
|
|
82
|
+
});
|
|
83
|
+
const ProductPriceStruct = (0, superstruct_1.type)({
|
|
84
|
+
interval: RecurringIntervalStruct,
|
|
85
|
+
unitAmount: (0, superstruct_1.number)(),
|
|
86
|
+
unitDecimals: (0, superstruct_1.number)(),
|
|
87
|
+
currency: (0, superstruct_1.enums)(['usd']),
|
|
88
|
+
trialPeriodDays: (0, superstruct_1.number)(),
|
|
89
|
+
minBillingCycles: (0, superstruct_1.number)(),
|
|
90
|
+
minBillingCyclesForBalance: (0, superstruct_1.number)(),
|
|
91
|
+
});
|
|
92
|
+
const ProductPricingStruct = (0, superstruct_1.type)({
|
|
93
|
+
name: ProductTypeStruct,
|
|
94
|
+
prices: (0, superstruct_1.array)(ProductPriceStruct),
|
|
95
|
+
});
|
|
96
|
+
const TokenPaymentInfoStruct = (0, superstruct_1.type)({
|
|
97
|
+
symbol: (0, superstruct_1.string)(),
|
|
98
|
+
address: utils_1.StrictHexStruct,
|
|
99
|
+
decimals: (0, superstruct_1.number)(),
|
|
100
|
+
conversionRate: (0, superstruct_1.type)({
|
|
101
|
+
usd: (0, superstruct_1.string)(),
|
|
102
|
+
}),
|
|
103
|
+
});
|
|
104
|
+
const ChainPaymentInfoStruct = (0, superstruct_1.type)({
|
|
105
|
+
chainId: utils_1.StrictHexStruct,
|
|
106
|
+
paymentAddress: utils_1.StrictHexStruct,
|
|
107
|
+
tokens: (0, superstruct_1.array)(TokenPaymentInfoStruct),
|
|
108
|
+
isSponsorshipSupported: (0, superstruct_1.optional)((0, superstruct_1.boolean)()),
|
|
109
|
+
});
|
|
110
|
+
const PricingPaymentMethodStruct = (0, superstruct_1.type)({
|
|
111
|
+
type: PaymentTypeStruct,
|
|
112
|
+
chains: (0, superstruct_1.optional)((0, superstruct_1.array)(ChainPaymentInfoStruct)),
|
|
113
|
+
});
|
|
114
|
+
exports.PricingResponseStruct = (0, superstruct_1.type)({
|
|
115
|
+
products: (0, superstruct_1.array)(ProductPricingStruct),
|
|
116
|
+
paymentMethods: (0, superstruct_1.array)(PricingPaymentMethodStruct),
|
|
117
|
+
});
|
|
118
|
+
const CohortStruct = (0, superstruct_1.type)({
|
|
119
|
+
cohort: (0, superstruct_1.string)(),
|
|
120
|
+
eligibilityRate: (0, superstruct_1.number)(),
|
|
121
|
+
priority: (0, superstruct_1.number)(),
|
|
122
|
+
eligible: (0, superstruct_1.boolean)(),
|
|
123
|
+
});
|
|
124
|
+
exports.SubscriptionEligibilityStruct = (0, superstruct_1.type)({
|
|
125
|
+
product: ProductTypeStruct,
|
|
126
|
+
canSubscribe: (0, superstruct_1.optional)((0, superstruct_1.boolean)()),
|
|
127
|
+
canViewEntryModal: (0, superstruct_1.optional)((0, superstruct_1.boolean)()),
|
|
128
|
+
modalType: (0, superstruct_1.optional)((0, superstruct_1.enums)(['A', 'B'])),
|
|
129
|
+
cohorts: (0, superstruct_1.optional)((0, superstruct_1.array)(CohortStruct)),
|
|
130
|
+
assignedCohort: (0, superstruct_1.optional)((0, superstruct_1.nullable)((0, superstruct_1.string)())),
|
|
131
|
+
assignedAt: (0, superstruct_1.optional)((0, superstruct_1.string)()),
|
|
132
|
+
hasAssignedCohortExpired: (0, superstruct_1.optional)((0, superstruct_1.boolean)()),
|
|
133
|
+
});
|
|
134
|
+
exports.SubscriptionEligibilityArrayStruct = (0, superstruct_1.array)(exports.SubscriptionEligibilityStruct);
|
|
135
|
+
//# sourceMappingURL=SubscriptionService-structs.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SubscriptionService-structs.cjs","sourceRoot":"","sources":["../src/SubscriptionService-structs.ts"],"names":[],"mappings":";;;AAAA,uDAU+B;AAC/B,2CAAuE;AAEvE,0CAOoB;AAEpB,MAAM,iBAAiB,GAAG,IAAA,mBAAK,EAAC,MAAM,CAAC,MAAM,CAAC,wBAAa,CAAC,CAAC,CAAC;AAC9D,MAAM,iBAAiB,GAAG,IAAA,mBAAK,EAAC,MAAM,CAAC,MAAM,CAAC,wBAAa,CAAC,CAAC,CAAC;AAC9D,MAAM,uBAAuB,GAAG,IAAA,mBAAK,EAAC,MAAM,CAAC,MAAM,CAAC,8BAAmB,CAAC,CAAC,CAAC;AAC1E,MAAM,wBAAwB,GAAG,IAAA,mBAAK,EAAC,MAAM,CAAC,MAAM,CAAC,gCAAqB,CAAC,CAAC,CAAC;AAC7E,MAAM,gBAAgB,GAAG,IAAA,mBAAK,EAAC,MAAM,CAAC,MAAM,CAAC,uBAAY,CAAC,CAAC,CAAC;AAC5D,MAAM,8BAA8B,GAAG,IAAA,mBAAK,EAC1C,MAAM,CAAC,MAAM,CAAC,uCAA4B,CAAC,CAC5C,CAAC;AAEF,MAAM,aAAa,GAAG,IAAA,kBAAI,EAAC;IACzB,IAAI,EAAE,iBAAiB;IACvB,QAAQ,EAAE,IAAA,mBAAK,EAAC,CAAC,KAAK,CAAC,CAAC;IACxB,UAAU,EAAE,IAAA,oBAAM,GAAE;IACpB,YAAY,EAAE,IAAA,oBAAM,G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AAsB,CAAC,CAAC;CAChD,CAAC,CAAC;AAEU,QAAA,qBAAqB,GAAG,IAAA,kBAAI,EAAC;IACxC,QAAQ,EAAE,IAAA,mBAAK,EAAC,oBAAoB,CAAC;IACrC,cAAc,EAAE,IAAA,mBAAK,EAAC,0BAA0B,CAAC;CAClD,CAAC,CAAC;AAEH,MAAM,YAAY,GAAG,IAAA,kBAAI,EAAC;IACxB,MAAM,EAAE,IAAA,oBAAM,GAAE;IAChB,eAAe,EAAE,IAAA,oBAAM,GAAE;IACzB,QAAQ,EAAE,IAAA,oBAAM,GAAE;IAClB,QAAQ,EAAE,IAAA,qBAAO,GAAE;CACpB,CAAC,CAAC;AAEU,QAAA,6BAA6B,GAAG,IAAA,kBAAI,EAAC;IAChD,OAAO,EAAE,iBAAiB;IAC1B,YAAY,EAAE,IAAA,sBAAQ,EAAC,IAAA,qBAAO,GAAE,CAAC;IACjC,iBAAiB,EAAE,IAAA,sBAAQ,EAAC,IAAA,qBAAO,GAAE,CAAC;IACtC,SAAS,EAAE,IAAA,sBAAQ,EAAC,IAAA,mBAAK,EAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;IACtC,OAAO,EAAE,IAAA,sBAAQ,EAAC,IAAA,mBAAK,EAAC,YAAY,CAAC,CAAC;IACtC,cAAc,EAAE,IAAA,sBAAQ,EAAC,IAAA,sBAAQ,EAAC,IAAA,oBAAM,GAAE,CAAC,CAAC;IAC5C,UAAU,EAAE,IAAA,sBAAQ,EAAC,IAAA,oBAAM,GAAE,CAAC;IAC9B,wBAAwB,EAAE,IAAA,sBAAQ,EAAC,IAAA,qBAAO,GAAE,CAAC;CAC9C,CAAC,CAAC;AAEU,QAAA,kCAAkC,GAAG,IAAA,mBAAK,EACrD,qCAA6B,CAC9B,CAAC","sourcesContent":["import {\n array,\n boolean,\n enums,\n nullable,\n number,\n optional,\n string,\n type,\n union,\n} from '@metamask/superstruct';\nimport { StrictHexStruct, CaipAccountIdStruct } from '@metamask/utils';\n\nimport {\n CANCEL_TYPES,\n CRYPTO_PAYMENT_METHOD_ERRORS,\n PAYMENT_TYPES,\n PRODUCT_TYPES,\n RECURRING_INTERVALS,\n SUBSCRIPTION_STATUSES,\n} from './types.js';\n\nconst ProductTypeStruct = enums(Object.values(PRODUCT_TYPES));\nconst PaymentTypeStruct = enums(Object.values(PAYMENT_TYPES));\nconst RecurringIntervalStruct = enums(Object.values(RECURRING_INTERVALS));\nconst SubscriptionStatusStruct = enums(Object.values(SUBSCRIPTION_STATUSES));\nconst CancelTypeStruct = enums(Object.values(CANCEL_TYPES));\nconst CryptoPaymentMethodErrorStruct = enums(\n Object.values(CRYPTO_PAYMENT_METHOD_ERRORS),\n);\n\nconst ProductStruct = type({\n name: ProductTypeStruct,\n currency: enums(['usd']),\n unitAmount: number(),\n unitDecimals: number(),\n});\n\nconst SubscriptionCardPaymentMethodStruct = type({\n type: enums([PAYMENT_TYPES.byCard]),\n card: type({\n brand: string(),\n displayBrand: string(),\n last4: string(),\n }),\n});\n\nconst SubscriptionCryptoPaymentMethodStruct = type({\n type: enums([PAYMENT_TYPES.byCrypto]),\n crypto: type({\n payerAddress: StrictHexStruct,\n chainId: StrictHexStruct,\n tokenSymbol: string(),\n error: optional(CryptoPaymentMethodErrorStruct),\n }),\n});\n\nconst SubscriptionPaymentMethodStruct = union([\n SubscriptionCardPaymentMethodStruct,\n SubscriptionCryptoPaymentMethodStruct,\n]);\n\nexport const SubscriptionStruct = type({\n id: string(),\n products: array(ProductStruct),\n currentPeriodStart: string(),\n currentPeriodEnd: string(),\n cancelAtPeriodEnd: optional(boolean()),\n status: SubscriptionStatusStruct,\n interval: RecurringIntervalStruct,\n paymentMethod: SubscriptionPaymentMethodStruct,\n trialPeriodDays: optional(number()),\n trialStart: optional(string()),\n trialEnd: optional(string()),\n endDate: optional(string()),\n canceledAt: optional(string()),\n cancelType: CancelTypeStruct,\n inactiveAt: optional(string()),\n isEligibleForSupport: boolean(),\n billingCycles: optional(number()),\n});\n\nexport const GetSubscriptionsResponseStruct = type({\n customerId: optional(string()),\n subscriptions: array(SubscriptionStruct),\n trialedProducts: array(ProductTypeStruct),\n lastSubscription: optional(SubscriptionStruct),\n rewardAccountId: optional(CaipAccountIdStruct),\n});\n\nexport const StartSubscriptionResponseStruct = type({\n checkoutSessionUrl: string(),\n});\n\nexport const StartCryptoSubscriptionResponseStruct = type({\n subscriptionId: string(),\n status: SubscriptionStatusStruct,\n});\n\nexport const UpdatePaymentMethodCardResponseStruct = type({\n redirectUrl: string(),\n});\n\nexport const BillingPortalResponseStruct = type({\n url: string(),\n});\n\nexport const SubscriptionApiGeneralResponseStruct = type({\n success: boolean(),\n message: optional(string()),\n});\n\nconst ProductPriceStruct = type({\n interval: RecurringIntervalStruct,\n unitAmount: number(),\n unitDecimals: number(),\n currency: enums(['usd']),\n trialPeriodDays: number(),\n minBillingCycles: number(),\n minBillingCyclesForBalance: number(),\n});\n\nconst ProductPricingStruct = type({\n name: ProductTypeStruct,\n prices: array(ProductPriceStruct),\n});\n\nconst TokenPaymentInfoStruct = type({\n symbol: string(),\n address: StrictHexStruct,\n decimals: number(),\n conversionRate: type({\n usd: string(),\n }),\n});\n\nconst ChainPaymentInfoStruct = type({\n chainId: StrictHexStruct,\n paymentAddress: StrictHexStruct,\n tokens: array(TokenPaymentInfoStruct),\n isSponsorshipSupported: optional(boolean()),\n});\n\nconst PricingPaymentMethodStruct = type({\n type: PaymentTypeStruct,\n chains: optional(array(ChainPaymentInfoStruct)),\n});\n\nexport const PricingResponseStruct = type({\n products: array(ProductPricingStruct),\n paymentMethods: array(PricingPaymentMethodStruct),\n});\n\nconst CohortStruct = type({\n cohort: string(),\n eligibilityRate: number(),\n priority: number(),\n eligible: boolean(),\n});\n\nexport const SubscriptionEligibilityStruct = type({\n product: ProductTypeStruct,\n canSubscribe: optional(boolean()),\n canViewEntryModal: optional(boolean()),\n modalType: optional(enums(['A', 'B'])),\n cohorts: optional(array(CohortStruct)),\n assignedCohort: optional(nullable(string())),\n assignedAt: optional(string()),\n hasAssignedCohortExpired: optional(boolean()),\n});\n\nexport const SubscriptionEligibilityArrayStruct = array(\n SubscriptionEligibilityStruct,\n);\n"]}
|