/// /// /// import 'reflect-metadata'; import { IncomingHttpHeaders } from 'http'; import { ParsedUrlQuery } from 'querystring'; import { MethodRegistrationBase } from '@dbos-inc/dbos-sdk'; import { DBOSLifecycleCallback, MethodParameter } from '@dbos-inc/dbos-sdk'; export declare enum ArgRequiredOptions { REQUIRED = "REQUIRED", OPTIONAL = "OPTIONAL", DEFAULT = "DEFAULT" } export declare function requestArgValidation(methReg: MethodRegistrationBase): void; export declare function ArgRequired(target: object, propertyKey: PropertyKey, param: number): void; export declare function ArgOptional(target: object, propertyKey: PropertyKey, param: number): void; export declare function ArgDate(): (target: object, propertyKey: PropertyKey, param: number) => void; export declare function ArgVarchar(length: number): (target: object, propertyKey: PropertyKey, param: number) => void; export declare function DefaultArgRequired(ctor: T): void; export declare function DefaultArgValidate(ctor: T): void; export declare function DefaultArgOptional(ctor: T): void; export declare enum LogMasks { NONE = "NONE", HASH = "HASH", SKIP = "SKIP" } export declare const LOGGER = "log"; export declare function SkipLogging(target: object, propertyKey: PropertyKey, param: number): void; export declare function LogMask(mask: LogMasks): (target: object, propertyKey: PropertyKey, param: number) => void; export declare function logMethodArgs(methReg: MethodRegistrationBase, args: Args): Args; export declare enum APITypes { GET = "GET", POST = "POST", PUT = "PUT", PATCH = "PATCH", DELETE = "DELETE" } export declare enum ArgSources { AUTO = "AUTO",// Look both places DEFAULT = "DEFAULT",// Look in the standard place for the method BODY = "BODY",// Look in body only QUERY = "QUERY" } export interface DBOSHTTPAuthReturn { authenticatedUser: string; authenticatedRoles: string[]; } export interface DBOSHTTPReg { apiURL: string; apiType: APITypes; } export interface DBOSHTTPMethodInfo { registrations?: DBOSHTTPReg[]; } export interface DBOSHTTPArgInfo { argSource?: ArgSources; } /** * This error can be thrown by DBOS applications to indicate * the HTTP response code, in addition to the message. * Note that any error with a 'status' field can be used. */ export declare class DBOSResponseError extends Error { readonly status: number; constructor(msg: string, status?: number); } /** * HTTPRequest includes useful information from http.IncomingMessage and parsed body, * URL parameters, and parsed query string. * In essence, it is the serializable part of the request. */ export interface DBOSHTTPRequest { readonly headers?: IncomingHttpHeaders; readonly rawHeaders?: string[]; readonly params?: unknown; readonly body?: unknown; readonly rawBody?: string; readonly query?: ParsedUrlQuery; readonly querystring?: string; readonly url?: string; readonly method?: string; readonly ip?: string; readonly requestID?: string; } export declare const DBOSHTTP = "dboshttp"; export declare const WorkflowIDHeader = "dbos-idempotency-key"; export declare const RequestIDHeader = "X-Request-ID"; export declare function getOrGenerateRequestID(headers: IncomingHttpHeaders): string; export declare function isClientRequestError(e: Error): boolean; export declare class DBOSHTTPBase implements DBOSLifecycleCallback { static HTTP_OPERATION_TYPE: string; static get httpRequest(): DBOSHTTPRequest; httpApiDec(verb: APITypes, url: string): (target: object, propertyKey: string, descriptor: TypedPropertyDescriptor<(this: This, ...args: Args) => Promise>) => TypedPropertyDescriptor<(this: This, ...args: Args) => Promise>; /** Decorator indicating that the method is the target of HTTP GET operations for `url` */ getApi(url: string): (target: object, propertyKey: string, descriptor: TypedPropertyDescriptor<(this: This, ...args: Args) => Promise>) => TypedPropertyDescriptor<(this: This, ...args: Args) => Promise>; /** Decorator indicating that the method is the target of HTTP POST operations for `url` */ postApi(url: string): (target: object, propertyKey: string, descriptor: TypedPropertyDescriptor<(this: This, ...args: Args) => Promise>) => TypedPropertyDescriptor<(this: This, ...args: Args) => Promise>; /** Decorator indicating that the method is the target of HTTP PUT operations for `url` */ putApi(url: string): (target: object, propertyKey: string, descriptor: TypedPropertyDescriptor<(this: This, ...args: Args) => Promise>) => TypedPropertyDescriptor<(this: This, ...args: Args) => Promise>; /** Decorator indicating that the method is the target of HTTP PATCH operations for `url` */ patchApi(url: string): (target: object, propertyKey: string, descriptor: TypedPropertyDescriptor<(this: This, ...args: Args) => Promise>) => TypedPropertyDescriptor<(this: This, ...args: Args) => Promise>; /** Decorator indicating that the method is the target of HTTP DELETE operations for `url` */ deleteApi(url: string): (target: object, propertyKey: string, descriptor: TypedPropertyDescriptor<(this: This, ...args: Args) => Promise>) => TypedPropertyDescriptor<(this: This, ...args: Args) => Promise>; /** Parameter decorator indicating which source to use (URL, BODY, etc) for arg data */ static argSource(source: ArgSources): (target: object, propertyKey: PropertyKey, param: number) => void; protected getArgSource(arg: MethodParameter): ArgSources; logRegisteredEndpoints(): void; static argRequired(target: object, propertyKey: PropertyKey, parameterIndex: number): void; static argOptional(target: object, propertyKey: PropertyKey, parameterIndex: number): void; static argDate(): (target: object, propertyKey: PropertyKey, param: number) => void; static argVarchar(n: number): (target: object, propertyKey: PropertyKey, param: number) => void; static defaultArgRequired(ctor: T): void; static defaultArgOptional(ctor: T): void; static defaultArgValidate(ctor: T): void; } //# sourceMappingURL=dboshttp.d.ts.map