slnodejs 6.0.29 → 6.1.2

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 (413) hide show
  1. package/lib/cli.js +1 -1
  2. package/package.json +124 -123
  3. package/tsOutputs/api.d.ts +12 -10
  4. package/tsOutputs/api.js +116 -115
  5. package/tsOutputs/build-scanner/ast-utils.js +39 -0
  6. package/tsOutputs/build-scanner/ast-utils.js.map +1 -0
  7. package/tsOutputs/build-scanner/build-diff-process.js +352 -346
  8. package/tsOutputs/build-scanner/build-diff-process.js.map +1 -1
  9. package/tsOutputs/build-scanner/cia.js +95 -95
  10. package/tsOutputs/build-scanner/complexity-metrics/complexity-metrics.js +1 -0
  11. package/tsOutputs/build-scanner/complexity-metrics/complexity-metrics.js.map +1 -0
  12. package/tsOutputs/build-scanner/configuration-loader.js +17 -17
  13. package/tsOutputs/build-scanner/current-agent-instance.js +5 -5
  14. package/tsOutputs/build-scanner/default-values-resolver.js +42 -42
  15. package/tsOutputs/build-scanner/entities-mapper.js +35 -35
  16. package/tsOutputs/build-scanner/file-and-folder-utils.js +176 -176
  17. package/tsOutputs/build-scanner/file-system/actual-file.js +66 -46
  18. package/tsOutputs/build-scanner/file-system/actual-file.js.map +1 -1
  19. package/tsOutputs/build-scanner/git-format-builder.js +68 -68
  20. package/tsOutputs/build-scanner/global-error-handler.js +20 -20
  21. package/tsOutputs/build-scanner/instrumentation/browser-instrumenter.js +299 -299
  22. package/tsOutputs/build-scanner/instrumentation/browser-instrumenter.js.map +1 -1
  23. package/tsOutputs/build-scanner/instrumentation/file-instrumenter.js +271 -180
  24. package/tsOutputs/build-scanner/instrumentation/file-instrumenter.js.map +1 -1
  25. package/tsOutputs/build-scanner/instrumentation/instrumentation-utils.js +58 -58
  26. package/tsOutputs/build-scanner/instrumentation/instrumented-file-size-reducer.js +159 -159
  27. package/tsOutputs/build-scanner/instrumentation/markup-file-instrumenter.js +185 -137
  28. package/tsOutputs/build-scanner/instrumentation/markup-file-instrumenter.js.map +1 -1
  29. package/tsOutputs/build-scanner/instrumentation/sync-instrumenter.js +39 -39
  30. package/tsOutputs/build-scanner/js_diff/ast-node-types.js +44 -44
  31. package/tsOutputs/build-scanner/js_diff/branch-key.js +10 -10
  32. package/tsOutputs/build-scanner/js_diff/branch-signature.js +156 -156
  33. package/tsOutputs/build-scanner/js_diff/code-metrics-spec.js +1 -0
  34. package/tsOutputs/build-scanner/js_diff/code-metrics-spec.js.map +1 -0
  35. package/tsOutputs/build-scanner/js_diff/code-metrics.js +1 -0
  36. package/tsOutputs/build-scanner/js_diff/code-metrics.js.map +1 -0
  37. package/tsOutputs/build-scanner/js_diff/create-node-key.js +7 -7
  38. package/tsOutputs/build-scanner/js_diff/dry-run-files-mapping.js +23 -23
  39. package/tsOutputs/build-scanner/js_diff/dry-run-files-mapping.js.map +1 -1
  40. package/tsOutputs/build-scanner/js_diff/file-signature.js +234 -244
  41. package/tsOutputs/build-scanner/js_diff/file-signature.js.map +1 -1
  42. package/tsOutputs/build-scanner/js_diff/files-mapping.js +460 -473
  43. package/tsOutputs/build-scanner/js_diff/files-mapping.js.map +1 -1
  44. package/tsOutputs/build-scanner/js_diff/generated-file-signature.js +143 -143
  45. package/tsOutputs/build-scanner/js_diff/generated-file-signature.js.map +1 -1
  46. package/tsOutputs/build-scanner/js_diff/globalMethodIndexer.js +26 -26
  47. package/tsOutputs/build-scanner/js_diff/guess-method-location.js +100 -97
  48. package/tsOutputs/build-scanner/js_diff/guess-method-location.js.map +1 -1
  49. package/tsOutputs/build-scanner/js_diff/guess-method-name.js +54 -54
  50. package/tsOutputs/build-scanner/js_diff/method-signature.js +142 -140
  51. package/tsOutputs/build-scanner/js_diff/method-signature.js.map +1 -1
  52. package/tsOutputs/build-scanner/js_diff/sl-mapper.js +136 -75
  53. package/tsOutputs/build-scanner/js_diff/sl-mapper.js.map +1 -1
  54. package/tsOutputs/build-scanner/js_diff/source-data-enricher.js +89 -89
  55. package/tsOutputs/build-scanner/js_diff/source-data-enricher.js.map +1 -1
  56. package/tsOutputs/build-scanner/js_diff/source-files-notifier.js +31 -31
  57. package/tsOutputs/build-scanner/js_diff/source-position-mapper.js +29 -29
  58. package/tsOutputs/build-scanner/mappings/contracts.js +3 -0
  59. package/tsOutputs/build-scanner/mappings/contracts.js.map +1 -0
  60. package/tsOutputs/build-scanner/mappings/ensure-files-handler.service.js +214 -0
  61. package/tsOutputs/build-scanner/mappings/ensure-files-handler.service.js.map +1 -0
  62. package/tsOutputs/build-scanner/mappings/file-element-utils.js +47 -0
  63. package/tsOutputs/build-scanner/mappings/file-element-utils.js.map +1 -0
  64. package/tsOutputs/build-scanner/mappings/file-enricher.js +205 -0
  65. package/tsOutputs/build-scanner/mappings/file-enricher.js.map +1 -0
  66. package/tsOutputs/build-scanner/mappings/files-data-container.js +52 -0
  67. package/tsOutputs/build-scanner/mappings/files-data-container.js.map +1 -0
  68. package/tsOutputs/build-scanner/mappings/scm-file-fixer.js +78 -0
  69. package/tsOutputs/build-scanner/mappings/scm-file-fixer.js.map +1 -0
  70. package/tsOutputs/build-scanner/markup-files-parser.js +71 -71
  71. package/tsOutputs/build-scanner/nopt-types.js +19 -19
  72. package/tsOutputs/build-scanner/nopt-usage-2.js +56 -56
  73. package/tsOutputs/build-scanner/polyfills.js +6 -6
  74. package/tsOutputs/build-scanner/scm/parse-log.js +5 -5
  75. package/tsOutputs/build-scanner/scm/scm-files-container.js +49 -49
  76. package/tsOutputs/build-scanner/sl-config-cia-cli.js +175 -175
  77. package/tsOutputs/build-scanner/utils.js +91 -91
  78. package/tsOutputs/cli-parse/agent-instance-data.d.ts +2 -2
  79. package/tsOutputs/cli-parse/agent-instance-data.js +6 -6
  80. package/tsOutputs/cli-parse/child-process-wrapper.js +82 -82
  81. package/tsOutputs/cli-parse/cli.js +509 -506
  82. package/tsOutputs/cli-parse/cli.js.map +1 -1
  83. package/tsOutputs/cli-parse/constants/constants.js +55 -56
  84. package/tsOutputs/cli-parse/constants/constants.js.map +1 -1
  85. package/tsOutputs/cli-parse/constants/third-parties.js +10 -10
  86. package/tsOutputs/cli-parse/contracts.js +2 -2
  87. package/tsOutputs/cli-parse/custom-commander.js +44 -31
  88. package/tsOutputs/cli-parse/custom-commander.js.map +1 -1
  89. package/tsOutputs/cli-parse/executors/base-executor.js +263 -254
  90. package/tsOutputs/cli-parse/executors/base-executor.js.map +1 -1
  91. package/tsOutputs/cli-parse/executors/build-args-dto.js +55 -55
  92. package/tsOutputs/cli-parse/executors/build-end-executor.js +115 -117
  93. package/tsOutputs/cli-parse/executors/build-end-executor.js.map +1 -1
  94. package/tsOutputs/cli-parse/executors/build-executor.js +147 -149
  95. package/tsOutputs/cli-parse/executors/build-executor.js.map +1 -1
  96. package/tsOutputs/cli-parse/executors/config-executor.js +112 -111
  97. package/tsOutputs/cli-parse/executors/config-executor.js.map +1 -1
  98. package/tsOutputs/cli-parse/executors/dry-run/base-data.js +55 -55
  99. package/tsOutputs/cli-parse/executors/dry-run/base-data.js.map +1 -1
  100. package/tsOutputs/cli-parse/executors/dry-run/build-mapping-data.js +228 -230
  101. package/tsOutputs/cli-parse/executors/dry-run/build-mapping-data.js.map +1 -1
  102. package/tsOutputs/cli-parse/executors/dry-run/dry-run-executor.js +277 -277
  103. package/tsOutputs/cli-parse/executors/dry-run/dry-run-executor.js.map +1 -1
  104. package/tsOutputs/cli-parse/executors/dry-run/dry-run-validation.js +120 -122
  105. package/tsOutputs/cli-parse/executors/dry-run/dry-run-validation.js.map +1 -1
  106. package/tsOutputs/cli-parse/executors/dry-run/footprints-data.js +130 -72
  107. package/tsOutputs/cli-parse/executors/dry-run/footprints-data.js.map +1 -1
  108. package/tsOutputs/cli-parse/executors/dry-run/helper-methods.js +104 -99
  109. package/tsOutputs/cli-parse/executors/dry-run/helper-methods.js.map +1 -1
  110. package/tsOutputs/cli-parse/executors/end-execution-executor.js +88 -90
  111. package/tsOutputs/cli-parse/executors/end-execution-executor.js.map +1 -1
  112. package/tsOutputs/cli-parse/executors/integration-build-components-executor.js +132 -134
  113. package/tsOutputs/cli-parse/executors/integration-build-components-executor.js.map +1 -1
  114. package/tsOutputs/cli-parse/executors/integration-build-delete-components-executor.js +73 -75
  115. package/tsOutputs/cli-parse/executors/integration-build-delete-components-executor.js.map +1 -1
  116. package/tsOutputs/cli-parse/executors/integration-build-update-components-executor.js +71 -73
  117. package/tsOutputs/cli-parse/executors/integration-build-update-components-executor.js.map +1 -1
  118. package/tsOutputs/cli-parse/executors/mocha-executor.js +122 -124
  119. package/tsOutputs/cli-parse/executors/mocha-executor.js.map +1 -1
  120. package/tsOutputs/cli-parse/executors/nyc-report-executor.js +104 -106
  121. package/tsOutputs/cli-parse/executors/nyc-report-executor.js.map +1 -1
  122. package/tsOutputs/cli-parse/executors/pr-config-executor.js +83 -85
  123. package/tsOutputs/cli-parse/executors/pr-config-executor.js.map +1 -1
  124. package/tsOutputs/cli-parse/executors/run-executor.js +93 -95
  125. package/tsOutputs/cli-parse/executors/run-executor.js.map +1 -1
  126. package/tsOutputs/cli-parse/executors/start-execution-executor.js +91 -93
  127. package/tsOutputs/cli-parse/executors/start-execution-executor.js.map +1 -1
  128. package/tsOutputs/cli-parse/executors/test-executions-executor.js +75 -77
  129. package/tsOutputs/cli-parse/executors/test-executions-executor.js.map +1 -1
  130. package/tsOutputs/cli-parse/executors/test-listener-executor.js +149 -151
  131. package/tsOutputs/cli-parse/executors/test-listener-executor.js.map +1 -1
  132. package/tsOutputs/cli-parse/executors/test-runner-build-session-data-builder.js +75 -77
  133. package/tsOutputs/cli-parse/executors/test-runner-build-session-data-builder.js.map +1 -1
  134. package/tsOutputs/cli-parse/executors/upload-report-executor.js +116 -118
  135. package/tsOutputs/cli-parse/executors/upload-report-executor.js.map +1 -1
  136. package/tsOutputs/cli-parse/utils.js +32 -32
  137. package/tsOutputs/common/agent-events/agent-events-conracts.d.ts +123 -123
  138. package/tsOutputs/common/agent-events/agent-events-conracts.js +56 -56
  139. package/tsOutputs/common/agent-events/agent-events-controller.d.ts +45 -45
  140. package/tsOutputs/common/agent-events/agent-events-controller.js +301 -301
  141. package/tsOutputs/common/agent-events/agent-instance-info-builder.d.ts +22 -22
  142. package/tsOutputs/common/agent-events/agent-instance-info-builder.js +63 -63
  143. package/tsOutputs/common/agent-events/agent-start-info-builder.d.ts +14 -14
  144. package/tsOutputs/common/agent-events/agent-start-info-builder.js +23 -23
  145. package/tsOutputs/common/agent-events/ci-info-builder.d.ts +7 -7
  146. package/tsOutputs/common/agent-events/ci-info-builder.js +30 -30
  147. package/tsOutputs/common/agent-events/cockpit-notifier.d.ts +26 -26
  148. package/tsOutputs/common/agent-events/cockpit-notifier.js +119 -119
  149. package/tsOutputs/common/agent-events/dry-run-agent-events-controller.d.ts +7 -7
  150. package/tsOutputs/common/agent-events/dry-run-agent-events-controller.js +31 -33
  151. package/tsOutputs/common/agent-events/dry-run-agent-events-controller.js.map +1 -1
  152. package/tsOutputs/common/agent-events/machine-info-builder.d.ts +7 -7
  153. package/tsOutputs/common/agent-events/machine-info-builder.js +35 -35
  154. package/tsOutputs/common/agent-events/nodejs-env-info-builder.d.ts +8 -8
  155. package/tsOutputs/common/agent-events/nodejs-env-info-builder.js +19 -19
  156. package/tsOutputs/common/agent-events/sensitive-data-filter.d.ts +2 -2
  157. package/tsOutputs/common/agent-events/sensitive-data-filter.js +54 -54
  158. package/tsOutputs/common/agent-instance-data.d.ts +10 -10
  159. package/tsOutputs/common/agent-instance-data.js +39 -39
  160. package/tsOutputs/common/config-process/config-loader.d.ts +8 -8
  161. package/tsOutputs/common/config-process/config-loader.js +86 -86
  162. package/tsOutputs/common/config-process/config-system.d.ts +88 -88
  163. package/tsOutputs/common/config-process/config-system.js +293 -293
  164. package/tsOutputs/common/config-process/config.d.ts +60 -60
  165. package/tsOutputs/common/config-process/config.js +90 -92
  166. package/tsOutputs/common/config-process/config.js.map +1 -1
  167. package/tsOutputs/common/config-process/index.d.ts +21 -21
  168. package/tsOutputs/common/config-process/index.js +125 -127
  169. package/tsOutputs/common/config-process/index.js.map +1 -1
  170. package/tsOutputs/common/constants/constants.d.ts +18 -18
  171. package/tsOutputs/common/constants/constants.js +29 -29
  172. package/tsOutputs/common/constants/sl-env-vars.d.ts +52 -52
  173. package/tsOutputs/common/constants/sl-env-vars.js +122 -122
  174. package/tsOutputs/common/contracts.d.ts +123 -122
  175. package/tsOutputs/common/contracts.js +2 -2
  176. package/tsOutputs/common/coverage-elements/contracts.d.ts +25 -25
  177. package/tsOutputs/common/coverage-elements/contracts.js +8 -8
  178. package/tsOutputs/common/coverage-elements/file-element.d.ts +35 -35
  179. package/tsOutputs/common/coverage-elements/file-element.js +158 -158
  180. package/tsOutputs/common/coverage-elements/istanbul-unique-id-converter.d.ts +12 -12
  181. package/tsOutputs/common/coverage-elements/istanbul-unique-id-converter.js +95 -97
  182. package/tsOutputs/common/coverage-elements/istanbul-unique-id-converter.js.map +1 -1
  183. package/tsOutputs/common/coverage-elements/new-id-resolver.d.ts +3 -3
  184. package/tsOutputs/common/coverage-elements/new-id-resolver.js +45 -45
  185. package/tsOutputs/common/coverage-elements/original-module-loader.d.ts +41 -41
  186. package/tsOutputs/common/coverage-elements/original-module-loader.js +189 -189
  187. package/tsOutputs/common/coverage-elements/unique-id-converter.d.ts +32 -32
  188. package/tsOutputs/common/coverage-elements/unique-id-converter.js +234 -234
  189. package/tsOutputs/common/environment-data-service.d.ts +15 -15
  190. package/tsOutputs/common/environment-data-service.js +60 -60
  191. package/tsOutputs/common/events-process/events-contracts.d.ts +52 -52
  192. package/tsOutputs/common/events-process/events-contracts.js +19 -19
  193. package/tsOutputs/common/events-process/events-creator.js +42 -40
  194. package/tsOutputs/common/events-process/events-creator.js.map +1 -1
  195. package/tsOutputs/common/events-process/index.d.ts +42 -42
  196. package/tsOutputs/common/events-process/index.js +265 -266
  197. package/tsOutputs/common/events-process/index.js.map +1 -1
  198. package/tsOutputs/common/footprints-process/collection-interval.d.ts +10 -10
  199. package/tsOutputs/common/footprints-process/collection-interval.js +27 -27
  200. package/tsOutputs/common/footprints-process/footprints-service-proxy.d.ts +12 -12
  201. package/tsOutputs/common/footprints-process/footprints-service-proxy.js +51 -51
  202. package/tsOutputs/common/footprints-process/index.d.ts +71 -71
  203. package/tsOutputs/common/footprints-process/index.js +264 -264
  204. package/tsOutputs/common/footprints-process/istanbul-to-footprints-contract.d.ts +98 -98
  205. package/tsOutputs/common/footprints-process/istanbul-to-footprints-contract.js +9 -9
  206. package/tsOutputs/common/footprints-process/istanbul-to-footprints.d.ts +47 -47
  207. package/tsOutputs/common/footprints-process/istanbul-to-footprints.js +421 -421
  208. package/tsOutputs/common/footprints-process/production-footprints-handler.d.ts +54 -54
  209. package/tsOutputs/common/footprints-process/production-footprints-handler.js +308 -308
  210. package/tsOutputs/common/footprints-process-v6/base-browser-hits-converter.d.ts +20 -20
  211. package/tsOutputs/common/footprints-process-v6/base-browser-hits-converter.js +63 -65
  212. package/tsOutputs/common/footprints-process-v6/base-browser-hits-converter.js.map +1 -1
  213. package/tsOutputs/common/footprints-process-v6/buffer-size-helper.d.ts +15 -15
  214. package/tsOutputs/common/footprints-process-v6/buffer-size-helper.js +40 -40
  215. package/tsOutputs/common/footprints-process-v6/contracts.d.ts +184 -181
  216. package/tsOutputs/common/footprints-process-v6/contracts.js +9 -9
  217. package/tsOutputs/common/footprints-process-v6/footprints-buffer.d.ts +36 -34
  218. package/tsOutputs/common/footprints-process-v6/footprints-buffer.js +147 -135
  219. package/tsOutputs/common/footprints-process-v6/footprints-buffer.js.map +1 -1
  220. package/tsOutputs/common/footprints-process-v6/hits-collector.d.ts +24 -24
  221. package/tsOutputs/common/footprints-process-v6/hits-collector.js +168 -168
  222. package/tsOutputs/common/footprints-process-v6/hits-converter.d.ts +30 -28
  223. package/tsOutputs/common/footprints-process-v6/hits-converter.js +135 -105
  224. package/tsOutputs/common/footprints-process-v6/hits-converter.js.map +1 -1
  225. package/tsOutputs/common/footprints-process-v6/index.d.ts +41 -40
  226. package/tsOutputs/common/footprints-process-v6/index.js +304 -258
  227. package/tsOutputs/common/footprints-process-v6/index.js.map +1 -1
  228. package/tsOutputs/common/footprints-process-v6/location-formatter.d.ts +6 -6
  229. package/tsOutputs/common/footprints-process-v6/location-formatter.js +25 -25
  230. package/tsOutputs/common/footprints-process-v6/relative-path-resolver.d.ts +8 -8
  231. package/tsOutputs/common/footprints-process-v6/relative-path-resolver.js +28 -28
  232. package/tsOutputs/common/footprints-process-v6/remote-browser-hits-converter.d.ts +9 -9
  233. package/tsOutputs/common/footprints-process-v6/remote-browser-hits-converter.js +38 -40
  234. package/tsOutputs/common/footprints-process-v6/remote-browser-hits-converter.js.map +1 -1
  235. package/tsOutputs/common/footprints-process-v6/remote-footprints-process.d.ts +8 -8
  236. package/tsOutputs/common/footprints-process-v6/remote-footprints-process.js +32 -34
  237. package/tsOutputs/common/footprints-process-v6/remote-footprints-process.js.map +1 -1
  238. package/tsOutputs/common/footprints-process-v6/remote-hits-collector.d.ts +14 -14
  239. package/tsOutputs/common/footprints-process-v6/remote-hits-collector.js +39 -41
  240. package/tsOutputs/common/footprints-process-v6/remote-hits-collector.js.map +1 -1
  241. package/tsOutputs/common/footprints-process-v6/source-map-data.d.ts +9 -9
  242. package/tsOutputs/common/footprints-process-v6/source-map-data.js +32 -32
  243. package/tsOutputs/common/footprints-process-v6/source-map-data.js.map +1 -1
  244. package/tsOutputs/common/http/backend-proxy-interface.d.ts +33 -33
  245. package/tsOutputs/common/http/backend-proxy-interface.js +2 -2
  246. package/tsOutputs/common/http/backend-proxy.d.ts +54 -53
  247. package/tsOutputs/common/http/backend-proxy.js +408 -398
  248. package/tsOutputs/common/http/backend-proxy.js.map +1 -1
  249. package/tsOutputs/common/http/contracts.d.ts +280 -203
  250. package/tsOutputs/common/http/contracts.js +156 -158
  251. package/tsOutputs/common/http/contracts.js.map +1 -1
  252. package/tsOutputs/common/http/dry-run-proxy.js +106 -106
  253. package/tsOutputs/common/http/entities-mapper.d.ts +4 -4
  254. package/tsOutputs/common/http/entities-mapper.js +17 -17
  255. package/tsOutputs/common/http/http-client.d.ts +21 -21
  256. package/tsOutputs/common/http/http-client.js +195 -191
  257. package/tsOutputs/common/http/http-client.js.map +1 -1
  258. package/tsOutputs/common/http/http-verb.d.ts +6 -6
  259. package/tsOutputs/common/http/http-verb.js +10 -10
  260. package/tsOutputs/common/http/sl-routes.d.ts +70 -70
  261. package/tsOutputs/common/http/sl-routes.js +218 -218
  262. package/tsOutputs/common/ignored-files-handler.js +122 -122
  263. package/tsOutputs/common/logger.d.ts +40 -40
  264. package/tsOutputs/common/logger.js +188 -190
  265. package/tsOutputs/common/logger.js.map +1 -1
  266. package/tsOutputs/common/messages-formatter.d.ts +6 -6
  267. package/tsOutputs/common/messages-formatter.js +21 -21
  268. package/tsOutputs/common/queue.d.ts +19 -19
  269. package/tsOutputs/common/queue.js +55 -57
  270. package/tsOutputs/common/queue.js.map +1 -1
  271. package/tsOutputs/common/scm/contracts.js +2 -2
  272. package/tsOutputs/common/scm/git-cloner.js +138 -0
  273. package/tsOutputs/common/scm/git-cloner.js.map +1 -0
  274. package/tsOutputs/common/scm/git-format-builder.js +72 -72
  275. package/tsOutputs/common/scm/git.js +411 -411
  276. package/tsOutputs/common/scm/none.js +115 -115
  277. package/tsOutputs/common/scm/scm-factory.js +21 -21
  278. package/tsOutputs/common/short-name-to-file-mapper.js +79 -79
  279. package/tsOutputs/common/source-map-handler.d.ts +58 -58
  280. package/tsOutputs/common/source-map-handler.js +197 -197
  281. package/tsOutputs/common/source-map-reader.js +84 -84
  282. package/tsOutputs/common/source-maps-utils.d.ts +3 -3
  283. package/tsOutputs/common/source-maps-utils.js +39 -39
  284. package/tsOutputs/common/state-tracker-fpv6.d.ts +6 -6
  285. package/tsOutputs/common/state-tracker-fpv6.js +42 -44
  286. package/tsOutputs/common/state-tracker-fpv6.js.map +1 -1
  287. package/tsOutputs/common/state-tracker.d.ts +49 -49
  288. package/tsOutputs/common/state-tracker.js +299 -304
  289. package/tsOutputs/common/state-tracker.js.map +1 -1
  290. package/tsOutputs/common/system-date.d.ts +2 -2
  291. package/tsOutputs/common/system-date.js +21 -21
  292. package/tsOutputs/common/utils/abstract-data-builder.d.ts +10 -10
  293. package/tsOutputs/common/utils/abstract-data-builder.js +24 -24
  294. package/tsOutputs/common/utils/build-session-data-builder.d.ts +18 -18
  295. package/tsOutputs/common/utils/build-session-data-builder.js +135 -137
  296. package/tsOutputs/common/utils/build-session-data-builder.js.map +1 -1
  297. package/tsOutputs/common/utils/dependency-utils.js +69 -69
  298. package/tsOutputs/common/utils/files-utils.d.ts +6 -5
  299. package/tsOutputs/common/utils/files-utils.js +45 -36
  300. package/tsOutputs/common/utils/files-utils.js.map +1 -1
  301. package/tsOutputs/common/utils/parsing-utils.d.ts +4 -4
  302. package/tsOutputs/common/utils/parsing-utils.js +29 -29
  303. package/tsOutputs/common/utils/test-utils/mock-server-utils/contracts.js +10 -10
  304. package/tsOutputs/common/utils/test-utils/mock-server-utils/mock-server-proxy.js +248 -248
  305. package/tsOutputs/common/utils/timer-utils.d.ts +3 -3
  306. package/tsOutputs/common/utils/timer-utils.js +12 -12
  307. package/tsOutputs/common/utils/token-data-builder.d.ts +21 -21
  308. package/tsOutputs/common/utils/token-data-builder.js +95 -97
  309. package/tsOutputs/common/utils/token-data-builder.js.map +1 -1
  310. package/tsOutputs/common/utils/validation-utils.d.ts +3 -3
  311. package/tsOutputs/common/utils/validation-utils.js +18 -18
  312. package/tsOutputs/common/uuid.js +23 -23
  313. package/tsOutputs/common/watchdog.d.ts +96 -96
  314. package/tsOutputs/common/watchdog.js +149 -151
  315. package/tsOutputs/common/watchdog.js.map +1 -1
  316. package/tsOutputs/mocha-reporter/constants.js +27 -27
  317. package/tsOutputs/mocha-reporter/end-execution.js +22 -22
  318. package/tsOutputs/mocha-reporter/index.js +323 -323
  319. package/tsOutputs/test-listener/IConsoleLogger.js +5 -5
  320. package/tsOutputs/test-listener/SlNodeJsProxy.js +96 -96
  321. package/tsOutputs/test-listener/UserMessageHelper.js +47 -47
  322. package/tsOutputs/test-listener/agent-loader.js +58 -58
  323. package/tsOutputs/test-listener/agent.d.ts +53 -53
  324. package/tsOutputs/test-listener/agent.js +273 -273
  325. package/tsOutputs/test-listener/api.js +157 -157
  326. package/tsOutputs/test-listener/base-proxy.d.ts +15 -15
  327. package/tsOutputs/test-listener/base-proxy.js +133 -133
  328. package/tsOutputs/test-listener/bootstrap.js +16 -16
  329. package/tsOutputs/test-listener/child-process-patcher.js +136 -136
  330. package/tsOutputs/test-listener/cli.js +64 -64
  331. package/tsOutputs/test-listener/coloring/http-coloring.d.ts +15 -15
  332. package/tsOutputs/test-listener/coloring/http-coloring.js +188 -188
  333. package/tsOutputs/test-listener/coloring/icoloring-provider.d.ts +10 -10
  334. package/tsOutputs/test-listener/coloring/icoloring-provider.js +2 -2
  335. package/tsOutputs/test-listener/coloring/listening-port.d.ts +20 -20
  336. package/tsOutputs/test-listener/coloring/listening-port.js +48 -48
  337. package/tsOutputs/test-listener/command-line-arg-parser.js +91 -91
  338. package/tsOutputs/test-listener/config-process/config-loader.js +104 -104
  339. package/tsOutputs/test-listener/config-process/config-system.d.ts +88 -88
  340. package/tsOutputs/test-listener/config-process/config-system.js +285 -285
  341. package/tsOutputs/test-listener/config-process/index.js +126 -128
  342. package/tsOutputs/test-listener/config-process/index.js.map +1 -1
  343. package/tsOutputs/test-listener/config.d.ts +50 -50
  344. package/tsOutputs/test-listener/config.js +80 -82
  345. package/tsOutputs/test-listener/config.js.map +1 -1
  346. package/tsOutputs/test-listener/contracts.d.ts +72 -72
  347. package/tsOutputs/test-listener/contracts.js +2 -2
  348. package/tsOutputs/test-listener/entities/BasicConfigurationData.js +72 -72
  349. package/tsOutputs/test-listener/entities/build-scanner/ConfigModeData.js +48 -50
  350. package/tsOutputs/test-listener/entities/build-scanner/ConfigModeData.js.map +1 -1
  351. package/tsOutputs/test-listener/entities/build-scanner/ScanModeData.js +51 -53
  352. package/tsOutputs/test-listener/entities/build-scanner/ScanModeData.js.map +1 -1
  353. package/tsOutputs/test-listener/environment-data-service.d.ts +11 -11
  354. package/tsOutputs/test-listener/environment-data-service.js +60 -60
  355. package/tsOutputs/test-listener/execution-process/contracts.js +5 -5
  356. package/tsOutputs/test-listener/execution-process/entities-mapper.js +49 -49
  357. package/tsOutputs/test-listener/execution-process/execution-service-proxy.js +205 -207
  358. package/tsOutputs/test-listener/execution-process/execution-service-proxy.js.map +1 -1
  359. package/tsOutputs/test-listener/execution-process/index.js +163 -163
  360. package/tsOutputs/test-listener/factory.d.ts +87 -87
  361. package/tsOutputs/test-listener/factory.js +285 -285
  362. package/tsOutputs/test-listener/footprints-process/footprints-service-proxy.js +50 -52
  363. package/tsOutputs/test-listener/footprints-process/footprints-service-proxy.js.map +1 -1
  364. package/tsOutputs/test-listener/footprints-process/index.js +230 -230
  365. package/tsOutputs/test-listener/footprints-process/istanbul-to-footprints-base.js +130 -130
  366. package/tsOutputs/test-listener/footprints-process/istanbul-to-footprints-contract.js +2 -2
  367. package/tsOutputs/test-listener/footprints-process/istanbul-to-footprints-v3.js +288 -290
  368. package/tsOutputs/test-listener/footprints-process/istanbul-to-footprints-v3.js.map +1 -1
  369. package/tsOutputs/test-listener/integrations/SlGulp.js +104 -104
  370. package/tsOutputs/test-listener/logs-process/index.d.ts +48 -48
  371. package/tsOutputs/test-listener/logs-process/index.js +142 -142
  372. package/tsOutputs/test-listener/logs-process/log-service-proxy.d.ts +9 -9
  373. package/tsOutputs/test-listener/logs-process/log-service-proxy.js +29 -31
  374. package/tsOutputs/test-listener/logs-process/log-service-proxy.js.map +1 -1
  375. package/tsOutputs/test-listener/nyc-report-executor-fpv6.js +143 -136
  376. package/tsOutputs/test-listener/nyc-report-executor-fpv6.js.map +1 -1
  377. package/tsOutputs/test-listener/nyc-report-executor.js +144 -144
  378. package/tsOutputs/test-listener/queue.js +55 -57
  379. package/tsOutputs/test-listener/queue.js.map +1 -1
  380. package/tsOutputs/test-listener/remote-agent.d.ts +42 -42
  381. package/tsOutputs/test-listener/remote-agent.js +200 -200
  382. package/tsOutputs/test-listener/resolvers/AppNameResolver.js +32 -34
  383. package/tsOutputs/test-listener/resolvers/AppNameResolver.js.map +1 -1
  384. package/tsOutputs/test-listener/resolvers/ArgumentResolver.js +64 -64
  385. package/tsOutputs/test-listener/resolvers/BuildResolver.js +31 -33
  386. package/tsOutputs/test-listener/resolvers/BuildResolver.js.map +1 -1
  387. package/tsOutputs/test-listener/resolvers/BuildSessionIdFileResolver.js +31 -33
  388. package/tsOutputs/test-listener/resolvers/BuildSessionIdFileResolver.js.map +1 -1
  389. package/tsOutputs/test-listener/resolvers/BuildSessionIdResolver.js +34 -36
  390. package/tsOutputs/test-listener/resolvers/BuildSessionIdResolver.js.map +1 -1
  391. package/tsOutputs/test-listener/resolvers/ProxyResolver.js +31 -33
  392. package/tsOutputs/test-listener/resolvers/ProxyResolver.js.map +1 -1
  393. package/tsOutputs/test-listener/resolvers/TokenResolver.js +31 -33
  394. package/tsOutputs/test-listener/resolvers/TokenResolver.js.map +1 -1
  395. package/tsOutputs/test-listener/state-tracker-process/index.js +160 -162
  396. package/tsOutputs/test-listener/state-tracker-process/index.js.map +1 -1
  397. package/tsOutputs/test-listener/state-tracker-process/state-tracker-proxy.d.ts +8 -8
  398. package/tsOutputs/test-listener/state-tracker-process/state-tracker-proxy.js +69 -71
  399. package/tsOutputs/test-listener/state-tracker-process/state-tracker-proxy.js.map +1 -1
  400. package/tsOutputs/test-listener/test-recommendation-handler.d.ts +29 -29
  401. package/tsOutputs/test-listener/test-recommendation-handler.js +161 -161
  402. package/tsOutputs/test-listener/upload-report-handler.js +96 -96
  403. package/tsOutputs/test-listener/utils.js +68 -68
  404. package/tsOutputs/test-listener/uuid.d.ts +3 -3
  405. package/tsOutputs/test-listener/uuid.js +23 -23
  406. package/tsOutputs/test-listener/wait-for-multiple-callbacks.d.ts +22 -22
  407. package/tsOutputs/test-listener/wait-for-multiple-callbacks.js +60 -60
  408. package/tsOutputs/test-listener/watchdog.d.ts +89 -89
  409. package/tsOutputs/test-listener/watchdog.js +144 -146
  410. package/tsOutputs/test-listener/watchdog.js.map +1 -1
  411. package/browser-agent/dist/browser-agent-all.js +0 -100989
  412. package/browser-agent/dist/browser-agent-all.min.js +0 -57
  413. package/browser-agent/package.json +0 -44
