From c51f73441d923d5d6bddfbd1e473b9660c9a686c Mon Sep 17 00:00:00 2001 From: Douglas Gubert Date: Fri, 17 Nov 2023 13:14:45 -0300 Subject: [PATCH 01/33] 1.42.0-alpha --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3bca5736e..1cb8d5470 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@rocket.chat/apps-engine", - "version": "1.41.0", + "version": "1.42.0-alpha", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index e0d1ebf2d..a581b37d1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@rocket.chat/apps-engine", - "version": "1.41.0", + "version": "1.42.0-alpha", "description": "The engine code for the Rocket.Chat Apps which manages, runs, translates, coordinates and all of that.", "main": "index", "typings": "index", From c32bc857f50c9214a73415c0099d6dd002ef24ab Mon Sep 17 00:00:00 2001 From: Luis Mauro <1216941+lmauromb@users.noreply.github.com> Date: Wed, 14 Feb 2024 11:25:32 -0600 Subject: [PATCH 02/33] feat: PROSVC-55 findRoomsByAgentId (#710) --- src/definition/accessors/ILivechatRead.ts | 2 ++ src/server/accessors/LivechatRead.ts | 8 ++++++++ src/server/bridges/LivechatBridge.ts | 16 ++++++++++++++++ tests/test-data/bridges/livechatBridge.ts | 8 ++++++++ 4 files changed, 34 insertions(+) diff --git a/src/definition/accessors/ILivechatRead.ts b/src/definition/accessors/ILivechatRead.ts index 6a7650949..91bdd487e 100644 --- a/src/definition/accessors/ILivechatRead.ts +++ b/src/definition/accessors/ILivechatRead.ts @@ -17,6 +17,8 @@ export interface ILivechatRead { isOnlineAsync(departmentId?: string): Promise; getDepartmentsEnabledWithAgents(): Promise>; getLivechatRooms(visitor: IVisitor, departmentId?: string): Promise>; + getLivechatRoomsByAgentId(agentId: string): Promise>; + getLivechatTotalRoomsByAgentId(agentId: string): Promise; /** * @deprecated This method does not adhere to the conversion practices applied * elsewhere in the Apps-Engine and will be removed in the next major version. diff --git a/src/server/accessors/LivechatRead.ts b/src/server/accessors/LivechatRead.ts index d58a4a531..ef7503976 100644 --- a/src/server/accessors/LivechatRead.ts +++ b/src/server/accessors/LivechatRead.ts @@ -30,6 +30,14 @@ export class LivechatRead implements ILivechatRead { return this.livechatBridge.doFindRooms(visitor, departmentId, this.appId); } + public getLivechatTotalRoomsByAgentId(agentId: string): Promise { + return this.livechatBridge.doCountRoomsByAgentId(agentId, this.appId); + } + + public getLivechatRoomsByAgentId(agentId: string): Promise> { + return this.livechatBridge.doFindRoomsByAgentId(agentId, this.appId); + } + /** * @deprecated This method does not adhere to the conversion practices applied * elsewhere in the Apps-Engine and will be removed in the next major version. diff --git a/src/server/bridges/LivechatBridge.ts b/src/server/bridges/LivechatBridge.ts index 48ab69942..8ca7b542f 100644 --- a/src/server/bridges/LivechatBridge.ts +++ b/src/server/bridges/LivechatBridge.ts @@ -104,6 +104,18 @@ export abstract class LivechatBridge extends BaseBridge { } } + public async doCountRoomsByAgentId(agentId: string, appId: string): Promise { + if (this.hasReadPermission(appId, 'livechat-room')) { + return this.countRoomsByAgentId(agentId, appId); + } + } + + public async doFindRoomsByAgentId(agentId: string, appId: string): Promise> { + if (this.hasReadPermission(appId, 'livechat-room')) { + return this.findRoomsByAgentId(agentId, appId); + } + } + public async doFindRooms(visitor: IVisitor, departmentId: string | null, appId: string): Promise> { if (this.hasReadPermission(appId, 'livechat-room')) { return this.findRooms(visitor, departmentId, appId); @@ -171,6 +183,10 @@ export abstract class LivechatBridge extends BaseBridge { protected abstract closeRoom(room: ILivechatRoom, comment: string, closer: IUser | undefined, appId: string): Promise; + protected abstract countRoomsByAgentId(agentId: string, appId: string): Promise; + + protected abstract findRoomsByAgentId(agentId: string, appId: string): Promise>; + protected abstract findRooms(visitor: IVisitor, departmentId: string | null, appId: string): Promise>; protected abstract findDepartmentByIdOrName(value: string, appId: string): Promise; diff --git a/tests/test-data/bridges/livechatBridge.ts b/tests/test-data/bridges/livechatBridge.ts index c9beb66f4..9898be1ae 100644 --- a/tests/test-data/bridges/livechatBridge.ts +++ b/tests/test-data/bridges/livechatBridge.ts @@ -70,6 +70,14 @@ export class TestLivechatBridge extends LivechatBridge { throw new Error('Method not implemented'); } + public findRoomsByAgentId(agentId: string, appId: string): Promise { + throw new Error('Method not implemented'); + } + + public countRoomsByAgentId(agentId: string, appId: string): Promise { + throw new Error('Method not implemented'); + } + public findDepartmentByIdOrName(value: string, appId: string): Promise { throw new Error('Method not implemented'); } From cba70dc0645683e9cce80de942c56f89fedc8a4b Mon Sep 17 00:00:00 2001 From: Luis Mauro <1216941+lmauromb@users.noreply.github.com> Date: Tue, 12 Mar 2024 17:31:39 -0600 Subject: [PATCH 03/33] chore: add Open prefix to find/count by agent methods (#735) --- src/definition/accessors/ILivechatRead.ts | 4 ++-- src/server/accessors/LivechatRead.ts | 8 ++++---- src/server/bridges/LivechatBridge.ts | 12 ++++++------ tests/test-data/bridges/livechatBridge.ts | 4 ++-- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/definition/accessors/ILivechatRead.ts b/src/definition/accessors/ILivechatRead.ts index 91bdd487e..a756d162c 100644 --- a/src/definition/accessors/ILivechatRead.ts +++ b/src/definition/accessors/ILivechatRead.ts @@ -17,8 +17,8 @@ export interface ILivechatRead { isOnlineAsync(departmentId?: string): Promise; getDepartmentsEnabledWithAgents(): Promise>; getLivechatRooms(visitor: IVisitor, departmentId?: string): Promise>; - getLivechatRoomsByAgentId(agentId: string): Promise>; - getLivechatTotalRoomsByAgentId(agentId: string): Promise; + getLivechatOpenRoomsByAgentId(agentId: string): Promise>; + getLivechatTotalOpenRoomsByAgentId(agentId: string): Promise; /** * @deprecated This method does not adhere to the conversion practices applied * elsewhere in the Apps-Engine and will be removed in the next major version. diff --git a/src/server/accessors/LivechatRead.ts b/src/server/accessors/LivechatRead.ts index ef7503976..3d9421ff9 100644 --- a/src/server/accessors/LivechatRead.ts +++ b/src/server/accessors/LivechatRead.ts @@ -30,12 +30,12 @@ export class LivechatRead implements ILivechatRead { return this.livechatBridge.doFindRooms(visitor, departmentId, this.appId); } - public getLivechatTotalRoomsByAgentId(agentId: string): Promise { - return this.livechatBridge.doCountRoomsByAgentId(agentId, this.appId); + public getLivechatTotalOpenRoomsByAgentId(agentId: string): Promise { + return this.livechatBridge.doCountOpenRoomsByAgentId(agentId, this.appId); } - public getLivechatRoomsByAgentId(agentId: string): Promise> { - return this.livechatBridge.doFindRoomsByAgentId(agentId, this.appId); + public getLivechatOpenRoomsByAgentId(agentId: string): Promise> { + return this.livechatBridge.doFindOpenRoomsByAgentId(agentId, this.appId); } /** diff --git a/src/server/bridges/LivechatBridge.ts b/src/server/bridges/LivechatBridge.ts index 8ca7b542f..ea9e50f1b 100644 --- a/src/server/bridges/LivechatBridge.ts +++ b/src/server/bridges/LivechatBridge.ts @@ -104,15 +104,15 @@ export abstract class LivechatBridge extends BaseBridge { } } - public async doCountRoomsByAgentId(agentId: string, appId: string): Promise { + public async doCountOpenRoomsByAgentId(agentId: string, appId: string): Promise { if (this.hasReadPermission(appId, 'livechat-room')) { - return this.countRoomsByAgentId(agentId, appId); + return this.countOpenRoomsByAgentId(agentId, appId); } } - public async doFindRoomsByAgentId(agentId: string, appId: string): Promise> { + public async doFindOpenRoomsByAgentId(agentId: string, appId: string): Promise> { if (this.hasReadPermission(appId, 'livechat-room')) { - return this.findRoomsByAgentId(agentId, appId); + return this.findOpenRoomsByAgentId(agentId, appId); } } @@ -183,9 +183,9 @@ export abstract class LivechatBridge extends BaseBridge { protected abstract closeRoom(room: ILivechatRoom, comment: string, closer: IUser | undefined, appId: string): Promise; - protected abstract countRoomsByAgentId(agentId: string, appId: string): Promise; + protected abstract countOpenRoomsByAgentId(agentId: string, appId: string): Promise; - protected abstract findRoomsByAgentId(agentId: string, appId: string): Promise>; + protected abstract findOpenRoomsByAgentId(agentId: string, appId: string): Promise>; protected abstract findRooms(visitor: IVisitor, departmentId: string | null, appId: string): Promise>; diff --git a/tests/test-data/bridges/livechatBridge.ts b/tests/test-data/bridges/livechatBridge.ts index 9898be1ae..83eb45e13 100644 --- a/tests/test-data/bridges/livechatBridge.ts +++ b/tests/test-data/bridges/livechatBridge.ts @@ -70,11 +70,11 @@ export class TestLivechatBridge extends LivechatBridge { throw new Error('Method not implemented'); } - public findRoomsByAgentId(agentId: string, appId: string): Promise { + public findOpenRoomsByAgentId(agentId: string, appId: string): Promise { throw new Error('Method not implemented'); } - public countRoomsByAgentId(agentId: string, appId: string): Promise { + public countOpenRoomsByAgentId(agentId: string, appId: string): Promise { throw new Error('Method not implemented'); } From 79d52ed03d1821910294e8bd50d26e2a4e01045e Mon Sep 17 00:00:00 2001 From: Allan RIbeiro <35040806+AllanPazRibeiro@users.noreply.github.com> Date: Fri, 15 Mar 2024 10:29:08 -0300 Subject: [PATCH 04/33] fix: url import usage on oauth2 (#739) --- src/definition/oauth2/IOAuth2.ts | 2 ++ src/server/oauth2/OAuth2Client.ts | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/definition/oauth2/IOAuth2.ts b/src/definition/oauth2/IOAuth2.ts index ee271f38e..d46fe4dce 100644 --- a/src/definition/oauth2/IOAuth2.ts +++ b/src/definition/oauth2/IOAuth2.ts @@ -1,3 +1,5 @@ +import type { URL } from 'url'; + import type { IConfigurationExtend, IHttp, IModify, IPersistence, IRead } from '../accessors'; import type { IUser } from '../users/IUser'; diff --git a/src/server/oauth2/OAuth2Client.ts b/src/server/oauth2/OAuth2Client.ts index 0c7ff99e8..069ee200c 100644 --- a/src/server/oauth2/OAuth2Client.ts +++ b/src/server/oauth2/OAuth2Client.ts @@ -1,3 +1,5 @@ +import { URL } from 'url'; + import type { IConfigurationExtend, IHttp, IModify, IPersistence, IRead } from '../../definition/accessors'; import { HttpStatusCode } from '../../definition/accessors'; import type { IApiEndpointInfo, IApiRequest, IApiResponse } from '../../definition/api'; From a7ee71563de741ddc27cb2843ea4e91f85b3c6a6 Mon Sep 17 00:00:00 2001 From: Allan RIbeiro <35040806+AllanPazRibeiro@users.noreply.github.com> Date: Sat, 16 Mar 2024 16:00:04 -0300 Subject: [PATCH 05/33] Chore/merge master into alpha (#742) --- docs/interfaces/oauth2_IOAuth2.IAuthData.html | 10 +++++----- .../interfaces/oauth2_IOAuth2.IOAuth2Client.html | 12 ++++++------ .../oauth2_IOAuth2.IOAuth2ClientOptions.html | 16 ++++++++-------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/docs/interfaces/oauth2_IOAuth2.IAuthData.html b/docs/interfaces/oauth2_IOAuth2.IAuthData.html index 9969fbe16..4d71f38ea 100644 --- a/docs/interfaces/oauth2_IOAuth2.IAuthData.html +++ b/docs/interfaces/oauth2_IOAuth2.IAuthData.html @@ -26,7 +26,7 @@

Hierarchy

  • IAuthData
+
  • Defined in src/definition/oauth2/IOAuth2.ts:10
  • @@ -48,7 +48,7 @@
    +
  • Defined in src/definition/oauth2/IOAuth2.ts:18
  • refreshToken?: string
    @@ -58,7 +58,7 @@
    +
  • Defined in src/definition/oauth2/IOAuth2.ts:33
  • scope: string
    @@ -69,7 +69,7 @@
    +
  • Defined in src/definition/oauth2/IOAuth2.ts:26
  • token: string
    @@ -77,7 +77,7 @@
    +
  • Defined in src/definition/oauth2/IOAuth2.ts:14
  • +
  • Defined in src/definition/oauth2/IOAuth2.ts:47
  • authUri: string
    @@ -71,7 +71,7 @@
    +
  • Defined in src/definition/oauth2/IOAuth2.ts:56
  • authorizationCallback?: ((token, user, read, modify, http, persis) => Promise<{
        responseContent?: string;
    }>)
    @@ -103,7 +103,7 @@
    persis: Returns Promise<{
        responseContent?: string;
    }>
    +
  • Defined in src/definition/oauth2/IOAuth2.ts:74
  • defaultScopes?: string[]
    @@ -111,7 +111,7 @@
    +
  • Defined in src/definition/oauth2/IOAuth2.ts:69
  • refreshTokenUri: string
    @@ -119,7 +119,7 @@
    +
  • Defined in src/definition/oauth2/IOAuth2.ts:60
  • revokeTokenUri: string
    @@ -127,7 +127,7 @@
    +
  • Defined in src/definition/oauth2/IOAuth2.ts:64