// Headers export const CONNECTION_ID_HEADER = 'X-Connection-ID'; export const WORKFLOW_ID_HEADER = 'X-Workflow-ID'; export const TASK_QUEUE_HEADER = 'X-Task-Queue'; export const CORRELATION_ID_HEADER = 'X-Correlation-ID'; export const SESSION_ID_HEADER = 'X-Session-ID'; export const VERIFICATION_HEADER = 'X-Verification-Key'; // Env export const AXIOM_AUTH_TOKEN_ENV = 'AXIOM_AUTH_TOKEN'; export const AXIOM_ORG_ID_ENV = 'AXIOM_ORG_ID'; export const AXIOM_DATASET_ENV = 'AXIOM_DATASET'; export const LOG_ENV = 'LOG'; export type LogLevel = 'info' | 'log' | 'error' | 'debug' | 'warn'; export type LogBindings = { [LOG_ENV]?: string; [AXIOM_AUTH_TOKEN_ENV]?: string; [AXIOM_ORG_ID_ENV]?: string; [AXIOM_DATASET_ENV]?: string; NODE_ENV?: string; IS_LOCAL_DEV?: string; MACHINE_NAME?: string; }; export type LogFn = (message: any, extra?: Record) => void; export type ErrorLogFn = ( message: any, errorOrExtra?: Error | unknown | Record, extra?: Record ) => void; export type LogFns = { error: ErrorLogFn; info: LogFn; debug: LogFn; warn: LogFn; }; export type Log = LogFns & { child: (data: ChildLogOptions) => Log; addContext: (data: Record) => void; }; export type ChildLogOptions = { correlationId?: string; name?: string; request?: any; context?: Record; }; type Res = | Response | { status: number; statusText?: string; headers?: Record; body?: any; response?: Response; }; export type BaseLog = Log & { flush(): Promise | void; }; export type WorkerLog = BaseLog & { respond( response: Res | Promise | (() => Res | Promise) ): Promise; }; export type RequestLike = { headers: { get: (key: string) => string | null; }; method: string; url: string; json: () => Promise; }; export type LogTags = { sessionId: string; correlationId: string; environment?: 'development' | 'production'; type?: 'worker' | 'durableObject'; workerId?: string; app?: string; version?: string; name?: string; }; export type ConsoleLogFn = (arg: { formatted: string; message: string; extra: Record; tags: LogTags; context: Record; level: LogLevel; error?: Error; }) => void; export type ConsoleLog = boolean | 'color' | ConsoleLogFn;