diff --git a/packages/perstack/src/status.ts b/packages/perstack/src/status.ts index 7f459e0f..1830622a 100644 --- a/packages/perstack/src/status.ts +++ b/packages/perstack/src/status.ts @@ -1,5 +1,5 @@ import { ApiV1Client } from "@perstack/api-client/v1" -import { renderStatus, type StatusVersionInfo } from "@perstack/tui" +import { renderStatus, type WizardVersionInfo } from "@perstack/tui" import { Command } from "commander" import { getPerstackConfig } from "./lib/perstack-toml.js" @@ -33,12 +33,12 @@ export const statusCommand = new Command() name, description: experts[name].description, })), - onFetchVersions: async (expertName: string): Promise => { + onFetchVersions: async (expertName: string): Promise => { try { const { versions } = await client.registry.experts.getVersions({ expertKey: expertName, }) - const versionInfos: StatusVersionInfo[] = [] + const versionInfos: WizardVersionInfo[] = [] for (const v of versions) { try { const { expert: fullExpert } = await client.registry.experts.get({ diff --git a/packages/perstack/src/tag.ts b/packages/perstack/src/tag.ts index cf717a31..9b86dc34 100644 --- a/packages/perstack/src/tag.ts +++ b/packages/perstack/src/tag.ts @@ -1,5 +1,5 @@ import { ApiV1Client } from "@perstack/api-client/v1" -import { renderTag, type VersionInfo } from "@perstack/tui" +import { renderTag, type WizardVersionInfo } from "@perstack/tui" import { Command } from "commander" import { getPerstackConfig } from "./lib/perstack-toml.js" @@ -33,12 +33,12 @@ export const tagCommand = new Command() name, description: experts[name].description, })), - onFetchVersions: async (expertName: string): Promise => { + onFetchVersions: async (expertName: string): Promise => { try { const { versions } = await client.registry.experts.getVersions({ expertKey: expertName, }) - const versionInfos: VersionInfo[] = [] + const versionInfos: WizardVersionInfo[] = [] for (const v of versions) { try { const { expert: fullExpert } = await client.registry.experts.get({ diff --git a/packages/perstack/src/unpublish.ts b/packages/perstack/src/unpublish.ts index 93ec76a0..6c0004c5 100644 --- a/packages/perstack/src/unpublish.ts +++ b/packages/perstack/src/unpublish.ts @@ -1,5 +1,5 @@ import { ApiV1Client } from "@perstack/api-client/v1" -import { renderUnpublish, type UnpublishVersionInfo } from "@perstack/tui" +import { renderUnpublish, type WizardVersionInfo } from "@perstack/tui" import { Command } from "commander" import { getPerstackConfig } from "./lib/perstack-toml.js" export const unpublishCommand = new Command() @@ -27,12 +27,12 @@ export const unpublishCommand = new Command() name, description: experts[name].description, })), - onFetchVersions: async (expertName: string): Promise => { + onFetchVersions: async (expertName: string): Promise => { try { const { versions } = await client.registry.experts.getVersions({ expertKey: expertName, }) - const versionInfos: UnpublishVersionInfo[] = [] + const versionInfos: WizardVersionInfo[] = [] for (const v of versions) { try { const { expert: fullExpert } = await client.registry.experts.get({ diff --git a/packages/tui/apps/publish/app.tsx b/packages/tui/apps/publish/app.tsx index f55490ef..8664bafa 100644 --- a/packages/tui/apps/publish/app.tsx +++ b/packages/tui/apps/publish/app.tsx @@ -1,13 +1,9 @@ import { Box, Text, useApp, useInput } from "ink" import { useState } from "react" - -type ExpertChoice = { - name: string - description?: string -} +import type { WizardExpertChoice } from "../../src/types/wizard.js" type PublishAppProps = { - experts: ExpertChoice[] + experts: WizardExpertChoice[] onSelect: (expertName: string) => void } diff --git a/packages/tui/apps/publish/render.tsx b/packages/tui/apps/publish/render.tsx index 1ec421db..072a5ada 100644 --- a/packages/tui/apps/publish/render.tsx +++ b/packages/tui/apps/publish/render.tsx @@ -1,13 +1,9 @@ import { render } from "ink" +import type { WizardExpertChoice } from "../../src/types/wizard.js" import { PublishApp } from "./app.js" -type ExpertChoice = { - name: string - description?: string -} - type RenderPublishSelectOptions = { - experts: ExpertChoice[] + experts: WizardExpertChoice[] } export async function renderPublish(options: RenderPublishSelectOptions): Promise { diff --git a/packages/tui/apps/status/app.tsx b/packages/tui/apps/status/app.tsx index ff656495..32cf1690 100644 --- a/packages/tui/apps/status/app.tsx +++ b/packages/tui/apps/status/app.tsx @@ -1,24 +1,13 @@ import { Box, Text, useApp, useInput } from "ink" import { useState } from "react" import { ErrorStep } from "../../src/components/error-step.js" +import type { WizardExpertChoice, WizardVersionInfo } from "../../src/types/wizard.js" import { getStatusColor } from "../../src/utils/index.js" -type ExpertChoice = { - name: string - description?: string -} - -type VersionInfo = { - key: string - version: string - tags: string[] - status: "available" | "deprecated" | "disabled" -} - type WizardStep = | { type: "selectExpert" } | { type: "loadingVersions"; expertName: string } - | { type: "selectVersion"; expertName: string; versions: VersionInfo[] } + | { type: "selectVersion"; expertName: string; versions: WizardVersionInfo[] } | { type: "selectStatus"; expertKey: string; currentStatus: string } | { type: "confirm"; expertKey: string; status: string; currentStatus: string } | { type: "error"; message: string } @@ -29,8 +18,8 @@ type StatusWizardResult = { } type StatusAppProps = { - experts: ExpertChoice[] - onFetchVersions: (expertName: string) => Promise + experts: WizardExpertChoice[] + onFetchVersions: (expertName: string) => Promise onComplete: (result: StatusWizardResult) => void onCancel: () => void } @@ -52,7 +41,7 @@ function ExpertSelector({ experts, onSelect, }: { - experts: ExpertChoice[] + experts: WizardExpertChoice[] onSelect: (name: string) => void }) { const { exit } = useApp() @@ -99,8 +88,8 @@ function VersionSelector({ onBack, }: { expertName: string - versions: VersionInfo[] - onSelect: (version: VersionInfo) => void + versions: WizardVersionInfo[] + onSelect: (version: WizardVersionInfo) => void onBack: () => void }) { const { exit } = useApp() @@ -283,7 +272,7 @@ export function StatusApp({ experts, onFetchVersions, onComplete, onCancel }: St }) } } - const handleVersionSelect = (version: VersionInfo) => { + const handleVersionSelect = (version: WizardVersionInfo) => { setStep({ type: "selectStatus", expertKey: version.key, @@ -376,4 +365,5 @@ export function StatusApp({ experts, onFetchVersions, onComplete, onCancel }: St } } -export type { ExpertChoice, VersionInfo, StatusWizardResult } +export type { StatusWizardResult } +export type { WizardExpertChoice, WizardVersionInfo } from "../../src/types/wizard.js" diff --git a/packages/tui/apps/status/render.tsx b/packages/tui/apps/status/render.tsx index e87faef9..3617c89f 100644 --- a/packages/tui/apps/status/render.tsx +++ b/packages/tui/apps/status/render.tsx @@ -1,9 +1,10 @@ import { render } from "ink" -import { type ExpertChoice, StatusApp, type StatusWizardResult, type VersionInfo } from "./app.js" +import type { WizardExpertChoice, WizardVersionInfo } from "../../src/types/wizard.js" +import { StatusApp, type StatusWizardResult } from "./app.js" type RenderStatusWizardOptions = { - experts: ExpertChoice[] - onFetchVersions: (expertName: string) => Promise + experts: WizardExpertChoice[] + onFetchVersions: (expertName: string) => Promise } export async function renderStatus( @@ -29,4 +30,5 @@ export async function renderStatus( }) } -export type { ExpertChoice, VersionInfo, StatusWizardResult } +export type { StatusWizardResult } +export type { WizardExpertChoice, WizardVersionInfo } from "../../src/types/wizard.js" diff --git a/packages/tui/apps/tag/app.tsx b/packages/tui/apps/tag/app.tsx index baac35d6..bfb62631 100644 --- a/packages/tui/apps/tag/app.tsx +++ b/packages/tui/apps/tag/app.tsx @@ -1,24 +1,13 @@ import { Box, Text, useApp, useInput } from "ink" import { useState } from "react" import { ErrorStep } from "../../src/components/error-step.js" +import type { WizardExpertChoice, WizardVersionInfo } from "../../src/types/wizard.js" import { getStatusColor } from "../../src/utils/index.js" -type ExpertChoice = { - name: string - description?: string -} - -type VersionInfo = { - key: string - version: string - tags: string[] - status: "available" | "deprecated" | "disabled" -} - type WizardStep = | { type: "selectExpert" } | { type: "loadingVersions"; expertName: string } - | { type: "selectVersion"; expertName: string; versions: VersionInfo[] } + | { type: "selectVersion"; expertName: string; versions: WizardVersionInfo[] } | { type: "inputTags"; expertKey: string; currentTags: string[] } | { type: "confirm"; expertKey: string; tags: string[]; currentTags: string[] } | { type: "error"; message: string } @@ -29,8 +18,8 @@ type TagWizardResult = { } type TagAppProps = { - experts: ExpertChoice[] - onFetchVersions: (expertName: string) => Promise + experts: WizardExpertChoice[] + onFetchVersions: (expertName: string) => Promise onComplete: (result: TagWizardResult) => void onCancel: () => void } @@ -39,7 +28,7 @@ function ExpertSelector({ experts, onSelect, }: { - experts: ExpertChoice[] + experts: WizardExpertChoice[] onSelect: (name: string) => void }) { const { exit } = useApp() @@ -86,8 +75,8 @@ function VersionSelector({ onBack, }: { expertName: string - versions: VersionInfo[] - onSelect: (version: VersionInfo) => void + versions: WizardVersionInfo[] + onSelect: (version: WizardVersionInfo) => void onBack: () => void }) { const { exit } = useApp() @@ -283,7 +272,7 @@ export function TagApp({ experts, onFetchVersions, onComplete, onCancel }: TagAp }) } } - const handleVersionSelect = (version: VersionInfo) => { + const handleVersionSelect = (version: WizardVersionInfo) => { setStep({ type: "inputTags", expertKey: version.key, @@ -376,4 +365,5 @@ export function TagApp({ experts, onFetchVersions, onComplete, onCancel }: TagAp } } -export type { ExpertChoice, VersionInfo, TagWizardResult } +export type { TagWizardResult } +export type { WizardExpertChoice, WizardVersionInfo } from "../../src/types/wizard.js" diff --git a/packages/tui/apps/tag/render.tsx b/packages/tui/apps/tag/render.tsx index 1f6bf487..5663eab3 100644 --- a/packages/tui/apps/tag/render.tsx +++ b/packages/tui/apps/tag/render.tsx @@ -1,9 +1,10 @@ import { render } from "ink" -import { type ExpertChoice, TagApp, type TagWizardResult, type VersionInfo } from "./app.js" +import type { WizardExpertChoice, WizardVersionInfo } from "../../src/types/wizard.js" +import { TagApp, type TagWizardResult } from "./app.js" type RenderTagWizardOptions = { - experts: ExpertChoice[] - onFetchVersions: (expertName: string) => Promise + experts: WizardExpertChoice[] + onFetchVersions: (expertName: string) => Promise } export async function renderTag(options: RenderTagWizardOptions): Promise { @@ -27,4 +28,5 @@ export async function renderTag(options: RenderTagWizardOptions): Promise Promise + experts: WizardExpertChoice[] + onFetchVersions: (expertName: string) => Promise onComplete: (result: UnpublishWizardResult) => void onCancel: () => void } @@ -32,7 +23,7 @@ function ExpertSelector({ experts, onSelect, }: { - experts: ExpertChoice[] + experts: WizardExpertChoice[] onSelect: (name: string) => void }) { const { exit } = useApp() @@ -78,8 +69,8 @@ function VersionSelector({ onBack, }: { expertName: string - versions: VersionInfo[] - onSelect: (version: VersionInfo) => void + versions: WizardVersionInfo[] + onSelect: (version: WizardVersionInfo) => void onBack: () => void }) { const { exit } = useApp() @@ -200,7 +191,7 @@ export function UnpublishApp({ }) } } - const handleVersionSelect = (version: VersionInfo) => { + const handleVersionSelect = (version: WizardVersionInfo) => { setStep({ type: "confirm", expertKey: version.key, @@ -262,4 +253,5 @@ export function UnpublishApp({ return null } } -export type { ExpertChoice, VersionInfo, UnpublishWizardResult } +export type { UnpublishWizardResult } +export type { WizardExpertChoice, WizardVersionInfo } from "../../src/types/wizard.js" diff --git a/packages/tui/apps/unpublish/render.tsx b/packages/tui/apps/unpublish/render.tsx index 06daa244..1a5aff2f 100644 --- a/packages/tui/apps/unpublish/render.tsx +++ b/packages/tui/apps/unpublish/render.tsx @@ -1,14 +1,10 @@ import { render } from "ink" -import { - type ExpertChoice, - UnpublishApp, - type UnpublishWizardResult, - type VersionInfo, -} from "./app.js" +import type { WizardExpertChoice, WizardVersionInfo } from "../../src/types/wizard.js" +import { UnpublishApp, type UnpublishWizardResult } from "./app.js" type RenderUnpublishOptions = { - experts: ExpertChoice[] - onFetchVersions: (expertName: string) => Promise + experts: WizardExpertChoice[] + onFetchVersions: (expertName: string) => Promise } export async function renderUnpublish( options: RenderUnpublishOptions, @@ -32,4 +28,5 @@ export async function renderUnpublish( }) }) } -export type { ExpertChoice, VersionInfo, UnpublishWizardResult } +export type { UnpublishWizardResult } +export type { WizardExpertChoice, WizardVersionInfo } from "../../src/types/wizard.js" diff --git a/packages/tui/src/index.ts b/packages/tui/src/index.ts index 8b12c3c6..9977132e 100644 --- a/packages/tui/src/index.ts +++ b/packages/tui/src/index.ts @@ -1,26 +1,13 @@ export { renderPublish } from "../apps/publish/render.js" export { renderStart } from "../apps/start/render.js" -export { - type ExpertChoice as StatusExpertChoice, - renderStatus, - type StatusWizardResult, - type VersionInfo as StatusVersionInfo, -} from "../apps/status/render.js" -export { - type ExpertChoice as TagExpertChoice, - renderTag, - type TagWizardResult, - type VersionInfo, -} from "../apps/tag/render.js" -export { - type ExpertChoice as UnpublishExpertChoice, - renderUnpublish, - type UnpublishWizardResult, - type VersionInfo as UnpublishVersionInfo, -} from "../apps/unpublish/render.js" +export { renderStatus, type StatusWizardResult } from "../apps/status/render.js" +export { renderTag, type TagWizardResult } from "../apps/tag/render.js" +export { renderUnpublish, type UnpublishWizardResult } from "../apps/unpublish/render.js" export type { CheckpointHistoryItem, EventHistoryItem, PerstackEvent, RunHistoryItem, + WizardExpertChoice, + WizardVersionInfo, } from "./types/index.js" diff --git a/packages/tui/src/types/index.ts b/packages/tui/src/types/index.ts index 1f598b60..0c783c02 100644 --- a/packages/tui/src/types/index.ts +++ b/packages/tui/src/types/index.ts @@ -19,3 +19,4 @@ export type { InputState, RunningState, } from "./input-state.js" +export type { WizardExpertChoice, WizardVersionInfo } from "./wizard.js" diff --git a/packages/tui/src/types/wizard.ts b/packages/tui/src/types/wizard.ts new file mode 100644 index 00000000..3174b0e8 --- /dev/null +++ b/packages/tui/src/types/wizard.ts @@ -0,0 +1,10 @@ +export type WizardExpertChoice = { + name: string + description?: string +} +export type WizardVersionInfo = { + key: string + version: string + tags: string[] + status: "available" | "deprecated" | "disabled" +}