workspace.ts 625 B

123456789101112131415161718
  1. export * as WorkspaceV2 from "./workspace"
  2. import { Schema } from "effect"
  3. import { withStatics } from "./schema"
  4. import { Identifier } from "./util/identifier"
  5. export const ID = Schema.String.check(Schema.isStartsWith("wrk")).pipe(
  6. Schema.brand("WorkspaceV2.ID"),
  7. withStatics((schema) => ({
  8. ascending: (id?: string) => {
  9. if (!id) return schema.make("wrk_" + Identifier.ascending())
  10. if (!id.startsWith("wrk")) throw new Error(`ID ${id} does not start with wrk`)
  11. return schema.make(id)
  12. },
  13. create: () => schema.make("wrk_" + Identifier.ascending()),
  14. })),
  15. )
  16. export type ID = typeof ID.Type