refactor: unify streaming
Build Test / test (pull_request) Successful in 26s
JS Unit Tests / test (pull_request) Successful in 27s
PHP Unit Tests / test (pull_request) Successful in 1m8s

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-03-06 22:53:08 -05:00
parent 5bfe5dd249
commit cceaf809d9
10 changed files with 205 additions and 130 deletions
+41
View File
@@ -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
View File
@@ -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> {}
+6 -2
View File
@@ -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;
}
/**