@aws-amplify/core 6.0.1-console-preview.f63250a.0 → 6.0.1-console-preview.5dc0b68.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 (354) hide show
  1. package/internals/adapter-core/package.json +8 -0
  2. package/internals/providers/pinpoint/package.json +8 -0
  3. package/internals/utils/package.json +7 -0
  4. package/lib/AwsClients/CognitoIdentity/getCredentialsForIdentity.d.ts +1 -1
  5. package/lib/AwsClients/CognitoIdentity/getId.d.ts +1 -1
  6. package/lib/AwsClients/Pinpoint/getInAppMessages.d.ts +1 -1
  7. package/lib/AwsClients/Pinpoint/index.d.ts +1 -1
  8. package/lib/AwsClients/Pinpoint/putEvents.d.ts +1 -1
  9. package/lib/AwsClients/Pinpoint/putEvents.js +2 -2
  10. package/lib/AwsClients/Pinpoint/updateEndpoint.d.ts +1 -1
  11. package/lib/Cache/AsyncStorageCache.js +3 -3
  12. package/lib/Cache/BrowserStorageCache.js +5 -5
  13. package/lib/Cache/InMemoryCache.js +3 -3
  14. package/lib/Cache/StorageCache.js +1 -1
  15. package/lib/Cache/Utils/CacheList.js +5 -5
  16. package/lib/Credentials.js +2 -5
  17. package/lib/{Hub.d.ts → Hub/index.d.ts} +5 -21
  18. package/lib/Hub/index.js +151 -0
  19. package/lib/Hub/types/AuthTypes.d.ts +11 -0
  20. package/lib/Hub/types/HubTypes.d.ts +28 -0
  21. package/lib/Hub/types/HubTypes.js +4 -0
  22. package/lib/Hub/types/index.d.ts +2 -0
  23. package/lib/Hub/types/index.js +20 -0
  24. package/lib/I18n/I18n.js +1 -1
  25. package/lib/I18n/index.js +5 -5
  26. package/lib/OAuthHelper/FacebookOAuth.js +1 -1
  27. package/lib/OAuthHelper/GoogleOAuth.js +1 -1
  28. package/lib/Platform/version.d.ts +1 -1
  29. package/lib/Platform/version.js +1 -1
  30. package/lib/RNComponents/index.d.ts +1 -0
  31. package/lib/RNComponents/index.js +2 -1
  32. package/lib/RNComponents/isAppInForeground.d.ts +1 -0
  33. package/lib/RNComponents/isAppInForeground.js +10 -0
  34. package/lib/ServiceWorker/ServiceWorker.js +9 -9
  35. package/lib/StorageHelper/localStorage.js +1 -1
  36. package/lib/StorageHelper/sessionStorage.js +1 -1
  37. package/lib/UniversalStorage/index.js +1 -1
  38. package/lib/Util/Constants.d.ts +12 -8
  39. package/lib/Util/Constants.js +21 -15
  40. package/lib/{Errors.d.ts → Util/Errors.d.ts} +1 -1
  41. package/lib/Util/Reachability.js +1 -1
  42. package/lib/Util/errors/AssertError.js +1 -1
  43. package/lib/Util/index.d.ts +1 -1
  44. package/lib/Util/index.js +1 -5
  45. package/lib/adapterCore/error/AmplifyServerContextError.d.ts +8 -0
  46. package/lib/adapterCore/error/AmplifyServerContextError.js +35 -0
  47. package/lib/adapterCore/error/index.d.ts +1 -0
  48. package/lib/adapterCore/error/index.js +7 -0
  49. package/lib/adapterCore/index.d.ts +2 -0
  50. package/lib/adapterCore/index.js +11 -0
  51. package/lib/adapterCore/serverContext/index.d.ts +2 -0
  52. package/lib/adapterCore/serverContext/index.js +9 -0
  53. package/lib/adapterCore/serverContext/serverContext.d.ts +20 -0
  54. package/lib/adapterCore/serverContext/serverContext.js +42 -0
  55. package/lib/adapterCore/serverContext/serverContextRegistry.d.ts +6 -0
  56. package/lib/adapterCore/serverContext/serverContextRegistry.js +24 -0
  57. package/lib/adapterCore/serverContext/types/amplifyServer.d.ts +16 -0
  58. package/lib/adapterCore/serverContext/types/amplifyServer.js +4 -0
  59. package/lib/adapterCore/serverContext/types/cookieStorage.d.ts +31 -0
  60. package/lib/adapterCore/serverContext/types/cookieStorage.js +4 -0
  61. package/lib/adapterCore/serverContext/types/index.d.ts +4 -0
  62. package/lib/adapterCore/serverContext/types/index.js +4 -0
  63. package/lib/clients/handlers/fetch.js +1 -0
  64. package/lib/clients/internal/composeServiceApi.d.ts +5 -2
  65. package/lib/index.d.ts +11 -32
  66. package/lib/index.js +19 -100
  67. package/lib/libraryUtils.d.ts +21 -0
  68. package/lib/libraryUtils.js +105 -0
  69. package/lib/providers/pinpoint/apis/index.d.ts +2 -0
  70. package/lib/providers/pinpoint/apis/index.js +9 -0
  71. package/lib/providers/pinpoint/apis/record.d.ts +5 -0
  72. package/lib/providers/pinpoint/apis/record.js +120 -0
  73. package/lib/providers/pinpoint/apis/updateEndpoint.d.ts +5 -0
  74. package/lib/providers/pinpoint/apis/updateEndpoint.js +120 -0
  75. package/lib/providers/pinpoint/index.d.ts +2 -0
  76. package/lib/providers/pinpoint/index.js +19 -0
  77. package/lib/providers/pinpoint/types/buffer.d.ts +25 -0
  78. package/lib/providers/pinpoint/types/buffer.js +4 -0
  79. package/lib/providers/pinpoint/types/index.d.ts +1 -0
  80. package/lib/providers/pinpoint/types/index.js +19 -0
  81. package/lib/providers/pinpoint/types/pinpoint.d.ts +40 -0
  82. package/lib/providers/pinpoint/types/pinpoint.js +4 -0
  83. package/lib/providers/pinpoint/utils/PinpointEventBuffer.d.ts +23 -0
  84. package/lib/providers/pinpoint/utils/PinpointEventBuffer.js +278 -0
  85. package/lib/providers/pinpoint/utils/cacheEndpointId.d.ts +7 -0
  86. package/lib/providers/pinpoint/utils/cacheEndpointId.js +61 -0
  87. package/lib/providers/pinpoint/utils/constants.d.ts +4 -0
  88. package/lib/providers/pinpoint/utils/constants.js +10 -0
  89. package/lib/providers/pinpoint/utils/getCacheKey.d.ts +7 -0
  90. package/lib/providers/pinpoint/utils/getCacheKey.js +13 -0
  91. package/lib/providers/pinpoint/utils/getEndpointId.d.ts +7 -0
  92. package/lib/providers/pinpoint/utils/getEndpointId.js +62 -0
  93. package/lib/providers/pinpoint/utils/getEventBuffer.d.ts +8 -0
  94. package/lib/providers/pinpoint/utils/getEventBuffer.js +48 -0
  95. package/lib/providers/pinpoint/utils/index.d.ts +3 -0
  96. package/lib/providers/pinpoint/utils/index.js +11 -0
  97. package/lib/server.d.ts +1 -0
  98. package/lib/server.js +7 -0
  99. package/lib/singleton/Amplify.d.ts +36 -0
  100. package/lib/singleton/Amplify.js +138 -0
  101. package/lib/singleton/Analytics/types.d.ts +2 -0
  102. package/lib/singleton/Analytics/types.js +4 -0
  103. package/lib/singleton/Auth/index.js +15 -12
  104. package/lib/singleton/Auth/types.d.ts +28 -3
  105. package/lib/singleton/Auth/utils/index.d.ts +3 -2
  106. package/lib/singleton/Auth/utils/index.js +15 -1
  107. package/lib/singleton/Storage/types.d.ts +6 -2
  108. package/lib/singleton/apis/fetchAuthSession.d.ts +2 -0
  109. package/lib/singleton/apis/fetchAuthSession.js +11 -0
  110. package/lib/singleton/apis/internal/fetchAuthSession.d.ts +3 -0
  111. package/lib/singleton/apis/internal/fetchAuthSession.js +9 -0
  112. package/lib/singleton/apis/server/fetchAuthSession.d.ts +3 -0
  113. package/lib/singleton/apis/server/fetchAuthSession.js +11 -0
  114. package/lib/singleton/index.d.ts +2 -46
  115. package/lib/singleton/index.js +7 -144
  116. package/lib/singleton/types.d.ts +3 -1
  117. package/lib/tsconfig.tsbuildinfo +1 -1
  118. package/lib/types/core.d.ts +47 -0
  119. package/lib/types/core.js +4 -0
  120. package/lib/types/errors.d.ts +16 -0
  121. package/lib/types/errors.js +4 -0
  122. package/lib/types/index.d.ts +4 -1
  123. package/lib/types/index.js +6 -3
  124. package/lib/types/logging.d.ts +13 -0
  125. package/lib/types/logging.js +4 -0
  126. package/lib/types/storage.d.ts +14 -0
  127. package/lib/types/storage.js +4 -0
  128. package/lib-esm/AwsClients/CognitoIdentity/getCredentialsForIdentity.d.ts +1 -1
  129. package/lib-esm/AwsClients/CognitoIdentity/getId.d.ts +1 -1
  130. package/lib-esm/AwsClients/Pinpoint/getInAppMessages.d.ts +1 -1
  131. package/lib-esm/AwsClients/Pinpoint/index.d.ts +1 -1
  132. package/lib-esm/AwsClients/Pinpoint/putEvents.d.ts +1 -1
  133. package/lib-esm/AwsClients/Pinpoint/putEvents.js +1 -1
  134. package/lib-esm/AwsClients/Pinpoint/updateEndpoint.d.ts +1 -1
  135. package/lib-esm/Cache/AsyncStorageCache.js +1 -1
  136. package/lib-esm/Cache/BrowserStorageCache.js +1 -1
  137. package/lib-esm/Cache/InMemoryCache.js +1 -1
  138. package/lib-esm/Cache/StorageCache.js +2 -2
  139. package/lib-esm/Cache/Utils/CacheList.js +1 -1
  140. package/lib-esm/Credentials.js +2 -5
  141. package/lib-esm/{Hub.d.ts → Hub/index.d.ts} +5 -21
  142. package/lib-esm/Hub/index.js +148 -0
  143. package/lib-esm/Hub/types/AuthTypes.d.ts +11 -0
  144. package/lib-esm/Hub/types/HubTypes.d.ts +28 -0
  145. package/lib-esm/Hub/types/HubTypes.js +3 -0
  146. package/lib-esm/Hub/types/index.d.ts +2 -0
  147. package/lib-esm/Hub/types/index.js +4 -0
  148. package/lib-esm/I18n/I18n.js +2 -2
  149. package/lib-esm/I18n/index.js +1 -1
  150. package/lib-esm/OAuthHelper/FacebookOAuth.js +1 -1
  151. package/lib-esm/OAuthHelper/GoogleOAuth.js +1 -1
  152. package/lib-esm/Platform/version.d.ts +1 -1
  153. package/lib-esm/Platform/version.js +1 -1
  154. package/lib-esm/RNComponents/index.d.ts +1 -0
  155. package/lib-esm/RNComponents/index.js +2 -1
  156. package/lib-esm/RNComponents/isAppInForeground.d.ts +1 -0
  157. package/lib-esm/RNComponents/isAppInForeground.js +6 -0
  158. package/lib-esm/ServiceWorker/ServiceWorker.js +3 -3
  159. package/lib-esm/StorageHelper/localStorage.js +1 -1
  160. package/lib-esm/StorageHelper/sessionStorage.js +1 -1
  161. package/lib-esm/UniversalStorage/index.js +1 -1
  162. package/lib-esm/Util/Constants.d.ts +12 -8
  163. package/lib-esm/Util/Constants.js +20 -8
  164. package/lib-esm/{Errors.d.ts → Util/Errors.d.ts} +1 -1
  165. package/lib-esm/Util/Reachability.js +1 -1
  166. package/lib-esm/Util/errors/AssertError.js +1 -1
  167. package/lib-esm/Util/index.d.ts +1 -1
  168. package/lib-esm/Util/index.js +1 -1
  169. package/lib-esm/adapterCore/error/AmplifyServerContextError.d.ts +8 -0
  170. package/lib-esm/adapterCore/error/AmplifyServerContextError.js +32 -0
  171. package/lib-esm/adapterCore/error/index.d.ts +1 -0
  172. package/lib-esm/adapterCore/error/index.js +3 -0
  173. package/lib-esm/adapterCore/index.d.ts +2 -0
  174. package/lib-esm/adapterCore/index.js +4 -0
  175. package/lib-esm/adapterCore/serverContext/index.d.ts +2 -0
  176. package/lib-esm/adapterCore/serverContext/index.js +3 -0
  177. package/lib-esm/adapterCore/serverContext/serverContext.d.ts +20 -0
  178. package/lib-esm/adapterCore/serverContext/serverContext.js +36 -0
  179. package/lib-esm/adapterCore/serverContext/serverContextRegistry.d.ts +6 -0
  180. package/lib-esm/adapterCore/serverContext/serverContextRegistry.js +21 -0
  181. package/lib-esm/adapterCore/serverContext/types/amplifyServer.d.ts +16 -0
  182. package/lib-esm/adapterCore/serverContext/types/amplifyServer.js +3 -0
  183. package/lib-esm/adapterCore/serverContext/types/cookieStorage.d.ts +31 -0
  184. package/lib-esm/adapterCore/serverContext/types/cookieStorage.js +3 -0
  185. package/lib-esm/adapterCore/serverContext/types/index.d.ts +4 -0
  186. package/lib-esm/adapterCore/serverContext/types/index.js +3 -0
  187. package/lib-esm/clients/handlers/fetch.js +1 -0
  188. package/lib-esm/clients/internal/composeServiceApi.d.ts +5 -2
  189. package/lib-esm/index.d.ts +11 -32
  190. package/lib-esm/index.js +11 -29
  191. package/lib-esm/libraryUtils.d.ts +21 -0
  192. package/lib-esm/libraryUtils.js +33 -0
  193. package/lib-esm/providers/pinpoint/apis/index.d.ts +2 -0
  194. package/lib-esm/providers/pinpoint/apis/index.js +4 -0
  195. package/lib-esm/providers/pinpoint/apis/record.d.ts +5 -0
  196. package/lib-esm/providers/pinpoint/apis/record.js +116 -0
  197. package/lib-esm/providers/pinpoint/apis/updateEndpoint.d.ts +5 -0
  198. package/lib-esm/providers/pinpoint/apis/updateEndpoint.js +116 -0
  199. package/lib-esm/providers/pinpoint/index.d.ts +2 -0
  200. package/lib-esm/providers/pinpoint/index.js +3 -0
  201. package/lib-esm/providers/pinpoint/types/buffer.d.ts +25 -0
  202. package/lib-esm/providers/pinpoint/types/buffer.js +3 -0
  203. package/lib-esm/providers/pinpoint/types/index.d.ts +1 -0
  204. package/lib-esm/providers/pinpoint/types/index.js +3 -0
  205. package/lib-esm/providers/pinpoint/types/pinpoint.d.ts +40 -0
  206. package/lib-esm/providers/pinpoint/types/pinpoint.js +3 -0
  207. package/lib-esm/providers/pinpoint/utils/PinpointEventBuffer.d.ts +23 -0
  208. package/lib-esm/providers/pinpoint/utils/PinpointEventBuffer.js +275 -0
  209. package/lib-esm/providers/pinpoint/utils/cacheEndpointId.d.ts +7 -0
  210. package/lib-esm/providers/pinpoint/utils/cacheEndpointId.js +57 -0
  211. package/lib-esm/providers/pinpoint/utils/constants.d.ts +4 -0
  212. package/lib-esm/providers/pinpoint/utils/constants.js +7 -0
  213. package/lib-esm/providers/pinpoint/utils/getCacheKey.d.ts +7 -0
  214. package/lib-esm/providers/pinpoint/utils/getCacheKey.js +9 -0
  215. package/lib-esm/providers/pinpoint/utils/getEndpointId.d.ts +7 -0
  216. package/lib-esm/providers/pinpoint/utils/getEndpointId.js +58 -0
  217. package/lib-esm/providers/pinpoint/utils/getEventBuffer.d.ts +8 -0
  218. package/lib-esm/providers/pinpoint/utils/getEventBuffer.js +44 -0
  219. package/lib-esm/providers/pinpoint/utils/index.d.ts +3 -0
  220. package/lib-esm/providers/pinpoint/utils/index.js +5 -0
  221. package/lib-esm/server.d.ts +1 -0
  222. package/lib-esm/server.js +3 -0
  223. package/lib-esm/singleton/Amplify.d.ts +36 -0
  224. package/lib-esm/singleton/Amplify.js +135 -0
  225. package/lib-esm/singleton/Analytics/types.d.ts +2 -0
  226. package/lib-esm/singleton/Analytics/types.js +3 -0
  227. package/lib-esm/singleton/Auth/index.js +14 -11
  228. package/lib-esm/singleton/Auth/types.d.ts +28 -3
  229. package/lib-esm/singleton/Auth/utils/index.d.ts +3 -2
  230. package/lib-esm/singleton/Auth/utils/index.js +13 -0
  231. package/lib-esm/singleton/Storage/types.d.ts +6 -2
  232. package/lib-esm/singleton/apis/fetchAuthSession.d.ts +2 -0
  233. package/lib-esm/singleton/apis/fetchAuthSession.js +7 -0
  234. package/lib-esm/singleton/apis/internal/fetchAuthSession.d.ts +3 -0
  235. package/lib-esm/singleton/apis/internal/fetchAuthSession.js +5 -0
  236. package/lib-esm/singleton/apis/server/fetchAuthSession.d.ts +3 -0
  237. package/lib-esm/singleton/apis/server/fetchAuthSession.js +7 -0
  238. package/lib-esm/singleton/index.d.ts +2 -46
  239. package/lib-esm/singleton/index.js +2 -141
  240. package/lib-esm/singleton/types.d.ts +3 -1
  241. package/lib-esm/tsconfig.tsbuildinfo +1 -1
  242. package/lib-esm/types/core.d.ts +47 -0
  243. package/lib-esm/types/core.js +3 -0
  244. package/lib-esm/types/errors.d.ts +16 -0
  245. package/lib-esm/types/errors.js +3 -0
  246. package/lib-esm/types/index.d.ts +4 -1
  247. package/lib-esm/types/index.js +4 -1
  248. package/lib-esm/types/logging.d.ts +13 -0
  249. package/lib-esm/types/logging.js +3 -0
  250. package/lib-esm/types/storage.d.ts +14 -0
  251. package/lib-esm/types/storage.js +3 -0
  252. package/package.json +15 -12
  253. package/server/package.json +8 -0
  254. package/src/AwsClients/Pinpoint/index.ts +1 -1
  255. package/src/AwsClients/Pinpoint/putEvents.ts +1 -1
  256. package/src/Cache/AsyncStorageCache.ts +1 -1
  257. package/src/Cache/BrowserStorageCache.ts +1 -1
  258. package/src/Cache/InMemoryCache.ts +1 -1
  259. package/src/Cache/StorageCache.ts +2 -2
  260. package/src/Cache/Utils/CacheList.ts +1 -1
  261. package/src/Credentials.ts +2 -8
  262. package/src/Hub/index.ts +204 -0
  263. package/src/Hub/types/AuthTypes.ts +10 -0
  264. package/src/Hub/types/HubTypes.ts +46 -0
  265. package/src/{Providers → Hub/types}/index.ts +3 -1
  266. package/src/I18n/I18n.ts +2 -2
  267. package/src/I18n/index.ts +1 -1
  268. package/src/Logger/ConsoleLogger.ts +1 -2
  269. package/src/OAuthHelper/FacebookOAuth.ts +1 -1
  270. package/src/OAuthHelper/GoogleOAuth.ts +1 -1
  271. package/src/Platform/version.ts +1 -1
  272. package/src/RNComponents/index.ts +2 -1
  273. package/src/RNComponents/isAppInForeground.ts +8 -0
  274. package/src/ServiceWorker/ServiceWorker.ts +3 -3
  275. package/src/StorageHelper/localStorage.ts +1 -1
  276. package/src/StorageHelper/sessionStorage.ts +1 -1
  277. package/src/UniversalStorage/index.ts +1 -1
  278. package/src/Util/Constants.ts +25 -16
  279. package/src/{Errors.ts → Util/Errors.ts} +1 -1
  280. package/src/Util/Reachability.ts +1 -1
  281. package/src/Util/errors/AssertError.ts +1 -1
  282. package/src/Util/index.ts +0 -4
  283. package/src/adapterCore/error/AmplifyServerContextError.ts +23 -0
  284. package/src/adapterCore/error/index.ts +4 -0
  285. package/src/adapterCore/index.ts +11 -0
  286. package/src/adapterCore/serverContext/index.ts +10 -0
  287. package/src/adapterCore/serverContext/serverContext.ts +54 -0
  288. package/src/adapterCore/serverContext/serverContextRegistry.ts +31 -0
  289. package/src/adapterCore/serverContext/types/amplifyServer.ts +29 -0
  290. package/src/adapterCore/serverContext/types/cookieStorage.ts +43 -0
  291. package/src/adapterCore/serverContext/types/index.ts +9 -0
  292. package/src/clients/handlers/fetch.ts +1 -0
  293. package/src/clients/internal/composeServiceApi.ts +13 -4
  294. package/src/index.ts +40 -120
  295. package/src/libraryUtils.ts +102 -0
  296. package/src/providers/pinpoint/apis/index.ts +5 -0
  297. package/src/providers/pinpoint/apis/record.ts +90 -0
  298. package/src/providers/pinpoint/apis/updateEndpoint.ts +82 -0
  299. package/src/providers/pinpoint/index.ts +5 -0
  300. package/src/providers/pinpoint/types/buffer.ts +32 -0
  301. package/{lib-esm/Providers/index.js → src/providers/pinpoint/types/index.ts} +2 -1
  302. package/src/providers/pinpoint/types/pinpoint.ts +55 -0
  303. package/src/providers/pinpoint/utils/PinpointEventBuffer.ts +248 -0
  304. package/src/providers/pinpoint/utils/cacheEndpointId.ts +27 -0
  305. package/src/providers/pinpoint/utils/constants.ts +8 -0
  306. package/src/providers/pinpoint/utils/getCacheKey.ts +16 -0
  307. package/src/providers/pinpoint/utils/getEndpointId.ts +20 -0
  308. package/src/providers/pinpoint/utils/getEventBuffer.ts +60 -0
  309. package/src/providers/pinpoint/utils/index.ts +6 -0
  310. package/src/server.ts +4 -0
  311. package/src/singleton/Amplify.ts +121 -0
  312. package/src/singleton/Analytics/types.ts +6 -0
  313. package/src/singleton/Auth/index.ts +7 -5
  314. package/src/singleton/Auth/types.ts +38 -6
  315. package/src/singleton/Auth/utils/index.ts +27 -1
  316. package/src/singleton/Storage/types.ts +6 -3
  317. package/src/singleton/apis/fetchAuthSession.ts +12 -0
  318. package/src/singleton/apis/internal/fetchAuthSession.ts +12 -0
  319. package/src/singleton/apis/server/fetchAuthSession.ts +16 -0
  320. package/src/singleton/index.ts +2 -128
  321. package/src/singleton/types.ts +4 -4
  322. package/src/types/core.ts +58 -0
  323. package/src/types/errors.ts +21 -0
  324. package/src/types/index.ts +5 -1
  325. package/src/types/logging.ts +24 -0
  326. package/src/types/storage.ts +19 -0
  327. package/lib/Hub.js +0 -220
  328. package/lib/Providers/AWSCloudWatchProvider.d.ts +0 -34
  329. package/lib/Providers/AWSCloudWatchProvider.js +0 -619
  330. package/lib/Providers/index.d.ts +0 -1
  331. package/lib/Providers/index.js +0 -7
  332. package/lib/constants.d.ts +0 -9
  333. package/lib/constants.js +0 -22
  334. package/lib/types/types.d.ts +0 -76
  335. package/lib-esm/Hub.js +0 -217
  336. package/lib-esm/Providers/AWSCloudWatchProvider.d.ts +0 -34
  337. package/lib-esm/Providers/AWSCloudWatchProvider.js +0 -616
  338. package/lib-esm/Providers/index.d.ts +0 -1
  339. package/lib-esm/constants.d.ts +0 -9
  340. package/lib-esm/constants.js +0 -19
  341. package/lib-esm/types/types.d.ts +0 -76
  342. package/src/Hub.ts +0 -236
  343. package/src/Providers/AWSCloudWatchProvider.ts +0 -540
  344. package/src/constants.ts +0 -31
  345. package/src/types/types.ts +0 -104
  346. /package/lib/{types/types.js → Hub/types/AuthTypes.js} +0 -0
  347. /package/lib/{Errors.js → Util/Errors.js} +0 -0
  348. /package/lib/{JS.d.ts → Util/JS.d.ts} +0 -0
  349. /package/lib/{JS.js → Util/JS.js} +0 -0
  350. /package/lib-esm/{types/types.js → Hub/types/AuthTypes.js} +0 -0
  351. /package/lib-esm/{Errors.js → Util/Errors.js} +0 -0
  352. /package/lib-esm/{JS.d.ts → Util/JS.d.ts} +0 -0
  353. /package/lib-esm/{JS.js → Util/JS.js} +0 -0
  354. /package/src/{JS.ts → Util/JS.ts} +0 -0
