mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-31 04:23:40 +00:00
chore: Update the sdk to match the rust and vica verse
This commit is contained in:
@@ -59,12 +59,13 @@ type AddSslOptions = {
|
||||
preferredExternalPort: number
|
||||
addXForwardedHeaders: boolean | null /** default: false */
|
||||
}
|
||||
type Security = { secure: false; ssl: false } | { secure: true; ssl: boolean }
|
||||
type Security = { ssl: boolean }
|
||||
export type BindOptions = {
|
||||
scheme: Scheme
|
||||
preferredExternalPort: number
|
||||
addSsl: AddSslOptions | null
|
||||
} & Security
|
||||
secure: Security | null
|
||||
}
|
||||
type KnownProtocols = typeof knownProtocols
|
||||
type ProtocolsWithSslVariants = {
|
||||
[K in keyof KnownProtocols]: KnownProtocols[K] extends {
|
||||
@@ -79,14 +80,15 @@ type NotProtocolsWithSslVariants = Exclude<
|
||||
>
|
||||
|
||||
type BindOptionsByKnownProtocol =
|
||||
| ({
|
||||
| {
|
||||
protocol: ProtocolsWithSslVariants
|
||||
preferredExternalPort?: number
|
||||
preferredExternalPort: number | null
|
||||
scheme: Scheme | null
|
||||
} & ({ noAddSsl: true } | { addSsl?: Partial<AddSslOptions> }))
|
||||
addSsl: Partial<AddSslOptions> | null
|
||||
}
|
||||
| {
|
||||
protocol: NotProtocolsWithSslVariants
|
||||
preferredExternalPort?: number
|
||||
preferredExternalPort: number | null
|
||||
scheme: Scheme | null
|
||||
addSsl: AddSslOptions | null
|
||||
}
|
||||
@@ -120,17 +122,12 @@ export class Host {
|
||||
|
||||
private async bindPortForUnknown(
|
||||
internalPort: number,
|
||||
options:
|
||||
| ({
|
||||
scheme: Scheme
|
||||
preferredExternalPort: number
|
||||
addSsl: AddSslOptions | null
|
||||
} & { secure: false; ssl: false })
|
||||
| ({
|
||||
scheme: Scheme
|
||||
preferredExternalPort: number
|
||||
addSsl: AddSslOptions | null
|
||||
} & { secure: true; ssl: boolean }),
|
||||
options: {
|
||||
scheme: Scheme
|
||||
preferredExternalPort: number
|
||||
addSsl: AddSslOptions | null
|
||||
secure: { ssl: boolean } | null
|
||||
},
|
||||
) {
|
||||
await this.options.effects.bind({
|
||||
kind: this.options.kind,
|
||||
@@ -154,18 +151,13 @@ export class Host {
|
||||
knownProtocols[options.protocol].defaultPort
|
||||
const addSsl = this.getAddSsl(options, protoInfo)
|
||||
|
||||
const security: Security = !protoInfo.secure
|
||||
? {
|
||||
secure: protoInfo.secure,
|
||||
ssl: protoInfo.ssl,
|
||||
}
|
||||
: { secure: false, ssl: false }
|
||||
const secure: Security | null = !protoInfo.secure ? null : { ssl: false }
|
||||
|
||||
const newOptions = {
|
||||
scheme,
|
||||
preferredExternalPort,
|
||||
addSsl,
|
||||
...security,
|
||||
secure,
|
||||
}
|
||||
|
||||
await this.options.effects.bind({
|
||||
|
||||
@@ -10,6 +10,8 @@ describe("host", () => {
|
||||
const fooOrigin = await foo.bindPort(80, {
|
||||
protocol: "http" as const,
|
||||
scheme: null,
|
||||
addSsl: null,
|
||||
preferredExternalPort: null,
|
||||
})
|
||||
const fooInterface = new ServiceInterfaceBuilder({
|
||||
effects,
|
||||
|
||||
@@ -14,41 +14,24 @@ import { GetSslCertificateParams } from "../../../core/startos/bindings/GetSslCe
|
||||
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"
|
||||
| "setDependencies"
|
||||
)]: 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,
|
||||
@@ -70,6 +53,19 @@ describe("startosTypeValidation ", () => {
|
||||
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,
|
||||
|
||||
@@ -302,8 +302,7 @@ export type Effects = {
|
||||
scheme: Scheme
|
||||
preferredExternalPort: number
|
||||
addSsl: AddSslOptions | null
|
||||
secure: boolean
|
||||
ssl: boolean
|
||||
secure: { ssl: boolean } | null
|
||||
}): Promise<void>
|
||||
/** Retrieves the current hostname(s) associated with a host id */
|
||||
// getHostInfo(options: {
|
||||
@@ -491,9 +490,7 @@ export type Effects = {
|
||||
}
|
||||
http: {
|
||||
// optional, will do TCP layer proxy only if not present
|
||||
headers:
|
||||
| ((headers: Record<string, string>) => Record<string, string>)
|
||||
| null
|
||||
headers: Record<string, string> | null
|
||||
} | null
|
||||
}): Promise<{ stop(): Promise<void> }>
|
||||
restart(): void
|
||||
|
||||
Reference in New Issue
Block a user