fix: pr changes

This commit is contained in:
sidwebworks
2025-08-03 02:39:16 +05:30
parent 9fde0a5787
commit 806165b9e9
5 changed files with 35 additions and 34 deletions
@@ -66,19 +66,24 @@ export type EventStreamClient = {
};
export function createEventStreamClient(redis: Redis, options: IEventStreamClientOpts): EventStreamClient {
const rules = options.registered.map((r) => ({
subject: options.type,
action: "subscribe",
conditions: {
eventType: r.event,
...(r.conditions
? {
secretPath: r.conditions?.secretPath,
environment: r.conditions?.environmentSlug
}
: {})
}
}));
const rules = options.registered.map((r) => {
const secretPath = r.conditions?.secretPath;
const hasConditions = r.conditions?.environmentSlug || r.conditions?.secretPath;
return {
subject: options.type,
action: "subscribe",
conditions: {
eventType: r.event,
...(hasConditions
? {
environment: r.conditions?.environmentSlug ?? "",
secretPath: r.conditions?.recursive ? { $glob: `${secretPath}/**` } : secretPath
}
: {})
}
};
});
const id = `sse-${nanoid()}`;
const control = new AbortController();
+2 -1
View File
@@ -117,7 +117,8 @@ export const EventRegisterSchema = z.object({
conditions: z
.object({
secretPath: z.string().optional().default("/"),
environmentSlug: z.string()
environmentSlug: z.string(),
recursive: z.boolean().optional().default(false)
})
.optional()
});