Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
dc78a98
Add E2E tests to missing omnichannel endpoints
KevLehman Aug 29, 2022
c007d4a
routing
KevLehman Aug 30, 2022
f17adf7
....
KevLehman Aug 30, 2022
bfe17d8
flaky test for some reason
KevLehman Aug 30, 2022
7f0f9b1
asdf
KevLehman Aug 30, 2022
a9581aa
wip
KevLehman Aug 30, 2022
e9e7794
replace fields with projection
KevLehman Aug 30, 2022
050186a
Merge branch 'develop' into chore/make-endpoints-async-omn
KevLehman Aug 30, 2022
946c3da
lgtm
KevLehman Aug 30, 2022
e9509d7
Merge branch 'chore/make-endpoints-async-omn' of github.com:RocketCha…
KevLehman Aug 30, 2022
3eb4c55
more tests and small changes to other endpoints
KevLehman Sep 5, 2022
1ce5158
Merge branch 'develop' into chore/make-endpoints-async-omn
KevLehman Sep 5, 2022
227f1f8
token test
KevLehman Sep 5, 2022
60e3291
god
KevLehman Sep 5, 2022
d75147c
Fix permission checks
KevLehman Sep 6, 2022
93741ee
fix perm check again
KevLehman Sep 6, 2022
83fa8d7
Fix
KevLehman Sep 6, 2022
839317c
more fix
KevLehman Sep 6, 2022
7596dad
wip
KevLehman Sep 7, 2022
5ccb6ba
wip 2
KevLehman Sep 7, 2022
eeaf0f0
final wip
KevLehman Sep 7, 2022
8a6e60e
Typecheck
KevLehman Sep 8, 2022
8065558
fix test
KevLehman Sep 8, 2022
d82f21a
more endpoints to ts
KevLehman Sep 8, 2022
bc9c991
fix
KevLehman Sep 8, 2022
65dbcf3
typecheck again
KevLehman Sep 8, 2022
f1dbfd4
TIL
KevLehman Sep 8, 2022
26fe7d8
wut
KevLehman Sep 8, 2022
3faab88
ffff
KevLehman Sep 8, 2022
18e7f27
Merge branch 'develop' into chore/endpoints-to-ts
KevLehman Sep 12, 2022
a13123b
Merge branch 'develop' into chore/endpoints-to-ts
KevLehman Sep 12, 2022
f873639
fix manager endpoint
KevLehman Sep 13, 2022
889330f
Merge branch 'chore/endpoints-to-ts' of github.com:RocketChat/Rocket.…
KevLehman Sep 13, 2022
343bef7
remove logs but return better validation errors
KevLehman Sep 13, 2022
e25536f
Merge branch 'develop' into chore/endpoints-to-ts
KevLehman Sep 13, 2022
666d90f
fix some tests
KevLehman Sep 13, 2022
481ecd2
Merge branch 'chore/endpoints-to-ts' of github.com:RocketChat/Rocket.…
KevLehman Sep 13, 2022
3fbe22a
Migrate visitors to ts
KevLehman Sep 13, 2022
bb9382e
Migrate agents to ts
KevLehman Sep 13, 2022
8264e2c
migrate appearance and triggers to ts
KevLehman Sep 13, 2022
24ccb90
migrate rooms to ts
KevLehman Sep 13, 2022
3f0b10e
migrate queue to ts
KevLehman Sep 14, 2022
6e71203
migrate integrations to ts
KevLehman Sep 14, 2022
76e8b5b
migrate upload to ts
KevLehman Sep 14, 2022
85a1538
migrate facebook to ts
KevLehman Sep 14, 2022
e45094a
migrate inquiries to ts
KevLehman Sep 14, 2022
365b089
migrate dashboards to ts
KevLehman Sep 14, 2022
3c36522
Merge branch 'develop' into chore/endpoints-to-ts
KevLehman Sep 14, 2022
478d8d9
fix typecheck
KevLehman Sep 14, 2022
951da92
Merge branch 'chore/endpoints-to-ts' of github.com:RocketChat/Rocket.…
KevLehman Sep 14, 2022
162a2ed
fix tests
KevLehman Sep 14, 2022
3f1d66f
review suggs
KevLehman Sep 19, 2022
fa65c59
Merge branch 'develop' into chore/endpoints-to-ts
KevLehman Sep 19, 2022
ff68828
typecheck
KevLehman Sep 19, 2022
4221494
Fix test run
KevLehman Sep 19, 2022
5b4b787
rollback api.js
KevLehman Sep 20, 2022
879c4fd
Fix typing on dashboard endpoint
KevLehman Sep 20, 2022
b1469a9
Merge branch 'develop' into chore/endpoints-to-ts
KevLehman Sep 20, 2022
12d1e1b
Merge branch 'develop' into chore/endpoints-to-ts
kodiakhq[bot] Sep 22, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/meteor/app/api/server/api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ type ActionThis<TMethod extends Method, TPathPattern extends PathPattern, TOptio
me: IUser,
): TOptions extends { authRequired: true } ? UserInfo : TOptions extends { authOrAnonRequired: true } ? UserInfo | undefined : undefined;
composeRoomWithLastMessage(room: IRoom, userId: string): IRoom;
isWidget(): boolean;
} & (TOptions extends { authRequired: true }
? {
readonly user: IUser;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
import { Match, check } from 'meteor/check';
import { isGETLivechatAgentsAgentIdDepartmentsParams } from '@rocket.chat/rest-typings';

import { API } from '../../../../api/server';
import { findAgentDepartments } from '../../../server/api/lib/agents';

API.v1.addRoute(
'livechat/agents/:agentId/departments',
{ authRequired: true, permissionsRequired: ['view-l-room'] },
{ authRequired: true, permissionsRequired: ['view-l-room'], validateParams: isGETLivechatAgentsAgentIdDepartmentsParams },
{
async get() {
check(this.urlParams, {
agentId: String,
});
check(this.queryParams, {
enabledDepartmentsOnly: Match.Maybe(String),
});

const departments = await findAgentDepartments({
userId: this.userId,
enabledDepartmentsOnly: this.queryParams.enabledDepartmentsOnly && this.queryParams.enabledDepartmentsOnly === 'true',
agentId: this.urlParams.agentId,
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { isGETBusinessHourParams } from '@rocket.chat/rest-typings';

import { API } from '../../../../api/server';
import { findLivechatBusinessHour } from '../../../server/api/lib/businessHours';

API.v1.addRoute(
'livechat/business-hour',
{ authRequired: true, permissionsRequired: ['view-livechat-business-hours'] },
{ authRequired: true, permissionsRequired: ['view-livechat-business-hours'], validateParams: isGETBusinessHourParams },
{
async get() {
const { _id, type } = this.queryParams;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Match, check } from 'meteor/check';
import { isGETDashboardTotalizerParams, isGETDashboardsAgentStatusParams } from '@rocket.chat/rest-typings';

import { API } from '../../../../api/server';
import {
Expand All @@ -16,117 +16,109 @@ import { Users } from '../../../../models/server';

API.v1.addRoute(
'livechat/analytics/dashboards/conversation-totalizers',
{ authRequired: true, permissionsRequired: ['view-livechat-manager'] },
{
authRequired: true,
permissionsRequired: ['view-livechat-manager'],
validateParams: isGETDashboardTotalizerParams,
},
{
async get() {
let { start, end } = this.requestParams();
const { start, end } = this.requestParams();
const { departmentId } = this.requestParams();

check(start, String);
check(end, String);
check(departmentId, Match.Maybe(String));

if (isNaN(Date.parse(start))) {
return API.v1.failure('The "start" query parameter must be a valid date.');
}
start = new Date(start);
const startDate = new Date(start);

if (isNaN(Date.parse(end))) {
return API.v1.failure('The "end" query parameter must be a valid date.');
}
end = new Date(end);
const endDate = new Date(end);

const user = Users.findOneById(this.userId, { fields: { utcOffset: 1, language: 1 } });

const totalizers = getConversationsMetrics({ start, end, departmentId, user });
// @ts-expect-error TODO: fix this
const totalizers = getConversationsMetrics({ start: startDate, end: endDate, departmentId, user });
return API.v1.success(totalizers);
},
},
);

API.v1.addRoute(
'livechat/analytics/dashboards/agents-productivity-totalizers',
{ authRequired: true, permissionsRequired: ['view-livechat-manager'] },
{ authRequired: true, permissionsRequired: ['view-livechat-manager'], validateParams: isGETDashboardTotalizerParams },
{
async get() {
let { start, end } = this.requestParams();
const { start, end } = this.requestParams();
const { departmentId } = this.requestParams();

check(start, String);
check(end, String);
check(departmentId, Match.Maybe(String));

if (isNaN(Date.parse(start))) {
return API.v1.failure('The "start" query parameter must be a valid date.');
}
start = new Date(start);
const startDate = new Date(start);

if (isNaN(Date.parse(end))) {
return API.v1.failure('The "end" query parameter must be a valid date.');
}
end = new Date(end);
const endDate = new Date(end);

const user = Users.findOneById(this.userId, { fields: { utcOffset: 1, language: 1 } });

const totalizers = getAgentsProductivityMetrics({ start, end, departmentId, user });
// @ts-expect-error TODO: fix this
const totalizers = getAgentsProductivityMetrics({ start: startDate, end: endDate, departmentId, user });
return API.v1.success(totalizers);
},
},
);

API.v1.addRoute(
'livechat/analytics/dashboards/chats-totalizers',
{ authRequired: true, permissionsRequired: ['view-livechat-manager'] },
{ authRequired: true, permissionsRequired: ['view-livechat-manager'], validateParams: isGETDashboardTotalizerParams },
{
async get() {
let { start, end } = this.requestParams();
const { start, end } = this.requestParams();
const { departmentId } = this.requestParams();

check(start, String);
check(end, String);
check(departmentId, Match.Maybe(String));

if (isNaN(Date.parse(start))) {
return API.v1.failure('The "start" query parameter must be a valid date.');
}
start = new Date(start);
const startDate = new Date(start);

if (isNaN(Date.parse(end))) {
return API.v1.failure('The "end" query parameter must be a valid date.');
}
end = new Date(end);
const endDate = new Date(end);

const totalizers = getChatsMetrics({ start, end, departmentId });
// @ts-expect-error TODO: fix this
const totalizers = getChatsMetrics({ start: startDate, end: endDate, departmentId });
return API.v1.success(totalizers);
},
},
);

API.v1.addRoute(
'livechat/analytics/dashboards/productivity-totalizers',
{ authRequired: true, permissionsRequired: ['view-livechat-manager'] },
{ authRequired: true, permissionsRequired: ['view-livechat-manager'], validateParams: isGETDashboardTotalizerParams },
{
async get() {
let { start, end } = this.requestParams();
const { start, end } = this.requestParams();
const { departmentId } = this.requestParams();

check(start, String);
check(end, String);
check(departmentId, Match.Maybe(String));

if (isNaN(Date.parse(start))) {
return API.v1.failure('The "start" query parameter must be a valid date.');
}
start = new Date(start);
const startDate = new Date(start);

if (isNaN(Date.parse(end))) {
return API.v1.failure('The "end" query parameter must be a valid date.');
}
end = new Date(end);
const endDate = new Date(end);

const user = Users.findOneById(this.userId, { fields: { utcOffset: 1, language: 1 } });

const totalizers = getProductivityMetrics({ start, end, departmentId, user });
// @ts-expect-error TODO: fix this
const totalizers = getProductivityMetrics({ start: startDate, end: endDate, departmentId, user });

return API.v1.success(totalizers);
},
Expand All @@ -135,26 +127,24 @@ API.v1.addRoute(

API.v1.addRoute(
'livechat/analytics/dashboards/charts/chats',
{ authRequired: true, permissionsRequired: ['view-livechat-manager'] },
{ authRequired: true, permissionsRequired: ['view-livechat-manager'], validateParams: isGETDashboardTotalizerParams },
{
async get() {
let { start, end } = this.requestParams();
const { start, end } = this.requestParams();
const { departmentId } = this.requestParams();

check(start, String);
check(end, String);
check(departmentId, Match.Maybe(String));

if (isNaN(Date.parse(start))) {
return API.v1.failure('The "start" query parameter must be a valid date.');
}
start = new Date(start);
const startDate = new Date(start);

if (isNaN(Date.parse(end))) {
return API.v1.failure('The "end" query parameter must be a valid date.');
}
end = new Date(end);
const result = findAllChatsStatus({ start, end, departmentId });
const endDate = new Date(end);

// @ts-expect-error TODO: fix this
const result = findAllChatsStatus({ start: startDate, end: endDate, departmentId });

return API.v1.success(result);
},
Expand All @@ -163,26 +153,25 @@ API.v1.addRoute(

API.v1.addRoute(
'livechat/analytics/dashboards/charts/chats-per-agent',
{ authRequired: true, permissionsRequired: ['view-livechat-manager'] },
{ authRequired: true, permissionsRequired: ['view-livechat-manager'], validateParams: isGETDashboardTotalizerParams },
{
async get() {
let { start, end } = this.requestParams();
const { start, end } = this.requestParams();
const { departmentId } = this.requestParams();

check(start, String);
check(end, String);
check(departmentId, Match.Maybe(String));

if (isNaN(Date.parse(start))) {
return API.v1.failure('The "start" query parameter must be a valid date.');
}
start = new Date(start);
const startDate = new Date(start);

if (isNaN(Date.parse(end))) {
return API.v1.failure('The "end" query parameter must be a valid date.');
}
end = new Date(end);
const result = findAllChatMetricsByAgent({ start, end, departmentId });
const endDate = new Date(end);
// @ts-expect-error TODO: fix this
const result = findAllChatMetricsByAgent({ start: startDate, end: endDate, departmentId }) as {
[k: string]: { open: number; closed: number; onhold: number };
};

return API.v1.success(result);
},
Expand All @@ -191,12 +180,12 @@ API.v1.addRoute(

API.v1.addRoute(
'livechat/analytics/dashboards/charts/agents-status',
{ authRequired: true, permissionsRequired: ['view-livechat-manager'] },
{ authRequired: true, permissionsRequired: ['view-livechat-manager'], validateParams: isGETDashboardsAgentStatusParams },
{
async get() {
const { departmentId } = this.requestParams();
check(departmentId, Match.Maybe(String));

// @ts-expect-error TODO: fix this
const result = findAllAgentsStatus({ departmentId });

return API.v1.success(result);
Expand All @@ -206,26 +195,26 @@ API.v1.addRoute(

API.v1.addRoute(
'livechat/analytics/dashboards/charts/chats-per-department',
{ authRequired: true, permissionsRequired: ['view-livechat-manager'] },
{ authRequired: true, permissionsRequired: ['view-livechat-manager'], validateParams: isGETDashboardTotalizerParams },
{
async get() {
let { start, end } = this.requestParams();
const { start, end } = this.requestParams();
const { departmentId } = this.requestParams();

check(start, String);
check(end, String);
check(departmentId, Match.Maybe(String));

if (isNaN(Date.parse(start))) {
return API.v1.failure('The "start" query parameter must be a valid date.');
}
start = new Date(start);
const startDate = new Date(start);

if (isNaN(Date.parse(end))) {
return API.v1.failure('The "end" query parameter must be a valid date.');
}
end = new Date(end);
const result = findAllChatMetricsByDepartment({ start, end, departmentId });
const endDate = new Date(end);

// @ts-expect-error TODO: fix this
const result = findAllChatMetricsByDepartment({ start: startDate, end: endDate, departmentId }) as {
[k: string]: { open: number; closed: number };
};

return API.v1.success(result);
},
Expand All @@ -234,26 +223,24 @@ API.v1.addRoute(

API.v1.addRoute(
'livechat/analytics/dashboards/charts/timings',
{ authRequired: true, permissionsRequired: ['view-livechat-manager'] },
{ authRequired: true, permissionsRequired: ['view-livechat-manager'], validateParams: isGETDashboardTotalizerParams },
{
async get() {
let { start, end } = this.requestParams();
const { start, end } = this.requestParams();
const { departmentId } = this.requestParams();

check(start, String);
check(end, String);
check(departmentId, Match.Maybe(String));

if (isNaN(Date.parse(start))) {
return API.v1.failure('The "start" query parameter must be a valid date.');
}
start = new Date(start);
const startDate = new Date(start);

if (isNaN(Date.parse(end))) {
return API.v1.failure('The "end" query parameter must be a valid date.');
}
end = new Date(end);
const result = findAllResponseTimeMetrics({ start, end, departmentId });
const endDate = new Date(end);

// @ts-expect-error TODO: fix this
const result = findAllResponseTimeMetrics({ start: startDate, end: endDate, departmentId });

return API.v1.success(result);
},
Expand Down
Loading