@appland/appmap 3.19.0 → 3.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +34 -0
- package/built/appmap.html +1 -1
- package/built/main.js.map +1 -1
- package/built/package.json +3 -1
- package/built/src/cmds/record/action/cancelRecording.js +14 -0
- package/built/src/cmds/record/action/cancelRecording.js.map +1 -0
- package/built/src/cmds/record/action/configureHostAndPort.js +35 -0
- package/built/src/cmds/record/action/configureHostAndPort.js.map +1 -0
- package/built/src/cmds/record/action/configureRemainingRequestOptions.js +36 -0
- package/built/src/cmds/record/action/configureRemainingRequestOptions.js.map +1 -0
- package/built/src/cmds/record/action/detectProcessCharacteristics.js +60 -0
- package/built/src/cmds/record/action/detectProcessCharacteristics.js.map +1 -0
- package/built/src/cmds/record/action/guessTestCommands.js +32 -0
- package/built/src/cmds/record/action/guessTestCommands.js.map +1 -0
- package/built/src/cmds/record/action/printAppMapCount.js +18 -0
- package/built/src/cmds/record/action/printAppMapCount.js.map +1 -0
- package/built/src/cmds/record/{createRecording.js → action/saveRecording.js} +9 -24
- package/built/src/cmds/record/action/saveRecording.js.map +1 -0
- package/built/src/cmds/record/action/startRecording.js +20 -0
- package/built/src/cmds/record/action/startRecording.js.map +1 -0
- package/built/src/cmds/record/action/startTestCases.js +24 -0
- package/built/src/cmds/record/action/startTestCases.js.map +1 -0
- package/built/src/cmds/record/action/stopRecording.js +11 -0
- package/built/src/cmds/record/action/stopRecording.js.map +1 -0
- package/built/src/cmds/record/configuration.js +145 -0
- package/built/src/cmds/record/configuration.js.map +1 -0
- package/built/src/cmds/record/prompt/obtainTestCommands.js +66 -0
- package/built/src/cmds/record/prompt/obtainTestCommands.js.map +1 -0
- package/built/src/cmds/record/prompt/recordingInProgress.js +29 -0
- package/built/src/cmds/record/prompt/recordingInProgress.js.map +1 -0
- package/built/src/cmds/record/record.js +61 -12
- package/built/src/cmds/record/record.js.map +1 -1
- package/built/src/cmds/record/state/abort.js +8 -0
- package/built/src/cmds/record/state/abort.js.map +1 -0
- package/built/src/cmds/record/state/agentAvailableAndReady.js +14 -0
- package/built/src/cmds/record/state/agentAvailableAndReady.js.map +1 -0
- package/built/src/cmds/record/state/agentIsRecording.js +45 -0
- package/built/src/cmds/record/state/agentIsRecording.js.map +1 -0
- package/built/src/cmds/record/state/agentNotAvailable.js +41 -0
- package/built/src/cmds/record/state/agentNotAvailable.js.map +1 -0
- package/built/src/cmds/record/state/agentProcessNotRunning.js +30 -0
- package/built/src/cmds/record/state/agentProcessNotRunning.js.map +1 -0
- package/built/src/cmds/record/state/initial.js +41 -0
- package/built/src/cmds/record/state/initial.js.map +1 -0
- package/built/src/cmds/record/state/record_remote.js +27 -0
- package/built/src/cmds/record/state/record_remote.js.map +1 -0
- package/built/src/cmds/record/state/record_test.js +20 -0
- package/built/src/cmds/record/state/record_test.js.map +1 -0
- package/built/src/cmds/record/state/recordingInProgress.js +14 -0
- package/built/src/cmds/record/state/recordingInProgress.js.map +1 -0
- package/built/src/cmds/record/state/recordingStopped.js +12 -0
- package/built/src/cmds/record/state/recordingStopped.js.map +1 -0
- package/built/src/cmds/record/state/testCasesComplete.js +15 -0
- package/built/src/cmds/record/state/testCasesComplete.js.map +1 -0
- package/built/src/cmds/record/state/testCasesRunning.js +13 -0
- package/built/src/cmds/record/state/testCasesRunning.js.map +1 -0
- package/built/src/cmds/record/state/testCommandsAvailable.js +14 -0
- package/built/src/cmds/record/state/testCommandsAvailable.js.map +1 -0
- package/built/src/cmds/record/state/testCommandsNeeded.js +13 -0
- package/built/src/cmds/record/state/testCommandsNeeded.js.map +1 -0
- package/built/src/cmds/record/test/areTestCommandsConfigured.js +32 -0
- package/built/src/cmds/record/test/areTestCommandsConfigured.js.map +1 -0
- package/built/src/cmds/record/test/isAgentAvailable.js +23 -0
- package/built/src/cmds/record/test/isAgentAvailable.js.map +1 -0
- package/built/src/cmds/record/test/isRecordingInProgress.js +13 -0
- package/built/src/cmds/record/test/isRecordingInProgress.js.map +1 -0
- package/built/src/cmds/record/testCaseRecording.js +111 -0
- package/built/src/cmds/record/testCaseRecording.js.map +1 -0
- package/built/src/cmds/record/types/exitCode.js +10 -0
- package/built/src/cmds/record/types/exitCode.js.map +1 -0
- package/built/src/cmds/record/types/fileName.js +3 -0
- package/built/src/cmds/record/types/fileName.js.map +1 -0
- package/built/src/cmds/record/types/remoteRecordingStatus.js +3 -0
- package/built/src/cmds/record/types/remoteRecordingStatus.js.map +1 -0
- package/built/src/cmds/record/types/state.js +3 -0
- package/built/src/cmds/record/types/state.js.map +1 -0
- package/built/src/cmds/userInteraction.js +11 -6
- package/built/src/cmds/userInteraction.js.map +1 -1
- package/built/src/openapi/command.js +33 -17
- package/built/src/openapi/command.js.map +1 -1
- package/built/src/openapi/index.js +28 -0
- package/built/src/openapi/index.js.map +1 -0
- package/built/src/openapi/method.js +54 -49
- package/built/src/openapi/method.js.map +1 -1
- package/built/src/openapi/model.js +19 -22
- package/built/src/openapi/model.js.map +1 -1
- package/built/src/openapi/objectSchema.js +47 -0
- package/built/src/openapi/objectSchema.js.map +1 -0
- package/built/src/openapi/parseHTTPServerRequests.js +11 -0
- package/built/src/openapi/parseHTTPServerRequests.js.map +1 -0
- package/built/src/openapi/path.js +13 -14
- package/built/src/openapi/path.js.map +1 -1
- package/built/src/openapi/provider.js +73 -0
- package/built/src/openapi/provider.js.map +1 -0
- package/built/src/openapi/response.js +37 -13
- package/built/src/openapi/response.js.map +1 -1
- package/built/src/openapi/rpcRequest.js +87 -0
- package/built/src/openapi/rpcRequest.js.map +1 -0
- package/built/src/openapi/schemaInferrer.js +59 -0
- package/built/src/openapi/schemaInferrer.js.map +1 -0
- package/built/src/openapi/securitySchemes.js +14 -39
- package/built/src/openapi/securitySchemes.js.map +1 -1
- package/built/src/openapi/statusCodes.js +68 -0
- package/built/src/openapi/statusCodes.js.map +1 -0
- package/built/src/openapi/util.js +67 -47
- package/built/src/openapi/util.js.map +1 -1
- package/built/src/telemetry.js.map +1 -1
- package/built/src/utils.js +1 -1
- package/built/src/utils.js.map +1 -1
- package/package.json +5 -3
- package/built/src/cmds/record/configureConnection.js +0 -16
- package/built/src/cmds/record/configureConnection.js.map +0 -1
- package/built/src/cmds/record/configureHostAndPort.js +0 -38
- package/built/src/cmds/record/configureHostAndPort.js.map +0 -1
- package/built/src/cmds/record/configureRemainingRequestOptions.js +0 -28
- package/built/src/cmds/record/configureRemainingRequestOptions.js.map +0 -1
- package/built/src/cmds/record/confirmProcessCharacteristics.js +0 -75
- package/built/src/cmds/record/confirmProcessCharacteristics.js.map +0 -1
- package/built/src/cmds/record/createRecording.js.map +0 -1
- package/built/src/cmds/record/intro.js +0 -22
- package/built/src/cmds/record/intro.js.map +0 -1
- package/built/src/cmds/record/ready.js +0 -19
- package/built/src/cmds/record/ready.js.map +0 -1
- package/built/src/cmds/record/testConnection.js +0 -35
- package/built/src/cmds/record/testConnection.js.map +0 -1
- package/built/src/openapi/schema.js +0 -34
- package/built/src/openapi/schema.js.map +0 -1
- package/built/src/openapi/settings.js +0 -10
- package/built/src/openapi/settings.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../../src/openapi/model.
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../../src/openapi/model.ts"],"names":[],"mappings":";;;;;AACA,kDAA0B;AAG1B,MAAqB,KAAK;IAA1B;QACE,UAAK,GAAyB,EAAE,CAAC;IAsCnC,CAAC;IApCC,OAAO;QACL,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;aAClC,IAAI,EAAE;aACN,MAAM,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE;YACrB,6CAA6C;YAC7C,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;YACxC,OAAO,IAAI,CAAC;QACd,CAAC,EAAE,EAA8C,CAAC,CAAC;QACrD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,aAAa,CAAC,UAAsB;QAClC,MAAM,IAAI,GAAG,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;QACpD,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE;YACrB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,cAAI,EAAE,CAAC;SAC/B;QACD,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACjC,OAAO,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IACpC,CAAC;IAED,MAAM,CAAC,QAAQ,CAAC,IAAY;QAC1B,MAAM,UAAU,GAAG,IAAI;aACpB,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;aACb,KAAK,CAAC,GAAG,CAAC;aACV,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;YACb,IAAI,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE;gBACzB,6CAA6C;gBAC7C,KAAK,GAAG,IAAI,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC;aACnC;YACD,OAAO,KAAK,CAAC;QACf,CAAC,CAAC,CAAC;QACL,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE;YAC7C,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;SACrB;QACD,OAAO,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC9B,CAAC;CACF;AAvCD,wBAuCC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const schemaInferrer_1 = __importDefault(require("./schemaInferrer"));
|
|
7
|
+
class ObjectSchema {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.examples = [];
|
|
10
|
+
}
|
|
11
|
+
addExample(message) {
|
|
12
|
+
if (!message.name) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
this.examples.push(message);
|
|
16
|
+
}
|
|
17
|
+
get empty() {
|
|
18
|
+
return this.examples.length > 0;
|
|
19
|
+
}
|
|
20
|
+
schema() {
|
|
21
|
+
const schemata = {};
|
|
22
|
+
this.examples
|
|
23
|
+
.filter((message) => message.name)
|
|
24
|
+
.sort((a, b) => a.name.localeCompare(b.name))
|
|
25
|
+
.forEach((message) => {
|
|
26
|
+
if (!schemata[message.name]) {
|
|
27
|
+
schemata[message.name] = new schemaInferrer_1.default();
|
|
28
|
+
}
|
|
29
|
+
schemata[message.name].addExample(message);
|
|
30
|
+
});
|
|
31
|
+
if (Object.keys(schemata).length === 0) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const properties = Object.keys(schemata).reduce((memo, name) => {
|
|
35
|
+
const schema = schemata[name].openapi();
|
|
36
|
+
if (schema)
|
|
37
|
+
memo[name] = schema;
|
|
38
|
+
return memo;
|
|
39
|
+
}, {});
|
|
40
|
+
return {
|
|
41
|
+
type: 'object',
|
|
42
|
+
properties,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.default = ObjectSchema;
|
|
47
|
+
//# sourceMappingURL=objectSchema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objectSchema.js","sourceRoot":"","sources":["../../../src/openapi/objectSchema.ts"],"names":[],"mappings":";;;;;AAEA,sEAA8C;AAE9C,MAAqB,YAAY;IAG/B;QACE,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;IACrB,CAAC;IAED,UAAU,CAAC,OAAwB;QACjC,IAAI,CAAC,OAAO,CAAC,IAAI,EA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AA3CD,+BA2CC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const models_1 = require("@appland/models");
|
|
4
|
+
function parseHTTPServerRequests(source, collector) {
|
|
5
|
+
const appmap = (0, models_1.buildAppMap)().source(source).normalize().build();
|
|
6
|
+
appmap.events
|
|
7
|
+
.filter((e) => e.httpServerRequest && e.httpServerResponse)
|
|
8
|
+
.forEach(collector);
|
|
9
|
+
}
|
|
10
|
+
exports.default = parseHTTPServerRequests;
|
|
11
|
+
//# sourceMappingURL=parseHTTPServerRequests.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseHTTPServerRequests.js","sourceRoot":"","sources":["../../../src/openapi/parseHTTPServerRequests.ts"],"names":[],"mappings":";;AAAA,4CAAqD;AAGrD,SAAwB,uBAAuB,CAC7C,MAAW,EACX,SAAiC;IAEjC,MAAM,MAAM,GAAG,IAAA,oBAAW,GAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,CAAC;IAEhE,MAAM,CAAC,MAAM;SACV,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,iBAAiB,IAAI,CAAC,CAAC,kBAAkB,CAAC;SAC1D,OAAO,CAAC,SAAS,CAAC,CAAC;AACxB,CAAC;AATD,0CASC"}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const method_1 = __importDefault(require("./method"));
|
|
3
7
|
class Path {
|
|
4
|
-
constructor(
|
|
5
|
-
this.securitySchemes = securitySchemes;
|
|
8
|
+
constructor() {
|
|
6
9
|
this.methods = {};
|
|
7
10
|
}
|
|
8
11
|
openapi() {
|
|
@@ -10,26 +13,22 @@ class Path {
|
|
|
10
13
|
.sort()
|
|
11
14
|
.reduce((memo, method) => {
|
|
12
15
|
// eslint-disable-next-line no-param-reassign
|
|
13
|
-
memo[method] =
|
|
16
|
+
memo[method] =
|
|
17
|
+
this.methods[method].openapi();
|
|
14
18
|
return memo;
|
|
15
19
|
}, {});
|
|
16
20
|
}
|
|
17
|
-
|
|
18
|
-
const method =
|
|
21
|
+
addRpcRequest(rpcRequest) {
|
|
22
|
+
const method = rpcRequest.requestMethod;
|
|
19
23
|
if (!method) {
|
|
20
24
|
return;
|
|
21
25
|
}
|
|
22
|
-
this.addMethod(method, event);
|
|
23
|
-
}
|
|
24
|
-
addMethod(method, event) {
|
|
25
|
-
// eslint-disable-next-line no-param-reassign
|
|
26
|
-
method = method.toLowerCase();
|
|
27
26
|
if (!this.methods[method]) {
|
|
28
|
-
this.methods[method] = new
|
|
27
|
+
this.methods[method] = new method_1.default();
|
|
29
28
|
}
|
|
30
29
|
const methodObj = this.methods[method];
|
|
31
|
-
methodObj.
|
|
30
|
+
methodObj.addRpcRequest(rpcRequest);
|
|
32
31
|
}
|
|
33
32
|
}
|
|
34
|
-
|
|
33
|
+
exports.default = Path;
|
|
35
34
|
//# sourceMappingURL=path.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"path.js","sourceRoot":"","sources":["../../../src/openapi/path.
|
|
1
|
+
{"version":3,"file":"path.js","sourceRoot":"","sources":["../../../src/openapi/path.ts"],"names":[],"mappings":";;;;;AACA,sDAA8B;AAG9B,MAAqB,IAAI;IAAzB;QACE,YAAO,GAA2B,EAAE,CAAC;IAyBvC,CAAC;IAvBC,OAAO;QACL,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC;aAC7B,IAAI,EAAE;aACN,MAAM,CAAC,CAAC,IAAI,EAAE,MAAc,EAAE,EAAE;YAC/B,6CAA6C;YAC7C,IAAI,CAAC,MAA+B,CAAC;gBACnC,IAAI,CAAC,OAAO,CAAC,MAA+B,CAAC,CAAC,OAAO,EAAE,CAAC;YAC1D,OAAO,IAAI,CAAC;QACd,CAAC,EAAE,EAA8D,CAAC,CAAC;IACvE,CAAC;IAED,aAAa,CAAC,UAAsB;QAClC,MAAM,MAAM,GAAG,UAAU,CAAC,aAAa,CAAC;QACxC,IAAI,CAAC,MAAM,EAAE;YACX,OAAO;SACR;QAED,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;YACzB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,IAAI,gBAAM,EAAE,CAAC;SACrC;QACD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACvC,SAAS,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IACtC,CAAC;CACF;AA1BD,uBA0BC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const js_yaml_1 = require("js-yaml");
|
|
7
|
+
const url_1 = require("url");
|
|
8
|
+
const http_1 = __importDefault(require("http"));
|
|
9
|
+
const https_1 = __importDefault(require("https"));
|
|
10
|
+
const promises_1 = require("fs/promises");
|
|
11
|
+
const URLLoader = (protocol) => {
|
|
12
|
+
return (url) => {
|
|
13
|
+
return new Promise((resolve, reject) => {
|
|
14
|
+
protocol
|
|
15
|
+
.get(url)
|
|
16
|
+
.on('response', (response) => {
|
|
17
|
+
if (response.statusCode !== 200) {
|
|
18
|
+
return reject(`${response.statusCode} ${response.statusMessage}`);
|
|
19
|
+
}
|
|
20
|
+
const data = [];
|
|
21
|
+
response
|
|
22
|
+
.on('data', (chunk) => {
|
|
23
|
+
data.push(Buffer.from(chunk));
|
|
24
|
+
})
|
|
25
|
+
.on('end', () => {
|
|
26
|
+
resolve(Buffer.concat(data));
|
|
27
|
+
});
|
|
28
|
+
})
|
|
29
|
+
.on('error', reject);
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
const FileLoader = (url) => {
|
|
34
|
+
return (0, promises_1.readFile)(url.pathname);
|
|
35
|
+
};
|
|
36
|
+
const ProtocolLoader = {
|
|
37
|
+
'http:': URLLoader(http_1.default),
|
|
38
|
+
'https:': URLLoader(https_1.default),
|
|
39
|
+
'file:': FileLoader,
|
|
40
|
+
};
|
|
41
|
+
const fetch = (urlStr) => {
|
|
42
|
+
const url = new url_1.URL(urlStr);
|
|
43
|
+
const loader = ProtocolLoader[url.protocol];
|
|
44
|
+
if (!loader) {
|
|
45
|
+
throw new Error(`No schema loader for protocol ${url.protocol}`);
|
|
46
|
+
}
|
|
47
|
+
return loader(url);
|
|
48
|
+
};
|
|
49
|
+
const SchemaCache = {};
|
|
50
|
+
const schemaCache = async (key, fn) => {
|
|
51
|
+
const cachedResult = SchemaCache[key];
|
|
52
|
+
if (cachedResult) {
|
|
53
|
+
return cachedResult;
|
|
54
|
+
}
|
|
55
|
+
const result = await fn(key);
|
|
56
|
+
SchemaCache[key] = result;
|
|
57
|
+
return result;
|
|
58
|
+
};
|
|
59
|
+
const fetchSchema = async (sourceURL) => {
|
|
60
|
+
return schemaCache(sourceURL, async (sourceURL) => {
|
|
61
|
+
const data = await fetch(sourceURL);
|
|
62
|
+
return (0, js_yaml_1.load)(data.toString());
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
const lookup = async (host, openapiSchemata) => {
|
|
66
|
+
const sourceURL = openapiSchemata[host];
|
|
67
|
+
if (!sourceURL) {
|
|
68
|
+
throw new Error(`No OpenAPI schema URL configured for host ${host}. Available hosts are: ${Object.keys(openapiSchemata).join(', ')}`);
|
|
69
|
+
}
|
|
70
|
+
return await fetchSchema(sourceURL);
|
|
71
|
+
};
|
|
72
|
+
exports.default = lookup;
|
|
73
|
+
//# sourceMappingURL=provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../../src/openapi/provider.ts"],"names":[],"mappings":";;;;;AAAA,qCAA+B;AAC/B,6BAA0B;AAE1B,gDAA6C;AAC7C,kDAA0B;AAC1B,0CAAuC;AAIvC,MAAM,SAAS,GAAG,CAAC,QAAa,EAAE,EAAE;IAClC,OAAO,CAAC,GAAQ,EAAmB,EAAE;QACnC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,QAAQ;iBACL,GAAG,CAAC,GAAG,CAAC;iBACR,EAAE,CAAC,UAAU,EAAE,CAAC,QAAyB,EAAE,EAAE;gBAC5C,IAAI,QAAQ,CAAC,UAAU,KAAK,GAAG,EAAE;oBAC/B,OAAO,MAAM,CAAC,GAAG,QAAQ,CAAC,UAAU,IAAI,QAAQ,CAAC,aAAa,EAAE,CAAC,CAAC;iBACnE;gBAED,MAAM,IAAI,GAAa,EAAE,CAAC;gBAC1B,QAAQ;qBACL,EAAE,CAAC,MAAM,EAAE,CAAC,KAAa,EAAE,EAAE;oBAC5B,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;gBAChC,CAAC,CAAC;qBACD,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE;oBACd,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;gBAC/B,CAAC,CAAC,CAAC;YACP,CAAC,CAAC;iBACD,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACzB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,UAAU,GAAG,CAAC,GAAQ,EAAmB,EAAE;IAC/C,OAAO,IAAA,mBAAQ,EAAC,GAAG,CAAC,QAAQ,CAAC,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eAAuC,EACV,EAAE;IAC/B,MAAM,SAAS,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;IACxC,IAAI,CAAC,SAAS,EAAE;QACd,MAAM,IAAI,KAAK,CACb,6CAA6C,IAAI,0BAA0B,MAAM,CAAC,IAAI,CACpF,eAAe,CAChB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACf,CAAC;KACH;IACD,OAAO,MAAM,WAAW,CAAC,SAAS,CAAC,CAAC;AACtC,CAAC,CAAC;AAEF,kBAAe,MAAM,CAAC"}
|
|
@@ -1,29 +1,53 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const statusCodes_1 = __importDefault(require("./statusCodes"));
|
|
7
|
+
const schemaInferrer_1 = __importDefault(require("./schemaInferrer"));
|
|
3
8
|
class Response {
|
|
4
9
|
constructor(statusCode) {
|
|
5
|
-
this.statusCode =
|
|
6
|
-
this.
|
|
10
|
+
this.statusCode = statusCode;
|
|
11
|
+
this.rpcRequests = [];
|
|
7
12
|
}
|
|
8
13
|
openapi() {
|
|
9
14
|
// eslint-disable-next-line arrow-body-style
|
|
10
|
-
const
|
|
11
|
-
return this.
|
|
12
|
-
.
|
|
13
|
-
.
|
|
15
|
+
const contentTypes = () => {
|
|
16
|
+
return this.rpcRequests
|
|
17
|
+
.map((rpcRequest) => rpcRequest.responseContentType)
|
|
18
|
+
.filter((ct) => ct)
|
|
19
|
+
.map((ct) => ct.split(';')[0]);
|
|
14
20
|
};
|
|
15
|
-
const
|
|
21
|
+
const schemata = {};
|
|
22
|
+
this.rpcRequests.forEach((rpcRequest) => {
|
|
23
|
+
const returnValue = rpcRequest.returnValue;
|
|
24
|
+
if (!returnValue)
|
|
25
|
+
return;
|
|
26
|
+
if (rpcRequest.responseContentType) {
|
|
27
|
+
const mimeType = rpcRequest.responseContentType.split(';')[0];
|
|
28
|
+
if (!schemata[mimeType]) {
|
|
29
|
+
schemata[mimeType] = new schemaInferrer_1.default();
|
|
30
|
+
}
|
|
31
|
+
schemata[mimeType].addExample(returnValue);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
const content = [...new Set(contentTypes())]
|
|
16
35
|
.sort()
|
|
17
36
|
.reduce((memo, mimeType) => {
|
|
18
|
-
// eslint-disable-next-line no-param-reassign
|
|
19
37
|
memo[mimeType] = {};
|
|
38
|
+
if (!schemata[mimeType])
|
|
39
|
+
return memo;
|
|
40
|
+
// eslint-disable-next-line no-param-reassign
|
|
41
|
+
const schema = schemata[mimeType].openapi();
|
|
42
|
+
if (schema)
|
|
43
|
+
memo[mimeType].schema = schema;
|
|
20
44
|
return memo;
|
|
21
45
|
}, {});
|
|
22
|
-
return { content, description:
|
|
46
|
+
return { content, description: statusCodes_1.default[this.statusCode] };
|
|
23
47
|
}
|
|
24
|
-
|
|
25
|
-
this.
|
|
48
|
+
addRpcRequest(rpcRequest) {
|
|
49
|
+
this.rpcRequests.push(rpcRequest);
|
|
26
50
|
}
|
|
27
51
|
}
|
|
28
|
-
|
|
52
|
+
exports.default = Response;
|
|
29
53
|
//# sourceMappingURL=response.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"response.js","sourceRoot":"","sources":["../../../src/openapi/response.
|
|
1
|
+
{"version":3,"file":"response.js","sourceRoot":"","sources":["../../../src/openapi/response.ts"],"names":[],"mappings":";;;;;AAAA,gEAAwC;AAIxC,sEAA8C;AAE9C,MAAqB,QAAQ;IAG3B,YAAmB,UAAkB;QAAlB,eAAU,GAAV,UAAU,CAAQ;QAFrC,gBAAW,GAAiB,EAAE,CAAC;IAES,CAAC;IAEzC,OAAO;QACL,4CAA4C;QAC5C,MAAM,YAAY,GAAG,GAAG,EAAE;YACxB,OAAO,IAAI,CAAC,WAAW;iBACpB,GAAG,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C,MAAM,GAAG,MAAM,CAAC;YAE3C,OAAO,IAAI,CAAC;QACd,CAAC,EAAE,EAA+C,CAAC,CAAC;QACtD,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,qBAAW,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;IAChE,CAAC;IAED,aAAa,CAAC,UAAsB;QAClC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACpC,CAAC;CACF;AAhDD,2BAgDC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.rpcRequestForEvent = void 0;
|
|
4
|
+
const url_1 = require("url");
|
|
5
|
+
const util_1 = require("./util");
|
|
6
|
+
class ServerRPCRequest {
|
|
7
|
+
constructor(event) {
|
|
8
|
+
this.event = event;
|
|
9
|
+
}
|
|
10
|
+
get status() {
|
|
11
|
+
return this.event.httpServerResponse.status;
|
|
12
|
+
}
|
|
13
|
+
get parameters() {
|
|
14
|
+
return this.event.message || [];
|
|
15
|
+
}
|
|
16
|
+
get returnValue() {
|
|
17
|
+
return this.event.returnValue;
|
|
18
|
+
}
|
|
19
|
+
get requestHeaders() {
|
|
20
|
+
var _a;
|
|
21
|
+
return ((_a = this.event.httpServerRequest) === null || _a === void 0 ? void 0 : _a.headers) || {};
|
|
22
|
+
}
|
|
23
|
+
get responseHeaders() {
|
|
24
|
+
var _a;
|
|
25
|
+
return ((_a = this.event.httpServerResponse) === null || _a === void 0 ? void 0 : _a.headers) || {};
|
|
26
|
+
}
|
|
27
|
+
get requestContentType() {
|
|
28
|
+
return this.event.requestContentType;
|
|
29
|
+
}
|
|
30
|
+
get responseContentType() {
|
|
31
|
+
return this.event.responseContentType;
|
|
32
|
+
}
|
|
33
|
+
get requestMethod() {
|
|
34
|
+
var _a;
|
|
35
|
+
return (_a = this.event.requestMethod) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
36
|
+
}
|
|
37
|
+
get requestPath() {
|
|
38
|
+
return (0, util_1.ensureString)(this.event.httpServerRequest.normalized_path_info ||
|
|
39
|
+
this.event.httpServerRequest.path_info);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
class ClientRPCRequest {
|
|
43
|
+
constructor(event) {
|
|
44
|
+
this.event = event;
|
|
45
|
+
}
|
|
46
|
+
get status() {
|
|
47
|
+
return this.event.httpClientResponse.status;
|
|
48
|
+
}
|
|
49
|
+
get parameters() {
|
|
50
|
+
return this.event.parameters || [];
|
|
51
|
+
}
|
|
52
|
+
get returnValue() {
|
|
53
|
+
return this.event.returnValue;
|
|
54
|
+
}
|
|
55
|
+
get requestHeaders() {
|
|
56
|
+
var _a;
|
|
57
|
+
return ((_a = this.event.httpClientRequest) === null || _a === void 0 ? void 0 : _a.headers) || {};
|
|
58
|
+
}
|
|
59
|
+
get responseHeaders() {
|
|
60
|
+
var _a;
|
|
61
|
+
return ((_a = this.event.httpClientResponse) === null || _a === void 0 ? void 0 : _a.headers) || {};
|
|
62
|
+
}
|
|
63
|
+
get requestContentType() {
|
|
64
|
+
return this.event.requestContentType;
|
|
65
|
+
}
|
|
66
|
+
get responseContentType() {
|
|
67
|
+
return this.event.responseContentType;
|
|
68
|
+
}
|
|
69
|
+
get requestMethod() {
|
|
70
|
+
var _a;
|
|
71
|
+
return (_a = this.event.requestMethod) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
72
|
+
}
|
|
73
|
+
get requestPath() {
|
|
74
|
+
// TODO: Back-substitute query parameters into the URL.
|
|
75
|
+
return new url_1.URL(this.event.httpClientRequest.url).pathname;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function rpcRequestForEvent(event) {
|
|
79
|
+
if (event.httpServerRequest && event.httpServerResponse) {
|
|
80
|
+
return new ServerRPCRequest(event);
|
|
81
|
+
}
|
|
82
|
+
else if (event.httpClientRequest && event.httpClientResponse) {
|
|
83
|
+
return new ClientRPCRequest(event);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
exports.rpcRequestForEvent = rpcRequestForEvent;
|
|
87
|
+
//# sourceMappingURL=rpcRequest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rpcRequest.js","sourceRoot":"","sources":["../../../src/openapi/rpcRequest.ts"],"names":[],"mappings":";;;AAEA,6BAA0B;AAC1B,iCAAsC;AActC,MAAM,gBAAgB;IACpB,YAAoB,KAAY;QAAZ,UAAK,GAAL,KAAK,CAAO;IAAG,CAAC;IAEpC,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,KAAK,CAAC,kBAAmB,CAAC,MAAM,CAAC;IAC/C,CAAC;IAED,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,EAAE,CAAC;IAClC,CAAC;IAED,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC;IAChC,CAAC;IAED,IAAI,cAAc;;QAChB,OAAO,CAAA,MAAA,IAAI,CAAC,KAAK,CAAC,iBAAiB,0CAAE,OAAO,KAAI,EAAE,CAAC;IACrD,CAAC;IAED,IAAI,eAAe;;QACjB,OAAO,CAAA,MAAA,IAAI,CAAC,KAAK,CAAC,kBAAkB,0CAAE,OAAO,KAAI,EAAE,CAAC;IACtD,CAAC;IAED,IAAI,kBAAkB;QACpB,OAAO,IAAI,CAAC,KAAK,CAAC,kBAAmB,CAAC;IACxC,CAAC;IAED,IAAI,mBAAmB;QACrB,OAAO,IAAI,CAAC,KAAK,CAAC,mBAAoB,CAAC;IACzC,CAAC;IAED,IAAI,aAAa;;QACf,OAAO,MAAA,IAAI,CAAC,KAAK,CAAC,aAAa,0CAAE,WAAW,EAA2B,CAAC;IAC1E,CAAC;IAED,IAAI,WAAW;QACb,OAAO,IAAA,mBAAY,EACjB,IAAI,CAAC,KAAK,CAAC,iBAAkB,CAAC,oBAAoB;YAChD,IAAI,CAAC,KAAK,CAAC,iBAAkB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AK,CAAC,kBAAkB,EAAE;QAC9D,OAAO,IAAI,gBAAgB,CAAC,KAAK,CAAC,CAAC;KACpC;AACH,CAAC;AAND,gDAMC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const util_1 = require("./util");
|
|
4
|
+
function mergeProperties(a, b) {
|
|
5
|
+
a || (a = {});
|
|
6
|
+
b || (b = {});
|
|
7
|
+
return Object.keys(a)
|
|
8
|
+
.concat(Object.keys(b))
|
|
9
|
+
.reduce((memo, key) => {
|
|
10
|
+
memo[key] = mergeType(a[key] || {}, b[key] || {});
|
|
11
|
+
return memo;
|
|
12
|
+
}, {});
|
|
13
|
+
}
|
|
14
|
+
// Merge type, items and properties of schema objects.
|
|
15
|
+
function mergeType(a, b) {
|
|
16
|
+
var _a, _b, _c, _d;
|
|
17
|
+
if (b === null || b === undefined)
|
|
18
|
+
return a;
|
|
19
|
+
const result = Object.assign({}, a);
|
|
20
|
+
if (!a.type) {
|
|
21
|
+
result.type = b.type;
|
|
22
|
+
}
|
|
23
|
+
else if (b.type === 'array') {
|
|
24
|
+
result.type = 'array';
|
|
25
|
+
}
|
|
26
|
+
else if (b.type === 'object') {
|
|
27
|
+
result.type = 'object';
|
|
28
|
+
}
|
|
29
|
+
if (a.items || b.items) {
|
|
30
|
+
result.items = mergeType(a.items || {}, b.items);
|
|
31
|
+
if (((_a = a.items) === null || _a === void 0 ? void 0 : _a.properties) || ((_b = b.items) === null || _b === void 0 ? void 0 : _b.properties)) {
|
|
32
|
+
result.items.properties = mergeProperties((_c = a.items) === null || _c === void 0 ? void 0 : _c.properties, (_d = b.items) === null || _d === void 0 ? void 0 : _d.properties);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
if (a.properties || b.properties) {
|
|
37
|
+
result.properties = mergeProperties(a.properties, b.properties);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
class SchemaInferrer {
|
|
43
|
+
constructor() {
|
|
44
|
+
this.examples = [];
|
|
45
|
+
}
|
|
46
|
+
openapi() {
|
|
47
|
+
if (this.examples.length === 0)
|
|
48
|
+
return;
|
|
49
|
+
return this.examples.reduce((memo, example) => {
|
|
50
|
+
const schema = (0, util_1.messageToOpenAPISchema)(example);
|
|
51
|
+
return mergeType(memo, schema);
|
|
52
|
+
}, {});
|
|
53
|
+
}
|
|
54
|
+
addExample(value) {
|
|
55
|
+
this.examples.push(value);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.default = SchemaInferrer;
|
|
59
|
+
//# sourceMappingURL=schemaInferrer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemaInferrer.js","sourceRoot":"","sources":["../../../src/openapi/schemaInferrer.ts"],"names":[],"mappings":";;AAEA,iCAAgD;AAEhD,SAAS,eAAe,CAAC,CAAM,EAAE,CAAM;IACrC,CAAC,KAAD,CAAC,GAAK,EAAE,EAAC;IACT,CAAC,KAAD,CAAC,GAAK,EAAE,EAAC;IAET,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;SAClB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACtB,MAAM,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE;QACpB,IAAI,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;QAClD,OAAO,IAAI,CAAC;IACd,CAAC,EAAE,EAAE,CAAC,CAAC;AACX,CAAC;AAED,sDAAsD;AACtD,SAAS,SAAS,CAChB,CAAM,EACN,CAAO;;IAEP,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,SAAS;QAAE,OAAO,CAAC,CAAC;IAE5C,MAAM,MAAM,GAAG,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EAAE;YAC5C,MAAM,MAAM,GAAG,IAAA,6BAAsB,EAAC,OAAO,CAAC,CAAC;YAC/C,OAAO,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACjC,CAAC,EAAE,EAAS,CAAC,CAAC;IAChB,CAAC;IAED,UAAU,CAAC,KAAgB;QACzB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;CACF;AAnBD,iCAmBC"}
|
|
@@ -1,56 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
if (tokens.length === 1) {
|
|
5
|
-
return {
|
|
6
|
-
schemeId: 'api_key',
|
|
7
|
-
scheme: {
|
|
8
|
-
type: 'apiKey',
|
|
9
|
-
name: 'authorization',
|
|
10
|
-
in: 'header',
|
|
11
|
-
},
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
const schemeId = tokens[0].toLowerCase();
|
|
15
|
-
return {
|
|
16
|
-
schemeId,
|
|
17
|
-
scheme: {
|
|
18
|
-
type: 'http',
|
|
19
|
-
scheme: schemeId,
|
|
20
|
-
},
|
|
21
|
-
};
|
|
22
|
-
}
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const util_1 = require("./util");
|
|
23
4
|
class SecuritySchemes {
|
|
24
5
|
constructor() {
|
|
25
|
-
this.
|
|
6
|
+
this.rpcRequests = [];
|
|
26
7
|
}
|
|
27
8
|
/**
|
|
28
9
|
* Adds an event to the security schemes, and assigns a security scheme id.
|
|
29
10
|
* If the event has no detectable security scheme, this function returns null.
|
|
30
11
|
*
|
|
31
|
-
* @param {Event} event
|
|
32
12
|
* @returns the security scheme id for the event, or null.
|
|
33
13
|
*/
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
if (!authorization) {
|
|
37
|
-
return null;
|
|
38
|
-
}
|
|
39
|
-
const { schemeId, scheme } = parseScheme(authorization);
|
|
40
|
-
if (!this.schemes[schemeId]) {
|
|
41
|
-
this.schemes[schemeId] = scheme;
|
|
42
|
-
}
|
|
43
|
-
return schemeId;
|
|
14
|
+
addRpcRequest(rpcRequest) {
|
|
15
|
+
this.rpcRequests.push(rpcRequest);
|
|
44
16
|
}
|
|
45
17
|
openapi() {
|
|
46
|
-
return
|
|
47
|
-
.
|
|
48
|
-
.
|
|
49
|
-
|
|
50
|
-
|
|
18
|
+
return this.rpcRequests
|
|
19
|
+
.map((rpcRequest) => rpcRequest.requestHeaders['Authorization'])
|
|
20
|
+
.filter((authorization) => authorization)
|
|
21
|
+
.reduce((memo, authorization) => {
|
|
22
|
+
const scheme = (0, util_1.parseScheme)(authorization);
|
|
23
|
+
if (!memo[scheme.schemeId]) {
|
|
24
|
+
memo[scheme.schemeId] = scheme.scheme;
|
|
25
|
+
}
|
|
51
26
|
return memo;
|
|
52
27
|
}, {});
|
|
53
28
|
}
|
|
54
29
|
}
|
|
55
|
-
|
|
30
|
+
exports.default = SecuritySchemes;
|
|
56
31
|
//# sourceMappingURL=securitySchemes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"securitySchemes.js","sourceRoot":"","sources":["../../../src/openapi/securitySchemes.
|
|
1
|
+
{"version":3,"file":"securitySchemes.js","sourceRoot":"","sources":["../../../src/openapi/securitySchemes.ts"],"names":[],"mappings":";;AAEA,iCAAqC;AAErC,MAAqB,eAAe;IAApC;QACE,gBAAW,GAAiB,EAAE,CAAC;IAwBjC,CAAC;IAtBC;;;;;OAKG;IACH,aAAa,CAAC,UAAsB;QAClC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACpC,CAAC;IAED,OAAO;QACL,OAAO,IAAI,CAAC,WAAW;aACpB,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,cAAc,CAAC,eAAe,CAAC,CAAC;aAC/D,MAAM,CAAC,CAAC,aAAa,EAAE,EAAE,CAAC,aAAa,CAAC;aACxC,MAAM,CAAC,CAAC,IAAI,EAAE,aAAa,EAAE,EAAE;YAC9B,MAAM,MAAM,GAAG,IAAA,kBAAW,EAAC,aAAa,CAAC,CAAC;YAC1C,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE;gBAC1B,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC;aACvC;YACD,OAAO,IAAI,CAAC;QACd,CAAC,EAAE,EAAoD,CAAC,CAAC;IAC7D,CAAC;CACF;AAzBD,kCAyBC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
// https://github.com/nodejs/node/blob/f1653cc9b80b521ef5b129537ce1df9098bbdc1b/lib/_http_server.js#L18-L81
|
|
4
|
+
exports.default = {
|
|
5
|
+
100: 'Continue',
|
|
6
|
+
101: 'Switching Protocols',
|
|
7
|
+
102: 'Processing',
|
|
8
|
+
200: 'OK',
|
|
9
|
+
201: 'Created',
|
|
10
|
+
202: 'Accepted',
|
|
11
|
+
203: 'Non-Authoritative Information',
|
|
12
|
+
204: 'No Content',
|
|
13
|
+
205: 'Reset Content',
|
|
14
|
+
206: 'Partial Content',
|
|
15
|
+
207: 'Multi-Status',
|
|
16
|
+
208: 'Already Reported',
|
|
17
|
+
226: 'IM Used',
|
|
18
|
+
300: 'Multiple Choices',
|
|
19
|
+
301: 'Moved Permanently',
|
|
20
|
+
302: 'Found',
|
|
21
|
+
303: 'See Other',
|
|
22
|
+
304: 'Not Modified',
|
|
23
|
+
305: 'Use Proxy',
|
|
24
|
+
307: 'Temporary Redirect',
|
|
25
|
+
308: 'Permanent Redirect',
|
|
26
|
+
400: 'Bad Request',
|
|
27
|
+
401: 'Unauthorized',
|
|
28
|
+
402: 'Payment Required',
|
|
29
|
+
403: 'Forbidden',
|
|
30
|
+
404: 'Not Found',
|
|
31
|
+
405: 'Method Not Allowed',
|
|
32
|
+
406: 'Not Acceptable',
|
|
33
|
+
407: 'Proxy Authentication Required',
|
|
34
|
+
408: 'Request Timeout',
|
|
35
|
+
409: 'Conflict',
|
|
36
|
+
410: 'Gone',
|
|
37
|
+
411: 'Length Required',
|
|
38
|
+
412: 'Precondition Failed',
|
|
39
|
+
413: 'Payload Too Large',
|
|
40
|
+
414: 'URI Too Long',
|
|
41
|
+
415: 'Unsupported Media Type',
|
|
42
|
+
416: 'Range Not Satisfiable',
|
|
43
|
+
417: 'Expectation Failed',
|
|
44
|
+
418: "I'm a teapot",
|
|
45
|
+
421: 'Misdirected Request',
|
|
46
|
+
422: 'Unprocessable Entity',
|
|
47
|
+
423: 'Locked',
|
|
48
|
+
424: 'Failed Dependency',
|
|
49
|
+
425: 'Unordered Collection',
|
|
50
|
+
426: 'Upgrade Required',
|
|
51
|
+
428: 'Precondition Required',
|
|
52
|
+
429: 'Too Many Requests',
|
|
53
|
+
431: 'Request Header Fields Too Large',
|
|
54
|
+
451: 'Unavailable For Legal Reasons',
|
|
55
|
+
500: 'Internal Server Error',
|
|
56
|
+
501: 'Not Implemented',
|
|
57
|
+
502: 'Bad Gateway',
|
|
58
|
+
503: 'Service Unavailable',
|
|
59
|
+
504: 'Gateway Timeout',
|
|
60
|
+
505: 'HTTP Version Not Supported',
|
|
61
|
+
506: 'Variant Also Negotiates',
|
|
62
|
+
507: 'Insufficient Storage',
|
|
63
|
+
508: 'Loop Detected',
|
|
64
|
+
509: 'Bandwidth Limit Exceeded',
|
|
65
|
+
510: 'Not Extended',
|
|
66
|
+
511: 'Network Authentication Required',
|
|
67
|
+
};
|
|
68
|
+
//# sourceMappingURL=statusCodes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"statusCodes.js","sourceRoot":"","sources":["../../../src/openapi/statusCodes.ts"],"names":[],"mappings":";;AAAA,2GAA2G;AAC3G,kBAAe;IACb,GAAG,EAAE,UAAU;IACf,GAAG,EAAE,qBAAqB;IAC1B,G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