mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-10-30 08:40:52 +08:00
37 lines
803 B
TypeScript
37 lines
803 B
TypeScript
import type { Fetcher, RequestOptions } from "./fetcher.js";
|
|
import type { z } from "zod";
|
|
|
|
import { array, boolean, object, string } from "zod";
|
|
import { nodeConfigSchema } from "./shared.js";
|
|
|
|
const profileSchema = object({
|
|
config: object({
|
|
publicExplorer: string(),
|
|
preferredSeeds: array(string()),
|
|
cli: object({ hints: boolean() }),
|
|
node: nodeConfigSchema,
|
|
}),
|
|
home: string(),
|
|
});
|
|
|
|
export type Profile = z.infer<typeof profileSchema>;
|
|
|
|
export class Client {
|
|
#fetcher: Fetcher;
|
|
|
|
public constructor(fetcher: Fetcher) {
|
|
this.#fetcher = fetcher;
|
|
}
|
|
|
|
public async getProfile(options?: RequestOptions): Promise<Profile> {
|
|
return this.#fetcher.fetchOk(
|
|
{
|
|
method: "GET",
|
|
path: `profile`,
|
|
options,
|
|
},
|
|
profileSchema,
|
|
);
|
|
}
|
|
}
|