chore: update bindings and use typed params for outbound gateway API

This commit is contained in:
Aiden McClelland
2026-02-17 12:31:35 -07:00
parent 52272feb3e
commit ccafb599a6
22 changed files with 85 additions and 51 deletions

View File

@@ -119,6 +119,10 @@ export default class ServiceActionsRoute {
ungrouped: 'General' | 'Other' = 'General'
readonly service = inject(StandardActionsService)
private readonly gateways = toSignal(
this.patch.watch$('serverInfo', 'network', 'gateways'),
)
readonly package = toSignal(
this.patch.watch$('packageData', getPkgId()).pipe(
map(pkg => {
@@ -173,11 +177,18 @@ export default class ServiceActionsRoute {
readonly outboundGatewayAction = computed(() => {
const pkg = this.package()
const gateway = pkg?.outboundGateway
const gatewayId = pkg?.outboundGateway
const gateways = this.gateways()
const gatewayName =
gatewayId && gateways?.[gatewayId]
? (gateways[gatewayId].name ??
gateways[gatewayId].ipInfo?.name ??
gatewayId)
: null
return {
name: this.i18n.transform('Set Outbound Gateway')!,
description: gateway
? `${this.i18n.transform('Current')}: ${gateway}`
description: gatewayName
? `${this.i18n.transform('Current')}: ${gatewayName}`
: `${this.i18n.transform('Current')}: ${this.i18n.transform('System')}`,
}
})
@@ -256,7 +267,7 @@ export default class ServiceActionsRoute {
try {
await this.api.setServiceOutbound({
packageId: pkg.manifest.id,
package: pkg.manifest.id,
gateway: input.gateway === SYSTEM_KEY ? null : input.gateway,
})
return true

View File

@@ -191,10 +191,9 @@ export abstract class ApiService {
abstract setDefaultOutbound(params: { gateway: string | null }): Promise<null>
abstract setServiceOutbound(params: {
packageId: string
gateway: string | null
}): Promise<null>
abstract setServiceOutbound(
params: T.SetOutboundGatewayParams,
): Promise<null>
// ** domains **

View File

@@ -276,9 +276,7 @@ export class LiveApiService extends ApiService {
})
}
async checkPort(
params: T.CheckPortParams,
): Promise<T.CheckPortRes> {
async checkPort(params: T.CheckPortParams): Promise<T.CheckPortRes> {
return this.rpcRequest({
method: 'net.gateway.check-port',
params,
@@ -369,17 +367,14 @@ export class LiveApiService extends ApiService {
return this.rpcRequest({ method: 'net.tunnel.remove', params })
}
async setDefaultOutbound(params: { gateway: string | null }): Promise<null> {
async setDefaultOutbound(params: T.SetDefaultOutboundParams): Promise<null> {
return this.rpcRequest({
method: 'net.gateway.set-default-outbound',
params,
})
}
async setServiceOutbound(params: {
packageId: string
gateway: string | null
}): Promise<null> {
async setServiceOutbound(params: T.SetOutboundGatewayParams): Promise<null> {
return this.rpcRequest({ method: 'package.set-outbound-gateway', params })
}

View File

@@ -662,15 +662,14 @@ export class MockApiService extends ApiService {
return null
}
async setServiceOutbound(params: {
packageId: string
gateway: string | null
}): Promise<null> {
async setServiceOutbound(
params: T.SetOutboundGatewayParams,
): Promise<null> {
await pauseFor(2000)
const patch = [
{
op: PatchOp.REPLACE,
path: `/packageData/${params.packageId}/outboundGateway`,
path: `/packageData/${params.package}/outboundGateway`,
value: params.gateway,
},
]