commerce-kit 0.0.0 → 0.0.6
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.md +21 -0
- package/README.md +66 -0
- package/dist/currencies.d.ts +11 -0
- package/dist/currencies.js +1 -0
- package/dist/index.d.ts +748 -0
- package/dist/index.js +1 -0
- package/dist/internal.d.ts +366 -0
- package/dist/internal.js +1 -0
- package/package.json +67 -6
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Your Next Store, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# commerce-kit
|
|
2
|
+
|
|
3
|
+
`commerce-kit` is a simple TypeScript library designed specifically for e-commerce applications built with Next.js. It provides a range of utilities to interact with products, categories, and orders, seamlessly integrating with Stripe for payment processing.
|
|
4
|
+
|
|
5
|
+
Built by [Your Next Store](https://yournextstore.com).
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **Product Browsing**: Easily fetch and display products.
|
|
10
|
+
- **Category Management**: Manage and retrieve product categories.
|
|
11
|
+
- **Order Handling**: Create and manage customer orders.
|
|
12
|
+
- **Cart Operations**: Add products to cart and retrieve cart details.
|
|
13
|
+
- **Stripe Integration**: Built-in support for payment processing using Stripe.
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
Install the package via npm:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install commerce-kit
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
`commerce-kit` is intended for use with Next.js applications. Here's a simple example of how to use it to fetch and display products:
|
|
26
|
+
|
|
27
|
+
```tsx
|
|
28
|
+
import * as Commerce from "commerce-kit";
|
|
29
|
+
import { formatMoney } from "commerce-kit/currencies";
|
|
30
|
+
import Image from "next/image";
|
|
31
|
+
import Link from "next/link";
|
|
32
|
+
|
|
33
|
+
export async function ProductList() {
|
|
34
|
+
const products = await Commerce.productBrowse({ first: 6 });
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<ul>
|
|
38
|
+
{products.map((product) => (
|
|
39
|
+
<li key={product.id}>
|
|
40
|
+
<Link href={`/product/${product.metadata.slug}`}>
|
|
41
|
+
<article>
|
|
42
|
+
{product.images[0] && (
|
|
43
|
+
<Image src={product.images[0]} width={300} height={300} alt={product.name} />
|
|
44
|
+
)}
|
|
45
|
+
<h2>{product.name}</h2>
|
|
46
|
+
{product.default_price.unit_amount && (
|
|
47
|
+
<p>
|
|
48
|
+
{formatMoney({
|
|
49
|
+
amount: product.default_price.unit_amount,
|
|
50
|
+
currency: product.default_price.currency,
|
|
51
|
+
locale: "en-US",
|
|
52
|
+
})}
|
|
53
|
+
</p>
|
|
54
|
+
)}
|
|
55
|
+
</article>
|
|
56
|
+
</Link>
|
|
57
|
+
</li>
|
|
58
|
+
))}
|
|
59
|
+
</ul>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## License
|
|
65
|
+
|
|
66
|
+
This project is licensed under the MIT License – see the [LICENSE](LICENSE.md) file for details.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
type Money = {
|
|
2
|
+
amount: number;
|
|
3
|
+
currency: string;
|
|
4
|
+
};
|
|
5
|
+
declare const getStripeAmountFromDecimal: ({ amount: major, currency }: Money) => number;
|
|
6
|
+
declare const getDecimalFromStripeAmount: ({ amount: minor, currency }: Money) => number;
|
|
7
|
+
declare const formatMoney: ({ amount: minor, currency, locale, }: Money & {
|
|
8
|
+
locale?: string;
|
|
9
|
+
}) => string;
|
|
10
|
+
|
|
11
|
+
export { formatMoney, getDecimalFromStripeAmount, getStripeAmountFromDecimal };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function o(e,n){if(!e)throw new Error(n)}var s=e=>{o(Number.isInteger(e),"Value must be an integer")};var u=e=>(o(e.length===3,"currency needs to be a 3-letter code"),a[e.toUpperCase()]??2),m=({amount:e,currency:n})=>{let t=10**u(n);return Number.parseInt((e*t).toFixed(0),10)},i=({amount:e,currency:n})=>{s(e);let r=u(n),t=10**r;return Number.parseFloat((e/t).toFixed(r))},p=({amount:e,currency:n,locale:r="en-US"})=>{let t=i({amount:e,currency:n});return new Intl.NumberFormat(r,{style:"currency",currency:n}).format(t)},a={BIF:0,CLP:0,DJF:0,GNF:0,JPY:0,KMF:0,KRW:0,MGA:0,PYG:0,RWF:0,UGX:0,VND:0,VUV:0,XAF:0,XOF:0,XPF:0,BHD:3,JOD:3,KWD:3,OMR:3,TND:3};export{p as formatMoney,i as getDecimalFromStripeAmount,m as getStripeAmountFromDecimal};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,748 @@
|
|
|
1
|
+
import { CartMetadata, mapCart } from './internal.js';
|
|
2
|
+
export { MappedProduct } from './internal.js';
|
|
3
|
+
import Stripe from 'stripe';
|
|
4
|
+
import { z, TypeOf } from 'zod';
|
|
5
|
+
|
|
6
|
+
type Entity = "Product" | "Category" | "Order";
|
|
7
|
+
type Provider = ({ tags, revalidate, cache, }: {
|
|
8
|
+
tags?: NextFetchRequestConfig["tags"];
|
|
9
|
+
revalidate?: NextFetchRequestConfig["revalidate"];
|
|
10
|
+
cache?: RequestInit["cache"];
|
|
11
|
+
}) => Stripe;
|
|
12
|
+
type Filter<T extends Entity> = {
|
|
13
|
+
Product: {
|
|
14
|
+
category?: string;
|
|
15
|
+
};
|
|
16
|
+
Category: {};
|
|
17
|
+
Order: {};
|
|
18
|
+
}[T];
|
|
19
|
+
type BrowseParams<T extends Entity> = {
|
|
20
|
+
first?: number;
|
|
21
|
+
last?: number;
|
|
22
|
+
offset?: number;
|
|
23
|
+
filter?: Filter<T>;
|
|
24
|
+
};
|
|
25
|
+
type SearchParams<_T extends Entity> = {
|
|
26
|
+
query: string;
|
|
27
|
+
};
|
|
28
|
+
type Cart = NonNullable<Awaited<ReturnType<typeof cartGet>>>;
|
|
29
|
+
declare function cartAdd({ productId, cartId }: {
|
|
30
|
+
productId: string;
|
|
31
|
+
cartId?: string;
|
|
32
|
+
}): Promise<Stripe.Response<Stripe.PaymentIntent> | undefined>;
|
|
33
|
+
declare function cartGet(cartId: string): Promise<{
|
|
34
|
+
cart: {
|
|
35
|
+
metadata: {
|
|
36
|
+
shippingRateId?: string | undefined;
|
|
37
|
+
taxCalculationId?: string | undefined;
|
|
38
|
+
taxCalculationExp?: string | undefined;
|
|
39
|
+
taxId?: string | undefined;
|
|
40
|
+
"billingAddress.city"?: string | undefined;
|
|
41
|
+
"billingAddress.country"?: string | undefined;
|
|
42
|
+
"billingAddress.line1"?: string | undefined;
|
|
43
|
+
"billingAddress.line2"?: string | undefined;
|
|
44
|
+
"billingAddress.name"?: string | undefined;
|
|
45
|
+
"billingAddress.postalCode"?: string | undefined;
|
|
46
|
+
"billingAddress.state"?: string | undefined;
|
|
47
|
+
netAmount?: string | undefined;
|
|
48
|
+
taxBreakdown0?: string | undefined;
|
|
49
|
+
taxBreakdown1?: string | undefined;
|
|
50
|
+
taxBreakdown2?: string | undefined;
|
|
51
|
+
taxBreakdown3?: string | undefined;
|
|
52
|
+
taxBreakdown4?: string | undefined;
|
|
53
|
+
taxBreakdown5?: string | undefined;
|
|
54
|
+
} & Record<string, string>;
|
|
55
|
+
payment_method: Stripe.PaymentMethod | null;
|
|
56
|
+
taxBreakdown: {
|
|
57
|
+
taxPercentage: string;
|
|
58
|
+
taxAmount: number;
|
|
59
|
+
taxType: Stripe.Tax.Calculation.TaxBreakdown.TaxRateDetails.TaxType | (string & {});
|
|
60
|
+
}[];
|
|
61
|
+
id: string;
|
|
62
|
+
object: "payment_intent";
|
|
63
|
+
amount: number;
|
|
64
|
+
amount_capturable: number;
|
|
65
|
+
amount_details?: Stripe.PaymentIntent.AmountDetails;
|
|
66
|
+
amount_received: number;
|
|
67
|
+
application: string | Stripe.Application | null;
|
|
68
|
+
application_fee_amount: number | null;
|
|
69
|
+
automatic_payment_methods: Stripe.PaymentIntent.AutomaticPaymentMethods | null;
|
|
70
|
+
canceled_at: number | null;
|
|
71
|
+
cancellation_reason: Stripe.PaymentIntent.CancellationReason | null;
|
|
72
|
+
capture_method: Stripe.PaymentIntent.CaptureMethod;
|
|
73
|
+
client_secret: string | null;
|
|
74
|
+
confirmation_method: Stripe.PaymentIntent.ConfirmationMethod;
|
|
75
|
+
created: number;
|
|
76
|
+
currency: string;
|
|
77
|
+
customer: string | Stripe.Customer | Stripe.DeletedCustomer | null;
|
|
78
|
+
description: string | null;
|
|
79
|
+
invoice: string | Stripe.Invoice | null;
|
|
80
|
+
last_payment_error: Stripe.PaymentIntent.LastPaymentError | null;
|
|
81
|
+
latest_charge: string | Stripe.Charge | null;
|
|
82
|
+
livemode: boolean;
|
|
83
|
+
next_action: Stripe.PaymentIntent.NextAction | null;
|
|
84
|
+
on_behalf_of: string | Stripe.Account | null;
|
|
85
|
+
payment_method_configuration_details: Stripe.PaymentIntent.PaymentMethodConfigurationDetails | null;
|
|
86
|
+
payment_method_options: Stripe.PaymentIntent.PaymentMethodOptions | null;
|
|
87
|
+
payment_method_types: Array<string>;
|
|
88
|
+
processing: Stripe.PaymentIntent.Processing | null;
|
|
89
|
+
receipt_email: string | null;
|
|
90
|
+
review: string | Stripe.Review | null;
|
|
91
|
+
setup_future_usage: Stripe.PaymentIntent.SetupFutureUsage | null;
|
|
92
|
+
shipping: Stripe.PaymentIntent.Shipping | null;
|
|
93
|
+
source: string | Stripe.CustomerSource | Stripe.DeletedCustomerSource | null;
|
|
94
|
+
statement_descriptor: string | null;
|
|
95
|
+
statement_descriptor_suffix: string | null;
|
|
96
|
+
status: Stripe.PaymentIntent.Status;
|
|
97
|
+
transfer_data: Stripe.PaymentIntent.TransferData | null;
|
|
98
|
+
transfer_group: string | null;
|
|
99
|
+
};
|
|
100
|
+
lines: {
|
|
101
|
+
product: {
|
|
102
|
+
default_price: Stripe.Price;
|
|
103
|
+
marketing_features: string[];
|
|
104
|
+
metadata: {
|
|
105
|
+
slug: string;
|
|
106
|
+
category?: string | undefined;
|
|
107
|
+
order?: number | undefined;
|
|
108
|
+
variant?: string | undefined;
|
|
109
|
+
};
|
|
110
|
+
id: string;
|
|
111
|
+
object: "product";
|
|
112
|
+
active: boolean;
|
|
113
|
+
created: number;
|
|
114
|
+
deleted?: void | undefined;
|
|
115
|
+
description: string | null;
|
|
116
|
+
images: Array<string>;
|
|
117
|
+
livemode: boolean;
|
|
118
|
+
name: string;
|
|
119
|
+
package_dimensions: Stripe.Product.PackageDimensions | null;
|
|
120
|
+
shippable: boolean | null;
|
|
121
|
+
statement_descriptor?: string | null;
|
|
122
|
+
tax_code: string | Stripe.TaxCode | null;
|
|
123
|
+
type: Stripe.Product.Type;
|
|
124
|
+
unit_label?: string | null;
|
|
125
|
+
updated: number;
|
|
126
|
+
url: string | null;
|
|
127
|
+
};
|
|
128
|
+
quantity: number;
|
|
129
|
+
}[];
|
|
130
|
+
shippingRate: Stripe.Response<Stripe.ShippingRate> | null;
|
|
131
|
+
} | null | undefined>;
|
|
132
|
+
declare function cartCreate(): Promise<Stripe.Response<Stripe.PaymentIntent>>;
|
|
133
|
+
declare function cartAddOptimistic({ cart, add }: {
|
|
134
|
+
cart: Cart;
|
|
135
|
+
add: string | undefined;
|
|
136
|
+
}): Promise<{
|
|
137
|
+
cart: {
|
|
138
|
+
metadata: {
|
|
139
|
+
shippingRateId?: string | undefined;
|
|
140
|
+
taxCalculationId?: string | undefined;
|
|
141
|
+
taxCalculationExp?: string | undefined;
|
|
142
|
+
taxId?: string | undefined;
|
|
143
|
+
"billingAddress.city"?: string | undefined;
|
|
144
|
+
"billingAddress.country"?: string | undefined;
|
|
145
|
+
"billingAddress.line1"?: string | undefined;
|
|
146
|
+
"billingAddress.line2"?: string | undefined;
|
|
147
|
+
"billingAddress.name"?: string | undefined;
|
|
148
|
+
"billingAddress.postalCode"?: string | undefined;
|
|
149
|
+
"billingAddress.state"?: string | undefined;
|
|
150
|
+
netAmount?: string | undefined;
|
|
151
|
+
taxBreakdown0?: string | undefined;
|
|
152
|
+
taxBreakdown1?: string | undefined;
|
|
153
|
+
taxBreakdown2?: string | undefined;
|
|
154
|
+
taxBreakdown3?: string | undefined;
|
|
155
|
+
taxBreakdown4?: string | undefined;
|
|
156
|
+
taxBreakdown5?: string | undefined;
|
|
157
|
+
} & Record<string, string>;
|
|
158
|
+
payment_method: Stripe.PaymentMethod | null;
|
|
159
|
+
taxBreakdown: {
|
|
160
|
+
taxPercentage: string;
|
|
161
|
+
taxAmount: number;
|
|
162
|
+
taxType: Stripe.Tax.Calculation.TaxBreakdown.TaxRateDetails.TaxType | (string & {});
|
|
163
|
+
}[];
|
|
164
|
+
id: string;
|
|
165
|
+
object: "payment_intent";
|
|
166
|
+
amount: number;
|
|
167
|
+
amount_capturable: number;
|
|
168
|
+
amount_details?: Stripe.PaymentIntent.AmountDetails;
|
|
169
|
+
amount_received: number;
|
|
170
|
+
application: string | Stripe.Application | null;
|
|
171
|
+
application_fee_amount: number | null;
|
|
172
|
+
automatic_payment_methods: Stripe.PaymentIntent.AutomaticPaymentMethods | null;
|
|
173
|
+
canceled_at: number | null;
|
|
174
|
+
cancellation_reason: Stripe.PaymentIntent.CancellationReason | null;
|
|
175
|
+
capture_method: Stripe.PaymentIntent.CaptureMethod;
|
|
176
|
+
client_secret: string | null;
|
|
177
|
+
confirmation_method: Stripe.PaymentIntent.ConfirmationMethod;
|
|
178
|
+
created: number;
|
|
179
|
+
currency: string;
|
|
180
|
+
customer: string | Stripe.Customer | Stripe.DeletedCustomer | null;
|
|
181
|
+
description: string | null;
|
|
182
|
+
invoice: string | Stripe.Invoice | null;
|
|
183
|
+
last_payment_error: Stripe.PaymentIntent.LastPaymentError | null;
|
|
184
|
+
latest_charge: string | Stripe.Charge | null;
|
|
185
|
+
livemode: boolean;
|
|
186
|
+
next_action: Stripe.PaymentIntent.NextAction | null;
|
|
187
|
+
on_behalf_of: string | Stripe.Account | null;
|
|
188
|
+
payment_method_configuration_details: Stripe.PaymentIntent.PaymentMethodConfigurationDetails | null;
|
|
189
|
+
payment_method_options: Stripe.PaymentIntent.PaymentMethodOptions | null;
|
|
190
|
+
payment_method_types: Array<string>;
|
|
191
|
+
processing: Stripe.PaymentIntent.Processing | null;
|
|
192
|
+
receipt_email: string | null;
|
|
193
|
+
review: string | Stripe.Review | null;
|
|
194
|
+
setup_future_usage: Stripe.PaymentIntent.SetupFutureUsage | null;
|
|
195
|
+
shipping: Stripe.PaymentIntent.Shipping | null;
|
|
196
|
+
source: string | Stripe.CustomerSource | Stripe.DeletedCustomerSource | null;
|
|
197
|
+
statement_descriptor: string | null;
|
|
198
|
+
statement_descriptor_suffix: string | null;
|
|
199
|
+
status: Stripe.PaymentIntent.Status;
|
|
200
|
+
transfer_data: Stripe.PaymentIntent.TransferData | null;
|
|
201
|
+
transfer_group: string | null;
|
|
202
|
+
};
|
|
203
|
+
lines: {
|
|
204
|
+
product: {
|
|
205
|
+
default_price: Stripe.Price;
|
|
206
|
+
marketing_features: string[];
|
|
207
|
+
metadata: {
|
|
208
|
+
slug: string;
|
|
209
|
+
category?: string | undefined;
|
|
210
|
+
order?: number | undefined;
|
|
211
|
+
variant?: string | undefined;
|
|
212
|
+
};
|
|
213
|
+
id: string;
|
|
214
|
+
object: "product";
|
|
215
|
+
active: boolean;
|
|
216
|
+
created: number;
|
|
217
|
+
deleted?: void | undefined;
|
|
218
|
+
description: string | null;
|
|
219
|
+
images: Array<string>;
|
|
220
|
+
livemode: boolean;
|
|
221
|
+
name: string;
|
|
222
|
+
package_dimensions: Stripe.Product.PackageDimensions | null;
|
|
223
|
+
shippable: boolean | null;
|
|
224
|
+
statement_descriptor?: string | null;
|
|
225
|
+
tax_code: string | Stripe.TaxCode | null;
|
|
226
|
+
type: Stripe.Product.Type;
|
|
227
|
+
unit_label?: string | null;
|
|
228
|
+
updated: number;
|
|
229
|
+
url: string | null;
|
|
230
|
+
};
|
|
231
|
+
quantity: number;
|
|
232
|
+
}[];
|
|
233
|
+
shippingRate: Stripe.Response<Stripe.ShippingRate> | null;
|
|
234
|
+
}>;
|
|
235
|
+
declare function cartSetQuantity({ cartId, productId, quantity, }: {
|
|
236
|
+
cartId: string;
|
|
237
|
+
productId: string;
|
|
238
|
+
quantity: number;
|
|
239
|
+
}): Promise<Stripe.Response<Stripe.PaymentIntent> | undefined>;
|
|
240
|
+
declare function productGetById(id: string): Promise<{
|
|
241
|
+
default_price: Stripe.Price;
|
|
242
|
+
marketing_features: string[];
|
|
243
|
+
metadata: {
|
|
244
|
+
slug: string;
|
|
245
|
+
category?: string | undefined;
|
|
246
|
+
order?: number | undefined;
|
|
247
|
+
variant?: string | undefined;
|
|
248
|
+
};
|
|
249
|
+
id: string;
|
|
250
|
+
object: "product";
|
|
251
|
+
active: boolean;
|
|
252
|
+
created: number;
|
|
253
|
+
deleted?: void | undefined;
|
|
254
|
+
description: string | null;
|
|
255
|
+
images: Array<string>;
|
|
256
|
+
livemode: boolean;
|
|
257
|
+
name: string;
|
|
258
|
+
package_dimensions: Stripe.Product.PackageDimensions | null;
|
|
259
|
+
shippable: boolean | null;
|
|
260
|
+
statement_descriptor?: string | null;
|
|
261
|
+
tax_code: string | Stripe.TaxCode | null;
|
|
262
|
+
type: Stripe.Product.Type;
|
|
263
|
+
unit_label?: string | null;
|
|
264
|
+
updated: number;
|
|
265
|
+
url: string | null;
|
|
266
|
+
} | null>;
|
|
267
|
+
declare function productGet({ slug }: {
|
|
268
|
+
slug: string;
|
|
269
|
+
}): Promise<{
|
|
270
|
+
default_price: Stripe.Price;
|
|
271
|
+
marketing_features: string[];
|
|
272
|
+
metadata: {
|
|
273
|
+
slug: string;
|
|
274
|
+
category?: string | undefined;
|
|
275
|
+
order?: number | undefined;
|
|
276
|
+
variant?: string | undefined;
|
|
277
|
+
};
|
|
278
|
+
id: string;
|
|
279
|
+
object: "product";
|
|
280
|
+
active: boolean;
|
|
281
|
+
created: number;
|
|
282
|
+
deleted?: void | undefined;
|
|
283
|
+
description: string | null;
|
|
284
|
+
images: Array<string>;
|
|
285
|
+
livemode: boolean;
|
|
286
|
+
name: string;
|
|
287
|
+
package_dimensions: Stripe.Product.PackageDimensions | null;
|
|
288
|
+
shippable: boolean | null;
|
|
289
|
+
statement_descriptor?: string | null;
|
|
290
|
+
tax_code: string | Stripe.TaxCode | null;
|
|
291
|
+
type: Stripe.Product.Type;
|
|
292
|
+
unit_label?: string | null;
|
|
293
|
+
updated: number;
|
|
294
|
+
url: string | null;
|
|
295
|
+
}[]>;
|
|
296
|
+
declare function productBrowse(params: BrowseParams<"Product">): Promise<{
|
|
297
|
+
default_price: Stripe.Price;
|
|
298
|
+
marketing_features: string[];
|
|
299
|
+
metadata: {
|
|
300
|
+
slug: string;
|
|
301
|
+
category?: string | undefined;
|
|
302
|
+
order?: number | undefined;
|
|
303
|
+
variant?: string | undefined;
|
|
304
|
+
};
|
|
305
|
+
id: string;
|
|
306
|
+
object: "product";
|
|
307
|
+
active: boolean;
|
|
308
|
+
created: number;
|
|
309
|
+
deleted?: void | undefined;
|
|
310
|
+
description: string | null;
|
|
311
|
+
images: Array<string>;
|
|
312
|
+
livemode: boolean;
|
|
313
|
+
name: string;
|
|
314
|
+
package_dimensions: Stripe.Product.PackageDimensions | null;
|
|
315
|
+
shippable: boolean | null;
|
|
316
|
+
statement_descriptor?: string | null;
|
|
317
|
+
tax_code: string | Stripe.TaxCode | null;
|
|
318
|
+
type: Stripe.Product.Type;
|
|
319
|
+
unit_label?: string | null;
|
|
320
|
+
updated: number;
|
|
321
|
+
url: string | null;
|
|
322
|
+
}[]>;
|
|
323
|
+
type ShippingRate = Awaited<ReturnType<typeof shippingBrowse>>["data"][0];
|
|
324
|
+
declare function shippingBrowse(): Promise<Stripe.Response<Stripe.ApiList<Stripe.ShippingRate>>>;
|
|
325
|
+
declare function shippingGet(id: string): Promise<Stripe.Response<Stripe.ShippingRate> | null>;
|
|
326
|
+
declare function categoryBrowse(params: BrowseParams<"Category">): Promise<string[]>;
|
|
327
|
+
declare function productSearch(params: SearchParams<"Product">): Promise<{
|
|
328
|
+
default_price: Stripe.Price;
|
|
329
|
+
marketing_features: string[];
|
|
330
|
+
metadata: {
|
|
331
|
+
slug: string;
|
|
332
|
+
category?: string | undefined;
|
|
333
|
+
order?: number | undefined;
|
|
334
|
+
variant?: string | undefined;
|
|
335
|
+
};
|
|
336
|
+
id: string;
|
|
337
|
+
object: "product";
|
|
338
|
+
active: boolean;
|
|
339
|
+
created: number;
|
|
340
|
+
deleted?: void | undefined;
|
|
341
|
+
description: string | null;
|
|
342
|
+
images: Array<string>;
|
|
343
|
+
livemode: boolean;
|
|
344
|
+
name: string;
|
|
345
|
+
package_dimensions: Stripe.Product.PackageDimensions | null;
|
|
346
|
+
shippable: boolean | null;
|
|
347
|
+
statement_descriptor?: string | null;
|
|
348
|
+
tax_code: string | Stripe.TaxCode | null;
|
|
349
|
+
type: Stripe.Product.Type;
|
|
350
|
+
unit_label?: string | null;
|
|
351
|
+
updated: number;
|
|
352
|
+
url: string | null;
|
|
353
|
+
}[]>;
|
|
354
|
+
declare function fileGet(id: string): Promise<Stripe.Response<Stripe.FileLink> | null>;
|
|
355
|
+
declare function accountGet(): Promise<{
|
|
356
|
+
account: (Stripe.Account & {
|
|
357
|
+
lastResponse: {
|
|
358
|
+
headers: {
|
|
359
|
+
[key: string]: string;
|
|
360
|
+
};
|
|
361
|
+
requestId: string;
|
|
362
|
+
statusCode: number;
|
|
363
|
+
apiVersion?: string;
|
|
364
|
+
idempotencyKey?: string;
|
|
365
|
+
stripeAccount?: string;
|
|
366
|
+
};
|
|
367
|
+
}) | null;
|
|
368
|
+
logo: null;
|
|
369
|
+
} | {
|
|
370
|
+
account: (Stripe.Account & {
|
|
371
|
+
lastResponse: {
|
|
372
|
+
headers: {
|
|
373
|
+
[key: string]: string;
|
|
374
|
+
};
|
|
375
|
+
requestId: string;
|
|
376
|
+
statusCode: number;
|
|
377
|
+
apiVersion?: string;
|
|
378
|
+
idempotencyKey?: string;
|
|
379
|
+
stripeAccount?: string;
|
|
380
|
+
};
|
|
381
|
+
}) | null;
|
|
382
|
+
logo: Stripe.File;
|
|
383
|
+
} | null>;
|
|
384
|
+
declare function orderGet(orderId: string): Promise<{
|
|
385
|
+
order: {
|
|
386
|
+
payment_method: Stripe.PaymentMethod | null;
|
|
387
|
+
latest_charge: Stripe.Charge | null;
|
|
388
|
+
taxBreakdown: {
|
|
389
|
+
taxPercentage: string;
|
|
390
|
+
taxAmount: number;
|
|
391
|
+
taxType: Stripe.Tax.Calculation.TaxBreakdown.TaxRateDetails.TaxType | (string & {});
|
|
392
|
+
}[];
|
|
393
|
+
metadata: {
|
|
394
|
+
shippingRateId?: string | undefined;
|
|
395
|
+
taxCalculationId?: string | undefined;
|
|
396
|
+
taxCalculationExp?: string | undefined;
|
|
397
|
+
taxId?: string | undefined;
|
|
398
|
+
"billingAddress.city"?: string | undefined;
|
|
399
|
+
"billingAddress.country"?: string | undefined;
|
|
400
|
+
"billingAddress.line1"?: string | undefined;
|
|
401
|
+
"billingAddress.line2"?: string | undefined;
|
|
402
|
+
"billingAddress.name"?: string | undefined;
|
|
403
|
+
"billingAddress.postalCode"?: string | undefined;
|
|
404
|
+
"billingAddress.state"?: string | undefined;
|
|
405
|
+
netAmount?: string | undefined;
|
|
406
|
+
taxBreakdown0?: string | undefined;
|
|
407
|
+
taxBreakdown1?: string | undefined;
|
|
408
|
+
taxBreakdown2?: string | undefined;
|
|
409
|
+
taxBreakdown3?: string | undefined;
|
|
410
|
+
taxBreakdown4?: string | undefined;
|
|
411
|
+
taxBreakdown5?: string | undefined;
|
|
412
|
+
} & Record<string, string>;
|
|
413
|
+
id: string;
|
|
414
|
+
object: "payment_intent";
|
|
415
|
+
amount: number;
|
|
416
|
+
amount_capturable: number;
|
|
417
|
+
amount_details?: Stripe.PaymentIntent.AmountDetails;
|
|
418
|
+
amount_received: number;
|
|
419
|
+
application: string | Stripe.Application | null;
|
|
420
|
+
application_fee_amount: number | null;
|
|
421
|
+
automatic_payment_methods: Stripe.PaymentIntent.AutomaticPaymentMethods | null;
|
|
422
|
+
canceled_at: number | null;
|
|
423
|
+
cancellation_reason: Stripe.PaymentIntent.CancellationReason | null;
|
|
424
|
+
capture_method: Stripe.PaymentIntent.CaptureMethod;
|
|
425
|
+
client_secret: string | null;
|
|
426
|
+
confirmation_method: Stripe.PaymentIntent.ConfirmationMethod;
|
|
427
|
+
created: number;
|
|
428
|
+
currency: string;
|
|
429
|
+
customer: string | Stripe.Customer | Stripe.DeletedCustomer | null;
|
|
430
|
+
description: string | null;
|
|
431
|
+
invoice: string | Stripe.Invoice | null;
|
|
432
|
+
last_payment_error: Stripe.PaymentIntent.LastPaymentError | null;
|
|
433
|
+
livemode: boolean;
|
|
434
|
+
next_action: Stripe.PaymentIntent.NextAction | null;
|
|
435
|
+
on_behalf_of: string | Stripe.Account | null;
|
|
436
|
+
payment_method_configuration_details: Stripe.PaymentIntent.PaymentMethodConfigurationDetails | null;
|
|
437
|
+
payment_method_options: Stripe.PaymentIntent.PaymentMethodOptions | null;
|
|
438
|
+
payment_method_types: Array<string>;
|
|
439
|
+
processing: Stripe.PaymentIntent.Processing | null;
|
|
440
|
+
receipt_email: string | null;
|
|
441
|
+
review: string | Stripe.Review | null;
|
|
442
|
+
setup_future_usage: Stripe.PaymentIntent.SetupFutureUsage | null;
|
|
443
|
+
shipping: Stripe.PaymentIntent.Shipping | null;
|
|
444
|
+
source: string | Stripe.CustomerSource | Stripe.DeletedCustomerSource | null;
|
|
445
|
+
statement_descriptor: string | null;
|
|
446
|
+
statement_descriptor_suffix: string | null;
|
|
447
|
+
status: Stripe.PaymentIntent.Status;
|
|
448
|
+
transfer_data: Stripe.PaymentIntent.TransferData | null;
|
|
449
|
+
transfer_group: string | null;
|
|
450
|
+
};
|
|
451
|
+
lines: {
|
|
452
|
+
product: {
|
|
453
|
+
default_price: Stripe.Price;
|
|
454
|
+
marketing_features: string[];
|
|
455
|
+
metadata: {
|
|
456
|
+
slug: string;
|
|
457
|
+
category?: string | undefined;
|
|
458
|
+
order?: number | undefined;
|
|
459
|
+
variant?: string | undefined;
|
|
460
|
+
};
|
|
461
|
+
id: string;
|
|
462
|
+
object: "product";
|
|
463
|
+
active: boolean;
|
|
464
|
+
created: number;
|
|
465
|
+
deleted?: void | undefined;
|
|
466
|
+
description: string | null;
|
|
467
|
+
images: Array<string>;
|
|
468
|
+
livemode: boolean;
|
|
469
|
+
name: string;
|
|
470
|
+
package_dimensions: Stripe.Product.PackageDimensions | null;
|
|
471
|
+
shippable: boolean | null;
|
|
472
|
+
statement_descriptor?: string | null;
|
|
473
|
+
tax_code: string | Stripe.TaxCode | null;
|
|
474
|
+
type: Stripe.Product.Type;
|
|
475
|
+
unit_label?: string | null;
|
|
476
|
+
updated: number;
|
|
477
|
+
url: string | null;
|
|
478
|
+
};
|
|
479
|
+
quantity: number;
|
|
480
|
+
}[];
|
|
481
|
+
shippingRate: Stripe.Response<Stripe.ShippingRate> | null;
|
|
482
|
+
} | null>;
|
|
483
|
+
declare const getProductsFromCart: (metadata: CartMetadata) => (readonly [productId: string, quantity: number])[];
|
|
484
|
+
type MappedCart = ReturnType<typeof mapCart>;
|
|
485
|
+
declare function getProductsFromMetadata(metadata: MappedCart["metadata"]): Promise<{
|
|
486
|
+
product: {
|
|
487
|
+
default_price: Stripe.Price;
|
|
488
|
+
marketing_features: string[];
|
|
489
|
+
metadata: {
|
|
490
|
+
slug: string;
|
|
491
|
+
category?: string | undefined;
|
|
492
|
+
order?: number | undefined;
|
|
493
|
+
variant?: string | undefined;
|
|
494
|
+
};
|
|
495
|
+
id: string;
|
|
496
|
+
object: "product";
|
|
497
|
+
active: boolean;
|
|
498
|
+
created: number;
|
|
499
|
+
deleted?: void | undefined;
|
|
500
|
+
description: string | null;
|
|
501
|
+
images: Array<string>;
|
|
502
|
+
livemode: boolean;
|
|
503
|
+
name: string;
|
|
504
|
+
package_dimensions: Stripe.Product.PackageDimensions | null;
|
|
505
|
+
shippable: boolean | null;
|
|
506
|
+
statement_descriptor?: string | null;
|
|
507
|
+
tax_code: string | Stripe.TaxCode | null;
|
|
508
|
+
type: Stripe.Product.Type;
|
|
509
|
+
unit_label?: string | null;
|
|
510
|
+
updated: number;
|
|
511
|
+
url: string | null;
|
|
512
|
+
} | null;
|
|
513
|
+
quantity: number;
|
|
514
|
+
}[]>;
|
|
515
|
+
type ProductsFromMetadata = Awaited<ReturnType<typeof getProductsFromMetadata>>;
|
|
516
|
+
declare const getCartWithProductsById: (provider: Provider, cartId: string) => Promise<{
|
|
517
|
+
cart: {
|
|
518
|
+
metadata: {
|
|
519
|
+
shippingRateId?: string | undefined;
|
|
520
|
+
taxCalculationId?: string | undefined;
|
|
521
|
+
taxCalculationExp?: string | undefined;
|
|
522
|
+
taxId?: string | undefined;
|
|
523
|
+
"billingAddress.city"?: string | undefined;
|
|
524
|
+
"billingAddress.country"?: string | undefined;
|
|
525
|
+
"billingAddress.line1"?: string | undefined;
|
|
526
|
+
"billingAddress.line2"?: string | undefined;
|
|
527
|
+
"billingAddress.name"?: string | undefined;
|
|
528
|
+
"billingAddress.postalCode"?: string | undefined;
|
|
529
|
+
"billingAddress.state"?: string | undefined;
|
|
530
|
+
netAmount?: string | undefined;
|
|
531
|
+
taxBreakdown0?: string | undefined;
|
|
532
|
+
taxBreakdown1?: string | undefined;
|
|
533
|
+
taxBreakdown2?: string | undefined;
|
|
534
|
+
taxBreakdown3?: string | undefined;
|
|
535
|
+
taxBreakdown4?: string | undefined;
|
|
536
|
+
taxBreakdown5?: string | undefined;
|
|
537
|
+
} & Record<string, string>;
|
|
538
|
+
payment_method: Stripe.PaymentMethod | null;
|
|
539
|
+
taxBreakdown: {
|
|
540
|
+
taxPercentage: string;
|
|
541
|
+
taxAmount: number;
|
|
542
|
+
taxType: Stripe.Tax.Calculation.TaxBreakdown.TaxRateDetails.TaxType | (string & {});
|
|
543
|
+
}[];
|
|
544
|
+
id: string;
|
|
545
|
+
object: "payment_intent";
|
|
546
|
+
amount: number;
|
|
547
|
+
amount_capturable: number;
|
|
548
|
+
amount_details?: Stripe.PaymentIntent.AmountDetails;
|
|
549
|
+
amount_received: number;
|
|
550
|
+
application: string | Stripe.Application | null;
|
|
551
|
+
application_fee_amount: number | null;
|
|
552
|
+
automatic_payment_methods: Stripe.PaymentIntent.AutomaticPaymentMethods | null;
|
|
553
|
+
canceled_at: number | null;
|
|
554
|
+
cancellation_reason: Stripe.PaymentIntent.CancellationReason | null;
|
|
555
|
+
capture_method: Stripe.PaymentIntent.CaptureMethod;
|
|
556
|
+
client_secret: string | null;
|
|
557
|
+
confirmation_method: Stripe.PaymentIntent.ConfirmationMethod;
|
|
558
|
+
created: number;
|
|
559
|
+
currency: string;
|
|
560
|
+
customer: string | Stripe.Customer | Stripe.DeletedCustomer | null;
|
|
561
|
+
description: string | null;
|
|
562
|
+
invoice: string | Stripe.Invoice | null;
|
|
563
|
+
last_payment_error: Stripe.PaymentIntent.LastPaymentError | null;
|
|
564
|
+
latest_charge: string | Stripe.Charge | null;
|
|
565
|
+
livemode: boolean;
|
|
566
|
+
next_action: Stripe.PaymentIntent.NextAction | null;
|
|
567
|
+
on_behalf_of: string | Stripe.Account | null;
|
|
568
|
+
payment_method_configuration_details: Stripe.PaymentIntent.PaymentMethodConfigurationDetails | null;
|
|
569
|
+
payment_method_options: Stripe.PaymentIntent.PaymentMethodOptions | null;
|
|
570
|
+
payment_method_types: Array<string>;
|
|
571
|
+
processing: Stripe.PaymentIntent.Processing | null;
|
|
572
|
+
receipt_email: string | null;
|
|
573
|
+
review: string | Stripe.Review | null;
|
|
574
|
+
setup_future_usage: Stripe.PaymentIntent.SetupFutureUsage | null;
|
|
575
|
+
shipping: Stripe.PaymentIntent.Shipping | null;
|
|
576
|
+
source: string | Stripe.CustomerSource | Stripe.DeletedCustomerSource | null;
|
|
577
|
+
statement_descriptor: string | null;
|
|
578
|
+
statement_descriptor_suffix: string | null;
|
|
579
|
+
status: Stripe.PaymentIntent.Status;
|
|
580
|
+
transfer_data: Stripe.PaymentIntent.TransferData | null;
|
|
581
|
+
transfer_group: string | null;
|
|
582
|
+
};
|
|
583
|
+
lines: {
|
|
584
|
+
product: {
|
|
585
|
+
default_price: Stripe.Price;
|
|
586
|
+
marketing_features: string[];
|
|
587
|
+
metadata: {
|
|
588
|
+
slug: string;
|
|
589
|
+
category?: string | undefined;
|
|
590
|
+
order?: number | undefined;
|
|
591
|
+
variant?: string | undefined;
|
|
592
|
+
};
|
|
593
|
+
id: string;
|
|
594
|
+
object: "product";
|
|
595
|
+
active: boolean;
|
|
596
|
+
created: number;
|
|
597
|
+
deleted?: void | undefined;
|
|
598
|
+
description: string | null;
|
|
599
|
+
images: Array<string>;
|
|
600
|
+
livemode: boolean;
|
|
601
|
+
name: string;
|
|
602
|
+
package_dimensions: Stripe.Product.PackageDimensions | null;
|
|
603
|
+
shippable: boolean | null;
|
|
604
|
+
statement_descriptor?: string | null;
|
|
605
|
+
tax_code: string | Stripe.TaxCode | null;
|
|
606
|
+
type: Stripe.Product.Type;
|
|
607
|
+
unit_label?: string | null;
|
|
608
|
+
updated: number;
|
|
609
|
+
url: string | null;
|
|
610
|
+
};
|
|
611
|
+
quantity: number;
|
|
612
|
+
}[];
|
|
613
|
+
shippingRate: Stripe.Response<Stripe.ShippingRate> | null;
|
|
614
|
+
} | null>;
|
|
615
|
+
declare const calculateCartTotalNet: (cart: {
|
|
616
|
+
cart: {
|
|
617
|
+
amount: number;
|
|
618
|
+
metadata?: {
|
|
619
|
+
taxCalculationId?: string;
|
|
620
|
+
};
|
|
621
|
+
};
|
|
622
|
+
lines: Array<{
|
|
623
|
+
product: {
|
|
624
|
+
default_price?: {
|
|
625
|
+
unit_amount?: number | null;
|
|
626
|
+
};
|
|
627
|
+
};
|
|
628
|
+
quantity: number;
|
|
629
|
+
}>;
|
|
630
|
+
shippingRate?: {
|
|
631
|
+
fixed_amount?: {
|
|
632
|
+
amount?: number;
|
|
633
|
+
};
|
|
634
|
+
} | null;
|
|
635
|
+
}) => number;
|
|
636
|
+
declare const getAddressSchema: (tr: {
|
|
637
|
+
nameRequired: string;
|
|
638
|
+
cityRequired: string;
|
|
639
|
+
countryRequired: string;
|
|
640
|
+
line1Required: string;
|
|
641
|
+
postalCodeRequired: string;
|
|
642
|
+
}) => z.ZodObject<{
|
|
643
|
+
name: z.ZodString;
|
|
644
|
+
city: z.ZodString;
|
|
645
|
+
country: z.ZodString;
|
|
646
|
+
line1: z.ZodString;
|
|
647
|
+
line2: z.ZodDefault<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
|
|
648
|
+
postalCode: z.ZodString;
|
|
649
|
+
state: z.ZodDefault<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
|
|
650
|
+
phone: z.ZodDefault<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
|
|
651
|
+
taxId: z.ZodDefault<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
|
|
652
|
+
}, "strip", z.ZodTypeAny, {
|
|
653
|
+
name: string;
|
|
654
|
+
taxId: string | null;
|
|
655
|
+
city: string;
|
|
656
|
+
country: string;
|
|
657
|
+
line1: string;
|
|
658
|
+
line2: string | null;
|
|
659
|
+
postalCode: string;
|
|
660
|
+
state: string | null;
|
|
661
|
+
phone: string | null;
|
|
662
|
+
}, {
|
|
663
|
+
name: string;
|
|
664
|
+
city: string;
|
|
665
|
+
country: string;
|
|
666
|
+
line1: string;
|
|
667
|
+
postalCode: string;
|
|
668
|
+
taxId?: string | null | undefined;
|
|
669
|
+
line2?: string | null | undefined;
|
|
670
|
+
state?: string | null | undefined;
|
|
671
|
+
phone?: string | null | undefined;
|
|
672
|
+
}>;
|
|
673
|
+
type AddressSchema = TypeOf<ReturnType<typeof getAddressSchema>>;
|
|
674
|
+
declare const calculateCartTotalPossiblyWithTax: (cart: {
|
|
675
|
+
cart: {
|
|
676
|
+
amount: number;
|
|
677
|
+
metadata?: {
|
|
678
|
+
taxCalculationId?: string;
|
|
679
|
+
};
|
|
680
|
+
};
|
|
681
|
+
lines: Array<{
|
|
682
|
+
product: {
|
|
683
|
+
default_price?: {
|
|
684
|
+
unit_amount?: number | null;
|
|
685
|
+
};
|
|
686
|
+
};
|
|
687
|
+
quantity: number;
|
|
688
|
+
}>;
|
|
689
|
+
shippingRate?: {
|
|
690
|
+
fixed_amount?: {
|
|
691
|
+
amount?: number;
|
|
692
|
+
};
|
|
693
|
+
} | null;
|
|
694
|
+
}) => number;
|
|
695
|
+
declare const calculateCartTotalNetWithoutShipping: (cart: {
|
|
696
|
+
cart: {
|
|
697
|
+
amount: number;
|
|
698
|
+
metadata?: {
|
|
699
|
+
taxCalculationId?: string;
|
|
700
|
+
};
|
|
701
|
+
};
|
|
702
|
+
lines: Array<{
|
|
703
|
+
product: {
|
|
704
|
+
default_price?: {
|
|
705
|
+
unit_amount?: number | null;
|
|
706
|
+
};
|
|
707
|
+
};
|
|
708
|
+
quantity: number;
|
|
709
|
+
}>;
|
|
710
|
+
shippingRate?: {
|
|
711
|
+
fixed_amount?: {
|
|
712
|
+
amount?: number;
|
|
713
|
+
};
|
|
714
|
+
} | null;
|
|
715
|
+
}) => number;
|
|
716
|
+
declare function cartChangeQuantity({ productId, cartId, operation, clearTaxCalculation, }: {
|
|
717
|
+
productId: string;
|
|
718
|
+
cartId: string;
|
|
719
|
+
operation: "INCREASE" | "DECREASE";
|
|
720
|
+
clearTaxCalculation?: boolean;
|
|
721
|
+
}): Promise<Stripe.Response<Stripe.PaymentIntent> | undefined>;
|
|
722
|
+
declare const cartSaveTax: ({ cartId, taxId }: {
|
|
723
|
+
cartId: string;
|
|
724
|
+
taxId: string;
|
|
725
|
+
}) => Promise<Stripe.Response<Stripe.PaymentIntent> | undefined>;
|
|
726
|
+
declare function cartSaveShipping({ cartId, shippingRateId, }: {
|
|
727
|
+
cartId: string;
|
|
728
|
+
shippingRateId: string;
|
|
729
|
+
}): Promise<Stripe.Response<Stripe.PaymentIntent> | undefined>;
|
|
730
|
+
declare function cartSaveBillingAddress({ cartId, billingAddress, }: {
|
|
731
|
+
cartId: string;
|
|
732
|
+
billingAddress: AddressSchema;
|
|
733
|
+
}): Promise<Stripe.Response<Stripe.PaymentIntent> | undefined>;
|
|
734
|
+
declare function taxDefaultGet(): Promise<Stripe.Response<Stripe.Tax.Settings>>;
|
|
735
|
+
declare function cartCount(metadata: CartMetadata): number;
|
|
736
|
+
|
|
737
|
+
declare const StripeClient: ({ tags, revalidate, cache, }: {
|
|
738
|
+
tags?: NextFetchRequestConfig["tags"];
|
|
739
|
+
revalidate?: NextFetchRequestConfig["revalidate"];
|
|
740
|
+
cache?: RequestInit["cache"];
|
|
741
|
+
}) => Stripe;
|
|
742
|
+
declare const provider: ({ tags, revalidate, cache, }: {
|
|
743
|
+
tags?: NextFetchRequestConfig["tags"];
|
|
744
|
+
revalidate?: NextFetchRequestConfig["revalidate"];
|
|
745
|
+
cache?: RequestInit["cache"];
|
|
746
|
+
}) => Stripe;
|
|
747
|
+
|
|
748
|
+
export { type AddressSchema, type Cart, type MappedCart, type ProductsFromMetadata, type ShippingRate, StripeClient, accountGet, calculateCartTotalNet, calculateCartTotalNetWithoutShipping, calculateCartTotalPossiblyWithTax, cartAdd, cartAddOptimistic, cartChangeQuantity, cartCount, cartCreate, cartGet, cartSaveBillingAddress, cartSaveShipping, cartSaveTax, cartSetQuantity, categoryBrowse, fileGet, getAddressSchema, getCartWithProductsById, getProductsFromCart, orderGet, productBrowse, productGet, productGetById, productSearch, provider, shippingBrowse, shippingGet, taxDefaultGet };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"server-only";import"server-only";import{z as c}from"zod";function _(t,e){if(!t)throw new Error(e)}var U=async t=>{try{return[null,await t]}catch(e){return[e instanceof Error?e:new Error(String(e)),null]}},R=t=>{if(t==null)return 0;if(typeof t=="number")return t;let e=Number.parseInt(t,10);return Number.isNaN(e)?0:e},F=t=>{if(t==null)return null;try{return JSON.parse(t)}catch{return null}};var L=t=>t.toString().replace(/"/g,'\\"'),O=t=>Object.entries(t).map(([e,a])=>`${e}:"${L(a)}"`).join(" AND ").trim();function P(t){return t.toSorted((e,a)=>{let r=Number(e.metadata.order),n=Number(a.metadata.order);return Number.isNaN(r)&&Number.isNaN(n)||r===n?a.updated-e.updated:Number.isNaN(r)?1:Number.isNaN(n)?-1:r-n})}var rt=c.object({category:c.string().optional(),order:c.coerce.number().optional(),slug:c.string(),variant:c.string().optional()});function N({default_price:t,marketing_features:e,...a}){return _(t,"Product must have a default price"),_(typeof t=="object","Product default price must be an object"),{...a,default_price:t,marketing_features:e.map(r=>r.name).filter(Boolean),metadata:rt.parse(a.metadata)}}function A(t){return t.data.map(N)}function j(t){return t.filter((e,a,r)=>a===r.findIndex(n=>n.metadata.slug===e.metadata.slug))}var B=t=>!t.deleted&&t.active,q=c.object({shippingRateId:c.string().optional(),taxCalculationId:c.string().optional(),taxCalculationExp:c.string().optional(),taxId:c.string().optional(),"billingAddress.city":c.string().optional(),"billingAddress.country":c.string().optional(),"billingAddress.line1":c.string().optional(),"billingAddress.line2":c.string().optional(),"billingAddress.name":c.string().optional(),"billingAddress.postalCode":c.string().optional(),"billingAddress.state":c.string().optional(),netAmount:c.string().optional(),taxBreakdown0:c.string().optional(),taxBreakdown1:c.string().optional(),taxBreakdown2:c.string().optional(),taxBreakdown3:c.string().optional(),taxBreakdown4:c.string().optional(),taxBreakdown5:c.string().optional()}).and(c.record(c.string())),W=c.object({taxType:c.string(),taxPercentage:c.string(),taxAmount:c.number()});function Q(t){let e=t.payment_method;_(typeof e!="string","Payment method is missing from cart");let a=q.parse(t.metadata),r=Object.entries(a).filter(([n])=>n.startsWith("taxBreakdown")).map(([n,o])=>{let i=W.safeParse(F(String(o)));return i.success?i.data:null}).filter(Boolean);return{...t,metadata:a,payment_method:e,taxBreakdown:r}}function V({payment_method:t,latest_charge:e,...a}){_(typeof t=="object","Payment method is missing from order"),_(typeof e=="object","Latest charge is missing from order");let r=q.parse(a.metadata),n=Object.entries(r).filter(([o])=>o.startsWith("taxBreakdown")).map(([o,i])=>{let s=W.safeParse(F(String(i)));return s.success?s.data:null}).filter(Boolean);return{...a,payment_method:t,latest_charge:e,taxBreakdown:n,metadata:r}}import"server-only";import{revalidatePath as Y,revalidateTag as S}from"next/cache";import C from"stripe";import{z as x}from"zod";import"server-only";var m=()=>{if(global.__ynsFindStripeAccount)return global.__ynsFindStripeAccount()};import"server-only";import K from"stripe";import"server-only";var z=process.env.STRIPE_SECRET_KEY;if(!z)throw new Error("Missing STRIPE_SECRET_KEY");var D=process.env.STRIPE_CURRENCY;if(!D)throw new Error("Missing STRIPE_CURRENCY");var g={StripeSecretKey:z,StripeCurrency:D};var at=({tags:t,revalidate:e,cache:a})=>new K(g.StripeSecretKey,{typescript:!0,apiVersion:"2024-06-20",httpClient:K.createFetchHttpClient((n,o)=>fetch(n,{...o,cache:a??o?.cache,next:{tags:t??o?.next?.tags,revalidate:e??o?.next?.revalidate}})),appInfo:{name:"Commerce SDK",version:"beta",url:"https://yournextstore.com",partner_id:"CONS-003378"}}),p=({tags:t,revalidate:e,cache:a})=>at({tags:t,revalidate:e,cache:a});var $=1e3;function Lt({productId:t,cartId:e}){return e?k.add(p,{productId:t,cartId:e}):k.create(p,{productId:t})}function E(t){return k.get(p,{cartId:t})}function Ot(){return k.create(p,{})}async function jt({cart:t,add:e}){if(!e)return t;let a=await v(e);if(!a)return console.warn(`Product not found: ${e}`),t;let n=(t?.lines.find(i=>i.product.id===e)?t.lines:[...t?.lines??[],{product:a,quantity:0}]).map(i=>i.product.id===e?{...i,quantity:i.quantity+1}:i),o=t?M(t)+(a.default_price.unit_amount??0):a.default_price.unit_amount??0;return{...t,cart:{...t?.cart,amount:o},lines:n}}async function Qt({cartId:t,productId:e,quantity:a}){let[r,n]=await Promise.all([X(e),E(t)]);if(!r)throw new Error(`Product not found: ${e}`);if(!n)throw new Error(`Cart not found: ${t}`);if(g.StripeCurrency?.toLowerCase()!==r.default_price.currency.toLowerCase())throw new Error(`Product currency ${r.default_price.currency} does not match cart currency ${g.StripeCurrency}`);let o=n.cart.metadata??{};a<=0?o[e]="":o[e]=a.toString();let i=M(n)+(r.default_price.unit_amount??0);try{return await b({paymentIntentId:t,data:{metadata:o,amount:i||$}})}catch(s){console.error(s)}finally{S(`cart-${t}`),Y("/cart"),Y("/cart-overlay")}}async function X(t){let e=await m(),a=p({tags:["product",`product-${t}`],cache:"force-cache"});try{let r=await a.products.retrieve(t,{expand:["default_price"]},{stripeAccount:e});return N(r)}catch(r){if(r instanceof C.errors.StripeError&&r.code==="resource_missing")return null;throw r}}async function Gt({slug:t}){let e=await m(),r=await p({tags:["product",`product-${t}`],cache:"force-cache"}).products.search({query:O({active:!0,'metadata["slug"]':t}),expand:["data.default_price"]},{stripeAccount:e});if(r.data.length>1&&r.data.some(n=>!n.metadata.variant))throw new Error(`Multiple products found with the same slug (${t}) but no variant set.`);return P(A(r).filter(B))}async function nt(t){let e=await m();if(t.filter?.category){let a=t.filter?.category,n=await p({tags:["product",`category-${a}`],cache:"force-cache"}).products.search({limit:100,query:O({active:!0,'metadata["category"]':a}),expand:["data.default_price"]},{stripeAccount:e});return P(j(A(n)).filter(B).slice(t.offset,t.first))}else{let r=await p({tags:["product"],cache:"force-cache"}).products.list({limit:100,active:!0,expand:["data.default_price"]},{stripeAccount:e});return P(j(A(r)).filter(B).slice(t.offset,t.first))}}async function Ut(){let t=await m();return await p({tags:["shipping"]}).shippingRates.list({active:!0},{stripeAccount:t})}async function T(t){let e=await m(),a=p({tags:["shipping",`shipping-${t}`]});try{return await a.shippingRates.retrieve(t,{},{stripeAccount:e})}catch(r){if(console.error(r),r instanceof C.errors.StripeError&&r.code==="resource_missing")return null;throw r}}async function Wt(t){let a=(await nt({first:100})).map(n=>n.metadata.category),r=new Set(a);return Array.from(r).filter(Boolean)}async function Vt(t){let e=await m(),a=p({tags:["products","search"]}),r=L(t.query),n=await a.products.search({limit:100,query:`name~"${r}" OR description~"${r}" OR metadata["slug"]:"${r}" OR metadata["category"]:"${r}"`,expand:["data.default_price"]},{stripeAccount:e});return P(A(n).filter(o=>o.active&&!o.deleted))}async function zt(t){let e=await m(),a=p({tags:["files",`file-${t}`]});try{return await a.fileLinks.create({file:t},{stripeAccount:e})}catch(r){if(console.error(r),r instanceof C.errors.StripeError&&r.code==="resource_missing")return null;throw r}}async function Dt(){let t=await m(),e=p({tags:["account"]});try{let[a,r]=await U(e.accounts.retrieve({expand:["settings.branding.logo"]},{stripeAccount:t})),n=r?.settings?.branding.logo??null;return!n||typeof n=="string"?{account:r,logo:null}:{account:r,logo:n}}catch(a){if(console.error(a),a instanceof C.errors.StripeError&&a.code==="resource_missing")return null;throw a}}async function ot(t){let e=await m(),a=p({tags:["order",`order-${t}`]});try{let r=await a.paymentIntents.retrieve(t,{expand:["payment_method","latest_charge"]},{stripeAccount:e});return V(r)}catch(r){if(r instanceof C.errors.StripeError&&r.code==="resource_missing")return null;throw r}}async function Kt(t){let e=await ot(t);if(!e)return null;let a=Z(e.metadata),r=await Promise.all(a.map(async([i,s])=>({product:await v(i),quantity:s}))),{metadata:{shippingRateId:n}}=e,o=n&&await T(n);return{order:e,lines:r.map(({product:i,quantity:s})=>i?{product:i,quantity:s}:null).filter(Boolean),shippingRate:o||null}}var v=async t=>{let e=await m(),a=p({tags:["product",`product-${t}`],cache:"force-cache"});try{let r=await a.products.retrieve(t,{expand:["default_price"]},{stripeAccount:e});return N(r)}catch(r){if(r instanceof C.errors.StripeError&&r.code==="resource_missing")return null;throw r}},H=["requires_action","requires_confirmation","requires_capture","requires_payment_method"],Z=t=>Object.entries(t??{}).filter(([e])=>e.startsWith("prod_")).map(([e,a])=>[e,R(a)]).filter(([,e])=>e&&Number.isFinite(e)&&e>0),it=async(t,e)=>{let a=await m(),r=t({tags:["cart",`cart-${e}`],cache:"force-cache"});try{let n=await r.paymentIntents.retrieve(e,{expand:["payment_method"]},{stripeAccount:a});if(H.includes(n.status))return Q(n)}catch(n){if(console.error(n),n instanceof C.errors.StripeError&&n.code==="resource_missing")return null;throw n}};async function G(t){let e=Z(t);return await Promise.all(e.map(async([r,n])=>({product:await v(r),quantity:n})))}var tt=async(t,e)=>{let a=await it(t,e);if(!a)return null;let r=await G(a.metadata),{metadata:{shippingRateId:n}}=a,o=n&&await T(n);return{cart:a,lines:r.map(({product:i,quantity:s})=>i?{product:i,quantity:s}:null).filter(Boolean),shippingRate:o||null}},st=t=>t?t.cart.metadata?.taxCalculationId?t.cart.amount:(t.shippingRate?.fixed_amount?.amount??0)+t.lines.reduce((e,{product:a,quantity:r})=>e+(a.default_price?.unit_amount??0)*r,0):0,ct=["billingAddress.country","billingAddress.postalCode","billingAddress.state","taxId","shippingRateId"];function ut({oldCart:t,data:e,mergedMetadata:a,lines:r}){if(!process.env.ENABLE_STRIPE_TAX)return!1;let n=Date.now(),o=a.taxCalculationExp?Number.parseInt(a.taxCalculationExp)*1e3:null;if(!o||n>=o)return!0;let i=t.cart.metadata.netAmount||t.cart.amount,s=e.amount,l=ct.some(u=>!a[u]&&!t.cart.metadata[u]?!1:a[u]!==t.cart.metadata[u]),d=r.length!==t.lines.length||r.some(u=>{let y=t.lines.find(I=>I.product.id===u.product?.id);return u.product?.default_price.unit_amount!==y?.product.default_price.unit_amount||u.quantity!==y?.quantity});return s&&i!==s||l||d}var Yt=t=>x.object({name:x.string({required_error:t.nameRequired}).min(1,t.nameRequired),city:x.string({required_error:t.cityRequired}).min(1,t.cityRequired),country:x.string({required_error:t.countryRequired}).min(1,t.countryRequired),line1:x.string({required_error:t.line1Required}).min(1,t.line1Required),line2:x.string().optional().nullable().default(""),postalCode:x.string({required_error:t.postalCodeRequired}).min(1,t.postalCodeRequired),state:x.string().optional().nullable().default(""),phone:x.string().optional().nullable().default(""),taxId:x.string().optional().nullable().default("")}),dt=async({lineItems:t,billingAddress:e,cartId:a,shippingRateId:r,taxId:n})=>{if(!process.env.ENABLE_STRIPE_TAX)return null;let o=await m(),i=p({tags:["tax-calculations",`tax-calculations-${a}`],cache:"force-cache"});if(!e?.country)return null;let s=r?await T(r):null,l=typeof s?.tax_code=="string"?s.tax_code:s?.tax_code?.id,d=await lt(),f=g.StripeCurrency==="usd"||g.StripeCurrency==="cad"?"exclusive":"inclusive",h=d.defaults.tax_behavior==="inferred_by_currency"?f:d.defaults.tax_behavior??f;return d.defaults.tax_behavior||console.warn(`Tax behavior not set in Stripe settings. Inferring from currency ${g.StripeCurrency}: ${f}.`),await i.tax.calculations.create({expand:["line_items"],line_items:t.map(y=>({...y,tax_behavior:y.tax_behavior??h})),currency:g.StripeCurrency,shipping_cost:s?.active&&s?.fixed_amount?{amount:s.fixed_amount.amount,tax_behavior:s.tax_behavior==="inclusive"?"inclusive":s.tax_behavior==="exclusive"?"exclusive":h,tax_code:l??d.defaults.tax_code??void 0}:void 0,customer_details:{tax_ids:n?[{type:"eu_vat",value:n}]:void 0,address_source:"billing",address:{country:e.country,city:e?.city,line1:e?.line1,line2:e?.line2,postal_code:e?.postalCode,state:e?.state}}},{stripeAccount:o})},J={taxBreakdown0:"",taxBreakdown1:"",taxBreakdown2:"",taxBreakdown3:"",taxBreakdown4:"",taxBreakdown5:""},b=async({paymentIntentId:t,data:e,clearTaxCalculation:a})=>{let r=await m(),n=await tt(p,t);_(n,`Cart not found: ${t}`);let o=q.parse({...n.cart.metadata,...e.metadata}),i=await G(o),l=!a&&ut({oldCart:n,data:e,mergedMetadata:o,lines:i})?await dt({cartId:t,taxId:o.taxId??null,shippingRateId:o.shippingRateId??null,billingAddress:{country:o["billingAddress.country"]??"",city:o["billingAddress.city"]??"",line1:o["billingAddress.line1"]??"",line2:o["billingAddress.line2"]??"",name:o["billingAddress.name"]??"",postalCode:o["billingAddress.postalCode"]??"",state:o["billingAddress.state"]??""},lineItems:i.map(({product:u,quantity:y})=>{if(u?.default_price.unit_amount)return{product:u.id,reference:[u.metadata.slug,u.metadata.variant].filter(Boolean).join("-"),quantity:y,amount:u.default_price.unit_amount*y,tax_behavior:u.default_price.tax_behavior==="exclusive"?"exclusive":u.default_price.tax_behavior==="inclusive"?"inclusive":void 0,tax_code:u.tax_code?typeof u.tax_code=="string"?u.tax_code:u.tax_code.id:void 0}}).filter(Boolean)}):null,d=e.amount?e.amount.toString():null;if(l){let u=Object.fromEntries(l.tax_breakdown.map(w=>({taxType:w.tax_rate_details.tax_type,taxPercentage:w.tax_rate_details.percentage_decimal,taxAmount:w.amount})).map((w,et)=>[`taxBreakdown${et}`,JSON.stringify(w)]));return await p({tags:[],cache:"no-cache"}).paymentIntents.update(t,{...e,amount:l.amount_total,metadata:{...o,...d&&{netAmount:d},...J,...u,taxCalculationId:l.id,taxCalculationExp:l?.expires_at}},{stripeAccount:r})}return await p({tags:[],cache:"no-cache"}).paymentIntents.update(t,{...e,metadata:{...o,...d&&{netAmount:d},...a&&{...J,taxCalculationId:"",taxCalculationExp:""}}},{stripeAccount:r})},k={async create(t,{productId:e,cartId:a}){let r=await m(),n=t({cache:"no-cache"});try{let o=e?await v(e):null;return await n.paymentIntents.create({currency:g.StripeCurrency,amount:o?.default_price.unit_amount||$,automatic_payment_methods:{enabled:!0},metadata:{...o&&{[o.id]:"1"}}},{stripeAccount:r})}catch(o){throw console.error(o),o}},async get(t,{cartId:e}){let a=await m(),r=t({tags:["cart",`cart-${e}`],cache:"force-cache"});try{let n=await r.paymentIntents.retrieve(e,{expand:["payment_method"]},{stripeAccount:a});if(H.includes(n.status)){let o=Q(n);if(!o)return null;let i=await G(o.metadata),{metadata:{shippingRateId:s}}=o,l=s&&await T(s);return{cart:o,lines:i.map(({product:d,quantity:f})=>d?{product:d,quantity:f}:null).filter(Boolean),shippingRate:l||null}}}catch(n){if(console.error(n),n instanceof C.errors.StripeError&&n.code==="resource_missing")return null;throw n}},async add(t,{cartId:e,productId:a}){return(async({productId:n,cartId:o,operation:i,clearTaxCalculation:s})=>{let[l,d]=await Promise.all([v(n),tt(t,o)]);if(!l)throw new Error(`Product not found: ${n}`);if(!d)throw new Error(`Cart not found: ${o}`);if(g.StripeCurrency.toLowerCase()!==l.default_price.currency.toLowerCase())throw new Error(`Product currency ${l.default_price.currency} does not match cart currency ${g.StripeCurrency}`);let f=d.cart.metadata??{},y=R(f[n])+(i==="INCREASE"?1:-1);y<=0?f[n]="":f[n]=y.toString();let I=st(d)+(l.default_price.unit_amount??0);try{return await b({paymentIntentId:o,data:{metadata:f,amount:I||$},clearTaxCalculation:s})}catch(w){console.error(w)}finally{S(`cart-${o}`)}})({productId:a,cartId:e,operation:"INCREASE",clearTaxCalculation:!0})}},M=t=>t?t.cart.metadata?.taxCalculationId?t.cart.amount:(t.shippingRate?.fixed_amount?.amount??0)+pt(t):0,pt=t=>t?t.lines.reduce((e,{product:a,quantity:r})=>e+(a.default_price?.unit_amount??0)*r,0):0;async function Jt({productId:t,cartId:e,operation:a,clearTaxCalculation:r}){let[n,o]=await Promise.all([X(t),E(e)]);if(!n)throw new Error(`Product not found: ${t}`);if(!o)throw new Error(`Cart not found: ${e}`);if(g.StripeCurrency?.toLowerCase()!==n.default_price.currency.toLowerCase())throw new Error(`Product currency ${n.default_price.currency} does not match cart currency ${g.StripeCurrency}`);let i=o.cart.metadata??{},d=R(i[t])+(a==="INCREASE"?1:-1);d<=0?i[t]="":i[t]=d.toString();let f=M(o)+(n.default_price.unit_amount??0);try{return await b({paymentIntentId:e,data:{metadata:i,amount:f||$},clearTaxCalculation:r})}catch(h){console.error(h)}finally{S(`cart-${e}`)}}var Xt=async({cartId:t,taxId:e})=>{let a=await E(t);if(!a)throw new Error(`Cart not found: ${t}`);try{return await b({paymentIntentId:t,data:{metadata:{...a.cart.metadata,taxId:e}}})}catch(r){console.error(r)}finally{S(`cart-${t}`)}};async function Ht({cartId:t,shippingRateId:e}){let a=await E(t);if(!a)throw new Error(`Cart not found: ${t}`);let r=await T(e);if(!r)throw new Error(`Shipping rate not found: ${e}`);try{return await b({paymentIntentId:t,data:{metadata:{...a.cart.metadata,shippingRateId:e},amount:M({...a,shippingRate:r})}})}catch(n){console.error(n)}finally{S(`cart-${t}`)}}async function Zt({cartId:t,billingAddress:e}){if(!await E(t))throw new Error(`Cart not found: ${t}`);try{return await b({paymentIntentId:t,data:{metadata:{"billingAddress.name":e.name,"billingAddress.phone":e.phone,"billingAddress.city":e.city,"billingAddress.country":e.country,"billingAddress.line1":e.line1,"billingAddress.line2":e.line2??"","billingAddress.postalCode":e.postalCode,"billingAddress.state":e.state??""}}})}catch(r){console.error(r)}finally{S(`cart-${t}`)}}async function lt(){let t=await m();return await p({tags:["tax-settings"]}).tax.settings.retrieve({},{stripeAccount:t})}function te(t){return Object.entries(t??{}).filter(([e])=>e.startsWith("prod_")).map(([e,a])=>[e,R(a)]).filter(([,e])=>e&&Number.isFinite(e)&&e>0).length}export{at as StripeClient,Dt as accountGet,st as calculateCartTotalNet,pt as calculateCartTotalNetWithoutShipping,M as calculateCartTotalPossiblyWithTax,Lt as cartAdd,jt as cartAddOptimistic,Jt as cartChangeQuantity,te as cartCount,Ot as cartCreate,E as cartGet,Zt as cartSaveBillingAddress,Ht as cartSaveShipping,Xt as cartSaveTax,Qt as cartSetQuantity,Wt as categoryBrowse,zt as fileGet,Yt as getAddressSchema,tt as getCartWithProductsById,Z as getProductsFromCart,Kt as orderGet,nt as productBrowse,Gt as productGet,X as productGetById,Vt as productSearch,p as provider,Ut as shippingBrowse,T as shippingGet,lt as taxDefaultGet};
|
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
import Stripe from 'stripe';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
declare const sanitizeQueryValue: (slug: string | number | boolean) => string;
|
|
5
|
+
declare const objectToStripeQuery: (obj: Record<string, string | number | boolean>) => string;
|
|
6
|
+
|
|
7
|
+
type MappedProduct = ReturnType<typeof mapProduct>;
|
|
8
|
+
/**
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
declare function sortProducts(products: MappedProduct[]): {
|
|
12
|
+
default_price: Stripe.Price;
|
|
13
|
+
marketing_features: string[];
|
|
14
|
+
metadata: {
|
|
15
|
+
slug: string;
|
|
16
|
+
category?: string | undefined;
|
|
17
|
+
order?: number | undefined;
|
|
18
|
+
variant?: string | undefined;
|
|
19
|
+
};
|
|
20
|
+
id: string;
|
|
21
|
+
object: "product";
|
|
22
|
+
active: boolean;
|
|
23
|
+
created: number;
|
|
24
|
+
deleted?: void | undefined;
|
|
25
|
+
description: string | null;
|
|
26
|
+
images: Array<string>;
|
|
27
|
+
livemode: boolean;
|
|
28
|
+
name: string;
|
|
29
|
+
package_dimensions: Stripe.Product.PackageDimensions | null;
|
|
30
|
+
shippable: boolean | null;
|
|
31
|
+
statement_descriptor?: string | null;
|
|
32
|
+
tax_code: string | Stripe.TaxCode | null;
|
|
33
|
+
type: Stripe.Product.Type;
|
|
34
|
+
unit_label?: string | null;
|
|
35
|
+
updated: number;
|
|
36
|
+
url: string | null;
|
|
37
|
+
}[];
|
|
38
|
+
declare const productMetadataSchema: z.ZodObject<{
|
|
39
|
+
category: z.ZodOptional<z.ZodString>;
|
|
40
|
+
order: z.ZodOptional<z.ZodNumber>;
|
|
41
|
+
slug: z.ZodString;
|
|
42
|
+
variant: z.ZodOptional<z.ZodString>;
|
|
43
|
+
}, "strip", z.ZodTypeAny, {
|
|
44
|
+
slug: string;
|
|
45
|
+
category?: string | undefined;
|
|
46
|
+
order?: number | undefined;
|
|
47
|
+
variant?: string | undefined;
|
|
48
|
+
}, {
|
|
49
|
+
slug: string;
|
|
50
|
+
category?: string | undefined;
|
|
51
|
+
order?: number | undefined;
|
|
52
|
+
variant?: string | undefined;
|
|
53
|
+
}>;
|
|
54
|
+
type ProductMetadata = z.infer<typeof productMetadataSchema>;
|
|
55
|
+
/**
|
|
56
|
+
* @internal
|
|
57
|
+
*/
|
|
58
|
+
declare function mapProduct({ default_price, marketing_features, ...product }: Stripe.Product): {
|
|
59
|
+
default_price: Stripe.Price;
|
|
60
|
+
marketing_features: string[];
|
|
61
|
+
metadata: {
|
|
62
|
+
slug: string;
|
|
63
|
+
category?: string | undefined;
|
|
64
|
+
order?: number | undefined;
|
|
65
|
+
variant?: string | undefined;
|
|
66
|
+
};
|
|
67
|
+
id: string;
|
|
68
|
+
object: "product";
|
|
69
|
+
active: boolean;
|
|
70
|
+
created: number;
|
|
71
|
+
deleted?: void | undefined;
|
|
72
|
+
description: string | null;
|
|
73
|
+
images: Array<string>;
|
|
74
|
+
livemode: boolean;
|
|
75
|
+
name: string;
|
|
76
|
+
package_dimensions: Stripe.Product.PackageDimensions | null;
|
|
77
|
+
shippable: boolean | null;
|
|
78
|
+
statement_descriptor?: string | null;
|
|
79
|
+
tax_code: string | Stripe.TaxCode | null;
|
|
80
|
+
type: Stripe.Product.Type;
|
|
81
|
+
unit_label?: string | null;
|
|
82
|
+
updated: number;
|
|
83
|
+
url: string | null;
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* @internal
|
|
87
|
+
*/
|
|
88
|
+
declare function mapProducts(products: Stripe.Response<Stripe.ApiSearchResult<Stripe.Product> | Stripe.ApiList<Stripe.Product>>): {
|
|
89
|
+
default_price: Stripe.Price;
|
|
90
|
+
marketing_features: string[];
|
|
91
|
+
metadata: {
|
|
92
|
+
slug: string;
|
|
93
|
+
category?: string | undefined;
|
|
94
|
+
order?: number | undefined;
|
|
95
|
+
variant?: string | undefined;
|
|
96
|
+
};
|
|
97
|
+
id: string;
|
|
98
|
+
object: "product";
|
|
99
|
+
active: boolean;
|
|
100
|
+
created: number;
|
|
101
|
+
deleted?: void | undefined;
|
|
102
|
+
description: string | null;
|
|
103
|
+
images: Array<string>;
|
|
104
|
+
livemode: boolean;
|
|
105
|
+
name: string;
|
|
106
|
+
package_dimensions: Stripe.Product.PackageDimensions | null;
|
|
107
|
+
shippable: boolean | null;
|
|
108
|
+
statement_descriptor?: string | null;
|
|
109
|
+
tax_code: string | Stripe.TaxCode | null;
|
|
110
|
+
type: Stripe.Product.Type;
|
|
111
|
+
unit_label?: string | null;
|
|
112
|
+
updated: number;
|
|
113
|
+
url: string | null;
|
|
114
|
+
}[];
|
|
115
|
+
/**
|
|
116
|
+
* @internal
|
|
117
|
+
*/
|
|
118
|
+
declare function getUniqueVariants(products: MappedProduct[]): {
|
|
119
|
+
default_price: Stripe.Price;
|
|
120
|
+
marketing_features: string[];
|
|
121
|
+
metadata: {
|
|
122
|
+
slug: string;
|
|
123
|
+
category?: string | undefined;
|
|
124
|
+
order?: number | undefined;
|
|
125
|
+
variant?: string | undefined;
|
|
126
|
+
};
|
|
127
|
+
id: string;
|
|
128
|
+
object: "product";
|
|
129
|
+
active: boolean;
|
|
130
|
+
created: number;
|
|
131
|
+
deleted?: void | undefined;
|
|
132
|
+
description: string | null;
|
|
133
|
+
images: Array<string>;
|
|
134
|
+
livemode: boolean;
|
|
135
|
+
name: string;
|
|
136
|
+
package_dimensions: Stripe.Product.PackageDimensions | null;
|
|
137
|
+
shippable: boolean | null;
|
|
138
|
+
statement_descriptor?: string | null;
|
|
139
|
+
tax_code: string | Stripe.TaxCode | null;
|
|
140
|
+
type: Stripe.Product.Type;
|
|
141
|
+
unit_label?: string | null;
|
|
142
|
+
updated: number;
|
|
143
|
+
url: string | null;
|
|
144
|
+
}[];
|
|
145
|
+
/**
|
|
146
|
+
* @internal
|
|
147
|
+
*/
|
|
148
|
+
declare const isProductAvailable: (product: MappedProduct) => boolean;
|
|
149
|
+
/**
|
|
150
|
+
* @internal
|
|
151
|
+
*/
|
|
152
|
+
declare const cartMetadataSchema: z.ZodIntersection<z.ZodObject<{
|
|
153
|
+
shippingRateId: z.ZodOptional<z.ZodString>;
|
|
154
|
+
taxCalculationId: z.ZodOptional<z.ZodString>;
|
|
155
|
+
taxCalculationExp: z.ZodOptional<z.ZodString>;
|
|
156
|
+
taxId: z.ZodOptional<z.ZodString>;
|
|
157
|
+
"billingAddress.city": z.ZodOptional<z.ZodString>;
|
|
158
|
+
"billingAddress.country": z.ZodOptional<z.ZodString>;
|
|
159
|
+
"billingAddress.line1": z.ZodOptional<z.ZodString>;
|
|
160
|
+
"billingAddress.line2": z.ZodOptional<z.ZodString>;
|
|
161
|
+
"billingAddress.name": z.ZodOptional<z.ZodString>;
|
|
162
|
+
"billingAddress.postalCode": z.ZodOptional<z.ZodString>;
|
|
163
|
+
"billingAddress.state": z.ZodOptional<z.ZodString>;
|
|
164
|
+
netAmount: z.ZodOptional<z.ZodString>;
|
|
165
|
+
taxBreakdown0: z.ZodOptional<z.ZodString>;
|
|
166
|
+
taxBreakdown1: z.ZodOptional<z.ZodString>;
|
|
167
|
+
taxBreakdown2: z.ZodOptional<z.ZodString>;
|
|
168
|
+
taxBreakdown3: z.ZodOptional<z.ZodString>;
|
|
169
|
+
taxBreakdown4: z.ZodOptional<z.ZodString>;
|
|
170
|
+
taxBreakdown5: z.ZodOptional<z.ZodString>;
|
|
171
|
+
}, "strip", z.ZodTypeAny, {
|
|
172
|
+
shippingRateId?: string | undefined;
|
|
173
|
+
taxCalculationId?: string | undefined;
|
|
174
|
+
taxCalculationExp?: string | undefined;
|
|
175
|
+
taxId?: string | undefined;
|
|
176
|
+
"billingAddress.city"?: string | undefined;
|
|
177
|
+
"billingAddress.country"?: string | undefined;
|
|
178
|
+
"billingAddress.line1"?: string | undefined;
|
|
179
|
+
"billingAddress.line2"?: string | undefined;
|
|
180
|
+
"billingAddress.name"?: string | undefined;
|
|
181
|
+
"billingAddress.postalCode"?: string | undefined;
|
|
182
|
+
"billingAddress.state"?: string | undefined;
|
|
183
|
+
netAmount?: string | undefined;
|
|
184
|
+
taxBreakdown0?: string | undefined;
|
|
185
|
+
taxBreakdown1?: string | undefined;
|
|
186
|
+
taxBreakdown2?: string | undefined;
|
|
187
|
+
taxBreakdown3?: string | undefined;
|
|
188
|
+
taxBreakdown4?: string | undefined;
|
|
189
|
+
taxBreakdown5?: string | undefined;
|
|
190
|
+
}, {
|
|
191
|
+
shippingRateId?: string | undefined;
|
|
192
|
+
taxCalculationId?: string | undefined;
|
|
193
|
+
taxCalculationExp?: string | undefined;
|
|
194
|
+
taxId?: string | undefined;
|
|
195
|
+
"billingAddress.city"?: string | undefined;
|
|
196
|
+
"billingAddress.country"?: string | undefined;
|
|
197
|
+
"billingAddress.line1"?: string | undefined;
|
|
198
|
+
"billingAddress.line2"?: string | undefined;
|
|
199
|
+
"billingAddress.name"?: string | undefined;
|
|
200
|
+
"billingAddress.postalCode"?: string | undefined;
|
|
201
|
+
"billingAddress.state"?: string | undefined;
|
|
202
|
+
netAmount?: string | undefined;
|
|
203
|
+
taxBreakdown0?: string | undefined;
|
|
204
|
+
taxBreakdown1?: string | undefined;
|
|
205
|
+
taxBreakdown2?: string | undefined;
|
|
206
|
+
taxBreakdown3?: string | undefined;
|
|
207
|
+
taxBreakdown4?: string | undefined;
|
|
208
|
+
taxBreakdown5?: string | undefined;
|
|
209
|
+
}>, z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
210
|
+
type CartMetadata = z.infer<typeof cartMetadataSchema>;
|
|
211
|
+
/**
|
|
212
|
+
* @internal
|
|
213
|
+
*/
|
|
214
|
+
declare const cartMetadataTaxBreakdownSchema: z.ZodObject<{
|
|
215
|
+
taxType: z.ZodLiteral<Stripe.Tax.Calculation.TaxBreakdown.TaxRateDetails.TaxType | (string & {})>;
|
|
216
|
+
taxPercentage: z.ZodString;
|
|
217
|
+
taxAmount: z.ZodNumber;
|
|
218
|
+
}, "strip", z.ZodTypeAny, {
|
|
219
|
+
taxPercentage: string;
|
|
220
|
+
taxAmount: number;
|
|
221
|
+
taxType: Stripe.Tax.Calculation.TaxBreakdown.TaxRateDetails.TaxType | (string & {});
|
|
222
|
+
}, {
|
|
223
|
+
taxPercentage: string;
|
|
224
|
+
taxAmount: number;
|
|
225
|
+
taxType: Stripe.Tax.Calculation.TaxBreakdown.TaxRateDetails.TaxType | (string & {});
|
|
226
|
+
}>;
|
|
227
|
+
/**
|
|
228
|
+
* @internal
|
|
229
|
+
*/
|
|
230
|
+
declare function mapCart(cart: Stripe.PaymentIntent): {
|
|
231
|
+
metadata: {
|
|
232
|
+
shippingRateId?: string | undefined;
|
|
233
|
+
taxCalculationId?: string | undefined;
|
|
234
|
+
taxCalculationExp?: string | undefined;
|
|
235
|
+
taxId?: string | undefined;
|
|
236
|
+
"billingAddress.city"?: string | undefined;
|
|
237
|
+
"billingAddress.country"?: string | undefined;
|
|
238
|
+
"billingAddress.line1"?: string | undefined;
|
|
239
|
+
"billingAddress.line2"?: string | undefined;
|
|
240
|
+
"billingAddress.name"?: string | undefined;
|
|
241
|
+
"billingAddress.postalCode"?: string | undefined;
|
|
242
|
+
"billingAddress.state"?: string | undefined;
|
|
243
|
+
netAmount?: string | undefined;
|
|
244
|
+
taxBreakdown0?: string | undefined;
|
|
245
|
+
taxBreakdown1?: string | undefined;
|
|
246
|
+
taxBreakdown2?: string | undefined;
|
|
247
|
+
taxBreakdown3?: string | undefined;
|
|
248
|
+
taxBreakdown4?: string | undefined;
|
|
249
|
+
taxBreakdown5?: string | undefined;
|
|
250
|
+
} & Record<string, string>;
|
|
251
|
+
payment_method: Stripe.PaymentMethod | null;
|
|
252
|
+
taxBreakdown: {
|
|
253
|
+
taxPercentage: string;
|
|
254
|
+
taxAmount: number;
|
|
255
|
+
taxType: Stripe.Tax.Calculation.TaxBreakdown.TaxRateDetails.TaxType | (string & {});
|
|
256
|
+
}[];
|
|
257
|
+
id: string;
|
|
258
|
+
object: "payment_intent";
|
|
259
|
+
amount: number;
|
|
260
|
+
amount_capturable: number;
|
|
261
|
+
amount_details?: Stripe.PaymentIntent.AmountDetails;
|
|
262
|
+
amount_received: number;
|
|
263
|
+
application: string | Stripe.Application | null;
|
|
264
|
+
application_fee_amount: number | null;
|
|
265
|
+
automatic_payment_methods: Stripe.PaymentIntent.AutomaticPaymentMethods | null;
|
|
266
|
+
canceled_at: number | null;
|
|
267
|
+
cancellation_reason: Stripe.PaymentIntent.CancellationReason | null;
|
|
268
|
+
capture_method: Stripe.PaymentIntent.CaptureMethod;
|
|
269
|
+
client_secret: string | null;
|
|
270
|
+
confirmation_method: Stripe.PaymentIntent.ConfirmationMethod;
|
|
271
|
+
created: number;
|
|
272
|
+
currency: string;
|
|
273
|
+
customer: string | Stripe.Customer | Stripe.DeletedCustomer | null;
|
|
274
|
+
description: string | null;
|
|
275
|
+
invoice: string | Stripe.Invoice | null;
|
|
276
|
+
last_payment_error: Stripe.PaymentIntent.LastPaymentError | null;
|
|
277
|
+
latest_charge: string | Stripe.Charge | null;
|
|
278
|
+
livemode: boolean;
|
|
279
|
+
next_action: Stripe.PaymentIntent.NextAction | null;
|
|
280
|
+
on_behalf_of: string | Stripe.Account | null;
|
|
281
|
+
payment_method_configuration_details: Stripe.PaymentIntent.PaymentMethodConfigurationDetails | null;
|
|
282
|
+
payment_method_options: Stripe.PaymentIntent.PaymentMethodOptions | null;
|
|
283
|
+
payment_method_types: Array<string>;
|
|
284
|
+
processing: Stripe.PaymentIntent.Processing | null;
|
|
285
|
+
receipt_email: string | null;
|
|
286
|
+
review: string | Stripe.Review | null;
|
|
287
|
+
setup_future_usage: Stripe.PaymentIntent.SetupFutureUsage | null;
|
|
288
|
+
shipping: Stripe.PaymentIntent.Shipping | null;
|
|
289
|
+
source: string | Stripe.CustomerSource | Stripe.DeletedCustomerSource | null;
|
|
290
|
+
statement_descriptor: string | null;
|
|
291
|
+
statement_descriptor_suffix: string | null;
|
|
292
|
+
status: Stripe.PaymentIntent.Status;
|
|
293
|
+
transfer_data: Stripe.PaymentIntent.TransferData | null;
|
|
294
|
+
transfer_group: string | null;
|
|
295
|
+
};
|
|
296
|
+
/**
|
|
297
|
+
* @internal
|
|
298
|
+
*/
|
|
299
|
+
declare function mapOrder({ payment_method, latest_charge, ...order }: Stripe.PaymentIntent): {
|
|
300
|
+
payment_method: Stripe.PaymentMethod | null;
|
|
301
|
+
latest_charge: Stripe.Charge | null;
|
|
302
|
+
taxBreakdown: {
|
|
303
|
+
taxPercentage: string;
|
|
304
|
+
taxAmount: number;
|
|
305
|
+
taxType: Stripe.Tax.Calculation.TaxBreakdown.TaxRateDetails.TaxType | (string & {});
|
|
306
|
+
}[];
|
|
307
|
+
metadata: {
|
|
308
|
+
shippingRateId?: string | undefined;
|
|
309
|
+
taxCalculationId?: string | undefined;
|
|
310
|
+
taxCalculationExp?: string | undefined;
|
|
311
|
+
taxId?: string | undefined;
|
|
312
|
+
"billingAddress.city"?: string | undefined;
|
|
313
|
+
"billingAddress.country"?: string | undefined;
|
|
314
|
+
"billingAddress.line1"?: string | undefined;
|
|
315
|
+
"billingAddress.line2"?: string | undefined;
|
|
316
|
+
"billingAddress.name"?: string | undefined;
|
|
317
|
+
"billingAddress.postalCode"?: string | undefined;
|
|
318
|
+
"billingAddress.state"?: string | undefined;
|
|
319
|
+
netAmount?: string | undefined;
|
|
320
|
+
taxBreakdown0?: string | undefined;
|
|
321
|
+
taxBreakdown1?: string | undefined;
|
|
322
|
+
taxBreakdown2?: string | undefined;
|
|
323
|
+
taxBreakdown3?: string | undefined;
|
|
324
|
+
taxBreakdown4?: string | undefined;
|
|
325
|
+
taxBreakdown5?: string | undefined;
|
|
326
|
+
} & Record<string, string>;
|
|
327
|
+
id: string;
|
|
328
|
+
object: "payment_intent";
|
|
329
|
+
amount: number;
|
|
330
|
+
amount_capturable: number;
|
|
331
|
+
amount_details?: Stripe.PaymentIntent.AmountDetails;
|
|
332
|
+
amount_received: number;
|
|
333
|
+
application: string | Stripe.Application | null;
|
|
334
|
+
application_fee_amount: number | null;
|
|
335
|
+
automatic_payment_methods: Stripe.PaymentIntent.AutomaticPaymentMethods | null;
|
|
336
|
+
canceled_at: number | null;
|
|
337
|
+
cancellation_reason: Stripe.PaymentIntent.CancellationReason | null;
|
|
338
|
+
capture_method: Stripe.PaymentIntent.CaptureMethod;
|
|
339
|
+
client_secret: string | null;
|
|
340
|
+
confirmation_method: Stripe.PaymentIntent.ConfirmationMethod;
|
|
341
|
+
created: number;
|
|
342
|
+
currency: string;
|
|
343
|
+
customer: string | Stripe.Customer | Stripe.DeletedCustomer | null;
|
|
344
|
+
description: string | null;
|
|
345
|
+
invoice: string | Stripe.Invoice | null;
|
|
346
|
+
last_payment_error: Stripe.PaymentIntent.LastPaymentError | null;
|
|
347
|
+
livemode: boolean;
|
|
348
|
+
next_action: Stripe.PaymentIntent.NextAction | null;
|
|
349
|
+
on_behalf_of: string | Stripe.Account | null;
|
|
350
|
+
payment_method_configuration_details: Stripe.PaymentIntent.PaymentMethodConfigurationDetails | null;
|
|
351
|
+
payment_method_options: Stripe.PaymentIntent.PaymentMethodOptions | null;
|
|
352
|
+
payment_method_types: Array<string>;
|
|
353
|
+
processing: Stripe.PaymentIntent.Processing | null;
|
|
354
|
+
receipt_email: string | null;
|
|
355
|
+
review: string | Stripe.Review | null;
|
|
356
|
+
setup_future_usage: Stripe.PaymentIntent.SetupFutureUsage | null;
|
|
357
|
+
shipping: Stripe.PaymentIntent.Shipping | null;
|
|
358
|
+
source: string | Stripe.CustomerSource | Stripe.DeletedCustomerSource | null;
|
|
359
|
+
statement_descriptor: string | null;
|
|
360
|
+
statement_descriptor_suffix: string | null;
|
|
361
|
+
status: Stripe.PaymentIntent.Status;
|
|
362
|
+
transfer_data: Stripe.PaymentIntent.TransferData | null;
|
|
363
|
+
transfer_group: string | null;
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
export { type CartMetadata, type MappedProduct, type ProductMetadata, cartMetadataSchema, cartMetadataTaxBreakdownSchema, getUniqueVariants, isProductAvailable, mapCart, mapOrder, mapProduct, mapProducts, objectToStripeQuery, sanitizeQueryValue, sortProducts };
|
package/dist/internal.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"server-only";import{z as t}from"zod";function i(e,r){if(!e)throw new Error(r)}var p=e=>{if(e==null)return null;try{return JSON.parse(e)}catch{return null}};var m=e=>e.toString().replace(/"/g,'\\"'),b=e=>Object.entries(e).map(([r,n])=>`${r}:"${m(n)}"`).join(" AND ").trim();function k(e){return e.toSorted((r,n)=>{let a=Number(r.metadata.order),o=Number(n.metadata.order);return Number.isNaN(a)&&Number.isNaN(o)||a===o?n.updated-r.updated:Number.isNaN(a)?1:Number.isNaN(o)?-1:a-o})}var g=t.object({category:t.string().optional(),order:t.coerce.number().optional(),slug:t.string(),variant:t.string().optional()});function f({default_price:e,marketing_features:r,...n}){return i(e,"Product must have a default price"),i(typeof e=="object","Product default price must be an object"),{...n,default_price:e,marketing_features:r.map(a=>a.name).filter(Boolean),metadata:g.parse(n.metadata)}}function N(e){return e.data.map(f)}function T(e){return e.filter((r,n,a)=>n===a.findIndex(o=>o.metadata.slug===r.metadata.slug))}var B=e=>!e.deleted&&e.active,l=t.object({shippingRateId:t.string().optional(),taxCalculationId:t.string().optional(),taxCalculationExp:t.string().optional(),taxId:t.string().optional(),"billingAddress.city":t.string().optional(),"billingAddress.country":t.string().optional(),"billingAddress.line1":t.string().optional(),"billingAddress.line2":t.string().optional(),"billingAddress.name":t.string().optional(),"billingAddress.postalCode":t.string().optional(),"billingAddress.state":t.string().optional(),netAmount:t.string().optional(),taxBreakdown0:t.string().optional(),taxBreakdown1:t.string().optional(),taxBreakdown2:t.string().optional(),taxBreakdown3:t.string().optional(),taxBreakdown4:t.string().optional(),taxBreakdown5:t.string().optional()}).and(t.record(t.string())),c=t.object({taxType:t.string(),taxPercentage:t.string(),taxAmount:t.number()});function h(e){let r=e.payment_method;i(typeof r!="string","Payment method is missing from cart");let n=l.parse(e.metadata),a=Object.entries(n).filter(([o])=>o.startsWith("taxBreakdown")).map(([o,s])=>{let u=c.safeParse(p(String(s)));return u.success?u.data:null}).filter(Boolean);return{...e,metadata:n,payment_method:r,taxBreakdown:a}}function A({payment_method:e,latest_charge:r,...n}){i(typeof e=="object","Payment method is missing from order"),i(typeof r=="object","Latest charge is missing from order");let a=l.parse(n.metadata),o=Object.entries(a).filter(([s])=>s.startsWith("taxBreakdown")).map(([s,u])=>{let d=c.safeParse(p(String(u)));return d.success?d.data:null}).filter(Boolean);return{...n,payment_method:e,latest_charge:r,taxBreakdown:o,metadata:a}}export{l as cartMetadataSchema,c as cartMetadataTaxBreakdownSchema,T as getUniqueVariants,B as isProductAvailable,h as mapCart,A as mapOrder,f as mapProduct,N as mapProducts,b as objectToStripeQuery,m as sanitizeQueryValue,k as sortProducts};
|
package/package.json
CHANGED
|
@@ -1,9 +1,70 @@
|
|
|
1
1
|
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/package",
|
|
2
3
|
"name": "commerce-kit",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
"version": "0.0.6",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": {
|
|
8
|
+
"name": "Your Next Store",
|
|
9
|
+
"email": "hi@yournextstore.com",
|
|
10
|
+
"url": "https://yournextstore.com"
|
|
11
|
+
},
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"import": "./dist/index.js",
|
|
15
|
+
"types": "./dist/index.d.ts"
|
|
16
|
+
},
|
|
17
|
+
"./currencies": {
|
|
18
|
+
"import": "./dist/currencies.js",
|
|
19
|
+
"types": "./dist/currencies.d.ts"
|
|
20
|
+
},
|
|
21
|
+
"./internal": {
|
|
22
|
+
"import": "./dist/internal.js",
|
|
23
|
+
"types": "./dist/internal.d.ts"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"package.json",
|
|
28
|
+
"dist",
|
|
29
|
+
"README.md",
|
|
30
|
+
"LICENSE.md"
|
|
31
|
+
],
|
|
32
|
+
"sideEffects": false,
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@types/node": "^20.14.8",
|
|
35
|
+
"@types/react": "npm:types-react@19.0.0-rc.1",
|
|
36
|
+
"@types/react-dom": "npm:types-react-dom@19.0.0-rc.1",
|
|
37
|
+
"next": "15.0.0-canary.96",
|
|
38
|
+
"prettier": "3.3.3",
|
|
39
|
+
"react": "^19.0.0-rc.1",
|
|
40
|
+
"react-dom": "^19.0.0-rc.1",
|
|
41
|
+
"rimraf": "5.0.7",
|
|
42
|
+
"server-only": "0.0.1",
|
|
43
|
+
"stripe": "^16.5.0",
|
|
44
|
+
"tsup": "8.1.0",
|
|
45
|
+
"tsx": "^4.15.7",
|
|
46
|
+
"zod": "^3.23.8"
|
|
47
|
+
},
|
|
48
|
+
"peerDependencies": {
|
|
49
|
+
"@types/node": "^20.14.8",
|
|
50
|
+
"@types/react": "npm:types-react@19.0.0-rc.1",
|
|
51
|
+
"@types/react-dom": "npm:types-react-dom@19.0.0-rc.1",
|
|
52
|
+
"next": "15.0.0-canary.96",
|
|
53
|
+
"react": "19.0.0-rc-3208e73e-20240730",
|
|
54
|
+
"react-dom": "19.0.0-rc-3208e73e-20240730",
|
|
55
|
+
"server-only": "0.0.1",
|
|
56
|
+
"stripe": "^16.5.0",
|
|
57
|
+
"typescript": "^5.5.4",
|
|
58
|
+
"zod": "^3.23.8"
|
|
59
|
+
},
|
|
60
|
+
"peerDependencyRules": {
|
|
61
|
+
"allowedVersions": {
|
|
62
|
+
"react": "19.0.0-rc-3208e73e-20240730",
|
|
63
|
+
"react-dom": "19.0.0-rc-3208e73e-20240730"
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
"scripts": {
|
|
67
|
+
"build": "rimraf dist/* && tsup --config tsup.config.ts",
|
|
68
|
+
"dev": "tsup --config tsup.config.ts --watch"
|
|
69
|
+
}
|
|
9
70
|
}
|