From 0fb36ea928ccf1a1febc7fb1515134c12058d8a1 Mon Sep 17 00:00:00 2001 From: Philipp Kunz Date: Fri, 23 Feb 2024 15:48:31 +0100 Subject: [PATCH] fix(core): update --- ts/00_commitinfo_data.ts | 2 +- ts/index.ts | 64 ++++++++++++++++++++++++++++++---------- 2 files changed, 50 insertions(+), 16 deletions(-) diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index e5e5a2e..5b8a951 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@api.global/typedrequest-interfaces', - version: '3.0.9', + version: '3.0.10', description: 'interfaces for making typed requests' } diff --git a/ts/index.ts b/ts/index.ts index ef204d2..96db224 100644 --- a/ts/index.ts +++ b/ts/index.ts @@ -17,7 +17,7 @@ export interface ITypedRequest { */ localData?: { firstTypedrouter?: any; - } + }; /** * server data that is added for dealing with the request server side. Will be omitted when sending the response @@ -76,21 +76,55 @@ export interface ITag { export type implementsTag = {}; -export interface IUnifiedStreamReqResObject { - streamId: string; - cycle: 'request' | 'response'; - cycleId: string; - type: 'start' | 'binaryChunk' | 'object' | 'end' | 'keepAlive'; - streamChunk?: any; - keepAlive?: boolean; - next?: boolean; +export interface IUnifiedStreamDataPackage { + /** + * the stream id, so Virtual Streams can talk to each other + */ + streamId: string; + + /** + * stream data is sent in cycles. This id is used to match the request and response + */ + cycleId: string; + cycle: 'request' | 'response'; + + /** + * the main purpose of the data package + * start: indicates the start of a stream + * binaryChunk: indicates a binary chunk of data + * object: indicates a json object + * end: indicates the end of a stream + * feedback: indicates a feedback message + */ + mainPurpose: 'start' | 'binaryChunk' | 'object' | 'end' | 'feedback' | 'keepAlive'; + + /** + * the data package + */ + chunkData?: any; + + /** + * feedback message + */ + feedback: { + message?: string; + data?: any; + sha265?: string; + }; + + /** + * keepAlive boolean + */ + keepAlive?: boolean; + + /** + * is there more data scheduled to be sent? + */ + next?: boolean; } -export interface IStreamRequest extends implementsTR< - ITypedRequest, - IStreamRequest -> { +export interface IStreamRequest extends implementsTR { method: '##VirtualStream##'; - request: IUnifiedStreamReqResObject; - response: IUnifiedStreamReqResObject; + request: IUnifiedStreamDataPackage; + response: IUnifiedStreamDataPackage; }