@final-commerce/common 2.11.2-preprod.0 → 2.11.2-staging2.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/dist/index.d.mts +1 -73
- package/dist/index.d.ts +1 -73
- package/dist/index.js +0 -181
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +0 -166
- package/dist/index.mjs.map +1 -1
- package/dist/pos-types/index.d.mts +1 -28
- package/dist/pos-types/index.d.ts +1 -28
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1781,157 +1781,6 @@ function lineStockMoves(item, quantity, reservations = []) {
|
|
|
1781
1781
|
});
|
|
1782
1782
|
}
|
|
1783
1783
|
|
|
1784
|
-
// utils/shell-settings.util.ts
|
|
1785
|
-
var DEFAULT_SHELL_SETTINGS = {
|
|
1786
|
-
pinSwitchUser: false,
|
|
1787
|
-
pinSession: false,
|
|
1788
|
-
stationLock: 0,
|
|
1789
|
-
buildTimeout: 0,
|
|
1790
|
-
lockedAccess: false,
|
|
1791
|
-
cashManagement: true,
|
|
1792
|
-
tips: {
|
|
1793
|
-
enabled: true,
|
|
1794
|
-
tip1: { label: "Good", value: 15 },
|
|
1795
|
-
tip2: { label: "Great", value: 18 },
|
|
1796
|
-
tip3: { label: "Amazing!", value: 25 },
|
|
1797
|
-
customTipLabel: "Custom",
|
|
1798
|
-
noTipLabel: "No tip"
|
|
1799
|
-
}
|
|
1800
|
-
};
|
|
1801
|
-
var FIELD_ORDER = ["station"];
|
|
1802
|
-
var TIP_ORDER = ["station", "outlet", "flow", "company"];
|
|
1803
|
-
var TOP_FIELDS = [
|
|
1804
|
-
"pinSwitchUser",
|
|
1805
|
-
"pinSession",
|
|
1806
|
-
"stationLock",
|
|
1807
|
-
"buildTimeout",
|
|
1808
|
-
"lockedAccess",
|
|
1809
|
-
"cashManagement"
|
|
1810
|
-
];
|
|
1811
|
-
var TIP_FIELDS = ["enabled", "tip1", "tip2", "tip3", "customTipLabel", "noTipLabel"];
|
|
1812
|
-
function pick(levels, order, read, fallback) {
|
|
1813
|
-
for (const level of order) {
|
|
1814
|
-
const settings = levels[level];
|
|
1815
|
-
if (!settings) continue;
|
|
1816
|
-
const value = read(settings);
|
|
1817
|
-
if (value !== void 0 && value !== null) return { value, source: level };
|
|
1818
|
-
}
|
|
1819
|
-
return { value: fallback, source: "default" };
|
|
1820
|
-
}
|
|
1821
|
-
function resolveShellSettingsWithSources(levels) {
|
|
1822
|
-
const settings = { ...DEFAULT_SHELL_SETTINGS, tips: { ...DEFAULT_SHELL_SETTINGS.tips } };
|
|
1823
|
-
const sources = { fields: {}, tips: {} };
|
|
1824
|
-
for (const field of TOP_FIELDS) {
|
|
1825
|
-
const { value, source } = pick(levels, FIELD_ORDER, (s) => s[field], DEFAULT_SHELL_SETTINGS[field]);
|
|
1826
|
-
settings[field] = value;
|
|
1827
|
-
sources.fields[field] = source;
|
|
1828
|
-
}
|
|
1829
|
-
for (const field of TIP_FIELDS) {
|
|
1830
|
-
const { value, source } = pick(levels, TIP_ORDER, (s) => s.tips?.[field], DEFAULT_SHELL_SETTINGS.tips[field]);
|
|
1831
|
-
settings.tips[field] = value;
|
|
1832
|
-
sources.tips[field] = source;
|
|
1833
|
-
}
|
|
1834
|
-
return { settings, sources };
|
|
1835
|
-
}
|
|
1836
|
-
function resolveShellSettings(levels) {
|
|
1837
|
-
return resolveShellSettingsWithSources(levels).settings;
|
|
1838
|
-
}
|
|
1839
|
-
var SHELL_TIP_PERCENT_MIN = 1;
|
|
1840
|
-
var SHELL_TIP_PERCENT_MAX = 100;
|
|
1841
|
-
var SHELL_TIP_LABEL_MAX_LENGTH = 20;
|
|
1842
|
-
var isLabel = (raw) => typeof raw === "string" && raw.trim().length > 0 && raw.length <= SHELL_TIP_LABEL_MAX_LENGTH;
|
|
1843
|
-
var isShellTipPercent = (raw) => typeof raw === "number" && Number.isInteger(raw) && raw >= SHELL_TIP_PERCENT_MIN && raw <= SHELL_TIP_PERCENT_MAX;
|
|
1844
|
-
function shellTipSettingsProblems(tips) {
|
|
1845
|
-
if (!tips) return [];
|
|
1846
|
-
const problems = [];
|
|
1847
|
-
if (tips.enabled !== void 0 && typeof tips.enabled !== "boolean") {
|
|
1848
|
-
problems.push({ field: "tips.enabled", code: "boolean" });
|
|
1849
|
-
}
|
|
1850
|
-
for (const key of ["tip1", "tip2", "tip3"]) {
|
|
1851
|
-
const option = tips[key];
|
|
1852
|
-
if (option === void 0) continue;
|
|
1853
|
-
if (!option || typeof option !== "object") {
|
|
1854
|
-
problems.push({ field: `tips.${key}`, code: "preset" });
|
|
1855
|
-
continue;
|
|
1856
|
-
}
|
|
1857
|
-
if (!isShellTipPercent(option.value)) problems.push({ field: `tips.${key}`, code: "percent" });
|
|
1858
|
-
if (!isLabel(option.label)) problems.push({ field: `tips.${key}`, code: "label" });
|
|
1859
|
-
}
|
|
1860
|
-
for (const key of ["customTipLabel", "noTipLabel"]) {
|
|
1861
|
-
if (tips[key] !== void 0 && !isLabel(tips[key])) problems.push({ field: `tips.${key}`, code: "label" });
|
|
1862
|
-
}
|
|
1863
|
-
return problems;
|
|
1864
|
-
}
|
|
1865
|
-
function shellSettingsProblems(settings) {
|
|
1866
|
-
if (!settings) return [];
|
|
1867
|
-
const problems = [];
|
|
1868
|
-
for (const field of ["pinSwitchUser", "pinSession", "lockedAccess", "cashManagement"]) {
|
|
1869
|
-
if (settings[field] !== void 0 && typeof settings[field] !== "boolean")
|
|
1870
|
-
problems.push({ field, code: "boolean" });
|
|
1871
|
-
}
|
|
1872
|
-
for (const field of ["stationLock", "buildTimeout"]) {
|
|
1873
|
-
const value = settings[field];
|
|
1874
|
-
if (value !== void 0 && !(typeof value === "number" && Number.isInteger(value) && value >= 0)) {
|
|
1875
|
-
problems.push({ field, code: "timeout" });
|
|
1876
|
-
}
|
|
1877
|
-
}
|
|
1878
|
-
return [...problems, ...shellTipSettingsProblems(settings.tips)];
|
|
1879
|
-
}
|
|
1880
|
-
var SHELL_FLOW_SETTINGS_PREFIX = "flowSettingsKey";
|
|
1881
|
-
var SHELL_FLOW_TIPS_KEY = `${SHELL_FLOW_SETTINGS_PREFIX}.tips`;
|
|
1882
|
-
var readBoolean = (raw) => {
|
|
1883
|
-
if (raw === void 0 || raw === "") return void 0;
|
|
1884
|
-
const v = raw.trim().toLowerCase();
|
|
1885
|
-
if (v === "true") return true;
|
|
1886
|
-
if (v === "false") return false;
|
|
1887
|
-
return void 0;
|
|
1888
|
-
};
|
|
1889
|
-
function readTipOption(raw) {
|
|
1890
|
-
if (!raw || typeof raw !== "object") return void 0;
|
|
1891
|
-
const { label, value } = raw;
|
|
1892
|
-
const n = typeof value === "number" ? value : parseFloat(String(value ?? ""));
|
|
1893
|
-
if (typeof label !== "string" || !Number.isFinite(n) || n < 0) return void 0;
|
|
1894
|
-
return { label, value: n };
|
|
1895
|
-
}
|
|
1896
|
-
function readShellTipSettings(raw) {
|
|
1897
|
-
if (!raw || typeof raw !== "object") return void 0;
|
|
1898
|
-
const r = raw;
|
|
1899
|
-
const tips = {};
|
|
1900
|
-
if (typeof r.enabled === "boolean") tips.enabled = r.enabled;
|
|
1901
|
-
const tip1 = readTipOption(r.tip1);
|
|
1902
|
-
const tip2 = readTipOption(r.tip2);
|
|
1903
|
-
const tip3 = readTipOption(r.tip3);
|
|
1904
|
-
if (tip1) tips.tip1 = tip1;
|
|
1905
|
-
if (tip2) tips.tip2 = tip2;
|
|
1906
|
-
if (tip3) tips.tip3 = tip3;
|
|
1907
|
-
if (typeof r.customTipLabel === "string") tips.customTipLabel = r.customTipLabel;
|
|
1908
|
-
if (typeof r.noTipLabel === "string") tips.noTipLabel = r.noTipLabel;
|
|
1909
|
-
return Object.keys(tips).length > 0 ? tips : void 0;
|
|
1910
|
-
}
|
|
1911
|
-
var parseJson = (raw) => {
|
|
1912
|
-
if (!raw) return void 0;
|
|
1913
|
-
try {
|
|
1914
|
-
return JSON.parse(raw);
|
|
1915
|
-
} catch {
|
|
1916
|
-
return void 0;
|
|
1917
|
-
}
|
|
1918
|
-
};
|
|
1919
|
-
function shellSettingsFromFlowSettings(dict) {
|
|
1920
|
-
const tips = readShellTipSettings(parseJson(dict?.[SHELL_FLOW_TIPS_KEY]));
|
|
1921
|
-
return tips ? { tips } : {};
|
|
1922
|
-
}
|
|
1923
|
-
function flowSettingsFromShellSettings(settings) {
|
|
1924
|
-
return settings.tips && Object.keys(settings.tips).length > 0 ? { [SHELL_FLOW_TIPS_KEY]: JSON.stringify(settings.tips) } : {};
|
|
1925
|
-
}
|
|
1926
|
-
function shellSettingsFromCompanyTips(enabled, options) {
|
|
1927
|
-
const tips = {
|
|
1928
|
-
...readShellTipSettings(typeof options === "string" ? parseJson(options) : options)
|
|
1929
|
-
};
|
|
1930
|
-
const on = typeof enabled === "boolean" ? enabled : readBoolean(typeof enabled === "string" ? enabled : void 0);
|
|
1931
|
-
if (on !== void 0) tips.enabled = on;
|
|
1932
|
-
return Object.keys(tips).length > 0 ? { tips } : {};
|
|
1933
|
-
}
|
|
1934
|
-
|
|
1935
1784
|
// units/family-code.ts
|
|
1936
1785
|
var MAX_SLUG_LENGTH = 32;
|
|
1937
1786
|
var FALLBACK_SLUG = "family";
|
|
@@ -4320,7 +4169,6 @@ export {
|
|
|
4320
4169
|
DEFAULT_DISPLAY_STATE_MAP,
|
|
4321
4170
|
DEFAULT_HOLD_MINUTES,
|
|
4322
4171
|
DEFAULT_RESOLVED_CONFIG,
|
|
4323
|
-
DEFAULT_SHELL_SETTINGS,
|
|
4324
4172
|
DEFAULT_UNIT_ID,
|
|
4325
4173
|
DualWriteStrategy,
|
|
4326
4174
|
EUFixedRates,
|
|
@@ -4376,11 +4224,6 @@ export {
|
|
|
4376
4224
|
ResidualPaymentMethod,
|
|
4377
4225
|
ResidualStatus,
|
|
4378
4226
|
ResourceAvailabilityState,
|
|
4379
|
-
SHELL_FLOW_SETTINGS_PREFIX,
|
|
4380
|
-
SHELL_FLOW_TIPS_KEY,
|
|
4381
|
-
SHELL_TIP_LABEL_MAX_LENGTH,
|
|
4382
|
-
SHELL_TIP_PERCENT_MAX,
|
|
4383
|
-
SHELL_TIP_PERCENT_MIN,
|
|
4384
4227
|
SHIPPING_COUNTRIES,
|
|
4385
4228
|
STATE_SCHEMA,
|
|
4386
4229
|
STRIPE_SUPPORTED_COUNTRIES,
|
|
@@ -4447,7 +4290,6 @@ export {
|
|
|
4447
4290
|
evaluateConditionSet,
|
|
4448
4291
|
extendPrice,
|
|
4449
4292
|
extendPriceFor,
|
|
4450
|
-
flowSettingsFromShellSettings,
|
|
4451
4293
|
formatCurrency,
|
|
4452
4294
|
formatInUnit,
|
|
4453
4295
|
formatMinorUnitsToString,
|
|
@@ -4481,7 +4323,6 @@ export {
|
|
|
4481
4323
|
isFulfillmentState,
|
|
4482
4324
|
isInCart,
|
|
4483
4325
|
isPaymentState,
|
|
4484
|
-
isShellTipPercent,
|
|
4485
4326
|
isSupportedCurrency,
|
|
4486
4327
|
isSystemFamilyCode,
|
|
4487
4328
|
isValidQuantity,
|
|
@@ -4516,22 +4357,15 @@ export {
|
|
|
4516
4357
|
presentAt,
|
|
4517
4358
|
priceForTotal,
|
|
4518
4359
|
provincesForPostCode,
|
|
4519
|
-
readShellTipSettings,
|
|
4520
4360
|
removeFragment,
|
|
4521
4361
|
resolveFamily,
|
|
4522
4362
|
resolveModifiersForProduct,
|
|
4523
|
-
resolveShellSettings,
|
|
4524
|
-
resolveShellSettingsWithSources,
|
|
4525
4363
|
resolveShipping,
|
|
4526
4364
|
resolveTemplate,
|
|
4527
4365
|
resolveUnit,
|
|
4528
4366
|
roundToPrecision,
|
|
4529
4367
|
sameFamily,
|
|
4530
4368
|
setOrderState,
|
|
4531
|
-
shellSettingsFromCompanyTips,
|
|
4532
|
-
shellSettingsFromFlowSettings,
|
|
4533
|
-
shellSettingsProblems,
|
|
4534
|
-
shellTipSettingsProblems,
|
|
4535
4369
|
shipsToCountry,
|
|
4536
4370
|
shopDayKey,
|
|
4537
4371
|
shopDayRange,
|