mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 12:11:56 +00:00
sdk tweaks (#2760)
* sdk tweaks * update action result types * accommodate new action response types * fix: show action value labels * Feature/get status effect (#2765) * wip: get status * feat: Add the get_status for effects * feat: Do a callback --------- Co-authored-by: J H <dragondef@gmail.com> --------- Co-authored-by: Matt Hill <mattnine@protonmail.com> Co-authored-by: waterplea <alexander@inkin.ru> Co-authored-by: J H <dragondef@gmail.com>
This commit is contained in:
@@ -134,6 +134,7 @@ export class StartSdk<Manifest extends T.SDKManifest, Store> {
|
||||
getDataVersion: (effects, ...args) => effects.getDataVersion(...args),
|
||||
shutdown: (effects, ...args) => effects.shutdown(...args),
|
||||
getDependencies: (effects, ...args) => effects.getDependencies(...args),
|
||||
getStatus: (effects, ...args) => effects.getStatus(...args),
|
||||
}
|
||||
|
||||
return {
|
||||
@@ -387,8 +388,8 @@ export class StartSdk<Manifest extends T.SDKManifest, Store> {
|
||||
algorithm?: T.Algorithm,
|
||||
) => new GetSslCertificate(effects, hostnames, algorithm),
|
||||
HealthCheck: {
|
||||
of(o: HealthCheckParams) {
|
||||
return healthCheck(o)
|
||||
of(effects: T.Effects, o: Omit<HealthCheckParams, "effects">) {
|
||||
return healthCheck({ effects, ...o })
|
||||
},
|
||||
},
|
||||
healthCheck: {
|
||||
@@ -636,12 +637,12 @@ export class StartSdk<Manifest extends T.SDKManifest, Store> {
|
||||
) => InputSpec.of<Spec, Store>(spec),
|
||||
},
|
||||
Daemons: {
|
||||
of(options: {
|
||||
effects: Effects
|
||||
started: (onTerm: () => PromiseLike<void>) => PromiseLike<null>
|
||||
healthReceipts: HealthReceipt[]
|
||||
}) {
|
||||
return Daemons.of<Manifest>(options)
|
||||
of(
|
||||
effects: Effects,
|
||||
started: (onTerm: () => PromiseLike<void>) => PromiseLike<null>,
|
||||
healthReceipts: HealthReceipt[],
|
||||
) {
|
||||
return Daemons.of<Manifest>({ effects, started, healthReceipts })
|
||||
},
|
||||
},
|
||||
List: {
|
||||
|
||||
@@ -15,18 +15,14 @@ import { VersionGraph } from "../version/VersionGraph"
|
||||
*/
|
||||
export function setupManifest<
|
||||
Id extends string,
|
||||
Dependencies extends Record<string, unknown>,
|
||||
VolumesTypes extends VolumeId,
|
||||
AssetTypes extends VolumeId,
|
||||
ImagesTypes extends ImageId,
|
||||
Manifest extends {
|
||||
dependencies: Dependencies
|
||||
id: Id
|
||||
assets: AssetTypes[]
|
||||
images: Record<ImagesTypes, SDKImageInputSpec>
|
||||
volumes: VolumesTypes[]
|
||||
},
|
||||
>(manifest: SDKManifest & Manifest): SDKManifest & Manifest {
|
||||
} & SDKManifest,
|
||||
>(manifest: Manifest): Manifest {
|
||||
return manifest
|
||||
}
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ export class FileHelper<A> {
|
||||
/**
|
||||
* Accepts structured data and overwrites the existing file on disk.
|
||||
*/
|
||||
async write(data: A): Promise<null> {
|
||||
private async writeFile(data: A): Promise<null> {
|
||||
const parent = previousPath.exec(this.path)
|
||||
if (parent) {
|
||||
await fs.mkdir(parent[1], { recursive: true })
|
||||
@@ -153,13 +153,27 @@ export class FileHelper<A> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Accepts structured data and performs a merge with the existing file on disk.
|
||||
* Accepts full structured data and performs a merge with the existing file on disk if it exists.
|
||||
*/
|
||||
async merge(data: A) {
|
||||
const fileData = (await this.readOnce().catch(() => ({}))) || {}
|
||||
async write(data: A) {
|
||||
const fileData = (await this.readOnce()) || {}
|
||||
const mergeData = merge({}, fileData, data)
|
||||
return await this.write(mergeData)
|
||||
return await this.writeFile(mergeData)
|
||||
}
|
||||
|
||||
/**
|
||||
* Accepts partial structured data and performs a merge with the existing file on disk.
|
||||
*/
|
||||
async merge(data: Partial<A>) {
|
||||
const fileData =
|
||||
(await this.readOnce()) ||
|
||||
(() => {
|
||||
throw new Error(`${this.path}: does not exist`)
|
||||
})()
|
||||
const mergeData = merge({}, fileData, data)
|
||||
return await this.writeFile(mergeData)
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a File Helper for an arbitrary file type.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user