@aws/lsp-codewhisperer 0.0.3 → 0.0.5

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 (192) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/out/client/sigv4/service.json +1 -1
  3. package/out/client/token/bearer-token-service.json +1 -1
  4. package/out/index.d.ts +1 -0
  5. package/out/index.js +1 -0
  6. package/out/index.js.map +1 -1
  7. package/out/language-server/chat/chatController.d.ts +25 -0
  8. package/out/language-server/chat/chatController.js +117 -0
  9. package/out/language-server/chat/chatController.js.map +1 -0
  10. package/out/language-server/chat/chatController.test.d.ts +1 -0
  11. package/out/language-server/chat/chatController.test.js +240 -0
  12. package/out/language-server/chat/chatController.test.js.map +1 -0
  13. package/out/language-server/chat/chatEventParser.d.ts +24 -0
  14. package/out/language-server/chat/chatEventParser.js +84 -0
  15. package/out/language-server/chat/chatEventParser.js.map +1 -0
  16. package/out/language-server/chat/chatEventParser.test.d.ts +1 -0
  17. package/out/language-server/chat/chatEventParser.test.js +189 -0
  18. package/out/language-server/chat/chatEventParser.test.js.map +1 -0
  19. package/out/language-server/chat/chatSessionManagementService.d.ts +16 -0
  20. package/out/language-server/chat/chatSessionManagementService.js +92 -0
  21. package/out/language-server/chat/chatSessionManagementService.js.map +1 -0
  22. package/out/language-server/chat/chatSessionManagementService.test.d.ts +1 -0
  23. package/out/language-server/chat/chatSessionManagementService.test.js +73 -0
  24. package/out/language-server/chat/chatSessionManagementService.test.js.map +1 -0
  25. package/out/language-server/chat/chatSessionService.d.ts +13 -0
  26. package/out/language-server/chat/chatSessionService.js +63 -0
  27. package/out/language-server/chat/chatSessionService.js.map +1 -0
  28. package/out/language-server/chat/chatSessionService.test.d.ts +1 -0
  29. package/out/language-server/chat/chatSessionService.test.js +80 -0
  30. package/out/language-server/chat/chatSessionService.test.js.map +1 -0
  31. package/out/language-server/chat/contexts/documentContext.d.ts +17 -0
  32. package/out/language-server/chat/contexts/documentContext.js +59 -0
  33. package/out/language-server/chat/contexts/documentContext.js.map +1 -0
  34. package/out/language-server/chat/contexts/documentContext.test.d.ts +1 -0
  35. package/out/language-server/chat/contexts/documentContext.test.js +147 -0
  36. package/out/language-server/chat/contexts/documentContext.test.js.map +1 -0
  37. package/out/language-server/chat/contexts/utils.d.ts +10 -0
  38. package/out/language-server/chat/contexts/utils.js +71 -0
  39. package/out/language-server/chat/contexts/utils.js.map +1 -0
  40. package/out/language-server/chat/contexts/utils.test.d.ts +1 -0
  41. package/out/language-server/chat/contexts/utils.test.js +72 -0
  42. package/out/language-server/chat/contexts/utils.test.js.map +1 -0
  43. package/out/language-server/chat/utils.d.ts +4 -0
  44. package/out/language-server/chat/utils.js +34 -0
  45. package/out/language-server/chat/utils.js.map +1 -0
  46. package/out/language-server/codeWhispererSecurityScanServer.d.ts +1 -2
  47. package/out/language-server/codeWhispererSecurityScanServer.js +152 -25
  48. package/out/language-server/codeWhispererSecurityScanServer.js.map +1 -1
  49. package/out/language-server/codeWhispererServer.d.ts +1 -2
  50. package/out/language-server/codeWhispererServer.js +3 -3
  51. package/out/language-server/codeWhispererServer.js.map +1 -1
  52. package/out/language-server/codeWhispererServer.test.js +100 -101
  53. package/out/language-server/codeWhispererServer.test.js.map +1 -1
  54. package/out/language-server/codeWhispererService.d.ts +1 -1
  55. package/out/language-server/codeWhispererService.js.map +1 -1
  56. package/out/language-server/dependencyGraph/csharpDependencyGraph.d.ts +3 -3
  57. package/out/language-server/dependencyGraph/csharpDependencyGraph.js +40 -37
  58. package/out/language-server/dependencyGraph/csharpDependencyGraph.js.map +1 -1
  59. package/out/language-server/dependencyGraph/csharpDependencyGraph.test.js +106 -78
  60. package/out/language-server/dependencyGraph/csharpDependencyGraph.test.js.map +1 -1
  61. package/out/language-server/dependencyGraph/dependencyGraph.d.ts +12 -4
  62. package/out/language-server/dependencyGraph/dependencyGraph.js +24 -6
  63. package/out/language-server/dependencyGraph/dependencyGraph.js.map +1 -1
  64. package/out/language-server/dependencyGraph/dependencyGraphFactory.d.ts +2 -3
  65. package/out/language-server/dependencyGraph/dependencyGraphFactory.js +2 -2
  66. package/out/language-server/dependencyGraph/dependencyGraphFactory.js.map +1 -1
  67. package/out/language-server/languageDetection.d.ts +11 -3
  68. package/out/language-server/languageDetection.js +85 -20
  69. package/out/language-server/languageDetection.js.map +1 -1
  70. package/out/language-server/languageDetection.test.d.ts +1 -0
  71. package/out/language-server/languageDetection.test.js +31 -0
  72. package/out/language-server/languageDetection.test.js.map +1 -0
  73. package/out/language-server/netTransformServer.d.ts +12 -0
  74. package/out/language-server/netTransformServer.js +27 -0
  75. package/out/language-server/netTransformServer.js.map +1 -0
  76. package/out/language-server/proxy-server.d.ts +3 -2
  77. package/out/language-server/proxy-server.js +35 -1
  78. package/out/language-server/proxy-server.js.map +1 -1
  79. package/out/language-server/qChatServer.d.ts +3 -0
  80. package/out/language-server/qChatServer.js +31 -0
  81. package/out/language-server/qChatServer.js.map +1 -0
  82. package/out/language-server/qChatServer.test.d.ts +1 -0
  83. package/out/language-server/qChatServer.test.js +51 -0
  84. package/out/language-server/qChatServer.test.js.map +1 -0
  85. package/out/language-server/securityScan/securityScanDiagnosticsProvider.d.ts +28 -0
  86. package/out/language-server/securityScan/securityScanDiagnosticsProvider.js +111 -0
  87. package/out/language-server/securityScan/securityScanDiagnosticsProvider.js.map +1 -0
  88. package/out/language-server/securityScan/securityScanHandler.d.ts +12 -5
  89. package/out/language-server/securityScan/securityScanHandler.js +69 -19
  90. package/out/language-server/securityScan/securityScanHandler.js.map +1 -1
  91. package/out/language-server/securityScan/securityScanHandler.test.js +3 -2
  92. package/out/language-server/securityScan/securityScanHandler.test.js.map +1 -1
  93. package/out/language-server/securityScan/types.d.ts +15 -0
  94. package/out/language-server/session/sessionManager.d.ts +1 -2
  95. package/out/language-server/session/sessionManager.js.map +1 -1
  96. package/out/language-server/telemetry/codePercentage.d.ts +1 -1
  97. package/out/language-server/telemetry/types.d.ts +20 -0
  98. package/out/language-server/telemetry/userTriggerDecision.test.js +8 -8
  99. package/out/language-server/telemetry/userTriggerDecision.test.js.map +1 -1
  100. package/out/language-server/telemetry.test.js +4 -4
  101. package/out/language-server/telemetry.test.js.map +1 -1
  102. package/out/language-server/testUtils.d.ts +1 -0
  103. package/out/language-server/testUtils.js +17 -1
  104. package/out/language-server/testUtils.js.map +1 -1
  105. package/out/language-server/types.d.ts +13 -0
  106. package/out/language-server/types.js +3 -0
  107. package/out/language-server/types.js.map +1 -0
  108. package/out/language-server/utils.d.ts +3 -0
  109. package/out/language-server/utils.js +19 -1
  110. package/out/language-server/utils.js.map +1 -1
  111. package/out/language-server/utils.test.d.ts +1 -0
  112. package/out/language-server/utils.test.js +33 -0
  113. package/out/language-server/utils.test.js.map +1 -0
  114. package/package.json +16 -7
  115. package/src.gen/@amzn/codewhisperer-streaming/LICENSE +201 -0
  116. package/src.gen/@amzn/codewhisperer-streaming/README.md +464 -0
  117. package/src.gen/@amzn/codewhisperer-streaming/api-extractor.json +4 -0
  118. package/src.gen/@amzn/codewhisperer-streaming/dist-cjs/CodeWhispererStreaming.js +17 -0
  119. package/src.gen/@amzn/codewhisperer-streaming/dist-cjs/CodeWhispererStreamingClient.js +42 -0
  120. package/src.gen/@amzn/codewhisperer-streaming/dist-cjs/commands/ExportResultArchiveCommand.js +42 -0
  121. package/src.gen/@amzn/codewhisperer-streaming/dist-cjs/commands/GenerateAssistantResponseCommand.js +42 -0
  122. package/src.gen/@amzn/codewhisperer-streaming/dist-cjs/commands/GenerateTaskAssistPlanCommand.js +42 -0
  123. package/src.gen/@amzn/codewhisperer-streaming/dist-cjs/commands/index.js +6 -0
  124. package/src.gen/@amzn/codewhisperer-streaming/dist-cjs/endpoints.js +165 -0
  125. package/src.gen/@amzn/codewhisperer-streaming/dist-cjs/extensionConfiguration.js +2 -0
  126. package/src.gen/@amzn/codewhisperer-streaming/dist-cjs/index.js +10 -0
  127. package/src.gen/@amzn/codewhisperer-streaming/dist-cjs/models/CodeWhispererStreamingServiceException.js +12 -0
  128. package/src.gen/@amzn/codewhisperer-streaming/dist-cjs/models/index.js +4 -0
  129. package/src.gen/@amzn/codewhisperer-streaming/dist-cjs/models/models_0.js +361 -0
  130. package/src.gen/@amzn/codewhisperer-streaming/dist-cjs/protocols/Aws_restJson1.js +458 -0
  131. package/src.gen/@amzn/codewhisperer-streaming/dist-cjs/runtimeConfig.browser.js +38 -0
  132. package/src.gen/@amzn/codewhisperer-streaming/dist-cjs/runtimeConfig.js +46 -0
  133. package/src.gen/@amzn/codewhisperer-streaming/dist-cjs/runtimeConfig.native.js +15 -0
  134. package/src.gen/@amzn/codewhisperer-streaming/dist-cjs/runtimeConfig.shared.js +22 -0
  135. package/src.gen/@amzn/codewhisperer-streaming/dist-cjs/runtimeExtensions.js +22 -0
  136. package/src.gen/@amzn/codewhisperer-streaming/dist-es/CodeWhispererStreaming.js +13 -0
  137. package/src.gen/@amzn/codewhisperer-streaming/dist-es/CodeWhispererStreamingClient.js +38 -0
  138. package/src.gen/@amzn/codewhisperer-streaming/dist-es/commands/ExportResultArchiveCommand.js +38 -0
  139. package/src.gen/@amzn/codewhisperer-streaming/dist-es/commands/GenerateAssistantResponseCommand.js +38 -0
  140. package/src.gen/@amzn/codewhisperer-streaming/dist-es/commands/GenerateTaskAssistPlanCommand.js +38 -0
  141. package/src.gen/@amzn/codewhisperer-streaming/dist-es/commands/index.js +3 -0
  142. package/src.gen/@amzn/codewhisperer-streaming/dist-es/endpoints.js +161 -0
  143. package/src.gen/@amzn/codewhisperer-streaming/dist-es/extensionConfiguration.js +1 -0
  144. package/src.gen/@amzn/codewhisperer-streaming/dist-es/index.js +5 -0
  145. package/src.gen/@amzn/codewhisperer-streaming/dist-es/models/CodeWhispererStreamingServiceException.js +8 -0
  146. package/src.gen/@amzn/codewhisperer-streaming/dist-es/models/index.js +1 -0
  147. package/src.gen/@amzn/codewhisperer-streaming/dist-es/models/models_0.js +328 -0
  148. package/src.gen/@amzn/codewhisperer-streaming/dist-es/protocols/Aws_restJson1.js +449 -0
  149. package/src.gen/@amzn/codewhisperer-streaming/dist-es/runtimeConfig.browser.js +33 -0
  150. package/src.gen/@amzn/codewhisperer-streaming/dist-es/runtimeConfig.js +41 -0
  151. package/src.gen/@amzn/codewhisperer-streaming/dist-es/runtimeConfig.native.js +11 -0
  152. package/src.gen/@amzn/codewhisperer-streaming/dist-es/runtimeConfig.shared.js +18 -0
  153. package/src.gen/@amzn/codewhisperer-streaming/dist-es/runtimeExtensions.js +18 -0
  154. package/src.gen/@amzn/codewhisperer-streaming/dist-types/CodeWhispererStreaming.d.ts +30 -0
  155. package/src.gen/@amzn/codewhisperer-streaming/dist-types/CodeWhispererStreamingClient.d.ts +169 -0
  156. package/src.gen/@amzn/codewhisperer-streaming/dist-types/commands/ExportResultArchiveCommand.d.ts +103 -0
  157. package/src.gen/@amzn/codewhisperer-streaming/dist-types/commands/GenerateAssistantResponseCommand.d.ts +294 -0
  158. package/src.gen/@amzn/codewhisperer-streaming/dist-types/commands/GenerateTaskAssistPlanCommand.d.ts +304 -0
  159. package/src.gen/@amzn/codewhisperer-streaming/dist-types/commands/index.d.ts +3 -0
  160. package/src.gen/@amzn/codewhisperer-streaming/dist-types/endpoints.d.ts +2 -0
  161. package/src.gen/@amzn/codewhisperer-streaming/dist-types/extensionConfiguration.d.ts +8 -0
  162. package/src.gen/@amzn/codewhisperer-streaming/dist-types/index.d.ts +5 -0
  163. package/src.gen/@amzn/codewhisperer-streaming/dist-types/models/CodeWhispererStreamingServiceException.d.ts +13 -0
  164. package/src.gen/@amzn/codewhisperer-streaming/dist-types/models/index.d.ts +1 -0
  165. package/src.gen/@amzn/codewhisperer-streaming/dist-types/models/models_0.d.ts +1173 -0
  166. package/src.gen/@amzn/codewhisperer-streaming/dist-types/protocols/Aws_restJson1.d.ts +29 -0
  167. package/src.gen/@amzn/codewhisperer-streaming/dist-types/runtimeConfig.browser.d.ts +39 -0
  168. package/src.gen/@amzn/codewhisperer-streaming/dist-types/runtimeConfig.d.ts +39 -0
  169. package/src.gen/@amzn/codewhisperer-streaming/dist-types/runtimeConfig.native.d.ts +38 -0
  170. package/src.gen/@amzn/codewhisperer-streaming/dist-types/runtimeConfig.shared.d.ts +17 -0
  171. package/src.gen/@amzn/codewhisperer-streaming/dist-types/runtimeExtensions.d.ts +17 -0
  172. package/src.gen/@amzn/codewhisperer-streaming/package.json +87 -0
  173. package/src.gen/@amzn/codewhisperer-streaming/src/CodeWhispererStreaming.ts +84 -0
  174. package/src.gen/@amzn/codewhisperer-streaming/src/CodeWhispererStreamingClient.ts +304 -0
  175. package/src.gen/@amzn/codewhisperer-streaming/src/commands/ExportResultArchiveCommand.ts +177 -0
  176. package/src.gen/@amzn/codewhisperer-streaming/src/commands/GenerateAssistantResponseCommand.ts +369 -0
  177. package/src.gen/@amzn/codewhisperer-streaming/src/commands/GenerateTaskAssistPlanCommand.ts +379 -0
  178. package/src.gen/@amzn/codewhisperer-streaming/src/commands/index.ts +4 -0
  179. package/src.gen/@amzn/codewhisperer-streaming/src/endpoints.ts +170 -0
  180. package/src.gen/@amzn/codewhisperer-streaming/src/extensionConfiguration.ts +12 -0
  181. package/src.gen/@amzn/codewhisperer-streaming/src/index.ts +8 -0
  182. package/src.gen/@amzn/codewhisperer-streaming/src/models/CodeWhispererStreamingServiceException.ts +22 -0
  183. package/src.gen/@amzn/codewhisperer-streaming/src/models/index.ts +2 -0
  184. package/src.gen/@amzn/codewhisperer-streaming/src/models/models_0.ts +1518 -0
  185. package/src.gen/@amzn/codewhisperer-streaming/src/protocols/Aws_restJson1.ts +740 -0
  186. package/src.gen/@amzn/codewhisperer-streaming/src/runtimeConfig.browser.ts +42 -0
  187. package/src.gen/@amzn/codewhisperer-streaming/src/runtimeConfig.native.ts +17 -0
  188. package/src.gen/@amzn/codewhisperer-streaming/src/runtimeConfig.shared.ts +24 -0
  189. package/src.gen/@amzn/codewhisperer-streaming/src/runtimeConfig.ts +55 -0
  190. package/src.gen/@amzn/codewhisperer-streaming/src/runtimeExtensions.ts +44 -0
  191. package/src.gen/@amzn/codewhisperer-streaming/typedoc.json +5 -0
  192. package/script/generateServiceClient.ts +0 -242
