|
1 | 1 | import { Schema } from "effect" |
2 | 2 | import z from "zod" |
3 | 3 |
|
4 | | -import { withStatics } from "@/util/schema" |
5 | 4 | import { Identifier } from "@/id/id" |
| 5 | +import { withStatics } from "@/util/schema" |
6 | 6 |
|
7 | | -const sessionIdSchema = Schema.String.pipe(Schema.brand("SessionID")) |
8 | | - |
9 | | -export type SessionID = typeof sessionIdSchema.Type |
10 | | - |
11 | | -export const SessionID = sessionIdSchema.pipe( |
12 | | - withStatics((schema: typeof sessionIdSchema) => ({ |
13 | | - make: (id: string) => schema.makeUnsafe(id), |
14 | | - descending: (id?: string) => schema.makeUnsafe(Identifier.descending("session", id)), |
15 | | - zod: Identifier.schema("session").pipe(z.custom<SessionID>()), |
| 7 | +export const SessionID = Schema.String.pipe( |
| 8 | + Schema.brand("SessionID"), |
| 9 | + withStatics((s) => ({ |
| 10 | + make: (id: string) => s.makeUnsafe(id), |
| 11 | + descending: (id?: string) => s.makeUnsafe(Identifier.descending("session", id)), |
| 12 | + zod: Identifier.schema("session").pipe(z.custom<Schema.Schema.Type<typeof s>>()), |
16 | 13 | })), |
17 | 14 | ) |
18 | 15 |
|
19 | | -const messageIdSchema = Schema.String.pipe(Schema.brand("MessageID")) |
| 16 | +export type SessionID = Schema.Schema.Type<typeof SessionID> |
20 | 17 |
|
21 | | -export type MessageID = typeof messageIdSchema.Type |
22 | | - |
23 | | -export const MessageID = messageIdSchema.pipe( |
24 | | - withStatics((schema: typeof messageIdSchema) => ({ |
25 | | - make: (id: string) => schema.makeUnsafe(id), |
26 | | - ascending: (id?: string) => schema.makeUnsafe(Identifier.ascending("message", id)), |
27 | | - zod: Identifier.schema("message").pipe(z.custom<MessageID>()), |
| 18 | +export const MessageID = Schema.String.pipe( |
| 19 | + Schema.brand("MessageID"), |
| 20 | + withStatics((s) => ({ |
| 21 | + make: (id: string) => s.makeUnsafe(id), |
| 22 | + ascending: (id?: string) => s.makeUnsafe(Identifier.ascending("message", id)), |
| 23 | + zod: Identifier.schema("message").pipe(z.custom<Schema.Schema.Type<typeof s>>()), |
28 | 24 | })), |
29 | 25 | ) |
30 | 26 |
|
31 | | -const partIdSchema = Schema.String.pipe(Schema.brand("PartID")) |
32 | | - |
33 | | -export type PartID = typeof partIdSchema.Type |
| 27 | +export type MessageID = Schema.Schema.Type<typeof MessageID> |
34 | 28 |
|
35 | | -export const PartID = partIdSchema.pipe( |
36 | | - withStatics((schema: typeof partIdSchema) => ({ |
37 | | - make: (id: string) => schema.makeUnsafe(id), |
38 | | - ascending: (id?: string) => schema.makeUnsafe(Identifier.ascending("part", id)), |
39 | | - zod: Identifier.schema("part").pipe(z.custom<PartID>()), |
| 29 | +export const PartID = Schema.String.pipe( |
| 30 | + Schema.brand("PartID"), |
| 31 | + withStatics((s) => ({ |
| 32 | + make: (id: string) => s.makeUnsafe(id), |
| 33 | + ascending: (id?: string) => s.makeUnsafe(Identifier.ascending("part", id)), |
| 34 | + zod: Identifier.schema("part").pipe(z.custom<Schema.Schema.Type<typeof s>>()), |
40 | 35 | })), |
41 | 36 | ) |
| 37 | + |
| 38 | +export type PartID = Schema.Schema.Type<typeof PartID> |
0 commit comments