session-id.ts 503 B

1234567891011121314151617
  1. export * as SessionID from "./session-id"
  2. import { Schema } from "effect"
  3. import { descending } from "./identifier"
  4. import { withStatics } from "./schema"
  5. export const ID = Schema.String.check(Schema.isStartsWith("ses")).pipe(
  6. Schema.brand("SessionID"),
  7. withStatics((schema) => {
  8. const create = () => schema.make("ses_" + descending())
  9. return {
  10. create,
  11. descending: (id?: string) => (id === undefined ? create() : schema.make(id)),
  12. }
  13. }),
  14. )
  15. export type ID = typeof ID.Type