@betterstore/sdk 0.3.46 → 0.3.48

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @betterstore/sdk
2
2
 
3
+ ## 0.3.48
4
+
5
+ ### Patch Changes
6
+
7
+ - collections and vendor addded
8
+
9
+ ## 0.3.47
10
+
11
+ ### Patch Changes
12
+
13
+ - currency formatter
14
+
3
15
  ## 0.3.46
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -86,12 +86,22 @@ interface Product {
86
86
  seoPageTitle?: string;
87
87
  seoDescription?: string;
88
88
  seoHandle?: string;
89
+ vendor?: string;
89
90
  status: ProductStatus;
90
91
  options: ProductOption[];
91
92
  productVariants: ProductVariant[];
92
93
  }
93
94
  interface ProductWithoutVariants extends Omit<Product, "productVariants"> {
94
95
  }
96
+ interface Collection {
97
+ id: string;
98
+ title: string;
99
+ description?: string;
100
+ images: string[];
101
+ seoPageTitle?: string;
102
+ seoDescription?: string;
103
+ seoHandle?: string;
104
+ }
95
105
 
96
106
  type ShippingRate = ZasilkovnaRate;
97
107
  interface BaseRate {
@@ -104,7 +114,7 @@ interface ZasilkovnaRate extends BaseRate {
104
114
  clientSecret: string;
105
115
  }
106
116
 
107
- type ProductData = Pick<Product, "title" | "description" | "images" | "category" | "tags" | "sku" | "barcode" | "isPhysical" | "weightInGrams" | "heightInCm" | "widthInCm" | "lengthInCm" | "priceInCents"> & {
117
+ type ProductData = Pick<Product, "title" | "description" | "images" | "category" | "tags" | "sku" | "barcode" | "vendor" | "isPhysical" | "weightInGrams" | "heightInCm" | "widthInCm" | "lengthInCm" | "priceInCents"> & {
108
118
  selectedVariant: Pick<ProductVariant, "title" | "sku" | "barcode" | "images" | "isPhysical" | "weightInGrams" | "heightInCm" | "widthInCm" | "lengthInCm" | "priceInCents" | "variantOptions">;
109
119
  };
110
120
  interface LineItem {
@@ -251,6 +261,7 @@ declare class Customer {
251
261
  declare class Helpers {
252
262
  proxy?: string;
253
263
  constructor(proxy?: string);
264
+ formatCurrency(currency: string): string;
254
265
  formatPrice(priceInCents: number, currency: string, exchangeRate?: number | null): string;
255
266
  getExchangeRate(baseCurrency: string, targetCurrency: string): Promise<number>;
256
267
  }
@@ -260,6 +271,7 @@ declare class Products {
260
271
  constructor(apiKey: string, proxy?: string);
261
272
  list(): Promise<ProductWithoutVariants[]>;
262
273
  retrieve(productId: string): Promise<Product | null>;
274
+ listCollections(): Promise<Collection[]>;
263
275
  }
264
276
 
265
277
  declare function createBetterStore(config: {
@@ -277,4 +289,4 @@ declare function createStoreHelpers(config?: {
277
289
  proxy?: string;
278
290
  }): Helpers;
279
291
 
280
- export { type Address, type CheckoutCreateParams, type CheckoutSession, type CheckoutUpdateParams, type Currency, type Customer$1 as Customer, type CustomerCreateParams, type CustomerUpdateParams, type LineItem, type LineItemCreate, type Product, type ProductOption, ProductStatus, type ProductVariant, type ProductWithoutVariants, type ShippingRate, type VariantOption, createStoreClient, createStoreHelpers, createBetterStore as default };
292
+ export { type Address, type CheckoutCreateParams, type CheckoutSession, type CheckoutUpdateParams, type Collection, type Currency, type Customer$1 as Customer, type CustomerCreateParams, type CustomerUpdateParams, type LineItem, type LineItemCreate, type Product, type ProductOption, ProductStatus, type ProductVariant, type ProductWithoutVariants, type ShippingRate, type VariantOption, createStoreClient, createStoreHelpers, createBetterStore as default };
package/dist/index.d.ts CHANGED
@@ -86,12 +86,22 @@ interface Product {
86
86
  seoPageTitle?: string;
87
87
  seoDescription?: string;
88
88
  seoHandle?: string;
89
+ vendor?: string;
89
90
  status: ProductStatus;
90
91
  options: ProductOption[];
91
92
  productVariants: ProductVariant[];
92
93
  }
93
94
  interface ProductWithoutVariants extends Omit<Product, "productVariants"> {
94
95
  }
96
+ interface Collection {
97
+ id: string;
98
+ title: string;
99
+ description?: string;
100
+ images: string[];
101
+ seoPageTitle?: string;
102
+ seoDescription?: string;
103
+ seoHandle?: string;
104
+ }
95
105
 
96
106
  type ShippingRate = ZasilkovnaRate;
97
107
  interface BaseRate {
@@ -104,7 +114,7 @@ interface ZasilkovnaRate extends BaseRate {
104
114
  clientSecret: string;
105
115
  }
106
116
 
107
- type ProductData = Pick<Product, "title" | "description" | "images" | "category" | "tags" | "sku" | "barcode" | "isPhysical" | "weightInGrams" | "heightInCm" | "widthInCm" | "lengthInCm" | "priceInCents"> & {
117
+ type ProductData = Pick<Product, "title" | "description" | "images" | "category" | "tags" | "sku" | "barcode" | "vendor" | "isPhysical" | "weightInGrams" | "heightInCm" | "widthInCm" | "lengthInCm" | "priceInCents"> & {
108
118
  selectedVariant: Pick<ProductVariant, "title" | "sku" | "barcode" | "images" | "isPhysical" | "weightInGrams" | "heightInCm" | "widthInCm" | "lengthInCm" | "priceInCents" | "variantOptions">;
109
119
  };
110
120
  interface LineItem {
@@ -251,6 +261,7 @@ declare class Customer {
251
261
  declare class Helpers {
252
262
  proxy?: string;
253
263
  constructor(proxy?: string);
264
+ formatCurrency(currency: string): string;
254
265
  formatPrice(priceInCents: number, currency: string, exchangeRate?: number | null): string;
255
266
  getExchangeRate(baseCurrency: string, targetCurrency: string): Promise<number>;
256
267
  }
@@ -260,6 +271,7 @@ declare class Products {
260
271
  constructor(apiKey: string, proxy?: string);
261
272
  list(): Promise<ProductWithoutVariants[]>;
262
273
  retrieve(productId: string): Promise<Product | null>;
274
+ listCollections(): Promise<Collection[]>;
263
275
  }
264
276
 
265
277
  declare function createBetterStore(config: {
@@ -277,4 +289,4 @@ declare function createStoreHelpers(config?: {
277
289
  proxy?: string;
278
290
  }): Helpers;
279
291
 
280
- export { type Address, type CheckoutCreateParams, type CheckoutSession, type CheckoutUpdateParams, type Currency, type Customer$1 as Customer, type CustomerCreateParams, type CustomerUpdateParams, type LineItem, type LineItemCreate, type Product, type ProductOption, ProductStatus, type ProductVariant, type ProductWithoutVariants, type ShippingRate, type VariantOption, createStoreClient, createStoreHelpers, createBetterStore as default };
292
+ export { type Address, type CheckoutCreateParams, type CheckoutSession, type CheckoutUpdateParams, type Collection, type Currency, type Customer$1 as Customer, type CustomerCreateParams, type CustomerUpdateParams, type LineItem, type LineItemCreate, type Product, type ProductOption, ProductStatus, type ProductVariant, type ProductWithoutVariants, type ShippingRate, type VariantOption, createStoreClient, createStoreHelpers, createBetterStore as default };
package/dist/index.js CHANGED
@@ -336,78 +336,88 @@ var Customer = class {
336
336
  var customer_default = Customer;
337
337
 
338
338
  // src/helpers/index.ts
339
+ var currencyLocales = {
340
+ CZK: "cs-CZ",
341
+ // Czech Koruna
342
+ USD: "en-US",
343
+ // US Dollar
344
+ EUR: "de-DE",
345
+ // Euro (Germany locale)
346
+ GBP: "en-GB",
347
+ // British Pound
348
+ JPY: "ja-JP",
349
+ // Japanese Yen
350
+ AUD: "en-AU",
351
+ // Australian Dollar
352
+ CAD: "en-CA",
353
+ // Canadian Dollar
354
+ NZD: "en-NZ",
355
+ // New Zealand Dollar
356
+ SEK: "sv-SE",
357
+ // Swedish Krona
358
+ NOK: "nb-NO",
359
+ // Norwegian Krone
360
+ DKK: "da-DK",
361
+ // Danish Krone
362
+ CHF: "de-CH",
363
+ // Swiss Franc (German Switzerland)
364
+ HUF: "hu-HU",
365
+ // Hungarian Forint
366
+ PLN: "pl-PL",
367
+ // Polish Zloty
368
+ BGN: "bg-BG",
369
+ // Bulgarian Lev
370
+ RON: "ro-RO",
371
+ // Romanian Leu
372
+ RUB: "ru-RU",
373
+ // Russian Ruble
374
+ CNY: "zh-CN",
375
+ // Chinese Yuan
376
+ INR: "en-IN",
377
+ // Indian Rupee
378
+ BRL: "pt-BR",
379
+ // Brazilian Real
380
+ MXN: "es-MX",
381
+ // Mexican Peso
382
+ ZAR: "en-ZA",
383
+ // South African Rand
384
+ KRW: "ko-KR",
385
+ // South Korean Won
386
+ MYR: "ms-MY",
387
+ // Malaysian Ringgit
388
+ SGD: "en-SG",
389
+ // Singapore Dollar
390
+ TWD: "zh-TW",
391
+ // Taiwanese Dollar
392
+ THB: "th-TH",
393
+ // Thai Baht
394
+ IDR: "id-ID",
395
+ // Indonesian Rupiah
396
+ AED: "ar-AE",
397
+ // UAE Dirham
398
+ SAR: "ar-SA",
399
+ // Saudi Riyal
400
+ TRY: "tr-TR"
401
+ // Turkish Lira
402
+ };
339
403
  var Helpers = class {
340
404
  constructor(proxy) {
341
405
  this.proxy = proxy;
342
406
  }
407
+ formatCurrency(currency) {
408
+ var _a;
409
+ const locale = (_a = currencyLocales[currency.toUpperCase()]) != null ? _a : void 0;
410
+ const formattedCurrency = new Intl.NumberFormat(locale, {
411
+ style: "currency",
412
+ currency,
413
+ currencyDisplay: "symbol"
414
+ });
415
+ return formattedCurrency.format(0).replace(/[\d.,\s]/g, "").trim();
416
+ }
343
417
  formatPrice(priceInCents, currency, exchangeRate) {
344
418
  var _a;
345
419
  const amount = priceInCents / 100 * (exchangeRate != null ? exchangeRate : 1);
346
420
  const isWhole = amount % 1 === 0;
347
- const currencyLocales = {
348
- CZK: "cs-CZ",
349
- // Czech Koruna
350
- USD: "en-US",
351
- // US Dollar
352
- EUR: "de-DE",
353
- // Euro (Germany locale)
354
- GBP: "en-GB",
355
- // British Pound
356
- JPY: "ja-JP",
357
- // Japanese Yen
358
- AUD: "en-AU",
359
- // Australian Dollar
360
- CAD: "en-CA",
361
- // Canadian Dollar
362
- NZD: "en-NZ",
363
- // New Zealand Dollar
364
- SEK: "sv-SE",
365
- // Swedish Krona
366
- NOK: "nb-NO",
367
- // Norwegian Krone
368
- DKK: "da-DK",
369
- // Danish Krone
370
- CHF: "de-CH",
371
- // Swiss Franc (German Switzerland)
372
- HUF: "hu-HU",
373
- // Hungarian Forint
374
- PLN: "pl-PL",
375
- // Polish Zloty
376
- BGN: "bg-BG",
377
- // Bulgarian Lev
378
- RON: "ro-RO",
379
- // Romanian Leu
380
- RUB: "ru-RU",
381
- // Russian Ruble
382
- CNY: "zh-CN",
383
- // Chinese Yuan
384
- INR: "en-IN",
385
- // Indian Rupee
386
- BRL: "pt-BR",
387
- // Brazilian Real
388
- MXN: "es-MX",
389
- // Mexican Peso
390
- ZAR: "en-ZA",
391
- // South African Rand
392
- KRW: "ko-KR",
393
- // South Korean Won
394
- MYR: "ms-MY",
395
- // Malaysian Ringgit
396
- SGD: "en-SG",
397
- // Singapore Dollar
398
- TWD: "zh-TW",
399
- // Taiwanese Dollar
400
- THB: "th-TH",
401
- // Thai Baht
402
- IDR: "id-ID",
403
- // Indonesian Rupiah
404
- AED: "ar-AE",
405
- // UAE Dirham
406
- SAR: "ar-SA",
407
- // Saudi Riyal
408
- TRY: "tr-TR"
409
- // Turkish Lira
410
- };
411
421
  const locale = (_a = currencyLocales[currency.toUpperCase()]) != null ? _a : void 0;
412
422
  const formattedPrice = new Intl.NumberFormat(locale, {
413
423
  style: "currency",
@@ -453,6 +463,12 @@ var Products = class {
453
463
  return data;
454
464
  });
455
465
  }
466
+ listCollections() {
467
+ return __async(this, null, function* () {
468
+ const data = yield this.apiClient.get("/collections");
469
+ return data;
470
+ });
471
+ }
456
472
  };
457
473
  var products_default = Products;
458
474
 
package/dist/index.mjs CHANGED
@@ -300,78 +300,88 @@ var Customer = class {
300
300
  var customer_default = Customer;
301
301
 
302
302
  // src/helpers/index.ts
303
+ var currencyLocales = {
304
+ CZK: "cs-CZ",
305
+ // Czech Koruna
306
+ USD: "en-US",
307
+ // US Dollar
308
+ EUR: "de-DE",
309
+ // Euro (Germany locale)
310
+ GBP: "en-GB",
311
+ // British Pound
312
+ JPY: "ja-JP",
313
+ // Japanese Yen
314
+ AUD: "en-AU",
315
+ // Australian Dollar
316
+ CAD: "en-CA",
317
+ // Canadian Dollar
318
+ NZD: "en-NZ",
319
+ // New Zealand Dollar
320
+ SEK: "sv-SE",
321
+ // Swedish Krona
322
+ NOK: "nb-NO",
323
+ // Norwegian Krone
324
+ DKK: "da-DK",
325
+ // Danish Krone
326
+ CHF: "de-CH",
327
+ // Swiss Franc (German Switzerland)
328
+ HUF: "hu-HU",
329
+ // Hungarian Forint
330
+ PLN: "pl-PL",
331
+ // Polish Zloty
332
+ BGN: "bg-BG",
333
+ // Bulgarian Lev
334
+ RON: "ro-RO",
335
+ // Romanian Leu
336
+ RUB: "ru-RU",
337
+ // Russian Ruble
338
+ CNY: "zh-CN",
339
+ // Chinese Yuan
340
+ INR: "en-IN",
341
+ // Indian Rupee
342
+ BRL: "pt-BR",
343
+ // Brazilian Real
344
+ MXN: "es-MX",
345
+ // Mexican Peso
346
+ ZAR: "en-ZA",
347
+ // South African Rand
348
+ KRW: "ko-KR",
349
+ // South Korean Won
350
+ MYR: "ms-MY",
351
+ // Malaysian Ringgit
352
+ SGD: "en-SG",
353
+ // Singapore Dollar
354
+ TWD: "zh-TW",
355
+ // Taiwanese Dollar
356
+ THB: "th-TH",
357
+ // Thai Baht
358
+ IDR: "id-ID",
359
+ // Indonesian Rupiah
360
+ AED: "ar-AE",
361
+ // UAE Dirham
362
+ SAR: "ar-SA",
363
+ // Saudi Riyal
364
+ TRY: "tr-TR"
365
+ // Turkish Lira
366
+ };
303
367
  var Helpers = class {
304
368
  constructor(proxy) {
305
369
  this.proxy = proxy;
306
370
  }
371
+ formatCurrency(currency) {
372
+ var _a;
373
+ const locale = (_a = currencyLocales[currency.toUpperCase()]) != null ? _a : void 0;
374
+ const formattedCurrency = new Intl.NumberFormat(locale, {
375
+ style: "currency",
376
+ currency,
377
+ currencyDisplay: "symbol"
378
+ });
379
+ return formattedCurrency.format(0).replace(/[\d.,\s]/g, "").trim();
380
+ }
307
381
  formatPrice(priceInCents, currency, exchangeRate) {
308
382
  var _a;
309
383
  const amount = priceInCents / 100 * (exchangeRate != null ? exchangeRate : 1);
310
384
  const isWhole = amount % 1 === 0;
311
- const currencyLocales = {
312
- CZK: "cs-CZ",
313
- // Czech Koruna
314
- USD: "en-US",
315
- // US Dollar
316
- EUR: "de-DE",
317
- // Euro (Germany locale)
318
- GBP: "en-GB",
319
- // British Pound
320
- JPY: "ja-JP",
321
- // Japanese Yen
322
- AUD: "en-AU",
323
- // Australian Dollar
324
- CAD: "en-CA",
325
- // Canadian Dollar
326
- NZD: "en-NZ",
327
- // New Zealand Dollar
328
- SEK: "sv-SE",
329
- // Swedish Krona
330
- NOK: "nb-NO",
331
- // Norwegian Krone
332
- DKK: "da-DK",
333
- // Danish Krone
334
- CHF: "de-CH",
335
- // Swiss Franc (German Switzerland)
336
- HUF: "hu-HU",
337
- // Hungarian Forint
338
- PLN: "pl-PL",
339
- // Polish Zloty
340
- BGN: "bg-BG",
341
- // Bulgarian Lev
342
- RON: "ro-RO",
343
- // Romanian Leu
344
- RUB: "ru-RU",
345
- // Russian Ruble
346
- CNY: "zh-CN",
347
- // Chinese Yuan
348
- INR: "en-IN",
349
- // Indian Rupee
350
- BRL: "pt-BR",
351
- // Brazilian Real
352
- MXN: "es-MX",
353
- // Mexican Peso
354
- ZAR: "en-ZA",
355
- // South African Rand
356
- KRW: "ko-KR",
357
- // South Korean Won
358
- MYR: "ms-MY",
359
- // Malaysian Ringgit
360
- SGD: "en-SG",
361
- // Singapore Dollar
362
- TWD: "zh-TW",
363
- // Taiwanese Dollar
364
- THB: "th-TH",
365
- // Thai Baht
366
- IDR: "id-ID",
367
- // Indonesian Rupiah
368
- AED: "ar-AE",
369
- // UAE Dirham
370
- SAR: "ar-SA",
371
- // Saudi Riyal
372
- TRY: "tr-TR"
373
- // Turkish Lira
374
- };
375
385
  const locale = (_a = currencyLocales[currency.toUpperCase()]) != null ? _a : void 0;
376
386
  const formattedPrice = new Intl.NumberFormat(locale, {
377
387
  style: "currency",
@@ -417,6 +427,12 @@ var Products = class {
417
427
  return data;
418
428
  });
419
429
  }
430
+ listCollections() {
431
+ return __async(this, null, function* () {
432
+ const data = yield this.apiClient.get("/collections");
433
+ return data;
434
+ });
435
+ }
420
436
  };
421
437
  var products_default = Products;
422
438
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@betterstore/sdk",
3
- "version": "0.3.46",
3
+ "version": "0.3.48",
4
4
  "description": "E-commerce for Developers",
5
5
  "private": false,
6
6
  "publishConfig": {