@aws/lsp-codewhisperer 0.0.9 → 0.0.10

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 (263) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/node_modules/@amzn/codewhisperer-streaming/package.json +4 -4
  3. package/node_modules/@aws/lsp-fqn/out/common/commonFqnWorkerPool.js +12 -25
  4. package/node_modules/@aws/lsp-fqn/out/common/commonFqnWorkerPool.js.map +1 -1
  5. package/node_modules/@aws/lsp-fqn/out/common/fqnExtractor.js +1 -2
  6. package/node_modules/@aws/lsp-fqn/out/common/fqnExtractor.js.map +1 -1
  7. package/node_modules/@aws/lsp-fqn/package.json +1 -1
  8. package/node_modules/@aws/lsp-fqn/tsconfig.tsbuildinfo +1 -1
  9. package/out/client/streamingClient/codewhispererStreamingClient.d.ts +5 -0
  10. package/out/client/streamingClient/codewhispererStreamingClient.js +25 -0
  11. package/out/client/streamingClient/codewhispererStreamingClient.js.map +1 -0
  12. package/out/client/token/bearer-token-service.json +55 -2
  13. package/out/index.d.ts +1 -0
  14. package/out/index.js +1 -0
  15. package/out/index.js.map +1 -1
  16. package/out/language-server/chat/chatController.js +104 -108
  17. package/out/language-server/chat/chatController.js.map +1 -1
  18. package/out/language-server/chat/chatController.test.js +16 -1
  19. package/out/language-server/chat/chatController.test.js.map +1 -1
  20. package/out/language-server/chat/chatEventParser.js +28 -34
  21. package/out/language-server/chat/chatEventParser.js.map +1 -1
  22. package/out/language-server/chat/chatSessionManagementService.js +22 -36
  23. package/out/language-server/chat/chatSessionManagementService.js.map +1 -1
  24. package/out/language-server/chat/chatSessionService.js +24 -37
  25. package/out/language-server/chat/chatSessionService.js.map +1 -1
  26. package/out/language-server/chat/constants.d.ts +2 -0
  27. package/out/language-server/chat/constants.js +32 -0
  28. package/out/language-server/chat/constants.js.map +1 -0
  29. package/out/language-server/chat/contexts/documentContext.js +11 -24
  30. package/out/language-server/chat/contexts/documentContext.js.map +1 -1
  31. package/out/language-server/chat/contexts/documentFqnExtractor.js +67 -78
  32. package/out/language-server/chat/contexts/documentFqnExtractor.js.map +1 -1
  33. package/out/language-server/chat/contexts/triggerContext.js +32 -44
  34. package/out/language-server/chat/contexts/triggerContext.js.map +1 -1
  35. package/out/language-server/chat/quickActions.d.ts +0 -1
  36. package/out/language-server/chat/quickActions.js +1 -28
  37. package/out/language-server/chat/quickActions.js.map +1 -1
  38. package/out/language-server/chat/telemetry/chatTelemetryController.js +114 -126
  39. package/out/language-server/chat/telemetry/chatTelemetryController.js.map +1 -1
  40. package/out/language-server/chat/utils.d.ts +6 -0
  41. package/out/language-server/chat/utils.js +60 -0
  42. package/out/language-server/chat/utils.js.map +1 -0
  43. package/out/language-server/codeWhispererService.js +13 -11
  44. package/out/language-server/codeWhispererService.js.map +1 -1
  45. package/out/language-server/constants.d.ts +3 -0
  46. package/out/language-server/constants.js +7 -0
  47. package/out/language-server/constants.js.map +1 -0
  48. package/out/language-server/dependencyGraph/csharpDependencyGraph.js +2 -2
  49. package/out/language-server/dependencyGraph/csharpDependencyGraph.js.map +1 -1
  50. package/out/language-server/dependencyGraph/dependencyGraph.js +12 -9
  51. package/out/language-server/dependencyGraph/dependencyGraph.js.map +1 -1
  52. package/out/language-server/dependencyGraph/gitIgnoreFilter.js +1 -0
  53. package/out/language-server/dependencyGraph/gitIgnoreFilter.js.map +1 -1
  54. package/out/language-server/netTransform/artifactManager.d.ts +29 -0
  55. package/out/language-server/netTransform/artifactManager.js +191 -0
  56. package/out/language-server/netTransform/artifactManager.js.map +1 -0
  57. package/out/language-server/netTransform/converter.d.ts +7 -0
  58. package/out/language-server/netTransform/converter.js +88 -0
  59. package/out/language-server/netTransform/converter.js.map +1 -0
  60. package/out/language-server/netTransform/metrics.d.ts +17 -0
  61. package/out/language-server/netTransform/metrics.js +222 -0
  62. package/out/language-server/netTransform/metrics.js.map +1 -0
  63. package/out/language-server/netTransform/models.d.ts +84 -0
  64. package/out/language-server/netTransform/models.js +12 -0
  65. package/out/language-server/netTransform/models.js.map +1 -0
  66. package/out/language-server/netTransform/resources/SupportedProjects.d.ts +2 -0
  67. package/out/language-server/netTransform/resources/SupportedProjects.js +26 -0
  68. package/out/language-server/netTransform/resources/SupportedProjects.js.map +1 -0
  69. package/out/language-server/netTransform/tests/converter.test.d.ts +1 -0
  70. package/out/language-server/netTransform/tests/converter.test.js +151 -0
  71. package/out/language-server/netTransform/tests/converter.test.js.map +1 -0
  72. package/out/language-server/netTransform/tests/mockData.d.ts +21 -0
  73. package/out/language-server/netTransform/tests/mockData.js +60 -0
  74. package/out/language-server/netTransform/tests/mockData.js.map +1 -0
  75. package/out/language-server/netTransform/tests/transformHandler.test.d.ts +1 -0
  76. package/out/language-server/netTransform/tests/transformHandler.test.js +242 -0
  77. package/out/language-server/netTransform/tests/transformHandler.test.js.map +1 -0
  78. package/out/language-server/netTransform/tests/validation.test.d.ts +1 -0
  79. package/out/language-server/netTransform/tests/validation.test.js +80 -0
  80. package/out/language-server/netTransform/tests/validation.test.js.map +1 -0
  81. package/out/language-server/netTransform/transformHandler.d.ts +27 -0
  82. package/out/language-server/netTransform/transformHandler.js +315 -0
  83. package/out/language-server/netTransform/transformHandler.js.map +1 -0
  84. package/out/language-server/netTransform/validation.d.ts +9 -0
  85. package/out/language-server/netTransform/validation.js +79 -0
  86. package/out/language-server/netTransform/validation.js.map +1 -0
  87. package/out/language-server/netTransformServer.d.ts +5 -6
  88. package/out/language-server/netTransformServer.js +149 -15
  89. package/out/language-server/netTransformServer.js.map +1 -1
  90. package/out/language-server/proxy-server.d.ts +1 -0
  91. package/out/language-server/proxy-server.js +16 -1
  92. package/out/language-server/proxy-server.js.map +1 -1
  93. package/out/language-server/securityScan/securityScanDiagnosticsProvider.js +10 -6
  94. package/out/language-server/securityScan/securityScanDiagnosticsProvider.js.map +1 -1
  95. package/out/language-server/securityScan/securityScanHandler.js +4 -0
  96. package/out/language-server/securityScan/securityScanHandler.js.map +1 -1
  97. package/out/language-server/session/sessionManager.js +35 -15
  98. package/out/language-server/session/sessionManager.js.map +1 -1
  99. package/out/language-server/telemetry/codeDiffTracker.js +69 -80
  100. package/out/language-server/telemetry/codeDiffTracker.js.map +1 -1
  101. package/out/language-server/telemetry/codePercentage.js +3 -0
  102. package/out/language-server/telemetry/codePercentage.js.map +1 -1
  103. package/out/language-server/telemetry/metric.js +8 -21
  104. package/out/language-server/telemetry/metric.js.map +1 -1
  105. package/out/language-server/telemetry/types.d.ts +38 -0
  106. package/out/language-server/telemetry/types.js.map +1 -1
  107. package/out/language-server/utils.d.ts +2 -5
  108. package/out/language-server/utils.js +25 -49
  109. package/out/language-server/utils.js.map +1 -1
  110. package/package.json +5 -2
  111. package/node_modules/@aws/lsp-fqn/node_modules/workerpool/HISTORY.md +0 -395
  112. package/node_modules/@aws/lsp-fqn/node_modules/workerpool/LICENSE +0 -201
  113. package/node_modules/@aws/lsp-fqn/node_modules/workerpool/README.md +0 -530
  114. package/node_modules/@aws/lsp-fqn/node_modules/workerpool/dist/worker.js +0 -288
  115. package/node_modules/@aws/lsp-fqn/node_modules/workerpool/dist/worker.js.map +0 -1
  116. package/node_modules/@aws/lsp-fqn/node_modules/workerpool/dist/worker.min.js +0 -2
  117. package/node_modules/@aws/lsp-fqn/node_modules/workerpool/dist/worker.min.js.map +0 -1
  118. package/node_modules/@aws/lsp-fqn/node_modules/workerpool/dist/workerpool.js +0 -1737
  119. package/node_modules/@aws/lsp-fqn/node_modules/workerpool/dist/workerpool.js.map +0 -1
  120. package/node_modules/@aws/lsp-fqn/node_modules/workerpool/dist/workerpool.min.js +0 -3
  121. package/node_modules/@aws/lsp-fqn/node_modules/workerpool/dist/workerpool.min.js.LICENSE.txt +0 -24
  122. package/node_modules/@aws/lsp-fqn/node_modules/workerpool/dist/workerpool.min.js.map +0 -1
  123. package/node_modules/@aws/lsp-fqn/node_modules/workerpool/package.json +0 -57
  124. package/node_modules/@aws/lsp-fqn/node_modules/workerpool/src/Pool.js +0 -476
  125. package/node_modules/@aws/lsp-fqn/node_modules/workerpool/src/Promise.js +0 -293
  126. package/node_modules/@aws/lsp-fqn/node_modules/workerpool/src/WorkerHandler.js +0 -547
  127. package/node_modules/@aws/lsp-fqn/node_modules/workerpool/src/debug-port-allocator.js +0 -28
  128. package/node_modules/@aws/lsp-fqn/node_modules/workerpool/src/environment.js +0 -30
  129. package/node_modules/@aws/lsp-fqn/node_modules/workerpool/src/generated/embeddedWorker.js +0 -6
  130. package/node_modules/@aws/lsp-fqn/node_modules/workerpool/src/header.js +0 -24
  131. package/node_modules/@aws/lsp-fqn/node_modules/workerpool/src/index.js +0 -60
  132. package/node_modules/@aws/lsp-fqn/node_modules/workerpool/src/requireFoolWebpack.js +0 -8
  133. package/node_modules/@aws/lsp-fqn/node_modules/workerpool/src/transfer.js +0 -12
  134. package/node_modules/@aws/lsp-fqn/node_modules/workerpool/src/types.js +0 -46
  135. package/node_modules/@aws/lsp-fqn/node_modules/workerpool/src/validateOptions.js +0 -51
  136. package/node_modules/@aws/lsp-fqn/node_modules/workerpool/src/worker.js +0 -256
  137. package/node_modules/@aws/lsp-fqn/node_modules/workerpool/types/Pool.d.ts +0 -130
  138. package/node_modules/@aws/lsp-fqn/node_modules/workerpool/types/Promise.d.ts +0 -125
  139. package/node_modules/@aws/lsp-fqn/node_modules/workerpool/types/WorkerHandler.d.ts +0 -89
  140. package/node_modules/@aws/lsp-fqn/node_modules/workerpool/types/debug-port-allocator.d.ts +0 -8
  141. package/node_modules/@aws/lsp-fqn/node_modules/workerpool/types/environment.d.ts +0 -4
  142. package/node_modules/@aws/lsp-fqn/node_modules/workerpool/types/generated/embeddedWorker.d.ts +0 -2
  143. package/node_modules/@aws/lsp-fqn/node_modules/workerpool/types/index.d.ts +0 -43
  144. package/node_modules/@aws/lsp-fqn/node_modules/workerpool/types/transfer.d.ts +0 -19
  145. package/node_modules/@aws/lsp-fqn/node_modules/workerpool/types/types.d.ts +0 -99
  146. package/node_modules/@aws/lsp-fqn/node_modules/workerpool/types/validateOptions.d.ts +0 -4
  147. package/node_modules/@aws/lsp-fqn/node_modules/workerpool/types/worker.d.ts +0 -8
  148. package/node_modules/@smithy/eventstream-serde-config-resolver/LICENSE +0 -201
  149. package/node_modules/@smithy/eventstream-serde-config-resolver/README.md +0 -10
  150. package/node_modules/@smithy/eventstream-serde-config-resolver/dist-cjs/EventStreamSerdeConfig.js +0 -1
  151. package/node_modules/@smithy/eventstream-serde-config-resolver/dist-cjs/index.js +0 -37
  152. package/node_modules/@smithy/eventstream-serde-config-resolver/dist-es/EventStreamSerdeConfig.js +0 -4
  153. package/node_modules/@smithy/eventstream-serde-config-resolver/dist-es/index.js +0 -1
  154. package/node_modules/@smithy/eventstream-serde-config-resolver/dist-types/EventStreamSerdeConfig.d.ts +0 -24
  155. package/node_modules/@smithy/eventstream-serde-config-resolver/dist-types/index.d.ts +0 -4
  156. package/node_modules/@smithy/eventstream-serde-config-resolver/dist-types/ts3.4/EventStreamSerdeConfig.d.ts +0 -24
  157. package/node_modules/@smithy/eventstream-serde-config-resolver/dist-types/ts3.4/index.d.ts +0 -4
  158. package/node_modules/@smithy/eventstream-serde-config-resolver/package.json +0 -61
  159. package/node_modules/bowser/CHANGELOG.md +0 -218
  160. package/node_modules/bowser/LICENSE +0 -39
  161. package/node_modules/bowser/README.md +0 -179
  162. package/node_modules/bowser/bundled.js +0 -1
  163. package/node_modules/bowser/es5.js +0 -1
  164. package/node_modules/bowser/index.d.ts +0 -250
  165. package/node_modules/bowser/package.json +0 -83
  166. package/node_modules/bowser/src/bowser.js +0 -77
  167. package/node_modules/bowser/src/constants.js +0 -116
  168. package/node_modules/bowser/src/parser-browsers.js +0 -700
  169. package/node_modules/bowser/src/parser-engines.js +0 -120
  170. package/node_modules/bowser/src/parser-os.js +0 -199
  171. package/node_modules/bowser/src/parser-platforms.js +0 -266
  172. package/node_modules/bowser/src/parser.js +0 -496
  173. package/node_modules/bowser/src/utils.js +0 -309
  174. package/node_modules/tslib/CopyrightNotice.txt +0 -15
  175. package/node_modules/tslib/LICENSE.txt +0 -12
  176. package/node_modules/tslib/README.md +0 -164
  177. package/node_modules/tslib/SECURITY.md +0 -41
  178. package/node_modules/tslib/modules/index.d.ts +0 -37
  179. package/node_modules/tslib/modules/index.js +0 -68
  180. package/node_modules/tslib/modules/package.json +0 -3
  181. package/node_modules/tslib/package.json +0 -47
  182. package/node_modules/tslib/tslib.d.ts +0 -453
  183. package/node_modules/tslib/tslib.es6.html +0 -1
  184. package/node_modules/tslib/tslib.es6.js +0 -374
  185. package/node_modules/tslib/tslib.es6.mjs +0 -373
  186. package/node_modules/tslib/tslib.html +0 -1
  187. package/node_modules/tslib/tslib.js +0 -424
  188. package/node_modules/uuid/CHANGELOG.md +0 -274
  189. package/node_modules/uuid/CONTRIBUTING.md +0 -18
  190. package/node_modules/uuid/LICENSE.md +0 -9
  191. package/node_modules/uuid/README.md +0 -466
  192. package/node_modules/uuid/dist/bin/uuid +0 -2
  193. package/node_modules/uuid/dist/commonjs-browser/index.js +0 -79
  194. package/node_modules/uuid/dist/commonjs-browser/md5.js +0 -223
  195. package/node_modules/uuid/dist/commonjs-browser/native.js +0 -11
  196. package/node_modules/uuid/dist/commonjs-browser/nil.js +0 -8
  197. package/node_modules/uuid/dist/commonjs-browser/parse.js +0 -45
  198. package/node_modules/uuid/dist/commonjs-browser/regex.js +0 -8
  199. package/node_modules/uuid/dist/commonjs-browser/rng.js +0 -25
  200. package/node_modules/uuid/dist/commonjs-browser/sha1.js +0 -104
  201. package/node_modules/uuid/dist/commonjs-browser/stringify.js +0 -44
  202. package/node_modules/uuid/dist/commonjs-browser/v1.js +0 -107
  203. package/node_modules/uuid/dist/commonjs-browser/v3.js +0 -16
  204. package/node_modules/uuid/dist/commonjs-browser/v35.js +0 -80
  205. package/node_modules/uuid/dist/commonjs-browser/v4.js +0 -43
  206. package/node_modules/uuid/dist/commonjs-browser/v5.js +0 -16
  207. package/node_modules/uuid/dist/commonjs-browser/validate.js +0 -17
  208. package/node_modules/uuid/dist/commonjs-browser/version.js +0 -21
  209. package/node_modules/uuid/dist/esm-browser/index.js +0 -9
  210. package/node_modules/uuid/dist/esm-browser/md5.js +0 -215
  211. package/node_modules/uuid/dist/esm-browser/native.js +0 -4
  212. package/node_modules/uuid/dist/esm-browser/nil.js +0 -1
  213. package/node_modules/uuid/dist/esm-browser/parse.js +0 -35
  214. package/node_modules/uuid/dist/esm-browser/regex.js +0 -1
  215. package/node_modules/uuid/dist/esm-browser/rng.js +0 -18
  216. package/node_modules/uuid/dist/esm-browser/sha1.js +0 -96
  217. package/node_modules/uuid/dist/esm-browser/stringify.js +0 -33
  218. package/node_modules/uuid/dist/esm-browser/v1.js +0 -95
  219. package/node_modules/uuid/dist/esm-browser/v3.js +0 -4
  220. package/node_modules/uuid/dist/esm-browser/v35.js +0 -66
  221. package/node_modules/uuid/dist/esm-browser/v4.js +0 -29
  222. package/node_modules/uuid/dist/esm-browser/v5.js +0 -4
  223. package/node_modules/uuid/dist/esm-browser/validate.js +0 -7
  224. package/node_modules/uuid/dist/esm-browser/version.js +0 -11
  225. package/node_modules/uuid/dist/esm-node/index.js +0 -9
  226. package/node_modules/uuid/dist/esm-node/md5.js +0 -13
  227. package/node_modules/uuid/dist/esm-node/native.js +0 -4
  228. package/node_modules/uuid/dist/esm-node/nil.js +0 -1
  229. package/node_modules/uuid/dist/esm-node/parse.js +0 -35
  230. package/node_modules/uuid/dist/esm-node/regex.js +0 -1
  231. package/node_modules/uuid/dist/esm-node/rng.js +0 -12
  232. package/node_modules/uuid/dist/esm-node/sha1.js +0 -13
  233. package/node_modules/uuid/dist/esm-node/stringify.js +0 -33
  234. package/node_modules/uuid/dist/esm-node/v1.js +0 -95
  235. package/node_modules/uuid/dist/esm-node/v3.js +0 -4
  236. package/node_modules/uuid/dist/esm-node/v35.js +0 -66
  237. package/node_modules/uuid/dist/esm-node/v4.js +0 -29
  238. package/node_modules/uuid/dist/esm-node/v5.js +0 -4
  239. package/node_modules/uuid/dist/esm-node/validate.js +0 -7
  240. package/node_modules/uuid/dist/esm-node/version.js +0 -11
  241. package/node_modules/uuid/dist/index.js +0 -79
  242. package/node_modules/uuid/dist/md5-browser.js +0 -223
  243. package/node_modules/uuid/dist/md5.js +0 -23
  244. package/node_modules/uuid/dist/native-browser.js +0 -11
  245. package/node_modules/uuid/dist/native.js +0 -15
  246. package/node_modules/uuid/dist/nil.js +0 -8
  247. package/node_modules/uuid/dist/parse.js +0 -45
  248. package/node_modules/uuid/dist/regex.js +0 -8
  249. package/node_modules/uuid/dist/rng-browser.js +0 -25
  250. package/node_modules/uuid/dist/rng.js +0 -24
  251. package/node_modules/uuid/dist/sha1-browser.js +0 -104
  252. package/node_modules/uuid/dist/sha1.js +0 -23
  253. package/node_modules/uuid/dist/stringify.js +0 -44
  254. package/node_modules/uuid/dist/uuid-bin.js +0 -85
  255. package/node_modules/uuid/dist/v1.js +0 -107
  256. package/node_modules/uuid/dist/v3.js +0 -16
  257. package/node_modules/uuid/dist/v35.js +0 -80
  258. package/node_modules/uuid/dist/v4.js +0 -43
  259. package/node_modules/uuid/dist/v5.js +0 -16
  260. package/node_modules/uuid/dist/validate.js +0 -17
  261. package/node_modules/uuid/dist/version.js +0 -21
  262. package/node_modules/uuid/package.json +0 -135
  263. package/node_modules/uuid/wrapper.mjs +0 -10
