-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add custom registries support, closes #61
- Loading branch information
Showing
60 changed files
with
2,006 additions
and
134 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
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,30 @@ | ||
<script lang="ts"> | ||
import Card from '$components/card.svelte'; | ||
import Link from '$components/link.svelte'; | ||
import routes from '$lib/path'; | ||
import type { Registry } from '$lib/resources/registries'; | ||
export let data: Registry; | ||
</script> | ||
|
||
<Card> | ||
<h2 class="title"><Link href={routes.editRegistry(data.id)}>{data.name}</Link></h2> | ||
<div class="meta">{data.url}</div> | ||
</Card> | ||
|
||
<style module> | ||
.title { | ||
color: var(--co-text-5); | ||
font: var(--ty-heading-2); | ||
white-space: nowrap; | ||
text-overflow: ellipsis; | ||
overflow: hidden; | ||
} | ||
.meta { | ||
font: var(--ty-caption); | ||
white-space: nowrap; | ||
text-overflow: ellipsis; | ||
overflow: hidden; | ||
} | ||
</style> |
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
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,84 @@ | ||
import { POLLING_INTERVAL_MS } from '$lib/config'; | ||
import fetcher, { type FetchOptions, type FetchService, type QueryResult } from '$lib/fetcher'; | ||
import type { ByUserData } from '$lib/resources/users'; | ||
|
||
export type Registry = { | ||
id: string; | ||
name: string; | ||
url: string; | ||
credentials?: Credentials; | ||
created_at: string; | ||
created_by: ByUserData; | ||
}; | ||
|
||
export type Credentials = { | ||
username: string; | ||
password: string; | ||
}; | ||
|
||
export type CreateRegistry = { | ||
name: string; | ||
url: string; | ||
credentials?: Credentials; | ||
}; | ||
|
||
export type UpdateRegistry = { | ||
name?: string; | ||
url?: string; | ||
credentials: Patch<{ | ||
username: string; | ||
password?: string; | ||
}>; | ||
}; | ||
|
||
export interface RegistriesService { | ||
create(payload: CreateRegistry): Promise<Registry>; | ||
update(id: string, payload: UpdateRegistry): Promise<Registry>; | ||
delete(id: string): Promise<void>; | ||
fetchAll(options?: FetchOptions): Promise<Registry[]>; | ||
fetchById(id: string, options?: FetchOptions): Promise<Registry>; | ||
queryAll(): QueryResult<Registry[]>; | ||
} | ||
|
||
type Options = { | ||
pollingInterval: number; | ||
}; | ||
|
||
export class RemoteRegistriesService implements RegistriesService { | ||
constructor(private readonly _fetcher: FetchService, private readonly _options: Options) {} | ||
|
||
create(payload: CreateRegistry): Promise<Registry> { | ||
return this._fetcher.post('/api/v1/registries', payload); | ||
} | ||
|
||
update(id: string, payload: UpdateRegistry): Promise<Registry> { | ||
return this._fetcher.patch(`/api/v1/registries/${id}`, payload); | ||
} | ||
|
||
delete(id: string): Promise<void> { | ||
return this._fetcher.delete(`/api/v1/registries/${id}`, { | ||
invalidate: ['/api/v1/registries'], | ||
skipUrlInvalidate: true | ||
}); | ||
} | ||
|
||
queryAll(): QueryResult<Registry[]> { | ||
return this._fetcher.query('/api/v1/registries', { | ||
refreshInterval: this._options.pollingInterval | ||
}); | ||
} | ||
|
||
fetchAll(options?: FetchOptions): Promise<Registry[]> { | ||
return this._fetcher.get('/api/v1/registries', options); | ||
} | ||
|
||
fetchById(id: string, options?: FetchOptions): Promise<Registry> { | ||
return this._fetcher.get(`/api/v1/registries/${id}`, options); | ||
} | ||
} | ||
|
||
const service: RegistriesService = new RemoteRegistriesService(fetcher, { | ||
pollingInterval: POLLING_INTERVAL_MS | ||
}); | ||
|
||
export default service; |
Oops, something went wrong.