@apifuse/provider-sdk 2.2.0-beta.7 → 2.2.0-beta.70
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 +943 -51
- package/CHANGELOG.md +273 -1
- package/LICENSE +21 -0
- package/README.md +117 -29
- package/SUBMISSION.md +3 -2
- package/bin/apifuse-check.ts +293 -13
- package/bin/apifuse-dev.ts +42 -19
- package/bin/apifuse-migrate-deployment.ts +200 -0
- package/bin/apifuse-migrate-operation-declaration.ts +55 -0
- package/bin/apifuse-migrate-shape.ts +202 -0
- package/bin/apifuse-pack-check.ts +19 -6
- package/bin/apifuse-pack-smoke.ts +57 -2
- package/bin/apifuse-pack-types.ts +736 -38
- package/bin/apifuse-perf.ts +59 -23
- package/bin/apifuse-record.ts +923 -94
- package/bin/apifuse-submit-check.ts +2313 -281
- package/bin/apifuse-test.ts +3 -1
- 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 +30 -0
- package/dist/cli/create.d.ts +1 -1
- package/dist/cli/create.js +8 -2
- package/dist/cli/deployment-intent.d.ts +178 -0
- package/dist/cli/deployment-intent.js +277 -0
- package/dist/cli/local-connection.d.ts +111 -0
- package/dist/cli/local-connection.js +151 -0
- package/dist/cli/migrate-deployment-intent.d.ts +132 -0
- package/dist/cli/migrate-deployment-intent.js +1552 -0
- package/dist/cli/migrate-operation-declaration.d.ts +70 -0
- package/dist/cli/migrate-operation-declaration.js +2206 -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 +56 -0
- package/dist/cli/migrate-provider-shape.js +580 -0
- package/dist/cli/resolver-runtime.d.ts +21 -0
- package/dist/cli/resolver-runtime.js +31 -0
- package/dist/cli/templates/provider/.agents/skills/health-checks-and-fail-closed/SKILL.md.tpl +141 -23
- package/dist/cli/templates/provider/Dockerfile.tpl +1 -1
- package/dist/cli/templates/provider/README.md.tpl +41 -19
- 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 +202 -16
- package/dist/config/loader.js +491 -141
- 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 +34 -0
- package/dist/declaration-validation.js +305 -0
- package/dist/define.d.ts +71 -29
- package/dist/define.js +807 -69
- package/dist/dev.d.ts +5 -0
- package/dist/dev.js +8 -1
- package/dist/engine.d.ts +129 -0
- package/dist/engine.js +209 -0
- package/dist/error-observability.d.ts +7 -0
- package/dist/error-observability.js +61 -0
- package/dist/error-resolution.d.ts +18 -0
- package/dist/error-resolution.js +243 -0
- package/dist/errors.d.ts +74 -0
- package/dist/errors.js +99 -0
- package/dist/fixture-sanitization.d.ts +28 -0
- package/dist/fixture-sanitization.js +371 -0
- package/dist/handle-meta.d.ts +90 -0
- package/dist/handle-meta.js +73 -0
- package/dist/handle.d.ts +226 -0
- package/dist/handle.js +345 -0
- package/dist/health-scenario.d.ts +1901 -0
- package/dist/health-scenario.js +653 -0
- package/dist/i18n/catalog.js +21 -1
- package/dist/i18n/error-messages.d.ts +86 -0
- package/dist/i18n/error-messages.js +192 -0
- package/dist/i18n/index.d.ts +1 -0
- package/dist/i18n/index.js +1 -0
- package/dist/i18n/keys.d.ts +12 -0
- package/dist/i18n/keys.js +76 -5
- package/dist/i18n/operation-locale-namespace.d.ts +2 -0
- package/dist/i18n/operation-locale-namespace.js +7 -0
- package/dist/index.d.ts +40 -15
- package/dist/index.js +29 -11
- package/dist/lint.d.ts +43 -11
- package/dist/lint.js +2512 -177
- 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 +18 -8
- package/dist/provider.js +11 -6
- package/dist/runtime/auth-flow.d.ts +6 -1
- package/dist/runtime/auth-flow.js +8 -0
- package/dist/runtime/bounded-expiring-map.d.ts +21 -0
- package/dist/runtime/bounded-expiring-map.js +64 -0
- package/dist/runtime/browser-telemetry-binding.d.ts +5 -0
- package/dist/runtime/browser-telemetry-binding.js +83 -0
- package/dist/runtime/browser-telemetry.d.ts +76 -0
- package/dist/runtime/browser-telemetry.js +165 -0
- package/dist/runtime/browser.d.ts +4 -0
- package/dist/runtime/browser.js +688 -83
- package/dist/runtime/cache-telemetry.d.ts +71 -0
- package/dist/runtime/cache-telemetry.js +177 -0
- package/dist/runtime/cache.d.ts +3 -0
- package/dist/runtime/cache.js +245 -23
- package/dist/runtime/capability-response.d.ts +3 -0
- package/dist/runtime/capability-response.js +56 -0
- package/dist/runtime/capability-telemetry.d.ts +46 -0
- package/dist/runtime/capability-telemetry.js +68 -0
- package/dist/runtime/chrome149-header-order.d.ts +58 -0
- package/dist/runtime/chrome149-header-order.js +289 -0
- package/dist/runtime/diagnostic-env-values.d.ts +5 -0
- package/dist/runtime/diagnostic-env-values.js +57 -0
- package/dist/runtime/diagnostic-env.d.ts +14 -0
- package/dist/runtime/diagnostic-env.js +44 -0
- package/dist/runtime/diagnostic-redactor.d.ts +54 -0
- package/dist/runtime/diagnostic-redactor.js +571 -0
- package/dist/runtime/egress-lease.d.ts +65 -0
- package/dist/runtime/egress-lease.js +236 -0
- package/dist/runtime/engine-mode.d.ts +74 -0
- package/dist/runtime/engine-mode.js +152 -0
- package/dist/runtime/env.js +14 -1
- package/dist/runtime/executor.d.ts +3 -2
- package/dist/runtime/executor.js +23 -26
- package/dist/runtime/handle-wordlist.d.ts +43 -0
- package/dist/runtime/handle-wordlist.js +256 -0
- package/dist/runtime/handle.d.ts +71 -0
- package/dist/runtime/handle.js +908 -0
- package/dist/runtime/http-telemetry-binding.d.ts +10 -0
- package/dist/runtime/http-telemetry-binding.js +152 -0
- package/dist/runtime/http-telemetry-guard.d.ts +16 -0
- package/dist/runtime/http-telemetry-guard.js +202 -0
- package/dist/runtime/http-telemetry.d.ts +104 -0
- package/dist/runtime/http-telemetry.js +190 -0
- package/dist/runtime/http.d.ts +34 -0
- package/dist/runtime/http.js +680 -121
- package/dist/runtime/insights.js +2 -2
- package/dist/runtime/instrumentation.d.ts +2 -2
- package/dist/runtime/instrumentation.js +462 -19
- 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 +105 -0
- package/dist/runtime/native-network.js +1433 -0
- package/dist/runtime/native-telemetry.d.ts +142 -0
- package/dist/runtime/native-telemetry.js +231 -0
- package/dist/runtime/ocr-telemetry.d.ts +82 -0
- package/dist/runtime/ocr-telemetry.js +192 -0
- package/dist/runtime/ocr.d.ts +29 -0
- package/dist/runtime/ocr.js +468 -0
- package/dist/runtime/otlp.d.ts +71 -2
- package/dist/runtime/otlp.js +398 -16
- package/dist/runtime/provider.d.ts +7 -0
- package/dist/runtime/provider.js +14 -0
- package/dist/runtime/proxy-errors.js +6 -2
- package/dist/runtime/proxy-nodemaven.d.ts +56 -0
- package/dist/runtime/proxy-nodemaven.js +147 -0
- package/dist/runtime/proxy-retry-policy.d.ts +4 -1
- package/dist/runtime/proxy-retry-policy.js +11 -2
- package/dist/runtime/proxy-telemetry.d.ts +133 -3
- package/dist/runtime/proxy-telemetry.js +218 -70
- package/dist/runtime/redirect-hop-headers.d.ts +19 -0
- package/dist/runtime/redirect-hop-headers.js +58 -0
- package/dist/runtime/redirects.d.ts +61 -0
- package/dist/runtime/redirects.js +149 -0
- package/dist/runtime/redis.d.ts +1 -1
- package/dist/runtime/redis.js +4 -2
- package/dist/runtime/request-options.d.ts +75 -1
- package/dist/runtime/request-options.js +588 -0
- package/dist/runtime/request-telemetry.d.ts +70 -0
- package/dist/runtime/request-telemetry.js +229 -0
- package/dist/runtime/resolver-config.d.ts +13 -0
- package/dist/runtime/resolver-config.js +14 -0
- package/dist/runtime/resolver-public.d.ts +3 -0
- package/dist/runtime/resolver-public.js +1 -0
- package/dist/runtime/resolver-runtime-options.d.ts +14 -0
- package/dist/runtime/resolver-runtime-options.js +33 -0
- package/dist/runtime/resolver-shared.d.ts +24 -0
- package/dist/runtime/resolver-shared.js +69 -0
- package/dist/runtime/resolver-span-attributes.d.ts +34 -0
- package/dist/runtime/resolver-span-attributes.js +93 -0
- package/dist/runtime/resolver-telemetry.d.ts +135 -0
- package/dist/runtime/resolver-telemetry.js +204 -0
- package/dist/runtime/resolver-usage.d.ts +32 -0
- package/dist/runtime/resolver-usage.js +54 -0
- package/dist/runtime/resolver-vendors/bindings.d.ts +53 -0
- package/dist/runtime/resolver-vendors/bindings.js +45 -0
- package/dist/runtime/resolver-vendors/browser.d.ts +24 -0
- package/dist/runtime/resolver-vendors/browser.js +423 -0
- package/dist/runtime/resolver-vendors/capsolver.d.ts +22 -0
- package/dist/runtime/resolver-vendors/capsolver.js +544 -0
- package/dist/runtime/resolver-vendors/hosts.d.ts +23 -0
- package/dist/runtime/resolver-vendors/hosts.js +68 -0
- package/dist/runtime/resolver-vendors/hypersolutions.d.ts +27 -0
- package/dist/runtime/resolver-vendors/hypersolutions.js +369 -0
- package/dist/runtime/resolver-vendors/twocaptcha.d.ts +24 -0
- package/dist/runtime/resolver-vendors/twocaptcha.js +425 -0
- package/dist/runtime/resolver-vendors/types.d.ts +125 -0
- package/dist/runtime/resolver-vendors/types.js +106 -0
- package/dist/runtime/resolver.d.ts +79 -0
- package/dist/runtime/resolver.js +1094 -0
- package/dist/runtime/state-telemetry.d.ts +79 -0
- package/dist/runtime/state-telemetry.js +194 -0
- package/dist/runtime/state.d.ts +10 -1
- package/dist/runtime/state.js +322 -82
- package/dist/runtime/stealth-akamai-sbsd.d.ts +54 -0
- package/dist/runtime/stealth-akamai-sbsd.js +142 -0
- package/dist/runtime/stealth-cookies.d.ts +24 -0
- package/dist/runtime/stealth-cookies.js +131 -0
- package/dist/runtime/stealth-owned-headers.d.ts +39 -0
- package/dist/runtime/stealth-owned-headers.js +57 -0
- package/dist/runtime/stealth-telemetry.d.ts +92 -0
- package/dist/runtime/stealth-telemetry.js +179 -0
- package/dist/runtime/stealth.d.ts +45 -6
- package/dist/runtime/stealth.js +1775 -320
- package/dist/runtime/stt-telemetry.d.ts +77 -0
- package/dist/runtime/stt-telemetry.js +176 -0
- package/dist/runtime/stt.js +18 -19
- 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 +17 -0
- package/dist/runtime/trace.js +176 -25
- package/dist/runtime-boundary-lint.d.ts +137 -0
- package/dist/runtime-boundary-lint.js +590 -0
- package/dist/schema.d.ts +20 -0
- package/dist/schema.js +72 -2
- 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/error-stack-frames.d.ts +35 -0
- package/dist/server/error-stack-frames.js +219 -0
- package/dist/server/index.d.ts +21 -2
- package/dist/server/index.js +11 -2
- package/dist/server/runtime-diagnostics.d.ts +165 -0
- package/dist/server/runtime-diagnostics.js +360 -0
- package/dist/server/sdk-version.d.ts +3 -0
- package/dist/server/sdk-version.js +19 -0
- 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-redaction.js +8 -33
- package/dist/server/self-test.d.ts +18 -3
- package/dist/server/self-test.js +139 -76
- package/dist/server/sensitive-values.d.ts +26 -0
- package/dist/server/sensitive-values.js +137 -0
- package/dist/server/serve-implementation.d.ts +285 -0
- package/dist/server/serve-implementation.js +3172 -0
- package/dist/server/serve.d.ts +1 -75
- package/dist/server/serve.js +1 -1170
- package/dist/server/state-backend-report.d.ts +70 -0
- package/dist/server/state-backend-report.js +113 -0
- package/dist/server/trace-output.d.ts +7 -0
- package/dist/server/trace-output.js +111 -0
- package/dist/server/types.d.ts +37 -5
- package/dist/server/types.js +34 -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 +237 -0
- package/dist/stateful/stateful-provider-runtime-context.d.ts +35 -0
- package/dist/stateful/stateful-provider-runtime-context.js +61 -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 +15 -4
- package/dist/stealth/profiles.js +169 -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 +509 -25
- package/dist/trace-sanitization.d.ts +6 -0
- package/dist/trace-sanitization.js +68 -0
- package/dist/types.d.ts +899 -210
- package/dist/types.js +1 -0
- package/dist/typescript-module.d.ts +39 -0
- package/dist/typescript-module.js +72 -0
- package/package.json +52 -6
- package/src/auth-turn/index.ts +1 -1
- package/src/auth.ts +118 -0
- package/src/ceremonies/index.ts +189 -46
- package/src/cli/commands.ts +37 -0
- package/src/cli/create.ts +8 -2
- package/src/cli/deployment-intent.ts +364 -0
- package/src/cli/local-connection.ts +221 -0
- package/src/cli/migrate-deployment-intent.ts +1908 -0
- package/src/cli/migrate-operation-declaration.ts +3026 -0
- package/src/cli/migrate-operation-shape.ts +184 -0
- package/src/cli/migrate-provider-shape.ts +778 -0
- package/src/cli/resolver-runtime.ts +72 -0
- package/src/cli/templates/provider/.agents/skills/health-checks-and-fail-closed/SKILL.md.tpl +141 -23
- package/src/cli/templates/provider/Dockerfile.tpl +1 -1
- package/src/cli/templates/provider/README.md.tpl +41 -19
- 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 +774 -181
- 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 +376 -0
- package/src/define.ts +1105 -131
- package/src/dev.ts +13 -1
- package/src/engine.ts +390 -0
- package/src/error-observability.ts +64 -0
- package/src/error-resolution.ts +269 -0
- package/src/errors.ts +157 -0
- package/src/fixture-sanitization.ts +422 -0
- package/src/handle-meta.ts +143 -0
- package/src/handle.ts +694 -0
- package/src/health-scenario.ts +960 -0
- package/src/i18n/catalog.ts +23 -1
- package/src/i18n/error-messages.ts +255 -0
- package/src/i18n/index.ts +1 -0
- package/src/i18n/keys.ts +80 -6
- package/src/i18n/operation-locale-namespace.ts +10 -0
- package/src/index.ts +390 -23
- package/src/lint.ts +2975 -234
- 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 +207 -27
- package/src/runtime/auth-flow.ts +15 -0
- package/src/runtime/bounded-expiring-map.ts +67 -0
- package/src/runtime/browser-telemetry-binding.ts +92 -0
- package/src/runtime/browser-telemetry.ts +289 -0
- package/src/runtime/browser.ts +882 -99
- package/src/runtime/cache-telemetry.ts +247 -0
- package/src/runtime/cache.ts +258 -22
- package/src/runtime/capability-response.ts +53 -0
- package/src/runtime/capability-telemetry.ts +101 -0
- package/src/runtime/chrome149-header-order.ts +330 -0
- package/src/runtime/diagnostic-env-values.ts +56 -0
- package/src/runtime/diagnostic-env.ts +65 -0
- package/src/runtime/diagnostic-redactor.ts +668 -0
- package/src/runtime/egress-lease.ts +341 -0
- package/src/runtime/engine-mode.ts +233 -0
- package/src/runtime/env.ts +15 -1
- package/src/runtime/executor.ts +39 -32
- package/src/runtime/handle-wordlist.ts +266 -0
- package/src/runtime/handle.ts +1180 -0
- package/src/runtime/http-telemetry-binding.ts +162 -0
- package/src/runtime/http-telemetry-guard.ts +208 -0
- package/src/runtime/http-telemetry.ts +292 -0
- package/src/runtime/http.ts +896 -150
- package/src/runtime/insights.ts +2 -2
- package/src/runtime/instrumentation.ts +628 -28
- package/src/runtime/native-network-errors.ts +99 -0
- package/src/runtime/native-network.ts +1853 -0
- package/src/runtime/native-telemetry.ts +366 -0
- package/src/runtime/ocr-telemetry.ts +308 -0
- package/src/runtime/ocr.ts +564 -0
- package/src/runtime/otlp.ts +468 -21
- package/src/runtime/provider.ts +15 -0
- package/src/runtime/proxy-errors.ts +12 -4
- package/src/runtime/proxy-nodemaven.ts +222 -0
- package/src/runtime/proxy-retry-policy.ts +12 -1
- package/src/runtime/proxy-telemetry.ts +358 -103
- package/src/runtime/redirect-hop-headers.ts +71 -0
- package/src/runtime/redirects.ts +215 -0
- package/src/runtime/redis.ts +7 -2
- package/src/runtime/request-options.ts +728 -1
- package/src/runtime/request-telemetry.ts +375 -0
- package/src/runtime/resolver-config.ts +18 -0
- package/src/runtime/resolver-public.ts +44 -0
- package/src/runtime/resolver-runtime-options.ts +50 -0
- package/src/runtime/resolver-shared.ts +113 -0
- package/src/runtime/resolver-span-attributes.ts +139 -0
- package/src/runtime/resolver-telemetry.ts +362 -0
- package/src/runtime/resolver-usage.ts +99 -0
- package/src/runtime/resolver-vendors/bindings.ts +61 -0
- package/src/runtime/resolver-vendors/browser.ts +591 -0
- package/src/runtime/resolver-vendors/capsolver.ts +727 -0
- package/src/runtime/resolver-vendors/hosts.ts +81 -0
- package/src/runtime/resolver-vendors/hypersolutions.ts +480 -0
- package/src/runtime/resolver-vendors/twocaptcha.ts +555 -0
- package/src/runtime/resolver-vendors/types.ts +261 -0
- package/src/runtime/resolver.ts +1543 -0
- package/src/runtime/state-telemetry.ts +298 -0
- package/src/runtime/state.ts +435 -89
- package/src/runtime/stealth-akamai-sbsd.ts +207 -0
- package/src/runtime/stealth-cookies.ts +155 -0
- package/src/runtime/stealth-owned-headers.ts +67 -0
- package/src/runtime/stealth-telemetry.ts +309 -0
- package/src/runtime/stealth.ts +2275 -372
- package/src/runtime/stt-telemetry.ts +282 -0
- package/src/runtime/stt.ts +96 -91
- package/src/runtime/timeout.ts +18 -0
- package/src/runtime/trace-config.ts +78 -0
- package/src/runtime/trace.ts +257 -35
- package/src/runtime-boundary-lint.ts +707 -0
- package/src/schema.ts +80 -2
- package/src/serve.ts +6 -1
- package/src/server/error-observability.ts +1 -0
- package/src/server/error-stack-frames.ts +214 -0
- package/src/server/index.ts +184 -2
- package/src/server/runtime-diagnostics.ts +522 -0
- package/src/server/sdk-version.ts +22 -0
- package/src/server/self-test-input-tokens.ts +29 -14
- package/src/server/self-test-redaction.ts +10 -40
- package/src/server/self-test.ts +205 -89
- package/src/server/sensitive-values.ts +211 -0
- package/src/server/serve-implementation.ts +4596 -0
- package/src/server/serve.ts +1 -1685
- package/src/server/state-backend-report.ts +185 -0
- package/src/server/trace-output.ts +189 -0
- package/src/server/types.ts +34 -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 +310 -0
- package/src/stateful/stateful-provider-runtime-context.ts +96 -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 +212 -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 +685 -19
- package/src/trace-sanitization.ts +110 -0
- package/src/types.ts +1014 -273
- package/src/typescript-module.ts +100 -0
- package/dist/choice-token.d.ts +0 -24
- package/dist/choice-token.js +0 -74
- package/dist/runtime/choice.d.ts +0 -15
- package/dist/runtime/choice.js +0 -413
- package/src/choice-token.ts +0 -165
- package/src/runtime/choice.ts +0 -686
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { ProviderLocaleCatalogMap } from "./catalog.js";
|
|
2
|
+
import { type ProviderLocale } from "./keys.js";
|
|
3
|
+
/**
|
|
4
|
+
* Values interpolated into a localized provider error message or fix.
|
|
5
|
+
*
|
|
6
|
+
* Strings and finite numbers only. String values are treated as untrusted
|
|
7
|
+
* (upstream bodies frequently end up here), so they are scrubbed and capped by
|
|
8
|
+
* {@link interpolateProviderErrorText} before substitution.
|
|
9
|
+
*/
|
|
10
|
+
export type ProviderErrorMessageParams = Readonly<Record<string, string | number>>;
|
|
11
|
+
/** Locales the SDK negotiates for client-facing provider text. */
|
|
12
|
+
export declare const PROVIDER_ERROR_LOCALES: readonly ["en", "ko", "ja"];
|
|
13
|
+
/** Locale used when the caller asks for nothing the provider catalog covers. */
|
|
14
|
+
export declare const DEFAULT_PROVIDER_ERROR_LOCALE = "en";
|
|
15
|
+
/** Catalog namespace for derived `errors.<code>.message` / `errors.<code>.fix` lookups. */
|
|
16
|
+
export declare const PROVIDER_ERROR_CATALOG_NAMESPACE = "errors";
|
|
17
|
+
/** Per-value cap applied to every interpolated param, before substitution. */
|
|
18
|
+
export declare const MAX_INTERPOLATED_PARAM_LENGTH = 200;
|
|
19
|
+
/** Cap applied to a rendered localized message or fix. */
|
|
20
|
+
export declare const MAX_LOCALIZED_ERROR_TEXT_LENGTH = 2000;
|
|
21
|
+
/**
|
|
22
|
+
* Negotiates an `Accept-Language` header against {@link PROVIDER_ERROR_LOCALES}.
|
|
23
|
+
*
|
|
24
|
+
* Quality values are honoured (`ko;q=0.1, ja;q=0.9` selects `ja`) and `q=0`
|
|
25
|
+
* means "not acceptable". Ranges are matched on the primary subtag, so `ko-KR`
|
|
26
|
+
* selects `ko`. Returns `undefined` when the header is absent or names no
|
|
27
|
+
* supported locale, so callers can consult a lower-precedence source before
|
|
28
|
+
* defaulting.
|
|
29
|
+
*/
|
|
30
|
+
export declare function providerLocaleFromAcceptLanguage(header: string | null | undefined): ProviderLocale | undefined;
|
|
31
|
+
/** Reads `accept-language` from a case-insensitive header record. */
|
|
32
|
+
export declare function acceptLanguageHeaderValue(headers: Readonly<Record<string, unknown>> | undefined): string | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Picks the first supported locale across header sources, in precedence order,
|
|
35
|
+
* falling back to {@link DEFAULT_PROVIDER_ERROR_LOCALE}.
|
|
36
|
+
*/
|
|
37
|
+
export declare function resolveProviderErrorLocale(...headerValues: readonly (string | null | undefined)[]): ProviderLocale;
|
|
38
|
+
/**
|
|
39
|
+
* Renders one param value as substitution text, or `undefined` when the value
|
|
40
|
+
* cannot be substituted (absent, non-finite, or not a string/number).
|
|
41
|
+
*/
|
|
42
|
+
export declare function interpolatedParamText(value: unknown): string | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Substitutes `{name}` placeholders in a catalog template.
|
|
45
|
+
*
|
|
46
|
+
* - `{{` and `}}` are the literal `{` and `}` escapes.
|
|
47
|
+
* - A placeholder with no usable param is left verbatim, so an authoring gap is
|
|
48
|
+
* visible in the response instead of silently deleting text.
|
|
49
|
+
* - Substituted text is never rescanned, so a param value containing `{other}`
|
|
50
|
+
* cannot trigger a second round of interpolation.
|
|
51
|
+
*/
|
|
52
|
+
export declare function interpolateProviderErrorText(template: string, params?: ProviderErrorMessageParams): string;
|
|
53
|
+
/** A key candidate considered by {@link localizeProviderErrorText}, in priority order. */
|
|
54
|
+
export type ProviderErrorTextCandidate =
|
|
55
|
+
/** An explicit dot-path key from a throw site or an `errorCodes[]` declaration. */
|
|
56
|
+
{
|
|
57
|
+
readonly kind: "key";
|
|
58
|
+
readonly key: string | undefined;
|
|
59
|
+
}
|
|
60
|
+
/** The `errors.<code>.<field>` convention; `code` is used verbatim as a segment. */
|
|
61
|
+
| {
|
|
62
|
+
readonly kind: "derived";
|
|
63
|
+
readonly code: string | undefined;
|
|
64
|
+
readonly field: string;
|
|
65
|
+
};
|
|
66
|
+
export interface LocalizeProviderErrorTextOptions {
|
|
67
|
+
readonly catalogs?: ProviderLocaleCatalogMap;
|
|
68
|
+
readonly locale: ProviderLocale;
|
|
69
|
+
readonly fallbackLocale?: ProviderLocale;
|
|
70
|
+
readonly candidates: readonly ProviderErrorTextCandidate[];
|
|
71
|
+
readonly params?: ProviderErrorMessageParams;
|
|
72
|
+
/** Literal text returned when no candidate resolves. May be `undefined` for `fix`. */
|
|
73
|
+
readonly fallback: string | undefined;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Resolves client-facing error text against the provider locale catalogs.
|
|
77
|
+
*
|
|
78
|
+
* Candidates are tried in order and each one is resolved in the caller's locale
|
|
79
|
+
* before the `en` catalog, so a more specific key always beats a more specific
|
|
80
|
+
* locale. Nothing here throws: a malformed key, an absent catalog, a
|
|
81
|
+
* non-string catalog value and a missing key all fall through to the next
|
|
82
|
+
* candidate and ultimately to `fallback`.
|
|
83
|
+
*/
|
|
84
|
+
export declare function localizeProviderErrorText(options: LocalizeProviderErrorTextOptions): string | undefined;
|
|
85
|
+
/** The `errors.<code>.<field>` dot path this SDK derives for an undeclared key. */
|
|
86
|
+
export declare function derivedProviderErrorCatalogPath(code: string, field: "message" | "fix"): string;
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { sanitizeDiagnosticText } from "../fixture-sanitization.js";
|
|
2
|
+
import { getProviderLocaleSegments, isProviderLocaleKey, } from "./keys.js";
|
|
3
|
+
/** Locales the SDK negotiates for client-facing provider text. */
|
|
4
|
+
export const PROVIDER_ERROR_LOCALES = ["en", "ko", "ja"];
|
|
5
|
+
/** Locale used when the caller asks for nothing the provider catalog covers. */
|
|
6
|
+
export const DEFAULT_PROVIDER_ERROR_LOCALE = "en";
|
|
7
|
+
/** Catalog namespace for derived `errors.<code>.message` / `errors.<code>.fix` lookups. */
|
|
8
|
+
export const PROVIDER_ERROR_CATALOG_NAMESPACE = "errors";
|
|
9
|
+
/** Per-value cap applied to every interpolated param, before substitution. */
|
|
10
|
+
export const MAX_INTERPOLATED_PARAM_LENGTH = 200;
|
|
11
|
+
/** Cap applied to a rendered localized message or fix. */
|
|
12
|
+
export const MAX_LOCALIZED_ERROR_TEXT_LENGTH = 2_000;
|
|
13
|
+
const TRUNCATION_SUFFIX = "…";
|
|
14
|
+
// One pass, three alternatives: `{{` and `}}` are the literal-brace escapes and
|
|
15
|
+
// `{name}` is a substitution. Named groups are deliberately not used so the
|
|
16
|
+
// callback can distinguish an escape from a substitution by the matched text.
|
|
17
|
+
const PLACEHOLDER_PATTERN = /\{\{|\}\}|\{([A-Za-z_][A-Za-z0-9_]*)\}/g;
|
|
18
|
+
// Markup openers are removed outright rather than entity-escaped: the envelope
|
|
19
|
+
// is plain text, so an escaped `<` would be as wrong for a terminal as a raw
|
|
20
|
+
// `<` is for an HTML surface. The `&` rule only fires in front of an
|
|
21
|
+
// entity-shaped run, so ordinary prose ("Tom & Jerry") survives while
|
|
22
|
+
// `<script>` cannot be revived by a consumer that decodes entities.
|
|
23
|
+
const MARKUP_OPENER_PATTERN = /[<>`]/g;
|
|
24
|
+
const HTML_ENTITY_AMPERSAND_PATTERN = /&(?=#?[0-9A-Za-z]{1,32};)/g;
|
|
25
|
+
function isProviderErrorLocale(value) {
|
|
26
|
+
return PROVIDER_ERROR_LOCALES.some((locale) => locale === value);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Negotiates an `Accept-Language` header against {@link PROVIDER_ERROR_LOCALES}.
|
|
30
|
+
*
|
|
31
|
+
* Quality values are honoured (`ko;q=0.1, ja;q=0.9` selects `ja`) and `q=0`
|
|
32
|
+
* means "not acceptable". Ranges are matched on the primary subtag, so `ko-KR`
|
|
33
|
+
* selects `ko`. Returns `undefined` when the header is absent or names no
|
|
34
|
+
* supported locale, so callers can consult a lower-precedence source before
|
|
35
|
+
* defaulting.
|
|
36
|
+
*/
|
|
37
|
+
export function providerLocaleFromAcceptLanguage(header) {
|
|
38
|
+
if (typeof header !== "string" || header.length === 0)
|
|
39
|
+
return undefined;
|
|
40
|
+
const ranges = [];
|
|
41
|
+
for (const [position, token] of header.split(",").entries()) {
|
|
42
|
+
const [rangeText, ...parameters] = token.split(";");
|
|
43
|
+
const primary = rangeText?.trim().split("-")[0]?.toLowerCase();
|
|
44
|
+
if (!primary)
|
|
45
|
+
continue;
|
|
46
|
+
const quality = parseQualityValue(parameters);
|
|
47
|
+
if (quality <= 0)
|
|
48
|
+
continue;
|
|
49
|
+
ranges.push({ primary, quality, position });
|
|
50
|
+
}
|
|
51
|
+
// Stable by construction: equal qualities keep header order.
|
|
52
|
+
ranges.sort((left, right) => left.quality === right.quality ? left.position - right.position : right.quality - left.quality);
|
|
53
|
+
for (const range of ranges) {
|
|
54
|
+
if (isProviderErrorLocale(range.primary))
|
|
55
|
+
return range.primary;
|
|
56
|
+
}
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
function parseQualityValue(parameters) {
|
|
60
|
+
for (const parameter of parameters) {
|
|
61
|
+
const [name, value] = parameter.split("=");
|
|
62
|
+
if (name?.trim().toLowerCase() !== "q")
|
|
63
|
+
continue;
|
|
64
|
+
const quality = Number.parseFloat(value?.trim() ?? "");
|
|
65
|
+
// A malformed `q` is not a rejection; RFC 9110 treats the range as
|
|
66
|
+
// fully acceptable when no usable quality is present.
|
|
67
|
+
if (!Number.isFinite(quality))
|
|
68
|
+
return 1;
|
|
69
|
+
return Math.min(Math.max(quality, 0), 1);
|
|
70
|
+
}
|
|
71
|
+
return 1;
|
|
72
|
+
}
|
|
73
|
+
/** Reads `accept-language` from a case-insensitive header record. */
|
|
74
|
+
export function acceptLanguageHeaderValue(headers) {
|
|
75
|
+
if (!headers)
|
|
76
|
+
return undefined;
|
|
77
|
+
for (const [name, value] of Object.entries(headers)) {
|
|
78
|
+
if (name.toLowerCase() === "accept-language" && typeof value === "string")
|
|
79
|
+
return value;
|
|
80
|
+
}
|
|
81
|
+
return undefined;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Picks the first supported locale across header sources, in precedence order,
|
|
85
|
+
* falling back to {@link DEFAULT_PROVIDER_ERROR_LOCALE}.
|
|
86
|
+
*/
|
|
87
|
+
export function resolveProviderErrorLocale(...headerValues) {
|
|
88
|
+
for (const value of headerValues) {
|
|
89
|
+
const locale = providerLocaleFromAcceptLanguage(value);
|
|
90
|
+
if (locale)
|
|
91
|
+
return locale;
|
|
92
|
+
}
|
|
93
|
+
return DEFAULT_PROVIDER_ERROR_LOCALE;
|
|
94
|
+
}
|
|
95
|
+
function truncateText(value, limit) {
|
|
96
|
+
return value.length <= limit ? value : `${value.slice(0, limit)}${TRUNCATION_SUFFIX}`;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Renders one param value as substitution text, or `undefined` when the value
|
|
100
|
+
* cannot be substituted (absent, non-finite, or not a string/number).
|
|
101
|
+
*/
|
|
102
|
+
export function interpolatedParamText(value) {
|
|
103
|
+
if (typeof value === "number") {
|
|
104
|
+
return Number.isFinite(value) ? String(value) : undefined;
|
|
105
|
+
}
|
|
106
|
+
if (typeof value !== "string")
|
|
107
|
+
return undefined;
|
|
108
|
+
// sanitizeDiagnosticText scrubs credentials and encodes control, bidi and
|
|
109
|
+
// line-separator characters; the markup pass closes the HTML/markdown hole
|
|
110
|
+
// it deliberately leaves open for log text.
|
|
111
|
+
const scrubbed = sanitizeDiagnosticText(value)
|
|
112
|
+
.replace(MARKUP_OPENER_PATTERN, "")
|
|
113
|
+
.replace(HTML_ENTITY_AMPERSAND_PATTERN, "")
|
|
114
|
+
.replace(/\s+/g, " ")
|
|
115
|
+
.trim();
|
|
116
|
+
return truncateText(scrubbed, MAX_INTERPOLATED_PARAM_LENGTH);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Substitutes `{name}` placeholders in a catalog template.
|
|
120
|
+
*
|
|
121
|
+
* - `{{` and `}}` are the literal `{` and `}` escapes.
|
|
122
|
+
* - A placeholder with no usable param is left verbatim, so an authoring gap is
|
|
123
|
+
* visible in the response instead of silently deleting text.
|
|
124
|
+
* - Substituted text is never rescanned, so a param value containing `{other}`
|
|
125
|
+
* cannot trigger a second round of interpolation.
|
|
126
|
+
*/
|
|
127
|
+
export function interpolateProviderErrorText(template, params) {
|
|
128
|
+
const rendered = template.replace(PLACEHOLDER_PATTERN, (match, name) => {
|
|
129
|
+
if (match === "{{")
|
|
130
|
+
return "{";
|
|
131
|
+
if (match === "}}")
|
|
132
|
+
return "}";
|
|
133
|
+
if (name === undefined)
|
|
134
|
+
return match;
|
|
135
|
+
const substitution = interpolatedParamText(params && Object.hasOwn(params, name) ? params[name] : undefined);
|
|
136
|
+
return substitution ?? match;
|
|
137
|
+
});
|
|
138
|
+
return truncateText(rendered, MAX_LOCALIZED_ERROR_TEXT_LENGTH);
|
|
139
|
+
}
|
|
140
|
+
function asCatalogText(value) {
|
|
141
|
+
return typeof value === "string" && value.trim().length > 0 ? value : undefined;
|
|
142
|
+
}
|
|
143
|
+
function readCatalogSegments(catalogs, segments, locale, fallbackLocale) {
|
|
144
|
+
return (asCatalogText(getProviderLocaleSegments(catalogs[locale] ?? {}, segments)) ??
|
|
145
|
+
asCatalogText(getProviderLocaleSegments(catalogs[fallbackLocale] ?? {}, segments)));
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Resolves client-facing error text against the provider locale catalogs.
|
|
149
|
+
*
|
|
150
|
+
* Candidates are tried in order and each one is resolved in the caller's locale
|
|
151
|
+
* before the `en` catalog, so a more specific key always beats a more specific
|
|
152
|
+
* locale. Nothing here throws: a malformed key, an absent catalog, a
|
|
153
|
+
* non-string catalog value and a missing key all fall through to the next
|
|
154
|
+
* candidate and ultimately to `fallback`.
|
|
155
|
+
*/
|
|
156
|
+
export function localizeProviderErrorText(options) {
|
|
157
|
+
const { catalogs } = options;
|
|
158
|
+
if (!catalogs)
|
|
159
|
+
return options.fallback;
|
|
160
|
+
const fallbackLocale = options.fallbackLocale ?? DEFAULT_PROVIDER_ERROR_LOCALE;
|
|
161
|
+
for (const candidate of options.candidates) {
|
|
162
|
+
const segments = candidateSegments(candidate);
|
|
163
|
+
if (!segments)
|
|
164
|
+
continue;
|
|
165
|
+
try {
|
|
166
|
+
const template = readCatalogSegments(catalogs, segments, options.locale, fallbackLocale);
|
|
167
|
+
if (template === undefined)
|
|
168
|
+
continue;
|
|
169
|
+
return interpolateProviderErrorText(template, options.params);
|
|
170
|
+
}
|
|
171
|
+
catch {
|
|
172
|
+
// A hostile catalog or params object (throwing getters, exotic proxies)
|
|
173
|
+
// must not turn a provider error into a masked 500. Fall through to the
|
|
174
|
+
// next candidate and ultimately to the English literal.
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return options.fallback;
|
|
178
|
+
}
|
|
179
|
+
function candidateSegments(candidate) {
|
|
180
|
+
if (candidate.kind === "key") {
|
|
181
|
+
// Explicit keys must satisfy the dot-path grammar; a malformed key is a
|
|
182
|
+
// miss, never a throw at envelope time.
|
|
183
|
+
return isProviderLocaleKey(candidate.key) ? candidate.key.split(".") : undefined;
|
|
184
|
+
}
|
|
185
|
+
if (typeof candidate.code !== "string" || candidate.code.length === 0)
|
|
186
|
+
return undefined;
|
|
187
|
+
return [PROVIDER_ERROR_CATALOG_NAMESPACE, candidate.code, candidate.field];
|
|
188
|
+
}
|
|
189
|
+
/** The `errors.<code>.<field>` dot path this SDK derives for an undeclared key. */
|
|
190
|
+
export function derivedProviderErrorCatalogPath(code, field) {
|
|
191
|
+
return `${PROVIDER_ERROR_CATALOG_NAMESPACE}.${code}.${field}`;
|
|
192
|
+
}
|
package/dist/i18n/index.d.ts
CHANGED
package/dist/i18n/index.js
CHANGED
package/dist/i18n/keys.d.ts
CHANGED
|
@@ -5,6 +5,18 @@ export declare function isProviderLocaleKey(value: unknown): value is ProviderLo
|
|
|
5
5
|
export declare function assertProviderLocaleKey(value: unknown): asserts value is ProviderLocaleKey;
|
|
6
6
|
export declare function qualifyProviderLocaleKey(providerId: string, key: ProviderLocaleKey | string): string;
|
|
7
7
|
export declare function getProviderLocalePath(catalog: ProviderLocaleCatalog, key: ProviderLocaleKey | string): ProviderLocaleValue | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* Reads a catalog path from raw segments, bypassing the dot-path grammar.
|
|
10
|
+
*
|
|
11
|
+
* Derived error-message lookups address the catalog by the thrown error code
|
|
12
|
+
* (`errors.<code>.message`). The grammar now accepts the code shapes the SDK
|
|
13
|
+
* registers and the fleet throws, but `code` is provider data: a provider may
|
|
14
|
+
* throw anything, and an unusual code must still resolve its catalog entry
|
|
15
|
+
* rather than be dropped as malformed. Own properties only: a
|
|
16
|
+
* `__proto__`/`constructor` segment must read as a miss, not as the prototype
|
|
17
|
+
* chain.
|
|
18
|
+
*/
|
|
19
|
+
export declare function getProviderLocaleSegments(catalog: ProviderLocaleCatalog, segments: readonly string[]): ProviderLocaleValue | undefined;
|
|
8
20
|
export type ProviderLocaleValue = string | readonly string[];
|
|
9
21
|
export type ProviderLocaleCatalog = Record<string, unknown>;
|
|
10
22
|
export declare function isProviderLocaleValue(value: unknown): value is ProviderLocaleValue;
|
package/dist/i18n/keys.js
CHANGED
|
@@ -1,14 +1,69 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* An ordinary catalog name segment: camelCase, ASCII only.
|
|
3
|
+
*
|
|
4
|
+
* `[A-Z][a-z0-9]+` forces at least one character after each hump, so a
|
|
5
|
+
* screaming acronym (`errorsURL`) is not silently read as camelCase.
|
|
6
|
+
*/
|
|
7
|
+
const NAME_SEGMENT_RE = /^[a-z][a-z0-9]*(?:[A-Z][a-z0-9]+)*$/;
|
|
8
|
+
/** An array-index segment, e.g. the `0` in `meta.tags.0`. */
|
|
9
|
+
const INDEX_SEGMENT_RE = /^[0-9]+$/;
|
|
10
|
+
/**
|
|
11
|
+
* An error-code segment: the thrown `code` used verbatim as a catalog key.
|
|
12
|
+
*
|
|
13
|
+
* Single-case underscore words only — `UPSTREAM_SCHEMA_ERROR`, `BLOCKED`,
|
|
14
|
+
* `reauth_required` — matching the shape the SDK registers and the fleet
|
|
15
|
+
* throws (a census of 91 provider repos found 224 distinct codes: 213
|
|
16
|
+
* SCREAMING_SNAKE, 11 lower_snake, none mixed-case, none with a leading digit).
|
|
17
|
+
* A leading letter is mandatory, so no error code can be spelled like the
|
|
18
|
+
* numeric array-index form and the two segment kinds stay disjoint.
|
|
19
|
+
* The lower_snake arm requires an underscore because a bare lowercase word is
|
|
20
|
+
* already a {@link NAME_SEGMENT_RE} segment.
|
|
21
|
+
*/
|
|
22
|
+
const ERROR_CODE_SEGMENT_RE = /^(?:[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*|[a-z][a-z0-9]*(?:_[a-z0-9]+)+)$/;
|
|
23
|
+
/**
|
|
24
|
+
* The only parent under which an error-code segment is legal.
|
|
25
|
+
*
|
|
26
|
+
* Must stay equal to `PROVIDER_ERROR_CATALOG_NAMESPACE` in `error-messages.ts`
|
|
27
|
+
* (the derived-path test in `keys.test.ts` fails if they drift). Anchoring the
|
|
28
|
+
* code vocabulary to this one parent is what keeps the grammar from degrading
|
|
29
|
+
* into "any identifier anywhere": everywhere else a segment is still camelCase
|
|
30
|
+
* or an array index.
|
|
31
|
+
*/
|
|
32
|
+
const ERROR_CODE_PARENT_SEGMENT = "errors";
|
|
33
|
+
/**
|
|
34
|
+
* Validates one segment in position.
|
|
35
|
+
*
|
|
36
|
+
* `parent` is the preceding segment, or `undefined` for the first segment. The
|
|
37
|
+
* first segment is always a plain name: catalogs are rooted in SDK-owned
|
|
38
|
+
* namespaces (`meta`, `operations`, `auth`, `errors`), never in an index or a
|
|
39
|
+
* code.
|
|
40
|
+
*/
|
|
41
|
+
function isValidProviderLocaleSegment(segment, parent) {
|
|
42
|
+
if (parent === undefined)
|
|
43
|
+
return NAME_SEGMENT_RE.test(segment);
|
|
44
|
+
if (NAME_SEGMENT_RE.test(segment) || INDEX_SEGMENT_RE.test(segment))
|
|
45
|
+
return true;
|
|
46
|
+
return parent === ERROR_CODE_PARENT_SEGMENT && ERROR_CODE_SEGMENT_RE.test(segment);
|
|
47
|
+
}
|
|
2
48
|
export function providerLocaleKey(key) {
|
|
3
49
|
assertProviderLocaleKey(key);
|
|
4
50
|
return key;
|
|
5
51
|
}
|
|
6
52
|
export function isProviderLocaleKey(value) {
|
|
7
|
-
|
|
53
|
+
if (typeof value !== "string" || value.length === 0)
|
|
54
|
+
return false;
|
|
55
|
+
const segments = value.split(".");
|
|
56
|
+
for (const [index, segment] of segments.entries()) {
|
|
57
|
+
// `split(".")` yields "" for an empty segment ("a..b", ".a", "a."), which
|
|
58
|
+
// no segment pattern matches, so those stay rejected.
|
|
59
|
+
if (!isValidProviderLocaleSegment(segment, index === 0 ? undefined : segments[index - 1]))
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
return true;
|
|
8
63
|
}
|
|
9
64
|
export function assertProviderLocaleKey(value) {
|
|
10
65
|
if (!isProviderLocaleKey(value)) {
|
|
11
|
-
throw new Error(`Provider locale key must be a dot path such as "meta.description" or "operations.search.description"; received ${JSON.stringify(value)}`);
|
|
66
|
+
throw new Error(`Provider locale key must be a camelCase dot path such as "meta.description" or "operations.search.description", optionally naming an error code under "${ERROR_CODE_PARENT_SEGMENT}." as in "errors.UPSTREAM_SCHEMA_ERROR.message"; received ${JSON.stringify(value)}`);
|
|
12
67
|
}
|
|
13
68
|
}
|
|
14
69
|
export function qualifyProviderLocaleKey(providerId, key) {
|
|
@@ -17,9 +72,25 @@ export function qualifyProviderLocaleKey(providerId, key) {
|
|
|
17
72
|
}
|
|
18
73
|
export function getProviderLocalePath(catalog, key) {
|
|
19
74
|
assertProviderLocaleKey(key);
|
|
75
|
+
return getProviderLocaleSegments(catalog, key.split("."));
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Reads a catalog path from raw segments, bypassing the dot-path grammar.
|
|
79
|
+
*
|
|
80
|
+
* Derived error-message lookups address the catalog by the thrown error code
|
|
81
|
+
* (`errors.<code>.message`). The grammar now accepts the code shapes the SDK
|
|
82
|
+
* registers and the fleet throws, but `code` is provider data: a provider may
|
|
83
|
+
* throw anything, and an unusual code must still resolve its catalog entry
|
|
84
|
+
* rather than be dropped as malformed. Own properties only: a
|
|
85
|
+
* `__proto__`/`constructor` segment must read as a miss, not as the prototype
|
|
86
|
+
* chain.
|
|
87
|
+
*/
|
|
88
|
+
export function getProviderLocaleSegments(catalog, segments) {
|
|
89
|
+
if (segments.length === 0)
|
|
90
|
+
return undefined;
|
|
20
91
|
let cursor = catalog;
|
|
21
|
-
for (const segment of
|
|
22
|
-
if (!isRecord(cursor))
|
|
92
|
+
for (const segment of segments) {
|
|
93
|
+
if (!isRecord(cursor) || !Object.hasOwn(cursor, segment))
|
|
23
94
|
return undefined;
|
|
24
95
|
cursor = cursor[segment];
|
|
25
96
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { assertProviderLocaleKey } from "./keys.js";
|
|
2
|
+
/** Canonical locale-catalog namespace for a URL-safe provider operation id. */
|
|
3
|
+
export function operationIdToLocaleNamespace(operationId) {
|
|
4
|
+
const namespace = operationId.replace(/[-_]([a-z0-9])/g, (_separator, character) => character.toUpperCase());
|
|
5
|
+
assertProviderLocaleKey(`operations.${namespace}.description`);
|
|
6
|
+
return namespace;
|
|
7
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,44 +1,69 @@
|
|
|
1
1
|
export * from "./auth.js";
|
|
2
2
|
export * from "./ceremonies/index.js";
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export { defineConfig, loadApiFuseConfig } from "./config/loader.js";
|
|
3
|
+
export type { ApiFuseConfig, BrowserConfig, ProxyCacheStatus, ProxyProtocol, ProxyResolutionOptions, ProxyResolutionSource, ProxyUserAgentSource, ProxyVendorName, ResolvedProxyConfig, SessionConfig, SmartproxyAllocatorBodyClass, } from "./config/loader.js";
|
|
4
|
+
export { defineConfig, loadApiFuseConfig, resolveProxy } from "./config/loader.js";
|
|
6
5
|
export { canonicalJson, digestProviderContract, extractProviderContract, type JsonPrimitive, type JsonValue, PROVIDER_CONTRACT_SCHEMA_VERSION, type ProviderContractOperation, type ProviderContractSnapshot, } from "./contract.js";
|
|
7
|
-
export { centered, delayed, defineHealthJourney, defineOperation, defineProvider, defineSmsOtpMatcher, defineStreamOperation, every, type
|
|
6
|
+
export { centered, delayed, defineHealthJourney, defineOperation, defineProvider, defineSmsOtpMatcher, defineStreamOperation, every, type AuthStartNoInputGuard, type OperationDefinitionFor, type ProviderBuilder, type ProviderContextOf, type ProviderDeclaration, type ProviderDefinitionFor, } from "./define.js";
|
|
7
|
+
export { AssertionExpressionSchema, AssertionPredicateSchema, AssertStepSchema, BoundedJsonPathSchema, CandidateBlockSchema, CandidatePolicySchema, CredentialRefDeclarationSchema, defineHealthScenario, HealthScenarioSchema, HealthStepSchema, ExtractStepSchema, FindFirstSchema, GUARD_REASON_CODES, GuardStepSchema, JournalPolicySchema, JsonTemplateSchema, ManualTriggerPolicySchema, OperandSchema, OperationStepSchema, QuantifierSchema, ReferenceSchema, RetryPolicySchema, SafeRegexSchema, ScopedAssertionExpressionSchema, ScopedAssertionPredicateSchema, ScopedItemReferenceSchema, ScopedOperandSchema, StepReferenceSchema, RelativeDateNodeSchema, ValueTypeSchema, } from "./health-scenario.js";
|
|
8
|
+
export type { AssertionExpression, AssertionPredicate, AttemptReference, AssertResult, AssertStep, BoundedJsonPath, CandidateBlock, CandidatePolicy, CandidateReference, CredentialReference, CredentialRefDeclaration, EstablishedConnectionReference, ExtractStep, FindFirst, GuardAttribution, GuardReasonCode, GuardResult, GuardStep, HealthScenario, HealthStep, JsonTemplate, JournalPolicy, ManualTriggerPolicy, NonEmpty, OperationResult, OperationStep, Operand, Quantifier, ReferenceNode, Reference, RelativeDateNode, RetryPolicy, SafeRegex, ScopedAssertionExpression, ScopedAssertionPredicate, ScopedItemReference, ScopedOperand, StepBase, StepReference, ExtractResult, ValueType, } from "./health-scenario.js";
|
|
8
9
|
export type { DevServerOptions } from "./dev.js";
|
|
9
10
|
export { createDevServer, startDevServer } from "./dev.js";
|
|
10
11
|
export * from "./errors.js";
|
|
12
|
+
export * from "./engine.js";
|
|
13
|
+
export * from "./observability.js";
|
|
11
14
|
export * from "./user-input.js";
|
|
12
15
|
export * from "./i18n/index.js";
|
|
13
|
-
export { type LintDiagnostic, lintOperation, lintProvider, } from "./lint.js";
|
|
16
|
+
export { type LintDiagnostic, lintOperation, lintProvider, type ProviderLintInformation, type ProviderLintResult, } from "./lint.js";
|
|
17
|
+
export { type LintRuntimeBoundarySourcesOptions, lintRuntimeBoundarySources, RUNTIME_BOUNDARY_RULES, type RuntimeBoundaryRule, } from "./runtime-boundary-lint.js";
|
|
18
|
+
export { TYPESCRIPT_COMPILER_MODULE_SPECIFIERS, type TypeScriptCompilerModuleLike, } from "./typescript-module.js";
|
|
14
19
|
export * from "./recipes/gov-api.js";
|
|
15
20
|
export * from "./recipes/rest-api.js";
|
|
16
21
|
export { createFlowContext, createScratchpad } from "./runtime/auth-flow.js";
|
|
17
22
|
export type { BrowserClientOptions } from "./runtime/browser.js";
|
|
18
|
-
export {
|
|
19
|
-
export
|
|
20
|
-
export {
|
|
23
|
+
export { APIFUSE__CACHE__KEY_PEPPER_ENV, createBypassProviderCache, createProviderCache, type ProviderCacheOptions, } from "./runtime/cache.js";
|
|
24
|
+
export * from "./handle.js";
|
|
25
|
+
export { APIFUSE_HANDLE_META_KEY, HANDLE_KIND_NAME_PATTERN, handleFieldDescription, handleFieldNameFor, handleHasDirectionalFieldNames, isHandleFieldMeta, } from "./handle-meta.js";
|
|
26
|
+
export { type CreateHandleContextOptions, type CreateTestHandleContextOptions, createHandleContext, createTestHandleContext, type HandleNormalizationClass, type NormalizedHandle, normalizeHandle, } from "./runtime/handle.js";
|
|
21
27
|
export { type CreateCredentialContextOptions, createCredentialContext, } from "./runtime/credential.js";
|
|
22
28
|
export { createEnvContext } from "./runtime/env.js";
|
|
23
29
|
export { executeOperation } from "./runtime/executor.js";
|
|
24
30
|
export { createHttpClient } from "./runtime/http.js";
|
|
31
|
+
export { OcrTelemetryCollector, bindOcrTelemetry, type OcrTelemetryBackend, type OcrTelemetryEngine, type OcrTelemetryErrorCode, type OcrTelemetryEvent, type OcrTelemetryFinishReason, type OcrTelemetryHeaderPayload, type OcrTelemetryLogPayload, type OcrTelemetryModel, type OcrTelemetrySink, } from "./runtime/ocr-telemetry.js";
|
|
32
|
+
export { NativeEgressGrantExpiredError, NativeEgressNotDeclaredError, NativeIdleTimeoutError, NativeNetworkError, NativeProxyExpiredError, } from "./runtime/native-network-errors.js";
|
|
33
|
+
export type { NativeGatewayProxy, NativeGatewayProxyResolutionInput, NativeGatewayProxySkipReason, NativeGatewayProxySynthesizer, NativeGatewayProxySynthesisResult, NativeGatewayProxySynthesisInput, NativeNetworkClientOptions, NativeNetworkErrorCode, VendorCredentialLookup, VendorCredentialResolver, } from "./runtime/native-network.js";
|
|
25
34
|
export type { Insight, InsightSeverity } from "./runtime/insights.js";
|
|
26
35
|
export { generateInsights } from "./runtime/insights.js";
|
|
27
36
|
export { type InstrumentationOptions, type InstrumentedProviderContext, wrapWithInstrumentation, } from "./runtime/instrumentation.js";
|
|
28
|
-
export {
|
|
37
|
+
export type { PrevalidateResult } from "./runtime/prevalidate.js";
|
|
29
38
|
export { getProviderBaseUrl } from "./runtime/provider.js";
|
|
39
|
+
export type { ProxyTelemetryHeaderPayload, ProxyHash, ProxyTelemetryLogPayload, ProxyTelemetryResolvedPayload, ProxyTelemetryUnresolvedPayload, } from "./runtime/proxy-telemetry.js";
|
|
40
|
+
export { RequestTelemetry, closedEnum, type ClosedEnum, type GatewayIngestible, type RequestTelemetryLogPayload, type SpanIndex, type TelemetryContributor, type TelemetryKey, type TenantNeutral, } from "./runtime/request-telemetry.js";
|
|
41
|
+
export { APIFUSE__ENGINE__CEREMONY_LEASE_KEY } from "./runtime/egress-lease.js";
|
|
42
|
+
export { ResolverTelemetryCollector, type ResolverCacheReadTelemetryEvent, type ResolverCacheWriteTelemetryEvent, type ResolverFailoverTelemetryEvent, type ResolverIdentityTelemetryEvent, type ResolverOutcomeTelemetryEvent, type ResolverTelemetryAttemptOutcome, type ResolverAttemptSample, type ResolverTelemetryCacheStatus, type ResolverTelemetryCacheWriteReason, type ResolverTelemetryErrorClass, type ResolverTelemetryHeaderPayload, type ResolverTelemetryIdentitySource, type ResolverTelemetryLogPayload, type ResolverTelemetryOutcome, type ResolverTelemetryPhase, type ResolverTelemetrySink, type ResolverVendorAttemptTelemetryEvent, } from "./runtime/resolver-telemetry.js";
|
|
43
|
+
export { StealthTelemetryCollector, type StealthTelemetryAttemptEvent, type StealthTelemetryAttemptKind, type StealthTelemetryAttemptSample, type StealthTelemetryDiagnostics, type StealthTelemetryErrorCode, type StealthTelemetryHeaderPayload, type StealthTelemetryLogPayload, type StealthTelemetryRequestClass, type StealthTelemetrySbsdEvent, type StealthTelemetrySbsdOutcome, type StealthTelemetrySink, } from "./runtime/stealth-telemetry.js";
|
|
44
|
+
export { SttTelemetryCollector, bindSttTelemetry, type SttTelemetryBackend, type SttTelemetryEngine, type SttTelemetryModel, type SttTelemetryErrorCode, type SttTelemetryEvent, type SttTelemetryHeaderPayload, type SttTelemetryLogPayload, type SttTelemetrySink, } from "./runtime/stt-telemetry.js";
|
|
45
|
+
export { BrowserTelemetryCollector, type BrowserTelemetryErrorCode, type BrowserTelemetryHeaderPayload, type BrowserTelemetryLogPayload, type BrowserTelemetryPoolAcquireOutcome, type BrowserTelemetrySink, type BrowserTelemetrySampleName, type BrowserTelemetryEngine, } from "./runtime/browser-telemetry.js";
|
|
46
|
+
export { APIFUSE__CDP_POOL__URL, APIFUSE__RESOLVER__2CAPTCHA__API_KEY, APIFUSE__RESOLVER__CAPMONSTER__API_KEY, APIFUSE__RESOLVER__CAPSOLVER__API_KEY, APIFUSE__RESOLVER__HYPERSOLUTIONS__API_KEY, APIFUSE__RESOLVER__TIMEOUT_MS, DEFAULT_RESOLVER_TIMEOUT_MS, } from "./runtime/resolver-config.js";
|
|
47
|
+
export { createUnsupportedResolverClient } from "./runtime/resolver-shared.js";
|
|
48
|
+
export type { ResolverRuntimeOptions } from "./runtime/resolver.js";
|
|
49
|
+
export type { ResolverPaidUsageContext, ResolverVendorTransport, ResolverVendorUnavailableReason, } from "./runtime/resolver-vendors/types.js";
|
|
30
50
|
export { assertRequiredSecretsPresent, listMissingRequiredSecrets, MISSING_SECRET_CODE, } from "./runtime/secrets.js";
|
|
31
|
-
export { createUnsupportedProviderRuntimeState, UnsupportedProviderStateError, } from "./runtime/state.js";
|
|
32
|
-
export {
|
|
51
|
+
export { createMemoryProviderRuntimeState, createUnsupportedProviderRuntimeState, UnsupportedProviderStateError, } from "./runtime/state.js";
|
|
52
|
+
export { APIFUSE__OCR__API_KEY_ENV, APIFUSE__OCR__BACKEND_ENV, APIFUSE__OCR__BASE_URL_ENV, APIFUSE__OCR__CLOUDFLARE_API_TOKEN_ENV, APIFUSE__OCR__MODEL_ENV, CLOUDFLARE_ACCOUNT_ID_ENV, CLOUDFLARE_WORKERS_AI_OCR_BACKEND, createCloudflareWorkersAiOcrClient, createOcrClientFromEnv, createOpenAiCompatibleOcrClient, createUnsupportedOcrClient, DEFAULT_CLOUDFLARE_WORKERS_AI_OCR_MODEL, extractCaptchaCandidates, OPENAI_COMPATIBLE_OCR_BACKEND, } from "./runtime/ocr.js";
|
|
33
53
|
export { APIFUSE__STT__BACKEND_ENV, APIFUSE__STT__CLOUDFLARE_API_TOKEN_ENV, APIFUSE__STT__MODEL_ENV, createSttClientFromEnv, createUnsupportedSttClient, extractVerificationCode, resolveSttPrompt, } from "./runtime/stt.js";
|
|
34
54
|
export { type CreateTraceContextOptions, createTraceContext, type Span, type TraceContext, } from "./runtime/trace.js";
|
|
35
|
-
export
|
|
36
|
-
export {
|
|
37
|
-
export {
|
|
55
|
+
export type { DiagnosticRedactor } from "./runtime/diagnostic-redactor.js";
|
|
56
|
+
export { APIFUSE_CONTENT_PROVENANCE_META_KEY, APIFUSE_CONTENT_TRUST_META_KEY, APIFUSE_DESCRIPTION_KEY_META_KEY, APIFUSE_REDACTION_MARKER, APIFUSE_SENSITIVE_KIND_META_KEY, APIFUSE_SENSITIVE_META_KEY, collectSensitivePaths, describeKey, field, fields, isSensitiveSchema, publicField, redactPayload, type SensitiveFieldKind, type SensitiveFieldOptions, type SensitivePath, sensitive, untrustedContent, z, } from "./schema.js";
|
|
57
|
+
export { createServerApp, createServerAppAsync, ERROR_OBSERVABILITY_HEADER, type ProviderErrorCauseFrame, type ServeOptions, serve, } from "./server/serve.js";
|
|
58
|
+
export { DEFAULT_STEALTH_BROWSER, DEFAULT_STEALTH_OS, getStealthProfile, listStealthProfiles, } from "./stealth/profiles.js";
|
|
38
59
|
export * from "./stream.js";
|
|
39
|
-
export type { ApiFuseResponse, AuthConfig, AuthContext, AuthFlowDefinition, AuthFlowInputHandler, AuthFlowStartHandler, AuthMode, AuthTurn, Bcp47Locale, BrowserEngine, BrowserOptions, BrowserResourceBody, BrowserResourceDecision, BrowserResourceMethod, BrowserResourcePolicy, BrowserResourceRequest, BrowserResourceRoute, ConnectionMode, ContextDeclaration, CookieJar, ContextScratchpad, CredentialContext, CredentialDeclaration, E164PhoneNumber, EnvContext, FlowContext, FlowContextStore, HealthCheckAssertionContext, HealthCheckCase, HealthCheckCaseResult, HealthCheckSuite, HealthCheckUnsupported, HealthJourneyDefinition, HealthJourneyEventContext, HealthJourneyGatewayContext, HealthJourneyJournalContext, HealthJourneyManualTriggerPolicy, HealthJourneyRunContext, HealthJourneyRunResult, HealthJourneySchedule, HealthScheduleRandomization, HealthJourneySmsContext, HealthJourneyStep, HttpClient, HttpMethod, HttpResponse, HttpRetryOptions, HttpRetrySummary, HttpStreamResponse, IanaTimeZone, InferSchemaOutput, Iso3166Alpha2CountryCode, Iso4217CurrencyCode, Iso8601Duration,
|
|
60
|
+
export type { ApiFuseResponse, AuthConfig, AuthContext, AuthFlowDefinition, AuthFlowInputHandler, AuthFlowStartHandler, AuthMode, AuthTurn, Bcp47Locale, BrowserCookie, BrowserEngine, BrowserOptions, BrowserResourceBody, BrowserResourceDecision, BrowserResourceMethod, BrowserResourcePolicy, BrowserResourceRequest, BrowserResourceRoute, ChallengeSolution, ConnectionMode, ContextDeclaration, CookieJar, ContextScratchpad, CredentialContext, CredentialDeclaration, E164PhoneNumber, EnvContext, FlowContext, FlowContextStore, HealthCheckAssertionContext, HealthCheckCase, HealthCheckCaseResult, HealthCheckSuite, HealthCheckUnsupported, HealthJourneyDefinition, HealthJourneyEventContext, HealthJourneyGatewayContext, HealthJourneyJournalContext, HealthJourneyManualTriggerPolicy, HealthJourneyRunContext, HealthJourneyRunResult, HealthJourneySchedule, HealthScheduleRandomization, HealthJourneySmsContext, HealthJourneyStep, HttpAttemptContext, HttpClient, HttpHeadersFactory, HttpMethod, HttpRedirectFailureReason, HttpRedirectPolicy, HttpRedirectPolicyMode, HttpResponse, HttpRetryOptions, HttpRetrySummary, HttpStreamResponse, IanaTimeZone, InferSchemaOutput, Iso3166Alpha2CountryCode, Iso4217CurrencyCode, Iso8601Duration, NativeContext, NativeNetworkClient, NativeNetworkCloseReason, NativeNetworkConnection, NativeNetworkConnectInput, NativeNetworkConnectOptions, NativeNetworkDynamicGrantOptions, NativeNetworkEgressGrant, NativeProviderConfig, NativeProxyDrainHandler, NativeProxyEgressInfo, NativeProxyExpiringEvent, NativeProxyExpiringReason, NativeTcpDynamicEgressRule, NativeTcpEgressGrant, NativeTcpEgressRule, NativeTcpPortRange, NativeTcpTlsMode, NativeTlsConnectOptions, OcrCaptchaCandidate, OcrCaptchaOptions, OcrCaptchaResult, OcrContext, OcrImageInput, OcrRecognizeRequest, OcrResult, OcrWarning, OperationApprovalPolicy, OperationContractMetadata, OperationDefinition, OperationDeprecationMetadata, OperationExample, OperationErrorCode, ProviderErrorStatus, OperationHandlerResult, OperationLifecycle, OperationObservabilityConfig, OperationObservabilitySensitiveConfig, OperationRelationships, OperationRiskClass, OperationSensitivePath, OperationTransport, OperationTransportKind, ProbeInterval, ProviderAccessConfig, ProviderAccessVisibility, ProviderCache, ProviderCacheGetOrSetOptions, ProviderCacheKeyOptions, ProviderCacheLookupMeta, ProviderCacheResponseMeta, ProviderCacheResult, ProviderChallenge, ProviderChallengeKind, ProviderContext, ProviderContextFor, ProviderDefinition, ProviderDeploymentOverrides, ProviderFileRef, ProviderFilesContext, ProviderHealthMonitorConfig, ProviderHealthProbeConfig, ProviderLocale, ProviderLocaleKey, ProviderLocaleKeyInput, ProviderLogoProfile, ProviderLogoSource, ProviderMeta, ProviderOcrConfig, ProviderProxyConfig, ProviderProxyMode, ProviderProxyPolicy, ProxiedOAuthConfig, ProviderProxyProvider, ProviderProxySessionAffinity, ProviderPublicConnectionMode, ProviderPublicProfile, ProviderReviewed, ProviderResolvedFile, ProviderResolverConfig, ProviderResolverVendor, ProviderRuntimeTarget, ProviderRuntimeState, ProviderSecretDeclaration, ProviderSecretIssuer, ProviderStealthConfig, ProviderStateDurationString, ProviderStateNamespace, ProviderStreamEvent, ProviderSttConfig, ProviderSttMode, ProviderSupportLevel, RequestOptions, RedirectRunReason, ResolverContext, Rfc3339Instant, SchemaLike, SmsOrigin, SmsOtpExtractionPattern, SmsOtpMatcherDefinition, SseMessage, StandardSchemaV1, StateCasResult, StateNamespaceOptions, StateNamespaceScope, StateValue, StateWriteOptions, StealthClient, StealthBrowser, StealthChallengeClassification, StealthCookieStore, StealthCookieStoreV1, StealthFetchOptions, StealthPlatform, StealthProfile, StealthProfileDescriptor, StealthProfileSelection, StealthOS, StealthRedirectHop, StealthRedirectRunOptions, StealthRedirectRunResult, StealthResponse, StealthSession, StealthSessionCookies, SttAudioInput, SttContext, SttPromptPolicy, SttSegment, SttTranscribeMode, SttTranscribeRequest, SttTranscript, SttUnsupportedOptionPolicy, SttUsage, SttVerificationCodeOptions, SttWarning, TraceConfig, TraceSpan, VerificationCodeCandidate, VerificationCodeCandidateSource, VerificationCodeExtractionResult, } from "./types.js";
|
|
40
61
|
export { DEFAULT_OPERATION_TRANSPORT, HttpRetryAfterPolicy, HttpRetryDelayStrategy, HttpRetryJitter, HttpRetryPreset, HttpRetryUnsafeMethodPolicy, PROBE_INTERVALS, STREAM_CHUNK_BYTES_MAX, STREAM_CHUNK_BYTES_MIN, STREAM_HEARTBEAT_MS_MAX, STREAM_HEARTBEAT_MS_MIN, STREAM_IDLE_TIMEOUT_MS_MAX, STREAM_IDLE_TIMEOUT_MS_MIN, STREAM_MAX_DURATION_MS_MAX, STREAM_MAX_DURATION_MS_MIN, } from "./types.js";
|
|
41
62
|
export * from "./utils/date.js";
|
|
42
63
|
export * from "./utils/parse.js";
|
|
43
64
|
export * from "./utils/text.js";
|
|
44
65
|
export * from "./utils/transform.js";
|
|
66
|
+
export { HttpTelemetryCollector, type HttpTelemetrySink, type HttpTelemetryRequestSink, type HttpAttemptTelemetryEvent, type HttpAttemptSample, type HttpTelemetryErrorCode, type HttpTelemetryRetryPayload, type HttpTelemetryLogPayload, type HttpTelemetryHeaderPayload, } from "./runtime/http-telemetry.js";
|
|
67
|
+
export { NativeTelemetryCollector, type NativeAttemptSample, type NativeConnectTelemetryEvent, type NativeLifecycleTelemetryEvent, type NativeTelemetryDiagnostics, type NativeTelemetryErrorCode, type NativeTelemetryHeaderPayload, type NativeTelemetryKind, type NativeTelemetryLifecycleKind, type NativeTelemetryLogPayload, type NativeTelemetryOutcome, type NativeTelemetrySink, type NativeTelemetryVendorSkipReason, type NativeVendorSkipTelemetryEvent, } from "./runtime/native-telemetry.js";
|
|
68
|
+
export { CacheTelemetryCollector, type CacheTelemetryHeaderPayload, type CacheTelemetryLogPayload, type CacheTelemetrySample, type CacheTelemetrySink, type CacheTelemetrySource, } from "./runtime/cache-telemetry.js";
|
|
69
|
+
export { StateTelemetryCollector, instrumentProviderRuntimeState, type StateTelemetryBackend, type StateTelemetryHeaderPayload, type StateTelemetryLogPayload, type StateTelemetryOperation, type StateTelemetrySample, type StateTelemetrySink, type StateTelemetryViolation, } from "./runtime/state-telemetry.js";
|
package/dist/index.js
CHANGED
|
@@ -1,40 +1,58 @@
|
|
|
1
1
|
// @apifuse/provider-sdk
|
|
2
2
|
export * from "./auth.js";
|
|
3
3
|
export * from "./ceremonies/index.js";
|
|
4
|
-
export
|
|
5
|
-
export { defineConfig, loadApiFuseConfig } from "./config/loader.js";
|
|
4
|
+
export { defineConfig, loadApiFuseConfig, resolveProxy } from "./config/loader.js";
|
|
6
5
|
export { canonicalJson, digestProviderContract, extractProviderContract, PROVIDER_CONTRACT_SCHEMA_VERSION, } from "./contract.js";
|
|
7
6
|
export { centered, delayed, defineHealthJourney, defineOperation, defineProvider, defineSmsOtpMatcher, defineStreamOperation, every, } from "./define.js";
|
|
7
|
+
export { AssertionExpressionSchema, AssertionPredicateSchema, AssertStepSchema, BoundedJsonPathSchema, CandidateBlockSchema, CandidatePolicySchema, CredentialRefDeclarationSchema, defineHealthScenario, HealthScenarioSchema, HealthStepSchema, ExtractStepSchema, FindFirstSchema, GUARD_REASON_CODES, GuardStepSchema, JournalPolicySchema, JsonTemplateSchema, ManualTriggerPolicySchema, OperandSchema, OperationStepSchema, QuantifierSchema, ReferenceSchema, RetryPolicySchema, SafeRegexSchema, ScopedAssertionExpressionSchema, ScopedAssertionPredicateSchema, ScopedItemReferenceSchema, ScopedOperandSchema, StepReferenceSchema, RelativeDateNodeSchema, ValueTypeSchema, } from "./health-scenario.js";
|
|
8
8
|
export { createDevServer, startDevServer } from "./dev.js";
|
|
9
9
|
export * from "./errors.js";
|
|
10
|
+
export * from "./engine.js";
|
|
11
|
+
export * from "./observability.js";
|
|
10
12
|
export * from "./user-input.js";
|
|
11
13
|
export * from "./i18n/index.js";
|
|
12
14
|
export { lintOperation, lintProvider, } from "./lint.js";
|
|
15
|
+
export { lintRuntimeBoundarySources, RUNTIME_BOUNDARY_RULES, } from "./runtime-boundary-lint.js";
|
|
16
|
+
export { TYPESCRIPT_COMPILER_MODULE_SPECIFIERS, } from "./typescript-module.js";
|
|
13
17
|
export * from "./recipes/gov-api.js";
|
|
14
18
|
export * from "./recipes/rest-api.js";
|
|
15
19
|
export { createFlowContext, createScratchpad } from "./runtime/auth-flow.js";
|
|
16
|
-
export {
|
|
17
|
-
export
|
|
18
|
-
export {
|
|
20
|
+
export { APIFUSE__CACHE__KEY_PEPPER_ENV, createBypassProviderCache, createProviderCache, } from "./runtime/cache.js";
|
|
21
|
+
export * from "./handle.js";
|
|
22
|
+
export { APIFUSE_HANDLE_META_KEY, HANDLE_KIND_NAME_PATTERN, handleFieldDescription, handleFieldNameFor, handleHasDirectionalFieldNames, isHandleFieldMeta, } from "./handle-meta.js";
|
|
23
|
+
export { createHandleContext, createTestHandleContext, normalizeHandle, } from "./runtime/handle.js";
|
|
19
24
|
export { createCredentialContext, } from "./runtime/credential.js";
|
|
20
25
|
export { createEnvContext } from "./runtime/env.js";
|
|
21
26
|
export { executeOperation } from "./runtime/executor.js";
|
|
22
27
|
export { createHttpClient } from "./runtime/http.js";
|
|
28
|
+
export { OcrTelemetryCollector, bindOcrTelemetry, } from "./runtime/ocr-telemetry.js";
|
|
29
|
+
export { NativeEgressGrantExpiredError, NativeEgressNotDeclaredError, NativeIdleTimeoutError, NativeNetworkError, NativeProxyExpiredError, } from "./runtime/native-network-errors.js";
|
|
23
30
|
export { generateInsights } from "./runtime/insights.js";
|
|
24
31
|
export { wrapWithInstrumentation, } from "./runtime/instrumentation.js";
|
|
25
|
-
export { prevalidate } from "./runtime/prevalidate.js";
|
|
26
32
|
export { getProviderBaseUrl } from "./runtime/provider.js";
|
|
33
|
+
export { RequestTelemetry, closedEnum, } from "./runtime/request-telemetry.js";
|
|
34
|
+
export { APIFUSE__ENGINE__CEREMONY_LEASE_KEY } from "./runtime/egress-lease.js";
|
|
35
|
+
export { ResolverTelemetryCollector, } from "./runtime/resolver-telemetry.js";
|
|
36
|
+
export { StealthTelemetryCollector, } from "./runtime/stealth-telemetry.js";
|
|
37
|
+
export { SttTelemetryCollector, bindSttTelemetry, } from "./runtime/stt-telemetry.js";
|
|
38
|
+
export { BrowserTelemetryCollector, } from "./runtime/browser-telemetry.js";
|
|
39
|
+
export { APIFUSE__CDP_POOL__URL, APIFUSE__RESOLVER__2CAPTCHA__API_KEY, APIFUSE__RESOLVER__CAPMONSTER__API_KEY, APIFUSE__RESOLVER__CAPSOLVER__API_KEY, APIFUSE__RESOLVER__HYPERSOLUTIONS__API_KEY, APIFUSE__RESOLVER__TIMEOUT_MS, DEFAULT_RESOLVER_TIMEOUT_MS, } from "./runtime/resolver-config.js";
|
|
40
|
+
export { createUnsupportedResolverClient } from "./runtime/resolver-shared.js";
|
|
27
41
|
export { assertRequiredSecretsPresent, listMissingRequiredSecrets, MISSING_SECRET_CODE, } from "./runtime/secrets.js";
|
|
28
|
-
export { createUnsupportedProviderRuntimeState, UnsupportedProviderStateError, } from "./runtime/state.js";
|
|
29
|
-
export {
|
|
42
|
+
export { createMemoryProviderRuntimeState, createUnsupportedProviderRuntimeState, UnsupportedProviderStateError, } from "./runtime/state.js";
|
|
43
|
+
export { APIFUSE__OCR__API_KEY_ENV, APIFUSE__OCR__BACKEND_ENV, APIFUSE__OCR__BASE_URL_ENV, APIFUSE__OCR__CLOUDFLARE_API_TOKEN_ENV, APIFUSE__OCR__MODEL_ENV, CLOUDFLARE_ACCOUNT_ID_ENV, CLOUDFLARE_WORKERS_AI_OCR_BACKEND, createCloudflareWorkersAiOcrClient, createOcrClientFromEnv, createOpenAiCompatibleOcrClient, createUnsupportedOcrClient, DEFAULT_CLOUDFLARE_WORKERS_AI_OCR_MODEL, extractCaptchaCandidates, OPENAI_COMPATIBLE_OCR_BACKEND, } from "./runtime/ocr.js";
|
|
30
44
|
export { APIFUSE__STT__BACKEND_ENV, APIFUSE__STT__CLOUDFLARE_API_TOKEN_ENV, APIFUSE__STT__MODEL_ENV, createSttClientFromEnv, createUnsupportedSttClient, extractVerificationCode, resolveSttPrompt, } from "./runtime/stt.js";
|
|
31
45
|
export { createTraceContext, } from "./runtime/trace.js";
|
|
32
|
-
export { APIFUSE_DESCRIPTION_KEY_META_KEY, APIFUSE_REDACTION_MARKER, APIFUSE_SENSITIVE_KIND_META_KEY, APIFUSE_SENSITIVE_META_KEY, collectSensitivePaths, describeKey, field, fields, isSensitiveSchema, redactPayload, sensitive, z, } from "./schema.js";
|
|
33
|
-
export { createServerApp, serve } from "./server/
|
|
34
|
-
export { getStealthProfile, listStealthProfiles } from "./stealth/profiles.js";
|
|
46
|
+
export { APIFUSE_CONTENT_PROVENANCE_META_KEY, APIFUSE_CONTENT_TRUST_META_KEY, APIFUSE_DESCRIPTION_KEY_META_KEY, APIFUSE_REDACTION_MARKER, APIFUSE_SENSITIVE_KIND_META_KEY, APIFUSE_SENSITIVE_META_KEY, collectSensitivePaths, describeKey, field, fields, isSensitiveSchema, publicField, redactPayload, sensitive, untrustedContent, z, } from "./schema.js";
|
|
47
|
+
export { createServerApp, createServerAppAsync, ERROR_OBSERVABILITY_HEADER, serve, } from "./server/serve.js";
|
|
48
|
+
export { DEFAULT_STEALTH_BROWSER, DEFAULT_STEALTH_OS, getStealthProfile, listStealthProfiles, } from "./stealth/profiles.js";
|
|
35
49
|
export * from "./stream.js";
|
|
36
50
|
export { DEFAULT_OPERATION_TRANSPORT, HttpRetryAfterPolicy, HttpRetryDelayStrategy, HttpRetryJitter, HttpRetryPreset, HttpRetryUnsafeMethodPolicy, PROBE_INTERVALS, STREAM_CHUNK_BYTES_MAX, STREAM_CHUNK_BYTES_MIN, STREAM_HEARTBEAT_MS_MAX, STREAM_HEARTBEAT_MS_MIN, STREAM_IDLE_TIMEOUT_MS_MAX, STREAM_IDLE_TIMEOUT_MS_MIN, STREAM_MAX_DURATION_MS_MAX, STREAM_MAX_DURATION_MS_MIN, } from "./types.js";
|
|
37
51
|
export * from "./utils/date.js";
|
|
38
52
|
export * from "./utils/parse.js";
|
|
39
53
|
export * from "./utils/text.js";
|
|
40
54
|
export * from "./utils/transform.js";
|
|
55
|
+
export { HttpTelemetryCollector, } from "./runtime/http-telemetry.js";
|
|
56
|
+
export { NativeTelemetryCollector, } from "./runtime/native-telemetry.js";
|
|
57
|
+
export { CacheTelemetryCollector, } from "./runtime/cache-telemetry.js";
|
|
58
|
+
export { StateTelemetryCollector, instrumentProviderRuntimeState, } from "./runtime/state-telemetry.js";
|