@betterstore/sdk 0.5.24 → 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 +98 -261
- package/dist/index.d.ts +98 -261
- package/dist/index.js +35 -79
- package/dist/index.mjs +35 -79
- package/package.json +3 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,63 +1,107 @@
|
|
|
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
|
-
interface
|
|
6
|
-
[shipmentId: string]: ShippingRate[];
|
|
7
|
-
}
|
|
8
|
-
type ShippingVendorCarrierType = "zasilkovna";
|
|
9
|
-
type ProviderId = "zasilkovna";
|
|
10
|
-
type ShippingRate = FixedRate | PlatformCarrierRate | CustomShippingVendorRate | PrebuiltRate;
|
|
11
|
-
interface FixedRate {
|
|
12
|
-
id: string;
|
|
13
|
-
type: "FIXED";
|
|
14
|
-
name: string;
|
|
15
|
-
description?: string;
|
|
16
|
-
priceInCents: number;
|
|
17
|
-
}
|
|
18
|
-
interface BasePlatformCarrierRate {
|
|
6
|
+
interface Discount {
|
|
19
7
|
id: string;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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;
|
|
24
36
|
}
|
|
25
|
-
interface
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
service: "z_box";
|
|
29
|
-
clientSecret: string;
|
|
37
|
+
interface VariantOption {
|
|
38
|
+
name: string;
|
|
39
|
+
value: string;
|
|
30
40
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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;
|
|
37
56
|
priceInCents: number;
|
|
57
|
+
billingType: ProductBillingType;
|
|
58
|
+
billingInterval: ProductBillingInterval;
|
|
59
|
+
billingIntervalCount: number;
|
|
60
|
+
metadata?: Record<string, any>;
|
|
61
|
+
variantOptions: VariantOption[];
|
|
38
62
|
}
|
|
39
|
-
interface
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
service: "z_box";
|
|
43
|
-
clientSecret: string;
|
|
63
|
+
interface ProductOption {
|
|
64
|
+
name: string;
|
|
65
|
+
values: string[];
|
|
44
66
|
}
|
|
45
|
-
type
|
|
46
|
-
type
|
|
47
|
-
|
|
67
|
+
type ProductStatus = "DRAFT" | "ACTIVE" | "ARCHIVED";
|
|
68
|
+
type ProductBillingInterval = "DAY" | "WEEK" | "MONTH" | "YEAR";
|
|
69
|
+
type ProductBillingType = "ONE_TIME" | "SUBSCRIPTION";
|
|
70
|
+
interface Product {
|
|
48
71
|
id: string;
|
|
49
|
-
|
|
50
|
-
|
|
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;
|
|
51
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[];
|
|
52
102
|
}
|
|
53
|
-
interface
|
|
54
|
-
prebuiltRateType: Extract<PrebuiltRateType, "PICKUP_IN_STORE">;
|
|
55
|
-
expectedPickupDateInHours: number;
|
|
56
|
-
}
|
|
57
|
-
interface PrebuiltLocalDeliveryRate extends BasePrebuiltRate {
|
|
58
|
-
prebuiltRateType: Extract<PrebuiltRateType, "LOCAL_DELIVERY">;
|
|
103
|
+
interface ProductWithoutVariants extends Omit<Product, "productVariants"> {
|
|
59
104
|
}
|
|
60
|
-
type PrebuiltRate = PrebuildPickupInStoreRate | PrebuiltLocalDeliveryRate;
|
|
61
105
|
|
|
62
106
|
type ProductData = Pick<Product, "title" | "description" | "images" | "category" | "tags" | "sku" | "barcode" | "vendor" | "isPhysical" | "weightInGrams" | "heightInCm" | "widthInCm" | "lengthInCm" | "priceInCents" | "billingType" | "billingInterval" | "billingIntervalCount"> & {
|
|
63
107
|
productId: string;
|
|
@@ -93,7 +137,6 @@ interface CheckoutUpdateParams {
|
|
|
93
137
|
customerId?: string;
|
|
94
138
|
shipments?: CheckoutShipment[];
|
|
95
139
|
}
|
|
96
|
-
|
|
97
140
|
type ShipmentData = {
|
|
98
141
|
rateId: string;
|
|
99
142
|
providerId?: string;
|
|
@@ -150,154 +193,6 @@ type LookupAddressResult = {
|
|
|
150
193
|
address: Pick<Address, "line1" | "city" | "province" | "provinceCode" | "country" | "countryCode" | "zipCode">;
|
|
151
194
|
};
|
|
152
195
|
|
|
153
|
-
type SortOrder = "asc" | "desc";
|
|
154
|
-
type GetListParams<A, B> = {
|
|
155
|
-
sortBy?: A;
|
|
156
|
-
sortOrder?: SortOrder;
|
|
157
|
-
query?: B & {
|
|
158
|
-
NOT?: B | B[];
|
|
159
|
-
OR?: B[];
|
|
160
|
-
};
|
|
161
|
-
};
|
|
162
|
-
type EnumQueryType<T> = {
|
|
163
|
-
equals?: T;
|
|
164
|
-
in?: T[];
|
|
165
|
-
not?: T;
|
|
166
|
-
notIn?: T[];
|
|
167
|
-
};
|
|
168
|
-
type StringArrayQueryType<T = string> = {
|
|
169
|
-
equals?: T[];
|
|
170
|
-
has?: T;
|
|
171
|
-
hasEvery?: T[];
|
|
172
|
-
hasSome?: T[];
|
|
173
|
-
isEmpty?: boolean;
|
|
174
|
-
};
|
|
175
|
-
type DateQueryType = {
|
|
176
|
-
equals?: Date;
|
|
177
|
-
in?: Date[];
|
|
178
|
-
not?: Date;
|
|
179
|
-
notIn?: Date[];
|
|
180
|
-
gt?: Date;
|
|
181
|
-
gte?: Date;
|
|
182
|
-
lt?: Date;
|
|
183
|
-
lte?: Date;
|
|
184
|
-
};
|
|
185
|
-
type OptionalDateQueryType = DateQueryType & {
|
|
186
|
-
isSet: boolean;
|
|
187
|
-
};
|
|
188
|
-
type ArrayModelQueryType<T> = {
|
|
189
|
-
some?: T;
|
|
190
|
-
every?: T;
|
|
191
|
-
none?: T;
|
|
192
|
-
};
|
|
193
|
-
|
|
194
|
-
interface VariantOption {
|
|
195
|
-
name: string;
|
|
196
|
-
value: string;
|
|
197
|
-
}
|
|
198
|
-
interface ProductVariant {
|
|
199
|
-
title: string;
|
|
200
|
-
description?: string;
|
|
201
|
-
images: string[];
|
|
202
|
-
sku?: string;
|
|
203
|
-
barcode?: string;
|
|
204
|
-
inventoryItem: {
|
|
205
|
-
stockPolicy: "CONTINUE" | "DENY";
|
|
206
|
-
trackInventory: boolean;
|
|
207
|
-
};
|
|
208
|
-
isPhysical: boolean;
|
|
209
|
-
weightInGrams?: number;
|
|
210
|
-
heightInCm?: number;
|
|
211
|
-
widthInCm?: number;
|
|
212
|
-
lengthInCm?: number;
|
|
213
|
-
priceInCents: number;
|
|
214
|
-
billingType: ProductBillingType;
|
|
215
|
-
billingInterval: ProductBillingInterval;
|
|
216
|
-
billingIntervalCount: number;
|
|
217
|
-
metadata?: Record<string, any>;
|
|
218
|
-
variantOptions: VariantOption[];
|
|
219
|
-
}
|
|
220
|
-
interface ProductOption {
|
|
221
|
-
name: string;
|
|
222
|
-
values: string[];
|
|
223
|
-
}
|
|
224
|
-
type ProductStatus = "DRAFT" | "ACTIVE" | "ARCHIVED";
|
|
225
|
-
type ProductBillingInterval = "DAY" | "WEEK" | "MONTH" | "YEAR";
|
|
226
|
-
type ProductBillingType = "ONE_TIME" | "SUBSCRIPTION";
|
|
227
|
-
interface Product {
|
|
228
|
-
id: string;
|
|
229
|
-
createdAt: Date;
|
|
230
|
-
updatedAt: Date;
|
|
231
|
-
title: string;
|
|
232
|
-
description?: string;
|
|
233
|
-
images: string[];
|
|
234
|
-
category: string;
|
|
235
|
-
tags: string[];
|
|
236
|
-
isPhysical: boolean;
|
|
237
|
-
weightInGrams?: number;
|
|
238
|
-
heightInCm?: number;
|
|
239
|
-
widthInCm?: number;
|
|
240
|
-
lengthInCm?: number;
|
|
241
|
-
priceInCents: number;
|
|
242
|
-
billingType: ProductBillingType;
|
|
243
|
-
billingInterval: ProductBillingInterval;
|
|
244
|
-
billingIntervalCount: number;
|
|
245
|
-
sku?: string;
|
|
246
|
-
barcode?: string;
|
|
247
|
-
inventoryItem: {
|
|
248
|
-
stockPolicy: "CONTINUE" | "DENY";
|
|
249
|
-
trackInventory: boolean;
|
|
250
|
-
};
|
|
251
|
-
seoPageTitle?: string;
|
|
252
|
-
seoDescription?: string;
|
|
253
|
-
seoHandle?: string;
|
|
254
|
-
vendor?: string;
|
|
255
|
-
metadata?: Record<string, any>;
|
|
256
|
-
status: ProductStatus;
|
|
257
|
-
options: ProductOption[];
|
|
258
|
-
productVariants: ProductVariant[];
|
|
259
|
-
}
|
|
260
|
-
interface ProductWithoutVariants extends Omit<Product, "productVariants"> {
|
|
261
|
-
}
|
|
262
|
-
type ListProductsQuery = {
|
|
263
|
-
collectionIDs?: StringArrayQueryType;
|
|
264
|
-
collections?: ArrayModelQueryType<{
|
|
265
|
-
seoHandle?: StringArrayQueryType;
|
|
266
|
-
}>;
|
|
267
|
-
tags?: StringArrayQueryType;
|
|
268
|
-
createdAt?: DateQueryType;
|
|
269
|
-
updatedAt?: DateQueryType;
|
|
270
|
-
};
|
|
271
|
-
type ListProductsSortBy = "createdAt" | "updatedAt" | "title" | "priceInCents";
|
|
272
|
-
type ListProductsParams = GetListParams<ListProductsSortBy, ListProductsQuery>;
|
|
273
|
-
type RetrieveProductParams = {
|
|
274
|
-
seoHandle: string;
|
|
275
|
-
} | {
|
|
276
|
-
id: string;
|
|
277
|
-
};
|
|
278
|
-
|
|
279
|
-
interface Collection {
|
|
280
|
-
id: string;
|
|
281
|
-
title: string;
|
|
282
|
-
description?: string;
|
|
283
|
-
images: string[];
|
|
284
|
-
tags: string[];
|
|
285
|
-
seoPageTitle?: string;
|
|
286
|
-
seoDescription?: string;
|
|
287
|
-
seoHandle?: string;
|
|
288
|
-
}
|
|
289
|
-
interface CollectionWithProducts extends Collection {
|
|
290
|
-
products: ProductWithoutVariants[];
|
|
291
|
-
}
|
|
292
|
-
type ListCollectionsQuery = undefined;
|
|
293
|
-
type ListCollectionsSortBy = "createdAt" | "updatedAt" | "title";
|
|
294
|
-
type ListCollectionsParams = GetListParams<ListCollectionsSortBy, ListCollectionsQuery>;
|
|
295
|
-
type RetrieveCollectionParams = {
|
|
296
|
-
seoHandle: string;
|
|
297
|
-
} | {
|
|
298
|
-
id: string;
|
|
299
|
-
};
|
|
300
|
-
|
|
301
196
|
type Address = {
|
|
302
197
|
name: string;
|
|
303
198
|
phone: string;
|
|
@@ -337,64 +232,6 @@ interface CustomerSubscription {
|
|
|
337
232
|
}
|
|
338
233
|
type CustomerSubscriptionUpdateParams = Partial<Pick<CustomerSubscription, "cancelAtPeriodEnd">>;
|
|
339
234
|
|
|
340
|
-
interface Discount {
|
|
341
|
-
id: string;
|
|
342
|
-
createdAt: Date;
|
|
343
|
-
updatedAt: Date;
|
|
344
|
-
type: "AMOUNT_OFF_PRODUCTS" | "BUY_X_GET_Y" | "AMOUNT_OFF_ORDER" | "FREE_SHIPPING";
|
|
345
|
-
method: "CODE" | "AUTOMATIC";
|
|
346
|
-
code?: string | null;
|
|
347
|
-
title?: string | null;
|
|
348
|
-
value: number;
|
|
349
|
-
valueType: "PERCENTAGE" | "FIXED_AMOUNT" | "FREE";
|
|
350
|
-
discountScope: "PRODUCTS" | "COLLECTIONS";
|
|
351
|
-
allowedProductIDs: string[];
|
|
352
|
-
allowedCollectionIDs: string[];
|
|
353
|
-
allowedCombinations: ("ORDER" | "PRODUCT" | "SHIPPING")[];
|
|
354
|
-
minimumRequirementsType: "NONE" | "MINIMUM_ORDER_AMOUNT" | "MINIMUM_PRODUCT_QUANTITY";
|
|
355
|
-
minimumRequirementsValue?: number | null;
|
|
356
|
-
requiredProductIDs: string[];
|
|
357
|
-
requiredCollectionIDs: string[];
|
|
358
|
-
minimumRequirementsScope: "PRODUCTS" | "COLLECTIONS";
|
|
359
|
-
maxUses?: number | null;
|
|
360
|
-
maxUsesPerCustomer?: number | null;
|
|
361
|
-
maxAllowedProductQuantity?: number | null;
|
|
362
|
-
uses: number;
|
|
363
|
-
subscriptionDiscountDurationType: "ONE_TIME" | "RECURRING" | "FOREVER";
|
|
364
|
-
subscriptionDiscountDurationValue: number;
|
|
365
|
-
stripeDiscountId?: string | null;
|
|
366
|
-
startsAt: Date;
|
|
367
|
-
expiresAt?: Date | null;
|
|
368
|
-
status: "ACTIVE" | "EXPIRED" | "SCHEDULED";
|
|
369
|
-
organizationId: string;
|
|
370
|
-
}
|
|
371
|
-
type ListDiscountsQuery = {
|
|
372
|
-
type?: EnumQueryType<Discount["type"]>;
|
|
373
|
-
valueType?: EnumQueryType<Discount["valueType"]>;
|
|
374
|
-
method?: EnumQueryType<Discount["method"]>;
|
|
375
|
-
status?: EnumQueryType<Discount["status"]>;
|
|
376
|
-
minimumRequirementsType?: EnumQueryType<Discount["minimumRequirementsType"]>;
|
|
377
|
-
minimumRequirementsScope?: EnumQueryType<Discount["minimumRequirementsScope"]>;
|
|
378
|
-
discountScope?: EnumQueryType<Discount["discountScope"]>;
|
|
379
|
-
subscriptionDiscountDurationType?: EnumQueryType<Discount["subscriptionDiscountDurationType"]>;
|
|
380
|
-
allowedCombinations?: StringArrayQueryType<Discount["allowedCombinations"]>;
|
|
381
|
-
allowedProductIDs?: StringArrayQueryType<Discount["allowedProductIDs"]>;
|
|
382
|
-
allowedCollectionIDs?: StringArrayQueryType<Discount["allowedCollectionIDs"]>;
|
|
383
|
-
requiredProductIDs?: StringArrayQueryType<Discount["requiredProductIDs"]>;
|
|
384
|
-
requiredCollectionIDs?: StringArrayQueryType<Discount["requiredCollectionIDs"]>;
|
|
385
|
-
startsAt?: DateQueryType;
|
|
386
|
-
expiresAt?: OptionalDateQueryType;
|
|
387
|
-
createdAt?: DateQueryType;
|
|
388
|
-
updatedAt?: DateQueryType;
|
|
389
|
-
};
|
|
390
|
-
type ListDiscountsSortBy = "createdAt" | "updatedAt" | "expiresAt" | "startsAt";
|
|
391
|
-
type ListDiscountsParams = GetListParams<ListDiscountsSortBy, ListDiscountsQuery>;
|
|
392
|
-
type RetrieveDiscountParams = {
|
|
393
|
-
id: string;
|
|
394
|
-
} | {
|
|
395
|
-
code: string;
|
|
396
|
-
};
|
|
397
|
-
|
|
398
235
|
interface CustomerSession {
|
|
399
236
|
customerId: string;
|
|
400
237
|
expiresAt: Date;
|
|
@@ -532,7 +369,7 @@ declare class Client {
|
|
|
532
369
|
/**
|
|
533
370
|
* Get shipping rates for a checkout session
|
|
534
371
|
*/
|
|
535
|
-
getCheckoutShippingRates(clientSecret: string, checkoutId: string): Promise<
|
|
372
|
+
getCheckoutShippingRates(clientSecret: string, checkoutId: string): Promise<GetShippingRatesResponse>;
|
|
536
373
|
/**
|
|
537
374
|
* Generate payment secret for a checkout session
|
|
538
375
|
*/
|
|
@@ -576,8 +413,8 @@ declare class Client {
|
|
|
576
413
|
declare class Collections {
|
|
577
414
|
private apiClient;
|
|
578
415
|
constructor(apiKey: string, proxy?: string);
|
|
579
|
-
list(params?:
|
|
580
|
-
retrieve(params:
|
|
416
|
+
list<T extends ListCollectionsParams>(params?: T): Promise<ListCollectionsResponse<T>>;
|
|
417
|
+
retrieve<T extends RetrieveCollectionParams>(params: T): Promise<RetrieveCollectionResponse<T> | null>;
|
|
581
418
|
}
|
|
582
419
|
|
|
583
420
|
declare class Customer {
|
|
@@ -608,8 +445,8 @@ declare class Customer {
|
|
|
608
445
|
declare class Discounts {
|
|
609
446
|
private apiClient;
|
|
610
447
|
constructor(apiKey: string, proxy?: string);
|
|
611
|
-
list(params?:
|
|
612
|
-
retrieve(params:
|
|
448
|
+
list<T extends ListDiscountsParams>(params?: T): Promise<ListDiscountsResponse>;
|
|
449
|
+
retrieve<T extends RetrieveDiscountParams>(params: T): Promise<RetrieveDiscountResponse | null>;
|
|
613
450
|
}
|
|
614
451
|
|
|
615
452
|
declare class Helpers {
|
|
@@ -622,8 +459,8 @@ declare class Helpers {
|
|
|
622
459
|
declare class Products {
|
|
623
460
|
private apiClient;
|
|
624
461
|
constructor(apiKey: string, proxy?: string);
|
|
625
|
-
list(params?:
|
|
626
|
-
retrieve(params:
|
|
462
|
+
list<T extends ListProductsParams>(params?: T): Promise<ListProductsResponse<T>>;
|
|
463
|
+
retrieve<T extends RetrieveProductParams>(params: T): Promise<RetrieveProductResponse<T> | null>;
|
|
627
464
|
}
|
|
628
465
|
|
|
629
466
|
declare function createBetterStore(config: {
|
|
@@ -644,4 +481,4 @@ declare function createStoreHelpers(config?: {
|
|
|
644
481
|
proxy?: string;
|
|
645
482
|
}): Helpers;
|
|
646
483
|
|
|
647
|
-
export { type Address, type AutosuggestAddressResult, type CheckoutCreateParams, type CheckoutSession, type CheckoutUpdateParams, type
|
|
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,63 +1,107 @@
|
|
|
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
|
-
interface
|
|
6
|
-
[shipmentId: string]: ShippingRate[];
|
|
7
|
-
}
|
|
8
|
-
type ShippingVendorCarrierType = "zasilkovna";
|
|
9
|
-
type ProviderId = "zasilkovna";
|
|
10
|
-
type ShippingRate = FixedRate | PlatformCarrierRate | CustomShippingVendorRate | PrebuiltRate;
|
|
11
|
-
interface FixedRate {
|
|
12
|
-
id: string;
|
|
13
|
-
type: "FIXED";
|
|
14
|
-
name: string;
|
|
15
|
-
description?: string;
|
|
16
|
-
priceInCents: number;
|
|
17
|
-
}
|
|
18
|
-
interface BasePlatformCarrierRate {
|
|
6
|
+
interface Discount {
|
|
19
7
|
id: string;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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;
|
|
24
36
|
}
|
|
25
|
-
interface
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
service: "z_box";
|
|
29
|
-
clientSecret: string;
|
|
37
|
+
interface VariantOption {
|
|
38
|
+
name: string;
|
|
39
|
+
value: string;
|
|
30
40
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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;
|
|
37
56
|
priceInCents: number;
|
|
57
|
+
billingType: ProductBillingType;
|
|
58
|
+
billingInterval: ProductBillingInterval;
|
|
59
|
+
billingIntervalCount: number;
|
|
60
|
+
metadata?: Record<string, any>;
|
|
61
|
+
variantOptions: VariantOption[];
|
|
38
62
|
}
|
|
39
|
-
interface
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
service: "z_box";
|
|
43
|
-
clientSecret: string;
|
|
63
|
+
interface ProductOption {
|
|
64
|
+
name: string;
|
|
65
|
+
values: string[];
|
|
44
66
|
}
|
|
45
|
-
type
|
|
46
|
-
type
|
|
47
|
-
|
|
67
|
+
type ProductStatus = "DRAFT" | "ACTIVE" | "ARCHIVED";
|
|
68
|
+
type ProductBillingInterval = "DAY" | "WEEK" | "MONTH" | "YEAR";
|
|
69
|
+
type ProductBillingType = "ONE_TIME" | "SUBSCRIPTION";
|
|
70
|
+
interface Product {
|
|
48
71
|
id: string;
|
|
49
|
-
|
|
50
|
-
|
|
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;
|
|
51
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[];
|
|
52
102
|
}
|
|
53
|
-
interface
|
|
54
|
-
prebuiltRateType: Extract<PrebuiltRateType, "PICKUP_IN_STORE">;
|
|
55
|
-
expectedPickupDateInHours: number;
|
|
56
|
-
}
|
|
57
|
-
interface PrebuiltLocalDeliveryRate extends BasePrebuiltRate {
|
|
58
|
-
prebuiltRateType: Extract<PrebuiltRateType, "LOCAL_DELIVERY">;
|
|
103
|
+
interface ProductWithoutVariants extends Omit<Product, "productVariants"> {
|
|
59
104
|
}
|
|
60
|
-
type PrebuiltRate = PrebuildPickupInStoreRate | PrebuiltLocalDeliveryRate;
|
|
61
105
|
|
|
62
106
|
type ProductData = Pick<Product, "title" | "description" | "images" | "category" | "tags" | "sku" | "barcode" | "vendor" | "isPhysical" | "weightInGrams" | "heightInCm" | "widthInCm" | "lengthInCm" | "priceInCents" | "billingType" | "billingInterval" | "billingIntervalCount"> & {
|
|
63
107
|
productId: string;
|
|
@@ -93,7 +137,6 @@ interface CheckoutUpdateParams {
|
|
|
93
137
|
customerId?: string;
|
|
94
138
|
shipments?: CheckoutShipment[];
|
|
95
139
|
}
|
|
96
|
-
|
|
97
140
|
type ShipmentData = {
|
|
98
141
|
rateId: string;
|
|
99
142
|
providerId?: string;
|
|
@@ -150,154 +193,6 @@ type LookupAddressResult = {
|
|
|
150
193
|
address: Pick<Address, "line1" | "city" | "province" | "provinceCode" | "country" | "countryCode" | "zipCode">;
|
|
151
194
|
};
|
|
152
195
|
|
|
153
|
-
type SortOrder = "asc" | "desc";
|
|
154
|
-
type GetListParams<A, B> = {
|
|
155
|
-
sortBy?: A;
|
|
156
|
-
sortOrder?: SortOrder;
|
|
157
|
-
query?: B & {
|
|
158
|
-
NOT?: B | B[];
|
|
159
|
-
OR?: B[];
|
|
160
|
-
};
|
|
161
|
-
};
|
|
162
|
-
type EnumQueryType<T> = {
|
|
163
|
-
equals?: T;
|
|
164
|
-
in?: T[];
|
|
165
|
-
not?: T;
|
|
166
|
-
notIn?: T[];
|
|
167
|
-
};
|
|
168
|
-
type StringArrayQueryType<T = string> = {
|
|
169
|
-
equals?: T[];
|
|
170
|
-
has?: T;
|
|
171
|
-
hasEvery?: T[];
|
|
172
|
-
hasSome?: T[];
|
|
173
|
-
isEmpty?: boolean;
|
|
174
|
-
};
|
|
175
|
-
type DateQueryType = {
|
|
176
|
-
equals?: Date;
|
|
177
|
-
in?: Date[];
|
|
178
|
-
not?: Date;
|
|
179
|
-
notIn?: Date[];
|
|
180
|
-
gt?: Date;
|
|
181
|
-
gte?: Date;
|
|
182
|
-
lt?: Date;
|
|
183
|
-
lte?: Date;
|
|
184
|
-
};
|
|
185
|
-
type OptionalDateQueryType = DateQueryType & {
|
|
186
|
-
isSet: boolean;
|
|
187
|
-
};
|
|
188
|
-
type ArrayModelQueryType<T> = {
|
|
189
|
-
some?: T;
|
|
190
|
-
every?: T;
|
|
191
|
-
none?: T;
|
|
192
|
-
};
|
|
193
|
-
|
|
194
|
-
interface VariantOption {
|
|
195
|
-
name: string;
|
|
196
|
-
value: string;
|
|
197
|
-
}
|
|
198
|
-
interface ProductVariant {
|
|
199
|
-
title: string;
|
|
200
|
-
description?: string;
|
|
201
|
-
images: string[];
|
|
202
|
-
sku?: string;
|
|
203
|
-
barcode?: string;
|
|
204
|
-
inventoryItem: {
|
|
205
|
-
stockPolicy: "CONTINUE" | "DENY";
|
|
206
|
-
trackInventory: boolean;
|
|
207
|
-
};
|
|
208
|
-
isPhysical: boolean;
|
|
209
|
-
weightInGrams?: number;
|
|
210
|
-
heightInCm?: number;
|
|
211
|
-
widthInCm?: number;
|
|
212
|
-
lengthInCm?: number;
|
|
213
|
-
priceInCents: number;
|
|
214
|
-
billingType: ProductBillingType;
|
|
215
|
-
billingInterval: ProductBillingInterval;
|
|
216
|
-
billingIntervalCount: number;
|
|
217
|
-
metadata?: Record<string, any>;
|
|
218
|
-
variantOptions: VariantOption[];
|
|
219
|
-
}
|
|
220
|
-
interface ProductOption {
|
|
221
|
-
name: string;
|
|
222
|
-
values: string[];
|
|
223
|
-
}
|
|
224
|
-
type ProductStatus = "DRAFT" | "ACTIVE" | "ARCHIVED";
|
|
225
|
-
type ProductBillingInterval = "DAY" | "WEEK" | "MONTH" | "YEAR";
|
|
226
|
-
type ProductBillingType = "ONE_TIME" | "SUBSCRIPTION";
|
|
227
|
-
interface Product {
|
|
228
|
-
id: string;
|
|
229
|
-
createdAt: Date;
|
|
230
|
-
updatedAt: Date;
|
|
231
|
-
title: string;
|
|
232
|
-
description?: string;
|
|
233
|
-
images: string[];
|
|
234
|
-
category: string;
|
|
235
|
-
tags: string[];
|
|
236
|
-
isPhysical: boolean;
|
|
237
|
-
weightInGrams?: number;
|
|
238
|
-
heightInCm?: number;
|
|
239
|
-
widthInCm?: number;
|
|
240
|
-
lengthInCm?: number;
|
|
241
|
-
priceInCents: number;
|
|
242
|
-
billingType: ProductBillingType;
|
|
243
|
-
billingInterval: ProductBillingInterval;
|
|
244
|
-
billingIntervalCount: number;
|
|
245
|
-
sku?: string;
|
|
246
|
-
barcode?: string;
|
|
247
|
-
inventoryItem: {
|
|
248
|
-
stockPolicy: "CONTINUE" | "DENY";
|
|
249
|
-
trackInventory: boolean;
|
|
250
|
-
};
|
|
251
|
-
seoPageTitle?: string;
|
|
252
|
-
seoDescription?: string;
|
|
253
|
-
seoHandle?: string;
|
|
254
|
-
vendor?: string;
|
|
255
|
-
metadata?: Record<string, any>;
|
|
256
|
-
status: ProductStatus;
|
|
257
|
-
options: ProductOption[];
|
|
258
|
-
productVariants: ProductVariant[];
|
|
259
|
-
}
|
|
260
|
-
interface ProductWithoutVariants extends Omit<Product, "productVariants"> {
|
|
261
|
-
}
|
|
262
|
-
type ListProductsQuery = {
|
|
263
|
-
collectionIDs?: StringArrayQueryType;
|
|
264
|
-
collections?: ArrayModelQueryType<{
|
|
265
|
-
seoHandle?: StringArrayQueryType;
|
|
266
|
-
}>;
|
|
267
|
-
tags?: StringArrayQueryType;
|
|
268
|
-
createdAt?: DateQueryType;
|
|
269
|
-
updatedAt?: DateQueryType;
|
|
270
|
-
};
|
|
271
|
-
type ListProductsSortBy = "createdAt" | "updatedAt" | "title" | "priceInCents";
|
|
272
|
-
type ListProductsParams = GetListParams<ListProductsSortBy, ListProductsQuery>;
|
|
273
|
-
type RetrieveProductParams = {
|
|
274
|
-
seoHandle: string;
|
|
275
|
-
} | {
|
|
276
|
-
id: string;
|
|
277
|
-
};
|
|
278
|
-
|
|
279
|
-
interface Collection {
|
|
280
|
-
id: string;
|
|
281
|
-
title: string;
|
|
282
|
-
description?: string;
|
|
283
|
-
images: string[];
|
|
284
|
-
tags: string[];
|
|
285
|
-
seoPageTitle?: string;
|
|
286
|
-
seoDescription?: string;
|
|
287
|
-
seoHandle?: string;
|
|
288
|
-
}
|
|
289
|
-
interface CollectionWithProducts extends Collection {
|
|
290
|
-
products: ProductWithoutVariants[];
|
|
291
|
-
}
|
|
292
|
-
type ListCollectionsQuery = undefined;
|
|
293
|
-
type ListCollectionsSortBy = "createdAt" | "updatedAt" | "title";
|
|
294
|
-
type ListCollectionsParams = GetListParams<ListCollectionsSortBy, ListCollectionsQuery>;
|
|
295
|
-
type RetrieveCollectionParams = {
|
|
296
|
-
seoHandle: string;
|
|
297
|
-
} | {
|
|
298
|
-
id: string;
|
|
299
|
-
};
|
|
300
|
-
|
|
301
196
|
type Address = {
|
|
302
197
|
name: string;
|
|
303
198
|
phone: string;
|
|
@@ -337,64 +232,6 @@ interface CustomerSubscription {
|
|
|
337
232
|
}
|
|
338
233
|
type CustomerSubscriptionUpdateParams = Partial<Pick<CustomerSubscription, "cancelAtPeriodEnd">>;
|
|
339
234
|
|
|
340
|
-
interface Discount {
|
|
341
|
-
id: string;
|
|
342
|
-
createdAt: Date;
|
|
343
|
-
updatedAt: Date;
|
|
344
|
-
type: "AMOUNT_OFF_PRODUCTS" | "BUY_X_GET_Y" | "AMOUNT_OFF_ORDER" | "FREE_SHIPPING";
|
|
345
|
-
method: "CODE" | "AUTOMATIC";
|
|
346
|
-
code?: string | null;
|
|
347
|
-
title?: string | null;
|
|
348
|
-
value: number;
|
|
349
|
-
valueType: "PERCENTAGE" | "FIXED_AMOUNT" | "FREE";
|
|
350
|
-
discountScope: "PRODUCTS" | "COLLECTIONS";
|
|
351
|
-
allowedProductIDs: string[];
|
|
352
|
-
allowedCollectionIDs: string[];
|
|
353
|
-
allowedCombinations: ("ORDER" | "PRODUCT" | "SHIPPING")[];
|
|
354
|
-
minimumRequirementsType: "NONE" | "MINIMUM_ORDER_AMOUNT" | "MINIMUM_PRODUCT_QUANTITY";
|
|
355
|
-
minimumRequirementsValue?: number | null;
|
|
356
|
-
requiredProductIDs: string[];
|
|
357
|
-
requiredCollectionIDs: string[];
|
|
358
|
-
minimumRequirementsScope: "PRODUCTS" | "COLLECTIONS";
|
|
359
|
-
maxUses?: number | null;
|
|
360
|
-
maxUsesPerCustomer?: number | null;
|
|
361
|
-
maxAllowedProductQuantity?: number | null;
|
|
362
|
-
uses: number;
|
|
363
|
-
subscriptionDiscountDurationType: "ONE_TIME" | "RECURRING" | "FOREVER";
|
|
364
|
-
subscriptionDiscountDurationValue: number;
|
|
365
|
-
stripeDiscountId?: string | null;
|
|
366
|
-
startsAt: Date;
|
|
367
|
-
expiresAt?: Date | null;
|
|
368
|
-
status: "ACTIVE" | "EXPIRED" | "SCHEDULED";
|
|
369
|
-
organizationId: string;
|
|
370
|
-
}
|
|
371
|
-
type ListDiscountsQuery = {
|
|
372
|
-
type?: EnumQueryType<Discount["type"]>;
|
|
373
|
-
valueType?: EnumQueryType<Discount["valueType"]>;
|
|
374
|
-
method?: EnumQueryType<Discount["method"]>;
|
|
375
|
-
status?: EnumQueryType<Discount["status"]>;
|
|
376
|
-
minimumRequirementsType?: EnumQueryType<Discount["minimumRequirementsType"]>;
|
|
377
|
-
minimumRequirementsScope?: EnumQueryType<Discount["minimumRequirementsScope"]>;
|
|
378
|
-
discountScope?: EnumQueryType<Discount["discountScope"]>;
|
|
379
|
-
subscriptionDiscountDurationType?: EnumQueryType<Discount["subscriptionDiscountDurationType"]>;
|
|
380
|
-
allowedCombinations?: StringArrayQueryType<Discount["allowedCombinations"]>;
|
|
381
|
-
allowedProductIDs?: StringArrayQueryType<Discount["allowedProductIDs"]>;
|
|
382
|
-
allowedCollectionIDs?: StringArrayQueryType<Discount["allowedCollectionIDs"]>;
|
|
383
|
-
requiredProductIDs?: StringArrayQueryType<Discount["requiredProductIDs"]>;
|
|
384
|
-
requiredCollectionIDs?: StringArrayQueryType<Discount["requiredCollectionIDs"]>;
|
|
385
|
-
startsAt?: DateQueryType;
|
|
386
|
-
expiresAt?: OptionalDateQueryType;
|
|
387
|
-
createdAt?: DateQueryType;
|
|
388
|
-
updatedAt?: DateQueryType;
|
|
389
|
-
};
|
|
390
|
-
type ListDiscountsSortBy = "createdAt" | "updatedAt" | "expiresAt" | "startsAt";
|
|
391
|
-
type ListDiscountsParams = GetListParams<ListDiscountsSortBy, ListDiscountsQuery>;
|
|
392
|
-
type RetrieveDiscountParams = {
|
|
393
|
-
id: string;
|
|
394
|
-
} | {
|
|
395
|
-
code: string;
|
|
396
|
-
};
|
|
397
|
-
|
|
398
235
|
interface CustomerSession {
|
|
399
236
|
customerId: string;
|
|
400
237
|
expiresAt: Date;
|
|
@@ -532,7 +369,7 @@ declare class Client {
|
|
|
532
369
|
/**
|
|
533
370
|
* Get shipping rates for a checkout session
|
|
534
371
|
*/
|
|
535
|
-
getCheckoutShippingRates(clientSecret: string, checkoutId: string): Promise<
|
|
372
|
+
getCheckoutShippingRates(clientSecret: string, checkoutId: string): Promise<GetShippingRatesResponse>;
|
|
536
373
|
/**
|
|
537
374
|
* Generate payment secret for a checkout session
|
|
538
375
|
*/
|
|
@@ -576,8 +413,8 @@ declare class Client {
|
|
|
576
413
|
declare class Collections {
|
|
577
414
|
private apiClient;
|
|
578
415
|
constructor(apiKey: string, proxy?: string);
|
|
579
|
-
list(params?:
|
|
580
|
-
retrieve(params:
|
|
416
|
+
list<T extends ListCollectionsParams>(params?: T): Promise<ListCollectionsResponse<T>>;
|
|
417
|
+
retrieve<T extends RetrieveCollectionParams>(params: T): Promise<RetrieveCollectionResponse<T> | null>;
|
|
581
418
|
}
|
|
582
419
|
|
|
583
420
|
declare class Customer {
|
|
@@ -608,8 +445,8 @@ declare class Customer {
|
|
|
608
445
|
declare class Discounts {
|
|
609
446
|
private apiClient;
|
|
610
447
|
constructor(apiKey: string, proxy?: string);
|
|
611
|
-
list(params?:
|
|
612
|
-
retrieve(params:
|
|
448
|
+
list<T extends ListDiscountsParams>(params?: T): Promise<ListDiscountsResponse>;
|
|
449
|
+
retrieve<T extends RetrieveDiscountParams>(params: T): Promise<RetrieveDiscountResponse | null>;
|
|
613
450
|
}
|
|
614
451
|
|
|
615
452
|
declare class Helpers {
|
|
@@ -622,8 +459,8 @@ declare class Helpers {
|
|
|
622
459
|
declare class Products {
|
|
623
460
|
private apiClient;
|
|
624
461
|
constructor(apiKey: string, proxy?: string);
|
|
625
|
-
list(params?:
|
|
626
|
-
retrieve(params:
|
|
462
|
+
list<T extends ListProductsParams>(params?: T): Promise<ListProductsResponse<T>>;
|
|
463
|
+
retrieve<T extends RetrieveProductParams>(params: T): Promise<RetrieveProductResponse<T> | null>;
|
|
627
464
|
}
|
|
628
465
|
|
|
629
466
|
declare function createBetterStore(config: {
|
|
@@ -644,4 +481,4 @@ declare function createStoreHelpers(config?: {
|
|
|
644
481
|
proxy?: string;
|
|
645
482
|
}): Helpers;
|
|
646
483
|
|
|
647
|
-
export { type Address, type AutosuggestAddressResult, type CheckoutCreateParams, type CheckoutSession, type CheckoutUpdateParams, type
|
|
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
|
|
334
|
+
`/checkout/${checkoutId}/shipping/rates`
|
|
335
335
|
);
|
|
336
|
-
if ("isError" in data && data.isError || !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
|
|
441
|
-
if (
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
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
|
-
|
|
454
|
-
|
|
455
|
-
|
|
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
|
|
553
|
-
|
|
554
|
-
|
|
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
|
-
|
|
566
|
-
|
|
567
|
-
|
|
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
|
|
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
|
|
690
|
-
|
|
691
|
-
|
|
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
|
-
|
|
703
|
-
|
|
704
|
-
|
|
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
|
|
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
|
|
296
|
+
`/checkout/${checkoutId}/shipping/rates`
|
|
297
297
|
);
|
|
298
|
-
if ("isError" in data && data.isError || !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
|
|
403
|
-
if (
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
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
|
-
|
|
416
|
-
|
|
417
|
-
|
|
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
|
|
515
|
-
|
|
516
|
-
|
|
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
|
-
|
|
528
|
-
|
|
529
|
-
|
|
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
|
|
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
|
|
652
|
-
|
|
653
|
-
|
|
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
|
-
|
|
665
|
-
|
|
666
|
-
|
|
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
|
|
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.
|
|
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
|
},
|