@porulle/adapter-woocommerce 0.64.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/dist/index.js +2 -29
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/src/index.ts +2 -29
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@porulle/adapter-woocommerce",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.65.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -10,15 +10,15 @@
|
|
|
10
10
|
}
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@porulle/core": "0.
|
|
13
|
+
"@porulle/core": "0.65.0"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"@types/node": "^24.5.2",
|
|
17
17
|
"eslint": "^9.39.1",
|
|
18
18
|
"typescript": "5.9.2",
|
|
19
19
|
"vitest": "^3.2.4",
|
|
20
|
-
"@porulle/
|
|
21
|
-
"@porulle/
|
|
20
|
+
"@porulle/eslint-config": "0.1.0",
|
|
21
|
+
"@porulle/typescript-config": "0.1.0"
|
|
22
22
|
},
|
|
23
23
|
"publishConfig": {
|
|
24
24
|
"access": "public"
|
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 =
|
|
165
|
+
const amount = toMinorUnits(variation.price, currency);
|
|
193
166
|
return amount === undefined ? undefined : [{ currency, amount }];
|
|
194
167
|
}
|
|
195
168
|
|