@forge/bridge 6.0.1-next.2-experimental-9423de1 → 6.0.1-next.3
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 +2 -5
- package/out/invoke/invoke.d.ts.map +1 -1
- package/out/invoke/invoke.js +3 -29
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
# @forge/bridge
|
|
2
2
|
|
|
3
|
-
## 6.0.1-next.
|
|
3
|
+
## 6.0.1-next.3
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
- Updated dependencies [c60a7a5]
|
|
9
|
-
- Updated dependencies [caa7518]
|
|
10
|
-
- @forge/manifest@13.1.0-next.2-experimental-9423de1
|
|
7
|
+
- 621000d: Update bridge call to include metadata argument
|
|
11
8
|
|
|
12
9
|
## 6.0.1-next.2
|
|
13
10
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invoke.d.ts","sourceRoot":"","sources":["../../src/invoke/invoke.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAInF,OAAO,
|
|
1
|
+
{"version":3,"file":"invoke.d.ts","sourceRoot":"","sources":["../../src/invoke/invoke.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAInF,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAyCzE;;;;;;;;;;GAUG;AACH,wBAAgB,MAAM,CAAC,OAAO,SAAS,aAAa,EAAE,CAAC,GAAG,cAAc,EACtE,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,OAAO,EAChB,QAAQ,CAAC,EAAE,cAAc,GACxB,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;AAE9B;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,CAAC,GAAG,cAAc,EACvC,WAAW,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE,aAAa,EACvB,QAAQ,CAAC,EAAE,cAAc,GACxB,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;AAa9B,KAAK,MAAM,CAAC,IAAI,SAAS,WAAW,IAAI,CAAC,GAAG,SAAS,MAAM,IAAI,GAAG,MAAM,EACtE,IAAI,EAAE,GAAG,EACT,GAAG,GAAG,EAAE,YAAY,CAAC,IAAI,EAAE,GAAG,CAAC,KAC5B,OAAO,CAAC,SAAS,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;AAEnC;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,SAAS,WAAW,KAAK,MAAM,CAAC,IAAI,CAAC,CAEnE"}
|
package/out/invoke/invoke.js
CHANGED
|
@@ -13,40 +13,14 @@ const validatePayload = (payload) => {
|
|
|
13
13
|
throw new errors_1.BridgeAPIError('Passing functions as part of the payload is not supported!');
|
|
14
14
|
}
|
|
15
15
|
};
|
|
16
|
-
/**
|
|
17
|
-
* While the rate limit metadata feature is being rolled out, the bridge may return either
|
|
18
|
-
* the resolver body directly or an object of shape `{ body, metadata }`, where the
|
|
19
|
-
* rate limit fields are reported under `metadata`.
|
|
20
|
-
*/
|
|
21
|
-
const isMetadataWrappedResponse = (response) => {
|
|
22
|
-
if (typeof response !== 'object' || response === null) {
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
const keys = Object.keys(response);
|
|
26
|
-
return keys.length === 2 && keys.includes('body') && keys.includes('metadata');
|
|
27
|
-
};
|
|
28
16
|
const _invoke = async (functionKey, payload, metadata) => {
|
|
29
|
-
var _a;
|
|
30
17
|
if (typeof functionKey !== 'string') {
|
|
31
18
|
throw new errors_1.BridgeAPIError('functionKey must be a string!');
|
|
32
19
|
}
|
|
33
20
|
validatePayload(payload);
|
|
34
|
-
|
|
35
|
-
//
|
|
36
|
-
|
|
37
|
-
// If the bridge response is not wrapped in metadata, return the metadata field as undefined.
|
|
38
|
-
if (!isMetadataWrappedResponse(response)) {
|
|
39
|
-
return { body: response, metadata: undefined };
|
|
40
|
-
}
|
|
41
|
-
const requestedMetadataKeys = Object.keys(metadata !== null && metadata !== void 0 ? metadata : {}).filter((key) => (metadata === null || metadata === void 0 ? void 0 : metadata[key]) === true);
|
|
42
|
-
const responseMetadata = {};
|
|
43
|
-
for (const key of requestedMetadataKeys) {
|
|
44
|
-
responseMetadata[key] = (_a = response.metadata) === null || _a === void 0 ? void 0 : _a[key];
|
|
45
|
-
}
|
|
46
|
-
return { body: response.body, metadata: responseMetadata };
|
|
47
|
-
}
|
|
48
|
-
// If metadata is not requested, return the response directly.
|
|
49
|
-
return (isMetadataWrappedResponse(response) ? response.body : response);
|
|
21
|
+
// When metadata is defined, the bridge returns the response wrapped in metadata as { body, metadata }
|
|
22
|
+
// Otherwise, the bridge returns the response directly
|
|
23
|
+
return await callBridge('invoke', { functionKey, payload, metadata });
|
|
50
24
|
};
|
|
51
25
|
const limitedInvoke = (0, utils_1.withRateLimiter)(_invoke, 500, 1000 * 25, 'Resolver calls are rate limited at 500req/25s');
|
|
52
26
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forge/bridge",
|
|
3
|
-
"version": "6.0.1-next.
|
|
3
|
+
"version": "6.0.1-next.3",
|
|
4
4
|
"description": "Forge bridge API for custom UI apps",
|
|
5
5
|
"author": "Atlassian",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"@forge/i18n": "1.0.0",
|
|
20
20
|
"@forge/resolver": "2.0.0",
|
|
21
21
|
"@types/history": "^4.7.11",
|
|
22
|
-
"@forge/manifest": "13.1.0-next.2
|
|
22
|
+
"@forge/manifest": "13.1.0-next.2",
|
|
23
23
|
"@types/iframe-resizer": "^3.5.8",
|
|
24
24
|
"iframe-resizer": "^4.4.5"
|
|
25
25
|
},
|