Skip to content

Commit

Permalink
sdk: cleanup deprecated code
Browse files Browse the repository at this point in the history
  • Loading branch information
maany committed Aug 3, 2023
1 parent f778747 commit 4661e54
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 28 deletions.
12 changes: 1 addition & 11 deletions src/lib/sdk/postprocessing-pipeline-elements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,6 @@ export abstract class BaseStreamingPostProcessingPipelineElement<TRequestModel,
*/
abstract makeGatewayRequest(requestModel: TRequestModel, responseModel: TResponseModel): Promise<TDTO>

/**
* 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`.
Expand Down Expand Up @@ -154,7 +144,7 @@ export abstract class BaseStreamingPostProcessingPipelineElement<TRequestModel,
async _transform(chunk: {status: 'success' | 'error', requestModel: TRequestModel, responseModel: TResponseModel | TErrorModel }, encoding: BufferEncoding, callback: (error?: Error | null, data?: any | TErrorModel) => void): Promise<void> {
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, {
Expand Down
1 change: 0 additions & 1 deletion src/lib/sdk/primary-ports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export interface BaseAuthenticatedInputPort<TRequestModel> {
/**
* 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<AuthenticatedRequestModel>
extends Transform {
Expand Down
19 changes: 3 additions & 16 deletions src/lib/sdk/usecase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -36,7 +35,7 @@ export type TAuthenticatedUseCase<TRequestModel> = 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<TRequestModel> = BaseStreamableInputPort<
export type TStreamableUseCase<TRequestModel> = BaseInputPort<
AuthenticatedRequestModel<TRequestModel>
>

Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 4661e54

Please sign in to comment.