@shware/purchase 1.8.9 → 2.0.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/dist/_virtual/_rolldown/runtime.cjs +23 -0
- package/dist/app-store/config.cjs +105 -128
- package/dist/app-store/config.cjs.map +1 -1
- package/dist/app-store/config.d.cts +36 -33
- package/dist/app-store/config.d.cts.map +1 -0
- package/dist/app-store/config.d.mts +42 -0
- package/dist/app-store/config.d.mts.map +1 -0
- package/dist/app-store/config.mjs +100 -91
- package/dist/app-store/config.mjs.map +1 -1
- package/dist/app-store/index.cjs +3 -31
- package/dist/app-store/index.d.cts +2 -3
- package/dist/app-store/index.d.mts +2 -0
- package/dist/app-store/index.mjs +1 -5
- package/dist/google-play/config.cjs +108 -123
- package/dist/google-play/config.cjs.map +1 -1
- package/dist/google-play/config.d.cts +35 -33
- package/dist/google-play/config.d.cts.map +1 -0
- package/dist/google-play/config.d.mts +41 -0
- package/dist/google-play/config.d.mts.map +1 -0
- package/dist/google-play/config.mjs +103 -86
- package/dist/google-play/config.mjs.map +1 -1
- package/dist/google-play/index.cjs +9 -42
- package/dist/google-play/index.d.cts +3 -4
- package/dist/google-play/index.d.mts +3 -0
- package/dist/google-play/index.mjs +2 -17
- package/dist/google-play/real-time-developer-notification.cjs +122 -81
- package/dist/google-play/real-time-developer-notification.cjs.map +1 -1
- package/dist/google-play/real-time-developer-notification.d.cts +119 -117
- package/dist/google-play/real-time-developer-notification.d.cts.map +1 -0
- package/dist/google-play/real-time-developer-notification.d.mts +150 -0
- package/dist/google-play/real-time-developer-notification.d.mts.map +1 -0
- package/dist/google-play/real-time-developer-notification.mjs +118 -53
- package/dist/google-play/real-time-developer-notification.mjs.map +1 -1
- package/dist/index.cjs +13 -48
- package/dist/index.d.cts +5 -6
- package/dist/index.d.mts +5 -0
- package/dist/index.mjs +2 -19
- package/dist/stripe/config.cjs +114 -133
- package/dist/stripe/config.cjs.map +1 -1
- package/dist/stripe/config.d.cts +46 -37
- package/dist/stripe/config.d.cts.map +1 -0
- package/dist/stripe/config.d.mts +52 -0
- package/dist/stripe/config.d.mts.map +1 -0
- package/dist/stripe/config.mjs +109 -96
- package/dist/stripe/config.mjs.map +1 -1
- package/dist/stripe/handler.cjs +25 -53
- package/dist/stripe/handler.cjs.map +1 -1
- package/dist/stripe/handler.d.cts +10 -9
- package/dist/stripe/handler.d.cts.map +1 -0
- package/dist/stripe/handler.d.mts +16 -0
- package/dist/stripe/handler.d.mts.map +1 -0
- package/dist/stripe/handler.mjs +25 -29
- package/dist/stripe/handler.mjs.map +1 -1
- package/dist/stripe/index.cjs +27 -74
- package/dist/stripe/index.d.cts +8 -12
- package/dist/stripe/index.d.mts +8 -0
- package/dist/stripe/index.mjs +5 -44
- package/dist/stripe/mapper.cjs +168 -219
- package/dist/stripe/mapper.cjs.map +1 -1
- package/dist/stripe/mapper.d.cts +115 -114
- package/dist/stripe/mapper.d.cts.map +1 -0
- package/dist/stripe/mapper.d.mts +158 -0
- package/dist/stripe/mapper.d.mts.map +1 -0
- package/dist/stripe/mapper.mjs +155 -182
- package/dist/stripe/mapper.mjs.map +1 -1
- package/dist/stripe/metadata.cjs +11 -35
- package/dist/stripe/metadata.cjs.map +1 -1
- package/dist/stripe/metadata.d.cts +9 -7
- package/dist/stripe/metadata.d.cts.map +1 -0
- package/dist/stripe/metadata.d.mts +12 -0
- package/dist/stripe/metadata.d.mts.map +1 -0
- package/dist/stripe/metadata.mjs +11 -11
- package/dist/stripe/metadata.mjs.map +1 -1
- package/dist/stripe/pending-checkout.cjs +55 -61
- package/dist/stripe/pending-checkout.cjs.map +1 -1
- package/dist/stripe/pending-checkout.d.cts +3 -1
- package/dist/stripe/pending-checkout.d.cts.map +1 -0
- package/dist/stripe/{pending-checkout.d.ts → pending-checkout.d.mts} +3 -1
- package/dist/stripe/pending-checkout.d.mts.map +1 -0
- package/dist/stripe/pending-checkout.mjs +52 -34
- package/dist/stripe/pending-checkout.mjs.map +1 -1
- package/dist/stripe/schema.cjs +30 -55
- package/dist/stripe/schema.cjs.map +1 -1
- package/dist/stripe/schema.d.cts +36 -37
- package/dist/stripe/schema.d.cts.map +1 -0
- package/dist/stripe/schema.d.mts +40 -0
- package/dist/stripe/schema.d.mts.map +1 -0
- package/dist/stripe/schema.mjs +28 -40
- package/dist/stripe/schema.mjs.map +1 -1
- package/dist/subscription/index.cjs +178 -80
- package/dist/subscription/index.cjs.map +1 -1
- package/dist/subscription/index.d.cts +136 -134
- package/dist/subscription/index.d.cts.map +1 -0
- package/dist/subscription/index.d.mts +150 -0
- package/dist/subscription/index.d.mts.map +1 -0
- package/dist/subscription/index.mjs +173 -51
- package/dist/subscription/index.mjs.map +1 -1
- package/dist/types.cjs +0 -19
- package/dist/types.d.cts +7 -6
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.mts +10 -0
- package/dist/types.d.mts.map +1 -0
- package/dist/types.mjs +1 -1
- package/package.json +40 -25
- package/dist/app-store/config.d.ts +0 -39
- package/dist/app-store/index.cjs.map +0 -1
- package/dist/app-store/index.d.ts +0 -3
- package/dist/app-store/index.mjs.map +0 -1
- package/dist/google-play/config.d.ts +0 -39
- package/dist/google-play/index.cjs.map +0 -1
- package/dist/google-play/index.d.ts +0 -4
- package/dist/google-play/index.mjs.map +0 -1
- package/dist/google-play/real-time-developer-notification.d.ts +0 -148
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.ts +0 -6
- package/dist/index.mjs.map +0 -1
- package/dist/stripe/config.d.ts +0 -43
- package/dist/stripe/handler.d.ts +0 -15
- package/dist/stripe/index.cjs.map +0 -1
- package/dist/stripe/index.d.ts +0 -12
- package/dist/stripe/index.mjs.map +0 -1
- package/dist/stripe/mapper.d.ts +0 -157
- package/dist/stripe/metadata.d.ts +0 -10
- package/dist/stripe/schema.d.ts +0 -41
- package/dist/subscription/index.d.ts +0 -148
- package/dist/types.cjs.map +0 -1
- package/dist/types.d.ts +0 -9
- package/dist/types.mjs.map +0 -1
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
//#region src/subscription/index.d.ts
|
|
2
|
+
declare enum Platform {
|
|
3
|
+
APPLE = "APPLE",
|
|
4
|
+
GOOGLE = "GOOGLE",
|
|
5
|
+
STRIPE = "STRIPE"
|
|
6
|
+
}
|
|
7
|
+
declare const ALL_PLATFORMS: readonly [Platform.APPLE, Platform.GOOGLE, Platform.STRIPE];
|
|
8
|
+
/**
|
|
9
|
+
* [Stripe Subscription Status](https://stripe.com/docs/api/subscriptions/object#subscription_object-status)
|
|
10
|
+
* [Stripe Subscription Lifecycle](https://docs.stripe.com/billing/subscriptions/overview)
|
|
11
|
+
*
|
|
12
|
+
* provision product for customer when Status = TRIALING, ACTIVE, IN_GRACE_PERIOD
|
|
13
|
+
*/
|
|
14
|
+
declare enum SubscriptionStatus {
|
|
15
|
+
/**
|
|
16
|
+
* The subscription is currently in a trial period and it’s safe to provision your product for
|
|
17
|
+
* your customer. The subscription transitions automatically to active when the first payment
|
|
18
|
+
* is made.
|
|
19
|
+
*
|
|
20
|
+
* Google: play(LineItems[0].OfferDetails.OfferId == 'xx')
|
|
21
|
+
*
|
|
22
|
+
* Platform: Apple, Google, Stripe
|
|
23
|
+
* */
|
|
24
|
+
TRIALING = "TRIALING",
|
|
25
|
+
/**
|
|
26
|
+
* The subscription is in good standing and the most recent payment is successful. It’s safe to
|
|
27
|
+
* provision your product for your customer.
|
|
28
|
+
*
|
|
29
|
+
* Platform: Apple, Google, Stripe
|
|
30
|
+
* */
|
|
31
|
+
ACTIVE = "ACTIVE",
|
|
32
|
+
/**
|
|
33
|
+
* Apple: The subscription enters the billing retry period. If the subtype is GRACE_PERIOD,
|
|
34
|
+
* continue to provide service through the grace period. If the subtype is empty, the
|
|
35
|
+
* subscription isn’t in a grace period and you can stop providing the subscription service.
|
|
36
|
+
*
|
|
37
|
+
* Google: Subscription is in grace period. The state is only available when the subscription
|
|
38
|
+
* is an auto renewing plan. In this state, all items are in grace period.
|
|
39
|
+
*
|
|
40
|
+
* Platform: Apple, Google
|
|
41
|
+
* */
|
|
42
|
+
IN_GRACE_PERIOD = "IN_GRACE_PERIOD",
|
|
43
|
+
/**
|
|
44
|
+
* A successful payment needs to be made within 23 hours to activate the subscription. Or the
|
|
45
|
+
* payment requires action, like customer authentication. Subscriptions can also be incomplete
|
|
46
|
+
* if there’s a pending payment and the PaymentIntent status would be processing.
|
|
47
|
+
*
|
|
48
|
+
* Platform: Stripe
|
|
49
|
+
* */
|
|
50
|
+
INCOMPLETE = "INCOMPLETE",
|
|
51
|
+
/**
|
|
52
|
+
* The initial payment on the subscription failed and no successful payment was made within 23
|
|
53
|
+
* hours of creating the subscription. These subscriptions don’t bill customers. This status
|
|
54
|
+
* exists so you can track customers that failed to activate their subscriptions.
|
|
55
|
+
*
|
|
56
|
+
* Platform: Stripe
|
|
57
|
+
* */
|
|
58
|
+
INCOMPLETE_EXPIRED = "INCOMPLETE_EXPIRED",
|
|
59
|
+
/**
|
|
60
|
+
* Subscription was created but awaiting payment during signup. In this state, all items are
|
|
61
|
+
* awaiting payment.
|
|
62
|
+
*
|
|
63
|
+
* Platform: Google
|
|
64
|
+
* */
|
|
65
|
+
PENDING = "PENDING",
|
|
66
|
+
/**
|
|
67
|
+
* Pending transaction for subscription is canceled. If this pending purchase was for an
|
|
68
|
+
* existing subscription, use linkedPurchaseToken to get the current state of that subscription.
|
|
69
|
+
*
|
|
70
|
+
* Platform: Google
|
|
71
|
+
* */
|
|
72
|
+
PENDING_PURCHASE_CANCELED = "PENDING_PURCHASE_CANCELED",
|
|
73
|
+
/**
|
|
74
|
+
* Payment on the latest finalized invoice either failed or wasn’t attempted. The subscription
|
|
75
|
+
* continues to create invoices. Your subscription settings determine the subscription’s next
|
|
76
|
+
* state. If the invoice is still unpaid after all Smart Retries have been attempted, you can
|
|
77
|
+
* configure the subscription to move to canceled, unpaid, or leave it as past_due. To move the
|
|
78
|
+
* subscription to active, pay the most recent invoice before its due date.
|
|
79
|
+
*
|
|
80
|
+
* Platform: Stripe
|
|
81
|
+
* */
|
|
82
|
+
PAST_DUE = "PAST_DUE",
|
|
83
|
+
/**
|
|
84
|
+
* Subscription is on hold (suspended). The state is only available when the subscription is an
|
|
85
|
+
* auto renewing plan. In this state, all items are on hold. Grace period ends or Active period
|
|
86
|
+
* ends but not grace period
|
|
87
|
+
*
|
|
88
|
+
* Platform: Google
|
|
89
|
+
* */
|
|
90
|
+
ON_HOLD = "ON_HOLD",
|
|
91
|
+
/**
|
|
92
|
+
* The subscription has been canceled. During cancellation, automatic collection for all unpaid
|
|
93
|
+
* invoices is disabled (auto_advance=false). This is a terminal state that can’t be updated.
|
|
94
|
+
*
|
|
95
|
+
* Platform: Apple, Google, Stripe
|
|
96
|
+
* */
|
|
97
|
+
CANCELED = "CANCELED",
|
|
98
|
+
/**
|
|
99
|
+
* The latest invoice hasn’t been paid but the subscription remains in place. The latest invoice
|
|
100
|
+
* remains open and invoices continue to be generated but payments aren’t attempted. You should
|
|
101
|
+
* revoke access to your product when the subscription is unpaid since payments were already
|
|
102
|
+
* attempted and retried when it was past_due. To move the subscription to active, pay the most
|
|
103
|
+
* recent invoice before its due date.
|
|
104
|
+
*
|
|
105
|
+
* Platform: Stripe
|
|
106
|
+
* */
|
|
107
|
+
UNPAID = "UNPAID",
|
|
108
|
+
/**
|
|
109
|
+
* Google: Subscription is paused. The state is only available when the subscription is an auto
|
|
110
|
+
* renewing plan. In this state, all items are in paused state.
|
|
111
|
+
*
|
|
112
|
+
* Stripe: The subscription has ended its trial period without a default payment method and the
|
|
113
|
+
* trial_settings.end_behavior.missing_payment_method is set to pause. Invoices will no longer
|
|
114
|
+
* be created for the subscription. After a default payment method has been attached to the
|
|
115
|
+
* customer, you can resume the subscription.
|
|
116
|
+
*
|
|
117
|
+
* Platform: Google, Stripe
|
|
118
|
+
* */
|
|
119
|
+
PAUSED = "PAUSED",
|
|
120
|
+
/**
|
|
121
|
+
* For example, a user buys a subscription and receives a purchase token A. The
|
|
122
|
+
* linkedPurchaseToken field will not be set in the API response because the purchase token
|
|
123
|
+
* belongs to a brand new subscription.
|
|
124
|
+
*
|
|
125
|
+
* If the user upgrades their subscription, a new purchase token B will be generated. Since the
|
|
126
|
+
* upgrade is replacing the subscription from purchase token A, the linkedPurchaseToken field
|
|
127
|
+
* for token B will be set to point to token A. Notice it points backwards in time to the
|
|
128
|
+
* original purchase token.
|
|
129
|
+
*
|
|
130
|
+
* +---------------------------+ +------------------------+ +------------------------+
|
|
131
|
+
* | Step 1 first purchase | | Step 2 upgrades | | Step 3 downgrades |
|
|
132
|
+
* | purchaseToken: A |->| purchaseToken: B |->| purchaseToken: C |
|
|
133
|
+
* | linkedPurchaseToken: null | | linkedPurchaseToken: A | | linkedPurchaseToken: B |
|
|
134
|
+
* +---------------------------+ +------------------------+ +------------------------+
|
|
135
|
+
*
|
|
136
|
+
* Platform: Google
|
|
137
|
+
* */
|
|
138
|
+
REPLACED = "REPLACED",
|
|
139
|
+
/**
|
|
140
|
+
* Google: Subscription is expired. All items have expiryTime in the past.
|
|
141
|
+
*
|
|
142
|
+
* Platform: Apple, Google
|
|
143
|
+
* */
|
|
144
|
+
EXPIRED = "EXPIRED"
|
|
145
|
+
}
|
|
146
|
+
declare const AVAILABLE_STATUS: SubscriptionStatus[];
|
|
147
|
+
declare const ALL_SUBSCRIPTION_STATUS: readonly [SubscriptionStatus.TRIALING, SubscriptionStatus.ACTIVE, SubscriptionStatus.IN_GRACE_PERIOD, SubscriptionStatus.INCOMPLETE, SubscriptionStatus.INCOMPLETE_EXPIRED, SubscriptionStatus.PENDING, SubscriptionStatus.PENDING_PURCHASE_CANCELED, SubscriptionStatus.PAST_DUE, SubscriptionStatus.ON_HOLD, SubscriptionStatus.CANCELED, SubscriptionStatus.UNPAID, SubscriptionStatus.PAUSED, SubscriptionStatus.REPLACED, SubscriptionStatus.EXPIRED];
|
|
148
|
+
//#endregion
|
|
149
|
+
export { ALL_PLATFORMS, ALL_SUBSCRIPTION_STATUS, AVAILABLE_STATUS, Platform, SubscriptionStatus };
|
|
150
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/subscription/index.ts"],"mappings":";aAAY;EACV;EACA;EACA;;cAGW,yBAAa,SAAA,OAAA,SAAA,QAAA,SAAA;;;;;;;aAQd;;;;;;;;;;EAUV;;;;;;;EAQA;;;;;;;;;;;EAYA;;;;;;;;EASA;;;;;;;;EASA;;;;;;;EAQA;;;;;;;EAQA;;;;;;;;;;EAWA;;;;;;;;EASA;;;;;;;EAQA;;;;;;;;;;EAWA;;;;;;;;;;;;EAaA;;;;;;;;;;;;;;;;;;;EAoBA;;;;;;EAOA;;cAGW,kBAAgB;cAMhB,mCAAuB,mBAAA,UAAA,mBAAA,QAAA,mBAAA,iBAAA,mBAAA,YAAA,mBAAA,oBAAA,mBAAA,SAAA,mBAAA,2BAAA,mBAAA,UAAA,mBAAA,SAAA,mBAAA,UAAA,mBAAA,QAAA,mBAAA,QAAA,mBAAA,UAAA,mBAAA"}
|
|
@@ -1,54 +1,176 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
SubscriptionStatus2["IN_GRACE_PERIOD"] = "IN_GRACE_PERIOD";
|
|
13
|
-
SubscriptionStatus2["INCOMPLETE"] = "INCOMPLETE";
|
|
14
|
-
SubscriptionStatus2["INCOMPLETE_EXPIRED"] = "INCOMPLETE_EXPIRED";
|
|
15
|
-
SubscriptionStatus2["PENDING"] = "PENDING";
|
|
16
|
-
SubscriptionStatus2["PENDING_PURCHASE_CANCELED"] = "PENDING_PURCHASE_CANCELED";
|
|
17
|
-
SubscriptionStatus2["PAST_DUE"] = "PAST_DUE";
|
|
18
|
-
SubscriptionStatus2["ON_HOLD"] = "ON_HOLD";
|
|
19
|
-
SubscriptionStatus2["CANCELED"] = "CANCELED";
|
|
20
|
-
SubscriptionStatus2["UNPAID"] = "UNPAID";
|
|
21
|
-
SubscriptionStatus2["PAUSED"] = "PAUSED";
|
|
22
|
-
SubscriptionStatus2["REPLACED"] = "REPLACED";
|
|
23
|
-
SubscriptionStatus2["EXPIRED"] = "EXPIRED";
|
|
24
|
-
return SubscriptionStatus2;
|
|
25
|
-
})(SubscriptionStatus || {});
|
|
26
|
-
var AVAILABLE_STATUS = [
|
|
27
|
-
"ACTIVE" /* ACTIVE */,
|
|
28
|
-
"TRIALING" /* TRIALING */,
|
|
29
|
-
"IN_GRACE_PERIOD" /* IN_GRACE_PERIOD */
|
|
1
|
+
//#region src/subscription/index.ts
|
|
2
|
+
let Platform = /* @__PURE__ */ function(Platform) {
|
|
3
|
+
Platform["APPLE"] = "APPLE";
|
|
4
|
+
Platform["GOOGLE"] = "GOOGLE";
|
|
5
|
+
Platform["STRIPE"] = "STRIPE";
|
|
6
|
+
return Platform;
|
|
7
|
+
}({});
|
|
8
|
+
const ALL_PLATFORMS = [
|
|
9
|
+
"APPLE",
|
|
10
|
+
"GOOGLE",
|
|
11
|
+
"STRIPE"
|
|
30
12
|
];
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
13
|
+
/**
|
|
14
|
+
* [Stripe Subscription Status](https://stripe.com/docs/api/subscriptions/object#subscription_object-status)
|
|
15
|
+
* [Stripe Subscription Lifecycle](https://docs.stripe.com/billing/subscriptions/overview)
|
|
16
|
+
*
|
|
17
|
+
* provision product for customer when Status = TRIALING, ACTIVE, IN_GRACE_PERIOD
|
|
18
|
+
*/
|
|
19
|
+
let SubscriptionStatus = /* @__PURE__ */ function(SubscriptionStatus) {
|
|
20
|
+
/**
|
|
21
|
+
* The subscription is currently in a trial period and it’s safe to provision your product for
|
|
22
|
+
* your customer. The subscription transitions automatically to active when the first payment
|
|
23
|
+
* is made.
|
|
24
|
+
*
|
|
25
|
+
* Google: play(LineItems[0].OfferDetails.OfferId == 'xx')
|
|
26
|
+
*
|
|
27
|
+
* Platform: Apple, Google, Stripe
|
|
28
|
+
* */
|
|
29
|
+
SubscriptionStatus["TRIALING"] = "TRIALING";
|
|
30
|
+
/**
|
|
31
|
+
* The subscription is in good standing and the most recent payment is successful. It’s safe to
|
|
32
|
+
* provision your product for your customer.
|
|
33
|
+
*
|
|
34
|
+
* Platform: Apple, Google, Stripe
|
|
35
|
+
* */
|
|
36
|
+
SubscriptionStatus["ACTIVE"] = "ACTIVE";
|
|
37
|
+
/**
|
|
38
|
+
* Apple: The subscription enters the billing retry period. If the subtype is GRACE_PERIOD,
|
|
39
|
+
* continue to provide service through the grace period. If the subtype is empty, the
|
|
40
|
+
* subscription isn’t in a grace period and you can stop providing the subscription service.
|
|
41
|
+
*
|
|
42
|
+
* Google: Subscription is in grace period. The state is only available when the subscription
|
|
43
|
+
* is an auto renewing plan. In this state, all items are in grace period.
|
|
44
|
+
*
|
|
45
|
+
* Platform: Apple, Google
|
|
46
|
+
* */
|
|
47
|
+
SubscriptionStatus["IN_GRACE_PERIOD"] = "IN_GRACE_PERIOD";
|
|
48
|
+
/**
|
|
49
|
+
* A successful payment needs to be made within 23 hours to activate the subscription. Or the
|
|
50
|
+
* payment requires action, like customer authentication. Subscriptions can also be incomplete
|
|
51
|
+
* if there’s a pending payment and the PaymentIntent status would be processing.
|
|
52
|
+
*
|
|
53
|
+
* Platform: Stripe
|
|
54
|
+
* */
|
|
55
|
+
SubscriptionStatus["INCOMPLETE"] = "INCOMPLETE";
|
|
56
|
+
/**
|
|
57
|
+
* The initial payment on the subscription failed and no successful payment was made within 23
|
|
58
|
+
* hours of creating the subscription. These subscriptions don’t bill customers. This status
|
|
59
|
+
* exists so you can track customers that failed to activate their subscriptions.
|
|
60
|
+
*
|
|
61
|
+
* Platform: Stripe
|
|
62
|
+
* */
|
|
63
|
+
SubscriptionStatus["INCOMPLETE_EXPIRED"] = "INCOMPLETE_EXPIRED";
|
|
64
|
+
/**
|
|
65
|
+
* Subscription was created but awaiting payment during signup. In this state, all items are
|
|
66
|
+
* awaiting payment.
|
|
67
|
+
*
|
|
68
|
+
* Platform: Google
|
|
69
|
+
* */
|
|
70
|
+
SubscriptionStatus["PENDING"] = "PENDING";
|
|
71
|
+
/**
|
|
72
|
+
* Pending transaction for subscription is canceled. If this pending purchase was for an
|
|
73
|
+
* existing subscription, use linkedPurchaseToken to get the current state of that subscription.
|
|
74
|
+
*
|
|
75
|
+
* Platform: Google
|
|
76
|
+
* */
|
|
77
|
+
SubscriptionStatus["PENDING_PURCHASE_CANCELED"] = "PENDING_PURCHASE_CANCELED";
|
|
78
|
+
/**
|
|
79
|
+
* Payment on the latest finalized invoice either failed or wasn’t attempted. The subscription
|
|
80
|
+
* continues to create invoices. Your subscription settings determine the subscription’s next
|
|
81
|
+
* state. If the invoice is still unpaid after all Smart Retries have been attempted, you can
|
|
82
|
+
* configure the subscription to move to canceled, unpaid, or leave it as past_due. To move the
|
|
83
|
+
* subscription to active, pay the most recent invoice before its due date.
|
|
84
|
+
*
|
|
85
|
+
* Platform: Stripe
|
|
86
|
+
* */
|
|
87
|
+
SubscriptionStatus["PAST_DUE"] = "PAST_DUE";
|
|
88
|
+
/**
|
|
89
|
+
* Subscription is on hold (suspended). The state is only available when the subscription is an
|
|
90
|
+
* auto renewing plan. In this state, all items are on hold. Grace period ends or Active period
|
|
91
|
+
* ends but not grace period
|
|
92
|
+
*
|
|
93
|
+
* Platform: Google
|
|
94
|
+
* */
|
|
95
|
+
SubscriptionStatus["ON_HOLD"] = "ON_HOLD";
|
|
96
|
+
/**
|
|
97
|
+
* The subscription has been canceled. During cancellation, automatic collection for all unpaid
|
|
98
|
+
* invoices is disabled (auto_advance=false). This is a terminal state that can’t be updated.
|
|
99
|
+
*
|
|
100
|
+
* Platform: Apple, Google, Stripe
|
|
101
|
+
* */
|
|
102
|
+
SubscriptionStatus["CANCELED"] = "CANCELED";
|
|
103
|
+
/**
|
|
104
|
+
* The latest invoice hasn’t been paid but the subscription remains in place. The latest invoice
|
|
105
|
+
* remains open and invoices continue to be generated but payments aren’t attempted. You should
|
|
106
|
+
* revoke access to your product when the subscription is unpaid since payments were already
|
|
107
|
+
* attempted and retried when it was past_due. To move the subscription to active, pay the most
|
|
108
|
+
* recent invoice before its due date.
|
|
109
|
+
*
|
|
110
|
+
* Platform: Stripe
|
|
111
|
+
* */
|
|
112
|
+
SubscriptionStatus["UNPAID"] = "UNPAID";
|
|
113
|
+
/**
|
|
114
|
+
* Google: Subscription is paused. The state is only available when the subscription is an auto
|
|
115
|
+
* renewing plan. In this state, all items are in paused state.
|
|
116
|
+
*
|
|
117
|
+
* Stripe: The subscription has ended its trial period without a default payment method and the
|
|
118
|
+
* trial_settings.end_behavior.missing_payment_method is set to pause. Invoices will no longer
|
|
119
|
+
* be created for the subscription. After a default payment method has been attached to the
|
|
120
|
+
* customer, you can resume the subscription.
|
|
121
|
+
*
|
|
122
|
+
* Platform: Google, Stripe
|
|
123
|
+
* */
|
|
124
|
+
SubscriptionStatus["PAUSED"] = "PAUSED";
|
|
125
|
+
/**
|
|
126
|
+
* For example, a user buys a subscription and receives a purchase token A. The
|
|
127
|
+
* linkedPurchaseToken field will not be set in the API response because the purchase token
|
|
128
|
+
* belongs to a brand new subscription.
|
|
129
|
+
*
|
|
130
|
+
* If the user upgrades their subscription, a new purchase token B will be generated. Since the
|
|
131
|
+
* upgrade is replacing the subscription from purchase token A, the linkedPurchaseToken field
|
|
132
|
+
* for token B will be set to point to token A. Notice it points backwards in time to the
|
|
133
|
+
* original purchase token.
|
|
134
|
+
*
|
|
135
|
+
* +---------------------------+ +------------------------+ +------------------------+
|
|
136
|
+
* | Step 1 first purchase | | Step 2 upgrades | | Step 3 downgrades |
|
|
137
|
+
* | purchaseToken: A |->| purchaseToken: B |->| purchaseToken: C |
|
|
138
|
+
* | linkedPurchaseToken: null | | linkedPurchaseToken: A | | linkedPurchaseToken: B |
|
|
139
|
+
* +---------------------------+ +------------------------+ +------------------------+
|
|
140
|
+
*
|
|
141
|
+
* Platform: Google
|
|
142
|
+
* */
|
|
143
|
+
SubscriptionStatus["REPLACED"] = "REPLACED";
|
|
144
|
+
/**
|
|
145
|
+
* Google: Subscription is expired. All items have expiryTime in the past.
|
|
146
|
+
*
|
|
147
|
+
* Platform: Apple, Google
|
|
148
|
+
* */
|
|
149
|
+
SubscriptionStatus["EXPIRED"] = "EXPIRED";
|
|
150
|
+
return SubscriptionStatus;
|
|
151
|
+
}({});
|
|
152
|
+
const AVAILABLE_STATUS = [
|
|
153
|
+
"ACTIVE",
|
|
154
|
+
"TRIALING",
|
|
155
|
+
"IN_GRACE_PERIOD"
|
|
46
156
|
];
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
157
|
+
const ALL_SUBSCRIPTION_STATUS = [
|
|
158
|
+
"TRIALING",
|
|
159
|
+
"ACTIVE",
|
|
160
|
+
"IN_GRACE_PERIOD",
|
|
161
|
+
"INCOMPLETE",
|
|
162
|
+
"INCOMPLETE_EXPIRED",
|
|
163
|
+
"PENDING",
|
|
164
|
+
"PENDING_PURCHASE_CANCELED",
|
|
165
|
+
"PAST_DUE",
|
|
166
|
+
"ON_HOLD",
|
|
167
|
+
"CANCELED",
|
|
168
|
+
"UNPAID",
|
|
169
|
+
"PAUSED",
|
|
170
|
+
"REPLACED",
|
|
171
|
+
"EXPIRED"
|
|
172
|
+
];
|
|
173
|
+
//#endregion
|
|
174
|
+
export { ALL_PLATFORMS, ALL_SUBSCRIPTION_STATUS, AVAILABLE_STATUS, Platform, SubscriptionStatus };
|
|
175
|
+
|
|
54
176
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/subscription/index.ts"],"sourcesContent":["export enum Platform {\n APPLE = 'APPLE',\n GOOGLE = 'GOOGLE',\n STRIPE = 'STRIPE',\n}\n\nexport const ALL_PLATFORMS = [Platform.APPLE, Platform.GOOGLE, Platform.STRIPE] as const;\n\n/**\n * [Stripe Subscription Status](https://stripe.com/docs/api/subscriptions/object#subscription_object-status)\n * [Stripe Subscription Lifecycle](https://docs.stripe.com/billing/subscriptions/overview)\n *\n * provision product for customer when Status = TRIALING, ACTIVE, IN_GRACE_PERIOD\n */\nexport enum SubscriptionStatus {\n /**\n * The subscription is currently in a trial period and it’s safe to provision your product for\n * your customer. The subscription transitions automatically to active when the first payment\n * is made.\n *\n * Google: play(LineItems[0].OfferDetails.OfferId == 'xx')\n *\n * Platform: Apple, Google, Stripe\n * */\n TRIALING = 'TRIALING',\n\n /**\n * The subscription is in good standing and the most recent payment is successful. It’s safe to\n * provision your product for your customer.\n *\n * Platform: Apple, Google, Stripe\n * */\n ACTIVE = 'ACTIVE',\n\n /**\n * Apple: The subscription enters the billing retry period. If the subtype is GRACE_PERIOD,\n * continue to provide service through the grace period. If the subtype is empty, the\n * subscription isn’t in a grace period and you can stop providing the subscription service.\n *\n * Google: Subscription is in grace period. The state is only available when the subscription\n * is an auto renewing plan. In this state, all items are in grace period.\n *\n * Platform: Apple, Google\n * */\n IN_GRACE_PERIOD = 'IN_GRACE_PERIOD',\n\n /**\n * A successful payment needs to be made within 23 hours to activate the subscription. Or the\n * payment requires action, like customer authentication. Subscriptions can also be incomplete\n * if there’s a pending payment and the PaymentIntent status would be processing.\n *\n * Platform: Stripe\n * */\n INCOMPLETE = 'INCOMPLETE',\n\n /**\n * The initial payment on the subscription failed and no successful payment was made within 23\n * hours of creating the subscription. These subscriptions don’t bill customers. This status\n * exists so you can track customers that failed to activate their subscriptions.\n *\n * Platform: Stripe\n * */\n INCOMPLETE_EXPIRED = 'INCOMPLETE_EXPIRED',\n\n /**\n * Subscription was created but awaiting payment during signup. In this state, all items are\n * awaiting payment.\n *\n * Platform: Google\n * */\n PENDING = 'PENDING',\n\n /**\n * Pending transaction for subscription is canceled. If this pending purchase was for an\n * existing subscription, use linkedPurchaseToken to get the current state of that subscription.\n *\n * Platform: Google\n * */\n PENDING_PURCHASE_CANCELED = 'PENDING_PURCHASE_CANCELED',\n\n /**\n * Payment on the latest finalized invoice either failed or wasn’t attempted. The subscription\n * continues to create invoices. Your subscription settings determine the subscription’s next\n * state. If the invoice is still unpaid after all Smart Retries have been attempted, you can\n * configure the subscription to move to canceled, unpaid, or leave it as past_due. To move the\n * subscription to active, pay the most recent invoice before its due date.\n *\n * Platform: Stripe\n * */\n PAST_DUE = 'PAST_DUE',\n\n /**\n * Subscription is on hold (suspended). The state is only available when the subscription is an\n * auto renewing plan. In this state, all items are on hold. Grace period ends or Active period\n * ends but not grace period\n *\n * Platform: Google\n * */\n ON_HOLD = 'ON_HOLD',\n\n /**\n * The subscription has been canceled. During cancellation, automatic collection for all unpaid\n * invoices is disabled (auto_advance=false). This is a terminal state that can’t be updated.\n *\n * Platform: Apple, Google, Stripe\n * */\n CANCELED = 'CANCELED',\n\n /**\n * The latest invoice hasn’t been paid but the subscription remains in place. The latest invoice\n * remains open and invoices continue to be generated but payments aren’t attempted. You should\n * revoke access to your product when the subscription is unpaid since payments were already\n * attempted and retried when it was past_due. To move the subscription to active, pay the most\n * recent invoice before its due date.\n *\n * Platform: Stripe\n * */\n UNPAID = 'UNPAID',\n\n /**\n * Google: Subscription is paused. The state is only available when the subscription is an auto\n * renewing plan. In this state, all items are in paused state.\n *\n * Stripe: The subscription has ended its trial period without a default payment method and the\n * trial_settings.end_behavior.missing_payment_method is set to pause. Invoices will no longer\n * be created for the subscription. After a default payment method has been attached to the\n * customer, you can resume the subscription.\n *\n * Platform: Google, Stripe\n * */\n PAUSED = 'PAUSED',\n\n /**\n * For example, a user buys a subscription and receives a purchase token A. The\n * linkedPurchaseToken field will not be set in the API response because the purchase token\n * belongs to a brand new subscription.\n *\n * If the user upgrades their subscription, a new purchase token B will be generated. Since the\n * upgrade is replacing the subscription from purchase token A, the linkedPurchaseToken field\n * for token B will be set to point to token A. Notice it points backwards in time to the\n * original purchase token.\n *\n * +---------------------------+ +------------------------+ +------------------------+\n * | Step 1 first purchase | | Step 2 upgrades | | Step 3 downgrades |\n * | purchaseToken: A |->| purchaseToken: B |->| purchaseToken: C |\n * | linkedPurchaseToken: null | | linkedPurchaseToken: A | | linkedPurchaseToken: B |\n * +---------------------------+ +------------------------+ +------------------------+\n *\n * Platform: Google\n * */\n REPLACED = 'REPLACED',\n\n /**\n * Google: \tSubscription is expired. All items have expiryTime in the past.\n *\n * Platform: Apple, Google\n * */\n EXPIRED = 'EXPIRED',\n}\n\nexport const AVAILABLE_STATUS = [\n SubscriptionStatus.ACTIVE,\n SubscriptionStatus.TRIALING,\n SubscriptionStatus.IN_GRACE_PERIOD,\n];\n\nexport const ALL_SUBSCRIPTION_STATUS = [\n SubscriptionStatus.TRIALING,\n SubscriptionStatus.ACTIVE,\n SubscriptionStatus.IN_GRACE_PERIOD,\n SubscriptionStatus.INCOMPLETE,\n SubscriptionStatus.INCOMPLETE_EXPIRED,\n SubscriptionStatus.PENDING,\n SubscriptionStatus.PENDING_PURCHASE_CANCELED,\n SubscriptionStatus.PAST_DUE,\n SubscriptionStatus.ON_HOLD,\n SubscriptionStatus.CANCELED,\n SubscriptionStatus.UNPAID,\n SubscriptionStatus.PAUSED,\n SubscriptionStatus.REPLACED,\n SubscriptionStatus.EXPIRED,\n] as const;\n"],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/subscription/index.ts"],"sourcesContent":["export enum Platform {\n APPLE = 'APPLE',\n GOOGLE = 'GOOGLE',\n STRIPE = 'STRIPE',\n}\n\nexport const ALL_PLATFORMS = [Platform.APPLE, Platform.GOOGLE, Platform.STRIPE] as const;\n\n/**\n * [Stripe Subscription Status](https://stripe.com/docs/api/subscriptions/object#subscription_object-status)\n * [Stripe Subscription Lifecycle](https://docs.stripe.com/billing/subscriptions/overview)\n *\n * provision product for customer when Status = TRIALING, ACTIVE, IN_GRACE_PERIOD\n */\nexport enum SubscriptionStatus {\n /**\n * The subscription is currently in a trial period and it’s safe to provision your product for\n * your customer. The subscription transitions automatically to active when the first payment\n * is made.\n *\n * Google: play(LineItems[0].OfferDetails.OfferId == 'xx')\n *\n * Platform: Apple, Google, Stripe\n * */\n TRIALING = 'TRIALING',\n\n /**\n * The subscription is in good standing and the most recent payment is successful. It’s safe to\n * provision your product for your customer.\n *\n * Platform: Apple, Google, Stripe\n * */\n ACTIVE = 'ACTIVE',\n\n /**\n * Apple: The subscription enters the billing retry period. If the subtype is GRACE_PERIOD,\n * continue to provide service through the grace period. If the subtype is empty, the\n * subscription isn’t in a grace period and you can stop providing the subscription service.\n *\n * Google: Subscription is in grace period. The state is only available when the subscription\n * is an auto renewing plan. In this state, all items are in grace period.\n *\n * Platform: Apple, Google\n * */\n IN_GRACE_PERIOD = 'IN_GRACE_PERIOD',\n\n /**\n * A successful payment needs to be made within 23 hours to activate the subscription. Or the\n * payment requires action, like customer authentication. Subscriptions can also be incomplete\n * if there’s a pending payment and the PaymentIntent status would be processing.\n *\n * Platform: Stripe\n * */\n INCOMPLETE = 'INCOMPLETE',\n\n /**\n * The initial payment on the subscription failed and no successful payment was made within 23\n * hours of creating the subscription. These subscriptions don’t bill customers. This status\n * exists so you can track customers that failed to activate their subscriptions.\n *\n * Platform: Stripe\n * */\n INCOMPLETE_EXPIRED = 'INCOMPLETE_EXPIRED',\n\n /**\n * Subscription was created but awaiting payment during signup. In this state, all items are\n * awaiting payment.\n *\n * Platform: Google\n * */\n PENDING = 'PENDING',\n\n /**\n * Pending transaction for subscription is canceled. If this pending purchase was for an\n * existing subscription, use linkedPurchaseToken to get the current state of that subscription.\n *\n * Platform: Google\n * */\n PENDING_PURCHASE_CANCELED = 'PENDING_PURCHASE_CANCELED',\n\n /**\n * Payment on the latest finalized invoice either failed or wasn’t attempted. The subscription\n * continues to create invoices. Your subscription settings determine the subscription’s next\n * state. If the invoice is still unpaid after all Smart Retries have been attempted, you can\n * configure the subscription to move to canceled, unpaid, or leave it as past_due. To move the\n * subscription to active, pay the most recent invoice before its due date.\n *\n * Platform: Stripe\n * */\n PAST_DUE = 'PAST_DUE',\n\n /**\n * Subscription is on hold (suspended). The state is only available when the subscription is an\n * auto renewing plan. In this state, all items are on hold. Grace period ends or Active period\n * ends but not grace period\n *\n * Platform: Google\n * */\n ON_HOLD = 'ON_HOLD',\n\n /**\n * The subscription has been canceled. During cancellation, automatic collection for all unpaid\n * invoices is disabled (auto_advance=false). This is a terminal state that can’t be updated.\n *\n * Platform: Apple, Google, Stripe\n * */\n CANCELED = 'CANCELED',\n\n /**\n * The latest invoice hasn’t been paid but the subscription remains in place. The latest invoice\n * remains open and invoices continue to be generated but payments aren’t attempted. You should\n * revoke access to your product when the subscription is unpaid since payments were already\n * attempted and retried when it was past_due. To move the subscription to active, pay the most\n * recent invoice before its due date.\n *\n * Platform: Stripe\n * */\n UNPAID = 'UNPAID',\n\n /**\n * Google: Subscription is paused. The state is only available when the subscription is an auto\n * renewing plan. In this state, all items are in paused state.\n *\n * Stripe: The subscription has ended its trial period without a default payment method and the\n * trial_settings.end_behavior.missing_payment_method is set to pause. Invoices will no longer\n * be created for the subscription. After a default payment method has been attached to the\n * customer, you can resume the subscription.\n *\n * Platform: Google, Stripe\n * */\n PAUSED = 'PAUSED',\n\n /**\n * For example, a user buys a subscription and receives a purchase token A. The\n * linkedPurchaseToken field will not be set in the API response because the purchase token\n * belongs to a brand new subscription.\n *\n * If the user upgrades their subscription, a new purchase token B will be generated. Since the\n * upgrade is replacing the subscription from purchase token A, the linkedPurchaseToken field\n * for token B will be set to point to token A. Notice it points backwards in time to the\n * original purchase token.\n *\n * +---------------------------+ +------------------------+ +------------------------+\n * | Step 1 first purchase | | Step 2 upgrades | | Step 3 downgrades |\n * | purchaseToken: A |->| purchaseToken: B |->| purchaseToken: C |\n * | linkedPurchaseToken: null | | linkedPurchaseToken: A | | linkedPurchaseToken: B |\n * +---------------------------+ +------------------------+ +------------------------+\n *\n * Platform: Google\n * */\n REPLACED = 'REPLACED',\n\n /**\n * Google: \tSubscription is expired. All items have expiryTime in the past.\n *\n * Platform: Apple, Google\n * */\n EXPIRED = 'EXPIRED',\n}\n\nexport const AVAILABLE_STATUS = [\n SubscriptionStatus.ACTIVE,\n SubscriptionStatus.TRIALING,\n SubscriptionStatus.IN_GRACE_PERIOD,\n];\n\nexport const ALL_SUBSCRIPTION_STATUS = [\n SubscriptionStatus.TRIALING,\n SubscriptionStatus.ACTIVE,\n SubscriptionStatus.IN_GRACE_PERIOD,\n SubscriptionStatus.INCOMPLETE,\n SubscriptionStatus.INCOMPLETE_EXPIRED,\n SubscriptionStatus.PENDING,\n SubscriptionStatus.PENDING_PURCHASE_CANCELED,\n SubscriptionStatus.PAST_DUE,\n SubscriptionStatus.ON_HOLD,\n SubscriptionStatus.CANCELED,\n SubscriptionStatus.UNPAID,\n SubscriptionStatus.PAUSED,\n SubscriptionStatus.REPLACED,\n SubscriptionStatus.EXPIRED,\n] as const;\n"],"mappings":";AAAA,IAAY,WAAL,yBAAA,UAAA;CACL,SAAA,WAAA;CACA,SAAA,YAAA;CACA,SAAA,YAAA;;AACF,EAAA,CAAA,CAAA;AAEA,MAAa,gBAAgB;;;;AAAiD;;;;;;;AAQ9E,IAAY,qBAAL,yBAAA,oBAAA;;;;;;;;;;CAUL,mBAAA,cAAA;;;;;;;CAQA,mBAAA,YAAA;;;;;;;;;;;CAYA,mBAAA,qBAAA;;;;;;;;CASA,mBAAA,gBAAA;;;;;;;;CASA,mBAAA,wBAAA;;;;;;;CAQA,mBAAA,aAAA;;;;;;;CAQA,mBAAA,+BAAA;;;;;;;;;;CAWA,mBAAA,cAAA;;;;;;;;CASA,mBAAA,aAAA;;;;;;;CAQA,mBAAA,cAAA;;;;;;;;;;CAWA,mBAAA,YAAA;;;;;;;;;;;;CAaA,mBAAA,YAAA;;;;;;;;;;;;;;;;;;;CAoBA,mBAAA,cAAA;;;;;;CAOA,mBAAA,aAAA;;AACF,EAAA,CAAA,CAAA;AAEA,MAAa,mBAAmB;;;;AAIhC;AAEA,MAAa,0BAA0B;;;;;;;;;;;;;;;AAevC"}
|
package/dist/types.cjs
CHANGED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
-
for (let key of __getOwnPropNames(from))
|
|
9
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
-
}
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
-
|
|
16
|
-
// src/types.ts
|
|
17
|
-
var types_exports = {};
|
|
18
|
-
module.exports = __toCommonJS(types_exports);
|
|
19
|
-
//# sourceMappingURL=types.cjs.map
|
package/dist/types.d.cts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { StringValue } from
|
|
2
|
-
|
|
1
|
+
import { StringValue } from "ms";
|
|
2
|
+
//#region src/types.d.ts
|
|
3
3
|
type Metadata = {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
credits: number;
|
|
5
|
+
expiresIn: StringValue;
|
|
6
6
|
};
|
|
7
7
|
type IsUnique<T extends readonly unknown[]> = T extends readonly [infer First, ...infer Rest] ? First extends Rest[number] ? false : IsUnique<Rest> : true;
|
|
8
|
-
|
|
9
|
-
export
|
|
8
|
+
//#endregion
|
|
9
|
+
export { IsUnique, Metadata };
|
|
10
|
+
//# sourceMappingURL=types.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.cts","names":[],"sources":["../src/types.ts"],"mappings":";;KAEY;EAAa;EAAiB,WAAW;;KAEzC,SAAS,gCAAgC,0BAA0B,gBAAgB,QAC3F,cAAc,uBAEZ,SAAS"}
|
package/dist/types.d.mts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { StringValue } from "ms";
|
|
2
|
+
//#region src/types.d.ts
|
|
3
|
+
type Metadata = {
|
|
4
|
+
credits: number;
|
|
5
|
+
expiresIn: StringValue;
|
|
6
|
+
};
|
|
7
|
+
type IsUnique<T extends readonly unknown[]> = T extends readonly [infer First, ...infer Rest] ? First extends Rest[number] ? false : IsUnique<Rest> : true;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { IsUnique, Metadata };
|
|
10
|
+
//# sourceMappingURL=types.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.mts","names":[],"sources":["../src/types.ts"],"mappings":";;KAEY;EAAa;EAAiB,WAAW;;KAEzC,SAAS,gCAAgC,0BAA0B,gBAAgB,QAC3F,cAAc,uBAEZ,SAAS"}
|
package/dist/types.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shware/purchase",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -12,48 +12,63 @@
|
|
|
12
12
|
"type": "module",
|
|
13
13
|
"exports": {
|
|
14
14
|
".": {
|
|
15
|
-
"
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
15
|
+
"import": {
|
|
16
|
+
"types": "./dist/index.d.mts",
|
|
17
|
+
"default": "./dist/index.mjs"
|
|
18
|
+
},
|
|
19
|
+
"require": {
|
|
20
|
+
"types": "./dist/index.d.cts",
|
|
21
|
+
"default": "./dist/index.cjs"
|
|
22
|
+
}
|
|
23
23
|
},
|
|
24
24
|
"./app-store": {
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
"import": {
|
|
26
|
+
"types": "./dist/app-store/index.d.mts",
|
|
27
|
+
"default": "./dist/app-store/index.mjs"
|
|
28
|
+
},
|
|
29
|
+
"require": {
|
|
30
|
+
"types": "./dist/app-store/index.d.cts",
|
|
31
|
+
"default": "./dist/app-store/index.cjs"
|
|
32
|
+
}
|
|
28
33
|
},
|
|
29
34
|
"./google-play": {
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
|
|
35
|
+
"import": {
|
|
36
|
+
"types": "./dist/google-play/index.d.mts",
|
|
37
|
+
"default": "./dist/google-play/index.mjs"
|
|
38
|
+
},
|
|
39
|
+
"require": {
|
|
40
|
+
"types": "./dist/google-play/index.d.cts",
|
|
41
|
+
"default": "./dist/google-play/index.cjs"
|
|
42
|
+
}
|
|
33
43
|
},
|
|
34
44
|
"./stripe": {
|
|
35
|
-
"
|
|
36
|
-
|
|
37
|
-
|
|
45
|
+
"import": {
|
|
46
|
+
"types": "./dist/stripe/index.d.mts",
|
|
47
|
+
"default": "./dist/stripe/index.mjs"
|
|
48
|
+
},
|
|
49
|
+
"require": {
|
|
50
|
+
"types": "./dist/stripe/index.d.cts",
|
|
51
|
+
"default": "./dist/stripe/index.cjs"
|
|
52
|
+
}
|
|
38
53
|
}
|
|
39
54
|
},
|
|
40
55
|
"publishConfig": {
|
|
41
56
|
"access": "public"
|
|
42
57
|
},
|
|
43
58
|
"dependencies": {
|
|
59
|
+
"@types/ms": "^2.1.0",
|
|
44
60
|
"ms": "^2.1.3",
|
|
45
61
|
"zod": "^4.4.3",
|
|
46
|
-
"@shware/utils": "^1.
|
|
62
|
+
"@shware/utils": "^1.5.0"
|
|
47
63
|
},
|
|
48
64
|
"devDependencies": {
|
|
49
|
-
"@types/
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"vitest": "^4.1.9",
|
|
65
|
+
"@types/node": "^26.1.1",
|
|
66
|
+
"typescript": "^7.0.2",
|
|
67
|
+
"vitest": "^4.1.10",
|
|
53
68
|
"@repo/typescript-config": "0.0.0"
|
|
54
69
|
},
|
|
55
70
|
"peerDependencies": {
|
|
56
|
-
"stripe": "^22"
|
|
71
|
+
"stripe": "^22.3.1"
|
|
57
72
|
},
|
|
58
73
|
"peerDependenciesMeta": {
|
|
59
74
|
"stripe": {
|
|
@@ -62,7 +77,7 @@
|
|
|
62
77
|
},
|
|
63
78
|
"scripts": {
|
|
64
79
|
"dev": "tsc --watch",
|
|
65
|
-
"build": "
|
|
80
|
+
"build": "tsdown",
|
|
66
81
|
"test": "vitest run",
|
|
67
82
|
"check-types": "tsc --noEmit",
|
|
68
83
|
"lint": "oxlint --type-aware . --fix"
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { Metadata } from '../types.js';
|
|
2
|
-
import 'ms';
|
|
3
|
-
|
|
4
|
-
declare const addMethod: unique symbol;
|
|
5
|
-
declare class Subscription<NS extends Lowercase<string> = Lowercase<string>, PE extends string = string, PL extends PE = never, PI extends string = never, I extends string = never> {
|
|
6
|
-
readonly plan: PL;
|
|
7
|
-
readonly config: AppStoreConfig<NS, PE, PL, PI>;
|
|
8
|
-
readonly products: Map<string, Metadata>;
|
|
9
|
-
defaultProductId: I | null;
|
|
10
|
-
constructor(config: AppStoreConfig<NS, PE, PL, PI>, plan: PL);
|
|
11
|
-
product: <K extends `${NS}.${Lowercase<string>}`>(productId: K extends PI ? never : K, metadata?: Metadata) => Subscription<NS, PE, PL, PI | K, I | K>;
|
|
12
|
-
default: (defaultProductId: I) => AppStoreConfig<NS, PE, PL, PI>;
|
|
13
|
-
}
|
|
14
|
-
type Options = {
|
|
15
|
-
appId: `${number}`;
|
|
16
|
-
bundleId: string;
|
|
17
|
-
};
|
|
18
|
-
declare class AppStoreConfig<NS extends Lowercase<string> = Lowercase<string>, PE extends string = string, PL extends PE = never, PI extends string = never> {
|
|
19
|
-
readonly appId: string;
|
|
20
|
-
readonly bundleId: string;
|
|
21
|
-
private products;
|
|
22
|
-
private consumables;
|
|
23
|
-
private subscriptions;
|
|
24
|
-
private nonConsumables;
|
|
25
|
-
get productIds(): string[];
|
|
26
|
-
[addMethod]: (subscription: Subscription<NS, PE, PL, PI>) => this;
|
|
27
|
-
private constructor();
|
|
28
|
-
static create: <NS_1 extends Lowercase<string>, PE_1 extends string>(options: Options) => AppStoreConfig<NS_1, PE_1, never, never>;
|
|
29
|
-
subscription: <K extends PE>(plan: K extends PL ? never : K) => Subscription<NS, PE, PL | K, PI, never>;
|
|
30
|
-
consumable: <K extends `${NS}.${Lowercase<string>}`>(productId: K extends PI ? never : K, metadata?: Metadata) => AppStoreConfig<NS, PE, PL, PI | K>;
|
|
31
|
-
nonConsumable: <K extends `${NS}.${Lowercase<string>}`>(productId: K extends PI ? never : K) => AppStoreConfig<NS, PE, PL, PI | K>;
|
|
32
|
-
getPlan: (productId: string) => PE;
|
|
33
|
-
getMode: (productId: string) => "payment" | "subscription";
|
|
34
|
-
getCreditAmount: (productId: string) => number;
|
|
35
|
-
private getCreditExpiresIn;
|
|
36
|
-
getCreditExpiresAt: (productId: string) => string;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export { AppStoreConfig };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/app-store/index.ts"],"sourcesContent":["export { AppStoreConfig } from './config';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA+B;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/app-store/index.ts"],"sourcesContent":["export { AppStoreConfig } from './config';\n"],"mappings":";AAAA,SAAS,sBAAsB;","names":[]}
|