Open History to see the last commit
1import * as Schema from "effect/Schema";
2
3export const TrimmedString = Schema.Trim;
4export const TrimmedNonEmptyString = TrimmedString.check(Schema.isNonEmpty());
5
6export const NonNegativeInt = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0));
7export const PositiveInt = Schema.Int.check(Schema.isGreaterThanOrEqualTo(1));
8export const PortSchema = Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 65535 }));
9
10export const IsoDateTime = Schema.String;
11export type IsoDateTime = typeof IsoDateTime.Type;
12
13/**
14 * Construct a branded identifier. Enforces non-empty trimmed strings
15 */
16const makeEntityId = <Brand extends string>(brand: Brand) => {
17 return TrimmedNonEmptyString.pipe(Schema.brand(brand));
18};
19
20export const ThreadId = makeEntityId("ThreadId");
21export type ThreadId = typeof ThreadId.Type;
22export const ProjectId = makeEntityId("ProjectId");
23export type ProjectId = typeof ProjectId.Type;
24export const EnvironmentId = makeEntityId("EnvironmentId");
25export type EnvironmentId = typeof EnvironmentId.Type;
26export const CommandId = makeEntityId("CommandId");
27export type CommandId = typeof CommandId.Type;
28export const EventId = makeEntityId("EventId");
29export type EventId = typeof EventId.Type;
30export const MessageId = makeEntityId("MessageId");
31export type MessageId = typeof MessageId.Type;
32export const TurnId = makeEntityId("TurnId");
33export type TurnId = typeof TurnId.Type;
34export const AuthSessionId = makeEntityId("AuthSessionId");
35export type AuthSessionId = typeof AuthSessionId.Type;
36
37export const ProviderItemId = makeEntityId("ProviderItemId");
38export type ProviderItemId = typeof ProviderItemId.Type;
39export const RuntimeSessionId = makeEntityId("RuntimeSessionId");
40export type RuntimeSessionId = typeof RuntimeSessionId.Type;
41export const RuntimeItemId = makeEntityId("RuntimeItemId");
42export type RuntimeItemId = typeof RuntimeItemId.Type;
43export const RuntimeRequestId = makeEntityId("RuntimeRequestId");
44export type RuntimeRequestId = typeof RuntimeRequestId.Type;
45export const RuntimeTaskId = makeEntityId("RuntimeTaskId");
46export type RuntimeTaskId = typeof RuntimeTaskId.Type;
47export const ApprovalRequestId = makeEntityId("ApprovalRequestId");
48export type ApprovalRequestId = typeof ApprovalRequestId.Type;
49export const CheckpointRef = makeEntityId("CheckpointRef");
50export type CheckpointRef = typeof CheckpointRef.Type;