@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
|
@@ -0,0 +1,111 @@
|
|
|
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 child_process_1 = require("child_process");
|
|
7
|
+
const process_1 = require("process");
|
|
8
|
+
const utils_1 = require("../../utils");
|
|
9
|
+
const userInteraction_1 = __importDefault(require("../userInteraction"));
|
|
10
|
+
const configuration_1 = require("./configuration");
|
|
11
|
+
let TestCommands = [];
|
|
12
|
+
let TestCaseProcesses = [];
|
|
13
|
+
const DiagnosticCommands = {
|
|
14
|
+
ruby: ['ruby -v', 'bundle info rails', 'bundle info actionpack'],
|
|
15
|
+
};
|
|
16
|
+
class TestCaseRecording {
|
|
17
|
+
static async start() {
|
|
18
|
+
TestCaseProcesses.forEach((process) => {
|
|
19
|
+
if (process.pid)
|
|
20
|
+
(0, process_1.kill)(process.pid);
|
|
21
|
+
});
|
|
22
|
+
TestCommands = [];
|
|
23
|
+
TestCaseProcesses = [];
|
|
24
|
+
let testCommands = (await (0, configuration_1.readConfigOption)('test_recording.test_commands', []));
|
|
25
|
+
if (testCommands.length === 0)
|
|
26
|
+
throw new Error(`No test commands are configured`);
|
|
27
|
+
if ((0, utils_1.verbose)()) {
|
|
28
|
+
const language = (await (0, configuration_1.readConfigOption)('language', 'undefined'));
|
|
29
|
+
const diagnosticCommands = DiagnosticCommands[language];
|
|
30
|
+
if (diagnosticCommands) {
|
|
31
|
+
await Promise.all(diagnosticCommands.map((cmd) => {
|
|
32
|
+
return new Promise((resolve) => {
|
|
33
|
+
const args = cmd.split(' ');
|
|
34
|
+
const process = (0, child_process_1.spawn)(args[0], args.slice(1), {
|
|
35
|
+
shell: true,
|
|
36
|
+
stdio: ['ignore', 'inherit', 'inherit'],
|
|
37
|
+
});
|
|
38
|
+
process.on('error', resolve);
|
|
39
|
+
process.on('exit', resolve);
|
|
40
|
+
});
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
TestCommands = testCommands;
|
|
45
|
+
}
|
|
46
|
+
static async waitFor() {
|
|
47
|
+
let maxTime = (await (0, configuration_1.readSetting)('test_recording.max_time', -1));
|
|
48
|
+
if (maxTime === -1)
|
|
49
|
+
maxTime = undefined;
|
|
50
|
+
if (maxTime)
|
|
51
|
+
userInteraction_1.default.progress(`Running tests for up to ${maxTime} seconds`);
|
|
52
|
+
let waitTime = maxTime;
|
|
53
|
+
async function waitForProcess(process) {
|
|
54
|
+
const commandStr = process.spawnargs.join(' ');
|
|
55
|
+
const startTime = Date.now();
|
|
56
|
+
return new Promise((resolve) => {
|
|
57
|
+
let reported = false;
|
|
58
|
+
let interruptTimeout;
|
|
59
|
+
function interrupt() {
|
|
60
|
+
if (process.pid) {
|
|
61
|
+
userInteraction_1.default.progress(`Stopping test command after ${maxTime} seconds: ${commandStr}`);
|
|
62
|
+
(0, process_1.kill)(process.pid, 'SIGTERM');
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function report(exitCode) {
|
|
66
|
+
if (reported)
|
|
67
|
+
return;
|
|
68
|
+
reported = true;
|
|
69
|
+
const elapsed = Date.now() - startTime;
|
|
70
|
+
if (waitTime) {
|
|
71
|
+
waitTime -= elapsed / 1000;
|
|
72
|
+
}
|
|
73
|
+
if (interruptTimeout)
|
|
74
|
+
clearTimeout(interruptTimeout);
|
|
75
|
+
if (exitCode && exitCode !== 0) {
|
|
76
|
+
userInteraction_1.default.progress(`Test command failed with status code ${exitCode}: ${commandStr}`);
|
|
77
|
+
}
|
|
78
|
+
resolve(exitCode);
|
|
79
|
+
}
|
|
80
|
+
if (process.exitCode)
|
|
81
|
+
return report(process.exitCode);
|
|
82
|
+
process.on('exit', report);
|
|
83
|
+
if (waitTime) {
|
|
84
|
+
interruptTimeout = setTimeout(interrupt, waitTime * 1000);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
for (const cmd of TestCommands) {
|
|
89
|
+
cmd.env || (cmd.env = {});
|
|
90
|
+
userInteraction_1.default.progress(`Running test command: ${TestCaseRecording.envString(cmd.env)}${cmd.command}`);
|
|
91
|
+
const args = cmd.command.split(' ');
|
|
92
|
+
const proc = (0, child_process_1.spawn)(args[0], args.slice(1), {
|
|
93
|
+
env: Object.assign(process.env, cmd.env),
|
|
94
|
+
shell: true,
|
|
95
|
+
stdio: ['ignore', 'inherit', 'inherit'],
|
|
96
|
+
});
|
|
97
|
+
await waitForProcess(proc);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
static envString(env) {
|
|
101
|
+
const str = Object.keys(env).length > 0
|
|
102
|
+
? Object.keys(env)
|
|
103
|
+
.sort()
|
|
104
|
+
.map((key) => [key, env[key]].join('='))
|
|
105
|
+
.join(' ')
|
|
106
|
+
: undefined;
|
|
107
|
+
return str ? `${str} ` : '';
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
exports.default = TestCaseRecording;
|
|
111
|
+
//# sourceMappingURL=testCaseRecording.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testCaseRecording.js","sourceRoot":"","sources":["../../../../src/cmds/record/testCaseRecording.ts"],"names":[],"mappings":";;;;;AAAA,iDAA0D;AAC1D,qCAA+B;AAC/B,uCAAsC;AACtC,yEAAoC;AACpC,mDAKyB;AAEzB,IAAI,YAAY,GAAkB,EAAE,CAAC;AAErC,IAAI,iBAAiB,GAAmB,EAAE,CAAC;AAE3C,MAAM,kBAAkB,GAA6B;IACnD,IAAI,EAAE,CAAC,SAAS,EAAE,mBAAmB,EAAE,wBAAwB,CAAC;CACjE,CAAC;AAEF,MAAqB,iBAAiB;IACpC,MAAM,CAAC,KAAK,CAAC,KAAK;QAChB,iBAAiB,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YACpC,IAAI,OAAO,CAAC,GAAG;gBAAE,IAAA,cAAI,EAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACrC,CAAC,CAAC,CAAC;QACH,YAAY,GAAG,EAAE,CAAC;QAClB,iBAAiB,GAAG,EAAE,CAAC;QAEvB,IAAI,YAAY,GAAG,CAAC,MAAM,IAAA,gCAAgB,EACxC,8BAA8B,EAC9B,EAAE,CACH,CAAkB,CAAC;QAEpB,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC;YAC3B,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;QAErD,IAAI,IAAA,eAAO,GAAE,EAAE;YACb,MAAM,QAAQ,GAAG,CAAC,MAAM,IAAA,gCAAgB,EACtC,UAAU,EACV,WAAW,CACZ,CAAW,CAAC;YACb,MAAM,kBAAkB,GAAG,kBAAkB,CAAC,QAAQ,CAAC,CAAC;YACxD,IAAI,kBAAkB,EAAE;gBACtB,MAAM,OAAO,C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CAAC,GAC3D,GAAG,CAAC,OACN,EAAE,CACH,CAAC;YACF,MAAM,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACpC,MAAM,IAAI,GAAG,IAAA,qBAAK,EAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;gBACzC,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC;gBACxC,KAAK,EAAE,IAAI;gBACX,KAAK,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,SAAS,CAAC;aACxC,CAAC,CAAC;YACH,MAAM,cAAc,CAAC,IAAI,CAAC,CAAC;SAC5B;IACH,CAAC;IAED,MAAM,CAAC,SAAS,CAAC,GAA2B;QAC1C,MAAM,GAAG,GACP,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC;YACzB,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;iBACb,IAAI,EAAE;iBACN,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;iBACvC,IAAI,CAAC,GAAG,CAAC;YACd,CAAC,CAAC,SAAS,CAAC;QAChB,OAAO,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAC9B,CAAC;CACF;AA5HD,oCA4HC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExitCode = void 0;
|
|
4
|
+
var ExitCode;
|
|
5
|
+
(function (ExitCode) {
|
|
6
|
+
ExitCode[ExitCode["Success"] = 0] = "Success";
|
|
7
|
+
ExitCode[ExitCode["Error"] = 1] = "Error";
|
|
8
|
+
ExitCode[ExitCode["Quit"] = 2] = "Quit";
|
|
9
|
+
})(ExitCode = exports.ExitCode || (exports.ExitCode = {}));
|
|
10
|
+
//# sourceMappingURL=exitCode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exitCode.js","sourceRoot":"","sources":["../../../../../src/cmds/record/types/exitCode.ts"],"names":[],"mappings":";;;AAAA,IAAY,QAIX;AAJD,WAAY,QAAQ;IAClB,6CAAW,CAAA;IACX,yCAAS,CAAA;IACT,uCAAQ,CAAA;AACV,CAAC,EAJW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAInB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fileName.js","sourceRoot":"","sources":["../../../../../src/cmds/record/types/fileName.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remoteRecordingStatus.js","sourceRoot":"","sources":["../../../../../src/cmds/record/types/remoteRecordingStatus.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.js","sourceRoot":"","sources":["../../../../../src/cmds/record/types/state.ts"],"names":[],"mappings":""}
|
|
@@ -24,6 +24,9 @@ class UserInteraction {
|
|
|
24
24
|
}
|
|
25
25
|
return result;
|
|
26
26
|
}
|
|
27
|
+
async confirm(msg) {
|
|
28
|
+
await inquirer_1.default.prompt({ type: 'input', name: 'confirm', message: msg });
|
|
29
|
+
}
|
|
27
30
|
progress(msg) {
|
|
28
31
|
console.log(msg);
|
|
29
32
|
}
|
|
@@ -31,12 +34,14 @@ class UserInteraction {
|
|
|
31
34
|
if (this.spinner.isSpinning) {
|
|
32
35
|
this.spinner.succeed();
|
|
33
36
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
if (msg) {
|
|
38
|
+
console.log((0, boxen_1.default)(msg, {
|
|
39
|
+
padding: 1,
|
|
40
|
+
margin: 1,
|
|
41
|
+
borderStyle: 'round',
|
|
42
|
+
align: 'center',
|
|
43
|
+
}));
|
|
44
|
+
}
|
|
40
45
|
}
|
|
41
46
|
error(msg) {
|
|
42
47
|
if (this.spinner.isSpinning) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"userInteraction.js","sourceRoot":"","sources":["../../../src/cmds/userInteraction.ts"],"names":[],"mappings":";;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"userInteraction.js","sourceRoot":"","sources":["../../../src/cmds/userInteraction.ts"],"names":[],"mappings":";;;;;;AAAA,wDAAiE;AACjE,8CAA+B;AAC/B,kDAA0B;AAC1B,oCAAmC;AAMnC,MAAa,eAAe;IAA5B;QACU,YAAO,GAAQ,IAAA,aAAG,GAAE,CAAC;IA2E/B,CAAC;IAzEC,KAAK,CAAC,MAAM,CACV,SAA6B,EAC7B,IAAqB;QAErB,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;QAC5C,IAAI,WAAW,EAAE;YACf,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;YACpB,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;SACtB;QAED,MAAM,MAAM,GAAG,MAAM,kBAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAEhD,IAAI,WAAW,IAAI,CAAC,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,cAAc,CAAA,EAAE;YACxC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;SACtB;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,GAAW;QACvB,MAAM,kBAAQ,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC;IAC1E,CAAC;IAED,QAA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AAE,CAAC;AACjC,kBAAe,EAAE,CAAC"}
|
|
@@ -1,49 +1,64 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.OpenAPICommand = void 0;
|
|
3
7
|
const path_1 = require("path");
|
|
4
8
|
const utils_1 = require("../utils");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
9
|
+
const fs_1 = require("fs");
|
|
10
|
+
const async_1 = require("async");
|
|
11
|
+
const glob_1 = require("glob");
|
|
12
|
+
const js_yaml_1 = __importDefault(require("js-yaml"));
|
|
13
|
+
const model_1 = __importDefault(require("./model"));
|
|
14
|
+
const parseHTTPServerRequests_1 = __importDefault(require("./parseHTTPServerRequests"));
|
|
15
|
+
const rpcRequest_1 = require("./rpcRequest");
|
|
16
|
+
const securitySchemes_1 = __importDefault(require("./securitySchemes"));
|
|
11
17
|
class OpenAPICommand {
|
|
12
18
|
constructor(directory) {
|
|
13
19
|
this.directory = directory;
|
|
20
|
+
this.model = new model_1.default();
|
|
21
|
+
this.securitySchemes = new securitySchemes_1.default();
|
|
22
|
+
this.count = 0;
|
|
14
23
|
}
|
|
15
24
|
async execute() {
|
|
16
|
-
|
|
17
|
-
this.model = new Model();
|
|
18
|
-
const q = queue(this.collectAppMap.bind(this), 5);
|
|
25
|
+
const q = (0, async_1.queue)(this.collectAppMap.bind(this), 5);
|
|
19
26
|
q.pause();
|
|
20
27
|
// Make sure the directory exists -- if it doesn't, the glob below just returns nothing.
|
|
21
|
-
statSync(this.directory);
|
|
22
|
-
const files = glob.sync(`${this.directory}/**/*.appmap.json`);
|
|
28
|
+
(0, fs_1.statSync)(this.directory);
|
|
29
|
+
const files = glob_1.glob.sync(`${this.directory}/**/*.appmap.json`);
|
|
23
30
|
files.forEach((f) => q.push(f));
|
|
24
31
|
await new Promise((resolve, reject) => {
|
|
25
32
|
q.drain(resolve);
|
|
26
33
|
q.error(reject);
|
|
27
34
|
q.resume();
|
|
28
35
|
});
|
|
29
|
-
return
|
|
36
|
+
return {
|
|
37
|
+
paths: this.model.openapi(),
|
|
38
|
+
securitySchemes: this.securitySchemes.openapi(),
|
|
39
|
+
};
|
|
30
40
|
}
|
|
31
41
|
async collectAppMap(file) {
|
|
32
42
|
this.count += 1;
|
|
33
43
|
try {
|
|
34
|
-
|
|
44
|
+
(0, parseHTTPServerRequests_1.default)(JSON.parse((await fs_1.promises.readFile(file)).toString()), (e) => {
|
|
45
|
+
const request = (0, rpcRequest_1.rpcRequestForEvent)(e);
|
|
46
|
+
this.model.addRpcRequest(request);
|
|
47
|
+
this.securitySchemes.addRpcRequest(request);
|
|
48
|
+
});
|
|
35
49
|
}
|
|
36
50
|
catch (e) {
|
|
37
|
-
throw new Error(`Error parsing ${file}
|
|
51
|
+
throw new Error(`Error parsing ${file}: ${e}`);
|
|
38
52
|
}
|
|
39
53
|
}
|
|
40
54
|
}
|
|
55
|
+
exports.OpenAPICommand = OpenAPICommand;
|
|
41
56
|
async function loadTemplate(fileName) {
|
|
42
57
|
if (!fileName) {
|
|
43
58
|
// eslint-disable-next-line no-param-reassign
|
|
44
59
|
fileName = (0, path_1.join)(__dirname, '../../resources/openapi-template.yaml');
|
|
45
60
|
}
|
|
46
|
-
return
|
|
61
|
+
return js_yaml_1.default.load((await fs_1.promises.readFile(fileName)).toString());
|
|
47
62
|
}
|
|
48
63
|
module.exports = {
|
|
49
64
|
command: 'openapi',
|
|
@@ -51,6 +66,7 @@ module.exports = {
|
|
|
51
66
|
describe: 'Generate OpenAPI from AppMaps in a directory',
|
|
52
67
|
builder(args) {
|
|
53
68
|
args.option('appmap-dir', {
|
|
69
|
+
alias: ['d'],
|
|
54
70
|
describe: 'directory to recursively inspect for AppMaps',
|
|
55
71
|
default: 'tmp/appmap',
|
|
56
72
|
requiresArg: true,
|
|
@@ -103,10 +119,10 @@ module.exports = {
|
|
|
103
119
|
# Customize this entire template with: --openapi-template
|
|
104
120
|
#
|
|
105
121
|
# 'paths' and 'components' will be populated automatically.
|
|
106
|
-
${
|
|
122
|
+
${js_yaml_1.default.dump(template)}
|
|
107
123
|
`;
|
|
108
124
|
if (argv.outputFile) {
|
|
109
|
-
await
|
|
125
|
+
await fs_1.promises.writeFile(argv.outputFile, fileContents);
|
|
110
126
|
}
|
|
111
127
|
else {
|
|
112
128
|
console.log(fileContents);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.js","sourceRoot":"","sources":["../../../src/openapi/command.
|
|
1
|
+
{"version":3,"file":"command.js","sourceRoot":"","sources":["../../../src/openapi/command.ts"],"names":[],"mappings":";;;;;;AAAA,+BAA4B;AAC5B,oCAAmC;AAEnC,2BAA+C;AAC/C,iCAA8B;AAC9B,+BAA4B;AAC5B,sDAA2B;AAC3B,oDAA4B;AAG5B,wFAAgE;AAChE,6CAAkD;AAClD,wEAAgD;AAEhD,MAAa,cAAc;IAMzB,YAAY,SAAiB;QAC3B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,KAAK,GAAG,IAAI,eAAK,EAAE,CAAC;QACzB,IAAI,CAAC,eAAe,GAAG,IAAI,yBAAe,EAAE,CAAC;QAC7C,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;IACjB,CAAC;IAED,KAAK,CAAC,OAAO;QACX,MAAM,CAAC,GAAG,IAAA,aAAK,EAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;QAClD,CAAC,CAAC,KAAK,EAAE,CAAC;QACV,wFAAwF;QACxF,IAAA,aAAQ,EAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACzB,MAAM,KAAK,GAAG,WAAI,CAAC,IAAI,CAAC,GAAG,IAAI,C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8C,IAAI,EAAE,CAAC,CAAC;aACpE;QACH,CAAC;QAED,MAAM,OAAO,GAAG,MAAM,IAAI,cAAc,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,CAAC;QAEnE,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QAC1D,QAAQ,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC/B,QAAQ,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;QACzC,IAAI,YAAY,EAAE;YAChB,YAAY,CAAC,YAAY,EAAE,GAAG,EAAE;gBAC9B,QAAQ,CAAC,IAAI,CAAC,KAAK,GAAG,YAAY,CAAC;YACrC,CAAC,CAAC,CAAC;SACJ;QACD,IAAI,cAAc,EAAE;YAClB,YAAY,CAAC,cAAc,EAAE,GAAG,EAAE;gBAChC,QAAQ,CAAC,IAAI,CAAC,OAAO,GAAG,cAAc,CAAC;YACzC,CAAC,CAAC,CAAC;SACJ;QAED,MAAM,YAAY,GAAG;;;;;;;EAOvB,iBAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;CACpB,CAAC;QACE,IAAI,IAAI,CAAC,UAAU,EAAE;YACnB,MAAM,aAAG,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;SACpD;aAAM;YACL,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;SAC3B;IACH,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
exports.forURL = exports.forClientRequest = void 0;
|
|
7
|
+
const provider_1 = __importDefault(require("./provider"));
|
|
8
|
+
const model_1 = __importDefault(require("./model"));
|
|
9
|
+
const securitySchemes_1 = __importDefault(require("./securitySchemes"));
|
|
10
|
+
const rpcRequest_1 = require("./rpcRequest");
|
|
11
|
+
const url_1 = require("url");
|
|
12
|
+
const forClientRequest = (event) => {
|
|
13
|
+
const rpcRequest = (0, rpcRequest_1.rpcRequestForEvent)(event);
|
|
14
|
+
if (!rpcRequest) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const securitySchemes = new securitySchemes_1.default();
|
|
18
|
+
const model = new model_1.default();
|
|
19
|
+
securitySchemes.addRpcRequest(rpcRequest);
|
|
20
|
+
model.addRpcRequest(rpcRequest);
|
|
21
|
+
return { paths: model.openapi(), securitySchemes: securitySchemes.openapi() };
|
|
22
|
+
};
|
|
23
|
+
exports.forClientRequest = forClientRequest;
|
|
24
|
+
const forURL = async (url, openapiSchemata) => {
|
|
25
|
+
return (0, provider_1.default)(new url_1.URL(url).host, openapiSchemata);
|
|
26
|
+
};
|
|
27
|
+
exports.forURL = forURL;
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/openapi/index.ts"],"names":[],"mappings":";;;;;;AAAA,0DAAkC;AAClC,oDAA4B;AAC5B,wEAAgD;AAChD,6CAAkD;AAGlD,6BAA0B;AAO1B,MAAM,gBAAgB,GAAG,CAAC,KAAY,EAAiC,EAAE;IACvE,MAAM,UAAU,GAAG,IAAA,+BAAkB,EAAC,KAAK,CAAC,CAAC;IAC7C,IAAI,CAAC,UAAU,EAAE;QACf,OAAO;KACR;IAED,MAAM,eAAe,GAAG,IAAI,yBAAe,EAAE,CAAC;IAC9C,MAAM,KAAK,GAAG,IAAI,eAAK,EAAE,CAAC;IAC1B,eAAe,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IAC1C,KAAK,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IAEhC,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE,EAAE,eAAe,EAAE,eAAe,CAAC,OAAO,EAAE,EAAE,CAAC;AAChF,CAAC,CAAC;AASO,4CAAgB;AAPzB,MAAM,MAAM,GAAG,KAAK,EAClB,GAAW,EACX,eAAuC,EACV,EAAE;IAC/B,OAAO,IAAA,kBAAQ,EAAC,IAAI,SAAG,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC;AACtD,CAAC,CAAC;AAEyB,wBAAM"}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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 response_1 = __importDefault(require("./response"));
|
|
7
|
+
const objectSchema_1 = __importDefault(require("./objectSchema"));
|
|
8
|
+
const util_1 = require("./util");
|
|
5
9
|
const bodyParamMethods = new Set(['delete', 'put', 'post', 'patch']);
|
|
6
|
-
function openapiIn(
|
|
7
|
-
const pathInfo =
|
|
10
|
+
function openapiIn(rpcRequest, name) {
|
|
11
|
+
const pathInfo = rpcRequest.requestPath;
|
|
8
12
|
// Trim format info from Rails paths, e.g. /foo/bar(.:format)
|
|
9
13
|
const tokens = pathInfo.split('/').map((token) => token.split('(')[0]);
|
|
10
14
|
// Recognize Rails-style normalized paths /org/:org_id and OpenAPI-style paths /org/{org_id}
|
|
@@ -14,45 +18,51 @@ function openapiIn(event, name) {
|
|
|
14
18
|
return 'query';
|
|
15
19
|
}
|
|
16
20
|
class Method {
|
|
17
|
-
constructor(
|
|
18
|
-
this.
|
|
21
|
+
constructor() {
|
|
22
|
+
this.rpcRequests = [];
|
|
19
23
|
this.responses = {};
|
|
20
|
-
this.events = [];
|
|
21
24
|
}
|
|
22
25
|
openapi() {
|
|
23
|
-
const
|
|
26
|
+
const responseByStatus = Object.keys(this.responses)
|
|
24
27
|
.sort()
|
|
25
|
-
.reduce((memo,
|
|
28
|
+
.reduce((memo, status) => {
|
|
26
29
|
// eslint-disable-next-line no-param-reassign
|
|
27
|
-
memo[
|
|
30
|
+
memo[status] = this.responses[status].openapi();
|
|
28
31
|
return memo;
|
|
29
32
|
}, {});
|
|
30
33
|
const schemata = {};
|
|
31
34
|
const parameters = [];
|
|
32
35
|
let securitySchemeId;
|
|
33
36
|
const uniqueNames = new Set(['controller', 'action', '_method']);
|
|
34
|
-
this.
|
|
35
|
-
const messages =
|
|
37
|
+
this.rpcRequests.forEach((rpcRequest) => {
|
|
38
|
+
const messages = rpcRequest.parameters;
|
|
36
39
|
if (!securitySchemeId) {
|
|
37
|
-
|
|
40
|
+
const authorization = rpcRequest.requestHeaders['Authorization'];
|
|
41
|
+
if (authorization) {
|
|
42
|
+
const scheme = (0, util_1.parseScheme)(authorization);
|
|
43
|
+
securitySchemeId = scheme.schemeId;
|
|
44
|
+
}
|
|
38
45
|
}
|
|
39
|
-
let schema
|
|
40
|
-
if (
|
|
41
|
-
const
|
|
42
|
-
if (!schemata[
|
|
43
|
-
schemata[
|
|
46
|
+
let schema;
|
|
47
|
+
if (rpcRequest.requestContentType) {
|
|
48
|
+
const mimeType = rpcRequest.requestContentType.split(';')[0];
|
|
49
|
+
if (!schemata[mimeType]) {
|
|
50
|
+
schemata[mimeType] = new objectSchema_1.default();
|
|
44
51
|
}
|
|
45
|
-
schema = schemata[
|
|
52
|
+
schema = schemata[mimeType];
|
|
46
53
|
}
|
|
47
54
|
messages.forEach((message) => {
|
|
55
|
+
if (!message.name) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
48
58
|
if (uniqueNames.has(message.name)) {
|
|
49
59
|
return;
|
|
50
60
|
}
|
|
51
61
|
uniqueNames.add(message.name);
|
|
52
|
-
const inLocation = openapiIn(
|
|
62
|
+
const inLocation = openapiIn(rpcRequest, message.name);
|
|
53
63
|
if (inLocation !== 'path' &&
|
|
54
|
-
|
|
55
|
-
bodyParamMethods.has(
|
|
64
|
+
rpcRequest.requestMethod &&
|
|
65
|
+
bodyParamMethods.has(rpcRequest.requestMethod)) {
|
|
56
66
|
if (schema) {
|
|
57
67
|
schema.addExample(message);
|
|
58
68
|
}
|
|
@@ -61,7 +71,7 @@ class Method {
|
|
|
61
71
|
const parameter = {
|
|
62
72
|
name: message.name,
|
|
63
73
|
in: inLocation,
|
|
64
|
-
schema: messageToOpenAPISchema(message),
|
|
74
|
+
schema: (0, util_1.messageToOpenAPISchema)(message),
|
|
65
75
|
};
|
|
66
76
|
if (parameter.in === 'path') {
|
|
67
77
|
parameter.required = true;
|
|
@@ -71,46 +81,41 @@ class Method {
|
|
|
71
81
|
});
|
|
72
82
|
});
|
|
73
83
|
const response = {
|
|
74
|
-
responses,
|
|
84
|
+
responses: responseByStatus,
|
|
75
85
|
};
|
|
76
86
|
if (securitySchemeId) {
|
|
77
87
|
const securityObj = {};
|
|
78
88
|
securityObj[securitySchemeId] = [];
|
|
79
89
|
response.security = [securityObj];
|
|
80
90
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
91
|
+
const mediaTypes = Object.keys(schemata)
|
|
92
|
+
.sort()
|
|
93
|
+
.map((contentType) => ({
|
|
94
|
+
contentType,
|
|
95
|
+
schema: schemata[contentType].schema(),
|
|
96
|
+
}))
|
|
97
|
+
.filter((entry) => entry.schema);
|
|
98
|
+
if (mediaTypes.length > 0) {
|
|
99
|
+
const content = mediaTypes.reduce((memo, entry) => {
|
|
100
|
+
memo[entry.contentType] = { schema: entry.schema };
|
|
101
|
+
return memo;
|
|
102
|
+
}, {});
|
|
103
|
+
response.requestBody = { content };
|
|
92
104
|
}
|
|
93
105
|
if (parameters.length > 0) {
|
|
94
106
|
response.parameters = parameters.sort((a, b) => a.name.localeCompare(b.name));
|
|
95
107
|
}
|
|
96
108
|
return response;
|
|
97
109
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
// eslint-disable-next-line camelcase
|
|
103
|
-
const { status, status_code: statusCode } = event.httpServerResponse;
|
|
104
|
-
this.addResponse(status || statusCode, event);
|
|
105
|
-
}
|
|
106
|
-
addResponse(status, event) {
|
|
110
|
+
addRpcRequest(request) {
|
|
111
|
+
const { status } = request;
|
|
107
112
|
if (!this.responses[status]) {
|
|
108
|
-
this.responses[status] = new
|
|
113
|
+
this.responses[status] = new response_1.default(status);
|
|
109
114
|
}
|
|
110
|
-
this.
|
|
115
|
+
this.rpcRequests.push(request);
|
|
111
116
|
const responseObj = this.responses[status];
|
|
112
|
-
responseObj.
|
|
117
|
+
responseObj.addRpcRequest(request);
|
|
113
118
|
}
|
|
114
119
|
}
|
|
115
|
-
|
|
120
|
+
exports.default = Method;
|
|
116
121
|
//# sourceMappingURL=method.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"method.js","sourceRoot":"","sources":["../../../src/openapi/method.
|
|
1
|
+
{"version":3,"file":"method.js","sourceRoot":"","sources":["../../../src/openapi/method.ts"],"names":[],"mappings":";;;;;AAEA,0DAAkC;AAElC,kEAA0C;AAC1C,iCAA6D;AAE7D,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAErE,SAAS,SAAS,CAAC,UAAsB,EAAE,IAAY;IACrD,MAAM,QAAQ,GAAG,UAAU,CAAC,WAAW,CAAC;IACxC,6DAA6D;IAC7D,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACvE,4FAA4F;IAC5F,I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C,SAAS,CAAC,MAAM,CAAC,EAAE;YAC3B,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,IAAI,kBAAQ,CAAC,MAAM,CAAC,CAAC;SAC/C;QACD,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC/B,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAC3C,WAAW,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC;CACF;AA7GD,yBA6GC"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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 path_1 = __importDefault(require("./path"));
|
|
5
7
|
class Model {
|
|
6
8
|
constructor() {
|
|
7
9
|
this.paths = {};
|
|
8
|
-
this.securitySchemes = new SecuritySchemes();
|
|
9
10
|
}
|
|
10
11
|
openapi() {
|
|
11
12
|
const paths = Object.keys(this.paths)
|
|
@@ -15,36 +16,32 @@ class Model {
|
|
|
15
16
|
memo[path] = this.paths[path].openapi();
|
|
16
17
|
return memo;
|
|
17
18
|
}, {});
|
|
18
|
-
|
|
19
|
-
return { paths, components: { securitySchemes } };
|
|
19
|
+
return paths;
|
|
20
20
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
addPath(path, event) {
|
|
21
|
+
addRpcRequest(rpcRequest) {
|
|
22
|
+
const path = Model.basePath(rpcRequest.requestPath);
|
|
25
23
|
if (!this.paths[path]) {
|
|
26
|
-
this.paths[path] = new
|
|
24
|
+
this.paths[path] = new path_1.default();
|
|
27
25
|
}
|
|
28
26
|
const pathObj = this.paths[path];
|
|
29
|
-
pathObj.
|
|
27
|
+
pathObj.addRpcRequest(rpcRequest);
|
|
30
28
|
}
|
|
31
|
-
static basePath(
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const path = pathInfo.split('/').map((entry) => {
|
|
29
|
+
static basePath(path) {
|
|
30
|
+
const pathTokens = path
|
|
31
|
+
.split('(')[0]
|
|
32
|
+
.split('/')
|
|
33
|
+
.map((entry) => {
|
|
37
34
|
if (entry.match(/^:(.*)/)) {
|
|
38
35
|
// eslint-disable-next-line no-param-reassign
|
|
39
36
|
entry = `{${entry.substring(1)}}`;
|
|
40
37
|
}
|
|
41
38
|
return entry;
|
|
42
39
|
});
|
|
43
|
-
if (
|
|
44
|
-
|
|
40
|
+
if (pathTokens.length === 1 && path[0] === '') {
|
|
41
|
+
pathTokens.push('');
|
|
45
42
|
}
|
|
46
|
-
return
|
|
43
|
+
return pathTokens.join('/');
|
|
47
44
|
}
|
|
48
45
|
}
|
|
49
|
-
|
|
46
|
+
exports.default = Model;
|
|
50
47
|
//# sourceMappingURL=model.js.map
|