@loadmill/executer 0.1.143 → 0.1.145
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/post-script/post-script-executor.js +6 -2
- package/dist/post-script/post-script-executor.js.map +1 -1
- package/dist/redact-data.js +1 -1
- package/dist/redact-data.js.map +1 -1
- package/dist/request-stats.d.ts +2 -1
- package/dist/request-stats.js +4 -4
- package/dist/request-stats.js.map +1 -1
- package/dist/sampler.js +2 -1
- package/dist/sampler.js.map +1 -1
- package/dist/sequence.js +9 -5
- package/dist/sequence.js.map +1 -1
- package/package.json +3 -3
- package/dist/post-script/ast-walker/index.d.ts +0 -18
- package/dist/post-script/ast-walker/index.js +0 -215
- package/dist/post-script/ast-walker/index.js.map +0 -1
- package/dist/post-script/ast-walker/type-guard.d.ts +0 -11
- package/dist/post-script/ast-walker/type-guard.js +0 -56
- package/dist/post-script/ast-walker/type-guard.js.map +0 -1
- package/dist/post-script/ast-walker/types.d.ts +0 -24
- package/dist/post-script/ast-walker/types.js +0 -25
- package/dist/post-script/ast-walker/types.js.map +0 -1
- package/dist/post-script/parser/acorn-js-parser.d.ts +0 -5
- package/dist/post-script/parser/acorn-js-parser.js +0 -20
- package/dist/post-script/parser/acorn-js-parser.js.map +0 -1
- package/dist/post-script/parser/js-parser.d.ts +0 -16
- package/dist/post-script/parser/js-parser.js +0 -3
- package/dist/post-script/parser/js-parser.js.map +0 -1
- package/dist/post-script/parser/parser.d.ts +0 -6
- package/dist/post-script/parser/parser.js +0 -3
- package/dist/post-script/parser/parser.js.map +0 -1
- package/package/dist/asserter.d.ts +0 -9
- package/package/dist/asserter.js +0 -158
- package/package/dist/asserter.js.map +0 -1
- package/package/dist/constants.d.ts +0 -7
- package/package/dist/constants.js +0 -13
- package/package/dist/constants.js.map +0 -1
- package/package/dist/cookies.d.ts +0 -4
- package/package/dist/cookies.js +0 -79
- package/package/dist/cookies.js.map +0 -1
- package/package/dist/errors.d.ts +0 -5
- package/package/dist/errors.js +0 -38
- package/package/dist/errors.js.map +0 -1
- package/package/dist/extraction-combiner.d.ts +0 -17
- package/package/dist/extraction-combiner.js +0 -182
- package/package/dist/extraction-combiner.js.map +0 -1
- package/package/dist/failures.d.ts +0 -24
- package/package/dist/failures.js +0 -67
- package/package/dist/failures.js.map +0 -1
- package/package/dist/grpc.d.ts +0 -34
- package/package/dist/grpc.js +0 -269
- package/package/dist/grpc.js.map +0 -1
- package/package/dist/iteration-stats.d.ts +0 -2
- package/package/dist/iteration-stats.js +0 -38
- package/package/dist/iteration-stats.js.map +0 -1
- package/package/dist/message-creators.d.ts +0 -31
- package/package/dist/message-creators.js +0 -90
- package/package/dist/message-creators.js.map +0 -1
- package/package/dist/mill-info.d.ts +0 -70
- package/package/dist/mill-info.js +0 -3
- package/package/dist/mill-info.js.map +0 -1
- package/package/dist/mill-version.d.ts +0 -6
- package/package/dist/mill-version.js +0 -10
- package/package/dist/mill-version.js.map +0 -1
- package/package/dist/parameter-pools.d.ts +0 -3
- package/package/dist/parameter-pools.js +0 -69
- package/package/dist/parameter-pools.js.map +0 -1
- package/package/dist/performance.d.ts +0 -1
- package/package/dist/performance.js +0 -10
- package/package/dist/performance.js.map +0 -1
- package/package/dist/post-script/ast-walker/index.d.ts +0 -18
- package/package/dist/post-script/ast-walker/index.js +0 -215
- package/package/dist/post-script/ast-walker/index.js.map +0 -1
- package/package/dist/post-script/ast-walker/type-guard.d.ts +0 -11
- package/package/dist/post-script/ast-walker/type-guard.js +0 -56
- package/package/dist/post-script/ast-walker/type-guard.js.map +0 -1
- package/package/dist/post-script/ast-walker/types.d.ts +0 -24
- package/package/dist/post-script/ast-walker/types.js +0 -25
- package/package/dist/post-script/ast-walker/types.js.map +0 -1
- package/package/dist/post-script/console-log.d.ts +0 -7
- package/package/dist/post-script/console-log.js +0 -31
- package/package/dist/post-script/console-log.js.map +0 -1
- package/package/dist/post-script/constants.d.ts +0 -4
- package/package/dist/post-script/constants.js +0 -9
- package/package/dist/post-script/constants.js.map +0 -1
- package/package/dist/post-script/parser/acorn-js-parser.d.ts +0 -5
- package/package/dist/post-script/parser/acorn-js-parser.js +0 -20
- package/package/dist/post-script/parser/acorn-js-parser.js.map +0 -1
- package/package/dist/post-script/parser/js-parser.d.ts +0 -16
- package/package/dist/post-script/parser/js-parser.js +0 -3
- package/package/dist/post-script/parser/js-parser.js.map +0 -1
- package/package/dist/post-script/parser/parser.d.ts +0 -6
- package/package/dist/post-script/parser/parser.js +0 -3
- package/package/dist/post-script/parser/parser.js.map +0 -1
- package/package/dist/post-script/post-script-executor.d.ts +0 -24
- package/package/dist/post-script/post-script-executor.js +0 -125
- package/package/dist/post-script/post-script-executor.js.map +0 -1
- package/package/dist/post-script/virtual-machine/virtual-machine.d.ts +0 -13
- package/package/dist/post-script/virtual-machine/virtual-machine.js +0 -3
- package/package/dist/post-script/virtual-machine/virtual-machine.js.map +0 -1
- package/package/dist/post-script/virtual-machine/vm2-virtual-machine.d.ts +0 -12
- package/package/dist/post-script/virtual-machine/vm2-virtual-machine.js +0 -81
- package/package/dist/post-script/virtual-machine/vm2-virtual-machine.js.map +0 -1
- package/package/dist/post-sequence.d.ts +0 -2
- package/package/dist/post-sequence.js +0 -192
- package/package/dist/post-sequence.js.map +0 -1
- package/package/dist/redact-data.d.ts +0 -2
- package/package/dist/redact-data.js +0 -60
- package/package/dist/redact-data.js.map +0 -1
- package/package/dist/report-types.d.ts +0 -102
- package/package/dist/report-types.js +0 -11
- package/package/dist/report-types.js.map +0 -1
- package/package/dist/request-sequence-result.d.ts +0 -37
- package/package/dist/request-sequence-result.js +0 -19
- package/package/dist/request-sequence-result.js.map +0 -1
- package/package/dist/request-stats.d.ts +0 -13
- package/package/dist/request-stats.js +0 -14
- package/package/dist/request-stats.js.map +0 -1
- package/package/dist/res-keeper.d.ts +0 -16
- package/package/dist/res-keeper.js +0 -104
- package/package/dist/res-keeper.js.map +0 -1
- package/package/dist/sampler.d.ts +0 -29
- package/package/dist/sampler.js +0 -276
- package/package/dist/sampler.js.map +0 -1
- package/package/dist/sequence-executor-like.d.ts +0 -23
- package/package/dist/sequence-executor-like.js +0 -3
- package/package/dist/sequence-executor-like.js.map +0 -1
- package/package/dist/sequence.d.ts +0 -16
- package/package/dist/sequence.js +0 -1738
- package/package/dist/sequence.js.map +0 -1
- package/package/dist/single-runner.d.ts +0 -29
- package/package/dist/single-runner.js +0 -147
- package/package/dist/single-runner.js.map +0 -1
- package/package/dist/step-handlers/code-step-handler.d.ts +0 -12
- package/package/dist/step-handlers/code-step-handler.js +0 -93
- package/package/dist/step-handlers/code-step-handler.js.map +0 -1
- package/package/dist/step-handlers/extract-step-handler.d.ts +0 -12
- package/package/dist/step-handlers/extract-step-handler.js +0 -101
- package/package/dist/step-handlers/extract-step-handler.js.map +0 -1
- package/package/dist/step-handlers/request-step-handler.d.ts +0 -13
- package/package/dist/step-handlers/request-step-handler.js +0 -94
- package/package/dist/step-handlers/request-step-handler.js.map +0 -1
- package/package/dist/step-handlers/step-handler.d.ts +0 -11
- package/package/dist/step-handlers/step-handler.js +0 -3
- package/package/dist/step-handlers/step-handler.js.map +0 -1
- package/package/dist/test-run-event-emitter.d.ts +0 -15
- package/package/dist/test-run-event-emitter.js +0 -36
- package/package/dist/test-run-event-emitter.js.map +0 -1
- package/package/dist/types/grpc.d.ts +0 -14
- package/package/dist/types/grpc.js +0 -3
- package/package/dist/types/grpc.js.map +0 -1
- package/package/dist/utils.d.ts +0 -3
- package/package/dist/utils.js +0 -32
- package/package/dist/utils.js.map +0 -1
- package/package/dist/work.d.ts +0 -15
- package/package/dist/work.js +0 -3
- package/package/dist/work.js.map +0 -1
- package/package/dist/ws.d.ts +0 -71
- package/package/dist/ws.js +0 -474
- package/package/dist/ws.js.map +0 -1
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { ArrayPattern as ESTArrayPattern, FunctionDeclaration as ESTFunctionDeclaration, Identifier, Pattern } from 'estree';
|
|
2
|
-
export interface ArrayPattern extends ESTArrayPattern {
|
|
3
|
-
elements: Array<Pattern>;
|
|
4
|
-
}
|
|
5
|
-
export interface FunctionDeclaration extends ESTFunctionDeclaration {
|
|
6
|
-
id: Identifier;
|
|
7
|
-
}
|
|
8
|
-
export declare enum Declarations {
|
|
9
|
-
FunctionDeclaration = "FunctionDeclaration",
|
|
10
|
-
VariableDeclaration = "VariableDeclaration"
|
|
11
|
-
}
|
|
12
|
-
export declare enum Expressions {
|
|
13
|
-
AssignmentExpression = "AssignmentExpression",
|
|
14
|
-
SequenceExpression = "SequenceExpression"
|
|
15
|
-
}
|
|
16
|
-
export declare enum Patterns {
|
|
17
|
-
ObjectPattern = "ObjectPattern",
|
|
18
|
-
ArrayPattern = "ArrayPattern",
|
|
19
|
-
RestElement = "RestElement",
|
|
20
|
-
Identifier = "Identifier"
|
|
21
|
-
}
|
|
22
|
-
export declare enum Statements {
|
|
23
|
-
ExpressionStatement = "ExpressionStatement"
|
|
24
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Statements = exports.Patterns = exports.Expressions = exports.Declarations = void 0;
|
|
4
|
-
var Declarations;
|
|
5
|
-
(function (Declarations) {
|
|
6
|
-
Declarations["FunctionDeclaration"] = "FunctionDeclaration";
|
|
7
|
-
Declarations["VariableDeclaration"] = "VariableDeclaration";
|
|
8
|
-
})(Declarations = exports.Declarations || (exports.Declarations = {}));
|
|
9
|
-
var Expressions;
|
|
10
|
-
(function (Expressions) {
|
|
11
|
-
Expressions["AssignmentExpression"] = "AssignmentExpression";
|
|
12
|
-
Expressions["SequenceExpression"] = "SequenceExpression";
|
|
13
|
-
})(Expressions = exports.Expressions || (exports.Expressions = {}));
|
|
14
|
-
var Patterns;
|
|
15
|
-
(function (Patterns) {
|
|
16
|
-
Patterns["ObjectPattern"] = "ObjectPattern";
|
|
17
|
-
Patterns["ArrayPattern"] = "ArrayPattern";
|
|
18
|
-
Patterns["RestElement"] = "RestElement";
|
|
19
|
-
Patterns["Identifier"] = "Identifier";
|
|
20
|
-
})(Patterns = exports.Patterns || (exports.Patterns = {}));
|
|
21
|
-
var Statements;
|
|
22
|
-
(function (Statements) {
|
|
23
|
-
Statements["ExpressionStatement"] = "ExpressionStatement";
|
|
24
|
-
})(Statements = exports.Statements || (exports.Statements = {}));
|
|
25
|
-
//# sourceMappingURL=types.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/post-script/ast-walker/types.ts"],"names":[],"mappings":";;;AAeA,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,2DAA2C,CAAA;IAC3C,2DAA2C,CAAA;AAC7C,CAAC,EAHW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAGvB;AAED,IAAY,WAGX;AAHD,WAAY,WAAW;IACrB,4DAA6C,CAAA;IAC7C,wDAAyC,CAAA;AAC3C,CAAC,EAHW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAGtB;AAED,IAAY,QAKX;AALD,WAAY,QAAQ;IAClB,2CAA+B,CAAA;IAC/B,yCAA6B,CAAA;IAC7B,uCAA2B,CAAA;IAC3B,qCAAyB,CAAA;AAC3B,CAAC,EALW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAKnB;AAED,IAAY,UAEX;AAFD,WAAY,UAAU;IACpB,yDAA2C,CAAA;AAC7C,CAAC,EAFW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAErB"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.myConsole = exports.CONSOLE_LOG_LIMIT = exports.LINE_LIMIT = void 0;
|
|
4
|
-
exports.LINE_LIMIT = 2500;
|
|
5
|
-
exports.CONSOLE_LOG_LIMIT = 100;
|
|
6
|
-
var isPassedTheLimit = function (line) { return line.length > exports.LINE_LIMIT; };
|
|
7
|
-
exports.myConsole = {
|
|
8
|
-
stdout: [],
|
|
9
|
-
log: function () {
|
|
10
|
-
var args = [];
|
|
11
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
12
|
-
args[_i] = arguments[_i];
|
|
13
|
-
}
|
|
14
|
-
if (exports.myConsole.stdout.length >= exports.CONSOLE_LOG_LIMIT) {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
var line = '';
|
|
18
|
-
for (var _a = 0, args_1 = args; _a < args_1.length; _a++) {
|
|
19
|
-
var item = args_1[_a];
|
|
20
|
-
line += typeof item === 'object' ? JSON.stringify(item, undefined, 2) : item;
|
|
21
|
-
if (isPassedTheLimit(line)) {
|
|
22
|
-
line = line.substring(0, exports.LINE_LIMIT) + '\n...';
|
|
23
|
-
break;
|
|
24
|
-
}
|
|
25
|
-
line += ' ';
|
|
26
|
-
}
|
|
27
|
-
!!line && exports.myConsole.stdout.push(line);
|
|
28
|
-
},
|
|
29
|
-
setStdout: function (newStdout) { return exports.myConsole.stdout = newStdout; },
|
|
30
|
-
};
|
|
31
|
-
//# sourceMappingURL=console-log.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"console-log.js","sourceRoot":"","sources":["../../src/post-script/console-log.ts"],"names":[],"mappings":";;;AAAa,QAAA,UAAU,GAAG,IAAI,CAAC;AAClB,QAAA,iBAAiB,GAAG,GAAG,CAAC;AAErC,IAAM,gBAAgB,GAAG,UAAC,IAAI,IAAK,OAAA,IAAI,CAAC,MAAM,GAAG,kBAAU,EAAxB,CAAwB,CAAC;AAE/C,QAAA,SAAS,GAAG;IACvB,MAAM,EAAE,EAAc;IACtB,GAAG,EAAE;QAAC,cAAO;aAAP,UAAO,EAAP,qBAAO,EAAP,IAAO;YAAP,yBAAO;;QACX,IAAI,iBAAS,CAAC,MAAM,CAAC,MAAM,IAAI,yBAAiB,EAAE;YAChD,OAAO;SACR;QACD,IAAI,IAAI,GAAG,EAAE,CAAC;QACd,KAAmB,UAAI,EAAJ,aAAI,EAAJ,kBAAI,EAAJ,IAAI,EAAE;YAApB,IAAM,IAAI,aAAA;YACb,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;YAC7E,IAAI,gBAAgB,CAAC,IAAI,CAAC,EAAE;gBAC1B,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,kBAAU,CAAC,GAAG,OAAO,CAAC;gBAC/C,MAAM;aACP;YACD,IAAI,IAAI,GAAG,CAAC;SACb;QACD,CAAC,CAAC,IAAI,IAAI,iBAAS,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;IACD,SAAS,EAAE,UAAC,SAAS,IAAK,OAAA,iBAAS,CAAC,MAAM,GAAG,SAAS,EAA5B,CAA4B;CACvD,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.POSTSCRIPT = void 0;
|
|
4
|
-
var POSTSCRIPT;
|
|
5
|
-
(function (POSTSCRIPT) {
|
|
6
|
-
POSTSCRIPT["STARTED"] = "postscript-started";
|
|
7
|
-
POSTSCRIPT["FINISHED"] = "postscript-finished";
|
|
8
|
-
})(POSTSCRIPT = exports.POSTSCRIPT || (exports.POSTSCRIPT = {}));
|
|
9
|
-
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/post-script/constants.ts"],"names":[],"mappings":";;;AAAA,IAAY,UAGX;AAHD,WAAY,UAAU;IAClB,4CAA8B,CAAA;IAC9B,8CAAgC,CAAA;AACpC,CAAC,EAHW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAGrB"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AcornJSParser = void 0;
|
|
4
|
-
var acorn_1 = require("acorn");
|
|
5
|
-
var AcornJSParser = /** @class */ (function () {
|
|
6
|
-
function AcornJSParser() {
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(AcornJSParser.prototype, "parse", {
|
|
9
|
-
enumerable: false,
|
|
10
|
-
configurable: true,
|
|
11
|
-
writable: true,
|
|
12
|
-
value: function (script, options) {
|
|
13
|
-
if (options === void 0) { options = { ecmaVersion: 2020 }; }
|
|
14
|
-
return acorn_1.parse(script, options);
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
return AcornJSParser;
|
|
18
|
-
}());
|
|
19
|
-
exports.AcornJSParser = AcornJSParser;
|
|
20
|
-
//# sourceMappingURL=acorn-js-parser.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"acorn-js-parser.js","sourceRoot":"","sources":["../../../src/post-script/parser/acorn-js-parser.ts"],"names":[],"mappings":";;;AAAA,+BAAuC;AAGvC;IAAA;IAIA,CAAC;;;;;eAHC,UAAM,MAAc,EAAE,OAAwC;YAAxC,wBAAA,EAAA,YAAqB,WAAW,EAAE,IAAI,EAAE;YAC5D,OAAO,aAAK,CAAC,MAAM,EAAE,OAAO,CAAW,CAAC;QAC1C,CAAC;;IACH,oBAAC;AAAD,CAAC,AAJD,IAIC;AAJY,sCAAa"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Node, Program } from 'estree';
|
|
2
|
-
import { Parser } from './parser';
|
|
3
|
-
interface JSParser extends Parser {
|
|
4
|
-
parse(script: string, options?: JSParserOptions): ESTree;
|
|
5
|
-
}
|
|
6
|
-
declare type ExtendNode<T> = {
|
|
7
|
-
[K in keyof T]: T[K] extends object ? ExtendNode<T[K]> : T[K];
|
|
8
|
-
} & (T extends Node ? {
|
|
9
|
-
start: number;
|
|
10
|
-
end: number;
|
|
11
|
-
} : {});
|
|
12
|
-
declare type ESTree = ExtendNode<Program>;
|
|
13
|
-
declare type JSParserOptions = {
|
|
14
|
-
ecmaVersion: number | string;
|
|
15
|
-
};
|
|
16
|
-
export { ESTree, JSParser, JSParserOptions, };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"js-parser.js","sourceRoot":"","sources":["../../../src/post-script/parser/js-parser.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../../../src/post-script/parser/parser.ts"],"names":[],"mappings":""}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { ParseJson } from '@loadmill/universal/dist/typescript-utils';
|
|
2
|
-
import { SequenceExecutorParameters } from '@loadmill/core/dist/parameters';
|
|
3
|
-
import { ParameterFunctionOperations } from '@loadmill/core/dist/parameters/parameter-functions/parameter-functions';
|
|
4
|
-
export declare class PostScriptRunner {
|
|
5
|
-
run: (outerStaticContext?: OuterStaticContext, dynamicContext?: SequenceExecutorParameters, userCode?: string, responseBody?: ParseJson) => {
|
|
6
|
-
result: SequenceExecutorParameters;
|
|
7
|
-
};
|
|
8
|
-
private wrapUserCode;
|
|
9
|
-
/**
|
|
10
|
-
* If the response JSON is an array, we need to unproxify it
|
|
11
|
-
* https://github.com/patriksimek/vm2/issues/437
|
|
12
|
-
*/
|
|
13
|
-
private unproxifyResponseBody;
|
|
14
|
-
validateCircularDependency: (obj: SequenceExecutorParameters) => void;
|
|
15
|
-
private removeAssertModule;
|
|
16
|
-
private unproxify;
|
|
17
|
-
}
|
|
18
|
-
declare type OuterStaticContext = {
|
|
19
|
-
staticContext: StaticContext;
|
|
20
|
-
};
|
|
21
|
-
declare type StaticContext = {
|
|
22
|
-
__: ParameterFunctionOperations;
|
|
23
|
-
};
|
|
24
|
-
export {};
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
14
|
-
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
|
15
|
-
to[j] = from[i];
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
19
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
20
|
-
};
|
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.PostScriptRunner = void 0;
|
|
23
|
-
var assert_1 = require("assert");
|
|
24
|
-
var cloneDeep_1 = __importDefault(require("lodash/cloneDeep"));
|
|
25
|
-
var ast_walker_1 = require("./ast-walker");
|
|
26
|
-
var vm2_virtual_machine_1 = require("./virtual-machine/vm2-virtual-machine");
|
|
27
|
-
var console_log_1 = require("./console-log");
|
|
28
|
-
var PostScriptRunner = /** @class */ (function () {
|
|
29
|
-
function PostScriptRunner() {
|
|
30
|
-
var _this = this;
|
|
31
|
-
Object.defineProperty(this, "run", {
|
|
32
|
-
enumerable: true,
|
|
33
|
-
configurable: true,
|
|
34
|
-
writable: true,
|
|
35
|
-
value: function (outerStaticContext, dynamicContext, userCode, responseBody) {
|
|
36
|
-
if (outerStaticContext === void 0) { outerStaticContext = { staticContext: { __: {} } }; }
|
|
37
|
-
if (dynamicContext === void 0) { dynamicContext = {}; }
|
|
38
|
-
if (userCode === void 0) { userCode = ''; }
|
|
39
|
-
if (responseBody === void 0) { responseBody = {}; }
|
|
40
|
-
var newVariables = new ast_walker_1.ASTWalker(userCode).detectDeclarations(Object.keys(outerStaticContext.staticContext));
|
|
41
|
-
var wrappedUserCode = _this.wrapUserCode(dynamicContext, userCode, newVariables);
|
|
42
|
-
var vm = new vm2_virtual_machine_1.VM2VirtualMachine();
|
|
43
|
-
vm.create({
|
|
44
|
-
globalObject: __assign(__assign({ assert: assert_1.strict }, dynamicContext), { console: cloneDeep_1.default(console_log_1.myConsole), $: responseBody }),
|
|
45
|
-
staticObject: outerStaticContext,
|
|
46
|
-
});
|
|
47
|
-
var modifiedDynamicContext = vm.run(wrappedUserCode);
|
|
48
|
-
_this.validateCircularDependency(modifiedDynamicContext);
|
|
49
|
-
_this.removeAssertModule(modifiedDynamicContext);
|
|
50
|
-
return { result: _this.unproxify(modifiedDynamicContext) };
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
Object.defineProperty(this, "wrapUserCode", {
|
|
54
|
-
enumerable: true,
|
|
55
|
-
configurable: true,
|
|
56
|
-
writable: true,
|
|
57
|
-
value: function (dynamicContext, userCode, newVariables) {
|
|
58
|
-
if (dynamicContext === void 0) { dynamicContext = {}; }
|
|
59
|
-
if (userCode === void 0) { userCode = ''; }
|
|
60
|
-
if (newVariables === void 0) { newVariables = []; }
|
|
61
|
-
var prefix = "\n Buffer = {};\n global = { assert: global.assert, console: global.console };\n $ = " + _this.unproxifyResponseBody() + ";\n ";
|
|
62
|
-
var suffix = "\n exports = {\n " + __spreadArray(__spreadArray([], Object.keys(dynamicContext)), newVariables).join() + "\n };\n ";
|
|
63
|
-
return prefix + userCode + suffix;
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
/**
|
|
67
|
-
* If the response JSON is an array, we need to unproxify it
|
|
68
|
-
* https://github.com/patriksimek/vm2/issues/437
|
|
69
|
-
*/
|
|
70
|
-
Object.defineProperty(this, "unproxifyResponseBody", {
|
|
71
|
-
enumerable: true,
|
|
72
|
-
configurable: true,
|
|
73
|
-
writable: true,
|
|
74
|
-
value: function () { return 'JSON.parse(JSON.stringify($))'; }
|
|
75
|
-
});
|
|
76
|
-
Object.defineProperty(this, "validateCircularDependency", {
|
|
77
|
-
enumerable: true,
|
|
78
|
-
configurable: true,
|
|
79
|
-
writable: true,
|
|
80
|
-
value: function (obj) {
|
|
81
|
-
function circularError(propName) {
|
|
82
|
-
return new TypeError("Cyclic object value. Circular reference in property " + propName);
|
|
83
|
-
}
|
|
84
|
-
findCircular(obj);
|
|
85
|
-
function findCircular(obj, _refs) {
|
|
86
|
-
if (_refs === void 0) { _refs = new WeakSet(); }
|
|
87
|
-
if (typeof obj === 'object' && obj !== null) {
|
|
88
|
-
_refs.add(obj);
|
|
89
|
-
for (var key in obj) {
|
|
90
|
-
if (_refs.has(obj[key])) {
|
|
91
|
-
throw circularError(key);
|
|
92
|
-
}
|
|
93
|
-
findCircular(obj[key], _refs);
|
|
94
|
-
}
|
|
95
|
-
_refs.delete(obj);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
Object.defineProperty(PostScriptRunner.prototype, "removeAssertModule", {
|
|
102
|
-
enumerable: false,
|
|
103
|
-
configurable: true,
|
|
104
|
-
writable: true,
|
|
105
|
-
value: function (context) {
|
|
106
|
-
Object.keys(context).forEach(function (key) {
|
|
107
|
-
var _a, _b;
|
|
108
|
-
if (((_b = (_a = context[key]) === null || _a === void 0 ? void 0 : _a.assert) === null || _b === void 0 ? void 0 : _b.name) === 'strict') {
|
|
109
|
-
context[key] = {};
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
Object.defineProperty(PostScriptRunner.prototype, "unproxify", {
|
|
115
|
-
enumerable: false,
|
|
116
|
-
configurable: true,
|
|
117
|
-
writable: true,
|
|
118
|
-
value: function (proxy) {
|
|
119
|
-
return cloneDeep_1.default(proxy);
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
return PostScriptRunner;
|
|
123
|
-
}());
|
|
124
|
-
exports.PostScriptRunner = PostScriptRunner;
|
|
125
|
-
//# sourceMappingURL=post-script-executor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"post-script-executor.js","sourceRoot":"","sources":["../../src/post-script/post-script-executor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,iCAA0C;AAC1C,+DAAyC;AAMzC,2CAAyC;AACzC,6EAA0E;AAC1E,6CAA0C;AAE1C;IAAA;QAAA,iBAqFC;QApFC;;;;mBAAa,UACX,kBAAsE,EACtE,cAA+C,EAC/C,QAAqB,EACrB,YAA4B;gBAH5B,mCAAA,EAAA,uBAA2C,aAAa,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE;gBACtE,+BAAA,EAAA,mBAA+C;gBAC/C,yBAAA,EAAA,aAAqB;gBACrB,6BAAA,EAAA,iBAA4B;gBAE5B,IAAM,YAAY,GAAG,IAAI,sBAAS,CAAC,QAAQ,CAAC,CAAC,kBAAkB,CAAC,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC,aAAa,CAAC,CAAC,CAAC;gBAC/G,IAAM,eAAe,GAAG,KAAI,CAAC,YAAY,CAAC,cAAc,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC;gBAElF,IAAM,EAAE,GAAG,IAAI,uCAAiB,EAAE,CAAC;gBACnC,EAAE,CAAC,MAAM,CAAC;oBACR,YAAY,sBAAI,MAAM,iBAAA,IAAK,cAAc,KAAE,OAAO,EAAE,mBAAS,CAAC,uBAAS,CAAC,EAAE,CAAC,EAAE,YAAY,GAAE;oBAC3F,YAAY,EAAE,kBAAkB;iBACjC,CAAC,CAAC;gBAEH,IAAM,sBAAsB,GAAG,EAAE,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;gBACvD,KAAI,CAAC,0BAA0B,CAAC,sBAAsB,CAAC,CAAC;gBACxD,KAAI,CAAC,kBAAkB,CAAC,sBAAsB,CAAC,CAAC;gBAChD,OAAO,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AC,CAAC;qBACnB;gBACH,CAAC;YACH,CAAC;WAAC;IAaJ,CAAC;;;;;eAXC,UAA2B,OAAmC;YAC5D,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,UAAA,GAAG;;gBAC9B,IAAI,CAAA,MAAA,MAAA,OAAO,CAAC,GAAG,CAAC,0CAAE,MAAM,0CAAE,IAAI,MAAK,QAAQ,EAAE;oBAC3C,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;iBACnB;YACH,CAAC,CAAC,CAAC;QACL,CAAC;;;;;;eAED,UAAkB,KAAwB;YACxC,OAAO,mBAAS,CAAC,KAAK,CAAC,CAAC;QAC1B,CAAC;;IACH,uBAAC;AAAD,CAAC,AArFD,IAqFC;AArFY,4CAAgB"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export interface VirtualMachine {
|
|
2
|
-
engine: Engine;
|
|
3
|
-
create(options: VirtualMachineOptions): Engine;
|
|
4
|
-
run(code: string): object;
|
|
5
|
-
}
|
|
6
|
-
export interface VirtualMachineOptions {
|
|
7
|
-
globalObject?: object;
|
|
8
|
-
staticObject?: object;
|
|
9
|
-
timeout?: number;
|
|
10
|
-
memoryLimit?: number;
|
|
11
|
-
async?: boolean;
|
|
12
|
-
}
|
|
13
|
-
export declare type Engine = any;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"virtual-machine.js","sourceRoot":"","sources":["../../../src/post-script/virtual-machine/virtual-machine.ts"],"names":[],"mappings":""}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { VM } from 'vm2';
|
|
2
|
-
import { SequenceExecutorParameters } from '../../../../core/dist/parameters';
|
|
3
|
-
import { Engine, VirtualMachine, VirtualMachineOptions } from './virtual-machine';
|
|
4
|
-
export declare class VM2VirtualMachine implements VirtualMachine {
|
|
5
|
-
engine: VM;
|
|
6
|
-
private DEFAULT_TIMOUT_MS;
|
|
7
|
-
create(options: VirtualMachineOptions): Engine;
|
|
8
|
-
makeStatic(obj?: object): void;
|
|
9
|
-
deepFreeze: (obj: object) => any;
|
|
10
|
-
setGlobals: (globalObject?: SequenceExecutorParameters) => void;
|
|
11
|
-
run(code: string): SequenceExecutorParameters;
|
|
12
|
-
}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.VM2VirtualMachine = void 0;
|
|
4
|
-
var vm2_1 = require("vm2");
|
|
5
|
-
var VM2VirtualMachine = /** @class */ (function () {
|
|
6
|
-
function VM2VirtualMachine() {
|
|
7
|
-
var _this = this;
|
|
8
|
-
Object.defineProperty(this, "engine", {
|
|
9
|
-
enumerable: true,
|
|
10
|
-
configurable: true,
|
|
11
|
-
writable: true,
|
|
12
|
-
value: void 0
|
|
13
|
-
});
|
|
14
|
-
Object.defineProperty(this, "DEFAULT_TIMOUT_MS", {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
configurable: true,
|
|
17
|
-
writable: true,
|
|
18
|
-
value: Number(process.env.POSTSCRIPT_TIMEOUT_MS) || 2000
|
|
19
|
-
});
|
|
20
|
-
Object.defineProperty(this, "deepFreeze", {
|
|
21
|
-
enumerable: true,
|
|
22
|
-
configurable: true,
|
|
23
|
-
writable: true,
|
|
24
|
-
value: function (obj) {
|
|
25
|
-
for (var _i = 0, _a = Object.keys(obj); _i < _a.length; _i++) {
|
|
26
|
-
var key = _a[_i];
|
|
27
|
-
if (typeof obj[key] === 'object' && obj[key] !== null) {
|
|
28
|
-
_this.engine.freeze(obj[key], key); // freeze me
|
|
29
|
-
_this.deepFreeze(obj[key]); // freeze my childrens
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
return _this.engine.freeze(obj); // freeze root
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
Object.defineProperty(this, "setGlobals", {
|
|
36
|
-
enumerable: true,
|
|
37
|
-
configurable: true,
|
|
38
|
-
writable: true,
|
|
39
|
-
value: function (globalObject) {
|
|
40
|
-
if (globalObject === void 0) { globalObject = {}; }
|
|
41
|
-
_this.engine.setGlobals(globalObject);
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
Object.defineProperty(VM2VirtualMachine.prototype, "create", {
|
|
46
|
-
enumerable: false,
|
|
47
|
-
configurable: true,
|
|
48
|
-
writable: true,
|
|
49
|
-
value: function (options) {
|
|
50
|
-
var timeout = options.timeout, globalObject = options.globalObject, async = options.async, staticObject = options.staticObject;
|
|
51
|
-
this.engine = new vm2_1.VM({
|
|
52
|
-
timeout: timeout || this.DEFAULT_TIMOUT_MS,
|
|
53
|
-
fixAsync: !async,
|
|
54
|
-
eval: false,
|
|
55
|
-
wasm: false,
|
|
56
|
-
});
|
|
57
|
-
this.makeStatic(staticObject);
|
|
58
|
-
this.setGlobals(globalObject);
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
Object.defineProperty(VM2VirtualMachine.prototype, "makeStatic", {
|
|
62
|
-
enumerable: false,
|
|
63
|
-
configurable: true,
|
|
64
|
-
writable: true,
|
|
65
|
-
value: function (obj) {
|
|
66
|
-
if (obj === void 0) { obj = {}; }
|
|
67
|
-
this.deepFreeze(obj);
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
Object.defineProperty(VM2VirtualMachine.prototype, "run", {
|
|
71
|
-
enumerable: false,
|
|
72
|
-
configurable: true,
|
|
73
|
-
writable: true,
|
|
74
|
-
value: function (code) {
|
|
75
|
-
return this.engine.run(code);
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
return VM2VirtualMachine;
|
|
79
|
-
}());
|
|
80
|
-
exports.VM2VirtualMachine = VM2VirtualMachine;
|
|
81
|
-
//# sourceMappingURL=vm2-virtual-machine.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vm2-virtual-machine.js","sourceRoot":"","sources":["../../../src/post-script/virtual-machine/vm2-virtual-machine.ts"],"names":[],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