|
|
@ -16,9 +16,28 @@ import { map } from 'rxjs/operators'; |
|
|
export class TransformDataSourceInResponseInterceptor<T> |
|
|
export class TransformDataSourceInResponseInterceptor<T> |
|
|
implements NestInterceptor<T, any> |
|
|
implements NestInterceptor<T, any> |
|
|
{ |
|
|
{ |
|
|
|
|
|
private encodedDataSourceMap: { |
|
|
|
|
|
[dataSource: string]: string; |
|
|
|
|
|
} = {}; |
|
|
|
|
|
|
|
|
public constructor( |
|
|
public constructor( |
|
|
private readonly configurationService: ConfigurationService |
|
|
private readonly configurationService: ConfigurationService |
|
|
) {} |
|
|
) { |
|
|
|
|
|
if (this.configurationService.get('ENABLE_FEATURE_SUBSCRIPTION')) { |
|
|
|
|
|
this.encodedDataSourceMap = Object.keys(DataSource).reduce( |
|
|
|
|
|
(encodedDataSourceMap, dataSource) => { |
|
|
|
|
|
if (!['GHOSTFOLIO', 'MANUAL'].includes(dataSource)) { |
|
|
|
|
|
encodedDataSourceMap[dataSource] = encodeDataSource( |
|
|
|
|
|
DataSource[dataSource] |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return encodedDataSourceMap; |
|
|
|
|
|
}, |
|
|
|
|
|
{} |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public intercept( |
|
|
public intercept( |
|
|
_context: ExecutionContext, |
|
|
_context: ExecutionContext, |
|
|
@ -31,18 +50,7 @@ export class TransformDataSourceInResponseInterceptor<T> |
|
|
options: [ |
|
|
options: [ |
|
|
{ |
|
|
{ |
|
|
attribute: 'dataSource', |
|
|
attribute: 'dataSource', |
|
|
valueMap: Object.keys(DataSource).reduce( |
|
|
valueMap: this.encodedDataSourceMap |
|
|
(valueMap, dataSource) => { |
|
|
|
|
|
if (!['MANUAL'].includes(dataSource)) { |
|
|
|
|
|
valueMap[dataSource] = encodeDataSource( |
|
|
|
|
|
DataSource[dataSource] |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return valueMap; |
|
|
|
|
|
}, |
|
|
|
|
|
{} |
|
|
|
|
|
) |
|
|
|
|
|
} |
|
|
} |
|
|
], |
|
|
], |
|
|
object: data |
|
|
object: data |
|
|
|