update network interfaces types

This commit is contained in:
Matt Hill
2024-02-17 13:07:41 -07:00
parent fab13db4b4
commit eae75c13bb
4 changed files with 98 additions and 10 deletions

View File

@@ -87,6 +87,8 @@ type PortOptionsByKnownProtocol =
} }
type PortOptionsByProtocol = PortOptionsByKnownProtocol | PortOptions type PortOptionsByProtocol = PortOptionsByKnownProtocol | PortOptions
export type HostKind = "static" | "single" | "multi"
const hasStringProtocol = object({ const hasStringProtocol = object({
protocol: string, protocol: string,
}).test }).test
@@ -95,7 +97,7 @@ export class Host {
constructor( constructor(
readonly options: { readonly options: {
effects: Effects effects: Effects
kind: "static" | "single" | "multi" kind: HostKind
id: string id: string
}, },
) {} ) {}

View File

@@ -1,9 +1,8 @@
export * as configTypes from "./config/configTypes" export * as configTypes from "./config/configTypes"
import { InputSpec } from "./config/configTypes" import { InputSpec } from "./config/configTypes"
import { DependenciesReceipt } from "./config/setupConfig" import { DependenciesReceipt } from "./config/setupConfig"
import { PortOptions } from "./interfaces/Host" import { HostKind, PortOptions } from "./interfaces/Host"
import { Daemons } from "./mainFn/Daemons" import { Daemons } from "./mainFn/Daemons"
import { Overlay } from "./util/Overlay"
import { UrlString } from "./util/getNetworkInterface" import { UrlString } from "./util/getNetworkInterface"
import { NetworkInterfaceType, Signals } from "./util/utils" import { NetworkInterfaceType, Signals } from "./util/utils"
@@ -165,7 +164,7 @@ export type ActionMetadata = {
group?: string group?: string
} }
export declare const hostName: unique symbol export declare const hostName: unique symbol
export type HostName = string & { [hostName]: never } export type Hostname = string & { [hostName]: never }
/** ${scheme}://${username}@${host}:${externalPort}${suffix} */ /** ${scheme}://${username}@${host}:${externalPort}${suffix} */
export type Address = { export type Address = {
username: string | null username: string | null
@@ -174,6 +173,68 @@ export type Address = {
suffix: string suffix: string
} }
export type ListenKind = "onion" | "ip"
export type ListenInfoBase = {
kind: ListenKind
}
export type ListenInfoOnion = ListenInfoBase & {
kind: "onion"
}
export type ListenInfoIp = ListenInfoBase & {
kind: "ip"
interfaceId: string
}
export type ListenInfo = ListenInfoOnion | ListenInfoIp
export type HostBase = {
id: string
kind: HostKind
}
export type SingleHost = HostBase & {
kind: "single" | "static"
} & (
| {
listen: null
hostname: null
}
| {
listen: ListenInfoOnion
hostname: string
}
| {
listen: ListenInfoIp
hostname:
| string
| { domain: string; subdomain: string | null; port: number }
}
)
export type MultiHost = HostBase & {
kind: "multi"
} & {
hostnames:
| {
listen: null
hostname: null
}
| {
listen: ListenInfoOnion
hostname: string
}
| {
listen: ListenInfoIp
hostname: (
| string
| { domain: string; subdomain: string | null; port: number }
)[]
}
}
export type InterfaceId = string export type InterfaceId = string
export type NetworkInterface = { export type NetworkInterface = {
@@ -189,7 +250,7 @@ export type NetworkInterface = {
/** All URIs */ /** All URIs */
addresses: Address[] addresses: Address[]
/** The netowrk interface could be serveral types, something like ui, p2p, or network */ /** The network interface could be several types, something like ui, p2p, or network */
type: NetworkInterfaceType type: NetworkInterfaceType
} }
// prettier-ignore // prettier-ignore
@@ -246,13 +307,13 @@ export type Effects = {
hostId: string hostId: string
packageId?: string packageId?: string
callback: () => void callback: () => void
}): Promise<[HostName]> }): Promise<[Hostname]>
getHostnames(options: { getHostnames(options: {
kind?: "multi" kind?: "multi"
packageId?: string packageId?: string
hostId: string hostId: string
callback: () => void callback: () => void
}): Promise<[HostName, ...HostName[]]> }): Promise<[Hostname, ...Hostname[]]>
// /** // /**
// * Run rsync between two volumes. This is used to backup data between volumes. // * Run rsync between two volumes. This is used to backup data between volumes.

26
web/package-lock.json generated
View File

