mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-12 17:43:30 +01:00
build: bump dependencies (#10457)
* build: bump `@vladfrangu/async_event_emitter` * chore: bump again + fixes * build: bump types/node and some dev deps * build: bump discord-api-types again * style: remove unused eslint-ignore comment * build: sync dependencies and update templates * build: bump turbo * build: vercel + vitest * build: bump undici --------- Co-authored-by: Vlad Frangu <me@vladfrangu.dev>
This commit is contained in:
@@ -30,17 +30,17 @@ export const DefaultBrokerOptions = {
|
||||
} as const satisfies Required<BaseBrokerOptions>;
|
||||
|
||||
export type ToEventMap<
|
||||
TRecord extends Record<string, any>,
|
||||
TRecord extends Record<string, any[]>,
|
||||
TResponses extends Record<keyof TRecord, any> | undefined = undefined,
|
||||
> = {
|
||||
[TKey in keyof TRecord]: [
|
||||
event: TResponses extends Record<keyof TRecord, any>
|
||||
? { ack(): Promise<void>; reply(data: TResponses[TKey]): Promise<void> }
|
||||
: { ack(): Promise<void> } & { data: TRecord[TKey] },
|
||||
: { ack(): Promise<void>; data: TRecord[TKey] },
|
||||
];
|
||||
} & { [K: string]: any };
|
||||
};
|
||||
|
||||
export interface IBaseBroker<TEvents extends Record<string, any>> {
|
||||
export interface IBaseBroker<TEvents extends {}> {
|
||||
/**
|
||||
* Subscribes to the given events
|
||||
*/
|
||||
@@ -51,7 +51,7 @@ export interface IBaseBroker<TEvents extends Record<string, any>> {
|
||||
unsubscribe(events: (keyof TEvents)[]): Promise<void>;
|
||||
}
|
||||
|
||||
export interface IPubSubBroker<TEvents extends Record<string, any>>
|
||||
export interface IPubSubBroker<TEvents extends {}>
|
||||
extends IBaseBroker<TEvents>,
|
||||
AsyncEventEmitter<ToEventMap<TEvents>> {
|
||||
/**
|
||||
@@ -60,7 +60,7 @@ export interface IPubSubBroker<TEvents extends Record<string, any>>
|
||||
publish<Event extends keyof TEvents>(event: Event, data: TEvents[Event]): Promise<void>;
|
||||
}
|
||||
|
||||
export interface IRPCBroker<TEvents extends Record<string, any>, TResponses extends Record<keyof TEvents, any>>
|
||||
export interface IRPCBroker<TEvents extends Record<string, any[]>, TResponses extends Record<keyof TEvents, any>>
|
||||
extends IBaseBroker<TEvents>,
|
||||
AsyncEventEmitter<ToEventMap<TEvents, TResponses>> {
|
||||
/**
|
||||
|
||||
@@ -57,8 +57,11 @@ export const DefaultRedisBrokerOptions = {
|
||||
/**
|
||||
* Helper class with shared Redis logic
|
||||
*/
|
||||
export abstract class BaseRedisBroker<TEvents extends Record<string, any>>
|
||||
extends AsyncEventEmitter<ToEventMap<TEvents>>
|
||||
export abstract class BaseRedisBroker<
|
||||
TEvents extends Record<string, any[]>,
|
||||
TResponses extends Record<keyof TEvents, any> | undefined = undefined,
|
||||
>
|
||||
extends AsyncEventEmitter<ToEventMap<TEvents, TResponses>>
|
||||
implements IBaseBroker<TEvents>
|
||||
{
|
||||
/**
|
||||
@@ -182,6 +185,7 @@ export abstract class BaseRedisBroker<TEvents extends Record<string, any>>
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
// @ts-expect-error: Intended
|
||||
this.emit('error', error);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ export class PubSubRedisBroker<TEvents extends Record<string, any>>
|
||||
},
|
||||
};
|
||||
|
||||
// @ts-expect-error: Intended
|
||||
this.emit(event, payload);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,8 +54,8 @@ export const DefaultRPCRedisBrokerOptions = {
|
||||
* await broker.subscribe('responders', ['testcall']);
|
||||
* ```
|
||||
*/
|
||||
export class RPCRedisBroker<TEvents extends Record<string, any>, TResponses extends Record<keyof TEvents, any>>
|
||||
extends BaseRedisBroker<TEvents>
|
||||
export class RPCRedisBroker<TEvents extends Record<string, any[]>, TResponses extends Record<keyof TEvents, any>>
|
||||
extends BaseRedisBroker<TEvents, TResponses>
|
||||
implements IRPCBroker<TEvents, TResponses>
|
||||
{
|
||||
/**
|
||||
@@ -125,6 +125,7 @@ export class RPCRedisBroker<TEvents extends Record<string, any>, TResponses exte
|
||||
},
|
||||
};
|
||||
|
||||
// @ts-expect-error: Intended
|
||||
this.emit(event, payload);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user