From b6da650ae2784103dca373f80bdcd648b3c959be Mon Sep 17 00:00:00 2001 From: Diego Sampaio Date: Mon, 26 Dec 2022 11:55:00 -0300 Subject: [PATCH 01/18] Update Meteor and packages --- apps/meteor/.meteor/packages | 50 +++++++++--------- apps/meteor/.meteor/release | 2 +- apps/meteor/.meteor/versions | 100 +++++++++++++++++------------------ 3 files changed, 76 insertions(+), 76 deletions(-) diff --git a/apps/meteor/.meteor/packages b/apps/meteor/.meteor/packages index 292ef0526ba7..8fba627cc78b 100644 --- a/apps/meteor/.meteor/packages +++ b/apps/meteor/.meteor/packages @@ -13,33 +13,33 @@ accounts-facebook@1.3.3 accounts-github@1.5.0 accounts-google@1.4.0 accounts-meteor-developer@1.5.0 -accounts-password@2.3.1 +accounts-password@2.3.2 accounts-twitter@1.5.0 blaze-html-templates -check@1.3.1 -ddp-rate-limiter@1.1.0 +check@1.3.2 +ddp-rate-limiter@1.1.1 ddp-common@1.4.0 dynamic-import@0.7.2 -ecmascript@0.16.2 -typescript@4.5.4 -ejson@1.1.2 -email@2.2.1 +ecmascript@0.16.4 +typescript@4.6.4 +ejson@1.1.3 +email@2.2.3 http@2.0.0 logging@1.3.1 meteor-base@1.5.1 mobile-experience@1.1.0 -mongo@1.15.0 -random@1.2.0 +mongo@1.16.3 +random@1.2.1 rate-limit@1.0.9 -reactive-dict@1.3.0 -reactive-var@1.0.11 +reactive-dict@1.3.1 +reactive-var@1.0.12 reload@1.3.1 -service-configuration@1.3.0 -session@1.2.0 +service-configuration@1.3.1 +session@1.2.1 shell-server@0.5.0 spacebars -standard-minifier-js@2.8.0 -tracker@1.2.0 +standard-minifier-js@2.8.1 +tracker@1.2.1 rocketchat:livechat rocketchat:streamer @@ -66,28 +66,28 @@ raix:handlebar-helpers raix:ui-dropped-event rocketchat:tap-i18n@3.0.0 -underscore@1.0.10 +underscore@1.0.11 littledata:synced-cron -accounts-base@2.2.3 -accounts-oauth@1.4.1 +accounts-base@2.2.6 +accounts-oauth@1.4.2 autoupdate@1.8.0 -babel-compiler@7.9.0 -google-oauth@1.4.2 +babel-compiler@7.10.1 +google-oauth@1.4.3 htmljs less matb33:collection-hooks meteorhacks:inject-initial -oauth@2.1.2 -oauth2@1.3.1 +oauth@2.1.3 +oauth2@1.3.2 routepolicy@1.1.1 sha@1.0.9 templating -webapp@1.13.1 -webapp-hashing@1.1.0 +webapp@1.13.2 +webapp-hashing@1.1.1 rocketchat:oauth2-server rocketchat:i18n dandv:caret-position facts-base@1.0.1 url@1.3.2 -standard-minifier-css +standard-minifier-css@1.8.3 diff --git a/apps/meteor/.meteor/release b/apps/meteor/.meteor/release index 66dd7b664724..e1e355d0cdb0 100644 --- a/apps/meteor/.meteor/release +++ b/apps/meteor/.meteor/release @@ -1 +1 @@ -METEOR@2.7.3 +METEOR@2.9.0 diff --git a/apps/meteor/.meteor/versions b/apps/meteor/.meteor/versions index 2cb41ac914aa..75d94436261d 100644 --- a/apps/meteor/.meteor/versions +++ b/apps/meteor/.meteor/versions @@ -1,51 +1,51 @@ -accounts-base@2.2.3 +accounts-base@2.2.6 accounts-facebook@1.3.3 accounts-github@1.5.0 accounts-google@1.4.0 accounts-meteor-developer@1.5.0 -accounts-oauth@1.4.1 -accounts-password@2.3.1 +accounts-oauth@1.4.2 +accounts-password@2.3.2 accounts-twitter@1.5.0 aldeed:simple-schema@1.5.4 allow-deny@1.1.1 autoupdate@1.8.0 -babel-compiler@7.9.0 +babel-compiler@7.10.1 babel-runtime@1.5.1 base64@1.0.12 binary-heap@1.0.11 -blaze@2.6.0 -blaze-html-templates@1.2.1 +blaze@2.6.1 +blaze-html-templates@2.0.0 blaze-tools@1.1.3 boilerplate-generator@1.7.1 caching-compiler@1.2.2 caching-html-compiler@1.2.1 callback-hook@1.4.0 -check@1.3.1 +check@1.3.2 coffeescript@2.4.1 coffeescript-compiler@2.4.1 dandv:caret-position@2.1.1 -ddp@1.4.0 -ddp-client@2.5.0 +ddp@1.4.1 +ddp-client@2.6.1 ddp-common@1.4.0 -ddp-rate-limiter@1.1.0 -ddp-server@2.5.0 +ddp-rate-limiter@1.1.1 +ddp-server@2.6.0 deps@1.0.12 -diff-sequence@1.1.1 +diff-sequence@1.1.2 dispatch:run-as-user@1.1.1 dynamic-import@0.7.2 -ecmascript@0.16.2 +ecmascript@0.16.4 ecmascript-runtime@0.8.0 ecmascript-runtime-client@0.12.1 ecmascript-runtime-server@0.11.0 -ejson@1.1.2 -email@2.2.1 +ejson@1.1.3 +email@2.2.3 es5-shim@4.8.0 -facebook-oauth@1.11.0 +facebook-oauth@1.11.2 facts-base@1.0.1 -fetch@0.1.1 -geojson-utils@1.0.10 -github-oauth@1.4.0 -google-oauth@1.4.2 +fetch@0.1.2 +geojson-utils@1.0.11 +github-oauth@1.4.1 +google-oauth@1.4.3 hot-code-push@1.0.4 html-tools@1.1.3 htmljs@1.1.1 @@ -63,49 +63,49 @@ kadira:flow-router@2.12.1 konecty:multiple-instances-status@1.1.0 konecty:user-presence@2.6.3 launch-screen@1.3.0 -less@3.0.2 +less@4.0.0 littledata:synced-cron@1.5.1 localstorage@1.2.0 logging@1.3.1 -matb33:collection-hooks@1.1.2 +matb33:collection-hooks@1.1.4 mdg:validation-error@0.5.1 -meteor@1.10.0 +meteor@1.10.3 meteor-base@1.5.1 -meteor-developer-oauth@1.3.1 +meteor-developer-oauth@1.3.2 meteorhacks:inject-initial@1.0.5 -minifier-css@1.6.0 -minifier-js@2.7.4 -minimongo@1.8.0 +minifier-css@1.6.2 +minifier-js@2.7.5 +minimongo@1.9.1 mobile-experience@1.1.0 mobile-status-bar@1.1.0 -modern-browsers@0.1.8 -modules@0.18.0 -modules-runtime@0.13.0 -mongo@1.15.0 +modern-browsers@0.1.9 +modules@0.19.0 +modules-runtime@0.13.1 +mongo@1.16.3 mongo-decimal@0.1.3 mongo-dev-server@1.1.0 mongo-id@1.0.8 mrt:reactive-store@0.0.1 mystor:device-detection@0.2.0 nooitaf:colors@1.2.0 -npm-mongo@4.3.1 -oauth@2.1.2 -oauth1@1.5.0 -oauth2@1.3.1 +npm-mongo@4.12.1 +oauth@2.1.3 +oauth1@1.5.1 +oauth2@1.3.2 observe-sequence@1.0.20 ordered-dict@1.1.0 ostrio:cookies@2.7.2 pauli:accounts-linkedin@6.0.0 pauli:linkedin-oauth@6.0.0 -promise@0.12.0 +promise@0.12.2 raix:eventemitter@1.0.0 raix:handlebar-helpers@0.2.5 raix:ui-dropped-event@0.0.7 -random@1.2.0 +random@1.2.1 rate-limit@1.0.9 react-fast-refresh@0.2.3 -reactive-dict@1.3.0 -reactive-var@1.0.11 +reactive-dict@1.3.1 +reactive-var@1.0.12 reload@1.3.1 retry@1.1.0 rocketchat:ddp@0.0.1 @@ -118,25 +118,25 @@ rocketchat:streamer@1.1.0 rocketchat:tap-i18n@3.0.0 rocketchat:version@1.0.0 routepolicy@1.1.1 -service-configuration@1.3.0 -session@1.2.0 +service-configuration@1.3.1 +session@1.2.1 sha@1.0.9 shell-server@0.5.0 simple:json-routes@2.3.1 socket-stream-client@0.5.0 spacebars@1.3.0 spacebars-compiler@1.3.1 -standard-minifier-css@1.8.1 -standard-minifier-js@2.8.0 +standard-minifier-css@1.8.3 +standard-minifier-js@2.8.1 templating@1.4.2 templating-compiler@1.4.1 -templating-runtime@1.6.0 +templating-runtime@1.6.1 templating-tools@1.2.2 -tracker@1.2.0 -twitter-oauth@1.3.0 -typescript@4.5.4 +tracker@1.2.1 +twitter-oauth@1.3.2 +typescript@4.6.4 ui@1.0.13 -underscore@1.0.10 +underscore@1.0.11 url@1.3.2 -webapp@1.13.1 -webapp-hashing@1.1.0 +webapp@1.13.2 +webapp-hashing@1.1.1 From e1b9a2a7234106c653bd73b6f5dc2a0a5b27590e Mon Sep 17 00:00:00 2001 From: Diego Sampaio Date: Mon, 26 Dec 2022 11:55:52 -0300 Subject: [PATCH 02/18] Update NodeJS --- .github/workflows/build_and_test.yml | 10 +++++----- apps/meteor/.docker-mongo/Dockerfile | 2 +- apps/meteor/.docker/Dockerfile | 2 +- apps/meteor/.docker/Dockerfile.alpine | 2 +- apps/meteor/ee/server/services/Dockerfile | 4 ++-- ee/apps/account-service/Dockerfile | 2 +- ee/apps/authorization-service/Dockerfile | 2 +- ee/apps/ddp-streamer/Dockerfile | 2 +- ee/apps/presence-service/Dockerfile | 2 +- ee/apps/stream-hub-service/Dockerfile | 2 +- package.json | 4 ++-- yarn.lock | 2 +- 12 files changed, 18 insertions(+), 18 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index df5438eb29c5..242160054cdd 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -79,10 +79,10 @@ jobs: - uses: actions/checkout@v3 - - name: Use Node.js 14.19.3 + - name: Use Node.js 14.21.1 uses: actions/setup-node@v3 with: - node-version: '14.19.3' + node-version: '14.21.1' cache: 'yarn' - name: Free disk space @@ -222,7 +222,7 @@ jobs: strategy: matrix: - node-version: ['14.19.3'] + node-version: ['14.21.1'] mongodb-version: ['4.2', '4.4', '5.0'] steps: @@ -423,7 +423,7 @@ jobs: strategy: matrix: - node-version: ['14.19.3'] + node-version: ['14.21.1'] mongodb-version-ee: ['4.4'] steps: @@ -693,7 +693,7 @@ jobs: aws s3 cp $ROCKET_DEPLOY_DIR/ s3://download.rocket.chat/build/ --recursive curl -H "Content-Type: application/json" -H "X-Update-Token: $UPDATE_TOKEN" -d \ - "{\"nodeVersion\": \"14.19.3\", \"compatibleMongoVersions\": [\"4.2\", \"4.4\", \"5.0\"], \"commit\": \"$GITHUB_SHA\", \"tag\": \"$RC_VERSION\", \"branch\": \"$GIT_BRANCH\", \"artifactName\": \"$ARTIFACT_NAME\", \"releaseType\": \"$RC_RELEASE\"}" \ + "{\"nodeVersion\": \"14.21.1\", \"compatibleMongoVersions\": [\"4.2\", \"4.4\", \"5.0\"], \"commit\": \"$GITHUB_SHA\", \"tag\": \"$RC_VERSION\", \"branch\": \"$GIT_BRANCH\", \"artifactName\": \"$ARTIFACT_NAME\", \"releaseType\": \"$RC_RELEASE\"}" \ https://releases.rocket.chat/update # Makes build fail if the release isn't there diff --git a/apps/meteor/.docker-mongo/Dockerfile b/apps/meteor/.docker-mongo/Dockerfile index f8556d971d8b..fbc2c2a37d06 100644 --- a/apps/meteor/.docker-mongo/Dockerfile +++ b/apps/meteor/.docker-mongo/Dockerfile @@ -1,4 +1,4 @@ -FROM node:14.19.3-bullseye-slim +FROM node:14.21.1-bullseye-slim LABEL maintainer="buildmaster@rocket.chat" diff --git a/apps/meteor/.docker/Dockerfile b/apps/meteor/.docker/Dockerfile index ce06aeb052eb..3fa996468957 100644 --- a/apps/meteor/.docker/Dockerfile +++ b/apps/meteor/.docker/Dockerfile @@ -1,4 +1,4 @@ -FROM node:14.19.3-bullseye-slim +FROM node:14.21.1-bullseye-slim LABEL maintainer="buildmaster@rocket.chat" diff --git a/apps/meteor/.docker/Dockerfile.alpine b/apps/meteor/.docker/Dockerfile.alpine index 99aa4c2eb016..8b15269d1f54 100644 --- a/apps/meteor/.docker/Dockerfile.alpine +++ b/apps/meteor/.docker/Dockerfile.alpine @@ -1,4 +1,4 @@ -FROM node:14.19.3-alpine3.15 +FROM node:14.21.1-alpine3.15 RUN apk add --no-cache ttf-dejavu diff --git a/apps/meteor/ee/server/services/Dockerfile b/apps/meteor/ee/server/services/Dockerfile index 62641d57abe8..c62d42e98105 100644 --- a/apps/meteor/ee/server/services/Dockerfile +++ b/apps/meteor/ee/server/services/Dockerfile @@ -1,4 +1,4 @@ -FROM node:14.19.3 as build +FROM node:14.21.1 as build WORKDIR /app @@ -26,7 +26,7 @@ COPY ./tsconfig.base.json . RUN yarn workspace @rocket.chat/core-typings run build \ && yarn workspace @rocket.chat/rest-typings run build -FROM node:14.19.3-alpine +FROM node:14.21.1-alpine ARG SERVICE diff --git a/ee/apps/account-service/Dockerfile b/ee/apps/account-service/Dockerfile index c27bf31f9e58..7d67b9466f3c 100644 --- a/ee/apps/account-service/Dockerfile +++ b/ee/apps/account-service/Dockerfile @@ -1,4 +1,4 @@ -FROM node:14.19.3-alpine +FROM node:14.21.1-alpine ARG SERVICE diff --git a/ee/apps/authorization-service/Dockerfile b/ee/apps/authorization-service/Dockerfile index c27bf31f9e58..7d67b9466f3c 100644 --- a/ee/apps/authorization-service/Dockerfile +++ b/ee/apps/authorization-service/Dockerfile @@ -1,4 +1,4 @@ -FROM node:14.19.3-alpine +FROM node:14.21.1-alpine ARG SERVICE diff --git a/ee/apps/ddp-streamer/Dockerfile b/ee/apps/ddp-streamer/Dockerfile index c27bf31f9e58..7d67b9466f3c 100644 --- a/ee/apps/ddp-streamer/Dockerfile +++ b/ee/apps/ddp-streamer/Dockerfile @@ -1,4 +1,4 @@ -FROM node:14.19.3-alpine +FROM node:14.21.1-alpine ARG SERVICE diff --git a/ee/apps/presence-service/Dockerfile b/ee/apps/presence-service/Dockerfile index b1e116ee833c..a795327827c5 100644 --- a/ee/apps/presence-service/Dockerfile +++ b/ee/apps/presence-service/Dockerfile @@ -1,4 +1,4 @@ -FROM node:14.19.3-alpine +FROM node:14.21.1-alpine ARG SERVICE diff --git a/ee/apps/stream-hub-service/Dockerfile b/ee/apps/stream-hub-service/Dockerfile index c27bf31f9e58..7d67b9466f3c 100644 --- a/ee/apps/stream-hub-service/Dockerfile +++ b/ee/apps/stream-hub-service/Dockerfile @@ -1,4 +1,4 @@ -FROM node:14.19.3-alpine +FROM node:14.21.1-alpine ARG SERVICE diff --git a/package.json b/package.json index e704c18ba850..88375710fc9f 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "homepage": "https://github.com/RocketChat/Rocket.Chat#readme", "engines": { "yarn": "3.2.2", - "node": "14.19.3", + "node": "14.21.1", "npm": "Use yarn instead" }, "packageManager": "yarn@3.2.2", @@ -55,7 +55,7 @@ ] }, "volta": { - "node": "14.19.3", + "node": "14.21.1", "yarn": "1.22.18" }, "resolutions": { diff --git a/yarn.lock b/yarn.lock index dcb6a8c599f5..2160229b696c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -24040,7 +24040,7 @@ __metadata: optional: true bin: lessc: ./bin/lessc - checksum: 61568b56b5289fdcfe3d51baf3c13e7db7140022c0a37ef0ae343169f0de927a4b4f4272bc10c20101796e8ee79e934e024051321bba93b3ae071f734309bd98 + checksum: c9b8c0e865427112c48a9cac36f14964e130577743c29d56a6d93b5812b70846b04ccaa364acf1e8d75cee3855215ec0a2d8d9de569c80e774f10b6245f39b7d languageName: node linkType: hard From 1fe62cd01816c392a75d04d9df4c7e00d5dd314f Mon Sep 17 00:00:00 2001 From: Diego Sampaio Date: Mon, 26 Dec 2022 12:50:15 -0300 Subject: [PATCH 03/18] Update TypeScript to 4.6.4 --- _templates/package/new/package.json.ejs.t | 2 +- _templates/service/new/package.json.ejs.t | 2 +- apps/meteor/ee/server/services/package.json | 2 +- apps/meteor/package.json | 4 +- ee/apps/account-service/package.json | 2 +- ee/apps/authorization-service/package.json | 2 +- ee/apps/ddp-streamer/package.json | 2 +- ee/apps/presence-service/package.json | 2 +- ee/apps/stream-hub-service/package.json | 2 +- ee/packages/ui-theming/package.json | 2 +- packages/agenda/package.json | 2 +- packages/api-client/package.json | 2 +- packages/cas-validate/package.json | 2 +- packages/core-typings/package.json | 2 +- packages/favicon/package.json | 2 +- packages/gazzodown/package.json | 2 +- packages/livechat/package.json | 2 +- packages/model-typings/package.json | 2 +- packages/models/package.json | 2 +- packages/node-poplib/package.json | 2 +- packages/presence/package.json | 2 +- packages/rest-typings/package.json | 2 +- packages/ui-client/package.json | 2 +- packages/ui-composer/package.json | 2 +- packages/ui-contexts/package.json | 2 +- packages/ui-video-conf/package.json | 2 +- yarn.lock | 83 ++++++++++++++------- 27 files changed, 85 insertions(+), 52 deletions(-) diff --git a/_templates/package/new/package.json.ejs.t b/_templates/package/new/package.json.ejs.t index 44fe58fea9b4..da6f3d189bd5 100644 --- a/_templates/package/new/package.json.ejs.t +++ b/_templates/package/new/package.json.ejs.t @@ -11,7 +11,7 @@ to: packages/<%= name %>/package.json "eslint": "^8.12.0", "jest": "^27.5.1", "ts-jest": "^27.1.4", - "typescript": "~4.5.5" + "typescript": "~4.6.4" }, "scripts": { "lint": "eslint --ext .js,.jsx,.ts,.tsx .", diff --git a/_templates/service/new/package.json.ejs.t b/_templates/service/new/package.json.ejs.t index 0b83e0d9b59b..f443dba2ab16 100644 --- a/_templates/service/new/package.json.ejs.t +++ b/_templates/service/new/package.json.ejs.t @@ -41,7 +41,7 @@ to: ee/apps/<%= name %>/package.json "@types/polka": "^0.5.4", "eslint": "^8.29.0", "ts-node": "^10.9.1", - "typescript": "~4.5.5" + "typescript": "~4.6.4" }, "main": "./dist/ee/apps/<%= name %>/src/service.js", "files": [ diff --git a/apps/meteor/ee/server/services/package.json b/apps/meteor/ee/server/services/package.json index d8322b12eb1b..e350651ffbf6 100644 --- a/apps/meteor/ee/server/services/package.json +++ b/apps/meteor/ee/server/services/package.json @@ -62,7 +62,7 @@ "pino-pretty": "^7.6.1", "pm2": "^5.2.0", "ts-node": "^10.9.1", - "typescript": "~4.5.5" + "typescript": "4.6.4" }, "volta": { "extends": "../../../package.json" diff --git a/apps/meteor/package.json b/apps/meteor/package.json index 9b2c61344b6b..58fa1334d38f 100644 --- a/apps/meteor/package.json +++ b/apps/meteor/package.json @@ -117,7 +117,7 @@ "@types/lodash.get": "^4.4.7", "@types/mailparser": "^3.4.0", "@types/marked": "^4.0.3", - "@types/meteor": "2.7.1", + "@types/meteor": "2.8.1", "@types/mkdirp": "^1.0.2", "@types/mocha": "^8.2.3", "@types/moment-timezone": "^0.5.30", @@ -191,7 +191,7 @@ "supertest": "^6.2.3", "template-file": "^6.0.1", "ts-node": "^10.9.1", - "typescript": "~4.5.5", + "typescript": "4.6.4", "webpack": "^4.46.0" }, "dependencies": { diff --git a/ee/apps/account-service/package.json b/ee/apps/account-service/package.json index afbaa4d3e618..0a735d351ae3 100644 --- a/ee/apps/account-service/package.json +++ b/ee/apps/account-service/package.json @@ -41,7 +41,7 @@ "@types/polka": "^0.5.4", "eslint": "^8.29.0", "ts-node": "^10.9.1", - "typescript": "~4.5.5" + "typescript": "4.6.4" }, "main": "./dist/ee/apps/account-service/src/service.js", "files": [ diff --git a/ee/apps/authorization-service/package.json b/ee/apps/authorization-service/package.json index aa084d9a5b47..fe718fb60403 100644 --- a/ee/apps/authorization-service/package.json +++ b/ee/apps/authorization-service/package.json @@ -38,7 +38,7 @@ "@types/polka": "^0.5.4", "eslint": "^8.29.0", "ts-node": "^10.9.1", - "typescript": "~4.5.5" + "typescript": "4.6.4" }, "main": "./dist/ee/apps/authorization-service/src/service.js", "files": [ diff --git a/ee/apps/ddp-streamer/package.json b/ee/apps/ddp-streamer/package.json index 56daab2e2cd8..78cd78d7d128 100644 --- a/ee/apps/ddp-streamer/package.json +++ b/ee/apps/ddp-streamer/package.json @@ -50,7 +50,7 @@ "eslint": "^8.29.0", "pino-pretty": "^7.6.1", "ts-node": "^10.9.1", - "typescript": "~4.5.5" + "typescript": "4.6.4" }, "main": "./dist/service.js", "files": [ diff --git a/ee/apps/presence-service/package.json b/ee/apps/presence-service/package.json index bb8a0db6f6bb..e9eeb4c07d78 100644 --- a/ee/apps/presence-service/package.json +++ b/ee/apps/presence-service/package.json @@ -37,7 +37,7 @@ "@types/polka": "^0.5.4", "eslint": "^8.29.0", "ts-node": "^10.9.1", - "typescript": "~4.5.5" + "typescript": "4.6.4" }, "main": "./dist/presence/src/Presence.js", "files": [ diff --git a/ee/apps/stream-hub-service/package.json b/ee/apps/stream-hub-service/package.json index 492d4b069475..71d88e43b75d 100644 --- a/ee/apps/stream-hub-service/package.json +++ b/ee/apps/stream-hub-service/package.json @@ -39,7 +39,7 @@ "@types/polka": "^0.5.4", "eslint": "^8.29.0", "ts-node": "^10.9.1", - "typescript": "~4.5.5" + "typescript": "4.6.4" }, "main": "./dist/ee/apps/stream-hub-service/src/service.js", "files": [ diff --git a/ee/packages/ui-theming/package.json b/ee/packages/ui-theming/package.json index 02fc58a72aec..962ccfec4855 100644 --- a/ee/packages/ui-theming/package.json +++ b/ee/packages/ui-theming/package.json @@ -36,7 +36,7 @@ "postcss-url": "~10.1.3", "react": "~17.0.2", "ts-jest": "^27.1.4", - "typescript": "~4.5.5" + "typescript": "4.6.4" }, "scripts": { "lint": "eslint --ext .js,.jsx,.ts,.tsx .", diff --git a/packages/agenda/package.json b/packages/agenda/package.json index c945d4332add..1350957914e4 100644 --- a/packages/agenda/package.json +++ b/packages/agenda/package.json @@ -17,7 +17,7 @@ "eslint": "^8.29.0", "jest": "^27.5.1", "ts-jest": "^27.1.4", - "typescript": "~4.5.5" + "typescript": "4.6.4" }, "scripts": { "lint": "eslint --ext .js,.jsx,.ts,.tsx .", diff --git a/packages/api-client/package.json b/packages/api-client/package.json index cf25c7c6ff68..a39db6fbaeb3 100644 --- a/packages/api-client/package.json +++ b/packages/api-client/package.json @@ -8,7 +8,7 @@ "eslint": "^8.29.0", "jest": "^27.5.1", "ts-jest": "^27.1.5", - "typescript": "~4.5.5" + "typescript": "4.6.4" }, "scripts": { "lint": "eslint --ext .js,.jsx,.ts,.tsx .", diff --git a/packages/cas-validate/package.json b/packages/cas-validate/package.json index be852b3f2aff..026adc1f7cd7 100644 --- a/packages/cas-validate/package.json +++ b/packages/cas-validate/package.json @@ -8,7 +8,7 @@ "eslint": "^8.29.0", "jest": "^27.5.1", "ts-jest": "^27.1.4", - "typescript": "~4.5.5" + "typescript": "4.6.4" }, "scripts": { "lint": "eslint --ext .js,.jsx,.ts,.tsx .", diff --git a/packages/core-typings/package.json b/packages/core-typings/package.json index 67d5bcaa70d9..3daeeb254e04 100644 --- a/packages/core-typings/package.json +++ b/packages/core-typings/package.json @@ -7,7 +7,7 @@ "eslint": "^8.29.0", "mongodb": "^4.12.1", "prettier": "^2.7.1", - "typescript": "~4.5.5" + "typescript": "4.6.4" }, "scripts": { "lint": "eslint --ext .js,.jsx,.ts,.tsx .", diff --git a/packages/favicon/package.json b/packages/favicon/package.json index e828133f96bb..0079c98a45e7 100644 --- a/packages/favicon/package.json +++ b/packages/favicon/package.json @@ -4,7 +4,7 @@ "private": true, "devDependencies": { "eslint": "^8.29.0", - "typescript": "~4.5.5" + "typescript": "4.6.4" }, "scripts": { "lint": "eslint --ext .js,.jsx,.ts,.tsx .", diff --git a/packages/gazzodown/package.json b/packages/gazzodown/package.json index 1d37518345e6..ac58107dfba8 100644 --- a/packages/gazzodown/package.json +++ b/packages/gazzodown/package.json @@ -43,7 +43,7 @@ "outdent": "^0.8.0", "react-dom": "~17.0.2", "ts-jest": "^27.1.4", - "typescript": "~4.5.5" + "typescript": "4.6.4" }, "scripts": { "lint": "eslint --ext .js,.jsx,.ts,.tsx .", diff --git a/packages/livechat/package.json b/packages/livechat/package.json index 0f616ee48796..93112d12675b 100644 --- a/packages/livechat/package.json +++ b/packages/livechat/package.json @@ -76,7 +76,7 @@ "stylelint": "^14.9.1", "stylelint-order": "^5.0.0", "svg-loader": "^0.0.2", - "typescript": "~4.5.5", + "typescript": "4.6.4", "url-loader": "^4.1.1", "webpack": "^4.44.1", "webpack-cli": "^3.3.12", diff --git a/packages/model-typings/package.json b/packages/model-typings/package.json index 10ac962e478d..35a5476d6dea 100644 --- a/packages/model-typings/package.json +++ b/packages/model-typings/package.json @@ -9,7 +9,7 @@ "jest": "^27.5.1", "mongodb": "^4.12.1", "ts-jest": "^27.1.5", - "typescript": "~4.5.5" + "typescript": "4.6.4" }, "scripts": { "lint": "eslint --ext .js,.jsx,.ts,.tsx .", diff --git a/packages/models/package.json b/packages/models/package.json index 086e87b22b20..27dedb794949 100644 --- a/packages/models/package.json +++ b/packages/models/package.json @@ -7,7 +7,7 @@ "eslint": "^8.29.0", "jest": "^27.5.1", "ts-jest": "^27.1.5", - "typescript": "~4.5.5" + "typescript": "4.6.4" }, "dependencies": { "@rocket.chat/model-typings": "workspace:^" diff --git a/packages/node-poplib/package.json b/packages/node-poplib/package.json index 916ebb92a85e..eaefd248a248 100644 --- a/packages/node-poplib/package.json +++ b/packages/node-poplib/package.json @@ -7,7 +7,7 @@ "eslint": "^8.29.0", "jest": "^27.5.1", "ts-jest": "^27.1.4", - "typescript": "~4.5.5" + "typescript": "4.6.4" }, "scripts": { "jest": "jest" diff --git a/packages/presence/package.json b/packages/presence/package.json index be2fd4e7f862..19253a91815c 100644 --- a/packages/presence/package.json +++ b/packages/presence/package.json @@ -13,7 +13,7 @@ "babel-jest": "^29.0.3", "eslint": "^8.29.0", "jest": "^29.0.3", - "typescript": "~4.5.5" + "typescript": "4.6.4" }, "scripts": { "lint": "eslint src", diff --git a/packages/rest-typings/package.json b/packages/rest-typings/package.json index f9f7f2e9fccd..8a8b3d5138bc 100644 --- a/packages/rest-typings/package.json +++ b/packages/rest-typings/package.json @@ -9,7 +9,7 @@ "jest": "^27.5.1", "mongodb": "^4.12.1", "ts-jest": "^27.1.5", - "typescript": "~4.5.5" + "typescript": "4.6.4" }, "scripts": { "lint": "eslint --ext .js,.jsx,.ts,.tsx .", diff --git a/packages/ui-client/package.json b/packages/ui-client/package.json index 37a3743886c6..7b83e26839c0 100644 --- a/packages/ui-client/package.json +++ b/packages/ui-client/package.json @@ -39,7 +39,7 @@ "postcss-url": "~10.1.3", "react": "~17.0.2", "ts-jest": "^27.1.4", - "typescript": "~4.5.5" + "typescript": "4.6.4" }, "scripts": { "lint": "eslint --ext .js,.jsx,.ts,.tsx .", diff --git a/packages/ui-composer/package.json b/packages/ui-composer/package.json index 252159a1040c..dca6a35d1cf8 100644 --- a/packages/ui-composer/package.json +++ b/packages/ui-composer/package.json @@ -22,7 +22,7 @@ "eslint-plugin-storybook": "^0.6.7", "jest": "^27.5.1", "ts-jest": "^27.1.4", - "typescript": "~4.5.5" + "typescript": "4.6.4" }, "peerDependencies": { "@rocket.chat/fuselage": "*", diff --git a/packages/ui-contexts/package.json b/packages/ui-contexts/package.json index d94f6cd0ed80..370257bccc8e 100644 --- a/packages/ui-contexts/package.json +++ b/packages/ui-contexts/package.json @@ -16,7 +16,7 @@ "mongodb": "^4.12.1", "react": "~17.0.2", "ts-jest": "^27.1.5", - "typescript": "~4.5.5", + "typescript": "4.6.4", "use-sync-external-store": "^1.2.0" }, "peerDependencies": { diff --git a/packages/ui-video-conf/package.json b/packages/ui-video-conf/package.json index 4269004e2fbf..521639633f53 100644 --- a/packages/ui-video-conf/package.json +++ b/packages/ui-video-conf/package.json @@ -26,7 +26,7 @@ "eslint-plugin-storybook": "^0.6.7", "jest": "^27.5.1", "ts-jest": "^27.1.4", - "typescript": "~4.5.5" + "typescript": "4.6.4" }, "peerDependencies": { "@rocket.chat/css-in-js": "*", diff --git a/yarn.lock b/yarn.lock index 2160229b696c..ff25eba21fb3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6186,7 +6186,7 @@ __metadata: pino: ^8.4.2 polka: ^0.5.2 ts-node: ^10.9.1 - typescript: ~4.5.5 + typescript: 4.6.4 uuid: ^9.0.0 languageName: unknown linkType: soft @@ -6206,7 +6206,7 @@ __metadata: moment-timezone: ~0.5.27 mongodb: ^4.12.1 ts-jest: ^27.1.4 - typescript: ~4.5.5 + typescript: 4.6.4 languageName: unknown linkType: soft @@ -6225,7 +6225,7 @@ __metadata: split-on-first: ^3.0.0 strict-uri-encode: ^2.0.0 ts-jest: ^27.1.5 - typescript: ~4.5.5 + typescript: 4.6.4 languageName: unknown linkType: soft @@ -6283,7 +6283,7 @@ __metadata: pino: ^8.4.2 polka: ^0.5.2 ts-node: ^10.9.1 - typescript: ~4.5.5 + typescript: 4.6.4 languageName: unknown linkType: soft @@ -6296,7 +6296,7 @@ __metadata: eslint: ^8.29.0 jest: ^27.5.1 ts-jest: ^27.1.4 - typescript: ~4.5.5 + typescript: 4.6.4 languageName: unknown linkType: soft @@ -6312,7 +6312,7 @@ __metadata: eslint: ^8.29.0 mongodb: ^4.12.1 prettier: ^2.7.1 - typescript: ~4.5.5 + typescript: 4.6.4 languageName: unknown linkType: soft @@ -6372,7 +6372,7 @@ __metadata: polka: ^0.5.2 sharp: ^0.30.7 ts-node: ^10.9.1 - typescript: ~4.5.5 + typescript: 4.6.4 underscore: ^1.13.4 uuid: ^7.0.3 ws: ^8.8.1 @@ -6409,7 +6409,7 @@ __metadata: resolution: "@rocket.chat/favicon@workspace:packages/favicon" dependencies: eslint: ^8.29.0 - typescript: ~4.5.5 + typescript: 4.6.4 languageName: unknown linkType: soft @@ -6645,7 +6645,7 @@ __metadata: react-dom: ~17.0.2 react-error-boundary: ^3.1.4 ts-jest: ^27.1.4 - typescript: ~4.5.5 + typescript: 4.6.4 peerDependencies: "@rocket.chat/core-typings": "*" "@rocket.chat/css-in-js": "*" @@ -6750,7 +6750,7 @@ __metadata: stylelint: ^14.9.1 stylelint-order: ^5.0.0 svg-loader: ^0.0.2 - typescript: ~4.5.5 + typescript: 4.6.4 url-loader: ^4.1.1 webpack: ^4.44.1 webpack-cli: ^3.3.12 @@ -6903,7 +6903,7 @@ __metadata: "@types/lodash.get": ^4.4.7 "@types/mailparser": ^3.4.0 "@types/marked": ^4.0.3 - "@types/meteor": 2.7.1 + "@types/meteor": 2.8.1 "@types/mkdirp": ^1.0.2 "@types/mocha": ^8.2.3 "@types/moment-timezone": ^0.5.30 @@ -7109,7 +7109,7 @@ __metadata: turndown: ^7.1.1 twilio: ^3.76.1 twit: ^2.2.11 - typescript: ~4.5.5 + typescript: 4.6.4 ua-parser-js: ^1.0.2 underscore: ^1.13.4 underscore.string: ^3.3.6 @@ -7139,7 +7139,7 @@ __metadata: jest: ^27.5.1 mongodb: ^4.12.1 ts-jest: ^27.1.5 - typescript: ~4.5.5 + typescript: 4.6.4 languageName: unknown linkType: soft @@ -7152,7 +7152,7 @@ __metadata: eslint: ^8.29.0 jest: ^27.5.1 ts-jest: ^27.1.5 - typescript: ~4.5.5 + typescript: 4.6.4 languageName: unknown linkType: soft @@ -7195,7 +7195,7 @@ __metadata: eslint: ^8.29.0 jest: ^27.5.1 ts-jest: ^27.1.4 - typescript: ~4.5.5 + typescript: 4.6.4 languageName: unknown linkType: soft @@ -7223,7 +7223,7 @@ __metadata: pino: ^8.4.2 polka: ^0.5.2 ts-node: ^10.9.1 - typescript: ~4.5.5 + typescript: 4.6.4 languageName: unknown linkType: soft @@ -7244,7 +7244,7 @@ __metadata: eslint: ^8.29.0 jest: ^29.0.3 mongodb: ^4.12.1 - typescript: ~4.5.5 + typescript: 4.6.4 languageName: unknown linkType: soft @@ -7272,7 +7272,7 @@ __metadata: jest: ^27.5.1 mongodb: ^4.12.1 ts-jest: ^27.1.5 - typescript: ~4.5.5 + typescript: 4.6.4 languageName: unknown linkType: soft @@ -7315,7 +7315,7 @@ __metadata: pino: ^8.4.2 polka: ^0.5.2 ts-node: ^10.9.1 - typescript: ~4.5.5 + typescript: 4.6.4 languageName: unknown linkType: soft @@ -7390,7 +7390,7 @@ __metadata: postcss-url: ~10.1.3 react: ~17.0.2 ts-jest: ^27.1.4 - typescript: ~4.5.5 + typescript: 4.6.4 peerDependencies: "@rocket.chat/css-in-js": "*" "@rocket.chat/fuselage": "*" @@ -7424,7 +7424,7 @@ __metadata: eslint-plugin-storybook: ^0.6.7 jest: ^27.5.1 ts-jest: ^27.1.4 - typescript: ~4.5.5 + typescript: 4.6.4 peerDependencies: "@rocket.chat/fuselage": "*" "@rocket.chat/icons": "*" @@ -7450,7 +7450,7 @@ __metadata: mongodb: ^4.12.1 react: ~17.0.2 ts-jest: ^27.1.5 - typescript: ~4.5.5 + typescript: 4.6.4 use-sync-external-store: ^1.2.0 peerDependencies: "@rocket.chat/core-typings": "workspace:^" @@ -7506,7 +7506,7 @@ __metadata: postcss-url: ~10.1.3 react: ~17.0.2 ts-jest: ^27.1.4 - typescript: ~4.5.5 + typescript: 4.6.4 peerDependencies: "@rocket.chat/css-in-js": "*" "@rocket.chat/fuselage": "*" @@ -7544,7 +7544,7 @@ __metadata: eslint-plugin-storybook: ^0.6.7 jest: ^27.5.1 ts-jest: ^27.1.4 - typescript: ~4.5.5 + typescript: 4.6.4 peerDependencies: "@rocket.chat/css-in-js": "*" "@rocket.chat/fuselage": "*" @@ -9858,6 +9858,19 @@ __metadata: languageName: node linkType: hard +"@types/meteor@npm:2.8.1": + version: 2.8.1 + resolution: "@types/meteor@npm:2.8.1" + dependencies: + "@types/connect": "*" + "@types/jquery": "*" + "@types/react": "*" + "@types/underscore": "*" + mongodb: ^4.3.1 + checksum: 00d29816a05db7dac92f27e22ced92f4db36b56a5778479f3c3aa4b00165944536ce1c37600f9b61c497dc85a77a91e1244f1ed346daea383af1c54f86013d72 + languageName: node + linkType: hard + "@types/mime@npm:^1": version: 1.3.2 resolution: "@types/mime@npm:1.3.2" @@ -31421,7 +31434,7 @@ __metadata: sodium-native: ^3.3.0 sodium-plus: ^0.9.0 ts-node: ^10.9.1 - typescript: ~4.5.5 + typescript: 4.6.4 underscore.string: ^3.3.6 uuid: ^8.3.2 ws: ^8.8.1 @@ -34821,6 +34834,16 @@ __metadata: languageName: node linkType: hard +"typescript@npm:4.6.4": + version: 4.6.4 + resolution: "typescript@npm:4.6.4" + bin: + tsc: bin/tsc + tsserver: bin/tsserver + checksum: e7bfcc39cd4571a63a54e5ea21f16b8445268b9900bf55aee0e02ad981be576acc140eba24f1af5e3c1457767c96cea6d12861768fb386cf3ffb34013718631a + languageName: node + linkType: hard + "typescript@npm:~4.3.5": version: 4.3.5 resolution: "typescript@npm:4.3.5" @@ -34841,6 +34864,16 @@ __metadata: languageName: node linkType: hard +"typescript@patch:typescript@4.6.4#~builtin": + version: 4.6.4 + resolution: "typescript@patch:typescript@npm%3A4.6.4#~builtin::version=4.6.4&hash=f456af" + bin: + tsc: bin/tsc + tsserver: bin/tsserver + checksum: 1cb434fbc637d347be90e3a0c6cd05e33c38f941713c8786d3031faf1842c2c148ba91d2fac01e7276b0ae3249b8633f1660e32686cc7a8c6a8fd5361dc52c66 + languageName: node + linkType: hard + "typescript@patch:typescript@~4.3.5#~builtin": version: 4.3.5 resolution: "typescript@patch:typescript@npm%3A4.3.5#~builtin::version=4.3.5&hash=f456af" From 4dc917360fa6e316c0ee7bc73f6eb852e567d1b8 Mon Sep 17 00:00:00 2001 From: Diego Sampaio Date: Mon, 26 Dec 2022 12:50:34 -0300 Subject: [PATCH 04/18] Use Meteor.callAsync on `useMethod` hook --- apps/meteor/client/providers/ServerProvider.tsx | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/apps/meteor/client/providers/ServerProvider.tsx b/apps/meteor/client/providers/ServerProvider.tsx index 068e9f78c43d..5916ff11b2fd 100644 --- a/apps/meteor/client/providers/ServerProvider.tsx +++ b/apps/meteor/client/providers/ServerProvider.tsx @@ -13,17 +13,7 @@ const absoluteUrl = (path: string): string => Meteor.absoluteUrl(path); const callMethod = ( methodName: MethodName, ...args: ServerMethodParameters -): Promise> => - new Promise((resolve, reject) => { - Meteor.call(methodName, ...args, (error: Error, result: ServerMethodReturn) => { - if (error) { - reject(error); - return; - } - - resolve(result); - }); - }); +): Promise> => Meteor.callAsync(methodName, ...args); const callEndpoint = >( method: TMethod, From e6fdc2cdb9e8f7b6669258656980a78ebbd99dce Mon Sep 17 00:00:00 2001 From: Diego Sampaio Date: Mon, 26 Dec 2022 12:51:41 -0300 Subject: [PATCH 05/18] Use `CssTools.minifyCssAsync` --- apps/meteor/packages/rocketchat-postcss/build.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/meteor/packages/rocketchat-postcss/build.js b/apps/meteor/packages/rocketchat-postcss/build.js index a9ad4c9527dd..125fe76be61f 100644 --- a/apps/meteor/packages/rocketchat-postcss/build.js +++ b/apps/meteor/packages/rocketchat-postcss/build.js @@ -168,7 +168,7 @@ const processFilesForBundle = async (files = [], { minifyMode }) => { return; } - const minifiedFiles = CssTools.minifyCss(code); + const minifiedFiles = await CssTools.minifyCssAsync(code); minifiedFiles.forEach((data) => { files[0].addStylesheet({ data }); From b0bd65d56be59ca2f80f39ef44aa963afaf746c4 Mon Sep 17 00:00:00 2001 From: Diego Sampaio Date: Mon, 26 Dec 2022 12:58:21 -0300 Subject: [PATCH 06/18] wait for rocket.chat first --- .github/workflows/build_and_test.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 242160054cdd..36da8a1358d1 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -521,18 +521,18 @@ jobs: run: | docker ps - until echo "$(docker compose -f docker-compose-ci.yml logs ddp-streamer-service)" | grep -q "NetworkBroker started successfully"; do - echo "Waiting 'ddp-streamer' to start up" - ((c++)) && ((c==10)) && docker compose -f docker-compose-ci.yml logs ddp-streamer-service && exit 1 - sleep 10 - done; - until echo "$(docker compose -f docker-compose-ci.yml logs rocketchat)" | grep -q "SERVER RUNNING"; do echo "Waiting Rocket.Chat to start up" ((c++)) && ((c==10)) && docker compose -f docker-compose-ci.yml logs rocketchat && exit 1 sleep 10 done; + until echo "$(docker compose -f docker-compose-ci.yml logs ddp-streamer-service)" | grep -q "NetworkBroker started successfully"; do + echo "Waiting 'ddp-streamer' to start up" + ((c++)) && ((c==10)) && docker compose -f docker-compose-ci.yml logs ddp-streamer-service && exit 1 + sleep 10 + done; + - name: E2E Test API env: LOWERCASE_REPOSITORY: ${{ steps.docker-env.outputs.lowercase-repo }} From 132891067c46a9e40004be487ca7de80b5360e22 Mon Sep 17 00:00:00 2001 From: Tasso Evangelista Date: Fri, 30 Dec 2022 17:20:43 -0300 Subject: [PATCH 07/18] Change `useEndpoint` signature --- .../CreateDiscussion/CreateDiscussion.tsx | 4 +- .../DefaultParentRoomField.tsx | 7 ++- .../Omnichannel/modals/CloseChatModalData.tsx | 2 +- .../RoomAutoComplete/RoomAutoComplete.tsx | 5 +- .../UserAutoComplete/UserAutoComplete.tsx | 2 +- .../UserAutoCompleteMultiple.tsx | 5 +- apps/meteor/client/hooks/useEndpointAction.ts | 54 +++++++++++-------- .../hooks/useEndpointActionExperimental.ts | 33 ------------ apps/meteor/client/hooks/useEndpointData.ts | 28 +++++----- apps/meteor/client/hooks/useUpdateAvatar.ts | 39 ++++++-------- .../client/providers/ServerProvider.tsx | 29 ++++++---- .../sidebar/header/CreateDirectMessage.tsx | 4 +- .../stories/contexts/ServerContextMock.tsx | 53 +++++++++--------- .../views/account/security/TwoFactorEmail.tsx | 8 ++- .../tabs/AppReleases/AppReleases.tsx | 2 +- .../views/admin/apps/hooks/useAppInfo.ts | 10 ++-- .../client/views/admin/apps/hooks/useLogs.ts | 4 +- .../views/admin/customEmoji/CustomEmoji.tsx | 2 +- .../admin/customEmoji/EditCustomEmoji.tsx | 10 ++-- .../customEmoji/EditCustomEmojiWithData.tsx | 2 +- .../admin/customSounds/AdminSoundsRoute.tsx | 2 +- .../admin/customSounds/EditCustomSound.tsx | 2 +- .../CustomUserStatusFormWithData.tsx | 2 +- .../CustomUserStatusTable.tsx | 2 +- .../views/admin/emailInbox/EmailInboxForm.tsx | 2 +- .../emailInbox/EmailInboxFormWithData.tsx | 4 +- .../views/admin/emailInbox/SendTestButton.tsx | 2 +- .../integrations/edit/EditIncomingWebhook.js | 7 ++- .../integrations/edit/EditOutgoingWebhook.js | 7 ++- .../integrations/new/NewIncomingWebhook.js | 7 ++- .../integrations/new/NewOutgoingWebhook.js | 16 +++--- .../client/views/admin/invites/InviteRow.tsx | 2 +- .../admin/oauthApps/EditOauthAppWithData.tsx | 2 +- .../UsersInRoleTableWithData.tsx | 2 +- .../client/views/admin/rooms/EditRoom.tsx | 8 +-- .../views/admin/rooms/EditRoomWithData.tsx | 5 +- .../client/views/admin/rooms/RoomsTable.tsx | 2 +- .../settings/groups/voip/AssignAgentModal.tsx | 2 +- .../groups/voip/RemoveAgentButton.tsx | 2 +- .../groups/voip/VoipExtensionsPage.tsx | 2 +- .../settings/inputs/LookupSettingInput.tsx | 4 +- .../client/views/admin/users/AddUser.js | 12 ++--- .../admin/users/AdminUserInfoWithData.tsx | 5 +- .../client/views/admin/users/EditUser.js | 43 +++++---------- .../views/admin/users/EditUserWithData.tsx | 9 +--- .../admin/users/UsersTable/UsersTable.tsx | 2 +- .../views/hooks/useDepartmentsByUnitsList.ts | 2 +- .../views/omnichannel/agents/AddAgent.tsx | 4 +- .../omnichannel/agents/AgentEditWithData.tsx | 4 +- .../views/omnichannel/agents/AgentInfo.tsx | 2 +- .../omnichannel/agents/AgentInfoActions.tsx | 4 +- .../views/omnichannel/agents/AgentsPage.tsx | 2 +- .../omnichannel/agents/RemoveAgentButton.tsx | 2 +- .../MessageList/useHistoryMessageList.ts | 2 +- .../contactHistory/useHistoryList.ts | 11 +++- .../views/omnichannel/departments/AddAgent.js | 2 +- .../departments/RemoveDepartmentButton.js | 2 +- .../directory/CallsContextualBarDirectory.tsx | 2 +- .../directory/ChatsContextualBar.tsx | 2 +- .../omnichannel/directory/calls/CallTable.tsx | 2 +- .../directory/contacts/ContactTable.tsx | 2 +- .../views/omnichannel/managers/AddManager.tsx | 4 +- .../omnichannel/managers/ManagersRoute.tsx | 2 +- .../managers/RemoveManagerButton.tsx | 2 +- .../views/omnichannel/queueList/index.tsx | 2 +- .../client/views/room/Header/ParentTeam.tsx | 12 ++--- .../views/room/UserCard/UserCardWithData.tsx | 2 +- .../AutoTranslate/AutoTranslateWithData.tsx | 11 ++-- .../Info/EditRoomInfo/EditChannel.js | 8 +-- .../Info/RoomInfo/RoomInfoWithData.js | 12 ++--- .../NotificationPreferencesWithData.tsx | 6 ++- .../UserInfo/UserInfoWithData.tsx | 5 +- .../VideoConfPopup/IncomingPopup.tsx | 2 +- .../actions/useChangeLeaderAction.ts | 10 ++-- .../actions/useChangeModeratorAction.ts | 10 ++-- .../actions/useChangeOwnerAction.tsx | 10 ++-- .../actions/useRemoveUserAction.tsx | 10 ++-- .../ConvertToChannelModal.tsx | 7 ++- .../channels/AddExistingModal/RoomsInput.tsx | 2 +- .../contextualBar/channels/RoomActions.js | 14 +++-- .../info/Delete/DeleteTeamModalWithRooms.tsx | 5 +- .../contextualBar/info/TeamsInfoWithData.js | 8 +-- apps/meteor/ee/client/audit/AuditPageBase.js | 15 ++++-- .../ee/client/hooks/useDeviceLogout.tsx | 12 ++--- .../CannedResponseEditWithData.tsx | 2 +- .../CannedResponseEditWithDepartmentData.tsx | 2 +- .../cannedResponses/CannedResponsesRoute.tsx | 2 +- .../tags/TagEditWithDepartmentData.tsx | 7 ++- .../omnichannel/units/UnitEditWithData.tsx | 6 +-- .../DeviceManagementAccountTable.tsx | 2 +- .../DeviceManagementAdminTable.tsx | 2 +- .../DeviceManagementInfoWithData.tsx | 5 +- .../EngagementDashboardRoute.tsx | 8 +-- ee/packages/ui-theming/package.json | 3 ++ .../src/hooks/useSetLayoutSetting.ts | 4 +- .../src/ServerContext/ServerContext.ts | 13 ++--- packages/ui-contexts/src/hooks/useEndpoint.ts | 26 ++++++--- 97 files changed, 348 insertions(+), 408 deletions(-) delete mode 100644 apps/meteor/client/hooks/useEndpointActionExperimental.ts diff --git a/apps/meteor/client/components/CreateDiscussion/CreateDiscussion.tsx b/apps/meteor/client/components/CreateDiscussion/CreateDiscussion.tsx index a852133906dc..26616fe6fd36 100644 --- a/apps/meteor/client/components/CreateDiscussion/CreateDiscussion.tsx +++ b/apps/meteor/client/components/CreateDiscussion/CreateDiscussion.tsx @@ -5,7 +5,7 @@ import { useTranslation } from '@rocket.chat/ui-contexts'; import type { ReactElement } from 'react'; import React from 'react'; -import { useEndpointActionExperimental } from '../../hooks/useEndpointActionExperimental'; +import { useEndpointAction } from '../../hooks/useEndpointAction'; import { useForm } from '../../hooks/useForm'; import { goToRoomById } from '../../lib/utils/goToRoomById'; import RoomAutoComplete from '../RoomAutoComplete'; @@ -44,7 +44,7 @@ const CreateDiscussion = ({ onClose, defaultParentRoom, parentMessageId, nameSug const canCreate = (parentRoom || defaultParentRoom) && name; - const createDiscussion = useEndpointActionExperimental('POST', '/v1/rooms.createDiscussion'); + const createDiscussion = useEndpointAction('POST', '/v1/rooms.createDiscussion'); const create = useMutableCallback(async (): Promise => { try { diff --git a/apps/meteor/client/components/CreateDiscussion/DefaultParentRoomField.tsx b/apps/meteor/client/components/CreateDiscussion/DefaultParentRoomField.tsx index f8d08f95500d..88de1d35051f 100644 --- a/apps/meteor/client/components/CreateDiscussion/DefaultParentRoomField.tsx +++ b/apps/meteor/client/components/CreateDiscussion/DefaultParentRoomField.tsx @@ -9,15 +9,14 @@ import { roomCoordinator } from '../../lib/rooms/roomCoordinator'; const DefaultParentRoomField = ({ defaultParentRoom }: { defaultParentRoom: string }): ReactElement => { const t = useTranslation(); - const { value, phase } = useEndpointData( - '/v1/rooms.info', - useMemo( + const { value, phase } = useEndpointData('/v1/rooms.info', { + params: useMemo( () => ({ roomId: defaultParentRoom, }), [defaultParentRoom], ), - ); + }); if (phase === AsyncStatePhase.LOADING) { return ; diff --git a/apps/meteor/client/components/Omnichannel/modals/CloseChatModalData.tsx b/apps/meteor/client/components/Omnichannel/modals/CloseChatModalData.tsx index 40c4e21f6b16..eae95e47cd4c 100644 --- a/apps/meteor/client/components/Omnichannel/modals/CloseChatModalData.tsx +++ b/apps/meteor/client/components/Omnichannel/modals/CloseChatModalData.tsx @@ -16,7 +16,7 @@ const CloseChatModalData = ({ onCancel: () => void; onConfirm: (comment?: string, tags?: string[]) => Promise; }): ReactElement => { - const { value: data, phase: state } = useEndpointData(`/v1/livechat/department/${departmentId}`); + const { value: data, phase: state } = useEndpointData('/v1/livechat/department/:_id', { keys: { _id: departmentId } }); if ([state].includes(AsyncStatePhase.LOADING)) { return ; diff --git a/apps/meteor/client/components/RoomAutoComplete/RoomAutoComplete.tsx b/apps/meteor/client/components/RoomAutoComplete/RoomAutoComplete.tsx index e59ac01a4ab3..80286a1a2b85 100644 --- a/apps/meteor/client/components/RoomAutoComplete/RoomAutoComplete.tsx +++ b/apps/meteor/client/components/RoomAutoComplete/RoomAutoComplete.tsx @@ -20,10 +20,7 @@ type RoomAutoCompleteProps = Omit, 'value /* @deprecated */ const RoomAutoComplete = (props: RoomAutoCompleteProps): ReactElement => { const [filter, setFilter] = useState(''); - const { value: data } = useEndpointData( - '/v1/rooms.autocomplete.channelAndPrivate', - useMemo(() => query(filter), [filter]), - ); + const { value: data } = useEndpointData('/v1/rooms.autocomplete.channelAndPrivate', { params: useMemo(() => query(filter), [filter]) }); const options = useMemo( () => data?.items.map(({ name, _id, avatarETag, t }) => ({ diff --git a/apps/meteor/client/components/UserAutoComplete/UserAutoComplete.tsx b/apps/meteor/client/components/UserAutoComplete/UserAutoComplete.tsx index 55b8f74678ed..dd1cceb4699e 100644 --- a/apps/meteor/client/components/UserAutoComplete/UserAutoComplete.tsx +++ b/apps/meteor/client/components/UserAutoComplete/UserAutoComplete.tsx @@ -28,7 +28,7 @@ const UserAutoComplete = ({ value, ...props }: UserAutoCompleteProps): ReactElem const { value: data } = useEndpointData( '/v1/users.autocomplete', // eslint-disable-next-line react-hooks/exhaustive-deps - useMemo(() => query(debouncedFilter, conditions), [filter]), + { params: useMemo(() => query(debouncedFilter, conditions), [filter]) }, ); const options = useMemo(() => data?.items.map((user) => ({ value: user.username, label: user.name || user.username })) || [], [data]); diff --git a/apps/meteor/client/components/UserAutoCompleteMultiple/UserAutoCompleteMultiple.tsx b/apps/meteor/client/components/UserAutoCompleteMultiple/UserAutoCompleteMultiple.tsx index 6f5a95fd3e5f..f4112b21d536 100644 --- a/apps/meteor/client/components/UserAutoCompleteMultiple/UserAutoCompleteMultiple.tsx +++ b/apps/meteor/client/components/UserAutoCompleteMultiple/UserAutoCompleteMultiple.tsx @@ -22,10 +22,7 @@ type UserAutoCompleteMultipleProps = Omit, ' const UserAutoCompleteMultiple = ({ onChange, ...props }: UserAutoCompleteMultipleProps): ReactElement => { const [filter, setFilter] = useState(''); const debouncedFilter = useDebouncedValue(filter, 1000); - const { value: data } = useEndpointData( - '/v1/users.autocomplete', - useMemo(() => query(debouncedFilter), [debouncedFilter]), - ); + const { value: data } = useEndpointData('/v1/users.autocomplete', { params: useMemo(() => query(debouncedFilter), [debouncedFilter]) }); const options = useMemo(() => data?.items.map((user) => ({ value: user.username, label: user.name })) || [], [data]); diff --git a/apps/meteor/client/hooks/useEndpointAction.ts b/apps/meteor/client/hooks/useEndpointAction.ts index c45659214e19..7cc1a68f1020 100644 --- a/apps/meteor/client/hooks/useEndpointAction.ts +++ b/apps/meteor/client/hooks/useEndpointAction.ts @@ -1,29 +1,41 @@ -import type { Serialized } from '@rocket.chat/core-typings'; -import type { MatchPathPattern, Method, OperationParams, OperationResult, PathFor } from '@rocket.chat/rest-typings'; +import type { Method, OperationParams, PathPattern, UrlParams } from '@rocket.chat/rest-typings'; +import type { EndpointFunction } from '@rocket.chat/ui-contexts'; import { useToastMessageDispatch, useEndpoint } from '@rocket.chat/ui-contexts'; import { useCallback } from 'react'; -export const useEndpointAction = >( +type UseEndpointActionOptions = (undefined extends UrlParams + ? { + keys?: UrlParams; + } + : { + keys: UrlParams; + }) & { + successMessage?: string; +}; +export function useEndpointAction( method: TMethod, - path: TPath, - params?: OperationParams>, - successMessage?: string, -): (() => Promise>>>) => { - const sendData = useEndpoint(method, path); + pathPattern: TPathPattern, + options: UseEndpointActionOptions = { keys: {} as UrlParams }, +): EndpointFunction { + const sendData = useEndpoint(method, pathPattern, options.keys as UrlParams); + const dispatchToastMessage = useToastMessageDispatch(); - return useCallback(async () => { - try { - const data = await sendData(params as any); + return useCallback( + async (params: OperationParams | undefined) => { + try { + const data = await sendData(params as OperationParams); - if (successMessage) { - dispatchToastMessage({ type: 'success', message: successMessage }); - } + if (options.successMessage) { + dispatchToastMessage({ type: 'success', message: options.successMessage }); + } - return data; - } catch (error) { - dispatchToastMessage({ type: 'error', message: error }); - throw error; - } - }, [dispatchToastMessage, params, sendData, successMessage]); -}; + return data; + } catch (error) { + dispatchToastMessage({ type: 'error', message: error }); + throw error; + } + }, + [dispatchToastMessage, sendData, options.successMessage], + ); +} diff --git a/apps/meteor/client/hooks/useEndpointActionExperimental.ts b/apps/meteor/client/hooks/useEndpointActionExperimental.ts deleted file mode 100644 index 352d9f312d43..000000000000 --- a/apps/meteor/client/hooks/useEndpointActionExperimental.ts +++ /dev/null @@ -1,33 +0,0 @@ -import type { Serialized } from '@rocket.chat/core-typings'; -import type { MatchPathPattern, Method, OperationParams, OperationResult, PathFor } from '@rocket.chat/rest-typings'; -import { useToastMessageDispatch, useEndpoint } from '@rocket.chat/ui-contexts'; -import { useCallback } from 'react'; - -export const useEndpointActionExperimental = >( - method: TMethod, - path: TPath, - successMessage?: string, -): (( - params: OperationParams>, -) => Promise>>>) => { - const sendData = useEndpoint(method, path); - const dispatchToastMessage = useToastMessageDispatch(); - - return useCallback( - async (params) => { - try { - const data = await sendData(params); - - if (successMessage) { - dispatchToastMessage({ type: 'success', message: successMessage }); - } - - return data; - } catch (error) { - dispatchToastMessage({ type: 'error', message: error }); - throw error; - } - }, - [dispatchToastMessage, sendData, successMessage], - ); -}; diff --git a/apps/meteor/client/hooks/useEndpointData.ts b/apps/meteor/client/hooks/useEndpointData.ts index d3fe845a3c80..6e759ad587e5 100644 --- a/apps/meteor/client/hooks/useEndpointData.ts +++ b/apps/meteor/client/hooks/useEndpointData.ts @@ -1,5 +1,5 @@ import type { Serialized } from '@rocket.chat/core-typings'; -import type { MatchPathPattern, OperationParams, OperationResult, PathFor } from '@rocket.chat/rest-typings'; +import type { OperationParams, OperationResult, PathPattern, UrlParams } from '@rocket.chat/rest-typings'; import { useToastMessageDispatch, useEndpoint } from '@rocket.chat/ui-contexts'; import { useCallback, useEffect } from 'react'; @@ -18,24 +18,24 @@ const deprecationWarning = log('useEndpointData is deprecated, use @tanstack/rea * use @tanstack/react-query with useEndpoint instead * @deprecated */ - -export const useEndpointData = >( - endpoint: TPath, - params?: OperationParams<'GET', MatchPathPattern>, - initialValue?: - | Serialized>> - | (() => Serialized>>), -): AsyncState>>> & { +export const useEndpointData = ( + endpoint: TPathPattern, + options: { + keys?: UrlParams; + params?: OperationParams<'GET', TPathPattern>; + initialValue?: Serialized> | (() => Serialized>); + } = {}, +): AsyncState>> & { reload: () => void; } => { - deprecationWarning({ endpoint, params, initialValue }); - const { resolve, reject, reset, ...state } = useAsyncState(initialValue); + deprecationWarning({ endpoint, ...options }); + const { resolve, reject, reset, ...state } = useAsyncState(options.initialValue); const dispatchToastMessage = useToastMessageDispatch(); - const getData = useEndpoint('GET', endpoint); + const getData = useEndpoint('GET', endpoint, options.keys as UrlParams); const fetchData = useCallback(() => { reset(); - getData(params as any) + getData(options.params as OperationParams<'GET', TPathPattern>) .then(resolve) .catch((error) => { console.error(error); @@ -45,7 +45,7 @@ export const useEndpointData = >( }); reject(error); }); - }, [reset, getData, params, resolve, dispatchToastMessage, reject]); + }, [reset, getData, options.params, resolve, dispatchToastMessage, reject]); useEffect(() => { fetchData(); diff --git a/apps/meteor/client/hooks/useUpdateAvatar.ts b/apps/meteor/client/hooks/useUpdateAvatar.ts index 851a815d6853..556e2989804c 100644 --- a/apps/meteor/client/hooks/useUpdateAvatar.ts +++ b/apps/meteor/client/hooks/useUpdateAvatar.ts @@ -1,6 +1,6 @@ import type { AvatarObject, AvatarServiceObject, AvatarReset, AvatarUrlObj, IUser } from '@rocket.chat/core-typings'; import { useToastMessageDispatch, useMethod, useTranslation } from '@rocket.chat/ui-contexts'; -import { useMemo, useCallback } from 'react'; +import { useCallback } from 'react'; import { useEndpointAction } from './useEndpointAction'; import { useEndpointUpload } from './useEndpointUpload'; @@ -18,42 +18,32 @@ export const useUpdateAvatar = ( const t = useTranslation(); const avatarUrl = isAvatarUrl(avatarObj) ? avatarObj.avatarUrl : ''; - const successText = t('Avatar_changed_successfully'); + const successMessage = t('Avatar_changed_successfully'); const setAvatarFromService = useMethod('setAvatarFromService'); const dispatchToastMessage = useToastMessageDispatch(); - const saveAvatarQuery = useMemo( - () => ({ - userId, - ...(avatarUrl && { avatarUrl }), - }), - [avatarUrl, userId], - ); - - const resetAvatarQuery = useMemo( - () => ({ - userId, - }), - [userId], - ); - - const saveAvatarAction = useEndpointUpload('/v1/users.setAvatar', successText); - const saveAvatarUrlAction = useEndpointAction('POST', '/v1/users.setAvatar', saveAvatarQuery, successText); - const resetAvatarAction = useEndpointAction('POST', '/v1/users.resetAvatar', resetAvatarQuery, successText); + const saveAvatarAction = useEndpointUpload('/v1/users.setAvatar', successMessage); + const saveAvatarUrlAction = useEndpointAction('POST', '/v1/users.setAvatar', { successMessage }); + const resetAvatarAction = useEndpointAction('POST', '/v1/users.resetAvatar', { successMessage }); const updateAvatar = useCallback(async () => { if (isAvatarReset(avatarObj)) { - return resetAvatarAction(); + return resetAvatarAction({ + userId, + }); } if (isAvatarUrl(avatarObj)) { - return saveAvatarUrlAction(); + return saveAvatarUrlAction({ + userId, + ...(avatarUrl && { avatarUrl }), + }); } if (isServiceObject(avatarObj)) { const { blob, contentType, service } = avatarObj; try { await setAvatarFromService(blob, contentType, service); - dispatchToastMessage({ type: 'success', message: successText }); + dispatchToastMessage({ type: 'success', message: successMessage }); } catch (error) { dispatchToastMessage({ type: 'error', message: error }); } @@ -65,12 +55,13 @@ export const useUpdateAvatar = ( } }, [ avatarObj, + avatarUrl, dispatchToastMessage, resetAvatarAction, saveAvatarAction, saveAvatarUrlAction, setAvatarFromService, - successText, + successMessage, userId, ]); diff --git a/apps/meteor/client/providers/ServerProvider.tsx b/apps/meteor/client/providers/ServerProvider.tsx index 5916ff11b2fd..5f218d755974 100644 --- a/apps/meteor/client/providers/ServerProvider.tsx +++ b/apps/meteor/client/providers/ServerProvider.tsx @@ -1,8 +1,9 @@ import type { Serialized } from '@rocket.chat/core-typings'; -import type { Method, PathFor, MatchPathPattern, OperationParams, OperationResult } from '@rocket.chat/rest-typings'; +import type { Method, PathFor, OperationParams, OperationResult, UrlParams, PathPattern } from '@rocket.chat/rest-typings'; import type { ServerMethodName, ServerMethodParameters, ServerMethodReturn, UploadResult } from '@rocket.chat/ui-contexts'; import { ServerContext } from '@rocket.chat/ui-contexts'; import { Meteor } from 'meteor/meteor'; +import { compile } from 'path-to-regexp'; import type { FC } from 'react'; import React from 'react'; @@ -15,23 +16,31 @@ const callMethod = ( ...args: ServerMethodParameters ): Promise> => Meteor.callAsync(methodName, ...args); -const callEndpoint = >( - method: TMethod, - path: TPath, - params: OperationParams>, -): Promise>>> => { +const callEndpoint = ({ + method, + pathPattern, + keys, + params, +}: { + method: TMethod; + pathPattern: TPathPattern; + keys: UrlParams; + params: OperationParams; +}): Promise>> => { + const compiledPath = compile(pathPattern, { encode: encodeURIComponent })(keys); + switch (method) { case 'GET': - return APIClient.get(path as any, params as any) as any; + return APIClient.get(compiledPath as any, params as any) as any; case 'POST': - return APIClient.post(path as any, params as any) as any; + return APIClient.post(compiledPath as any, params as any) as any; case 'PUT': - return APIClient.put(path as any, params as any) as any; + return APIClient.put(compiledPath as any, params as any) as any; case 'DELETE': - return APIClient.delete(path as any, params as any) as any; + return APIClient.delete(compiledPath as any, params as any) as any; default: throw new Error('Invalid HTTP method'); diff --git a/apps/meteor/client/sidebar/header/CreateDirectMessage.tsx b/apps/meteor/client/sidebar/header/CreateDirectMessage.tsx index 9309c07aee90..8bf9bc858ac5 100644 --- a/apps/meteor/client/sidebar/header/CreateDirectMessage.tsx +++ b/apps/meteor/client/sidebar/header/CreateDirectMessage.tsx @@ -6,7 +6,7 @@ import type { FC } from 'react'; import React, { useState, memo } from 'react'; import UserAutoCompleteMultipleFederated from '../../components/UserAutoCompleteMultiple/UserAutoCompleteMultipleFederated'; -import { useEndpointActionExperimental } from '../../hooks/useEndpointActionExperimental'; +import { useEndpointAction } from '../../hooks/useEndpointAction'; import { goToRoomById } from '../../lib/utils/goToRoomById'; type Username = Exclude; @@ -19,7 +19,7 @@ const CreateDirectMessage: FC = ({ onClose }) => { const t = useTranslation(); const [users, setUsers] = useState>([]); - const createDirect = useEndpointActionExperimental('POST', '/v1/dm.create'); + const createDirect = useEndpointAction('POST', '/v1/dm.create'); const onCreate = useMutableCallback(async () => { try { diff --git a/apps/meteor/client/stories/contexts/ServerContextMock.tsx b/apps/meteor/client/stories/contexts/ServerContextMock.tsx index 8a4d3724a779..265b3181d4a8 100644 --- a/apps/meteor/client/stories/contexts/ServerContextMock.tsx +++ b/apps/meteor/client/stories/contexts/ServerContextMock.tsx @@ -1,9 +1,8 @@ import type { Serialized } from '@rocket.chat/core-typings'; -import type { MatchPathPattern, Method, OperationParams, OperationResult, Path, PathFor } from '@rocket.chat/rest-typings'; +import type { Method, OperationParams, OperationResult, PathFor, PathPattern } from '@rocket.chat/rest-typings'; import type { ServerMethodName, ServerMethodParameters, ServerMethodReturn, UploadResult } from '@rocket.chat/ui-contexts'; import { ServerContext } from '@rocket.chat/ui-contexts'; import { action } from '@storybook/addon-actions'; -import { pathToRegexp } from 'path-to-regexp'; import type { ContextType, ReactElement, ReactNode } from 'react'; import React, { useContext, useMemo } from 'react'; @@ -38,19 +37,13 @@ const getStream = ( type Operations = { [TOperation in Method extends infer TMethod ? TMethod extends Method - ? PathFor extends infer TPath - ? TPath extends Path + ? PathPattern extends infer TPathPattern + ? TPathPattern extends PathPattern ? { - id: `${TMethod} ${TPath extends `/${string}` ? TPath : `/v1/${TPath}`}`; + id: `${TMethod} ${TPathPattern extends `/${string}` ? TPathPattern : `/v1/${TPathPattern}`}`; fn: ( - params: void extends OperationParams> - ? void - : OperationParams>, - ) => Promise< - void extends OperationResult> - ? Serialized>> - : void - >; + params: void extends OperationParams ? void : OperationParams, + ) => Promise ? Serialized> : void>; } : never : never @@ -94,41 +87,43 @@ const ServerContextMock = ({ match: (method: string, path: string) => boolean; handler: ((params: any) => Promise) | 'infinite' | 'errored' | undefined; } => { - const [_method, pathPattern] = operationID.split(' '); - const pathRegexp = pathToRegexp(pathPattern[0] === '/' ? pathPattern : `/v1/${pathPattern}`); - + const [_method, _pathPattern] = operationID.split(' '); return { - match: (method: string, path: string): boolean => _method === method && pathRegexp.test(path[0] === '/' ? path : `/v1/${path}`), + match: (method: string, pathPattern: string): boolean => _method === method && _pathPattern === pathPattern, handler: handler as any, }; }, ); - const _callEndpoint: ServerContextValue['callEndpoint'] = async >( - method: TMethod, - path: TPath, - params: OperationParams>, - ): Promise>>> => { - const mockedEndpoint = mockedEndpoints.find((endpoint) => endpoint.match(method, path)); + const _callEndpoint: ServerContextValue['callEndpoint'] = async ({ + method, + pathPattern, + params, + }: { + method: TMethod; + pathPattern: TPathPattern; + params: OperationParams; + }): Promise>> => { + const mockedEndpoint = mockedEndpoints.find((endpoint) => endpoint.match(method, pathPattern)); const handler = mockedEndpoint?.handler; if (!handler) { - logAction('callEndpoint (undefined)', method, path, params); + logAction('callEndpoint (undefined)', method, pathPattern, params); return undefined as any; } if (handler === 'infinite') { - logAction('callEndpoint (infinite)', method, path, params); + logAction('callEndpoint (infinite)', method, pathPattern, params); return new Promise(() => undefined); } if (handler === 'errored') { - logAction('callEndpoint (errored)', method, path, params); - throw new Error(`${method} ${path} failed`); + logAction('callEndpoint (errored)', method, pathPattern, params); + throw new Error(`${method} ${pathPattern} failed`); } - logAction('callEndpoint (intercepted)', method, path, params); - return handler(params) as Promise>>>; + logAction('callEndpoint (intercepted)', method, pathPattern, params); + return handler(params) as Promise>>; }; const _callMethod: ServerContextValue['callMethod'] = async ( diff --git a/apps/meteor/client/views/account/security/TwoFactorEmail.tsx b/apps/meteor/client/views/account/security/TwoFactorEmail.tsx index dd2036753516..669d78c07f78 100644 --- a/apps/meteor/client/views/account/security/TwoFactorEmail.tsx +++ b/apps/meteor/client/views/account/security/TwoFactorEmail.tsx @@ -11,8 +11,12 @@ const TwoFactorEmail = (props: ComponentProps): ReactElement => { const isEnabled = user?.services?.email2fa?.enabled; - const enable2faAction = useEndpointAction('POST', '/v1/users.2fa.enableEmail', undefined, t('Two-factor_authentication_enabled')); - const disable2faAction = useEndpointAction('POST', '/v1/users.2fa.disableEmail', undefined, t('Two-factor_authentication_disabled')); + const enable2faAction = useEndpointAction('POST', '/v1/users.2fa.enableEmail', { + successMessage: t('Two-factor_authentication_enabled'), + }); + const disable2faAction = useEndpointAction('POST', '/v1/users.2fa.disableEmail', { + successMessage: t('Two-factor_authentication_disabled'), + }); const handleEnable = useCallback(async () => { await enable2faAction(); diff --git a/apps/meteor/client/views/admin/apps/AppDetailsPage/tabs/AppReleases/AppReleases.tsx b/apps/meteor/client/views/admin/apps/AppDetailsPage/tabs/AppReleases/AppReleases.tsx index 946096031663..d36de080d8b7 100644 --- a/apps/meteor/client/views/admin/apps/AppDetailsPage/tabs/AppReleases/AppReleases.tsx +++ b/apps/meteor/client/views/admin/apps/AppDetailsPage/tabs/AppReleases/AppReleases.tsx @@ -10,7 +10,7 @@ import AppReleasesItem from './AppReleasesItem'; // TODO: replace useEndpointData const AppReleases = ({ id }: { id: App['id'] }): ReactElement => { - const result = useEndpointData(`/apps/${id}/versions`); + const result = useEndpointData('/apps/:id/versions', { keys: { id } }); return ( <> diff --git a/apps/meteor/client/views/admin/apps/hooks/useAppInfo.ts b/apps/meteor/client/views/admin/apps/hooks/useAppInfo.ts index 44fce08f52bb..6f4d4d08d260 100644 --- a/apps/meteor/client/views/admin/apps/hooks/useAppInfo.ts +++ b/apps/meteor/client/views/admin/apps/hooks/useAppInfo.ts @@ -24,12 +24,10 @@ export const useAppInfo = (appId: string): AppInfo | undefined => { const [appData, setAppData] = useState(); - const getSettings = useEndpoint('GET', `/apps/${appId}/settings`); - const getScreenshots = useEndpoint('GET', `/apps/${appId}/screenshots`); - const getApis = useEndpoint('GET', `/apps/${appId}/apis`); - - // TODO: remove EndpointFunction<'GET', 'apps/:id'> - const getBundledIn = useEndpoint('GET', `/apps/${appId}`) as any; + const getSettings = useEndpoint('GET', '/apps/:id/settings', { id: appId }); + const getScreenshots = useEndpoint('GET', '/apps/:id/screenshots', { id: appId }); + const getApis = useEndpoint('GET', '/apps/:id/apis', { id: appId }); + const getBundledIn = useEndpoint('GET', '/apps/:id', { id: appId }); useEffect(() => { const apps: App[] = []; diff --git a/apps/meteor/client/views/admin/apps/hooks/useLogs.ts b/apps/meteor/client/views/admin/apps/hooks/useLogs.ts index 9819d8c20d39..6d117f3bf7ec 100644 --- a/apps/meteor/client/views/admin/apps/hooks/useLogs.ts +++ b/apps/meteor/client/views/admin/apps/hooks/useLogs.ts @@ -4,7 +4,7 @@ import type { UseQueryResult } from '@tanstack/react-query'; import { useQuery } from '@tanstack/react-query'; export const useLogs = (appId: string): UseQueryResult> => { - const logs = useEndpoint('GET', `/apps/${appId}/logs`); + const logs = useEndpoint('GET', '/apps/:id/logs', { id: appId }); - return useQuery(['MarketplaceAppLogs'], () => logs()); + return useQuery(['marketplace', 'apps', appId, 'logs'], () => logs()); }; diff --git a/apps/meteor/client/views/admin/customEmoji/CustomEmoji.tsx b/apps/meteor/client/views/admin/customEmoji/CustomEmoji.tsx index 2eefba862450..56016013ec30 100644 --- a/apps/meteor/client/views/admin/customEmoji/CustomEmoji.tsx +++ b/apps/meteor/client/views/admin/customEmoji/CustomEmoji.tsx @@ -46,7 +46,7 @@ const CustomEmoji: FC = function CustomEmoji({ onClick, reload 500, ); - const { value: data, phase, reload: reloadEndPoint } = useEndpointData('/v1/emoji-custom.all', query); + const { value: data, phase, reload: reloadEndPoint } = useEndpointData('/v1/emoji-custom.all', { params: query }); useEffect(() => { reload.current = reloadEndPoint; diff --git a/apps/meteor/client/views/admin/customEmoji/EditCustomEmoji.tsx b/apps/meteor/client/views/admin/customEmoji/EditCustomEmoji.tsx index b2d2e5b4b53a..e9865448d73e 100644 --- a/apps/meteor/client/views/admin/customEmoji/EditCustomEmoji.tsx +++ b/apps/meteor/client/views/admin/customEmoji/EditCustomEmoji.tsx @@ -81,16 +81,12 @@ const EditCustomEmoji: FC = ({ close, onChange, data, ...p } }, [emojiFile, _id, name, aliases, saveAction, onChange, close, newEmojiPreview]); - const deleteAction = useEndpointAction( - 'POST', - '/v1/emoji-custom.delete', - useMemo(() => ({ emojiId: _id }), [_id]), - ); + const deleteAction = useEndpointAction('POST', '/v1/emoji-custom.delete'); const handleDeleteButtonClick = useCallback(() => { const handleDelete = async (): Promise => { try { - await deleteAction(); + await deleteAction({ emojiId: _id }); dispatchToastMessage({ type: 'success', message: t('Custom_Emoji_Has_Been_Deleted') }); } catch (error) { dispatchToastMessage({ type: 'error', message: error }); @@ -110,7 +106,7 @@ const EditCustomEmoji: FC = ({ close, onChange, data, ...p {t('Custom_Emoji_Delete_Warning')} )); - }, [deleteAction, close, dispatchToastMessage, onChange, setModal, t]); + }, [setModal, deleteAction, _id, dispatchToastMessage, t, onChange, close]); const handleChangeAliases = useCallback( (e) => { diff --git a/apps/meteor/client/views/admin/customEmoji/EditCustomEmojiWithData.tsx b/apps/meteor/client/views/admin/customEmoji/EditCustomEmojiWithData.tsx index 122a7445412c..9baf94f4eae1 100644 --- a/apps/meteor/client/views/admin/customEmoji/EditCustomEmojiWithData.tsx +++ b/apps/meteor/client/views/admin/customEmoji/EditCustomEmojiWithData.tsx @@ -26,7 +26,7 @@ const EditCustomEmojiWithData: FC = ({ _id, onChan phase: state, error, reload, - } = useEndpointData('/v1/emoji-custom.list', query); + } = useEndpointData('/v1/emoji-custom.list', { params: query }); if (state === AsyncStatePhase.LOADING) { return ( diff --git a/apps/meteor/client/views/admin/customSounds/AdminSoundsRoute.tsx b/apps/meteor/client/views/admin/customSounds/AdminSoundsRoute.tsx index 4603f3d87183..9eda105ec62c 100644 --- a/apps/meteor/client/views/admin/customSounds/AdminSoundsRoute.tsx +++ b/apps/meteor/client/views/admin/customSounds/AdminSoundsRoute.tsx @@ -46,7 +46,7 @@ const CustomSoundsRoute = (): ReactElement => { 500, ); - const { reload, ...result } = useEndpointData('/v1/custom-sounds.list', query); + const { reload, ...result } = useEndpointData('/v1/custom-sounds.list', { params: query }); const handleItemClick = useCallback( (_id) => (): void => { diff --git a/apps/meteor/client/views/admin/customSounds/EditCustomSound.tsx b/apps/meteor/client/views/admin/customSounds/EditCustomSound.tsx index c38bfa50e4d1..30e34b7ecd25 100644 --- a/apps/meteor/client/views/admin/customSounds/EditCustomSound.tsx +++ b/apps/meteor/client/views/admin/customSounds/EditCustomSound.tsx @@ -15,7 +15,7 @@ type EditCustomSoundProps = { function EditCustomSound({ _id, onChange, ...props }: EditCustomSoundProps): ReactElement { const query = useMemo(() => ({ query: JSON.stringify({ _id }) }), [_id]); - const { value: data, phase: state, error, reload } = useEndpointData('/v1/custom-sounds.list', query); + const { value: data, phase: state, error, reload } = useEndpointData('/v1/custom-sounds.list', { params: query }); if (state === AsyncStatePhase.LOADING) { return ( diff --git a/apps/meteor/client/views/admin/customUserStatus/CustomUserStatusFormWithData.tsx b/apps/meteor/client/views/admin/customUserStatus/CustomUserStatusFormWithData.tsx index f5e9afcc3f80..64950fb8674c 100644 --- a/apps/meteor/client/views/admin/customUserStatus/CustomUserStatusFormWithData.tsx +++ b/apps/meteor/client/views/admin/customUserStatus/CustomUserStatusFormWithData.tsx @@ -18,7 +18,7 @@ const CustomUserStatusFormWithData = ({ _id, onReload, onClose }: CustomUserStat const t = useTranslation(); const query = useMemo(() => ({ query: JSON.stringify({ _id }) }), [_id]); - const { value: data, phase: state, error, reload } = useEndpointData('/v1/custom-user-status.list', query); + const { value: data, phase: state, error, reload } = useEndpointData('/v1/custom-user-status.list', { params: query }); const handleReload = (): void => { onReload?.(); diff --git a/apps/meteor/client/views/admin/customUserStatus/CustomUserStatusTable/CustomUserStatusTable.tsx b/apps/meteor/client/views/admin/customUserStatus/CustomUserStatusTable/CustomUserStatusTable.tsx index 541fb8b0e791..f9e9a98bf08c 100644 --- a/apps/meteor/client/views/admin/customUserStatus/CustomUserStatusTable/CustomUserStatusTable.tsx +++ b/apps/meteor/client/views/admin/customUserStatus/CustomUserStatusTable/CustomUserStatusTable.tsx @@ -42,7 +42,7 @@ const CustomUserStatus = ({ reload, onClick }: CustomUserStatusProps): ReactElem 500, ); - const { value, reload: reloadEndpoint, phase } = useEndpointData('/v1/custom-user-status.list', query); + const { value, reload: reloadEndpoint, phase } = useEndpointData('/v1/custom-user-status.list', { params: query }); useEffect(() => { reload.current = reloadEndpoint; diff --git a/apps/meteor/client/views/admin/emailInbox/EmailInboxForm.tsx b/apps/meteor/client/views/admin/emailInbox/EmailInboxForm.tsx index 1ed8b9d19ccb..aa52b61f2a1b 100644 --- a/apps/meteor/client/views/admin/emailInbox/EmailInboxForm.tsx +++ b/apps/meteor/client/views/admin/emailInbox/EmailInboxForm.tsx @@ -33,7 +33,7 @@ const EmailInboxForm = ({ inboxData }: { inboxData?: IEmailInboxPayload }): Reac const handleBack = useCallback(() => router.push({}), [router]); const saveEmailInbox = useEndpoint('POST', '/v1/email-inbox'); - const deleteInboxAction = useEndpoint('DELETE', `/v1/email-inbox/${inboxData?._id}`); + const deleteInboxAction = useEndpoint('DELETE', '/v1/email-inbox/:_id', { _id: inboxData?._id ?? '' }); const emailAlreadyExistsAction = useEndpoint('GET', '/v1/email-inbox.search'); const { diff --git a/apps/meteor/client/views/admin/emailInbox/EmailInboxFormWithData.tsx b/apps/meteor/client/views/admin/emailInbox/EmailInboxFormWithData.tsx index 393dccbc9924..da6c601944e0 100644 --- a/apps/meteor/client/views/admin/emailInbox/EmailInboxFormWithData.tsx +++ b/apps/meteor/client/views/admin/emailInbox/EmailInboxFormWithData.tsx @@ -10,8 +10,8 @@ import EmailInboxForm from './EmailInboxForm'; const EmailInboxFormWithData = ({ id }: { id: IEmailInbox['_id'] }): ReactElement => { const t = useTranslation(); - const getEmailInboxById = useEndpoint('GET', `/v1/email-inbox/${id}`); - const { data, isLoading, error } = useQuery(['email-inbox/:_id'], () => getEmailInboxById()); + const getEmailInboxById = useEndpoint('GET', '/v1/email-inbox/:_id', { _id: id }); + const { data, isLoading, error } = useQuery(['email-inbox', id], () => getEmailInboxById()); if (isLoading) { return ; diff --git a/apps/meteor/client/views/admin/emailInbox/SendTestButton.tsx b/apps/meteor/client/views/admin/emailInbox/SendTestButton.tsx index f3ea0a7fa087..4f4fa8215901 100644 --- a/apps/meteor/client/views/admin/emailInbox/SendTestButton.tsx +++ b/apps/meteor/client/views/admin/emailInbox/SendTestButton.tsx @@ -7,7 +7,7 @@ import React from 'react'; const SendTestButton = ({ id }: { id: IEmailInboxPayload['_id'] }): ReactElement => { const t = useTranslation(); const dispatchToastMessage = useToastMessageDispatch(); - const sendTest = useEndpoint('POST', `/v1/email-inbox.send-test/${id}`); + const sendTest = useEndpoint('POST', '/v1/email-inbox.send-test/:_id', { _id: id }); const handleOnClick = async (e: React.MouseEvent): Promise => { e.preventDefault(); diff --git a/apps/meteor/client/views/admin/integrations/edit/EditIncomingWebhook.js b/apps/meteor/client/views/admin/integrations/edit/EditIncomingWebhook.js index 73f7dde4b123..29da599949db 100644 --- a/apps/meteor/client/views/admin/integrations/edit/EditIncomingWebhook.js +++ b/apps/meteor/client/views/admin/integrations/edit/EditIncomingWebhook.js @@ -29,8 +29,7 @@ function EditIncomingWebhook({ data, onChange, ...props }) { const { values: formValues, handlers: formHandlers, reset } = useForm(getInitialValue(data)); const setModal = useSetModal(); - const deleteQuery = useMemo(() => ({ type: 'webhook-incoming', integrationId: data._id }), [data._id]); - const deleteIntegration = useEndpointAction('POST', '/v1/integrations.remove', deleteQuery); + const deleteIntegration = useEndpointAction('POST', '/v1/integrations.remove'); const saveIntegration = useMethod('updateIncomingIntegration'); const router = useRoute('admin-integrations'); @@ -44,7 +43,7 @@ function EditIncomingWebhook({ data, onChange, ...props }) { }; const onDelete = async () => { - const result = await deleteIntegration(); + const result = await deleteIntegration({ type: 'webhook-incoming', integrationId: data._id }); if (result.success) { setModal( @@ -59,7 +58,7 @@ function EditIncomingWebhook({ data, onChange, ...props }) { {t('Integration_Delete_Warning')} , ); - }, [deleteIntegration, router, setModal, t]); + }, [data._id, deleteIntegration, router, setModal, t]); const handleSave = useCallback(async () => { try { diff --git a/apps/meteor/client/views/admin/integrations/edit/EditOutgoingWebhook.js b/apps/meteor/client/views/admin/integrations/edit/EditOutgoingWebhook.js index 61bdbcca4fe4..b7e63063cf39 100644 --- a/apps/meteor/client/views/admin/integrations/edit/EditOutgoingWebhook.js +++ b/apps/meteor/client/views/admin/integrations/edit/EditOutgoingWebhook.js @@ -45,8 +45,7 @@ function EditOutgoingWebhook({ data, onChange, setSaveAction, ...props }) { const router = useRoute('admin-integrations'); - const deleteQuery = useMemo(() => ({ type: 'webhook-outgoing', integrationId: data._id }), [data._id]); - const deleteIntegration = useEndpointAction('POST', '/v1/integrations.remove', deleteQuery); + const deleteIntegration = useEndpointAction('POST', '/v1/integrations.remove'); const handleDeleteIntegration = useCallback(() => { const closeModal = () => setModal(); @@ -57,7 +56,7 @@ function EditOutgoingWebhook({ data, onChange, setSaveAction, ...props }) { }; const onDelete = async () => { - const result = await deleteIntegration(); + const result = await deleteIntegration({ type: 'webhook-outgoing', integrationId: data._id }); if (result.success) { setModal( @@ -72,7 +71,7 @@ function EditOutgoingWebhook({ data, onChange, setSaveAction, ...props }) { {t('Integration_Delete_Warning')} , ); - }, [deleteIntegration, router, setModal, t]); + }, [data._id, deleteIntegration, router, setModal, t]); const { urls, triggerWords } = formValues; diff --git a/apps/meteor/client/views/admin/integrations/new/NewIncomingWebhook.js b/apps/meteor/client/views/admin/integrations/new/NewIncomingWebhook.js index 958bce303162..cfbb67256134 100644 --- a/apps/meteor/client/views/admin/integrations/new/NewIncomingWebhook.js +++ b/apps/meteor/client/views/admin/integrations/new/NewIncomingWebhook.js @@ -25,15 +25,14 @@ export default function NewIncomingWebhook(props) { const { values: formValues, handlers: formHandlers, reset } = useForm(initialState); - const params = useMemo(() => ({ ...formValues, type: 'webhook-incoming' }), [formValues]); - const saveAction = useEndpointAction('POST', '/v1/integrations.create', params, t('Integration_added')); + const saveAction = useEndpointAction('POST', '/v1/integrations.create', { successMessage: t('Integration_added') }); const handleSave = useCallback(async () => { - const result = await saveAction(); + const result = await saveAction({ ...formValues, type: 'webhook-incoming' }); if (result.success) { router.push({ context: 'edit', type: 'incoming', id: result.integration._id }); } - }, [router, saveAction]); + }, [formValues, router, saveAction]); const actionButtons = useMemo( () => ( diff --git a/apps/meteor/client/views/admin/integrations/new/NewOutgoingWebhook.js b/apps/meteor/client/views/admin/integrations/new/NewOutgoingWebhook.js index b20b50b2b698..818082f5f5de 100644 --- a/apps/meteor/client/views/admin/integrations/new/NewOutgoingWebhook.js +++ b/apps/meteor/client/views/admin/integrations/new/NewOutgoingWebhook.js @@ -39,22 +39,18 @@ export default function NewOutgoingWebhook({ data = defaultData, onChange, setSa const { urls, triggerWords } = formValues; - const params = useMemo( - () => ({ + const saveIntegration = useEndpointAction('POST', '/v1/integrations.create', { successMessage: t('Integration_added') }); + + const handleSave = useCallback(async () => { + const result = await saveIntegration({ ...formValues, urls: urls.split('\n'), triggerWords: triggerWordsToArray(triggerWords), - }), - [formValues, triggerWords, urls], - ); - const saveIntegration = useEndpointAction('POST', '/v1/integrations.create', params, t('Integration_added')); - - const handleSave = useCallback(async () => { - const result = await saveIntegration(); + }); if (result.success) { router.push({ id: result.integration._id, context: 'edit', type: 'outgoing' }); } - }, [saveIntegration, router]); + }, [saveIntegration, formValues, urls, triggerWords, router]); const saveButton = useMemo( () => ( diff --git a/apps/meteor/client/views/admin/invites/InviteRow.tsx b/apps/meteor/client/views/admin/invites/InviteRow.tsx index 9e0b6c696dfc..48c49ce73a78 100644 --- a/apps/meteor/client/views/admin/invites/InviteRow.tsx +++ b/apps/meteor/client/views/admin/invites/InviteRow.tsx @@ -27,7 +27,7 @@ type InviteRowProps = Omit & { const InviteRow = ({ _id, createdAt, expires, uses, maxUses, onRemove }: InviteRowProps): ReactElement => { const t = useTranslation(); const formatDateAndTime = useFormatDateAndTime(); - const removeInvite = useEndpoint('DELETE', `/v1/removeInvite/${_id}`); + const removeInvite = useEndpoint('DELETE', '/v1/removeInvite/:_id', { _id }); const getTimeFromNow = useTimeFromNow(false); diff --git a/apps/meteor/client/views/admin/oauthApps/EditOauthAppWithData.tsx b/apps/meteor/client/views/admin/oauthApps/EditOauthAppWithData.tsx index 40709026b8a8..ddaa955c5fbf 100644 --- a/apps/meteor/client/views/admin/oauthApps/EditOauthAppWithData.tsx +++ b/apps/meteor/client/views/admin/oauthApps/EditOauthAppWithData.tsx @@ -12,7 +12,7 @@ const EditOauthAppWithData = ({ _id, ...props }: { _id: string }): ReactElement const params = useMemo(() => ({ appId: _id }), [_id]); - const { value: data, phase: state, error, reload } = useEndpointData('/v1/oauth-apps.get', params); + const { value: data, phase: state, error, reload } = useEndpointData('/v1/oauth-apps.get', { params }); const onChange = useCallback(() => { reload(); diff --git a/apps/meteor/client/views/admin/permissions/UsersInRole/UsersInRoleTable/UsersInRoleTableWithData.tsx b/apps/meteor/client/views/admin/permissions/UsersInRole/UsersInRoleTable/UsersInRoleTableWithData.tsx index 7c03f6e970e5..31f20bb645ac 100644 --- a/apps/meteor/client/views/admin/permissions/UsersInRole/UsersInRoleTable/UsersInRoleTableWithData.tsx +++ b/apps/meteor/client/views/admin/permissions/UsersInRole/UsersInRoleTable/UsersInRoleTableWithData.tsx @@ -34,7 +34,7 @@ const UsersInRoleTableWithData = ({ [itemsPerPage, current, rid, roleId], ); - const { reload, ...result } = useEndpointData('/v1/roles.getUsersInRole', query); + const { reload, ...result } = useEndpointData('/v1/roles.getUsersInRole', { params: query }); useEffect(() => { reloadRef.current = reload; diff --git a/apps/meteor/client/views/admin/rooms/EditRoom.tsx b/apps/meteor/client/views/admin/rooms/EditRoom.tsx index b081385c3aa6..752ae6219f37 100644 --- a/apps/meteor/client/views/admin/rooms/EditRoom.tsx +++ b/apps/meteor/client/views/admin/rooms/EditRoom.tsx @@ -9,7 +9,7 @@ import { RoomSettingsEnum } from '../../../../definition/IRoomTypeConfig'; import GenericModal from '../../../components/GenericModal'; import VerticalBar from '../../../components/VerticalBar'; import RoomAvatarEditor from '../../../components/avatar/RoomAvatarEditor'; -import { useEndpointActionExperimental } from '../../../hooks/useEndpointActionExperimental'; +import { useEndpointAction } from '../../../hooks/useEndpointAction'; import { useForm } from '../../../hooks/useForm'; import { roomCoordinator } from '../../../lib/rooms/roomCoordinator'; import DeleteTeamModalWithRooms from '../../teams/contextualBar/info/Delete'; @@ -114,8 +114,10 @@ const EditRoom = ({ room, onChange, onDelete }: EditRoomProps): ReactElement => const archiveSelector = room.archived ? 'unarchive' : 'archive'; const archiveMessage = room.archived ? 'Room_has_been_unarchived' : 'Room_has_been_archived'; - const saveAction = useEndpointActionExperimental('POST', '/v1/rooms.saveRoomSettings', t('Room_updated_successfully')); - const archiveAction = useEndpointActionExperimental('POST', '/v1/rooms.changeArchivationState', t(archiveMessage)); + const saveAction = useEndpointAction('POST', '/v1/rooms.saveRoomSettings', { + successMessage: t('Room_updated_successfully'), + }); + const archiveAction = useEndpointAction('POST', '/v1/rooms.changeArchivationState', { successMessage: t(archiveMessage) }); const handleSave = useMutableCallback(async () => { const save = (): Promise<{ success: boolean; rid: string }> => diff --git a/apps/meteor/client/views/admin/rooms/EditRoomWithData.tsx b/apps/meteor/client/views/admin/rooms/EditRoomWithData.tsx index c942bad4ffed..1e826b3d3ca3 100644 --- a/apps/meteor/client/views/admin/rooms/EditRoomWithData.tsx +++ b/apps/meteor/client/views/admin/rooms/EditRoomWithData.tsx @@ -12,10 +12,7 @@ const EditRoomWithData: FC<{ rid?: string; onReload: () => void }> = ({ rid, onR phase: state, error, reload, - } = useEndpointData( - '/v1/rooms.adminRooms.getRoom', - useMemo(() => ({ rid }), [rid]), - ); + } = useEndpointData('/v1/rooms.adminRooms.getRoom', { params: useMemo(() => ({ rid }), [rid]) }); if (state === AsyncStatePhase.LOADING) { return ( diff --git a/apps/meteor/client/views/admin/rooms/RoomsTable.tsx b/apps/meteor/client/views/admin/rooms/RoomsTable.tsx index 1bcae5250dcd..e5aedc965f97 100644 --- a/apps/meteor/client/views/admin/rooms/RoomsTable.tsx +++ b/apps/meteor/client/views/admin/rooms/RoomsTable.tsx @@ -113,7 +113,7 @@ const RoomsTable = ({ reload }: { reload: MutableRefObject<() => void> }): React const query = useQuery(debouncedParams, debouncedSort); - const endpointData = useEndpointData('/v1/rooms.adminRooms', query); + const endpointData = useEndpointData('/v1/rooms.adminRooms', { params: query }); const { value: data, reload: reloadEndPoint } = endpointData; diff --git a/apps/meteor/client/views/admin/settings/groups/voip/AssignAgentModal.tsx b/apps/meteor/client/views/admin/settings/groups/voip/AssignAgentModal.tsx index 378532a6e2d9..7d158c44800b 100644 --- a/apps/meteor/client/views/admin/settings/groups/voip/AssignAgentModal.tsx +++ b/apps/meteor/client/views/admin/settings/groups/voip/AssignAgentModal.tsx @@ -34,7 +34,7 @@ const AssignAgentModal: FC = ({ existingExtension, close }); const handleAgentChange = useMutableCallback((e) => setAgent(e)); - const { value: availableExtensions, phase: state } = useEndpointData('/v1/omnichannel/extension', query); + const { value: availableExtensions, phase: state } = useEndpointData('/v1/omnichannel/extension', { params: query }); return ( diff --git a/apps/meteor/client/views/admin/settings/groups/voip/RemoveAgentButton.tsx b/apps/meteor/client/views/admin/settings/groups/voip/RemoveAgentButton.tsx index f0fb0bc60266..f1026086ba61 100644 --- a/apps/meteor/client/views/admin/settings/groups/voip/RemoveAgentButton.tsx +++ b/apps/meteor/client/views/admin/settings/groups/voip/RemoveAgentButton.tsx @@ -7,7 +7,7 @@ import React from 'react'; import GenericModal from '../../../../../components/GenericModal'; const RemoveAgentButton: FC<{ username: string; reload: () => void }> = ({ username, reload }) => { - const removeAgent = useEndpoint('DELETE', `/v1/omnichannel/agent/extension/${username}`); + const removeAgent = useEndpoint('DELETE', '/v1/omnichannel/agent/extension/:username', { username }); const setModal = useSetModal(); const dispatchToastMessage = useToastMessageDispatch(); const t = useTranslation(); diff --git a/apps/meteor/client/views/admin/settings/groups/voip/VoipExtensionsPage.tsx b/apps/meteor/client/views/admin/settings/groups/voip/VoipExtensionsPage.tsx index 53e0e41e2b2c..aa1b0532583e 100644 --- a/apps/meteor/client/views/admin/settings/groups/voip/VoipExtensionsPage.tsx +++ b/apps/meteor/client/views/admin/settings/groups/voip/VoipExtensionsPage.tsx @@ -30,7 +30,7 @@ const VoipExtensionsPage: FC = () => { [itemsPerPage, current], ); - const { value: data, reload } = useEndpointData('/v1/omnichannel/extensions', query); + const { value: data, reload } = useEndpointData('/v1/omnichannel/extensions', { params: query }); const header = useMemo( () => diff --git a/apps/meteor/client/views/admin/settings/inputs/LookupSettingInput.tsx b/apps/meteor/client/views/admin/settings/inputs/LookupSettingInput.tsx index dc8c71d8edfb..db15dc67af1e 100644 --- a/apps/meteor/client/views/admin/settings/inputs/LookupSettingInput.tsx +++ b/apps/meteor/client/views/admin/settings/inputs/LookupSettingInput.tsx @@ -1,5 +1,5 @@ import { Box, Field, Flex, Select } from '@rocket.chat/fuselage'; -import type { PathFor } from '@rocket.chat/rest-typings'; +import type { PathPattern } from '@rocket.chat/rest-typings'; import type { ReactElement } from 'react'; import React from 'react'; @@ -11,7 +11,7 @@ type LookupSettingInputProps = { _id: string; label: string; value?: string; - lookupEndpoint: PathFor<'GET'>; + lookupEndpoint: PathPattern extends `/${infer U}` ? U : PathPattern; placeholder?: string; readonly?: boolean; autocomplete?: boolean; diff --git a/apps/meteor/client/views/admin/users/AddUser.js b/apps/meteor/client/views/admin/users/AddUser.js index 11163b2e696c..efe429224dc7 100644 --- a/apps/meteor/client/views/admin/users/AddUser.js +++ b/apps/meteor/client/views/admin/users/AddUser.js @@ -77,10 +77,8 @@ const AddUser = ({ onReload, ...props }) => { [router], ); - const saveAction = useEndpointAction('POST', '/v1/users.create', values, t('User_created_successfully!')); - const eventStats = useEndpointAction('POST', '/v1/statistics.telemetry', { - params: [{ eventName: 'updateCounter', settingsId: 'Manual_Entry_User_Count' }], - }); + const saveAction = useEndpointAction('POST', '/v1/users.create', { successMessage: t('User_created_successfully!') }); + const eventStats = useEndpointAction('POST', '/v1/statistics.telemetry'); const handleSave = useMutableCallback(async () => { Object.entries(values).forEach(([key, value]) => { @@ -95,9 +93,11 @@ const AddUser = ({ onReload, ...props }) => { return false; } - const result = await saveAction(); + const result = await saveAction(values); if (result.success) { - eventStats(); + eventStats({ + params: [{ eventName: 'updateCounter', settingsId: 'Manual_Entry_User_Count' }], + }); goToUser(result.user._id); onReload(); } diff --git a/apps/meteor/client/views/admin/users/AdminUserInfoWithData.tsx b/apps/meteor/client/views/admin/users/AdminUserInfoWithData.tsx index 2a5712165079..f8bb19b45e42 100644 --- a/apps/meteor/client/views/admin/users/AdminUserInfoWithData.tsx +++ b/apps/meteor/client/views/admin/users/AdminUserInfoWithData.tsx @@ -31,10 +31,7 @@ const AdminUserInfoWithData = ({ uid, onReload }: AdminUserInfoWithDataProps): R phase: state, error, reload: reloadUserInfo, - } = useEndpointData( - '/v1/users.info', - useMemo(() => ({ userId: uid }), [uid]), - ); + } = useEndpointData('/v1/users.info', { params: useMemo(() => ({ userId: uid }), [uid]) }); const onChange = useMutableCallback(() => { onReload(); diff --git a/apps/meteor/client/views/admin/users/EditUser.js b/apps/meteor/client/views/admin/users/EditUser.js index 0e2191aeb68a..0ce4367d59e4 100644 --- a/apps/meteor/client/views/admin/users/EditUser.js +++ b/apps/meteor/client/views/admin/users/EditUser.js @@ -65,40 +65,22 @@ function EditUser({ data, roles, onReload, ...props }) { [router], ); - const saveQuery = useMemo( - () => ({ - userId: data._id, - data: values, - }), - [data._id, values], - ); - - const saveAvatarQuery = useMemo( - () => ({ - userId: data._id, - avatarUrl: avatarObj && avatarObj.avatarUrl, - }), - [data._id, avatarObj], - ); - - const resetAvatarQuery = useMemo( - () => ({ - userId: data._id, - }), - [data._id], - ); - - const saveAction = useEndpointAction('POST', '/v1/users.update', saveQuery, t('User_updated_successfully')); + const saveAction = useEndpointAction('POST', '/v1/users.update', { successMessage: t('User_updated_successfully') }); const saveAvatarAction = useEndpointUpload('/v1/users.setAvatar', t('Avatar_changed_successfully')); - const saveAvatarUrlAction = useEndpointAction('POST', '/v1/users.setAvatar', saveAvatarQuery, t('Avatar_changed_successfully')); - const resetAvatarAction = useEndpointAction('POST', '/v1/users.resetAvatar', resetAvatarQuery, t('Avatar_changed_successfully')); + const saveAvatarUrlAction = useEndpointAction('POST', '/v1/users.setAvatar', { successMessage: t('Avatar_changed_successfully') }); + const resetAvatarAction = useEndpointAction('POST', '/v1/users.resetAvatar', { successMessage: t('Avatar_changed_successfully') }); const updateAvatar = useCallback(async () => { if (avatarObj === 'reset') { - return resetAvatarAction(); + return resetAvatarAction({ + userId: data._id, + }); } if (avatarObj.avatarUrl) { - return saveAvatarUrlAction(); + return saveAvatarUrlAction({ + userId: data._id, + avatarUrl: avatarObj && avatarObj.avatarUrl, + }); } avatarObj.set('userId', data._id); return saveAvatarAction(avatarObj); @@ -115,7 +97,10 @@ function EditUser({ data, roles, onReload, ...props }) { } if (hasUnsavedChanges) { - const result = await saveAction(); + const result = await saveAction({ + userId: data._id, + data: values, + }); if (result.success && avatarObj) { await updateAvatar(); } diff --git a/apps/meteor/client/views/admin/users/EditUserWithData.tsx b/apps/meteor/client/views/admin/users/EditUserWithData.tsx index c048dd824a23..d3a308e8f0e5 100644 --- a/apps/meteor/client/views/admin/users/EditUserWithData.tsx +++ b/apps/meteor/client/views/admin/users/EditUserWithData.tsx @@ -18,14 +18,7 @@ type EditUserWithDataProps = { const EditUserWithData = ({ uid, onReload, ...props }: EditUserWithDataProps): ReactElement => { const t = useTranslation(); const { value: roleData, phase: roleState, error: roleError } = useEndpointData('/v1/roles.list'); - const { - value: data, - phase: state, - error, - } = useEndpointData( - '/v1/users.info', - useMemo(() => ({ userId: uid }), [uid]), - ); + const { value: data, phase: state, error } = useEndpointData('/v1/users.info', { params: useMemo(() => ({ userId: uid }), [uid]) }); if ([state, roleState].includes(AsyncStatePhase.LOADING)) { return ( diff --git a/apps/meteor/client/views/admin/users/UsersTable/UsersTable.tsx b/apps/meteor/client/views/admin/users/UsersTable/UsersTable.tsx index e5d09e83689a..2da33358062d 100644 --- a/apps/meteor/client/views/admin/users/UsersTable/UsersTable.tsx +++ b/apps/meteor/client/views/admin/users/UsersTable/UsersTable.tsx @@ -58,7 +58,7 @@ const UsersTable = ({ reload }: UsersTableProps): ReactElement | null => { 500, ); - const { value, phase, reload: reloadList } = useEndpointData('/v1/users.list', query); + const { value, phase, reload: reloadList } = useEndpointData('/v1/users.list', { params: query }); useEffect(() => { reload.current = reloadList; diff --git a/apps/meteor/client/views/hooks/useDepartmentsByUnitsList.ts b/apps/meteor/client/views/hooks/useDepartmentsByUnitsList.ts index 282897f298fb..ceaa600c1ee2 100644 --- a/apps/meteor/client/views/hooks/useDepartmentsByUnitsList.ts +++ b/apps/meteor/client/views/hooks/useDepartmentsByUnitsList.ts @@ -22,7 +22,7 @@ export const useDepartmentsByUnitsList = ( const [itemsList, setItemsList] = useState(() => new RecordList()); const reload = useCallback(() => setItemsList(new RecordList()), []); - const getDepartments = useEndpoint('GET', `/v1/livechat/units/${options.unitId || 'none'}/departments/available`); + const getDepartments = useEndpoint('GET', '/v1/livechat/units/:unitId/departments/available', { unitId: options.unitId || 'none' }); useComponentDidUpdate(() => { options && reload(); diff --git a/apps/meteor/client/views/omnichannel/agents/AddAgent.tsx b/apps/meteor/client/views/omnichannel/agents/AddAgent.tsx index 14a2b9ba8310..9989a17cc81f 100644 --- a/apps/meteor/client/views/omnichannel/agents/AddAgent.tsx +++ b/apps/meteor/client/views/omnichannel/agents/AddAgent.tsx @@ -15,13 +15,13 @@ const AddAgent = ({ reload }: AddAgentProps): ReactElement => { const t = useTranslation(); const [username, setUsername] = useState(''); - const saveAction = useEndpointAction('POST', '/v1/livechat/users/agent', { username }); + const saveAction = useEndpointAction('POST', '/v1/livechat/users/agent'); const handleSave = useMutableCallback(async () => { if (!username) { return; } - const result = await saveAction(); + const result = await saveAction({ username }); if (!result.success) { return; } diff --git a/apps/meteor/client/views/omnichannel/agents/AgentEditWithData.tsx b/apps/meteor/client/views/omnichannel/agents/AgentEditWithData.tsx index 472d2efa2957..92513109dedb 100644 --- a/apps/meteor/client/views/omnichannel/agents/AgentEditWithData.tsx +++ b/apps/meteor/client/views/omnichannel/agents/AgentEditWithData.tsx @@ -15,12 +15,12 @@ type AgentEditWithDataProps = { const AgentEditWithData = ({ uid, reload }: AgentEditWithDataProps): ReactElement => { const t = useTranslation(); - const { value: data, phase: state, error } = useEndpointData(`/v1/livechat/users/agent/${uid}`); + const { value: data, phase: state, error } = useEndpointData('/v1/livechat/users/agent/:_id', { keys: { _id: uid } }); const { value: userDepartments, phase: userDepartmentsState, error: userDepartmentsError, - } = useEndpointData(`/v1/livechat/agents/${uid}/departments`); + } = useEndpointData('/v1/livechat/agents/:agentId/departments', { keys: { agentId: uid } }); const { value: availableDepartments, phase: availableDepartmentsState, diff --git a/apps/meteor/client/views/omnichannel/agents/AgentInfo.tsx b/apps/meteor/client/views/omnichannel/agents/AgentInfo.tsx index 5b2b15d4a9a3..38efc6fc4e04 100644 --- a/apps/meteor/client/views/omnichannel/agents/AgentInfo.tsx +++ b/apps/meteor/client/views/omnichannel/agents/AgentInfo.tsx @@ -18,7 +18,7 @@ type AgentInfoProps = { export const AgentInfo = memo(function AgentInfo({ uid, children, ...props }) { const t = useTranslation(); - const result = useEndpointData(`/v1/livechat/users/agent/${uid}`); + const result = useEndpointData('/v1/livechat/users/agent/:_id', { keys: { _id: uid } }); const { useMaxChatsPerAgentDisplay } = useFormsSubscription(); diff --git a/apps/meteor/client/views/omnichannel/agents/AgentInfoActions.tsx b/apps/meteor/client/views/omnichannel/agents/AgentInfoActions.tsx index 66ace29da02c..b25d783b97be 100644 --- a/apps/meteor/client/views/omnichannel/agents/AgentInfoActions.tsx +++ b/apps/meteor/client/views/omnichannel/agents/AgentInfoActions.tsx @@ -9,9 +9,9 @@ import AgentInfo from './AgentInfo'; const AgentInfoActions = ({ reload }: { reload: () => void }): ReactElement => { const t = useTranslation(); - const _id = useRouteParameter('id'); + const _id = useRouteParameter('id') ?? ''; const agentsRoute = useRoute('omnichannel-agents'); - const deleteAction = useEndpointAction('DELETE', `/v1/livechat/users/agent/${_id}`); + const deleteAction = useEndpointAction('DELETE', '/v1/livechat/users/agent/:_id', { keys: { _id } }); const setModal = useSetModal(); const dispatchToastMessage = useToastMessageDispatch(); diff --git a/apps/meteor/client/views/omnichannel/agents/AgentsPage.tsx b/apps/meteor/client/views/omnichannel/agents/AgentsPage.tsx index 9d14e9abde5e..7b1818057ac2 100644 --- a/apps/meteor/client/views/omnichannel/agents/AgentsPage.tsx +++ b/apps/meteor/client/views/omnichannel/agents/AgentsPage.tsx @@ -37,7 +37,7 @@ const AgentsPage = (): ReactElement => { const { current, itemsPerPage, setItemsPerPage, setCurrent, ...paginationProps } = usePagination(); const query = useQuery({ text: debouncedFilter, current, itemsPerPage }, debouncedSort); - const { reload, ...result } = useEndpointData('/v1/livechat/users/agent', query); + const { reload, ...result } = useEndpointData('/v1/livechat/users/agent', { params: query }); const onHeaderClick = useMutableCallback((id) => { if (sortBy === id) { diff --git a/apps/meteor/client/views/omnichannel/agents/RemoveAgentButton.tsx b/apps/meteor/client/views/omnichannel/agents/RemoveAgentButton.tsx index 757e45f7b52e..109bb4688cd2 100644 --- a/apps/meteor/client/views/omnichannel/agents/RemoveAgentButton.tsx +++ b/apps/meteor/client/views/omnichannel/agents/RemoveAgentButton.tsx @@ -14,7 +14,7 @@ type RemoveAgentButtonProps = { }; const RemoveAgentButton = ({ _id, reload }: RemoveAgentButtonProps): ReactElement => { - const deleteAction = useEndpointAction('DELETE', `/v1/livechat/users/agent/${_id}`); + const deleteAction = useEndpointAction('DELETE', '/v1/livechat/users/agent/:_id', { keys: { _id } }); const setModal = useSetModal(); const dispatchToastMessage = useToastMessageDispatch(); const t = useTranslation(); diff --git a/apps/meteor/client/views/omnichannel/contactHistory/MessageList/useHistoryMessageList.ts b/apps/meteor/client/views/omnichannel/contactHistory/MessageList/useHistoryMessageList.ts index dbfd19c7b4ec..cd231b84e8dd 100644 --- a/apps/meteor/client/views/omnichannel/contactHistory/MessageList/useHistoryMessageList.ts +++ b/apps/meteor/client/views/omnichannel/contactHistory/MessageList/useHistoryMessageList.ts @@ -20,7 +20,7 @@ export const useHistoryMessageList = ( const [itemsList, setItemsList] = useState(() => new MessageList()); const reload = useCallback(() => setItemsList(new MessageList()), []); - const getMessages = useEndpoint('GET', `/v1/livechat/${options.roomId}/messages`); + const getMessages = useEndpoint('GET', '/v1/livechat/:rid/messages', { rid: options.roomId }); useComponentDidUpdate(() => { options && reload(); diff --git a/apps/meteor/client/views/omnichannel/contactHistory/useHistoryList.ts b/apps/meteor/client/views/omnichannel/contactHistory/useHistoryList.ts index a3b5085a2689..f62af76d3d94 100644 --- a/apps/meteor/client/views/omnichannel/contactHistory/useHistoryList.ts +++ b/apps/meteor/client/views/omnichannel/contactHistory/useHistoryList.ts @@ -5,6 +5,7 @@ import { useCallback, useState } from 'react'; import { useScrollableRecordList } from '../../../hooks/lists/useScrollableRecordList'; import { useComponentDidUpdate } from '../../../hooks/useComponentDidUpdate'; import { RecordList } from '../../../lib/lists/RecordList'; +import { mapMessageFromApi } from '../../../lib/utils/mapMessageFromApi'; type HistoryListOptions = { filter: string; @@ -22,7 +23,10 @@ export const useHistoryList = ( const [itemsList, setItemsList] = useState(() => new RecordList()); const reload = useCallback(() => setItemsList(new RecordList()), []); - const getHistory = useEndpoint('GET', `/v1/livechat/visitors.searchChats/room/${options.roomId}/visitor/${options.visitorId}`); + const getHistory = useEndpoint('GET', '/v1/livechat/visitors.searchChats/room/:roomId/visitor/:visitorId', { + roomId: options.roomId, + visitorId: options.visitorId, + }); useComponentDidUpdate(() => { options && reload(); @@ -38,10 +42,13 @@ export const useHistoryList = ( count: end + start, }); return { - items: history.map((history: any) => ({ + items: history.map((history) => ({ ...history, ts: new Date(history.ts), _updatedAt: new Date(history.ts), + closedAt: history.closedAt ? new Date(history.closedAt) : undefined, + servedBy: history.servedBy ? { ...history.servedBy, ts: new Date(history.servedBy.ts) } : undefined, + closingMessage: history.closingMessage ? mapMessageFromApi(history.closingMessage) : undefined, })), itemCount: total, }; diff --git a/apps/meteor/client/views/omnichannel/departments/AddAgent.js b/apps/meteor/client/views/omnichannel/departments/AddAgent.js index a720bbee36e9..b2964ae5bbba 100644 --- a/apps/meteor/client/views/omnichannel/departments/AddAgent.js +++ b/apps/meteor/client/views/omnichannel/departments/AddAgent.js @@ -9,7 +9,7 @@ import { useEndpointAction } from '../../../hooks/useEndpointAction'; function AddAgent({ agentList, setAgentsAdded, setAgentList, ...props }) { const t = useTranslation(); const [userId, setUserId] = useState(); - const getAgent = useEndpointAction('GET', `/v1/livechat/users/agent/${userId}`); + const getAgent = useEndpointAction('GET', '/v1/livechat/users/agent/:_id', { keys: { _id: userId } }); const dispatchToastMessage = useToastMessageDispatch(); const handleAgent = useMutableCallback((e) => setUserId(e)); diff --git a/apps/meteor/client/views/omnichannel/departments/RemoveDepartmentButton.js b/apps/meteor/client/views/omnichannel/departments/RemoveDepartmentButton.js index 927d5c629e8e..8d1f5b02cff3 100644 --- a/apps/meteor/client/views/omnichannel/departments/RemoveDepartmentButton.js +++ b/apps/meteor/client/views/omnichannel/departments/RemoveDepartmentButton.js @@ -7,7 +7,7 @@ import GenericModal from '../../../components/GenericModal'; import { useEndpointAction } from '../../../hooks/useEndpointAction'; function RemoveDepartmentButton({ _id, reload }) { - const deleteAction = useEndpointAction('DELETE', `/v1/livechat/department/${_id}`); + const deleteAction = useEndpointAction('DELETE', '/v1/livechat/department/:_id', { keys: { _id } }); const setModal = useSetModal(); const dispatchToastMessage = useToastMessageDispatch(); const t = useTranslation(); diff --git a/apps/meteor/client/views/omnichannel/directory/CallsContextualBarDirectory.tsx b/apps/meteor/client/views/omnichannel/directory/CallsContextualBarDirectory.tsx index 085f3f022604..d1620f4fe0b5 100644 --- a/apps/meteor/client/views/omnichannel/directory/CallsContextualBarDirectory.tsx +++ b/apps/meteor/client/views/omnichannel/directory/CallsContextualBarDirectory.tsx @@ -32,7 +32,7 @@ const CallsContextualBarDirectory: FC = () => { [id, token], ); - const { value: data, phase: state, error } = useEndpointData(`/v1/voip/room`, query); + const { value: data, phase: state, error } = useEndpointData(`/v1/voip/room`, { params: query }); if (bar === 'view' && id) { return ; diff --git a/apps/meteor/client/views/omnichannel/directory/ChatsContextualBar.tsx b/apps/meteor/client/views/omnichannel/directory/ChatsContextualBar.tsx index ac6f7f9bdbda..05018b6c5c1e 100644 --- a/apps/meteor/client/views/omnichannel/directory/ChatsContextualBar.tsx +++ b/apps/meteor/client/views/omnichannel/directory/ChatsContextualBar.tsx @@ -38,7 +38,7 @@ const ChatsContextualBar: FC<{ chatReload?: () => void }> = ({ chatReload }) => [id], ); - const { value: data, phase: state, error, reload: reloadInfo } = useEndpointData(`/v1/rooms.info`, query); + const { value: data, phase: state, error, reload: reloadInfo } = useEndpointData(`/v1/rooms.info`, { params: query }); if (bar === 'view' && id) { return ; diff --git a/apps/meteor/client/views/omnichannel/directory/calls/CallTable.tsx b/apps/meteor/client/views/omnichannel/directory/calls/CallTable.tsx index f79107a65aab..f666ea310196 100644 --- a/apps/meteor/client/views/omnichannel/directory/calls/CallTable.tsx +++ b/apps/meteor/client/views/omnichannel/directory/calls/CallTable.tsx @@ -75,7 +75,7 @@ const CallTable: FC = () => { ); }); - const { value: data } = useEndpointData('/v1/voip/rooms', query); + const { value: data } = useEndpointData('/v1/voip/rooms', { params: query }); const header = useMemo( () => diff --git a/apps/meteor/client/views/omnichannel/directory/contacts/ContactTable.tsx b/apps/meteor/client/views/omnichannel/directory/contacts/ContactTable.tsx index 7e9aea9fd7a1..620ae7ef4869 100644 --- a/apps/meteor/client/views/omnichannel/directory/contacts/ContactTable.tsx +++ b/apps/meteor/client/views/omnichannel/directory/contacts/ContactTable.tsx @@ -68,7 +68,7 @@ function ContactTable({ setContactReload }: ContactTableProps): ReactElement { }), ); - const { reload, ...result } = useEndpointData('/v1/livechat/visitors.search', query); + const { reload, ...result } = useEndpointData('/v1/livechat/visitors.search', { params: query }); useEffect(() => { setContactReload(() => reload); diff --git a/apps/meteor/client/views/omnichannel/managers/AddManager.tsx b/apps/meteor/client/views/omnichannel/managers/AddManager.tsx index d06942fcbb88..4d846fc37ef1 100644 --- a/apps/meteor/client/views/omnichannel/managers/AddManager.tsx +++ b/apps/meteor/client/views/omnichannel/managers/AddManager.tsx @@ -11,13 +11,13 @@ const AddManager = ({ reload }: { reload: () => void }): ReactElement => { const t = useTranslation(); const [username, setUsername] = useState(''); - const saveAction = useEndpointAction('POST', '/v1/livechat/users/manager', { username }); + const saveAction = useEndpointAction('POST', '/v1/livechat/users/manager'); const handleSave = useMutableCallback(async () => { if (!username) { return; } - const result = await saveAction(); + const result = await saveAction({ username }); if (!result?.success) { return; } diff --git a/apps/meteor/client/views/omnichannel/managers/ManagersRoute.tsx b/apps/meteor/client/views/omnichannel/managers/ManagersRoute.tsx index 4d68db0f33a2..6e3574b8cd0e 100644 --- a/apps/meteor/client/views/omnichannel/managers/ManagersRoute.tsx +++ b/apps/meteor/client/views/omnichannel/managers/ManagersRoute.tsx @@ -43,7 +43,7 @@ const ManagersRoute = (): ReactElement => { 500, ); - const { reload, ...result } = useEndpointData('/v1/livechat/users/manager', query); + const { reload, ...result } = useEndpointData('/v1/livechat/users/manager', { params: query }); const canViewManagers = usePermission('manage-livechat-managers'); if (!canViewManagers) { diff --git a/apps/meteor/client/views/omnichannel/managers/RemoveManagerButton.tsx b/apps/meteor/client/views/omnichannel/managers/RemoveManagerButton.tsx index 3e420ab56014..7b591446eb80 100644 --- a/apps/meteor/client/views/omnichannel/managers/RemoveManagerButton.tsx +++ b/apps/meteor/client/views/omnichannel/managers/RemoveManagerButton.tsx @@ -9,7 +9,7 @@ import { useEndpointAction } from '../../../hooks/useEndpointAction'; const RemoveManagerButton = ({ _id, reload }: { _id: string; reload: () => void }): ReactElement => { const t = useTranslation(); - const deleteAction = useEndpointAction('DELETE', `/v1/livechat/users/manager/${_id}`); + const deleteAction = useEndpointAction('DELETE', '/v1/livechat/users/manager/:_id', { keys: { _id } }); const setModal = useSetModal(); const dispatchToastMessage = useToastMessageDispatch(); diff --git a/apps/meteor/client/views/omnichannel/queueList/index.tsx b/apps/meteor/client/views/omnichannel/queueList/index.tsx index 541f3d1b676e..856aa659641f 100644 --- a/apps/meteor/client/views/omnichannel/queueList/index.tsx +++ b/apps/meteor/client/views/omnichannel/queueList/index.tsx @@ -104,7 +104,7 @@ const QueueList = (): ReactElement => { const debouncedParams = useDebouncedValue(params, 500); const debouncedSort = useDebouncedValue(sort, 500); const query = useQuery(debouncedParams, debouncedSort); - const { value: data } = useEndpointData('/v1/livechat/queue', query); + const { value: data } = useEndpointData('/v1/livechat/queue', { params: query }); return ( diff --git a/apps/meteor/client/views/room/Header/ParentTeam.tsx b/apps/meteor/client/views/room/Header/ParentTeam.tsx index 88b6f8918e10..8c8119995757 100644 --- a/apps/meteor/client/views/room/Header/ParentTeam.tsx +++ b/apps/meteor/client/views/room/Header/ParentTeam.tsx @@ -25,15 +25,11 @@ const ParentTeam = ({ room }: ParentTeamProps): ReactElement | null => { throw new Error('invalid uid'); } - const { value, phase } = useEndpointData( - '/v1/teams.info', - useMemo(() => ({ teamId }), [teamId]), - ); + const { value, phase } = useEndpointData('/v1/teams.info', { params: useMemo(() => ({ teamId }), [teamId]) }); - const { value: userTeams, phase: userTeamsPhase } = useEndpointData( - '/v1/users.listTeams', - useMemo(() => ({ userId }), [userId]), - ); + const { value: userTeams, phase: userTeamsPhase } = useEndpointData('/v1/users.listTeams', { + params: useMemo(() => ({ userId }), [userId]), + }); const belongsToTeam = userTeams?.teams?.find((team) => team._id === teamId) || false; const isTeamPublic = value?.teamInfo.type === TEAM_TYPE.PUBLIC; diff --git a/apps/meteor/client/views/room/UserCard/UserCardWithData.tsx b/apps/meteor/client/views/room/UserCard/UserCardWithData.tsx index 497bfbaf910e..fd632bf8dde4 100644 --- a/apps/meteor/client/views/room/UserCard/UserCardWithData.tsx +++ b/apps/meteor/client/views/room/UserCard/UserCardWithData.tsx @@ -28,7 +28,7 @@ const UserCardWithData = ({ username, onClose, target, open, rid }: UserCardWith const showRealNames = useSetting('UI_Use_Real_Name'); const query = useMemo(() => ({ username }), [username]); - const { value: data, phase: state } = useEndpointData('/v1/users.info', query); + const { value: data, phase: state } = useEndpointData('/v1/users.info', { params: query }); ref.current = target; diff --git a/apps/meteor/client/views/room/contextualBar/AutoTranslate/AutoTranslateWithData.tsx b/apps/meteor/client/views/room/contextualBar/AutoTranslate/AutoTranslateWithData.tsx index 6b5498dfbcb7..0d18e1eeeb8a 100644 --- a/apps/meteor/client/views/room/contextualBar/AutoTranslate/AutoTranslateWithData.tsx +++ b/apps/meteor/client/views/room/contextualBar/AutoTranslate/AutoTranslateWithData.tsx @@ -4,7 +4,7 @@ import { useUserSubscription, useLanguage } from '@rocket.chat/ui-contexts'; import type { ReactElement } from 'react'; import React, { useMemo, useEffect, useState, memo } from 'react'; -import { useEndpointActionExperimental } from '../../../../hooks/useEndpointActionExperimental'; +import { useEndpointAction } from '../../../../hooks/useEndpointAction'; import { useEndpointData } from '../../../../hooks/useEndpointData'; import { useTabBarClose } from '../../contexts/ToolboxContext'; import AutoTranslate from './AutoTranslate'; @@ -14,12 +14,11 @@ const AutoTranslateWithData = ({ rid }: { rid: IRoom['_id'] }): ReactElement => const userLanguage = useLanguage(); const subscription = useUserSubscription(rid); const [currentLanguage, setCurrentLanguage] = useState(subscription?.autoTranslateLanguage ?? ''); - const saveSettings = useEndpointActionExperimental('POST', '/v1/autotranslate.saveSettings'); + const saveSettings = useEndpointAction('POST', '/v1/autotranslate.saveSettings'); - const { value: translateData } = useEndpointData( - '/v1/autotranslate.getSupportedLanguages', - useMemo(() => ({ targetLanguage: userLanguage }), [userLanguage]), - ); + const { value: translateData } = useEndpointData('/v1/autotranslate.getSupportedLanguages', { + params: useMemo(() => ({ targetLanguage: userLanguage }), [userLanguage]), + }); const handleChangeLanguage = useMutableCallback((value) => { setCurrentLanguage(value); diff --git a/apps/meteor/client/views/room/contextualBar/Info/EditRoomInfo/EditChannel.js b/apps/meteor/client/views/room/contextualBar/Info/EditRoomInfo/EditChannel.js index 239a122d2c32..a728050ca4eb 100644 --- a/apps/meteor/client/views/room/contextualBar/Info/EditRoomInfo/EditChannel.js +++ b/apps/meteor/client/views/room/contextualBar/Info/EditRoomInfo/EditChannel.js @@ -35,7 +35,7 @@ import GenericModal from '../../../../../components/GenericModal'; import RawText from '../../../../../components/RawText'; import VerticalBar from '../../../../../components/VerticalBar'; import RoomAvatarEditor from '../../../../../components/avatar/RoomAvatarEditor'; -import { useEndpointActionExperimental } from '../../../../../hooks/useEndpointActionExperimental'; +import { useEndpointAction } from '../../../../../hooks/useEndpointAction'; import { useForm } from '../../../../../hooks/useForm'; import { roomCoordinator } from '../../../../../lib/rooms/roomCoordinator'; @@ -239,8 +239,10 @@ function EditChannel({ room, onClickClose, onClickBack }) { const changeArchivation = archived !== !!room.archived; const archiveSelector = room.archived ? 'unarchive' : 'archive'; const archiveMessage = room.archived ? 'Room_has_been_unarchived' : 'Room_has_been_archived'; - const saveAction = useEndpointActionExperimental('POST', '/v1/rooms.saveRoomSettings', t('Room_updated_successfully')); - const archiveAction = useEndpointActionExperimental('POST', '/v1/rooms.changeArchivationState', t(archiveMessage)); + const saveAction = useEndpointAction('POST', '/v1/rooms.saveRoomSettings', { + successMessage: t('Room_updated_successfully'), + }); + const archiveAction = useEndpointAction('POST', '/v1/rooms.changeArchivationState', { successMessage: t(archiveMessage) }); const handleSave = useMutableCallback(async () => { const { joinCodeRequired, hideSysMes, ...data } = saveData.current; diff --git a/apps/meteor/client/views/room/contextualBar/Info/RoomInfo/RoomInfoWithData.js b/apps/meteor/client/views/room/contextualBar/Info/RoomInfo/RoomInfoWithData.js index 44abc20a5de3..a361a60e975c 100644 --- a/apps/meteor/client/views/room/contextualBar/Info/RoomInfo/RoomInfoWithData.js +++ b/apps/meteor/client/views/room/contextualBar/Info/RoomInfo/RoomInfoWithData.js @@ -18,7 +18,7 @@ import { RoomManager } from '../../../../../../app/ui-utils/client'; import { UiTextContext } from '../../../../../../definition/IRoomTypeConfig'; import GenericModal from '../../../../../components/GenericModal'; import WarningModal from '../../../../../components/WarningModal'; -import { useEndpointActionExperimental } from '../../../../../hooks/useEndpointActionExperimental'; +import { useEndpointAction } from '../../../../../hooks/useEndpointAction'; import * as Federation from '../../../../../lib/federation/Federation'; import { roomCoordinator } from '../../../../../lib/rooms/roomCoordinator'; import { useTabBarClose } from '../../../contexts/ToolboxContext'; @@ -65,12 +65,10 @@ const RoomInfoWithData = ({ rid, openEditing, onClickBack, onEnterRoom, resetSta const leaveRoom = useMethod('leaveRoom'); const router = useRoute('home'); - const moveChannelToTeam = useEndpointActionExperimental('POST', '/v1/teams.addRooms', t('Rooms_added_successfully')); - const convertRoomToTeam = useEndpointActionExperimental( - 'POST', - type === 'c' ? '/v1/channels.convertToTeam' : '/v1/groups.convertToTeam', - t('Success'), - ); + const moveChannelToTeam = useEndpointAction('POST', '/v1/teams.addRooms', { successMessage: t('Rooms_added_successfully') }); + const convertRoomToTeam = useEndpointAction('POST', type === 'c' ? '/v1/channels.convertToTeam' : '/v1/groups.convertToTeam', { + successMessage: t('Success'), + }); const isFederated = isRoomFederated(room); const hasPermissionToDelete = usePermission(type === 'c' ? 'delete-c' : 'delete-p', rid); diff --git a/apps/meteor/client/views/room/contextualBar/NotificationPreferences/NotificationPreferencesWithData.tsx b/apps/meteor/client/views/room/contextualBar/NotificationPreferences/NotificationPreferencesWithData.tsx index b2cd71518c2e..b451527ceedc 100644 --- a/apps/meteor/client/views/room/contextualBar/NotificationPreferences/NotificationPreferencesWithData.tsx +++ b/apps/meteor/client/views/room/contextualBar/NotificationPreferences/NotificationPreferencesWithData.tsx @@ -3,7 +3,7 @@ import { useCustomSound, useUserSubscription, useTranslation } from '@rocket.cha import type { ReactElement } from 'react'; import React, { memo } from 'react'; -import { useEndpointActionExperimental } from '../../../../hooks/useEndpointActionExperimental'; +import { useEndpointAction } from '../../../../hooks/useEndpointAction'; import { useForm } from '../../../../hooks/useForm'; import { useTabBarClose } from '../../contexts/ToolboxContext'; import NotificationPreferences from './NotificationPreferences'; @@ -26,7 +26,9 @@ const NotificationPreferencesWithData = ({ rid }: { rid: string }): ReactElement const customSound = useCustomSound(); const handleClose = useTabBarClose(); - const saveSettings = useEndpointActionExperimental('POST', '/v1/rooms.saveNotification', t('Room_updated_successfully')); + const saveSettings = useEndpointAction('POST', '/v1/rooms.saveNotification', { + successMessage: t('Room_updated_successfully'), + }); const { values, handlers, hasUnsavedChanges, commit } = useForm({ turnOn: !subscription?.disableNotifications, diff --git a/apps/meteor/client/views/room/contextualBar/UserInfo/UserInfoWithData.tsx b/apps/meteor/client/views/room/contextualBar/UserInfo/UserInfoWithData.tsx index 41c2ac6dc93b..a16d0cb00a8d 100644 --- a/apps/meteor/client/views/room/contextualBar/UserInfo/UserInfoWithData.tsx +++ b/apps/meteor/client/views/room/contextualBar/UserInfo/UserInfoWithData.tsx @@ -31,10 +31,7 @@ const UserInfoWithData = ({ uid, username, rid, onClose, onClickBack }: UserInfo value: data, phase: state, error, - } = useEndpointData( - '/v1/users.info', - useMemo(() => ({ userId: uid, username }), [uid, username]), - ); + } = useEndpointData('/v1/users.info', { params: useMemo(() => ({ userId: uid, username }), [uid, username]) }); const isLoading = state === AsyncStatePhase.LOADING; diff --git a/apps/meteor/client/views/room/contextualBar/VideoConference/VideoConfPopups/VideoConfPopup/IncomingPopup.tsx b/apps/meteor/client/views/room/contextualBar/VideoConference/VideoConfPopups/VideoConfPopup/IncomingPopup.tsx index 3d364fd9bb3a..44727aae98c9 100644 --- a/apps/meteor/client/views/room/contextualBar/VideoConference/VideoConfPopups/VideoConfPopup/IncomingPopup.tsx +++ b/apps/meteor/client/views/room/contextualBar/VideoConference/VideoConfPopups/VideoConfPopup/IncomingPopup.tsx @@ -37,7 +37,7 @@ const IncomingPopup = ({ id, room, position, onClose, onMute, onConfirm }: Incom const setPreferences = useVideoConfSetPreferences(); const params = useMemo(() => ({ callId: id }), [id]); - const { phase, value } = useEndpointData('/v1/video-conference.info', params); + const { phase, value } = useEndpointData('/v1/video-conference.info', { params }); const showMic = Boolean(value?.capabilities?.mic); const showCam = Boolean(value?.capabilities?.cam); diff --git a/apps/meteor/client/views/room/hooks/useUserInfoActions/actions/useChangeLeaderAction.ts b/apps/meteor/client/views/room/hooks/useUserInfoActions/actions/useChangeLeaderAction.ts index 74a435d152eb..14702d9fd58a 100644 --- a/apps/meteor/client/views/room/hooks/useUserInfoActions/actions/useChangeLeaderAction.ts +++ b/apps/meteor/client/views/room/hooks/useUserInfoActions/actions/useChangeLeaderAction.ts @@ -4,7 +4,7 @@ import { escapeHTML } from '@rocket.chat/string-helpers'; import { useTranslation, usePermission, useUserRoom } from '@rocket.chat/ui-contexts'; import { useMemo } from 'react'; -import { useEndpointActionExperimental } from '../../../../../hooks/useEndpointActionExperimental'; +import { useEndpointAction } from '../../../../../hooks/useEndpointAction'; import { roomCoordinator } from '../../../../../lib/rooms/roomCoordinator'; import type { Action } from '../../../../hooks/useActionSpread'; import { getRoomDirectives } from '../../../lib/getRoomDirectives'; @@ -30,11 +30,9 @@ export const useChangeLeaderAction = (user: Pick, rid const changeLeaderMessage = isLeader ? 'User__username__removed_from__room_name__leaders' : 'User__username__is_now_a_leader_of__room_name_'; - const changeLeader = useEndpointActionExperimental( - 'POST', - `${endpointPrefix}.${changeLeaderEndpoint}`, - t(changeLeaderMessage, { username: user.username, room_name: roomName }), - ); + const changeLeader = useEndpointAction('POST', `${endpointPrefix}.${changeLeaderEndpoint}`, { + successMessage: t(changeLeaderMessage, { username: user.username, room_name: roomName }), + }); const changeLeaderAction = useMutableCallback(() => changeLeader({ roomId: rid, userId: uid })); const changeLeaderOption = useMemo( () => diff --git a/apps/meteor/client/views/room/hooks/useUserInfoActions/actions/useChangeModeratorAction.ts b/apps/meteor/client/views/room/hooks/useUserInfoActions/actions/useChangeModeratorAction.ts index 4b34a9f35f25..dc800e6405ef 100644 --- a/apps/meteor/client/views/room/hooks/useUserInfoActions/actions/useChangeModeratorAction.ts +++ b/apps/meteor/client/views/room/hooks/useUserInfoActions/actions/useChangeModeratorAction.ts @@ -4,7 +4,7 @@ import { escapeHTML } from '@rocket.chat/string-helpers'; import { useTranslation, usePermission, useUserRoom } from '@rocket.chat/ui-contexts'; import { useMemo } from 'react'; -import { useEndpointActionExperimental } from '../../../../../hooks/useEndpointActionExperimental'; +import { useEndpointAction } from '../../../../../hooks/useEndpointAction'; import { roomCoordinator } from '../../../../../lib/rooms/roomCoordinator'; import type { Action } from '../../../../hooks/useActionSpread'; import { getRoomDirectives } from '../../../lib/getRoomDirectives'; @@ -31,11 +31,9 @@ export const useChangeModeratorAction = (user: Pick, const changeModeratorMessage = isModerator ? 'User__username__removed_from__room_name__moderators' : 'User__username__is_now_a_moderator_of__room_name_'; - const changeModerator = useEndpointActionExperimental( - 'POST', - `${endpointPrefix}.${changeModeratorEndpoint}`, - t(changeModeratorMessage, { username: user.username, room_name: roomName }), - ); + const changeModerator = useEndpointAction('POST', `${endpointPrefix}.${changeModeratorEndpoint}`, { + successMessage: t(changeModeratorMessage, { username: user.username, room_name: roomName }), + }); const changeModeratorAction = useMutableCallback(() => changeModerator({ roomId: rid, userId: uid })); const changeModeratorOption = useMemo( () => diff --git a/apps/meteor/client/views/room/hooks/useUserInfoActions/actions/useChangeOwnerAction.tsx b/apps/meteor/client/views/room/hooks/useUserInfoActions/actions/useChangeOwnerAction.tsx index 2a8eea879213..650d4bae4a81 100644 --- a/apps/meteor/client/views/room/hooks/useUserInfoActions/actions/useChangeOwnerAction.tsx +++ b/apps/meteor/client/views/room/hooks/useUserInfoActions/actions/useChangeOwnerAction.tsx @@ -4,7 +4,7 @@ import { escapeHTML } from '@rocket.chat/string-helpers'; import { useTranslation, usePermission, useUserRoom } from '@rocket.chat/ui-contexts'; import { useMemo } from 'react'; -import { useEndpointActionExperimental } from '../../../../../hooks/useEndpointActionExperimental'; +import { useEndpointAction } from '../../../../../hooks/useEndpointAction'; import { roomCoordinator } from '../../../../../lib/rooms/roomCoordinator'; import type { Action } from '../../../../hooks/useActionSpread'; import { getRoomDirectives } from '../../../lib/getRoomDirectives'; @@ -29,11 +29,9 @@ export const useChangeOwnerAction = (user: Pick, rid: const changeOwnerEndpoint = isOwner ? 'removeOwner' : 'addOwner'; const changeOwnerMessage = isOwner ? 'User__username__removed_from__room_name__owners' : 'User__username__is_now_an_owner_of__room_name_'; - const changeOwner = useEndpointActionExperimental( - 'POST', - `${endpointPrefix}.${changeOwnerEndpoint}`, - t(changeOwnerMessage, { username: user.username, room_name: roomName }), - ); + const changeOwner = useEndpointAction('POST', `${endpointPrefix}.${changeOwnerEndpoint}` as const, { + successMessage: t(changeOwnerMessage, { username: user.username, room_name: roomName }), + }); const changeOwnerAction = useMutableCallback(async () => changeOwner({ roomId: rid, userId: uid })); const changeOwnerOption = useMemo( diff --git a/apps/meteor/client/views/room/hooks/useUserInfoActions/actions/useRemoveUserAction.tsx b/apps/meteor/client/views/room/hooks/useUserInfoActions/actions/useRemoveUserAction.tsx index 1bd5c0223944..159384406598 100644 --- a/apps/meteor/client/views/room/hooks/useUserInfoActions/actions/useRemoveUserAction.tsx +++ b/apps/meteor/client/views/room/hooks/useUserInfoActions/actions/useRemoveUserAction.tsx @@ -7,7 +7,7 @@ import { usePermission, useSetModal, useTranslation, useUser, useUserRoom } from import React, { useMemo } from 'react'; import GenericModal from '../../../../../components/GenericModal'; -import { useEndpointActionExperimental } from '../../../../../hooks/useEndpointActionExperimental'; +import { useEndpointAction } from '../../../../../hooks/useEndpointAction'; import * as Federation from '../../../../../lib/federation/Federation'; import { roomCoordinator } from '../../../../../lib/rooms/roomCoordinator'; import type { Action } from '../../../../hooks/useActionSpread'; @@ -36,8 +36,12 @@ export const useRemoveUserAction = (user: Pick, rid: const endpointPrefix = room.t === 'p' ? '/v1/groups' : '/v1/channels'; const { roomCanRemove } = getRoomDirectives(room); - const removeFromTeam = useEndpointActionExperimental('POST', '/v1/teams.removeMember', t('User_has_been_removed_from_team')); - const removeFromRoom = useEndpointActionExperimental('POST', `${endpointPrefix}.kick`, t('User_has_been_removed_from_s', roomName)); + const removeFromTeam = useEndpointAction('POST', '/v1/teams.removeMember', { + successMessage: t('User_has_been_removed_from_team'), + }); + const removeFromRoom = useEndpointAction('POST', `${endpointPrefix}.kick`, { + successMessage: t('User_has_been_removed_from_s', roomName), + }); const removeUserOptionAction = useMutableCallback(() => { const handleRemoveFromTeam = async (rooms: IRoom[]): Promise => { diff --git a/apps/meteor/client/views/teams/ConvertToChannelModal/ConvertToChannelModal.tsx b/apps/meteor/client/views/teams/ConvertToChannelModal/ConvertToChannelModal.tsx index ead17b842583..7acf1a337a04 100644 --- a/apps/meteor/client/views/teams/ConvertToChannelModal/ConvertToChannelModal.tsx +++ b/apps/meteor/client/views/teams/ConvertToChannelModal/ConvertToChannelModal.tsx @@ -20,10 +20,9 @@ type ConvertToChannelModalProps = { const ConvertToChannelModal: FC = ({ onClose, onCancel, onConfirm, teamId, userId }) => { const t = useTranslation(); - const { value, phase } = useEndpointData( - '/v1/teams.listRoomsOfUser', - useMemo(() => ({ teamId, userId, canUserDelete: 'true' }), [teamId, userId]), - ); + const { value, phase } = useEndpointData('/v1/teams.listRoomsOfUser', { + params: useMemo(() => ({ teamId, userId, canUserDelete: 'true' }), [teamId, userId]), + }); if (phase === AsyncStatePhase.LOADING) { return ( diff --git a/apps/meteor/client/views/teams/contextualBar/channels/AddExistingModal/RoomsInput.tsx b/apps/meteor/client/views/teams/contextualBar/channels/AddExistingModal/RoomsInput.tsx index b3f7f0efbbb2..16926a211c20 100644 --- a/apps/meteor/client/views/teams/contextualBar/channels/AddExistingModal/RoomsInput.tsx +++ b/apps/meteor/client/views/teams/contextualBar/channels/AddExistingModal/RoomsInput.tsx @@ -27,7 +27,7 @@ const useRoomsAutoComplete = ( }), [name], ); - const { value: data } = useEndpointData('/v1/rooms.autocomplete.availableForTeams', params); + const { value: data } = useEndpointData('/v1/rooms.autocomplete.availableForTeams', { params }); const options = useMemo(() => { if (!data) { diff --git a/apps/meteor/client/views/teams/contextualBar/channels/RoomActions.js b/apps/meteor/client/views/teams/contextualBar/channels/RoomActions.js index 4f332441ccad..d0d69e91a696 100644 --- a/apps/meteor/client/views/teams/contextualBar/channels/RoomActions.js +++ b/apps/meteor/client/views/teams/contextualBar/channels/RoomActions.js @@ -3,7 +3,7 @@ import { useMutableCallback } from '@rocket.chat/fuselage-hooks'; import { useSetModal, useToastMessageDispatch, usePermission, useTranslation } from '@rocket.chat/ui-contexts'; import React, { useMemo } from 'react'; -import { useEndpointActionExperimental } from '../../../../hooks/useEndpointActionExperimental'; +import { useEndpointAction } from '../../../../hooks/useEndpointAction'; import { roomCoordinator } from '../../../../lib/rooms/roomCoordinator'; import ConfirmationModal from './ConfirmationModal'; @@ -30,13 +30,11 @@ const RoomActions = ({ room, reload }) => { const canEditTeamChannel = usePermission('edit-team-channel', rid); const canRemoveTeamChannel = usePermission('remove-team-channel', rid); - const updateRoomEndpoint = useEndpointActionExperimental('POST', '/v1/teams.updateRoom'); - const removeRoomEndpoint = useEndpointActionExperimental('POST', '/v1/teams.removeRoom', t('Room_has_been_removed')); - const deleteRoomEndpoint = useEndpointActionExperimental( - 'POST', - room.t === 'c' ? '/v1/channels.delete' : '/v1/groups.delete', - t('Room_has_been_deleted'), - ); + const updateRoomEndpoint = useEndpointAction('POST', '/v1/teams.updateRoom'); + const removeRoomEndpoint = useEndpointAction('POST', '/v1/teams.removeRoom', { successMessage: t('Room_has_been_removed') }); + const deleteRoomEndpoint = useEndpointAction('POST', room.t === 'c' ? '/v1/channels.delete' : '/v1/groups.delete', { + successMessage: t('Room_has_been_deleted'), + }); const RemoveFromTeamAction = useReactModal(ConfirmationModal, { onConfirmAction: async () => { diff --git a/apps/meteor/client/views/teams/contextualBar/info/Delete/DeleteTeamModalWithRooms.tsx b/apps/meteor/client/views/teams/contextualBar/info/Delete/DeleteTeamModalWithRooms.tsx index 6c20fa0de02e..0eab29e69758 100644 --- a/apps/meteor/client/views/teams/contextualBar/info/Delete/DeleteTeamModalWithRooms.tsx +++ b/apps/meteor/client/views/teams/contextualBar/info/Delete/DeleteTeamModalWithRooms.tsx @@ -16,10 +16,7 @@ type DeleteTeamModalWithRoomsProps = { }; const DeleteTeamModalWithRooms = ({ teamId, onConfirm, onCancel }: DeleteTeamModalWithRoomsProps): ReactElement => { - const { value, phase } = useEndpointData( - '/v1/teams.listRooms', - useMemo(() => ({ teamId }), [teamId]), - ); + const { value, phase } = useEndpointData('/v1/teams.listRooms', { params: useMemo(() => ({ teamId }), [teamId]) }); const t = useTranslation(); diff --git a/apps/meteor/client/views/teams/contextualBar/info/TeamsInfoWithData.js b/apps/meteor/client/views/teams/contextualBar/info/TeamsInfoWithData.js index d55037b28ca9..04826342411d 100644 --- a/apps/meteor/client/views/teams/contextualBar/info/TeamsInfoWithData.js +++ b/apps/meteor/client/views/teams/contextualBar/info/TeamsInfoWithData.js @@ -14,7 +14,7 @@ import React, { useCallback } from 'react'; import { UiTextContext } from '../../../../../definition/IRoomTypeConfig'; import { GenericModalDoNotAskAgain } from '../../../../components/GenericModal'; import { useDontAskAgain } from '../../../../hooks/useDontAskAgain'; -import { useEndpointActionExperimental } from '../../../../hooks/useEndpointActionExperimental'; +import { useEndpointAction } from '../../../../hooks/useEndpointAction'; import { roomCoordinator } from '../../../../lib/rooms/roomCoordinator'; import { useTabBarClose, useTabBarOpen } from '../../../room/contexts/ToolboxContext'; import ConvertToChannelModal from '../../ConvertToChannelModal'; @@ -55,9 +55,9 @@ const TeamsInfoWithLogic = ({ room, openEditing }) => { const setModal = useSetModal(); const closeModal = useMutableCallback(() => setModal()); - const deleteTeam = useEndpointActionExperimental('POST', '/v1/teams.delete'); - const leaveTeam = useEndpointActionExperimental('POST', '/v1/teams.leave'); - const convertTeamToChannel = useEndpointActionExperimental('POST', '/v1/teams.convertToChannel'); + const deleteTeam = useEndpointAction('POST', '/v1/teams.delete'); + const leaveTeam = useEndpointAction('POST', '/v1/teams.leave'); + const convertTeamToChannel = useEndpointAction('POST', '/v1/teams.convertToChannel'); const hideTeam = useMethod('hideRoom'); diff --git a/apps/meteor/ee/client/audit/AuditPageBase.js b/apps/meteor/ee/client/audit/AuditPageBase.js index ca2540b98488..992bb07f6079 100644 --- a/apps/meteor/ee/client/audit/AuditPageBase.js +++ b/apps/meteor/ee/client/audit/AuditPageBase.js @@ -43,9 +43,7 @@ export const AuditPageBase = ({ handleType(type); }); - const eventStats = useEndpointAction('POST', '/v1/statistics.telemetry', { - params: [{ eventName: 'updateCounter', settingsId: 'Message_Auditing_Apply_Count', timestamp: Date.now() }], - }); + const eventStats = useEndpointAction('POST', '/v1/statistics.telemetry'); return ( @@ -93,7 +91,16 @@ export const AuditPageBase = ({ )} - diff --git a/apps/meteor/ee/client/hooks/useDeviceLogout.tsx b/apps/meteor/ee/client/hooks/useDeviceLogout.tsx index 5b1357f77474..0cc0df4630ac 100644 --- a/apps/meteor/ee/client/hooks/useDeviceLogout.tsx +++ b/apps/meteor/ee/client/hooks/useDeviceLogout.tsx @@ -1,5 +1,5 @@ import { useSetModal, useTranslation, useToastMessageDispatch, useRoute, useRouteParameter } from '@rocket.chat/ui-contexts'; -import React, { useCallback, useMemo } from 'react'; +import React, { useCallback } from 'react'; import GenericModal from '../../../client/components/GenericModal'; import { useEndpointAction } from '../../../client/hooks/useEndpointAction'; @@ -14,11 +14,7 @@ export const useDeviceLogout = ( const deviceManagementRouter = useRoute('device-management'); const routeId = useRouteParameter('id'); - const logoutDevice = useEndpointAction( - 'POST', - endpoint, - useMemo(() => ({ sessionId }), [sessionId]), - ); + const logoutDevice = useEndpointAction('POST', endpoint); const handleCloseContextualBar = useCallback((): void => deviceManagementRouter.push({}), [deviceManagementRouter]); @@ -30,7 +26,7 @@ export const useDeviceLogout = ( const handleLogoutDevice = async (): Promise => { try { - await logoutDevice(); + await logoutDevice({ sessionId }); onReload(); isContextualBarOpen && handleCloseContextualBar(); dispatchToastMessage({ type: 'success', message: t('Device_Logged_Out') }); @@ -55,7 +51,7 @@ export const useDeviceLogout = ( , ); }, - [t, logoutDevice, setModal, dispatchToastMessage, handleCloseContextualBar, isContextualBarOpen], + [setModal, t, logoutDevice, sessionId, isContextualBarOpen, handleCloseContextualBar, dispatchToastMessage], ); return handleLogoutDeviceModal; diff --git a/apps/meteor/ee/client/omnichannel/cannedResponses/CannedResponseEditWithData.tsx b/apps/meteor/ee/client/omnichannel/cannedResponses/CannedResponseEditWithData.tsx index 4e032dc460c5..c2295685454a 100644 --- a/apps/meteor/ee/client/omnichannel/cannedResponses/CannedResponseEditWithData.tsx +++ b/apps/meteor/ee/client/omnichannel/cannedResponses/CannedResponseEditWithData.tsx @@ -15,7 +15,7 @@ const CannedResponseEditWithData: FC<{ reload: () => void; totalDataReload: () => void; }> = ({ cannedResponseId, reload, totalDataReload }) => { - const { value: data, phase: state, error } = useEndpointData(`/v1/canned-responses/${cannedResponseId}`); + const { value: data, phase: state, error } = useEndpointData('/v1/canned-responses/:_id', { keys: { _id: cannedResponseId } }); const t = useTranslation(); diff --git a/apps/meteor/ee/client/omnichannel/cannedResponses/CannedResponseEditWithDepartmentData.tsx b/apps/meteor/ee/client/omnichannel/cannedResponses/CannedResponseEditWithDepartmentData.tsx index 2cc07e84b39f..6bbdc38c219d 100644 --- a/apps/meteor/ee/client/omnichannel/cannedResponses/CannedResponseEditWithDepartmentData.tsx +++ b/apps/meteor/ee/client/omnichannel/cannedResponses/CannedResponseEditWithDepartmentData.tsx @@ -19,7 +19,7 @@ const CannedResponseEditWithData: FC<{ totalDataReload: () => void; }> = ({ data, reload, totalDataReload }) => { const departmentId = useMemo(() => data?.cannedResponse?.departmentId, [data]) as string; - const { value: departmentData, phase: state, error } = useEndpointData(`/v1/livechat/department/${departmentId}`); + const { value: departmentData, phase: state, error } = useEndpointData('/v1/livechat/department/:_id', { keys: { _id: departmentId } }); const t = useTranslation(); diff --git a/apps/meteor/ee/client/omnichannel/cannedResponses/CannedResponsesRoute.tsx b/apps/meteor/ee/client/omnichannel/cannedResponses/CannedResponsesRoute.tsx index 9c6b1480cfbf..7fce6990c96c 100644 --- a/apps/meteor/ee/client/omnichannel/cannedResponses/CannedResponsesRoute.tsx +++ b/apps/meteor/ee/client/omnichannel/cannedResponses/CannedResponsesRoute.tsx @@ -104,7 +104,7 @@ const CannedResponsesRoute: FC = () => { [t], ); - const { value: data, reload } = useEndpointData('/v1/canned-responses', query); + const { value: data, reload } = useEndpointData('/v1/canned-responses', { params: query }); const { value: totalData, phase: totalDataPhase, reload: totalDataReload } = useEndpointData('/v1/canned-responses'); const getTime = useFormatDateAndTime(); diff --git a/apps/meteor/ee/client/omnichannel/tags/TagEditWithDepartmentData.tsx b/apps/meteor/ee/client/omnichannel/tags/TagEditWithDepartmentData.tsx index 037ba7fe61cc..327cb0477252 100644 --- a/apps/meteor/ee/client/omnichannel/tags/TagEditWithDepartmentData.tsx +++ b/apps/meteor/ee/client/omnichannel/tags/TagEditWithDepartmentData.tsx @@ -23,10 +23,9 @@ function TagEditWithDepartmentData({ data, title, ...props }: TagEditWithDepartm value: currentDepartments, phase: currentDepartmentsState, error: currentDepartmentsError, - } = useEndpointData( - '/v1/livechat/department.listByIds', - useMemo(() => ({ ids: data?.departments ? data.departments : [] }), [data]), - ); + } = useEndpointData('/v1/livechat/department.listByIds', { + params: useMemo(() => ({ ids: data?.departments ? data.departments : [] }), [data]), + }); if ([currentDepartmentsState].includes(AsyncStatePhase.LOADING)) { return ; diff --git a/apps/meteor/ee/client/omnichannel/units/UnitEditWithData.tsx b/apps/meteor/ee/client/omnichannel/units/UnitEditWithData.tsx index ff2ed2cffa99..1088fc3c730d 100644 --- a/apps/meteor/ee/client/omnichannel/units/UnitEditWithData.tsx +++ b/apps/meteor/ee/client/omnichannel/units/UnitEditWithData.tsx @@ -13,19 +13,19 @@ const UnitEditWithData: FC<{ title: string; reload: () => void; }> = function UnitEditWithData({ unitId, reload, title }) { - const { value: data, phase: state, error } = useEndpointData(`/v1/livechat/units/${unitId}`); + const { value: data, phase: state, error } = useEndpointData('/v1/livechat/units/:id', { keys: { id: unitId } }); const { value: unitMonitors, phase: unitMonitorsState, error: unitMonitorsError, - } = useEndpointData(`/v1/livechat/units/${unitId}/monitors`); + } = useEndpointData('/v1/livechat/units/:unitId/monitors', { keys: { unitId } }); const { value: unitDepartments, phase: unitDepartmentsState, error: unitDepartmentsError, - } = useEndpointData(`/v1/livechat/units/${unitId}/departments`); + } = useEndpointData('/v1/livechat/units/:unitId/departments', { keys: { unitId } }); const t = useTranslation(); diff --git a/apps/meteor/ee/client/views/account/deviceManagement/DeviceManagementAccountTable/DeviceManagementAccountTable.tsx b/apps/meteor/ee/client/views/account/deviceManagement/DeviceManagementAccountTable/DeviceManagementAccountTable.tsx index dc82b0594569..aaa2c04fc2f1 100644 --- a/apps/meteor/ee/client/views/account/deviceManagement/DeviceManagementAccountTable/DeviceManagementAccountTable.tsx +++ b/apps/meteor/ee/client/views/account/deviceManagement/DeviceManagementAccountTable/DeviceManagementAccountTable.tsx @@ -30,7 +30,7 @@ const DeviceManagementAccountTable = (): ReactElement => { [itemsPerPage, current, sortBy, sortDirection], ); - const { value: data, phase, error, reload } = useEndpointData('/v1/sessions/list', query); + const { value: data, phase, error, reload } = useEndpointData('/v1/sessions/list', { params: query }); const mediaQuery = useMediaQuery('(min-width: 1024px)'); diff --git a/apps/meteor/ee/client/views/admin/deviceManagement/DeviceManagementAdminTable/DeviceManagementAdminTable.tsx b/apps/meteor/ee/client/views/admin/deviceManagement/DeviceManagementAdminTable/DeviceManagementAdminTable.tsx index aed94ad87325..0218b41f7a6b 100644 --- a/apps/meteor/ee/client/views/admin/deviceManagement/DeviceManagementAdminTable/DeviceManagementAdminTable.tsx +++ b/apps/meteor/ee/client/views/admin/deviceManagement/DeviceManagementAdminTable/DeviceManagementAdminTable.tsx @@ -42,7 +42,7 @@ const DeviceManagementAdminTable = ({ reloadRef }: { reloadRef: MutableRefObject 500, ); - const { value: data, phase, error, reload } = useEndpointData('/v1/sessions/list.all', query); + const { value: data, phase, error, reload } = useEndpointData('/v1/sessions/list.all', { params: query }); useEffect(() => { reloadRef.current = reload; diff --git a/apps/meteor/ee/client/views/admin/deviceManagement/DeviceManagementInfo/DeviceManagementInfoWithData.tsx b/apps/meteor/ee/client/views/admin/deviceManagement/DeviceManagementInfo/DeviceManagementInfoWithData.tsx index 14052bc71e24..645de7126228 100644 --- a/apps/meteor/ee/client/views/admin/deviceManagement/DeviceManagementInfo/DeviceManagementInfoWithData.tsx +++ b/apps/meteor/ee/client/views/admin/deviceManagement/DeviceManagementInfo/DeviceManagementInfoWithData.tsx @@ -26,10 +26,7 @@ const DeviceInfoWithData = ({ deviceId, onReload }: { deviceId: string; onReload value: data, phase, error, - } = useEndpointData( - '/v1/sessions/info.admin', - useMemo(() => ({ sessionId: deviceId }), [deviceId]), - ); + } = useEndpointData('/v1/sessions/info.admin', { params: useMemo(() => ({ sessionId: deviceId }), [deviceId]) }); if (phase === AsyncStatePhase.LOADING) { return ( diff --git a/apps/meteor/ee/client/views/admin/engagementDashboard/EngagementDashboardRoute.tsx b/apps/meteor/ee/client/views/admin/engagementDashboard/EngagementDashboardRoute.tsx index f3992a2b0c79..29afa2b4a0f8 100644 --- a/apps/meteor/ee/client/views/admin/engagementDashboard/EngagementDashboardRoute.tsx +++ b/apps/meteor/ee/client/views/admin/engagementDashboard/EngagementDashboardRoute.tsx @@ -25,9 +25,7 @@ const EngagementDashboardRoute = (): ReactElement | null => { } }, [routeName, engagementDashboardRoute, tab]); - const eventStats = useEndpointAction('POST', '/v1/statistics.telemetry', { - params: [{ eventName: 'updateCounter', settingsId: 'Engagement_Dashboard_Load_Count' }], - }); + const eventStats = useEndpointAction('POST', '/v1/statistics.telemetry'); if (!isValidTab(tab)) { return null; @@ -37,7 +35,9 @@ const EngagementDashboardRoute = (): ReactElement | null => { return ; } - eventStats(); + eventStats({ + params: [{ eventName: 'updateCounter', settingsId: 'Engagement_Dashboard_Load_Count' }], + }); return engagementDashboardRoute.push({ tab })} />; }; diff --git a/ee/packages/ui-theming/package.json b/ee/packages/ui-theming/package.json index 962ccfec4855..c2f23243fbc0 100644 --- a/ee/packages/ui-theming/package.json +++ b/ee/packages/ui-theming/package.json @@ -57,5 +57,8 @@ "@rocket.chat/fuselage-hooks": "*", "@rocket.chat/icons": "*", "react": "~17.0.2" + }, + "volta": { + "extends": "../../../package.json" } } diff --git a/ee/packages/ui-theming/src/hooks/useSetLayoutSetting.ts b/ee/packages/ui-theming/src/hooks/useSetLayoutSetting.ts index 7ea5e4d4ced0..1810273bbfe7 100644 --- a/ee/packages/ui-theming/src/hooks/useSetLayoutSetting.ts +++ b/ee/packages/ui-theming/src/hooks/useSetLayoutSetting.ts @@ -1,5 +1,5 @@ import { useEndpoint } from '@rocket.chat/ui-contexts'; -export const useSetLayoutSetting = () => { - return useEndpoint('POST', '/v1/settings/Layout_Fuselage_Palette') as unknown as ({ value }: { value: string }) => void; +export const useSetLayoutSetting = (): (({ value }: { value: string }) => void) => { + return useEndpoint('POST', '/v1/settings/:_id', { _id: 'Layout_Fuselage_Palette' }); }; diff --git a/packages/ui-contexts/src/ServerContext/ServerContext.ts b/packages/ui-contexts/src/ServerContext/ServerContext.ts index 7297879f4b79..0180e93ea699 100644 --- a/packages/ui-contexts/src/ServerContext/ServerContext.ts +++ b/packages/ui-contexts/src/ServerContext/ServerContext.ts @@ -1,5 +1,5 @@ import type { IServerInfo, Serialized } from '@rocket.chat/core-typings'; -import type { Method, OperationParams, MatchPathPattern, OperationResult, PathFor } from '@rocket.chat/rest-typings'; +import type { Method, OperationParams, OperationResult, PathFor, PathPattern, UrlParams } from '@rocket.chat/rest-typings'; import { createContext } from 'react'; import type { ServerMethodName, ServerMethodParameters, ServerMethodReturn } from './methods'; @@ -17,11 +17,12 @@ export type ServerContextValue = { methodName: MethodName, ...args: ServerMethodParameters ) => Promise>; - callEndpoint: >( - method: TMethod, - path: TPath, - params: OperationParams>, - ) => Promise>>>; + callEndpoint: (args: { + method: TMethod; + pathPattern: TPathPattern; + keys: UrlParams; + params: OperationParams; + }) => Promise>>; uploadToEndpoint: ( endpoint: PathFor<'POST'>, formData: any, diff --git a/packages/ui-contexts/src/hooks/useEndpoint.ts b/packages/ui-contexts/src/hooks/useEndpoint.ts index 19dd00950bfe..a0b7c977f2c6 100644 --- a/packages/ui-contexts/src/hooks/useEndpoint.ts +++ b/packages/ui-contexts/src/hooks/useEndpoint.ts @@ -1,6 +1,6 @@ import type { Serialized } from '@rocket.chat/core-typings'; -import type { Method, PathFor, OperationParams, MatchPathPattern, OperationResult, PathPattern } from '@rocket.chat/rest-typings'; -import { useCallback, useContext } from 'react'; +import type { Method, OperationParams, OperationResult, PathPattern, UrlParams } from '@rocket.chat/rest-typings'; +import { useCallback, useContext, useRef } from 'react'; import { ServerContext } from '../ServerContext'; @@ -11,11 +11,23 @@ export type EndpointFunction) => Promise>> : (params: OperationParams) => Promise>>; -export const useEndpoint = >( +export function useEndpoint( method: TMethod, - path: TPath, -): EndpointFunction> => { + pathPattern: TPathPattern, + ...[keys]: undefined extends UrlParams ? [keys?: UrlParams] : [keys: UrlParams] +): EndpointFunction { const { callEndpoint } = useContext(ServerContext); + const keysRef = useRef(keys); + keysRef.current = keys; - return useCallback((params: any) => callEndpoint(method, path, params), [callEndpoint, path, method]); -}; + return useCallback( + (params: OperationParams | undefined) => + callEndpoint({ + method, + pathPattern, + keys: keysRef.current as UrlParams, + params: params as OperationParams, + }), + [callEndpoint, pathPattern, method], + ); +} From e004220d860f818a914d4ac29a1d20c8f80ad685 Mon Sep 17 00:00:00 2001 From: Tasso Evangelista Date: Fri, 30 Dec 2022 18:04:02 -0300 Subject: [PATCH 08/18] Align explicit TypeScript versions --- apps/meteor/ee/server/services/package.json | 2 +- apps/meteor/package.json | 2 +- ee/apps/account-service/package.json | 2 +- ee/apps/authorization-service/package.json | 2 +- ee/apps/ddp-streamer/package.json | 2 +- ee/apps/presence-service/package.json | 2 +- ee/apps/stream-hub-service/package.json | 2 +- ee/packages/ui-theming/package.json | 2 +- packages/agenda/package.json | 2 +- packages/api-client/package.json | 2 +- packages/cas-validate/package.json | 2 +- packages/core-services/package.json | 2 +- packages/core-typings/package.json | 2 +- packages/favicon/package.json | 2 +- packages/fuselage-ui-kit/package.json | 2 +- packages/gazzodown/package.json | 2 +- packages/livechat/package.json | 2 +- packages/model-typings/package.json | 2 +- packages/models/package.json | 2 +- packages/node-poplib/package.json | 2 +- packages/presence/package.json | 2 +- packages/rest-typings/package.json | 2 +- packages/ui-client/package.json | 2 +- packages/ui-composer/package.json | 2 +- packages/ui-contexts/package.json | 2 +- packages/ui-video-conf/package.json | 2 +- packages/web-ui-registration/package.json | 2 +- yarn.lock | 98 ++++++--------------- 28 files changed, 56 insertions(+), 96 deletions(-) diff --git a/apps/meteor/ee/server/services/package.json b/apps/meteor/ee/server/services/package.json index 4ec38956b1f7..8684487eacdf 100644 --- a/apps/meteor/ee/server/services/package.json +++ b/apps/meteor/ee/server/services/package.json @@ -63,7 +63,7 @@ "pino-pretty": "^7.6.1", "pm2": "^5.2.0", "ts-node": "^10.9.1", - "typescript": "4.6.4" + "typescript": "~4.6.4" }, "volta": { "extends": "../../../package.json" diff --git a/apps/meteor/package.json b/apps/meteor/package.json index 6b18d3a1b485..19d0793d0209 100644 --- a/apps/meteor/package.json +++ b/apps/meteor/package.json @@ -191,7 +191,7 @@ "supertest": "^6.2.3", "template-file": "^6.0.1", "ts-node": "^10.9.1", - "typescript": "4.6.4", + "typescript": "~4.6.4", "webpack": "^4.46.0" }, "dependencies": { diff --git a/ee/apps/account-service/package.json b/ee/apps/account-service/package.json index d35e11926cdd..15b7c7c4e910 100644 --- a/ee/apps/account-service/package.json +++ b/ee/apps/account-service/package.json @@ -42,7 +42,7 @@ "@types/polka": "^0.5.4", "eslint": "^8.29.0", "ts-node": "^10.9.1", - "typescript": "4.6.4" + "typescript": "~4.6.4" }, "main": "./dist/ee/apps/account-service/src/service.js", "files": [ diff --git a/ee/apps/authorization-service/package.json b/ee/apps/authorization-service/package.json index 44881c7f1cf7..533ae958a9a0 100644 --- a/ee/apps/authorization-service/package.json +++ b/ee/apps/authorization-service/package.json @@ -39,7 +39,7 @@ "@types/polka": "^0.5.4", "eslint": "^8.29.0", "ts-node": "^10.9.1", - "typescript": "4.6.4" + "typescript": "~4.6.4" }, "main": "./dist/ee/apps/authorization-service/src/service.js", "files": [ diff --git a/ee/apps/ddp-streamer/package.json b/ee/apps/ddp-streamer/package.json index f33529f8919f..84248a29b7fe 100644 --- a/ee/apps/ddp-streamer/package.json +++ b/ee/apps/ddp-streamer/package.json @@ -51,7 +51,7 @@ "eslint": "^8.29.0", "pino-pretty": "^7.6.1", "ts-node": "^10.9.1", - "typescript": "4.6.4" + "typescript": "~4.6.4" }, "main": "./dist/service.js", "files": [ diff --git a/ee/apps/presence-service/package.json b/ee/apps/presence-service/package.json index 747d03889e66..bebe0155a38c 100644 --- a/ee/apps/presence-service/package.json +++ b/ee/apps/presence-service/package.json @@ -38,7 +38,7 @@ "@types/polka": "^0.5.4", "eslint": "^8.29.0", "ts-node": "^10.9.1", - "typescript": "4.6.4" + "typescript": "~4.6.4" }, "main": "./dist/ee/apps/presence-service/src/service.js", "files": [ diff --git a/ee/apps/stream-hub-service/package.json b/ee/apps/stream-hub-service/package.json index 1899c101f3ce..8c5d52c893e6 100644 --- a/ee/apps/stream-hub-service/package.json +++ b/ee/apps/stream-hub-service/package.json @@ -40,7 +40,7 @@ "@types/polka": "^0.5.4", "eslint": "^8.29.0", "ts-node": "^10.9.1", - "typescript": "4.6.4" + "typescript": "~4.6.4" }, "main": "./dist/ee/apps/stream-hub-service/src/service.js", "files": [ diff --git a/ee/packages/ui-theming/package.json b/ee/packages/ui-theming/package.json index c2f23243fbc0..ba0e6408a552 100644 --- a/ee/packages/ui-theming/package.json +++ b/ee/packages/ui-theming/package.json @@ -36,7 +36,7 @@ "postcss-url": "~10.1.3", "react": "~17.0.2", "ts-jest": "^27.1.4", - "typescript": "4.6.4" + "typescript": "~4.6.4" }, "scripts": { "lint": "eslint --ext .js,.jsx,.ts,.tsx .", diff --git a/packages/agenda/package.json b/packages/agenda/package.json index 1350957914e4..21b2934680cd 100644 --- a/packages/agenda/package.json +++ b/packages/agenda/package.json @@ -17,7 +17,7 @@ "eslint": "^8.29.0", "jest": "^27.5.1", "ts-jest": "^27.1.4", - "typescript": "4.6.4" + "typescript": "~4.6.4" }, "scripts": { "lint": "eslint --ext .js,.jsx,.ts,.tsx .", diff --git a/packages/api-client/package.json b/packages/api-client/package.json index a39db6fbaeb3..5554789c1bd7 100644 --- a/packages/api-client/package.json +++ b/packages/api-client/package.json @@ -8,7 +8,7 @@ "eslint": "^8.29.0", "jest": "^27.5.1", "ts-jest": "^27.1.5", - "typescript": "4.6.4" + "typescript": "~4.6.4" }, "scripts": { "lint": "eslint --ext .js,.jsx,.ts,.tsx .", diff --git a/packages/cas-validate/package.json b/packages/cas-validate/package.json index 026adc1f7cd7..1f7f4aa7c35e 100644 --- a/packages/cas-validate/package.json +++ b/packages/cas-validate/package.json @@ -8,7 +8,7 @@ "eslint": "^8.29.0", "jest": "^27.5.1", "ts-jest": "^27.1.4", - "typescript": "4.6.4" + "typescript": "~4.6.4" }, "scripts": { "lint": "eslint --ext .js,.jsx,.ts,.tsx .", diff --git a/packages/core-services/package.json b/packages/core-services/package.json index 64bf3e706d20..b14f70a23f90 100644 --- a/packages/core-services/package.json +++ b/packages/core-services/package.json @@ -7,7 +7,7 @@ "eslint": "^8.29.0", "mongodb": "^4.12.1", "prettier": "^2.7.1", - "typescript": "~4.5.5" + "typescript": "~4.6.4" }, "scripts": { "lint": "eslint --ext .js,.jsx,.ts,.tsx .", diff --git a/packages/core-typings/package.json b/packages/core-typings/package.json index f6baac60f4c0..339bce5e9eeb 100644 --- a/packages/core-typings/package.json +++ b/packages/core-typings/package.json @@ -7,7 +7,7 @@ "eslint": "^8.29.0", "mongodb": "^4.12.1", "prettier": "^2.7.1", - "typescript": "4.6.4" + "typescript": "~4.6.4" }, "scripts": { "lint": "eslint --ext .js,.jsx,.ts,.tsx .", diff --git a/packages/favicon/package.json b/packages/favicon/package.json index 0079c98a45e7..2be326689eda 100644 --- a/packages/favicon/package.json +++ b/packages/favicon/package.json @@ -4,7 +4,7 @@ "private": true, "devDependencies": { "eslint": "^8.29.0", - "typescript": "4.6.4" + "typescript": "~4.6.4" }, "scripts": { "lint": "eslint --ext .js,.jsx,.ts,.tsx .", diff --git a/packages/fuselage-ui-kit/package.json b/packages/fuselage-ui-kit/package.json index 3065be4cd79e..d5c78902aeae 100644 --- a/packages/fuselage-ui-kit/package.json +++ b/packages/fuselage-ui-kit/package.json @@ -85,7 +85,7 @@ "react-dom": "^17.0.2", "rimraf": "^3.0.2", "tslib": "^2.3.1", - "typescript": "~4.3.5", + "typescript": "~4.6.4", "webpack": "~5.68.0" }, "dependencies": { diff --git a/packages/gazzodown/package.json b/packages/gazzodown/package.json index 015f183c71fc..8191f9def22d 100644 --- a/packages/gazzodown/package.json +++ b/packages/gazzodown/package.json @@ -43,7 +43,7 @@ "outdent": "^0.8.0", "react-dom": "~17.0.2", "ts-jest": "^27.1.4", - "typescript": "4.6.4" + "typescript": "~4.6.4" }, "scripts": { "lint": "eslint --ext .js,.jsx,.ts,.tsx .", diff --git a/packages/livechat/package.json b/packages/livechat/package.json index 93112d12675b..0b16d7314ab2 100644 --- a/packages/livechat/package.json +++ b/packages/livechat/package.json @@ -76,7 +76,7 @@ "stylelint": "^14.9.1", "stylelint-order": "^5.0.0", "svg-loader": "^0.0.2", - "typescript": "4.6.4", + "typescript": "~4.6.4", "url-loader": "^4.1.1", "webpack": "^4.44.1", "webpack-cli": "^3.3.12", diff --git a/packages/model-typings/package.json b/packages/model-typings/package.json index 35a5476d6dea..2c4f1d9a4b33 100644 --- a/packages/model-typings/package.json +++ b/packages/model-typings/package.json @@ -9,7 +9,7 @@ "jest": "^27.5.1", "mongodb": "^4.12.1", "ts-jest": "^27.1.5", - "typescript": "4.6.4" + "typescript": "~4.6.4" }, "scripts": { "lint": "eslint --ext .js,.jsx,.ts,.tsx .", diff --git a/packages/models/package.json b/packages/models/package.json index 27dedb794949..9d6a7d88fb79 100644 --- a/packages/models/package.json +++ b/packages/models/package.json @@ -7,7 +7,7 @@ "eslint": "^8.29.0", "jest": "^27.5.1", "ts-jest": "^27.1.5", - "typescript": "4.6.4" + "typescript": "~4.6.4" }, "dependencies": { "@rocket.chat/model-typings": "workspace:^" diff --git a/packages/node-poplib/package.json b/packages/node-poplib/package.json index eaefd248a248..762fdcbc999b 100644 --- a/packages/node-poplib/package.json +++ b/packages/node-poplib/package.json @@ -7,7 +7,7 @@ "eslint": "^8.29.0", "jest": "^27.5.1", "ts-jest": "^27.1.4", - "typescript": "4.6.4" + "typescript": "~4.6.4" }, "scripts": { "jest": "jest" diff --git a/packages/presence/package.json b/packages/presence/package.json index 2f5fc262d06a..1b28b47f4a14 100644 --- a/packages/presence/package.json +++ b/packages/presence/package.json @@ -13,7 +13,7 @@ "babel-jest": "^29.0.3", "eslint": "^8.29.0", "jest": "^29.0.3", - "typescript": "4.6.4" + "typescript": "~4.6.4" }, "scripts": { "lint": "eslint src", diff --git a/packages/rest-typings/package.json b/packages/rest-typings/package.json index 1af41179c832..2857df0ca438 100644 --- a/packages/rest-typings/package.json +++ b/packages/rest-typings/package.json @@ -9,7 +9,7 @@ "jest": "^27.5.1", "mongodb": "^4.12.1", "ts-jest": "^27.1.5", - "typescript": "4.6.4" + "typescript": "~4.6.4" }, "scripts": { "lint": "eslint --ext .js,.jsx,.ts,.tsx .", diff --git a/packages/ui-client/package.json b/packages/ui-client/package.json index 7b83e26839c0..40ca9fa83130 100644 --- a/packages/ui-client/package.json +++ b/packages/ui-client/package.json @@ -39,7 +39,7 @@ "postcss-url": "~10.1.3", "react": "~17.0.2", "ts-jest": "^27.1.4", - "typescript": "4.6.4" + "typescript": "~4.6.4" }, "scripts": { "lint": "eslint --ext .js,.jsx,.ts,.tsx .", diff --git a/packages/ui-composer/package.json b/packages/ui-composer/package.json index dca6a35d1cf8..f14e56f8791b 100644 --- a/packages/ui-composer/package.json +++ b/packages/ui-composer/package.json @@ -22,7 +22,7 @@ "eslint-plugin-storybook": "^0.6.7", "jest": "^27.5.1", "ts-jest": "^27.1.4", - "typescript": "4.6.4" + "typescript": "~4.6.4" }, "peerDependencies": { "@rocket.chat/fuselage": "*", diff --git a/packages/ui-contexts/package.json b/packages/ui-contexts/package.json index 370257bccc8e..475fe682b74d 100644 --- a/packages/ui-contexts/package.json +++ b/packages/ui-contexts/package.json @@ -16,7 +16,7 @@ "mongodb": "^4.12.1", "react": "~17.0.2", "ts-jest": "^27.1.5", - "typescript": "4.6.4", + "typescript": "~4.6.4", "use-sync-external-store": "^1.2.0" }, "peerDependencies": { diff --git a/packages/ui-video-conf/package.json b/packages/ui-video-conf/package.json index 521639633f53..5971db4831d9 100644 --- a/packages/ui-video-conf/package.json +++ b/packages/ui-video-conf/package.json @@ -26,7 +26,7 @@ "eslint-plugin-storybook": "^0.6.7", "jest": "^27.5.1", "ts-jest": "^27.1.4", - "typescript": "4.6.4" + "typescript": "~4.6.4" }, "peerDependencies": { "@rocket.chat/css-in-js": "*", diff --git a/packages/web-ui-registration/package.json b/packages/web-ui-registration/package.json index b47c5ff845ed..4800c1712abc 100644 --- a/packages/web-ui-registration/package.json +++ b/packages/web-ui-registration/package.json @@ -12,7 +12,7 @@ "jest": "^27.5.1", "react-hook-form": "^7.34.2", "ts-jest": "^27.1.4", - "typescript": "~4.5.5" + "typescript": "~4.6.4" }, "peerDependencies": { "@rocket.chat/layout": "*", diff --git a/yarn.lock b/yarn.lock index 38d90283f93f..aec676902183 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6187,7 +6187,7 @@ __metadata: pino: ^8.4.2 polka: ^0.5.2 ts-node: ^10.9.1 - typescript: 4.6.4 + typescript: ~4.6.4 uuid: ^9.0.0 languageName: unknown linkType: soft @@ -6207,7 +6207,7 @@ __metadata: moment-timezone: ~0.5.27 mongodb: ^4.12.1 ts-jest: ^27.1.4 - typescript: 4.6.4 + typescript: ~4.6.4 languageName: unknown linkType: soft @@ -6226,7 +6226,7 @@ __metadata: split-on-first: ^3.0.0 strict-uri-encode: ^2.0.0 ts-jest: ^27.1.5 - typescript: 4.6.4 + typescript: ~4.6.4 languageName: unknown linkType: soft @@ -6285,7 +6285,7 @@ __metadata: pino: ^8.4.2 polka: ^0.5.2 ts-node: ^10.9.1 - typescript: 4.6.4 + typescript: ~4.6.4 languageName: unknown linkType: soft @@ -6298,7 +6298,7 @@ __metadata: eslint: ^8.29.0 jest: ^27.5.1 ts-jest: ^27.1.4 - typescript: 4.6.4 + typescript: ~4.6.4 languageName: unknown linkType: soft @@ -6319,7 +6319,7 @@ __metadata: fibers: ^5.0.3 mongodb: ^4.12.1 prettier: ^2.7.1 - typescript: ~4.5.5 + typescript: ~4.6.4 languageName: unknown linkType: soft @@ -6335,7 +6335,7 @@ __metadata: eslint: ^8.29.0 mongodb: ^4.12.1 prettier: ^2.7.1 - typescript: 4.6.4 + typescript: ~4.6.4 languageName: unknown linkType: soft @@ -6396,7 +6396,7 @@ __metadata: polka: ^0.5.2 sharp: ^0.30.7 ts-node: ^10.9.1 - typescript: 4.6.4 + typescript: ~4.6.4 underscore: ^1.13.4 uuid: ^7.0.3 ws: ^8.8.1 @@ -6433,7 +6433,7 @@ __metadata: resolution: "@rocket.chat/favicon@workspace:packages/favicon" dependencies: eslint: ^8.29.0 - typescript: 4.6.4 + typescript: ~4.6.4 languageName: unknown linkType: soft @@ -6579,7 +6579,7 @@ __metadata: react-dom: ^17.0.2 rimraf: ^3.0.2 tslib: ^2.3.1 - typescript: ~4.3.5 + typescript: ~4.6.4 webpack: ~5.68.0 peerDependencies: "@rocket.chat/apps-engine": "*" @@ -6669,7 +6669,7 @@ __metadata: react-dom: ~17.0.2 react-error-boundary: ^3.1.4 ts-jest: ^27.1.4 - typescript: 4.6.4 + typescript: ~4.6.4 peerDependencies: "@rocket.chat/core-typings": "*" "@rocket.chat/css-in-js": "*" @@ -6774,7 +6774,7 @@ __metadata: stylelint: ^14.9.1 stylelint-order: ^5.0.0 svg-loader: ^0.0.2 - typescript: 4.6.4 + typescript: ~4.6.4 url-loader: ^4.1.1 webpack: ^4.44.1 webpack-cli: ^3.3.12 @@ -7134,7 +7134,7 @@ __metadata: turndown: ^7.1.1 twilio: ^3.76.1 twit: ^2.2.11 - typescript: 4.6.4 + typescript: ~4.6.4 ua-parser-js: ^1.0.2 underscore: ^1.13.4 underscore.string: ^3.3.6 @@ -7164,7 +7164,7 @@ __metadata: jest: ^27.5.1 mongodb: ^4.12.1 ts-jest: ^27.1.5 - typescript: 4.6.4 + typescript: ~4.6.4 languageName: unknown linkType: soft @@ -7177,7 +7177,7 @@ __metadata: eslint: ^8.29.0 jest: ^27.5.1 ts-jest: ^27.1.5 - typescript: 4.6.4 + typescript: ~4.6.4 languageName: unknown linkType: soft @@ -7220,7 +7220,7 @@ __metadata: eslint: ^8.29.0 jest: ^27.5.1 ts-jest: ^27.1.4 - typescript: 4.6.4 + typescript: ~4.6.4 languageName: unknown linkType: soft @@ -7249,7 +7249,7 @@ __metadata: pino: ^8.4.2 polka: ^0.5.2 ts-node: ^10.9.1 - typescript: 4.6.4 + typescript: ~4.6.4 languageName: unknown linkType: soft @@ -7271,7 +7271,7 @@ __metadata: eslint: ^8.29.0 jest: ^29.0.3 mongodb: ^4.12.1 - typescript: 4.6.4 + typescript: ~4.6.4 languageName: unknown linkType: soft @@ -7299,7 +7299,7 @@ __metadata: jest: ^27.5.1 mongodb: ^4.12.1 ts-jest: ^27.1.5 - typescript: 4.6.4 + typescript: ~4.6.4 languageName: unknown linkType: soft @@ -7343,7 +7343,7 @@ __metadata: pino: ^8.4.2 polka: ^0.5.2 ts-node: ^10.9.1 - typescript: 4.6.4 + typescript: ~4.6.4 languageName: unknown linkType: soft @@ -7418,7 +7418,7 @@ __metadata: postcss-url: ~10.1.3 react: ~17.0.2 ts-jest: ^27.1.4 - typescript: 4.6.4 + typescript: ~4.6.4 peerDependencies: "@rocket.chat/css-in-js": "*" "@rocket.chat/fuselage": "*" @@ -7452,7 +7452,7 @@ __metadata: eslint-plugin-storybook: ^0.6.7 jest: ^27.5.1 ts-jest: ^27.1.4 - typescript: 4.6.4 + typescript: ~4.6.4 peerDependencies: "@rocket.chat/fuselage": "*" "@rocket.chat/icons": "*" @@ -7478,7 +7478,7 @@ __metadata: mongodb: ^4.12.1 react: ~17.0.2 ts-jest: ^27.1.5 - typescript: 4.6.4 + typescript: ~4.6.4 use-sync-external-store: ^1.2.0 peerDependencies: "@rocket.chat/core-typings": "workspace:^" @@ -7534,7 +7534,7 @@ __metadata: postcss-url: ~10.1.3 react: ~17.0.2 ts-jest: ^27.1.4 - typescript: 4.6.4 + typescript: ~4.6.4 peerDependencies: "@rocket.chat/css-in-js": "*" "@rocket.chat/fuselage": "*" @@ -7572,7 +7572,7 @@ __metadata: eslint-plugin-storybook: ^0.6.7 jest: ^27.5.1 ts-jest: ^27.1.4 - typescript: 4.6.4 + typescript: ~4.6.4 peerDependencies: "@rocket.chat/css-in-js": "*" "@rocket.chat/fuselage": "*" @@ -7598,7 +7598,7 @@ __metadata: jest: ^27.5.1 react-hook-form: ^7.34.2 ts-jest: ^27.1.4 - typescript: ~4.5.5 + typescript: ~4.6.4 peerDependencies: "@rocket.chat/layout": "*" "@rocket.chat/ui-contexts": "*" @@ -31463,7 +31463,7 @@ __metadata: sodium-native: ^3.3.0 sodium-plus: ^0.9.0 ts-node: ^10.9.1 - typescript: 4.6.4 + typescript: ~4.6.4 underscore.string: ^3.3.6 uuid: ^8.3.2 ws: ^8.8.1 @@ -34863,7 +34863,7 @@ __metadata: languageName: node linkType: hard -"typescript@npm:4.6.4": +"typescript@npm:~4.6.4": version: 4.6.4 resolution: "typescript@npm:4.6.4" bin: @@ -34873,27 +34873,7 @@ __metadata: languageName: node linkType: hard -"typescript@npm:~4.3.5": - version: 4.3.5 - resolution: "typescript@npm:4.3.5" - bin: - tsc: bin/tsc - tsserver: bin/tsserver - checksum: bab033b5e2b0790dd35b77fd005df976ef80b8d84fd2c6e63cc31808151875beae9216e5a315fe7068e8499905c3c354248fe83272cdfc13b7705635f0c66c97 - languageName: node - linkType: hard - -"typescript@npm:~4.5.5": - version: 4.5.5 - resolution: "typescript@npm:4.5.5" - bin: - tsc: bin/tsc - tsserver: bin/tsserver - checksum: 506f4c919dc8aeaafa92068c997f1d213b9df4d9756d0fae1a1e7ab66b585ab3498050e236113a1c9e57ee08c21ec6814ca7a7f61378c058d79af50a4b1f5a5e - languageName: node - linkType: hard - -"typescript@patch:typescript@4.6.4#~builtin": +"typescript@patch:typescript@~4.6.4#~builtin": version: 4.6.4 resolution: "typescript@patch:typescript@npm%3A4.6.4#~builtin::version=4.6.4&hash=f456af" bin: @@ -34903,26 +34883,6 @@ __metadata: languageName: node linkType: hard -"typescript@patch:typescript@~4.3.5#~builtin": - version: 4.3.5 - resolution: "typescript@patch:typescript@npm%3A4.3.5#~builtin::version=4.3.5&hash=f456af" - bin: - tsc: bin/tsc - tsserver: bin/tsserver - checksum: 365df18cf979c971ef9543b2acaa8694377a803f98e1804c41d0ede0b09d7046cb0cd98f2eaf3884b0fe923c01a60af1f653841bd8805c9715d5479c09a4ebe4 - languageName: node - linkType: hard - -"typescript@patch:typescript@~4.5.5#~builtin": - version: 4.5.5 - resolution: "typescript@patch:typescript@npm%3A4.5.5#~builtin::version=4.5.5&hash=f456af" - bin: - tsc: bin/tsc - tsserver: bin/tsserver - checksum: 858c61fa63f7274ca4aaaffeced854d550bf416cff6e558c4884041b3311fb662f476f167cf5c9f8680c607239797e26a2ee0bcc6467fbc05bfcb218e1c6c671 - languageName: node - linkType: hard - "ua-parser-js@npm:^1.0.2": version: 1.0.2 resolution: "ua-parser-js@npm:1.0.2" From e1d10866c6be62e4b2e0eed45c312c505a6709be Mon Sep 17 00:00:00 2001 From: Diego Sampaio Date: Mon, 2 Jan 2023 10:22:13 -0300 Subject: [PATCH 09/18] fix email --- .../packages/rocketchat-mongo-config/server/index.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/apps/meteor/packages/rocketchat-mongo-config/server/index.js b/apps/meteor/packages/rocketchat-mongo-config/server/index.js index 19f3b0341ae8..53650338ca6f 100644 --- a/apps/meteor/packages/rocketchat-mongo-config/server/index.js +++ b/apps/meteor/packages/rocketchat-mongo-config/server/index.js @@ -1,7 +1,7 @@ import tls from 'tls'; import { PassThrough } from 'stream'; -import { EmailTest, Email } from 'meteor/email'; +import { Email } from 'meteor/email'; import { Mongo } from 'meteor/mongo'; const shouldDisableOplog = ['yes', 'true'].includes(String(process.env.USE_NATIVE_OPLOG).toLowerCase()); @@ -34,17 +34,13 @@ if (Object.keys(mongoConnectionOptions).length > 0) { process.env.HTTP_FORWARDED_COUNT = process.env.HTTP_FORWARDED_COUNT || '1'; -// Send emails to a "fake" stream instead of print them in console +// Send emails to a "fake" stream instead of print them in console in case MAIL_URL or SMTP is not configured if (process.env.NODE_ENV !== 'development') { + const { send } = Email; const stream = new PassThrough(); - EmailTest.overrideOutputStream(stream); stream.on('data', () => {}); stream.on('end', () => {}); -} - -// Just print to logs if in TEST_MODE due to a bug in Meteor 2.5: TypeError: Cannot read property '_syncSendMail' of null -if (process.env.TEST_MODE === 'true') { Email.send = function _send(options) { - console.log('Email.send', options); + return send.call(this, { stream, ...options }); }; } From b4b67d93dc147c16e0597bfb8163b700cd357cbc Mon Sep 17 00:00:00 2001 From: Diego Sampaio Date: Mon, 2 Jan 2023 11:28:32 -0300 Subject: [PATCH 10/18] add back email overwrite on TEST_MODE --- .../packages/rocketchat-mongo-config/server/index.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/apps/meteor/packages/rocketchat-mongo-config/server/index.js b/apps/meteor/packages/rocketchat-mongo-config/server/index.js index 53650338ca6f..81d91e83e897 100644 --- a/apps/meteor/packages/rocketchat-mongo-config/server/index.js +++ b/apps/meteor/packages/rocketchat-mongo-config/server/index.js @@ -44,3 +44,10 @@ if (process.env.NODE_ENV !== 'development') { return send.call(this, { stream, ...options }); }; } + +// Just print to logs if in TEST_MODE due to a bug in Meteor 2.5: TypeError: Cannot read property '_syncSendMail' of null +if (process.env.TEST_MODE === 'true') { + Email.send = function _send(options) { + console.log('Email.send', options); + }; +} From ef2f4b61ac002afa4e8458a3ffef29b71509ef9e Mon Sep 17 00:00:00 2001 From: Diego Sampaio Date: Mon, 2 Jan 2023 11:28:37 -0300 Subject: [PATCH 11/18] remove console.log --- apps/meteor/tests/data/uploads.helper.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/apps/meteor/tests/data/uploads.helper.ts b/apps/meteor/tests/data/uploads.helper.ts index 679d99ba5fae..e620f4c34a58 100644 --- a/apps/meteor/tests/data/uploads.helper.ts +++ b/apps/meteor/tests/data/uploads.helper.ts @@ -20,8 +20,6 @@ export async function testFileUploads(filesEndpoint: 'channels.files' | 'groups. await updateSetting('Message_KeepHistory', false); }); - console.log('filesEndpoint', filesEndpoint, room); - const createVoipRoom = async function () { const testUser = await createUser({ roles: ['user', 'livechat-agent'] }); const testUserCredentials = await login(testUser.username, password); From d10989e23d932f7ae790be12020141b3e9bb5796 Mon Sep 17 00:00:00 2001 From: Diego Sampaio Date: Mon, 2 Jan 2023 15:00:54 -0300 Subject: [PATCH 12/18] fix calls to `useEndpointData` --- .../views/admin/integrations/IntegrationsTable.js | 2 +- .../integrations/edit/EditIncomingWebhookWithData.js | 2 +- .../integrations/edit/EditOutgoingWebhookWithData.js | 2 +- apps/meteor/client/views/admin/users/AddUser.js | 2 +- apps/meteor/client/views/directory/ChannelsTable.js | 2 +- apps/meteor/client/views/directory/TeamsTable.js | 2 +- .../businessHours/EditBusinessHoursPage.js | 7 +++---- .../views/omnichannel/components/CustomField.js | 2 +- .../customFields/EditCustomFieldsPageContainer.js | 2 +- .../views/omnichannel/departments/DepartmentsRoute.js | 2 +- .../EditDepartmentWithAllowedForwardData.js | 7 +++---- .../omnichannel/departments/EditDepartmentWithData.js | 4 ++-- .../directory/chats/contextualBar/AgentField.js | 5 +---- .../directory/chats/contextualBar/ContactField.js | 5 +---- .../directory/chats/contextualBar/DepartmentField.js | 2 +- .../directory/chats/contextualBar/PriorityField.js | 2 +- .../directory/chats/contextualBar/RoomEditWithData.js | 9 +-------- .../chats/contextualBar/VisitorClientInfo.js | 6 ++---- .../directory/chats/contextualBar/VisitorData.js | 5 +---- .../contacts/contextualBar/ContactEditWithData.js | 5 +---- .../directory/contacts/contextualBar/ContactInfo.js | 11 +++-------- .../realTimeMonitoring/charts/AgentStatusChart.js | 2 +- .../realTimeMonitoring/charts/ChatDurationChart.js | 2 +- .../realTimeMonitoring/charts/ChatsChart.js | 2 +- .../realTimeMonitoring/charts/ChatsPerAgentChart.js | 2 +- .../charts/ChatsPerDepartmentChart.js | 6 +++++- .../realTimeMonitoring/charts/ResponseTimesChart.js | 2 +- .../realTimeMonitoring/overviews/AgentsOverview.js | 6 +++++- .../realTimeMonitoring/overviews/ChatsOverview.js | 2 +- .../overviews/ConversationOverview.js | 2 +- .../overviews/ProductivityOverview.js | 2 +- .../omnichannel/triggers/EditTriggerPageContainer.js | 2 +- .../omnichannel/triggers/TriggersTableContainer.js | 7 +++---- .../TeamAutocomplete/TeamAutocomplete.js | 5 +---- .../client/views/teams/contextualBar/info/index.js | 2 +- .../members/RemoveUsersModal/RemoveUsersModal.js | 11 ++--------- .../client/audit/RoomAutoComplete/RoomAutoComplete.js | 5 +---- apps/meteor/ee/client/audit/VisitorAutoComplete.js | 5 +---- .../client/omnichannel/BusinessHoursTableContainer.js | 7 +++---- .../ee/client/omnichannel/ContactManagerInfo.js | 5 +---- .../additionalForms/DepartmentBusinessHours.js | 5 +---- .../ee/client/omnichannel/monitors/MonitorsPage.js | 2 +- .../client/omnichannel/priorities/PrioritiesRoute.js | 2 +- .../omnichannel/priorities/PriorityEditWithData.js | 2 +- .../ee/client/omnichannel/tags/TagEditWithData.js | 2 +- apps/meteor/ee/client/omnichannel/tags/TagsRoute.js | 2 +- apps/meteor/ee/client/omnichannel/units/UnitsRoute.js | 2 +- 47 files changed, 68 insertions(+), 112 deletions(-) diff --git a/apps/meteor/client/views/admin/integrations/IntegrationsTable.js b/apps/meteor/client/views/admin/integrations/IntegrationsTable.js index 6f27e7aba61c..aa0632047357 100644 --- a/apps/meteor/client/views/admin/integrations/IntegrationsTable.js +++ b/apps/meteor/client/views/admin/integrations/IntegrationsTable.js @@ -36,7 +36,7 @@ function IntegrationsTable({ type }) { const debouncedSort = useDebouncedValue(sort, 500); const query = useQuery({ ...params, text: debouncedText, type }, debouncedSort); - const { value: data } = useEndpointData('/v1/integrations.list', query); + const { value: data } = useEndpointData('/v1/integrations.list', { params: query }); const router = useRoute('admin-integrations'); diff --git a/apps/meteor/client/views/admin/integrations/edit/EditIncomingWebhookWithData.js b/apps/meteor/client/views/admin/integrations/edit/EditIncomingWebhookWithData.js index 1babc968c285..4d0996ef58a9 100644 --- a/apps/meteor/client/views/admin/integrations/edit/EditIncomingWebhookWithData.js +++ b/apps/meteor/client/views/admin/integrations/edit/EditIncomingWebhookWithData.js @@ -10,7 +10,7 @@ function EditIncomingWebhookWithData({ integrationId, ...props }) { const t = useTranslation(); const params = useMemo(() => ({ integrationId }), [integrationId]); - const { value: data, phase: state, error, reload } = useEndpointData('/v1/integrations.get', params); + const { value: data, phase: state, error, reload } = useEndpointData('/v1/integrations.get', { params }); const onChange = () => { reload(); diff --git a/apps/meteor/client/views/admin/integrations/edit/EditOutgoingWebhookWithData.js b/apps/meteor/client/views/admin/integrations/edit/EditOutgoingWebhookWithData.js index 18de6d51f192..09e5f28cf189 100644 --- a/apps/meteor/client/views/admin/integrations/edit/EditOutgoingWebhookWithData.js +++ b/apps/meteor/client/views/admin/integrations/edit/EditOutgoingWebhookWithData.js @@ -10,7 +10,7 @@ function EditOutgoingWebhookWithData({ integrationId, ...props }) { const t = useTranslation(); const params = useMemo(() => ({ integrationId }), [integrationId]); - const { value: data, phase: state, error, reload } = useEndpointData('/v1/integrations.get', params); + const { value: data, phase: state, error, reload } = useEndpointData('/v1/integrations.get', { params }); const onChange = () => { reload(); diff --git a/apps/meteor/client/views/admin/users/AddUser.js b/apps/meteor/client/views/admin/users/AddUser.js index efe429224dc7..b95647cef13e 100644 --- a/apps/meteor/client/views/admin/users/AddUser.js +++ b/apps/meteor/client/views/admin/users/AddUser.js @@ -13,7 +13,7 @@ const AddUser = ({ onReload, ...props }) => { const router = useRoute('admin-users'); - const { value: roleData } = useEndpointData('/v1/roles.list', ''); + const { value: roleData } = useEndpointData('/v1/roles.list'); const [errors, setErrors] = useState({}); const validationKeys = { diff --git a/apps/meteor/client/views/directory/ChannelsTable.js b/apps/meteor/client/views/directory/ChannelsTable.js index 1e881fff748a..02990624605b 100644 --- a/apps/meteor/client/views/directory/ChannelsTable.js +++ b/apps/meteor/client/views/directory/ChannelsTable.js @@ -93,7 +93,7 @@ function ChannelsTable() { const channelRoute = useRoute('channel'); const groupsRoute = useRoute('group'); - const { value: data = {} } = useEndpointData('/v1/directory', query); + const { value: data = {} } = useEndpointData('/v1/directory', { params: query }); const onClick = useMemo( () => (name, type) => (e) => { diff --git a/apps/meteor/client/views/directory/TeamsTable.js b/apps/meteor/client/views/directory/TeamsTable.js index 98a75491d345..90e5a6b246d7 100644 --- a/apps/meteor/client/views/directory/TeamsTable.js +++ b/apps/meteor/client/views/directory/TeamsTable.js @@ -69,7 +69,7 @@ function TeamsTable() { const query = useDirectoryQuery(params, sort, 'teams'); - const { value: data = {} } = useEndpointData('/v1/directory', query); + const { value: data = {} } = useEndpointData('/v1/directory', { params: query }); const onClick = useMemo( () => (name, type) => (e) => { diff --git a/apps/meteor/client/views/omnichannel/businessHours/EditBusinessHoursPage.js b/apps/meteor/client/views/omnichannel/businessHours/EditBusinessHoursPage.js index 5681fa65de38..1b45e62fbc83 100644 --- a/apps/meteor/client/views/omnichannel/businessHours/EditBusinessHoursPage.js +++ b/apps/meteor/client/views/omnichannel/businessHours/EditBusinessHoursPage.js @@ -16,10 +16,9 @@ const EditBusinessHoursPage = ({ id, type }) => { const dispatchToastMessage = useToastMessageDispatch(); const isSingleBH = useIsSingleBusinessHours(); - const { value: data, phase: state } = useEndpointData( - '/v1/livechat/business-hour', - useMemo(() => ({ _id: id, type }), [id, type]), - ); + const { value: data, phase: state } = useEndpointData('/v1/livechat/business-hour', { + params: useMemo(() => ({ _id: id, type }), [id, type]), + }); const saveData = useRef({ form: {} }); diff --git a/apps/meteor/client/views/omnichannel/components/CustomField.js b/apps/meteor/client/views/omnichannel/components/CustomField.js index 5960d5225467..bf95f8e52720 100644 --- a/apps/meteor/client/views/omnichannel/components/CustomField.js +++ b/apps/meteor/client/views/omnichannel/components/CustomField.js @@ -11,7 +11,7 @@ import Label from './Label'; const CustomField = ({ id, value }) => { const t = useTranslation(); - const { value: data, phase: state, error } = useEndpointData(`/v1/livechat/custom-fields/${id}`); + const { value: data, phase: state, error } = useEndpointData('/v1/livechat/custom-fields/:_id', { keys: { _id: id } }); if (state === AsyncStatePhase.LOADING) { return ; } diff --git a/apps/meteor/client/views/omnichannel/customFields/EditCustomFieldsPageContainer.js b/apps/meteor/client/views/omnichannel/customFields/EditCustomFieldsPageContainer.js index 8c8e6455755d..be3f83c55da4 100644 --- a/apps/meteor/client/views/omnichannel/customFields/EditCustomFieldsPageContainer.js +++ b/apps/meteor/client/views/omnichannel/customFields/EditCustomFieldsPageContainer.js @@ -12,7 +12,7 @@ const EditCustomFieldsPageContainer = ({ reload }) => { const t = useTranslation(); const id = useRouteParameter('id'); - const { value: data, phase: state, error } = useEndpointData(`/v1/livechat/custom-fields/${id}`); + const { value: data, phase: state, error } = useEndpointData('/v1/livechat/custom-fields/:_id', { keys: { _id: id } }); if (state === AsyncStatePhase.LOADING) { return ; diff --git a/apps/meteor/client/views/omnichannel/departments/DepartmentsRoute.js b/apps/meteor/client/views/omnichannel/departments/DepartmentsRoute.js index b752413441ec..00e29b11dd60 100644 --- a/apps/meteor/client/views/omnichannel/departments/DepartmentsRoute.js +++ b/apps/meteor/client/views/omnichannel/departments/DepartmentsRoute.js @@ -66,7 +66,7 @@ function DepartmentsRoute() { }), ); - const { value: data = {}, reload } = useEndpointData('/v1/livechat/department', query); + const { value: data = {}, reload } = useEndpointData('/v1/livechat/department', { params: query }); const header = useMemo( () => diff --git a/apps/meteor/client/views/omnichannel/departments/EditDepartmentWithAllowedForwardData.js b/apps/meteor/client/views/omnichannel/departments/EditDepartmentWithAllowedForwardData.js index 5df029fdab0a..6563408ef5d5 100644 --- a/apps/meteor/client/views/omnichannel/departments/EditDepartmentWithAllowedForwardData.js +++ b/apps/meteor/client/views/omnichannel/departments/EditDepartmentWithAllowedForwardData.js @@ -14,15 +14,14 @@ function EditDepartmentWithAllowedForwardData({ data, ...props }) { value: allowedToForwardData, phase: allowedToForwardState, error: allowedToForwardError, - } = useEndpointData( - '/v1/livechat/department.listByIds', - useMemo( + } = useEndpointData('/v1/livechat/department.listByIds', { + params: useMemo( () => ({ ids: data && data.department && data.department.departmentsAllowedToForward ? data.department.departmentsAllowedToForward : [], }), [data], ), - ); + }); if ([allowedToForwardState].includes(AsyncStatePhase.LOADING)) { return ; diff --git a/apps/meteor/client/views/omnichannel/departments/EditDepartmentWithData.js b/apps/meteor/client/views/omnichannel/departments/EditDepartmentWithData.js index 7fe2a08edc4a..06b1855523ad 100644 --- a/apps/meteor/client/views/omnichannel/departments/EditDepartmentWithData.js +++ b/apps/meteor/client/views/omnichannel/departments/EditDepartmentWithData.js @@ -8,10 +8,10 @@ import { useEndpointData } from '../../../hooks/useEndpointData'; import EditDepartment from './EditDepartment'; import EditDepartmentWithAllowedForwardData from './EditDepartmentWithAllowedForwardData'; -const param = { onlyMyDepartments: true }; +const params = { onlyMyDepartments: true }; function EditDepartmentWithData({ id, reload, title }) { const t = useTranslation(); - const { value: data, phase: state, error } = useEndpointData(`/v1/livechat/department/${id}`, param); + const { value: data, phase: state, error } = useEndpointData('/v1/livechat/department/:_id', { keys: { _id: id }, params }); if ([state].includes(AsyncStatePhase.LOADING)) { return ; diff --git a/apps/meteor/client/views/omnichannel/directory/chats/contextualBar/AgentField.js b/apps/meteor/client/views/omnichannel/directory/chats/contextualBar/AgentField.js index da67f9e559ea..460574dea7e5 100644 --- a/apps/meteor/client/views/omnichannel/directory/chats/contextualBar/AgentField.js +++ b/apps/meteor/client/views/omnichannel/directory/chats/contextualBar/AgentField.js @@ -14,10 +14,7 @@ import { FormSkeleton } from '../../Skeleton'; const AgentField = ({ agent, isSmall = false }) => { const t = useTranslation(); const { username } = agent; - const { value, phase: state } = useEndpointData( - `/v1/users.info`, - useMemo(() => ({ username }), [username]), - ); + const { value, phase: state } = useEndpointData('/v1/users.info', { params: useMemo(() => ({ username }), [username]) }); if (state === AsyncStatePhase.LOADING) { return ; diff --git a/apps/meteor/client/views/omnichannel/directory/chats/contextualBar/ContactField.js b/apps/meteor/client/views/omnichannel/directory/chats/contextualBar/ContactField.js index 8723ad109093..cf60b957c4fb 100644 --- a/apps/meteor/client/views/omnichannel/directory/chats/contextualBar/ContactField.js +++ b/apps/meteor/client/views/omnichannel/directory/chats/contextualBar/ContactField.js @@ -22,10 +22,7 @@ const ContactField = ({ contact, room }) => { value: data, phase: state, error, - } = useEndpointData( - '/v1/livechat/visitors.info', - useMemo(() => ({ visitorId: contact._id }), [contact._id]), - ); + } = useEndpointData('/v1/livechat/visitors.info', { params: useMemo(() => ({ visitorId: contact._id }), [contact._id]) }); if (state === AsyncStatePhase.LOADING) { return ; diff --git a/apps/meteor/client/views/omnichannel/directory/chats/contextualBar/DepartmentField.js b/apps/meteor/client/views/omnichannel/directory/chats/contextualBar/DepartmentField.js index 5e68b7abb586..7b1209364de8 100644 --- a/apps/meteor/client/views/omnichannel/directory/chats/contextualBar/DepartmentField.js +++ b/apps/meteor/client/views/omnichannel/directory/chats/contextualBar/DepartmentField.js @@ -10,7 +10,7 @@ import { FormSkeleton } from '../../Skeleton'; const DepartmentField = ({ departmentId }) => { const t = useTranslation(); - const { value: data, phase: state } = useEndpointData(`/v1/livechat/department/${departmentId}`); + const { value: data, phase: state } = useEndpointData('/v1/livechat/department/:_id', { keys: { _id: departmentId } }); if (state === AsyncStatePhase.LOADING) { return ; } diff --git a/apps/meteor/client/views/omnichannel/directory/chats/contextualBar/PriorityField.js b/apps/meteor/client/views/omnichannel/directory/chats/contextualBar/PriorityField.js index 3e6506348a35..8ce66bc4cff3 100644 --- a/apps/meteor/client/views/omnichannel/directory/chats/contextualBar/PriorityField.js +++ b/apps/meteor/client/views/omnichannel/directory/chats/contextualBar/PriorityField.js @@ -11,7 +11,7 @@ import { FormSkeleton } from '../../Skeleton'; const PriorityField = ({ id }) => { const t = useTranslation(); - const { value: data, phase: state, error } = useEndpointData(`/v1/livechat/priorities/${id}`); + const { value: data, phase: state, error } = useEndpointData('/v1/livechat/priorities/:priorityId', { keys: { priorityId: id } }); if (state === AsyncStatePhase.LOADING) { return ; } diff --git a/apps/meteor/client/views/omnichannel/directory/chats/contextualBar/RoomEditWithData.js b/apps/meteor/client/views/omnichannel/directory/chats/contextualBar/RoomEditWithData.js index b4c566db5181..ee34a38b9fd5 100644 --- a/apps/meteor/client/views/omnichannel/directory/chats/contextualBar/RoomEditWithData.js +++ b/apps/meteor/client/views/omnichannel/directory/chats/contextualBar/RoomEditWithData.js @@ -10,14 +10,7 @@ import VisitorData from './VisitorData'; function RoomEditWithData({ id, reload, reloadInfo, close }) { const t = useTranslation(); - const { - value: roomData, - phase: state, - error, - } = useEndpointData( - '/v1/rooms.info', - useMemo(() => ({ roomId: id }), [id]), - ); + const { value: roomData, phase: state, error } = useEndpointData('/v1/rooms.info', { params: useMemo(() => ({ roomId: id }), [id]) }); if ([state].includes(AsyncStatePhase.LOADING)) { return ; diff --git a/apps/meteor/client/views/omnichannel/directory/chats/contextualBar/VisitorClientInfo.js b/apps/meteor/client/views/omnichannel/directory/chats/contextualBar/VisitorClientInfo.js index 3dce914bb3b7..5f5cd5b2c636 100644 --- a/apps/meteor/client/views/omnichannel/directory/chats/contextualBar/VisitorClientInfo.js +++ b/apps/meteor/client/views/omnichannel/directory/chats/contextualBar/VisitorClientInfo.js @@ -15,10 +15,8 @@ const VisitorClientInfo = ({ uid }) => { value: userData, phase: state, error, - } = useEndpointData( - '/v1/livechat/visitors.info', - useMemo(() => ({ visitorId: uid }), [uid]), - ); + } = useEndpointData('/v1/livechat/visitors.info', { params: useMemo(() => ({ visitorId: uid }), [uid]) }); + if (state === AsyncStatePhase.LOADING) { return ; } diff --git a/apps/meteor/client/views/omnichannel/directory/chats/contextualBar/VisitorData.js b/apps/meteor/client/views/omnichannel/directory/chats/contextualBar/VisitorData.js index 7d2b78a4bb26..b7e84c5a121b 100644 --- a/apps/meteor/client/views/omnichannel/directory/chats/contextualBar/VisitorData.js +++ b/apps/meteor/client/views/omnichannel/directory/chats/contextualBar/VisitorData.js @@ -20,10 +20,7 @@ function VisitorData({ room, reload, reloadInfo, close }) { value: visitor, phase: stateVisitor, error: errorVisitor, - } = useEndpointData( - '/v1/livechat/visitors.info', - useMemo(() => ({ visitorId: _id }), [_id]), - ); + } = useEndpointData('/v1/livechat/visitors.info', { params: useMemo(() => ({ visitorId: _id }), [_id]) }); if ([stateVisitor].includes(AsyncStatePhase.LOADING)) { return ; diff --git a/apps/meteor/client/views/omnichannel/directory/contacts/contextualBar/ContactEditWithData.js b/apps/meteor/client/views/omnichannel/directory/contacts/contextualBar/ContactEditWithData.js index 24c95fa64b35..e88ac9f0bd7b 100644 --- a/apps/meteor/client/views/omnichannel/directory/contacts/contextualBar/ContactEditWithData.js +++ b/apps/meteor/client/views/omnichannel/directory/contacts/contextualBar/ContactEditWithData.js @@ -13,10 +13,7 @@ function ContactEditWithData({ id, close }) { value: data, phase: state, error, - } = useEndpointData( - '/v1/omnichannel/contact', - useMemo(() => ({ contactId: id }), [id]), - ); + } = useEndpointData('/v1/omnichannel/contact', { params: useMemo(() => ({ contactId: id }), [id]) }); if ([state].includes(AsyncStatePhase.LOADING)) { return ; diff --git a/apps/meteor/client/views/omnichannel/directory/contacts/contextualBar/ContactInfo.js b/apps/meteor/client/views/omnichannel/directory/contacts/contextualBar/ContactInfo.js index a6f47b490176..8f713d080ed4 100644 --- a/apps/meteor/client/views/omnichannel/directory/contacts/contextualBar/ContactInfo.js +++ b/apps/meteor/client/views/omnichannel/directory/contacts/contextualBar/ContactInfo.js @@ -64,14 +64,9 @@ const ContactInfo = ({ id, rid, route }) => { } }, [allCustomFields, stateCustomFields]); - const { - value: data, - phase: state, - error, - } = useEndpointData( - '/v1/omnichannel/contact', - useMemo(() => ({ contactId: id }), [id]), - ); + const query = useMemo(() => ({ contactId: id }), [id]); + + const { value: data, phase: state, error } = useEndpointData('/v1/omnichannel/contact', { params: query }); const [currentRouteName] = useCurrentRoute(); const liveRoute = useRoute('live'); diff --git a/apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/AgentStatusChart.js b/apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/AgentStatusChart.js index c1cf1b438f8b..4564a859ccf5 100644 --- a/apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/AgentStatusChart.js +++ b/apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/AgentStatusChart.js @@ -38,7 +38,7 @@ const AgentStatusChart = ({ params, reloadRef, ...props }) => { init, }); - const { value: data, phase: state, reload } = useEndpointData('/v1/livechat/analytics/dashboards/charts/agents-status', params); + const { value: data, phase: state, reload } = useEndpointData('/v1/livechat/analytics/dashboards/charts/agents-status', { params }); reloadRef.current.agentStatusChart = reload; diff --git a/apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/ChatDurationChart.js b/apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/ChatDurationChart.js index f049480b789a..d85fe1d3799d 100644 --- a/apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/ChatDurationChart.js +++ b/apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/ChatDurationChart.js @@ -45,7 +45,7 @@ const ChatDurationChart = ({ params, reloadRef, ...props }) => { init, }); - const { value: data, phase: state, reload } = useEndpointData('/v1/livechat/analytics/dashboards/charts/timings', params); + const { value: data, phase: state, reload } = useEndpointData('/v1/livechat/analytics/dashboards/charts/timings', { params }); reloadRef.current.chatDurationChart = reload; diff --git a/apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/ChatsChart.js b/apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/ChatsChart.js index 5cb49cafb013..cbe1285931d7 100644 --- a/apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/ChatsChart.js +++ b/apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/ChatsChart.js @@ -38,7 +38,7 @@ const ChatsChart = ({ params, reloadRef, ...props }) => { init, }); - const { value: data, phase: state, reload } = useEndpointData('/v1/livechat/analytics/dashboards/charts/chats', params); + const { value: data, phase: state, reload } = useEndpointData('/v1/livechat/analytics/dashboards/charts/chats', { params }); reloadRef.current.chatsChart = reload; diff --git a/apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/ChatsPerAgentChart.js b/apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/ChatsPerAgentChart.js index a2e6837e9486..6c7741781e1b 100644 --- a/apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/ChatsPerAgentChart.js +++ b/apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/ChatsPerAgentChart.js @@ -32,7 +32,7 @@ const ChatsPerAgentChart = ({ params, reloadRef, ...props }) => { init, }); - const { value: data, phase: state, reload } = useEndpointData('/v1/livechat/analytics/dashboards/charts/chats-per-agent', params); + const { value: data, phase: state, reload } = useEndpointData('/v1/livechat/analytics/dashboards/charts/chats-per-agent', { params }); reloadRef.current.chatsPerAgentChart = reload; diff --git a/apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/ChatsPerDepartmentChart.js b/apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/ChatsPerDepartmentChart.js index 55ba495d412a..030fcedc0576 100644 --- a/apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/ChatsPerDepartmentChart.js +++ b/apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/ChatsPerDepartmentChart.js @@ -31,7 +31,11 @@ const ChatsPerDepartmentChart = ({ params, reloadRef, ...props }) => { init, }); - const { value: data, phase: state, reload } = useEndpointData('/v1/livechat/analytics/dashboards/charts/chats-per-department', params); + const { + value: data, + phase: state, + reload, + } = useEndpointData('/v1/livechat/analytics/dashboards/charts/chats-per-department', { params }); reloadRef.current.chatsPerDepartmentChart = reload; diff --git a/apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/ResponseTimesChart.js b/apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/ResponseTimesChart.js index c94b59ee077e..ac0500ebf4da 100644 --- a/apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/ResponseTimesChart.js +++ b/apps/meteor/client/views/omnichannel/realTimeMonitoring/charts/ResponseTimesChart.js @@ -46,7 +46,7 @@ const ResponseTimesChart = ({ params, reloadRef, ...props }) => { init, }); - const { value: data, phase: state, reload } = useEndpointData('/v1/livechat/analytics/dashboards/charts/timings', params); + const { value: data, phase: state, reload } = useEndpointData('/v1/livechat/analytics/dashboards/charts/timings', { params }); reloadRef.current.responseTimesChart = reload; diff --git a/apps/meteor/client/views/omnichannel/realTimeMonitoring/overviews/AgentsOverview.js b/apps/meteor/client/views/omnichannel/realTimeMonitoring/overviews/AgentsOverview.js index f0c4fdc353bb..08eafa0aebab 100644 --- a/apps/meteor/client/views/omnichannel/realTimeMonitoring/overviews/AgentsOverview.js +++ b/apps/meteor/client/views/omnichannel/realTimeMonitoring/overviews/AgentsOverview.js @@ -11,7 +11,11 @@ const overviewInitalValue = { const initialData = [overviewInitalValue, overviewInitalValue, overviewInitalValue]; const AgentsOverview = ({ params, reloadRef, ...props }) => { - const { value: data, phase: state, reload } = useEndpointData('/v1/livechat/analytics/dashboards/agents-productivity-totalizers', params); + const { + value: data, + phase: state, + reload, + } = useEndpointData('/v1/livechat/analytics/dashboards/agents-productivity-totalizers', { params }); reloadRef.current.agentsOverview = reload; diff --git a/apps/meteor/client/views/omnichannel/realTimeMonitoring/overviews/ChatsOverview.js b/apps/meteor/client/views/omnichannel/realTimeMonitoring/overviews/ChatsOverview.js index 21912c1666cc..c351d297c5c3 100644 --- a/apps/meteor/client/views/omnichannel/realTimeMonitoring/overviews/ChatsOverview.js +++ b/apps/meteor/client/views/omnichannel/realTimeMonitoring/overviews/ChatsOverview.js @@ -10,7 +10,7 @@ const initialData = [ ]; const ChatsOverview = ({ params, reloadRef, ...props }) => { - const { value: data, phase: state, reload } = useEndpointData('/v1/livechat/analytics/dashboards/chats-totalizers', params); + const { value: data, phase: state, reload } = useEndpointData('/v1/livechat/analytics/dashboards/chats-totalizers', { params }); reloadRef.current.chatsOverview = reload; diff --git a/apps/meteor/client/views/omnichannel/realTimeMonitoring/overviews/ConversationOverview.js b/apps/meteor/client/views/omnichannel/realTimeMonitoring/overviews/ConversationOverview.js index 141f50968d77..08d7a9d101e2 100644 --- a/apps/meteor/client/views/omnichannel/realTimeMonitoring/overviews/ConversationOverview.js +++ b/apps/meteor/client/views/omnichannel/realTimeMonitoring/overviews/ConversationOverview.js @@ -11,7 +11,7 @@ const overviewInitalValue = { const initialData = [overviewInitalValue, overviewInitalValue, overviewInitalValue, overviewInitalValue]; const ConversationOverview = ({ params, reloadRef, ...props }) => { - const { value: data, phase: state, reload } = useEndpointData('/v1/livechat/analytics/dashboards/conversation-totalizers', params); + const { value: data, phase: state, reload } = useEndpointData('/v1/livechat/analytics/dashboards/conversation-totalizers', { params }); reloadRef.current.conversationOverview = reload; diff --git a/apps/meteor/client/views/omnichannel/realTimeMonitoring/overviews/ProductivityOverview.js b/apps/meteor/client/views/omnichannel/realTimeMonitoring/overviews/ProductivityOverview.js index 9e76b9d3e337..691a2e1b8840 100644 --- a/apps/meteor/client/views/omnichannel/realTimeMonitoring/overviews/ProductivityOverview.js +++ b/apps/meteor/client/views/omnichannel/realTimeMonitoring/overviews/ProductivityOverview.js @@ -8,7 +8,7 @@ const defaultValue = { title: '', value: '00:00:00' }; const initialData = [defaultValue, defaultValue, defaultValue, defaultValue]; const ProductivityOverview = ({ params, reloadRef, ...props }) => { - const { value: data, phase: state, reload } = useEndpointData('/v1/livechat/analytics/dashboards/productivity-totalizers', params); + const { value: data, phase: state, reload } = useEndpointData('/v1/livechat/analytics/dashboards/productivity-totalizers', { params }); reloadRef.current.productivityOverview = reload; diff --git a/apps/meteor/client/views/omnichannel/triggers/EditTriggerPageContainer.js b/apps/meteor/client/views/omnichannel/triggers/EditTriggerPageContainer.js index 96f76541d2db..6252ce51c198 100644 --- a/apps/meteor/client/views/omnichannel/triggers/EditTriggerPageContainer.js +++ b/apps/meteor/client/views/omnichannel/triggers/EditTriggerPageContainer.js @@ -9,7 +9,7 @@ import EditTriggerPage from './EditTriggerPage'; const EditTriggerPageContainer = ({ id, onSave }) => { const t = useTranslation(); - const { value: data, phase: state } = useEndpointData(`/v1/livechat/triggers/${id}`); + const { value: data, phase: state } = useEndpointData('/v1/livechat/triggers/:_id', { keys: { _id: id } }); if (state === AsyncStatePhase.LOADING) { return ; diff --git a/apps/meteor/client/views/omnichannel/triggers/TriggersTableContainer.js b/apps/meteor/client/views/omnichannel/triggers/TriggersTableContainer.js index 270f702bd8ef..4acb025cc798 100644 --- a/apps/meteor/client/views/omnichannel/triggers/TriggersTableContainer.js +++ b/apps/meteor/client/views/omnichannel/triggers/TriggersTableContainer.js @@ -16,10 +16,9 @@ const TriggersTableContainer = ({ reloadRef }) => { value: data, phase: state, reload, - } = useEndpointData( - '/v1/livechat/triggers', - useMemo(() => ({ offset: current, count: itemsPerPage }), [current, itemsPerPage]), - ); + } = useEndpointData('/v1/livechat/triggers', { + params: useMemo(() => ({ offset: current, count: itemsPerPage }), [current, itemsPerPage]), + }); reloadRef.current = reload; diff --git a/apps/meteor/client/views/teams/contextualBar/TeamAutocomplete/TeamAutocomplete.js b/apps/meteor/client/views/teams/contextualBar/TeamAutocomplete/TeamAutocomplete.js index 0f06cb132b2c..7b3d3523dc3c 100644 --- a/apps/meteor/client/views/teams/contextualBar/TeamAutocomplete/TeamAutocomplete.js +++ b/apps/meteor/client/views/teams/contextualBar/TeamAutocomplete/TeamAutocomplete.js @@ -7,10 +7,7 @@ import Avatar from './Avatar'; const TeamAutocomplete = (props) => { const [filter, setFilter] = useState(''); - const { value: data } = useEndpointData( - '/v1/teams.autocomplete', - useMemo(() => ({ name: filter }), [filter]), - ); + const { value: data } = useEndpointData('/v1/teams.autocomplete', { params: useMemo(() => ({ name: filter }), [filter]) }); const options = useMemo( () => diff --git a/apps/meteor/client/views/teams/contextualBar/info/index.js b/apps/meteor/client/views/teams/contextualBar/info/index.js index f903923050e8..18674a5e2781 100644 --- a/apps/meteor/client/views/teams/contextualBar/info/index.js +++ b/apps/meteor/client/views/teams/contextualBar/info/index.js @@ -15,7 +15,7 @@ export default function TeamsInfoWithRooms({ rid }) { const t = useTranslation(); const params = useMemo(() => ({ roomId: rid }), [rid]); - const { phase, value, error } = useEndpointData('/v1/rooms.info', params); + const { phase, value, error } = useEndpointData('/v1/rooms.info', { params }); if (phase === AsyncStatePhase.LOADING) { return ; diff --git a/apps/meteor/client/views/teams/contextualBar/members/RemoveUsersModal/RemoveUsersModal.js b/apps/meteor/client/views/teams/contextualBar/members/RemoveUsersModal/RemoveUsersModal.js index 25bc54b72baa..76a38b680692 100644 --- a/apps/meteor/client/views/teams/contextualBar/members/RemoveUsersModal/RemoveUsersModal.js +++ b/apps/meteor/client/views/teams/contextualBar/members/RemoveUsersModal/RemoveUsersModal.js @@ -11,15 +11,8 @@ const initialData = { user: { username: '' } }; const RemoveUsersModal = ({ teamId, userId, onClose, onCancel, onConfirm }) => { const t = useTranslation(); - const { value, phase } = useEndpointData( - '/v1/teams.listRoomsOfUser', - useMemo(() => ({ teamId, userId }), [teamId, userId]), - ); - const userDataFetch = useEndpointData( - '/v1/users.info', - useMemo(() => ({ userId }), [userId]), - initialData, - ); + const { value, phase } = useEndpointData('/v1/teams.listRoomsOfUser', { params: useMemo(() => ({ teamId, userId }), [teamId, userId]) }); + const userDataFetch = useEndpointData('/v1/users.info', { params: useMemo(() => ({ userId }), [userId]), initialValue: initialData }); const { user: { username }, } = userDataFetch?.value; diff --git a/apps/meteor/ee/client/audit/RoomAutoComplete/RoomAutoComplete.js b/apps/meteor/ee/client/audit/RoomAutoComplete/RoomAutoComplete.js index f690814fed74..edb96d1b0686 100644 --- a/apps/meteor/ee/client/audit/RoomAutoComplete/RoomAutoComplete.js +++ b/apps/meteor/ee/client/audit/RoomAutoComplete/RoomAutoComplete.js @@ -8,10 +8,7 @@ const query = (name = '') => ({ selector: JSON.stringify({ name }) }); const RoomAutoComplete = (props) => { const [filter, setFilter] = useState(''); - const { value: data } = useEndpointData( - '/v1/rooms.autocomplete.adminRooms', - useMemo(() => query(filter), [filter]), - ); + const { value: data } = useEndpointData('/v1/rooms.autocomplete.adminRooms', { params: useMemo(() => query(filter), [filter]) }); const options = useMemo( () => (data && diff --git a/apps/meteor/ee/client/audit/VisitorAutoComplete.js b/apps/meteor/ee/client/audit/VisitorAutoComplete.js index 1bc9b22de288..88fcf960e8f1 100644 --- a/apps/meteor/ee/client/audit/VisitorAutoComplete.js +++ b/apps/meteor/ee/client/audit/VisitorAutoComplete.js @@ -7,10 +7,7 @@ const query = (term = '') => ({ selector: JSON.stringify({ term }) }); const VisitorAutoComplete = (props) => { const [filter, setFilter] = useState(''); - const { value: data } = useEndpointData( - '/v1/livechat/visitors.autocomplete', - useMemo(() => query(filter), [filter]), - ); + const { value: data } = useEndpointData('/v1/livechat/visitors.autocomplete', { params: useMemo(() => query(filter), [filter]) }); const options = useMemo(() => (data && data.items.map((user) => ({ value: user._id, label: user.name }))) || [], [data]); return ( { value: data, phase: state, reload, - } = useEndpointData( - '/v1/livechat/business-hours', - useMemo( + } = useEndpointData('/v1/livechat/business-hours', { + params: useMemo( () => ({ count: params.itemsPerPage, offset: params.current, @@ -24,7 +23,7 @@ const BusinessHoursTableContainer = () => { }), [params], ), - ); + }); if (state === AsyncStatePhase.REJECTED) { return {t('Error')}: error; diff --git a/apps/meteor/ee/client/omnichannel/ContactManagerInfo.js b/apps/meteor/ee/client/omnichannel/ContactManagerInfo.js index 6a25be2216bb..00838a0a14e6 100644 --- a/apps/meteor/ee/client/omnichannel/ContactManagerInfo.js +++ b/apps/meteor/ee/client/omnichannel/ContactManagerInfo.js @@ -13,10 +13,7 @@ const wordBreak = css` `; function ContactManagerInfo({ username }) { - const { value: data, phase: state } = useEndpointData( - `/v1/users.info`, - useMemo(() => ({ username }), [username]), - ); + const { value: data, phase: state } = useEndpointData('/v1/users.info', { params: useMemo(() => ({ username }), [username]) }); if (!data && state === AsyncStatePhase.LOADING) { return null; } diff --git a/apps/meteor/ee/client/omnichannel/additionalForms/DepartmentBusinessHours.js b/apps/meteor/ee/client/omnichannel/additionalForms/DepartmentBusinessHours.js index 12fb93f551df..2b3fabc73a8b 100644 --- a/apps/meteor/ee/client/omnichannel/additionalForms/DepartmentBusinessHours.js +++ b/apps/meteor/ee/client/omnichannel/additionalForms/DepartmentBusinessHours.js @@ -6,10 +6,7 @@ import { useEndpointData } from '../../../../client/hooks/useEndpointData'; export const DepartmentBusinessHours = ({ bhId }) => { const t = useTranslation(); - const { value: data } = useEndpointData( - '/v1/livechat/business-hour', - useMemo(() => ({ _id: bhId, type: 'custom' }), [bhId]), - ); + const { value: data } = useEndpointData('/v1/livechat/business-hour', { params: useMemo(() => ({ _id: bhId, type: 'custom' }), [bhId]) }); const name = data && data.businessHour && data.businessHour.name; diff --git a/apps/meteor/ee/client/omnichannel/monitors/MonitorsPage.js b/apps/meteor/ee/client/omnichannel/monitors/MonitorsPage.js index 1be85c984ec9..be7ae6d9cbdd 100644 --- a/apps/meteor/ee/client/omnichannel/monitors/MonitorsPage.js +++ b/apps/meteor/ee/client/omnichannel/monitors/MonitorsPage.js @@ -30,7 +30,7 @@ const MonitorsPage = () => { const [sort, setSort] = useState(['name', 'asc']); const [username, setUsername] = useState(''); - const { value: data, phase: state, reload } = useEndpointData('/v1/livechat/monitors', useQuery(params, sort)); + const { value: data, phase: state, reload } = useEndpointData('/v1/livechat/monitors', { params: useQuery(params, sort) }); const addMonitor = useMethod('livechat:addMonitor'); diff --git a/apps/meteor/ee/client/omnichannel/priorities/PrioritiesRoute.js b/apps/meteor/ee/client/omnichannel/priorities/PrioritiesRoute.js index 7d1d4e4536ae..cfeb8feec5a9 100644 --- a/apps/meteor/ee/client/omnichannel/priorities/PrioritiesRoute.js +++ b/apps/meteor/ee/client/omnichannel/priorities/PrioritiesRoute.js @@ -61,7 +61,7 @@ function PrioritiesRoute() { }), ); - const { value: data = {}, reload } = useEndpointData('/v1/livechat/priorities', query); + const { value: data = {}, reload } = useEndpointData('/v1/livechat/priorities', { params: query }); const header = useMemo( () => diff --git a/apps/meteor/ee/client/omnichannel/priorities/PriorityEditWithData.js b/apps/meteor/ee/client/omnichannel/priorities/PriorityEditWithData.js index 9362d516e5bb..b8ee09082923 100644 --- a/apps/meteor/ee/client/omnichannel/priorities/PriorityEditWithData.js +++ b/apps/meteor/ee/client/omnichannel/priorities/PriorityEditWithData.js @@ -8,7 +8,7 @@ import { useEndpointData } from '../../../../client/hooks/useEndpointData'; import PriorityEdit from './PriorityEdit'; function PriorityEditWithData({ priorityId, reload }) { - const { value: data, phase: state, error } = useEndpointData(`/v1/livechat/priorities/${priorityId}`); + const { value: data, phase: state, error } = useEndpointData('/v1/livechat/priorities/:priorityId', { keys: { priorityId } }); const t = useTranslation(); diff --git a/apps/meteor/ee/client/omnichannel/tags/TagEditWithData.js b/apps/meteor/ee/client/omnichannel/tags/TagEditWithData.js index 9e575230aa7c..4426e9fc8caf 100644 --- a/apps/meteor/ee/client/omnichannel/tags/TagEditWithData.js +++ b/apps/meteor/ee/client/omnichannel/tags/TagEditWithData.js @@ -9,7 +9,7 @@ import TagEdit from './TagEdit'; import TagEditWithDepartmentData from './TagEditWithDepartmentData'; function TagEditWithData({ tagId, reload, title }) { - const { value: data, phase: state, error } = useEndpointData(`/v1/livechat/tags/${tagId}`); + const { value: data, phase: state, error } = useEndpointData('/v1/livechat/tags/:tagId', { keys: { tagId } }); const t = useTranslation(); diff --git a/apps/meteor/ee/client/omnichannel/tags/TagsRoute.js b/apps/meteor/ee/client/omnichannel/tags/TagsRoute.js index 84edbcc511dc..6b3b1dbe8a68 100644 --- a/apps/meteor/ee/client/omnichannel/tags/TagsRoute.js +++ b/apps/meteor/ee/client/omnichannel/tags/TagsRoute.js @@ -59,7 +59,7 @@ function TagsRoute() { }), ); - const { value: data = {}, reload } = useEndpointData('/v1/livechat/tags', query); + const { value: data = {}, reload } = useEndpointData('/v1/livechat/tags', { params: query }); const header = useMemo( () => diff --git a/apps/meteor/ee/client/omnichannel/units/UnitsRoute.js b/apps/meteor/ee/client/omnichannel/units/UnitsRoute.js index 7fcfb57b4ee4..45c3abc196ec 100644 --- a/apps/meteor/ee/client/omnichannel/units/UnitsRoute.js +++ b/apps/meteor/ee/client/omnichannel/units/UnitsRoute.js @@ -60,7 +60,7 @@ function UnitsRoute() { }), ); - const { value: data = {}, reload } = useEndpointData('/v1/livechat/units', query); + const { value: data = {}, reload } = useEndpointData('/v1/livechat/units', { params: query }); const header = useMemo( () => From cc5688729b08976a153a3e6f6c6794b6aa5d2bca Mon Sep 17 00:00:00 2001 From: Diego Sampaio Date: Mon, 2 Jan 2023 17:58:16 -0300 Subject: [PATCH 13/18] Fix deparment routes --- .../views/omnichannel/departments/DepartmentsRoute.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/meteor/client/views/omnichannel/departments/DepartmentsRoute.js b/apps/meteor/client/views/omnichannel/departments/DepartmentsRoute.js index 00e29b11dd60..a8db7d713b86 100644 --- a/apps/meteor/client/views/omnichannel/departments/DepartmentsRoute.js +++ b/apps/meteor/client/views/omnichannel/departments/DepartmentsRoute.js @@ -7,6 +7,7 @@ import GenericTable from '../../../components/GenericTable'; import { useEndpointData } from '../../../hooks/useEndpointData'; import NotAuthorizedPage from '../../notAuthorized/NotAuthorizedPage'; import DepartmentsPage from './DepartmentsPage'; +import EditDepartment from './EditDepartment'; import EditDepartmentWithData from './EditDepartmentWithData'; import RemoveDepartmentButton from './RemoveDepartmentButton'; @@ -131,8 +132,12 @@ function DepartmentsRoute() { return ; } - if (context === 'edit' || context === 'new') { - return ; + if (context === 'new') { + return ; + } + + if (context === 'edit') { + return ; } return ( From 29ac6ed1bf5e3550c741593423718cdaefa8fbaf Mon Sep 17 00:00:00 2001 From: Diego Sampaio Date: Mon, 2 Jan 2023 18:26:51 -0300 Subject: [PATCH 14/18] Better fix --- .../views/omnichannel/departments/DepartmentsRoute.js | 2 +- .../views/omnichannel/departments/EditDepartment.js | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/apps/meteor/client/views/omnichannel/departments/DepartmentsRoute.js b/apps/meteor/client/views/omnichannel/departments/DepartmentsRoute.js index a8db7d713b86..38d5f392ccfe 100644 --- a/apps/meteor/client/views/omnichannel/departments/DepartmentsRoute.js +++ b/apps/meteor/client/views/omnichannel/departments/DepartmentsRoute.js @@ -133,7 +133,7 @@ function DepartmentsRoute() { } if (context === 'new') { - return ; + return ; } if (context === 'edit') { diff --git a/apps/meteor/client/views/omnichannel/departments/EditDepartment.js b/apps/meteor/client/views/omnichannel/departments/EditDepartment.js index da7349e73d88..2c163df99e08 100644 --- a/apps/meteor/client/views/omnichannel/departments/EditDepartment.js +++ b/apps/meteor/client/views/omnichannel/departments/EditDepartment.js @@ -43,7 +43,9 @@ function EditDepartment({ data, id, title, reload, allowedToForwardData }) { useSelectForwardDepartment = () => {}, } = useFormsSubscription(); - const initialAgents = useRef((data && data.agents) || []); + const { agents } = data || { agents: [] }; + + const initialAgents = useRef(agents); const MaxChats = useEeNumberInput(); const VisitorInactivity = useEeNumberInput(); @@ -242,7 +244,7 @@ function EditDepartment({ data, id, title, reload, allowedToForwardData }) { const formId = useUniqueId(); - const hasNewAgent = useMemo(() => data.agents.length === agentList.length, [data.agents, agentList]); + const hasNewAgent = useMemo(() => agents.length === agentList.length, [agents, agentList]); const agentsHaveChanged = () => { let hasChanges = false; @@ -479,7 +481,7 @@ function EditDepartment({ data, id, title, reload, allowedToForwardData }) { {t('Agents')}: Date: Mon, 2 Jan 2023 22:58:05 -0300 Subject: [PATCH 15/18] update license --- .github/workflows/build_and_test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 36da8a1358d1..7a175c6e7c2f 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -485,9 +485,9 @@ jobs: RC_DOCKER_TAG: '${{ needs.release-versions.outputs.gh-docker-tag }}.official' DOCKER_TAG: ${{ needs.release-versions.outputs.gh-docker-tag }} TRANSPORTER: nats://nats:4222 - # this is 100% intentional, secrets are not available at forks, so ee-tests will always fail - # to avoid this, we are using a dummy license, expiring on 2022-12-31 - ENTERPRISE_LICENSE: GWHMQe3C3lu3if4ropk1iQ09sCKjIaQogwMymgl7pbuotLpHPhTzxvuSqJYmEtHGKX4MQsrYA+8witFF3JMOc3AswwAkxQz+TZz9+XfiBo49p7OL0xfO6f9ElhLHclptcEPFDSilQlmDI1Jjr7k+MdqXxE4XbZ4Pdeg9vdEDtroKvSvd0ngtFMkIXa6829Cg0nzTCCcWo3Jc80JPub6VMgpdZ2KnsswQt8dBz+psvztcwrqF7X5731HkPX0lTttjF6SSIs+WAIdwAY4b2VRtD3PbMWxbe0ac+2x5+ItIRH0PFRh/gVWdtiKfskQpcucU739CX/d4pQGK/OWxKifH1XH824doeyYuvjXwvCW5anPlRXKAqIn2gh6LcdGfFNIbjX9wG4/U162vDr3AtEpRYdjzfvvBW1gveYMGidIiEhQZu7h5Ie9b3tNBkNBgBcqibL9JO6K3/2pxX7gymjT+9VRZgB5+ME2pziD54SjSWCwkLcf/RByxArdDSqI3llKjyDnRXjhqzsLhmsc6UdJCJd1IiqjQ4v5QXH2C57cJlej93ZLuNRFcnb0cE0nAFHIfLSZP5CSJA/gY7mtBL0b0osUisNL/os7a74JFMoa4DDfTD2CarYV5E4+fpX3NqINzpYwFzZi9pH2wIL6oe1yuZPcn9vjRhK2jvG81tHSR/4s= + # this is 100% intentional, secrets are not available for forks, so ee-tests will always fail + # to avoid this, we are using a dummy license, expiring at 2023-06-30 + ENTERPRISE_LICENSE: Z2Dg0RC3kyxjuklSE6qfqyvD2xSD+oTYcS9OesJG0523r7rSPjv59LTQqPcp5E61qQYM3MOKoW3mDrurw4h78nVbsfrF2DoJZeNjRFQfIbgwcdPwtmnqPpDvAslszHY16VzM7O7EYqAqp/9mlnRzs1iJY+W3w1r6HWBlVMb9u41bl5HBSpX6Nxw8YxL4mizwOpjxewQbPQvNTLJNAW6w0nCzF5A3CKBhD9fziadedVMLOuXBuR8kIl8zbIAfqpHmL8SvakvQAbZEjWWQshmH+C9CKA5PppkmA8Q1DNWQoVtHSiYDK8RRjAEx+0oGflklzFyhJFDvD+ohZduNtNCgrJmxP5VFrVrLSK4BXgTSwwnaSKa2N+Qx0CmuRfu7nCPc1Cf6h6+k2TXvzkE4Z0ZJnDV1khu611glAr99bHdwF+bMX3XZI66bS8KqnHEukCt5xei25iKJ2xrfmGuiAkAuKHKzBmTEmXM0pGhkfDhA9jhxG3Atoj1A5y8vdrs88voF+UuNFZ6k9sKtdvrWIWClnkatPE+41ggbzCsOhFz07BvRWaEtw2Kenipl4Vtag4qmFpUaUfsuouH99M3gDlysDZO3x5aH8yfzvFeL5WDMvsmdEHNLpHl89WsPCONvx0JjRSdwcCA1NrRuVy1Ncu0S0bRByn7HZqoY9u6HPkXKBxQ= run: | docker compose -f docker-compose-ci.yml up -d --build From 825d12e3b9560593970297a6c1d5b570d1617d3f Mon Sep 17 00:00:00 2001 From: Diego Sampaio Date: Mon, 9 Jan 2023 09:14:09 -0300 Subject: [PATCH 16/18] Update Meteor to 2.9.1 --- apps/meteor/.meteor/packages | 2 +- apps/meteor/.meteor/release | 2 +- apps/meteor/.meteor/versions | 9 +++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/apps/meteor/.meteor/packages b/apps/meteor/.meteor/packages index f71168827bb2..63e36de0e438 100644 --- a/apps/meteor/.meteor/packages +++ b/apps/meteor/.meteor/packages @@ -13,7 +13,7 @@ accounts-facebook@1.3.3 accounts-github@1.5.0 accounts-google@1.4.0 accounts-meteor-developer@1.5.0 -accounts-password@2.3.2 +accounts-password@2.3.3 accounts-twitter@1.5.0 blaze-html-templates check@1.3.2 diff --git a/apps/meteor/.meteor/release b/apps/meteor/.meteor/release index e1e355d0cdb0..eff99d911ecb 100644 --- a/apps/meteor/.meteor/release +++ b/apps/meteor/.meteor/release @@ -1 +1 @@ -METEOR@2.9.0 +METEOR@2.9.1 diff --git a/apps/meteor/.meteor/versions b/apps/meteor/.meteor/versions index 57780346a135..7eadce0be117 100644 --- a/apps/meteor/.meteor/versions +++ b/apps/meteor/.meteor/versions @@ -4,7 +4,7 @@ accounts-github@1.5.0 accounts-google@1.4.0 accounts-meteor-developer@1.5.0 accounts-oauth@1.4.2 -accounts-password@2.3.2 +accounts-password@2.3.3 accounts-twitter@1.5.0 aldeed:simple-schema@1.5.4 allow-deny@1.1.1 @@ -42,7 +42,7 @@ email@2.2.3 es5-shim@4.8.0 facebook-oauth@1.11.2 facts-base@1.0.1 -fetch@0.1.2 +fetch@0.1.3 geojson-utils@1.0.11 github-oauth@1.4.1 google-oauth@1.4.3 @@ -66,9 +66,9 @@ launch-screen@1.3.0 littledata:synced-cron@1.5.1 localstorage@1.2.0 logging@1.3.1 -matb33:collection-hooks@1.1.4 +matb33:collection-hooks@1.2.0 mdg:validation-error@0.5.1 -meteor@1.10.3 +meteor@1.10.4 meteor-base@1.5.1 meteor-developer-oauth@1.3.2 meteorhacks:inject-initial@1.0.5 @@ -139,3 +139,4 @@ underscore@1.0.11 url@1.3.2 webapp@1.13.2 webapp-hashing@1.1.1 +zodern:types@1.0.9 From fdac0753f4b5b9519f0e63b807711afb7a81ff87 Mon Sep 17 00:00:00 2001 From: Diego Sampaio Date: Mon, 9 Jan 2023 09:15:15 -0300 Subject: [PATCH 17/18] Update NodeJS to 14.21.2 --- .github/workflows/build_and_test.yml | 10 +++++----- apps/meteor/.docker-mongo/Dockerfile | 2 +- apps/meteor/.docker/Dockerfile | 2 +- apps/meteor/.docker/Dockerfile.alpine | 2 +- apps/meteor/ee/server/services/Dockerfile | 4 ++-- ee/apps/account-service/Dockerfile | 2 +- ee/apps/authorization-service/Dockerfile | 2 +- ee/apps/ddp-streamer/Dockerfile | 2 +- ee/apps/presence-service/Dockerfile | 2 +- ee/apps/stream-hub-service/Dockerfile | 2 +- package.json | 4 ++-- 11 files changed, 17 insertions(+), 17 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 7a175c6e7c2f..a9b285b074a8 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -79,10 +79,10 @@ jobs: - uses: actions/checkout@v3 - - name: Use Node.js 14.21.1 + - name: Use Node.js 14.21.2 uses: actions/setup-node@v3 with: - node-version: '14.21.1' + node-version: '14.21.2' cache: 'yarn' - name: Free disk space @@ -222,7 +222,7 @@ jobs: strategy: matrix: - node-version: ['14.21.1'] + node-version: ['14.21.2'] mongodb-version: ['4.2', '4.4', '5.0'] steps: @@ -423,7 +423,7 @@ jobs: strategy: matrix: - node-version: ['14.21.1'] + node-version: ['14.21.2'] mongodb-version-ee: ['4.4'] steps: @@ -693,7 +693,7 @@ jobs: aws s3 cp $ROCKET_DEPLOY_DIR/ s3://download.rocket.chat/build/ --recursive curl -H "Content-Type: application/json" -H "X-Update-Token: $UPDATE_TOKEN" -d \ - "{\"nodeVersion\": \"14.21.1\", \"compatibleMongoVersions\": [\"4.2\", \"4.4\", \"5.0\"], \"commit\": \"$GITHUB_SHA\", \"tag\": \"$RC_VERSION\", \"branch\": \"$GIT_BRANCH\", \"artifactName\": \"$ARTIFACT_NAME\", \"releaseType\": \"$RC_RELEASE\"}" \ + "{\"nodeVersion\": \"14.21.2\", \"compatibleMongoVersions\": [\"4.2\", \"4.4\", \"5.0\"], \"commit\": \"$GITHUB_SHA\", \"tag\": \"$RC_VERSION\", \"branch\": \"$GIT_BRANCH\", \"artifactName\": \"$ARTIFACT_NAME\", \"releaseType\": \"$RC_RELEASE\"}" \ https://releases.rocket.chat/update # Makes build fail if the release isn't there diff --git a/apps/meteor/.docker-mongo/Dockerfile b/apps/meteor/.docker-mongo/Dockerfile index fbc2c2a37d06..998fda046363 100644 --- a/apps/meteor/.docker-mongo/Dockerfile +++ b/apps/meteor/.docker-mongo/Dockerfile @@ -1,4 +1,4 @@ -FROM node:14.21.1-bullseye-slim +FROM node:14.21.2-bullseye-slim LABEL maintainer="buildmaster@rocket.chat" diff --git a/apps/meteor/.docker/Dockerfile b/apps/meteor/.docker/Dockerfile index 3fa996468957..aeb5f4648aaa 100644 --- a/apps/meteor/.docker/Dockerfile +++ b/apps/meteor/.docker/Dockerfile @@ -1,4 +1,4 @@ -FROM node:14.21.1-bullseye-slim +FROM node:14.21.2-bullseye-slim LABEL maintainer="buildmaster@rocket.chat" diff --git a/apps/meteor/.docker/Dockerfile.alpine b/apps/meteor/.docker/Dockerfile.alpine index 8b15269d1f54..14684f5d53c9 100644 --- a/apps/meteor/.docker/Dockerfile.alpine +++ b/apps/meteor/.docker/Dockerfile.alpine @@ -1,4 +1,4 @@ -FROM node:14.21.1-alpine3.15 +FROM node:14.21.2-alpine3.15 RUN apk add --no-cache ttf-dejavu diff --git a/apps/meteor/ee/server/services/Dockerfile b/apps/meteor/ee/server/services/Dockerfile index 1e09502003e4..19e530c82d0f 100644 --- a/apps/meteor/ee/server/services/Dockerfile +++ b/apps/meteor/ee/server/services/Dockerfile @@ -1,4 +1,4 @@ -FROM node:14.21.1 as build +FROM node:14.21.2 as build WORKDIR /app @@ -27,7 +27,7 @@ COPY ./tsconfig.base.json . RUN yarn workspace @rocket.chat/core-typings run build \ && yarn workspace @rocket.chat/rest-typings run build -FROM node:14.21.1-alpine +FROM node:14.21.2-alpine ARG SERVICE diff --git a/ee/apps/account-service/Dockerfile b/ee/apps/account-service/Dockerfile index bd5ea1bee556..515b1978e060 100644 --- a/ee/apps/account-service/Dockerfile +++ b/ee/apps/account-service/Dockerfile @@ -1,4 +1,4 @@ -FROM node:14.21.1-alpine +FROM node:14.21.2-alpine ARG SERVICE diff --git a/ee/apps/authorization-service/Dockerfile b/ee/apps/authorization-service/Dockerfile index bd5ea1bee556..515b1978e060 100644 --- a/ee/apps/authorization-service/Dockerfile +++ b/ee/apps/authorization-service/Dockerfile @@ -1,4 +1,4 @@ -FROM node:14.21.1-alpine +FROM node:14.21.2-alpine ARG SERVICE diff --git a/ee/apps/ddp-streamer/Dockerfile b/ee/apps/ddp-streamer/Dockerfile index bd5ea1bee556..515b1978e060 100644 --- a/ee/apps/ddp-streamer/Dockerfile +++ b/ee/apps/ddp-streamer/Dockerfile @@ -1,4 +1,4 @@ -FROM node:14.21.1-alpine +FROM node:14.21.2-alpine ARG SERVICE diff --git a/ee/apps/presence-service/Dockerfile b/ee/apps/presence-service/Dockerfile index 2f95237182be..3e1ca1b835c1 100644 --- a/ee/apps/presence-service/Dockerfile +++ b/ee/apps/presence-service/Dockerfile @@ -1,4 +1,4 @@ -FROM node:14.21.1-alpine +FROM node:14.21.2-alpine ARG SERVICE diff --git a/ee/apps/stream-hub-service/Dockerfile b/ee/apps/stream-hub-service/Dockerfile index bd5ea1bee556..515b1978e060 100644 --- a/ee/apps/stream-hub-service/Dockerfile +++ b/ee/apps/stream-hub-service/Dockerfile @@ -1,4 +1,4 @@ -FROM node:14.21.1-alpine +FROM node:14.21.2-alpine ARG SERVICE diff --git a/package.json b/package.json index 88375710fc9f..ab152f0d87f7 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "homepage": "https://github.com/RocketChat/Rocket.Chat#readme", "engines": { "yarn": "3.2.2", - "node": "14.21.1", + "node": "14.21.2", "npm": "Use yarn instead" }, "packageManager": "yarn@3.2.2", @@ -55,7 +55,7 @@ ] }, "volta": { - "node": "14.21.1", + "node": "14.21.2", "yarn": "1.22.18" }, "resolutions": { From 56ef2567bdcc21841a217f7e1b816719e0e2b016 Mon Sep 17 00:00:00 2001 From: Diego Sampaio Date: Mon, 9 Jan 2023 09:58:25 -0300 Subject: [PATCH 18/18] Update Alpine --- apps/meteor/.docker/Dockerfile.alpine | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/meteor/.docker/Dockerfile.alpine b/apps/meteor/.docker/Dockerfile.alpine index 14684f5d53c9..cc896cf9051f 100644 --- a/apps/meteor/.docker/Dockerfile.alpine +++ b/apps/meteor/.docker/Dockerfile.alpine @@ -1,4 +1,4 @@ -FROM node:14.21.2-alpine3.15 +FROM node:14.21.2-alpine3.16 RUN apk add --no-cache ttf-dejavu