fix missing event types in sdk

This commit is contained in:
Dax Raad
2026-05-14 21:53:36 -04:00
parent f179dcbf02
commit f39cf911d7
6 changed files with 219 additions and 151 deletions

View File

@@ -6,6 +6,7 @@ import { Database } from "@/storage/db"
import { eq } from "drizzle-orm"
export function initProjectors() {
console.log("initProjectors")
SyncEvent.init({
projectors: sessionProjectors,
convertEvent: (type, data) => {

View File

@@ -1,3 +1,6 @@
import { initProjectors } from "@/server/projectors"
initProjectors()
import { Schema } from "effect"
import { HttpApi } from "effect/unstable/httpapi"
import { BusEvent } from "@/bus/bus-event"

View File

@@ -1,7 +1,6 @@
import { Config } from "@/config/config"
import { BusEvent } from "@/bus/bus-event"
import { SyncEvent } from "@/sync"
import "@/event-v2-bridge"
import "@/server/event"
import { Schema } from "effect"
import { HttpApi, HttpApiEndpoint, HttpApiError, HttpApiGroup, OpenApi } from "effect/unstable/httpapi"

View File

@@ -5,7 +5,6 @@ import { HttpRouter, HttpServer } from "effect/unstable/http"
import { OpenApi } from "effect/unstable/httpapi"
import { createServer } from "node:http"
import { MDNS } from "./mdns"
import { initProjectors } from "./projectors"
import { HttpApiApp } from "./routes/instance/httpapi/server"
import { disposeMiddleware } from "./routes/instance/httpapi/lifecycle"
import { WebSocketTracker } from "./routes/instance/httpapi/websocket-tracker"
@@ -16,8 +15,6 @@ import { lazy } from "@/util/lazy"
// @ts-ignore This global is needed to prevent ai-sdk from logging warnings to stdout https://github.com/vercel/ai/blob/2dc67e0ef538307f21368db32d5a12345d98831b/packages/ai/src/logger/log-warnings.ts#L85
globalThis.AI_SDK_LOG_WARNINGS = false
initProjectors()
const log = Log.create({ service: "server" })
export type Listener = {

View File

@@ -226,9 +226,6 @@ export function reset() {
}
export function init(input: { projectors: Array<[Definition, ProjectorFunc]>; convertEvent?: ConvertEvent }) {
for (const [def] of input.projectors) {
register(def)
}
projectors = new Map(input.projectors)
// Install all the latest event defs to the bus. We only ever emit
@@ -236,8 +233,8 @@ export function init(input: { projectors: Array<[Definition, ProjectorFunc]>; co
// replaying. Replaying does not go through the bus, and it
// simplifies the bus to only use unversioned latest events
for (let [type, version] of versions.entries()) {
console.log(type)
let def = registry.get(versionedType(type, version))!
BusEvent.define(def.type, def.properties)
}
@@ -286,7 +283,6 @@ export function project<Def extends Definition>(
def: Def,
func: (db: Database.TxOrDb, data: Event<Def>["data"], event: Event<Def>) => void,
): [Definition, ProjectorFunc] {
register(def)
return [def, func as ProjectorFunc]
}
@@ -393,7 +389,7 @@ export function effectPayloads() {
name: EffectSchema.Literal(versionedType(definition.type, definition.version!)),
id: EffectSchema.String,
seq: EffectSchema.Finite,
aggregateID: EffectSchema.String,
aggregateID: EffectSchema.Literal(definition.aggregate!),
data: definition.data,
}).annotate({ identifier: `SyncEvent.${definition.type}` }),
)