Fix StartOS 0.4 TypeScript packaging to match SDK API
This commit is contained in:
+59
@@ -0,0 +1,59 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.GetServiceInterfaces = void 0;
|
||||
exports.getOwnServiceInterfaces = getOwnServiceInterfaces;
|
||||
exports.getServiceInterfaces = getServiceInterfaces;
|
||||
const deepEqual_1 = require("./deepEqual");
|
||||
const getServiceInterface_1 = require("./getServiceInterface");
|
||||
const Watchable_1 = require("./Watchable");
|
||||
const makeManyInterfaceFilled = async ({ effects, packageId, callback, }) => {
|
||||
const serviceInterfaceValues = await effects.listServiceInterfaces({
|
||||
packageId,
|
||||
callback,
|
||||
});
|
||||
const serviceInterfacesFilled = await Promise.all(Object.values(serviceInterfaceValues).map(async (serviceInterfaceValue) => {
|
||||
const hostId = serviceInterfaceValue.addressInfo.hostId;
|
||||
const host = await effects.getHostInfo({
|
||||
packageId,
|
||||
hostId,
|
||||
callback,
|
||||
});
|
||||
if (!host) {
|
||||
throw new Error(`host ${hostId} not found!`);
|
||||
}
|
||||
return {
|
||||
...serviceInterfaceValue,
|
||||
host,
|
||||
addressInfo: (0, getServiceInterface_1.filledAddress)(host, serviceInterfaceValue.addressInfo),
|
||||
};
|
||||
}));
|
||||
return serviceInterfacesFilled;
|
||||
};
|
||||
class GetServiceInterfaces extends Watchable_1.Watchable {
|
||||
constructor(effects, opts, options) {
|
||||
super(effects, options);
|
||||
this.opts = opts;
|
||||
this.label = 'GetServiceInterfaces';
|
||||
}
|
||||
fetch(callback) {
|
||||
return makeManyInterfaceFilled({
|
||||
effects: this.effects,
|
||||
packageId: this.opts.packageId,
|
||||
callback,
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.GetServiceInterfaces = GetServiceInterfaces;
|
||||
function getOwnServiceInterfaces(effects, map, eq) {
|
||||
return new GetServiceInterfaces(effects, {}, {
|
||||
map: map ?? ((a) => a),
|
||||
eq: eq ?? ((a, b) => (0, deepEqual_1.deepEqual)(a, b)),
|
||||
});
|
||||
}
|
||||
function getServiceInterfaces(effects, opts, map, eq) {
|
||||
return new GetServiceInterfaces(effects, opts, {
|
||||
map: map ?? ((a) => a),
|
||||
eq: eq ?? ((a, b) => (0, deepEqual_1.deepEqual)(a, b)),
|
||||
});
|
||||
}
|
||||
//# sourceMappingURL=getServiceInterfaces.js.map
|
||||
Reference in New Issue
Block a user