@lovrozagar/honey 0.6.8 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +514 -192
- package/bin/honey.js +25 -0
- package/dist/accepts.d.ts +7 -1
- package/dist/accepts.d.ts.map +1 -1
- package/dist/accepts.js +126 -0
- package/dist/accepts.js.map +1 -0
- package/dist/body-kind.d.ts +26 -0
- package/dist/body-kind.d.ts.map +1 -0
- package/dist/body-kind.js +70 -0
- package/dist/body-kind.js.map +1 -0
- package/dist/body-limit.d.ts +5 -1
- package/dist/body-limit.d.ts.map +1 -1
- package/dist/body-limit.js +126 -0
- package/dist/body-limit.js.map +1 -0
- package/dist/build/index.d.ts +19 -3
- package/dist/build/index.d.ts.map +1 -1
- package/dist/build/index.js +173 -0
- package/dist/build/index.js.map +1 -0
- package/dist/cli-args.d.ts +33 -0
- package/dist/cli-args.d.ts.map +1 -0
- package/dist/cli-args.js +102 -0
- package/dist/cli-args.js.map +1 -0
- package/dist/cli-go/auth.go +26 -0
- package/dist/cli-go/config.go +192 -0
- package/dist/cli-go/errors.go +75 -0
- package/dist/cli-go/multipart.go +79 -0
- package/dist/cli-go/output.go +163 -0
- package/dist/cli-go/root.go +30 -0
- package/dist/cli-go/stream.go +88 -0
- package/dist/cli-go/version.go +5 -0
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +209 -0
- package/dist/cli.js.map +1 -0
- package/dist/client/defaults.js +48 -0
- package/dist/client/defaults.js.map +1 -0
- package/dist/client/error.d.ts +35 -0
- package/dist/client/error.d.ts.map +1 -1
- package/dist/client/error.js +71 -0
- package/dist/client/error.js.map +1 -0
- package/dist/client/http.d.ts +67 -8
- package/dist/client/http.d.ts.map +1 -1
- package/dist/client/http.js +571 -0
- package/dist/client/http.js.map +1 -0
- package/dist/client/index.d.ts +3 -2
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +95 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/path.d.ts +26 -0
- package/dist/client/path.d.ts.map +1 -0
- package/dist/client/path.js +163 -0
- package/dist/client/path.js.map +1 -0
- package/dist/client/redirect-policy.d.ts +12 -0
- package/dist/client/redirect-policy.d.ts.map +1 -0
- package/dist/client/redirect-policy.js +20 -0
- package/dist/client/redirect-policy.js.map +1 -0
- package/dist/client/sdk.d.ts +36 -0
- package/dist/client/sdk.d.ts.map +1 -1
- package/dist/client/sdk.js +292 -0
- package/dist/client/sdk.js.map +1 -0
- package/dist/client/sse.d.ts +13 -0
- package/dist/client/sse.d.ts.map +1 -1
- package/dist/client/sse.js +129 -0
- package/dist/client/sse.js.map +1 -0
- package/dist/client/types.js +2 -0
- package/dist/client/types.js.map +1 -0
- package/dist/client/ws.d.ts +9 -2
- package/dist/client/ws.d.ts.map +1 -1
- package/dist/client/ws.js +112 -0
- package/dist/client/ws.js.map +1 -0
- package/dist/client-go/errors.go +236 -0
- package/dist/client-go/export.go +44 -0
- package/dist/client-go/invalidation.go +371 -0
- package/dist/client-go/nullable.go +62 -0
- package/dist/client-go/realtime.go +354 -0
- package/dist/client-go/result.go +20 -0
- package/dist/client-go/runtime.go +975 -0
- package/dist/client-go/sse.go +159 -0
- package/dist/client-go/transport.go +495 -0
- package/dist/client-go/ws.go +128 -0
- package/dist/client-info.d.ts +36 -0
- package/dist/client-info.d.ts.map +1 -0
- package/dist/client-info.js +53 -0
- package/dist/client-info.js.map +1 -0
- package/dist/client-mcp/README.md +10 -0
- package/dist/client-mcp/server.ts +221 -0
- package/dist/client-mcp/types.ts +19 -0
- package/dist/client-python/_errors.py +115 -0
- package/dist/client-python/_invalidation.py +494 -0
- package/dist/client-python/_realtime.py +179 -0
- package/dist/client-python/_runtime.py +860 -0
- package/dist/client-python/_sse.py +155 -0
- package/dist/client-python/_transport.py +366 -0
- package/dist/client-python/_ws.py +159 -0
- package/dist/client-python/py.typed +0 -0
- package/dist/client-rust/errors.rs +220 -0
- package/dist/client-rust/invalidation.rs +412 -0
- package/dist/client-rust/invalidation_sync.rs +93 -0
- package/dist/client-rust/nullable.rs +17 -0
- package/dist/client-rust/realtime.rs +702 -0
- package/dist/client-rust/result.rs +22 -0
- package/dist/client-rust/runtime.rs +980 -0
- package/dist/client-rust/runtime_sync.rs +484 -0
- package/dist/client-rust/sse.rs +188 -0
- package/dist/client-rust/ws.rs +167 -0
- package/dist/codegen-go-cli.d.ts.map +1 -1
- package/dist/codegen-go-cli.js +964 -0
- package/dist/codegen-go-cli.js.map +1 -0
- package/dist/codegen-go.d.ts +15 -3
- package/dist/codegen-go.d.ts.map +1 -1
- package/dist/codegen-go.js +872 -0
- package/dist/codegen-go.js.map +1 -0
- package/dist/codegen-hash.js +9 -0
- package/dist/codegen-hash.js.map +1 -0
- package/dist/codegen-ir.d.ts +69 -2
- package/dist/codegen-ir.d.ts.map +1 -1
- package/dist/codegen-ir.js +661 -0
- package/dist/codegen-ir.js.map +1 -0
- package/dist/codegen-lang.d.ts +65 -0
- package/dist/codegen-lang.d.ts.map +1 -0
- package/dist/codegen-lang.js +526 -0
- package/dist/codegen-lang.js.map +1 -0
- package/dist/codegen-load.d.ts +31 -0
- package/dist/codegen-load.d.ts.map +1 -0
- package/dist/codegen-load.js +138 -0
- package/dist/codegen-load.js.map +1 -0
- package/dist/codegen-loaders.js +55 -0
- package/dist/codegen-loaders.js.map +1 -0
- package/dist/codegen-mcp.d.ts.map +1 -1
- package/dist/codegen-mcp.js +368 -0
- package/dist/codegen-mcp.js.map +1 -0
- package/dist/codegen-python.d.ts +13 -1
- package/dist/codegen-python.d.ts.map +1 -1
- package/dist/codegen-python.js +828 -0
- package/dist/codegen-python.js.map +1 -0
- package/dist/codegen-route-tree-intern.d.ts +15 -5
- package/dist/codegen-route-tree-intern.d.ts.map +1 -1
- package/dist/codegen-route-tree-intern.js +221 -0
- package/dist/codegen-route-tree-intern.js.map +1 -0
- package/dist/codegen-rust.d.ts.map +1 -1
- package/dist/codegen-rust.js +1293 -0
- package/dist/codegen-rust.js.map +1 -0
- package/dist/codegen-sanitize.d.ts.map +1 -1
- package/dist/codegen-sanitize.js +56 -0
- package/dist/codegen-sanitize.js.map +1 -0
- package/dist/codegen-schema-naming.d.ts +5 -0
- package/dist/codegen-schema-naming.d.ts.map +1 -1
- package/dist/codegen-schema-naming.js +150 -0
- package/dist/codegen-schema-naming.js.map +1 -0
- package/dist/codegen-sdk-model.d.ts +71 -0
- package/dist/codegen-sdk-model.d.ts.map +1 -0
- package/dist/codegen-sdk-model.js +179 -0
- package/dist/codegen-sdk-model.js.map +1 -0
- package/dist/codegen.d.ts +41 -23
- package/dist/codegen.d.ts.map +1 -1
- package/dist/codegen.js +4610 -0
- package/dist/codegen.js.map +1 -0
- package/dist/context.d.ts +36 -6
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +242 -0
- package/dist/context.js.map +1 -0
- package/dist/cookie-sign.d.ts +16 -2
- package/dist/cookie-sign.d.ts.map +1 -1
- package/dist/cookie-sign.js +104 -0
- package/dist/cookie-sign.js.map +1 -0
- package/dist/cookie.d.ts +12 -0
- package/dist/cookie.d.ts.map +1 -1
- package/dist/cookie.js +138 -0
- package/dist/cookie.js.map +1 -0
- package/dist/cors.d.ts +1 -0
- package/dist/cors.d.ts.map +1 -1
- package/dist/cors.js +87 -0
- package/dist/cors.js.map +1 -0
- package/dist/crypto.d.ts +6 -1
- package/dist/crypto.d.ts.map +1 -1
- package/dist/crypto.js +38 -0
- package/dist/crypto.js.map +1 -0
- package/dist/csrf.d.ts +19 -0
- package/dist/csrf.d.ts.map +1 -1
- package/dist/csrf.js +79 -0
- package/dist/csrf.js.map +1 -0
- package/dist/curl-logger.d.ts +14 -3
- package/dist/curl-logger.d.ts.map +1 -1
- package/dist/curl-logger.js +199 -0
- package/dist/curl-logger.js.map +1 -0
- package/dist/detect-runtime.js +13 -0
- package/dist/detect-runtime.js.map +1 -0
- package/dist/dict.d.ts +11 -0
- package/dist/dict.d.ts.map +1 -0
- package/dist/dict.js +13 -0
- package/dist/dict.js.map +1 -0
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js +44 -0
- package/dist/error.js.map +1 -0
- package/dist/errors.js +39 -0
- package/dist/errors.js.map +1 -0
- package/dist/etag.d.ts +2 -0
- package/dist/etag.d.ts.map +1 -1
- package/dist/etag.js +82 -0
- package/dist/etag.js.map +1 -0
- package/dist/feature-detect.d.ts +25 -0
- package/dist/feature-detect.d.ts.map +1 -0
- package/dist/feature-detect.js +144 -0
- package/dist/feature-detect.js.map +1 -0
- package/dist/feature-load.js +36 -0
- package/dist/feature-load.js.map +1 -0
- package/dist/feature-slots.d.ts +44 -0
- package/dist/feature-slots.d.ts.map +1 -0
- package/dist/feature-slots.js +48 -0
- package/dist/feature-slots.js.map +1 -0
- package/dist/fetch-request.d.ts +10 -0
- package/dist/fetch-request.d.ts.map +1 -0
- package/dist/fetch-request.js +13 -0
- package/dist/fetch-request.js.map +1 -0
- package/dist/gen-process.d.ts +15 -0
- package/dist/gen-process.d.ts.map +1 -0
- package/dist/gen-process.js +43 -0
- package/dist/gen-process.js.map +1 -0
- package/dist/gen-write.d.ts +19 -0
- package/dist/gen-write.d.ts.map +1 -0
- package/dist/gen-write.js +120 -0
- package/dist/gen-write.js.map +1 -0
- package/dist/glob.d.ts +21 -0
- package/dist/glob.d.ts.map +1 -0
- package/dist/glob.js +115 -0
- package/dist/glob.js.map +1 -0
- package/dist/go-type-emitter.d.ts +18 -4
- package/dist/go-type-emitter.d.ts.map +1 -1
- package/dist/go-type-emitter.js +594 -0
- package/dist/go-type-emitter.js.map +1 -0
- package/dist/honey-response.d.ts.map +1 -1
- package/dist/honey-response.js +338 -0
- package/dist/honey-response.js.map +1 -0
- package/dist/i18n-slot.d.ts +8 -0
- package/dist/i18n-slot.d.ts.map +1 -1
- package/dist/i18n-slot.js +14 -0
- package/dist/i18n-slot.js.map +1 -0
- package/dist/i18n.d.ts +3 -0
- package/dist/i18n.d.ts.map +1 -1
- package/dist/i18n.js +250 -0
- package/dist/i18n.js.map +1 -0
- package/dist/index.d.ts +408 -148
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2324 -0
- package/dist/index.js.map +1 -0
- package/dist/init.d.ts +3 -5
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +140 -0
- package/dist/init.js.map +1 -0
- package/dist/input.js +4 -0
- package/dist/input.js.map +1 -0
- package/dist/invalidate-check.d.ts +11 -0
- package/dist/invalidate-check.d.ts.map +1 -1
- package/dist/invalidate-check.js +163 -0
- package/dist/invalidate-check.js.map +1 -0
- package/dist/invoke-user.d.ts +35 -0
- package/dist/invoke-user.d.ts.map +1 -0
- package/dist/invoke-user.js +73 -0
- package/dist/invoke-user.js.map +1 -0
- package/dist/ip-restrict.d.ts +13 -1
- package/dist/ip-restrict.d.ts.map +1 -1
- package/dist/ip-restrict.js +60 -0
- package/dist/ip-restrict.js.map +1 -0
- package/dist/ip.d.ts +39 -0
- package/dist/ip.d.ts.map +1 -0
- package/dist/ip.js +209 -0
- package/dist/ip.js.map +1 -0
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +113 -0
- package/dist/logger.js.map +1 -0
- package/dist/media-type.d.ts +30 -0
- package/dist/media-type.d.ts.map +1 -0
- package/dist/media-type.js +97 -0
- package/dist/media-type.js.map +1 -0
- package/dist/meta-spec-merge.d.ts +32 -0
- package/dist/meta-spec-merge.d.ts.map +1 -0
- package/dist/meta-spec-merge.js +68 -0
- package/dist/meta-spec-merge.js.map +1 -0
- package/dist/meta-spec.d.ts +16 -3
- package/dist/meta-spec.d.ts.map +1 -1
- package/dist/meta-spec.js +535 -0
- package/dist/meta-spec.js.map +1 -0
- package/dist/middleware.d.ts +23 -6
- package/dist/middleware.d.ts.map +1 -1
- package/dist/middleware.js +253 -0
- package/dist/middleware.js.map +1 -0
- package/dist/node-request.d.ts +57 -12
- package/dist/node-request.d.ts.map +1 -1
- package/dist/node-request.js +407 -0
- package/dist/node-request.js.map +1 -0
- package/dist/node.d.ts +20 -3
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js +396 -0
- package/dist/node.js.map +1 -0
- package/dist/openapi/collect.d.ts +6 -3
- package/dist/openapi/collect.d.ts.map +1 -1
- package/dist/openapi/collect.js +30 -0
- package/dist/openapi/collect.js.map +1 -0
- package/dist/openapi/docs-page.d.ts +42 -0
- package/dist/openapi/docs-page.d.ts.map +1 -0
- package/dist/openapi/docs-page.js +80 -0
- package/dist/openapi/docs-page.js.map +1 -0
- package/dist/openapi/document.d.ts +4 -0
- package/dist/openapi/document.d.ts.map +1 -1
- package/dist/openapi/document.js +785 -0
- package/dist/openapi/document.js.map +1 -0
- package/dist/openapi/json-schema-slot.d.ts +7 -0
- package/dist/openapi/json-schema-slot.d.ts.map +1 -1
- package/dist/openapi/json-schema-slot.js +38 -0
- package/dist/openapi/json-schema-slot.js.map +1 -0
- package/dist/openapi/register.d.ts.map +1 -1
- package/dist/openapi/register.js +20 -0
- package/dist/openapi/register.js.map +1 -0
- package/dist/openapi/scalar.d.ts +3 -1
- package/dist/openapi/scalar.d.ts.map +1 -1
- package/dist/openapi/scalar.js +21 -0
- package/dist/openapi/scalar.js.map +1 -0
- package/dist/openapi/serve.d.ts +9 -0
- package/dist/openapi/serve.d.ts.map +1 -0
- package/dist/openapi/serve.js +36 -0
- package/dist/openapi/serve.js.map +1 -0
- package/dist/openapi/spec-factory.d.ts +30 -1
- package/dist/openapi/spec-factory.d.ts.map +1 -1
- package/dist/openapi/spec-factory.js +52 -0
- package/dist/openapi/spec-factory.js.map +1 -0
- package/dist/openapi/spec.d.ts +14 -5
- package/dist/openapi/spec.d.ts.map +1 -1
- package/dist/openapi/spec.js +50 -0
- package/dist/openapi/spec.js.map +1 -0
- package/dist/openapi/swagger.d.ts +3 -1
- package/dist/openapi/swagger.d.ts.map +1 -1
- package/dist/openapi/swagger.js +22 -0
- package/dist/openapi/swagger.js.map +1 -0
- package/dist/pattern.d.ts +71 -0
- package/dist/pattern.d.ts.map +1 -0
- package/dist/pattern.js +239 -0
- package/dist/pattern.js.map +1 -0
- package/dist/peer.d.ts +17 -0
- package/dist/peer.d.ts.map +1 -0
- package/dist/peer.js +50 -0
- package/dist/peer.js.map +1 -0
- package/dist/plugin.d.ts +67 -16
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +649 -0
- package/dist/plugin.js.map +1 -0
- package/dist/powered-by.d.ts.map +1 -1
- package/dist/powered-by.js +11 -0
- package/dist/powered-by.js.map +1 -0
- package/dist/pretty-json.d.ts.map +1 -1
- package/dist/pretty-json.js +47 -0
- package/dist/pretty-json.js.map +1 -0
- package/dist/producer-stream.d.ts +47 -0
- package/dist/producer-stream.d.ts.map +1 -0
- package/dist/producer-stream.js +267 -0
- package/dist/producer-stream.js.map +1 -0
- package/dist/proxy.d.ts +47 -8
- package/dist/proxy.d.ts.map +1 -1
- package/dist/proxy.js +274 -0
- package/dist/proxy.js.map +1 -0
- package/dist/python-type-emitter.d.ts +14 -1
- package/dist/python-type-emitter.d.ts.map +1 -1
- package/dist/python-type-emitter.js +157 -0
- package/dist/python-type-emitter.js.map +1 -0
- package/dist/realtime/bus.d.ts +17 -1
- package/dist/realtime/bus.d.ts.map +1 -1
- package/dist/realtime/bus.js +112 -0
- package/dist/realtime/bus.js.map +1 -0
- package/dist/realtime/register.d.ts +3 -0
- package/dist/realtime/register.d.ts.map +1 -0
- package/dist/realtime/register.js +10 -0
- package/dist/realtime/register.js.map +1 -0
- package/dist/realtime/route.d.ts +65 -26
- package/dist/realtime/route.d.ts.map +1 -1
- package/dist/realtime/route.js +72 -0
- package/dist/realtime/route.js.map +1 -0
- package/dist/realtime/server.d.ts +43 -0
- package/dist/realtime/server.d.ts.map +1 -0
- package/dist/realtime/server.js +255 -0
- package/dist/realtime/server.js.map +1 -0
- package/dist/request-id.d.ts +7 -0
- package/dist/request-id.d.ts.map +1 -1
- package/dist/request-id.js +16 -0
- package/dist/request-id.js.map +1 -0
- package/dist/request-limits.d.ts +3 -0
- package/dist/request-limits.d.ts.map +1 -0
- package/dist/request-limits.js +3 -0
- package/dist/request-limits.js.map +1 -0
- package/dist/request-path.d.ts +33 -0
- package/dist/request-path.d.ts.map +1 -0
- package/dist/request-path.js +178 -0
- package/dist/request-path.js.map +1 -0
- package/dist/request-to-curl.d.ts +7 -1
- package/dist/request-to-curl.d.ts.map +1 -1
- package/dist/request-to-curl.js +48 -0
- package/dist/request-to-curl.js.map +1 -0
- package/dist/response.d.ts +25 -2
- package/dist/response.d.ts.map +1 -1
- package/dist/response.js +313 -0
- package/dist/response.js.map +1 -0
- package/dist/rust-type-emitter.d.ts +14 -2
- package/dist/rust-type-emitter.d.ts.map +1 -1
- package/dist/rust-type-emitter.js +463 -0
- package/dist/rust-type-emitter.js.map +1 -0
- package/dist/secure-headers.d.ts.map +1 -1
- package/dist/secure-headers.js +53 -0
- package/dist/secure-headers.js.map +1 -0
- package/dist/serve-register.d.ts +4 -0
- package/dist/serve-register.d.ts.map +1 -1
- package/dist/serve-register.js +9 -0
- package/dist/serve-register.js.map +1 -0
- package/dist/serve-slot.d.ts +3 -0
- package/dist/serve-slot.d.ts.map +1 -1
- package/dist/serve-slot.js +52 -0
- package/dist/serve-slot.js.map +1 -0
- package/dist/serve.d.ts +18 -1
- package/dist/serve.d.ts.map +1 -1
- package/dist/serve.js +157 -0
- package/dist/serve.js.map +1 -0
- package/dist/server-timing.d.ts.map +1 -1
- package/dist/server-timing.js +51 -0
- package/dist/server-timing.js.map +1 -0
- package/dist/static.d.ts +9 -0
- package/dist/static.d.ts.map +1 -1
- package/dist/static.js +102 -0
- package/dist/static.js.map +1 -0
- package/dist/telemetry/otel.d.ts +2 -0
- package/dist/telemetry/otel.d.ts.map +1 -1
- package/dist/telemetry/otel.js +135 -0
- package/dist/telemetry/otel.js.map +1 -0
- package/dist/testing.d.ts +12 -0
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +124 -0
- package/dist/testing.js.map +1 -0
- package/dist/timeout.d.ts +6 -0
- package/dist/timeout.d.ts.map +1 -1
- package/dist/timeout.js +36 -0
- package/dist/timeout.js.map +1 -0
- package/dist/tree.d.ts +133 -36
- package/dist/tree.d.ts.map +1 -1
- package/dist/tree.js +437 -0
- package/dist/tree.js.map +1 -0
- package/dist/trust.d.ts +21 -0
- package/dist/trust.d.ts.map +1 -0
- package/dist/trust.js +100 -0
- package/dist/trust.js.map +1 -0
- package/dist/ts-type-emitter.d.ts.map +1 -1
- package/dist/ts-type-emitter.js +150 -0
- package/dist/ts-type-emitter.js.map +1 -0
- package/dist/type-emitter.d.ts +16 -2
- package/dist/type-emitter.d.ts.map +1 -1
- package/dist/type-emitter.js +729 -0
- package/dist/type-emitter.js.map +1 -0
- package/dist/type-extractor.d.ts +8 -4
- package/dist/type-extractor.d.ts.map +1 -1
- package/dist/type-extractor.js +819 -0
- package/dist/type-extractor.js.map +1 -0
- package/dist/types.d.ts +7 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +96 -0
- package/dist/types.js.map +1 -0
- package/dist/validation.d.ts +14 -2
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +335 -0
- package/dist/validation.js.map +1 -0
- package/dist/with-headers.d.ts +15 -0
- package/dist/with-headers.d.ts.map +1 -0
- package/dist/with-headers.js +45 -0
- package/dist/with-headers.js.map +1 -0
- package/dist/ws/bun.d.ts +11 -5
- package/dist/ws/bun.d.ts.map +1 -1
- package/dist/ws/bun.js +82 -0
- package/dist/ws/bun.js.map +1 -0
- package/dist/ws/cloudflare.d.ts +25 -3
- package/dist/ws/cloudflare.d.ts.map +1 -1
- package/dist/ws/cloudflare.js +117 -0
- package/dist/ws/cloudflare.js.map +1 -0
- package/dist/ws/deno.d.ts +4 -4
- package/dist/ws/deno.d.ts.map +1 -1
- package/dist/ws/deno.js +133 -0
- package/dist/ws/deno.js.map +1 -0
- package/dist/ws/node.d.ts +20 -3
- package/dist/ws/node.d.ts.map +1 -1
- package/dist/ws/node.js +173 -0
- package/dist/ws/node.js.map +1 -0
- package/dist/ws/session.d.ts +11 -0
- package/dist/ws/session.d.ts.map +1 -0
- package/dist/ws/session.js +60 -0
- package/dist/ws/session.js.map +1 -0
- package/dist/ws/shared.d.ts +65 -0
- package/dist/ws/shared.d.ts.map +1 -0
- package/dist/ws/shared.js +103 -0
- package/dist/ws/shared.js.map +1 -0
- package/dist/ws-origin.d.ts +20 -0
- package/dist/ws-origin.d.ts.map +1 -0
- package/dist/ws-origin.js +41 -0
- package/dist/ws-origin.js.map +1 -0
- package/dist/yaml.d.ts +15 -1
- package/dist/yaml.d.ts.map +1 -1
- package/dist/yaml.js +101 -0
- package/dist/yaml.js.map +1 -0
- package/docs/invalidate-spec.md +13 -1
- package/docs/meta-spec.md +36 -12
- package/docs/packaging.md +43 -24
- package/docs/regression-matrix/README.md +32 -0
- package/docs/regression-matrix/review.md +44 -0
- package/docs/regression-matrix/ws1-3.md +97 -0
- package/docs/regression-matrix/ws4-8.md +107 -0
- package/docs/regression-matrix/ws9-12.md +266 -0
- package/docs/sdk.md +102 -52
- package/package.json +183 -52
- package/src/accepts.ts +91 -33
- package/src/body-kind.ts +67 -0
- package/src/body-limit.ts +102 -87
- package/src/build/index.ts +104 -54
- package/src/cli-args.ts +123 -0
- package/src/cli-go/auth.go +12 -1
- package/src/cli-go/config.go +29 -2
- package/src/cli-go/errors.go +28 -10
- package/src/cli-go/multipart.go +51 -27
- package/src/cli-go/output.go +58 -4
- package/src/cli-go/root.go +1 -1
- package/src/cli-go/version.go +2 -2
- package/src/cli.ts +154 -148
- package/src/client/error.ts +56 -1
- package/src/client/http.ts +479 -256
- package/src/client/index.ts +55 -17
- package/src/client/path.ts +169 -0
- package/src/client/redirect-policy.ts +19 -0
- package/src/client/sdk.ts +180 -101
- package/src/client/sse.ts +92 -66
- package/src/client/ws.ts +67 -31
- package/src/client-go/errors.go +41 -12
- package/src/client-go/export.go +44 -0
- package/src/client-go/invalidation.go +52 -54
- package/src/client-go/nullable.go +62 -0
- package/src/client-go/realtime.go +147 -110
- package/src/client-go/runtime.go +646 -88
- package/src/client-go/sse.go +104 -94
- package/src/client-go/transport.go +67 -27
- package/src/client-go/ws.go +49 -25
- package/src/client-info.ts +79 -0
- package/src/client-mcp/server.ts +133 -3
- package/src/client-python/_invalidation.py +207 -291
- package/src/client-python/_realtime.py +63 -40
- package/src/client-python/_runtime.py +501 -119
- package/src/client-python/_sse.py +130 -74
- package/src/client-python/_transport.py +37 -9
- package/src/client-python/_ws.py +50 -22
- package/src/client-rust/errors.rs +21 -1
- package/src/client-rust/invalidation.rs +202 -231
- package/src/client-rust/invalidation_sync.rs +16 -229
- package/src/client-rust/nullable.rs +17 -0
- package/src/client-rust/realtime.rs +217 -217
- package/src/client-rust/runtime.rs +602 -177
- package/src/client-rust/runtime_sync.rs +169 -145
- package/src/client-rust/sse.rs +142 -121
- package/src/client-rust/ws.rs +61 -37
- package/src/codegen-go-cli.ts +607 -728
- package/src/codegen-go.ts +710 -770
- package/src/codegen-ir.ts +381 -75
- package/src/codegen-lang.ts +517 -0
- package/src/codegen-load.ts +150 -0
- package/src/codegen-mcp.ts +207 -108
- package/src/codegen-python.ts +684 -816
- package/src/codegen-route-tree-intern.ts +51 -25
- package/src/codegen-rust.ts +946 -1240
- package/src/codegen-sanitize.ts +0 -4
- package/src/codegen-schema-naming.ts +19 -6
- package/src/codegen-sdk-model.ts +228 -0
- package/src/codegen.ts +1488 -1140
- package/src/context.ts +130 -11
- package/src/cookie-sign.ts +85 -16
- package/src/cookie.ts +66 -11
- package/src/cors.ts +55 -54
- package/src/crypto.ts +27 -5
- package/src/csrf.ts +57 -25
- package/src/curl-logger.ts +155 -114
- package/src/dict.ts +12 -0
- package/src/error.ts +4 -2
- package/src/etag.ts +58 -34
- package/src/feature-detect.ts +147 -0
- package/src/feature-slots.ts +70 -0
- package/src/fetch-request.ts +13 -0
- package/src/gen-process.ts +42 -0
- package/src/gen-write.ts +127 -0
- package/src/glob.ts +109 -0
- package/src/go-type-emitter.ts +406 -155
- package/src/honey-response.ts +36 -9
- package/src/i18n-slot.ts +10 -0
- package/src/i18n.ts +98 -23
- package/src/index.ts +1887 -1756
- package/src/init.ts +40 -28
- package/src/invalidate-check.ts +42 -4
- package/src/invoke-user.ts +95 -0
- package/src/ip-restrict.ts +47 -161
- package/src/ip.ts +194 -0
- package/src/logger.ts +65 -36
- package/src/media-type.ts +104 -0
- package/src/meta-spec-merge.ts +80 -0
- package/src/meta-spec.ts +0 -0
- package/src/middleware.ts +112 -12
- package/src/node-request.ts +242 -52
- package/src/node.ts +318 -75
- package/src/openapi/collect.ts +19 -44
- package/src/openapi/docs-page.ts +89 -0
- package/src/openapi/document.ts +503 -224
- package/src/openapi/json-schema-slot.ts +40 -0
- package/src/openapi/register.ts +7 -2
- package/src/openapi/scalar.ts +11 -10
- package/src/openapi/serve.ts +39 -0
- package/src/openapi/spec-factory.ts +50 -1
- package/src/openapi/spec.ts +53 -30
- package/src/openapi/swagger.ts +12 -11
- package/src/pattern.ts +245 -0
- package/src/peer.ts +53 -0
- package/src/plugin.ts +270 -185
- package/src/powered-by.ts +2 -2
- package/src/pretty-json.ts +25 -9
- package/src/producer-stream.ts +296 -0
- package/src/proxy.ts +253 -55
- package/src/python-type-emitter.ts +68 -56
- package/src/realtime/bus.ts +56 -9
- package/src/realtime/register.ts +13 -0
- package/src/realtime/route.ts +129 -80
- package/src/realtime/server.ts +298 -0
- package/src/request-id.ts +13 -3
- package/src/request-limits.ts +2 -0
- package/src/request-path.ts +165 -0
- package/src/request-to-curl.ts +28 -7
- package/src/response.ts +143 -103
- package/src/rust-type-emitter.ts +265 -170
- package/src/secure-headers.ts +8 -4
- package/src/serve-register.ts +4 -0
- package/src/serve-slot.ts +38 -0
- package/src/serve.ts +113 -25
- package/src/server-timing.ts +11 -7
- package/src/static.ts +85 -32
- package/src/telemetry/otel.ts +29 -7
- package/src/testing.ts +76 -14
- package/src/timeout.ts +15 -7
- package/src/tree.ts +405 -333
- package/src/trust.ts +117 -0
- package/src/ts-type-emitter.ts +18 -12
- package/src/type-emitter.ts +227 -89
- package/src/type-extractor.ts +603 -423
- package/src/types.ts +8 -0
- package/src/validation.ts +221 -96
- package/src/with-headers.ts +45 -0
- package/src/ws/bun.ts +53 -15
- package/src/ws/cloudflare.ts +81 -19
- package/src/ws/deno.ts +124 -36
- package/src/ws/node.ts +173 -79
- package/src/ws/session.ts +73 -0
- package/src/ws/shared.ts +140 -0
- package/src/ws-origin.ts +53 -0
- package/src/yaml.ts +45 -22
- package/dist/client-mcp/server.d.ts +0 -10
- package/dist/client-mcp/server.d.ts.map +0 -1
- package/dist/client-mcp/types.d.ts +0 -16
- package/dist/client-mcp/types.d.ts.map +0 -1
- package/dist/cloudflare/realtime.d.ts +0 -30
- package/dist/cloudflare/realtime.d.ts.map +0 -1
- package/dist/realtime/buffer.d.ts +0 -18
- package/dist/realtime/buffer.d.ts.map +0 -1
- package/dist/realtime/longpoll.d.ts +0 -23
- package/dist/realtime/longpoll.d.ts.map +0 -1
- package/dist/realtime/protocol.d.ts +0 -50
- package/dist/realtime/protocol.d.ts.map +0 -1
- package/dist/realtime/runtime.d.ts +0 -74
- package/dist/realtime/runtime.d.ts.map +0 -1
- package/src/cloudflare/realtime.ts +0 -234
- package/src/realtime/buffer.ts +0 -101
- package/src/realtime/longpoll.ts +0 -148
- package/src/realtime/protocol.ts +0 -128
- package/src/realtime/runtime.ts +0 -427
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
/* Code generated by honey. DO NOT EDIT. */
|
|
2
|
+
|
|
3
|
+
use std::fmt;
|
|
4
|
+
|
|
5
|
+
/// ApiError is the trait implemented by all SDK typed error types.
|
|
6
|
+
/// Use `downcast_ref` on the inner `Box<dyn ApiError>` to discriminate by status.
|
|
7
|
+
pub trait ApiError: fmt::Display + std::error::Error + Send + Sync {
|
|
8
|
+
fn status(&self) -> u16;
|
|
9
|
+
fn body(&self) -> &[u8];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
macro_rules! define_api_error {
|
|
13
|
+
($name:ident, $code:expr, $phrase:expr) => {
|
|
14
|
+
pub struct $name {
|
|
15
|
+
pub message: String,
|
|
16
|
+
pub body: Vec<u8>,
|
|
17
|
+
pub status_code: u16,
|
|
18
|
+
pub data: Option<serde_json::Value>,
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
impl fmt::Display for $name {
|
|
22
|
+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
23
|
+
write!(f, "{} {}: {}", $code, $phrase, self.message)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
impl fmt::Debug for $name {
|
|
28
|
+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
29
|
+
write!(f, "{} {{ message: {:?}, status_code: {} }}", stringify!($name), self.message, self.status_code)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
impl std::error::Error for $name {}
|
|
34
|
+
|
|
35
|
+
impl ApiError for $name {
|
|
36
|
+
fn status(&self) -> u16 {
|
|
37
|
+
$code
|
|
38
|
+
}
|
|
39
|
+
fn body(&self) -> &[u8] {
|
|
40
|
+
&self.body
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
define_api_error!(BadRequestError, 400, "Bad Request");
|
|
47
|
+
define_api_error!(UnauthorizedError, 401, "Unauthorized");
|
|
48
|
+
define_api_error!(ForbiddenError, 403, "Forbidden");
|
|
49
|
+
define_api_error!(NotFoundError, 404, "Not Found");
|
|
50
|
+
define_api_error!(ConflictError, 409, "Conflict");
|
|
51
|
+
define_api_error!(UnprocessableEntityError, 422, "Unprocessable Entity");
|
|
52
|
+
define_api_error!(RateLimitError, 429, "Too Many Requests");
|
|
53
|
+
define_api_error!(InternalServerError, 500, "Internal Server Error");
|
|
54
|
+
define_api_error!(BadGatewayError, 502, "Bad Gateway");
|
|
55
|
+
define_api_error!(ServiceUnavailableError, 503, "Service Unavailable");
|
|
56
|
+
define_api_error!(GatewayTimeoutError, 504, "Gateway Timeout");
|
|
57
|
+
|
|
58
|
+
/// StatusError is the fallback for any non-2xx status not covered by a concrete type.
|
|
59
|
+
pub struct StatusError {
|
|
60
|
+
pub message: String,
|
|
61
|
+
pub status_code: u16,
|
|
62
|
+
pub body: Vec<u8>,
|
|
63
|
+
pub data: Option<serde_json::Value>,
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
impl fmt::Display for StatusError {
|
|
67
|
+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
68
|
+
write!(f, "{}: {}", self.status_code, self.message)
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
impl fmt::Debug for StatusError {
|
|
73
|
+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
74
|
+
write!(f, "StatusError {{ status_code: {}, message: {:?} }}", self.status_code, self.message)
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
impl std::error::Error for StatusError {}
|
|
79
|
+
|
|
80
|
+
impl ApiError for StatusError {
|
|
81
|
+
fn status(&self) -> u16 {
|
|
82
|
+
self.status_code
|
|
83
|
+
}
|
|
84
|
+
fn body(&self) -> &[u8] {
|
|
85
|
+
&self.body
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/// Error is the top-level error enum for all SDK operations.
|
|
90
|
+
pub enum Error {
|
|
91
|
+
/// A typed API error (non-2xx HTTP response).
|
|
92
|
+
Api(Box<dyn ApiError + Send + Sync>),
|
|
93
|
+
/// A transport-level error from reqwest.
|
|
94
|
+
Transport(reqwest::Error),
|
|
95
|
+
/// A JSON serialization/deserialization error.
|
|
96
|
+
Json(serde_json::Error),
|
|
97
|
+
/// A URL parse error.
|
|
98
|
+
UrlParse(url::ParseError),
|
|
99
|
+
/// The request was canceled before completion.
|
|
100
|
+
Canceled,
|
|
101
|
+
/// The request timed out.
|
|
102
|
+
Timeout,
|
|
103
|
+
/// Authentication expired; string carries the refresh error message.
|
|
104
|
+
AuthExpired(String),
|
|
105
|
+
/// WebSocket close frame (or stream end). `code` is the RFC 6455 status
|
|
106
|
+
/// (1005 = no status received, 1006 = abnormal / no close frame).
|
|
107
|
+
Closed { code: u16, reason: String },
|
|
108
|
+
/// Any other error not covered by the above variants.
|
|
109
|
+
Other(String),
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
impl fmt::Display for Error {
|
|
113
|
+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
114
|
+
match self {
|
|
115
|
+
Error::Api(e) => write!(f, "api error: {}", e),
|
|
116
|
+
Error::Transport(e) => write!(f, "transport error: {}", e),
|
|
117
|
+
Error::Json(e) => write!(f, "json error: {}", e),
|
|
118
|
+
Error::UrlParse(e) => write!(f, "url parse error: {}", e),
|
|
119
|
+
Error::Canceled => write!(f, "request canceled"),
|
|
120
|
+
Error::Timeout => write!(f, "request timed out"),
|
|
121
|
+
Error::AuthExpired(msg) => write!(f, "auth expired: {}", msg),
|
|
122
|
+
Error::Closed { code, reason } => {
|
|
123
|
+
if reason.is_empty() {
|
|
124
|
+
write!(f, "connection closed: {}", code)
|
|
125
|
+
} else {
|
|
126
|
+
write!(f, "connection closed: {} {}", code, reason)
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
Error::Other(msg) => write!(f, "error: {}", msg),
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
impl fmt::Debug for Error {
|
|
135
|
+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
136
|
+
fmt::Display::fmt(self, f)
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
impl std::error::Error for Error {
|
|
141
|
+
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
|
|
142
|
+
match self {
|
|
143
|
+
Error::Transport(e) => Some(e),
|
|
144
|
+
Error::Json(e) => Some(e),
|
|
145
|
+
Error::UrlParse(e) => Some(e),
|
|
146
|
+
_ => None,
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
impl From<reqwest::Error> for Error {
|
|
152
|
+
fn from(e: reqwest::Error) -> Self {
|
|
153
|
+
if e.is_timeout() {
|
|
154
|
+
Error::Timeout
|
|
155
|
+
} else {
|
|
156
|
+
Error::Transport(e)
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
impl From<serde_json::Error> for Error {
|
|
162
|
+
fn from(e: serde_json::Error) -> Self {
|
|
163
|
+
Error::Json(e)
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
impl From<url::ParseError> for Error {
|
|
168
|
+
fn from(e: url::ParseError) -> Self {
|
|
169
|
+
Error::UrlParse(e)
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/// raise_for_status returns None for 2xx responses, Some(Error::Api(...)) for
|
|
174
|
+
/// non-2xx responses, mapping to the appropriate concrete error type when known.
|
|
175
|
+
pub(crate) fn raise_for_status(status: u16, body: Vec<u8>) -> Option<Error> {
|
|
176
|
+
if (200..300).contains(&status) {
|
|
177
|
+
return None;
|
|
178
|
+
}
|
|
179
|
+
let data: Option<serde_json::Value> = if body.is_empty() {
|
|
180
|
+
None
|
|
181
|
+
} else {
|
|
182
|
+
serde_json::from_slice(&body).ok()
|
|
183
|
+
};
|
|
184
|
+
let message = error_message(&body, data.as_ref());
|
|
185
|
+
let api_err: Box<dyn ApiError + Send + Sync> = match status {
|
|
186
|
+
400 => Box::new(BadRequestError { message, body, status_code: 400, data }),
|
|
187
|
+
401 => Box::new(UnauthorizedError { message, body, status_code: 401, data }),
|
|
188
|
+
403 => Box::new(ForbiddenError { message, body, status_code: 403, data }),
|
|
189
|
+
404 => Box::new(NotFoundError { message, body, status_code: 404, data }),
|
|
190
|
+
409 => Box::new(ConflictError { message, body, status_code: 409, data }),
|
|
191
|
+
422 => Box::new(UnprocessableEntityError { message, body, status_code: 422, data }),
|
|
192
|
+
429 => Box::new(RateLimitError { message, body, status_code: 429, data }),
|
|
193
|
+
500 => Box::new(InternalServerError { message, body, status_code: 500, data }),
|
|
194
|
+
502 => Box::new(BadGatewayError { message, body, status_code: 502, data }),
|
|
195
|
+
503 => Box::new(ServiceUnavailableError { message, body, status_code: 503, data }),
|
|
196
|
+
504 => Box::new(GatewayTimeoutError { message, body, status_code: 504, data }),
|
|
197
|
+
_ => Box::new(StatusError { message, body, status_code: status, data }),
|
|
198
|
+
};
|
|
199
|
+
Some(Error::Api(api_err))
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/// error_message is the server's `message` field when the body is a JSON object
|
|
203
|
+
/// carrying one, else the body text, with control characters dropped and capped
|
|
204
|
+
/// at 512 characters.
|
|
205
|
+
pub(crate) fn error_message(body: &[u8], data: Option<&serde_json::Value>) -> String {
|
|
206
|
+
let text = data
|
|
207
|
+
.and_then(|d| d.get("message"))
|
|
208
|
+
.and_then(|m| m.as_str())
|
|
209
|
+
.map(|s| s.to_string())
|
|
210
|
+
.unwrap_or_else(|| String::from_utf8_lossy(body).into_owned());
|
|
211
|
+
let mut out = String::new();
|
|
212
|
+
for (n, ch) in text.chars().filter(|c| !c.is_control()).enumerate() {
|
|
213
|
+
if n >= 512 {
|
|
214
|
+
out.push('…');
|
|
215
|
+
break;
|
|
216
|
+
}
|
|
217
|
+
out.push(ch);
|
|
218
|
+
}
|
|
219
|
+
out
|
|
220
|
+
}
|
|
@@ -0,0 +1,412 @@
|
|
|
1
|
+
/* Code generated by honey. DO NOT EDIT. */
|
|
2
|
+
|
|
3
|
+
#![allow(dead_code)]
|
|
4
|
+
|
|
5
|
+
use crate::runtime::InvalidationConfig;
|
|
6
|
+
use once_cell::sync::Lazy;
|
|
7
|
+
use regex::Regex;
|
|
8
|
+
use std::collections::{BTreeMap, HashMap, HashSet};
|
|
9
|
+
use std::time::{Duration, Instant};
|
|
10
|
+
use tokio::sync::Mutex;
|
|
11
|
+
|
|
12
|
+
/* PLACEHOLDER_RE matches `{name}` (any name without braces or slashes) and a
|
|
13
|
+
* `:name` segment; a colon inside a segment (`/ops/1:cancel`) is literal.
|
|
14
|
+
* Group 1: braced name; group 2: the `/` (or start) before a colon param; group 3: its name. */
|
|
15
|
+
static PLACEHOLDER_RE: Lazy<Regex> =
|
|
16
|
+
Lazy::new(|| Regex::new(r"\{([^{}/]+)\}|(^|/):([a-zA-Z_][a-zA-Z0-9_]*)").unwrap());
|
|
17
|
+
|
|
18
|
+
/* PATTERN_REGEX_CACHE caches compiled placeholder→`[^/]+` regexps per pattern key.
|
|
19
|
+
* std::sync::Mutex is fine — pure CPU work, never held across an .await point. */
|
|
20
|
+
static PATTERN_REGEX_CACHE: Lazy<std::sync::Mutex<HashMap<String, Regex>>> =
|
|
21
|
+
Lazy::new(|| std::sync::Mutex::new(HashMap::new()));
|
|
22
|
+
|
|
23
|
+
/// StaleEntry is the per-key invalidation record. `by` records mutation
|
|
24
|
+
/// selectors that contributed to the entry, `seq` is the monotonic version
|
|
25
|
+
/// stamp at write time, `until` is the absolute expiry.
|
|
26
|
+
#[derive(Clone, Debug)]
|
|
27
|
+
pub struct StaleEntry {
|
|
28
|
+
pub by: Vec<String>,
|
|
29
|
+
pub seq: u64,
|
|
30
|
+
pub until: Instant,
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/// RequestMeta is the per-request invalidation snapshot consumers see on hook
|
|
34
|
+
/// contexts. Mirrors TS `_RequestMeta`, Python `_RequestMeta`, Go `RequestMeta`.
|
|
35
|
+
#[derive(Clone, Debug)]
|
|
36
|
+
pub struct RequestMeta {
|
|
37
|
+
pub selector: String,
|
|
38
|
+
pub is_stale: bool,
|
|
39
|
+
pub invalidated_by: Vec<String>,
|
|
40
|
+
pub seq_snapshot: u64,
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/// compile_pattern returns a cached anchored regex for the given pattern,
|
|
44
|
+
/// substituting `{name}` and `:name` placeholders with `[^/]+`.
|
|
45
|
+
pub fn compile_pattern(pattern: &str) -> Regex {
|
|
46
|
+
{
|
|
47
|
+
let cache = PATTERN_REGEX_CACHE.lock().unwrap();
|
|
48
|
+
if let Some(re) = cache.get(pattern) {
|
|
49
|
+
return re.clone();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
let mut out = String::with_capacity(pattern.len() + 4);
|
|
53
|
+
out.push('^');
|
|
54
|
+
let mut last = 0usize;
|
|
55
|
+
for caps in PLACEHOLDER_RE.captures_iter(pattern) {
|
|
56
|
+
let m = caps.get(0).unwrap();
|
|
57
|
+
/* keep the segment slash of a `:name` match literal */
|
|
58
|
+
let start = m.start() + caps.get(2).map(|p| p.len()).unwrap_or(0);
|
|
59
|
+
out.push_str(®ex::escape(&pattern[last..start]));
|
|
60
|
+
out.push_str("[^/]+");
|
|
61
|
+
last = m.end();
|
|
62
|
+
}
|
|
63
|
+
out.push_str(®ex::escape(&pattern[last..]));
|
|
64
|
+
out.push('$');
|
|
65
|
+
let re = Regex::new(&out).unwrap();
|
|
66
|
+
let mut cache = PATTERN_REGEX_CACHE.lock().unwrap();
|
|
67
|
+
cache.entry(pattern.to_string()).or_insert(re).clone()
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/// path_has_placeholders returns true when `path` contains a `{name}` or `:name` segment.
|
|
71
|
+
pub fn path_has_placeholders(path: &str) -> bool {
|
|
72
|
+
PLACEHOLDER_RE.is_match(path)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/// path_matches_pattern returns true when `concrete_path` matches `pattern`,
|
|
76
|
+
/// where `pattern` may contain `{name}` / `:name` placeholders.
|
|
77
|
+
pub fn path_matches_pattern(concrete_path: &str, pattern: &str) -> bool {
|
|
78
|
+
if concrete_path == pattern {
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
compile_pattern(pattern).is_match(concrete_path)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/// interpolate_path substitutes `{name}` / `:name` placeholders in `template`
|
|
85
|
+
/// using `params`. Returns Err(missing_key) if any placeholder is not in params.
|
|
86
|
+
pub fn interpolate_path(
|
|
87
|
+
template: &str,
|
|
88
|
+
params: &HashMap<String, String>,
|
|
89
|
+
) -> Result<String, String> {
|
|
90
|
+
if !path_has_placeholders(template) {
|
|
91
|
+
return Ok(template.to_string());
|
|
92
|
+
}
|
|
93
|
+
let mut missing: Option<String> = None;
|
|
94
|
+
let mut out = String::with_capacity(template.len());
|
|
95
|
+
let mut last = 0usize;
|
|
96
|
+
for caps in PLACEHOLDER_RE.captures_iter(template) {
|
|
97
|
+
let m = caps.get(0).unwrap();
|
|
98
|
+
out.push_str(&template[last..m.start()]);
|
|
99
|
+
let prefix = caps.get(2).map(|c| c.as_str()).unwrap_or_default();
|
|
100
|
+
let key = caps
|
|
101
|
+
.get(1)
|
|
102
|
+
.or_else(|| caps.get(3))
|
|
103
|
+
.map(|c| c.as_str())
|
|
104
|
+
.unwrap_or_default();
|
|
105
|
+
match params.get(key) {
|
|
106
|
+
Some(v) => {
|
|
107
|
+
out.push_str(prefix);
|
|
108
|
+
out.push_str(&crate::runtime::escape_segment(v));
|
|
109
|
+
}
|
|
110
|
+
None => {
|
|
111
|
+
if missing.is_none() {
|
|
112
|
+
missing = Some(key.to_string());
|
|
113
|
+
}
|
|
114
|
+
out.push_str(m.as_str());
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
last = m.end();
|
|
118
|
+
}
|
|
119
|
+
out.push_str(&template[last..]);
|
|
120
|
+
if let Some(k) = missing {
|
|
121
|
+
return Err(k);
|
|
122
|
+
}
|
|
123
|
+
Ok(out)
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/// resolve_invalidation_targets_for_mutation expands templated `METHOD /path/{x}`
|
|
127
|
+
/// invalidation entries to concrete `METHOD /path/abc` selectors using params.
|
|
128
|
+
/// Entries without placeholders pass through; an entry whose placeholders cannot
|
|
129
|
+
/// all be resolved stays a pattern, so it marks every instance stale (TS parity).
|
|
130
|
+
pub fn resolve_invalidation_targets_for_mutation(
|
|
131
|
+
targets: &[String],
|
|
132
|
+
params: &HashMap<String, String>,
|
|
133
|
+
) -> Vec<String> {
|
|
134
|
+
let mut out = Vec::with_capacity(targets.len());
|
|
135
|
+
for entry in targets {
|
|
136
|
+
let space_idx = match entry.find(' ') {
|
|
137
|
+
Some(i) => i,
|
|
138
|
+
None => {
|
|
139
|
+
out.push(entry.clone());
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
let method = &entry[..space_idx];
|
|
144
|
+
let template = &entry[space_idx + 1..];
|
|
145
|
+
if !path_has_placeholders(template) {
|
|
146
|
+
out.push(entry.clone());
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
match interpolate_path(template, params) {
|
|
150
|
+
Ok(concrete) => out.push(format!("{} {}", method, concrete)),
|
|
151
|
+
Err(_) => out.push(entry.clone()),
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
out
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
struct Slot {
|
|
158
|
+
entry: StaleEntry,
|
|
159
|
+
/* position in `order`; a touch moves the entry to a fresh tick */
|
|
160
|
+
tick: u64,
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/// Stale state shared by the async and blocking trackers; each wraps it in its own mutex.
|
|
164
|
+
/// Concrete keys are found by one map read; keys that still hold placeholders are also
|
|
165
|
+
/// indexed per method, so a lookup scans only the patterns of its method. `order` keeps
|
|
166
|
+
/// LRU order by tick, so touch and eviction are O(log n).
|
|
167
|
+
#[derive(Default)]
|
|
168
|
+
pub(crate) struct TrackerState {
|
|
169
|
+
entries: HashMap<String, Slot>,
|
|
170
|
+
order: BTreeMap<u64, String>,
|
|
171
|
+
patterns: HashMap<String, HashSet<String>>,
|
|
172
|
+
next_tick: u64,
|
|
173
|
+
pub(crate) seq: u64,
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
impl TrackerState {
|
|
177
|
+
fn tick(&mut self) -> u64 {
|
|
178
|
+
self.next_tick += 1;
|
|
179
|
+
self.next_tick
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
pub(crate) fn upsert(&mut self, key: &str, until: Instant, seq: u64, mutation_selector: &str, max_sources: usize) {
|
|
183
|
+
let tick = self.tick();
|
|
184
|
+
if let Some(slot) = self.entries.get_mut(key) {
|
|
185
|
+
slot.entry.until = until;
|
|
186
|
+
slot.entry.seq = seq;
|
|
187
|
+
if !mutation_selector.is_empty()
|
|
188
|
+
&& slot.entry.by.len() < max_sources
|
|
189
|
+
&& !slot.entry.by.iter().any(|b| b == mutation_selector)
|
|
190
|
+
{
|
|
191
|
+
slot.entry.by.push(mutation_selector.to_string());
|
|
192
|
+
}
|
|
193
|
+
let old = std::mem::replace(&mut slot.tick, tick);
|
|
194
|
+
self.order.remove(&old);
|
|
195
|
+
self.order.insert(tick, key.to_string());
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
let by = if mutation_selector.is_empty() { Vec::new() } else { vec![mutation_selector.to_string()] };
|
|
199
|
+
self.entries.insert(key.to_string(), Slot { entry: StaleEntry { by, seq, until }, tick });
|
|
200
|
+
self.order.insert(tick, key.to_string());
|
|
201
|
+
if let Some((method, _)) = key.split_once(' ') {
|
|
202
|
+
if key_is_pattern(key) {
|
|
203
|
+
self.patterns.entry(method.to_string()).or_default().insert(key.to_string());
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
pub(crate) fn delete(&mut self, key: &str) {
|
|
209
|
+
let Some(slot) = self.entries.remove(key) else { return };
|
|
210
|
+
self.order.remove(&slot.tick);
|
|
211
|
+
if let Some((method, _)) = key.split_once(' ') {
|
|
212
|
+
if let Some(bucket) = self.patterns.get_mut(method) {
|
|
213
|
+
bucket.remove(key);
|
|
214
|
+
if bucket.is_empty() {
|
|
215
|
+
self.patterns.remove(method);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
pub(crate) fn seq_of(&self, key: &str) -> Option<u64> {
|
|
222
|
+
self.entries.get(key).map(|s| s.entry.seq)
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
pub(crate) fn lookup(&mut self, concrete_selector: &str, concrete_path: &str, method: &str, now: Instant) -> (Vec<String>, bool) {
|
|
226
|
+
let mut all_by: Vec<String> = Vec::new();
|
|
227
|
+
let mut exact_expired = false;
|
|
228
|
+
if let Some(exact) = self.entries.get(concrete_selector) {
|
|
229
|
+
if exact.entry.until > now {
|
|
230
|
+
all_by.extend(exact.entry.by.iter().cloned());
|
|
231
|
+
} else {
|
|
232
|
+
exact_expired = true;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
if exact_expired {
|
|
236
|
+
self.delete(concrete_selector);
|
|
237
|
+
}
|
|
238
|
+
let mut expired: Vec<String> = Vec::new();
|
|
239
|
+
if let Some(bucket) = self.patterns.get(method) {
|
|
240
|
+
for key in bucket {
|
|
241
|
+
let Some(slot) = self.entries.get(key) else { continue };
|
|
242
|
+
if slot.entry.until <= now {
|
|
243
|
+
expired.push(key.clone());
|
|
244
|
+
continue;
|
|
245
|
+
}
|
|
246
|
+
if key == concrete_selector {
|
|
247
|
+
continue;
|
|
248
|
+
}
|
|
249
|
+
let pattern = key.split_once(' ').map(|(_, p)| p).unwrap_or("");
|
|
250
|
+
if path_matches_pattern(concrete_path, pattern) {
|
|
251
|
+
all_by.extend(slot.entry.by.iter().cloned());
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
for key in expired {
|
|
256
|
+
self.delete(&key);
|
|
257
|
+
}
|
|
258
|
+
let mut seen = HashSet::new();
|
|
259
|
+
all_by.retain(|src| seen.insert(src.clone()));
|
|
260
|
+
let any = !all_by.is_empty();
|
|
261
|
+
(all_by, any)
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
pub(crate) fn clear(&mut self, concrete_selector: &str, concrete_path: &str, method: &str, seq_snapshot: u64) {
|
|
265
|
+
if self.seq_of(concrete_selector).is_some_and(|seq| seq <= seq_snapshot) {
|
|
266
|
+
self.delete(concrete_selector);
|
|
267
|
+
}
|
|
268
|
+
let to_delete: Vec<String> = self
|
|
269
|
+
.patterns
|
|
270
|
+
.get(method)
|
|
271
|
+
.map(|bucket| {
|
|
272
|
+
bucket
|
|
273
|
+
.iter()
|
|
274
|
+
.filter(|key| {
|
|
275
|
+
self.seq_of(key).is_some_and(|seq| seq <= seq_snapshot)
|
|
276
|
+
&& path_matches_pattern(concrete_path, key.split_once(' ').map(|(_, p)| p).unwrap_or(""))
|
|
277
|
+
})
|
|
278
|
+
.cloned()
|
|
279
|
+
.collect()
|
|
280
|
+
})
|
|
281
|
+
.unwrap_or_default();
|
|
282
|
+
for key in to_delete {
|
|
283
|
+
self.delete(&key);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
pub(crate) fn enforce_capacity(&mut self, max_entries: usize) {
|
|
288
|
+
if self.entries.len() <= max_entries {
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
let now = Instant::now();
|
|
292
|
+
let expired: Vec<String> = self.entries.iter().filter(|(_, s)| s.entry.until <= now).map(|(k, _)| k.clone()).collect();
|
|
293
|
+
for key in expired {
|
|
294
|
+
self.delete(&key);
|
|
295
|
+
}
|
|
296
|
+
let target = (max_entries / 2).max(1);
|
|
297
|
+
while self.entries.len() > target {
|
|
298
|
+
/* the oldest tick; delete() drops the rest of its state */
|
|
299
|
+
let Some((_, oldest)) = self.order.pop_first() else { break };
|
|
300
|
+
self.delete(&oldest);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/// StaleTracker tracks invalidation state per `METHOD /path` selector with TS-
|
|
306
|
+
/// parity semantics: exact-key + pattern-key two-tier lookup, TTL stale window,
|
|
307
|
+
/// LRU eviction at cap, monotonic seq for clear-after-mutate ordering.
|
|
308
|
+
/// All public methods are safe for concurrent async use (interior tokio Mutex).
|
|
309
|
+
pub struct StaleTracker {
|
|
310
|
+
state: Mutex<TrackerState>,
|
|
311
|
+
enabled: bool,
|
|
312
|
+
stale_time: Duration,
|
|
313
|
+
max_entries: usize,
|
|
314
|
+
max_sources: usize,
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/// (enabled, stale_time, max_entries, max_sources) from a config; disabled when absent or stale_time ≤ 0.
|
|
318
|
+
pub(crate) fn tracker_settings(cfg: Option<&InvalidationConfig>) -> (bool, Duration, usize, usize) {
|
|
319
|
+
let mut out = (false, Duration::from_millis(0), 1000usize, 16usize);
|
|
320
|
+
if let Some(c) = cfg {
|
|
321
|
+
if c.stale_time > 0 {
|
|
322
|
+
out.0 = true;
|
|
323
|
+
out.1 = Duration::from_millis(c.stale_time as u64);
|
|
324
|
+
if c.stale_max_entries > 0 {
|
|
325
|
+
out.2 = c.stale_max_entries;
|
|
326
|
+
}
|
|
327
|
+
if c.max_sources_per_target > 0 {
|
|
328
|
+
out.3 = c.max_sources_per_target;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
out
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
impl StaleTracker {
|
|
336
|
+
/// new constructs a tracker from an InvalidationConfig.
|
|
337
|
+
/// Tracker is disabled (cheap no-op) when cfg is None or stale_time ≤ 0.
|
|
338
|
+
pub fn new(cfg: Option<&InvalidationConfig>) -> Self {
|
|
339
|
+
let (enabled, stale_time, max_entries, max_sources) = tracker_settings(cfg);
|
|
340
|
+
StaleTracker { state: Mutex::new(TrackerState::default()), enabled, stale_time, max_entries, max_sources }
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/// enabled reports whether the tracker will record / report stale entries.
|
|
344
|
+
pub fn enabled(&self) -> bool {
|
|
345
|
+
self.enabled
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
/// mark_stale bumps seq, expands templated invalidation entries with
|
|
349
|
+
/// `params`, and records each resolved target as freshly stale.
|
|
350
|
+
/// `mutation_selector` is appended to each entry's `by` list (capped at
|
|
351
|
+
/// max_sources, deduped).
|
|
352
|
+
pub async fn mark_stale(&self, invalidate: &[String], params: &HashMap<String, String>, mutation_selector: &str) {
|
|
353
|
+
if !self.enabled || invalidate.is_empty() {
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
let mut s = self.state.lock().await;
|
|
357
|
+
s.seq += 1;
|
|
358
|
+
let seq = s.seq;
|
|
359
|
+
let until = Instant::now() + self.stale_time;
|
|
360
|
+
for target in resolve_invalidation_targets_for_mutation(invalidate, params) {
|
|
361
|
+
s.upsert(&target, until, seq, mutation_selector, self.max_sources);
|
|
362
|
+
}
|
|
363
|
+
s.enforce_capacity(self.max_entries);
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/// lookup_stale returns (invalidated_by, is_stale): exact + pattern lookup
|
|
367
|
+
/// with expired-key sweep. Disabled tracker → (vec![], false).
|
|
368
|
+
pub async fn lookup_stale(&self, concrete_selector: &str, concrete_path: &str, method: &str, now: Instant) -> (Vec<String>, bool) {
|
|
369
|
+
if !self.enabled {
|
|
370
|
+
return (Vec::new(), false);
|
|
371
|
+
}
|
|
372
|
+
self.state.lock().await.lookup(concrete_selector, concrete_path, method, now)
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
/// clear_stale drops stale entries whose seq ≤ seq_snapshot and which match
|
|
376
|
+
/// the given concrete_path under method (exact key + pattern keys).
|
|
377
|
+
pub async fn clear_stale(&self, concrete_selector: &str, concrete_path: &str, method: &str, seq_snapshot: u64) {
|
|
378
|
+
if !self.enabled {
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
381
|
+
self.state.lock().await.clear(concrete_selector, concrete_path, method, seq_snapshot);
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/// is_stale reports whether (method, path) currently sits inside an active
|
|
385
|
+
/// stale window. Walks pattern entries too. Disabled tracker → false.
|
|
386
|
+
pub async fn is_stale(&self, method: &str, path: &str) -> bool {
|
|
387
|
+
if !self.enabled {
|
|
388
|
+
return false;
|
|
389
|
+
}
|
|
390
|
+
let selector = format!("{} {}", method, path);
|
|
391
|
+
self.state.lock().await.lookup(&selector, path, method, Instant::now()).1
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
/// build_request_meta returns a RequestMeta snapshot for the request about
|
|
395
|
+
/// to fire, or None when tracker is disabled.
|
|
396
|
+
pub async fn build_request_meta(&self, concrete_selector: &str, concrete_path: &str, method: &str) -> Option<RequestMeta> {
|
|
397
|
+
if !self.enabled {
|
|
398
|
+
return None;
|
|
399
|
+
}
|
|
400
|
+
let mut s = self.state.lock().await;
|
|
401
|
+
let (by, is_stale) = s.lookup(concrete_selector, concrete_path, method, Instant::now());
|
|
402
|
+
Some(RequestMeta { selector: concrete_selector.to_string(), is_stale, invalidated_by: by, seq_snapshot: s.seq })
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
/// key_is_pattern reports whether a stored `METHOD /path` key holds placeholders.
|
|
407
|
+
pub(crate) fn key_is_pattern(key: &str) -> bool {
|
|
408
|
+
match key.find(' ') {
|
|
409
|
+
Some(i) => path_has_placeholders(&key[i + 1..]),
|
|
410
|
+
None => false,
|
|
411
|
+
}
|
|
412
|
+
}
|