@betterstore/sdk 0.5.9 → 0.5.11
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 +31 -5
- package/dist/index.d.ts +31 -5
- package/dist/index.js +32 -19
- package/dist/index.mjs +32 -19
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -90,6 +90,12 @@ interface CheckoutSession {
|
|
|
90
90
|
status: "IN_PROGRESS" | "PAYMENT_PENDING" | "ABANDONED" | "CANCELED" | "FAILED";
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
+
type AutosuggestAddressResult = {
|
|
94
|
+
id: string;
|
|
95
|
+
title: string;
|
|
96
|
+
};
|
|
97
|
+
type LookupAddressResult = AutosuggestAddressResult & Pick<Address, "line1" | "line2" | "city" | "province" | "provinceCode" | "country" | "countryCode" | "zipCode">;
|
|
98
|
+
|
|
93
99
|
type SortOrder = "asc" | "desc";
|
|
94
100
|
type GetListParams<A, B> = {
|
|
95
101
|
sortBy?: A;
|
|
@@ -335,8 +341,6 @@ type RetrieveDiscountParams = {
|
|
|
335
341
|
code: string;
|
|
336
342
|
};
|
|
337
343
|
|
|
338
|
-
type AutocompleteAddressResult = Pick<Address, "line1" | "line2" | "city" | "province" | "provinceCode" | "country" | "countryCode" | "zipCode">;
|
|
339
|
-
|
|
340
344
|
interface CustomerSession {
|
|
341
345
|
customerId: string;
|
|
342
346
|
expiresAt: Date;
|
|
@@ -495,6 +499,30 @@ declare class Client {
|
|
|
495
499
|
* Update a customer
|
|
496
500
|
*/
|
|
497
501
|
updateCustomer(clientSecret: string, customerId: string, params: CustomerUpdateParams): Promise<Customer$1 | null>;
|
|
502
|
+
/**
|
|
503
|
+
* Get exchange rate for a currency
|
|
504
|
+
*/
|
|
505
|
+
getExchangeRate(clientSecret: string, baseCurrency: string, targetCurrency: string): Promise<number>;
|
|
506
|
+
/**
|
|
507
|
+
* Get autosuggest address results
|
|
508
|
+
*/
|
|
509
|
+
getAutosuggestAddressResults(clientSecret: string, params: {
|
|
510
|
+
query: string;
|
|
511
|
+
locale?: string;
|
|
512
|
+
latitude?: string;
|
|
513
|
+
longitude?: string;
|
|
514
|
+
countryCode?: string;
|
|
515
|
+
}): Promise<AutosuggestAddressResult[]>;
|
|
516
|
+
/**
|
|
517
|
+
* Get lookup address results
|
|
518
|
+
*/
|
|
519
|
+
getLookupAddressResults(clientSecret: string, params: {
|
|
520
|
+
query: string;
|
|
521
|
+
locale?: string;
|
|
522
|
+
latitude?: string;
|
|
523
|
+
longitude?: string;
|
|
524
|
+
countryCode?: string;
|
|
525
|
+
}): Promise<LookupAddressResult[]>;
|
|
498
526
|
}
|
|
499
527
|
|
|
500
528
|
declare class Collections {
|
|
@@ -541,8 +569,6 @@ declare class Helpers {
|
|
|
541
569
|
constructor(proxy?: string);
|
|
542
570
|
formatCurrency(currency: string): string;
|
|
543
571
|
formatPrice(priceInCents: number, currency: string, exchangeRate?: number | null): string;
|
|
544
|
-
getExchangeRate(baseCurrency: string, targetCurrency: string): Promise<number>;
|
|
545
|
-
getAutocompleteAddressResults(query: string, locale?: string): Promise<AutocompleteAddressResult[]>;
|
|
546
572
|
}
|
|
547
573
|
|
|
548
574
|
declare class Products {
|
|
@@ -570,4 +596,4 @@ declare function createStoreHelpers(config?: {
|
|
|
570
596
|
proxy?: string;
|
|
571
597
|
}): Helpers;
|
|
572
598
|
|
|
573
|
-
export { type Address, type
|
|
599
|
+
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -90,6 +90,12 @@ interface CheckoutSession {
|
|
|
90
90
|
status: "IN_PROGRESS" | "PAYMENT_PENDING" | "ABANDONED" | "CANCELED" | "FAILED";
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
+
type AutosuggestAddressResult = {
|
|
94
|
+
id: string;
|
|
95
|
+
title: string;
|
|
96
|
+
};
|
|
97
|
+
type LookupAddressResult = AutosuggestAddressResult & Pick<Address, "line1" | "line2" | "city" | "province" | "provinceCode" | "country" | "countryCode" | "zipCode">;
|
|
98
|
+
|
|
93
99
|
type SortOrder = "asc" | "desc";
|
|
94
100
|
type GetListParams<A, B> = {
|
|
95
101
|
sortBy?: A;
|
|
@@ -335,8 +341,6 @@ type RetrieveDiscountParams = {
|
|
|
335
341
|
code: string;
|
|
336
342
|
};
|
|
337
343
|
|
|
338
|
-
type AutocompleteAddressResult = Pick<Address, "line1" | "line2" | "city" | "province" | "provinceCode" | "country" | "countryCode" | "zipCode">;
|
|
339
|
-
|
|
340
344
|
interface CustomerSession {
|
|
341
345
|
customerId: string;
|
|
342
346
|
expiresAt: Date;
|
|
@@ -495,6 +499,30 @@ declare class Client {
|
|
|
495
499
|
* Update a customer
|
|
496
500
|
*/
|
|
497
501
|
updateCustomer(clientSecret: string, customerId: string, params: CustomerUpdateParams): Promise<Customer$1 | null>;
|
|
502
|
+
/**
|
|
503
|
+
* Get exchange rate for a currency
|
|
504
|
+
*/
|
|
505
|
+
getExchangeRate(clientSecret: string, baseCurrency: string, targetCurrency: string): Promise<number>;
|
|
506
|
+
/**
|
|
507
|
+
* Get autosuggest address results
|
|
508
|
+
*/
|
|
509
|
+
getAutosuggestAddressResults(clientSecret: string, params: {
|
|
510
|
+
query: string;
|
|
511
|
+
locale?: string;
|
|
512
|
+
latitude?: string;
|
|
513
|
+
longitude?: string;
|
|
514
|
+
countryCode?: string;
|
|
515
|
+
}): Promise<AutosuggestAddressResult[]>;
|
|
516
|
+
/**
|
|
517
|
+
* Get lookup address results
|
|
518
|
+
*/
|
|
519
|
+
getLookupAddressResults(clientSecret: string, params: {
|
|
520
|
+
query: string;
|
|
521
|
+
locale?: string;
|
|
522
|
+
latitude?: string;
|
|
523
|
+
longitude?: string;
|
|
524
|
+
countryCode?: string;
|
|
525
|
+
}): Promise<LookupAddressResult[]>;
|
|
498
526
|
}
|
|
499
527
|
|
|
500
528
|
declare class Collections {
|
|
@@ -541,8 +569,6 @@ declare class Helpers {
|
|
|
541
569
|
constructor(proxy?: string);
|
|
542
570
|
formatCurrency(currency: string): string;
|
|
543
571
|
formatPrice(priceInCents: number, currency: string, exchangeRate?: number | null): string;
|
|
544
|
-
getExchangeRate(baseCurrency: string, targetCurrency: string): Promise<number>;
|
|
545
|
-
getAutocompleteAddressResults(query: string, locale?: string): Promise<AutocompleteAddressResult[]>;
|
|
546
572
|
}
|
|
547
573
|
|
|
548
574
|
declare class Products {
|
|
@@ -570,4 +596,4 @@ declare function createStoreHelpers(config?: {
|
|
|
570
596
|
proxy?: string;
|
|
571
597
|
}): Helpers;
|
|
572
598
|
|
|
573
|
-
export { type Address, type
|
|
599
|
+
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 };
|
package/dist/index.js
CHANGED
|
@@ -396,6 +396,38 @@ var Client = class {
|
|
|
396
396
|
}
|
|
397
397
|
return data;
|
|
398
398
|
}
|
|
399
|
+
/**
|
|
400
|
+
* Get exchange rate for a currency
|
|
401
|
+
*/
|
|
402
|
+
async getExchangeRate(clientSecret, baseCurrency, targetCurrency) {
|
|
403
|
+
const apiClient = createApiClient(clientSecret, this.proxy);
|
|
404
|
+
const { data } = await apiClient.get(`/helpers/rates/${baseCurrency}`);
|
|
405
|
+
const rate = data.rates[targetCurrency];
|
|
406
|
+
if (!rate) {
|
|
407
|
+
throw new Error("Could not get exchange rate for target currency");
|
|
408
|
+
}
|
|
409
|
+
return rate;
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* Get autosuggest address results
|
|
413
|
+
*/
|
|
414
|
+
async getAutosuggestAddressResults(clientSecret, params) {
|
|
415
|
+
const apiClient = createApiClient(clientSecret, this.proxy);
|
|
416
|
+
const { data } = await apiClient.get("/helpers/autosuggest-address", {
|
|
417
|
+
params
|
|
418
|
+
});
|
|
419
|
+
return data;
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* Get lookup address results
|
|
423
|
+
*/
|
|
424
|
+
async getLookupAddressResults(clientSecret, params) {
|
|
425
|
+
const apiClient = createApiClient(clientSecret, this.proxy);
|
|
426
|
+
const { data } = await apiClient.get("/helpers/lookup-address", {
|
|
427
|
+
params
|
|
428
|
+
});
|
|
429
|
+
return data;
|
|
430
|
+
}
|
|
399
431
|
};
|
|
400
432
|
var client_default = Client;
|
|
401
433
|
|
|
@@ -645,25 +677,6 @@ var Helpers = class {
|
|
|
645
677
|
}).format(amount);
|
|
646
678
|
return formattedPrice;
|
|
647
679
|
}
|
|
648
|
-
async getExchangeRate(baseCurrency, targetCurrency) {
|
|
649
|
-
const apiClient = createApiClient("", this.proxy);
|
|
650
|
-
const { data } = await apiClient.get(`/helpers/rates/${baseCurrency}`);
|
|
651
|
-
const rate = data.rates[targetCurrency];
|
|
652
|
-
if (!rate) {
|
|
653
|
-
throw new Error("Could not get exchange rate for target currency");
|
|
654
|
-
}
|
|
655
|
-
return rate;
|
|
656
|
-
}
|
|
657
|
-
async getAutocompleteAddressResults(query, locale) {
|
|
658
|
-
const apiClient = createApiClient("", this.proxy);
|
|
659
|
-
const { data } = await apiClient.get("/helpers/autocomplete-address", {
|
|
660
|
-
params: {
|
|
661
|
-
locale,
|
|
662
|
-
query
|
|
663
|
-
}
|
|
664
|
-
});
|
|
665
|
-
return data;
|
|
666
|
-
}
|
|
667
680
|
};
|
|
668
681
|
var helpers_default = Helpers;
|
|
669
682
|
|
package/dist/index.mjs
CHANGED
|
@@ -358,6 +358,38 @@ var Client = class {
|
|
|
358
358
|
}
|
|
359
359
|
return data;
|
|
360
360
|
}
|
|
361
|
+
/**
|
|
362
|
+
* Get exchange rate for a currency
|
|
363
|
+
*/
|
|
364
|
+
async getExchangeRate(clientSecret, baseCurrency, targetCurrency) {
|
|
365
|
+
const apiClient = createApiClient(clientSecret, this.proxy);
|
|
366
|
+
const { data } = await apiClient.get(`/helpers/rates/${baseCurrency}`);
|
|
367
|
+
const rate = data.rates[targetCurrency];
|
|
368
|
+
if (!rate) {
|
|
369
|
+
throw new Error("Could not get exchange rate for target currency");
|
|
370
|
+
}
|
|
371
|
+
return rate;
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Get autosuggest address results
|
|
375
|
+
*/
|
|
376
|
+
async getAutosuggestAddressResults(clientSecret, params) {
|
|
377
|
+
const apiClient = createApiClient(clientSecret, this.proxy);
|
|
378
|
+
const { data } = await apiClient.get("/helpers/autosuggest-address", {
|
|
379
|
+
params
|
|
380
|
+
});
|
|
381
|
+
return data;
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Get lookup address results
|
|
385
|
+
*/
|
|
386
|
+
async getLookupAddressResults(clientSecret, params) {
|
|
387
|
+
const apiClient = createApiClient(clientSecret, this.proxy);
|
|
388
|
+
const { data } = await apiClient.get("/helpers/lookup-address", {
|
|
389
|
+
params
|
|
390
|
+
});
|
|
391
|
+
return data;
|
|
392
|
+
}
|
|
361
393
|
};
|
|
362
394
|
var client_default = Client;
|
|
363
395
|
|
|
@@ -607,25 +639,6 @@ var Helpers = class {
|
|
|
607
639
|
}).format(amount);
|
|
608
640
|
return formattedPrice;
|
|
609
641
|
}
|
|
610
|
-
async getExchangeRate(baseCurrency, targetCurrency) {
|
|
611
|
-
const apiClient = createApiClient("", this.proxy);
|
|
612
|
-
const { data } = await apiClient.get(`/helpers/rates/${baseCurrency}`);
|
|
613
|
-
const rate = data.rates[targetCurrency];
|
|
614
|
-
if (!rate) {
|
|
615
|
-
throw new Error("Could not get exchange rate for target currency");
|
|
616
|
-
}
|
|
617
|
-
return rate;
|
|
618
|
-
}
|
|
619
|
-
async getAutocompleteAddressResults(query, locale) {
|
|
620
|
-
const apiClient = createApiClient("", this.proxy);
|
|
621
|
-
const { data } = await apiClient.get("/helpers/autocomplete-address", {
|
|
622
|
-
params: {
|
|
623
|
-
locale,
|
|
624
|
-
query
|
|
625
|
-
}
|
|
626
|
-
});
|
|
627
|
-
return data;
|
|
628
|
-
}
|
|
629
642
|
};
|
|
630
643
|
var helpers_default = Helpers;
|
|
631
644
|
|