@speedkit/cli 4.51.1 → 4.52.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/README.md +1426 -14
- package/dist/base/run-control-command.d.ts +15 -0
- package/dist/base/run-control-command.js +20 -0
- package/dist/build-info.json +6 -0
- package/dist/commands/diff.d.ts +7 -1
- package/dist/commands/diff.js +9 -3
- package/dist/commands/login.d.ts +3 -0
- package/dist/commands/login.js +14 -3
- package/dist/commands/onboarding/browser/click.d.ts +75 -0
- package/dist/commands/onboarding/browser/click.js +19 -0
- package/dist/commands/onboarding/browser/emulate.d.ts +105 -0
- package/dist/commands/onboarding/browser/emulate.js +26 -0
- package/dist/commands/onboarding/browser/navigate.d.ts +75 -0
- package/dist/commands/onboarding/browser/navigate.js +19 -0
- package/dist/commands/onboarding/browser/panel.d.ts +63 -0
- package/dist/commands/onboarding/browser/panel.js +12 -0
- package/dist/commands/onboarding/browser/reinstall-sw.d.ts +63 -0
- package/dist/commands/onboarding/browser/reinstall-sw.js +14 -0
- package/dist/commands/onboarding/browser/reset.d.ts +71 -0
- package/dist/commands/onboarding/browser/reset.js +18 -0
- package/dist/commands/onboarding/browser/screenshot.d.ts +77 -0
- package/dist/commands/onboarding/browser/screenshot.js +19 -0
- package/dist/commands/onboarding/browser/state.d.ts +63 -0
- package/dist/commands/onboarding/browser/state.js +12 -0
- package/dist/commands/onboarding/browser/tabs.d.ts +58 -0
- package/dist/commands/onboarding/browser/tabs.js +16 -0
- package/dist/commands/onboarding/cache/clear.d.ts +58 -0
- package/dist/commands/onboarding/cache/clear.js +12 -0
- package/dist/commands/onboarding/cache/errors.d.ts +58 -0
- package/dist/commands/onboarding/cache/errors.js +12 -0
- package/dist/commands/onboarding/cache/evict.d.ts +62 -0
- package/dist/commands/onboarding/cache/evict.js +15 -0
- package/dist/commands/onboarding/cache/get.d.ts +85 -0
- package/dist/commands/onboarding/cache/get.js +17 -0
- package/dist/commands/onboarding/cache/list.d.ts +58 -0
- package/dist/commands/onboarding/cache/list.js +15 -0
- package/dist/commands/onboarding/cache/prewarm.d.ts +73 -0
- package/dist/commands/onboarding/cache/prewarm.js +20 -0
- package/dist/commands/onboarding/cache/refresh.d.ts +62 -0
- package/dist/commands/onboarding/cache/refresh.js +18 -0
- package/dist/commands/onboarding/cdp.d.ts +81 -0
- package/dist/commands/onboarding/cdp.js +18 -0
- package/dist/commands/onboarding/debug/arm.d.ts +83 -0
- package/dist/commands/onboarding/debug/arm.js +19 -0
- package/dist/commands/onboarding/debug/await.d.ts +71 -0
- package/dist/commands/onboarding/debug/await.js +18 -0
- package/dist/commands/onboarding/debug/disarm.d.ts +63 -0
- package/dist/commands/onboarding/debug/disarm.js +12 -0
- package/dist/commands/onboarding/debug/eval.d.ts +75 -0
- package/dist/commands/onboarding/debug/eval.js +16 -0
- package/dist/commands/onboarding/debug/release.d.ts +63 -0
- package/dist/commands/onboarding/debug/release.js +12 -0
- package/dist/commands/onboarding/debug/resume.d.ts +63 -0
- package/dist/commands/onboarding/debug/resume.js +12 -0
- package/dist/commands/onboarding/debug/status.d.ts +63 -0
- package/dist/commands/onboarding/debug/status.js +12 -0
- package/dist/commands/onboarding/debug/step.d.ts +67 -0
- package/dist/commands/onboarding/debug/step.js +15 -0
- package/dist/commands/onboarding/files/list.d.ts +58 -0
- package/dist/commands/onboarding/files/list.js +12 -0
- package/dist/commands/onboarding/files/read.d.ts +73 -0
- package/dist/commands/onboarding/files/read.js +16 -0
- package/dist/commands/onboarding/files/rebuild.d.ts +63 -0
- package/dist/commands/onboarding/files/rebuild.js +18 -0
- package/dist/commands/onboarding/files/validate.d.ts +58 -0
- package/dist/commands/onboarding/files/validate.js +12 -0
- package/dist/commands/onboarding/fouc.d.ts +77 -0
- package/dist/commands/onboarding/fouc.js +16 -0
- package/dist/commands/onboarding/inject/add.d.ts +89 -0
- package/dist/commands/onboarding/inject/add.js +17 -0
- package/dist/commands/onboarding/inject/clear.d.ts +63 -0
- package/dist/commands/onboarding/inject/clear.js +12 -0
- package/dist/commands/onboarding/inject/list.d.ts +63 -0
- package/dist/commands/onboarding/inject/list.js +12 -0
- package/dist/commands/onboarding/inject/read.d.ts +75 -0
- package/dist/commands/onboarding/inject/read.js +18 -0
- package/dist/commands/onboarding/inject/recipes.d.ts +63 -0
- package/dist/commands/onboarding/inject/recipes.js +12 -0
- package/dist/commands/onboarding/inject/remove.d.ts +67 -0
- package/dist/commands/onboarding/inject/remove.js +15 -0
- package/dist/commands/onboarding/list.d.ts +13 -0
- package/dist/commands/onboarding/list.js +12 -0
- package/dist/commands/onboarding/logs.d.ts +41 -0
- package/dist/commands/onboarding/logs.js +257 -0
- package/dist/commands/onboarding/navwalk.d.ts +95 -0
- package/dist/commands/onboarding/navwalk.js +19 -0
- package/dist/commands/onboarding/response.d.ts +67 -0
- package/dist/commands/onboarding/response.js +18 -0
- package/dist/commands/onboarding/rum/beacons.d.ts +75 -0
- package/dist/commands/onboarding/rum/beacons.js +16 -0
- package/dist/commands/onboarding/rum/get.d.ts +77 -0
- package/dist/commands/onboarding/rum/get.js +18 -0
- package/dist/commands/onboarding/rum/key.d.ts +67 -0
- package/dist/commands/onboarding/rum/key.js +13 -0
- package/dist/commands/onboarding/rum/previous.d.ts +63 -0
- package/dist/commands/onboarding/rum/previous.js +12 -0
- package/dist/commands/onboarding/status.d.ts +13 -0
- package/dist/commands/onboarding/status.js +17 -0
- package/dist/commands/onboarding/stop.d.ts +13 -0
- package/dist/commands/onboarding/stop.js +17 -0
- package/dist/commands/onboarding/todo.d.ts +58 -0
- package/dist/commands/onboarding/todo.js +12 -0
- package/dist/commands/onboarding/viewport.d.ts +101 -0
- package/dist/commands/onboarding/viewport.js +18 -0
- package/dist/commands/onboarding/watch.d.ts +93 -0
- package/dist/commands/onboarding/watch.js +16 -0
- package/dist/commands/onboarding.d.ts +26 -0
- package/dist/commands/onboarding.js +221 -4
- package/dist/commands/origin-request.d.ts +4 -0
- package/dist/commands/origin-request.js +4 -0
- package/dist/commands/spec/onboarding.spec.d.ts +1 -0
- package/dist/commands/spec/onboarding.spec.js +127 -0
- package/dist/services/browser-fetch/device-emulation.d.ts +11 -0
- package/dist/services/browser-fetch/device-emulation.js +14 -0
- package/dist/services/cli/build-info.d.ts +33 -0
- package/dist/services/cli/build-info.js +63 -0
- package/dist/services/cli/cli-environment-factory.d.ts +3 -0
- package/dist/services/cli/cli-environment-factory.js +1 -0
- package/dist/services/cli/cli-service-build-context.d.ts +3 -0
- package/dist/services/cli/cli-service-factory.js +1 -1
- package/dist/services/cli/cli-service-model.d.ts +29 -10
- package/dist/services/cli/cli-service.d.ts +60 -11
- package/dist/services/cli/cli-service.js +196 -32
- package/dist/services/cli/index.d.ts +2 -0
- package/dist/services/cli/index.js +2 -0
- package/dist/services/cli/sink.d.ts +47 -0
- package/dist/services/cli/sink.js +31 -0
- package/dist/services/cli/spec/build-identity.spec.d.ts +1 -0
- package/dist/services/cli/spec/build-identity.spec.js +85 -0
- package/dist/services/cli/spec/build-info.spec.d.ts +1 -0
- package/dist/services/cli/spec/build-info.spec.js +10 -0
- package/dist/services/cli/spec/cli-service-log.spec.d.ts +1 -0
- package/dist/services/cli/spec/cli-service-log.spec.js +133 -0
- package/dist/services/cli/spec/cli-service.spec.js +113 -50
- package/dist/services/cli/spec/memory-cli.d.ts +9 -0
- package/dist/services/cli/spec/memory-cli.js +9 -0
- package/dist/services/diff/config-at-ref.d.ts +20 -0
- package/dist/services/diff/config-at-ref.js +33 -0
- package/dist/services/diff/diff-service-build-context.d.ts +12 -0
- package/dist/services/diff/diff-service-build-context.js +45 -1
- package/dist/services/diff/diff-service-factory.d.ts +2 -0
- package/dist/services/diff/diff-service-factory.js +65 -25
- package/dist/services/diff/diff-service.d.ts +11 -0
- package/dist/services/diff/diff-service.js +37 -11
- package/dist/services/diff/page-source.d.ts +12 -0
- package/dist/services/diff/page-source.js +16 -11
- package/dist/services/diff/run-runtime-config.d.ts +33 -0
- package/dist/services/diff/run-runtime-config.js +74 -0
- package/dist/services/diff/sinks/tool-diff-sink.d.ts +3 -2
- package/dist/services/diff/sinks/tool-diff-sink.js +3 -2
- package/dist/services/diff/spec/config-at-ref.spec.d.ts +1 -0
- package/dist/services/diff/spec/config-at-ref.spec.js +46 -0
- package/dist/services/diff/spec/diff-service-build-context.spec.js +19 -0
- package/dist/services/diff/spec/diff-service.spec.js +95 -0
- package/dist/services/diff/spec/run-runtime-config.spec.d.ts +1 -0
- package/dist/services/diff/spec/run-runtime-config.spec.js +87 -0
- package/dist/services/git/git-repository.d.ts +2 -0
- package/dist/services/git/git-repository.js +6 -0
- package/dist/services/integration-api/customer-config-flags.js +1 -0
- package/dist/services/onboarding/browse/browse-service.d.ts +13 -1
- package/dist/services/onboarding/browse/browse-service.js +43 -7
- package/dist/services/onboarding/browser/answer-dialogs.d.ts +12 -0
- package/dist/services/onboarding/browser/answer-dialogs.js +25 -0
- package/dist/services/onboarding/browser/baqend-response.d.ts +17 -1
- package/dist/services/onboarding/browser/baqend-response.js +23 -0
- package/dist/services/onboarding/browser/console-log.d.ts +9 -0
- package/dist/services/onboarding/browser/console-log.js +27 -0
- package/dist/services/onboarding/browser/emulate-device.d.ts +12 -1
- package/dist/services/onboarding/browser/emulate-device.js +68 -13
- package/dist/services/onboarding/browser/executable/executable-validator.js +4 -2
- package/dist/services/onboarding/browser/extension/extension-bridge.js +5 -3
- package/dist/services/onboarding/browser/extension/extension-downloader.js +17 -8
- package/dist/services/onboarding/browser/extension/extension-validator.js +9 -4
- package/dist/services/onboarding/browser/launch-browser.d.ts +2 -1
- package/dist/services/onboarding/browser/launch-browser.js +6 -1
- package/dist/services/onboarding/browser/resume-restarted-workers.d.ts +14 -0
- package/dist/services/onboarding/browser/resume-restarted-workers.js +26 -0
- package/dist/services/onboarding/control/body-inspect.d.ts +24 -0
- package/dist/services/onboarding/control/body-inspect.js +106 -0
- package/dist/services/onboarding/control/browser-session.d.ts +547 -0
- package/dist/services/onboarding/control/browser-session.js +1337 -0
- package/dist/services/onboarding/control/config-validation.d.ts +17 -0
- package/dist/services/onboarding/control/config-validation.js +46 -0
- package/dist/services/onboarding/control/control-protocol.d.ts +1430 -0
- package/dist/services/onboarding/control/control-protocol.js +58 -0
- package/dist/services/onboarding/control/control-server.d.ts +292 -0
- package/dist/services/onboarding/control/control-server.js +1629 -0
- package/dist/services/onboarding/control/debug-session.d.ts +219 -0
- package/dist/services/onboarding/control/debug-session.js +897 -0
- package/dist/services/onboarding/control/fouc.d.ts +23 -0
- package/dist/services/onboarding/control/fouc.js +151 -0
- package/dist/services/onboarding/control/index.d.ts +4 -0
- package/dist/services/onboarding/control/index.js +4 -0
- package/dist/services/onboarding/control/navigate-wait.d.ts +33 -0
- package/dist/services/onboarding/control/navigate-wait.js +56 -0
- package/dist/services/onboarding/control/navwalk.d.ts +65 -0
- package/dist/services/onboarding/control/navwalk.js +248 -0
- package/dist/services/onboarding/control/preload-registry.d.ts +150 -0
- package/dist/services/onboarding/control/preload-registry.js +829 -0
- package/dist/services/onboarding/control/response-explainer.d.ts +24 -0
- package/dist/services/onboarding/control/response-explainer.js +257 -0
- package/dist/services/onboarding/control/rum.d.ts +8 -0
- package/dist/services/onboarding/control/rum.js +220 -0
- package/dist/services/onboarding/control/service-worker-tracker.d.ts +68 -0
- package/dist/services/onboarding/control/service-worker-tracker.js +120 -0
- package/dist/services/onboarding/control/viewport.d.ts +45 -0
- package/dist/services/onboarding/control/viewport.js +344 -0
- package/dist/services/onboarding/control/watch.d.ts +26 -0
- package/dist/services/onboarding/control/watch.js +157 -0
- package/dist/services/onboarding/dashboard/diff-against-current-page.js +3 -1
- package/dist/services/onboarding/dashboard/index.js +7 -2
- package/dist/services/onboarding/fetch-event-handler.d.ts +24 -5
- package/dist/services/onboarding/fetch-event-handler.js +103 -32
- package/dist/services/onboarding/fetch-events/speed-kit-install-js.js +11 -2
- package/dist/services/onboarding/fetch-events/speed-kit-rum-pi-request.d.ts +14 -0
- package/dist/services/onboarding/fetch-events/speed-kit-rum-pi-request.js +30 -0
- package/dist/services/onboarding/fetch-events/speed-kit-service-worker-js.d.ts +13 -0
- package/dist/services/onboarding/fetch-events/speed-kit-service-worker-js.js +28 -1
- package/dist/services/onboarding/file-events/file-watcher.d.ts +42 -1
- package/dist/services/onboarding/file-events/file-watcher.js +117 -12
- package/dist/services/onboarding/inject/inject-service.js +1 -1
- package/dist/services/onboarding/onboarding-model.d.ts +40 -7
- package/dist/services/onboarding/onboarding-model.js +20 -9
- package/dist/services/onboarding/onboarding-service-build-context.d.ts +4 -0
- package/dist/services/onboarding/onboarding-service-build-context.js +7 -1
- package/dist/services/onboarding/onboarding-service-factory.d.ts +17 -1
- package/dist/services/onboarding/onboarding-service-factory.js +150 -23
- package/dist/services/onboarding/onboarding-service.d.ts +40 -1
- package/dist/services/onboarding/onboarding-service.js +139 -23
- package/dist/services/onboarding/request-cache/asset-key.d.ts +61 -0
- package/dist/services/onboarding/request-cache/asset-key.js +115 -0
- package/dist/services/onboarding/request-cache/cache.d.ts +62 -5
- package/dist/services/onboarding/request-cache/cache.js +128 -17
- package/dist/services/onboarding/spec/browser/answer-dialogs.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/browser/answer-dialogs.spec.js +66 -0
- package/dist/services/onboarding/spec/browser/console-log.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/browser/console-log.spec.js +42 -0
- package/dist/services/onboarding/spec/browser/resume-restarted-workers.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/browser/resume-restarted-workers.spec.js +45 -0
- package/dist/services/onboarding/spec/control/browser-session.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/control/browser-session.spec.js +753 -0
- package/dist/services/onboarding/spec/control/control-server.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/control/control-server.spec.js +371 -0
- package/dist/services/onboarding/spec/control/debug-session.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/control/debug-session.spec.js +751 -0
- package/dist/services/onboarding/spec/control/fakes.d.ts +31 -0
- package/dist/services/onboarding/spec/control/fakes.js +67 -0
- package/dist/services/onboarding/spec/control/fouc.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/control/fouc.spec.js +167 -0
- package/dist/services/onboarding/spec/control/navigate-wait.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/control/navigate-wait.spec.js +47 -0
- package/dist/services/onboarding/spec/control/navwalk.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/control/navwalk.spec.js +222 -0
- package/dist/services/onboarding/spec/control/preload-registry.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/control/preload-registry.spec.js +432 -0
- package/dist/services/onboarding/spec/control/response-explainer.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/control/response-explainer.spec.js +324 -0
- package/dist/services/onboarding/spec/control/rum.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/control/rum.spec.js +222 -0
- package/dist/services/onboarding/spec/control/service-worker-tracker.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/control/service-worker-tracker.spec.js +193 -0
- package/dist/services/onboarding/spec/control/viewport.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/control/viewport.spec.js +200 -0
- package/dist/services/onboarding/spec/control/watch.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/control/watch.spec.js +187 -0
- package/dist/services/onboarding/spec/fetch-event-handler.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/fetch-event-handler.spec.js +219 -0
- package/dist/services/onboarding/spec/fetch-events/speed-kit-service-worker-js.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/fetch-events/speed-kit-service-worker-js.spec.js +41 -0
- package/dist/services/onboarding/spec/onboarding-model.spec.js +39 -3
- package/dist/services/onboarding/spec/onboarding-service-factory.spec.js +25 -1
- package/dist/services/onboarding/spec/request-cache/cache.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/request-cache/cache.spec.js +107 -0
- package/dist/services/onboarding/spec/todo-collector.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/todo-collector.spec.js +136 -0
- package/dist/services/onboarding/spec/virtual-orestes-app/virtual-orestes-app.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/virtual-orestes-app/virtual-orestes-app.spec.js +65 -0
- package/dist/services/onboarding/todo-collector.d.ts +7 -2
- package/dist/services/onboarding/todo-collector.js +49 -12
- package/dist/services/onboarding/virtual-orestes-app/index.d.ts +38 -0
- package/dist/services/onboarding/virtual-orestes-app/index.js +113 -27
- package/dist/services/origin-request/asset-variations.d.ts +14 -0
- package/dist/services/origin-request/asset-variations.js +11 -4
- package/dist/services/origin-request/origin-fetcher.d.ts +7 -0
- package/dist/services/origin-request/origin-fetcher.js +43 -5
- package/dist/services/origin-request/origin-request-service-build-context.d.ts +17 -0
- package/dist/services/origin-request/origin-request-service-build-context.js +8 -0
- package/dist/services/origin-request/origin-request-service-factory.d.ts +0 -5
- package/dist/services/origin-request/origin-request-service-factory.js +2 -30
- package/dist/services/origin-request/origin-request-service.d.ts +121 -6
- package/dist/services/origin-request/origin-request-service.js +273 -49
- package/dist/services/origin-request/runtime-config-source.d.ts +6 -0
- package/dist/services/origin-request/runtime-config-source.js +15 -4
- package/dist/services/origin-request/spec/asset-variations.spec.js +20 -0
- package/dist/services/origin-request/spec/origin-request-service.spec.js +329 -6
- package/dist/services/query-builder/rules/rule-match.d.ts +35 -0
- package/dist/services/query-builder/rules/rule-match.js +70 -0
- package/dist/services/query-builder/spec/rules/rule-match.spec.d.ts +1 -0
- package/dist/services/query-builder/spec/rules/rule-match.spec.js +121 -0
- package/dist/services/run-control/browser/run-browser-contexts.d.ts +557 -0
- package/dist/services/run-control/browser/run-browser-contexts.js +91 -0
- package/dist/services/run-control/browser/run-browser-service-factory.d.ts +5 -0
- package/dist/services/run-control/browser/run-browser-service-factory.js +7 -0
- package/dist/services/run-control/browser/run-browser-service.d.ts +68 -0
- package/dist/services/run-control/browser/run-browser-service.js +206 -0
- package/dist/services/run-control/cache/run-cache-contexts.d.ts +349 -0
- package/dist/services/run-control/cache/run-cache-contexts.js +51 -0
- package/dist/services/run-control/cache/run-cache-service-factory.d.ts +6 -0
- package/dist/services/run-control/cache/run-cache-service-factory.js +12 -0
- package/dist/services/run-control/cache/run-cache-service.d.ts +35 -0
- package/dist/services/run-control/cache/run-cache-service.js +151 -0
- package/dist/services/run-control/control-client.d.ts +36 -0
- package/dist/services/run-control/control-client.js +147 -0
- package/dist/services/run-control/debug/run-debug-contexts.d.ts +416 -0
- package/dist/services/run-control/debug/run-debug-contexts.js +47 -0
- package/dist/services/run-control/debug/run-debug-service-factory.d.ts +5 -0
- package/dist/services/run-control/debug/run-debug-service-factory.js +7 -0
- package/dist/services/run-control/debug/run-debug-service.d.ts +39 -0
- package/dist/services/run-control/debug/run-debug-service.js +164 -0
- package/dist/services/run-control/files/run-files-contexts.d.ts +238 -0
- package/dist/services/run-control/files/run-files-contexts.js +26 -0
- package/dist/services/run-control/files/run-files-service-factory.d.ts +5 -0
- package/dist/services/run-control/files/run-files-service-factory.js +7 -0
- package/dist/services/run-control/files/run-files-service.d.ts +29 -0
- package/dist/services/run-control/files/run-files-service.js +120 -0
- package/dist/services/run-control/index.d.ts +32 -0
- package/dist/services/run-control/index.js +31 -0
- package/dist/services/run-control/inject/run-inject-contexts.d.ts +319 -0
- package/dist/services/run-control/inject/run-inject-contexts.js +38 -0
- package/dist/services/run-control/inject/run-inject-service-factory.d.ts +5 -0
- package/dist/services/run-control/inject/run-inject-service-factory.js +7 -0
- package/dist/services/run-control/inject/run-inject-service.d.ts +31 -0
- package/dist/services/run-control/inject/run-inject-service.js +227 -0
- package/dist/services/run-control/live-run.d.ts +37 -0
- package/dist/services/run-control/live-run.js +56 -0
- package/dist/services/run-control/probe/run-probe-contexts.d.ts +333 -0
- package/dist/services/run-control/probe/run-probe-contexts.js +73 -0
- package/dist/services/run-control/probe/run-probe-service-factory.d.ts +5 -0
- package/dist/services/run-control/probe/run-probe-service-factory.js +7 -0
- package/dist/services/run-control/probe/run-probe-service.d.ts +54 -0
- package/dist/services/run-control/probe/run-probe-service.js +194 -0
- package/dist/services/run-control/rum/run-rum-contexts.d.ts +216 -0
- package/dist/services/run-control/rum/run-rum-contexts.js +34 -0
- package/dist/services/run-control/rum/run-rum-service-factory.d.ts +5 -0
- package/dist/services/run-control/rum/run-rum-service-factory.js +7 -0
- package/dist/services/run-control/rum/run-rum-service.d.ts +36 -0
- package/dist/services/run-control/rum/run-rum-service.js +122 -0
- package/dist/services/run-control/run-answer.d.ts +28 -0
- package/dist/services/run-control/run-answer.js +58 -0
- package/dist/services/run-control/run-control-context.d.ts +102 -0
- package/dist/services/run-control/run-control-context.js +36 -0
- package/dist/services/run-control/run-control-flags.d.ts +12 -0
- package/dist/services/run-control/run-control-flags.js +22 -0
- package/dist/services/run-control/run-control-model.d.ts +9 -0
- package/dist/services/run-control/run-control-model.js +1 -0
- package/dist/services/run-control/run-control-service-factory.d.ts +14 -0
- package/dist/services/run-control/run-control-service-factory.js +26 -0
- package/dist/services/run-control/session/run-session-contexts.d.ts +25 -0
- package/dist/services/run-control/session/run-session-contexts.js +20 -0
- package/dist/services/run-control/session/run-session-service-factory.d.ts +8 -0
- package/dist/services/run-control/session/run-session-service-factory.js +18 -0
- package/dist/services/run-control/session/run-session-service.d.ts +32 -0
- package/dist/services/run-control/session/run-session-service.js +151 -0
- package/dist/services/run-control/spec/browser/run-browser-service.spec.d.ts +1 -0
- package/dist/services/run-control/spec/browser/run-browser-service.spec.js +328 -0
- package/dist/services/run-control/spec/cache/run-cache-service.spec.d.ts +1 -0
- package/dist/services/run-control/spec/cache/run-cache-service.spec.js +454 -0
- package/dist/services/run-control/spec/debug/run-debug-service.spec.d.ts +1 -0
- package/dist/services/run-control/spec/debug/run-debug-service.spec.js +113 -0
- package/dist/services/run-control/spec/files/run-files-service.spec.d.ts +1 -0
- package/dist/services/run-control/spec/files/run-files-service.spec.js +234 -0
- package/dist/services/run-control/spec/inject/run-inject-service.spec.d.ts +1 -0
- package/dist/services/run-control/spec/inject/run-inject-service.spec.js +251 -0
- package/dist/services/run-control/spec/live-run-fixture.d.ts +32 -0
- package/dist/services/run-control/spec/live-run-fixture.js +109 -0
- package/dist/services/run-control/spec/probe/run-probe-service.spec.d.ts +1 -0
- package/dist/services/run-control/spec/probe/run-probe-service.spec.js +108 -0
- package/dist/services/run-control/spec/rum/run-rum-service.spec.d.ts +1 -0
- package/dist/services/run-control/spec/rum/run-rum-service.spec.js +47 -0
- package/dist/services/run-control/spec/run-answer.spec.d.ts +1 -0
- package/dist/services/run-control/spec/run-answer.spec.js +57 -0
- package/dist/services/run-control/spec/session/run-session-service.spec.d.ts +1 -0
- package/dist/services/run-control/spec/session/run-session-service.spec.js +150 -0
- package/dist/services/run-log/crash-mirror.d.ts +31 -0
- package/dist/services/run-log/crash-mirror.js +69 -0
- package/dist/services/run-log/index.d.ts +11 -0
- package/dist/services/run-log/index.js +11 -0
- package/dist/services/run-log/jsonl-appender.d.ts +46 -0
- package/dist/services/run-log/jsonl-appender.js +91 -0
- package/dist/services/run-log/log-event-model.d.ts +104 -0
- package/dist/services/run-log/log-event-model.js +56 -0
- package/dist/services/run-log/log-query-service-factory.d.ts +11 -0
- package/dist/services/run-log/log-query-service-factory.js +14 -0
- package/dist/services/run-log/log-query-service.d.ts +59 -0
- package/dist/services/run-log/log-query-service.js +111 -0
- package/dist/services/run-log/log-reader.d.ts +84 -0
- package/dist/services/run-log/log-reader.js +180 -0
- package/dist/services/run-log/log-summary.d.ts +72 -0
- package/dist/services/run-log/log-summary.js +208 -0
- package/dist/services/run-log/redaction.d.ts +34 -0
- package/dist/services/run-log/redaction.js +124 -0
- package/dist/services/run-log/request-log.d.ts +82 -0
- package/dist/services/run-log/request-log.js +69 -0
- package/dist/services/run-log/request-summary.d.ts +76 -0
- package/dist/services/run-log/request-summary.js +0 -0
- package/dist/services/run-log/run-log.d.ts +61 -0
- package/dist/services/run-log/run-log.js +102 -0
- package/dist/services/run-log/spec/log-query-service.spec.d.ts +1 -0
- package/dist/services/run-log/spec/log-query-service.spec.js +197 -0
- package/dist/services/run-log/spec/log-reader.spec.d.ts +1 -0
- package/dist/services/run-log/spec/log-reader.spec.js +109 -0
- package/dist/services/run-log/spec/log-summary.spec.d.ts +1 -0
- package/dist/services/run-log/spec/log-summary.spec.js +153 -0
- package/dist/services/run-log/spec/redaction.spec.d.ts +1 -0
- package/dist/services/run-log/spec/redaction.spec.js +61 -0
- package/dist/services/run-log/spec/request-log.spec.d.ts +1 -0
- package/dist/services/run-log/spec/request-log.spec.js +101 -0
- package/dist/services/run-log/spec/request-summary.spec.d.ts +1 -0
- package/dist/services/run-log/spec/request-summary.spec.js +171 -0
- package/dist/services/run-log/spec/run-log.spec.d.ts +1 -0
- package/dist/services/run-log/spec/run-log.spec.js +122 -0
- package/dist/services/run-registry/exit-classification.d.ts +39 -0
- package/dist/services/run-registry/exit-classification.js +42 -0
- package/dist/services/run-registry/index.d.ts +3 -0
- package/dist/services/run-registry/index.js +3 -0
- package/dist/services/run-registry/process-identity.d.ts +28 -0
- package/dist/services/run-registry/process-identity.js +80 -0
- package/dist/services/run-registry/run-registry-model.d.ts +128 -0
- package/dist/services/run-registry/run-registry-model.js +16 -0
- package/dist/services/run-registry/run-registry.d.ts +155 -0
- package/dist/services/run-registry/run-registry.js +430 -0
- package/dist/services/run-registry/spec/exit-classification.spec.d.ts +1 -0
- package/dist/services/run-registry/spec/exit-classification.spec.js +82 -0
- package/dist/services/run-registry/spec/run-registry.spec.d.ts +1 -0
- package/dist/services/run-registry/spec/run-registry.spec.js +526 -0
- package/dist/services/setup/os/tool-registry.js +2 -2
- package/oclif.manifest.json +3493 -372
- package/package.json +20 -2
|
@@ -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
|
-
|
|
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({
|
|
@@ -1,12 +1,70 @@
|
|
|
1
1
|
import { CliServiceInterface } from "../cli/index.js";
|
|
2
|
+
import { ConfigApiService } from "../config-api/index.js";
|
|
3
|
+
import { CustomerConfig } from "../integration-api/index.js";
|
|
2
4
|
import { OriginRequestOptions } from "./origin-request-service-build-context.js";
|
|
3
|
-
import { OriginFetcher } from "./origin-fetcher.js";
|
|
4
5
|
import { ResolvedRequest } from "./asset-variations.js";
|
|
5
6
|
/**
|
|
6
7
|
* The headers as reported. Origin basic auth and the origin map's headers are sent, but their
|
|
7
8
|
* values are not printed: the runtime config stores credentials there, such as a bypass token.
|
|
8
9
|
*/
|
|
9
10
|
export declare function printable(headers: Record<string, string>, { originMapHeaders }: ResolvedRequest): Record<string, string>;
|
|
11
|
+
/** What the origin answered, and the request that was sent to get it. */
|
|
12
|
+
export interface OriginRequestResult {
|
|
13
|
+
outcome: "fetched";
|
|
14
|
+
variation: string;
|
|
15
|
+
/** Every variation the config defines, so a wrong guess is one call from right. */
|
|
16
|
+
variations: string[];
|
|
17
|
+
/** And the ones the server resolves regardless — a config often defines none. */
|
|
18
|
+
deviceDefaults: string[];
|
|
19
|
+
resolutionPath: "named" | "template";
|
|
20
|
+
appliedKeys: string[];
|
|
21
|
+
/** The `speedKit.originMap` entry the request was rewritten by, if any. */
|
|
22
|
+
originMapKey?: string;
|
|
23
|
+
requestUrl: string;
|
|
24
|
+
requestHeaders: Record<string, string>;
|
|
25
|
+
curl: string;
|
|
26
|
+
status: number;
|
|
27
|
+
statusText: string;
|
|
28
|
+
responseHeaders: Record<string, string>;
|
|
29
|
+
setCookie: string[];
|
|
30
|
+
body: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* A reason no request was sent, as data rather than a printed line.
|
|
34
|
+
*
|
|
35
|
+
* Every one of these is a thing the caller can act on — log in, pass a file,
|
|
36
|
+
* pick a variation that exists — so each carries what the next attempt needs.
|
|
37
|
+
* Discriminated by a string: `strict` is off in this project, and a boolean
|
|
38
|
+
* discriminant does not narrow under it.
|
|
39
|
+
*/
|
|
40
|
+
export type OriginRequestFailure = {
|
|
41
|
+
outcome: "config-unavailable";
|
|
42
|
+
message: string;
|
|
43
|
+
cause: string;
|
|
44
|
+
} | {
|
|
45
|
+
outcome: "unreadable-variations";
|
|
46
|
+
message: string;
|
|
47
|
+
file: string;
|
|
48
|
+
} | {
|
|
49
|
+
outcome: "unknown-variation";
|
|
50
|
+
message: string;
|
|
51
|
+
requested: string;
|
|
52
|
+
/** What the config defines. `*` is the wildcard and a template key is a regex. */
|
|
53
|
+
available: string[];
|
|
54
|
+
deviceDefaults: string[];
|
|
55
|
+
} | {
|
|
56
|
+
outcome: "bad-url";
|
|
57
|
+
message: string;
|
|
58
|
+
url: string;
|
|
59
|
+
base: string | null;
|
|
60
|
+
};
|
|
61
|
+
export type OriginRequestOutcome = OriginRequestResult | OriginRequestFailure;
|
|
62
|
+
/** The variations a customer's deployed config defines. */
|
|
63
|
+
export type VariationListOutcome = {
|
|
64
|
+
outcome: "variations";
|
|
65
|
+
variations: string[];
|
|
66
|
+
deviceDefaults: string[];
|
|
67
|
+
} | OriginRequestFailure;
|
|
10
68
|
/**
|
|
11
69
|
* Fetches a page from origin with exactly the headers Speed Kit's server would send for a cache
|
|
12
70
|
* variation, then reports what the origin answered.
|
|
@@ -15,6 +73,10 @@ export declare function printable(headers: Record<string, string>, { originMapHe
|
|
|
15
73
|
* — without waiting for a render or reading backend logs. The variations come from the app's
|
|
16
74
|
* deployed runtime config, so the simulation follows production rather than a local file.
|
|
17
75
|
*
|
|
76
|
+
* {@link run} renders for a terminal; {@link execute} returns the same work as data. The split
|
|
77
|
+
* keeps the failures typed: a failure a human reads as one line is an outcome a caller can branch
|
|
78
|
+
* on, and the tests read it that way.
|
|
79
|
+
*
|
|
18
80
|
* Known deviations from the server, all deliberate:
|
|
19
81
|
* - Revalidation headers (If-None-Match, If-Modified-Since) apply only when refreshing a cached
|
|
20
82
|
* entry, so they are out of scope.
|
|
@@ -23,12 +85,65 @@ export declare function printable(headers: Record<string, string>, { originMapHe
|
|
|
23
85
|
export declare class OriginRequestService {
|
|
24
86
|
private readonly context;
|
|
25
87
|
private readonly cli;
|
|
26
|
-
/** Absent
|
|
27
|
-
private readonly
|
|
88
|
+
/** Absent without a customer: there is no app to load a runtime config from. */
|
|
89
|
+
private readonly configApi;
|
|
90
|
+
private readonly customer?;
|
|
28
91
|
constructor(context: OriginRequestOptions, cli: CliServiceInterface,
|
|
29
|
-
/** Absent
|
|
30
|
-
|
|
31
|
-
/** False when
|
|
92
|
+
/** Absent without a customer: there is no app to load a runtime config from. */
|
|
93
|
+
configApi: ConfigApiService | undefined, customer?: CustomerConfig);
|
|
94
|
+
/** False when no request was sent, so the command can exit 2 like `sk diff`. */
|
|
32
95
|
run(): Promise<boolean>;
|
|
96
|
+
/**
|
|
97
|
+
* The request, as data.
|
|
98
|
+
*
|
|
99
|
+
* A failure comes back as an outcome rather than a thrown error, because
|
|
100
|
+
* every one of them is an ordinary answer to "can this be simulated" — not
|
|
101
|
+
* logged in, no variations configured, a variation that does not exist. Only
|
|
102
|
+
* a genuinely unexpected error still throws.
|
|
103
|
+
*/
|
|
104
|
+
execute(): Promise<OriginRequestOutcome>;
|
|
105
|
+
/**
|
|
106
|
+
* Which variations exist, without sending anything to the origin.
|
|
107
|
+
*
|
|
108
|
+
* The answer to "what do I pass as `variation`", which otherwise costs a
|
|
109
|
+
* request that is known in advance to be refused.
|
|
110
|
+
*/
|
|
111
|
+
listVariations(): Promise<VariationListOutcome>;
|
|
112
|
+
/**
|
|
113
|
+
* Resolves the requested page against the customer's own origin, so a path is enough.
|
|
114
|
+
*
|
|
115
|
+
* Normalised the way the control socket does, and for the same reason: `new URL(input, base)`
|
|
116
|
+
* parses the base first and throws when it is not absolute — even when the input is — and
|
|
117
|
+
* `domain` is a bare host in every `config_customer` that has one. Blaming the input for a base
|
|
118
|
+
* that was wrong already cost one testing session.
|
|
119
|
+
*
|
|
120
|
+
* `domain` is optional, and plenty of configs carry only `origins` — so a single origin serves as
|
|
121
|
+
* the base too. Several origins and no `domain` used to be refused outright: picking the first
|
|
122
|
+
* would be a guess, and a page fetched from the wrong one of a customer's origins answers like a
|
|
123
|
+
* real result.
|
|
124
|
+
*
|
|
125
|
+
* {@link OriginRequestOptions.base} is the way out of that, and it wins over both — a caller that
|
|
126
|
+
* supplies one knows something the config does not. For a run that is the origin it is actually
|
|
127
|
+
* driving, which is why `sk onboarding response` accepted `/sale` on a twelve-origin customer while this
|
|
128
|
+
* refused it: the same question, two answers, for no reason the caller could see.
|
|
129
|
+
*/
|
|
130
|
+
private absoluteUrl;
|
|
131
|
+
/**
|
|
132
|
+
* Reads `speedKit.variations` from the app's deployed runtime config, or from a local file when
|
|
133
|
+
* `--variations` is given.
|
|
134
|
+
*/
|
|
135
|
+
private loadVariations;
|
|
136
|
+
/**
|
|
137
|
+
* `--raw` without a customer: no app, so no runtime config. An empty set is the point here —
|
|
138
|
+
* only Speed Kit's device defaults resolve, and no origin basic auth is sent — which is the
|
|
139
|
+
* request `sk diff --raw` makes for a site that has no config yet.
|
|
140
|
+
*/
|
|
141
|
+
private noApp;
|
|
142
|
+
private fetchRuntimeConfig;
|
|
143
|
+
private readVariationsFile;
|
|
33
144
|
private report;
|
|
145
|
+
/** `--select`, counted and sampled: "did the origin send it" in one number. */
|
|
146
|
+
private selected;
|
|
147
|
+
/** `--grep`, case-insensitive as its flag says, each line windowed. */
|
|
148
|
+
private grepped;
|
|
34
149
|
}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import { writeFile } from "node:fs/promises";
|
|
1
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
2
|
+
import { safe } from "../../helpers/safe.js";
|
|
2
3
|
import { originFetch } from "../../helpers/origin-proxy.js";
|
|
3
|
-
import {
|
|
4
|
+
import { grepText, selectInHtml } from "../onboarding/control/body-inspect.js";
|
|
5
|
+
import ApplicationError from "../error-handling/error/application-error.js";
|
|
6
|
+
import { OriginFetcher } from "./origin-fetcher.js";
|
|
7
|
+
import { DEFAULT_TYPE, DEVICE_DEFAULT_TYPES, toCurl, } from "./asset-variations.js";
|
|
4
8
|
/** Standard request headers that carry no credentials, so an origin map value stays visible. */
|
|
5
9
|
const PLAIN_HEADERS = new Set([
|
|
6
10
|
"accept",
|
|
@@ -38,6 +42,10 @@ export function printable(headers, { originMapHeaders = [] }) {
|
|
|
38
42
|
* — without waiting for a render or reading backend logs. The variations come from the app's
|
|
39
43
|
* deployed runtime config, so the simulation follows production rather than a local file.
|
|
40
44
|
*
|
|
45
|
+
* {@link run} renders for a terminal; {@link execute} returns the same work as data. The split
|
|
46
|
+
* keeps the failures typed: a failure a human reads as one line is an outcome a caller can branch
|
|
47
|
+
* on, and the tests read it that way.
|
|
48
|
+
*
|
|
41
49
|
* Known deviations from the server, all deliberate:
|
|
42
50
|
* - Revalidation headers (If-None-Match, If-Modified-Since) apply only when refreshing a cached
|
|
43
51
|
* entry, so they are out of scope.
|
|
@@ -46,72 +54,288 @@ export function printable(headers, { originMapHeaders = [] }) {
|
|
|
46
54
|
export class OriginRequestService {
|
|
47
55
|
context;
|
|
48
56
|
cli;
|
|
49
|
-
|
|
57
|
+
configApi;
|
|
58
|
+
customer;
|
|
50
59
|
constructor(context, cli,
|
|
51
|
-
/** Absent
|
|
52
|
-
|
|
60
|
+
/** Absent without a customer: there is no app to load a runtime config from. */
|
|
61
|
+
configApi, customer) {
|
|
53
62
|
this.context = context;
|
|
54
63
|
this.cli = cli;
|
|
55
|
-
this.
|
|
64
|
+
this.configApi = configApi;
|
|
65
|
+
this.customer = customer;
|
|
56
66
|
}
|
|
57
|
-
/** False when
|
|
67
|
+
/** False when no request was sent, so the command can exit 2 like `sk diff`. */
|
|
58
68
|
async run() {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
69
|
+
const result = await this.execute();
|
|
70
|
+
if (result.outcome !== "fetched") {
|
|
71
|
+
// `--variations` is this command's flag, so the hint is added here rather
|
|
72
|
+
// than carried in the outcome, which names what happened and not what to
|
|
73
|
+
// type.
|
|
74
|
+
this.cli.writeError(result.outcome === "config-unavailable"
|
|
75
|
+
? `${result.message} Or pass --variations <file> to simulate against a config you already have.`
|
|
76
|
+
: result.message);
|
|
62
77
|
return false;
|
|
63
|
-
|
|
64
|
-
const { url, init, resolved } = this.fetcher.prepare(this.context.pageUrl, this.context.variation);
|
|
65
|
-
const headers = printable(init.headers, resolved);
|
|
66
|
-
const response = await originFetch(url, { ...init, redirect: "manual" });
|
|
67
|
-
const body = await response.text();
|
|
68
|
-
const setCookies = response.headers.getSetCookie?.() ?? [];
|
|
78
|
+
}
|
|
69
79
|
if (this.context.bodyFile)
|
|
70
|
-
await writeFile(this.context.bodyFile, body);
|
|
80
|
+
await writeFile(this.context.bodyFile, result.body);
|
|
71
81
|
if (this.context.json) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
// The payload channel, so `--json > file` gets the document and nothing
|
|
83
|
+
// the CLI had to say about it.
|
|
84
|
+
this.cli.pipe(`${JSON.stringify({
|
|
85
|
+
variation: result.variation,
|
|
86
|
+
resolutionPath: result.resolutionPath,
|
|
87
|
+
appliedConfigs: result.appliedKeys,
|
|
88
|
+
originMapKey: result.originMapKey ?? null,
|
|
89
|
+
requestUrl: result.requestUrl,
|
|
90
|
+
requestHeaders: result.requestHeaders,
|
|
91
|
+
status: result.status,
|
|
92
|
+
responseHeaders: result.responseHeaders,
|
|
93
|
+
setCookie: result.setCookie,
|
|
94
|
+
bodyLength: result.body.length,
|
|
95
|
+
bodyFile: this.context.bodyFile,
|
|
96
|
+
curl: result.curl,
|
|
97
|
+
select: this.selected(result.body),
|
|
98
|
+
grep: this.grepped(result.body),
|
|
99
|
+
}, null, 2)}\n`);
|
|
84
100
|
return true;
|
|
85
101
|
}
|
|
86
|
-
this.report(
|
|
102
|
+
this.report(result);
|
|
87
103
|
return true;
|
|
88
104
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
105
|
+
/**
|
|
106
|
+
* The request, as data.
|
|
107
|
+
*
|
|
108
|
+
* A failure comes back as an outcome rather than a thrown error, because
|
|
109
|
+
* every one of them is an ordinary answer to "can this be simulated" — not
|
|
110
|
+
* logged in, no variations configured, a variation that does not exist. Only
|
|
111
|
+
* a genuinely unexpected error still throws.
|
|
112
|
+
*/
|
|
113
|
+
async execute() {
|
|
114
|
+
const loaded = await this.loadVariations();
|
|
115
|
+
// Without variations every request would resolve to the bare defaults, so the report would
|
|
116
|
+
// describe a request the server never sends. Stop instead of simulating something wrong.
|
|
117
|
+
if (loaded.outcome !== "loaded")
|
|
118
|
+
return loaded;
|
|
119
|
+
const variations = loaded.variations;
|
|
120
|
+
const variation = this.context.variation ?? DEFAULT_TYPE;
|
|
121
|
+
const pageUrl = this.absoluteUrl();
|
|
122
|
+
if (typeof pageUrl !== "string")
|
|
123
|
+
return pageUrl;
|
|
124
|
+
const fetcher = new OriginFetcher({
|
|
125
|
+
cli: this.cli,
|
|
126
|
+
config: {
|
|
127
|
+
variations,
|
|
128
|
+
authentications: loaded.authentications,
|
|
129
|
+
originMap: loaded.originMap,
|
|
130
|
+
},
|
|
131
|
+
host: this.context.host,
|
|
132
|
+
strict: true,
|
|
133
|
+
});
|
|
134
|
+
let prepared;
|
|
135
|
+
try {
|
|
136
|
+
prepared = fetcher.prepare(pageUrl, this.context.variation);
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
// Strict, the fetcher throws only for a variation the config does not define.
|
|
140
|
+
if (error instanceof ApplicationError) {
|
|
141
|
+
return {
|
|
142
|
+
outcome: "unknown-variation",
|
|
143
|
+
message: error.message,
|
|
144
|
+
requested: variation,
|
|
145
|
+
available: Object.keys(variations),
|
|
146
|
+
deviceDefaults: DEVICE_DEFAULT_TYPES,
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
throw error;
|
|
150
|
+
}
|
|
151
|
+
const { url, init, resolved } = prepared;
|
|
152
|
+
const headers = printable(init.headers, resolved);
|
|
153
|
+
const response = await originFetch(url, { ...init, redirect: "manual" });
|
|
154
|
+
const body = await response.text();
|
|
155
|
+
return {
|
|
156
|
+
outcome: "fetched",
|
|
157
|
+
variation,
|
|
158
|
+
variations: Object.keys(variations),
|
|
159
|
+
deviceDefaults: DEVICE_DEFAULT_TYPES,
|
|
160
|
+
resolutionPath: resolved.resolutionPath,
|
|
161
|
+
appliedKeys: resolved.appliedKeys,
|
|
162
|
+
originMapKey: resolved.originMapKey,
|
|
163
|
+
requestUrl: url,
|
|
164
|
+
requestHeaders: headers,
|
|
165
|
+
curl: toCurl(url, headers),
|
|
166
|
+
status: response.status,
|
|
167
|
+
statusText: response.statusText,
|
|
168
|
+
responseHeaders: Object.fromEntries(response.headers),
|
|
169
|
+
setCookie: response.headers.getSetCookie?.() ?? [],
|
|
170
|
+
body,
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Which variations exist, without sending anything to the origin.
|
|
175
|
+
*
|
|
176
|
+
* The answer to "what do I pass as `variation`", which otherwise costs a
|
|
177
|
+
* request that is known in advance to be refused.
|
|
178
|
+
*/
|
|
179
|
+
async listVariations() {
|
|
180
|
+
const loaded = await this.loadVariations();
|
|
181
|
+
if (loaded.outcome !== "loaded")
|
|
182
|
+
return loaded;
|
|
183
|
+
return {
|
|
184
|
+
outcome: "variations",
|
|
185
|
+
variations: Object.keys(loaded.variations),
|
|
186
|
+
deviceDefaults: DEVICE_DEFAULT_TYPES,
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Resolves the requested page against the customer's own origin, so a path is enough.
|
|
191
|
+
*
|
|
192
|
+
* Normalised the way the control socket does, and for the same reason: `new URL(input, base)`
|
|
193
|
+
* parses the base first and throws when it is not absolute — even when the input is — and
|
|
194
|
+
* `domain` is a bare host in every `config_customer` that has one. Blaming the input for a base
|
|
195
|
+
* that was wrong already cost one testing session.
|
|
196
|
+
*
|
|
197
|
+
* `domain` is optional, and plenty of configs carry only `origins` — so a single origin serves as
|
|
198
|
+
* the base too. Several origins and no `domain` used to be refused outright: picking the first
|
|
199
|
+
* would be a guess, and a page fetched from the wrong one of a customer's origins answers like a
|
|
200
|
+
* real result.
|
|
201
|
+
*
|
|
202
|
+
* {@link OriginRequestOptions.base} is the way out of that, and it wins over both — a caller that
|
|
203
|
+
* supplies one knows something the config does not. For a run that is the origin it is actually
|
|
204
|
+
* driving, which is why `sk onboarding response` accepted `/sale` on a twelve-origin customer while this
|
|
205
|
+
* refused it: the same question, two answers, for no reason the caller could see.
|
|
206
|
+
*/
|
|
207
|
+
absoluteUrl() {
|
|
208
|
+
const origins = this.customer?.origins ?? [];
|
|
209
|
+
const named = this.context.base ||
|
|
210
|
+
this.customer?.domain ||
|
|
211
|
+
(origins.length === 1 && origins[0]);
|
|
212
|
+
const base = named && !/^https?:\/\//.test(named) ? `https://${named}` : named;
|
|
213
|
+
try {
|
|
214
|
+
return new URL(this.context.pageUrl, base || undefined).toString();
|
|
215
|
+
}
|
|
216
|
+
catch {
|
|
217
|
+
return {
|
|
218
|
+
outcome: "bad-url",
|
|
219
|
+
message: base
|
|
220
|
+
? `"${this.context.pageUrl}" is not a url, absolute or relative to ${base}`
|
|
221
|
+
: origins.length > 1
|
|
222
|
+
? `"${this.context.pageUrl}" is not an absolute url, and this config names no domain and ${origins.length} origins — say which: ${origins.join(", ")}`
|
|
223
|
+
: `"${this.context.pageUrl}" is not an absolute url, and no customer config was available to resolve it against`,
|
|
224
|
+
url: this.context.pageUrl,
|
|
225
|
+
base: base || null,
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Reads `speedKit.variations` from the app's deployed runtime config, or from a local file when
|
|
231
|
+
* `--variations` is given.
|
|
232
|
+
*/
|
|
233
|
+
async loadVariations() {
|
|
234
|
+
if (!this.configApi && !this.context.variationsFile)
|
|
235
|
+
return this.noApp();
|
|
236
|
+
const raw = this.context.variationsFile
|
|
237
|
+
? await this.readVariationsFile(this.context.variationsFile)
|
|
238
|
+
: await this.fetchRuntimeConfig();
|
|
239
|
+
if (typeof raw !== "string")
|
|
240
|
+
return raw;
|
|
241
|
+
const parsed = JSON.parse(raw);
|
|
242
|
+
// An empty variation set still runs: device defaults resolve, originMap and authentications apply.
|
|
243
|
+
const variations = parsed.speedKit?.variations ?? parsed.variations ?? {};
|
|
244
|
+
const authentications = (parsed.speedKit ?? parsed).authentications ?? [];
|
|
245
|
+
const originMap = (parsed.speedKit ?? parsed).originMap ?? {};
|
|
246
|
+
// Narration, so never under --json: stdout is the document there.
|
|
247
|
+
if (!this.context.json && Object.keys(variations).length > 0) {
|
|
248
|
+
this.cli.writeSuccess(`variations: ${Object.keys(variations).join(", ")}`);
|
|
249
|
+
}
|
|
250
|
+
return { outcome: "loaded", variations, authentications, originMap };
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* `--raw` without a customer: no app, so no runtime config. An empty set is the point here —
|
|
254
|
+
* only Speed Kit's device defaults resolve, and no origin basic auth is sent — which is the
|
|
255
|
+
* request `sk diff --raw` makes for a site that has no config yet.
|
|
256
|
+
*/
|
|
257
|
+
noApp() {
|
|
258
|
+
if (!this.context.json) {
|
|
259
|
+
this.cli.writeWarning("no customer: the request carries Speed Kit's device defaults only, no variation of an app");
|
|
260
|
+
}
|
|
261
|
+
return {
|
|
262
|
+
outcome: "loaded",
|
|
263
|
+
variations: {},
|
|
264
|
+
authentications: [],
|
|
265
|
+
originMap: {},
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
async fetchRuntimeConfig() {
|
|
269
|
+
this.cli.startAction("ORIGIN_REQUEST:FETCH:RUNTIME_CONFIG", "load variations from the app");
|
|
270
|
+
const serverConfig = await safe(this.configApi.getServerConfig());
|
|
271
|
+
if (serverConfig.success === false) {
|
|
272
|
+
this.cli.failAction("ORIGIN_REQUEST:FETCH:RUNTIME_CONFIG");
|
|
273
|
+
return {
|
|
274
|
+
outcome: "config-unavailable",
|
|
275
|
+
message: `unable to load the runtime config: ${serverConfig.error}. Run "sk login" and try again.`,
|
|
276
|
+
cause: String(serverConfig.error),
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
this.cli.successAction("ORIGIN_REQUEST:FETCH:RUNTIME_CONFIG");
|
|
280
|
+
return serverConfig.data;
|
|
281
|
+
}
|
|
282
|
+
async readVariationsFile(file) {
|
|
283
|
+
const content = await safe(readFile(file, "utf8"));
|
|
284
|
+
if (content.success === false) {
|
|
285
|
+
return {
|
|
286
|
+
outcome: "unreadable-variations",
|
|
287
|
+
message: `unable to read ${file}: ${content.error}`,
|
|
288
|
+
file,
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
this.cli.writeSuccess(`variations from ${file}`);
|
|
292
|
+
return content.data;
|
|
293
|
+
}
|
|
294
|
+
report(result) {
|
|
295
|
+
this.cli.write(`variation ${result.variation}`);
|
|
296
|
+
this.cli.write(`resolution ${result.resolutionPath} → applied: ${result.appliedKeys.join(" then ")}`);
|
|
297
|
+
if (result.originMapKey)
|
|
298
|
+
this.cli.write(`origin map ${result.originMapKey}`);
|
|
299
|
+
this.cli.write(`request url ${result.requestUrl}`);
|
|
95
300
|
this.cli.write("request headers");
|
|
96
|
-
for (const [key, value] of Object.entries(
|
|
301
|
+
for (const [key, value] of Object.entries(result.requestHeaders))
|
|
97
302
|
this.cli.write(` ${key}: ${value}`);
|
|
98
|
-
this.cli.write(`\nstatus ${
|
|
99
|
-
const location =
|
|
303
|
+
this.cli.write(`\nstatus ${result.status} ${result.statusText}`);
|
|
304
|
+
const location = result.responseHeaders.location;
|
|
100
305
|
if (location)
|
|
101
306
|
this.cli.write(`location ${location}`);
|
|
102
|
-
if (
|
|
307
|
+
if (result.setCookie.length) {
|
|
103
308
|
this.cli.write("set-cookie");
|
|
104
|
-
for (const cookie of
|
|
309
|
+
for (const cookie of result.setCookie)
|
|
105
310
|
this.cli.write(` ${cookie}`);
|
|
106
311
|
}
|
|
107
|
-
this.cli.write(`body ${body.length} bytes${this.context.bodyFile ? ` → ${this.context.bodyFile}` : ""}`);
|
|
108
|
-
this.cli.write(`\nequivalent curl:\n${
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
312
|
+
this.cli.write(`body ${result.body.length} bytes${this.context.bodyFile ? ` → ${this.context.bodyFile}` : ""}`);
|
|
313
|
+
this.cli.write(`\nequivalent curl:\n${result.curl}`);
|
|
314
|
+
const selected = this.selected(result.body);
|
|
315
|
+
if (selected) {
|
|
316
|
+
this.cli.write(selected.error
|
|
317
|
+
? `\nselect "${selected.selector}" → rejected: ${selected.error}`
|
|
318
|
+
: `\nselect "${selected.selector}" → ${selected.count} match(es)`);
|
|
319
|
+
for (const match of selected.matches)
|
|
320
|
+
this.cli.write(` ${match}`);
|
|
115
321
|
}
|
|
322
|
+
const grepped = this.grepped(result.body);
|
|
323
|
+
if (grepped) {
|
|
324
|
+
this.cli.write(`\ngrep "${grepped.pattern}" → ${grepped.count} line(s)`);
|
|
325
|
+
for (const match of grepped.matches)
|
|
326
|
+
this.cli.write(` ${match.line}: ${match.text}`);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
/** `--select`, counted and sampled: "did the origin send it" in one number. */
|
|
330
|
+
selected(body) {
|
|
331
|
+
return this.context.select
|
|
332
|
+
? selectInHtml(body, this.context.select, this.context.maxMatches)
|
|
333
|
+
: undefined;
|
|
334
|
+
}
|
|
335
|
+
/** `--grep`, case-insensitive as its flag says, each line windowed. */
|
|
336
|
+
grepped(body) {
|
|
337
|
+
return this.context.grep
|
|
338
|
+
? grepText(body, this.context.grep, this.context.maxMatches, "i")
|
|
339
|
+
: undefined;
|
|
116
340
|
}
|
|
117
341
|
}
|
|
@@ -15,6 +15,12 @@ export interface OriginRequestConfig {
|
|
|
15
15
|
/** `speedKit.originMap`: per origin, a rewrite target and extra headers. */
|
|
16
16
|
readonly originMap: OriginMap;
|
|
17
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* What a session without the runtime config loses. Everything the runtime config alone carries
|
|
20
|
+
* is gone, including any override of a device variation; those still resolve from their
|
|
21
|
+
* built-in defaults only.
|
|
22
|
+
*/
|
|
23
|
+
export declare const NO_RUNTIME_CONFIG_WARNING = "without the runtime config, origin fetches carry no basic auth, no custom variation and no configured override of default, mobile or tablet \u2014 those fall back to the built-in defaults.";
|
|
18
24
|
/** What loading the runtime config reports through. */
|
|
19
25
|
export type RuntimeConfigLog = Pick<CliServiceInterface, "writeError" | "writeSuccess" | "startAction" | "successAction" | "failAction">;
|
|
20
26
|
export interface RuntimeConfigSourceDeps {
|