project.ts 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. export * as Project from "./project.js"
  2. import { Schema } from "effect"
  3. import { ephemeral, inventory } from "./event.js"
  4. import { AbsolutePath, NonNegativeInt, optional } from "./schema.js"
  5. import { ProjectID } from "./project-id.js"
  6. export const ID = ProjectID
  7. export type ID = typeof ID.Type
  8. export const Vcs = Schema.Literals(["git", "hg"]).annotate({ identifier: "Project.Vcs" })
  9. export const Current = Schema.Struct({
  10. id: ID,
  11. directory: AbsolutePath,
  12. canonical: AbsolutePath,
  13. }).annotate({ identifier: "Project.Current" })
  14. export interface Current extends Schema.Schema.Type<typeof Current> {}
  15. export const Directory = Schema.Struct({
  16. directory: AbsolutePath,
  17. strategy: optional(Schema.String),
  18. }).annotate({ identifier: "Project.Directory" })
  19. export interface Directory extends Schema.Schema.Type<typeof Directory> {}
  20. export const DirectoriesInput = Schema.Struct({
  21. projectID: ID,
  22. }).annotate({ identifier: "Project.DirectoriesInput" })
  23. export interface DirectoriesInput extends Schema.Schema.Type<typeof DirectoriesInput> {}
  24. export const Directories = Schema.Array(Directory).annotate({ identifier: "Project.Directories" })
  25. export type Directories = typeof Directories.Type
  26. export const Icon = Schema.Struct({
  27. url: optional(Schema.String),
  28. override: optional(Schema.String),
  29. color: optional(Schema.String),
  30. }).annotate({ identifier: "Project.Icon" })
  31. export interface Icon extends Schema.Schema.Type<typeof Icon> {}
  32. export const Commands = Schema.Struct({
  33. start: optional(
  34. Schema.String.annotate({ description: "Startup script to run when creating a new workspace (worktree)" }),
  35. ),
  36. }).annotate({ identifier: "Project.Commands" })
  37. export interface Commands extends Schema.Schema.Type<typeof Commands> {}
  38. export const Time = Schema.Struct({
  39. created: NonNegativeInt,
  40. updated: NonNegativeInt,
  41. initialized: optional(NonNegativeInt),
  42. }).annotate({ identifier: "Project.Time" })
  43. export interface Time extends Schema.Schema.Type<typeof Time> {}
  44. export const Info = Schema.Struct({
  45. id: ID,
  46. canonical: AbsolutePath,
  47. vcs: optional(Vcs),
  48. name: optional(Schema.String),
  49. icon: optional(Icon),
  50. commands: optional(Commands),
  51. time: Time,
  52. sandboxes: Schema.Array(Schema.String),
  53. }).annotate({ identifier: "Project" })
  54. export interface Info extends Schema.Schema.Type<typeof Info> {}
  55. const Updated = ephemeral({ type: "project.updated", schema: Info.fields })
  56. export const Event = { Updated, Definitions: inventory(Updated) }