@fire-spark/core 0.12.2 → 0.12.3

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.ts CHANGED
@@ -462,6 +462,15 @@ type CreateOrderOptions = {
462
462
  customer?: OrderCustomerSource;
463
463
  fromOrderId?: string;
464
464
  isAnonymous?: boolean;
465
+ /**
466
+ * ISO 4217 code for a new cart's totals — pass the merchant's
467
+ * `preferences.currency.code`. Ignored when an OPEN order is reused or
468
+ * with `fromOrderId` (the source keeps its currency). The API stamps the
469
+ * merchant currency on every write, so the cart adopts it after the
470
+ * first sync either way; this keeps the local draft right before that.
471
+ * Default `"USD"`.
472
+ */
473
+ currency?: string;
465
474
  /** When false, skips the OPEN-order lookup and starts a local draft. */
466
475
  reuseOpen?: boolean;
467
476
  orderId?: string;
package/dist/index.js CHANGED
@@ -5447,6 +5447,11 @@ const optionalBrandId = (value) => {
5447
5447
  if (!trimmed) return void 0;
5448
5448
  return trimmed;
5449
5449
  };
5450
+ /** ISO 4217 code, upper-cased; anything else → undefined (USD default). */
5451
+ const optionalCurrency = (value) => {
5452
+ const code = value?.trim().toUpperCase() ?? "";
5453
+ return /^[A-Z]{3}$/.test(code) ? code : void 0;
5454
+ };
5450
5455
  const buildInsertFromOptions = (options) => {
5451
5456
  if (!options.scope) throw new Error("Order requires scope when fromOrderId is omitted");
5452
5457
  if (!options.customer) throw new Error("Order requires customer when fromOrderId is omitted");
@@ -5470,7 +5475,7 @@ const buildInsertFromOptions = (options) => {
5470
5475
  redeem: []
5471
5476
  };
5472
5477
  const b5 = {
5473
- totals: emptyTotals(),
5478
+ totals: emptyTotals(optionalCurrency(options.currency)),
5474
5479
  metadata: {},
5475
5480
  redemption_steps: []
5476
5481
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fire-spark/core",
3
- "version": "0.12.2",
3
+ "version": "0.12.3",
4
4
  "description": "Fire Spark headless SDK",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -20,8 +20,8 @@
20
20
  "big.js": "6.2.1",
21
21
  "dayjs": "1.11.9",
22
22
  "@types/big.js": "6.2.2",
23
- "@fire-spark/payments": "^0.12.2",
24
- "@fire-spark/types": "^0.12.2"
23
+ "@fire-spark/payments": "^0.12.3",
24
+ "@fire-spark/types": "^0.12.3"
25
25
  },
26
26
  "devDependencies": {
27
27
  "tsdown": "^0.22.14",