fix(sdk): preserve generated event contracts
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { Config } from "@/config/config"
|
||||
import { EventV2 } from "@opencode-ai/core/event"
|
||||
import "@/server/event"
|
||||
import { InstanceDisposed } from "@/server/event"
|
||||
import { Schema } from "effect"
|
||||
import { HttpApi, HttpApiEndpoint, HttpApiError, HttpApiGroup, HttpApiSchema, OpenApi } from "effect/unstable/httpapi"
|
||||
import { described } from "./metadata"
|
||||
@@ -10,18 +10,37 @@ const GlobalHealth = Schema.Struct({
|
||||
version: Schema.String,
|
||||
})
|
||||
|
||||
const SyncEventSchemas = EventV2.registry
|
||||
.values()
|
||||
.flatMap((definition) => {
|
||||
if (!definition.sync) return []
|
||||
return [
|
||||
Schema.Struct({
|
||||
type: Schema.Literal("sync"),
|
||||
name: Schema.Literal(EventV2.versionedType(definition.type, definition.sync.version)),
|
||||
id: Schema.String,
|
||||
seq: Schema.Finite,
|
||||
aggregateID: Schema.Literal(definition.sync.aggregate),
|
||||
data: definition.data,
|
||||
}).annotate({ identifier: `SyncEvent.${definition.type}` }),
|
||||
]
|
||||
})
|
||||
.toArray()
|
||||
|
||||
const GlobalEventSchema = Schema.Struct({
|
||||
directory: Schema.String,
|
||||
project: Schema.optional(Schema.String),
|
||||
workspace: Schema.optional(Schema.String),
|
||||
payload: Schema.Union(
|
||||
EventV2.registry
|
||||
payload: Schema.Union([
|
||||
...EventV2.registry
|
||||
.values()
|
||||
.map((definition) =>
|
||||
Schema.Struct({ id: Schema.String, type: Schema.Literal(definition.type), properties: definition.data }),
|
||||
)
|
||||
.toArray(),
|
||||
),
|
||||
InstanceDisposed,
|
||||
...SyncEventSchemas,
|
||||
]),
|
||||
}).annotate({ identifier: "GlobalEvent" })
|
||||
|
||||
export const GlobalUpgradeInput = Schema.Struct({
|
||||
|
||||
Reference in New Issue
Block a user