Skip to content
This repository has been archived by the owner on Oct 2, 2023. It is now read-only.

Add more APIs for 0.1.0 #10

Merged
merged 3 commits into from
Jun 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 61 additions & 1 deletion src/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export type Dependency = 'bitcoind' | 'electrum' | 'lnd' | 'c-lightning';
/**
* Defines an app
*/
export type app = {
export type OldApp = {
/** The id of the app, the name as a simple string without spaces */
id: string;
/** A category for the app, used for grouping apps on the dashboard */
Expand Down Expand Up @@ -42,6 +42,66 @@ export type app = {
compatible: boolean;
};

export type MetadataV4 = {
/**
* The category for the app
*/
category: string;
/**
* The app's default password. Can also be $APP_SEED for a random password
*/
defaultPassword?: string | undefined;
developers: Record<string, string>;
/**
* A list of promo images for the apps
*/
gallery?: string[] | undefined;
/**
* The name of the app
*/
name: string;
/**
* The path the "Open" link on the dashboard should lead to
*/
path?: string | undefined;
/**
* Permissions the app requires
*/
permissions?: Array<string | string[]>;
/**
* App repository name -> repo URL
*/
repo: Record<string, string>;
/**
* A support link for the app
*/
support: string;
/**
* A short tagline for the app
*/
tagline: string;
/**
* True if the app only works over Tor
*/
torOnly?: boolean;
/**
* A list of containers to update automatically (still validated by the Citadel team)
*/
updateContainers?: string[] | undefined;
/**
* The version of the app
*/
version: string;
/** Automatically added */
hiddenService?: string;
/** Automatically added */
installed?: boolean;
/** Automatically added */
compatible: boolean;
};

export type app = MetadataV4 | OldApp;

type BuildPowersOf2LengthArrays<
N extends number,
R extends never[][],
Expand Down
20 changes: 18 additions & 2 deletions src/manager/apps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,23 @@ export class ManagerApps extends ApiConnection {
/**
* Get a list of all apps which can be updates
*/
async listUpdateable(): Promise<string[]> {
return await this.get<string[]>(`/updates`);
async listUpdatable(): Promise<
Record<
string,
{
updateFrom: string;
updateTo: string;
}
>
> {
return await this.get<
Record<
string,
{
updateFrom: string;
updateTo: string;
}
>
>(`/updates`);
}
}
4 changes: 4 additions & 0 deletions src/manager/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ export class ManagerSystem extends ApiConnection {
await this.post('update');
}

async startQuickUpdate(): Promise<void> {
await this.post('quick-update');
}

async updateStatus(): Promise<updateStatus> {
return await this.get<updateStatus>('update-status');
}
Expand Down