@porulle/adapter-woocommerce 0.63.0 → 0.65.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@porulle/adapter-woocommerce",
3
- "version": "0.63.0",
3
+ "version": "0.65.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -10,7 +10,7 @@
10
10
  }
11
11
  },
12
12
  "dependencies": {
13
- "@porulle/core": "0.63.0"
13
+ "@porulle/core": "0.65.0"
14
14
  },
15
15
  "devDependencies": {
16
16
  "@types/node": "^24.5.2",
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { defineChannelConnector, Err, Ok } from "@porulle/core";
1
+ import { defineChannelConnector, Err, Ok, toMinorUnits } from "@porulle/core";
2
2
  import { createHmac, timingSafeEqual } from "node:crypto";
3
3
  import type {
4
4
  ChannelCatalogPage,
@@ -145,25 +145,6 @@ const wooVariationNativeFields = new Set([
145
145
  "menu_order",
146
146
  ]);
147
147
 
148
- const zeroDecimalCurrencies = new Set([
149
- "BIF",
150
- "CLP",
151
- "DJF",
152
- "GNF",
153
- "ISK",
154
- "JPY",
155
- "KMF",
156
- "KRW",
157
- "PYG",
158
- "RWF",
159
- "UGX",
160
- "VND",
161
- "VUV",
162
- "XAF",
163
- "XOF",
164
- "XPF",
165
- ]);
166
-
167
148
  function buildWooUrl(base: string, path: string, key: string, secret: string, page: number, cursor?: string): string {
168
149
  const url = new URL(path, base.replace(/\/$/, "/"));
169
150
  url.searchParams.set("consumer_key", key);
@@ -179,17 +160,9 @@ function normalizeCurrency(value: unknown): string | undefined {
179
160
  return value.trim().toUpperCase();
180
161
  }
181
162
 
182
- function parseMoney(value: string | null | undefined, currency: string): number | undefined {
183
- if (value == null || value.trim() === "") return undefined;
184
- const parsed = Number(value);
185
- if (!Number.isFinite(parsed)) return undefined;
186
- const exponent = zeroDecimalCurrencies.has(currency) ? 0 : 2;
187
- return Math.round(parsed * (10 ** exponent));
188
- }
189
-
190
163
  function pricesForVariation(variation: WooProductVariation, currency: string | undefined): ChannelCatalogPrice[] | undefined {
191
164
  if (!currency) return undefined;
192
- const amount = parseMoney(variation.price, currency);
165
+ const amount = toMinorUnits(variation.price, currency);
193
166
  return amount === undefined ? undefined : [{ currency, amount }];
194
167
  }
195
168