Refactor/sdk init (#2947)

* fixes for main

* refactor package initialization

* fixes from testing

* more fixes

* beta.21

* do not use instanceof

* closes #2921

* beta22

* allow disabling kiosk

* migration

* fix /etc/shadow

* actionRequest -> task

* beta.23
This commit is contained in:
Aiden McClelland
2025-05-21 10:24:37 -06:00
committed by GitHub
parent 46fd01c264
commit 44560c8da8
237 changed files with 1827 additions and 98800 deletions

View File

@@ -11,7 +11,12 @@ export class Origin {
readonly sslScheme: string | null,
) {}
build({ username, path, search, schemeOverride }: BuildOptions): AddressInfo {
build({
username,
path,
query: search,
schemeOverride,
}: BuildOptions): AddressInfo {
const qpEntries = Object.entries(search)
.map(
([key, val]) => `${encodeURIComponent(key)}=${encodeURIComponent(val)}`,
@@ -50,7 +55,7 @@ export class Origin {
type,
username,
path,
search,
query: search,
schemeOverride,
masked,
} = serviceInterface.options
@@ -58,7 +63,7 @@ export class Origin {
const addressInfo = this.build({
username,
path,
search,
query: search,
schemeOverride,
})
@@ -82,5 +87,5 @@ type BuildOptions = {
schemeOverride: { ssl: Scheme; noSsl: Scheme } | null
username: string | null
path: string
search: Record<string, string>
query: Record<string, string>
}

View File

@@ -23,7 +23,7 @@ export class ServiceInterfaceBuilder {
type: ServiceInterfaceType
username: string | null
path: string
search: Record<string, string>
query: Record<string, string>
schemeOverride: { ssl: Scheme; noSsl: Scheme } | null
masked: boolean
},

View File

@@ -10,46 +10,34 @@ export type UpdateServiceInterfacesReceipt = {
export type ServiceInterfacesReceipt = Array<T.AddressInfo[] & AddressReceipt>
export type SetServiceInterfaces<Output extends ServiceInterfacesReceipt> =
(opts: { effects: T.Effects }) => Promise<Output>
export type UpdateServiceInterfaces<Output extends ServiceInterfacesReceipt> =
(opts: {
effects: T.Effects
}) => Promise<Output & UpdateServiceInterfacesReceipt>
export type UpdateServiceInterfaces = (effects: T.Effects) => Promise<null>
export type SetupServiceInterfaces = <Output extends ServiceInterfacesReceipt>(
fn: SetServiceInterfaces<Output>,
) => UpdateServiceInterfaces<Output>
) => UpdateServiceInterfaces
export const NO_INTERFACE_CHANGES = {} as UpdateServiceInterfacesReceipt
export const setupServiceInterfaces: SetupServiceInterfaces = <
Output extends ServiceInterfacesReceipt,
>(
fn: SetServiceInterfaces<Output>,
) => {
const cell = {
updater: (async (options: { effects: T.Effects }) =>
[] as any as Output) as UpdateServiceInterfaces<Output>,
}
cell.updater = (async (options: { effects: T.Effects }) => {
const childEffects = options.effects.child("setupInterfaces")
childEffects.constRetry = once(() => {
cell.updater({ effects: options.effects })
})
return (async (effects: T.Effects) => {
const bindings: T.BindId[] = []
const interfaces: T.ServiceInterfaceId[] = []
const res = await fn({
await fn({
effects: {
...childEffects,
...effects,
bind: (params: T.BindParams) => {
bindings.push({ id: params.id, internalPort: params.internalPort })
return childEffects.bind(params)
return effects.bind(params)
},
exportServiceInterface: (params: T.ExportServiceInterfaceParams) => {
interfaces.push(params.id)
return childEffects.exportServiceInterface(params)
return effects.exportServiceInterface(params)
},
},
})
await options.effects.clearBindings({ except: bindings })
await options.effects.clearServiceInterfaces({ except: interfaces })
return res
}) as UpdateServiceInterfaces<Output>
return cell.updater
await effects.clearBindings({ except: bindings })
await effects.clearServiceInterfaces({ except: interfaces })
return null
}) as UpdateServiceInterfaces
}