Merge pull request #12 from Start9Labs/chore/side_fixes

Chore/side fixes
This commit is contained in:
J H
2023-06-08 13:14:51 -06:00
committed by GitHub
2 changed files with 23 additions and 64 deletions

View File

@@ -219,35 +219,13 @@ export type ExposeUiPaths<Store> = Array<{
}> }>
/** Used to reach out from the pure js runtime */ /** Used to reach out from the pure js runtime */
export type Effects = { export type Effects = {
runCommand<A extends string>(
command: ValidIfNoStupidEscape<A> | [string, ...string[]],
options?: {
timeoutMillis?: number
env?: Record<string, string>
},
): Promise<string>
runDaemon<A extends string>(
command: ValidIfNoStupidEscape<A> | [string, ...string[]],
options?: {
env?: Record<string, string>
},
): DaemonReturned
/** Uses the chown on the system */
chown(input: { volumeId: string; path: string; uid: string }): Promise<null>
/** Uses the chmod on the system */
chmod(input: { volumeId: string; path: string; mode: string }): Promise<null>
executeAction<Input>(opts: { executeAction<Input>(opts: {
serviceId?: string serviceId?: string
input: Input input: Input
}): Promise<unknown> }): Promise<unknown>
/** Sandbox mode lets us read but not write */ /** Sandbox mode lets us read but not write */
is_sandboxed(): boolean is_sandboxed(): Promise<boolean>
/** Check that a file exists or not */
exists(input: { volumeId: string; path: string }): Promise<boolean>
/** Removes all network bindings */ /** Removes all network bindings */
clearBindings(): Promise<void> clearBindings(): Promise<void>
@@ -273,44 +251,22 @@ export type Effects = {
callback: () => void callback: () => void
}): Promise<[HostName, ...HostName[]]> }): Promise<[HostName, ...HostName[]]>
/** Similar to the fetch api via the mdn, this is simplified but the point is // /**
* to get something from some website, and return the response. // * Run rsync between two volumes. This is used to backup data between volumes.
*/ // * This is a long running process, and a structure that we can either wait for, or get the progress of.
fetch( // */
url: string, // runRsync(options: {
options?: { // srcVolume: string
method?: "GET" | "POST" | "PUT" | "DELETE" | "HEAD" | "PATCH" // dstVolume: string
headers?: Record<string, string> // srcPath: string
body?: string // dstPath: string
}, // // rsync options: https://linux.die.net/man/1/rsync
): Promise<{ // options: BackupOptions
method: string // }): {
ok: boolean // id: () => Promise<string>
status: number // wait: () => Promise<null>
headers: Record<string, string> // progress: () => Promise<number>
body?: string | null // }
/// Returns the body as a string
text(): Promise<string>
/// Returns the body as a json
json(): Promise<unknown>
}>
/**
* Run rsync between two volumes. This is used to backup data between volumes.
* This is a long running process, and a structure that we can either wait for, or get the progress of.
*/
runRsync(options: {
srcVolume: string
dstVolume: string
srcPath: string
dstPath: string
// rsync options: https://linux.die.net/man/1/rsync
options: BackupOptions
}): {
id: () => Promise<string>
wait: () => Promise<null>
progress: () => Promise<number>
}
store: { store: {
/** Get a value in a json like data, can be observed and subscribed */ /** Get a value in a json like data, can be observed and subscribed */
@@ -425,11 +381,14 @@ export type Effects = {
getSslCertificate: ( getSslCertificate: (
packageId: string, packageId: string,
algorithm?: "ecdsa" | "ed25519", algorithm?: "ecdsa" | "ed25519",
) => [string, string, string] ) => Promise<[string, string, string]>
/** /**
* @returns PEM encoded ssl key (ecdsa) * @returns PEM encoded ssl key (ecdsa)
*/ */
getSslKey: (packageId: string, algorithm?: "ecdsa" | "ed25519") => string getSslKey: (
packageId: string,
algorithm?: "ecdsa" | "ed25519",
) => Promise<string>
setHealth(o: { setHealth(o: {
name: string name: string

View File

@@ -118,7 +118,7 @@ export class FileHelper<A> {
return new FileHelper<A>( return new FileHelper<A>(
path, path,
(inData) => { (inData) => {
return JSON.stringify(inData, null, 2) return TOML.stringify(inData as any)
}, },
(inString) => { (inString) => {
return shape.unsafeCast(TOML.parse(inString)) return shape.unsafeCast(TOML.parse(inString))