commerce-kit 0.0.0 → 0.0.5

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 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 @@
1
+ # commerce-kit
@@ -0,0 +1,715 @@
1
+ import Stripe from 'stripe';
2
+ import { z, TypeOf } from 'zod';
3
+ import { CartMetadata, mapCart } from './internal.js';
4
+ export { MappedProduct } from './internal.js';
5
+
6
+ declare const findStripeAccount: () => string | Promise<string | undefined> | undefined;
7
+ type Entity = "Product" | "Category" | "Order";
8
+ type Provider = ({ tags, revalidate, cache, }: {
9
+ tags?: string[];
10
+ revalidate?: number;
11
+ cache?: RequestInit["cache"];
12
+ }) => Stripe;
13
+ type Filter<T extends Entity> = {
14
+ Product: {
15
+ category?: string;
16
+ };
17
+ Category: {};
18
+ Order: {};
19
+ }[T];
20
+ type BrowseParams<T extends Entity> = {
21
+ first?: number;
22
+ last?: number;
23
+ offset?: number;
24
+ filter?: Filter<T>;
25
+ };
26
+ type SearchParams<T extends Entity> = {
27
+ query: string;
28
+ };
29
+ type Cart = NonNullable<Awaited<ReturnType<typeof cartGet>>>;
30
+ declare function cartAdd({ productId, cartId }: {
31
+ productId: string;
32
+ cartId?: string;
33
+ }): Promise<Stripe.Response<Stripe.PaymentIntent> | undefined>;
34
+ declare function cartGet(cartId: string): Promise<{
35
+ cart: {
36
+ metadata: {
37
+ shippingRateId?: string | undefined;
38
+ taxCalculationId?: string | undefined;
39
+ taxCalculationExp?: string | undefined;
40
+ taxId?: string | undefined;
41
+ "billingAddress.city"?: string | undefined;
42
+ "billingAddress.country"?: string | undefined;
43
+ "billingAddress.line1"?: string | undefined;
44
+ "billingAddress.line2"?: string | undefined;
45
+ "billingAddress.name"?: string | undefined;
46
+ "billingAddress.postalCode"?: string | undefined;
47
+ "billingAddress.state"?: string | undefined;
48
+ netAmount?: string | undefined;
49
+ taxBreakdown0?: string | undefined;
50
+ taxBreakdown1?: string | undefined;
51
+ taxBreakdown2?: string | undefined;
52
+ taxBreakdown3?: string | undefined;
53
+ taxBreakdown4?: string | undefined;
54
+ taxBreakdown5?: string | undefined;
55
+ } & Record<string, string>;
56
+ payment_method: Stripe.PaymentMethod | null;
57
+ taxBreakdown: {
58
+ taxPercentage: string;
59
+ taxAmount: number;
60
+ taxType: Stripe.Tax.Calculation.TaxBreakdown.TaxRateDetails.TaxType | (string & {});
61
+ }[];
62
+ id: string;
63
+ object: "payment_intent";
64
+ amount: number;
65
+ amount_capturable: number;
66
+ amount_details?: Stripe.PaymentIntent.AmountDetails;
67
+ amount_received: number;
68
+ application: string | Stripe.Application | null;
69
+ application_fee_amount: number | null;
70
+ automatic_payment_methods: Stripe.PaymentIntent.AutomaticPaymentMethods | null;
71
+ canceled_at: number | null;
72
+ cancellation_reason: Stripe.PaymentIntent.CancellationReason | null;
73
+ capture_method: Stripe.PaymentIntent.CaptureMethod;
74
+ client_secret: string | null;
75
+ confirmation_method: Stripe.PaymentIntent.ConfirmationMethod;
76
+ created: number;
77
+ currency: string;
78
+ customer: string | Stripe.Customer | Stripe.DeletedCustomer | null;
79
+ description: string | null;
80
+ invoice: string | Stripe.Invoice | null;
81
+ last_payment_error: Stripe.PaymentIntent.LastPaymentError | null;
82
+ latest_charge: string | Stripe.Charge | null;
83
+ livemode: boolean;
84
+ next_action: Stripe.PaymentIntent.NextAction | null;
85
+ on_behalf_of: string | Stripe.Account | null;
86
+ payment_method_configuration_details: Stripe.PaymentIntent.PaymentMethodConfigurationDetails | null;
87
+ payment_method_options: Stripe.PaymentIntent.PaymentMethodOptions | null;
88
+ payment_method_types: Array<string>;
89
+ processing: Stripe.PaymentIntent.Processing | null;
90
+ receipt_email: string | null;
91
+ review: string | Stripe.Review | null;
92
+ setup_future_usage: Stripe.PaymentIntent.SetupFutureUsage | null;
93
+ shipping: Stripe.PaymentIntent.Shipping | null;
94
+ source: string | Stripe.CustomerSource | Stripe.DeletedCustomerSource | null;
95
+ statement_descriptor: string | null;
96
+ statement_descriptor_suffix: string | null;
97
+ status: Stripe.PaymentIntent.Status;
98
+ transfer_data: Stripe.PaymentIntent.TransferData | null;
99
+ transfer_group: string | null;
100
+ };
101
+ lines: {
102
+ product: {
103
+ default_price: Stripe.Price;
104
+ marketing_features: string[];
105
+ metadata: {
106
+ slug: string;
107
+ category?: string | undefined;
108
+ order?: number | undefined;
109
+ variant?: string | undefined;
110
+ };
111
+ id: string;
112
+ object: "product";
113
+ active: boolean;
114
+ created: number;
115
+ deleted?: void | undefined;
116
+ description: string | null;
117
+ images: Array<string>;
118
+ livemode: boolean;
119
+ name: string;
120
+ package_dimensions: Stripe.Product.PackageDimensions | null;
121
+ shippable: boolean | null;
122
+ statement_descriptor?: string | null;
123
+ tax_code: string | Stripe.TaxCode | null;
124
+ type: Stripe.Product.Type;
125
+ unit_label?: string | null;
126
+ updated: number;
127
+ url: string | null;
128
+ };
129
+ quantity: number;
130
+ }[];
131
+ shippingRate: Stripe.Response<Stripe.ShippingRate> | null;
132
+ } | null | undefined>;
133
+ declare function cartCreate(): Promise<Stripe.Response<Stripe.PaymentIntent>>;
134
+ declare function cartAddOptimistic({ cart, add }: {
135
+ cart: Cart;
136
+ add: string | undefined;
137
+ }): Promise<{
138
+ cart: {
139
+ metadata: {
140
+ shippingRateId?: string | undefined;
141
+ taxCalculationId?: string | undefined;
142
+ taxCalculationExp?: string | undefined;
143
+ taxId?: string | undefined;
144
+ "billingAddress.city"?: string | undefined;
145
+ "billingAddress.country"?: string | undefined;
146
+ "billingAddress.line1"?: string | undefined;
147
+ "billingAddress.line2"?: string | undefined;
148
+ "billingAddress.name"?: string | undefined;
149
+ "billingAddress.postalCode"?: string | undefined;
150
+ "billingAddress.state"?: string | undefined;
151
+ netAmount?: string | undefined;
152
+ taxBreakdown0?: string | undefined;
153
+ taxBreakdown1?: string | undefined;
154
+ taxBreakdown2?: string | undefined;
155
+ taxBreakdown3?: string | undefined;
156
+ taxBreakdown4?: string | undefined;
157
+ taxBreakdown5?: string | undefined;
158
+ } & Record<string, string>;
159
+ payment_method: Stripe.PaymentMethod | null;
160
+ taxBreakdown: {
161
+ taxPercentage: string;
162
+ taxAmount: number;
163
+ taxType: Stripe.Tax.Calculation.TaxBreakdown.TaxRateDetails.TaxType | (string & {});
164
+ }[];
165
+ id: string;
166
+ object: "payment_intent";
167
+ amount: number;
168
+ amount_capturable: number;
169
+ amount_details?: Stripe.PaymentIntent.AmountDetails;
170
+ amount_received: number;
171
+ application: string | Stripe.Application | null;
172
+ application_fee_amount: number | null;
173
+ automatic_payment_methods: Stripe.PaymentIntent.AutomaticPaymentMethods | null;
174
+ canceled_at: number | null;
175
+ cancellation_reason: Stripe.PaymentIntent.CancellationReason | null;
176
+ capture_method: Stripe.PaymentIntent.CaptureMethod;
177
+ client_secret: string | null;
178
+ confirmation_method: Stripe.PaymentIntent.ConfirmationMethod;
179
+ created: number;
180
+ currency: string;
181
+ customer: string | Stripe.Customer | Stripe.DeletedCustomer | null;
182
+ description: string | null;
183
+ invoice: string | Stripe.Invoice | null;
184
+ last_payment_error: Stripe.PaymentIntent.LastPaymentError | null;
185
+ latest_charge: string | Stripe.Charge | null;
186
+ livemode: boolean;
187
+ next_action: Stripe.PaymentIntent.NextAction | null;
188
+ on_behalf_of: string | Stripe.Account | null;
189
+ payment_method_configuration_details: Stripe.PaymentIntent.PaymentMethodConfigurationDetails | null;
190
+ payment_method_options: Stripe.PaymentIntent.PaymentMethodOptions | null;
191
+ payment_method_types: Array<string>;
192
+ processing: Stripe.PaymentIntent.Processing | null;
193
+ receipt_email: string | null;
194
+ review: string | Stripe.Review | null;
195
+ setup_future_usage: Stripe.PaymentIntent.SetupFutureUsage | null;
196
+ shipping: Stripe.PaymentIntent.Shipping | null;
197
+ source: string | Stripe.CustomerSource | Stripe.DeletedCustomerSource | null;
198
+ statement_descriptor: string | null;
199
+ statement_descriptor_suffix: string | null;
200
+ status: Stripe.PaymentIntent.Status;
201
+ transfer_data: Stripe.PaymentIntent.TransferData | null;
202
+ transfer_group: string | null;
203
+ };
204
+ lines: {
205
+ product: {
206
+ default_price: Stripe.Price;
207
+ marketing_features: string[];
208
+ metadata: {
209
+ slug: string;
210
+ category?: string | undefined;
211
+ order?: number | undefined;
212
+ variant?: string | undefined;
213
+ };
214
+ id: string;
215
+ object: "product";
216
+ active: boolean;
217
+ created: number;
218
+ deleted?: void | undefined;
219
+ description: string | null;
220
+ images: Array<string>;
221
+ livemode: boolean;
222
+ name: string;
223
+ package_dimensions: Stripe.Product.PackageDimensions | null;
224
+ shippable: boolean | null;
225
+ statement_descriptor?: string | null;
226
+ tax_code: string | Stripe.TaxCode | null;
227
+ type: Stripe.Product.Type;
228
+ unit_label?: string | null;
229
+ updated: number;
230
+ url: string | null;
231
+ };
232
+ quantity: number;
233
+ }[];
234
+ shippingRate: Stripe.Response<Stripe.ShippingRate> | null;
235
+ }>;
236
+ declare function cartSetQuantity({ cartId, productId, quantity, }: {
237
+ cartId: string;
238
+ productId: string;
239
+ quantity: number;
240
+ }): Promise<Stripe.Response<Stripe.PaymentIntent> | undefined>;
241
+ declare function productGetById(id: string): Promise<{
242
+ default_price: Stripe.Price;
243
+ marketing_features: string[];
244
+ metadata: {
245
+ slug: string;
246
+ category?: string | undefined;
247
+ order?: number | undefined;
248
+ variant?: string | undefined;
249
+ };
250
+ id: string;
251
+ object: "product";
252
+ active: boolean;
253
+ created: number;
254
+ deleted?: void | undefined;
255
+ description: string | null;
256
+ images: Array<string>;
257
+ livemode: boolean;
258
+ name: string;
259
+ package_dimensions: Stripe.Product.PackageDimensions | null;
260
+ shippable: boolean | null;
261
+ statement_descriptor?: string | null;
262
+ tax_code: string | Stripe.TaxCode | null;
263
+ type: Stripe.Product.Type;
264
+ unit_label?: string | null;
265
+ updated: number;
266
+ url: string | null;
267
+ } | null>;
268
+ declare function productGet({ slug }: {
269
+ slug: string;
270
+ }): Promise<{
271
+ default_price: Stripe.Price;
272
+ marketing_features: string[];
273
+ metadata: {
274
+ slug: string;
275
+ category?: string | undefined;
276
+ order?: number | undefined;
277
+ variant?: string | undefined;
278
+ };
279
+ id: string;
280
+ object: "product";
281
+ active: boolean;
282
+ created: number;
283
+ deleted?: void | undefined;
284
+ description: string | null;
285
+ images: Array<string>;
286
+ livemode: boolean;
287
+ name: string;
288
+ package_dimensions: Stripe.Product.PackageDimensions | null;
289
+ shippable: boolean | null;
290
+ statement_descriptor?: string | null;
291
+ tax_code: string | Stripe.TaxCode | null;
292
+ type: Stripe.Product.Type;
293
+ unit_label?: string | null;
294
+ updated: number;
295
+ url: string | null;
296
+ }[]>;
297
+ declare function productBrowse(params: BrowseParams<"Product">): Promise<{
298
+ default_price: Stripe.Price;
299
+ marketing_features: string[];
300
+ metadata: {
301
+ slug: string;
302
+ category?: string | undefined;
303
+ order?: number | undefined;
304
+ variant?: string | undefined;
305
+ };
306
+ id: string;
307
+ object: "product";
308
+ active: boolean;
309
+ created: number;
310
+ deleted?: void | undefined;
311
+ description: string | null;
312
+ images: Array<string>;
313
+ livemode: boolean;
314
+ name: string;
315
+ package_dimensions: Stripe.Product.PackageDimensions | null;
316
+ shippable: boolean | null;
317
+ statement_descriptor?: string | null;
318
+ tax_code: string | Stripe.TaxCode | null;
319
+ type: Stripe.Product.Type;
320
+ unit_label?: string | null;
321
+ updated: number;
322
+ url: string | null;
323
+ }[]>;
324
+ type ShippingRate = Awaited<ReturnType<typeof shippingBrowse>>["data"][0];
325
+ declare function shippingBrowse(): Promise<Stripe.Response<Stripe.ApiList<Stripe.ShippingRate>>>;
326
+ declare function shippingGet(id: string): Promise<Stripe.Response<Stripe.ShippingRate> | null>;
327
+ declare function categoryBrowse(params: BrowseParams<"Category">): Promise<string[]>;
328
+ declare function productSearch(params: SearchParams<"Product">): Promise<{
329
+ default_price: Stripe.Price;
330
+ marketing_features: string[];
331
+ metadata: {
332
+ slug: string;
333
+ category?: string | undefined;
334
+ order?: number | undefined;
335
+ variant?: string | undefined;
336
+ };
337
+ id: string;
338
+ object: "product";
339
+ active: boolean;
340
+ created: number;
341
+ deleted?: void | undefined;
342
+ description: string | null;
343
+ images: Array<string>;
344
+ livemode: boolean;
345
+ name: string;
346
+ package_dimensions: Stripe.Product.PackageDimensions | null;
347
+ shippable: boolean | null;
348
+ statement_descriptor?: string | null;
349
+ tax_code: string | Stripe.TaxCode | null;
350
+ type: Stripe.Product.Type;
351
+ unit_label?: string | null;
352
+ updated: number;
353
+ url: string | null;
354
+ }[]>;
355
+ declare function fileGet(id: string): Promise<Stripe.Response<Stripe.FileLink> | null>;
356
+ declare function accountGet(): Promise<{
357
+ account: (Stripe.Account & {
358
+ lastResponse: {
359
+ headers: {
360
+ [key: string]: string;
361
+ };
362
+ requestId: string;
363
+ statusCode: number;
364
+ apiVersion?: string;
365
+ idempotencyKey?: string;
366
+ stripeAccount?: string;
367
+ };
368
+ }) | null;
369
+ logo: null;
370
+ } | {
371
+ account: (Stripe.Account & {
372
+ lastResponse: {
373
+ headers: {
374
+ [key: string]: string;
375
+ };
376
+ requestId: string;
377
+ statusCode: number;
378
+ apiVersion?: string;
379
+ idempotencyKey?: string;
380
+ stripeAccount?: string;
381
+ };
382
+ }) | null;
383
+ logo: Stripe.File;
384
+ } | null>;
385
+ declare function orderGet(orderId: string): Promise<{
386
+ order: {
387
+ payment_method: Stripe.PaymentMethod | null;
388
+ latest_charge: Stripe.Charge | null;
389
+ taxBreakdown: {
390
+ taxPercentage: string;
391
+ taxAmount: number;
392
+ taxType: Stripe.Tax.Calculation.TaxBreakdown.TaxRateDetails.TaxType | (string & {});
393
+ }[];
394
+ metadata: {
395
+ shippingRateId?: string | undefined;
396
+ taxCalculationId?: string | undefined;
397
+ taxCalculationExp?: string | undefined;
398
+ taxId?: string | undefined;
399
+ "billingAddress.city"?: string | undefined;
400
+ "billingAddress.country"?: string | undefined;
401
+ "billingAddress.line1"?: string | undefined;
402
+ "billingAddress.line2"?: string | undefined;
403
+ "billingAddress.name"?: string | undefined;
404
+ "billingAddress.postalCode"?: string | undefined;
405
+ "billingAddress.state"?: string | undefined;
406
+ netAmount?: string | undefined;
407
+ taxBreakdown0?: string | undefined;
408
+ taxBreakdown1?: string | undefined;
409
+ taxBreakdown2?: string | undefined;
410
+ taxBreakdown3?: string | undefined;
411
+ taxBreakdown4?: string | undefined;
412
+ taxBreakdown5?: string | undefined;
413
+ } & Record<string, string>;
414
+ id: string;
415
+ object: "payment_intent";
416
+ amount: number;
417
+ amount_capturable: number;
418
+ amount_details?: Stripe.PaymentIntent.AmountDetails;
419
+ amount_received: number;
420
+ application: string | Stripe.Application | null;
421
+ application_fee_amount: number | null;
422
+ automatic_payment_methods: Stripe.PaymentIntent.AutomaticPaymentMethods | null;
423
+ canceled_at: number | null;
424
+ cancellation_reason: Stripe.PaymentIntent.CancellationReason | null;
425
+ capture_method: Stripe.PaymentIntent.CaptureMethod;
426
+ client_secret: string | null;
427
+ confirmation_method: Stripe.PaymentIntent.ConfirmationMethod;
428
+ created: number;
429
+ currency: string;
430
+ customer: string | Stripe.Customer | Stripe.DeletedCustomer | null;
431
+ description: string | null;
432
+ invoice: string | Stripe.Invoice | null;
433
+ last_payment_error: Stripe.PaymentIntent.LastPaymentError | null;
434
+ livemode: boolean;
435
+ next_action: Stripe.PaymentIntent.NextAction | null;
436
+ on_behalf_of: string | Stripe.Account | null;
437
+ payment_method_configuration_details: Stripe.PaymentIntent.PaymentMethodConfigurationDetails | null;
438
+ payment_method_options: Stripe.PaymentIntent.PaymentMethodOptions | null;
439
+ payment_method_types: Array<string>;
440
+ processing: Stripe.PaymentIntent.Processing | null;
441
+ receipt_email: string | null;
442
+ review: string | Stripe.Review | null;
443
+ setup_future_usage: Stripe.PaymentIntent.SetupFutureUsage | null;
444
+ shipping: Stripe.PaymentIntent.Shipping | null;
445
+ source: string | Stripe.CustomerSource | Stripe.DeletedCustomerSource | null;
446
+ statement_descriptor: string | null;
447
+ statement_descriptor_suffix: string | null;
448
+ status: Stripe.PaymentIntent.Status;
449
+ transfer_data: Stripe.PaymentIntent.TransferData | null;
450
+ transfer_group: string | null;
451
+ };
452
+ lines: {
453
+ product: {
454
+ default_price: Stripe.Price;
455
+ marketing_features: string[];
456
+ metadata: {
457
+ slug: string;
458
+ category?: string | undefined;
459
+ order?: number | undefined;
460
+ variant?: string | undefined;
461
+ };
462
+ id: string;
463
+ object: "product";
464
+ active: boolean;
465
+ created: number;
466
+ deleted?: void | undefined;
467
+ description: string | null;
468
+ images: Array<string>;
469
+ livemode: boolean;
470
+ name: string;
471
+ package_dimensions: Stripe.Product.PackageDimensions | null;
472
+ shippable: boolean | null;
473
+ statement_descriptor?: string | null;
474
+ tax_code: string | Stripe.TaxCode | null;
475
+ type: Stripe.Product.Type;
476
+ unit_label?: string | null;
477
+ updated: number;
478
+ url: string | null;
479
+ };
480
+ quantity: number;
481
+ }[];
482
+ shippingRate: Stripe.Response<Stripe.ShippingRate> | null;
483
+ } | null>;
484
+ declare const sanitizeQueryValue: (slug: string | number | boolean) => string;
485
+ declare const objectToStripeQuery: (obj: Record<string, string | number | boolean>) => string;
486
+ declare const StripeClient: ({ tags, revalidate, cache, }: {
487
+ tags?: string[];
488
+ revalidate?: number;
489
+ cache?: RequestInit["cache"];
490
+ }) => Stripe;
491
+ declare const provider: ({ tags, revalidate, cache, }: {
492
+ tags?: string[];
493
+ revalidate?: number;
494
+ cache?: RequestInit["cache"];
495
+ }) => Stripe;
496
+ declare const getProductsFromCart: (metadata: CartMetadata) => (readonly [productId: string, quantity: number])[];
497
+ type MappedCart = ReturnType<typeof mapCart>;
498
+ declare function getProductsFromMetadata(metadata: MappedCart["metadata"]): Promise<{
499
+ product: {
500
+ default_price: Stripe.Price;
501
+ marketing_features: string[];
502
+ metadata: {
503
+ slug: string;
504
+ category?: string | undefined;
505
+ order?: number | undefined;
506
+ variant?: string | undefined;
507
+ };
508
+ id: string;
509
+ object: "product";
510
+ active: boolean;
511
+ created: number;
512
+ deleted?: void | undefined;
513
+ description: string | null;
514
+ images: Array<string>;
515
+ livemode: boolean;
516
+ name: string;
517
+ package_dimensions: Stripe.Product.PackageDimensions | null;
518
+ shippable: boolean | null;
519
+ statement_descriptor?: string | null;
520
+ tax_code: string | Stripe.TaxCode | null;
521
+ type: Stripe.Product.Type;
522
+ unit_label?: string | null;
523
+ updated: number;
524
+ url: string | null;
525
+ } | null;
526
+ quantity: number;
527
+ }[]>;
528
+ type ProductsFromMetadata = Awaited<ReturnType<typeof getProductsFromMetadata>>;
529
+ declare const getCartWithProductsById: (provider: Provider, cartId: string) => Promise<{
530
+ cart: {
531
+ metadata: {
532
+ shippingRateId?: string | undefined;
533
+ taxCalculationId?: string | undefined;
534
+ taxCalculationExp?: string | undefined;
535
+ taxId?: string | undefined;
536
+ "billingAddress.city"?: string | undefined;
537
+ "billingAddress.country"?: string | undefined;
538
+ "billingAddress.line1"?: string | undefined;
539
+ "billingAddress.line2"?: string | undefined;
540
+ "billingAddress.name"?: string | undefined;
541
+ "billingAddress.postalCode"?: string | undefined;
542
+ "billingAddress.state"?: string | undefined;
543
+ netAmount?: string | undefined;
544
+ taxBreakdown0?: string | undefined;
545
+ taxBreakdown1?: string | undefined;
546
+ taxBreakdown2?: string | undefined;
547
+ taxBreakdown3?: string | undefined;
548
+ taxBreakdown4?: string | undefined;
549
+ taxBreakdown5?: string | undefined;
550
+ } & Record<string, string>;
551
+ payment_method: Stripe.PaymentMethod | null;
552
+ taxBreakdown: {
553
+ taxPercentage: string;
554
+ taxAmount: number;
555
+ taxType: Stripe.Tax.Calculation.TaxBreakdown.TaxRateDetails.TaxType | (string & {});
556
+ }[];
557
+ id: string;
558
+ object: "payment_intent";
559
+ amount: number;
560
+ amount_capturable: number;
561
+ amount_details?: Stripe.PaymentIntent.AmountDetails;
562
+ amount_received: number;
563
+ application: string | Stripe.Application | null;
564
+ application_fee_amount: number | null;
565
+ automatic_payment_methods: Stripe.PaymentIntent.AutomaticPaymentMethods | null;
566
+ canceled_at: number | null;
567
+ cancellation_reason: Stripe.PaymentIntent.CancellationReason | null;
568
+ capture_method: Stripe.PaymentIntent.CaptureMethod;
569
+ client_secret: string | null;
570
+ confirmation_method: Stripe.PaymentIntent.ConfirmationMethod;
571
+ created: number;
572
+ currency: string;
573
+ customer: string | Stripe.Customer | Stripe.DeletedCustomer | null;
574
+ description: string | null;
575
+ invoice: string | Stripe.Invoice | null;
576
+ last_payment_error: Stripe.PaymentIntent.LastPaymentError | null;
577
+ latest_charge: string | Stripe.Charge | null;
578
+ livemode: boolean;
579
+ next_action: Stripe.PaymentIntent.NextAction | null;
580
+ on_behalf_of: string | Stripe.Account | null;
581
+ payment_method_configuration_details: Stripe.PaymentIntent.PaymentMethodConfigurationDetails | null;
582
+ payment_method_options: Stripe.PaymentIntent.PaymentMethodOptions | null;
583
+ payment_method_types: Array<string>;
584
+ processing: Stripe.PaymentIntent.Processing | null;
585
+ receipt_email: string | null;
586
+ review: string | Stripe.Review | null;
587
+ setup_future_usage: Stripe.PaymentIntent.SetupFutureUsage | null;
588
+ shipping: Stripe.PaymentIntent.Shipping | null;
589
+ source: string | Stripe.CustomerSource | Stripe.DeletedCustomerSource | null;
590
+ statement_descriptor: string | null;
591
+ statement_descriptor_suffix: string | null;
592
+ status: Stripe.PaymentIntent.Status;
593
+ transfer_data: Stripe.PaymentIntent.TransferData | null;
594
+ transfer_group: string | null;
595
+ };
596
+ lines: {
597
+ product: {
598
+ default_price: Stripe.Price;
599
+ marketing_features: string[];
600
+ metadata: {
601
+ slug: string;
602
+ category?: string | undefined;
603
+ order?: number | undefined;
604
+ variant?: string | undefined;
605
+ };
606
+ id: string;
607
+ object: "product";
608
+ active: boolean;
609
+ created: number;
610
+ deleted?: void | undefined;
611
+ description: string | null;
612
+ images: Array<string>;
613
+ livemode: boolean;
614
+ name: string;
615
+ package_dimensions: Stripe.Product.PackageDimensions | null;
616
+ shippable: boolean | null;
617
+ statement_descriptor?: string | null;
618
+ tax_code: string | Stripe.TaxCode | null;
619
+ type: Stripe.Product.Type;
620
+ unit_label?: string | null;
621
+ updated: number;
622
+ url: string | null;
623
+ };
624
+ quantity: number;
625
+ }[];
626
+ shippingRate: Stripe.Response<Stripe.ShippingRate> | null;
627
+ } | null>;
628
+ declare const calculateCartTotalNet: (cart: {
629
+ cart: {
630
+ amount: number;
631
+ metadata?: {
632
+ taxCalculationId?: string;
633
+ };
634
+ };
635
+ lines: Array<{
636
+ product: {
637
+ default_price?: {
638
+ unit_amount?: number | null;
639
+ };
640
+ };
641
+ quantity: number;
642
+ }>;
643
+ shippingRate?: {
644
+ fixed_amount?: {
645
+ amount?: number;
646
+ };
647
+ } | null;
648
+ }) => number;
649
+ declare const getAddressSchema: (tr: {
650
+ nameRequired: string;
651
+ cityRequired: string;
652
+ countryRequired: string;
653
+ line1Required: string;
654
+ postalCodeRequired: string;
655
+ }) => z.ZodObject<{
656
+ name: z.ZodString;
657
+ city: z.ZodString;
658
+ country: z.ZodString;
659
+ line1: z.ZodString;
660
+ line2: z.ZodDefault<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
661
+ postalCode: z.ZodString;
662
+ state: z.ZodDefault<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
663
+ phone: z.ZodDefault<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
664
+ taxId: z.ZodDefault<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
665
+ }, "strip", z.ZodTypeAny, {
666
+ name: string;
667
+ taxId: string | null;
668
+ city: string;
669
+ country: string;
670
+ line1: string;
671
+ line2: string | null;
672
+ postalCode: string;
673
+ state: string | null;
674
+ phone: string | null;
675
+ }, {
676
+ name: string;
677
+ city: string;
678
+ country: string;
679
+ line1: string;
680
+ postalCode: string;
681
+ taxId?: string | null | undefined;
682
+ line2?: string | null | undefined;
683
+ state?: string | null | undefined;
684
+ phone?: string | null | undefined;
685
+ }>;
686
+ type AddressSchema = TypeOf<ReturnType<typeof getAddressSchema>>;
687
+ declare function cartChangeQuantity({ productId, cartId, operation, clearTaxCalculation, }: {
688
+ productId: string;
689
+ cartId: string;
690
+ operation: "INCREASE" | "DECREASE";
691
+ clearTaxCalculation?: boolean;
692
+ }): Promise<Stripe.Response<Stripe.PaymentIntent> | undefined>;
693
+ declare const cartSaveTax: ({ cartId, taxId }: {
694
+ cartId: string;
695
+ taxId: string;
696
+ }) => Promise<Stripe.Response<Stripe.PaymentIntent> | undefined>;
697
+ declare function cartSaveShipping({ cartId, shippingRateId, }: {
698
+ cartId: string;
699
+ shippingRateId: string;
700
+ }): Promise<Stripe.Response<Stripe.PaymentIntent> | undefined>;
701
+ declare function cartSaveBillingAddress({ cartId, billingAddress, }: {
702
+ cartId: string;
703
+ billingAddress: AddressSchema;
704
+ }): Promise<Stripe.Response<Stripe.PaymentIntent> | undefined>;
705
+ declare function taxDefaultGet(): Promise<Stripe.Response<Stripe.Tax.Settings>>;
706
+ declare function cartCount(metadata: CartMetadata): number;
707
+ declare global {
708
+ /**
709
+ * ⚠️ Warning: This might be `undefined` but TypeScript doesn't have a syntax to express that.
710
+ * @see https://github.com/microsoft/TypeScript/issues/36057
711
+ */
712
+ function __ynsFindStripeAccount(): string | undefined | Promise<string | undefined>;
713
+ }
714
+
715
+ export { type AddressSchema, type Cart, type MappedCart, type ProductsFromMetadata, type ShippingRate, StripeClient, accountGet, calculateCartTotalNet, cartAdd, cartAddOptimistic, cartChangeQuantity, cartCount, cartCreate, cartGet, cartSaveBillingAddress, cartSaveShipping, cartSaveTax, cartSetQuantity, categoryBrowse, fileGet, findStripeAccount, getAddressSchema, getCartWithProductsById, getProductsFromCart, objectToStripeQuery, orderGet, productBrowse, productGet, productGetById, productSearch, provider, sanitizeQueryValue, shippingBrowse, shippingGet, taxDefaultGet };
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ import"server-only";import{revalidatePath as W,revalidateTag as b}from"next/cache";import h from"stripe";import{z as x}from"zod";import"server-only";import{z as c}from"zod";function C(t,e){if(!t)throw new Error(e)}var Q=async t=>{try{return[null,await t]}catch(e){return[e instanceof Error?e:new Error(String(e)),null]}},P=t=>{if(t==null)return 0;if(typeof t=="number")return t;let e=Number.parseInt(t,10);return Number.isNaN(e)?0:e},O=t=>{if(t==null)return null;try{return JSON.parse(t)}catch{return null}};function R(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 et=c.object({category:c.string().optional(),order:c.coerce.number().optional(),slug:c.string(),variant:c.string().optional()});function B({default_price:t,marketing_features:e,...a}){return C(t,"Product must have a default price"),C(typeof t=="object","Product default price must be an object"),{...a,default_price:t,marketing_features:e.map(r=>r.name).filter(Boolean),metadata:et.parse(a.metadata)}}function A(t){return t.data.map(B)}function L(t){return t.filter((e,a,r)=>a===r.findIndex(n=>n.metadata.slug===e.metadata.slug))}var N=t=>!t.deleted&&t.active,$=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())),G=c.object({taxType:c.string(),taxPercentage:c.string(),taxAmount:c.number()});function j(t){let e=t.payment_method;C(typeof e!="string","Payment method is missing from cart");let a=$.parse(t.metadata),r=Object.entries(a).filter(([n])=>n.startsWith("taxBreakdown")).map(([n,o])=>{let i=G.safeParse(O(String(o)));return i.success?i.data:null}).filter(Boolean);return{...t,metadata:a,payment_method:e,taxBreakdown:r}}function U({payment_method:t,latest_charge:e,...a}){C(typeof t=="object","Payment method is missing from order"),C(typeof e=="object","Latest charge is missing from order");let r=$.parse(a.metadata),n=Object.entries(r).filter(([o])=>o.startsWith("taxBreakdown")).map(([o,i])=>{let s=G.safeParse(O(String(i)));return s.success?s.data:null}).filter(Boolean);return{...a,payment_method:t,latest_charge:e,taxBreakdown:n,metadata:r}}var m=()=>{if(global.__ynsFindStripeAccount)return global.__ynsFindStripeAccount()},V=process.env.STRIPE_SECRET_KEY;if(!V)throw new Error("Missing STRIPE_SECRET_KEY");var y=process.env.STRIPE_CURRENCY;if(!y)throw new Error("Missing STRIPE_CURRENCY");var q=1e3;function bt({productId:t,cartId:e}){return e?k.add(l,{productId:t,cartId:e}):k.create(l,{productId:t})}function v(t){return k.get(l,{cartId:t})}function St(){return k.create(l,{})}async function Pt({cart:t,add:e}){if(!e)return t;let a=await E(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 Rt({cartId:t,productId:e,quantity:a}){let[r,n]=await Promise.all([z(e),v(t)]);if(!r)throw new Error(`Product not found: ${e}`);if(!n)throw new Error(`Cart not found: ${t}`);if(y?.toLowerCase()!==r.default_price.currency.toLowerCase())throw new Error(`Product currency ${r.default_price.currency} does not match cart currency ${y}`);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 S({paymentIntentId:t,data:{metadata:o,amount:i||q}})}catch(s){console.error(s)}finally{b(`cart-${t}`),W("/cart"),W("/cart-overlay")}}async function z(t){let e=await m(),a=l({tags:["product",`product-${t}`],cache:"force-cache"});try{let r=await a.products.retrieve(t,{expand:["default_price"]},{stripeAccount:e});return B(r)}catch(r){if(r instanceof h.errors.StripeError&&r.code==="resource_missing")return null;throw r}}async function At({slug:t}){let e=await m(),r=await l({tags:["product",`product-${t}`],cache:"force-cache"}).products.search({query:J({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 R(A(r).filter(N))}async function rt(t){let e=await m();if(t.filter?.category){let a=t.filter?.category,n=await l({tags:["product",`category-${a}`],cache:"force-cache"}).products.search({limit:100,query:J({active:!0,'metadata["category"]':a}),expand:["data.default_price"]},{stripeAccount:e});return R(L(A(n)).filter(N).slice(t.offset,t.first))}else{let r=await l({tags:["product"],cache:"force-cache"}).products.list({limit:100,active:!0,expand:["data.default_price"]},{stripeAccount:e});return R(L(A(r)).filter(N).slice(t.offset,t.first))}}async function Et(){let t=await m();return await l({tags:["shipping"]}).shippingRates.list({active:!0},{stripeAccount:t})}async function T(t){let e=await m(),a=l({tags:["shipping",`shipping-${t}`]});try{return await a.shippingRates.retrieve(t,{},{stripeAccount:e})}catch(r){if(console.error(r),r instanceof h.errors.StripeError&&r.code==="resource_missing")return null;throw r}}async function vt(t){let a=(await rt({first:100})).map(n=>n.metadata.category),r=new Set(a);return Array.from(r).filter(Boolean)}async function Tt(t){let e=await m(),a=l({tags:["products","search"]}),r=Y(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 R(A(n).filter(o=>o.active&&!o.deleted))}async function It(t){let e=await m(),a=l({tags:["files",`file-${t}`]});try{return await a.fileLinks.create({file:t},{stripeAccount:e})}catch(r){if(console.error(r),r instanceof h.errors.StripeError&&r.code==="resource_missing")return null;throw r}}async function Bt(){let t=await m(),e=l({tags:["account"]});try{let[a,r]=await Q(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 h.errors.StripeError&&a.code==="resource_missing")return null;throw a}}async function at(t){let e=await m(),a=l({tags:["order",`order-${t}`]});try{let r=await a.paymentIntents.retrieve(t,{expand:["payment_method","latest_charge"]},{stripeAccount:e});return U(r)}catch(r){if(r instanceof h.errors.StripeError&&r.code==="resource_missing")return null;throw r}}async function Nt(t){let e=await at(t);if(!e)return null;let a=H(e.metadata),r=await Promise.all(a.map(async([i,s])=>({product:await E(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 Y=t=>t.toString().replace(/"/g,'\\"'),J=t=>Object.entries(t).map(([e,a])=>`${e}:"${Y(a)}"`).join(" AND ").trim(),$t=({tags:t,revalidate:e,cache:a})=>K({next:{tags:t,revalidate:e},cache:a}),K=({cache:t,next:e}={})=>new h(V,{typescript:!0,apiVersion:"2024-06-20",httpClient:h.createFetchHttpClient((r,n)=>fetch(r,{...n,cache:t??n?.cache,next:e??n?.next})),appInfo:{name:"Commerce SDK",version:"beta",url:"https://yournextstore.com",partner_id:"CONS-003378"}}),l=({tags:t,revalidate:e,cache:a})=>K({next:{tags:t,revalidate:e},cache:a}),E=async t=>{let e=await m(),a=l({tags:["product",`product-${t}`],cache:"force-cache"});try{let r=await a.products.retrieve(t,{expand:["default_price"]},{stripeAccount:e});return B(r)}catch(r){if(r instanceof h.errors.StripeError&&r.code==="resource_missing")return null;throw r}},X=["requires_action","requires_confirmation","requires_capture","requires_payment_method"],H=t=>Object.entries(t??{}).filter(([e])=>e.startsWith("prod_")).map(([e,a])=>[e,P(a)]).filter(([,e])=>e&&Number.isFinite(e)&&e>0),nt=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(X.includes(n.status))return j(n)}catch(n){if(console.error(n),n instanceof h.errors.StripeError&&n.code==="resource_missing")return null;throw n}};async function F(t){let e=H(t);return await Promise.all(e.map(async([r,n])=>({product:await E(r),quantity:n})))}var Z=async(t,e)=>{let a=await nt(t,e);if(!a)return null;let r=await F(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}},ot=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,it=["billingAddress.country","billingAddress.postalCode","billingAddress.state","taxId","shippingRateId"];function st({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,p=it.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 g=t.lines.find(I=>I.product.id===u.product?.id);return u.product?.default_price.unit_amount!==g?.product.default_price.unit_amount||u.quantity!==g?.quantity});return s&&i!==s||p||d}var qt=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("")}),ct=async({lineItems:t,billingAddress:e,cartId:a,shippingRateId:r,taxId:n})=>{if(!process.env.ENABLE_STRIPE_TAX)return null;let o=await m(),i=l({tags:["tax-calculations",`tax-calculations-${a}`],cache:"force-cache"});if(!e?.country)return null;let s=r?await T(r):null,p=typeof s?.tax_code=="string"?s.tax_code:s?.tax_code?.id,d=await dt(),f=y==="usd"||y==="cad"?"exclusive":"inclusive",w=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 ${y}: ${f}.`),await i.tax.calculations.create({expand:["line_items"],line_items:t.map(g=>({...g,tax_behavior:g.tax_behavior??w})),currency:y,shipping_cost:s?.active&&s?.fixed_amount?{amount:s.fixed_amount.amount,tax_behavior:s.tax_behavior==="inclusive"?"inclusive":s.tax_behavior==="exclusive"?"exclusive":w,tax_code:p??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})},D={taxBreakdown0:"",taxBreakdown1:"",taxBreakdown2:"",taxBreakdown3:"",taxBreakdown4:"",taxBreakdown5:""},S=async({paymentIntentId:t,data:e,clearTaxCalculation:a})=>{let r=await m(),n=await Z(l,t);C(n,`Cart not found: ${t}`);let o=$.parse({...n.cart.metadata,...e.metadata}),i=await F(o),p=!a&&st({oldCart:n,data:e,mergedMetadata:o,lines:i})?await ct({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:g})=>{if(u?.default_price.unit_amount)return{product:u.id,reference:[u.metadata.slug,u.metadata.variant].filter(Boolean).join("-"),quantity:g,amount:u.default_price.unit_amount*g,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(p){let u=Object.fromEntries(p.tax_breakdown.map(_=>({taxType:_.tax_rate_details.tax_type,taxPercentage:_.tax_rate_details.percentage_decimal,taxAmount:_.amount})).map((_,tt)=>[`taxBreakdown${tt}`,JSON.stringify(_)]));return await l({tags:[],cache:"no-cache"}).paymentIntents.update(t,{...e,amount:p.amount_total,metadata:{...o,...d&&{netAmount:d},...D,...u,taxCalculationId:p.id,taxCalculationExp:p?.expires_at}},{stripeAccount:r})}return await l({tags:[],cache:"no-cache"}).paymentIntents.update(t,{...e,metadata:{...o,...d&&{netAmount:d},...a&&{...D,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 E(e):null;return await n.paymentIntents.create({currency:y,amount:o?.default_price.unit_amount||q,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(X.includes(n.status)){let o=j(n);if(!o)return null;let i=await F(o.metadata),{metadata:{shippingRateId:s}}=o,p=s&&await T(s);return{cart:o,lines:i.map(({product:d,quantity:f})=>d?{product:d,quantity:f}:null).filter(Boolean),shippingRate:p||null}}}catch(n){if(console.error(n),n instanceof h.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[p,d]=await Promise.all([E(n),Z(t,o)]);if(!p)throw new Error(`Product not found: ${n}`);if(!d)throw new Error(`Cart not found: ${o}`);if(y.toLowerCase()!==p.default_price.currency.toLowerCase())throw new Error(`Product currency ${p.default_price.currency} does not match cart currency ${y}`);let f=d.cart.metadata??{},g=P(f[n])+(i==="INCREASE"?1:-1);g<=0?f[n]="":f[n]=g.toString();let I=ot(d)+(p.default_price.unit_amount??0);try{return await S({paymentIntentId:o,data:{metadata:f,amount:I||q},clearTaxCalculation:s})}catch(_){console.error(_)}finally{b(`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)+ut(t):0,ut=t=>t?t.lines.reduce((e,{product:a,quantity:r})=>e+(a.default_price?.unit_amount??0)*r,0):0;async function kt({productId:t,cartId:e,operation:a,clearTaxCalculation:r}){let[n,o]=await Promise.all([z(t),v(e)]);if(!n)throw new Error(`Product not found: ${t}`);if(!o)throw new Error(`Cart not found: ${e}`);if(y?.toLowerCase()!==n.default_price.currency.toLowerCase())throw new Error(`Product currency ${n.default_price.currency} does not match cart currency ${y}`);let i=o.cart.metadata??{},d=P(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 S({paymentIntentId:e,data:{metadata:i,amount:f||q},clearTaxCalculation:r})}catch(w){console.error(w)}finally{b(`cart-${e}`)}}var Mt=async({cartId:t,taxId:e})=>{let a=await v(t);if(!a)throw new Error(`Cart not found: ${t}`);try{return await S({paymentIntentId:t,data:{metadata:{...a.cart.metadata,taxId:e}}})}catch(r){console.error(r)}finally{b(`cart-${t}`)}};async function Ot({cartId:t,shippingRateId:e}){let a=await v(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 S({paymentIntentId:t,data:{metadata:{...a.cart.metadata,shippingRateId:e},amount:M({...a,shippingRate:r})}})}catch(n){console.error(n)}finally{b(`cart-${t}`)}}async function Lt({cartId:t,billingAddress:e}){if(!await v(t))throw new Error(`Cart not found: ${t}`);try{return await S({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{b(`cart-${t}`)}}async function dt(){let t=await m();return await l({tags:["tax-settings"]}).tax.settings.retrieve({},{stripeAccount:t})}function jt(t){return Object.entries(t??{}).filter(([e])=>e.startsWith("prod_")).map(([e,a])=>[e,P(a)]).filter(([,e])=>e&&Number.isFinite(e)&&e>0).length}export{$t as StripeClient,Bt as accountGet,ot as calculateCartTotalNet,bt as cartAdd,Pt as cartAddOptimistic,kt as cartChangeQuantity,jt as cartCount,St as cartCreate,v as cartGet,Lt as cartSaveBillingAddress,Ot as cartSaveShipping,Mt as cartSaveTax,Rt as cartSetQuantity,vt as categoryBrowse,It as fileGet,m as findStripeAccount,qt as getAddressSchema,Z as getCartWithProductsById,H as getProductsFromCart,J as objectToStripeQuery,Nt as orderGet,rt as productBrowse,At as productGet,z as productGetById,Tt as productSearch,l as provider,Y as sanitizeQueryValue,Et as shippingBrowse,T as shippingGet,dt as taxDefaultGet};
@@ -0,0 +1,319 @@
1
+ import Stripe from 'stripe';
2
+ import { z } from 'zod';
3
+
4
+ type MappedProduct = ReturnType<typeof mapProduct>;
5
+ declare function sortProducts(products: MappedProduct[]): {
6
+ default_price: Stripe.Price;
7
+ marketing_features: string[];
8
+ metadata: {
9
+ slug: string;
10
+ category?: string | undefined;
11
+ order?: number | undefined;
12
+ variant?: string | undefined;
13
+ };
14
+ id: string;
15
+ object: "product";
16
+ active: boolean;
17
+ created: number;
18
+ deleted?: void | undefined;
19
+ description: string | null;
20
+ images: Array<string>;
21
+ livemode: boolean;
22
+ name: string;
23
+ package_dimensions: Stripe.Product.PackageDimensions | null;
24
+ shippable: boolean | null;
25
+ statement_descriptor?: string | null;
26
+ tax_code: string | Stripe.TaxCode | null;
27
+ type: Stripe.Product.Type;
28
+ unit_label?: string | null;
29
+ updated: number;
30
+ url: string | null;
31
+ }[];
32
+ declare function mapProduct({ default_price, marketing_features, ...product }: Stripe.Product): {
33
+ default_price: Stripe.Price;
34
+ marketing_features: string[];
35
+ metadata: {
36
+ slug: string;
37
+ category?: string | undefined;
38
+ order?: number | undefined;
39
+ variant?: string | undefined;
40
+ };
41
+ id: string;
42
+ object: "product";
43
+ active: boolean;
44
+ created: number;
45
+ deleted?: void | undefined;
46
+ description: string | null;
47
+ images: Array<string>;
48
+ livemode: boolean;
49
+ name: string;
50
+ package_dimensions: Stripe.Product.PackageDimensions | null;
51
+ shippable: boolean | null;
52
+ statement_descriptor?: string | null;
53
+ tax_code: string | Stripe.TaxCode | null;
54
+ type: Stripe.Product.Type;
55
+ unit_label?: string | null;
56
+ updated: number;
57
+ url: string | null;
58
+ };
59
+ declare function mapProducts(products: Stripe.Response<Stripe.ApiSearchResult<Stripe.Product> | Stripe.ApiList<Stripe.Product>>): {
60
+ default_price: Stripe.Price;
61
+ marketing_features: string[];
62
+ metadata: {
63
+ slug: string;
64
+ category?: string | undefined;
65
+ order?: number | undefined;
66
+ variant?: string | undefined;
67
+ };
68
+ id: string;
69
+ object: "product";
70
+ active: boolean;
71
+ created: number;
72
+ deleted?: void | undefined;
73
+ description: string | null;
74
+ images: Array<string>;
75
+ livemode: boolean;
76
+ name: string;
77
+ package_dimensions: Stripe.Product.PackageDimensions | null;
78
+ shippable: boolean | null;
79
+ statement_descriptor?: string | null;
80
+ tax_code: string | Stripe.TaxCode | null;
81
+ type: Stripe.Product.Type;
82
+ unit_label?: string | null;
83
+ updated: number;
84
+ url: string | null;
85
+ }[];
86
+ declare function getUniqueVariants(products: MappedProduct[]): {
87
+ default_price: Stripe.Price;
88
+ marketing_features: string[];
89
+ metadata: {
90
+ slug: string;
91
+ category?: string | undefined;
92
+ order?: number | undefined;
93
+ variant?: string | undefined;
94
+ };
95
+ id: string;
96
+ object: "product";
97
+ active: boolean;
98
+ created: number;
99
+ deleted?: void | undefined;
100
+ description: string | null;
101
+ images: Array<string>;
102
+ livemode: boolean;
103
+ name: string;
104
+ package_dimensions: Stripe.Product.PackageDimensions | null;
105
+ shippable: boolean | null;
106
+ statement_descriptor?: string | null;
107
+ tax_code: string | Stripe.TaxCode | null;
108
+ type: Stripe.Product.Type;
109
+ unit_label?: string | null;
110
+ updated: number;
111
+ url: string | null;
112
+ }[];
113
+ declare const isProductAvailable: (product: MappedProduct) => boolean;
114
+ declare const cartMetadataSchema: z.ZodIntersection<z.ZodObject<{
115
+ shippingRateId: z.ZodOptional<z.ZodString>;
116
+ taxCalculationId: z.ZodOptional<z.ZodString>;
117
+ taxCalculationExp: z.ZodOptional<z.ZodString>;
118
+ taxId: z.ZodOptional<z.ZodString>;
119
+ "billingAddress.city": z.ZodOptional<z.ZodString>;
120
+ "billingAddress.country": z.ZodOptional<z.ZodString>;
121
+ "billingAddress.line1": z.ZodOptional<z.ZodString>;
122
+ "billingAddress.line2": z.ZodOptional<z.ZodString>;
123
+ "billingAddress.name": z.ZodOptional<z.ZodString>;
124
+ "billingAddress.postalCode": z.ZodOptional<z.ZodString>;
125
+ "billingAddress.state": z.ZodOptional<z.ZodString>;
126
+ netAmount: z.ZodOptional<z.ZodString>;
127
+ taxBreakdown0: z.ZodOptional<z.ZodString>;
128
+ taxBreakdown1: z.ZodOptional<z.ZodString>;
129
+ taxBreakdown2: z.ZodOptional<z.ZodString>;
130
+ taxBreakdown3: z.ZodOptional<z.ZodString>;
131
+ taxBreakdown4: z.ZodOptional<z.ZodString>;
132
+ taxBreakdown5: z.ZodOptional<z.ZodString>;
133
+ }, "strip", z.ZodTypeAny, {
134
+ shippingRateId?: string | undefined;
135
+ taxCalculationId?: string | undefined;
136
+ taxCalculationExp?: string | undefined;
137
+ taxId?: string | undefined;
138
+ "billingAddress.city"?: string | undefined;
139
+ "billingAddress.country"?: string | undefined;
140
+ "billingAddress.line1"?: string | undefined;
141
+ "billingAddress.line2"?: string | undefined;
142
+ "billingAddress.name"?: string | undefined;
143
+ "billingAddress.postalCode"?: string | undefined;
144
+ "billingAddress.state"?: string | undefined;
145
+ netAmount?: string | undefined;
146
+ taxBreakdown0?: string | undefined;
147
+ taxBreakdown1?: string | undefined;
148
+ taxBreakdown2?: string | undefined;
149
+ taxBreakdown3?: string | undefined;
150
+ taxBreakdown4?: string | undefined;
151
+ taxBreakdown5?: string | undefined;
152
+ }, {
153
+ shippingRateId?: string | undefined;
154
+ taxCalculationId?: string | undefined;
155
+ taxCalculationExp?: string | undefined;
156
+ taxId?: string | undefined;
157
+ "billingAddress.city"?: string | undefined;
158
+ "billingAddress.country"?: string | undefined;
159
+ "billingAddress.line1"?: string | undefined;
160
+ "billingAddress.line2"?: string | undefined;
161
+ "billingAddress.name"?: string | undefined;
162
+ "billingAddress.postalCode"?: string | undefined;
163
+ "billingAddress.state"?: string | undefined;
164
+ netAmount?: string | undefined;
165
+ taxBreakdown0?: string | undefined;
166
+ taxBreakdown1?: string | undefined;
167
+ taxBreakdown2?: string | undefined;
168
+ taxBreakdown3?: string | undefined;
169
+ taxBreakdown4?: string | undefined;
170
+ taxBreakdown5?: string | undefined;
171
+ }>, z.ZodRecord<z.ZodString, z.ZodString>>;
172
+ type CartMetadata = z.infer<typeof cartMetadataSchema>;
173
+ declare const cartMetadataTaxBreakdownSchema: z.ZodObject<{
174
+ taxType: z.ZodLiteral<Stripe.Tax.Calculation.TaxBreakdown.TaxRateDetails.TaxType | (string & {})>;
175
+ taxPercentage: z.ZodString;
176
+ taxAmount: z.ZodNumber;
177
+ }, "strip", z.ZodTypeAny, {
178
+ taxPercentage: string;
179
+ taxAmount: number;
180
+ taxType: Stripe.Tax.Calculation.TaxBreakdown.TaxRateDetails.TaxType | (string & {});
181
+ }, {
182
+ taxPercentage: string;
183
+ taxAmount: number;
184
+ taxType: Stripe.Tax.Calculation.TaxBreakdown.TaxRateDetails.TaxType | (string & {});
185
+ }>;
186
+ declare function mapCart(cart: Stripe.PaymentIntent): {
187
+ metadata: {
188
+ shippingRateId?: string | undefined;
189
+ taxCalculationId?: string | undefined;
190
+ taxCalculationExp?: string | undefined;
191
+ taxId?: string | undefined;
192
+ "billingAddress.city"?: string | undefined;
193
+ "billingAddress.country"?: string | undefined;
194
+ "billingAddress.line1"?: string | undefined;
195
+ "billingAddress.line2"?: string | undefined;
196
+ "billingAddress.name"?: string | undefined;
197
+ "billingAddress.postalCode"?: string | undefined;
198
+ "billingAddress.state"?: string | undefined;
199
+ netAmount?: string | undefined;
200
+ taxBreakdown0?: string | undefined;
201
+ taxBreakdown1?: string | undefined;
202
+ taxBreakdown2?: string | undefined;
203
+ taxBreakdown3?: string | undefined;
204
+ taxBreakdown4?: string | undefined;
205
+ taxBreakdown5?: string | undefined;
206
+ } & Record<string, string>;
207
+ payment_method: Stripe.PaymentMethod | null;
208
+ taxBreakdown: {
209
+ taxPercentage: string;
210
+ taxAmount: number;
211
+ taxType: Stripe.Tax.Calculation.TaxBreakdown.TaxRateDetails.TaxType | (string & {});
212
+ }[];
213
+ id: string;
214
+ object: "payment_intent";
215
+ amount: number;
216
+ amount_capturable: number;
217
+ amount_details?: Stripe.PaymentIntent.AmountDetails;
218
+ amount_received: number;
219
+ application: string | Stripe.Application | null;
220
+ application_fee_amount: number | null;
221
+ automatic_payment_methods: Stripe.PaymentIntent.AutomaticPaymentMethods | null;
222
+ canceled_at: number | null;
223
+ cancellation_reason: Stripe.PaymentIntent.CancellationReason | null;
224
+ capture_method: Stripe.PaymentIntent.CaptureMethod;
225
+ client_secret: string | null;
226
+ confirmation_method: Stripe.PaymentIntent.ConfirmationMethod;
227
+ created: number;
228
+ currency: string;
229
+ customer: string | Stripe.Customer | Stripe.DeletedCustomer | null;
230
+ description: string | null;
231
+ invoice: string | Stripe.Invoice | null;
232
+ last_payment_error: Stripe.PaymentIntent.LastPaymentError | null;
233
+ latest_charge: string | Stripe.Charge | null;
234
+ livemode: boolean;
235
+ next_action: Stripe.PaymentIntent.NextAction | null;
236
+ on_behalf_of: string | Stripe.Account | null;
237
+ payment_method_configuration_details: Stripe.PaymentIntent.PaymentMethodConfigurationDetails | null;
238
+ payment_method_options: Stripe.PaymentIntent.PaymentMethodOptions | null;
239
+ payment_method_types: Array<string>;
240
+ processing: Stripe.PaymentIntent.Processing | null;
241
+ receipt_email: string | null;
242
+ review: string | Stripe.Review | null;
243
+ setup_future_usage: Stripe.PaymentIntent.SetupFutureUsage | null;
244
+ shipping: Stripe.PaymentIntent.Shipping | null;
245
+ source: string | Stripe.CustomerSource | Stripe.DeletedCustomerSource | null;
246
+ statement_descriptor: string | null;
247
+ statement_descriptor_suffix: string | null;
248
+ status: Stripe.PaymentIntent.Status;
249
+ transfer_data: Stripe.PaymentIntent.TransferData | null;
250
+ transfer_group: string | null;
251
+ };
252
+ declare function mapOrder({ payment_method, latest_charge, ...order }: Stripe.PaymentIntent): {
253
+ payment_method: Stripe.PaymentMethod | null;
254
+ latest_charge: Stripe.Charge | null;
255
+ taxBreakdown: {
256
+ taxPercentage: string;
257
+ taxAmount: number;
258
+ taxType: Stripe.Tax.Calculation.TaxBreakdown.TaxRateDetails.TaxType | (string & {});
259
+ }[];
260
+ metadata: {
261
+ shippingRateId?: string | undefined;
262
+ taxCalculationId?: string | undefined;
263
+ taxCalculationExp?: string | undefined;
264
+ taxId?: string | undefined;
265
+ "billingAddress.city"?: string | undefined;
266
+ "billingAddress.country"?: string | undefined;
267
+ "billingAddress.line1"?: string | undefined;
268
+ "billingAddress.line2"?: string | undefined;
269
+ "billingAddress.name"?: string | undefined;
270
+ "billingAddress.postalCode"?: string | undefined;
271
+ "billingAddress.state"?: string | undefined;
272
+ netAmount?: string | undefined;
273
+ taxBreakdown0?: string | undefined;
274
+ taxBreakdown1?: string | undefined;
275
+ taxBreakdown2?: string | undefined;
276
+ taxBreakdown3?: string | undefined;
277
+ taxBreakdown4?: string | undefined;
278
+ taxBreakdown5?: string | undefined;
279
+ } & Record<string, string>;
280
+ id: string;
281
+ object: "payment_intent";
282
+ amount: number;
283
+ amount_capturable: number;
284
+ amount_details?: Stripe.PaymentIntent.AmountDetails;
285
+ amount_received: number;
286
+ application: string | Stripe.Application | null;
287
+ application_fee_amount: number | null;
288
+ automatic_payment_methods: Stripe.PaymentIntent.AutomaticPaymentMethods | null;
289
+ canceled_at: number | null;
290
+ cancellation_reason: Stripe.PaymentIntent.CancellationReason | null;
291
+ capture_method: Stripe.PaymentIntent.CaptureMethod;
292
+ client_secret: string | null;
293
+ confirmation_method: Stripe.PaymentIntent.ConfirmationMethod;
294
+ created: number;
295
+ currency: string;
296
+ customer: string | Stripe.Customer | Stripe.DeletedCustomer | null;
297
+ description: string | null;
298
+ invoice: string | Stripe.Invoice | null;
299
+ last_payment_error: Stripe.PaymentIntent.LastPaymentError | null;
300
+ livemode: boolean;
301
+ next_action: Stripe.PaymentIntent.NextAction | null;
302
+ on_behalf_of: string | Stripe.Account | null;
303
+ payment_method_configuration_details: Stripe.PaymentIntent.PaymentMethodConfigurationDetails | null;
304
+ payment_method_options: Stripe.PaymentIntent.PaymentMethodOptions | null;
305
+ payment_method_types: Array<string>;
306
+ processing: Stripe.PaymentIntent.Processing | null;
307
+ receipt_email: string | null;
308
+ review: string | Stripe.Review | null;
309
+ setup_future_usage: Stripe.PaymentIntent.SetupFutureUsage | null;
310
+ shipping: Stripe.PaymentIntent.Shipping | null;
311
+ source: string | Stripe.CustomerSource | Stripe.DeletedCustomerSource | null;
312
+ statement_descriptor: string | null;
313
+ statement_descriptor_suffix: string | null;
314
+ status: Stripe.PaymentIntent.Status;
315
+ transfer_data: Stripe.PaymentIntent.TransferData | null;
316
+ transfer_group: string | null;
317
+ };
318
+
319
+ export { type CartMetadata, type MappedProduct, cartMetadataSchema, cartMetadataTaxBreakdownSchema, getUniqueVariants, isProductAvailable, mapCart, mapOrder, mapProduct, mapProducts, sortProducts };
@@ -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}};function P(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 m=t.object({category:t.string().optional(),order:t.coerce.number().optional(),slug:t.string(),variant:t.string().optional()});function g({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:m.parse(n.metadata)}}function w(e){return e.data.map(g)}function k(e){return e.filter((r,n,a)=>n===a.findIndex(o=>o.metadata.slug===r.metadata.slug))}var S=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 N(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 d=c.safeParse(p(String(s)));return d.success?d.data:null}).filter(Boolean);return{...e,metadata:n,payment_method:r,taxBreakdown:a}}function B({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,d])=>{let u=c.safeParse(p(String(d)));return u.success?u.data:null}).filter(Boolean);return{...n,payment_method:e,latest_charge:r,taxBreakdown:o,metadata:a}}export{l as cartMetadataSchema,c as cartMetadataTaxBreakdownSchema,k as getUniqueVariants,S as isProductAvailable,N as mapCart,B as mapOrder,g as mapProduct,w as mapProducts,P as sortProducts};
package/package.json CHANGED
@@ -1,9 +1,67 @@
1
1
  {
2
+ "$schema": "https://json.schemastore.org/package",
2
3
  "name": "commerce-kit",
3
- "version": "0.0.0",
4
- "description": "",
5
- "main": "index.js",
6
- "keywords": [],
7
- "author": "",
8
- "license": "ISC"
4
+ "version": "0.0.5",
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
+ "./internal": {
18
+ "import": "./dist/internal.js",
19
+ "types": "./dist/internal.d.ts"
20
+ }
21
+ },
22
+ "files": [
23
+ "package.json",
24
+ "dist",
25
+ "README.md",
26
+ "LICENSE.md"
27
+ ],
28
+ "sideEffects": false,
29
+ "dependencies": {
30
+ "server-only": "^0.0.1"
31
+ },
32
+ "devDependencies": {
33
+ "@types/node": "^20.14.8",
34
+ "@types/react": "npm:types-react@19.0.0-rc.1",
35
+ "@types/react-dom": "npm:types-react-dom@19.0.0-rc.1",
36
+ "next": "15.0.0-canary.96",
37
+ "prettier": "3.3.3",
38
+ "react": "^19.0.0-rc.1",
39
+ "react-dom": "^19.0.0-rc.1",
40
+ "rimraf": "5.0.7",
41
+ "stripe": "^16.5.0",
42
+ "tsup": "8.1.0",
43
+ "tsx": "^4.15.7",
44
+ "zod": "^3.23.8"
45
+ },
46
+ "peerDependencies": {
47
+ "@types/node": "^20.14.8",
48
+ "@types/react": "npm:types-react@19.0.0-rc.1",
49
+ "@types/react-dom": "npm:types-react-dom@19.0.0-rc.1",
50
+ "next": "15.0.0-canary.96",
51
+ "react": "19.0.0-rc-3208e73e-20240730",
52
+ "react-dom": "19.0.0-rc-3208e73e-20240730",
53
+ "stripe": "^16.5.0",
54
+ "typescript": "^5.5.4",
55
+ "zod": "^3.23.8"
56
+ },
57
+ "peerDependencyRules": {
58
+ "allowedVersions": {
59
+ "react": "19.0.0-rc-3208e73e-20240730",
60
+ "react-dom": "19.0.0-rc-3208e73e-20240730"
61
+ }
62
+ },
63
+ "scripts": {
64
+ "build": "rimraf dist/* && tsup --config tsup.config.ts",
65
+ "dev": "tsup --config tsup.config.ts --watch"
66
+ }
9
67
  }