Fix StartOS 0.4 TypeScript packaging to match SDK API
This commit is contained in:
+5
@@ -0,0 +1,5 @@
|
||||
declare const AddressProof: unique symbol;
|
||||
export type AddressReceipt = {
|
||||
[AddressProof]: never;
|
||||
};
|
||||
export {};
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=AddressReceipt.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"AddressReceipt.js","sourceRoot":"","sources":["../../../../base/lib/interfaces/AddressReceipt.ts"],"names":[],"mappings":""}
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
import { Effects } from '../Effects';
|
||||
import { Origin } from './Origin';
|
||||
import { AddSslOptions } from '../osBindings';
|
||||
import { Security } from '../osBindings';
|
||||
import { BindOptions } from '../osBindings';
|
||||
import { AlpnInfo } from '../osBindings';
|
||||
export { AddSslOptions, Security, BindOptions };
|
||||
export declare const knownProtocols: {
|
||||
readonly http: {
|
||||
readonly secure: null;
|
||||
readonly defaultPort: 80;
|
||||
readonly withSsl: "https";
|
||||
readonly alpn: AlpnInfo;
|
||||
readonly addXForwardedHeaders: true;
|
||||
};
|
||||
readonly https: {
|
||||
readonly secure: {
|
||||
readonly ssl: true;
|
||||
};
|
||||
readonly defaultPort: 443;
|
||||
readonly addXForwardedHeaders: true;
|
||||
};
|
||||
readonly ws: {
|
||||
readonly secure: null;
|
||||
readonly defaultPort: 80;
|
||||
readonly withSsl: "wss";
|
||||
readonly alpn: AlpnInfo;
|
||||
readonly addXForwardedHeaders: true;
|
||||
};
|
||||
readonly wss: {
|
||||
readonly secure: {
|
||||
readonly ssl: true;
|
||||
};
|
||||
readonly defaultPort: 443;
|
||||
readonly addXForwardedHeaders: true;
|
||||
};
|
||||
readonly ssh: {
|
||||
readonly secure: {
|
||||
readonly ssl: false;
|
||||
};
|
||||
readonly defaultPort: 22;
|
||||
readonly addXForwardedHeaders: false;
|
||||
};
|
||||
readonly dns: {
|
||||
readonly secure: {
|
||||
readonly ssl: false;
|
||||
};
|
||||
readonly defaultPort: 53;
|
||||
readonly addXForwardedHeaders: false;
|
||||
};
|
||||
};
|
||||
export type Scheme = string | null;
|
||||
type KnownProtocols = typeof knownProtocols;
|
||||
type ProtocolsWithSslVariants = {
|
||||
[K in keyof KnownProtocols]: KnownProtocols[K] extends {
|
||||
withSsl: string;
|
||||
} ? K : never;
|
||||
}[keyof KnownProtocols];
|
||||
type NotProtocolsWithSslVariants = Exclude<keyof KnownProtocols, ProtocolsWithSslVariants>;
|
||||
type BindOptionsByKnownProtocol = {
|
||||
protocol: ProtocolsWithSslVariants;
|
||||
preferredExternalPort?: number;
|
||||
addSsl?: Partial<AddSslOptions>;
|
||||
} | {
|
||||
protocol: NotProtocolsWithSslVariants;
|
||||
preferredExternalPort?: number;
|
||||
addSsl?: AddSslOptions;
|
||||
};
|
||||
export type BindOptionsByProtocol = BindOptionsByKnownProtocol | (BindOptions & {
|
||||
protocol: null;
|
||||
});
|
||||
export declare class MultiHost {
|
||||
readonly options: {
|
||||
effects: Effects;
|
||||
id: string;
|
||||
};
|
||||
constructor(options: {
|
||||
effects: Effects;
|
||||
id: string;
|
||||
});
|
||||
/**
|
||||
* @description Use this function to bind the host to an internal port and configured options for protocol, security, and external port.
|
||||
*
|
||||
* @param internalPort - The internal port to be bound.
|
||||
* @param options - The protocol options for this binding.
|
||||
* @returns A multi-origin that is capable of exporting one or more service interfaces.
|
||||
* @example
|
||||
* In this example, we bind a previously created multi-host to port 80, then select the http protocol and request an external port of 8332.
|
||||
*
|
||||
* ```
|
||||
const uiMultiOrigin = await uiMulti.bindPort(80, {
|
||||
protocol: 'http',
|
||||
preferredExternalPort: 8332,
|
||||
})
|
||||
* ```
|
||||
*/
|
||||
bindPort(internalPort: number, options: BindOptionsByProtocol): Promise<Origin>;
|
||||
private bindPortForUnknown;
|
||||
private bindPortForKnown;
|
||||
private getSslProto;
|
||||
}
|
||||
+128
@@ -0,0 +1,128 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.MultiHost = exports.knownProtocols = void 0;
|
||||
const zod_1 = require("zod");
|
||||
const Origin_1 = require("./Origin");
|
||||
exports.knownProtocols = {
|
||||
http: {
|
||||
secure: null,
|
||||
defaultPort: 80,
|
||||
withSsl: 'https',
|
||||
alpn: { specified: ['http/1.1'] },
|
||||
addXForwardedHeaders: true,
|
||||
},
|
||||
https: {
|
||||
secure: { ssl: true },
|
||||
defaultPort: 443,
|
||||
addXForwardedHeaders: true,
|
||||
},
|
||||
ws: {
|
||||
secure: null,
|
||||
defaultPort: 80,
|
||||
withSsl: 'wss',
|
||||
alpn: { specified: ['http/1.1'] },
|
||||
addXForwardedHeaders: true,
|
||||
},
|
||||
wss: {
|
||||
secure: { ssl: true },
|
||||
defaultPort: 443,
|
||||
addXForwardedHeaders: true,
|
||||
},
|
||||
ssh: {
|
||||
secure: { ssl: false },
|
||||
defaultPort: 22,
|
||||
addXForwardedHeaders: false,
|
||||
},
|
||||
dns: {
|
||||
secure: { ssl: false },
|
||||
defaultPort: 53,
|
||||
addXForwardedHeaders: false,
|
||||
},
|
||||
};
|
||||
const hasStringProtocol = (v) => zod_1.z.object({ protocol: zod_1.z.string() }).safeParse(v).success;
|
||||
class MultiHost {
|
||||
constructor(options) {
|
||||
this.options = options;
|
||||
}
|
||||
/**
|
||||
* @description Use this function to bind the host to an internal port and configured options for protocol, security, and external port.
|
||||
*
|
||||
* @param internalPort - The internal port to be bound.
|
||||
* @param options - The protocol options for this binding.
|
||||
* @returns A multi-origin that is capable of exporting one or more service interfaces.
|
||||
* @example
|
||||
* In this example, we bind a previously created multi-host to port 80, then select the http protocol and request an external port of 8332.
|
||||
*
|
||||
* ```
|
||||
const uiMultiOrigin = await uiMulti.bindPort(80, {
|
||||
protocol: 'http',
|
||||
preferredExternalPort: 8332,
|
||||
})
|
||||
* ```
|
||||
*/
|
||||
async bindPort(internalPort, options) {
|
||||
if (hasStringProtocol(options)) {
|
||||
return await this.bindPortForKnown(options, internalPort);
|
||||
}
|
||||
else {
|
||||
return await this.bindPortForUnknown(internalPort, options);
|
||||
}
|
||||
}
|
||||
async bindPortForUnknown(internalPort, options) {
|
||||
const binderOptions = {
|
||||
id: this.options.id,
|
||||
internalPort,
|
||||
...options,
|
||||
};
|
||||
await this.options.effects.bind(binderOptions);
|
||||
return new Origin_1.Origin(this, internalPort, null, null);
|
||||
}
|
||||
async bindPortForKnown(options, internalPort) {
|
||||
const protoInfo = exports.knownProtocols[options.protocol];
|
||||
const preferredExternalPort = options.preferredExternalPort ||
|
||||
exports.knownProtocols[options.protocol].defaultPort;
|
||||
const sslProto = this.getSslProto(options);
|
||||
const addSsl = sslProto
|
||||
? {
|
||||
addXForwardedHeaders: exports.knownProtocols[sslProto].addXForwardedHeaders,
|
||||
preferredExternalPort: exports.knownProtocols[sslProto].defaultPort,
|
||||
scheme: sslProto,
|
||||
alpn: 'alpn' in protoInfo ? protoInfo.alpn : null,
|
||||
...('addSsl' in options ? options.addSsl : null),
|
||||
}
|
||||
: options.addSsl
|
||||
? {
|
||||
addXForwardedHeaders: false,
|
||||
preferredExternalPort: 443,
|
||||
scheme: sslProto,
|
||||
alpn: null,
|
||||
...options.addSsl,
|
||||
}
|
||||
: null;
|
||||
const secure = protoInfo.secure ?? null;
|
||||
await this.options.effects.bind({
|
||||
id: this.options.id,
|
||||
internalPort,
|
||||
preferredExternalPort,
|
||||
addSsl,
|
||||
secure,
|
||||
});
|
||||
return new Origin_1.Origin(this, internalPort, options.protocol, sslProto);
|
||||
}
|
||||
getSslProto(options) {
|
||||
const proto = options.protocol;
|
||||
const protoInfo = exports.knownProtocols[proto];
|
||||
if (inObject('noAddSsl', options) && options.noAddSsl)
|
||||
return null;
|
||||
if ('withSsl' in protoInfo && protoInfo.withSsl)
|
||||
return protoInfo.withSsl;
|
||||
if (protoInfo.secure?.ssl)
|
||||
return proto;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
exports.MultiHost = MultiHost;
|
||||
function inObject(key, obj) {
|
||||
return key in obj;
|
||||
}
|
||||
//# sourceMappingURL=Host.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"Host.js","sourceRoot":"","sources":["../../../../base/lib/interfaces/Host.ts"],"names":[],"mappings":";;;AAAA,6BAAuB;AAEvB,qCAAiC;AAQpB,QAAA,cAAc,GAAG;IAC5B,IAAI,EAAE;QACJ,MAAM,EAAE,IAAI;QACZ,WAAW,EAAE,EAAE;QACf,OAAO,EAAE,OAAO;QAChB,IAAI,EAAE,EAAE,SAAS,EAAE,CAAC,UAAU,CAAC,EAAc;QAC7C,oBAAoB,EAAE,IAAI;KAC3B;IACD,KAAK,EAAE;QACL,MAAM,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE;QACrB,WAAW,EAAE,GAAG;QAChB,oBAAoB,EAAE,IAAI;KAC3B;IACD,EAAE,EAAE;QACF,MAAM,EAAE,IAAI;QACZ,WAAW,EAAE,EAAE;QACf,OAAO,EAAE,KAAK;QACd,IAAI,EAAE,EAAE,SAAS,EAAE,CAAC,UAAU,CAAC,EAAc;QAC7C,oBAAoB,EAAE,IAAI;KAC3B;IACD,GAAG,EAAE;QACH,MAAM,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE;QACrB,WAAW,EAAE,GAAG;QAChB,oBAAoB,EAAE,IAAI;KAC3B;IACD,GAAG,EAAE;QACH,MAAM,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE;QACtB,WAAW,EAAE,EAAE;QACf,oBAAoB,EAAE,KAAK;KAC5B;IACD,GAAG,EAAE;QACH,MAAM,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE;QACtB,WAAW,EAAE,EAAE;QACf,oBAAoB,EAAE,KAAK;KAC5B;CACO,CAAA;AAgCV,MAAM,iBAAiB,GAAG,CAAC,CAAU,EAA6B,EAAE,CAClE,OAAC,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,OAAC,CAAC,MAAM,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YAAE,OAAO,KAAK,CAAA;QACvC,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AArGD,8BAqGC;AAED,SAAS,QAAQ,CACf,GAAQ,EACR,GAAQ;IAER,OAAO,GAAG,IAAI,GAAG,CAAA;AACnB,CAAC"}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
import { AddressInfo } from '../types';
|
||||
import { AddressReceipt } from './AddressReceipt';
|
||||
import { MultiHost, Scheme } from './Host';
|
||||
import { ServiceInterfaceBuilder } from './ServiceInterfaceBuilder';
|
||||
export declare class Origin {
|
||||
readonly host: MultiHost;
|
||||
readonly internalPort: number;
|
||||
readonly scheme: string | null;
|
||||
readonly sslScheme: string | null;
|
||||
constructor(host: MultiHost, internalPort: number, scheme: string | null, sslScheme: string | null);
|
||||
build({ username, path, query: search, schemeOverride, }: BuildOptions): AddressInfo;
|
||||
/**
|
||||
* @description A function to register a group of origins (<PROTOCOL> :// <HOSTNAME> : <PORT>) with StartOS
|
||||
*
|
||||
* The returned addressReceipt serves as proof that the addresses were registered
|
||||
*
|
||||
* @param addressInfo
|
||||
* @returns
|
||||
*/
|
||||
export(serviceInterfaces: ServiceInterfaceBuilder[]): Promise<AddressInfo[] & AddressReceipt>;
|
||||
}
|
||||
type BuildOptions = {
|
||||
schemeOverride: {
|
||||
ssl: Scheme;
|
||||
noSsl: Scheme;
|
||||
} | null;
|
||||
username: string | null;
|
||||
path: string;
|
||||
query: Record<string, string>;
|
||||
};
|
||||
export {};
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Origin = void 0;
|
||||
class Origin {
|
||||
constructor(host, internalPort, scheme, sslScheme) {
|
||||
this.host = host;
|
||||
this.internalPort = internalPort;
|
||||
this.scheme = scheme;
|
||||
this.sslScheme = sslScheme;
|
||||
}
|
||||
build({ username, path, query: search, schemeOverride, }) {
|
||||
const qpEntries = Object.entries(search)
|
||||
.map(([key, val]) => `${encodeURIComponent(key)}=${encodeURIComponent(val)}`)
|
||||
.join('&');
|
||||
const qp = qpEntries.length ? `?${qpEntries}` : '';
|
||||
return {
|
||||
hostId: this.host.options.id,
|
||||
internalPort: this.internalPort,
|
||||
scheme: schemeOverride ? schemeOverride.noSsl : this.scheme,
|
||||
sslScheme: schemeOverride ? schemeOverride.ssl : this.sslScheme,
|
||||
suffix: `${path}${qp}`,
|
||||
username,
|
||||
};
|
||||
}
|
||||
/**
|
||||
* @description A function to register a group of origins (<PROTOCOL> :// <HOSTNAME> : <PORT>) with StartOS
|
||||
*
|
||||
* The returned addressReceipt serves as proof that the addresses were registered
|
||||
*
|
||||
* @param addressInfo
|
||||
* @returns
|
||||
*/
|
||||
async export(serviceInterfaces) {
|
||||
const addressesInfo = [];
|
||||
for (let serviceInterface of serviceInterfaces) {
|
||||
const { name, description, id, type, username, path, query: search, schemeOverride, masked, } = serviceInterface.options;
|
||||
const addressInfo = this.build({
|
||||
username,
|
||||
path,
|
||||
query: search,
|
||||
schemeOverride,
|
||||
});
|
||||
await serviceInterface.options.effects.exportServiceInterface({
|
||||
id,
|
||||
name,
|
||||
description,
|
||||
addressInfo,
|
||||
type,
|
||||
masked,
|
||||
});
|
||||
addressesInfo.push(addressInfo);
|
||||
}
|
||||
return addressesInfo;
|
||||
}
|
||||
}
|
||||
exports.Origin = Origin;
|
||||
//# sourceMappingURL=Origin.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"Origin.js","sourceRoot":"","sources":["../../../../base/lib/interfaces/Origin.ts"],"names":[],"mappings":";;;AAKA,MAAa,MAAM;IACjB,YACW,IAAe,EACf,YAAoB,EACpB,MAAqB,EACrB,SAAwB;QAHxB,SAAI,GAAJ,IAAI,CAAW;QACf,iBAAY,GAAZ,YAAY,CAAQ;QACpB,WAAM,GAAN,MAAM,CAAe;QACrB,cAAS,GAAT,SAAS,CAAe;IAChC,CAAC;IAEJ,KAAK,CAAC,EACJ,QAAQ,EACR,IAAI,EACJ,KAA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AAC,OAAO,CAAC,OAAO,CAAC,sBAAsB,CAAC;gBAC5D,EAAE;gBACF,IAAI;gBACJ,WAAW;gBACX,WAAW;gBACX,IAAI;gBACJ,MAAM;aACP,CAAC,CAAA;YAEF,aAAa,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;QACjC,CAAC;QAED,OAAO,aAA+C,CAAA;IACxD,CAAC;CACF;AA9ED,wBA8EC"}
|
||||
Generated
Vendored
+46
@@ -0,0 +1,46 @@
|
||||
import { ServiceInterfaceType } from '../types';
|
||||
import { Effects } from '../Effects';
|
||||
import { Scheme } from './Host';
|
||||
/**
|
||||
* A helper class for creating a Network Interface
|
||||
*
|
||||
* Network Interfaces are collections of web addresses that expose the same API or other resource,
|
||||
* display to the user with under a common name and description.
|
||||
*
|
||||
* All URIs on an interface inherit the same ui: bool, basic auth credentials, path, and search (query) params
|
||||
*
|
||||
* @param options
|
||||
* @returns
|
||||
*/
|
||||
export declare class ServiceInterfaceBuilder {
|
||||
readonly options: {
|
||||
effects: Effects;
|
||||
name: string;
|
||||
id: string;
|
||||
description: string;
|
||||
type: ServiceInterfaceType;
|
||||
username: string | null;
|
||||
path: string;
|
||||
query: Record<string, string>;
|
||||
schemeOverride: {
|
||||
ssl: Scheme;
|
||||
noSsl: Scheme;
|
||||
} | null;
|
||||
masked: boolean;
|
||||
};
|
||||
constructor(options: {
|
||||
effects: Effects;
|
||||
name: string;
|
||||
id: string;
|
||||
description: string;
|
||||
type: ServiceInterfaceType;
|
||||
username: string | null;
|
||||
path: string;
|
||||
query: Record<string, string>;
|
||||
schemeOverride: {
|
||||
ssl: Scheme;
|
||||
noSsl: Scheme;
|
||||
} | null;
|
||||
masked: boolean;
|
||||
});
|
||||
}
|
||||
Generated
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ServiceInterfaceBuilder = void 0;
|
||||
/**
|
||||
* A helper class for creating a Network Interface
|
||||
*
|
||||
* Network Interfaces are collections of web addresses that expose the same API or other resource,
|
||||
* display to the user with under a common name and description.
|
||||
*
|
||||
* All URIs on an interface inherit the same ui: bool, basic auth credentials, path, and search (query) params
|
||||
*
|
||||
* @param options
|
||||
* @returns
|
||||
*/
|
||||
class ServiceInterfaceBuilder {
|
||||
constructor(options) {
|
||||
this.options = options;
|
||||
}
|
||||
}
|
||||
exports.ServiceInterfaceBuilder = ServiceInterfaceBuilder;
|
||||
//# sourceMappingURL=ServiceInterfaceBuilder.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"ServiceInterfaceBuilder.js","sourceRoot":"","sources":["../../../../base/lib/interfaces/ServiceInterfaceBuilder.ts"],"names":[],"mappings":";;;AAIA;;;;;;;;;;GAUG;AACH,MAAa,uBAAuB;IAClC,YACW,OAWR;QAXQ,YAAO,GAAP,OAAO,CAWf;IACA,CAAC;CACL;AAfD,0DAeC"}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import { Effects } from '../types';
|
||||
export type SetExportedUrls = (opts: {
|
||||
effects: Effects;
|
||||
}) => Promise<void>;
|
||||
export type UpdateExportedUrls = (effects: Effects) => Promise<null>;
|
||||
export type SetupExportedUrls = (fn: SetExportedUrls) => UpdateExportedUrls;
|
||||
export declare const setupExportedUrls: SetupExportedUrls;
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.setupExportedUrls = void 0;
|
||||
const setupExportedUrls = (fn) => {
|
||||
return (async (effects) => {
|
||||
const urls = [];
|
||||
await fn({
|
||||
effects: {
|
||||
...effects,
|
||||
plugin: {
|
||||
...effects.plugin,
|
||||
url: {
|
||||
...effects.plugin.url,
|
||||
exportUrl: (params) => {
|
||||
urls.push(params.hostnameInfo);
|
||||
return effects.plugin.url.exportUrl(params);
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
await effects.plugin.url.clearUrls({ except: urls });
|
||||
return null;
|
||||
});
|
||||
};
|
||||
exports.setupExportedUrls = setupExportedUrls;
|
||||
//# sourceMappingURL=setupExportedUrls.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"setupExportedUrls.js","sourceRoot":"","sources":["../../../../base/lib/interfaces/setupExportedUrls.ts"],"names":[],"mappings":";;;AAMO,MAAM,iBAAiB,GAAsB,CAAC,EAAmB,EAAE,EAAE;IAC1E,OAAO,CAAC,KAAK,EAAE,OAAgB,EAAE,EAAE;QACjC,MAAM,IAAI,GAAyB,EAAE,CAAA;QACrC,MAAM,EAAE,CAAC;YACP,OAAO,EAAE;gBACP,GAAG,OAAO;gBACV,MAAM,EAAE;oBACN,GAAG,OAAO,CAAC,MAAM;oBACjB,GAAG,EAAE;wBACH,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG;wBACrB,SAAS,EAAE,CAAC,MAAM,EAAE,EAAE;4BACpB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,CAAA;4BAC9B,OAAO,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;wBAC7C,CAAC;qBACF;iBACF;aACF;SACF,CAAC,CAAA;QACF,MAAM,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAA;QACpD,OAAO,IAAI,CAAA;IACb,CAAC,CAAuB,CAAA;AAC1B,CAAC,CAAA;AArBY,QAAA,iBAAiB,qBAqB7B"}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
import * as T from '../types';
|
||||
import { AddressReceipt } from './AddressReceipt';
|
||||
declare const UpdateServiceInterfacesProof: unique symbol;
|
||||
export type UpdateServiceInterfacesReceipt = {
|
||||
[UpdateServiceInterfacesProof]: never;
|
||||
};
|
||||
export type ServiceInterfacesReceipt = Array<T.AddressInfo[] & AddressReceipt>;
|
||||
export type SetServiceInterfaces<Output extends ServiceInterfacesReceipt> = (opts: {
|
||||
effects: T.Effects;
|
||||
}) => Promise<Output>;
|
||||
export type UpdateServiceInterfaces = (effects: T.Effects) => Promise<null>;
|
||||
export type SetupServiceInterfaces = <Output extends ServiceInterfacesReceipt>(fn: SetServiceInterfaces<Output>) => UpdateServiceInterfaces;
|
||||
export declare const NO_INTERFACE_CHANGES: UpdateServiceInterfacesReceipt;
|
||||
export declare const setupServiceInterfaces: SetupServiceInterfaces;
|
||||
export {};
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.setupServiceInterfaces = exports.NO_INTERFACE_CHANGES = void 0;
|
||||
exports.NO_INTERFACE_CHANGES = {};
|
||||
const setupServiceInterfaces = (fn) => {
|
||||
return (async (effects) => {
|
||||
const bindings = [];
|
||||
const interfaces = [];
|
||||
await fn({
|
||||
effects: {
|
||||
...effects,
|
||||
bind: (params) => {
|
||||
bindings.push({ id: params.id, internalPort: params.internalPort });
|
||||
return effects.bind(params);
|
||||
},
|
||||
exportServiceInterface: (params) => {
|
||||
interfaces.push(params.id);
|
||||
return effects.exportServiceInterface(params);
|
||||
},
|
||||
},
|
||||
});
|
||||
await effects.clearBindings({ except: bindings });
|
||||
await effects.clearServiceInterfaces({ except: interfaces });
|
||||
return null;
|
||||
});
|
||||
};
|
||||
exports.setupServiceInterfaces = setupServiceInterfaces;
|
||||
//# sourceMappingURL=setupInterfaces.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"setupInterfaces.js","sourceRoot":"","sources":["../../../../base/lib/interfaces/setupInterfaces.ts"],"names":[],"mappings":";;;AAgBa,QAAA,oBAAoB,GAAG,EAAoC,CAAA;AACjE,MAAM,sBAAsB,GAA2B,CAG5D,EAAgC,EAChC,EAAE;IACF,OAAO,CAAC,KAAK,EAAE,OAAkB,EAAE,EAAE;QACnC,MAAM,QAAQ,GAAe,EAAE,CAAA;QAC/B,MAAM,UAAU,GAA2B,EAAE,CAAA;QAC7C,MAAM,EAAE,CAAC;YACP,OAAO,EAAE;gBACP,GAAG,OAAO;gBACV,IAAI,EAAE,CAAC,MAAoB,EAAE,EAAE;oBAC7B,QAAQ,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,YAAY,EAAE,MAAM,CAAC,YAAY,EAAE,CAAC,CAAA;oBACnE,OAAO,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;gBAC7B,CAAC;gBACD,sBAAsB,EAAE,CAAC,MAAsC,EAAE,EAAE;oBACjE,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;oBAC1B,OAAO,OAAO,CAAC,sBAAsB,CAAC,MAAM,CAAC,CAAA;gBAC/C,CAAC;aACF;SACF,CAAC,CAAA;QACF,MAAM,OAAO,CAAC,aAAa,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAA;QACjD,MAAM,OAAO,CAAC,sBAAsB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAA;QAC5D,OAAO,IAAI,CAAA;IACb,CAAC,CAA4B,CAAA;AAC/B,CAAC,CAAA;AAzBY,QAAA,sBAAsB,0BAyBlC"}
|
||||
Reference in New Issue
Block a user