chore:little fixes and formating and linting and patches

This commit is contained in:
2026-03-31 15:50:54 +02:00
parent a1ce71ffb6
commit 9b197abcfa
815 changed files with 22960 additions and 8982 deletions

View File

@@ -1,7 +1,6 @@
import { type Redis, getRedisPub, getRedisSub } from './redis';
import type { IServiceEvent, Notification, Prisma } from '@openpanel/db';
import type { Prisma } from '@openpanel/db';
import { getSuperJson, setSuperJson } from '@openpanel/json';
import { getRedisPub, getRedisSub, type Redis } from './redis';
export type IPublishChannels = {
organization: {
@@ -19,7 +18,7 @@ export type IPublishChannels = {
export function getSubscribeChannel<Channel extends keyof IPublishChannels>(
channel: Channel,
type: keyof IPublishChannels[Channel],
type: keyof IPublishChannels[Channel]
) {
return `${channel}:${String(type)}`;
}
@@ -28,7 +27,7 @@ export function publishEvent<Channel extends keyof IPublishChannels>(
channel: Channel,
type: keyof IPublishChannels[Channel],
event: IPublishChannels[Channel][typeof type],
multi?: ReturnType<Redis['multi']>,
multi?: ReturnType<Redis['multi']>
) {
const redis = multi ?? getRedisPub();
return redis.publish(getSubscribeChannel(channel, type), setSuperJson(event));
@@ -37,7 +36,7 @@ export function publishEvent<Channel extends keyof IPublishChannels>(
export function parsePublishedEvent<Channel extends keyof IPublishChannels>(
_channel: Channel,
_type: keyof IPublishChannels[Channel],
message: string,
message: string
): IPublishChannels[Channel][typeof _type] {
return getSuperJson<IPublishChannels[Channel][typeof _type]>(message)!;
}
@@ -47,7 +46,7 @@ export function subscribeToPublishedEvent<
>(
channel: Channel,
type: keyof IPublishChannels[Channel],
callback: (event: IPublishChannels[Channel][typeof type]) => void,
callback: (event: IPublishChannels[Channel][typeof type]) => void
) {
const subscribeChannel = getSubscribeChannel(channel, type);
getRedisSub().subscribe(subscribeChannel);
@@ -71,7 +70,7 @@ export function subscribeToPublishedEvent<
export function psubscribeToPublishedEvent(
pattern: string,
callback: (key: string) => void,
callback: (key: string) => void
) {
getRedisSub().psubscribe(pattern);
const pmessage = (_: unknown, pattern: string, key: string) => callback(key);