feat: Update the type of the network interface to type

This commit is contained in:
Blu-J
2023-08-02 12:26:07 -06:00
parent 2d52b39409
commit c9484418ff
5 changed files with 17 additions and 14 deletions

View File

@@ -1,4 +1,5 @@
import { Address, Effects } from "../types" import { Address, Effects } from "../types"
import { NetworkInterfaceType } from "../util/utils"
import { AddressReceipt } from "./AddressReceipt" import { AddressReceipt } from "./AddressReceipt"
import { Host } from "./Host" import { Host } from "./Host"
import { Origin } from "./Origin" import { Origin } from "./Origin"
@@ -23,7 +24,7 @@ export class NetworkInterfaceBuilder {
description: string description: string
hasPrimary: boolean hasPrimary: boolean
disabled: boolean disabled: boolean
ui: boolean type: NetworkInterfaceType
username: null | string username: null | string
path: string path: string
search: Record<string, string> search: Record<string, string>
@@ -47,7 +48,7 @@ export class NetworkInterfaceBuilder {
hasPrimary, hasPrimary,
disabled, disabled,
id, id,
ui, type,
username, username,
path, path,
search, search,
@@ -64,7 +65,7 @@ export class NetworkInterfaceBuilder {
hasPrimary, hasPrimary,
disabled, disabled,
addresses, addresses,
ui, type,
}) })
return addresses as Address[] & AddressReceipt return addresses as Address[] & AddressReceipt

View File

@@ -15,7 +15,7 @@ describe("host", () => {
description: "A Foo", description: "A Foo",
hasPrimary: false, hasPrimary: false,
disabled: false, disabled: false,
ui: true, type: "ui",
username: "bar", username: "bar",
path: "/baz", path: "/baz",
search: { qux: "yes" }, search: { qux: "yes" },

View File

@@ -3,6 +3,7 @@ import { InputSpec } from "./config/configTypes"
import { DependenciesReceipt } from "./config/setupConfig" import { DependenciesReceipt } from "./config/setupConfig"
import { PortOptions } from "./interfaces/Host" import { PortOptions } from "./interfaces/Host"
import { UrlString } from "./util/getNetworkInterface" import { UrlString } from "./util/getNetworkInterface"
import { NetworkInterfaceType } from "./util/utils"
export type ExportedAction = (options: { export type ExportedAction = (options: {
effects: Effects effects: Effects
@@ -186,10 +187,9 @@ export type NetworkInterface = {
disabled: boolean disabled: boolean
/** All URIs */ /** All URIs */
addresses: Address[] addresses: Address[]
/** Defaults to false, but describes if this address can be opened in a browser as an
* ui interface /** The netowrk interface could be serveral types, something like ui, p2p, or network */
*/ type: NetworkInterfaceType
ui: boolean
} }
// prettier-ignore // prettier-ignore
export type ExposeAllServicePaths<Store, PreviousPath extends string = ""> = export type ExposeAllServicePaths<Store, PreviousPath extends string = ""> =

View File

@@ -1,5 +1,6 @@
import { Address, Effects, HostName, NetworkInterface } from "../types" import { Address, Effects, HostName, NetworkInterface } from "../types"
import * as regexes from "./regexes" import * as regexes from "./regexes"
import { NetworkInterfaceType } from "./utils"
export type UrlString = string export type UrlString = string
export type HostId = string export type HostId = string
@@ -45,10 +46,9 @@ export type NetworkInterfaceFilled = {
disabled: boolean disabled: boolean
/** All URIs */ /** All URIs */
addresses: FilledAddress[] addresses: FilledAddress[]
/** Defaults to false, but describes if this address can be opened in a browser as an
* ui interface /** Indicates if we are a ui/ p2p/ api/ other for the kind of interface that this is representing */
*/ type: NetworkInterfaceType
ui: boolean
primaryHostname: HostName | null primaryHostname: HostName | null
primaryUrl: UrlString | null primaryUrl: UrlString | null

View File

@@ -43,6 +43,8 @@ const childProcess = {
execFile: promisify(CP.execFile), execFile: promisify(CP.execFile),
} }
export type NetworkInterfaceType = "ui" | "p2p" | "api" | "other"
export type Utils<Store, WrapperOverWrite = { const: never }> = { export type Utils<Store, WrapperOverWrite = { const: never }> = {
checkPortListening( checkPortListening(
port: number, port: number,
@@ -68,7 +70,7 @@ export type Utils<Store, WrapperOverWrite = { const: never }> = {
description: string description: string
hasPrimary: boolean hasPrimary: boolean
disabled: boolean disabled: boolean
ui: boolean type: NetworkInterfaceType
username: null | string username: null | string
path: string path: string
search: Record<string, string> search: Record<string, string>
@@ -128,7 +130,7 @@ export const utils = <Store = never, WrapperOverWrite = { const: never }>(
description: string description: string
hasPrimary: boolean hasPrimary: boolean
disabled: boolean disabled: boolean
ui: boolean type: NetworkInterfaceType
username: null | string username: null | string
path: string path: string
search: Record<string, string> search: Record<string, string>