|
|
@ -1,5 +1,8 @@ |
|
|
|
import { Logger } from '@nestjs/common'; |
|
|
|
import { Logger } from '@nestjs/common'; |
|
|
|
import axios from 'axios'; |
|
|
|
import axios from 'axios'; |
|
|
|
|
|
|
|
import { streamObject } from 'stream-json/streamers/StreamObject'; |
|
|
|
|
|
|
|
import { parser } from 'stream-json/Parser'; |
|
|
|
|
|
|
|
import { ignore } from 'stream-json/filters/Ignore'; |
|
|
|
|
|
|
|
|
|
|
|
const logger = new Logger('FetchAT'); |
|
|
|
const logger = new Logger('FetchAT'); |
|
|
|
|
|
|
|
|
|
|
@ -126,11 +129,33 @@ async function read() { |
|
|
|
referrerPolicy: 'no-referrer', |
|
|
|
referrerPolicy: 'no-referrer', |
|
|
|
body: null, |
|
|
|
body: null, |
|
|
|
method: 'GET', |
|
|
|
method: 'GET', |
|
|
|
|
|
|
|
responseType: 'stream', |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
if (resreq?.data?.data) { |
|
|
|
const data: any = await new Promise((resolve, reject) => { |
|
|
|
|
|
|
|
const jsonStream = resreq.data |
|
|
|
|
|
|
|
.pipe(parser()) |
|
|
|
|
|
|
|
.pipe(ignore({ filter: 'data.tableDatas' })) |
|
|
|
|
|
|
|
.pipe(streamObject()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const fullObject = {}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
jsonStream.on('data', (chunk) => { |
|
|
|
|
|
|
|
if (chunk.key) fullObject[chunk.key] = chunk.value; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
jsonStream.on('error', (err) => { |
|
|
|
|
|
|
|
reject(err); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
jsonStream.on('end', () => { |
|
|
|
|
|
|
|
resolve(fullObject); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (data?.data) { |
|
|
|
return { |
|
|
|
return { |
|
|
|
schema: resreq.data.data, |
|
|
|
schema: data?.data, |
|
|
|
baseId: info.baseId, |
|
|
|
baseId: info.baseId, |
|
|
|
baseInfo: info.baseInfo, |
|
|
|
baseInfo: info.baseInfo, |
|
|
|
}; |
|
|
|
}; |
|
|
@ -194,11 +219,34 @@ async function readView(viewId) { |
|
|
|
referrerPolicy: 'no-referrer', |
|
|
|
referrerPolicy: 'no-referrer', |
|
|
|
body: null, |
|
|
|
body: null, |
|
|
|
method: 'GET', |
|
|
|
method: 'GET', |
|
|
|
|
|
|
|
responseType: 'stream', |
|
|
|
}, |
|
|
|
}, |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
if (resreq?.data?.data) { |
|
|
|
const data: any = await new Promise((resolve, reject) => { |
|
|
|
return { view: resreq.data.data }; |
|
|
|
const jsonStream = resreq.data |
|
|
|
|
|
|
|
.pipe(parser()) |
|
|
|
|
|
|
|
.pipe(ignore({ filter: 'data.rowOrder' })) |
|
|
|
|
|
|
|
.pipe(streamObject()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const fullObject = {}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
jsonStream.on('data', (chunk) => { |
|
|
|
|
|
|
|
if (chunk.key) fullObject[chunk.key] = chunk.value; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
jsonStream.on('error', (err) => { |
|
|
|
|
|
|
|
reject(err); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
jsonStream.on('end', () => { |
|
|
|
|
|
|
|
resolve(fullObject); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (data?.data) { |
|
|
|
|
|
|
|
return { view: data.data }; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
throw new Error('Error Reading :: Data missing'); |
|
|
|
throw new Error('Error Reading :: Data missing'); |
|
|
|
} |
|
|
|
} |
|
|
|