@loadmill/core 0.3.50 → 0.3.53
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/conf/extrema.d.ts +1 -1
- package/dist/conf/extrema.js +2 -2
- package/dist/conf/extrema.js.map +1 -1
- package/dist/conf/types.d.ts +12 -0
- package/dist/conf/validate.d.ts +2 -1
- package/dist/conf/validate.js +6 -1
- package/dist/conf/validate.js.map +1 -1
- package/dist/multipart-form-data/form-data-utils.js +2 -2
- package/dist/multipart-form-data/form-data-utils.js.map +1 -1
- package/dist/multipart-form-data/is-binary-file.d.ts +2 -0
- package/dist/multipart-form-data/is-binary-file.js +215 -0
- package/dist/multipart-form-data/is-binary-file.js.map +1 -0
- package/dist/multipart-form-data/multipart-text-to-post-form-data.d.ts +5 -1
- package/dist/multipart-form-data/multipart-text-to-post-form-data.js +96 -35
- package/dist/multipart-form-data/multipart-text-to-post-form-data.js.map +1 -1
- package/dist/parameters/extractions.d.ts +2 -1
- package/dist/parameters/extractions.js.map +1 -1
- package/dist/parameters/index.d.ts +1 -1
- package/dist/parameters/index.js +4 -0
- package/dist/parameters/index.js.map +1 -1
- package/dist/request/index.d.ts +1 -0
- package/dist/request/index.js.map +1 -1
- package/package.json +7 -2
- package/src/conf/defaults.ts +0 -25
- package/src/conf/extrema.ts +0 -35
- package/src/conf/index.ts +0 -95
- package/src/conf/notifications.ts +0 -17
- package/src/conf/types.ts +0 -86
- package/src/conf/validate.ts +0 -548
- package/src/distributed-logger-reporter.ts +0 -19
- package/src/echo/firehose.ts +0 -64
- package/src/echo/index.ts +0 -4
- package/src/echo/stats.ts +0 -84
- package/src/har/index.ts +0 -81
- package/src/multipart-form-data/form-data-utils.ts +0 -81
- package/src/multipart-form-data/multipart-text-to-post-form-data.ts +0 -89
- package/src/parameters/extractions.ts +0 -51
- package/src/parameters/extractors/cheerio-extractor.ts +0 -57
- package/src/parameters/extractors/expression-extractor.ts +0 -13
- package/src/parameters/extractors/extractor.ts +0 -3
- package/src/parameters/extractors/header-extractor.ts +0 -24
- package/src/parameters/extractors/index.ts +0 -10
- package/src/parameters/extractors/json-path-extractor.ts +0 -63
- package/src/parameters/extractors/parametrized-extractor.ts +0 -27
- package/src/parameters/extractors/regex-extractor.ts +0 -18
- package/src/parameters/extractors/regex-matcher.ts +0 -17
- package/src/parameters/extractors/ws-extractor.ts +0 -91
- package/src/parameters/generate-random.ts +0 -114
- package/src/parameters/index.ts +0 -621
- package/src/parameters/json-path-utils.ts +0 -20
- package/src/parameters/operators/binary-operator.ts +0 -23
- package/src/parameters/operators/index.ts +0 -39
- package/src/parameters/parameter-functions/boolean-parameter-functions.ts +0 -24
- package/src/parameters/parameter-functions/crypto.ts +0 -55
- package/src/parameters/parameter-functions/json-schema.ts +0 -29
- package/src/parameters/parameter-functions/numeric-input-parameter-functions.ts +0 -22
- package/src/parameters/parameter-functions/numeric-parameter-functions.ts +0 -37
- package/src/parameters/parameter-functions/parameter-function-utils.ts +0 -55
- package/src/parameters/parameter-functions/parameter-function.ts +0 -7
- package/src/parameters/parameter-functions/parameter-functions.ts +0 -54
- package/src/parameters/parameter-functions/random-parameter-functions.ts +0 -22
- package/src/parameters/parameter-functions/textual-parameter-functions.ts +0 -464
- package/src/parameters/parameter-regex-providers.ts +0 -78
- package/src/parameters/resolvers/random-parameters-resolver.ts +0 -8
- package/src/parameters/type.ts +0 -7
- package/src/parameters/value-utils.ts +0 -47
- package/src/request/index.ts +0 -525
- package/src/schema/json-schema-generator.ts +0 -76
- package/test/conf/validate.spec.js +0 -141
- package/test/har/is-har.spec.js +0 -33
- package/test/multipart-form-data/form-data-utils.spec.ts +0 -121
- package/test/multipart-form-data/resources/multipart-form-data-file-text-content.json +0 -5
- package/test/parameters/builtin-functions.spec.js +0 -85
- package/test/parameters/json-path-utils.spec.ts +0 -50
- package/test/parameters/parameter-functions.spec.js +0 -48
- package/test/parameters/parameter-utils.spec.js +0 -185
- package/test/parameters/regex-functions.spec.ts +0 -57
- package/test/parameters/value-utils.spec.js +0 -73
- package/test/schema/json-schema-generator.spec.js +0 -227
- package/tsconfig.json +0 -9
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { withBooleanInput } from './parameter-function-utils';
|
|
2
|
-
import { ParameterFunction } from './parameter-function';
|
|
3
|
-
|
|
4
|
-
class BooleanParameterFunction extends ParameterFunction {
|
|
5
|
-
constructor(operate: (...args: boolean[]) => boolean, minArgs?, maxArgs?) {
|
|
6
|
-
super(withBooleanInput(operate), minArgs, maxArgs);
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const booleanParameterFunctions = {
|
|
11
|
-
__and: new BooleanParameterFunction((...args) =>
|
|
12
|
-
args.reduce((x, y) => x && y, true)
|
|
13
|
-
),
|
|
14
|
-
|
|
15
|
-
__or: new BooleanParameterFunction((...args) =>
|
|
16
|
-
args.reduce((x, y) => x || y, false)
|
|
17
|
-
),
|
|
18
|
-
|
|
19
|
-
__not: new BooleanParameterFunction((x) => !x, 1, 1),
|
|
20
|
-
|
|
21
|
-
__true: new BooleanParameterFunction(() => true, 0, 0),
|
|
22
|
-
|
|
23
|
-
__false: new BooleanParameterFunction(() => false, 0, 0),
|
|
24
|
-
};
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
const CryptoJS = require('crypto-js');
|
|
2
|
-
|
|
3
|
-
import { PresentableError } from '@loadmill/universal/dist/errors';
|
|
4
|
-
|
|
5
|
-
export const FORMATS = {
|
|
6
|
-
UTF8: 'utf-8',
|
|
7
|
-
HEX: 'hex'
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export const HASH = {
|
|
11
|
-
SHA1: 'SHA1',
|
|
12
|
-
SHA256: 'SHA256',
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export const toSha = (secret: string, alg: string, secretFormat: string) => {
|
|
16
|
-
try {
|
|
17
|
-
const hashFunction = toHashFunction(alg);
|
|
18
|
-
const hashed = hashFunction(toCryptoFormat(secret, secretFormat));
|
|
19
|
-
return hashed.toString(CryptoJS.enc.Hex);
|
|
20
|
-
} catch (_e) {
|
|
21
|
-
throw new PresentableError(`Can't digest ${secret}`);
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export const toHMAC = (secret: string, alg: string, secretFormat: string, salt: string) => {
|
|
26
|
-
try {
|
|
27
|
-
const converted = toCryptoFormat(secret, secretFormat);
|
|
28
|
-
const hmaced = CryptoJS.algo.HMAC.create(CryptoJS.algo[(alg || HASH.SHA256)], converted);
|
|
29
|
-
salt && hmaced.update(salt);
|
|
30
|
-
const hashed = hmaced.finalize();
|
|
31
|
-
return hashed.toString(CryptoJS.enc.Hex);
|
|
32
|
-
} catch (_e) {
|
|
33
|
-
throw new PresentableError(`Can't digest ${secret}`);
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
const toHashFunction = (type) => {
|
|
38
|
-
switch (type) {
|
|
39
|
-
case HASH.SHA1:
|
|
40
|
-
return CryptoJS.SHA1;
|
|
41
|
-
case HASH.SHA256:
|
|
42
|
-
default:
|
|
43
|
-
return CryptoJS.SHA256;
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const toCryptoFormat = (from, base) => {
|
|
48
|
-
switch (base) {
|
|
49
|
-
case FORMATS.HEX:
|
|
50
|
-
return CryptoJS.enc.Hex.parse(from);
|
|
51
|
-
case FORMATS.UTF8:
|
|
52
|
-
default:
|
|
53
|
-
return CryptoJS.enc.Utf8.parse(from);
|
|
54
|
-
}
|
|
55
|
-
};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Validator } from 'jsonschema';
|
|
2
|
-
import isEmpty from 'lodash/isEmpty';
|
|
3
|
-
|
|
4
|
-
import { JSONSchemaAssertionError } from '@loadmill/universal/dist/errors';
|
|
5
|
-
|
|
6
|
-
export const applyJSONSchema = (instance, schema) => {
|
|
7
|
-
const v = new Validator();
|
|
8
|
-
let parsedInstance, parsedSchema;
|
|
9
|
-
|
|
10
|
-
try {
|
|
11
|
-
parsedInstance = JSON.parse(instance);
|
|
12
|
-
} catch {
|
|
13
|
-
parsedInstance = instance;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
try {
|
|
17
|
-
parsedSchema = JSON.parse(schema);
|
|
18
|
-
} catch (e) {
|
|
19
|
-
throw new JSONSchemaAssertionError(`Invalid schema - ${e.message}`);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const res = v.validate(parsedInstance, parsedSchema);
|
|
23
|
-
|
|
24
|
-
if (!isEmpty(res.errors)) {
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return true;
|
|
29
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { withNumericInput } from './parameter-function-utils';
|
|
2
|
-
import { ParameterFunction } from './parameter-function';
|
|
3
|
-
|
|
4
|
-
class NumericInputParameterFunction extends ParameterFunction {
|
|
5
|
-
constructor(
|
|
6
|
-
operate: (...args: number[]) => NonNullable<any>,
|
|
7
|
-
minArgs?,
|
|
8
|
-
maxArgs?
|
|
9
|
-
) {
|
|
10
|
-
super(withNumericInput(operate), minArgs, maxArgs);
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export const numericInputParameterFunctions = {
|
|
15
|
-
__lt: new NumericInputParameterFunction((x, y) => x < y, 2, 2),
|
|
16
|
-
|
|
17
|
-
__lte: new NumericInputParameterFunction((x, y) => x <= y, 2, 2),
|
|
18
|
-
|
|
19
|
-
__gt: new NumericInputParameterFunction((x, y) => x > y, 2, 2),
|
|
20
|
-
|
|
21
|
-
__gte: new NumericInputParameterFunction((x, y) => x >= y, 2, 2),
|
|
22
|
-
};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { ParameterFunction } from './parameter-function';
|
|
2
|
-
import { withNumericIO } from './parameter-function-utils';
|
|
3
|
-
import { PresentableError } from '@loadmill/universal/dist/errors';
|
|
4
|
-
|
|
5
|
-
class NumericParameterFunction extends ParameterFunction {
|
|
6
|
-
constructor(operate: (...args: number[]) => number, minArgs?, maxArgs?) {
|
|
7
|
-
super(withNumericIO(operate), minArgs, maxArgs);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const numericParameterFunctions = {
|
|
12
|
-
__add: new NumericParameterFunction((...args) =>
|
|
13
|
-
args.reduce((x, y) => x + y, 0)
|
|
14
|
-
),
|
|
15
|
-
|
|
16
|
-
__sub: new NumericParameterFunction((v1, v2) => v1 - v2, 2, 2),
|
|
17
|
-
|
|
18
|
-
__neg: new NumericParameterFunction((x) => -x, 1, 1),
|
|
19
|
-
|
|
20
|
-
__abs: new NumericParameterFunction((x) => Math.abs(x), 1, 1),
|
|
21
|
-
|
|
22
|
-
__mult: new NumericParameterFunction((...args) =>
|
|
23
|
-
args.reduce((x, y) => x * y, 1)
|
|
24
|
-
),
|
|
25
|
-
|
|
26
|
-
__div: new NumericParameterFunction(
|
|
27
|
-
(v1, v2) => {
|
|
28
|
-
if (v2 === 0) {
|
|
29
|
-
throw new PresentableError('Cannot divide by zero');
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return v1 / v2;
|
|
33
|
-
},
|
|
34
|
-
2,
|
|
35
|
-
2
|
|
36
|
-
),
|
|
37
|
-
};
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { isTruthyParameterValue, parameterValueToNumber } from '../value-utils';
|
|
2
|
-
import { ParameterFunction } from './parameter-function';
|
|
3
|
-
import { PresentableError } from '@loadmill/universal/dist/errors';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export const withParameters = (fun) => (...args) => {
|
|
7
|
-
const result = fun(...args);
|
|
8
|
-
|
|
9
|
-
if (result != null) {
|
|
10
|
-
return result.toString();
|
|
11
|
-
} else {
|
|
12
|
-
throw new PresentableError('Result undefined');
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
withBooleanInput = (fun) => {
|
|
16
|
-
const pfun = withParameters(fun);
|
|
17
|
-
return (...args) => pfun(...args.map(isTruthyParameterValue));
|
|
18
|
-
},
|
|
19
|
-
withNumericInput = (fun) => {
|
|
20
|
-
const pfun = withParameters(fun);
|
|
21
|
-
return (...args) =>
|
|
22
|
-
pfun(
|
|
23
|
-
...args.map((arg, index) => {
|
|
24
|
-
const num = parameterValueToNumber(arg);
|
|
25
|
-
|
|
26
|
-
if (num == null) {
|
|
27
|
-
throw new PresentableError(
|
|
28
|
-
`Cannot translate '${arg}' at index ${index} to a finite number`
|
|
29
|
-
);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return num;
|
|
33
|
-
})
|
|
34
|
-
);
|
|
35
|
-
},
|
|
36
|
-
withNumericIO = (fun) =>
|
|
37
|
-
withNumericInput((...args) => {
|
|
38
|
-
const result = fun(...args);
|
|
39
|
-
|
|
40
|
-
if (Number.isFinite(result)) {
|
|
41
|
-
return result;
|
|
42
|
-
} else {
|
|
43
|
-
throw new PresentableError(`Result '${result}' is not a finite number`);
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
export class BasicParameterFunction extends ParameterFunction {
|
|
48
|
-
constructor(
|
|
49
|
-
operate: (...args: string[]) => NonNullable<any>,
|
|
50
|
-
minArgs?,
|
|
51
|
-
maxArgs?
|
|
52
|
-
) {
|
|
53
|
-
super(withParameters(operate), minArgs, maxArgs);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { ParameterFunction } from './parameter-function';
|
|
2
|
-
import { randomParameterFunctions } from './random-parameter-functions';
|
|
3
|
-
import { booleanParameterFunctions } from './boolean-parameter-functions';
|
|
4
|
-
import { numericParameterFunctions } from './numeric-parameter-functions';
|
|
5
|
-
import { textualParameterFunctions } from './textual-parameter-functions';
|
|
6
|
-
import { numericInputParameterFunctions } from './numeric-input-parameter-functions';
|
|
7
|
-
import { BasicParameterFunction } from './parameter-function-utils';
|
|
8
|
-
|
|
9
|
-
const parameterFunctions: { [name: string]: BasicParameterFunction } = {
|
|
10
|
-
...randomParameterFunctions,
|
|
11
|
-
...textualParameterFunctions,
|
|
12
|
-
...booleanParameterFunctions,
|
|
13
|
-
...numericParameterFunctions,
|
|
14
|
-
...numericInputParameterFunctions,
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const toOperations = (paramFunctions: typeof parameterFunctions): ParameterFunctionOperations => {
|
|
18
|
-
const operations = {};
|
|
19
|
-
for (const func in paramFunctions) {
|
|
20
|
-
const without__prefix = func.substring(2);
|
|
21
|
-
operations[without__prefix] = paramFunctions[func].operate;
|
|
22
|
-
}
|
|
23
|
-
return operations;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export const parameterFunctionOperations = toOperations(parameterFunctions);
|
|
27
|
-
|
|
28
|
-
export type ParameterFunctionOperations = { [no__prefix: string]: Function };
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* This is a list of all the functions we allow to accept a parameter with null value.
|
|
32
|
-
* For example, __encode_url(${url_param}) when url_param has a null value.
|
|
33
|
-
*
|
|
34
|
-
* We are using these functions in Orca so in case one of the functions is changed we must changed in Orca as well.
|
|
35
|
-
*/
|
|
36
|
-
const nullableParameterVaulesTextFunctions = {
|
|
37
|
-
// true / false would have suffice but I want hard refernce to avoid mistakes if a function name is changed
|
|
38
|
-
// so if you change the name of the function - you must change the key name
|
|
39
|
-
__escape_quotes: textualParameterFunctions.__escape_quotes,
|
|
40
|
-
__encode_url: textualParameterFunctions.__encode_url,
|
|
41
|
-
__decode_url: textualParameterFunctions.__decode_url,
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
export function canHaveNullParameterValue(functionName: string): boolean {
|
|
45
|
-
return nullableParameterVaulesTextFunctions.hasOwnProperty(functionName);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export function getParameterFunction(
|
|
49
|
-
functionName: string
|
|
50
|
-
): ParameterFunction | null {
|
|
51
|
-
return parameterFunctions.hasOwnProperty(functionName)
|
|
52
|
-
? parameterFunctions[functionName]
|
|
53
|
-
: null;
|
|
54
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
const seedrandom = require('seedrandom');
|
|
2
|
-
import { generateRandom, RandomTypes } from '../generate-random';
|
|
3
|
-
import { BasicParameterFunction } from './parameter-function-utils';
|
|
4
|
-
|
|
5
|
-
const MAX_NUMBER_OF_DIGITS = 10; // max length of output from seedrandom(seed).int32()
|
|
6
|
-
|
|
7
|
-
export const randomParameterFunctions = Object.assign(
|
|
8
|
-
{},
|
|
9
|
-
...Object.keys(RandomTypes).map((kind) => ({
|
|
10
|
-
[`__random_${kind}`]: new BasicParameterFunction((...args) =>
|
|
11
|
-
generateRandom(kind, ...args)
|
|
12
|
-
),
|
|
13
|
-
})),
|
|
14
|
-
{ '__random_seeded_number': new BasicParameterFunction((seed = '', length) => {
|
|
15
|
-
const rand= Math.abs(new seedrandom(seed).int32());
|
|
16
|
-
if (length && +length > 0) {
|
|
17
|
-
const cut = Math.min(+length, rand.toString().length, MAX_NUMBER_OF_DIGITS);
|
|
18
|
-
return ('' + rand).substring(0, cut);
|
|
19
|
-
}
|
|
20
|
-
return rand;
|
|
21
|
-
} , 0, 2) }
|
|
22
|
-
);
|