48 lines
1.7 KiB
TypeScript
48 lines
1.7 KiB
TypeScript
import { Schema } from "effect";
|
|
import { TrimmedNonEmptyString } from "./baseSchemas";
|
|
import { KeybindingRule, ResolvedKeybindingsConfig } from "./keybindings";
|
|
|
|
export const KeybindingsMalformedConfigIssue = Schema.Struct({
|
|
kind: Schema.Literal("keybindings.malformed-config"),
|
|
message: TrimmedNonEmptyString,
|
|
});
|
|
export type KeybindingsMalformedConfigIssue = typeof KeybindingsMalformedConfigIssue.Type;
|
|
|
|
export const KeybindingsInvalidEntryIssue = Schema.Struct({
|
|
kind: Schema.Literal("keybindings.invalid-entry"),
|
|
message: TrimmedNonEmptyString,
|
|
index: Schema.Number,
|
|
});
|
|
export type KeybindingsInvalidEntryIssue = typeof KeybindingsInvalidEntryIssue.Type;
|
|
|
|
export const ServerConfigIssue = Schema.Union([
|
|
KeybindingsMalformedConfigIssue,
|
|
KeybindingsInvalidEntryIssue,
|
|
]);
|
|
export type ServerConfigIssue = typeof ServerConfigIssue.Type;
|
|
|
|
export const ServerConfigIssues = Schema.Array(ServerConfigIssue);
|
|
export type ServerConfigIssues = typeof ServerConfigIssues.Type;
|
|
|
|
export const ServerConfig = Schema.Struct({
|
|
cwd: TrimmedNonEmptyString,
|
|
keybindingsConfigPath: TrimmedNonEmptyString,
|
|
keybindings: ResolvedKeybindingsConfig,
|
|
issues: ServerConfigIssues,
|
|
});
|
|
export type ServerConfig = typeof ServerConfig.Type;
|
|
|
|
export const ServerUpsertKeybindingInput = KeybindingRule;
|
|
export type ServerUpsertKeybindingInput = typeof ServerUpsertKeybindingInput.Type;
|
|
|
|
export const ServerUpsertKeybindingResult = Schema.Struct({
|
|
keybindings: ResolvedKeybindingsConfig,
|
|
issues: ServerConfigIssues,
|
|
});
|
|
export type ServerUpsertKeybindingResult = typeof ServerUpsertKeybindingResult.Type;
|
|
|
|
export const ServerConfigUpdatedPayload = Schema.Struct({
|
|
issues: ServerConfigIssues,
|
|
});
|
|
export type ServerConfigUpdatedPayload = typeof ServerConfigUpdatedPayload.Type;
|