fix: typings for version api
Some checks failed
Build / build (amd64, 20.x) (push) Has been cancelled
Build / build (amd64, 22.x) (push) Has been cancelled
Build / build (amd64, 23.x) (push) Has been cancelled
Build / build (arm64, 20.x) (push) Has been cancelled
Build / build (arm64, 22.x) (push) Has been cancelled
Build / build (arm64, 23.x) (push) Has been cancelled
Push Docker Images / push (push) Has been cancelled
Push Docker Images / amend-builds (push) Has been cancelled

This commit is contained in:
diced 2025-05-08 21:29:51 -07:00
parent 4a5d01c663
commit 08eb2df26c
No known key found for this signature in database
GPG key ID: 436B2B0FA0DCA354
2 changed files with 19 additions and 19 deletions

View file

@ -80,7 +80,7 @@ export default function VersionBadge() {
{!version.isLatest && !version.isUpstream && version.isRelease && ( {!version.isLatest && !version.isUpstream && version.isRelease && (
<Text> <Text>
You are running an <b>outdated</b> version of Zipline. It is recommended to update to the{' '} You are running an <b>outdated</b> version of Zipline. It is recommended to update to the{' '}
<Anchor href={version.latest?.url!}>latest version</Anchor>. <Anchor href={version.latest.url}>latest version</Anchor>.
</Text> </Text>
)} )}
@ -100,19 +100,19 @@ export default function VersionBadge() {
items={[ items={[
{ {
label: 'Version', label: 'Version',
value: version.version?.tag!, value: version.version.tag!,
href: `https://github.com/diced/zipline/releases/${version.version?.tag}`, href: `https://github.com/diced/zipline/releases/${version.version.tag}`,
}, },
{ {
label: 'Commit', label: 'Commit',
value: version.version?.sha!, value: version.version.sha!,
href: `https://github.com/diced/zipline/commit/${version.version?.sha}`, href: `https://github.com/diced/zipline/commit/${version.version.sha}`,
}, },
{ label: 'Upstream?', value: version.isUpstream ? 'Yes' : 'No' }, { label: 'Upstream?', value: version.isUpstream ? 'Yes' : 'No' },
]} ]}
/> />
{!version.isLatest && version.isUpstream && ( {!version.isLatest && version.isUpstream && version.latest.commit && (
<> <>
<Title order={3} mt='sm'> <Title order={3} mt='sm'>
Latest Commit Available Latest Commit Available
@ -125,12 +125,12 @@ export default function VersionBadge() {
items={[ items={[
{ {
label: 'Commit', label: 'Commit',
value: version.latest?.commit?.sha!.slice(0, 7)!, value: version.latest.commit.sha!.slice(0, 7)!,
href: `https://github.com/diced/zipline/commit/${version.latest?.commit?.sha}`, href: `https://github.com/diced/zipline/commit/${version.latest.commit.sha}`,
}, },
{ {
label: 'Available to update', label: 'Available to update',
value: version.latest?.commit?.pull ? 'Yes' : 'No', value: version.latest.commit.pull ? 'Yes' : 'No',
}, },
]} ]}
/> />
@ -140,15 +140,15 @@ export default function VersionBadge() {
{!version.isLatest && version.isRelease && ( {!version.isLatest && version.isRelease && (
<> <>
<Title order={3} mt='sm'> <Title order={3} mt='sm'>
{version.latest?.tag} is available {version.latest.tag} is available
</Title> </Title>
<VersionButton text='Changelogs' href={version.latest?.url!}> <VersionButton text='Changelogs' href={version.latest.url}>
{version.latest?.tag} {version.latest.tag}
</VersionButton> </VersionButton>
<VersionButton text='Update' href='https://zipline.diced.sh/docs/get-started/docker#updating'> <VersionButton text='Update' href='https://zipline.diced.sh/docs/get-started/docker#updating'>
{version.latest?.tag} {version.latest.tag}
</VersionButton> </VersionButton>
</> </>
)} )}

View file

@ -8,15 +8,15 @@ export type ApiVersionResponse = {
}; };
interface VersionAPI { interface VersionAPI {
isUpstream?: boolean; isUpstream: boolean;
isRelease?: boolean; isRelease: boolean;
isLatest?: boolean; isLatest: boolean;
version?: { version: {
tag: string; tag: string;
sha: string; sha: string;
url: string; url: string;
}; };
latest?: { latest: {
tag: string; tag: string;
url: string; url: string;
commit?: { commit?: {
@ -37,7 +37,7 @@ export default fastifyPlugin(
const resp = await fetch(`https://zipline-version.diced.sh/?${params.toString()}`); const resp = await fetch(`https://zipline-version.diced.sh/?${params.toString()}`);
if (!resp.ok) { if (!resp.ok) {
return res.internalServerError('failed to fetch version details: ' + await resp.text()); return res.internalServerError('failed to fetch version details: ' + (await resp.text()));
} }
const data: VersionAPI = await resp.json(); const data: VersionAPI = await resp.json();