UNPKG

integreat

Version:
35 lines (34 loc) 1.87 kB
import Endpoint from './Endpoint.js'; import type Schema from '../schema/Schema.js'; import type Auth from './Auth.js'; import type { Action, Response, Dispatch, HandlerDispatch, Middleware, Transporter, Adapter, Authenticator, MapOptions, EmitFn, MapTransform } from '../types.js'; import type { ServiceDef, IdentConfig } from './types.js'; export interface Resources { transporters?: Record<string, Transporter>; adapters?: Record<string, Adapter>; authenticators?: Record<string, Authenticator>; auths?: Record<string, Auth>; schemas: Map<string, Schema>; mapTransform: MapTransform; mapOptions?: MapOptions; middleware?: Middleware[]; identConfig?: IdentConfig; emit?: EmitFn; } export default class Service { #private; id: string; meta?: string; isListening: boolean; constructor({ id: serviceId, transporter: transporterId, adapters: adapterDefs, auth, meta, options, mutation, endpoints: endpointDefs, }: ServiceDef, { transporters, adapters, authenticators, auths, schemas, mapTransform, mapOptions, middleware, identConfig, emit, }: Resources); endpointFromAction(action: Action, isIncoming?: boolean): Promise<Endpoint | undefined>; preflightAction(action: Action, endpoint: Endpoint, dispatch: HandlerDispatch): Promise<Action>; mutateRequest(action: Action, endpoint: Endpoint): Promise<Action>; mutateIncomingRequest(action: Action, endpoint: Endpoint): Promise<Action>; mutateResponse(action: Action, endpoint: Endpoint): Promise<Response>; mutateIncomingResponse(action: Action, endpoint: Endpoint): Promise<Response>; send(action: Action, endpoint: Endpoint | null, dispatch: HandlerDispatch, doSetTargetService?: boolean): Promise<Response>; listen(dispatch: Dispatch): Promise<Response>; stopListening(): Promise<Response>; close(): Promise<Response>; }