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