raffel 0.1.2
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 +485 -0
- package/dist/adapters/grpc.d.ts +56 -0
- package/dist/adapters/grpc.d.ts.map +1 -0
- package/dist/adapters/grpc.int.test.d.ts +5 -0
- package/dist/adapters/grpc.int.test.d.ts.map +1 -0
- package/dist/adapters/grpc.int.test.js +168 -0
- package/dist/adapters/grpc.int.test.js.map +1 -0
- package/dist/adapters/grpc.js +434 -0
- package/dist/adapters/grpc.js.map +1 -0
- package/dist/adapters/http.d.ts +62 -0
- package/dist/adapters/http.d.ts.map +1 -0
- package/dist/adapters/http.int.test.d.ts +5 -0
- package/dist/adapters/http.int.test.d.ts.map +1 -0
- package/dist/adapters/http.int.test.js +396 -0
- package/dist/adapters/http.int.test.js.map +1 -0
- package/dist/adapters/http.js +606 -0
- package/dist/adapters/http.js.map +1 -0
- package/dist/adapters/index.d.ts +13 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/index.js +13 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/adapters/jsonrpc.d.ts +86 -0
- package/dist/adapters/jsonrpc.d.ts.map +1 -0
- package/dist/adapters/jsonrpc.int.test.d.ts +5 -0
- package/dist/adapters/jsonrpc.int.test.d.ts.map +1 -0
- package/dist/adapters/jsonrpc.int.test.js +640 -0
- package/dist/adapters/jsonrpc.int.test.js.map +1 -0
- package/dist/adapters/jsonrpc.js +338 -0
- package/dist/adapters/jsonrpc.js.map +1 -0
- package/dist/adapters/s3db/adapter.d.ts +105 -0
- package/dist/adapters/s3db/adapter.d.ts.map +1 -0
- package/dist/adapters/s3db/adapter.js +539 -0
- package/dist/adapters/s3db/adapter.js.map +1 -0
- package/dist/adapters/s3db/index.d.ts +20 -0
- package/dist/adapters/s3db/index.d.ts.map +1 -0
- package/dist/adapters/s3db/index.js +25 -0
- package/dist/adapters/s3db/index.js.map +1 -0
- package/dist/adapters/s3db/s3db.int.test.d.ts +5 -0
- package/dist/adapters/s3db/s3db.int.test.d.ts.map +1 -0
- package/dist/adapters/s3db/s3db.int.test.js +472 -0
- package/dist/adapters/s3db/s3db.int.test.js.map +1 -0
- package/dist/adapters/s3db/types.d.ts +277 -0
- package/dist/adapters/s3db/types.d.ts.map +1 -0
- package/dist/adapters/s3db/types.js +7 -0
- package/dist/adapters/s3db/types.js.map +1 -0
- package/dist/adapters/s3db/utils/etag.d.ts +65 -0
- package/dist/adapters/s3db/utils/etag.d.ts.map +1 -0
- package/dist/adapters/s3db/utils/etag.js +99 -0
- package/dist/adapters/s3db/utils/etag.js.map +1 -0
- package/dist/adapters/s3db/utils/guards.d.ts +121 -0
- package/dist/adapters/s3db/utils/guards.d.ts.map +1 -0
- package/dist/adapters/s3db/utils/guards.js +169 -0
- package/dist/adapters/s3db/utils/guards.js.map +1 -0
- package/dist/adapters/s3db/utils/index.d.ts +9 -0
- package/dist/adapters/s3db/utils/index.d.ts.map +1 -0
- package/dist/adapters/s3db/utils/index.js +10 -0
- package/dist/adapters/s3db/utils/index.js.map +1 -0
- package/dist/adapters/s3db/utils/populate.d.ts +89 -0
- package/dist/adapters/s3db/utils/populate.d.ts.map +1 -0
- package/dist/adapters/s3db/utils/populate.js +165 -0
- package/dist/adapters/s3db/utils/populate.js.map +1 -0
- package/dist/adapters/tcp.d.ts +59 -0
- package/dist/adapters/tcp.d.ts.map +1 -0
- package/dist/adapters/tcp.int.test.d.ts +5 -0
- package/dist/adapters/tcp.int.test.d.ts.map +1 -0
- package/dist/adapters/tcp.int.test.js +379 -0
- package/dist/adapters/tcp.int.test.js.map +1 -0
- package/dist/adapters/tcp.js +400 -0
- package/dist/adapters/tcp.js.map +1 -0
- package/dist/adapters/websocket.d.ts +75 -0
- package/dist/adapters/websocket.d.ts.map +1 -0
- package/dist/adapters/websocket.int.test.d.ts +5 -0
- package/dist/adapters/websocket.int.test.d.ts.map +1 -0
- package/dist/adapters/websocket.int.test.js +383 -0
- package/dist/adapters/websocket.int.test.js.map +1 -0
- package/dist/adapters/websocket.js +393 -0
- package/dist/adapters/websocket.js.map +1 -0
- package/dist/cache/drivers/file.d.ts +77 -0
- package/dist/cache/drivers/file.d.ts.map +1 -0
- package/dist/cache/drivers/file.js +329 -0
- package/dist/cache/drivers/file.js.map +1 -0
- package/dist/cache/drivers/index.d.ts +10 -0
- package/dist/cache/drivers/index.d.ts.map +1 -0
- package/dist/cache/drivers/index.js +10 -0
- package/dist/cache/drivers/index.js.map +1 -0
- package/dist/cache/drivers/memory.d.ts +138 -0
- package/dist/cache/drivers/memory.d.ts.map +1 -0
- package/dist/cache/drivers/memory.int.test.d.ts +5 -0
- package/dist/cache/drivers/memory.int.test.d.ts.map +1 -0
- package/dist/cache/drivers/memory.int.test.js +241 -0
- package/dist/cache/drivers/memory.int.test.js.map +1 -0
- package/dist/cache/drivers/memory.js +659 -0
- package/dist/cache/drivers/memory.js.map +1 -0
- package/dist/cache/drivers/redis.d.ts +84 -0
- package/dist/cache/drivers/redis.d.ts.map +1 -0
- package/dist/cache/drivers/redis.js +243 -0
- package/dist/cache/drivers/redis.js.map +1 -0
- package/dist/cache/drivers/s3db.d.ts +78 -0
- package/dist/cache/drivers/s3db.d.ts.map +1 -0
- package/dist/cache/drivers/s3db.js +216 -0
- package/dist/cache/drivers/s3db.js.map +1 -0
- package/dist/cache/factory.d.ts +77 -0
- package/dist/cache/factory.d.ts.map +1 -0
- package/dist/cache/factory.js +130 -0
- package/dist/cache/factory.js.map +1 -0
- package/dist/cache/index.d.ts +62 -0
- package/dist/cache/index.d.ts.map +1 -0
- package/dist/cache/index.js +63 -0
- package/dist/cache/index.js.map +1 -0
- package/dist/cache/types.d.ts +328 -0
- package/dist/cache/types.d.ts.map +1 -0
- package/dist/cache/types.js +8 -0
- package/dist/cache/types.js.map +1 -0
- package/dist/channels/channel-manager.d.ts +39 -0
- package/dist/channels/channel-manager.d.ts.map +1 -0
- package/dist/channels/channel-manager.int.test.d.ts +5 -0
- package/dist/channels/channel-manager.int.test.d.ts.map +1 -0
- package/dist/channels/channel-manager.int.test.js +378 -0
- package/dist/channels/channel-manager.int.test.js.map +1 -0
- package/dist/channels/channel-manager.js +274 -0
- package/dist/channels/channel-manager.js.map +1 -0
- package/dist/channels/index.d.ts +47 -0
- package/dist/channels/index.d.ts.map +1 -0
- package/dist/channels/index.js +48 -0
- package/dist/channels/index.js.map +1 -0
- package/dist/channels/types.d.ts +265 -0
- package/dist/channels/types.d.ts.map +1 -0
- package/dist/channels/types.js +39 -0
- package/dist/channels/types.js.map +1 -0
- package/dist/core/ctx-call.int.test.d.ts +7 -0
- package/dist/core/ctx-call.int.test.d.ts.map +1 -0
- package/dist/core/ctx-call.int.test.js +263 -0
- package/dist/core/ctx-call.int.test.js.map +1 -0
- package/dist/core/event-delivery.d.ts +38 -0
- package/dist/core/event-delivery.d.ts.map +1 -0
- package/dist/core/event-delivery.js +131 -0
- package/dist/core/event-delivery.js.map +1 -0
- package/dist/core/index.d.ts +7 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +7 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/registry.d.ts +93 -0
- package/dist/core/registry.d.ts.map +1 -0
- package/dist/core/registry.js +107 -0
- package/dist/core/registry.js.map +1 -0
- package/dist/core/registry.unit.test.d.ts +2 -0
- package/dist/core/registry.unit.test.d.ts.map +1 -0
- package/dist/core/registry.unit.test.js +133 -0
- package/dist/core/registry.unit.test.js.map +1 -0
- package/dist/core/router.d.ts +70 -0
- package/dist/core/router.d.ts.map +1 -0
- package/dist/core/router.int.test.d.ts +2 -0
- package/dist/core/router.int.test.d.ts.map +1 -0
- package/dist/core/router.int.test.js +368 -0
- package/dist/core/router.int.test.js.map +1 -0
- package/dist/core/router.js +308 -0
- package/dist/core/router.js.map +1 -0
- package/dist/docs/generators/content-types.d.ts +10 -0
- package/dist/docs/generators/content-types.d.ts.map +1 -0
- package/dist/docs/generators/content-types.js +18 -0
- package/dist/docs/generators/content-types.js.map +1 -0
- package/dist/docs/generators/errors-types.d.ts +409 -0
- package/dist/docs/generators/errors-types.d.ts.map +1 -0
- package/dist/docs/generators/errors-types.js +224 -0
- package/dist/docs/generators/errors-types.js.map +1 -0
- package/dist/docs/generators/errors.d.ts +88 -0
- package/dist/docs/generators/errors.d.ts.map +1 -0
- package/dist/docs/generators/errors.js +224 -0
- package/dist/docs/generators/errors.js.map +1 -0
- package/dist/docs/generators/generators.int.test.d.ts +2 -0
- package/dist/docs/generators/generators.int.test.d.ts.map +1 -0
- package/dist/docs/generators/generators.int.test.js +105 -0
- package/dist/docs/generators/generators.int.test.js.map +1 -0
- package/dist/docs/generators/grpc-generator.d.ts +53 -0
- package/dist/docs/generators/grpc-generator.d.ts.map +1 -0
- package/dist/docs/generators/grpc-generator.js +109 -0
- package/dist/docs/generators/grpc-generator.js.map +1 -0
- package/dist/docs/generators/http-generator.d.ts +49 -0
- package/dist/docs/generators/http-generator.d.ts.map +1 -0
- package/dist/docs/generators/http-generator.js +561 -0
- package/dist/docs/generators/http-generator.js.map +1 -0
- package/dist/docs/generators/index.d.ts +17 -0
- package/dist/docs/generators/index.d.ts.map +1 -0
- package/dist/docs/generators/index.js +30 -0
- package/dist/docs/generators/index.js.map +1 -0
- package/dist/docs/generators/jsonrpc-generator.d.ts +53 -0
- package/dist/docs/generators/jsonrpc-generator.d.ts.map +1 -0
- package/dist/docs/generators/jsonrpc-generator.js +111 -0
- package/dist/docs/generators/jsonrpc-generator.js.map +1 -0
- package/dist/docs/generators/schema-converter.d.ts +117 -0
- package/dist/docs/generators/schema-converter.d.ts.map +1 -0
- package/dist/docs/generators/schema-converter.js +370 -0
- package/dist/docs/generators/schema-converter.js.map +1 -0
- package/dist/docs/generators/streams-generator.d.ts +85 -0
- package/dist/docs/generators/streams-generator.d.ts.map +1 -0
- package/dist/docs/generators/streams-generator.js +282 -0
- package/dist/docs/generators/streams-generator.js.map +1 -0
- package/dist/docs/generators/tcp-generator.d.ts +133 -0
- package/dist/docs/generators/tcp-generator.d.ts.map +1 -0
- package/dist/docs/generators/tcp-generator.js +227 -0
- package/dist/docs/generators/tcp-generator.js.map +1 -0
- package/dist/docs/generators/udp-generator.d.ts +119 -0
- package/dist/docs/generators/udp-generator.d.ts.map +1 -0
- package/dist/docs/generators/udp-generator.js +241 -0
- package/dist/docs/generators/udp-generator.js.map +1 -0
- package/dist/docs/generators/usd-generator.d.ts +182 -0
- package/dist/docs/generators/usd-generator.d.ts.map +1 -0
- package/dist/docs/generators/usd-generator.js +473 -0
- package/dist/docs/generators/usd-generator.js.map +1 -0
- package/dist/docs/generators/websocket-generator.d.ts +49 -0
- package/dist/docs/generators/websocket-generator.d.ts.map +1 -0
- package/dist/docs/generators/websocket-generator.js +319 -0
- package/dist/docs/generators/websocket-generator.js.map +1 -0
- package/dist/docs/index.d.ts +31 -0
- package/dist/docs/index.d.ts.map +1 -0
- package/dist/docs/index.js +56 -0
- package/dist/docs/index.js.map +1 -0
- package/dist/docs/openapi/generator.d.ts +164 -0
- package/dist/docs/openapi/generator.d.ts.map +1 -0
- package/dist/docs/openapi/generator.int.test.d.ts +5 -0
- package/dist/docs/openapi/generator.int.test.d.ts.map +1 -0
- package/dist/docs/openapi/generator.int.test.js +260 -0
- package/dist/docs/openapi/generator.int.test.js.map +1 -0
- package/dist/docs/openapi/generator.js +690 -0
- package/dist/docs/openapi/generator.js.map +1 -0
- package/dist/docs/openapi/index.d.ts +7 -0
- package/dist/docs/openapi/index.d.ts.map +1 -0
- package/dist/docs/openapi/index.js +7 -0
- package/dist/docs/openapi/index.js.map +1 -0
- package/dist/docs/ui/html-builder.d.ts +19 -0
- package/dist/docs/ui/html-builder.d.ts.map +1 -0
- package/dist/docs/ui/html-builder.js +3065 -0
- package/dist/docs/ui/html-builder.js.map +1 -0
- package/dist/docs/ui/index.d.ts +8 -0
- package/dist/docs/ui/index.d.ts.map +1 -0
- package/dist/docs/ui/index.js +7 -0
- package/dist/docs/ui/index.js.map +1 -0
- package/dist/docs/ui/styles.d.ts +14 -0
- package/dist/docs/ui/styles.d.ts.map +1 -0
- package/dist/docs/ui/styles.js +2228 -0
- package/dist/docs/ui/styles.js.map +1 -0
- package/dist/docs/ui/types.d.ts +68 -0
- package/dist/docs/ui/types.d.ts.map +1 -0
- package/dist/docs/ui/types.js +7 -0
- package/dist/docs/ui/types.js.map +1 -0
- package/dist/docs/ui/utils.d.ts +24 -0
- package/dist/docs/ui/utils.d.ts.map +1 -0
- package/dist/docs/ui/utils.js +55 -0
- package/dist/docs/ui/utils.js.map +1 -0
- package/dist/docs/usd-middleware.d.ts +157 -0
- package/dist/docs/usd-middleware.d.ts.map +1 -0
- package/dist/docs/usd-middleware.js +118 -0
- package/dist/docs/usd-middleware.js.map +1 -0
- package/dist/dx/health/health.int.test.d.ts +5 -0
- package/dist/dx/health/health.int.test.d.ts.map +1 -0
- package/dist/dx/health/health.int.test.js +249 -0
- package/dist/dx/health/health.int.test.js.map +1 -0
- package/dist/dx/health/index.d.ts +82 -0
- package/dist/dx/health/index.d.ts.map +1 -0
- package/dist/dx/health/index.js +260 -0
- package/dist/dx/health/index.js.map +1 -0
- package/dist/dx/health/types.d.ts +104 -0
- package/dist/dx/health/types.d.ts.map +1 -0
- package/dist/dx/health/types.js +7 -0
- package/dist/dx/health/types.js.map +1 -0
- package/dist/dx/index.d.ts +12 -0
- package/dist/dx/index.d.ts.map +1 -0
- package/dist/dx/index.js +15 -0
- package/dist/dx/index.js.map +1 -0
- package/dist/dx/logging/formats.d.ts +46 -0
- package/dist/dx/logging/formats.d.ts.map +1 -0
- package/dist/dx/logging/formats.js +225 -0
- package/dist/dx/logging/formats.js.map +1 -0
- package/dist/dx/logging/http-logging.int.test.d.ts +5 -0
- package/dist/dx/logging/http-logging.int.test.d.ts.map +1 -0
- package/dist/dx/logging/http-logging.int.test.js +319 -0
- package/dist/dx/logging/http-logging.int.test.js.map +1 -0
- package/dist/dx/logging/index.d.ts +84 -0
- package/dist/dx/logging/index.d.ts.map +1 -0
- package/dist/dx/logging/index.js +164 -0
- package/dist/dx/logging/index.js.map +1 -0
- package/dist/dx/logging/types.d.ts +76 -0
- package/dist/dx/logging/types.d.ts.map +1 -0
- package/dist/dx/logging/types.js +7 -0
- package/dist/dx/logging/types.js.map +1 -0
- package/dist/errors/codes.d.ts +239 -0
- package/dist/errors/codes.d.ts.map +1 -0
- package/dist/errors/codes.js +286 -0
- package/dist/errors/codes.js.map +1 -0
- package/dist/errors/factories.d.ts +142 -0
- package/dist/errors/factories.d.ts.map +1 -0
- package/dist/errors/factories.js +201 -0
- package/dist/errors/factories.js.map +1 -0
- package/dist/errors/factories.unit.test.d.ts +7 -0
- package/dist/errors/factories.unit.test.d.ts.map +1 -0
- package/dist/errors/factories.unit.test.js +358 -0
- package/dist/errors/factories.unit.test.js.map +1 -0
- package/dist/errors/index.d.ts +9 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +11 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/graphql/adapter.d.ts +28 -0
- package/dist/graphql/adapter.d.ts.map +1 -0
- package/dist/graphql/adapter.js +624 -0
- package/dist/graphql/adapter.js.map +1 -0
- package/dist/graphql/index.d.ts +35 -0
- package/dist/graphql/index.d.ts.map +1 -0
- package/dist/graphql/index.js +35 -0
- package/dist/graphql/index.js.map +1 -0
- package/dist/graphql/schema-generator.d.ts +23 -0
- package/dist/graphql/schema-generator.d.ts.map +1 -0
- package/dist/graphql/schema-generator.int.test.d.ts +5 -0
- package/dist/graphql/schema-generator.int.test.d.ts.map +1 -0
- package/dist/graphql/schema-generator.int.test.js +51 -0
- package/dist/graphql/schema-generator.int.test.js.map +1 -0
- package/dist/graphql/schema-generator.js +502 -0
- package/dist/graphql/schema-generator.js.map +1 -0
- package/dist/graphql/types.d.ts +172 -0
- package/dist/graphql/types.d.ts.map +1 -0
- package/dist/graphql/types.js +7 -0
- package/dist/graphql/types.js.map +1 -0
- package/dist/http/app.d.ts +156 -0
- package/dist/http/app.d.ts.map +1 -0
- package/dist/http/app.js +421 -0
- package/dist/http/app.js.map +1 -0
- package/dist/http/auth.d.ts +617 -0
- package/dist/http/auth.d.ts.map +1 -0
- package/dist/http/auth.js +913 -0
- package/dist/http/auth.js.map +1 -0
- package/dist/http/banner.d.ts +118 -0
- package/dist/http/banner.d.ts.map +1 -0
- package/dist/http/banner.js +187 -0
- package/dist/http/banner.js.map +1 -0
- package/dist/http/body-limit.d.ts +80 -0
- package/dist/http/body-limit.d.ts.map +1 -0
- package/dist/http/body-limit.js +187 -0
- package/dist/http/body-limit.js.map +1 -0
- package/dist/http/compress.d.ts +67 -0
- package/dist/http/compress.d.ts.map +1 -0
- package/dist/http/compress.js +226 -0
- package/dist/http/compress.js.map +1 -0
- package/dist/http/context-helpers.d.ts +171 -0
- package/dist/http/context-helpers.d.ts.map +1 -0
- package/dist/http/context-helpers.js +325 -0
- package/dist/http/context-helpers.js.map +1 -0
- package/dist/http/context.d.ts +157 -0
- package/dist/http/context.d.ts.map +1 -0
- package/dist/http/context.js +217 -0
- package/dist/http/context.js.map +1 -0
- package/dist/http/cookie.d.ts +291 -0
- package/dist/http/cookie.d.ts.map +1 -0
- package/dist/http/cookie.js +585 -0
- package/dist/http/cookie.js.map +1 -0
- package/dist/http/cors.d.ts +95 -0
- package/dist/http/cors.d.ts.map +1 -0
- package/dist/http/cors.js +177 -0
- package/dist/http/cors.js.map +1 -0
- package/dist/http/errors.d.ts +286 -0
- package/dist/http/errors.d.ts.map +1 -0
- package/dist/http/errors.js +487 -0
- package/dist/http/errors.js.map +1 -0
- package/dist/http/events.d.ts +251 -0
- package/dist/http/events.d.ts.map +1 -0
- package/dist/http/events.js +321 -0
- package/dist/http/events.js.map +1 -0
- package/dist/http/failban.d.ts +230 -0
- package/dist/http/failban.d.ts.map +1 -0
- package/dist/http/failban.js +351 -0
- package/dist/http/failban.js.map +1 -0
- package/dist/http/guards.d.ts +210 -0
- package/dist/http/guards.d.ts.map +1 -0
- package/dist/http/guards.js +327 -0
- package/dist/http/guards.js.map +1 -0
- package/dist/http/health.d.ts +197 -0
- package/dist/http/health.d.ts.map +1 -0
- package/dist/http/health.js +255 -0
- package/dist/http/health.js.map +1 -0
- package/dist/http/index.d.ts +64 -0
- package/dist/http/index.d.ts.map +1 -0
- package/dist/http/index.js +130 -0
- package/dist/http/index.js.map +1 -0
- package/dist/http/oauth2.d.ts +280 -0
- package/dist/http/oauth2.d.ts.map +1 -0
- package/dist/http/oauth2.js +503 -0
- package/dist/http/oauth2.js.map +1 -0
- package/dist/http/oidc.d.ts +310 -0
- package/dist/http/oidc.d.ts.map +1 -0
- package/dist/http/oidc.js +470 -0
- package/dist/http/oidc.js.map +1 -0
- package/dist/http/rate-limit.d.ts +312 -0
- package/dist/http/rate-limit.d.ts.map +1 -0
- package/dist/http/rate-limit.js +522 -0
- package/dist/http/rate-limit.js.map +1 -0
- package/dist/http/response.d.ts +239 -0
- package/dist/http/response.d.ts.map +1 -0
- package/dist/http/response.js +352 -0
- package/dist/http/response.js.map +1 -0
- package/dist/http/security.d.ts +233 -0
- package/dist/http/security.d.ts.map +1 -0
- package/dist/http/security.js +230 -0
- package/dist/http/security.js.map +1 -0
- package/dist/http/serve.d.ts +72 -0
- package/dist/http/serve.d.ts.map +1 -0
- package/dist/http/serve.js +200 -0
- package/dist/http/serve.js.map +1 -0
- package/dist/http/session.d.ts +279 -0
- package/dist/http/session.d.ts.map +1 -0
- package/dist/http/session.js +354 -0
- package/dist/http/session.js.map +1 -0
- package/dist/http/static-s3.d.ts +176 -0
- package/dist/http/static-s3.d.ts.map +1 -0
- package/dist/http/static-s3.js +282 -0
- package/dist/http/static-s3.js.map +1 -0
- package/dist/http/static.d.ts +111 -0
- package/dist/http/static.d.ts.map +1 -0
- package/dist/http/static.js +373 -0
- package/dist/http/static.js.map +1 -0
- package/dist/http/stream-auth.d.ts +312 -0
- package/dist/http/stream-auth.d.ts.map +1 -0
- package/dist/http/stream-auth.js +404 -0
- package/dist/http/stream-auth.js.map +1 -0
- package/dist/http/templates.d.ts +262 -0
- package/dist/http/templates.d.ts.map +1 -0
- package/dist/http/templates.js +457 -0
- package/dist/http/templates.js.map +1 -0
- package/dist/http/types.d.ts +97 -0
- package/dist/http/types.d.ts.map +1 -0
- package/dist/http/types.js +59 -0
- package/dist/http/types.js.map +1 -0
- package/dist/http/validate.d.ts +197 -0
- package/dist/http/validate.d.ts.map +1 -0
- package/dist/http/validate.js +437 -0
- package/dist/http/validate.js.map +1 -0
- package/dist/http/web-types.d.ts +38 -0
- package/dist/http/web-types.d.ts.map +1 -0
- package/dist/http/web-types.js +9 -0
- package/dist/http/web-types.js.map +1 -0
- package/dist/index.d.ts +45 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +96 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/cli.d.ts +18 -0
- package/dist/mcp/cli.d.ts.map +1 -0
- package/dist/mcp/cli.js +185 -0
- package/dist/mcp/cli.js.map +1 -0
- package/dist/mcp/docs/adapters.d.ts +10 -0
- package/dist/mcp/docs/adapters.d.ts.map +1 -0
- package/dist/mcp/docs/adapters.js +891 -0
- package/dist/mcp/docs/adapters.js.map +1 -0
- package/dist/mcp/docs/errors.d.ts +11 -0
- package/dist/mcp/docs/errors.d.ts.map +1 -0
- package/dist/mcp/docs/errors.js +549 -0
- package/dist/mcp/docs/errors.js.map +1 -0
- package/dist/mcp/docs/index.d.ts +38 -0
- package/dist/mcp/docs/index.d.ts.map +1 -0
- package/dist/mcp/docs/index.js +94 -0
- package/dist/mcp/docs/index.js.map +1 -0
- package/dist/mcp/docs/interceptors.d.ts +18 -0
- package/dist/mcp/docs/interceptors.d.ts.map +1 -0
- package/dist/mcp/docs/interceptors.js +872 -0
- package/dist/mcp/docs/interceptors.js.map +1 -0
- package/dist/mcp/docs/patterns.d.ts +12 -0
- package/dist/mcp/docs/patterns.d.ts.map +1 -0
- package/dist/mcp/docs/patterns.js +1099 -0
- package/dist/mcp/docs/patterns.js.map +1 -0
- package/dist/mcp/docs/quickstart.d.ts +52 -0
- package/dist/mcp/docs/quickstart.d.ts.map +1 -0
- package/dist/mcp/docs/quickstart.js +682 -0
- package/dist/mcp/docs/quickstart.js.map +1 -0
- package/dist/mcp/index.d.ts +14 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +18 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/prompts/index.d.ts +11 -0
- package/dist/mcp/prompts/index.d.ts.map +1 -0
- package/dist/mcp/prompts/index.js +596 -0
- package/dist/mcp/prompts/index.js.map +1 -0
- package/dist/mcp/resources/index.d.ts +10 -0
- package/dist/mcp/resources/index.d.ts.map +1 -0
- package/dist/mcp/resources/index.js +262 -0
- package/dist/mcp/resources/index.js.map +1 -0
- package/dist/mcp/server.d.ts +35 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +452 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/tools/definitions.d.ts +15 -0
- package/dist/mcp/tools/definitions.d.ts.map +1 -0
- package/dist/mcp/tools/definitions.js +395 -0
- package/dist/mcp/tools/definitions.js.map +1 -0
- package/dist/mcp/tools/handlers.d.ts +8 -0
- package/dist/mcp/tools/handlers.d.ts.map +1 -0
- package/dist/mcp/tools/handlers.js +883 -0
- package/dist/mcp/tools/handlers.js.map +1 -0
- package/dist/mcp/tools/index.d.ts +8 -0
- package/dist/mcp/tools/index.d.ts.map +1 -0
- package/dist/mcp/tools/index.js +8 -0
- package/dist/mcp/tools/index.js.map +1 -0
- package/dist/mcp/types.d.ts +248 -0
- package/dist/mcp/types.d.ts.map +1 -0
- package/dist/mcp/types.js +13 -0
- package/dist/mcp/types.js.map +1 -0
- package/dist/metrics/exporters.d.ts +20 -0
- package/dist/metrics/exporters.d.ts.map +1 -0
- package/dist/metrics/exporters.js +122 -0
- package/dist/metrics/exporters.js.map +1 -0
- package/dist/metrics/index.d.ts +11 -0
- package/dist/metrics/index.d.ts.map +1 -0
- package/dist/metrics/index.js +10 -0
- package/dist/metrics/index.js.map +1 -0
- package/dist/metrics/interceptor.d.ts +29 -0
- package/dist/metrics/interceptor.d.ts.map +1 -0
- package/dist/metrics/interceptor.js +146 -0
- package/dist/metrics/interceptor.js.map +1 -0
- package/dist/metrics/metrics.int.test.d.ts +5 -0
- package/dist/metrics/metrics.int.test.d.ts.map +1 -0
- package/dist/metrics/metrics.int.test.js +288 -0
- package/dist/metrics/metrics.int.test.js.map +1 -0
- package/dist/metrics/registry.d.ts +11 -0
- package/dist/metrics/registry.d.ts.map +1 -0
- package/dist/metrics/registry.js +178 -0
- package/dist/metrics/registry.js.map +1 -0
- package/dist/metrics/types.d.ts +107 -0
- package/dist/metrics/types.d.ts.map +1 -0
- package/dist/metrics/types.js +21 -0
- package/dist/metrics/types.js.map +1 -0
- package/dist/middleware/auth.d.ts +231 -0
- package/dist/middleware/auth.d.ts.map +1 -0
- package/dist/middleware/auth.int.test.d.ts +5 -0
- package/dist/middleware/auth.int.test.d.ts.map +1 -0
- package/dist/middleware/auth.int.test.js +366 -0
- package/dist/middleware/auth.int.test.js.map +1 -0
- package/dist/middleware/auth.js +413 -0
- package/dist/middleware/auth.js.map +1 -0
- package/dist/middleware/compose.d.ts +102 -0
- package/dist/middleware/compose.d.ts.map +1 -0
- package/dist/middleware/compose.int.test.d.ts +7 -0
- package/dist/middleware/compose.int.test.d.ts.map +1 -0
- package/dist/middleware/compose.int.test.js +238 -0
- package/dist/middleware/compose.int.test.js.map +1 -0
- package/dist/middleware/compose.js +152 -0
- package/dist/middleware/compose.js.map +1 -0
- package/dist/middleware/http/compression.d.ts +92 -0
- package/dist/middleware/http/compression.d.ts.map +1 -0
- package/dist/middleware/http/compression.js +264 -0
- package/dist/middleware/http/compression.js.map +1 -0
- package/dist/middleware/http/index.d.ts +10 -0
- package/dist/middleware/http/index.d.ts.map +1 -0
- package/dist/middleware/http/index.js +11 -0
- package/dist/middleware/http/index.js.map +1 -0
- package/dist/middleware/http/security.d.ts +71 -0
- package/dist/middleware/http/security.d.ts.map +1 -0
- package/dist/middleware/http/security.js +263 -0
- package/dist/middleware/http/security.js.map +1 -0
- package/dist/middleware/index.d.ts +28 -0
- package/dist/middleware/index.d.ts.map +1 -0
- package/dist/middleware/index.js +58 -0
- package/dist/middleware/index.js.map +1 -0
- package/dist/middleware/interceptors/bulkhead.d.ts +104 -0
- package/dist/middleware/interceptors/bulkhead.d.ts.map +1 -0
- package/dist/middleware/interceptors/bulkhead.int.test.d.ts +5 -0
- package/dist/middleware/interceptors/bulkhead.int.test.d.ts.map +1 -0
- package/dist/middleware/interceptors/bulkhead.int.test.js +263 -0
- package/dist/middleware/interceptors/bulkhead.int.test.js.map +1 -0
- package/dist/middleware/interceptors/bulkhead.js +260 -0
- package/dist/middleware/interceptors/bulkhead.js.map +1 -0
- package/dist/middleware/interceptors/cache.d.ts +218 -0
- package/dist/middleware/interceptors/cache.d.ts.map +1 -0
- package/dist/middleware/interceptors/cache.int.test.d.ts +5 -0
- package/dist/middleware/interceptors/cache.int.test.d.ts.map +1 -0
- package/dist/middleware/interceptors/cache.int.test.js +470 -0
- package/dist/middleware/interceptors/cache.int.test.js.map +1 -0
- package/dist/middleware/interceptors/cache.js +505 -0
- package/dist/middleware/interceptors/cache.js.map +1 -0
- package/dist/middleware/interceptors/circuit-breaker.d.ts +72 -0
- package/dist/middleware/interceptors/circuit-breaker.d.ts.map +1 -0
- package/dist/middleware/interceptors/circuit-breaker.int.test.d.ts +5 -0
- package/dist/middleware/interceptors/circuit-breaker.int.test.d.ts.map +1 -0
- package/dist/middleware/interceptors/circuit-breaker.int.test.js +253 -0
- package/dist/middleware/interceptors/circuit-breaker.int.test.js.map +1 -0
- package/dist/middleware/interceptors/circuit-breaker.js +268 -0
- package/dist/middleware/interceptors/circuit-breaker.js.map +1 -0
- package/dist/middleware/interceptors/dedup.d.ts +105 -0
- package/dist/middleware/interceptors/dedup.d.ts.map +1 -0
- package/dist/middleware/interceptors/dedup.js +219 -0
- package/dist/middleware/interceptors/dedup.js.map +1 -0
- package/dist/middleware/interceptors/fallback.d.ts +94 -0
- package/dist/middleware/interceptors/fallback.d.ts.map +1 -0
- package/dist/middleware/interceptors/fallback.int.test.d.ts +5 -0
- package/dist/middleware/interceptors/fallback.int.test.d.ts.map +1 -0
- package/dist/middleware/interceptors/fallback.int.test.js +211 -0
- package/dist/middleware/interceptors/fallback.int.test.js.map +1 -0
- package/dist/middleware/interceptors/fallback.js +161 -0
- package/dist/middleware/interceptors/fallback.js.map +1 -0
- package/dist/middleware/interceptors/index.d.ts +24 -0
- package/dist/middleware/interceptors/index.d.ts.map +1 -0
- package/dist/middleware/interceptors/index.js +28 -0
- package/dist/middleware/interceptors/index.js.map +1 -0
- package/dist/middleware/interceptors/logging.d.ts +62 -0
- package/dist/middleware/interceptors/logging.d.ts.map +1 -0
- package/dist/middleware/interceptors/logging.int.test.d.ts +5 -0
- package/dist/middleware/interceptors/logging.int.test.d.ts.map +1 -0
- package/dist/middleware/interceptors/logging.int.test.js +144 -0
- package/dist/middleware/interceptors/logging.int.test.js.map +1 -0
- package/dist/middleware/interceptors/logging.js +294 -0
- package/dist/middleware/interceptors/logging.js.map +1 -0
- package/dist/middleware/interceptors/rate-limit.d.ts +147 -0
- package/dist/middleware/interceptors/rate-limit.d.ts.map +1 -0
- package/dist/middleware/interceptors/rate-limit.int.test.d.ts +5 -0
- package/dist/middleware/interceptors/rate-limit.int.test.d.ts.map +1 -0
- package/dist/middleware/interceptors/rate-limit.int.test.js +221 -0
- package/dist/middleware/interceptors/rate-limit.int.test.js.map +1 -0
- package/dist/middleware/interceptors/rate-limit.js +376 -0
- package/dist/middleware/interceptors/rate-limit.js.map +1 -0
- package/dist/middleware/interceptors/request-id.d.ts +63 -0
- package/dist/middleware/interceptors/request-id.d.ts.map +1 -0
- package/dist/middleware/interceptors/request-id.int.test.d.ts +5 -0
- package/dist/middleware/interceptors/request-id.int.test.d.ts.map +1 -0
- package/dist/middleware/interceptors/request-id.int.test.js +136 -0
- package/dist/middleware/interceptors/request-id.int.test.js.map +1 -0
- package/dist/middleware/interceptors/request-id.js +119 -0
- package/dist/middleware/interceptors/request-id.js.map +1 -0
- package/dist/middleware/interceptors/retry.d.ts +80 -0
- package/dist/middleware/interceptors/retry.d.ts.map +1 -0
- package/dist/middleware/interceptors/retry.int.test.d.ts +5 -0
- package/dist/middleware/interceptors/retry.int.test.d.ts.map +1 -0
- package/dist/middleware/interceptors/retry.int.test.js +534 -0
- package/dist/middleware/interceptors/retry.int.test.js.map +1 -0
- package/dist/middleware/interceptors/retry.js +275 -0
- package/dist/middleware/interceptors/retry.js.map +1 -0
- package/dist/middleware/interceptors/size-limit.d.ts +145 -0
- package/dist/middleware/interceptors/size-limit.d.ts.map +1 -0
- package/dist/middleware/interceptors/size-limit.js +231 -0
- package/dist/middleware/interceptors/size-limit.js.map +1 -0
- package/dist/middleware/interceptors/timeout.d.ts +121 -0
- package/dist/middleware/interceptors/timeout.d.ts.map +1 -0
- package/dist/middleware/interceptors/timeout.int.test.d.ts +5 -0
- package/dist/middleware/interceptors/timeout.int.test.d.ts.map +1 -0
- package/dist/middleware/interceptors/timeout.int.test.js +228 -0
- package/dist/middleware/interceptors/timeout.int.test.js.map +1 -0
- package/dist/middleware/interceptors/timeout.js +253 -0
- package/dist/middleware/interceptors/timeout.js.map +1 -0
- package/dist/middleware/presets.d.ts +214 -0
- package/dist/middleware/presets.d.ts.map +1 -0
- package/dist/middleware/presets.js +329 -0
- package/dist/middleware/presets.js.map +1 -0
- package/dist/middleware/rate-limit.d.ts +105 -0
- package/dist/middleware/rate-limit.d.ts.map +1 -0
- package/dist/middleware/rate-limit.int.test.d.ts +5 -0
- package/dist/middleware/rate-limit.int.test.d.ts.map +1 -0
- package/dist/middleware/rate-limit.int.test.js +350 -0
- package/dist/middleware/rate-limit.int.test.js.map +1 -0
- package/dist/middleware/rate-limit.js +206 -0
- package/dist/middleware/rate-limit.js.map +1 -0
- package/dist/middleware/types.d.ts +371 -0
- package/dist/middleware/types.d.ts.map +1 -0
- package/dist/middleware/types.js +7 -0
- package/dist/middleware/types.js.map +1 -0
- package/dist/openapi/index.d.ts +9 -0
- package/dist/openapi/index.d.ts.map +1 -0
- package/dist/openapi/index.js +9 -0
- package/dist/openapi/index.js.map +1 -0
- package/dist/rate-limit/drivers/filesystem.d.ts +17 -0
- package/dist/rate-limit/drivers/filesystem.d.ts.map +1 -0
- package/dist/rate-limit/drivers/filesystem.js +85 -0
- package/dist/rate-limit/drivers/filesystem.js.map +1 -0
- package/dist/rate-limit/drivers/memory.d.ts +15 -0
- package/dist/rate-limit/drivers/memory.d.ts.map +1 -0
- package/dist/rate-limit/drivers/memory.js +55 -0
- package/dist/rate-limit/drivers/memory.js.map +1 -0
- package/dist/rate-limit/drivers/redis.d.ts +12 -0
- package/dist/rate-limit/drivers/redis.d.ts.map +1 -0
- package/dist/rate-limit/drivers/redis.js +46 -0
- package/dist/rate-limit/drivers/redis.js.map +1 -0
- package/dist/rate-limit/factory.d.ts +11 -0
- package/dist/rate-limit/factory.d.ts.map +1 -0
- package/dist/rate-limit/factory.js +33 -0
- package/dist/rate-limit/factory.js.map +1 -0
- package/dist/rate-limit/index.d.ts +6 -0
- package/dist/rate-limit/index.d.ts.map +1 -0
- package/dist/rate-limit/index.js +5 -0
- package/dist/rate-limit/index.js.map +1 -0
- package/dist/rate-limit/types.d.ts +51 -0
- package/dist/rate-limit/types.d.ts.map +1 -0
- package/dist/rate-limit/types.js +7 -0
- package/dist/rate-limit/types.js.map +1 -0
- package/dist/server/builder.d.ts +11 -0
- package/dist/server/builder.d.ts.map +1 -0
- package/dist/server/builder.int.test.d.ts +7 -0
- package/dist/server/builder.int.test.d.ts.map +1 -0
- package/dist/server/builder.int.test.js +414 -0
- package/dist/server/builder.int.test.js.map +1 -0
- package/dist/server/builder.js +1682 -0
- package/dist/server/builder.js.map +1 -0
- package/dist/server/channel-utils.d.ts +34 -0
- package/dist/server/channel-utils.d.ts.map +1 -0
- package/dist/server/channel-utils.js +131 -0
- package/dist/server/channel-utils.js.map +1 -0
- package/dist/server/discovery-utils.d.ts +32 -0
- package/dist/server/discovery-utils.d.ts.map +1 -0
- package/dist/server/discovery-utils.js +118 -0
- package/dist/server/discovery-utils.js.map +1 -0
- package/dist/server/errors.d.ts +186 -0
- package/dist/server/errors.d.ts.map +1 -0
- package/dist/server/errors.js +397 -0
- package/dist/server/errors.js.map +1 -0
- package/dist/server/fs-routes/index.d.ts +66 -0
- package/dist/server/fs-routes/index.d.ts.map +1 -0
- package/dist/server/fs-routes/index.js +66 -0
- package/dist/server/fs-routes/index.js.map +1 -0
- package/dist/server/fs-routes/loader.d.ts +28 -0
- package/dist/server/fs-routes/loader.d.ts.map +1 -0
- package/dist/server/fs-routes/loader.int.test.d.ts +5 -0
- package/dist/server/fs-routes/loader.int.test.d.ts.map +1 -0
- package/dist/server/fs-routes/loader.int.test.js +48 -0
- package/dist/server/fs-routes/loader.int.test.js.map +1 -0
- package/dist/server/fs-routes/loader.js +586 -0
- package/dist/server/fs-routes/loader.js.map +1 -0
- package/dist/server/fs-routes/middleware-processor.d.ts +19 -0
- package/dist/server/fs-routes/middleware-processor.d.ts.map +1 -0
- package/dist/server/fs-routes/middleware-processor.js +232 -0
- package/dist/server/fs-routes/middleware-processor.js.map +1 -0
- package/dist/server/fs-routes/resources/index.d.ts +8 -0
- package/dist/server/fs-routes/resources/index.d.ts.map +1 -0
- package/dist/server/fs-routes/resources/index.js +8 -0
- package/dist/server/fs-routes/resources/index.js.map +1 -0
- package/dist/server/fs-routes/resources/loader.d.ts +16 -0
- package/dist/server/fs-routes/resources/loader.d.ts.map +1 -0
- package/dist/server/fs-routes/resources/loader.js +431 -0
- package/dist/server/fs-routes/resources/loader.js.map +1 -0
- package/dist/server/fs-routes/resources/types.d.ts +256 -0
- package/dist/server/fs-routes/resources/types.d.ts.map +1 -0
- package/dist/server/fs-routes/resources/types.js +8 -0
- package/dist/server/fs-routes/resources/types.js.map +1 -0
- package/dist/server/fs-routes/rest/index.d.ts +8 -0
- package/dist/server/fs-routes/rest/index.d.ts.map +1 -0
- package/dist/server/fs-routes/rest/index.js +8 -0
- package/dist/server/fs-routes/rest/index.js.map +1 -0
- package/dist/server/fs-routes/rest/loader.d.ts +11 -0
- package/dist/server/fs-routes/rest/loader.d.ts.map +1 -0
- package/dist/server/fs-routes/rest/loader.js +595 -0
- package/dist/server/fs-routes/rest/loader.js.map +1 -0
- package/dist/server/fs-routes/rest/types.d.ts +288 -0
- package/dist/server/fs-routes/rest/types.d.ts.map +1 -0
- package/dist/server/fs-routes/rest/types.js +50 -0
- package/dist/server/fs-routes/rest/types.js.map +1 -0
- package/dist/server/fs-routes/tcp/index.d.ts +8 -0
- package/dist/server/fs-routes/tcp/index.d.ts.map +1 -0
- package/dist/server/fs-routes/tcp/index.js +8 -0
- package/dist/server/fs-routes/tcp/index.js.map +1 -0
- package/dist/server/fs-routes/tcp/loader.d.ts +15 -0
- package/dist/server/fs-routes/tcp/loader.d.ts.map +1 -0
- package/dist/server/fs-routes/tcp/loader.js +402 -0
- package/dist/server/fs-routes/tcp/loader.js.map +1 -0
- package/dist/server/fs-routes/tcp/types.d.ts +215 -0
- package/dist/server/fs-routes/tcp/types.d.ts.map +1 -0
- package/dist/server/fs-routes/tcp/types.js +7 -0
- package/dist/server/fs-routes/tcp/types.js.map +1 -0
- package/dist/server/fs-routes/types.d.ts +437 -0
- package/dist/server/fs-routes/types.d.ts.map +1 -0
- package/dist/server/fs-routes/types.js +7 -0
- package/dist/server/fs-routes/types.js.map +1 -0
- package/dist/server/fs-routes/udp/index.d.ts +8 -0
- package/dist/server/fs-routes/udp/index.d.ts.map +1 -0
- package/dist/server/fs-routes/udp/index.js +8 -0
- package/dist/server/fs-routes/udp/index.js.map +1 -0
- package/dist/server/fs-routes/udp/loader.d.ts +15 -0
- package/dist/server/fs-routes/udp/loader.d.ts.map +1 -0
- package/dist/server/fs-routes/udp/loader.js +282 -0
- package/dist/server/fs-routes/udp/loader.js.map +1 -0
- package/dist/server/fs-routes/udp/types.d.ts +164 -0
- package/dist/server/fs-routes/udp/types.d.ts.map +1 -0
- package/dist/server/fs-routes/udp/types.js +7 -0
- package/dist/server/fs-routes/udp/types.js.map +1 -0
- package/dist/server/fs-routes/watcher.d.ts +34 -0
- package/dist/server/fs-routes/watcher.d.ts.map +1 -0
- package/dist/server/fs-routes/watcher.js +158 -0
- package/dist/server/fs-routes/watcher.js.map +1 -0
- package/dist/server/handler-builders.d.ts +44 -0
- package/dist/server/handler-builders.d.ts.map +1 -0
- package/dist/server/handler-builders.js +297 -0
- package/dist/server/handler-builders.js.map +1 -0
- package/dist/server/hooks.int.test.d.ts +7 -0
- package/dist/server/hooks.int.test.d.ts.map +1 -0
- package/dist/server/hooks.int.test.js +564 -0
- package/dist/server/hooks.int.test.js.map +1 -0
- package/dist/server/index.d.ts +18 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +37 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/protocol-config.d.ts +22 -0
- package/dist/server/protocol-config.d.ts.map +1 -0
- package/dist/server/protocol-config.js +61 -0
- package/dist/server/protocol-config.js.map +1 -0
- package/dist/server/resource-builder.d.ts +175 -0
- package/dist/server/resource-builder.d.ts.map +1 -0
- package/dist/server/resource-builder.js +212 -0
- package/dist/server/resource-builder.js.map +1 -0
- package/dist/server/rest-middleware.d.ts +45 -0
- package/dist/server/rest-middleware.d.ts.map +1 -0
- package/dist/server/rest-middleware.js +368 -0
- package/dist/server/rest-middleware.js.map +1 -0
- package/dist/server/route-discovery.d.ts +54 -0
- package/dist/server/route-discovery.d.ts.map +1 -0
- package/dist/server/route-discovery.int.test.d.ts +5 -0
- package/dist/server/route-discovery.int.test.d.ts.map +1 -0
- package/dist/server/route-discovery.int.test.js +49 -0
- package/dist/server/route-discovery.int.test.js.map +1 -0
- package/dist/server/route-discovery.js +154 -0
- package/dist/server/route-discovery.js.map +1 -0
- package/dist/server/router-module.d.ts +50 -0
- package/dist/server/router-module.d.ts.map +1 -0
- package/dist/server/router-module.js +250 -0
- package/dist/server/router-module.js.map +1 -0
- package/dist/server/shared-context.d.ts +140 -0
- package/dist/server/shared-context.d.ts.map +1 -0
- package/dist/server/shared-context.js +258 -0
- package/dist/server/shared-context.js.map +1 -0
- package/dist/server/types.d.ts +2160 -0
- package/dist/server/types.d.ts.map +1 -0
- package/dist/server/types.js +7 -0
- package/dist/server/types.js.map +1 -0
- package/dist/stream/index.d.ts +3 -0
- package/dist/stream/index.d.ts.map +1 -0
- package/dist/stream/index.js +2 -0
- package/dist/stream/index.js.map +1 -0
- package/dist/stream/raffel-stream.d.ts +17 -0
- package/dist/stream/raffel-stream.d.ts.map +1 -0
- package/dist/stream/raffel-stream.int.test.d.ts +2 -0
- package/dist/stream/raffel-stream.int.test.d.ts.map +1 -0
- package/dist/stream/raffel-stream.int.test.js +265 -0
- package/dist/stream/raffel-stream.int.test.js.map +1 -0
- package/dist/stream/raffel-stream.js +205 -0
- package/dist/stream/raffel-stream.js.map +1 -0
- package/dist/tracing/exporters.d.ts +47 -0
- package/dist/tracing/exporters.d.ts.map +1 -0
- package/dist/tracing/exporters.js +173 -0
- package/dist/tracing/exporters.js.map +1 -0
- package/dist/tracing/index.d.ts +43 -0
- package/dist/tracing/index.d.ts.map +1 -0
- package/dist/tracing/index.js +46 -0
- package/dist/tracing/index.js.map +1 -0
- package/dist/tracing/interceptor.d.ts +20 -0
- package/dist/tracing/interceptor.d.ts.map +1 -0
- package/dist/tracing/interceptor.js +90 -0
- package/dist/tracing/interceptor.js.map +1 -0
- package/dist/tracing/sampler.d.ts +32 -0
- package/dist/tracing/sampler.d.ts.map +1 -0
- package/dist/tracing/sampler.js +111 -0
- package/dist/tracing/sampler.js.map +1 -0
- package/dist/tracing/span.d.ts +32 -0
- package/dist/tracing/span.d.ts.map +1 -0
- package/dist/tracing/span.js +139 -0
- package/dist/tracing/span.js.map +1 -0
- package/dist/tracing/tracer.d.ts +11 -0
- package/dist/tracing/tracer.d.ts.map +1 -0
- package/dist/tracing/tracer.js +149 -0
- package/dist/tracing/tracer.js.map +1 -0
- package/dist/tracing/tracing.int.test.d.ts +5 -0
- package/dist/tracing/tracing.int.test.d.ts.map +1 -0
- package/dist/tracing/tracing.int.test.js +412 -0
- package/dist/tracing/tracing.int.test.js.map +1 -0
- package/dist/tracing/types.d.ts +175 -0
- package/dist/tracing/types.d.ts.map +1 -0
- package/dist/tracing/types.js +16 -0
- package/dist/tracing/types.js.map +1 -0
- package/dist/types/context.d.ts +96 -0
- package/dist/types/context.d.ts.map +1 -0
- package/dist/types/context.js +55 -0
- package/dist/types/context.js.map +1 -0
- package/dist/types/envelope.d.ts +57 -0
- package/dist/types/envelope.d.ts.map +1 -0
- package/dist/types/envelope.js +39 -0
- package/dist/types/envelope.js.map +1 -0
- package/dist/types/handlers.d.ts +142 -0
- package/dist/types/handlers.d.ts.map +1 -0
- package/dist/types/handlers.js +7 -0
- package/dist/types/handlers.js.map +1 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/stream.d.ts +69 -0
- package/dist/types/stream.d.ts.map +1 -0
- package/dist/types/stream.js +7 -0
- package/dist/types/stream.js.map +1 -0
- package/dist/ui/core/event-delivery.d.ts +38 -0
- package/dist/ui/core/event-delivery.d.ts.map +1 -0
- package/dist/ui/core/registry.d.ts +93 -0
- package/dist/ui/core/registry.d.ts.map +1 -0
- package/dist/ui/core/router.d.ts +70 -0
- package/dist/ui/core/router.d.ts.map +1 -0
- package/dist/ui/docs/openapi/generator.d.ts +164 -0
- package/dist/ui/docs/openapi/generator.d.ts.map +1 -0
- package/dist/ui/docs/openapi/index.d.ts +7 -0
- package/dist/ui/docs/openapi/index.d.ts.map +1 -0
- package/dist/ui/docs/ui/html-builder.d.ts +19 -0
- package/dist/ui/docs/ui/html-builder.d.ts.map +1 -0
- package/dist/ui/docs/ui/index.d.ts +8 -0
- package/dist/ui/docs/ui/index.d.ts.map +1 -0
- package/dist/ui/docs/ui/styles.d.ts +14 -0
- package/dist/ui/docs/ui/styles.d.ts.map +1 -0
- package/dist/ui/docs/ui/types.d.ts +68 -0
- package/dist/ui/docs/ui/types.d.ts.map +1 -0
- package/dist/ui/docs/ui/utils.d.ts +24 -0
- package/dist/ui/docs/ui/utils.d.ts.map +1 -0
- package/dist/ui/errors/codes.d.ts +239 -0
- package/dist/ui/errors/codes.d.ts.map +1 -0
- package/dist/ui/types/context.d.ts +96 -0
- package/dist/ui/types/context.d.ts.map +1 -0
- package/dist/ui/types/envelope.d.ts +57 -0
- package/dist/ui/types/envelope.d.ts.map +1 -0
- package/dist/ui/types/handlers.d.ts +142 -0
- package/dist/ui/types/handlers.d.ts.map +1 -0
- package/dist/ui/types/index.d.ts +7 -0
- package/dist/ui/types/index.d.ts.map +1 -0
- package/dist/ui/types/stream.d.ts +69 -0
- package/dist/ui/types/stream.d.ts.map +1 -0
- package/dist/ui/usd/builder/document.d.ts +190 -0
- package/dist/ui/usd/builder/document.d.ts.map +1 -0
- package/dist/ui/usd/builder/grpc.d.ts +119 -0
- package/dist/ui/usd/builder/grpc.d.ts.map +1 -0
- package/dist/ui/usd/builder/http.d.ts +131 -0
- package/dist/ui/usd/builder/http.d.ts.map +1 -0
- package/dist/ui/usd/builder/index.d.ts +15 -0
- package/dist/ui/usd/builder/index.d.ts.map +1 -0
- package/dist/ui/usd/builder/jsonrpc.d.ts +96 -0
- package/dist/ui/usd/builder/jsonrpc.d.ts.map +1 -0
- package/dist/ui/usd/builder/schema.d.ts +143 -0
- package/dist/ui/usd/builder/schema.d.ts.map +1 -0
- package/dist/ui/usd/builder/streams.d.ts +71 -0
- package/dist/ui/usd/builder/streams.d.ts.map +1 -0
- package/dist/ui/usd/builder/tcp.d.ts +61 -0
- package/dist/ui/usd/builder/tcp.d.ts.map +1 -0
- package/dist/ui/usd/builder/udp.d.ts +64 -0
- package/dist/ui/usd/builder/udp.d.ts.map +1 -0
- package/dist/ui/usd/builder/websocket.d.ts +131 -0
- package/dist/ui/usd/builder/websocket.d.ts.map +1 -0
- package/dist/ui/usd/export/index.d.ts +8 -0
- package/dist/ui/usd/export/index.d.ts.map +1 -0
- package/dist/ui/usd/export/openapi.d.ts +75 -0
- package/dist/ui/usd/export/openapi.d.ts.map +1 -0
- package/dist/ui/usd/index.d.ts +58 -0
- package/dist/ui/usd/index.d.ts.map +1 -0
- package/dist/ui/usd/parser/index.d.ts +93 -0
- package/dist/ui/usd/parser/index.d.ts.map +1 -0
- package/dist/ui/usd/parser/json.d.ts +34 -0
- package/dist/ui/usd/parser/json.d.ts.map +1 -0
- package/dist/ui/usd/parser/normalize.d.ts +20 -0
- package/dist/ui/usd/parser/normalize.d.ts.map +1 -0
- package/dist/ui/usd/parser/yaml.d.ts +41 -0
- package/dist/ui/usd/parser/yaml.d.ts.map +1 -0
- package/dist/ui/usd/spec/defaults.d.ts +121 -0
- package/dist/ui/usd/spec/defaults.d.ts.map +1 -0
- package/dist/ui/usd/spec/types.d.ts +704 -0
- package/dist/ui/usd/spec/types.d.ts.map +1 -0
- package/dist/ui/usd/utils/index.d.ts +6 -0
- package/dist/ui/usd/utils/index.d.ts.map +1 -0
- package/dist/ui/usd/utils/merge.d.ts +29 -0
- package/dist/ui/usd/utils/merge.d.ts.map +1 -0
- package/dist/ui/usd/utils/refs.d.ts +46 -0
- package/dist/ui/usd/utils/refs.d.ts.map +1 -0
- package/dist/ui/usd/validator/errors.d.ts +66 -0
- package/dist/ui/usd/validator/errors.d.ts.map +1 -0
- package/dist/ui/usd/validator/index.d.ts +68 -0
- package/dist/ui/usd/validator/index.d.ts.map +1 -0
- package/dist/ui/usd/validator/schema.d.ts +905 -0
- package/dist/ui/usd/validator/schema.d.ts.map +1 -0
- package/dist/ui/usd/validator/semantic.d.ts +15 -0
- package/dist/ui/usd/validator/semantic.d.ts.map +1 -0
- package/dist/ui/utils/id/alphabets.d.ts +68 -0
- package/dist/ui/utils/id/alphabets.d.ts.map +1 -0
- package/dist/ui/utils/id/entropy.d.ts +45 -0
- package/dist/ui/utils/id/entropy.d.ts.map +1 -0
- package/dist/ui/utils/id/index.d.ts +15 -0
- package/dist/ui/utils/id/index.d.ts.map +1 -0
- package/dist/ui/utils/id/sid.d.ts +86 -0
- package/dist/ui/utils/id/sid.d.ts.map +1 -0
- package/dist/ui/validation/adapters/ajv.d.ts +59 -0
- package/dist/ui/validation/adapters/ajv.d.ts.map +1 -0
- package/dist/ui/validation/adapters/fastest.d.ts +52 -0
- package/dist/ui/validation/adapters/fastest.d.ts.map +1 -0
- package/dist/ui/validation/adapters/index.d.ts +19 -0
- package/dist/ui/validation/adapters/index.d.ts.map +1 -0
- package/dist/ui/validation/adapters/joi.d.ts +51 -0
- package/dist/ui/validation/adapters/joi.d.ts.map +1 -0
- package/dist/ui/validation/adapters/yup.d.ts +53 -0
- package/dist/ui/validation/adapters/yup.d.ts.map +1 -0
- package/dist/ui/validation/adapters/zod.d.ts +52 -0
- package/dist/ui/validation/adapters/zod.d.ts.map +1 -0
- package/dist/ui/validation/index.d.ts +26 -0
- package/dist/ui/validation/index.d.ts.map +1 -0
- package/dist/ui/validation/schema.d.ts +150 -0
- package/dist/ui/validation/schema.d.ts.map +1 -0
- package/dist/ui/validation/types.d.ts +72 -0
- package/dist/ui/validation/types.d.ts.map +1 -0
- package/dist/usd/builder/document.d.ts +190 -0
- package/dist/usd/builder/document.d.ts.map +1 -0
- package/dist/usd/builder/document.js +418 -0
- package/dist/usd/builder/document.js.map +1 -0
- package/dist/usd/builder/grpc.d.ts +119 -0
- package/dist/usd/builder/grpc.d.ts.map +1 -0
- package/dist/usd/builder/grpc.js +220 -0
- package/dist/usd/builder/grpc.js.map +1 -0
- package/dist/usd/builder/http.d.ts +131 -0
- package/dist/usd/builder/http.d.ts.map +1 -0
- package/dist/usd/builder/http.js +248 -0
- package/dist/usd/builder/http.js.map +1 -0
- package/dist/usd/builder/index.d.ts +15 -0
- package/dist/usd/builder/index.d.ts.map +1 -0
- package/dist/usd/builder/index.js +18 -0
- package/dist/usd/builder/index.js.map +1 -0
- package/dist/usd/builder/jsonrpc.d.ts +96 -0
- package/dist/usd/builder/jsonrpc.d.ts.map +1 -0
- package/dist/usd/builder/jsonrpc.js +167 -0
- package/dist/usd/builder/jsonrpc.js.map +1 -0
- package/dist/usd/builder/schema.d.ts +143 -0
- package/dist/usd/builder/schema.d.ts.map +1 -0
- package/dist/usd/builder/schema.js +171 -0
- package/dist/usd/builder/schema.js.map +1 -0
- package/dist/usd/builder/streams.d.ts +71 -0
- package/dist/usd/builder/streams.d.ts.map +1 -0
- package/dist/usd/builder/streams.js +146 -0
- package/dist/usd/builder/streams.js.map +1 -0
- package/dist/usd/builder/tcp.d.ts +61 -0
- package/dist/usd/builder/tcp.d.ts.map +1 -0
- package/dist/usd/builder/tcp.js +150 -0
- package/dist/usd/builder/tcp.js.map +1 -0
- package/dist/usd/builder/udp.d.ts +64 -0
- package/dist/usd/builder/udp.d.ts.map +1 -0
- package/dist/usd/builder/udp.js +166 -0
- package/dist/usd/builder/udp.js.map +1 -0
- package/dist/usd/builder/websocket.d.ts +131 -0
- package/dist/usd/builder/websocket.d.ts.map +1 -0
- package/dist/usd/builder/websocket.js +218 -0
- package/dist/usd/builder/websocket.js.map +1 -0
- package/dist/usd/export/index.d.ts +8 -0
- package/dist/usd/export/index.d.ts.map +1 -0
- package/dist/usd/export/index.js +10 -0
- package/dist/usd/export/index.js.map +1 -0
- package/dist/usd/export/openapi.d.ts +75 -0
- package/dist/usd/export/openapi.d.ts.map +1 -0
- package/dist/usd/export/openapi.js +296 -0
- package/dist/usd/export/openapi.js.map +1 -0
- package/dist/usd/index.d.ts +58 -0
- package/dist/usd/index.d.ts.map +1 -0
- package/dist/usd/index.js +61 -0
- package/dist/usd/index.js.map +1 -0
- package/dist/usd/parser/index.d.ts +93 -0
- package/dist/usd/parser/index.d.ts.map +1 -0
- package/dist/usd/parser/index.js +137 -0
- package/dist/usd/parser/index.js.map +1 -0
- package/dist/usd/parser/json.d.ts +34 -0
- package/dist/usd/parser/json.d.ts.map +1 -0
- package/dist/usd/parser/json.js +68 -0
- package/dist/usd/parser/json.js.map +1 -0
- package/dist/usd/parser/normalize.d.ts +20 -0
- package/dist/usd/parser/normalize.d.ts.map +1 -0
- package/dist/usd/parser/normalize.js +271 -0
- package/dist/usd/parser/normalize.js.map +1 -0
- package/dist/usd/parser/yaml.d.ts +41 -0
- package/dist/usd/parser/yaml.d.ts.map +1 -0
- package/dist/usd/parser/yaml.js +66 -0
- package/dist/usd/parser/yaml.js.map +1 -0
- package/dist/usd/spec/defaults.d.ts +121 -0
- package/dist/usd/spec/defaults.d.ts.map +1 -0
- package/dist/usd/spec/defaults.js +204 -0
- package/dist/usd/spec/defaults.js.map +1 -0
- package/dist/usd/spec/index.d.ts +6 -0
- package/dist/usd/spec/index.d.ts.map +1 -0
- package/dist/usd/spec/index.js +6 -0
- package/dist/usd/spec/index.js.map +1 -0
- package/dist/usd/spec/types.d.ts +698 -0
- package/dist/usd/spec/types.d.ts.map +1 -0
- package/dist/usd/spec/types.js +33 -0
- package/dist/usd/spec/types.js.map +1 -0
- package/dist/usd/utils/index.d.ts +6 -0
- package/dist/usd/utils/index.d.ts.map +1 -0
- package/dist/usd/utils/index.js +6 -0
- package/dist/usd/utils/index.js.map +1 -0
- package/dist/usd/utils/merge.d.ts +29 -0
- package/dist/usd/utils/merge.d.ts.map +1 -0
- package/dist/usd/utils/merge.js +92 -0
- package/dist/usd/utils/merge.js.map +1 -0
- package/dist/usd/utils/refs.d.ts +46 -0
- package/dist/usd/utils/refs.d.ts.map +1 -0
- package/dist/usd/utils/refs.js +102 -0
- package/dist/usd/utils/refs.js.map +1 -0
- package/dist/usd/validator/errors.d.ts +66 -0
- package/dist/usd/validator/errors.d.ts.map +1 -0
- package/dist/usd/validator/errors.js +132 -0
- package/dist/usd/validator/errors.js.map +1 -0
- package/dist/usd/validator/index.d.ts +68 -0
- package/dist/usd/validator/index.d.ts.map +1 -0
- package/dist/usd/validator/index.js +92 -0
- package/dist/usd/validator/index.js.map +1 -0
- package/dist/usd/validator/schema.d.ts +905 -0
- package/dist/usd/validator/schema.d.ts.map +1 -0
- package/dist/usd/validator/schema.js +539 -0
- package/dist/usd/validator/schema.js.map +1 -0
- package/dist/usd/validator/semantic.d.ts +15 -0
- package/dist/usd/validator/semantic.d.ts.map +1 -0
- package/dist/usd/validator/semantic.js +452 -0
- package/dist/usd/validator/semantic.js.map +1 -0
- package/dist/utils/content-codecs.d.ts +14 -0
- package/dist/utils/content-codecs.d.ts.map +1 -0
- package/dist/utils/content-codecs.js +201 -0
- package/dist/utils/content-codecs.js.map +1 -0
- package/dist/utils/header-metadata.d.ts +6 -0
- package/dist/utils/header-metadata.d.ts.map +1 -0
- package/dist/utils/header-metadata.js +78 -0
- package/dist/utils/header-metadata.js.map +1 -0
- package/dist/utils/id/alphabets.d.ts +68 -0
- package/dist/utils/id/alphabets.d.ts.map +1 -0
- package/dist/utils/id/alphabets.js +90 -0
- package/dist/utils/id/alphabets.js.map +1 -0
- package/dist/utils/id/entropy.d.ts +45 -0
- package/dist/utils/id/entropy.d.ts.map +1 -0
- package/dist/utils/id/entropy.js +154 -0
- package/dist/utils/id/entropy.js.map +1 -0
- package/dist/utils/id/index.d.ts +15 -0
- package/dist/utils/id/index.d.ts.map +1 -0
- package/dist/utils/id/index.js +13 -0
- package/dist/utils/id/index.js.map +1 -0
- package/dist/utils/id/sid.d.ts +86 -0
- package/dist/utils/id/sid.d.ts.map +1 -0
- package/dist/utils/id/sid.js +109 -0
- package/dist/utils/id/sid.js.map +1 -0
- package/dist/utils/index.d.ts +7 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +8 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/logger.d.ts +15 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +36 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/validation/adapters/ajv.d.ts +59 -0
- package/dist/validation/adapters/ajv.d.ts.map +1 -0
- package/dist/validation/adapters/ajv.js +136 -0
- package/dist/validation/adapters/ajv.js.map +1 -0
- package/dist/validation/adapters/fastest.d.ts +52 -0
- package/dist/validation/adapters/fastest.d.ts.map +1 -0
- package/dist/validation/adapters/fastest.js +215 -0
- package/dist/validation/adapters/fastest.js.map +1 -0
- package/dist/validation/adapters/index.d.ts +19 -0
- package/dist/validation/adapters/index.d.ts.map +1 -0
- package/dist/validation/adapters/index.js +19 -0
- package/dist/validation/adapters/index.js.map +1 -0
- package/dist/validation/adapters/joi.d.ts +51 -0
- package/dist/validation/adapters/joi.d.ts.map +1 -0
- package/dist/validation/adapters/joi.js +267 -0
- package/dist/validation/adapters/joi.js.map +1 -0
- package/dist/validation/adapters/yup.d.ts +53 -0
- package/dist/validation/adapters/yup.d.ts.map +1 -0
- package/dist/validation/adapters/yup.js +267 -0
- package/dist/validation/adapters/yup.js.map +1 -0
- package/dist/validation/adapters/zod.d.ts +52 -0
- package/dist/validation/adapters/zod.d.ts.map +1 -0
- package/dist/validation/adapters/zod.js +107 -0
- package/dist/validation/adapters/zod.js.map +1 -0
- package/dist/validation/index.d.ts +26 -0
- package/dist/validation/index.d.ts.map +1 -0
- package/dist/validation/index.js +48 -0
- package/dist/validation/index.js.map +1 -0
- package/dist/validation/multi-validator.int.test.d.ts +7 -0
- package/dist/validation/multi-validator.int.test.d.ts.map +1 -0
- package/dist/validation/multi-validator.int.test.js +808 -0
- package/dist/validation/multi-validator.int.test.js.map +1 -0
- package/dist/validation/schema.d.ts +150 -0
- package/dist/validation/schema.d.ts.map +1 -0
- package/dist/validation/schema.int.test.d.ts +5 -0
- package/dist/validation/schema.int.test.d.ts.map +1 -0
- package/dist/validation/schema.int.test.js +340 -0
- package/dist/validation/schema.int.test.js.map +1 -0
- package/dist/validation/schema.js +271 -0
- package/dist/validation/schema.js.map +1 -0
- package/dist/validation/types.d.ts +72 -0
- package/dist/validation/types.d.ts.map +1 -0
- package/dist/validation/types.js +14 -0
- package/dist/validation/types.js.map +1 -0
- package/package.json +222 -0
|
@@ -0,0 +1,2160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server Builder Types
|
|
3
|
+
*
|
|
4
|
+
* Type definitions for the unified server API.
|
|
5
|
+
*/
|
|
6
|
+
import type { z } from 'zod';
|
|
7
|
+
import type { IncomingMessage, Server } from 'node:http';
|
|
8
|
+
import type { WebSocketServer } from 'ws';
|
|
9
|
+
import type { Server as NetServer } from 'node:net';
|
|
10
|
+
import type { Options as ProtoLoaderOptions } from '@grpc/proto-loader';
|
|
11
|
+
import type { Registry } from '../core/registry.js';
|
|
12
|
+
import type { Router } from '../core/router.js';
|
|
13
|
+
import type { Context, Interceptor, ProcedureHandler, StreamHandler, EventHandler, JsonRpcMeta, GrpcMeta, HttpMethod, StreamDirection, RetryPolicy } from '../types/index.js';
|
|
14
|
+
import type { EventDeliveryOptions } from '../core/event-delivery.js';
|
|
15
|
+
import type { ChannelOptions, ChannelManager } from '../channels/index.js';
|
|
16
|
+
import type { HttpMiddleware } from '../adapters/http.js';
|
|
17
|
+
import type { DiscoveryConfig, DiscoveryWatcher, LoadedRoute, LoadedChannel, LoadedRestResource, LoadedResource, LoadedTcpHandler, LoadedUdpHandler } from './fs-routes/index.js';
|
|
18
|
+
import type { DiscoveryResult } from './fs-routes/loader.js';
|
|
19
|
+
import type { GraphQLOptions, GraphQLAdapter } from '../graphql/index.js';
|
|
20
|
+
import type { MetricsConfig, MetricRegistry } from '../metrics/index.js';
|
|
21
|
+
import type { TracingConfig, Tracer } from '../tracing/index.js';
|
|
22
|
+
import type { Codec } from '../utils/content-codecs.js';
|
|
23
|
+
import type { USDDocument, USDProtocol, USDTag, USDExternalDocs, USDServer, USDSecurityScheme } from '../usd/index.js';
|
|
24
|
+
import type { OpenAPIDocument } from '../usd/export/openapi.js';
|
|
25
|
+
/**
|
|
26
|
+
* Provider factory function.
|
|
27
|
+
* Called once at server startup to create the singleton instance.
|
|
28
|
+
*/
|
|
29
|
+
export type ProviderFactory<T> = () => T | Promise<T>;
|
|
30
|
+
/**
|
|
31
|
+
* Provider definition with optional lifecycle hooks.
|
|
32
|
+
*/
|
|
33
|
+
export interface ProviderDefinition<T = unknown> {
|
|
34
|
+
/** Factory function to create the provider instance */
|
|
35
|
+
factory: ProviderFactory<T>;
|
|
36
|
+
/** Called on server shutdown */
|
|
37
|
+
onShutdown?: (instance: T) => void | Promise<void>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Map of provider names to their definitions or factory functions.
|
|
41
|
+
*/
|
|
42
|
+
export type ProvidersConfig = Record<string, ProviderFactory<unknown> | ProviderDefinition<unknown>>;
|
|
43
|
+
/**
|
|
44
|
+
* Resolved provider instances (after initialization).
|
|
45
|
+
*/
|
|
46
|
+
export type ResolvedProviders = Record<string, unknown>;
|
|
47
|
+
/**
|
|
48
|
+
* Protocol identifier for error context
|
|
49
|
+
*/
|
|
50
|
+
export type ErrorProtocol = 'http' | 'websocket' | 'jsonrpc' | 'grpc' | 'streams' | 'tcp' | 'udp' | 'graphql';
|
|
51
|
+
/**
|
|
52
|
+
* Normalized error information for cross-protocol consistency
|
|
53
|
+
*/
|
|
54
|
+
export interface NormalizedError {
|
|
55
|
+
/** String error code (e.g., 'NOT_FOUND', 'VALIDATION_ERROR') */
|
|
56
|
+
code: string;
|
|
57
|
+
/** Numeric status (HTTP-compatible) */
|
|
58
|
+
status: number;
|
|
59
|
+
/** Human-readable error message */
|
|
60
|
+
message: string;
|
|
61
|
+
/** Additional error details */
|
|
62
|
+
details?: unknown;
|
|
63
|
+
/** Original error */
|
|
64
|
+
cause?: Error;
|
|
65
|
+
/** Stack trace (only in development) */
|
|
66
|
+
stack?: string;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Global error handler function type
|
|
70
|
+
*
|
|
71
|
+
* @param error - The original error (may be RaffelError, HttpError, or plain Error)
|
|
72
|
+
* @param protocol - The protocol where the error occurred
|
|
73
|
+
* @param ctx - Request context (if available)
|
|
74
|
+
*/
|
|
75
|
+
export type GlobalErrorHandler = (error: Error, protocol: ErrorProtocol, ctx?: Context) => void | Promise<void>;
|
|
76
|
+
export interface ServerOptions {
|
|
77
|
+
/** Port to listen on (HTTP) */
|
|
78
|
+
port: number;
|
|
79
|
+
/** Host to bind to (default: '0.0.0.0') */
|
|
80
|
+
host?: string;
|
|
81
|
+
/** Base path for HTTP procedures (default: '/') */
|
|
82
|
+
basePath?: string;
|
|
83
|
+
/** CORS configuration (default: enabled with '*') */
|
|
84
|
+
cors?: CorsOptions | boolean;
|
|
85
|
+
/** HTTP adapter options */
|
|
86
|
+
http?: HttpOptions;
|
|
87
|
+
/**
|
|
88
|
+
* WebSocket configuration.
|
|
89
|
+
* - `true` enables with defaults (path: '/')
|
|
90
|
+
* - Object for custom configuration
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```typescript
|
|
94
|
+
* // Quick enable
|
|
95
|
+
* websocket: true
|
|
96
|
+
*
|
|
97
|
+
* // With channels
|
|
98
|
+
* websocket: {
|
|
99
|
+
* path: '/ws',
|
|
100
|
+
* channels: {
|
|
101
|
+
* authorize: async (socketId, channel, ctx) => ctx.auth?.authenticated ?? false,
|
|
102
|
+
* presenceData: (socketId, channel, ctx) => ({ userId: ctx.auth?.principal }),
|
|
103
|
+
* }
|
|
104
|
+
* }
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
websocket?: WebSocketOptions | boolean;
|
|
108
|
+
/**
|
|
109
|
+
* JSON-RPC configuration.
|
|
110
|
+
* - `true` enables with defaults (path: '/rpc')
|
|
111
|
+
* - Object for custom configuration
|
|
112
|
+
*/
|
|
113
|
+
jsonrpc?: JsonRpcOptions | boolean;
|
|
114
|
+
/**
|
|
115
|
+
* TCP configuration (always requires separate port).
|
|
116
|
+
*/
|
|
117
|
+
tcp?: TcpOptions;
|
|
118
|
+
/**
|
|
119
|
+
* GraphQL configuration.
|
|
120
|
+
* - `true` enables with defaults (path: '/graphql', auto-generate schema)
|
|
121
|
+
* - Object for custom configuration
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* ```typescript
|
|
125
|
+
* // Quick enable
|
|
126
|
+
* graphql: true
|
|
127
|
+
*
|
|
128
|
+
* // With configuration
|
|
129
|
+
* graphql: {
|
|
130
|
+
* path: '/graphql',
|
|
131
|
+
* playground: true,
|
|
132
|
+
* subscriptions: true,
|
|
133
|
+
* schemaOptions: {
|
|
134
|
+
* procedureMapping: 'prefix', // get*, list* → Query, others → Mutation
|
|
135
|
+
* },
|
|
136
|
+
* }
|
|
137
|
+
* ```
|
|
138
|
+
*/
|
|
139
|
+
graphql?: GraphQLOptions | boolean;
|
|
140
|
+
/**
|
|
141
|
+
* Global middleware applied to all handlers.
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* ```typescript
|
|
145
|
+
* middleware: [
|
|
146
|
+
* createAuthMiddleware({ ... }),
|
|
147
|
+
* createLoggingMiddleware(),
|
|
148
|
+
* createRateLimitInterceptor({ ... }),
|
|
149
|
+
* ]
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
middleware?: Interceptor[];
|
|
153
|
+
/**
|
|
154
|
+
* Auto-discover handlers from file system (Next.js-style).
|
|
155
|
+
* - `true` enables all defaults (./src/http, ./src/channels, ./src/rpc, ./src/streams, ./src/rest, ./src/resources, ./src/tcp, ./src/udp)
|
|
156
|
+
* - Object for custom configuration
|
|
157
|
+
*
|
|
158
|
+
* This is separate from manual route definition (via `.procedure()`, `.stream()`, `.mount()`)
|
|
159
|
+
* which can be used alongside or instead of discovery.
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* ```typescript
|
|
163
|
+
* // Quick enable all
|
|
164
|
+
* discovery: true
|
|
165
|
+
*
|
|
166
|
+
* // Custom paths
|
|
167
|
+
* discovery: {
|
|
168
|
+
* http: './src/api',
|
|
169
|
+
* channels: './src/realtime',
|
|
170
|
+
* rpc: './src/rpc',
|
|
171
|
+
* streams: './src/streams',
|
|
172
|
+
* rest: './src/rest',
|
|
173
|
+
* resources: './src/resources',
|
|
174
|
+
* tcp: './src/tcp',
|
|
175
|
+
* udp: './src/udp',
|
|
176
|
+
* }
|
|
177
|
+
*
|
|
178
|
+
* // Only HTTP and RPC
|
|
179
|
+
* discovery: {
|
|
180
|
+
* http: true,
|
|
181
|
+
* rpc: './api/rpc',
|
|
182
|
+
* }
|
|
183
|
+
* ```
|
|
184
|
+
*/
|
|
185
|
+
discovery?: DiscoveryConfig | boolean;
|
|
186
|
+
/**
|
|
187
|
+
* Enable hot reload for discovered handlers in development.
|
|
188
|
+
* @default true in development, false in production
|
|
189
|
+
*/
|
|
190
|
+
hotReload?: boolean;
|
|
191
|
+
/**
|
|
192
|
+
* Providers are singletons injected into the context of all handlers.
|
|
193
|
+
* Use this to share database clients, services, configs, etc.
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* ```typescript
|
|
197
|
+
* import { PrismaClient } from '@prisma/client'
|
|
198
|
+
* import { S3DB } from 's3db.js'
|
|
199
|
+
*
|
|
200
|
+
* const server = createServer({
|
|
201
|
+
* port: 3000,
|
|
202
|
+
* providers: {
|
|
203
|
+
* db: () => new PrismaClient(),
|
|
204
|
+
* s3db: () => new S3DB({ bucket: 'my-bucket' }),
|
|
205
|
+
* config: () => ({
|
|
206
|
+
* apiKey: process.env.API_KEY,
|
|
207
|
+
* environment: process.env.NODE_ENV,
|
|
208
|
+
* }),
|
|
209
|
+
* },
|
|
210
|
+
* })
|
|
211
|
+
*
|
|
212
|
+
* // In handlers (including discovered routes):
|
|
213
|
+
* server.procedure('users.get').handler(async (input, ctx) => {
|
|
214
|
+
* return ctx.db.user.findUnique({ where: { id: input.id } })
|
|
215
|
+
* })
|
|
216
|
+
* ```
|
|
217
|
+
*/
|
|
218
|
+
providers?: ProvidersConfig;
|
|
219
|
+
/** Event delivery configuration (for at-least-once/at-most-once) */
|
|
220
|
+
eventDelivery?: EventDeliveryOptions;
|
|
221
|
+
/**
|
|
222
|
+
* Global error handler for all protocols.
|
|
223
|
+
* Called when an error occurs in any handler (HTTP, WebSocket, Streams, JSON-RPC, etc.).
|
|
224
|
+
*
|
|
225
|
+
* @example
|
|
226
|
+
* ```typescript
|
|
227
|
+
* const server = createServer({
|
|
228
|
+
* port: 3000,
|
|
229
|
+
* onError: (error, protocol, ctx) => {
|
|
230
|
+
* console.error(`[${protocol}] Error:`, error.message)
|
|
231
|
+
* // Report to error tracking service
|
|
232
|
+
* errorTracker.captureException(error, { protocol, requestId: ctx?.requestId })
|
|
233
|
+
* },
|
|
234
|
+
* })
|
|
235
|
+
* ```
|
|
236
|
+
*/
|
|
237
|
+
onError?: GlobalErrorHandler;
|
|
238
|
+
}
|
|
239
|
+
export interface CorsOptions {
|
|
240
|
+
/** Allowed origins (default: '*') */
|
|
241
|
+
origin?: string | string[] | boolean;
|
|
242
|
+
/** Allowed HTTP methods */
|
|
243
|
+
methods?: string[];
|
|
244
|
+
/** Allowed headers */
|
|
245
|
+
headers?: string[];
|
|
246
|
+
/** Whether to allow credentials */
|
|
247
|
+
credentials?: boolean;
|
|
248
|
+
}
|
|
249
|
+
export interface HttpOptions {
|
|
250
|
+
/** Maximum request body size in bytes (default: 1MB) */
|
|
251
|
+
maxBodySize?: number;
|
|
252
|
+
/** Additional codecs for content negotiation */
|
|
253
|
+
codecs?: Codec[];
|
|
254
|
+
/**
|
|
255
|
+
* HTTP middleware to run before routing.
|
|
256
|
+
* Middleware that returns true indicates it handled the request.
|
|
257
|
+
*/
|
|
258
|
+
middleware?: HttpMiddleware[];
|
|
259
|
+
/** Context factory for creating request context */
|
|
260
|
+
contextFactory?: (req: IncomingMessage) => Partial<Context>;
|
|
261
|
+
}
|
|
262
|
+
export interface WebSocketOptions {
|
|
263
|
+
/** Port (if omitted, shares HTTP port via upgrade) */
|
|
264
|
+
port?: number;
|
|
265
|
+
/** WebSocket path (default: '/') */
|
|
266
|
+
path?: string;
|
|
267
|
+
/** Max payload size in bytes (default: 1MB) */
|
|
268
|
+
maxPayloadSize?: number;
|
|
269
|
+
/** Heartbeat interval in ms (default: 30000, 0 to disable) */
|
|
270
|
+
heartbeatInterval?: number;
|
|
271
|
+
/**
|
|
272
|
+
* Enable Pusher-like channels for real-time pub/sub.
|
|
273
|
+
*
|
|
274
|
+
* @example
|
|
275
|
+
* ```typescript
|
|
276
|
+
* channels: {
|
|
277
|
+
* authorize: async (socketId, channel, ctx) => {
|
|
278
|
+
* if (channel.startsWith('private-') || channel.startsWith('presence-')) {
|
|
279
|
+
* return ctx.auth?.authenticated ?? false
|
|
280
|
+
* }
|
|
281
|
+
* return true
|
|
282
|
+
* },
|
|
283
|
+
* presenceData: (socketId, channel, ctx) => ({
|
|
284
|
+
* userId: ctx.auth?.principal,
|
|
285
|
+
* name: ctx.auth?.claims?.name,
|
|
286
|
+
* }),
|
|
287
|
+
* }
|
|
288
|
+
* ```
|
|
289
|
+
*/
|
|
290
|
+
channels?: ChannelOptions;
|
|
291
|
+
/**
|
|
292
|
+
* Context factory for creating auth context from WebSocket connection.
|
|
293
|
+
* Called once per connection to establish the connection context.
|
|
294
|
+
*
|
|
295
|
+
* @example
|
|
296
|
+
* ```typescript
|
|
297
|
+
* contextFactory: (ws, req) => {
|
|
298
|
+
* const url = new URL(req.url, 'http://localhost')
|
|
299
|
+
* const token = url.searchParams.get('token')
|
|
300
|
+
* return {
|
|
301
|
+
* auth: token ? { authenticated: true, principal: token } : undefined,
|
|
302
|
+
* }
|
|
303
|
+
* }
|
|
304
|
+
* ```
|
|
305
|
+
*/
|
|
306
|
+
contextFactory?: (ws: import('ws').WebSocket, req: import('http').IncomingMessage) => Partial<Context>;
|
|
307
|
+
}
|
|
308
|
+
export interface JsonRpcOptions {
|
|
309
|
+
/** Port (if omitted, shares HTTP port) */
|
|
310
|
+
port?: number;
|
|
311
|
+
/** JSON-RPC endpoint path (default: '/rpc') */
|
|
312
|
+
path?: string;
|
|
313
|
+
/** Request timeout in ms (default: 30000) */
|
|
314
|
+
timeout?: number;
|
|
315
|
+
/** Max body size in bytes (default: 1MB) */
|
|
316
|
+
maxBodySize?: number;
|
|
317
|
+
/** Additional codecs for content negotiation */
|
|
318
|
+
codecs?: Codec[];
|
|
319
|
+
}
|
|
320
|
+
export interface TcpOptions {
|
|
321
|
+
/** Port (required - TCP always needs separate port) */
|
|
322
|
+
port: number;
|
|
323
|
+
/** Host to bind to (default: '0.0.0.0') */
|
|
324
|
+
host?: string;
|
|
325
|
+
/** Max message size in bytes (default: 16MB) */
|
|
326
|
+
maxMessageSize?: number;
|
|
327
|
+
/** Keep-alive interval in ms (default: 30000, 0 to disable) */
|
|
328
|
+
keepAliveInterval?: number;
|
|
329
|
+
}
|
|
330
|
+
export interface GrpcTlsOptions {
|
|
331
|
+
/** Server private key */
|
|
332
|
+
key: string | Buffer;
|
|
333
|
+
/** Server certificate chain */
|
|
334
|
+
cert: string | Buffer;
|
|
335
|
+
/** Root CA certificates (optional) */
|
|
336
|
+
ca?: string | Buffer;
|
|
337
|
+
/** Require client certificate */
|
|
338
|
+
requireClientCert?: boolean;
|
|
339
|
+
}
|
|
340
|
+
export interface GrpcOptions {
|
|
341
|
+
/** Port to listen on */
|
|
342
|
+
port: number;
|
|
343
|
+
/** Host to bind to (default: '0.0.0.0') */
|
|
344
|
+
host?: string;
|
|
345
|
+
/** Proto file path(s) */
|
|
346
|
+
protoPath: string | string[];
|
|
347
|
+
/** Package name to scope services (optional) */
|
|
348
|
+
packageName?: string;
|
|
349
|
+
/** Service names to register (optional) */
|
|
350
|
+
serviceNames?: string[];
|
|
351
|
+
/** Proto loader options */
|
|
352
|
+
loaderOptions?: ProtoLoaderOptions;
|
|
353
|
+
/** TLS credentials */
|
|
354
|
+
tls?: GrpcTlsOptions;
|
|
355
|
+
/** Max receive message length in bytes */
|
|
356
|
+
maxReceiveMessageLength?: number;
|
|
357
|
+
/** Max send message length in bytes */
|
|
358
|
+
maxSendMessageLength?: number;
|
|
359
|
+
}
|
|
360
|
+
export interface AddressInfo {
|
|
361
|
+
host: string;
|
|
362
|
+
port: number;
|
|
363
|
+
}
|
|
364
|
+
export interface ServerAddresses {
|
|
365
|
+
http: AddressInfo;
|
|
366
|
+
websocket?: AddressInfo & {
|
|
367
|
+
path: string;
|
|
368
|
+
shared: boolean;
|
|
369
|
+
};
|
|
370
|
+
jsonrpc?: AddressInfo & {
|
|
371
|
+
path: string;
|
|
372
|
+
shared: boolean;
|
|
373
|
+
};
|
|
374
|
+
graphql?: AddressInfo & {
|
|
375
|
+
path: string;
|
|
376
|
+
shared: boolean;
|
|
377
|
+
};
|
|
378
|
+
grpc?: AddressInfo;
|
|
379
|
+
tcp?: AddressInfo;
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* Before hook - runs before the handler.
|
|
383
|
+
* Can modify context extensions. Throwing prevents handler execution.
|
|
384
|
+
*/
|
|
385
|
+
export type BeforeHook<TInput = unknown> = (input: TInput, ctx: Context) => void | Promise<void>;
|
|
386
|
+
/**
|
|
387
|
+
* After hook - runs after the handler.
|
|
388
|
+
* Receives and can transform the result.
|
|
389
|
+
*/
|
|
390
|
+
export type AfterHook<TInput = unknown, TOutput = unknown> = (input: TInput, ctx: Context, result: TOutput) => TOutput | Promise<TOutput>;
|
|
391
|
+
/**
|
|
392
|
+
* Error hook - runs when an error occurs.
|
|
393
|
+
* Can swallow errors (by returning a value), transform them, or re-throw.
|
|
394
|
+
*/
|
|
395
|
+
export type ErrorHook<TInput = unknown> = (input: TInput, ctx: Context, error: Error) => unknown | Promise<unknown>;
|
|
396
|
+
/**
|
|
397
|
+
* Global hooks configuration with pattern matching.
|
|
398
|
+
*/
|
|
399
|
+
export interface GlobalHooksConfig {
|
|
400
|
+
/** Before hooks by pattern (e.g., '*', 'users.*') */
|
|
401
|
+
before?: Record<string, BeforeHook<any> | BeforeHook<any>[]>;
|
|
402
|
+
/** After hooks by pattern */
|
|
403
|
+
after?: Record<string, AfterHook<any, any> | AfterHook<any, any>[]>;
|
|
404
|
+
/** Error hooks by pattern */
|
|
405
|
+
error?: Record<string, ErrorHook<any> | ErrorHook<any>[]>;
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* HTTP route handler function.
|
|
409
|
+
* Similar to ProcedureHandler but with Response return support.
|
|
410
|
+
*/
|
|
411
|
+
export type HttpRouteHandler<TInput = unknown, TOutput = unknown> = (input: TInput, ctx: Context) => TOutput | Promise<TOutput> | Response | Promise<Response>;
|
|
412
|
+
/**
|
|
413
|
+
* Options for HTTP route registration.
|
|
414
|
+
* Generics allow type inference from input/output schemas.
|
|
415
|
+
*/
|
|
416
|
+
export interface HttpRouteOptions<TInput = unknown, TOutput = unknown> {
|
|
417
|
+
/** Input schema (Zod) - for GET: query params, for others: body */
|
|
418
|
+
input?: z.ZodType<TInput>;
|
|
419
|
+
/** Output schema (Zod) */
|
|
420
|
+
output?: z.ZodType<TOutput>;
|
|
421
|
+
/** Short summary for documentation */
|
|
422
|
+
summary?: string;
|
|
423
|
+
/** Detailed description (supports markdown) */
|
|
424
|
+
description?: string;
|
|
425
|
+
/** Tags for documentation grouping */
|
|
426
|
+
tags?: string[];
|
|
427
|
+
/** Middleware interceptors */
|
|
428
|
+
use?: Interceptor[];
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Helper type to infer input type from HttpRouteOptions
|
|
432
|
+
*/
|
|
433
|
+
export type InferHttpInput<T> = T extends HttpRouteOptions<infer I, unknown> ? I : unknown;
|
|
434
|
+
/**
|
|
435
|
+
* Helper type to infer output type from HttpRouteOptions
|
|
436
|
+
*/
|
|
437
|
+
export type InferHttpOutput<T> = T extends HttpRouteOptions<unknown, infer O> ? O : unknown;
|
|
438
|
+
/**
|
|
439
|
+
* HTTP protocol namespace for Hono-style routes.
|
|
440
|
+
* Provides organized access to HTTP route registration methods with full type inference.
|
|
441
|
+
*
|
|
442
|
+
* @example
|
|
443
|
+
* ```typescript
|
|
444
|
+
* // Type inference from schema
|
|
445
|
+
* server.http
|
|
446
|
+
* .get('/users', handler)
|
|
447
|
+
* .post('/users', { input: z.object({ name: z.string() }) }, (input, ctx) => {
|
|
448
|
+
* // input is typed as { name: string }
|
|
449
|
+
* return { id: '1', name: input.name }
|
|
450
|
+
* })
|
|
451
|
+
* ```
|
|
452
|
+
*/
|
|
453
|
+
export interface HttpNamespace {
|
|
454
|
+
/** Register an HTTP GET route */
|
|
455
|
+
get(path: string, handler: HttpRouteHandler): HttpNamespace;
|
|
456
|
+
/** Register an HTTP GET route with typed options */
|
|
457
|
+
get<TIn, TOut>(path: string, options: HttpRouteOptions<TIn, TOut>, handler: HttpRouteHandler<TIn, TOut>): HttpNamespace;
|
|
458
|
+
/** Register an HTTP POST route */
|
|
459
|
+
post(path: string, handler: HttpRouteHandler): HttpNamespace;
|
|
460
|
+
/** Register an HTTP POST route with typed options */
|
|
461
|
+
post<TIn, TOut>(path: string, options: HttpRouteOptions<TIn, TOut>, handler: HttpRouteHandler<TIn, TOut>): HttpNamespace;
|
|
462
|
+
/** Register an HTTP PUT route */
|
|
463
|
+
put(path: string, handler: HttpRouteHandler): HttpNamespace;
|
|
464
|
+
/** Register an HTTP PUT route with typed options */
|
|
465
|
+
put<TIn, TOut>(path: string, options: HttpRouteOptions<TIn, TOut>, handler: HttpRouteHandler<TIn, TOut>): HttpNamespace;
|
|
466
|
+
/** Register an HTTP PATCH route */
|
|
467
|
+
patch(path: string, handler: HttpRouteHandler): HttpNamespace;
|
|
468
|
+
/** Register an HTTP PATCH route with typed options */
|
|
469
|
+
patch<TIn, TOut>(path: string, options: HttpRouteOptions<TIn, TOut>, handler: HttpRouteHandler<TIn, TOut>): HttpNamespace;
|
|
470
|
+
/** Register an HTTP DELETE route */
|
|
471
|
+
delete(path: string, handler: HttpRouteHandler): HttpNamespace;
|
|
472
|
+
/** Register an HTTP DELETE route with typed options */
|
|
473
|
+
delete<TIn, TOut>(path: string, options: HttpRouteOptions<TIn, TOut>, handler: HttpRouteHandler<TIn, TOut>): HttpNamespace;
|
|
474
|
+
/** Register an HTTP OPTIONS route */
|
|
475
|
+
options(path: string, handler: HttpRouteHandler): HttpNamespace;
|
|
476
|
+
/** Register an HTTP OPTIONS route with typed options */
|
|
477
|
+
options<TIn, TOut>(path: string, options: HttpRouteOptions<TIn, TOut>, handler: HttpRouteHandler<TIn, TOut>): HttpNamespace;
|
|
478
|
+
/** Register an HTTP HEAD route */
|
|
479
|
+
head(path: string, handler: HttpRouteHandler): HttpNamespace;
|
|
480
|
+
/** Register an HTTP HEAD route with typed options */
|
|
481
|
+
head<TIn, TOut>(path: string, options: HttpRouteOptions<TIn, TOut>, handler: HttpRouteHandler<TIn, TOut>): HttpNamespace;
|
|
482
|
+
/** Add middleware to all routes in this namespace */
|
|
483
|
+
use(interceptor: Interceptor): HttpNamespace;
|
|
484
|
+
}
|
|
485
|
+
/**
|
|
486
|
+
* WebSocket protocol namespace for pub/sub channels.
|
|
487
|
+
*
|
|
488
|
+
* @example
|
|
489
|
+
* ```typescript
|
|
490
|
+
* server.ws
|
|
491
|
+
* .channel('chat-room', { type: 'public' })
|
|
492
|
+
* .channel('user-updates', { type: 'private' })
|
|
493
|
+
* .onSubscribe((channel, ctx) => { ... })
|
|
494
|
+
* ```
|
|
495
|
+
*/
|
|
496
|
+
export interface WebSocketNamespace {
|
|
497
|
+
/** Define a WebSocket channel */
|
|
498
|
+
channel(name: string, options?: WebSocketChannelOptions): WebSocketNamespace;
|
|
499
|
+
/** Handle channel subscription */
|
|
500
|
+
onSubscribe(handler: WebSocketSubscribeHandler): WebSocketNamespace;
|
|
501
|
+
/** Handle incoming messages */
|
|
502
|
+
onMessage(handler: WebSocketMessageHandler): WebSocketNamespace;
|
|
503
|
+
/** Handle unsubscription */
|
|
504
|
+
onUnsubscribe(handler: WebSocketUnsubscribeHandler): WebSocketNamespace;
|
|
505
|
+
/** Add middleware to all WebSocket handlers */
|
|
506
|
+
use(interceptor: Interceptor): WebSocketNamespace;
|
|
507
|
+
}
|
|
508
|
+
/**
|
|
509
|
+
* WebSocket channel configuration options.
|
|
510
|
+
*/
|
|
511
|
+
export interface WebSocketChannelOptions {
|
|
512
|
+
/** Channel type: public (no auth), private (requires auth), presence (shows members) */
|
|
513
|
+
type?: 'public' | 'private' | 'presence';
|
|
514
|
+
/** Description for documentation */
|
|
515
|
+
description?: string;
|
|
516
|
+
/** Tags for documentation grouping */
|
|
517
|
+
tags?: string[];
|
|
518
|
+
/** Custom authorization function */
|
|
519
|
+
authorize?: (ctx: Context) => boolean | Promise<boolean>;
|
|
520
|
+
}
|
|
521
|
+
/** WebSocket subscribe event handler */
|
|
522
|
+
export type WebSocketSubscribeHandler = (channel: string, ctx: Context) => void | Promise<void>;
|
|
523
|
+
/** WebSocket message event handler */
|
|
524
|
+
export type WebSocketMessageHandler = (channel: string, event: string, data: unknown, ctx: Context) => void | Promise<void>;
|
|
525
|
+
/** WebSocket unsubscribe event handler */
|
|
526
|
+
export type WebSocketUnsubscribeHandler = (channel: string, ctx: Context) => void | Promise<void>;
|
|
527
|
+
/**
|
|
528
|
+
* Streams protocol namespace for SSE/EventSource.
|
|
529
|
+
*
|
|
530
|
+
* @example
|
|
531
|
+
* ```typescript
|
|
532
|
+
* server.streams
|
|
533
|
+
* .source('events', async function*(ctx) {
|
|
534
|
+
* while (true) {
|
|
535
|
+
* yield { event: 'tick', data: { time: Date.now() } }
|
|
536
|
+
* await delay(1000)
|
|
537
|
+
* }
|
|
538
|
+
* })
|
|
539
|
+
* ```
|
|
540
|
+
*/
|
|
541
|
+
export interface StreamsNamespace {
|
|
542
|
+
/** Define a server-to-client stream (SSE source) */
|
|
543
|
+
source(name: string, handler: StreamSourceHandler): StreamsNamespace;
|
|
544
|
+
/** Define a server-to-client stream with typed options */
|
|
545
|
+
source<TOut>(name: string, options: StreamOptions<unknown, TOut>, handler: StreamSourceHandler<TOut>): StreamsNamespace;
|
|
546
|
+
/** Define a client-to-server stream (upload sink) */
|
|
547
|
+
sink(name: string, handler: StreamSinkHandler): StreamsNamespace;
|
|
548
|
+
/** Define a client-to-server stream with typed options */
|
|
549
|
+
sink<TIn>(name: string, options: StreamOptions<TIn>, handler: StreamSinkHandler<TIn>): StreamsNamespace;
|
|
550
|
+
/** Define a bidirectional stream */
|
|
551
|
+
duplex(name: string, handler: StreamDuplexHandler): StreamsNamespace;
|
|
552
|
+
/** Define a bidirectional stream with typed options */
|
|
553
|
+
duplex<TIn, TOut>(name: string, options: StreamOptions<TIn, TOut>, handler: StreamDuplexHandler<TIn, TOut>): StreamsNamespace;
|
|
554
|
+
/** Add middleware to all stream handlers */
|
|
555
|
+
use(interceptor: Interceptor): StreamsNamespace;
|
|
556
|
+
}
|
|
557
|
+
/**
|
|
558
|
+
* Stream configuration options.
|
|
559
|
+
* Generics allow type inference for input params and output chunks.
|
|
560
|
+
*/
|
|
561
|
+
export interface StreamOptions<TInput = unknown, TOutput = unknown> {
|
|
562
|
+
/** HTTP path for the stream endpoint */
|
|
563
|
+
path?: string;
|
|
564
|
+
/** Description for documentation */
|
|
565
|
+
description?: string;
|
|
566
|
+
/** Tags for documentation grouping */
|
|
567
|
+
tags?: string[];
|
|
568
|
+
/** Input schema for stream parameters */
|
|
569
|
+
input?: z.ZodType<TInput>;
|
|
570
|
+
/** Output schema for stream chunks (for documentation) */
|
|
571
|
+
output?: z.ZodType<TOutput>;
|
|
572
|
+
}
|
|
573
|
+
/** Stream source handler (server → client) with typed output */
|
|
574
|
+
export type StreamSourceHandler<TOutput = unknown> = (ctx: Context) => AsyncIterable<{
|
|
575
|
+
event?: string;
|
|
576
|
+
data: TOutput;
|
|
577
|
+
}> | Promise<AsyncIterable<{
|
|
578
|
+
event?: string;
|
|
579
|
+
data: TOutput;
|
|
580
|
+
}>>;
|
|
581
|
+
/** Stream sink handler (client → server) with typed input */
|
|
582
|
+
export type StreamSinkHandler<TInput = unknown> = (stream: AsyncIterable<TInput>, ctx: Context) => void | Promise<void>;
|
|
583
|
+
/** Stream duplex handler (bidirectional) with typed input/output */
|
|
584
|
+
export type StreamDuplexHandler<TInput = unknown, TOutput = unknown> = (input: AsyncIterable<TInput>, ctx: Context) => AsyncIterable<TOutput> | Promise<AsyncIterable<TOutput>>;
|
|
585
|
+
/**
|
|
586
|
+
* JSON-RPC protocol namespace for method and notification handlers.
|
|
587
|
+
*
|
|
588
|
+
* @example
|
|
589
|
+
* ```typescript
|
|
590
|
+
* server.rpc
|
|
591
|
+
* .method('users.get', { input: GetUserSchema }, async (input, ctx) => {
|
|
592
|
+
* return db.users.findById(input.id)
|
|
593
|
+
* })
|
|
594
|
+
* .notification('logs.write', async (data, ctx) => {
|
|
595
|
+
* logger.info(data)
|
|
596
|
+
* })
|
|
597
|
+
* ```
|
|
598
|
+
*/
|
|
599
|
+
export interface RpcNamespace {
|
|
600
|
+
/** Register a JSON-RPC method (request/response) */
|
|
601
|
+
method(name: string, handler: ProcedureHandler): RpcNamespace;
|
|
602
|
+
/** Register a JSON-RPC method with typed options */
|
|
603
|
+
method<TIn, TOut>(name: string, options: RpcMethodOptions<TIn, TOut>, handler: (input: TIn, ctx: Context) => TOut | Promise<TOut>): RpcNamespace;
|
|
604
|
+
/** Register a JSON-RPC notification (fire-and-forget, no response) */
|
|
605
|
+
notification(name: string, handler: ProcedureHandler): RpcNamespace;
|
|
606
|
+
/** Register a JSON-RPC notification with typed options */
|
|
607
|
+
notification<TIn>(name: string, options: RpcMethodOptions<TIn, void>, handler: (input: TIn, ctx: Context) => void | Promise<void>): RpcNamespace;
|
|
608
|
+
/** Add middleware to all RPC handlers */
|
|
609
|
+
use(interceptor: Interceptor): RpcNamespace;
|
|
610
|
+
}
|
|
611
|
+
/**
|
|
612
|
+
* RPC method configuration options.
|
|
613
|
+
* Generics allow type inference from input/output schemas.
|
|
614
|
+
*/
|
|
615
|
+
export interface RpcMethodOptions<TInput = unknown, TOutput = unknown> {
|
|
616
|
+
/** Description for documentation */
|
|
617
|
+
description?: string;
|
|
618
|
+
/** Tags for documentation grouping */
|
|
619
|
+
tags?: string[];
|
|
620
|
+
/** Input schema for validation */
|
|
621
|
+
input?: z.ZodType<TInput>;
|
|
622
|
+
/** Output schema for documentation */
|
|
623
|
+
output?: z.ZodType<TOutput>;
|
|
624
|
+
}
|
|
625
|
+
/**
|
|
626
|
+
* gRPC protocol namespace for service definitions.
|
|
627
|
+
*
|
|
628
|
+
* @example
|
|
629
|
+
* ```typescript
|
|
630
|
+
* server.grpc
|
|
631
|
+
* .service('UserService')
|
|
632
|
+
* .unary('GetUser', { input: GetUserSchema }, async (input, ctx) => {
|
|
633
|
+
* return db.users.findById(input.id)
|
|
634
|
+
* })
|
|
635
|
+
* .serverStream('ListUsers', async function*(input, ctx) {
|
|
636
|
+
* for await (const user of db.users.stream()) {
|
|
637
|
+
* yield user
|
|
638
|
+
* }
|
|
639
|
+
* })
|
|
640
|
+
* ```
|
|
641
|
+
*/
|
|
642
|
+
export interface GrpcNamespace {
|
|
643
|
+
/** Define a gRPC service (namespace for methods) */
|
|
644
|
+
service(serviceName: string): GrpcServiceBuilder;
|
|
645
|
+
/** Add middleware to all gRPC handlers */
|
|
646
|
+
use(interceptor: Interceptor): GrpcNamespace;
|
|
647
|
+
}
|
|
648
|
+
/**
|
|
649
|
+
* Builder for a specific gRPC service.
|
|
650
|
+
*/
|
|
651
|
+
export interface GrpcServiceBuilder {
|
|
652
|
+
/** Register a unary RPC (single request, single response) */
|
|
653
|
+
unary(name: string, handler: ProcedureHandler): GrpcServiceBuilder;
|
|
654
|
+
unary(name: string, options: GrpcMethodOptions, handler: ProcedureHandler): GrpcServiceBuilder;
|
|
655
|
+
/** Register a server streaming RPC (single request, stream of responses) */
|
|
656
|
+
serverStream(name: string, handler: StreamHandler): GrpcServiceBuilder;
|
|
657
|
+
serverStream(name: string, options: GrpcMethodOptions, handler: StreamHandler): GrpcServiceBuilder;
|
|
658
|
+
/** Register a client streaming RPC (stream of requests, single response) */
|
|
659
|
+
clientStream(name: string, handler: StreamHandler): GrpcServiceBuilder;
|
|
660
|
+
clientStream(name: string, options: GrpcMethodOptions, handler: StreamHandler): GrpcServiceBuilder;
|
|
661
|
+
/** Register a bidirectional streaming RPC */
|
|
662
|
+
bidiStream(name: string, handler: StreamHandler): GrpcServiceBuilder;
|
|
663
|
+
bidiStream(name: string, options: GrpcMethodOptions, handler: StreamHandler): GrpcServiceBuilder;
|
|
664
|
+
/** Return to the main gRPC namespace */
|
|
665
|
+
end(): GrpcNamespace;
|
|
666
|
+
}
|
|
667
|
+
/**
|
|
668
|
+
* gRPC method configuration options.
|
|
669
|
+
*/
|
|
670
|
+
export interface GrpcMethodOptions {
|
|
671
|
+
/** Description for documentation */
|
|
672
|
+
description?: string;
|
|
673
|
+
/** Tags for documentation grouping */
|
|
674
|
+
tags?: string[];
|
|
675
|
+
/** Input schema for validation */
|
|
676
|
+
input?: z.ZodType;
|
|
677
|
+
/** Output schema for documentation */
|
|
678
|
+
output?: z.ZodType;
|
|
679
|
+
}
|
|
680
|
+
/**
|
|
681
|
+
* TCP protocol namespace for raw socket handlers.
|
|
682
|
+
*
|
|
683
|
+
* @example
|
|
684
|
+
* ```typescript
|
|
685
|
+
* server.tcp
|
|
686
|
+
* .handler('echo', {
|
|
687
|
+
* port: 9000,
|
|
688
|
+
* framing: 'line'
|
|
689
|
+
* })
|
|
690
|
+
* .onConnect((socket, ctx) => {
|
|
691
|
+
* console.log('Client connected')
|
|
692
|
+
* })
|
|
693
|
+
* .onData((data, socket, ctx) => {
|
|
694
|
+
* socket.write(data) // Echo back
|
|
695
|
+
* })
|
|
696
|
+
* .onClose((socket, ctx) => {
|
|
697
|
+
* console.log('Client disconnected')
|
|
698
|
+
* })
|
|
699
|
+
* ```
|
|
700
|
+
*/
|
|
701
|
+
export interface TcpNamespace {
|
|
702
|
+
/** Define a TCP handler with connection lifecycle */
|
|
703
|
+
handler(name: string, options?: TcpHandlerOptions): TcpHandlerBuilder;
|
|
704
|
+
/** Add middleware to all TCP handlers */
|
|
705
|
+
use(interceptor: Interceptor): TcpNamespace;
|
|
706
|
+
}
|
|
707
|
+
/**
|
|
708
|
+
* TCP handler configuration options.
|
|
709
|
+
*/
|
|
710
|
+
export interface TcpHandlerOptions {
|
|
711
|
+
/** TCP port to listen on */
|
|
712
|
+
port?: number;
|
|
713
|
+
/** Host to bind to */
|
|
714
|
+
host?: string;
|
|
715
|
+
/** Description for documentation */
|
|
716
|
+
description?: string;
|
|
717
|
+
/** Framing mode for message boundaries */
|
|
718
|
+
framing?: 'none' | 'line' | 'length-prefixed' | 'delimiter';
|
|
719
|
+
/** Delimiter character for 'delimiter' framing (default: '\n') */
|
|
720
|
+
delimiter?: string;
|
|
721
|
+
/** TLS options for secure connections */
|
|
722
|
+
tls?: {
|
|
723
|
+
key: string | Buffer;
|
|
724
|
+
cert: string | Buffer;
|
|
725
|
+
ca?: string | Buffer;
|
|
726
|
+
};
|
|
727
|
+
}
|
|
728
|
+
/**
|
|
729
|
+
* Builder for a TCP handler with lifecycle hooks.
|
|
730
|
+
*/
|
|
731
|
+
export interface TcpHandlerBuilder {
|
|
732
|
+
/** Handle new connection */
|
|
733
|
+
onConnect(handler: TcpConnectHandler): TcpHandlerBuilder;
|
|
734
|
+
/** Handle incoming data */
|
|
735
|
+
onData(handler: TcpDataHandler): TcpHandlerBuilder;
|
|
736
|
+
/** Handle connection close */
|
|
737
|
+
onClose(handler: TcpCloseHandler): TcpHandlerBuilder;
|
|
738
|
+
/** Handle errors */
|
|
739
|
+
onError(handler: TcpErrorHandler): TcpHandlerBuilder;
|
|
740
|
+
/** Return to the main TCP namespace */
|
|
741
|
+
end(): TcpNamespace;
|
|
742
|
+
}
|
|
743
|
+
/** TCP connection handler */
|
|
744
|
+
export type TcpConnectHandler = (socket: import('node:net').Socket, ctx: Context) => void | Promise<void>;
|
|
745
|
+
/** TCP data handler */
|
|
746
|
+
export type TcpDataHandler = (data: Buffer, socket: import('node:net').Socket, ctx: Context) => void | Promise<void>;
|
|
747
|
+
/** TCP close handler */
|
|
748
|
+
export type TcpCloseHandler = (socket: import('node:net').Socket, ctx: Context) => void | Promise<void>;
|
|
749
|
+
/** TCP error handler */
|
|
750
|
+
export type TcpErrorHandler = (error: Error, socket: import('node:net').Socket, ctx: Context) => void | Promise<void>;
|
|
751
|
+
/**
|
|
752
|
+
* UDP protocol namespace for datagram handlers.
|
|
753
|
+
*
|
|
754
|
+
* @example
|
|
755
|
+
* ```typescript
|
|
756
|
+
* server.udp
|
|
757
|
+
* .handler('metrics', {
|
|
758
|
+
* port: 9001,
|
|
759
|
+
* multicast: '239.0.0.1'
|
|
760
|
+
* })
|
|
761
|
+
* .onMessage((msg, rinfo, ctx) => {
|
|
762
|
+
* console.log(`Received: ${msg} from ${rinfo.address}:${rinfo.port}`)
|
|
763
|
+
* })
|
|
764
|
+
* ```
|
|
765
|
+
*/
|
|
766
|
+
export interface UdpNamespace {
|
|
767
|
+
/** Define a UDP handler */
|
|
768
|
+
handler(name: string, options?: UdpHandlerOptions): UdpHandlerBuilder;
|
|
769
|
+
/** Add middleware to all UDP handlers */
|
|
770
|
+
use(interceptor: Interceptor): UdpNamespace;
|
|
771
|
+
}
|
|
772
|
+
/**
|
|
773
|
+
* UDP handler configuration options.
|
|
774
|
+
*/
|
|
775
|
+
export interface UdpHandlerOptions {
|
|
776
|
+
/** UDP port to listen on */
|
|
777
|
+
port?: number;
|
|
778
|
+
/** Host to bind to */
|
|
779
|
+
host?: string;
|
|
780
|
+
/** Description for documentation */
|
|
781
|
+
description?: string;
|
|
782
|
+
/** Multicast group to join */
|
|
783
|
+
multicast?: string;
|
|
784
|
+
/** UDP socket type */
|
|
785
|
+
type?: 'udp4' | 'udp6';
|
|
786
|
+
}
|
|
787
|
+
/**
|
|
788
|
+
* Builder for a UDP handler with message callback.
|
|
789
|
+
*/
|
|
790
|
+
export interface UdpHandlerBuilder {
|
|
791
|
+
/** Handle incoming messages */
|
|
792
|
+
onMessage(handler: UdpMessageHandler): UdpHandlerBuilder;
|
|
793
|
+
/** Handle errors */
|
|
794
|
+
onError(handler: UdpErrorHandler): UdpHandlerBuilder;
|
|
795
|
+
/** Return to the main UDP namespace */
|
|
796
|
+
end(): UdpNamespace;
|
|
797
|
+
}
|
|
798
|
+
/** UDP message handler */
|
|
799
|
+
export type UdpMessageHandler = (msg: Buffer, rinfo: import('node:dgram').RemoteInfo, ctx: Context) => void | Promise<void>;
|
|
800
|
+
/** UDP error handler */
|
|
801
|
+
export type UdpErrorHandler = (error: Error, ctx: Context) => void | Promise<void>;
|
|
802
|
+
/**
|
|
803
|
+
* gRPC protocol namespace for defining gRPC services.
|
|
804
|
+
* Provides a chainable API for defining gRPC methods.
|
|
805
|
+
* Use `grpcNs` to avoid conflict with the `grpc(options)` method that configures gRPC.
|
|
806
|
+
*
|
|
807
|
+
* @example
|
|
808
|
+
* ```typescript
|
|
809
|
+
* server.grpcNs
|
|
810
|
+
* .use(loggingInterceptor)
|
|
811
|
+
* .service('UserService')
|
|
812
|
+
* .method('GetUser', { input: GetUserRequest, output: User }, async (req, ctx) => {
|
|
813
|
+
* return db.users.findById(req.id)
|
|
814
|
+
* })
|
|
815
|
+
* .method('CreateUser', { input: CreateUserRequest, output: User }, async (req, ctx) => {
|
|
816
|
+
* return db.users.create(req)
|
|
817
|
+
* })
|
|
818
|
+
* .end()
|
|
819
|
+
* ```
|
|
820
|
+
*/
|
|
821
|
+
export interface GrpcNamespace {
|
|
822
|
+
/** Define a gRPC service */
|
|
823
|
+
service(name: string, options?: GrpcServiceOptions): GrpcServiceBuilder;
|
|
824
|
+
/** Add middleware to all gRPC services */
|
|
825
|
+
use(interceptor: Interceptor): GrpcNamespace;
|
|
826
|
+
}
|
|
827
|
+
/**
|
|
828
|
+
* gRPC service configuration options.
|
|
829
|
+
*/
|
|
830
|
+
export interface GrpcServiceOptions {
|
|
831
|
+
/** Package name for the service */
|
|
832
|
+
packageName?: string;
|
|
833
|
+
/** Description for documentation */
|
|
834
|
+
description?: string;
|
|
835
|
+
}
|
|
836
|
+
/**
|
|
837
|
+
* Builder for a gRPC service with methods.
|
|
838
|
+
*/
|
|
839
|
+
export interface GrpcServiceBuilder {
|
|
840
|
+
/**
|
|
841
|
+
* Add a unary method to the service.
|
|
842
|
+
*
|
|
843
|
+
* @example
|
|
844
|
+
* ```typescript
|
|
845
|
+
* .method('GetUser', async (request, ctx) => {
|
|
846
|
+
* return { id: request.id, name: 'John' }
|
|
847
|
+
* })
|
|
848
|
+
* ```
|
|
849
|
+
*/
|
|
850
|
+
method(name: string, handler: GrpcMethodHandler): GrpcServiceBuilder;
|
|
851
|
+
/**
|
|
852
|
+
* Add a unary method with options.
|
|
853
|
+
*
|
|
854
|
+
* @example
|
|
855
|
+
* ```typescript
|
|
856
|
+
* .method('GetUser', { input: GetUserRequest, output: User }, async (request, ctx) => {
|
|
857
|
+
* return db.users.findById(request.id)
|
|
858
|
+
* })
|
|
859
|
+
* ```
|
|
860
|
+
*/
|
|
861
|
+
method(name: string, options: GrpcMethodOptions, handler: GrpcMethodHandler): GrpcServiceBuilder;
|
|
862
|
+
/**
|
|
863
|
+
* Add a server streaming method.
|
|
864
|
+
* Returns multiple responses for a single request.
|
|
865
|
+
*/
|
|
866
|
+
serverStream(name: string, handler: GrpcServerStreamHandler): GrpcServiceBuilder;
|
|
867
|
+
serverStream(name: string, options: GrpcMethodOptions, handler: GrpcServerStreamHandler): GrpcServiceBuilder;
|
|
868
|
+
/**
|
|
869
|
+
* Add a client streaming method.
|
|
870
|
+
* Receives multiple requests and returns a single response.
|
|
871
|
+
*/
|
|
872
|
+
clientStream(name: string, handler: GrpcClientStreamHandler): GrpcServiceBuilder;
|
|
873
|
+
clientStream(name: string, options: GrpcMethodOptions, handler: GrpcClientStreamHandler): GrpcServiceBuilder;
|
|
874
|
+
/**
|
|
875
|
+
* Add a bidirectional streaming method.
|
|
876
|
+
* Both client and server can send multiple messages.
|
|
877
|
+
*/
|
|
878
|
+
bidiStream(name: string, handler: GrpcBidiStreamHandler): GrpcServiceBuilder;
|
|
879
|
+
bidiStream(name: string, options: GrpcMethodOptions, handler: GrpcBidiStreamHandler): GrpcServiceBuilder;
|
|
880
|
+
/** Return to the main gRPC namespace */
|
|
881
|
+
end(): GrpcNamespace;
|
|
882
|
+
}
|
|
883
|
+
/**
|
|
884
|
+
* gRPC method configuration options.
|
|
885
|
+
*/
|
|
886
|
+
export interface GrpcMethodOptions {
|
|
887
|
+
/** Input schema (Zod) */
|
|
888
|
+
input?: z.ZodType;
|
|
889
|
+
/** Output schema (Zod) */
|
|
890
|
+
output?: z.ZodType;
|
|
891
|
+
/** Description for documentation */
|
|
892
|
+
description?: string;
|
|
893
|
+
}
|
|
894
|
+
/** gRPC unary method handler */
|
|
895
|
+
export type GrpcMethodHandler = (request: unknown, ctx: Context) => unknown | Promise<unknown>;
|
|
896
|
+
/** gRPC server streaming method handler */
|
|
897
|
+
export type GrpcServerStreamHandler = (request: unknown, ctx: Context) => AsyncIterable<unknown>;
|
|
898
|
+
/** gRPC client streaming method handler */
|
|
899
|
+
export type GrpcClientStreamHandler = (requests: AsyncIterable<unknown>, ctx: Context) => unknown | Promise<unknown>;
|
|
900
|
+
/** gRPC bidirectional streaming method handler */
|
|
901
|
+
export type GrpcBidiStreamHandler = (requests: AsyncIterable<unknown>, ctx: Context) => AsyncIterable<unknown>;
|
|
902
|
+
export interface ProcedureBuilder<TInput = unknown, TOutput = unknown> {
|
|
903
|
+
/** Define input schema (Zod) */
|
|
904
|
+
input<T extends z.ZodType>(schema: T): ProcedureBuilder<z.infer<T>, TOutput>;
|
|
905
|
+
/** Define output schema (Zod) */
|
|
906
|
+
output<T extends z.ZodType>(schema: T): ProcedureBuilder<TInput, z.infer<T>>;
|
|
907
|
+
/** Add short summary for OpenAPI (one-liner) */
|
|
908
|
+
summary(sum: string): this;
|
|
909
|
+
/** Add description for OpenAPI (supports markdown) */
|
|
910
|
+
description(desc: string): this;
|
|
911
|
+
/**
|
|
912
|
+
* Set tags for OpenAPI grouping.
|
|
913
|
+
*
|
|
914
|
+
* @example
|
|
915
|
+
* ```ts
|
|
916
|
+
* server.procedure('users.create')
|
|
917
|
+
* .tags(['users', 'admin'])
|
|
918
|
+
* ```
|
|
919
|
+
*/
|
|
920
|
+
tags(tags: string[]): this;
|
|
921
|
+
/** Add interceptor */
|
|
922
|
+
use(interceptor: Interceptor): this;
|
|
923
|
+
/** Mark GraphQL mapping */
|
|
924
|
+
graphql(type: 'query' | 'mutation'): this;
|
|
925
|
+
/** Configure JSON-RPC metadata for USD generation */
|
|
926
|
+
jsonrpc(meta: JsonRpcMeta): this;
|
|
927
|
+
/** Configure gRPC metadata for USD generation */
|
|
928
|
+
grpc(meta: GrpcMeta): this;
|
|
929
|
+
/**
|
|
930
|
+
* Configure HTTP routing for this procedure.
|
|
931
|
+
* By default, procedures use POST /{name}.
|
|
932
|
+
* Use this to define REST-style routes with path parameters.
|
|
933
|
+
*
|
|
934
|
+
* @param path - HTTP path with optional parameters (e.g., '/users/{id}')
|
|
935
|
+
* @param method - HTTP method (GET, POST, PUT, PATCH, DELETE)
|
|
936
|
+
*
|
|
937
|
+
* @example
|
|
938
|
+
* ```ts
|
|
939
|
+
* server.procedure('users.get')
|
|
940
|
+
* .http('/users/{userId}', 'GET')
|
|
941
|
+
* .input(z.object({
|
|
942
|
+
* userId: z.string().uuid(), // extracted from path
|
|
943
|
+
* include: z.string().optional() // becomes query param
|
|
944
|
+
* }))
|
|
945
|
+
* ```
|
|
946
|
+
*/
|
|
947
|
+
http(path: string, method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE'): this;
|
|
948
|
+
/**
|
|
949
|
+
* Add a before hook - runs before the handler.
|
|
950
|
+
* Multiple before hooks run in order of registration.
|
|
951
|
+
* Throwing from a before hook prevents handler execution.
|
|
952
|
+
*/
|
|
953
|
+
before(hook: BeforeHook<TInput>): this;
|
|
954
|
+
/**
|
|
955
|
+
* Add an after hook - runs after the handler.
|
|
956
|
+
* Receives the result and can transform it.
|
|
957
|
+
* Multiple after hooks run in order, each receiving the previous result.
|
|
958
|
+
*/
|
|
959
|
+
after(hook: AfterHook<TInput, TOutput>): this;
|
|
960
|
+
/**
|
|
961
|
+
* Add an error hook - runs when handler or before hooks throw.
|
|
962
|
+
* Can swallow errors (by returning a value), transform them, or re-throw.
|
|
963
|
+
*/
|
|
964
|
+
error(hook: ErrorHook<TInput>): this;
|
|
965
|
+
/** Register the handler */
|
|
966
|
+
handler(fn: (input: TInput, ctx: Context) => Promise<TOutput>): void;
|
|
967
|
+
}
|
|
968
|
+
export interface StreamBuilder<TInput = unknown, TOutput = unknown> {
|
|
969
|
+
/** Define input schema */
|
|
970
|
+
input<T extends z.ZodType>(schema: T): StreamBuilder<z.infer<T>, TOutput>;
|
|
971
|
+
/** Define output chunk schema */
|
|
972
|
+
output<T extends z.ZodType>(schema: T): StreamBuilder<TInput, z.infer<T>>;
|
|
973
|
+
/** Set stream direction */
|
|
974
|
+
direction(direction: StreamDirection): this;
|
|
975
|
+
/** Add description */
|
|
976
|
+
description(desc: string): this;
|
|
977
|
+
/** Add interceptor */
|
|
978
|
+
use(interceptor: Interceptor): this;
|
|
979
|
+
/** Register the handler */
|
|
980
|
+
handler(fn: (input: TInput, ctx: Context) => AsyncIterable<TOutput>): void;
|
|
981
|
+
}
|
|
982
|
+
export interface EventBuilder<TInput = unknown> {
|
|
983
|
+
/** Define input schema */
|
|
984
|
+
input<T extends z.ZodType>(schema: T): EventBuilder<z.infer<T>>;
|
|
985
|
+
/** Add description */
|
|
986
|
+
description(desc: string): this;
|
|
987
|
+
/** Add interceptor */
|
|
988
|
+
use(interceptor: Interceptor): this;
|
|
989
|
+
/** Set delivery guarantee */
|
|
990
|
+
delivery(guarantee: 'best-effort' | 'at-least-once' | 'at-most-once'): this;
|
|
991
|
+
/** Set retry policy (for at-least-once) */
|
|
992
|
+
retryPolicy(policy: RetryPolicy): this;
|
|
993
|
+
/** Set deduplication window in ms (for at-most-once) */
|
|
994
|
+
deduplicationWindow(ms: number): this;
|
|
995
|
+
/** Register the handler */
|
|
996
|
+
handler(fn: (input: TInput, ctx: Context, ack: () => void) => Promise<void>): void;
|
|
997
|
+
}
|
|
998
|
+
/**
|
|
999
|
+
* Resource builder for REST CRUD operations.
|
|
1000
|
+
* Dramatically reduces verbosity for defining REST endpoints.
|
|
1001
|
+
*
|
|
1002
|
+
* @example
|
|
1003
|
+
* ```typescript
|
|
1004
|
+
* // Instead of 5+ procedure definitions with .http():
|
|
1005
|
+
* server.resource('users', User)
|
|
1006
|
+
* .list(ListInput, async (input, ctx) => db.users.list(input))
|
|
1007
|
+
* .get(async (id, ctx) => db.users.findById(id))
|
|
1008
|
+
* .create(CreateInput, async (input, ctx) => db.users.create(input))
|
|
1009
|
+
* .update(UpdateInput, async (id, input, ctx) => db.users.update(id, input))
|
|
1010
|
+
* .delete(async (id, ctx) => db.users.delete(id))
|
|
1011
|
+
* ```
|
|
1012
|
+
*/
|
|
1013
|
+
export interface ResourceBuilder<TOutput = unknown> {
|
|
1014
|
+
/** Add interceptor to all operations */
|
|
1015
|
+
use(interceptor: Interceptor): ResourceBuilder<TOutput>;
|
|
1016
|
+
/** Set tags for documentation */
|
|
1017
|
+
tags(tags: string[]): ResourceBuilder<TOutput>;
|
|
1018
|
+
/** GET /resources - List all */
|
|
1019
|
+
list<TInput>(inputSchema: z.ZodType<TInput>, handler: (input: TInput, ctx: Context) => Promise<TOutput[]>): ResourceBuilder<TOutput>;
|
|
1020
|
+
/** GET /resources - List all (no input) */
|
|
1021
|
+
list(handler: (input: unknown, ctx: Context) => Promise<TOutput[]>): ResourceBuilder<TOutput>;
|
|
1022
|
+
/** GET /resources/:id - Get one */
|
|
1023
|
+
get(handler: (id: string, ctx: Context) => Promise<TOutput | null>): ResourceBuilder<TOutput>;
|
|
1024
|
+
/** POST /resources - Create */
|
|
1025
|
+
create<TInput>(inputSchema: z.ZodType<TInput>, handler: (input: TInput, ctx: Context) => Promise<TOutput>): ResourceBuilder<TOutput>;
|
|
1026
|
+
/** PUT /resources/:id - Full update */
|
|
1027
|
+
update<TInput>(inputSchema: z.ZodType<TInput>, handler: (id: string, input: TInput, ctx: Context) => Promise<TOutput>): ResourceBuilder<TOutput>;
|
|
1028
|
+
/** PATCH /resources/:id - Partial update */
|
|
1029
|
+
patch<TInput>(inputSchema: z.ZodType<TInput>, handler: (id: string, input: TInput, ctx: Context) => Promise<TOutput>): ResourceBuilder<TOutput>;
|
|
1030
|
+
/** DELETE /resources/:id - Delete */
|
|
1031
|
+
delete(handler: (id: string, ctx: Context) => Promise<void | TOutput>): ResourceBuilder<TOutput>;
|
|
1032
|
+
/** POST /resources/:action - Custom collection action */
|
|
1033
|
+
action<TInput, TActionOutput = TOutput>(actionName: string, inputSchema: z.ZodType<TInput>, handler: (input: TInput, ctx: Context) => Promise<TActionOutput>): ResourceBuilder<TOutput>;
|
|
1034
|
+
/** POST /resources/:id/:action - Custom item action */
|
|
1035
|
+
itemAction<TInput = void, TActionOutput = TOutput>(actionName: string, handler: (id: string, ctx: Context) => Promise<TActionOutput>): ResourceBuilder<TOutput>;
|
|
1036
|
+
itemAction<TInput, TActionOutput = TOutput>(actionName: string, inputSchema: z.ZodType<TInput>, handler: (id: string, input: TInput, ctx: Context) => Promise<TActionOutput>): ResourceBuilder<TOutput>;
|
|
1037
|
+
}
|
|
1038
|
+
export interface GroupBuilder {
|
|
1039
|
+
/** Add interceptor to all handlers in this group */
|
|
1040
|
+
use(interceptor: Interceptor): this;
|
|
1041
|
+
/** Create a procedure in this group */
|
|
1042
|
+
procedure(name: string): ProcedureBuilder;
|
|
1043
|
+
/** Create a stream in this group */
|
|
1044
|
+
stream(name: string): StreamBuilder;
|
|
1045
|
+
/** Create an event in this group */
|
|
1046
|
+
event(name: string): EventBuilder;
|
|
1047
|
+
/** Create a nested group (inherits middleware) */
|
|
1048
|
+
group(prefix: string): GroupBuilder;
|
|
1049
|
+
}
|
|
1050
|
+
export interface RouterModule {
|
|
1051
|
+
/** Add interceptor to all handlers in this module */
|
|
1052
|
+
use(interceptor: Interceptor): this;
|
|
1053
|
+
/** Create a procedure in this module */
|
|
1054
|
+
procedure(name: string): ProcedureBuilder;
|
|
1055
|
+
/** Create a stream in this module */
|
|
1056
|
+
stream(name: string): StreamBuilder;
|
|
1057
|
+
/** Create an event in this module */
|
|
1058
|
+
event(name: string): EventBuilder;
|
|
1059
|
+
/** Create a nested module group */
|
|
1060
|
+
group(prefix: string): RouterModule;
|
|
1061
|
+
}
|
|
1062
|
+
export interface MountOptions {
|
|
1063
|
+
/** Interceptors applied between global and module interceptors */
|
|
1064
|
+
interceptors?: Interceptor[];
|
|
1065
|
+
}
|
|
1066
|
+
/**
|
|
1067
|
+
* Unified protocol configuration for enabling multiple protocols at once.
|
|
1068
|
+
*
|
|
1069
|
+
* @example
|
|
1070
|
+
* ```typescript
|
|
1071
|
+
* const server = createServer({ port: 3000 })
|
|
1072
|
+
* .protocols({
|
|
1073
|
+
* http: true, // Already enabled by default
|
|
1074
|
+
* websocket: { path: '/ws' }, // Enable WebSocket at /ws
|
|
1075
|
+
* jsonrpc: '/rpc', // Enable JSON-RPC at /rpc
|
|
1076
|
+
* streams: true, // Enable SSE streams
|
|
1077
|
+
* graphql: { path: '/graphql' }, // Enable GraphQL
|
|
1078
|
+
* })
|
|
1079
|
+
* ```
|
|
1080
|
+
*/
|
|
1081
|
+
export interface UnifiedProtocolConfig {
|
|
1082
|
+
/** HTTP is enabled by default. Set to false to disable */
|
|
1083
|
+
http?: boolean;
|
|
1084
|
+
/** WebSocket: boolean to enable on /ws, string for custom path, or full options */
|
|
1085
|
+
websocket?: boolean | string | WebSocketOptions;
|
|
1086
|
+
/** JSON-RPC: boolean to enable on /rpc, string for custom path, or full options */
|
|
1087
|
+
jsonrpc?: boolean | string | JsonRpcOptions;
|
|
1088
|
+
/** SSE Streams: boolean to enable on /streams, string for custom path */
|
|
1089
|
+
streams?: boolean | string;
|
|
1090
|
+
/** GraphQL: boolean to enable on /graphql, string for custom path, or full options */
|
|
1091
|
+
graphql?: boolean | string | GraphQLOptions;
|
|
1092
|
+
/** TCP: requires explicit port */
|
|
1093
|
+
tcp?: TcpOptions;
|
|
1094
|
+
/** gRPC: requires proto path */
|
|
1095
|
+
grpc?: GrpcOptions;
|
|
1096
|
+
}
|
|
1097
|
+
export interface RaffelServer {
|
|
1098
|
+
/**
|
|
1099
|
+
* Enable multiple protocols with a single configuration object.
|
|
1100
|
+
* This is the recommended way to configure protocols for multi-protocol servers.
|
|
1101
|
+
*
|
|
1102
|
+
* @example
|
|
1103
|
+
* ```typescript
|
|
1104
|
+
* const server = createServer({ port: 3000 })
|
|
1105
|
+
* .protocols({
|
|
1106
|
+
* websocket: '/ws',
|
|
1107
|
+
* jsonrpc: true,
|
|
1108
|
+
* streams: true,
|
|
1109
|
+
* })
|
|
1110
|
+
* ```
|
|
1111
|
+
*/
|
|
1112
|
+
protocols(config: UnifiedProtocolConfig): this;
|
|
1113
|
+
/** Enable WebSocket on same HTTP port (upgrade) */
|
|
1114
|
+
enableWebSocket(path?: string): this;
|
|
1115
|
+
/** Configure WebSocket on custom port */
|
|
1116
|
+
websocket(options: WebSocketOptions): this;
|
|
1117
|
+
/** Enable JSON-RPC on same HTTP port */
|
|
1118
|
+
enableJsonRpc(path?: string): this;
|
|
1119
|
+
/** Configure JSON-RPC on custom port */
|
|
1120
|
+
jsonrpc(options: JsonRpcOptions): this;
|
|
1121
|
+
/** Configure TCP (always separate port) */
|
|
1122
|
+
tcp(options: TcpOptions): this;
|
|
1123
|
+
/** Configure gRPC */
|
|
1124
|
+
grpc(options: GrpcOptions): this;
|
|
1125
|
+
/** Enable GraphQL on same HTTP port */
|
|
1126
|
+
enableGraphQL(path?: string): this;
|
|
1127
|
+
/** Configure GraphQL with custom options */
|
|
1128
|
+
configureGraphQL(options: GraphQLOptions): this;
|
|
1129
|
+
/**
|
|
1130
|
+
* Enable Prometheus-style metrics collection.
|
|
1131
|
+
*
|
|
1132
|
+
* @param config - Metrics configuration
|
|
1133
|
+
*
|
|
1134
|
+
* @example
|
|
1135
|
+
* ```typescript
|
|
1136
|
+
* const server = createServer({ port: 3000 })
|
|
1137
|
+
* .enableMetrics({
|
|
1138
|
+
* endpoint: '/metrics',
|
|
1139
|
+
* collectRequestMetrics: true,
|
|
1140
|
+
* collectProcessMetrics: true,
|
|
1141
|
+
* defaultLabels: { service: 'api' },
|
|
1142
|
+
* })
|
|
1143
|
+
*
|
|
1144
|
+
* // Custom metrics
|
|
1145
|
+
* server.metrics?.counter('orders_created', { labels: ['region'] })
|
|
1146
|
+
* server.metrics?.increment('orders_created', { region: 'us-east' })
|
|
1147
|
+
*
|
|
1148
|
+
* // Timer helper
|
|
1149
|
+
* const end = server.metrics?.timer('db_query_duration_seconds')
|
|
1150
|
+
* await database.query(...)
|
|
1151
|
+
* end?.()
|
|
1152
|
+
* ```
|
|
1153
|
+
*/
|
|
1154
|
+
enableMetrics(config?: MetricsConfig): this;
|
|
1155
|
+
/**
|
|
1156
|
+
* Enable distributed tracing with OpenTelemetry-compatible spans.
|
|
1157
|
+
*
|
|
1158
|
+
* @param config - Tracing configuration
|
|
1159
|
+
*
|
|
1160
|
+
* @example
|
|
1161
|
+
* ```typescript
|
|
1162
|
+
* import { createConsoleExporter, createJaegerExporter } from 'raffel'
|
|
1163
|
+
*
|
|
1164
|
+
* const server = createServer({ port: 3000 })
|
|
1165
|
+
* .enableTracing({
|
|
1166
|
+
* serviceName: 'my-service',
|
|
1167
|
+
* sampleRate: 1.0, // Sample all requests
|
|
1168
|
+
* exporters: [
|
|
1169
|
+
* createConsoleExporter(), // Dev logging
|
|
1170
|
+
* createJaegerExporter({ serviceName: 'my-service' }), // Production
|
|
1171
|
+
* ],
|
|
1172
|
+
* })
|
|
1173
|
+
*
|
|
1174
|
+
* // Spans are automatically created for requests
|
|
1175
|
+
* // W3C Trace Context headers are propagated
|
|
1176
|
+
* ```
|
|
1177
|
+
*/
|
|
1178
|
+
enableTracing(config?: TracingConfig): this;
|
|
1179
|
+
/**
|
|
1180
|
+
* Enable USD (Universal Service Documentation) - the modern multi-protocol documentation format.
|
|
1181
|
+
*
|
|
1182
|
+
* USD extends OpenAPI 3.1 with the x-usd namespace to document:
|
|
1183
|
+
* - HTTP endpoints (procedures, REST resources)
|
|
1184
|
+
* - WebSocket channels
|
|
1185
|
+
* - Server-Sent Events (streams)
|
|
1186
|
+
* - JSON-RPC methods
|
|
1187
|
+
* - gRPC services
|
|
1188
|
+
*
|
|
1189
|
+
* @param config - USD configuration
|
|
1190
|
+
*
|
|
1191
|
+
* @example
|
|
1192
|
+
* ```typescript
|
|
1193
|
+
* const server = createServer({ port: 3000 })
|
|
1194
|
+
* .enableUSD({
|
|
1195
|
+
* basePath: '/docs',
|
|
1196
|
+
* info: {
|
|
1197
|
+
* title: 'My API',
|
|
1198
|
+
* version: '1.0.0',
|
|
1199
|
+
* },
|
|
1200
|
+
* ui: { theme: 'dark' },
|
|
1201
|
+
* })
|
|
1202
|
+
*
|
|
1203
|
+
* // Documentation available at:
|
|
1204
|
+
* // - /docs - Interactive UI
|
|
1205
|
+
* // - /docs/usd.json - USD document
|
|
1206
|
+
* // - /docs/usd.yaml - USD document (YAML)
|
|
1207
|
+
* // - /docs/openapi.json - Pure OpenAPI 3.1
|
|
1208
|
+
* ```
|
|
1209
|
+
*/
|
|
1210
|
+
enableUSD(config?: USDDocsConfig): this;
|
|
1211
|
+
/**
|
|
1212
|
+
* Get the USD document.
|
|
1213
|
+
* Available after server.start() or after enableUSD() is called.
|
|
1214
|
+
*
|
|
1215
|
+
* @example
|
|
1216
|
+
* ```typescript
|
|
1217
|
+
* const doc = server.getUSDDocument()
|
|
1218
|
+
* console.log(doc.info.title)
|
|
1219
|
+
* console.log(doc['x-usd']?.websocket?.channels)
|
|
1220
|
+
* ```
|
|
1221
|
+
*/
|
|
1222
|
+
getUSDDocument(): USDDocument | null;
|
|
1223
|
+
/**
|
|
1224
|
+
* Get pure OpenAPI 3.1 document (for Swagger UI compatibility).
|
|
1225
|
+
* This strips the x-usd namespace and other USD extensions.
|
|
1226
|
+
*
|
|
1227
|
+
* @example
|
|
1228
|
+
* ```typescript
|
|
1229
|
+
* const openapi = server.getOpenAPIDocument()
|
|
1230
|
+
* // Use with Swagger UI or other OpenAPI tools
|
|
1231
|
+
* ```
|
|
1232
|
+
*/
|
|
1233
|
+
getOpenAPIDocument(): OpenAPIDocument | null;
|
|
1234
|
+
/** Get USD handlers (available after enableUSD) */
|
|
1235
|
+
readonly usd?: USDDocsHandlers;
|
|
1236
|
+
/**
|
|
1237
|
+
* Register a provider (singleton) that will be available in all handlers.
|
|
1238
|
+
* Providers are initialized on server start and injected into context.
|
|
1239
|
+
*
|
|
1240
|
+
* @example
|
|
1241
|
+
* ```typescript
|
|
1242
|
+
* const server = createServer({ port: 3000 })
|
|
1243
|
+
* .provide('db', () => new PrismaClient())
|
|
1244
|
+
* .provide('s3db', () => new S3DB({ bucket: 'my-bucket' }))
|
|
1245
|
+
* .provide('config', () => ({ apiKey: process.env.API_KEY }))
|
|
1246
|
+
*
|
|
1247
|
+
* // In handlers:
|
|
1248
|
+
* server.procedure('users.get').handler(async (input, ctx) => {
|
|
1249
|
+
* return ctx.db.user.findUnique({ where: { id: input.id } })
|
|
1250
|
+
* })
|
|
1251
|
+
* ```
|
|
1252
|
+
*/
|
|
1253
|
+
provide<T>(name: string, factory: ProviderFactory<T>, options?: {
|
|
1254
|
+
onShutdown?: (instance: T) => void | Promise<void>;
|
|
1255
|
+
}): this;
|
|
1256
|
+
/** Add global interceptor */
|
|
1257
|
+
use(interceptor: Interceptor): this;
|
|
1258
|
+
/**
|
|
1259
|
+
* Register global hooks with pattern matching.
|
|
1260
|
+
* Hooks run for procedures whose names match the pattern.
|
|
1261
|
+
*
|
|
1262
|
+
* Patterns:
|
|
1263
|
+
* - '*' matches all procedures
|
|
1264
|
+
* - 'users.*' matches all procedures starting with 'users.'
|
|
1265
|
+
* - 'users.get' matches exact procedure name
|
|
1266
|
+
*
|
|
1267
|
+
* @example
|
|
1268
|
+
* ```typescript
|
|
1269
|
+
* const server = createServer({ port: 3000 })
|
|
1270
|
+
* .hooks({
|
|
1271
|
+
* before: {
|
|
1272
|
+
* '*': async (input, ctx) => {
|
|
1273
|
+
* console.log('Before all:', ctx.requestId)
|
|
1274
|
+
* },
|
|
1275
|
+
* 'users.*': async (input, ctx) => {
|
|
1276
|
+
* if (!ctx.auth?.authenticated) {
|
|
1277
|
+
* throw new Error('Unauthorized')
|
|
1278
|
+
* }
|
|
1279
|
+
* },
|
|
1280
|
+
* },
|
|
1281
|
+
* after: {
|
|
1282
|
+
* '*': async (input, ctx, result) => {
|
|
1283
|
+
* console.log('After all:', result)
|
|
1284
|
+
* return result
|
|
1285
|
+
* },
|
|
1286
|
+
* },
|
|
1287
|
+
* error: {
|
|
1288
|
+
* '*': async (input, ctx, error) => {
|
|
1289
|
+
* console.error('Error:', error)
|
|
1290
|
+
* throw error // re-throw or return recovery value
|
|
1291
|
+
* },
|
|
1292
|
+
* },
|
|
1293
|
+
* })
|
|
1294
|
+
* ```
|
|
1295
|
+
*/
|
|
1296
|
+
hooks(config: GlobalHooksConfig): this;
|
|
1297
|
+
/** Create a procedure builder */
|
|
1298
|
+
procedure(name: string): ProcedureBuilder;
|
|
1299
|
+
/** Create a stream builder */
|
|
1300
|
+
stream(name: string): StreamBuilder;
|
|
1301
|
+
/** Create an event builder */
|
|
1302
|
+
event(name: string): EventBuilder;
|
|
1303
|
+
/**
|
|
1304
|
+
* Create a REST resource with CRUD operations.
|
|
1305
|
+
* Dramatically reduces verbosity for REST endpoints.
|
|
1306
|
+
*
|
|
1307
|
+
* @param name - Resource name (e.g., 'users', 'posts')
|
|
1308
|
+
* @param outputSchema - Zod schema for the resource output type
|
|
1309
|
+
* @param basePath - Custom base path (defaults to `/${name}`)
|
|
1310
|
+
*
|
|
1311
|
+
* @example
|
|
1312
|
+
* ```typescript
|
|
1313
|
+
* // Before: 5 procedure definitions with .http() each
|
|
1314
|
+
* // After: One fluent chain
|
|
1315
|
+
* server.resource('users', User)
|
|
1316
|
+
* .list(async (input, ctx) => db.users.list())
|
|
1317
|
+
* .get(async (id, ctx) => db.users.findById(id))
|
|
1318
|
+
* .create(CreateUserInput, async (input, ctx) => db.users.create(input))
|
|
1319
|
+
* .update(UpdateUserInput, async (id, input, ctx) => db.users.update(id, input))
|
|
1320
|
+
* .delete(async (id, ctx) => db.users.delete(id))
|
|
1321
|
+
*
|
|
1322
|
+
* // Generates:
|
|
1323
|
+
* // GET /users → users.list
|
|
1324
|
+
* // GET /users/:id → users.get
|
|
1325
|
+
* // POST /users → users.create
|
|
1326
|
+
* // PUT /users/:id → users.update
|
|
1327
|
+
* // DELETE /users/:id → users.delete
|
|
1328
|
+
*
|
|
1329
|
+
* // Custom actions:
|
|
1330
|
+
* server.resource('users', User)
|
|
1331
|
+
* .action('import', ImportSchema, async (input) => db.users.bulkCreate(input))
|
|
1332
|
+
* .itemAction('activate', async (id) => db.users.activate(id))
|
|
1333
|
+
* // → POST /users/import
|
|
1334
|
+
* // → POST /users/:id/activate
|
|
1335
|
+
* ```
|
|
1336
|
+
*/
|
|
1337
|
+
resource<TOutput>(name: string, outputSchema?: z.ZodType<TOutput>, basePath?: string): ResourceBuilder<TOutput>;
|
|
1338
|
+
/**
|
|
1339
|
+
* Register multiple procedures from a plain object map.
|
|
1340
|
+
* More concise than chaining multiple `.procedure()` calls.
|
|
1341
|
+
*
|
|
1342
|
+
* @example
|
|
1343
|
+
* ```typescript
|
|
1344
|
+
* server.procedures({
|
|
1345
|
+
* 'users.create': {
|
|
1346
|
+
* input: CreateUserInput,
|
|
1347
|
+
* output: User,
|
|
1348
|
+
* http: '/users', // POST by default
|
|
1349
|
+
* handler: async (input) => db.users.create(input)
|
|
1350
|
+
* },
|
|
1351
|
+
* 'users.list': {
|
|
1352
|
+
* output: z.array(User),
|
|
1353
|
+
* http: ['GET', '/users'],
|
|
1354
|
+
* handler: async () => db.users.list()
|
|
1355
|
+
* },
|
|
1356
|
+
* 'users.get': {
|
|
1357
|
+
* output: User,
|
|
1358
|
+
* http: ['GET', '/users/:id'],
|
|
1359
|
+
* handler: async (input) => db.users.findById(input.id)
|
|
1360
|
+
* }
|
|
1361
|
+
* })
|
|
1362
|
+
* ```
|
|
1363
|
+
*/
|
|
1364
|
+
procedures(map: ProcedureMap): this;
|
|
1365
|
+
/**
|
|
1366
|
+
* Register multiple resources from a plain object map.
|
|
1367
|
+
* Each resource generates full CRUD endpoints.
|
|
1368
|
+
*
|
|
1369
|
+
* @example
|
|
1370
|
+
* ```typescript
|
|
1371
|
+
* server.resources({
|
|
1372
|
+
* users: {
|
|
1373
|
+
* schema: User,
|
|
1374
|
+
* list: async () => db.users.list(),
|
|
1375
|
+
* get: async (id) => db.users.findById(id),
|
|
1376
|
+
* create: {
|
|
1377
|
+
* input: CreateUserInput,
|
|
1378
|
+
* handler: async (input) => db.users.create(input)
|
|
1379
|
+
* },
|
|
1380
|
+
* update: {
|
|
1381
|
+
* input: UpdateUserInput,
|
|
1382
|
+
* handler: async (id, input) => db.users.update(id, input)
|
|
1383
|
+
* },
|
|
1384
|
+
* delete: async (id) => db.users.delete(id)
|
|
1385
|
+
* },
|
|
1386
|
+
* posts: {
|
|
1387
|
+
* schema: Post,
|
|
1388
|
+
* list: async () => db.posts.list(),
|
|
1389
|
+
* get: async (id) => db.posts.findById(id)
|
|
1390
|
+
* }
|
|
1391
|
+
* })
|
|
1392
|
+
* ```
|
|
1393
|
+
*/
|
|
1394
|
+
resources(map: ResourceMap): this;
|
|
1395
|
+
/** Register procedure directly (backwards compatible) */
|
|
1396
|
+
procedure(name: string, handler: ProcedureHandler, options?: {
|
|
1397
|
+
description?: string;
|
|
1398
|
+
interceptors?: Interceptor[];
|
|
1399
|
+
}): void;
|
|
1400
|
+
/**
|
|
1401
|
+
* Register an HTTP GET route.
|
|
1402
|
+
* Creates a procedure with the path as name (e.g., `get:/users/:id`).
|
|
1403
|
+
*
|
|
1404
|
+
* @example
|
|
1405
|
+
* ```typescript
|
|
1406
|
+
* // Simple route
|
|
1407
|
+
* server.get('/users', async (input, ctx) => {
|
|
1408
|
+
* return { users: await db.users.list() }
|
|
1409
|
+
* })
|
|
1410
|
+
*
|
|
1411
|
+
* // With path parameters
|
|
1412
|
+
* server.get('/users/:id', async (input, ctx) => {
|
|
1413
|
+
* return await db.users.findById(ctx.params.id)
|
|
1414
|
+
* })
|
|
1415
|
+
*
|
|
1416
|
+
* // With options
|
|
1417
|
+
* server.get('/users', {
|
|
1418
|
+
* input: z.object({ page: z.number().optional() }),
|
|
1419
|
+
* output: z.array(UserSchema),
|
|
1420
|
+
* summary: 'List all users',
|
|
1421
|
+
* }, async (input, ctx) => {
|
|
1422
|
+
* return await db.users.list(input.page)
|
|
1423
|
+
* })
|
|
1424
|
+
* ```
|
|
1425
|
+
*/
|
|
1426
|
+
get(path: string, handler: HttpRouteHandler): this;
|
|
1427
|
+
get(path: string, options: HttpRouteOptions, handler: HttpRouteHandler): this;
|
|
1428
|
+
/**
|
|
1429
|
+
* Register an HTTP POST route.
|
|
1430
|
+
*
|
|
1431
|
+
* @example
|
|
1432
|
+
* ```typescript
|
|
1433
|
+
* server.post('/users', {
|
|
1434
|
+
* input: CreateUserSchema,
|
|
1435
|
+
* output: UserSchema,
|
|
1436
|
+
* }, async (input, ctx) => {
|
|
1437
|
+
* return await db.users.create(input)
|
|
1438
|
+
* })
|
|
1439
|
+
* ```
|
|
1440
|
+
*/
|
|
1441
|
+
post(path: string, handler: HttpRouteHandler): this;
|
|
1442
|
+
post(path: string, options: HttpRouteOptions, handler: HttpRouteHandler): this;
|
|
1443
|
+
/**
|
|
1444
|
+
* Register an HTTP PUT route.
|
|
1445
|
+
*/
|
|
1446
|
+
put(path: string, handler: HttpRouteHandler): this;
|
|
1447
|
+
put(path: string, options: HttpRouteOptions, handler: HttpRouteHandler): this;
|
|
1448
|
+
/**
|
|
1449
|
+
* Register an HTTP PATCH route.
|
|
1450
|
+
*/
|
|
1451
|
+
patch(path: string, handler: HttpRouteHandler): this;
|
|
1452
|
+
patch(path: string, options: HttpRouteOptions, handler: HttpRouteHandler): this;
|
|
1453
|
+
/**
|
|
1454
|
+
* Register an HTTP DELETE route.
|
|
1455
|
+
*/
|
|
1456
|
+
delete(path: string, handler: HttpRouteHandler): this;
|
|
1457
|
+
delete(path: string, options: HttpRouteOptions, handler: HttpRouteHandler): this;
|
|
1458
|
+
/**
|
|
1459
|
+
* Register an HTTP OPTIONS route.
|
|
1460
|
+
*/
|
|
1461
|
+
options(path: string, handler: HttpRouteHandler): this;
|
|
1462
|
+
options(path: string, options: HttpRouteOptions, handler: HttpRouteHandler): this;
|
|
1463
|
+
/**
|
|
1464
|
+
* Register an HTTP HEAD route.
|
|
1465
|
+
*/
|
|
1466
|
+
head(path: string, handler: HttpRouteHandler): this;
|
|
1467
|
+
head(path: string, options: HttpRouteOptions, handler: HttpRouteHandler): this;
|
|
1468
|
+
/** Create a handler group with shared middleware */
|
|
1469
|
+
group(prefix: string): GroupBuilder;
|
|
1470
|
+
/** Mount a router module with an additional prefix */
|
|
1471
|
+
mount(prefix: string, module: RouterModule, options?: MountOptions): this;
|
|
1472
|
+
/**
|
|
1473
|
+
* Add a procedure handler programmatically.
|
|
1474
|
+
* Compatible with LoadedRoute from discovery.
|
|
1475
|
+
*
|
|
1476
|
+
* @example
|
|
1477
|
+
* ```typescript
|
|
1478
|
+
* server.addProcedure({
|
|
1479
|
+
* name: 'users.get',
|
|
1480
|
+
* handler: async (input, ctx) => db.users.find(input.id),
|
|
1481
|
+
* inputSchema: z.object({ id: z.string() }),
|
|
1482
|
+
* })
|
|
1483
|
+
*
|
|
1484
|
+
* // Or from discovery:
|
|
1485
|
+
* const result = await loadDiscovery({ discovery: true })
|
|
1486
|
+
* for (const route of result.routes) {
|
|
1487
|
+
* if (route.kind === 'procedure') server.addProcedure(route)
|
|
1488
|
+
* }
|
|
1489
|
+
* ```
|
|
1490
|
+
*/
|
|
1491
|
+
addProcedure(input: AddProcedureInput | LoadedRoute): this;
|
|
1492
|
+
/**
|
|
1493
|
+
* Add a stream handler programmatically.
|
|
1494
|
+
*/
|
|
1495
|
+
addStream(input: AddStreamInput | LoadedRoute): this;
|
|
1496
|
+
/**
|
|
1497
|
+
* Add an event handler programmatically.
|
|
1498
|
+
*/
|
|
1499
|
+
addEvent(input: AddEventInput | LoadedRoute): this;
|
|
1500
|
+
/**
|
|
1501
|
+
* Add a channel configuration.
|
|
1502
|
+
* Channels are for WebSocket pub/sub.
|
|
1503
|
+
*/
|
|
1504
|
+
addChannel(channel: LoadedChannel): this;
|
|
1505
|
+
/**
|
|
1506
|
+
* Add a REST resource (auto-CRUD from schema).
|
|
1507
|
+
* Generates standard CRUD endpoints.
|
|
1508
|
+
*
|
|
1509
|
+
* @example
|
|
1510
|
+
* ```typescript
|
|
1511
|
+
* const result = await loadRestResources({ restDir: './src/rest' })
|
|
1512
|
+
* for (const resource of result.resources) {
|
|
1513
|
+
* server.addRest(resource)
|
|
1514
|
+
* }
|
|
1515
|
+
* ```
|
|
1516
|
+
*/
|
|
1517
|
+
addRest(resource: LoadedRestResource): this;
|
|
1518
|
+
/**
|
|
1519
|
+
* Add a resource handler (explicit handlers).
|
|
1520
|
+
* Each resource file exports specific handlers.
|
|
1521
|
+
*
|
|
1522
|
+
* @example
|
|
1523
|
+
* ```typescript
|
|
1524
|
+
* const result = await loadResources({ resourcesDir: './src/resources' })
|
|
1525
|
+
* for (const resource of result.resources) {
|
|
1526
|
+
* server.addResource(resource)
|
|
1527
|
+
* }
|
|
1528
|
+
* ```
|
|
1529
|
+
*/
|
|
1530
|
+
addResource(resource: LoadedResource): this;
|
|
1531
|
+
/**
|
|
1532
|
+
* Add a TCP handler.
|
|
1533
|
+
* TCP handlers have full control over socket lifecycle.
|
|
1534
|
+
*
|
|
1535
|
+
* @example
|
|
1536
|
+
* ```typescript
|
|
1537
|
+
* const result = await loadTcpHandlers({ tcpDir: './src/tcp' })
|
|
1538
|
+
* for (const handler of result.handlers) {
|
|
1539
|
+
* server.addTcpHandler(handler)
|
|
1540
|
+
* }
|
|
1541
|
+
* ```
|
|
1542
|
+
*/
|
|
1543
|
+
addTcpHandler(handler: LoadedTcpHandler): this;
|
|
1544
|
+
/**
|
|
1545
|
+
* Add a UDP handler.
|
|
1546
|
+
* UDP handlers receive datagrams and can respond.
|
|
1547
|
+
*
|
|
1548
|
+
* @example
|
|
1549
|
+
* ```typescript
|
|
1550
|
+
* const result = await loadUdpHandlers({ udpDir: './src/udp' })
|
|
1551
|
+
* for (const handler of result.handlers) {
|
|
1552
|
+
* server.addUdpHandler(handler)
|
|
1553
|
+
* }
|
|
1554
|
+
* ```
|
|
1555
|
+
*/
|
|
1556
|
+
addUdpHandler(handler: LoadedUdpHandler): this;
|
|
1557
|
+
/**
|
|
1558
|
+
* Add all handlers from a discovery result.
|
|
1559
|
+
* Convenience method for bulk registration.
|
|
1560
|
+
*
|
|
1561
|
+
* @example
|
|
1562
|
+
* ```typescript
|
|
1563
|
+
* const result = await loadDiscovery({ discovery: true })
|
|
1564
|
+
* server.addDiscovery(result)
|
|
1565
|
+
* ```
|
|
1566
|
+
*/
|
|
1567
|
+
addDiscovery(result: DiscoveryResult): this;
|
|
1568
|
+
/** Start all configured protocols */
|
|
1569
|
+
start(): Promise<void>;
|
|
1570
|
+
/** Stop all protocols */
|
|
1571
|
+
stop(): Promise<void>;
|
|
1572
|
+
/** Restart all protocols */
|
|
1573
|
+
restart(): Promise<void>;
|
|
1574
|
+
/**
|
|
1575
|
+
* HTTP protocol namespace for Hono-style route registration.
|
|
1576
|
+
* Provides a chainable API for defining HTTP routes.
|
|
1577
|
+
*
|
|
1578
|
+
* @example
|
|
1579
|
+
* ```typescript
|
|
1580
|
+
* server.http
|
|
1581
|
+
* .get('/users', async (input, ctx) => db.users.list())
|
|
1582
|
+
* .get('/users/:id', async (input, ctx) => db.users.findById(ctx.params.id))
|
|
1583
|
+
* .post('/users', { input: CreateUserSchema }, async (input, ctx) => db.users.create(input))
|
|
1584
|
+
* .delete('/users/:id', async (input, ctx) => db.users.delete(ctx.params.id))
|
|
1585
|
+
* ```
|
|
1586
|
+
*/
|
|
1587
|
+
readonly http: HttpNamespace;
|
|
1588
|
+
/**
|
|
1589
|
+
* WebSocket protocol namespace for pub/sub channels.
|
|
1590
|
+
* Provides a chainable API for defining WebSocket channels and handlers.
|
|
1591
|
+
*
|
|
1592
|
+
* @example
|
|
1593
|
+
* ```typescript
|
|
1594
|
+
* server.ws
|
|
1595
|
+
* .channel('chat-room', { type: 'public' })
|
|
1596
|
+
* .channel('user-updates', { type: 'private' })
|
|
1597
|
+
* .onSubscribe(async (channel, ctx) => {
|
|
1598
|
+
* console.log(`User ${ctx.auth?.userId} subscribed to ${channel}`)
|
|
1599
|
+
* })
|
|
1600
|
+
* ```
|
|
1601
|
+
*/
|
|
1602
|
+
readonly ws: WebSocketNamespace;
|
|
1603
|
+
/**
|
|
1604
|
+
* Streams protocol namespace for SSE/EventSource.
|
|
1605
|
+
* Provides a chainable API for defining server-sent event streams.
|
|
1606
|
+
*
|
|
1607
|
+
* @example
|
|
1608
|
+
* ```typescript
|
|
1609
|
+
* server.streams
|
|
1610
|
+
* .source('events', async function*(ctx) {
|
|
1611
|
+
* while (true) {
|
|
1612
|
+
* yield { event: 'tick', data: { time: Date.now() } }
|
|
1613
|
+
* await delay(1000)
|
|
1614
|
+
* }
|
|
1615
|
+
* })
|
|
1616
|
+
* ```
|
|
1617
|
+
*/
|
|
1618
|
+
readonly streams: StreamsNamespace;
|
|
1619
|
+
/**
|
|
1620
|
+
* JSON-RPC protocol namespace for RPC methods and notifications.
|
|
1621
|
+
* Provides a chainable API for defining JSON-RPC 2.0 handlers.
|
|
1622
|
+
*
|
|
1623
|
+
* @example
|
|
1624
|
+
* ```typescript
|
|
1625
|
+
* server.rpc
|
|
1626
|
+
* .method('users.get', { input: GetUserSchema }, async (input, ctx) => {
|
|
1627
|
+
* return db.users.findById(input.id)
|
|
1628
|
+
* })
|
|
1629
|
+
* .notification('logs.write', async (data, ctx) => {
|
|
1630
|
+
* logger.info(data)
|
|
1631
|
+
* })
|
|
1632
|
+
* ```
|
|
1633
|
+
*/
|
|
1634
|
+
readonly rpc: RpcNamespace;
|
|
1635
|
+
/**
|
|
1636
|
+
* TCP protocol namespace for raw socket handlers.
|
|
1637
|
+
* Provides a chainable API for defining TCP socket handlers.
|
|
1638
|
+
* Use `tcpNs` to avoid conflict with the `tcp(options)` method that enables TCP.
|
|
1639
|
+
*
|
|
1640
|
+
* @example
|
|
1641
|
+
* ```typescript
|
|
1642
|
+
* server.tcpNs
|
|
1643
|
+
* .handler('echo', { port: 9000, framing: 'line' })
|
|
1644
|
+
* .onConnect((socket, ctx) => console.log('Connected'))
|
|
1645
|
+
* .onData((data, socket, ctx) => socket.write(data))
|
|
1646
|
+
* .onClose((socket, ctx) => console.log('Disconnected'))
|
|
1647
|
+
* .end()
|
|
1648
|
+
* ```
|
|
1649
|
+
*/
|
|
1650
|
+
readonly tcpNs: TcpNamespace;
|
|
1651
|
+
/**
|
|
1652
|
+
* UDP protocol namespace for datagram handlers.
|
|
1653
|
+
* Provides a chainable API for defining UDP message handlers.
|
|
1654
|
+
*
|
|
1655
|
+
* @example
|
|
1656
|
+
* ```typescript
|
|
1657
|
+
* server.udp
|
|
1658
|
+
* .handler('metrics', { port: 9001 })
|
|
1659
|
+
* .onMessage((msg, rinfo, ctx) => {
|
|
1660
|
+
* console.log(`Received: ${msg} from ${rinfo.address}`)
|
|
1661
|
+
* })
|
|
1662
|
+
* .end()
|
|
1663
|
+
* ```
|
|
1664
|
+
*/
|
|
1665
|
+
readonly udp: UdpNamespace;
|
|
1666
|
+
/**
|
|
1667
|
+
* gRPC protocol namespace for defining gRPC services.
|
|
1668
|
+
* Provides a chainable API for defining gRPC methods.
|
|
1669
|
+
* Use `grpcNs` to avoid conflict with the `grpc(options)` method that configures gRPC.
|
|
1670
|
+
*
|
|
1671
|
+
* @example
|
|
1672
|
+
* ```typescript
|
|
1673
|
+
* server.grpcNs
|
|
1674
|
+
* .service('UserService')
|
|
1675
|
+
* .method('GetUser', async (req, ctx) => {
|
|
1676
|
+
* return db.users.findById(req.id)
|
|
1677
|
+
* })
|
|
1678
|
+
* .end()
|
|
1679
|
+
* ```
|
|
1680
|
+
*/
|
|
1681
|
+
readonly grpcNs: GrpcNamespace;
|
|
1682
|
+
/** Get the registry */
|
|
1683
|
+
readonly registry: Registry;
|
|
1684
|
+
/** Get the router */
|
|
1685
|
+
readonly router: Router;
|
|
1686
|
+
/** Check if server is running */
|
|
1687
|
+
readonly isRunning: boolean;
|
|
1688
|
+
/** Get server addresses */
|
|
1689
|
+
readonly addresses: ServerAddresses | null;
|
|
1690
|
+
/**
|
|
1691
|
+
* Channel manager for Pusher-like pub/sub.
|
|
1692
|
+
* Only available when WebSocket is enabled with channels option.
|
|
1693
|
+
*
|
|
1694
|
+
* @example
|
|
1695
|
+
* ```typescript
|
|
1696
|
+
* // Broadcast to a channel
|
|
1697
|
+
* server.channels?.broadcast('chat-room', 'message', { text: 'Hello!' })
|
|
1698
|
+
*
|
|
1699
|
+
* // Get presence members
|
|
1700
|
+
* const members = server.channels?.getMembers('presence-lobby')
|
|
1701
|
+
*
|
|
1702
|
+
* // Kick a user from a channel
|
|
1703
|
+
* server.channels?.kick('presence-lobby', socketId)
|
|
1704
|
+
* ```
|
|
1705
|
+
*/
|
|
1706
|
+
readonly channels: ChannelManager | null;
|
|
1707
|
+
/**
|
|
1708
|
+
* Discovery watcher for hot reload.
|
|
1709
|
+
* Only available when `discovery` option is enabled.
|
|
1710
|
+
*
|
|
1711
|
+
* @example
|
|
1712
|
+
* ```typescript
|
|
1713
|
+
* // Force reload all handlers
|
|
1714
|
+
* await server.discoveryWatcher?.reload()
|
|
1715
|
+
*
|
|
1716
|
+
* // Check if watching
|
|
1717
|
+
* console.log(server.discoveryWatcher?.isWatching)
|
|
1718
|
+
* ```
|
|
1719
|
+
*/
|
|
1720
|
+
readonly discoveryWatcher: DiscoveryWatcher | null;
|
|
1721
|
+
/**
|
|
1722
|
+
* Resolved provider instances.
|
|
1723
|
+
* Available after server.start() is called.
|
|
1724
|
+
*
|
|
1725
|
+
* @example
|
|
1726
|
+
* ```typescript
|
|
1727
|
+
* await server.start()
|
|
1728
|
+
*
|
|
1729
|
+
* // Access providers directly (useful for CLI tools, scripts)
|
|
1730
|
+
* const db = server.providers.db as PrismaClient
|
|
1731
|
+
* await db.user.findMany()
|
|
1732
|
+
* ```
|
|
1733
|
+
*/
|
|
1734
|
+
readonly providers: ResolvedProviders;
|
|
1735
|
+
/**
|
|
1736
|
+
* GraphQL adapter info.
|
|
1737
|
+
* Only available when `graphql` option is enabled.
|
|
1738
|
+
*
|
|
1739
|
+
* @example
|
|
1740
|
+
* ```typescript
|
|
1741
|
+
* // Get generated schema info
|
|
1742
|
+
* console.log(server.graphql?.schemaInfo?.queries)
|
|
1743
|
+
* console.log(server.graphql?.schemaInfo?.mutations)
|
|
1744
|
+
*
|
|
1745
|
+
* // Access the GraphQL schema directly
|
|
1746
|
+
* const schema = server.graphql?.schema
|
|
1747
|
+
* ```
|
|
1748
|
+
*/
|
|
1749
|
+
readonly graphql: GraphQLAdapter | null;
|
|
1750
|
+
/**
|
|
1751
|
+
* Metrics registry for custom metrics.
|
|
1752
|
+
* Only available when `enableMetrics()` is called.
|
|
1753
|
+
*
|
|
1754
|
+
* @example
|
|
1755
|
+
* ```typescript
|
|
1756
|
+
* // Register custom metrics
|
|
1757
|
+
* server.metrics?.counter('orders_created', { labels: ['region'] })
|
|
1758
|
+
* server.metrics?.gauge('active_users')
|
|
1759
|
+
* server.metrics?.histogram('payment_amount', { buckets: [10, 50, 100, 500] })
|
|
1760
|
+
*
|
|
1761
|
+
* // Record metrics
|
|
1762
|
+
* server.metrics?.increment('orders_created', { region: 'us-east' })
|
|
1763
|
+
* server.metrics?.set('active_users', 150)
|
|
1764
|
+
* server.metrics?.observe('payment_amount', 75.50)
|
|
1765
|
+
*
|
|
1766
|
+
* // Timer helper
|
|
1767
|
+
* const end = server.metrics?.timer('db_query_duration_seconds')
|
|
1768
|
+
* await database.query(...)
|
|
1769
|
+
* end?.()
|
|
1770
|
+
* ```
|
|
1771
|
+
*/
|
|
1772
|
+
readonly metrics: MetricRegistry | null;
|
|
1773
|
+
/**
|
|
1774
|
+
* Tracer for distributed tracing.
|
|
1775
|
+
* Only available when `enableTracing()` is called.
|
|
1776
|
+
*
|
|
1777
|
+
* @example
|
|
1778
|
+
* ```typescript
|
|
1779
|
+
* // Manual span creation
|
|
1780
|
+
* const span = server.tracer?.startSpan('custom-operation')
|
|
1781
|
+
* span?.setAttribute('key', 'value')
|
|
1782
|
+
* // ... do work ...
|
|
1783
|
+
* span?.finish()
|
|
1784
|
+
*
|
|
1785
|
+
* // Extract/inject trace context
|
|
1786
|
+
* const headers = server.tracer?.injectContext(span!.context)
|
|
1787
|
+
* const context = server.tracer?.extractContext(headers!)
|
|
1788
|
+
* ```
|
|
1789
|
+
*/
|
|
1790
|
+
readonly tracer: Tracer | null;
|
|
1791
|
+
}
|
|
1792
|
+
/**
|
|
1793
|
+
* USD (Universal Service Documentation) configuration.
|
|
1794
|
+
*
|
|
1795
|
+
* USD extends OpenAPI 3.1 with the x-usd namespace for multi-protocol support.
|
|
1796
|
+
*/
|
|
1797
|
+
export interface USDDocsConfig {
|
|
1798
|
+
/** Base path for documentation endpoints (default: '/docs') */
|
|
1799
|
+
basePath?: string;
|
|
1800
|
+
/** API information */
|
|
1801
|
+
info?: {
|
|
1802
|
+
title?: string;
|
|
1803
|
+
version?: string;
|
|
1804
|
+
description?: string;
|
|
1805
|
+
termsOfService?: string;
|
|
1806
|
+
contact?: {
|
|
1807
|
+
name?: string;
|
|
1808
|
+
url?: string;
|
|
1809
|
+
email?: string;
|
|
1810
|
+
};
|
|
1811
|
+
license?: {
|
|
1812
|
+
name: string;
|
|
1813
|
+
url?: string;
|
|
1814
|
+
identifier?: string;
|
|
1815
|
+
};
|
|
1816
|
+
summary?: string;
|
|
1817
|
+
};
|
|
1818
|
+
/** Server definitions */
|
|
1819
|
+
servers?: USDServer[];
|
|
1820
|
+
/** Protocols to include (auto-detected if not specified) */
|
|
1821
|
+
protocols?: USDProtocol[];
|
|
1822
|
+
/** Security schemes */
|
|
1823
|
+
securitySchemes?: Record<string, USDSecurityScheme>;
|
|
1824
|
+
/** Default security requirement */
|
|
1825
|
+
defaultSecurity?: Array<Record<string, string[]>>;
|
|
1826
|
+
/** Tags for grouping */
|
|
1827
|
+
tags?: USDTag[];
|
|
1828
|
+
/** External documentation */
|
|
1829
|
+
externalDocs?: USDExternalDocs;
|
|
1830
|
+
/** UI configuration */
|
|
1831
|
+
ui?: {
|
|
1832
|
+
/** Theme preference */
|
|
1833
|
+
theme?: 'light' | 'dark' | 'auto';
|
|
1834
|
+
/** Primary color for UI */
|
|
1835
|
+
primaryColor?: string;
|
|
1836
|
+
/** Logo URL */
|
|
1837
|
+
logo?: string;
|
|
1838
|
+
/** Enable "Try It Out" feature */
|
|
1839
|
+
tryItOut?: boolean;
|
|
1840
|
+
/** Code generation options */
|
|
1841
|
+
codeGeneration?: {
|
|
1842
|
+
enabled?: boolean;
|
|
1843
|
+
languages?: ('typescript' | 'python' | 'go' | 'curl')[];
|
|
1844
|
+
};
|
|
1845
|
+
};
|
|
1846
|
+
/** Include standard error schemas */
|
|
1847
|
+
includeErrorSchemas?: boolean;
|
|
1848
|
+
/** Include stream event schemas */
|
|
1849
|
+
includeStreamEventSchemas?: boolean;
|
|
1850
|
+
/** JSON-RPC generation options */
|
|
1851
|
+
jsonrpc?: {
|
|
1852
|
+
endpoint?: string;
|
|
1853
|
+
version?: '2.0';
|
|
1854
|
+
batch?: {
|
|
1855
|
+
enabled?: boolean;
|
|
1856
|
+
maxSize?: number;
|
|
1857
|
+
};
|
|
1858
|
+
groupByNamespace?: boolean;
|
|
1859
|
+
};
|
|
1860
|
+
/** gRPC generation options */
|
|
1861
|
+
grpc?: {
|
|
1862
|
+
package?: string;
|
|
1863
|
+
syntax?: 'proto3' | 'proto2';
|
|
1864
|
+
options?: Record<string, unknown>;
|
|
1865
|
+
serviceNameOverrides?: Record<string, {
|
|
1866
|
+
service: string;
|
|
1867
|
+
method?: string;
|
|
1868
|
+
}>;
|
|
1869
|
+
defaultServiceName?: string;
|
|
1870
|
+
};
|
|
1871
|
+
}
|
|
1872
|
+
/**
|
|
1873
|
+
* USD documentation handlers
|
|
1874
|
+
*/
|
|
1875
|
+
export interface USDDocsHandlers {
|
|
1876
|
+
/** Serve the main documentation UI */
|
|
1877
|
+
serveUI: () => Response;
|
|
1878
|
+
/** Serve USD document as JSON */
|
|
1879
|
+
serveUSD: () => Response;
|
|
1880
|
+
/** Serve USD document as YAML */
|
|
1881
|
+
serveUSDYaml: () => Response;
|
|
1882
|
+
/** Serve pure OpenAPI 3.1 JSON (for Swagger UI compatibility) */
|
|
1883
|
+
serveOpenAPI: () => Response;
|
|
1884
|
+
/** Get the USD document */
|
|
1885
|
+
getUSDDocument: () => USDDocument;
|
|
1886
|
+
/** Get the OpenAPI document */
|
|
1887
|
+
getOpenAPIDocument: () => OpenAPIDocument;
|
|
1888
|
+
}
|
|
1889
|
+
export interface ProtocolConfig {
|
|
1890
|
+
websocket?: {
|
|
1891
|
+
enabled: boolean;
|
|
1892
|
+
options: WebSocketOptions;
|
|
1893
|
+
shared: boolean;
|
|
1894
|
+
};
|
|
1895
|
+
jsonrpc?: {
|
|
1896
|
+
enabled: boolean;
|
|
1897
|
+
options: JsonRpcOptions;
|
|
1898
|
+
shared: boolean;
|
|
1899
|
+
};
|
|
1900
|
+
graphql?: {
|
|
1901
|
+
enabled: boolean;
|
|
1902
|
+
options: GraphQLOptions;
|
|
1903
|
+
shared: boolean;
|
|
1904
|
+
};
|
|
1905
|
+
tcp?: {
|
|
1906
|
+
enabled: boolean;
|
|
1907
|
+
options: TcpOptions;
|
|
1908
|
+
};
|
|
1909
|
+
grpc?: {
|
|
1910
|
+
enabled: boolean;
|
|
1911
|
+
options: GrpcOptions;
|
|
1912
|
+
};
|
|
1913
|
+
}
|
|
1914
|
+
export interface ActiveAdapters {
|
|
1915
|
+
http?: Server;
|
|
1916
|
+
websocket?: WebSocketServer;
|
|
1917
|
+
jsonrpc?: Server;
|
|
1918
|
+
tcp?: NetServer;
|
|
1919
|
+
}
|
|
1920
|
+
/**
|
|
1921
|
+
* Procedure definition as plain object.
|
|
1922
|
+
* More concise than the builder pattern for simple cases.
|
|
1923
|
+
*
|
|
1924
|
+
* @example
|
|
1925
|
+
* ```typescript
|
|
1926
|
+
* const createUser: ProcedureDef = {
|
|
1927
|
+
* input: CreateUserInput,
|
|
1928
|
+
* output: User,
|
|
1929
|
+
* http: '/users', // shorthand for POST
|
|
1930
|
+
* handler: async (input, ctx) => db.users.create(input)
|
|
1931
|
+
* }
|
|
1932
|
+
*
|
|
1933
|
+
* // Or with explicit method
|
|
1934
|
+
* const listUsers: ProcedureDef = {
|
|
1935
|
+
* input: ListInput,
|
|
1936
|
+
* output: z.array(User),
|
|
1937
|
+
* http: ['GET', '/users'], // [method, path] tuple
|
|
1938
|
+
* handler: async (input, ctx) => db.users.list(input)
|
|
1939
|
+
* }
|
|
1940
|
+
* ```
|
|
1941
|
+
*/
|
|
1942
|
+
export interface ProcedureDef<TInput = unknown, TOutput = unknown> {
|
|
1943
|
+
/** Input validation schema */
|
|
1944
|
+
input?: z.ZodType<TInput>;
|
|
1945
|
+
/** Output validation schema */
|
|
1946
|
+
output?: z.ZodType<TOutput>;
|
|
1947
|
+
/** Handler function */
|
|
1948
|
+
handler: (input: TInput, ctx: Context) => Promise<TOutput>;
|
|
1949
|
+
/**
|
|
1950
|
+
* HTTP endpoint configuration:
|
|
1951
|
+
* - string: path (defaults to POST)
|
|
1952
|
+
* - [method, path]: explicit method and path
|
|
1953
|
+
* - object: full config
|
|
1954
|
+
*/
|
|
1955
|
+
http?: string | [HttpMethod, string] | {
|
|
1956
|
+
method?: HttpMethod;
|
|
1957
|
+
path: string;
|
|
1958
|
+
};
|
|
1959
|
+
/** Short summary for docs */
|
|
1960
|
+
summary?: string;
|
|
1961
|
+
/** Longer description */
|
|
1962
|
+
description?: string;
|
|
1963
|
+
/** Tags for grouping in docs */
|
|
1964
|
+
tags?: string[];
|
|
1965
|
+
/** Interceptors/middleware */
|
|
1966
|
+
use?: Interceptor[];
|
|
1967
|
+
}
|
|
1968
|
+
/**
|
|
1969
|
+
* Map of procedure names to their definitions.
|
|
1970
|
+
*
|
|
1971
|
+
* @example
|
|
1972
|
+
* ```typescript
|
|
1973
|
+
* server.procedures({
|
|
1974
|
+
* 'users.create': {
|
|
1975
|
+
* input: CreateUserInput,
|
|
1976
|
+
* output: User,
|
|
1977
|
+
* http: '/users',
|
|
1978
|
+
* handler: async (input) => db.users.create(input)
|
|
1979
|
+
* },
|
|
1980
|
+
* 'users.list': {
|
|
1981
|
+
* output: z.array(User),
|
|
1982
|
+
* http: ['GET', '/users'],
|
|
1983
|
+
* handler: async () => db.users.list()
|
|
1984
|
+
* }
|
|
1985
|
+
* })
|
|
1986
|
+
* ```
|
|
1987
|
+
*/
|
|
1988
|
+
export type ProcedureMap = Record<string, ProcedureDef>;
|
|
1989
|
+
/**
|
|
1990
|
+
* Resource definition as plain object.
|
|
1991
|
+
* Define all CRUD operations in one place.
|
|
1992
|
+
*
|
|
1993
|
+
* @example
|
|
1994
|
+
* ```typescript
|
|
1995
|
+
* const usersResource: ResourceDef = {
|
|
1996
|
+
* schema: User,
|
|
1997
|
+
* basePath: '/users', // optional, defaults to /{name}
|
|
1998
|
+
* list: async () => db.users.list(),
|
|
1999
|
+
* get: async (id) => db.users.findById(id),
|
|
2000
|
+
* create: {
|
|
2001
|
+
* input: CreateUserInput,
|
|
2002
|
+
* handler: async (input) => db.users.create(input)
|
|
2003
|
+
* },
|
|
2004
|
+
* update: {
|
|
2005
|
+
* input: UpdateUserInput,
|
|
2006
|
+
* handler: async (id, input) => db.users.update(id, input)
|
|
2007
|
+
* },
|
|
2008
|
+
* delete: async (id) => db.users.delete(id),
|
|
2009
|
+
* actions: {
|
|
2010
|
+
* import: {
|
|
2011
|
+
* input: ImportInput,
|
|
2012
|
+
* handler: async (input) => db.users.bulkCreate(input)
|
|
2013
|
+
* }
|
|
2014
|
+
* }
|
|
2015
|
+
* }
|
|
2016
|
+
* ```
|
|
2017
|
+
*/
|
|
2018
|
+
export interface ResourceDef<TOutput = unknown> {
|
|
2019
|
+
/** Output schema for the resource */
|
|
2020
|
+
schema?: z.ZodType<TOutput>;
|
|
2021
|
+
/** Base path (defaults to /{resourceName}) */
|
|
2022
|
+
basePath?: string;
|
|
2023
|
+
/** Tags for docs */
|
|
2024
|
+
tags?: string[];
|
|
2025
|
+
/** Interceptors for all operations */
|
|
2026
|
+
use?: Interceptor[];
|
|
2027
|
+
/** GET /resources - List all */
|
|
2028
|
+
list?: ((input: unknown, ctx: Context) => Promise<TOutput[]>) | {
|
|
2029
|
+
input?: z.ZodType;
|
|
2030
|
+
handler: (input: unknown, ctx: Context) => Promise<TOutput[]>;
|
|
2031
|
+
};
|
|
2032
|
+
/** GET /resources/:id - Get one */
|
|
2033
|
+
get?: (id: string, ctx: Context) => Promise<TOutput | null>;
|
|
2034
|
+
/** POST /resources - Create */
|
|
2035
|
+
create?: ((input: unknown, ctx: Context) => Promise<TOutput>) | {
|
|
2036
|
+
input: z.ZodType;
|
|
2037
|
+
handler: (input: unknown, ctx: Context) => Promise<TOutput>;
|
|
2038
|
+
};
|
|
2039
|
+
/** PUT /resources/:id - Full update */
|
|
2040
|
+
update?: ((id: string, input: unknown, ctx: Context) => Promise<TOutput>) | {
|
|
2041
|
+
input: z.ZodType;
|
|
2042
|
+
handler: (id: string, input: unknown, ctx: Context) => Promise<TOutput>;
|
|
2043
|
+
};
|
|
2044
|
+
/** PATCH /resources/:id - Partial update */
|
|
2045
|
+
patch?: ((id: string, input: unknown, ctx: Context) => Promise<TOutput>) | {
|
|
2046
|
+
input: z.ZodType;
|
|
2047
|
+
handler: (id: string, input: unknown, ctx: Context) => Promise<TOutput>;
|
|
2048
|
+
};
|
|
2049
|
+
/** DELETE /resources/:id */
|
|
2050
|
+
delete?: (id: string, ctx: Context) => Promise<void | TOutput>;
|
|
2051
|
+
/** Custom collection actions (POST /resources/:action) */
|
|
2052
|
+
actions?: Record<string, {
|
|
2053
|
+
input?: z.ZodType;
|
|
2054
|
+
handler: (input: unknown, ctx: Context) => Promise<unknown>;
|
|
2055
|
+
}>;
|
|
2056
|
+
/** Custom item actions (POST /resources/:id/:action) */
|
|
2057
|
+
itemActions?: Record<string, ((id: string, ctx: Context) => Promise<unknown>) | {
|
|
2058
|
+
input?: z.ZodType;
|
|
2059
|
+
handler: (id: string, input: unknown, ctx: Context) => Promise<unknown>;
|
|
2060
|
+
}>;
|
|
2061
|
+
}
|
|
2062
|
+
/**
|
|
2063
|
+
* Map of resource names to their definitions.
|
|
2064
|
+
*
|
|
2065
|
+
* @example
|
|
2066
|
+
* ```typescript
|
|
2067
|
+
* server.resources({
|
|
2068
|
+
* users: {
|
|
2069
|
+
* schema: User,
|
|
2070
|
+
* list: async () => db.users.list(),
|
|
2071
|
+
* get: async (id) => db.users.findById(id),
|
|
2072
|
+
* create: {
|
|
2073
|
+
* input: CreateUserInput,
|
|
2074
|
+
* handler: async (input) => db.users.create(input)
|
|
2075
|
+
* }
|
|
2076
|
+
* },
|
|
2077
|
+
* posts: {
|
|
2078
|
+
* schema: Post,
|
|
2079
|
+
* list: async () => db.posts.list(),
|
|
2080
|
+
* get: async (id) => db.posts.findById(id)
|
|
2081
|
+
* }
|
|
2082
|
+
* })
|
|
2083
|
+
* ```
|
|
2084
|
+
*/
|
|
2085
|
+
export type ResourceMap = Record<string, ResourceDef>;
|
|
2086
|
+
/**
|
|
2087
|
+
* Input for adding a procedure handler programmatically.
|
|
2088
|
+
* Compatible with LoadedRoute from discovery.
|
|
2089
|
+
*/
|
|
2090
|
+
export interface AddProcedureInput {
|
|
2091
|
+
/** Procedure name */
|
|
2092
|
+
name: string;
|
|
2093
|
+
/** Handler function */
|
|
2094
|
+
handler: ProcedureHandler;
|
|
2095
|
+
/** Input schema (Zod) */
|
|
2096
|
+
inputSchema?: import('zod').ZodType;
|
|
2097
|
+
/** Output schema (Zod) */
|
|
2098
|
+
outputSchema?: import('zod').ZodType;
|
|
2099
|
+
/** Short summary (one-liner) */
|
|
2100
|
+
summary?: string;
|
|
2101
|
+
/** Description */
|
|
2102
|
+
description?: string;
|
|
2103
|
+
/** Tags for grouping */
|
|
2104
|
+
tags?: string[];
|
|
2105
|
+
/** GraphQL mapping */
|
|
2106
|
+
graphql?: {
|
|
2107
|
+
type: 'query' | 'mutation';
|
|
2108
|
+
};
|
|
2109
|
+
/** HTTP path override */
|
|
2110
|
+
httpPath?: string;
|
|
2111
|
+
/** HTTP method override */
|
|
2112
|
+
httpMethod?: HttpMethod;
|
|
2113
|
+
/** JSON-RPC metadata */
|
|
2114
|
+
jsonrpc?: JsonRpcMeta;
|
|
2115
|
+
/** gRPC metadata */
|
|
2116
|
+
grpc?: GrpcMeta;
|
|
2117
|
+
/** Interceptors */
|
|
2118
|
+
interceptors?: Interceptor[];
|
|
2119
|
+
}
|
|
2120
|
+
/**
|
|
2121
|
+
* Input for adding a stream handler programmatically.
|
|
2122
|
+
*/
|
|
2123
|
+
export interface AddStreamInput {
|
|
2124
|
+
/** Stream name */
|
|
2125
|
+
name: string;
|
|
2126
|
+
/** Handler function */
|
|
2127
|
+
handler: StreamHandler;
|
|
2128
|
+
/** Input schema */
|
|
2129
|
+
inputSchema?: import('zod').ZodType;
|
|
2130
|
+
/** Output schema */
|
|
2131
|
+
outputSchema?: import('zod').ZodType;
|
|
2132
|
+
/** Stream direction */
|
|
2133
|
+
direction?: StreamDirection;
|
|
2134
|
+
/** Description */
|
|
2135
|
+
description?: string;
|
|
2136
|
+
/** Interceptors */
|
|
2137
|
+
interceptors?: Interceptor[];
|
|
2138
|
+
}
|
|
2139
|
+
/**
|
|
2140
|
+
* Input for adding an event handler programmatically.
|
|
2141
|
+
*/
|
|
2142
|
+
export interface AddEventInput {
|
|
2143
|
+
/** Event name */
|
|
2144
|
+
name: string;
|
|
2145
|
+
/** Handler function */
|
|
2146
|
+
handler: EventHandler;
|
|
2147
|
+
/** Input schema */
|
|
2148
|
+
inputSchema?: import('zod').ZodType;
|
|
2149
|
+
/** Description */
|
|
2150
|
+
description?: string;
|
|
2151
|
+
/** Delivery guarantee */
|
|
2152
|
+
delivery?: 'best-effort' | 'at-least-once' | 'at-most-once';
|
|
2153
|
+
/** Retry policy (for at-least-once) */
|
|
2154
|
+
retryPolicy?: RetryPolicy;
|
|
2155
|
+
/** Deduplication window in ms (for at-most-once) */
|
|
2156
|
+
deduplicationWindow?: number;
|
|
2157
|
+
/** Interceptors */
|
|
2158
|
+
interceptors?: Interceptor[];
|
|
2159
|
+
}
|
|
2160
|
+
//# sourceMappingURL=types.d.ts.map
|