diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 4efe227acdb0..cc271aee793a 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,6 +1,7 @@ /packages/* @RocketChat/chat-engine /packages/core-typings/ @RocketChat/chat-engine /packages/rest-typings/ @RocketChat/chat-engine +/packages/eslint-config/ @RocketChat/chat-engine /.vscode/ @RocketChat/chat-engine /.github/ @RocketChat/chat-engine /_templates/ @RocketChat/chat-engine diff --git a/.github/no-js-action-config.json b/.github/no-js-action-config.json index f2c55418f002..5e76f81ed62b 100644 --- a/.github/no-js-action-config.json +++ b/.github/no-js-action-config.json @@ -1,5 +1,5 @@ { "added": { - "ignore": ["packages/accounts-linkedin/**/*", "packages/linkedin-oauth/**/*", "tests/cypress/integration/08-resolutions.spec.js"] + "ignore": ["packages/accounts-linkedin/**/*", "packages/linkedin-oauth/**/*", "tests/cypress/integration/08-resolutions.spec.js", "**/.eslintrc.js", "packages/eslint-config/**"] } } diff --git a/apps/meteor/.prettierrc b/.prettierrc similarity index 100% rename from apps/meteor/.prettierrc rename to .prettierrc diff --git a/_templates/package/new/package.json.ejs.t b/_templates/package/new/package.json.ejs.t index a136608feeda..3a6f8f9411b5 100644 --- a/_templates/package/new/package.json.ejs.t +++ b/_templates/package/new/package.json.ejs.t @@ -14,8 +14,8 @@ to: packages/<%= name %>/package.json "typescript": "~4.3.5" }, "scripts": { - "eslint": "eslint --ext .js,.jsx,.ts,.tsx .", - "eslint:fix": "eslint --ext .js,.jsx,.ts,.tsx . --fix", + "lint": "eslint --ext .js,.jsx,.ts,.tsx .", + "lint:fix": "eslint --ext .js,.jsx,.ts,.tsx . --fix", "jest": "jest", "build": "tsc -p tsconfig.json" }, diff --git a/apps/meteor/.eslintrc b/apps/meteor/.eslintrc index 010bd512f614..e41eb46338e0 100644 --- a/apps/meteor/.eslintrc +++ b/apps/meteor/.eslintrc @@ -1,6 +1,5 @@ { - "extends": ["@rocket.chat/eslint-config", "plugin:prettier/recommended", "plugin:import/typescript"], - "parser": "babel-eslint", + "extends": ["@rocket.chat/eslint-config"], "globals": { "__meteor_bootstrap__": false, "__meteor_runtime_config__": false, @@ -10,7 +9,6 @@ }, "plugins": ["react", "react-hooks"], "rules": { - "jsx-quotes": ["error", "prefer-single"], "react/jsx-uses-react": "error", "react/jsx-uses-vars": "error", "react/jsx-no-undef": "error", @@ -24,11 +22,6 @@ ] }, "settings": { - "import/resolver": { - "node": { - "extensions": [".js", ".ts", ".tsx"] - } - }, "react": { "version": "detect" } @@ -36,67 +29,18 @@ "overrides": [ { "files": ["**/*.ts", "**/*.tsx"], - "extends": [ - "plugin:@typescript-eslint/recommended", - "plugin:@typescript-eslint/eslint-recommended", - "@rocket.chat/eslint-config", - "plugin:prettier/recommended" - ], "globals": { "Atomics": "readonly", "SharedArrayBuffer": "readonly" }, - "parser": "@typescript-eslint/parser", - "parserOptions": { - "sourceType": "module", - "ecmaVersion": 2018, - "warnOnUnsupportedTypeScriptVersion": false, - "ecmaFeatures": { - "experimentalObjectRestSpread": true, - "legacyDecorators": true - } - }, - "plugins": ["react", "@typescript-eslint", "anti-trojan-source"], + "plugins": ["react"], "rules": { - "func-call-spacing": "off", - "jsx-quotes": ["error", "prefer-single"], - "indent": "off", - "no-dupe-class-members": "off", - "no-spaced-func": "off", - "no-unused-vars": "off", - "no-useless-constructor": "off", - "no-use-before-define": "off", "react/jsx-uses-react": "error", "react/jsx-uses-vars": "error", "react/jsx-no-undef": "error", - "react/jsx-fragments": ["error", "syntax"], - "@typescript-eslint/ban-ts-ignore": "off", - "@typescript-eslint/interface-name-prefix": ["error", "always"], - "@typescript-eslint/no-dupe-class-members": "error", - "@typescript-eslint/no-explicit-any": "off", - "@typescript-eslint/no-unused-vars": [ - "error", - { - "argsIgnorePattern": "^_", - "ignoreRestSiblings": true - } - ], - "@typescript-eslint/prefer-optional-chain": "warn", - "anti-trojan-source/no-bidi": "error" - }, - "env": { - "browser": true, - "commonjs": true, - "es6": true, - "node": true + "react/jsx-fragments": ["error", "syntax"] }, - "settings": { - "import/resolver": { - "node": { - "extensions": [".js", ".ts", ".tsx"] - } - }, "react": { "version": "detect" } diff --git a/apps/meteor/client/.eslintrc.js b/apps/meteor/client/.eslintrc.js index b90c756cd264..6a0a200b3c3c 100644 --- a/apps/meteor/client/.eslintrc.js +++ b/apps/meteor/client/.eslintrc.js @@ -1,6 +1,6 @@ module.exports = { root: true, - extends: ['@rocket.chat/eslint-config', 'prettier'], + extends: ['@rocket.chat/eslint-config/original', 'prettier'], parser: 'babel-eslint', plugins: ['react', 'react-hooks', 'prettier', 'testing-library', 'anti-trojan-source'], rules: { @@ -54,7 +54,7 @@ module.exports = { extends: [ 'plugin:@typescript-eslint/recommended', 'plugin:@typescript-eslint/eslint-recommended', - '@rocket.chat/eslint-config', + '@rocket.chat/eslint-config/original', 'prettier', ], parser: '@typescript-eslint/parser', diff --git a/apps/meteor/ee/definition/rest/v1/omnichannel/cannedResponses.ts b/apps/meteor/ee/definition/rest/v1/omnichannel/cannedResponses.ts index 370899a0da25..13a6ec1d2224 100644 --- a/apps/meteor/ee/definition/rest/v1/omnichannel/cannedResponses.ts +++ b/apps/meteor/ee/definition/rest/v1/omnichannel/cannedResponses.ts @@ -1,24 +1,22 @@ import type { ILivechatDepartment, IOmnichannelCannedResponse, IUser } from '@rocket.chat/core-typings'; +import type { PaginatedResult, PaginatedRequest } from '@rocket.chat/rest-typings'; declare module '@rocket.chat/rest-typings' { // eslint-disable-next-line @typescript-eslint/interface-name-prefix interface Endpoints { 'canned-responses': { - GET: (params: { - shortcut?: string; - text?: string; - scope?: string; - createdBy?: IUser['username']; - tags?: any; - departmentId?: ILivechatDepartment['_id']; - offset?: number; - count?: number; - }) => { + GET: ( + params: PaginatedRequest<{ + shortcut?: string; + text?: string; + scope?: string; + createdBy?: IUser['username']; + tags?: any; + departmentId?: ILivechatDepartment['_id']; + }>, + ) => PaginatedResult<{ cannedResponses: IOmnichannelCannedResponse[]; - count?: number; - offset?: number; - total: number; - }; + }>; POST: (params: { _id?: IOmnichannelCannedResponse['_id']; shortcut: string; diff --git a/apps/meteor/package.json b/apps/meteor/package.json index 2c008ea8940d..357e7be08da8 100644 --- a/apps/meteor/package.json +++ b/apps/meteor/package.json @@ -69,7 +69,7 @@ "@babel/preset-react": "^7.14.5", "@babel/register": "^7.14.5", "@playwright/test": "^1.21.0", - "@rocket.chat/eslint-config": "^0.4.0", + "@rocket.chat/eslint-config": "workspace:^", "@rocket.chat/livechat": "1.13.3", "@settlin/spacebars-loader": "^1.0.9", "@storybook/addon-essentials": "~6.4.19", diff --git a/packages/core-typings/.eslintrc b/packages/core-typings/.eslintrc index 4867a00cbe0b..56a6f6602e33 100644 --- a/packages/core-typings/.eslintrc +++ b/packages/core-typings/.eslintrc @@ -1,5 +1,5 @@ { - "extends": ["../../.eslintrc"], + "extends": ["@rocket.chat/eslint-config"], "overrides": [ { "files": ["**/*.spec.js", "**/*.spec.jsx"], diff --git a/packages/core-typings/package.json b/packages/core-typings/package.json index 436359d3fb29..d077c2c9ed90 100644 --- a/packages/core-typings/package.json +++ b/packages/core-typings/package.json @@ -4,6 +4,7 @@ "private": true, "devDependencies": { "@rocket.chat/apps-engine": "^1.31.0", + "@rocket.chat/eslint-config": "workspace:^", "@rocket.chat/icons": "^0.31.9", "@rocket.chat/message-parser": "^0.31.6", "@rocket.chat/ui-kit": "^0.31.6", @@ -13,8 +14,8 @@ "typescript": "~4.3.5" }, "scripts": { - "eslint": "eslint --ext .js,.jsx,.ts,.tsx .", - "eslint:fix": "eslint --ext .js,.jsx,.ts,.tsx . --fix", + "lint": "eslint --ext .js,.jsx,.ts,.tsx .", + "lint:fix": "eslint --ext .js,.jsx,.ts,.tsx . --fix", "test": "echo \"Error: no test specified\" && exit 1", "build": "tsc -p tsconfig.json" }, diff --git a/packages/core-typings/src/Federation.ts b/packages/core-typings/src/Federation.ts index 64de8f6ff112..92b482e48a92 100644 --- a/packages/core-typings/src/Federation.ts +++ b/packages/core-typings/src/Federation.ts @@ -1,5 +1,5 @@ -import type { IRocketChatRecord } from "./IRocketChatRecord"; +import type { IRocketChatRecord } from './IRocketChatRecord'; export interface IFederationServer extends IRocketChatRecord { - domain: string; + domain: string; } diff --git a/packages/core-typings/src/IAnalytic.ts b/packages/core-typings/src/IAnalytic.ts index 5b7dbc1df2ef..320da54a707d 100644 --- a/packages/core-typings/src/IAnalytic.ts +++ b/packages/core-typings/src/IAnalytic.ts @@ -1,37 +1,33 @@ -import type { IRocketChatRecord } from "./IRocketChatRecord"; +import type { IRocketChatRecord } from './IRocketChatRecord'; interface IAnalyticsBase extends IRocketChatRecord { - type: "messages" | "users" | "seat-request"; - date: number; + type: 'messages' | 'users' | 'seat-request'; + date: number; } export interface IAnalyticsMessages extends IAnalyticsBase { - type: "messages"; - room: { - _id: string; - name?: string; - t: string; - usernames: string[]; - }; + type: 'messages'; + room: { + _id: string; + name?: string; + t: string; + usernames: string[]; + }; } export interface IAnalyticsUsers extends IAnalyticsBase { - type: "users"; - room: { - _id: string; - name?: string; - t: string; - usernames: string[]; - }; + type: 'users'; + room: { + _id: string; + name?: string; + t: string; + usernames: string[]; + }; } export interface IAnalyticsSeatRequest extends IAnalyticsBase { - type: "seat-request"; - count: number; + type: 'seat-request'; + count: number; } -export type IAnalytic = - | IAnalyticsBase - | IAnalyticsMessages - | IAnalyticsUsers - | IAnalyticsSeatRequest; +export type IAnalytic = IAnalyticsBase | IAnalyticsMessages | IAnalyticsUsers | IAnalyticsSeatRequest; diff --git a/packages/core-typings/src/IAvatar.ts b/packages/core-typings/src/IAvatar.ts index 8f50dfeef709..95d7b780a445 100644 --- a/packages/core-typings/src/IAvatar.ts +++ b/packages/core-typings/src/IAvatar.ts @@ -1,13 +1,13 @@ -import type { IRocketChatRecord } from "./IRocketChatRecord"; +import type { IRocketChatRecord } from './IRocketChatRecord'; export interface IAvatar extends IRocketChatRecord { - name: string; - rid: string; - userId: string; - store: string; - complete: boolean; - uploading: boolean; - progress: number; - extension: string; - uploadedAt: Date; + name: string; + rid: string; + userId: string; + store: string; + complete: boolean; + uploading: boolean; + progress: number; + extension: string; + uploadedAt: Date; } diff --git a/packages/core-typings/src/IBanner.ts b/packages/core-typings/src/IBanner.ts index 047d537f41e8..29867cdfb6c8 100644 --- a/packages/core-typings/src/IBanner.ts +++ b/packages/core-typings/src/IBanner.ts @@ -1,35 +1,34 @@ -import type { IRocketChatRecord } from "./IRocketChatRecord"; -import type { IUser } from "./IUser"; -import type { UiKitBannerPayload } from "./UIKit"; +import type { IRocketChatRecord } from './IRocketChatRecord'; +import type { IUser } from './IUser'; +import type { UiKitBannerPayload } from './UIKit'; export enum BannerPlatform { - Web = "web", - Mobile = "mobile", + Web = 'web', + Mobile = 'mobile', } export interface IBanner extends IRocketChatRecord { - platform: BannerPlatform[]; // pĺatforms a banner could be shown - expireAt: Date; // date when banner should not be shown anymore - startAt: Date; // start date a banner should be presented - roles?: string[]; // only show the banner to this roles - createdBy: Pick; - createdAt: Date; - view: UiKitBannerPayload; - active?: boolean; - inactivedAt?: Date; - snapshot?: string; + platform: BannerPlatform[]; // pĺatforms a banner could be shown + expireAt: Date; // date when banner should not be shown anymore + startAt: Date; // start date a banner should be presented + roles?: string[]; // only show the banner to this roles + createdBy: Pick; + createdAt: Date; + view: UiKitBannerPayload; + active?: boolean; + inactivedAt?: Date; + snapshot?: string; } export type InactiveBanner = IBanner & { - active: false; - inactivedAt: Date; + active: false; + inactivedAt: Date; }; -export const isInactiveBanner = (banner: IBanner): banner is InactiveBanner => - banner.active === false; +export const isInactiveBanner = (banner: IBanner): banner is InactiveBanner => banner.active === false; export interface IBannerDismiss extends IRocketChatRecord { - userId: IUser["_id"]; // user receiving the banner dismissed - bannerId: IBanner["_id"]; // banner dismissed - dismissedAt: Date; // when is was dismissed - dismissedBy: Pick; // who dismissed (usually the same as userId) + userId: IUser['_id']; // user receiving the banner dismissed + bannerId: IBanner['_id']; // banner dismissed + dismissedAt: Date; // when is was dismissed + dismissedBy: Pick; // who dismissed (usually the same as userId) } diff --git a/packages/core-typings/src/ICustomEmojiDescriptor.ts b/packages/core-typings/src/ICustomEmojiDescriptor.ts index d47e5db74f6c..1fa3a97cee62 100644 --- a/packages/core-typings/src/ICustomEmojiDescriptor.ts +++ b/packages/core-typings/src/ICustomEmojiDescriptor.ts @@ -1,7 +1,7 @@ -import type { IRocketChatRecord } from "./IRocketChatRecord"; +import type { IRocketChatRecord } from './IRocketChatRecord'; export interface ICustomEmojiDescriptor extends IRocketChatRecord { - name: string; - aliases: string[]; - extension: string; + name: string; + aliases: string[]; + extension: string; } diff --git a/packages/core-typings/src/ICustomSound.ts b/packages/core-typings/src/ICustomSound.ts index 3b2f8a166b64..19596929f752 100644 --- a/packages/core-typings/src/ICustomSound.ts +++ b/packages/core-typings/src/ICustomSound.ts @@ -1,6 +1,6 @@ -import type { IRocketChatRecord } from "./IRocketChatRecord"; +import type { IRocketChatRecord } from './IRocketChatRecord'; export interface ICustomSound extends IRocketChatRecord { - name: string; - statusType: string; + name: string; + statusType: string; } diff --git a/packages/core-typings/src/ICustomUserStatus.ts b/packages/core-typings/src/ICustomUserStatus.ts index 78afda18e3f7..d634d53247fe 100644 --- a/packages/core-typings/src/ICustomUserStatus.ts +++ b/packages/core-typings/src/ICustomUserStatus.ts @@ -1,6 +1,6 @@ -import type { IRocketChatRecord } from "./IRocketChatRecord"; +import type { IRocketChatRecord } from './IRocketChatRecord'; export interface ICustomUserStatus extends IRocketChatRecord { - name: string; - statusType: string; + name: string; + statusType: string; } diff --git a/packages/core-typings/src/IEmojiCustom.ts b/packages/core-typings/src/IEmojiCustom.ts index 41afe49e4737..64c2706fbb2e 100644 --- a/packages/core-typings/src/IEmojiCustom.ts +++ b/packages/core-typings/src/IEmojiCustom.ts @@ -1,7 +1,7 @@ -import type { IRocketChatRecord } from "./IRocketChatRecord"; +import type { IRocketChatRecord } from './IRocketChatRecord'; export interface IEmojiCustom extends IRocketChatRecord { - name: string; - aliases: string; - extension: string; + name: string; + aliases: string; + extension: string; } diff --git a/packages/core-typings/src/IExportOperation.ts b/packages/core-typings/src/IExportOperation.ts index 3c654d6f5a4c..3afcd530d09b 100644 --- a/packages/core-typings/src/IExportOperation.ts +++ b/packages/core-typings/src/IExportOperation.ts @@ -1,16 +1,16 @@ -import type { IRocketChatRecord } from "./IRocketChatRecord"; +import type { IRocketChatRecord } from './IRocketChatRecord'; export interface IExportOperation extends IRocketChatRecord { - roomList?: string[]; - status: string; - fileList: string[]; - generatedFile?: string; - fileId: string; - userNameTable: string; - userData: string; - generatedUserFile: string; - generatedAvatar: string; - exportPath: string; - assetsPath: string; - createdAt: Date; + roomList?: string[]; + status: string; + fileList: string[]; + generatedFile?: string; + fileId: string; + userNameTable: string; + userData: string; + generatedUserFile: string; + generatedAvatar: string; + exportPath: string; + assetsPath: string; + createdAt: Date; } diff --git a/packages/core-typings/src/IImportRecord.ts b/packages/core-typings/src/IImportRecord.ts index 2d8ba9bd2ab1..730e36de83b7 100644 --- a/packages/core-typings/src/IImportRecord.ts +++ b/packages/core-typings/src/IImportRecord.ts @@ -1,36 +1,36 @@ -import type { IImportUser } from "./IImportUser"; -import type { IImportChannel } from "./IImportChannel"; -import type { IImportMessage } from "./IImportMessage"; +import type { IImportUser } from './IImportUser'; +import type { IImportChannel } from './IImportChannel'; +import type { IImportMessage } from './IImportMessage'; -export type IImportRecordType = "user" | "channel" | "message"; +export type IImportRecordType = 'user' | 'channel' | 'message'; export type IImportData = IImportUser | IImportChannel | IImportMessage; export interface IImportRecord { - data: IImportData; - dataType: IImportRecordType; - _id: string; - options?: {}; - errors?: Array<{ - message: string; - stack?: string; - }>; - skipped?: boolean; + data: IImportData; + dataType: IImportRecordType; + _id: string; + options?: {}; + errors?: Array<{ + message: string; + stack?: string; + }>; + skipped?: boolean; } export interface IImportUserRecord extends IImportRecord { - data: IImportUser; - dataType: "user"; + data: IImportUser; + dataType: 'user'; } export interface IImportChannelRecord extends IImportRecord { - data: IImportChannel; - dataType: "channel"; + data: IImportChannel; + dataType: 'channel'; } export interface IImportMessageRecord extends IImportRecord { - data: IImportMessage; - dataType: "message"; - options: { - useQuickInsert?: boolean; - }; + data: IImportMessage; + dataType: 'message'; + options: { + useQuickInsert?: boolean; + }; } diff --git a/packages/core-typings/src/IIncomingMessage.ts b/packages/core-typings/src/IIncomingMessage.ts index 8301c46dd161..0889312784f7 100644 --- a/packages/core-typings/src/IIncomingMessage.ts +++ b/packages/core-typings/src/IIncomingMessage.ts @@ -1,6 +1,6 @@ -import type { IncomingMessage } from "http"; +import type { IncomingMessage } from 'http'; export interface IIncomingMessage extends IncomingMessage { - query: Record; - body: Record; + query: Record; + body: Record; } diff --git a/packages/core-typings/src/IIntegration.ts b/packages/core-typings/src/IIntegration.ts index 8960f55d2fe2..3807cfac1d3a 100644 --- a/packages/core-typings/src/IIntegration.ts +++ b/packages/core-typings/src/IIntegration.ts @@ -1,10 +1,10 @@ -import type { IRocketChatRecord } from "./IRocketChatRecord"; -import type { IUser } from "./IUser"; +import type { IRocketChatRecord } from './IRocketChatRecord'; +import type { IUser } from './IUser'; export interface IIntegration extends IRocketChatRecord { - type: string; - enabled: boolean; - channel: string; - scriptEnabled: boolean; - _createdBy: IUser; + type: string; + enabled: boolean; + channel: string; + scriptEnabled: boolean; + _createdBy: IUser; } diff --git a/packages/core-typings/src/IIntegrationHistory.ts b/packages/core-typings/src/IIntegrationHistory.ts index cc4201c4cfd8..6297cd7d74a0 100644 --- a/packages/core-typings/src/IIntegrationHistory.ts +++ b/packages/core-typings/src/IIntegrationHistory.ts @@ -1,28 +1,28 @@ -import type { IRocketChatRecord } from "./IRocketChatRecord"; +import type { IRocketChatRecord } from './IRocketChatRecord'; export interface IIntegrationHistory extends IRocketChatRecord { - type: string; - step: string; - integration: { - _id: string; - }; - event: string; - _createdAt: Date; - _updatedAt: Date; - data?: { - user?: any; - room?: any; - }; - ranPrepareScript: boolean; - finished: boolean; + type: string; + step: string; + integration: { + _id: string; + }; + event: string; + _createdAt: Date; + _updatedAt: Date; + data?: { + user?: any; + room?: any; + }; + ranPrepareScript: boolean; + finished: boolean; - triggerWord?: string; - prepareSentMessage?: string; - processSentMessage?: string; - url?: string; - httpCallData?: string; - httpError?: any; - httpResult?: string; - error?: any; - errorStack?: any; + triggerWord?: string; + prepareSentMessage?: string; + processSentMessage?: string; + url?: string; + httpCallData?: string; + httpError?: any; + httpResult?: string; + error?: any; + errorStack?: any; } diff --git a/packages/core-typings/src/IInvite.ts b/packages/core-typings/src/IInvite.ts index fe054c821b66..5c8dd1da601f 100644 --- a/packages/core-typings/src/IInvite.ts +++ b/packages/core-typings/src/IInvite.ts @@ -1,11 +1,11 @@ -import type { IRocketChatRecord } from "./IRocketChatRecord"; +import type { IRocketChatRecord } from './IRocketChatRecord'; export interface IInvite extends IRocketChatRecord { - days: number; - maxUses: number; - rid: string; - userId: string; - createdAt: Date; - expires: Date | null; - uses: number; + days: number; + maxUses: number; + rid: string; + userId: string; + createdAt: Date; + expires: Date | null; + uses: number; } diff --git a/packages/core-typings/src/ILivechatAgent.ts b/packages/core-typings/src/ILivechatAgent.ts index ae6c56e4a05d..5457ef642c5a 100644 --- a/packages/core-typings/src/ILivechatAgent.ts +++ b/packages/core-typings/src/ILivechatAgent.ts @@ -1,16 +1,16 @@ -import type { IUser } from "./IUser"; +import type { IUser } from './IUser'; export enum ILivechatAgentStatus { - AVAILABLE = "available", - UNAVAILABLE = "unavailable", + AVAILABLE = 'available', + UNAVAILABLE = 'unavailable', } export interface ILivechatAgent extends IUser { - statusLivechat: ILivechatAgentStatus; - livechat: { - maxNumberSimultaneousChat: number; - }; - livechatCount: number; - lastRoutingTime: Date; - livechatStatusSystemModified?: boolean; + statusLivechat: ILivechatAgentStatus; + livechat: { + maxNumberSimultaneousChat: number; + }; + livechatCount: number; + lastRoutingTime: Date; + livechatStatusSystemModified?: boolean; } diff --git a/packages/core-typings/src/ILivechatAgentActivity.ts b/packages/core-typings/src/ILivechatAgentActivity.ts index cda2634c8fdc..3686ac7c8d07 100644 --- a/packages/core-typings/src/ILivechatAgentActivity.ts +++ b/packages/core-typings/src/ILivechatAgentActivity.ts @@ -1,15 +1,15 @@ -import type { IRocketChatRecord } from "./IRocketChatRecord"; +import type { IRocketChatRecord } from './IRocketChatRecord'; export interface ILivechatAgentActivity extends IRocketChatRecord { - agentId: string; - date: number; - lastStartedAt: Date; - availableTime: number; - serviceHistory: IServiceHistory[]; - lastStoppedAt?: Date; + agentId: string; + date: number; + lastStartedAt: Date; + availableTime: number; + serviceHistory: IServiceHistory[]; + lastStoppedAt?: Date; } export interface IServiceHistory { - startedAt: Date; - stoppedAt: Date; + startedAt: Date; + stoppedAt: Date; } diff --git a/packages/core-typings/src/ILivechatBusinessHour.ts b/packages/core-typings/src/ILivechatBusinessHour.ts index 22d09944e269..9991272a69f4 100644 --- a/packages/core-typings/src/ILivechatBusinessHour.ts +++ b/packages/core-typings/src/ILivechatBusinessHour.ts @@ -1,42 +1,42 @@ -import type { ILivechatDepartment } from "./ILivechatDepartment"; +import type { ILivechatDepartment } from './ILivechatDepartment'; export enum LivechatBusinessHourTypes { - DEFAULT = "default", - CUSTOM = "custom", + DEFAULT = 'default', + CUSTOM = 'custom', } export enum LivechatBusinessHourBehaviors { - SINGLE = "Single", - MULTIPLE = "Multiple", + SINGLE = 'Single', + MULTIPLE = 'Multiple', } interface IBusinessHourTime { - time: string; - utc: { dayOfWeek: string; time: string }; - cron: { dayOfWeek: string; time: string }; + time: string; + utc: { dayOfWeek: string; time: string }; + cron: { dayOfWeek: string; time: string }; } export interface IBusinessHourWorkHour { - day: string; - start: IBusinessHourTime; - finish: IBusinessHourTime; - open: boolean; - code: unknown; + day: string; + start: IBusinessHourTime; + finish: IBusinessHourTime; + open: boolean; + code: unknown; } export interface IBusinessHourTimezone { - name: string; - utc: string; + name: string; + utc: string; } export interface ILivechatBusinessHour { - _id: string; - name: string; - active: boolean; - type: LivechatBusinessHourTypes; - timezone: IBusinessHourTimezone; - ts: Date; - workHours: IBusinessHourWorkHour[]; - _updatedAt?: Date; - departments?: ILivechatDepartment[]; + _id: string; + name: string; + active: boolean; + type: LivechatBusinessHourTypes; + timezone: IBusinessHourTimezone; + ts: Date; + workHours: IBusinessHourWorkHour[]; + _updatedAt?: Date; + departments?: ILivechatDepartment[]; } diff --git a/packages/core-typings/src/ILivechatCustomField.ts b/packages/core-typings/src/ILivechatCustomField.ts index b758487f4715..9f1ce0ffad5f 100644 --- a/packages/core-typings/src/ILivechatCustomField.ts +++ b/packages/core-typings/src/ILivechatCustomField.ts @@ -1,13 +1,13 @@ -import type { IRocketChatRecord } from "./IRocketChatRecord"; +import type { IRocketChatRecord } from './IRocketChatRecord'; export interface ILivechatCustomField extends IRocketChatRecord { - label: string; - scope: "visitor" | "room"; - visibility: string; - type?: string; - regexp?: string; - required?: boolean; - defaultValue?: string; - options?: string; - public?: boolean; + label: string; + scope: 'visitor' | 'room'; + visibility: string; + type?: string; + regexp?: string; + required?: boolean; + defaultValue?: string; + options?: string; + public?: boolean; } diff --git a/packages/core-typings/src/ILivechatDepartmentRecord.ts b/packages/core-typings/src/ILivechatDepartmentRecord.ts index 1bfbd236742f..498432783bab 100644 --- a/packages/core-typings/src/ILivechatDepartmentRecord.ts +++ b/packages/core-typings/src/ILivechatDepartmentRecord.ts @@ -1,19 +1,19 @@ -import type { IRocketChatRecord } from "./IRocketChatRecord"; +import type { IRocketChatRecord } from './IRocketChatRecord'; export interface ILivechatDepartmentRecord extends IRocketChatRecord { - _id: string; - name: string; - enabled: boolean; - description?: string; - showOnRegistration: boolean; - showOnOfflineForm: boolean; - requestTagBeforeClosingChat?: boolean; - email: string; - chatClosingTags?: string[]; - offlineMessageChannelName: string; - numAgents: number; - businessHourId?: string; - fallbackForwardDepartment?: string; - // extra optional fields - [k: string]: any; + _id: string; + name: string; + enabled: boolean; + description?: string; + showOnRegistration: boolean; + showOnOfflineForm: boolean; + requestTagBeforeClosingChat?: boolean; + email: string; + chatClosingTags?: string[]; + offlineMessageChannelName: string; + numAgents: number; + businessHourId?: string; + fallbackForwardDepartment?: string; + // extra optional fields + [k: string]: any; } diff --git a/packages/core-typings/src/ILivechatMonitorRecord.ts b/packages/core-typings/src/ILivechatMonitorRecord.ts index ca2f268af61a..140d80f6662f 100644 --- a/packages/core-typings/src/ILivechatMonitorRecord.ts +++ b/packages/core-typings/src/ILivechatMonitorRecord.ts @@ -1,10 +1,10 @@ -import type { IRocketChatRecord } from "./IRocketChatRecord"; +import type { IRocketChatRecord } from './IRocketChatRecord'; export interface ILivechatMonitorRecord extends IRocketChatRecord { - _id: string; - name: string; - enabled: boolean; - numMonitors: number; - type: string; - visibility: string; + _id: string; + name: string; + enabled: boolean; + numMonitors: number; + type: string; + visibility: string; } diff --git a/packages/core-typings/src/ILivechatTagRecord.ts b/packages/core-typings/src/ILivechatTagRecord.ts index f6195578d9d8..af03bb0cba5f 100644 --- a/packages/core-typings/src/ILivechatTagRecord.ts +++ b/packages/core-typings/src/ILivechatTagRecord.ts @@ -1,9 +1,9 @@ -import type { IRocketChatRecord } from "./IRocketChatRecord"; +import type { IRocketChatRecord } from './IRocketChatRecord'; export interface ILivechatTagRecord extends IRocketChatRecord { - _id: string; - name: string; - description: string; - numDepartments: number; - departments: Array; + _id: string; + name: string; + description: string; + numDepartments: number; + departments: Array; } diff --git a/packages/core-typings/src/ILivechatTrigger.ts b/packages/core-typings/src/ILivechatTrigger.ts index e654820372a8..8d02801ce99f 100644 --- a/packages/core-typings/src/ILivechatTrigger.ts +++ b/packages/core-typings/src/ILivechatTrigger.ts @@ -1,30 +1,30 @@ -import type { IRocketChatRecord } from "./IRocketChatRecord"; +import type { IRocketChatRecord } from './IRocketChatRecord'; export enum ILivechatTriggerType { - TIME_ON_SITE = "time-on-site", - PAGE_URL = "page-url", - CHAT_OPENED_BY_VISITOR = "chat-opened-by-visitor", + TIME_ON_SITE = 'time-on-site', + PAGE_URL = 'page-url', + CHAT_OPENED_BY_VISITOR = 'chat-opened-by-visitor', } export interface ILivechatTriggerCondition { - name: ILivechatTriggerType; - value?: string | number; + name: ILivechatTriggerType; + value?: string | number; } export interface ILivechatTriggerAction { - name: "send-message"; - params?: { - sender: "queue" | "custom"; - msg: string; - name: string; - }; + name: 'send-message'; + params?: { + sender: 'queue' | 'custom'; + msg: string; + name: string; + }; } export interface ILivechatTrigger extends IRocketChatRecord { - name: string; - description: string; - enabled: boolean; - runOnce: boolean; - conditions: ILivechatTriggerCondition[]; - actions: ILivechatTriggerAction[]; + name: string; + description: string; + enabled: boolean; + runOnce: boolean; + conditions: ILivechatTriggerCondition[]; + actions: ILivechatTriggerAction[]; } diff --git a/packages/core-typings/src/ILivechatVisitor.ts b/packages/core-typings/src/ILivechatVisitor.ts index 15a83896fe2d..3145854c3868 100644 --- a/packages/core-typings/src/ILivechatVisitor.ts +++ b/packages/core-typings/src/ILivechatVisitor.ts @@ -1,56 +1,55 @@ -import type { IRocketChatRecord } from "./IRocketChatRecord"; +import type { IRocketChatRecord } from './IRocketChatRecord'; export interface IVisitorPhone { - phoneNumber: string; + phoneNumber: string; } export interface IVisitorLastChat { - _id: string; - ts: string; + _id: string; + ts: string; } export interface ILivechatVisitorConnectionData { - httpHeaders: { - [k: string]: string; - }; - clientAddress: string; + httpHeaders: { + [k: string]: string; + }; + clientAddress: string; } export interface IVisitorEmail { - address: string; + address: string; } export interface ILivechatVisitor extends IRocketChatRecord { - username: string; - ts: Date; - token: string; - department?: string; - name?: string; - phone?: IVisitorPhone[] | null; - lastChat?: IVisitorLastChat; - userAgent?: string; - ip?: string; - host?: string; - visitorEmails?: IVisitorEmail[]; + username: string; + ts: Date; + token: string; + department?: string; + name?: string; + phone?: IVisitorPhone[] | null; + lastChat?: IVisitorLastChat; + userAgent?: string; + ip?: string; + host?: string; + visitorEmails?: IVisitorEmail[]; } export interface ILivechatVisitorDTO { - id?: string; - token: string; - name?: string; - email?: string; - department?: string; - phone?: string | { number: string }; - username?: string; - customFields?: { - key: string; - value: string; - overwrite: boolean; - }[]; - connectionData?: { - httpHeaders: Record; - }; + id?: string; + token: string; + name?: string; + email?: string; + department?: string; + phone?: string | { number: string }; + username?: string; + customFields?: { + key: string; + value: string; + overwrite: boolean; + }[]; + connectionData?: { + httpHeaders: Record; + }; } -export const isILivechatVisitor = (a: any): a is ILivechatVisitor => - typeof a?.token === "string"; +export const isILivechatVisitor = (a: any): a is ILivechatVisitor => typeof a?.token === 'string'; diff --git a/packages/core-typings/src/IMessage/IMessage.ts b/packages/core-typings/src/IMessage/IMessage.ts index c414ca6baff2..2a0e738fdd1c 100644 --- a/packages/core-typings/src/IMessage/IMessage.ts +++ b/packages/core-typings/src/IMessage/IMessage.ts @@ -1,262 +1,234 @@ -import type Icons from "@rocket.chat/icons"; -import type { MessageSurfaceLayout } from "@rocket.chat/ui-kit"; -import type { parser } from "@rocket.chat/message-parser"; +import type Icons from '@rocket.chat/icons'; +import type { MessageSurfaceLayout } from '@rocket.chat/ui-kit'; +import type { parser } from '@rocket.chat/message-parser'; -import type { IRocketChatRecord } from "../IRocketChatRecord"; -import type { IUser } from "../IUser"; -import type { ChannelName, IRoom, RoomID } from "../IRoom"; -import type { MessageAttachment } from "./MessageAttachment/MessageAttachment"; -import type { FileProp } from "./MessageAttachment/Files/FileProp"; +import type { IRocketChatRecord } from '../IRocketChatRecord'; +import type { IUser } from '../IUser'; +import type { IRoom, RoomID } from '../IRoom'; +import type { MessageAttachment } from './MessageAttachment/MessageAttachment'; +import type { FileProp } from './MessageAttachment/Files/FileProp'; -type MentionType = "user" | "team"; +type MentionType = 'user' | 'team'; type MessageUrl = { - url: string; - meta: Record; - headers?: { contentLength: string; contentType: string }; + url: string; + meta: Record; + headers?: { contentLength: string; contentType: string }; }; type VoipMessageTypesValues = - | "voip-call-started" - | "voip-call-declined" - | "voip-call-on-hold" - | "voip-call-unhold" - | "voip-call-ended" - | "voip-call-duration" - | "voip-call-wrapup" - | "voip-call-ended-unexpectedly"; + | 'voip-call-started' + | 'voip-call-declined' + | 'voip-call-on-hold' + | 'voip-call-unhold' + | 'voip-call-ended' + | 'voip-call-duration' + | 'voip-call-wrapup' + | 'voip-call-ended-unexpectedly'; type TeamMessageTypes = - | "removed-user-from-team" - | "added-user-to-team" - | "ult" - | "user-converted-to-team" - | "user-converted-to-channel" - | "user-removed-room-from-team" - | "user-deleted-room-from-team" - | "user-added-room-to-team" - | "ujt"; - -type OmnichannelTypesValues = - | "livechat_transfer_history_fallback" - | "livechat-close"; - -type OtrSystemMessages = - | "user_joined_otr" - | "user_requested_otr_key_refresh" - | "user_key_refreshed_successfully"; + | 'removed-user-from-team' + | 'added-user-to-team' + | 'ult' + | 'user-converted-to-team' + | 'user-converted-to-channel' + | 'user-removed-room-from-team' + | 'user-deleted-room-from-team' + | 'user-added-room-to-team' + | 'ujt'; + +type OmnichannelTypesValues = 'livechat_transfer_history_fallback' | 'livechat-close'; + +type OtrSystemMessages = 'user_joined_otr' | 'user_requested_otr_key_refresh' | 'user_key_refreshed_successfully'; export type MessageTypesValues = - | "e2e" - | "uj" - | "ul" - | "ru" - | "au" - | "mute_unmute" - | "r" - | "ut" - | "wm" - | "rm" - | "subscription-role-added" - | "subscription-role-removed" - | "room-archived" - | "room-unarchived" - | "room_changed_privacy" - | "room_changed_description" - | "room_changed_announcement" - | "room_changed_avatar" - | "room_changed_topic" - | "room_e2e_enabled" - | "room_e2e_disabled" - | "user-muted" - | "user-unmuted" - | "room-removed-read-only" - | "room-set-read-only" - | "room-allowed-reacting" - | "room-disallowed-reacting" - | TeamMessageTypes - | VoipMessageTypesValues - | OmnichannelTypesValues - | OtrSystemMessages; + | 'e2e' + | 'uj' + | 'ul' + | 'ru' + | 'au' + | 'mute_unmute' + | 'r' + | 'ut' + | 'wm' + | 'rm' + | 'subscription-role-added' + | 'subscription-role-removed' + | 'room-archived' + | 'room-unarchived' + | 'room_changed_privacy' + | 'room_changed_description' + | 'room_changed_announcement' + | 'room_changed_avatar' + | 'room_changed_topic' + | 'room_e2e_enabled' + | 'room_e2e_disabled' + | 'user-muted' + | 'user-unmuted' + | 'room-removed-read-only' + | 'room-set-read-only' + | 'room-allowed-reacting' + | 'room-disallowed-reacting' + | TeamMessageTypes + | VoipMessageTypesValues + | OmnichannelTypesValues + | OtrSystemMessages; export interface IMessage extends IRocketChatRecord { - rid: RoomID; - msg: string; - tmid?: string; - ts: Date; - mentions?: ({ - type: MentionType; - } & Pick)[]; - - groupable?: false; - channels?: Pick[]; - u: Required>; - blocks?: MessageSurfaceLayout; - alias?: string; - md?: ReturnType; - - // TODO: chapter day frontend - wrong type - ignored?: boolean; - _hidden?: boolean; - imported?: boolean; - replies?: IUser["_id"][]; - location?: { - type: "Point"; - coordinates: [string, string]; - }; - starred?: { _id: IUser["_id"] }[]; - pinned?: boolean; - unread?: boolean; - temp?: boolean; - drid?: RoomID; - tlm?: Date; - - dcount?: number; - tcount?: number; - t?: MessageTypesValues; - e2e?: "pending" | "done"; - - urls?: MessageUrl[]; - - /** @deprecated Deprecated */ - actionLinks?: { - icon: keyof typeof Icons; - i18nLabel: unknown; - label: string; - method_id: string; - params: string; - }[]; - - /** @deprecated Deprecated in favor of files */ - file?: FileProp; - files?: FileProp[]; - attachments?: MessageAttachment[]; - - reactions?: { - [key: string]: { names?: (string | undefined)[]; usernames: string[] }; - }; - - private?: boolean; - /* @deprecated */ - bot?: boolean; - sentByEmail?: boolean; - webRtcCallEndTs?: Date; - role?: string; - - avatar?: string; - emoji?: string; + rid: RoomID; + msg: string; + tmid?: string; + ts: Date; + mentions?: ({ + type: MentionType; + } & Pick)[]; + + groupable?: false; + channels?: Pick[]; + u: Required>; + blocks?: MessageSurfaceLayout; + alias?: string; + md?: ReturnType; + + // TODO: chapter day frontend - wrong type + ignored?: boolean; + _hidden?: boolean; + imported?: boolean; + replies?: IUser['_id'][]; + location?: { + type: 'Point'; + coordinates: [string, string]; + }; + starred?: { _id: IUser['_id'] }[]; + pinned?: boolean; + unread?: boolean; + temp?: boolean; + drid?: RoomID; + tlm?: Date; + + dcount?: number; + tcount?: number; + t?: MessageTypesValues; + e2e?: 'pending' | 'done'; + + urls?: MessageUrl[]; + + /** @deprecated Deprecated */ + actionLinks?: { + icon: keyof typeof Icons; + i18nLabel: unknown; + label: string; + method_id: string; + params: string; + }[]; + + /** @deprecated Deprecated in favor of files */ + file?: FileProp; + files?: FileProp[]; + attachments?: MessageAttachment[]; + + reactions?: { + [key: string]: { names?: (string | undefined)[]; usernames: string[] }; + }; + + private?: boolean; + /* @deprecated */ + bot?: boolean; + sentByEmail?: boolean; + webRtcCallEndTs?: Date; + role?: string; + + avatar?: string; + emoji?: string; } export type MessageSystem = { - t: "system"; + t: 'system'; }; export interface IEditedMessage extends IMessage { - editedAt: Date; - editedBy: Pick; + editedAt: Date; + editedBy: Pick; } -export const isEditedMessage = (message: IMessage): message is IEditedMessage => - "editedAt" in message && "editedBy" in message; +export const isEditedMessage = (message: IMessage): message is IEditedMessage => 'editedAt' in message && 'editedBy' in message; export interface ITranslatedMessage extends IMessage { - translations: { [key: string]: unknown }; + translations: { [key: string]: unknown }; } -export const isTranslatedMessage = ( - message: IMessage -): message is ITranslatedMessage => "translations" in message; +export const isTranslatedMessage = (message: IMessage): message is ITranslatedMessage => 'translations' in message; export interface IThreadMainMessage extends IMessage { - tcount: number; - tlm: Date; - replies: IUser["_id"][]; + tcount: number; + tlm: Date; + replies: IUser['_id'][]; } export interface IThreadMessage extends IMessage { - tmid: string; + tmid: string; } -export const isThreadMainMessage = ( - message: IMessage -): message is IThreadMainMessage => "tcount" in message && "tlm" in message; +export const isThreadMainMessage = (message: IMessage): message is IThreadMainMessage => 'tcount' in message && 'tlm' in message; -export const isThreadMessage = (message: IMessage): message is IThreadMessage => - !!message.tmid; +export const isThreadMessage = (message: IMessage): message is IThreadMessage => !!message.tmid; export interface IDiscussionMessage extends IMessage { - drid: string; - dlm?: Date; - dcount: number; + drid: string; + dlm?: Date; + dcount: number; } -export const isDiscussionMessage = ( - message: IMessage -): message is IDiscussionMessage => !!message.drid; +export const isDiscussionMessage = (message: IMessage): message is IDiscussionMessage => !!message.drid; export interface IPrivateMessage extends IMessage { - private: true; + private: true; } -export const isPrivateMessage = ( - message: IMessage -): message is IPrivateMessage => !!message.private; +export const isPrivateMessage = (message: IMessage): message is IPrivateMessage => !!message.private; export interface IMessageReactionsNormalized extends IMessage { - reactions: { - [key: string]: { - usernames: Required[]; - names: Required["name"][]; - }; - }; + reactions: { + [key: string]: { + usernames: Required[]; + names: Required['name'][]; + }; + }; } -export const isMessageReactionsNormalized = ( - message: IMessage -): message is IMessageReactionsNormalized => - Boolean( - "reactions" in message && - message.reactions && - message.reactions[0] && - "names" in message.reactions[0] - ); +export const isMessageReactionsNormalized = (message: IMessage): message is IMessageReactionsNormalized => + Boolean('reactions' in message && message.reactions && message.reactions[0] && 'names' in message.reactions[0]); export type IVoipMessage = IMessage & { - voipData: { - callDuration?: number; - callStarted?: string; - callWaitingTime?: string; - }; + voipData: { + callDuration?: number; + callStarted?: string; + callWaitingTime?: string; + }; }; export interface IMessageDiscussion extends IMessage { - drid: RoomID; + drid: RoomID; } -export const isMessageDiscussion = ( - message: IMessage -): message is IMessageDiscussion => { - return "drid" in message; +export const isMessageDiscussion = (message: IMessage): message is IMessageDiscussion => { + return 'drid' in message; }; export type IMessageEdited = IMessage & { - editedAt: Date; - editedBy: Pick; + editedAt: Date; + editedBy: Pick; }; -export const isMessageEdited = ( - message: IMessage -): message is IMessageEdited => { - return "editedAt" in message && "editedBy" in message; +export const isMessageEdited = (message: IMessage): message is IMessageEdited => { + return 'editedAt' in message && 'editedBy' in message; }; export type IMessageInbox = IMessage & { - // email inbox fields - email?: { - references?: string[]; - messageId?: string; - }; + // email inbox fields + email?: { + references?: string[]; + messageId?: string; + }; }; -export const isIMessageInbox = (message: IMessage): message is IMessageInbox => - "email" in message; -export const isVoipMessage = (message: IMessage): message is IVoipMessage => - "voipData" in message; +export const isIMessageInbox = (message: IMessage): message is IMessageInbox => 'email' in message; +export const isVoipMessage = (message: IMessage): message is IVoipMessage => 'voipData' in message; diff --git a/packages/core-typings/src/IMethodType.ts b/packages/core-typings/src/IMethodType.ts index 4eb40c5cc1b2..7a9b116a429c 100644 --- a/packages/core-typings/src/IMethodType.ts +++ b/packages/core-typings/src/IMethodType.ts @@ -1,5 +1,5 @@ -import type { IMethodThisType } from "./IMethodThisType"; +import type { IMethodThisType } from './IMethodThisType'; export interface IMethodType { - [key: string]: (this: IMethodThisType, ...args: any[]) => any; + [key: string]: (this: IMethodThisType, ...args: any[]) => any; } diff --git a/packages/core-typings/src/INotification.ts b/packages/core-typings/src/INotification.ts index bb6999a61483..a5fc9155eba8 100644 --- a/packages/core-typings/src/INotification.ts +++ b/packages/core-typings/src/INotification.ts @@ -1,66 +1,66 @@ -import type { IMessage } from "./IMessage"; -import type { IRoom } from "./IRoom"; +import type { IMessage } from './IMessage'; +import type { IRoom } from './IRoom'; export interface INotificationItemPush { - type: "push"; - data: { - payload: { - sender: { - _id: string; - username: string; - name?: string; - }; - type: string; - }; - roomName: string; - username: string; - message: string; - badge: number; - category: string; - }; + type: 'push'; + data: { + payload: { + sender: { + _id: string; + username: string; + name?: string; + }; + type: string; + }; + roomName: string; + username: string; + message: string; + badge: number; + category: string; + }; } export interface INotificationItemEmail { - type: "email"; - data: { - to: string; - subject: string; - html: string; - data: { - room_path: string; - }; - from: string; - }; + type: 'email'; + data: { + to: string; + subject: string; + html: string; + data: { + room_path: string; + }; + from: string; + }; } export type NotificationItem = INotificationItemPush | INotificationItemEmail; export interface INotification { - _id: string; - uid: string; - rid: string; - mid: string; - ts: Date; - schedule?: Date; - sending?: Date; - error?: string; - items: NotificationItem[]; + _id: string; + uid: string; + rid: string; + mid: string; + ts: Date; + schedule?: Date; + sending?: Date; + error?: string; + items: NotificationItem[]; } export interface INotificationDesktop { - title: string; - text: string; - duration?: number; - payload: { - _id: IMessage["_id"]; - rid: IMessage["rid"]; - tmid?: IMessage["tmid"]; - sender: IMessage["u"]; - type: IRoom["t"]; - name: IRoom["name"]; - message: { - msg: IMessage["msg"]; - t?: IMessage["t"]; - }; - }; + title: string; + text: string; + duration?: number; + payload: { + _id: IMessage['_id']; + rid: IMessage['rid']; + tmid?: IMessage['tmid']; + sender: IMessage['u']; + type: IRoom['t']; + name: IRoom['name']; + message: { + msg: IMessage['msg']; + t?: IMessage['t']; + }; + }; } diff --git a/packages/core-typings/src/INps.ts b/packages/core-typings/src/INps.ts index c8751ea0f401..e89796d9d9a4 100644 --- a/packages/core-typings/src/INps.ts +++ b/packages/core-typings/src/INps.ts @@ -1,35 +1,35 @@ -import type { IRocketChatRecord } from "./IRocketChatRecord"; -import type { IUser } from "./IUser"; +import type { IRocketChatRecord } from './IRocketChatRecord'; +import type { IUser } from './IUser'; export enum NPSStatus { - OPEN = "open", - SENDING = "sending", - SENT = "sent", - CLOSED = "closed", + OPEN = 'open', + SENDING = 'sending', + SENT = 'sent', + CLOSED = 'closed', } export interface INps extends IRocketChatRecord { - startAt: Date; // start date a banner should be presented - expireAt: Date; // date when banner should not be shown anymore - createdBy: Pick; - createdAt: Date; - status: NPSStatus; + startAt: Date; // start date a banner should be presented + expireAt: Date; // date when banner should not be shown anymore + createdBy: Pick; + createdAt: Date; + status: NPSStatus; } export enum INpsVoteStatus { - NEW = "new", - SENDING = "sending", - SENT = "sent", + NEW = 'new', + SENDING = 'sending', + SENT = 'sent', } export interface INpsVote extends IRocketChatRecord { - _id: string; - npsId: INps["_id"]; - ts: Date; - identifier: string; // voter identifier - roles: IUser["roles"]; // voter roles - score: number; - comment: string; - status: INpsVoteStatus; - sentAt?: Date; + _id: string; + npsId: INps['_id']; + ts: Date; + identifier: string; // voter identifier + roles: IUser['roles']; // voter roles + score: number; + comment: string; + status: INpsVoteStatus; + sentAt?: Date; } diff --git a/packages/core-typings/src/IOmnichannelAgent.ts b/packages/core-typings/src/IOmnichannelAgent.ts index 927ce7ad63d3..390452d8b35e 100644 --- a/packages/core-typings/src/IOmnichannelAgent.ts +++ b/packages/core-typings/src/IOmnichannelAgent.ts @@ -1,7 +1,7 @@ -import type { IUser } from "./IUser"; +import type { IUser } from './IUser'; export interface IOmnichannelAgent extends IUser { - statusLivechat: OmnichannelAgentStatus; + statusLivechat: OmnichannelAgentStatus; } -export type OmnichannelAgentStatus = "available" | "not-available"; +export type OmnichannelAgentStatus = 'available' | 'not-available'; diff --git a/packages/core-typings/src/IOmnichannelCannedResponse.ts b/packages/core-typings/src/IOmnichannelCannedResponse.ts index defbda2bc2d5..7ae9fe26751e 100644 --- a/packages/core-typings/src/IOmnichannelCannedResponse.ts +++ b/packages/core-typings/src/IOmnichannelCannedResponse.ts @@ -1,17 +1,17 @@ -import type { ILivechatDepartment } from "./ILivechatDepartment"; -import type { IRocketChatRecord } from "./IRocketChatRecord"; -import type { IUser } from "./IUser"; +import type { ILivechatDepartment } from './ILivechatDepartment'; +import type { IRocketChatRecord } from './IRocketChatRecord'; +import type { IUser } from './IUser'; export interface IOmnichannelCannedResponse extends IRocketChatRecord { - shortcut: string; - text: string; - scope: string; - tags: any; - userId: IUser["_id"]; - departmentId?: ILivechatDepartment["_id"]; - createdBy: { - _id: IUser["_id"]; - username: string; - }; - _createdAt: Date; + shortcut: string; + text: string; + scope: string; + tags: any; + userId: IUser['_id']; + departmentId?: ILivechatDepartment['_id']; + createdBy: { + _id: IUser['_id']; + username: string; + }; + _createdAt: Date; } diff --git a/packages/core-typings/src/IOmnichannelVoipServiceResult.ts b/packages/core-typings/src/IOmnichannelVoipServiceResult.ts index 639369fb5cd8..ca30086a976a 100644 --- a/packages/core-typings/src/IOmnichannelVoipServiceResult.ts +++ b/packages/core-typings/src/IOmnichannelVoipServiceResult.ts @@ -1,12 +1,12 @@ -import type { IVoipRoom } from "./IRoom"; +import type { IVoipRoom } from './IRoom'; export interface IAgentExtensionMap { - _id: string; - agentName: string; - extension: string; + _id: string; + agentName: string; + extension: string; } export interface IRoomCreationResponse { - newRoom: boolean; - room: IVoipRoom; + newRoom: boolean; + room: IVoipRoom; } diff --git a/packages/core-typings/src/IPbxEvent.ts b/packages/core-typings/src/IPbxEvent.ts index 251ea326673a..b3fde05d6794 100644 --- a/packages/core-typings/src/IPbxEvent.ts +++ b/packages/core-typings/src/IPbxEvent.ts @@ -1,17 +1,17 @@ -import type { IRocketChatRecord } from "./IRocketChatRecord"; +import type { IRocketChatRecord } from './IRocketChatRecord'; export interface IPbxEvent extends IRocketChatRecord { - uniqueId: string; - event: string; - phone?: string; // calleridnum - queue?: string; // queue - ts: Date; // the moment when event happened - holdTime?: string; - callUniqueId?: string; - // most of the times, this will be the same as callUniqueId - // theres some scenarios where the "channel" of the call changed - // and therefore a new "link" will be created for the call. That will generate a - // new uniqueId for events - callUniqueIdFallback?: string; - agentExtension?: string; + uniqueId: string; + event: string; + phone?: string; // calleridnum + queue?: string; // queue + ts: Date; // the moment when event happened + holdTime?: string; + callUniqueId?: string; + // most of the times, this will be the same as callUniqueId + // theres some scenarios where the "channel" of the call changed + // and therefore a new "link" will be created for the call. That will generate a + // new uniqueId for events + callUniqueIdFallback?: string; + agentExtension?: string; } diff --git a/packages/core-typings/src/IReport.ts b/packages/core-typings/src/IReport.ts index e14e5871bd9b..ab2da9317bd7 100644 --- a/packages/core-typings/src/IReport.ts +++ b/packages/core-typings/src/IReport.ts @@ -1,9 +1,9 @@ -import type { IRocketChatRecord } from "./IRocketChatRecord"; -import type { IMessage } from "./IMessage/IMessage"; +import type { IRocketChatRecord } from './IRocketChatRecord'; +import type { IMessage } from './IMessage/IMessage'; export interface IReport extends IRocketChatRecord { - message: IMessage; - description: string; - ts: Date; - userId: string; + message: IMessage; + description: string; + ts: Date; + userId: string; } diff --git a/packages/core-typings/src/IRole.ts b/packages/core-typings/src/IRole.ts index ba1f0d4d5edb..d0f15f3a9f23 100644 --- a/packages/core-typings/src/IRole.ts +++ b/packages/core-typings/src/IRole.ts @@ -1 +1,8 @@ -export { IRole } from './IUser'; +export interface IRole { + description: string; + mandatory2fa?: boolean; + name: string; + protected: boolean; + scope: 'Users' | 'Subscriptions'; + _id: string; +} diff --git a/packages/core-typings/src/IRoom.ts b/packages/core-typings/src/IRoom.ts index 65cf9bb23b81..4a663543a2a7 100644 --- a/packages/core-typings/src/IRoom.ts +++ b/packages/core-typings/src/IRoom.ts @@ -1,259 +1,236 @@ -import type { IRocketChatRecord } from "./IRocketChatRecord"; -import type { IMessage } from "./IMessage"; -import type { IUser, Username } from "./IUser"; -import type { RoomType } from "./RoomType"; +import type { IRocketChatRecord } from './IRocketChatRecord'; +import type { IMessage } from './IMessage'; +import type { IUser, Username } from './IUser'; +import type { RoomType } from './RoomType'; -type CallStatus = "ringing" | "ended" | "declined" | "ongoing"; +type CallStatus = 'ringing' | 'ended' | 'declined' | 'ongoing'; export type RoomID = string; export type ChannelName = string; interface IRequestTranscript { - email: string; - requestedAt: Date; - requestedBy: IUser; - subject: string; + email: string; + requestedAt: Date; + requestedBy: IUser; + subject: string; } export interface IRoom extends IRocketChatRecord { - _id: RoomID; - t: RoomType; - name?: string; - fname?: string; - msgs: number; - default?: true; - broadcast?: true; - featured?: true; - announcement?: string; - encrypted?: boolean; - topic?: string; - - reactWhenReadOnly?: boolean; - - sysMes?: string[]; - - u: Pick; - uids?: Array; - - lastMessage?: IMessage; - lm?: Date; - usersCount: number; - jitsiTimeout?: Date; - callStatus?: CallStatus; - webRtcCallStartTime?: Date; - servedBy?: { - _id: string; - }; - - streamingOptions?: { - id?: string; - type: string; - }; - - prid?: string; - avatarETag?: string; - tokenpass?: { - require: string; - tokens: { - token: string; - balance: number; - }[]; - }; - - teamMain?: boolean; - teamId?: string; - teamDefault?: boolean; - open?: boolean; - - autoTranslateLanguage: string; - autoTranslate?: boolean; - unread?: number; - alert?: boolean; - hideUnreadStatus?: boolean; - - muted?: string[]; - unmuted?: string[]; - - usernames?: string[]; - ts?: Date; - - cl?: boolean; - ro?: boolean; - favorite?: boolean; - archived?: boolean; - description?: string; - createdOTR?: boolean; - e2eKeyId?: string; + _id: RoomID; + t: RoomType; + name?: string; + fname?: string; + msgs: number; + default?: true; + broadcast?: true; + featured?: true; + announcement?: string; + encrypted?: boolean; + topic?: string; + + reactWhenReadOnly?: boolean; + + sysMes?: string[]; + + u: Pick; + uids?: Array; + + lastMessage?: IMessage; + lm?: Date; + usersCount: number; + jitsiTimeout?: Date; + callStatus?: CallStatus; + webRtcCallStartTime?: Date; + servedBy?: { + _id: string; + }; + + streamingOptions?: { + id?: string; + type: string; + }; + + prid?: string; + avatarETag?: string; + tokenpass?: { + require: string; + tokens: { + token: string; + balance: number; + }[]; + }; + + teamMain?: boolean; + teamId?: string; + teamDefault?: boolean; + open?: boolean; + + autoTranslateLanguage: string; + autoTranslate?: boolean; + unread?: number; + alert?: boolean; + hideUnreadStatus?: boolean; + + muted?: string[]; + unmuted?: string[]; + + usernames?: string[]; + ts?: Date; + + cl?: boolean; + ro?: boolean; + favorite?: boolean; + archived?: boolean; + description?: string; + createdOTR?: boolean; + e2eKeyId?: string; } export interface ICreatedRoom extends IRoom { - rid: string; + rid: string; } export interface ITeamRoom extends IRoom { - teamMain: boolean; - teamId: string; + teamMain: boolean; + teamId: string; } -export const isTeamRoom = (room: Partial): room is ITeamRoom => - !!room.teamMain; -export const isPrivateTeamRoom = (room: Partial): room is ITeamRoom => - isTeamRoom(room) && room.t === "p"; -export const isPublicTeamRoom = (room: Partial): room is ITeamRoom => - isTeamRoom(room) && room.t === "c"; - -export const isDiscussion = (room: Partial): room is IRoom => - !!room.prid; -export const isPrivateDiscussion = (room: Partial): room is IRoom => - isDiscussion(room) && room.t === "p"; -export const isPublicDiscussion = (room: Partial): room is IRoom => - isDiscussion(room) && room.t === "c"; - -export interface IDirectMessageRoom - extends Omit { - t: "d"; - uids: Array; - usernames: Array; +export const isTeamRoom = (room: Partial): room is ITeamRoom => !!room.teamMain; +export const isPrivateTeamRoom = (room: Partial): room is ITeamRoom => isTeamRoom(room) && room.t === 'p'; +export const isPublicTeamRoom = (room: Partial): room is ITeamRoom => isTeamRoom(room) && room.t === 'c'; + +export const isDiscussion = (room: Partial): room is IRoom => !!room.prid; +export const isPrivateDiscussion = (room: Partial): room is IRoom => isDiscussion(room) && room.t === 'p'; +export const isPublicDiscussion = (room: Partial): room is IRoom => isDiscussion(room) && room.t === 'c'; + +export interface IDirectMessageRoom extends Omit { + t: 'd'; + uids: Array; + usernames: Array; } -export const isDirectMessageRoom = ( - room: IRoom | IDirectMessageRoom -): room is IDirectMessageRoom => room.t === "d"; -export const isMultipleDirectMessageRoom = ( - room: IRoom | IDirectMessageRoom -): room is IDirectMessageRoom => - isDirectMessageRoom(room) && room.uids.length > 2; +export const isDirectMessageRoom = (room: IRoom | IDirectMessageRoom): room is IDirectMessageRoom => room.t === 'd'; +export const isMultipleDirectMessageRoom = (room: IRoom | IDirectMessageRoom): room is IDirectMessageRoom => + isDirectMessageRoom(room) && room.uids.length > 2; export enum OmnichannelSourceType { - WIDGET = "widget", - EMAIL = "email", - SMS = "sms", - APP = "app", - API = "api", - OTHER = "other", // catch-all source type + WIDGET = 'widget', + EMAIL = 'email', + SMS = 'sms', + APP = 'app', + API = 'api', + OTHER = 'other', // catch-all source type } -export interface IOmnichannelGenericRoom - extends Omit { - t: "l" | "v"; - v: { - _id?: string; - token?: string; - status: "online" | "busy" | "away" | "offline"; - }; - email?: { - // Data used when the room is created from an email, via email Integration. - inbox: string; - thread: string; - replyTo: string; - subject: string; - }; - source: { - // TODO: looks like this is not so required as the definition suggests - // The source, or client, which created the Omnichannel room - type: OmnichannelSourceType; - // An optional identification of external sources, such as an App - id?: string; - // A human readable alias that goes with the ID, for post analytical purposes - alias?: string; - // A label to be shown in the room info - label?: string; - // The sidebar icon - sidebarIcon?: string; - // The default sidebar icon - defaultIcon?: string; - }; - transcriptRequest?: IRequestTranscript; - servedBy?: { - _id: string; - ts: Date; - username: IUser["username"]; - }; - onHold?: boolean; - departmentId?: string; - - lastMessage?: IMessage & { token?: string }; - - tags?: any; - closedAt?: Date; - metrics?: any; - waitingResponse: any; - responseBy: any; - priorityId: any; - livechatData: any; - queuedAt?: Date; - - ts: Date; - label?: string; - crmData?: unknown; - - // optional keys for closed rooms - closer?: "user" | "visitor"; - closedBy?: { - _id: string; - username: IUser["username"]; - }; +export interface IOmnichannelGenericRoom extends Omit { + t: 'l' | 'v'; + v: { + _id?: string; + token?: string; + status: 'online' | 'busy' | 'away' | 'offline'; + }; + email?: { + // Data used when the room is created from an email, via email Integration. + inbox: string; + thread: string; + replyTo: string; + subject: string; + }; + source: { + // TODO: looks like this is not so required as the definition suggests + // The source, or client, which created the Omnichannel room + type: OmnichannelSourceType; + // An optional identification of external sources, such as an App + id?: string; + // A human readable alias that goes with the ID, for post analytical purposes + alias?: string; + // A label to be shown in the room info + label?: string; + // The sidebar icon + sidebarIcon?: string; + // The default sidebar icon + defaultIcon?: string; + }; + transcriptRequest?: IRequestTranscript; + servedBy?: { + _id: string; + ts: Date; + username: IUser['username']; + }; + onHold?: boolean; + departmentId?: string; + + lastMessage?: IMessage & { token?: string }; + + tags?: any; + closedAt?: Date; + metrics?: any; + waitingResponse: any; + responseBy: any; + priorityId: any; + livechatData: any; + queuedAt?: Date; + + ts: Date; + label?: string; + crmData?: unknown; + + // optional keys for closed rooms + closer?: 'user' | 'visitor'; + closedBy?: { + _id: string; + username: IUser['username']; + }; } export interface IOmnichannelRoom extends IOmnichannelGenericRoom { - t: "l"; + t: 'l'; } export interface IVoipRoom extends IOmnichannelGenericRoom { - t: "v"; - // The timestamp when call was started - callStarted: Date; - // The amount of time the call lasted, in milliseconds - callDuration?: number; - // The amount of time call was in queue in milliseconds - callWaitingTime?: number; - // The total of hold time for call (calculated at closing time) in seconds - callTotalHoldTime?: number; - // The pbx queue the call belongs to - queue: string; - // The ID assigned to the call (opaque ID) - callUniqueId?: string; - v: { - _id?: string; - token?: string; - status: "online" | "busy" | "away" | "offline"; - phone?: string | null; - }; + t: 'v'; + // The timestamp when call was started + callStarted: Date; + // The amount of time the call lasted, in milliseconds + callDuration?: number; + // The amount of time call was in queue in milliseconds + callWaitingTime?: number; + // The total of hold time for call (calculated at closing time) in seconds + callTotalHoldTime?: number; + // The pbx queue the call belongs to + queue: string; + // The ID assigned to the call (opaque ID) + callUniqueId?: string; + v: { + _id?: string; + token?: string; + status: 'online' | 'busy' | 'away' | 'offline'; + phone?: string | null; + }; } export interface IOmnichannelRoomFromAppSource extends IOmnichannelRoom { - source: { - type: OmnichannelSourceType.APP; - id: string; - alias?: string; - sidebarIcon?: string; - defaultIcon?: string; - }; + source: { + type: OmnichannelSourceType.APP; + id: string; + alias?: string; + sidebarIcon?: string; + defaultIcon?: string; + }; } -export type IRoomClosingInfo = Pick< - IOmnichannelGenericRoom, - "closer" | "closedBy" | "closedAt" | "tags" -> & - Pick & { - serviceTimeDuration?: number; - }; - -export const isOmnichannelRoom = ( - room: IRoom -): room is IOmnichannelRoom & IRoom => room.t === "l"; - -export const isVoipRoom = (room: IRoom): room is IVoipRoom & IRoom => - room.t === "v"; - -export const isOmnichannelRoomFromAppSource = ( - room: IRoom -): room is IOmnichannelRoomFromAppSource => { - if (!isOmnichannelRoom(room)) { - return false; - } - - return room.source?.type === OmnichannelSourceType.APP; -}; +export type IRoomClosingInfo = Pick & + Pick & { + serviceTimeDuration?: number; + }; + +export const isOmnichannelRoom = (room: IRoom): room is IOmnichannelRoom & IRoom => room.t === 'l'; -/** @deprecated */ -export { RoomType }; +export const isVoipRoom = (room: IRoom): room is IVoipRoom & IRoom => room.t === 'v'; + +export const isOmnichannelRoomFromAppSource = (room: IRoom): room is IOmnichannelRoomFromAppSource => { + if (!isOmnichannelRoom(room)) { + return false; + } + + return room.source?.type === OmnichannelSourceType.APP; +}; diff --git a/packages/core-typings/src/IServerEvent.ts b/packages/core-typings/src/IServerEvent.ts index ae04e204f861..c920f2dd5cb5 100644 --- a/packages/core-typings/src/IServerEvent.ts +++ b/packages/core-typings/src/IServerEvent.ts @@ -1,14 +1,14 @@ -import type { IUser } from "./IUser"; +import type { IUser } from './IUser'; export enum ServerEventType { - FAILED_LOGIN_ATTEMPT = "failed-login-attempt", - LOGIN = "login", + FAILED_LOGIN_ATTEMPT = 'failed-login-attempt', + LOGIN = 'login', } export interface IServerEvent { - _id: string; - t: ServerEventType; - ts: Date; - ip: string; - u?: Partial>; + _id: string; + t: ServerEventType; + ts: Date; + ip: string; + u?: Partial>; } diff --git a/packages/core-typings/src/ISetting.ts b/packages/core-typings/src/ISetting.ts index c1a85c9c470a..cdde985ff0c5 100644 --- a/packages/core-typings/src/ISetting.ts +++ b/packages/core-typings/src/ISetting.ts @@ -1,4 +1,4 @@ -import type { FilterQuery } from "mongodb"; +import type { FilterQuery } from 'mongodb'; export type SettingId = string; export type GroupId = SettingId; @@ -6,262 +6,238 @@ export type TabId = SettingId; export type SectionName = string; export enum SettingEditor { - COLOR = "color", - EXPRESSION = "expression", + COLOR = 'color', + EXPRESSION = 'expression', } type AssetValue = { defaultUrl?: string }; export type SettingValueMultiSelect = (string | number)[]; -export type SettingValueRoomPick = - | Array<{ _id: string; name: string }> - | string; -export type SettingValue = - | string - | boolean - | number - | SettingValueMultiSelect - | Date - | AssetValue - | undefined; +export type SettingValueRoomPick = Array<{ _id: string; name: string }> | string; +export type SettingValue = string | boolean | number | SettingValueMultiSelect | Date | AssetValue | undefined; export interface ISettingSelectOption { - key: string | number; - i18nLabel: string; + key: string | number; + i18nLabel: string; } -export type ISetting = - | ISettingBase - | ISettingEnterprise - | ISettingColor - | ISettingCode - | ISettingAction; +export type ISetting = ISettingBase | ISettingEnterprise | ISettingColor | ISettingCode | ISettingAction; export interface ISettingBase { - _id: SettingId; - type: - | "boolean" - | "timezone" - | "string" - | "relativeUrl" - | "password" - | "int" - | "select" - | "multiSelect" - | "language" - | "color" - | "font" - | "code" - | "action" - | "asset" - | "roomPick" - | "group" - | "date"; - public: boolean; - env: boolean; - group?: GroupId; - section?: SectionName; - tab?: TabId; - i18nLabel: string; - value: SettingValue; - packageValue: SettingValue; - blocked: boolean; - enableQuery?: string | FilterQuery | FilterQuery[]; - displayQuery?: string | FilterQuery | FilterQuery[]; - sorter: number; - properties?: unknown; - enterprise?: boolean; - requiredOnWizard?: boolean; - hidden?: boolean; - modules?: Array; - invalidValue?: SettingValue; - valueSource?: string; - secret?: boolean; - i18nDescription?: string; - autocomplete?: boolean; - processEnvValue?: SettingValue; - meteorSettingsValue?: SettingValue; - ts: Date; - createdAt: Date; - _updatedAt?: Date; - multiline?: boolean; - values?: Array; - placeholder?: string; - wizard?: { - step: number; - order: number; - } | null; - persistent?: boolean; // todo: remove - readonly?: boolean; // todo: remove - alert?: string; // todo: check if this is still used - private?: boolean; // todo: remove + _id: SettingId; + type: + | 'boolean' + | 'timezone' + | 'string' + | 'relativeUrl' + | 'password' + | 'int' + | 'select' + | 'multiSelect' + | 'language' + | 'color' + | 'font' + | 'code' + | 'action' + | 'asset' + | 'roomPick' + | 'group' + | 'date'; + public: boolean; + env: boolean; + group?: GroupId; + section?: SectionName; + tab?: TabId; + i18nLabel: string; + value: SettingValue; + packageValue: SettingValue; + blocked: boolean; + enableQuery?: string | FilterQuery | FilterQuery[]; + displayQuery?: string | FilterQuery | FilterQuery[]; + sorter: number; + properties?: unknown; + enterprise?: boolean; + requiredOnWizard?: boolean; + hidden?: boolean; + modules?: Array; + invalidValue?: SettingValue; + valueSource?: string; + secret?: boolean; + i18nDescription?: string; + autocomplete?: boolean; + processEnvValue?: SettingValue; + meteorSettingsValue?: SettingValue; + ts: Date; + createdAt: Date; + _updatedAt?: Date; + multiline?: boolean; + values?: Array; + placeholder?: string; + wizard?: { + step: number; + order: number; + } | null; + persistent?: boolean; // todo: remove + readonly?: boolean; // todo: remove + alert?: string; // todo: check if this is still used + private?: boolean; // todo: remove } export interface ISettingGroup { - _id: string; - hidden: boolean; - blocked: boolean; - ts?: Date; - sorter: number; - i18nLabel: string; - displayQuery?: string | FilterQuery | FilterQuery[]; - i18nDescription: string; - value?: undefined; - type: "group"; - - alert?: string; // todo: check if this is needed + _id: string; + hidden: boolean; + blocked: boolean; + ts?: Date; + sorter: number; + i18nLabel: string; + displayQuery?: string | FilterQuery | FilterQuery[]; + i18nDescription: string; + value?: undefined; + type: 'group'; + + alert?: string; // todo: check if this is needed } export interface ISettingEnterprise extends ISettingBase { - enterprise: true; - invalidValue: SettingValue; + enterprise: true; + invalidValue: SettingValue; } export interface ISettingColor extends ISettingBase { - type: "color"; - editor: SettingEditor; - packageEditor?: SettingEditor; + type: 'color'; + editor: SettingEditor; + packageEditor?: SettingEditor; } export interface ISettingCode extends ISettingBase { - type: "code"; - code?: string; + type: 'code'; + code?: string; } export interface ISettingAction extends ISettingBase { - type: "action"; - value: string; - actionText?: string; + type: 'action'; + value: string; + actionText?: string; } export interface ISettingAsset extends ISettingBase { - type: "asset"; - value: AssetValue; + type: 'asset'; + value: AssetValue; } export interface ISettingDate extends ISettingBase { - type: "date"; - value: Date; + type: 'date'; + value: Date; } -export const isDateSetting = (setting: ISetting): setting is ISettingDate => - setting.type === "date"; +export const isDateSetting = (setting: ISetting): setting is ISettingDate => setting.type === 'date'; -export const isSettingEnterprise = ( - setting: ISettingBase -): setting is ISettingEnterprise => setting.enterprise === true; +export const isSettingEnterprise = (setting: ISettingBase): setting is ISettingEnterprise => setting.enterprise === true; -export const isSettingColor = ( - setting: ISettingBase -): setting is ISettingColor => setting.type === "color"; +export const isSettingColor = (setting: ISettingBase): setting is ISettingColor => setting.type === 'color'; -export const isSettingCode = (setting: ISettingBase): setting is ISettingCode => - setting.type === "code"; +export const isSettingCode = (setting: ISettingBase): setting is ISettingCode => setting.type === 'code'; -export const isSettingAction = ( - setting: ISettingBase -): setting is ISettingAction => setting.type === "action"; +export const isSettingAction = (setting: ISettingBase): setting is ISettingAction => setting.type === 'action'; -export const isSettingAsset = ( - setting: ISettingBase -): setting is ISettingAsset => setting.type === "asset"; +export const isSettingAsset = (setting: ISettingBase): setting is ISettingAsset => setting.type === 'asset'; export interface ISettingStatistics { - account2fa?: boolean; - cannedResponsesEnabled?: boolean; - e2e?: boolean; - e2eDefaultDirectRoom?: boolean; - e2eDefaultPrivateRoom?: boolean; - smtpHost?: string; - smtpPort?: string; - fromEmail?: string; - fileUploadEnable?: boolean; - frameworkDevMode?: boolean; - frameworkEnable?: boolean; - surveyEnabled?: boolean; - updateChecker?: boolean; - liveStream?: boolean; - broadcasting?: boolean; - allowEditing?: boolean; - allowDeleting?: boolean; - allowUnrecognizedSlashCommand?: boolean; - allowBadWordsFilter?: boolean; - readReceiptEnabled?: boolean; - readReceiptStoreUsers?: boolean; - otrEnable?: boolean; - pushEnable?: boolean; - globalSearchEnabled?: boolean; - threadsEnabled?: boolean; - bigBlueButton?: boolean; - jitsiEnabled?: boolean; - webRTCEnableChannel?: boolean; - webRTCEnablePrivate?: boolean; - webRTCEnableDirect?: boolean; + account2fa?: boolean; + cannedResponsesEnabled?: boolean; + e2e?: boolean; + e2eDefaultDirectRoom?: boolean; + e2eDefaultPrivateRoom?: boolean; + smtpHost?: string; + smtpPort?: string; + fromEmail?: string; + fileUploadEnable?: boolean; + frameworkDevMode?: boolean; + frameworkEnable?: boolean; + surveyEnabled?: boolean; + updateChecker?: boolean; + liveStream?: boolean; + broadcasting?: boolean; + allowEditing?: boolean; + allowDeleting?: boolean; + allowUnrecognizedSlashCommand?: boolean; + allowBadWordsFilter?: boolean; + readReceiptEnabled?: boolean; + readReceiptStoreUsers?: boolean; + otrEnable?: boolean; + pushEnable?: boolean; + globalSearchEnabled?: boolean; + threadsEnabled?: boolean; + bigBlueButton?: boolean; + jitsiEnabled?: boolean; + webRTCEnableChannel?: boolean; + webRTCEnablePrivate?: boolean; + webRTCEnableDirect?: boolean; } export interface ISettingStatisticsObject { - accounts?: { - account2fa?: boolean; - }; - cannedResponses?: { - cannedResponsesEnabled?: boolean; - }; - e2ee?: { - e2e?: boolean; - e2eDefaultDirectRoom?: boolean; - e2eDefaultPrivateRoom?: boolean; - }; - email?: { - smtp?: { - smtpHost?: string; - smtpPort?: string; - fromEmail?: string; - }; - }; - fileUpload?: { - fileUploadEnable?: boolean; - }; - general?: { - apps?: { - frameworkDevMode?: boolean; - frameworkEnable?: boolean; - }; - nps?: { - surveyEnabled?: boolean; - }; - update?: { - updateChecker?: boolean; - }; - }; - liveStreamAndBroadcasting?: { - liveStream?: boolean; - broadcasting?: boolean; - }; - message?: { - allowEditing?: boolean; - allowDeleting?: boolean; - allowUnrecognizedSlashCommand?: boolean; - allowBadWordsFilter?: boolean; - readReceiptEnabled?: boolean; - readReceiptStoreUsers?: boolean; - }; - otr?: { - otrEnable?: boolean; - }; - push?: { - pushEnable?: boolean; - }; - search?: { - defaultProvider?: { - globalSearchEnabled?: boolean; - }; - }; - threads?: { - threadsEnabled?: boolean; - }; - videoConference?: { - bigBlueButton?: boolean; - jitsiEnabled?: boolean; - }; - webRTC?: { - webRTCEnableChannel?: boolean; - webRTCEnablePrivate?: boolean; - webRTCEnableDirect?: boolean; - }; + accounts?: { + account2fa?: boolean; + }; + cannedResponses?: { + cannedResponsesEnabled?: boolean; + }; + e2ee?: { + e2e?: boolean; + e2eDefaultDirectRoom?: boolean; + e2eDefaultPrivateRoom?: boolean; + }; + email?: { + smtp?: { + smtpHost?: string; + smtpPort?: string; + fromEmail?: string; + }; + }; + fileUpload?: { + fileUploadEnable?: boolean; + }; + general?: { + apps?: { + frameworkDevMode?: boolean; + frameworkEnable?: boolean; + }; + nps?: { + surveyEnabled?: boolean; + }; + update?: { + updateChecker?: boolean; + }; + }; + liveStreamAndBroadcasting?: { + liveStream?: boolean; + broadcasting?: boolean; + }; + message?: { + allowEditing?: boolean; + allowDeleting?: boolean; + allowUnrecognizedSlashCommand?: boolean; + allowBadWordsFilter?: boolean; + readReceiptEnabled?: boolean; + readReceiptStoreUsers?: boolean; + }; + otr?: { + otrEnable?: boolean; + }; + push?: { + pushEnable?: boolean; + }; + search?: { + defaultProvider?: { + globalSearchEnabled?: boolean; + }; + }; + threads?: { + threadsEnabled?: boolean; + }; + videoConference?: { + bigBlueButton?: boolean; + jitsiEnabled?: boolean; + }; + webRTC?: { + webRTCEnableChannel?: boolean; + webRTCEnablePrivate?: boolean; + webRTCEnableDirect?: boolean; + }; } diff --git a/packages/core-typings/src/IStatistic.ts b/packages/core-typings/src/IStatistic.ts index be1e1a9862e1..e080eb9a40b5 100644 --- a/packages/core-typings/src/IStatistic.ts +++ b/packages/core-typings/src/IStatistic.ts @@ -1,3 +1,3 @@ -import type { IStats } from "./IStats"; +import type { IStats } from './IStats'; export type IStatistic = IStats; diff --git a/packages/core-typings/src/IStats.ts b/packages/core-typings/src/IStats.ts index a22494ec15fc..01ce617c140c 100644 --- a/packages/core-typings/src/IStats.ts +++ b/packages/core-typings/src/IStats.ts @@ -1,152 +1,148 @@ -import type { CpuInfo } from "os"; +import type { CpuInfo } from 'os'; -import type { - DeviceSessionAggregationResult, - OSSessionAggregationResult, - UserSessionAggregationResult, -} from "./ISession"; -import type { ISettingStatisticsObject, SettingValue } from "./ISetting"; -import type { ITeamStats } from "./ITeam"; +import type { DeviceSessionAggregationResult, OSSessionAggregationResult, UserSessionAggregationResult } from './ISession'; +import type { ISettingStatisticsObject, SettingValue } from './ISetting'; +import type { ITeamStats } from './ITeam'; export interface IStats { - _id: string; - wizard: Record; - uniqueId: string; - installedAt?: string; - version?: string; - tag?: string; - branch?: string; - totalUsers: number; - activeUsers: number; - activeGuests: number; - nonActiveUsers: number; - appUsers: number; - onlineUsers: number; - awayUsers: number; - busyUsers: number; - totalConnectedUsers: number; - offlineUsers: number; - userLanguages: Record; - totalRooms: number; - totalChannels: number; - totalPrivateGroups: number; - totalDirect: number; - totalLivechat: number; - totalDiscussions: number; - totalThreads: number; - teams: ITeamStats; - totalLivechatVisitors: number; - totalLivechatAgents: number; - livechatEnabled: boolean; - totalChannelMessages: number; - totalPrivateGroupMessages: number; - totalDirectMessages: number; - totalLivechatMessages: number; - totalMessages: number; - federatedServers: number; - federatedUsers: number; - lastLogin: string; - lastMessageSentAt: string; - lastSeenSubscription: string; - os: { - type: string; - platform: NodeJS.Platform; - arch: string; - release: string; - uptime: number; - loadavg: number[]; - totalmem: number; - freemem: number; - cpus: CpuInfo[]; - }; - process: { - nodeVersion: string; - pid: number; - uptime: number; - }; - deploy: { - method: string; - platform: string; - }; - enterpriseReady: boolean; - uploadsTotal: number; - uploadsTotalSize: number; - migration: { - _id?: string; - locked: boolean; - version: number; - buildAt?: string; - lockedAt?: string; - }; - instanceCount: number; - oplogEnabled: boolean; - mongoVersion: string; - mongoStorageEngine: string; - pushQueue: number; - omnichannelSources: { [key: string]: number | string }[]; - departments: number; - routingAlgorithm: string; - onHoldEnabled: boolean; - emailInboxes: number; - BusinessHours: { [key: string]: number | string }; - lastChattedAgentPreferred: boolean; - assignNewConversationsToContactManager: boolean; - visitorAbandonment: string; - chatsOnHold: number; - voipEnabled: boolean; - voipCalls: number; - voipExtensions: number; - voipSuccessfulCalls: number; - voipErrorCalls: number; - voipOnHoldCalls: number; - federationOverviewData: { - numberOfEvents: number; - numberOfFederatedUsers: number; - numberOfServers: number; - }; - readReceiptsEnabled: boolean; - readReceiptsDetailed: boolean; - uniqueUsersOfLastWeek: UserSessionAggregationResult; - uniqueUsersOfLastMonth: UserSessionAggregationResult; - uniqueUsersOfYesterday: UserSessionAggregationResult; - uniqueDevicesOfYesterday: DeviceSessionAggregationResult; - uniqueDevicesOfLastWeek: DeviceSessionAggregationResult; - uniqueDevicesOfLastMonth: DeviceSessionAggregationResult; - uniqueOSOfYesterday: OSSessionAggregationResult; - uniqueOSOfLastWeek: OSSessionAggregationResult; - uniqueOSOfLastMonth: OSSessionAggregationResult; - apps: { - engineVersion: number; - enabled: SettingValue; - totalInstalled: number | false; - totalActive: number | false; - totalFailed: number | false; - }; - services: Record; - settings: ISettingStatisticsObject; - integrations: { - totalIntegrations: number; - totalIncoming: number; - totalIncomingActive: number; - totalOutgoing: number; - totalOutgoingActive: number; - totalWithScriptEnabled: number; - }; - enterprise: { - modules: string[]; - tags: string[]; - seatRequests: number; - livechatTags: number; - cannedResponses: number; - priorities: number; - businessUnits: number; - }; - createdAt: Date | string; - totalOTR: number; - totalOTRRooms: number; - slashCommandsJitsi: number; - messageAuditApply: number; - messageAuditLoad: number; - dashboardCount: number; - joinJitsiButton: number; + _id: string; + wizard: Record; + uniqueId: string; + installedAt?: string; + version?: string; + tag?: string; + branch?: string; + totalUsers: number; + activeUsers: number; + activeGuests: number; + nonActiveUsers: number; + appUsers: number; + onlineUsers: number; + awayUsers: number; + busyUsers: number; + totalConnectedUsers: number; + offlineUsers: number; + userLanguages: Record; + totalRooms: number; + totalChannels: number; + totalPrivateGroups: number; + totalDirect: number; + totalLivechat: number; + totalDiscussions: number; + totalThreads: number; + teams: ITeamStats; + totalLivechatVisitors: number; + totalLivechatAgents: number; + livechatEnabled: boolean; + totalChannelMessages: number; + totalPrivateGroupMessages: number; + totalDirectMessages: number; + totalLivechatMessages: number; + totalMessages: number; + federatedServers: number; + federatedUsers: number; + lastLogin: string; + lastMessageSentAt: string; + lastSeenSubscription: string; + os: { + type: string; + platform: NodeJS.Platform; + arch: string; + release: string; + uptime: number; + loadavg: number[]; + totalmem: number; + freemem: number; + cpus: CpuInfo[]; + }; + process: { + nodeVersion: string; + pid: number; + uptime: number; + }; + deploy: { + method: string; + platform: string; + }; + enterpriseReady: boolean; + uploadsTotal: number; + uploadsTotalSize: number; + migration: { + _id?: string; + locked: boolean; + version: number; + buildAt?: string; + lockedAt?: string; + }; + instanceCount: number; + oplogEnabled: boolean; + mongoVersion: string; + mongoStorageEngine: string; + pushQueue: number; + omnichannelSources: { [key: string]: number | string }[]; + departments: number; + routingAlgorithm: string; + onHoldEnabled: boolean; + emailInboxes: number; + BusinessHours: { [key: string]: number | string }; + lastChattedAgentPreferred: boolean; + assignNewConversationsToContactManager: boolean; + visitorAbandonment: string; + chatsOnHold: number; + voipEnabled: boolean; + voipCalls: number; + voipExtensions: number; + voipSuccessfulCalls: number; + voipErrorCalls: number; + voipOnHoldCalls: number; + federationOverviewData: { + numberOfEvents: number; + numberOfFederatedUsers: number; + numberOfServers: number; + }; + readReceiptsEnabled: boolean; + readReceiptsDetailed: boolean; + uniqueUsersOfLastWeek: UserSessionAggregationResult; + uniqueUsersOfLastMonth: UserSessionAggregationResult; + uniqueUsersOfYesterday: UserSessionAggregationResult; + uniqueDevicesOfYesterday: DeviceSessionAggregationResult; + uniqueDevicesOfLastWeek: DeviceSessionAggregationResult; + uniqueDevicesOfLastMonth: DeviceSessionAggregationResult; + uniqueOSOfYesterday: OSSessionAggregationResult; + uniqueOSOfLastWeek: OSSessionAggregationResult; + uniqueOSOfLastMonth: OSSessionAggregationResult; + apps: { + engineVersion: number; + enabled: SettingValue; + totalInstalled: number | false; + totalActive: number | false; + totalFailed: number | false; + }; + services: Record; + settings: ISettingStatisticsObject; + integrations: { + totalIntegrations: number; + totalIncoming: number; + totalIncomingActive: number; + totalOutgoing: number; + totalOutgoingActive: number; + totalWithScriptEnabled: number; + }; + enterprise: { + modules: string[]; + tags: string[]; + seatRequests: number; + livechatTags: number; + cannedResponses: number; + priorities: number; + businessUnits: number; + }; + createdAt: Date | string; + totalOTR: number; + totalOTRRooms: number; + slashCommandsJitsi: number; + messageAuditApply: number; + messageAuditLoad: number; + dashboardCount: number; + joinJitsiButton: number; } diff --git a/packages/core-typings/src/ISubscription.ts b/packages/core-typings/src/ISubscription.ts index 31083c85b721..c12afb9aea15 100644 --- a/packages/core-typings/src/ISubscription.ts +++ b/packages/core-typings/src/ISubscription.ts @@ -1,69 +1,69 @@ -import type { IRocketChatRecord } from "./IRocketChatRecord"; -import type { IUser, IRole } from "./IUser"; -import type { RoomType } from "./RoomType"; +import type { IRocketChatRecord } from './IRocketChatRecord'; +import type { IRole } from './IRole'; +import type { IUser } from './IUser'; +import type { RoomType } from './RoomType'; type RoomID = string; export interface ISubscription extends IRocketChatRecord { - u: Pick; - v?: Pick; - rid: RoomID; - open: boolean; - ts: Date; + u: Pick; + v?: Pick; + rid: RoomID; + open: boolean; + ts: Date; - name: string; + name: string; - alert?: boolean; - unread: number; - t: RoomType; - ls: Date; - f?: true; - lr: Date; - hideUnreadStatus?: true; - teamMain?: boolean; - teamId?: string; + alert?: boolean; + unread: number; + t: RoomType; + ls: Date; + f?: true; + lr: Date; + hideUnreadStatus?: true; + teamMain?: boolean; + teamId?: string; - userMentions: number; - groupMentions: number; + userMentions: number; + groupMentions: number; - broadcast?: boolean; - tunread?: Array; - tunreadGroup?: Array; - tunreadUser?: Array; + broadcast?: boolean; + tunread?: Array; + tunreadGroup?: Array; + tunreadUser?: Array; - prid?: RoomID; + prid?: RoomID; - roles?: IRole["_id"][]; + roles?: IRole['_id'][]; - onHold?: boolean; - encrypted?: boolean; - E2EKey?: string; - unreadAlert?: "default" | "all" | "mentions" | "nothing"; + onHold?: boolean; + encrypted?: boolean; + E2EKey?: string; + unreadAlert?: 'default' | 'all' | 'mentions' | 'nothing'; - fname?: string; + fname?: string; - code?: unknown; - archived?: unknown; - audioNotificationValue?: unknown; - desktopNotifications?: unknown; - mobilePushNotifications?: unknown; - emailNotifications?: unknown; - blocked?: unknown; - blocker?: unknown; - autoTranslate?: unknown; - autoTranslateLanguage?: unknown; - disableNotifications?: unknown; - muteGroupMentions?: unknown; - ignored?: unknown; + code?: unknown; + archived?: unknown; + audioNotificationValue?: unknown; + desktopNotifications?: unknown; + mobilePushNotifications?: unknown; + emailNotifications?: unknown; + blocked?: unknown; + blocker?: unknown; + autoTranslate?: unknown; + autoTranslateLanguage?: unknown; + disableNotifications?: unknown; + muteGroupMentions?: unknown; + ignored?: unknown; - department?: unknown; + department?: unknown; } export interface IOmnichannelSubscription extends ISubscription { - department?: string; // TODO REMOVE/DEPRECATE no need keeo in both room and subscription + department?: string; // TODO REMOVE/DEPRECATE no need keeo in both room and subscription } -export interface ISubscriptionDirectMessage - extends Omit { - t: "d"; +export interface ISubscriptionDirectMessage extends Omit { + t: 'd'; } diff --git a/packages/core-typings/src/ITeam.ts b/packages/core-typings/src/ITeam.ts index 9484f980b1ff..6616af53213d 100644 --- a/packages/core-typings/src/ITeam.ts +++ b/packages/core-typings/src/ITeam.ts @@ -1,67 +1,68 @@ -import type { SortOptionObject, FilterQuery, SchemaMember } from "mongodb"; +import type { SortOptionObject, FilterQuery, SchemaMember } from 'mongodb'; -import type { IRocketChatRecord } from "./IRocketChatRecord"; -import type { IUser, IRole } from "./IUser"; +import type { IRocketChatRecord } from './IRocketChatRecord'; +import type { IRole } from './IRole'; +import type { IUser } from './IUser'; export enum TEAM_TYPE { - PUBLIC = 0, - PRIVATE = 1, + PUBLIC = 0, + PRIVATE = 1, } export type SortType = -1 | 1; export interface ITeam extends IRocketChatRecord { - name: string; - type: TEAM_TYPE; - roomId: string; - createdBy: Pick; - createdAt: Date; + name: string; + type: TEAM_TYPE; + roomId: string; + createdBy: Pick; + createdAt: Date; } export interface ITeamMember extends IRocketChatRecord { - teamId: string; - userId: string; - roles?: Array; - createdBy: Pick; - createdAt: Date; + teamId: string; + userId: string; + roles?: Array; + createdBy: Pick; + createdAt: Date; } // TODO move this definition to a more broader file export interface IPaginationOptions { - offset: number; - count: number; + offset: number; + count: number; } // TODO move this definition to a more broader file export interface IQueryOptions { - sort?: SortOptionObject; - query?: FilterQuery; - fields?: SchemaMember; + sort?: SortOptionObject; + query?: FilterQuery; + fields?: SchemaMember; } // TODO move this definition to a more broader file export interface IRecordsWithTotal { - records: Array; - total: number; + records: Array; + total: number; } export interface ITeamStatData { - teamId: string; - mainRoom: string; - totalRooms: number; - totalMessages: number; - totalPublicRooms: number; - totalPrivateRooms: number; - totalDefaultRooms: number; - totalMembers: number; + teamId: string; + mainRoom: string; + totalRooms: number; + totalMessages: number; + totalPublicRooms: number; + totalPrivateRooms: number; + totalDefaultRooms: number; + totalMembers: number; } export interface ITeamStats { - totalTeams: number; - teamStats: Array; + totalTeams: number; + teamStats: Array; } // TODO: move to service sdk package export interface ITeamMemberParams { - userId: string; - roles?: Array | null; + userId: string; + roles?: Array | null; } diff --git a/packages/core-typings/src/IUpload.ts b/packages/core-typings/src/IUpload.ts index 64dc6b5eaac9..25dc82b7314a 100644 --- a/packages/core-typings/src/IUpload.ts +++ b/packages/core-typings/src/IUpload.ts @@ -1,12 +1,12 @@ -import type { IRocketChatRecord } from "./IRocketChatRecord"; +import type { IRocketChatRecord } from './IRocketChatRecord'; export interface IUpload extends IRocketChatRecord { - typeGroup?: string; - type?: string; - name: string; - aliases?: string; - extension?: string; - complete?: boolean; - uploading?: boolean; - progress?: number; + typeGroup?: string; + type?: string; + name: string; + aliases?: string; + extension?: string; + complete?: boolean; + uploading?: boolean; + progress?: number; } diff --git a/packages/core-typings/src/IUser.ts b/packages/core-typings/src/IUser.ts index 3cd4cdf08c58..c7d00ad750f6 100644 --- a/packages/core-typings/src/IUser.ts +++ b/packages/core-typings/src/IUser.ts @@ -1,175 +1,166 @@ -import type { UserStatus } from "./UserStatus"; -import type { IRocketChatRecord } from "./IRocketChatRecord"; +import type { UserStatus } from './UserStatus'; +import type { IRocketChatRecord } from './IRocketChatRecord'; +import type { IRole } from './IRole'; export interface ILoginToken { - hashedToken: string; - twoFactorAuthorizedUntil?: Date; - twoFactorAuthorizedHash?: string; + hashedToken: string; + twoFactorAuthorizedUntil?: Date; + twoFactorAuthorizedHash?: string; } export interface IMeteorLoginToken extends ILoginToken { - when: Date; + when: Date; } export interface IPersonalAccessToken extends ILoginToken { - type: "personalAccessToken"; - createdAt: Date; - lastTokenPart: string; - name?: string; - bypassTwoFactor?: boolean; + type: 'personalAccessToken'; + createdAt: Date; + lastTokenPart: string; + name?: string; + bypassTwoFactor?: boolean; } export interface IUserEmailVerificationToken { - token: string; - address: string; - when: Date; + token: string; + address: string; + when: Date; } export interface IUserEmailCode { - code: string; - expire: Date; + code: string; + expire: Date; } type LoginToken = IMeteorLoginToken & IPersonalAccessToken; export type Username = string; export type ILoginUsername = - | { - username: string; - } - | { - email: string; - }; + | { + username: string; + } + | { + email: string; + }; export type LoginUsername = string | ILoginUsername; export interface IUserServices { - password?: { - bcrypt: string; - }; - passwordHistory?: string[]; - email?: { - verificationTokens?: IUserEmailVerificationToken[]; - }; - resume?: { - loginTokens?: LoginToken[]; - }; - google?: any; - facebook?: any; - github?: any; - totp?: { - enabled: boolean; - hashedBackup: string[]; - secret: string; - }; - email2fa?: { - enabled: boolean; - changedAt: Date; - }; - emailCode: IUserEmailCode[]; - saml?: { - inResponseTo?: string; - provider?: string; - idp?: string; - idpSession?: string; - nameID?: string; - }; - ldap?: { - id: string; - idAttribute?: string; - }; + password?: { + bcrypt: string; + }; + passwordHistory?: string[]; + email?: { + verificationTokens?: IUserEmailVerificationToken[]; + }; + resume?: { + loginTokens?: LoginToken[]; + }; + google?: any; + facebook?: any; + github?: any; + totp?: { + enabled: boolean; + hashedBackup: string[]; + secret: string; + }; + email2fa?: { + enabled: boolean; + changedAt: Date; + }; + emailCode: IUserEmailCode[]; + saml?: { + inResponseTo?: string; + provider?: string; + idp?: string; + idpSession?: string; + nameID?: string; + }; + ldap?: { + id: string; + idAttribute?: string; + }; } export interface IUserEmail { - address: string; - verified?: boolean; + address: string; + verified?: boolean; } export interface IUserSettings { - profile: any; - preferences: { - [key: string]: any; - }; -} - -export interface IRole { - description: string; - mandatory2fa?: boolean; - name: string; - protected: boolean; - scope: "Users" | "Subscriptions"; - _id: string; + profile: any; + preferences: { + [key: string]: any; + }; } export interface IGetRoomRoles { - _id: string; - rid: string; - u: { - _id: string; - username: string; - }; - roles: string[]; + _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; - active: boolean; - username?: string; - name?: string; - services?: IUserServices; - emails?: IUserEmail[]; - status?: UserStatus; - statusConnection?: string; - lastLogin?: Date; - avatarOrigin?: string; - avatarETag?: string; - utcOffset?: number; - language?: string; - statusDefault?: UserStatus; - statusText?: string; - oauth?: { - authorizedClients: string[]; - }; - _updatedAt: Date; - statusLivechat?: string; - e2e?: { - private_key: string; - public_key: string; - }; - requirePasswordChange?: boolean; - customFields?: { - [key: string]: any; - }; - settings?: IUserSettings; - defaultRoom?: string; - ldap?: boolean; - extension?: string; - inviteToken?: string; + _id: string; + createdAt: Date; + roles: IRole['_id'][]; + type: string; + active: boolean; + username?: string; + name?: string; + services?: IUserServices; + emails?: IUserEmail[]; + status?: UserStatus; + statusConnection?: string; + lastLogin?: Date; + avatarOrigin?: string; + avatarETag?: string; + utcOffset?: number; + language?: string; + statusDefault?: UserStatus; + statusText?: string; + oauth?: { + authorizedClients: string[]; + }; + _updatedAt: Date; + statusLivechat?: string; + e2e?: { + private_key: string; + public_key: string; + }; + requirePasswordChange?: boolean; + customFields?: { + [key: string]: any; + }; + settings?: IUserSettings; + defaultRoom?: string; + ldap?: boolean; + extension?: string; + inviteToken?: string; } export interface IRegisterUser extends IUser { - username: string; - name: string; + username: string; + name: string; } -export const isRegisterUser = (user: IUser): user is IRegisterUser => - user.username !== undefined && user.name !== undefined; +export const isRegisterUser = (user: IUser): user is IRegisterUser => user.username !== undefined && user.name !== undefined; export type IUserDataEvent = { - id: unknown; + id: unknown; } & ( - | ({ - type: "inserted"; - } & IUser) - | { - type: "removed"; - } - | { - type: "updated"; - diff: Partial; - unset: Record; - } + | ({ + type: 'inserted'; + } & IUser) + | { + type: 'removed'; + } + | { + type: 'updated'; + diff: Partial; + unset: Record; + } ); export type IUserInRole = Pick< diff --git a/packages/core-typings/src/IUserAction.ts b/packages/core-typings/src/IUserAction.ts index 16277b9d8cfe..d9e781b391d3 100644 --- a/packages/core-typings/src/IUserAction.ts +++ b/packages/core-typings/src/IUserAction.ts @@ -1,11 +1,11 @@ export type IUserAction = { - _id: string; - username?: string; - name?: string; + _id: string; + username?: string; + name?: string; }; export type IExtras = { - tmid?: string; + tmid?: string; }; export type IActivity = Record; diff --git a/packages/core-typings/src/IUserDataFile.ts b/packages/core-typings/src/IUserDataFile.ts index d988dd3a7574..1d9f2c618a14 100644 --- a/packages/core-typings/src/IUserDataFile.ts +++ b/packages/core-typings/src/IUserDataFile.ts @@ -1,13 +1,13 @@ -import type { IRocketChatRecord } from "./IRocketChatRecord"; +import type { IRocketChatRecord } from './IRocketChatRecord'; export interface IUserDataFile extends IRocketChatRecord { - name: string; - rid: string; - userId: string; - store: string; - complete: boolean; - uploading: boolean; - progress: number; - extension: string; - uploadedAt: Date; + name: string; + rid: string; + userId: string; + store: string; + complete: boolean; + uploading: boolean; + progress: number; + extension: string; + uploadedAt: Date; } diff --git a/packages/core-typings/src/IUserSession.ts b/packages/core-typings/src/IUserSession.ts index aa4c466bf617..48844fab6e27 100644 --- a/packages/core-typings/src/IUserSession.ts +++ b/packages/core-typings/src/IUserSession.ts @@ -1,14 +1,14 @@ -import type { UserStatus } from "./UserStatus"; +import type { UserStatus } from './UserStatus'; export interface IUserSessionConnection { - id: string; - instanceId: string; - status: UserStatus; - _createdAt: Date; - _updatedAt: Date; + id: string; + instanceId: string; + status: UserStatus; + _createdAt: Date; + _updatedAt: Date; } export interface IUserSession { - _id: string; - connections: IUserSessionConnection[]; + _id: string; + connections: IUserSessionConnection[]; } diff --git a/packages/core-typings/src/IVoipConnectorResult.ts b/packages/core-typings/src/IVoipConnectorResult.ts index 3efd28b8853d..5fa73c113fa2 100644 --- a/packages/core-typings/src/IVoipConnectorResult.ts +++ b/packages/core-typings/src/IVoipConnectorResult.ts @@ -1,20 +1,15 @@ -import type { - IVoipExtensionConfig, - IVoipExtensionBase, - IQueueMembershipDetails, - IQueueMembershipSubscription, -} from "./IVoipExtension"; -import type { IQueueDetails, IQueueSummary } from "./ACDQueues"; -import type { IRegistrationInfo } from "./voip"; +import type { IVoipExtensionConfig, IVoipExtensionBase, IQueueMembershipDetails, IQueueMembershipSubscription } from './IVoipExtension'; +import type { IQueueDetails, IQueueSummary } from './ACDQueues'; +import type { IRegistrationInfo } from './voip'; export interface IVoipConnectorResult { - result: - | IVoipExtensionConfig - | IVoipExtensionBase[] - | IQueueSummary[] - | IQueueDetails - | IQueueMembershipDetails - | IQueueMembershipSubscription - | IRegistrationInfo - | undefined; + result: + | IVoipExtensionConfig + | IVoipExtensionBase[] + | IQueueSummary[] + | IQueueDetails + | IQueueMembershipDetails + | IQueueMembershipSubscription + | IRegistrationInfo + | undefined; } diff --git a/packages/core-typings/src/IVoipExtension.ts b/packages/core-typings/src/IVoipExtension.ts index 1263b5844200..9a32cdc0fa00 100644 --- a/packages/core-typings/src/IVoipExtension.ts +++ b/packages/core-typings/src/IVoipExtension.ts @@ -1,66 +1,53 @@ -import type { IQueueSummary } from "./ACDQueues"; -import type { IUser } from "./IUser"; -import type { IExtensionDetails, IRegistrationInfo } from "./voip"; +import type { IQueueSummary } from './ACDQueues'; +import type { IUser } from './IUser'; +import type { IExtensionDetails, IRegistrationInfo } from './voip'; export enum EndpointState { - UNKNOWN = "unknown", - REGISTERED = "registered", - UNREGISTERED = "unregistered", - RINGING = "ringing", - BUSY = "busy", + UNKNOWN = 'unknown', + REGISTERED = 'registered', + UNREGISTERED = 'unregistered', + RINGING = 'ringing', + BUSY = 'busy', } export interface IVoipExtensionBase { - extension: string; - state: EndpointState; + extension: string; + state: EndpointState; } export interface IVoipExtensionWithAgentInfo extends IVoipExtensionBase { - queues?: string[]; - userId?: IUser["_id"]; - username?: IUser["username"]; - name?: IUser["name"]; + queues?: string[]; + userId?: IUser['_id']; + username?: IUser['username']; + name?: IUser['name']; } export const isIVoipExtensionBase = (obj: any): obj is IVoipExtensionBase => - obj && typeof obj.name === "string" && typeof obj.state === "string"; + obj && typeof obj.name === 'string' && typeof obj.state === 'string'; export interface IVoipExtensionConfig extends IVoipExtensionBase { - authType: string; - password: string; + authType: string; + password: string; } export const isIVoipExtensionConfig = (obj: any): obj is IVoipExtensionConfig => - obj.name !== undefined && - obj.state !== undefined && - obj.authType !== undefined && - obj.password !== undefined; + obj.name !== undefined && obj.state !== undefined && obj.authType !== undefined && obj.password !== undefined; export interface IQueueMembershipDetails { - extension: string; - queueCount: number; - callWaitingCount: number; + extension: string; + queueCount: number; + callWaitingCount: number; } export interface IQueueMembershipSubscription { - queues: IQueueSummary[]; - extension: string; + queues: IQueueSummary[]; + extension: string; } -export const isIQueueMembershipDetails = ( - obj: any -): obj is IQueueMembershipDetails => - obj && - typeof obj.extension === "string" && - typeof obj.queueCount === "number" && - typeof obj.callWaitingCount === "number"; +export const isIQueueMembershipDetails = (obj: any): obj is IQueueMembershipDetails => + obj && typeof obj.extension === 'string' && typeof obj.queueCount === 'number' && typeof obj.callWaitingCount === 'number'; export const isIExtensionDetails = (prop: any): prop is IExtensionDetails => - prop.extension !== undefined && - prop.password !== undefined && - prop.authtype !== undefined && - prop.state !== undefined; + prop.extension !== undefined && prop.password !== undefined && prop.authtype !== undefined && prop.state !== undefined; export const isIRegistrationInfo = (prop: any): prop is IRegistrationInfo => - prop.hasOwnProperty("host") && - prop.hasOwnProperty("callServerConfig") && - prop.hasOwnProperty("extensionDetails"); + prop.hasOwnProperty('host') && prop.hasOwnProperty('callServerConfig') && prop.hasOwnProperty('extensionDetails'); diff --git a/packages/core-typings/src/IVoipServerConfig.ts b/packages/core-typings/src/IVoipServerConfig.ts index be2210cfc604..0c4555a8e84e 100644 --- a/packages/core-typings/src/IVoipServerConfig.ts +++ b/packages/core-typings/src/IVoipServerConfig.ts @@ -1,34 +1,31 @@ -import type { ICallServerConfigData } from "./voip"; +import type { ICallServerConfigData } from './voip'; export enum ServerType { - MANAGEMENT = "management", - CALL_SERVER = "call-server", + MANAGEMENT = 'management', + CALL_SERVER = 'call-server', } export interface IVoipServerConfigBase { - type: ServerType; - host: string; - name: string; + type: ServerType; + host: string; + name: string; } export interface IVoipCallServerConfig extends IVoipServerConfigBase { - type: ServerType.CALL_SERVER; - configData: ICallServerConfigData; + type: ServerType.CALL_SERVER; + configData: ICallServerConfigData; } export interface IVoipManagementServerConfig extends IVoipServerConfigBase { - type: ServerType.MANAGEMENT; - configData: IManagementConfigData; + type: ServerType.MANAGEMENT; + configData: IManagementConfigData; } export interface IManagementConfigData { - port: number; - username: string; - password: string; + port: number; + username: string; + password: string; } -export const isICallServerConfigData = ( - obj: any -): obj is ICallServerConfigData => - Number.isInteger(obj.websocketPort) && - String(obj.websocketPath) === obj.websocketPath; +export const isICallServerConfigData = (obj: any): obj is ICallServerConfigData => + Number.isInteger(obj.websocketPort) && String(obj.websocketPath) === obj.websocketPath; diff --git a/packages/core-typings/src/IWebdavAccount.ts b/packages/core-typings/src/IWebdavAccount.ts index 51cafc02da05..2ed42f07d19e 100644 --- a/packages/core-typings/src/IWebdavAccount.ts +++ b/packages/core-typings/src/IWebdavAccount.ts @@ -1,14 +1,11 @@ -import type { IRocketChatRecord } from "./IRocketChatRecord"; +import type { IRocketChatRecord } from './IRocketChatRecord'; export interface IWebdavAccount extends IRocketChatRecord { - userId: string; - serverURL: string; - username: string; - password: string; - name: string; + userId: string; + serverURL: string; + username: string; + password: string; + name: string; } -export type IWebdavAccountPayload = Omit< - IWebdavAccount, - "userId" | "_id" | "_updatedAt" ->; +export type IWebdavAccountPayload = Omit; diff --git a/packages/core-typings/src/OmichannelRoutingConfig.ts b/packages/core-typings/src/OmichannelRoutingConfig.ts index 3f8b4335df14..43d1344ff5c5 100644 --- a/packages/core-typings/src/OmichannelRoutingConfig.ts +++ b/packages/core-typings/src/OmichannelRoutingConfig.ts @@ -1,20 +1,20 @@ -import type { IRoom } from "./IRoom"; +import type { IRoom } from './IRoom'; export type OmichannelRoutingConfig = { - previewRoom: boolean; - showConnecting: boolean; - showQueue: boolean; - showQueueLink: boolean; - returnQueue: boolean; - enableTriggerAction: boolean; - autoAssignAgent: boolean; + previewRoom: boolean; + showConnecting: boolean; + showQueue: boolean; + showQueueLink: boolean; + returnQueue: boolean; + enableTriggerAction: boolean; + autoAssignAgent: boolean; }; export type Inquiries = - | { - enabled: true; - queue: Array; - } - | { - enabled: false; - }; + | { + enabled: true; + queue: Array; + } + | { + enabled: false; + }; diff --git a/packages/core-typings/src/UIKit.ts b/packages/core-typings/src/UIKit.ts index 71f32ab30694..19cf46f82b92 100644 --- a/packages/core-typings/src/UIKit.ts +++ b/packages/core-typings/src/UIKit.ts @@ -1,72 +1,60 @@ -import { UIKitInteractionType as UIKitInteractionTypeApi } from "@rocket.chat/apps-engine/definition/uikit"; +import { UIKitInteractionType as UIKitInteractionTypeApi } from '@rocket.chat/apps-engine/definition/uikit'; import type { - IDividerBlock, - ISectionBlock, - IActionsBlock, - IContextBlock, - IInputBlock, -} from "@rocket.chat/apps-engine/definition/uikit/blocks/Blocks"; + IDividerBlock, + ISectionBlock, + IActionsBlock, + IContextBlock, + IInputBlock, +} from '@rocket.chat/apps-engine/definition/uikit/blocks/Blocks'; enum UIKitInteractionTypeExtended { - BANNER_OPEN = "banner.open", - BANNER_UPDATE = "banner.update", - BANNER_CLOSE = "banner.close", + BANNER_OPEN = 'banner.open', + BANNER_UPDATE = 'banner.update', + BANNER_CLOSE = 'banner.close', } -export type UIKitInteractionType = - | UIKitInteractionTypeApi - | UIKitInteractionTypeExtended; +export type UIKitInteractionType = UIKitInteractionTypeApi | UIKitInteractionTypeExtended; export const UIKitInteractionTypes = { - ...UIKitInteractionTypeApi, - ...UIKitInteractionTypeExtended, + ...UIKitInteractionTypeApi, + ...UIKitInteractionTypeExtended, }; export type UiKitPayload = { - viewId: string; - appId: string; - blocks: ( - | IDividerBlock - | ISectionBlock - | IActionsBlock - | IContextBlock - | IInputBlock - )[]; + viewId: string; + appId: string; + blocks: (IDividerBlock | ISectionBlock | IActionsBlock | IContextBlock | IInputBlock)[]; }; export type UiKitBannerPayload = UiKitPayload & { - inline?: boolean; - variant?: "neutral" | "info" | "success" | "warning" | "danger"; - icon?: string; - title?: string; + inline?: boolean; + variant?: 'neutral' | 'info' | 'success' | 'warning' | 'danger'; + icon?: string; + title?: string; }; export type UIKitUserInteraction = { - type: UIKitInteractionType; + type: UIKitInteractionType; } & UiKitPayload; export type UiKitBannerProps = { - payload: UiKitBannerPayload; + payload: UiKitBannerPayload; }; -export type UIKitUserInteractionResult = - | UIKitUserInteractionResultError - | UIKitUserInteraction; +export type UIKitUserInteractionResult = UIKitUserInteractionResultError | UIKitUserInteraction; type UIKitUserInteractionResultError = UIKitUserInteraction & { - type: UIKitInteractionTypeApi.ERRORS; - errors?: Array<{ [key: string]: string }>; + type: UIKitInteractionTypeApi.ERRORS; + errors?: Array<{ [key: string]: string }>; }; -export const isErrorType = ( - result: UIKitUserInteractionResult -): result is UIKitUserInteractionResultError => - result.type === UIKitInteractionTypeApi.ERRORS; +export const isErrorType = (result: UIKitUserInteractionResult): result is UIKitUserInteractionResultError => + result.type === UIKitInteractionTypeApi.ERRORS; export type UIKitActionEvent = { - blockId: string; - value?: unknown; - appId: string; - actionId: string; - viewId: string; + blockId: string; + value?: unknown; + appId: string; + actionId: string; + viewId: string; }; diff --git a/packages/core-typings/src/ee/ILicense/ILicense.ts b/packages/core-typings/src/ee/ILicense/ILicense.ts index d2bedfc43bd1..668866b5cc4c 100644 --- a/packages/core-typings/src/ee/ILicense/ILicense.ts +++ b/packages/core-typings/src/ee/ILicense/ILicense.ts @@ -1,16 +1,16 @@ -import type { ILicenseTag } from "./ILicenseTag"; +import type { ILicenseTag } from './ILicenseTag'; export interface ILicense { - url: string; - expiry: string; - maxActiveUsers: number; - modules: string[]; - maxGuestUsers: number; - maxRoomsPerGuest: number; - tag?: ILicenseTag; - meta?: { - trial: boolean; - trialEnd: string; - workspaceId: string; - }; + url: string; + expiry: string; + maxActiveUsers: number; + modules: string[]; + maxGuestUsers: number; + maxRoomsPerGuest: number; + tag?: ILicenseTag; + meta?: { + trial: boolean; + trialEnd: string; + workspaceId: string; + }; } diff --git a/packages/core-typings/src/index.ts b/packages/core-typings/src/index.ts index 2b6c70bf9ac5..86a99127e824 100644 --- a/packages/core-typings/src/index.ts +++ b/packages/core-typings/src/index.ts @@ -1,116 +1,106 @@ -export * from "./IRoom"; -export * from "./UIKit"; -export * from "./IMessage"; -export * from "./Serialized"; -export * from "./ISetting"; -export * from "./ISubscription"; -export * from "./ITeam"; -export * from "./RoomType"; -export * from "./IInvite"; -export * from "./IRocketChatRecord"; -export * from "./UserStatus"; -export * from "./IUserAction"; -export * from "./IBanner"; -export * from "./IStats"; -export * from "./IServerInfo"; -export * from "./IInstanceStatus"; -export * from "./IWebdavAccount"; -export * from "./IPermission"; -export * from "./utils"; -export * from "./IRole"; -export * from "./IIntegration"; -export * from "./IIntegrationHistory"; -export * from "./ICustomSound"; -export * from "./ICloud"; -export * from "./IServerEvent"; -export * from "./ICronJobs"; +export * from './IRoom'; +export * from './UIKit'; +export * from './IMessage'; +export * from './Serialized'; +export * from './ISetting'; +export * from './ISubscription'; +export * from './ITeam'; +export * from './RoomType'; +export * from './IInvite'; +export * from './IRocketChatRecord'; +export * from './UserStatus'; +export * from './IUserAction'; +export * from './IBanner'; +export * from './IStats'; +export * from './IServerInfo'; +export * from './IInstanceStatus'; +export * from './IWebdavAccount'; +export * from './IPermission'; +export * from './utils'; +export * from './IRole'; +export * from './IIntegration'; +export * from './IIntegrationHistory'; +export * from './ICustomSound'; +export * from './ICloud'; +export * from './IServerEvent'; +export * from './ICronJobs'; -export * from "./IUserDataFile"; -export * from "./IUserSession"; -export * from "./IUserStatus"; -export * from "./IUser"; +export * from './IUserDataFile'; +export * from './IUserSession'; +export * from './IUserStatus'; +export * from './IUser'; -export * from "./ee/ILicense/ILicense"; +export * from './ee/ILicense/ILicense'; -export * from "./IImportUser"; -export * from "./IImportRecord"; -export * from "./IImportMessage"; -export * from "./IImportChannel"; -export * from "./IIncomingMessage"; -export * from "./IExportOperation"; -export * from "./INotification"; -export * from "./INps"; +export * from './IImportUser'; +export * from './IImportRecord'; +export * from './IImportMessage'; +export * from './IImportChannel'; +export * from './IIncomingMessage'; +export * from './IExportOperation'; +export * from './INotification'; +export * from './INps'; -export * from "./ISession"; -export * from "./IEmoji"; -export * from "./IEmojiCustom"; -export * from "./ICustomEmojiDescriptor"; -export * from "./IAnalytic"; -export * from "./ICredentialToken"; -export * from "./IAvatar"; -export * from "./ICustomUserStatus"; -export * from "./IEmailMessageHistory"; +export * from './ISession'; +export * from './IEmoji'; +export * from './IEmojiCustom'; +export * from './ICustomEmojiDescriptor'; +export * from './IAnalytic'; +export * from './ICredentialToken'; +export * from './IAvatar'; +export * from './ICustomUserStatus'; +export * from './IEmailMessageHistory'; -export * from "./ReadReceipt"; -export * from "./IUpload"; -export * from "./IOEmbedCache"; +export * from './ReadReceipt'; +export * from './IUpload'; +export * from './IOEmbedCache'; // TODO: not sure if this is the right place to put this -export * from "./IEmailInbox"; -export * from "./ILoginServiceConfiguration"; -export * from "./ISocketConnection"; -export * from "./IMethodThisType"; -export * from "./IPassword"; -export * from "./IBaseData"; -export * from "./IOAuthApps"; -export * from "./Federation"; -export * from "./ISmarshHistory"; -export * from "./IStatistic"; -export * from "./IReport"; +export * from './IEmailInbox'; +export * from './ILoginServiceConfiguration'; +export * from './ISocketConnection'; +export * from './IMethodThisType'; +export * from './IPassword'; +export * from './IBaseData'; +export * from './IOAuthApps'; +export * from './Federation'; +export * from './ISmarshHistory'; +export * from './IStatistic'; +export * from './IReport'; // export * from './IMethodConnection'; -export * from "./ldap"; +export * from './ldap'; // TODO: move to separated package -export * from "./IOmnichannelBusinessUnit"; -export * from "./IOmnichannelCustomAgent"; -export * from "./IOmnichannelBusinessUnit"; -export * from "./IOmnichannelCustomAgent"; +export * from './IOmnichannelBusinessUnit'; +export * from './IOmnichannelCustomAgent'; -export * from "./ILivechatTag"; -export * from "./IPbxEvent"; -export * from "./ILivechatMonitor"; -export * from "./ILivechatTagRecord"; -export * from "./ILivechatTrigger"; -export * from "./ILivechatCustomField"; -export * from "./IOmnichannel"; -export * from "./ILivechatAgentActivity"; -export * from "./ILivechatBusinessHour"; -export * from "./ILivechatVisitor"; -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 "./IVoipExtension"; -export * from "./voip"; -export * from "./voip/CallStates"; -export * from "./voip/ICallerInfo"; -export * from "./voip/Operations"; -export * from "./voip/UserState"; -export * from "./voip/VoIPUserConfiguration"; -export * from "./voip/VoIpCallerInfo"; -export * from "./voip/VoipEvents"; -export * from "./voip/VoIpCallerInfo"; -export * from "./voip/VoipClientEvents"; -export * from "./voip/WorkflowTypes"; -export * from "./ACDQueues"; -export * from "./IVoipConnectorResult"; -export * from "./IVoipServerConfig"; -export * from "./IVoipServerConnectivityStatus"; -export * from "./IOmnichannelVoipServiceResult"; -export * from "./IInquiry"; +export * from './ILivechatTag'; +export * from './IPbxEvent'; +export * from './ILivechatMonitor'; +export * from './ILivechatTagRecord'; +export * from './ILivechatTrigger'; +export * from './ILivechatCustomField'; +export * from './IOmnichannel'; +export * from './ILivechatAgentActivity'; +export * from './ILivechatBusinessHour'; +export * from './ILivechatVisitor'; +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 './IVoipExtension'; +export * from './voip'; +export * from './voip/VoIPUserConfiguration'; +export * from './voip/VoIpCallerInfo'; +export * from './ACDQueues'; +export * from './IVoipConnectorResult'; +export * from './IVoipServerConfig'; +export * from './IVoipServerConnectivityStatus'; +export * from './IOmnichannelVoipServiceResult'; +export * from './IInquiry'; diff --git a/packages/core-typings/src/voip/VoIpCallerInfo.ts b/packages/core-typings/src/voip/VoIpCallerInfo.ts index e1c0bf74661c..e0a1eadf44d9 100644 --- a/packages/core-typings/src/voip/VoIpCallerInfo.ts +++ b/packages/core-typings/src/voip/VoIpCallerInfo.ts @@ -1,19 +1,19 @@ -import type { CallStates } from "./CallStates"; -import type { ICallerInfo } from "./ICallerInfo"; -import type { UserState } from "./UserState"; +import type { CallStates } from './CallStates'; +import type { ICallerInfo } from './ICallerInfo'; +import type { UserState } from './UserState'; export interface IState { - isReady: boolean; - enableVideo: boolean; + isReady: boolean; + enableVideo: boolean; } export type VoIpCallerInfo = - | { - state: Exclude; - userState: UserState; - } - | { - state: "IN_CALL" | "ON_HOLD" | "OFFER_RECEIVED"; - userState: UserState; - caller: ICallerInfo; - }; // TODO: Check for additional properties and States (E.g. call on hold, muted, etc) + | { + state: Exclude; + userState: UserState; + } + | { + state: 'IN_CALL' | 'ON_HOLD' | 'OFFER_RECEIVED'; + userState: UserState; + caller: ICallerInfo; + }; // TODO: Check for additional properties and States (E.g. call on hold, muted, etc) diff --git a/packages/core-typings/src/voip/VoipEvents.ts b/packages/core-typings/src/voip/VoipEvents.ts index 10be9a4e9917..9a97e551ba22 100644 --- a/packages/core-typings/src/voip/VoipEvents.ts +++ b/packages/core-typings/src/voip/VoipEvents.ts @@ -1,19 +1,19 @@ -import type { ICallerInfo } from "./ICallerInfo"; +import type { ICallerInfo } from './ICallerInfo'; export type VoipEvents = { - registered: undefined; - registrationerror: unknown; - unregistered: undefined; - unregistrationerror: unknown; - connected: undefined; - connectionerror: unknown; - callestablished: undefined; - incomingcall: ICallerInfo; - callterminated: undefined; - hold: undefined; - holderror: undefined; - muteerror: undefined; - unhold: undefined; - unholderror: undefined; - stateChanged: undefined; + registered: undefined; + registrationerror: unknown; + unregistered: undefined; + unregistrationerror: unknown; + connected: undefined; + connectionerror: unknown; + callestablished: undefined; + incomingcall: ICallerInfo; + callterminated: undefined; + hold: undefined; + holderror: undefined; + muteerror: undefined; + unhold: undefined; + unholderror: undefined; + stateChanged: undefined; }; diff --git a/packages/core-typings/src/voip/index.ts b/packages/core-typings/src/voip/index.ts index 9d229d58d71a..584d349ea89c 100644 --- a/packages/core-typings/src/voip/index.ts +++ b/packages/core-typings/src/voip/index.ts @@ -1,14 +1,14 @@ -export * from "./CallStates"; -export * from "./ConnectionState"; -export * from "./ICallerInfo"; -export * from "./IConnectionDelegate"; -export * from "./IEvents"; -export * from "./IQueueInfo"; -export * from "./IRegisterHandlerDelegate"; -export * from "./IRegistrationInfo"; -export * from "./Operations"; -export * from "./SignalingSocketEvents"; -export * from "./UserState"; -export * from "./VoipClientEvents"; -export * from "./VoipEvents"; -export * from "./WorkflowTypes"; +export * from './CallStates'; +export * from './ConnectionState'; +export * from './ICallerInfo'; +export * from './IConnectionDelegate'; +export * from './IEvents'; +export * from './IQueueInfo'; +export * from './IRegisterHandlerDelegate'; +export * from './IRegistrationInfo'; +export * from './Operations'; +export * from './SignalingSocketEvents'; +export * from './UserState'; +export * from './VoipClientEvents'; +export * from './VoipEvents'; +export * from './WorkflowTypes'; diff --git a/packages/eslint-config/.eslintrc.js b/packages/eslint-config/.eslintrc.js new file mode 100644 index 000000000000..c22d591dea9c --- /dev/null +++ b/packages/eslint-config/.eslintrc.js @@ -0,0 +1,3 @@ +module.exports = { + extends: './standard/index.js', +}; diff --git a/packages/eslint-config/best-practices/index.js b/packages/eslint-config/best-practices/index.js new file mode 100644 index 000000000000..ea745228dbe3 --- /dev/null +++ b/packages/eslint-config/best-practices/index.js @@ -0,0 +1,327 @@ +module.exports = { + rules: { + // // enforces getter/setter pairs in objects + // 'accessor-pairs': 'off', + + // enforces return statements in callbacks of array's methods + // https://eslint.org/docs/rules/array-callback-return + 'array-callback-return': ['error', { allowImplicit: true }], + + // treat var statements as if they were block scoped + 'block-scoped-var': 'error', + + // specify the maximum cyclomatic complexity allowed in a program + 'complexity': ['warn', 31], + + // enforce that class methods use "this" + // https://eslint.org/docs/rules/class-methods-use-this + // 'class-methods-use-this': ['error', { + // exceptMethods: [], + // }], + + // require return statements to either always or never specify values + // 'consistent-return': 'error', + + // specify curly brace conventions for all control statements + 'curly': ['error', 'all'], + + // // require default case in switch statements + // 'default-case': ['error', { commentPattern: '^no default$' }], + + // encourages use of dot notation whenever possible + 'dot-notation': ['error', { allowKeywords: true }], + + // enforces consistent newlines before or after dots + // https://eslint.org/docs/rules/dot-location + 'dot-location': ['error', 'property'], + + // require the use of === and !== + // https://eslint.org/docs/rules/eqeqeq + 'eqeqeq': ['error', 'allow-null'], + + // make sure for-in loops have an if statement + 'guard-for-in': 'error', + + // // enforce a maximum number of classes per file + // // https://eslint.org/docs/rules/max-classes-per-file + // // TODO: semver-major (eslint 5): enable + // 'max-classes-per-file': ['off', 1], + + // // disallow the use of alert, confirm, and prompt + // 'no-alert': 'warn', + + // disallow use of arguments.caller or arguments.callee + 'no-caller': 'error', + + // disallow lexical declarations in case/default clauses + // https://eslint.org/docs/rules/no-case-declarations.html + // 'no-case-declarations': 'error', + + // disallow division operators explicitly at beginning of regular expression + // https://eslint.org/docs/rules/no-div-regex + 'no-div-regex': 'off', + + // disallow else after a return in an if + // https://eslint.org/docs/rules/no-else-return + 'no-else-return': ['error', { allowElseIf: false }], + + // disallow empty functions, except for standalone funcs/arrows + // https://eslint.org/docs/rules/no-empty-function + 'no-empty-function': [ + 'error', + { + allow: ['arrowFunctions', 'functions', 'methods'], + }, + ], + + // disallow empty destructuring patterns + // https://eslint.org/docs/rules/no-empty-pattern + 'no-empty-pattern': 'error', + + // // disallow comparisons to null without a type-checking operator + // 'no-eq-null': 'off', + + // disallow use of eval() + 'no-eval': 'error', + + // disallow adding to native types + 'no-extend-native': 'error', + + // disallow unnecessary function binding + 'no-extra-bind': 'error', + + // disallow Unnecessary Labels + // https://eslint.org/docs/rules/no-extra-label + 'no-extra-label': 'error', + + // disallow fallthrough of case statements + 'no-fallthrough': 'error', + + // disallow the use of leading or trailing decimal points in numeric literals + 'no-floating-decimal': 'error', + + // // disallow reassignments of native objects or read-only globals + // // https://eslint.org/docs/rules/no-global-assign + // 'no-global-assign': ['error', { exceptions: [] }], + // // deprecated in favor of no-global-assign + // 'no-native-reassign': 'off', + + // // disallow implicit type conversions + // // https://eslint.org/docs/rules/no-implicit-coercion + // 'no-implicit-coercion': ['off', { + // boolean: false, + // number: true, + // string: true, + // allow: [], + // }], + + // // disallow var and named functions in global scope + // // https://eslint.org/docs/rules/no-implicit-globals + // 'no-implicit-globals': 'off', + + // disallow use of eval()-like methods + 'no-implied-eval': 'error', + + // disallow this keywords outside of classes or class-like objects + 'no-invalid-this': 'off', + + // disallow usage of __iterator__ property + 'no-iterator': 'error', + + // // disallow use of labels for anything other then loops and switches + // 'no-labels': ['error', { allowLoop: false, allowSwitch: false }], + + // disallow unnecessary nested blocks + 'no-lone-blocks': 'error', + + // disallow creation of functions within loops + 'no-loop-func': 'error', + + // // disallow magic numbers + // // https://eslint.org/docs/rules/no-magic-numbers + // 'no-magic-numbers': ['off', { + // ignore: [], + // ignoreArrayIndexes: true, + // enforceConst: true, + // detectObjects: false, + // }], + + // disallow use of multiple spaces + 'no-multi-spaces': 'error', + + // disallow use of multiline strings + 'no-multi-str': 'error', + + // disallow use of new operator when not part of the assignment or comparison + // 'no-new': 'error', + + // disallow use of new operator for Function object + // 'no-new-func': 'error', + + // disallows creating new instances of String, Number, and Boolean + 'no-new-wrappers': 'error', + + // disallow use of (old style) octal literals + 'no-octal': 'error', + + // // disallow use of octal escape sequences in string literals, such as + // // var foo = 'Copyright \251'; + // 'no-octal-escape': 'error', + + // // disallow reassignment of function parameters + // // disallow parameter object manipulation except for specific exclusions + // // rule: https://eslint.org/docs/rules/no-param-reassign.html + // 'no-param-reassign': ['error', { + // props: true, + // ignorePropertyModificationsFor: [ + // 'acc', // for reduce accumulators + // 'accumulator', // for reduce accumulators + // 'e', // for e.returnvalue + // 'ctx', // for Koa routing + // 'req', // for Express requests + // 'request', // for Express requests + // 'res', // for Express responses + // 'response', // for Express responses + // '$scope', // for Angular 1 scopes + // ] + // }], + + // disallow usage of __proto__ property + 'no-proto': 'error', + + // disallow declaring the same variable more then once + 'no-redeclare': 'error', + + // // disallow certain object properties + // // https://eslint.org/docs/rules/no-restricted-properties + // 'no-restricted-properties': ['error', { + // object: 'arguments', + // property: 'callee', + // message: 'arguments.callee is deprecated', + // }, { + // object: 'global', + // property: 'isFinite', + // message: 'Please use Number.isFinite instead', + // }, { + // object: 'self', + // property: 'isFinite', + // message: 'Please use Number.isFinite instead', + // }, { + // object: 'window', + // property: 'isFinite', + // message: 'Please use Number.isFinite instead', + // }, { + // object: 'global', + // property: 'isNaN', + // message: 'Please use Number.isNaN instead', + // }, { + // object: 'self', + // property: 'isNaN', + // message: 'Please use Number.isNaN instead', + // }, { + // object: 'window', + // property: 'isNaN', + // message: 'Please use Number.isNaN instead', + // }, { + // property: '__defineGetter__', + // message: 'Please use Object.defineProperty instead.', + // }, { + // property: '__defineSetter__', + // message: 'Please use Object.defineProperty instead.', + // }, { + // object: 'Math', + // property: 'pow', + // message: 'Use the exponentiation operator (**) instead.', + // }], + + // disallow use of assignment in return statement + 'no-return-assign': ['error', 'always'], + + // disallow redundant `return await` + 'no-return-await': 'error', + + // // disallow use of `javascript:` urls. + // 'no-script-url': 'error', + + // // disallow self assignment + // // https://eslint.org/docs/rules/no-self-assign + // // TODO: semver-major: props -> true + // 'no-self-assign': ['error', { + // props: false, + // }], + + // disallow comparisons where both sides are exactly the same + 'no-self-compare': 'error', + + // disallow use of comma operator + 'no-sequences': 'error', + + // restrict what can be thrown as an exception + 'no-throw-literal': 'error', + + // // disallow unmodified conditions of loops + // // https://eslint.org/docs/rules/no-unmodified-loop-condition + // 'no-unmodified-loop-condition': 'off', + + // // disallow usage of expressions in statement position + // 'no-unused-expressions': ['error', { + // allowShortCircuit: false, + // allowTernary: false, + // allowTaggedTemplates: false, + // }], + + // disallow unused labels + // https://eslint.org/docs/rules/no-unused-labels + 'no-unused-labels': 'error', + + // disallow unnecessary .call() and .apply() + 'no-useless-call': 'off', + + // disallow useless string concatenation + // https://eslint.org/docs/rules/no-useless-concat + 'no-useless-concat': 'error', + + // // disallow unnecessary string escaping + // // https://eslint.org/docs/rules/no-useless-escape + // 'no-useless-escape': 'error', + + // disallow redundant return; keywords + // https://eslint.org/docs/rules/no-useless-return + 'no-useless-return': 'error', + + // disallow use of void operator + // https://eslint.org/docs/rules/no-void + 'no-void': 'error', + + // // disallow usage of configurable warning terms in comments: e.g. todo + // 'no-warning-comments': ['off', { terms: ['todo', 'fixme', 'xxx'], location: 'start' }], + + // // disallow use of the with statement + // 'no-with': 'error', + + // // require using Error objects as Promise rejection reasons + // // https://eslint.org/docs/rules/prefer-promise-reject-errors + // 'prefer-promise-reject-errors': ['error', { allowEmptyReject: true }], + + // // require use of the second argument for parseInt() + // radix: 'error', + + // // require `await` in `async function` (note: this is a horrible rule that should never be used) + // // https://eslint.org/docs/rules/require-await + // 'require-await': 'off', + + // // Enforce the use of u flag on RegExp + // // https://eslint.org/docs/rules/require-unicode-regexp + // 'require-unicode-regexp': 'off', + + // // requires to declare all vars on top of their containing scope + // 'vars-on-top': 'error', + + // require immediate function invocation to be wrapped in parentheses + // https://eslint.org/docs/rules/wrap-iife.html + 'wrap-iife': ['error', 'outside', { functionPrototypeMethods: false }], + + // require or disallow Yoda conditions + 'yoda': 'error', + }, +}; diff --git a/packages/eslint-config/errors/index.js b/packages/eslint-config/errors/index.js new file mode 100644 index 000000000000..3223c31e34b2 --- /dev/null +++ b/packages/eslint-config/errors/index.js @@ -0,0 +1,148 @@ +module.exports = { + rules: { + // Enforce “for” loop update clause moving the counter in the right direction + // https://eslint.org/docs/rules/for-direction + 'for-direction': 'error', + + // Enforces that a return statement is present in property getters + // https://eslint.org/docs/rules/getter-return + 'getter-return': ['error', { allowImplicit: true }], + + // disallow using an async function as a Promise executor + // https://eslint.org/docs/rules/no-async-promise-executor + // TODO: enable, semver-major + 'no-async-promise-executor': 'off', + + // Disallow await inside of loops + // https://eslint.org/docs/rules/no-await-in-loop + 'no-await-in-loop': 'error', + + // Disallow comparisons to negative zero + // https://eslint.org/docs/rules/no-compare-neg-zero + 'no-compare-neg-zero': 'error', + + // disallow assignment in conditional expressions + 'no-cond-assign': 'error', + + // disallow use of console + // 'no-console': 'warn', + + // disallow use of constant expressions in conditions + 'no-constant-condition': 'error', + + // disallow control characters in regular expressions + 'no-control-regex': 'error', + + // disallow use of debugger + 'no-debugger': 'error', + + // disallow duplicate arguments in functions + 'no-dupe-args': 'error', + + // disallow duplicate keys when creating object literals + 'no-dupe-keys': 'error', + + // disallow a duplicate case label. + 'no-duplicate-case': 'error', + + // disallow empty statements + 'no-empty': 'error', + + // disallow the use of empty character classes in regular expressions + 'no-empty-character-class': 'error', + + // disallow assigning to the exception in a catch block + 'no-ex-assign': 'error', + + // disallow double-negation boolean casts in a boolean context + // https://eslint.org/docs/rules/no-extra-boolean-cast + 'no-extra-boolean-cast': 'error', + + // disallow unnecessary parentheses + // https://eslint.org/docs/rules/no-extra-parens + 'no-extra-parens': [ + 'error', + 'all', + { + conditionalAssign: true, + nestedBinaryExpressions: false, + returnAssign: true, + ignoreJSX: 'all', // delegate to eslint-plugin-react + enforceForArrowConditionals: false, + }, + ], + + // disallow unnecessary semicolons + 'no-extra-semi': 'error', + + // disallow overwriting functions written as function declarations + 'no-func-assign': 'error', + + // disallow function declarations in nested blocks + 'no-inner-declarations': ['error', 'functions'], + + // disallow invalid regular expression strings in the RegExp constructor + 'no-invalid-regexp': 'error', + + // disallow irregular whitespace outside of strings and comments + 'no-irregular-whitespace': 'error', + + // // Disallow characters which are made with multiple code points in character class syntax + // // https://eslint.org/docs/rules/no-misleading-character-class + // // TODO: enable, semver-major + // 'no-misleading-character-class': 'off', + + // disallow the use of object properties of the global object (Math and JSON) as functions + 'no-obj-calls': 'error', + + // // disallow use of Object.prototypes builtins directly + // // https://eslint.org/docs/rules/no-prototype-builtins + // 'no-prototype-builtins': 'error', + + // disallow multiple spaces in a regular expression literal + 'no-regex-spaces': 'error', + + // disallow sparse arrays + 'no-sparse-arrays': 'error', + + // // Disallow template literal placeholder syntax in regular strings + // // https://eslint.org/docs/rules/no-template-curly-in-string + // 'no-template-curly-in-string': 'error', + + // Avoid code that looks like two expressions but is actually one + // https://eslint.org/docs/rules/no-unexpected-multiline + 'no-unexpected-multiline': 'error', + + // disallow unreachable statements after a return, throw, continue, or break statement + 'no-unreachable': 'error', + + // disallow return/throw/break/continue inside finally blocks + // https://eslint.org/docs/rules/no-unsafe-finally + 'no-unsafe-finally': 'error', + + // disallow negating the left operand of relational operators + // https://eslint.org/docs/rules/no-unsafe-negation + 'no-unsafe-negation': 'error', + + // disallow negation of the left operand of an in expression + // deprecated in favor of no-unsafe-negation + // TODO: turn off + 'no-negated-in-lhs': 'error', + + // Disallow assignments that can lead to race conditions due to usage of await or yield + // https://eslint.org/docs/rules/require-atomic-updates + // TODO: enable, semver-major + 'require-atomic-updates': 'off', + + // disallow comparisons with the value NaN + 'use-isnan': 'error', + + // // ensure JSDoc comments are valid + // // https://eslint.org/docs/rules/valid-jsdoc + // 'valid-jsdoc': 'off', + + // ensure that the results of typeof are compared against a valid string + // https://eslint.org/docs/rules/valid-typeof + 'valid-typeof': ['error', { requireStringLiterals: true }], + }, +}; diff --git a/packages/eslint-config/es6/index.js b/packages/eslint-config/es6/index.js new file mode 100644 index 000000000000..b06679192085 --- /dev/null +++ b/packages/eslint-config/es6/index.js @@ -0,0 +1,189 @@ +module.exports = { + env: { + es6: true, + }, + parserOptions: { + ecmaVersion: 6, + sourceType: 'module', + ecmaFeatures: { + generators: false, + objectLiteralDuplicateProperties: false, + }, + }, + + rules: { + // enforces no braces where they can be omitted + // https://eslint.org/docs/rules/arrow-body-style + // TODO: enable requireReturnForObjectLiteral? + 'arrow-body-style': [ + 'error', + 'as-needed', + { + requireReturnForObjectLiteral: false, + }, + ], + + // require parens in arrow function arguments + // https://eslint.org/docs/rules/arrow-parens + 'arrow-parens': ['error', 'always'], + + // require space before/after arrow function's arrow + // https://eslint.org/docs/rules/arrow-spacing + 'arrow-spacing': ['error', { before: true, after: true }], + + // // verify super() callings in constructors + // 'constructor-super': 'error', + + // // enforce the spacing around the * in generator functions + // // https://eslint.org/docs/rules/generator-star-spacing + // 'generator-star-spacing': ['error', { before: false, after: true }], + + // // disallow modifying variables of class declarations + // // https://eslint.org/docs/rules/no-class-assign + // 'no-class-assign': 'error', + + // disallow arrow functions where they could be confused with comparisons + // https://eslint.org/docs/rules/no-confusing-arrow + 'no-confusing-arrow': [ + 'error', + { + allowParens: true, + }, + ], + + // disallow modifying variables that are declared using const + 'no-const-assign': 'error', + + // disallow duplicate class members + // https://eslint.org/docs/rules/no-dupe-class-members + 'no-dupe-class-members': 'error', + + // disallow importing from the same path more than once + // https://eslint.org/docs/rules/no-duplicate-imports + // replaced by https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-duplicates.md + 'no-duplicate-imports': 'off', + + // // disallow symbol constructor + // // https://eslint.org/docs/rules/no-new-symbol + // 'no-new-symbol': 'error', + + // // disallow specific imports + // // https://eslint.org/docs/rules/no-restricted-imports + // 'no-restricted-imports': ['off', { + // paths: [], + // patterns: [] + // }], + + // disallow to use this/super before super() calling in constructors. + // https://eslint.org/docs/rules/no-this-before-super + 'no-this-before-super': 'error', + + // disallow useless computed property keys + // https://eslint.org/docs/rules/no-useless-computed-key + 'no-useless-computed-key': 'error', + + // disallow unnecessary constructor + // https://eslint.org/docs/rules/no-useless-constructor + 'no-useless-constructor': 'error', + + // disallow renaming import, export, and destructured assignments to the same name + // https://eslint.org/docs/rules/no-useless-rename + 'no-useless-rename': [ + 'error', + { + ignoreDestructuring: false, + ignoreImport: false, + ignoreExport: false, + }, + ], + + // require let or const instead of var + 'no-var': 'error', + + // require method and property shorthand syntax for object literals + // https://eslint.org/docs/rules/object-shorthand + 'object-shorthand': 'error', + + // // suggest using arrow functions as callbacks + // 'prefer-arrow-callback': ['error', { + // allowNamedFunctions: false, + // allowUnboundThis: true, + // }], + + // suggest using of const declaration for variables that are never modified after declared + 'prefer-const': [ + 'error', + { + destructuring: 'any', + ignoreReadBeforeAssign: true, + }, + ], + + // Prefer destructuring from arrays and objects + // https://eslint.org/docs/rules/prefer-destructuring + 'prefer-destructuring': [ + 'error', + { + VariableDeclarator: { + array: false, + object: true, + }, + AssignmentExpression: { + array: false, + object: false, + }, + }, + { + enforceForRenamedProperties: false, + }, + ], + + // // disallow parseInt() in favor of binary, octal, and hexadecimal literals + // // https://eslint.org/docs/rules/prefer-numeric-literals + // 'prefer-numeric-literals': 'error', + + // // suggest using Reflect methods where applicable + // // https://eslint.org/docs/rules/prefer-reflect + // 'prefer-reflect': 'off', + + // use rest parameters instead of arguments + // https://eslint.org/docs/rules/prefer-rest-params + 'prefer-rest-params': 'error', + + // // suggest using the spread operator instead of .apply() + // // https://eslint.org/docs/rules/prefer-spread + // 'prefer-spread': 'error', + + // suggest using template literals instead of string concatenation + // https://eslint.org/docs/rules/prefer-template + 'prefer-template': 'error', + + // // disallow generator functions that do not have yield + // // https://eslint.org/docs/rules/require-yield + // 'require-yield': 'error', + + // enforce spacing between object rest-spread + // https://eslint.org/docs/rules/rest-spread-spacing + 'rest-spread-spacing': ['error', 'never'], + + // // import sorting + // // https://eslint.org/docs/rules/sort-imports + // 'sort-imports': ['off', { + // ignoreCase: false, + // ignoreMemberSort: false, + // memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'], + // }], + + // // require a Symbol description + // // https://eslint.org/docs/rules/symbol-description + // 'symbol-description': 'error', + + // enforce usage of spacing in template strings + // https://eslint.org/docs/rules/template-curly-spacing + 'template-curly-spacing': ['error', 'always'], + + // // enforce spacing around the * in yield* expressions + // // https://eslint.org/docs/rules/yield-star-spacing + // 'yield-star-spacing': ['error', 'after'] + }, +}; diff --git a/packages/eslint-config/imports/index.js b/packages/eslint-config/imports/index.js new file mode 100644 index 000000000000..cc2a33662314 --- /dev/null +++ b/packages/eslint-config/imports/index.js @@ -0,0 +1,254 @@ +module.exports = { + env: { + es6: true, + }, + parserOptions: { + ecmaVersion: 6, + sourceType: 'module', + }, + plugins: ['import'], + + settings: { + 'import/resolver': { + node: { + extensions: ['.mjs', '.js', '.json'], + }, + }, + 'import/extensions': ['.js', '.mjs', '.jsx'], + 'import/core-modules': [], + 'import/ignore': ['node_modules', '\\.(coffee|scss|css|less|hbs|svg|json)$'], + }, + + rules: { + // Static analysis: + + // ensure imports point to files/modules that can be resolved + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-unresolved.md + 'import/no-unresolved': [ + 'error', + { + commonjs: true, + caseSensitive: true, + amd: true, + ignore: ['^meteor/.+$'], + }, + ], + + // ensure named imports coupled with named exports + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/named.md#when-not-to-use-it + 'import/named': 'off', + + // ensure default import coupled with default export + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/default.md#when-not-to-use-it + 'import/default': 'off', + + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/namespace.md + 'import/namespace': 'off', + + // Helpful warnings: + + // disallow invalid exports, e.g. multiple defaults + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/export.md + 'import/export': 'error', + + // do not allow a default import name to match a named export + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-named-as-default.md + // 'import/no-named-as-default': 'error', + 'import/no-named-as-default': 'off', + + // warn on accessing default export property names that are also named exports + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-named-as-default-member.md + // 'import/no-named-as-default-member': 'error', + 'import/no-named-as-default-member': 'off', + + // // disallow use of jsdoc-marked-deprecated imports + // // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-deprecated.md + // 'import/no-deprecated': 'off', + + // // Forbid the use of extraneous packages + // // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-extraneous-dependencies.md + // // paths are treated both as absolute paths, and relative to process.cwd() + // 'import/no-extraneous-dependencies': ['error', { + // devDependencies: [ + // 'test/**', // tape, common npm pattern + // 'tests/**', // also common npm pattern + // 'spec/**', // mocha, rspec-like pattern + // '**/__tests__/**', // jest pattern + // '**/__mocks__/**', // jest pattern + // 'test.{js,jsx}', // repos with a single test file + // 'test-*.{js,jsx}', // repos with multiple top-level test files + // '**/*{.,_}{test,spec}.{js,jsx}', // tests where the extension or filename suffix denotes that it is a test + // '**/jest.config.js', // jest config + // '**/vue.config.js', // vue-cli config + // '**/webpack.config.js', // webpack config + // '**/webpack.config.*.js', // webpack config + // '**/rollup.config.js', // rollup config + // '**/rollup.config.*.js', // rollup config + // '**/gulpfile.js', // gulp config + // '**/gulpfile.*.js', // gulp config + // '**/Gruntfile{,.js}', // grunt config + // '**/protractor.conf.js', // protractor config + // '**/protractor.conf.*.js', // protractor config + // ], + // optionalDependencies: false, + // }], + + // // Forbid mutable exports + // // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-mutable-exports.md + // 'import/no-mutable-exports': 'error', + + // Module systems: + + // // disallow require() + // // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-commonjs.md + // 'import/no-commonjs': 'off', + + // // disallow AMD require/define + // // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-amd.md + // 'import/no-amd': 'error', + + // // No Node.js builtin modules + // // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-nodejs-modules.md + // // TODO: enable? + // 'import/no-nodejs-modules': 'off', + + // Style guide: + + // disallow non-import statements appearing before import statements + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/first.md + 'import/first': 'error', + + // // disallow non-import statements appearing before import statements + // // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/imports-first.md + // // deprecated: use `import/first` + // 'import/imports-first': 'off', + + // disallow duplicate imports + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-duplicates.md + 'import/no-duplicates': 'error', + + // // disallow namespace imports + // // TODO: enable? + // // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-namespace.md + // 'import/no-namespace': 'off', + + // // Ensure consistent use of file extension within the import path + // // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/extensions.md + // 'import/extensions': ['error', 'ignorePackages', { + // js: 'never', + // mjs: 'never', + // jsx: 'never', + // }], + + // ensure absolute imports are above relative imports and that unassigned imports are ignored + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/order.md + // TODO: enforce a stricter convention in module import order? + 'import/order': [ + 'error', + { + 'newlines-between': 'always', + 'groups': ['builtin', 'external', 'internal', ['parent', 'sibling', 'index']], + }, + ], + + // Require a newline after the last import/require in a group + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/newline-after-import.md + 'import/newline-after-import': 'error', + + // // Require modules with a single export to use a default export + // // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/prefer-default-export.md + // 'import/prefer-default-export': 'error', + + // // Restrict which files can be imported in a given folder + // // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-restricted-paths.md + // 'import/no-restricted-paths': 'off', + + // // Forbid modules to have too many dependencies + // // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/max-dependencies.md + // 'import/max-dependencies': ['off', { max: 10 }], + + // Forbid import of modules using absolute paths + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-absolute-path.md + 'import/no-absolute-path': 'error', + + // Forbid require() calls with expressions + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-dynamic-require.md + 'import/no-dynamic-require': 'error', + + // // prevent importing the submodules of other modules + // // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-internal-modules.md + // 'import/no-internal-modules': ['off', { + // allow: [], + // }], + + // // Warn if a module could be mistakenly parsed as a script by a consumer + // // leveraging Unambiguous JavaScript Grammar + // // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/unambiguous.md + // // this should not be enabled until this proposal has at least been *presented* to TC39. + // // At the moment, it's not a thing. + // 'import/unambiguous': 'off', + + // // Forbid Webpack loader syntax in imports + // // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-webpack-loader-syntax.md + // 'import/no-webpack-loader-syntax': 'error', + + // // Prevent unassigned imports + // // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-unassigned-import.md + // // importing for side effects is perfectly acceptable, if you need side effects. + // 'import/no-unassigned-import': 'off', + + // // Prevent importing the default as if it were named + // // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-named-default.md + // 'import/no-named-default': 'error', + + // // Reports if a module's default export is unnamed + // // https://github.com/benmosher/eslint-plugin-import/blob/d9b712ac7fd1fddc391f7b234827925c160d956f/docs/rules/no-anonymous-default-export.md + // 'import/no-anonymous-default-export': ['off', { + // allowArray: false, + // allowArrowFunction: false, + // allowAnonymousClass: false, + // allowAnonymousFunction: false, + // allowLiteral: false, + // allowObject: false, + // }], + + // // This rule enforces that all exports are declared at the bottom of the file. + // // https://github.com/benmosher/eslint-plugin-import/blob/98acd6afd04dcb6920b81330114e146dc8532ea4/docs/rules/exports-last.md + // // TODO: enable? + // 'import/exports-last': 'off', + + // // Reports when named exports are not grouped together in a single export declaration + // // or when multiple assignments to CommonJS module.exports or exports object are present + // // in a single file. + // // https://github.com/benmosher/eslint-plugin-import/blob/44a038c06487964394b1e15b64f3bd34e5d40cde/docs/rules/group-exports.md + // 'import/group-exports': 'off', + + // // forbid default exports. this is a terrible rule, do not use it. + // // https://github.com/benmosher/eslint-plugin-import/blob/44a038c06487964394b1e15b64f3bd34e5d40cde/docs/rules/no-default-export.md + // 'import/no-default-export': 'off', + + // Forbid a module from importing itself + // https://github.com/benmosher/eslint-plugin-import/blob/44a038c06487964394b1e15b64f3bd34e5d40cde/docs/rules/no-self-import.md + 'import/no-self-import': 'error', + + // Forbid cyclical dependencies between modules + // https://github.com/benmosher/eslint-plugin-import/blob/d81f48a2506182738409805f5272eff4d77c9348/docs/rules/no-cycle.md + // 'import/no-cycle': ['error', { maxDepth: Infinity }], + 'import/no-cycle': 'off', + + // Ensures that there are no useless path segments + // https://github.com/benmosher/eslint-plugin-import/blob/ebafcbf59ec9f653b2ac2a0156ca3bcba0a7cf57/docs/rules/no-useless-path-segments.md + 'import/no-useless-path-segments': 'error', + + // // dynamic imports require a leading comment with a webpackChunkName + // // https://github.com/benmosher/eslint-plugin-import/blob/ebafcbf59ec9f653b2ac2a0156ca3bcba0a7cf57/docs/rules/dynamic-import-chunkname.md + // 'import/dynamic-import-chunkname': ['off', { + // importFunctions: [], + // webpackChunknameFormat: '[0-9a-zA-Z-_/.]+', + // }], + + // // Use this rule to prevent imports to folders in relative parent paths. + // // https://github.com/benmosher/eslint-plugin-import/blob/c34f14f67f077acd5a61b3da9c0b0de298d20059/docs/rules/no-relative-parent-imports.md + // 'import/no-relative-parent-imports': 'off', + }, +}; diff --git a/packages/eslint-config/node/index.js b/packages/eslint-config/node/index.js new file mode 100644 index 000000000000..396bb969c7df --- /dev/null +++ b/packages/eslint-config/node/index.js @@ -0,0 +1,33 @@ +module.exports = { + env: { + node: true, + }, + + rules: { + // enforce return after a callback + // 'callback-return': 'off', + // // require all requires be top-level + // // https://eslint.org/docs/rules/global-require + // 'global-require': 'error', + // // enforces error handling in callbacks (node environment) + // 'handle-callback-err': 'off', + // // disallow use of the Buffer() constructor + // // https://eslint.org/docs/rules/no-buffer-constructor + // 'no-buffer-constructor': 'error', + // // disallow mixing regular variable and require declarations + // 'no-mixed-requires': ['off', false], + // // disallow use of new operator with the require function + // 'no-new-require': 'error', + // // disallow string concatenation with __dirname and __filename + // // https://eslint.org/docs/rules/no-path-concat + // 'no-path-concat': 'error', + // // disallow use of process.env + // 'no-process-env': 'off', + // // disallow process.exit() + // 'no-process-exit': 'off', + // // restrict usage of specified node modules + // 'no-restricted-modules': 'off', + // // disallow use of synchronous methods (off by default) + // 'no-sync': 'off', + }, +}; diff --git a/packages/eslint-config/original/index.js b/packages/eslint-config/original/index.js new file mode 100644 index 000000000000..1e0fe050becc --- /dev/null +++ b/packages/eslint-config/original/index.js @@ -0,0 +1,149 @@ +module.exports = { + extends: [ + '../best-practices/index.js', + '../errors/index.js', + '../node/index.js', + '../style/index.js', + '../variables/index.js', + '../es6/index.js', + '../imports/index.js', + ], + + parserOptions: { + sourceType: 'module', + ecmaVersion: 2018, + ecmaFeatures: { + generators: false, + objectLiteralDuplicateProperties: false, + }, + }, + env: { + browser: true, + commonjs: true, + es6: true, + node: true, + jquery: true, + }, + // rules: { + // // 'no-multi-spaces': 2, + // // 'no-eval': 2, + // // 'no-extend-native': 2, + // // 'no-multi-str': 2, + // // 'no-use-before-define': 2, + // // 'no-const-assign': 2, + // // 'no-cond-assign': 2, + // // 'no-constant-condition': 2, + // // 'no-control-regex': 2, + // // 'no-debugger': 2, + // // 'no-delete-var': 2, + // // 'no-dupe-keys': 2, + // // 'no-dupe-args': 2, + // // 'no-dupe-class-members': 2, + // // 'no-duplicate-case': 2, + // // 'no-empty': 2, + // // 'no-empty-character-class': 2, + // // 'no-ex-assign': 2, + // // 'no-extra-boolean-cast': 2, + // // 'no-extra-semi': 2, + // // 'no-fallthrough': 2, + // // 'no-func-assign': 2, + // // 'no-inner-declarations': [2, 'functions'], + // // 'no-invalid-regexp': 2, + // // 'no-irregular-whitespace': 2, + // // 'no-mixed-operators': [2, { + // // 'groups': [ + // // ['%', '**'], + // // ['%', '+'], + // // ['%', '-'], + // // ['%', '*'], + // // ['%', '/'], + // // ['**', '+'], + // // ['**', '-'], + // // ['**', '*'], + // // ['**', '/'], + // // ['&', '|', '^', '~', '<<', '>>', '>>>'], + // // ['==', '!=', '===', '!==', '>', '>=', '<', '<='], + // // ['&&', '||'], + // // ['in', 'instanceof'] + // // ], + // // 'allowSamePrecedence': false + // // }], + // // 'no-mixed-spaces-and-tabs': 2, + // // 'no-sparse-arrays': 2, + // // 'no-negated-in-lhs': 2, + // // 'no-obj-calls': 2, + // // 'no-octal': 2, + // // 'no-redeclare': 2, + // // 'no-regex-spaces': 2, + // // 'no-undef': 2, + // // 'no-unreachable': 2, + // // 'no-unused-vars': [2, { + // // 'vars': 'all', + // // 'args': 'after-used' + // // }], + // // 'no-void': 2, + // // 'no-var': 2, + // // 'no-multiple-empty-lines': [2, { 'max': 2 }], + // // 'no-nested-ternary': 2, + // // 'prefer-rest-params': 2, + // // 'array-callback-return': 2, + // // 'prefer-destructuring': [2, { + // // 'VariableDeclarator': { + // // 'array': false, + // // 'object': true + // // }, + // // 'AssignmentExpression': { + // // 'array': false, + // // 'object': false + // // } + // // }, { + // // 'enforceForRenamedProperties': false + // // }], + // // 'no-duplicate-imports': 2, + // // 'arrow-parens': [2, 'always'], + // // 'quote-props': [2, 'as-needed'], + // // 'no-array-constructor': 2, + // // 'arrow-spacing': 2, + // // 'arrow-body-style': [2, 'as-needed'], + // // 'no-confusing-arrow': [2, { 'allowParens': true }], + // // 'dot-notation': 2, + // // 'no-unneeded-ternary': 2, + // // 'spaced-comment': 2, + // // 'space-infix-ops': 2, + // // 'array-bracket-spacing': [2, 'never'], + // // 'object-curly-spacing': [2, 'always'], + // // 'one-var': [2, 'never'], + // // 'no-lonely-if': 2, + // // 'no-trailing-spaces': 2, + // // 'complexity': [1, 31], + // // 'space-in-parens': [2, 'never'], + // // 'space-before-function-paren': [2, 'never'], + // // 'space-before-blocks': [2, 'always'], + // // 'indent': [2, 'tab', {'SwitchCase': 1}], + // // 'eol-last': [2, 'always'], + // // 'comma-dangle': [2, 'always-multiline'], + // // 'keyword-spacing': 2, + // // 'block-spacing': 2, + // // 'brace-style': [2, '1tbs', { 'allowSingleLine': true }], + // // 'computed-property-spacing': 2, + // // 'comma-spacing': 2, + // // 'comma-style': 2, + // // 'guard-for-in': 2, + // // 'wrap-iife': 2, + // // 'block-scoped-var': 2, + // // 'curly': [2, 'all'], + // // 'eqeqeq': [2, 'allow-null'], + // // 'new-cap': [2, { + // // 'capIsNewExceptions': ['Match.Optional', 'Match.Maybe', 'Match.OneOf', 'Match.Where', 'Match.ObjectIncluding', 'Push.Configure', 'SHA256'] + // // }], + // // 'use-isnan': 2, + // // 'valid-typeof': 2, + // // 'linebreak-style': [2, 'unix'], + // // 'prefer-template': 2, + // // 'template-curly-spacing': [2, 'always'], + // // 'quotes': [2, 'single'], + // // 'semi': [2, 'always'], + // // 'prefer-const': 2, + // // 'object-shorthand': 2 + // } +}; diff --git a/packages/eslint-config/package.json b/packages/eslint-config/package.json new file mode 100644 index 000000000000..ee30e12b4440 --- /dev/null +++ b/packages/eslint-config/package.json @@ -0,0 +1,34 @@ +{ + "name": "@rocket.chat/eslint-config", + "version": "0.5.0", + "description": "Rocket.Chat's JS ESLint config", + "devDependencies": { + "@types/prettier": "^2", + "@typescript-eslint/eslint-plugin": "^2.34.0", + "@typescript-eslint/parser": "^3.0.0", + "babel-eslint": "^10.1.0", + "eslint": "^6.8.0", + "eslint-config-prettier": "^8.3.0", + "eslint-plugin-anti-trojan-source": "^1.1.0", + "eslint-plugin-import": "^2.24.2", + "eslint-plugin-jest": "^26.1.5", + "eslint-plugin-prettier": "^3.4.1", + "prettier": "2.6.2" + }, + "scripts": { + "lint": "eslint --ext .js .", + "lint:fix": "eslint --ext .js . --fix" + }, + "main": "./standard/index.js", + "files": [ + "/standard", + "/original", + "/best-practices", + "/errors", + "/es6", + "/imports", + "/node", + "/style", + "/variables" + ] +} diff --git a/packages/eslint-config/standard/index.js b/packages/eslint-config/standard/index.js new file mode 100644 index 000000000000..f31b0ad4c72c --- /dev/null +++ b/packages/eslint-config/standard/index.js @@ -0,0 +1,84 @@ +module.exports = { + extends: ['../original/index.js', 'plugin:prettier/recommended', 'plugin:import/typescript'], + parser: 'babel-eslint', + settings: { + 'import/resolver': { + node: { + extensions: ['.js', '.ts', '.tsx'], + }, + }, + }, + rules: { + 'jsx-quotes': ['error', 'prefer-single'], + }, + overrides: [ + { + files: ['**/*.ts', '**/*.tsx'], + extends: [ + 'plugin:@typescript-eslint/recommended', + 'plugin:@typescript-eslint/eslint-recommended', + '../original/index.js', + 'plugin:prettier/recommended', + ], + parser: '@typescript-eslint/parser', + parserOptions: { + sourceType: 'module', + ecmaVersion: 2018, + warnOnUnsupportedTypeScriptVersion: false, + ecmaFeatures: { + experimentalObjectRestSpread: true, + legacyDecorators: true, + }, + }, + plugins: ['@typescript-eslint', 'anti-trojan-source'], + rules: { + 'func-call-spacing': 'off', + 'jsx-quotes': ['error', 'prefer-single'], + 'indent': 'off', + 'no-dupe-class-members': 'off', + 'no-spaced-func': 'off', + 'no-unused-vars': 'off', + 'no-useless-constructor': 'off', + 'no-use-before-define': 'off', + '@typescript-eslint/ban-ts-ignore': 'off', + '@typescript-eslint/interface-name-prefix': ['error', 'always'], + // The following config should successfully replace @typescript-eslint/interface-name-prefix as it is deprecated on newer versions + // '@typescript-eslint/naming-convention': [ + // 'error', + // { + // selector: 'interface', + // format: ['PascalCase'], + // custom: { + // regex: '^I[A-Z]', + // match: true, + // }, + // }, + // ], + '@typescript-eslint/no-dupe-class-members': 'error', + '@typescript-eslint/no-explicit-any': 'off', + '@typescript-eslint/no-unused-vars': [ + 'error', + { + argsIgnorePattern: '^_', + ignoreRestSiblings: true, + }, + ], + '@typescript-eslint/prefer-optional-chain': 'warn', + 'anti-trojan-source/no-bidi': 'error', + }, + env: { + browser: true, + commonjs: true, + es6: true, + node: true, + }, + settings: { + 'import/resolver': { + node: { + extensions: ['.js', '.ts', '.tsx'], + }, + }, + }, + }, + ], +}; diff --git a/packages/eslint-config/style/index.js b/packages/eslint-config/style/index.js new file mode 100644 index 000000000000..ca875683dbeb --- /dev/null +++ b/packages/eslint-config/style/index.js @@ -0,0 +1,473 @@ +module.exports = { + rules: { + // enforce line breaks after opening and before closing array brackets + // https://eslint.org/docs/rules/array-bracket-newline + // TODO: enable? semver-major + // 'array-bracket-newline': ['off', 'consistent'], // object option alternative: { multiline: true, minItems: 3 } + + // // enforce line breaks between array elements + // // https://eslint.org/docs/rules/array-element-newline + // // TODO: enable? semver-major + // 'array-element-newline': ['off', { multiline: true, minItems: 3 }], + + // enforce spacing inside array brackets + 'array-bracket-spacing': ['error', 'never'], + + // enforce spacing inside single-line blocks + // https://eslint.org/docs/rules/block-spacing + 'block-spacing': 'error', + + // enforce one true brace style + 'brace-style': ['error', '1tbs', { allowSingleLine: true }], + + // // require camel case names + // // TODO: semver-major (eslint 5): add ignoreDestructuring: false option + // camelcase: ['error', { properties: 'never' }], + + // // enforce or disallow capitalization of the first letter of a comment + // // https://eslint.org/docs/rules/capitalized-comments + // 'capitalized-comments': ['off', 'never', { + // line: { + // ignorePattern: '.*', + // ignoreInlineComments: true, + // ignoreConsecutiveComments: true, + // }, + // block: { + // ignorePattern: '.*', + // ignoreInlineComments: true, + // ignoreConsecutiveComments: true, + // }, + // }], + + // require trailing commas in multiline object literals + 'comma-dangle': ['error', 'always-multiline'], + + // enforce spacing before and after comma + 'comma-spacing': 'error', + + // enforce one true comma style + 'comma-style': 'error', + + // disallow padding inside computed properties + 'computed-property-spacing': ['error', 'never'], + + // // enforces consistent naming when capturing the current execution context + // 'consistent-this': 'off', + + // enforce newline at the end of file, with no multiple empty lines + 'eol-last': ['error', 'always'], + + // enforce spacing between functions and their invocations + // https://eslint.org/docs/rules/func-call-spacing + 'func-call-spacing': ['error', 'never'], + + // // requires function names to match the name of the variable or property to which they are + // // assigned + // // https://eslint.org/docs/rules/func-name-matching + // // TODO: semver-major (eslint 5): add considerPropertyDescriptor: true + // 'func-name-matching': ['off', 'always', { + // includeCommonJSModuleExports: false + // }], + + // // require function expressions to have a name + // // https://eslint.org/docs/rules/func-names + // 'func-names': 'warn', + + // // enforces use of function declarations or expressions + // // https://eslint.org/docs/rules/func-style + // // TODO: enable + // 'func-style': ['off', 'expression'], + + // // enforce consistent line breaks inside function parentheses + // // https://eslint.org/docs/rules/function-paren-newline + // 'function-paren-newline': ['error', 'consistent'], + + // // Blacklist certain identifiers to prevent them being used + // // https://eslint.org/docs/rules/id-blacklist + // 'id-blacklist': 'off', + + // // this option enforces minimum and maximum identifier lengths + // // (variable names, property names etc.) + // 'id-length': 'off', + + // // require identifiers to match the provided regular expression + // 'id-match': 'off', + + // Enforce the location of arrow function bodies with implicit returns + // https://eslint.org/docs/rules/implicit-arrow-linebreak + // 'implicit-arrow-linebreak': ['error', 'beside'], + + // this option sets a specific tab width for your code + // https://eslint.org/docs/rules/indent + 'indent': ['error', 'tab', { SwitchCase: 1 }], + + // // specify whether double or single quotes should be used in JSX attributes + // // https://eslint.org/docs/rules/jsx-quotes + // 'jsx-quotes': ['off', 'prefer-double'], + + // enforces spacing between keys and values in object literal properties + 'key-spacing': ['error', { beforeColon: false, afterColon: true }], + + // require a space before & after certain keywords + 'keyword-spacing': 'error', + + // // enforce position of line comments + // // https://eslint.org/docs/rules/line-comment-position + // // TODO: enable? + // 'line-comment-position': ['off', { + // position: 'above', + // ignorePattern: '', + // applyDefaultPatterns: true, + // }], + + // disallow mixed 'LF' and 'CRLF' as linebreaks + // https://eslint.org/docs/rules/linebreak-style + 'linebreak-style': ['error', 'unix'], + + // require or disallow an empty line between class members + // https://eslint.org/docs/rules/lines-between-class-members + 'lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: false }], + + // // enforces empty lines around comments + // 'lines-around-comment': 'off', + + // require or disallow newlines around directives + // https://eslint.org/docs/rules/lines-around-directive + 'lines-around-directive': [ + 'error', + { + before: 'always', + after: 'always', + }, + ], + + // specify the maximum depth that blocks can be nested + 'max-depth': ['off', 4], + + // // specify the maximum length of a line in your program + // // https://eslint.org/docs/rules/max-len + // 'max-len': ['error', 100, 2, { + // ignoreUrls: true, + // ignoreComments: false, + // ignoreRegExpLiterals: true, + // ignoreStrings: true, + // ignoreTemplateLiterals: true, + // }], + + // // specify the max number of lines in a file + // // https://eslint.org/docs/rules/max-lines + // 'max-lines': ['off', { + // max: 300, + // skipBlankLines: true, + // skipComments: true + // }], + + // // enforce a maximum function length + // // https://eslint.org/docs/rules/max-lines-per-function + // 'max-lines-per-function': ['off', { + // max: 50, + // skipBlankLines: true, + // skipComments: true, + // IIFEs: true, + // }], + + // // specify the maximum depth callbacks can be nested + // 'max-nested-callbacks': 'off', + + // // limits the number of parameters that can be used in the function declaration. + // 'max-params': ['off', 3], + + // // specify the maximum number of statement allowed in a function + // 'max-statements': ['off', 10], + + // // restrict the number of statements per line + // // https://eslint.org/docs/rules/max-statements-per-line + // 'max-statements-per-line': ['off', { max: 1 }], + + // // enforce a particular style for multiline comments + // // https://eslint.org/docs/rules/multiline-comment-style + // 'multiline-comment-style': ['off', 'starred-block'], + + // // require multiline ternary + // // https://eslint.org/docs/rules/multiline-ternary + // // TODO: enable? + // 'multiline-ternary': ['off', 'never'], + + // require a capital letter for constructors + 'new-cap': [ + 'error', + { + capIsNewExceptions: [ + 'Match.Optional', + 'Match.Maybe', + 'Match.OneOf', + 'Match.Where', + 'Match.ObjectIncluding', + 'Push.Configure', + 'SHA256', + ], + }, + ], + + // disallow the omission of parentheses when invoking a constructor with no arguments + // https://eslint.org/docs/rules/new-parens + 'new-parens': 'error', + + // // allow/disallow an empty newline after var statement + // 'newline-after-var': 'off', + + // // https://eslint.org/docs/rules/newline-before-return + // 'newline-before-return': 'off', + + // // enforces new line after each method call in the chain to make it + // // more readable and easy to maintain + // // https://eslint.org/docs/rules/newline-per-chained-call + // 'newline-per-chained-call': ['error', { ignoreChainWithDepth: 4 }], + + // disallow use of the Array constructor + 'no-array-constructor': 'error', + + // // disallow use of bitwise operators + // // https://eslint.org/docs/rules/no-bitwise + // 'no-bitwise': 'error', + + // // disallow use of the continue statement + // // https://eslint.org/docs/rules/no-continue + // 'no-continue': 'error', + + // // disallow comments inline after code + // 'no-inline-comments': 'off', + + // disallow if as the only statement in an else block + // https://eslint.org/docs/rules/no-lonely-if + 'no-lonely-if': 'error', + + // disallow un-paren'd mixes of different operators + // https://eslint.org/docs/rules/no-mixed-operators + 'no-mixed-operators': [ + 'error', + { + // the list of arthmetic groups disallows mixing `%` and `**` + // with other arithmetic operators. + groups: [ + ['%', '**'], + ['%', '+'], + ['%', '-'], + ['%', '*'], + ['%', '/'], + ['**', '+'], + ['**', '-'], + ['**', '*'], + ['**', '/'], + ['&', '|', '^', '~', '<<', '>>', '>>>'], + ['==', '!=', '===', '!==', '>', '>=', '<', '<='], + ['&&', '||'], + ['in', 'instanceof'], + ], + allowSamePrecedence: false, + }, + ], + + // disallow mixed spaces and tabs for indentation + 'no-mixed-spaces-and-tabs': 'error', + + // disallow use of chained assignment expressions + // https://eslint.org/docs/rules/no-multi-assign + 'no-multi-assign': ['error'], + + // disallow multiple empty lines and only one newline at the end + 'no-multiple-empty-lines': ['error', { max: 2, maxEOF: 0 }], + + // // disallow negated conditions + // // https://eslint.org/docs/rules/no-negated-condition + // 'no-negated-condition': 'off', + + // disallow nested ternary expressions + 'no-nested-ternary': 'error', + + // // disallow use of the Object constructor + // 'no-new-object': 'error', + + // // disallow use of unary operators, ++ and -- + // // https://eslint.org/docs/rules/no-plusplus + // 'no-plusplus': 'error', + + // // disallow certain syntax forms + // // https://eslint.org/docs/rules/no-restricted-syntax + // 'no-restricted-syntax': [ + // 'error', + // { + // selector: 'ForInStatement', + // message: 'for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array.', + // }, + // { + // selector: 'ForOfStatement', + // message: 'iterators/generators require regenerator-runtime, which is too heavyweight for this guide to allow them. Separately, loops should be avoided in favor of array iterations.', + // }, + // { + // selector: 'LabeledStatement', + // message: 'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.', + // }, + // { + // selector: 'WithStatement', + // message: '`with` is disallowed in strict mode because it makes code impossible to predict and optimize.', + // }, + // ], + + // disallow space between function identifier and application + 'no-spaced-func': 'error', + + // // disallow tab characters entirely + // 'no-tabs': 'error', + + // // disallow the use of ternary operators + // 'no-ternary': 'off', + + // disallow trailing whitespace at the end of lines + 'no-trailing-spaces': [ + 'error', + { + skipBlankLines: false, + ignoreComments: false, + }, + ], + + // // disallow dangling underscores in identifiers + // // https://eslint.org/docs/rules/no-underscore-dangle + // 'no-underscore-dangle': ['error', { + // allow: [], + // allowAfterThis: false, + // allowAfterSuper: false, + // enforceInMethodNames: true, + // }], + + // disallow the use of Boolean literals in conditional expressions + // also, prefer `a || b` over `a ? a : b` + // https://eslint.org/docs/rules/no-unneeded-ternary + 'no-unneeded-ternary': ['error', { defaultAssignment: false }], + + // disallow whitespace before properties + // https://eslint.org/docs/rules/no-whitespace-before-property + 'no-whitespace-before-property': 'error', + + // // enforce the location of single-line statements + // // https://eslint.org/docs/rules/nonblock-statement-body-position + // 'nonblock-statement-body-position': ['error', 'beside', { overrides: {} }], + + // require padding inside curly braces + 'object-curly-spacing': ['error', 'always'], + + // // enforce line breaks between braces + // // https://eslint.org/docs/rules/object-curly-newline + // 'object-curly-newline': ['error', { + // ObjectExpression: { minProperties: 4, multiline: true, consistent: true }, + // ObjectPattern: { minProperties: 4, multiline: true, consistent: true }, + // ImportDeclaration: { minProperties: 4, multiline: true, consistent: true }, + // ExportDeclaration: { minProperties: 4, multiline: true, consistent: true }, + // }], + + // enforce "same line" or "multiple line" on object properties. + // https://eslint.org/docs/rules/object-property-newline + 'object-property-newline': [ + 'error', + { + allowAllPropertiesOnSameLine: true, + }, + ], + + // allow just one var statement per function + 'one-var': ['error', 'never'], + + // // require a newline around variable declaration + // // https://eslint.org/docs/rules/one-var-declaration-per-line + // 'one-var-declaration-per-line': ['error', 'always'], + + // require assignment operator shorthand where possible or prohibit it entirely + // https://eslint.org/docs/rules/operator-assignment + 'operator-assignment': ['error', 'always'], + + // Requires operator at the beginning of the line in multiline statements + // https://eslint.org/docs/rules/operator-linebreak + 'operator-linebreak': ['error', 'before', { overrides: { '=': 'none' } }], + + // disallow padding within blocks + 'padded-blocks': ['error', { blocks: 'never', classes: 'never', switches: 'never' }], + + // // Require or disallow padding lines between statements + // // https://eslint.org/docs/rules/padding-line-between-statements + // 'padding-line-between-statements': 'off', + + // Prefer use of an object spread over Object.assign + // https://eslint.org/docs/rules/prefer-object-spread + // TODO: semver-major (eslint 5): enable + 'prefer-object-spread': 'off', + + // require quotes around object literal property names + // https://eslint.org/docs/rules/quote-props.html + 'quote-props': ['error', 'as-needed', { keywords: false, unnecessary: true, numbers: false }], + + // specify whether double or single quotes should be used + 'quotes': ['error', 'single', { avoidEscape: true }], + + // // do not require jsdoc + // // https://eslint.org/docs/rules/require-jsdoc + // 'require-jsdoc': 'off', + + // require or disallow use of semicolons instead of ASI + 'semi': ['error', 'always'], + + // enforce spacing before and after semicolons + 'semi-spacing': ['error', { before: false, after: true }], + + // Enforce location of semicolons + // https://eslint.org/docs/rules/semi-style + 'semi-style': ['error', 'last'], + + // // requires object keys to be sorted + // 'sort-keys': ['off', 'asc', { caseSensitive: false, natural: true }], + + // // sort variables within the same declaration block + // 'sort-vars': 'off', + + // require or disallow space before blocks + 'space-before-blocks': ['error', 'always'], + + // require or disallow space before function opening parenthesis + // https://eslint.org/docs/rules/space-before-function-paren + 'space-before-function-paren': ['error', { anonymous: 'never', named: 'never', asyncArrow: 'always' }], + + // require or disallow spaces inside parentheses + 'space-in-parens': ['error', 'never'], + + // require spaces around operators + 'space-infix-ops': 'error', + + // // Require or disallow spaces before/after unary operators + // // https://eslint.org/docs/rules/space-unary-ops + // 'space-unary-ops': ['error', { + // words: true, + // nonwords: false, + // overrides: { + // }, + // }], + + // require or disallow a space immediately following the // or /* in a comment + // https://eslint.org/docs/rules/spaced-comment + 'spaced-comment': 'error', + + // Enforce spacing around colons of switch statements + // https://eslint.org/docs/rules/switch-colon-spacing + 'switch-colon-spacing': ['error', { after: true, before: false }], + + // // Require or disallow spacing between template tags and their literals + // // https://eslint.org/docs/rules/template-tag-spacing + // 'template-tag-spacing': ['error', 'never'], + + // // require or disallow the Unicode Byte Order Mark + // // https://eslint.org/docs/rules/unicode-bom + // 'unicode-bom': ['error', 'never'], + + // // require regex literals to be wrapped in parentheses + // 'wrap-regex': 'off' + }, +}; diff --git a/packages/eslint-config/variables/index.js b/packages/eslint-config/variables/index.js new file mode 100644 index 000000000000..a6b1e24f8832 --- /dev/null +++ b/packages/eslint-config/variables/index.js @@ -0,0 +1,51 @@ +// const restrictedGlobals = require('eslint-restricted-globals'); + +module.exports = { + rules: { + // enforce or disallow variable initializations at definition + // 'init-declarations': 'off', + + // // disallow the catch clause parameter name being the same as a variable in the outer scope + // 'no-catch-shadow': 'off', + + // disallow deletion of variables + 'no-delete-var': 'error', + + // // disallow labels that share a name with a variable + // // https://eslint.org/docs/rules/no-label-var + // 'no-label-var': 'error', + + // // disallow specific globals + // 'no-restricted-globals': ['error', 'isFinite', 'isNaN'].concat(restrictedGlobals), + + // // disallow declaration of variables already declared in the outer scope + // 'no-shadow': 'error', + + // // disallow shadowing of names such as arguments + // 'no-shadow-restricted-names': 'error', + + // disallow use of undeclared variables unless mentioned in a /*global */ block + 'no-undef': 'error', + + // // disallow use of undefined when initializing variables + // 'no-undef-init': 'error', + + // // disallow use of undefined variable + // // https://eslint.org/docs/rules/no-undefined + // // TODO: enable? + // 'no-undefined': 'off', + + // disallow declaration of variables that are not used in the code + 'no-unused-vars': [ + 'error', + { + vars: 'all', + args: 'after-used', + ignoreRestSiblings: true, + }, + ], + + // disallow use of variables before they are defined + 'no-use-before-define': ['error', { functions: true, classes: true, variables: true }], + }, +}; diff --git a/packages/rest-typings/.eslintrc b/packages/rest-typings/.eslintrc index 4f2acee7e0f3..4d3f4a7d4d54 100644 --- a/packages/rest-typings/.eslintrc +++ b/packages/rest-typings/.eslintrc @@ -1,5 +1,5 @@ { - "extends": ["../../.eslintrc"], + "extends": ["@rocket.chat/eslint-config"], "overrides": [ { "files": ["**/*.spec.js", "**/*.spec.jsx"], diff --git a/packages/rest-typings/package.json b/packages/rest-typings/package.json index e010826f8ce7..65869a5d16fd 100644 --- a/packages/rest-typings/package.json +++ b/packages/rest-typings/package.json @@ -5,6 +5,7 @@ "devDependencies": { "@rocket.chat/apps-engine": "^1.31.0", "@rocket.chat/core-typings": "workspace:^", + "@rocket.chat/eslint-config": "workspace:^", "@rocket.chat/message-parser": "^0.31.6", "@rocket.chat/ui-kit": "^0.31.6", "@types/jest": "^27.4.1", @@ -15,8 +16,8 @@ "typescript": "~4.3.5" }, "scripts": { - "eslint": "eslint --ext .js,.jsx,.ts,.tsx .", - "eslint:fix": "eslint --ext .js,.jsx,.ts,.tsx . --fix", + "lint": "eslint --ext .js,.jsx,.ts,.tsx .", + "lint:fix": "eslint --ext .js,.jsx,.ts,.tsx . --fix", "jest": "jest", "build": "tsc -p tsconfig.json" }, diff --git a/packages/rest-typings/src/.prettierrc b/packages/rest-typings/src/.prettierrc deleted file mode 120000 index 9d5a1f5613c4..000000000000 --- a/packages/rest-typings/src/.prettierrc +++ /dev/null @@ -1 +0,0 @@ -../../client/.prettierrc \ No newline at end of file diff --git a/packages/rest-typings/src/index.ts b/packages/rest-typings/src/index.ts index 1998762270c0..45cc1b3c36a6 100644 --- a/packages/rest-typings/src/index.ts +++ b/packages/rest-typings/src/index.ts @@ -1,149 +1,131 @@ // import type { EnterpriseEndpoints } from "@rocket.chat/core-typings"; -import type { KeyOfEach } from "@rocket.chat/core-typings"; -import type { AppsEndpoints } from "./apps"; -import type { ReplacePlaceholders } from "./helpers/ReplacePlaceholders"; -import type { BannersEndpoints } from "./v1/banners"; -import type { ChannelsEndpoints } from "./v1/channels"; -import type { ChatEndpoints } from "./v1/chat"; -import type { CloudEndpoints } from "./v1/cloud"; -import type { CustomSoundEndpoint } from "./v1/customSounds"; -import type { CustomUserStatusEndpoints } from "./v1/customUserStatus"; -import type { DmEndpoints } from "./v1/dm"; -import type { DnsEndpoints } from "./v1/dns"; -import type { E2eEndpoints } from "./v1/e2e"; -import type { EmojiCustomEndpoints } from "./v1/emojiCustom"; -import type { GroupsEndpoints } from "./v1/groups"; -import type { ImEndpoints } from "./v1/im"; -import type { InstancesEndpoints } from "./v1/instances"; -import type { InvitesEndpoints } from "./v1/invites"; -import type { LDAPEndpoints } from "./v1/ldap"; -import type { LicensesEndpoints } from "./v1/licenses"; -import type { MiscEndpoints } from "./v1/misc"; -import type { OmnichannelEndpoints } from "./v1/omnichannel"; -import type { PermissionsEndpoints } from "./v1/permissions"; -import type { RolesEndpoints } from "./v1/roles"; -import type { RoomsEndpoints } from "./v1/rooms"; -import type { SettingsEndpoints } from "./v1/settings"; -import type { StatisticsEndpoints } from "./v1/statistics"; -import type { TeamsEndpoints } from "./v1/teams"; -import type { UsersEndpoints } from "./v1/users"; -import type { VoipEndpoints } from "./v1/voip"; - -type CommunityEndpoints = BannersEndpoints & - ChatEndpoints & - ChannelsEndpoints & - CloudEndpoints & - CustomUserStatusEndpoints & - DmEndpoints & - DnsEndpoints & - EmojiCustomEndpoints & - GroupsEndpoints & - ImEndpoints & - LDAPEndpoints & - RoomsEndpoints & - RolesEndpoints & - TeamsEndpoints & - SettingsEndpoints & - UsersEndpoints & - AppsEndpoints & - OmnichannelEndpoints & - StatisticsEndpoints & - LicensesEndpoints & - MiscEndpoints & - PermissionsEndpoints & - InstancesEndpoints & - VoipEndpoints & - InvitesEndpoints & - E2eEndpoints & - CustomSoundEndpoint; - -export interface Endpoints extends CommunityEndpoints {} -// type Endpoints = CommunityEndpoints; - -type OperationsByPathPattern = - TPathPattern extends any - ? OperationsByPathPatternAndMethod - : never; +import type { KeyOfEach } from '@rocket.chat/core-typings'; + +import type { AppsEndpoints } from './apps'; +import type { ReplacePlaceholders } from './helpers/ReplacePlaceholders'; +import type { BannersEndpoints } from './v1/banners'; +import type { ChannelsEndpoints } from './v1/channels'; +import type { ChatEndpoints } from './v1/chat'; +import type { CloudEndpoints } from './v1/cloud'; +import type { CustomSoundEndpoint } from './v1/customSounds'; +import type { CustomUserStatusEndpoints } from './v1/customUserStatus'; +import type { DmEndpoints } from './v1/dm'; +import type { DnsEndpoints } from './v1/dns'; +import type { E2eEndpoints } from './v1/e2e'; +import type { EmojiCustomEndpoints } from './v1/emojiCustom'; +import type { GroupsEndpoints } from './v1/groups'; +import type { ImEndpoints } from './v1/im'; +import type { InstancesEndpoints } from './v1/instances'; +import type { InvitesEndpoints } from './v1/invites'; +import type { LDAPEndpoints } from './v1/ldap'; +import type { LicensesEndpoints } from './v1/licenses'; +import type { MiscEndpoints } from './v1/misc'; +import type { OmnichannelEndpoints } from './v1/omnichannel'; +import type { PermissionsEndpoints } from './v1/permissions'; +import type { RolesEndpoints } from './v1/roles'; +import type { RoomsEndpoints } from './v1/rooms'; +import type { SettingsEndpoints } from './v1/settings'; +import type { StatisticsEndpoints } from './v1/statistics'; +import type { TeamsEndpoints } from './v1/teams'; +import type { UsersEndpoints } from './v1/users'; +import type { VoipEndpoints } from './v1/voip'; + +// eslint-disable-next-line @typescript-eslint/no-empty-interface, @typescript-eslint/interface-name-prefix +export interface Endpoints + extends BannersEndpoints, + ChatEndpoints, + ChannelsEndpoints, + CloudEndpoints, + CustomUserStatusEndpoints, + DmEndpoints, + DnsEndpoints, + EmojiCustomEndpoints, + GroupsEndpoints, + ImEndpoints, + LDAPEndpoints, + RoomsEndpoints, + RolesEndpoints, + TeamsEndpoints, + SettingsEndpoints, + UsersEndpoints, + AppsEndpoints, + OmnichannelEndpoints, + StatisticsEndpoints, + LicensesEndpoints, + MiscEndpoints, + PermissionsEndpoints, + InstancesEndpoints, + VoipEndpoints, + InvitesEndpoints, + E2eEndpoints, + CustomSoundEndpoint {} + +type OperationsByPathPattern = TPathPattern extends any + ? OperationsByPathPatternAndMethod + : never; type OperationsByPathPatternAndMethod< - TPathPattern extends keyof Endpoints, - TMethod extends KeyOfEach = KeyOfEach< - Endpoints[TPathPattern] - > + TPathPattern extends keyof Endpoints, + TMethod extends KeyOfEach = KeyOfEach, > = TMethod extends any - ? { - pathPattern: TPathPattern; - method: TMethod; - path: ReplacePlaceholders; - params: GetParams; - result: GetResult; - } - : never; + ? { + pathPattern: TPathPattern; + method: TMethod; + path: ReplacePlaceholders; + params: GetParams; + result: GetResult; + } + : never; type Operations = OperationsByPathPattern; -export type PathPattern = Operations["pathPattern"]; +export type PathPattern = Operations['pathPattern']; -export type Method = Operations["method"]; +export type Method = Operations['method']; -export type Path = Operations["path"]; +export type Path = Operations['path']; -export type MethodFor = TPath extends any - ? Extract["method"] - : never; +export type MethodFor = TPath extends any ? Extract['method'] : never; -export type PathFor = TMethod extends any - ? Extract["path"] - : never; +export type PathFor = TMethod extends any ? Extract['path'] : never; -export type MatchPathPattern = TPath extends any - ? Extract["pathPattern"] - : never; +export type MatchPathPattern = TPath extends any ? Extract['pathPattern'] : never; -export type JoinPathPattern< - TBasePath extends string, - TSubPathPattern extends string -> = Extract; +export type JoinPathPattern = Extract< + PathPattern, + `${TBasePath}/${TSubPathPattern}` | TSubPathPattern +>; type GetParams = TOperation extends (...args: any) => any - ? Parameters[0] extends void - ? void - : Parameters[0] - : never; - -type GetResult = TOperation extends (...args: any) => any - ? ReturnType - : never; - -export type OperationParams< - TMethod extends Method, - TPathPattern extends PathPattern -> = TMethod extends keyof Endpoints[TPathPattern] - ? GetParams - : never; - -export type OperationResult< - TMethod extends Method, - TPathPattern extends PathPattern -> = TMethod extends keyof Endpoints[TPathPattern] - ? GetResult - : never; + ? Parameters[0] extends void + ? void + : Parameters[0] + : never; + +type GetResult = TOperation extends (...args: any) => any ? ReturnType : never; + +export type OperationParams = TMethod extends keyof Endpoints[TPathPattern] + ? GetParams + : never; + +export type OperationResult = TMethod extends keyof Endpoints[TPathPattern] + ? GetResult + : never; export type UrlParams = string extends T - ? Record - : T extends `${infer _Start}:${infer Param}/${infer Rest}` - ? { [k in Param | keyof UrlParams]: string } - : T extends `${infer _Start}:${infer Param}` - ? { [k in Param]: string } - : {}; - -export type MethodOf = - TPathPattern extends any ? keyof Endpoints[TPathPattern] : never; - -export * from "./v1/permissions"; -export * from "./v1/roles"; -export * from "./v1/settings"; -export * from "./v1/teams"; -export * from "./helpers/PaginatedRequest"; -export * from "./helpers/PaginatedResult"; -export * from "./helpers/ReplacePlaceholders"; + ? Record + : T extends `${infer _Start}:${infer Param}/${infer Rest}` + ? { [k in Param | keyof UrlParams]: string } + : T extends `${infer _Start}:${infer Param}` + ? { [k in Param]: string } + : {}; + +export type MethodOf = TPathPattern extends any ? keyof Endpoints[TPathPattern] : never; + +export * from './v1/permissions'; +export * from './v1/roles'; +export * from './v1/settings'; +export * from './v1/teams'; +export * from './helpers/PaginatedRequest'; +export * from './helpers/PaginatedResult'; +export * from './helpers/ReplacePlaceholders'; diff --git a/packages/rest-typings/src/v1/banners.ts b/packages/rest-typings/src/v1/banners.ts index 799dc4fe4fe4..2af16f69620d 100644 --- a/packages/rest-typings/src/v1/banners.ts +++ b/packages/rest-typings/src/v1/banners.ts @@ -1,26 +1,26 @@ -import type { BannerPlatform, IBanner } from "@rocket.chat/core-typings"; +import type { BannerPlatform, IBanner } from '@rocket.chat/core-typings'; export type BannersEndpoints = { - /* @deprecated */ - "banners.getNew": { - GET: (params: { platform: BannerPlatform; bid: IBanner["_id"] }) => { - banners: IBanner[]; - }; - }; + /* @deprecated */ + 'banners.getNew': { + GET: (params: { platform: BannerPlatform; bid: IBanner['_id'] }) => { + banners: IBanner[]; + }; + }; - "banners/:id": { - GET: (params: { platform: BannerPlatform }) => { - banners: IBanner[]; - }; - }; + 'banners/:id': { + GET: (params: { platform: BannerPlatform }) => { + banners: IBanner[]; + }; + }; - banners: { - GET: (params: { platform: BannerPlatform }) => { - banners: IBanner[]; - }; - }; + 'banners': { + GET: (params: { platform: BannerPlatform }) => { + banners: IBanner[]; + }; + }; - "banners.dismiss": { - POST: (params: { bannerId: string }) => void; - }; + 'banners.dismiss': { + POST: (params: { bannerId: string }) => void; + }; }; diff --git a/packages/rest-typings/src/v1/channels.ts b/packages/rest-typings/src/v1/channels.ts index 09e30c0f85a3..646b72481083 100644 --- a/packages/rest-typings/src/v1/channels.ts +++ b/packages/rest-typings/src/v1/channels.ts @@ -1,128 +1,110 @@ -import type { IMessage } from "@rocket.chat/core-typings"; -import type { IRoom } from "@rocket.chat/core-typings"; -import type { ITeam } from "@rocket.chat/core-typings"; -import type { IGetRoomRoles, IUser } from "@rocket.chat/core-typings"; +import type { IMessage, IRoom, ITeam, IGetRoomRoles, IUser } from '@rocket.chat/core-typings'; export type ChannelsEndpoints = { - "channels.files": { - GET: (params: { - roomId: IRoom["_id"]; - offset: number; - count: number; - sort: string; - query: string; - }) => { - files: IMessage[]; - total: number; - }; - }; - "channels.members": { - GET: (params: { - roomId: IRoom["_id"]; - offset?: number; - count?: number; - filter?: string; - status?: string[]; - }) => { - count: number; - offset: number; - members: IUser[]; - total: number; - }; - }; - "channels.history": { - GET: (params: { roomId: string; count: number; latest?: string }) => { - messages: IMessage[]; - }; - }; - "channels.archive": { - POST: (params: { roomId: string }) => void; - }; - "channels.unarchive": { - POST: (params: { roomId: string }) => void; - }; - "channels.create": { - POST: (params: { - name: string; - members: string[]; - readOnly: boolean; - extraData: { - broadcast: boolean; - encrypted: boolean; - teamId?: string; - }; - }) => { - group: Partial; - }; - }; - "channels.convertToTeam": { - POST: (params: { channelId: string; channelName: string }) => { - team: ITeam; - }; - }; - "channels.info": { - GET: (params: { roomId: string }) => { channel: IRoom }; - }; - "channels.counters": { - GET: (params: { roomId: string }) => { - joined: boolean; - members: number; - unreads: number; - unreadsFrom: Date; - msgs: number; - latest: Date; - userMentions: number; - }; - }; - "channels.join": { - POST: (params: { roomId: string; joinCode: string | null }) => { - channel: IRoom; - }; - }; - "channels.close": { - POST: (params: { roomId: string }) => {}; - }; - "channels.kick": { - POST: (params: { roomId: string; userId: string }) => {}; - }; - "channels.delete": { - POST: (params: { roomId: string }) => {}; - }; - "channels.leave": { - POST: (params: { roomId: string }) => {}; - }; - "channels.addModerator": { - POST: (params: { roomId: string; userId: string }) => {}; - }; - "channels.removeModerator": { - POST: (params: { roomId: string; userId: string }) => {}; - }; - "channels.addOwner": { - POST: (params: { roomId: string; userId: string }) => {}; - }; - "channels.removeOwner": { - POST: (params: { roomId: string; userId: string }) => {}; - }; - "channels.addLeader": { - POST: (params: { roomId: string; userId: string }) => {}; - }; - "channels.removeLeader": { - POST: (params: { roomId: string; userId: string }) => {}; - }; - "channels.roles": { - GET: (params: { roomId: string }) => { roles: IGetRoomRoles[] }; - }; - "channels.messages": { - GET: (params: { - roomId: IRoom["_id"]; - query: - | { "mentions._id": { $in: string[] } } - | { "starred._id": { $in: string[] } } - | { pinned: boolean }; - offset: number; - sort: { ts: number }; - }) => { - messages: IMessage[]; - }; - }; + 'channels.files': { + GET: (params: { roomId: IRoom['_id']; offset: number; count: number; sort: string; query: string }) => { + files: IMessage[]; + total: number; + }; + }; + 'channels.members': { + GET: (params: { roomId: IRoom['_id']; offset?: number; count?: number; filter?: string; status?: string[] }) => { + count: number; + offset: number; + members: IUser[]; + total: number; + }; + }; + 'channels.history': { + GET: (params: { roomId: string; count: number; latest?: string }) => { + messages: IMessage[]; + }; + }; + 'channels.archive': { + POST: (params: { roomId: string }) => void; + }; + 'channels.unarchive': { + POST: (params: { roomId: string }) => void; + }; + 'channels.create': { + POST: (params: { + name: string; + members: string[]; + readOnly: boolean; + extraData: { + broadcast: boolean; + encrypted: boolean; + teamId?: string; + }; + }) => { + group: Partial; + }; + }; + 'channels.convertToTeam': { + POST: (params: { channelId: string; channelName: string }) => { + team: ITeam; + }; + }; + 'channels.info': { + GET: (params: { roomId: string }) => { channel: IRoom }; + }; + 'channels.counters': { + GET: (params: { roomId: string }) => { + joined: boolean; + members: number; + unreads: number; + unreadsFrom: Date; + msgs: number; + latest: Date; + userMentions: number; + }; + }; + 'channels.join': { + POST: (params: { roomId: string; joinCode: string | null }) => { + channel: IRoom; + }; + }; + 'channels.close': { + POST: (params: { roomId: string }) => {}; + }; + 'channels.kick': { + POST: (params: { roomId: string; userId: string }) => {}; + }; + 'channels.delete': { + POST: (params: { roomId: string }) => {}; + }; + 'channels.leave': { + POST: (params: { roomId: string }) => {}; + }; + 'channels.addModerator': { + POST: (params: { roomId: string; userId: string }) => {}; + }; + 'channels.removeModerator': { + POST: (params: { roomId: string; userId: string }) => {}; + }; + 'channels.addOwner': { + POST: (params: { roomId: string; userId: string }) => {}; + }; + 'channels.removeOwner': { + POST: (params: { roomId: string; userId: string }) => {}; + }; + 'channels.addLeader': { + POST: (params: { roomId: string; userId: string }) => {}; + }; + 'channels.removeLeader': { + POST: (params: { roomId: string; userId: string }) => {}; + }; + 'channels.roles': { + GET: (params: { roomId: string }) => { roles: IGetRoomRoles[] }; + }; + 'channels.messages': { + GET: (params: { + roomId: IRoom['_id']; + query: { 'mentions._id': { $in: string[] } } | { 'starred._id': { $in: string[] } } | { pinned: boolean }; + offset: number; + sort: { ts: number }; + }) => { + messages: IMessage[]; + }; + }; }; diff --git a/packages/rest-typings/src/v1/chat.ts b/packages/rest-typings/src/v1/chat.ts index 376344446759..e22ab320c99f 100644 --- a/packages/rest-typings/src/v1/chat.ts +++ b/packages/rest-typings/src/v1/chat.ts @@ -1,98 +1,76 @@ -import type { IMessage } from "@rocket.chat/core-typings"; -import type { IRoom } from "@rocket.chat/core-typings"; -import type { ReadReceipt } from "@rocket.chat/core-typings"; +import type { IMessage, IRoom, ReadReceipt } from '@rocket.chat/core-typings'; export type ChatEndpoints = { - "chat.getMessage": { - GET: (params: { msgId: IMessage["_id"] }) => { - message: IMessage; - }; - }; - "chat.followMessage": { - POST: (params: { mid: IMessage["_id"] }) => void; - }; - "chat.unfollowMessage": { - POST: (params: { mid: IMessage["_id"] }) => void; - }; - "chat.starMessage": { - POST: (params: { messageId: IMessage["_id"] }) => void; - }; - "chat.unStarMessage": { - POST: (params: { messageId: IMessage["_id"] }) => void; - }; - "chat.pinMessage": { - POST: (params: { messageId: IMessage["_id"] }) => void; - }; - "chat.unPinMessage": { - POST: (params: { messageId: IMessage["_id"] }) => void; - }; - "chat.reportMessage": { - POST: (params: { messageId: IMessage["_id"]; description: string }) => void; - }; - "chat.getDiscussions": { - GET: (params: { - roomId: IRoom["_id"]; - text?: string; - offset: number; - count: number; - }) => { - messages: IMessage[]; - total: number; - }; - }; - "chat.getThreadsList": { - GET: (params: { - rid: IRoom["_id"]; - type: "unread" | "following" | "all"; - text?: string; - offset: number; - count: number; - }) => { - threads: IMessage[]; - total: number; - }; - }; - "chat.syncThreadsList": { - GET: (params: { rid: IRoom["_id"]; updatedSince: string }) => { - threads: { - update: IMessage[]; - remove: IMessage[]; - }; - }; - }; - "chat.delete": { - POST: (params: { msgId: string; roomId: string }) => { - _id: string; - ts: string; - message: Pick; - }; - }; - "chat.react": { - POST: ( - params: - | { emoji: string; messageId: string } - | { reaction: string; messageId: string } - ) => void; - }; - "chat.ignoreUser": { - GET: (params: { rid: string; userId: string; ignore: boolean }) => {}; - }; - "chat.search": { - GET: (params: { - roomId: IRoom["_id"]; - searchText: string; - count: number; - offset: number; - }) => { - messages: IMessage[]; - }; - }; - "chat.update": { - POST: (params: { roomId: IRoom["_id"]; msgId: string; text: string }) => { - messages: IMessage; - }; - }; - "chat.getMessageReadReceipts": { - GET: (params: { messageId: string }) => { receipts: ReadReceipt[] }; - }; + 'chat.getMessage': { + GET: (params: { msgId: IMessage['_id'] }) => { + message: IMessage; + }; + }; + 'chat.followMessage': { + POST: (params: { mid: IMessage['_id'] }) => void; + }; + 'chat.unfollowMessage': { + POST: (params: { mid: IMessage['_id'] }) => void; + }; + 'chat.starMessage': { + POST: (params: { messageId: IMessage['_id'] }) => void; + }; + 'chat.unStarMessage': { + POST: (params: { messageId: IMessage['_id'] }) => void; + }; + 'chat.pinMessage': { + POST: (params: { messageId: IMessage['_id'] }) => void; + }; + 'chat.unPinMessage': { + POST: (params: { messageId: IMessage['_id'] }) => void; + }; + 'chat.reportMessage': { + POST: (params: { messageId: IMessage['_id']; description: string }) => void; + }; + 'chat.getDiscussions': { + GET: (params: { roomId: IRoom['_id']; text?: string; offset: number; count: number }) => { + messages: IMessage[]; + total: number; + }; + }; + 'chat.getThreadsList': { + GET: (params: { rid: IRoom['_id']; type: 'unread' | 'following' | 'all'; text?: string; offset: number; count: number }) => { + threads: IMessage[]; + total: number; + }; + }; + 'chat.syncThreadsList': { + GET: (params: { rid: IRoom['_id']; updatedSince: string }) => { + threads: { + update: IMessage[]; + remove: IMessage[]; + }; + }; + }; + 'chat.delete': { + POST: (params: { msgId: string; roomId: string }) => { + _id: string; + ts: string; + message: Pick; + }; + }; + 'chat.react': { + POST: (params: { emoji: string; messageId: string } | { reaction: string; messageId: string }) => void; + }; + 'chat.ignoreUser': { + GET: (params: { rid: string; userId: string; ignore: boolean }) => {}; + }; + 'chat.search': { + GET: (params: { roomId: IRoom['_id']; searchText: string; count: number; offset: number }) => { + messages: IMessage[]; + }; + }; + 'chat.update': { + POST: (params: { roomId: IRoom['_id']; msgId: string; text: string }) => { + messages: IMessage; + }; + }; + 'chat.getMessageReadReceipts': { + GET: (params: { messageId: string }) => { receipts: ReadReceipt[] }; + }; }; diff --git a/packages/rest-typings/src/v1/cloud.ts b/packages/rest-typings/src/v1/cloud.ts index a623c99fc430..c5f56e26f097 100644 --- a/packages/rest-typings/src/v1/cloud.ts +++ b/packages/rest-typings/src/v1/cloud.ts @@ -1,24 +1,20 @@ -import type { - CloudRegistrationIntentData, - CloudConfirmationPollData, - CloudRegistrationStatus, -} from "@rocket.chat/core-typings"; +import type { CloudRegistrationIntentData, CloudConfirmationPollData, CloudRegistrationStatus } from '@rocket.chat/core-typings'; export type CloudEndpoints = { - "cloud.manualRegister": { - POST: (params: { cloudBlob: string }) => void; - }; - "cloud.createRegistrationIntent": { - POST: (params: { resend: boolean; email: string }) => { - intentData: CloudRegistrationIntentData; - }; - }; - "cloud.confirmationPoll": { - GET: (params: { deviceCode: string; resend?: boolean }) => { - pollData: CloudConfirmationPollData; - }; - }; - "cloud.registrationStatus": { - GET: (params: void) => { registrationStatus: CloudRegistrationStatus }; - }; + 'cloud.manualRegister': { + POST: (params: { cloudBlob: string }) => void; + }; + 'cloud.createRegistrationIntent': { + POST: (params: { resend: boolean; email: string }) => { + intentData: CloudRegistrationIntentData; + }; + }; + 'cloud.confirmationPoll': { + GET: (params: { deviceCode: string; resend?: boolean }) => { + pollData: CloudConfirmationPollData; + }; + }; + 'cloud.registrationStatus': { + GET: (params: void) => { registrationStatus: CloudRegistrationStatus }; + }; }; diff --git a/packages/rest-typings/src/v1/customSounds.ts b/packages/rest-typings/src/v1/customSounds.ts index e23502a96922..4a8f75a68089 100644 --- a/packages/rest-typings/src/v1/customSounds.ts +++ b/packages/rest-typings/src/v1/customSounds.ts @@ -1,14 +1,14 @@ -import type { PaginatedRequest } from "../helpers/PaginatedRequest"; -import type { PaginatedResult } from "../helpers/PaginatedResult"; +import type { PaginatedRequest } from '../helpers/PaginatedRequest'; +import type { PaginatedResult } from '../helpers/PaginatedResult'; export type CustomSoundEndpoint = { - "custom-sounds.list": { - GET: (params: PaginatedRequest<{ query: string }>) => PaginatedResult<{ - sounds: { - _id: string; - name: string; - extension: string; - }[]; - }>; - }; + 'custom-sounds.list': { + GET: (params: PaginatedRequest<{ query: string }>) => PaginatedResult<{ + sounds: { + _id: string; + name: string; + extension: string; + }[]; + }>; + }; }; diff --git a/packages/rest-typings/src/v1/directory.ts b/packages/rest-typings/src/v1/directory.ts index 735221f96348..fda67ddf9810 100644 --- a/packages/rest-typings/src/v1/directory.ts +++ b/packages/rest-typings/src/v1/directory.ts @@ -1,13 +1,14 @@ -import type { IRoom } from "@rocket.chat/core-typings"; -import type { PaginatedResult } from "../helpers/PaginatedResult"; +import type { IRoom } from '@rocket.chat/core-typings'; + +import type { PaginatedResult } from '../helpers/PaginatedResult'; export type DirectoryEndpoint = { - directory: { - GET: (params: { - query: { [key: string]: string }; - count: number; - offset: number; - sort: { [key: string]: number }; - }) => PaginatedResult<{ result: IRoom[] }>; - }; + directory: { + GET: (params: { + query: { [key: string]: string }; + count: number; + offset: number; + sort: { [key: string]: number }; + }) => PaginatedResult<{ result: IRoom[] }>; + }; }; diff --git a/packages/rest-typings/src/v1/dm.ts b/packages/rest-typings/src/v1/dm.ts index 5b0ce8e688cf..44f796bbd594 100644 --- a/packages/rest-typings/src/v1/dm.ts +++ b/packages/rest-typings/src/v1/dm.ts @@ -1,21 +1,20 @@ -import type { IRoom } from "@rocket.chat/core-typings"; -import type { IUser } from "@rocket.chat/core-typings"; +import type { IRoom, IUser } from '@rocket.chat/core-typings'; export type DmEndpoints = { - "dm.create": { - POST: ( - params: ( - | { - username: Exclude; - } - | { - usernames: string; - } - ) & { - excludeSelf?: boolean; - } - ) => { - room: IRoom & { rid: IRoom["_id"] }; - }; - }; + 'dm.create': { + POST: ( + params: ( + | { + username: Exclude; + } + | { + usernames: string; + } + ) & { + excludeSelf?: boolean; + }, + ) => { + room: IRoom & { rid: IRoom['_id'] }; + }; + }; }; diff --git a/packages/rest-typings/src/v1/e2e.ts b/packages/rest-typings/src/v1/e2e.ts index 3632a00d7025..d8bf5f77312c 100644 --- a/packages/rest-typings/src/v1/e2e.ts +++ b/packages/rest-typings/src/v1/e2e.ts @@ -1,21 +1,21 @@ -import type { IUser } from "@rocket.chat/core-typings"; +import type { IUser } from '@rocket.chat/core-typings'; export type E2eEndpoints = { - "e2e.setUserPublicAndPrivateKeys": { - POST: (params: { public_key: string; private_key: string }) => void; - }; - "e2e.getUsersOfRoomWithoutKey": { - GET: (params: { rid: string }) => { - users: Pick[]; - }; - }; - "e2e.updateGroupKey": { - POST: (params: { uid: string; rid: string; key: string }) => {}; - }; - "e2e.setRoomKeyID": { - POST: (params: { rid: string; keyID: string }) => {}; - }; - "e2e.fetchMyKeys": { - GET: () => { public_key: string; private_key: string }; - }; + 'e2e.setUserPublicAndPrivateKeys': { + POST: (params: { public_key: string; private_key: string }) => void; + }; + 'e2e.getUsersOfRoomWithoutKey': { + GET: (params: { rid: string }) => { + users: Pick[]; + }; + }; + 'e2e.updateGroupKey': { + POST: (params: { uid: string; rid: string; key: string }) => {}; + }; + 'e2e.setRoomKeyID': { + POST: (params: { rid: string; keyID: string }) => {}; + }; + 'e2e.fetchMyKeys': { + GET: () => { public_key: string; private_key: string }; + }; }; diff --git a/packages/rest-typings/src/v1/emojiCustom.ts b/packages/rest-typings/src/v1/emojiCustom.ts index 6d5cccfc74a0..0a52dddc940e 100644 --- a/packages/rest-typings/src/v1/emojiCustom.ts +++ b/packages/rest-typings/src/v1/emojiCustom.ts @@ -1,21 +1,22 @@ -import type { ICustomEmojiDescriptor } from "@rocket.chat/core-typings"; -import type { PaginatedRequest } from "../helpers/PaginatedRequest"; -import type { PaginatedResult } from "../helpers/PaginatedResult"; +import type { ICustomEmojiDescriptor } from '@rocket.chat/core-typings'; + +import type { PaginatedRequest } from '../helpers/PaginatedRequest'; +import type { PaginatedResult } from '../helpers/PaginatedResult'; export type EmojiCustomEndpoints = { - "emoji-custom.all": { - GET: (params: PaginatedRequest<{ query: string }, "name">) => { - emojis: ICustomEmojiDescriptor[]; - } & PaginatedResult; - }; - "emoji-custom.list": { - GET: (params: { query: string }) => { - emojis?: { - update: ICustomEmojiDescriptor[]; - }; - }; - }; - "emoji-custom.delete": { - POST: (params: { emojiId: ICustomEmojiDescriptor["_id"] }) => void; - }; + 'emoji-custom.all': { + GET: (params: PaginatedRequest<{ query: string }, 'name'>) => { + emojis: ICustomEmojiDescriptor[]; + } & PaginatedResult; + }; + 'emoji-custom.list': { + GET: (params: { query: string }) => { + emojis?: { + update: ICustomEmojiDescriptor[]; + }; + }; + }; + 'emoji-custom.delete': { + POST: (params: { emojiId: ICustomEmojiDescriptor['_id'] }) => void; + }; }; diff --git a/packages/rest-typings/src/v1/groups.ts b/packages/rest-typings/src/v1/groups.ts index b0bc3738cfab..5cc1a505554e 100644 --- a/packages/rest-typings/src/v1/groups.ts +++ b/packages/rest-typings/src/v1/groups.ts @@ -1,99 +1,82 @@ -import type { IMessage } from "@rocket.chat/core-typings"; -import type { IRoom } from "@rocket.chat/core-typings"; -import type { ITeam } from "@rocket.chat/core-typings"; -import type { IGetRoomRoles, IUser } from "@rocket.chat/core-typings"; +import type { IMessage, IRoom, ITeam, IGetRoomRoles, IUser } from '@rocket.chat/core-typings'; export type GroupsEndpoints = { - "groups.files": { - GET: (params: { - roomId: IRoom["_id"]; - count: number; - sort: string; - query: string; - }) => { - files: IMessage[]; - total: number; - }; - }; - "groups.members": { - GET: (params: { - roomId: IRoom["_id"]; - offset?: number; - count?: number; - filter?: string; - status?: string[]; - }) => { - count: number; - offset: number; - members: IUser[]; - total: number; - }; - }; - "groups.history": { - GET: (params: { roomId: string; count: number; latest?: string }) => { - messages: IMessage[]; - }; - }; - "groups.archive": { - POST: (params: { roomId: string }) => void; - }; - "groups.unarchive": { - POST: (params: { roomId: string }) => void; - }; - "groups.create": { - POST: (params: { - name: string; - members: string[]; - readOnly: boolean; - extraData: { - broadcast: boolean; - encrypted: boolean; - teamId?: string; - }; - }) => { - group: Partial; - }; - }; - "groups.convertToTeam": { - POST: (params: { roomId: string; roomName: string }) => { team: ITeam }; - }; - "groups.counters": { - GET: (params: { roomId: string }) => { - joined: boolean; - members: number; - unreads: number; - unreadsFrom: Date; - msgs: number; - latest: Date; - userMentions: number; - }; - }; - "groups.close": { - POST: (params: { roomId: string }) => {}; - }; - "groups.kick": { - POST: (params: { roomId: string; userId: string }) => {}; - }; - "groups.delete": { - POST: (params: { roomId: string }) => {}; - }; - "groups.leave": { - POST: (params: { roomId: string }) => {}; - }; - "groups.roles": { - GET: (params: { roomId: string }) => { roles: IGetRoomRoles[] }; - }; - "groups.messages": { - GET: (params: { - roomId: IRoom["_id"]; - query: - | { "mentions._id": { $in: string[] } } - | { "starred._id": { $in: string[] } } - | { pinned: boolean }; - offset: number; - sort: { ts: number }; - }) => { - messages: IMessage[]; - }; - }; + 'groups.files': { + GET: (params: { roomId: IRoom['_id']; count: number; sort: string; query: string }) => { + files: IMessage[]; + total: number; + }; + }; + 'groups.members': { + GET: (params: { roomId: IRoom['_id']; offset?: number; count?: number; filter?: string; status?: string[] }) => { + count: number; + offset: number; + members: IUser[]; + total: number; + }; + }; + 'groups.history': { + GET: (params: { roomId: string; count: number; latest?: string }) => { + messages: IMessage[]; + }; + }; + 'groups.archive': { + POST: (params: { roomId: string }) => void; + }; + 'groups.unarchive': { + POST: (params: { roomId: string }) => void; + }; + 'groups.create': { + POST: (params: { + name: string; + members: string[]; + readOnly: boolean; + extraData: { + broadcast: boolean; + encrypted: boolean; + teamId?: string; + }; + }) => { + group: Partial; + }; + }; + 'groups.convertToTeam': { + POST: (params: { roomId: string; roomName: string }) => { team: ITeam }; + }; + 'groups.counters': { + GET: (params: { roomId: string }) => { + joined: boolean; + members: number; + unreads: number; + unreadsFrom: Date; + msgs: number; + latest: Date; + userMentions: number; + }; + }; + 'groups.close': { + POST: (params: { roomId: string }) => {}; + }; + 'groups.kick': { + POST: (params: { roomId: string; userId: string }) => {}; + }; + 'groups.delete': { + POST: (params: { roomId: string }) => {}; + }; + 'groups.leave': { + POST: (params: { roomId: string }) => {}; + }; + 'groups.roles': { + GET: (params: { roomId: string }) => { roles: IGetRoomRoles[] }; + }; + 'groups.messages': { + GET: (params: { + roomId: IRoom['_id']; + query: { 'mentions._id': { $in: string[] } } | { 'starred._id': { $in: string[] } } | { pinned: boolean }; + offset: number; + sort: { ts: number }; + }) => { + messages: IMessage[]; + }; + }; }; diff --git a/packages/rest-typings/src/v1/im.ts b/packages/rest-typings/src/v1/im.ts index 14891183205b..c221b0d0c96a 100644 --- a/packages/rest-typings/src/v1/im.ts +++ b/packages/rest-typings/src/v1/im.ts @@ -1,77 +1,61 @@ -import type { IMessage } from "@rocket.chat/core-typings"; -import type { IRoom } from "@rocket.chat/core-typings"; -import type { IUser } from "@rocket.chat/core-typings"; +import type { IMessage, IRoom, IUser } from '@rocket.chat/core-typings'; export type ImEndpoints = { - "im.create": { - POST: ( - params: ( - | { - username: Exclude; - } - | { - usernames: string; - } - ) & { - excludeSelf?: boolean; - } - ) => { - room: IRoom; - }; - }; - "im.files": { - GET: (params: { - roomId: IRoom["_id"]; - count: number; - sort: string; - query: string; - }) => { - files: IMessage[]; - total: number; - }; - }; - "im.members": { - GET: (params: { - roomId: IRoom["_id"]; - offset?: number; - count?: number; - filter?: string; - status?: string[]; - }) => { - count: number; - offset: number; - members: IUser[]; - total: number; - }; - }; - "im.history": { - GET: (params: { roomId: string; count: number; latest?: string }) => { - messages: IMessage[]; - }; - }; - "im.close": { - POST: (params: { roomId: string }) => {}; - }; - "im.kick": { - POST: (params: { roomId: string; userId: string }) => {}; - }; - "im.delete": { - POST: (params: { roomId: string }) => {}; - }; - "im.leave": { - POST: (params: { roomId: string }) => {}; - }; - "im.messages": { - GET: (params: { - roomId: IRoom["_id"]; - query: - | { "mentions._id": { $in: string[] } } - | { "starred._id": { $in: string[] } } - | { pinned: boolean }; - offset: number; - sort: { ts: number }; - }) => { - messages: IMessage[]; - }; - }; + 'im.create': { + POST: ( + params: ( + | { + username: Exclude; + } + | { + usernames: string; + } + ) & { + excludeSelf?: boolean; + }, + ) => { + room: IRoom; + }; + }; + 'im.files': { + GET: (params: { roomId: IRoom['_id']; count: number; sort: string; query: string }) => { + files: IMessage[]; + total: number; + }; + }; + 'im.members': { + GET: (params: { roomId: IRoom['_id']; offset?: number; count?: number; filter?: string; status?: string[] }) => { + count: number; + offset: number; + members: IUser[]; + total: number; + }; + }; + 'im.history': { + GET: (params: { roomId: string; count: number; latest?: string }) => { + messages: IMessage[]; + }; + }; + 'im.close': { + POST: (params: { roomId: string }) => {}; + }; + 'im.kick': { + POST: (params: { roomId: string; userId: string }) => {}; + }; + 'im.delete': { + POST: (params: { roomId: string }) => {}; + }; + 'im.leave': { + POST: (params: { roomId: string }) => {}; + }; + 'im.messages': { + GET: (params: { + roomId: IRoom['_id']; + query: { 'mentions._id': { $in: string[] } } | { 'starred._id': { $in: string[] } } | { pinned: boolean }; + offset: number; + sort: { ts: number }; + }) => { + messages: IMessage[]; + }; + }; }; diff --git a/packages/rest-typings/src/v1/instances.ts b/packages/rest-typings/src/v1/instances.ts index 240acf0b2739..ab37f127ad23 100644 --- a/packages/rest-typings/src/v1/instances.ts +++ b/packages/rest-typings/src/v1/instances.ts @@ -1,19 +1,19 @@ -import type { IInstanceStatus } from "@rocket.chat/core-typings"; +import type { IInstanceStatus } from '@rocket.chat/core-typings'; export type InstancesEndpoints = { - "instances.get": { - GET: () => { - instances: ( - | IInstanceStatus - | { - connection: { - address: string; - currentStatus: IInstanceStatus["currentStatus"]; - instanceRecord: IInstanceStatus["instanceRecord"]; - broadcastAuth: boolean; - }; - } - )[]; - }; - }; + 'instances.get': { + GET: () => { + instances: ( + | IInstanceStatus + | { + connection: { + address: string; + currentStatus: IInstanceStatus['currentStatus']; + instanceRecord: IInstanceStatus['instanceRecord']; + broadcastAuth: boolean; + }; + } + )[]; + }; + }; }; diff --git a/packages/rest-typings/src/v1/invites.ts b/packages/rest-typings/src/v1/invites.ts index ba9f0f0e7a76..200302c99711 100644 --- a/packages/rest-typings/src/v1/invites.ts +++ b/packages/rest-typings/src/v1/invites.ts @@ -1,25 +1,24 @@ -import type { IInvite } from "@rocket.chat/core-typings"; -import type { IRoom } from "@rocket.chat/core-typings"; +import type { IInvite, IRoom } from '@rocket.chat/core-typings'; export type InvitesEndpoints = { - listInvites: { - GET: () => Array; - }; - "removeInvite/:_id": { - DELETE: () => void; - }; - "/v1/useInviteToken": { - POST: (params: { token: string }) => { - room: { - rid: IRoom["_id"]; - prid: IRoom["prid"]; - fname: IRoom["fname"]; - name: IRoom["name"]; - t: IRoom["t"]; - }; - }; - }; - "/v1/validateInviteToken": { - POST: (params: { token: string }) => { valid: boolean }; - }; + 'listInvites': { + GET: () => Array; + }; + 'removeInvite/:_id': { + DELETE: () => void; + }; + '/v1/useInviteToken': { + POST: (params: { token: string }) => { + room: { + rid: IRoom['_id']; + prid: IRoom['prid']; + fname: IRoom['fname']; + name: IRoom['name']; + t: IRoom['t']; + }; + }; + }; + '/v1/validateInviteToken': { + POST: (params: { token: string }) => { valid: boolean }; + }; }; diff --git a/packages/rest-typings/src/v1/ldap.ts b/packages/rest-typings/src/v1/ldap.ts index 85ac79e345e3..45c482c0957d 100644 --- a/packages/rest-typings/src/v1/ldap.ts +++ b/packages/rest-typings/src/v1/ldap.ts @@ -1,17 +1,17 @@ export type LDAPEndpoints = { - "ldap.testConnection": { - POST: () => { - message: string; - }; - }; - "ldap.testSearch": { - POST: (params: { username: string }) => { - message: string; - }; - }; - "ldap.syncNow": { - POST: () => { - message: string; - }; - }; + 'ldap.testConnection': { + POST: () => { + message: string; + }; + }; + 'ldap.testSearch': { + POST: (params: { username: string }) => { + message: string; + }; + }; + 'ldap.syncNow': { + POST: () => { + message: string; + }; + }; }; diff --git a/packages/rest-typings/src/v1/licenses.ts b/packages/rest-typings/src/v1/licenses.ts index 1da3c2bcd1a3..f1bb124a956b 100644 --- a/packages/rest-typings/src/v1/licenses.ts +++ b/packages/rest-typings/src/v1/licenses.ts @@ -1,16 +1,16 @@ -import type { ILicense } from "@rocket.chat/core-typings"; +import type { ILicense } from '@rocket.chat/core-typings'; export type LicensesEndpoints = { - "licenses.get": { - GET: () => { licenses: Array }; - }; - "licenses.add": { - POST: (params: { license: string }) => void; - }; - "licenses.maxActiveUsers": { - GET: () => { maxActiveUsers: number | null; activeUsers: number }; - }; - "licenses.requestSeatsLink": { - GET: () => { url: string }; - }; + 'licenses.get': { + GET: () => { licenses: Array }; + }; + 'licenses.add': { + POST: (params: { license: string }) => void; + }; + 'licenses.maxActiveUsers': { + GET: () => { maxActiveUsers: number | null; activeUsers: number }; + }; + 'licenses.requestSeatsLink': { + GET: () => { url: string }; + }; }; diff --git a/packages/rest-typings/src/v1/omnichannel.ts b/packages/rest-typings/src/v1/omnichannel.ts index 48b517be6516..1f5757eca9a7 100644 --- a/packages/rest-typings/src/v1/omnichannel.ts +++ b/packages/rest-typings/src/v1/omnichannel.ts @@ -1,243 +1,227 @@ -import type { IOmnichannelCannedResponse } from "@rocket.chat/core-typings"; -import type { ILivechatAgent } from "@rocket.chat/core-typings"; -import type { ILivechatDepartment } from "@rocket.chat/core-typings"; -import type { ILivechatDepartmentAgents } from "@rocket.chat/core-typings"; -import type { ILivechatMonitor } from "@rocket.chat/core-typings"; -import type { ILivechatTag } from "@rocket.chat/core-typings"; import type { - ILivechatVisitor, - ILivechatVisitorDTO, -} from "@rocket.chat/core-typings"; -import type { IMessage } from "@rocket.chat/core-typings"; -import type { IOmnichannelRoom, IRoom } from "@rocket.chat/core-typings"; -import type { ISetting } from "@rocket.chat/core-typings"; -import type { PaginatedRequest } from "../helpers/PaginatedRequest"; -import type { PaginatedResult } from "../helpers/PaginatedResult"; + IOmnichannelCannedResponse, + ILivechatAgent, + ILivechatDepartment, + ILivechatDepartmentAgents, + ILivechatMonitor, + ILivechatTag, + ILivechatVisitor, + ILivechatVisitorDTO, + IMessage, + IOmnichannelRoom, + IRoom, + ISetting, +} from '@rocket.chat/core-typings'; -type booleanString = "true" | "false"; +import type { PaginatedRequest } from '../helpers/PaginatedRequest'; +import type { PaginatedResult } from '../helpers/PaginatedResult'; + +type booleanString = 'true' | 'false'; export type OmnichannelEndpoints = { - "livechat/appearance": { - GET: () => { - appearance: ISetting[]; - }; - }; - "livechat/visitors.info": { - GET: (params: { visitorId: string }) => { - visitor: { - visitorEmails: Array<{ - address: string; - }>; - }; - }; - }; - "livechat/room.onHold": { - POST: (params: { roomId: IRoom["_id"] }) => void; - }; - "livechat/room.join": { - GET: (params: { roomId: IRoom["_id"] }) => { success: boolean }; - }; - "livechat/monitors.list": { - GET: (params: PaginatedRequest<{ text: string }>) => PaginatedResult<{ - monitors: ILivechatMonitor[]; - }>; - }; - "livechat/tags.list": { - GET: ( - params: PaginatedRequest<{ text: string }, "name"> - ) => PaginatedResult<{ - tags: ILivechatTag[]; - }>; - }; - "livechat/department": { - GET: ( - params: PaginatedRequest<{ - text: string; - onlyMyDepartments?: booleanString; - enabled?: boolean; - excludeDepartmentId?: string; - }> - ) => PaginatedResult<{ - departments: ILivechatDepartment[]; - }>; - POST: (params: { - department: Partial; - agents: string[]; - }) => { - department: ILivechatDepartment; - agents: any[]; - }; - }; - "livechat/department/:_id": { - GET: (params: { - onlyMyDepartments?: booleanString; - includeAgents?: booleanString; - }) => { - department: ILivechatDepartment | null; - agents?: any[]; - }; - PUT: (params: { - department: Partial[]; - agents: any[]; - }) => { - department: ILivechatDepartment; - agents: any[]; - }; - DELETE: () => void; - }; - "livechat/department.autocomplete": { - GET: (params: { selector: string; onlyMyDepartments: booleanString }) => { - items: ILivechatDepartment[]; - }; - }; - "livechat/department/:departmentId/agents": { - GET: (params: { - sort: string; - }) => PaginatedResult<{ agents: ILivechatDepartmentAgents[] }>; - POST: (params: { upsert: string[]; remove: string[] }) => void; - }; - "livechat/departments.available-by-unit/:id": { - GET: (params: PaginatedRequest<{ text: string }>) => PaginatedResult<{ - departments: ILivechatDepartment[]; - }>; - }; - "livechat/departments.by-unit/": { - GET: (params: PaginatedRequest<{ text: string }>) => PaginatedResult<{ - departments: ILivechatDepartment[]; - }>; - }; + 'livechat/appearance': { + GET: () => { + appearance: ISetting[]; + }; + }; + 'livechat/visitors.info': { + GET: (params: { visitorId: string }) => { + visitor: { + visitorEmails: Array<{ + address: string; + }>; + }; + }; + }; + 'livechat/room.onHold': { + POST: (params: { roomId: IRoom['_id'] }) => void; + }; + 'livechat/room.join': { + GET: (params: { roomId: IRoom['_id'] }) => { success: boolean }; + }; + 'livechat/monitors.list': { + GET: (params: PaginatedRequest<{ text: string }>) => PaginatedResult<{ + monitors: ILivechatMonitor[]; + }>; + }; + 'livechat/tags.list': { + GET: (params: PaginatedRequest<{ text: string }, 'name'>) => PaginatedResult<{ + tags: ILivechatTag[]; + }>; + }; + 'livechat/department': { + GET: ( + params: PaginatedRequest<{ + text: string; + onlyMyDepartments?: booleanString; + enabled?: boolean; + excludeDepartmentId?: string; + }>, + ) => PaginatedResult<{ + departments: ILivechatDepartment[]; + }>; + POST: (params: { department: Partial; agents: string[] }) => { + department: ILivechatDepartment; + agents: any[]; + }; + }; + 'livechat/department/:_id': { + GET: (params: { onlyMyDepartments?: booleanString; includeAgents?: booleanString }) => { + department: ILivechatDepartment | null; + agents?: any[]; + }; + PUT: (params: { department: Partial[]; agents: any[] }) => { + department: ILivechatDepartment; + agents: any[]; + }; + DELETE: () => void; + }; + 'livechat/department.autocomplete': { + GET: (params: { selector: string; onlyMyDepartments: booleanString }) => { + items: ILivechatDepartment[]; + }; + }; + 'livechat/department/:departmentId/agents': { + GET: (params: { sort: string }) => PaginatedResult<{ agents: ILivechatDepartmentAgents[] }>; + POST: (params: { upsert: string[]; remove: string[] }) => void; + }; + 'livechat/departments.available-by-unit/:id': { + GET: (params: PaginatedRequest<{ text: string }>) => PaginatedResult<{ + departments: ILivechatDepartment[]; + }>; + }; + 'livechat/departments.by-unit/': { + GET: (params: PaginatedRequest<{ text: string }>) => PaginatedResult<{ + departments: ILivechatDepartment[]; + }>; + }; - "livechat/departments.by-unit/:id": { - GET: (params: PaginatedRequest<{ text: string }>) => PaginatedResult<{ - departments: ILivechatDepartment[]; - }>; - }; + 'livechat/departments.by-unit/:id': { + GET: (params: PaginatedRequest<{ text: string }>) => PaginatedResult<{ + departments: ILivechatDepartment[]; + }>; + }; - "livechat/department.listByIds": { - GET: (params: { ids: string[]; fields?: Record }) => { - departments: ILivechatDepartment[]; - }; - }; + 'livechat/department.listByIds': { + GET: (params: { ids: string[]; fields?: Record }) => { + departments: ILivechatDepartment[]; + }; + }; - "livechat/custom-fields": { - GET: (params: PaginatedRequest<{ text: string }>) => PaginatedResult<{ - customFields: [ - { - _id: string; - label: string; - } - ]; - }>; - }; - "livechat/rooms": { - GET: (params: { - guest: string; - fname: string; - servedBy: string[]; - status: string; - department: string; - from: string; - to: string; - customFields: any; - current: number; - itemsPerPage: number; - tags: string[]; - }) => PaginatedResult<{ - rooms: IOmnichannelRoom[]; - }>; - }; - "livechat/:rid/messages": { - GET: (params: PaginatedRequest<{ query: string }>) => PaginatedResult<{ - messages: IMessage[]; - }>; - }; - "livechat/users/agent": { - GET: (params: PaginatedRequest<{ text?: string }>) => PaginatedResult<{ - users: { - _id: string; - emails: { - address: string; - verified: boolean; - }[]; - status: string; - name: string; - username: string; - statusLivechat: string; - livechat: { - maxNumberSimultaneousChat: number; - }; - }[]; - }>; - }; + 'livechat/custom-fields': { + GET: (params: PaginatedRequest<{ text: string }>) => PaginatedResult<{ + customFields: [ + { + _id: string; + label: string; + }, + ]; + }>; + }; + 'livechat/rooms': { + GET: (params: { + guest: string; + fname: string; + servedBy: string[]; + status: string; + department: string; + from: string; + to: string; + customFields: any; + current: number; + itemsPerPage: number; + tags: string[]; + }) => PaginatedResult<{ + rooms: IOmnichannelRoom[]; + }>; + }; + 'livechat/:rid/messages': { + GET: (params: PaginatedRequest<{ query: string }>) => PaginatedResult<{ + messages: IMessage[]; + }>; + }; + 'livechat/users/agent': { + GET: (params: PaginatedRequest<{ text?: string }>) => PaginatedResult<{ + users: { + _id: string; + emails: { + address: string; + verified: boolean; + }[]; + status: string; + name: string; + username: string; + statusLivechat: string; + livechat: { + maxNumberSimultaneousChat: number; + }; + }[]; + }>; + }; - "livechat/visitor": { - POST: (params: { visitor: ILivechatVisitorDTO }) => { - visitor: ILivechatVisitor; - }; - }; + 'livechat/visitor': { + POST: (params: { visitor: ILivechatVisitorDTO }) => { + visitor: ILivechatVisitor; + }; + }; - "livechat/visitor/:token": { - GET: (params: { token: string }) => { visitor: ILivechatVisitor }; - DELETE: (params: { token: string }) => { - visitor: { _id: string; ts: string }; - }; - }; + 'livechat/visitor/:token': { + GET: (params: { token: string }) => { visitor: ILivechatVisitor }; + DELETE: (params: { token: string }) => { + visitor: { _id: string; ts: string }; + }; + }; - "livechat/visitor/:token/room": { - GET: (params: { token: string }) => { rooms: IOmnichannelRoom[] }; - }; + 'livechat/visitor/:token/room': { + GET: (params: { token: string }) => { rooms: IOmnichannelRoom[] }; + }; - "livechat/visitor.callStatus": { - POST: (params: { - token: string; - callStatus: string; - rid: string; - callId: string; - }) => { - token: string; - callStatus: string; - }; - }; + 'livechat/visitor.callStatus': { + POST: (params: { token: string; callStatus: string; rid: string; callId: string }) => { + token: string; + callStatus: string; + }; + }; - "livechat/visitor.status": { - POST: (params: { token: string; status: string }) => { - token: string; - status: string; - }; - }; + 'livechat/visitor.status': { + POST: (params: { token: string; status: string }) => { + token: string; + status: string; + }; + }; - "livechat/queue": { - GET: (params: { - agentId?: ILivechatAgent["_id"]; - includeOfflineAgents?: boolean; - departmentId?: ILivechatAgent["_id"]; - offset: number; - count: number; - sort: string; - }) => { - queue: { - chats: number; - department: { _id: string; name: string }; - user: { _id: string; username: string; status: string }; - }[]; - count: number; - offset: number; - total: number; - }; - }; - "livechat/agents/:uid/departments?enabledDepartmentsOnly=true": { - GET: () => { departments: ILivechatDepartment[] }; - }; + 'livechat/queue': { + GET: (params: { + agentId?: ILivechatAgent['_id']; + includeOfflineAgents?: boolean; + departmentId?: ILivechatAgent['_id']; + offset: number; + count: number; + sort: string; + }) => { + queue: { + chats: number; + department: { _id: string; name: string }; + user: { _id: string; username: string; status: string }; + }[]; + count: number; + offset: number; + total: number; + }; + }; + 'livechat/agents/:uid/departments?enabledDepartmentsOnly=true': { + GET: () => { departments: ILivechatDepartment[] }; + }; - "canned-responses": { - GET: ( - params: PaginatedRequest<{ - scope?: string; - departmentId?: string; - text?: string; - }> - ) => PaginatedResult<{ - cannedResponses: IOmnichannelCannedResponse[]; - }>; - }; + 'canned-responses': { + GET: ( + params: PaginatedRequest<{ + scope?: string; + departmentId?: string; + text?: string; + }>, + ) => PaginatedResult<{ + cannedResponses: IOmnichannelCannedResponse[]; + }>; + }; }; diff --git a/packages/rest-typings/src/v1/permissions.ts b/packages/rest-typings/src/v1/permissions.ts index 989449a9ddb0..85506bf1aff8 100644 --- a/packages/rest-typings/src/v1/permissions.ts +++ b/packages/rest-typings/src/v1/permissions.ts @@ -1,51 +1,48 @@ -import Ajv, { JSONSchemaType } from "ajv"; - -import type { IPermission } from "@rocket.chat/core-typings"; +import Ajv, { JSONSchemaType } from 'ajv'; +import type { IPermission } from '@rocket.chat/core-typings'; const ajv = new Ajv(); type PermissionsUpdateProps = { - permissions: { _id: string; roles: string[] }[]; + permissions: { _id: string; roles: string[] }[]; }; const permissionUpdatePropsSchema: JSONSchemaType = { - type: "object", - properties: { - permissions: { - type: "array", - items: { - type: "object", - properties: { - _id: { type: "string" }, - roles: { - type: "array", - items: { type: "string" }, - uniqueItems: true, - }, - }, - additionalProperties: false, - required: ["_id", "roles"], - }, - }, - }, - required: ["permissions"], - additionalProperties: false, + type: 'object', + properties: { + permissions: { + type: 'array', + items: { + type: 'object', + properties: { + _id: { type: 'string' }, + roles: { + type: 'array', + items: { type: 'string' }, + uniqueItems: true, + }, + }, + additionalProperties: false, + required: ['_id', 'roles'], + }, + }, + }, + required: ['permissions'], + additionalProperties: false, }; -export const isBodyParamsValidPermissionUpdate = ajv.compile( - permissionUpdatePropsSchema -); +export const isBodyParamsValidPermissionUpdate = ajv.compile(permissionUpdatePropsSchema); export type PermissionsEndpoints = { - "permissions.listAll": { - GET: (params: { updatedSince?: string }) => { - update: IPermission[]; - remove: IPermission[]; - }; - }; - "permissions.update": { - POST: (params: PermissionsUpdateProps) => { - permissions: IPermission[]; - }; - }; + 'permissions.listAll': { + GET: (params: { updatedSince?: string }) => { + update: IPermission[]; + remove: IPermission[]; + }; + }; + 'permissions.update': { + POST: (params: PermissionsUpdateProps) => { + permissions: IPermission[]; + }; + }; }; diff --git a/packages/rest-typings/src/v1/roles.ts b/packages/rest-typings/src/v1/roles.ts index b6709c996a18..6e3d729a0222 100644 --- a/packages/rest-typings/src/v1/roles.ts +++ b/packages/rest-typings/src/v1/roles.ts @@ -1,219 +1,206 @@ -import Ajv, { JSONSchemaType } from "ajv"; - -import type { RocketChatRecordDeleted } from "@rocket.chat/core-typings"; -import type { IRole, IUser, IUserInRole } from "@rocket.chat/core-typings"; +import Ajv, { JSONSchemaType } from 'ajv'; +import type { RocketChatRecordDeleted, IRole, IUserInRole } from '@rocket.chat/core-typings'; const ajv = new Ajv(); -type RoleCreateProps = Pick & - Partial>; +type RoleCreateProps = Pick & Partial>; const roleCreatePropsSchema: JSONSchemaType = { - type: "object", - properties: { - name: { - type: "string", - }, - description: { - type: "string", - nullable: true, - }, - scope: { - type: "string", - enum: ["Users", "Subscriptions"], - nullable: true, - }, - mandatory2fa: { - type: "boolean", - nullable: true, - }, - }, - required: ["name"], - additionalProperties: false, + type: 'object', + properties: { + name: { + type: 'string', + }, + description: { + type: 'string', + nullable: true, + }, + scope: { + type: 'string', + enum: ['Users', 'Subscriptions'], + nullable: true, + }, + mandatory2fa: { + type: 'boolean', + nullable: true, + }, + }, + required: ['name'], + additionalProperties: false, }; export const isRoleCreateProps = ajv.compile(roleCreatePropsSchema); type RoleUpdateProps = { - roleId: IRole["_id"]; - name: IRole["name"]; + roleId: IRole['_id']; + name: IRole['name']; } & Partial; const roleUpdatePropsSchema: JSONSchemaType = { - type: "object", - properties: { - roleId: { - type: "string", - }, - name: { - type: "string", - }, - description: { - type: "string", - nullable: true, - }, - scope: { - type: "string", - enum: ["Users", "Subscriptions"], - nullable: true, - }, - mandatory2fa: { - type: "boolean", - nullable: true, - }, - }, - required: ["roleId", "name"], - additionalProperties: false, + type: 'object', + properties: { + roleId: { + type: 'string', + }, + name: { + type: 'string', + }, + description: { + type: 'string', + nullable: true, + }, + scope: { + type: 'string', + enum: ['Users', 'Subscriptions'], + nullable: true, + }, + mandatory2fa: { + type: 'boolean', + nullable: true, + }, + }, + required: ['roleId', 'name'], + additionalProperties: false, }; export const isRoleUpdateProps = ajv.compile(roleUpdatePropsSchema); -type RoleDeleteProps = { roleId: IRole["_id"] }; +type RoleDeleteProps = { roleId: IRole['_id'] }; const roleDeletePropsSchema: JSONSchemaType = { - type: "object", - properties: { - roleId: { - type: "string", - }, - }, - required: ["roleId"], - additionalProperties: false, + type: 'object', + properties: { + roleId: { + type: 'string', + }, + }, + required: ['roleId'], + additionalProperties: false, }; export const isRoleDeleteProps = ajv.compile(roleDeletePropsSchema); type RoleAddUserToRoleProps = { - username: string; - // #ToDo: Make it non-optional on the next major release - roleId?: string; - roleName?: string; - roomId?: string; + username: string; + // #ToDo: Make it non-optional on the next major release + roleId?: string; + roleName?: string; + roomId?: string; }; const roleAddUserToRolePropsSchema: JSONSchemaType = { - type: "object", - properties: { - username: { - type: "string", - }, - roleId: { - type: "string", - nullable: true, - }, - roleName: { - type: "string", - nullable: true, - }, - roomId: { - type: "string", - nullable: true, - }, - }, - required: ["username"], - additionalProperties: false, + type: 'object', + properties: { + username: { + type: 'string', + }, + roleId: { + type: 'string', + nullable: true, + }, + roleName: { + type: 'string', + nullable: true, + }, + roomId: { + type: 'string', + nullable: true, + }, + }, + required: ['username'], + additionalProperties: false, }; -export const isRoleAddUserToRoleProps = ajv.compile( - roleAddUserToRolePropsSchema -); +export const isRoleAddUserToRoleProps = ajv.compile(roleAddUserToRolePropsSchema); type RoleRemoveUserFromRoleProps = { - username: string; - // #ToDo: Make it non-optional on the next major release - roleId?: string; - roleName?: string; - roomId?: string; - scope?: string; + username: string; + // #ToDo: Make it non-optional on the next major release + roleId?: string; + roleName?: string; + roomId?: string; + scope?: string; +}; + +const roleRemoveUserFromRolePropsSchema: JSONSchemaType = { + type: 'object', + properties: { + username: { + type: 'string', + }, + roleId: { + type: 'string', + nullable: true, + }, + roleName: { + type: 'string', + nullable: true, + }, + roomId: { + type: 'string', + nullable: true, + }, + scope: { + type: 'string', + nullable: true, + }, + }, + required: ['username'], + additionalProperties: false, }; -const roleRemoveUserFromRolePropsSchema: JSONSchemaType = - { - type: "object", - properties: { - username: { - type: "string", - }, - roleId: { - type: "string", - nullable: true, - }, - roleName: { - type: "string", - nullable: true, - }, - roomId: { - type: "string", - nullable: true, - }, - scope: { - type: "string", - nullable: true, - }, - }, - required: ["username"], - additionalProperties: false, - }; - -export const isRoleRemoveUserFromRoleProps = ajv.compile( - roleRemoveUserFromRolePropsSchema -); +export const isRoleRemoveUserFromRoleProps = ajv.compile(roleRemoveUserFromRolePropsSchema); type RoleSyncProps = { - updatedSince?: string; + updatedSince?: string; }; export type RolesEndpoints = { - "roles.list": { - GET: () => { - roles: IRole[]; - }; - }; - "roles.sync": { - GET: (params: RoleSyncProps) => { - roles: { - update: IRole[]; - remove: RocketChatRecordDeleted[]; - }; - }; - }; - "roles.create": { - POST: (params: RoleCreateProps) => { - role: IRole; - }; - }; - - "roles.addUserToRole": { - POST: (params: RoleAddUserToRoleProps) => { - role: IRole; - }; - }; - - "roles.getUsersInRole": { - GET: (params: { - roomId?: string; - role: string; - offset?: number; - count?: number; - }) => { - users: IUserInRole[]; - total: number; - }; - }; - - "roles.update": { - POST: (role: RoleUpdateProps) => { - role: IRole; - }; - }; - - "roles.delete": { - POST: (prop: RoleDeleteProps) => void; - }; - - "roles.removeUserFromRole": { - POST: (props: RoleRemoveUserFromRoleProps) => { - role: IRole; - }; - }; + 'roles.list': { + GET: () => { + roles: IRole[]; + }; + }; + 'roles.sync': { + GET: (params: RoleSyncProps) => { + roles: { + update: IRole[]; + remove: RocketChatRecordDeleted[]; + }; + }; + }; + 'roles.create': { + POST: (params: RoleCreateProps) => { + role: IRole; + }; + }; + + 'roles.addUserToRole': { + POST: (params: RoleAddUserToRoleProps) => { + role: IRole; + }; + }; + + 'roles.getUsersInRole': { + GET: (params: { roomId?: string; role: string; offset?: number; count?: number }) => { + users: IUserInRole[]; + total: number; + }; + }; + + 'roles.update': { + POST: (role: RoleUpdateProps) => { + role: IRole; + }; + }; + + 'roles.delete': { + POST: (prop: RoleDeleteProps) => void; + }; + + 'roles.removeUserFromRole': { + POST: (props: RoleRemoveUserFromRoleProps) => { + role: IRole; + }; + }; }; diff --git a/packages/rest-typings/src/v1/rooms.ts b/packages/rest-typings/src/v1/rooms.ts index edacba18ca64..0352d63f9882 100644 --- a/packages/rest-typings/src/v1/rooms.ts +++ b/packages/rest-typings/src/v1/rooms.ts @@ -1,63 +1,56 @@ -import type { IMessage } from "@rocket.chat/core-typings"; -import type { IRoom } from "@rocket.chat/core-typings"; -import type { IUser } from "@rocket.chat/core-typings"; +import type { IMessage, IRoom, IUser } from '@rocket.chat/core-typings'; export type RoomsEndpoints = { - "rooms.autocomplete.channelAndPrivate": { - GET: (params: { selector: string }) => { - items: IRoom[]; - }; - }; - "rooms.autocomplete.channelAndPrivate.withPagination": { - GET: (params: { - selector: string; - offset?: number; - count?: number; - sort?: string; - }) => { - items: IRoom[]; - count: number; - offset: number; - total: number; - }; - }; - "rooms.autocomplete.availableForTeams": { - GET: (params: { name: string }) => { - items: IRoom[]; - }; - }; - "rooms.info": { - GET: (params: { roomId: string } | { roomName: string }) => { - room: IRoom; - }; - }; - "rooms.createDiscussion": { - POST: (params: { - prid: IRoom["_id"]; - pmid?: IMessage["_id"]; - t_name: IRoom["fname"]; - users?: IUser["username"][]; - encrypted?: boolean; - reply?: string; - }) => { - discussion: IRoom; - }; - }; - "rooms.export": { - POST: (params: { - rid: IRoom["_id"]; - type: "email" | "file"; - toUsers?: IUser["username"][]; - toEmails?: string[]; - additionalEmails?: string; - subject?: string; - messages?: IMessage["_id"][]; - dateFrom?: string; - dateTo?: string; - format?: "html" | "json"; - }) => { - missing?: []; - success: boolean; - }; - }; + 'rooms.autocomplete.channelAndPrivate': { + GET: (params: { selector: string }) => { + items: IRoom[]; + }; + }; + 'rooms.autocomplete.channelAndPrivate.withPagination': { + GET: (params: { selector: string; offset?: number; count?: number; sort?: string }) => { + items: IRoom[]; + count: number; + offset: number; + total: number; + }; + }; + 'rooms.autocomplete.availableForTeams': { + GET: (params: { name: string }) => { + items: IRoom[]; + }; + }; + 'rooms.info': { + GET: (params: { roomId: string } | { roomName: string }) => { + room: IRoom; + }; + }; + 'rooms.createDiscussion': { + POST: (params: { + prid: IRoom['_id']; + pmid?: IMessage['_id']; + t_name: IRoom['fname']; + users?: IUser['username'][]; + encrypted?: boolean; + reply?: string; + }) => { + discussion: IRoom; + }; + }; + 'rooms.export': { + POST: (params: { + rid: IRoom['_id']; + type: 'email' | 'file'; + toUsers?: IUser['username'][]; + toEmails?: string[]; + additionalEmails?: string; + subject?: string; + messages?: IMessage['_id'][]; + dateFrom?: string; + dateTo?: string; + format?: 'html' | 'json'; + }) => { + missing?: []; + success: boolean; + }; + }; }; diff --git a/packages/rest-typings/src/v1/settings.ts b/packages/rest-typings/src/v1/settings.ts index 999f398c80b3..8e9b09a3bddf 100644 --- a/packages/rest-typings/src/v1/settings.ts +++ b/packages/rest-typings/src/v1/settings.ts @@ -1,111 +1,103 @@ -import type { ISetting, ISettingColor } from "@rocket.chat/core-typings"; -import type { PaginatedResult } from "../helpers/PaginatedResult"; +import type { ISetting, ISettingColor } from '@rocket.chat/core-typings'; -type SettingsUpdateProps = - | SettingsUpdatePropDefault - | SettingsUpdatePropsActions - | SettingsUpdatePropsColor; +import type { PaginatedResult } from '../helpers/PaginatedResult'; + +type SettingsUpdateProps = SettingsUpdatePropDefault | SettingsUpdatePropsActions | SettingsUpdatePropsColor; type SettingsUpdatePropsActions = { - execute: boolean; + execute: boolean; }; export type OauthCustomConfiguration = { - _id: string; - clientId?: string; - custom: boolean; - service?: string; - serverURL: string; - tokenPath: string; - identityPath: string; - authorizePath: string; - scope: string; - loginStyle: "popup" | "redirect"; - tokenSentVia: "header" | "payload"; - identityTokenSentVia: "default" | "header" | "payload"; - keyField: "username" | "email"; - usernameField: string; - emailField: string; - nameField: string; - avatarField: string; - rolesClaim: string; - groupsClaim: string; - mapChannels: string; - channelsMap: string; - channelsAdmin: string; - mergeUsers: boolean; - mergeRoles: boolean; - accessTokenParam: string; - showButton: boolean; - - appId: string; - consumerKey?: string; - - clientConfig: unknown; - buttonLabelText: string; - buttonLabelColor: string; - buttonColor: string; + _id: string; + clientId?: string; + custom: boolean; + service?: string; + serverURL: string; + tokenPath: string; + identityPath: string; + authorizePath: string; + scope: string; + loginStyle: 'popup' | 'redirect'; + tokenSentVia: 'header' | 'payload'; + identityTokenSentVia: 'default' | 'header' | 'payload'; + keyField: 'username' | 'email'; + usernameField: string; + emailField: string; + nameField: string; + avatarField: string; + rolesClaim: string; + groupsClaim: string; + mapChannels: string; + channelsMap: string; + channelsAdmin: string; + mergeUsers: boolean; + mergeRoles: boolean; + accessTokenParam: string; + showButton: boolean; + + appId: string; + consumerKey?: string; + + clientConfig: unknown; + buttonLabelText: string; + buttonLabelColor: string; + buttonColor: string; }; -export const isOauthCustomConfiguration = ( - config: any -): config is OauthCustomConfiguration => Boolean(config); +export const isOauthCustomConfiguration = (config: any): config is OauthCustomConfiguration => Boolean(config); -export const isSettingsUpdatePropsActions = ( - props: Partial -): props is SettingsUpdatePropsActions => "execute" in props; +export const isSettingsUpdatePropsActions = (props: Partial): props is SettingsUpdatePropsActions => + 'execute' in props; type SettingsUpdatePropsColor = { - editor: ISettingColor["editor"]; - value: ISetting["value"]; + editor: ISettingColor['editor']; + value: ISetting['value']; }; -export const isSettingsUpdatePropsColor = ( - props: Partial -): props is SettingsUpdatePropsColor => "editor" in props && "value" in props; +export const isSettingsUpdatePropsColor = (props: Partial): props is SettingsUpdatePropsColor => + 'editor' in props && 'value' in props; type SettingsUpdatePropDefault = { - value: ISetting["value"]; + value: ISetting['value']; }; -export const isSettingsUpdatePropDefault = ( - props: Partial -): props is SettingsUpdatePropDefault => "value" in props; +export const isSettingsUpdatePropDefault = (props: Partial): props is SettingsUpdatePropDefault => 'value' in props; export type SettingsEndpoints = { - "settings.public": { - GET: () => PaginatedResult & { - settings: Array; - }; - }; - - "settings.oauth": { - GET: () => { - services: Partial[]; - }; - }; - - "settings.addCustomOAuth": { - POST: (params: { name: string }) => void; - }; - - settings: { - GET: () => { - settings: ISetting[]; - }; - }; - - "settings/:_id": { - GET: () => Pick; - POST: (params: SettingsUpdateProps) => void; - }; - - "service.configurations": { - GET: () => { - configurations: Array<{ - appId: string; - secret: string; - }>; - }; - }; + 'settings.public': { + GET: () => PaginatedResult & { + settings: Array; + }; + }; + + 'settings.oauth': { + GET: () => { + services: Partial[]; + }; + }; + + 'settings.addCustomOAuth': { + POST: (params: { name: string }) => void; + }; + + 'settings': { + GET: () => { + settings: ISetting[]; + }; + }; + + 'settings/:_id': { + GET: () => Pick; + POST: (params: SettingsUpdateProps) => void; + }; + + 'service.configurations': { + GET: () => { + configurations: Array<{ + appId: string; + secret: string; + }>; + }; + }; }; diff --git a/packages/rest-typings/src/v1/statistics.ts b/packages/rest-typings/src/v1/statistics.ts index efa2b904c57c..ff358ab617f0 100644 --- a/packages/rest-typings/src/v1/statistics.ts +++ b/packages/rest-typings/src/v1/statistics.ts @@ -1,17 +1,17 @@ -import type { IStats } from "@rocket.chat/core-typings"; +import type { IStats } from '@rocket.chat/core-typings'; export type StatisticsEndpoints = { - statistics: { - GET: (params: { refresh?: boolean }) => IStats; - }; - "statistics.telemetry": { - POST: (params: TelemetryPayload) => any; - }; + 'statistics': { + GET: (params: { refresh?: boolean }) => IStats; + }; + 'statistics.telemetry': { + POST: (params: TelemetryPayload) => any; + }; }; export type TelemetryBase = { - eventName: string; - timestamp: number; + eventName: string; + timestamp: number; }; type OTREnded = TelemetryBase & { rid: string }; diff --git a/packages/rest-typings/src/v1/teams/ITeamMemberParams.ts b/packages/rest-typings/src/v1/teams/ITeamMemberParams.ts index c4f8a04d3591..b239027b6247 100644 --- a/packages/rest-typings/src/v1/teams/ITeamMemberParams.ts +++ b/packages/rest-typings/src/v1/teams/ITeamMemberParams.ts @@ -1,6 +1,6 @@ -import type { IRole } from "@rocket.chat/core-typings"; +import type { IRole } from '@rocket.chat/core-typings'; export interface ITeamMemberParams { - userId: string; - roles?: Array | null; + userId: string; + roles?: Array | null; } diff --git a/packages/rest-typings/src/v1/teams/TeamsAddMembersProps.ts b/packages/rest-typings/src/v1/teams/TeamsAddMembersProps.ts index 7a3666b9b687..95cc3be9197f 100644 --- a/packages/rest-typings/src/v1/teams/TeamsAddMembersProps.ts +++ b/packages/rest-typings/src/v1/teams/TeamsAddMembersProps.ts @@ -1,82 +1,79 @@ -import type { IRole } from "@rocket.chat/core-typings"; -import Ajv, { JSONSchemaType } from "ajv"; -import type { ITeamMemberParams } from "./ITeamMemberParams"; +import Ajv, { JSONSchemaType } from 'ajv'; + +import type { ITeamMemberParams } from './ITeamMemberParams'; const ajv = new Ajv(); -export type TeamsAddMembersProps = ( - | { teamId: string } - | { teamName: string } -) & { - members: ITeamMemberParams[]; +export type TeamsAddMembersProps = ({ teamId: string } | { teamName: string }) & { + members: ITeamMemberParams[]; }; const teamsAddMembersPropsSchema: JSONSchemaType = { - oneOf: [ - { - type: "object", - properties: { - teamId: { - type: "string", - }, - members: { - type: "array", - items: { - type: "object", - properties: { - userId: { - type: "string", - }, - roles: { - type: "array", - items: { - type: "string", - }, - nullable: true, - }, - }, - required: ["userId"], - additionalProperties: false, - }, - minItems: 1, - uniqueItems: true, - }, - }, - required: ["teamId", "members"], - additionalProperties: false, - }, - { - type: "object", - properties: { - teamName: { - type: "string", - }, - members: { - type: "array", - items: { - type: "object", - properties: { - userId: { - type: "string", - }, - roles: { - type: "array", - items: { - type: "string", - }, - nullable: true, - }, - }, - required: ["userId"], - additionalProperties: false, - }, - minItems: 1, - uniqueItems: true, - }, - }, - required: ["teamName", "members"], - additionalProperties: false, - }, - ], + oneOf: [ + { + type: 'object', + properties: { + teamId: { + type: 'string', + }, + members: { + type: 'array', + items: { + type: 'object', + properties: { + userId: { + type: 'string', + }, + roles: { + type: 'array', + items: { + type: 'string', + }, + nullable: true, + }, + }, + required: ['userId'], + additionalProperties: false, + }, + minItems: 1, + uniqueItems: true, + }, + }, + required: ['teamId', 'members'], + additionalProperties: false, + }, + { + type: 'object', + properties: { + teamName: { + type: 'string', + }, + members: { + type: 'array', + items: { + type: 'object', + properties: { + userId: { + type: 'string', + }, + roles: { + type: 'array', + items: { + type: 'string', + }, + nullable: true, + }, + }, + required: ['userId'], + additionalProperties: false, + }, + minItems: 1, + uniqueItems: true, + }, + }, + required: ['teamName', 'members'], + additionalProperties: false, + }, + ], }; export const isTeamsAddMembersProps = ajv.compile(teamsAddMembersPropsSchema); diff --git a/packages/rest-typings/src/v1/teams/TeamsRemoveRoomProps.ts b/packages/rest-typings/src/v1/teams/TeamsRemoveRoomProps.ts index b65123cb11c3..9c214701270f 100644 --- a/packages/rest-typings/src/v1/teams/TeamsRemoveRoomProps.ts +++ b/packages/rest-typings/src/v1/teams/TeamsRemoveRoomProps.ts @@ -1,46 +1,41 @@ -import Ajv, { JSONSchemaType } from "ajv"; - -import type { IRoom } from "@rocket.chat/core-typings"; +import Ajv, { JSONSchemaType } from 'ajv'; +import type { IRoom } from '@rocket.chat/core-typings'; const ajv = new Ajv(); -export type TeamsRemoveRoomProps = ( - | { teamId: string } - | { teamName: string } -) & { - roomId: IRoom["_id"]; +export type TeamsRemoveRoomProps = ({ teamId: string } | { teamName: string }) & { + roomId: IRoom['_id']; }; -export const teamsRemoveRoomPropsSchema: JSONSchemaType = - { - oneOf: [ - { - type: "object", - properties: { - teamId: { - type: "string", - }, - roomId: { - type: "string", - }, - }, - required: ["teamId", "roomId"], - additionalProperties: false, - }, - { - type: "object", - properties: { - teamName: { - type: "string", - }, - roomId: { - type: "string", - }, - }, - required: ["teamName", "roomId"], - additionalProperties: false, - }, - ], - }; +export const teamsRemoveRoomPropsSchema: JSONSchemaType = { + oneOf: [ + { + type: 'object', + properties: { + teamId: { + type: 'string', + }, + roomId: { + type: 'string', + }, + }, + required: ['teamId', 'roomId'], + additionalProperties: false, + }, + { + type: 'object', + properties: { + teamName: { + type: 'string', + }, + roomId: { + type: 'string', + }, + }, + required: ['teamName', 'roomId'], + additionalProperties: false, + }, + ], +}; export const isTeamsRemoveRoomProps = ajv.compile(teamsRemoveRoomPropsSchema); diff --git a/packages/rest-typings/src/v1/teams/TeamsUpdateMemberProps.ts b/packages/rest-typings/src/v1/teams/TeamsUpdateMemberProps.ts index 024a45c7de02..0615f3f30767 100644 --- a/packages/rest-typings/src/v1/teams/TeamsUpdateMemberProps.ts +++ b/packages/rest-typings/src/v1/teams/TeamsUpdateMemberProps.ts @@ -1,74 +1,70 @@ -import Ajv, { JSONSchemaType } from "ajv"; -import type { ITeamMemberParams } from "./ITeamMemberParams"; +import Ajv, { JSONSchemaType } from 'ajv'; + +import type { ITeamMemberParams } from './ITeamMemberParams'; const ajv = new Ajv(); -export type TeamsUpdateMemberProps = ( - | { teamId: string } - | { teamName: string } -) & { - member: ITeamMemberParams; +export type TeamsUpdateMemberProps = ({ teamId: string } | { teamName: string }) & { + member: ITeamMemberParams; }; const teamsUpdateMemberPropsSchema: JSONSchemaType = { - oneOf: [ - { - type: "object", - properties: { - teamId: { - type: "string", - }, - member: { - type: "object", - properties: { - userId: { - type: "string", - }, - roles: { - type: "array", - items: { - type: "string", - }, - nullable: true, - }, - }, - required: ["userId"], - additionalProperties: false, - }, - }, - required: ["teamId", "member"], - additionalProperties: false, - }, - { - type: "object", - properties: { - teamName: { - type: "string", - }, - member: { - type: "object", - properties: { - userId: { - type: "string", - }, - roles: { - type: "array", - items: { - type: "string", - }, - nullable: true, - }, - }, - required: ["userId"], - additionalProperties: false, - }, - }, - required: ["teamName", "member"], - additionalProperties: false, - }, - ], + oneOf: [ + { + type: 'object', + properties: { + teamId: { + type: 'string', + }, + member: { + type: 'object', + properties: { + userId: { + type: 'string', + }, + roles: { + type: 'array', + items: { + type: 'string', + }, + nullable: true, + }, + }, + required: ['userId'], + additionalProperties: false, + }, + }, + required: ['teamId', 'member'], + additionalProperties: false, + }, + { + type: 'object', + properties: { + teamName: { + type: 'string', + }, + member: { + type: 'object', + properties: { + userId: { + type: 'string', + }, + roles: { + type: 'array', + items: { + type: 'string', + }, + nullable: true, + }, + }, + required: ['userId'], + additionalProperties: false, + }, + }, + required: ['teamName', 'member'], + additionalProperties: false, + }, + ], }; -export const isTeamsUpdateMemberProps = ajv.compile( - teamsUpdateMemberPropsSchema -); +export const isTeamsUpdateMemberProps = ajv.compile(teamsUpdateMemberPropsSchema); diff --git a/packages/rest-typings/src/v1/teams/TeamsUpdateProps.ts b/packages/rest-typings/src/v1/teams/TeamsUpdateProps.ts index 935fc0d82add..2a1349767f0f 100644 --- a/packages/rest-typings/src/v1/teams/TeamsUpdateProps.ts +++ b/packages/rest-typings/src/v1/teams/TeamsUpdateProps.ts @@ -1,74 +1,73 @@ -import Ajv, { JSONSchemaType } from "ajv"; - -import { TEAM_TYPE } from "@rocket.chat/core-typings"; +import Ajv, { JSONSchemaType } from 'ajv'; +import { TEAM_TYPE } from '@rocket.chat/core-typings'; const ajv = new Ajv(); export type TeamsUpdateProps = ({ teamId: string } | { teamName: string }) & { - data: - | { - name: string; - type?: TEAM_TYPE; - } - | { - name?: string; - type: TEAM_TYPE; - }; + data: + | { + name: string; + type?: TEAM_TYPE; + } + | { + name?: string; + type: TEAM_TYPE; + }; }; const teamsUpdatePropsSchema: JSONSchemaType = { - type: "object", - properties: { - updateRoom: { - type: "boolean", - nullable: true, - }, - teamId: { - type: "string", - nullable: true, - }, - teamName: { - type: "string", - nullable: true, - }, - data: { - type: "object", - properties: { - name: { - type: "string", - nullable: true, - }, - type: { - type: "number", - enum: [TEAM_TYPE.PUBLIC, TEAM_TYPE.PRIVATE], - }, - }, - additionalProperties: false, - required: [], - anyOf: [ - { - required: ["name"], - }, - { - required: ["type"], - }, - ], - }, - name: { - type: "string", - nullable: true, - }, - }, - required: [], - oneOf: [ - { - required: ["teamId", "data"], - }, - { - required: ["teamName", "data"], - }, - ], - additionalProperties: false, + type: 'object', + properties: { + updateRoom: { + type: 'boolean', + nullable: true, + }, + teamId: { + type: 'string', + nullable: true, + }, + teamName: { + type: 'string', + nullable: true, + }, + data: { + type: 'object', + properties: { + name: { + type: 'string', + nullable: true, + }, + type: { + type: 'number', + enum: [TEAM_TYPE.PUBLIC, TEAM_TYPE.PRIVATE], + }, + }, + additionalProperties: false, + required: [], + anyOf: [ + { + required: ['name'], + }, + { + required: ['type'], + }, + ], + }, + name: { + type: 'string', + nullable: true, + }, + }, + required: [], + oneOf: [ + { + required: ['teamId', 'data'], + }, + { + required: ['teamName', 'data'], + }, + ], + additionalProperties: false, }; export const isTeamsUpdateProps = ajv.compile(teamsUpdatePropsSchema); diff --git a/packages/rest-typings/src/v1/teams/index.ts b/packages/rest-typings/src/v1/teams/index.ts index f79b24b28317..5aaccb50533c 100644 --- a/packages/rest-typings/src/v1/teams/index.ts +++ b/packages/rest-typings/src/v1/teams/index.ts @@ -1,197 +1,185 @@ -import type { IRole, IRoom } from "@rocket.chat/core-typings"; -import type { ITeam } from "@rocket.chat/core-typings"; -import type { IUser } from "@rocket.chat/core-typings"; -import type { PaginatedRequest } from "../../helpers/PaginatedRequest"; -import type { PaginatedResult } from "../../helpers/PaginatedResult"; -import type { TeamsAddMembersProps } from "./TeamsAddMembersProps"; -import type { TeamsConvertToChannelProps } from "./TeamsConvertToChannelProps"; -import type { TeamsDeleteProps } from "./TeamsDeleteProps"; -import type { TeamsLeaveProps } from "./TeamsLeaveProps"; -import type { TeamsRemoveMemberProps } from "./TeamsRemoveMemberProps"; -import type { TeamsRemoveRoomProps } from "./TeamsRemoveRoomProps"; -import type { TeamsUpdateMemberProps } from "./TeamsUpdateMemberProps"; -import type { TeamsUpdateProps } from "./TeamsUpdateProps"; - -export * from "./TeamsAddMembersProps"; -export * from "./TeamsConvertToChannelProps"; -export * from "./TeamsDeleteProps"; -export * from "./TeamsLeaveProps"; -export * from "./TeamsRemoveMemberProps"; -export * from "./TeamsRemoveRoomProps"; -export * from "./TeamsUpdateMemberProps"; -export * from "./TeamsUpdateProps"; - -type ITeamAutocompleteResult = Pick< - IRoom, - "_id" | "fname" | "teamId" | "name" | "t" | "avatarETag" ->; +import type { IRole, IRoom, ITeam, IUser } from '@rocket.chat/core-typings'; + +import type { PaginatedRequest } from '../../helpers/PaginatedRequest'; +import type { PaginatedResult } from '../../helpers/PaginatedResult'; +import type { TeamsAddMembersProps } from './TeamsAddMembersProps'; +import type { TeamsConvertToChannelProps } from './TeamsConvertToChannelProps'; +import type { TeamsDeleteProps } from './TeamsDeleteProps'; +import type { TeamsLeaveProps } from './TeamsLeaveProps'; +import type { TeamsRemoveMemberProps } from './TeamsRemoveMemberProps'; +import type { TeamsRemoveRoomProps } from './TeamsRemoveRoomProps'; +import type { TeamsUpdateMemberProps } from './TeamsUpdateMemberProps'; +import type { TeamsUpdateProps } from './TeamsUpdateProps'; + +export * from './TeamsAddMembersProps'; +export * from './TeamsConvertToChannelProps'; +export * from './TeamsDeleteProps'; +export * from './TeamsLeaveProps'; +export * from './TeamsRemoveMemberProps'; +export * from './TeamsRemoveRoomProps'; +export * from './TeamsUpdateMemberProps'; +export * from './TeamsUpdateProps'; + +type ITeamAutocompleteResult = Pick; interface IUserInfo { - _id: string; - username?: string; - name: string; - status: string; - settings?: Record; + _id: string; + username?: string; + name: string; + status: string; + settings?: Record; } interface ITeamMemberInfo { - user: IUserInfo; - roles?: IRole["_id"][] | null; - createdBy: Omit; - createdAt: Date; + user: IUserInfo; + roles?: IRole['_id'][] | null; + createdBy: Omit; + createdAt: Date; } type TeamProps = - | TeamsRemoveRoomProps - | TeamsConvertToChannelProps - | TeamsUpdateMemberProps - | TeamsAddMembersProps - | TeamsRemoveMemberProps - | TeamsDeleteProps - | TeamsLeaveProps - | TeamsUpdateProps; - -export const isTeamPropsWithTeamName = ( - props: T -): props is T & { teamName: string } => "teamName" in props; - -export const isTeamPropsWithTeamId = ( - props: T -): props is T & { teamId: string } => "teamId" in props; + | TeamsRemoveRoomProps + | TeamsConvertToChannelProps + | TeamsUpdateMemberProps + | TeamsAddMembersProps + | TeamsRemoveMemberProps + | TeamsDeleteProps + | TeamsLeaveProps + | TeamsUpdateProps; + +export const isTeamPropsWithTeamName = (props: T): props is T & { teamName: string } => 'teamName' in props; + +export const isTeamPropsWithTeamId = (props: T): props is T & { teamId: string } => 'teamId' in props; export type TeamsEndpoints = { - "teams.list": { - GET: () => PaginatedResult & { teams: ITeam[] }; - }; - "teams.listAll": { - GET: () => { teams: ITeam[] } & PaginatedResult; - }; - "teams.create": { - POST: (params: { - name: ITeam["name"]; - type: ITeam["type"]; - members?: IUser["_id"][]; - room: { - id?: string; - name?: IRoom["name"]; - members?: IUser["_id"][]; - readOnly?: boolean; - extraData?: { - teamId?: string; - teamMain?: boolean; - } & { [key: string]: string | boolean }; - options?: { - nameValidationRegex?: string; - creator: string; - subscriptionExtra?: { - open: boolean; - ls: Date; - prid: IRoom["_id"]; - }; - } & { - [key: string]: - | string - | { - open: boolean; - ls: Date; - prid: IRoom["_id"]; - }; - }; - }; - owner?: IUser["_id"]; - }) => { - team: ITeam; - }; - }; - - "teams.convertToChannel": { - POST: (params: TeamsConvertToChannelProps) => void; - }; - - "teams.addRooms": { - POST: ( - params: - | { rooms: IRoom["_id"][]; teamId: string } - | { rooms: IRoom["_id"][]; teamName: string } - ) => { rooms: IRoom[] }; - }; - - "teams.removeRoom": { - POST: (params: TeamsRemoveRoomProps) => { room: IRoom }; - }; - - "teams.members": { - GET: ( - params: ({ teamId: string } | { teamName: string }) & { - status?: string[]; - username?: string; - name?: string; - } - ) => PaginatedResult & { members: ITeamMemberInfo[] }; - }; - - "teams.addMembers": { - POST: (params: TeamsAddMembersProps) => void; - }; - - "teams.updateMember": { - POST: (params: TeamsUpdateMemberProps) => void; - }; - - "teams.removeMember": { - POST: (params: TeamsRemoveMemberProps) => void; - }; - - "teams.leave": { - POST: (params: TeamsLeaveProps) => void; - }; - - "teams.info": { - GET: (params: ({ teamId: string } | { teamName: string }) & {}) => { - teamInfo: Partial; - }; - }; - - "teams.autocomplete": { - GET: (params: { name: string }) => { teams: ITeamAutocompleteResult[] }; - }; - - "teams.update": { - POST: (params: TeamsUpdateProps) => void; - }; - - "teams.delete": { - POST: (params: TeamsDeleteProps) => void; - }; - - "teams.listRoomsOfUser": { - GET: ( - params: - | { - teamId: ITeam["_id"]; - userId: IUser["_id"]; - canUserDelete?: string; - } - | { - teamName: ITeam["name"]; - userId: IUser["_id"]; - canUserDelete?: string; - } - ) => PaginatedResult & { rooms: IRoom[] }; - }; - - "teams.listRooms": { - GET: ( - params: PaginatedRequest & - ({ teamId: string } | { teamName: string }) & { - filter?: string; - type?: string; - } - ) => PaginatedResult & { rooms: IRoom[] }; - }; - - "teams.updateRoom": { - POST: (params: { roomId: IRoom["_id"]; isDefault: boolean }) => { - room: IRoom; - }; - }; + 'teams.list': { + GET: () => PaginatedResult & { teams: ITeam[] }; + }; + 'teams.listAll': { + GET: () => { teams: ITeam[] } & PaginatedResult; + }; + 'teams.create': { + POST: (params: { + name: ITeam['name']; + type: ITeam['type']; + members?: IUser['_id'][]; + room: { + id?: string; + name?: IRoom['name']; + members?: IUser['_id'][]; + readOnly?: boolean; + extraData?: { + teamId?: string; + teamMain?: boolean; + } & { [key: string]: string | boolean }; + options?: { + nameValidationRegex?: string; + creator: string; + subscriptionExtra?: { + open: boolean; + ls: Date; + prid: IRoom['_id']; + }; + } & { + [key: string]: + | string + | { + open: boolean; + ls: Date; + prid: IRoom['_id']; + }; + }; + }; + owner?: IUser['_id']; + }) => { + team: ITeam; + }; + }; + + 'teams.convertToChannel': { + POST: (params: TeamsConvertToChannelProps) => void; + }; + + 'teams.addRooms': { + POST: (params: { rooms: IRoom['_id'][]; teamId: string } | { rooms: IRoom['_id'][]; teamName: string }) => { rooms: IRoom[] }; + }; + + 'teams.removeRoom': { + POST: (params: TeamsRemoveRoomProps) => { room: IRoom }; + }; + + 'teams.members': { + GET: ( + params: ({ teamId: string } | { teamName: string }) & { + status?: string[]; + username?: string; + name?: string; + }, + ) => PaginatedResult & { members: ITeamMemberInfo[] }; + }; + + 'teams.addMembers': { + POST: (params: TeamsAddMembersProps) => void; + }; + + 'teams.updateMember': { + POST: (params: TeamsUpdateMemberProps) => void; + }; + + 'teams.removeMember': { + POST: (params: TeamsRemoveMemberProps) => void; + }; + + 'teams.leave': { + POST: (params: TeamsLeaveProps) => void; + }; + + 'teams.info': { + GET: (params: ({ teamId: string } | { teamName: string }) & {}) => { + teamInfo: Partial; + }; + }; + + 'teams.autocomplete': { + GET: (params: { name: string }) => { teams: ITeamAutocompleteResult[] }; + }; + + 'teams.update': { + POST: (params: TeamsUpdateProps) => void; + }; + + 'teams.delete': { + POST: (params: TeamsDeleteProps) => void; + }; + + 'teams.listRoomsOfUser': { + GET: ( + params: + | { + teamId: ITeam['_id']; + userId: IUser['_id']; + canUserDelete?: string; + } + | { + teamName: ITeam['name']; + userId: IUser['_id']; + canUserDelete?: string; + }, + ) => PaginatedResult & { rooms: IRoom[] }; + }; + + 'teams.listRooms': { + GET: ( + params: PaginatedRequest & + ({ teamId: string } | { teamName: string }) & { + filter?: string; + type?: string; + }, + ) => PaginatedResult & { rooms: IRoom[] }; + }; + + 'teams.updateRoom': { + POST: (params: { roomId: IRoom['_id']; isDefault: boolean }) => { + room: IRoom; + }; + }; }; diff --git a/packages/rest-typings/src/v1/users.ts b/packages/rest-typings/src/v1/users.ts index c56e7a125136..6caa5d8abbf7 100644 --- a/packages/rest-typings/src/v1/users.ts +++ b/packages/rest-typings/src/v1/users.ts @@ -1,19 +1,18 @@ -import type { ITeam } from "@rocket.chat/core-typings"; -import type { IUser } from "@rocket.chat/core-typings"; +import type { ITeam, IUser } from '@rocket.chat/core-typings'; export type UsersEndpoints = { - "users.info": { - GET: (params: { userId?: IUser["_id"]; userName?: IUser["username"] }) => { - user: IUser; - }; - }; - "users.2fa.sendEmailCode": { - POST: (params: { emailOrUsername: string }) => void; - }; - "users.autocomplete": { - GET: (params: { selector: string }) => { items: IUser[] }; - }; - "users.listTeams": { - GET: (params: { userId: IUser["_id"] }) => { teams: Array }; - }; + 'users.info': { + GET: (params: { userId?: IUser['_id']; userName?: IUser['username'] }) => { + user: IUser; + }; + }; + 'users.2fa.sendEmailCode': { + POST: (params: { emailOrUsername: string }) => void; + }; + 'users.autocomplete': { + GET: (params: { selector: string }) => { items: IUser[] }; + }; + 'users.listTeams': { + GET: (params: { userId: IUser['_id'] }) => { teams: Array }; + }; }; diff --git a/packages/rest-typings/src/v1/voip.ts b/packages/rest-typings/src/v1/voip.ts index 9116befeadae..5398586927a3 100644 --- a/packages/rest-typings/src/v1/voip.ts +++ b/packages/rest-typings/src/v1/voip.ts @@ -1,17 +1,18 @@ -import type { IQueueSummary } from "@rocket.chat/core-typings"; -import type { ILivechatAgent } from "@rocket.chat/core-typings"; -import type { IVoipRoom } from "@rocket.chat/core-typings"; -import type { IUser } from "@rocket.chat/core-typings"; import type { - IQueueMembershipDetails, - IQueueMembershipSubscription, - IVoipExtensionWithAgentInfo, -} from "@rocket.chat/core-typings"; -import type { IManagementServerConnectionStatus } from "@rocket.chat/core-typings"; -import type { IRegistrationInfo } from "@rocket.chat/core-typings"; -import type { VoipClientEvents } from "@rocket.chat/core-typings"; -import type { PaginatedRequest } from "../helpers/PaginatedRequest"; -import type { PaginatedResult } from "../helpers/PaginatedResult"; + IQueueSummary, + ILivechatAgent, + IVoipRoom, + IUser, + IQueueMembershipDetails, + IQueueMembershipSubscription, + IVoipExtensionWithAgentInfo, + IManagementServerConnectionStatus, + IRegistrationInfo, + VoipClientEvents, +} from '@rocket.chat/core-typings'; + +import type { PaginatedRequest } from '../helpers/PaginatedRequest'; +import type { PaginatedResult } from '../helpers/PaginatedResult'; export type VoipEndpoints = { 'connector.extension.getRegistrationInfoByUserId': { diff --git a/yarn.lock b/yarn.lock index 0dea2bce4c74..153951ef33b8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3416,6 +3416,7 @@ __metadata: resolution: "@rocket.chat/core-typings@workspace:packages/core-typings" dependencies: "@rocket.chat/apps-engine": ^1.31.0 + "@rocket.chat/eslint-config": "workspace:^" "@rocket.chat/icons": ^0.31.9 "@rocket.chat/message-parser": ^0.31.6 "@rocket.chat/ui-kit": ^0.31.6 @@ -3462,17 +3463,23 @@ __metadata: languageName: node linkType: hard -"@rocket.chat/eslint-config@npm:^0.4.0": - version: 0.4.0 - resolution: "@rocket.chat/eslint-config@npm:0.4.0" +"@rocket.chat/eslint-config@workspace:^, @rocket.chat/eslint-config@workspace:packages/eslint-config": + version: 0.0.0-use.local + resolution: "@rocket.chat/eslint-config@workspace:packages/eslint-config" dependencies: - eslint-plugin-import: ^2.17.2 - peerDependencies: - eslint: ^4.19.1 || ^5.16.0 - eslint-plugin-import: ^2.17.2 - checksum: 1bcfcd23cc6f16645f8ad46c060bdaa4ef248c7e200d0d011b426c8c0db4619100cb84125621fa6e4efeb0401381f43fe521ab0fd4dcd2fed8023d1323e9884d - languageName: node - linkType: hard + "@types/prettier": ^2 + "@typescript-eslint/eslint-plugin": ^2.34.0 + "@typescript-eslint/parser": ^3.0.0 + babel-eslint: ^10.1.0 + eslint: ^6.8.0 + eslint-config-prettier: ^8.3.0 + eslint-plugin-anti-trojan-source: ^1.1.0 + eslint-plugin-import: ^2.24.2 + eslint-plugin-jest: ^26.1.5 + eslint-plugin-prettier: ^3.4.1 + prettier: 2.6.2 + languageName: unknown + linkType: soft "@rocket.chat/fuselage-hooks@npm:^0.31.10, @rocket.chat/fuselage-hooks@npm:~0.31.10": version: 0.31.10 @@ -3646,7 +3653,7 @@ __metadata: "@rocket.chat/core-typings": "workspace:^" "@rocket.chat/css-in-js": ~0.31.10 "@rocket.chat/emitter": ~0.31.10 - "@rocket.chat/eslint-config": ^0.4.0 + "@rocket.chat/eslint-config": "workspace:^" "@rocket.chat/fuselage": ~0.31.10 "@rocket.chat/fuselage-hooks": ~0.31.10 "@rocket.chat/fuselage-polyfills": ~0.31.10 @@ -3951,6 +3958,7 @@ __metadata: dependencies: "@rocket.chat/apps-engine": ^1.31.0 "@rocket.chat/core-typings": "workspace:^" + "@rocket.chat/eslint-config": "workspace:^" "@rocket.chat/message-parser": ^0.31.6 "@rocket.chat/ui-kit": ^0.31.6 "@types/jest": ^27.4.1 @@ -6158,7 +6166,7 @@ __metadata: languageName: node linkType: hard -"@types/prettier@npm:^2.1.5": +"@types/prettier@npm:^2, @types/prettier@npm:^2.1.5": version: 2.6.0 resolution: "@types/prettier@npm:2.6.0" checksum: 946f1f82ce6f31664e023a5d65931c31b7d677b454f528f67dce851d72e7fcfe713076f4251b16c3646eecf1545f5f5b909b4962966341ed9ddf5b80113b3674 @@ -6646,6 +6654,16 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/scope-manager@npm:5.21.0": + version: 5.21.0 + resolution: "@typescript-eslint/scope-manager@npm:5.21.0" + dependencies: + "@typescript-eslint/types": 5.21.0 + "@typescript-eslint/visitor-keys": 5.21.0 + checksum: 2bcb5947d7882f08fb8f40eea154c15152957105a3dc80bf8481212a66d35a8d2239437e095a9a7526c6c0043e9bd6bececf4f87d40da85abb2d2b69f774d805 + languageName: node + linkType: hard + "@typescript-eslint/types@npm:3.10.1": version: 3.10.1 resolution: "@typescript-eslint/types@npm:3.10.1" @@ -6660,6 +6678,13 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/types@npm:5.21.0": + version: 5.21.0 + resolution: "@typescript-eslint/types@npm:5.21.0" + checksum: 1581bf79f8c9236844ca8891e26c84503b654359fbfee80d76f9f57fb90c24210687cd30f61592e7d44cacf5417c83aaa5ae8559a4a8b6ce6b6c4a163b8b86c2 + languageName: node + linkType: hard + "@typescript-eslint/typescript-estree@npm:2.34.0": version: 2.34.0 resolution: "@typescript-eslint/typescript-estree@npm:2.34.0" @@ -6715,6 +6740,40 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/typescript-estree@npm:5.21.0": + version: 5.21.0 + resolution: "@typescript-eslint/typescript-estree@npm:5.21.0" + dependencies: + "@typescript-eslint/types": 5.21.0 + "@typescript-eslint/visitor-keys": 5.21.0 + debug: ^4.3.2 + globby: ^11.0.4 + is-glob: ^4.0.3 + semver: ^7.3.5 + tsutils: ^3.21.0 + peerDependenciesMeta: + typescript: + optional: true + checksum: 4f78d61be2f35775d0f2d7fc4e3bb0bfc6b84e608e96a297c948f84a7254c1b9f0062f61a1dce67a8d4eb67476a9b4a9ebd8b6412e97db76f675c03363a5a0ad + languageName: node + linkType: hard + +"@typescript-eslint/utils@npm:^5.10.0": + version: 5.21.0 + resolution: "@typescript-eslint/utils@npm:5.21.0" + dependencies: + "@types/json-schema": ^7.0.9 + "@typescript-eslint/scope-manager": 5.21.0 + "@typescript-eslint/types": 5.21.0 + "@typescript-eslint/typescript-estree": 5.21.0 + eslint-scope: ^5.1.1 + eslint-utils: ^3.0.0 + peerDependencies: + eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 + checksum: ed339a4ccb9eeb2a1132c41999d6584c15c4b7e2f0132bce613f502faa1dbbad7e206b642360392a6e2b24e294df90910141c7da0959901efcd600aedc4c4253 + languageName: node + linkType: hard + "@typescript-eslint/utils@npm:^5.13.0": version: 5.18.0 resolution: "@typescript-eslint/utils@npm:5.18.0" @@ -6750,6 +6809,16 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/visitor-keys@npm:5.21.0": + version: 5.21.0 + resolution: "@typescript-eslint/visitor-keys@npm:5.21.0" + dependencies: + "@typescript-eslint/types": 5.21.0 + eslint-visitor-keys: ^3.0.0 + checksum: 328b18faa61872160f3e5faacb5b68022bdabd04b5414f115133245a4a1ecfb5762c67fd645ab3253005480bd25a38598f57fdc2ff2b01d830ac68b37d3d06a5 + languageName: node + linkType: hard + "@ungap/promise-all-settled@npm:1.1.2": version: 1.1.2 resolution: "@ungap/promise-all-settled@npm:1.1.2" @@ -12450,7 +12519,7 @@ __metadata: languageName: node linkType: hard -"eslint-plugin-import@npm:^2.17.2, eslint-plugin-import@npm:^2.24.2": +"eslint-plugin-import@npm:^2.24.2": version: 2.25.4 resolution: "eslint-plugin-import@npm:2.25.4" dependencies: @@ -12473,6 +12542,23 @@ __metadata: languageName: node linkType: hard +"eslint-plugin-jest@npm:^26.1.5": + version: 26.1.5 + resolution: "eslint-plugin-jest@npm:26.1.5" + dependencies: + "@typescript-eslint/utils": ^5.10.0 + peerDependencies: + "@typescript-eslint/eslint-plugin": ^5.0.0 + eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 + peerDependenciesMeta: + "@typescript-eslint/eslint-plugin": + optional: true + jest: + optional: true + checksum: 727487c6d0cc4aa66f8209fc187a2f4eb56ffea6569dacb04bb1e3272221d6238460fb967a12074acac50b0b545d2190c697bad64ebc6c8bdd4e8f3cc66d5a68 + languageName: node + linkType: hard + "eslint-plugin-prettier@npm:^3.4.1": version: 3.4.1 resolution: "eslint-plugin-prettier@npm:3.4.1"