@@ -0,0 +1,242 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const codewhisperer_streaming_1 = require("@amzn/codewhisperer-streaming");
4
+ const assert = require("assert");
5
+ const aws_sdk_1 = require("aws-sdk");
6
+ const chai_1 = require("chai");
7
+ const fs = require("fs");
8
+ const got_1 = require("got");
9
+ const ts_sinon_1 = require("ts-sinon");
10
+ const codewhispererStreamingClient_1 = require("../../../client/streamingClient/codewhispererStreamingClient");
11
+ const models_1 = require("../models");
12
+ const transformHandler_1 = require("../transformHandler");
13
+ const sinon = require("sinon");
14
+ const mocked$Response = {
15
+ $response: {
16
+ hasNextPage: ts_sinon_1.default.mock(),
17
+ nextPage: ts_sinon_1.default.mock(),
18
+ data: undefined,
19
+ error: undefined,
20
+ requestId: '',
21
+ redirectCount: 0,
22
+ retryCount: 0,
23
+ httpResponse: new aws_sdk_1.HttpResponse(),
24
+ },
25
+ };
26
+ const testUploadId = 'test-upoload-id';
27
+ const testTransformId = 'test-transform-id';
28
+ const payloadFileName = 'C:\\test.zip';
29
+ describe('Test Transform handler ', () => {
30
+ let client;
31
+ let workspace;
32
+ let transformHandler;
33
+ const mockedLogging = (0, ts_sinon_1.stubInterface)();
34
+ beforeEach(async () => {
35
+ // Set up the server with a mock service
36
+ client = (0, ts_sinon_1.stubInterface)();
37
+ workspace = (0, ts_sinon_1.stubInterface)();
38
+ transformHandler = new transformHandler_1.TransformHandler(client, workspace, mockedLogging);
39
+ });
40
+ describe('test upload artifact', () => {
41
+ it('call upload method correctly', async () => {
42
+ const putStub = sinon.stub(got_1.default, 'put').resolves({ statusCode: 'Success' });
43
+ const readFileSyncStub = sinon.stub(fs, 'readFileSync').returns('text file content');
44
+ await transformHandler.uploadArtifactToS3Async(payloadFileName, {
45
+ uploadId: testUploadId,
46
+ uploadUrl: 'dummy-upload-url',
47
+ kmsKeyArn: 'ResourceArn',
48
+ ...mocked$Response,
49
+ }, 'dummy-256');
50
+ ts_sinon_1.default.assert.callCount(putStub, 1);
51
+ ts_sinon_1.default.assert.callCount(readFileSyncStub, 1);
52
+ putStub.restore();
53
+ readFileSyncStub.restore();
54
+ });
55
+ });
56
+ describe('Test transform create presign url and upload', () => {
57
+ beforeEach(async () => {
58
+ // mock default return value for createUploadUrl
59
+ client.codeModernizerCreateUploadUrl.resolves({
60
+ uploadId: testUploadId,
61
+ uploadUrl: 'dummy-upload-url',
62
+ kmsKeyArn: 'ResourceArn',
63
+ ...mocked$Response,
64
+ });
65
+ });
66
+ it('returns upload id correctly', async () => {
67
+ const readFileSyncStub = sinon.stub(fs, 'readFileSync').returns('text file content');
68
+ const uploadStub = sinon.stub(transformHandler, 'uploadArtifactToS3Async');
69
+ const res = await transformHandler.uploadPayloadAsync(payloadFileName);
70
+ ts_sinon_1.default.assert.callCount(readFileSyncStub, 1);
71
+ ts_sinon_1.default.assert.callCount(uploadStub, 1);
72
+ assert.equal(res, testUploadId);
73
+ uploadStub.restore();
74
+ readFileSyncStub.restore();
75
+ });
76
+ it('should throw error if uploadArtifactToS3Async fails', async () => {
77
+ const mockError = new Error('Error in uploadArtifactToS3 call');
78
+ const readFileSyncStub = sinon.stub(fs, 'readFileSync').returns('text file content');
79
+ sinon.stub(transformHandler, 'uploadArtifactToS3Async').rejects(mockError);
80
+ // Call the method to be tested
81
+ try {
82
+ await transformHandler.uploadPayloadAsync(payloadFileName);
83
+ }
84
+ catch (error) {
85
+ // Assertions
86
+ (0, chai_1.expect)(error.message).to.equal(mockError.message);
87
+ sinon.assert.calledOnce(readFileSyncStub);
88
+ readFileSyncStub.restore();
89
+ }
90
+ });
91
+ /*
92
+ it('should upload payload and return uploadId', async () => {
93
+ workspace.fs.getTempDirPath = simon.stub().returns('C:\\tmp')
94
+ const zipStub = sinon.stub(transformHandler, 'zipCodeAsync').returns(Promise.resolve(payloadFileName))
95
+ const uploadStub = sinon.stub(transformHandler, 'uploadPayloadAsync').returns(Promise.resolve(testUploadId))
96
+ const result = await transformHandler.preTransformationUploadCode(payloadFileName)
97
+ expect(result).to.equal(testUploadId)
98
+ sinon.assert.calledOnce(zipStub)
99
+ sinon.assert.calledOnce(uploadStub)
100
+ zipStub.restore()
101
+ uploadStub.restore()
102
+ })
103
+
104
+ it('should throw error if upload fails', async () => {
105
+ // Mocking necessary dependencies and methods
106
+ const mockError = new Error('Upload failed')
107
+ const requestString = JSON.stringify(EXAMPLE_REQUEST)
108
+ const request = JSON.parse(requestString) as StartTransformRequest
109
+ workspace.fs.getTempDirPath = simon.stub().returns('C:\\tmp')
110
+ const zipStub = sinon.stub(transformHandler, 'zipCodeAsync').returns(Promise.resolve(payloadFileName))
111
+ sinon.stub(transformHandler, 'uploadPayloadAsync').rejects(mockError)
112
+ try {
113
+ await transformHandler.preTransformationUploadCode(request)
114
+ } catch (error) {
115
+ sinon.assert.calledOnce(zipStub)
116
+ expect((error as Error).message).to.equal(mockError.message)
117
+ zipStub.restore()
118
+ }
119
+ })
120
+ */
121
+ });
122
+ describe('Test cancel transform job', () => {
123
+ beforeEach(async () => {
124
+ // mock default return value for cancelTransform
125
+ client.codeModernizerStopCodeTransformation.returns(Promise.resolve({
126
+ transformationStatus: 'STOPPED',
127
+ ...mocked$Response,
128
+ }));
129
+ });
130
+ it('should cancel transform', async () => {
131
+ const requestString = JSON.stringify({ TransformationJobId: testTransformId });
132
+ const request = JSON.parse(requestString);
133
+ const res = await transformHandler.cancelTransformation(request);
134
+ (0, chai_1.expect)(res.TransformationJobStatus).to.equal(models_1.CancellationJobStatus.SUCCESSFULLY_CANCELLED);
135
+ });
136
+ it('should throw error if cancellation fails', async () => {
137
+ client.codeModernizerStopCodeTransformation.returns(Promise.resolve({
138
+ transformationStatus: 'COMPLETED',
139
+ ...mocked$Response,
140
+ }));
141
+ const requestString = JSON.stringify({ TransformationJobId: testTransformId });
142
+ const request = JSON.parse(requestString);
143
+ const res = await transformHandler.cancelTransformation(request);
144
+ (0, chai_1.expect)(res.TransformationJobStatus).to.equal(models_1.CancellationJobStatus.FAILED_TO_CANCEL);
145
+ });
146
+ });
147
+ const mockedCredentialsProvider = {
148
+ getCredentials: sinon.stub().returns({ token: 'mockedToken' }),
149
+ };
150
+ describe('StreamingClient', () => {
151
+ it('should create a new streaming client', async () => {
152
+ const streamingClient = new codewhispererStreamingClient_1.StreamingClient();
153
+ const client = await streamingClient.getStreamingClient(mockedCredentialsProvider);
154
+ (0, chai_1.expect)(client).to.be.instanceOf(codewhisperer_streaming_1.CodeWhispererStreaming);
155
+ });
156
+ });
157
+ describe('createStreamingClient', () => {
158
+ it('should create a new streaming client with correct configurations', async () => {
159
+ const client = await (0, codewhispererStreamingClient_1.createStreamingClient)(mockedCredentialsProvider);
160
+ (0, chai_1.expect)(client).to.be.instanceOf(codewhisperer_streaming_1.CodeWhispererStreaming);
161
+ });
162
+ });
163
+ describe('Test get transformJob', () => {
164
+ beforeEach(async () => {
165
+ // mock default return value for Transformation Job
166
+ client.codeModernizerGetCodeTransformation.returns(Promise.resolve({
167
+ transformationJob: {
168
+ jobId: testTransformId,
169
+ status: 'COMPLETED',
170
+ ...mocked$Response,
171
+ },
172
+ ...mocked$Response,
173
+ }));
174
+ });
175
+ it('should get transform', async () => {
176
+ const requestString = JSON.stringify({ TransformationJobId: testTransformId });
177
+ const request = JSON.parse(requestString);
178
+ const res = await transformHandler.getTransformation(request);
179
+ (0, chai_1.expect)(res.TransformationJob.status).to.equal('COMPLETED');
180
+ });
181
+ });
182
+ describe('Test get transformJob for failed case', () => {
183
+ beforeEach(async () => {
184
+ // mock default return value for Transformation Job
185
+ client.codeModernizerGetCodeTransformation.returns(Promise.resolve({
186
+ transformationJob: {
187
+ jobId: testTransformId,
188
+ status: 'FAILED',
189
+ ...mocked$Response,
190
+ },
191
+ ...mocked$Response,
192
+ }));
193
+ });
194
+ it('should get transform for failed case', async () => {
195
+ const requestString = JSON.stringify({ TransformationJobId: testTransformId });
196
+ const request = JSON.parse(requestString);
197
+ const res = await transformHandler.getTransformation(request);
198
+ (0, chai_1.expect)(res.TransformationJob.status).to.equal('FAILED');
199
+ });
200
+ });
201
+ describe('Test get transform plan', () => {
202
+ beforeEach(async () => {
203
+ // mock default return value for Transformation plan
204
+ const mockPlanString = JSON.stringify({
205
+ transformationPlan: {
206
+ transformationSteps: [
207
+ {
208
+ id: '1',
209
+ name: 'PlanStepName 1',
210
+ description: 'PlanStepDescription 1',
211
+ status: 'COMPLETED',
212
+ progressUpdates: [
213
+ {
214
+ name: 'ProgressUpdateName 1 for PlanStep 1',
215
+ status: 'COMPLETED',
216
+ description: 'ProgressUpdateDescription 1 for PlanStep 1',
217
+ startTime: '2024-03-11T23:27:33.935Z',
218
+ endTime: '2024-03-11T23:27:34.038Z',
219
+ },
220
+ ],
221
+ startTime: '2024-03-12T18:49:41.431Z',
222
+ endTime: '2024-03-12T18:49:42.431Z',
223
+ },
224
+ ],
225
+ },
226
+ });
227
+ const response = JSON.parse(mockPlanString);
228
+ client.codeModernizerGetCodeTransformationPlan.returns(Promise.resolve(response));
229
+ });
230
+ it('should get transform plan', async () => {
231
+ const requestString = JSON.stringify({ TransformationJobId: testTransformId });
232
+ const request = JSON.parse(requestString);
233
+ const res = await transformHandler.getTransformationPlan(request);
234
+ (0, chai_1.expect)(res.TransformationPlan.transformationSteps[0].status).to.equal('COMPLETED');
235
+ (0, chai_1.expect)(res.TransformationPlan.transformationSteps[0].name).to.equal('PlanStepName 1');
236
+ if (res.TransformationPlan.transformationSteps[0].progressUpdates) {
237
+ (0, chai_1.expect)(res.TransformationPlan.transformationSteps[0].progressUpdates[0].name).to.equal('ProgressUpdateName 1 for PlanStep 1');
238
+ }
239
+ });
240
+ });
241
+ });
242
+ //# sourceMappingURL=transformHandler.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transformHandler.test.js","sourceRoot":"","sources":["../../../../src/language-server/netTransform/tests/transformHandler.test.ts"],"names":[],"mappings":";;AAAA,2EAAsE;AAEtE,iCAAgC;AAChC,qCAAsC;AACtC,+BAA6B;AAC7B,yBAAwB;AACxB,6BAAqB;AACrB,uCAA2E;AAC3E,+GAAqH;AAErH,sCAMkB;AAClB,0DAAsD;AAEtD,+BAA+B;AAC/B,MAAM,eAAe,GAAG;IACpB,SAAS,EAAE;QACP,WAAW,EAAE,kBAAK,CAAC,IAAI,EAAE;QACzB,QAAQ,EAAE,kBAAK,CAAC,IAAI,EAAE;QACtB,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,SAAS;QAChB,SAAS,EAAE,EAAE;QACb,aAAa,EAAE,CAAC;QAChB,UAAU,EAAE,CAAC;QACb,YAAY,EAAE,IAAI,sBAAY,EAAE;KACnC;CACJ,CAAA;AACD,MAAM,YAAY,GAAG,iBAAiB,CAAA;AACtC,MAAM,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CAAC,2BAA2B,EAAE,KAAK,IAAI,EAAE;YACvC,MAAM,aAAa,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,mBAAmB,EAAE,eAAe,EAAE,CAAC,CAAA;YAC9E,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,CAA4B,CAAA;YACpE,MAAM,GAAG,GAAG,MAAM,gBAAgB,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAA;YAEjE,IAAA,aAAM,EAAC,GAAG,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,CAAA;YAClF,IAAA,aAAM,EAAC,GAAG,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAA;YACrF,IAAI,GAAG,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,eAAe,EAAE;gBAC/D,IAAA,aAAM,EAAC,GAAG,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAClF,qCAAqC,CACxC,CAAA;aACJ;QACL,CAAC,CAAC,CAAA;IACN,CAAC,CAAC,CAAA;AACN,CAAC,CAAC,CAAA"}
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const chai_1 = require("chai");
4
+ const validation_1 = require("../validation");
5
+ const sampleStartTransformRequest = {
6
+ SolutionRootPath: '',
7
+ SelectedProjectPath: 'test.csproj',
8
+ ProgramLanguage: '',
9
+ TargetFramework: '',
10
+ SolutionConfigPaths: [],
11
+ ProjectMetadata: [],
12
+ command: '',
13
+ };
14
+ describe('Test validation functionality', () => {
15
+ it('should return true when selectedProjectPath is a valid csproj', () => {
16
+ let mockStartTransformationRequest = sampleStartTransformRequest;
17
+ mockStartTransformationRequest.SelectedProjectPath = 'test.csproj';
18
+ (0, chai_1.expect)((0, validation_1.isProject)(mockStartTransformationRequest)).to.equal(true);
19
+ });
20
+ it('should return false when selectedProjectPath is not a valid csproj', () => {
21
+ let mockStartTransformationRequest = sampleStartTransformRequest;
22
+ mockStartTransformationRequest.SelectedProjectPath = 'test.sln';
23
+ (0, chai_1.expect)((0, validation_1.isProject)(mockStartTransformationRequest)).to.equal(false);
24
+ });
25
+ it('should return true when selectedProjectPath is a valid sln', () => {
26
+ let mockStartTransformationRequest = sampleStartTransformRequest;
27
+ mockStartTransformationRequest.SelectedProjectPath = 'test.sln';
28
+ (0, chai_1.expect)((0, validation_1.isSolution)(mockStartTransformationRequest)).to.equal(true);
29
+ });
30
+ it('should return false when selectedProjectPath is not a valid sln', () => {
31
+ let mockStartTransformationRequest = sampleStartTransformRequest;
32
+ mockStartTransformationRequest.SelectedProjectPath = 'test.csproj';
33
+ (0, chai_1.expect)((0, validation_1.isSolution)(mockStartTransformationRequest)).to.equal(false);
34
+ });
35
+ it('should return true when project is a supported type', () => {
36
+ let mockStartTransformationRequest = sampleStartTransformRequest;
37
+ const mockProjectMeta = {
38
+ Name: '',
39
+ ProjectTargetFramework: '',
40
+ ProjectPath: 'test.csproj',
41
+ SourceCodeFilePaths: [],
42
+ ProjectLanguage: '',
43
+ ProjectType: 'AspNetCoreMvc',
44
+ ExternalReferences: [],
45
+ };
46
+ mockStartTransformationRequest.ProjectMetadata.push(mockProjectMeta);
47
+ (0, chai_1.expect)((0, validation_1.validateProject)(mockStartTransformationRequest)).to.equal(true);
48
+ });
49
+ it('should return false when project is not a supported type', () => {
50
+ let mockStartTransformationRequest = sampleStartTransformRequest;
51
+ const mockProjectMeta = {
52
+ Name: '',
53
+ ProjectTargetFramework: '',
54
+ ProjectPath: 'test.csproj',
55
+ SourceCodeFilePaths: [],
56
+ ProjectLanguage: '',
57
+ ProjectType: 'not supported',
58
+ ExternalReferences: [],
59
+ };
60
+ mockStartTransformationRequest.ProjectMetadata = [];
61
+ mockStartTransformationRequest.ProjectMetadata.push(mockProjectMeta);
62
+ (0, chai_1.expect)((0, validation_1.validateProject)(mockStartTransformationRequest)).to.equal(false);
63
+ });
64
+ it('should return false when there is no project path that is the same as the selected project path', () => {
65
+ let mockStartTransformationRequest = sampleStartTransformRequest;
66
+ const mockProjectMeta = {
67
+ Name: '',
68
+ ProjectTargetFramework: '',
69
+ ProjectPath: 'different.csproj',
70
+ SourceCodeFilePaths: [],
71
+ ProjectLanguage: '',
72
+ ProjectType: 'AspNetCoreMvc',
73
+ ExternalReferences: [],
74
+ };
75
+ mockStartTransformationRequest.ProjectMetadata = [];
76
+ mockStartTransformationRequest.ProjectMetadata.push(mockProjectMeta);
77
+ (0, chai_1.expect)((0, validation_1.validateProject)(mockStartTransformationRequest)).to.equal(false);
78
+ });
79
+ });
80
+ //# sourceMappingURL=validation.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.test.js","sourceRoot":"","sources":["../../../../src/language-server/netTransform/tests/validation.test.ts"],"names":[],"mappings":";;AAAA,+BAA6B;AAE7B,8CAAsE;AAItE,MAAM,2BAA2B,GAA0B;IACvD,gBAAgB,EAAE,EAAE;IACpB,mBAAmB,EAAE,aAAa;IAClC,eAAe,EAAE,EAAE;IACnB,eAAe,EAAE,EAAE;IACnB,mBAAmB,EAAE,EAAE;IACvB,eAAe,EAAE,EAAE;IACnB,OAAO,EAAE,EAAE;CACd,CAAA;AAED,QAAQ,CAAC,+BAA+B,EAAE,GAAG,EAAE;IAC3C,EAAE,CAAC,+DAA+D,EAAE,GAAG,EAAE;QACrE,IAAI,8BAA8B,GAA0B,2BAA2B,CAAA;QACvF,8BAA8B,CAAC,mBAAmB,GAAG,aAAa,CAAA;QAClE,IAAA,aAAM,EAAC,IAAA,sBAAS,EAAC,8BAA8B,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,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"}
@@ -0,0 +1,27 @@
1
+ import { CodeWhispererStreaming } from '@amzn/codewhisperer-streaming';
2
+ import { Logging, Workspace } from '@aws/language-server-runtimes/server-interface';
3
+ import { CreateUploadUrlResponse } from '../../client/token/codewhispererbearertokenclient';
4
+ import { CodeWhispererServiceToken } from '../codeWhispererService';
5
+ import { ArtifactManager } from './artifactManager';
6
+ import { CancelTransformRequest, CancelTransformResponse, DownloadArtifactsResponse, GetTransformPlanRequest, GetTransformPlanResponse, GetTransformRequest, GetTransformResponse, StartTransformRequest, StartTransformResponse } from './models';
7
+ export declare class TransformHandler {
8
+ private client;
9
+ private workspace;
10
+ private logging;
11
+ constructor(client: CodeWhispererServiceToken, workspace: Workspace, logging: Logging);
12
+ startTransformation(userInputrequest: StartTransformRequest): Promise<StartTransformResponse>;
13
+ preTransformationUploadCode(payloadFilePath: string): Promise<string>;
14
+ uploadPayloadAsync(payloadFileName: string): Promise<string>;
15
+ zipCodeAsync(request: StartTransformRequest, artifactManager: ArtifactManager): Promise<string>;
16
+ uploadArtifactToS3Async(fileName: string, resp: CreateUploadUrlResponse, sha256: string): Promise<void>;
17
+ getHeadersObj(sha256: string, kmsKeyArn: string | undefined): {};
18
+ getTransformation(request: GetTransformRequest): Promise<GetTransformResponse>;
19
+ getTransformationPlan(request: GetTransformPlanRequest): Promise<GetTransformPlanResponse>;
20
+ cancelTransformation(request: CancelTransformRequest): Promise<CancelTransformResponse>;
21
+ sleep(duration?: number): Promise<void>;
22
+ pollTransformation(request: GetTransformRequest, validExitStatus: string[], failureStates: string[]): Promise<GetTransformResponse>;
23
+ downloadExportResultArchive(cwStreamingClient: CodeWhispererStreaming, exportId: string, saveToDir: string): Promise<DownloadArtifactsResponse>;
24
+ archivePathGenerator(exportId: string, buffer: Uint8Array[], saveToDir: string): Promise<string>;
25
+ directoryExists(directoryPath: any): Promise<void>;
26
+ getWorkspacePath(solutionRootPath: string): string;
27
+ }