mirror of
https://github.com/Start9Labs/start-sdk.git
synced 2026-03-26 02:11:56 +00:00
fix the types
This commit is contained in:
@@ -42,12 +42,12 @@ export class Backups<M extends SDKManifest> {
|
||||
|
||||
private constructor(
|
||||
private options = DEFAULT_OPTIONS,
|
||||
private backupSet = [] as BackupSet<keyof M["volumes"] & string>[],
|
||||
private backupSet = [] as BackupSet<M["volumes"][0]>[],
|
||||
) {}
|
||||
static volumes<M extends SDKManifest = never>(
|
||||
...volumeNames: Array<keyof M["volumes"] & string>
|
||||
) {
|
||||
return new Backups().addSets(
|
||||
...volumeNames: Array<M["volumes"][0]>
|
||||
): Backups<M> {
|
||||
return new Backups<M>().addSets(
|
||||
...volumeNames.map((srcVolume) => ({
|
||||
srcVolume,
|
||||
srcPath: "./",
|
||||
@@ -57,7 +57,7 @@ export class Backups<M extends SDKManifest> {
|
||||
)
|
||||
}
|
||||
static addSets<M extends SDKManifest = never>(
|
||||
...options: BackupSet<keyof M["volumes"] & string>[]
|
||||
...options: BackupSet<M["volumes"][0]>[]
|
||||
) {
|
||||
return new Backups().addSets(...options)
|
||||
}
|
||||
@@ -75,7 +75,7 @@ export class Backups<M extends SDKManifest> {
|
||||
}
|
||||
return this
|
||||
}
|
||||
volumes(...volumeNames: Array<keyof M["volumes"] & string>) {
|
||||
volumes(...volumeNames: Array<M["volumes"][0]>) {
|
||||
return this.addSets(
|
||||
...volumeNames.map((srcVolume) => ({
|
||||
srcVolume,
|
||||
@@ -85,7 +85,7 @@ export class Backups<M extends SDKManifest> {
|
||||
})),
|
||||
)
|
||||
}
|
||||
addSets(...options: BackupSet<keyof M["volumes"] & string>[]) {
|
||||
addSets(...options: BackupSet<M["volumes"][0]>[]) {
|
||||
options.forEach((x) =>
|
||||
this.backupSet.push({ ...x, options: { ...this.options, ...x.options } }),
|
||||
)
|
||||
|
||||
@@ -4,14 +4,14 @@ import { ExpectedExports } from "../types"
|
||||
import { _ } from "../util"
|
||||
|
||||
export type SetupBackupsParams<M extends SDKManifest> = Array<
|
||||
(keyof M["volumes"] & string) | Backups<M>
|
||||
M["volumes"][0] | Backups<M>
|
||||
>
|
||||
|
||||
export function setupBackups<M extends SDKManifest>(
|
||||
...args: _<SetupBackupsParams<M>>
|
||||
) {
|
||||
const backups = Array<Backups<M>>()
|
||||
const volumes = new Set<keyof M["volumes"] & string>()
|
||||
const volumes = new Set<M["volumes"][0]>()
|
||||
for (const arg of args) {
|
||||
if (arg instanceof Backups) {
|
||||
backups.push(arg)
|
||||
|
||||
@@ -35,7 +35,7 @@ class SetupDependencyMounts<Building> {
|
||||
|
||||
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,
|
||||
|
||||
@@ -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<Ids extends string, Command extends string, Id extends string> = {
|
||||
id: "" extends Id ? never : Id
|
||||
command: ValidIfNoStupidEscape<Command> | [string, ...string[]]
|
||||
@@ -128,7 +129,7 @@ export class Daemons<Ids extends string> {
|
||||
})
|
||||
}
|
||||
return {
|
||||
async term(options?: { signal?: string; timeout?: number }) {
|
||||
async term(options?: { signal?: Signals; timeout?: number }) {
|
||||
await Promise.all(
|
||||
Object.values<Promise<DaemonReturned>>(daemonsStarted).map((x) =>
|
||||
x.then((x) => x.term(options)),
|
||||
|
||||
@@ -4,12 +4,16 @@ export function setupManifest<
|
||||
Id extends string,
|
||||
Version extends ManifestVersion,
|
||||
Dependencies extends Record<string, unknown>,
|
||||
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
|
||||
|
||||
@@ -35,6 +35,7 @@ describe("mountDependencies", () => {
|
||||
},
|
||||
dependencies: {},
|
||||
})
|
||||
const clnManifestVolumes = clnManifest.volumes
|
||||
const lndManifest = setupManifest({
|
||||
id: "lnd",
|
||||
title: "",
|
||||
|
||||
39
lib/types.ts
39
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<A extends string> =
|
||||
|
||||
export type DaemonReturned = {
|
||||
wait(): Promise<string>
|
||||
term(): Promise<void>
|
||||
term(options?: { signal?: Signals; timeout?: number }): Promise<void>
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user