@speedkit/cli 4.50.5 → 4.51.0-run-control.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 (406) hide show
  1. package/README.md +1369 -10
  2. package/dist/base/run-control-command.d.ts +15 -0
  3. package/dist/base/run-control-command.js +20 -0
  4. package/dist/build-info.json +6 -0
  5. package/dist/commands/diff.d.ts +6 -1
  6. package/dist/commands/diff.js +9 -3
  7. package/dist/commands/onboarding/browser/click.d.ts +75 -0
  8. package/dist/commands/onboarding/browser/click.js +19 -0
  9. package/dist/commands/onboarding/browser/emulate.d.ts +93 -0
  10. package/dist/commands/onboarding/browser/emulate.js +23 -0
  11. package/dist/commands/onboarding/browser/navigate.d.ts +67 -0
  12. package/dist/commands/onboarding/browser/navigate.js +18 -0
  13. package/dist/commands/onboarding/browser/panel.d.ts +63 -0
  14. package/dist/commands/onboarding/browser/panel.js +12 -0
  15. package/dist/commands/onboarding/browser/reinstall-sw.d.ts +63 -0
  16. package/dist/commands/onboarding/browser/reinstall-sw.js +14 -0
  17. package/dist/commands/onboarding/browser/reset.d.ts +71 -0
  18. package/dist/commands/onboarding/browser/reset.js +18 -0
  19. package/dist/commands/onboarding/browser/screenshot.d.ts +77 -0
  20. package/dist/commands/onboarding/browser/screenshot.js +19 -0
  21. package/dist/commands/onboarding/browser/state.d.ts +63 -0
  22. package/dist/commands/onboarding/browser/state.js +12 -0
  23. package/dist/commands/onboarding/browser/tabs.d.ts +58 -0
  24. package/dist/commands/onboarding/browser/tabs.js +16 -0
  25. package/dist/commands/onboarding/cache/clear.d.ts +58 -0
  26. package/dist/commands/onboarding/cache/clear.js +12 -0
  27. package/dist/commands/onboarding/cache/errors.d.ts +58 -0
  28. package/dist/commands/onboarding/cache/errors.js +12 -0
  29. package/dist/commands/onboarding/cache/evict.d.ts +62 -0
  30. package/dist/commands/onboarding/cache/evict.js +15 -0
  31. package/dist/commands/onboarding/cache/get.d.ts +85 -0
  32. package/dist/commands/onboarding/cache/get.js +17 -0
  33. package/dist/commands/onboarding/cache/list.d.ts +58 -0
  34. package/dist/commands/onboarding/cache/list.js +15 -0
  35. package/dist/commands/onboarding/cache/prewarm.d.ts +73 -0
  36. package/dist/commands/onboarding/cache/prewarm.js +20 -0
  37. package/dist/commands/onboarding/cache/refresh.d.ts +62 -0
  38. package/dist/commands/onboarding/cache/refresh.js +18 -0
  39. package/dist/commands/onboarding/cdp.d.ts +81 -0
  40. package/dist/commands/onboarding/cdp.js +18 -0
  41. package/dist/commands/onboarding/debug/arm.d.ts +77 -0
  42. package/dist/commands/onboarding/debug/arm.js +18 -0
  43. package/dist/commands/onboarding/debug/await.d.ts +71 -0
  44. package/dist/commands/onboarding/debug/await.js +18 -0
  45. package/dist/commands/onboarding/debug/disarm.d.ts +63 -0
  46. package/dist/commands/onboarding/debug/disarm.js +12 -0
  47. package/dist/commands/onboarding/debug/eval.d.ts +75 -0
  48. package/dist/commands/onboarding/debug/eval.js +16 -0
  49. package/dist/commands/onboarding/debug/release.d.ts +63 -0
  50. package/dist/commands/onboarding/debug/release.js +12 -0
  51. package/dist/commands/onboarding/debug/resume.d.ts +63 -0
  52. package/dist/commands/onboarding/debug/resume.js +12 -0
  53. package/dist/commands/onboarding/debug/status.d.ts +63 -0
  54. package/dist/commands/onboarding/debug/status.js +12 -0
  55. package/dist/commands/onboarding/debug/step.d.ts +67 -0
  56. package/dist/commands/onboarding/debug/step.js +15 -0
  57. package/dist/commands/onboarding/files/list.d.ts +58 -0
  58. package/dist/commands/onboarding/files/list.js +12 -0
  59. package/dist/commands/onboarding/files/read.d.ts +73 -0
  60. package/dist/commands/onboarding/files/read.js +16 -0
  61. package/dist/commands/onboarding/files/rebuild.d.ts +63 -0
  62. package/dist/commands/onboarding/files/rebuild.js +18 -0
  63. package/dist/commands/onboarding/files/validate.d.ts +58 -0
  64. package/dist/commands/onboarding/files/validate.js +12 -0
  65. package/dist/commands/onboarding/fouc.d.ts +77 -0
  66. package/dist/commands/onboarding/fouc.js +16 -0
  67. package/dist/commands/onboarding/inject/add.d.ts +89 -0
  68. package/dist/commands/onboarding/inject/add.js +17 -0
  69. package/dist/commands/onboarding/inject/clear.d.ts +63 -0
  70. package/dist/commands/onboarding/inject/clear.js +12 -0
  71. package/dist/commands/onboarding/inject/list.d.ts +63 -0
  72. package/dist/commands/onboarding/inject/list.js +12 -0
  73. package/dist/commands/onboarding/inject/read.d.ts +75 -0
  74. package/dist/commands/onboarding/inject/read.js +18 -0
  75. package/dist/commands/onboarding/inject/recipes.d.ts +63 -0
  76. package/dist/commands/onboarding/inject/recipes.js +12 -0
  77. package/dist/commands/onboarding/inject/remove.d.ts +67 -0
  78. package/dist/commands/onboarding/inject/remove.js +15 -0
  79. package/dist/commands/onboarding/list.d.ts +13 -0
  80. package/dist/commands/onboarding/list.js +12 -0
  81. package/dist/commands/onboarding/logs.d.ts +41 -0
  82. package/dist/commands/onboarding/logs.js +256 -0
  83. package/dist/commands/onboarding/navwalk.d.ts +95 -0
  84. package/dist/commands/onboarding/navwalk.js +19 -0
  85. package/dist/commands/onboarding/response.d.ts +67 -0
  86. package/dist/commands/onboarding/response.js +18 -0
  87. package/dist/commands/onboarding/rum/beacons.d.ts +75 -0
  88. package/dist/commands/onboarding/rum/beacons.js +16 -0
  89. package/dist/commands/onboarding/rum/get.d.ts +77 -0
  90. package/dist/commands/onboarding/rum/get.js +18 -0
  91. package/dist/commands/onboarding/rum/key.d.ts +67 -0
  92. package/dist/commands/onboarding/rum/key.js +13 -0
  93. package/dist/commands/onboarding/rum/previous.d.ts +63 -0
  94. package/dist/commands/onboarding/rum/previous.js +12 -0
  95. package/dist/commands/onboarding/status.d.ts +13 -0
  96. package/dist/commands/onboarding/status.js +17 -0
  97. package/dist/commands/onboarding/todo.d.ts +58 -0
  98. package/dist/commands/onboarding/todo.js +12 -0
  99. package/dist/commands/onboarding/viewport.d.ts +101 -0
  100. package/dist/commands/onboarding/viewport.js +18 -0
  101. package/dist/commands/onboarding/watch.d.ts +93 -0
  102. package/dist/commands/onboarding/watch.js +16 -0
  103. package/dist/commands/onboarding.d.ts +26 -0
  104. package/dist/commands/onboarding.js +220 -3
  105. package/dist/commands/origin-request.d.ts +4 -0
  106. package/dist/commands/origin-request.js +4 -0
  107. package/dist/commands/spec/onboarding.spec.d.ts +1 -0
  108. package/dist/commands/spec/onboarding.spec.js +127 -0
  109. package/dist/services/cli/build-info.d.ts +33 -0
  110. package/dist/services/cli/build-info.js +63 -0
  111. package/dist/services/cli/cli-environment-factory.d.ts +3 -0
  112. package/dist/services/cli/cli-environment-factory.js +1 -0
  113. package/dist/services/cli/cli-service-build-context.d.ts +3 -0
  114. package/dist/services/cli/cli-service-factory.js +1 -1
  115. package/dist/services/cli/cli-service-model.d.ts +29 -10
  116. package/dist/services/cli/cli-service.d.ts +60 -11
  117. package/dist/services/cli/cli-service.js +196 -32
  118. package/dist/services/cli/index.d.ts +2 -0
  119. package/dist/services/cli/index.js +2 -0
  120. package/dist/services/cli/sink.d.ts +47 -0
  121. package/dist/services/cli/sink.js +31 -0
  122. package/dist/services/cli/spec/build-identity.spec.d.ts +1 -0
  123. package/dist/services/cli/spec/build-identity.spec.js +85 -0
  124. package/dist/services/cli/spec/build-info.spec.d.ts +1 -0
  125. package/dist/services/cli/spec/build-info.spec.js +10 -0
  126. package/dist/services/cli/spec/cli-service-log.spec.d.ts +1 -0
  127. package/dist/services/cli/spec/cli-service-log.spec.js +133 -0
  128. package/dist/services/cli/spec/cli-service.spec.js +113 -50
  129. package/dist/services/cli/spec/memory-cli.d.ts +9 -0
  130. package/dist/services/cli/spec/memory-cli.js +9 -0
  131. package/dist/services/diff/config-at-ref.d.ts +20 -0
  132. package/dist/services/diff/config-at-ref.js +33 -0
  133. package/dist/services/diff/diff-service-build-context.d.ts +8 -0
  134. package/dist/services/diff/diff-service-build-context.js +40 -1
  135. package/dist/services/diff/diff-service-factory.d.ts +2 -0
  136. package/dist/services/diff/diff-service-factory.js +48 -20
  137. package/dist/services/diff/diff-service.d.ts +11 -0
  138. package/dist/services/diff/diff-service.js +37 -11
  139. package/dist/services/diff/page-source.d.ts +12 -0
  140. package/dist/services/diff/page-source.js +16 -11
  141. package/dist/services/diff/sinks/tool-diff-sink.d.ts +3 -2
  142. package/dist/services/diff/sinks/tool-diff-sink.js +3 -2
  143. package/dist/services/diff/spec/config-at-ref.spec.d.ts +1 -0
  144. package/dist/services/diff/spec/config-at-ref.spec.js +46 -0
  145. package/dist/services/diff/spec/diff-service-build-context.spec.js +19 -0
  146. package/dist/services/diff/spec/diff-service.spec.js +95 -0
  147. package/dist/services/git/git-repository.d.ts +2 -0
  148. package/dist/services/git/git-repository.js +6 -0
  149. package/dist/services/integration-api/customer-config-flags.js +1 -0
  150. package/dist/services/onboarding/browser/baqend-response.d.ts +17 -1
  151. package/dist/services/onboarding/browser/baqend-response.js +23 -0
  152. package/dist/services/onboarding/browser/console-log.d.ts +9 -0
  153. package/dist/services/onboarding/browser/console-log.js +27 -0
  154. package/dist/services/onboarding/browser/executable/executable-validator.js +4 -2
  155. package/dist/services/onboarding/browser/extension/extension-bridge.js +5 -3
  156. package/dist/services/onboarding/browser/extension/extension-downloader.js +17 -8
  157. package/dist/services/onboarding/browser/extension/extension-validator.js +9 -4
  158. package/dist/services/onboarding/control/body-inspect.d.ts +24 -0
  159. package/dist/services/onboarding/control/body-inspect.js +106 -0
  160. package/dist/services/onboarding/control/browser-session.d.ts +521 -0
  161. package/dist/services/onboarding/control/browser-session.js +1273 -0
  162. package/dist/services/onboarding/control/config-validation.d.ts +17 -0
  163. package/dist/services/onboarding/control/config-validation.js +46 -0
  164. package/dist/services/onboarding/control/control-protocol.d.ts +1390 -0
  165. package/dist/services/onboarding/control/control-protocol.js +69 -0
  166. package/dist/services/onboarding/control/control-server.d.ts +284 -0
  167. package/dist/services/onboarding/control/control-server.js +1609 -0
  168. package/dist/services/onboarding/control/debug-session.d.ts +190 -0
  169. package/dist/services/onboarding/control/debug-session.js +801 -0
  170. package/dist/services/onboarding/control/fouc.d.ts +23 -0
  171. package/dist/services/onboarding/control/fouc.js +151 -0
  172. package/dist/services/onboarding/control/index.d.ts +4 -0
  173. package/dist/services/onboarding/control/index.js +4 -0
  174. package/dist/services/onboarding/control/navwalk.d.ts +65 -0
  175. package/dist/services/onboarding/control/navwalk.js +248 -0
  176. package/dist/services/onboarding/control/preload-registry.d.ts +150 -0
  177. package/dist/services/onboarding/control/preload-registry.js +829 -0
  178. package/dist/services/onboarding/control/response-explainer.d.ts +24 -0
  179. package/dist/services/onboarding/control/response-explainer.js +257 -0
  180. package/dist/services/onboarding/control/rum.d.ts +8 -0
  181. package/dist/services/onboarding/control/rum.js +220 -0
  182. package/dist/services/onboarding/control/service-worker-tracker.d.ts +68 -0
  183. package/dist/services/onboarding/control/service-worker-tracker.js +119 -0
  184. package/dist/services/onboarding/control/viewport.d.ts +45 -0
  185. package/dist/services/onboarding/control/viewport.js +344 -0
  186. package/dist/services/onboarding/control/watch.d.ts +26 -0
  187. package/dist/services/onboarding/control/watch.js +149 -0
  188. package/dist/services/onboarding/dashboard/diff-against-current-page.js +3 -1
  189. package/dist/services/onboarding/dashboard/index.js +7 -2
  190. package/dist/services/onboarding/fetch-event-handler.d.ts +24 -5
  191. package/dist/services/onboarding/fetch-event-handler.js +94 -32
  192. package/dist/services/onboarding/fetch-events/speed-kit-install-js.js +11 -2
  193. package/dist/services/onboarding/fetch-events/speed-kit-rum-pi-request.d.ts +14 -0
  194. package/dist/services/onboarding/fetch-events/speed-kit-rum-pi-request.js +30 -0
  195. package/dist/services/onboarding/fetch-events/speed-kit-service-worker-js.d.ts +13 -0
  196. package/dist/services/onboarding/fetch-events/speed-kit-service-worker-js.js +28 -1
  197. package/dist/services/onboarding/file-events/file-watcher.d.ts +42 -1
  198. package/dist/services/onboarding/file-events/file-watcher.js +117 -12
  199. package/dist/services/onboarding/onboarding-model.d.ts +30 -0
  200. package/dist/services/onboarding/onboarding-model.js +10 -0
  201. package/dist/services/onboarding/onboarding-service-build-context.d.ts +4 -0
  202. package/dist/services/onboarding/onboarding-service-build-context.js +6 -0
  203. package/dist/services/onboarding/onboarding-service-factory.d.ts +17 -1
  204. package/dist/services/onboarding/onboarding-service-factory.js +131 -17
  205. package/dist/services/onboarding/onboarding-service.d.ts +40 -1
  206. package/dist/services/onboarding/onboarding-service.js +135 -22
  207. package/dist/services/onboarding/request-cache/asset-key.d.ts +61 -0
  208. package/dist/services/onboarding/request-cache/asset-key.js +115 -0
  209. package/dist/services/onboarding/request-cache/cache.d.ts +62 -5
  210. package/dist/services/onboarding/request-cache/cache.js +128 -17
  211. package/dist/services/onboarding/spec/browser/console-log.spec.d.ts +1 -0
  212. package/dist/services/onboarding/spec/browser/console-log.spec.js +42 -0
  213. package/dist/services/onboarding/spec/control/browser-session.spec.d.ts +1 -0
  214. package/dist/services/onboarding/spec/control/browser-session.spec.js +526 -0
  215. package/dist/services/onboarding/spec/control/control-server.spec.d.ts +1 -0
  216. package/dist/services/onboarding/spec/control/control-server.spec.js +338 -0
  217. package/dist/services/onboarding/spec/control/debug-session.spec.d.ts +1 -0
  218. package/dist/services/onboarding/spec/control/debug-session.spec.js +693 -0
  219. package/dist/services/onboarding/spec/control/fakes.d.ts +31 -0
  220. package/dist/services/onboarding/spec/control/fakes.js +66 -0
  221. package/dist/services/onboarding/spec/control/fouc.spec.d.ts +1 -0
  222. package/dist/services/onboarding/spec/control/fouc.spec.js +167 -0
  223. package/dist/services/onboarding/spec/control/navwalk.spec.d.ts +1 -0
  224. package/dist/services/onboarding/spec/control/navwalk.spec.js +222 -0
  225. package/dist/services/onboarding/spec/control/preload-registry.spec.d.ts +1 -0
  226. package/dist/services/onboarding/spec/control/preload-registry.spec.js +432 -0
  227. package/dist/services/onboarding/spec/control/response-explainer.spec.d.ts +1 -0
  228. package/dist/services/onboarding/spec/control/response-explainer.spec.js +324 -0
  229. package/dist/services/onboarding/spec/control/rum.spec.d.ts +1 -0
  230. package/dist/services/onboarding/spec/control/rum.spec.js +222 -0
  231. package/dist/services/onboarding/spec/control/service-worker-tracker.spec.d.ts +1 -0
  232. package/dist/services/onboarding/spec/control/service-worker-tracker.spec.js +193 -0
  233. package/dist/services/onboarding/spec/control/viewport.spec.d.ts +1 -0
  234. package/dist/services/onboarding/spec/control/viewport.spec.js +200 -0
  235. package/dist/services/onboarding/spec/control/watch.spec.d.ts +1 -0
  236. package/dist/services/onboarding/spec/control/watch.spec.js +172 -0
  237. package/dist/services/onboarding/spec/fetch-event-handler.spec.d.ts +1 -0
  238. package/dist/services/onboarding/spec/fetch-event-handler.spec.js +202 -0
  239. package/dist/services/onboarding/spec/fetch-events/speed-kit-service-worker-js.spec.d.ts +1 -0
  240. package/dist/services/onboarding/spec/fetch-events/speed-kit-service-worker-js.spec.js +41 -0
  241. package/dist/services/onboarding/spec/onboarding-model.spec.js +37 -0
  242. package/dist/services/onboarding/spec/onboarding-service-factory.spec.js +1 -0
  243. package/dist/services/onboarding/spec/request-cache/cache.spec.d.ts +1 -0
  244. package/dist/services/onboarding/spec/request-cache/cache.spec.js +107 -0
  245. package/dist/services/onboarding/spec/todo-collector.spec.d.ts +1 -0
  246. package/dist/services/onboarding/spec/todo-collector.spec.js +136 -0
  247. package/dist/services/onboarding/todo-collector.d.ts +7 -2
  248. package/dist/services/onboarding/todo-collector.js +49 -12
  249. package/dist/services/onboarding/virtual-orestes-app/index.d.ts +34 -0
  250. package/dist/services/onboarding/virtual-orestes-app/index.js +82 -27
  251. package/dist/services/origin-request/asset-variations.d.ts +14 -0
  252. package/dist/services/origin-request/asset-variations.js +11 -4
  253. package/dist/services/origin-request/origin-fetcher.d.ts +7 -0
  254. package/dist/services/origin-request/origin-fetcher.js +43 -5
  255. package/dist/services/origin-request/origin-request-service-build-context.d.ts +17 -0
  256. package/dist/services/origin-request/origin-request-service-build-context.js +8 -0
  257. package/dist/services/origin-request/origin-request-service-factory.d.ts +0 -5
  258. package/dist/services/origin-request/origin-request-service-factory.js +2 -30
  259. package/dist/services/origin-request/origin-request-service.d.ts +121 -6
  260. package/dist/services/origin-request/origin-request-service.js +273 -49
  261. package/dist/services/origin-request/runtime-config-source.js +9 -4
  262. package/dist/services/origin-request/spec/asset-variations.spec.js +20 -0
  263. package/dist/services/origin-request/spec/origin-request-service.spec.js +329 -6
  264. package/dist/services/query-builder/rules/rule-match.d.ts +35 -0
  265. package/dist/services/query-builder/rules/rule-match.js +70 -0
  266. package/dist/services/query-builder/spec/rules/rule-match.spec.d.ts +1 -0
  267. package/dist/services/query-builder/spec/rules/rule-match.spec.js +121 -0
  268. package/dist/services/run-control/browser/run-browser-contexts.d.ts +541 -0
  269. package/dist/services/run-control/browser/run-browser-contexts.js +78 -0
  270. package/dist/services/run-control/browser/run-browser-service-factory.d.ts +5 -0
  271. package/dist/services/run-control/browser/run-browser-service-factory.js +7 -0
  272. package/dist/services/run-control/browser/run-browser-service.d.ts +64 -0
  273. package/dist/services/run-control/browser/run-browser-service.js +199 -0
  274. package/dist/services/run-control/cache/run-cache-contexts.d.ts +349 -0
  275. package/dist/services/run-control/cache/run-cache-contexts.js +51 -0
  276. package/dist/services/run-control/cache/run-cache-service-factory.d.ts +6 -0
  277. package/dist/services/run-control/cache/run-cache-service-factory.js +12 -0
  278. package/dist/services/run-control/cache/run-cache-service.d.ts +35 -0
  279. package/dist/services/run-control/cache/run-cache-service.js +151 -0
  280. package/dist/services/run-control/control-client.d.ts +36 -0
  281. package/dist/services/run-control/control-client.js +147 -0
  282. package/dist/services/run-control/debug/run-debug-contexts.d.ts +411 -0
  283. package/dist/services/run-control/debug/run-debug-contexts.js +44 -0
  284. package/dist/services/run-control/debug/run-debug-service-factory.d.ts +5 -0
  285. package/dist/services/run-control/debug/run-debug-service-factory.js +7 -0
  286. package/dist/services/run-control/debug/run-debug-service.d.ts +38 -0
  287. package/dist/services/run-control/debug/run-debug-service.js +161 -0
  288. package/dist/services/run-control/files/run-files-contexts.d.ts +238 -0
  289. package/dist/services/run-control/files/run-files-contexts.js +26 -0
  290. package/dist/services/run-control/files/run-files-service-factory.d.ts +5 -0
  291. package/dist/services/run-control/files/run-files-service-factory.js +7 -0
  292. package/dist/services/run-control/files/run-files-service.d.ts +29 -0
  293. package/dist/services/run-control/files/run-files-service.js +120 -0
  294. package/dist/services/run-control/index.d.ts +32 -0
  295. package/dist/services/run-control/index.js +31 -0
  296. package/dist/services/run-control/inject/run-inject-contexts.d.ts +319 -0
  297. package/dist/services/run-control/inject/run-inject-contexts.js +32 -0
  298. package/dist/services/run-control/inject/run-inject-service-factory.d.ts +5 -0
  299. package/dist/services/run-control/inject/run-inject-service-factory.js +7 -0
  300. package/dist/services/run-control/inject/run-inject-service.d.ts +31 -0
  301. package/dist/services/run-control/inject/run-inject-service.js +203 -0
  302. package/dist/services/run-control/live-run.d.ts +37 -0
  303. package/dist/services/run-control/live-run.js +56 -0
  304. package/dist/services/run-control/probe/run-probe-contexts.d.ts +333 -0
  305. package/dist/services/run-control/probe/run-probe-contexts.js +73 -0
  306. package/dist/services/run-control/probe/run-probe-service-factory.d.ts +5 -0
  307. package/dist/services/run-control/probe/run-probe-service-factory.js +7 -0
  308. package/dist/services/run-control/probe/run-probe-service.d.ts +54 -0
  309. package/dist/services/run-control/probe/run-probe-service.js +193 -0
  310. package/dist/services/run-control/rum/run-rum-contexts.d.ts +216 -0
  311. package/dist/services/run-control/rum/run-rum-contexts.js +34 -0
  312. package/dist/services/run-control/rum/run-rum-service-factory.d.ts +5 -0
  313. package/dist/services/run-control/rum/run-rum-service-factory.js +7 -0
  314. package/dist/services/run-control/rum/run-rum-service.d.ts +36 -0
  315. package/dist/services/run-control/rum/run-rum-service.js +122 -0
  316. package/dist/services/run-control/run-answer.d.ts +28 -0
  317. package/dist/services/run-control/run-answer.js +58 -0
  318. package/dist/services/run-control/run-control-context.d.ts +102 -0
  319. package/dist/services/run-control/run-control-context.js +36 -0
  320. package/dist/services/run-control/run-control-flags.d.ts +12 -0
  321. package/dist/services/run-control/run-control-flags.js +22 -0
  322. package/dist/services/run-control/run-control-model.d.ts +9 -0
  323. package/dist/services/run-control/run-control-model.js +1 -0
  324. package/dist/services/run-control/run-control-service-factory.d.ts +14 -0
  325. package/dist/services/run-control/run-control-service-factory.js +26 -0
  326. package/dist/services/run-control/session/run-session-contexts.d.ts +25 -0
  327. package/dist/services/run-control/session/run-session-contexts.js +20 -0
  328. package/dist/services/run-control/session/run-session-service-factory.d.ts +8 -0
  329. package/dist/services/run-control/session/run-session-service-factory.js +18 -0
  330. package/dist/services/run-control/session/run-session-service.d.ts +25 -0
  331. package/dist/services/run-control/session/run-session-service.js +95 -0
  332. package/dist/services/run-control/spec/browser/run-browser-service.spec.d.ts +1 -0
  333. package/dist/services/run-control/spec/browser/run-browser-service.spec.js +327 -0
  334. package/dist/services/run-control/spec/cache/run-cache-service.spec.d.ts +1 -0
  335. package/dist/services/run-control/spec/cache/run-cache-service.spec.js +454 -0
  336. package/dist/services/run-control/spec/debug/run-debug-service.spec.d.ts +1 -0
  337. package/dist/services/run-control/spec/debug/run-debug-service.spec.js +113 -0
  338. package/dist/services/run-control/spec/files/run-files-service.spec.d.ts +1 -0
  339. package/dist/services/run-control/spec/files/run-files-service.spec.js +234 -0
  340. package/dist/services/run-control/spec/inject/run-inject-service.spec.d.ts +1 -0
  341. package/dist/services/run-control/spec/inject/run-inject-service.spec.js +224 -0
  342. package/dist/services/run-control/spec/live-run-fixture.d.ts +32 -0
  343. package/dist/services/run-control/spec/live-run-fixture.js +109 -0
  344. package/dist/services/run-control/spec/probe/run-probe-service.spec.d.ts +1 -0
  345. package/dist/services/run-control/spec/probe/run-probe-service.spec.js +108 -0
  346. package/dist/services/run-control/spec/rum/run-rum-service.spec.d.ts +1 -0
  347. package/dist/services/run-control/spec/rum/run-rum-service.spec.js +47 -0
  348. package/dist/services/run-control/spec/run-answer.spec.d.ts +1 -0
  349. package/dist/services/run-control/spec/run-answer.spec.js +57 -0
  350. package/dist/services/run-control/spec/session/run-session-service.spec.d.ts +1 -0
  351. package/dist/services/run-control/spec/session/run-session-service.spec.js +101 -0
  352. package/dist/services/run-log/crash-mirror.d.ts +31 -0
  353. package/dist/services/run-log/crash-mirror.js +69 -0
  354. package/dist/services/run-log/index.d.ts +11 -0
  355. package/dist/services/run-log/index.js +11 -0
  356. package/dist/services/run-log/jsonl-appender.d.ts +46 -0
  357. package/dist/services/run-log/jsonl-appender.js +91 -0
  358. package/dist/services/run-log/log-event-model.d.ts +104 -0
  359. package/dist/services/run-log/log-event-model.js +56 -0
  360. package/dist/services/run-log/log-query-service-factory.d.ts +11 -0
  361. package/dist/services/run-log/log-query-service-factory.js +14 -0
  362. package/dist/services/run-log/log-query-service.d.ts +59 -0
  363. package/dist/services/run-log/log-query-service.js +111 -0
  364. package/dist/services/run-log/log-reader.d.ts +84 -0
  365. package/dist/services/run-log/log-reader.js +180 -0
  366. package/dist/services/run-log/log-summary.d.ts +72 -0
  367. package/dist/services/run-log/log-summary.js +208 -0
  368. package/dist/services/run-log/redaction.d.ts +34 -0
  369. package/dist/services/run-log/redaction.js +124 -0
  370. package/dist/services/run-log/request-log.d.ts +80 -0
  371. package/dist/services/run-log/request-log.js +69 -0
  372. package/dist/services/run-log/request-summary.d.ts +76 -0
  373. package/dist/services/run-log/request-summary.js +0 -0
  374. package/dist/services/run-log/run-log.d.ts +61 -0
  375. package/dist/services/run-log/run-log.js +102 -0
  376. package/dist/services/run-log/spec/log-query-service.spec.d.ts +1 -0
  377. package/dist/services/run-log/spec/log-query-service.spec.js +197 -0
  378. package/dist/services/run-log/spec/log-reader.spec.d.ts +1 -0
  379. package/dist/services/run-log/spec/log-reader.spec.js +109 -0
  380. package/dist/services/run-log/spec/log-summary.spec.d.ts +1 -0
  381. package/dist/services/run-log/spec/log-summary.spec.js +153 -0
  382. package/dist/services/run-log/spec/redaction.spec.d.ts +1 -0
  383. package/dist/services/run-log/spec/redaction.spec.js +61 -0
  384. package/dist/services/run-log/spec/request-log.spec.d.ts +1 -0
  385. package/dist/services/run-log/spec/request-log.spec.js +101 -0
  386. package/dist/services/run-log/spec/request-summary.spec.d.ts +1 -0
  387. package/dist/services/run-log/spec/request-summary.spec.js +171 -0
  388. package/dist/services/run-log/spec/run-log.spec.d.ts +1 -0
  389. package/dist/services/run-log/spec/run-log.spec.js +122 -0
  390. package/dist/services/run-registry/exit-classification.d.ts +39 -0
  391. package/dist/services/run-registry/exit-classification.js +42 -0
  392. package/dist/services/run-registry/index.d.ts +3 -0
  393. package/dist/services/run-registry/index.js +3 -0
  394. package/dist/services/run-registry/process-identity.d.ts +28 -0
  395. package/dist/services/run-registry/process-identity.js +80 -0
  396. package/dist/services/run-registry/run-registry-model.d.ts +128 -0
  397. package/dist/services/run-registry/run-registry-model.js +16 -0
  398. package/dist/services/run-registry/run-registry.d.ts +150 -0
  399. package/dist/services/run-registry/run-registry.js +409 -0
  400. package/dist/services/run-registry/spec/exit-classification.spec.d.ts +1 -0
  401. package/dist/services/run-registry/spec/exit-classification.spec.js +82 -0
  402. package/dist/services/run-registry/spec/run-registry.spec.d.ts +1 -0
  403. package/dist/services/run-registry/spec/run-registry.spec.js +509 -0
  404. package/dist/services/setup/os/tool-registry.js +2 -2
  405. package/oclif.manifest.json +3293 -272
  406. package/package.json +20 -2
@@ -5,6 +5,7 @@ import { Cache } from "../request-cache/cache.js";
5
5
  import { CliServiceInterface } from "../../cli/index.js";
6
6
  import { OriginFetcher } from "../../origin-request/index.js";
7
7
  import { CustomerConfig } from "../../integration-api/index.js";
8
+ import { LocalCacheErrorEntry } from "../control/control-protocol.js";
8
9
  import { DevtoolsExtensionApi } from "../browser/extension/devtools-extension-api.js";
9
10
  export declare class VirtualOrestesApp {
10
11
  private customerConfig;
@@ -18,6 +19,26 @@ export declare class VirtualOrestesApp {
18
19
  private prerendererHintShown;
19
20
  constructor(customerConfig: CustomerConfig, originFetcher: OriginFetcher, documentHandler: DocumentHandlerServer, cache: Cache, cli: CliServiceInterface, developmentToolsMessages: DevtoolsExtensionApi, removeContentSecurityPolicy?: boolean);
20
21
  fetchAssetResponse(event: Protocol.Fetch.RequestPausedEvent): Promise<Partial<Protocol.Fetch.FulfillRequestRequest> | AbortResponse>;
22
+ /** The variations the runtime config names: see {@link OriginFetcher.namedVariations}. */
23
+ namedVariations(): string[];
24
+ /**
25
+ * Build and cache one variation of a url without the browser asking for it.
26
+ *
27
+ * The same path a real asset request takes — {@link buildResponse} fetches
28
+ * the origin with the variation's headers, runs the documentHandler over it
29
+ * and caches the result — with the request synthesised rather than
30
+ * intercepted. That is what makes a variation reachable at all: a browser is
31
+ * one device at a time, so mobile and desktop can never both be in the cache
32
+ * from browsing, and the comparison everyone wants to make is between exactly
33
+ * those two.
34
+ *
35
+ * Throws what the build threw. The caller is asking for one specific entry,
36
+ * so a failure is the answer to its question, not a background detail —
37
+ * unlike {@link refreshEntry}, which is fire-and-forget and logs instead.
38
+ *
39
+ * @returns the cache key the entry was stored under.
40
+ */
41
+ prewarm(originUrl: string, variation: string): Promise<string>;
21
42
  /**
22
43
  * Re-warm all cached entries for the given origin url in the background.
23
44
  *
@@ -49,6 +70,19 @@ export declare class VirtualOrestesApp {
49
70
  private refreshEntry;
50
71
  private buildResponse;
51
72
  private getResponseText;
73
+ /**
74
+ * The urls the local documentHandler could not build, as they stand now.
75
+ *
76
+ * Already collected for the devtools panel; this is the same list for a
77
+ * reader without one. State rather than history: an entry disappears once the
78
+ * same url and variation builds successfully, so an empty list means nothing
79
+ * is currently failing, not that nothing ever did.
80
+ *
81
+ * `occurredAt` is converted to ISO on the way out — the panel wants epoch
82
+ * milliseconds to sort by, a reader wants a timestamp it can compare against
83
+ * a log line.
84
+ */
85
+ getLocalCacheErrors(): LocalCacheErrorEntry[];
52
86
  private localCacheErrorKey;
53
87
  private recordLocalCacheError;
54
88
  private clearLocalCacheError;
@@ -1,3 +1,4 @@
1
+ import { assetOriginUrl, assetRequestUrl } from "../request-cache/asset-key.js";
1
2
  import { BaqendResponse } from "../browser/baqend-response.js";
2
3
  import { ABORT_SERVER_TIMING, ABORT_STATUS_CODE, isDocumentHandlerAbort, isLocalPrerendererUnreachable, LOCAL_PRERENDERER_PORT, prerenderFailure, } from "../../document-handler-runtime/document-handler-abort.js";
3
4
  import { isBlockedOriginStatus, ORIGIN_ERROR_STATUS_CODE, originErrorCauseName, originErrorCode, originErrorServerTiming, } from "../../origin-request/index.js";
@@ -51,6 +52,32 @@ export class VirtualOrestesApp {
51
52
  }
52
53
  return this.buildResponse(event.request.url);
53
54
  }
55
+ /** The variations the runtime config names: see {@link OriginFetcher.namedVariations}. */
56
+ namedVariations() {
57
+ return this.originFetcher.namedVariations();
58
+ }
59
+ /**
60
+ * Build and cache one variation of a url without the browser asking for it.
61
+ *
62
+ * The same path a real asset request takes — {@link buildResponse} fetches
63
+ * the origin with the variation's headers, runs the documentHandler over it
64
+ * and caches the result — with the request synthesised rather than
65
+ * intercepted. That is what makes a variation reachable at all: a browser is
66
+ * one device at a time, so mobile and desktop can never both be in the cache
67
+ * from browsing, and the comparison everyone wants to make is between exactly
68
+ * those two.
69
+ *
70
+ * Throws what the build threw. The caller is asking for one specific entry,
71
+ * so a failure is the answer to its question, not a background detail —
72
+ * unlike {@link refreshEntry}, which is fire-and-forget and logs instead.
73
+ *
74
+ * @returns the cache key the entry was stored under.
75
+ */
76
+ async prewarm(originUrl, variation) {
77
+ const requestUrl = assetRequestUrl(this.customerConfig.appDomain, originUrl, variation);
78
+ await this.buildResponse(requestUrl);
79
+ return requestUrl;
80
+ }
54
81
  /**
55
82
  * Re-warm all cached entries for the given origin url in the background.
56
83
  *
@@ -66,10 +93,13 @@ export class VirtualOrestesApp {
66
93
  .map(([key]) => key)
67
94
  .filter((key) => key.includes(originUrl));
68
95
  if (matchingKeys.length === 0) {
69
- this.cli.write(`changeDetection for url: ${originUrl} - nothing cached to refresh`);
96
+ this.cli.write(`changeDetection for url: ${originUrl} - nothing cached to refresh`, false, { scope: "cache", data: { url: originUrl, refreshed: 0 } });
70
97
  return;
71
98
  }
72
- this.cli.write(`changeDetection triggered for url: ${originUrl} - refreshing dh-cache in background`);
99
+ this.cli.write(`changeDetection triggered for url: ${originUrl} - refreshing dh-cache in background`, false, {
100
+ scope: "cache",
101
+ data: { url: originUrl, refreshed: matchingKeys.length },
102
+ });
73
103
  for (const key of matchingKeys) {
74
104
  await this.refreshEntry(key);
75
105
  }
@@ -91,7 +121,10 @@ export class VirtualOrestesApp {
91
121
  if (matchingKeys.length === 0) {
92
122
  return;
93
123
  }
94
- this.cli.write(`refreshing ${matchingKeys.length} dh-cache entries for current url ${currentUrl} in background`);
124
+ this.cli.write(`refreshing ${matchingKeys.length} dh-cache entries for current url ${currentUrl} in background`, false, {
125
+ scope: "cache",
126
+ data: { url: currentUrl, refreshed: matchingKeys.length },
127
+ });
95
128
  for (const key of matchingKeys) {
96
129
  await this.refreshEntry(key);
97
130
  }
@@ -107,7 +140,7 @@ export class VirtualOrestesApp {
107
140
  const result = await safe(this.buildResponse(requestUrl));
108
141
  if (result.success === false) {
109
142
  this.cache.removeEntry(requestUrl);
110
- this.cli.writeError(`failed to refresh dh-cache entry ${requestUrl}: ${result.error}`);
143
+ this.cli.writeError(`failed to refresh dh-cache entry ${requestUrl}: ${result.error}`, false, { scope: "cache", data: { url: requestUrl, error: result.error } });
111
144
  }
112
145
  }
113
146
  async buildResponse(requestUrl) {
@@ -145,7 +178,7 @@ export class VirtualOrestesApp {
145
178
  if (!this.isHtmlContentHeader(response?.headers) ||
146
179
  !this.isValidHtmlContent(responseContent)) {
147
180
  const customResponse = new BaqendResponse(responseContent, `text/html; charset=${textEncoding}`, customHeaders);
148
- this.cache.addEntry(requestUrl, customResponse);
181
+ this.cache.addEntry(requestUrl, customResponse, responseContent);
149
182
  return customResponse;
150
183
  }
151
184
  const customResponse = await safe(this.documentHandler.transform(`text/html;charset=${textEncoding}`, responseContent, variation, originUrl, this.convertResponseHeadersToOrestesFormat(response)));
@@ -183,16 +216,36 @@ export class VirtualOrestesApp {
183
216
  name: "x-sk-detected-encoding",
184
217
  value: textEncoding,
185
218
  });
186
- const baqendResponse = new BaqendResponse(Buffer.isBuffer(skResponse.body)
219
+ // Decoded, and cached decoded: only Chrome needs the base64.
220
+ const decodedBody = Buffer.isBuffer(skResponse.body)
187
221
  ? skResponse.body
188
- : iconv.encode(skResponse.body, textEncoding), skResponse.headers["content-type"] ?? `text/html;charset=${textEncoding}`, [...customHeaders, ...originHeaders]);
189
- this.cache.addEntry(requestUrl, baqendResponse);
222
+ : iconv.encode(skResponse.body, textEncoding);
223
+ const baqendResponse = new BaqendResponse(decodedBody, skResponse.headers["content-type"] ?? `text/html;charset=${textEncoding}`, [...customHeaders, ...originHeaders]);
224
+ this.cache.addEntry(requestUrl, baqendResponse, decodedBody);
190
225
  return baqendResponse;
191
226
  }
192
227
  async getResponseText(response) {
193
228
  const { text, charset } = decodeHtml(response?.headers.get("content-type") || "", Buffer.from(await response.arrayBuffer()));
194
229
  return { responseContent: text, textEncoding: charset };
195
230
  }
231
+ /**
232
+ * The urls the local documentHandler could not build, as they stand now.
233
+ *
234
+ * Already collected for the devtools panel; this is the same list for a
235
+ * reader without one. State rather than history: an entry disappears once the
236
+ * same url and variation builds successfully, so an empty list means nothing
237
+ * is currently failing, not that nothing ever did.
238
+ *
239
+ * `occurredAt` is converted to ISO on the way out — the panel wants epoch
240
+ * milliseconds to sort by, a reader wants a timestamp it can compare against
241
+ * a log line.
242
+ */
243
+ getLocalCacheErrors() {
244
+ return [...this.localCacheErrors.values()].map((error) => ({
245
+ ...error,
246
+ occurredAt: new Date(error.occurredAt).toISOString(),
247
+ }));
248
+ }
196
249
  localCacheErrorKey(url, variation) {
197
250
  return `${url}|${variation}`;
198
251
  }
@@ -238,13 +291,17 @@ export class VirtualOrestesApp {
238
291
  this.warnPrerendererUnreachable();
239
292
  return;
240
293
  }
294
+ const meta = {
295
+ scope: "documentHandler",
296
+ data: { aborted: true, status: ABORT_STATUS_CODE, error: message },
297
+ };
241
298
  const failure = prerenderFailure(error);
242
299
  if (failure) {
243
300
  this.cli.writeError(`[DocumentHandler:local]: SSR failed for ${failure.url} (${failure.variation}): ` +
244
- `${failure.detailMessage ?? "no error message"}`);
301
+ `${failure.detailMessage ?? "no error message"}`, false, meta);
245
302
  return;
246
303
  }
