89 lines
3.0 KiB
TypeScript
89 lines
3.0 KiB
TypeScript
/// <reference types="node" />
|
|
import { IncomingHttpHeaders } from "http";
|
|
import { SyncContext } from '../store/SyncRowStore';
|
|
import { Connector, EntityDict, OakException, OpRecord } from "../types";
|
|
import { EntityDict as BaseEntityDict } from '../base-app-domain';
|
|
import { AccessConfiguration } from '../types/Configuration';
|
|
export default class SimpleConnector<ED extends EntityDict & BaseEntityDict, FrontCxt extends SyncContext<ED>> implements Connector<ED, FrontCxt> {
|
|
static ASPECT_ROUTER: string;
|
|
static BRIDGE_ROUTER: string;
|
|
static SUBSCRIBE_PATH: string;
|
|
static SOCKET_PATH: string;
|
|
static SOCKET_POINT_ROUTER: string;
|
|
static ENDPOINT_ROUTER: string;
|
|
private serverUrl;
|
|
private serverAspectUrl;
|
|
private serverBridgeUrl;
|
|
private serverSubscribePointUrl;
|
|
private configuration;
|
|
private makeException;
|
|
private timeout;
|
|
private clockDriftDuration;
|
|
constructor(configuration: AccessConfiguration, makeException: (exceptionData: any) => OakException<ED>);
|
|
getCorsHeader(): string[];
|
|
protected makeHeadersAndBody(name: string, data: any, context?: FrontCxt): Promise<{
|
|
headers: {
|
|
'oak-cxt': string;
|
|
'oak-aspect': string;
|
|
};
|
|
body: FormData;
|
|
} | {
|
|
headers: Record<string, string>;
|
|
body: string;
|
|
}>;
|
|
protected parseAspectResult(response: Response): Promise<{
|
|
result: any;
|
|
opRecords: any;
|
|
message: string | undefined;
|
|
} | {
|
|
result: ReadableStream<Uint8Array> | null;
|
|
message: string | undefined;
|
|
opRecords?: undefined;
|
|
}>;
|
|
callAspect(name: string, params: any, context?: FrontCxt): Promise<{
|
|
result: any;
|
|
opRecords: any;
|
|
message: string | undefined;
|
|
} | {
|
|
result: ReadableStream<Uint8Array> | null;
|
|
message: string | undefined;
|
|
opRecords?: undefined;
|
|
}>;
|
|
getRouter(): string;
|
|
getSocketPath(): string;
|
|
getSocketPointRouter(): string;
|
|
getSocketPoint(): Promise<{
|
|
path: any;
|
|
subscribeUrl: any;
|
|
socketUrl: any;
|
|
}>;
|
|
getEndpointRouter(): string;
|
|
parseRequest(headers: IncomingHttpHeaders, body?: any, files?: any): {
|
|
contextString: string | undefined;
|
|
aspectName: string;
|
|
data: any;
|
|
};
|
|
serializeResult(result: any, opRecords: OpRecord<ED>[], headers: IncomingHttpHeaders, body: any, rawMessage?: string): Promise<{
|
|
body: any;
|
|
headers?: Record<string, any> | undefined;
|
|
}>;
|
|
serializeException(exception: OakException<ED>, headers: IncomingHttpHeaders, body: any): {
|
|
body: {
|
|
exception: string;
|
|
};
|
|
};
|
|
getBridgeRouter(): string;
|
|
/**
|
|
* 通过本地服务器桥接访问外部资源的url
|
|
* @param url
|
|
* @param headers
|
|
*/
|
|
makeBridgeUrl(url: string, headers?: Record<string, string>): string;
|
|
parseBridgeRequestQuery(urlParams: string): {
|
|
url: string;
|
|
headers?: Record<string, string> | undefined;
|
|
};
|
|
getFullData(): Promise<{}>;
|
|
private fetchWithTimeout;
|
|
}
|