@haatlabs-core/billing 0.0.0-stage → 0.10.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/LICENSE +201 -0
- package/README.md +19 -2
- package/dist/cjs/codes.d.ts +11 -0
- package/dist/cjs/codes.js +38 -0
- package/dist/cjs/contracts.d.ts +208 -0
- package/dist/cjs/contracts.js +187 -0
- package/dist/cjs/gateway.d.ts +78 -0
- package/dist/cjs/gateway.js +111 -0
- package/dist/cjs/index.d.ts +11 -0
- package/dist/cjs/index.js +49 -0
- package/dist/cjs/package.json +8 -0
- package/dist/cjs/payment-provider.d.ts +41 -0
- package/dist/cjs/payment-provider.js +46 -0
- package/dist/cjs/razorpay.d.ts +22 -0
- package/dist/cjs/razorpay.js +123 -0
- package/dist/cjs/shopify-plan.d.ts +105 -0
- package/dist/cjs/shopify-plan.js +110 -0
- package/dist/cjs/store-billing-sync.d.ts +66 -0
- package/dist/cjs/store-billing-sync.js +101 -0
- package/dist/cjs/stripe.d.ts +22 -0
- package/dist/cjs/stripe.js +131 -0
- package/dist/codes.d.ts +11 -0
- package/dist/codes.js +10 -0
- package/dist/codes.js.map +1 -0
- package/dist/contracts.d.ts +208 -0
- package/dist/contracts.js +171 -0
- package/dist/contracts.js.map +1 -0
- package/dist/gateway.d.ts +78 -0
- package/dist/gateway.js +79 -0
- package/dist/gateway.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/payment-provider.d.ts +41 -0
- package/dist/payment-provider.js +26 -0
- package/dist/payment-provider.js.map +1 -0
- package/dist/razorpay.d.ts +22 -0
- package/dist/razorpay.js +106 -0
- package/dist/razorpay.js.map +1 -0
- package/dist/shopify-plan.d.ts +105 -0
- package/dist/shopify-plan.js +109 -0
- package/dist/shopify-plan.js.map +1 -0
- package/dist/store-billing-sync.d.ts +66 -0
- package/dist/store-billing-sync.js +90 -0
- package/dist/store-billing-sync.js.map +1 -0
- package/dist/stripe.d.ts +22 -0
- package/dist/stripe.js +115 -0
- package/dist/stripe.js.map +1 -0
- package/package.json +68 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "{}"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Haatlabs
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @haatlabs-core/billing
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Payment gateways (Stripe, Razorpay, a manual provider) and the plan Shopify bills a store
|
|
4
|
+
for. It throws `PAYMENT_PROVIDER_ERROR`; a project spreads `BILLING_ERRORS` into
|
|
5
|
+
`defineErrors`. `shopifySubscriptionName` and `reconcileShopifyPlan` take the app's name;
|
|
6
|
+
the `cancel` port is optional, and without it a refused plan cancels nothing.
|
|
7
|
+
|
|
8
|
+
**`StoreBillingSync`** (since 0.5.0) keeps an organization's plan what Shopify charges one of
|
|
9
|
+
its stores for; the worker runs it when Shopify says a subscription changed. It is given the
|
|
10
|
+
app's repositories and the Shopify calls from `@haatlabs-core/shopify`.
|
|
11
|
+
|
|
12
|
+
**`@haatlabs-core/billing/contracts`**: the schemas an app's API and pages share: checkout,
|
|
13
|
+
Shopify checkout and plan, `PLAN_LIMIT_ERRORS`, and `billingSchemas({ metrics, caps,
|
|
14
|
+
planFeatures })` for the usage, plan list and plan seed file in the app's own lists.
|
|
15
|
+
|
|
16
|
+
## Install
|
|
17
|
+
|
|
18
|
+
pnpm add @haatlabs-core/billing
|
|
19
|
+
|
|
20
|
+
It leaves one package to your app, so the app holds one copy: `zod`.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** The code this package throws beyond the core ones: a project spreads it into defineErrors. */
|
|
2
|
+
export declare const BILLING_ERRORS: {
|
|
3
|
+
readonly PAYMENT_PROVIDER_ERROR: {
|
|
4
|
+
readonly httpStatus: 503;
|
|
5
|
+
readonly transient: true;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
export declare const BillingErrorCode: {
|
|
9
|
+
readonly PAYMENT_PROVIDER_ERROR: "PAYMENT_PROVIDER_ERROR";
|
|
10
|
+
};
|
|
11
|
+
export declare const createBillingError: (code: "PAYMENT_PROVIDER_ERROR", message: string, options?: import("@haatlabs-core/errors").AppErrorOptions) => import("@haatlabs-core/errors").AppError<"PAYMENT_PROVIDER_ERROR">;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var codes_exports = {};
|
|
19
|
+
__export(codes_exports, {
|
|
20
|
+
BILLING_ERRORS: () => BILLING_ERRORS,
|
|
21
|
+
BillingErrorCode: () => BillingErrorCode,
|
|
22
|
+
createBillingError: () => createBillingError
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(codes_exports);
|
|
25
|
+
var import_errors = require("@haatlabs-core/errors");
|
|
26
|
+
const BILLING_ERRORS = {
|
|
27
|
+
// Something this API depends on failed: 503, never 502 or 504 (see @haatlabs-core/errors).
|
|
28
|
+
PAYMENT_PROVIDER_ERROR: { httpStatus: 503, transient: true }
|
|
29
|
+
};
|
|
30
|
+
const billing = (0, import_errors.domainErrors)(BILLING_ERRORS);
|
|
31
|
+
const BillingErrorCode = billing.codes;
|
|
32
|
+
const createBillingError = billing.create;
|
|
33
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
34
|
+
0 && (module.exports = {
|
|
35
|
+
BILLING_ERRORS,
|
|
36
|
+
BillingErrorCode,
|
|
37
|
+
createBillingError
|
|
38
|
+
});
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const SubscriptionStatus: {
|
|
3
|
+
readonly ACTIVE: "ACTIVE";
|
|
4
|
+
readonly CANCELLED: "CANCELLED";
|
|
5
|
+
};
|
|
6
|
+
export type SubscriptionStatus = (typeof SubscriptionStatus)[keyof typeof SubscriptionStatus];
|
|
7
|
+
/** The `feature_key` under which a plan says its work goes first: 1 for yes. */
|
|
8
|
+
export declare const PLAN_PRIORITY_KEY = "PRIORITY";
|
|
9
|
+
/** The `feature_key` of a plan's switch for a feature it may leave out: 1 on, 0 off. */
|
|
10
|
+
export declare const planFeatureKey: (feature: string) => string;
|
|
11
|
+
/** Shown to a merchant whenever a plan limit stops something. */
|
|
12
|
+
export declare const PLAN_LIMIT_MESSAGE = "Your plan's limit has been reached.";
|
|
13
|
+
/** The code a plan limit refuses with: an app with plans spreads it into defineErrors. */
|
|
14
|
+
export declare const PLAN_LIMIT_ERRORS: {
|
|
15
|
+
readonly PLAN_LIMIT_REACHED: {
|
|
16
|
+
readonly httpStatus: 402;
|
|
17
|
+
readonly transient: false;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export declare const PaymentProviderName: {
|
|
21
|
+
readonly stripe: "stripe";
|
|
22
|
+
readonly razorpay: "razorpay";
|
|
23
|
+
readonly shopify: "shopify";
|
|
24
|
+
};
|
|
25
|
+
export type PaymentProviderName = (typeof PaymentProviderName)[keyof typeof PaymentProviderName];
|
|
26
|
+
/** The gateways with a hosted checkout page and an account-wide key. Shopify billing is not one. */
|
|
27
|
+
export declare const isGateway: (value: string) => value is "stripe" | "razorpay";
|
|
28
|
+
export declare const isProvider: (value: string) => value is PaymentProviderName;
|
|
29
|
+
export declare const CheckoutRequestSchema: z.ZodObject<{
|
|
30
|
+
planCode: z.ZodString;
|
|
31
|
+
provider: z.ZodEnum<{
|
|
32
|
+
readonly stripe: "stripe";
|
|
33
|
+
readonly razorpay: "razorpay";
|
|
34
|
+
readonly shopify: "shopify";
|
|
35
|
+
}>;
|
|
36
|
+
currency: z.ZodOptional<z.ZodString>;
|
|
37
|
+
}, z.core.$strip>;
|
|
38
|
+
export type CheckoutRequest = z.infer<typeof CheckoutRequestSchema>;
|
|
39
|
+
/** The gateway's own hosted page, where the customer pays. */
|
|
40
|
+
export declare const CheckoutResponseSchema: z.ZodObject<{
|
|
41
|
+
url: z.ZodURL;
|
|
42
|
+
}, z.core.$strip>;
|
|
43
|
+
export type CheckoutResponse = z.infer<typeof CheckoutResponseSchema>;
|
|
44
|
+
export declare const CancelRenewalResponseSchema: z.ZodObject<{
|
|
45
|
+
cancelled: z.ZodLiteral<true>;
|
|
46
|
+
}, z.core.$strip>;
|
|
47
|
+
export type CancelRenewalResponse = z.infer<typeof CancelRenewalResponseSchema>;
|
|
48
|
+
/** A plan bought through Shopify's billing, from inside Shopify admin: Shopify sets the price. */
|
|
49
|
+
export declare const ShopifyCheckoutRequestSchema: z.ZodObject<{
|
|
50
|
+
planCode: z.ZodString;
|
|
51
|
+
}, z.core.$strip>;
|
|
52
|
+
export type ShopifyCheckoutRequest = z.infer<typeof ShopifyCheckoutRequestSchema>;
|
|
53
|
+
/** The paid plan Shopify is charging the store for, or null when it is charging for none. */
|
|
54
|
+
export declare const ShopifyPlanResponseSchema: z.ZodObject<{
|
|
55
|
+
plan: z.ZodNullable<z.ZodObject<{
|
|
56
|
+
code: z.ZodString;
|
|
57
|
+
name: z.ZodString;
|
|
58
|
+
}, z.core.$strip>>;
|
|
59
|
+
}, z.core.$strip>;
|
|
60
|
+
export type ShopifyPlanResponse = z.infer<typeof ShopifyPlanResponseSchema>;
|
|
61
|
+
/**
|
|
62
|
+
* A plan's monthly price at one gateway. `priceRef` is the gateway's own ID for it (a Stripe
|
|
63
|
+
* price ID, a Razorpay plan ID), an identifier and not a secret. `amountMinor` is in the
|
|
64
|
+
* currency's smallest unit and is what the pages show; the gateway charges what its own
|
|
65
|
+
* price says, so keep the two the same.
|
|
66
|
+
*/
|
|
67
|
+
export declare const PlanPriceSeedSchema: z.ZodObject<{
|
|
68
|
+
provider: z.ZodEnum<{
|
|
69
|
+
readonly stripe: "stripe";
|
|
70
|
+
readonly razorpay: "razorpay";
|
|
71
|
+
readonly shopify: "shopify";
|
|
72
|
+
}>;
|
|
73
|
+
priceRef: z.ZodString;
|
|
74
|
+
currency: z.ZodString;
|
|
75
|
+
amountMinor: z.ZodNumber;
|
|
76
|
+
}, z.core.$strip>;
|
|
77
|
+
/** The plans an administrator can put an organization on. */
|
|
78
|
+
export declare const AdminPlanListSchema: z.ZodObject<{
|
|
79
|
+
plans: z.ZodArray<z.ZodObject<{
|
|
80
|
+
code: z.ZodString;
|
|
81
|
+
name: z.ZodString;
|
|
82
|
+
isDefault: z.ZodBoolean;
|
|
83
|
+
}, z.core.$strip>>;
|
|
84
|
+
}, z.core.$strip>;
|
|
85
|
+
export type AdminPlanList = z.infer<typeof AdminPlanListSchema>;
|
|
86
|
+
/**
|
|
87
|
+
* Puts an organization on a plan without taking payment, until the end of `until` (UTC):
|
|
88
|
+
* one month from now when no day is given.
|
|
89
|
+
*/
|
|
90
|
+
export declare const AdminAssignPlanRequestSchema: z.ZodObject<{
|
|
91
|
+
planCode: z.ZodString;
|
|
92
|
+
until: z.ZodOptional<z.ZodString>;
|
|
93
|
+
}, z.core.$strict>;
|
|
94
|
+
export type AdminAssignPlanRequest = z.infer<typeof AdminAssignPlanRequestSchema>;
|
|
95
|
+
/** A number of stores for one organization, over its plan's. Null: its plan decides again. */
|
|
96
|
+
export declare const AdminSetStoreLimitRequestSchema: z.ZodObject<{
|
|
97
|
+
limit: z.ZodNullable<z.ZodNumber>;
|
|
98
|
+
}, z.core.$strict>;
|
|
99
|
+
export type AdminSetStoreLimitRequest = z.infer<typeof AdminSetStoreLimitRequestSchema>;
|
|
100
|
+
/**
|
|
101
|
+
* Turns one of the app's features off or on for an organization: any feature an
|
|
102
|
+
* administrator may switch, of which those a plan may leave out are some.
|
|
103
|
+
*/
|
|
104
|
+
export declare const featureSwitchRequestSchema: <F extends string>(features: readonly F[]) => z.ZodObject<{
|
|
105
|
+
feature: z.ZodEnum<{ [k_1 in F]: k_1; } extends infer T ? { [k in keyof T]: T[k]; } : never>;
|
|
106
|
+
enabled: z.ZodNullable<z.ZodBoolean>;
|
|
107
|
+
}, z.core.$strict>;
|
|
108
|
+
/** What an app sells by: what it counts, what it caps, and what a plan may leave out. */
|
|
109
|
+
export interface BillingCatalog<M extends string = string, C extends string = string, F extends string = string> {
|
|
110
|
+
metrics: readonly M[];
|
|
111
|
+
caps: readonly C[];
|
|
112
|
+
planFeatures: readonly F[];
|
|
113
|
+
}
|
|
114
|
+
/** The schemas whose shape is the app's lists. */
|
|
115
|
+
export declare function billingSchemas<M extends string, C extends string, F extends string>(catalog: BillingCatalog<M, C, F>): {
|
|
116
|
+
usageResponse: z.ZodObject<{
|
|
117
|
+
plan: z.ZodObject<{
|
|
118
|
+
code: z.ZodString;
|
|
119
|
+
name: z.ZodString;
|
|
120
|
+
}, z.core.$strip>;
|
|
121
|
+
period: z.ZodObject<{
|
|
122
|
+
start: z.ZodString;
|
|
123
|
+
end: z.ZodString;
|
|
124
|
+
}, z.core.$strip>;
|
|
125
|
+
metrics: z.ZodArray<z.ZodObject<{
|
|
126
|
+
metric: z.ZodEnum<{ [k_1 in M]: k_1; } extends infer T ? { [k in keyof T]: T[k]; } : never>;
|
|
127
|
+
used: z.ZodNumber;
|
|
128
|
+
limit: z.ZodNullable<z.ZodNumber>;
|
|
129
|
+
}, z.core.$strip>>;
|
|
130
|
+
managedBy: z.ZodNullable<z.ZodEnum<{
|
|
131
|
+
readonly stripe: "stripe";
|
|
132
|
+
readonly razorpay: "razorpay";
|
|
133
|
+
readonly shopify: "shopify";
|
|
134
|
+
}>>;
|
|
135
|
+
}, z.core.$strip>;
|
|
136
|
+
planListResponse: z.ZodObject<{
|
|
137
|
+
plans: z.ZodArray<z.ZodObject<{
|
|
138
|
+
code: z.ZodString;
|
|
139
|
+
name: z.ZodString;
|
|
140
|
+
isDefault: z.ZodBoolean;
|
|
141
|
+
limits: z.ZodArray<z.ZodObject<{
|
|
142
|
+
metric: z.ZodEnum<{ [k_1 in M]: k_1; } extends infer T_1 ? { [k in keyof T_1]: T_1[k]; } : never>;
|
|
143
|
+
limit: z.ZodNullable<z.ZodNumber>;
|
|
144
|
+
}, z.core.$strip>>;
|
|
145
|
+
includes: z.ZodOptional<z.ZodObject<Record<F, z.ZodBoolean> & {
|
|
146
|
+
PRIORITY: z.ZodDefault<z.ZodBoolean>;
|
|
147
|
+
} extends infer T_2 ? { -readonly [P in keyof T_2]: T_2[P]; } : never, z.core.$strip>>;
|
|
148
|
+
caps: z.ZodOptional<z.ZodObject<Record<C, z.ZodOptional<z.ZodNullable<z.ZodNumber>>> extends infer T_3 ? { -readonly [P_1 in keyof T_3]: T_3[P_1]; } : never, z.core.$strip>>;
|
|
149
|
+
prices: z.ZodArray<z.ZodObject<{
|
|
150
|
+
provider: z.ZodEnum<{
|
|
151
|
+
readonly stripe: "stripe";
|
|
152
|
+
readonly razorpay: "razorpay";
|
|
153
|
+
readonly shopify: "shopify";
|
|
154
|
+
}>;
|
|
155
|
+
currency: z.ZodString;
|
|
156
|
+
amountMinor: z.ZodNumber;
|
|
157
|
+
}, z.core.$strip>>;
|
|
158
|
+
}, z.core.$strip>>;
|
|
159
|
+
providers: z.ZodArray<z.ZodEnum<{
|
|
160
|
+
readonly stripe: "stripe";
|
|
161
|
+
readonly razorpay: "razorpay";
|
|
162
|
+
readonly shopify: "shopify";
|
|
163
|
+
}>>;
|
|
164
|
+
}, z.core.$strip>;
|
|
165
|
+
planSeed: z.ZodObject<{
|
|
166
|
+
code: z.ZodString;
|
|
167
|
+
name: z.ZodString;
|
|
168
|
+
isDefault: z.ZodBoolean;
|
|
169
|
+
position: z.ZodNumber;
|
|
170
|
+
limits: z.ZodObject<Record<M, z.ZodNullable<z.ZodNumber>> extends infer T_4 ? { -readonly [P_2 in keyof T_4]: T_4[P_2]; } : never, z.core.$strict>;
|
|
171
|
+
caps: z.ZodDefault<z.ZodObject<Record<C, z.ZodDefault<z.ZodNullable<z.ZodNumber>>> extends infer T_5 ? { -readonly [P_3 in keyof T_5]: T_5[P_3]; } : never, z.core.$strict>>;
|
|
172
|
+
features: z.ZodDefault<z.ZodObject<Record<F, z.ZodDefault<z.ZodBoolean>> extends infer T_6 ? { -readonly [P_4 in keyof T_6]: T_6[P_4]; } : never, z.core.$strict>>;
|
|
173
|
+
priority: z.ZodDefault<z.ZodBoolean>;
|
|
174
|
+
prices: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
175
|
+
provider: z.ZodEnum<{
|
|
176
|
+
readonly stripe: "stripe";
|
|
177
|
+
readonly razorpay: "razorpay";
|
|
178
|
+
readonly shopify: "shopify";
|
|
179
|
+
}>;
|
|
180
|
+
priceRef: z.ZodString;
|
|
181
|
+
currency: z.ZodString;
|
|
182
|
+
amountMinor: z.ZodNumber;
|
|
183
|
+
}, z.core.$strip>>>;
|
|
184
|
+
}, z.core.$strip>;
|
|
185
|
+
planSeedFile: z.ZodObject<{
|
|
186
|
+
plans: z.ZodArray<z.ZodObject<{
|
|
187
|
+
code: z.ZodString;
|
|
188
|
+
name: z.ZodString;
|
|
189
|
+
isDefault: z.ZodBoolean;
|
|
190
|
+
position: z.ZodNumber;
|
|
191
|
+
limits: z.ZodObject<Record<M, z.ZodNullable<z.ZodNumber>> extends infer T_7 ? { -readonly [P_2 in keyof T_7]: T_7[P_2]; } : never, z.core.$strict>;
|
|
192
|
+
caps: z.ZodDefault<z.ZodObject<Record<C, z.ZodDefault<z.ZodNullable<z.ZodNumber>>> extends infer T_8 ? { -readonly [P_3 in keyof T_8]: T_8[P_3]; } : never, z.core.$strict>>;
|
|
193
|
+
features: z.ZodDefault<z.ZodObject<Record<F, z.ZodDefault<z.ZodBoolean>> extends infer T_9 ? { -readonly [P_4 in keyof T_9]: T_9[P_4]; } : never, z.core.$strict>>;
|
|
194
|
+
priority: z.ZodDefault<z.ZodBoolean>;
|
|
195
|
+
prices: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
196
|
+
provider: z.ZodEnum<{
|
|
197
|
+
readonly stripe: "stripe";
|
|
198
|
+
readonly razorpay: "razorpay";
|
|
199
|
+
readonly shopify: "shopify";
|
|
200
|
+
}>;
|
|
201
|
+
priceRef: z.ZodString;
|
|
202
|
+
currency: z.ZodString;
|
|
203
|
+
amountMinor: z.ZodNumber;
|
|
204
|
+
}, z.core.$strip>>>;
|
|
205
|
+
}, z.core.$strip>>;
|
|
206
|
+
}, z.core.$strict>;
|
|
207
|
+
};
|
|
208
|
+
export type BillingSchemas<M extends string, C extends string, F extends string> = ReturnType<typeof billingSchemas<M, C, F>>;
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var contracts_exports = {};
|
|
19
|
+
__export(contracts_exports, {
|
|
20
|
+
AdminAssignPlanRequestSchema: () => AdminAssignPlanRequestSchema,
|
|
21
|
+
AdminPlanListSchema: () => AdminPlanListSchema,
|
|
22
|
+
AdminSetStoreLimitRequestSchema: () => AdminSetStoreLimitRequestSchema,
|
|
23
|
+
CancelRenewalResponseSchema: () => CancelRenewalResponseSchema,
|
|
24
|
+
CheckoutRequestSchema: () => CheckoutRequestSchema,
|
|
25
|
+
CheckoutResponseSchema: () => CheckoutResponseSchema,
|
|
26
|
+
PLAN_LIMIT_ERRORS: () => PLAN_LIMIT_ERRORS,
|
|
27
|
+
PLAN_LIMIT_MESSAGE: () => PLAN_LIMIT_MESSAGE,
|
|
28
|
+
PLAN_PRIORITY_KEY: () => PLAN_PRIORITY_KEY,
|
|
29
|
+
PaymentProviderName: () => PaymentProviderName,
|
|
30
|
+
PlanPriceSeedSchema: () => PlanPriceSeedSchema,
|
|
31
|
+
ShopifyCheckoutRequestSchema: () => ShopifyCheckoutRequestSchema,
|
|
32
|
+
ShopifyPlanResponseSchema: () => ShopifyPlanResponseSchema,
|
|
33
|
+
SubscriptionStatus: () => SubscriptionStatus,
|
|
34
|
+
billingSchemas: () => billingSchemas,
|
|
35
|
+
featureSwitchRequestSchema: () => featureSwitchRequestSchema,
|
|
36
|
+
isGateway: () => isGateway,
|
|
37
|
+
isProvider: () => isProvider,
|
|
38
|
+
planFeatureKey: () => planFeatureKey
|
|
39
|
+
});
|
|
40
|
+
module.exports = __toCommonJS(contracts_exports);
|
|
41
|
+
var import_zod = require("zod");
|
|
42
|
+
const SubscriptionStatus = { ACTIVE: "ACTIVE", CANCELLED: "CANCELLED" };
|
|
43
|
+
const PLAN_PRIORITY_KEY = "PRIORITY";
|
|
44
|
+
const planFeatureKey = (feature) => `FEATURE_${feature}`;
|
|
45
|
+
const PLAN_LIMIT_MESSAGE = "Your plan's limit has been reached.";
|
|
46
|
+
const PLAN_LIMIT_ERRORS = {
|
|
47
|
+
PLAN_LIMIT_REACHED: { httpStatus: 402, transient: false }
|
|
48
|
+
};
|
|
49
|
+
const PaymentProviderName = {
|
|
50
|
+
stripe: "stripe",
|
|
51
|
+
razorpay: "razorpay",
|
|
52
|
+
shopify: "shopify"
|
|
53
|
+
};
|
|
54
|
+
const isGateway = (value) => value === "stripe" || value === "razorpay";
|
|
55
|
+
const isProvider = (value) => Object.hasOwn(PaymentProviderName, value);
|
|
56
|
+
const MAX_PLAN_CODE_LENGTH = 40;
|
|
57
|
+
const MAX_PLAN_NAME_LENGTH = 80;
|
|
58
|
+
const currency = import_zod.z.string().regex(/^[A-Z]{3}$/);
|
|
59
|
+
const CheckoutRequestSchema = import_zod.z.object({
|
|
60
|
+
planCode: import_zod.z.string().min(1).max(MAX_PLAN_CODE_LENGTH),
|
|
61
|
+
provider: import_zod.z.enum(PaymentProviderName),
|
|
62
|
+
/** Which of the plan's prices at that gateway; needed when it has more than one. */
|
|
63
|
+
currency: currency.optional()
|
|
64
|
+
});
|
|
65
|
+
const CheckoutResponseSchema = import_zod.z.object({ url: import_zod.z.url() });
|
|
66
|
+
const CancelRenewalResponseSchema = import_zod.z.object({ cancelled: import_zod.z.literal(true) });
|
|
67
|
+
const ShopifyCheckoutRequestSchema = import_zod.z.object({
|
|
68
|
+
planCode: import_zod.z.string().min(1).max(MAX_PLAN_CODE_LENGTH)
|
|
69
|
+
});
|
|
70
|
+
const ShopifyPlanResponseSchema = import_zod.z.object({
|
|
71
|
+
plan: import_zod.z.object({ code: import_zod.z.string(), name: import_zod.z.string() }).nullable()
|
|
72
|
+
});
|
|
73
|
+
const PlanPriceSeedSchema = import_zod.z.object({
|
|
74
|
+
provider: import_zod.z.enum(PaymentProviderName),
|
|
75
|
+
priceRef: import_zod.z.string().regex(/^[A-Za-z0-9_]{1,128}$/).refine((value) => !/replace|placeholder|example|your|xxx/i.test(value), {
|
|
76
|
+
message: "Put the gateway's real ID here, not a placeholder"
|
|
77
|
+
}),
|
|
78
|
+
currency,
|
|
79
|
+
amountMinor: import_zod.z.number().int().positive()
|
|
80
|
+
});
|
|
81
|
+
const calendarDay = import_zod.z.string().regex(/^\d{4}-\d{2}-\d{2}$/);
|
|
82
|
+
const AdminPlanListSchema = import_zod.z.object({
|
|
83
|
+
plans: import_zod.z.array(import_zod.z.object({ code: import_zod.z.string(), name: import_zod.z.string(), isDefault: import_zod.z.boolean() }))
|
|
84
|
+
});
|
|
85
|
+
const AdminAssignPlanRequestSchema = import_zod.z.strictObject({
|
|
86
|
+
planCode: import_zod.z.string().min(1).max(100),
|
|
87
|
+
until: calendarDay.optional()
|
|
88
|
+
});
|
|
89
|
+
const MAX_STORE_LIMIT = 1e4;
|
|
90
|
+
const AdminSetStoreLimitRequestSchema = import_zod.z.strictObject({
|
|
91
|
+
limit: import_zod.z.number().int().min(1).max(MAX_STORE_LIMIT).nullable()
|
|
92
|
+
});
|
|
93
|
+
const featureSwitchRequestSchema = (features) => import_zod.z.strictObject({
|
|
94
|
+
feature: import_zod.z.enum(features),
|
|
95
|
+
/** Null: no longer decided here; the organization's plan decides again. */
|
|
96
|
+
enabled: import_zod.z.boolean().nullable()
|
|
97
|
+
});
|
|
98
|
+
const keyed = (keys, schema) => Object.fromEntries(keys.map((key) => [key, schema]));
|
|
99
|
+
function billingSchemas(catalog) {
|
|
100
|
+
const metric = import_zod.z.enum(catalog.metrics);
|
|
101
|
+
const limit = import_zod.z.number().int().nonnegative().nullable();
|
|
102
|
+
const day = import_zod.z.string().regex(/^\d{4}-\d{2}-\d{2}$/);
|
|
103
|
+
const cap = import_zod.z.number().int().positive().nullable().default(null);
|
|
104
|
+
const usageResponse = import_zod.z.object({
|
|
105
|
+
plan: import_zod.z.object({ code: import_zod.z.string(), name: import_zod.z.string() }),
|
|
106
|
+
/** The billing period: `start` is its first day, `end` the first day after it. */
|
|
107
|
+
period: import_zod.z.object({ start: day, end: day }),
|
|
108
|
+
metrics: import_zod.z.array(import_zod.z.object({ metric, used: import_zod.z.number().int().nonnegative(), limit })),
|
|
109
|
+
/** The gateway charging for the plan, or null when nothing is being charged. */
|
|
110
|
+
managedBy: import_zod.z.enum(PaymentProviderName).nullable()
|
|
111
|
+
});
|
|
112
|
+
const planListResponse = import_zod.z.object({
|
|
113
|
+
plans: import_zod.z.array(import_zod.z.object({
|
|
114
|
+
code: import_zod.z.string(),
|
|
115
|
+
name: import_zod.z.string(),
|
|
116
|
+
isDefault: import_zod.z.boolean(),
|
|
117
|
+
limits: import_zod.z.array(import_zod.z.object({ metric, limit })),
|
|
118
|
+
/** What the plan includes of what a plan may leave out, and whether its work goes first. */
|
|
119
|
+
includes: import_zod.z.object({
|
|
120
|
+
...keyed(catalog.planFeatures, import_zod.z.boolean()),
|
|
121
|
+
PRIORITY: import_zod.z.boolean().default(false)
|
|
122
|
+
}).optional(),
|
|
123
|
+
/** What the plan allows at most; null: no cap of its own. */
|
|
124
|
+
caps: import_zod.z.object(keyed(catalog.caps, import_zod.z.number().int().nullable().optional())).optional(),
|
|
125
|
+
/** Per month, in the currency's smallest unit, through each gateway offered here. */
|
|
126
|
+
prices: import_zod.z.array(import_zod.z.object({
|
|
127
|
+
provider: import_zod.z.enum(PaymentProviderName),
|
|
128
|
+
currency: import_zod.z.string(),
|
|
129
|
+
amountMinor: import_zod.z.number().int().positive()
|
|
130
|
+
}))
|
|
131
|
+
})),
|
|
132
|
+
/** The gateways a plan can be bought through here. Empty: nothing is for sale. */
|
|
133
|
+
providers: import_zod.z.array(import_zod.z.enum(PaymentProviderName))
|
|
134
|
+
});
|
|
135
|
+
const noCaps = Object.fromEntries(catalog.caps.map((key) => [key, null]));
|
|
136
|
+
const allFeatures = Object.fromEntries(catalog.planFeatures.map((key) => [key, true]));
|
|
137
|
+
const planSeed = import_zod.z.object({
|
|
138
|
+
code: import_zod.z.string().regex(/^[a-z][a-z0-9-]{0,39}$/),
|
|
139
|
+
name: import_zod.z.string().min(1).max(MAX_PLAN_NAME_LENGTH),
|
|
140
|
+
/** The plan of an organization that has no current subscription. */
|
|
141
|
+
isDefault: import_zod.z.boolean(),
|
|
142
|
+
/** Order in which plans are listed. */
|
|
143
|
+
position: import_zod.z.number().int().nonnegative(),
|
|
144
|
+
limits: import_zod.z.strictObject(keyed(catalog.metrics, limit)),
|
|
145
|
+
/** What the plan allows at most; null, or left out, means no cap of its own. */
|
|
146
|
+
caps: import_zod.z.strictObject(keyed(catalog.caps, cap)).default(noCaps),
|
|
147
|
+
/** What the plan includes of the features a plan may leave out. Left out: all of them. */
|
|
148
|
+
features: import_zod.z.strictObject(keyed(catalog.planFeatures, import_zod.z.boolean().default(true))).default(allFeatures),
|
|
149
|
+
/** Whether the plan's work goes ahead of ordinary work. Left out: it does not. */
|
|
150
|
+
priority: import_zod.z.boolean().default(false),
|
|
151
|
+
/** What the plan costs through each gateway it is sold through. None: not for sale. */
|
|
152
|
+
prices: import_zod.z.array(PlanPriceSeedSchema).default([]).refine((prices) => new Set(prices.map((price) => `${price.provider}:${price.currency}`)).size === prices.length, { message: "A plan can have one price for each gateway and currency" })
|
|
153
|
+
});
|
|
154
|
+
const planSeedFile = import_zod.z.strictObject({ plans: import_zod.z.array(planSeed).min(1) }).refine((file) => file.plans.filter((plan) => plan.isDefault).length === 1, {
|
|
155
|
+
message: "Exactly one plan must be the default",
|
|
156
|
+
path: ["plans"]
|
|
157
|
+
}).refine((file) => new Set(file.plans.map((plan) => plan.code)).size === file.plans.length, {
|
|
158
|
+
message: "Plan codes must not repeat",
|
|
159
|
+
path: ["plans"]
|
|
160
|
+
}).refine((file) => {
|
|
161
|
+
const refs = file.plans.flatMap((plan) => plan.prices.map((price) => `${price.provider}:${price.priceRef}`));
|
|
162
|
+
return new Set(refs).size === refs.length;
|
|
163
|
+
}, { message: "A gateway price can belong to one plan only", path: ["plans"] });
|
|
164
|
+
return { usageResponse, planListResponse, planSeed, planSeedFile };
|
|
165
|
+
}
|
|
166
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
167
|
+
0 && (module.exports = {
|
|
168
|
+
AdminAssignPlanRequestSchema,
|
|
169
|
+
AdminPlanListSchema,
|
|
170
|
+
AdminSetStoreLimitRequestSchema,
|
|
171
|
+
CancelRenewalResponseSchema,
|
|
172
|
+
CheckoutRequestSchema,
|
|
173
|
+
CheckoutResponseSchema,
|
|
174
|
+
PLAN_LIMIT_ERRORS,
|
|
175
|
+
PLAN_LIMIT_MESSAGE,
|
|
176
|
+
PLAN_PRIORITY_KEY,
|
|
177
|
+
PaymentProviderName,
|
|
178
|
+
PlanPriceSeedSchema,
|
|
179
|
+
ShopifyCheckoutRequestSchema,
|
|
180
|
+
ShopifyPlanResponseSchema,
|
|
181
|
+
SubscriptionStatus,
|
|
182
|
+
billingSchemas,
|
|
183
|
+
featureSwitchRequestSchema,
|
|
184
|
+
isGateway,
|
|
185
|
+
isProvider,
|
|
186
|
+
planFeatureKey
|
|
187
|
+
});
|