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 */
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: {
serviceId?: string
input: Input
}): Promise<unknown>
/** Sandbox mode lets us read but not write */
is_sandboxed(): boolean
/** Check that a file exists or not */
exists(input: { volumeId: string; path: string }): Promise<boolean>
is_sandboxed(): Promise<boolean>
/** Removes all network bindings */
clearBindings(): Promise<void>
@@ -273,44 +251,22 @@ export type Effects = {
callback: () => void
}): 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.
*/
fetch(
url: string,
options?: {
method?: "GET" | "POST" | "PUT" | "DELETE" | "HEAD" | "PATCH"
headers?: Record<string, string>
body?: string
},
): Promise<{
method: string
ok: boolean
status: number
headers: Record<string, string>
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>
}
// /**
// * 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: {
/** Get a value in a json like data, can be observed and subscribed */
@@ -425,11 +381,14 @@ export type Effects = {
getSslCertificate: (
packageId: string,
algorithm?: "ecdsa" | "ed25519",
) => [string, string, string]
) => Promise<[string, string, string]>
/**
* @returns PEM encoded ssl key (ecdsa)
*/
getSslKey: (packageId: string, algorithm?: "ecdsa" | "ed25519") => string
getSslKey: (
packageId: string,
algorithm?: "ecdsa" | "ed25519",
) => Promise<string>
setHealth(o: {
name: string

View File

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