@@ -57,7 +57,7 @@ export const EventCodes = {
57
57
SUBSCRIPTION_ABORTED : "SUBSCRIPTION_ABORTED" ,
58
58
} as const ;
59
59
60
- export type EventCodes = typeof EventCodes [ keyof typeof EventCodes ] ;
60
+ export type EventCodes = ( typeof EventCodes ) [ keyof typeof EventCodes ] ;
61
61
62
62
export function RedisPubSub ( {
63
63
publisher,
@@ -270,7 +270,7 @@ export function RedisPubSub({
270
270
) ;
271
271
}
272
272
273
- function createChannel < Input , Output > ( {
273
+ function createChannel < PublishInput , ChannelData , SubscriberData > ( {
274
274
name,
275
275
isLazy = true ,
276
276
...schemas
@@ -282,12 +282,12 @@ export function RedisPubSub({
282
282
isLazy ?: boolean ;
283
283
} & (
284
284
| {
285
- inputSchema : ZodSchema < Input , ZodTypeDef , Input > ;
286
- outputSchema : ZodSchema < Output , ZodTypeDef , Input > ;
285
+ inputSchema : ZodSchema < ChannelData , ZodTypeDef , PublishInput > ;
286
+ outputSchema : ZodSchema < SubscriberData , ZodTypeDef , ChannelData > ;
287
287
schema ?: never ;
288
288
}
289
289
| {
290
- schema : ZodSchema < Output , ZodTypeDef , Input > ;
290
+ schema : ZodSchema < SubscriberData , ZodTypeDef , PublishInput > ;
291
291
inputSchema ?: never ;
292
292
outputSchema ?: never ;
293
293
}
@@ -315,8 +315,6 @@ export function RedisPubSub({
315
315
unsubscribe,
316
316
publish,
317
317
unsubscribeAll,
318
- inputSchema,
319
- outputSchema,
320
318
} ;
321
319
322
320
function getSubscriptionValue ( {
@@ -339,23 +337,23 @@ export function RedisPubSub({
339
337
} ) ;
340
338
}
341
339
342
- function subscribe < FilteredValue extends Output > ( subscribeArguments : {
340
+ function subscribe < FilteredValue extends SubscriberData > ( subscribeArguments : {
343
341
abortSignal ?: AbortSignal ;
344
- filter : ( value : Output ) => value is FilteredValue ;
342
+ filter : ( value : SubscriberData ) => value is FilteredValue ;
345
343
identifier ?: string | number ;
346
344
} ) : AsyncGenerator < FilteredValue , void , unknown > ;
347
345
function subscribe ( subscribeArguments ?: {
348
346
abortSignal ?: AbortSignal ;
349
- filter ?: ( value : Output ) => unknown ;
347
+ filter ?: ( value : SubscriberData ) => unknown ;
350
348
identifier ?: string | number ;
351
- } ) : AsyncGenerator < Output , void , unknown > ;
349
+ } ) : AsyncGenerator < SubscriberData , void , unknown > ;
352
350
async function * subscribe ( {
353
351
abortSignal,
354
352
filter,
355
353
identifier,
356
354
} : {
357
355
abortSignal ?: AbortSignal ;
358
- filter ?: ( value : Output ) => unknown ;
356
+ filter ?: ( value : SubscriberData ) => unknown ;
359
357
identifier ?: string | number ;
360
358
} = { } ) {
361
359
const channel = identifier ? name + identifier : name ;
@@ -428,7 +426,7 @@ export function RedisPubSub({
428
426
while ( true ) {
429
427
await dataPromise . current . promise ;
430
428
431
- for ( const value of dataPromise . current . values as Output [ ] ) {
429
+ for ( const value of dataPromise . current . values as SubscriberData [ ] ) {
432
430
if ( filter && ! filter ( value ) ) {
433
431
if ( enabledLogEvents ?. SUBSCRIPTION_MESSAGE_FILTERED_OUT ) {
434
432
logMessage ( "SUBSCRIPTION_MESSAGE_FILTERED_OUT" , {
@@ -498,15 +496,15 @@ export function RedisPubSub({
498
496
499
497
async function publish (
500
498
...values : [
501
- { value : Input ; identifier ?: string | number } ,
502
- ...{ value : Input ; identifier ?: string | number } [ ]
499
+ { value : PublishInput ; identifier ?: string | number } ,
500
+ ...{ value : PublishInput ; identifier ?: string | number } [ ] ,
503
501
]
504
502
) {
505
503
await Promise . all (
506
504
values . map ( async ( { value, identifier } ) => {
507
505
const tracing = enabledLogEvents ?. PUBLISH_MESSAGE_EXECUTION_TIME ? getTracing ( ) : null ;
508
506
509
- let parsedValue : Input | Output ;
507
+ let parsedValue : ChannelData | SubscriberData ;
510
508
511
509
try {
512
510
parsedValue = await inputSchema . parseAsync ( value ) ;
0 commit comments