@nocobase/evaluators 0.13.0-alpha.3 → 0.13.0-alpha.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/lib/client/engines/formulajs.js +37 -13
- package/lib/client/engines/mathjs.js +37 -13
- package/lib/client/index.js +51 -30
- package/lib/index.js +36 -23
- package/lib/server/index.js +49 -33
- package/lib/utils/formulajs.js +40 -20
- package/lib/utils/index.js +46 -28
- package/lib/utils/mathjs.js +39 -19
- package/package.json +3 -3
|
@@ -1,16 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var formulajs_exports = {};
|
|
29
|
+
__export(formulajs_exports, {
|
|
30
|
+
default: () => formulajs_default
|
|
5
31
|
});
|
|
6
|
-
exports
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
label: 'Formula.js',
|
|
32
|
+
module.exports = __toCommonJS(formulajs_exports);
|
|
33
|
+
var import_utils = require("../../utils");
|
|
34
|
+
var import_formulajs = __toESM(require("../../utils/formulajs"));
|
|
35
|
+
var formulajs_default = {
|
|
36
|
+
label: "Formula.js",
|
|
12
37
|
tooltip: '{{t("Formula.js supports most Microsoft Excel formula functions.")}}',
|
|
13
|
-
link:
|
|
14
|
-
evaluate:
|
|
38
|
+
link: "https://formulajs.info/functions/",
|
|
39
|
+
evaluate: import_utils.evaluate.bind(import_formulajs.default)
|
|
15
40
|
};
|
|
16
|
-
exports.default = _default;
|
|
@@ -1,16 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var mathjs_exports = {};
|
|
29
|
+
__export(mathjs_exports, {
|
|
30
|
+
default: () => mathjs_default
|
|
5
31
|
});
|
|
6
|
-
exports
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
label: 'Math.js',
|
|
32
|
+
module.exports = __toCommonJS(mathjs_exports);
|
|
33
|
+
var import_utils = require("../../utils");
|
|
34
|
+
var import_mathjs = __toESM(require("../../utils/mathjs"));
|
|
35
|
+
var mathjs_default = {
|
|
36
|
+
label: "Math.js",
|
|
12
37
|
tooltip: `{{t('Math.js comes with a large set of built-in functions and constants, and offers an integrated solution to work with different data types')}}`,
|
|
13
|
-
link:
|
|
14
|
-
evaluate:
|
|
38
|
+
link: "https://mathjs.org/",
|
|
39
|
+
evaluate: import_utils.evaluate.bind(import_mathjs.default)
|
|
15
40
|
};
|
|
16
|
-
exports.default = _default;
|
package/lib/client/index.js
CHANGED
|
@@ -1,33 +1,54 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var client_exports = {};
|
|
30
|
+
__export(client_exports, {
|
|
31
|
+
default: () => client_default,
|
|
32
|
+
evaluators: () => evaluators,
|
|
33
|
+
getOptions: () => getOptions
|
|
5
34
|
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return data;
|
|
14
|
-
}
|
|
15
|
-
var _mathjs = _interopRequireDefault(require("./engines/mathjs"));
|
|
16
|
-
var _formulajs = _interopRequireDefault(require("./engines/formulajs"));
|
|
17
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
19
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
20
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
21
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
22
|
-
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
23
|
-
const evaluators = new (_client().Registry)();
|
|
24
|
-
exports.evaluators = evaluators;
|
|
25
|
-
evaluators.register('math.js', _mathjs.default);
|
|
26
|
-
evaluators.register('formula.js', _formulajs.default);
|
|
35
|
+
module.exports = __toCommonJS(client_exports);
|
|
36
|
+
var import_client = require("@nocobase/utils/client");
|
|
37
|
+
var import_mathjs = __toESM(require("./engines/mathjs"));
|
|
38
|
+
var import_formulajs = __toESM(require("./engines/formulajs"));
|
|
39
|
+
const evaluators = new import_client.Registry();
|
|
40
|
+
evaluators.register("math.js", import_mathjs.default);
|
|
41
|
+
evaluators.register("formula.js", import_formulajs.default);
|
|
27
42
|
function getOptions() {
|
|
28
|
-
return Array.from(evaluators.getEntities()).reduce(
|
|
29
|
-
value
|
|
30
|
-
|
|
43
|
+
return Array.from(evaluators.getEntities()).reduce(
|
|
44
|
+
(result, [value, options]) => result.concat({ value, ...options }),
|
|
45
|
+
[]
|
|
46
|
+
);
|
|
31
47
|
}
|
|
32
|
-
|
|
33
|
-
|
|
48
|
+
__name(getOptions, "getOptions");
|
|
49
|
+
var client_default = evaluators;
|
|
50
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
51
|
+
0 && (module.exports = {
|
|
52
|
+
evaluators,
|
|
53
|
+
getOptions
|
|
54
|
+
});
|
package/lib/index.js
CHANGED
|
@@ -1,26 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
16
|
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var src_exports = {};
|
|
30
|
+
__export(src_exports, {
|
|
31
|
+
default: () => import_server.default
|
|
12
32
|
});
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function get() {
|
|
21
|
-
return _server[key];
|
|
22
|
-
}
|
|
23
|
-
});
|
|
33
|
+
module.exports = __toCommonJS(src_exports);
|
|
34
|
+
var import_server = __toESM(require("./server"));
|
|
35
|
+
__reExport(src_exports, require("./server"), module.exports);
|
|
36
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
37
|
+
0 && (module.exports = {
|
|
38
|
+
...require("./server")
|
|
24
39
|
});
|
|
25
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
26
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
package/lib/server/index.js
CHANGED
|
@@ -1,36 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
Object.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
16
|
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var server_exports = {};
|
|
29
|
+
__export(server_exports, {
|
|
30
|
+
Evaluator: () => import_utils3.Evaluator,
|
|
31
|
+
appendArrayColumn: () => import_utils3.appendArrayColumn,
|
|
32
|
+
default: () => server_default,
|
|
33
|
+
evaluate: () => import_utils3.evaluate,
|
|
34
|
+
evaluators: () => evaluators
|
|
11
35
|
});
|
|
12
|
-
exports
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
36
|
+
module.exports = __toCommonJS(server_exports);
|
|
37
|
+
var import_utils = require("@nocobase/utils");
|
|
38
|
+
var import_utils2 = require("../utils");
|
|
39
|
+
var import_mathjs = __toESM(require("../utils/mathjs"));
|
|
40
|
+
var import_formulajs = __toESM(require("../utils/formulajs"));
|
|
41
|
+
var import_utils3 = require("../utils");
|
|
42
|
+
const evaluators = new import_utils.Registry();
|
|
43
|
+
evaluators.register("math.js", import_utils2.evaluate.bind(import_mathjs.default));
|
|
44
|
+
evaluators.register("formula.js", import_utils2.evaluate.bind(import_formulajs.default));
|
|
45
|
+
var server_default = evaluators;
|
|
46
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
47
|
+
0 && (module.exports = {
|
|
48
|
+
Evaluator,
|
|
49
|
+
appendArrayColumn,
|
|
50
|
+
evaluate,
|
|
51
|
+
evaluators
|
|
18
52
|
});
|
|
19
|
-
exports.evaluators = void 0;
|
|
20
|
-
function _utils() {
|
|
21
|
-
const data = require("@nocobase/utils");
|
|
22
|
-
_utils = function _utils() {
|
|
23
|
-
return data;
|
|
24
|
-
};
|
|
25
|
-
return data;
|
|
26
|
-
}
|
|
27
|
-
var _utils2 = require("../utils");
|
|
28
|
-
var _mathjs = _interopRequireDefault(require("../utils/mathjs"));
|
|
29
|
-
var _formulajs = _interopRequireDefault(require("../utils/formulajs"));
|
|
30
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
31
|
-
const evaluators = new (_utils().Registry)();
|
|
32
|
-
exports.evaluators = evaluators;
|
|
33
|
-
evaluators.register('math.js', _utils2.evaluate.bind(_mathjs.default));
|
|
34
|
-
evaluators.register('formula.js', _utils2.evaluate.bind(_formulajs.default));
|
|
35
|
-
var _default = evaluators;
|
|
36
|
-
exports.default = _default;
|
package/lib/utils/formulajs.js
CHANGED
|
@@ -1,28 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var formulajs_exports = {};
|
|
30
|
+
__export(formulajs_exports, {
|
|
31
|
+
default: () => formulajs_default
|
|
5
32
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
12
|
-
return data;
|
|
13
|
-
}
|
|
14
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
15
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
16
|
-
const fnNames = Object.keys(functions()).filter(key => key !== 'default');
|
|
17
|
-
const fns = fnNames.map(key => functions()[key]);
|
|
18
|
-
function _default(expression, scope = {}) {
|
|
33
|
+
module.exports = __toCommonJS(formulajs_exports);
|
|
34
|
+
var functions = __toESM(require("@formulajs/formulajs"));
|
|
35
|
+
const fnNames = Object.keys(functions).filter((key) => key !== "default");
|
|
36
|
+
const fns = fnNames.map((key) => functions[key]);
|
|
37
|
+
function formulajs_default(expression, scope = {}) {
|
|
19
38
|
const fn = new Function(...fnNames, ...Object.keys(scope), `return ${expression}`);
|
|
20
39
|
const result = fn(...fns, ...Object.values(scope));
|
|
21
|
-
if (typeof result ===
|
|
40
|
+
if (typeof result === "number") {
|
|
22
41
|
if (Number.isNaN(result) || !Number.isFinite(result)) {
|
|
23
42
|
return null;
|
|
24
43
|
}
|
|
25
|
-
return functions
|
|
44
|
+
return functions.ROUND(result, 9);
|
|
26
45
|
}
|
|
27
46
|
return result;
|
|
28
|
-
}
|
|
47
|
+
}
|
|
48
|
+
__name(formulajs_default, "default");
|
package/lib/utils/index.js
CHANGED
|
@@ -1,58 +1,70 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var utils_exports = {};
|
|
20
|
+
__export(utils_exports, {
|
|
21
|
+
appendArrayColumn: () => appendArrayColumn,
|
|
22
|
+
evaluate: () => evaluate
|
|
5
23
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
-
function _lodash() {
|
|
9
|
-
const data = require("lodash");
|
|
10
|
-
_lodash = function _lodash() {
|
|
11
|
-
return data;
|
|
12
|
-
};
|
|
13
|
-
return data;
|
|
14
|
-
}
|
|
24
|
+
module.exports = __toCommonJS(utils_exports);
|
|
25
|
+
var import_lodash = require("lodash");
|
|
15
26
|
function appendArrayColumn(scope, key) {
|
|
16
|
-
const paths = key.split(
|
|
27
|
+
const paths = key.split(".");
|
|
17
28
|
let data = scope;
|
|
18
29
|
for (let p = 0; p < paths.length && data != null; p++) {
|
|
19
|
-
var _data;
|
|
20
30
|
const path = paths[p];
|
|
21
31
|
const isIndex = path.match(/^\d+$/);
|
|
22
32
|
if (Array.isArray(data) && !isIndex && !data[path]) {
|
|
23
|
-
data[path] = data.map(item => item[path]);
|
|
33
|
+
data[path] = data.map((item) => item[path]);
|
|
24
34
|
}
|
|
25
|
-
data =
|
|
35
|
+
data = data == null ? void 0 : data[path];
|
|
26
36
|
}
|
|
27
37
|
}
|
|
38
|
+
__name(appendArrayColumn, "appendArrayColumn");
|
|
28
39
|
function replaceNumberIndex(path, scope) {
|
|
29
|
-
const segments = path.split(
|
|
40
|
+
const segments = path.split(".");
|
|
30
41
|
const paths = [];
|
|
31
42
|
for (let i = 0; i < segments.length; i++) {
|
|
32
43
|
const p = segments[i];
|
|
33
|
-
if (p[0] &&
|
|
34
|
-
paths.push(Array.isArray((0,
|
|
44
|
+
if (p[0] && "0123456789".indexOf(p[0]) > -1) {
|
|
45
|
+
paths.push(Array.isArray((0, import_lodash.get)(scope, segments.slice(0, i))) ? `[${p}]` : `["${p}"]`);
|
|
35
46
|
} else {
|
|
36
47
|
if (i) {
|
|
37
|
-
paths.push(
|
|
48
|
+
paths.push(".", p);
|
|
38
49
|
} else {
|
|
39
50
|
paths.push(p);
|
|
40
51
|
}
|
|
41
52
|
}
|
|
42
53
|
}
|
|
43
|
-
return paths.join(
|
|
54
|
+
return paths.join("");
|
|
44
55
|
}
|
|
56
|
+
__name(replaceNumberIndex, "replaceNumberIndex");
|
|
45
57
|
function evaluate(expression, scope = {}) {
|
|
46
|
-
const context = (0,
|
|
58
|
+
const context = (0, import_lodash.cloneDeep)(scope);
|
|
47
59
|
const exp = expression.trim().replace(/{{\s*([^{}]+)\s*}}/g, (_, v) => {
|
|
48
60
|
appendArrayColumn(context, v);
|
|
49
|
-
const item = (0,
|
|
61
|
+
const item = (0, import_lodash.get)(context, v);
|
|
50
62
|
let result;
|
|
51
63
|
if (item == null) {
|
|
52
|
-
result =
|
|
53
|
-
} else if (typeof item ===
|
|
64
|
+
result = "null";
|
|
65
|
+
} else if (typeof item === "function") {
|
|
54
66
|
result = item();
|
|
55
|
-
result = typeof result ===
|
|
67
|
+
result = typeof result === "string" ? `'${result.replace(/'/g, "\\'")}'` : result;
|
|
56
68
|
} else {
|
|
57
69
|
result = replaceNumberIndex(v, context);
|
|
58
70
|
}
|
|
@@ -62,4 +74,10 @@ function evaluate(expression, scope = {}) {
|
|
|
62
74
|
return ` ${result} `;
|
|
63
75
|
});
|
|
64
76
|
return this(exp, context);
|
|
65
|
-
}
|
|
77
|
+
}
|
|
78
|
+
__name(evaluate, "evaluate");
|
|
79
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
80
|
+
0 && (module.exports = {
|
|
81
|
+
appendArrayColumn,
|
|
82
|
+
evaluate
|
|
83
|
+
});
|
package/lib/utils/mathjs.js
CHANGED
|
@@ -1,25 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var mathjs_exports = {};
|
|
30
|
+
__export(mathjs_exports, {
|
|
31
|
+
default: () => mathjs_default
|
|
5
32
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
12
|
-
return data;
|
|
13
|
-
}
|
|
14
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
15
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
16
|
-
function _default(expression, scope = {}) {
|
|
17
|
-
const result = math().evaluate(expression, scope);
|
|
18
|
-
if (typeof result === 'number') {
|
|
33
|
+
module.exports = __toCommonJS(mathjs_exports);
|
|
34
|
+
var math = __toESM(require("mathjs"));
|
|
35
|
+
function mathjs_default(expression, scope = {}) {
|
|
36
|
+
const result = math.evaluate(expression, scope);
|
|
37
|
+
if (typeof result === "number") {
|
|
19
38
|
if (Number.isNaN(result) || !Number.isFinite(result)) {
|
|
20
39
|
return null;
|
|
21
40
|
}
|
|
22
|
-
return math
|
|
41
|
+
return math.round(result, 9);
|
|
23
42
|
}
|
|
24
43
|
return result;
|
|
25
|
-
}
|
|
44
|
+
}
|
|
45
|
+
__name(mathjs_default, "default");
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/evaluators",
|
|
3
|
-
"version": "0.13.0-alpha.
|
|
3
|
+
"version": "0.13.0-alpha.5",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
7
7
|
"license": "Apache-2.0",
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@formulajs/formulajs": "4.2.0",
|
|
10
|
-
"@nocobase/utils": "0.13.0-alpha.
|
|
10
|
+
"@nocobase/utils": "0.13.0-alpha.5",
|
|
11
11
|
"mathjs": "^10.6.0"
|
|
12
12
|
},
|
|
13
13
|
"repository": {
|
|
@@ -15,5 +15,5 @@
|
|
|
15
15
|
"url": "git+https://github.com/nocobase/nocobase.git",
|
|
16
16
|
"directory": "packages/evaluators"
|
|
17
17
|
},
|
|
18
|
-
"gitHead": "
|
|
18
|
+
"gitHead": "9eabe607b4a20c356fdb2fd95e40fa476986dcb0"
|
|
19
19
|
}
|