Open History to see the last commit
1import * as Option from "effect/Option";
2import * as Schema from "effect/Schema";
3import * as SchemaIssue from "effect/SchemaIssue";
4import * as Struct from "effect/Struct";
5
6import { NonNegativeInt, ThreadId, TrimmedNonEmptyString } from "./baseSchemas.ts";
7
8export const TurnCountRange = Schema.Struct({
9 fromTurnCount: NonNegativeInt,
10 toTurnCount: NonNegativeInt,
11}).check(
12 Schema.makeFilter(
13 (input) =>
14 input.fromTurnCount <= input.toTurnCount ||
15 new SchemaIssue.InvalidValue(Option.some(input.fromTurnCount), {
16 message: "fromTurnCount must be less than or equal to toTurnCount",
17 }),
18 { identifier: "OrchestrationTurnDiffRange" },
19 ),
20);
21
22export const ThreadTurnDiff = TurnCountRange.mapFields(
23 Struct.assign({
24 threadId: ThreadId,
25 diff: Schema.String,
26 }),
27 { unsafePreserveChecks: true },
28);
29
30export const OrchestrationGetTurnDiffInput = TurnCountRange.mapFields(
31 Struct.assign({
32 threadId: ThreadId,
33 ignoreWhitespace: Schema.optionalKey(Schema.Boolean),
34 }),
35 { unsafePreserveChecks: true },
36);
37export type OrchestrationGetTurnDiffInput = typeof OrchestrationGetTurnDiffInput.Type;
38
39export const OrchestrationGetTurnDiffResult = ThreadTurnDiff;
40export type OrchestrationGetTurnDiffResult = typeof OrchestrationGetTurnDiffResult.Type;
41
42export const OrchestrationGetFullThreadDiffInput = Schema.Struct({
43 threadId: ThreadId,
44 toTurnCount: NonNegativeInt,
45 ignoreWhitespace: Schema.optionalKey(Schema.Boolean),
46});
47export type OrchestrationGetFullThreadDiffInput = typeof OrchestrationGetFullThreadDiffInput.Type;
48
49export const OrchestrationGetFullThreadDiffResult = ThreadTurnDiff;
50export type OrchestrationGetFullThreadDiffResult = typeof OrchestrationGetFullThreadDiffResult.Type;
51
52export class OrchestrationGetTurnDiffError extends Schema.TaggedErrorClass<OrchestrationGetTurnDiffError>()(
53 "OrchestrationGetTurnDiffError",
54 {
55 message: TrimmedNonEmptyString,
56 cause: Schema.optional(Schema.Defect()),
57 },
58) {}
59
60export class OrchestrationGetFullThreadDiffError extends Schema.TaggedErrorClass<OrchestrationGetFullThreadDiffError>()(
61 "OrchestrationGetFullThreadDiffError",
62 {
63 message: TrimmedNonEmptyString,
64 cause: Schema.optional(Schema.Defect()),
65 },
66) {}