@viu/emporix-sdk 2.26.0 → 2.28.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/CHANGELOG.md +19 -0
- package/dist/index.cjs +14 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +29 -1
- package/dist/index.d.ts +29 -1
- package/dist/index.js +13 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @viu/emporix-sdk
|
|
2
2
|
|
|
3
|
+
## 2.28.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#195](https://github.com/viuteam/emporix-sdk/pull/195) [`bda9663`](https://github.com/viuteam/emporix-sdk/commit/bda9663040b3d6c8c33743ced6a3df4b79c81ddb) Thanks [@amnael1](https://github.com/amnael1)! - Export `resolveZone` and `pickFee` alongside the shipping service, plus the
|
|
8
|
+
`ShippingFee` type they use.
|
|
9
|
+
|
|
10
|
+
Both are pure functions — no client, no request — lifted verbatim from the
|
|
11
|
+
storefront demo, where they had no test coverage. They now have ten tests,
|
|
12
|
+
including the `<=` boundary that decides whether a cart total exactly meeting a
|
|
13
|
+
free-shipping threshold gets free shipping.
|
|
14
|
+
- `resolveZone(zones, country)` — the zone whose `shipTo` covers the country,
|
|
15
|
+
else the default zone, else the first.
|
|
16
|
+
- `pickFee(fees, cartTotal)` — the highest `minOrderValue` at or below the
|
|
17
|
+
total, else the first fee.
|
|
18
|
+
|
|
19
|
+
The fee type is exported as `ShippingFee` rather than `Fee`, because the Fee
|
|
20
|
+
service already owns that name at the package root.
|
|
21
|
+
|
|
3
22
|
## 2.26.0
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -890,7 +890,7 @@ var HttpClient = class {
|
|
|
890
890
|
};
|
|
891
891
|
|
|
892
892
|
// package.json
|
|
893
|
-
var version = "2.
|
|
893
|
+
var version = "2.28.0";
|
|
894
894
|
|
|
895
895
|
// src/version.ts
|
|
896
896
|
var SDK_VERSION = version;
|
|
@@ -6673,6 +6673,17 @@ var CurrencyService = class {
|
|
|
6673
6673
|
|
|
6674
6674
|
// src/services/shipping.ts
|
|
6675
6675
|
var SERVICE25 = { kind: "service" };
|
|
6676
|
+
function resolveZone(zones, country) {
|
|
6677
|
+
if (!zones || zones.length === 0) return void 0;
|
|
6678
|
+
const c = country.trim().toUpperCase();
|
|
6679
|
+
const byCountry = c ? zones.find((z) => (z.shipTo ?? []).some((s) => s.country?.toUpperCase() === c)) : void 0;
|
|
6680
|
+
return byCountry ?? zones.find((z) => z.default) ?? zones[0];
|
|
6681
|
+
}
|
|
6682
|
+
function pickFee(fees, cartTotal) {
|
|
6683
|
+
if (!fees || fees.length === 0) return void 0;
|
|
6684
|
+
const eligible = fees.filter((f) => (f.minOrderValue?.amount ?? 0) <= cartTotal).sort((a, b) => (b.minOrderValue?.amount ?? 0) - (a.minOrderValue?.amount ?? 0));
|
|
6685
|
+
return eligible[0] ?? fees[0];
|
|
6686
|
+
}
|
|
6676
6687
|
var ShippingService = class {
|
|
6677
6688
|
constructor(ctx) {
|
|
6678
6689
|
this.ctx = ctx;
|
|
@@ -8256,10 +8267,12 @@ exports.createEmporixClient = createEmporixClient;
|
|
|
8256
8267
|
exports.createNoopLogger = createNoopLogger;
|
|
8257
8268
|
exports.errorFromResponse = errorFromResponse;
|
|
8258
8269
|
exports.iterateAll = iterateAll;
|
|
8270
|
+
exports.pickFee = pickFee;
|
|
8259
8271
|
exports.productIdFromYrn = productIdFromYrn;
|
|
8260
8272
|
exports.redact = redact;
|
|
8261
8273
|
exports.resolveQuery = resolveQuery;
|
|
8262
8274
|
exports.resolveToken = resolveToken;
|
|
8275
|
+
exports.resolveZone = resolveZone;
|
|
8263
8276
|
exports.validateConfig = validateConfig;
|
|
8264
8277
|
//# sourceMappingURL=index.cjs.map
|
|
8265
8278
|
//# sourceMappingURL=index.cjs.map
|