@pegasimed.com/shared-tools 1.0.1 → 1.0.2
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.
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { IPipelinesMap } from './executeVariablesCondition';
|
|
2
|
-
export declare const executeFormula: (formula: string, data: any, customPipelines?: IPipelinesMap) => any
|
|
2
|
+
export declare const executeFormula: (formula: string, data: any, customPipelines?: IPipelinesMap) => Promise<any>;
|
|
@@ -1,19 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
exports.executeFormula = void 0;
|
|
4
13
|
const type_check_1 = require("type-check");
|
|
5
14
|
const replaceAllVariables_1 = require("./replaceAllVariables");
|
|
6
|
-
const executeFormula = (formula, data, customPipelines) => {
|
|
15
|
+
const executeFormula = (formula, data, customPipelines) => __awaiter(void 0, void 0, void 0, function* () {
|
|
7
16
|
if (!(0, type_check_1.typeCheck)('String', formula) || !formula) {
|
|
8
17
|
throw new Error('execute formula: formula is not a string or is empty');
|
|
9
18
|
}
|
|
10
|
-
const variables = (0, replaceAllVariables_1.replaceAllVariables)(formula, data, 'formula', customPipelines);
|
|
19
|
+
const variables = yield (0, replaceAllVariables_1.replaceAllVariables)(formula, data, 'formula', customPipelines);
|
|
11
20
|
try {
|
|
12
21
|
return Function(`return ${variables}`)();
|
|
13
22
|
}
|
|
14
23
|
catch (error) {
|
|
15
24
|
throw error;
|
|
16
25
|
}
|
|
17
|
-
};
|
|
26
|
+
});
|
|
18
27
|
exports.executeFormula = executeFormula;
|
|
19
28
|
//# sourceMappingURL=executeFormula.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executeFormula.js","sourceRoot":"","sources":["../../src/custom-variable-resolvers/executeFormula.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"executeFormula.js","sourceRoot":"","sources":["../../src/custom-variable-resolvers/executeFormula.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAuC;AAEvC,+DAA4D;AAErD,MAAM,cAAc,GAAG,CAAO,OAAe,EAAE,IAAS,EAAE,eAA+B,EAAgB,EAAE;IAChH,IAAI,CAAC,IAAA,sBAAS,EAAC,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;QAC9C,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;IAC1E,CAAC;IAED,MAAM,SAAS,GAAG,MAAM,IAAA,yCAAmB,EAAC,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,eAAe,CAAC,CAAC;IAEvF,IAAI,CAAC;QACH,OAAO,QAAQ,CAAC,UAAU,SAAS,EAAE,CAAC,EAAE,CAAC;IAC3C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC,CAAA,CAAC;AAZW,QAAA,cAAc,kBAYzB"}
|