mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-04-26 08:56:22 +02:00
feat: add syncing update for graph building on the UI
This commit is contained in:
parent
6425dbcf28
commit
eefc6a9700
13 changed files with 1093 additions and 163 deletions
65
apps/x/packages/shared/src/service-events.ts
Normal file
65
apps/x/packages/shared/src/service-events.ts
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
import z from 'zod';
|
||||
|
||||
export const ServiceName = z.enum([
|
||||
'graph',
|
||||
'gmail',
|
||||
'calendar',
|
||||
'fireflies',
|
||||
'granola',
|
||||
'voice_memo',
|
||||
]);
|
||||
|
||||
const ServiceEventBase = z.object({
|
||||
service: ServiceName,
|
||||
runId: z.string(),
|
||||
ts: z.iso.datetime(),
|
||||
level: z.enum(['info', 'warn', 'error']),
|
||||
message: z.string(),
|
||||
});
|
||||
|
||||
export const ServiceRunStartEvent = ServiceEventBase.extend({
|
||||
type: z.literal('run_start'),
|
||||
trigger: z.enum(['timer', 'manual', 'startup']).optional(),
|
||||
config: z.record(z.string(), z.unknown()).optional(),
|
||||
});
|
||||
|
||||
export const ServiceChangesIdentifiedEvent = ServiceEventBase.extend({
|
||||
type: z.literal('changes_identified'),
|
||||
counts: z.record(z.string(), z.number()).optional(),
|
||||
items: z.array(z.string()).optional(),
|
||||
truncated: z.boolean().optional(),
|
||||
});
|
||||
|
||||
export const ServiceProgressEvent = ServiceEventBase.extend({
|
||||
type: z.literal('progress'),
|
||||
step: z.string().optional(),
|
||||
current: z.number().optional(),
|
||||
total: z.number().optional(),
|
||||
details: z.record(z.string(), z.unknown()).optional(),
|
||||
});
|
||||
|
||||
export const ServiceRunCompleteEvent = ServiceEventBase.extend({
|
||||
type: z.literal('run_complete'),
|
||||
durationMs: z.number(),
|
||||
outcome: z.enum(['ok', 'idle', 'skipped', 'error']),
|
||||
summary: z.record(z.string(), z.union([z.string(), z.number(), z.boolean()])).optional(),
|
||||
items: z.array(z.string()).optional(),
|
||||
truncated: z.boolean().optional(),
|
||||
});
|
||||
|
||||
export const ServiceErrorEvent = ServiceEventBase.extend({
|
||||
type: z.literal('error'),
|
||||
error: z.string(),
|
||||
context: z.record(z.string(), z.unknown()).optional(),
|
||||
});
|
||||
|
||||
export const ServiceEvent = z.union([
|
||||
ServiceRunStartEvent,
|
||||
ServiceChangesIdentifiedEvent,
|
||||
ServiceProgressEvent,
|
||||
ServiceRunCompleteEvent,
|
||||
ServiceErrorEvent,
|
||||
]);
|
||||
|
||||
export type ServiceNameType = z.infer<typeof ServiceName>;
|
||||
export type ServiceEventType = z.infer<typeof ServiceEvent>;
|
||||
Loading…
Add table
Add a link
Reference in a new issue