@forge/bridge 4.5.3 → 4.6.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/out/index.d.ts +1 -1
- package/out/index.d.ts.map +1 -1
- package/out/index.js +1 -1
- package/out/invoke-endpoint/index.d.ts +3 -0
- package/out/invoke-endpoint/index.d.ts.map +1 -0
- package/out/{invoke-remote → invoke-endpoint}/index.js +1 -0
- package/out/invoke-endpoint/invoke-endpoint.d.ts +18 -0
- package/out/invoke-endpoint/invoke-endpoint.d.ts.map +1 -0
- package/out/invoke-endpoint/invoke-endpoint.js +45 -0
- package/out/invoke-endpoint/invoke-remote.d.ts +4 -0
- package/out/invoke-endpoint/invoke-remote.d.ts.map +1 -0
- package/out/invoke-endpoint/invoke-remote.js +9 -0
- package/out/invoke-endpoint/invoke-service.d.ts +4 -0
- package/out/invoke-endpoint/invoke-service.d.ts.map +1 -0
- package/out/invoke-endpoint/invoke-service.js +9 -0
- package/package.json +1 -1
- package/out/invoke-remote/index.d.ts +0 -2
- package/out/invoke-remote/index.d.ts.map +0 -1
- package/out/invoke-remote/invoke-remote.d.ts +0 -8
- package/out/invoke-remote/invoke-remote.d.ts.map +0 -1
- package/out/invoke-remote/invoke-remote.js +0 -31
package/CHANGELOG.md
CHANGED
package/out/index.d.ts
CHANGED
package/out/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,cAAc,UAAU,CAAC;AACzB,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAClC,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC"}
|
package/out/index.js
CHANGED
|
@@ -5,7 +5,7 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
var targets_1 = require("./router/targets");
|
|
6
6
|
Object.defineProperty(exports, "NavigationTarget", { enumerable: true, get: function () { return targets_1.NavigationTarget; } });
|
|
7
7
|
tslib_1.__exportStar(require("./invoke"), exports);
|
|
8
|
-
tslib_1.__exportStar(require("./invoke-
|
|
8
|
+
tslib_1.__exportStar(require("./invoke-endpoint"), exports);
|
|
9
9
|
tslib_1.__exportStar(require("./view"), exports);
|
|
10
10
|
tslib_1.__exportStar(require("./router"), exports);
|
|
11
11
|
tslib_1.__exportStar(require("./modal"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/invoke-endpoint/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { InvokeResponse } from '../types';
|
|
2
|
+
declare type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
3
|
+
export interface InvokeEndpointInput {
|
|
4
|
+
path: string;
|
|
5
|
+
method: HttpMethod;
|
|
6
|
+
headers?: Record<string, string>;
|
|
7
|
+
body?: unknown;
|
|
8
|
+
}
|
|
9
|
+
export declare enum InvokeType {
|
|
10
|
+
REMOTE = "Remote",
|
|
11
|
+
SERVICE = "Container"
|
|
12
|
+
}
|
|
13
|
+
export interface CallBridgePayload extends InvokeEndpointInput {
|
|
14
|
+
invokeType: string;
|
|
15
|
+
}
|
|
16
|
+
export declare const _invokeEndpointFn: (invokeType: InvokeType) => (input: InvokeEndpointInput) => Promise<InvokeResponse>;
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=invoke-endpoint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invoke-endpoint.d.ts","sourceRoot":"","sources":["../../src/invoke-endpoint/invoke-endpoint.ts"],"names":[],"mappings":"AAEA,OAAO,EAAiB,cAAc,EAAE,MAAM,UAAU,CAAC;AAOzD,aAAK,UAAU,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;AAE9D,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,UAAU,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,oBAAY,UAAU;IACpB,MAAM,WAAW;IACjB,OAAO,cAAc;CACtB;AAED,MAAM,WAAW,iBAAkB,SAAQ,mBAAmB;IAC5D,UAAU,EAAE,MAAM,CAAC;CACpB;AAoCD,eAAO,MAAM,iBAAiB,eAChB,UAAU,aACZ,mBAAmB,KAAK,QAAQ,cAAc,CASzD,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports._invokeEndpointFn = exports.InvokeType = void 0;
|
|
4
|
+
const bridge_1 = require("../bridge");
|
|
5
|
+
const errors_1 = require("../errors");
|
|
6
|
+
const utils_1 = require("../utils");
|
|
7
|
+
const MAX_NUM_OPERATIONS = 500;
|
|
8
|
+
const OPERATION_INTERVAL_SEC = 25;
|
|
9
|
+
const OPERATION_INTERVAL_MS = 1000 * OPERATION_INTERVAL_SEC;
|
|
10
|
+
var InvokeType;
|
|
11
|
+
(function (InvokeType) {
|
|
12
|
+
InvokeType["REMOTE"] = "Remote";
|
|
13
|
+
InvokeType["SERVICE"] = "Container";
|
|
14
|
+
})(InvokeType = exports.InvokeType || (exports.InvokeType = {}));
|
|
15
|
+
const callBridge = (0, bridge_1.getCallBridge)();
|
|
16
|
+
const validatePayload = (payload) => {
|
|
17
|
+
if (!payload)
|
|
18
|
+
return;
|
|
19
|
+
if (Object.values(payload).some((val) => typeof val === 'function')) {
|
|
20
|
+
throw new errors_1.BridgeAPIError('Passing functions as part of the payload is not supported!');
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
const _setupInvokeEndpointFn = (invokeType) => async (input) => {
|
|
24
|
+
validatePayload(input);
|
|
25
|
+
const callBridgePayload = {
|
|
26
|
+
...input,
|
|
27
|
+
invokeType: `ui-${invokeType.toLowerCase()}-fetch`
|
|
28
|
+
};
|
|
29
|
+
const bridgeResponse = await callBridge('invoke', callBridgePayload);
|
|
30
|
+
const { success, payload, error } = bridgeResponse !== null && bridgeResponse !== void 0 ? bridgeResponse : {};
|
|
31
|
+
const response = { ...(success ? payload : error) };
|
|
32
|
+
if (response && response.headers) {
|
|
33
|
+
for (const header in response.headers) {
|
|
34
|
+
if (Array.isArray(response.headers[header])) {
|
|
35
|
+
response.headers[header] = response.headers[header].join(',');
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return response;
|
|
40
|
+
};
|
|
41
|
+
const _invokeEndpointFn = (invokeType) => {
|
|
42
|
+
const invokeEndpointFn = _setupInvokeEndpointFn(invokeType);
|
|
43
|
+
return (0, utils_1.withRateLimiter)(invokeEndpointFn, MAX_NUM_OPERATIONS, OPERATION_INTERVAL_MS, `${invokeType} invocation calls are rate limited at ${MAX_NUM_OPERATIONS}/${OPERATION_INTERVAL_SEC}s`);
|
|
44
|
+
};
|
|
45
|
+
exports._invokeEndpointFn = _invokeEndpointFn;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { InvokeEndpointInput } from './invoke-endpoint';
|
|
2
|
+
export declare type InvokeRemoteInput = InvokeEndpointInput;
|
|
3
|
+
export declare const invokeRemote: (input: InvokeRemoteInput) => Promise<import("../types").InvokeResponse>;
|
|
4
|
+
//# sourceMappingURL=invoke-remote.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invoke-remote.d.ts","sourceRoot":"","sources":["../../src/invoke-endpoint/invoke-remote.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,mBAAmB,EAAc,MAAM,mBAAmB,CAAC;AAEvF,oBAAY,iBAAiB,GAAG,mBAAmB,CAAC;AAEpD,eAAO,MAAM,YAAY,UAAW,iBAAiB,+CAIpD,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.invokeRemote = void 0;
|
|
4
|
+
const invoke_endpoint_1 = require("./invoke-endpoint");
|
|
5
|
+
const invokeRemote = (input) => {
|
|
6
|
+
const invokeEndpoint = (0, invoke_endpoint_1._invokeEndpointFn)(invoke_endpoint_1.InvokeType.REMOTE);
|
|
7
|
+
return invokeEndpoint(input);
|
|
8
|
+
};
|
|
9
|
+
exports.invokeRemote = invokeRemote;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { InvokeEndpointInput } from './invoke-endpoint';
|
|
2
|
+
export declare type InvokeServiceInput = InvokeEndpointInput;
|
|
3
|
+
export declare const invokeService: (input: InvokeServiceInput) => Promise<import("../types").InvokeResponse>;
|
|
4
|
+
//# sourceMappingURL=invoke-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invoke-service.d.ts","sourceRoot":"","sources":["../../src/invoke-endpoint/invoke-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,mBAAmB,EAAc,MAAM,mBAAmB,CAAC;AAEvF,oBAAY,kBAAkB,GAAG,mBAAmB,CAAC;AAErD,eAAO,MAAM,aAAa,UAAW,kBAAkB,+CAItD,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.invokeService = void 0;
|
|
4
|
+
const invoke_endpoint_1 = require("./invoke-endpoint");
|
|
5
|
+
const invokeService = (input) => {
|
|
6
|
+
const invokeEndpoint = (0, invoke_endpoint_1._invokeEndpointFn)(invoke_endpoint_1.InvokeType.SERVICE);
|
|
7
|
+
return invokeEndpoint(input);
|
|
8
|
+
};
|
|
9
|
+
exports.invokeService = invokeService;
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/invoke-remote/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export interface InvokeRemoteInput {
|
|
2
|
-
path: string;
|
|
3
|
-
method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
4
|
-
headers?: Record<string, string>;
|
|
5
|
-
body?: unknown;
|
|
6
|
-
}
|
|
7
|
-
export declare const invokeRemote: <T>(input: InvokeRemoteInput) => Promise<T>;
|
|
8
|
-
//# sourceMappingURL=invoke-remote.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"invoke-remote.d.ts","sourceRoot":"","sources":["../../src/invoke-remote/invoke-remote.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;IACpD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AA6BD,eAAO,MAAM,YAAY,6CAKxB,CAAC"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.invokeRemote = void 0;
|
|
4
|
-
const bridge_1 = require("../bridge");
|
|
5
|
-
const errors_1 = require("../errors");
|
|
6
|
-
const utils_1 = require("../utils");
|
|
7
|
-
const MAX_NUM_OPERATIONS = 500;
|
|
8
|
-
const OPERATION_INTERVAL_MS = 1000 * 25;
|
|
9
|
-
const callBridge = (0, bridge_1.getCallBridge)();
|
|
10
|
-
const validatePayload = (payload) => {
|
|
11
|
-
if (!payload)
|
|
12
|
-
return;
|
|
13
|
-
if (Object.values(payload).some((val) => typeof val === 'function')) {
|
|
14
|
-
throw new errors_1.BridgeAPIError('Passing functions as part of the payload is not supported!');
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
const _invokeRemote = async (input) => {
|
|
18
|
-
var _a;
|
|
19
|
-
validatePayload(input);
|
|
20
|
-
const { success, payload, error } = (_a = (await callBridge('invoke', input))) !== null && _a !== void 0 ? _a : {};
|
|
21
|
-
const response = { ...(success ? payload : error) };
|
|
22
|
-
if (response && response.headers) {
|
|
23
|
-
for (const header in response.headers) {
|
|
24
|
-
if (Array.isArray(response.headers[header])) {
|
|
25
|
-
response.headers[header] = response.headers[header].join(',');
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return response;
|
|
30
|
-
};
|
|
31
|
-
exports.invokeRemote = (0, utils_1.withRateLimiter)(_invokeRemote, MAX_NUM_OPERATIONS, OPERATION_INTERVAL_MS, 'Remote invocation calls are rate limited at 500req/25s');
|