@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/dist/index.js
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
|
const PORULLE_META_PREFIX = "porulle_";
|
|
4
4
|
const WOO_BATCH_LIMIT = 100;
|
|
@@ -66,24 +66,6 @@ const wooVariationNativeFields = new Set([
|
|
|
66
66
|
"image",
|
|
67
67
|
"menu_order",
|
|
68
68
|
]);
|
|
69
|
-
const zeroDecimalCurrencies = new Set([
|
|
70
|
-
"BIF",
|
|
71
|
-
"CLP",
|
|
72
|
-
"DJF",
|
|
73
|
-
"GNF",
|
|
74
|
-
"ISK",
|
|
75
|
-
"JPY",
|
|
76
|
-
"KMF",
|
|
77
|
-
"KRW",
|
|
78
|
-
"PYG",
|
|
79
|
-
"RWF",
|
|
80
|
-
"UGX",
|
|
81
|
-
"VND",
|
|
82
|
-
"VUV",
|
|
83
|
-
"XAF",
|
|
84
|
-
"XOF",
|
|
85
|
-
"XPF",
|
|
86
|
-
]);
|
|
87
69
|
function buildWooUrl(base, path, key, secret, page, cursor) {
|
|
88
70
|
const url = new URL(path, base.replace(/\/$/, "/"));
|
|
89
71
|
url.searchParams.set("consumer_key", key);
|
|
@@ -99,19 +81,10 @@ function normalizeCurrency(value) {
|
|
|
99
81
|
return undefined;
|
|
100
82
|
return value.trim().toUpperCase();
|
|
101
83
|
}
|
|
102
|
-
function parseMoney(value, currency) {
|
|
103
|
-
if (value == null || value.trim() === "")
|
|
104
|
-
return undefined;
|
|
105
|
-
const parsed = Number(value);
|
|
106
|
-
if (!Number.isFinite(parsed))
|
|
107
|
-
return undefined;
|
|
108
|
-
const exponent = zeroDecimalCurrencies.has(currency) ? 0 : 2;
|
|
109
|
-
return Math.round(parsed * (10 ** exponent));
|
|
110
|
-
}
|
|
111
84
|
function pricesForVariation(variation, currency) {
|
|
112
85
|
if (!currency)
|
|
113
86
|
return undefined;
|
|
114
|
-
const amount =
|
|
87
|
+
const amount = toMinorUnits(variation.price, currency);
|
|
115
88
|
return amount === undefined ? undefined : [{ currency, amount }];
|
|
116
89
|
}
|
|
117
90
|
function catalogStatus(value) {
|