@@ -1,616 +0,0 @@
1
- // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- // SPDX-License-Identifier: Apache-2.0
3
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
- return new (P || (P = Promise))(function (resolve, reject) {
6
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9
- step((generator = generator.apply(thisArg, _arguments || [])).next());
10
- });
11
- };
12
- var __generator = (this && this.__generator) || function (thisArg, body) {
13
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
14
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
15
- function verb(n) { return function (v) { return step([n, v]); }; }
16
- function step(op) {
17
- if (f) throw new TypeError("Generator is already executing.");
18
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
19
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
20
- if (y = 0, t) op = [op[0] & 2, t.value];
21
- switch (op[0]) {
22
- case 0: case 1: t = op; break;
23
- case 4: _.label++; return { value: op[1], done: false };
24
- case 5: _.label++; y = op[1]; op = [0]; continue;
25
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
26
- default:
27
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
28
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
29
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
30
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
31
- if (t[2]) _.ops.pop();
32
- _.trys.pop(); continue;
33
- }
34
- op = body.call(thisArg, _);
35
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
36
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
37
- }
38
- };
39
- var __read = (this && this.__read) || function (o, n) {
40
- var m = typeof Symbol === "function" && o[Symbol.iterator];
41
- if (!m) return o;
42
- var i = m.call(o), r, ar = [], e;
43
- try {
44
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
45
- }
46
- catch (error) { e = { error: error }; }
47
- finally {
48
- try {
49
- if (r && !r.done && (m = i["return"])) m.call(i);
50
- }
51
- finally { if (e) throw e.error; }
52
- }
53
- return ar;
54
- };
55
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
56
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
57
- if (ar || !(i in from)) {
58
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
59
- ar[i] = from[i];
60
- }
61
- }
62
- return to.concat(ar || Array.prototype.slice.call(from));
63
- };
64
- import { CloudWatchLogsClient, CreateLogGroupCommand, CreateLogStreamCommand, DescribeLogGroupsCommand, DescribeLogStreamsCommand, GetLogEventsCommand, PutLogEventsCommand, } from '@aws-sdk/client-cloudwatch-logs';
65
- import { Credentials } from '../Credentials';
66
- import { ConsoleLogger as Logger } from '../Logger';
67
- import { getAmplifyUserAgentObject } from '../Platform';
68
- import { parseAWSExports } from '../parseAWSExports';
69
- import { AWS_CLOUDWATCH_BASE_BUFFER_SIZE, AWS_CLOUDWATCH_CATEGORY, AWS_CLOUDWATCH_MAX_BATCH_EVENT_SIZE, AWS_CLOUDWATCH_MAX_EVENT_SIZE, AWS_CLOUDWATCH_PROVIDER_NAME, NO_CREDS_ERROR_STRING, RETRY_ERROR_CODES, } from '../Util/Constants';
70
- import { asserts } from '../Util/errors/AssertError';
71
- import { AWS_CLOUD_WATCH_PROVIDER_OPTIONS_EXCEPTION } from '../constants';
72
- var logger = new Logger('AWSCloudWatch');
73
- var AWSCloudWatchProvider = /** @class */ (function () {
74
- function AWSCloudWatchProvider(config) {
75
- this.configure(config);
76
- this._dataTracker = {
77
- eventUploadInProgress: false,
78
- logEvents: [],
79
- };
80
- this._currentLogBatch = [];
81
- this._initiateLogPushInterval();
82
- }
83
- AWSCloudWatchProvider.prototype.getProviderName = function () {
84
- return AWSCloudWatchProvider.PROVIDER_NAME;
85
- };
86
- AWSCloudWatchProvider.prototype.getCategoryName = function () {
87
- return AWSCloudWatchProvider.CATEGORY;
88
- };
89
- AWSCloudWatchProvider.prototype.getLogQueue = function () {
90
- return this._dataTracker.logEvents;
91
- };
92
- AWSCloudWatchProvider.prototype.configure = function (config) {
93
- if (!config)
94
- return this._config || {};
95
- var conf = Object.assign({}, this._config, parseAWSExports(config).Logging, config);
96
- this._config = conf;
97
- return this._config;
98
- };
99
- AWSCloudWatchProvider.prototype.createLogGroup = function (params) {
100
- return __awaiter(this, void 0, void 0, function () {
101
- var cmd, credentialsOK, client, output, error_1;
102
- return __generator(this, function (_a) {
103
- switch (_a.label) {
104
- case 0:
105
- logger.debug('creating new log group in CloudWatch - ', params.logGroupName);
106
- cmd = new CreateLogGroupCommand(params);
107
- _a.label = 1;
108
- case 1:
109
- _a.trys.push([1, 4, , 5]);
110
- return [4 /*yield*/, this._ensureCredentials()];
111
- case 2:
112
- credentialsOK = _a.sent();
113
- if (!credentialsOK) {
114
- throw new Error(NO_CREDS_ERROR_STRING);
115
- }
116
- client = this._initCloudWatchLogs();
117
- return [4 /*yield*/, client.send(cmd)];
118
- case 3:
119
- output = _a.sent();
120
- return [2 /*return*/, output];
121
- case 4:
122
- error_1 = _a.sent();
123
- logger.error("error creating log group - ".concat(error_1));
124
- throw error_1;
125
- case 5: return [2 /*return*/];
126
- }
127
- });
128
- });
129
- };
130
- AWSCloudWatchProvider.prototype.getLogGroups = function (params) {
131
- return __awaiter(this, void 0, void 0, function () {
132
- var cmd, credentialsOK, client, output, error_2;
133
- return __generator(this, function (_a) {
134
- switch (_a.label) {
135
- case 0:
136
- logger.debug('getting list of log groups');
137
- cmd = new DescribeLogGroupsCommand(params);
138
- _a.label = 1;
139
- case 1:
140
- _a.trys.push([1, 4, , 5]);
141
- return [4 /*yield*/, this._ensureCredentials()];
142
- case 2:
143
- credentialsOK = _a.sent();
144
- if (!credentialsOK) {
145
- throw new Error(NO_CREDS_ERROR_STRING);
146
- }
147
- client = this._initCloudWatchLogs();
148
- return [4 /*yield*/, client.send(cmd)];
149
- case 3:
150
- output = _a.sent();
151
- return [2 /*return*/, output];
152
- case 4:
153
- error_2 = _a.sent();
154
- logger.error("error getting log group - ".concat(error_2));
155
- throw error_2;
156
- case 5: return [2 /*return*/];
157
- }
158
- });
159
- });
160
- };
161
- AWSCloudWatchProvider.prototype.createLogStream = function (params) {
162
- return __awaiter(this, void 0, void 0, function () {
163
- var cmd, credentialsOK, client, output, error_3;
164
- return __generator(this, function (_a) {
165
- switch (_a.label) {
166
- case 0:
167
- logger.debug('creating new log stream in CloudWatch - ', params.logStreamName);
168
- cmd = new CreateLogStreamCommand(params);
169
- _a.label = 1;
170
- case 1:
171
- _a.trys.push([1, 4, , 5]);
172
- return [4 /*yield*/, this._ensureCredentials()];
173
- case 2:
174
- credentialsOK = _a.sent();
175
- if (!credentialsOK) {
176
- throw new Error(NO_CREDS_ERROR_STRING);
177
- }
178
- client = this._initCloudWatchLogs();
179
- return [4 /*yield*/, client.send(cmd)];
180
- case 3:
181
- output = _a.sent();
182
- return [2 /*return*/, output];
183
- case 4:
184
- error_3 = _a.sent();
185
- logger.error("error creating log stream - ".concat(error_3));
186
- throw error_3;
187
- case 5: return [2 /*return*/];
188
- }
189
- });
190
- });
191
- };
192
- AWSCloudWatchProvider.prototype.getLogStreams = function (params) {
193
- return __awaiter(this, void 0, void 0, function () {
194
- var cmd, credentialsOK, client, output, error_4;
195
- return __generator(this, function (_a) {
196
- switch (_a.label) {
197
- case 0:
198
- logger.debug('getting list of log streams');
199
- cmd = new DescribeLogStreamsCommand(params);
200
- _a.label = 1;
201
- case 1:
202
- _a.trys.push([1, 4, , 5]);
203
- return [4 /*yield*/, this._ensureCredentials()];
204
- case 2:
205
- credentialsOK = _a.sent();
206
- if (!credentialsOK) {
207
- throw new Error(NO_CREDS_ERROR_STRING);
208
- }
209
- client = this._initCloudWatchLogs();
210
- return [4 /*yield*/, client.send(cmd)];
211
- case 3:
212
- output = _a.sent();
213
- return [2 /*return*/, output];
214
- case 4:
215
- error_4 = _a.sent();
216
- logger.error("error getting log stream - ".concat(error_4));
217
- throw error_4;
218
- case 5: return [2 /*return*/];
219
- }
220
- });
221
- });
222
- };
223
- AWSCloudWatchProvider.prototype.getLogEvents = function (params) {
224
- return __awaiter(this, void 0, void 0, function () {
225
- var cmd, credentialsOK, client, output, error_5;
226
- return __generator(this, function (_a) {
227
- switch (_a.label) {
228
- case 0:
229
- logger.debug('getting log events from stream - ', params.logStreamName);
230
- cmd = new GetLogEventsCommand(params);
231
- _a.label = 1;
232
- case 1:
233
- _a.trys.push([1, 4, , 5]);
234
- return [4 /*yield*/, this._ensureCredentials()];
235
- case 2:
236
- credentialsOK = _a.sent();
237
- if (!credentialsOK) {
238
- throw new Error(NO_CREDS_ERROR_STRING);
239
- }
240
- client = this._initCloudWatchLogs();
241
- return [4 /*yield*/, client.send(cmd)];
242
- case 3:
243
- output = _a.sent();
244
- return [2 /*return*/, output];
245
- case 4:
246
- error_5 = _a.sent();
247
- logger.error("error getting log events - ".concat(error_5));
248
- throw error_5;
249
- case 5: return [2 /*return*/];
250
- }
251
- });
252
- });
253
- };
254
- AWSCloudWatchProvider.prototype.pushLogs = function (logs) {
255
- logger.debug('pushing log events to Cloudwatch...');
256
- this._dataTracker.logEvents = __spreadArray(__spreadArray([], __read(this._dataTracker.logEvents), false), __read(logs), false);
257
- };
258
- AWSCloudWatchProvider.prototype._validateLogGroupExistsAndCreate = function (logGroupName) {
259
- return __awaiter(this, void 0, void 0, function () {
260
- var credentialsOK, currGroups, foundGroups, err_1, errString;
261
- return __generator(this, function (_a) {
262
- switch (_a.label) {
263
- case 0:
264
- if (this._dataTracker.verifiedLogGroup) {
265
- return [2 /*return*/, this._dataTracker.verifiedLogGroup];
266
- }
267
- _a.label = 1;
268
- case 1:
269
- _a.trys.push([1, 5, , 6]);
270
- return [4 /*yield*/, this._ensureCredentials()];
271
- case 2:
272
- credentialsOK = _a.sent();
273
- if (!credentialsOK) {
274
- throw new Error(NO_CREDS_ERROR_STRING);
275
- }
276
- return [4 /*yield*/, this.getLogGroups({
277
- logGroupNamePrefix: logGroupName,
278
- })];
279
- case 3:
280
- currGroups = _a.sent();
281
- if (!(typeof currGroups === 'string') && currGroups.logGroups) {
282
- foundGroups = currGroups.logGroups.filter(function (group) { return group.logGroupName === logGroupName; });
283
- if (foundGroups.length > 0) {
284
- this._dataTracker.verifiedLogGroup = foundGroups[0];
285
- return [2 /*return*/, foundGroups[0]];
286
- }
287
- }
288
- /**
289
- * If we get to this point, it means that the specified log group does not exist
290
- * and we should create it.
291
- */
292
- return [4 /*yield*/, this.createLogGroup({ logGroupName: logGroupName })];
293
- case 4:
294
- /**
295
- * If we get to this point, it means that the specified log group does not exist
296
- * and we should create it.
297
- */
298
- _a.sent();
299
- return [2 /*return*/, null];
300
- case 5:
301
- err_1 = _a.sent();
302
- errString = "failure during log group search: ".concat(err_1);
303
- logger.error(errString);
304
- throw err_1;
305
- case 6: return [2 /*return*/];
306
- }
307
- });
308
- });
309
- };
310
- AWSCloudWatchProvider.prototype._validateLogStreamExists = function (logGroupName, logStreamName) {
311
- return __awaiter(this, void 0, void 0, function () {
312
- var credentialsOK, currStreams, foundStreams, err_2, errString;
313
- return __generator(this, function (_a) {
314
- switch (_a.label) {
315
- case 0:
316
- _a.trys.push([0, 4, , 5]);
317
- return [4 /*yield*/, this._ensureCredentials()];
318
- case 1:
319
- credentialsOK = _a.sent();
320
- if (!credentialsOK) {
321
- throw new Error(NO_CREDS_ERROR_STRING);
322
- }
323
- return [4 /*yield*/, this.getLogStreams({
324
- logGroupName: logGroupName,
325
- logStreamNamePrefix: logStreamName,
326
- })];
327
- case 2:
328
- currStreams = _a.sent();
329
- if (currStreams.logStreams) {
330
- foundStreams = currStreams.logStreams.filter(function (stream) { return stream.logStreamName === logStreamName; });
331
- if (foundStreams.length > 0) {
332
- this._nextSequenceToken = foundStreams[0].uploadSequenceToken;
333
- return [2 /*return*/, foundStreams[0]];
334
- }
335
- }
336
- /**
337
- * If we get to this point, it means that the specified stream does not
338
- * exist, and we should create it now.
339
- */
340
- return [4 /*yield*/, this.createLogStream({
341
- logGroupName: logGroupName,
342
- logStreamName: logStreamName,
343
- })];
344
- case 3:
345
- /**
346
- * If we get to this point, it means that the specified stream does not
347
- * exist, and we should create it now.
348
- */
349
- _a.sent();
350
- return [2 /*return*/, null];
351
- case 4:
352
- err_2 = _a.sent();
353
- errString = "failure during log stream search: ".concat(err_2);
354
- logger.error(errString);
355
- throw err_2;
356
- case 5: return [2 /*return*/];
357
- }
358
- });
359
- });
360
- };
361
- AWSCloudWatchProvider.prototype._sendLogEvents = function (params) {
362
- return __awaiter(this, void 0, void 0, function () {
363
- var credentialsOK, cmd, client, output, err_3, errString;
364
- return __generator(this, function (_a) {
365
- switch (_a.label) {
366
- case 0:
367
- _a.trys.push([0, 3, , 4]);
368
- return [4 /*yield*/, this._ensureCredentials()];
369
- case 1:
370
- credentialsOK = _a.sent();
371
- if (!credentialsOK) {
372
- throw new Error(NO_CREDS_ERROR_STRING);
373
- }
374
- logger.debug('sending log events to stream - ', params.logStreamName);
375
- cmd = new PutLogEventsCommand(params);
376
- client = this._initCloudWatchLogs();
377
- return [4 /*yield*/, client.send(cmd)];
378
- case 2:
379
- output = _a.sent();
380
- return [2 /*return*/, output];
381
- case 3:
382
- err_3 = _a.sent();
383
- errString = "failure during log push: ".concat(err_3);
384
- logger.error(errString);
385
- return [3 /*break*/, 4];
386
- case 4: return [2 /*return*/];
387
- }
388
- });
389
- });
390
- };
391
- AWSCloudWatchProvider.prototype._initCloudWatchLogs = function () {
392
- assertsAWSClouldWatchOptions(this._config);
393
- return new CloudWatchLogsClient({
394
- region: this._config.region,
395
- credentials: this._config.credentials,
396
- customUserAgent: getAmplifyUserAgentObject(),
397
- endpoint: this._config.endpoint,
398
- });
399
- };
400
- AWSCloudWatchProvider.prototype._ensureCredentials = function () {
401
- return __awaiter(this, void 0, void 0, function () {
402
- var _this = this;
403
- return __generator(this, function (_a) {
404
- switch (_a.label) {
405
- case 0: return [4 /*yield*/, Credentials.get()
406
- .then(function (credentials) {
407
- assertsAWSClouldWatchOptions(_this._config);
408
- if (!credentials)
409
- return false;
410
- var cred = Credentials.shear(credentials);
411
- logger.debug('set credentials for logging', cred);
412
- _this._config.credentials = cred;
413
- return true;
414
- })
415
- .catch(function (error) {
416
- logger.warn('ensure credentials error', error);
417
- return false;
418
- })];
419
- case 1: return [2 /*return*/, _a.sent()];
420
- }
421
- });
422
- });
423
- };
424
- AWSCloudWatchProvider.prototype._getNextSequenceToken = function () {
425
- return __awaiter(this, void 0, void 0, function () {
426
- var logStream, err_4;
427
- return __generator(this, function (_a) {
428
- switch (_a.label) {
429
- case 0:
430
- assertsAWSClouldWatchOptions(this._config);
431
- if (this._nextSequenceToken && this._nextSequenceToken.length > 0) {
432
- return [2 /*return*/, this._nextSequenceToken];
433
- }
434
- _a.label = 1;
435
- case 1:
436
- _a.trys.push([1, 4, , 5]);
437
- asserts(this._config.logGroupName !== undefined, {
438
- name: AWS_CLOUD_WATCH_PROVIDER_OPTIONS_EXCEPTION,
439
- message: ' log group name is undefined',
440
- });
441
- asserts(this._config.logStreamName !== undefined, {
442
- name: AWS_CLOUD_WATCH_PROVIDER_OPTIONS_EXCEPTION,
443
- message: ' log stream name is undefined',
444
- });
445
- return [4 /*yield*/, this._validateLogGroupExistsAndCreate(this._config.logGroupName)];
446
- case 2:
447
- _a.sent();
448
- this._nextSequenceToken = undefined;
449
- return [4 /*yield*/, this._validateLogStreamExists(this._config.logGroupName, this._config.logStreamName)];
450
- case 3:
451
- logStream = _a.sent();
452
- if (logStream) {
453
- this._nextSequenceToken = logStream.uploadSequenceToken;
454
- }
455
- return [2 /*return*/, this._nextSequenceToken];
456
- case 4:
457
- err_4 = _a.sent();
458
- logger.error("failure while getting next sequence token: ".concat(err_4));
459
- throw err_4;
460
- case 5: return [2 /*return*/];
461
- }
462
- });
463
- });
464
- };
465
- AWSCloudWatchProvider.prototype._safeUploadLogEvents = function () {
466
- return __awaiter(this, void 0, void 0, function () {
467
- var seqToken, logBatch, putLogsPayload, sendLogEventsResponse, err_5;
468
- return __generator(this, function (_a) {
469
- switch (_a.label) {
470
- case 0:
471
- assertsAWSClouldWatchOptions(this._config);
472
- _a.label = 1;
473
- case 1:
474
- _a.trys.push([1, 4, , 5]);
475
- return [4 /*yield*/, this._getNextSequenceToken()];
476
- case 2:
477
- seqToken = _a.sent();
478
- logBatch = this._currentLogBatch.length === 0
479
- ? this._getBufferedBatchOfLogs()
480
- : this._currentLogBatch;
481
- putLogsPayload = {
482
- logGroupName: this._config.logGroupName,
483
- logStreamName: this._config.logStreamName,
484
- logEvents: logBatch,
485
- sequenceToken: seqToken,
486
- };
487
- this._dataTracker.eventUploadInProgress = true;
488
- return [4 /*yield*/, this._sendLogEvents(putLogsPayload)];
489
- case 3:
490
- sendLogEventsResponse = _a.sent();
491
- this._nextSequenceToken = sendLogEventsResponse === null || sendLogEventsResponse === void 0 ? void 0 : sendLogEventsResponse.nextSequenceToken;
492
- this._dataTracker.eventUploadInProgress = false;
493
- this._currentLogBatch = [];
494
- return [2 /*return*/, sendLogEventsResponse];
495
- case 4:
496
- err_5 = _a.sent();
497
- logger.error("error during _safeUploadLogEvents: ".concat(err_5));
498
- if (err_5 instanceof Error && RETRY_ERROR_CODES.includes(err_5.name)) {
499
- this._getNewSequenceTokenAndSubmit({
500
- logEvents: this._currentLogBatch,
501
- logGroupName: this._config.logGroupName,
502
- logStreamName: this._config.logStreamName,
503
- });
504
- }
505
- else {
506
- this._dataTracker.eventUploadInProgress = false;
507
- throw err_5;
508
- }
509
- return [3 /*break*/, 5];
510
- case 5: return [2 /*return*/];
511
- }
512
- });
513
- });
514
- };
515
- AWSCloudWatchProvider.prototype._getBufferedBatchOfLogs = function () {
516
- var _a;
517
- /**
518
- * CloudWatch has restrictions on the size of the log events that get sent up.
519
- * We need to track both the size of each event and the total size of the batch
520
- * of logs.
521
- *
522
- * We also need to ensure that the logs in the batch are sorted in chronological order.
523
- * https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_PutLogEvents.html
524
- */
525
- var currentEventIdx = 0;
526
- var totalByteSize = 0;
527
- while (currentEventIdx < this._dataTracker.logEvents.length) {
528
- var currentEvent = this._dataTracker.logEvents[currentEventIdx];
529
- var eventSize = currentEvent
530
- ? new TextEncoder().encode(currentEvent.message).length +
531
- AWS_CLOUDWATCH_BASE_BUFFER_SIZE
532
- : 0;
533
- if (eventSize > AWS_CLOUDWATCH_MAX_EVENT_SIZE) {
534
- var errString = "Log entry exceeds maximum size for CloudWatch logs. Log size: ".concat(eventSize, ". Truncating log message.");
535
- logger.warn(errString);
536
- currentEvent.message = (_a = currentEvent.message) === null || _a === void 0 ? void 0 : _a.substring(0, eventSize);
537
- }
538
- if (totalByteSize + eventSize > AWS_CLOUDWATCH_MAX_BATCH_EVENT_SIZE)
539
- break;
540
- totalByteSize += eventSize;
541
- currentEventIdx++;
542
- }
543
- this._currentLogBatch = this._dataTracker.logEvents.splice(0, currentEventIdx);
544
- return this._currentLogBatch;
545
- };
546
- AWSCloudWatchProvider.prototype._getNewSequenceTokenAndSubmit = function (payload) {
547
- return __awaiter(this, void 0, void 0, function () {
548
- var seqToken, sendLogEventsRepsonse, err_6;
549
- return __generator(this, function (_a) {
550
- switch (_a.label) {
551
- case 0:
552
- _a.trys.push([0, 3, , 4]);
553
- this._nextSequenceToken = undefined;
554
- this._dataTracker.eventUploadInProgress = true;
555
- return [4 /*yield*/, this._getNextSequenceToken()];
556
- case 1:
557
- seqToken = _a.sent();
558
- payload.sequenceToken = seqToken;
559
- return [4 /*yield*/, this._sendLogEvents(payload)];
560
- case 2:
561
- sendLogEventsRepsonse = _a.sent();
562
- this._dataTracker.eventUploadInProgress = false;
563
- this._currentLogBatch = [];
564
- return [2 /*return*/, sendLogEventsRepsonse];
565
- case 3:
566
- err_6 = _a.sent();
567
- logger.error("error when retrying log submission with new sequence token: ".concat(err_6));
568
- this._dataTracker.eventUploadInProgress = false;
569
- throw err_6;
570
- case 4: return [2 /*return*/];
571
- }
572
- });
573
- });
574
- };
575
- AWSCloudWatchProvider.prototype._initiateLogPushInterval = function () {
576
- var _this = this;
577
- if (this._timer) {
578
- clearInterval(this._timer);
579
- }
580
- this._timer = setInterval(function () { return __awaiter(_this, void 0, void 0, function () {
581
- var err_7;
582
- return __generator(this, function (_a) {
583
- switch (_a.label) {
584
- case 0:
585
- _a.trys.push([0, 3, , 4]);
586
- if (!this._getDocUploadPermissibility()) return [3 /*break*/, 2];
587
- return [4 /*yield*/, this._safeUploadLogEvents()];
588
- case 1:
589
- _a.sent();
590
- _a.label = 2;
591
- case 2: return [3 /*break*/, 4];
592
- case 3:
593
- err_7 = _a.sent();
594
- logger.error("error when calling _safeUploadLogEvents in the timer interval - ".concat(err_7));
595
- return [3 /*break*/, 4];
596
- case 4: return [2 /*return*/];
597
- }
598
- });
599
- }); }, 2000);
600
- };
601
- AWSCloudWatchProvider.prototype._getDocUploadPermissibility = function () {
602
- return ((this._dataTracker.logEvents.length !== 0 ||
603
- this._currentLogBatch.length !== 0) &&
604
- !this._dataTracker.eventUploadInProgress);
605
- };
606
- AWSCloudWatchProvider.PROVIDER_NAME = AWS_CLOUDWATCH_PROVIDER_NAME;
607
- AWSCloudWatchProvider.CATEGORY = AWS_CLOUDWATCH_CATEGORY;
608
- return AWSCloudWatchProvider;
609
- }());
610
- function assertsAWSClouldWatchOptions(options) {
611
- return asserts(options !== undefined, {
612
- name: AWS_CLOUD_WATCH_PROVIDER_OPTIONS_EXCEPTION,
613
- message: 'AWSCloudWatchProviderOptions cannot be undefined',
614
- });
615
- }
616
- export { AWSCloudWatchProvider };
@@ -1 +0,0 @@
1
- export { AWSCloudWatchProvider } from './AWSCloudWatchProvider';
@@ -1,9 +0,0 @@
1
- export declare const INTERNAL_AWS_APPSYNC_REALTIME_PUBSUB_PROVIDER: string | symbol;
2
- export declare const USER_AGENT_HEADER = "x-amz-user-agent";
3
- export declare const AUTH_CONFING_EXCEPTION = "AuthConfigException";
4
- export declare const AWS_CLOUD_WATCH_PROVIDER_OPTIONS_EXCEPTION = "AWSCloudWatchProviderOptionsException";
5
- export declare const CACHE_LIST_EXCEPTION = "CacheListException";
6
- export declare const I18N_EXCEPTION = "I18NException";
7
- export declare const SERVICE_WORKER_EXCEPTION = "ServiceWorkerException";
8
- export declare const STORAGE_CACHE_EXCEPTION = "StorageCacheException";
9
- export declare const APPLICATION_ID_EXCEPTION = "ApplicationIdException";
@@ -1,19 +0,0 @@
1
- // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- // SPDX-License-Identifier: Apache-2.0
3
- /**
4
- * This Symbol is used to reference an internal-only PubSub provider that
5
- * is used for AppSync/GraphQL subscriptions in the API category.
6
- */
7
- var hasSymbol = typeof Symbol !== 'undefined' && typeof Symbol.for === 'function';
8
- export var INTERNAL_AWS_APPSYNC_REALTIME_PUBSUB_PROVIDER = hasSymbol
9
- ? Symbol.for('INTERNAL_AWS_APPSYNC_REALTIME_PUBSUB_PROVIDER')
10
- : '@@INTERNAL_AWS_APPSYNC_REALTIME_PUBSUB_PROVIDER';
11
- export var USER_AGENT_HEADER = 'x-amz-user-agent';
12
- // Error exception code constants
13
- export var AUTH_CONFING_EXCEPTION = 'AuthConfigException';
14
- export var AWS_CLOUD_WATCH_PROVIDER_OPTIONS_EXCEPTION = 'AWSCloudWatchProviderOptionsException';
15
- export var CACHE_LIST_EXCEPTION = 'CacheListException';
16
- export var I18N_EXCEPTION = 'I18NException';
17
- export var SERVICE_WORKER_EXCEPTION = 'ServiceWorkerException';
18
- export var STORAGE_CACHE_EXCEPTION = 'StorageCacheException';
19
- export var APPLICATION_ID_EXCEPTION = 'ApplicationIdException';