@@ -1,309 +1,309 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
18
- 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;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.ProductionFootprintsHandler = void 0;
40
- var fs = require("fs");
41
- var os = require("os");
42
- var sl_env_vars_1 = require("../constants/sl-env-vars");
43
- var path = require("path");
44
- var http_client_1 = require("../http/http-client");
45
- var messages_formatter_1 = require("../messages-formatter");
46
- var sl_routes_1 = require("../http/sl-routes");
47
- var validation_utils_1 = require("../utils/validation-utils");
48
- var system_date_1 = require("../system-date");
49
- var FILE_NOT_FOUND_CODE = 'ENOENT';
50
- var ProductionFootprintsHandler = /** @class */ (function () {
51
- function ProductionFootprintsHandler(cfg, logger) {
52
- this.validateConfig(cfg);
53
- this.agentConfig = cfg;
54
- validation_utils_1.ValidationUtils.verifyNotNullOrEmpty(logger, 'logger');
55
- this.logger = logger;
56
- this.metaData = new MetaData(cfg.buildSessionId.value, cfg.labId.value);
57
- this.filename = this.createFilePath(cfg); //Todo: remove or make saving to file configurable
58
- this.collectionStartDate = system_date_1.getSystemDateValueOf();
59
- this.methodIdToHits = {};
60
- this.initHttpConfig(cfg);
61
- this.httpClient = new http_client_1.HttpClient(this.httpConfig, logger);
62
- this.setupProdListenerModes();
63
- }
64
- ProductionFootprintsHandler.prototype.setupProdListenerModes = function () {
65
- var prodListenerModes = sl_env_vars_1.SlEnvVars.getProductionListenerModes();
66
- if (prodListenerModes.length == 0 || (prodListenerModes.length == 1 && prodListenerModes[0] == 'true')) {
67
- //Defaults in case the production listener env var is not present or is set to 'true'
68
- this.sendToServer = true;
69
- this.saveToFile = false;
70
- }
71
- else {
72
- this.sendToServer = prodListenerModes.indexOf('server') > -1;
73
- this.saveToFile = prodListenerModes.indexOf('file') > -1;
74
- }
75
- this.logger.info('Production listener send to server: ' + this.sendToServer + ', save to file: ' + this.saveToFile);
76
- };
77
- ProductionFootprintsHandler.prototype.initHttpConfig = function (cfg) {
78
- var config = {
79
- token: cfg.token.value,
80
- server: cfg.server.value,
81
- proxy: cfg.proxy.value,
82
- compressRequests: cfg.gzip.hasValue ? cfg.gzip.value : true
83
- };
84
- this.httpConfig = config;
85
- };
86
- ProductionFootprintsHandler.prototype.handleFootprints = function (footprintsPacket, callback) {
87
- if (!footprintsPacket) {
88
- this.logger.info('Handle footprints - got null or empty packet. Skip saving.');
89
- callback(null);
90
- return;
91
- }
92
- if (!footprintsPacket || !footprintsPacket.apps || !footprintsPacket.apps[0] || !footprintsPacket.apps[0].files) {
93
- this.logger.info('Handle footprints - no footprints data. Skip saving.');
94
- callback(null);
95
- return;
96
- }
97
- this.saveAndSendMethodsHits(footprintsPacket)
98
- .then(function () { return callback(null); })
99
- .catch(function (err) { return callback(err); });
100
- };
101
- ProductionFootprintsHandler.prototype.saveAndSendMethodsHits = function (packetToSend) {
102
- return __awaiter(this, void 0, void 0, function () {
103
- var hitFiles;
104
- return __generator(this, function (_a) {
105
- switch (_a.label) {
106
- case 0:
107
- hitFiles = this.getHitFiles(packetToSend);
108
- this.logger.debug('Submitting production data, files: %s, toServer: %s, toFile: %s (%s)', hitFiles, this.sendToServer, this.saveToFile, this.filename);
109
- if (!this.sendToServer) return [3 /*break*/, 2];
110
- return [4 /*yield*/, this.convertAndSubmitToServer(packetToSend)];
111
- case 1:
112
- _a.sent();
113
- _a.label = 2;
114
- case 2:
115
- if (!this.saveToFile) return [3 /*break*/, 5];
116
- this.methodIdToHits = {};
117
- this.addHitsFromFootprints(packetToSend.apps[0].files);
118
- return [4 /*yield*/, this.addHitsFromFile()];
119
- case 3:
120
- _a.sent();
121
- return [4 /*yield*/, this.writeDataToFile()];
122
- case 4:
123
- _a.sent();
124
- _a.label = 5;
125
- case 5: return [2 /*return*/];
126
- }
127
- });
128
- });
129
- };
130
- ProductionFootprintsHandler.prototype.getHitFiles = function (packetToSend) {
131
- if (!this.logger.isDebugEnabled()) {
132
- return;
133
- }
134
- var formatter = new messages_formatter_1.MessagesFormatter();
135
- if (packetToSend && packetToSend.apps && packetToSend.apps[0] && packetToSend.apps[0].files) {
136
- packetToSend.apps[0].files.forEach(function (file) {
137
- formatter.addContent(file.path);
138
- });
139
- }
140
- return formatter.content;
141
- };
142
- ProductionFootprintsHandler.prototype.convertFootprintsToProductionData = function (footprintsPacket) {
143
- var now = system_date_1.getSystemDateValueOf();
144
- var productionDataPacket = {
145
- meta: {
146
- appName: this.agentConfig.appName.value,
147
- branchName: this.agentConfig.branch.value,
148
- buildName: this.agentConfig.build.value,
149
- bsid: this.agentConfig.buildSessionId.value,
150
- createdAt: this.collectionStartDate,
151
- lastModified: now,
152
- customerId: this.agentConfig.customerId.value,
153
- hostName: os.hostname(),
154
- pid: process.pid,
155
- labId: this.agentConfig.labId.value || 'production'
156
- },
157
- methodsHits: {}
158
- };
159
- if (footprintsPacket && footprintsPacket.apps && footprintsPacket.apps[0] && footprintsPacket.apps[0].files) {
160
- footprintsPacket.apps[0].files.forEach(function (file) {
161
- if (!file.methods)
162
- return;
163
- file.methods.forEach(function (method) {
164
- var totalHits = 0;
165
- if (!method.hits)
166
- return;
167
- method.hits.forEach(function (testIdxAndHits) {
168
- totalHits += testIdxAndHits[1];
169
- });
170
- productionDataPacket.methodsHits[method.uniqueId] = totalHits;
171
- });
172
- });
173
- }
174
- this.collectionStartDate = now;
175
- return productionDataPacket;
176
- };
177
- ProductionFootprintsHandler.prototype.convertAndSubmitToServer = function (footprintsPacket) {
178
- var _this = this;
179
- var productionDataPacket = this.convertFootprintsToProductionData(footprintsPacket);
180
- return new Promise(function (resolve, reject) {
181
- var url = sl_routes_1.SLRoutes.productionV1(_this.agentConfig.buildSessionId.value);
182
- _this.httpClient.post(productionDataPacket, url, function (err) {
183
- err ? reject(err) : resolve();
184
- });
185
- });
186
- };
187
- /*
188
- In production listener we are in anonymous mode, and all hits will refer to single anonymous test.
189
- So we can there will be single array in "hits" array.
190
- In this inner array firs element will be always '0'(the index of test in array which contains only one - the anonymous),
191
- and the second element is the hits number.
192
- */
193
- ProductionFootprintsHandler.prototype.addHitsFromFootprints = function (files) {
194
- var _this = this;
195
- files.forEach(function (file) {
196
- file.methods.forEach(function (method) {
197
- _this.methodIdToHits[method.uniqueId] = method.hits[0][1];
198
- });
199
- });
200
- };
201
- ProductionFootprintsHandler.prototype.tryParseFileContent = function (fileContent) {
202
- try {
203
- var hitsData = JSON.parse(fileContent).methodsHits;
204
- this.logger.debug('Previous hit data parsed successfully, \'%s\' items loaded', Object.keys(hitsData).length);
205
- return hitsData;
206
- }
207
- catch (err) {
208
- this.logger.error('Error while parsing hits file content. %s', err);
209
- return null;
210
- }
211
- };
212
- ProductionFootprintsHandler.prototype.validateConfig = function (config) {
213
- if (!config) {
214
- throw new Error('cfg cannot be null or undefined');
215
- }
216
- if (!config.labId.hasValue) {
217
- throw new Error('Configuration must contains labId');
218
- }
219
- if (!config.buildSessionId.hasValue) {
220
- throw new Error('Configuration must contains buildSessionId');
221
- }
222
- };
223
- ProductionFootprintsHandler.prototype.addHitsFromFile = function () {
224
- var _this = this;
225
- return new Promise(function (resolve, reject) {
226
- fs.readFile(_this.filename, function (err, data) {
227
- if (err && err.code != FILE_NOT_FOUND_CODE) {
228
- _this.logger.error('Error while trying to read previous hits data. %s', err);
229
- }
230
- if (data != null) {
231
- var hits = _this.tryParseFileContent(data.toString());
232
- if (hits != null) {
233
- _this.updateHits(hits);
234
- }
235
- else {
236
- _this.logger.error('Could not load previous hits from file');
237
- }
238
- }
239
- resolve();
240
- });
241
- });
242
- };
243
- ProductionFootprintsHandler.prototype.writeDataToFile = function () {
244
- var _this = this;
245
- return new Promise(function (resolve, reject) {
246
- var data = JSON.stringify(_this.toJSonObject());
247
- fs.writeFile(_this.filename, data, function (err) {
248
- if (err) {
249
- _this.logger.error('Error while trying to write methods hits into file. %s', err);
250
- reject(err);
251
- }
252
- resolve();
253
- });
254
- });
255
- };
256
- ProductionFootprintsHandler.prototype.createFilePath = function (config) {
257
- var filename = this.combineArgsWithDash(config.buildSessionId.value, config.labId.value, process.pid) + '.json';
258
- var fileStorage = sl_env_vars_1.SlEnvVars.getFileStorage();
259
- if (fileStorage) {
260
- return path.join(fileStorage, filename);
261
- }
262
- return filename;
263
- };
264
- ProductionFootprintsHandler.prototype.combineArgsWithDash = function () {
265
- var args = [];
266
- for (var _i = 0; _i < arguments.length; _i++) {
267
- args[_i] = arguments[_i];
268
- }
269
- return args.join('-');
270
- };
271
- ProductionFootprintsHandler.prototype.updateHits = function (methodsHitFromFile) {
272
- var _this = this;
273
- Object.keys(methodsHitFromFile).forEach(function (methodId) {
274
- if (_this.methodIdToHits[methodId]) {
275
- _this.methodIdToHits[methodId] += parseInt(methodsHitFromFile[methodId]);
276
- }
277
- else {
278
- _this.methodIdToHits[methodId] = parseInt(methodsHitFromFile[methodId]);
279
- }
280
- });
281
- };
282
- ProductionFootprintsHandler.prototype.toJSonObject = function () {
283
- return {
284
- meta: this.metaData.toJsonObject(),
285
- methodsHits: this.methodIdToHits
286
- };
287
- };
288
- return ProductionFootprintsHandler;
289
- }());
290
- exports.ProductionFootprintsHandler = ProductionFootprintsHandler;
291
- var MetaData = /** @class */ (function () {
292
- function MetaData(buildSessionId, labId) {
293
- this.buildSessionId = buildSessionId;
294
- this.labId = labId;
295
- this.createdAt = system_date_1.getSystemDate().toLocaleString();
296
- this.pid = process.pid;
297
- }
298
- MetaData.prototype.toJsonObject = function () {
299
- var _this = this;
300
- this.lastModifiedAt = system_date_1.getSystemDate().toLocaleString();
301
- var json = {};
302
- Object.keys(this).forEach(function (key) {
303
- json[key] = _this[key];
304
- });
305
- return json;
306
- };
307
- return MetaData;
308
- }());
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ 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;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.ProductionFootprintsHandler = void 0;
40
+ var fs = require("fs");
41
+ var os = require("os");
42
+ var sl_env_vars_1 = require("../constants/sl-env-vars");
43
+ var path = require("path");
44
+ var http_client_1 = require("../http/http-client");
45
+ var messages_formatter_1 = require("../messages-formatter");
46
+ var sl_routes_1 = require("../http/sl-routes");
47
+ var validation_utils_1 = require("../utils/validation-utils");
48
+ var system_date_1 = require("../system-date");
49
+ var FILE_NOT_FOUND_CODE = 'ENOENT';
50
+ var ProductionFootprintsHandler = /** @class */ (function () {
51
+ function ProductionFootprintsHandler(cfg, logger) {
52
+ this.validateConfig(cfg);
53
+ this.agentConfig = cfg;
54
+ validation_utils_1.ValidationUtils.verifyNotNullOrEmpty(logger, 'logger');
55
+ this.logger = logger;
56
+ this.metaData = new MetaData(cfg.buildSessionId.value, cfg.labId.value);
57
+ this.filename = this.createFilePath(cfg); //Todo: remove or make saving to file configurable
58
+ this.collectionStartDate = system_date_1.getSystemDateValueOf();
59
+ this.methodIdToHits = {};
60
+ this.initHttpConfig(cfg);
61
+ this.httpClient = new http_client_1.HttpClient(this.httpConfig, logger);
62
+ this.setupProdListenerModes();
63
+ }
64
+ ProductionFootprintsHandler.prototype.setupProdListenerModes = function () {
65
+ var prodListenerModes = sl_env_vars_1.SlEnvVars.getProductionListenerModes();
66
+ if (prodListenerModes.length == 0 || (prodListenerModes.length == 1 && prodListenerModes[0] == 'true')) {
67
+ //Defaults in case the production listener env var is not present or is set to 'true'
68
+ this.sendToServer = true;
69
+ this.saveToFile = false;
70
+ }
71
+ else {
72
+ this.sendToServer = prodListenerModes.indexOf('server') > -1;
73
+ this.saveToFile = prodListenerModes.indexOf('file') > -1;
74
+ }
75
+ this.logger.info('Production listener send to server: ' + this.sendToServer + ', save to file: ' + this.saveToFile);
76
+ };
77
+ ProductionFootprintsHandler.prototype.initHttpConfig = function (cfg) {
78
+ var config = {
79
+ token: cfg.token.value,
80
+ server: cfg.server.value,
81
+ proxy: cfg.proxy.value,
82
+ compressRequests: cfg.gzip.hasValue ? cfg.gzip.value : true
83
+ };
84
+ this.httpConfig = config;
85
+ };
86
+ ProductionFootprintsHandler.prototype.handleFootprints = function (footprintsPacket, callback) {
87
+ if (!footprintsPacket) {
88
+ this.logger.info('Handle footprints - got null or empty packet. Skip saving.');
89
+ callback(null);
90
+ return;
91
+ }
92
+ if (!footprintsPacket || !footprintsPacket.apps || !footprintsPacket.apps[0] || !footprintsPacket.apps[0].files) {
93
+ this.logger.info('Handle footprints - no footprints data. Skip saving.');
94
+ callback(null);
95
+ return;
96
+ }
97
+ this.saveAndSendMethodsHits(footprintsPacket)
98
+ .then(function () { return callback(null); })
99
+ .catch(function (err) { return callback(err); });
100
+ };
101
+ ProductionFootprintsHandler.prototype.saveAndSendMethodsHits = function (packetToSend) {
102
+ return __awaiter(this, void 0, void 0, function () {
103
+ var hitFiles;
104
+ return __generator(this, function (_a) {
105
+ switch (_a.label) {
106
+ case 0:
107
+ hitFiles = this.getHitFiles(packetToSend);
108
+ this.logger.debug('Submitting production data, files: %s, toServer: %s, toFile: %s (%s)', hitFiles, this.sendToServer, this.saveToFile, this.filename);
109
+ if (!this.sendToServer) return [3 /*break*/, 2];
110
+ return [4 /*yield*/, this.convertAndSubmitToServer(packetToSend)];
111
+ case 1:
112
+ _a.sent();
113
+ _a.label = 2;
114
+ case 2:
115
+ if (!this.saveToFile) return [3 /*break*/, 5];
116
+ this.methodIdToHits = {};
117
+ this.addHitsFromFootprints(packetToSend.apps[0].files);
118
+ return [4 /*yield*/, this.addHitsFromFile()];
119
+ case 3:
120
+ _a.sent();
121
+ return [4 /*yield*/, this.writeDataToFile()];
122
+ case 4:
123
+ _a.sent();
124
+ _a.label = 5;
125
+ case 5: return [2 /*return*/];
126
+ }
127
+ });
128
+ });
129
+ };
130
+ ProductionFootprintsHandler.prototype.getHitFiles = function (packetToSend) {
131
+ if (!this.logger.isDebugEnabled()) {
132
+ return;
133
+ }
134
+ var formatter = new messages_formatter_1.MessagesFormatter();
135
+ if (packetToSend && packetToSend.apps && packetToSend.apps[0] && packetToSend.apps[0].files) {
136
+ packetToSend.apps[0].files.forEach(function (file) {
137
+ formatter.addContent(file.path);
138
+ });
139
+ }
140
+ return formatter.content;
141
+ };
142
+ ProductionFootprintsHandler.prototype.convertFootprintsToProductionData = function (footprintsPacket) {
143
+ var now = system_date_1.getSystemDateValueOf();
144
+ var productionDataPacket = {
145
+ meta: {
146
+ appName: this.agentConfig.appName.value,
147
+ branchName: this.agentConfig.branch.value,
148
+ buildName: this.agentConfig.build.value,
149
+ bsid: this.agentConfig.buildSessionId.value,
150
+ createdAt: this.collectionStartDate,
151
+ lastModified: now,
152
+ customerId: this.agentConfig.customerId.value,
153
+ hostName: os.hostname(),
154
+ pid: process.pid,
155
+ labId: this.agentConfig.labId.value || 'production'
156
+ },
157
+ methodsHits: {}
158
+ };
159
+ if (footprintsPacket && footprintsPacket.apps && footprintsPacket.apps[0] && footprintsPacket.apps[0].files) {
160
+ footprintsPacket.apps[0].files.forEach(function (file) {
161
+ if (!file.methods)
162
+ return;
163
+ file.methods.forEach(function (method) {
164
+ var totalHits = 0;
165
+ if (!method.hits)
166
+ return;
167
+ method.hits.forEach(function (testIdxAndHits) {
168
+ totalHits += testIdxAndHits[1];
169
+ });
170
+ productionDataPacket.methodsHits[method.uniqueId] = totalHits;
171
+ });
172
+ });
173
+ }
174
+ this.collectionStartDate = now;
175
+ return productionDataPacket;
176
+ };
177
+ ProductionFootprintsHandler.prototype.convertAndSubmitToServer = function (footprintsPacket) {
178
+ var _this = this;
179
+ var productionDataPacket = this.convertFootprintsToProductionData(footprintsPacket);
180
+ return new Promise(function (resolve, reject) {
181
+ var url = sl_routes_1.SLRoutes.productionV1(_this.agentConfig.buildSessionId.value);
182
+ _this.httpClient.post(productionDataPacket, url, function (err) {
183
+ err ? reject(err) : resolve();
184
+ });
185
+ });
186
+ };
187
+ /*
188
+ In production listener we are in anonymous mode, and all hits will refer to single anonymous test.
189
+ So we can there will be single array in "hits" array.
190
+ In this inner array firs element will be always '0'(the index of test in array which contains only one - the anonymous),
191
+ and the second element is the hits number.
192
+ */
193
+ ProductionFootprintsHandler.prototype.addHitsFromFootprints = function (files) {
194
+ var _this = this;
195
+ files.forEach(function (file) {
196
+ file.methods.forEach(function (method) {
197
+ _this.methodIdToHits[method.uniqueId] = method.hits[0][1];
198
+ });
199
+ });
200
+ };
201
+ ProductionFootprintsHandler.prototype.tryParseFileContent = function (fileContent) {
202
+ try {
203
+ var hitsData = JSON.parse(fileContent).methodsHits;
204
+ this.logger.debug('Previous hit data parsed successfully, \'%s\' items loaded', Object.keys(hitsData).length);
205
+ return hitsData;
206
+ }
207
+ catch (err) {
208
+ this.logger.error('Error while parsing hits file content. %s', err);
209
+ return null;
210
+ }
211
+ };
212
+ ProductionFootprintsHandler.prototype.validateConfig = function (config) {
213
+ if (!config) {
214
+ throw new Error('cfg cannot be null or undefined');
215
+ }
216
+ if (!config.labId.hasValue) {
217
+ throw new Error('Configuration must contains labId');
218
+ }
219
+ if (!config.buildSessionId.hasValue) {
220
+ throw new Error('Configuration must contains buildSessionId');
221
+ }
222
+ };
223
+ ProductionFootprintsHandler.prototype.addHitsFromFile = function () {
224
+ var _this = this;
225
+ return new Promise(function (resolve, reject) {
226
+ fs.readFile(_this.filename, function (err, data) {
227
+ if (err && err.code != FILE_NOT_FOUND_CODE) {
228
+ _this.logger.error('Error while trying to read previous hits data. %s', err);
229
+ }
230
+ if (data != null) {
231
+ var hits = _this.tryParseFileContent(data.toString());
232
+ if (hits != null) {
233
+ _this.updateHits(hits);
234
+ }
235
+ else {
236
+ _this.logger.error('Could not load previous hits from file');
237
+ }
238
+ }
239
+ resolve();
240
+ });
241
+ });
242
+ };
243
+ ProductionFootprintsHandler.prototype.writeDataToFile = function () {
244
+ var _this = this;
245
+ return new Promise(function (resolve, reject) {
246
+ var data = JSON.stringify(_this.toJSonObject());
247
+ fs.writeFile(_this.filename, data, function (err) {
248
+ if (err) {
249
+ _this.logger.error('Error while trying to write methods hits into file. %s', err);
250
+ reject(err);
251
+ }
252
+ resolve();
253
+ });
254
+ });
255
+ };
256
+ ProductionFootprintsHandler.prototype.createFilePath = function (config) {
257
+ var filename = this.combineArgsWithDash(config.buildSessionId.value, config.labId.value, process.pid) + '.json';
258
+ var fileStorage = sl_env_vars_1.SlEnvVars.getFileStorage();
259
+ if (fileStorage) {
260
+ return path.join(fileStorage, filename);
261
+ }
262
+ return filename;
263
+ };
264
+ ProductionFootprintsHandler.prototype.combineArgsWithDash = function () {
265
+ var args = [];
266
+ for (var _i = 0; _i < arguments.length; _i++) {
267
+ args[_i] = arguments[_i];
268
+ }
269
+ return args.join('-');
270
+ };
271
+ ProductionFootprintsHandler.prototype.updateHits = function (methodsHitFromFile) {
272
+ var _this = this;
273
+ Object.keys(methodsHitFromFile).forEach(function (methodId) {
274
+ if (_this.methodIdToHits[methodId]) {
275
+ _this.methodIdToHits[methodId] += parseInt(methodsHitFromFile[methodId]);
276
+ }
277
+ else {
278
+ _this.methodIdToHits[methodId] = parseInt(methodsHitFromFile[methodId]);
279
+ }
280
+ });
281
+ };
282
+ ProductionFootprintsHandler.prototype.toJSonObject = function () {
283
+ return {
284
+ meta: this.metaData.toJsonObject(),
285
+ methodsHits: this.methodIdToHits
286
+ };
287
+ };
288
+ return ProductionFootprintsHandler;
289
+ }());
290
+ exports.ProductionFootprintsHandler = ProductionFootprintsHandler;
291
+ var MetaData = /** @class */ (function () {
292
+ function MetaData(buildSessionId, labId) {
293
+ this.buildSessionId = buildSessionId;
294
+ this.labId = labId;
295
+ this.createdAt = system_date_1.getSystemDate().toLocaleString();
296
+ this.pid = process.pid;
297
+ }
298
+ MetaData.prototype.toJsonObject = function () {
299
+ var _this = this;
300
+ this.lastModifiedAt = system_date_1.getSystemDate().toLocaleString();
301
+ var json = {};
302
+ Object.keys(this).forEach(function (key) {
303
+ json[key] = _this[key];
304
+ });
305
+ return json;
306
+ };
307
+ return MetaData;
308
+ }());
309
309
  //# sourceMappingURL=production-footprints-handler.js.map