@noodleseed/one 0.22.0 → 0.24.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/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +2 -1
- package/dist/cli.js.map +1 -1
- package/dist/commands/author-loop.d.ts +1 -0
- package/dist/commands/author-loop.d.ts.map +1 -1
- package/dist/commands/author-loop.js +6 -2
- package/dist/commands/author-loop.js.map +1 -1
- package/dist/commands/catalog-data-core.d.ts.map +1 -1
- package/dist/commands/catalog-data-core.js +17 -3
- package/dist/commands/catalog-data-core.js.map +1 -1
- package/dist/commands/catalog-data-resources.js +2 -2
- package/dist/commands/catalog-data-resources.js.map +1 -1
- package/dist/commands/catalog-dispatch.d.ts.map +1 -1
- package/dist/commands/catalog-dispatch.js +21 -2
- package/dist/commands/catalog-dispatch.js.map +1 -1
- package/dist/commands/catalog-render.d.ts.map +1 -1
- package/dist/commands/catalog-render.js +6 -0
- package/dist/commands/catalog-render.js.map +1 -1
- package/dist/commands/deploy-ops.d.ts.map +1 -1
- package/dist/commands/deploy-ops.js +30 -13
- package/dist/commands/deploy-ops.js.map +1 -1
- package/dist/commands/deploy-status-ops.d.ts +1 -1
- package/dist/commands/deploy-status-ops.d.ts.map +1 -1
- package/dist/commands/deploy-status-ops.js +8 -4
- package/dist/commands/deploy-status-ops.js.map +1 -1
- package/dist/commands/devtools.d.ts +11 -0
- package/dist/commands/devtools.d.ts.map +1 -0
- package/dist/commands/devtools.js +123 -0
- package/dist/commands/devtools.js.map +1 -0
- package/dist/commands/mcp-apps.d.ts +0 -1
- package/dist/commands/mcp-apps.d.ts.map +1 -1
- package/dist/commands/mcp-apps.js +71 -122
- package/dist/commands/mcp-apps.js.map +1 -1
- package/dist/commands/shared.d.ts +6 -0
- package/dist/commands/shared.d.ts.map +1 -1
- package/dist/commands/shared.js +19 -0
- package/dist/commands/shared.js.map +1 -1
- package/dist/deploy.d.ts +1 -1
- package/dist/deploy.d.ts.map +1 -1
- package/dist/deploy.js +5 -1
- package/dist/deploy.js.map +1 -1
- package/dist/dev.d.ts.map +1 -1
- package/dist/dev.js +13 -1
- package/dist/dev.js.map +1 -1
- package/dist/fire.js +1 -1
- package/dist/fire.js.map +1 -1
- package/dist/first-run.d.ts +11 -0
- package/dist/first-run.d.ts.map +1 -1
- package/dist/first-run.js +19 -4
- package/dist/first-run.js.map +1 -1
- package/dist/flavor.d.ts +1 -1
- package/dist/flavor.d.ts.map +1 -1
- package/dist/flavor.js +12 -2
- package/dist/flavor.js.map +1 -1
- package/dist/project-scaffold-templates.d.ts +11 -0
- package/dist/project-scaffold-templates.d.ts.map +1 -0
- package/dist/project-scaffold-templates.js +359 -0
- package/dist/project-scaffold-templates.js.map +1 -0
- package/dist/project.d.ts.map +1 -1
- package/dist/project.js +1 -323
- package/dist/project.js.map +1 -1
- package/dist/react.d.ts +2 -2
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +1 -1
- package/dist/react.js.map +1 -1
- package/dist/validate.d.ts +12 -0
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +11 -0
- package/dist/validate.js.map +1 -1
- package/node_modules/@noodle-borg/agent-kit/dist/skill-authoring-refs.js +4 -4
- package/node_modules/@noodle-borg/agent-kit/dist/skill-authoring-refs.js.map +1 -1
- package/node_modules/@noodle-borg/agent-kit/dist/skill-content.d.ts.map +1 -1
- package/node_modules/@noodle-borg/agent-kit/dist/skill-content.js +72 -13
- package/node_modules/@noodle-borg/agent-kit/dist/skill-content.js.map +1 -1
- package/node_modules/@noodle-borg/agent-kit/dist/skill-operations-refs.d.ts.map +1 -1
- package/node_modules/@noodle-borg/agent-kit/dist/skill-operations-refs.js +8 -3
- package/node_modules/@noodle-borg/agent-kit/dist/skill-operations-refs.js.map +1 -1
- package/node_modules/@noodle-borg/agent-kit/package.json +1 -1
- package/node_modules/@noodle-borg/authoring/dist/connectors.d.ts +18 -1
- package/node_modules/@noodle-borg/authoring/dist/connectors.d.ts.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/connectors.js +17 -4
- package/node_modules/@noodle-borg/authoring/dist/connectors.js.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/index.d.ts +3 -3
- package/node_modules/@noodle-borg/authoring/dist/index.d.ts.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/index.js +1 -1
- package/node_modules/@noodle-borg/authoring/dist/index.js.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/react/components.d.ts +302 -7
- package/node_modules/@noodle-borg/authoring/dist/react/components.d.ts.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/react/components.js +39 -7
- package/node_modules/@noodle-borg/authoring/dist/react/components.js.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/react/index.d.ts +4 -2
- package/node_modules/@noodle-borg/authoring/dist/react/index.d.ts.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/react/index.js +2 -1
- package/node_modules/@noodle-borg/authoring/dist/react/index.js.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/react/semantic-components.d.ts +2618 -0
- package/node_modules/@noodle-borg/authoring/dist/react/semantic-components.d.ts.map +1 -0
- package/node_modules/@noodle-borg/authoring/dist/react/semantic-components.js +110 -0
- package/node_modules/@noodle-borg/authoring/dist/react/semantic-components.js.map +1 -0
- package/node_modules/@noodle-borg/authoring/dist/react.d.ts +2 -2
- package/node_modules/@noodle-borg/authoring/dist/react.d.ts.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/react.js +1 -1
- package/node_modules/@noodle-borg/authoring/dist/react.js.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/recording.d.ts +1 -1
- package/node_modules/@noodle-borg/authoring/dist/recording.d.ts.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/recording.js +38 -6
- package/node_modules/@noodle-borg/authoring/dist/recording.js.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/server.d.ts +25 -2
- package/node_modules/@noodle-borg/authoring/dist/server.d.ts.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/server.js +64 -6
- package/node_modules/@noodle-borg/authoring/dist/server.js.map +1 -1
- package/node_modules/@noodle-borg/compiler/dist/compile.d.ts.map +1 -1
- package/node_modules/@noodle-borg/compiler/dist/compile.js +20 -8
- package/node_modules/@noodle-borg/compiler/dist/compile.js.map +1 -1
- package/node_modules/@noodle-borg/compiler/dist/manifest/schema.d.ts +2 -0
- package/node_modules/@noodle-borg/compiler/dist/manifest/schema.d.ts.map +1 -1
- package/node_modules/@noodle-borg/compiler/dist/manifest/schema.js +6 -0
- package/node_modules/@noodle-borg/compiler/dist/manifest/schema.js.map +1 -1
- package/node_modules/@noodle-borg/connector-defs/dist/auth-variables.js +1 -1
- package/node_modules/@noodle-borg/connector-defs/dist/auth-variables.js.map +1 -1
- package/node_modules/@noodle-borg/connector-defs/dist/call-graph.d.ts +14 -0
- package/node_modules/@noodle-borg/connector-defs/dist/call-graph.d.ts.map +1 -0
- package/node_modules/@noodle-borg/connector-defs/dist/call-graph.js +66 -0
- package/node_modules/@noodle-borg/connector-defs/dist/call-graph.js.map +1 -0
- package/node_modules/@noodle-borg/connector-defs/dist/compile-auth.d.ts +21 -0
- package/node_modules/@noodle-borg/connector-defs/dist/compile-auth.d.ts.map +1 -0
- package/node_modules/@noodle-borg/connector-defs/dist/compile-auth.js +102 -0
- package/node_modules/@noodle-borg/connector-defs/dist/compile-auth.js.map +1 -0
- package/node_modules/@noodle-borg/connector-defs/dist/compile.d.ts +19 -4
- package/node_modules/@noodle-borg/connector-defs/dist/compile.d.ts.map +1 -1
- package/node_modules/@noodle-borg/connector-defs/dist/compile.js +67 -99
- package/node_modules/@noodle-borg/connector-defs/dist/compile.js.map +1 -1
- package/node_modules/@noodle-borg/connector-defs/dist/index.d.ts +1 -1
- package/node_modules/@noodle-borg/connector-defs/dist/index.d.ts.map +1 -1
- package/node_modules/@noodle-borg/connector-defs/dist/index.js.map +1 -1
- package/node_modules/@noodle-borg/connector-defs/dist/schema.d.ts +168 -10
- package/node_modules/@noodle-borg/connector-defs/dist/schema.d.ts.map +1 -1
- package/node_modules/@noodle-borg/connector-defs/dist/schema.js +72 -5
- package/node_modules/@noodle-borg/connector-defs/dist/schema.js.map +1 -1
- package/node_modules/@noodle-borg/connector-http/dist/http-connector.d.ts +6 -0
- package/node_modules/@noodle-borg/connector-http/dist/http-connector.d.ts.map +1 -1
- package/node_modules/@noodle-borg/connector-http/dist/http-connector.js +2 -0
- package/node_modules/@noodle-borg/connector-http/dist/http-connector.js.map +1 -1
- package/node_modules/@noodle-borg/connector-http/package.json +1 -1
- package/node_modules/@noodle-borg/protocol/dist/mapping.d.ts.map +1 -1
- package/node_modules/@noodle-borg/protocol/dist/mapping.js +8 -0
- package/node_modules/@noodle-borg/protocol/dist/mapping.js.map +1 -1
- package/node_modules/@noodle-borg/runtime/dist/execute.d.ts.map +1 -1
- package/node_modules/@noodle-borg/runtime/dist/execute.js +87 -62
- package/node_modules/@noodle-borg/runtime/dist/execute.js.map +1 -1
- package/node_modules/@noodle-borg/runtime/dist/result.d.ts +1 -1
- package/node_modules/@noodle-borg/runtime/dist/result.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/credential-broker.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/credential-broker.js +113 -11
- package/node_modules/@noodle-borg/service/dist/credential-broker.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/github/app-client.d.ts +28 -5
- package/node_modules/@noodle-borg/service/dist/github/app-client.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/github/app-client.js +116 -7
- package/node_modules/@noodle-borg/service/dist/github/app-client.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/github/builder-auth.d.ts +12 -0
- package/node_modules/@noodle-borg/service/dist/github/builder-auth.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/github/builder-auth.js +15 -0
- package/node_modules/@noodle-borg/service/dist/github/builder-auth.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/github/builder-main.d.ts +3 -0
- package/node_modules/@noodle-borg/service/dist/github/builder-main.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/github/builder-main.js +9 -0
- package/node_modules/@noodle-borg/service/dist/github/builder-main.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/github/builder-runner.d.ts +21 -0
- package/node_modules/@noodle-borg/service/dist/github/builder-runner.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/github/builder-runner.js +192 -0
- package/node_modules/@noodle-borg/service/dist/github/builder-runner.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/github/cloud-run-job-executor.d.ts +45 -0
- package/node_modules/@noodle-borg/service/dist/github/cloud-run-job-executor.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/github/cloud-run-job-executor.js +60 -0
- package/node_modules/@noodle-borg/service/dist/github/cloud-run-job-executor.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/github/deploy-pipeline.d.ts +64 -0
- package/node_modules/@noodle-borg/service/dist/github/deploy-pipeline.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/github/deploy-pipeline.js +121 -0
- package/node_modules/@noodle-borg/service/dist/github/deploy-pipeline.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/github/deploy-run-executor.d.ts +33 -0
- package/node_modules/@noodle-borg/service/dist/github/deploy-run-executor.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/github/deploy-run-executor.js +14 -0
- package/node_modules/@noodle-borg/service/dist/github/deploy-run-executor.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/github/deploy-run-reconciler.d.ts +36 -0
- package/node_modules/@noodle-borg/service/dist/github/deploy-run-reconciler.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/github/deploy-run-reconciler.js +107 -0
- package/node_modules/@noodle-borg/service/dist/github/deploy-run-reconciler.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/github/fast-lane-classifier.d.ts +38 -0
- package/node_modules/@noodle-borg/service/dist/github/fast-lane-classifier.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/github/fast-lane-classifier.js +60 -0
- package/node_modules/@noodle-borg/service/dist/github/fast-lane-classifier.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/github/local-compile.d.ts +24 -0
- package/node_modules/@noodle-borg/service/dist/github/local-compile.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/github/local-compile.js +98 -0
- package/node_modules/@noodle-borg/service/dist/github/local-compile.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/github/local-process-executor.d.ts +39 -0
- package/node_modules/@noodle-borg/service/dist/github/local-process-executor.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/github/local-process-executor.js +67 -0
- package/node_modules/@noodle-borg/service/dist/github/local-process-executor.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/github/run-access-mode.d.ts +18 -0
- package/node_modules/@noodle-borg/service/dist/github/run-access-mode.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/github/run-access-mode.js +32 -0
- package/node_modules/@noodle-borg/service/dist/github/run-access-mode.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/github/run-token.d.ts +41 -0
- package/node_modules/@noodle-borg/service/dist/github/run-token.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/github/run-token.js +59 -0
- package/node_modules/@noodle-borg/service/dist/github/run-token.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/http-util.d.ts +7 -1
- package/node_modules/@noodle-borg/service/dist/http-util.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/http-util.js +14 -0
- package/node_modules/@noodle-borg/service/dist/http-util.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/index.d.ts +13 -2
- package/node_modules/@noodle-borg/service/dist/index.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/index.js +12 -1
- package/node_modules/@noodle-borg/service/dist/index.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/main.js +72 -0
- package/node_modules/@noodle-borg/service/dist/main.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/options.d.ts +26 -3
- package/node_modules/@noodle-borg/service/dist/options.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/registry-helpers.d.ts +12 -0
- package/node_modules/@noodle-borg/service/dist/registry-helpers.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/registry-helpers.js +3 -0
- package/node_modules/@noodle-borg/service/dist/registry-helpers.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/registry-types.d.ts +7 -0
- package/node_modules/@noodle-borg/service/dist/registry-types.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/registry.d.ts +7 -29
- package/node_modules/@noodle-borg/service/dist/registry.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/registry.js +62 -57
- package/node_modules/@noodle-borg/service/dist/registry.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/routes/asset-control-plane.d.ts +3 -2
- package/node_modules/@noodle-borg/service/dist/routes/asset-control-plane.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/routes/asset-control-plane.js +36 -8
- package/node_modules/@noodle-borg/service/dist/routes/asset-control-plane.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/routes/control-plane.d.ts +3 -2
- package/node_modules/@noodle-borg/service/dist/routes/control-plane.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/routes/control-plane.js +100 -12
- package/node_modules/@noodle-borg/service/dist/routes/control-plane.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/routes/github-dispatch.d.ts +7 -0
- package/node_modules/@noodle-borg/service/dist/routes/github-dispatch.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/routes/github-dispatch.js +36 -1
- package/node_modules/@noodle-borg/service/dist/routes/github-dispatch.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/routes/github-run-claim.d.ts +13 -0
- package/node_modules/@noodle-borg/service/dist/routes/github-run-claim.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/routes/github-run-claim.js +84 -0
- package/node_modules/@noodle-borg/service/dist/routes/github-run-claim.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/routes/github-run-status.d.ts +5 -0
- package/node_modules/@noodle-borg/service/dist/routes/github-run-status.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/routes/github-run-status.js +73 -0
- package/node_modules/@noodle-borg/service/dist/routes/github-run-status.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/routes/github-webhook.d.ts +23 -1
- package/node_modules/@noodle-borg/service/dist/routes/github-webhook.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/routes/github-webhook.js +41 -0
- package/node_modules/@noodle-borg/service/dist/routes/github-webhook.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/routes/paths.d.ts +4 -0
- package/node_modules/@noodle-borg/service/dist/routes/paths.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/routes/paths.js +10 -0
- package/node_modules/@noodle-borg/service/dist/routes/paths.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/routes/run-deploy-auth.d.ts +85 -0
- package/node_modules/@noodle-borg/service/dist/routes/run-deploy-auth.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/routes/run-deploy-auth.js +90 -0
- package/node_modules/@noodle-borg/service/dist/routes/run-deploy-auth.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/serve.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/serve.js +31 -0
- package/node_modules/@noodle-borg/service/dist/serve.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/service.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/service.js +8 -13
- package/node_modules/@noodle-borg/service/dist/service.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/store/github-connections-json-file.d.ts +1 -0
- package/node_modules/@noodle-borg/service/dist/store/github-connections-json-file.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/store/github-connections-json-file.js +5 -0
- package/node_modules/@noodle-borg/service/dist/store/github-connections-json-file.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/store/github-connections.d.ts +1 -0
- package/node_modules/@noodle-borg/service/dist/store/github-connections.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/store/github-connections.js +5 -0
- package/node_modules/@noodle-borg/service/dist/store/github-connections.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/store/github-deploy-run-contract.d.ts +120 -0
- package/node_modules/@noodle-borg/service/dist/store/github-deploy-run-contract.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/store/github-deploy-run-contract.js +6 -0
- package/node_modules/@noodle-borg/service/dist/store/github-deploy-run-contract.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/store/github-runs-json-file.d.ts +6 -1
- package/node_modules/@noodle-borg/service/dist/store/github-runs-json-file.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/store/github-runs-json-file.js +18 -1
- package/node_modules/@noodle-borg/service/dist/store/github-runs-json-file.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/store/github-runs.d.ts +22 -1
- package/node_modules/@noodle-borg/service/dist/store/github-runs.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/store/github-runs.js +39 -2
- package/node_modules/@noodle-borg/service/dist/store/github-runs.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/store/postgres-github-runs.d.ts +13 -1
- package/node_modules/@noodle-borg/service/dist/store/postgres-github-runs.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/store/postgres-github-runs.js +115 -1
- package/node_modules/@noodle-borg/service/dist/store/postgres-github-runs.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/store/postgres-github.d.ts +1 -0
- package/node_modules/@noodle-borg/service/dist/store/postgres-github.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/store/postgres-github.js +6 -0
- package/node_modules/@noodle-borg/service/dist/store/postgres-github.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/store/postgres.d.ts +15 -1
- package/node_modules/@noodle-borg/service/dist/store/postgres.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/store/postgres.js +22 -2
- package/node_modules/@noodle-borg/service/dist/store/postgres.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/store.d.ts +22 -99
- package/node_modules/@noodle-borg/service/dist/store.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/store.js.map +1 -1
- package/node_modules/hono/dist/adapter/aws-lambda/handler.js +15 -21
- package/node_modules/hono/dist/adapter/bun/websocket.js +3 -1
- package/node_modules/hono/dist/adapter/lambda-edge/handler.js +8 -2
- package/node_modules/hono/dist/cjs/adapter/aws-lambda/handler.js +15 -21
- package/node_modules/hono/dist/cjs/adapter/bun/websocket.js +3 -1
- package/node_modules/hono/dist/cjs/adapter/lambda-edge/handler.js +8 -2
- package/node_modules/hono/dist/cjs/helper/css/common.js +3 -1
- package/node_modules/hono/dist/cjs/helper/css/index.js +9 -1
- package/node_modules/hono/dist/cjs/jsx/base.js +8 -14
- package/node_modules/hono/dist/cjs/jsx/components.js +41 -21
- package/node_modules/hono/dist/cjs/jsx/context.js +131 -5
- package/node_modules/hono/dist/cjs/jsx/streaming.js +9 -7
- package/node_modules/hono/dist/cjs/middleware/cors/index.js +2 -5
- package/node_modules/hono/dist/cjs/middleware/serve-static/index.js +2 -2
- package/node_modules/hono/dist/cjs/utils/body.js +12 -4
- package/node_modules/hono/dist/cjs/utils/buffer.js +2 -1
- package/node_modules/hono/dist/cjs/validator/validator.js +3 -3
- package/node_modules/hono/dist/helper/css/common.js +3 -1
- package/node_modules/hono/dist/helper/css/index.js +9 -1
- package/node_modules/hono/dist/jsx/base.js +15 -15
- package/node_modules/hono/dist/jsx/components.js +42 -22
- package/node_modules/hono/dist/jsx/context.js +129 -5
- package/node_modules/hono/dist/jsx/streaming.js +10 -8
- package/node_modules/hono/dist/middleware/cors/index.js +2 -5
- package/node_modules/hono/dist/middleware/serve-static/index.js +2 -2
- package/node_modules/hono/dist/types/adapter/aws-lambda/handler.d.ts +1 -1
- package/node_modules/hono/dist/types/jsx/base.d.ts +1 -3
- package/node_modules/hono/dist/types/jsx/context.d.ts +39 -0
- package/node_modules/hono/dist/types/middleware/context-storage/index.d.ts +2 -2
- package/node_modules/hono/dist/types/utils/body.d.ts +1 -1
- package/node_modules/hono/dist/utils/body.js +12 -4
- package/node_modules/hono/dist/utils/buffer.js +2 -1
- package/node_modules/hono/dist/validator/validator.js +3 -3
- package/node_modules/hono/package.json +9 -10
- package/node_modules/tailwindcss/dist/chunk-HMCCH6MG.mjs +1 -0
- package/node_modules/tailwindcss/dist/default-theme.mjs +1 -1
- package/node_modules/tailwindcss/dist/lib.js +13 -13
- package/node_modules/tailwindcss/dist/lib.mjs +18 -18
- package/node_modules/tailwindcss/package.json +2 -2
- package/node_modules/undici/README.md +3 -2
- package/node_modules/undici/docs/docs/api/Agent.md +248 -44
- package/node_modules/undici/docs/docs/api/BalancedPool.md +246 -48
- package/node_modules/undici/docs/docs/api/CacheStorage.md +171 -13
- package/node_modules/undici/docs/docs/api/CacheStore.md +294 -98
- package/node_modules/undici/docs/docs/api/Client.md +365 -178
- package/node_modules/undici/docs/docs/api/ClientStats.md +80 -14
- package/node_modules/undici/docs/docs/api/Connector.md +118 -36
- package/node_modules/undici/docs/docs/api/ContentType.md +65 -25
- package/node_modules/undici/docs/docs/api/Cookies.md +125 -47
- package/node_modules/undici/docs/docs/api/Debug.md +34 -18
- package/node_modules/undici/docs/docs/api/DiagnosticsChannel.md +364 -164
- package/node_modules/undici/docs/docs/api/Dispatcher.md +479 -1093
- package/node_modules/undici/docs/docs/api/EnvHttpProxyAgent.md +101 -87
- package/node_modules/undici/docs/docs/api/Errors.md +503 -40
- package/node_modules/undici/docs/docs/api/EventSource.md +294 -32
- package/node_modules/undici/docs/docs/api/Fetch.md +680 -31
- package/node_modules/undici/docs/docs/api/GlobalInstallation.md +78 -98
- package/node_modules/undici/docs/docs/api/H2CClient.md +298 -176
- package/node_modules/undici/docs/docs/api/Interceptors.md +355 -0
- package/node_modules/undici/docs/docs/api/MockAgent.md +314 -322
- package/node_modules/undici/docs/docs/api/MockCallHistory.md +272 -98
- package/node_modules/undici/docs/docs/api/MockCallHistoryLog.md +189 -26
- package/node_modules/undici/docs/docs/api/MockClient.md +151 -33
- package/node_modules/undici/docs/docs/api/MockErrors.md +56 -5
- package/node_modules/undici/docs/docs/api/MockPool.md +299 -263
- package/node_modules/undici/docs/docs/api/Pool.md +235 -43
- package/node_modules/undici/docs/docs/api/PoolStats.md +119 -13
- package/node_modules/undici/docs/docs/api/ProxyAgent.md +179 -160
- package/node_modules/undici/docs/docs/api/RedirectHandler.md +238 -63
- package/node_modules/undici/docs/docs/api/RetryAgent.md +113 -26
- package/node_modules/undici/docs/docs/api/RetryHandler.md +161 -77
- package/node_modules/undici/docs/docs/api/RoundRobinPool.md +166 -72
- package/node_modules/undici/docs/docs/api/SnapshotAgent.md +264 -542
- package/node_modules/undici/docs/docs/api/Socks5ProxyAgent.md +162 -186
- package/node_modules/undici/docs/docs/api/Util.md +68 -11
- package/node_modules/undici/docs/docs/api/WebSocket.md +475 -80
- package/node_modules/undici/docs/docs/api/api-lifecycle.md +100 -32
- package/node_modules/undici/docs/docs/best-practices/client-certificate.md +2 -0
- package/node_modules/undici/docs/docs/best-practices/crawling.md +3 -1
- package/node_modules/undici/docs/docs/best-practices/migrating-from-v7-to-v8.md +6 -4
- package/node_modules/undici/docs/docs/best-practices/mocking-request.md +9 -7
- package/node_modules/undici/docs/docs/best-practices/proxy.md +3 -1
- package/node_modules/undici/docs/docs/best-practices/undici-vs-builtin-fetch.md +10 -8
- package/node_modules/undici/docs/docs/best-practices/writing-tests.md +2 -0
- package/node_modules/undici/docs/docs/{GettingStarted.md → getting-started.md} +22 -19
- package/node_modules/undici/docs/docs/index.md +779 -0
- package/node_modules/undici/docs/docs/site.json +125 -0
- package/node_modules/undici/docs/docs/type-map.json +79 -0
- package/node_modules/undici/lib/api/api-request.js +7 -1
- package/node_modules/undici/lib/api/readable.js +47 -2
- package/node_modules/undici/lib/core/errors.js +20 -0
- package/node_modules/undici/lib/core/request.js +1 -1
- package/node_modules/undici/lib/core/util.js +24 -1
- package/node_modules/undici/lib/dispatcher/client-h1.js +92 -1
- package/node_modules/undici/lib/dispatcher/client-h2.js +322 -118
- package/node_modules/undici/lib/dispatcher/client.js +6 -2
- package/node_modules/undici/lib/dispatcher/dispatcher-base.js +1 -0
- package/node_modules/undici/lib/dispatcher/proxy-agent.js +42 -7
- package/node_modules/undici/lib/dispatcher/socks5-proxy-agent.js +4 -2
- package/node_modules/undici/lib/handler/redirect-handler.js +1 -0
- package/node_modules/undici/lib/handler/retry-handler.js +57 -19
- package/node_modules/undici/lib/util/cache.js +8 -2
- package/node_modules/undici/lib/web/cookies/parse.js +20 -27
- package/node_modules/undici/lib/web/cookies/util.js +1 -1
- package/node_modules/undici/lib/web/eventsource/eventsource.js +7 -18
- package/node_modules/undici/lib/web/eventsource/util.js +32 -1
- package/node_modules/undici/lib/web/fetch/body.js +43 -0
- package/node_modules/undici/lib/web/fetch/constants.js +1 -1
- package/node_modules/undici/lib/web/fetch/index.js +11 -2
- package/node_modules/undici/lib/web/fetch/request.js +1 -0
- package/node_modules/undici/lib/web/fetch/util.js +4 -1
- package/node_modules/undici/lib/web/websocket/receiver.js +20 -3
- package/node_modules/undici/lib/web/websocket/stream/websocketstream.js +8 -1
- package/node_modules/undici/lib/web/websocket/websocket.js +3 -1
- package/node_modules/undici/package.json +1 -1
- package/node_modules/undici/types/client.d.ts +6 -1
- package/node_modules/undici/types/cookies.d.ts +1 -1
- package/node_modules/undici/types/errors.d.ts +10 -0
- package/node_modules/undici/types/fetch.d.ts +1 -0
- package/node_modules/undici/types/handlers.d.ts +2 -0
- package/node_modules/undici/types/proxy-agent.d.ts +7 -0
- package/package.json +4 -4
- package/react/styles.css +510 -5
- package/react/styles.source.css +850 -0
- package/node_modules/hono/dist/tsconfig.build.tsbuildinfo +0 -1
- package/node_modules/tailwindcss/dist/chunk-XVOTX5KS.mjs +0 -1
|
@@ -1,109 +1,209 @@
|
|
|
1
|
-
#
|
|
1
|
+
# MockPool
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<!--introduced_in=v4.0.0-->
|
|
4
|
+
<!--type=module-->
|
|
5
|
+
<!-- source_link=lib/mock/mock-pool.js -->
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
> Stability: 2 - Stable
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
A `MockPool` is a [`Pool`][] that intercepts requests matching registered routes
|
|
10
|
+
and replies with mocked responses instead of contacting the network. It is
|
|
11
|
+
created by a [`MockAgent`][] and exposes the same interception API as
|
|
12
|
+
[`MockClient`][].
|
|
8
13
|
|
|
9
|
-
|
|
14
|
+
A `MockPool` is not constructed directly in most cases; instead it is obtained
|
|
15
|
+
through [`mockAgent.get(origin)`][]. Once registered as the global dispatcher,
|
|
16
|
+
any request whose origin matches the pool is matched against the mocks it holds.
|
|
10
17
|
|
|
11
|
-
|
|
12
|
-
* **options** `MockPoolOptions` - It extends the `Pool` options.
|
|
13
|
-
|
|
14
|
-
Returns: `MockPool`
|
|
15
|
-
|
|
16
|
-
### Parameter: `MockPoolOptions`
|
|
17
|
-
|
|
18
|
-
Extends: `PoolOptions`
|
|
19
|
-
|
|
20
|
-
* **agent** `Agent` - the agent to associate this MockPool with.
|
|
21
|
-
|
|
22
|
-
### Example - Basic MockPool instantiation
|
|
23
|
-
|
|
24
|
-
We can use MockAgent to instantiate a MockPool ready to be used to intercept specified requests. It will not do anything until registered as the agent to use and any mock request are registered.
|
|
25
|
-
|
|
26
|
-
```js
|
|
18
|
+
```mjs
|
|
27
19
|
import { MockAgent } from 'undici'
|
|
28
20
|
|
|
29
21
|
const mockAgent = new MockAgent()
|
|
30
|
-
|
|
31
22
|
const mockPool = mockAgent.get('http://localhost:3000')
|
|
32
23
|
```
|
|
33
24
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
### `MockPool.intercept(options)`
|
|
37
|
-
|
|
38
|
-
This method defines the interception rules for matching against requests for a MockPool or MockPool. We can intercept multiple times on a single instance, but each intercept is only used once. For example if you expect to make 2 requests inside a test, you need to call `intercept()` twice. Assuming you use `disableNetConnect()` you will get `MockNotMatchedError` on the second request when you only call `intercept()` once.
|
|
39
|
-
|
|
40
|
-
When defining interception rules, all the rules must pass for a request to be intercepted. If a request is not intercepted, a real request will be attempted.
|
|
41
|
-
|
|
42
|
-
| Matcher type | Condition to pass |
|
|
43
|
-
|:------------:| -------------------------- |
|
|
44
|
-
| `string` | Exact match against string |
|
|
45
|
-
| `RegExp` | Regex must pass |
|
|
46
|
-
| `Function` | Function must return true |
|
|
47
|
-
|
|
48
|
-
Arguments:
|
|
49
|
-
|
|
50
|
-
* **options** `MockPoolInterceptOptions` - Interception options.
|
|
51
|
-
|
|
52
|
-
Returns: `MockInterceptor` corresponding to the input options.
|
|
25
|
+
```cjs
|
|
26
|
+
const { MockAgent } = require('undici')
|
|
53
27
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
* **method** `string | RegExp | (method: string) => boolean` - (optional) - a matcher for the HTTP request method. Defaults to `GET`.
|
|
58
|
-
* **body** `string | RegExp | (body: string) => boolean` - (optional) - a matcher for the HTTP request body.
|
|
59
|
-
* **headers** `Record<string, string | RegExp | (body: string) => boolean`> - (optional) - a matcher for the HTTP request headers. To be intercepted, a request must match all defined headers. Extra headers not defined here may (or may not) be included in the request and do not affect the interception in any way.
|
|
60
|
-
* **query** `Record<string, any> | null` - (optional) - a matcher for the HTTP request query string params. Only applies when a `string` was provided for `MockPoolInterceptOptions.path`.
|
|
61
|
-
* **ignoreTrailingSlash** `boolean` - (optional) - set to `true` if the matcher should also match by ignoring potential trailing slashes in `MockPoolInterceptOptions.path`.
|
|
62
|
-
|
|
63
|
-
### Return: `MockInterceptor`
|
|
28
|
+
const mockAgent = new MockAgent()
|
|
29
|
+
const mockPool = mockAgent.get('http://localhost:3000')
|
|
30
|
+
```
|
|
64
31
|
|
|
65
|
-
|
|
32
|
+
## Class: `MockPool`
|
|
66
33
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
* **defaultReplyHeaders** `(headers: Record<string, string>) => MockInterceptor` - define default headers to be included in subsequent replies. These are in addition to headers on a specific reply.
|
|
71
|
-
* **defaultReplyTrailers** `(trailers: Record<string, string>) => MockInterceptor` - define default trailers to be included in subsequent replies. These are in addition to trailers on a specific reply.
|
|
72
|
-
* **replyContentLength** `() => MockInterceptor` - define automatically calculated `content-length` headers to be included in subsequent replies.
|
|
34
|
+
<!-- YAML
|
|
35
|
+
added: v4.0.0
|
|
36
|
+
-->
|
|
73
37
|
|
|
74
|
-
|
|
38
|
+
* Extends: {Pool}
|
|
75
39
|
|
|
76
|
-
|
|
40
|
+
Extends [`Pool`][] and implements the `Interceptable` interface, allowing
|
|
41
|
+
requests made through it to be matched against registered mocks.
|
|
77
42
|
|
|
78
|
-
###
|
|
43
|
+
### `new MockPool(origin[, options])`
|
|
79
44
|
|
|
80
|
-
|
|
81
|
-
|
|
45
|
+
<!-- YAML
|
|
46
|
+
added: v4.0.0
|
|
47
|
+
-->
|
|
82
48
|
|
|
83
|
-
|
|
49
|
+
* `origin` {string} The origin to associate this mock pool with. It should only
|
|
50
|
+
include the protocol, hostname, and port.
|
|
51
|
+
* `options` {MockPoolOptions} Extends the [`Pool`][] options.
|
|
52
|
+
* Returns: {MockPool}
|
|
84
53
|
|
|
85
|
-
|
|
54
|
+
The `agent` option is required and must implement the `Agent` interface;
|
|
55
|
+
otherwise an `InvalidArgumentError` is thrown.
|
|
86
56
|
|
|
87
|
-
|
|
88
|
-
* **persist** `() => MockScope` - any matching request will always reply with the defined response indefinitely.
|
|
89
|
-
* **times** `(repeatTimes: number) => MockScope` - any matching request will reply with the defined response a fixed amount of times. This is overridden by **persist**.
|
|
57
|
+
#### Parameter: `MockPoolOptions`
|
|
90
58
|
|
|
91
|
-
|
|
59
|
+
Extends: `PoolOptions`
|
|
92
60
|
|
|
93
|
-
|
|
61
|
+
* `agent` {MockAgent} The agent to associate this mock pool with.
|
|
62
|
+
* `ignoreTrailingSlash` {boolean} Whether trailing slashes should be ignored
|
|
63
|
+
when matching the path of intercepted requests. **Default:** `false`.
|
|
64
|
+
|
|
65
|
+
### `mockPool.intercept(options)`
|
|
66
|
+
|
|
67
|
+
<!-- YAML
|
|
68
|
+
added: v4.0.0
|
|
69
|
+
-->
|
|
70
|
+
|
|
71
|
+
* `options` {MockPoolInterceptOptions} The matching criteria for the requests to
|
|
72
|
+
intercept.
|
|
73
|
+
* Returns: {MockInterceptor} The interceptor used to define the mocked reply.
|
|
74
|
+
|
|
75
|
+
Registers a route on the mock pool and returns a [`MockInterceptor`][] for any
|
|
76
|
+
matching request that uses the same origin as this mock pool. The interceptor is
|
|
77
|
+
then used to define the reply, for example with `reply()` or `replyWithError()`.
|
|
78
|
+
|
|
79
|
+
Each `intercept()` call is consumed by a single matching request. To match more
|
|
80
|
+
than one request, call `intercept()` once per expected request, or use
|
|
81
|
+
`persist()` or `times()` on the returned [`MockScope`][]. When no registered
|
|
82
|
+
mock matches a request, a real request is attempted unless network connections
|
|
83
|
+
have been disabled on the [`MockAgent`][], in which case a `MockNotMatchedError`
|
|
84
|
+
is thrown.
|
|
85
|
+
|
|
86
|
+
A request is intercepted only when every defined matcher passes. The accepted
|
|
87
|
+
matcher forms behave as follows:
|
|
88
|
+
|
|
89
|
+
| Matcher type | Condition to pass |
|
|
90
|
+
| :----------: | ---------------------------- |
|
|
91
|
+
| `string` | Exact match against the value |
|
|
92
|
+
| `RegExp` | The expression must match |
|
|
93
|
+
| `Function` | The function must return `true` |
|
|
94
|
+
|
|
95
|
+
#### Parameter: `MockPoolInterceptOptions`
|
|
96
|
+
|
|
97
|
+
* `path` {string|RegExp|Function} A matcher for the HTTP request path. The
|
|
98
|
+
function form has the signature `(path: string) => boolean`. When a `RegExp`
|
|
99
|
+
or function is used, it matches against the request path including all query
|
|
100
|
+
parameters in alphabetical order. When a `string` is used, query parameters
|
|
101
|
+
can instead be supplied through `query`.
|
|
102
|
+
* `method` {string|RegExp|Function} A matcher for the HTTP request method. The
|
|
103
|
+
function form has the signature `(method: string) => boolean`.
|
|
104
|
+
**Default:** `'GET'`.
|
|
105
|
+
* `body` {string|RegExp|Function} A matcher for the HTTP request body. The
|
|
106
|
+
function form has the signature `(body: string) => boolean`.
|
|
107
|
+
* `headers` {Object|Function} A matcher for the HTTP request headers, given
|
|
108
|
+
either as a map of header name to a `string`, `RegExp`, or
|
|
109
|
+
`(value: string) => boolean` matcher, or as a single function that receives
|
|
110
|
+
all headers and returns a `boolean`. When a map is used, the request must
|
|
111
|
+
match every defined header; extra headers not listed here do not affect
|
|
112
|
+
matching.
|
|
113
|
+
* `query` {Object} A matcher for the HTTP request query string parameters. Only
|
|
114
|
+
applies when a `string` was provided for `path`.
|
|
115
|
+
* `ignoreTrailingSlash` {boolean} Whether a trailing slash on `path` is ignored
|
|
116
|
+
when matching. Inherited from the mock pool's `ignoreTrailingSlash` option
|
|
117
|
+
when not set.
|
|
118
|
+
|
|
119
|
+
#### Return: `MockInterceptor`
|
|
120
|
+
|
|
121
|
+
The reply behaviour of a matching request is defined through the returned
|
|
122
|
+
`MockInterceptor`.
|
|
123
|
+
|
|
124
|
+
* `reply(statusCode[, data[, responseOptions]])` {Function} Defines the reply
|
|
125
|
+
for a matching request.
|
|
126
|
+
* `statusCode` {number} The status code of the mocked reply.
|
|
127
|
+
* `data` {string|Buffer|Object|Function} The body of the mocked reply.
|
|
128
|
+
Objects are serialized to JSON; strings and `Buffer`s are sent as-is. The
|
|
129
|
+
function form has the signature
|
|
130
|
+
`(opts: MockResponseCallbackOptions) => string | Buffer | Object` and is
|
|
131
|
+
invoked with the incoming request to compute the reply body.
|
|
132
|
+
* `responseOptions` {MockResponseOptions} Additional reply options.
|
|
133
|
+
**Default:** `{}`.
|
|
134
|
+
* Returns: {MockScope}
|
|
135
|
+
* `reply(callback)` {Function} Defines the reply for a matching request,
|
|
136
|
+
computing all reply options dynamically rather than just the body.
|
|
137
|
+
* `callback` {Function} A `(opts: MockResponseCallbackOptions) =>
|
|
138
|
+
{ statusCode, data, responseOptions }` function invoked with the incoming
|
|
139
|
+
request.
|
|
140
|
+
* Returns: {MockScope}
|
|
141
|
+
* `replyWithError(error)` {Function} Defines an error for a matching request to
|
|
142
|
+
throw.
|
|
143
|
+
* `error` {Error} The error thrown when a request matches.
|
|
144
|
+
* Returns: {MockScope}
|
|
145
|
+
* `defaultReplyHeaders(headers)` {Function} Sets default headers included on
|
|
146
|
+
every subsequent reply defined on this interceptor, in addition to any headers
|
|
147
|
+
set on a specific reply.
|
|
148
|
+
* `headers` {Object} A map of header name to value.
|
|
149
|
+
* Returns: {MockInterceptor}
|
|
150
|
+
* `defaultReplyTrailers(trailers)` {Function} Sets default trailers included on
|
|
151
|
+
every subsequent reply defined on this interceptor, in addition to any
|
|
152
|
+
trailers set on a specific reply.
|
|
153
|
+
* `trailers` {Object} A map of trailer name to value.
|
|
154
|
+
* Returns: {MockInterceptor}
|
|
155
|
+
* `replyContentLength()` {Function} Sets an automatically calculated
|
|
156
|
+
`content-length` header on every subsequent reply defined on this interceptor.
|
|
157
|
+
* Returns: {MockInterceptor}
|
|
158
|
+
|
|
159
|
+
By default, `reply()` and `replyWithError()` define the behaviour for the first
|
|
160
|
+
matching request only; subsequent requests are not affected unless `persist()`
|
|
161
|
+
or `times()` is used on the returned [`MockScope`][].
|
|
162
|
+
|
|
163
|
+
#### Parameter: `MockResponseCallbackOptions`
|
|
164
|
+
|
|
165
|
+
The argument passed to the `reply()` data and options callbacks.
|
|
166
|
+
|
|
167
|
+
* `path` {string} The path of the intercepted request.
|
|
168
|
+
* `method` {string} The method of the intercepted request.
|
|
169
|
+
* `headers` {Object|Headers} The headers of the intercepted request.
|
|
170
|
+
* `origin` {string} The origin of the intercepted request.
|
|
171
|
+
* `body` {string|null} The body of the intercepted request.
|
|
172
|
+
|
|
173
|
+
#### Parameter: `MockResponseOptions`
|
|
174
|
+
|
|
175
|
+
* `headers` {Object} Headers to include on the mocked reply.
|
|
176
|
+
* `trailers` {Object} Trailers to include on the mocked reply.
|
|
177
|
+
|
|
178
|
+
#### Return: `MockScope`
|
|
179
|
+
|
|
180
|
+
A `MockScope` is associated with a single [`MockInterceptor`][] and configures
|
|
181
|
+
how many times the defined reply is used.
|
|
182
|
+
|
|
183
|
+
* `delay(waitInMs)` {Function} Delays the associated reply by a set amount of
|
|
184
|
+
time.
|
|
185
|
+
* `waitInMs` {number} The delay in milliseconds.
|
|
186
|
+
* Returns: {MockScope}
|
|
187
|
+
* `persist()` {Function} Makes the associated reply match indefinitely, so every
|
|
188
|
+
matching request receives the defined response.
|
|
189
|
+
* Returns: {MockScope}
|
|
190
|
+
* `times(repeatTimes)` {Function} Makes the associated reply match a fixed number
|
|
191
|
+
of times. This is overridden by `persist()`.
|
|
192
|
+
* `repeatTimes` {number} The number of matching requests the reply applies to.
|
|
193
|
+
* Returns: {MockScope}
|
|
194
|
+
|
|
195
|
+
The following examples show common interception patterns.
|
|
196
|
+
|
|
197
|
+
```mjs displayName="Basic mocked request"
|
|
94
198
|
import { MockAgent, setGlobalDispatcher, request } from 'undici'
|
|
95
199
|
|
|
96
200
|
const mockAgent = new MockAgent()
|
|
97
201
|
setGlobalDispatcher(mockAgent)
|
|
98
202
|
|
|
99
|
-
// MockPool
|
|
100
203
|
const mockPool = mockAgent.get('http://localhost:3000')
|
|
101
204
|
mockPool.intercept({ path: '/foo' }).reply(200, 'foo')
|
|
102
205
|
|
|
103
|
-
const {
|
|
104
|
-
statusCode,
|
|
105
|
-
body
|
|
106
|
-
} = await request('http://localhost:3000/foo')
|
|
206
|
+
const { statusCode, body } = await request('http://localhost:3000/foo')
|
|
107
207
|
|
|
108
208
|
console.log('response received', statusCode) // response received 200
|
|
109
209
|
|
|
@@ -112,9 +212,7 @@ for await (const data of body) {
|
|
|
112
212
|
}
|
|
113
213
|
```
|
|
114
214
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
```js
|
|
215
|
+
```mjs displayName="Reply with a data callback"
|
|
118
216
|
import { MockAgent, setGlobalDispatcher, request } from 'undici'
|
|
119
217
|
|
|
120
218
|
const mockAgent = new MockAgent()
|
|
@@ -124,30 +222,21 @@ const mockPool = mockAgent.get('http://localhost:3000')
|
|
|
124
222
|
|
|
125
223
|
mockPool.intercept({
|
|
126
224
|
path: '/echo',
|
|
127
|
-
method: 'GET'
|
|
128
|
-
|
|
129
|
-
'User-Agent': 'undici',
|
|
130
|
-
Host: 'example.com'
|
|
131
|
-
}
|
|
132
|
-
}).reply(200, ({ headers }) => ({ message: headers.get('message') }))
|
|
225
|
+
method: 'GET'
|
|
226
|
+
}).reply(200, ({ headers }) => ({ message: headers.message }))
|
|
133
227
|
|
|
134
|
-
const { statusCode, body
|
|
135
|
-
headers: {
|
|
136
|
-
message: 'hello world!'
|
|
137
|
-
}
|
|
228
|
+
const { statusCode, body } = await request('http://localhost:3000/echo', {
|
|
229
|
+
headers: { message: 'hello world!' }
|
|
138
230
|
})
|
|
139
231
|
|
|
140
232
|
console.log('response received', statusCode) // response received 200
|
|
141
|
-
console.log('headers', headers) // { 'content-type': 'application/json' }
|
|
142
233
|
|
|
143
234
|
for await (const data of body) {
|
|
144
|
-
console.log('data', data.toString('utf8')) // {
|
|
235
|
+
console.log('data', data.toString('utf8')) // {"message":"hello world!"}
|
|
145
236
|
}
|
|
146
237
|
```
|
|
147
238
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
```js
|
|
239
|
+
```mjs displayName="Reply with an options callback"
|
|
151
240
|
import { MockAgent, setGlobalDispatcher, request } from 'undici'
|
|
152
241
|
|
|
153
242
|
const mockAgent = new MockAgent()
|
|
@@ -157,30 +246,24 @@ const mockPool = mockAgent.get('http://localhost:3000')
|
|
|
157
246
|
|
|
158
247
|
mockPool.intercept({
|
|
159
248
|
path: '/echo',
|
|
160
|
-
method: 'GET'
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}).reply(({ headers }) => ({ statusCode: 200, data: { message: headers.get('message') }})))
|
|
249
|
+
method: 'GET'
|
|
250
|
+
}).reply(({ headers }) => ({
|
|
251
|
+
statusCode: 200,
|
|
252
|
+
data: { message: headers.message }
|
|
253
|
+
}))
|
|
166
254
|
|
|
167
|
-
const { statusCode, body
|
|
168
|
-
headers: {
|
|
169
|
-
message: 'hello world!'
|
|
170
|
-
}
|
|
255
|
+
const { statusCode, body } = await request('http://localhost:3000/echo', {
|
|
256
|
+
headers: { message: 'hello world!' }
|
|
171
257
|
})
|
|
172
258
|
|
|
173
259
|
console.log('response received', statusCode) // response received 200
|
|
174
|
-
console.log('headers', headers) // { 'content-type': 'application/json' }
|
|
175
260
|
|
|
176
261
|
for await (const data of body) {
|
|
177
|
-
console.log('data', data.toString('utf8')) // {
|
|
262
|
+
console.log('data', data.toString('utf8')) // {"message":"hello world!"}
|
|
178
263
|
}
|
|
179
264
|
```
|
|
180
265
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
```js
|
|
266
|
+
```mjs displayName="Multiple intercepts"
|
|
184
267
|
import { MockAgent, setGlobalDispatcher, request } from 'undici'
|
|
185
268
|
|
|
186
269
|
const mockAgent = new MockAgent()
|
|
@@ -188,36 +271,21 @@ setGlobalDispatcher(mockAgent)
|
|
|
188
271
|
|
|
189
272
|
const mockPool = mockAgent.get('http://localhost:3000')
|
|
190
273
|
|
|
191
|
-
mockPool.intercept({
|
|
192
|
-
|
|
193
|
-
method: 'GET'
|
|
194
|
-
}).reply(200, 'foo')
|
|
274
|
+
mockPool.intercept({ path: '/foo', method: 'GET' }).reply(200, 'foo')
|
|
275
|
+
mockPool.intercept({ path: '/hello', method: 'GET' }).reply(200, 'hello')
|
|
195
276
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
method: 'GET',
|
|
199
|
-
}).reply(200, 'hello')
|
|
200
|
-
|
|
201
|
-
const result1 = await request('http://localhost:3000/foo')
|
|
202
|
-
|
|
203
|
-
console.log('response received', result1.statusCode) // response received 200
|
|
204
|
-
|
|
205
|
-
for await (const data of result1.body) {
|
|
277
|
+
const fooResult = await request('http://localhost:3000/foo')
|
|
278
|
+
for await (const data of fooResult.body) {
|
|
206
279
|
console.log('data', data.toString('utf8')) // data foo
|
|
207
280
|
}
|
|
208
281
|
|
|
209
|
-
const
|
|
210
|
-
|
|
211
|
-
console.log('response received', result2.statusCode) // response received 200
|
|
212
|
-
|
|
213
|
-
for await (const data of result2.body) {
|
|
282
|
+
const helloResult = await request('http://localhost:3000/hello')
|
|
283
|
+
for await (const data of helloResult.body) {
|
|
214
284
|
console.log('data', data.toString('utf8')) // data hello
|
|
215
285
|
}
|
|
216
286
|
```
|
|
217
287
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
```js
|
|
288
|
+
```mjs displayName="Match query, body, request headers; reply with headers and trailers"
|
|
221
289
|
import { MockAgent, setGlobalDispatcher, request } from 'undici'
|
|
222
290
|
|
|
223
291
|
const mockAgent = new MockAgent()
|
|
@@ -238,12 +306,9 @@ mockPool.intercept({
|
|
|
238
306
|
trailers: { 'Content-MD5': 'test' }
|
|
239
307
|
})
|
|
240
308
|
|
|
241
|
-
const {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
trailers,
|
|
245
|
-
body
|
|
246
|
-
} = await request('http://localhost:3000/foo?hello=there&see=ya', {
|
|
309
|
+
const { statusCode, headers, trailers, body } = await request(
|
|
310
|
+
'http://localhost:3000/foo?hello=there&see=ya',
|
|
311
|
+
{
|
|
247
312
|
method: 'POST',
|
|
248
313
|
body: 'form1=data1&form2=data2',
|
|
249
314
|
headers: {
|
|
@@ -251,21 +316,20 @@ const {
|
|
|
251
316
|
'User-Agent': 'undici',
|
|
252
317
|
Host: 'example.com'
|
|
253
318
|
}
|
|
254
|
-
}
|
|
319
|
+
}
|
|
320
|
+
)
|
|
255
321
|
|
|
256
322
|
console.log('response received', statusCode) // response received 200
|
|
257
323
|
console.log('headers', headers) // { 'content-type': 'application/json' }
|
|
258
324
|
|
|
259
325
|
for await (const data of body) {
|
|
260
|
-
console.log('data', data.toString('utf8')) //
|
|
326
|
+
console.log('data', data.toString('utf8')) // {"foo":"bar"}
|
|
261
327
|
}
|
|
262
328
|
|
|
263
329
|
console.log('trailers', trailers) // { 'content-md5': 'test' }
|
|
264
330
|
```
|
|
265
331
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
```js
|
|
332
|
+
```mjs displayName="Different matcher forms"
|
|
269
333
|
import { MockAgent, setGlobalDispatcher, request } from 'undici'
|
|
270
334
|
|
|
271
335
|
const mockAgent = new MockAgent()
|
|
@@ -279,14 +343,11 @@ mockPool.intercept({
|
|
|
279
343
|
body: (value) => value === 'form=data',
|
|
280
344
|
headers: {
|
|
281
345
|
'User-Agent': 'undici',
|
|
282
|
-
Host: /^example
|
|
346
|
+
Host: /^example\.com$/
|
|
283
347
|
}
|
|
284
348
|
}).reply(200, 'foo')
|
|
285
349
|
|
|
286
|
-
const {
|
|
287
|
-
statusCode,
|
|
288
|
-
body
|
|
289
|
-
} = await request('http://localhost:3000/foo', {
|
|
350
|
+
const { statusCode, body } = await request('http://localhost:3000/foo', {
|
|
290
351
|
method: 'GET',
|
|
291
352
|
body: 'form=data',
|
|
292
353
|
headers: {
|
|
@@ -303,9 +364,7 @@ for await (const data of body) {
|
|
|
303
364
|
}
|
|
304
365
|
```
|
|
305
366
|
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
```js
|
|
367
|
+
```mjs displayName="Reply with an error"
|
|
309
368
|
import { MockAgent, setGlobalDispatcher, request } from 'undici'
|
|
310
369
|
|
|
311
370
|
const mockAgent = new MockAgent()
|
|
@@ -319,18 +378,13 @@ mockPool.intercept({
|
|
|
319
378
|
}).replyWithError(new Error('kaboom'))
|
|
320
379
|
|
|
321
380
|
try {
|
|
322
|
-
await request('http://localhost:3000/foo', {
|
|
323
|
-
method: 'GET'
|
|
324
|
-
})
|
|
381
|
+
await request('http://localhost:3000/foo', { method: 'GET' })
|
|
325
382
|
} catch (error) {
|
|
326
|
-
console.error(error) //
|
|
327
|
-
console.error(error.cause) // Error: kaboom
|
|
383
|
+
console.error(error.message) // kaboom
|
|
328
384
|
}
|
|
329
385
|
```
|
|
330
386
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
```js
|
|
387
|
+
```mjs displayName="Default reply headers"
|
|
334
388
|
import { MockAgent, setGlobalDispatcher, request } from 'undici'
|
|
335
389
|
|
|
336
390
|
const mockAgent = new MockAgent()
|
|
@@ -338,10 +392,8 @@ setGlobalDispatcher(mockAgent)
|
|
|
338
392
|
|
|
339
393
|
const mockPool = mockAgent.get('http://localhost:3000')
|
|
340
394
|
|
|
341
|
-
mockPool.intercept({
|
|
342
|
-
|
|
343
|
-
method: 'GET'
|
|
344
|
-
}).defaultReplyHeaders({ foo: 'bar' })
|
|
395
|
+
mockPool.intercept({ path: '/foo', method: 'GET' })
|
|
396
|
+
.defaultReplyHeaders({ foo: 'bar' })
|
|
345
397
|
.reply(200, 'foo')
|
|
346
398
|
|
|
347
399
|
const { headers } = await request('http://localhost:3000/foo')
|
|
@@ -349,9 +401,7 @@ const { headers } = await request('http://localhost:3000/foo')
|
|
|
349
401
|
console.log('headers', headers) // headers { foo: 'bar' }
|
|
350
402
|
```
|
|
351
403
|
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
```js
|
|
404
|
+
```mjs displayName="Default reply trailers"
|
|
355
405
|
import { MockAgent, setGlobalDispatcher, request } from 'undici'
|
|
356
406
|
|
|
357
407
|
const mockAgent = new MockAgent()
|
|
@@ -359,10 +409,8 @@ setGlobalDispatcher(mockAgent)
|
|
|
359
409
|
|
|
360
410
|
const mockPool = mockAgent.get('http://localhost:3000')
|
|
361
411
|
|
|
362
|
-
mockPool.intercept({
|
|
363
|
-
|
|
364
|
-
method: 'GET'
|
|
365
|
-
}).defaultReplyTrailers({ foo: 'bar' })
|
|
412
|
+
mockPool.intercept({ path: '/foo', method: 'GET' })
|
|
413
|
+
.defaultReplyTrailers({ foo: 'bar' })
|
|
366
414
|
.reply(200, 'foo')
|
|
367
415
|
|
|
368
416
|
const { trailers } = await request('http://localhost:3000/foo')
|
|
@@ -370,9 +418,7 @@ const { trailers } = await request('http://localhost:3000/foo')
|
|
|
370
418
|
console.log('trailers', trailers) // trailers { foo: 'bar' }
|
|
371
419
|
```
|
|
372
420
|
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
```js
|
|
421
|
+
```mjs displayName="Automatic content-length"
|
|
376
422
|
import { MockAgent, setGlobalDispatcher, request } from 'undici'
|
|
377
423
|
|
|
378
424
|
const mockAgent = new MockAgent()
|
|
@@ -380,19 +426,16 @@ setGlobalDispatcher(mockAgent)
|
|
|
380
426
|
|
|
381
427
|
const mockPool = mockAgent.get('http://localhost:3000')
|
|
382
428
|
|
|
383
|
-
mockPool.intercept({
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
}).replyContentLength().reply(200, 'foo')
|
|
429
|
+
mockPool.intercept({ path: '/foo', method: 'GET' })
|
|
430
|
+
.replyContentLength()
|
|
431
|
+
.reply(200, 'foo')
|
|
387
432
|
|
|
388
433
|
const { headers } = await request('http://localhost:3000/foo')
|
|
389
434
|
|
|
390
435
|
console.log('headers', headers) // headers { 'content-length': '3' }
|
|
391
436
|
```
|
|
392
437
|
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
```js
|
|
438
|
+
```mjs displayName="Persisted reply"
|
|
396
439
|
import { MockAgent, setGlobalDispatcher, request } from 'undici'
|
|
397
440
|
|
|
398
441
|
const mockAgent = new MockAgent()
|
|
@@ -400,43 +443,13 @@ setGlobalDispatcher(mockAgent)
|
|
|
400
443
|
|
|
401
444
|
const mockPool = mockAgent.get('http://localhost:3000')
|
|
402
445
|
|
|
403
|
-
mockPool.intercept({
|
|
404
|
-
path: '/foo',
|
|
405
|
-
method: 'GET'
|
|
406
|
-
}).replyContentLength().reply(200, { foo: 'bar' })
|
|
407
|
-
|
|
408
|
-
const { headers } = await request('http://localhost:3000/foo')
|
|
409
|
-
|
|
410
|
-
console.log('headers', headers) // headers { 'content-length': '13' }
|
|
411
|
-
```
|
|
412
|
-
|
|
413
|
-
#### Example - Mocked request with persist enabled
|
|
414
|
-
|
|
415
|
-
```js
|
|
416
|
-
import { MockAgent, setGlobalDispatcher, request } from 'undici'
|
|
417
|
-
|
|
418
|
-
const mockAgent = new MockAgent()
|
|
419
|
-
setGlobalDispatcher(mockAgent)
|
|
420
|
-
|
|
421
|
-
const mockPool = mockAgent.get('http://localhost:3000')
|
|
422
|
-
|
|
423
|
-
mockPool.intercept({
|
|
424
|
-
path: '/foo',
|
|
425
|
-
method: 'GET'
|
|
426
|
-
}).reply(200, 'foo').persist()
|
|
427
|
-
|
|
428
|
-
const result1 = await request('http://localhost:3000/foo')
|
|
429
|
-
// Will match and return mocked data
|
|
430
|
-
|
|
431
|
-
const result2 = await request('http://localhost:3000/foo')
|
|
432
|
-
// Will match and return mocked data
|
|
446
|
+
mockPool.intercept({ path: '/foo', method: 'GET' }).reply(200, 'foo').persist()
|
|
433
447
|
|
|
434
|
-
//
|
|
448
|
+
await request('http://localhost:3000/foo') // Matches and returns the mock
|
|
449
|
+
await request('http://localhost:3000/foo') // Matches again, indefinitely
|
|
435
450
|
```
|
|
436
451
|
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
```js
|
|
452
|
+
```mjs displayName="Reply a fixed number of times"
|
|
440
453
|
import { MockAgent, setGlobalDispatcher, request } from 'undici'
|
|
441
454
|
|
|
442
455
|
const mockAgent = new MockAgent()
|
|
@@ -444,33 +457,23 @@ setGlobalDispatcher(mockAgent)
|
|
|
444
457
|
|
|
445
458
|
const mockPool = mockAgent.get('http://localhost:3000')
|
|
446
459
|
|
|
447
|
-
mockPool.intercept({
|
|
448
|
-
path: '/foo',
|
|
449
|
-
method: 'GET'
|
|
450
|
-
}).reply(200, 'foo').times(2)
|
|
451
|
-
|
|
452
|
-
const result1 = await request('http://localhost:3000/foo')
|
|
453
|
-
// Will match and return mocked data
|
|
454
|
-
|
|
455
|
-
const result2 = await request('http://localhost:3000/foo')
|
|
456
|
-
// Will match and return mocked data
|
|
460
|
+
mockPool.intercept({ path: '/foo', method: 'GET' }).reply(200, 'foo').times(2)
|
|
457
461
|
|
|
458
|
-
|
|
459
|
-
|
|
462
|
+
await request('http://localhost:3000/foo') // Matches and returns the mock
|
|
463
|
+
await request('http://localhost:3000/foo') // Matches and returns the mock
|
|
464
|
+
await request('http://localhost:3000/foo') // No match; a real request is attempted
|
|
460
465
|
```
|
|
461
466
|
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
```js
|
|
467
|
+
```mjs displayName="Match the path with a function"
|
|
465
468
|
import { MockAgent, setGlobalDispatcher, request } from 'undici'
|
|
466
|
-
import querystring from 'querystring'
|
|
469
|
+
import querystring from 'node:querystring'
|
|
467
470
|
|
|
468
471
|
const mockAgent = new MockAgent()
|
|
469
472
|
setGlobalDispatcher(mockAgent)
|
|
470
473
|
|
|
471
474
|
const mockPool = mockAgent.get('http://localhost:3000')
|
|
472
475
|
|
|
473
|
-
const matchPath = requestPath => {
|
|
476
|
+
const matchPath = (requestPath) => {
|
|
474
477
|
const [pathname, search] = requestPath.split('?')
|
|
475
478
|
const requestQuery = querystring.parse(search)
|
|
476
479
|
|
|
@@ -478,31 +481,26 @@ const matchPath = requestPath => {
|
|
|
478
481
|
return false
|
|
479
482
|
}
|
|
480
483
|
|
|
481
|
-
|
|
482
|
-
return false
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
return true
|
|
484
|
+
return requestQuery.foo === 'bar'
|
|
486
485
|
}
|
|
487
486
|
|
|
488
|
-
mockPool.intercept({
|
|
489
|
-
path: matchPath,
|
|
490
|
-
method: 'GET'
|
|
491
|
-
}).reply(200, 'foo')
|
|
487
|
+
mockPool.intercept({ path: matchPath, method: 'GET' }).reply(200, 'foo')
|
|
492
488
|
|
|
493
|
-
|
|
494
|
-
// Will match and return mocked data
|
|
489
|
+
await request('http://localhost:3000/foo?foo=bar') // Matches and returns the mock
|
|
495
490
|
```
|
|
496
491
|
|
|
497
|
-
### `
|
|
492
|
+
### `mockPool.close()`
|
|
498
493
|
|
|
499
|
-
|
|
494
|
+
<!-- YAML
|
|
495
|
+
added: v4.0.0
|
|
496
|
+
-->
|
|
500
497
|
|
|
501
|
-
Returns: `
|
|
498
|
+
* Returns: {Promise} Fulfills with `undefined` once the mock pool is closed.
|
|
502
499
|
|
|
503
|
-
|
|
500
|
+
Closes the mock pool, gracefully waiting for any enqueued requests to complete,
|
|
501
|
+
and removes it from the associated [`MockAgent`][].
|
|
504
502
|
|
|
505
|
-
```
|
|
503
|
+
```mjs
|
|
506
504
|
import { MockAgent } from 'undici'
|
|
507
505
|
|
|
508
506
|
const mockAgent = new MockAgent()
|
|
@@ -511,31 +509,45 @@ const mockPool = mockAgent.get('http://localhost:3000')
|
|
|
511
509
|
await mockPool.close()
|
|
512
510
|
```
|
|
513
511
|
|
|
514
|
-
### `
|
|
512
|
+
### `mockPool.dispatch(options, handlers)`
|
|
513
|
+
|
|
514
|
+
<!-- YAML
|
|
515
|
+
added: v4.0.0
|
|
516
|
+
-->
|
|
517
|
+
|
|
518
|
+
* `options` {DispatchOptions} The request options.
|
|
519
|
+
* `handlers` {DispatchHandler} The handlers invoked over the request lifecycle.
|
|
520
|
+
* Returns: {boolean} `false` if the dispatcher is busy and the caller should
|
|
521
|
+
wait before dispatching further requests, otherwise `true`.
|
|
522
|
+
|
|
523
|
+
Dispatches a request, matching it against the registered mocks. This override of
|
|
524
|
+
[`dispatcher.dispatch(options, handlers)`][] is what drives the mocking
|
|
525
|
+
behaviour for every higher-level method such as `request`.
|
|
515
526
|
|
|
516
|
-
|
|
527
|
+
### `mockPool.request(options[, callback])`
|
|
517
528
|
|
|
518
|
-
|
|
529
|
+
<!-- YAML
|
|
530
|
+
added: v4.0.0
|
|
531
|
+
-->
|
|
519
532
|
|
|
520
|
-
|
|
533
|
+
* `options` {DispatchOptions}
|
|
534
|
+
* `callback` {Function} (optional) Invoked with the response when no `Promise`
|
|
535
|
+
is requested.
|
|
536
|
+
* Returns: {Promise} Fulfills with the mocked response when no `callback` is
|
|
537
|
+
provided.
|
|
521
538
|
|
|
522
|
-
|
|
539
|
+
Performs a request and resolves it against the registered mocks. Inherited from
|
|
540
|
+
[`Pool`][]; see [`dispatcher.request(options[, callback])`][] for the full
|
|
541
|
+
parameter and return value documentation.
|
|
523
542
|
|
|
524
|
-
```
|
|
543
|
+
```mjs
|
|
525
544
|
import { MockAgent } from 'undici'
|
|
526
545
|
|
|
527
546
|
const mockAgent = new MockAgent()
|
|
528
|
-
|
|
529
547
|
const mockPool = mockAgent.get('http://localhost:3000')
|
|
530
|
-
mockPool.intercept({
|
|
531
|
-
path: '/foo',
|
|
532
|
-
method: 'GET',
|
|
533
|
-
}).reply(200, 'foo')
|
|
548
|
+
mockPool.intercept({ path: '/foo', method: 'GET' }).reply(200, 'foo')
|
|
534
549
|
|
|
535
|
-
const {
|
|
536
|
-
statusCode,
|
|
537
|
-
body
|
|
538
|
-
} = await mockPool.request({
|
|
550
|
+
const { statusCode, body } = await mockPool.request({
|
|
539
551
|
origin: 'http://localhost:3000',
|
|
540
552
|
path: '/foo',
|
|
541
553
|
method: 'GET'
|
|
@@ -548,8 +560,32 @@ for await (const data of body) {
|
|
|
548
560
|
}
|
|
549
561
|
```
|
|
550
562
|
|
|
551
|
-
### `
|
|
563
|
+
### `mockPool.cleanMocks()`
|
|
564
|
+
|
|
565
|
+
<!-- YAML
|
|
566
|
+
added: v7.11.0
|
|
567
|
+
-->
|
|
568
|
+
|
|
569
|
+
* Returns: {undefined}
|
|
570
|
+
|
|
571
|
+
Removes all registered interceptors from the mock pool. Pending mocks defined
|
|
572
|
+
before this call no longer match incoming requests.
|
|
552
573
|
|
|
553
|
-
|
|
574
|
+
```mjs
|
|
575
|
+
import { MockAgent } from 'undici'
|
|
576
|
+
|
|
577
|
+
const mockAgent = new MockAgent()
|
|
578
|
+
const mockPool = mockAgent.get('http://localhost:3000')
|
|
579
|
+
|
|
580
|
+
mockPool.intercept({ path: '/foo' }).reply(200, 'foo')
|
|
581
|
+
mockPool.cleanMocks()
|
|
582
|
+
```
|
|
554
583
|
|
|
555
|
-
|
|
584
|
+
[`MockAgent`]: MockAgent.md#class-mockagent
|
|
585
|
+
[`MockClient`]: MockClient.md#class-mockclient
|
|
586
|
+
[`MockInterceptor`]: MockPool.md#return-mockinterceptor
|
|
587
|
+
[`MockScope`]: MockPool.md#return-mockscope
|
|
588
|
+
[`Pool`]: Pool.md#class-pool
|
|
589
|
+
[`dispatcher.dispatch(options, handlers)`]: Dispatcher.md#dispatcherdispatchoptions-handler
|
|
590
|
+
[`dispatcher.request(options[, callback])`]: Dispatcher.md#dispatcherrequestoptions-callback
|
|
591
|
+
[`mockAgent.get(origin)`]: MockAgent.md#mockagentgetorigin
|