@@ -25,6 +25,7 @@
"@ng-web-apis/resize-observer": "^2.0.0", "@ng-web-apis/resize-observer": "^2.0.0",
"@start9labs/argon2": "^0.2.2", "@start9labs/argon2": "^0.2.2",
"@start9labs/emver": "^0.1.5", "@start9labs/emver": "^0.1.5",
"@start9labs/start-sdk": "file:../sdk/dist",
"@taiga-ui/addon-charts": "3.20.0", "@taiga-ui/addon-charts": "3.20.0",
"@taiga-ui/cdk": "3.20.0", "@taiga-ui/cdk": "3.20.0",
"@taiga-ui/core": "3.20.0", "@taiga-ui/core": "3.20.0",
@@ -47,7 +48,7 @@
"mustache": "^4.2.0", "mustache": "^4.2.0",
"ng-qrcode": "^7.0.0", "ng-qrcode": "^7.0.0",
"node-jose": "^2.2.0", "node-jose": "^2.2.0",
"patch-db-client": "file: ../../../patch-db/client", "patch-db-client": "file:../patch-db/client",
"pbkdf2": "^3.1.2", "pbkdf2": "^3.1.2",
"rxjs": "^7.8.1", "rxjs": "^7.8.1",
"swiper": "^8.2.4", "swiper": "^8.2.4",
@@ -1970,6 +1971,25 @@
"url": "https://github.com/sponsors/sindresorhus" "url": "https://github.com/sponsors/sindresorhus"
} }
}, },
"../sdk/dist": {
"version": "0.4.0-rev0.lib0.rc8.beta7",
"license": "MIT",
"dependencies": {
"@iarna/toml": "^2.2.5",
"isomorphic-fetch": "^3.0.0",
"ts-matches": "^5.4.1",
"yaml": "^2.2.2"
},
"devDependencies": {
"@types/jest": "^29.4.0",
"jest": "^29.4.3",
"prettier": "^3.2.5",
"ts-jest": "^29.0.5",
"ts-node": "^10.9.1",
"tsx": "^4.7.1",
"typescript": "^5.0.4"
}
},
"node_modules/@adobe/css-tools": { "node_modules/@adobe/css-tools": {
"version": "4.0.1", "version": "4.0.1",
"dev": true, "dev": true,
@@ -5291,6 +5311,10 @@
"version": "0.1.5", "version": "0.1.5",
"license": "MIT" "license": "MIT"
}, },
"node_modules/@start9labs/start-sdk": {
"resolved": "../sdk/dist",
"link": true
},
"node_modules/@stencil/core": { "node_modules/@stencil/core": {
"version": "2.18.0", "version": "2.18.0",
"license": "MIT", "license": "MIT",

View File

@@ -12,7 +12,7 @@
"check:install-wiz": "tsc --project projects/install-wizard/tsconfig.json --noEmit --skipLibCheck", "check:install-wiz": "tsc --project projects/install-wizard/tsconfig.json --noEmit --skipLibCheck",
"check:setup": "tsc --project projects/setup-wizard/tsconfig.json --noEmit --skipLibCheck", "check:setup": "tsc --project projects/setup-wizard/tsconfig.json --noEmit --skipLibCheck",
"check:ui": "tsc --project projects/ui/tsconfig.json --noEmit --skipLibCheck", "check:ui": "tsc --project projects/ui/tsconfig.json --noEmit --skipLibCheck",
"build:deps": "rm -rf .angular/cache && cd ../patch-db/client && npm ci && npm run build", "build:deps": "rm -rf .angular/cache && (cd ../patch-db/client && npm ci && npm run build) && (cd ../sdk && make bundle)",
"build:dui": "ng run diagnostic-ui:build", "build:dui": "ng run diagnostic-ui:build",
"build:install-wiz": "ng run install-wizard:build", "build:install-wiz": "ng run install-wizard:build",
"build:setup": "ng run setup-wizard:build", "build:setup": "ng run setup-wizard:build",
@@ -50,6 +50,7 @@
"@ng-web-apis/resize-observer": "^2.0.0", "@ng-web-apis/resize-observer": "^2.0.0",
"@start9labs/argon2": "^0.2.2", "@start9labs/argon2": "^0.2.2",
"@start9labs/emver": "^0.1.5", "@start9labs/emver": "^0.1.5",
"@start9labs/start-sdk": "file:../sdk/dist",
"@taiga-ui/addon-charts": "3.20.0", "@taiga-ui/addon-charts": "3.20.0",
"@taiga-ui/cdk": "3.20.0", "@taiga-ui/cdk": "3.20.0",
"@taiga-ui/core": "3.20.0", "@taiga-ui/core": "3.20.0",
@@ -72,7 +73,7 @@
"mustache": "^4.2.0", "mustache": "^4.2.0",
"ng-qrcode": "^7.0.0", "ng-qrcode": "^7.0.0",
"node-jose": "^2.2.0", "node-jose": "^2.2.0",
"patch-db-client": "file: ../../../patch-db/client", "patch-db-client": "file:../patch-db/client",
"pbkdf2": "^3.1.2", "pbkdf2": "^3.1.2",
"rxjs": "^7.8.1", "rxjs": "^7.8.1",
"swiper": "^8.2.4", "swiper": "^8.2.4",