@forge/bridge 3.0.0 → 3.1.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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @forge/bridge
2
2
 
3
+ ## 3.1.0-next.0
4
+
5
+ ### Minor Changes
6
+
7
+ - baffae7: Add invokeRemote API to @forge/bridge
8
+
3
9
  ## 3.0.0
4
10
 
5
11
  ### Major Changes
package/out/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from './invoke';
2
+ export * from './invoke-remote';
2
3
  export * from './view';
3
4
  export * from './router';
4
5
  export * from './modal';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC"}
package/out/index.js CHANGED
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./invoke"), exports);
5
+ tslib_1.__exportStar(require("./invoke-remote"), exports);
5
6
  tslib_1.__exportStar(require("./view"), exports);
6
7
  tslib_1.__exportStar(require("./router"), exports);
7
8
  tslib_1.__exportStar(require("./modal"), exports);
@@ -0,0 +1,2 @@
1
+ export * from './invoke-remote';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/invoke-remote/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./invoke-remote"), exports);
@@ -0,0 +1,8 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.invokeRemote = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const bridge_1 = require("../bridge");
6
+ const errors_1 = require("../errors");
7
+ const utils_1 = require("../utils");
8
+ const MAX_NUM_OPERATIONS = 500;
9
+ const OPERATION_INTERVAL_MS = 1000 * 25;
10
+ const callBridge = (0, bridge_1.getCallBridge)();
11
+ const validatePayload = (payload) => {
12
+ if (!payload)
13
+ return;
14
+ if (Object.values(payload).some((val) => typeof val === 'function')) {
15
+ throw new errors_1.BridgeAPIError('Passing functions as part of the payload is not supported!');
16
+ }
17
+ };
18
+ const _invokeRemote = (input) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
19
+ var _a;
20
+ validatePayload(input);
21
+ const { success, payload, error } = (_a = (yield callBridge('invoke', input))) !== null && _a !== void 0 ? _a : {};
22
+ const response = Object.assign({}, (success ? payload : error));
23
+ if (response && response.headers) {
24
+ for (const header in response.headers) {
25
+ if (Array.isArray(response.headers[header])) {
26
+ response.headers[header] = response.headers[header].join(',');
27
+ }
28
+ }
29
+ }
30
+ return response;
31
+ });
32
+ exports.invokeRemote = (0, utils_1.withRateLimiter)(_invokeRemote, MAX_NUM_OPERATIONS, OPERATION_INTERVAL_MS, 'Remote invocation calls are rate limited at 500req/25s');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forge/bridge",
3
- "version": "3.0.0",
3
+ "version": "3.1.0-next.0",
4
4
  "description": "Forge bridge API for custom UI apps",
5
5
  "author": "Atlassian",
6
6
  "license": "UNLICENSED",