@reponseai/sdk 0.2.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.
@@ -0,0 +1,1131 @@
1
+ type ClientOptions$1 = {
2
+ baseUrl: 'https://api.reponse.ai' | (string & {});
3
+ };
4
+ type ProductVariant = {
5
+ id: string;
6
+ title: string;
7
+ price: number | null;
8
+ compare_at_price: number | null;
9
+ inventory_quantity: number;
10
+ sku: string | null;
11
+ option_values: Array<string> | null;
12
+ };
13
+ type Product = {
14
+ id: string;
15
+ title: string;
16
+ slug: string | null;
17
+ description: string | null;
18
+ seo_title: string | null;
19
+ seo_description: string | null;
20
+ price: number;
21
+ compare_at_price: number | null;
22
+ currency: string;
23
+ in_stock: boolean;
24
+ images: Array<string>;
25
+ status: 'active' | 'draft' | 'archived';
26
+ variants?: Array<ProductVariant>;
27
+ created_at: string;
28
+ updated_at: string;
29
+ };
30
+ type ProductListResponse = {
31
+ data: Array<Product>;
32
+ next_cursor: string | null;
33
+ has_more: boolean;
34
+ };
35
+ type Collection = {
36
+ id: string;
37
+ title: string;
38
+ description: string | null;
39
+ };
40
+ type CollectionListResponse = {
41
+ data: Array<Collection>;
42
+ };
43
+ type Cart = {
44
+ id: string;
45
+ items: Array<{
46
+ id: string;
47
+ product_id: string;
48
+ variant_id?: string;
49
+ quantity: number;
50
+ price: number;
51
+ }>;
52
+ subtotal: number;
53
+ currency: string;
54
+ created_at: string;
55
+ updated_at: string;
56
+ };
57
+ type CreateCartInput = {
58
+ items?: Array<{
59
+ product_id: string;
60
+ variant_id?: string;
61
+ quantity: number;
62
+ }>;
63
+ currency?: string;
64
+ };
65
+ type CheckoutSession = {
66
+ url: string;
67
+ };
68
+ type CreateCheckoutInput = {
69
+ cart_id: string;
70
+ success_url?: string;
71
+ cancel_url?: string;
72
+ };
73
+ type AddCartItemInput = {
74
+ product_id: string;
75
+ variant_id?: string;
76
+ quantity?: number;
77
+ };
78
+ type UpdateCartItemInput = {
79
+ /**
80
+ * New quantity. Set to 0 to remove item.
81
+ */
82
+ quantity: number;
83
+ };
84
+ type GetV1ProductsData = {
85
+ body?: never;
86
+ path?: never;
87
+ query?: {
88
+ /**
89
+ * Number of items to return
90
+ */
91
+ limit?: number;
92
+ /**
93
+ * Cursor for pagination
94
+ */
95
+ cursor?: string;
96
+ /**
97
+ * Search query
98
+ */
99
+ query?: string;
100
+ /**
101
+ * Filter by slug (handle)
102
+ */
103
+ slug?: string;
104
+ };
105
+ url: '/v1/products';
106
+ };
107
+ type GetV1ProductsResponses = {
108
+ /**
109
+ * A list of products
110
+ */
111
+ 200: ProductListResponse;
112
+ };
113
+ type GetV1ProductsResponse = GetV1ProductsResponses[keyof GetV1ProductsResponses];
114
+ type GetV1ProductsByIdData = {
115
+ body?: never;
116
+ path: {
117
+ /**
118
+ * Product ID
119
+ */
120
+ id: string;
121
+ };
122
+ query?: never;
123
+ url: '/v1/products/{id}';
124
+ };
125
+ type GetV1ProductsByIdErrors = {
126
+ /**
127
+ * Product not found
128
+ */
129
+ 404: unknown;
130
+ };
131
+ type GetV1ProductsByIdResponses = {
132
+ /**
133
+ * The product
134
+ */
135
+ 200: Product;
136
+ };
137
+ type GetV1ProductsByIdResponse = GetV1ProductsByIdResponses[keyof GetV1ProductsByIdResponses];
138
+ type PostV1CartsData = {
139
+ body?: CreateCartInput;
140
+ path?: never;
141
+ query?: never;
142
+ url: '/v1/carts';
143
+ };
144
+ type PostV1CartsResponses = {
145
+ /**
146
+ * The created cart
147
+ */
148
+ 201: Cart;
149
+ };
150
+ type PostV1CartsResponse = PostV1CartsResponses[keyof PostV1CartsResponses];
151
+ type GetV1CartsByIdData = {
152
+ body?: never;
153
+ path: {
154
+ /**
155
+ * Cart ID
156
+ */
157
+ id: string;
158
+ };
159
+ query?: never;
160
+ url: '/v1/carts/{id}';
161
+ };
162
+ type GetV1CartsByIdErrors = {
163
+ /**
164
+ * Cart not found
165
+ */
166
+ 404: unknown;
167
+ };
168
+ type GetV1CartsByIdResponses = {
169
+ /**
170
+ * The cart
171
+ */
172
+ 200: Cart;
173
+ };
174
+ type GetV1CartsByIdResponse = GetV1CartsByIdResponses[keyof GetV1CartsByIdResponses];
175
+ type PostV1CartsByIdItemsData = {
176
+ body?: {
177
+ /**
178
+ * Items to add to cart
179
+ */
180
+ items: Array<{
181
+ product_id: string;
182
+ variant_id?: string;
183
+ quantity?: number;
184
+ }>;
185
+ };
186
+ path: {
187
+ /**
188
+ * Cart ID
189
+ */
190
+ id: string;
191
+ };
192
+ query?: never;
193
+ url: '/v1/carts/{id}/items';
194
+ };
195
+ type PostV1CartsByIdItemsErrors = {
196
+ /**
197
+ * Bad request (e.g. variant_id required)
198
+ */
199
+ 400: unknown;
200
+ /**
201
+ * Cart not found
202
+ */
203
+ 404: unknown;
204
+ };
205
+ type PostV1CartsByIdItemsResponses = {
206
+ /**
207
+ * Success
208
+ */
209
+ 200: unknown;
210
+ };
211
+ type DeleteV1CartsByIdItemsByLineIdData = {
212
+ body?: never;
213
+ path: {
214
+ /**
215
+ * Cart ID
216
+ */
217
+ id: string;
218
+ /**
219
+ * Line Item ID
220
+ */
221
+ lineId: string;
222
+ };
223
+ query?: never;
224
+ url: '/v1/carts/{id}/items/{lineId}';
225
+ };
226
+ type DeleteV1CartsByIdItemsByLineIdErrors = {
227
+ /**
228
+ * Cart not found
229
+ */
230
+ 404: unknown;
231
+ };
232
+ type DeleteV1CartsByIdItemsByLineIdResponses = {
233
+ /**
234
+ * Success
235
+ */
236
+ 200: unknown;
237
+ };
238
+ type PutV1CartsByIdItemsByLineIdData = {
239
+ body?: {
240
+ /**
241
+ * New quantity (0 to delete)
242
+ */
243
+ quantity: number;
244
+ };
245
+ path: {
246
+ /**
247
+ * Cart ID
248
+ */
249
+ id: string;
250
+ /**
251
+ * Line Item ID
252
+ */
253
+ lineId: string;
254
+ };
255
+ query?: never;
256
+ url: '/v1/carts/{id}/items/{lineId}';
257
+ };
258
+ type PutV1CartsByIdItemsByLineIdErrors = {
259
+ /**
260
+ * Invalid quantity
261
+ */
262
+ 400: unknown;
263
+ /**
264
+ * Cart not found
265
+ */
266
+ 404: unknown;
267
+ };
268
+ type PutV1CartsByIdItemsByLineIdResponses = {
269
+ /**
270
+ * Success
271
+ */
272
+ 200: unknown;
273
+ };
274
+ type PatchV1OrdersByOrderIdShippingAddressData = {
275
+ body?: {
276
+ shipping_address: {
277
+ address1: string;
278
+ address2?: string;
279
+ city: string;
280
+ zip: string;
281
+ country: string;
282
+ };
283
+ /**
284
+ * Optional conversation ID for B2C conversational security
285
+ */
286
+ conversation_id?: string;
287
+ };
288
+ path: {
289
+ /**
290
+ * Order ID
291
+ */
292
+ orderId: string;
293
+ };
294
+ query?: never;
295
+ url: '/v1/orders/{orderId}/shipping-address';
296
+ };
297
+ type PatchV1OrdersByOrderIdShippingAddressErrors = {
298
+ /**
299
+ * Bad request or business rule validation failed (e.g., order already shipped)
300
+ */
301
+ 400: unknown;
302
+ /**
303
+ * Forbidden - B2C identity verification failed
304
+ */
305
+ 403: unknown;
306
+ /**
307
+ * Order not found
308
+ */
309
+ 404: unknown;
310
+ };
311
+ type PatchV1OrdersByOrderIdShippingAddressResponses = {
312
+ /**
313
+ * The updated order
314
+ */
315
+ 200: {
316
+ success: boolean;
317
+ confirmation_message?: string;
318
+ notify_merchant?: boolean;
319
+ event_id?: string;
320
+ };
321
+ };
322
+ type PatchV1OrdersByOrderIdShippingAddressResponse = PatchV1OrdersByOrderIdShippingAddressResponses[keyof PatchV1OrdersByOrderIdShippingAddressResponses];
323
+ type PostV1OrdersByOrderIdResendConfirmationData = {
324
+ body?: {
325
+ /**
326
+ * Optional conversation ID for B2C conversational security
327
+ */
328
+ conversation_id?: string;
329
+ };
330
+ path: {
331
+ /**
332
+ * Order ID
333
+ */
334
+ orderId: string;
335
+ };
336
+ query?: never;
337
+ url: '/v1/orders/{orderId}/resend-confirmation';
338
+ };
339
+ type PostV1OrdersByOrderIdResendConfirmationErrors = {
340
+ /**
341
+ * Bad request or business validation failed
342
+ */
343
+ 400: unknown;
344
+ /**
345
+ * Forbidden - Identity not verified
346
+ */
347
+ 403: unknown;
348
+ /**
349
+ * Order not found
350
+ */
351
+ 404: unknown;
352
+ /**
353
+ * Too many requests (rate limited)
354
+ */
355
+ 429: unknown;
356
+ };
357
+ type PostV1OrdersByOrderIdResendConfirmationResponses = {
358
+ /**
359
+ * Confirmation sent
360
+ */
361
+ 200: {
362
+ success: boolean;
363
+ confirmation_message?: string;
364
+ event_id?: string;
365
+ };
366
+ };
367
+ type PostV1OrdersByOrderIdResendConfirmationResponse = PostV1OrdersByOrderIdResendConfirmationResponses[keyof PostV1OrdersByOrderIdResendConfirmationResponses];
368
+ type PostV1OrdersByOrderIdResendInvoiceData = {
369
+ body?: {
370
+ /**
371
+ * Optional conversation ID for B2C conversational security
372
+ */
373
+ conversation_id?: string;
374
+ };
375
+ path: {
376
+ /**
377
+ * Order ID
378
+ */
379
+ orderId: string;
380
+ };
381
+ query?: never;
382
+ url: '/v1/orders/{orderId}/resend-invoice';
383
+ };
384
+ type PostV1OrdersByOrderIdResendInvoiceErrors = {
385
+ /**
386
+ * Bad request or invoice is generating
387
+ */
388
+ 400: unknown;
389
+ /**
390
+ * Forbidden - Identity not verified
391
+ */
392
+ 403: unknown;
393
+ /**
394
+ * Invoice or Order not found
395
+ */
396
+ 404: unknown;
397
+ /**
398
+ * Too many requests (rate limited)
399
+ */
400
+ 429: unknown;
401
+ /**
402
+ * Invoice generation failed
403
+ */
404
+ 500: unknown;
405
+ };
406
+ type PostV1OrdersByOrderIdResendInvoiceResponses = {
407
+ /**
408
+ * Invoice sent
409
+ */
410
+ 200: {
411
+ success: boolean;
412
+ confirmation_message?: string;
413
+ event_id?: string;
414
+ };
415
+ };
416
+ type PostV1OrdersByOrderIdResendInvoiceResponse = PostV1OrdersByOrderIdResendInvoiceResponses[keyof PostV1OrdersByOrderIdResendInvoiceResponses];
417
+ type PostV1OrdersByOrderIdCancelData = {
418
+ body?: {
419
+ /**
420
+ * Optional conversation ID
421
+ */
422
+ conversation_id?: string;
423
+ /**
424
+ * Reason for cancellation
425
+ */
426
+ reason: 'customer_changed_mind' | 'wrong_item_ordered' | 'delivery_too_slow_anticipated' | 'found_better_price' | 'payment_issue' | 'other';
427
+ /**
428
+ * Custom reason if reason is other
429
+ */
430
+ custom_reason?: string;
431
+ };
432
+ path: {
433
+ /**
434
+ * Order ID
435
+ */
436
+ orderId: string;
437
+ };
438
+ query?: never;
439
+ url: '/v1/orders/{orderId}/cancel';
440
+ };
441
+ type PostV1OrdersByOrderIdCancelErrors = {
442
+ /**
443
+ * Bad request or business validation failed
444
+ */
445
+ 400: unknown;
446
+ /**
447
+ * Forbidden - Identity not verified
448
+ */
449
+ 403: unknown;
450
+ /**
451
+ * Order not found
452
+ */
453
+ 404: unknown;
454
+ /**
455
+ * Too many requests (rate limited) or abuse detected
456
+ */
457
+ 429: unknown;
458
+ /**
459
+ * Stripe refund failed or internal error
460
+ */
461
+ 500: unknown;
462
+ };
463
+ type PostV1OrdersByOrderIdCancelResponses = {
464
+ /**
465
+ * Order cancelled successfully
466
+ */
467
+ 200: unknown;
468
+ };
469
+ type GetV1CollectionsData = {
470
+ body?: never;
471
+ path?: never;
472
+ query?: {
473
+ /**
474
+ * Number of items to return
475
+ */
476
+ limit?: number;
477
+ };
478
+ url: '/v1/collections';
479
+ };
480
+ type GetV1CollectionsResponses = {
481
+ /**
482
+ * A list of collections
483
+ */
484
+ 200: CollectionListResponse;
485
+ };
486
+ type GetV1CollectionsResponse = GetV1CollectionsResponses[keyof GetV1CollectionsResponses];
487
+ type PostV1CheckoutStripeData = {
488
+ body?: CreateCheckoutInput;
489
+ path?: never;
490
+ query?: never;
491
+ url: '/v1/checkout/stripe';
492
+ };
493
+ type PostV1CheckoutStripeResponses = {
494
+ /**
495
+ * The checkout session URL
496
+ */
497
+ 200: CheckoutSession;
498
+ };
499
+ type PostV1CheckoutStripeResponse = PostV1CheckoutStripeResponses[keyof PostV1CheckoutStripeResponses];
500
+
501
+ type AuthToken = string | undefined;
502
+ interface Auth {
503
+ /**
504
+ * Which part of the request do we use to send the auth?
505
+ *
506
+ * @default 'header'
507
+ */
508
+ in?: 'header' | 'query' | 'cookie';
509
+ /**
510
+ * Header or query parameter name.
511
+ *
512
+ * @default 'Authorization'
513
+ */
514
+ name?: string;
515
+ scheme?: 'basic' | 'bearer';
516
+ type: 'apiKey' | 'http';
517
+ }
518
+
519
+ interface SerializerOptions<T> {
520
+ /**
521
+ * @default true
522
+ */
523
+ explode: boolean;
524
+ style: T;
525
+ }
526
+ type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited';
527
+ type ObjectStyle = 'form' | 'deepObject';
528
+
529
+ type QuerySerializer = (query: Record<string, unknown>) => string;
530
+ type BodySerializer = (body: unknown) => unknown;
531
+ type QuerySerializerOptionsObject = {
532
+ allowReserved?: boolean;
533
+ array?: Partial<SerializerOptions<ArrayStyle>>;
534
+ object?: Partial<SerializerOptions<ObjectStyle>>;
535
+ };
536
+ type QuerySerializerOptions = QuerySerializerOptionsObject & {
537
+ /**
538
+ * Per-parameter serialization overrides. When provided, these settings
539
+ * override the global array/object settings for specific parameter names.
540
+ */
541
+ parameters?: Record<string, QuerySerializerOptionsObject>;
542
+ };
543
+
544
+ type HttpMethod = 'connect' | 'delete' | 'get' | 'head' | 'options' | 'patch' | 'post' | 'put' | 'trace';
545
+ type Client$1<RequestFn = never, Config = unknown, MethodFn = never, BuildUrlFn = never, SseFn = never> = {
546
+ /**
547
+ * Returns the final request URL.
548
+ */
549
+ buildUrl: BuildUrlFn;
550
+ getConfig: () => Config;
551
+ request: RequestFn;
552
+ setConfig: (config: Config) => Config;
553
+ } & {
554
+ [K in HttpMethod]: MethodFn;
555
+ } & ([SseFn] extends [never] ? {
556
+ sse?: never;
557
+ } : {
558
+ sse: {
559
+ [K in HttpMethod]: SseFn;
560
+ };
561
+ });
562
+ interface Config$1 {
563
+ /**
564
+ * Auth token or a function returning auth token. The resolved value will be
565
+ * added to the request payload as defined by its `security` array.
566
+ */
567
+ auth?: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken;
568
+ /**
569
+ * A function for serializing request body parameter. By default,
570
+ * {@link JSON.stringify()} will be used.
571
+ */
572
+ bodySerializer?: BodySerializer | null;
573
+ /**
574
+ * An object containing any HTTP headers that you want to pre-populate your
575
+ * `Headers` object with.
576
+ *
577
+ * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more}
578
+ */
579
+ headers?: RequestInit['headers'] | Record<string, string | number | boolean | (string | number | boolean)[] | null | undefined | unknown>;
580
+ /**
581
+ * The request method.
582
+ *
583
+ * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more}
584
+ */
585
+ method?: Uppercase<HttpMethod>;
586
+ /**
587
+ * A function for serializing request query parameters. By default, arrays
588
+ * will be exploded in form style, objects will be exploded in deepObject
589
+ * style, and reserved characters are percent-encoded.
590
+ *
591
+ * This method will have no effect if the native `paramsSerializer()` Axios
592
+ * API function is used.
593
+ *
594
+ * {@link https://swagger.io/docs/specification/serialization/#query View examples}
595
+ */
596
+ querySerializer?: QuerySerializer | QuerySerializerOptions;
597
+ /**
598
+ * A function validating request data. This is useful if you want to ensure
599
+ * the request conforms to the desired shape, so it can be safely sent to
600
+ * the server.
601
+ */
602
+ requestValidator?: (data: unknown) => Promise<unknown>;
603
+ /**
604
+ * A function transforming response data before it's returned. This is useful
605
+ * for post-processing data, e.g., converting ISO strings into Date objects.
606
+ */
607
+ responseTransformer?: (data: unknown) => Promise<unknown>;
608
+ /**
609
+ * A function validating response data. This is useful if you want to ensure
610
+ * the response conforms to the desired shape, so it can be safely passed to
611
+ * the transformers and returned to the user.
612
+ */
613
+ responseValidator?: (data: unknown) => Promise<unknown>;
614
+ }
615
+
616
+ type ServerSentEventsOptions<TData = unknown> = Omit<RequestInit, 'method'> & Pick<Config$1, 'method' | 'responseTransformer' | 'responseValidator'> & {
617
+ /**
618
+ * Fetch API implementation. You can use this option to provide a custom
619
+ * fetch instance.
620
+ *
621
+ * @default globalThis.fetch
622
+ */
623
+ fetch?: typeof fetch;
624
+ /**
625
+ * Implementing clients can call request interceptors inside this hook.
626
+ */
627
+ onRequest?: (url: string, init: RequestInit) => Promise<Request>;
628
+ /**
629
+ * Callback invoked when a network or parsing error occurs during streaming.
630
+ *
631
+ * This option applies only if the endpoint returns a stream of events.
632
+ *
633
+ * @param error The error that occurred.
634
+ */
635
+ onSseError?: (error: unknown) => void;
636
+ /**
637
+ * Callback invoked when an event is streamed from the server.
638
+ *
639
+ * This option applies only if the endpoint returns a stream of events.
640
+ *
641
+ * @param event Event streamed from the server.
642
+ * @returns Nothing (void).
643
+ */
644
+ onSseEvent?: (event: StreamEvent<TData>) => void;
645
+ serializedBody?: RequestInit['body'];
646
+ /**
647
+ * Default retry delay in milliseconds.
648
+ *
649
+ * This option applies only if the endpoint returns a stream of events.
650
+ *
651
+ * @default 3000
652
+ */
653
+ sseDefaultRetryDelay?: number;
654
+ /**
655
+ * Maximum number of retry attempts before giving up.
656
+ */
657
+ sseMaxRetryAttempts?: number;
658
+ /**
659
+ * Maximum retry delay in milliseconds.
660
+ *
661
+ * Applies only when exponential backoff is used.
662
+ *
663
+ * This option applies only if the endpoint returns a stream of events.
664
+ *
665
+ * @default 30000
666
+ */
667
+ sseMaxRetryDelay?: number;
668
+ /**
669
+ * Optional sleep function for retry backoff.
670
+ *
671
+ * Defaults to using `setTimeout`.
672
+ */
673
+ sseSleepFn?: (ms: number) => Promise<void>;
674
+ url: string;
675
+ };
676
+ interface StreamEvent<TData = unknown> {
677
+ data: TData;
678
+ event?: string;
679
+ id?: string;
680
+ retry?: number;
681
+ }
682
+ type ServerSentEventsResult<TData = unknown, TReturn = void, TNext = unknown> = {
683
+ stream: AsyncGenerator<TData extends Record<string, unknown> ? TData[keyof TData] : TData, TReturn, TNext>;
684
+ };
685
+
686
+ type ErrInterceptor<Err, Res, Req, Options> = (error: Err,
687
+ /** response may be undefined due to a network error where no response object is produced */
688
+ response: Res | undefined,
689
+ /** request may be undefined, because error may be from building the request object itself */
690
+ request: Req | undefined, options: Options) => Err | Promise<Err>;
691
+ type ReqInterceptor<Req, Options> = (request: Req, options: Options) => Req | Promise<Req>;
692
+ type ResInterceptor<Res, Req, Options> = (response: Res, request: Req, options: Options) => Res | Promise<Res>;
693
+ declare class Interceptors<Interceptor> {
694
+ fns: Array<Interceptor | null>;
695
+ clear(): void;
696
+ eject(id: number | Interceptor): void;
697
+ exists(id: number | Interceptor): boolean;
698
+ getInterceptorIndex(id: number | Interceptor): number;
699
+ update(id: number | Interceptor, fn: Interceptor): number | Interceptor | false;
700
+ use(fn: Interceptor): number;
701
+ }
702
+ interface Middleware<Req, Res, Err, Options> {
703
+ error: Interceptors<ErrInterceptor<Err, Res, Req, Options>>;
704
+ request: Interceptors<ReqInterceptor<Req, Options>>;
705
+ response: Interceptors<ResInterceptor<Res, Req, Options>>;
706
+ }
707
+
708
+ type ResponseStyle = 'data' | 'fields';
709
+ interface Config<T extends ClientOptions = ClientOptions> extends Omit<RequestInit, 'body' | 'headers' | 'method'>, Config$1 {
710
+ /**
711
+ * Base URL for all requests made by this client.
712
+ */
713
+ baseUrl?: T['baseUrl'];
714
+ /**
715
+ * Fetch API implementation. You can use this option to provide a custom
716
+ * fetch instance.
717
+ *
718
+ * @default globalThis.fetch
719
+ */
720
+ fetch?: typeof fetch;
721
+ /**
722
+ * Please don't use the Fetch client for Next.js applications. The `next`
723
+ * options won't have any effect.
724
+ *
725
+ * Install {@link https://www.npmjs.com/package/@hey-api/client-next `@hey-api/client-next`} instead.
726
+ */
727
+ next?: never;
728
+ /**
729
+ * Return the response data parsed in a specified format. By default, `auto`
730
+ * will infer the appropriate method from the `Content-Type` response header.
731
+ * You can override this behavior with any of the {@link Body} methods.
732
+ * Select `stream` if you don't want to parse response data at all.
733
+ *
734
+ * @default 'auto'
735
+ */
736
+ parseAs?: 'arrayBuffer' | 'auto' | 'blob' | 'formData' | 'json' | 'stream' | 'text';
737
+ /**
738
+ * Should we return only data or multiple fields (data, error, response, etc.)?
739
+ *
740
+ * @default 'fields'
741
+ */
742
+ responseStyle?: ResponseStyle;
743
+ /**
744
+ * Throw an error instead of returning it in the response?
745
+ *
746
+ * @default false
747
+ */
748
+ throwOnError?: T['throwOnError'];
749
+ }
750
+ interface RequestOptions<TData = unknown, TResponseStyle extends ResponseStyle = 'fields', ThrowOnError extends boolean = boolean, Url extends string = string> extends Config<{
751
+ responseStyle: TResponseStyle;
752
+ throwOnError: ThrowOnError;
753
+ }>, Pick<ServerSentEventsOptions<TData>, 'onRequest' | 'onSseError' | 'onSseEvent' | 'sseDefaultRetryDelay' | 'sseMaxRetryAttempts' | 'sseMaxRetryDelay'> {
754
+ /**
755
+ * Any body that you want to add to your request.
756
+ *
757
+ * {@link https://developer.mozilla.org/docs/Web/API/fetch#body}
758
+ */
759
+ body?: unknown;
760
+ path?: Record<string, unknown>;
761
+ query?: Record<string, unknown>;
762
+ /**
763
+ * Security mechanism(s) to use for the request.
764
+ */
765
+ security?: ReadonlyArray<Auth>;
766
+ url: Url;
767
+ }
768
+ interface ResolvedRequestOptions<TResponseStyle extends ResponseStyle = 'fields', ThrowOnError extends boolean = boolean, Url extends string = string> extends RequestOptions<unknown, TResponseStyle, ThrowOnError, Url> {
769
+ headers: Headers;
770
+ serializedBody?: string;
771
+ }
772
+ type RequestResult<TData = unknown, TError = unknown, ThrowOnError extends boolean = boolean, TResponseStyle extends ResponseStyle = 'fields'> = ThrowOnError extends true ? Promise<TResponseStyle extends 'data' ? TData extends Record<string, unknown> ? TData[keyof TData] : TData : {
773
+ data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
774
+ request: Request;
775
+ response: Response;
776
+ }> : Promise<TResponseStyle extends 'data' ? (TData extends Record<string, unknown> ? TData[keyof TData] : TData) | undefined : ({
777
+ data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
778
+ error: undefined;
779
+ } | {
780
+ data: undefined;
781
+ error: TError extends Record<string, unknown> ? TError[keyof TError] : TError;
782
+ }) & {
783
+ /** request may be undefined, because error may be from building the request object itself */
784
+ request?: Request;
785
+ /** response may be undefined, because error may be from building the request object itself or from a network error */
786
+ response?: Response;
787
+ }>;
788
+ interface ClientOptions {
789
+ baseUrl?: string;
790
+ responseStyle?: ResponseStyle;
791
+ throwOnError?: boolean;
792
+ }
793
+ type MethodFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = 'fields'>(options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'>) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
794
+ type SseFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = 'fields'>(options: Omit<RequestOptions<never, TResponseStyle, ThrowOnError>, 'method'>) => Promise<ServerSentEventsResult<TData, TError>>;
795
+ type RequestFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = 'fields'>(options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'> & Pick<Required<RequestOptions<TData, TResponseStyle, ThrowOnError>>, 'method'>) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
796
+ type BuildUrlFn = <TData extends {
797
+ body?: unknown;
798
+ path?: Record<string, unknown>;
799
+ query?: Record<string, unknown>;
800
+ url: string;
801
+ }>(options: TData & Options$1<TData>) => string;
802
+ type Client = Client$1<RequestFn, Config, MethodFn, BuildUrlFn, SseFn> & {
803
+ interceptors: Middleware<Request, Response, unknown, ResolvedRequestOptions>;
804
+ };
805
+ interface TDataShape {
806
+ body?: unknown;
807
+ headers?: unknown;
808
+ path?: unknown;
809
+ query?: unknown;
810
+ url: string;
811
+ }
812
+ type OmitKeys<T, K> = Pick<T, Exclude<keyof T, K>>;
813
+ type Options$1<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponse = unknown, TResponseStyle extends ResponseStyle = 'fields'> = OmitKeys<RequestOptions<TResponse, TResponseStyle, ThrowOnError>, 'body' | 'path' | 'query' | 'url'> & ([TData] extends [never] ? unknown : Omit<TData, 'url'>);
814
+
815
+ type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponse = unknown> = Options$1<TData, ThrowOnError, TResponse> & {
816
+ /**
817
+ * You can provide a client instance returned by `createClient()` instead of
818
+ * individual options. This might be also useful if you want to implement a
819
+ * custom client.
820
+ */
821
+ client?: Client;
822
+ /**
823
+ * You can pass arbitrary values through the `meta` object. This can be
824
+ * used to access values that aren't defined as part of the SDK function.
825
+ */
826
+ meta?: Record<string, unknown>;
827
+ };
828
+ /**
829
+ * Retrieve a list of products
830
+ *
831
+ * List products
832
+ */
833
+ declare const getV1Products: <ThrowOnError extends boolean = false>(options?: Options<GetV1ProductsData, ThrowOnError>) => RequestResult<GetV1ProductsResponses, unknown, ThrowOnError, "fields">;
834
+ /**
835
+ * Retrieve a product by ID
836
+ *
837
+ * Get a single product
838
+ */
839
+ declare const getV1ProductsById: <ThrowOnError extends boolean = false>(options: Options<GetV1ProductsByIdData, ThrowOnError>) => RequestResult<GetV1ProductsByIdResponses, GetV1ProductsByIdErrors, ThrowOnError, "fields">;
840
+ /**
841
+ * Create a cart
842
+ *
843
+ * Create a new cart
844
+ */
845
+ declare const postV1Carts: <ThrowOnError extends boolean = false>(options?: Options<PostV1CartsData, ThrowOnError>) => RequestResult<PostV1CartsResponses, unknown, ThrowOnError, "fields">;
846
+ /**
847
+ * Get cart
848
+ *
849
+ * Get cart by ID
850
+ */
851
+ declare const getV1CartsById: <ThrowOnError extends boolean = false>(options: Options<GetV1CartsByIdData, ThrowOnError>) => RequestResult<GetV1CartsByIdResponses, GetV1CartsByIdErrors, ThrowOnError, "fields">;
852
+ /**
853
+ * Add cart items
854
+ *
855
+ * Add items to cart
856
+ */
857
+ declare const postV1CartsByIdItems: <ThrowOnError extends boolean = false>(options: Options<PostV1CartsByIdItemsData, ThrowOnError>) => RequestResult<PostV1CartsByIdItemsResponses, PostV1CartsByIdItemsErrors, ThrowOnError, "fields">;
858
+ /**
859
+ * Remove cart item
860
+ *
861
+ * Remove item from cart
862
+ */
863
+ declare const deleteV1CartsByIdItemsByLineId: <ThrowOnError extends boolean = false>(options: Options<DeleteV1CartsByIdItemsByLineIdData, ThrowOnError>) => RequestResult<DeleteV1CartsByIdItemsByLineIdResponses, DeleteV1CartsByIdItemsByLineIdErrors, ThrowOnError, "fields">;
864
+ /**
865
+ * Update cart item
866
+ *
867
+ * Update cart item quantity
868
+ */
869
+ declare const putV1CartsByIdItemsByLineId: <ThrowOnError extends boolean = false>(options: Options<PutV1CartsByIdItemsByLineIdData, ThrowOnError>) => RequestResult<PutV1CartsByIdItemsByLineIdResponses, PutV1CartsByIdItemsByLineIdErrors, ThrowOnError, "fields">;
870
+ /**
871
+ * Update shipping address
872
+ *
873
+ * Update shipping address of an order
874
+ */
875
+ declare const patchV1OrdersByOrderIdShippingAddress: <ThrowOnError extends boolean = false>(options: Options<PatchV1OrdersByOrderIdShippingAddressData, ThrowOnError>) => RequestResult<PatchV1OrdersByOrderIdShippingAddressResponses, PatchV1OrdersByOrderIdShippingAddressErrors, ThrowOnError, "fields">;
876
+ /**
877
+ * Resend confirmation
878
+ *
879
+ * Resend order confirmation email
880
+ */
881
+ declare const postV1OrdersByOrderIdResendConfirmation: <ThrowOnError extends boolean = false>(options: Options<PostV1OrdersByOrderIdResendConfirmationData, ThrowOnError>) => RequestResult<PostV1OrdersByOrderIdResendConfirmationResponses, PostV1OrdersByOrderIdResendConfirmationErrors, ThrowOnError, "fields">;
882
+ /**
883
+ * Resend invoice
884
+ *
885
+ * Resend invoice email with PDF link
886
+ */
887
+ declare const postV1OrdersByOrderIdResendInvoice: <ThrowOnError extends boolean = false>(options: Options<PostV1OrdersByOrderIdResendInvoiceData, ThrowOnError>) => RequestResult<PostV1OrdersByOrderIdResendInvoiceResponses, PostV1OrdersByOrderIdResendInvoiceErrors, ThrowOnError, "fields">;
888
+ /**
889
+ * Cancel order
890
+ *
891
+ * Cancel an order and refund if necessary
892
+ */
893
+ declare const postV1OrdersByOrderIdCancel: <ThrowOnError extends boolean = false>(options: Options<PostV1OrdersByOrderIdCancelData, ThrowOnError>) => RequestResult<PostV1OrdersByOrderIdCancelResponses, PostV1OrdersByOrderIdCancelErrors, ThrowOnError, "fields">;
894
+ /**
895
+ * Retrieve a list of collections
896
+ *
897
+ * List collections
898
+ */
899
+ declare const getV1Collections: <ThrowOnError extends boolean = false>(options?: Options<GetV1CollectionsData, ThrowOnError>) => RequestResult<GetV1CollectionsResponses, unknown, ThrowOnError, "fields">;
900
+ /**
901
+ * Create checkout
902
+ *
903
+ * Create a Stripe Checkout session
904
+ */
905
+ declare const postV1CheckoutStripe: <ThrowOnError extends boolean = false>(options?: Options<PostV1CheckoutStripeData, ThrowOnError>) => RequestResult<PostV1CheckoutStripeResponses, unknown, ThrowOnError, "fields">;
906
+
907
+ declare const client: Client;
908
+
909
+ interface ReponseOptions {
910
+ apiKey: string;
911
+ baseUrl?: string;
912
+ }
913
+ declare class Reponse {
914
+ constructor(options: ReponseOptions);
915
+ catalog: {
916
+ listProducts: (params?: Parameters<typeof getV1Products>[0]) => Promise<{
917
+ data: ProductListResponse;
918
+ request: Request;
919
+ response: Response;
920
+ } | (({
921
+ data: ProductListResponse;
922
+ error: undefined;
923
+ } | {
924
+ data: undefined;
925
+ error: unknown;
926
+ }) & {
927
+ request?: Request;
928
+ response?: Response;
929
+ })>;
930
+ getProduct: (params: Parameters<typeof getV1ProductsById>[0]) => Promise<{
931
+ data: Product;
932
+ request: Request;
933
+ response: Response;
934
+ } | (({
935
+ data: Product;
936
+ error: undefined;
937
+ } | {
938
+ data: undefined;
939
+ error: unknown;
940
+ }) & {
941
+ request?: Request;
942
+ response?: Response;
943
+ })>;
944
+ listCollections: (params?: Parameters<typeof getV1Collections>[0]) => Promise<{
945
+ data: CollectionListResponse;
946
+ request: Request;
947
+ response: Response;
948
+ } | (({
949
+ data: undefined;
950
+ error: unknown;
951
+ } | {
952
+ data: CollectionListResponse;
953
+ error: undefined;
954
+ }) & {
955
+ request?: Request;
956
+ response?: Response;
957
+ })>;
958
+ };
959
+ cart: {
960
+ create: (params?: Parameters<typeof postV1Carts>[0]) => Promise<{
961
+ data: Cart;
962
+ request: Request;
963
+ response: Response;
964
+ } | (({
965
+ data: undefined;
966
+ error: unknown;
967
+ } | {
968
+ data: Cart;
969
+ error: undefined;
970
+ }) & {
971
+ request?: Request;
972
+ response?: Response;
973
+ })>;
974
+ get: (params: Parameters<typeof getV1CartsById>[0]) => Promise<{
975
+ data: Cart;
976
+ request: Request;
977
+ response: Response;
978
+ } | (({
979
+ data: Cart;
980
+ error: undefined;
981
+ } | {
982
+ data: undefined;
983
+ error: unknown;
984
+ }) & {
985
+ request?: Request;
986
+ response?: Response;
987
+ })>;
988
+ addItem: (params: Parameters<typeof postV1CartsByIdItems>[0]) => Promise<{
989
+ data: unknown;
990
+ request: Request;
991
+ response: Response;
992
+ } | (({
993
+ data: unknown;
994
+ error: undefined;
995
+ } | {
996
+ data: undefined;
997
+ error: unknown;
998
+ }) & {
999
+ request?: Request;
1000
+ response?: Response;
1001
+ })>;
1002
+ updateItem: (params: Parameters<typeof putV1CartsByIdItemsByLineId>[0]) => Promise<{
1003
+ data: unknown;
1004
+ request: Request;
1005
+ response: Response;
1006
+ } | (({
1007
+ data: unknown;
1008
+ error: undefined;
1009
+ } | {
1010
+ data: undefined;
1011
+ error: unknown;
1012
+ }) & {
1013
+ request?: Request;
1014
+ response?: Response;
1015
+ })>;
1016
+ removeItem: (params: Parameters<typeof deleteV1CartsByIdItemsByLineId>[0]) => Promise<{
1017
+ data: unknown;
1018
+ request: Request;
1019
+ response: Response;
1020
+ } | (({
1021
+ data: unknown;
1022
+ error: undefined;
1023
+ } | {
1024
+ data: undefined;
1025
+ error: unknown;
1026
+ }) & {
1027
+ request?: Request;
1028
+ response?: Response;
1029
+ })>;
1030
+ createCheckout: (params?: Parameters<typeof postV1CheckoutStripe>[0]) => Promise<{
1031
+ data: CheckoutSession;
1032
+ request: Request;
1033
+ response: Response;
1034
+ } | (({
1035
+ data: undefined;
1036
+ error: unknown;
1037
+ } | {
1038
+ data: CheckoutSession;
1039
+ error: undefined;
1040
+ }) & {
1041
+ request?: Request;
1042
+ response?: Response;
1043
+ })>;
1044
+ };
1045
+ orders: {
1046
+ updateShippingAddress: (params: Parameters<typeof patchV1OrdersByOrderIdShippingAddress>[0]) => Promise<{
1047
+ data: {
1048
+ success: boolean;
1049
+ confirmation_message?: string;
1050
+ notify_merchant?: boolean;
1051
+ event_id?: string;
1052
+ };
1053
+ request: Request;
1054
+ response: Response;
1055
+ } | (({
1056
+ data: {
1057
+ success: boolean;
1058
+ confirmation_message?: string;
1059
+ notify_merchant?: boolean;
1060
+ event_id?: string;
1061
+ };
1062
+ error: undefined;
1063
+ } | {
1064
+ data: undefined;
1065
+ error: unknown;
1066
+ }) & {
1067
+ request?: Request;
1068
+ response?: Response;
1069
+ })>;
1070
+ resendConfirmation: (params: Parameters<typeof postV1OrdersByOrderIdResendConfirmation>[0]) => Promise<{
1071
+ data: {
1072
+ success: boolean;
1073
+ confirmation_message?: string;
1074
+ event_id?: string;
1075
+ };
1076
+ request: Request;
1077
+ response: Response;
1078
+ } | (({
1079
+ data: {
1080
+ success: boolean;
1081
+ confirmation_message?: string;
1082
+ event_id?: string;
1083
+ };
1084
+ error: undefined;
1085
+ } | {
1086
+ data: undefined;
1087
+ error: unknown;
1088
+ }) & {
1089
+ request?: Request;
1090
+ response?: Response;
1091
+ })>;
1092
+ resendInvoice: (params: Parameters<typeof postV1OrdersByOrderIdResendInvoice>[0]) => Promise<{
1093
+ data: {
1094
+ success: boolean;
1095
+ confirmation_message?: string;
1096
+ event_id?: string;
1097
+ };
1098
+ request: Request;
1099
+ response: Response;
1100
+ } | (({
1101
+ data: {
1102
+ success: boolean;
1103
+ confirmation_message?: string;
1104
+ event_id?: string;
1105
+ };
1106
+ error: undefined;
1107
+ } | {
1108
+ data: undefined;
1109
+ error: unknown;
1110
+ }) & {
1111
+ request?: Request;
1112
+ response?: Response;
1113
+ })>;
1114
+ cancel: (params: Parameters<typeof postV1OrdersByOrderIdCancel>[0]) => Promise<{
1115
+ data: unknown;
1116
+ request: Request;
1117
+ response: Response;
1118
+ } | (({
1119
+ data: unknown;
1120
+ error: undefined;
1121
+ } | {
1122
+ data: undefined;
1123
+ error: unknown;
1124
+ }) & {
1125
+ request?: Request;
1126
+ response?: Response;
1127
+ })>;
1128
+ };
1129
+ }
1130
+
1131
+ export { type AddCartItemInput, type Cart, type CheckoutSession, type ClientOptions$1 as ClientOptions, type Collection, type CollectionListResponse, type CreateCartInput, type CreateCheckoutInput, type DeleteV1CartsByIdItemsByLineIdData, type DeleteV1CartsByIdItemsByLineIdErrors, type DeleteV1CartsByIdItemsByLineIdResponses, type GetV1CartsByIdData, type GetV1CartsByIdErrors, type GetV1CartsByIdResponse, type GetV1CartsByIdResponses, type GetV1CollectionsData, type GetV1CollectionsResponse, type GetV1CollectionsResponses, type GetV1ProductsByIdData, type GetV1ProductsByIdErrors, type GetV1ProductsByIdResponse, type GetV1ProductsByIdResponses, type GetV1ProductsData, type GetV1ProductsResponse, type GetV1ProductsResponses, type Options, type PatchV1OrdersByOrderIdShippingAddressData, type PatchV1OrdersByOrderIdShippingAddressErrors, type PatchV1OrdersByOrderIdShippingAddressResponse, type PatchV1OrdersByOrderIdShippingAddressResponses, type PostV1CartsByIdItemsData, type PostV1CartsByIdItemsErrors, type PostV1CartsByIdItemsResponses, type PostV1CartsData, type PostV1CartsResponse, type PostV1CartsResponses, type PostV1CheckoutStripeData, type PostV1CheckoutStripeResponse, type PostV1CheckoutStripeResponses, type PostV1OrdersByOrderIdCancelData, type PostV1OrdersByOrderIdCancelErrors, type PostV1OrdersByOrderIdCancelResponses, type PostV1OrdersByOrderIdResendConfirmationData, type PostV1OrdersByOrderIdResendConfirmationErrors, type PostV1OrdersByOrderIdResendConfirmationResponse, type PostV1OrdersByOrderIdResendConfirmationResponses, type PostV1OrdersByOrderIdResendInvoiceData, type PostV1OrdersByOrderIdResendInvoiceErrors, type PostV1OrdersByOrderIdResendInvoiceResponse, type PostV1OrdersByOrderIdResendInvoiceResponses, type Product, type ProductListResponse, type ProductVariant, type PutV1CartsByIdItemsByLineIdData, type PutV1CartsByIdItemsByLineIdErrors, type PutV1CartsByIdItemsByLineIdResponses, Reponse, type ReponseOptions, type UpdateCartItemInput, client, deleteV1CartsByIdItemsByLineId, getV1CartsById, getV1Collections, getV1Products, getV1ProductsById, patchV1OrdersByOrderIdShippingAddress, postV1Carts, postV1CartsByIdItems, postV1CheckoutStripe, postV1OrdersByOrderIdCancel, postV1OrdersByOrderIdResendConfirmation, postV1OrdersByOrderIdResendInvoice, putV1CartsByIdItemsByLineId };