Merge branch 'next/minor' of github.com:Start9Labs/start-os into rebase/feat/domains

This commit is contained in:
Matt Hill
2024-03-30 21:14:53 -06:00
191 changed files with 1789 additions and 1316 deletions

View File

@@ -6,13 +6,13 @@ export class Dependency {
| {
type: "running"
versionSpec: Checker
url: string
registryUrl: string
healthChecks: string[]
}
| {
type: "exists"
versionSpec: Checker
url: string
registryUrl: string
},
) {}
}

View File

@@ -179,7 +179,6 @@ export class Checker {
* @returns
*/
static parse(range: string | Checker): Checker {
console.log(`Parser (${range})`)
if (range instanceof Checker) {
return range
}

View File

@@ -40,19 +40,21 @@ export function healthCheck(o: {
const { status, message } = await o.fn(overlay)
await o.effects.setHealth({
name: o.name,
status,
message,
id: o.name,
result: status,
message: message || "",
})
currentValue.hadSuccess = true
currentValue.lastResult = "passing"
currentValue.lastResult = "success"
await triggerFirstSuccess().catch((err) => {
console.error(err)
})
} catch (e) {
await o.effects.setHealth({
name: o.name,
status: "failure",
message: asMessage(e),
id: o.name,
result: "failure",
message: asMessage(e) || "",
})
currentValue.lastResult = "failure"
}

View File

@@ -45,7 +45,7 @@ export async function checkPortListening(
port,
)
if (hasAddress) {
return { status: "passing", message: options.successMessage }
return { status: "success", message: options.successMessage }
}
return {
status: "failure",

View File

@@ -22,7 +22,7 @@ export const checkWebUrl = async (
.then(
(x) =>
({
status: "passing",
status: "success",
message: successMessage,
}) as const,
)

View File

@@ -32,7 +32,7 @@ export const runHealthScript = async (
throw { status: "failure", message: errorMessage } as CheckResult
})
return {
status: "passing",
status: "success",
message: message(res.stdout.toString()),
} as CheckResult
}

View File

@@ -1,71 +1,58 @@
import { object, string } from "ts-matches"
import { Effects } from "../types"
import { Origin } from "./Origin"
import { AddSslOptions } from "../../../core/startos/bindings/AddSslOptions"
import { Security } from "../../../core/startos/bindings/Security"
import { BindOptions } from "../../../core/startos/bindings/BindOptions"
import { AlpnInfo } from "../../../core/startos/bindings/AlpnInfo"
export { AddSslOptions, Security, BindOptions }
const knownProtocols = {
http: {
secure: false,
ssl: false,
secure: null,
defaultPort: 80,
withSsl: "https",
alpn: { specified: ["http/1.1"] } as AlpnInfo,
},
https: {
secure: true,
ssl: true,
secure: { ssl: true },
defaultPort: 443,
},
ws: {
secure: false,
ssl: false,
secure: null,
defaultPort: 80,
withSsl: "wss",
alpn: { specified: ["http/1.1"] } as AlpnInfo,
},
wss: {
secure: true,
ssl: true,
secure: { ssl: true },
defaultPort: 443,
},
ssh: {
secure: true,
ssl: false,
secure: { ssl: false },
defaultPort: 22,
},
bitcoin: {
secure: true,
ssl: false,
secure: { ssl: false },
defaultPort: 8333,
},
lightning: {
secure: true,
ssl: true,
secure: { ssl: true },
defaultPort: 9735,
},
grpc: {
secure: true,
ssl: true,
secure: { ssl: true },
defaultPort: 50051,
},
dns: {
secure: true,
ssl: false,
secure: { ssl: false },
defaultPort: 53,
},
} as const
export type Scheme = string | null
type AddSslOptions = {
scheme: Scheme
preferredExternalPort: number
addXForwardedHeaders: boolean | null /** default: false */
}
type Security = { ssl: boolean }
export type BindOptions = {
scheme: Scheme
preferredExternalPort: number
addSsl: AddSslOptions | null
secure: Security | null
}
type KnownProtocols = typeof knownProtocols
type ProtocolsWithSslVariants = {
[K in keyof KnownProtocols]: KnownProtocols[K] extends {
@@ -177,9 +164,10 @@ export class Host {
if ("noAddSsl" in options && options.noAddSsl) return null
if ("withSsl" in protoInfo && protoInfo.withSsl)
return {
addXForwardedHeaders: null,
// addXForwardedHeaders: null,
preferredExternalPort: knownProtocols[protoInfo.withSsl].defaultPort,
scheme: protoInfo.withSsl,
alpn: protoInfo.alpn,
...("addSsl" in options ? options.addSsl : null),
}
return null

View File

@@ -227,7 +227,7 @@ export class Daemons<Manifest extends SDKManifest, Ids extends string> {
}) as CheckResult,
)
currentInput.lastResult = response.status || null
if (!currentInput.hadSuccess && response.status === "passing") {
if (!currentInput.hadSuccess && response.status === "success") {
currentInput.hadSuccess = true
resolve(child)
}

View File

@@ -9,7 +9,6 @@ import { ParamsMaybePackageId } from "../../../core/startos/bindings/ParamsMaybe
import { SetConfigured } from "../../../core/startos/bindings/SetConfigured"
import { SetHealth } from "../../../core/startos/bindings/SetHealth"
import { ExposeForDependentsParams } from "../../../core/startos/bindings/ExposeForDependentsParams"
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"
@@ -24,7 +23,6 @@ import { ExportActionParams } from "../../../core/startos/bindings/ExportActionP
import { RemoveActionParams } from "../../../core/startos/bindings/RemoveActionParams"
import { ReverseProxyParams } from "../../../core/startos/bindings/ReverseProxyParams"
import { MountParams } from "../../../core/startos/bindings/MountParams"
import { ExposedUI } from "../../../core/startos/bindings/ExposedUI"
function typeEquality<ExpectedType>(_a: ExpectedType) {}
describe("startosTypeValidation ", () => {
test(`checking the params match`, () => {

View File

@@ -11,7 +11,7 @@ export function changeOnFirstSuccess(o: {
beforeFirstSuccess.next()
for (
let res = await beforeFirstSuccess.next();
currentValue?.lastResult !== "passing" && !res.done;
currentValue?.lastResult !== "success" && !res.done;
res = await beforeFirstSuccess.next()
) {
yield

View File

@@ -12,7 +12,7 @@ export function successFailure(o: {
beforeSuccess.next()
for (
let res = await beforeSuccess.next();
currentValue?.lastResult !== "passing" && !res.done;
currentValue?.lastResult !== "success" && !res.done;
res = await beforeSuccess.next()
) {
yield
@@ -21,7 +21,7 @@ export function successFailure(o: {
const duringError = o.duringError(getInput)
for (
let res = await duringError.next();
currentValue?.lastResult === "passing" && !res.done;
currentValue?.lastResult === "success" && !res.done;
res = await duringError.next()
) {
yield

View File

@@ -1,5 +1,6 @@
export * as configTypes from "./config/configTypes"
import { AddSslOptions } from "../../core/startos/bindings/AddSslOptions"
import { HealthCheckId } from "../../core/startos/bindings/HealthCheckId"
import { HealthCheckResult } from "../../core/startos/bindings/HealthCheckResult"
import { MainEffects, ServiceInterfaceType, Signals } from "./StartSdk"
import { InputSpec } from "./config/configTypes"
import { DependenciesReceipt } from "./config/setupConfig"
@@ -142,13 +143,7 @@ export type Daemon = {
[DaemonProof]: never
}
export type HealthStatus =
| `passing`
| `disabled`
| `starting`
| `warning`
| `failure`
export type HealthStatus = HealthCheckResult["result"]
export type SmtpValue = {
server: string
port: number
@@ -324,16 +319,13 @@ export type Effects = {
/** Removes all network bindings */
clearBindings(): Promise<void>
/** Creates a host connected to the specified port with the provided options */
bind(options: {
kind: "static" | "single" | "multi"
id: string
internalPort: number
scheme: Scheme
preferredExternalPort: number
addSsl: AddSslOptions | null
secure: { ssl: boolean } | null
}): Promise<void>
bind(
options: {
kind: "static" | "single" | "multi"
id: string
internalPort: number
} & BindOptions,
): Promise<void>
/** Retrieves the current hostname(s) associated with a host id */
// getHostInfo(options: {
// kind: "static" | "single"
@@ -479,11 +471,11 @@ export type Effects = {
algorithm: "ecdsa" | "ed25519" | null
}) => Promise<string>
setHealth(o: {
name: string
status: HealthStatus
message: string | null
}): Promise<void>
setHealth(
o: HealthCheckResult & {
id: HealthCheckId
},
): Promise<void>
/** Set the dependencies of what the service needs, usually ran during the set config as a best practice */
setDependencies(options: {
@@ -590,7 +582,7 @@ export type KnownError =
export type Dependency = {
id: PackageId
versionSpec: string
url: string
registryUrl: string
} & ({ kind: "exists" } | { kind: "running"; healthChecks: string[] })
export type Dependencies = Array<Dependency>