@betterstore/sdk 0.3.21 → 0.3.23

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.23
4
+
5
+ ### Patch Changes
6
+
7
+ - currency formatting
8
+
9
+ ## 0.3.22
10
+
11
+ ### Patch Changes
12
+
13
+ - formatting issue
14
+
3
15
  ## 0.3.21
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -229,7 +229,7 @@ declare class Products {
229
229
  retrieve(productId: string): Promise<Product>;
230
230
  }
231
231
 
232
- declare function betterStore(config: {
232
+ declare function createBetterStore(config: {
233
233
  apiKey: string;
234
234
  proxy?: string;
235
235
  }): {
@@ -244,4 +244,4 @@ declare function createStoreHelpers(config?: {
244
244
  proxy?: string;
245
245
  }): Helpers;
246
246
 
247
- export { type Address, type CheckoutCreateParams, type CheckoutSession, type CheckoutUpdateParams, type Currency, type Customer$1 as Customer, type CustomerCreateParams, type CustomerUpdateParams, type LineItem, type Product, type ProductOption, ProductStatus, type ProductVariant, type VariantOption, createStoreClient, createStoreHelpers, betterStore as default };
247
+ export { type Address, type CheckoutCreateParams, type CheckoutSession, type CheckoutUpdateParams, type Currency, type Customer$1 as Customer, type CustomerCreateParams, type CustomerUpdateParams, type LineItem, type Product, type ProductOption, ProductStatus, type ProductVariant, type VariantOption, createStoreClient, createStoreHelpers, createBetterStore as default };
package/dist/index.d.ts CHANGED
@@ -229,7 +229,7 @@ declare class Products {
229
229
  retrieve(productId: string): Promise<Product>;
230
230
  }
231
231
 
232
- declare function betterStore(config: {
232
+ declare function createBetterStore(config: {
233
233
  apiKey: string;
234
234
  proxy?: string;
235
235
  }): {
@@ -244,4 +244,4 @@ declare function createStoreHelpers(config?: {
244
244
  proxy?: string;
245
245
  }): Helpers;
246
246
 
247
- export { type Address, type CheckoutCreateParams, type CheckoutSession, type CheckoutUpdateParams, type Currency, type Customer$1 as Customer, type CustomerCreateParams, type CustomerUpdateParams, type LineItem, type Product, type ProductOption, ProductStatus, type ProductVariant, type VariantOption, createStoreClient, createStoreHelpers, betterStore as default };
247
+ export { type Address, type CheckoutCreateParams, type CheckoutSession, type CheckoutUpdateParams, type Currency, type Customer$1 as Customer, type CustomerCreateParams, type CustomerUpdateParams, type LineItem, type Product, type ProductOption, ProductStatus, type ProductVariant, type VariantOption, createStoreClient, createStoreHelpers, createBetterStore as default };
package/dist/index.js CHANGED
@@ -54,7 +54,7 @@ __export(index_exports, {
54
54
  ShippingRate: () => import_shippo.Rate,
55
55
  createStoreClient: () => createStoreClient,
56
56
  createStoreHelpers: () => createStoreHelpers,
57
- default: () => betterStore
57
+ default: () => createBetterStore
58
58
  });
59
59
  module.exports = __toCommonJS(index_exports);
60
60
 
@@ -318,11 +318,78 @@ var Helpers = class {
318
318
  this.proxy = proxy;
319
319
  }
320
320
  formatPrice(priceInCents, currency, exchangeRate) {
321
+ var _a;
321
322
  const amount = priceInCents / 100 * (exchangeRate != null ? exchangeRate : 1);
322
323
  const isWhole = amount % 1 === 0;
323
- const formattedPrice = new Intl.NumberFormat(void 0, {
324
+ const currencyLocales = {
325
+ CZK: "cs-CZ",
326
+ // Czech Koruna
327
+ USD: "en-US",
328
+ // US Dollar
329
+ EUR: "de-DE",
330
+ // Euro (Germany locale)
331
+ GBP: "en-GB",
332
+ // British Pound
333
+ JPY: "ja-JP",
334
+ // Japanese Yen
335
+ AUD: "en-AU",
336
+ // Australian Dollar
337
+ CAD: "en-CA",
338
+ // Canadian Dollar
339
+ NZD: "en-NZ",
340
+ // New Zealand Dollar
341
+ SEK: "sv-SE",
342
+ // Swedish Krona
343
+ NOK: "nb-NO",
344
+ // Norwegian Krone
345
+ DKK: "da-DK",
346
+ // Danish Krone
347
+ CHF: "de-CH",
348
+ // Swiss Franc (German Switzerland)
349
+ HUF: "hu-HU",
350
+ // Hungarian Forint
351
+ PLN: "pl-PL",
352
+ // Polish Zloty
353
+ BGN: "bg-BG",
354
+ // Bulgarian Lev
355
+ RON: "ro-RO",
356
+ // Romanian Leu
357
+ RUB: "ru-RU",
358
+ // Russian Ruble
359
+ CNY: "zh-CN",
360
+ // Chinese Yuan
361
+ INR: "en-IN",
362
+ // Indian Rupee
363
+ BRL: "pt-BR",
364
+ // Brazilian Real
365
+ MXN: "es-MX",
366
+ // Mexican Peso
367
+ ZAR: "en-ZA",
368
+ // South African Rand
369
+ KRW: "ko-KR",
370
+ // South Korean Won
371
+ MYR: "ms-MY",
372
+ // Malaysian Ringgit
373
+ SGD: "en-SG",
374
+ // Singapore Dollar
375
+ TWD: "zh-TW",
376
+ // Taiwanese Dollar
377
+ THB: "th-TH",
378
+ // Thai Baht
379
+ IDR: "id-ID",
380
+ // Indonesian Rupiah
381
+ AED: "ar-AE",
382
+ // UAE Dirham
383
+ SAR: "ar-SA",
384
+ // Saudi Riyal
385
+ TRY: "tr-TR"
386
+ // Turkish Lira
387
+ };
388
+ const locale = (_a = currencyLocales[currency]) != null ? _a : void 0;
389
+ const formattedPrice = new Intl.NumberFormat(locale, {
324
390
  style: "currency",
325
391
  currency,
392
+ currencyDisplay: "symbol",
326
393
  minimumFractionDigits: isWhole ? 0 : 2,
327
394
  maximumFractionDigits: isWhole ? 0 : 2
328
395
  }).format(amount);
@@ -378,7 +445,7 @@ var ProductStatus = /* @__PURE__ */ ((ProductStatus2) => {
378
445
  })(ProductStatus || {});
379
446
 
380
447
  // src/index.ts
381
- function betterStore(config) {
448
+ function createBetterStore(config) {
382
449
  if (!config.apiKey) {
383
450
  throw new Error("API key is required.");
384
451
  }
package/dist/index.mjs CHANGED
@@ -279,11 +279,78 @@ var Helpers = class {
279
279
  this.proxy = proxy;
280
280
  }
281
281
  formatPrice(priceInCents, currency, exchangeRate) {
282
+ var _a;
282
283
  const amount = priceInCents / 100 * (exchangeRate != null ? exchangeRate : 1);
283
284
  const isWhole = amount % 1 === 0;
284
- const formattedPrice = new Intl.NumberFormat(void 0, {
285
+ const currencyLocales = {
286
+ CZK: "cs-CZ",
287
+ // Czech Koruna
288
+ USD: "en-US",
289
+ // US Dollar
290
+ EUR: "de-DE",
291
+ // Euro (Germany locale)
292
+ GBP: "en-GB",
293
+ // British Pound
294
+ JPY: "ja-JP",
295
+ // Japanese Yen
296
+ AUD: "en-AU",
297
+ // Australian Dollar
298
+ CAD: "en-CA",
299
+ // Canadian Dollar
300
+ NZD: "en-NZ",
301
+ // New Zealand Dollar
302
+ SEK: "sv-SE",
303
+ // Swedish Krona
304
+ NOK: "nb-NO",
305
+ // Norwegian Krone
306
+ DKK: "da-DK",
307
+ // Danish Krone
308
+ CHF: "de-CH",
309
+ // Swiss Franc (German Switzerland)
310
+ HUF: "hu-HU",
311
+ // Hungarian Forint
312
+ PLN: "pl-PL",
313
+ // Polish Zloty
314
+ BGN: "bg-BG",
315
+ // Bulgarian Lev
316
+ RON: "ro-RO",
317
+ // Romanian Leu
318
+ RUB: "ru-RU",
319
+ // Russian Ruble
320
+ CNY: "zh-CN",
321
+ // Chinese Yuan
322
+ INR: "en-IN",
323
+ // Indian Rupee
324
+ BRL: "pt-BR",
325
+ // Brazilian Real
326
+ MXN: "es-MX",
327
+ // Mexican Peso
328
+ ZAR: "en-ZA",
329
+ // South African Rand
330
+ KRW: "ko-KR",
331
+ // South Korean Won
332
+ MYR: "ms-MY",
333
+ // Malaysian Ringgit
334
+ SGD: "en-SG",
335
+ // Singapore Dollar
336
+ TWD: "zh-TW",
337
+ // Taiwanese Dollar
338
+ THB: "th-TH",
339
+ // Thai Baht
340
+ IDR: "id-ID",
341
+ // Indonesian Rupiah
342
+ AED: "ar-AE",
343
+ // UAE Dirham
344
+ SAR: "ar-SA",
345
+ // Saudi Riyal
346
+ TRY: "tr-TR"
347
+ // Turkish Lira
348
+ };
349
+ const locale = (_a = currencyLocales[currency]) != null ? _a : void 0;
350
+ const formattedPrice = new Intl.NumberFormat(locale, {
285
351
  style: "currency",
286
352
  currency,
353
+ currencyDisplay: "symbol",
287
354
  minimumFractionDigits: isWhole ? 0 : 2,
288
355
  maximumFractionDigits: isWhole ? 0 : 2
289
356
  }).format(amount);
@@ -339,7 +406,7 @@ var ProductStatus = /* @__PURE__ */ ((ProductStatus2) => {
339
406
  })(ProductStatus || {});
340
407
 
341
408
  // src/index.ts
342
- function betterStore(config) {
409
+ function createBetterStore(config) {
343
410
  if (!config.apiKey) {
344
411
  throw new Error("API key is required.");
345
412
  }
@@ -360,5 +427,5 @@ export {
360
427
  Rate as ShippingRate,
361
428
  createStoreClient,
362
429
  createStoreHelpers,
363
- betterStore as default
430
+ createBetterStore as default
364
431
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@betterstore/sdk",
3
- "version": "0.3.21",
3
+ "version": "0.3.23",
4
4
  "description": "E-commerce for Developers",
5
5
  "private": false,
6
6
  "publishConfig": {