Skip to content

Commit 218bf68

Browse files
authored
Merge pull request #207 from LeoPlatform/feature/ES-2579-improve-types
ES-2579 - improve the types
2 parents 3cc96dc + 06b80eb commit 218bf68

3 files changed

Lines changed: 186 additions & 3 deletions

File tree

lib/lib.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,8 +1330,8 @@ export declare namespace StreamUtil {
13301330
* @todo question don't we already have other ways to do this? do we need this?
13311331
* @todo unclear This is a transform stream which means it can't be the sink and yet it takes an outQueue as though it's sending to another queue. Don't get it.
13321332
*/
1333-
function process<T, U>(id: string, func: ProcessFunction<T, U>, outQueue: string, onFlush?: any, opts?: any): TransformStream<T, U>
1334-
function process<T, U>(id: string, func: ProcessFunctionAsync<T, U>, outQueue: string, onFlush?: any, opts?: any): TransformStream<T, U>
1333+
function process<T, U>(id: string, func: ProcessFunction<T, U>, outQueue: string, onFlush?: any, opts?: any): TransformStream<ReadEvent<T>, U>
1334+
function process<T, U>(id: string, func: ProcessFunctionAsync<T, U>, outQueue: string, onFlush?: any, opts?: any): TransformStream<ReadEvent<T>, U>
13351335

13361336
/**
13371337
* todo document: what this functon does. Creates Correlation form read events

lib/streams.d.ts

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,99 @@ export function pipe<T1, T2, T3, T4, T5>(read: ReadableStream<T1> | stream.Strea
287287
*/
288288
export function pipe<T1, T2, T3, T4, T5, T6>(read: ReadableStream<T1> | stream.Stream, t1: TransformStream<T1, T2>, t2: TransformStream<T2, T3>, t3: TransformStream<T3, T4>, t4: TransformStream<T4, T5>, t5: TransformStream<T5, T6>, write: WritableStream<T6> | stream.Stream, errorCallback?: ErrorCallback): WritableStream<T6> | stream.Stream;
289289

290+
/**
291+
* A callback-based version of [[`pipeAsync`]]. Creates a pipeline of steps where the first step produces the data and then
292+
* it flows to the next step and so on. The first step is the source, producing the content, the final step is the sink.
293+
*
294+
* @typeParam T1 The type of data that is produced by the source
295+
* @typeParam T2 The type of data generated and that moves to the next step of the pipe
296+
* @typeParam T3 The type of data generated and that moves to the next step of the pipe
297+
* @typeParam T4 The type of data generated and that moves to the next step of the pipe
298+
* @typeParam T5 The type of data generated and that moves to the next step of the pipe
299+
* @typeParam T6 The type of data generated and that moves to the next step of the pipe
300+
* @typeParam T7 The type of data generated and that moves to the final step of the pipe
301+
*
302+
* @param read Pipeline step 1: The source that produces the data, the first step of the pipe
303+
* @param t1 Pipeline step 2: A transformation step that takes data from the previous step and pushes the result to the next step
304+
* @param t2 Pipeline step 3: A transformation step that takes data from the previous step and pushes the result to the next step
305+
* @param t3 Pipeline step 4: A transformation step that takes data from the previous step and pushes the result to the next step
306+
* @param t4 Pipeline step 5: A transformation step that takes data from the previous step and pushes the result to the next step
307+
* @param t5 Pipeline step 6: A transformation step that takes data from the previous step and pushes the result to the next step
308+
* @param t6 Pipeline step 7: A transformation step that takes data from the previous step and pushes the result to the next step
309+
* @param write Pipeline step 8: The sink that is the last step of the pipe
310+
* @param errorCallback Called if something goes wrong
311+
* @returns The pipeline itself
312+
*/
313+
export function pipe<T1, T2, T3, T4, T5, T6, T7>(read: ReadableStream<T1> | stream.Stream, t1: TransformStream<T1, T2>, t2: TransformStream<T2, T3>, t3: TransformStream<T3, T4>, t4: TransformStream<T4, T5>, t5: TransformStream<T5, T6>, t6: TransformStream<T6, T7>, write: WritableStream<T7> | stream.Stream, errorCallback?: ErrorCallback): WritableStream<T7> | stream.Stream;
314+
315+
/**
316+
* A callback-based version of [[`pipeAsync`]]. Creates a pipeline of steps where the first step produces the data and then
317+
* it flows to the next step and so on. The first step is the source, producing the content, the final step is the sink.
318+
*
319+
* @typeParam T1 The type of data that is produced by the source
320+
* @typeParam T2 The type of data generated and that moves to the next step of the pipe
321+
* @typeParam T3 The type of data generated and that moves to the next step of the pipe
322+
* @typeParam T4 The type of data generated and that moves to the next step of the pipe
323+
* @typeParam T5 The type of data generated and that moves to the next step of the pipe
324+
* @typeParam T6 The type of data generated and that moves to the next step of the pipe
325+
* @typeParam T7 The type of data generated and that moves to the next step of the pipe
326+
* @typeParam T8 The type of data generated and that moves to the final step of the pipe
327+
*
328+
* @param read Pipeline step 1: The source that produces the data, the first step of the pipe
329+
* @param t1 Pipeline step 2: A transformation step that takes data from the previous step and pushes the result to the next step
330+
* @param t2 Pipeline step 3: A transformation step that takes data from the previous step and pushes the result to the next step
331+
* @param t3 Pipeline step 4: A transformation step that takes data from the previous step and pushes the result to the next step
332+
* @param t4 Pipeline step 5: A transformation step that takes data from the previous step and pushes the result to the next step
333+
* @param t5 Pipeline step 6: A transformation step that takes data from the previous step and pushes the result to the next step
334+
* @param t6 Pipeline step 7: A transformation step that takes data from the previous step and pushes the result to the next step
335+
* @param t7 Pipeline step 8: A transformation step that takes data from the previous step and pushes the result to the next step
336+
* @param write Pipeline step 9: The sink that is the last step of the pipe
337+
* @param errorCallback Called if something goes wrong
338+
* @returns The pipeline itself
339+
*/
340+
export function pipe<T1, T2, T3, T4, T5, T6, T7, T8>(read: ReadableStream<T1> | stream.Stream, t1: TransformStream<T1, T2>, t2: TransformStream<T2, T3>, t3: TransformStream<T3, T4>, t4: TransformStream<T4, T5>, t5: TransformStream<T5, T6>, t6: TransformStream<T6, T7>, t7: TransformStream<T7, T8>, write: WritableStream<T8> | stream.Stream, errorCallback?: ErrorCallback): WritableStream<T8> | stream.Stream;
341+
342+
/**
343+
* A callback-based version of [[`pipeAsync`]]. Creates a pipeline of steps where the first step produces the data and then
344+
* it flows to the next step and so on. The first step is the source, producing the content, the final step is the sink.
345+
*
346+
* @typeParam T1 The type of data that is produced by the source
347+
* @typeParam T2 The type of data generated and that moves to the next step of the pipe
348+
* @typeParam T3 The type of data generated and that moves to the next step of the pipe
349+
* @typeParam T4 The type of data generated and that moves to the next step of the pipe
350+
* @typeParam T5 The type of data generated and that moves to the next step of the pipe
351+
* @typeParam T6 The type of data generated and that moves to the next step of the pipe
352+
* @typeParam T7 The type of data generated and that moves to the next step of the pipe
353+
* @typeParam T8 The type of data generated and that moves to the next step of the pipe
354+
* @typeParam T9 The type of data generated and that moves to the final step of the pipe
355+
*
356+
* @param read Pipeline step 1: The source that produces the data, the first step of the pipe
357+
* @param t1 Pipeline step 2: A transformation step that takes data from the previous step and pushes the result to the next step
358+
* @param t2 Pipeline step 3: A transformation step that takes data from the previous step and pushes the result to the next step
359+
* @param t3 Pipeline step 4: A transformation step that takes data from the previous step and pushes the result to the next step
360+
* @param t4 Pipeline step 5: A transformation step that takes data from the previous step and pushes the result to the next step
361+
* @param t5 Pipeline step 6: A transformation step that takes data from the previous step and pushes the result to the next step
362+
* @param t6 Pipeline step 7: A transformation step that takes data from the previous step and pushes the result to the next step
363+
* @param t7 Pipeline step 8: A transformation step that takes data from the previous step and pushes the result to the next step
364+
* @param t8 Pipeline step 9: A transformation step that takes data from the previous step and pushes the result to the next step
365+
* @param write Pipeline step 10: The sink that is the last step of the pipe
366+
* @param errorCallback Called if something goes wrong
367+
* @returns The pipeline itself
368+
*/
369+
export function pipe<T1, T2, T3, T4, T5, T6, T7, T8, T9>(read: ReadableStream<T1> | stream.Stream, t1: TransformStream<T1, T2>, t2: TransformStream<T2, T3>, t3: TransformStream<T3, T4>, t4: TransformStream<T4, T5>, t5: TransformStream<T5, T6>, t6: TransformStream<T6, T7>, t7: TransformStream<T7, T8>, t8: TransformStream<T8, T9>, write: WritableStream<T9> | stream.Stream, errorCallback?: ErrorCallback): WritableStream<T9> | stream.Stream;
370+
371+
/**
372+
* A callback-based version of [[`pipeAsync`]]. Creates a pipeline of steps where the first step produces the data and then
373+
* it flows to the next step and so on. The first step is the source, producing the content, the final step is the sink.
374+
*
375+
* This catch-all overload handles pipelines with more than 8 transform streams. For such cases, TypeScript cannot
376+
* maintain full type safety across all transformations, so the types are relaxed.
377+
*
378+
* @param streams Any number of streams (source, transforms, and sink) followed by an optional error callback
379+
* @returns The pipeline itself
380+
*/
381+
export function pipe(...streams: Array<stream.Stream | ErrorCallback>): stream.Stream;
382+
290383
/**
291384
* An async/await-friendly version of [[`pipe`]]. Creates a pipeline of steps where the first step produces the data and then
292385
* it flows to the next step and so on. The first step is the source, producing the content, the final step is the sink.
@@ -387,6 +480,96 @@ export function pipeAsync<T1, T2, T3, T4, T5>(read: ReadableStream<T1> | stream.
387480
*/
388481
export function pipeAsync<T1, T2, T3, T4, T5, T6>(read: ReadableStream<T1> | stream.Stream, t1: TransformStream<T1, T2>, t2: TransformStream<T2, T3>, t3: TransformStream<T3, T4>, t4: TransformStream<T4, T5>, t5: TransformStream<T5, T6>, write: WritableStream<T6>): Promise<void>;
389482

483+
/**
484+
* An async/await-friendly version of [[`pipe`]]. Creates a pipeline of steps where the first step produces the data and then
485+
* it flows to the next step and so on. The first step is the source, producing the content, the final step is the sink.
486+
*
487+
* @typeParam T1 The type of data that is produced by the source
488+
* @typeParam T2 The type of data generated and that moves to the next step of the pipe
489+
* @typeParam T3 The type of data generated and that moves to the next step of the pipe
490+
* @typeParam T4 The type of data generated and that moves to the next step of the pipe
491+
* @typeParam T5 The type of data generated and that moves to the next step of the pipe
492+
* @typeParam T6 The type of data generated and that moves to the next step of the pipe
493+
* @typeParam T7 The type of data generated and that moves to the final step of the pipe
494+
*
495+
* @param read Pipeline step 1: The source that produces the data, the first step of the pipe
496+
* @param t1 Pipeline step 2: A transformation step that takes data from the previous step and pushes the result to the next step
497+
* @param t2 Pipeline step 3: A transformation step that takes data from the previous step and pushes the result to the next step
498+
* @param t3 Pipeline step 4: A transformation step that takes data from the previous step and pushes the result to the next step
499+
* @param t4 Pipeline step 5: A transformation step that takes data from the previous step and pushes the result to the next step
500+
* @param t5 Pipeline step 6: A transformation step that takes data from the previous step and pushes the result to the next step
501+
* @param t6 Pipeline step 7: A transformation step that takes data from the previous step and pushes the result to the next step
502+
* @param write Pipeline step 8: The sink that is the last step of the pipe
503+
* @returns A promise so it can play nice with async/await
504+
*/
505+
export function pipeAsync<T1, T2, T3, T4, T5, T6, T7>(read: ReadableStream<T1> | stream.Stream, t1: TransformStream<T1, T2>, t2: TransformStream<T2, T3>, t3: TransformStream<T3, T4>, t4: TransformStream<T4, T5>, t5: TransformStream<T5, T6>, t6: TransformStream<T6, T7>, write: WritableStream<T7>): Promise<void>;
506+
507+
/**
508+
* An async/await-friendly version of [[`pipe`]]. Creates a pipeline of steps where the first step produces the data and then
509+
* it flows to the next step and so on. The first step is the source, producing the content, the final step is the sink.
510+
*
511+
* @typeParam T1 The type of data that is produced by the source
512+
* @typeParam T2 The type of data generated and that moves to the next step of the pipe
513+
* @typeParam T3 The type of data generated and that moves to the next step of the pipe
514+
* @typeParam T4 The type of data generated and that moves to the next step of the pipe
515+
* @typeParam T5 The type of data generated and that moves to the next step of the pipe
516+
* @typeParam T6 The type of data generated and that moves to the next step of the pipe
517+
* @typeParam T7 The type of data generated and that moves to the next step of the pipe
518+
* @typeParam T8 The type of data generated and that moves to the final step of the pipe
519+
*
520+
* @param read Pipeline step 1: The source that produces the data, the first step of the pipe
521+
* @param t1 Pipeline step 2: A transformation step that takes data from the previous step and pushes the result to the next step
522+
* @param t2 Pipeline step 3: A transformation step that takes data from the previous step and pushes the result to the next step
523+
* @param t3 Pipeline step 4: A transformation step that takes data from the previous step and pushes the result to the next step
524+
* @param t4 Pipeline step 5: A transformation step that takes data from the previous step and pushes the result to the next step
525+
* @param t5 Pipeline step 6: A transformation step that takes data from the previous step and pushes the result to the next step
526+
* @param t6 Pipeline step 7: A transformation step that takes data from the previous step and pushes the result to the next step
527+
* @param t7 Pipeline step 8: A transformation step that takes data from the previous step and pushes the result to the next step
528+
* @param write Pipeline step 9: The sink that is the last step of the pipe
529+
* @returns A promise so it can play nice with async/await
530+
*/
531+
export function pipeAsync<T1, T2, T3, T4, T5, T6, T7, T8>(read: ReadableStream<T1> | stream.Stream, t1: TransformStream<T1, T2>, t2: TransformStream<T2, T3>, t3: TransformStream<T3, T4>, t4: TransformStream<T4, T5>, t5: TransformStream<T5, T6>, t6: TransformStream<T6, T7>, t7: TransformStream<T7, T8>, write: WritableStream<T8>): Promise<void>;
532+
533+
/**
534+
* An async/await-friendly version of [[`pipe`]]. Creates a pipeline of steps where the first step produces the data and then
535+
* it flows to the next step and so on. The first step is the source, producing the content, the final step is the sink.
536+
*
537+
* @typeParam T1 The type of data that is produced by the source
538+
* @typeParam T2 The type of data generated and that moves to the next step of the pipe
539+
* @typeParam T3 The type of data generated and that moves to the next step of the pipe
540+
* @typeParam T4 The type of data generated and that moves to the next step of the pipe
541+
* @typeParam T5 The type of data generated and that moves to the next step of the pipe
542+
* @typeParam T6 The type of data generated and that moves to the next step of the pipe
543+
* @typeParam T7 The type of data generated and that moves to the next step of the pipe
544+
* @typeParam T8 The type of data generated and that moves to the next step of the pipe
545+
* @typeParam T9 The type of data generated and that moves to the final step of the pipe
546+
*
547+
* @param read Pipeline step 1: The source that produces the data, the first step of the pipe
548+
* @param t1 Pipeline step 2: A transformation step that takes data from the previous step and pushes the result to the next step
549+
* @param t2 Pipeline step 3: A transformation step that takes data from the previous step and pushes the result to the next step
550+
* @param t3 Pipeline step 4: A transformation step that takes data from the previous step and pushes the result to the next step
551+
* @param t4 Pipeline step 5: A transformation step that takes data from the previous step and pushes the result to the next step
552+
* @param t5 Pipeline step 6: A transformation step that takes data from the previous step and pushes the result to the next step
553+
* @param t6 Pipeline step 7: A transformation step that takes data from the previous step and pushes the result to the next step
554+
* @param t7 Pipeline step 8: A transformation step that takes data from the previous step and pushes the result to the next step
555+
* @param t8 Pipeline step 9: A transformation step that takes data from the previous step and pushes the result to the next step
556+
* @param write Pipeline step 10: The sink that is the last step of the pipe
557+
* @returns A promise so it can play nice with async/await
558+
*/
559+
export function pipeAsync<T1, T2, T3, T4, T5, T6, T7, T8, T9>(read: ReadableStream<T1> | stream.Stream, t1: TransformStream<T1, T2>, t2: TransformStream<T2, T3>, t3: TransformStream<T3, T4>, t4: TransformStream<T4, T5>, t5: TransformStream<T5, T6>, t6: TransformStream<T6, T7>, t7: TransformStream<T7, T8>, t8: TransformStream<T8, T9>, write: WritableStream<T9>): Promise<void>;
560+
561+
/**
562+
* An async/await-friendly version of [[`pipe`]]. Creates a pipeline of steps where the first step produces the data and then
563+
* it flows to the next step and so on. The first step is the source, producing the content, the final step is the sink.
564+
*
565+
* This catch-all overload handles pipelines with more than 8 transform streams. For such cases, TypeScript cannot
566+
* maintain full type safety across all transformations, so the types are relaxed.
567+
*
568+
* @param streams Any number of streams (source, transforms, and sink)
569+
* @returns A promise so it can play nice with async/await
570+
*/
571+
export function pipeAsync(...streams: stream.Stream[]): Promise<void>;
572+
390573
// export function pipe<T1>(read: ReadableStream<T1> | stream.Stream | stream.Readable, write: WritableStream<T1> | stream.Stream, errorCallback?: ErrorCallback): WritableStream<T1>;
391574
// export function pipe<T1, T2>(read: ReadableStream<T1> | stream.Stream | stream.Readable, t1: TransformStream<T1, T2>, write: WritableStream<T2> | stream.Stream, errorCallback?: ErrorCallback): WritableStream<T2>;
392575
// export function pipe<T1, T2, T3>(read: ReadableStream<T1> | stream.Stream | stream.Readable, t1: TransformStream<T1, T2>, t2: TransformStream<T2, T3>, write: WritableStream<T3> | stream.Stream, errorCallback?: ErrorCallback): WritableStream<T3>;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "leo-sdk",
3-
"version": "7.1.13",
3+
"version": "7.1.14",
44
"description": "Load data onto the LEO Platform",
55
"homepage": "https://leoplatform.io",
66
"main": "index.js",

0 commit comments

Comments
 (0)