location.ts 743 B

12345678910111213141516171819202122232425
  1. export * as Location from "./location"
  2. import { Schema } from "effect"
  3. import { AbsolutePath, optional } from "./schema"
  4. import { ProjectID } from "./project-id"
  5. import { WorkspaceID } from "./workspace-id"
  6. export interface Ref extends Schema.Schema.Type<typeof Ref> {}
  7. export const Ref = Schema.Struct({
  8. directory: AbsolutePath,
  9. workspaceID: optional(WorkspaceID),
  10. }).annotate({ identifier: "Location.Ref" })
  11. export class Info extends Schema.Class<Info>("Location.Info")({
  12. directory: AbsolutePath,
  13. workspaceID: optional(WorkspaceID),
  14. project: Schema.Struct({
  15. id: ProjectID,
  16. directory: AbsolutePath,
  17. }),
  18. }) {}
  19. export function response<S extends Schema.Top>(data: S) {
  20. return Schema.Struct({ location: Info, data })
  21. }