diff --git a/_templates/service/new/service.ejs.t b/_templates/service/new/service.ejs.t index bdd160b43cdf..b0880bd47539 100644 --- a/_templates/service/new/service.ejs.t +++ b/_templates/service/new/service.ejs.t @@ -2,12 +2,11 @@ to: ee/apps/<%= name %>/src/service.ts --- import { api, getConnection, getTrashCollection } from '@rocket.chat/core-services'; +import { registerServiceModels } from '@rocket.chat/models'; import { broker } from '@rocket.chat/network-broker'; import { startTracing } from '@rocket.chat/tracing'; import polka from 'polka'; -import { registerServiceModels } from '../../../../apps/meteor/ee/server/lib/registerServiceModels'; - const PORT = process.env.PORT || <%= h.random() %>; (async () => { diff --git a/apps/meteor/app/livechat/server/business-hour/AbstractBusinessHour.ts b/apps/meteor/app/livechat/server/business-hour/AbstractBusinessHour.ts index 9ddd273600d5..940954dfa2a7 100644 --- a/apps/meteor/app/livechat/server/business-hour/AbstractBusinessHour.ts +++ b/apps/meteor/app/livechat/server/business-hour/AbstractBusinessHour.ts @@ -1,10 +1,10 @@ import type { AtLeast, ILivechatAgentStatus, ILivechatBusinessHour, ILivechatDepartment } from '@rocket.chat/core-typings'; import type { ILivechatBusinessHoursModel, IUsersModel } from '@rocket.chat/model-typings'; import { LivechatBusinessHours, Users } from '@rocket.chat/models'; +import type { IWorkHoursCronJobsWrapper } from '@rocket.chat/models'; import moment from 'moment-timezone'; import type { UpdateFilter } from 'mongodb'; -import type { IWorkHoursCronJobsWrapper } from '../../../../server/models/raw/LivechatBusinessHours'; import { notifyOnUserChange } from '../../../lib/server/lib/notifyListener'; export interface IBusinessHourBehavior { diff --git a/apps/meteor/app/statistics/server/lib/SAUMonitor.ts b/apps/meteor/app/statistics/server/lib/SAUMonitor.ts index e1cdab7f0773..aee710292636 100644 --- a/apps/meteor/app/statistics/server/lib/SAUMonitor.ts +++ b/apps/meteor/app/statistics/server/lib/SAUMonitor.ts @@ -1,7 +1,7 @@ import type { ISession, ISessionDevice, ISocketConnectionLogged, IUser } from '@rocket.chat/core-typings'; import { cronJobs } from '@rocket.chat/cron'; import { Logger } from '@rocket.chat/logger'; -import { Sessions, Users } from '@rocket.chat/models'; +import { Sessions, Users, aggregates } from '@rocket.chat/models'; import mem from 'mem'; import { Meteor } from 'meteor/meteor'; import UAParser from 'ua-parser-js'; @@ -9,7 +9,6 @@ import UAParser from 'ua-parser-js'; import { UAParserMobile, UAParserDesktop } from './UAParserCustom'; import { getMostImportantRole } from '../../../../lib/roles/getMostImportantRole'; import { getClientAddress } from '../../../../server/lib/getClientAddress'; -import { aggregates } from '../../../../server/models/raw/Sessions'; import { sauEvents } from '../../../../server/services/sauMonitor/events'; type DateObj = { day: number; month: number; year: number }; diff --git a/apps/meteor/ee/server/lib/registerServiceModels.ts b/apps/meteor/ee/server/lib/registerServiceModels.ts deleted file mode 100644 index 22d8a9c1b322..000000000000 --- a/apps/meteor/ee/server/lib/registerServiceModels.ts +++ /dev/null @@ -1,66 +0,0 @@ -import type { - ILivechatDepartmentAgents, - ILivechatInquiryRecord, - ISetting, - ISubscription, - RocketChatRecordDeleted, -} from '@rocket.chat/core-typings'; -import { registerModel } from '@rocket.chat/models'; -import type { Collection, Db } from 'mongodb'; - -import { EmailInboxRaw } from '../../../server/models/raw/EmailInbox'; -import { InstanceStatusRaw } from '../../../server/models/raw/InstanceStatus'; -import { IntegrationHistoryRaw } from '../../../server/models/raw/IntegrationHistory'; -import { IntegrationsRaw } from '../../../server/models/raw/Integrations'; -import { LivechatDepartmentAgentsRaw } from '../../../server/models/raw/LivechatDepartmentAgents'; -import { LivechatInquiryRaw } from '../../../server/models/raw/LivechatInquiry'; -import { LivechatRoomsRaw } from '../../../server/models/raw/LivechatRooms'; -import { LivechatVisitorsRaw } from '../../../server/models/raw/LivechatVisitors'; -import { LoginServiceConfigurationRaw } from '../../../server/models/raw/LoginServiceConfiguration'; -import { MessagesRaw } from '../../../server/models/raw/Messages'; -import { PbxEventsRaw } from '../../../server/models/raw/PbxEvents'; -import { PermissionsRaw } from '../../../server/models/raw/Permissions'; -import { RolesRaw } from '../../../server/models/raw/Roles'; -import { RoomsRaw } from '../../../server/models/raw/Rooms'; -import { SettingsRaw } from '../../../server/models/raw/Settings'; -import { SubscriptionsRaw } from '../../../server/models/raw/Subscriptions'; -import { TeamRaw } from '../../../server/models/raw/Team'; -import { TeamMemberRaw } from '../../../server/models/raw/TeamMember'; -import { UploadsRaw } from '../../../server/models/raw/Uploads'; -import { UsersRaw } from '../../../server/models/raw/Users'; -import { UsersSessionsRaw } from '../../../server/models/raw/UsersSessions'; -import { LivechatPriorityRaw } from '../models/raw/LivechatPriority'; - -// TODO add trash param to appropiate model instances -export function registerServiceModels(db: Db, trash?: Collection>): void { - registerModel('IRolesModel', () => new RolesRaw(db)); - registerModel('IRoomsModel', () => new RoomsRaw(db)); - registerModel('ISettingsModel', () => new SettingsRaw(db, trash as Collection>)); - registerModel('ISubscriptionsModel', () => new SubscriptionsRaw(db, trash as Collection>)); - registerModel('ITeamModel', () => new TeamRaw(db)); - registerModel('ITeamMemberModel', () => new TeamMemberRaw(db)); - registerModel('IUsersModel', () => new UsersRaw(db)); - - registerModel('IMessagesModel', () => new MessagesRaw(db)); - - registerModel( - 'ILivechatInquiryModel', - () => new LivechatInquiryRaw(db, trash as Collection>), - ); - registerModel( - 'ILivechatDepartmentAgentsModel', - () => new LivechatDepartmentAgentsRaw(db, trash as Collection>), - ); - registerModel('IUsersSessionsModel', () => new UsersSessionsRaw(db)); - registerModel('IPermissionsModel', () => new PermissionsRaw(db)); - registerModel('ILoginServiceConfigurationModel', () => new LoginServiceConfigurationRaw(db)); - registerModel('IInstanceStatusModel', () => new InstanceStatusRaw(db)); - registerModel('IIntegrationHistoryModel', () => new IntegrationHistoryRaw(db)); - registerModel('IIntegrationsModel', () => new IntegrationsRaw(db)); - registerModel('IEmailInboxModel', () => new EmailInboxRaw(db)); - registerModel('IPbxEventsModel', () => new PbxEventsRaw(db)); - registerModel('ILivechatPriorityModel', new LivechatPriorityRaw(db)); - registerModel('ILivechatRoomsModel', () => new LivechatRoomsRaw(db)); - registerModel('IUploadsModel', () => new UploadsRaw(db)); - registerModel('ILivechatVisitorsModel', () => new LivechatVisitorsRaw(db)); -} diff --git a/apps/meteor/ee/server/models/LivechatPriority.ts b/apps/meteor/ee/server/models/LivechatPriority.ts deleted file mode 100644 index c6d3b0ecf96a..000000000000 --- a/apps/meteor/ee/server/models/LivechatPriority.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { LivechatPriorityRaw } from './raw/LivechatPriority'; -import { db } from '../../../server/database/utils'; - -registerModel('ILivechatPriorityModel', new LivechatPriorityRaw(db)); diff --git a/apps/meteor/ee/server/models/raw/AuditLog.ts b/apps/meteor/ee/server/models/raw/AuditLog.ts index e0c70d3290bb..62e86aae1793 100644 --- a/apps/meteor/ee/server/models/raw/AuditLog.ts +++ b/apps/meteor/ee/server/models/raw/AuditLog.ts @@ -1,8 +1,7 @@ import type { RocketChatRecordDeleted, IAuditLog } from '@rocket.chat/core-typings'; +import { BaseRaw } from '@rocket.chat/models'; import type { Collection, Db } from 'mongodb'; -import { BaseRaw } from '../../../../server/models/raw/BaseRaw'; - export class AuditLogRaw extends BaseRaw { constructor(db: Db, trash?: Collection>) { super(db, 'audit_log', trash); diff --git a/apps/meteor/ee/server/models/raw/CannedResponse.ts b/apps/meteor/ee/server/models/raw/CannedResponse.ts index e897db928dc2..fdfb4a02d97b 100644 --- a/apps/meteor/ee/server/models/raw/CannedResponse.ts +++ b/apps/meteor/ee/server/models/raw/CannedResponse.ts @@ -1,9 +1,8 @@ import type { IOmnichannelCannedResponse } from '@rocket.chat/core-typings'; import type { ICannedResponseModel } from '@rocket.chat/model-typings'; +import { BaseRaw } from '@rocket.chat/models'; import type { Db, DeleteResult, FindCursor, FindOptions, IndexDescription, UpdateFilter } from 'mongodb'; -import { BaseRaw } from '../../../../server/models/raw/BaseRaw'; - // TODO need to define type for CannedResponse object export class CannedResponseRaw extends BaseRaw implements ICannedResponseModel { constructor(db: Db) { diff --git a/apps/meteor/ee/server/models/raw/LivechatDepartment.ts b/apps/meteor/ee/server/models/raw/LivechatDepartment.ts index 3586c4b836d1..50a17da13b65 100644 --- a/apps/meteor/ee/server/models/raw/LivechatDepartment.ts +++ b/apps/meteor/ee/server/models/raw/LivechatDepartment.ts @@ -1,6 +1,6 @@ import type { ILivechatDepartment, RocketChatRecordDeleted, LivechatDepartmentDTO } from '@rocket.chat/core-typings'; import type { ILivechatDepartmentModel } from '@rocket.chat/model-typings'; -import { LivechatUnit } from '@rocket.chat/models'; +import { LivechatUnit, LivechatDepartmentRaw } from '@rocket.chat/models'; import type { Collection, DeleteResult, @@ -14,8 +14,6 @@ import type { AggregationCursor, } from 'mongodb'; -import { LivechatDepartmentRaw } from '../../../../server/models/raw/LivechatDepartment'; - declare module '@rocket.chat/model-typings' { interface ILivechatDepartmentModel { removeDepartmentFromForwardListById(departmentId: string): Promise; diff --git a/apps/meteor/ee/server/models/raw/LivechatDepartmentAgents.ts b/apps/meteor/ee/server/models/raw/LivechatDepartmentAgents.ts index 0c04ed355ce6..a7a661225459 100644 --- a/apps/meteor/ee/server/models/raw/LivechatDepartmentAgents.ts +++ b/apps/meteor/ee/server/models/raw/LivechatDepartmentAgents.ts @@ -1,6 +1,5 @@ import type { ILivechatDepartmentAgents } from '@rocket.chat/core-typings'; - -import { LivechatDepartmentAgentsRaw } from '../../../../server/models/raw/LivechatDepartmentAgents'; +import { LivechatDepartmentAgentsRaw } from '@rocket.chat/models'; export class LivechatDepartmentAgents extends LivechatDepartmentAgentsRaw { findAgentsByAgentIdAndBusinessHourId(agentId: string, businessHourId: string): Promise { diff --git a/apps/meteor/ee/server/models/raw/LivechatInquiry.ts b/apps/meteor/ee/server/models/raw/LivechatInquiry.ts index 75e09019db22..12a6c60b9ed3 100644 --- a/apps/meteor/ee/server/models/raw/LivechatInquiry.ts +++ b/apps/meteor/ee/server/models/raw/LivechatInquiry.ts @@ -1,10 +1,9 @@ import type { ILivechatInquiryRecord, ILivechatPriority } from '@rocket.chat/core-typings'; import { DEFAULT_SLA_CONFIG, LivechatPriorityWeight } from '@rocket.chat/core-typings'; import type { ILivechatInquiryModel } from '@rocket.chat/model-typings'; +import { LivechatInquiryRaw } from '@rocket.chat/models'; import type { ModifyResult, UpdateResult, Document } from 'mongodb'; -import { LivechatInquiryRaw } from '../../../../server/models/raw/LivechatInquiry'; - declare module '@rocket.chat/model-typings' { interface ILivechatInquiryModel { setSlaForRoom(rid: string, sla: { estimatedWaitingTimeQueue: number; slaId: string }): Promise>; diff --git a/apps/meteor/ee/server/models/raw/LivechatRooms.ts b/apps/meteor/ee/server/models/raw/LivechatRooms.ts index 9e8cdc0b8486..df099608f9bf 100644 --- a/apps/meteor/ee/server/models/raw/LivechatRooms.ts +++ b/apps/meteor/ee/server/models/raw/LivechatRooms.ts @@ -9,11 +9,11 @@ import type { import { LivechatPriorityWeight, DEFAULT_SLA_CONFIG } from '@rocket.chat/core-typings'; import type { FindPaginated, ILivechatRoomsModel } from '@rocket.chat/model-typings'; import type { Updater } from '@rocket.chat/models'; +import { LivechatRoomsRaw } from '@rocket.chat/models'; import { escapeRegExp } from '@rocket.chat/string-helpers'; import type { FindCursor, UpdateResult, Document, FindOptions, Db, Collection, Filter, AggregationCursor, UpdateOptions } from 'mongodb'; import { readSecondaryPreferred } from '../../../../server/database/readSecondaryPreferred'; -import { LivechatRoomsRaw } from '../../../../server/models/raw/LivechatRooms'; declare module '@rocket.chat/model-typings' { interface ILivechatRoomsModel { diff --git a/apps/meteor/ee/server/models/raw/LivechatTag.ts b/apps/meteor/ee/server/models/raw/LivechatTag.ts index a4314c569f46..aec7f605b270 100644 --- a/apps/meteor/ee/server/models/raw/LivechatTag.ts +++ b/apps/meteor/ee/server/models/raw/LivechatTag.ts @@ -1,9 +1,8 @@ import type { ILivechatTag } from '@rocket.chat/core-typings'; import type { ILivechatTagModel } from '@rocket.chat/model-typings'; +import { BaseRaw } from '@rocket.chat/models'; import type { Db, DeleteResult, FindCursor, FindOptions, IndexDescription } from 'mongodb'; -import { BaseRaw } from '../../../../server/models/raw/BaseRaw'; - export class LivechatTagRaw extends BaseRaw implements ILivechatTagModel { constructor(db: Db) { super(db, 'livechat_tag'); diff --git a/apps/meteor/ee/server/models/raw/LivechatUnit.ts b/apps/meteor/ee/server/models/raw/LivechatUnit.ts index c198ee04fbb0..3045d55c9006 100644 --- a/apps/meteor/ee/server/models/raw/LivechatUnit.ts +++ b/apps/meteor/ee/server/models/raw/LivechatUnit.ts @@ -1,9 +1,8 @@ import type { IOmnichannelBusinessUnit, ILivechatDepartment } from '@rocket.chat/core-typings'; import type { FindPaginated, ILivechatUnitModel } from '@rocket.chat/model-typings'; -import { LivechatUnitMonitors, LivechatDepartment, LivechatRooms } from '@rocket.chat/models'; +import { LivechatUnitMonitors, LivechatDepartment, LivechatRooms, BaseRaw } from '@rocket.chat/models'; import type { FindOptions, Filter, FindCursor, Db, FilterOperators, UpdateResult, DeleteResult, Document, UpdateFilter } from 'mongodb'; -import { BaseRaw } from '../../../../server/models/raw/BaseRaw'; import { getUnitsFromUser } from '../../../app/livechat-enterprise/server/lib/units'; const addQueryRestrictions = async (originalQuery: Filter = {}) => { diff --git a/apps/meteor/ee/server/models/raw/LivechatUnitMonitors.ts b/apps/meteor/ee/server/models/raw/LivechatUnitMonitors.ts index fcfed41c3382..f5545174ee60 100644 --- a/apps/meteor/ee/server/models/raw/LivechatUnitMonitors.ts +++ b/apps/meteor/ee/server/models/raw/LivechatUnitMonitors.ts @@ -1,9 +1,8 @@ import type { ILivechatUnitMonitor } from '@rocket.chat/core-typings'; import type { ILivechatUnitMonitorsModel } from '@rocket.chat/model-typings'; +import { BaseRaw } from '@rocket.chat/models'; import type { Db, FindCursor, UpdateResult, DeleteResult, IndexDescription } from 'mongodb'; -import { BaseRaw } from '../../../../server/models/raw/BaseRaw'; - export class LivechatUnitMonitorsRaw extends BaseRaw implements ILivechatUnitMonitorsModel { constructor(db: Db) { super(db, 'livechat_unit_monitors'); diff --git a/apps/meteor/ee/server/models/raw/ReadReceipts.ts b/apps/meteor/ee/server/models/raw/ReadReceipts.ts index cf0dd7283f31..f356016b49d3 100644 --- a/apps/meteor/ee/server/models/raw/ReadReceipts.ts +++ b/apps/meteor/ee/server/models/raw/ReadReceipts.ts @@ -1,9 +1,9 @@ import type { IUser, IMessage, ReadReceipt, RocketChatRecordDeleted } from '@rocket.chat/core-typings'; import type { IReadReceiptsModel } from '@rocket.chat/model-typings'; +import { BaseRaw } from '@rocket.chat/models'; import type { Collection, FindCursor, Db, IndexDescription, DeleteResult, Filter, UpdateResult, Document } from 'mongodb'; import { otrSystemMessages } from '../../../../app/otr/lib/constants'; -import { BaseRaw } from '../../../../server/models/raw/BaseRaw'; export class ReadReceiptsRaw extends BaseRaw implements IReadReceiptsModel { constructor(db: Db, trash?: Collection>) { diff --git a/apps/meteor/ee/server/models/raw/ServiceLevelAgreements.ts b/apps/meteor/ee/server/models/raw/ServiceLevelAgreements.ts index ac34b6f82741..30f330b4710a 100644 --- a/apps/meteor/ee/server/models/raw/ServiceLevelAgreements.ts +++ b/apps/meteor/ee/server/models/raw/ServiceLevelAgreements.ts @@ -1,9 +1,8 @@ import type { IOmnichannelServiceLevelAgreements } from '@rocket.chat/core-typings'; import type { IOmnichannelServiceLevelAgreementsModel } from '@rocket.chat/model-typings/src'; +import { BaseRaw } from '@rocket.chat/models'; import type { Db, IndexDescription } from 'mongodb'; -import { BaseRaw } from '../../../../server/models/raw/BaseRaw'; - export class ServiceLevelAgreements extends BaseRaw implements IOmnichannelServiceLevelAgreementsModel { constructor(db: Db) { super(db, 'omnichannel_service_level_agreements'); diff --git a/apps/meteor/ee/server/models/raw/Users.ts b/apps/meteor/ee/server/models/raw/Users.ts index 20e6e0eb7962..9f2ae33019dd 100644 --- a/apps/meteor/ee/server/models/raw/Users.ts +++ b/apps/meteor/ee/server/models/raw/Users.ts @@ -1,8 +1,8 @@ import type { RocketChatRecordDeleted, IUser } from '@rocket.chat/core-typings'; +import { UsersRaw } from '@rocket.chat/models'; import type { Db, Collection } from 'mongodb'; import { readSecondaryPreferred } from '../../../../server/database/readSecondaryPreferred'; -import { UsersRaw } from '../../../../server/models/raw/Users'; type AgentMetadata = { 'agentId'?: string; diff --git a/apps/meteor/ee/server/models/startup.ts b/apps/meteor/ee/server/models/startup.ts index f77bcd1d7619..b558c95b4639 100644 --- a/apps/meteor/ee/server/models/startup.ts +++ b/apps/meteor/ee/server/models/startup.ts @@ -3,7 +3,6 @@ import { License } from '@rocket.chat/license'; // To facilitate our lives with the stream // Collection will be registered on CE too // No functionality will be imported tho, just the service registration -import('./LivechatPriority'); import('./OmnichannelServiceLevelAgreements'); import('./AuditLog'); import('./ReadReceipts'); diff --git a/apps/meteor/ee/tests/unit/server/hooks/messages/BeforeSaveCannedResponse.tests.ts b/apps/meteor/ee/tests/unit/server/hooks/messages/BeforeSaveCannedResponse.tests.ts index 56c4b7827940..9d2d2661dffe 100644 --- a/apps/meteor/ee/tests/unit/server/hooks/messages/BeforeSaveCannedResponse.tests.ts +++ b/apps/meteor/ee/tests/unit/server/hooks/messages/BeforeSaveCannedResponse.tests.ts @@ -1,9 +1,8 @@ -import { registerModel } from '@rocket.chat/models'; +import { registerModel, BaseRaw } from '@rocket.chat/models'; import { expect } from 'chai'; import { before, describe, it } from 'mocha'; import sinon from 'sinon'; -import { BaseRaw } from '../../../../../../server/models/raw/BaseRaw'; import { BeforeSaveCannedResponse } from '../../../../../server/hooks/messages/BeforeSaveCannedResponse'; const createMessage = (msg?: string, extra: any = {}) => ({ diff --git a/apps/meteor/server/database/trash.ts b/apps/meteor/server/database/trash.ts index 18c7161a3dc8..be4caac9b60d 100644 --- a/apps/meteor/server/database/trash.ts +++ b/apps/meteor/server/database/trash.ts @@ -1,5 +1,6 @@ +import { TrashRaw } from '@rocket.chat/models'; + import { db } from './utils'; -import { TrashRaw } from '../models/raw/Trash'; const Trash = new TrashRaw(db); export const trashCollection = Trash.col; diff --git a/apps/meteor/server/main.ts b/apps/meteor/server/main.ts index 647f476587b8..0a3b164033b9 100644 --- a/apps/meteor/server/main.ts +++ b/apps/meteor/server/main.ts @@ -1,5 +1,5 @@ import './tracing'; -import './models/startup'; +import './models'; /** * ./settings uses top level await, in theory the settings creation * and the startup should be done in parallel diff --git a/apps/meteor/server/models.ts b/apps/meteor/server/models.ts new file mode 100644 index 000000000000..b712a0ed5895 --- /dev/null +++ b/apps/meteor/server/models.ts @@ -0,0 +1,165 @@ +import type { RocketChatRecordDeleted, ISubscription, ILivechatInquiryRecord, ILivechatDepartmentAgents } from '@rocket.chat/core-typings'; +import { + AnalyticsRaw, + AppsLogsModel, + AppsModel, + AppsPersistenceModel, + AppsTokensRaw, + AvatarsRaw, + BannersDismissRaw, + BannersRaw, + CalendarEventRaw, + CredentialTokensRaw, + CronHistoryRaw, + CustomSoundsRaw, + CustomUserStatusRaw, + EmailInboxRaw, + EmailMessageHistoryRaw, + EmojiCustomRaw, + ExportOperationsRaw, + FederationKeysRaw, + FederationRoomEventsRaw, + FederationServersRaw, + ImportDataRaw, + ImportsModel, + InstanceStatusRaw, + IntegrationHistoryRaw, + IntegrationsRaw, + InvitesRaw, + LivechatAgentActivityRaw, + LivechatBusinessHoursRaw, + LivechatContactsRaw, + LivechatCustomFieldRaw, + LivechatDepartmentAgentsRaw, + LivechatDepartmentRaw, + LivechatInquiryRaw, + LivechatPriorityRaw, + LivechatRoomsRaw, + LivechatTriggerRaw, + LivechatVisitorsRaw, + LoginServiceConfigurationRaw, + MatrixBridgedRoomRaw, + MatrixBridgedUserRaw, + MessageReadsRaw, + MessagesRaw, + MigrationsRaw, + ModerationReportsRaw, + NotificationQueueRaw, + NpsRaw, + NpsVoteRaw, + OAuthAccessTokensRaw, + OAuthAppsRaw, + OAuthAuthCodesRaw, + OAuthRefreshTokensRaw, + OEmbedCacheRaw, + PbxEventsRaw, + PermissionsRaw, + PushTokenRaw, + ReadReceiptsDummy, + registerModel, + ReportsRaw, + RolesRaw, + RoomsRaw, + ServerEventsRaw, + SessionsRaw, + SettingsRaw, + SmarshHistoryRaw, + StatisticsRaw, + SubscriptionsRaw, + TeamMemberRaw, + TeamRaw, + UploadsRaw, + UserDataFilesRaw, + UsersRaw, + UsersSessionsRaw, + VideoConferenceRaw, + VoipRoomRaw, + WebdavAccountsRaw, + WorkspaceCredentialsRaw, +} from '@rocket.chat/models'; +import type { Collection } from 'mongodb'; + +import { trashCollection } from './database/trash'; +import { db } from './database/utils'; + +registerModel('IAnalyticsModel', new AnalyticsRaw(db)); +registerModel('IAppLogsModel', new AppsLogsModel(db)); +registerModel('IAppsModel', new AppsModel(db)); +registerModel('IAppsPersistenceModel', new AppsPersistenceModel(db)); +registerModel('IAppsTokensModel', new AppsTokensRaw(db)); +registerModel('IAvatarsModel', new AvatarsRaw(db)); +registerModel('IBannersDismissModel', new BannersDismissRaw(db)); +registerModel('IBannersModel', new BannersRaw(db)); +registerModel('ICalendarEventModel', new CalendarEventRaw(db)); +registerModel('ICredentialTokensModel', new CredentialTokensRaw(db)); +registerModel('ICronHistoryModel', new CronHistoryRaw(db)); +registerModel('ICustomSoundsModel', new CustomSoundsRaw(db)); +registerModel('ICustomUserStatusModel', new CustomUserStatusRaw(db)); +registerModel('IEmailInboxModel', new EmailInboxRaw(db)); +registerModel('IEmailMessageHistoryModel', new EmailMessageHistoryRaw(db)); +registerModel('IEmojiCustomModel', new EmojiCustomRaw(db, trashCollection)); +registerModel('IExportOperationsModel', new ExportOperationsRaw(db)); +registerModel('IFederationKeysModel', new FederationKeysRaw(db)); +registerModel('IFederationRoomEventsModel', new FederationRoomEventsRaw(db)); +registerModel('IFederationServersModel', new FederationServersRaw(db)); +registerModel('IImportDataModel', new ImportDataRaw(db)); +registerModel('IImportsModel', new ImportsModel(db)); +registerModel('IInstanceStatusModel', new InstanceStatusRaw(db)); +registerModel('IIntegrationHistoryModel', new IntegrationHistoryRaw(db)); +registerModel('IIntegrationsModel', new IntegrationsRaw(db)); +registerModel('IInvitesModel', new InvitesRaw(db)); +registerModel('ILivechatAgentActivityModel', new LivechatAgentActivityRaw(db)); +registerModel('ILivechatBusinessHoursModel', new LivechatBusinessHoursRaw(db)); +registerModel('ILivechatContactsModel', new LivechatContactsRaw(db)); +registerModel('ILivechatCustomFieldModel', new LivechatCustomFieldRaw(db)); +registerModel( + 'ILivechatDepartmentAgentsModel', + new LivechatDepartmentAgentsRaw(db, trashCollection as Collection>), +); +registerModel('ILivechatDepartmentModel', new LivechatDepartmentRaw(db, trashCollection)); +registerModel( + 'ILivechatInquiryModel', + new LivechatInquiryRaw(db, trashCollection as Collection>), +); +registerModel('ILivechatRoomsModel', new LivechatRoomsRaw(db, trashCollection)); +registerModel('ILivechatPriorityModel', new LivechatPriorityRaw(db)); +registerModel('ILivechatTriggerModel', new LivechatTriggerRaw(db)); +registerModel('ILivechatVisitorsModel', new LivechatVisitorsRaw(db)); +registerModel('ILoginServiceConfigurationModel', new LoginServiceConfigurationRaw(db)); +registerModel('IMatrixBridgedRoomModel', new MatrixBridgedRoomRaw(db)); +registerModel('IMatrixBridgedUserModel', new MatrixBridgedUserRaw(db)); +registerModel('IMessageReadsModel', new MessageReadsRaw(db)); +registerModel('IMessagesModel', new MessagesRaw(db, trashCollection)); +registerModel('IMigrationsModel', new MigrationsRaw(db)); +registerModel('IModerationReportsModel', new ModerationReportsRaw(db)); +registerModel('INotificationQueueModel', new NotificationQueueRaw(db)); +registerModel('INpsModel', new NpsRaw(db)); +registerModel('INpsVoteModel', new NpsVoteRaw(db)); +registerModel('IOAuthAccessTokensModel', new OAuthAccessTokensRaw(db)); +registerModel('IOAuthAppsModel', new OAuthAppsRaw(db)); +registerModel('IOAuthAuthCodesModel', new OAuthAuthCodesRaw(db)); +registerModel('IOAuthRefreshTokensModel', new OAuthRefreshTokensRaw(db)); +registerModel('IOEmbedCacheModel', new OEmbedCacheRaw(db)); +registerModel('IPbxEventsModel', new PbxEventsRaw(db)); +registerModel('IPermissionsModel', new PermissionsRaw(db, trashCollection)); +registerModel('IPushTokenModel', new PushTokenRaw(db)); +registerModel('IReadReceiptsModel', new ReadReceiptsDummy(), false); +registerModel('IReportsModel', new ReportsRaw(db)); +registerModel('IRolesModel', new RolesRaw(db, trashCollection)); +registerModel('IRoomsModel', new RoomsRaw(db, trashCollection)); +registerModel('IServerEventsModel', new ServerEventsRaw(db)); +registerModel('ISessionsModel', new SessionsRaw(db)); +registerModel('ISettingsModel', new SettingsRaw(db, trashCollection)); +registerModel('ISmarshHistoryModel', new SmarshHistoryRaw(db)); +registerModel('IStatisticsModel', new StatisticsRaw(db)); +registerModel('ISubscriptionsModel', new SubscriptionsRaw(db, trashCollection as Collection>)); +registerModel('ITeamMemberModel', new TeamMemberRaw(db)); +registerModel('ITeamModel', new TeamRaw(db)); +registerModel('IUploadsModel', new UploadsRaw(db)); +registerModel('IUserDataFilesModel', new UserDataFilesRaw(db)); +registerModel('IUsersModel', new UsersRaw(db, trashCollection)); +registerModel('IUsersSessionsModel', new UsersSessionsRaw(db)); +registerModel('IVideoConferenceModel', new VideoConferenceRaw(db)); +registerModel('IVoipRoomModel', new VoipRoomRaw(db, trashCollection)); +registerModel('IWebdavAccountsModel', new WebdavAccountsRaw(db)); +registerModel('IWorkspaceCredentialsModel', new WorkspaceCredentialsRaw(db)); diff --git a/apps/meteor/server/models/Analytics.ts b/apps/meteor/server/models/Analytics.ts deleted file mode 100644 index fd5fc32766e1..000000000000 --- a/apps/meteor/server/models/Analytics.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { AnalyticsRaw } from './raw/Analytics'; - -registerModel('IAnalyticsModel', new AnalyticsRaw(db)); diff --git a/apps/meteor/server/models/AppLogs.ts b/apps/meteor/server/models/AppLogs.ts deleted file mode 100644 index 7d4ebbb530d0..000000000000 --- a/apps/meteor/server/models/AppLogs.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { AppsLogsModel } from './raw/AppLogsModel'; - -registerModel('IAppLogsModel', new AppsLogsModel(db)); diff --git a/apps/meteor/server/models/Apps.ts b/apps/meteor/server/models/Apps.ts deleted file mode 100644 index 0f9bd3750624..000000000000 --- a/apps/meteor/server/models/Apps.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { AppsModel } from './raw/Apps'; - -registerModel('IAppsModel', new AppsModel(db)); diff --git a/apps/meteor/server/models/AppsPersistence.ts b/apps/meteor/server/models/AppsPersistence.ts deleted file mode 100644 index 297a10ec1e94..000000000000 --- a/apps/meteor/server/models/AppsPersistence.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { AppsPersistenceModel } from './raw/AppsPersistence'; - -registerModel('IAppsPersistenceModel', new AppsPersistenceModel(db)); diff --git a/apps/meteor/server/models/AppsTokens.ts b/apps/meteor/server/models/AppsTokens.ts deleted file mode 100644 index 559545b445bd..000000000000 --- a/apps/meteor/server/models/AppsTokens.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { AppsTokens } from './raw/AppsTokens'; - -registerModel('IAppsTokensModel', new AppsTokens(db)); diff --git a/apps/meteor/server/models/Avatars.ts b/apps/meteor/server/models/Avatars.ts deleted file mode 100644 index 1e74d72a2acc..000000000000 --- a/apps/meteor/server/models/Avatars.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { AvatarsRaw } from './raw/Avatars'; - -registerModel('IAvatarsModel', new AvatarsRaw(db)); diff --git a/apps/meteor/server/models/Banners.ts b/apps/meteor/server/models/Banners.ts deleted file mode 100644 index 174366f62af2..000000000000 --- a/apps/meteor/server/models/Banners.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { BannersRaw } from './raw/Banners'; - -registerModel('IBannersModel', new BannersRaw(db)); diff --git a/apps/meteor/server/models/BannersDismiss.ts b/apps/meteor/server/models/BannersDismiss.ts deleted file mode 100644 index 79e5ce956f03..000000000000 --- a/apps/meteor/server/models/BannersDismiss.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { BannersDismissRaw } from './raw/BannersDismiss'; - -registerModel('IBannersDismissModel', new BannersDismissRaw(db)); diff --git a/apps/meteor/server/models/CalendarEvent.ts b/apps/meteor/server/models/CalendarEvent.ts deleted file mode 100644 index 669ecbbdb91c..000000000000 --- a/apps/meteor/server/models/CalendarEvent.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { CalendarEventRaw } from './raw/CalendarEvent'; - -registerModel('ICalendarEventModel', new CalendarEventRaw(db)); diff --git a/apps/meteor/server/models/CredentialTokens.ts b/apps/meteor/server/models/CredentialTokens.ts deleted file mode 100644 index 2d88bd25dc86..000000000000 --- a/apps/meteor/server/models/CredentialTokens.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { CredentialTokensRaw } from './raw/CredentialTokens'; - -registerModel('ICredentialTokensModel', new CredentialTokensRaw(db)); diff --git a/apps/meteor/server/models/CronHistory.ts b/apps/meteor/server/models/CronHistory.ts deleted file mode 100644 index 2589026b9c1e..000000000000 --- a/apps/meteor/server/models/CronHistory.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { CronHistoryRaw } from './raw/CronHistoryModel'; - -registerModel('ICronHistoryModel', new CronHistoryRaw(db)); diff --git a/apps/meteor/server/models/CustomSounds.ts b/apps/meteor/server/models/CustomSounds.ts deleted file mode 100644 index acce42fc62ed..000000000000 --- a/apps/meteor/server/models/CustomSounds.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { CustomSoundsRaw } from './raw/CustomSounds'; - -registerModel('ICustomSoundsModel', new CustomSoundsRaw(db)); diff --git a/apps/meteor/server/models/CustomUserStatus.ts b/apps/meteor/server/models/CustomUserStatus.ts deleted file mode 100644 index fe62266866b4..000000000000 --- a/apps/meteor/server/models/CustomUserStatus.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { CustomUserStatusRaw } from './raw/CustomUserStatus'; - -registerModel('ICustomUserStatusModel', new CustomUserStatusRaw(db)); diff --git a/apps/meteor/server/models/EmailInbox.ts b/apps/meteor/server/models/EmailInbox.ts deleted file mode 100644 index 27596319c9ad..000000000000 --- a/apps/meteor/server/models/EmailInbox.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { EmailInboxRaw } from './raw/EmailInbox'; - -registerModel('IEmailInboxModel', new EmailInboxRaw(db)); diff --git a/apps/meteor/server/models/EmailMessageHistory.ts b/apps/meteor/server/models/EmailMessageHistory.ts deleted file mode 100644 index d5a94648d734..000000000000 --- a/apps/meteor/server/models/EmailMessageHistory.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { EmailMessageHistoryRaw } from './raw/EmailMessageHistory'; - -registerModel('IEmailMessageHistoryModel', new EmailMessageHistoryRaw(db)); diff --git a/apps/meteor/server/models/EmojiCustom.ts b/apps/meteor/server/models/EmojiCustom.ts deleted file mode 100644 index 0f7e9d6ef62b..000000000000 --- a/apps/meteor/server/models/EmojiCustom.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { trashCollection } from '../database/trash'; -import { db } from '../database/utils'; -import { EmojiCustomRaw } from './raw/EmojiCustom'; - -registerModel('IEmojiCustomModel', new EmojiCustomRaw(db, trashCollection)); diff --git a/apps/meteor/server/models/ExportOperations.ts b/apps/meteor/server/models/ExportOperations.ts deleted file mode 100644 index 332aac21ea78..000000000000 --- a/apps/meteor/server/models/ExportOperations.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { ExportOperationsRaw } from './raw/ExportOperations'; - -registerModel('IExportOperationsModel', new ExportOperationsRaw(db)); diff --git a/apps/meteor/server/models/FederationKeys.ts b/apps/meteor/server/models/FederationKeys.ts deleted file mode 100644 index fa7e80d4f7f1..000000000000 --- a/apps/meteor/server/models/FederationKeys.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { FederationKeysRaw } from './raw/FederationKeys'; - -registerModel('IFederationKeysModel', new FederationKeysRaw(db)); diff --git a/apps/meteor/server/models/FederationRoomEvents.ts b/apps/meteor/server/models/FederationRoomEvents.ts deleted file mode 100644 index 67aefab9825e..000000000000 --- a/apps/meteor/server/models/FederationRoomEvents.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { FederationRoomEvents } from './raw/FederationRoomEvents'; - -registerModel('IFederationRoomEventsModel', new FederationRoomEvents(db)); diff --git a/apps/meteor/server/models/FederationServers.ts b/apps/meteor/server/models/FederationServers.ts deleted file mode 100644 index b4c0cf1a3584..000000000000 --- a/apps/meteor/server/models/FederationServers.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { FederationServersRaw } from './raw/FederationServers'; - -registerModel('IFederationServersModel', new FederationServersRaw(db)); diff --git a/apps/meteor/server/models/FreeSwitchCall.ts b/apps/meteor/server/models/FreeSwitchCall.ts deleted file mode 100644 index 97b470538e80..000000000000 --- a/apps/meteor/server/models/FreeSwitchCall.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { FreeSwitchCallRaw } from './raw/FreeSwitchCall'; - -registerModel('IFreeSwitchCallModel', new FreeSwitchCallRaw(db)); diff --git a/apps/meteor/server/models/FreeSwitchEvent.ts b/apps/meteor/server/models/FreeSwitchEvent.ts deleted file mode 100644 index cab4d7daa2e4..000000000000 --- a/apps/meteor/server/models/FreeSwitchEvent.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { FreeSwitchEventRaw } from './raw/FreeSwitchEvent'; - -registerModel('IFreeSwitchEventModel', new FreeSwitchEventRaw(db)); diff --git a/apps/meteor/server/models/ImportData.ts b/apps/meteor/server/models/ImportData.ts deleted file mode 100644 index ac3ee0b05f13..000000000000 --- a/apps/meteor/server/models/ImportData.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { ImportDataRaw } from './raw/ImportData'; - -registerModel('IImportDataModel', new ImportDataRaw(db)); diff --git a/apps/meteor/server/models/Imports.ts b/apps/meteor/server/models/Imports.ts deleted file mode 100644 index 72f9e0eb014c..000000000000 --- a/apps/meteor/server/models/Imports.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { ImportsModel } from './raw/Imports'; - -registerModel('IImportsModel', new ImportsModel(db)); diff --git a/apps/meteor/server/models/InstanceStatus.ts b/apps/meteor/server/models/InstanceStatus.ts deleted file mode 100644 index 571a16e6bd85..000000000000 --- a/apps/meteor/server/models/InstanceStatus.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { InstanceStatusRaw } from './raw/InstanceStatus'; - -registerModel('IInstanceStatusModel', new InstanceStatusRaw(db)); diff --git a/apps/meteor/server/models/IntegrationHistory.ts b/apps/meteor/server/models/IntegrationHistory.ts deleted file mode 100644 index 839d143a7cd7..000000000000 --- a/apps/meteor/server/models/IntegrationHistory.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { IntegrationHistoryRaw } from './raw/IntegrationHistory'; - -registerModel('IIntegrationHistoryModel', new IntegrationHistoryRaw(db)); diff --git a/apps/meteor/server/models/Integrations.ts b/apps/meteor/server/models/Integrations.ts deleted file mode 100644 index 50b7059e6232..000000000000 --- a/apps/meteor/server/models/Integrations.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { IntegrationsRaw } from './raw/Integrations'; - -registerModel('IIntegrationsModel', new IntegrationsRaw(db)); diff --git a/apps/meteor/server/models/Invites.ts b/apps/meteor/server/models/Invites.ts deleted file mode 100644 index 0419ada05df8..000000000000 --- a/apps/meteor/server/models/Invites.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { InvitesRaw } from './raw/Invites'; - -registerModel('IInvitesModel', new InvitesRaw(db)); diff --git a/apps/meteor/server/models/LivechatAgentActivity.ts b/apps/meteor/server/models/LivechatAgentActivity.ts deleted file mode 100644 index 4fdb3b8e3697..000000000000 --- a/apps/meteor/server/models/LivechatAgentActivity.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { LivechatAgentActivityRaw } from './raw/LivechatAgentActivity'; - -registerModel('ILivechatAgentActivityModel', new LivechatAgentActivityRaw(db)); diff --git a/apps/meteor/server/models/LivechatBusinessHours.ts b/apps/meteor/server/models/LivechatBusinessHours.ts deleted file mode 100644 index be1aff0a7f9e..000000000000 --- a/apps/meteor/server/models/LivechatBusinessHours.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { LivechatBusinessHoursRaw } from './raw/LivechatBusinessHours'; - -registerModel('ILivechatBusinessHoursModel', new LivechatBusinessHoursRaw(db)); diff --git a/apps/meteor/server/models/LivechatContacts.ts b/apps/meteor/server/models/LivechatContacts.ts deleted file mode 100644 index d341ae87b021..000000000000 --- a/apps/meteor/server/models/LivechatContacts.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { LivechatContactsRaw } from './raw/LivechatContacts'; - -registerModel('ILivechatContactsModel', new LivechatContactsRaw(db)); diff --git a/apps/meteor/server/models/LivechatCustomField.ts b/apps/meteor/server/models/LivechatCustomField.ts deleted file mode 100644 index 25e6af9366e0..000000000000 --- a/apps/meteor/server/models/LivechatCustomField.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { LivechatCustomFieldRaw } from './raw/LivechatCustomField'; - -registerModel('ILivechatCustomFieldModel', new LivechatCustomFieldRaw(db)); diff --git a/apps/meteor/server/models/LivechatDepartment.ts b/apps/meteor/server/models/LivechatDepartment.ts deleted file mode 100644 index 3e1eec2a945d..000000000000 --- a/apps/meteor/server/models/LivechatDepartment.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { trashCollection } from '../database/trash'; -import { db } from '../database/utils'; -import { LivechatDepartmentRaw } from './raw/LivechatDepartment'; - -registerModel('ILivechatDepartmentModel', new LivechatDepartmentRaw(db, trashCollection)); diff --git a/apps/meteor/server/models/LivechatDepartmentAgents.ts b/apps/meteor/server/models/LivechatDepartmentAgents.ts deleted file mode 100644 index 26b79260c81f..000000000000 --- a/apps/meteor/server/models/LivechatDepartmentAgents.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { trashCollection } from '../database/trash'; -import { db } from '../database/utils'; -import { LivechatDepartmentAgentsRaw } from './raw/LivechatDepartmentAgents'; - -registerModel('ILivechatDepartmentAgentsModel', new LivechatDepartmentAgentsRaw(db, trashCollection)); diff --git a/apps/meteor/server/models/LivechatInquiry.ts b/apps/meteor/server/models/LivechatInquiry.ts deleted file mode 100644 index cb14c207027b..000000000000 --- a/apps/meteor/server/models/LivechatInquiry.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { trashCollection } from '../database/trash'; -import { db } from '../database/utils'; -import { LivechatInquiryRaw } from './raw/LivechatInquiry'; - -registerModel('ILivechatInquiryModel', new LivechatInquiryRaw(db, trashCollection)); diff --git a/apps/meteor/server/models/LivechatRooms.ts b/apps/meteor/server/models/LivechatRooms.ts deleted file mode 100644 index 0e84584c0d88..000000000000 --- a/apps/meteor/server/models/LivechatRooms.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { trashCollection } from '../database/trash'; -import { db } from '../database/utils'; -import { LivechatRoomsRaw } from './raw/LivechatRooms'; - -registerModel('ILivechatRoomsModel', new LivechatRoomsRaw(db, trashCollection)); diff --git a/apps/meteor/server/models/LivechatTrigger.ts b/apps/meteor/server/models/LivechatTrigger.ts deleted file mode 100644 index 2c3221d4f59f..000000000000 --- a/apps/meteor/server/models/LivechatTrigger.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { LivechatTriggerRaw } from './raw/LivechatTrigger'; - -registerModel('ILivechatTriggerModel', new LivechatTriggerRaw(db)); diff --git a/apps/meteor/server/models/LivechatVisitors.ts b/apps/meteor/server/models/LivechatVisitors.ts deleted file mode 100644 index 81111ff842fa..000000000000 --- a/apps/meteor/server/models/LivechatVisitors.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { LivechatVisitorsRaw } from './raw/LivechatVisitors'; - -registerModel('ILivechatVisitorsModel', new LivechatVisitorsRaw(db)); diff --git a/apps/meteor/server/models/LoginServiceConfiguration.ts b/apps/meteor/server/models/LoginServiceConfiguration.ts deleted file mode 100644 index dd4f7dbae6de..000000000000 --- a/apps/meteor/server/models/LoginServiceConfiguration.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { LoginServiceConfigurationRaw } from './raw/LoginServiceConfiguration'; - -registerModel('ILoginServiceConfigurationModel', new LoginServiceConfigurationRaw(db)); diff --git a/apps/meteor/server/models/MatrixBridgedRoom.ts b/apps/meteor/server/models/MatrixBridgedRoom.ts deleted file mode 100644 index 38dbdac880b6..000000000000 --- a/apps/meteor/server/models/MatrixBridgedRoom.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { MatrixBridgedRoomRaw } from './raw/MatrixBridgedRoom'; - -registerModel('IMatrixBridgedRoomModel', new MatrixBridgedRoomRaw(db)); diff --git a/apps/meteor/server/models/MatrixBridgedUser.ts b/apps/meteor/server/models/MatrixBridgedUser.ts deleted file mode 100644 index 7f813748ae50..000000000000 --- a/apps/meteor/server/models/MatrixBridgedUser.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { MatrixBridgedUserRaw } from './raw/MatrixBridgedUser'; - -registerModel('IMatrixBridgedUserModel', new MatrixBridgedUserRaw(db)); diff --git a/apps/meteor/server/models/MessageReads.ts b/apps/meteor/server/models/MessageReads.ts deleted file mode 100644 index 43984e9e2b4a..000000000000 --- a/apps/meteor/server/models/MessageReads.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { MessageReadsRaw } from './raw/MessageReads'; - -registerModel('IMessageReadsModel', new MessageReadsRaw(db)); diff --git a/apps/meteor/server/models/Messages.ts b/apps/meteor/server/models/Messages.ts deleted file mode 100644 index e9de00514627..000000000000 --- a/apps/meteor/server/models/Messages.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { trashCollection } from '../database/trash'; -import { db } from '../database/utils'; -import { MessagesRaw } from './raw/Messages'; - -registerModel('IMessagesModel', new MessagesRaw(db, trashCollection)); diff --git a/apps/meteor/server/models/Migrations.ts b/apps/meteor/server/models/Migrations.ts deleted file mode 100644 index 41e98fac1151..000000000000 --- a/apps/meteor/server/models/Migrations.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { MigrationsRaw } from './raw/Migrations'; - -registerModel('IMigrationsModel', new MigrationsRaw(db)); diff --git a/apps/meteor/server/models/ModerationReports.ts b/apps/meteor/server/models/ModerationReports.ts deleted file mode 100644 index e3014ef849b8..000000000000 --- a/apps/meteor/server/models/ModerationReports.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { ModerationReportsRaw } from './raw/ModerationReports'; - -registerModel('IModerationReportsModel', () => new ModerationReportsRaw(db)); diff --git a/apps/meteor/server/models/NotificationQueue.ts b/apps/meteor/server/models/NotificationQueue.ts deleted file mode 100644 index 68d729f49d95..000000000000 --- a/apps/meteor/server/models/NotificationQueue.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { NotificationQueueRaw } from './raw/NotificationQueue'; - -registerModel('INotificationQueueModel', new NotificationQueueRaw(db)); diff --git a/apps/meteor/server/models/Nps.ts b/apps/meteor/server/models/Nps.ts deleted file mode 100644 index 4cdf7a4a31af..000000000000 --- a/apps/meteor/server/models/Nps.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { NpsRaw } from './raw/Nps'; - -registerModel('INpsModel', new NpsRaw(db)); diff --git a/apps/meteor/server/models/NpsVote.ts b/apps/meteor/server/models/NpsVote.ts deleted file mode 100644 index e784ad789dbc..000000000000 --- a/apps/meteor/server/models/NpsVote.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { NpsVoteRaw } from './raw/NpsVote'; - -registerModel('INpsVoteModel', new NpsVoteRaw(db)); diff --git a/apps/meteor/server/models/OAuthAccessTokens.ts b/apps/meteor/server/models/OAuthAccessTokens.ts deleted file mode 100644 index ec6fa236a5d6..000000000000 --- a/apps/meteor/server/models/OAuthAccessTokens.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { OAuthAccessTokensRaw } from './raw/OAuthAccessTokens'; - -registerModel('IOAuthAccessTokensModel', new OAuthAccessTokensRaw(db)); diff --git a/apps/meteor/server/models/OAuthApps.ts b/apps/meteor/server/models/OAuthApps.ts deleted file mode 100644 index e56bcae5914c..000000000000 --- a/apps/meteor/server/models/OAuthApps.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { OAuthAppsRaw } from './raw/OAuthApps'; - -registerModel('IOAuthAppsModel', new OAuthAppsRaw(db)); diff --git a/apps/meteor/server/models/OAuthAuthCodes.ts b/apps/meteor/server/models/OAuthAuthCodes.ts deleted file mode 100644 index fa7f422425b8..000000000000 --- a/apps/meteor/server/models/OAuthAuthCodes.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { OAuthAuthCodesRaw } from './raw/OAuthAuthCodes'; - -registerModel('IOAuthAuthCodesModel', new OAuthAuthCodesRaw(db)); diff --git a/apps/meteor/server/models/OAuthRefreshTokens.ts b/apps/meteor/server/models/OAuthRefreshTokens.ts deleted file mode 100644 index 9c5dad78a98f..000000000000 --- a/apps/meteor/server/models/OAuthRefreshTokens.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { OAuthRefreshTokensRaw } from './raw/OAuthRefreshTokens'; - -registerModel('IOAuthRefreshTokensModel', new OAuthRefreshTokensRaw(db)); diff --git a/apps/meteor/server/models/OEmbedCache.ts b/apps/meteor/server/models/OEmbedCache.ts deleted file mode 100644 index 4836ea556937..000000000000 --- a/apps/meteor/server/models/OEmbedCache.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { OEmbedCacheRaw } from './raw/OEmbedCache'; - -registerModel('IOEmbedCacheModel', new OEmbedCacheRaw(db)); diff --git a/apps/meteor/server/models/PbxEvents.ts b/apps/meteor/server/models/PbxEvents.ts deleted file mode 100644 index 82ba25a392db..000000000000 --- a/apps/meteor/server/models/PbxEvents.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { PbxEventsRaw } from './raw/PbxEvents'; - -registerModel('IPbxEventsModel', new PbxEventsRaw(db)); diff --git a/apps/meteor/server/models/Permissions.ts b/apps/meteor/server/models/Permissions.ts deleted file mode 100644 index edbf68dbfc59..000000000000 --- a/apps/meteor/server/models/Permissions.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { trashCollection } from '../database/trash'; -import { db } from '../database/utils'; -import { PermissionsRaw } from './raw/Permissions'; - -registerModel('IPermissionsModel', new PermissionsRaw(db, trashCollection)); diff --git a/apps/meteor/server/models/PushToken.ts b/apps/meteor/server/models/PushToken.ts deleted file mode 100644 index 16df39673dd7..000000000000 --- a/apps/meteor/server/models/PushToken.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { PushTokenRaw } from './raw/PushToken'; - -registerModel('IPushTokenModel', new PushTokenRaw(db)); diff --git a/apps/meteor/server/models/ReadReceipts.ts b/apps/meteor/server/models/ReadReceipts.ts deleted file mode 100644 index 5faf90c33546..000000000000 --- a/apps/meteor/server/models/ReadReceipts.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { ReadReceiptsDummy } from './dummy/ReadReceipts'; - -registerModel('IReadReceiptsModel', new ReadReceiptsDummy(), false); diff --git a/apps/meteor/server/models/Reports.ts b/apps/meteor/server/models/Reports.ts deleted file mode 100644 index ec328bc0b5d6..000000000000 --- a/apps/meteor/server/models/Reports.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { ReportsRaw } from './raw/Reports'; - -registerModel('IReportsModel', new ReportsRaw(db)); diff --git a/apps/meteor/server/models/Roles.ts b/apps/meteor/server/models/Roles.ts deleted file mode 100644 index f4f924b5acca..000000000000 --- a/apps/meteor/server/models/Roles.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { trashCollection } from '../database/trash'; -import { db } from '../database/utils'; -import { RolesRaw } from './raw/Roles'; - -registerModel('IRolesModel', new RolesRaw(db, trashCollection)); diff --git a/apps/meteor/server/models/Rooms.ts b/apps/meteor/server/models/Rooms.ts deleted file mode 100644 index 59d4ccc9f2c4..000000000000 --- a/apps/meteor/server/models/Rooms.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { trashCollection } from '../database/trash'; -import { db } from '../database/utils'; -import { RoomsRaw } from './raw/Rooms'; - -registerModel('IRoomsModel', new RoomsRaw(db, trashCollection)); diff --git a/apps/meteor/server/models/ServerEvents.ts b/apps/meteor/server/models/ServerEvents.ts deleted file mode 100644 index 997026f7b515..000000000000 --- a/apps/meteor/server/models/ServerEvents.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { ServerEventsRaw } from './raw/ServerEvents'; - -registerModel('IServerEventsModel', new ServerEventsRaw(db)); diff --git a/apps/meteor/server/models/Sessions.ts b/apps/meteor/server/models/Sessions.ts deleted file mode 100644 index 9abe142be3a8..000000000000 --- a/apps/meteor/server/models/Sessions.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { SessionsRaw } from './raw/Sessions'; - -registerModel('ISessionsModel', new SessionsRaw(db)); diff --git a/apps/meteor/server/models/Settings.ts b/apps/meteor/server/models/Settings.ts deleted file mode 100644 index bd14012e1f6a..000000000000 --- a/apps/meteor/server/models/Settings.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { trashCollection } from '../database/trash'; -import { db } from '../database/utils'; -import { SettingsRaw } from './raw/Settings'; - -registerModel('ISettingsModel', new SettingsRaw(db, trashCollection)); diff --git a/apps/meteor/server/models/SmarshHistory.ts b/apps/meteor/server/models/SmarshHistory.ts deleted file mode 100644 index 9414a37993c0..000000000000 --- a/apps/meteor/server/models/SmarshHistory.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { SmarshHistoryRaw } from './raw/SmarshHistory'; - -registerModel('ISmarshHistoryModel', new SmarshHistoryRaw(db)); diff --git a/apps/meteor/server/models/Statistics.ts b/apps/meteor/server/models/Statistics.ts deleted file mode 100644 index 9a9d69d3bc22..000000000000 --- a/apps/meteor/server/models/Statistics.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { StatisticsRaw } from './raw/Statistics'; - -registerModel('IStatisticsModel', new StatisticsRaw(db)); diff --git a/apps/meteor/server/models/Subscriptions.ts b/apps/meteor/server/models/Subscriptions.ts deleted file mode 100644 index 36a8d75ad49d..000000000000 --- a/apps/meteor/server/models/Subscriptions.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { trashCollection } from '../database/trash'; -import { db } from '../database/utils'; -import { SubscriptionsRaw } from './raw/Subscriptions'; - -registerModel('ISubscriptionsModel', new SubscriptionsRaw(db, trashCollection)); diff --git a/apps/meteor/server/models/Team.ts b/apps/meteor/server/models/Team.ts deleted file mode 100644 index 5c1264c6e2a4..000000000000 --- a/apps/meteor/server/models/Team.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { TeamRaw } from './raw/Team'; - -registerModel('ITeamModel', new TeamRaw(db)); diff --git a/apps/meteor/server/models/TeamMember.ts b/apps/meteor/server/models/TeamMember.ts deleted file mode 100644 index 7c34bea74b7b..000000000000 --- a/apps/meteor/server/models/TeamMember.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { TeamMemberRaw } from './raw/TeamMember'; - -registerModel('ITeamMemberModel', new TeamMemberRaw(db)); diff --git a/apps/meteor/server/models/Uploads.ts b/apps/meteor/server/models/Uploads.ts deleted file mode 100644 index 1aee2cef260c..000000000000 --- a/apps/meteor/server/models/Uploads.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { UploadsRaw } from './raw/Uploads'; - -registerModel('IUploadsModel', new UploadsRaw(db)); diff --git a/apps/meteor/server/models/UserDataFiles.ts b/apps/meteor/server/models/UserDataFiles.ts deleted file mode 100644 index 72fa09dccc2f..000000000000 --- a/apps/meteor/server/models/UserDataFiles.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { UserDataFilesRaw } from './raw/UserDataFiles'; - -registerModel('IUserDataFilesModel', new UserDataFilesRaw(db)); diff --git a/apps/meteor/server/models/Users.ts b/apps/meteor/server/models/Users.ts deleted file mode 100644 index b9b7ad6298a7..000000000000 --- a/apps/meteor/server/models/Users.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { UsersRaw } from './raw/Users'; - -registerModel('IUsersModel', new UsersRaw(db)); diff --git a/apps/meteor/server/models/UsersSessions.ts b/apps/meteor/server/models/UsersSessions.ts deleted file mode 100644 index d7cca6105523..000000000000 --- a/apps/meteor/server/models/UsersSessions.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { UsersSessionsRaw } from './raw/UsersSessions'; - -registerModel('IUsersSessionsModel', new UsersSessionsRaw(db)); diff --git a/apps/meteor/server/models/VideoConference.ts b/apps/meteor/server/models/VideoConference.ts deleted file mode 100644 index 7c052ef304dc..000000000000 --- a/apps/meteor/server/models/VideoConference.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { VideoConferenceRaw } from './raw/VideoConference'; - -registerModel('IVideoConferenceModel', new VideoConferenceRaw(db)); diff --git a/apps/meteor/server/models/VoipRoom.ts b/apps/meteor/server/models/VoipRoom.ts deleted file mode 100644 index e743b7185a92..000000000000 --- a/apps/meteor/server/models/VoipRoom.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { trashCollection } from '../database/trash'; -import { db } from '../database/utils'; -import { VoipRoomRaw } from './raw/VoipRoom'; - -registerModel('IVoipRoomModel', new VoipRoomRaw(db, trashCollection)); diff --git a/apps/meteor/server/models/WebdavAccounts.ts b/apps/meteor/server/models/WebdavAccounts.ts deleted file mode 100644 index 3ae1e07f9ca1..000000000000 --- a/apps/meteor/server/models/WebdavAccounts.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { WebdavAccountsRaw } from './raw/WebdavAccounts'; - -registerModel('IWebdavAccountsModel', new WebdavAccountsRaw(db)); diff --git a/apps/meteor/server/models/WorkspaceCredentials.ts b/apps/meteor/server/models/WorkspaceCredentials.ts deleted file mode 100644 index 7901f2bfef2d..000000000000 --- a/apps/meteor/server/models/WorkspaceCredentials.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { registerModel } from '@rocket.chat/models'; - -import { db } from '../database/utils'; -import { WorkspaceCredentialsRaw } from './raw/WorkspaceCredentials'; - -registerModel('IWorkspaceCredentialsModel', new WorkspaceCredentialsRaw(db)); diff --git a/apps/meteor/server/models/startup.ts b/apps/meteor/server/models/startup.ts deleted file mode 100644 index a03c2265c683..000000000000 --- a/apps/meteor/server/models/startup.ts +++ /dev/null @@ -1,75 +0,0 @@ -import './Analytics'; -import './Apps'; -import './AppLogs'; -import './AppsPersistence'; -import './Avatars'; -import './Banners'; -import './BannersDismiss'; -import './CalendarEvent'; -import './CredentialTokens'; -import './CustomSounds'; -import './CustomUserStatus'; -import './EmailInbox'; -import './EmailMessageHistory'; -import './EmojiCustom'; -import './ExportOperations'; -import './FederationKeys'; -import './FederationServers'; -import './FreeSwitchCall'; -import './FreeSwitchEvent'; -import './ImportData'; -import './InstanceStatus'; -import './IntegrationHistory'; -import './Integrations'; -import './Invites'; -import './LivechatAgentActivity'; -import './LivechatBusinessHours'; -import './LivechatContacts'; -import './LivechatCustomField'; -import './LivechatDepartment'; -import './LivechatDepartmentAgents'; -import './LivechatInquiry'; -import './LivechatRooms'; -import './LivechatTrigger'; -import './LivechatVisitors'; -import './LoginServiceConfiguration'; -import './MatrixBridgedRoom'; -import './MatrixBridgedUser'; -import './Messages'; -import './NotificationQueue'; -import './Nps'; -import './NpsVote'; -import './OAuthApps'; -import './OAuthAuthCodes'; -import './OAuthAccessTokens'; -import './OAuthRefreshTokens'; -import './OEmbedCache'; -import './PbxEvents'; -import './PushToken'; -import './Permissions'; -import './MessageReads'; -import './ModerationReports'; -import './Roles'; -import './Rooms'; -import './ServerEvents'; -import './Sessions'; -import './Settings'; -import './SmarshHistory'; -import './Statistics'; -import './Subscriptions'; -import './Team'; -import './TeamMember'; -import './Uploads'; -import './UserDataFiles'; -import './Users'; -import './UsersSessions'; -import './VideoConference'; -import './VoipRoom'; -import './WebdavAccounts'; -import './FederationRoomEvents'; -import './Imports'; -import './AppsTokens'; -import './CronHistory'; -import './Migrations'; -import './ReadReceipts'; -import './WorkspaceCredentials'; diff --git a/apps/meteor/tests/unit/server/services/banner/service.tests.ts b/apps/meteor/tests/unit/server/services/banner/service.tests.ts index b1892ff849d1..b570f87365df 100644 --- a/apps/meteor/tests/unit/server/services/banner/service.tests.ts +++ b/apps/meteor/tests/unit/server/services/banner/service.tests.ts @@ -1,13 +1,11 @@ import type { BannerPlatform, IBanner, IBannerDismiss } from '@rocket.chat/core-typings'; -import { registerModel } from '@rocket.chat/models'; +import { registerModel, BaseRaw } from '@rocket.chat/models'; import { expect } from 'chai'; import { afterEach, before, describe, it } from 'mocha'; import type { FindCursor, FindOptions } from 'mongodb'; import proxyquire from 'proxyquire'; import sinon from 'sinon'; -import { BaseRaw } from '../../../../../server/models/raw/BaseRaw'; - const { BannerService } = proxyquire.noCallThru().load('../../../../../server/services/banner/service', {}); class BannerModel extends BaseRaw { diff --git a/apps/meteor/tests/unit/server/services/user/service.tests.ts b/apps/meteor/tests/unit/server/services/user/service.tests.ts index b4b4d950673f..8c12af015d73 100644 --- a/apps/meteor/tests/unit/server/services/user/service.tests.ts +++ b/apps/meteor/tests/unit/server/services/user/service.tests.ts @@ -1,11 +1,9 @@ -import { registerModel } from '@rocket.chat/models'; +import { registerModel, BaseRaw } from '@rocket.chat/models'; import { expect } from 'chai'; import { afterEach, before, describe, it } from 'mocha'; import proxyquire from 'proxyquire'; import sinon from 'sinon'; -import { BaseRaw } from '../../../../../server/models/raw/BaseRaw'; - const maxTokens = { getMaxLoginTokens: () => 2, }; diff --git a/ee/apps/account-service/Dockerfile b/ee/apps/account-service/Dockerfile index 272a781ce5b0..4adc86ff1bc9 100644 --- a/ee/apps/account-service/Dockerfile +++ b/ee/apps/account-service/Dockerfile @@ -47,6 +47,12 @@ COPY ./ee/packages/network-broker/dist ee/packages/network-broker/dist COPY ./ee/packages/license/package.json packages/license/package.json COPY ./ee/packages/license/dist packages/license/dist +COPY ./packages/random/package.json packages/random/package.json +COPY ./packages/random/dist packages/random/dist + +COPY ./packages/sha256/package.json packages/sha256/package.json +COPY ./packages/sha256/dist packages/sha256/dist + COPY ./packages/tracing/package.json packages/tracing/package.json COPY ./packages/tracing/dist packages/tracing/dist diff --git a/ee/apps/account-service/package.json b/ee/apps/account-service/package.json index da2122998c23..35b7bd119516 100644 --- a/ee/apps/account-service/package.json +++ b/ee/apps/account-service/package.json @@ -18,6 +18,7 @@ "@rocket.chat/core-services": "workspace:^", "@rocket.chat/core-typings": "workspace:^", "@rocket.chat/emitter": "~0.31.25", + "@rocket.chat/logger": "workspace:^", "@rocket.chat/model-typings": "workspace:^", "@rocket.chat/models": "workspace:^", "@rocket.chat/network-broker": "workspace:^", diff --git a/ee/apps/account-service/src/service.ts b/ee/apps/account-service/src/service.ts index e9e8cd8bef83..54ecd217091d 100755 --- a/ee/apps/account-service/src/service.ts +++ b/ee/apps/account-service/src/service.ts @@ -1,10 +1,9 @@ import { api, getConnection, getTrashCollection } from '@rocket.chat/core-services'; +import { registerServiceModels } from '@rocket.chat/models'; import { broker } from '@rocket.chat/network-broker'; import { startTracing } from '@rocket.chat/tracing'; import polka from 'polka'; -import { registerServiceModels } from '../../../../apps/meteor/ee/server/lib/registerServiceModels'; - const PORT = process.env.PORT || 3033; (async () => { diff --git a/ee/apps/account-service/tsconfig.json b/ee/apps/account-service/tsconfig.json index 032878e7b4b8..85c682540991 100644 --- a/ee/apps/account-service/tsconfig.json +++ b/ee/apps/account-service/tsconfig.json @@ -12,7 +12,7 @@ "noImplicitReturns": false, "noFallthroughCasesInSwitch": false, - "outDir": "./dist" + "outDir": "./dist/ee/apps/account-service/src", }, "files": ["./src/service.ts"], "include": ["../../../apps/meteor/definition/externals/meteor"], diff --git a/ee/apps/authorization-service/Dockerfile b/ee/apps/authorization-service/Dockerfile index de7b41913a20..18ad2653a631 100644 --- a/ee/apps/authorization-service/Dockerfile +++ b/ee/apps/authorization-service/Dockerfile @@ -47,6 +47,12 @@ COPY ./ee/packages/network-broker/dist ee/packages/network-broker/dist COPY ./ee/packages/license/package.json packages/license/package.json COPY ./ee/packages/license/dist packages/license/dist +COPY ./packages/random/package.json packages/random/package.json +COPY ./packages/random/dist packages/random/dist + +COPY ./packages/sha256/package.json packages/sha256/package.json +COPY ./packages/sha256/dist packages/sha256/dist + COPY ./packages/tracing/package.json packages/tracing/package.json COPY ./packages/tracing/dist packages/tracing/dist diff --git a/ee/apps/authorization-service/package.json b/ee/apps/authorization-service/package.json index 83719a245bf5..40fd480b0a0f 100644 --- a/ee/apps/authorization-service/package.json +++ b/ee/apps/authorization-service/package.json @@ -18,6 +18,7 @@ "@rocket.chat/core-services": "workspace:^", "@rocket.chat/core-typings": "workspace:^", "@rocket.chat/emitter": "~0.31.25", + "@rocket.chat/logger": "workspace:^", "@rocket.chat/model-typings": "workspace:^", "@rocket.chat/models": "workspace:^", "@rocket.chat/network-broker": "workspace:^", diff --git a/ee/apps/authorization-service/src/service.ts b/ee/apps/authorization-service/src/service.ts index 8b3350c5f754..0ed1e83177a1 100755 --- a/ee/apps/authorization-service/src/service.ts +++ b/ee/apps/authorization-service/src/service.ts @@ -1,10 +1,9 @@ import { api, getConnection, getTrashCollection } from '@rocket.chat/core-services'; +import { registerServiceModels } from '@rocket.chat/models'; import { broker } from '@rocket.chat/network-broker'; import { startTracing } from '@rocket.chat/tracing'; import polka from 'polka'; -import { registerServiceModels } from '../../../../apps/meteor/ee/server/lib/registerServiceModels'; - const PORT = process.env.PORT || 3034; (async () => { diff --git a/ee/apps/ddp-streamer/Dockerfile b/ee/apps/ddp-streamer/Dockerfile index e0ff3620e17d..411d25ff7c3c 100644 --- a/ee/apps/ddp-streamer/Dockerfile +++ b/ee/apps/ddp-streamer/Dockerfile @@ -50,6 +50,12 @@ COPY ./ee/packages/network-broker/dist ee/packages/network-broker/dist COPY ./ee/packages/license/package.json packages/license/package.json COPY ./ee/packages/license/dist packages/license/dist +COPY ./packages/random/package.json packages/random/package.json +COPY ./packages/random/dist packages/random/dist + +COPY ./packages/sha256/package.json packages/sha256/package.json +COPY ./packages/sha256/dist packages/sha256/dist + COPY ./packages/instance-status/package.json packages/instance-status/package.json COPY ./packages/instance-status/dist packages/instance-status/dist diff --git a/ee/apps/ddp-streamer/src/service.ts b/ee/apps/ddp-streamer/src/service.ts index 66ad72be4050..0afea31dc231 100755 --- a/ee/apps/ddp-streamer/src/service.ts +++ b/ee/apps/ddp-streamer/src/service.ts @@ -1,9 +1,8 @@ import { api, getConnection, getTrashCollection } from '@rocket.chat/core-services'; +import { registerServiceModels } from '@rocket.chat/models'; import { broker } from '@rocket.chat/network-broker'; import { startTracing } from '@rocket.chat/tracing'; -import { registerServiceModels } from '../../../../apps/meteor/ee/server/lib/registerServiceModels'; - (async () => { const { db, client } = await getConnection(); diff --git a/ee/apps/omnichannel-transcript/Dockerfile b/ee/apps/omnichannel-transcript/Dockerfile index daf27317e554..eb709d2f3ed0 100644 --- a/ee/apps/omnichannel-transcript/Dockerfile +++ b/ee/apps/omnichannel-transcript/Dockerfile @@ -47,6 +47,12 @@ COPY ./ee/packages/network-broker/dist ee/packages/network-broker/dist COPY ./ee/packages/license/package.json packages/license/package.json COPY ./ee/packages/license/dist packages/license/dist +COPY ./packages/random/package.json packages/random/package.json +COPY ./packages/random/dist packages/random/dist + +COPY ./packages/sha256/package.json packages/sha256/package.json +COPY ./packages/sha256/dist packages/sha256/dist + COPY ./ee/packages/omnichannel-services/package.json ee/packages/omnichannel-services/package.json COPY ./ee/packages/omnichannel-services/dist ee/packages/omnichannel-services/dist diff --git a/ee/apps/omnichannel-transcript/src/service.ts b/ee/apps/omnichannel-transcript/src/service.ts index e78d646bf9ea..840da856b6d7 100644 --- a/ee/apps/omnichannel-transcript/src/service.ts +++ b/ee/apps/omnichannel-transcript/src/service.ts @@ -1,11 +1,10 @@ import { api, getConnection, getTrashCollection } from '@rocket.chat/core-services'; import { Logger } from '@rocket.chat/logger'; +import { registerServiceModels } from '@rocket.chat/models'; import { broker } from '@rocket.chat/network-broker'; import { startTracing } from '@rocket.chat/tracing'; import polka from 'polka'; -import { registerServiceModels } from '../../../../apps/meteor/ee/server/lib/registerServiceModels'; - const PORT = process.env.PORT || 3036; (async () => { diff --git a/ee/apps/omnichannel-transcript/tsconfig.json b/ee/apps/omnichannel-transcript/tsconfig.json index 58ffe2a53b03..d98107bf9f70 100644 --- a/ee/apps/omnichannel-transcript/tsconfig.json +++ b/ee/apps/omnichannel-transcript/tsconfig.json @@ -3,7 +3,7 @@ "compilerOptions": { "allowJs": true, "strictPropertyInitialization": false, - "outDir": "./dist", + "outDir": "./dist/ee/apps/omnichannel-transcript/src", }, "files": ["./src/service.ts"], "include": ["../../../apps/meteor/definition/externals/meteor"], diff --git a/ee/apps/presence-service/Dockerfile b/ee/apps/presence-service/Dockerfile index cf7bc5577700..f32a2a636064 100644 --- a/ee/apps/presence-service/Dockerfile +++ b/ee/apps/presence-service/Dockerfile @@ -50,6 +50,12 @@ COPY ./ee/packages/network-broker/dist ee/packages/network-broker/dist COPY ./ee/packages/license/package.json packages/license/package.json COPY ./ee/packages/license/dist packages/license/dist +COPY ./packages/random/package.json packages/random/package.json +COPY ./packages/random/dist packages/random/dist + +COPY ./packages/sha256/package.json packages/sha256/package.json +COPY ./packages/sha256/dist packages/sha256/dist + COPY ./packages/tracing/package.json packages/tracing/package.json COPY ./packages/tracing/dist packages/tracing/dist diff --git a/ee/apps/presence-service/package.json b/ee/apps/presence-service/package.json index de78e2bd8275..091b1ed03aa4 100644 --- a/ee/apps/presence-service/package.json +++ b/ee/apps/presence-service/package.json @@ -18,6 +18,7 @@ "@rocket.chat/core-services": "workspace:^", "@rocket.chat/core-typings": "workspace:^", "@rocket.chat/emitter": "~0.31.25", + "@rocket.chat/logger": "workspace:^", "@rocket.chat/model-typings": "workspace:^", "@rocket.chat/models": "workspace:^", "@rocket.chat/network-broker": "workspace:^", diff --git a/ee/apps/presence-service/src/service.ts b/ee/apps/presence-service/src/service.ts index f1e86419fc69..e87d659dac25 100755 --- a/ee/apps/presence-service/src/service.ts +++ b/ee/apps/presence-service/src/service.ts @@ -1,10 +1,9 @@ import { api, getConnection, getTrashCollection } from '@rocket.chat/core-services'; +import { registerServiceModels } from '@rocket.chat/models'; import { broker } from '@rocket.chat/network-broker'; import { startTracing } from '@rocket.chat/tracing'; import polka from 'polka'; -import { registerServiceModels } from '../../../../apps/meteor/ee/server/lib/registerServiceModels'; - const PORT = process.env.PORT || 3031; (async () => { diff --git a/ee/apps/presence-service/tsconfig.json b/ee/apps/presence-service/tsconfig.json index 7c09cdc08940..e5999ba7d1bc 100644 --- a/ee/apps/presence-service/tsconfig.json +++ b/ee/apps/presence-service/tsconfig.json @@ -3,7 +3,7 @@ "compilerOptions": { "strictPropertyInitialization": false, // TODO: Remove this line "allowJs": true, // TODO: Remove this line - "outDir": "./dist" + "outDir": "./dist/ee/apps/presence-service/src", }, "files": ["./src/service.ts"], "include": ["../../../apps/meteor/definition/externals/meteor"], diff --git a/ee/apps/queue-worker/Dockerfile b/ee/apps/queue-worker/Dockerfile index daf27317e554..eb709d2f3ed0 100644 --- a/ee/apps/queue-worker/Dockerfile +++ b/ee/apps/queue-worker/Dockerfile @@ -47,6 +47,12 @@ COPY ./ee/packages/network-broker/dist ee/packages/network-broker/dist COPY ./ee/packages/license/package.json packages/license/package.json COPY ./ee/packages/license/dist packages/license/dist +COPY ./packages/random/package.json packages/random/package.json +COPY ./packages/random/dist packages/random/dist + +COPY ./packages/sha256/package.json packages/sha256/package.json +COPY ./packages/sha256/dist packages/sha256/dist + COPY ./ee/packages/omnichannel-services/package.json ee/packages/omnichannel-services/package.json COPY ./ee/packages/omnichannel-services/dist ee/packages/omnichannel-services/dist diff --git a/ee/apps/queue-worker/src/service.ts b/ee/apps/queue-worker/src/service.ts index e936621e3389..69817f42a323 100644 --- a/ee/apps/queue-worker/src/service.ts +++ b/ee/apps/queue-worker/src/service.ts @@ -1,11 +1,10 @@ import { api, getConnection, getTrashCollection } from '@rocket.chat/core-services'; import { Logger } from '@rocket.chat/logger'; +import { registerServiceModels } from '@rocket.chat/models'; import { broker } from '@rocket.chat/network-broker'; import { startTracing } from '@rocket.chat/tracing'; import polka from 'polka'; -import { registerServiceModels } from '../../../../apps/meteor/ee/server/lib/registerServiceModels'; - const PORT = process.env.PORT || 3038; (async () => { diff --git a/ee/apps/queue-worker/tsconfig.json b/ee/apps/queue-worker/tsconfig.json index 58ffe2a53b03..ac2fff501da3 100644 --- a/ee/apps/queue-worker/tsconfig.json +++ b/ee/apps/queue-worker/tsconfig.json @@ -3,7 +3,7 @@ "compilerOptions": { "allowJs": true, "strictPropertyInitialization": false, - "outDir": "./dist", + "outDir": "./dist/ee/apps/queue-worker/src", }, "files": ["./src/service.ts"], "include": ["../../../apps/meteor/definition/externals/meteor"], diff --git a/ee/apps/stream-hub-service/Dockerfile b/ee/apps/stream-hub-service/Dockerfile index de7b41913a20..18ad2653a631 100644 --- a/ee/apps/stream-hub-service/Dockerfile +++ b/ee/apps/stream-hub-service/Dockerfile @@ -47,6 +47,12 @@ COPY ./ee/packages/network-broker/dist ee/packages/network-broker/dist COPY ./ee/packages/license/package.json packages/license/package.json COPY ./ee/packages/license/dist packages/license/dist +COPY ./packages/random/package.json packages/random/package.json +COPY ./packages/random/dist packages/random/dist + +COPY ./packages/sha256/package.json packages/sha256/package.json +COPY ./packages/sha256/dist packages/sha256/dist + COPY ./packages/tracing/package.json packages/tracing/package.json COPY ./packages/tracing/dist packages/tracing/dist diff --git a/ee/apps/stream-hub-service/src/service.ts b/ee/apps/stream-hub-service/src/service.ts index 07baf5923f01..1827cfeccff1 100755 --- a/ee/apps/stream-hub-service/src/service.ts +++ b/ee/apps/stream-hub-service/src/service.ts @@ -1,11 +1,11 @@ import { api, getConnection, getTrashCollection } from '@rocket.chat/core-services'; import { Logger } from '@rocket.chat/logger'; +import { registerServiceModels } from '@rocket.chat/models'; import { broker } from '@rocket.chat/network-broker'; import { startTracing } from '@rocket.chat/tracing'; import polka from 'polka'; import { StreamHub } from './StreamHub'; -import { registerServiceModels } from '../../../../apps/meteor/ee/server/lib/registerServiceModels'; import { DatabaseWatcher } from '../../../../apps/meteor/server/database/DatabaseWatcher'; const PORT = process.env.PORT || 3035; diff --git a/packages/models/package.json b/packages/models/package.json index 2259a4d1566c..ee978f14ea2d 100644 --- a/packages/models/package.json +++ b/packages/models/package.json @@ -5,12 +5,20 @@ "devDependencies": { "@rocket.chat/jest-presets": "workspace:~", "@types/jest": "~29.5.14", + "@types/node-rsa": "^1.1.4", "eslint": "~8.45.0", "jest": "^29.7.0", "typescript": "~5.7.2" }, "dependencies": { - "@rocket.chat/model-typings": "workspace:~" + "@rocket.chat/model-typings": "workspace:~", + "@rocket.chat/random": "workspace:^", + "@rocket.chat/rest-typings": "workspace:^", + "@rocket.chat/sha256": "workspace:^", + "@rocket.chat/string-helpers": "^0.31.25", + "@rocket.chat/tracing": "workspace:^", + "moment": "^2.30.1", + "node-rsa": "^1.1.1" }, "scripts": { "build": "rm -rf dist && tsc", diff --git a/apps/meteor/server/models/dummy/BaseDummy.ts b/packages/models/src/dummy/BaseDummy.ts similarity index 97% rename from apps/meteor/server/models/dummy/BaseDummy.ts rename to packages/models/src/dummy/BaseDummy.ts index 049295c1a28a..c30208df4d6c 100644 --- a/apps/meteor/server/models/dummy/BaseDummy.ts +++ b/packages/models/src/dummy/BaseDummy.ts @@ -1,7 +1,5 @@ import type { RocketChatRecordDeleted } from '@rocket.chat/core-typings'; import type { DefaultFields, FindPaginated, IBaseModel, InsertionModel, ResultFields } from '@rocket.chat/model-typings'; -import { getCollectionName, UpdaterImpl } from '@rocket.chat/models'; -import type { Updater } from '@rocket.chat/models'; import type { BulkWriteOptions, ChangeStream, @@ -22,6 +20,9 @@ import type { WithId, } from 'mongodb'; +import { getCollectionName, UpdaterImpl } from '../index'; +import type { Updater } from '../updater'; + export class BaseDummy< T extends { _id: string }, C extends DefaultFields = undefined, diff --git a/apps/meteor/server/models/dummy/ReadReceipts.ts b/packages/models/src/dummy/ReadReceipts.ts similarity index 100% rename from apps/meteor/server/models/dummy/ReadReceipts.ts rename to packages/models/src/dummy/ReadReceipts.ts diff --git a/packages/models/src/index.ts b/packages/models/src/index.ts index 7f13e4c9a079..d8f8c67ad3b2 100644 --- a/packages/models/src/index.ts +++ b/packages/models/src/index.ts @@ -1,3 +1,10 @@ +import type { + ILivechatDepartmentAgents, + ILivechatInquiryRecord, + ISetting, + ISubscription, + RocketChatRecordDeleted, +} from '@rocket.chat/core-typings'; import type { IAnalyticsModel, IAvatarsModel, @@ -83,14 +90,43 @@ import type { IModerationReportsModel, IWorkspaceCredentialsModel, } from '@rocket.chat/model-typings'; +import type { Collection, Db } from 'mongodb'; -import { proxify } from './proxify'; +import { + TeamMemberRaw, + MessagesRaw, + LivechatInquiryRaw, + LivechatDepartmentAgentsRaw, + PermissionsRaw, + LoginServiceConfigurationRaw, + InstanceStatusRaw, + IntegrationHistoryRaw, + IntegrationsRaw, + EmailInboxRaw, + PbxEventsRaw, + LivechatRoomsRaw, + LivechatPriorityRaw, + UploadsRaw, + LivechatVisitorsRaw, + RolesRaw, + RoomsRaw, + SettingsRaw, + SubscriptionsRaw, + TeamRaw, + UsersRaw, + UsersSessionsRaw, +} from './modelClasses'; +import { proxify, registerModel } from './proxify'; const prefix = 'rocketchat_'; export function getCollectionName(name: string): string { return `${prefix}${name}`; } +export * from './modelClasses'; + +export * from './dummy/ReadReceipts'; + export { registerModel } from './proxify'; export { type Updater, UpdaterImpl } from './updater'; @@ -179,3 +215,38 @@ export const CronHistory = proxify('ICronHistoryModel'); export const Migrations = proxify('IMigrationsModel'); export const ModerationReports = proxify('IModerationReportsModel'); export const WorkspaceCredentials = proxify('IWorkspaceCredentialsModel'); + +export function registerServiceModels(db: Db, trash?: Collection>): void { + registerModel('ISettingsModel', () => new SettingsRaw(db, trash as Collection>)); + registerModel('IUsersSessionsModel', () => new UsersSessionsRaw(db)); + registerModel('IUsersModel', () => new UsersRaw(db)); + + registerModel('IRolesModel', () => new RolesRaw(db)); + registerModel('IRoomsModel', () => new RoomsRaw(db)); + registerModel('ISubscriptionsModel', () => new SubscriptionsRaw(db, trash as Collection>)); + registerModel('ITeamModel', () => new TeamRaw(db)); + registerModel('ITeamMemberModel', () => new TeamMemberRaw(db)); + + registerModel('IMessagesModel', () => new MessagesRaw(db)); + + registerModel( + 'ILivechatInquiryModel', + () => new LivechatInquiryRaw(db, trash as Collection>), + ); + registerModel( + 'ILivechatDepartmentAgentsModel', + () => new LivechatDepartmentAgentsRaw(db, trash as Collection>), + ); + + registerModel('IPermissionsModel', () => new PermissionsRaw(db)); + registerModel('ILoginServiceConfigurationModel', () => new LoginServiceConfigurationRaw(db)); + registerModel('IInstanceStatusModel', () => new InstanceStatusRaw(db)); + registerModel('IIntegrationHistoryModel', () => new IntegrationHistoryRaw(db)); + registerModel('IIntegrationsModel', () => new IntegrationsRaw(db)); + registerModel('IEmailInboxModel', () => new EmailInboxRaw(db)); + registerModel('IPbxEventsModel', () => new PbxEventsRaw(db)); + registerModel('ILivechatPriorityModel', new LivechatPriorityRaw(db)); + registerModel('ILivechatRoomsModel', () => new LivechatRoomsRaw(db)); + registerModel('IUploadsModel', () => new UploadsRaw(db)); + registerModel('ILivechatVisitorsModel', () => new LivechatVisitorsRaw(db)); +} diff --git a/packages/models/src/modelClasses.ts b/packages/models/src/modelClasses.ts new file mode 100644 index 000000000000..2a7e3ce8e665 --- /dev/null +++ b/packages/models/src/modelClasses.ts @@ -0,0 +1,76 @@ +export * from './models/BaseRaw'; +export * from './models/Analytics'; +export * from './models/Apps'; +export * from './models/AppsPersistence'; +export * from './models/AppsTokens'; +export * from './models/AppLogsModel'; +export * from './models/Avatars'; +export * from './models/Banners'; +export * from './models/BannersDismiss'; +export * from './models/CalendarEvent'; +export * from './models/CustomSounds'; +export * from './models/CustomUserStatus'; +export * from './models/EmailInbox'; +export * from './models/EmailMessageHistory'; +export * from './models/EmojiCustom'; +export * from './models/ExportOperations'; +export * from './models/FederationKeys'; +export * from './models/FederationRoomEvents'; +export * from './models/FederationServers'; +export * from './models/ImportData'; +export * from './models/Imports'; +export * from './models/InstanceStatus'; +export * from './models/IntegrationHistory'; +export * from './models/Integrations'; +export * from './models/Invites'; +export * from './models/LivechatAgentActivity'; +export * from './models/LivechatBusinessHours'; +export * from './models/LivechatContacts'; +export * from './models/LivechatCustomField'; +export * from './models/LivechatDepartment'; +export * from './models/LivechatDepartmentAgents'; +export * from './models/LivechatInquiry'; +export * from './models/LivechatPriority'; +export * from './models/LivechatRooms'; +export * from './models/LivechatTrigger'; +export * from './models/LivechatVisitors'; +export * from './models/LoginServiceConfiguration'; +export * from './models/Messages'; +export * from './models/NotificationQueue'; +export * from './models/Nps'; +export * from './models/NpsVote'; +export * from './models/OAuthAccessTokens'; +export * from './models/OAuthApps'; +export * from './models/OAuthAuthCodes'; +export * from './models/OAuthRefreshTokens'; +export * from './models/OEmbedCache'; +export * from './models/PbxEvents'; +export * from './models/Permissions'; +export * from './models/PushToken'; +export * from './models/Reports'; +export * from './models/Roles'; +export * from './models/Rooms'; +export * from './models/ServerEvents'; +export * from './models/Sessions'; +export * from './models/Settings'; +export * from './models/SmarshHistory'; +export * from './models/Statistics'; +export * from './models/Subscriptions'; +export * from './models/Team'; +export * from './models/TeamMember'; +export * from './models/Uploads'; +export * from './models/UserDataFiles'; +export * from './models/Users'; +export * from './models/UsersSessions'; +export * from './models/VideoConference'; +export * from './models/VoipRoom'; +export * from './models/WebdavAccounts'; +export * from './models/MatrixBridgedRoom'; +export * from './models/MatrixBridgedUser'; +export * from './models/CredentialTokens'; +export * from './models/MessageReads'; +export * from './models/CronHistoryModel'; +export * from './models/Migrations'; +export * from './models/ModerationReports'; +export * from './models/WorkspaceCredentials'; +export * from './models/Trash'; diff --git a/apps/meteor/server/models/raw/Analytics.ts b/packages/models/src/models/Analytics.ts similarity index 98% rename from apps/meteor/server/models/raw/Analytics.ts rename to packages/models/src/models/Analytics.ts index e7f5a57ec9f4..b95eb23e9e26 100644 --- a/apps/meteor/server/models/raw/Analytics.ts +++ b/packages/models/src/models/Analytics.ts @@ -4,7 +4,7 @@ import { Random } from '@rocket.chat/random'; import type { AggregationCursor, FindCursor, Db, IndexDescription, FindOptions, UpdateResult, Document, Collection } from 'mongodb'; import { BaseRaw } from './BaseRaw'; -import { readSecondaryPreferred } from '../../database/readSecondaryPreferred'; +import { readSecondaryPreferred } from '../readSecondaryPreferred'; export class AnalyticsRaw extends BaseRaw implements IAnalyticsModel { constructor(db: Db) { diff --git a/apps/meteor/server/models/raw/AppLogsModel.ts b/packages/models/src/models/AppLogsModel.ts similarity index 100% rename from apps/meteor/server/models/raw/AppLogsModel.ts rename to packages/models/src/models/AppLogsModel.ts diff --git a/apps/meteor/server/models/raw/Apps.ts b/packages/models/src/models/Apps.ts similarity index 100% rename from apps/meteor/server/models/raw/Apps.ts rename to packages/models/src/models/Apps.ts diff --git a/apps/meteor/server/models/raw/AppsPersistence.ts b/packages/models/src/models/AppsPersistence.ts similarity index 100% rename from apps/meteor/server/models/raw/AppsPersistence.ts rename to packages/models/src/models/AppsPersistence.ts diff --git a/apps/meteor/server/models/raw/AppsTokens.ts b/packages/models/src/models/AppsTokens.ts similarity index 90% rename from apps/meteor/server/models/raw/AppsTokens.ts rename to packages/models/src/models/AppsTokens.ts index 43c085f30226..b151b3de6310 100644 --- a/apps/meteor/server/models/raw/AppsTokens.ts +++ b/packages/models/src/models/AppsTokens.ts @@ -4,7 +4,7 @@ import type { Db } from 'mongodb'; import { BaseRaw } from './BaseRaw'; -export class AppsTokens extends BaseRaw implements IAppsTokensModel { +export class AppsTokensRaw extends BaseRaw implements IAppsTokensModel { constructor(db: Db) { super(db, '_raix_push_app_tokens', undefined, { collectionNameResolver: (name) => name }); } diff --git a/apps/meteor/server/models/raw/Avatars.ts b/packages/models/src/models/Avatars.ts similarity index 100% rename from apps/meteor/server/models/raw/Avatars.ts rename to packages/models/src/models/Avatars.ts diff --git a/apps/meteor/server/models/raw/Banners.ts b/packages/models/src/models/Banners.ts similarity index 100% rename from apps/meteor/server/models/raw/Banners.ts rename to packages/models/src/models/Banners.ts diff --git a/apps/meteor/server/models/raw/BannersDismiss.ts b/packages/models/src/models/BannersDismiss.ts similarity index 100% rename from apps/meteor/server/models/raw/BannersDismiss.ts rename to packages/models/src/models/BannersDismiss.ts diff --git a/apps/meteor/server/models/raw/BaseRaw.ts b/packages/models/src/models/BaseRaw.ts similarity index 98% rename from apps/meteor/server/models/raw/BaseRaw.ts rename to packages/models/src/models/BaseRaw.ts index 7b79973ba14f..b1d8eb352a1c 100644 --- a/apps/meteor/server/models/raw/BaseRaw.ts +++ b/packages/models/src/models/BaseRaw.ts @@ -1,7 +1,5 @@ import type { RocketChatRecordDeleted } from '@rocket.chat/core-typings'; import type { IBaseModel, DefaultFields, ResultFields, FindPaginated, InsertionModel } from '@rocket.chat/model-typings'; -import type { Updater } from '@rocket.chat/models'; -import { getCollectionName, UpdaterImpl } from '@rocket.chat/models'; import { traceInstanceMethods } from '@rocket.chat/tracing'; import { ObjectId } from 'mongodb'; import type { @@ -31,6 +29,8 @@ import type { CountDocumentsOptions, } from 'mongodb'; +import { getCollectionName, UpdaterImpl } from '..'; +import type { Updater } from '../updater'; import { setUpdatedAt } from './setUpdatedAt'; const warnFields = @@ -53,7 +53,7 @@ export abstract class BaseRaw< TDeleted extends RocketChatRecordDeleted = RocketChatRecordDeleted, > implements IBaseModel { - public readonly defaultFields: C; + public readonly defaultFields: C | undefined; public readonly col: Collection; diff --git a/apps/meteor/server/models/raw/BaseUploadModel.ts b/packages/models/src/models/BaseUploadModel.ts similarity index 100% rename from apps/meteor/server/models/raw/BaseUploadModel.ts rename to packages/models/src/models/BaseUploadModel.ts diff --git a/apps/meteor/server/models/raw/CalendarEvent.ts b/packages/models/src/models/CalendarEvent.ts similarity index 100% rename from apps/meteor/server/models/raw/CalendarEvent.ts rename to packages/models/src/models/CalendarEvent.ts diff --git a/apps/meteor/server/models/raw/CredentialTokens.ts b/packages/models/src/models/CredentialTokens.ts similarity index 100% rename from apps/meteor/server/models/raw/CredentialTokens.ts rename to packages/models/src/models/CredentialTokens.ts diff --git a/apps/meteor/server/models/raw/CronHistoryModel.ts b/packages/models/src/models/CronHistoryModel.ts similarity index 100% rename from apps/meteor/server/models/raw/CronHistoryModel.ts rename to packages/models/src/models/CronHistoryModel.ts diff --git a/apps/meteor/server/models/raw/CustomSounds.ts b/packages/models/src/models/CustomSounds.ts similarity index 100% rename from apps/meteor/server/models/raw/CustomSounds.ts rename to packages/models/src/models/CustomSounds.ts diff --git a/apps/meteor/server/models/raw/CustomUserStatus.ts b/packages/models/src/models/CustomUserStatus.ts similarity index 100% rename from apps/meteor/server/models/raw/CustomUserStatus.ts rename to packages/models/src/models/CustomUserStatus.ts diff --git a/apps/meteor/server/models/raw/EmailInbox.ts b/packages/models/src/models/EmailInbox.ts similarity index 100% rename from apps/meteor/server/models/raw/EmailInbox.ts rename to packages/models/src/models/EmailInbox.ts diff --git a/apps/meteor/server/models/raw/EmailMessageHistory.ts b/packages/models/src/models/EmailMessageHistory.ts similarity index 100% rename from apps/meteor/server/models/raw/EmailMessageHistory.ts rename to packages/models/src/models/EmailMessageHistory.ts diff --git a/apps/meteor/server/models/raw/EmojiCustom.ts b/packages/models/src/models/EmojiCustom.ts similarity index 100% rename from apps/meteor/server/models/raw/EmojiCustom.ts rename to packages/models/src/models/EmojiCustom.ts diff --git a/apps/meteor/server/models/raw/ExportOperations.ts b/packages/models/src/models/ExportOperations.ts similarity index 100% rename from apps/meteor/server/models/raw/ExportOperations.ts rename to packages/models/src/models/ExportOperations.ts diff --git a/apps/meteor/server/models/raw/FederationEvents.ts b/packages/models/src/models/FederationEvents.ts similarity index 100% rename from apps/meteor/server/models/raw/FederationEvents.ts rename to packages/models/src/models/FederationEvents.ts diff --git a/apps/meteor/server/models/raw/FederationKeys.ts b/packages/models/src/models/FederationKeys.ts similarity index 100% rename from apps/meteor/server/models/raw/FederationKeys.ts rename to packages/models/src/models/FederationKeys.ts diff --git a/apps/meteor/server/models/raw/FederationRoomEvents.ts b/packages/models/src/models/FederationRoomEvents.ts similarity index 97% rename from apps/meteor/server/models/raw/FederationRoomEvents.ts rename to packages/models/src/models/FederationRoomEvents.ts index df69c42e056e..e15b47d581a5 100644 --- a/apps/meteor/server/models/raw/FederationRoomEvents.ts +++ b/packages/models/src/models/FederationRoomEvents.ts @@ -5,7 +5,7 @@ import type { Db, DeleteResult, IndexDescription } from 'mongodb'; import { FederationEventsModel } from './FederationEvents'; -export class FederationRoomEvents extends FederationEventsModel implements IFederationRoomEventsModel { +export class FederationRoomEventsRaw extends FederationEventsModel implements IFederationRoomEventsModel { constructor(db: Db) { super(db, 'federation_room_events'); } diff --git a/apps/meteor/server/models/raw/FederationServers.ts b/packages/models/src/models/FederationServers.ts similarity index 96% rename from apps/meteor/server/models/raw/FederationServers.ts rename to packages/models/src/models/FederationServers.ts index af94f26cf76e..95256c2280b9 100644 --- a/apps/meteor/server/models/raw/FederationServers.ts +++ b/packages/models/src/models/FederationServers.ts @@ -1,9 +1,9 @@ import type { IFederationServer, RocketChatRecordDeleted } from '@rocket.chat/core-typings'; import type { IFederationServersModel } from '@rocket.chat/model-typings'; -import { Users } from '@rocket.chat/models'; import type { Collection, Db, IndexDescription, UpdateResult } from 'mongodb'; import { BaseRaw } from './BaseRaw'; +import { Users } from '../index'; export class FederationServersRaw extends BaseRaw implements IFederationServersModel { constructor(db: Db, trash?: Collection>) { diff --git a/apps/meteor/server/models/raw/FreeSwitchCall.ts b/packages/models/src/models/FreeSwitchCall.ts similarity index 100% rename from apps/meteor/server/models/raw/FreeSwitchCall.ts rename to packages/models/src/models/FreeSwitchCall.ts diff --git a/apps/meteor/server/models/raw/FreeSwitchEvent.ts b/packages/models/src/models/FreeSwitchEvent.ts similarity index 100% rename from apps/meteor/server/models/raw/FreeSwitchEvent.ts rename to packages/models/src/models/FreeSwitchEvent.ts diff --git a/apps/meteor/server/models/raw/ImportData.ts b/packages/models/src/models/ImportData.ts similarity index 100% rename from apps/meteor/server/models/raw/ImportData.ts rename to packages/models/src/models/ImportData.ts diff --git a/apps/meteor/server/models/raw/Imports.ts b/packages/models/src/models/Imports.ts similarity index 100% rename from apps/meteor/server/models/raw/Imports.ts rename to packages/models/src/models/Imports.ts diff --git a/apps/meteor/server/models/raw/InstanceStatus.ts b/packages/models/src/models/InstanceStatus.ts similarity index 100% rename from apps/meteor/server/models/raw/InstanceStatus.ts rename to packages/models/src/models/InstanceStatus.ts diff --git a/apps/meteor/server/models/raw/IntegrationHistory.ts b/packages/models/src/models/IntegrationHistory.ts similarity index 100% rename from apps/meteor/server/models/raw/IntegrationHistory.ts rename to packages/models/src/models/IntegrationHistory.ts diff --git a/apps/meteor/server/models/raw/Integrations.ts b/packages/models/src/models/Integrations.ts similarity index 100% rename from apps/meteor/server/models/raw/Integrations.ts rename to packages/models/src/models/Integrations.ts diff --git a/apps/meteor/server/models/raw/Invites.ts b/packages/models/src/models/Invites.ts similarity index 100% rename from apps/meteor/server/models/raw/Invites.ts rename to packages/models/src/models/Invites.ts diff --git a/apps/meteor/server/models/raw/LivechatAgentActivity.ts b/packages/models/src/models/LivechatAgentActivity.ts similarity index 98% rename from apps/meteor/server/models/raw/LivechatAgentActivity.ts rename to packages/models/src/models/LivechatAgentActivity.ts index ec9215adf855..c40f5e15e238 100644 --- a/apps/meteor/server/models/raw/LivechatAgentActivity.ts +++ b/packages/models/src/models/LivechatAgentActivity.ts @@ -4,7 +4,7 @@ import moment from 'moment'; import type { AggregationCursor, Collection, Document, FindCursor, Db, ModifyResult, IndexDescription, UpdateResult } from 'mongodb'; import { BaseRaw } from './BaseRaw'; -import { readSecondaryPreferred } from '../../database/readSecondaryPreferred'; +import { readSecondaryPreferred } from '../readSecondaryPreferred'; export class LivechatAgentActivityRaw extends BaseRaw implements ILivechatAgentActivityModel { constructor(db: Db, trash?: Collection>) { diff --git a/apps/meteor/server/models/raw/LivechatBusinessHours.ts b/packages/models/src/models/LivechatBusinessHours.ts similarity index 100% rename from apps/meteor/server/models/raw/LivechatBusinessHours.ts rename to packages/models/src/models/LivechatBusinessHours.ts diff --git a/apps/meteor/server/models/raw/LivechatContacts.ts b/packages/models/src/models/LivechatContacts.ts similarity index 99% rename from apps/meteor/server/models/raw/LivechatContacts.ts rename to packages/models/src/models/LivechatContacts.ts index 43a5f5204e60..ed84fd64d18c 100644 --- a/apps/meteor/server/models/raw/LivechatContacts.ts +++ b/packages/models/src/models/LivechatContacts.ts @@ -25,7 +25,7 @@ import type { } from 'mongodb'; import { BaseRaw } from './BaseRaw'; -import { readSecondaryPreferred } from '../../database/readSecondaryPreferred'; +import { readSecondaryPreferred } from '../readSecondaryPreferred'; export class LivechatContactsRaw extends BaseRaw implements ILivechatContactsModel { constructor(db: Db, trash?: Collection>) { diff --git a/apps/meteor/server/models/raw/LivechatCustomField.ts b/packages/models/src/models/LivechatCustomField.ts similarity index 100% rename from apps/meteor/server/models/raw/LivechatCustomField.ts rename to packages/models/src/models/LivechatCustomField.ts diff --git a/apps/meteor/server/models/raw/LivechatDepartment.ts b/packages/models/src/models/LivechatDepartment.ts similarity index 99% rename from apps/meteor/server/models/raw/LivechatDepartment.ts rename to packages/models/src/models/LivechatDepartment.ts index 949807f7213e..b77f752c6e0e 100644 --- a/apps/meteor/server/models/raw/LivechatDepartment.ts +++ b/packages/models/src/models/LivechatDepartment.ts @@ -1,6 +1,5 @@ import type { ILivechatDepartment, RocketChatRecordDeleted } from '@rocket.chat/core-typings'; import type { ILivechatDepartmentModel } from '@rocket.chat/model-typings'; -import { LivechatDepartmentAgents, LivechatUnitMonitors } from '@rocket.chat/models'; import { escapeRegExp } from '@rocket.chat/string-helpers'; import type { Collection, @@ -16,6 +15,7 @@ import type { AggregationCursor, } from 'mongodb'; +import { LivechatDepartmentAgents, LivechatUnitMonitors } from '../index'; import { BaseRaw } from './BaseRaw'; export class LivechatDepartmentRaw extends BaseRaw implements ILivechatDepartmentModel { diff --git a/apps/meteor/server/models/raw/LivechatDepartmentAgents.ts b/packages/models/src/models/LivechatDepartmentAgents.ts similarity index 99% rename from apps/meteor/server/models/raw/LivechatDepartmentAgents.ts rename to packages/models/src/models/LivechatDepartmentAgents.ts index 6d7ec76222db..62e9db5bc265 100644 --- a/apps/meteor/server/models/raw/LivechatDepartmentAgents.ts +++ b/packages/models/src/models/LivechatDepartmentAgents.ts @@ -1,6 +1,5 @@ import type { ILivechatDepartmentAgents, RocketChatRecordDeleted, IUser } from '@rocket.chat/core-typings'; import type { FindPaginated, ILivechatDepartmentAgentsModel } from '@rocket.chat/model-typings'; -import { Users } from '@rocket.chat/models'; import type { Collection, FindCursor, @@ -15,6 +14,7 @@ import type { AggregationCursor, } from 'mongodb'; +import { Users } from '../index'; import { BaseRaw } from './BaseRaw'; export class LivechatDepartmentAgentsRaw extends BaseRaw implements ILivechatDepartmentAgentsModel { diff --git a/apps/meteor/server/models/raw/LivechatInquiry.ts b/packages/models/src/models/LivechatInquiry.ts similarity index 99% rename from apps/meteor/server/models/raw/LivechatInquiry.ts rename to packages/models/src/models/LivechatInquiry.ts index de5ebc069949..f79e234db84b 100644 --- a/apps/meteor/server/models/raw/LivechatInquiry.ts +++ b/packages/models/src/models/LivechatInquiry.ts @@ -18,7 +18,7 @@ import type { } from 'mongodb'; import { BaseRaw } from './BaseRaw'; -import { readSecondaryPreferred } from '../../database/readSecondaryPreferred'; +import { readSecondaryPreferred } from '../readSecondaryPreferred'; export class LivechatInquiryRaw extends BaseRaw implements ILivechatInquiryModel { constructor(db: Db, trash?: Collection>) { diff --git a/apps/meteor/ee/server/models/raw/LivechatPriority.ts b/packages/models/src/models/LivechatPriority.ts similarity index 97% rename from apps/meteor/ee/server/models/raw/LivechatPriority.ts rename to packages/models/src/models/LivechatPriority.ts index 61f8ac9a1ab9..d7a8d172e518 100644 --- a/apps/meteor/ee/server/models/raw/LivechatPriority.ts +++ b/packages/models/src/models/LivechatPriority.ts @@ -3,7 +3,7 @@ import type { ILivechatPriorityModel } from '@rocket.chat/model-typings'; import { escapeRegExp } from '@rocket.chat/string-helpers'; import type { Db, UpdateFilter, ModifyResult, IndexDescription, FindCursor } from 'mongodb'; -import { BaseRaw } from '../../../../server/models/raw/BaseRaw'; +import { BaseRaw } from './BaseRaw'; // TODO need to define type for LivechatPriority object export class LivechatPriorityRaw extends BaseRaw implements ILivechatPriorityModel { diff --git a/apps/meteor/server/models/raw/LivechatRooms.ts b/packages/models/src/models/LivechatRooms.ts similarity index 99% rename from apps/meteor/server/models/raw/LivechatRooms.ts rename to packages/models/src/models/LivechatRooms.ts index e1a4d31a2a38..6e03b422cc78 100644 --- a/apps/meteor/server/models/raw/LivechatRooms.ts +++ b/packages/models/src/models/LivechatRooms.ts @@ -14,8 +14,6 @@ import type { } from '@rocket.chat/core-typings'; import { UserStatus } from '@rocket.chat/core-typings'; import type { FindPaginated, ILivechatRoomsModel } from '@rocket.chat/model-typings'; -import type { Updater } from '@rocket.chat/models'; -import { Settings } from '@rocket.chat/models'; import { escapeRegExp } from '@rocket.chat/string-helpers'; import type { Db, @@ -32,8 +30,10 @@ import type { UpdateOptions, } from 'mongodb'; +import { Settings } from '../index'; +import type { Updater } from '../updater'; import { BaseRaw } from './BaseRaw'; -import { readSecondaryPreferred } from '../../database/readSecondaryPreferred'; +import { readSecondaryPreferred } from '../readSecondaryPreferred'; /** * @extends BaseRaw diff --git a/apps/meteor/server/models/raw/LivechatTrigger.ts b/packages/models/src/models/LivechatTrigger.ts similarity index 100% rename from apps/meteor/server/models/raw/LivechatTrigger.ts rename to packages/models/src/models/LivechatTrigger.ts diff --git a/apps/meteor/server/models/raw/LivechatVisitors.ts b/packages/models/src/models/LivechatVisitors.ts similarity index 99% rename from apps/meteor/server/models/raw/LivechatVisitors.ts rename to packages/models/src/models/LivechatVisitors.ts index 27e46808bea9..d6d9f45ef778 100644 --- a/apps/meteor/server/models/raw/LivechatVisitors.ts +++ b/packages/models/src/models/LivechatVisitors.ts @@ -1,6 +1,5 @@ import type { ILivechatVisitor, RocketChatRecordDeleted } from '@rocket.chat/core-typings'; import type { FindPaginated, ILivechatVisitorsModel } from '@rocket.chat/model-typings'; -import { Settings } from '@rocket.chat/models'; import { escapeRegExp } from '@rocket.chat/string-helpers'; import type { AggregationCursor, @@ -19,6 +18,7 @@ import type { } from 'mongodb'; import { ObjectId } from 'mongodb'; +import { Settings } from '../index'; import { BaseRaw } from './BaseRaw'; export class LivechatVisitorsRaw extends BaseRaw implements ILivechatVisitorsModel { diff --git a/apps/meteor/server/models/raw/LoginServiceConfiguration.ts b/packages/models/src/models/LoginServiceConfiguration.ts similarity index 100% rename from apps/meteor/server/models/raw/LoginServiceConfiguration.ts rename to packages/models/src/models/LoginServiceConfiguration.ts diff --git a/apps/meteor/server/models/raw/MatrixBridgedRoom.ts b/packages/models/src/models/MatrixBridgedRoom.ts similarity index 100% rename from apps/meteor/server/models/raw/MatrixBridgedRoom.ts rename to packages/models/src/models/MatrixBridgedRoom.ts diff --git a/apps/meteor/server/models/raw/MatrixBridgedUser.ts b/packages/models/src/models/MatrixBridgedUser.ts similarity index 100% rename from apps/meteor/server/models/raw/MatrixBridgedUser.ts rename to packages/models/src/models/MatrixBridgedUser.ts diff --git a/apps/meteor/server/models/raw/MessageReads.ts b/packages/models/src/models/MessageReads.ts similarity index 100% rename from apps/meteor/server/models/raw/MessageReads.ts rename to packages/models/src/models/MessageReads.ts diff --git a/apps/meteor/server/models/raw/Messages.ts b/packages/models/src/models/Messages.ts similarity index 99% rename from apps/meteor/server/models/raw/Messages.ts rename to packages/models/src/models/Messages.ts index 4736758afbb6..22e3243bdca2 100644 --- a/apps/meteor/server/models/raw/Messages.ts +++ b/packages/models/src/models/Messages.ts @@ -31,7 +31,7 @@ import type { } from 'mongodb'; import { BaseRaw } from './BaseRaw'; -import { readSecondaryPreferred } from '../../database/readSecondaryPreferred'; +import { readSecondaryPreferred } from '../readSecondaryPreferred'; type DeepWritable = T extends (...args: any) => any ? T diff --git a/apps/meteor/server/models/raw/Migrations.ts b/packages/models/src/models/Migrations.ts similarity index 100% rename from apps/meteor/server/models/raw/Migrations.ts rename to packages/models/src/models/Migrations.ts diff --git a/apps/meteor/server/models/raw/ModerationReports.ts b/packages/models/src/models/ModerationReports.ts similarity index 99% rename from apps/meteor/server/models/raw/ModerationReports.ts rename to packages/models/src/models/ModerationReports.ts index b50057a389fd..c57a8126d1e0 100644 --- a/apps/meteor/server/models/raw/ModerationReports.ts +++ b/packages/models/src/models/ModerationReports.ts @@ -10,7 +10,7 @@ import type { FindPaginated, IModerationReportsModel, PaginationParams } from '@ import type { AggregationCursor, Collection, Db, Document, FindCursor, FindOptions, IndexDescription, UpdateResult } from 'mongodb'; import { BaseRaw } from './BaseRaw'; -import { readSecondaryPreferred } from '../../database/readSecondaryPreferred'; +import { readSecondaryPreferred } from '../readSecondaryPreferred'; export class ModerationReportsRaw extends BaseRaw implements IModerationReportsModel { constructor(db: Db, trash?: Collection>) { diff --git a/apps/meteor/server/models/raw/NotificationQueue.ts b/packages/models/src/models/NotificationQueue.ts similarity index 100% rename from apps/meteor/server/models/raw/NotificationQueue.ts rename to packages/models/src/models/NotificationQueue.ts diff --git a/apps/meteor/server/models/raw/Nps.ts b/packages/models/src/models/Nps.ts similarity index 100% rename from apps/meteor/server/models/raw/Nps.ts rename to packages/models/src/models/Nps.ts diff --git a/apps/meteor/server/models/raw/NpsVote.ts b/packages/models/src/models/NpsVote.ts similarity index 100% rename from apps/meteor/server/models/raw/NpsVote.ts rename to packages/models/src/models/NpsVote.ts diff --git a/apps/meteor/server/models/raw/OAuthAccessTokens.ts b/packages/models/src/models/OAuthAccessTokens.ts similarity index 100% rename from apps/meteor/server/models/raw/OAuthAccessTokens.ts rename to packages/models/src/models/OAuthAccessTokens.ts diff --git a/apps/meteor/server/models/raw/OAuthApps.ts b/packages/models/src/models/OAuthApps.ts similarity index 100% rename from apps/meteor/server/models/raw/OAuthApps.ts rename to packages/models/src/models/OAuthApps.ts diff --git a/apps/meteor/server/models/raw/OAuthAuthCodes.ts b/packages/models/src/models/OAuthAuthCodes.ts similarity index 100% rename from apps/meteor/server/models/raw/OAuthAuthCodes.ts rename to packages/models/src/models/OAuthAuthCodes.ts diff --git a/apps/meteor/server/models/raw/OAuthRefreshTokens.ts b/packages/models/src/models/OAuthRefreshTokens.ts similarity index 100% rename from apps/meteor/server/models/raw/OAuthRefreshTokens.ts rename to packages/models/src/models/OAuthRefreshTokens.ts diff --git a/apps/meteor/server/models/raw/OEmbedCache.ts b/packages/models/src/models/OEmbedCache.ts similarity index 100% rename from apps/meteor/server/models/raw/OEmbedCache.ts rename to packages/models/src/models/OEmbedCache.ts diff --git a/apps/meteor/server/models/raw/PbxEvents.ts b/packages/models/src/models/PbxEvents.ts similarity index 100% rename from apps/meteor/server/models/raw/PbxEvents.ts rename to packages/models/src/models/PbxEvents.ts diff --git a/apps/meteor/server/models/raw/Permissions.ts b/packages/models/src/models/Permissions.ts similarity index 100% rename from apps/meteor/server/models/raw/Permissions.ts rename to packages/models/src/models/Permissions.ts diff --git a/apps/meteor/server/models/raw/PushToken.ts b/packages/models/src/models/PushToken.ts similarity index 100% rename from apps/meteor/server/models/raw/PushToken.ts rename to packages/models/src/models/PushToken.ts diff --git a/apps/meteor/server/models/raw/Reports.ts b/packages/models/src/models/Reports.ts similarity index 100% rename from apps/meteor/server/models/raw/Reports.ts rename to packages/models/src/models/Reports.ts diff --git a/apps/meteor/server/models/raw/Roles.ts b/packages/models/src/models/Roles.ts similarity index 99% rename from apps/meteor/server/models/raw/Roles.ts rename to packages/models/src/models/Roles.ts index fad0312bc52f..d731cf54fe72 100644 --- a/apps/meteor/server/models/raw/Roles.ts +++ b/packages/models/src/models/Roles.ts @@ -1,8 +1,8 @@ import type { IRole, IRoom, IUser, RocketChatRecordDeleted } from '@rocket.chat/core-typings'; import type { IRolesModel } from '@rocket.chat/model-typings'; -import { Subscriptions, Users } from '@rocket.chat/models'; import type { Collection, FindCursor, Db, Filter, FindOptions, Document, CountDocumentsOptions } from 'mongodb'; +import { Subscriptions, Users } from '../index'; import { BaseRaw } from './BaseRaw'; export class RolesRaw extends BaseRaw implements IRolesModel { diff --git a/apps/meteor/server/models/raw/Rooms.ts b/packages/models/src/models/Rooms.ts similarity index 99% rename from apps/meteor/server/models/raw/Rooms.ts rename to packages/models/src/models/Rooms.ts index d35033ad90f3..b010f58e2e23 100644 --- a/apps/meteor/server/models/raw/Rooms.ts +++ b/packages/models/src/models/Rooms.ts @@ -9,8 +9,6 @@ import type { RocketChatRecordDeleted, } from '@rocket.chat/core-typings'; import type { FindPaginated, IRoomsModel, IChannelsWithNumberOfMessagesBetweenDate } from '@rocket.chat/model-typings'; -import { Subscriptions } from '@rocket.chat/models'; -import type { Updater } from '@rocket.chat/models'; import { escapeRegExp } from '@rocket.chat/string-helpers'; import type { AggregationCursor, @@ -29,8 +27,10 @@ import type { CountDocumentsOptions, } from 'mongodb'; +import { Subscriptions } from '../index'; import { BaseRaw } from './BaseRaw'; -import { readSecondaryPreferred } from '../../database/readSecondaryPreferred'; +import { readSecondaryPreferred } from '../readSecondaryPreferred'; +import type { Updater } from '../updater'; export class RoomsRaw extends BaseRaw implements IRoomsModel { constructor(db: Db, trash?: Collection>) { diff --git a/apps/meteor/server/models/raw/ServerEvents.ts b/packages/models/src/models/ServerEvents.ts similarity index 100% rename from apps/meteor/server/models/raw/ServerEvents.ts rename to packages/models/src/models/ServerEvents.ts diff --git a/apps/meteor/server/models/raw/Sessions.ts b/packages/models/src/models/Sessions.ts similarity index 99% rename from apps/meteor/server/models/raw/Sessions.ts rename to packages/models/src/models/Sessions.ts index 4a0b72646c77..c89ca9d34037 100644 --- a/apps/meteor/server/models/raw/Sessions.ts +++ b/packages/models/src/models/Sessions.ts @@ -12,7 +12,6 @@ import type { RocketChatRecordDeleted, } from '@rocket.chat/core-typings'; import type { ISessionsModel } from '@rocket.chat/model-typings'; -import { getCollectionName } from '@rocket.chat/models'; import type { PaginatedResult, WithItemCount } from '@rocket.chat/rest-typings'; import type { AggregationCursor, @@ -28,8 +27,9 @@ import type { OptionalId, } from 'mongodb'; +import { getCollectionName } from '../index'; import { BaseRaw } from './BaseRaw'; -import { readSecondaryPreferred } from '../../database/readSecondaryPreferred'; +import { readSecondaryPreferred } from '../readSecondaryPreferred'; type DestructuredDate = { year: number; month: number; day: number }; type DestructuredDateWithType = { diff --git a/apps/meteor/server/models/raw/Settings.ts b/packages/models/src/models/Settings.ts similarity index 100% rename from apps/meteor/server/models/raw/Settings.ts rename to packages/models/src/models/Settings.ts diff --git a/apps/meteor/server/models/raw/SmarshHistory.ts b/packages/models/src/models/SmarshHistory.ts similarity index 100% rename from apps/meteor/server/models/raw/SmarshHistory.ts rename to packages/models/src/models/SmarshHistory.ts diff --git a/apps/meteor/server/models/raw/Statistics.ts b/packages/models/src/models/Statistics.ts similarity index 100% rename from apps/meteor/server/models/raw/Statistics.ts rename to packages/models/src/models/Statistics.ts diff --git a/apps/meteor/server/models/raw/Subscriptions.ts b/packages/models/src/models/Subscriptions.ts similarity index 99% rename from apps/meteor/server/models/raw/Subscriptions.ts rename to packages/models/src/models/Subscriptions.ts index 2ba63aba86cf..ba28b6da843a 100644 --- a/apps/meteor/server/models/raw/Subscriptions.ts +++ b/packages/models/src/models/Subscriptions.ts @@ -9,7 +9,6 @@ import type { SpotlightUser, } from '@rocket.chat/core-typings'; import type { ISubscriptionsModel } from '@rocket.chat/model-typings'; -import { Rooms, Users } from '@rocket.chat/models'; import { escapeRegExp } from '@rocket.chat/string-helpers'; import { compact } from 'lodash'; import mem from 'mem'; @@ -33,6 +32,7 @@ import type { ModifyResult, } from 'mongodb'; +import { Rooms, Users } from '../index'; import { BaseRaw } from './BaseRaw'; export class SubscriptionsRaw extends BaseRaw implements ISubscriptionsModel { diff --git a/apps/meteor/server/models/raw/Team.ts b/packages/models/src/models/Team.ts similarity index 100% rename from apps/meteor/server/models/raw/Team.ts rename to packages/models/src/models/Team.ts diff --git a/apps/meteor/server/models/raw/TeamMember.ts b/packages/models/src/models/TeamMember.ts similarity index 100% rename from apps/meteor/server/models/raw/TeamMember.ts rename to packages/models/src/models/TeamMember.ts diff --git a/apps/meteor/server/models/raw/Trash.ts b/packages/models/src/models/Trash.ts similarity index 100% rename from apps/meteor/server/models/raw/Trash.ts rename to packages/models/src/models/Trash.ts diff --git a/apps/meteor/server/models/raw/Uploads.ts b/packages/models/src/models/Uploads.ts similarity index 100% rename from apps/meteor/server/models/raw/Uploads.ts rename to packages/models/src/models/Uploads.ts diff --git a/apps/meteor/server/models/raw/UserDataFiles.ts b/packages/models/src/models/UserDataFiles.ts similarity index 100% rename from apps/meteor/server/models/raw/UserDataFiles.ts rename to packages/models/src/models/UserDataFiles.ts diff --git a/apps/meteor/server/models/raw/Users.js b/packages/models/src/models/Users.js similarity index 100% rename from apps/meteor/server/models/raw/Users.js rename to packages/models/src/models/Users.js diff --git a/apps/meteor/server/models/raw/UsersSessions.ts b/packages/models/src/models/UsersSessions.ts similarity index 100% rename from apps/meteor/server/models/raw/UsersSessions.ts rename to packages/models/src/models/UsersSessions.ts diff --git a/apps/meteor/server/models/raw/VideoConference.ts b/packages/models/src/models/VideoConference.ts similarity index 100% rename from apps/meteor/server/models/raw/VideoConference.ts rename to packages/models/src/models/VideoConference.ts diff --git a/apps/meteor/server/models/raw/VoipRoom.ts b/packages/models/src/models/VoipRoom.ts similarity index 100% rename from apps/meteor/server/models/raw/VoipRoom.ts rename to packages/models/src/models/VoipRoom.ts diff --git a/apps/meteor/server/models/raw/WebdavAccounts.ts b/packages/models/src/models/WebdavAccounts.ts similarity index 100% rename from apps/meteor/server/models/raw/WebdavAccounts.ts rename to packages/models/src/models/WebdavAccounts.ts diff --git a/apps/meteor/server/models/raw/WorkspaceCredentials.ts b/packages/models/src/models/WorkspaceCredentials.ts similarity index 100% rename from apps/meteor/server/models/raw/WorkspaceCredentials.ts rename to packages/models/src/models/WorkspaceCredentials.ts diff --git a/apps/meteor/server/models/raw/setUpdatedAt.ts b/packages/models/src/models/setUpdatedAt.ts similarity index 100% rename from apps/meteor/server/models/raw/setUpdatedAt.ts rename to packages/models/src/models/setUpdatedAt.ts diff --git a/packages/models/src/readSecondaryPreferred.ts b/packages/models/src/readSecondaryPreferred.ts new file mode 100644 index 000000000000..4bf7e5a95918 --- /dev/null +++ b/packages/models/src/readSecondaryPreferred.ts @@ -0,0 +1,18 @@ +import type { Db, ReadPreferenceLike } from 'mongodb'; +import { ReadPreference } from 'mongodb'; + +export function readSecondaryPreferred(db?: Db, tags: any[] = []): ReadPreferenceLike { + const { readPreference } = db?.options || {}; + + if (tags.length) { + return new ReadPreference(ReadPreference.SECONDARY_PREFERRED, tags); + } + if (readPreference && readPreference instanceof ReadPreference && readPreference.tags?.length) { + return new ReadPreference(ReadPreference.SECONDARY_PREFERRED, readPreference.tags); + } + + // For some reason the new ReadPreference definition requires the tags parameter even not been + // required by the code implementation and, for some reason, when passing an empty array it + // doesn't ignore the tags and stop using the secondaries. + return ReadPreference.SECONDARY_PREFERRED; +} diff --git a/packages/models/tsconfig.json b/packages/models/tsconfig.json index 74d65c3b8a3d..e28418fe4a24 100644 --- a/packages/models/tsconfig.json +++ b/packages/models/tsconfig.json @@ -1,6 +1,8 @@ { "extends": "../../tsconfig.base.server.json", "compilerOptions": { + // TODO migrate Users to TS + "allowJs": true, "declaration": true, "rootDir": "./src", "outDir": "./dist", diff --git a/packages/sha256/tsconfig.build.json b/packages/sha256/tsconfig.build.json index 4a856a106b58..fb44f1fb1e59 100644 --- a/packages/sha256/tsconfig.build.json +++ b/packages/sha256/tsconfig.build.json @@ -2,7 +2,7 @@ "extends": "./tsconfig.json", "compilerOptions": { "target": "ES2015", - "module": "ESNext", + "module": "commonjs", "declaration": true, "declarationMap": true, "sourceMap": true, diff --git a/yarn.lock b/yarn.lock index 835f25921016..a3756b75550c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8269,6 +8269,7 @@ __metadata: "@rocket.chat/core-typings": "workspace:^" "@rocket.chat/emitter": "npm:~0.31.25" "@rocket.chat/eslint-config": "workspace:^" + "@rocket.chat/logger": "workspace:^" "@rocket.chat/model-typings": "workspace:^" "@rocket.chat/models": "workspace:^" "@rocket.chat/network-broker": "workspace:^" @@ -8404,6 +8405,7 @@ __metadata: "@rocket.chat/core-typings": "workspace:^" "@rocket.chat/emitter": "npm:~0.31.25" "@rocket.chat/eslint-config": "workspace:^" + "@rocket.chat/logger": "workspace:^" "@rocket.chat/model-typings": "workspace:^" "@rocket.chat/models": "workspace:^" "@rocket.chat/network-broker": "workspace:^" @@ -9557,9 +9559,17 @@ __metadata: dependencies: "@rocket.chat/jest-presets": "workspace:~" "@rocket.chat/model-typings": "workspace:~" + "@rocket.chat/random": "workspace:^" + "@rocket.chat/rest-typings": "workspace:^" + "@rocket.chat/sha256": "workspace:^" + "@rocket.chat/string-helpers": "npm:^0.31.25" + "@rocket.chat/tracing": "workspace:^" "@types/jest": "npm:~29.5.14" + "@types/node-rsa": "npm:^1.1.4" eslint: "npm:~8.45.0" jest: "npm:^29.7.0" + moment: "npm:^2.30.1" + node-rsa: "npm:^1.1.1" typescript: "npm:~5.7.2" languageName: unknown linkType: soft @@ -9777,6 +9787,7 @@ __metadata: "@rocket.chat/core-typings": "workspace:^" "@rocket.chat/emitter": "npm:~0.31.25" "@rocket.chat/eslint-config": "workspace:^" + "@rocket.chat/logger": "workspace:^" "@rocket.chat/model-typings": "workspace:^" "@rocket.chat/models": "workspace:^" "@rocket.chat/network-broker": "workspace:^" @@ -10014,7 +10025,7 @@ __metadata: languageName: unknown linkType: soft -"@rocket.chat/string-helpers@npm:~0.31.25": +"@rocket.chat/string-helpers@npm:^0.31.25, @rocket.chat/string-helpers@npm:~0.31.25": version: 0.31.25 resolution: "@rocket.chat/string-helpers@npm:0.31.25" checksum: 10/9fd3f25a9e87a6c33bea1fb521c51e7e6497ad5f9b695807b8b0b98b3130799924305adaa1ea851f10ed2ffc64af8270f3f14339ac181f64b038cb1fd8f8819f