/** * This is a base class that represents the common interface between the * following HTTP transaction types: * - incoming requests * - outgoing responses * - outgoing requests * - incoming responses * * This class is useful as a means of consolidating the common logic between * these four transaction types. Things such as HTTP headers, status codes, * connection state, and so on. */ import Logger, { LogLevel } from '@fc3/logger'; import { ConnectionStatus } from '@fc3/network'; import ExecutionContext from '@fc3/execution-context'; import { TagMap } from '@fc3/metrics'; import HeaderMap from './type/header-map'; import HttpMethod from './enum/method'; import HttpHeader from './enum/header'; import ContentType from './enum/content-type'; import LogAttributes from './type/log-attributes'; import TransactionData from './type/transaction-data'; declare abstract class Transaction { private execution_context; private path; private data; private headers; private method; private body; private id; private connection_status; private start_time; private end_time; private logging_disabled; constructor(execution_context?: ExecutionContext); setPath(path: string): this; getPath(): string; getUrl(): string; setData(data: TransactionData): this; setBody(body: Buffer): this; getBody(): Buffer; setHeaders(headers: HeaderMap): this; getHeaders(): HeaderMap; getContentType(): ContentType | void; setContentType(content_type: ContentType): this; getHeaderValue(key: HttpHeader): string | undefined; setHeaderValue(key: HttpHeader, value: string | number): this; setMethod(method: HttpMethod): this; getMethod(): HttpMethod; getConnectionStatus(): ConnectionStatus; setConnectionStatus(connection_status: ConnectionStatus): this; getRequestId(): string; log(): void; getLogger(): Logger; getId(): string; getExecutionContext(): ExecutionContext; setExecutionContext(execution_context: ExecutionContext): this; disableLogging(): this; getData(): TransactionData; protected hasData(): boolean; protected hasBody(): boolean; protected getBodyAsString(): string; protected appendToBody(data: Buffer): void; protected hasHeaderValue(key: HttpHeader): boolean; protected createExecutionContext(): ExecutionContext; protected getDuration(): number; protected hasEnded(): boolean; protected end(): void; protected getSanitizedUrl(): string; protected loggingIsDisabled(): boolean; private dispatchMetrics; private dispatchCountMetric; private dispatchTimingMetric; private getLogMessage; private stripHeaderParameter; private markEndTime; private getStartTime; private getEndTime; protected abstract getLogAttributes(): LogAttributes; protected abstract getLogLevel(): LogLevel; protected abstract getMetricTags(): TagMap; protected abstract getCountMetricName(): string; protected abstract getTimingMetricName(): string; } export default Transaction;