@speedkit/cli 2.4.1

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 (385) hide show
  1. package/README.md +775 -0
  2. package/bin/dev +18 -0
  3. package/bin/dev.cmd +3 -0
  4. package/bin/run +4 -0
  5. package/bin/run.cmd +3 -0
  6. package/dist/commands/airports_iata.json +1 -0
  7. package/dist/commands/build-parameter-query.d.ts +15 -0
  8. package/dist/commands/build-parameter-query.js +95 -0
  9. package/dist/commands/build-prewarm-query.d.ts +15 -0
  10. package/dist/commands/build-prewarm-query.js +69 -0
  11. package/dist/commands/deploy.d.ts +17 -0
  12. package/dist/commands/deploy.js +39 -0
  13. package/dist/commands/document-handler.d.ts +16 -0
  14. package/dist/commands/document-handler.js +36 -0
  15. package/dist/commands/find-pops.d.ts +17 -0
  16. package/dist/commands/find-pops.js +84 -0
  17. package/dist/commands/generate-customer-config.d.ts +10 -0
  18. package/dist/commands/generate-customer-config.js +29 -0
  19. package/dist/commands/generate-pop-config.d.ts +27 -0
  20. package/dist/commands/generate-pop-config.js +231 -0
  21. package/dist/commands/login.d.ts +10 -0
  22. package/dist/commands/login.js +35 -0
  23. package/dist/commands/onboarding.d.ts +16 -0
  24. package/dist/commands/onboarding.js +25 -0
  25. package/dist/commands/param-diff.d.ts +16 -0
  26. package/dist/commands/param-diff.js +111 -0
  27. package/dist/commands/pop-prewarm.d.ts +17 -0
  28. package/dist/commands/pop-prewarm.js +80 -0
  29. package/dist/commands/prewarm.d.ts +40 -0
  30. package/dist/commands/prewarm.js +127 -0
  31. package/dist/commands/pull.d.ts +14 -0
  32. package/dist/commands/pull.js +24 -0
  33. package/dist/commands/wpt-launcher.d.ts +21 -0
  34. package/dist/commands/wpt-launcher.js +79 -0
  35. package/dist/helpers/CustomerConfig.d.ts +51 -0
  36. package/dist/helpers/CustomerConfig.js +150 -0
  37. package/dist/helpers/build-query-helper.d.ts +32 -0
  38. package/dist/helpers/build-query-helper.js +216 -0
  39. package/dist/helpers/cli-config.d.ts +22 -0
  40. package/dist/helpers/cli-config.js +85 -0
  41. package/dist/helpers/file-helper.d.ts +8 -0
  42. package/dist/helpers/file-helper.js +63 -0
  43. package/dist/helpers/get-parsed-config.d.ts +11 -0
  44. package/dist/helpers/get-parsed-config.js +63 -0
  45. package/dist/helpers/getChromePath.d.ts +7 -0
  46. package/dist/helpers/getChromePath.js +27 -0
  47. package/dist/helpers/isDirectory.d.ts +1 -0
  48. package/dist/helpers/isDirectory.js +17 -0
  49. package/dist/helpers/isExecutable.d.ts +1 -0
  50. package/dist/helpers/isExecutable.js +15 -0
  51. package/dist/helpers/isFile.d.ts +1 -0
  52. package/dist/helpers/isFile.js +17 -0
  53. package/dist/helpers/logging-helper.d.ts +12 -0
  54. package/dist/helpers/logging-helper.js +27 -0
  55. package/dist/helpers/normalize.d.ts +40 -0
  56. package/dist/helpers/normalize.js +112 -0
  57. package/dist/helpers/race.d.ts +1 -0
  58. package/dist/helpers/race.js +16 -0
  59. package/dist/helpers/safe.d.ts +10 -0
  60. package/dist/helpers/safe.js +34 -0
  61. package/dist/helpers/scrape.d.ts +1 -0
  62. package/dist/helpers/scrape.js +11 -0
  63. package/dist/helpers/speedKitRuleToRegExp.d.ts +1 -0
  64. package/dist/helpers/speedKitRuleToRegExp.js +10 -0
  65. package/dist/helpers/watchFiles.d.ts +1 -0
  66. package/dist/helpers/watchFiles.js +20 -0
  67. package/dist/models/cli-parameters.d.ts +73 -0
  68. package/dist/models/cli-parameters.js +82 -0
  69. package/dist/models/files.d.ts +20 -0
  70. package/dist/models/files.js +23 -0
  71. package/dist/models/install.d.ts +24 -0
  72. package/dist/models/install.js +2 -0
  73. package/dist/services/athena-service.d.ts +30 -0
  74. package/dist/services/athena-service.js +139 -0
  75. package/dist/services/bundler/bundle-service-factory.d.ts +4 -0
  76. package/dist/services/bundler/bundle-service-factory.js +10 -0
  77. package/dist/services/bundler/bundle-service.d.ts +25 -0
  78. package/dist/services/bundler/bundle-service.js +84 -0
  79. package/dist/services/bundler/index.d.ts +2 -0
  80. package/dist/services/bundler/index.js +5 -0
  81. package/dist/services/cli/cli-service-factory.d.ts +5 -0
  82. package/dist/services/cli/cli-service-factory.js +14 -0
  83. package/dist/services/cli/cli-service-model.d.ts +27 -0
  84. package/dist/services/cli/cli-service-model.js +9 -0
  85. package/dist/services/cli/cli-service.d.ts +37 -0
  86. package/dist/services/cli/cli-service.js +123 -0
  87. package/dist/services/cli/error/cli-type-error.d.ts +3 -0
  88. package/dist/services/cli/error/cli-type-error.js +7 -0
  89. package/dist/services/cli/hooks.d.ts +11 -0
  90. package/dist/services/cli/hooks.js +33 -0
  91. package/dist/services/cli/index.d.ts +3 -0
  92. package/dist/services/cli/index.js +6 -0
  93. package/dist/services/config-api/client.d.ts +16 -0
  94. package/dist/services/config-api/client.js +54 -0
  95. package/dist/services/config-api/config-api-service.d.ts +16 -0
  96. package/dist/services/config-api/config-api-service.js +56 -0
  97. package/dist/services/config-api/context/config-api-context.d.ts +5 -0
  98. package/dist/services/config-api/context/config-api-context.js +9 -0
  99. package/dist/services/config-api/error/json-response-error.d.ts +2 -0
  100. package/dist/services/config-api/error/json-response-error.js +5 -0
  101. package/dist/services/config-api/error/login-error.d.ts +5 -0
  102. package/dist/services/config-api/error/login-error.js +12 -0
  103. package/dist/services/config-api/factory/config-api-service-factory.d.ts +10 -0
  104. package/dist/services/config-api/factory/config-api-service-factory.js +38 -0
  105. package/dist/services/config-api/factory/entity-manager-factory.d.ts +5 -0
  106. package/dist/services/config-api/factory/entity-manager-factory.js +21 -0
  107. package/dist/services/config-api/interface/config-api-context-interface.d.ts +4 -0
  108. package/dist/services/config-api/interface/config-api-context-interface.js +2 -0
  109. package/dist/services/config-api/interface/request-extension-interface.d.ts +5 -0
  110. package/dist/services/config-api/interface/request-extension-interface.js +2 -0
  111. package/dist/services/config-api-service.d.ts +18 -0
  112. package/dist/services/config-api-service.js +96 -0
  113. package/dist/services/context/app-context.d.ts +1 -0
  114. package/dist/services/context/app-context.js +2 -0
  115. package/dist/services/context/error/context-runtime-error.d.ts +3 -0
  116. package/dist/services/context/error/context-runtime-error.js +7 -0
  117. package/dist/services/context/interface/context-interface.d.ts +2 -0
  118. package/dist/services/context/interface/context-interface.js +2 -0
  119. package/dist/services/customer-config/customer-config-service-context.d.ts +5 -0
  120. package/dist/services/customer-config/customer-config-service-context.js +15 -0
  121. package/dist/services/customer-config/customer-config-service-factory.d.ts +8 -0
  122. package/dist/services/customer-config/customer-config-service-factory.js +24 -0
  123. package/dist/services/customer-config/customer-config-service-model.d.ts +39 -0
  124. package/dist/services/customer-config/customer-config-service-model.js +23 -0
  125. package/dist/services/customer-config/customer-config-service.d.ts +27 -0
  126. package/dist/services/customer-config/customer-config-service.js +263 -0
  127. package/dist/services/customer-config/index.d.ts +4 -0
  128. package/dist/services/customer-config/index.js +7 -0
  129. package/dist/services/customer-config/templates/config_SpeedKit.js.hbs +351 -0
  130. package/dist/services/customer-config/templates/config_customer.js.hbs +75 -0
  131. package/dist/services/customer-config/templates/config_documentHandler.js.hbs +162 -0
  132. package/dist/services/customer-config/templates/config_dynamicBlocks.es6.hbs +263 -0
  133. package/dist/services/customer-config/templates/config_dynamicStyles.css.hbs +116 -0
  134. package/dist/services/customer-config/templates/config_loadHandler.js.hbs +394 -0
  135. package/dist/services/customer-config/templates/deploymentDetection.es6.hbs +262 -0
  136. package/dist/services/customer-config/templates/downtimeDetection.js.hbs +110 -0
  137. package/dist/services/deploy/builder/install-resource-builder.d.ts +14 -0
  138. package/dist/services/deploy/builder/install-resource-builder.js +48 -0
  139. package/dist/services/deploy/checks/post-deploy/revalidated-module-check.d.ts +11 -0
  140. package/dist/services/deploy/checks/post-deploy/revalidated-module-check.js +30 -0
  141. package/dist/services/deploy/checks/post-deploy/save-files-check.d.ts +9 -0
  142. package/dist/services/deploy/checks/post-deploy/save-files-check.js +25 -0
  143. package/dist/services/deploy/context/deploy-context.d.ts +12 -0
  144. package/dist/services/deploy/context/deploy-context.js +26 -0
  145. package/dist/services/deploy/deploy-service-factory.d.ts +15 -0
  146. package/dist/services/deploy/deploy-service-factory.js +68 -0
  147. package/dist/services/deploy/deploy-service.d.ts +17 -0
  148. package/dist/services/deploy/deploy-service.js +63 -0
  149. package/dist/services/deploy/error/create-find-temp-directory-error.d.ts +4 -0
  150. package/dist/services/deploy/error/create-find-temp-directory-error.js +10 -0
  151. package/dist/services/deploy/error/deploy-app-error.d.ts +2 -0
  152. package/dist/services/deploy/error/deploy-app-error.js +5 -0
  153. package/dist/services/deploy/error/no-active-installation-error.d.ts +4 -0
  154. package/dist/services/deploy/error/no-active-installation-error.js +10 -0
  155. package/dist/services/deploy/handler/customer-config-handler.d.ts +21 -0
  156. package/dist/services/deploy/handler/customer-config-handler.js +85 -0
  157. package/dist/services/deploy/handler/install-resource-handler.d.ts +25 -0
  158. package/dist/services/deploy/handler/install-resource-handler.js +104 -0
  159. package/dist/services/deploy/handler/install-resource-modifier/deleted-file-check.d.ts +13 -0
  160. package/dist/services/deploy/handler/install-resource-modifier/deleted-file-check.js +51 -0
  161. package/dist/services/deploy/handler/module-handler.d.ts +14 -0
  162. package/dist/services/deploy/handler/module-handler.js +81 -0
  163. package/dist/services/deploy/handler/module-modifier/deployment-detection-modifier.d.ts +9 -0
  164. package/dist/services/deploy/handler/module-modifier/deployment-detection-modifier.js +24 -0
  165. package/dist/services/deploy/handler/server-config-handler.d.ts +12 -0
  166. package/dist/services/deploy/handler/server-config-handler.js +63 -0
  167. package/dist/services/deploy/interface/deploy-handler-interface.d.ts +6 -0
  168. package/dist/services/deploy/interface/deploy-handler-interface.js +2 -0
  169. package/dist/services/deploy/interface/install-configs.d.ts +11 -0
  170. package/dist/services/deploy/interface/install-configs.js +2 -0
  171. package/dist/services/deploy/interface/install-resource-processor-interface.d.ts +5 -0
  172. package/dist/services/deploy/interface/install-resource-processor-interface.js +2 -0
  173. package/dist/services/deploy/interface/install.d.ts +14 -0
  174. package/dist/services/deploy/interface/install.js +2 -0
  175. package/dist/services/deploy/interface/post-deploy-check-interface.d.ts +3 -0
  176. package/dist/services/deploy/interface/post-deploy-check-interface.js +2 -0
  177. package/dist/services/deploy/interface/runtime-modifier.d.ts +6 -0
  178. package/dist/services/deploy/interface/runtime-modifier.js +2 -0
  179. package/dist/services/deploy/interface/validate-origins-response.d.ts +4 -0
  180. package/dist/services/deploy/interface/validate-origins-response.js +2 -0
  181. package/dist/services/diff/diff-model.d.ts +5 -0
  182. package/dist/services/diff/diff-model.js +12 -0
  183. package/dist/services/diff/diff-service-factory.d.ts +7 -0
  184. package/dist/services/diff/diff-service-factory.js +20 -0
  185. package/dist/services/diff/diff-service.d.ts +34 -0
  186. package/dist/services/diff/diff-service.js +134 -0
  187. package/dist/services/diff/index.d.ts +3 -0
  188. package/dist/services/diff/index.js +6 -0
  189. package/dist/services/diff-service.d.ts +24 -0
  190. package/dist/services/diff-service.js +112 -0
  191. package/dist/services/document-handler-runtime/context/document-handler-runtime-context.d.ts +23 -0
  192. package/dist/services/document-handler-runtime/context/document-handler-runtime-context.js +41 -0
  193. package/dist/services/document-handler-runtime/document-handler-runtime-service.d.ts +32 -0
  194. package/dist/services/document-handler-runtime/document-handler-runtime-service.js +220 -0
  195. package/dist/services/document-handler-runtime/document-handler-server.d.ts +42 -0
  196. package/dist/services/document-handler-runtime/document-handler-server.js +225 -0
  197. package/dist/services/document-handler-runtime/error/handler/required-file-not-found-handler.d.ts +6 -0
  198. package/dist/services/document-handler-runtime/error/handler/required-file-not-found-handler.js +14 -0
  199. package/dist/services/document-handler-runtime/error/required-file-not-found-error.d.ts +3 -0
  200. package/dist/services/document-handler-runtime/error/required-file-not-found-error.js +7 -0
  201. package/dist/services/document-handler-runtime/factory/document-handler-runtime-service-factory.d.ts +24 -0
  202. package/dist/services/document-handler-runtime/factory/document-handler-runtime-service-factory.js +106 -0
  203. package/dist/services/document-handler-runtime/interface/document-handler-runtime-config-interface.d.ts +3 -0
  204. package/dist/services/document-handler-runtime/interface/document-handler-runtime-config-interface.js +6 -0
  205. package/dist/services/document-handler-runtime/interface/template-context-interface.d.ts +3 -0
  206. package/dist/services/document-handler-runtime/interface/template-context-interface.js +2 -0
  207. package/dist/services/document-handler-runtime/interface/template-interface.d.ts +6 -0
  208. package/dist/services/document-handler-runtime/interface/template-interface.js +2 -0
  209. package/dist/services/document-handler-runtime/interface/template-param-interface.d.ts +4 -0
  210. package/dist/services/document-handler-runtime/interface/template-param-interface.js +2 -0
  211. package/dist/services/document-handler-runtime/templates/abstract-template.d.ts +9 -0
  212. package/dist/services/document-handler-runtime/templates/abstract-template.js +18 -0
  213. package/dist/services/document-handler-runtime/templates/database-mock.d.ts +6 -0
  214. package/dist/services/document-handler-runtime/templates/database-mock.js +111 -0
  215. package/dist/services/document-handler-runtime/templates/execute-document-handler.d.ts +6 -0
  216. package/dist/services/document-handler-runtime/templates/execute-document-handler.js +76 -0
  217. package/dist/services/document-handler-runtime/templates/orestes-mock.d.ts +9 -0
  218. package/dist/services/document-handler-runtime/templates/orestes-mock.js +168 -0
  219. package/dist/services/document-handler-runtime/templates/package-json.d.ts +8 -0
  220. package/dist/services/document-handler-runtime/templates/package-json.js +21 -0
  221. package/dist/services/document-handler-runtime/templates/test.d.ts +6 -0
  222. package/dist/services/document-handler-runtime/templates/test.js +63 -0
  223. package/dist/services/error-handling/abstract/abstract-async-error-handling-factory.d.ts +6 -0
  224. package/dist/services/error-handling/abstract/abstract-async-error-handling-factory.js +19 -0
  225. package/dist/services/error-handling/abstract/abstract-async-error-handling-service.d.ts +6 -0
  226. package/dist/services/error-handling/abstract/abstract-async-error-handling-service.js +18 -0
  227. package/dist/services/error-handling/abstract/abstract-error-handling-factory.d.ts +6 -0
  228. package/dist/services/error-handling/abstract/abstract-error-handling-factory.js +19 -0
  229. package/dist/services/error-handling/abstract/abstract-error-handling-service.d.ts +6 -0
  230. package/dist/services/error-handling/abstract/abstract-error-handling-service.js +19 -0
  231. package/dist/services/error-handling/error/application-error.d.ts +5 -0
  232. package/dist/services/error-handling/error/application-error.js +11 -0
  233. package/dist/services/error-handling/error/handler/default-error-handler.d.ts +5 -0
  234. package/dist/services/error-handling/error/handler/default-error-handler.js +13 -0
  235. package/dist/services/error-handling/error-handling-service.d.ts +7 -0
  236. package/dist/services/error-handling/error-handling-service.js +27 -0
  237. package/dist/services/error-handling/factory/error-handling-factory.d.ts +8 -0
  238. package/dist/services/error-handling/factory/error-handling-factory.js +21 -0
  239. package/dist/services/error-handling/interface/error-context-interface.d.ts +6 -0
  240. package/dist/services/error-handling/interface/error-context-interface.js +2 -0
  241. package/dist/services/error-handling/interface/error-handler-interface.d.ts +5 -0
  242. package/dist/services/error-handling/interface/error-handler-interface.js +2 -0
  243. package/dist/services/error-handling/interface/error-handling-factory-interface.d.ts +8 -0
  244. package/dist/services/error-handling/interface/error-handling-factory-interface.js +2 -0
  245. package/dist/services/error-handling/interface/error-handling-service-interface.d.ts +8 -0
  246. package/dist/services/error-handling/interface/error-handling-service-interface.js +2 -0
  247. package/dist/services/integration-api/context/integration-api-context.d.ts +9 -0
  248. package/dist/services/integration-api/context/integration-api-context.js +20 -0
  249. package/dist/services/integration-api/error/customer-config-error.d.ts +2 -0
  250. package/dist/services/integration-api/error/customer-config-error.js +5 -0
  251. package/dist/services/integration-api/error/customer-config-legacy-error.d.ts +3 -0
  252. package/dist/services/integration-api/error/customer-config-legacy-error.js +7 -0
  253. package/dist/services/integration-api/error/handler/customer-config-handler.d.ts +5 -0
  254. package/dist/services/integration-api/error/handler/customer-config-handler.js +19 -0
  255. package/dist/services/integration-api/error/handler/customer-config-legacy-handler.d.ts +6 -0
  256. package/dist/services/integration-api/error/handler/customer-config-legacy-handler.js +24 -0
  257. package/dist/services/integration-api/error/handler/origin-handler.d.ts +6 -0
  258. package/dist/services/integration-api/error/handler/origin-handler.js +22 -0
  259. package/dist/services/integration-api/error/load-customer-error.d.ts +4 -0
  260. package/dist/services/integration-api/error/load-customer-error.js +10 -0
  261. package/dist/services/integration-api/error/mandatory-file-missing-error.d.ts +3 -0
  262. package/dist/services/integration-api/error/mandatory-file-missing-error.js +8 -0
  263. package/dist/services/integration-api/error/origin-error.d.ts +3 -0
  264. package/dist/services/integration-api/error/origin-error.js +7 -0
  265. package/dist/services/integration-api/external/external-file-reader.d.ts +4 -0
  266. package/dist/services/integration-api/external/external-file-reader.js +17 -0
  267. package/dist/services/integration-api/factory/integration-api-service-factory.d.ts +13 -0
  268. package/dist/services/integration-api/factory/integration-api-service-factory.js +55 -0
  269. package/dist/services/integration-api/file-list.d.ts +18 -0
  270. package/dist/services/integration-api/file-list.js +79 -0
  271. package/dist/services/integration-api/file-reader.d.ts +15 -0
  272. package/dist/services/integration-api/file-reader.js +97 -0
  273. package/dist/services/integration-api/file-writer.d.ts +9 -0
  274. package/dist/services/integration-api/file-writer.js +27 -0
  275. package/dist/services/integration-api/handler/customer-config-handler.d.ts +16 -0
  276. package/dist/services/integration-api/handler/customer-config-handler.js +55 -0
  277. package/dist/services/integration-api/handler/file-handler.d.ts +9 -0
  278. package/dist/services/integration-api/handler/file-handler.js +20 -0
  279. package/dist/services/integration-api/handler/install-resource-handler.d.ts +33 -0
  280. package/dist/services/integration-api/handler/install-resource-handler.js +67 -0
  281. package/dist/services/integration-api/handler/module-handler.d.ts +12 -0
  282. package/dist/services/integration-api/handler/module-handler.js +20 -0
  283. package/dist/services/integration-api/handler/server-config-handler.d.ts +8 -0
  284. package/dist/services/integration-api/handler/server-config-handler.js +21 -0
  285. package/dist/services/integration-api/integration-api-model.d.ts +89 -0
  286. package/dist/services/integration-api/integration-api-model.js +2 -0
  287. package/dist/services/integration-api/integration-api-service.d.ts +21 -0
  288. package/dist/services/integration-api/integration-api-service.js +76 -0
  289. package/dist/services/integration-api/struct/customer-config-file.d.ts +10 -0
  290. package/dist/services/integration-api/struct/customer-config-file.js +32 -0
  291. package/dist/services/integration-api/struct/customer-config.d.ts +22 -0
  292. package/dist/services/integration-api/struct/customer-config.js +67 -0
  293. package/dist/services/integration-api/struct/file.d.ts +19 -0
  294. package/dist/services/integration-api/struct/file.js +61 -0
  295. package/dist/services/integration-api/struct/install-resource-file.d.ts +6 -0
  296. package/dist/services/integration-api/struct/install-resource-file.js +12 -0
  297. package/dist/services/integration-api/struct/module-file.d.ts +5 -0
  298. package/dist/services/integration-api/struct/module-file.js +10 -0
  299. package/dist/services/integration-api/struct/ro-file.d.ts +13 -0
  300. package/dist/services/integration-api/struct/ro-file.js +26 -0
  301. package/dist/services/integration-api/struct/server-config-file.d.ts +9 -0
  302. package/dist/services/integration-api/struct/server-config-file.js +22 -0
  303. package/dist/services/integration-api/struct/virtual-file.d.ts +14 -0
  304. package/dist/services/integration-api/struct/virtual-file.js +28 -0
  305. package/dist/services/integration-api/validator/customer-config-validator.d.ts +5 -0
  306. package/dist/services/integration-api/validator/customer-config-validator.js +23 -0
  307. package/dist/services/integration-api/validator/mandatory-files-validator.d.ts +7 -0
  308. package/dist/services/integration-api/validator/mandatory-files-validator.js +39 -0
  309. package/dist/services/integration-api/virtual/external-recipe.d.ts +9 -0
  310. package/dist/services/integration-api/virtual/external-recipe.js +19 -0
  311. package/dist/services/integration-api/virtual/virtual-file-handler.d.ts +7 -0
  312. package/dist/services/integration-api/virtual/virtual-file-handler.js +38 -0
  313. package/dist/services/onboarding/browser/abort-response.d.ts +5 -0
  314. package/dist/services/onboarding/browser/abort-response.js +10 -0
  315. package/dist/services/onboarding/browser/baqend-response.d.ts +12 -0
  316. package/dist/services/onboarding/browser/baqend-response.js +52 -0
  317. package/dist/services/onboarding/browser/origin-response.d.ts +8 -0
  318. package/dist/services/onboarding/browser/origin-response.js +20 -0
  319. package/dist/services/onboarding/config-renderer/install-file-recipe.d.ts +7 -0
  320. package/dist/services/onboarding/config-renderer/install-file-recipe.js +13 -0
  321. package/dist/services/onboarding/config-renderer/speed-kit-install-context.d.ts +22 -0
  322. package/dist/services/onboarding/config-renderer/speed-kit-install-context.js +78 -0
  323. package/dist/services/onboarding/dashboard/athena-service.d.ts +11 -0
  324. package/dist/services/onboarding/dashboard/athena-service.js +70 -0
  325. package/dist/services/onboarding/dashboard/frontend-dist/assets/index-87b53ed4.css +1 -0
  326. package/dist/services/onboarding/dashboard/frontend-dist/assets/main-274b5625.js +9 -0
  327. package/dist/services/onboarding/dashboard/frontend-dist/index.html +18 -0
  328. package/dist/services/onboarding/dashboard/index.d.ts +16 -0
  329. package/dist/services/onboarding/dashboard/index.js +78 -0
  330. package/dist/services/onboarding/dashboard/param-query-builder.d.ts +9 -0
  331. package/dist/services/onboarding/dashboard/param-query-builder.js +67 -0
  332. package/dist/services/onboarding/dashboard/request-diff-service.d.ts +11 -0
  333. package/dist/services/onboarding/dashboard/request-diff-service.js +59 -0
  334. package/dist/services/onboarding/error/vm-error.d.ts +2 -0
  335. package/dist/services/onboarding/error/vm-error.js +6 -0
  336. package/dist/services/onboarding/fetch-event-handler.d.ts +19 -0
  337. package/dist/services/onboarding/fetch-event-handler.js +155 -0
  338. package/dist/services/onboarding/fetch-events/customer-domain-document-response.d.ts +24 -0
  339. package/dist/services/onboarding/fetch-events/customer-domain-document-response.js +118 -0
  340. package/dist/services/onboarding/fetch-events/customer-service-worker-js.d.ts +14 -0
  341. package/dist/services/onboarding/fetch-events/customer-service-worker-js.js +30 -0
  342. package/dist/services/onboarding/fetch-events/dashboard-request.d.ts +15 -0
  343. package/dist/services/onboarding/fetch-events/dashboard-request.js +29 -0
  344. package/dist/services/onboarding/fetch-events/speed-kit-asset-request.d.ts +26 -0
  345. package/dist/services/onboarding/fetch-events/speed-kit-asset-request.js +138 -0
  346. package/dist/services/onboarding/fetch-events/speed-kit-install-html.d.ts +15 -0
  347. package/dist/services/onboarding/fetch-events/speed-kit-install-html.js +49 -0
  348. package/dist/services/onboarding/fetch-events/speed-kit-install-js.d.ts +22 -0
  349. package/dist/services/onboarding/fetch-events/speed-kit-install-js.js +62 -0
  350. package/dist/services/onboarding/fetch-events/speed-kit-rum-pi-request.d.ts +21 -0
  351. package/dist/services/onboarding/fetch-events/speed-kit-rum-pi-request.js +43 -0
  352. package/dist/services/onboarding/fetch-events/speed-kit-service-worker-js.d.ts +17 -0
  353. package/dist/services/onboarding/fetch-events/speed-kit-service-worker-js.js +27 -0
  354. package/dist/services/onboarding/file-events/fileWatcher.d.ts +28 -0
  355. package/dist/services/onboarding/file-events/fileWatcher.js +133 -0
  356. package/dist/services/onboarding/index.d.ts +3 -0
  357. package/dist/services/onboarding/index.js +8 -0
  358. package/dist/services/onboarding/onboarding-model.d.ts +30 -0
  359. package/dist/services/onboarding/onboarding-model.js +53 -0
  360. package/dist/services/onboarding/onboarding-service-factory.d.ts +16 -0
  361. package/dist/services/onboarding/onboarding-service-factory.js +163 -0
  362. package/dist/services/onboarding/onboarding-service.d.ts +31 -0
  363. package/dist/services/onboarding/onboarding-service.js +130 -0
  364. package/dist/services/onboarding/request-cache/cache.d.ts +15 -0
  365. package/dist/services/onboarding/request-cache/cache.js +32 -0
  366. package/dist/services/onboarding/templates/install-speed-kit-html-template.d.ts +4 -0
  367. package/dist/services/onboarding/templates/install-speed-kit-html-template.js +264 -0
  368. package/dist/services/onboarding/templates/install-speed-kit-js-template.d.ts +4 -0
  369. package/dist/services/onboarding/templates/install-speed-kit-js-template.js +41 -0
  370. package/dist/services/onboarding/todo-collector.d.ts +18 -0
  371. package/dist/services/onboarding/todo-collector.js +48 -0
  372. package/dist/services/prewarm-service.d.ts +5 -0
  373. package/dist/services/prewarm-service.js +57 -0
  374. package/dist/services/pull/index.d.ts +3 -0
  375. package/dist/services/pull/index.js +6 -0
  376. package/dist/services/pull/pull-service-factory.d.ts +12 -0
  377. package/dist/services/pull/pull-service-factory.js +44 -0
  378. package/dist/services/pull/pull-service-model.d.ts +43 -0
  379. package/dist/services/pull/pull-service-model.js +27 -0
  380. package/dist/services/pull/pull-service.d.ts +18 -0
  381. package/dist/services/pull/pull-service.js +106 -0
  382. package/dist/templates/pops.js +97 -0
  383. package/dist/templates/speedKit.Revalidated.js +86 -0
  384. package/oclif.manifest.json +700 -0
  385. package/package.json +128 -0
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RequestDiffService = void 0;
4
+ const baqend_response_1 = require("../browser/baqend-response");
5
+ const safe_1 = require("../../../helpers/safe");
6
+ class RequestDiffService {
7
+ diffService;
8
+ constructor(diffService) {
9
+ this.diffService = diffService;
10
+ }
11
+ async postDiff(url, parametersString) {
12
+ const params = parametersString.replace('[', '').replace(']', '').split((',')).map(param => {
13
+ return param.trim();
14
+ });
15
+ const { urlWithParam, urlWithoutParam } = this.createUrlsForDiff(url, params);
16
+ const result = await (0, safe_1.safe)(this.diffLocal(urlWithParam, urlWithoutParam));
17
+ if (result.success === true) {
18
+ return new baqend_response_1.BaqendResponse(JSON.stringify({ status: 'success', isIdentical: result.data }), 'application/json; charset=UTF-8');
19
+ }
20
+ return new baqend_response_1.BaqendResponse(JSON.stringify({ status: 'error', error: result.error }), 'application/json; charset=UTF-8', null, 500);
21
+ }
22
+ async diffLocal(urlWithParam, urlWithoutParam) {
23
+ const htmlWithParam = await this.fetchHtml(urlWithParam);
24
+ const htmlWithoutParam = await this.fetchHtml(urlWithoutParam);
25
+ const paramsFilePath = await this.diffService.writeContentToTemporalFile('params', htmlWithParam);
26
+ const pureFilePath = await this.diffService.writeContentToTemporalFile('pure', htmlWithoutParam);
27
+ return await this.diffService.executeDiff(paramsFilePath, pureFilePath);
28
+ }
29
+ async doOriginVsContentDiff(url, content) {
30
+ const html = await this.fetchHtml(url);
31
+ const origin = await this.diffService.writeContentToTemporalFile('origin', html);
32
+ const local = await this.diffService.writeContentToTemporalFile('content', content);
33
+ return await this.diffService.executeDiff(local, origin);
34
+ }
35
+ async fetchHtml(url) {
36
+ const response = await fetch(url);
37
+ return await response.text();
38
+ }
39
+ createUrlsForDiff(urlWithParam, params) {
40
+ const url = new URL(urlWithParam);
41
+ const search_params = url.searchParams;
42
+ for (const param of params) {
43
+ search_params.delete(param);
44
+ }
45
+ url.search = search_params.toString();
46
+ const urlWithoutParam = url.toString();
47
+ console.log('With-----');
48
+ console.log(urlWithParam);
49
+ console.log('Without-----');
50
+ console.log(urlWithoutParam);
51
+ console.log('-----');
52
+ // TODO: Insert the content
53
+ return {
54
+ urlWithParam,
55
+ urlWithoutParam
56
+ };
57
+ }
58
+ }
59
+ exports.RequestDiffService = RequestDiffService;
@@ -0,0 +1,2 @@
1
+ export declare class VmError extends Error {
2
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VmError = void 0;
4
+ class VmError extends Error {
5
+ }
6
+ exports.VmError = VmError;
@@ -0,0 +1,19 @@
1
+ import { FetchRequestPausedEventHandler } from "./onboarding-model";
2
+ import { Protocol } from "puppeteer-core";
3
+ import { CDPSession, Target } from "puppeteer";
4
+ import { CliService } from "../cli";
5
+ import CustomerConfig from "../integration-api/struct/customer-config";
6
+ import ConfigApiService from "../config-api/config-api-service";
7
+ export declare class FetchEventHandler {
8
+ private browserFetchEvents;
9
+ private customerConfig;
10
+ private cli;
11
+ private client?;
12
+ constructor(browserFetchEvents: FetchRequestPausedEventHandler[], customerConfig: CustomerConfig, cli: CliService, client?: ConfigApiService);
13
+ handleRequestFetchEvents(target: Target): Promise<void>;
14
+ private canHandlePattern;
15
+ private onFetchRequestPaused;
16
+ getAuthPattern(): Protocol.Fetch.RequestPattern[];
17
+ private onFetchAuthRequired;
18
+ sendDefaultAuthBehaviour(browserClient: CDPSession, requestId: string): Promise<void>;
19
+ }
@@ -0,0 +1,155 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FetchEventHandler = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const puppeteer_core_1 = require("puppeteer-core");
6
+ const abort_response_1 = require("./browser/abort-response");
7
+ const cli_1 = require("../cli");
8
+ const login_error_1 = tslib_1.__importDefault(require("../config-api/error/login-error"));
9
+ const safe_1 = require("../../helpers/safe");
10
+ class FetchEventHandler {
11
+ browserFetchEvents;
12
+ customerConfig;
13
+ cli;
14
+ client;
15
+ constructor(browserFetchEvents, customerConfig, cli, client) {
16
+ this.browserFetchEvents = browserFetchEvents;
17
+ this.customerConfig = customerConfig;
18
+ this.cli = cli;
19
+ this.client = client;
20
+ }
21
+ async handleRequestFetchEvents(target) {
22
+ const browserClient = await target.createCDPSession();
23
+ await browserClient.send('Fetch.enable', {
24
+ handleAuthRequests: true,
25
+ //see: https://chromedevtools.github.io/devtools-protocol/tot/Fetch#type-RequestPattern
26
+ patterns: this.browserFetchEvents.flatMap(handler => {
27
+ return handler.patterns;
28
+ }).concat(this.getAuthPattern()),
29
+ });
30
+ browserClient.on('Fetch.authRequired', async (event) => {
31
+ const response = await (0, safe_1.safe)(this.onFetchAuthRequired(event, browserClient));
32
+ if (response.success === true) {
33
+ return response.data;
34
+ }
35
+ this.cli.writeError(response.error);
36
+ });
37
+ browserClient.on('Fetch.requestPaused', async (event) => {
38
+ const response = await (0, safe_1.safe)(this.onFetchRequestPaused(event, browserClient));
39
+ if (response.success === true) {
40
+ return;
41
+ }
42
+ if (response.errorObj) {
43
+ this.cli.writeError(`error on ${event.request.url}`);
44
+ this.cli.writeError(`${response.errorObj.message}`);
45
+ return;
46
+ }
47
+ this.cli.writeError(`error on ${target.url()}`);
48
+ this.cli.writeError(JSON.stringify(response.errorObj));
49
+ });
50
+ }
51
+ canHandlePattern(fetchEventHandler, url, resourceType, requestStage) {
52
+ return fetchEventHandler.patterns.some(pattern => {
53
+ if (!(new RegExp(pattern.urlPattern).test(url))) {
54
+ return false;
55
+ }
56
+ if (pattern.requestStage !== requestStage) {
57
+ return false;
58
+ }
59
+ return !pattern.resourceType || pattern.resourceType === resourceType;
60
+ });
61
+ }
62
+ async onFetchRequestPaused(event, browserClient) {
63
+ const requestId = event.requestId;
64
+ for (const fetchEvent of this.browserFetchEvents) {
65
+ // check if current request could be handled
66
+ if (!this.canHandlePattern(fetchEvent, event.request.url, event.resourceType, event.responseHeaders ? 'Response' : 'Request')) {
67
+ continue;
68
+ }
69
+ const response = await fetchEvent.handle(event, browserClient);
70
+ if (!response) {
71
+ continue;
72
+ }
73
+ if (response instanceof abort_response_1.AbortResponse) {
74
+ await browserClient.send('Fetch.failRequest', { requestId: requestId, errorReason: response.errorReason });
75
+ return;
76
+ }
77
+ await browserClient.send('Fetch.fulfillRequest', {
78
+ ...response,
79
+ requestId,
80
+ });
81
+ return;
82
+ }
83
+ //see: https://chromedevtools.github.io/devtools-protocol/tot/Fetch#method-continueRequest
84
+ await browserClient.send('Fetch.continueRequest', {
85
+ requestId: requestId,
86
+ });
87
+ }
88
+ getAuthPattern() {
89
+ let result = [];
90
+ for (const origin of this.customerConfig.origins) {
91
+ const pattern = [
92
+ {
93
+ urlPattern: `${origin}*`,
94
+ requestStage: "Request"
95
+ }
96
+ ];
97
+ result.push(...pattern);
98
+ }
99
+ return result;
100
+ }
101
+ async onFetchAuthRequired(event, browserClient) {
102
+ this.cli.writeWarning(`auth requested for ${event.request.url}`);
103
+ if (!this.customerConfig.origins.some((origin) => { return event.request.url.includes(origin); }) || !this.client) {
104
+ this.cli.writeWarning(`incorrect origin for auth request: -> ${this.customerConfig.origins.join("|")}`);
105
+ return { response: "Default" };
106
+ }
107
+ this.cli.startAction('wait for credentials from server-config');
108
+ const serverConfigResponse = await (0, safe_1.safe)(this.client.getServerConfig());
109
+ if (serverConfigResponse.success === true) {
110
+ const config = JSON.parse(serverConfigResponse.data);
111
+ const authUrlOrigin = new URL(event.request.url).origin;
112
+ for (const auth of config.speedKit.authentications) {
113
+ if (auth.uri.includes(authUrlOrigin) && auth.type === event.authChallenge.scheme) {
114
+ await browserClient.send('Fetch.continueWithAuth', {
115
+ requestId: event.requestId,
116
+ authChallengeResponse: {
117
+ response: "ProvideCredentials",
118
+ username: auth.user,
119
+ password: auth.password
120
+ }
121
+ });
122
+ this.cli.endAction(cli_1.CliActionStatus.COMPLETED);
123
+ this.cli.writeSuccess(`auth provided for ${event.request.url}`);
124
+ await this.sendDefaultAuthBehaviour(browserClient, event.requestId);
125
+ return;
126
+ }
127
+ }
128
+ this.cli.endAction(cli_1.CliActionStatus.FAILED);
129
+ this.cli.writeError(`error providing auth: no credentials found in runtimeConfig of app ${this.customerConfig.app}`);
130
+ await this.sendDefaultAuthBehaviour(browserClient, event.requestId);
131
+ return;
132
+ }
133
+ this.cli.endAction(cli_1.CliActionStatus.FAILED);
134
+ if (serverConfigResponse.errorObj instanceof puppeteer_core_1.ProtocolError) {
135
+ // unknown raceCondition where the authResponse is sent to fast
136
+ return;
137
+ }
138
+ if (serverConfigResponse.errorObj instanceof login_error_1.default) {
139
+ this.cli.writeError(`could not login to app ${serverConfigResponse.errorObj.app} to gather credentials. Try run sk login`);
140
+ await this.sendDefaultAuthBehaviour(browserClient, event.requestId);
141
+ return;
142
+ }
143
+ this.cli.writeError(`error providing auth: ${JSON.stringify(serverConfigResponse.errorObj)}`);
144
+ await this.sendDefaultAuthBehaviour(browserClient, event.requestId);
145
+ }
146
+ async sendDefaultAuthBehaviour(browserClient, requestId) {
147
+ await browserClient.send('Fetch.continueWithAuth', {
148
+ requestId,
149
+ authChallengeResponse: {
150
+ response: "Default"
151
+ }
152
+ });
153
+ }
154
+ }
155
+ exports.FetchEventHandler = FetchEventHandler;
@@ -0,0 +1,24 @@
1
+ import Protocol from 'devtools-protocol';
2
+ import { FetchRequestPausedEventHandler } from "../onboarding-model";
3
+ import CustomerConfig from "../../integration-api/struct/customer-config";
4
+ import { CDPSession } from "puppeteer";
5
+ import { ConfigFileInterface } from "../../integration-api/integration-api-model";
6
+ /**
7
+ * Intercepts any request to the customersOrigin and equivalent requests to baqendAssetApi
8
+ * @implements {FetchRequestPausedEventHandler}
9
+ */
10
+ export declare class CustomerDomainDocumentResponse implements FetchRequestPausedEventHandler {
11
+ private customerConfig;
12
+ private configDynamicBlock;
13
+ private configDynamicStyles;
14
+ get patterns(): Protocol.Fetch.RequestPattern[];
15
+ constructor(customerConfig: CustomerConfig, configDynamicBlock: ConfigFileInterface, configDynamicStyles: ConfigFileInterface);
16
+ handle(event: Protocol.Fetch.RequestPausedEvent, client: CDPSession): Promise<Partial<Protocol.Fetch.FulfillRequestRequest> | void>;
17
+ private isValidHtmlContent;
18
+ private isValidResponse;
19
+ private isHtmlContentHeader;
20
+ private getHtmlContent;
21
+ private isSpeedKitResponse;
22
+ private rewriteInstallResource;
23
+ private rewriteHtmlToLocalConfig;
24
+ }
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CustomerDomainDocumentResponse = void 0;
4
+ const origin_response_1 = require("../browser/origin-response");
5
+ /**
6
+ * Intercepts any request to the customersOrigin and equivalent requests to baqendAssetApi
7
+ * @implements {FetchRequestPausedEventHandler}
8
+ */
9
+ class CustomerDomainDocumentResponse {
10
+ customerConfig;
11
+ configDynamicBlock;
12
+ configDynamicStyles;
13
+ get patterns() {
14
+ let result = [];
15
+ for (const origin of this.customerConfig.origins) {
16
+ const pattern = [
17
+ {
18
+ urlPattern: `${origin}*`,
19
+ resourceType: 'Document',
20
+ requestStage: "Response"
21
+ },
22
+ {
23
+ urlPattern: `${origin}*`,
24
+ resourceType: 'Fetch',
25
+ requestStage: "Response"
26
+ },
27
+ {
28
+ urlPattern: `${origin}*`,
29
+ resourceType: 'XHR',
30
+ requestStage: "Response"
31
+ },
32
+ {
33
+ urlPattern: `https://${this.customerConfig.appDomain}/v1/asset/${origin}*`,
34
+ resourceType: 'Fetch',
35
+ requestStage: "Response"
36
+ },
37
+ {
38
+ urlPattern: `https://${this.customerConfig.appDomain}/v1/asset/${origin}*`,
39
+ resourceType: "XHR",
40
+ requestStage: "Response"
41
+ }
42
+ ];
43
+ result.push(...pattern);
44
+ }
45
+ return result;
46
+ }
47
+ constructor(customerConfig, configDynamicBlock, configDynamicStyles) {
48
+ this.customerConfig = customerConfig;
49
+ this.configDynamicBlock = configDynamicBlock;
50
+ this.configDynamicStyles = configDynamicStyles;
51
+ }
52
+ async handle(event, client) {
53
+ if (!this.isValidResponse(event)) {
54
+ return;
55
+ }
56
+ if (!this.isHtmlContentHeader(event.responseHeaders)) {
57
+ return;
58
+ }
59
+ let text = await this.getHtmlContent(client, event);
60
+ if (!this.isValidHtmlContent(text)) {
61
+ return;
62
+ }
63
+ if (this.customerConfig.forceInstall) {
64
+ text = this.rewriteInstallResource(text);
65
+ }
66
+ if (this.isSpeedKitResponse(text)) {
67
+ text = this.rewriteHtmlToLocalConfig(text);
68
+ }
69
+ return new origin_response_1.OriginResponse(text, event.responseHeaders, event.responseStatusCode);
70
+ }
71
+ isValidHtmlContent(text) {
72
+ return text.includes('<html');
73
+ }
74
+ isValidResponse(event) {
75
+ return event.responseHeaders &&
76
+ event.responseStatusCode &&
77
+ event.responseStatusCode > 199 &&
78
+ event.responseStatusCode < 300;
79
+ }
80
+ isHtmlContentHeader(responseHeaders) {
81
+ const contentType = responseHeaders.filter(headerRecord => {
82
+ return headerRecord.name.toLowerCase() === 'content-type';
83
+ })?.[0]?.['value'];
84
+ return contentType && contentType.includes('text/html');
85
+ }
86
+ async getHtmlContent(client, event) {
87
+ const contentType = event.responseHeaders.filter(headerRecord => {
88
+ return headerRecord.name.toLowerCase() === 'content-type';
89
+ })?.[0]?.['value'] || '';
90
+ const charset = contentType.split('charset=')?.[1];
91
+ const { body, base64Encoded } = await client.send('Fetch.getResponseBody', { requestId: event.requestId });
92
+ if (base64Encoded) {
93
+ // todo get encodingHeader for target encoding
94
+ return Buffer.from(body, 'base64').toString(charset || 'utf-8');
95
+ }
96
+ return body;
97
+ }
98
+ isSpeedKitResponse(text) {
99
+ return text.includes('speed-kit-dynamic');
100
+ }
101
+ rewriteInstallResource(text) {
102
+ text = text.replace(/<script(?:.(?!<\/script>))*app\.baqend\.com\/v1\/speedkit\/install.js(?:.|(?!<\/script>))*<\/script>/, '');
103
+ return text.replace(/<\s*head\b[^>]*>/, (head) => {
104
+ return `${head}\n<script src="${this.customerConfig.installPath}" ${this.customerConfig.installParams}></script>`;
105
+ });
106
+ }
107
+ rewriteHtmlToLocalConfig(html) {
108
+ const DF_CONFIG_PATTERN = /(<script[^>]* id="speed-kit-df-config"[^>]*>)([\s\S]*?)(<\/script>)/g;
109
+ const DF_STYLES_PATTERN = /(<style[^>]* id="speed-kit-df-styles"[^>]*>)(?:(?!<\/style>)[\s\S])*(<\/style>)/g;
110
+ html = html.replace(DF_CONFIG_PATTERN, (_, tag, body, end) => {
111
+ const injectedConfig = body.match(/window\.dynamicBlockConfig\.appName\s=.*$/s) ?? [''];
112
+ return `${tag}${this.configDynamicBlock.getContent()}${injectedConfig[0]}${end}`;
113
+ });
114
+ html = html.replace(DF_STYLES_PATTERN, (_, tag, end) => `${tag}${this.configDynamicStyles.getContent()}${end}`);
115
+ return html;
116
+ }
117
+ }
118
+ exports.CustomerDomainDocumentResponse = CustomerDomainDocumentResponse;
@@ -0,0 +1,14 @@
1
+ import Protocol from 'devtools-protocol';
2
+ import { FetchRequestPausedEventHandler } from "../onboarding-model";
3
+ import CustomerConfig from "../../integration-api/struct/customer-config";
4
+ /**
5
+ * Intercepts request to /wrapper-sw.js
6
+ *
7
+ * @implements {FetchRequestPausedEventHandler}
8
+ */
9
+ export declare class CustomerServiceWorkerJs implements FetchRequestPausedEventHandler {
10
+ private customerConfig;
11
+ get patterns(): Protocol.Fetch.RequestPattern[];
12
+ constructor(customerConfig: CustomerConfig);
13
+ handle(): Promise<Partial<Protocol.Fetch.FulfillRequestRequest>>;
14
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CustomerServiceWorkerJs = void 0;
4
+ const baqend_response_1 = require("../browser/baqend-response");
5
+ /**
6
+ * Intercepts request to /wrapper-sw.js
7
+ *
8
+ * @implements {FetchRequestPausedEventHandler}
9
+ */
10
+ class CustomerServiceWorkerJs {
11
+ customerConfig;
12
+ get patterns() {
13
+ let result = [];
14
+ for (const origin of this.customerConfig.origins) {
15
+ result.push({
16
+ urlPattern: `${origin}${this.customerConfig.swPath}*`,
17
+ requestStage: "Request"
18
+ });
19
+ }
20
+ return result;
21
+ }
22
+ constructor(customerConfig) {
23
+ this.customerConfig = customerConfig;
24
+ }
25
+ async handle() {
26
+ const wrapperSwCode = `importScripts(\`https://${this.customerConfig.appDomain}/v1/speedkit/sw.js\${location.search}\`); // skonboarding`;
27
+ return new baqend_response_1.BaqendResponse(wrapperSwCode, 'text/javascript; charset=utf-8');
28
+ }
29
+ }
30
+ exports.CustomerServiceWorkerJs = CustomerServiceWorkerJs;
@@ -0,0 +1,15 @@
1
+ import Protocol from 'devtools-protocol';
2
+ import { FetchRequestPausedEventHandler } from "../onboarding-model";
3
+ import { Dashboard } from "../dashboard";
4
+ /**
5
+ * The DashboardRequest class represents a request handler for the dashboard.
6
+ * Handle all the requests on the secondTab(http://skonboarding.local)
7
+ *
8
+ * @implements {FetchRequestPausedEventHandler}
9
+ */
10
+ export declare class DashboardRequest implements FetchRequestPausedEventHandler {
11
+ private dashboard;
12
+ readonly patterns: Protocol.Fetch.RequestPattern[];
13
+ constructor(dashboard: Dashboard);
14
+ handle(event: Protocol.Fetch.RequestPausedEvent): Promise<Partial<Protocol.Fetch.FulfillRequestRequest>>;
15
+ }
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DashboardRequest = void 0;
4
+ /**
5
+ * The DashboardRequest class represents a request handler for the dashboard.
6
+ * Handle all the requests on the secondTab(http://skonboarding.local)
7
+ *
8
+ * @implements {FetchRequestPausedEventHandler}
9
+ */
10
+ class DashboardRequest {
11
+ dashboard;
12
+ patterns = [
13
+ {
14
+ urlPattern: `http://skonboarding.local*`,
15
+ requestStage: "Request"
16
+ },
17
+ {
18
+ urlPattern: `https://skonboarding.local*`,
19
+ requestStage: "Request"
20
+ },
21
+ ];
22
+ constructor(dashboard) {
23
+ this.dashboard = dashboard;
24
+ }
25
+ async handle(event) {
26
+ return await this.dashboard.getResponse(event.request);
27
+ }
28
+ }
29
+ exports.DashboardRequest = DashboardRequest;
@@ -0,0 +1,26 @@
1
+ import Protocol from "devtools-protocol";
2
+ import { FetchRequestPausedEventHandler } from "../onboarding-model";
3
+ import CustomerConfig from "../../integration-api/struct/customer-config";
4
+ import { DocumentHandlerServer } from "../../document-handler-runtime/document-handler-server";
5
+ import { AbortResponse } from "../browser/abort-response";
6
+ import { Cache } from "../request-cache/cache";
7
+ import { CliService } from "../../cli";
8
+ /**
9
+ * Handles fetch requests for Speed Kit assets and returns customized responses.
10
+ */
11
+ export declare class SpeedKitAssetRequest implements FetchRequestPausedEventHandler {
12
+ private customerConfig;
13
+ private documentHandler;
14
+ private cache;
15
+ private cli;
16
+ get patterns(): Protocol.Fetch.RequestPattern[];
17
+ constructor(customerConfig: CustomerConfig, documentHandler: DocumentHandlerServer, cache: Cache, cli: CliService);
18
+ handle(event: Protocol.Fetch.RequestPausedEvent): Promise<Partial<Protocol.Fetch.FulfillRequestRequest> | AbortResponse>;
19
+ private getCachedResponse;
20
+ private buildCustomHeaders;
21
+ private createResponseFromLocalDocumentHandler;
22
+ private getAssetUrl;
23
+ private isHtmlContentHeader;
24
+ private isValidHtmlContent;
25
+ private rewriteInstallResource;
26
+ }
@@ -0,0 +1,138 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SpeedKitAssetRequest = void 0;
4
+ const baqend_response_1 = require("../browser/baqend-response");
5
+ /**
6
+ * Handles fetch requests for Speed Kit assets and returns customized responses.
7
+ */
8
+ class SpeedKitAssetRequest {
9
+ customerConfig;
10
+ documentHandler;
11
+ cache;
12
+ cli;
13
+ get patterns() {
14
+ let result = [];
15
+ for (const origin of this.customerConfig.origins) {
16
+ const pattern = [
17
+ {
18
+ urlPattern: `https://${this.customerConfig.appDomain}/v1/asset/${origin}*`,
19
+ resourceType: 'Fetch',
20
+ requestStage: "Request"
21
+ },
22
+ {
23
+ urlPattern: `https://${this.customerConfig.appDomain}/v1/asset/${origin}*`,
24
+ resourceType: "XHR",
25
+ requestStage: "Request"
26
+ }
27
+ ];
28
+ result.push(...pattern);
29
+ }
30
+ return result;
31
+ }
32
+ constructor(customerConfig, documentHandler, cache, cli) {
33
+ this.customerConfig = customerConfig;
34
+ this.documentHandler = documentHandler;
35
+ this.cache = cache;
36
+ this.cli = cli;
37
+ }
38
+ async handle(event) {
39
+ const originUrl = this.getAssetUrl(event.request.url);
40
+ const UrlObject = new URL(event.request.url);
41
+ const variation = UrlObject.searchParams.has('bqvariation') ? UrlObject.searchParams.get('bqvariation') : 'DEFAULT';
42
+ const cachedResponse = this.getCachedResponse(event.request.url);
43
+ if (cachedResponse instanceof baqend_response_1.BaqendResponse) {
44
+ return cachedResponse;
45
+ }
46
+ const response = await fetch(originUrl, { headers: (event.request.headers) });
47
+ const customHeaders = this.buildCustomHeaders(originUrl);
48
+ if (response.headers.get('Content-Type').includes('image') || response.headers.get('Content-Type').includes('font')) {
49
+ return;
50
+ }
51
+ const responseContent = await response.text();
52
+ if (!this.isHtmlContentHeader(response.headers) || !this.isValidHtmlContent(responseContent)) {
53
+ const customResponse = new baqend_response_1.BaqendResponse(responseContent, response.headers.get('Content-Type') || null, customHeaders);
54
+ this.cache.addEntry(event.request.url, customResponse);
55
+ return customResponse;
56
+ }
57
+ try {
58
+ let customResponse = await this.createResponseFromLocalDocumentHandler(responseContent, variation, originUrl, event.request.headers);
59
+ customResponse = customResponse.replace('speed-kit-dynamic-load', 'skonboarding speed-kit-dynamic-load');
60
+ if (this.customerConfig.forceInstall) {
61
+ customResponse = this.rewriteInstallResource(customResponse);
62
+ }
63
+ const response = new baqend_response_1.BaqendResponse(customResponse, null, customHeaders);
64
+ this.cache.addEntry(event.request.url, response);
65
+ return response;
66
+ }
67
+ catch (error) {
68
+ let message = 'could not transform html';
69
+ if (error instanceof Error) {
70
+ message = error.message;
71
+ }
72
+ this.cli.writeError(message);
73
+ customHeaders.push({ name: 'x-error', value: message });
74
+ return new baqend_response_1.BaqendResponse(message, null, customHeaders, 500);
75
+ }
76
+ }
77
+ getCachedResponse(requestUrl) {
78
+ const response = this.cache.getEntry(requestUrl);
79
+ if (!(response instanceof baqend_response_1.BaqendResponse)) {
80
+ return;
81
+ }
82
+ response.setHeader('x-cache', 'POP, HIT');
83
+ response.setHeader('x-served-by', 'cache-local');
84
+ response.setHeader('server-timing', 'pop;desc=LOCAL;dur=1,cache;desc=CACHE,hotness;desc=1,proto;desc=h3');
85
+ return response;
86
+ }
87
+ buildCustomHeaders(originUrl) {
88
+ const time = new Date().toUTCString();
89
+ const originDomain = new URL(originUrl).origin;
90
+ return [
91
+ { name: 'origin', value: originDomain },
92
+ { name: 'Access-Control-Allow-Credentials', value: 'true' },
93
+ {
94
+ name: 'Access-Control-Expose-Headers',
95
+ value: 'Location, ETag, Baqend-Authorization-Token, Baqend-Acl, Baqend-Size, Baqend-SW-Control, Baqend-Created-At, Date, Age, Baqend-Speed-Kit, Baqend-Custom-Headers, X-Served-By, X-Cache, X-Timer, Access-Control-Allow-Origin, Fastly-Io-Info, Server-Timing'
96
+ },
97
+ { name: 'strict-transport-security', value: 'max-age=31536000; includeSubDomains' },
98
+ { name: 'timing-allow-origin', value: originDomain },
99
+ { name: 'Cache-Control', value: 'public,browser-ttl=0,sw-max-age=31536000,max-age=31469674' },
100
+ { name: 'server-timing', value: 'pop;desc=LOCAL;dur=1,cache;desc=STREAM,hotness;desc=1,proto;desc=h3' },
101
+ { name: 'Alt-Svc', value: 'h3=":443";ma=86400,h3-29=":443";ma=86400,h3-27=":443";ma=86400' },
102
+ { name: 'x-frame-options', value: 'SAMEORIGIN' },
103
+ { name: 'x-cache', value: 'STREAM, HIT' },
104
+ { name: 'x-cache-hits', value: '1' },
105
+ { name: 'x-served-by', value: 'stream-local' },
106
+ { name: 'Date', value: time },
107
+ { name: 'last-modified', value: time },
108
+ { name: 'Baqend-Created-At', value: time },
109
+ { name: 'Age', value: '0' },
110
+ ];
111
+ }
112
+ async createResponseFromLocalDocumentHandler(html, variation, url, headers) {
113
+ return this.documentHandler.transform(html, variation, url, headers);
114
+ }
115
+ getAssetUrl(requestUrl) {
116
+ const url = new URL(requestUrl);
117
+ url.searchParams.forEach((value, name, searchParams) => {
118
+ if (name.startsWith("bq") || name === "bqsk") {
119
+ searchParams.delete(name);
120
+ }
121
+ });
122
+ const cleanedUrl = url.toString();
123
+ return cleanedUrl.split("app.baqend.com/v1/asset/")[1];
124
+ }
125
+ isHtmlContentHeader(responseHeaders) {
126
+ return responseHeaders.has('content-type') && responseHeaders.get('content-type').includes('text/html');
127
+ }
128
+ isValidHtmlContent(text) {
129
+ return text.includes('<html');
130
+ }
131
+ rewriteInstallResource(text) {
132
+ text = text.replace(/<script(?:.(?!<\/script>))*app\.baqend\.com\/v1\/speedkit\/install.js(?:.|(?!<\/script>))*<\/script>/, '');
133
+ return text.replace(/<\s*head\b[^>]*>/, (head) => {
134
+ return `${head}\n<script src="${this.customerConfig.installPath}" ${this.customerConfig.installParams}></script>`;
135
+ });
136
+ }
137
+ }
138
+ exports.SpeedKitAssetRequest = SpeedKitAssetRequest;
@@ -0,0 +1,15 @@
1
+ import Protocol from 'devtools-protocol';
2
+ import { BrowserContext, FetchRequestPausedEventHandler } from "../onboarding-model";
3
+ import CustomerConfig from "../../integration-api/struct/customer-config";
4
+ import { InstallSpeedKitHtmlTemplate } from "../templates/install-speed-kit-html-template";
5
+ /**
6
+ * Represents a class that handles the installation of Speed Kit HTML.
7
+ */
8
+ export declare class SpeedKitInstallHtml implements FetchRequestPausedEventHandler {
9
+ private customerConfig;
10
+ private browserContext;
11
+ private speedKitInstallHtmlTemplate;
12
+ get patterns(): Protocol.Fetch.RequestPattern[];
13
+ constructor(customerConfig: CustomerConfig, browserContext: BrowserContext, speedKitInstallHtmlTemplate: InstallSpeedKitHtmlTemplate);
14
+ handle(): Promise<Partial<Protocol.Fetch.FulfillRequestRequest>>;
15
+ }