@final-commerce/common 2.11.1-online.2 → 2.11.1
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/README.md +20 -0
- package/bin/gate-done.mjs +92 -44
- package/bin/lib/budget.mjs +71 -0
- package/dist/index.d.mts +1 -215
- package/dist/index.d.ts +1 -215
- package/dist/index.js +0 -233
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +0 -219
- package/dist/index.mjs.map +1 -1
- package/dist/pos-types/index.d.mts +12 -37
- package/dist/pos-types/index.d.ts +12 -37
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -541,30 +541,6 @@ var ShippingZoneError = /* @__PURE__ */ ((ShippingZoneError2) => {
|
|
|
541
541
|
return ShippingZoneError2;
|
|
542
542
|
})(ShippingZoneError || {});
|
|
543
543
|
|
|
544
|
-
// enums/tax.enum.ts
|
|
545
|
-
var TaxRegistrationKind = /* @__PURE__ */ ((TaxRegistrationKind2) => {
|
|
546
|
-
TaxRegistrationKind2["GST_HST"] = "GST_HST";
|
|
547
|
-
TaxRegistrationKind2["PST"] = "PST";
|
|
548
|
-
TaxRegistrationKind2["QST"] = "QST";
|
|
549
|
-
return TaxRegistrationKind2;
|
|
550
|
-
})(TaxRegistrationKind || {});
|
|
551
|
-
var TaxSource = /* @__PURE__ */ ((TaxSource2) => {
|
|
552
|
-
TaxSource2["MERCHANT"] = "merchant";
|
|
553
|
-
TaxSource2["AUTOMATIC"] = "automatic";
|
|
554
|
-
return TaxSource2;
|
|
555
|
-
})(TaxSource || {});
|
|
556
|
-
var OutOfProvinceTaxes = /* @__PURE__ */ ((OutOfProvinceTaxes2) => {
|
|
557
|
-
OutOfProvinceTaxes2["AUTOMATIC"] = "automatic";
|
|
558
|
-
OutOfProvinceTaxes2["HOME"] = "home";
|
|
559
|
-
return OutOfProvinceTaxes2;
|
|
560
|
-
})(OutOfProvinceTaxes || {});
|
|
561
|
-
var TaxWarningCode = /* @__PURE__ */ ((TaxWarningCode2) => {
|
|
562
|
-
TaxWarningCode2["NOT_REGISTERED"] = "NOT_REGISTERED";
|
|
563
|
-
TaxWarningCode2["NO_RULES_FOR_PLACE"] = "NO_RULES_FOR_PLACE";
|
|
564
|
-
TaxWarningCode2["NO_TABLE"] = "NO_TABLE";
|
|
565
|
-
return TaxWarningCode2;
|
|
566
|
-
})(TaxWarningCode || {});
|
|
567
|
-
|
|
568
544
|
// enums/sales-line.enum.ts
|
|
569
545
|
var SalesLineAction = /* @__PURE__ */ ((SalesLineAction2) => {
|
|
570
546
|
SalesLineAction2["SALE"] = "sale";
|
|
@@ -4069,187 +4045,6 @@ function tiersAreValid(option) {
|
|
|
4069
4045
|
return tiers.every((tier) => Number.isInteger(tier.from) && tier.from > 0 && isAmount(tier.price)) && new Set(froms).size === froms.length;
|
|
4070
4046
|
}
|
|
4071
4047
|
|
|
4072
|
-
// tax/sha1.ts
|
|
4073
|
-
function utf8Bytes(text) {
|
|
4074
|
-
const bytes = [];
|
|
4075
|
-
for (const char of text) {
|
|
4076
|
-
const cp = char.codePointAt(0);
|
|
4077
|
-
if (cp < 128) bytes.push(cp);
|
|
4078
|
-
else if (cp < 2048) bytes.push(192 | cp >> 6, 128 | cp & 63);
|
|
4079
|
-
else if (cp < 65536) bytes.push(224 | cp >> 12, 128 | cp >> 6 & 63, 128 | cp & 63);
|
|
4080
|
-
else bytes.push(240 | cp >> 18, 128 | cp >> 12 & 63, 128 | cp >> 6 & 63, 128 | cp & 63);
|
|
4081
|
-
}
|
|
4082
|
-
return bytes;
|
|
4083
|
-
}
|
|
4084
|
-
var rotl = (x, n) => x << n | x >>> 32 - n;
|
|
4085
|
-
function sha1Hex(text) {
|
|
4086
|
-
const bytes = utf8Bytes(text);
|
|
4087
|
-
const bitLength = bytes.length * 8;
|
|
4088
|
-
bytes.push(128);
|
|
4089
|
-
while (bytes.length % 64 !== 56) bytes.push(0);
|
|
4090
|
-
const high = Math.floor(bitLength / 4294967296);
|
|
4091
|
-
for (const word of [high, bitLength >>> 0])
|
|
4092
|
-
bytes.push(word >>> 24 & 255, word >>> 16 & 255, word >>> 8 & 255, word & 255);
|
|
4093
|
-
const h = [1732584193, 4023233417, 2562383102, 271733878, 3285377520];
|
|
4094
|
-
const w = new Array(80);
|
|
4095
|
-
for (let offset = 0; offset < bytes.length; offset += 64) {
|
|
4096
|
-
for (let i = 0; i < 16; i++) {
|
|
4097
|
-
const j = offset + i * 4;
|
|
4098
|
-
w[i] = bytes[j] << 24 | bytes[j + 1] << 16 | bytes[j + 2] << 8 | bytes[j + 3];
|
|
4099
|
-
}
|
|
4100
|
-
for (let i = 16; i < 80; i++) w[i] = rotl(w[i - 3] ^ w[i - 8] ^ w[i - 14] ^ w[i - 16], 1);
|
|
4101
|
-
let [a, b, c, d, e] = h;
|
|
4102
|
-
for (let i = 0; i < 80; i++) {
|
|
4103
|
-
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];
|
|
4104
|
-
const t = rotl(a, 5) + f + e + k + w[i] | 0;
|
|
4105
|
-
e = d;
|
|
4106
|
-
d = c;
|
|
4107
|
-
c = rotl(b, 30);
|
|
4108
|
-
b = a;
|
|
4109
|
-
a = t;
|
|
4110
|
-
}
|
|
4111
|
-
h[0] = h[0] + a | 0;
|
|
4112
|
-
h[1] = h[1] + b | 0;
|
|
4113
|
-
h[2] = h[2] + c | 0;
|
|
4114
|
-
h[3] = h[3] + d | 0;
|
|
4115
|
-
h[4] = h[4] + e | 0;
|
|
4116
|
-
}
|
|
4117
|
-
return h.map((x) => (x >>> 0).toString(16).padStart(8, "0")).join("");
|
|
4118
|
-
}
|
|
4119
|
-
|
|
4120
|
-
// tax/table.ts
|
|
4121
|
-
var STANDARD_TAX_TYPE = "standard";
|
|
4122
|
-
var TYPE_FIELDS = ["key", "name", "description", "sortOrder", "active"];
|
|
4123
|
-
var RATE_FIELDS = [
|
|
4124
|
-
"code",
|
|
4125
|
-
"name",
|
|
4126
|
-
"kind",
|
|
4127
|
-
"places",
|
|
4128
|
-
"rate",
|
|
4129
|
-
"from",
|
|
4130
|
-
"to",
|
|
4131
|
-
"order",
|
|
4132
|
-
"compound",
|
|
4133
|
-
"registrationPlace",
|
|
4134
|
-
"harmonized",
|
|
4135
|
-
"parts",
|
|
4136
|
-
"sourceUrl",
|
|
4137
|
-
"status"
|
|
4138
|
-
];
|
|
4139
|
-
var RULE_FIELDS = ["taxType", "codes", "rate", "from", "to", "sourceUrl", "status", "note"];
|
|
4140
|
-
function canonical(row, fields) {
|
|
4141
|
-
return JSON.stringify(fields.map((field) => row[field] ?? null));
|
|
4142
|
-
}
|
|
4143
|
-
var sortedCanonical = (rows, fields) => rows.map((row) => canonical(row, fields)).sort();
|
|
4144
|
-
function automaticTaxTableVersion(table) {
|
|
4145
|
-
return sha1Hex(
|
|
4146
|
-
JSON.stringify([
|
|
4147
|
-
sortedCanonical(table.types, TYPE_FIELDS),
|
|
4148
|
-
sortedCanonical(table.rates, RATE_FIELDS),
|
|
4149
|
-
sortedCanonical(table.rules, RULE_FIELDS)
|
|
4150
|
-
])
|
|
4151
|
-
);
|
|
4152
|
-
}
|
|
4153
|
-
var toTypeRow = ({ key, name, description, sortOrder, active }) => ({
|
|
4154
|
-
key,
|
|
4155
|
-
name,
|
|
4156
|
-
description,
|
|
4157
|
-
sortOrder,
|
|
4158
|
-
active
|
|
4159
|
-
});
|
|
4160
|
-
var toRateRow = (rate) => ({
|
|
4161
|
-
code: rate.code,
|
|
4162
|
-
name: rate.name,
|
|
4163
|
-
kind: rate.kind,
|
|
4164
|
-
places: rate.places,
|
|
4165
|
-
rate: rate.rate,
|
|
4166
|
-
from: rate.from,
|
|
4167
|
-
to: rate.to,
|
|
4168
|
-
order: rate.order,
|
|
4169
|
-
compound: rate.compound,
|
|
4170
|
-
registrationPlace: rate.registrationPlace,
|
|
4171
|
-
harmonized: rate.harmonized,
|
|
4172
|
-
parts: rate.parts?.map(({ code, name, rate: partRate, level }) => ({ code, name, rate: partRate, level })),
|
|
4173
|
-
sourceUrl: rate.sourceUrl,
|
|
4174
|
-
status: rate.status
|
|
4175
|
-
});
|
|
4176
|
-
var toRuleRow = ({
|
|
4177
|
-
taxType,
|
|
4178
|
-
codes: codes2,
|
|
4179
|
-
rate,
|
|
4180
|
-
from,
|
|
4181
|
-
to,
|
|
4182
|
-
sourceUrl,
|
|
4183
|
-
status,
|
|
4184
|
-
note
|
|
4185
|
-
}) => ({
|
|
4186
|
-
taxType,
|
|
4187
|
-
codes: codes2,
|
|
4188
|
-
rate,
|
|
4189
|
-
from,
|
|
4190
|
-
to,
|
|
4191
|
-
sourceUrl,
|
|
4192
|
-
status,
|
|
4193
|
-
note
|
|
4194
|
-
});
|
|
4195
|
-
function buildAutomaticTaxTable(rows) {
|
|
4196
|
-
const table = {
|
|
4197
|
-
types: [...rows.types].sort((a, b) => a.sortOrder - b.sortOrder).map(toTypeRow),
|
|
4198
|
-
rates: rows.rates.map(toRateRow),
|
|
4199
|
-
rules: rows.rules.map(toRuleRow)
|
|
4200
|
-
};
|
|
4201
|
-
return { version: automaticTaxTableVersion(table), ...table };
|
|
4202
|
-
}
|
|
4203
|
-
function registrationPlacesByKind(rates) {
|
|
4204
|
-
const places = /* @__PURE__ */ new Map();
|
|
4205
|
-
for (const rate of rates) {
|
|
4206
|
-
const list = places.get(rate.kind) ?? [];
|
|
4207
|
-
if (!list.includes(rate.registrationPlace)) list.push(rate.registrationPlace);
|
|
4208
|
-
places.set(rate.kind, list);
|
|
4209
|
-
}
|
|
4210
|
-
return places;
|
|
4211
|
-
}
|
|
4212
|
-
|
|
4213
|
-
// shopper/types.ts
|
|
4214
|
-
var SHOPPER_CONSENT_SOURCES = ["checkout", "my-account", "store-account"];
|
|
4215
|
-
var SHOPPER_RETURN_METHODS = ["mail", "in-store"];
|
|
4216
|
-
var SHOPPER_ERROR_CODES = {
|
|
4217
|
-
ORDER_NOT_FOUND: "ORDER_NOT_FOUND",
|
|
4218
|
-
RETURN_ALREADY_REQUESTED: "RETURN_ALREADY_REQUESTED",
|
|
4219
|
-
RETURN_NOT_ALLOWED: "RETURN_NOT_ALLOWED",
|
|
4220
|
-
STORE_HAS_NO_SUPPORT_EMAIL: "STORE_HAS_NO_SUPPORT_EMAIL",
|
|
4221
|
-
TOO_MANY_ADDRESSES: "TOO_MANY_ADDRESSES",
|
|
4222
|
-
STORE_NOT_LINKED: "STORE_NOT_LINKED",
|
|
4223
|
-
STORED_METHOD_NOT_FOUND: "STORED_METHOD_NOT_FOUND"
|
|
4224
|
-
};
|
|
4225
|
-
|
|
4226
|
-
// shopper/email.ts
|
|
4227
|
-
function normalizeShopperEmail(email) {
|
|
4228
|
-
if (typeof email !== "string") return null;
|
|
4229
|
-
const value = email.trim().toLowerCase();
|
|
4230
|
-
return /^[^\s@]+@[^\s@]+$/.test(value) ? value : null;
|
|
4231
|
-
}
|
|
4232
|
-
|
|
4233
|
-
// shopper/card.ts
|
|
4234
|
-
function cardFromProcessorData(processorData) {
|
|
4235
|
-
if (typeof processorData !== "string" || !processorData) return {};
|
|
4236
|
-
let data;
|
|
4237
|
-
try {
|
|
4238
|
-
data = JSON.parse(processorData);
|
|
4239
|
-
} catch {
|
|
4240
|
-
return {};
|
|
4241
|
-
}
|
|
4242
|
-
if (!data || typeof data !== "object") return {};
|
|
4243
|
-
const fields = new Map(Object.entries(data));
|
|
4244
|
-
const text = (...keys) => keys.map((key) => fields.get(key)).find((value) => typeof value === "string" && !!value.trim());
|
|
4245
|
-
const brand = text("Brand", "brand")?.trim();
|
|
4246
|
-
const digits = text("Card Number", "card", "card_number")?.replace(/\D/g, "");
|
|
4247
|
-
return {
|
|
4248
|
-
...brand ? { cardBrand: brand.charAt(0).toUpperCase() + brand.slice(1) } : {},
|
|
4249
|
-
...digits && digits.length >= 4 ? { cardLastFour: digits.slice(-4) } : {}
|
|
4250
|
-
};
|
|
4251
|
-
}
|
|
4252
|
-
|
|
4253
4048
|
// constants/adyen.constants.ts
|
|
4254
4049
|
var ADYEN_ROLLOUT_COUNTRY_CODES = /* @__PURE__ */ new Set(["CA"]);
|
|
4255
4050
|
function isAdyenRolloutCountry(alpha2) {
|
|
@@ -4402,7 +4197,6 @@ export {
|
|
|
4402
4197
|
ORDER_STATE_TOPIC,
|
|
4403
4198
|
OrderPlatform,
|
|
4404
4199
|
OtherFixedRates,
|
|
4405
|
-
OutOfProvinceTaxes,
|
|
4406
4200
|
OwnerType,
|
|
4407
4201
|
PATH_MODES,
|
|
4408
4202
|
PAYMENT_CHANNELS,
|
|
@@ -4431,10 +4225,6 @@ export {
|
|
|
4431
4225
|
ResidualStatus,
|
|
4432
4226
|
ResourceAvailabilityState,
|
|
4433
4227
|
SHIPPING_COUNTRIES,
|
|
4434
|
-
SHOPPER_CONSENT_SOURCES,
|
|
4435
|
-
SHOPPER_ERROR_CODES,
|
|
4436
|
-
SHOPPER_RETURN_METHODS,
|
|
4437
|
-
STANDARD_TAX_TYPE,
|
|
4438
4228
|
STATE_SCHEMA,
|
|
4439
4229
|
STRIPE_SUPPORTED_COUNTRIES,
|
|
4440
4230
|
SYSTEM_FAMILIES,
|
|
@@ -4452,9 +4242,6 @@ export {
|
|
|
4452
4242
|
StationStatus,
|
|
4453
4243
|
StripeCurrencyCode,
|
|
4454
4244
|
StripeStatus,
|
|
4455
|
-
TaxRegistrationKind,
|
|
4456
|
-
TaxSource,
|
|
4457
|
-
TaxWarningCode,
|
|
4458
4245
|
TimePeriod,
|
|
4459
4246
|
TopMetericsSort,
|
|
4460
4247
|
UserTypes,
|
|
@@ -4469,13 +4256,11 @@ export {
|
|
|
4469
4256
|
ancestorChain,
|
|
4470
4257
|
applyAssignment,
|
|
4471
4258
|
assertUnitSane,
|
|
4472
|
-
automaticTaxTableVersion,
|
|
4473
4259
|
availableIn,
|
|
4474
4260
|
baseFor,
|
|
4475
4261
|
baseFulfillmentDefinitions,
|
|
4476
4262
|
baseOf,
|
|
4477
4263
|
basePaymentDefinitions,
|
|
4478
|
-
buildAutomaticTaxTable,
|
|
4479
4264
|
buildAvailability,
|
|
4480
4265
|
buildGrid,
|
|
4481
4266
|
buildOrderContext,
|
|
@@ -4483,7 +4268,6 @@ export {
|
|
|
4483
4268
|
buildResolvedConfig,
|
|
4484
4269
|
calculatePercentage,
|
|
4485
4270
|
canTransition,
|
|
4486
|
-
cardFromProcessorData,
|
|
4487
4271
|
cheapestCompositeItem,
|
|
4488
4272
|
cheapestCompositePrice,
|
|
4489
4273
|
compositeItemCost,
|
|
@@ -4558,7 +4342,6 @@ export {
|
|
|
4558
4342
|
normalizeMongoIdString,
|
|
4559
4343
|
normalizePostCode,
|
|
4560
4344
|
normalizeProvince,
|
|
4561
|
-
normalizeShopperEmail,
|
|
4562
4345
|
occupancyIn,
|
|
4563
4346
|
orderAssignments,
|
|
4564
4347
|
parseAmountToMinorUnits,
|
|
@@ -4574,7 +4357,6 @@ export {
|
|
|
4574
4357
|
presentAt,
|
|
4575
4358
|
priceForTotal,
|
|
4576
4359
|
provincesForPostCode,
|
|
4577
|
-
registrationPlacesByKind,
|
|
4578
4360
|
removeFragment,
|
|
4579
4361
|
resolveFamily,
|
|
4580
4362
|
resolveModifiersForProduct,
|
|
@@ -4584,7 +4366,6 @@ export {
|
|
|
4584
4366
|
roundToPrecision,
|
|
4585
4367
|
sameFamily,
|
|
4586
4368
|
setOrderState,
|
|
4587
|
-
sha1Hex,
|
|
4588
4369
|
shipsToCountry,
|
|
4589
4370
|
shopDayKey,
|
|
4590
4371
|
shopDayRange,
|