@apifuse/provider-sdk 2.2.0-beta.5 → 2.2.0-beta.51
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/AUTHORING.md +537 -33
- package/CHANGELOG.md +205 -1
- package/README.md +83 -22
- package/SUBMISSION.md +2 -2
- package/bin/apifuse-check.ts +165 -11
- package/bin/apifuse-dev.ts +57 -13
- package/bin/apifuse-migrate-operation-declaration.ts +55 -0
- package/bin/apifuse-migrate-shape.ts +202 -0
- package/bin/apifuse-pack-check.ts +22 -2
- package/bin/apifuse-pack-smoke.ts +57 -2
- package/bin/apifuse-pack-types.ts +357 -38
- package/bin/apifuse-perf.ts +14 -13
- package/bin/apifuse-record.ts +709 -72
- package/bin/apifuse-submit-check.ts +2344 -324
- package/bin/apifuse-sync-assets.ts +117 -0
- package/bin/submit-check-delimited-text.ts +50 -0
- package/dist/auth-turn/index.d.ts +3 -3
- package/dist/auth-turn/index.js +1 -1
- package/dist/auth.d.ts +14 -0
- package/dist/auth.js +67 -0
- package/dist/ceremonies/index.d.ts +16 -0
- package/dist/ceremonies/index.js +141 -36
- package/dist/cli/commands.d.ts +1 -1
- package/dist/cli/commands.js +27 -0
- package/dist/cli/create.d.ts +4 -1
- package/dist/cli/create.js +42 -37
- package/dist/cli/migrate-operation-declaration.d.ts +59 -0
- package/dist/cli/migrate-operation-declaration.js +1249 -0
- package/dist/cli/migrate-operation-shape.d.ts +44 -0
- package/dist/cli/migrate-operation-shape.js +113 -0
- package/dist/cli/migrate-provider-shape.d.ts +52 -0
- package/dist/cli/migrate-provider-shape.js +578 -0
- package/dist/cli/prompt-assets.d.ts +80 -0
- package/dist/cli/prompt-assets.js +743 -0
- package/dist/cli/templates/provider/AGENTS.md.tpl +17 -8
- package/dist/cli/templates/provider/Dockerfile.tpl +1 -1
- package/dist/cli/templates/provider/README.md.tpl +5 -5
- package/dist/cli/templates/provider/index.ts.tpl +6 -3
- package/dist/cli/templates/provider/operations/ping.ts.tpl +4 -1
- package/dist/cli/templates/provider/provider.json.tpl +6 -0
- package/dist/config/loader.d.ts +179 -16
- package/dist/config/loader.js +435 -127
- package/dist/contract-serialization.js +4 -8
- package/dist/contract-types.d.ts +12 -5
- package/dist/contract.js +24 -10
- package/dist/declaration-validation.d.ts +33 -0
- package/dist/declaration-validation.js +266 -0
- package/dist/define.d.ts +66 -29
- package/dist/define.js +778 -69
- package/dist/dev.d.ts +3 -0
- package/dist/dev.js +1 -1
- package/dist/engine.d.ts +78 -0
- package/dist/engine.js +133 -0
- package/dist/error-observability.d.ts +7 -0
- package/dist/error-observability.js +61 -0
- package/dist/error-resolution.d.ts +4 -0
- package/dist/error-resolution.js +122 -0
- package/dist/errors.d.ts +33 -0
- package/dist/errors.js +40 -0
- package/dist/fixture-sanitization.d.ts +28 -0
- package/dist/fixture-sanitization.js +227 -0
- package/dist/health-scenario.d.ts +1842 -0
- package/dist/health-scenario.js +624 -0
- package/dist/index.d.ts +21 -10
- package/dist/index.js +12 -7
- package/dist/lint.d.ts +23 -11
- package/dist/lint.js +572 -69
- package/dist/native-address.d.ts +43 -0
- package/dist/native-address.js +281 -0
- package/dist/native-egress-policy.d.ts +31 -0
- package/dist/native-egress-policy.js +288 -0
- package/dist/observability.d.ts +5 -2
- package/dist/observability.js +48 -1
- package/dist/provider.d.ts +10 -2
- package/dist/provider.js +4 -1
- package/dist/runtime/auth-flow.d.ts +5 -1
- package/dist/runtime/auth-flow.js +6 -0
- package/dist/runtime/browser.d.ts +1 -0
- package/dist/runtime/browser.js +492 -49
- package/dist/runtime/cache.d.ts +1 -0
- package/dist/runtime/cache.js +169 -15
- package/dist/runtime/choice-wordlist.d.ts +9 -0
- package/dist/runtime/choice-wordlist.js +138 -0
- package/dist/runtime/choice.d.ts +13 -1
- package/dist/runtime/choice.js +490 -102
- package/dist/runtime/chrome149-header-order.d.ts +58 -0
- package/dist/runtime/chrome149-header-order.js +289 -0
- package/dist/runtime/env.js +12 -0
- package/dist/runtime/executor.d.ts +3 -2
- package/dist/runtime/executor.js +26 -25
- package/dist/runtime/http.d.ts +1 -0
- package/dist/runtime/http.js +515 -53
- package/dist/runtime/insights.js +2 -2
- package/dist/runtime/instrumentation.d.ts +2 -2
- package/dist/runtime/instrumentation.js +366 -8
- package/dist/runtime/native-network-errors.d.ts +33 -0
- package/dist/runtime/native-network-errors.js +69 -0
- package/dist/runtime/native-network.d.ts +96 -0
- package/dist/runtime/native-network.js +1232 -0
- package/dist/runtime/ocr.d.ts +29 -0
- package/dist/runtime/ocr.js +440 -0
- package/dist/runtime/otlp.d.ts +71 -2
- package/dist/runtime/otlp.js +397 -16
- package/dist/runtime/proxy-errors.js +6 -2
- package/dist/runtime/proxy-nodemaven.d.ts +56 -0
- package/dist/runtime/proxy-nodemaven.js +146 -0
- package/dist/runtime/proxy-telemetry.d.ts +80 -1
- package/dist/runtime/proxy-telemetry.js +154 -47
- package/dist/runtime/redirects.d.ts +29 -0
- package/dist/runtime/redirects.js +36 -0
- package/dist/runtime/redis.d.ts +1 -1
- package/dist/runtime/redis.js +4 -2
- package/dist/runtime/request-options.d.ts +68 -1
- package/dist/runtime/request-options.js +548 -0
- package/dist/runtime/resolver-config.d.ts +6 -0
- package/dist/runtime/resolver-config.js +6 -0
- package/dist/runtime/resolver-public.d.ts +1 -0
- package/dist/runtime/resolver-public.js +1 -0
- package/dist/runtime/resolver-shared.d.ts +14 -0
- package/dist/runtime/resolver-shared.js +12 -0
- package/dist/runtime/resolver-vendors/bindings.d.ts +48 -0
- package/dist/runtime/resolver-vendors/bindings.js +40 -0
- package/dist/runtime/resolver-vendors/browser.d.ts +22 -0
- package/dist/runtime/resolver-vendors/browser.js +377 -0
- package/dist/runtime/resolver-vendors/capsolver.d.ts +22 -0
- package/dist/runtime/resolver-vendors/capsolver.js +531 -0
- package/dist/runtime/resolver-vendors/hosts.d.ts +2 -0
- package/dist/runtime/resolver-vendors/hosts.js +33 -0
- package/dist/runtime/resolver-vendors/twocaptcha.d.ts +24 -0
- package/dist/runtime/resolver-vendors/twocaptcha.js +408 -0
- package/dist/runtime/resolver-vendors/types.d.ts +94 -0
- package/dist/runtime/resolver-vendors/types.js +96 -0
- package/dist/runtime/resolver.d.ts +72 -0
- package/dist/runtime/resolver.js +771 -0
- package/dist/runtime/secrets.d.ts +27 -0
- package/dist/runtime/secrets.js +51 -0
- package/dist/runtime/state.d.ts +3 -0
- package/dist/runtime/state.js +277 -71
- package/dist/runtime/stealth-cookies.d.ts +20 -0
- package/dist/runtime/stealth-cookies.js +111 -0
- package/dist/runtime/stealth.d.ts +41 -5
- package/dist/runtime/stealth.js +997 -291
- package/dist/runtime/stt.js +1 -12
- package/dist/runtime/timeout.d.ts +5 -0
- package/dist/runtime/timeout.js +12 -0
- package/dist/runtime/trace-config.d.ts +12 -0
- package/dist/runtime/trace-config.js +62 -0
- package/dist/runtime/trace.d.ts +5 -0
- package/dist/runtime/trace.js +43 -10
- package/dist/serve.d.ts +1 -1
- package/dist/serve.js +1 -1
- package/dist/server/error-observability.d.ts +1 -0
- package/dist/server/error-observability.js +1 -0
- package/dist/server/index.d.ts +5 -2
- package/dist/server/index.js +2 -2
- package/dist/server/self-test-input-tokens.d.ts +2 -1
- package/dist/server/self-test-input-tokens.js +18 -14
- package/dist/server/self-test.d.ts +14 -3
- package/dist/server/self-test.js +129 -58
- package/dist/server/serve-implementation.d.ts +230 -0
- package/dist/server/serve-implementation.js +2265 -0
- package/dist/server/serve.d.ts +1 -70
- package/dist/server/serve.js +1 -1131
- package/dist/server/trace-output.d.ts +6 -0
- package/dist/server/trace-output.js +79 -0
- package/dist/server/types.d.ts +30 -5
- package/dist/server/types.js +13 -1
- package/dist/stateful/errors.d.ts +19 -0
- package/dist/stateful/errors.js +24 -0
- package/dist/stateful/http-provider-event-emitter.d.ts +40 -0
- package/dist/stateful/http-provider-event-emitter.js +237 -0
- package/dist/stateful/http-session-owner-registry.d.ts +44 -0
- package/dist/stateful/http-session-owner-registry.js +210 -0
- package/dist/stateful/index.d.ts +18 -0
- package/dist/stateful/index.js +18 -0
- package/dist/stateful/provider-event-delivery-failures.d.ts +32 -0
- package/dist/stateful/provider-event-delivery-failures.js +43 -0
- package/dist/stateful/provider-event-pipeline-metrics.d.ts +46 -0
- package/dist/stateful/provider-event-pipeline-metrics.js +48 -0
- package/dist/stateful/provider-event-pipeline.d.ts +50 -0
- package/dist/stateful/provider-event-pipeline.js +1 -0
- package/dist/stateful/provider-events.d.ts +101 -0
- package/dist/stateful/provider-events.js +289 -0
- package/dist/stateful/session-key.d.ts +15 -0
- package/dist/stateful/session-key.js +86 -0
- package/dist/stateful/stateful-provider-adapter-context.d.ts +5 -0
- package/dist/stateful/stateful-provider-adapter-context.js +42 -0
- package/dist/stateful/stateful-provider-adapter-metrics.d.ts +15 -0
- package/dist/stateful/stateful-provider-adapter-metrics.js +21 -0
- package/dist/stateful/stateful-provider-adapter.d.ts +98 -0
- package/dist/stateful/stateful-provider-adapter.js +287 -0
- package/dist/stateful/stateful-provider-observability.d.ts +62 -0
- package/dist/stateful/stateful-provider-observability.js +161 -0
- package/dist/stateful/stateful-provider-owner-forwarder.d.ts +41 -0
- package/dist/stateful/stateful-provider-owner-forwarder.js +215 -0
- package/dist/stateful/stateful-provider-runtime-context.d.ts +32 -0
- package/dist/stateful/stateful-provider-runtime-context.js +60 -0
- package/dist/stateful/stateful-provider-runtime-executor.d.ts +34 -0
- package/dist/stateful/stateful-provider-runtime-executor.js +52 -0
- package/dist/stateful/stateful-provider-session-routing.d.ts +67 -0
- package/dist/stateful/stateful-provider-session-routing.js +345 -0
- package/dist/stateful/stateful-provider-session-runtime.d.ts +98 -0
- package/dist/stateful/stateful-provider-session-runtime.js +245 -0
- package/dist/stateful-signing.d.ts +18 -0
- package/dist/stateful-signing.js +27 -0
- package/dist/stealth/profiles.d.ts +9 -4
- package/dist/stealth/profiles.js +160 -211
- package/dist/stream-evidence.d.ts +74 -0
- package/dist/stream-evidence.js +785 -0
- package/dist/stream.js +7 -1
- package/dist/testing/index.d.ts +2 -1
- package/dist/testing/index.js +2 -1
- package/dist/testing/run.d.ts +32 -2
- package/dist/testing/run.js +489 -21
- package/dist/trace-sanitization.d.ts +5 -0
- package/dist/trace-sanitization.js +45 -0
- package/dist/types.d.ts +673 -131
- package/dist/types.js +1 -0
- package/package.json +45 -5
- package/src/auth-turn/index.ts +1 -1
- package/src/auth.ts +118 -0
- package/src/ceremonies/index.ts +189 -46
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/approval-override.ts.txt +6 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/codemod-syntax.ts.txt +3 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/connection-precedence.ts.txt +10 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/docs-conflict.ts.txt +8 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/examples-hoisted-array-spread.ts.txt +15 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/examples-imported-array-spread.ts.txt +9 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/examples-map.ts.txt +5 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/examples-mixed-array-spread.ts.txt +24 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/examples-operation.ts.txt +16 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/factory-map.ts.txt +3 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/hoist-all.ts.txt +31 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/hoisted-const.ts.txt +11 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/imported-spread.ts.txt +11 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/inline-map.ts.txt +11 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/inline-spread-cast-tail.ts.txt +21 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/inline-spread-ekitan.ts.txt +11 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/inline-spread-override.ts.txt +14 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/missing-english-locale.ts.txt +7 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/no-safety.ts.txt +6 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/non-literal.ts.txt +7 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/redundant-approval.ts.txt +6 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/safety-conflict.ts.txt +7 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/stream.ts.txt +7 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/tool-router-spread.ts.txt +15 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/unparseable.ts.txt +4 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/verbatim-template.ts.txt +12 -0
- package/src/cli/commands.ts +33 -0
- package/src/cli/create.ts +50 -37
- package/src/cli/migrate-operation-declaration.ts +1751 -0
- package/src/cli/migrate-operation-shape.ts +184 -0
- package/src/cli/migrate-provider-shape.ts +772 -0
- package/src/cli/prompt-assets.ts +865 -0
- package/src/cli/templates/provider/AGENTS.md.tpl +17 -8
- package/src/cli/templates/provider/Dockerfile.tpl +1 -1
- package/src/cli/templates/provider/README.md.tpl +5 -5
- package/src/cli/templates/provider/index.ts.tpl +6 -3
- package/src/cli/templates/provider/operations/ping.ts.tpl +4 -1
- package/src/cli/templates/provider/provider.json.tpl +6 -0
- package/src/config/loader.ts +690 -163
- package/src/contract-serialization.ts +5 -7
- package/src/contract-types.ts +12 -5
- package/src/contract.ts +24 -10
- package/src/declaration-validation.ts +330 -0
- package/src/define.ts +1048 -131
- package/src/dev.ts +4 -1
- package/src/engine.ts +279 -0
- package/src/error-observability.ts +64 -0
- package/src/error-resolution.ts +127 -0
- package/src/errors.ts +68 -0
- package/src/fixture-sanitization.ts +264 -0
- package/src/health-scenario.ts +875 -0
- package/src/index.ts +220 -13
- package/src/lint.ts +698 -90
- package/src/native-address.ts +340 -0
- package/src/native-egress-policy.ts +358 -0
- package/src/observability.ts +51 -1
- package/src/provider.ts +161 -3
- package/src/runtime/auth-flow.ts +12 -0
- package/src/runtime/browser.ts +661 -63
- package/src/runtime/cache.ts +189 -14
- package/src/runtime/choice-wordlist.ts +145 -0
- package/src/runtime/choice.ts +631 -120
- package/src/runtime/chrome149-header-order.ts +330 -0
- package/src/runtime/env.ts +13 -0
- package/src/runtime/executor.ts +43 -31
- package/src/runtime/http.ts +641 -61
- package/src/runtime/insights.ts +2 -2
- package/src/runtime/instrumentation.ts +520 -15
- package/src/runtime/native-network-errors.ts +99 -0
- package/src/runtime/native-network.ts +1605 -0
- package/src/runtime/ocr.ts +523 -0
- package/src/runtime/otlp.ts +467 -21
- package/src/runtime/proxy-errors.ts +12 -4
- package/src/runtime/proxy-nodemaven.ts +221 -0
- package/src/runtime/proxy-telemetry.ts +244 -75
- package/src/runtime/redirects.ts +66 -0
- package/src/runtime/redis.ts +7 -2
- package/src/runtime/request-options.ts +680 -1
- package/src/runtime/resolver-config.ts +6 -0
- package/src/runtime/resolver-public.ts +23 -0
- package/src/runtime/resolver-shared.ts +33 -0
- package/src/runtime/resolver-vendors/bindings.ts +56 -0
- package/src/runtime/resolver-vendors/browser.ts +533 -0
- package/src/runtime/resolver-vendors/capsolver.ts +707 -0
- package/src/runtime/resolver-vendors/hosts.ts +38 -0
- package/src/runtime/resolver-vendors/twocaptcha.ts +540 -0
- package/src/runtime/resolver-vendors/types.ts +212 -0
- package/src/runtime/resolver.ts +1157 -0
- package/src/runtime/secrets.ts +64 -0
- package/src/runtime/state.ts +394 -77
- package/src/runtime/stealth-cookies.ts +132 -0
- package/src/runtime/stealth.ts +1280 -336
- package/src/runtime/stt.ts +1 -19
- package/src/runtime/timeout.ts +18 -0
- package/src/runtime/trace-config.ts +78 -0
- package/src/runtime/trace.ts +57 -17
- package/src/serve.ts +6 -1
- package/src/server/error-observability.ts +1 -0
- package/src/server/index.ts +34 -2
- package/src/server/self-test-input-tokens.ts +29 -14
- package/src/server/self-test.ts +191 -68
- package/src/server/serve-implementation.ts +3378 -0
- package/src/server/serve.ts +1 -1632
- package/src/server/trace-output.ts +129 -0
- package/src/server/types.ts +13 -1
- package/src/stateful/README.md +146 -0
- package/src/stateful/errors.ts +35 -0
- package/src/stateful/http-provider-event-emitter.ts +314 -0
- package/src/stateful/http-session-owner-registry.ts +306 -0
- package/src/stateful/index.ts +18 -0
- package/src/stateful/provider-event-delivery-failures.ts +80 -0
- package/src/stateful/provider-event-pipeline-metrics.ts +95 -0
- package/src/stateful/provider-event-pipeline.ts +61 -0
- package/src/stateful/provider-events.ts +462 -0
- package/src/stateful/session-key.ts +111 -0
- package/src/stateful/stateful-provider-adapter-context.ts +59 -0
- package/src/stateful/stateful-provider-adapter-metrics.ts +48 -0
- package/src/stateful/stateful-provider-adapter.ts +562 -0
- package/src/stateful/stateful-provider-observability.ts +261 -0
- package/src/stateful/stateful-provider-owner-forwarder.ts +287 -0
- package/src/stateful/stateful-provider-runtime-context.ts +92 -0
- package/src/stateful/stateful-provider-runtime-executor.ts +96 -0
- package/src/stateful/stateful-provider-session-routing.ts +546 -0
- package/src/stateful/stateful-provider-session-runtime.ts +403 -0
- package/src/stateful-signing.ts +46 -0
- package/src/stealth/profiles.ts +202 -231
- package/src/stream-evidence.ts +988 -0
- package/src/stream.ts +8 -1
- package/src/testing/index.ts +10 -1
- package/src/testing/run.ts +658 -15
- package/src/trace-sanitization.ts +63 -0
- package/src/types.ts +788 -174
- package/dist/cli/templates/provider/CLAUDE.md.tpl +0 -1
- package/src/cli/templates/provider/CLAUDE.md.tpl +0 -1
- /package/dist/cli/templates/provider/{skills → .agents/skills}/fixtures-and-recording/SKILL.md.tpl +0 -0
- /package/dist/cli/templates/provider/{skills → .agents/skills}/health-checks-and-fail-closed/SKILL.md.tpl +0 -0
- /package/dist/cli/templates/provider/{skills → .agents/skills}/normalization-standards/SKILL.md.tpl +0 -0
- /package/dist/cli/templates/provider/{skills → .agents/skills}/pagination-and-counts/SKILL.md.tpl +0 -0
- /package/dist/cli/templates/provider/{skills → .agents/skills}/upstream-contract-verification/SKILL.md.tpl +0 -0
- /package/dist/cli/templates/provider/{skills → .agents/skills}/upstream-notes/README.md.tpl +0 -0
- /package/src/cli/templates/provider/{skills → .agents/skills}/fixtures-and-recording/SKILL.md.tpl +0 -0
- /package/src/cli/templates/provider/{skills → .agents/skills}/health-checks-and-fail-closed/SKILL.md.tpl +0 -0
- /package/src/cli/templates/provider/{skills → .agents/skills}/normalization-standards/SKILL.md.tpl +0 -0
- /package/src/cli/templates/provider/{skills → .agents/skills}/pagination-and-counts/SKILL.md.tpl +0 -0
- /package/src/cli/templates/provider/{skills → .agents/skills}/upstream-contract-verification/SKILL.md.tpl +0 -0
- /package/src/cli/templates/provider/{skills → .agents/skills}/upstream-notes/README.md.tpl +0 -0
|
@@ -1,8 +1,87 @@
|
|
|
1
|
-
import type { ProxyAttemptTelemetryEvent, ProxyResolutionTelemetryEvent, ProxyTelemetrySink } from "../config/loader.js";
|
|
1
|
+
import type { ProxyAttemptTelemetryEvent, ProxyCacheStatus, ProxyProtocol, ProxyResolutionTelemetryEvent, ProxyTelemetrySink, ProxyUserAgentSource, ProxyVendorFailoverTelemetryEvent, ProxyVendorName, SmartproxyAllocatorBodyClass } from "../config/loader.js";
|
|
2
2
|
export declare const PROVIDER_TELEMETRY_HEADER = "X-ApiFuse-Provider-Telemetry";
|
|
3
|
+
export type ProxyTelemetryResolvedPayload = {
|
|
4
|
+
kind: "resolved";
|
|
5
|
+
provider: ProxyVendorName;
|
|
6
|
+
userAgentSource?: ProxyUserAgentSource;
|
|
7
|
+
protocol?: ProxyProtocol;
|
|
8
|
+
cacheStatus: ProxyCacheStatus;
|
|
9
|
+
cacheHit: boolean;
|
|
10
|
+
resolutionMs: number;
|
|
11
|
+
allocatorMs?: number;
|
|
12
|
+
allocatorStatus?: number;
|
|
13
|
+
allocatorBodyClass?: SmartproxyAllocatorBodyClass;
|
|
14
|
+
allocatorAttempts?: number;
|
|
15
|
+
lockWaitMs?: number;
|
|
16
|
+
redisReadMs?: number;
|
|
17
|
+
redisWriteMs?: number;
|
|
18
|
+
poolAgeMs?: number;
|
|
19
|
+
poolExpiresInMs?: number;
|
|
20
|
+
attempts: number;
|
|
21
|
+
refreshes?: number;
|
|
22
|
+
attemptSamples?: {
|
|
23
|
+
n: number;
|
|
24
|
+
a: number;
|
|
25
|
+
i?: number;
|
|
26
|
+
h?: string;
|
|
27
|
+
o: ProxyAttemptTelemetryEvent["outcome"];
|
|
28
|
+
c?: string;
|
|
29
|
+
s?: number;
|
|
30
|
+
d?: number;
|
|
31
|
+
}[];
|
|
32
|
+
/** Distinct vendors attempted across the resolution chain, in order seen. */
|
|
33
|
+
vendors?: ProxyVendorName[];
|
|
34
|
+
/** Cross-vendor failover events (bounded). */
|
|
35
|
+
failovers?: {
|
|
36
|
+
v: ProxyVendorName;
|
|
37
|
+
nx?: ProxyVendorName;
|
|
38
|
+
p: ProxyVendorFailoverTelemetryEvent["phase"];
|
|
39
|
+
r: ProxyVendorFailoverTelemetryEvent["reason"];
|
|
40
|
+
a?: number;
|
|
41
|
+
}[];
|
|
42
|
+
};
|
|
43
|
+
export type ProxyTelemetryUnresolvedPayload = {
|
|
44
|
+
kind: "unresolved";
|
|
45
|
+
/** Distinct vendors that failed resolution or recorded a failover, in order seen. */
|
|
46
|
+
vendors: ProxyVendorName[];
|
|
47
|
+
cacheStatus?: ProxyCacheStatus;
|
|
48
|
+
cacheHit?: boolean;
|
|
49
|
+
resolutionMs?: number;
|
|
50
|
+
allocatorMs?: number;
|
|
51
|
+
allocatorStatus?: number;
|
|
52
|
+
allocatorBodyClass?: SmartproxyAllocatorBodyClass;
|
|
53
|
+
allocatorAttempts?: number;
|
|
54
|
+
lockWaitMs?: number;
|
|
55
|
+
redisReadMs?: number;
|
|
56
|
+
redisWriteMs?: number;
|
|
57
|
+
poolAgeMs?: number;
|
|
58
|
+
poolExpiresInMs?: number;
|
|
59
|
+
attempts?: number;
|
|
60
|
+
refreshes?: number;
|
|
61
|
+
failovers?: {
|
|
62
|
+
v: ProxyVendorName;
|
|
63
|
+
nx?: ProxyVendorName;
|
|
64
|
+
p: ProxyVendorFailoverTelemetryEvent["phase"];
|
|
65
|
+
r: ProxyVendorFailoverTelemetryEvent["reason"];
|
|
66
|
+
a?: number;
|
|
67
|
+
}[];
|
|
68
|
+
attemptSamples?: {
|
|
69
|
+
n: number;
|
|
70
|
+
a: number;
|
|
71
|
+
i?: number;
|
|
72
|
+
h?: string;
|
|
73
|
+
o: ProxyAttemptTelemetryEvent["outcome"];
|
|
74
|
+
c?: string;
|
|
75
|
+
s?: number;
|
|
76
|
+
d?: number;
|
|
77
|
+
}[];
|
|
78
|
+
};
|
|
79
|
+
export type ProxyTelemetryLogPayload = ProxyTelemetryResolvedPayload | ProxyTelemetryUnresolvedPayload;
|
|
3
80
|
export declare class ProxyTelemetryCollector implements ProxyTelemetrySink {
|
|
4
81
|
#private;
|
|
5
82
|
recordProxyResolution(event: ProxyResolutionTelemetryEvent): void;
|
|
83
|
+
recordProxyVendorFailover(event: ProxyVendorFailoverTelemetryEvent): void;
|
|
6
84
|
recordProxyAttempt(event: ProxyAttemptTelemetryEvent): void;
|
|
85
|
+
toLogPayload(): ProxyTelemetryLogPayload | undefined;
|
|
7
86
|
toHeaderValue(): string | undefined;
|
|
8
87
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export const PROVIDER_TELEMETRY_HEADER = "X-ApiFuse-Provider-Telemetry";
|
|
2
2
|
const MAX_HEADER_BYTES = 4_096;
|
|
3
3
|
const MAX_PROXY_ATTEMPT_SAMPLES = 24;
|
|
4
|
+
const MAX_PROXY_FAILOVER_SAMPLES = 12;
|
|
4
5
|
const CACHE_STATUS_SEVERITY = {
|
|
5
6
|
disabled: 0,
|
|
6
7
|
memory_hit: 1,
|
|
@@ -28,9 +29,15 @@ function encodeBase64Url(value) {
|
|
|
28
29
|
export class ProxyTelemetryCollector {
|
|
29
30
|
#events = [];
|
|
30
31
|
#attempts = [];
|
|
32
|
+
#failovers = [];
|
|
33
|
+
#unresolvedVendors = [];
|
|
31
34
|
recordProxyResolution(event) {
|
|
35
|
+
const outcome = event.outcome === "error" ? "error" : "ok";
|
|
32
36
|
this.#events.push({
|
|
33
|
-
provider:
|
|
37
|
+
provider: event.provider,
|
|
38
|
+
outcome,
|
|
39
|
+
...(event.userAgentSource ? { userAgentSource: event.userAgentSource } : {}),
|
|
40
|
+
...(event.protocol ? { protocol: event.protocol } : {}),
|
|
34
41
|
cacheStatus: event.cacheStatus,
|
|
35
42
|
cacheHit: event.cacheHit,
|
|
36
43
|
resolutionMs: Math.max(0, Math.floor(event.resolutionMs)),
|
|
@@ -52,12 +59,29 @@ export class ProxyTelemetryCollector {
|
|
|
52
59
|
attempts: Math.max(1, Math.floor(event.attempts || 1)),
|
|
53
60
|
refreshes: event.refreshes === undefined ? undefined : Math.max(0, Math.floor(event.refreshes)),
|
|
54
61
|
});
|
|
62
|
+
if (outcome === "error" && !this.#unresolvedVendors.includes(event.provider)) {
|
|
63
|
+
this.#unresolvedVendors.push(event.provider);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
recordProxyVendorFailover(event) {
|
|
67
|
+
if (this.#failovers.length >= MAX_PROXY_FAILOVER_SAMPLES)
|
|
68
|
+
return;
|
|
69
|
+
this.#failovers.push({
|
|
70
|
+
vendor: event.vendor,
|
|
71
|
+
...(event.nextVendor ? { nextVendor: event.nextVendor } : {}),
|
|
72
|
+
phase: event.phase,
|
|
73
|
+
reason: event.reason,
|
|
74
|
+
...(event.attempt === undefined ? {} : { attempt: Math.max(0, Math.floor(event.attempt)) }),
|
|
75
|
+
});
|
|
76
|
+
if (!this.#unresolvedVendors.includes(event.vendor)) {
|
|
77
|
+
this.#unresolvedVendors.push(event.vendor);
|
|
78
|
+
}
|
|
55
79
|
}
|
|
56
80
|
recordProxyAttempt(event) {
|
|
57
81
|
if (this.#attempts.length >= MAX_PROXY_ATTEMPT_SAMPLES)
|
|
58
82
|
return;
|
|
59
83
|
this.#attempts.push({
|
|
60
|
-
provider:
|
|
84
|
+
provider: event.provider,
|
|
61
85
|
attempt: Math.max(1, Math.floor(event.attempt || 1)),
|
|
62
86
|
...(event.poolIndex === undefined
|
|
63
87
|
? {}
|
|
@@ -71,12 +95,100 @@ export class ProxyTelemetryCollector {
|
|
|
71
95
|
: { durationMs: Math.max(0, Math.floor(event.durationMs)) }),
|
|
72
96
|
});
|
|
73
97
|
}
|
|
74
|
-
|
|
98
|
+
toLogPayload() {
|
|
75
99
|
const [first, ...rest] = this.#events;
|
|
76
|
-
|
|
77
|
-
|
|
100
|
+
const okEvents = this.#events.filter((event) => event.outcome !== "error");
|
|
101
|
+
const attemptSamples = this.#attempts.map((attempt, index) => ({
|
|
102
|
+
n: index + 1,
|
|
103
|
+
a: attempt.attempt,
|
|
104
|
+
...(attempt.poolIndex === undefined ? {} : { i: attempt.poolIndex }),
|
|
105
|
+
...(attempt.proxyHash ? { h: attempt.proxyHash } : {}),
|
|
106
|
+
o: attempt.outcome,
|
|
107
|
+
...(attempt.errorCode ? { c: attempt.errorCode } : {}),
|
|
108
|
+
...(attempt.status === undefined ? {} : { s: attempt.status }),
|
|
109
|
+
...(attempt.durationMs === undefined ? {} : { d: attempt.durationMs }),
|
|
110
|
+
}));
|
|
111
|
+
const failovers = this.#failovers.map((failover) => ({
|
|
112
|
+
v: failover.vendor,
|
|
113
|
+
...(failover.nextVendor ? { nx: failover.nextVendor } : {}),
|
|
114
|
+
p: failover.phase,
|
|
115
|
+
r: failover.reason,
|
|
116
|
+
...(failover.attempt === undefined ? {} : { a: failover.attempt }),
|
|
117
|
+
}));
|
|
118
|
+
if (okEvents.length === 0) {
|
|
119
|
+
if (!first && failovers.length === 0)
|
|
120
|
+
return undefined;
|
|
121
|
+
const failureEvents = this.#events.filter((event) => event.outcome === "error");
|
|
122
|
+
const [firstFailure, ...remainingFailures] = failureEvents;
|
|
123
|
+
const aggregate = firstFailure
|
|
124
|
+
? remainingFailures.reduce((acc, event) => ({
|
|
125
|
+
provider: event.provider,
|
|
126
|
+
outcome: "error",
|
|
127
|
+
cacheStatus: worseStatus(acc.cacheStatus, event.cacheStatus),
|
|
128
|
+
cacheHit: acc.cacheHit && event.cacheHit,
|
|
129
|
+
resolutionMs: acc.resolutionMs + event.resolutionMs,
|
|
130
|
+
allocatorMs: sumOptional(acc.allocatorMs, event.allocatorMs),
|
|
131
|
+
allocatorStatus: event.allocatorStatus ?? acc.allocatorStatus,
|
|
132
|
+
allocatorBodyClass: event.allocatorBodyClass ?? acc.allocatorBodyClass,
|
|
133
|
+
allocatorAttempts: sumOptional(acc.allocatorAttempts, event.allocatorAttempts),
|
|
134
|
+
lockWaitMs: sumOptional(acc.lockWaitMs, event.lockWaitMs),
|
|
135
|
+
redisReadMs: sumOptional(acc.redisReadMs, event.redisReadMs),
|
|
136
|
+
redisWriteMs: sumOptional(acc.redisWriteMs, event.redisWriteMs),
|
|
137
|
+
poolAgeMs: maxOptional(acc.poolAgeMs, event.poolAgeMs),
|
|
138
|
+
poolExpiresInMs: maxOptional(acc.poolExpiresInMs, event.poolExpiresInMs),
|
|
139
|
+
attempts: acc.attempts + event.attempts,
|
|
140
|
+
refreshes: sumOptional(acc.refreshes, event.refreshes),
|
|
141
|
+
}), firstFailure)
|
|
142
|
+
: undefined;
|
|
143
|
+
return {
|
|
144
|
+
kind: "unresolved",
|
|
145
|
+
vendors: [...this.#unresolvedVendors],
|
|
146
|
+
...(aggregate
|
|
147
|
+
? {
|
|
148
|
+
cacheStatus: aggregate.cacheStatus,
|
|
149
|
+
cacheHit: aggregate.cacheHit,
|
|
150
|
+
resolutionMs: aggregate.resolutionMs,
|
|
151
|
+
...(aggregate.allocatorMs !== undefined
|
|
152
|
+
? { allocatorMs: aggregate.allocatorMs }
|
|
153
|
+
: {}),
|
|
154
|
+
...(aggregate.allocatorStatus !== undefined
|
|
155
|
+
? { allocatorStatus: aggregate.allocatorStatus }
|
|
156
|
+
: {}),
|
|
157
|
+
...(aggregate.allocatorBodyClass !== undefined
|
|
158
|
+
? { allocatorBodyClass: aggregate.allocatorBodyClass }
|
|
159
|
+
: {}),
|
|
160
|
+
...(aggregate.allocatorAttempts !== undefined
|
|
161
|
+
? { allocatorAttempts: aggregate.allocatorAttempts }
|
|
162
|
+
: {}),
|
|
163
|
+
...(aggregate.lockWaitMs !== undefined ? { lockWaitMs: aggregate.lockWaitMs } : {}),
|
|
164
|
+
...(aggregate.redisReadMs !== undefined
|
|
165
|
+
? { redisReadMs: aggregate.redisReadMs }
|
|
166
|
+
: {}),
|
|
167
|
+
...(aggregate.redisWriteMs !== undefined
|
|
168
|
+
? { redisWriteMs: aggregate.redisWriteMs }
|
|
169
|
+
: {}),
|
|
170
|
+
...(aggregate.poolAgeMs !== undefined ? { poolAgeMs: aggregate.poolAgeMs } : {}),
|
|
171
|
+
...(aggregate.poolExpiresInMs !== undefined
|
|
172
|
+
? { poolExpiresInMs: aggregate.poolExpiresInMs }
|
|
173
|
+
: {}),
|
|
174
|
+
attempts: aggregate.attempts,
|
|
175
|
+
...(aggregate.refreshes !== undefined ? { refreshes: aggregate.refreshes } : {}),
|
|
176
|
+
}
|
|
177
|
+
: {}),
|
|
178
|
+
...(failovers.length > 0 ? { failovers } : {}),
|
|
179
|
+
...(attemptSamples.length > 0 ? { attemptSamples } : {}),
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
// The serving vendor/protocol is the last successful resolution.
|
|
183
|
+
const serving = okEvents[okEvents.length - 1] ?? first;
|
|
184
|
+
const vendors = [];
|
|
185
|
+
for (const event of this.#events) {
|
|
186
|
+
if (!vendors.includes(event.provider))
|
|
187
|
+
vendors.push(event.provider);
|
|
188
|
+
}
|
|
78
189
|
const aggregate = rest.reduce((acc, event) => ({
|
|
79
|
-
provider:
|
|
190
|
+
provider: event.provider,
|
|
191
|
+
userAgentSource: event.userAgentSource ?? acc.userAgentSource,
|
|
80
192
|
cacheStatus: worseStatus(acc.cacheStatus, event.cacheStatus),
|
|
81
193
|
cacheHit: acc.cacheHit && event.cacheHit,
|
|
82
194
|
resolutionMs: acc.resolutionMs + event.resolutionMs,
|
|
@@ -92,48 +204,43 @@ export class ProxyTelemetryCollector {
|
|
|
92
204
|
attempts: acc.attempts + event.attempts,
|
|
93
205
|
refreshes: sumOptional(acc.refreshes, event.refreshes),
|
|
94
206
|
}), first);
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
a: attempt.attempt,
|
|
126
|
-
...(attempt.poolIndex === undefined ? {} : { i: attempt.poolIndex }),
|
|
127
|
-
...(attempt.proxyHash ? { h: attempt.proxyHash } : {}),
|
|
128
|
-
o: attempt.outcome,
|
|
129
|
-
...(attempt.errorCode ? { c: attempt.errorCode } : {}),
|
|
130
|
-
...(attempt.status === undefined ? {} : { s: attempt.status }),
|
|
131
|
-
...(attempt.durationMs === undefined ? {} : { d: attempt.durationMs }),
|
|
132
|
-
})),
|
|
133
|
-
}
|
|
134
|
-
: {}),
|
|
135
|
-
},
|
|
207
|
+
return {
|
|
208
|
+
kind: "resolved",
|
|
209
|
+
provider: serving.provider,
|
|
210
|
+
...(aggregate.userAgentSource ? { userAgentSource: aggregate.userAgentSource } : {}),
|
|
211
|
+
...(serving.protocol ? { protocol: serving.protocol } : {}),
|
|
212
|
+
cacheStatus: aggregate.cacheStatus,
|
|
213
|
+
cacheHit: aggregate.cacheHit,
|
|
214
|
+
resolutionMs: aggregate.resolutionMs,
|
|
215
|
+
...(aggregate.allocatorMs !== undefined ? { allocatorMs: aggregate.allocatorMs } : {}),
|
|
216
|
+
...(aggregate.allocatorStatus !== undefined
|
|
217
|
+
? { allocatorStatus: aggregate.allocatorStatus }
|
|
218
|
+
: {}),
|
|
219
|
+
...(aggregate.allocatorBodyClass !== undefined
|
|
220
|
+
? { allocatorBodyClass: aggregate.allocatorBodyClass }
|
|
221
|
+
: {}),
|
|
222
|
+
...(aggregate.allocatorAttempts !== undefined
|
|
223
|
+
? { allocatorAttempts: aggregate.allocatorAttempts }
|
|
224
|
+
: {}),
|
|
225
|
+
...(aggregate.lockWaitMs !== undefined ? { lockWaitMs: aggregate.lockWaitMs } : {}),
|
|
226
|
+
...(aggregate.redisReadMs !== undefined ? { redisReadMs: aggregate.redisReadMs } : {}),
|
|
227
|
+
...(aggregate.redisWriteMs !== undefined ? { redisWriteMs: aggregate.redisWriteMs } : {}),
|
|
228
|
+
...(aggregate.poolAgeMs !== undefined ? { poolAgeMs: aggregate.poolAgeMs } : {}),
|
|
229
|
+
...(aggregate.poolExpiresInMs !== undefined
|
|
230
|
+
? { poolExpiresInMs: aggregate.poolExpiresInMs }
|
|
231
|
+
: {}),
|
|
232
|
+
attempts: aggregate.attempts,
|
|
233
|
+
...(aggregate.refreshes !== undefined ? { refreshes: aggregate.refreshes } : {}),
|
|
234
|
+
...(attemptSamples.length > 0 ? { attemptSamples } : {}),
|
|
235
|
+
...(vendors.length > 1 ? { vendors } : {}),
|
|
236
|
+
...(failovers.length > 0 ? { failovers } : {}),
|
|
136
237
|
};
|
|
238
|
+
}
|
|
239
|
+
toHeaderValue() {
|
|
240
|
+
const proxy = this.toLogPayload();
|
|
241
|
+
if (!proxy)
|
|
242
|
+
return undefined;
|
|
243
|
+
const payload = { v: 1, proxy };
|
|
137
244
|
const encoded = encodeBase64Url(JSON.stringify(payload));
|
|
138
245
|
if (encoded.length > MAX_HEADER_BYTES)
|
|
139
246
|
return undefined;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { HttpRedirectFailureReason } from "../types.js";
|
|
2
|
+
export type RedirectHopDecision<TMethod extends string> = {
|
|
3
|
+
kind: "follow";
|
|
4
|
+
nextMethod: TMethod | "GET";
|
|
5
|
+
nextUrl: string;
|
|
6
|
+
} | {
|
|
7
|
+
kind: "stop";
|
|
8
|
+
reason: HttpRedirectFailureReason;
|
|
9
|
+
nextUrl?: string;
|
|
10
|
+
};
|
|
11
|
+
export declare function isRedirectStatus(status: number): boolean;
|
|
12
|
+
/** Shared fetch-compatible redirect method rewriting for stealth and ctx.http. */
|
|
13
|
+
export declare function nextRedirectMethod<TMethod extends string>(status: number, method: TMethod): TMethod | "GET";
|
|
14
|
+
/** Resolves a Location value against the response URL without issuing a request. */
|
|
15
|
+
export declare function resolveRedirectUrl(location: string | undefined, responseUrl: string): string | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Shared post-response decision ordering for both redirect walkers. The
|
|
18
|
+
* caller-owned stop hook is checked first, matching stealth's pre-follow
|
|
19
|
+
* contract, then structural termination and loop checks run before follow.
|
|
20
|
+
*/
|
|
21
|
+
export declare function evaluateRedirectHop<TMethod extends string>(input: {
|
|
22
|
+
status: number;
|
|
23
|
+
method: TMethod;
|
|
24
|
+
nextUrl: string | undefined;
|
|
25
|
+
shouldStop: boolean;
|
|
26
|
+
redirectCount: number;
|
|
27
|
+
maxHops: number;
|
|
28
|
+
visitedRequests: ReadonlySet<string>;
|
|
29
|
+
}): RedirectHopDecision<TMethod>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const REDIRECT_STATUSES = new Set([301, 302, 303, 307, 308]);
|
|
2
|
+
export function isRedirectStatus(status) {
|
|
3
|
+
return REDIRECT_STATUSES.has(status);
|
|
4
|
+
}
|
|
5
|
+
/** Shared fetch-compatible redirect method rewriting for stealth and ctx.http. */
|
|
6
|
+
export function nextRedirectMethod(status, method) {
|
|
7
|
+
if (status === 303 && method !== "HEAD")
|
|
8
|
+
return "GET";
|
|
9
|
+
if ((status === 301 || status === 302) && method === "POST")
|
|
10
|
+
return "GET";
|
|
11
|
+
return method;
|
|
12
|
+
}
|
|
13
|
+
/** Resolves a Location value against the response URL without issuing a request. */
|
|
14
|
+
export function resolveRedirectUrl(location, responseUrl) {
|
|
15
|
+
return location ? new URL(location, responseUrl).toString() : undefined;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Shared post-response decision ordering for both redirect walkers. The
|
|
19
|
+
* caller-owned stop hook is checked first, matching stealth's pre-follow
|
|
20
|
+
* contract, then structural termination and loop checks run before follow.
|
|
21
|
+
*/
|
|
22
|
+
export function evaluateRedirectHop(input) {
|
|
23
|
+
if (input.shouldStop) {
|
|
24
|
+
return { kind: "stop", reason: "stopped", ...(input.nextUrl ? { nextUrl: input.nextUrl } : {}) };
|
|
25
|
+
}
|
|
26
|
+
if (!input.nextUrl)
|
|
27
|
+
return { kind: "stop", reason: "missing_location" };
|
|
28
|
+
if (input.redirectCount > input.maxHops) {
|
|
29
|
+
return { kind: "stop", reason: "max_hops", nextUrl: input.nextUrl };
|
|
30
|
+
}
|
|
31
|
+
const nextMethod = nextRedirectMethod(input.status, input.method);
|
|
32
|
+
if (input.visitedRequests.has(`${nextMethod} ${input.nextUrl}`)) {
|
|
33
|
+
return { kind: "stop", reason: "loop", nextUrl: input.nextUrl };
|
|
34
|
+
}
|
|
35
|
+
return { kind: "follow", nextMethod, nextUrl: input.nextUrl };
|
|
36
|
+
}
|
package/dist/runtime/redis.d.ts
CHANGED
package/dist/runtime/redis.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
const require = createRequire(import.meta.url);
|
|
2
3
|
export function createProviderRedisClient(options) {
|
|
3
|
-
const
|
|
4
|
+
const { Redis: RedisClient } = require("ioredis");
|
|
5
|
+
const redis = new RedisClient(options.redisUrl, {
|
|
4
6
|
connectTimeout: options.timeoutMs,
|
|
5
7
|
enableOfflineQueue: false,
|
|
6
8
|
lazyConnect: true,
|
|
@@ -1,3 +1,70 @@
|
|
|
1
|
-
import type { RequestParams } from "../types.js";
|
|
1
|
+
import type { HttpClient, RequestOptions, RequestParams } from "../types.js";
|
|
2
|
+
export declare const REDACTED_QUERY_VALUE = "[REDACTED]";
|
|
3
|
+
/** Internal heuristic shared by diagnostic and fixture structural redaction. */
|
|
4
|
+
export declare function isSensitiveKey(key: string): boolean;
|
|
5
|
+
declare const HTTP_REQUEST_METHOD_CONFIG: {
|
|
6
|
+
readonly request: {
|
|
7
|
+
readonly optionsIndex: 1;
|
|
8
|
+
};
|
|
9
|
+
readonly get: {
|
|
10
|
+
readonly optionsIndex: 1;
|
|
11
|
+
};
|
|
12
|
+
readonly post: {
|
|
13
|
+
readonly optionsIndex: 2;
|
|
14
|
+
};
|
|
15
|
+
readonly put: {
|
|
16
|
+
readonly optionsIndex: 2;
|
|
17
|
+
};
|
|
18
|
+
readonly delete: {
|
|
19
|
+
readonly optionsIndex: 1;
|
|
20
|
+
};
|
|
21
|
+
readonly stream: {
|
|
22
|
+
readonly optionsIndex: 1;
|
|
23
|
+
};
|
|
24
|
+
readonly sse: {
|
|
25
|
+
readonly optionsIndex: 1;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export type HttpRequestMethod = keyof typeof HTTP_REQUEST_METHOD_CONFIG;
|
|
29
|
+
export type HttpRequestInvocation = {
|
|
30
|
+
[M in HttpRequestMethod]: {
|
|
31
|
+
method: M;
|
|
32
|
+
args: Parameters<HttpClient[M]>;
|
|
33
|
+
};
|
|
34
|
+
}[HttpRequestMethod];
|
|
35
|
+
export declare const HTTP_REQUEST_METHOD_NAMES: HttpRequestMethod[];
|
|
36
|
+
export declare function isHttpRequestMethod(method: PropertyKey): method is HttpRequestMethod;
|
|
37
|
+
export type SerializedRequestUrl = {
|
|
38
|
+
requestUrl: string;
|
|
39
|
+
redactedUrl: string;
|
|
40
|
+
sensitiveValues: readonly string[];
|
|
41
|
+
};
|
|
42
|
+
export declare function normalizeSensitiveParams(sensitiveParams?: Record<string, string>): Record<string, string> | undefined;
|
|
2
43
|
export declare function appendQueryParams(url: string, params?: RequestParams): string;
|
|
44
|
+
/** Redacts matching query keys without reserializing any other URL bytes. */
|
|
45
|
+
export declare function redactUrlQueryParams(url: string, sensitiveParamNames: readonly string[]): {
|
|
46
|
+
redactedUrl: string;
|
|
47
|
+
sensitiveValues: readonly string[];
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Serializes public and secret query parameters together while constructing a
|
|
51
|
+
* separate, structurally redacted URL for diagnostics and observability.
|
|
52
|
+
*/
|
|
53
|
+
export declare function serializeRequestUrl(url: string, params?: RequestParams, sensitiveParams?: Record<string, string>): SerializedRequestUrl;
|
|
54
|
+
/** Scrubs raw and URL-encoded secret values from diagnostic text. */
|
|
55
|
+
export declare function redactSensitiveText(text: string, sensitiveValues: readonly string[], requestUrl?: string, redactedUrl?: string): string;
|
|
56
|
+
/**
|
|
57
|
+
* Redacts error text and recursively serializable diagnostic metadata.
|
|
58
|
+
* Mutable errors retain identity; readonly/frozen errors may be replaced, so
|
|
59
|
+
* callers must use the returned value.
|
|
60
|
+
*/
|
|
61
|
+
export declare function redactSensitiveError<T>(error: T, sensitiveValues: readonly string[], requestUrl?: string, redactedUrl?: string): T;
|
|
62
|
+
/** Redacts failures that occur before a request URL can be fully serialized. */
|
|
63
|
+
export declare function redactSensitiveRequestError<T>(error: T, url: string, sensitiveParams?: Record<string, string>): T;
|
|
64
|
+
/** Validates an untyped proxy invocation before narrowing it to the HttpClient contract. */
|
|
65
|
+
export declare function parseHttpRequestInvocation(method: PropertyKey, args: unknown[]): HttpRequestInvocation | undefined;
|
|
66
|
+
/** Internal typed registry for the request-options position of HttpClient calls. */
|
|
67
|
+
export declare function requestOptionsFromHttpInvocation(invocation: HttpRequestInvocation): RequestOptions | undefined;
|
|
68
|
+
export declare function replaceRequestOptionsInHttpInvocation(invocation: HttpRequestInvocation, options: RequestOptions): void;
|
|
3
69
|
export declare function normalizeHttpRequestBody(body: unknown): string | Buffer | undefined;
|
|
70
|
+
export {};
|