/
Alex_Ural
/
opencode
Обзор
Документация
Войти
/
Alex_Ural
/
opencode
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
packages/protocol/src/groups/location.ts
42 строки
1 KB
Kit Langton
refactor(protocol): extract server contracts (#33708)
25 июн 2026, 05:15
Не верифицирован
25 июн 2026, 05:15
56a37c3
Код
Авторство
О чём код?
import { Location } from "@opencode-ai/schema/location" import { Schema } from "effect" import { HttpApiEndpoint, HttpApiGroup, OpenApi } from "effect/unstable/httpapi" export const LocationQuery = Schema.Struct({ location: Schema.optional( Schema.Struct({ directory: Schema.optional(Schema.String), workspace: Schema.optional(Schema.String), }), ), }).annotate({ identifier: "LocationQuery" }) export const locationQueryOpenApi = OpenApi.annotations({ transform: (operation) => { const parameters = operation.parameters if (!Array.isArray(parameters)) return operation return { ...operation, parameters: parameters.map((parameter) => parameter?.name === "location" && parameter?.in === "query" ? { ...parameter, style: "deepObject", explode: true } : parameter, ), } }, }) export const LocationGroup = HttpApiGroup.make("server.location").add( HttpApiEndpoint.get("location.get", "/api/location", { query: LocationQuery, success: Location.Info, }) .annotateMerge(locationQueryOpenApi) .annotateMerge( OpenApi.annotations({ identifier: "v2.location.get", summary: "Get location", description: "Resolve the requested location or the server default location.", }), ), )