From 4661e549dd4b6f2c38473717964f4b2c8053f70a Mon Sep 17 00:00:00 2001 From: maany Date: Thu, 3 Aug 2023 15:09:46 +0200 Subject: [PATCH] sdk: cleanup deprecated code --- .../sdk/postprocessing-pipeline-elements.ts | 12 +----------- src/lib/sdk/primary-ports.ts | 1 - src/lib/sdk/usecase.ts | 19 +++---------------- 3 files changed, 4 insertions(+), 28 deletions(-) diff --git a/src/lib/sdk/postprocessing-pipeline-elements.ts b/src/lib/sdk/postprocessing-pipeline-elements.ts index 33e0f585a..a4279ce0d 100644 --- a/src/lib/sdk/postprocessing-pipeline-elements.ts +++ b/src/lib/sdk/postprocessing-pipeline-elements.ts @@ -95,16 +95,6 @@ export abstract class BaseStreamingPostProcessingPipelineElement - /** - * Handles the individual DTO object returned by the gateway's response stream. - * @param dto The DTO returned by the gateway. - * @returns An object that contains the DTO or error model and the status of processing the DTO. - */ - // abstract validateDTO(dto: TDTO): { - // status: 'success' | 'error' | 'critical' - // data: TDTO | TErrorModel - // } - /** * Handles a gateway error by converting it to an error model. * This method is called when the gateway returns a DTO with a status of `error`. @@ -154,7 +144,7 @@ export abstract class BaseStreamingPostProcessingPipelineElement void): Promise { let { status, requestModel, responseModel } = chunk - //bypass is responseModel is already an error model + //bypass if responseModel is already an error model if (status === 'error') { const errorModel = responseModel as TErrorModel callback(null, { diff --git a/src/lib/sdk/primary-ports.ts b/src/lib/sdk/primary-ports.ts index 514939770..d7962f1cf 100644 --- a/src/lib/sdk/primary-ports.ts +++ b/src/lib/sdk/primary-ports.ts @@ -24,7 +24,6 @@ export interface BaseAuthenticatedInputPort { /** * A base interface for streamable input ports. * @typeparam AuthenticatedRequestModel The type of the authenticated request model for the input port. - * @deprecated Primary Input Ports should not be streamable!! Use {@link BaseAuthenticatedInputPort} instead. */ export interface BaseStreamableInputPort extends Transform { diff --git a/src/lib/sdk/usecase.ts b/src/lib/sdk/usecase.ts index cac93cfe3..aad0479d0 100644 --- a/src/lib/sdk/usecase.ts +++ b/src/lib/sdk/usecase.ts @@ -16,7 +16,6 @@ import { BaseDTO, BaseStreamableDTO } from './dto' import { BaseStreamingPostProcessingPipelineElement, BaseResponseModelValidatorPipelineElement, BasePostProcessingPipelineElement } from './postprocessing-pipeline-elements' import { BaseStreamingPresenter } from './presenter' import { BaseViewModel } from './view-models' -import { pipeline } from 'stream' /** * A type that represents a simple use case that does not require authentication. @@ -36,7 +35,7 @@ export type TAuthenticatedUseCase = BaseAuthenticatedInputPort< * A type that represents a streamable use case. These usecases are always authenticated. * @typeparam TRequestModel The type of the request model for the use case. */ -export type TStreamableUseCase = BaseStreamableInputPort< +export type TStreamableUseCase = BaseInputPort< AuthenticatedRequestModel > @@ -433,23 +432,11 @@ export abstract class BaseMultiCallStreamableUseCase< ...this.postProcessingPipelineElements, this.finalResponseValidationTransform, ] - // TODO: cleanup for (let i = 1; i < pipelineElements.length; i++) { const pipelineElement = pipelineElements[i] const prevPipelineElement = pipelineElements[i - 1] - prevPipelineElement - // .on('error', error => - // this.handleStreamError(error as TErrorModel), - // ) - // .on('end', () => { - // console.log("********** Pipeline element ended **********"); - // }) - .pipe(pipelineElement) - // pipeline(prevPipelineElement, pipelineElement, (error) => { - // console.log("********** Pipeline element ERRRORRROROROROROROROR **********"); - // console.log(`${prevPipelineElement.constructor.name} -> ${pipelineElement.constructor.name} error: ${error?.message}`) - // console.log('---------------------------------------------------------------') - // }) + prevPipelineElement.pipe(pipelineElement) + } this.presenter.setupStream(this.finalResponseValidationTransform) }