misc sdk changes (#2934)

* misc sdk changes

* delete the store ☠️

* port comments

* fix build

* fix removing

* fix tests

* beta.20

---------

Co-authored-by: Matt Hill <mattnine@protonmail.com>
This commit is contained in:
Aiden McClelland
2025-05-09 15:10:51 -06:00
committed by GitHub
parent d2c4741f0b
commit 7750e33f82
62 changed files with 1255 additions and 2130 deletions

View File

@@ -56,6 +56,8 @@ type NewDaemonParams<Manifest extends T.SDKManifest> = {
subcontainer: SubContainer<Manifest>
runAsInit?: boolean
env?: Record<string, string>
cwd?: string
user?: string
sigtermTimeout?: number
onStdout?: (chunk: Buffer | string | any) => void
onStderr?: (chunk: Buffer | string | any) => void

View File

@@ -8,8 +8,12 @@ type SharedOptions = {
subpath: string | null
/** Where to mount the resource. e.g. /data */
mountpoint: string
/** Whether to mount this as a file or directory */
type?: "file" | "directory"
/**
* Whether to mount this as a file or directory
*
* defaults to "directory"
* */
type?: "file" | "directory" | "infer"
}
type VolumeOpts<Manifest extends T.SDKManifest> = {
@@ -43,7 +47,7 @@ export class Mounts<
return new Mounts<Manifest>([], [], [], [])
}
addVolume(options: VolumeOpts<Manifest>) {
mountVolume(options: VolumeOpts<Manifest>) {
return new Mounts<Manifest, Backups>(
[...this.volumes, options],
[...this.assets],
@@ -52,7 +56,7 @@ export class Mounts<
)
}
addAssets(options: SharedOptions) {
mountAssets(options: SharedOptions) {
return new Mounts<Manifest, Backups>(
[...this.volumes],
[...this.assets, options],
@@ -61,7 +65,7 @@ export class Mounts<
)
}
addDependency<DependencyManifest extends T.SDKManifest>(
mountDependency<DependencyManifest extends T.SDKManifest>(
options: DependencyOpts<DependencyManifest>,
) {
return new Mounts<Manifest, Backups>(
@@ -72,7 +76,7 @@ export class Mounts<
)
}
addBackups(options: SharedOptions) {
mountBackups(options: SharedOptions) {
return new Mounts<
Manifest,
{
@@ -109,7 +113,7 @@ export class Mounts<
volumeId: v.volumeId,
subpath: v.subpath,
readonly: v.readonly,
filetype: v.type,
filetype: v.type ?? "directory",
},
})),
)
@@ -119,7 +123,7 @@ export class Mounts<
options: {
type: "assets",
subpath: a.subpath,
filetype: a.type,
filetype: a.type ?? "directory",
},
})),
)
@@ -132,13 +136,13 @@ export class Mounts<
volumeId: d.volumeId,
subpath: d.subpath,
readonly: d.readonly,
filetype: d.type,
filetype: d.type ?? "directory",
},
})),
)
}
}
const a = Mounts.of().addBackups({ subpath: null, mountpoint: "" })
const a = Mounts.of().mountBackups({ subpath: null, mountpoint: "" })
// @ts-expect-error
const m: Mounts<T.SDKManifest, never> = a

View File

@@ -14,7 +14,7 @@ export const DEFAULT_SIGTERM_TIMEOUT = 30_000
* @param fn
* @returns
*/
export const setupMain = <Manifest extends T.SDKManifest, Store>(
export const setupMain = <Manifest extends T.SDKManifest>(
fn: (o: {
effects: T.Effects
started(onTerm: () => PromiseLike<void>): PromiseLike<null>