247
- this.cli.writeWarning(`[DocumentHandler:local]: ${message}`);
304
+ this.cli.writeWarning(`[DocumentHandler:local]: ${message}`, false, meta);
248
305
  }
249
306
  warnPrerendererUnreachable() {
250
307
  const unreachable = `no pre-renderer is listening on localhost:${LOCAL_PRERENDERER_PORT}`;
@@ -291,9 +348,18 @@ export class VirtualOrestesApp {
291
348
  return this.returnAbortResponse(customResponse, customHeaders);
292
349
  }
293
350
  const message = `Could not transform html: - ${customResponse.error}`;
294
- this.cli.writeError(`[VirtualOrestes]: ${message}`);
295
- this.cli.comment(customResponse.errorObj.stack);
296
- this.cli.writeWarning("Suggestion: check files: config_documentHandler.es6 | custom_documentHandler.js");
351
+ this.cli.writeError(`[VirtualOrestes]: ${message}`, false, {
352
+ scope: "documentHandler",
353
+ data: {
354
+ error: customResponse.error,
355
+ stack: customResponse.errorObj.stack,
356
+ },
357
+ });
358
+ this.cli.comment(customResponse.errorObj.stack, false, {
359
+ scope: "documentHandler",
360
+ level: "debug",
361
+ });
362
+ this.cli.writeWarning("Suggestion: check files: config_documentHandler.es6 | custom_documentHandler.js", false, { scope: "documentHandler" });
297
363
  customHeaders.push({ name: "x-error", value: message });
298
364
  return new BaqendResponse(message, null, customHeaders, 500);
299
365
  }
