sahab-utils 2.1.6 → 2.1.7
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/ts/cash.d.ts +1 -1
- package/dist/ts/cash.js +1 -1
- package/dist/ts/utils.d.ts +2 -0
- package/dist/ts/utils.js +5 -2
- package/package.json +1 -1
package/dist/ts/cash.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Order, PaymentConfigs } from '../constants/types';
|
|
2
|
-
/** Cash payment — the shared rules. The fee is set from `payment_methods
|
|
2
|
+
/** Cash payment — the shared rules. The fee is set from `configs/payment_methods`; the app only shows it
|
|
3
3
|
* and cloudFun is what charges it, so both must reach the same number from the same config. */
|
|
4
4
|
/** A fee above this is read as a typo (5000 for 5.00) and ignored rather than charged to customers. */
|
|
5
5
|
export declare const MAX_CASH_FEE = 50;
|
package/dist/ts/cash.js
CHANGED
|
@@ -7,7 +7,7 @@ exports.cashAmountToCollect = cashAmountToCollect;
|
|
|
7
7
|
const types_1 = require("../constants/types");
|
|
8
8
|
const calcs_1 = require("./calcs");
|
|
9
9
|
const utils_1 = require("./utils");
|
|
10
|
-
/** Cash payment — the shared rules. The fee is set from `payment_methods
|
|
10
|
+
/** Cash payment — the shared rules. The fee is set from `configs/payment_methods`; the app only shows it
|
|
11
11
|
* and cloudFun is what charges it, so both must reach the same number from the same config. */
|
|
12
12
|
/** A fee above this is read as a typo (5000 for 5.00) and ignored rather than charged to customers. */
|
|
13
13
|
exports.MAX_CASH_FEE = 50;
|
package/dist/ts/utils.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ export declare function preventNaN(x?: number | string): number;
|
|
|
2
2
|
export declare const toFixed: (num: any) => string;
|
|
3
3
|
export declare const isEmpty: (text: any) => boolean;
|
|
4
4
|
export declare const compareVersions: (version1: string, version2: string) => number;
|
|
5
|
+
/** A plain dotted version such as `2.1.0`: digits and dots only. The one rule for saving a minimum version and for reading it. */
|
|
6
|
+
export declare const isValidVersion: (value: unknown) => value is string;
|
|
5
7
|
/** Fails open on a missing/malformed version — a second, independent guard (the admin UI already
|
|
6
8
|
* validates before saving) against a hand-edit or future write path bricking every install with a typo. */
|
|
7
9
|
export declare function shouldForceUpdate(minVer?: string, currentVersion?: string): boolean;
|
package/dist/ts/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.compareVersions = exports.isEmpty = exports.toFixed = void 0;
|
|
3
|
+
exports.isValidVersion = exports.compareVersions = exports.isEmpty = exports.toFixed = void 0;
|
|
4
4
|
exports.preventNaN = preventNaN;
|
|
5
5
|
exports.shouldForceUpdate = shouldForceUpdate;
|
|
6
6
|
function preventNaN(x) {
|
|
@@ -39,12 +39,15 @@ const compareVersions = (version1, version2) => {
|
|
|
39
39
|
};
|
|
40
40
|
exports.compareVersions = compareVersions;
|
|
41
41
|
const VERSION_RE = /^\d+(\.\d+)*$/;
|
|
42
|
+
/** A plain dotted version such as `2.1.0`: digits and dots only. The one rule for saving a minimum version and for reading it. */
|
|
43
|
+
const isValidVersion = (value) => typeof value === 'string' && value.length <= 20 && VERSION_RE.test(value);
|
|
44
|
+
exports.isValidVersion = isValidVersion;
|
|
42
45
|
/** Fails open on a missing/malformed version — a second, independent guard (the admin UI already
|
|
43
46
|
* validates before saving) against a hand-edit or future write path bricking every install with a typo. */
|
|
44
47
|
function shouldForceUpdate(minVer, currentVersion) {
|
|
45
48
|
if (!minVer || !currentVersion)
|
|
46
49
|
return false;
|
|
47
|
-
if (!
|
|
50
|
+
if (!(0, exports.isValidVersion)(minVer) || !(0, exports.isValidVersion)(currentVersion))
|
|
48
51
|
return false;
|
|
49
52
|
return (0, exports.compareVersions)(minVer, currentVersion) > 0;
|
|
50
53
|
}
|