@olane/o-core 0.7.12-alpha.23 → 0.7.12-alpha.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,5 +4,6 @@ export interface ConnectionSendParams {
4
4
  [key: string]: unknown;
5
5
  };
6
6
  id?: string;
7
+ isStream?: boolean;
7
8
  }
8
9
  //# sourceMappingURL=connection-send-params.interface.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"connection-send-params.interface.d.ts","sourceRoot":"","sources":["../../../../src/connection/interfaces/connection-send-params.interface.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE;QACP,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACxB,CAAC;IACF,EAAE,CAAC,EAAE,MAAM,CAAC;CACb"}
1
+ {"version":3,"file":"connection-send-params.interface.d.ts","sourceRoot":"","sources":["../../../../src/connection/interfaces/connection-send-params.interface.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE;QACP,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACxB,CAAC;IACF,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB"}
@@ -13,5 +13,6 @@ export interface oConnectionConfig {
13
13
  * Default: 30000 (30 seconds)
14
14
  */
15
15
  drainTimeoutMs?: number;
16
+ isStream?: boolean;
16
17
  }
17
18
  //# sourceMappingURL=connection.config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"connection.config.d.ts","sourceRoot":"","sources":["../../../../src/connection/interfaces/connection.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAErD,MAAM,WAAW,iBAAiB;IAChC,cAAc,EAAE,QAAQ,CAAC;IACzB,aAAa,CAAC,EAAE,QAAQ,CAAC;IACzB,OAAO,EAAE,QAAQ,CAAC;IAClB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB"}
1
+ {"version":3,"file":"connection.config.d.ts","sourceRoot":"","sources":["../../../../src/connection/interfaces/connection.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAErD,MAAM,WAAW,iBAAiB;IAChC,cAAc,EAAE,QAAQ,CAAC;IACzB,aAAa,CAAC,EAAE,QAAQ,CAAC;IACzB,OAAO,EAAE,QAAQ,CAAC;IAClB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB"}
@@ -4,13 +4,16 @@ import { oResponse } from './o-response.js';
4
4
  import { ConnectionSendParams } from './interfaces/connection-send-params.interface.js';
5
5
  import { oObject } from '../core/o-object.js';
6
6
  import { oConnectionConfig } from './interfaces/connection.config.js';
7
+ import { EventEmitter } from 'events';
7
8
  export declare abstract class oConnection extends oObject {
8
9
  protected readonly config: oConnectionConfig;
9
10
  readonly id: string;
10
11
  readonly address: oAddress;
11
12
  readonly nextHopAddress: oAddress;
12
13
  readonly callerAddress: oAddress | undefined;
14
+ protected readonly emitter: EventEmitter;
13
15
  constructor(config: oConnectionConfig);
16
+ onChunk(listener: (response: oResponse) => void): void;
14
17
  validate(): void;
15
18
  createRequest(method: string, params: ConnectionSendParams): oRequest;
16
19
  abstract transmit(request: oRequest): Promise<oResponse>;
@@ -1 +1 @@
1
- {"version":3,"file":"o-connection.d.ts","sourceRoot":"","sources":["../../../src/connection/o-connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAA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C;AAEtC,8BAAsB,WAAY,SAAQ,OAAO;IAOnC,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,iBAAiB;IANxD,SAAgB,EAAE,EAAE,MAAM,CAAC;IAC3B,SAAgB,OAAO,EAAE,QAAQ,CAAC;IAClC,SAAgB,cAAc,EAAE,QAAQ,CAAC;IACzC,SAAgB,aAAa,EAAE,QAAQ,GAAG,SAAS,CAAC;IACpD,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAsB;gBAE/B,MAAM,EAAE,iBAAiB;IAgBxD,OAAO,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,SAAS,KAAK,IAAI;IAI/C,QAAQ,IAAI,IAAI;IAMhB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,oBAAoB,GAAG,QAAQ;IAcrE,QAAQ,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC;IAElD,IAAI,CAAC,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,SAAS,CAAC;IAMpD,KAAK;CAGZ"}
@@ -2,10 +2,12 @@ import { oRequest } from './o-request.js';
2
2
  import { oProtocolMethods } from '@olane/o-protocol';
3
3
  import { v4 as uuidv4 } from 'uuid';
4
4
  import { oObject } from '../core/o-object.js';
5
+ import { EventEmitter } from 'events';
5
6
  export class oConnection extends oObject {
6
7
  constructor(config) {
7
8
  super();
8
9
  this.config = config;
10
+ this.emitter = new EventEmitter();
9
11
  this.id = uuidv4();
10
12
  this.address = config.address;
11
13
  this.nextHopAddress = config.nextHopAddress;
@@ -17,6 +19,9 @@ export class oConnection extends oObject {
17
19
  ']:' +
18
20
  this.id);
19
21
  }
22
+ onChunk(listener) {
23
+ this.emitter.addListener('chunk', listener);
24
+ }
20
25
  validate() {
21
26
  if (!this.address || !this.nextHopAddress || !this.callerAddress) {
22
27
  throw new Error('Connection configuration is invalid');
@@ -29,6 +34,7 @@ export class oConnection extends oObject {
29
34
  _connectionId: this.id,
30
35
  _requestMethod: method,
31
36
  _callerAddress: this.callerAddress?.value,
37
+ _isStream: this.config.isStream || false,
32
38
  ...params,
33
39
  },
34
40
  id: params.id || uuidv4(),
@@ -37,8 +43,7 @@ export class oConnection extends oObject {
37
43
  async send(data) {
38
44
  // proxy through the router tool
39
45
  const request = this.createRequest(oProtocolMethods.ROUTE, data);
40
- const result = await this.transmit(request);
41
- return result;
46
+ return this.transmit(request);
42
47
  }
43
48
  async close() {
44
49
  this.logger.debug('Closing connection...');
@@ -3,23 +3,9 @@ export declare class oResponse implements Response {
3
3
  jsonrpc: typeof JSONRPC_VERSION;
4
4
  id: RequestId;
5
5
  result: Result;
6
- isStreaming?: boolean;
7
- streamChunks?: unknown[];
8
6
  constructor(config: Result & {
9
7
  id: RequestId;
10
8
  });
11
- /**
12
- * Check if a result is a streaming result
13
- */
14
- private isStreamingResult;
15
- /**
16
- * Add a chunk to a streaming response
17
- */
18
- addChunk(chunk: unknown): void;
19
- /**
20
- * Get all accumulated chunks for a streaming response
21
- */
22
- getChunks(): unknown[];
23
9
  toJSON(): any;
24
10
  toString(): string;
25
11
  }
@@ -1 +1 @@
1
- {"version":3,"file":"o-response.d.ts","sourceRoot":"","sources":["../../../src/connection/o-response.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,SAAS,EACT,SAAS,IAAI,QAAQ,EACrB,MAAM,EAEP,MAAM,mBAAmB,CAAC;AAE3B,qBAAa,SAAU,YAAW,QAAQ;IACxC,OAAO,EAAE,OAAO,eAAe,CAAC;IAChC,EAAE,EAAE,SAAS,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IAGf,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,YAAY,CAAC,EAAE,OAAO,EAAE,CAAC;gBAEb,MAAM,EAAE,MAAM,GAAG;QAAE,EAAE,EAAE,SAAS,CAAA;KAAE;IAY9C;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAIzB;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAQ9B;;OAEG;IACH,SAAS,IAAI,OAAO,EAAE;IAItB,MAAM,IAAI,GAAG;IAQb,QAAQ,IAAI,MAAM;CAGnB"}
1
+ {"version":3,"file":"o-response.d.ts","sourceRoot":"","sources":["../../../src/connection/o-response.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,SAAS,EACT,SAAS,IAAI,QAAQ,EACrB,MAAM,EACP,MAAM,mBAAmB,CAAC;AAE3B,qBAAa,SAAU,YAAW,QAAQ;IACxC,OAAO,EAAE,OAAO,eAAe,CAAC;IAChC,EAAE,EAAE,SAAS,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;gBAEH,MAAM,EAAE,MAAM,GAAG;QAAE,EAAE,EAAE,SAAS,CAAA;KAAE;IAM9C,MAAM,IAAI,GAAG;IAQb,QAAQ,IAAI,MAAM;CAGnB"}
@@ -4,33 +4,6 @@ export class oResponse {
4
4
  this.jsonrpc = JSONRPC_VERSION;
5
5
  this.id = config.id;
6
6
  this.result = config;
7
- // Check if this is a streaming result
8
- if (this.isStreamingResult(config)) {
9
- this.isStreaming = true;
10
- this.streamChunks = [config._data];
11
- }
12
- }
13
- /**
14
- * Check if a result is a streaming result
15
- */
16
- isStreamingResult(result) {
17
- return '_streaming' in result && result._streaming === true;
18
- }
19
- /**
20
- * Add a chunk to a streaming response
21
- */
22
- addChunk(chunk) {
23
- if (!this.isStreaming) {
24
- this.isStreaming = true;
25
- this.streamChunks = [];
26
- }
27
- this.streamChunks.push(chunk);
28
- }
29
- /**
30
- * Get all accumulated chunks for a streaming response
31
- */
32
- getChunks() {
33
- return this.streamChunks || [];
34
7
  }
35
8
  toJSON() {
36
9
  return {
@@ -16,6 +16,7 @@ import { oRouter } from '../router/o-router.js';
16
16
  import { oRequest } from '../connection/o-request.js';
17
17
  import { oNotificationManager } from './lib/o-notification.manager.js';
18
18
  import { oNotificationEvent, EventFilter, NotificationHandler, Subscription } from './lib/events/index.js';
19
+ import { oConnectionConfig } from '../connection/index.js';
19
20
  export declare abstract class oCore extends oObject {
20
21
  readonly config: oCoreConfig;
21
22
  address: oAddress;
@@ -32,6 +33,15 @@ export declare abstract class oCore extends oObject {
32
33
  get isLeader(): boolean;
33
34
  get leader(): oAddress | null;
34
35
  abstract configureTransports(): any[];
36
+ useStream(address: oAddress, data: {
37
+ method?: string;
38
+ params?: {
39
+ [key: string]: any;
40
+ };
41
+ id?: string;
42
+ }, options: {
43
+ onChunk?: (chunk: oResponse) => void;
44
+ }): Promise<oResponse>;
35
45
  useDirect(address: oAddress, data?: {
36
46
  method?: string;
37
47
  params?: {
@@ -102,6 +112,8 @@ export declare abstract class oCore extends oObject {
102
112
  noRouting?: boolean;
103
113
  readTimeoutMs?: number;
104
114
  drainTimeoutMs?: number;
115
+ isStream?: boolean;
116
+ onChunk?: (chunk: oResponse) => void;
105
117
  }): Promise<oResponse>;
106
118
  abstract execute(request: oRequest): Promise<any>;
107
119
  useSelf(data?: {
@@ -117,10 +129,13 @@ export declare abstract class oCore extends oObject {
117
129
  [key: string]: any;
118
130
  };
119
131
  id?: string;
132
+ }, options?: {
133
+ isStream?: boolean;
134
+ onChunk?: (chunk: oResponse) => void;
120
135
  }): Promise<oResponse>;
121
136
  addChildNode(node: oCore): void;
122
137
  removeChildNode(node: oCore): void;
123
- abstract connect(nextHopAddress: oAddress, targetAddress: oAddress, readTimeoutMs?: number, drainTimeoutMs?: number): Promise<oConnection>;
138
+ abstract connect(config: oConnectionConfig): Promise<oConnection>;
124
139
  abstract initializeRouter(): void;
125
140
  abstract unregister(): Promise<void>;
126
141
  abstract register(): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"o-core.d.ts","sourceRoot":"","sources":["../../../src/core/o-core.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAA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,IAAI,OAAO,CAAC,IAAI,CAAC;IAyBtC,IAAI,YAAY,IAAI,WAAW,EAAE,CAEhC;IAED;;;OAGG;IACH,OAAO,CAAC,cAAc;IAmCtB,IAAI,OAAO,IAAI;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAExC;IAED,IAAI,WAAW,IAAI,MAAM,CAExB;IAED,IAAI,aAAa,IAAI,QAAQ,CAE5B;IAED,IAAI,IAAI,IAAI,QAAQ,CAEnB;IAED,IAAI,UAAU,IAAI,UAAU,EAAE,CAE7B;IAED,IAAI,MAAM,IAAI,QAAQ,GAAG,IAAI,CAE5B;IAED,IAAI,gBAAgB,IAAI,UAAU,EAAE,CAEnC;IAEK,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC;CAQ7B"}
@@ -30,6 +30,12 @@ export class oCore extends oObject {
30
30
  get leader() {
31
31
  return this.isLeader ? this.address : this.config?.leader || null;
32
32
  }
33
+ async useStream(address, data, options) {
34
+ return this.use(address, data, {
35
+ isStream: true,
36
+ onChunk: options.onChunk,
37
+ });
38
+ }
33
39
  async useDirect(address, data) {
34
40
  return this.use(address, data, { noRouting: true });
35
41
  }
@@ -109,13 +115,29 @@ export class oCore extends oObject {
109
115
  if (nextHopAddress.toStaticAddress().equals(this.address.toStaticAddress())) {
110
116
  return this.useSelf(data);
111
117
  }
112
- const connection = await this.connect(nextHopAddress, targetAddress, options?.readTimeoutMs, options?.drainTimeoutMs);
118
+ const connection = await this.connect({
119
+ nextHopAddress: nextHopAddress,
120
+ address: targetAddress,
121
+ callerAddress: this.address,
122
+ readTimeoutMs: options?.readTimeoutMs,
123
+ drainTimeoutMs: options?.drainTimeoutMs,
124
+ isStream: options?.isStream,
125
+ });
126
+ if (options?.isStream) {
127
+ connection.onChunk((response) => {
128
+ options.onChunk?.(response);
129
+ });
130
+ }
113
131
  // communicate the payload to the target node
114
132
  const response = await connection.send({
115
133
  address: targetAddress?.toString() || '',
116
134
  payload: data || {},
117
135
  id: data?.id,
118
136
  });
137
+ // we handle streaming response differently
138
+ if (options?.isStream) {
139
+ return response;
140
+ }
119
141
  // if there is an error, throw it to continue to bubble up
120
142
  if (response.result.error) {
121
143
  this.logger.error('response.result.error', JSON.stringify(response.result.error, null, 2));
@@ -157,7 +179,7 @@ export class oCore extends oObject {
157
179
  }
158
180
  return CoreUtils.buildResponse(request, result, result?.error);
159
181
  }
160
- async useChild(childAddress, data) {
182
+ async useChild(childAddress, data, options) {
161
183
  if (!this.isRunning) {
162
184
  throw new Error('Node is not running');
163
185
  }
@@ -171,7 +193,11 @@ export class oCore extends oObject {
171
193
  childAddress.setTransports(child?.transports || []);
172
194
  }
173
195
  }
174
- const connection = await this.connect(childAddress, childAddress);
196
+ const connection = await this.connect({
197
+ nextHopAddress: childAddress,
198
+ address: childAddress,
199
+ callerAddress: this.address,
200
+ });
175
201
  // communicate the payload to the target node
176
202
  const response = await connection.send({
177
203
  address: childAddress?.toString() || '',
@@ -25,6 +25,10 @@ export declare class CoreUtils {
25
25
  static phraseToSeed(phrase: string): string;
26
26
  static childAddress(parentAddress: oAddress, childAddress: oAddress): oAddress;
27
27
  static sendResponse(response: oResponse, stream: Stream): Promise<void>;
28
+ static sendStreamResponse(response: oResponse, stream: Stream): Promise<void>;
29
+ static processStream(event: any): Promise<any>;
30
+ static processStreamRequest(event: any): Promise<oRequest>;
31
+ static processStreamResponse(event: any): Promise<oResponse>;
28
32
  static toCID(data: any): Promise<CID>;
29
33
  }
30
34
  //# sourceMappingURL=core.utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"core.utils.d.ts","sourceRoot":"","sources":["../../../src/utils/core.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,MAAM,EAEP,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,4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AO,CAAC,GAAG,CAAC;CAMnD"}
@@ -1,7 +1,8 @@
1
- import { generateKeyPairFromSeed, createEd25519PeerId, } from '@olane/o-config';
1
+ import { generateKeyPairFromSeed, createEd25519PeerId, Uint8ArrayList, } from '@olane/o-config';
2
2
  import { createHash } from 'crypto';
3
3
  import { oAddress } from '../router/o-address.js';
4
4
  import { oResponse } from '../connection/o-response.js';
5
+ import { oRequest } from '../connection/o-request.js';
5
6
  import { CID } from 'multiformats';
6
7
  import * as json from 'multiformats/codecs/json';
7
8
  import { sha256 } from 'multiformats/hashes/sha2';
@@ -99,6 +100,24 @@ export class CoreUtils {
99
100
  console.error('Error sending response: ', error);
100
101
  }
101
102
  }
103
+ static async sendStreamResponse(response, stream) {
104
+ if (stream.status !== 'open') {
105
+ throw new Error('Stream is not open');
106
+ }
107
+ await stream.send(new TextEncoder().encode(response.toString()));
108
+ }
109
+ static async processStream(event) {
110
+ const bytes = event.data instanceof Uint8ArrayList ? event.data.subarray() : event.data;
111
+ return JSON.parse(new TextDecoder().decode(bytes));
112
+ }
113
+ static async processStreamRequest(event) {
114
+ const req = await CoreUtils.processStream(event);
115
+ return new oRequest(req);
116
+ }
117
+ static async processStreamResponse(event) {
118
+ const res = await CoreUtils.processStream(event);
119
+ return new oResponse(res);
120
+ }
102
121
  static async toCID(data) {
103
122
  const bytes = json.encode(data);
104
123
  const hash = await sha256.digest(bytes);
@@ -1,4 +1,3 @@
1
- import { oResponse } from '../connection/o-response.js';
2
1
  /**
3
2
  * Type guard to check if a value is an AsyncGenerator
4
3
  * @param value - The value to check
@@ -13,14 +12,6 @@ export declare function isAsyncGenerator(value: any): value is AsyncGenerator;
13
12
  * @returns Promise that resolves when iteration is complete
14
13
  */
15
14
  export declare function iterateAsyncGenerator<T>(generator: AsyncGenerator<T>, onChunk: (chunk: T) => Promise<void> | void, onError?: (error: unknown) => void): Promise<void>;
16
- /**
17
- * Create an oResponse object configured for streaming
18
- * @param connectionId - The connection ID
19
- * @param requestMethod - The request method
20
- * @param requestId - The request ID
21
- * @returns An oResponse configured for streaming
22
- */
23
- export declare function createStreamingResponse(connectionId: string, requestMethod: string, requestId: string | number): oResponse;
24
15
  /**
25
16
  * Collect all chunks from an AsyncGenerator into an array
26
17
  * Useful for testing or converting streaming responses to non-streaming
@@ -28,10 +19,4 @@ export declare function createStreamingResponse(connectionId: string, requestMet
28
19
  * @returns Promise resolving to array of all chunks
29
20
  */
30
21
  export declare function collectStreamChunks<T>(generator: AsyncGenerator<T>): Promise<T[]>;
31
- /**
32
- * Process incoming stream data (deserialize from bytes)
33
- * @param data - The data to process
34
- * @returns Parsed message object
35
- */
36
- export declare function processStream(data: Uint8Array): any;
37
22
  //# sourceMappingURL=streaming.utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"streaming.utils.d.ts","sourceRoot":"","sources":["../../../src/utils/streaming.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAExD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,cAAc,CAMpE;AAED;;;;;;GAMG;AACH,wBAAsB,qBAAqB,CAAC,CAAC,EAC3C,SAAS,EAAE,cAAc,CAAC,CAAC,CAAC,EAC5B,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,EAC3C,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,GACjC,OAAO,CAAC,IAAI,CAAC,CAYf;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,YAAY,EAAE,MAAM,EACpB,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,MAAM,GAAG,MAAM,GACzB,SAAS,CAQX;AAED;;;;;GAKG;AACH,wBAAsB,mBAAmB,CAAC,CAAC,EACzC,SAAS,EAAE,cAAc,CAAC,CAAC,CAAC,GAC3B,OAAO,CAAC,CAAC,EAAE,CAAC,CAMd;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,UAAU,GAAG,GAAG,CAGnD"}
1
+ {"version":3,"file":"streaming.utils.d.ts","sourceRoot":"","sources":["../../../src/utils/streaming.utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,cAAc,CAMpE;AAED;;;;;;GAMG;AACH,wBAAsB,qBAAqB,CAAC,CAAC,EAC3C,SAAS,EAAE,cAAc,CAAC,CAAC,CAAC,EAC5B,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,EAC3C,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,GACjC,OAAO,CAAC,IAAI,CAAC,CAYf;AAED;;;;;GAKG;AACH,wBAAsB,mBAAmB,CAAC,CAAC,EACzC,SAAS,EAAE,cAAc,CAAC,CAAC,CAAC,GAC3B,OAAO,CAAC,CAAC,EAAE,CAAC,CAMd"}
@@ -1,4 +1,3 @@
1
- import { oResponse } from '../connection/o-response.js';
2
1
  /**
3
2
  * Type guard to check if a value is an AsyncGenerator
4
3
  * @param value - The value to check
@@ -31,22 +30,6 @@ export async function iterateAsyncGenerator(generator, onChunk, onError) {
31
30
  }
32
31
  }
33
32
  }
34
- /**
35
- * Create an oResponse object configured for streaming
36
- * @param connectionId - The connection ID
37
- * @param requestMethod - The request method
38
- * @param requestId - The request ID
39
- * @returns An oResponse configured for streaming
40
- */
41
- export function createStreamingResponse(connectionId, requestMethod, requestId) {
42
- const response = new oResponse({
43
- id: requestId,
44
- _connectionId: connectionId,
45
- _requestMethod: requestMethod,
46
- });
47
- response.isStreaming = true;
48
- return response;
49
- }
50
33
  /**
51
34
  * Collect all chunks from an AsyncGenerator into an array
52
35
  * Useful for testing or converting streaming responses to non-streaming
@@ -60,12 +43,3 @@ export async function collectStreamChunks(generator) {
60
43
  }
61
44
  return chunks;
62
45
  }
63
- /**
64
- * Process incoming stream data (deserialize from bytes)
65
- * @param data - The data to process
66
- * @returns Parsed message object
67
- */
68
- export function processStream(data) {
69
- const text = new TextDecoder().decode(data);
70
- return JSON.parse(text);
71
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@olane/o-core",
3
- "version": "0.7.12-alpha.23",
3
+ "version": "0.7.12-alpha.24",
4
4
  "type": "module",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",
@@ -63,11 +63,11 @@
63
63
  "typescript": "^5.8.3"
64
64
  },
65
65
  "dependencies": {
66
- "@olane/o-protocol": "0.7.12-alpha.23",
66
+ "@olane/o-protocol": "0.7.12-alpha.24",
67
67
  "chalk": "^5.4.1",
68
68
  "debug": "^4.4.1",
69
69
  "dotenv": "^16.5.0",
70
70
  "multiformats": "^13.3.7"
71
71
  },
72
- "gitHead": "26031c23b8802d7ad89ec333f2c5c5b082333119"
72
+ "gitHead": "ac75e0acc3a0a232a5cdeb9271060d90cf1e5a2c"
73
73
  }