feat(registry-envelope-integration): update execute(), call, subscribe, env to return ResponseEnvelope

- OperationRegistry.execute() now returns Promise<ResponseEnvelope<TOutput>>
- Applies shared result pipeline: detect → wrap → normalize → validate
- Uses KindGuard.IsUnknown() to check if Value.Cast should be applied
- PendingRequestMap.call() returns Promise<ResponseEnvelope>
- PendingRequestMap.respond() validates envelope via isResponseEnvelope()
- CallHandler captures handler result, wraps, normalizes, validates, publishes
- CallEventSchema call.responded.output changed to ResponseEnvelopeSchema
- subscribe() yields ResponseEnvelope with isResponseEnvelope() passthrough
- OperationEnv inner functions return Promise<ResponseEnvelope>
- Tests updated for all new return types and behaviors
- 171 tests passing, build and lint clean
This commit is contained in:
2026-05-11 02:19:05 +00:00
parent e111e1b4d8
commit 3150a49578
8 changed files with 149 additions and 38 deletions

View File

@@ -1,4 +1,5 @@
import { Type, type Static, type TSchema } from "@alkdev/typebox";
import type { ResponseEnvelope } from "./response-envelope.js";
export enum OperationType {
QUERY = "query",
@@ -12,7 +13,7 @@ export interface Identity {
resources?: Record<string, string[]>
}
export type OperationEnv = Record<string, Record<string, (input: unknown) => Promise<unknown>>>
export type OperationEnv = Record<string, Record<string, (input: unknown) => Promise<ResponseEnvelope>>>
export const OperationContextSchema = Type.Object({
metadata: Type.Optional(Type.Record(Type.String(), Type.Unknown())),