@forge/bridge
Advanced tools
Comparing version 0.1.0-next.2 to 0.1.0-next.3
# @forge/bridge | ||
## 0.1.0-next.3 | ||
### Patch Changes | ||
- 07e630d: Fix max retries timeout + add semver to global bridge object | ||
## 0.1.0-next.2 | ||
@@ -4,0 +10,0 @@ |
@@ -5,2 +5,3 @@ "use strict"; | ||
var __1 = require(".."); | ||
var errors_1 = require("../errors"); | ||
describe('invoke', function () { | ||
@@ -42,3 +43,3 @@ var callBridgeMock = jest.fn(); | ||
case 0: | ||
callBridgeMock.mockRejectedValueOnce(new Error('No handler found for post message: invoke ')); | ||
callBridgeMock.mockRejectedValueOnce(new errors_1.BridgeAPIError('No handler found for post message: invoke ')); | ||
return [4, __1.invoke('key')]; | ||
@@ -57,3 +58,3 @@ case 1: | ||
case 0: | ||
callBridgeMock.mockRejectedValue(new Error('No handler found for post message: invoke ')); | ||
callBridgeMock.mockRejectedValue(new errors_1.BridgeAPIError('No handler found for post message: invoke ')); | ||
_a.label = 1; | ||
@@ -68,2 +69,3 @@ case 1: | ||
err_1 = _a.sent(); | ||
expect(err_1).toBeInstanceOf(errors_1.BridgeAPIError); | ||
expect(callBridgeMock).toHaveBeenCalledTimes(10); | ||
@@ -70,0 +72,0 @@ return [3, 4]; |
@@ -5,2 +5,3 @@ "use strict"; | ||
var tslib_1 = require("tslib"); | ||
var errors_1 = require("./errors"); | ||
var delay = function (time) { return Promise.resolve(function (res) { return setTimeout(res, time); }); }; | ||
@@ -11,3 +12,3 @@ var validatePayload = function (payload) { | ||
if (Object.values(payload).some(function (val) { return typeof val === 'function'; })) { | ||
throw new Error('Passing functions as part of the payload is not supported!'); | ||
throw new errors_1.BridgeAPIError('Passing functions as part of the payload is not supported!'); | ||
} | ||
@@ -18,7 +19,7 @@ }; | ||
if (typeof functionKey !== 'string') { | ||
throw new Error('functionKey must be a string!'); | ||
throw new errors_1.BridgeAPIError('functionKey must be a string!'); | ||
} | ||
validatePayload(payload); | ||
var callBridge = window.__bridge.callBridge; | ||
var retriableInvoke = function (retryCount, error) { | ||
var retriableInvoke = function (retryCount) { | ||
if (retryCount === void 0) { retryCount = MAX_INVOKE_RETRIES; } | ||
@@ -31,3 +32,3 @@ return tslib_1.__awaiter(void 0, void 0, void 0, function () { | ||
if (retryCount <= 0) { | ||
throw error; | ||
throw new errors_1.BridgeAPIError("\n Unable to call invoke(). Product handler for this event was not found or is not ready yet\n "); | ||
} | ||
@@ -42,6 +43,6 @@ _a.label = 1; | ||
if (!(error_1 === null || error_1 === void 0 ? void 0 : error_1.message.startsWith('No handler found for post message: invoke'))) return [3, 5]; | ||
return [4, delay((MAX_INVOKE_RETRIES - retryCount + 1) * 50)]; | ||
return [4, delay((MAX_INVOKE_RETRIES - retryCount + 1) * 100)]; | ||
case 4: | ||
_a.sent(); | ||
return [2, retriableInvoke(--retryCount, error_1)]; | ||
return [2, retriableInvoke(--retryCount)]; | ||
case 5: throw error_1; | ||
@@ -48,0 +49,0 @@ case 6: return [3, 7]; |
{ | ||
"name": "@forge/bridge", | ||
"version": "0.1.0-next.2", | ||
"version": "0.1.0-next.3", | ||
"description": "Forge bridge API for custom UI apps", | ||
@@ -5,0 +5,0 @@ "author": "Atlassian", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8940
12
166