From c053987591680d7cb0011b27c51085ac55805628 Mon Sep 17 00:00:00 2001 From: Diego Sampaio Date: Mon, 4 Jan 2021 14:38:13 -0300 Subject: [PATCH 1/4] Try building micro services --- .github/workflows/build_and_test.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 272c40ac57d51..5193056a11c27 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -137,6 +137,13 @@ jobs: run: | meteor reset + - name: Try building micro services + run: | + cd ./ee/server/services + npm i + npm run build + rm -rf dist/ + - name: Build Rocket.Chat From Pull Request if: startsWith(github.ref, 'refs/pull/') == true env: From ce82eb25e5b9137e0588ed68ad25c32be0ae56bf Mon Sep 17 00:00:00 2001 From: Renato Becker Date: Wed, 6 Jan 2021 12:16:04 -0300 Subject: [PATCH 2/4] Remover meteor dependency from raw model. --- app/models/server/raw/LivechatDepartmentAgents.js | 3 +++ .../server/business-hour/Multiple.ts | 6 +++--- ee/app/models/server/index.js | 3 +-- .../models/server/raw/LivechatDepartmentAgents.ts | 15 +++++++-------- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/app/models/server/raw/LivechatDepartmentAgents.js b/app/models/server/raw/LivechatDepartmentAgents.js index 3bcd4032bad80..b5118e78eca08 100644 --- a/app/models/server/raw/LivechatDepartmentAgents.js +++ b/app/models/server/raw/LivechatDepartmentAgents.js @@ -31,4 +31,7 @@ export class LivechatDepartmentAgentsRaw extends BaseRaw { findByDepartmentIds(departmentIds, options = {}) { return this.find({ departmentId: { $in: departmentIds } }, options); } + + // eslint-disable-next-line no-unused-vars + findAgentsByAgentIdAndBusinessHourId(agentId, businessHourId) { return []; } } diff --git a/ee/app/livechat-enterprise/server/business-hour/Multiple.ts b/ee/app/livechat-enterprise/server/business-hour/Multiple.ts index 22f2e67e3d519..6d6a8b6dc94e7 100644 --- a/ee/app/livechat-enterprise/server/business-hour/Multiple.ts +++ b/ee/app/livechat-enterprise/server/business-hour/Multiple.ts @@ -6,8 +6,8 @@ import { } from '../../../../../app/livechat/server/business-hour/AbstractBusinessHour'; import { ILivechatBusinessHour } from '../../../../../definition/ILivechatBusinessHour'; import { LivechatDepartmentRaw } from '../../../../../app/models/server/raw/LivechatDepartment'; -import LivechatDepartmentAgentsRaw from '../../../models/server/raw/LivechatDepartmentAgents'; -import { LivechatDepartment } from '../../../../../app/models/server/raw'; +import { LivechatDepartmentAgentsRaw } from '../../../../../app/models/server/raw/LivechatDepartmentAgents'; +import { LivechatDepartment, LivechatDepartmentAgents } from '../../../../../app/models/server/raw'; import { filterBusinessHoursThatMustBeOpened } from '../../../../../app/livechat/server/business-hour/Helper'; import { closeBusinessHour, openBusinessHour, removeBusinessHourByAgentIds } from './Helper'; @@ -19,7 +19,7 @@ interface IBusinessHoursExtraProperties extends ILivechatBusinessHour { export class MultipleBusinessHoursBehavior extends AbstractBusinessHourBehavior implements IBusinessHourBehavior { private DepartmentsRepository: LivechatDepartmentRaw = LivechatDepartment; - private DepartmentsAgentsRepository = LivechatDepartmentAgentsRaw; + private DepartmentsAgentsRepository: LivechatDepartmentAgentsRaw = LivechatDepartmentAgents; constructor() { super(); diff --git a/ee/app/models/server/index.js b/ee/app/models/server/index.js index c44afe4be4bb1..c28fe3762acca 100644 --- a/ee/app/models/server/index.js +++ b/ee/app/models/server/index.js @@ -7,12 +7,12 @@ import CannedResponseRaw from './raw/CannedResponse'; import LivechatPriorityRaw from './raw/LivechatPriority'; import LivechatTagRaw from './raw/LivechatTag'; import LivechatUnitMonitorsRaw from './raw/LivechatUnitMonitors'; -import LivechatDepartmentAgentsRaw from './raw/LivechatDepartmentAgents'; import './models/LivechatDepartment'; import './models/LivechatRooms'; import './models/LivechatInquiry'; import './models/Messages'; import './raw/LivechatDepartment'; +import './raw/LivechatDepartmentAgents'; import './raw/LivechatRooms'; export { @@ -25,5 +25,4 @@ export { LivechatUnitMonitorsRaw, LivechatPriority, LivechatPriorityRaw, - LivechatDepartmentAgentsRaw, }; diff --git a/ee/app/models/server/raw/LivechatDepartmentAgents.ts b/ee/app/models/server/raw/LivechatDepartmentAgents.ts index 51f4c343056b6..8c8c4422eb0c9 100644 --- a/ee/app/models/server/raw/LivechatDepartmentAgents.ts +++ b/ee/app/models/server/raw/LivechatDepartmentAgents.ts @@ -1,7 +1,7 @@ -import { LivechatDepartmentAgentsRaw as Raw } from '../../../../../app/models/server/raw/LivechatDepartmentAgents'; -import { LivechatDepartmentAgents } from '../../../../../app/models/server'; +import { LivechatDepartmentAgentsRaw } from '../../../../../app/models/server/raw/LivechatDepartmentAgents'; +import { overwriteClassOnLicense } from '../../../license/server'; -export class LivechatDepartmentAgentsRaw extends Raw { +overwriteClassOnLicense('livechat-enterprise', LivechatDepartmentAgentsRaw, { findAgentsByAgentIdAndBusinessHourId(agentId: string, businessHourId: string): Promise> { const match = { $match: { agentId }, @@ -22,8 +22,7 @@ export class LivechatDepartmentAgentsRaw extends Raw { }; const withBusinessHourId = { $match: { 'departments.businessHourId': businessHourId } }; const project = { $project: { departments: 0 } }; - return this.col.aggregate([match, lookup, unwind, withBusinessHourId, project]).toArray(); - } -} - -export default new LivechatDepartmentAgentsRaw(LivechatDepartmentAgents.model.rawCollection()); + const model = this as unknown as LivechatDepartmentAgentsRaw; + return model.col.aggregate([match, lookup, unwind, withBusinessHourId, project]).toArray(); + }, +}); From 8daa46b18d9c2ab02b501dcc1583cb502771c4d5 Mon Sep 17 00:00:00 2001 From: Renato Becker Date: Wed, 6 Jan 2021 13:33:05 -0300 Subject: [PATCH 3/4] Fix wrong import statement. --- ee/server/services/stream-hub/StreamHub.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ee/server/services/stream-hub/StreamHub.ts b/ee/server/services/stream-hub/StreamHub.ts index bfa1c64644c92..5ddf3c4b5cd3b 100755 --- a/ee/server/services/stream-hub/StreamHub.ts +++ b/ee/server/services/stream-hub/StreamHub.ts @@ -12,7 +12,7 @@ import { RoomsRaw } from '../../../../app/models/server/raw/Rooms'; import { LoginServiceConfigurationRaw } from '../../../../app/models/server/raw/LoginServiceConfiguration'; import { InstanceStatusRaw } from '../../../../app/models/server/raw/InstanceStatus'; import { IntegrationHistoryRaw } from '../../../../app/models/server/raw/IntegrationHistory'; -import { LivechatDepartmentAgentsRaw } from '../../../app/models/server/raw/LivechatDepartmentAgents'; +import { LivechatDepartmentAgentsRaw } from '../../../../app/models/server/raw/LivechatDepartmentAgents'; import { IntegrationsRaw } from '../../../../app/models/server/raw/Integrations'; import { PermissionsRaw } from '../../../../app/models/server/raw/Permissions'; import { api } from '../../../../server/sdk/api'; From f642a1f2b7ae17a41be00e87e7087f8d4c1f49f2 Mon Sep 17 00:00:00 2001 From: Renato Becker Date: Thu, 7 Jan 2021 11:19:24 -0300 Subject: [PATCH 4/4] Revert code. --- app/models/server/raw/LivechatDepartmentAgents.js | 3 --- .../server/business-hour/Multiple.ts | 6 +++--- ee/app/models/server/index.js | 3 ++- .../models/server/raw/LivechatDepartmentAgents.ts | 15 ++++++++------- ee/server/services/stream-hub/StreamHub.ts | 2 +- 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/app/models/server/raw/LivechatDepartmentAgents.js b/app/models/server/raw/LivechatDepartmentAgents.js index b5118e78eca08..3bcd4032bad80 100644 --- a/app/models/server/raw/LivechatDepartmentAgents.js +++ b/app/models/server/raw/LivechatDepartmentAgents.js @@ -31,7 +31,4 @@ export class LivechatDepartmentAgentsRaw extends BaseRaw { findByDepartmentIds(departmentIds, options = {}) { return this.find({ departmentId: { $in: departmentIds } }, options); } - - // eslint-disable-next-line no-unused-vars - findAgentsByAgentIdAndBusinessHourId(agentId, businessHourId) { return []; } } diff --git a/ee/app/livechat-enterprise/server/business-hour/Multiple.ts b/ee/app/livechat-enterprise/server/business-hour/Multiple.ts index 6d6a8b6dc94e7..22f2e67e3d519 100644 --- a/ee/app/livechat-enterprise/server/business-hour/Multiple.ts +++ b/ee/app/livechat-enterprise/server/business-hour/Multiple.ts @@ -6,8 +6,8 @@ import { } from '../../../../../app/livechat/server/business-hour/AbstractBusinessHour'; import { ILivechatBusinessHour } from '../../../../../definition/ILivechatBusinessHour'; import { LivechatDepartmentRaw } from '../../../../../app/models/server/raw/LivechatDepartment'; -import { LivechatDepartmentAgentsRaw } from '../../../../../app/models/server/raw/LivechatDepartmentAgents'; -import { LivechatDepartment, LivechatDepartmentAgents } from '../../../../../app/models/server/raw'; +import LivechatDepartmentAgentsRaw from '../../../models/server/raw/LivechatDepartmentAgents'; +import { LivechatDepartment } from '../../../../../app/models/server/raw'; import { filterBusinessHoursThatMustBeOpened } from '../../../../../app/livechat/server/business-hour/Helper'; import { closeBusinessHour, openBusinessHour, removeBusinessHourByAgentIds } from './Helper'; @@ -19,7 +19,7 @@ interface IBusinessHoursExtraProperties extends ILivechatBusinessHour { export class MultipleBusinessHoursBehavior extends AbstractBusinessHourBehavior implements IBusinessHourBehavior { private DepartmentsRepository: LivechatDepartmentRaw = LivechatDepartment; - private DepartmentsAgentsRepository: LivechatDepartmentAgentsRaw = LivechatDepartmentAgents; + private DepartmentsAgentsRepository = LivechatDepartmentAgentsRaw; constructor() { super(); diff --git a/ee/app/models/server/index.js b/ee/app/models/server/index.js index c28fe3762acca..c44afe4be4bb1 100644 --- a/ee/app/models/server/index.js +++ b/ee/app/models/server/index.js @@ -7,12 +7,12 @@ import CannedResponseRaw from './raw/CannedResponse'; import LivechatPriorityRaw from './raw/LivechatPriority'; import LivechatTagRaw from './raw/LivechatTag'; import LivechatUnitMonitorsRaw from './raw/LivechatUnitMonitors'; +import LivechatDepartmentAgentsRaw from './raw/LivechatDepartmentAgents'; import './models/LivechatDepartment'; import './models/LivechatRooms'; import './models/LivechatInquiry'; import './models/Messages'; import './raw/LivechatDepartment'; -import './raw/LivechatDepartmentAgents'; import './raw/LivechatRooms'; export { @@ -25,4 +25,5 @@ export { LivechatUnitMonitorsRaw, LivechatPriority, LivechatPriorityRaw, + LivechatDepartmentAgentsRaw, }; diff --git a/ee/app/models/server/raw/LivechatDepartmentAgents.ts b/ee/app/models/server/raw/LivechatDepartmentAgents.ts index 8c8c4422eb0c9..51f4c343056b6 100644 --- a/ee/app/models/server/raw/LivechatDepartmentAgents.ts +++ b/ee/app/models/server/raw/LivechatDepartmentAgents.ts @@ -1,7 +1,7 @@ -import { LivechatDepartmentAgentsRaw } from '../../../../../app/models/server/raw/LivechatDepartmentAgents'; -import { overwriteClassOnLicense } from '../../../license/server'; +import { LivechatDepartmentAgentsRaw as Raw } from '../../../../../app/models/server/raw/LivechatDepartmentAgents'; +import { LivechatDepartmentAgents } from '../../../../../app/models/server'; -overwriteClassOnLicense('livechat-enterprise', LivechatDepartmentAgentsRaw, { +export class LivechatDepartmentAgentsRaw extends Raw { findAgentsByAgentIdAndBusinessHourId(agentId: string, businessHourId: string): Promise> { const match = { $match: { agentId }, @@ -22,7 +22,8 @@ overwriteClassOnLicense('livechat-enterprise', LivechatDepartmentAgentsRaw, { }; const withBusinessHourId = { $match: { 'departments.businessHourId': businessHourId } }; const project = { $project: { departments: 0 } }; - const model = this as unknown as LivechatDepartmentAgentsRaw; - return model.col.aggregate([match, lookup, unwind, withBusinessHourId, project]).toArray(); - }, -}); + return this.col.aggregate([match, lookup, unwind, withBusinessHourId, project]).toArray(); + } +} + +export default new LivechatDepartmentAgentsRaw(LivechatDepartmentAgents.model.rawCollection()); diff --git a/ee/server/services/stream-hub/StreamHub.ts b/ee/server/services/stream-hub/StreamHub.ts index 5ddf3c4b5cd3b..bfa1c64644c92 100755 --- a/ee/server/services/stream-hub/StreamHub.ts +++ b/ee/server/services/stream-hub/StreamHub.ts @@ -12,7 +12,7 @@ import { RoomsRaw } from '../../../../app/models/server/raw/Rooms'; import { LoginServiceConfigurationRaw } from '../../../../app/models/server/raw/LoginServiceConfiguration'; import { InstanceStatusRaw } from '../../../../app/models/server/raw/InstanceStatus'; import { IntegrationHistoryRaw } from '../../../../app/models/server/raw/IntegrationHistory'; -import { LivechatDepartmentAgentsRaw } from '../../../../app/models/server/raw/LivechatDepartmentAgents'; +import { LivechatDepartmentAgentsRaw } from '../../../app/models/server/raw/LivechatDepartmentAgents'; import { IntegrationsRaw } from '../../../../app/models/server/raw/Integrations'; import { PermissionsRaw } from '../../../../app/models/server/raw/Permissions'; import { api } from '../../../../server/sdk/api';