tyoe changes

This commit is contained in:
Matt Hill
2024-01-18 16:12:37 -07:00
parent 27127f58d4
commit 009f79e289
7 changed files with 17 additions and 30 deletions

View File

@@ -87,7 +87,7 @@ type PortOptionsByKnownProtocol =
} }
type PortOptionsByProtocol = PortOptionsByKnownProtocol | PortOptions type PortOptionsByProtocol = PortOptionsByKnownProtocol | PortOptions
const hasStringProtocal = object({ const hasStringProtocol = object({
protocol: string, protocol: string,
}).test }).test
@@ -104,7 +104,7 @@ export class Host {
internalPort: number, internalPort: number,
options: PortOptionsByProtocol, options: PortOptionsByProtocol,
): Promise<Origin<this>> { ): Promise<Origin<this>> {
if (hasStringProtocal(options)) { if (hasStringProtocol(options)) {
return await this.bindPortForKnown(options, internalPort) return await this.bindPortForKnown(options, internalPort)
} else { } else {
return await this.bindPortForUnknown(internalPort, options) return await this.bindPortForUnknown(internalPort, options)

View File

@@ -18,7 +18,6 @@ export class Origin<T extends Host> {
options: this.options, options: this.options,
suffix: `${path}${qp}`, suffix: `${path}${qp}`,
username, username,
scheme: this.options.scheme,
} }
} }
} }

View File

@@ -4,7 +4,7 @@ export function setupManifest<
Id extends string, Id extends string,
Version extends ManifestVersion, Version extends ManifestVersion,
Dependencies extends Record<string, unknown>, Dependencies extends Record<string, unknown>,
Volumes extends Record<string, unknown>, Volumes extends string[],
Manifest extends SDKManifest & { Manifest extends SDKManifest & {
dependencies: Dependencies dependencies: Dependencies
id: Id id: Id

View File

@@ -22,13 +22,9 @@ describe("mountDependencies", () => {
short: "", short: "",
long: "", long: "",
}, },
assets: { assets: [],
icon: "", images: [],
instructions: "", volumes: ["main"],
license: "",
},
containers: {},
volumes: { main: "data" },
alerts: { alerts: {
install: null, install: null,
update: null, update: null,
@@ -55,15 +51,9 @@ describe("mountDependencies", () => {
short: "", short: "",
long: "", long: "",
}, },
assets: { assets: [],
icon: "", images: [],
instructions: "", volumes: ["main2"],
license: "",
},
containers: {},
volumes: {
main2: "data",
},
alerts: { alerts: {
install: null, install: null,
update: null, update: null,

View File

@@ -20,13 +20,10 @@ export const sdk = StartSdk.of()
short: "", short: "",
long: "", long: "",
}, },
assets: {
icon: "",
instructions: "",
license: "",
},
containers: {}, containers: {},
volumes: {}, images: [],
volumes: [],
assets: [],
alerts: { alerts: {
install: null, install: null,
update: null, update: null,

View File

@@ -170,7 +170,6 @@ export type Address = {
hostId: string hostId: string
options: PortOptions options: PortOptions
suffix: string suffix: string
scheme: string | null
} }
export type InterfaceId = string export type InterfaceId = string

View File

@@ -63,12 +63,14 @@ const negate =
!fn(a) !fn(a)
const unique = <A>(values: A[]) => Array.from(new Set(values)) const unique = <A>(values: A[]) => Array.from(new Set(values))
const addressHostToUrl = ( const addressHostToUrl = (
{ scheme, username, suffix }: Address, { options, username, suffix }: Address,
host: HostName, host: HostName,
): UrlString => ): UrlString => {
`${scheme ? `${scheme}//` : ""}${ const scheme = host.endsWith('.onion') ? options.scheme : (options.addSsl ? options.addSsl.scheme : options.scheme) // TODO: encode whether hostname transport is "secure"?
return `${scheme ? `${scheme}//` : ""}${
username ? `${username}@` : "" username ? `${username}@` : ""
}${host}${suffix}` }${host}${suffix}`
}
export const filledAddress = ( export const filledAddress = (
mapHostnames: { mapHostnames: {
[hostId: string]: HostName[] [hostId: string]: HostName[]