reorganize package data and write dependencies rpc (#2571)

* wip

* finish dependencies

* minor fixes
This commit is contained in:
Aiden McClelland
2024-03-15 13:02:47 -06:00
committed by GitHub
parent e604c914d1
commit 1a396cfc7b
30 changed files with 1045 additions and 897 deletions

View File

@@ -3,7 +3,7 @@ import { Dependency } from "../types"
export type ConfigDependencies<T extends SDKManifest> = {
exists(id: keyof T["dependencies"]): Dependency
running(id: keyof T["dependencies"]): Dependency
running(id: keyof T["dependencies"], healthChecks: string[]): Dependency
}
export const configDependenciesSet = <
@@ -16,10 +16,11 @@ export const configDependenciesSet = <
} as Dependency
},
running(id: keyof T["dependencies"]) {
running(id: keyof T["dependencies"], healthChecks: string[]) {
return {
id,
kind: "running",
healthChecks,
} as Dependency
},
})

View File

@@ -13,6 +13,7 @@ import { ExposeUiParams } from "../../../core/startos/bindings/ExposeUiParams"
import { GetSslCertificateParams } from "../../../core/startos/bindings/GetSslCertificateParams"
import { GetSslKeyParams } from "../../../core/startos/bindings/GetSslKeyParams"
import { GetServiceInterfaceParams } from "../../../core/startos/bindings/GetServiceInterfaceParams"
import { SetDependenciesParams } from "../../../core/startos/bindings/SetDependenciesParams"
function typeEquality<ExpectedType>(_a: ExpectedType) {}
describe("startosTypeValidation ", () => {
@@ -46,6 +47,7 @@ describe("startosTypeValidation ", () => {
| "clearBindings"
| "bind"
| "getHostInfo"
| "setDependencies"
)]: Effects[K] extends Function ? Parameters<Effects[K]>[0] : never
}>({
executeAction: {} as ExecuteAction,
@@ -67,6 +69,7 @@ describe("startosTypeValidation ", () => {
getSslCertificate: {} as GetSslCertificateParams,
getSslKey: {} as GetSslKeyParams,
getServiceInterface: {} as GetServiceInterfaceParams,
setDependencies: {} as SetDependenciesParams,
})
typeEquality<Parameters<Effects["executeAction"]>[0]>(
testInput as ExecuteAction,

View File

@@ -286,10 +286,7 @@ export type Effects = {
createOverlayedImage(options: { imageId: string }): Promise<[string, string]>
/** A low level api used by destroyOverlay + makeOverlay:destroy */
destroyOverlayedImage(options: {
imageId: string
guid: string
}): Promise<void>
destroyOverlayedImage(options: { guid: string }): Promise<void>
/** Removes all network bindings */
clearBindings(): Promise<void>
@@ -467,7 +464,9 @@ export type Effects = {
}): Promise<void>
/** Set the dependencies of what the service needs, usually ran during the set config as a best practice */
setDependencies(dependencies: Dependencies): Promise<DependenciesReceipt>
setDependencies(options: {
dependencies: Dependencies
}): Promise<DependenciesReceipt>
/** Exists could be useful during the runtime to know if some service exists, option dep */
exists(options: { packageId: PackageId }): Promise<boolean>
/** Exists could be useful during the runtime to know if some service is running, option dep */
@@ -585,7 +584,7 @@ export type KnownError =
export type Dependency = {
id: PackageId
kind: DependencyKind
}
} & ({ kind: "exists" } | { kind: "running"; healthChecks: string[] })
export type Dependencies = Array<Dependency>
export type DeepPartial<T> = T extends {}