diff --git a/apps/meteor/app/api/server/v1/channels.ts b/apps/meteor/app/api/server/v1/channels.ts index 578a741efd52f..45f2a54d8df23 100644 --- a/apps/meteor/app/api/server/v1/channels.ts +++ b/apps/meteor/app/api/server/v1/channels.ts @@ -1,5 +1,5 @@ import { Team, Room } from '@rocket.chat/core-services'; -import { TEAM_TYPE, type IRoom, type ISubscription, type IUser, type RoomType, type UserStatus } from '@rocket.chat/core-typings'; +import { TeamType, type IRoom, type ISubscription, type IUser, type RoomType, type UserStatus } from '@rocket.chat/core-typings'; import { Integrations, Messages, Rooms, Subscriptions, Uploads, Users } from '@rocket.chat/models'; import { isChannelsAddAllProps, @@ -1466,7 +1466,7 @@ API.v1.addRoute( // Public rooms of private teams should be accessible only by team members if (findResult.teamId) { const team = await Team.getOneById(findResult.teamId); - if (team?.type === TEAM_TYPE.PRIVATE) { + if (team?.type === TeamType.PRIVATE) { if (!this.userId || !(await canAccessRoomAsync(findResult, { _id: this.userId }))) { return API.v1.notFound('Room not found'); } diff --git a/apps/meteor/app/api/server/v1/teams.ts b/apps/meteor/app/api/server/v1/teams.ts index f1893def4a7a2..e106a4e4ae707 100644 --- a/apps/meteor/app/api/server/v1/teams.ts +++ b/apps/meteor/app/api/server/v1/teams.ts @@ -1,6 +1,6 @@ import { Team } from '@rocket.chat/core-services'; import type { ITeam, UserStatus } from '@rocket.chat/core-typings'; -import { TEAM_TYPE } from '@rocket.chat/core-typings'; +import { TeamType } from '@rocket.chat/core-typings'; import { Users, Rooms } from '@rocket.chat/models'; import { isTeamsConvertToChannelProps, @@ -73,7 +73,7 @@ API.v1.addRoute( this.bodyParams, Match.ObjectIncluding({ name: String, - type: Match.OneOf(TEAM_TYPE.PRIVATE, TEAM_TYPE.PUBLIC), + type: Match.OneOf(TeamType.PRIVATE, TeamType.PUBLIC), members: Match.Maybe([String]), room: Match.Maybe(Match.Any), owner: Match.Maybe(String), diff --git a/apps/meteor/app/api/server/v1/users.ts b/apps/meteor/app/api/server/v1/users.ts index fd546426e84b5..f57dc2d7bfb8c 100644 --- a/apps/meteor/app/api/server/v1/users.ts +++ b/apps/meteor/app/api/server/v1/users.ts @@ -1,5 +1,5 @@ import { MeteorError, Team, api, Calendar } from '@rocket.chat/core-services'; -import { type IExportOperation, type ILoginToken, type IPersonalAccessToken, type IUser, type UserStatus } from '@rocket.chat/core-typings'; +import type { IExportOperation, ILoginToken, IPersonalAccessToken, IUser, UserStatus } from '@rocket.chat/core-typings'; import { Users, Subscriptions, Sessions } from '@rocket.chat/models'; import { isUserCreateParamsPOST, diff --git a/apps/meteor/app/autotranslate/server/autotranslate.ts b/apps/meteor/app/autotranslate/server/autotranslate.ts index afb4b5d5cf5fd..774242565c553 100644 --- a/apps/meteor/app/autotranslate/server/autotranslate.ts +++ b/apps/meteor/app/autotranslate/server/autotranslate.ts @@ -2,7 +2,6 @@ import type { IMessage, IRoom, MessageAttachment, - ISupportedLanguages, IProviderMetadata, ISupportedLanguage, ITranslationResult, @@ -134,7 +133,9 @@ export abstract class AutoTranslate { languages: string[]; - supportedLanguages: ISupportedLanguages; + supportedLanguages: { + [language: string]: ISupportedLanguage[]; + }; /** * Encapsulate the api key and provider settings. diff --git a/apps/meteor/app/autotranslate/server/deeplTranslate.ts b/apps/meteor/app/autotranslate/server/deeplTranslate.ts index 7b6bb9c83c41c..8ed1a6876e39f 100644 --- a/apps/meteor/app/autotranslate/server/deeplTranslate.ts +++ b/apps/meteor/app/autotranslate/server/deeplTranslate.ts @@ -2,14 +2,7 @@ * @author Vigneshwaran Odayappan */ -import type { - IMessage, - IDeepLTranslation, - MessageAttachment, - IProviderMetadata, - ITranslationResult, - ISupportedLanguage, -} from '@rocket.chat/core-typings'; +import type { IMessage, MessageAttachment, IProviderMetadata, ITranslationResult, ISupportedLanguage } from '@rocket.chat/core-typings'; import { serverFetch as fetch } from '@rocket.chat/server-fetch'; import _ from 'underscore'; @@ -21,6 +14,11 @@ import { settings } from '../../settings/server'; const proApiEndpoint = 'https://api.deepl.com/v2/translate'; const freeApiEndpoint = 'https://api-free.deepl.com/v2/translate'; +interface IDeepLTranslation { + detected_source_language: string; + text: string; +} + /** * DeepL translation service provider class representation. * Encapsulates the service provider settings and information. diff --git a/apps/meteor/app/autotranslate/server/googleTranslate.ts b/apps/meteor/app/autotranslate/server/googleTranslate.ts index 5c17a38d41609..23955a401c69c 100644 --- a/apps/meteor/app/autotranslate/server/googleTranslate.ts +++ b/apps/meteor/app/autotranslate/server/googleTranslate.ts @@ -2,14 +2,7 @@ * @author Vigneshwaran Odayappan */ -import type { - IMessage, - IProviderMetadata, - ISupportedLanguage, - ITranslationResult, - IGoogleTranslation, - MessageAttachment, -} from '@rocket.chat/core-typings'; +import type { IMessage, IProviderMetadata, ISupportedLanguage, ITranslationResult, MessageAttachment } from '@rocket.chat/core-typings'; import { serverFetch as fetch } from '@rocket.chat/server-fetch'; import _ from 'underscore'; @@ -18,6 +11,10 @@ import { i18n } from '../../../server/lib/i18n'; import { SystemLogger } from '../../../server/lib/logger/system'; import { settings } from '../../settings/server'; +interface IGoogleTranslation { + translatedText: string; +} + /** * Represents google translate class * @class diff --git a/apps/meteor/app/channel-settings/server/methods/saveRoomSettings.ts b/apps/meteor/app/channel-settings/server/methods/saveRoomSettings.ts index 6ca88c1fdabc5..56dbef2d1cdb1 100644 --- a/apps/meteor/app/channel-settings/server/methods/saveRoomSettings.ts +++ b/apps/meteor/app/channel-settings/server/methods/saveRoomSettings.ts @@ -1,6 +1,6 @@ import { Team } from '@rocket.chat/core-services'; -import type { IRoom, IRoomWithRetentionPolicy, IUser, MessageTypesValues, ITeam } from '@rocket.chat/core-typings'; -import { TEAM_TYPE } from '@rocket.chat/core-typings'; +import type { IRoom, IRoomWithRetentionPolicy, IUser, MessageTypesValues, ITeam, RequiredField } from '@rocket.chat/core-typings'; +import { TeamType } from '@rocket.chat/core-typings'; import type { ServerMethods } from '@rocket.chat/ddp-client'; import { Rooms, Users } from '@rocket.chat/models'; import { Match } from 'meteor/check'; @@ -68,7 +68,7 @@ const isAbacManagedRoom = (room: IRoom): boolean => { const isAbacManagedTeam = (team: Partial | null, teamRoom: IRoom): boolean => { return ( - team?.type === TEAM_TYPE.PRIVATE && + team?.type === TeamType.PRIVATE && settings.get('ABAC_Enabled') && Array.isArray(teamRoom?.abacAttributes) && teamRoom.abacAttributes.length > 0 @@ -236,7 +236,7 @@ const validators: RoomSettingsValidators = { type RoomSettingsSavers = { [TRoomSetting in keyof RoomSettings]?: (params: { userId: IUser['_id']; - user: IUser & Required>; + user: RequiredField; value: RoomSettings[TRoomSetting]; room: IRoom; rid: IRoom['_id']; @@ -251,7 +251,7 @@ const settingSavers: RoomSettingsSavers = { if (room.teamId && room.teamMain) { void Team.update(user._id, room.teamId, { - type: room.t === 'c' ? TEAM_TYPE.PUBLIC : TEAM_TYPE.PRIVATE, + type: room.t === 'c' ? TeamType.PUBLIC : TeamType.PRIVATE, name: value, updateRoom: false, }); @@ -296,7 +296,7 @@ const settingSavers: RoomSettingsSavers = { } if (room.teamId && room.teamMain) { - const type = value === 'c' ? TEAM_TYPE.PUBLIC : TEAM_TYPE.PRIVATE; + const type = value === 'c' ? TeamType.PUBLIC : TeamType.PRIVATE; void Team.update(user._id, room.teamId, { type, updateRoom: false }); } }, @@ -406,7 +406,7 @@ async function save( setting: TRoomSetting, params: { userId: IUser['_id']; - user: IUser & Required>; + user: RequiredField; value: RoomSettings[TRoomSetting]; room: IRoom; rid: IRoom['_id']; @@ -509,7 +509,7 @@ export async function saveRoomSettings( for await (const setting of Object.keys(settings) as (keyof RoomSettings)[]) { await save(setting, { userId, - user: user as IUser & Required>, + user: user as RequiredField, value: settings[setting], room, rid, diff --git a/apps/meteor/app/cloud/server/functions/syncWorkspace/handleCommsSync.ts b/apps/meteor/app/cloud/server/functions/syncWorkspace/handleCommsSync.ts index 9d3934cc0a3c2..133c3cc5b3f63 100644 --- a/apps/meteor/app/cloud/server/functions/syncWorkspace/handleCommsSync.ts +++ b/apps/meteor/app/cloud/server/functions/syncWorkspace/handleCommsSync.ts @@ -39,7 +39,7 @@ export const handleBannerOnWorkspaceSync = async (banners: Exclude): Cloud.Announcement => { +const deserializeAnnouncement = (announcement: Serialized): Cloud.IAnnouncement => { const { inactivedAt, _updatedAt, expireAt, startAt, createdAt } = announcement; return { diff --git a/apps/meteor/client/components/message/content/attachments/file/ImageAttachment.tsx b/apps/meteor/client/components/message/content/attachments/file/ImageAttachment.tsx index 207e0aa7e1670..8f88f9dc4fe85 100644 --- a/apps/meteor/client/components/message/content/attachments/file/ImageAttachment.tsx +++ b/apps/meteor/client/components/message/content/attachments/file/ImageAttachment.tsx @@ -1,11 +1,11 @@ import type { ImageAttachmentProps } from '@rocket.chat/core-typings'; import { useMediaUrl } from '@rocket.chat/ui-contexts'; +import { useLoadImage } from './hooks/useLoadImage'; import MarkdownText from '../../../../MarkdownText'; import MessageCollapsible from '../../../MessageCollapsible'; import MessageContentBody from '../../../MessageContentBody'; import AttachmentImage from '../structure/AttachmentImage'; -import { useLoadImage } from './hooks/useLoadImage'; const ImageAttachment = ({ id, diff --git a/apps/meteor/client/components/message/content/attachments/structure/AttachmentImage.tsx b/apps/meteor/client/components/message/content/attachments/structure/AttachmentImage.tsx index 38881695fdff5..072602cc15d5f 100644 --- a/apps/meteor/client/components/message/content/attachments/structure/AttachmentImage.tsx +++ b/apps/meteor/client/components/message/content/attachments/structure/AttachmentImage.tsx @@ -1,4 +1,3 @@ -import type { Dimensions } from '@rocket.chat/core-typings'; import { Box } from '@rocket.chat/fuselage'; import { useAttachmentDimensions } from '@rocket.chat/ui-contexts'; import { memo, useState, useMemo } from 'react'; @@ -14,12 +13,13 @@ type AttachmentImageProps = { loadImage?: boolean; setLoadImage: () => void; id: string | undefined; -} & Dimensions & - ({ loadImage: true } | { loadImage: false; setLoadImage: () => void }); + width: number; + height: number; +} & ({ loadImage: true } | { loadImage: false; setLoadImage: () => void }); const getDimensions = ( - originalWidth: Dimensions['width'], - originalHeight: Dimensions['height'], + originalWidth: number, + originalHeight: number, limits: { width: number; height: number }, ): { width: number; height: number; ratio: number } => { const widthRatio = originalWidth / limits.width; diff --git a/apps/meteor/client/lib/chats/ChatAPI.ts b/apps/meteor/client/lib/chats/ChatAPI.ts index ef90b95cbb29f..d2a4e8766d0c7 100644 --- a/apps/meteor/client/lib/chats/ChatAPI.ts +++ b/apps/meteor/client/lib/chats/ChatAPI.ts @@ -1,10 +1,15 @@ -import type { IMessage, IRoom, ISubscription, IE2EEMessage, IUpload, Subscribable } from '@rocket.chat/core-typings'; +import type { IMessage, IRoom, ISubscription, IE2EEMessage, IUpload } from '@rocket.chat/core-typings'; import type { IActionManager } from '@rocket.chat/ui-contexts'; import type { Upload } from './Upload'; import type { ReadStateManager } from './readStateManager'; import type { FormattingButton } from '../../../app/ui-message/client/messageBox/messageBoxFormatting'; +type Subscribable = { + get(): T; + subscribe(callback: () => void): () => void; +}; + export type ComposerAPI = { release(): void; readonly text: string; diff --git a/apps/meteor/client/meteor/minimongo/Cursor.ts b/apps/meteor/client/meteor/minimongo/Cursor.ts index f77180bde2a45..db7b5c5ebf5bf 100644 --- a/apps/meteor/client/meteor/minimongo/Cursor.ts +++ b/apps/meteor/client/meteor/minimongo/Cursor.ts @@ -1,3 +1,4 @@ +import type { Optional } from '@rocket.chat/core-typings'; import { createComparatorFromSort, createPredicateFromFilter } from '@rocket.chat/mongo-adapter'; import { Tracker } from 'meteor/tracker'; import type { Filter, Sort } from 'mongodb'; @@ -573,7 +574,7 @@ export class Cursor> { if (!options._suppress_initial && !this.collection.paused) { const handler = (doc: T) => { - const fields: Omit & Partial> = clone(doc); + const fields: Optional = clone(doc); delete fields._id; diff --git a/apps/meteor/client/meteor/minimongo/LocalCollection.ts b/apps/meteor/client/meteor/minimongo/LocalCollection.ts index 4ee6c13257e14..0afdf5fc29011 100644 --- a/apps/meteor/client/meteor/minimongo/LocalCollection.ts +++ b/apps/meteor/client/meteor/minimongo/LocalCollection.ts @@ -1,3 +1,4 @@ +import type { Optional } from '@rocket.chat/core-typings'; import { createDocumentMatcherFromFilter, createPredicateFromFilter, @@ -134,7 +135,7 @@ export class LocalCollection { } private _insertInResults(query: Query, doc: T) { - const fields: Omit & Partial> = clone(doc); + const fields: Optional = clone(doc); delete fields._id; @@ -158,7 +159,7 @@ export class LocalCollection { } private async _insertInResultsAsync(query: Query, doc: T) { - const fields: Omit & Partial> = clone(doc); + const fields: Optional = clone(doc); delete fields._id; diff --git a/apps/meteor/client/views/navigation/sidepanel/SidepanelItem/useParentTeamData.ts b/apps/meteor/client/views/navigation/sidepanel/SidepanelItem/useParentTeamData.ts index 464ff7a5da5a9..7cb2da9b01c79 100644 --- a/apps/meteor/client/views/navigation/sidepanel/SidepanelItem/useParentTeamData.ts +++ b/apps/meteor/client/views/navigation/sidepanel/SidepanelItem/useParentTeamData.ts @@ -1,5 +1,5 @@ import type { ITeam } from '@rocket.chat/core-typings'; -import { TEAM_TYPE } from '@rocket.chat/core-typings'; +import { TeamType } from '@rocket.chat/core-typings'; import { useUserId } from '@rocket.chat/ui-contexts'; import { useTeamInfoQuery } from '../../../../hooks/useTeamInfoQuery'; @@ -27,7 +27,7 @@ export const useParentTeamData = (teamId?: ITeam['_id']) => { const { data: userTeams, isLoading: userTeamsLoading } = useUserTeamsQuery(userId); const userBelongsToTeam = Boolean(userTeams?.find((team) => team._id === teamId)) || false; - const isTeamPublic = teamInfo?.type === TEAM_TYPE.PUBLIC; + const isTeamPublic = teamInfo?.type === TeamType.PUBLIC; const shouldDisplayTeam = isTeamPublic || userBelongsToTeam; return { diff --git a/apps/meteor/client/views/room/Header/ParentRoom/ParentTeam.tsx b/apps/meteor/client/views/room/Header/ParentRoom/ParentTeam.tsx index 722fece0605c5..eee946aeefdae 100644 --- a/apps/meteor/client/views/room/Header/ParentRoom/ParentTeam.tsx +++ b/apps/meteor/client/views/room/Header/ParentRoom/ParentTeam.tsx @@ -1,5 +1,5 @@ import type { IRoom } from '@rocket.chat/core-typings'; -import { TEAM_TYPE } from '@rocket.chat/core-typings'; +import { TeamType } from '@rocket.chat/core-typings'; import { useUserId } from '@rocket.chat/ui-contexts'; import { useTranslation } from 'react-i18next'; @@ -37,7 +37,7 @@ const ParentTeam = ({ room }: ParentTeamProps) => { const { data: userTeams, isLoading: userTeamsLoading } = useUserTeamsQuery(userId); const userBelongsToTeam = Boolean(userTeams?.find((team) => team._id === teamId)) || false; - const isPublicTeam = teamInfo?.type === TEAM_TYPE.PUBLIC; + const isPublicTeam = teamInfo?.type === TeamType.PUBLIC; const shouldDisplayTeam = isPublicTeam || userBelongsToTeam; const redirectToMainRoom = (): void => { diff --git a/apps/meteor/client/views/room/contexts/ComposerPopupContext.ts b/apps/meteor/client/views/room/contexts/ComposerPopupContext.ts index bf0b534c5ae04..d6f8611d8ab5c 100644 --- a/apps/meteor/client/views/room/contexts/ComposerPopupContext.ts +++ b/apps/meteor/client/views/room/contexts/ComposerPopupContext.ts @@ -1,3 +1,4 @@ +import type { Optional } from '@rocket.chat/core-typings'; import type { ReactElement } from 'react'; import { useContext, createContext } from 'react'; @@ -29,7 +30,7 @@ export type ComposerPopupContextValue = ComposerPopupOption[]; export const ComposerPopupContext = createContext(undefined); export const createMessageBoxPopupConfig = ( - partial: Omit, 'getValue'> & Partial, 'getValue'>>, + partial: Optional, 'getValue'>, ): ComposerPopupOption => { return { blurOnSelectItem: true, diff --git a/apps/meteor/client/views/room/hooks/useE2EEResetRoomKey.ts b/apps/meteor/client/views/room/hooks/useE2EEResetRoomKey.ts index 5c179016a528c..a7c7124af9e15 100644 --- a/apps/meteor/client/views/room/hooks/useE2EEResetRoomKey.ts +++ b/apps/meteor/client/views/room/hooks/useE2EEResetRoomKey.ts @@ -1,4 +1,4 @@ -import type { RoomID } from '@rocket.chat/core-typings'; +import type { IRoom } from '@rocket.chat/core-typings'; import { useEndpoint } from '@rocket.chat/ui-contexts'; import type { UseMutationOptions, UseMutationResult } from '@tanstack/react-query'; import { useMutation } from '@tanstack/react-query'; @@ -6,7 +6,7 @@ import { useMutation } from '@tanstack/react-query'; import { e2e } from '../../../lib/e2ee'; type UseE2EEResetRoomKeyVariables = { - roomId: RoomID; + roomId: IRoom['_id']; }; export const useE2EEResetRoomKey = ( diff --git a/apps/meteor/ee/server/apps/marketplace/appRequestNotifyUsers.ts b/apps/meteor/ee/server/apps/marketplace/appRequestNotifyUsers.ts index 59f7d64f309e0..616d6d087115b 100644 --- a/apps/meteor/ee/server/apps/marketplace/appRequestNotifyUsers.ts +++ b/apps/meteor/ee/server/apps/marketplace/appRequestNotifyUsers.ts @@ -1,4 +1,4 @@ -import type { AppRequest, IUser, Pagination } from '@rocket.chat/core-typings'; +import type { AppRequest, IUser } from '@rocket.chat/core-typings'; import { serverFetch as fetch } from '@rocket.chat/server-fetch'; import { getWorkspaceAccessToken } from '../../../../app/cloud/server'; @@ -49,7 +49,7 @@ export const appRequestNotififyForUsers = async ( }; // First request - const pagination: Pagination = { limit: DEFAULT_LIMIT, offset: 0 }; + const pagination = { limit: DEFAULT_LIMIT, offset: 0 }; // First request to get the total and the first batch const response = await fetch(`${marketplaceBaseUrl}/v1/app-request`, { diff --git a/apps/meteor/ee/server/lib/engagementDashboard/users.ts b/apps/meteor/ee/server/lib/engagementDashboard/users.ts index 7aa05855f0dbc..bed16b60903cd 100644 --- a/apps/meteor/ee/server/lib/engagementDashboard/users.ts +++ b/apps/meteor/ee/server/lib/engagementDashboard/users.ts @@ -23,14 +23,10 @@ export const fillFirstDaysOfUsersIfNeeded = async (date: Date): Promise => }).toArray(); if (!usersFromAnalytics.length) { const startOfPeriod = moment(date).subtract(90, 'days').toDate(); - const users = (await Users.getTotalOfRegisteredUsersByDate({ + const users = await Users.getTotalOfRegisteredUsersByDate({ start: startOfPeriod, end: date, - })) as { - date: string; - users: number; - type: 'users'; - }[]; + }); users.forEach((user) => Analytics.insertOne({ ...user, diff --git a/apps/meteor/lib/typedJSONParse.ts b/apps/meteor/lib/typedJSONParse.ts deleted file mode 100644 index bf8c7937b15a6..0000000000000 --- a/apps/meteor/lib/typedJSONParse.ts +++ /dev/null @@ -1,5 +0,0 @@ -import type { Jsonify } from '@rocket.chat/core-typings'; - -export const typedJsonParse = (str: string): Jsonify => { - return JSON.parse(JSON.stringify(str)); -}; diff --git a/apps/meteor/server/configuration/cas.ts b/apps/meteor/server/configuration/cas.ts index 85d4bf88e1872..c5f82eb798b5a 100644 --- a/apps/meteor/server/configuration/cas.ts +++ b/apps/meteor/server/configuration/cas.ts @@ -1,4 +1,3 @@ -import type { Awaited } from '@rocket.chat/core-typings'; import debounce from 'lodash.debounce'; import { RoutePolicy } from 'meteor/routepolicy'; import { WebApp } from 'meteor/webapp'; diff --git a/apps/meteor/server/lib/cas/middleware.ts b/apps/meteor/server/lib/cas/middleware.ts index f8c0de6945d42..ad7cda5f92366 100644 --- a/apps/meteor/server/lib/cas/middleware.ts +++ b/apps/meteor/server/lib/cas/middleware.ts @@ -2,7 +2,7 @@ import type { IncomingMessage, ServerResponse } from 'http'; import url from 'url'; import { validate } from '@rocket.chat/cas-validate'; -import type { ICredentialToken } from '@rocket.chat/core-typings'; +import type { ICredentialToken, RequiredField } from '@rocket.chat/core-typings'; import { CredentialTokens } from '@rocket.chat/models'; import _ from 'underscore'; @@ -15,7 +15,7 @@ const closePopup = function (res: ServerResponse): void { res.end(content, 'utf-8'); }; -type IncomingMessageWithUrl = IncomingMessage & Required>; +type IncomingMessageWithUrl = RequiredField; const casTicket = function (req: IncomingMessageWithUrl, token: string, callback: () => void): void { // get configuration diff --git a/apps/meteor/server/lib/rooms/roomTypes/public.ts b/apps/meteor/server/lib/rooms/roomTypes/public.ts index 860c5984291b4..ead4609c11c8d 100644 --- a/apps/meteor/server/lib/rooms/roomTypes/public.ts +++ b/apps/meteor/server/lib/rooms/roomTypes/public.ts @@ -1,6 +1,6 @@ import { Team } from '@rocket.chat/core-services'; import type { AtLeast, IRoom } from '@rocket.chat/core-typings'; -import { isRoomFederated, isRoomNativeFederated, TEAM_TYPE } from '@rocket.chat/core-typings'; +import { isRoomFederated, isRoomNativeFederated, TeamType } from '@rocket.chat/core-typings'; import { settings } from '../../../../app/settings/server'; import type { IRoomTypeServerDirectives } from '../../../../definition/IRoomTypeConfig'; @@ -70,7 +70,7 @@ roomCoordinator.add(PublicRoomType, { async getDiscussionType(room) { if (room?.teamId) { const team = await Team.getOneById(room.teamId, { projection: { type: 1 } }); - if (team?.type === TEAM_TYPE.PRIVATE) { + if (team?.type === TeamType.PRIVATE) { return 'p'; } } diff --git a/apps/meteor/server/services/authorization/canAccessRoom.ts b/apps/meteor/server/services/authorization/canAccessRoom.ts index 3f348e953a98c..2c7cfd7432393 100644 --- a/apps/meteor/server/services/authorization/canAccessRoom.ts +++ b/apps/meteor/server/services/authorization/canAccessRoom.ts @@ -1,6 +1,6 @@ import { Authorization, License, Abac } from '@rocket.chat/core-services'; import type { RoomAccessValidator } from '@rocket.chat/core-services'; -import { TEAM_TYPE, AbacAccessOperation, AbacObjectType } from '@rocket.chat/core-typings'; +import { TeamType, AbacAccessOperation, AbacObjectType } from '@rocket.chat/core-typings'; import type { IUser, ITeam } from '@rocket.chat/core-typings'; import { Subscriptions, Rooms, Settings, TeamMember, Team } from '@rocket.chat/models'; @@ -30,7 +30,7 @@ const roomAccessValidators: RoomAccessValidator[] = [ const team = await Team.findOneById>(room.teamId, { projection: { type: 1 }, }); - if (team?.type === TEAM_TYPE.PUBLIC) { + if (team?.type === TeamType.PUBLIC) { return canAccessPublicRoom(user); } diff --git a/apps/meteor/server/services/team/service.ts b/apps/meteor/server/services/team/service.ts index 87c8ce18af4f3..add7f3940574f 100644 --- a/apps/meteor/server/services/team/service.ts +++ b/apps/meteor/server/services/team/service.ts @@ -9,7 +9,7 @@ import type { ITeamService, ITeamUpdateData, } from '@rocket.chat/core-services'; -import { TEAM_TYPE } from '@rocket.chat/core-typings'; +import { TeamType } from '@rocket.chat/core-typings'; import type { IRoom, IUser, @@ -81,7 +81,7 @@ export class TeamService extends ServiceClassInternal implements ITeamService { ( await Room.create(owner || uid, { ...room, - type: team.type === TEAM_TYPE.PRIVATE ? 'p' : 'c', + type: team.type === TeamType.PRIVATE ? 'p' : 'c', name: team.name, members: memberUsernames as string[], extraData: { @@ -158,7 +158,7 @@ export class TeamService extends ServiceClassInternal implements ITeamService { } if (updateRoom && typeof type !== 'undefined') { - await saveRoomType(team.roomId, type === TEAM_TYPE.PRIVATE ? 'p' : 'c', user); + await saveRoomType(team.roomId, type === TeamType.PRIVATE ? 'p' : 'c', user); } await Team.updateNameAndType(teamId, updateData); @@ -173,7 +173,7 @@ export class TeamService extends ServiceClassInternal implements ITeamService { let teamIds = unfilteredTeamIds; if (callerId) { - const publicTeams = await Team.findByIdsAndType>(unfilteredTeamIds, TEAM_TYPE.PUBLIC, { + const publicTeams = await Team.findByIdsAndType>(unfilteredTeamIds, TeamType.PUBLIC, { projection: { _id: 1 }, }).toArray(); const publicTeamIds = publicTeams.map(({ _id }) => _id); @@ -524,7 +524,7 @@ export class TeamService extends ServiceClassInternal implements ITeamService { const { getAllRooms, allowPrivateTeam, name, isDefault } = filter; const isMember = await TeamMember.findOneByUserIdAndTeamId(uid, teamId); - if (team.type === TEAM_TYPE.PRIVATE && !allowPrivateTeam && !isMember) { + if (team.type === TeamType.PRIVATE && !allowPrivateTeam && !isMember) { throw new Error('user-not-on-private-team'); } @@ -571,7 +571,7 @@ export class TeamService extends ServiceClassInternal implements ITeamService { throw new Error('invalid-team'); } const isMember = await TeamMember.findOneByUserIdAndTeamId(uid, teamId); - if (team.type === TEAM_TYPE.PRIVATE && !allowPrivateTeam && !isMember) { + if (team.type === TeamType.PRIVATE && !allowPrivateTeam && !isMember) { throw new Error('user-not-on-private-team'); } @@ -894,7 +894,7 @@ export class TeamService extends ServiceClassInternal implements ITeamService { getAllPublicTeams(options: FindOptions): Promise; async getAllPublicTeams(options?: undefined | FindOptions): Promise { - return options ? Team.findByType(TEAM_TYPE.PUBLIC, options).toArray() : Team.findByType(TEAM_TYPE.PUBLIC).toArray(); + return options ? Team.findByType(TeamType.PUBLIC, options).toArray() : Team.findByType(TeamType.PUBLIC).toArray(); } async getOneById(teamId: string, options?: FindOptions): Promise { diff --git a/apps/meteor/tests/data/teams.helper.ts b/apps/meteor/tests/data/teams.helper.ts index f6cba25f86c95..4f4d47dac3ea5 100644 --- a/apps/meteor/tests/data/teams.helper.ts +++ b/apps/meteor/tests/data/teams.helper.ts @@ -1,11 +1,11 @@ -import type { ITeam, TEAM_TYPE } from '@rocket.chat/core-typings'; +import type { ITeam, TeamType } from '@rocket.chat/core-typings'; import { api, request } from './api-data'; export const createTeam = async ( credentials: Record, teamName: string, - type: TEAM_TYPE, + type: TeamType, members?: string[], ): Promise => { const response = await request diff --git a/apps/meteor/tests/end-to-end/api/channels.ts b/apps/meteor/tests/end-to-end/api/channels.ts index ed02741f3da4a..f2d348240f3cf 100644 --- a/apps/meteor/tests/end-to-end/api/channels.ts +++ b/apps/meteor/tests/end-to-end/api/channels.ts @@ -1,5 +1,5 @@ import type { Credentials } from '@rocket.chat/api-client'; -import { TEAM_TYPE, type IIntegration, type IMessage, type IRoom, type ITeam, type IUser } from '@rocket.chat/core-typings'; +import { TeamType, type IIntegration, type IMessage, type IRoom, type ITeam, type IUser } from '@rocket.chat/core-typings'; import { Random } from '@rocket.chat/random'; import { expect, assert } from 'chai'; import { after, before, describe, it } from 'mocha'; @@ -1037,8 +1037,8 @@ describe('[Channels]', () => { // Create a public team and a private team [publicTeam, privateTeam] = await Promise.all([ - createTeam(insideCredentials, `channels.info.team.public.${Random.id()}`, TEAM_TYPE.PUBLIC, [outsiderUser.username as string]), - createTeam(insideCredentials, `channels.info.team.private.${Random.id()}`, TEAM_TYPE.PRIVATE, [outsiderUser.username as string]), + createTeam(insideCredentials, `channels.info.team.public.${Random.id()}`, TeamType.PUBLIC, [outsiderUser.username as string]), + createTeam(insideCredentials, `channels.info.team.private.${Random.id()}`, TeamType.PRIVATE, [outsiderUser.username as string]), ]); const [ @@ -1887,8 +1887,8 @@ describe('[Channels]', () => { // Create a public team and a private team [publicTeam, privateTeam] = await Promise.all([ - createTeam(insideCredentials, `channels.members.team.public.${Random.id()}`, TEAM_TYPE.PUBLIC, [outsiderUser.username as string]), - createTeam(insideCredentials, `channels.members.team.private.${Random.id()}`, TEAM_TYPE.PRIVATE, [ + createTeam(insideCredentials, `channels.members.team.public.${Random.id()}`, TeamType.PUBLIC, [outsiderUser.username as string]), + createTeam(insideCredentials, `channels.members.team.private.${Random.id()}`, TeamType.PRIVATE, [ outsiderUser.username as string, ]), ]); @@ -2312,10 +2312,10 @@ describe('[Channels]', () => { // Create a public team and a private team [publicTeam, privateTeam] = await Promise.all([ - createTeam(insideCredentials, `channels.getIntegrations.team.public.${Random.id()}`, TEAM_TYPE.PUBLIC, [ + createTeam(insideCredentials, `channels.getIntegrations.team.public.${Random.id()}`, TeamType.PUBLIC, [ outsiderUser.username as string, ]), - createTeam(insideCredentials, `channels.getIntegrations.team.private.${Random.id()}`, TEAM_TYPE.PRIVATE, [ + createTeam(insideCredentials, `channels.getIntegrations.team.private.${Random.id()}`, TeamType.PRIVATE, [ outsiderUser.username as string, ]), ]); @@ -3284,10 +3284,10 @@ describe('[Channels]', () => { // Create a public team and a private team [publicTeam, privateTeam] = await Promise.all([ - createTeam(insideCredentials, `channels.moderators.team.public.${Random.id()}`, TEAM_TYPE.PUBLIC, [ + createTeam(insideCredentials, `channels.moderators.team.public.${Random.id()}`, TeamType.PUBLIC, [ outsiderUser.username as string, ]), - createTeam(insideCredentials, `channels.moderators.team.private.${Random.id()}`, TEAM_TYPE.PRIVATE, [ + createTeam(insideCredentials, `channels.moderators.team.private.${Random.id()}`, TeamType.PRIVATE, [ outsiderUser.username as string, ]), ]); @@ -3650,7 +3650,7 @@ describe('[Channels]', () => { ]); // Create a private team - privateTeam = await createTeam(insideCredentials, `channels.anonymousread.team.private.${Random.id()}`, TEAM_TYPE.PRIVATE, [ + privateTeam = await createTeam(insideCredentials, `channels.anonymousread.team.private.${Random.id()}`, TeamType.PRIVATE, [ outsiderUser.username as string, ]); @@ -4231,10 +4231,8 @@ describe('[Channels]', () => { // Create a public team and a private team [publicTeam, privateTeam] = await Promise.all([ - createTeam(insideCredentials, `channels.messages.team.public.${Random.id()}`, TEAM_TYPE.PUBLIC, [ - outsiderUser.username as string, - ]), - createTeam(insideCredentials, `channels.messages.team.private.${Random.id()}`, TEAM_TYPE.PRIVATE, [ + createTeam(insideCredentials, `channels.messages.team.public.${Random.id()}`, TeamType.PUBLIC, [outsiderUser.username as string]), + createTeam(insideCredentials, `channels.messages.team.private.${Random.id()}`, TeamType.PRIVATE, [ outsiderUser.username as string, ]), ]); diff --git a/apps/meteor/tests/end-to-end/api/incoming-integrations.ts b/apps/meteor/tests/end-to-end/api/incoming-integrations.ts index bdc1691f79869..0f80ee77b6faf 100644 --- a/apps/meteor/tests/end-to-end/api/incoming-integrations.ts +++ b/apps/meteor/tests/end-to-end/api/incoming-integrations.ts @@ -1,5 +1,5 @@ import type { Credentials } from '@rocket.chat/api-client'; -import { TEAM_TYPE } from '@rocket.chat/core-typings'; +import { TeamType } from '@rocket.chat/core-typings'; import type { AtLeast, IIntegration, IMessage, IRoom, ITeam, IUser } from '@rocket.chat/core-typings'; import { Random } from '@rocket.chat/random'; import { assert, expect } from 'chai'; @@ -903,7 +903,7 @@ describe('[Incoming Integrations]', () => { before(async () => { nonMemberUser = await createUser({ username: `g_${Random.id()}` }); - privateTeam = await createTeam(credentials, `private.team.${Random.id()}`, TEAM_TYPE.PRIVATE); + privateTeam = await createTeam(credentials, `private.team.${Random.id()}`, TeamType.PRIVATE); const [publicInPrivateResponse, privateRoomResponse, publicRoomResponse] = await Promise.all([ createRoom({ diff --git a/apps/meteor/tests/end-to-end/api/miscellaneous.ts b/apps/meteor/tests/end-to-end/api/miscellaneous.ts index 59510e96bdb71..0f3f7de85abfd 100644 --- a/apps/meteor/tests/end-to-end/api/miscellaneous.ts +++ b/apps/meteor/tests/end-to-end/api/miscellaneous.ts @@ -1,6 +1,6 @@ import type { Credentials } from '@rocket.chat/api-client'; import type { IInstanceStatus, IRoom, ITeam, IUser } from '@rocket.chat/core-typings'; -import { TEAM_TYPE } from '@rocket.chat/core-typings'; +import { TeamType } from '@rocket.chat/core-typings'; import type { IInstance } from '@rocket.chat/rest-typings'; import { AssertionError, expect } from 'chai'; import { after, before, describe, it } from 'mocha'; @@ -228,7 +228,7 @@ describe('miscellaneous', () => { [testChannel, testGroup, teamCreated] = await Promise.all([ createRoom({ name: `channel.test.${Date.now()}`, type: 'c' }).then((res) => res.body.channel), createRoom({ name: `group.test.${Date.now()}`, type: 'p' }).then((res) => res.body.group), - createTeam(normalUserCredentials, teamName, TEAM_TYPE.PUBLIC), + createTeam(normalUserCredentials, teamName, TeamType.PUBLIC), ]); }); @@ -448,7 +448,7 @@ describe('miscellaneous', () => { await updateSetting('UI_Allow_room_names_with_special_chars', true); testChannelSpecialChars = (await createRoom({ type: 'c', name: fnameSpecialCharsRoom, credentials: userCredentials })).body.channel; testChannel = (await createRoom({ type: 'c', name: `channel.test.${Date.now()}`, credentials: userCredentials })).body.channel; - testTeam = await createTeam(userCredentials, teamName, TEAM_TYPE.PUBLIC); + testTeam = await createTeam(userCredentials, teamName, TeamType.PUBLIC); }); after(async () => { diff --git a/apps/meteor/tests/end-to-end/api/rooms.ts b/apps/meteor/tests/end-to-end/api/rooms.ts index 8ab8a3bb20917..345baf3369f87 100644 --- a/apps/meteor/tests/end-to-end/api/rooms.ts +++ b/apps/meteor/tests/end-to-end/api/rooms.ts @@ -13,7 +13,7 @@ import type { MessageAttachment, SettingValue, } from '@rocket.chat/core-typings'; -import { isFileAttachment, isQuoteAttachment, TEAM_TYPE } from '@rocket.chat/core-typings'; +import { isFileAttachment, isQuoteAttachment, TeamType } from '@rocket.chat/core-typings'; import { Random } from '@rocket.chat/random'; import { assert, expect } from 'chai'; import { after, afterEach, before, beforeEach, describe, it } from 'mocha'; @@ -2213,8 +2213,8 @@ describe('[Rooms]', () => { publicChannel = (await createRoom({ type: 'c', name: `public-channel-${Date.now()}` })).body.channel; privateGroup = (await createRoom({ type: 'p', name: `private-group-${Date.now()}` })).body.group; - publicTeam = await createTeam(credentials, `public-team-${Date.now()}`, TEAM_TYPE.PUBLIC); - privateTeam = await createTeam(credentials, `private-team-${Date.now()}`, TEAM_TYPE.PRIVATE); + publicTeam = await createTeam(credentials, `public-team-${Date.now()}`, TeamType.PUBLIC); + privateTeam = await createTeam(credentials, `private-team-${Date.now()}`, TeamType.PRIVATE); }); after(async () => { @@ -2401,7 +2401,7 @@ describe('[Rooms]', () => { body: { channel }, } = await createRoom({ type: 'c', name: `channel.test.${Date.now()}-${Math.random()}` }); testChannel = channel; - testTeam = await createTeam(userCredentials, `team.test.${Date.now()}-${Math.random()}`, TEAM_TYPE.PUBLIC, [ + testTeam = await createTeam(userCredentials, `team.test.${Date.now()}-${Math.random()}`, TeamType.PUBLIC, [ testUser.username as string, testUser2.username as string, ]); @@ -3859,10 +3859,10 @@ describe('[Rooms]', () => { // Create a public team and a private team [publicTeam, privateTeam] = await Promise.all([ - createTeam(insideCredentials, `rooms.membersOrderedByRole.team.public.${Random.id()}`, TEAM_TYPE.PUBLIC, [ + createTeam(insideCredentials, `rooms.membersOrderedByRole.team.public.${Random.id()}`, TeamType.PUBLIC, [ outsiderUser.username as string, ]), - createTeam(insideCredentials, `rooms.membersOrderedByRole.team.private.${Random.id()}`, TEAM_TYPE.PRIVATE, [ + createTeam(insideCredentials, `rooms.membersOrderedByRole.team.private.${Random.id()}`, TeamType.PRIVATE, [ outsiderUser.username as string, ]), ]); diff --git a/apps/meteor/tests/end-to-end/api/teams.ts b/apps/meteor/tests/end-to-end/api/teams.ts index 195606d3099c4..35ddbaae0b5d9 100644 --- a/apps/meteor/tests/end-to-end/api/teams.ts +++ b/apps/meteor/tests/end-to-end/api/teams.ts @@ -1,6 +1,6 @@ import type { Credentials } from '@rocket.chat/api-client'; import type { IRole, IRoom, ITeam, IUser } from '@rocket.chat/core-typings'; -import { TEAM_TYPE } from '@rocket.chat/core-typings'; +import { TeamType } from '@rocket.chat/core-typings'; import { Random } from '@rocket.chat/random'; import { expect } from 'chai'; import { after, afterEach, before, beforeEach, describe, it } from 'mocha'; @@ -1179,8 +1179,8 @@ describe('/teams.info', () => { before(async () => { testUser = await createUser(); testUserCredentials = await login(testUser.username, password); - testTeam = await createTeam(credentials, teamName, TEAM_TYPE.PUBLIC); - testTeam2 = await createTeam(credentials, `${teamName}-2`, TEAM_TYPE.PRIVATE); + testTeam = await createTeam(credentials, teamName, TeamType.PUBLIC); + testTeam2 = await createTeam(credentials, `${teamName}-2`, TeamType.PRIVATE); }); after(() => Promise.all([deleteTeam(credentials, testTeam.name), deleteTeam(credentials, testTeam2.name), deleteUser(testUser)])); @@ -1660,8 +1660,8 @@ describe('/teams.addRooms', () => { privateRoom3 = (await createRoom({ type: 'p', name: `community-channel-private-3-${Date.now()}` })).body.group; publicRoom = (await createRoom({ type: 'c', name: `community-channel-public-1-${Date.now()}` })).body.channel; publicRoom2 = (await createRoom({ type: 'c', name: `community-channel-public-2-${Date.now()}` })).body.channel; - publicTeam = await createTeam(credentials, `team-name-c-${Date.now()}`, TEAM_TYPE.PUBLIC); - privateTeam = await createTeam(credentials, `team-name-p-${Date.now()}`, TEAM_TYPE.PRIVATE); + publicTeam = await createTeam(credentials, `team-name-c-${Date.now()}`, TeamType.PUBLIC); + privateTeam = await createTeam(credentials, `team-name-p-${Date.now()}`, TeamType.PRIVATE); }); after(async () => { @@ -1836,8 +1836,8 @@ describe('/teams.listRooms', () => { before(async () => { testUser = await createUser(); testUserCredentials = await login(testUser.username, password); - privateTeam = await createTeam(credentials, `teamName-private-${Date.now()}`, TEAM_TYPE.PRIVATE); - publicTeam = await createTeam(testUserCredentials, `teamName-public-${Date.now()}`, TEAM_TYPE.PUBLIC); + privateTeam = await createTeam(credentials, `teamName-private-${Date.now()}`, TeamType.PRIVATE); + publicTeam = await createTeam(testUserCredentials, `teamName-public-${Date.now()}`, TeamType.PUBLIC); privateRoom = (await createRoom({ type: 'p', name: `test-p-${Date.now()}` })).body.group; publicRoom = (await createRoom({ type: 'c', name: `test-c-${Date.now()}` })).body.channel; @@ -2335,7 +2335,7 @@ describe('/teams.updateRoom', () => { before(async () => { publicRoom = (await createRoom({ type: 'c', name: `public-update-room-${Date.now()}` })).body.channel; - publicTeam = await createTeam(credentials, name, TEAM_TYPE.PUBLIC); + publicTeam = await createTeam(credentials, name, TeamType.PUBLIC); await request .post(api('teams.addRooms')) .set(credentials) @@ -2713,7 +2713,7 @@ describe('/teams.removeRoom', () => { before(async () => { publicRoom = (await createRoom({ type: 'c', name: `public-remove-room-${Date.now()}` })).body.channel; - publicTeam = await createTeam(credentials, name, TEAM_TYPE.PUBLIC); + publicTeam = await createTeam(credentials, name, TeamType.PUBLIC); await request .post(api('teams.addRooms')) .set(credentials) diff --git a/apps/meteor/tests/end-to-end/api/users.ts b/apps/meteor/tests/end-to-end/api/users.ts index eb0baf3aa3d00..1618d79330207 100644 --- a/apps/meteor/tests/end-to-end/api/users.ts +++ b/apps/meteor/tests/end-to-end/api/users.ts @@ -1,9 +1,9 @@ import crypto from 'crypto'; import type { Credentials } from '@rocket.chat/api-client'; -import type { IGetRoomRoles, IRoom, ISubscription, ITeam, IUser } from '@rocket.chat/core-typings'; +import type { IRoom, ISubscription, ITeam, IUser } from '@rocket.chat/core-typings'; import { Random } from '@rocket.chat/random'; -import type { PaginatedResult, DefaultUserInfo } from '@rocket.chat/rest-typings'; +import type { IGetRoomRoles, PaginatedResult, DefaultUserInfo } from '@rocket.chat/rest-typings'; import { assert, expect } from 'chai'; import { after, afterEach, before, beforeEach, describe, it } from 'mocha'; import { MongoClient } from 'mongodb'; diff --git a/apps/meteor/tests/mocks/data/marketplace.ts b/apps/meteor/tests/mocks/data/marketplace.ts index cb8c5d67ad10b..31715f46c58a1 100644 --- a/apps/meteor/tests/mocks/data/marketplace.ts +++ b/apps/meteor/tests/mocks/data/marketplace.ts @@ -1,6 +1,7 @@ import { faker } from '@faker-js/faker'; import type { AppStatus } from '@rocket.chat/apps'; -import { type App, type AppSubscriptionInfo, AppSubscriptionStatus } from '@rocket.chat/core-typings'; +import { AppSubscriptionStatus } from '@rocket.chat/core-typings'; +import type { AppSubscriptionInfo, App } from '@rocket.chat/core-typings'; import { createFakeApp } from '../data'; diff --git a/ee/packages/license/src/MockedLicenseBuilder.ts b/ee/packages/license/src/MockedLicenseBuilder.ts index 9b9a2a7e897f9..60a1e98e242cf 100644 --- a/ee/packages/license/src/MockedLicenseBuilder.ts +++ b/ee/packages/license/src/MockedLicenseBuilder.ts @@ -7,7 +7,6 @@ import type { LicenseLimit, LicenseModule, LicensePeriod, - Timestamp, } from '@rocket.chat/core-typings'; import { encrypt, encryptStatsToken } from './token'; @@ -16,12 +15,12 @@ export class MockedLicenseBuilder { information: { id?: string; autoRenew: boolean; - visualExpiration?: Timestamp; - notifyAdminsAt?: Timestamp; - notifyUsersAt?: Timestamp; + visualExpiration?: string; + notifyAdminsAt?: string; + notifyUsersAt?: string; trial: boolean; offline: boolean; - createdAt: Timestamp; + createdAt: string; grantedBy: { method: 'manual' | 'self-service' | 'sales' | 'support' | 'reseller'; seller?: string; diff --git a/ee/packages/license/src/validation/validateLicensePeriods.ts b/ee/packages/license/src/validation/validateLicensePeriods.ts index 4229d24356455..37f5d33a5ab2c 100644 --- a/ee/packages/license/src/validation/validateLicensePeriods.ts +++ b/ee/packages/license/src/validation/validateLicensePeriods.ts @@ -1,10 +1,10 @@ -import type { ILicenseV3, BehaviorWithContext, Timestamp, LicenseValidationOptions } from '@rocket.chat/core-typings'; +import type { ILicenseV3, BehaviorWithContext, LicenseValidationOptions } from '@rocket.chat/core-typings'; import { isBehaviorAllowed } from '../isItemAllowed'; import { logger } from '../logger'; import { getResultingBehavior } from './getResultingBehavior'; -export const isPeriodInvalid = (from: Timestamp | undefined, until: Timestamp | undefined) => { +export const isPeriodInvalid = (from: string | undefined, until: string | undefined) => { const now = new Date(); if (from && now < new Date(from)) { diff --git a/packages/core-services/src/types/ITeamService.ts b/packages/core-services/src/types/ITeamService.ts index 7b357c266570c..0a9b24842e937 100644 --- a/packages/core-services/src/types/ITeamService.ts +++ b/packages/core-services/src/types/ITeamService.ts @@ -5,7 +5,7 @@ import type { ITeam, ITeamMember, ITeamStats, - TEAM_TYPE, + TeamType, IRoom, IUser, IRole, @@ -61,11 +61,11 @@ export interface IListRoomsFilter { export type ITeamUpdateData = { updateRoom?: boolean } & ( | { name: string; - type?: TEAM_TYPE; + type?: TeamType; } | { name?: string; - type: TEAM_TYPE; + type: TeamType; } ); diff --git a/packages/core-typings/src/AppOverview.ts b/packages/core-typings/src/AppOverview.ts deleted file mode 100644 index 0b0eec451928b..0000000000000 --- a/packages/core-typings/src/AppOverview.ts +++ /dev/null @@ -1,115 +0,0 @@ -import type { AppStatus } from '@rocket.chat/apps-engine/definition/AppStatus'; - -import type { App, AppSubscriptionStatus } from './Apps'; - -export type AppOverview = { - appId: string; - latest: Latest; - isAddon: boolean; - addonId: string; - isEnterpriseOnly: boolean; - isBundle: boolean; - bundledAppIds: any[]; - bundledIn: bundledIn[]; - isPurchased: boolean; - isSubscribed: boolean; - subscriptionInfo: SubscriptionInfo; - price: number; - purchaseType: string; - pricingPlans: PricingPlan[]; - isUsageBased: boolean; - createdAt: string; - modifiedAt: string; - iconFileContent?: string; - marketplaceVersion?: string; - marketplace?: unknown; -}; - -export type bundledIn = { - bundleId: string; - bundleName: string; - apps: App[]; - addonTierId: string; -}; - -export type Latest = { - internalId: string; - id: string; - name: string; - nameSlug: string; - version: string; - categories: string[]; - languages: string[]; - description: string; - privacyPolicySummary: string; - detailedDescription: DetailedDescription; - detailedChangelog: DetailedChangelog; - requiredApiVersion: string; - permissions: Permission[]; - author: Author; - classFile: string; - iconFile: string; - iconFileData: string; - status: AppStatus; - isVisible: boolean; - createdDate: string; - modifiedDate: string; - isPurchased: boolean; - isSubscribed: boolean; - subscriptionInfo: SubscriptionInfo; - compileJobId: string; - compiled: boolean; - tosLink: string; - privacyLink: string; -}; - -export type DetailedDescription = { - raw: string; - rendered: string; -}; - -export type DetailedChangelog = { - raw: string; - rendered: string; -}; - -export type Permission = { - name: string; - scopes?: string[]; -}; - -export type Author = { - name: string; - support: string; - homepage: string; -}; - -export type SubscriptionInfo = { - typeOf: string; - status: AppSubscriptionStatus; - statusFromBilling: boolean; - isSeatBased: boolean; - seats: number; - maxSeats: number; - license: License; - startDate: string; - periodEnd: string; - endDate: string; - externallyManaged: boolean; - isSubscribedViaBundle: boolean; -}; - -export type License = { - license: string; - version: number; - expireDate: string; -}; - -export type PricingPlan = { - id: string; - enabled: boolean; - price: number; - trialDays: number; - strategy: string; - isPerSeat: boolean; -}; diff --git a/packages/core-typings/src/AppRequests.ts b/packages/core-typings/src/AppRequests.ts deleted file mode 100644 index 8a59488c81cca..0000000000000 --- a/packages/core-typings/src/AppRequests.ts +++ /dev/null @@ -1,47 +0,0 @@ -export type AppRequestFilter = 'unseen' | 'seen' | 'notification-sent' | 'notification-not-sent' | ''; - -export type AppRequestEndUser = { - id: string; - username: string; - name: string; - nickname: string; - emails: string[]; -}; - -export type AppRequest = { - id: string; - appId: string; - - requester: AppRequestEndUser; - admins: AppRequestEndUser[]; - - workspaceId: string; - message: string; - - seen: boolean; - seenAt: string; - notificationSent: boolean; - notificationSentAt: string; - - createdDate: string; -}; - -export type Meta = { - limit: 25 | 50 | 100; - offset: number; - sort: string; - filter: string; - total: number; -}; - -export type PaginatedAppRequests = { - data: AppRequest[] | null; - meta: Meta; -}; - -export type AppRequestsStats = { - data: { - totalSeen: number; - totalUnseen: number; - }; -}; diff --git a/packages/core-typings/src/Apps.ts b/packages/core-typings/src/Apps.ts index 06a18581cd442..d440c9b372703 100644 --- a/packages/core-typings/src/Apps.ts +++ b/packages/core-typings/src/Apps.ts @@ -12,13 +12,6 @@ export type AppScreenshot = { modifiedAt: string; }; -export type AppTiers = { - perUnit: boolean; - minimum: number; - maximum: number; - price: number; -}; - export type AppPricingPlan = { id: string; enabled: boolean; @@ -26,13 +19,12 @@ export type AppPricingPlan = { trialDays: number; strategy: string; isPerSeat: boolean; - tiers?: AppTiers[]; -}; - -export type AppLicense = { - license: string; - version: number; - expireDate: string; + tiers?: { + perUnit: boolean; + minimum: number; + maximum: number; + price: number; + }[]; }; export enum AppSubscriptionStatus { @@ -50,7 +42,11 @@ export type AppSubscriptionInfo = { isSeatBased: boolean; seats: number; maxSeats: number; - license: AppLicense; + license: { + license: string; + version: number; + expireDate: string; + }; startDate: string; periodEnd: string; endDate: string; @@ -144,3 +140,114 @@ export type AppCategory = { createdDate: string; modifiedDate: string; }; + +export type AppOverview = { + appId: string; + latest: { + internalId: string; + id: string; + name: string; + nameSlug: string; + version: string; + categories: string[]; + languages: string[]; + description: string; + privacyPolicySummary: string; + detailedDescription: { + raw: string; + rendered: string; + }; + detailedChangelog: { + raw: string; + rendered: string; + }; + requiredApiVersion: string; + permissions: { + name: string; + scopes?: string[]; + }[]; + author: { + name: string; + support: string; + homepage: string; + }; + classFile: string; + iconFile: string; + iconFileData: string; + status: AppStatus; + isVisible: boolean; + createdDate: string; + modifiedDate: string; + isPurchased: boolean; + isSubscribed: boolean; + subscriptionInfo: AppSubscriptionInfo & { externallyManaged: boolean }; + compileJobId: string; + compiled: boolean; + tosLink: string; + privacyLink: string; + }; + isAddon: boolean; + addonId: string; + isEnterpriseOnly: boolean; + isBundle: boolean; + bundledAppIds: any[]; + bundledIn: { + bundleId: string; + bundleName: string; + apps: App[]; + addonTierId: string; + }[]; + isPurchased: boolean; + isSubscribed: boolean; + subscriptionInfo: AppSubscriptionInfo & { externallyManaged: boolean }; + price: number; + purchaseType: string; + pricingPlans: { + id: string; + enabled: boolean; + price: number; + trialDays: number; + strategy: string; + isPerSeat: boolean; + }[]; + isUsageBased: boolean; + createdAt: string; + modifiedAt: string; + iconFileContent?: string; + marketplaceVersion?: string; + marketplace?: unknown; +}; + +export type FeaturedAppsSection = { + i18nLabel: string; + slug: string; + apps: AppOverview[]; +}; + +export type AppRequestFilter = 'unseen' | 'seen' | 'notification-sent' | 'notification-not-sent' | ''; + +type AppRequestEndUser = { + id: string; + username: string; + name: string; + nickname: string; + emails: string[]; +}; + +export type AppRequest = { + id: string; + appId: string; + + requester: AppRequestEndUser; + admins: AppRequestEndUser[]; + + workspaceId: string; + message: string; + + seen: boolean; + seenAt: string; + notificationSent: boolean; + notificationSentAt: string; + + createdDate: string; +}; diff --git a/packages/core-typings/src/FeaturedApps.ts b/packages/core-typings/src/FeaturedApps.ts deleted file mode 100644 index 462c2af93c7dc..0000000000000 --- a/packages/core-typings/src/FeaturedApps.ts +++ /dev/null @@ -1,7 +0,0 @@ -import type { AppOverview } from './AppOverview'; - -export type FeaturedAppsSection = { - i18nLabel: string; - slug: string; - apps: AppOverview[]; -}; diff --git a/packages/core-typings/src/IAnalytic.ts b/packages/core-typings/src/IAnalytics.ts similarity index 57% rename from packages/core-typings/src/IAnalytic.ts rename to packages/core-typings/src/IAnalytics.ts index 320da54a707dc..80bc26cfabc0a 100644 --- a/packages/core-typings/src/IAnalytic.ts +++ b/packages/core-typings/src/IAnalytics.ts @@ -5,7 +5,7 @@ interface IAnalyticsBase extends IRocketChatRecord { date: number; } -export interface IAnalyticsMessages extends IAnalyticsBase { +interface IAnalyticsMessages extends IAnalyticsBase { type: 'messages'; room: { _id: string; @@ -15,14 +15,8 @@ export interface IAnalyticsMessages extends IAnalyticsBase { }; } -export interface IAnalyticsUsers extends IAnalyticsBase { +interface IAnalyticsUsers extends IAnalyticsBase { type: 'users'; - room: { - _id: string; - name?: string; - t: string; - usernames: string[]; - }; } export interface IAnalyticsSeatRequest extends IAnalyticsBase { @@ -30,4 +24,4 @@ export interface IAnalyticsSeatRequest extends IAnalyticsBase { count: number; } -export type IAnalytic = IAnalyticsBase | IAnalyticsMessages | IAnalyticsUsers | IAnalyticsSeatRequest; +export type IAnalytics = IAnalyticsMessages | IAnalyticsUsers | IAnalyticsSeatRequest; diff --git a/packages/core-typings/src/AppsTokens.ts b/packages/core-typings/src/IAppsTokens.ts similarity index 100% rename from packages/core-typings/src/AppsTokens.ts rename to packages/core-typings/src/IAppsTokens.ts diff --git a/packages/core-typings/src/IAvatar.ts b/packages/core-typings/src/IAvatar.ts index 3afd50745e277..dad1d1c2ada54 100644 --- a/packages/core-typings/src/IAvatar.ts +++ b/packages/core-typings/src/IAvatar.ts @@ -1,3 +1,3 @@ import type { IUpload } from './IUpload'; -export type IAvatar = IUpload; +export interface IAvatar extends IUpload {} diff --git a/packages/core-typings/src/IBaseData.ts b/packages/core-typings/src/IBaseData.ts deleted file mode 100644 index 16227f92a1e36..0000000000000 --- a/packages/core-typings/src/IBaseData.ts +++ /dev/null @@ -1,3 +0,0 @@ -export interface IBaseData { - _id: string; -} diff --git a/packages/core-typings/src/ILivechatMonitorRecord.ts b/packages/core-typings/src/ILivechatMonitorRecord.ts deleted file mode 100644 index 140d80f6662fb..0000000000000 --- a/packages/core-typings/src/ILivechatMonitorRecord.ts +++ /dev/null @@ -1,10 +0,0 @@ -import type { IRocketChatRecord } from './IRocketChatRecord'; - -export interface ILivechatMonitorRecord extends IRocketChatRecord { - _id: string; - name: string; - enabled: boolean; - numMonitors: number; - type: string; - visibility: string; -} diff --git a/packages/core-typings/src/ILivechatPriority.ts b/packages/core-typings/src/ILivechatPriority.ts index 06ee3b1ea6de4..348c822071dcb 100644 --- a/packages/core-typings/src/ILivechatPriority.ts +++ b/packages/core-typings/src/ILivechatPriority.ts @@ -17,5 +17,3 @@ export interface ILivechatPriority extends IRocketChatRecord { // Whether the priority has been modified by the user or not dirty: boolean; } - -export type ILivechatPriorityData = Omit; diff --git a/packages/core-typings/src/ILivechatTrigger.ts b/packages/core-typings/src/ILivechatTrigger.ts index 1c9eafbb9bd37..0d202e70e16a5 100644 --- a/packages/core-typings/src/ILivechatTrigger.ts +++ b/packages/core-typings/src/ILivechatTrigger.ts @@ -33,12 +33,6 @@ export const isExternalServiceTrigger = ( return trigger.actions.every((action) => action.name === 'use-external-service'); }; -export const isSendMessageTrigger = ( - trigger: ILivechatTrigger, -): trigger is ILivechatTrigger & { actions: ILivechatSendMessageAction[] } => { - return trigger.actions.every((action) => action.name === 'send-message'); -}; - export type ILivechatTriggerAction = ILivechatSendMessageAction | ILivechatUseExternalServiceAction; export interface ILivechatTrigger extends IRocketChatRecord { diff --git a/packages/core-typings/src/ILivechatVisitor.ts b/packages/core-typings/src/ILivechatVisitor.ts index 4b64137657fc0..9a033fee33e4d 100644 --- a/packages/core-typings/src/ILivechatVisitor.ts +++ b/packages/core-typings/src/ILivechatVisitor.ts @@ -10,21 +10,10 @@ export interface IVisitorLastChat { ts: Date; } -export interface ILivechatVisitorConnectionData { - httpHeaders: { - [k: string]: string; - }; - clientAddress: string; -} - export interface IVisitorEmail { address: string; } -interface ILivechatData { - [k: string]: unknown; -} - export interface ILivechatVisitor extends IRocketChatRecord { username: string; ts: Date; @@ -43,7 +32,7 @@ export interface ILivechatVisitor extends IRocketChatRecord { agentId: string; ts: Date; }; - livechatData?: ILivechatData; + livechatData?: Record; contactManager?: { _id?: string; username: string; diff --git a/packages/core-typings/src/ILogs.ts b/packages/core-typings/src/ILogItem.ts similarity index 57% rename from packages/core-typings/src/ILogs.ts rename to packages/core-typings/src/ILogItem.ts index 5cb802e8e9bff..1851d876b2bdf 100644 --- a/packages/core-typings/src/ILogs.ts +++ b/packages/core-typings/src/ILogItem.ts @@ -1,15 +1,13 @@ -export interface ILogEntry { - args: string[]; - caller: string; - severity: string; - timestamp: string; - method?: string; -} - export interface ILogItem { appId: string; endTime: string; - entries: ILogEntry[]; + entries: { + args: string[]; + caller: string; + severity: string; + timestamp: string; + method?: string; + }[]; instanceId: string; method: string; startTime: string; diff --git a/packages/core-typings/src/IMessage/IMessage.ts b/packages/core-typings/src/IMessage/IMessage.ts index f2c717f1505c1..9f61d6fad1b56 100644 --- a/packages/core-typings/src/IMessage/IMessage.ts +++ b/packages/core-typings/src/IMessage/IMessage.ts @@ -8,7 +8,7 @@ import type { ILivechatPriority } from '../ILivechatPriority'; import type { ILivechatVisitor } from '../ILivechatVisitor'; import type { IOmnichannelServiceLevelAgreements } from '../IOmnichannelServiceLevelAgreements'; import type { IRocketChatRecord } from '../IRocketChatRecord'; -import type { IRoom, RoomID } from '../IRoom'; +import type { IRoom } from '../IRoom'; import type { IUser } from '../IUser'; import type { FileProp } from './MessageAttachment/Files/FileProp'; import type { MessageAttachment } from './MessageAttachment/MessageAttachment'; @@ -116,8 +116,6 @@ export type MessageMention = { fname?: string; // incase of channel mentions }; -export interface IMessageCustomFields {} - interface IEncryptedContent { algorithm: string; ciphertext: string; @@ -143,7 +141,7 @@ interface IEncryptedContentFederation extends IEncryptedContent { export type EncryptedContent = IEncryptedContentV1 | IEncryptedContentV2 | IEncryptedContentFederation; export interface IMessage extends IRocketChatRecord { - rid: RoomID; + rid: IRoom['_id']; msg: string; tmid?: string; tshow?: boolean; @@ -170,7 +168,7 @@ export interface IMessage extends IRocketChatRecord { pinnedBy?: Pick; unread?: boolean; temp?: boolean; - drid?: RoomID; + drid?: IRoom['_id']; tlm?: Date; dcount?: number; @@ -236,7 +234,7 @@ export interface IMessage extends IRocketChatRecord { priority?: Pick; }; - customFields?: IMessageCustomFields; + customFields?: Record; content?: EncryptedContent; } @@ -262,7 +260,7 @@ export function isEncryptedMessageContent(value: unknown): value is EncryptedMes typeof value.content.kid === 'string')) ); } -export interface ISystemMessage extends IMessage { +interface ISystemMessage extends IMessage { t: MessageTypesValues; } @@ -285,25 +283,15 @@ export const isSystemMessage = (message: IMessage): message is ISystemMessage => export const isDeletedMessage = (message: IMessage): message is IEditedMessage => isEditedMessage(message) && message.t === 'rm'; -export interface IFederatedMessage extends IMessage { +interface IFederatedMessage extends IMessage { federation: { eventId: string; }; } -export interface INativeFederatedMessage extends IMessage { - federation: { - version: number; - eventId: string; - }; -} - export const isMessageFromMatrixFederation = (message: IMessage): message is IFederatedMessage => 'federation' in message && Boolean(message.federation?.eventId); -export const isMessageFromNativeFederation = (message: IMessage): message is INativeFederatedMessage => - isMessageFromMatrixFederation(message) && 'version' in message.federation; - export interface ITranslatedMessage extends IMessage { translations: { [key: string]: string } & { original?: string }; translationProvider: string; @@ -334,21 +322,6 @@ export interface IDiscussionMessage extends IMessage { export const isDiscussionMessage = (message: IMessage): message is IDiscussionMessage => !!message.drid; -export interface IPrivateMessage extends IMessage { - private: true; -} - -export const isPrivateMessage = (message: IMessage): message is IPrivateMessage => !!message.private; - -export interface IMessageReactionsNormalized extends IMessage { - reactions: { - [key: string]: { - usernames: Required[]; - names: Required['name'][]; - }; - }; -} - export interface IOmnichannelSystemMessage extends IMessage { navigation?: { page: { @@ -384,39 +357,31 @@ export interface IOmnichannelSystemMessage extends IMessage { comment?: string; } -export interface IMessageDiscussion extends IMessage { - drid: RoomID; -} - -export const isMessageDiscussion = (message: IMessage): message is IMessageDiscussion => { - return 'drid' in message; -}; - -export type IMessageInbox = IMessage & { +export interface IMessageInbox extends IMessage { // email inbox fields email?: { references?: string[]; messageId?: string; thread?: string[]; }; -}; +} export const isIMessageInbox = (message: IMessage): message is IMessageInbox => 'email' in message; -export type IE2EEMessage = IMessage & { +export interface IE2EEMessage extends IMessage { t: 'e2e'; e2e: 'pending' | 'done'; content: EncryptedContent; -}; +} -export type IE2EEPinnedMessage = IMessage & { +export interface IE2EEPinnedMessage extends IMessage { t: 'message_pinned_e2e'; attachments: [MessageAttachment & { content: EncryptedContent }]; -}; +} -export type IVideoConfMessage = IMessage & { +interface IVideoConfMessage extends IMessage { t: 'videoconf'; -}; +} export const isE2EEMessage = (message: IMessage): message is IE2EEMessage => message.t === 'e2e'; export const isE2EEPinnedMessage = (message: IMessage): message is IE2EEPinnedMessage => message.t === 'message_pinned_e2e'; @@ -436,7 +401,7 @@ export type IMessageWithPendingFileImport = IMessage & { }; }; -export interface IMessageFromVisitor extends IMessage { +interface IMessageFromVisitor extends IMessage { token: string; } diff --git a/packages/core-typings/src/IMessage/MessageAttachment/FieldProps.ts b/packages/core-typings/src/IMessage/MessageAttachment/FieldProps.ts deleted file mode 100644 index 2fc0bcce4ba7d..0000000000000 --- a/packages/core-typings/src/IMessage/MessageAttachment/FieldProps.ts +++ /dev/null @@ -1,5 +0,0 @@ -export type FieldProps = { - short?: boolean; - title: string; - value: string; -}; diff --git a/packages/core-typings/src/IMessage/MessageAttachment/Files/Dimensions.ts b/packages/core-typings/src/IMessage/MessageAttachment/Files/Dimensions.ts deleted file mode 100644 index 5bf8031e805e9..0000000000000 --- a/packages/core-typings/src/IMessage/MessageAttachment/Files/Dimensions.ts +++ /dev/null @@ -1,4 +0,0 @@ -export type Dimensions = { - width: number; - height: number; -}; diff --git a/packages/core-typings/src/IMessage/MessageAttachment/Files/ImageAttachmentProps.ts b/packages/core-typings/src/IMessage/MessageAttachment/Files/ImageAttachmentProps.ts index 28143d3027743..20d1d17390109 100644 --- a/packages/core-typings/src/IMessage/MessageAttachment/Files/ImageAttachmentProps.ts +++ b/packages/core-typings/src/IMessage/MessageAttachment/Files/ImageAttachmentProps.ts @@ -1,10 +1,12 @@ import type { MessageAttachmentBase } from '../MessageAttachmentBase'; -import type { Dimensions } from './Dimensions'; import type { FileAttachmentProps } from './FileAttachmentProps'; import type { FileProp } from './FileProp'; export type ImageAttachmentProps = { - image_dimensions?: Dimensions; + image_dimensions?: { + width: number; + height: number; + }; image_preview?: string; image_url: string; image_type?: string; diff --git a/packages/core-typings/src/IMessage/MessageAttachment/Files/PDFAttachmentProps.ts b/packages/core-typings/src/IMessage/MessageAttachment/Files/PDFAttachmentProps.ts deleted file mode 100644 index 01d1cc49580c6..0000000000000 --- a/packages/core-typings/src/IMessage/MessageAttachment/Files/PDFAttachmentProps.ts +++ /dev/null @@ -1,6 +0,0 @@ -import type { MessageAttachmentBase } from '../MessageAttachmentBase'; -import type { FileProp } from './FileProp'; - -export type PDFAttachmentProps = { - file: FileProp; -} & MessageAttachmentBase; diff --git a/packages/core-typings/src/IMessage/MessageAttachment/Files/index.ts b/packages/core-typings/src/IMessage/MessageAttachment/Files/index.ts index efc267781a29e..5d33ee5cdb9d1 100644 --- a/packages/core-typings/src/IMessage/MessageAttachment/Files/index.ts +++ b/packages/core-typings/src/IMessage/MessageAttachment/Files/index.ts @@ -1,7 +1,5 @@ export * from './AudioAttachmentProps'; -export * from './Dimensions'; export * from './FileAttachmentProps'; export * from './FileProp'; export * from './ImageAttachmentProps'; -export * from './PDFAttachmentProps'; export * from './VideoAttachmentProps'; diff --git a/packages/core-typings/src/IMessage/MessageAttachment/MessageAttachmentDefault.ts b/packages/core-typings/src/IMessage/MessageAttachment/MessageAttachmentDefault.ts index efcd7725102d5..576e92985ba96 100644 --- a/packages/core-typings/src/IMessage/MessageAttachment/MessageAttachmentDefault.ts +++ b/packages/core-typings/src/IMessage/MessageAttachment/MessageAttachmentDefault.ts @@ -1,7 +1,5 @@ import type { Root } from '@rocket.chat/message-parser'; -import type { FieldProps } from './FieldProps'; -import type { Dimensions } from './Files/Dimensions'; import type { MessageAttachmentBase } from './MessageAttachmentBase'; export type MarkdownFields = 'text' | 'pretext' | 'fields'; @@ -11,13 +9,20 @@ export type MessageAttachmentDefault = { author_link?: string; author_name?: string; - fields?: FieldProps[]; + fields?: { + short?: boolean; + title: string; + value: string; + }[]; // footer // footer_icon image_url?: string; - image_dimensions?: Dimensions; + image_dimensions?: { + width: number; + height: number; + }; mrkdwn_in?: Array; pretext?: string; diff --git a/packages/core-typings/src/IMessage/MessageAttachment/TranslatedMessageAttachment.ts b/packages/core-typings/src/IMessage/MessageAttachment/TranslatedMessageAttachment.ts index 711f565985460..bed65141b6075 100644 --- a/packages/core-typings/src/IMessage/MessageAttachment/TranslatedMessageAttachment.ts +++ b/packages/core-typings/src/IMessage/MessageAttachment/TranslatedMessageAttachment.ts @@ -1,7 +1,7 @@ import type { MessageAttachment } from './MessageAttachment'; import type { MessageAttachmentDefault } from './MessageAttachmentDefault'; -export interface ITranslatedMessageAttachment extends MessageAttachmentDefault { +interface ITranslatedMessageAttachment extends MessageAttachmentDefault { translations: { [language: string]: string }; } diff --git a/packages/core-typings/src/IMessage/MessageAttachment/index.ts b/packages/core-typings/src/IMessage/MessageAttachment/index.ts index 82f8613b5e294..5f852834efa70 100644 --- a/packages/core-typings/src/IMessage/MessageAttachment/index.ts +++ b/packages/core-typings/src/IMessage/MessageAttachment/index.ts @@ -1,5 +1,4 @@ export * from './Files'; -export * from './FieldProps'; export * from './MessageAttachment'; export * from './MessageAttachmentAction'; export * from './MessageAttachmentBase'; diff --git a/packages/core-typings/src/IModerationReport.ts b/packages/core-typings/src/IModerationReport.ts index 8b87fb1c77358..84063ef566436 100644 --- a/packages/core-typings/src/IModerationReport.ts +++ b/packages/core-typings/src/IModerationReport.ts @@ -3,18 +3,6 @@ import type { IRocketChatRecord } from './IRocketChatRecord'; import type { IRoom } from './IRoom'; import type { IUser } from './IUser'; -/** - * Right now we're assuming neither Room Info or User Info changes. - * There's no update method referencing reports as of now (6.3.0-develop). - * This means that a possible user or room change will not be reflected in the report. - */ -export interface IModerationInfo { - moderatedBy: IUser['_id']; - hiddenAt: Date; - action: string; - reason: string; -} - export interface IModerationReport extends IRocketChatRecord { message?: IMessage; room?: Pick; @@ -22,7 +10,17 @@ export interface IModerationReport extends IRocketChatRecord { description: string; ts: Date | string; reportedBy: Pick; - moderationInfo?: IModerationInfo; + /** + * Right now we're assuming neither Room Info or User Info changes. + * There's no update method referencing reports as of now (6.3.0-develop). + * This means that a possible user or room change will not be reflected in the report. + */ + moderationInfo?: { + moderatedBy: IUser['_id']; + hiddenAt: Date; + action: string; + reason: string; + }; _hidden?: boolean; } diff --git a/packages/core-typings/src/IOembed.ts b/packages/core-typings/src/IOembed.ts index f3eee39042602..a99097b734094 100644 --- a/packages/core-typings/src/IOembed.ts +++ b/packages/core-typings/src/IOembed.ts @@ -27,8 +27,6 @@ export type OEmbedUrlContentResult = { attachments?: MessageAttachment[]; }; -export const isOEmbedUrlContentResult = (value: any): value is OEmbedUrlContentResult => 'attachments' in value; - export type OEmbedUrlWithMetadata = { url: string; meta: OEmbedMeta; diff --git a/packages/core-typings/src/IReadReceipt.ts b/packages/core-typings/src/IReadReceipt.ts index e83029ffd0c56..1b4941cf1d238 100644 --- a/packages/core-typings/src/IReadReceipt.ts +++ b/packages/core-typings/src/IReadReceipt.ts @@ -2,7 +2,7 @@ import type { IMessage } from './IMessage/IMessage'; import type { IRoom } from './IRoom'; import type { IUser } from './IUser'; -export type IReadReceipt = { +export interface IReadReceipt { token?: string; messageId: IMessage['_id']; roomId: IRoom['_id']; @@ -13,8 +13,8 @@ export type IReadReceipt = { tmid?: IMessage['tmid']; userId: IUser['_id']; _id: string; -}; +} -export type IReadReceiptWithUser = IReadReceipt & { +export interface IReadReceiptWithUser extends IReadReceipt { user?: Pick | undefined; -}; +} diff --git a/packages/core-typings/src/IRocketChatAssets.ts b/packages/core-typings/src/IRocketChatAssets.ts index a7cdc76b29466..92d8fc80a92cd 100644 --- a/packages/core-typings/src/IRocketChatAssets.ts +++ b/packages/core-typings/src/IRocketChatAssets.ts @@ -5,11 +5,6 @@ export interface IRocketChatAssetConstraint { height?: number; } -export interface IRocketChatAssetWizard { - step: number; - order: number; -} - export interface IRocketChatAssetCache { path: string; cacheable: boolean; @@ -30,7 +25,10 @@ export interface IRocketChatAsset { constraints: IRocketChatAssetConstraint; defaultUrl?: string; url?: string; - wizard?: IRocketChatAssetWizard; + wizard?: { + step: number; + order: number; + }; cache?: IRocketChatAssetCache; } diff --git a/packages/core-typings/src/IRoom.ts b/packages/core-typings/src/IRoom.ts index 1b9e95f662253..fb243a8f92e52 100644 --- a/packages/core-typings/src/IRoom.ts +++ b/packages/core-typings/src/IRoom.ts @@ -5,20 +5,11 @@ import type { ILivechatVisitor } from './ILivechatVisitor'; import type { IMessage, MessageTypesValues } from './IMessage'; import type { IOmnichannelServiceLevelAgreements } from './IOmnichannelServiceLevelAgreements'; import type { IRocketChatRecord } from './IRocketChatRecord'; -import type { IUser, Username } from './IUser'; +import type { IUser } from './IUser'; import type { RoomType } from './RoomType'; - -export type RoomID = string; -export type ChannelName = string; -interface IRequestTranscript { - email: string; // the email address to send the transcript to - subject: string; // the subject of the email - requestedAt: Date; - requestedBy: Pick; -} +import type { Branded } from './utils'; export interface IRoom extends IRocketChatRecord { - _id: RoomID; t: RoomType; name?: string; fname?: string; @@ -101,10 +92,6 @@ export interface IRoomWithJoinCode extends IRoom { joinCode: string; } -declare const __brand: unique symbol; -type Brand = { [__brand]: B }; -export type Branded = T & Brand; - export interface IRoomFederated extends IRoom { _id: Branded; federated: true; @@ -148,7 +135,7 @@ export const isPrivateRoom = (room: Partial): room is IRoom => room.t === export interface IDirectMessageRoom extends Omit { t: 'd'; uids: Array; - usernames: Array; + usernames: Array>; } export const isDirectMessageRoom = (room: Partial | IDirectMessageRoom): room is IDirectMessageRoom => room.t === 'd'; @@ -208,7 +195,12 @@ export interface IOmnichannelGenericRoom extends Omit; + }; servedBy?: { _id: string; @@ -319,10 +311,6 @@ export interface IOmnichannelRoom extends IOmnichannelGenericRoom { verified?: boolean; } -export interface IOmnichannelRoomFromAppSource extends IOmnichannelRoom { - source: IOmnichannelSourceFromApp; -} - export type IOmnichannelRoomClosingInfo = Pick & { serviceTimeDuration?: number; chatDuration: number; diff --git a/packages/core-typings/src/IServerEvent.ts b/packages/core-typings/src/IServerEvent.ts index 4bf19d1236193..4be4e0f74a3e3 100644 --- a/packages/core-typings/src/IServerEvent.ts +++ b/packages/core-typings/src/IServerEvent.ts @@ -1,4 +1,13 @@ import type { IUser } from './IUser'; +import type { + IServerEventAbacActionPerformed, + IServerEventAbacAttributeChanged, + IServerEventAbacObjectAttributeChanged, + IServerEventAbacObjectAttributesRemoved, + IServerEventAbacSubjectAttributeChanged, +} from './ServerAudit/IAuditServerAbacAction'; +import type { IServerEventSettingsChanged } from './ServerAudit/IAuditServerSettingEvent'; +import type { IServerEventUserChanged } from './ServerAudit/IAuditUserChangedEvent'; export enum ServerEventType { FAILED_LOGIN_ATTEMPT = 'failed-login-attempt', @@ -57,7 +66,15 @@ export interface IAuditServerEventType ex data: E[]; } -export interface IServerEvents {} +export interface IServerEvents { + 'abac.subject.attribute.changed': IServerEventAbacSubjectAttributeChanged; + 'abac.object.attribute.changed': IServerEventAbacObjectAttributeChanged; + 'abac.attribute.changed': IServerEventAbacAttributeChanged; + 'abac.action.performed': IServerEventAbacActionPerformed; + 'abac.object.attributes.removed': IServerEventAbacObjectAttributesRemoved; + 'settings.changed': IServerEventSettingsChanged; + 'user.changed': IServerEventUserChanged; +} type KeyValuePair = { key: string; value: any }; diff --git a/packages/core-typings/src/ISession.ts b/packages/core-typings/src/ISession.ts index 009850d750e44..19dfe0432f2f7 100644 --- a/packages/core-typings/src/ISession.ts +++ b/packages/core-typings/src/ISession.ts @@ -11,6 +11,7 @@ export interface ISessionDevice { }; version: string; } + export interface ISession { _id: string; type: 'session' | 'computed-session' | 'user_daily'; @@ -45,9 +46,11 @@ type SessionAggregationResult = { export type UserSessionAggregationResult = SessionAggregationResult & { data: UserSessionAggregation[]; }; + export type DeviceSessionAggregationResult = SessionAggregationResult & { data: DeviceSessionAggregation[]; }; + export type OSSessionAggregationResult = SessionAggregationResult & { data: OSSessionAggregation[]; }; @@ -57,6 +60,7 @@ export type UserSessionAggregation = Pick & { sessions: number; roles: { role: string; count: number; sessions: number; time: number }[]; }; + export type DeviceSessionAggregation = Pick & { type: string; name: string; @@ -64,6 +68,7 @@ export type DeviceSessionAggregation = Pick & { count: number; time: number; }; + export type OSSessionAggregation = Pick & { name: string; version: string; @@ -72,6 +77,7 @@ export type OSSessionAggregation = Pick & { }; export type DeviceManagementSession = Pick; + export type DeviceManagementPopulatedSession = DeviceManagementSession & { _user: Pick; }; diff --git a/packages/core-typings/src/ISetting.ts b/packages/core-typings/src/ISetting.ts index f4fe0a81e87dd..fbc1b031bce66 100644 --- a/packages/core-typings/src/ISetting.ts +++ b/packages/core-typings/src/ISetting.ts @@ -105,7 +105,7 @@ export interface ISettingGroup { alert?: string; // todo: check if this is needed } -export interface ISettingEnterprise extends ISettingBase { +interface ISettingEnterprise extends ISettingBase { enterprise: true; invalidValue: SettingValue; } @@ -115,12 +115,13 @@ export interface ISettingColor extends ISettingBase { editor: SettingEditor; packageEditor?: SettingEditor; } -export interface ISettingCode extends ISettingBase { + +interface ISettingCode extends ISettingBase { type: 'code'; code?: string; } -export interface ISettingAction extends ISettingBase { +interface ISettingAction extends ISettingBase { type: 'action'; value: string; actionText?: string; @@ -133,12 +134,7 @@ export interface ISettingAsset extends ISettingBase { asset: string; } -export interface ISettingDate extends ISettingBase { - type: 'date'; - value: Date; -} - -export interface ISettingRange extends ISettingBase { +interface ISettingRange extends ISettingBase { type: 'range'; minValue: number; maxValue: number; @@ -155,8 +151,6 @@ export const isSetting = (setting: any): setting is ISetting => 'sorter' in setting && 'i18nLabel' in setting; -export const isDateSetting = (setting: ISetting): setting is ISettingDate => setting.type === 'date'; - export const isSettingEnterprise = (setting: ISettingBase): setting is ISettingEnterprise => setting.enterprise === true; export const isSettingColor = (setting: ISettingBase): setting is ISettingColor => setting.type === 'color'; @@ -165,8 +159,6 @@ export const isSettingCode = (setting: ISettingBase): setting is ISettingCode => export const isSettingAction = (setting: ISettingBase): setting is ISettingAction => setting.type === 'action'; -export const isSettingAsset = (setting: ISettingBase): setting is ISettingAsset => setting.type === 'asset'; - export const isSettingRange = (setting: ISettingBase): setting is ISettingRange => setting.type === 'range'; export interface ISettingStatistics { diff --git a/packages/core-typings/src/IStats.ts b/packages/core-typings/src/IStats.ts index c80bbf433cfac..5fb30bdd7cc3b 100644 --- a/packages/core-typings/src/IStats.ts +++ b/packages/core-typings/src/IStats.ts @@ -6,7 +6,7 @@ import type { ISettingStatisticsObject } from './ISetting'; import type { ITeamStats } from './ITeam'; import type { MACStats } from './omnichannel'; -export interface IVoIPPeriodStats { +interface IVoIPPeriodStats { calls?: number; externalInboundCalls?: number; externalOutboundCalls?: number; diff --git a/packages/core-typings/src/ISubscription.ts b/packages/core-typings/src/ISubscription.ts index 23e84326dd16d..65751dd46638b 100644 --- a/packages/core-typings/src/ISubscription.ts +++ b/packages/core-typings/src/ISubscription.ts @@ -1,17 +1,17 @@ import type { IRocketChatRecord } from './IRocketChatRecord'; import type { IRole } from './IRole'; +import type { IRoom } from './IRoom'; import type { IUser } from './IUser'; import type { RoomType } from './RoomType'; -type RoomID = string; - -export type OldKey = { e2eKeyId: string; ts: Date; E2EKey: string }; +type OldKey = { e2eKeyId: string; ts: Date; E2EKey: string }; export type SubscriptionStatus = 'INVITED'; + export interface ISubscription extends IRocketChatRecord { u: Pick; v?: Pick & { token?: string }; - rid: RoomID; + rid: IRoom['_id']; open: boolean; ts: Date; @@ -36,7 +36,7 @@ export interface ISubscription extends IRocketChatRecord { tunreadGroup?: Array; tunreadUser?: Array; - prid?: RoomID; + prid?: IRoom['_id']; roles?: IRole['_id'][]; @@ -85,14 +85,6 @@ export interface IInviteSubscription extends ISubscription { inviter: NonNullable; } -export interface IOmnichannelSubscription extends ISubscription { - department?: string; // TODO REMOVE/DEPRECATE no need keeo in both room and subscription -} - -export interface ISubscriptionDirectMessage extends Omit { - t: 'd'; -} - export const isInviteSubscription = (subscription: ISubscription): subscription is IInviteSubscription => { return subscription?.status === 'INVITED' && !!subscription.inviter; }; diff --git a/packages/core-typings/src/ITeam.ts b/packages/core-typings/src/ITeam.ts index a17d5ae786618..fda3f488edf79 100644 --- a/packages/core-typings/src/ITeam.ts +++ b/packages/core-typings/src/ITeam.ts @@ -4,7 +4,7 @@ import type { IRocketChatRecord } from './IRocketChatRecord'; import type { IRole } from './IRole'; import type { IUser } from './IUser'; -export enum TEAM_TYPE { +export enum TeamType { PUBLIC = 0, PRIVATE = 1, } @@ -13,7 +13,7 @@ export type SortType = -1 | 1; export interface ITeam extends IRocketChatRecord { name: string; - type: TEAM_TYPE; + type: TeamType; roomId: string; createdBy: Pick; createdAt: Date; diff --git a/packages/core-typings/src/IUser.ts b/packages/core-typings/src/IUser.ts index e41ab7c53ccee..a018ed386b1dc 100644 --- a/packages/core-typings/src/IUser.ts +++ b/packages/core-typings/src/IUser.ts @@ -1,8 +1,8 @@ import type { IAbacAttributeDefinition } from './IAbacAttribute'; import type { IRocketChatRecord } from './IRocketChatRecord'; import type { IRole } from './IRole'; -import type { Serialized } from './Serialized'; import type { UserStatus } from './UserStatus'; +import type { Serialized } from './utils'; export interface ILoginToken { hashedToken: string; @@ -22,34 +22,21 @@ export interface IPersonalAccessToken extends ILoginToken { bypassTwoFactor?: boolean; } +type LoginToken = IMeteorLoginToken | IPersonalAccessToken; + export const isPersonalAccessToken = (token: LoginToken): token is IPersonalAccessToken => 'type' in token && token.type === 'personalAccessToken'; -export interface IUserEmailVerificationToken { - token: string; - address: string; - when: Date; -} - -export interface IUserEmailCode { - code: string; - expire: Date; - attempts: number; -} - -type LoginToken = IMeteorLoginToken | IPersonalAccessToken; -export type Username = string; - -export type ILoginUsername = +export type LoginUsername = + | string | { username: string; } | { email: string; }; -export type LoginUsername = string | ILoginUsername; -export interface IOAuthUserServices { +interface IOAuthUserServices { google?: any; facebook?: any; github?: any; @@ -77,14 +64,18 @@ export interface IOAuthUserServices { }; } -export interface IUserServices extends IOAuthUserServices { +interface IUserServices extends IOAuthUserServices { password?: { exists?: boolean; bcrypt?: string; }; passwordHistory?: string[]; email?: { - verificationTokens?: IUserEmailVerificationToken[]; + verificationTokens?: { + token: string; + address: string; + when: Date; + }[]; }; resume?: { loginTokens?: LoginToken[]; @@ -104,7 +95,11 @@ export interface IUserServices extends IOAuthUserServices { enabled: boolean; changedAt: Date; }; - emailCode?: IUserEmailCode; + emailCode?: { + code: string; + expire: Date; + attempts: number; + }; /** * iframe is used for iframe login @@ -127,7 +122,7 @@ export interface IUserServices extends IOAuthUserServices { type IUserService = keyof IUserServices; type IOAuthService = keyof IOAuthUserServices; -const defaultOAuthKeys = [ +const defaultOAuthKeys: IOAuthService[] = [ 'google', 'dolphin', 'facebook', @@ -139,17 +134,16 @@ const defaultOAuthKeys = [ 'nextcloud', 'saml', 'twitter', -] as IOAuthService[]; -const userServiceKeys = ['emailCode', 'email2fa', 'totp', 'resume', 'password', 'passwordHistory', 'cloud', 'email'] as IUserService[]; +]; +const userServiceKeys: IUserService[] = ['emailCode', 'email2fa', 'totp', 'resume', 'password', 'passwordHistory', 'cloud', 'email']; -export const isUserServiceKey = (key: string): key is IUserService => +const isUserServiceKey = (key: string): key is IUserService => userServiceKeys.includes(key as IUserService) || defaultOAuthKeys.includes(key as IOAuthService); -export const isDefaultOAuthUser = (user: IUser): boolean => +const isDefaultOAuthUser = (user: IUser): boolean => !!user.services && Object.keys(user.services).some((key) => defaultOAuthKeys.includes(key as IOAuthService)); -export const isCustomOAuthUser = (user: IUser): boolean => - !!user.services && Object.keys(user.services).some((key) => !isUserServiceKey(key)); +const isCustomOAuthUser = (user: IUser): boolean => !!user.services && Object.keys(user.services).some((key) => !isUserServiceKey(key)); export const isOAuthUser = (user: IUser): boolean => isDefaultOAuthUser(user) || isCustomOAuthUser(user); @@ -158,14 +152,12 @@ export interface IUserEmail { verified?: boolean; } -export interface IOutlook { - Enabled: boolean; - Exchange_Url: string; - Outlook_Url: string; -} - export interface IUserCalendar { - outlook?: IOutlook; + outlook?: { + Enabled: boolean; + Exchange_Url: string; + Outlook_Url: string; + }; } export interface IUserSettings { @@ -174,18 +166,7 @@ export interface IUserSettings { calendar?: IUserCalendar; } -export interface IGetRoomRoles { - _id: string; - rid: string; - u: { - _id: string; - username: string; - }; - roles: string[]; -} - export interface IUser extends IRocketChatRecord { - _id: string; createdAt: Date; roles: IRole['_id'][]; type: string; @@ -266,7 +247,7 @@ export const isRegisterUser = (user: IUser): user is IRegisterUser => user.usern export const isUserFederated = (user: Partial | Partial>) => 'federated' in user && user.federated === true; -export interface IUserNativeFederated extends IUser { +interface IUserNativeFederated extends IUser { federated: true; username: `@${string}:${string}`; federation: { diff --git a/packages/core-typings/src/IUserAction.ts b/packages/core-typings/src/IUserAction.ts deleted file mode 100644 index 80a726c8678b7..0000000000000 --- a/packages/core-typings/src/IUserAction.ts +++ /dev/null @@ -1,13 +0,0 @@ -export type IUserAction = { - _id: string; - username?: string; - name?: string; -}; - -export type IExtras = { - tmid?: string; -}; - -export type IActivity = Record; - -export type IRoomActivity = Record; diff --git a/packages/core-typings/src/IUserDataFile.ts b/packages/core-typings/src/IUserDataFile.ts index aea5cf62d4c9a..e2583695b093a 100644 --- a/packages/core-typings/src/IUserDataFile.ts +++ b/packages/core-typings/src/IUserDataFile.ts @@ -1,3 +1,3 @@ import type { IUpload } from './IUpload'; -export type IUserDataFile = IUpload; +export interface IUserDataFile extends IUpload {} diff --git a/packages/core-typings/src/IVideoConference.ts b/packages/core-typings/src/IVideoConference.ts index 0d9936c8dfbaf..834d7196a65c6 100644 --- a/packages/core-typings/src/IVideoConference.ts +++ b/packages/core-typings/src/IVideoConference.ts @@ -94,9 +94,7 @@ export interface ILivechatVideoConference extends IVideoConference { type: 'livechat'; } -export interface IVoIPVideoConferenceData {} - -export type IVoIPVideoConference = IVideoConference & { +export interface IVoIPVideoConference extends IVideoConference { type: 'voip'; externalId: string; @@ -113,11 +111,11 @@ export type IVoIPVideoConference = IVideoConference & { bridge?: boolean; answer?: boolean; }; -}; +} export type ExternalVideoConference = IDirectVideoConference | IGroupVideoConference | ILivechatVideoConference; -export type InternalVideoConference = IVoIPVideoConference; +type InternalVideoConference = IVoIPVideoConference; export type VideoConference = ExternalVideoConference | InternalVideoConference; @@ -135,10 +133,6 @@ export const isLivechatVideoConference = (call: VideoConference | undefined | nu return call?.type === 'livechat'; }; -export const isVoIPVideoConference = (call: VideoConference | undefined | null): call is IVoIPVideoConference => { - return call?.type === 'voip'; -}; - type GroupVideoConferenceCreateData = Omit & { createdBy: IUser['_id'] }; type DirectVideoConferenceCreateData = Omit & { createdBy: IUser['_id'] }; type LivechatVideoConferenceCreateData = Omit & { createdBy: IUser['_id'] }; diff --git a/packages/core-typings/src/IWebdavAccount.ts b/packages/core-typings/src/IWebdavAccount.ts index 53059382fb50a..397db412a067c 100644 --- a/packages/core-typings/src/IWebdavAccount.ts +++ b/packages/core-typings/src/IWebdavAccount.ts @@ -12,7 +12,7 @@ export type IWebdavAccountIntegration = Pick & Partial>; -export type IWebdavNode = { +export interface IWebdavNode { basename: string; etag: string | null; filename: string; @@ -20,4 +20,4 @@ export type IWebdavNode = { mime?: string; size: number; type: 'file' | 'directory'; -}; +} diff --git a/packages/core-typings/src/IWorkspaceInfo.ts b/packages/core-typings/src/IWorkspaceInfo.ts index 1282c8bb9277b..c918e2126d08f 100644 --- a/packages/core-typings/src/IWorkspaceInfo.ts +++ b/packages/core-typings/src/IWorkspaceInfo.ts @@ -1,9 +1,9 @@ import type { IServerInfo } from './IServerInfo'; -export type IWorkspaceInfo = { +export interface IWorkspaceInfo { info?: IServerInfo; supportedVersions?: { signed: string }; minimumClientVersions: { desktop: string; mobile: string }; version: string; cloudWorkspaceId?: string; -}; +} diff --git a/packages/core-typings/src/MarketplaceRest.ts b/packages/core-typings/src/MarketplaceRest.ts deleted file mode 100644 index f25698912e82f..0000000000000 --- a/packages/core-typings/src/MarketplaceRest.ts +++ /dev/null @@ -1,17 +0,0 @@ -export type PaginationMeta = { - total: number; - limit: number; - offset: number; - sort: string; - filter: string; -}; - -export type Pagination = { - offset: number; - limit: number; -}; - -export interface IRestResponse { - data: T[]; - meta: PaginationMeta; -} diff --git a/packages/core-typings/src/ICustomOAuthConfig.ts b/packages/core-typings/src/OauthConfig.ts similarity index 100% rename from packages/core-typings/src/ICustomOAuthConfig.ts rename to packages/core-typings/src/OauthConfig.ts diff --git a/packages/core-typings/src/IOmnichannel.ts b/packages/core-typings/src/OmnichannelSortingMechanismSettingType.ts similarity index 51% rename from packages/core-typings/src/IOmnichannel.ts rename to packages/core-typings/src/OmnichannelSortingMechanismSettingType.ts index 57f4b772daaf1..7eb7913f03694 100644 --- a/packages/core-typings/src/IOmnichannel.ts +++ b/packages/core-typings/src/OmnichannelSortingMechanismSettingType.ts @@ -1,10 +1,3 @@ -export interface IOmnichannelQueueStatus { - _id: string; - startedAt: Date; - stoppedAt?: Date; - locked: boolean; -} - export enum OmnichannelSortingMechanismSettingType { Timestamp = 'Timestamp', Priority = 'Priority', diff --git a/packages/core-typings/src/Serialized.ts b/packages/core-typings/src/Serialized.ts deleted file mode 100644 index 9c5408d88b955..0000000000000 --- a/packages/core-typings/src/Serialized.ts +++ /dev/null @@ -1,27 +0,0 @@ -/* eslint-disable @typescript-eslint/ban-types */ - -type SerializablePrimitive = boolean | number | string | null; - -type UnserializablePrimitive = Function | bigint | symbol | undefined; - -type CustomSerializable = { - toJSON(key: string): T; -}; - -/** - * The type of a value that was serialized via `JSON.stringify` and then deserialized via `JSON.parse`. - */ -export type Serialized = - T extends CustomSerializable - ? Serialized - : T extends [any, ...any] // is T a tuple? - ? { [K in keyof T]: T extends UnserializablePrimitive ? null : Serialized } - : T extends any[] - ? Serialized[] - : T extends object - ? { [K in keyof T]: Serialized } - : T extends SerializablePrimitive - ? T - : T extends UnserializablePrimitive - ? undefined - : null; diff --git a/packages/core-typings/src/ServerAudit/IAuditServerAbacAction.ts b/packages/core-typings/src/ServerAudit/IAuditServerAbacAction.ts index d7f5bb8e02ecc..720e1c4d53c38 100644 --- a/packages/core-typings/src/ServerAudit/IAuditServerAbacAction.ts +++ b/packages/core-typings/src/ServerAudit/IAuditServerAbacAction.ts @@ -18,21 +18,15 @@ export type AbacAttributeDefinitionChangeType = | 'key-added' | 'key-updated'; -export type AbacAttributeDefinitionDiff = { - added?: string[]; - removed?: string[]; - renamedFrom?: string; -}; - // Since user attributes can grow without limits, we're only logging the diffs -interface IServerEventAbacSubjectAttributeChanged +export interface IServerEventAbacSubjectAttributeChanged extends IAuditServerEventType< { key: 'subject'; value: MinimalUser } | { key: 'reason'; value: AbacAuditReason } | { key: 'diff'; value: IAbacAttributeDefinition[] } > { t: 'abac.subject.attribute.changed'; } -interface IServerEventAbacObjectAttributeChanged +export interface IServerEventAbacObjectAttributeChanged extends IAuditServerEventType< | { key: 'room'; value: MinimalRoom } | { key: 'reason'; value: AbacAuditReason } @@ -43,7 +37,7 @@ interface IServerEventAbacObjectAttributeChanged t: 'abac.object.attribute.changed'; } -interface IServerEventAbacAttributeChanged +export interface IServerEventAbacAttributeChanged extends IAuditServerEventType< | { key: 'attributeKey'; value: string } | { key: 'reason'; value: AbacAuditReason } @@ -54,7 +48,7 @@ interface IServerEventAbacAttributeChanged t: 'abac.attribute.changed'; } -interface IServerEventAbacActionPerformed +export interface IServerEventAbacActionPerformed extends IAuditServerEventType< | { key: 'action'; value: AbacActionPerformed } | { key: 'reason'; value: AbacAuditReason } @@ -64,7 +58,7 @@ interface IServerEventAbacActionPerformed t: 'abac.action.performed'; } -interface IServerEventAbacObjectAttributesRemoved +export interface IServerEventAbacObjectAttributesRemoved extends IAuditServerEventType< | { key: 'room'; value: MinimalRoom } | { key: 'reason'; value: AbacAuditReason } @@ -74,15 +68,6 @@ interface IServerEventAbacObjectAttributesRemoved > { t: 'abac.object.attributes.removed'; } -declare module '../IServerEvent' { - interface IServerEvents { - 'abac.subject.attribute.changed': IServerEventAbacSubjectAttributeChanged; - 'abac.object.attribute.changed': IServerEventAbacObjectAttributeChanged; - 'abac.attribute.changed': IServerEventAbacAttributeChanged; - 'abac.action.performed': IServerEventAbacActionPerformed; - 'abac.object.attributes.removed': IServerEventAbacObjectAttributesRemoved; - } -} // Utility type to extract all ABAC-related server event names // (ensures that only events prefixed with "abac." are included) diff --git a/packages/core-typings/src/ServerAudit/IAuditServerSettingEvent.ts b/packages/core-typings/src/ServerAudit/IAuditServerSettingEvent.ts index a49c4ae5f9be3..a78663781329d 100644 --- a/packages/core-typings/src/ServerAudit/IAuditServerSettingEvent.ts +++ b/packages/core-typings/src/ServerAudit/IAuditServerSettingEvent.ts @@ -1,7 +1,7 @@ import type { IAuditServerEventType } from '../IServerEvent'; import type { ISetting } from '../ISetting'; -interface IServerEventSettingsChanged +export interface IServerEventSettingsChanged extends IAuditServerEventType< | { key: 'id'; @@ -18,9 +18,3 @@ interface IServerEventSettingsChanged > { t: 'settings.changed'; } - -declare module '../IServerEvent' { - interface IServerEvents { - 'settings.changed': IServerEventSettingsChanged; - } -} diff --git a/packages/core-typings/src/ServerAudit/IAuditUserChangedEvent.ts b/packages/core-typings/src/ServerAudit/IAuditUserChangedEvent.ts index 4218dcbb7c311..d079c1d64d2a7 100644 --- a/packages/core-typings/src/ServerAudit/IAuditUserChangedEvent.ts +++ b/packages/core-typings/src/ServerAudit/IAuditUserChangedEvent.ts @@ -4,11 +4,7 @@ import type { IAuditServerEventType } from '../IServerEvent'; import type { IUser } from '../IUser'; import type { DeepPartial } from '../utils'; -export type IServerEventAuditedUser = IUser & { - password: string; -}; - -interface IServerEventUserChanged +export interface IServerEventUserChanged extends IAuditServerEventType< | { key: 'user'; @@ -28,9 +24,3 @@ interface IServerEventUserChanged > { t: 'user.changed'; } - -declare module '../IServerEvent' { - interface IServerEvents { - 'user.changed': IServerEventUserChanged; - } -} diff --git a/packages/core-typings/src/SpotlightUser.ts b/packages/core-typings/src/SpotlightUser.ts index 4d6358315c785..8b24dee03d782 100644 --- a/packages/core-typings/src/SpotlightUser.ts +++ b/packages/core-typings/src/SpotlightUser.ts @@ -2,7 +2,7 @@ import type { IUser } from './IUser'; export type SpotlightUser = { _id: IUser['_id']; - username: Required['username']; + username: NonNullable; nickname: IUser['nickname']; name: IUser['name']; status: IUser['status']; diff --git a/packages/core-typings/src/Subscribable.ts b/packages/core-typings/src/Subscribable.ts deleted file mode 100644 index b34ea70759410..0000000000000 --- a/packages/core-typings/src/Subscribable.ts +++ /dev/null @@ -1,4 +0,0 @@ -export type Subscribable = { - get(): T; - subscribe(callback: () => void): () => void; -}; diff --git a/packages/core-typings/src/VideoConferenceOptions.ts b/packages/core-typings/src/VideoConferenceOptions.ts deleted file mode 100644 index 4ed1a415e2a10..0000000000000 --- a/packages/core-typings/src/VideoConferenceOptions.ts +++ /dev/null @@ -1,4 +0,0 @@ -export type VideoConferenceOptions = { - mic?: boolean; - cam?: boolean; -}; diff --git a/packages/core-typings/src/IAutoTranslate.ts b/packages/core-typings/src/autoTranslate.ts similarity index 54% rename from packages/core-typings/src/IAutoTranslate.ts rename to packages/core-typings/src/autoTranslate.ts index a3eb0d703509a..eeaee565cb90a 100644 --- a/packages/core-typings/src/IAutoTranslate.ts +++ b/packages/core-typings/src/autoTranslate.ts @@ -6,22 +6,11 @@ export interface IProviderMetadata { apiEndPointUrl: string; }; } -export interface IDeepLTranslation { - detected_source_language: string; - text: string; -} - -export interface IGoogleTranslation { - translatedText: string; -} export interface ISupportedLanguage { language: string; name: string; } -export interface ISupportedLanguages { - [language: string]: ISupportedLanguage[]; -} export interface ITranslationResult { [language: string]: string; diff --git a/packages/core-typings/src/cloud/Announcement.ts b/packages/core-typings/src/cloud/Announcement.ts deleted file mode 100644 index 8542af634a857..0000000000000 --- a/packages/core-typings/src/cloud/Announcement.ts +++ /dev/null @@ -1,8 +0,0 @@ -/* eslint-disable @typescript-eslint/naming-convention */ -import type { IBanner } from '../IBanner'; - -export interface Announcement extends IBanner { - selector?: { - roles?: string[]; - }; -} diff --git a/packages/core-typings/src/cloud/NpsSurveyAnnouncement.ts b/packages/core-typings/src/cloud/NpsSurveyAnnouncement.ts deleted file mode 100644 index fff1db8f1b998..0000000000000 --- a/packages/core-typings/src/cloud/NpsSurveyAnnouncement.ts +++ /dev/null @@ -1,7 +0,0 @@ -/* eslint-disable @typescript-eslint/naming-convention */ - -export interface NpsSurveyAnnouncement { - id: string; - startAt: Date; - expireAt: Date; -} diff --git a/packages/core-typings/src/cloud/WorkspaceSyncPayload.ts b/packages/core-typings/src/cloud/WorkspaceSyncPayload.ts index e8821e93ac13b..7f510c801066f 100644 --- a/packages/core-typings/src/cloud/WorkspaceSyncPayload.ts +++ b/packages/core-typings/src/cloud/WorkspaceSyncPayload.ts @@ -3,8 +3,12 @@ import type * as UiKit from '@rocket.chat/ui-kit'; import type { IBanner } from '../IBanner'; -import type { Announcement } from './Announcement'; -import type { NpsSurveyAnnouncement } from './NpsSurveyAnnouncement'; + +interface NpsSurveyAnnouncement { + id: string; + startAt: Date; + expireAt: Date; +} export interface WorkspaceSyncPayload { workspaceId: string; @@ -52,18 +56,17 @@ export interface WorkspaceSyncResponse { cloudSyncAnnouncement: unknown; } -export interface WorkspaceCommsRequestPayload { - npsEnabled: boolean; - deploymentMethod: string; - deploymentPlatform: string; - version: string; +export interface IAnnouncement extends IBanner { + selector?: { + roles?: string[]; + }; } export interface WorkspaceCommsResponsePayload { nps?: NpsSurveyAnnouncement | null; // Potentially consolidate into announcements announcements?: { - create: Announcement[]; - delete: Announcement['_id'][]; + create: IAnnouncement[]; + delete: IAnnouncement['_id'][]; }; } diff --git a/packages/core-typings/src/cloud/index.ts b/packages/core-typings/src/cloud/index.ts index 63efbd0bcf180..b57b620a8751d 100644 --- a/packages/core-typings/src/cloud/index.ts +++ b/packages/core-typings/src/cloud/index.ts @@ -1,11 +1,9 @@ -export { Announcement } from './Announcement'; -export { NpsSurveyAnnouncement } from './NpsSurveyAnnouncement'; export { WorkspaceLicensePayload } from './WorkspaceLicensePayload'; export { + IAnnouncement, WorkspaceSyncPayload, WorkspaceSyncRequestPayload, WorkspaceSyncResponse, - WorkspaceCommsRequestPayload, WorkspaceCommsResponsePayload, WorkspaceInteractionResponsePayload, } from './WorkspaceSyncPayload'; diff --git a/packages/core-typings/src/federation/v1/events.ts b/packages/core-typings/src/federation/v1/events.ts index f13f947348f0a..fcd81a718fba4 100644 --- a/packages/core-typings/src/federation/v1/events.ts +++ b/packages/core-typings/src/federation/v1/events.ts @@ -15,4 +15,4 @@ export const eventTypes = { ROOM_UNSET_MESSAGE_REACTION: 'room_unset_message_reaction', ROOM_MUTE_USER: 'room_mute_user', ROOM_UNMUTE_USER: 'room_unmute_user', -}; +} as const; diff --git a/packages/core-typings/src/import/IImportFileData.ts b/packages/core-typings/src/import/IImportFileData.ts deleted file mode 100644 index c3347a1b4052a..0000000000000 --- a/packages/core-typings/src/import/IImportFileData.ts +++ /dev/null @@ -1,8 +0,0 @@ -import type { IImportChannel } from './IImportChannel'; -import type { IImportUser } from './IImportUser'; - -export interface IImportFileData { - users: Array; - channels: Array; - message_count: number; -} diff --git a/packages/core-typings/src/import/IImportMessage.ts b/packages/core-typings/src/import/IImportMessage.ts index 8892b484f3e5b..59dd231557096 100644 --- a/packages/core-typings/src/import/IImportMessage.ts +++ b/packages/core-typings/src/import/IImportMessage.ts @@ -1,8 +1,6 @@ -export type IImportedId = string; - export interface IImportMessageReaction { name: string; - users: Array; + users: Array; } export interface IImportPendingFile { @@ -15,18 +13,18 @@ export interface IImportPendingFile { original: Record; } -export interface IImportAttachment extends Record { +interface IImportAttachment extends Record { text?: string; title?: string; fallback?: string; } export interface IImportMessage { - _id?: IImportedId; + _id?: string; - rid: IImportedId; + rid: string; u: { - _id: IImportedId; + _id: string; }; msg: string; @@ -36,13 +34,13 @@ export interface IImportMessage { reactions?: Record; groupable?: boolean; - tmid?: IImportedId; + tmid?: string; tlm?: Date; tcount?: number; - replies?: Array; + replies?: Array; editedAt?: Date; - editedBy?: IImportedId; - mentions?: Array; + editedBy?: string; + mentions?: Array; channels?: Array; attachments?: IImportAttachment[]; bot?: boolean; diff --git a/packages/core-typings/src/import/IImporterInfo.ts b/packages/core-typings/src/import/IImporterInfo.ts deleted file mode 100644 index cff4becc20df1..0000000000000 --- a/packages/core-typings/src/import/IImporterInfo.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface IImporterInfo { - key: string; - name: string; -} diff --git a/packages/core-typings/src/import/ImportState.ts b/packages/core-typings/src/import/ImportState.ts index e1d48f307c2d8..e7421f39366eb 100644 --- a/packages/core-typings/src/import/ImportState.ts +++ b/packages/core-typings/src/import/ImportState.ts @@ -1,10 +1,8 @@ import type { IImport } from './IImport'; -export type ImportState = 'none' | 'new' | 'loading' | 'ready' | 'importing' | 'done' | 'error' | 'canceled'; - export type ImportStatus = | { state: 'none' } | { - state: ImportState; + state: 'new' | 'loading' | 'ready' | 'importing' | 'done' | 'error' | 'canceled'; operation: IImport; }; diff --git a/packages/core-typings/src/import/index.ts b/packages/core-typings/src/import/index.ts index 7b29b2644766e..f5acc77d7ae8e 100644 --- a/packages/core-typings/src/import/index.ts +++ b/packages/core-typings/src/import/index.ts @@ -4,8 +4,6 @@ export * from './IImportRecord'; export * from './IImportMessage'; export * from './IImportChannel'; export * from './IImportContact'; -export * from './IImporterInfo'; -export * from './IImportFileData'; export * from './IImportProgress'; export * from './IImporterSelection'; export * from './IImporterSelectionUser'; diff --git a/packages/core-typings/src/index.ts b/packages/core-typings/src/index.ts index befca6827c4cf..5e0522cd0cf2d 100644 --- a/packages/core-typings/src/index.ts +++ b/packages/core-typings/src/index.ts @@ -1,18 +1,9 @@ -import './ServerAudit/IAuditServerSettingEvent'; -import './ServerAudit/IAuditUserChangedEvent'; -import './ServerAudit/IAuditServerAbacAction'; +export * from './utils'; -export * from './ServerAudit/IAuditUserChangedEvent'; export * from './Apps'; -export * from './AppOverview'; -export * from './FeaturedApps'; -export * from './AppRequests'; -export * from './MarketplaceRest'; export * from './IRoom'; export * from './IMessage'; export * from './federation'; -export * from './Serialized'; -export * from './Subscribable'; export * from './ISetting'; export * from './ISubscription'; export * from './ITeam'; @@ -20,7 +11,7 @@ export * from './RoomType'; export * from './IInvite'; export * from './IRocketChatRecord'; export * from './UserStatus'; -export * from './IUserAction'; +export * from './userAction'; export * from './IBanner'; export * from './IStats'; export * from './IMatrixFederationStatistics'; @@ -29,7 +20,6 @@ export * from './IWorkspaceInfo'; export * from './IInstanceStatus'; export * from './IWebdavAccount'; export * from './IPermission'; -export * from './utils'; export * from './IRole'; export * from './IIntegration'; export * from './IIntegrationHistory'; @@ -60,7 +50,7 @@ export * from './ISession'; export * from './IEmoji'; export * from './IEmojiCustom'; export * from './ICustomEmojiDescriptor'; -export * from './IAnalytic'; +export * from './IAnalytics'; export * from './ICredentialToken'; export * from './IAvatar'; export * from './ICustomUserStatus'; @@ -78,7 +68,6 @@ export * from './ILoginServiceConfiguration'; export * from './ISocketConnection'; export * from './IMethodConnection'; export * from './IPassword'; -export * from './IBaseData'; export * from './IOAuthApps'; export * from './IOAuthAuthCode'; export * from './IOAuthAccessToken'; @@ -97,7 +86,7 @@ export * from './ILivechatMonitor'; export * from './ILivechatTagRecord'; export * from './ILivechatTrigger'; export * from './ILivechatCustomField'; -export * from './IOmnichannel'; +export * from './OmnichannelSortingMechanismSettingType'; export * from './ILivechatAgentActivity'; export * from './ILivechatBusinessHour'; export * from './ILivechatContact'; @@ -106,31 +95,29 @@ export * from './ILivechatDepartmentAgents'; export * from './ILivechatAgent'; export * from './ILivechatDepartmentRecord'; export * from './IOmnichannelCannedResponse'; -export * from './ILivechatMonitorRecord'; export * from './ILivechatDepartment'; export * from './IOmnichannelAgent'; export * from './OmichannelRoutingConfig'; export * from './IInquiry'; export * from './ILivechatPriority'; -export * from './ILogs'; +export * from './ILogItem'; export * from './IOmnichannelServiceLevelAgreements'; -export * from './IAutoTranslate'; +export * from './autoTranslate'; export * from './IVideoConference'; export * from './VideoConferenceCapabilities'; -export * from './VideoConferenceOptions'; export * from './SpotlightUser'; export * from './ICalendarEvent'; export * from './search'; export * from './omnichannel'; -export * from './AppsTokens'; +export * from './IAppsTokens'; export * from './ILivechatUnitMonitor'; export * from './ICronHistoryItem'; export * from './migrations/IControl'; -export * from './ICustomOAuthConfig'; +export * from './OauthConfig'; export * from './IModerationReport'; export * from './CustomFieldMetadata'; @@ -144,5 +131,6 @@ export * from './ICallHistoryItem'; export * from './IAbacAttribute'; export * from './Abac'; export * from './ServerAudit/IAuditServerAbacAction'; +export * from './ServerAudit/IAuditUserChangedEvent'; export { schemas } from './Ajv'; diff --git a/packages/core-typings/src/license/ILicenseV3.ts b/packages/core-typings/src/license/ILicenseV3.ts index b6f6fae00eb7f..cd69e389b74eb 100644 --- a/packages/core-typings/src/license/ILicenseV3.ts +++ b/packages/core-typings/src/license/ILicenseV3.ts @@ -1,7 +1,7 @@ import type { ILicenseTag } from './ILicenseTag'; import type { LicenseLimit } from './LicenseLimit'; import type { ExternalModuleName, InternalModuleName } from './LicenseModule'; -import type { LicensePeriod, Timestamp } from './LicensePeriod'; +import type { LicensePeriod } from './LicensePeriod'; export type InternalModule = { module: InternalModuleName; external?: false }; export type ExternalModule = { module: ExternalModuleName; external: true }; @@ -13,13 +13,13 @@ export interface ILicenseV3 { information: { id?: string; autoRenew: boolean; - visualExpiration?: Timestamp; - notifyAdminsAt?: Timestamp; - notifyUsersAt?: Timestamp; + visualExpiration?: string; + notifyAdminsAt?: string; + notifyUsersAt?: string; trial: boolean; cancellable?: boolean; offline: boolean; - createdAt: Timestamp; + createdAt: string; grantedBy: { method: 'manual' | 'self-service' | 'sales' | 'support' | 'reseller'; seller?: string; diff --git a/packages/core-typings/src/license/LicensePeriod.ts b/packages/core-typings/src/license/LicensePeriod.ts index d9bae6198fdec..96e12c6d6241f 100644 --- a/packages/core-typings/src/license/LicensePeriod.ts +++ b/packages/core-typings/src/license/LicensePeriod.ts @@ -1,13 +1,9 @@ import type { LicenseBehavior } from './LicenseBehavior'; import type { LicenseModule } from './LicenseModule'; -export type Timestamp = string; - export type LicensePeriod = { - validFrom?: Timestamp; - validUntil?: Timestamp; + validFrom?: string; + validUntil?: string; invalidBehavior: LicenseBehavior; -} & ({ validFrom: Timestamp } | { validUntil: Timestamp }) & +} & ({ validFrom: string } | { validUntil: string }) & ({ invalidBehavior: 'disable_modules'; modules: LicenseModule[] } | { invalidBehavior: Exclude }); - -export type LicensePeriodBehavior = Exclude; diff --git a/packages/core-typings/src/mediaCalls/IMediaCall.ts b/packages/core-typings/src/mediaCalls/IMediaCall.ts index 82d79a9477836..40f130e01a331 100644 --- a/packages/core-typings/src/mediaCalls/IMediaCall.ts +++ b/packages/core-typings/src/mediaCalls/IMediaCall.ts @@ -10,7 +10,7 @@ export type MediaCallActor = contractId?: string; }; -export type MediaCallSignedEntity = RequiredField; +type MediaCallSignedEntity = RequiredField; export type MediaCallSignedActor = MediaCallSignedEntity>; @@ -30,7 +30,7 @@ export type MediaCallContact export type MediaCallSignedContact = MediaCallSignedEntity>; /* The list of call states that may actually be stored on the collection is smaller than the list of call states that may be computed by the client class */ -export type MediaCallState = 'none' | 'ringing' | 'accepted' | 'active' | 'hangup'; +type MediaCallState = 'none' | 'ringing' | 'accepted' | 'active' | 'hangup'; export interface IMediaCall extends IRocketChatRecord { service: 'webrtc'; diff --git a/packages/core-typings/src/migrations/IControl.ts b/packages/core-typings/src/migrations/IControl.ts index 3f89ce730f1a7..2d1a3902265ca 100644 --- a/packages/core-typings/src/migrations/IControl.ts +++ b/packages/core-typings/src/migrations/IControl.ts @@ -1,8 +1,8 @@ -export type IControl = { +export interface IControl { _id: string; version: number; locked: boolean; hash?: string; buildAt?: string | Date; lockedAt?: string | Date; -}; +} diff --git a/packages/core-typings/src/omnichannel/outbound.ts b/packages/core-typings/src/omnichannel/outbound.ts index fbfb189f18c04..02912b5dc7097 100644 --- a/packages/core-typings/src/omnichannel/outbound.ts +++ b/packages/core-typings/src/omnichannel/outbound.ts @@ -30,8 +30,6 @@ export interface IOutboundProviderTemplate { rejectedReason: string | undefined; } -type Component = IHeaderComponent | IBodyComponent | IFooterComponent; - // If we happen to have a different structure for this (since this could be a link or idk) we are gonna update this component type interface IHeaderComponent { type: 'header'; @@ -56,6 +54,8 @@ interface IFooterComponent { text: string; } +type Component = IHeaderComponent | IBodyComponent | IFooterComponent; + // Template from RC to App export interface IOutboundMessage { to: string; diff --git a/packages/core-typings/src/omnichannel/routing.ts b/packages/core-typings/src/omnichannel/routing.ts index 526c88eb3d5ab..5179427d00c07 100644 --- a/packages/core-typings/src/omnichannel/routing.ts +++ b/packages/core-typings/src/omnichannel/routing.ts @@ -18,6 +18,7 @@ export type SelectedAgent = { agentId: string; username?: string; }; + export interface IRoutingMethod { getNextAgent(departmentId?: string, ignoreAgentId?: string): Promise; config?: RoutingMethodConfig; diff --git a/packages/core-typings/src/omnichannel/sms.ts b/packages/core-typings/src/omnichannel/sms.ts index 72afb2c8ded71..b0750f4dfc9fb 100644 --- a/packages/core-typings/src/omnichannel/sms.ts +++ b/packages/core-typings/src/omnichannel/sms.ts @@ -1,12 +1,11 @@ -type ServiceMedia = { - url: string; - contentType: string; -}; export type ServiceData = { from: string; to: string; body: string; - media?: ServiceMedia[]; + media?: { + url: string; + contentType: string; + }[]; extra?: Record; }; @@ -44,24 +43,3 @@ export interface ISMSProvider { ): Promise; error(error: Error & { reason?: string }): SMSProviderResponse; } - -export const isServiceData = (data: unknown): data is ServiceData => { - if (typeof data !== 'object' || data === null) { - return false; - } - - const { from, to, body } = data as Record; - - return typeof from === 'string' && typeof to === 'string' && typeof body === 'string'; -}; - -export type SMSWorker = { - services: Record; - accountSid: string | null; - authToken: string | null; - fromNumber: string | null; - - registerService(name: string, service: ISMSProviderConstructor): void; - getService(name: string): ISMSProvider; - isConfiguredService(name: string): boolean; -}; diff --git a/packages/core-typings/src/themes.ts b/packages/core-typings/src/themes.ts index 2fe98dfbe2b08..3928a6721e7fb 100644 --- a/packages/core-typings/src/themes.ts +++ b/packages/core-typings/src/themes.ts @@ -1,3 +1,3 @@ -export type ThemePreference = 'light' | 'dark' | 'auto' | 'high-contrast'; - export type Themes = 'light' | 'dark' | 'high-contrast'; + +export type ThemePreference = Themes | 'auto'; diff --git a/packages/core-typings/src/userAction.ts b/packages/core-typings/src/userAction.ts new file mode 100644 index 0000000000000..62b9e8345d6a7 --- /dev/null +++ b/packages/core-typings/src/userAction.ts @@ -0,0 +1,7 @@ +import type { IMessage } from './IMessage'; + +export type IExtras = { + tmid?: IMessage['_id']; +}; + +export type IRoomActivity = Record>>; diff --git a/packages/core-typings/src/utils.ts b/packages/core-typings/src/utils.ts index 3e8f4869ce3d2..58195b3e167c6 100644 --- a/packages/core-typings/src/utils.ts +++ b/packages/core-typings/src/utils.ts @@ -6,25 +6,18 @@ export type ValueOf = T[keyof T]; export type UnionToIntersection = (T extends any ? (x: T) => void : never) extends (x: infer U) => void ? U : never; -export type Awaited = T extends PromiseLike ? Awaited : T; - // `T extends any` is a trick to apply a operator to each member of a union export type KeyOfEach = T extends any ? keyof T : never; -// Taken from https://effectivetypescript.com/2020/04/09/jsonify/ -export type Jsonify = T extends Date - ? string - : T extends object - ? { - [k in keyof T]: Jsonify; - } - : T; - -// Use AtLeast when you don't care if you receive a partial or full object, as long as the specified attributes are loaded -// Attributes defined as optional will continue to be optional. +/** + * Use AtLeast when you don't care if you received a partial or full object, as long as the specified attributes are loaded + * Attributes defined as optional will continue to be optional. + */ export type AtLeast = Partial & Pick; -// Use RequiredField when you want a full object with specific optional fields no longer being optional. +/** + * Use RequiredField when you want a full object with specific optional fields no longer being optional. + */ export type RequiredField = T & Required>; export type DeepWritable = T extends (...args: any) => any @@ -35,10 +28,6 @@ export type DeepWritable = T extends (...args: any) => any export type DistributiveOmit = T extends any ? Omit : never; -export type ValueOfUnion> = T extends any ? (K extends keyof T ? T[K] : undefined) : undefined; - -export type ValueOfOptional> = T extends undefined ? undefined : T extends object ? ValueOfUnion : null; - export type DeepPartial = { [P in keyof T]?: T[P] extends (infer U)[] | undefined ? DeepPartial[] @@ -50,3 +39,34 @@ export type DeepPartial = { }; export const isNotUndefined = (value: T | undefined): value is T => value !== undefined; + +declare const __brand: unique symbol; +type Brand = { [__brand]: B }; +export type Branded = T & Brand; + +type SerializablePrimitive = boolean | number | string | null; + +// eslint-disable-next-line @typescript-eslint/ban-types +type UnserializablePrimitive = bigint | symbol | undefined; + +type CustomSerializable = { + toJSON(key: string): T; +}; + +/** + * The type of a value that was serialized via `JSON.stringify` and then deserialized via `JSON.parse`. + */ +export type Serialized = + T extends CustomSerializable + ? Serialized + : T extends [any, ...any] // is T a tuple? + ? { [K in keyof T]: T[K] extends UnserializablePrimitive ? null : Serialized } + : T extends any[] + ? Serialized[] + : T extends object + ? { [K in keyof T]: Serialized } + : T extends SerializablePrimitive + ? T + : T extends UnserializablePrimitive + ? undefined + : null; diff --git a/packages/model-typings/src/models/IAnalyticsModel.ts b/packages/model-typings/src/models/IAnalyticsModel.ts index 1ca4d7abf1186..1baec42d0c585 100644 --- a/packages/model-typings/src/models/IAnalyticsModel.ts +++ b/packages/model-typings/src/models/IAnalyticsModel.ts @@ -1,29 +1,29 @@ -import type { IAnalytic, IRoom } from '@rocket.chat/core-typings'; +import type { IAnalytics, IRoom } from '@rocket.chat/core-typings'; import type { AggregationCursor, FindCursor, FindOptions, UpdateResult, Document } from 'mongodb'; import type { IBaseModel } from './IBaseModel'; import type { IChannelsWithNumberOfMessagesBetweenDate } from './IRoomsModel'; -export interface IAnalyticsModel extends IBaseModel { - saveMessageSent({ room, date }: { room: IRoom; date: IAnalytic['date'] }): Promise; - saveUserData({ date }: { date: IAnalytic['date'] }): Promise; - saveMessageDeleted({ room, date }: { room: { _id: string }; date: IAnalytic['date'] }): Promise; +export interface IAnalyticsModel extends IBaseModel { + saveMessageSent({ room, date }: { room: IRoom; date: IAnalytics['date'] }): Promise; + saveUserData({ date }: { date: IAnalytics['date'] }): Promise; + saveMessageDeleted({ room, date }: { room: { _id: string }; date: IAnalytics['date'] }): Promise; getMessagesSentTotalByDate(params: { - start: IAnalytic['date']; - end: IAnalytic['date']; - options?: { sort?: FindOptions['sort']; count?: number }; + start: IAnalytics['date']; + end: IAnalytics['date']; + options?: { sort?: FindOptions['sort']; count?: number }; }): AggregationCursor<{ - _id: IAnalytic['date']; + _id: IAnalytics['date']; messages: number; }>; - getMessagesOrigin({ start, end }: { start: IAnalytic['date']; end: IAnalytic['date'] }): AggregationCursor<{ + getMessagesOrigin({ start, end }: { start: IAnalytics['date']; end: IAnalytics['date'] }): AggregationCursor<{ t: IRoom['t']; messages: number; }>; getMostPopularChannelsByMessagesSentQuantity(params: { - start: IAnalytic['date']; - end: IAnalytic['date']; - options?: { sort?: FindOptions['sort']; count?: number }; + start: IAnalytics['date']; + end: IAnalytics['date']; + options?: { sort?: FindOptions['sort']; count?: number }; }): AggregationCursor<{ t: IRoom['t']; name: string; @@ -31,14 +31,14 @@ export interface IAnalyticsModel extends IBaseModel { usernames: string[]; }>; getTotalOfRegisteredUsersByDate(params: { - start: IAnalytic['date']; - end: IAnalytic['date']; - options?: { sort?: FindOptions['sort']; count?: number }; + start: IAnalytics['date']; + end: IAnalytics['date']; + options?: { sort?: FindOptions['sort']; count?: number }; }): AggregationCursor<{ - _id: IAnalytic['date']; + _id: IAnalytics['date']; users: number; }>; - findByTypeBeforeDate({ type, date }: { type: IAnalytic['type']; date: IAnalytic['date'] }): FindCursor; + findByTypeBeforeDate({ type, date }: { type: IAnalytics['type']; date: IAnalytics['date'] }): FindCursor; findRoomsByTypesWithNumberOfMessagesBetweenDate(params: { types: Array; start: number; diff --git a/packages/model-typings/src/models/ITeamModel.ts b/packages/model-typings/src/models/ITeamModel.ts index f94ff83687994..ef2cde1cdaa14 100644 --- a/packages/model-typings/src/models/ITeamModel.ts +++ b/packages/model-typings/src/models/ITeamModel.ts @@ -1,4 +1,4 @@ -import type { ITeam, TEAM_TYPE } from '@rocket.chat/core-typings'; +import type { ITeam, TeamType } from '@rocket.chat/core-typings'; import type { FindOptions, FindCursor, UpdateResult, DeleteResult, Filter, Document } from 'mongodb'; import type { FindPaginated, IBaseModel } from './IBaseModel'; @@ -33,19 +33,19 @@ export interface ITeamModel extends IBaseModel { findByIdsPaginated(ids: Array, options?: undefined | FindOptions, query?: Filter): FindPaginated>; - findByIdsAndType(ids: Array, type: TEAM_TYPE): FindCursor; + findByIdsAndType(ids: Array, type: TeamType): FindCursor; - findByIdsAndType(ids: Array, type: TEAM_TYPE, options: FindOptions): FindCursor; + findByIdsAndType(ids: Array, type: TeamType, options: FindOptions): FindCursor; findByIdsAndType

( ids: Array, - type: TEAM_TYPE, + type: TeamType, options: FindOptions

, ): FindCursor

; findByIdsAndType

( ids: Array, - type: TEAM_TYPE, + type: TeamType, options?: undefined | FindOptions | FindOptions

, ): FindCursor

| FindCursor; @@ -104,5 +104,5 @@ export interface ITeamModel extends IBaseModel { deleteOneByName(name: string): Promise; - updateNameAndType(teamId: string, nameAndType: { name?: string; type?: TEAM_TYPE }): Promise; + updateNameAndType(teamId: string, nameAndType: { name?: string; type?: TeamType }): Promise; } diff --git a/packages/models/src/models/Analytics.ts b/packages/models/src/models/Analytics.ts index 04203b8e552c0..a26cb50500fd3 100644 --- a/packages/models/src/models/Analytics.ts +++ b/packages/models/src/models/Analytics.ts @@ -1,4 +1,4 @@ -import type { IAnalytic, IRoom } from '@rocket.chat/core-typings'; +import type { IAnalytics, IRoom } from '@rocket.chat/core-typings'; import type { IAnalyticsModel, IChannelsWithNumberOfMessagesBetweenDate } from '@rocket.chat/model-typings'; import { Random } from '@rocket.chat/random'; import type { AggregationCursor, FindCursor, Db, IndexDescription, FindOptions, UpdateResult, Document, Collection } from 'mongodb'; @@ -6,7 +6,7 @@ import type { AggregationCursor, FindCursor, Db, IndexDescription, FindOptions, import { BaseRaw } from './BaseRaw'; import { readSecondaryPreferred } from '../readSecondaryPreferred'; -export class AnalyticsRaw extends BaseRaw implements IAnalyticsModel { +export class AnalyticsRaw extends BaseRaw implements IAnalyticsModel { constructor(db: Db) { super(db, 'analytics', undefined, { collection: { readPreference: readSecondaryPreferred(db) }, @@ -21,7 +21,7 @@ export class AnalyticsRaw extends BaseRaw implements IAnalyticsModel ]; } - saveMessageSent({ room, date }: { room: IRoom; date: IAnalytic['date'] }): Promise { + saveMessageSent({ room, date }: { room: IRoom; date: IAnalytics['date'] }): Promise { return this.updateMany( { date, 'room._id': room._id, 'type': 'messages' }, { @@ -44,7 +44,7 @@ export class AnalyticsRaw extends BaseRaw implements IAnalyticsModel ); } - saveUserData({ date }: { date: IAnalytic['date'] }): Promise { + saveUserData({ date }: { date: IAnalytics['date'] }): Promise { return this.updateMany( { date, type: 'users' }, { @@ -59,7 +59,7 @@ export class AnalyticsRaw extends BaseRaw implements IAnalyticsModel ); } - saveMessageDeleted({ room, date }: { room: { _id: string }; date: IAnalytic['date'] }): Promise { + saveMessageDeleted({ room, date }: { room: { _id: string }; date: IAnalytics['date'] }): Promise { return this.updateMany( { date, 'room._id': room._id }, { @@ -73,15 +73,15 @@ export class AnalyticsRaw extends BaseRaw implements IAnalyticsModel end, options = {}, }: { - start: IAnalytic['date']; - end: IAnalytic['date']; - options?: { sort?: FindOptions['sort']; count?: number }; + start: IAnalytics['date']; + end: IAnalytics['date']; + options?: { sort?: FindOptions['sort']; count?: number }; }): AggregationCursor<{ - _id: IAnalytic['date']; + _id: IAnalytics['date']; messages: number; }> { return this.col.aggregate<{ - _id: IAnalytic['date']; + _id: IAnalytics['date']; messages: number; }>( [ @@ -104,7 +104,7 @@ export class AnalyticsRaw extends BaseRaw implements IAnalyticsModel ); } - getMessagesOrigin({ start, end }: { start: IAnalytic['date']; end: IAnalytic['date'] }): AggregationCursor<{ + getMessagesOrigin({ start, end }: { start: IAnalytics['date']; end: IAnalytics['date'] }): AggregationCursor<{ t: IRoom['t']; messages: number; }> { @@ -137,9 +137,9 @@ export class AnalyticsRaw extends BaseRaw implements IAnalyticsModel end, options = {}, }: { - start: IAnalytic['date']; - end: IAnalytic['date']; - options?: { sort?: FindOptions['sort']; count?: number }; + start: IAnalytics['date']; + end: IAnalytics['date']; + options?: { sort?: FindOptions['sort']; count?: number }; }): AggregationCursor<{ t: IRoom['t']; name: string; @@ -181,15 +181,15 @@ export class AnalyticsRaw extends BaseRaw implements IAnalyticsModel end, options = {}, }: { - start: IAnalytic['date']; - end: IAnalytic['date']; - options?: { sort?: FindOptions['sort']; count?: number }; + start: IAnalytics['date']; + end: IAnalytics['date']; + options?: { sort?: FindOptions['sort']; count?: number }; }): AggregationCursor<{ - _id: IAnalytic['date']; + _id: IAnalytics['date']; users: number; }> { return this.col.aggregate<{ - _id: IAnalytic['date']; + _id: IAnalytics['date']; users: number; }>( [ @@ -212,7 +212,7 @@ export class AnalyticsRaw extends BaseRaw implements IAnalyticsModel ); } - findByTypeBeforeDate({ type, date }: { type: IAnalytic['type']; date: IAnalytic['date'] }): FindCursor { + findByTypeBeforeDate({ type, date }: { type: IAnalytics['type']; date: IAnalytics['date'] }): FindCursor { return this.find({ type, date: { $lte: date } }); } diff --git a/packages/models/src/models/Team.ts b/packages/models/src/models/Team.ts index 8a3cf29518150..c459a77e32998 100644 --- a/packages/models/src/models/Team.ts +++ b/packages/models/src/models/Team.ts @@ -1,4 +1,4 @@ -import type { ITeam, RocketChatRecordDeleted, TEAM_TYPE } from '@rocket.chat/core-typings'; +import type { ITeam, RocketChatRecordDeleted, TeamType } from '@rocket.chat/core-typings'; import type { FindPaginated, ITeamModel } from '@rocket.chat/model-typings'; import type { Collection, FindCursor, Db, DeleteResult, Document, Filter, FindOptions, IndexDescription, UpdateResult } from 'mongodb'; @@ -63,19 +63,19 @@ export class TeamRaw extends BaseRaw implements ITeamModel { return this.findPaginated({ ...query, _id: { $in: ids } }, options); } - findByIdsAndType(ids: Array, type: TEAM_TYPE): FindCursor; + findByIdsAndType(ids: Array, type: TeamType): FindCursor; - findByIdsAndType(ids: Array, type: TEAM_TYPE, options: FindOptions): FindCursor; + findByIdsAndType(ids: Array, type: TeamType, options: FindOptions): FindCursor; findByIdsAndType

( ids: Array, - type: TEAM_TYPE, + type: TeamType, options: FindOptions

, ): FindCursor

; findByIdsAndType

( ids: Array, - type: TEAM_TYPE, + type: TeamType, options?: undefined | FindOptions | FindOptions

, ): FindCursor

| FindCursor { if (options === undefined) { @@ -200,7 +200,7 @@ export class TeamRaw extends BaseRaw implements ITeamModel { return this.col.deleteOne({ name }); } - updateNameAndType(teamId: string, nameAndType: { name?: string; type?: TEAM_TYPE }): Promise { + updateNameAndType(teamId: string, nameAndType: { name?: string; type?: TeamType }): Promise { const query = { _id: teamId, }; diff --git a/packages/rest-typings/src/apps/index.ts b/packages/rest-typings/src/apps/index.ts index 13d5e522eb10d..a012d251b9801 100644 --- a/packages/rest-typings/src/apps/index.ts +++ b/packages/rest-typings/src/apps/index.ts @@ -11,8 +11,7 @@ import type { FeaturedAppsSection, ILogItem, AppRequestFilter, - AppRequestsStats, - PaginatedAppRequests, + AppRequest, } from '@rocket.chat/core-typings'; import type * as UiKit from '@rocket.chat/ui-kit'; @@ -198,11 +197,25 @@ export type AppsEndpoints = { }; '/apps/app-request': { - GET: (params: { appId: string; q?: AppRequestFilter; sort?: string; limit?: number; offset?: number }) => PaginatedAppRequests; + GET: (params: { appId: string; q?: AppRequestFilter; sort?: string; limit?: number; offset?: number }) => { + data: AppRequest[] | null; + meta: { + limit: 25 | 50 | 100; + offset: number; + sort: string; + filter: string; + total: number; + }; + }; }; '/apps/app-request/stats': { - GET: () => AppRequestsStats; + GET: () => { + data: { + totalSeen: number; + totalUnseen: number; + }; + }; }; '/apps/app-request/markAsSeen': { diff --git a/packages/rest-typings/src/helpers/IGetRoomRoles.ts b/packages/rest-typings/src/helpers/IGetRoomRoles.ts new file mode 100644 index 0000000000000..513cfa3f80ff4 --- /dev/null +++ b/packages/rest-typings/src/helpers/IGetRoomRoles.ts @@ -0,0 +1,9 @@ +export interface IGetRoomRoles { + _id: string; + rid: string; + u: { + _id: string; + username: string; + }; + roles: string[]; +} diff --git a/packages/rest-typings/src/index.ts b/packages/rest-typings/src/index.ts index a7019029529c9..097ce5081b1de 100644 --- a/packages/rest-typings/src/index.ts +++ b/packages/rest-typings/src/index.ts @@ -222,6 +222,7 @@ export * from './v1/dm/DmHistoryProps'; export * from './v1/integrations'; export * from './v1/licenses'; export * from './v1/omnichannel'; +export * from './helpers/IGetRoomRoles'; export * from './helpers/PaginatedRequest'; export * from './helpers/PaginatedResult'; export * from './helpers/ReplacePlaceholders'; diff --git a/packages/rest-typings/src/v1/channels/channels.ts b/packages/rest-typings/src/v1/channels/channels.ts index 51611dfa783b5..6ae8adbd4a365 100644 --- a/packages/rest-typings/src/v1/channels/channels.ts +++ b/packages/rest-typings/src/v1/channels/channels.ts @@ -1,4 +1,4 @@ -import type { IUploadWithUser, IMessage, IRoom, ITeam, IGetRoomRoles, IUser, IIntegration } from '@rocket.chat/core-typings'; +import type { IUploadWithUser, IMessage, IRoom, ITeam, IUser, IIntegration } from '@rocket.chat/core-typings'; import type { ChannelsAddAllProps } from './ChannelsAddAllProps'; import type { ChannelsArchiveProps } from './ChannelsArchiveProps'; @@ -30,6 +30,7 @@ import type { ChannelsSetReadOnlyProps } from './ChannelsSetReadOnlyProps'; import type { ChannelsSetTopicProps } from './ChannelsSetTopicProps'; import type { ChannelsSetTypeProps } from './ChannelsSetTypeProps'; import type { ChannelsUnarchiveProps } from './ChannelsUnarchiveProps'; +import type { IGetRoomRoles } from '../../helpers/IGetRoomRoles'; import type { PaginatedRequest } from '../../helpers/PaginatedRequest'; import type { PaginatedResult } from '../../helpers/PaginatedResult'; diff --git a/packages/rest-typings/src/v1/groups/groups.ts b/packages/rest-typings/src/v1/groups/groups.ts index 973f5d98a357e..a7c937b08a9fc 100644 --- a/packages/rest-typings/src/v1/groups/groups.ts +++ b/packages/rest-typings/src/v1/groups/groups.ts @@ -1,4 +1,4 @@ -import type { IMessage, IRoom, ITeam, IGetRoomRoles, IUser, IUploadWithUser, IIntegration, ISubscription } from '@rocket.chat/core-typings'; +import type { IMessage, IRoom, ITeam, IUser, IUploadWithUser, IIntegration, ISubscription } from '@rocket.chat/core-typings'; import type { GroupsAddAllProps } from './GroupsAddAllProps'; import type { GroupsAddLeaderProps } from './GroupsAddLeaderProps'; @@ -37,6 +37,7 @@ import type { GroupsSetReadOnlyProps } from './GroupsSetReadOnlyProps'; import type { GroupsSetTopicProps } from './GroupsSetTopicProps'; import type { GroupsSetTypeProps } from './GroupsSetTypeProps'; import type { GroupsUnarchiveProps } from './GroupsUnarchiveProps'; +import type { IGetRoomRoles } from '../../helpers/IGetRoomRoles'; import type { PaginatedResult } from '../../helpers/PaginatedResult'; export type GroupsEndpoints = { diff --git a/packages/rest-typings/src/v1/import/import.ts b/packages/rest-typings/src/v1/import/import.ts index 24d726d57e493..cc78002eeb783 100644 --- a/packages/rest-typings/src/v1/import/import.ts +++ b/packages/rest-typings/src/v1/import/import.ts @@ -1,4 +1,4 @@ -import type { IImport, IImporterSelection, IImportProgress, IImporterInfo, ImportStatus, IImportUser } from '@rocket.chat/core-typings'; +import type { IImport, IImporterSelection, IImportProgress, ImportStatus, IImportUser } from '@rocket.chat/core-typings'; import type { DownloadPublicImportFileParamsPOST } from './DownloadPublicImportFileParamsPOST'; import type { StartImportParamsPOST } from './StartImportParamsPOST'; @@ -33,7 +33,10 @@ export type ImportEndpoints = { GET: () => { operation: IImport }; }; '/v1/importers.list': { - GET: () => Array; + GET: () => Array<{ + key: string; + name: string; + }>; }; '/v1/import.clear': { POST: () => void; diff --git a/packages/rest-typings/src/v1/teams/TeamsUpdateProps.ts b/packages/rest-typings/src/v1/teams/TeamsUpdateProps.ts index 4d1b7d1ed13b9..554d96b12c786 100644 --- a/packages/rest-typings/src/v1/teams/TeamsUpdateProps.ts +++ b/packages/rest-typings/src/v1/teams/TeamsUpdateProps.ts @@ -1,4 +1,4 @@ -import { TEAM_TYPE } from '@rocket.chat/core-typings'; +import { TeamType } from '@rocket.chat/core-typings'; import Ajv from 'ajv'; const ajv = new Ajv(); @@ -7,11 +7,11 @@ export type TeamsUpdateProps = ({ teamId: string } | { teamName: string }) & { data: | { name: string; - type?: TEAM_TYPE; + type?: TeamType; } | { name?: string; - type: TEAM_TYPE; + type: TeamType; }; }; @@ -39,7 +39,7 @@ const teamsUpdatePropsSchema = { }, type: { type: 'number', - enum: [TEAM_TYPE.PUBLIC, TEAM_TYPE.PRIVATE], + enum: [TeamType.PUBLIC, TeamType.PRIVATE], }, }, additionalProperties: false, diff --git a/packages/ui-contexts/src/UserPresenceContext.ts b/packages/ui-contexts/src/UserPresenceContext.ts index 58ccfd6d676e3..dc5673323377f 100644 --- a/packages/ui-contexts/src/UserPresenceContext.ts +++ b/packages/ui-contexts/src/UserPresenceContext.ts @@ -1,8 +1,11 @@ -import type { Subscribable, UserPresence } from '@rocket.chat/core-typings'; +import type { UserPresence } from '@rocket.chat/core-typings'; import { createContext } from 'react'; export type UserPresenceContextValue = { - queryUserData: (uid: string | undefined) => Subscribable; + queryUserData: (uid: string | undefined) => { + get(): UserPresence | undefined; + subscribe(callback: () => void): () => void; + }; }; export const UserPresenceContext = createContext({