import type { QueryParameter } from '../core/HttpServer/types/QueryParameter.js'; import type { SupportedHttpMethod } from '../core/HttpServer/types/SupportedHttpMethod.js'; import type { Service } from '../core/Service/Service.impl.js'; import type { ContentType } from '../core/types/ContentType.js'; import { StatusCode } from '../core/types/StatusCode.enum.js'; import type { StreamAfterGuardHook } from '../core/types/stream/StreamAfterGuardHook.js'; import type { StreamBeforeGuardHook } from '../core/types/stream/StreamBeforeGuardHook.js'; import type { StreamDefinition } from '../core/types/stream/StreamDefinition.js'; import type { StreamDefinitionMetadataBase } from '../core/types/stream/StreamDefinitionMetadataBase.js'; import type { StreamFunction } from '../core/types/stream/StreamFunction.js'; import type { NonEmptyString } from '../helper/types/NonEmptyString.js'; import type { Infer, InferIn, Schema } from '../schema/index.js'; import type { StreamDefinitionBuilderTypes } from './StreamDefinitionBuilderTypes.js'; /** * Builds a stream definition for incremental output or aggregate stream results. * * Streams can emit typed chunks, optionally aggregate chunks into a final * payload, expose server-sent HTTP streams, invoke commands, consume other * streams, enqueue queues, and emit custom events. * * @example * ```ts * const stream = service * .getStreamBuilder('generateReport', 'Generate report progress') * .addChunkSchema(progressSchema) * .addFinalSchema(reportSchema) * .exposeAsHttpStreamEndpoint('POST', 'reports/generate') * ``` */ export declare class StreamDefinitionBuilder { private streamName; private streamDescription; private payloadSchema?; private parameterSchema?; private chunkSchema?; private finalSchema?; private validateChunk; private validateFinal; private aggregateChunks; private finalEventName?; private invokes; private streamInvokes; private emitList; private queueInvokes; private inputContentType; private inputContentEncoding; private outputContentEncoding; private httpMetadata?; private queryParameter; private tags; private summary?; private operationId?; private isSecure; private errorStatusCodes; private httpStreamProtocol?; private httpStreamingMode; private durable; private autoacknowledge; private deprecated; private hooks; private fn?; constructor(streamName: Exclude, streamDescription: string, finalEventName?: Exclude, deprecated?: boolean); /** * Declare a queue this stream handler may enqueue through its typed queue proxy. */ canEnqueue(queueName: QueueName, payloadSchema?: Payload, parameterSchema?: Parameter): StreamDefinitionBuilder>>; /** Declare a command this stream handler may invoke through its typed service proxy. */ canInvoke(serviceName: SName, serviceVersion: Version, serviceTarget: Fname, outputSchema?: Output, payloadSchema?: Payload, parameterSchema?: Parameter): StreamDefinitionBuilder, parameter: InferIn) => Promise>>>>, C['StreamInvokes'], C['EmitList'], C['QueueInvokes']>>; /** * Declare a stream this stream handler may consume through its typed stream proxy. * * @example * ```ts * stream.canConsumeStream( * 'reports', * '1', * 'extractPages', * pageChunkSchema, * requestSchema, * undefined, * summarySchema, * ) * ``` */ canConsumeStream(serviceName: SName, serviceVersion: Version, serviceTarget: Fname, chunkSchema?: Chunk, payloadSchema?: Payload, parameterSchema?: Parameter, finalSchema?: Final, validateChunk?: boolean, validateFinal?: boolean): StreamDefinitionBuilder, parameter: InferIn) => Promise<{ sessionId: string; cancel(reason?: string): Promise; [Symbol.asyncIterator](): AsyncIterator<{ payload: { chunk?: Infer; final?: Infer; }; }>; }>>>>, C['EmitList'], C['QueueInvokes']>>; /** Declare a custom event this stream handler may emit. */ canEmit(eventName: EventName, schema: T): StreamDefinitionBuilder>, C['QueueInvokes']>>; /** * Set one or more before guard hook(s). * If there are multiple before guard hooks, they are executed in parallel. */ setBeforeGuardHooks(beforeGuards: Record, Infer, Infer, Infer, C['Resources'], C['Invokes'], C['StreamInvokes'], C['EmitList'], C['QueueInvokes']>>): this; /** * Return a previously registered before-guard hook by name. */ getBeforeGuardHook(name: keyof typeof this.hooks.beforeGuard): StreamBeforeGuardHook, Infer, Infer, Infer, C['Resources'], C['Invokes'], C['StreamInvokes'], C['EmitList'], C['QueueInvokes']>; /** * Set one or more after guard hook(s). * If there are multiple after guard hooks, they are executed in parallel. */ setAfterGuardHooks(afterGuards: Record, Infer, Infer, Infer, InferIn, C['Resources'], C['Invokes'], C['StreamInvokes'], C['EmitList'], C['QueueInvokes']>>): this; /** * Return a previously registered after-guard hook by name. */ getAfterGuardHook(name: keyof typeof this.hooks.afterGuard): StreamAfterGuardHook, Infer, Infer, Infer, InferIn, C['Resources'], C['Invokes'], C['StreamInvokes'], C['EmitList'], C['QueueInvokes']>; /** Add the payload schema used by stream invocation and handler input. */ addPayloadSchema(inputSchema: PayloadSchema, inputContentType?: ContentType, inputContentEncoding?: string): StreamDefinitionBuilder>; /** Add the parameter schema used by stream invocation and handler input. */ addParameterSchema(parameterSchema: ParamsSchema): StreamDefinitionBuilder>; /** Add the schema used to validate each stream chunk written by the handler. */ addChunkSchema(chunkSchema: ChunkSchema, validateChunks?: boolean): StreamDefinitionBuilder>; /** Add the schema used to validate the final stream payload. */ addFinalSchema(finalSchema: FinalSchema, validateFinal?: boolean): StreamDefinitionBuilder>; /** Mark this stream definition as deprecated in generated metadata. */ markAsDeprecated(): this; /** * Enable or disable default aggregation of chunks into the final payload. * * @example * ```ts * stream.enableChunkAggregation(false) * ``` */ enableChunkAggregation(enabled?: boolean): this; /** Set a custom event name emitted for successful final stream output. */ setFinalEventName(eventName: NonEmptyString): this; /** * Expose this stream as an HTTP stream endpoint. * * @example * ```ts * stream * .exposeAsHttpStreamEndpoint('POST', 'reports/generate') * .setHttpStreamingMode('stream') * .makeEndpointPublic() * ``` */ exposeAsHttpStreamEndpoint(method: SupportedHttpMethod, path: string, contentTypeRequest?: ContentType, contentEncodingRequest?: string): this; /** Set stream protocol metadata for generated OpenAPI/HTTP exposure. */ setHttpStreamProtocol(protocol: string, documentationUrl?: string): this; /** Choose whether HTTP exposure returns chunks or an aggregate JSON response. */ setHttpStreamingMode(mode: 'stream' | 'aggregate'): this; /** Mark the HTTP stream endpoint public in generated security metadata. */ makeEndpointPublic(): this; /** Enable or disable generated HTTP security metadata. */ enableHttpSecurity(enabled?: boolean): this; /** Set the OpenAPI summary for HTTP stream exposure. */ setOpenApiSummary(summary: string): this; /** Add OpenAPI tags for HTTP stream exposure. */ addOpenApiTags(...tags: string[]): this; /** Set the OpenAPI operation id for HTTP stream exposure. */ setOpenApiOperationId(operationId: string): this; /** Add non-default OpenAPI error status codes for HTTP stream exposure. */ addOpenApiErrorStatusCodes(...codes: StatusCode[]): this; /** Add query parameter metadata for HTTP stream exposure. */ addQueryParameters(...queryParams: QueryParameter>[]): this; /** * Set the stream handler implementation. * * Use a function declaration so PURISTA can bind the service instance as * `this` when executing the handler. */ setStreamFunction(fn: StreamFunction, Infer, Infer, Infer, InferIn, InferIn, C['Resources'], C['Invokes'], C['StreamInvokes'], C['EmitList'], C['QueueInvokes']>): this; /** Return the configured stream handler implementation. */ getStreamFunction(): StreamFunction, Infer, Infer, Infer, InferIn, InferIn, C['Resources'], C['Invokes'], C['StreamInvokes'], C['EmitList'], C['QueueInvokes']>; /** Resolve this builder into the stream definition consumed by a service. */ getDefinition(): Promise, Infer, Infer, Infer, InferIn, InferIn, C["Resources"], C["Invokes"], C["StreamInvokes"], C["EmitList"], StreamDefinitionMetadataBase, C["QueueInvokes"]>>; } //# sourceMappingURL=StreamDefinitionBuilder.impl.d.ts.map