diff --git a/CommonServer/Services/AnalyticsDatabaseService.ts b/CommonServer/Services/AnalyticsDatabaseService.ts index 292df86195..cd06417051 100644 --- a/CommonServer/Services/AnalyticsDatabaseService.ts +++ b/CommonServer/Services/AnalyticsDatabaseService.ts @@ -658,7 +658,7 @@ export default class AnalyticsDatabaseService< return await this.onBeforeCreate(createBy); } - public async create(createBy: CreateBy): Promise { + public async create(createBy: CreateBy): Promise { const onCreate: OnCreate = createBy.props.ignoreHooks ? { createBy, carryForward: [] } : await this._onBeforeCreate(createBy); @@ -728,6 +728,9 @@ export default class AnalyticsDatabaseService< ); } } + + return createBy.data; + } catch (error) { await this.onCreateError(error as Exception); throw this.getException(error as Exception); diff --git a/CommonServer/Utils/Stream.ts b/CommonServer/Utils/Stream.ts index 7f28acf595..31a0d8b616 100644 --- a/CommonServer/Utils/Stream.ts +++ b/CommonServer/Utils/Stream.ts @@ -1,4 +1,3 @@ -import { JSONObject } from 'Common/Types/JSON'; import { Stream } from 'stream'; export default class StreamUtil { @@ -20,29 +19,10 @@ export default class StreamUtil { }); } - public static async toJSONArray( - stream: Stream - ): Promise> { - const text = await this.convertStreamToText(stream); - return JSON.parse(text); - } - public static async toStringArray( stream: Stream ): Promise> { - return new Promise>( - (resolve: Function, reject: Function) => { - const data: Array = []; - stream.on('data', (chunk: any) => { - data.push(chunk); - }); - stream.on('end', () => { - resolve(data); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - } - ); + const text: string = await StreamUtil.convertStreamToText(stream); + return text.split('\n'); } }