@pegasimed.com/shared-tools 1.0.0
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 +1 -0
- package/dist/constants/index.d.ts +1 -0
- package/dist/constants/index.js +18 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/constants/patterns.d.ts +2 -0
- package/dist/constants/patterns.js +6 -0
- package/dist/constants/patterns.js.map +1 -0
- package/dist/custom-variable-resolvers/executeCondition.d.ts +1 -0
- package/dist/custom-variable-resolvers/executeCondition.js +36 -0
- package/dist/custom-variable-resolvers/executeCondition.js.map +1 -0
- package/dist/custom-variable-resolvers/executeFormula.d.ts +2 -0
- package/dist/custom-variable-resolvers/executeFormula.js +19 -0
- package/dist/custom-variable-resolvers/executeFormula.js.map +1 -0
- package/dist/custom-variable-resolvers/executeVariablesCondition.d.ts +4 -0
- package/dist/custom-variable-resolvers/executeVariablesCondition.js +46 -0
- package/dist/custom-variable-resolvers/executeVariablesCondition.js.map +1 -0
- package/dist/custom-variable-resolvers/findAllCustomVariables.d.ts +2 -0
- package/dist/custom-variable-resolvers/findAllCustomVariables.js +24 -0
- package/dist/custom-variable-resolvers/findAllCustomVariables.js.map +1 -0
- package/dist/custom-variable-resolvers/findDataObject.d.ts +1 -0
- package/dist/custom-variable-resolvers/findDataObject.js +16 -0
- package/dist/custom-variable-resolvers/findDataObject.js.map +1 -0
- package/dist/custom-variable-resolvers/getAllJsonKeyAndValues.d.ts +1 -0
- package/dist/custom-variable-resolvers/getAllJsonKeyAndValues.js +49 -0
- package/dist/custom-variable-resolvers/getAllJsonKeyAndValues.js.map +1 -0
- package/dist/custom-variable-resolvers/index.d.ts +7 -0
- package/dist/custom-variable-resolvers/index.js +24 -0
- package/dist/custom-variable-resolvers/index.js.map +1 -0
- package/dist/custom-variable-resolvers/pipelines/arrayFilter.d.ts +1 -0
- package/dist/custom-variable-resolvers/pipelines/arrayFilter.js +28 -0
- package/dist/custom-variable-resolvers/pipelines/arrayFilter.js.map +1 -0
- package/dist/custom-variable-resolvers/pipelines/arrayJoin.d.ts +1 -0
- package/dist/custom-variable-resolvers/pipelines/arrayJoin.js +12 -0
- package/dist/custom-variable-resolvers/pipelines/arrayJoin.js.map +1 -0
- package/dist/custom-variable-resolvers/pipelines/arrayMap.d.ts +1 -0
- package/dist/custom-variable-resolvers/pipelines/arrayMap.js +23 -0
- package/dist/custom-variable-resolvers/pipelines/arrayMap.js.map +1 -0
- package/dist/custom-variable-resolvers/pipelines/documentSelect.d.ts +1 -0
- package/dist/custom-variable-resolvers/pipelines/documentSelect.js +7 -0
- package/dist/custom-variable-resolvers/pipelines/documentSelect.js.map +1 -0
- package/dist/custom-variable-resolvers/pipelines/index.d.ts +9 -0
- package/dist/custom-variable-resolvers/pipelines/index.js +26 -0
- package/dist/custom-variable-resolvers/pipelines/index.js.map +1 -0
- package/dist/custom-variable-resolvers/pipelines/toBoolean.d.ts +1 -0
- package/dist/custom-variable-resolvers/pipelines/toBoolean.js +6 -0
- package/dist/custom-variable-resolvers/pipelines/toBoolean.js.map +1 -0
- package/dist/custom-variable-resolvers/pipelines/toLowerCase.d.ts +1 -0
- package/dist/custom-variable-resolvers/pipelines/toLowerCase.js +6 -0
- package/dist/custom-variable-resolvers/pipelines/toLowerCase.js.map +1 -0
- package/dist/custom-variable-resolvers/pipelines/toNumber.d.ts +1 -0
- package/dist/custom-variable-resolvers/pipelines/toNumber.js +6 -0
- package/dist/custom-variable-resolvers/pipelines/toNumber.js.map +1 -0
- package/dist/custom-variable-resolvers/pipelines/toString.d.ts +1 -0
- package/dist/custom-variable-resolvers/pipelines/toString.js +6 -0
- package/dist/custom-variable-resolvers/pipelines/toString.js.map +1 -0
- package/dist/custom-variable-resolvers/pipelines/toUpperCase.d.ts +1 -0
- package/dist/custom-variable-resolvers/pipelines/toUpperCase.js +6 -0
- package/dist/custom-variable-resolvers/pipelines/toUpperCase.js.map +1 -0
- package/dist/custom-variable-resolvers/replaceAllVariables.d.ts +3 -0
- package/dist/custom-variable-resolvers/replaceAllVariables.js +23 -0
- package/dist/custom-variable-resolvers/replaceAllVariables.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/package.json +47 -0
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# shared-tools
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './patterns';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./patterns"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PATTERN_EDITOR_VARIABLES_STRUCTURE = exports.PATTERN_FORMULA_VARIABLES_STRUCTURE = void 0;
|
|
4
|
+
exports.PATTERN_FORMULA_VARIABLES_STRUCTURE = /\[[a-zA-Z0-9áéíóúÁÉÍÓÚüÜñÑ\-\., ]+( \| [a-zA-Z0-9]+(: [a-zA-Z0-9áéíóúÁÉÍÓÚüÜñÑ ,{}\+\-/*()&\.<=>\|\?'"_-]+)*)*\]/g;
|
|
5
|
+
exports.PATTERN_EDITOR_VARIABLES_STRUCTURE = /\[\[[a-zA-Z0-9áéíóúÁÉÍÓÚüÜñÑ\-\., ]+( \| [a-zA-Z0-9]+(: [a-zA-Z0-9áéíóúÁÉÍÓÚüÜñÑ ,{}\+\-/*()&\.<=>\|\?'"_-]+)*)*\]\]/g;
|
|
6
|
+
//# sourceMappingURL=patterns.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"patterns.js","sourceRoot":"","sources":["../../src/constants/patterns.ts"],"names":[],"mappings":";;;AAAa,QAAA,mCAAmC,GAC9C,mHAAmH,CAAC;AACzG,QAAA,kCAAkC,GAC7C,uHAAuH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const executeCondition: (data: any, condition: string, regExpVariables: RegExp) => any;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.executeCondition = void 0;
|
|
4
|
+
const type_check_1 = require("type-check");
|
|
5
|
+
const findDataObject_1 = require("./findDataObject");
|
|
6
|
+
const executeCondition = (data, condition, regExpVariables) => {
|
|
7
|
+
if (!(0, type_check_1.typeCheck)('String', condition) || !condition) {
|
|
8
|
+
throw new Error('execute condition: condition is not a string or is empty');
|
|
9
|
+
}
|
|
10
|
+
let newCondition = condition || '';
|
|
11
|
+
const regExp = new RegExp(regExpVariables);
|
|
12
|
+
const variables = condition.match(regExp) || [];
|
|
13
|
+
for (const variable of variables) {
|
|
14
|
+
const fieldPath = variable.replace('{{', '').replace('}}', '');
|
|
15
|
+
const splitFields = fieldPath.split('.');
|
|
16
|
+
try {
|
|
17
|
+
let value = (0, findDataObject_1.findDataObject)(splitFields, data, fieldPath);
|
|
18
|
+
if ((0, type_check_1.typeCheck)('String', value)) {
|
|
19
|
+
value = `'${value}'`;
|
|
20
|
+
}
|
|
21
|
+
newCondition = newCondition.replace(variable, value);
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
// not emit error
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
try {
|
|
28
|
+
const response = Function(`return ${newCondition}`)();
|
|
29
|
+
return response;
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
throw error;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
exports.executeCondition = executeCondition;
|
|
36
|
+
//# sourceMappingURL=executeCondition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executeCondition.js","sourceRoot":"","sources":["../../src/custom-variable-resolvers/executeCondition.ts"],"names":[],"mappings":";;;AAAA,2CAAuC;AACvC,qDAAkD;AAE3C,MAAM,gBAAgB,GAAG,CAAC,IAAS,EAAE,SAAiB,EAAE,eAAuB,EAAE,EAAE;IACxF,IAAI,CAAC,IAAA,sBAAS,EAAC,QAAQ,EAAE,SAAS,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;QAClD,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;IAC9E,CAAC;IACD,IAAI,YAAY,GAAG,SAAS,IAAI,EAAE,CAAC;IACnC,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,eAAe,CAAC,CAAC;IAC3C,MAAM,SAAS,GAAG,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IAChD,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QACjC,MAAM,SAAS,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAC/D,MAAM,WAAW,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACzC,IAAI,CAAC;YACH,IAAI,KAAK,GAAG,IAAA,+BAAc,EAAC,WAAW,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;YACzD,IAAI,IAAA,sBAAS,EAAC,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC;gBAC/B,KAAK,GAAG,IAAI,KAAK,GAAG,CAAC;YACvB,CAAC;YAED,YAAY,GAAG,YAAY,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QACvD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,iBAAiB;QACnB,CAAC;IACH,CAAC;IAED,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,QAAQ,CAAC,UAAU,YAAY,EAAE,CAAC,EAAE,CAAC;QACtD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC,CAAC;AA5BW,QAAA,gBAAgB,oBA4B3B"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.executeFormula = void 0;
|
|
4
|
+
const type_check_1 = require("type-check");
|
|
5
|
+
const replaceAllVariables_1 = require("./replaceAllVariables");
|
|
6
|
+
const executeFormula = (formula, data, customPipelines) => {
|
|
7
|
+
if (!(0, type_check_1.typeCheck)('String', formula) || !formula) {
|
|
8
|
+
throw new Error('execute formula: formula is not a string or is empty');
|
|
9
|
+
}
|
|
10
|
+
const variables = (0, replaceAllVariables_1.replaceAllVariables)(formula, data, 'formula', customPipelines);
|
|
11
|
+
try {
|
|
12
|
+
return Function(`return ${variables}`)();
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
throw error;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
exports.executeFormula = executeFormula;
|
|
19
|
+
//# sourceMappingURL=executeFormula.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executeFormula.js","sourceRoot":"","sources":["../../src/custom-variable-resolvers/executeFormula.ts"],"names":[],"mappings":";;;AAAA,2CAAuC;AAEvC,+DAA4D;AAErD,MAAM,cAAc,GAAG,CAAC,OAAe,EAAE,IAAS,EAAE,eAA+B,EAAO,EAAE;IACjG,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,IAAA,yCAAmB,EAAC,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,eAAe,CAAC,CAAC;IAEjF,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,CAAC;AAZW,QAAA,cAAc,kBAYzB"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.executeVariableEstructure = void 0;
|
|
4
|
+
const findDataObject_1 = require("./findDataObject");
|
|
5
|
+
const pipelines = require("./pipelines");
|
|
6
|
+
const executeVariableEstructure = (variable, data, customPipelines) => {
|
|
7
|
+
const splitVariable = variable
|
|
8
|
+
.replace(/[\[\]]+/gi, '')
|
|
9
|
+
.split('|')
|
|
10
|
+
.map((item) => item.trim());
|
|
11
|
+
if (!splitVariable.length) {
|
|
12
|
+
throw new Error(`Variable ${variable} is not valid. example: 'fieldPath | pipeline1: arg1,arg2 | pipeline2: arg1,arg2'`);
|
|
13
|
+
}
|
|
14
|
+
const fieldPath = splitVariable.shift() || '';
|
|
15
|
+
const validFieldPath = fieldPath.match(/^[a-zA-Z0-9_.]+$/);
|
|
16
|
+
if (!validFieldPath) {
|
|
17
|
+
throw new Error(`Field path ${fieldPath} is not valid. Example: 'fielOne.fieldTwo.0.fieldThree'`);
|
|
18
|
+
}
|
|
19
|
+
const pipelinesToExec = splitVariable === null || splitVariable === void 0 ? void 0 : splitVariable.map((pipelineString) => {
|
|
20
|
+
const pipelineSplit = (pipelineString === null || pipelineString === void 0 ? void 0 : pipelineString.split(':').map((item) => item.trim())) || [];
|
|
21
|
+
const args = pipelineSplit[1] || '';
|
|
22
|
+
const pipeline = pipelineSplit[0] || '';
|
|
23
|
+
return {
|
|
24
|
+
pipeline,
|
|
25
|
+
args: args.split(',').map((item) => item.trim()),
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
let currentValue = (0, findDataObject_1.findDataObject)(fieldPath.split('.'), data, fieldPath);
|
|
29
|
+
if (!pipelinesToExec.length) {
|
|
30
|
+
return currentValue;
|
|
31
|
+
}
|
|
32
|
+
for (const pipelineToExec of pipelinesToExec) {
|
|
33
|
+
const name = pipelineToExec.pipeline;
|
|
34
|
+
const args = pipelineToExec.args;
|
|
35
|
+
const allPipelines = Object.assign(Object.assign({}, pipelines), (customPipelines || {}));
|
|
36
|
+
const pipelinesFound = Object.keys(allPipelines).find((key) => key === name);
|
|
37
|
+
if (!pipelinesFound) {
|
|
38
|
+
throw new Error(`Pipeline ${name} not found`);
|
|
39
|
+
}
|
|
40
|
+
const pipeline = allPipelines[name];
|
|
41
|
+
currentValue = pipeline(currentValue, ...args);
|
|
42
|
+
}
|
|
43
|
+
return currentValue;
|
|
44
|
+
};
|
|
45
|
+
exports.executeVariableEstructure = executeVariableEstructure;
|
|
46
|
+
//# sourceMappingURL=executeVariablesCondition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executeVariablesCondition.js","sourceRoot":"","sources":["../../src/custom-variable-resolvers/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CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;SACzD,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,IAAI,YAAY,GAAG,IAAA,+BAAc,EAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;IACzE,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,CAAC;QAC5B,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,KAAK,MAAM,cAAc,IAAI,eAAe,EAAE,CAAC;QAC7C,MAAM,IAAI,GAAG,cAAc,CAAC,QAAQ,CAAC;QACrC,MAAM,IAAI,GAAG,cAAc,CAAC,IAAI,CAAC;QACjC,MAAM,YAAY,mCAAuB,SAAS,GAAK,CAAC,eAAe,IAAI,EAAE,CAAC,CAAE,CAAC;QACjF,MAAM,cAAc,GAAG,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,KAAK,IAAI,CAAC,CAAC;QAE7E,IAAI,CAAC,cAAc,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CAAC,YAAY,IAAI,YAAY,CAAC,CAAC;QAChD,CAAC;QAED,MAAM,QAAQ,GAAQ,YAAY,CAAC,IAAI,CAAC,CAAC;QACzC,YAAY,GAAG,QAAQ,CAAC,YAAY,EAAE,GAAG,IAAI,CAAC,CAAC;IACjD,CAAC;IAED,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AA/CW,QAAA,yBAAyB,6BA+CpC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findAllCustomVariables = void 0;
|
|
4
|
+
const type_check_1 = require("type-check");
|
|
5
|
+
const constants_1 = require("../constants");
|
|
6
|
+
const findAllCustomVariables = (text, variableType) => {
|
|
7
|
+
let regExp;
|
|
8
|
+
if (!(0, type_check_1.typeCheck)('String', text)) {
|
|
9
|
+
throw new Error('find all custom variables: text is not a string');
|
|
10
|
+
}
|
|
11
|
+
switch (variableType) {
|
|
12
|
+
case 'editor':
|
|
13
|
+
regExp = constants_1.PATTERN_EDITOR_VARIABLES_STRUCTURE;
|
|
14
|
+
break;
|
|
15
|
+
case 'formula':
|
|
16
|
+
regExp = constants_1.PATTERN_FORMULA_VARIABLES_STRUCTURE;
|
|
17
|
+
break;
|
|
18
|
+
default:
|
|
19
|
+
throw new Error(`find all custom variables: variable type not found or not supported ${variableType}`);
|
|
20
|
+
}
|
|
21
|
+
return text.match(regExp) || [];
|
|
22
|
+
};
|
|
23
|
+
exports.findAllCustomVariables = findAllCustomVariables;
|
|
24
|
+
//# sourceMappingURL=findAllCustomVariables.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"findAllCustomVariables.js","sourceRoot":"","sources":["../../src/custom-variable-resolvers/findAllCustomVariables.ts"],"names":[],"mappings":";;;AAAA,2CAAuC;AACvC,4CAAuG;AAIhG,MAAM,sBAAsB,GAAG,CAAC,IAAY,EAAE,YAAiC,EAAY,EAAE;IAClG,IAAI,MAAc,CAAC;IAEnB,IAAI,CAAC,IAAA,sBAAS,EAAC,QAAQ,EAAE,IAAI,CAAC,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;IACrE,CAAC;IAED,QAAQ,YAAY,EAAE,CAAC;QACrB,KAAK,QAAQ;YACX,MAAM,GAAG,8CAAkC,CAAC;YAC5C,MAAM;QACR,KAAK,SAAS;YACZ,MAAM,GAAG,+CAAmC,CAAC;YAC7C,MAAM;QACR;YACE,MAAM,IAAI,KAAK,CAAC,wEAAwE,YAAY,EAAE,CAAC,CAAC;IAC5G,CAAC;IAED,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;AAClC,CAAC,CAAC;AAnBW,QAAA,sBAAsB,0BAmBjC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const findDataObject: (splitFields: string[], data: any, fieldPath: string) => any;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findDataObject = void 0;
|
|
4
|
+
const findDataObject = (splitFields, data, fieldPath) => {
|
|
5
|
+
const currentField = splitFields.shift() || '';
|
|
6
|
+
const currentValue = currentField ? data[currentField] : undefined;
|
|
7
|
+
if (currentValue === undefined) {
|
|
8
|
+
throw new Error(`undefined value found in ${currentField} of ${fieldPath}`);
|
|
9
|
+
}
|
|
10
|
+
if (splitFields.length === 0) {
|
|
11
|
+
return currentValue;
|
|
12
|
+
}
|
|
13
|
+
return (0, exports.findDataObject)(splitFields, data[currentField], fieldPath);
|
|
14
|
+
};
|
|
15
|
+
exports.findDataObject = findDataObject;
|
|
16
|
+
//# sourceMappingURL=findDataObject.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"findDataObject.js","sourceRoot":"","sources":["../../src/custom-variable-resolvers/findDataObject.ts"],"names":[],"mappings":";;;AAAO,MAAM,cAAc,GAAG,CAAC,WAAqB,EAAE,IAAS,EAAE,SAAiB,EAAO,EAAE;IACzF,MAAM,YAAY,GAAG,WAAW,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC;IAC/C,MAAM,YAAY,GAAG,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACnE,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,4BAA4B,YAAY,OAAO,SAAS,EAAE,CAAC,CAAC;IAC9E,CAAC;IACD,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC7B,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,OAAO,IAAA,sBAAc,EAAC,WAAW,EAAE,IAAI,CAAC,YAAY,CAAC,EAAE,SAAS,CAAC,CAAC;AACpE,CAAC,CAAC;AAXW,QAAA,cAAc,kBAWzB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getAllJsonKeyAndValues: (data: any) => any[];
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAllJsonKeyAndValues = void 0;
|
|
4
|
+
const type_check_1 = require("type-check");
|
|
5
|
+
const findAllObjectKeyAndValue = (data, currentValues, currentValueKey) => {
|
|
6
|
+
let isError = true;
|
|
7
|
+
if ((0, type_check_1.typeCheck)('Number', data) || (0, type_check_1.typeCheck)('String', data) || (0, type_check_1.typeCheck)('Boolean', data) || (0, type_check_1.typeCheck)('Null', data)) {
|
|
8
|
+
isError = false;
|
|
9
|
+
return currentValues.map((currentValue) => currentValue.key === currentValueKey ? { key: currentValueKey, value: data } : Object.assign({}, currentValue));
|
|
10
|
+
}
|
|
11
|
+
if ((0, type_check_1.typeCheck)('Object', data)) {
|
|
12
|
+
isError = false;
|
|
13
|
+
const lowLevelKeys = Object.keys(data);
|
|
14
|
+
let newCurrentValues = currentValues.filter((currentValue) => currentValue.key !== currentValueKey);
|
|
15
|
+
for (const lowLevelKey of lowLevelKeys) {
|
|
16
|
+
newCurrentValues = findAllObjectKeyAndValue(data[lowLevelKey], [...(newCurrentValues || []), { key: `${currentValueKey}.${lowLevelKey}`, value: null }], `${currentValueKey}.${lowLevelKey}`);
|
|
17
|
+
}
|
|
18
|
+
return newCurrentValues;
|
|
19
|
+
}
|
|
20
|
+
if ((0, type_check_1.typeCheck)('Array', data)) {
|
|
21
|
+
isError = false;
|
|
22
|
+
if (!data.length) {
|
|
23
|
+
return currentValues.map((currentValue) => currentValue.key === currentValueKey ? { key: currentValueKey, value: '__EMPTY__' } : Object.assign({}, currentValue));
|
|
24
|
+
}
|
|
25
|
+
let index = 0;
|
|
26
|
+
let newCurrentValues = currentValues.filter((currentValue) => currentValue.key !== currentValueKey);
|
|
27
|
+
for (const arrayItem of data) {
|
|
28
|
+
newCurrentValues = findAllObjectKeyAndValue(arrayItem, [...(newCurrentValues || []), { key: `${currentValueKey}.${index}`, value: null }], `${currentValueKey}.${index}`);
|
|
29
|
+
++index;
|
|
30
|
+
}
|
|
31
|
+
return newCurrentValues;
|
|
32
|
+
}
|
|
33
|
+
if (isError) {
|
|
34
|
+
throw new Error(`Invalid data type ${typeof data} in ${currentValueKey}`);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
const getAllJsonKeyAndValues = (data) => {
|
|
38
|
+
let response = [];
|
|
39
|
+
if (!(0, type_check_1.typeCheck)('Object', data)) {
|
|
40
|
+
return response;
|
|
41
|
+
}
|
|
42
|
+
const keys = Object.keys(data);
|
|
43
|
+
for (const key of keys) {
|
|
44
|
+
response = findAllObjectKeyAndValue(data[key], [...(response || []), { key, value: null }], key);
|
|
45
|
+
}
|
|
46
|
+
return response || [];
|
|
47
|
+
};
|
|
48
|
+
exports.getAllJsonKeyAndValues = getAllJsonKeyAndValues;
|
|
49
|
+
//# sourceMappingURL=getAllJsonKeyAndValues.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getAllJsonKeyAndValues.js","sourceRoot":"","sources":["../../src/custom-variable-resolvers/getAllJsonKeyAndValues.ts"],"names":[],"mappings":";;;AAAA,2CAAuC;AAEvC,MAAM,wBAAwB,GAAG,CAAC,IAAS,EAAE,aAAoB,EAAE,eAAuB,EAAqB,EAAE;IAC/G,IAAI,OAAO,GAAG,IAAI,CAAC;IACnB,IAAI,IAAA,sBAAS,EAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,IAAA,sBAAS,EAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,IAAA,sBAAS,EAAC,SAAS,EAAE,IAAI,CAAC,IAAI,IAAA,sBAAS,EAAC,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC;QACpH,OAAO,GAAG,KAAK,CAAC;QAChB,OAA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}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './executeCondition';
|
|
2
|
+
export * from './executeFormula';
|
|
3
|
+
export * from './executeVariablesCondition';
|
|
4
|
+
export * from './findAllCustomVariables';
|
|
5
|
+
export * from './findDataObject';
|
|
6
|
+
export * from './getAllJsonKeyAndValues';
|
|
7
|
+
export * from './replaceAllVariables';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./executeCondition"), exports);
|
|
18
|
+
__exportStar(require("./executeFormula"), exports);
|
|
19
|
+
__exportStar(require("./executeVariablesCondition"), exports);
|
|
20
|
+
__exportStar(require("./findAllCustomVariables"), exports);
|
|
21
|
+
__exportStar(require("./findDataObject"), exports);
|
|
22
|
+
__exportStar(require("./getAllJsonKeyAndValues"), exports);
|
|
23
|
+
__exportStar(require("./replaceAllVariables"), exports);
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/custom-variable-resolvers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC;AACnC,mDAAiC;AACjC,8DAA4C;AAC5C,2DAAyC;AACzC,mDAAiC;AACjC,2DAAyC;AACzC,wDAAsC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const arrayFilter: (data: any, condition: string) => any;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.arrayFilter = void 0;
|
|
4
|
+
const type_check_1 = require("type-check");
|
|
5
|
+
const executeCondition_1 = require("../executeCondition");
|
|
6
|
+
const arrayFilter = (data, condition) => {
|
|
7
|
+
if (!(0, type_check_1.typeCheck)('Array', data)) {
|
|
8
|
+
throw new Error('pipeline arrayFilter: data is not an array');
|
|
9
|
+
}
|
|
10
|
+
const newArray = [];
|
|
11
|
+
if (!data.length) {
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
for (const item of data) {
|
|
15
|
+
try {
|
|
16
|
+
const response = (0, executeCondition_1.executeCondition)(item, condition, /\{\{[a-zA-Z0-9_\.]+\}\}/g);
|
|
17
|
+
if (response) {
|
|
18
|
+
newArray.push(item);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
throw error;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return newArray;
|
|
26
|
+
};
|
|
27
|
+
exports.arrayFilter = arrayFilter;
|
|
28
|
+
//# sourceMappingURL=arrayFilter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arrayFilter.js","sourceRoot":"","sources":["../../../src/custom-variable-resolvers/pipelines/arrayFilter.ts"],"names":[],"mappings":";;;AAAA,2CAAuC;AACvC,0DAAuD;AAEhD,MAAM,WAAW,GAAG,CAAC,IAAS,EAAE,SAAiB,EAAE,EAAE;IAC1D,IAAI,CAAC,IAAA,sBAAS,EAAC,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAChE,CAAC;IACD,MAAM,QAAQ,GAAG,EAAE,CAAC;IACpB,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;QACjB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;QACxB,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,IAAA,mCAAgB,EAAC,IAAI,EAAE,SAAS,EAAE,0BAA0B,CAAC,CAAC;YAC/E,IAAI,QAAQ,EAAE,CAAC;gBACb,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACtB,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AArBW,QAAA,WAAW,eAqBtB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const arrayJoin: (data: any, separator: string) => any;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.arrayJoin = void 0;
|
|
4
|
+
const type_check_1 = require("type-check");
|
|
5
|
+
const arrayJoin = (data, separator) => {
|
|
6
|
+
if (!(0, type_check_1.typeCheck)('Array', data)) {
|
|
7
|
+
throw new Error('pipeline arrayJoin: data is not an array');
|
|
8
|
+
}
|
|
9
|
+
return data.join(separator);
|
|
10
|
+
};
|
|
11
|
+
exports.arrayJoin = arrayJoin;
|
|
12
|
+
//# sourceMappingURL=arrayJoin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arrayJoin.js","sourceRoot":"","sources":["../../../src/custom-variable-resolvers/pipelines/arrayJoin.ts"],"names":[],"mappings":";;;AAAA,2CAAuC;AAEhC,MAAM,SAAS,GAAG,CAAC,IAAS,EAAE,SAAiB,EAAE,EAAE;IACxD,IAAI,CAAC,IAAA,sBAAS,EAAC,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAC9D,CAAC;IAED,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AAC9B,CAAC,CAAC;AANW,QAAA,SAAS,aAMpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const arrayMap: (data: any, fieldPath: string) => any;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.arrayMap = void 0;
|
|
4
|
+
const type_check_1 = require("type-check");
|
|
5
|
+
const findDataObject_1 = require("../findDataObject");
|
|
6
|
+
const arrayMap = (data, fieldPath) => {
|
|
7
|
+
if (!(0, type_check_1.typeCheck)('Array', data)) {
|
|
8
|
+
throw new Error('pipeline arrayMap: data is not an array');
|
|
9
|
+
}
|
|
10
|
+
if (!data.length) {
|
|
11
|
+
return data;
|
|
12
|
+
}
|
|
13
|
+
return data.map((item) => {
|
|
14
|
+
try {
|
|
15
|
+
return (0, findDataObject_1.findDataObject)(fieldPath.split('.'), item, fieldPath);
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
throw error;
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
exports.arrayMap = arrayMap;
|
|
23
|
+
//# sourceMappingURL=arrayMap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arrayMap.js","sourceRoot":"","sources":["../../../src/custom-variable-resolvers/pipelines/arrayMap.ts"],"names":[],"mappings":";;;AAAA,2CAAuC;AACvC,sDAAmD;AAE5C,MAAM,QAAQ,GAAG,CAAC,IAAS,EAAE,SAAiB,EAAE,EAAE;IACvD,IAAI,CAAC,IAAA,sBAAS,EAAC,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;IAC7D,CAAC;IAED,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;QACjB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,IAAS,EAAE,EAAE;QAC5B,IAAI,CAAC;YACH,OAAO,IAAA,+BAAc,EAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;QAC/D,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAhBW,QAAA,QAAQ,YAgBnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const documentSelect: (data: any, fieldPath: string) => any;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.documentSelect = void 0;
|
|
4
|
+
const findDataObject_1 = require("../findDataObject");
|
|
5
|
+
const documentSelect = (data, fieldPath) => (0, findDataObject_1.findDataObject)(fieldPath.split('.'), data, fieldPath);
|
|
6
|
+
exports.documentSelect = documentSelect;
|
|
7
|
+
//# sourceMappingURL=documentSelect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"documentSelect.js","sourceRoot":"","sources":["../../../src/custom-variable-resolvers/pipelines/documentSelect.ts"],"names":[],"mappings":";;;AAAA,sDAAmD;AAE5C,MAAM,cAAc,GAAG,CAAC,IAAS,EAAE,SAAiB,EAAO,EAAE,CAClE,IAAA,+BAAc,EAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;AAD3C,QAAA,cAAc,kBAC6B"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './arrayFilter';
|
|
2
|
+
export * from './arrayJoin';
|
|
3
|
+
export * from './arrayMap';
|
|
4
|
+
export * from './documentSelect';
|
|
5
|
+
export * from './toBoolean';
|
|
6
|
+
export * from './toLowerCase';
|
|
7
|
+
export * from './toNumber';
|
|
8
|
+
export * from './toString';
|
|
9
|
+
export * from './toUpperCase';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./arrayFilter"), exports);
|
|
18
|
+
__exportStar(require("./arrayJoin"), exports);
|
|
19
|
+
__exportStar(require("./arrayMap"), exports);
|
|
20
|
+
__exportStar(require("./documentSelect"), exports);
|
|
21
|
+
__exportStar(require("./toBoolean"), exports);
|
|
22
|
+
__exportStar(require("./toLowerCase"), exports);
|
|
23
|
+
__exportStar(require("./toNumber"), exports);
|
|
24
|
+
__exportStar(require("./toString"), exports);
|
|
25
|
+
__exportStar(require("./toUpperCase"), exports);
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/custom-variable-resolvers/pipelines/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,8CAA4B;AAC5B,6CAA2B;AAC3B,mDAAiC;AACjC,8CAA4B;AAC5B,gDAA8B;AAC9B,6CAA2B;AAC3B,6CAA2B;AAC3B,gDAA8B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const toBoolean: (value: any) => boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toBoolean.js","sourceRoot":"","sources":["../../../src/custom-variable-resolvers/pipelines/toBoolean.ts"],"names":[],"mappings":";;;AAAO,MAAM,SAAS,GAAG,CAAC,KAAU,EAAW,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAApD,QAAA,SAAS,aAA2C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const toLowerCase: (data: any) => string;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toLowerCase = void 0;
|
|
4
|
+
const toLowerCase = (data) => { var _a; return ((_a = data === null || data === void 0 ? void 0 : data.toString()) === null || _a === void 0 ? void 0 : _a.toLowerCase()) || ''; };
|
|
5
|
+
exports.toLowerCase = toLowerCase;
|
|
6
|
+
//# sourceMappingURL=toLowerCase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toLowerCase.js","sourceRoot":"","sources":["../../../src/custom-variable-resolvers/pipelines/toLowerCase.ts"],"names":[],"mappings":";;;AAAO,MAAM,WAAW,GAAG,CAAC,IAAS,EAAU,EAAE,WAAC,OAAA,CAAA,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,QAAQ,EAAE,0CAAE,WAAW,EAAE,KAAI,EAAE,CAAA,EAAA,CAAC;AAA3E,QAAA,WAAW,eAAgE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const toNumber: (value: any) => number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toNumber.js","sourceRoot":"","sources":["../../../src/custom-variable-resolvers/pipelines/toNumber.ts"],"names":[],"mappings":";;;AAAO,MAAM,QAAQ,GAAG,CAAC,KAAU,EAAU,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAAjD,QAAA,QAAQ,YAAyC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const toString: (value: any) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toString.js","sourceRoot":"","sources":["../../../src/custom-variable-resolvers/pipelines/toString.ts"],"names":[],"mappings":";;;AAAO,MAAM,QAAQ,GAAG,CAAC,KAAU,EAAU,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAAjD,QAAA,QAAQ,YAAyC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const toUpperCase: (data: any) => string;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toUpperCase = void 0;
|
|
4
|
+
const toUpperCase = (data) => { var _a; return ((_a = data === null || data === void 0 ? void 0 : data.toString()) === null || _a === void 0 ? void 0 : _a.toUpperCase()) || ''; };
|
|
5
|
+
exports.toUpperCase = toUpperCase;
|
|
6
|
+
//# sourceMappingURL=toUpperCase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toUpperCase.js","sourceRoot":"","sources":["../../../src/custom-variable-resolvers/pipelines/toUpperCase.ts"],"names":[],"mappings":";;;AAAO,MAAM,WAAW,GAAG,CAAC,IAAS,EAAU,EAAE,WAAC,OAAA,CAAA,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,QAAQ,EAAE,0CAAE,WAAW,EAAE,KAAI,EAAE,CAAA,EAAA,CAAC;AAA3E,QAAA,WAAW,eAAgE"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.replaceAllVariables = void 0;
|
|
4
|
+
const type_check_1 = require("type-check");
|
|
5
|
+
const findAllCustomVariables_1 = require("./findAllCustomVariables");
|
|
6
|
+
const executeVariablesCondition_1 = require("./executeVariablesCondition");
|
|
7
|
+
const replaceAllVariables = (text, data, type, customPipelines) => {
|
|
8
|
+
if (!(0, type_check_1.typeCheck)('String', text) || !text) {
|
|
9
|
+
throw new Error('replace all variables: text is not a string or is empty');
|
|
10
|
+
}
|
|
11
|
+
let newText = text || '';
|
|
12
|
+
const customVariables = (0, findAllCustomVariables_1.findAllCustomVariables)(text, type);
|
|
13
|
+
for (const variable of customVariables) {
|
|
14
|
+
let value = (0, executeVariablesCondition_1.executeVariableEstructure)(variable, data, customPipelines);
|
|
15
|
+
if ((0, type_check_1.typeCheck)('String', value)) {
|
|
16
|
+
value = `'${value}'`;
|
|
17
|
+
}
|
|
18
|
+
newText = newText.replace(variable, value);
|
|
19
|
+
}
|
|
20
|
+
return newText;
|
|
21
|
+
};
|
|
22
|
+
exports.replaceAllVariables = replaceAllVariables;
|
|
23
|
+
//# sourceMappingURL=replaceAllVariables.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replaceAllVariables.js","sourceRoot":"","sources":["../../src/custom-variable-resolvers/replaceAllVariables.ts"],"names":[],"mappings":";;;AAAA,2CAAuC;AACvC,qEAAuF;AACvF,2EAAuF;AAEhF,MAAM,mBAAmB,GAAG,CACjC,IAAY,EACZ,IAAS,EACT,IAAyB,EACzB,eAA+B,EACvB,EAAE;IACV,IAAI,CAAC,IAAA,sBAAS,EAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;IAC7E,CAAC;IAED,IAAI,OAAO,GAAW,IAAI,IAAI,EAAE,CAAC;IAEjC,MAAM,eAAe,GAAG,IAAA,+CAAsB,EAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAE3D,KAAK,MAAM,QAAQ,IAAI,eAAe,EAAE,CAAC;QACvC,IAAI,KAAK,GAAG,IAAA,qDAAyB,EAAC,QAAQ,EAAE,IAAI,EAAE,eAAe,CAAC,CAAC;QACvE,IAAI,IAAA,sBAAS,EAAC,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC;YAC/B,KAAK,GAAG,IAAI,KAAK,GAAG,CAAC;QACvB,CAAC;QACD,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAC7C,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAvBW,QAAA,mBAAmB,uBAuB9B"}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./constants"), exports);
|
|
18
|
+
__exportStar(require("./custom-variable-resolvers"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,8DAA4C"}
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pegasimed.com/shared-tools",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Pegasi shared tools",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist/**/*"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "rimraf dist/ && tsc",
|
|
12
|
+
"format": "prettier --write \"src/**/*.ts\" \"src/**/*.js\"",
|
|
13
|
+
"lint": "tslint -p tsconfig.json",
|
|
14
|
+
"lint:fix": "tslint --fix -p tsconfig.json",
|
|
15
|
+
"prepare": "npm run build",
|
|
16
|
+
"prepublishOnly": "npm run lint",
|
|
17
|
+
"preversion": "npm run lint",
|
|
18
|
+
"version": "npm run format && git add -A src",
|
|
19
|
+
"postversion": "git push && git push --tags",
|
|
20
|
+
"test:basic": "ts-node ./src/tests/basic.ts"
|
|
21
|
+
},
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "git+https://github.com/devops-pegasi/shared-tools.git"
|
|
25
|
+
},
|
|
26
|
+
"author": {
|
|
27
|
+
"name": "pegasimed.com"
|
|
28
|
+
},
|
|
29
|
+
"license": "ISC",
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://github.com/devops-pegasi/shared-tools/issues"
|
|
32
|
+
},
|
|
33
|
+
"homepage": "https://github.com/devops-pegasi/shared-tools#readme",
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"type-check": "^0.4.0"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@types/node": "^20.11.19",
|
|
39
|
+
"@types/type-check": "^0.3.30",
|
|
40
|
+
"prettier": "^3.2.5",
|
|
41
|
+
"rimraf": "^5.0.5",
|
|
42
|
+
"ts-node": "^10.9.2",
|
|
43
|
+
"tslint": "^5.20.1",
|
|
44
|
+
"tslint-config-prettier": "^1.18.0",
|
|
45
|
+
"typescript": "5.3.3"
|
|
46
|
+
}
|
|
47
|
+
}
|