@@ -0,0 +1,740 @@
1
+ // smithy-typescript generated code
2
+ import {
3
+ ExportResultArchiveCommandInput,
4
+ ExportResultArchiveCommandOutput,
5
+ } from '../commands/ExportResultArchiveCommand'
6
+ import {
7
+ GenerateAssistantResponseCommandInput,
8
+ GenerateAssistantResponseCommandOutput,
9
+ } from '../commands/GenerateAssistantResponseCommand'
10
+ import {
11
+ GenerateTaskAssistPlanCommandInput,
12
+ GenerateTaskAssistPlanCommandOutput,
13
+ } from '../commands/GenerateTaskAssistPlanCommand'
14
+ import { CodeWhispererStreamingServiceException as __BaseException } from '../models/CodeWhispererStreamingServiceException'
15
+ import {
16
+ AccessDeniedException,
17
+ AssistantResponseEvent,
18
+ AssistantResponseMessage,
19
+ BinaryMetadataEvent,
20
+ BinaryPayloadEvent,
21
+ ChatMessage,
22
+ ChatResponseStream,
23
+ CodeReferenceEvent,
24
+ ConflictException,
25
+ ConversationState,
26
+ CursorState,
27
+ Diagnostic,
28
+ DocumentSymbol,
29
+ EditorState,
30
+ FollowupPrompt,
31
+ FollowupPromptEvent,
32
+ InternalServerException,
33
+ InvalidStateEvent,
34
+ MessageMetadataEvent,
35
+ Position,
36
+ ProgrammingLanguage,
37
+ Range,
38
+ Reference,
39
+ ResourceNotFoundException,
40
+ ResultArchiveStream,
41
+ RuntimeDiagnostic,
42
+ Span,
43
+ SupplementaryWebLink,
44
+ SupplementaryWebLinksEvent,
45
+ TextDocument,
46
+ TextDocumentDiagnostic,
47
+ ThrottlingException,
48
+ UserInputMessage,
49
+ UserInputMessageContext,
50
+ ValidationException,
51
+ WorkspaceState,
52
+ } from '../models/models_0'
53
+ import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from '@smithy/protocol-http'
54
+ import {
55
+ decorateServiceException as __decorateServiceException,
56
+ expectString as __expectString,
57
+ _json,
58
+ collectBody,
59
+ map,
60
+ take,
61
+ withBaseException,
62
+ } from '@smithy/smithy-client'
63
+ import {
64
+ Endpoint as __Endpoint,
65
+ EventStreamSerdeContext as __EventStreamSerdeContext,
66
+ ResponseMetadata as __ResponseMetadata,
67
+ SerdeContext as __SerdeContext,
68
+ } from '@smithy/types'
69
+ import { v4 as generateIdempotencyToken } from 'uuid'
70
+
71
+ /**
72
+ * serializeAws_restJson1ExportResultArchiveCommand
73
+ */
74
+ export const se_ExportResultArchiveCommand = async (
75
+ input: ExportResultArchiveCommandInput,
76
+ context: __SerdeContext
77
+ ): Promise<__HttpRequest> => {
78
+ const { hostname, protocol = 'https', port, path: basePath } = await context.endpoint()
79
+ const headers: any = {
80
+ 'content-type': 'application/json',
81
+ }
82
+ let resolvedPath = `${basePath?.endsWith('/') ? basePath.slice(0, -1) : basePath || ''}` + '/exportResultArchive'
83
+ let body: any
84
+ body = JSON.stringify(
85
+ take(input, {
86
+ exportId: [],
87
+ exportIntent: [],
88
+ })
89
+ )
90
+ return new __HttpRequest({
91
+ protocol,
92
+ hostname,
93
+ port,
94
+ method: 'POST',
95
+ headers,
96
+ path: resolvedPath,
97
+ body,
98
+ })
99
+ }
100
+
101
+ /**
102
+ * serializeAws_restJson1GenerateAssistantResponseCommand
103
+ */
104
+ export const se_GenerateAssistantResponseCommand = async (
105
+ input: GenerateAssistantResponseCommandInput,
106
+ context: __SerdeContext
107
+ ): Promise<__HttpRequest> => {
108
+ const { hostname, protocol = 'https', port, path: basePath } = await context.endpoint()
109
+ const headers: any = {
110
+ 'content-type': 'application/json',
111
+ }
112
+ let resolvedPath =
113
+ `${basePath?.endsWith('/') ? basePath.slice(0, -1) : basePath || ''}` + '/generateAssistantResponse'
114
+ let body: any
115
+ body = JSON.stringify(
116
+ take(input, {
117
+ conversationState: _ => _json(_),
118
+ })
119
+ )
120
+ return new __HttpRequest({
121
+ protocol,
122
+ hostname,
123
+ port,
124
+ method: 'POST',
125
+ headers,
126
+ path: resolvedPath,
127
+ body,
128
+ })
129
+ }
130
+
131
+ /**
132
+ * serializeAws_restJson1GenerateTaskAssistPlanCommand
133
+ */
134
+ export const se_GenerateTaskAssistPlanCommand = async (
135
+ input: GenerateTaskAssistPlanCommandInput,
136
+ context: __SerdeContext
137
+ ): Promise<__HttpRequest> => {
138
+ const { hostname, protocol = 'https', port, path: basePath } = await context.endpoint()
139
+ const headers: any = {
140
+ 'content-type': 'application/json',
141
+ }
142
+ let resolvedPath = `${basePath?.endsWith('/') ? basePath.slice(0, -1) : basePath || ''}` + '/generateTaskAssistPlan'
143
+ let body: any
144
+ body = JSON.stringify(
145
+ take(input, {
146
+ conversationState: _ => _json(_),
147
+ workspaceState: _ => _json(_),
148
+ })
149
+ )
150
+ return new __HttpRequest({
151
+ protocol,
152
+ hostname,
153
+ port,
154
+ method: 'POST',
155
+ headers,
156
+ path: resolvedPath,
157
+ body,
158
+ })
159
+ }
160
+
161
+ /**
162
+ * deserializeAws_restJson1ExportResultArchiveCommand
163
+ */
164
+ export const de_ExportResultArchiveCommand = async (
165
+ output: __HttpResponse,
166
+ context: __SerdeContext & __EventStreamSerdeContext
167
+ ): Promise<ExportResultArchiveCommandOutput> => {
168
+ if (output.statusCode !== 200 && output.statusCode >= 300) {
169
+ return de_ExportResultArchiveCommandError(output, context)
170
+ }
171
+ const contents: any = map({
172
+ $metadata: deserializeMetadata(output),
173
+ })
174
+ const data: any = output.body
175
+ contents.body = de_ResultArchiveStream(data, context)
176
+ return contents
177
+ }
178
+
179
+ /**
180
+ * deserializeAws_restJson1ExportResultArchiveCommandError
181
+ */
182
+ const de_ExportResultArchiveCommandError = async (
183
+ output: __HttpResponse,
184
+ context: __SerdeContext
185
+ ): Promise<ExportResultArchiveCommandOutput> => {
186
+ const parsedOutput: any = {
187
+ ...output,
188
+ body: await parseErrorBody(output.body, context),
189
+ }
190
+ const errorCode = loadRestJsonErrorCode(output, parsedOutput.body)
191
+ switch (errorCode) {
192
+ case 'AccessDeniedException':
193
+ case 'com.amazon.aws.codewhisperer#AccessDeniedException':
194
+ throw await de_AccessDeniedExceptionRes(parsedOutput, context)
195
+ case 'ConflictException':
196
+ case 'com.amazon.aws.codewhisperer#ConflictException':
197
+ throw await de_ConflictExceptionRes(parsedOutput, context)
198
+ case 'InternalServerException':
199
+ case 'com.amazon.aws.codewhisperer#InternalServerException':
200
+ throw await de_InternalServerExceptionRes(parsedOutput, context)
201
+ case 'ResourceNotFoundException':
202
+ case 'com.amazon.aws.codewhisperer#ResourceNotFoundException':
203
+ throw await de_ResourceNotFoundExceptionRes(parsedOutput, context)
204
+ case 'ThrottlingException':
205
+ case 'com.amazon.aws.codewhisperer#ThrottlingException':
206
+ throw await de_ThrottlingExceptionRes(parsedOutput, context)
207
+ case 'ValidationException':
208
+ case 'com.amazon.aws.codewhisperer#ValidationException':
209
+ throw await de_ValidationExceptionRes(parsedOutput, context)
210
+ default:
211
+ const parsedBody = parsedOutput.body
212
+ return throwDefaultError({
213
+ output,
214
+ parsedBody,
215
+ errorCode,
216
+ })
217
+ }
218
+ }
219
+
220
+ /**
221
+ * deserializeAws_restJson1GenerateAssistantResponseCommand
222
+ */
223
+ export const de_GenerateAssistantResponseCommand = async (
224
+ output: __HttpResponse,
225
+ context: __SerdeContext & __EventStreamSerdeContext
226
+ ): Promise<GenerateAssistantResponseCommandOutput> => {
227
+ if (output.statusCode !== 200 && output.statusCode >= 300) {
228
+ return de_GenerateAssistantResponseCommandError(output, context)
229
+ }
230
+ const contents: any = map({
231
+ $metadata: deserializeMetadata(output),
232
+ conversationId: [, output.headers['x-amzn-codewhisperer-conversation-id']],
233
+ })
234
+ const data: any = output.body
235
+ contents.generateAssistantResponseResponse = de_ChatResponseStream(data, context)
236
+ return contents
237
+ }
238
+
239
+ /**
240
+ * deserializeAws_restJson1GenerateAssistantResponseCommandError
241
+ */
242
+ const de_GenerateAssistantResponseCommandError = async (
243
+ output: __HttpResponse,
244
+ context: __SerdeContext
245
+ ): Promise<GenerateAssistantResponseCommandOutput> => {
246
+ const parsedOutput: any = {
247
+ ...output,
248
+ body: await parseErrorBody(output.body, context),
249
+ }
250
+ const errorCode = loadRestJsonErrorCode(output, parsedOutput.body)
251
+ switch (errorCode) {
252
+ case 'AccessDeniedException':
253
+ case 'com.amazon.aws.codewhisperer#AccessDeniedException':
254
+ throw await de_AccessDeniedExceptionRes(parsedOutput, context)
255
+ case 'InternalServerException':
256
+ case 'com.amazon.aws.codewhisperer#InternalServerException':
257
+ throw await de_InternalServerExceptionRes(parsedOutput, context)
258
+ case 'ThrottlingException':
259
+ case 'com.amazon.aws.codewhisperer#ThrottlingException':
260
+ throw await de_ThrottlingExceptionRes(parsedOutput, context)
261
+ case 'ValidationException':
262
+ case 'com.amazon.aws.codewhisperer#ValidationException':
263
+ throw await de_ValidationExceptionRes(parsedOutput, context)
264
+ default:
265
+ const parsedBody = parsedOutput.body
266
+ return throwDefaultError({
267
+ output,
268
+ parsedBody,
269
+ errorCode,
270
+ })
271
+ }
272
+ }
273
+
274
+ /**
275
+ * deserializeAws_restJson1GenerateTaskAssistPlanCommand
276
+ */
277
+ export const de_GenerateTaskAssistPlanCommand = async (
278
+ output: __HttpResponse,
279
+ context: __SerdeContext & __EventStreamSerdeContext
280
+ ): Promise<GenerateTaskAssistPlanCommandOutput> => {
281
+ if (output.statusCode !== 200 && output.statusCode >= 300) {
282
+ return de_GenerateTaskAssistPlanCommandError(output, context)
283
+ }
284
+ const contents: any = map({
285
+ $metadata: deserializeMetadata(output),
286
+ })
287
+ const data: any = output.body
288
+ contents.planningResponseStream = de_ChatResponseStream(data, context)
289
+ return contents
290
+ }
291
+
292
+ /**
293
+ * deserializeAws_restJson1GenerateTaskAssistPlanCommandError
294
+ */
295
+ const de_GenerateTaskAssistPlanCommandError = async (
296
+ output: __HttpResponse,
297
+ context: __SerdeContext
298
+ ): Promise<GenerateTaskAssistPlanCommandOutput> => {
299
+ const parsedOutput: any = {
300
+ ...output,
301
+ body: await parseErrorBody(output.body, context),
302
+ }
303
+ const errorCode = loadRestJsonErrorCode(output, parsedOutput.body)
304
+ switch (errorCode) {
305
+ case 'AccessDeniedException':
306
+ case 'com.amazon.aws.codewhisperer#AccessDeniedException':
307
+ throw await de_AccessDeniedExceptionRes(parsedOutput, context)
308
+ case 'ConflictException':
309
+ case 'com.amazon.aws.codewhisperer#ConflictException':
310
+ throw await de_ConflictExceptionRes(parsedOutput, context)
311
+ case 'InternalServerException':
312
+ case 'com.amazon.aws.codewhisperer#InternalServerException':
313
+ throw await de_InternalServerExceptionRes(parsedOutput, context)
314
+ case 'ResourceNotFoundException':
315
+ case 'com.amazon.aws.codewhisperer#ResourceNotFoundException':
316
+ throw await de_ResourceNotFoundExceptionRes(parsedOutput, context)
317
+ case 'ThrottlingException':
318
+ case 'com.amazon.aws.codewhisperer#ThrottlingException':
319
+ throw await de_ThrottlingExceptionRes(parsedOutput, context)
320
+ case 'ValidationException':
321
+ case 'com.amazon.aws.codewhisperer#ValidationException':
322
+ throw await de_ValidationExceptionRes(parsedOutput, context)
323
+ default:
324
+ const parsedBody = parsedOutput.body
325
+ return throwDefaultError({
326
+ output,
327
+ parsedBody,
328
+ errorCode,
329
+ })
330
+ }
331
+ }
332
+
333
+ const throwDefaultError = withBaseException(__BaseException)
334
+ /**
335
+ * deserializeAws_restJson1AccessDeniedExceptionRes
336
+ */
337
+ const de_AccessDeniedExceptionRes = async (
338
+ parsedOutput: any,
339
+ context: __SerdeContext
340
+ ): Promise<AccessDeniedException> => {
341
+ const contents: any = map({})
342
+ const data: any = parsedOutput.body
343
+ const doc = take(data, {
344
+ message: __expectString,
345
+ reason: __expectString,
346
+ })
347
+ Object.assign(contents, doc)
348
+ const exception = new AccessDeniedException({
349
+ $metadata: deserializeMetadata(parsedOutput),
350
+ ...contents,
351
+ })
352
+ return __decorateServiceException(exception, parsedOutput.body)
353
+ }
354
+
355
+ /**
356
+ * deserializeAws_restJson1ConflictExceptionRes
357
+ */
358
+ const de_ConflictExceptionRes = async (parsedOutput: any, context: __SerdeContext): Promise<ConflictException> => {
359
+ const contents: any = map({})
360
+ const data: any = parsedOutput.body
361
+ const doc = take(data, {
362
+ message: __expectString,
363
+ })
364
+ Object.assign(contents, doc)
365
+ const exception = new ConflictException({
366
+ $metadata: deserializeMetadata(parsedOutput),
367
+ ...contents,
368
+ })
369
+ return __decorateServiceException(exception, parsedOutput.body)
370
+ }
371
+
372
+ /**
373
+ * deserializeAws_restJson1InternalServerExceptionRes
374
+ */
375
+ const de_InternalServerExceptionRes = async (
376
+ parsedOutput: any,
377
+ context: __SerdeContext
378
+ ): Promise<InternalServerException> => {
379
+ const contents: any = map({})
380
+ const data: any = parsedOutput.body
381
+ const doc = take(data, {
382
+ message: __expectString,
383
+ })
384
+ Object.assign(contents, doc)
385
+ const exception = new InternalServerException({
386
+ $metadata: deserializeMetadata(parsedOutput),
387
+ ...contents,
388
+ })
389
+ return __decorateServiceException(exception, parsedOutput.body)
390
+ }
391
+
392
+ /**
393
+ * deserializeAws_restJson1ResourceNotFoundExceptionRes
394
+ */
395
+ const de_ResourceNotFoundExceptionRes = async (
396
+ parsedOutput: any,
397
+ context: __SerdeContext
398
+ ): Promise<ResourceNotFoundException> => {
399
+ const contents: any = map({})
400
+ const data: any = parsedOutput.body
401
+ const doc = take(data, {
402
+ message: __expectString,
403
+ })
404
+ Object.assign(contents, doc)
405
+ const exception = new ResourceNotFoundException({
406
+ $metadata: deserializeMetadata(parsedOutput),
407
+ ...contents,
408
+ })
409
+ return __decorateServiceException(exception, parsedOutput.body)
410
+ }
411
+
412
+ /**
413
+ * deserializeAws_restJson1ThrottlingExceptionRes
414
+ */
415
+ const de_ThrottlingExceptionRes = async (parsedOutput: any, context: __SerdeContext): Promise<ThrottlingException> => {
416
+ const contents: any = map({})
417
+ const data: any = parsedOutput.body
418
+ const doc = take(data, {
419
+ message: __expectString,
420
+ })
421
+ Object.assign(contents, doc)
422
+ const exception = new ThrottlingException({
423
+ $metadata: deserializeMetadata(parsedOutput),
424
+ ...contents,
425
+ })
426
+ return __decorateServiceException(exception, parsedOutput.body)
427
+ }
428
+
429
+ /**
430
+ * deserializeAws_restJson1ValidationExceptionRes
431
+ */
432
+ const de_ValidationExceptionRes = async (parsedOutput: any, context: __SerdeContext): Promise<ValidationException> => {
433
+ const contents: any = map({})
434
+ const data: any = parsedOutput.body
435
+ const doc = take(data, {
436
+ message: __expectString,
437
+ reason: __expectString,
438
+ })
439
+ Object.assign(contents, doc)
440
+ const exception = new ValidationException({
441
+ $metadata: deserializeMetadata(parsedOutput),
442
+ ...contents,
443
+ })
444
+ return __decorateServiceException(exception, parsedOutput.body)
445
+ }
446
+
447
+ /**
448
+ * deserializeAws_restJson1ChatResponseStream
449
+ */
450
+ const de_ChatResponseStream = (
451
+ output: any,
452
+ context: __SerdeContext & __EventStreamSerdeContext
453
+ ): AsyncIterable<ChatResponseStream> => {
454
+ return context.eventStreamMarshaller.deserialize(output, async event => {
455
+ if (event['messageMetadataEvent'] != null) {
456
+ return {
457
+ messageMetadataEvent: await de_MessageMetadataEvent_event(event['messageMetadataEvent'], context),
458
+ }
459
+ }
460
+ if (event['assistantResponseEvent'] != null) {
461
+ return {
462
+ assistantResponseEvent: await de_AssistantResponseEvent_event(event['assistantResponseEvent'], context),
463
+ }
464
+ }
465
+ if (event['codeReferenceEvent'] != null) {
466
+ return {
467
+ codeReferenceEvent: await de_CodeReferenceEvent_event(event['codeReferenceEvent'], context),
468
+ }
469
+ }
470
+ if (event['supplementaryWebLinksEvent'] != null) {
471
+ return {
472
+ supplementaryWebLinksEvent: await de_SupplementaryWebLinksEvent_event(
473
+ event['supplementaryWebLinksEvent'],
474
+ context
475
+ ),
476
+ }
477
+ }
478
+ if (event['followupPromptEvent'] != null) {
479
+ return {
480
+ followupPromptEvent: await de_FollowupPromptEvent_event(event['followupPromptEvent'], context),
481
+ }
482
+ }
483
+ if (event['invalidStateEvent'] != null) {
484
+ return {
485
+ invalidStateEvent: await de_InvalidStateEvent_event(event['invalidStateEvent'], context),
486
+ }
487
+ }
488
+ if (event['error'] != null) {
489
+ return {
490
+ error: await de_InternalServerException_event(event['error'], context),
491
+ }
492
+ }
493
+ return { $unknown: output }
494
+ })
495
+ }
496
+ /**
497
+ * deserializeAws_restJson1ResultArchiveStream
498
+ */
499
+ const de_ResultArchiveStream = (
500
+ output: any,
501
+ context: __SerdeContext & __EventStreamSerdeContext
502
+ ): AsyncIterable<ResultArchiveStream> => {
503
+ return context.eventStreamMarshaller.deserialize(output, async event => {
504
+ if (event['binaryMetadataEvent'] != null) {
505
+ return {
506
+ binaryMetadataEvent: await de_BinaryMetadataEvent_event(event['binaryMetadataEvent'], context),
507
+ }
508
+ }
509
+ if (event['binaryPayloadEvent'] != null) {
510
+ return {
511
+ binaryPayloadEvent: await de_BinaryPayloadEvent_event(event['binaryPayloadEvent'], context),
512
+ }
513
+ }
514
+ if (event['internalServerException'] != null) {
515
+ return {
516
+ internalServerException: await de_InternalServerException_event(
517
+ event['internalServerException'],
518
+ context
519
+ ),
520
+ }
521
+ }
522
+ return { $unknown: output }
523
+ })
524
+ }
525
+ const de_AssistantResponseEvent_event = async (
526
+ output: any,
527
+ context: __SerdeContext
528
+ ): Promise<AssistantResponseEvent> => {
529
+ const contents: AssistantResponseEvent = {} as any
530
+ const data: any = await parseBody(output.body, context)
531
+ Object.assign(contents, _json(data))
532
+ return contents
533
+ }
534
+ const de_BinaryMetadataEvent_event = async (output: any, context: __SerdeContext): Promise<BinaryMetadataEvent> => {
535
+ const contents: BinaryMetadataEvent = {} as any
536
+ const data: any = await parseBody(output.body, context)
537
+ Object.assign(contents, _json(data))
538
+ return contents
539
+ }
540
+ const de_BinaryPayloadEvent_event = async (output: any, context: __SerdeContext): Promise<BinaryPayloadEvent> => {
541
+ const contents: BinaryPayloadEvent = {} as any
542
+ const data: any = await parseBody(output.body, context)
543
+ Object.assign(contents, de_BinaryPayloadEvent(data, context))
544
+ return contents
545
+ }
546
+ const de_CodeReferenceEvent_event = async (output: any, context: __SerdeContext): Promise<CodeReferenceEvent> => {
547
+ const contents: CodeReferenceEvent = {} as any
548
+ const data: any = await parseBody(output.body, context)
549
+ Object.assign(contents, _json(data))
550
+ return contents
551
+ }
552
+ const de_FollowupPromptEvent_event = async (output: any, context: __SerdeContext): Promise<FollowupPromptEvent> => {
553
+ const contents: FollowupPromptEvent = {} as any
554
+ const data: any = await parseBody(output.body, context)
555
+ Object.assign(contents, _json(data))
556
+ return contents
557
+ }
558
+ const de_InternalServerException_event = async (
559
+ output: any,
560
+ context: __SerdeContext
561
+ ): Promise<InternalServerException> => {
562
+ const parsedOutput: any = {
563
+ ...output,
564
+ body: await parseBody(output.body, context),
565
+ }
566
+ return de_InternalServerExceptionRes(parsedOutput, context)
567
+ }
568
+ const de_InvalidStateEvent_event = async (output: any, context: __SerdeContext): Promise<InvalidStateEvent> => {
569
+ const contents: InvalidStateEvent = {} as any
570
+ const data: any = await parseBody(output.body, context)
571
+ Object.assign(contents, _json(data))
572
+ return contents
573
+ }
574
+ const de_MessageMetadataEvent_event = async (output: any, context: __SerdeContext): Promise<MessageMetadataEvent> => {
575
+ const contents: MessageMetadataEvent = {} as any
576
+ const data: any = await parseBody(output.body, context)
577
+ Object.assign(contents, _json(data))
578
+ return contents
579
+ }
580
+ const de_SupplementaryWebLinksEvent_event = async (
581
+ output: any,
582
+ context: __SerdeContext
583
+ ): Promise<SupplementaryWebLinksEvent> => {
584
+ const contents: SupplementaryWebLinksEvent = {} as any
585
+ const data: any = await parseBody(output.body, context)
586
+ Object.assign(contents, _json(data))
587
+ return contents
588
+ }
589
+ // se_AssistantResponseMessage omitted.
590
+
591
+ // se_ChatHistory omitted.
592
+
593
+ // se_ChatMessage omitted.
594
+
595
+ // se_ConversationState omitted.
596
+
597
+ // se_CursorState omitted.
598
+
599
+ // se_Diagnostic omitted.
600
+
601
+ // se_DocumentSymbol omitted.
602
+
603
+ // se_DocumentSymbols omitted.
604
+
605
+ // se_EditorState omitted.
606
+
607
+ // se_FollowupPrompt omitted.
608
+
609
+ // se_Position omitted.
610
+
611
+ // se_ProgrammingLanguage omitted.
612
+
613
+ // se_Range omitted.
614
+
615
+ // se_Reference omitted.
616
+
617
+ // se_References omitted.
618
+
619
+ // se_RuntimeDiagnostic omitted.
620
+
621
+ // se_Span omitted.
622
+
623
+ // se_SupplementaryWebLink omitted.
624
+
625
+ // se_SupplementaryWebLinks omitted.
626
+
627
+ // se_TextDocument omitted.
628
+
629
+ // se_TextDocumentDiagnostic omitted.
630
+
631
+ // se_UserInputMessage omitted.
632
+
633
+ // se_UserInputMessageContext omitted.
634
+
635
+ // se_WorkspaceState omitted.
636
+
637
+ // de_AssistantResponseEvent omitted.
638
+
639
+ // de_BinaryMetadataEvent omitted.
640
+
641
+ /**
642
+ * deserializeAws_restJson1BinaryPayloadEvent
643
+ */
644
+ const de_BinaryPayloadEvent = (output: any, context: __SerdeContext): BinaryPayloadEvent => {
645
+ return take(output, {
646
+ bytes: context.base64Decoder,
647
+ }) as any
648
+ }
649
+
650
+ // de_CodeReferenceEvent omitted.
651
+
652
+ // de_FollowupPrompt omitted.
653
+
654
+ // de_FollowupPromptEvent omitted.
655
+
656
+ // de_InvalidStateEvent omitted.
657
+
658
+ // de_MessageMetadataEvent omitted.
659
+
660
+ // de_Reference omitted.
661
+
662
+ // de_References omitted.
663
+
664
+ // de_Span omitted.
665
+
666
+ // de_SupplementaryWebLink omitted.
667
+
668
+ // de_SupplementaryWebLinks omitted.
669
+
670
+ // de_SupplementaryWebLinksEvent omitted.
671
+
672
+ const deserializeMetadata = (output: __HttpResponse): __ResponseMetadata => ({
673
+ httpStatusCode: output.statusCode,
674
+ requestId:
675
+ output.headers['x-amzn-requestid'] ?? output.headers['x-amzn-request-id'] ?? output.headers['x-amz-request-id'],
676
+ extendedRequestId: output.headers['x-amz-id-2'],
677
+ cfId: output.headers['x-amz-cf-id'],
678
+ })
679
+
680
+ // Encode Uint8Array data into string with utf-8.
681
+ const collectBodyString = (streamBody: any, context: __SerdeContext): Promise<string> =>
682
+ collectBody(streamBody, context).then(body => context.utf8Encoder(body))
683
+
684
+ const isSerializableHeaderValue = (value: any): boolean =>
685
+ value !== undefined &&
686
+ value !== null &&
687
+ value !== '' &&
688
+ (!Object.getOwnPropertyNames(value).includes('length') || value.length != 0) &&
689
+ (!Object.getOwnPropertyNames(value).includes('size') || value.size != 0)
690
+
691
+ const parseBody = (streamBody: any, context: __SerdeContext): any =>
692
+ collectBodyString(streamBody, context).then(encoded => {
693
+ if (encoded.length) {
694
+ return JSON.parse(encoded)
695
+ }
696
+ return {}
697
+ })
698
+
699
+ const parseErrorBody = async (errorBody: any, context: __SerdeContext) => {
700
+ const value = await parseBody(errorBody, context)
701
+ value.message = value.message ?? value.Message
702
+ return value
703
+ }
704
+
705
+ /**
706
+ * Load an error code for the aws.rest-json-1.1 protocol.
707
+ */
708
+ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => {
709
+ const findKey = (object: any, key: string) => Object.keys(object).find(k => k.toLowerCase() === key.toLowerCase())
710
+
711
+ const sanitizeErrorCode = (rawValue: string | number): string => {
712
+ let cleanValue = rawValue
713
+ if (typeof cleanValue === 'number') {
714
+ cleanValue = cleanValue.toString()
715
+ }
716
+ if (cleanValue.indexOf(',') >= 0) {
717
+ cleanValue = cleanValue.split(',')[0]
718
+ }
719
+ if (cleanValue.indexOf(':') >= 0) {
720
+ cleanValue = cleanValue.split(':')[0]
721
+ }
722
+ if (cleanValue.indexOf('#') >= 0) {
723
+ cleanValue = cleanValue.split('#')[1]
724
+ }
725
+ return cleanValue
726
+ }
727
+
728
+ const headerKey = findKey(output.headers, 'x-amzn-errortype')
729
+ if (headerKey !== undefined) {
730
+ return sanitizeErrorCode(output.headers[headerKey])
731
+ }
732
+
733
+ if (data.code !== undefined) {
734
+ return sanitizeErrorCode(data.code)
735
+ }
736
+
737
+ if (data['__type'] !== undefined) {
738
+ return sanitizeErrorCode(data['__type'])
739
+ }
740
+ }