| 1 | import * as Schema from "effect/Schema"; |
| 2 | |
| 3 | export const RelayClientStatusSchema = Schema.Union([ |
| 4 | Schema.Struct({ |
| 5 | status: Schema.Literal("available"), |
| 6 | executablePath: Schema.String, |
| 7 | source: Schema.Literals(["override", "managed", "path"]), |
| 8 | version: Schema.String, |
| 9 | }), |
| 10 | Schema.Struct({ |
| 11 | status: Schema.Literal("missing"), |
| 12 | version: Schema.String, |
| 13 | }), |
| 14 | Schema.Struct({ |
| 15 | status: Schema.Literal("unsupported"), |
| 16 | platform: Schema.String, |
| 17 | arch: Schema.String, |
| 18 | version: Schema.String, |
| 19 | }), |
| 20 | ]); |
| 21 | export type RelayClientStatus = typeof RelayClientStatusSchema.Type; |
| 22 | |
| 23 | export const RelayClientInstallProgressStageSchema = Schema.Literals([ |
| 24 | "checking", |
| 25 | "waiting_for_lock", |
| 26 | "downloading", |
| 27 | "verifying", |
| 28 | "installing", |
| 29 | "validating", |
| 30 | "activating", |
| 31 | ]); |
| 32 | export type RelayClientInstallProgressStage = typeof RelayClientInstallProgressStageSchema.Type; |
| 33 | |
| 34 | export const RelayClientInstallProgressEventSchema = Schema.Union([ |
| 35 | Schema.Struct({ |
| 36 | type: Schema.Literal("progress"), |
| 37 | stage: RelayClientInstallProgressStageSchema, |
| 38 | }), |
| 39 | Schema.Struct({ |
| 40 | type: Schema.Literal("complete"), |
| 41 | status: RelayClientStatusSchema, |
| 42 | }), |
| 43 | ]); |
| 44 | export type RelayClientInstallProgressEvent = typeof RelayClientInstallProgressEventSchema.Type; |
| 45 | |
| 46 | export const RelayClientInstallFailureReasonSchema = Schema.Literals([ |
| 47 | "download_failed", |
| 48 | "invalid_checksum", |
| 49 | "install_locked", |
| 50 | "override_missing", |
| 51 | "unsupported_platform", |
| 52 | "validation_failed", |
| 53 | "write_failed", |
| 54 | ]); |
| 55 | export type RelayClientInstallFailureReason = typeof RelayClientInstallFailureReasonSchema.Type; |
| 56 | |
| 57 | export class RelayClientInstallFailedError extends Schema.TaggedError<RelayClientInstallFailedError>()( |
| 58 | "RelayClientInstallFailedError", |
| 59 | { |
| 60 | reason: RelayClientInstallFailureReasonSchema, |
| 61 | message: Schema.String, |
| 62 | }, |
| 63 | ) {} |