-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: remove proxifyWithWait and waitAndCall
- Loading branch information
1 parent
fd5e54f
commit 5ccebc9
Showing
12 changed files
with
52 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import { proxifyWithWait } from '@rocket.chat/core-services'; | ||
import { proxify } from '@rocket.chat/core-services'; | ||
|
||
import type { IInstanceService } from './types/IInstanceService'; | ||
import type { ILDAPEEService } from './types/ILDAPEEService'; | ||
|
||
export const LDAPEE = proxifyWithWait<ILDAPEEService>('ldap-enterprise'); | ||
export const Instance = proxifyWithWait<IInstanceService>('instance'); | ||
export const LDAPEE = proxify<ILDAPEEService>('ldap-enterprise'); | ||
export const Instance = proxify<IInstanceService>('instance'); |
4 changes: 2 additions & 2 deletions
4
apps/meteor/server/services/authorization/canAccessRoomLivechat.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
apps/meteor/server/services/authorization/canAccessRoomVoip.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,22 @@ | ||
import { api } from '../api'; | ||
|
||
type Prom<T> = { | ||
[K in keyof T as T[K] extends (...params: any) => any ? K : never]: T[K] extends (...params: any) => Promise<any> | ||
type Promisify<T> = { | ||
[K in keyof T as T[K] extends (...params: any[]) => unknown ? K : never]: T[K] extends (...params: any[]) => Promise<any> | ||
? T[K] | ||
: T[K] extends (...params: infer P) => infer R | ||
? (...params: P) => Promise<R> | ||
: never; | ||
}; | ||
|
||
type PromOrError<T> = { | ||
[K in keyof T as T[K] extends (...params: any) => any ? K : never]: T[K] extends (...params: any) => Promise<any> | ||
? T[K] | ||
: T[K] extends (...params: infer P) => infer R | ||
? (...params: P) => Promise<R | Error> | ||
: never; | ||
}; | ||
|
||
function handler<T extends object>(namespace: string, waitService: boolean): ProxyHandler<T> { | ||
function handler<T extends object>(namespace: string): ProxyHandler<T> { | ||
return { | ||
get: | ||
(_target: T, prop: string): any => | ||
(...params: any): Promise<any> => | ||
api[waitService ? 'waitAndCall' : 'call'](`${namespace}.${prop}`, params), | ||
api.call(`${namespace}.${prop}`, params), | ||
}; | ||
} | ||
|
||
// TODO remove the need to wait for a service, if that is really needed it should have a dependency on startup | ||
export function proxifyWithWait<T>(namespace: string): Prom<T> { | ||
return new Proxy({}, handler(namespace, true)) as unknown as Prom<T>; | ||
} | ||
|
||
export function proxify<T>(namespace: string): PromOrError<T> { | ||
return new Proxy({}, handler(namespace, false)) as unknown as PromOrError<T>; | ||
export function proxify<T>(namespace: string): Promisify<T> { | ||
return new Proxy({}, handler(namespace)) as unknown as Promisify<T>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters