|
|
|
|
@ -16,36 +16,56 @@ import { map } from 'rxjs/operators';
|
|
|
|
|
export class TransformDataSourceInResponseInterceptor<T>
|
|
|
|
|
implements NestInterceptor<T, any>
|
|
|
|
|
{
|
|
|
|
|
private encodedDataSourceMap: {
|
|
|
|
|
[dataSource: string]: string;
|
|
|
|
|
} = {};
|
|
|
|
|
|
|
|
|
|
public constructor(
|
|
|
|
|
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(
|
|
|
|
|
_context: ExecutionContext,
|
|
|
|
|
context: ExecutionContext,
|
|
|
|
|
next: CallHandler<T>
|
|
|
|
|
): Observable<any> {
|
|
|
|
|
const isExportMode = context.getClass().name === 'ExportController';
|
|
|
|
|
|
|
|
|
|
return next.handle().pipe(
|
|
|
|
|
map((data: any) => {
|
|
|
|
|
if (this.configurationService.get('ENABLE_FEATURE_SUBSCRIPTION')) {
|
|
|
|
|
const valueMap = this.encodedDataSourceMap;
|
|
|
|
|
|
|
|
|
|
if (isExportMode) {
|
|
|
|
|
for (const dataSource of this.configurationService.get(
|
|
|
|
|
'DATA_SOURCES_GHOSTFOLIO_DATA_PROVIDER'
|
|
|
|
|
)) {
|
|
|
|
|
valueMap[dataSource] = 'GHOSTFOLIO';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
data = redactAttributes({
|
|
|
|
|
object: data,
|
|
|
|
|
options: [
|
|
|
|
|
{
|
|
|
|
|
attribute: 'dataSource',
|
|
|
|
|
valueMap: Object.keys(DataSource).reduce(
|
|
|
|
|
(valueMap, dataSource) => {
|
|
|
|
|
if (!['MANUAL'].includes(dataSource)) {
|
|
|
|
|
valueMap[dataSource] = encodeDataSource(
|
|
|
|
|
DataSource[dataSource]
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return valueMap;
|
|
|
|
|
},
|
|
|
|
|
{}
|
|
|
|
|
)
|
|
|
|
|
valueMap,
|
|
|
|
|
attribute: 'dataSource'
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
object: data
|
|
|
|
|
]
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|