@betterstore/sdk 0.5.22 → 0.5.24
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 +65 -20
- package/dist/index.d.ts +65 -20
- package/dist/index.js +4 -4
- package/dist/index.mjs +4 -4
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -2,16 +2,62 @@ import axios from 'axios';
|
|
|
2
2
|
|
|
3
3
|
declare const createApiClient: (apiKey: string, proxy?: string) => axios.AxiosInstance;
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
interface GetShippingRatesResponse {
|
|
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";
|
|
8
14
|
name: string;
|
|
15
|
+
description?: string;
|
|
16
|
+
priceInCents: number;
|
|
17
|
+
}
|
|
18
|
+
interface BasePlatformCarrierRate {
|
|
19
|
+
id: string;
|
|
20
|
+
providerId: ProviderId;
|
|
21
|
+
type: "PLATFORM_CARRIER";
|
|
22
|
+
platformCarrierSlug: string;
|
|
23
|
+
priceInCents: number;
|
|
24
|
+
}
|
|
25
|
+
interface ZasilkovnaPlatformCarrierRate extends BasePlatformCarrierRate {
|
|
26
|
+
providerId: "zasilkovna";
|
|
27
|
+
platformCarrierSlug: "bs_platform_zasilkovna";
|
|
28
|
+
service: "z_box";
|
|
29
|
+
clientSecret: string;
|
|
30
|
+
}
|
|
31
|
+
type PlatformCarrierRate = ZasilkovnaPlatformCarrierRate;
|
|
32
|
+
interface BaseCustomShippingVendorRate {
|
|
33
|
+
id: string;
|
|
34
|
+
providerId: ProviderId;
|
|
35
|
+
type: "CUSTOM_SHIPPING_VENDOR";
|
|
36
|
+
shippingVendorCarrierType: ShippingVendorCarrierType;
|
|
9
37
|
priceInCents: number;
|
|
10
38
|
}
|
|
11
|
-
interface
|
|
12
|
-
|
|
39
|
+
interface ZasilkovnaCustomShippingVendorRate extends BaseCustomShippingVendorRate {
|
|
40
|
+
providerId: "zasilkovna";
|
|
41
|
+
shippingVendorCarrierType: Extract<ShippingVendorCarrierType, "zasilkovna">;
|
|
42
|
+
service: "z_box";
|
|
13
43
|
clientSecret: string;
|
|
14
44
|
}
|
|
45
|
+
type CustomShippingVendorRate = ZasilkovnaCustomShippingVendorRate;
|
|
46
|
+
type PrebuiltRateType = "PICKUP_IN_STORE" | "LOCAL_DELIVERY";
|
|
47
|
+
interface BasePrebuiltRate {
|
|
48
|
+
id: string;
|
|
49
|
+
type: "PREBUILT";
|
|
50
|
+
prebuiltRateType: PrebuiltRateType;
|
|
51
|
+
priceInCents: number;
|
|
52
|
+
}
|
|
53
|
+
interface PrebuildPickupInStoreRate extends BasePrebuiltRate {
|
|
54
|
+
prebuiltRateType: Extract<PrebuiltRateType, "PICKUP_IN_STORE">;
|
|
55
|
+
expectedPickupDateInHours: number;
|
|
56
|
+
}
|
|
57
|
+
interface PrebuiltLocalDeliveryRate extends BasePrebuiltRate {
|
|
58
|
+
prebuiltRateType: Extract<PrebuiltRateType, "LOCAL_DELIVERY">;
|
|
59
|
+
}
|
|
60
|
+
type PrebuiltRate = PrebuildPickupInStoreRate | PrebuiltLocalDeliveryRate;
|
|
15
61
|
|
|
16
62
|
type ProductData = Pick<Product, "title" | "description" | "images" | "category" | "tags" | "sku" | "barcode" | "vendor" | "isPhysical" | "weightInGrams" | "heightInCm" | "widthInCm" | "lengthInCm" | "priceInCents" | "billingType" | "billingInterval" | "billingIntervalCount"> & {
|
|
17
63
|
productId: string;
|
|
@@ -49,13 +95,12 @@ interface CheckoutUpdateParams {
|
|
|
49
95
|
}
|
|
50
96
|
|
|
51
97
|
type ShipmentData = {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
98
|
+
rateId: string;
|
|
99
|
+
providerId?: string;
|
|
100
|
+
priceInCents: number;
|
|
55
101
|
pickupPointId?: string;
|
|
56
102
|
trackingId?: string;
|
|
57
103
|
trackingUrl?: string;
|
|
58
|
-
priceInCents: number;
|
|
59
104
|
};
|
|
60
105
|
type CheckoutShipment = {
|
|
61
106
|
id: string;
|
|
@@ -154,12 +199,12 @@ interface ProductVariant {
|
|
|
154
199
|
title: string;
|
|
155
200
|
description?: string;
|
|
156
201
|
images: string[];
|
|
157
|
-
trackInventory: boolean;
|
|
158
202
|
sku?: string;
|
|
159
203
|
barcode?: string;
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
204
|
+
inventoryItem: {
|
|
205
|
+
stockPolicy: "CONTINUE" | "DENY";
|
|
206
|
+
trackInventory: boolean;
|
|
207
|
+
};
|
|
163
208
|
isPhysical: boolean;
|
|
164
209
|
weightInGrams?: number;
|
|
165
210
|
heightInCm?: number;
|
|
@@ -197,12 +242,12 @@ interface Product {
|
|
|
197
242
|
billingType: ProductBillingType;
|
|
198
243
|
billingInterval: ProductBillingInterval;
|
|
199
244
|
billingIntervalCount: number;
|
|
200
|
-
trackInventory: boolean;
|
|
201
245
|
sku?: string;
|
|
202
246
|
barcode?: string;
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
247
|
+
inventoryItem: {
|
|
248
|
+
stockPolicy: "CONTINUE" | "DENY";
|
|
249
|
+
trackInventory: boolean;
|
|
250
|
+
};
|
|
206
251
|
seoPageTitle?: string;
|
|
207
252
|
seoDescription?: string;
|
|
208
253
|
seoHandle?: string;
|
|
@@ -223,7 +268,7 @@ type ListProductsQuery = {
|
|
|
223
268
|
createdAt?: DateQueryType;
|
|
224
269
|
updatedAt?: DateQueryType;
|
|
225
270
|
};
|
|
226
|
-
type ListProductsSortBy = "createdAt" | "updatedAt" | "title" | "
|
|
271
|
+
type ListProductsSortBy = "createdAt" | "updatedAt" | "title" | "priceInCents";
|
|
227
272
|
type ListProductsParams = GetListParams<ListProductsSortBy, ListProductsQuery>;
|
|
228
273
|
type RetrieveProductParams = {
|
|
229
274
|
seoHandle: string;
|
|
@@ -450,7 +495,7 @@ declare class Checkout {
|
|
|
450
495
|
/**
|
|
451
496
|
* Get shipping rates for a checkout session
|
|
452
497
|
*/
|
|
453
|
-
getShippingRates(checkoutId: string
|
|
498
|
+
getShippingRates(checkoutId: string): Promise<GetShippingRatesResponse>;
|
|
454
499
|
/**
|
|
455
500
|
* Generate payment secret for a checkout session
|
|
456
501
|
*/
|
|
@@ -599,4 +644,4 @@ declare function createStoreHelpers(config?: {
|
|
|
599
644
|
proxy?: string;
|
|
600
645
|
}): Helpers;
|
|
601
646
|
|
|
602
|
-
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 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 };
|
|
647
|
+
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -2,16 +2,62 @@ import axios from 'axios';
|
|
|
2
2
|
|
|
3
3
|
declare const createApiClient: (apiKey: string, proxy?: string) => axios.AxiosInstance;
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
interface GetShippingRatesResponse {
|
|
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";
|
|
8
14
|
name: string;
|
|
15
|
+
description?: string;
|
|
16
|
+
priceInCents: number;
|
|
17
|
+
}
|
|
18
|
+
interface BasePlatformCarrierRate {
|
|
19
|
+
id: string;
|
|
20
|
+
providerId: ProviderId;
|
|
21
|
+
type: "PLATFORM_CARRIER";
|
|
22
|
+
platformCarrierSlug: string;
|
|
23
|
+
priceInCents: number;
|
|
24
|
+
}
|
|
25
|
+
interface ZasilkovnaPlatformCarrierRate extends BasePlatformCarrierRate {
|
|
26
|
+
providerId: "zasilkovna";
|
|
27
|
+
platformCarrierSlug: "bs_platform_zasilkovna";
|
|
28
|
+
service: "z_box";
|
|
29
|
+
clientSecret: string;
|
|
30
|
+
}
|
|
31
|
+
type PlatformCarrierRate = ZasilkovnaPlatformCarrierRate;
|
|
32
|
+
interface BaseCustomShippingVendorRate {
|
|
33
|
+
id: string;
|
|
34
|
+
providerId: ProviderId;
|
|
35
|
+
type: "CUSTOM_SHIPPING_VENDOR";
|
|
36
|
+
shippingVendorCarrierType: ShippingVendorCarrierType;
|
|
9
37
|
priceInCents: number;
|
|
10
38
|
}
|
|
11
|
-
interface
|
|
12
|
-
|
|
39
|
+
interface ZasilkovnaCustomShippingVendorRate extends BaseCustomShippingVendorRate {
|
|
40
|
+
providerId: "zasilkovna";
|
|
41
|
+
shippingVendorCarrierType: Extract<ShippingVendorCarrierType, "zasilkovna">;
|
|
42
|
+
service: "z_box";
|
|
13
43
|
clientSecret: string;
|
|
14
44
|
}
|
|
45
|
+
type CustomShippingVendorRate = ZasilkovnaCustomShippingVendorRate;
|
|
46
|
+
type PrebuiltRateType = "PICKUP_IN_STORE" | "LOCAL_DELIVERY";
|
|
47
|
+
interface BasePrebuiltRate {
|
|
48
|
+
id: string;
|
|
49
|
+
type: "PREBUILT";
|
|
50
|
+
prebuiltRateType: PrebuiltRateType;
|
|
51
|
+
priceInCents: number;
|
|
52
|
+
}
|
|
53
|
+
interface PrebuildPickupInStoreRate extends BasePrebuiltRate {
|
|
54
|
+
prebuiltRateType: Extract<PrebuiltRateType, "PICKUP_IN_STORE">;
|
|
55
|
+
expectedPickupDateInHours: number;
|
|
56
|
+
}
|
|
57
|
+
interface PrebuiltLocalDeliveryRate extends BasePrebuiltRate {
|
|
58
|
+
prebuiltRateType: Extract<PrebuiltRateType, "LOCAL_DELIVERY">;
|
|
59
|
+
}
|
|
60
|
+
type PrebuiltRate = PrebuildPickupInStoreRate | PrebuiltLocalDeliveryRate;
|
|
15
61
|
|
|
16
62
|
type ProductData = Pick<Product, "title" | "description" | "images" | "category" | "tags" | "sku" | "barcode" | "vendor" | "isPhysical" | "weightInGrams" | "heightInCm" | "widthInCm" | "lengthInCm" | "priceInCents" | "billingType" | "billingInterval" | "billingIntervalCount"> & {
|
|
17
63
|
productId: string;
|
|
@@ -49,13 +95,12 @@ interface CheckoutUpdateParams {
|
|
|
49
95
|
}
|
|
50
96
|
|
|
51
97
|
type ShipmentData = {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
98
|
+
rateId: string;
|
|
99
|
+
providerId?: string;
|
|
100
|
+
priceInCents: number;
|
|
55
101
|
pickupPointId?: string;
|
|
56
102
|
trackingId?: string;
|
|
57
103
|
trackingUrl?: string;
|
|
58
|
-
priceInCents: number;
|
|
59
104
|
};
|
|
60
105
|
type CheckoutShipment = {
|
|
61
106
|
id: string;
|
|
@@ -154,12 +199,12 @@ interface ProductVariant {
|
|
|
154
199
|
title: string;
|
|
155
200
|
description?: string;
|
|
156
201
|
images: string[];
|
|
157
|
-
trackInventory: boolean;
|
|
158
202
|
sku?: string;
|
|
159
203
|
barcode?: string;
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
204
|
+
inventoryItem: {
|
|
205
|
+
stockPolicy: "CONTINUE" | "DENY";
|
|
206
|
+
trackInventory: boolean;
|
|
207
|
+
};
|
|
163
208
|
isPhysical: boolean;
|
|
164
209
|
weightInGrams?: number;
|
|
165
210
|
heightInCm?: number;
|
|
@@ -197,12 +242,12 @@ interface Product {
|
|
|
197
242
|
billingType: ProductBillingType;
|
|
198
243
|
billingInterval: ProductBillingInterval;
|
|
199
244
|
billingIntervalCount: number;
|
|
200
|
-
trackInventory: boolean;
|
|
201
245
|
sku?: string;
|
|
202
246
|
barcode?: string;
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
247
|
+
inventoryItem: {
|
|
248
|
+
stockPolicy: "CONTINUE" | "DENY";
|
|
249
|
+
trackInventory: boolean;
|
|
250
|
+
};
|
|
206
251
|
seoPageTitle?: string;
|
|
207
252
|
seoDescription?: string;
|
|
208
253
|
seoHandle?: string;
|
|
@@ -223,7 +268,7 @@ type ListProductsQuery = {
|
|
|
223
268
|
createdAt?: DateQueryType;
|
|
224
269
|
updatedAt?: DateQueryType;
|
|
225
270
|
};
|
|
226
|
-
type ListProductsSortBy = "createdAt" | "updatedAt" | "title" | "
|
|
271
|
+
type ListProductsSortBy = "createdAt" | "updatedAt" | "title" | "priceInCents";
|
|
227
272
|
type ListProductsParams = GetListParams<ListProductsSortBy, ListProductsQuery>;
|
|
228
273
|
type RetrieveProductParams = {
|
|
229
274
|
seoHandle: string;
|
|
@@ -450,7 +495,7 @@ declare class Checkout {
|
|
|
450
495
|
/**
|
|
451
496
|
* Get shipping rates for a checkout session
|
|
452
497
|
*/
|
|
453
|
-
getShippingRates(checkoutId: string
|
|
498
|
+
getShippingRates(checkoutId: string): Promise<GetShippingRatesResponse>;
|
|
454
499
|
/**
|
|
455
500
|
* Generate payment secret for a checkout session
|
|
456
501
|
*/
|
|
@@ -599,4 +644,4 @@ declare function createStoreHelpers(config?: {
|
|
|
599
644
|
proxy?: string;
|
|
600
645
|
}): Helpers;
|
|
601
646
|
|
|
602
|
-
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 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 };
|
|
647
|
+
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 };
|
package/dist/index.js
CHANGED
|
@@ -222,12 +222,12 @@ var Checkout = class {
|
|
|
222
222
|
/**
|
|
223
223
|
* Get shipping rates for a checkout session
|
|
224
224
|
*/
|
|
225
|
-
async getShippingRates(checkoutId
|
|
225
|
+
async getShippingRates(checkoutId) {
|
|
226
226
|
const data = await this.apiClient.get(
|
|
227
|
-
`/checkout/${checkoutId}/shipping
|
|
227
|
+
`/checkout/${checkoutId}/shipping/rates`
|
|
228
228
|
);
|
|
229
|
-
if ("isError" in data && data.isError || !data
|
|
230
|
-
return
|
|
229
|
+
if ("isError" in data && data.isError || !data) {
|
|
230
|
+
return {};
|
|
231
231
|
}
|
|
232
232
|
return data;
|
|
233
233
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -184,12 +184,12 @@ var Checkout = class {
|
|
|
184
184
|
/**
|
|
185
185
|
* Get shipping rates for a checkout session
|
|
186
186
|
*/
|
|
187
|
-
async getShippingRates(checkoutId
|
|
187
|
+
async getShippingRates(checkoutId) {
|
|
188
188
|
const data = await this.apiClient.get(
|
|
189
|
-
`/checkout/${checkoutId}/shipping
|
|
189
|
+
`/checkout/${checkoutId}/shipping/rates`
|
|
190
190
|
);
|
|
191
|
-
if ("isError" in data && data.isError || !data
|
|
192
|
-
return
|
|
191
|
+
if ("isError" in data && data.isError || !data) {
|
|
192
|
+
return {};
|
|
193
193
|
}
|
|
194
194
|
return data;
|
|
195
195
|
}
|