refactor: unify streaming
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -43,6 +43,47 @@ export interface ApiErrorResponse {
|
||||
*/
|
||||
export type ApiResponse<T = any> = ApiSuccessResponse<T> | ApiErrorResponse;
|
||||
|
||||
/**
|
||||
* Stream control start line
|
||||
*/
|
||||
export interface ApiStreamStartResponse {
|
||||
type: 'control';
|
||||
status: 'start';
|
||||
version: number;
|
||||
transaction: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stream control end line
|
||||
*/
|
||||
export interface ApiStreamEndResponse {
|
||||
type: 'control';
|
||||
status: 'end';
|
||||
total: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stream error line
|
||||
*/
|
||||
export interface ApiStreamErrorResponse {
|
||||
type: 'error';
|
||||
message: string;
|
||||
}
|
||||
|
||||
export interface ApiStreamDataResponse<T = any> {
|
||||
type: 'data';
|
||||
data: T;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shared stream control lines
|
||||
*/
|
||||
export type ApiStreamResponse<T = any> =
|
||||
| ApiStreamStartResponse
|
||||
| ApiStreamEndResponse
|
||||
| ApiStreamErrorResponse
|
||||
| ApiStreamDataResponse<T>;
|
||||
|
||||
/**
|
||||
* Selector for targeting specific providers, services, collections, or entities in list or extant operations.
|
||||
*
|
||||
|
||||
+7
-27
@@ -1,7 +1,12 @@
|
||||
/**
|
||||
* Entity type definitions
|
||||
*/
|
||||
import type { SourceSelector, ListFilter, ListSort, ListRange } from './common';
|
||||
import type {
|
||||
ListFilter,
|
||||
ListRange,
|
||||
ListSort,
|
||||
SourceSelector,
|
||||
} from './common';
|
||||
import type { MessageInterface } from './message';
|
||||
|
||||
/**
|
||||
@@ -169,29 +174,4 @@ export interface EntityStreamRequest {
|
||||
range?: ListRange;
|
||||
}
|
||||
|
||||
export interface EntityStreamMetaLine {
|
||||
type: 'meta';
|
||||
version: number;
|
||||
transaction: string;
|
||||
status: 'success';
|
||||
}
|
||||
|
||||
export interface EntityStreamEntityLine extends EntityInterface<MessageInterface> {
|
||||
type: 'entity';
|
||||
}
|
||||
|
||||
export interface EntityStreamDoneLine {
|
||||
type: 'done';
|
||||
total: number;
|
||||
}
|
||||
|
||||
export interface EntityStreamErrorLine {
|
||||
type: 'error';
|
||||
message: string;
|
||||
}
|
||||
|
||||
export type EntityStreamLine =
|
||||
| EntityStreamMetaLine
|
||||
| EntityStreamEntityLine
|
||||
| EntityStreamDoneLine
|
||||
| EntityStreamErrorLine;
|
||||
export interface EntityStreamResponse extends EntityInterface<MessageInterface> {}
|
||||
@@ -1,7 +1,10 @@
|
||||
/**
|
||||
* Service type definitions
|
||||
*/
|
||||
import type { SourceSelector, ListFilterComparisonOperator } from './common';
|
||||
import type {
|
||||
ListFilterComparisonOperator,
|
||||
SourceSelector,
|
||||
} from './common';
|
||||
|
||||
/**
|
||||
* Service capabilities
|
||||
@@ -130,7 +133,8 @@ export interface ServiceDiscoverRequest {
|
||||
}
|
||||
|
||||
export interface ServiceDiscoverResponse {
|
||||
[provider: string]: ServiceLocation; // Uses existing ServiceLocation discriminated union
|
||||
provider: string;
|
||||
location: ServiceLocation;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user