@@ -310,7 +376,7 @@ export class VirtualOrestesApp {
310
376
  value: response?.headers.get("location") || "",
311
377
  });
312
378
  const redirectResponse = new BaqendResponse("", null, customHeaders, response.status);
313
- this.cache.addEntry(requestUrl, redirectResponse);
379
+ this.cache.addEntry(requestUrl, redirectResponse, "");
314
380
  return redirectResponse;
315
381
  }
316
382
  handleCdnRedirect(customHeaders, response, requestUrl) {
@@ -328,22 +394,11 @@ export class VirtualOrestesApp {
328
394
  // the CDN redirect surfaced as a bare ClientError (`AssetAPIHandler.ts:200-205`).
329
395
  serverTimingHeader.value += ",errorcode;desc=202";
330
396
  const redirectResponse = new BaqendResponse("", null, customHeaders, 400);
331
- this.cache.addEntry(requestUrl, redirectResponse);
397
+ this.cache.addEntry(requestUrl, redirectResponse, "");
332
398
  return redirectResponse;
333
399
  }
334
400
  getAssetUrl(requestUrl) {
335
- const url = new URL(requestUrl);
336
- const parametersToDelete = [];
337
- for (const [name] of url.searchParams.entries()) {
338
- if (name.startsWith("bq")) {
339
- parametersToDelete.push(name);
340
- }
341
- }
342
- for (const parameter of parametersToDelete) {
343
- url.searchParams.delete(parameter);
344
- }
345
- const cleanedUrl = url.toString();
346
- return cleanedUrl.split("app.baqend.com/v1/asset/")[1];
401
+ return assetOriginUrl(requestUrl);
347
402
  }
348
403
  getCachedResponse(requestUrl) {
349
404
  const response = this.cache.getEntry(requestUrl);
@@ -19,6 +19,13 @@ export interface AssetVariation {
19
19
  regex?: string | null;
20
20
  /** Which config key produced this entry. Set during resolution, for reporting. */
21
21
  matchedKey?: string;
22
+ /**
23
+ * Set during resolution, for reporting: the entry came from a regex key that
24
+ * matched the requested variation, not from a key of that name. Carried on
25
+ * the entry because only the resolution knows it — reading it back off the
26
+ * finished chain cannot tell a named key from a matched template.
27
+ */
28
+ viaTemplate?: boolean;
22
29
  }
23
30
  export type AssetVariationMap = Record<string, AssetVariation>;
24
31
  /** An entry of the runtime config's `speedKit.originMap`, keyed by origin or by host. */
@@ -48,6 +55,13 @@ export declare const DEFAULT_TYPE = "default";
48
55
  export declare const DEFAULT_USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.6 Safari/605.1.15 (compatible; SpeedKit/1.0)";
49
56
  export declare const MOBILE_USER_AGENT = "Mozilla/5.0 (iPhone; CPU iPhone OS 18_6_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.6 Mobile/15E148 Safari/604.1 (compatible; SpeedKit/1.0)";
50
57
  export declare const TABLET_USER_AGENT = "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36 (compatible; SpeedKit/1.0)";
58
+ /**
59
+ * The variation types the server resolves whether a config defines them or not.
60
+ *
61
+ * Exported because "which variations exist" is otherwise answered with the config's own keys alone,
62
+ * and a config that defines none reads as "nothing can be passed" while these three still work.
63
+ */
64
+ export declare const DEVICE_DEFAULT_TYPES: string[];
51
65
  /** Thrown where the server would throw UndefinedVariationException. */
52
66
  export declare class UndefinedVariationError extends Error {
53
67
  constructor(variationType: string);
@@ -22,6 +22,13 @@ const DEVICE_DEFAULTS = {
22
22
  mobile: { headers: { "user-agent": MOBILE_USER_AGENT } },
23
23
  tablet: { headers: { "user-agent": TABLET_USER_AGENT } },
24
24
  };
25
+ /**
26
+ * The variation types the server resolves whether a config defines them or not.
27
+ *
28
+ * Exported because "which variations exist" is otherwise answered with the config's own keys alone,
29
+ * and a config that defines none reads as "nothing can be passed" while these three still work.
30
+ */
31
+ export const DEVICE_DEFAULT_TYPES = Object.keys(DEVICE_DEFAULTS);
25
32
  /** Group names a template captures, e.g. `storeId` from `(?<storeId>.*)`. */
26
33
  const CAPTURING_TEMPLATES = /<(\w+)>/g;
27
34
  /** Thrown where the server would throw UndefinedVariationException. */
@@ -64,6 +71,7 @@ function applyTemplate(entry, variationType) {
64
71
  };
65
72
  return {
66
73
  matchedKey: entry.matchedKey,
74
+ viaTemplate: true,
67
75
  urlPrefix: entry.urlPrefix ? substitute(entry.urlPrefix) : entry.urlPrefix,
68
76
  encodePrefixedUrl: entry.encodePrefixedUrl,
69
77
  queryParams: (entry.queryParams ?? []).map(substitute),
@@ -180,16 +188,15 @@ export function resolveRequest(custom, url, variationType, { hostOverride, origi
180
188
  const originalHost = originEntry?.origin && originEntry.overrideHostHeader
181
189
  ? parsed.hostname
182
190
  : undefined;
183
- const isTemplate = chain.some((config) => config.matchedKey !== WILD_CARD &&
184
- !DEVICE_DEFAULTS[config.matchedKey ?? ""]) &&
185
- !chain.some((config) => config.matchedKey?.startsWith("device-default:"));
186
191
  const headers = buildHeaders(chain, hostOverride, originEntry, originalHost);
187
192
  const originMapHeaders = Object.entries(originEntry?.headers ?? {})
188
193
  .filter(([key, value]) => headers[key.toLowerCase()] === String(value))
189
194
  .map(([key]) => key.toLowerCase());
190
195
  return {
191
196
  appliedKeys: chain.map((config) => config.matchedKey ?? "?"),
192
- resolutionPath: isTemplate ? "template" : "named",
197
+ resolutionPath: chain.some((config) => config.viaTemplate)
198
+ ? "template"
199
+ : "named",
193
200
  ...(originMapKey ? { originMapKey, originMapHeaders } : {}),
194
201
  url: buildUrl(requestUrl, chain),
195
202
  headers,
@@ -35,6 +35,13 @@ export declare class OriginFetcher {
35
35
  /** Warnings already shown, so a per-fetch condition is reported once per session. */
36
36
  private readonly warned;
37
37
  constructor(deps: OriginFetcherDeps);
38
+ /**
39
+ * The variations the runtime config names. The wildcard and the regex
40
+ * templates are not variations of their own, and the device defaults are
41
+ * left out: whether a config ever produces `tablet` is decided in the
42
+ * browser, by `detectDevice` or the user agent, and nothing here can tell.
43
+ */
44
+ namedVariations(): string[];
38
45
  /** The request, without sending it. */
39
46
  prepare(originUrl: string, variation?: string): PreparedOriginRequest;
40
47
  /**
@@ -18,6 +18,18 @@ export class OriginFetcher {
18
18
  constructor(deps) {
19
19
  this.deps = deps;
20
20
  }
21
+ /**
22
+ * The variations the runtime config names. The wildcard and the regex
23
+ * templates are not variations of their own, and the device defaults are
24
+ * left out: whether a config ever produces `tablet` is decided in the
25
+ * browser, by `detectDevice` or the user agent, and nothing here can tell.
26
+ */
27
+ namedVariations() {
28
+ const variations = this.deps.config?.variations ?? {};
29
+ return Object.entries(variations)
30
+ .filter(([key, entry]) => key !== "*" && !key.startsWith("device-default:") && !entry?.regex)
31
+ .map(([key]) => key);
32
+ }
21
33
  /** The request, without sending it. */
22
34
  prepare(originUrl, variation) {
23
35
  // A missing runtime config is not reported here; the load that failed says what it costs.
@@ -42,15 +54,38 @@ export class OriginFetcher {
42
54
  async fetch(originUrl, variation) {
43
55
  const { url, init } = this.prepare(originUrl, variation);
44
56
  const action = `ORIGIN:FETCH:${randomUUID()}`;
45
- this.deps.cli.startAction(action, `[documentHandler:fetch]: ${url}`);
57
+ this.deps.cli.startAction(action, `[documentHandler:fetch]: ${url}`, {
58
+ scope: "documentHandler",
59
+ data: { url, originUrl, variation },
60
+ });
61
+ const startedAt = Date.now();
46
62
  try {
47
63
  const response = await originFetch(url, init);
48
- this.deps.cli.successAction(action);
64
+ this.deps.cli.successAction(action, undefined, {
65
+ scope: "documentHandler",
66
+ data: {
67
+ url,
68
+ variation,
69
+ status: response.status,
70
+ durationMs: Date.now() - startedAt,
71
+ },
72
+ });
49
73
  return { response, url };
50
74
  }
51
75
  catch (error) {
52
- this.deps.cli.failAction(action, `error while fetching Asset: ${originUrl}`);
53
- this.deps.cli.writeError(String(error));
76
+ this.deps.cli.failAction(action, `error while fetching Asset: ${originUrl}`, {
77
+ scope: "documentHandler",
78
+ data: {
79
+ url,
80
+ originUrl,
81
+ variation,
82
+ durationMs: Date.now() - startedAt,
83
+ error: String(error),
84
+ },
85
+ });
86
+ this.deps.cli.writeError(String(error), false, {
87
+ scope: "documentHandler",
88
+ });
54
89
  return undefined;
55
90
  }
56
91
  }
@@ -94,6 +129,9 @@ export class OriginFetcher {
94
129
  if (this.warned.has(key))
95
130
  return;
96
131
  this.warned.add(key);
97
- this.deps.cli.writeWarning(message);
132
+ this.deps.cli.writeWarning(message, false, {
133
+ scope: "documentHandler",
134
+ data: { once: key },
135
+ });
98
136
  }
99
137
  }
@@ -11,6 +11,8 @@ declare const flags: {
11
11
  host: Interfaces.OptionFlag<string, Interfaces.CustomOptions>;
12
12
  body: Interfaces.OptionFlag<string, Interfaces.CustomOptions>;
13
13
  grep: Interfaces.OptionFlag<string, Interfaces.CustomOptions>;
14
+ select: Interfaces.OptionFlag<string, Interfaces.CustomOptions>;
15
+ maxMatches: Interfaces.OptionFlag<number, Interfaces.CustomOptions>;
14
16
  json: Interfaces.BooleanFlag<boolean>;
15
17
  variations: Interfaces.OptionFlag<string, Interfaces.CustomOptions>;
16
18
  raw: Interfaces.BooleanFlag<boolean>;
@@ -26,8 +28,21 @@ export interface OriginRequestOptions {
26
28
  readonly host?: string;
27
29
  readonly bodyFile?: string;
28
30
  readonly grep?: string;
31
+ readonly select?: string;
32
+ readonly maxMatches?: number;
29
33
  readonly json?: boolean;
30
34
  readonly variationsFile?: string;
35
+ /**
36
+ * The origin a relative {@link pageUrl} is resolved against, when the
37
+ * caller knows one the config cannot supply.
38
+ *
39
+ * A customer with several origins and no `domain` has no base in its
40
+ * config, and picking `origins[0]` would answer about the wrong site. But
41
+ * a run *is* on one of them — the one `-d` or the startup prompt chose —
42
+ * and that is the origin whoever is asking means. Passed in rather than
43
+ * looked up, because this service has no idea a run exists.
44
+ */
45
+ readonly base?: string;
31
46
  }
32
47
  export interface OriginRequestServiceBuildContextValues extends CommandContextValues, OriginRequestOptions {
33
48
  }
@@ -45,6 +60,8 @@ export declare class OriginRequestServiceBuildContext extends OriginRequestServi
45
60
  host: Interfaces.OptionFlag<string, Interfaces.CustomOptions>;
46
61
  body: Interfaces.OptionFlag<string, Interfaces.CustomOptions>;
47
62
  grep: Interfaces.OptionFlag<string, Interfaces.CustomOptions>;
63
+ select: Interfaces.OptionFlag<string, Interfaces.CustomOptions>;
64
+ maxMatches: Interfaces.OptionFlag<number, Interfaces.CustomOptions>;
48
65
  json: Interfaces.BooleanFlag<boolean>;
49
66
  variations: Interfaces.OptionFlag<string, Interfaces.CustomOptions>;
50
67
  raw: Interfaces.BooleanFlag<boolean>;
@@ -34,6 +34,12 @@ const flags = {
34
34
  grep: Flags.string({
35
35
  description: "Print body lines matching this regex, case-insensitive",
36
36
  }),
37
+ select: Flags.string({
38
+ description: "Count and sample what this CSS selector matches in the body, e.g. 'script[src*=\"analytics\"]'",
39
+ }),
40
+ maxMatches: Flags.integer({
41
+ description: "How many --select and --grep matches to show. Default 10",
42
+ }),
37
43
  json: Flags.boolean({
38
44
  description: "Machine-readable output",
39
45
  }),
@@ -72,6 +78,8 @@ export class OriginRequestServiceBuildContext extends Context() {
72
78
  host: parsedFlags.host,
73
79
  bodyFile: parsedFlags.body,
74
80
  grep: parsedFlags.grep,
81
+ select: parsedFlags.select,
82
+ maxMatches: parsedFlags.maxMatches,
75
83
  json: parsedFlags.json,
76
84
  variationsFile: parsedFlags.variations,
77
85
  });
@@ -6,11 +6,6 @@ export declare class OriginRequestServiceFactory {
6
6
  constructor(context: OriginRequestServiceBuildContext);
7
7
  buildService(): Promise<OriginRequestService>;
8
8
  private build;
9
- /**
10
- * The runtime config: a local file when one is named, else the app's. Without a customer there is
11
- * no app, and the request carries Speed Kit's device defaults only.
12
- */
13
- private loadRuntimeConfig;
14
9
  private getIntegrationFiles;
15
10
  private getConfigApi;
16
11
  }
@@ -2,8 +2,6 @@ import { ConfigApiContext, ConfigApiServiceFactory, } from "../config-api/index.
2
2
  import { IntegrationApiServiceBuildContext, IntegrationApiFactory, } from "../integration-api/index.js";
3
3
  import { applyOriginProxy } from "../../helpers/origin-proxy.js";
4
4
  import { OriginRequestService } from "./origin-request-service.js";
5
- import { OriginFetcher } from "./origin-fetcher.js";
6
- import { RuntimeConfigSource, } from "./runtime-config-source.js";
7
5
  export class OriginRequestServiceFactory {
8
6
  context;
9
7
  service = undefined;
@@ -18,39 +16,13 @@ export class OriginRequestServiceFactory {
18
16
  }
19
17
  async build() {
20
18
  const cli = this.context.environment.cli;
19
+ // `sk origin-request --raw <url>` names no customer: no app, so no runtime config.
21
20
  const customer = this.context.customerPath
22
21
  ? (await this.getIntegrationFiles(this.context.customerPath)).getCustomerConfig().config
23
22
  : undefined;
24
23
  // `--json` owns stdout, so the proxy line stays out of a machine-readable run.
25
24
  applyOriginProxy(customer?.chromeFlags, this.context.json ? undefined : cli);
26
- // An empty variation set still runs: device defaults resolve, originMap and authentications apply.
27
- const config = await this.loadRuntimeConfig(customer?.app);
28
- this.service = new OriginRequestService(this.context, cli, config
29
- ? new OriginFetcher({
30
- cli,
31
- config,
32
- host: this.context.host,
33
- strict: true,
34
- })
35
- : undefined);
36
- }
37
- /**
38
- * The runtime config: a local file when one is named, else the app's. Without a customer there is
39
- * no app, and the request carries Speed Kit's device defaults only.
40
- */
41
- async loadRuntimeConfig(app) {
42
- const cli = this.context.environment.cli;
43
- if (!app && !this.context.variationsFile) {
44
- if (!this.context.json) {
45
- cli.writeWarning("no customer: the request carries Speed Kit's device defaults only, no variation of an app");
46
- }
47
- return { variations: {}, authentications: [], originMap: {} };
48
- }
49
- return new RuntimeConfigSource({
50
- cli,
51
- configApi: app ? this.getConfigApi(app) : undefined,
52
- fileFlag: "--variations",
53
- }).load(this.context.variationsFile);
25
+ this.service = new OriginRequestService(this.context, cli, customer ? this.getConfigApi(customer.app) : undefined, customer);
54
26
  }
55
27
  async getIntegrationFiles(customerPath) {
56
28
  const integrationApiContext = new IntegrationApiServiceBuildContext({