mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-11 08:10:50 +08:00
fix: support legacy and current DSH hosts
This commit is contained in:
parent
72ffd7115c
commit
6b9118fe95
20 changed files with 1279 additions and 259 deletions
|
|
@ -1,13 +1,18 @@
|
|||
import { modernHarnessApi } from './modern-harness-api.mjs';
|
||||
|
||||
function optionalService(ctx, name) {
|
||||
if (ctx && Object.hasOwn(ctx, name)) return ctx[name];
|
||||
return typeof ctx?.get === 'function' ? ctx.get(name) : undefined;
|
||||
}
|
||||
|
||||
/** Connect to this Host directly unless an external Harness URL was configured. */
|
||||
export function harnessConnection(ctx, config = {}) {
|
||||
if (config.harnessBaseUrl !== undefined) {
|
||||
return { baseUrl: new URL(config.harnessBaseUrl) };
|
||||
}
|
||||
if (!ctx?.apiProxy) {
|
||||
throw new TypeError('dsh-im requires the Host apiProxy service; check that DSH has finished loading its Host services');
|
||||
}
|
||||
const apiProxy = optionalService(ctx, 'apiProxy') ?? modernHarnessApi(ctx);
|
||||
return {
|
||||
apiProxy: ctx.apiProxy,
|
||||
apiProxy,
|
||||
// Cordis child contexts share one root; different Hosts must not share
|
||||
// ownership of pending questions and approvals.
|
||||
interactionScope: ctx.root ?? ctx,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue