project.ts 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. export * as Project from "./project"
  2. import { Schema } from "effect"
  3. import { define, inventory } from "./event"
  4. import { NonNegativeInt, optional } from "./schema"
  5. import { ProjectID } from "./project-id"
  6. export const ID = ProjectID
  7. export type ID = typeof ID.Type
  8. export const Vcs = Schema.Literal("git").annotate({ identifier: "Project.Vcs" })
  9. export const Icon = Schema.Struct({
  10. url: optional(Schema.String),
  11. override: optional(Schema.String),
  12. color: optional(Schema.String),
  13. }).annotate({ identifier: "Project.Icon" })
  14. export interface Icon extends Schema.Schema.Type<typeof Icon> {}
  15. export const Commands = Schema.Struct({
  16. start: optional(
  17. Schema.String.annotate({ description: "Startup script to run when creating a new workspace (worktree)" }),
  18. ),
  19. }).annotate({ identifier: "Project.Commands" })
  20. export interface Commands extends Schema.Schema.Type<typeof Commands> {}
  21. export const Time = Schema.Struct({
  22. created: NonNegativeInt,
  23. updated: NonNegativeInt,
  24. initialized: optional(NonNegativeInt),
  25. }).annotate({ identifier: "Project.Time" })
  26. export interface Time extends Schema.Schema.Type<typeof Time> {}
  27. export const Info = Schema.Struct({
  28. id: ID,
  29. worktree: Schema.String,
  30. vcs: optional(Vcs),
  31. name: optional(Schema.String),
  32. icon: optional(Icon),
  33. commands: optional(Commands),
  34. time: Time,
  35. sandboxes: Schema.Array(Schema.String),
  36. }).annotate({ identifier: "Project" })
  37. export interface Info extends Schema.Schema.Type<typeof Info> {}
  38. const Updated = define({ type: "project.updated", schema: Info.fields })
  39. export const Event = { Updated, Definitions: inventory(Updated) }