refactor: unwrap BusEvent namespace + self-reexport (#22962)
This commit is contained in:
@@ -1,21 +1,20 @@
|
||||
import z from "zod"
|
||||
import type { ZodType } from "zod"
|
||||
|
||||
export namespace BusEvent {
|
||||
export type Definition = ReturnType<typeof define>
|
||||
export type Definition = ReturnType<typeof define>
|
||||
|
||||
const registry = new Map<string, Definition>()
|
||||
const registry = new Map<string, Definition>()
|
||||
|
||||
export function define<Type extends string, Properties extends ZodType>(type: Type, properties: Properties) {
|
||||
export function define<Type extends string, Properties extends ZodType>(type: Type, properties: Properties) {
|
||||
const result = {
|
||||
type,
|
||||
properties,
|
||||
}
|
||||
registry.set(type, result)
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
export function payloads() {
|
||||
export function payloads() {
|
||||
return registry
|
||||
.entries()
|
||||
.map(([type, def]) => {
|
||||
@@ -29,5 +28,6 @@ export namespace BusEvent {
|
||||
})
|
||||
})
|
||||
.toArray()
|
||||
}
|
||||
}
|
||||
|
||||
export * as BusEvent from "./bus-event"
|
||||
|
||||
Reference in New Issue
Block a user