@betterstore/sdk 0.5.23 → 0.5.25

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.mts CHANGED
@@ -1,19 +1,106 @@
1
1
  import axios from 'axios';
2
+ import { GetShippingRatesResponse, ListCollectionsParams, ListCollectionsResponse, RetrieveCollectionParams, RetrieveCollectionResponse, ListDiscountsParams, ListDiscountsResponse, RetrieveDiscountParams, RetrieveDiscountResponse, ListProductsParams, ListProductsResponse, RetrieveProductParams, RetrieveProductResponse } from '@betterstore/bridge';
2
3
 
3
4
  declare const createApiClient: (apiKey: string, proxy?: string) => axios.AxiosInstance;
4
5
 
5
- type ShippingRate = ZasilkovnaRate;
6
- interface BaseRate {
7
- provider: string;
6
+ interface Discount {
7
+ id: string;
8
+ createdAt: Date;
9
+ updatedAt: Date;
10
+ type: "AMOUNT_OFF_PRODUCTS" | "BUY_X_GET_Y" | "AMOUNT_OFF_ORDER" | "FREE_SHIPPING";
11
+ method: "CODE" | "AUTOMATIC";
12
+ code?: string | null;
13
+ title?: string | null;
14
+ value: number;
15
+ valueType: "PERCENTAGE" | "FIXED_AMOUNT" | "FREE";
16
+ discountScope: "PRODUCTS" | "COLLECTIONS";
17
+ allowedProductIDs: string[];
18
+ allowedCollectionIDs: string[];
19
+ allowedCombinations: ("ORDER" | "PRODUCT" | "SHIPPING")[];
20
+ minimumRequirementsType: "NONE" | "MINIMUM_ORDER_AMOUNT" | "MINIMUM_PRODUCT_QUANTITY";
21
+ minimumRequirementsValue?: number | null;
22
+ requiredProductIDs: string[];
23
+ requiredCollectionIDs: string[];
24
+ minimumRequirementsScope: "PRODUCTS" | "COLLECTIONS";
25
+ maxUses?: number | null;
26
+ maxUsesPerCustomer?: number | null;
27
+ maxAllowedProductQuantity?: number | null;
28
+ uses: number;
29
+ subscriptionDiscountDurationType: "ONE_TIME" | "RECURRING" | "FOREVER";
30
+ subscriptionDiscountDurationValue: number;
31
+ stripeDiscountId?: string | null;
32
+ startsAt: Date;
33
+ expiresAt?: Date | null;
34
+ status: "ACTIVE" | "EXPIRED" | "SCHEDULED";
35
+ organizationId: string;
36
+ }
37
+ interface VariantOption {
8
38
  name: string;
39
+ value: string;
40
+ }
41
+ interface ProductVariant {
42
+ title: string;
43
+ description?: string;
44
+ images: string[];
45
+ sku?: string;
46
+ barcode?: string;
47
+ inventoryItem: {
48
+ stockPolicy: "CONTINUE" | "DENY";
49
+ trackInventory: boolean;
50
+ };
51
+ isPhysical: boolean;
52
+ weightInGrams?: number;
53
+ heightInCm?: number;
54
+ widthInCm?: number;
55
+ lengthInCm?: number;
9
56
  priceInCents: number;
57
+ billingType: ProductBillingType;
58
+ billingInterval: ProductBillingInterval;
59
+ billingIntervalCount: number;
60
+ metadata?: Record<string, any>;
61
+ variantOptions: VariantOption[];
10
62
  }
11
- interface ZasilkovnaRate extends BaseRate {
12
- provider: "zasilkovna";
13
- clientSecret: string;
63
+ interface ProductOption {
64
+ name: string;
65
+ values: string[];
66
+ }
67
+ type ProductStatus = "DRAFT" | "ACTIVE" | "ARCHIVED";
68
+ type ProductBillingInterval = "DAY" | "WEEK" | "MONTH" | "YEAR";
69
+ type ProductBillingType = "ONE_TIME" | "SUBSCRIPTION";
70
+ interface Product {
71
+ id: string;
72
+ createdAt: Date;
73
+ updatedAt: Date;
74
+ title: string;
75
+ description?: string;
76
+ images: string[];
77
+ category: string;
78
+ tags: string[];
79
+ isPhysical: boolean;
80
+ weightInGrams?: number;
81
+ heightInCm?: number;
82
+ widthInCm?: number;
83
+ lengthInCm?: number;
84
+ priceInCents: number;
85
+ billingType: ProductBillingType;
86
+ billingInterval: ProductBillingInterval;
87
+ billingIntervalCount: number;
88
+ sku?: string;
89
+ barcode?: string;
90
+ inventoryItem: {
91
+ stockPolicy: "CONTINUE" | "DENY";
92
+ trackInventory: boolean;
93
+ };
94
+ seoPageTitle?: string;
95
+ seoDescription?: string;
96
+ seoHandle?: string;
97
+ vendor?: string;
98
+ metadata?: Record<string, any>;
99
+ status: ProductStatus;
100
+ options: ProductOption[];
101
+ productVariants: ProductVariant[];
14
102
  }
15
- interface GetShippingRatesResponse {
16
- [shipmentId: string]: ShippingRate[];
103
+ interface ProductWithoutVariants extends Omit<Product, "productVariants"> {
17
104
  }
18
105
 
19
106
  type ProductData = Pick<Product, "title" | "description" | "images" | "category" | "tags" | "sku" | "barcode" | "vendor" | "isPhysical" | "weightInGrams" | "heightInCm" | "widthInCm" | "lengthInCm" | "priceInCents" | "billingType" | "billingInterval" | "billingIntervalCount"> & {
@@ -50,15 +137,13 @@ interface CheckoutUpdateParams {
50
137
  customerId?: string;
51
138
  shipments?: CheckoutShipment[];
52
139
  }
53
-
54
140
  type ShipmentData = {
55
- provider: string;
56
- name?: string;
57
- service?: string;
141
+ rateId: string;
142
+ providerId?: string;
143
+ priceInCents: number;
58
144
  pickupPointId?: string;
59
145
  trackingId?: string;
60
146
  trackingUrl?: string;
61
- priceInCents: number;
62
147
  };
63
148
  type CheckoutShipment = {
64
149
  id: string;
@@ -108,154 +193,6 @@ type LookupAddressResult = {
108
193
  address: Pick<Address, "line1" | "city" | "province" | "provinceCode" | "country" | "countryCode" | "zipCode">;
109
194
  };
110
195
 
111
- type SortOrder = "asc" | "desc";
112
- type GetListParams<A, B> = {
113
- sortBy?: A;
114
- sortOrder?: SortOrder;
115
- query?: B & {
116
- NOT?: B | B[];
117
- OR?: B[];
118
- };
119
- };
120
- type EnumQueryType<T> = {
121
- equals?: T;
122
- in?: T[];
123
- not?: T;
124
- notIn?: T[];
125
- };
126
- type StringArrayQueryType<T = string> = {
127
- equals?: T[];
128
- has?: T;
129
- hasEvery?: T[];
130
- hasSome?: T[];
131
- isEmpty?: boolean;
132
- };
133
- type DateQueryType = {
134
- equals?: Date;
135
- in?: Date[];
136
- not?: Date;
137
- notIn?: Date[];
138
- gt?: Date;
139
- gte?: Date;
140
- lt?: Date;
141
- lte?: Date;
142
- };
143
- type OptionalDateQueryType = DateQueryType & {
144
- isSet: boolean;
145
- };
146
- type ArrayModelQueryType<T> = {
147
- some?: T;
148
- every?: T;
149
- none?: T;
150
- };
151
-
152
- interface VariantOption {
153
- name: string;
154
- value: string;
155
- }
156
- interface ProductVariant {
157
- title: string;
158
- description?: string;
159
- images: string[];
160
- trackInventory: boolean;
161
- sku?: string;
162
- barcode?: string;
163
- stockAvailable: number;
164
- stockCommited: number;
165
- stockUnavailable: number;
166
- isPhysical: boolean;
167
- weightInGrams?: number;
168
- heightInCm?: number;
169
- widthInCm?: number;
170
- lengthInCm?: number;
171
- priceInCents: number;
172
- billingType: ProductBillingType;
173
- billingInterval: ProductBillingInterval;
174
- billingIntervalCount: number;
175
- metadata?: Record<string, any>;
176
- variantOptions: VariantOption[];
177
- }
178
- interface ProductOption {
179
- name: string;
180
- values: string[];
181
- }
182
- type ProductStatus = "DRAFT" | "ACTIVE" | "ARCHIVED";
183
- type ProductBillingInterval = "DAY" | "WEEK" | "MONTH" | "YEAR";
184
- type ProductBillingType = "ONE_TIME" | "SUBSCRIPTION";
185
- interface Product {
186
- id: string;
187
- createdAt: Date;
188
- updatedAt: Date;
189
- title: string;
190
- description?: string;
191
- images: string[];
192
- category: string;
193
- tags: string[];
194
- isPhysical: boolean;
195
- weightInGrams?: number;
196
- heightInCm?: number;
197
- widthInCm?: number;
198
- lengthInCm?: number;
199
- priceInCents: number;
200
- billingType: ProductBillingType;
201
- billingInterval: ProductBillingInterval;
202
- billingIntervalCount: number;
203
- trackInventory: boolean;
204
- sku?: string;
205
- barcode?: string;
206
- stockAvailable: number;
207
- stockCommited: number;
208
- stockUnavailable: number;
209
- seoPageTitle?: string;
210
- seoDescription?: string;
211
- seoHandle?: string;
212
- vendor?: string;
213
- metadata?: Record<string, any>;
214
- status: ProductStatus;
215
- options: ProductOption[];
216
- productVariants: ProductVariant[];
217
- }
218
- interface ProductWithoutVariants extends Omit<Product, "productVariants"> {
219
- }
220
- type ListProductsQuery = {
221
- collectionIDs?: StringArrayQueryType;
222
- collections?: ArrayModelQueryType<{
223
- seoHandle?: StringArrayQueryType;
224
- }>;
225
- tags?: StringArrayQueryType;
226
- createdAt?: DateQueryType;
227
- updatedAt?: DateQueryType;
228
- };
229
- type ListProductsSortBy = "createdAt" | "updatedAt" | "title" | "stockAvailable" | "stockCommited" | "priceInCents";
230
- type ListProductsParams = GetListParams<ListProductsSortBy, ListProductsQuery>;
231
- type RetrieveProductParams = {
232
- seoHandle: string;
233
- } | {
234
- id: string;
235
- };
236
-
237
- interface Collection {
238
- id: string;
239
- title: string;
240
- description?: string;
241
- images: string[];
242
- tags: string[];
243
- seoPageTitle?: string;
244
- seoDescription?: string;
245
- seoHandle?: string;
246
- }
247
- interface CollectionWithProducts extends Collection {
248
- products: ProductWithoutVariants[];
249
- }
250
- type ListCollectionsQuery = undefined;
251
- type ListCollectionsSortBy = "createdAt" | "updatedAt" | "title";
252
- type ListCollectionsParams = GetListParams<ListCollectionsSortBy, ListCollectionsQuery>;
253
- type RetrieveCollectionParams = {
254
- seoHandle: string;
255
- } | {
256
- id: string;
257
- };
258
-
259
196
  type Address = {
260
197
  name: string;
261
198
  phone: string;
@@ -295,64 +232,6 @@ interface CustomerSubscription {
295
232
  }
296
233
  type CustomerSubscriptionUpdateParams = Partial<Pick<CustomerSubscription, "cancelAtPeriodEnd">>;
297
234
 
298
- interface Discount {
299
- id: string;
300
- createdAt: Date;
301
- updatedAt: Date;
302
- type: "AMOUNT_OFF_PRODUCTS" | "BUY_X_GET_Y" | "AMOUNT_OFF_ORDER" | "FREE_SHIPPING";
303
- method: "CODE" | "AUTOMATIC";
304
- code?: string | null;
305
- title?: string | null;
306
- value: number;
307
- valueType: "PERCENTAGE" | "FIXED_AMOUNT" | "FREE";
308
- discountScope: "PRODUCTS" | "COLLECTIONS";
309
- allowedProductIDs: string[];
310
- allowedCollectionIDs: string[];
311
- allowedCombinations: ("ORDER" | "PRODUCT" | "SHIPPING")[];
312
- minimumRequirementsType: "NONE" | "MINIMUM_ORDER_AMOUNT" | "MINIMUM_PRODUCT_QUANTITY";
313
- minimumRequirementsValue?: number | null;
314
- requiredProductIDs: string[];
315
- requiredCollectionIDs: string[];
316
- minimumRequirementsScope: "PRODUCTS" | "COLLECTIONS";
317
- maxUses?: number | null;
318
- maxUsesPerCustomer?: number | null;
319
- maxAllowedProductQuantity?: number | null;
320
- uses: number;
321
- subscriptionDiscountDurationType: "ONE_TIME" | "RECURRING" | "FOREVER";
322
- subscriptionDiscountDurationValue: number;
323
- stripeDiscountId?: string | null;
324
- startsAt: Date;
325
- expiresAt?: Date | null;
326
- status: "ACTIVE" | "EXPIRED" | "SCHEDULED";
327
- organizationId: string;
328
- }
329
- type ListDiscountsQuery = {
330
- type?: EnumQueryType<Discount["type"]>;
331
- valueType?: EnumQueryType<Discount["valueType"]>;
332
- method?: EnumQueryType<Discount["method"]>;
333
- status?: EnumQueryType<Discount["status"]>;
334
- minimumRequirementsType?: EnumQueryType<Discount["minimumRequirementsType"]>;
335
- minimumRequirementsScope?: EnumQueryType<Discount["minimumRequirementsScope"]>;
336
- discountScope?: EnumQueryType<Discount["discountScope"]>;
337
- subscriptionDiscountDurationType?: EnumQueryType<Discount["subscriptionDiscountDurationType"]>;
338
- allowedCombinations?: StringArrayQueryType<Discount["allowedCombinations"]>;
339
- allowedProductIDs?: StringArrayQueryType<Discount["allowedProductIDs"]>;
340
- allowedCollectionIDs?: StringArrayQueryType<Discount["allowedCollectionIDs"]>;
341
- requiredProductIDs?: StringArrayQueryType<Discount["requiredProductIDs"]>;
342
- requiredCollectionIDs?: StringArrayQueryType<Discount["requiredCollectionIDs"]>;
343
- startsAt?: DateQueryType;
344
- expiresAt?: OptionalDateQueryType;
345
- createdAt?: DateQueryType;
346
- updatedAt?: DateQueryType;
347
- };
348
- type ListDiscountsSortBy = "createdAt" | "updatedAt" | "expiresAt" | "startsAt";
349
- type ListDiscountsParams = GetListParams<ListDiscountsSortBy, ListDiscountsQuery>;
350
- type RetrieveDiscountParams = {
351
- id: string;
352
- } | {
353
- code: string;
354
- };
355
-
356
235
  interface CustomerSession {
357
236
  customerId: string;
358
237
  expiresAt: Date;
@@ -490,7 +369,7 @@ declare class Client {
490
369
  /**
491
370
  * Get shipping rates for a checkout session
492
371
  */
493
- getCheckoutShippingRates(clientSecret: string, checkoutId: string): Promise<ShippingRate[]>;
372
+ getCheckoutShippingRates(clientSecret: string, checkoutId: string): Promise<GetShippingRatesResponse>;
494
373
  /**
495
374
  * Generate payment secret for a checkout session
496
375
  */
@@ -534,8 +413,8 @@ declare class Client {
534
413
  declare class Collections {
535
414
  private apiClient;
536
415
  constructor(apiKey: string, proxy?: string);
537
- list(params?: ListCollectionsParams): Promise<Collection[]>;
538
- retrieve(params: RetrieveCollectionParams): Promise<CollectionWithProducts | null>;
416
+ list<T extends ListCollectionsParams>(params?: T): Promise<ListCollectionsResponse<T>>;
417
+ retrieve<T extends RetrieveCollectionParams>(params: T): Promise<RetrieveCollectionResponse<T> | null>;
539
418
  }
540
419
 
541
420
  declare class Customer {
@@ -566,8 +445,8 @@ declare class Customer {
566
445
  declare class Discounts {
567
446
  private apiClient;
568
447
  constructor(apiKey: string, proxy?: string);
569
- list(params?: ListDiscountsParams): Promise<Discount[]>;
570
- retrieve(params: RetrieveDiscountParams): Promise<Discount | null>;
448
+ list<T extends ListDiscountsParams>(params?: T): Promise<ListDiscountsResponse>;
449
+ retrieve<T extends RetrieveDiscountParams>(params: T): Promise<RetrieveDiscountResponse | null>;
571
450
  }
572
451
 
573
452
  declare class Helpers {
@@ -580,8 +459,8 @@ declare class Helpers {
580
459
  declare class Products {
581
460
  private apiClient;
582
461
  constructor(apiKey: string, proxy?: string);
583
- list(params?: ListProductsParams): Promise<ProductWithoutVariants[]>;
584
- retrieve(params: RetrieveProductParams): Promise<Product | null>;
462
+ list<T extends ListProductsParams>(params?: T): Promise<ListProductsResponse<T>>;
463
+ retrieve<T extends RetrieveProductParams>(params: T): Promise<RetrieveProductResponse<T> | null>;
585
464
  }
586
465
 
587
466
  declare function createBetterStore(config: {
@@ -602,4 +481,4 @@ declare function createStoreHelpers(config?: {
602
481
  proxy?: string;
603
482
  }): Helpers;
604
483
 
605
- export { type Address, type AutosuggestAddressResult, type CheckoutCreateParams, type CheckoutSession, type CheckoutUpdateParams, type Collection, type CollectionWithProducts, type Currency, type Customer$1 as Customer, type CustomerCreateParams, type CustomerSession, type CustomerSubscription, type CustomerSubscriptionUpdateParams, type CustomerUpdateParams, type Discount, type GetShippingRatesResponse, type LineItem, type LineItemCreate, type ListCollectionsParams, type ListCollectionsQuery, type ListCollectionsSortBy, type ListDiscountsParams, type ListDiscountsQuery, type ListDiscountsSortBy, type ListProductsParams, type ListProductsQuery, type ListProductsSortBy, type LookupAddressResult, type OTPLoginParams, type OTPLoginResponse, type OTPSignupParams, type OTPSignupResponse, type OTPVerifyParams, type OTPVerifyResponse, type Product, type ProductBillingInterval, type ProductBillingType, type ProductOption, type ProductStatus, type ProductVariant, type ProductWithoutVariants, type RetrieveCollectionParams, type RetrieveDiscountParams, type RetrieveProductParams, type ShippingRate, type VariantOption, createStoreClient, createStoreHelpers, createBetterStore as default };
484
+ export { type Address, type AutosuggestAddressResult, type CheckoutCreateParams, type CheckoutSession, type CheckoutUpdateParams, type Currency, type Customer$1 as Customer, type CustomerCreateParams, type CustomerSession, type CustomerSubscription, type CustomerSubscriptionUpdateParams, type CustomerUpdateParams, type Discount, type LineItem, type LineItemCreate, type LookupAddressResult, type OTPLoginParams, type OTPLoginResponse, type OTPSignupParams, type OTPSignupResponse, type OTPVerifyParams, type OTPVerifyResponse, type Product, type ProductBillingInterval, type ProductBillingType, type ProductOption, type ProductStatus, type ProductVariant, type ProductWithoutVariants, type VariantOption, createStoreClient, createStoreHelpers, createBetterStore as default };
package/dist/index.d.ts CHANGED
@@ -1,19 +1,106 @@
1
1
  import axios from 'axios';
2
+ import { GetShippingRatesResponse, ListCollectionsParams, ListCollectionsResponse, RetrieveCollectionParams, RetrieveCollectionResponse, ListDiscountsParams, ListDiscountsResponse, RetrieveDiscountParams, RetrieveDiscountResponse, ListProductsParams, ListProductsResponse, RetrieveProductParams, RetrieveProductResponse } from '@betterstore/bridge';
2
3
 
3
4
  declare const createApiClient: (apiKey: string, proxy?: string) => axios.AxiosInstance;
4
5
 
5
- type ShippingRate = ZasilkovnaRate;
6
- interface BaseRate {
7
- provider: string;
6
+ interface Discount {
7
+ id: string;
8
+ createdAt: Date;
9
+ updatedAt: Date;
10
+ type: "AMOUNT_OFF_PRODUCTS" | "BUY_X_GET_Y" | "AMOUNT_OFF_ORDER" | "FREE_SHIPPING";
11
+ method: "CODE" | "AUTOMATIC";
12
+ code?: string | null;
13
+ title?: string | null;
14
+ value: number;
15
+ valueType: "PERCENTAGE" | "FIXED_AMOUNT" | "FREE";
16
+ discountScope: "PRODUCTS" | "COLLECTIONS";
17
+ allowedProductIDs: string[];
18
+ allowedCollectionIDs: string[];
19
+ allowedCombinations: ("ORDER" | "PRODUCT" | "SHIPPING")[];
20
+ minimumRequirementsType: "NONE" | "MINIMUM_ORDER_AMOUNT" | "MINIMUM_PRODUCT_QUANTITY";
21
+ minimumRequirementsValue?: number | null;
22
+ requiredProductIDs: string[];
23
+ requiredCollectionIDs: string[];
24
+ minimumRequirementsScope: "PRODUCTS" | "COLLECTIONS";
25
+ maxUses?: number | null;
26
+ maxUsesPerCustomer?: number | null;
27
+ maxAllowedProductQuantity?: number | null;
28
+ uses: number;
29
+ subscriptionDiscountDurationType: "ONE_TIME" | "RECURRING" | "FOREVER";
30
+ subscriptionDiscountDurationValue: number;
31
+ stripeDiscountId?: string | null;
32
+ startsAt: Date;
33
+ expiresAt?: Date | null;
34
+ status: "ACTIVE" | "EXPIRED" | "SCHEDULED";
35
+ organizationId: string;
36
+ }
37
+ interface VariantOption {
8
38
  name: string;
39
+ value: string;
40
+ }
41
+ interface ProductVariant {
42
+ title: string;
43
+ description?: string;
44
+ images: string[];
45
+ sku?: string;
46
+ barcode?: string;
47
+ inventoryItem: {
48
+ stockPolicy: "CONTINUE" | "DENY";
49
+ trackInventory: boolean;
50
+ };
51
+ isPhysical: boolean;
52
+ weightInGrams?: number;
53
+ heightInCm?: number;
54
+ widthInCm?: number;
55
+ lengthInCm?: number;
9
56
  priceInCents: number;
57
+ billingType: ProductBillingType;
58
+ billingInterval: ProductBillingInterval;
59
+ billingIntervalCount: number;
60
+ metadata?: Record<string, any>;
61
+ variantOptions: VariantOption[];
10
62
  }
11
- interface ZasilkovnaRate extends BaseRate {
12
- provider: "zasilkovna";
13
- clientSecret: string;
63
+ interface ProductOption {
64
+ name: string;
65
+ values: string[];
66
+ }
67
+ type ProductStatus = "DRAFT" | "ACTIVE" | "ARCHIVED";
68
+ type ProductBillingInterval = "DAY" | "WEEK" | "MONTH" | "YEAR";
69
+ type ProductBillingType = "ONE_TIME" | "SUBSCRIPTION";
70
+ interface Product {
71
+ id: string;
72
+ createdAt: Date;
73
+ updatedAt: Date;
74
+ title: string;
75
+ description?: string;
76
+ images: string[];
77
+ category: string;
78
+ tags: string[];
79
+ isPhysical: boolean;
80
+ weightInGrams?: number;
81
+ heightInCm?: number;
82
+ widthInCm?: number;
83
+ lengthInCm?: number;
84
+ priceInCents: number;
85
+ billingType: ProductBillingType;
86
+ billingInterval: ProductBillingInterval;
87
+ billingIntervalCount: number;
88
+ sku?: string;
89
+ barcode?: string;
90
+ inventoryItem: {
91
+ stockPolicy: "CONTINUE" | "DENY";
92
+ trackInventory: boolean;
93
+ };
94
+ seoPageTitle?: string;
95
+ seoDescription?: string;
96
+ seoHandle?: string;
97
+ vendor?: string;
98
+ metadata?: Record<string, any>;
99
+ status: ProductStatus;
100
+ options: ProductOption[];
101
+ productVariants: ProductVariant[];
14
102
  }
15
- interface GetShippingRatesResponse {
16
- [shipmentId: string]: ShippingRate[];
103
+ interface ProductWithoutVariants extends Omit<Product, "productVariants"> {
17
104
  }
18
105
 
19
106
  type ProductData = Pick<Product, "title" | "description" | "images" | "category" | "tags" | "sku" | "barcode" | "vendor" | "isPhysical" | "weightInGrams" | "heightInCm" | "widthInCm" | "lengthInCm" | "priceInCents" | "billingType" | "billingInterval" | "billingIntervalCount"> & {
@@ -50,15 +137,13 @@ interface CheckoutUpdateParams {
50
137
  customerId?: string;
51
138
  shipments?: CheckoutShipment[];
52
139
  }
53
-
54
140
  type ShipmentData = {
55
- provider: string;
56
- name?: string;
57
- service?: string;
141
+ rateId: string;
142
+ providerId?: string;
143
+ priceInCents: number;
58
144
  pickupPointId?: string;
59
145
  trackingId?: string;
60
146
  trackingUrl?: string;
61
- priceInCents: number;
62
147
  };
63
148
  type CheckoutShipment = {
64
149
  id: string;
@@ -108,154 +193,6 @@ type LookupAddressResult = {
108
193
  address: Pick<Address, "line1" | "city" | "province" | "provinceCode" | "country" | "countryCode" | "zipCode">;
109
194
  };
110
195
 
111
- type SortOrder = "asc" | "desc";
112
- type GetListParams<A, B> = {
113
- sortBy?: A;
114
- sortOrder?: SortOrder;
115
- query?: B & {
116
- NOT?: B | B[];
117
- OR?: B[];
118
- };
119
- };
120
- type EnumQueryType<T> = {
121
- equals?: T;
122
- in?: T[];
123
- not?: T;
124
- notIn?: T[];
125
- };
126
- type StringArrayQueryType<T = string> = {
127
- equals?: T[];
128
- has?: T;
129
- hasEvery?: T[];
130
- hasSome?: T[];
131
- isEmpty?: boolean;
132
- };
133
- type DateQueryType = {
134
- equals?: Date;
135
- in?: Date[];
136
- not?: Date;
137
- notIn?: Date[];
138
- gt?: Date;
139
- gte?: Date;
140
- lt?: Date;
141
- lte?: Date;
142
- };
143
- type OptionalDateQueryType = DateQueryType & {
144
- isSet: boolean;
145
- };
146
- type ArrayModelQueryType<T> = {
147
- some?: T;
148
- every?: T;
149
- none?: T;
150
- };
151
-
152
- interface VariantOption {
153
- name: string;
154
- value: string;
155
- }
156
- interface ProductVariant {
157
- title: string;
158
- description?: string;
159
- images: string[];
160
- trackInventory: boolean;
161
- sku?: string;
162
- barcode?: string;
163
- stockAvailable: number;
164
- stockCommited: number;
165
- stockUnavailable: number;
166
- isPhysical: boolean;
167
- weightInGrams?: number;
168
- heightInCm?: number;
169
- widthInCm?: number;
170
- lengthInCm?: number;
171
- priceInCents: number;
172
- billingType: ProductBillingType;
173
- billingInterval: ProductBillingInterval;
174
- billingIntervalCount: number;
175
- metadata?: Record<string, any>;
176
- variantOptions: VariantOption[];
177
- }
178
- interface ProductOption {
179
- name: string;
180
- values: string[];
181
- }
182
- type ProductStatus = "DRAFT" | "ACTIVE" | "ARCHIVED";
183
- type ProductBillingInterval = "DAY" | "WEEK" | "MONTH" | "YEAR";
184
- type ProductBillingType = "ONE_TIME" | "SUBSCRIPTION";
185
- interface Product {
186
- id: string;
187
- createdAt: Date;
188
- updatedAt: Date;
189
- title: string;
190
- description?: string;
191
- images: string[];
192
- category: string;
193
- tags: string[];
194
- isPhysical: boolean;
195
- weightInGrams?: number;
196
- heightInCm?: number;
197
- widthInCm?: number;
198
- lengthInCm?: number;
199
- priceInCents: number;
200
- billingType: ProductBillingType;
201
- billingInterval: ProductBillingInterval;
202
- billingIntervalCount: number;
203
- trackInventory: boolean;
204
- sku?: string;
205
- barcode?: string;
206
- stockAvailable: number;
207
- stockCommited: number;
208
- stockUnavailable: number;
209
- seoPageTitle?: string;
210
- seoDescription?: string;
211
- seoHandle?: string;
212
- vendor?: string;
213
- metadata?: Record<string, any>;
214
- status: ProductStatus;
215
- options: ProductOption[];
216
- productVariants: ProductVariant[];
217
- }
218
- interface ProductWithoutVariants extends Omit<Product, "productVariants"> {
219
- }
220
- type ListProductsQuery = {
221
- collectionIDs?: StringArrayQueryType;
222
- collections?: ArrayModelQueryType<{
223
- seoHandle?: StringArrayQueryType;
224
- }>;
225
- tags?: StringArrayQueryType;
226
- createdAt?: DateQueryType;
227
- updatedAt?: DateQueryType;
228
- };
229
- type ListProductsSortBy = "createdAt" | "updatedAt" | "title" | "stockAvailable" | "stockCommited" | "priceInCents";
230
- type ListProductsParams = GetListParams<ListProductsSortBy, ListProductsQuery>;
231
- type RetrieveProductParams = {
232
- seoHandle: string;
233
- } | {
234
- id: string;
235
- };
236
-
237
- interface Collection {
238
- id: string;
239
- title: string;
240
- description?: string;
241
- images: string[];
242
- tags: string[];
243
- seoPageTitle?: string;
244
- seoDescription?: string;
245
- seoHandle?: string;
246
- }
247
- interface CollectionWithProducts extends Collection {
248
- products: ProductWithoutVariants[];
249
- }
250
- type ListCollectionsQuery = undefined;
251
- type ListCollectionsSortBy = "createdAt" | "updatedAt" | "title";
252
- type ListCollectionsParams = GetListParams<ListCollectionsSortBy, ListCollectionsQuery>;
253
- type RetrieveCollectionParams = {
254
- seoHandle: string;
255
- } | {
256
- id: string;
257
- };
258
-
259
196
  type Address = {
260
197
  name: string;
261
198
  phone: string;
@@ -295,64 +232,6 @@ interface CustomerSubscription {
295
232
  }
296
233
  type CustomerSubscriptionUpdateParams = Partial<Pick<CustomerSubscription, "cancelAtPeriodEnd">>;
297
234
 
298
- interface Discount {
299
- id: string;
300
- createdAt: Date;
301
- updatedAt: Date;
302
- type: "AMOUNT_OFF_PRODUCTS" | "BUY_X_GET_Y" | "AMOUNT_OFF_ORDER" | "FREE_SHIPPING";
303
- method: "CODE" | "AUTOMATIC";
304
- code?: string | null;
305
- title?: string | null;
306
- value: number;
307
- valueType: "PERCENTAGE" | "FIXED_AMOUNT" | "FREE";
308
- discountScope: "PRODUCTS" | "COLLECTIONS";
309
- allowedProductIDs: string[];
310
- allowedCollectionIDs: string[];
311
- allowedCombinations: ("ORDER" | "PRODUCT" | "SHIPPING")[];
312
- minimumRequirementsType: "NONE" | "MINIMUM_ORDER_AMOUNT" | "MINIMUM_PRODUCT_QUANTITY";
313
- minimumRequirementsValue?: number | null;
314
- requiredProductIDs: string[];
315
- requiredCollectionIDs: string[];
316
- minimumRequirementsScope: "PRODUCTS" | "COLLECTIONS";
317
- maxUses?: number | null;
318
- maxUsesPerCustomer?: number | null;
319
- maxAllowedProductQuantity?: number | null;
320
- uses: number;
321
- subscriptionDiscountDurationType: "ONE_TIME" | "RECURRING" | "FOREVER";
322
- subscriptionDiscountDurationValue: number;
323
- stripeDiscountId?: string | null;
324
- startsAt: Date;
325
- expiresAt?: Date | null;
326
- status: "ACTIVE" | "EXPIRED" | "SCHEDULED";
327
- organizationId: string;
328
- }
329
- type ListDiscountsQuery = {
330
- type?: EnumQueryType<Discount["type"]>;
331
- valueType?: EnumQueryType<Discount["valueType"]>;
332
- method?: EnumQueryType<Discount["method"]>;
333
- status?: EnumQueryType<Discount["status"]>;
334
- minimumRequirementsType?: EnumQueryType<Discount["minimumRequirementsType"]>;
335
- minimumRequirementsScope?: EnumQueryType<Discount["minimumRequirementsScope"]>;
336
- discountScope?: EnumQueryType<Discount["discountScope"]>;
337
- subscriptionDiscountDurationType?: EnumQueryType<Discount["subscriptionDiscountDurationType"]>;
338
- allowedCombinations?: StringArrayQueryType<Discount["allowedCombinations"]>;
339
- allowedProductIDs?: StringArrayQueryType<Discount["allowedProductIDs"]>;
340
- allowedCollectionIDs?: StringArrayQueryType<Discount["allowedCollectionIDs"]>;
341
- requiredProductIDs?: StringArrayQueryType<Discount["requiredProductIDs"]>;
342
- requiredCollectionIDs?: StringArrayQueryType<Discount["requiredCollectionIDs"]>;
343
- startsAt?: DateQueryType;
344
- expiresAt?: OptionalDateQueryType;
345
- createdAt?: DateQueryType;
346
- updatedAt?: DateQueryType;
347
- };
348
- type ListDiscountsSortBy = "createdAt" | "updatedAt" | "expiresAt" | "startsAt";
349
- type ListDiscountsParams = GetListParams<ListDiscountsSortBy, ListDiscountsQuery>;
350
- type RetrieveDiscountParams = {
351
- id: string;
352
- } | {
353
- code: string;
354
- };
355
-
356
235
  interface CustomerSession {
357
236
  customerId: string;
358
237
  expiresAt: Date;
@@ -490,7 +369,7 @@ declare class Client {
490
369
  /**
491
370
  * Get shipping rates for a checkout session
492
371
  */
493
- getCheckoutShippingRates(clientSecret: string, checkoutId: string): Promise<ShippingRate[]>;
372
+ getCheckoutShippingRates(clientSecret: string, checkoutId: string): Promise<GetShippingRatesResponse>;
494
373
  /**
495
374
  * Generate payment secret for a checkout session
496
375
  */
@@ -534,8 +413,8 @@ declare class Client {
534
413
  declare class Collections {
535
414
  private apiClient;
536
415
  constructor(apiKey: string, proxy?: string);
537
- list(params?: ListCollectionsParams): Promise<Collection[]>;
538
- retrieve(params: RetrieveCollectionParams): Promise<CollectionWithProducts | null>;
416
+ list<T extends ListCollectionsParams>(params?: T): Promise<ListCollectionsResponse<T>>;
417
+ retrieve<T extends RetrieveCollectionParams>(params: T): Promise<RetrieveCollectionResponse<T> | null>;
539
418
  }
540
419
 
541
420
  declare class Customer {
@@ -566,8 +445,8 @@ declare class Customer {
566
445
  declare class Discounts {
567
446
  private apiClient;
568
447
  constructor(apiKey: string, proxy?: string);
569
- list(params?: ListDiscountsParams): Promise<Discount[]>;
570
- retrieve(params: RetrieveDiscountParams): Promise<Discount | null>;
448
+ list<T extends ListDiscountsParams>(params?: T): Promise<ListDiscountsResponse>;
449
+ retrieve<T extends RetrieveDiscountParams>(params: T): Promise<RetrieveDiscountResponse | null>;
571
450
  }
572
451
 
573
452
  declare class Helpers {
@@ -580,8 +459,8 @@ declare class Helpers {
580
459
  declare class Products {
581
460
  private apiClient;
582
461
  constructor(apiKey: string, proxy?: string);
583
- list(params?: ListProductsParams): Promise<ProductWithoutVariants[]>;
584
- retrieve(params: RetrieveProductParams): Promise<Product | null>;
462
+ list<T extends ListProductsParams>(params?: T): Promise<ListProductsResponse<T>>;
463
+ retrieve<T extends RetrieveProductParams>(params: T): Promise<RetrieveProductResponse<T> | null>;
585
464
  }
586
465
 
587
466
  declare function createBetterStore(config: {
@@ -602,4 +481,4 @@ declare function createStoreHelpers(config?: {
602
481
  proxy?: string;
603
482
  }): Helpers;
604
483
 
605
- export { type Address, type AutosuggestAddressResult, type CheckoutCreateParams, type CheckoutSession, type CheckoutUpdateParams, type Collection, type CollectionWithProducts, type Currency, type Customer$1 as Customer, type CustomerCreateParams, type CustomerSession, type CustomerSubscription, type CustomerSubscriptionUpdateParams, type CustomerUpdateParams, type Discount, type GetShippingRatesResponse, type LineItem, type LineItemCreate, type ListCollectionsParams, type ListCollectionsQuery, type ListCollectionsSortBy, type ListDiscountsParams, type ListDiscountsQuery, type ListDiscountsSortBy, type ListProductsParams, type ListProductsQuery, type ListProductsSortBy, type LookupAddressResult, type OTPLoginParams, type OTPLoginResponse, type OTPSignupParams, type OTPSignupResponse, type OTPVerifyParams, type OTPVerifyResponse, type Product, type ProductBillingInterval, type ProductBillingType, type ProductOption, type ProductStatus, type ProductVariant, type ProductWithoutVariants, type RetrieveCollectionParams, type RetrieveDiscountParams, type RetrieveProductParams, type ShippingRate, type VariantOption, createStoreClient, createStoreHelpers, createBetterStore as default };
484
+ export { type Address, type AutosuggestAddressResult, type CheckoutCreateParams, type CheckoutSession, type CheckoutUpdateParams, type Currency, type Customer$1 as Customer, type CustomerCreateParams, type CustomerSession, type CustomerSubscription, type CustomerSubscriptionUpdateParams, type CustomerUpdateParams, type Discount, type LineItem, type LineItemCreate, type LookupAddressResult, type OTPLoginParams, type OTPLoginResponse, type OTPSignupParams, type OTPSignupResponse, type OTPVerifyParams, type OTPVerifyResponse, type Product, type ProductBillingInterval, type ProductBillingType, type ProductOption, type ProductStatus, type ProductVariant, type ProductWithoutVariants, type VariantOption, createStoreClient, createStoreHelpers, createBetterStore as default };
package/dist/index.js CHANGED
@@ -331,10 +331,10 @@ var Client = class {
331
331
  async getCheckoutShippingRates(clientSecret, checkoutId) {
332
332
  const apiClient = createApiClient(clientSecret, this.proxy);
333
333
  const data = await apiClient.get(
334
- `/checkout/shipping/${checkoutId}`
334
+ `/checkout/${checkoutId}/shipping/rates`
335
335
  );
336
- if ("isError" in data && data.isError || !data || !Array.isArray(data)) {
337
- return [];
336
+ if ("isError" in data && data.isError || !data || !("rates" in data)) {
337
+ return {};
338
338
  }
339
339
  return data;
340
340
  }
@@ -437,36 +437,18 @@ var Collections = class {
437
437
  this.apiClient = createApiClient(apiKey, proxy);
438
438
  }
439
439
  async list(params) {
440
- const queryParams = new URLSearchParams();
441
- if (params) {
442
- queryParams.set("params", JSON.stringify(params));
443
- }
444
- const data = await this.apiClient.get(
445
- `/collections?${queryParams.toString()}`
446
- );
447
- if (!data || !Array.isArray(data) || "isError" in data && data.isError) {
448
- return [];
440
+ const data = await this.apiClient.post(`/collections`, params);
441
+ if (!data || !Array.isArray(data) || "isError" in data && data.isError || !("collections" in data)) {
442
+ return {
443
+ collections: []
444
+ };
449
445
  }
450
446
  return data;
451
447
  }
452
448
  async retrieve(params) {
453
- if ("seoHandle" in params) {
454
- const data2 = await this.apiClient.get(
455
- `/collections/${params.seoHandle}`
456
- );
457
- if ("isError" in data2 && data2.isError || !data2 || !("id" in data2)) {
458
- console.error(
459
- `Collection with seoHandle ${params.seoHandle} not found`
460
- );
461
- return null;
462
- }
463
- return data2;
464
- }
465
- const data = await this.apiClient.get(
466
- `/collections/id/${params.id}`
467
- );
468
- if ("isError" in data && data.isError || !data || !("id" in data)) {
469
- console.error(`Collection with id ${params.id} not found`);
449
+ const data = await this.apiClient.post(`/collections/retrieve`, params);
450
+ if ("isError" in data && data.isError || !data || !("id" in data) || !("collection" in data)) {
451
+ console.error(`Collection not found`);
470
452
  return null;
471
453
  }
472
454
  return data;
@@ -549,34 +531,24 @@ var Discounts = class {
549
531
  this.apiClient = createApiClient(apiKey, proxy);
550
532
  }
551
533
  async list(params) {
552
- const queryParams = new URLSearchParams();
553
- if (params) {
554
- queryParams.set("params", JSON.stringify(params));
555
- }
556
- const data = await this.apiClient.get(
557
- `/discounts?${queryParams.toString()}`
534
+ const data = await this.apiClient.post(
535
+ "/discounts",
536
+ params
558
537
  );
559
- if (!data || !Array.isArray(data) || "isError" in data && data.isError) {
560
- return [];
538
+ if (!data || !Array.isArray(data) || "isError" in data && data.isError || !("discounts" in data)) {
539
+ return {
540
+ discounts: []
541
+ };
561
542
  }
562
543
  return data;
563
544
  }
564
545
  async retrieve(params) {
565
- if ("code" in params) {
566
- const data2 = await this.apiClient.get(
567
- `/discounts/code/${params.code}`
568
- );
569
- if ("isError" in data2 && data2.isError || !data2 || !("id" in data2)) {
570
- console.error(`Discount with code ${params.code} not found`);
571
- return null;
572
- }
573
- return data2;
574
- }
575
- const data = await this.apiClient.get(
576
- `/discounts/id/${params.id}`
546
+ const data = await this.apiClient.post(
547
+ `/discounts/retrieve`,
548
+ params
577
549
  );
578
- if ("isError" in data && data.isError || !data || !("id" in data)) {
579
- console.error(`Discount with id ${params.id} not found`);
550
+ if ("isError" in data && data.isError || !data || !("id" in data) || !("discount" in data)) {
551
+ console.error(`Discount not found`);
580
552
  return null;
581
553
  }
582
554
  return data;
@@ -686,40 +658,24 @@ var Products = class {
686
658
  this.apiClient = createApiClient(apiKey, proxy);
687
659
  }
688
660
  async list(params) {
689
- const queryParams = new URLSearchParams();
690
- if (params) {
691
- queryParams.set("params", JSON.stringify(params));
692
- }
693
- const data = await this.apiClient.get(
694
- `/products?${queryParams.toString()}`
661
+ const data = await this.apiClient.post(
662
+ "/products",
663
+ params
695
664
  );
696
- if (!data || !Array.isArray(data) || "isError" in data && data.isError) {
697
- return [];
665
+ if (!data || !Array.isArray(data) || "isError" in data && data.isError || !("products" in data)) {
666
+ return {
667
+ products: []
668
+ };
698
669
  }
699
670
  return data;
700
671
  }
701
672
  async retrieve(params) {
702
- if ("seoHandle" in params && typeof params?.seoHandle === "string") {
703
- const data = await this.apiClient.get(
704
- `/products/${params.seoHandle}`
705
- );
706
- if ("isError" in data && data.isError || !data || !("id" in data)) {
707
- console.error(`Product with seoHandle ${params.seoHandle} not found`);
708
- return null;
709
- }
710
- return data;
711
- }
712
- if ("id" in params && typeof params?.id === "string") {
713
- const data = await this.apiClient.get(
714
- `/products/id/${params.id}`
715
- );
716
- if ("isError" in data && data.isError || !data || !("id" in data)) {
717
- console.error(`Product with id ${params.id} not found`);
718
- return null;
719
- }
720
- return data;
673
+ const data = await this.apiClient.post("/products/retrieve", params);
674
+ if ("isError" in data && data.isError || !data || !("id" in data) || !("product" in data)) {
675
+ console.error(`Product not found`);
676
+ return null;
721
677
  }
722
- return null;
678
+ return data;
723
679
  }
724
680
  };
725
681
  var products_default = Products;
package/dist/index.mjs CHANGED
@@ -293,10 +293,10 @@ var Client = class {
293
293
  async getCheckoutShippingRates(clientSecret, checkoutId) {
294
294
  const apiClient = createApiClient(clientSecret, this.proxy);
295
295
  const data = await apiClient.get(
296
- `/checkout/shipping/${checkoutId}`
296
+ `/checkout/${checkoutId}/shipping/rates`
297
297
  );
298
- if ("isError" in data && data.isError || !data || !Array.isArray(data)) {
299
- return [];
298
+ if ("isError" in data && data.isError || !data || !("rates" in data)) {
299
+ return {};
300
300
  }
301
301
  return data;
302
302
  }
@@ -399,36 +399,18 @@ var Collections = class {
399
399
  this.apiClient = createApiClient(apiKey, proxy);
400
400
  }
401
401
  async list(params) {
402
- const queryParams = new URLSearchParams();
403
- if (params) {
404
- queryParams.set("params", JSON.stringify(params));
405
- }
406
- const data = await this.apiClient.get(
407
- `/collections?${queryParams.toString()}`
408
- );
409
- if (!data || !Array.isArray(data) || "isError" in data && data.isError) {
410
- return [];
402
+ const data = await this.apiClient.post(`/collections`, params);
403
+ if (!data || !Array.isArray(data) || "isError" in data && data.isError || !("collections" in data)) {
404
+ return {
405
+ collections: []
406
+ };
411
407
  }
412
408
  return data;
413
409
  }
414
410
  async retrieve(params) {
415
- if ("seoHandle" in params) {
416
- const data2 = await this.apiClient.get(
417
- `/collections/${params.seoHandle}`
418
- );
419
- if ("isError" in data2 && data2.isError || !data2 || !("id" in data2)) {
420
- console.error(
421
- `Collection with seoHandle ${params.seoHandle} not found`
422
- );
423
- return null;
424
- }
425
- return data2;
426
- }
427
- const data = await this.apiClient.get(
428
- `/collections/id/${params.id}`
429
- );
430
- if ("isError" in data && data.isError || !data || !("id" in data)) {
431
- console.error(`Collection with id ${params.id} not found`);
411
+ const data = await this.apiClient.post(`/collections/retrieve`, params);
412
+ if ("isError" in data && data.isError || !data || !("id" in data) || !("collection" in data)) {
413
+ console.error(`Collection not found`);
432
414
  return null;
433
415
  }
434
416
  return data;
@@ -511,34 +493,24 @@ var Discounts = class {
511
493
  this.apiClient = createApiClient(apiKey, proxy);
512
494
  }
513
495
  async list(params) {
514
- const queryParams = new URLSearchParams();
515
- if (params) {
516
- queryParams.set("params", JSON.stringify(params));
517
- }
518
- const data = await this.apiClient.get(
519
- `/discounts?${queryParams.toString()}`
496
+ const data = await this.apiClient.post(
497
+ "/discounts",
498
+ params
520
499
  );
521
- if (!data || !Array.isArray(data) || "isError" in data && data.isError) {
522
- return [];
500
+ if (!data || !Array.isArray(data) || "isError" in data && data.isError || !("discounts" in data)) {
501
+ return {
502
+ discounts: []
503
+ };
523
504
  }
524
505
  return data;
525
506
  }
526
507
  async retrieve(params) {
527
- if ("code" in params) {
528
- const data2 = await this.apiClient.get(
529
- `/discounts/code/${params.code}`
530
- );
531
- if ("isError" in data2 && data2.isError || !data2 || !("id" in data2)) {
532
- console.error(`Discount with code ${params.code} not found`);
533
- return null;
534
- }
535
- return data2;
536
- }
537
- const data = await this.apiClient.get(
538
- `/discounts/id/${params.id}`
508
+ const data = await this.apiClient.post(
509
+ `/discounts/retrieve`,
510
+ params
539
511
  );
540
- if ("isError" in data && data.isError || !data || !("id" in data)) {
541
- console.error(`Discount with id ${params.id} not found`);
512
+ if ("isError" in data && data.isError || !data || !("id" in data) || !("discount" in data)) {
513
+ console.error(`Discount not found`);
542
514
  return null;
543
515
  }
544
516
  return data;
@@ -648,40 +620,24 @@ var Products = class {
648
620
  this.apiClient = createApiClient(apiKey, proxy);
649
621
  }
650
622
  async list(params) {
651
- const queryParams = new URLSearchParams();
652
- if (params) {
653
- queryParams.set("params", JSON.stringify(params));
654
- }
655
- const data = await this.apiClient.get(
656
- `/products?${queryParams.toString()}`
623
+ const data = await this.apiClient.post(
624
+ "/products",
625
+ params
657
626
  );
658
- if (!data || !Array.isArray(data) || "isError" in data && data.isError) {
659
- return [];
627
+ if (!data || !Array.isArray(data) || "isError" in data && data.isError || !("products" in data)) {
628
+ return {
629
+ products: []
630
+ };
660
631
  }
661
632
  return data;
662
633
  }
663
634
  async retrieve(params) {
664
- if ("seoHandle" in params && typeof params?.seoHandle === "string") {
665
- const data = await this.apiClient.get(
666
- `/products/${params.seoHandle}`
667
- );
668
- if ("isError" in data && data.isError || !data || !("id" in data)) {
669
- console.error(`Product with seoHandle ${params.seoHandle} not found`);
670
- return null;
671
- }
672
- return data;
673
- }
674
- if ("id" in params && typeof params?.id === "string") {
675
- const data = await this.apiClient.get(
676
- `/products/id/${params.id}`
677
- );
678
- if ("isError" in data && data.isError || !data || !("id" in data)) {
679
- console.error(`Product with id ${params.id} not found`);
680
- return null;
681
- }
682
- return data;
635
+ const data = await this.apiClient.post("/products/retrieve", params);
636
+ if ("isError" in data && data.isError || !data || !("id" in data) || !("product" in data)) {
637
+ console.error(`Product not found`);
638
+ return null;
683
639
  }
684
- return null;
640
+ return data;
685
641
  }
686
642
  };
687
643
  var products_default = Products;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@betterstore/sdk",
3
- "version": "0.5.23",
3
+ "version": "0.5.25",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -11,13 +11,14 @@
11
11
  ],
12
12
  "devDependencies": {
13
13
  "@types/axios": "^0.14.4",
14
- "tsup": "^8.4.0",
15
14
  "eslint": "^9.29.0",
15
+ "tsup": "^8.4.0",
16
16
  "typescript": "5.8.2",
17
17
  "@betterstore/eslint-config": "0.0.0",
18
18
  "@betterstore/typescript-config": "0.0.0"
19
19
  },
20
20
  "dependencies": {
21
+ "@betterstore/bridge": "^0.0.2",
21
22
  "axios": "^1.8.2",
22
23
  "zod": "^3.24.2"
23
24
  },