Skip to content

Commit

Permalink
fix CI
Browse files Browse the repository at this point in the history
  • Loading branch information
ggazzo committed Jun 9, 2022
1 parent 13bba40 commit c8b57c1
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 61 deletions.
8 changes: 3 additions & 5 deletions apps/meteor/client/lib/meteorCallWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,13 @@ function wrapMeteorDDPCalls(): void {
});
Meteor.connection.onMessage(_message);
};
const method = encodeURIComponent(message.method.replace(/\//g, ':'));

APIClient.post(
`/v1/${endpoint}/${encodeURIComponent(message.method.replace(/\//g, ':'))}` as Parameters<typeof APIClient.post>[0],
restParams as any,
)
APIClient.post(`/v1/${endpoint}/${method}`, restParams)
.then(({ message: _message }) => {
processResult(_message);
if (message.method === 'login') {
const parsedMessage = DDPCommon.parseDDP(_message) as { result?: { token?: string } };
const parsedMessage = DDPCommon.parseDDP(_message as any) as { result?: { token?: string } };
if (parsedMessage.result?.token) {
Meteor.loginWithToken(parsedMessage.result.token);
}
Expand Down
8 changes: 4 additions & 4 deletions apps/meteor/client/providers/ServerProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,20 @@ const callEndpoint = <TMethod extends Method, TPath extends PathFor<TMethod>>(
): Promise<Serialized<OperationResult<TMethod, MatchPathPattern<TPath>>>> => {
switch (method) {
case 'GET':
return APIClient.get(path as Parameters<typeof APIClient.get>[0], params) as any;
return APIClient.get(path as Parameters<typeof APIClient.get>[0], params as any | undefined) as any;

case 'POST':
return APIClient.post(path as Parameters<typeof APIClient.post>[0], params) as ReturnType<typeof APIClient.post>;
return APIClient.post(path as Parameters<typeof APIClient.post>[0], params as never) as ReturnType<typeof APIClient.post>;

case 'DELETE':
return APIClient.delete(path as Parameters<typeof APIClient.delete>[0], params) as ReturnType<typeof APIClient.delete>;
return APIClient.delete(path as Parameters<typeof APIClient.delete>[0], params as never) as ReturnType<typeof APIClient.delete>;

default:
throw new Error('Invalid HTTP method');
}
};

const uploadToEndpoint = (endpoint: PathFor<'POST'>, formData: any): Promise<UploadResult> => APIClient.post(endpoint, formData);
const uploadToEndpoint = (endpoint: PathFor<'POST'>, formData: any): Promise<UploadResult> => APIClient.post(endpoint, formData as never);

const getStream = (streamName: string, options: {} = {}): (<T>(eventName: string, callback: (data: T) => void) => () => void) => {
const streamer = Meteor.StreamerCentral.instances[streamName]
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/client/views/admin/apps/AppDetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useMutableCallback } from '@rocket.chat/fuselage-hooks';
import { useTranslation, useCurrentRoute, useRoute, useRouteParameter } from '@rocket.chat/ui-contexts';
import React, { useState, useCallback, useRef, FC } from 'react';

import { ISettings, ISettingsPayload } from '../../../../app/apps/client/@types/IOrchestrator';
import { ISettings } from '../../../../app/apps/client/@types/IOrchestrator';
import { Apps } from '../../../../app/apps/client/orchestrator';
import Page from '../../../components/Page';
import APIsDisplay from './APIsDisplay';
Expand Down Expand Up @@ -49,7 +49,7 @@ const AppDetailsPage: FC<{ id: string }> = function AppDetailsPage({ id }) {
(Object.values(settings || {}) as ISetting[]).map((value) => ({
...value,
value: current?.[value.id],
})) as unknown as ISettingsPayload,
})),
);
} catch (e) {
handleAPIError(e);
Expand Down
3 changes: 1 addition & 2 deletions apps/meteor/client/views/admin/apps/hooks/useCategories.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { useTranslation } from '@rocket.chat/ui-contexts';
import { useCallback, useEffect, useMemo, useState } from 'react';

import { ICategory } from '../../../../../app/apps/client/@types/IOrchestrator';
import { Apps } from '../../../../../app/apps/client/orchestrator';
import { CategoryDropdownItem, CategoryDropDownListProps } from '../definitions/CategoryDropdownDefinitions';
import { handleAPIError } from '../helpers';
Expand All @@ -21,7 +20,7 @@ export const useCategories = (): [
try {
const fetchedCategories = await Apps.getCategories();

const mappedCategories = fetchedCategories.map((currentCategory: ICategory) => ({
const mappedCategories = fetchedCategories.map((currentCategory) => ({
id: currentCategory.id,
label: currentCategory.title,
checked: false,
Expand Down
61 changes: 33 additions & 28 deletions packages/rest-typings/src/v1/me.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,40 @@
import type { IUser, Serialized } from '@rocket.chat/core-typings';

type RawUserData = Serialized<
Pick<
IUser,
| '_id'
| 'type'
| 'name'
| 'username'
| 'emails'
| 'status'
| 'statusDefault'
| 'statusText'
| 'statusConnection'
| 'avatarOrigin'
| 'utcOffset'
| 'language'
| 'settings'
| 'roles'
| 'active'
| 'defaultRoom'
| 'customFields'
| 'statusLivechat'
| 'oauth'
| 'createdAt'
| '_updatedAt'
| 'avatarETag'
>
>;
type Keys =
| '_id'
| 'type'
| 'name'
| 'username'
| 'emails'
| 'status'
| 'statusDefault'
| 'statusText'
| 'statusConnection'
| 'avatarOrigin'
| 'utcOffset'
| 'language'
| 'settings'
| 'roles'
| 'active'
| 'defaultRoom'
| 'customFields'
| 'statusLivechat'
| 'oauth'
| 'createdAt'
| '_updatedAt'
| 'avatarETag';

type RawUserData = Serialized<Pick<IUser, Keys>>;

export type MeEndpoints = {
'/v1/me': {
GET: () => RawUserData;
GET: (params: { fields: Record<Keys, 0> | Record<Keys, 1>; user: IUser }) => RawUserData & {
email?: string;
settings: {
profile: {};
preferences: unknown;
};
avatarUrl: string;
};
};
};
30 changes: 10 additions & 20 deletions packages/rest-typings/src/v1/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ const MethodCallAnonSchema = {
export const isMethodCallAnonProps = ajv.compile<MethodCallAnon>(MethodCallAnonSchema);

export type MiscEndpoints = {
'/v1/stdout.queue': {
'v1/stdout.queue': {
GET: () => {
queue: {
id: string;
Expand All @@ -180,45 +180,35 @@ export type MiscEndpoints = {
}[];
};
};
'me': {
GET: (params: { fields: { [k: string]: number }; user: IUser }) => IUser & {
email?: string;
settings: {
profile: {};
preferences: unknown;
};
avatarUrl: string;
};
};

'shield.svg': {
'/v1/shield.svg': {
GET: (params: ShieldSvg) => {
svg: string;
};
};

'spotlight': {
'/v1/spotlight': {
GET: (params: Spotlight) => {
users: Pick<IUser, 'username' | 'name' | 'status' | 'statusText' | 'avatarETag'>[];
rooms: IRoom[];
};
};

'directory': {
'/v1/directory': {
GET: (params: Directory) => PaginatedResult<{
result: (IUser | IRoom | ITeam)[];
}>;
};

'method.call': {
POST: (params: MethodCall) => {
result: unknown;
'/v1/method.call/:method': {
POST: (params: { message: string }) => {
message: unknown;
};
};

'method.callAnon': {
POST: (params: MethodCallAnon) => {
result: unknown;
'/v1/method.callAnon/:method': {
POST: (params: { message: string }) => {
message: unknown;
};
};
};

0 comments on commit c8b57c1

Please sign in to comment.