commerce-kit 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,1174 +1,6 @@
1
- import Stripe from 'stripe';
2
- import { z, TypeOf } from 'zod';
3
- import { CartMetadata, MappedCart } from './internal.js';
4
- export { MappedProduct, MappedShippingRate } from './internal.js';
5
1
  export { formatMoney } from './currencies.js';
6
-
7
- type Cart$1 = NonNullable<Awaited<ReturnType<typeof cartGet>>>;
8
- type Order$1 = NonNullable<Awaited<ReturnType<typeof orderGet>>>;
9
- declare function cartAdd({ productId, cartId }: {
10
- productId: string;
11
- cartId?: string;
12
- }): Promise<Stripe.Response<Stripe.PaymentIntent> | undefined>;
13
- declare function cartUpdateQuantity({ productId, cartId, operation, clearTaxCalculation, }: {
14
- productId: string;
15
- cartId: string;
16
- operation: "INCREASE" | "DECREASE";
17
- clearTaxCalculation?: boolean;
18
- }): Promise<Stripe.Response<Stripe.PaymentIntent> | undefined>;
19
- declare function cartGet(cartId: string): Promise<{
20
- cart: {
21
- metadata: {
22
- shippingRateId?: string | undefined;
23
- taxCalculationId?: string | undefined;
24
- taxCalculationExp?: string | undefined;
25
- taxId?: string | undefined;
26
- couponCode?: string | undefined;
27
- taxedAmount?: string | undefined;
28
- "billingAddress.city"?: string | undefined;
29
- "billingAddress.country"?: string | undefined;
30
- "billingAddress.line1"?: string | undefined;
31
- "billingAddress.line2"?: string | undefined;
32
- "billingAddress.name"?: string | undefined;
33
- "billingAddress.postalCode"?: string | undefined;
34
- "billingAddress.state"?: string | undefined;
35
- netAmount?: string | undefined;
36
- taxBreakdown0?: string | undefined;
37
- taxBreakdown1?: string | undefined;
38
- taxBreakdown2?: string | undefined;
39
- taxBreakdown3?: string | undefined;
40
- taxBreakdown4?: string | undefined;
41
- taxBreakdown5?: string | undefined;
42
- } & Record<string, string>;
43
- customer: Stripe.Customer | null;
44
- payment_method: Stripe.PaymentMethod | null;
45
- taxBreakdown: {
46
- taxType: Stripe.Tax.Calculation.TaxBreakdown.TaxRateDetails.TaxType | (string & {});
47
- taxPercentage: string;
48
- taxAmount: number;
49
- }[];
50
- id: string;
51
- object: "payment_intent";
52
- amount: number;
53
- amount_capturable: number;
54
- amount_details?: Stripe.PaymentIntent.AmountDetails;
55
- amount_received: number;
56
- application: string | Stripe.Application | null;
57
- application_fee_amount: number | null;
58
- automatic_payment_methods: Stripe.PaymentIntent.AutomaticPaymentMethods | null;
59
- canceled_at: number | null;
60
- cancellation_reason: Stripe.PaymentIntent.CancellationReason | null;
61
- capture_method: Stripe.PaymentIntent.CaptureMethod;
62
- client_secret: string | null;
63
- confirmation_method: Stripe.PaymentIntent.ConfirmationMethod;
64
- created: number;
65
- currency: string;
66
- description: string | null;
67
- excluded_payment_method_types: Array<Stripe.PaymentIntent.ExcludedPaymentMethodType> | null;
68
- last_payment_error: Stripe.PaymentIntent.LastPaymentError | null;
69
- latest_charge: string | Stripe.Charge | null;
70
- livemode: boolean;
71
- next_action: Stripe.PaymentIntent.NextAction | null;
72
- on_behalf_of: string | Stripe.Account | null;
73
- payment_method_configuration_details: Stripe.PaymentIntent.PaymentMethodConfigurationDetails | null;
74
- payment_method_options: Stripe.PaymentIntent.PaymentMethodOptions | null;
75
- payment_method_types: Array<string>;
76
- presentment_details?: Stripe.PaymentIntent.PresentmentDetails;
77
- processing: Stripe.PaymentIntent.Processing | null;
78
- receipt_email: string | null;
79
- review: string | Stripe.Review | null;
80
- setup_future_usage: Stripe.PaymentIntent.SetupFutureUsage | null;
81
- shipping: Stripe.PaymentIntent.Shipping | null;
82
- source: string | Stripe.CustomerSource | Stripe.DeletedCustomerSource | null;
83
- statement_descriptor: string | null;
84
- statement_descriptor_suffix: string | null;
85
- status: Stripe.PaymentIntent.Status;
86
- transfer_data: Stripe.PaymentIntent.TransferData | null;
87
- transfer_group: string | null;
88
- };
89
- lines: {
90
- product: {
91
- default_price: Stripe.Price;
92
- marketing_features: string[];
93
- metadata: {
94
- slug: string;
95
- stock: number;
96
- category?: string | undefined;
97
- order?: number | undefined;
98
- variant?: string | undefined;
99
- digitalAsset?: string | undefined;
100
- preview?: string | undefined;
101
- };
102
- id: string;
103
- object: "product";
104
- active: boolean;
105
- created: number;
106
- deleted?: void | undefined;
107
- description: string | null;
108
- images: Array<string>;
109
- livemode: boolean;
110
- name: string;
111
- package_dimensions: Stripe.Product.PackageDimensions | null;
112
- shippable: boolean | null;
113
- statement_descriptor?: string | null;
114
- tax_code: string | Stripe.TaxCode | null;
115
- type: Stripe.Product.Type;
116
- unit_label?: string | null;
117
- updated: number;
118
- url: string | null;
119
- };
120
- quantity: number;
121
- }[];
122
- shippingRate: Stripe.ShippingRate | null;
123
- } | null | undefined>;
124
- declare function cartCreate({ productId }?: {
125
- productId?: string;
126
- cartId?: string;
127
- }): Promise<Stripe.Response<Stripe.PaymentIntent>>;
128
- declare function cartAddOptimistic({ cart, add }: {
129
- cart?: Cart$1 | null;
130
- add: string | undefined;
131
- }): Promise<{
132
- cart: {
133
- amount: number;
134
- metadata?: ({
135
- shippingRateId?: string | undefined;
136
- taxCalculationId?: string | undefined;
137
- taxCalculationExp?: string | undefined;
138
- taxId?: string | undefined;
139
- couponCode?: string | undefined;
140
- taxedAmount?: string | undefined;
141
- "billingAddress.city"?: string | undefined;
142
- "billingAddress.country"?: string | undefined;
143
- "billingAddress.line1"?: string | undefined;
144
- "billingAddress.line2"?: string | undefined;
145
- "billingAddress.name"?: string | undefined;
146
- "billingAddress.postalCode"?: string | undefined;
147
- "billingAddress.state"?: string | undefined;
148
- netAmount?: string | undefined;
149
- taxBreakdown0?: string | undefined;
150
- taxBreakdown1?: string | undefined;
151
- taxBreakdown2?: string | undefined;
152
- taxBreakdown3?: string | undefined;
153
- taxBreakdown4?: string | undefined;
154
- taxBreakdown5?: string | undefined;
155
- } & Record<string, string>) | undefined;
156
- customer?: Stripe.Customer | null | undefined;
157
- payment_method?: Stripe.PaymentMethod | null | undefined;
158
- taxBreakdown?: {
159
- taxType: Stripe.Tax.Calculation.TaxBreakdown.TaxRateDetails.TaxType | (string & {});
160
- taxPercentage: string;
161
- taxAmount: number;
162
- }[] | undefined;
163
- id?: string | undefined;
164
- object?: "payment_intent" | undefined;
165
- amount_capturable?: number | undefined;
166
- amount_details?: Stripe.PaymentIntent.AmountDetails;
167
- amount_received?: number | undefined;
168
- application?: string | Stripe.Application | null | undefined;
169
- application_fee_amount?: number | null | undefined;
170
- automatic_payment_methods?: Stripe.PaymentIntent.AutomaticPaymentMethods | null | undefined;
171
- canceled_at?: number | null | undefined;
172
- cancellation_reason?: Stripe.PaymentIntent.CancellationReason | null | undefined;
173
- capture_method?: Stripe.PaymentIntent.CaptureMethod | undefined;
174
- client_secret?: string | null | undefined;
175
- confirmation_method?: Stripe.PaymentIntent.ConfirmationMethod | undefined;
176
- created?: number | undefined;
177
- currency?: string | undefined;
178
- description?: string | null | undefined;
179
- excluded_payment_method_types?: Stripe.PaymentIntent.ExcludedPaymentMethodType[] | null | undefined;
180
- last_payment_error?: Stripe.PaymentIntent.LastPaymentError | null | undefined;
181
- latest_charge?: string | Stripe.Charge | null | undefined;
182
- livemode?: boolean | undefined;
183
- next_action?: Stripe.PaymentIntent.NextAction | null | undefined;
184
- on_behalf_of?: string | Stripe.Account | null | undefined;
185
- payment_method_configuration_details?: Stripe.PaymentIntent.PaymentMethodConfigurationDetails | null | undefined;
186
- payment_method_options?: Stripe.PaymentIntent.PaymentMethodOptions | null | undefined;
187
- payment_method_types?: string[] | undefined;
188
- presentment_details?: Stripe.PaymentIntent.PresentmentDetails;
189
- processing?: Stripe.PaymentIntent.Processing | null | undefined;
190
- receipt_email?: string | null | undefined;
191
- review?: string | Stripe.Review | null | undefined;
192
- setup_future_usage?: Stripe.PaymentIntent.SetupFutureUsage | null | undefined;
193
- shipping?: Stripe.PaymentIntent.Shipping | null | undefined;
194
- source?: string | Stripe.CustomerSource | Stripe.DeletedCustomerSource | null | undefined;
195
- statement_descriptor?: string | null | undefined;
196
- statement_descriptor_suffix?: string | null | undefined;
197
- status?: Stripe.PaymentIntent.Status | undefined;
198
- transfer_data?: Stripe.PaymentIntent.TransferData | null | undefined;
199
- transfer_group?: string | null | undefined;
200
- };
201
- lines: {
202
- product: {
203
- default_price: Stripe.Price;
204
- marketing_features: string[];
205
- metadata: {
206
- slug: string;
207
- stock: number;
208
- category?: string | undefined;
209
- order?: number | undefined;
210
- variant?: string | undefined;
211
- digitalAsset?: string | undefined;
212
- preview?: 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.ShippingRate | null | undefined;
235
- } | null | undefined>;
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
- stock: number;
247
- category?: string | undefined;
248
- order?: number | undefined;
249
- variant?: string | undefined;
250
- digitalAsset?: string | undefined;
251
- preview?: string | undefined;
252
- };
253
- id: string;
254
- object: "product";
255
- active: boolean;
256
- created: number;
257
- deleted?: void | undefined;
258
- description: string | null;
259
- images: Array<string>;
260
- livemode: boolean;
261
- name: string;
262
- package_dimensions: Stripe.Product.PackageDimensions | null;
263
- shippable: boolean | null;
264
- statement_descriptor?: string | null;
265
- tax_code: string | Stripe.TaxCode | null;
266
- type: Stripe.Product.Type;
267
- unit_label?: string | null;
268
- updated: number;
269
- url: string | null;
270
- } | null>;
271
- declare function productGet({ slug }: {
272
- slug: string;
273
- }): Promise<{
274
- default_price: Stripe.Price;
275
- marketing_features: string[];
276
- metadata: {
277
- slug: string;
278
- stock: number;
279
- category?: string | undefined;
280
- order?: number | undefined;
281
- variant?: string | undefined;
282
- digitalAsset?: string | undefined;
283
- preview?: string | undefined;
284
- };
285
- id: string;
286
- object: "product";
287
- active: boolean;
288
- created: number;
289
- deleted?: void | undefined;
290
- description: string | null;
291
- images: Array<string>;
292
- livemode: boolean;
293
- name: string;
294
- package_dimensions: Stripe.Product.PackageDimensions | null;
295
- shippable: boolean | null;
296
- statement_descriptor?: string | null;
297
- tax_code: string | Stripe.TaxCode | null;
298
- type: Stripe.Product.Type;
299
- unit_label?: string | null;
300
- updated: number;
301
- url: string | null;
302
- }[]>;
303
- declare function productBrowse(params: {
304
- first?: number;
305
- last?: number;
306
- offset?: number;
307
- filter?: {
308
- category?: string;
309
- };
310
- }): Promise<{
311
- default_price: Stripe.Price;
312
- marketing_features: string[];
313
- metadata: {
314
- slug: string;
315
- stock: number;
316
- category?: string | undefined;
317
- order?: number | undefined;
318
- variant?: string | undefined;
319
- digitalAsset?: string | undefined;
320
- preview?: string | undefined;
321
- };
322
- id: string;
323
- object: "product";
324
- active: boolean;
325
- created: number;
326
- deleted?: void | undefined;
327
- description: string | null;
328
- images: Array<string>;
329
- livemode: boolean;
330
- name: string;
331
- package_dimensions: Stripe.Product.PackageDimensions | null;
332
- shippable: boolean | null;
333
- statement_descriptor?: string | null;
334
- tax_code: string | Stripe.TaxCode | null;
335
- type: Stripe.Product.Type;
336
- unit_label?: string | null;
337
- updated: number;
338
- url: string | null;
339
- }[]>;
340
- declare function shippingBrowse(): Promise<Stripe.ShippingRate[]>;
341
- declare function shippingGet(id: string): Promise<Stripe.ShippingRate | null>;
342
- declare function categoryBrowse(): Promise<string[]>;
343
- declare function fileGet(id: string): Promise<Stripe.Response<Stripe.FileLink> | null>;
344
- declare function accountGet(): Promise<{
345
- account: (Stripe.Account & {
346
- lastResponse: {
347
- headers: {
348
- [key: string]: string;
349
- };
350
- requestId: string;
351
- statusCode: number;
352
- apiVersion?: string;
353
- idempotencyKey?: string;
354
- stripeAccount?: string;
355
- };
356
- }) | null;
357
- logo: null;
358
- } | {
359
- account: (Stripe.Account & {
360
- lastResponse: {
361
- headers: {
362
- [key: string]: string;
363
- };
364
- requestId: string;
365
- statusCode: number;
366
- apiVersion?: string;
367
- idempotencyKey?: string;
368
- stripeAccount?: string;
369
- };
370
- }) | null;
371
- logo: Stripe.File;
372
- } | null>;
373
- declare function orderGet(orderId: string): Promise<{
374
- order: {
375
- payment_method: Stripe.PaymentMethod | null;
376
- latest_charge: Stripe.Charge | null;
377
- taxBreakdown: {
378
- taxType: Stripe.Tax.Calculation.TaxBreakdown.TaxRateDetails.TaxType | (string & {});
379
- taxPercentage: string;
380
- taxAmount: number;
381
- }[];
382
- metadata: {
383
- shippingRateId?: string | undefined;
384
- taxCalculationId?: string | undefined;
385
- taxCalculationExp?: string | undefined;
386
- taxId?: string | undefined;
387
- couponCode?: string | undefined;
388
- taxedAmount?: string | undefined;
389
- "billingAddress.city"?: string | undefined;
390
- "billingAddress.country"?: string | undefined;
391
- "billingAddress.line1"?: string | undefined;
392
- "billingAddress.line2"?: string | undefined;
393
- "billingAddress.name"?: string | undefined;
394
- "billingAddress.postalCode"?: string | undefined;
395
- "billingAddress.state"?: string | undefined;
396
- netAmount?: string | undefined;
397
- taxBreakdown0?: string | undefined;
398
- taxBreakdown1?: string | undefined;
399
- taxBreakdown2?: string | undefined;
400
- taxBreakdown3?: string | undefined;
401
- taxBreakdown4?: string | undefined;
402
- taxBreakdown5?: string | undefined;
403
- } & Record<string, string>;
404
- id: string;
405
- object: "payment_intent";
406
- amount: number;
407
- amount_capturable: number;
408
- amount_details?: Stripe.PaymentIntent.AmountDetails;
409
- amount_received: number;
410
- application: string | Stripe.Application | null;
411
- application_fee_amount: number | null;
412
- automatic_payment_methods: Stripe.PaymentIntent.AutomaticPaymentMethods | null;
413
- canceled_at: number | null;
414
- cancellation_reason: Stripe.PaymentIntent.CancellationReason | null;
415
- capture_method: Stripe.PaymentIntent.CaptureMethod;
416
- client_secret: string | null;
417
- confirmation_method: Stripe.PaymentIntent.ConfirmationMethod;
418
- created: number;
419
- currency: string;
420
- customer: string | Stripe.Customer | Stripe.DeletedCustomer | null;
421
- description: string | null;
422
- excluded_payment_method_types: Array<Stripe.PaymentIntent.ExcludedPaymentMethodType> | null;
423
- last_payment_error: Stripe.PaymentIntent.LastPaymentError | null;
424
- livemode: boolean;
425
- next_action: Stripe.PaymentIntent.NextAction | null;
426
- on_behalf_of: string | Stripe.Account | null;
427
- payment_method_configuration_details: Stripe.PaymentIntent.PaymentMethodConfigurationDetails | null;
428
- payment_method_options: Stripe.PaymentIntent.PaymentMethodOptions | null;
429
- payment_method_types: Array<string>;
430
- presentment_details?: Stripe.PaymentIntent.PresentmentDetails;
431
- processing: Stripe.PaymentIntent.Processing | null;
432
- receipt_email: string | null;
433
- review: string | Stripe.Review | null;
434
- setup_future_usage: Stripe.PaymentIntent.SetupFutureUsage | null;
435
- shipping: Stripe.PaymentIntent.Shipping | null;
436
- source: string | Stripe.CustomerSource | Stripe.DeletedCustomerSource | null;
437
- statement_descriptor: string | null;
438
- statement_descriptor_suffix: string | null;
439
- status: Stripe.PaymentIntent.Status;
440
- transfer_data: Stripe.PaymentIntent.TransferData | null;
441
- transfer_group: string | null;
442
- };
443
- lines: {
444
- product: {
445
- default_price: Stripe.Price;
446
- marketing_features: string[];
447
- metadata: {
448
- slug: string;
449
- stock: number;
450
- category?: string | undefined;
451
- order?: number | undefined;
452
- variant?: string | undefined;
453
- digitalAsset?: string | undefined;
454
- preview?: string | undefined;
455
- };
456
- id: string;
457
- object: "product";
458
- active: boolean;
459
- created: number;
460
- deleted?: void | undefined;
461
- description: string | null;
462
- images: Array<string>;
463
- livemode: boolean;
464
- name: string;
465
- package_dimensions: Stripe.Product.PackageDimensions | null;
466
- shippable: boolean | null;
467
- statement_descriptor?: string | null;
468
- tax_code: string | Stripe.TaxCode | null;
469
- type: Stripe.Product.Type;
470
- unit_label?: string | null;
471
- updated: number;
472
- url: string | null;
473
- };
474
- quantity: number;
475
- }[];
476
- shippingRate: Stripe.ShippingRate | null;
477
- } | null>;
478
- declare const getProductsFromCart: (metadata: CartMetadata) => (readonly [productId: string, quantity: number])[];
479
- declare function getProductsFromMetadata(metadata: MappedCart["metadata"]): Promise<{
480
- product: {
481
- default_price: Stripe.Price;
482
- marketing_features: string[];
483
- metadata: {
484
- slug: string;
485
- stock: number;
486
- category?: string | undefined;
487
- order?: number | undefined;
488
- variant?: string | undefined;
489
- digitalAsset?: string | undefined;
490
- preview?: string | undefined;
491
- };
492
- id: string;
493
- object: "product";
494
- active: boolean;
495
- created: number;
496
- deleted?: void | undefined;
497
- description: string | null;
498
- images: Array<string>;
499
- livemode: boolean;
500
- name: string;
501
- package_dimensions: Stripe.Product.PackageDimensions | null;
502
- shippable: boolean | null;
503
- statement_descriptor?: string | null;
504
- tax_code: string | Stripe.TaxCode | null;
505
- type: Stripe.Product.Type;
506
- unit_label?: string | null;
507
- updated: number;
508
- url: string | null;
509
- } | null;
510
- quantity: number;
511
- }[]>;
512
- type ProductsFromMetadata = Awaited<ReturnType<typeof getProductsFromMetadata>>;
513
- declare const getCartWithProductsById: (cartId: string) => Promise<{
514
- cart: {
515
- metadata: {
516
- shippingRateId?: string | undefined;
517
- taxCalculationId?: string | undefined;
518
- taxCalculationExp?: string | undefined;
519
- taxId?: string | undefined;
520
- couponCode?: string | undefined;
521
- taxedAmount?: string | undefined;
522
- "billingAddress.city"?: string | undefined;
523
- "billingAddress.country"?: string | undefined;
524
- "billingAddress.line1"?: string | undefined;
525
- "billingAddress.line2"?: string | undefined;
526
- "billingAddress.name"?: string | undefined;
527
- "billingAddress.postalCode"?: string | undefined;
528
- "billingAddress.state"?: string | undefined;
529
- netAmount?: string | undefined;
530
- taxBreakdown0?: string | undefined;
531
- taxBreakdown1?: string | undefined;
532
- taxBreakdown2?: string | undefined;
533
- taxBreakdown3?: string | undefined;
534
- taxBreakdown4?: string | undefined;
535
- taxBreakdown5?: string | undefined;
536
- } & Record<string, string>;
537
- customer: Stripe.Customer | null;
538
- payment_method: Stripe.PaymentMethod | null;
539
- taxBreakdown: {
540
- taxType: Stripe.Tax.Calculation.TaxBreakdown.TaxRateDetails.TaxType | (string & {});
541
- taxPercentage: string;
542
- taxAmount: number;
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
- description: string | null;
561
- excluded_payment_method_types: Array<Stripe.PaymentIntent.ExcludedPaymentMethodType> | null;
562
- last_payment_error: Stripe.PaymentIntent.LastPaymentError | null;
563
- latest_charge: string | Stripe.Charge | null;
564
- livemode: boolean;
565
- next_action: Stripe.PaymentIntent.NextAction | null;
566
- on_behalf_of: string | Stripe.Account | null;
567
- payment_method_configuration_details: Stripe.PaymentIntent.PaymentMethodConfigurationDetails | null;
568
- payment_method_options: Stripe.PaymentIntent.PaymentMethodOptions | null;
569
- payment_method_types: Array<string>;
570
- presentment_details?: Stripe.PaymentIntent.PresentmentDetails;
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
- stock: number;
590
- category?: string | undefined;
591
- order?: number | undefined;
592
- variant?: string | undefined;
593
- digitalAsset?: string | undefined;
594
- preview?: string | undefined;
595
- };
596
- id: string;
597
- object: "product";
598
- active: boolean;
599
- created: number;
600
- deleted?: void | undefined;
601
- description: string | null;
602
- images: Array<string>;
603
- livemode: boolean;
604
- name: string;
605
- package_dimensions: Stripe.Product.PackageDimensions | null;
606
- shippable: boolean | null;
607
- statement_descriptor?: string | null;
608
- tax_code: string | Stripe.TaxCode | null;
609
- type: Stripe.Product.Type;
610
- unit_label?: string | null;
611
- updated: number;
612
- url: string | null;
613
- };
614
- quantity: number;
615
- }[];
616
- shippingRate: Stripe.ShippingRate | null;
617
- } | null>;
618
- declare const calculateCartTotalNet: (cart: {
619
- cart: {
620
- amount: number;
621
- metadata?: {
622
- taxCalculationId?: string;
623
- };
624
- };
625
- lines: Array<{
626
- product: {
627
- default_price?: {
628
- unit_amount?: number | null;
629
- };
630
- };
631
- quantity: number;
632
- }>;
633
- shippingRate?: {
634
- fixed_amount?: {
635
- amount?: number;
636
- };
637
- } | null;
638
- }) => number;
639
- declare const getAddressSchema: (tr: {
640
- nameRequired: string;
641
- cityRequired: string;
642
- countryRequired: string;
643
- line1Required: string;
644
- postalCodeRequired: string;
645
- }) => z.ZodObject<{
646
- name: z.ZodString;
647
- city: z.ZodString;
648
- country: z.ZodString;
649
- line1: z.ZodString;
650
- line2: z.ZodDefault<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
651
- postalCode: z.ZodString;
652
- state: z.ZodDefault<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
653
- phone: z.ZodDefault<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
654
- taxId: z.ZodDefault<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
655
- email: z.ZodDefault<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
656
- }, z.core.$strip>;
657
- type AddressSchema = TypeOf<ReturnType<typeof getAddressSchema>>;
658
- /**
659
- * @internal
660
- */
661
- declare const updatePaymentIntent: ({ paymentIntentId, data, customerOverride, clearTaxCalculation, }: {
662
- paymentIntentId: string;
663
- data: Stripe.PaymentIntentUpdateParams;
664
- customerOverride?: Stripe.Customer;
665
- clearTaxCalculation?: boolean;
666
- }) => Promise<Stripe.Response<Stripe.PaymentIntent>>;
667
- declare const calculateCartTotalPossiblyWithTax: (cart: {
668
- cart: {
669
- amount: number;
670
- metadata?: {
671
- taxCalculationId?: string;
672
- };
673
- };
674
- lines: Array<{
675
- product: {
676
- default_price?: {
677
- unit_amount?: number | null;
678
- };
679
- };
680
- quantity: number;
681
- }>;
682
- shippingRate?: {
683
- fixed_amount?: {
684
- amount?: number;
685
- };
686
- } | null;
687
- }) => number;
688
- declare const calculateCartTotalNetWithoutShipping: (cart: {
689
- cart: {
690
- amount: number;
691
- metadata?: {
692
- taxCalculationId?: string;
693
- };
694
- };
695
- lines: Array<{
696
- product: {
697
- default_price?: {
698
- unit_amount?: number | null;
699
- };
700
- };
701
- quantity: number;
702
- }>;
703
- shippingRate?: {
704
- fixed_amount?: {
705
- amount?: number;
706
- };
707
- } | null;
708
- }) => number;
709
- declare function cartChangeQuantity({ productId, cartId, operation, clearTaxCalculation, }: {
710
- productId: string;
711
- cartId: string;
712
- operation: "INCREASE" | "DECREASE";
713
- clearTaxCalculation?: boolean;
714
- }): Promise<Stripe.Response<Stripe.PaymentIntent> | undefined>;
715
- declare const cartSaveEmail: ({ cartId, email }: {
716
- cartId: string;
717
- email: string;
718
- }) => Promise<Stripe.Response<Stripe.PaymentIntent> | undefined>;
719
- declare const cartSaveTax: ({ cartId, taxId }: {
720
- cartId: string;
721
- taxId: string;
722
- }) => Promise<Stripe.Response<Stripe.PaymentIntent> | undefined>;
723
- declare function cartSaveShipping({ cartId, shippingRateId, }: {
724
- cartId: string;
725
- shippingRateId: string;
726
- }): Promise<Stripe.Response<Stripe.PaymentIntent> | undefined>;
727
- declare function cartSaveBillingAddress({ cartId, billingAddress, }: {
728
- cartId: string;
729
- billingAddress: AddressSchema;
730
- }): Promise<Stripe.Response<Stripe.PaymentIntent> | undefined>;
731
- declare function taxDefaultGet(): Promise<Stripe.Response<Stripe.Tax.Settings>>;
732
- declare function cartCount(metadata: CartMetadata): number;
733
- type Review = {
734
- id: string;
735
- store_id: string;
736
- product_id: string;
737
- created_at: string;
738
- updated_at: string;
739
- author: string;
740
- email: string;
741
- content: string;
742
- rating: number;
743
- };
744
- declare function productReviewBrowse(params: {
745
- productId: string;
746
- first?: number;
747
- last?: number;
748
- offset?: number;
749
- filter?: Record<string, never>;
750
- }): Promise<Review[] | null>;
751
- declare function productReviewAdd(params: {
752
- productId: string;
753
- author: string;
754
- email: string;
755
- content: string;
756
- rating: number;
757
- }): Promise<Record<string, any>[] | null>;
758
- declare const contextGet: () => Promise<{
759
- stripeAccount: string | undefined;
760
- storeId: string | undefined;
761
- secretKey: string | undefined;
762
- publishableKey: string | undefined;
763
- }>;
764
-
765
- interface BaseProvider {
766
- productBrowse(params: ProductBrowseParams): Promise<ProductBrowseResult>;
767
- productGet(params: ProductGetParams): Promise<Product | null>;
768
- productSearch?(params: ProductSearchParams): Promise<ProductSearchResult>;
769
- cartAdd(params: CartAddParams): Promise<{
770
- cartId: string;
771
- }>;
772
- cartUpdate(params: CartUpdateParams): Promise<{
773
- cartId: string;
774
- }>;
775
- cartClear(params: CartClearParams): Promise<{
776
- cartId: string;
777
- }>;
778
- cartGet(params: CartGetParams): Promise<Cart | null>;
779
- orderGet?(params: OrderGetParams): Promise<Order | null>;
780
- orderList?(params: OrderListParams): Promise<OrderListResult>;
781
- }
782
- interface StripeProviderConfig {
783
- secretKey?: string;
784
- tagPrefix?: string;
785
- }
786
- interface YnsProviderConfig {
787
- endpoint: string;
788
- token: string;
789
- }
790
- interface CommerceConfig {
791
- provider: "stripe" | "yns";
792
- stripe?: StripeProviderConfig;
793
- yns?: YnsProviderConfig;
794
- }
795
- interface Product {
796
- id: string;
797
- name: string;
798
- slug?: string;
799
- summary?: string;
800
- images: string[];
801
- active: boolean;
802
- price: number;
803
- currency: string;
804
- stock?: number;
805
- }
806
- interface Cart {
807
- id: string;
808
- customerId?: string;
809
- items: CartItem[];
810
- total: number;
811
- currency: string;
812
- createdAt: string;
813
- updatedAt: string;
814
- }
815
- interface CartItem {
816
- id: string;
817
- productId: string;
818
- variantId?: string;
819
- quantity: number;
820
- price: number;
821
- }
822
- interface Order {
823
- id: string;
824
- customerId?: string;
825
- items: CartItem[];
826
- total: number;
827
- currency: string;
828
- status: string;
829
- createdAt: string;
830
- updatedAt: string;
831
- }
832
- interface ProductBrowseParams {
833
- first?: number;
834
- offset?: number;
835
- category?: string;
836
- query?: string;
837
- active?: boolean;
838
- orderBy?: string;
839
- orderDirection?: "asc" | "desc";
840
- fields?: string[];
841
- _provider?: "stripe" | "yns";
842
- }
843
- interface ProductGetParams {
844
- slug?: string;
845
- id?: string;
846
- fields?: string[];
847
- _provider?: "stripe" | "yns";
848
- }
849
- interface ProductSearchParams {
850
- query: string;
851
- limit?: number;
852
- fields?: string[];
853
- _provider?: "stripe" | "yns";
854
- }
855
- interface CartAddParams {
856
- variantId: string;
857
- cartId?: string;
858
- quantity?: number;
859
- subscriptionId?: string;
860
- _provider?: "stripe" | "yns";
861
- }
862
- interface CartUpdateParams {
863
- cartId: string;
864
- variantId: string;
865
- quantity: number;
866
- _provider?: "stripe" | "yns";
867
- }
868
- interface CartClearParams {
869
- cartId: string;
870
- _provider?: "stripe" | "yns";
871
- }
872
- interface CartGetParams {
873
- cartId: string;
874
- _provider?: "stripe" | "yns";
875
- }
876
- interface OrderGetParams {
877
- orderId: string;
878
- _provider?: "stripe" | "yns";
879
- }
880
- interface OrderListParams {
881
- customerId?: string;
882
- limit?: number;
883
- offset?: number;
884
- _provider?: "stripe" | "yns";
885
- }
886
- interface ProductBrowseResult {
887
- data: Product[];
888
- meta: {
889
- count: number;
890
- offset: number;
891
- limit: number;
892
- hasMore: boolean;
893
- };
894
- }
895
- interface ProductSearchResult {
896
- data: Product[];
897
- total: number;
898
- }
899
- interface OrderListResult {
900
- data: Order[];
901
- meta: {
902
- count: number;
903
- offset: number;
904
- limit: number;
905
- hasMore: boolean;
906
- };
907
- }
908
-
909
- /**
910
- * Configure the Commerce SDK with provider settings
911
- */
912
- declare function configure(config: CommerceConfig): void;
913
-
914
- /**
915
- * Cart resource operations
916
- */
917
- declare const cart: {
918
- /**
919
- * Add item to cart
920
- *
921
- * @example
922
- * ```typescript
923
- * import { cart } from "commerce-kit";
924
- *
925
- * // Add to existing cart
926
- * const result = await cart.add({
927
- * variantId: "variant_123",
928
- * cartId: "cart_abc",
929
- * quantity: 2
930
- * });
931
- *
932
- * // Create new cart if no cartId provided
933
- * const newCart = await cart.add({
934
- * variantId: "variant_456"
935
- * });
936
- *
937
- * // Override provider
938
- * const stripeCart = await cart.add({
939
- * variantId: "price_123",
940
- * cartId: "pi_456",
941
- * _provider: "stripe"
942
- * });
943
- * ```
944
- */
945
- add(params: CartAddParams): Promise<{
946
- cartId: string;
947
- }>;
948
- /**
949
- * Update item quantity in cart
950
- *
951
- * @example
952
- * ```typescript
953
- * import { cart } from "commerce-kit";
954
- *
955
- * // Update quantity
956
- * const result = await cart.update({
957
- * cartId: "cart_123",
958
- * variantId: "variant_456",
959
- * quantity: 3
960
- * });
961
- *
962
- * // Set quantity to 0 to remove item
963
- * const removed = await cart.update({
964
- * cartId: "cart_123",
965
- * variantId: "variant_456",
966
- * quantity: 0
967
- * });
968
- * ```
969
- */
970
- update(params: CartUpdateParams): Promise<{
971
- cartId: string;
972
- }>;
973
- /**
974
- * Clear all items from cart
975
- *
976
- * @example
977
- * ```typescript
978
- * import { cart } from "commerce-kit";
979
- *
980
- * const result = await cart.clear({
981
- * cartId: "cart_123"
982
- * });
983
- * ```
984
- */
985
- clear(params: CartClearParams): Promise<{
986
- cartId: string;
987
- }>;
988
- /**
989
- * Get cart details with all items
990
- *
991
- * @example
992
- * ```typescript
993
- * import { cart } from "commerce-kit";
994
- *
995
- * const cartData = await cart.get({
996
- * cartId: "cart_123"
997
- * });
998
- *
999
- * if (cartData) {
1000
- * console.log(`Cart has ${cartData.items.length} items`);
1001
- * console.log(`Total: ${cartData.total} ${cartData.currency}`);
1002
- * }
1003
- * ```
1004
- */
1005
- get(params: CartGetParams): Promise<Cart | null>;
1006
- };
1007
-
1008
- /**
1009
- * Order resource operations
1010
- */
1011
- declare const order: {
1012
- /**
1013
- * Get a single order by ID
1014
- *
1015
- * @example
1016
- * ```typescript
1017
- * import { order } from "commerce-kit";
1018
- *
1019
- * const orderData = await order.get({
1020
- * orderId: "order_123"
1021
- * });
1022
- *
1023
- * if (orderData) {
1024
- * console.log(`Order status: ${orderData.status}`);
1025
- * console.log(`Order total: ${orderData.total} ${orderData.currency}`);
1026
- * }
1027
- * ```
1028
- */
1029
- get(params: OrderGetParams): Promise<Order | null>;
1030
- /**
1031
- * List orders with optional filtering and pagination
1032
- *
1033
- * @example
1034
- * ```typescript
1035
- * import { order } from "commerce-kit";
1036
- *
1037
- * // List all orders
1038
- * const orders = await order.list({
1039
- * limit: 20,
1040
- * offset: 0
1041
- * });
1042
- *
1043
- * // List orders for specific customer
1044
- * const customerOrders = await order.list({
1045
- * customerId: "customer_123",
1046
- * limit: 10
1047
- * });
1048
- *
1049
- * console.log(`Found ${orders.meta.count} orders`);
1050
- * ```
1051
- */
1052
- list(params?: OrderListParams): Promise<OrderListResult>;
1053
- };
1054
-
1055
- /**
1056
- * Product resource operations
1057
- */
1058
- declare const product: {
1059
- /**
1060
- * Browse/list products with optional filtering and pagination
1061
- *
1062
- * @example
1063
- * ```typescript
1064
- * import { product } from "commerce-kit";
1065
- *
1066
- * const products = await product.browse({
1067
- * first: 10,
1068
- * category: "electronics"
1069
- * });
1070
- *
1071
- * // With GraphQL field selection (YNS only)
1072
- * const productsWithFields = await product.browse({
1073
- * first: 5,
1074
- * fields: ["id", "name", "price", "images"]
1075
- * });
1076
- *
1077
- * // Override provider for specific call
1078
- * const stripeProducts = await product.browse({
1079
- * first: 10,
1080
- * _provider: "stripe"
1081
- * });
1082
- * ```
1083
- */
1084
- browse(params?: ProductBrowseParams): Promise<ProductBrowseResult>;
1085
- /**
1086
- * Get a single product by slug or ID
1087
- *
1088
- * @example
1089
- * ```typescript
1090
- * import { product } from "commerce-kit";
1091
- *
1092
- * const productData = await product.get({ slug: "awesome-product" });
1093
- *
1094
- * // With GraphQL field selection (YNS only)
1095
- * const productWithFields = await product.get({
1096
- * slug: "awesome-product",
1097
- * fields: ["id", "name", "price", "category.name"]
1098
- * });
1099
- *
1100
- * // Get by ID instead of slug
1101
- * const productById = await product.get({ id: "prod_123" });
1102
- * ```
1103
- */
1104
- get(params: ProductGetParams): Promise<Product | null>;
1105
- /**
1106
- * Search products by query string
1107
- *
1108
- * @example
1109
- * ```typescript
1110
- * import { product } from "commerce-kit";
1111
- *
1112
- * const searchResults = await product.search({
1113
- * query: "laptop computer",
1114
- * limit: 20
1115
- * });
1116
- *
1117
- * // With field selection
1118
- * const searchWithFields = await product.search({
1119
- * query: "smartphone",
1120
- * fields: ["id", "name", "price"],
1121
- * limit: 10
1122
- * });
1123
- * ```
1124
- */
1125
- search(params: ProductSearchParams): Promise<ProductSearchResult>;
1126
- };
1127
-
1128
- declare const provider: ({ tags, revalidate, cache, tagPrefix, secretKey, }: {
1129
- tags?: NextFetchRequestConfig["tags"];
1130
- revalidate?: NextFetchRequestConfig["revalidate"];
1131
- cache?: RequestInit["cache"];
1132
- tagPrefix: string | undefined;
1133
- secretKey: string | undefined;
1134
- }) => Stripe;
1135
-
1136
- /**
1137
- * Create a scoped Commerce instance with a specific provider
1138
- *
1139
- * @example
1140
- * ```typescript
1141
- * import { withProvider } from "commerce-kit";
1142
- *
1143
- * const ynsCommerce = withProvider("yns");
1144
- * const stripeCommerce = withProvider("stripe");
1145
- *
1146
- * const ynsProducts = await ynsCommerce.product.browse({ first: 10 });
1147
- * const stripeProducts = await stripeCommerce.product.browse({ first: 10 });
1148
- * ```
1149
- */
1150
- declare function withProvider(provider: "stripe" | "yns"): {
1151
- product: {
1152
- browse(params: any): Promise<ProductBrowseResult>;
1153
- get(params: any): Promise<Product | null>;
1154
- search(params: any): Promise<ProductSearchResult>;
1155
- };
1156
- cart: {
1157
- add(params: any): Promise<{
1158
- cartId: string;
1159
- }>;
1160
- update(params: any): Promise<{
1161
- cartId: string;
1162
- }>;
1163
- clear(params: any): Promise<{
1164
- cartId: string;
1165
- }>;
1166
- get(params: any): Promise<Cart | null>;
1167
- };
1168
- order: {
1169
- get(params: any): Promise<Order | null>;
1170
- list(params?: any): Promise<OrderListResult>;
1171
- };
1172
- };
1173
-
1174
- export { type AddressSchema, type BaseProvider, type Cart$1 as Cart, type CartAddParams, type CartClearParams, type CartGetParams, type CartUpdateParams, type Cart as CommerceCart, type CartItem as CommerceCartItem, type CommerceConfig, type Order as CommerceOrder, MappedCart, type Order$1 as Order, type Product, type ProductBrowseParams, type ProductGetParams, type ProductsFromMetadata, accountGet, calculateCartTotalNet, calculateCartTotalNetWithoutShipping, calculateCartTotalPossiblyWithTax, cart, cartAdd, cartAddOptimistic, cartChangeQuantity, cartCount, cartCreate, cartGet, cartSaveBillingAddress, cartSaveEmail, cartSaveShipping, cartSaveTax, cartSetQuantity, cartUpdateQuantity, categoryBrowse, configure, contextGet, fileGet, getAddressSchema, getCartWithProductsById, getProductsFromCart, getProductsFromMetadata, order, orderGet, product, productBrowse, productGet, productGetById, productReviewAdd, productReviewBrowse, provider, shippingBrowse, shippingGet, taxDefaultGet, updatePaymentIntent, withProvider };
2
+ export { MappedCart, MappedProduct, MappedShippingRate } from './internal.js';
3
+ export { B as BaseProvider, C as Cart, a as CartAddParams, b as CartClearParams, c as CartGetParams, d as CartItem, e as CartUpdateParams, O as Order, f as OrderGetParams, g as OrderListParams, h as OrderListResult, P as Product, i as ProductBrowseParams, j as ProductBrowseResult, k as ProductGetParams, l as ProductSearchParams, m as ProductSearchResult, S as StripeProviderConfig, Y as YnsProviderConfig } from './provider-Co3VegT-.js';
4
+ export { Commerce } from './yns.js';
5
+ import 'stripe';
6
+ import 'zod';