@loadmill/core 0.3.109 → 0.3.110
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/defaults.d.ts +1 -0
- package/dist/conf/defaults.js +11 -0
- package/dist/conf/defaults.js.map +1 -0
- package/dist/conf/extrema.d.ts +7 -0
- package/dist/conf/extrema.js +12 -0
- package/dist/conf/extrema.js.map +1 -0
- package/dist/conf/index.d.ts +15 -0
- package/dist/conf/index.js +80 -0
- package/dist/conf/index.js.map +1 -0
- package/dist/conf/notifications.d.ts +2 -0
- package/dist/conf/notifications.js +19 -0
- package/dist/conf/notifications.js.map +1 -0
- package/dist/conf/types.d.ts +110 -0
- package/dist/conf/types.js +38 -0
- package/dist/conf/types.js.map +1 -0
- package/dist/conf/validate.d.ts +69 -0
- package/dist/conf/validate.js +495 -0
- package/dist/conf/validate.js.map +1 -0
- package/dist/distributed-logger-reporter.d.ts +3 -0
- package/dist/distributed-logger-reporter.js +74 -0
- package/dist/distributed-logger-reporter.js.map +1 -0
- package/dist/echo/firehose.d.ts +7 -0
- package/dist/echo/firehose.js +130 -0
- package/dist/echo/firehose.js.map +1 -0
- package/dist/echo/index.d.ts +3 -0
- package/dist/echo/index.js +8 -0
- package/dist/echo/index.js.map +1 -0
- package/dist/echo/stats.d.ts +8 -0
- package/dist/echo/stats.js +152 -0
- package/dist/echo/stats.js.map +1 -0
- package/dist/har/index.d.ts +68 -0
- package/dist/har/index.js +14 -0
- package/dist/har/index.js.map +1 -0
- package/dist/labels/constants.d.ts +1 -0
- package/dist/labels/constants.js +5 -0
- package/dist/labels/constants.js.map +1 -0
- package/dist/multipart-form-data/files.d.ts +2 -0
- package/dist/multipart-form-data/files.js +63 -0
- package/dist/multipart-form-data/files.js.map +1 -0
- package/dist/multipart-form-data/form-data-utils.d.ts +19 -0
- package/dist/multipart-form-data/form-data-utils.js +117 -0
- package/dist/multipart-form-data/form-data-utils.js.map +1 -0
- 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 +2 -0
- package/dist/multipart-form-data/multipart-text-to-post-form-data.js +86 -0
- package/dist/multipart-form-data/multipart-text-to-post-form-data.js.map +1 -0
- package/dist/parameters/extractions.d.ts +26 -0
- package/dist/parameters/extractions.js +49 -0
- package/dist/parameters/extractions.js.map +1 -0
- package/dist/parameters/extractors/cheerio-extractor.d.ts +11 -0
- package/dist/parameters/extractors/cheerio-extractor.js +84 -0
- package/dist/parameters/extractors/cheerio-extractor.js.map +1 -0
- package/dist/parameters/extractors/expression-extractor.d.ts +6 -0
- package/dist/parameters/extractors/expression-extractor.js +38 -0
- package/dist/parameters/extractors/expression-extractor.js.map +1 -0
- package/dist/parameters/extractors/extractor.d.ts +3 -0
- package/dist/parameters/extractors/extractor.js +3 -0
- package/dist/parameters/extractors/extractor.js.map +1 -0
- package/dist/parameters/extractors/header-extractor.d.ts +7 -0
- package/dist/parameters/extractors/header-extractor.js +51 -0
- package/dist/parameters/extractors/header-extractor.js.map +1 -0
- package/dist/parameters/extractors/index.d.ts +10 -0
- package/dist/parameters/extractors/index.js +20 -0
- package/dist/parameters/extractors/index.js.map +1 -0
- package/dist/parameters/extractors/json-path-extractor.d.ts +11 -0
- package/dist/parameters/extractors/json-path-extractor.js +117 -0
- package/dist/parameters/extractors/json-path-extractor.js.map +1 -0
- package/dist/parameters/extractors/parametrized-extractor.d.ts +10 -0
- package/dist/parameters/extractors/parametrized-extractor.js +34 -0
- package/dist/parameters/extractors/parametrized-extractor.js.map +1 -0
- package/dist/parameters/extractors/regex-extractor.d.ts +7 -0
- package/dist/parameters/extractors/regex-extractor.js +46 -0
- package/dist/parameters/extractors/regex-extractor.js.map +1 -0
- package/dist/parameters/extractors/regex-matcher.d.ts +1 -0
- package/dist/parameters/extractors/regex-matcher.js +21 -0
- package/dist/parameters/extractors/regex-matcher.js.map +1 -0
- package/dist/parameters/extractors/ws-extractor.d.ts +33 -0
- package/dist/parameters/extractors/ws-extractor.js +215 -0
- package/dist/parameters/extractors/ws-extractor.js.map +1 -0
- package/dist/parameters/extractors/x-path-extractor.d.ts +9 -0
- package/dist/parameters/extractors/x-path-extractor.js +71 -0
- package/dist/parameters/extractors/x-path-extractor.js.map +1 -0
- package/dist/parameters/generate-random.d.ts +13 -0
- package/dist/parameters/generate-random.js +108 -0
- package/dist/parameters/generate-random.js.map +1 -0
- package/dist/parameters/html-utils.d.ts +1 -0
- package/dist/parameters/html-utils.js +18 -0
- package/dist/parameters/html-utils.js.map +1 -0
- package/dist/parameters/index.d.ts +89 -0
- package/dist/parameters/index.js +602 -0
- package/dist/parameters/index.js.map +1 -0
- package/dist/parameters/json-path-utils.d.ts +1 -0
- package/dist/parameters/json-path-utils.js +16 -0
- package/dist/parameters/json-path-utils.js.map +1 -0
- package/dist/parameters/operators/binary-operator.d.ts +13 -0
- package/dist/parameters/operators/binary-operator.js +39 -0
- package/dist/parameters/operators/binary-operator.js.map +1 -0
- package/dist/parameters/operators/index.d.ts +5 -0
- package/dist/parameters/operators/index.js +21 -0
- package/dist/parameters/operators/index.js.map +1 -0
- package/dist/parameters/parameter-functions/boolean-parameter-functions.d.ts +12 -0
- package/dist/parameters/parameter-functions/boolean-parameter-functions.js +47 -0
- package/dist/parameters/parameter-functions/boolean-parameter-functions.js.map +1 -0
- package/dist/parameters/parameter-functions/crypto.d.ts +11 -0
- package/dist/parameters/parameter-functions/crypto.js +71 -0
- package/dist/parameters/parameter-functions/crypto.js.map +1 -0
- package/dist/parameters/parameter-functions/json-schema.d.ts +1 -0
- package/dist/parameters/parameter-functions/json-schema.js +33 -0
- package/dist/parameters/parameter-functions/json-schema.js.map +1 -0
- package/dist/parameters/parameter-functions/numeric-input-parameter-functions.d.ts +11 -0
- package/dist/parameters/parameter-functions/numeric-input-parameter-functions.js +34 -0
- package/dist/parameters/parameter-functions/numeric-input-parameter-functions.js.map +1 -0
- package/dist/parameters/parameter-functions/numeric-parameter-functions.d.ts +15 -0
- package/dist/parameters/parameter-functions/numeric-parameter-functions.js +56 -0
- package/dist/parameters/parameter-functions/numeric-parameter-functions.js.map +1 -0
- package/dist/parameters/parameter-functions/parameter-function-utils.d.ts +5 -0
- package/dist/parameters/parameter-functions/parameter-function-utils.js +82 -0
- package/dist/parameters/parameter-functions/parameter-function-utils.js.map +1 -0
- package/dist/parameters/parameter-functions/parameter-function.d.ts +6 -0
- package/dist/parameters/parameter-functions/parameter-function.js +28 -0
- package/dist/parameters/parameter-functions/parameter-function.js.map +1 -0
- package/dist/parameters/parameter-functions/parameter-functions.d.ts +7 -0
- package/dist/parameters/parameter-functions/parameter-functions.js +53 -0
- package/dist/parameters/parameter-functions/parameter-functions.js.map +1 -0
- package/dist/parameters/parameter-functions/random-parameter-functions.d.ts +1 -0
- package/dist/parameters/parameter-functions/random-parameter-functions.js +43 -0
- package/dist/parameters/parameter-functions/random-parameter-functions.js.map +1 -0
- package/dist/parameters/parameter-functions/textual-parameter-functions.d.ts +67 -0
- package/dist/parameters/parameter-functions/textual-parameter-functions.js +374 -0
- package/dist/parameters/parameter-functions/textual-parameter-functions.js.map +1 -0
- package/dist/parameters/parameter-name-utils.d.ts +5 -0
- package/dist/parameters/parameter-name-utils.js +136 -0
- package/dist/parameters/parameter-name-utils.js.map +1 -0
- package/dist/parameters/parameter-regex-providers.d.ts +24 -0
- package/dist/parameters/parameter-regex-providers.js +70 -0
- package/dist/parameters/parameter-regex-providers.js.map +1 -0
- package/dist/parameters/resolvers/random-parameters-resolver.d.ts +1 -0
- package/dist/parameters/resolvers/random-parameters-resolver.js +12 -0
- package/dist/parameters/resolvers/random-parameters-resolver.js.map +1 -0
- package/dist/parameters/type.d.ts +10 -0
- package/dist/parameters/type.js +9 -0
- package/dist/parameters/type.js.map +1 -0
- package/dist/parameters/value-utils.d.ts +5 -0
- package/dist/parameters/value-utils.js +44 -0
- package/dist/parameters/value-utils.js.map +1 -0
- package/dist/request/index.d.ts +265 -0
- package/dist/request/index.js +541 -0
- package/dist/request/index.js.map +1 -0
- package/dist/schema/json-schema-generator.d.ts +20 -0
- package/dist/schema/json-schema-generator.js +135 -0
- package/dist/schema/json-schema-generator.js.map +1 -0
- package/dist/signals.d.ts +4 -0
- package/dist/signals.js +9 -0
- package/dist/signals.js.map +1 -0
- package/dist/subset/index.d.ts +3 -0
- package/dist/subset/index.js +8 -0
- package/dist/subset/index.js.map +1 -0
- package/dist/subset/is-subset.d.ts +2 -0
- package/dist/subset/is-subset.js +29 -0
- package/dist/subset/is-subset.js.map +1 -0
- package/dist/subset/json-contains.d.ts +1 -0
- package/dist/subset/json-contains.js +24 -0
- package/dist/subset/json-contains.js.map +1 -0
- package/dist/team-options/constants.d.ts +3 -0
- package/dist/team-options/constants.js +7 -0
- package/dist/team-options/constants.js.map +1 -0
- package/dist/xml/decode.d.ts +2 -0
- package/dist/xml/decode.js +87 -0
- package/dist/xml/decode.js.map +1 -0
- package/dist/xml/encode.d.ts +1 -0
- package/dist/xml/encode.js +14 -0
- package/dist/xml/encode.js.map +1 -0
- package/dist/xml/escape-reserved-chars.d.ts +6 -0
- package/dist/xml/escape-reserved-chars.js +57 -0
- package/dist/xml/escape-reserved-chars.js.map +1 -0
- package/dist/xml/is-xml.d.ts +1 -0
- package/dist/xml/is-xml.js +9 -0
- package/dist/xml/is-xml.js.map +1 -0
- package/dist/xml/json-to-xml.d.ts +2 -0
- package/dist/xml/json-to-xml.js +11 -0
- package/dist/xml/json-to-xml.js.map +1 -0
- package/dist/xml/namespaces.d.ts +7 -0
- package/dist/xml/namespaces.js +16 -0
- package/dist/xml/namespaces.js.map +1 -0
- package/dist/xml/remove-invisible-chars.d.ts +2 -0
- package/dist/xml/remove-invisible-chars.js +13 -0
- package/dist/xml/remove-invisible-chars.js.map +1 -0
- package/dist/xml/replace-s-tags.d.ts +4 -0
- package/dist/xml/replace-s-tags.js +21 -0
- package/dist/xml/replace-s-tags.js.map +1 -0
- package/dist/xml/xml-to-json.d.ts +7 -0
- package/dist/xml/xml-to-json.js +21 -0
- package/dist/xml/xml-to-json.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.FirehoseRecords = void 0;
|
|
40
|
+
var client_firehose_1 = require("@aws-sdk/client-firehose");
|
|
41
|
+
var client_cognito_identity_1 = require("@aws-sdk/client-cognito-identity");
|
|
42
|
+
var FIREHOSE_API_VERSION = '2015-08-04';
|
|
43
|
+
var REGION = 'us-east-1';
|
|
44
|
+
var STREAM_NAME = 'fhs-test1';
|
|
45
|
+
var firehose;
|
|
46
|
+
var cognito = new client_cognito_identity_1.CognitoIdentity({ region: REGION });
|
|
47
|
+
var FirehoseRecords = /** @class */ (function () {
|
|
48
|
+
function FirehoseRecords() {
|
|
49
|
+
Object.defineProperty(this, "records", {
|
|
50
|
+
enumerable: true,
|
|
51
|
+
configurable: true,
|
|
52
|
+
writable: true,
|
|
53
|
+
value: void 0
|
|
54
|
+
});
|
|
55
|
+
this.clearRecords();
|
|
56
|
+
}
|
|
57
|
+
Object.defineProperty(FirehoseRecords.prototype, "addRecord", {
|
|
58
|
+
enumerable: false,
|
|
59
|
+
configurable: true,
|
|
60
|
+
writable: true,
|
|
61
|
+
value: function (record) {
|
|
62
|
+
var enc = new TextEncoder(); // always utf-8
|
|
63
|
+
var encodedRecord = enc.encode(JSON.stringify(record) + "\n");
|
|
64
|
+
this.records.push({ Data: encodedRecord });
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
Object.defineProperty(FirehoseRecords.prototype, "pushRecords", {
|
|
68
|
+
enumerable: false,
|
|
69
|
+
configurable: true,
|
|
70
|
+
writable: true,
|
|
71
|
+
value: function () {
|
|
72
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
73
|
+
var identity, credentialResponse, command, err_1;
|
|
74
|
+
return __generator(this, function (_a) {
|
|
75
|
+
switch (_a.label) {
|
|
76
|
+
case 0:
|
|
77
|
+
_a.trys.push([0, 4, 5, 6]);
|
|
78
|
+
if (!this.records.length) {
|
|
79
|
+
return [2 /*return*/];
|
|
80
|
+
}
|
|
81
|
+
return [4 /*yield*/, cognito.getId({ IdentityPoolId: 'us-east-1:79372411-2664-431b-aa0b-aad9f938f6e9' })];
|
|
82
|
+
case 1:
|
|
83
|
+
identity = _a.sent();
|
|
84
|
+
return [4 /*yield*/, cognito.getCredentialsForIdentity({ IdentityId: identity.IdentityId })];
|
|
85
|
+
case 2:
|
|
86
|
+
credentialResponse = _a.sent();
|
|
87
|
+
firehose = new client_firehose_1.FirehoseClient({
|
|
88
|
+
region: REGION,
|
|
89
|
+
apiVersion: FIREHOSE_API_VERSION,
|
|
90
|
+
credentials: {
|
|
91
|
+
accessKeyId: credentialResponse.Credentials.AccessKeyId,
|
|
92
|
+
secretAccessKey: credentialResponse.Credentials.SecretKey,
|
|
93
|
+
sessionToken: credentialResponse.Credentials.SessionToken,
|
|
94
|
+
expiration: credentialResponse.Credentials.Expiration
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
command = new client_firehose_1.PutRecordBatchCommand({
|
|
98
|
+
Records: this.records,
|
|
99
|
+
DeliveryStreamName: STREAM_NAME
|
|
100
|
+
});
|
|
101
|
+
return [4 /*yield*/, firehose.send(command)];
|
|
102
|
+
case 3:
|
|
103
|
+
_a.sent();
|
|
104
|
+
return [3 /*break*/, 6];
|
|
105
|
+
case 4:
|
|
106
|
+
err_1 = _a.sent();
|
|
107
|
+
// eslint-disable-next-line no-console
|
|
108
|
+
console.error(err_1);
|
|
109
|
+
return [3 /*break*/, 6];
|
|
110
|
+
case 5:
|
|
111
|
+
this.clearRecords();
|
|
112
|
+
return [7 /*endfinally*/];
|
|
113
|
+
case 6: return [2 /*return*/];
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
Object.defineProperty(FirehoseRecords.prototype, "clearRecords", {
|
|
120
|
+
enumerable: false,
|
|
121
|
+
configurable: true,
|
|
122
|
+
writable: true,
|
|
123
|
+
value: function () {
|
|
124
|
+
this.records = [];
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
return FirehoseRecords;
|
|
128
|
+
}());
|
|
129
|
+
exports.FirehoseRecords = FirehoseRecords;
|
|
130
|
+
//# sourceMappingURL=firehose.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"firehose.js","sourceRoot":"","sources":["../../src/echo/firehose.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4DAAiF;AACjF,4EAAmE;AAEnE,IAAM,oBAAoB,GAAG,YAAY,CAAC;AAC1C,IAAM,MAAM,GAAG,WAAW,CAAC;AAC3B,IAAM,WAAW,GAAG,WAAW,CAAC;AAEhC,IAAI,QAAwB,CAAC;AAC7B,IAAM,OAAO,GAAG,IAAI,yCAAe,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;AAExD;IAGE;QAFA;;;;;WAAQ;QAGN,IAAI,CAAC,YAAY,EAAE,CAAC;IACtB,CAAC;;;;;eAED,UAAU,MAAM;YACd,IAAM,GAAG,GAAG,IAAI,WAAW,EAAE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;;;eAED;YACE,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;QACpB,CAAC;;IAEH,sBAAC;AAAD,CAAC,AArDD,IAqDC;AArDY,0CAAe"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FirehoseRecords = exports.Stats = void 0;
|
|
4
|
+
var stats_1 = require("./stats");
|
|
5
|
+
Object.defineProperty(exports, "Stats", { enumerable: true, get: function () { return stats_1.Stats; } });
|
|
6
|
+
var firehose_1 = require("./firehose");
|
|
7
|
+
Object.defineProperty(exports, "FirehoseRecords", { enumerable: true, get: function () { return firehose_1.FirehoseRecords; } });
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/echo/index.ts"],"names":[],"mappings":";;;AAAA,iCAAgC;AAGvB,sFAHA,aAAK,OAGA;AAFd,uCAA6C;AAE7B,gGAFP,0BAAe,OAEO"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.Stats = void 0;
|
|
43
|
+
var isUUID_1 = __importDefault(require("validator/lib/isUUID"));
|
|
44
|
+
var isNumber = function (s) { return /^[0-9]+$/.test(s); };
|
|
45
|
+
var standardizePath = function (path) {
|
|
46
|
+
var parts = path.slice(1).split('/');
|
|
47
|
+
var newPath = '';
|
|
48
|
+
parts.forEach(function (part) {
|
|
49
|
+
newPath += (isUUID_1.default(part) || isNumber(part)) ? '/{param}' : "/" + part;
|
|
50
|
+
});
|
|
51
|
+
return newPath;
|
|
52
|
+
};
|
|
53
|
+
var updateKey = function (obj, key, shouldIncr, value) {
|
|
54
|
+
obj[key] = shouldIncr ? (obj[key] || 0) + value : value;
|
|
55
|
+
};
|
|
56
|
+
var Stats = /** @class */ (function () {
|
|
57
|
+
function Stats() {
|
|
58
|
+
Object.defineProperty(this, "stats", {
|
|
59
|
+
enumerable: true,
|
|
60
|
+
configurable: true,
|
|
61
|
+
writable: true,
|
|
62
|
+
value: void 0
|
|
63
|
+
});
|
|
64
|
+
this.stats = {
|
|
65
|
+
lmCode: -1,
|
|
66
|
+
totalRequests: 0,
|
|
67
|
+
totalResponseTime: 0,
|
|
68
|
+
requestsCounter: {},
|
|
69
|
+
requestsResponseTime: {},
|
|
70
|
+
isNewSession: false,
|
|
71
|
+
totalNewSessions: 0
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
Object.defineProperty(Stats.prototype, "updateStats", {
|
|
75
|
+
enumerable: false,
|
|
76
|
+
configurable: true,
|
|
77
|
+
writable: true,
|
|
78
|
+
value: function (key, shouldIncr, value, subKey) {
|
|
79
|
+
if (value === void 0) { value = 0; }
|
|
80
|
+
if (subKey === void 0) { subKey = ''; }
|
|
81
|
+
if (key && value) {
|
|
82
|
+
if (subKey) {
|
|
83
|
+
updateKey(this.stats[key], subKey, shouldIncr, value);
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
updateKey(this.stats, key, shouldIncr, value);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
Object.defineProperty(Stats.prototype, "addRequest", {
|
|
92
|
+
enumerable: false,
|
|
93
|
+
configurable: true,
|
|
94
|
+
writable: true,
|
|
95
|
+
value: function (request, responseTime) {
|
|
96
|
+
var convertedPath = standardizePath(new URL(request.url).pathname);
|
|
97
|
+
this.updateStats('totalRequests', true, 1);
|
|
98
|
+
this.updateStats('totalResponseTime', true, parseInt(responseTime, 10));
|
|
99
|
+
this.updateStats('requestsCounter', true, 1, request.method + ":" + convertedPath);
|
|
100
|
+
this.updateStats('requestsResponseTime', true, parseInt(responseTime, 10), request.method + ":" + convertedPath);
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
Object.defineProperty(Stats.prototype, "clearStats", {
|
|
104
|
+
enumerable: false,
|
|
105
|
+
configurable: true,
|
|
106
|
+
writable: true,
|
|
107
|
+
value: function () {
|
|
108
|
+
this.stats.totalRequests = 0;
|
|
109
|
+
this.stats.totalResponseTime = 0;
|
|
110
|
+
this.stats.requestsCounter = {};
|
|
111
|
+
this.stats.requestsResponseTime = {};
|
|
112
|
+
this.stats.isNewSession = false;
|
|
113
|
+
this.stats.totalNewSessions = 0;
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
Object.defineProperty(Stats.prototype, "push", {
|
|
117
|
+
enumerable: false,
|
|
118
|
+
configurable: true,
|
|
119
|
+
writable: true,
|
|
120
|
+
value: function (url) {
|
|
121
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
122
|
+
var isPushed, res;
|
|
123
|
+
return __generator(this, function (_a) {
|
|
124
|
+
switch (_a.label) {
|
|
125
|
+
case 0:
|
|
126
|
+
isPushed = false;
|
|
127
|
+
if (!(this.stats.totalRequests > 0)) return [3 /*break*/, 2];
|
|
128
|
+
return [4 /*yield*/, fetch(url + "/stats", {
|
|
129
|
+
method: 'POST',
|
|
130
|
+
body: JSON.stringify(this.stats),
|
|
131
|
+
headers: {
|
|
132
|
+
'Content-Type': 'application/json',
|
|
133
|
+
Accept: 'application/json'
|
|
134
|
+
}
|
|
135
|
+
})];
|
|
136
|
+
case 1:
|
|
137
|
+
res = _a.sent();
|
|
138
|
+
if (res.ok) {
|
|
139
|
+
this.clearStats();
|
|
140
|
+
isPushed = true;
|
|
141
|
+
}
|
|
142
|
+
_a.label = 2;
|
|
143
|
+
case 2: return [2 /*return*/, isPushed];
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
return Stats;
|
|
150
|
+
}());
|
|
151
|
+
exports.Stats = Stats;
|
|
152
|
+
//# sourceMappingURL=stats.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stats.js","sourceRoot":"","sources":["../../src/echo/stats.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gEAA0C;AAE1C,IAAM,QAAQ,GAAG,UAAA,CAAC,IAAI,OAAA,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAlB,CAAkB,CAAC;AAEzC,IAAM,eAAe,GAAG,UAAA,IAAI;IAC1B,IAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACvC,IAAI,OAAO,GAAG,EAAE,CAAC;IAEjB,KAAK,CAAC,OAAO,CAAC,UAAA,IAAI;QAChB,OAAO,IAAI,CAAC,gBAAM,CAAC,IAAI,CAAC,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,MAAI,IAAM,CAAC;IACxE,CAAC,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF,IAAM,SAAS,GAAG,UAAC,GAAG,EAAE,GAAG,EAAE,UAAU,EAAE,KAAK;IAC5C,GAAG,CAAC,GAAG,CAAC,GA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|
|
6
|
+
entries: HarEntry[];
|
|
7
|
+
}
|
|
8
|
+
export interface HarEntry {
|
|
9
|
+
time: number;
|
|
10
|
+
request: HarRequest;
|
|
11
|
+
response: HarResponse;
|
|
12
|
+
startedDateTime: string;
|
|
13
|
+
_resourceType?: ResourceType;
|
|
14
|
+
_webSocketMessages?: WebSocketMessage[];
|
|
15
|
+
}
|
|
16
|
+
declare type ResourceType = 'main_frame' | 'sub_frame' | 'stylesheet' | 'script' | 'image' | 'font' | 'object' | 'xmlhttprequest' | 'ping' | 'csp_report' | 'media' | 'websocket' | 'other';
|
|
17
|
+
export declare type WebSocketMessage = {
|
|
18
|
+
type: WebSocketMessageType;
|
|
19
|
+
time: number;
|
|
20
|
+
opcode: number;
|
|
21
|
+
data: string;
|
|
22
|
+
};
|
|
23
|
+
export declare type WebSocketMessageType = 'send' | 'receive';
|
|
24
|
+
export interface HarRequest {
|
|
25
|
+
url: string;
|
|
26
|
+
method: string;
|
|
27
|
+
headers: HarHeaders;
|
|
28
|
+
bodySize: number;
|
|
29
|
+
postData?: HarPostData;
|
|
30
|
+
cookies: Cookie[];
|
|
31
|
+
queryString: {
|
|
32
|
+
name: string;
|
|
33
|
+
value: string;
|
|
34
|
+
}[];
|
|
35
|
+
}
|
|
36
|
+
export declare type HarHeaders = HarHeader[];
|
|
37
|
+
export declare type HarHeader = {
|
|
38
|
+
name: string;
|
|
39
|
+
value: string;
|
|
40
|
+
};
|
|
41
|
+
export interface HarResponse {
|
|
42
|
+
status: number;
|
|
43
|
+
headers: HarHeaders;
|
|
44
|
+
statusText: string;
|
|
45
|
+
content: {
|
|
46
|
+
mimeType: string;
|
|
47
|
+
text?: string;
|
|
48
|
+
encoding?: string;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
export declare type Cookie = {
|
|
52
|
+
name: string;
|
|
53
|
+
value: string;
|
|
54
|
+
};
|
|
55
|
+
export declare type HarPostData = {
|
|
56
|
+
mimeType: string;
|
|
57
|
+
text?: string;
|
|
58
|
+
params?: HarParam[];
|
|
59
|
+
};
|
|
60
|
+
export declare type HarParam = {
|
|
61
|
+
name: string;
|
|
62
|
+
value?: string;
|
|
63
|
+
fileName?: string;
|
|
64
|
+
contentType?: string;
|
|
65
|
+
};
|
|
66
|
+
export declare const isHar: (obj: any) => any;
|
|
67
|
+
export declare const isWSEntry: (entry: HarEntry) => number | true | undefined;
|
|
68
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isWSEntry = exports.isHar = void 0;
|
|
4
|
+
var isHar = function (obj) {
|
|
5
|
+
var _a, _b, _c;
|
|
6
|
+
return Boolean(obj.log) &&
|
|
7
|
+
typeof ((_a = obj.log) === null || _a === void 0 ? void 0 : _a.version) === 'string' &&
|
|
8
|
+
((_b = obj.log) === null || _b === void 0 ? void 0 : _b.version.startsWith('1.')) &&
|
|
9
|
+
Array.isArray((_c = obj.log) === null || _c === void 0 ? void 0 : _c.entries);
|
|
10
|
+
};
|
|
11
|
+
exports.isHar = isHar;
|
|
12
|
+
var isWSEntry = function (entry) { var _a; return entry._resourceType === 'websocket' || ((_a = entry._webSocketMessages) === null || _a === void 0 ? void 0 : _a.length); };
|
|
13
|
+
exports.isWSEntry = isWSEntry;
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/har/index.ts"],"names":[],"mappings":";;;AA6EO,IAAM,KAAK,GAAG,UAAC,GAAQ;;IAAK,OAAA,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;QACjD,OAAO,CAAA,MAAA,GAAG,CAAC,GAAG,0CAAE,OAAO,CAAA,KAAK,QAAQ;SACpC,MAAA,GAAG,CAAC,GAAG,0CAAE,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;QACjC,KAAK,CAAC,OAAO,CAAC,MAAA,GAAG,CAAC,GAAG,0CAAE,OAAO,CAAC,CAAA;CAAA,CAAC;AAHrB,QAAA,KAAK,SAGgB;AAE3B,IAAM,SAAS,GAAG,UAAC,KAAe,YAAK,OAAA,KAAK,CAAC,aAAa,KAAK,WAAW,KAAI,MAAA,KAAK,CAAC,kBAAkB,0CAAE,MAAM,CAAA,CAAA,EAAA,CAAC;AAAzG,QAAA,SAAS,aAAgG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const AND_OR_NOT_BRACKET_REGEXP: RegExp;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/labels/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,yBAAyB,GAAG,WAAW,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getBinaryOrTextValue = void 0;
|
|
4
|
+
var mime_types_1 = require("mime-types");
|
|
5
|
+
var validator_1 = require("validator");
|
|
6
|
+
var is_binary_file_1 = require("./is-binary-file");
|
|
7
|
+
var getBinaryOrTextValue = function (fields) {
|
|
8
|
+
var _a = fields.value, value = _a === void 0 ? '' : _a, fileName = fields.fileName;
|
|
9
|
+
if (fileName) {
|
|
10
|
+
return myAtob(fields);
|
|
11
|
+
}
|
|
12
|
+
return value;
|
|
13
|
+
};
|
|
14
|
+
exports.getBinaryOrTextValue = getBinaryOrTextValue;
|
|
15
|
+
var myAtob = function (fields) {
|
|
16
|
+
var _a = fields.value, value = _a === void 0 ? '' : _a;
|
|
17
|
+
return Buffer.from(value, getEncodingFrom(value))
|
|
18
|
+
.toString(getEncodingTo(fields));
|
|
19
|
+
};
|
|
20
|
+
var getEncodingFrom = function (value) {
|
|
21
|
+
if (value === void 0) { value = ''; }
|
|
22
|
+
if (validator_1.isBase64(value)) {
|
|
23
|
+
return 'base64';
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
var getEncodingTo = function (fields) {
|
|
27
|
+
if (isToBinary(fields)) {
|
|
28
|
+
return 'binary';
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
var isToBinary = function (fields) {
|
|
32
|
+
var _a = fields.value, value = _a === void 0 ? '' : _a, fileName = fields.fileName, contentType = fields.contentType;
|
|
33
|
+
if (isAlreadyBinary(value)) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
if (fileName) {
|
|
37
|
+
var ext = getExtension(fileName);
|
|
38
|
+
if (ext) {
|
|
39
|
+
return isBinaryFileExtension(ext);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (contentType) {
|
|
43
|
+
return isBinaryContentType(contentType);
|
|
44
|
+
}
|
|
45
|
+
return false;
|
|
46
|
+
};
|
|
47
|
+
var isAlreadyBinary = function (target) {
|
|
48
|
+
if (target === void 0) { target = ''; }
|
|
49
|
+
var bytes = Buffer.from(target);
|
|
50
|
+
var size = target.length;
|
|
51
|
+
return is_binary_file_1.isBinaryFile(bytes, size);
|
|
52
|
+
};
|
|
53
|
+
var getExtension = function (fileName) {
|
|
54
|
+
return fileName.split('.').pop();
|
|
55
|
+
};
|
|
56
|
+
var isBinaryFileExtension = function (ext) {
|
|
57
|
+
return ['docx', 'pdf', 'doc', 'jpg', 'jpeg', 'png', 'xlsx', 'sdata'].includes(ext);
|
|
58
|
+
};
|
|
59
|
+
var isBinaryContentType = function (contentType) {
|
|
60
|
+
return contentType.includes('octet-stream') ||
|
|
61
|
+
['docx', 'pdf', 'bin'].includes(mime_types_1.extension(contentType) || '');
|
|
62
|
+
};
|
|
63
|
+
//# sourceMappingURL=files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.js","sourceRoot":"","sources":["../../src/multipart-form-data/files.ts"],"names":[],"mappings":";;;AAAA,yCAAuC;AACvC,uCAAqC;AAGrC,mDAAgD;AAGzC,IAAM,oBAAoB,GAAG,UAAC,MAA8B;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,CAAC,CAAC;KACzC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,IAAM,eAAe,GAAG,UAAC,MAAW;IAAX,uBAAA,EAAA,WAAW;IAClC,IAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAClC,IAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC;IAC3B,OAAO,6BAAY,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AACnC,CAAC,CAAC;AAEF,IAAM,YAAY,GAAG,UAAC,QAAgB;IACpC,OAAA,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE;AAAzB,CAAyB,CAAC;AAE5B,IAAM,qBAAqB,GAAG,UAAC,GAAW;IACxC,OAAA,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC;AAA3E,CAA2E,CAAC;AAE9E,IAAM,mBAAmB,GAAG,UAAC,WAAmB;IAC9C,OAAA,WAAW,CAAC,QAAQ,CAAC,cAAc,CAAC;QACpC,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,sBAAS,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;AAD7D,CAC6D,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { HarParam } from '../har';
|
|
2
|
+
import { multipartFormDataTextToPostFormData } from './multipart-text-to-post-form-data';
|
|
3
|
+
export declare class Form {
|
|
4
|
+
entries: HarParam[];
|
|
5
|
+
boundary: string;
|
|
6
|
+
constructor(entries?: HarParam[], boundary?: string);
|
|
7
|
+
generateBoundary: () => string;
|
|
8
|
+
append: (name: string, value: string, fileName?: string | undefined) => void;
|
|
9
|
+
toString: () => string;
|
|
10
|
+
private addFileName;
|
|
11
|
+
private addContentType;
|
|
12
|
+
}
|
|
13
|
+
export declare type FormEntry = {
|
|
14
|
+
name: string;
|
|
15
|
+
value: string;
|
|
16
|
+
[other: string]: string;
|
|
17
|
+
};
|
|
18
|
+
export declare function mapToMultipartFormData(request: any): void;
|
|
19
|
+
export { multipartFormDataTextToPostFormData };
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.multipartFormDataTextToPostFormData = exports.mapToMultipartFormData = exports.Form = void 0;
|
|
4
|
+
var files_1 = require("./files");
|
|
5
|
+
var multipart_text_to_post_form_data_1 = require("./multipart-text-to-post-form-data");
|
|
6
|
+
Object.defineProperty(exports, "multipartFormDataTextToPostFormData", { enumerable: true, get: function () { return multipart_text_to_post_form_data_1.multipartFormDataTextToPostFormData; } });
|
|
7
|
+
var Form = /** @class */ (function () {
|
|
8
|
+
function Form(entries, boundary) {
|
|
9
|
+
var _this = this;
|
|
10
|
+
Object.defineProperty(this, "entries", {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
configurable: true,
|
|
13
|
+
writable: true,
|
|
14
|
+
value: void 0
|
|
15
|
+
});
|
|
16
|
+
Object.defineProperty(this, "boundary", {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
configurable: true,
|
|
19
|
+
writable: true,
|
|
20
|
+
value: void 0
|
|
21
|
+
});
|
|
22
|
+
Object.defineProperty(this, "generateBoundary", {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
configurable: true,
|
|
25
|
+
writable: true,
|
|
26
|
+
value: function () {
|
|
27
|
+
var boundary = '-'.repeat(26);
|
|
28
|
+
for (var i = 0; i < 24; i++) {
|
|
29
|
+
boundary += Math.floor(Math.random() * 10).toString(16);
|
|
30
|
+
}
|
|
31
|
+
return boundary;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
Object.defineProperty(this, "append", {
|
|
35
|
+
enumerable: true,
|
|
36
|
+
configurable: true,
|
|
37
|
+
writable: true,
|
|
38
|
+
value: function (name, value, fileName) {
|
|
39
|
+
var entry = { name: name, value: value };
|
|
40
|
+
fileName && (entry.fileName = fileName);
|
|
41
|
+
_this.entries.push(entry);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
Object.defineProperty(this, "toString", {
|
|
45
|
+
enumerable: true,
|
|
46
|
+
configurable: true,
|
|
47
|
+
writable: true,
|
|
48
|
+
value: function () {
|
|
49
|
+
var result = '';
|
|
50
|
+
for (var _i = 0, _a = _this.entries; _i < _a.length; _i++) {
|
|
51
|
+
var _b = _a[_i], name_1 = _b.name, value = _b.value, fileName = _b.fileName, contentType = _b.contentType;
|
|
52
|
+
result += '--' + _this.boundary + '\r\n';
|
|
53
|
+
result += "Content-Disposition: form-data; name=\"" + name_1 + "\"" + _this.addFileName(fileName) + _this.addContentType(contentType) + "\r\n\r\n" + (value || '') + "\r\n";
|
|
54
|
+
}
|
|
55
|
+
result += '--' + _this.boundary + '--\r\n';
|
|
56
|
+
return result;
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
Object.defineProperty(this, "addContentType", {
|
|
60
|
+
enumerable: true,
|
|
61
|
+
configurable: true,
|
|
62
|
+
writable: true,
|
|
63
|
+
value: function (contentType) {
|
|
64
|
+
if (contentType === void 0) { contentType = ''; }
|
|
65
|
+
var formattedContentType = '';
|
|
66
|
+
if (contentType) {
|
|
67
|
+
formattedContentType = "\r\ncontent-type: " + contentType;
|
|
68
|
+
}
|
|
69
|
+
return formattedContentType;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
this.entries = entries || [];
|
|
73
|
+
this.boundary = boundary || this.generateBoundary();
|
|
74
|
+
}
|
|
75
|
+
Object.defineProperty(Form.prototype, "addFileName", {
|
|
76
|
+
enumerable: false,
|
|
77
|
+
configurable: true,
|
|
78
|
+
writable: true,
|
|
79
|
+
value: function (fileName) {
|
|
80
|
+
if (fileName === void 0) { fileName = ''; }
|
|
81
|
+
var formattedFileName = '';
|
|
82
|
+
if (fileName) {
|
|
83
|
+
formattedFileName = "; filename=\"" + fileName + "\"";
|
|
84
|
+
}
|
|
85
|
+
return formattedFileName;
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
return Form;
|
|
89
|
+
}());
|
|
90
|
+
exports.Form = Form;
|
|
91
|
+
function mapToMultipartFormData(request) {
|
|
92
|
+
var _a = request.postData, params = _a.params, text = _a.text;
|
|
93
|
+
if (text) {
|
|
94
|
+
request.postFormData = multipart_text_to_post_form_data_1.multipartFormDataTextToPostFormData(text);
|
|
95
|
+
}
|
|
96
|
+
else if (params) {
|
|
97
|
+
request.postFormData = multipartParamsToPostFormData(params);
|
|
98
|
+
}
|
|
99
|
+
delete request.postData;
|
|
100
|
+
}
|
|
101
|
+
exports.mapToMultipartFormData = mapToMultipartFormData;
|
|
102
|
+
var multipartParamsToPostFormData = function (params) {
|
|
103
|
+
if (params === void 0) { params = []; }
|
|
104
|
+
var postFormData = [];
|
|
105
|
+
for (var _i = 0, params_1 = params; _i < params_1.length; _i++) {
|
|
106
|
+
var p = params_1[_i];
|
|
107
|
+
var name_2 = p.name, _a = p.value, value = _a === void 0 ? '' : _a, fileName = p.fileName;
|
|
108
|
+
var entry = { name: name_2, value: value };
|
|
109
|
+
if (fileName) {
|
|
110
|
+
entry.fileName = fileName;
|
|
111
|
+
entry.value = files_1.getBinaryOrTextValue(p);
|
|
112
|
+
}
|
|
113
|
+
postFormData.push(entry);
|
|
114
|
+
}
|
|
115
|
+
return postFormData;
|
|
116
|
+
};
|
|
117
|
+
//# sourceMappingURL=form-data-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form-data-utils.js","sourceRoot":"","sources":["../../src/multipart-form-data/form-data-utils.ts"],"names":[],"mappings":";;;AAEA,iCAA+C;AAC/C,uFAAyF;AA8EhF,oHA9EA,sEAAmC,OA8EA;AA5E5C;IAGE,cAAY,OAAoB,EAAE,QAAiB;QAAnD,iBAGC;QALD;;;;;WAAoB;QACpB;;;;;WAAiB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