export patchdb ts types from rust

This commit is contained in:
Aiden McClelland
2024-03-27 17:47:12 -06:00
parent 9cf62f03fa
commit f41f5ebebd
75 changed files with 536 additions and 634 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

@@ -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

@@ -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

@@ -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"
@@ -324,16 +325,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 +477,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 +588,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>