@betterstore/sdk 0.5.9 → 0.5.12

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
@@ -90,6 +90,16 @@ 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
+ position: {
97
+ latitude: number;
98
+ longitude: number;
99
+ };
100
+ };
101
+ type GeocodeAddressResult = Omit<AutosuggestAddressResult, "position"> & Pick<Address, "line1" | "line2" | "city" | "province" | "provinceCode" | "country" | "countryCode" | "zipCode">;
102
+
93
103
  type SortOrder = "asc" | "desc";
94
104
  type GetListParams<A, B> = {
95
105
  sortBy?: A;
@@ -335,8 +345,6 @@ type RetrieveDiscountParams = {
335
345
  code: string;
336
346
  };
337
347
 
338
- type AutocompleteAddressResult = Pick<Address, "line1" | "line2" | "city" | "province" | "provinceCode" | "country" | "countryCode" | "zipCode">;
339
-
340
348
  interface CustomerSession {
341
349
  customerId: string;
342
350
  expiresAt: Date;
@@ -495,6 +503,27 @@ declare class Client {
495
503
  * Update a customer
496
504
  */
497
505
  updateCustomer(clientSecret: string, customerId: string, params: CustomerUpdateParams): Promise<Customer$1 | null>;
506
+ /**
507
+ * Get exchange rate for a currency
508
+ */
509
+ getExchangeRate(clientSecret: string, baseCurrency: string, targetCurrency: string): Promise<number>;
510
+ /**
511
+ * Get autosuggest address results
512
+ */
513
+ getAutosuggestAddressResults(clientSecret: string, params: {
514
+ query: string;
515
+ locale?: string;
516
+ latitude?: string;
517
+ longitude?: string;
518
+ countryCode?: string;
519
+ }): Promise<AutosuggestAddressResult[]>;
520
+ /**
521
+ * Get geocode address results
522
+ */
523
+ getGeocodeAddressResults(clientSecret: string, params: {
524
+ selectedStreetId: string;
525
+ position: AutosuggestAddressResult["position"];
526
+ }): Promise<GeocodeAddressResult[]>;
498
527
  }
499
528
 
500
529
  declare class Collections {
@@ -541,8 +570,6 @@ declare class Helpers {
541
570
  constructor(proxy?: string);
542
571
  formatCurrency(currency: string): string;
543
572
  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
573
  }
547
574
 
548
575
  declare class Products {
@@ -570,4 +597,4 @@ declare function createStoreHelpers(config?: {
570
597
  proxy?: string;
571
598
  }): Helpers;
572
599
 
573
- export { type Address, type AutocompleteAddressResult, 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 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 };
600
+ 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 GeocodeAddressResult, type LineItem, type LineItemCreate, type ListCollectionsParams, type ListCollectionsQuery, type ListCollectionsSortBy, type ListDiscountsParams, type ListDiscountsQuery, type ListDiscountsSortBy, type ListProductsParams, type ListProductsQuery, type ListProductsSortBy, 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,16 @@ 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
+ position: {
97
+ latitude: number;
98
+ longitude: number;
99
+ };
100
+ };
101
+ type GeocodeAddressResult = Omit<AutosuggestAddressResult, "position"> & Pick<Address, "line1" | "line2" | "city" | "province" | "provinceCode" | "country" | "countryCode" | "zipCode">;
102
+
93
103
  type SortOrder = "asc" | "desc";
94
104
  type GetListParams<A, B> = {
95
105
  sortBy?: A;
@@ -335,8 +345,6 @@ type RetrieveDiscountParams = {
335
345
  code: string;
336
346
  };
337
347
 
338
- type AutocompleteAddressResult = Pick<Address, "line1" | "line2" | "city" | "province" | "provinceCode" | "country" | "countryCode" | "zipCode">;
339
-
340
348
  interface CustomerSession {
341
349
  customerId: string;
342
350
  expiresAt: Date;
@@ -495,6 +503,27 @@ declare class Client {
495
503
  * Update a customer
496
504
  */
497
505
  updateCustomer(clientSecret: string, customerId: string, params: CustomerUpdateParams): Promise<Customer$1 | null>;
506
+ /**
507
+ * Get exchange rate for a currency
508
+ */
509
+ getExchangeRate(clientSecret: string, baseCurrency: string, targetCurrency: string): Promise<number>;
510
+ /**
511
+ * Get autosuggest address results
512
+ */
513
+ getAutosuggestAddressResults(clientSecret: string, params: {
514
+ query: string;
515
+ locale?: string;
516
+ latitude?: string;
517
+ longitude?: string;
518
+ countryCode?: string;
519
+ }): Promise<AutosuggestAddressResult[]>;
520
+ /**
521
+ * Get geocode address results
522
+ */
523
+ getGeocodeAddressResults(clientSecret: string, params: {
524
+ selectedStreetId: string;
525
+ position: AutosuggestAddressResult["position"];
526
+ }): Promise<GeocodeAddressResult[]>;
498
527
  }
499
528
 
500
529
  declare class Collections {
@@ -541,8 +570,6 @@ declare class Helpers {
541
570
  constructor(proxy?: string);
542
571
  formatCurrency(currency: string): string;
543
572
  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
573
  }
547
574
 
548
575
  declare class Products {
@@ -570,4 +597,4 @@ declare function createStoreHelpers(config?: {
570
597
  proxy?: string;
571
598
  }): Helpers;
572
599
 
573
- export { type Address, type AutocompleteAddressResult, 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 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 };
600
+ 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 GeocodeAddressResult, type LineItem, type LineItemCreate, type ListCollectionsParams, type ListCollectionsQuery, type ListCollectionsSortBy, type ListDiscountsParams, type ListDiscountsQuery, type ListDiscountsSortBy, type ListProductsParams, type ListProductsQuery, type ListProductsSortBy, 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,47 @@ 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(
405
+ `/helpers/rates/${baseCurrency}`
406
+ );
407
+ const rate = data.rates[targetCurrency];
408
+ if (!rate) {
409
+ throw new Error("Could not get exchange rate for target currency");
410
+ }
411
+ return rate;
412
+ }
413
+ /**
414
+ * Get autosuggest address results
415
+ */
416
+ async getAutosuggestAddressResults(clientSecret, params) {
417
+ const apiClient = createApiClient(clientSecret, this.proxy);
418
+ const { data, ...rest } = await apiClient.get(
419
+ "/helpers/autosuggest-address",
420
+ {
421
+ params
422
+ }
423
+ );
424
+ console.log("autosuggest data", data);
425
+ console.log("autosuggest rest", rest);
426
+ return data;
427
+ }
428
+ /**
429
+ * Get geocode address results
430
+ */
431
+ async getGeocodeAddressResults(clientSecret, params) {
432
+ const apiClient = createApiClient(clientSecret, this.proxy);
433
+ const { data, ...rest } = await apiClient.get("/helpers/geocode-address", {
434
+ params
435
+ });
436
+ console.log("geocode data", data);
437
+ console.log("geocode rest", rest);
438
+ return data;
439
+ }
399
440
  };
400
441
  var client_default = Client;
401
442
 
@@ -645,25 +686,6 @@ var Helpers = class {
645
686
  }).format(amount);
646
687
  return formattedPrice;
647
688
  }
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
689
  };
668
690
  var helpers_default = Helpers;
669
691
 
package/dist/index.mjs CHANGED
@@ -358,6 +358,47 @@ 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(
367
+ `/helpers/rates/${baseCurrency}`
368
+ );
369
+ const rate = data.rates[targetCurrency];
370
+ if (!rate) {
371
+ throw new Error("Could not get exchange rate for target currency");
372
+ }
373
+ return rate;
374
+ }
375
+ /**
376
+ * Get autosuggest address results
377
+ */
378
+ async getAutosuggestAddressResults(clientSecret, params) {
379
+ const apiClient = createApiClient(clientSecret, this.proxy);
380
+ const { data, ...rest } = await apiClient.get(
381
+ "/helpers/autosuggest-address",
382
+ {
383
+ params
384
+ }
385
+ );
386
+ console.log("autosuggest data", data);
387
+ console.log("autosuggest rest", rest);
388
+ return data;
389
+ }
390
+ /**
391
+ * Get geocode address results
392
+ */
393
+ async getGeocodeAddressResults(clientSecret, params) {
394
+ const apiClient = createApiClient(clientSecret, this.proxy);
395
+ const { data, ...rest } = await apiClient.get("/helpers/geocode-address", {
396
+ params
397
+ });
398
+ console.log("geocode data", data);
399
+ console.log("geocode rest", rest);
400
+ return data;
401
+ }
361
402
  };
362
403
  var client_default = Client;
363
404
 
@@ -607,25 +648,6 @@ var Helpers = class {
607
648
  }).format(amount);
608
649
  return formattedPrice;
609
650
  }
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
651
  };
630
652
  var helpers_default = Helpers;
631
653
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@betterstore/sdk",
3
- "version": "0.5.9",
3
+ "version": "0.5.12",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",