@final-commerce/common 2.8.1-online.3 → 2.8.1-online.5
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/bin/gate-done.mjs +11 -24
- package/dist/index.d.mts +60 -9
- package/dist/index.d.ts +60 -9
- package/dist/index.js +151 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +146 -15
- package/dist/index.mjs.map +1 -1
- package/dist/pos-types/index.d.mts +7 -12
- package/dist/pos-types/index.d.ts +7 -12
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -532,13 +532,6 @@ var ShippingZoneError = /* @__PURE__ */ ((ShippingZoneError2) => {
|
|
|
532
532
|
})(ShippingZoneError || {});
|
|
533
533
|
|
|
534
534
|
// enums/tax.enum.ts
|
|
535
|
-
var TaxProductType = /* @__PURE__ */ ((TaxProductType2) => {
|
|
536
|
-
TaxProductType2["STANDARD"] = "standard";
|
|
537
|
-
TaxProductType2["BASIC_FOOD"] = "basic_food";
|
|
538
|
-
TaxProductType2["CHILDRENS_CLOTHING"] = "childrens_clothing";
|
|
539
|
-
TaxProductType2["EXEMPT"] = "exempt";
|
|
540
|
-
return TaxProductType2;
|
|
541
|
-
})(TaxProductType || {});
|
|
542
535
|
var TaxRegistrationKind = /* @__PURE__ */ ((TaxRegistrationKind2) => {
|
|
543
536
|
TaxRegistrationKind2["GST_HST"] = "GST_HST";
|
|
544
537
|
TaxRegistrationKind2["PST"] = "PST";
|
|
@@ -558,6 +551,7 @@ var OutOfProvinceTaxes = /* @__PURE__ */ ((OutOfProvinceTaxes2) => {
|
|
|
558
551
|
var TaxWarningCode = /* @__PURE__ */ ((TaxWarningCode2) => {
|
|
559
552
|
TaxWarningCode2["NOT_REGISTERED"] = "NOT_REGISTERED";
|
|
560
553
|
TaxWarningCode2["NO_RULES_FOR_PLACE"] = "NO_RULES_FOR_PLACE";
|
|
554
|
+
TaxWarningCode2["NO_TABLE"] = "NO_TABLE";
|
|
561
555
|
return TaxWarningCode2;
|
|
562
556
|
})(TaxWarningCode || {});
|
|
563
557
|
|
|
@@ -3996,12 +3990,146 @@ function tiersAreValid(option) {
|
|
|
3996
3990
|
return tiers.every((tier) => Number.isInteger(tier.from) && tier.from > 0 && isAmount(tier.price)) && new Set(froms).size === froms.length;
|
|
3997
3991
|
}
|
|
3998
3992
|
|
|
3999
|
-
// tax/
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
|
|
3993
|
+
// tax/sha1.ts
|
|
3994
|
+
function utf8Bytes(text) {
|
|
3995
|
+
const bytes = [];
|
|
3996
|
+
for (const char of text) {
|
|
3997
|
+
const cp = char.codePointAt(0);
|
|
3998
|
+
if (cp < 128) bytes.push(cp);
|
|
3999
|
+
else if (cp < 2048) bytes.push(192 | cp >> 6, 128 | cp & 63);
|
|
4000
|
+
else if (cp < 65536) bytes.push(224 | cp >> 12, 128 | cp >> 6 & 63, 128 | cp & 63);
|
|
4001
|
+
else bytes.push(240 | cp >> 18, 128 | cp >> 12 & 63, 128 | cp >> 6 & 63, 128 | cp & 63);
|
|
4002
|
+
}
|
|
4003
|
+
return bytes;
|
|
4004
|
+
}
|
|
4005
|
+
var rotl = (x, n) => x << n | x >>> 32 - n;
|
|
4006
|
+
function sha1Hex(text) {
|
|
4007
|
+
const bytes = utf8Bytes(text);
|
|
4008
|
+
const bitLength = bytes.length * 8;
|
|
4009
|
+
bytes.push(128);
|
|
4010
|
+
while (bytes.length % 64 !== 56) bytes.push(0);
|
|
4011
|
+
const high = Math.floor(bitLength / 4294967296);
|
|
4012
|
+
for (const word of [high, bitLength >>> 0])
|
|
4013
|
+
bytes.push(word >>> 24 & 255, word >>> 16 & 255, word >>> 8 & 255, word & 255);
|
|
4014
|
+
const h = [1732584193, 4023233417, 2562383102, 271733878, 3285377520];
|
|
4015
|
+
const w = new Array(80);
|
|
4016
|
+
for (let offset = 0; offset < bytes.length; offset += 64) {
|
|
4017
|
+
for (let i = 0; i < 16; i++) {
|
|
4018
|
+
const j = offset + i * 4;
|
|
4019
|
+
w[i] = bytes[j] << 24 | bytes[j + 1] << 16 | bytes[j + 2] << 8 | bytes[j + 3];
|
|
4020
|
+
}
|
|
4021
|
+
for (let i = 16; i < 80; i++) w[i] = rotl(w[i - 3] ^ w[i - 8] ^ w[i - 14] ^ w[i - 16], 1);
|
|
4022
|
+
let [a, b, c, d, e] = h;
|
|
4023
|
+
for (let i = 0; i < 80; i++) {
|
|
4024
|
+
const [f, k] = i < 20 ? [b & c | ~b & d, 1518500249] : i < 40 ? [b ^ c ^ d, 1859775393] : i < 60 ? [b & c | b & d | c & d, 2400959708] : [b ^ c ^ d, 3395469782];
|
|
4025
|
+
const t = rotl(a, 5) + f + e + k + w[i] | 0;
|
|
4026
|
+
e = d;
|
|
4027
|
+
d = c;
|
|
4028
|
+
c = rotl(b, 30);
|
|
4029
|
+
b = a;
|
|
4030
|
+
a = t;
|
|
4031
|
+
}
|
|
4032
|
+
h[0] = h[0] + a | 0;
|
|
4033
|
+
h[1] = h[1] + b | 0;
|
|
4034
|
+
h[2] = h[2] + c | 0;
|
|
4035
|
+
h[3] = h[3] + d | 0;
|
|
4036
|
+
h[4] = h[4] + e | 0;
|
|
4037
|
+
}
|
|
4038
|
+
return h.map((x) => (x >>> 0).toString(16).padStart(8, "0")).join("");
|
|
4039
|
+
}
|
|
4040
|
+
|
|
4041
|
+
// tax/table.ts
|
|
4042
|
+
var STANDARD_TAX_TYPE = "standard";
|
|
4043
|
+
var TYPE_FIELDS = ["key", "name", "description", "sortOrder", "active"];
|
|
4044
|
+
var RATE_FIELDS = [
|
|
4045
|
+
"code",
|
|
4046
|
+
"name",
|
|
4047
|
+
"kind",
|
|
4048
|
+
"places",
|
|
4049
|
+
"rate",
|
|
4050
|
+
"from",
|
|
4051
|
+
"to",
|
|
4052
|
+
"order",
|
|
4053
|
+
"compound",
|
|
4054
|
+
"registrationPlace",
|
|
4055
|
+
"harmonized",
|
|
4056
|
+
"parts",
|
|
4057
|
+
"sourceUrl",
|
|
4058
|
+
"status"
|
|
4059
|
+
];
|
|
4060
|
+
var RULE_FIELDS = ["taxType", "codes", "rate", "from", "to", "sourceUrl", "status", "note"];
|
|
4061
|
+
function canonical(row, fields) {
|
|
4062
|
+
return JSON.stringify(fields.map((field) => row[field] ?? null));
|
|
4063
|
+
}
|
|
4064
|
+
var sortedCanonical = (rows, fields) => rows.map((row) => canonical(row, fields)).sort();
|
|
4065
|
+
function automaticTaxTableVersion(table) {
|
|
4066
|
+
return sha1Hex(
|
|
4067
|
+
JSON.stringify([
|
|
4068
|
+
sortedCanonical(table.types, TYPE_FIELDS),
|
|
4069
|
+
sortedCanonical(table.rates, RATE_FIELDS),
|
|
4070
|
+
sortedCanonical(table.rules, RULE_FIELDS)
|
|
4071
|
+
])
|
|
4072
|
+
);
|
|
4073
|
+
}
|
|
4074
|
+
var toTypeRow = ({ key, name, description, sortOrder, active }) => ({
|
|
4075
|
+
key,
|
|
4076
|
+
name,
|
|
4077
|
+
description,
|
|
4078
|
+
sortOrder,
|
|
4079
|
+
active
|
|
4080
|
+
});
|
|
4081
|
+
var toRateRow = (rate) => ({
|
|
4082
|
+
code: rate.code,
|
|
4083
|
+
name: rate.name,
|
|
4084
|
+
kind: rate.kind,
|
|
4085
|
+
places: rate.places,
|
|
4086
|
+
rate: rate.rate,
|
|
4087
|
+
from: rate.from,
|
|
4088
|
+
to: rate.to,
|
|
4089
|
+
order: rate.order,
|
|
4090
|
+
compound: rate.compound,
|
|
4091
|
+
registrationPlace: rate.registrationPlace,
|
|
4092
|
+
harmonized: rate.harmonized,
|
|
4093
|
+
parts: rate.parts?.map(({ code, name, rate: partRate, level }) => ({ code, name, rate: partRate, level })),
|
|
4094
|
+
sourceUrl: rate.sourceUrl,
|
|
4095
|
+
status: rate.status
|
|
4096
|
+
});
|
|
4097
|
+
var toRuleRow = ({
|
|
4098
|
+
taxType,
|
|
4099
|
+
codes: codes2,
|
|
4100
|
+
rate,
|
|
4101
|
+
from,
|
|
4102
|
+
to,
|
|
4103
|
+
sourceUrl,
|
|
4104
|
+
status,
|
|
4105
|
+
note
|
|
4106
|
+
}) => ({
|
|
4107
|
+
taxType,
|
|
4108
|
+
codes: codes2,
|
|
4109
|
+
rate,
|
|
4110
|
+
from,
|
|
4111
|
+
to,
|
|
4112
|
+
sourceUrl,
|
|
4113
|
+
status,
|
|
4114
|
+
note
|
|
4115
|
+
});
|
|
4116
|
+
function buildAutomaticTaxTable(rows) {
|
|
4117
|
+
const table = {
|
|
4118
|
+
types: [...rows.types].sort((a, b) => a.sortOrder - b.sortOrder).map(toTypeRow),
|
|
4119
|
+
rates: rows.rates.map(toRateRow),
|
|
4120
|
+
rules: rows.rules.map(toRuleRow)
|
|
4121
|
+
};
|
|
4122
|
+
return { version: automaticTaxTableVersion(table), ...table };
|
|
4123
|
+
}
|
|
4124
|
+
function registrationPlacesByKind(rates) {
|
|
4125
|
+
const places = /* @__PURE__ */ new Map();
|
|
4126
|
+
for (const rate of rates) {
|
|
4127
|
+
const list = places.get(rate.kind) ?? [];
|
|
4128
|
+
if (!list.includes(rate.registrationPlace)) list.push(rate.registrationPlace);
|
|
4129
|
+
places.set(rate.kind, list);
|
|
4130
|
+
}
|
|
4131
|
+
return places;
|
|
4132
|
+
}
|
|
4005
4133
|
|
|
4006
4134
|
// constants/adyen.constants.ts
|
|
4007
4135
|
var ADYEN_ROLLOUT_COUNTRY_CODES = /* @__PURE__ */ new Set(["CA"]);
|
|
@@ -4180,6 +4308,7 @@ export {
|
|
|
4180
4308
|
ResidualPaymentMethod,
|
|
4181
4309
|
ResidualStatus,
|
|
4182
4310
|
ResourceAvailabilityState,
|
|
4311
|
+
STANDARD_TAX_TYPE,
|
|
4183
4312
|
STATE_SCHEMA,
|
|
4184
4313
|
STRIPE_SUPPORTED_COUNTRIES,
|
|
4185
4314
|
SYSTEM_FAMILIES,
|
|
@@ -4195,8 +4324,6 @@ export {
|
|
|
4195
4324
|
StationStatus,
|
|
4196
4325
|
StripeCurrencyCode,
|
|
4197
4326
|
StripeStatus,
|
|
4198
|
-
TAX_REGISTRATION_PLACES,
|
|
4199
|
-
TaxProductType,
|
|
4200
4327
|
TaxRegistrationKind,
|
|
4201
4328
|
TaxSource,
|
|
4202
4329
|
TaxWarningCode,
|
|
@@ -4213,11 +4340,13 @@ export {
|
|
|
4213
4340
|
amountToString,
|
|
4214
4341
|
ancestorChain,
|
|
4215
4342
|
assertUnitSane,
|
|
4343
|
+
automaticTaxTableVersion,
|
|
4216
4344
|
availableIn,
|
|
4217
4345
|
baseFor,
|
|
4218
4346
|
baseFulfillmentDefinitions,
|
|
4219
4347
|
baseOf,
|
|
4220
4348
|
basePaymentDefinitions,
|
|
4349
|
+
buildAutomaticTaxTable,
|
|
4221
4350
|
buildAvailability,
|
|
4222
4351
|
buildGrid,
|
|
4223
4352
|
buildOrderContext,
|
|
@@ -4311,6 +4440,7 @@ export {
|
|
|
4311
4440
|
presentAt,
|
|
4312
4441
|
priceForTotal,
|
|
4313
4442
|
provincesForPostCode,
|
|
4443
|
+
registrationPlacesByKind,
|
|
4314
4444
|
removeFragment,
|
|
4315
4445
|
resolveFamily,
|
|
4316
4446
|
resolveModifiersForProduct,
|
|
@@ -4320,6 +4450,7 @@ export {
|
|
|
4320
4450
|
roundToPrecision,
|
|
4321
4451
|
sameFamily,
|
|
4322
4452
|
setOrderState,
|
|
4453
|
+
sha1Hex,
|
|
4323
4454
|
shopDayKey,
|
|
4324
4455
|
shopDayRange,
|
|
4325
4456
|
signReportForDisplay,
|