diff --git a/lib/backup/Backups.ts b/lib/backup/Backups.ts index 9df5304..659da0e 100644 --- a/lib/backup/Backups.ts +++ b/lib/backup/Backups.ts @@ -42,12 +42,12 @@ export class Backups { private constructor( private options = DEFAULT_OPTIONS, - private backupSet = [] as BackupSet[], + private backupSet = [] as BackupSet[], ) {} static volumes( - ...volumeNames: Array - ) { - return new Backups().addSets( + ...volumeNames: Array + ): Backups { + return new Backups().addSets( ...volumeNames.map((srcVolume) => ({ srcVolume, srcPath: "./", @@ -57,7 +57,7 @@ export class Backups { ) } static addSets( - ...options: BackupSet[] + ...options: BackupSet[] ) { return new Backups().addSets(...options) } @@ -75,7 +75,7 @@ export class Backups { } return this } - volumes(...volumeNames: Array) { + volumes(...volumeNames: Array) { return this.addSets( ...volumeNames.map((srcVolume) => ({ srcVolume, @@ -85,7 +85,7 @@ export class Backups { })), ) } - addSets(...options: BackupSet[]) { + addSets(...options: BackupSet[]) { options.forEach((x) => this.backupSet.push({ ...x, options: { ...this.options, ...x.options } }), ) diff --git a/lib/backup/setupBackups.ts b/lib/backup/setupBackups.ts index e5d21ed..d171a4a 100644 --- a/lib/backup/setupBackups.ts +++ b/lib/backup/setupBackups.ts @@ -4,14 +4,14 @@ import { ExpectedExports } from "../types" import { _ } from "../util" export type SetupBackupsParams = Array< - (keyof M["volumes"] & string) | Backups + M["volumes"][0] | Backups > export function setupBackups( ...args: _> ) { const backups = Array>() - const volumes = new Set() + const volumes = new Set() for (const arg of args) { if (arg instanceof Backups) { backups.push(arg) diff --git a/lib/dependency/setupDependencyMounts.ts b/lib/dependency/setupDependencyMounts.ts index f867b13..15e2ca1 100644 --- a/lib/dependency/setupDependencyMounts.ts +++ b/lib/dependency/setupDependencyMounts.ts @@ -35,7 +35,7 @@ class SetupDependencyMounts { addPath< Name extends string, - Volume extends keyof M["volumes"] & string, + Volume extends M["volumes"][0] & string, Path extends string, ManifestId extends M["id"], M extends SDKManifest, diff --git a/lib/mainFn/Daemons.ts b/lib/mainFn/Daemons.ts index 4e8ba7b..d2049fc 100644 --- a/lib/mainFn/Daemons.ts +++ b/lib/mainFn/Daemons.ts @@ -5,6 +5,7 @@ import { TriggerInput } from "../trigger/TriggerInput" import { defaultTrigger } from "../trigger/defaultTrigger" import { DaemonReturned, Effects, ValidIfNoStupidEscape } from "../types" import { createUtils } from "../util" +import { Signals } from "../util/utils" type Daemon = { id: "" extends Id ? never : Id command: ValidIfNoStupidEscape | [string, ...string[]] @@ -128,7 +129,7 @@ export class Daemons { }) } return { - async term(options?: { signal?: string; timeout?: number }) { + async term(options?: { signal?: Signals; timeout?: number }) { await Promise.all( Object.values>(daemonsStarted).map((x) => x.then((x) => x.term(options)), diff --git a/lib/manifest/setupManifest.ts b/lib/manifest/setupManifest.ts index 071c817..41c74ba 100644 --- a/lib/manifest/setupManifest.ts +++ b/lib/manifest/setupManifest.ts @@ -4,12 +4,16 @@ export function setupManifest< Id extends string, Version extends ManifestVersion, Dependencies extends Record, - Volumes extends string[], + VolumesTypes extends string, + AssetTypes extends string, + ImagesTypes extends string, Manifest extends SDKManifest & { dependencies: Dependencies id: Id version: Version - volumes: Volumes + assets: AssetTypes[] + images: ImagesTypes[] + volumes: VolumesTypes[] }, >(manifest: Manifest): Manifest { return manifest diff --git a/lib/test/mountDependencies.test.ts b/lib/test/mountDependencies.test.ts index 6de66d4..84e76aa 100644 --- a/lib/test/mountDependencies.test.ts +++ b/lib/test/mountDependencies.test.ts @@ -35,6 +35,7 @@ describe("mountDependencies", () => { }, dependencies: {}, }) + const clnManifestVolumes = clnManifest.volumes const lndManifest = setupManifest({ id: "lnd", title: "", diff --git a/lib/types.ts b/lib/types.ts index eef314a..2189523 100644 --- a/lib/types.ts +++ b/lib/types.ts @@ -3,7 +3,7 @@ import { InputSpec } from "./config/configTypes" import { DependenciesReceipt } from "./config/setupConfig" import { PortOptions } from "./interfaces/Host" import { UrlString } from "./util/getNetworkInterface" -import { NetworkInterfaceType } from "./util/utils" +import { NetworkInterfaceType, Signals } from "./util/utils" export type ExportedAction = (options: { effects: Effects @@ -148,7 +148,7 @@ export type CommandType = export type DaemonReturned = { wait(): Promise - term(): Promise + term(options?: { signal?: Signals; timeout?: number }): Promise } export type ActionMetadata = { @@ -495,40 +495,7 @@ export type ActionResult = { } export type SetResult = { /** These are the unix process signals */ - signal: - | "SIGTERM" - | "SIGHUP" - | "SIGINT" - | "SIGQUIT" - | "SIGILL" - | "SIGTRAP" - | "SIGABRT" - | "SIGBUS" - | "SIGFPE" - | "SIGKILL" - | "SIGUSR1" - | "SIGSEGV" - | "SIGUSR2" - | "SIGPIPE" - | "SIGALRM" - | "SIGSTKFLT" - | "SIGCHLD" - | "SIGCONT" - | "SIGSTOP" - | "SIGTSTP" - | "SIGTTIN" - | "SIGTTOU" - | "SIGURG" - | "SIGXCPU" - | "SIGXFSZ" - | "SIGVTALRM" - | "SIGPROF" - | "SIGWINCH" - | "SIGIO" - | "SIGPWR" - | "SIGSYS" - | "SIGEMT" - | "SIGINFO" + signal: Signals "depends-on": DependsOn } diff --git a/lib/util/utils.ts b/lib/util/utils.ts index 0cc5a5f..75a9512 100644 --- a/lib/util/utils.ts +++ b/lib/util/utils.ts @@ -37,7 +37,8 @@ import { import * as CP from "node:child_process" import { promisify } from "node:util" import { splitCommand } from "./splitCommand" -export type Signals = "SIGTERM" | "SIGKILL" +export type Signals = NodeJS.Signals + export const SIGTERM: Signals = "SIGTERM" export const SIGKILL: Signals = "SIGTERM" export const NO_TIMEOUT = -1