@loadmill/core 0.3.49 → 0.3.52
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/parameters/parameter-regex-providers.d.ts +2 -0
- package/dist/parameters/parameter-regex-providers.js +3 -1
- package/dist/parameters/parameter-regex-providers.js.map +1 -1
- package/dist/request/index.d.ts +1 -0
- package/dist/request/index.js +5 -5
- 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 -74
- 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,114 +0,0 @@
|
|
|
1
|
-
import uuid from 'uuid';
|
|
2
|
-
import randomstring from 'randomstring';
|
|
3
|
-
import clamp = require('lodash/clamp');
|
|
4
|
-
import random = require('lodash/random');
|
|
5
|
-
import { parameterValueToNumber } from './value-utils';
|
|
6
|
-
import { PresentableError } from '@loadmill/universal/dist/errors';
|
|
7
|
-
|
|
8
|
-
const MAX_RANDOM_LEN = 100;
|
|
9
|
-
const DEFAULT_RANDOM_LEN = 10;
|
|
10
|
-
// 2^32
|
|
11
|
-
const DEFAULT_MAX_RANDOM_INT = 4294967296;
|
|
12
|
-
|
|
13
|
-
export enum RandomTypes {
|
|
14
|
-
hex = 'hex',
|
|
15
|
-
uuid = 'uuid',
|
|
16
|
-
from = 'from',
|
|
17
|
-
chars = 'chars',
|
|
18
|
-
number = 'number',
|
|
19
|
-
digits = 'digits',
|
|
20
|
-
uppers = 'uppers',
|
|
21
|
-
lowers = 'lowers',
|
|
22
|
-
letters = 'letters',
|
|
23
|
-
boolean = 'boolean',
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export function generateRandom(kind: string, arg1?: string, arg2?: string) {
|
|
27
|
-
if (!kind) {
|
|
28
|
-
return null;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if (kind === RandomTypes.uuid) {
|
|
32
|
-
return uuid.v4();
|
|
33
|
-
} else if (kind === RandomTypes.number) {
|
|
34
|
-
let min = 0,
|
|
35
|
-
max = DEFAULT_MAX_RANDOM_INT;
|
|
36
|
-
|
|
37
|
-
if (arg2) {
|
|
38
|
-
min = nonNegativeInt(arg1);
|
|
39
|
-
max = nonNegativeInt(arg2);
|
|
40
|
-
|
|
41
|
-
if (min > max) {
|
|
42
|
-
const temp = min;
|
|
43
|
-
min = max;
|
|
44
|
-
max = temp;
|
|
45
|
-
}
|
|
46
|
-
} else if (arg1) {
|
|
47
|
-
max = nonNegativeInt(arg1);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// Assumes both are integers!
|
|
51
|
-
return random(min, max);
|
|
52
|
-
} else if (kind === RandomTypes.boolean) {
|
|
53
|
-
const probability = nonNegativeInt(arg1, 50) / 100;
|
|
54
|
-
|
|
55
|
-
return (
|
|
56
|
-
probability >= 1 ||
|
|
57
|
-
(probability !== 0 && Math.random() <= probability)
|
|
58
|
-
).toString();
|
|
59
|
-
} else {
|
|
60
|
-
const length = nonNegativeInt(
|
|
61
|
-
kind === RandomTypes.from ? arg2 : arg1,
|
|
62
|
-
DEFAULT_RANDOM_LEN
|
|
63
|
-
);
|
|
64
|
-
const options: { length; charset?; capitalization? } = {
|
|
65
|
-
length: clamp(length, 0, MAX_RANDOM_LEN),
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
if (kind === RandomTypes.chars) {
|
|
69
|
-
options.charset = 'alphanumeric';
|
|
70
|
-
} else if (kind === RandomTypes.digits) {
|
|
71
|
-
options.charset = 'numeric';
|
|
72
|
-
} else if (kind === RandomTypes.hex) {
|
|
73
|
-
options.charset = 'hex';
|
|
74
|
-
} else if (
|
|
75
|
-
kind === RandomTypes.letters ||
|
|
76
|
-
kind === RandomTypes.lowers ||
|
|
77
|
-
kind === RandomTypes.uppers
|
|
78
|
-
) {
|
|
79
|
-
options.charset = 'alphabetic';
|
|
80
|
-
|
|
81
|
-
if (kind !== RandomTypes.letters) {
|
|
82
|
-
options.capitalization =
|
|
83
|
-
kind === RandomTypes.lowers ? 'lowercase' : 'uppercase';
|
|
84
|
-
}
|
|
85
|
-
} else if (kind === RandomTypes.from) {
|
|
86
|
-
if (!arg1) {
|
|
87
|
-
return null;
|
|
88
|
-
}
|
|
89
|
-
options.charset = arg1;
|
|
90
|
-
} else {
|
|
91
|
-
options.charset = kind;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return randomstring.generate(options);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
function nonNegativeInt(arg?: string, def?: number) {
|
|
99
|
-
let value;
|
|
100
|
-
|
|
101
|
-
if (!arg) {
|
|
102
|
-
value = def;
|
|
103
|
-
} else {
|
|
104
|
-
value = parameterValueToNumber(arg, { integer: true, nonNegative: true });
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
if (value == null) {
|
|
108
|
-
throw new PresentableError(
|
|
109
|
-
'Argument must be a non-negative integer, instead found: ' + arg
|
|
110
|
-
);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
return value;
|
|
114
|
-
}
|