-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a7bf920
commit c87c54e
Showing
8 changed files
with
129 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
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, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<script lang="ts" strictEvents> | ||
import debounce from "lodash/debounce"; | ||
import { createEventDispatcher } from "svelte"; | ||
import { toClipboard } from "@app/lib/utils"; | ||
import IconSmall from "@app/components/IconSmall.svelte"; | ||
import Button from "@app/components/Button.svelte"; | ||
export let text: string; | ||
export let tooltip: string | undefined = undefined; | ||
const dispatch = createEventDispatcher<{ copied: null }>(); | ||
let icon: "globe" | "checkmark" = "globe"; | ||
const restoreIcon = debounce(() => { | ||
icon = "globe"; | ||
}, 800); | ||
export async function copy() { | ||
await toClipboard(text); | ||
dispatch("copied"); | ||
icon = "checkmark"; | ||
restoreIcon(); | ||
} | ||
</script> | ||
|
||
<Button variant="outline" size="large" on:click={copy} title={tooltip}> | ||
<IconSmall name={icon} /> | ||
Share | ||
</Button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters