@appland/appmap 3.18.3 → 3.21.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.
Files changed (105) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/built/appmap.html +1 -1
  3. package/built/main.js.LICENSE.txt +1 -1
  4. package/built/main.js.map +1 -1
  5. package/built/package.json +3 -1
  6. package/built/src/cmds/agentInstaller/gradleInstaller.js +24 -3
  7. package/built/src/cmds/agentInstaller/gradleInstaller.js.map +1 -1
  8. package/built/src/cmds/record/action/cancelRecording.js +14 -0
  9. package/built/src/cmds/record/action/cancelRecording.js.map +1 -0
  10. package/built/src/cmds/record/action/configureHostAndPort.js +35 -0
  11. package/built/src/cmds/record/action/configureHostAndPort.js.map +1 -0
  12. package/built/src/cmds/record/action/configureRemainingRequestOptions.js +36 -0
  13. package/built/src/cmds/record/action/configureRemainingRequestOptions.js.map +1 -0
  14. package/built/src/cmds/record/action/detectProcessCharacteristics.js +60 -0
  15. package/built/src/cmds/record/action/detectProcessCharacteristics.js.map +1 -0
  16. package/built/src/cmds/record/{createRecording.js → action/saveRecording.js} +9 -24
  17. package/built/src/cmds/record/action/saveRecording.js.map +1 -0
  18. package/built/src/cmds/record/action/startRecording.js +20 -0
  19. package/built/src/cmds/record/action/startRecording.js.map +1 -0
  20. package/built/src/cmds/record/action/stopRecording.js +11 -0
  21. package/built/src/cmds/record/action/stopRecording.js.map +1 -0
  22. package/built/src/cmds/record/configuration.js +126 -0
  23. package/built/src/cmds/record/configuration.js.map +1 -0
  24. package/built/src/cmds/record/prompt/recordingInProgress.js +29 -0
  25. package/built/src/cmds/record/prompt/recordingInProgress.js.map +1 -0
  26. package/built/src/cmds/record/record.js +16 -11
  27. package/built/src/cmds/record/record.js.map +1 -1
  28. package/built/src/cmds/record/state/abort.js +8 -0
  29. package/built/src/cmds/record/state/abort.js.map +1 -0
  30. package/built/src/cmds/record/state/agentAvailableAndReady.js +14 -0
  31. package/built/src/cmds/record/state/agentAvailableAndReady.js.map +1 -0
  32. package/built/src/cmds/record/state/agentIsRecording.js +45 -0
  33. package/built/src/cmds/record/state/agentIsRecording.js.map +1 -0
  34. package/built/src/cmds/record/state/agentNotAvailable.js +41 -0
  35. package/built/src/cmds/record/state/agentNotAvailable.js.map +1 -0
  36. package/built/src/cmds/record/state/agentProcessNotRunning.js +30 -0
  37. package/built/src/cmds/record/state/agentProcessNotRunning.js.map +1 -0
  38. package/built/src/cmds/record/state/initial.js +27 -0
  39. package/built/src/cmds/record/state/initial.js.map +1 -0
  40. package/built/src/cmds/record/state/recordingInProgress.js +14 -0
  41. package/built/src/cmds/record/state/recordingInProgress.js.map +1 -0
  42. package/built/src/cmds/record/state/recordingStopped.js +12 -0
  43. package/built/src/cmds/record/state/recordingStopped.js.map +1 -0
  44. package/built/src/cmds/record/test/isAgentAvailable.js +23 -0
  45. package/built/src/cmds/record/test/isAgentAvailable.js.map +1 -0
  46. package/built/src/cmds/record/test/isRecordingInProgress.js +13 -0
  47. package/built/src/cmds/record/test/isRecordingInProgress.js.map +1 -0
  48. package/built/src/cmds/record/types/exitCode.js +10 -0
  49. package/built/src/cmds/record/types/exitCode.js.map +1 -0
  50. package/built/src/cmds/record/types/fileName.js +3 -0
  51. package/built/src/cmds/record/types/fileName.js.map +1 -0
  52. package/built/src/cmds/record/types/remoteRecordingStatus.js +3 -0
  53. package/built/src/cmds/record/types/remoteRecordingStatus.js.map +1 -0
  54. package/built/src/cmds/record/types/state.js +3 -0
  55. package/built/src/cmds/record/types/state.js.map +1 -0
  56. package/built/src/cmds/userInteraction.js +11 -6
  57. package/built/src/cmds/userInteraction.js.map +1 -1
  58. package/built/src/openapi/command.js +33 -17
  59. package/built/src/openapi/command.js.map +1 -1
  60. package/built/src/openapi/index.js +28 -0
  61. package/built/src/openapi/index.js.map +1 -0
  62. package/built/src/openapi/method.js +54 -49
  63. package/built/src/openapi/method.js.map +1 -1
  64. package/built/src/openapi/model.js +19 -22
  65. package/built/src/openapi/model.js.map +1 -1
  66. package/built/src/openapi/objectSchema.js +47 -0
  67. package/built/src/openapi/objectSchema.js.map +1 -0
  68. package/built/src/openapi/parseHTTPServerRequests.js +11 -0
  69. package/built/src/openapi/parseHTTPServerRequests.js.map +1 -0
  70. package/built/src/openapi/path.js +13 -14
  71. package/built/src/openapi/path.js.map +1 -1
  72. package/built/src/openapi/provider.js +73 -0
  73. package/built/src/openapi/provider.js.map +1 -0
  74. package/built/src/openapi/response.js +37 -13
  75. package/built/src/openapi/response.js.map +1 -1
  76. package/built/src/openapi/rpcRequest.js +87 -0
  77. package/built/src/openapi/rpcRequest.js.map +1 -0
  78. package/built/src/openapi/schemaInferrer.js +59 -0
  79. package/built/src/openapi/schemaInferrer.js.map +1 -0
  80. package/built/src/openapi/securitySchemes.js +14 -39
  81. package/built/src/openapi/securitySchemes.js.map +1 -1
  82. package/built/src/openapi/statusCodes.js +68 -0
  83. package/built/src/openapi/statusCodes.js.map +1 -0
  84. package/built/src/openapi/util.js +67 -47
  85. package/built/src/openapi/util.js.map +1 -1
  86. package/package.json +5 -3
  87. package/built/src/cmds/record/configureConnection.js +0 -16
  88. package/built/src/cmds/record/configureConnection.js.map +0 -1
  89. package/built/src/cmds/record/configureHostAndPort.js +0 -38
  90. package/built/src/cmds/record/configureHostAndPort.js.map +0 -1
  91. package/built/src/cmds/record/configureRemainingRequestOptions.js +0 -28
  92. package/built/src/cmds/record/configureRemainingRequestOptions.js.map +0 -1
  93. package/built/src/cmds/record/confirmProcessCharacteristics.js +0 -75
  94. package/built/src/cmds/record/confirmProcessCharacteristics.js.map +0 -1
  95. package/built/src/cmds/record/createRecording.js.map +0 -1
  96. package/built/src/cmds/record/intro.js +0 -22
  97. package/built/src/cmds/record/intro.js.map +0 -1
  98. package/built/src/cmds/record/ready.js +0 -19
  99. package/built/src/cmds/record/ready.js.map +0 -1
  100. package/built/src/cmds/record/testConnection.js +0 -35
  101. package/built/src/cmds/record/testConnection.js.map +0 -1
  102. package/built/src/openapi/schema.js +0 -34
  103. package/built/src/openapi/schema.js.map +0 -1
  104. package/built/src/openapi/settings.js +0 -10
  105. package/built/src/openapi/settings.js.map +0 -1
