Skip to content

Commit 13f788a

Browse files
Merge pull request #80 from eshtek/dev
dev -> main
2 parents 3ba7bd4 + ccca696 commit 13f788a

13 files changed

Lines changed: 410 additions & 222 deletions

eshtek/admin.types.ts

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
/**
2+
* Admin API Types and Interfaces
3+
*/
4+
5+
/**
6+
* Response from the catalog status endpoint
7+
*/
8+
export interface CatalogStatusResponse {
9+
totalApps: number;
10+
totalNonDeprecated: number;
11+
totalWithScripts: number;
12+
totalWithScriptsNonDeprecated: number;
13+
totalDeprecated: number;
14+
lastSync: Date | null;
15+
}
16+
17+
/**
18+
* Individual app in the catalog
19+
*/
20+
export interface CatalogApp {
21+
id: number;
22+
name: string;
23+
train: string | null;
24+
version: string | null;
25+
appVersion: string | null;
26+
title: string | null;
27+
description: string | null;
28+
home: string | null;
29+
iconUrl: string | null;
30+
screenshots: string[];
31+
sources: string[];
32+
categories: string[];
33+
keywords: string[];
34+
maintainers: any[];
35+
supported: boolean;
36+
deprecated: boolean;
37+
installScript: string | null;
38+
requirements: any;
39+
compatibility: string | null;
40+
lastCatalogSync: Date | null;
41+
metadata: any;
42+
// Event statistics (detailed)
43+
installsDiscovered?: number;
44+
installsCompleted?: number;
45+
installsFailed?: number;
46+
uninstallsCompleted?: number;
47+
uninstallsFailed?: number;
48+
upgradesCompleted?: number;
49+
upgradesFailed?: number;
50+
updatesCompleted?: number;
51+
updatesFailed?: number;
52+
}
53+
54+
/**
55+
* Response from the catalog data endpoint
56+
*/
57+
export interface AppsCatalogResponse {
58+
apps: CatalogApp[];
59+
totalApps: number;
60+
totalWithScripts: number;
61+
totalDeprecated: number;
62+
lastSync: Date | null;
63+
}
64+
65+
/**
66+
* Drive data with event statistics
67+
*/
68+
export interface DriveData {
69+
id: number;
70+
manufacturer: string;
71+
model: string;
72+
name: string | null;
73+
type: string | null;
74+
size: number | null;
75+
smr: boolean;
76+
notes: string | null;
77+
isUserDiscovered: boolean;
78+
createdAt: Date;
79+
updatedAt: Date;
80+
// Event statistics
81+
utilized: number;
82+
replaced: number;
83+
removed: number;
84+
failed: number;
85+
discovered: number;
86+
}
87+
88+
/**
89+
* Response from the drives data endpoint
90+
*/
91+
export interface DrivesResponse {
92+
drives: DriveData[];
93+
totalDrives: number;
94+
totalSMR: number;
95+
totalUtilized: number;
96+
totalFailed: number;
97+
totalRemoved: number;
98+
}

eshtek/apps-schema.ts

Lines changed: 0 additions & 201 deletions
This file was deleted.

eshtek/apps.ts

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,28 @@ export interface AppRequirementsCheck {
5959
};
6060
}
6161

62-
export interface AppListing extends AvailableApp {
63-
hexos: boolean;
62+
export interface AppMaintainer {
63+
name: string;
64+
email: string;
65+
}
66+
67+
export interface AppListing {
68+
appId: string;
69+
name: string;
70+
train: "stable" | "community";
71+
version: string;
72+
appVersion: string;
73+
description: string;
74+
icon: string;
75+
categories: string[];
76+
keywords: string[];
77+
maintainers: AppMaintainer[];
78+
screenshots: string[];
79+
sources: string[];
80+
homepage: string;
81+
recommended: boolean;
82+
supported: boolean;
83+
fresh: boolean;
6484
installScript?: string;
6585
requirements?: AppRequirements;
6686
}
@@ -69,7 +89,9 @@ export interface AppInfo extends AppBasics {
6989
status: AppState;
7090
url_webui: string;
7191
upgradeAvailable: boolean;
92+
updatedScriptAvailable: boolean;
7293
latestVersion: string;
94+
recommended: boolean;
7395
}
7496
export interface AppInfoDetailed extends AppInfo {
7597
data: number[][];
@@ -120,6 +142,7 @@ export interface InstallationQuestion {
120142

121143
interface AppsInstallScriptV1 {
122144
version: 1;
145+
requirements?: AppRequirements;
123146
ensure_directories_exists?: Array<string | { path: string; network_share?: boolean; posix?: boolean }>;
124147
ensure_permissions_exists?: Array<{
125148
path: string;
@@ -132,6 +155,7 @@ interface AppsInstallScriptV1 {
132155

133156
interface AppsInstallScriptV2 {
134157
version: 2;
158+
requirements?: AppRequirements;
135159
installation_questions?: InstallationQuestion[];
136160
ensure_directories_exists?: Array<string | { path: string; network_share?: boolean; posix?: boolean }>;
137161
ensure_permissions_exists?: Array<{
@@ -143,7 +167,22 @@ interface AppsInstallScriptV2 {
143167
app_values: Record<string, ChartFormValue>;
144168
}
145169

146-
export type AppsInstallScript = AppsInstallScriptV1 | AppsInstallScriptV2;
170+
interface AppsInstallScriptV3 extends Omit<AppsInstallScriptV2, 'version' | 'requirements'> {
171+
version: 3;
172+
script: {
173+
version: string;
174+
updateCompatibility?: string;
175+
changeLog?: string;
176+
};
177+
requirements: AppRequirements; // Required in V3
178+
}
179+
180+
export type AppsInstallScript = AppsInstallScriptV1 | AppsInstallScriptV2 | AppsInstallScriptV3;
181+
182+
export interface AppConfiguration {
183+
installScript?: AppsInstallScript | null;
184+
questionResponses?: Record<string, string | number | boolean>;
185+
}
147186

148187
export interface InstallScriptCuration {
149188
name: string;

eshtek/common.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,3 +505,16 @@ export function getStepSize(range: number, steps: number = 10, acceptableSteps:
505505
return Math.abs(curr - rawStep) < Math.abs(prev - rawStep) ? curr : prev;
506506
});
507507
}
508+
509+
import type { HexTaskType } from './tasks';
510+
import type { EventState, TaskEventName } from './events';
511+
512+
/**
513+
* Generates a task event name from a task type and event state.
514+
* @param {HexTaskType} taskType - The type of the task.
515+
* @param {EventState} state - The state of the event (started, completed, failed).
516+
* @returns {TaskEventName} - Returns the generated event name (e.g., 'app_install_started').
517+
*/
518+
export function getTaskEventName(taskType: HexTaskType, state: EventState): TaskEventName {
519+
return `${taskType.toLowerCase()}_${state}` as TaskEventName;
520+
}

0 commit comments

Comments
 (0)