session-status-event.ts 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. export * as SessionStatusEvent from "./session-status-event"
  2. import { Schema } from "effect"
  3. import { optional } from "./schema"
  4. import { Event } from "./event"
  5. import { NonNegativeInt } from "./schema"
  6. import { SessionID } from "./session-id"
  7. export const Info = Schema.Union([
  8. Schema.Struct({
  9. type: Schema.Literal("idle"),
  10. }),
  11. Schema.Struct({
  12. type: Schema.Literal("retry"),
  13. attempt: NonNegativeInt,
  14. message: Schema.String,
  15. action: optional(
  16. Schema.Struct({
  17. reason: Schema.String,
  18. provider: Schema.String,
  19. title: Schema.String,
  20. message: Schema.String,
  21. label: Schema.String,
  22. link: optional(Schema.String),
  23. }),
  24. ),
  25. next: NonNegativeInt,
  26. }),
  27. Schema.Struct({
  28. type: Schema.Literal("busy"),
  29. }),
  30. ]).annotate({ identifier: "SessionStatus" })
  31. export type Info = Schema.Schema.Type<typeof Info>
  32. export const Status = Event.define({
  33. type: "session.status",
  34. schema: {
  35. sessionID: SessionID,
  36. status: Info,
  37. },
  38. })
  39. // deprecated
  40. export const Idle = Event.define({
  41. type: "session.idle",
  42. schema: {
  43. sessionID: SessionID,
  44. },
  45. })
  46. export const Definitions = Event.inventory(Status, Idle)