@@ -1,10 +1,14 @@
1
1
  "use strict";
2
- const Response = require('./response');
3
- const Schema = require('./schema');
4
- const { messageToOpenAPISchema, bestPathInfo } = require('./util');
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(event, name) {
7
- const pathInfo = bestPathInfo(event.httpServerRequest);
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(securitySchemes) {
18
- this.securitySchemes = securitySchemes;
21
+ constructor() {
22
+ this.rpcRequests = [];
19
23
  this.responses = {};
20
- this.events = [];
21
24
  }
22
25
  openapi() {
23
- const responses = Object.keys(this.responses)
26
+ const responseByStatus = Object.keys(this.responses)
24
27
  .sort()
25
- .reduce((memo, response) => {
28
+ .reduce((memo, status) => {
26
29
  // eslint-disable-next-line no-param-reassign
27
- memo[response] = this.responses[response].openapi();
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.events.forEach((event) => {
35
- const messages = event.message || [];
37
+ this.rpcRequests.forEach((rpcRequest) => {
38
+ const messages = rpcRequest.parameters;
36
39
  if (!securitySchemeId) {
37
- securitySchemeId = this.securitySchemes.addRequest(event);
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 = null;
40
- if (event.requestContentType) {
41
- const contentType = event.requestContentType.split(';')[0];
42
- if (!schemata[contentType]) {
43
- schemata[contentType] = new Schema();
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[contentType];
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(event, message.name);
62
+ const inLocation = openapiIn(rpcRequest, message.name);
53
63
  if (inLocation !== 'path' &&
54
- event.httpServerRequest.request_method &&
55
- bodyParamMethods.has(event.httpServerRequest.request_method.toLowerCase())) {
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
- if (Object.keys(schemata).length > 0) {
82
- response.requestBody = { content: {} };
83
- Object.keys(schemata)
84
- .sort()
85
- .forEach((contentType) => {
86
- const schema = schemata[contentType].schema();
87
- if (!schema) {
88
- return;
89
- }
90
- response.requestBody.content[contentType] = { schema };
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
- addRequest(event) {
99
- if (!event.httpServerResponse) {
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 Response(status);
113
+ this.responses[status] = new response_1.default(status);
109
114
  }
110
- this.events.push(event);
115
+ this.rpcRequests.push(request);
111
116
  const responseObj = this.responses[status];
112
- responseObj.addRequest(event);
117
+ responseObj.addRpcRequest(request);
113
118
  }
114
119
  }
115
- module.exports = Method;
120
+ exports.default = Method;
116
121
  //# sourceMappingURL=method.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"method.js","sourceRoot":"","sources":["../../../src/openapi/method.js"],"names":[],"mappings":";AAAA,MAAM,QAAQ,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;AACvC,MAAM,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACnC,MAAM,EAAE,sBAAsB,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC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aAAa,CAAC,OAAmB;QAC/B,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;QAC3B,IAAI,CAAC,IAAI,CAAC,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
- const Path = require('./path');
3
- const SecuritySchemes = require('./securitySchemes');
4
- const { bestPathInfo } = require('./util');
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
- const securitySchemes = this.securitySchemes.openapi();
19
- return { paths, components: { securitySchemes } };
19
+ return paths;
20
20
  }
21
- addRequest(event) {
22
- this.addPath(Model.basePath(event), event);
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 Path(this.securitySchemes);
24
+ this.paths[path] = new path_1.default();
27
25
  }
28
26
  const pathObj = this.paths[path];
29
- pathObj.addRequest(event);
27
+ pathObj.addRpcRequest(rpcRequest);
30
28
  }
31
- static basePath(event) {
32
- const { httpServerRequest } = event;
33
- let pathInfo = bestPathInfo(httpServerRequest);
34
- // eslint-disable-next-line prefer-destructuring
35
- pathInfo = pathInfo.split('(')[0];
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 (path.length === 1 && path[0] === '') {
44
- path.push('');
40
+ if (pathTokens.length === 1 && path[0] === '') {
41
+ pathTokens.push('');
45
42
  }
46
- return path.join('/');
43
+ return pathTokens.join('/');
47
44
  }
48
45
  }
49
- module.exports = Model;
46
+ exports.default = Model;
50
47
  //# sourceMappingURL=model.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"model.js","sourceRoot":"","sources":["../../../src/openapi/model.js"],"names":[],"mappings":";AAAA,MAAM,IAAI,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC/B,MAAM,eAAe,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AACrD,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAE3C,MAAM,KAAK;IACT;QACE,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;QAChB,IAAI,CAAC,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC;IAC/C,CAAC;IAED,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,E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AAC,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
+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E,EAAE;YAC7D,MAAM,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;YACxC,IAAI,MAAM;gBAAE,IAAI,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;YAChC,OAAO,IAAI,CAAC;QACd,CAAC,EAAE,EAA4C,CAAC,CAAC;QACjD,OAAO;YACL,IAAI,EAAE,QAAQ;YACd,UAAU;SACX,CAAC;IACJ,CAAC;CACF;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
- const Method = require('./method');
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(securitySchemes) {
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] = this.methods[method].openapi();
16
+ memo[method] =
17
+ this.methods[method].openapi();
14
18
  return memo;
15
19
  }, {});
16
20
  }
17
- addRequest(event) {
18
- const method = event.httpServerRequest.request_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 Method(this.securitySchemes);
27
+ this.methods[method] = new method_1.default();
29
28
  }
30
29
  const methodObj = this.methods[method];
31
- methodObj.addRequest(event);
30
+ methodObj.addRpcRequest(rpcRequest);
32
31
  }
33
32
  }
34
- module.exports = Path;
33
+ exports.default = Path;
35
34
  //# sourceMappingURL=path.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"path.js","sourceRoot":"","sources":["../../../src/openapi/path.js"],"names":[],"mappings":";AAAA,MAAM,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAEnC,MAAM,IAAI;IACR,YAAY,eAAe;QACzB,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;IACpB,CAAC;IAED,OAAO;QACL,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC;aAC7B,IAAI,EAAE;aACN,MAAM,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE;YACvB,6CAA6C;YAC7C,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,OAAO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;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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EAAE;QAChB,OAAO,YAAY,CAAC;KACrB;IAED,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC;IAC7B,WAAW,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC;IAC1B,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEF,MAAM,WAAW,GAAG,KAAK,EAAE,SAAiB,EAA+B,EAAE;IAC3E,OAAO,WAAW,CAAC,SAAS,EAAE,KAAK,EAAE,SAAiB,EAAE,EAAE;QACxD,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,SAAS,CAAC,CAAC;QACpC,OAAO,IAAA,cAAI,EAAC,IAAI,CAAC,QAAQ,EAAE,CAAuB,CAAC;IACrD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,MAAM,GAAG,KAAK,EAClB,IAAY,EACZ,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
- const { STATUS_CODES } = require('http');
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 = parseInt(`${statusCode}`, 10);
6
- this.events = [];
10
+ this.statusCode = statusCode;
11
+ this.rpcRequests = [];
7
12
  }
8
13
  openapi() {
9
14
  // eslint-disable-next-line arrow-body-style
10
- const mimeTypes = () => {
11
- return this.events
12
- .filter((event) => event.httpServerResponse && event.responseContentType)
13
- .map((event) => event.responseContentType.split(';')[0]);
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 content = [...new Set(mimeTypes())]
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: STATUS_CODES[this.statusCode] };
46
+ return { content, description: statusCodes_1.default[this.statusCode] };
23
47
  }
24
- addRequest(event) {
25
- this.events.push(event);
48
+ addRpcRequest(rpcRequest) {
49
+ this.rpcRequests.push(rpcRequest);
26
50
  }
27
51
  }
28
- module.exports = Response;
52
+ exports.default = Response;
29
53
  //# sourceMappingURL=response.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"response.js","sourceRoot":"","sources":["../../../src/openapi/response.js"],"names":[],"mappings":";AAAA,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AAEzC,MAAM,QAAQ;IACZ,YAAY,UAAU;Q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C,QAAQ,CAAC,CAAC,OAAO,EAAE,CAAC;YAC5C,IAAI,MAAM;gBAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,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