import type { FunctionRuntime } from '../runner/sdk.js'; import type { DBTeam } from '../team/db.js'; import type { DBUser } from '../user/db.js'; type Serializable = string | number | boolean | Date | null | undefined | Serializable[] | { [key: string]: Serializable; }; interface EventBase { idempotencyKey: string; subject: TSubject; type: TType; payload: TPayload; source?: string | undefined; createdAt: Date; } type EnforceEventBase> = T; export type Event = EnforceEventBase; export type UserCreatedEvent = EventBase<'user', 'user.created', { userId: DBUser['id']; teamId: DBTeam['id']; }>; export type TeamUpdatedEvent = EventBase<'team', 'team.updated', { id: DBTeam['id']; }>; interface UsageEventBase extends EventBase<'usage', TType, TPayload> { subject: 'usage'; type: TType; payload: TPayload & { value: number; properties: { accountId: number; environmentId: number; environmentName: string; integrationId: string; connectionId: string; }; }; } export type UsageRecordsEvent = UsageEventBase<'usage.records', { value: number; properties: { syncId: string; model: string; }; }>; export type UsageMarEvent = UsageEventBase<'usage.monthly_active_records', { value: number; properties: { syncId: string; model: string; }; }>; export type UsageActionsEvent = UsageEventBase<'usage.actions', { value: number; properties: { actionName: string; }; }>; export type UsageConnectionsEvent = UsageEventBase<'usage.connections', { value: number; }>; export type UsageFunctionExecutionsEvent = UsageEventBase<'usage.function_executions', { value: number; properties: { type: 'sync' | 'action' | 'webhook' | 'on-event'; success: boolean; functionName: string; runtime: FunctionRuntime | undefined; telemetryBag: { durationMs: number; memoryGb: number; customLogs: number; proxyCalls: number; } | undefined; frequencyMs?: number | undefined; }; }>; export type UsageProxyEvent = UsageEventBase<'usage.proxy', { value: number; properties: { success: boolean; }; }>; export type UsageWebhookForwardEvent = UsageEventBase<'usage.webhook_forward', { value: number; properties: { success: boolean; }; }>; type EnforceUsageEventBase> = T; export type UsageEvent = EnforceUsageEventBase; export {};