Merge branch 'integration/new-container-runtime' of github.com:Start9Labs/start-os into integration/new-container-runtime

This commit is contained in:
Aiden McClelland
2024-03-18 15:15:55 -06:00
111 changed files with 2332 additions and 2042 deletions

View File

@@ -4,6 +4,8 @@ import { List } from "../config/builder/list"
import { Value } from "../config/builder/value"
import { Variants } from "../config/builder/variants"
import { ValueSpec } from "../config/configTypes"
import { setupManifest } from "../manifest/setupManifest"
import { StartSdk } from "../StartSdk"
describe("builder tests", () => {
test("text", async () => {
@@ -379,17 +381,61 @@ describe("values", () => {
})
})
test("datetime", async () => {
const value = Value.dynamicDatetime<{ test: "a" }>(async ({ utils }) => {
;async () => {
;(await utils.store.getOwn("/test").once()) satisfies "a"
}
const sdk = StartSdk.of()
.withManifest(
setupManifest({
id: "testOutput",
title: "",
version: "1.0",
releaseNotes: "",
license: "",
replaces: [],
wrapperRepo: "",
upstreamRepo: "",
supportSite: "",
marketingSite: "",
donationUrl: null,
description: {
short: "",
long: "",
},
containers: {},
images: [],
volumes: [],
assets: [],
alerts: {
install: null,
update: null,
uninstall: null,
restore: null,
start: null,
stop: null,
},
dependencies: {
remoteTest: {
description: "",
requirement: { how: "", type: "opt-in" },
version: "1.0",
},
},
}),
)
.withStore<{ test: "a" }>()
.build(true)
return {
name: "Testing",
required: { default: null },
inputmode: "date",
}
})
const value = Value.dynamicDatetime<{ test: "a" }>(
async ({ effects }) => {
;async () => {
;(await sdk.store.getOwn(effects, "/test").once()) satisfies "a"
}
return {
name: "Testing",
required: { default: null },
inputmode: "date",
}
},
)
const validator = value.validator
validator.unsafeCast("2021-01-01")
validator.unsafeCast(null)

View File

@@ -1,15 +1,13 @@
import { ServiceInterfaceBuilder } from "../interfaces/ServiceInterfaceBuilder"
import { Effects } from "../types"
import { createUtils } from "../util"
import { sdk } from "./output.sdk"
describe("host", () => {
test("Testing that the types work", () => {
async function test(effects: Effects) {
const utils = createUtils<never, never>(effects)
const foo = utils.host.multi("foo")
const foo = sdk.host.multi(effects, "foo")
const fooOrigin = await foo.bindPort(80, {
protocol: "http" as const,
scheme: null,
})
const fooInterface = new ServiceInterfaceBuilder({
effects,

View File

@@ -13,40 +13,25 @@ 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"
import { GetSystemSmtpParams } from "../../../core/startos/bindings/GetSystemSmtpParams"
import { GetServicePortForwardParams } from "../../../core/startos/bindings/GetServicePortForwardParams"
import { ExportServiceInterfaceParams } from "../../../core/startos/bindings/ExportServiceInterfaceParams"
import { GetPrimaryUrlParams } from "../../../core/startos/bindings/GetPrimaryUrlParams"
import { ListServiceInterfacesParams } from "../../../core/startos/bindings/ListServiceInterfacesParams"
import { RemoveAddressParams } from "../../../core/startos/bindings/RemoveAddressParams"
import { ExportActionParams } from "../../../core/startos/bindings/ExportActionParams"
import { RemoveActionParams } from "../../../core/startos/bindings/RemoveActionParams"
import { ReverseProxyParams } from "../../../core/startos/bindings/ReverseProxyParams"
import { MountParams } from "../../../core/startos/bindings/MountParams"
function typeEquality<ExpectedType>(_a: ExpectedType) {}
describe("startosTypeValidation ", () => {
test(`checking the params match`, () => {
const testInput: any = {}
typeEquality<{
[K in keyof Effects &
(
| "gitInfo"
| "echo"
| "chroot"
| "exists"
| "executeAction"
| "getConfigured"
| "stopped"
| "running"
| "restart"
| "shutdown"
| "setConfigured"
| "setMainStatus"
| "setHealth"
| "getStore"
| "setStore"
| "exposeForDependents"
| "exposeUi"
| "createOverlayedImage"
| "destroyOverlayedImage"
| "getSslCertificate"
| "getSslKey"
| "getServiceInterface"
| "clearBindings"
| "bind"
| "getHostInfo"
)]: Effects[K] extends Function ? Parameters<Effects[K]>[0] : never
[K in keyof Effects]: Effects[K] extends (args: infer A) => any
? A
: never
}>({
executeAction: {} as ExecuteAction,
createOverlayedImage: {} as CreateOverlayedImageParams,
@@ -57,7 +42,7 @@ describe("startosTypeValidation ", () => {
exists: {} as ParamsPackageId,
getConfigured: undefined,
stopped: {} as ParamsMaybePackageId,
running: {} as ParamsMaybePackageId,
running: {} as ParamsPackageId,
restart: undefined,
shutdown: undefined,
setConfigured: {} as SetConfigured,
@@ -67,6 +52,20 @@ describe("startosTypeValidation ", () => {
getSslCertificate: {} as GetSslCertificateParams,
getSslKey: {} as GetSslKeyParams,
getServiceInterface: {} as GetServiceInterfaceParams,
setDependencies: {} as SetDependenciesParams,
store: {} as never,
getSystemSmtp: {} as GetSystemSmtpParams,
getContainerIp: undefined,
getServicePortForward: {} as GetServicePortForwardParams,
clearServiceInterfaces: undefined,
exportServiceInterface: {} as ExportServiceInterfaceParams,
getPrimaryUrl: {} as GetPrimaryUrlParams,
listServiceInterfaces: {} as ListServiceInterfacesParams,
removeAddress: {} as RemoveAddressParams,
exportAction: {} as ExportActionParams,
removeAction: {} as RemoveActionParams,
reverseProxy: {} as ReverseProxyParams,
mount: {} as MountParams,
})
typeEquality<Parameters<Effects["executeAction"]>[0]>(
testInput as ExecuteAction,

View File

@@ -1,6 +1,5 @@
import { MainEffects, StartSdk } from "../StartSdk"
import { Effects } from "../types"
import { createMainUtils } from "../util"
import { createUtils } from "../util/utils"
type Store = {
config: {
@@ -12,26 +11,31 @@ const todo = <A>(): A => {
throw new Error("not implemented")
}
const noop = () => {}
const sdk = StartSdk.of()
.withManifest({} as Manifest)
.withStore<Store>()
.build(true)
describe("Store", () => {
test("types", async () => {
;async () => {
createUtils<Manifest, Store>(todo<Effects>()).store.setOwn("/config", {
sdk.store.setOwn(todo<Effects>(), "/config", {
someValue: "a",
})
createUtils<Manifest, Store>(todo<Effects>()).store.setOwn(
"/config/someValue",
"b",
)
createUtils<Manifest, Store>(todo<Effects>()).store.setOwn("", {
sdk.store.setOwn(todo<Effects>(), "/config/someValue", "b")
sdk.store.setOwn(todo<Effects>(), "", {
config: { someValue: "b" },
})
createUtils<Manifest, Store>(todo<Effects>()).store.setOwn(
sdk.store.setOwn(
todo<Effects>(),
"/config/someValue",
// @ts-expect-error Type is wrong for the setting value
5,
)
createUtils(todo<Effects>()).store.setOwn(
sdk.store.setOwn(
todo<Effects>(),
// @ts-expect-error Path is wrong
"/config/someVae3lue",
"someValue",
@@ -52,49 +56,47 @@ describe("Store", () => {
path: "/config/some2Value",
value: "a",
})
;(await createMainUtils<Manifest, Store>(todo<Effects>())
.store.getOwn("/config/someValue")
;(await sdk.store
.getOwn(todo<MainEffects>(), "/config/someValue")
.const()) satisfies string
;(await createMainUtils<Manifest, Store>(todo<Effects>())
.store.getOwn("/config")
;(await sdk.store
.getOwn(todo<MainEffects>(), "/config")
.const()) satisfies Store["config"]
await createMainUtils(todo<Effects>())
// @ts-expect-error Path is wrong
.store.getOwn("/config/somdsfeValue")
await sdk.store // @ts-expect-error Path is wrong
.getOwn(todo<MainEffects>(), "/config/somdsfeValue")
.const()
/// ----------------- ERRORS -----------------
createUtils<Manifest, Store>(todo<Effects>()).store.setOwn("", {
sdk.store.setOwn(todo<MainEffects>(), "", {
// @ts-expect-error Type is wrong for the setting value
config: { someValue: "notInAOrB" },
})
createUtils<Manifest, Store>(todo<Effects>()).store.setOwn(
sdk.store.setOwn(
todo<MainEffects>(),
"/config/someValue",
// @ts-expect-error Type is wrong for the setting value
"notInAOrB",
)
;(await createUtils<Manifest, Store>(todo<Effects>())
.store.getOwn("/config/someValue")
;(await sdk.store
.getOwn(todo<Effects>(), "/config/someValue")
// @ts-expect-error Const should normally not be callable
.const()) satisfies string
;(await createUtils<Manifest, Store>(todo<Effects>())
.store.getOwn("/config")
;(await sdk.store
.getOwn(todo<Effects>(), "/config")
// @ts-expect-error Const should normally not be callable
.const()) satisfies Store["config"]
await createUtils<Manifest, Store>(todo<Effects>())
// @ts-expect-error Path is wrong
.store.getOwn("/config/somdsfeValue")
await sdk.store // @ts-expect-error Path is wrong
.getOwn("/config/somdsfeValue")
// @ts-expect-error Const should normally not be callable
.const()
///
;(await createUtils<Manifest, Store>(todo<Effects>())
.store.getOwn("/config/someValue")
;(await sdk.store
.getOwn(todo<MainEffects>(), "/config/someValue")
// @ts-expect-error satisfies type is wrong
.const()) satisfies number
;(await createMainUtils(todo<Effects>())
// @ts-expect-error Path is wrong
.store.getOwn("/config/")
;(await sdk.store // @ts-expect-error Path is wrong
.getOwn(todo<MainEffects>(), "/config/")
.const()) satisfies Store["config"]
;(await todo<Effects>().store.get<Store, "/config/someValue">({
path: "/config/someValue",