@metamask-previews/subscription-controller 6.2.2-preview-4c8a5dfcb → 6.2.2-preview-801e09874
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 +1 -8
- package/dist/SubscriptionController.cjs +26 -18
- package/dist/SubscriptionController.cjs.map +1 -1
- package/dist/SubscriptionController.d.cts +9 -5
- package/dist/SubscriptionController.d.cts.map +1 -1
- package/dist/SubscriptionController.d.mts +9 -5
- package/dist/SubscriptionController.d.mts.map +1 -1
- package/dist/SubscriptionController.mjs +26 -18
- package/dist/SubscriptionController.mjs.map +1 -1
- package/dist/SubscriptionService.cjs +87 -257
- package/dist/SubscriptionService.cjs.map +1 -1
- package/dist/SubscriptionService.d.cts +10 -90
- package/dist/SubscriptionService.d.cts.map +1 -1
- package/dist/SubscriptionService.d.mts +10 -90
- package/dist/SubscriptionService.d.mts.map +1 -1
- package/dist/SubscriptionService.mjs +87 -257
- package/dist/SubscriptionService.mjs.map +1 -1
- package/dist/index.cjs +1 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -4
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +3 -4
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -5
- package/dist/SubscriptionService-method-action-types.cjs +0 -7
- package/dist/SubscriptionService-method-action-types.cjs.map +0 -1
- package/dist/SubscriptionService-method-action-types.d.cts +0 -151
- package/dist/SubscriptionService-method-action-types.d.cts.map +0 -1
- package/dist/SubscriptionService-method-action-types.d.mts +0 -151
- package/dist/SubscriptionService-method-action-types.d.mts.map +0 -1
- package/dist/SubscriptionService-method-action-types.mjs +0 -6
- package/dist/SubscriptionService-method-action-types.mjs.map +0 -1
- package/dist/SubscriptionService-structs.cjs +0 -135
- package/dist/SubscriptionService-structs.cjs.map +0 -1
- package/dist/SubscriptionService-structs.d.cts +0 -773
- package/dist/SubscriptionService-structs.d.cts.map +0 -1
- package/dist/SubscriptionService-structs.d.mts +0 -773
- package/dist/SubscriptionService-structs.d.mts.map +0 -1
- package/dist/SubscriptionService-structs.mjs +0 -132
- package/dist/SubscriptionService-structs.mjs.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SubscriptionService-structs.d.mts","sourceRoot":"","sources":["../src/SubscriptionService-structs.ts"],"names":[],"mappings":"AA8DA,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkB7B,CAAC;AAEH,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAMzC,CAAC;AAEH,eAAO,MAAM,+BAA+B;;;;EAE1C,CAAC;AAEH,eAAO,MAAM,qCAAqC;;;;;;;;;;;;;;;;EAGhD,CAAC;AAEH,eAAO,MAAM,qCAAqC;;;;EAEhD,CAAC;AAEH,eAAO,MAAM,2BAA2B;;;;EAEtC,CAAC;AAEH,eAAO,MAAM,oCAAoC;;;;;;EAG/C,CAAC;AAsCH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAGhC,CAAC;AASH,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EASxC,CAAC;AAEH,eAAO,MAAM,kCAAkC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAE9C,CAAC"}
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import { array, boolean, enums, nullable, number, optional, string, type, union } from "@metamask/superstruct";
|
|
2
|
-
import { StrictHexStruct, CaipAccountIdStruct } from "@metamask/utils";
|
|
3
|
-
import { CANCEL_TYPES, CRYPTO_PAYMENT_METHOD_ERRORS, PAYMENT_TYPES, PRODUCT_TYPES, RECURRING_INTERVALS, SUBSCRIPTION_STATUSES } from "./types.mjs";
|
|
4
|
-
const ProductTypeStruct = enums(Object.values(PRODUCT_TYPES));
|
|
5
|
-
const PaymentTypeStruct = enums(Object.values(PAYMENT_TYPES));
|
|
6
|
-
const RecurringIntervalStruct = enums(Object.values(RECURRING_INTERVALS));
|
|
7
|
-
const SubscriptionStatusStruct = enums(Object.values(SUBSCRIPTION_STATUSES));
|
|
8
|
-
const CancelTypeStruct = enums(Object.values(CANCEL_TYPES));
|
|
9
|
-
const CryptoPaymentMethodErrorStruct = enums(Object.values(CRYPTO_PAYMENT_METHOD_ERRORS));
|
|
10
|
-
const ProductStruct = type({
|
|
11
|
-
name: ProductTypeStruct,
|
|
12
|
-
currency: enums(['usd']),
|
|
13
|
-
unitAmount: number(),
|
|
14
|
-
unitDecimals: number(),
|
|
15
|
-
});
|
|
16
|
-
const SubscriptionCardPaymentMethodStruct = type({
|
|
17
|
-
type: enums([PAYMENT_TYPES.byCard]),
|
|
18
|
-
card: type({
|
|
19
|
-
brand: string(),
|
|
20
|
-
displayBrand: string(),
|
|
21
|
-
last4: string(),
|
|
22
|
-
}),
|
|
23
|
-
});
|
|
24
|
-
const SubscriptionCryptoPaymentMethodStruct = type({
|
|
25
|
-
type: enums([PAYMENT_TYPES.byCrypto]),
|
|
26
|
-
crypto: type({
|
|
27
|
-
payerAddress: StrictHexStruct,
|
|
28
|
-
chainId: StrictHexStruct,
|
|
29
|
-
tokenSymbol: string(),
|
|
30
|
-
error: optional(CryptoPaymentMethodErrorStruct),
|
|
31
|
-
}),
|
|
32
|
-
});
|
|
33
|
-
const SubscriptionPaymentMethodStruct = union([
|
|
34
|
-
SubscriptionCardPaymentMethodStruct,
|
|
35
|
-
SubscriptionCryptoPaymentMethodStruct,
|
|
36
|
-
]);
|
|
37
|
-
export const SubscriptionStruct = type({
|
|
38
|
-
id: string(),
|
|
39
|
-
products: array(ProductStruct),
|
|
40
|
-
currentPeriodStart: string(),
|
|
41
|
-
currentPeriodEnd: string(),
|
|
42
|
-
cancelAtPeriodEnd: optional(boolean()),
|
|
43
|
-
status: SubscriptionStatusStruct,
|
|
44
|
-
interval: RecurringIntervalStruct,
|
|
45
|
-
paymentMethod: SubscriptionPaymentMethodStruct,
|
|
46
|
-
trialPeriodDays: optional(number()),
|
|
47
|
-
trialStart: optional(string()),
|
|
48
|
-
trialEnd: optional(string()),
|
|
49
|
-
endDate: optional(string()),
|
|
50
|
-
canceledAt: optional(string()),
|
|
51
|
-
cancelType: CancelTypeStruct,
|
|
52
|
-
inactiveAt: optional(string()),
|
|
53
|
-
isEligibleForSupport: boolean(),
|
|
54
|
-
billingCycles: optional(number()),
|
|
55
|
-
});
|
|
56
|
-
export const GetSubscriptionsResponseStruct = type({
|
|
57
|
-
customerId: optional(string()),
|
|
58
|
-
subscriptions: array(SubscriptionStruct),
|
|
59
|
-
trialedProducts: array(ProductTypeStruct),
|
|
60
|
-
lastSubscription: optional(SubscriptionStruct),
|
|
61
|
-
rewardAccountId: optional(CaipAccountIdStruct),
|
|
62
|
-
});
|
|
63
|
-
export const StartSubscriptionResponseStruct = type({
|
|
64
|
-
checkoutSessionUrl: string(),
|
|
65
|
-
});
|
|
66
|
-
export const StartCryptoSubscriptionResponseStruct = type({
|
|
67
|
-
subscriptionId: string(),
|
|
68
|
-
status: SubscriptionStatusStruct,
|
|
69
|
-
});
|
|
70
|
-
export const UpdatePaymentMethodCardResponseStruct = type({
|
|
71
|
-
redirectUrl: string(),
|
|
72
|
-
});
|
|
73
|
-
export const BillingPortalResponseStruct = type({
|
|
74
|
-
url: string(),
|
|
75
|
-
});
|
|
76
|
-
export const SubscriptionApiGeneralResponseStruct = type({
|
|
77
|
-
success: boolean(),
|
|
78
|
-
message: optional(string()),
|
|
79
|
-
});
|
|
80
|
-
const ProductPriceStruct = type({
|
|
81
|
-
interval: RecurringIntervalStruct,
|
|
82
|
-
unitAmount: number(),
|
|
83
|
-
unitDecimals: number(),
|
|
84
|
-
currency: enums(['usd']),
|
|
85
|
-
trialPeriodDays: number(),
|
|
86
|
-
minBillingCycles: number(),
|
|
87
|
-
minBillingCyclesForBalance: number(),
|
|
88
|
-
});
|
|
89
|
-
const ProductPricingStruct = type({
|
|
90
|
-
name: ProductTypeStruct,
|
|
91
|
-
prices: array(ProductPriceStruct),
|
|
92
|
-
});
|
|
93
|
-
const TokenPaymentInfoStruct = type({
|
|
94
|
-
symbol: string(),
|
|
95
|
-
address: StrictHexStruct,
|
|
96
|
-
decimals: number(),
|
|
97
|
-
conversionRate: type({
|
|
98
|
-
usd: string(),
|
|
99
|
-
}),
|
|
100
|
-
});
|
|
101
|
-
const ChainPaymentInfoStruct = type({
|
|
102
|
-
chainId: StrictHexStruct,
|
|
103
|
-
paymentAddress: StrictHexStruct,
|
|
104
|
-
tokens: array(TokenPaymentInfoStruct),
|
|
105
|
-
isSponsorshipSupported: optional(boolean()),
|
|
106
|
-
});
|
|
107
|
-
const PricingPaymentMethodStruct = type({
|
|
108
|
-
type: PaymentTypeStruct,
|
|
109
|
-
chains: optional(array(ChainPaymentInfoStruct)),
|
|
110
|
-
});
|
|
111
|
-
export const PricingResponseStruct = type({
|
|
112
|
-
products: array(ProductPricingStruct),
|
|
113
|
-
paymentMethods: array(PricingPaymentMethodStruct),
|
|
114
|
-
});
|
|
115
|
-
const CohortStruct = type({
|
|
116
|
-
cohort: string(),
|
|
117
|
-
eligibilityRate: number(),
|
|
118
|
-
priority: number(),
|
|
119
|
-
eligible: boolean(),
|
|
120
|
-
});
|
|
121
|
-
export const SubscriptionEligibilityStruct = type({
|
|
122
|
-
product: ProductTypeStruct,
|
|
123
|
-
canSubscribe: optional(boolean()),
|
|
124
|
-
canViewEntryModal: optional(boolean()),
|
|
125
|
-
modalType: optional(enums(['A', 'B'])),
|
|
126
|
-
cohorts: optional(array(CohortStruct)),
|
|
127
|
-
assignedCohort: optional(nullable(string())),
|
|
128
|
-
assignedAt: optional(string()),
|
|
129
|
-
hasAssignedCohortExpired: optional(boolean()),
|
|
130
|
-
});
|
|
131
|
-
export const SubscriptionEligibilityArrayStruct = array(SubscriptionEligibilityStruct);
|
|
132
|
-
//# sourceMappingURL=SubscriptionService-structs.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SubscriptionService-structs.mjs","sourceRoot":"","sources":["../src/SubscriptionService-structs.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,OAAO,EACP,KAAK,EACL,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,KAAK,EACN,8BAA8B;AAC/B,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,wBAAwB;AAEvE,OAAO,EACL,YAAY,EACZ,4BAA4B,EAC5B,aAAa,EACb,aAAa,EACb,mBAAmB,EACnB,qBAAqB,EACtB,oBAAmB;AAEpB,MAAM,iBAAiB,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC;AAC9D,MAAM,iBAAiB,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,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,MAAM,0BAA0B,GAAG,IAAI,CAAC;IACtC,IAAI,EAAE,iBAAiB;IACvB,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAAC;CAChD,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,CAAC;IACxC,QAAQ,EAAE,KAAK,CAAC,oBAAoB,CAAC;IACrC,cAAc,EAAE,KAAK,CAAC,0BAA0B,CAAC;CAClD,CAAC,CAAC;AAEH,MAAM,YAAY,GAAG,IAAI,CAAC;IACxB,MAAM,EAAE,MAAM,EAAE;IAChB,eAAe,EAAE,MAAM,EAAE;IACzB,QAAQ,EAAE,MAAM,EAAE;IAClB,QAAQ,EAAE,OAAO,EAAE;CACpB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,6BAA6B,GAAG,IAAI,CAAC;IAChD,OAAO,EAAE,iBAAiB;IAC1B,YAAY,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAC;IACjC,iBAAiB,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAC;IACtC,SAAS,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;IACtC,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IACtC,cAAc,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IAC5C,UAAU,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;IAC9B,wBAAwB,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAC;CAC9C,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,kCAAkC,GAAG,KAAK,CACrD,6BAA6B,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"]}
|