mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 12:11:56 +00:00
Feature/callbacks (#2678)
* wip * initialize callbacks * wip * smtp * list_service_interfaces * wip * wip * fix domains * fix hostname handling in NetService * misc fixes * getInstalledPackages * misc fixes * publish v6 lib * refactor service effects * fix import * fix container runtime * fix tests * apply suggestions from review
This commit is contained in:
@@ -55,9 +55,9 @@ export type ServiceInterfaceFilled = {
|
||||
/** Whether or not to mask the URIs for this interface. Useful if the URIs contain sensitive information, such as a password, macaroon, or API key */
|
||||
masked: boolean
|
||||
/** Information about the host for this binding */
|
||||
host: Host
|
||||
host: Host | null
|
||||
/** URI information */
|
||||
addressInfo: FilledAddressInfo
|
||||
addressInfo: FilledAddressInfo | null
|
||||
/** Indicates if we are a ui/p2p/api for the kind of interface that this is representing */
|
||||
type: ServiceInterfaceType
|
||||
/** The primary hostname for the service, as chosen by the user */
|
||||
@@ -183,33 +183,36 @@ const makeInterfaceFilled = async ({
|
||||
}: {
|
||||
effects: Effects
|
||||
id: string
|
||||
packageId: string | null
|
||||
callback: () => void
|
||||
packageId?: string
|
||||
callback?: () => void
|
||||
}) => {
|
||||
const serviceInterfaceValue = await effects.getServiceInterface({
|
||||
serviceInterfaceId: id,
|
||||
packageId,
|
||||
callback,
|
||||
})
|
||||
if (!serviceInterfaceValue) {
|
||||
return null
|
||||
}
|
||||
const hostId = serviceInterfaceValue.addressInfo.hostId
|
||||
const host = await effects.getHostInfo({
|
||||
packageId,
|
||||
hostId,
|
||||
callback,
|
||||
})
|
||||
const primaryUrl = await effects
|
||||
.getPrimaryUrl({
|
||||
serviceInterfaceId: id,
|
||||
packageId,
|
||||
callback,
|
||||
})
|
||||
.catch((e) => null)
|
||||
const primaryUrl = await effects.getPrimaryUrl({
|
||||
hostId,
|
||||
packageId,
|
||||
callback,
|
||||
})
|
||||
|
||||
const interfaceFilled: ServiceInterfaceFilled = {
|
||||
...serviceInterfaceValue,
|
||||
primaryUrl: primaryUrl,
|
||||
host,
|
||||
addressInfo: filledAddress(host, serviceInterfaceValue.addressInfo),
|
||||
addressInfo: host
|
||||
? filledAddress(host, serviceInterfaceValue.addressInfo)
|
||||
: null,
|
||||
get primaryHostname() {
|
||||
if (primaryUrl == null) return null
|
||||
return getHostname(primaryUrl)
|
||||
@@ -221,7 +224,7 @@ const makeInterfaceFilled = async ({
|
||||
export class GetServiceInterface {
|
||||
constructor(
|
||||
readonly effects: Effects,
|
||||
readonly opts: { id: string; packageId: string | null },
|
||||
readonly opts: { id: string; packageId?: string },
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -230,7 +233,7 @@ export class GetServiceInterface {
|
||||
async const() {
|
||||
const { id, packageId } = this.opts
|
||||
const callback = this.effects.restart
|
||||
const interfaceFilled: ServiceInterfaceFilled = await makeInterfaceFilled({
|
||||
const interfaceFilled = await makeInterfaceFilled({
|
||||
effects: this.effects,
|
||||
id,
|
||||
packageId,
|
||||
@@ -244,12 +247,10 @@ export class GetServiceInterface {
|
||||
*/
|
||||
async once() {
|
||||
const { id, packageId } = this.opts
|
||||
const callback = () => {}
|
||||
const interfaceFilled: ServiceInterfaceFilled = await makeInterfaceFilled({
|
||||
const interfaceFilled = await makeInterfaceFilled({
|
||||
effects: this.effects,
|
||||
id,
|
||||
packageId,
|
||||
callback,
|
||||
})
|
||||
|
||||
return interfaceFilled
|
||||
@@ -277,7 +278,7 @@ export class GetServiceInterface {
|
||||
}
|
||||
export function getServiceInterface(
|
||||
effects: Effects,
|
||||
opts: { id: string; packageId: string | null },
|
||||
opts: { id: string; packageId?: string },
|
||||
) {
|
||||
return new GetServiceInterface(effects, opts)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user