@forge/bridge
Advanced tools
Comparing version 0.0.0-experimental-819498d to 0.0.0-experimental-869511d
# @forge/bridge | ||
## 0.0.0-experimental-819498d | ||
## 0.0.0-experimental-869511d | ||
### Patch Changes | ||
- 869511d: Change | ||
- 97ce1f3: update history.location in bridge when route changes | ||
- 869511d: Add | ||
## 2.2.1-next.0 | ||
### Patch Changes | ||
- 97ce1f3: update history.location in bridge when route changes | ||
## 2.2.0 | ||
### Minor Changes | ||
- 6fe6082: Ability to disable close on escape and overlay click for modals | ||
## 2.2.0-next.0 | ||
### Minor Changes | ||
- 6fe60823: Ability to disable close on escape and overlay click for modals | ||
## 2.1.3 | ||
### Patch Changes | ||
- 7c11b22: Improve error message for when the Custom UI bridge is not available | ||
## 2.1.3-next.0 | ||
### Patch Changes | ||
- 7c11b22: Improve error message for when the Custom UI bridge is not available | ||
## 2.1.2 | ||
### Patch Changes | ||
- 06edfce: Fix headers for some REST endpoints | ||
## 2.1.2-next.0 | ||
### Patch Changes | ||
- 06edfce: Fix headers for some REST endpoints | ||
## 2.1.1 | ||
### Patch Changes | ||
- abf359f: Enable requestJira and requestConfluence in Forge bridge to generate correct content type for form data | ||
## 2.1.1-next.0 | ||
### Patch Changes | ||
- abf359f: Enable requestJira and requestConfluence in Forge bridge to generate correct content type for form data | ||
## 2.1.0 | ||
### Minor Changes | ||
- 63e5561: Add submit method | ||
## 2.1.0-next.0 | ||
### Minor Changes | ||
- 63e5561: Add submit method | ||
## 2.0.0 | ||
### Major Changes | ||
- 2f07efb: Add new client-side 3LO requestJira and requestConfluence methods | ||
## 2.0.0-next.0 | ||
### Major Changes | ||
- 2f07efb: Add new client-side 3LO requestJira and requestConfluence methods | ||
## 1.5.0 | ||
### Minor Changes | ||
- c5aedc4: Move createHistory method into view namespace | ||
@@ -8,0 +94,0 @@ - 05977d4: Add modal api |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getCallBridge = void 0; | ||
exports.getCallBridge = function () { | ||
return window.__bridge.callBridge; | ||
const errors_1 = require("./errors"); | ||
function isBridgeAvailable(bridge) { | ||
return !!(bridge === null || bridge === void 0 ? void 0 : bridge.callBridge); | ||
} | ||
exports.getCallBridge = () => { | ||
if (!isBridgeAvailable(self.__bridge)) { | ||
throw new errors_1.BridgeAPIError(` | ||
Unable to establish a connection with the Custom UI bridge. | ||
If you are trying to run your app locally, Forge apps only work in the context of Atlassian products. Refer to https://go.atlassian.com/forge-tunneling-with-custom-ui for how to tunnel when using a local development server. | ||
`); | ||
} | ||
return self.__bridge.callBridge; | ||
}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.BridgeAPIError = void 0; | ||
var tslib_1 = require("tslib"); | ||
var BridgeAPIError = (function (_super) { | ||
tslib_1.__extends(BridgeAPIError, _super); | ||
function BridgeAPIError() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
return BridgeAPIError; | ||
}(Error)); | ||
class BridgeAPIError extends Error { | ||
} | ||
exports.BridgeAPIError = BridgeAPIError; |
@@ -5,2 +5,3 @@ export * from './invoke'; | ||
export * from './modal'; | ||
export * from './fetch'; | ||
//# sourceMappingURL=index.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
const tslib_1 = require("tslib"); | ||
tslib_1.__exportStar(require("./invoke"), exports); | ||
@@ -8,1 +8,2 @@ tslib_1.__exportStar(require("./view"), exports); | ||
tslib_1.__exportStar(require("./modal"), exports); | ||
tslib_1.__exportStar(require("./fetch"), exports); |
export * from './invoke'; | ||
export * from './requestJira'; | ||
export * from './requestConfluence'; | ||
//# sourceMappingURL=index.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
const tslib_1 = require("tslib"); | ||
tslib_1.__exportStar(require("./invoke"), exports); | ||
tslib_1.__exportStar(require("./requestJira"), exports); | ||
tslib_1.__exportStar(require("./requestConfluence"), exports); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.invoke = void 0; | ||
var bridge_1 = require("../bridge"); | ||
var errors_1 = require("../errors"); | ||
var utils_1 = require("../utils"); | ||
var callBridge = bridge_1.getCallBridge(); | ||
var validatePayload = function (payload) { | ||
const bridge_1 = require("../bridge"); | ||
const errors_1 = require("../errors"); | ||
const utils_1 = require("../utils"); | ||
const callBridge = bridge_1.getCallBridge(); | ||
const validatePayload = (payload) => { | ||
if (!payload) | ||
return; | ||
if (Object.values(payload).some(function (val) { return typeof val === 'function'; })) { | ||
if (Object.values(payload).some((val) => typeof val === 'function')) { | ||
throw new errors_1.BridgeAPIError('Passing functions as part of the payload is not supported!'); | ||
} | ||
}; | ||
var _invoke = function (functionKey, payload) { | ||
const _invoke = (functionKey, payload) => { | ||
if (typeof functionKey !== 'string') { | ||
@@ -20,4 +20,4 @@ throw new errors_1.BridgeAPIError('functionKey must be a string!'); | ||
validatePayload(payload); | ||
return callBridge('invoke', { functionKey: functionKey, payload: payload }); | ||
return callBridge('invoke', { functionKey, payload }); | ||
}; | ||
exports.invoke = utils_1.withRateLimiter(_invoke, 20, 2000, 'Resolver calls are rate limited at 20req/2s'); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
const tslib_1 = require("tslib"); | ||
tslib_1.__exportStar(require("./modal"), exports); |
@@ -6,2 +6,4 @@ export interface ModalOptions { | ||
context?: any; | ||
closeOnEscape?: boolean; | ||
closeOnOverlayClick?: boolean; | ||
} | ||
@@ -13,2 +15,4 @@ export declare class Modal { | ||
context: any; | ||
closeOnEscape: boolean; | ||
closeOnOverlayClick: boolean; | ||
constructor(opts?: ModalOptions); | ||
@@ -15,0 +19,0 @@ open(): Promise<void>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Modal = void 0; | ||
var tslib_1 = require("tslib"); | ||
var bridge_1 = require("../bridge"); | ||
var errors_1 = require("../errors"); | ||
var callBridge = bridge_1.getCallBridge(); | ||
var noop = function () { }; | ||
var Modal = (function () { | ||
function Modal(opts) { | ||
const tslib_1 = require("tslib"); | ||
const bridge_1 = require("../bridge"); | ||
const errors_1 = require("../errors"); | ||
const callBridge = bridge_1.getCallBridge(); | ||
const noop = () => { }; | ||
class Modal { | ||
constructor(opts) { | ||
var _a, _b; | ||
this.resource = (opts === null || opts === void 0 ? void 0 : opts.resource) || null; | ||
@@ -15,32 +16,26 @@ this.onClose = (opts === null || opts === void 0 ? void 0 : opts.onClose) || noop; | ||
this.context = (opts === null || opts === void 0 ? void 0 : opts.context) || {}; | ||
this.closeOnEscape = (_a = opts === null || opts === void 0 ? void 0 : opts.closeOnEscape) !== null && _a !== void 0 ? _a : true; | ||
this.closeOnOverlayClick = (_b = opts === null || opts === void 0 ? void 0 : opts.closeOnOverlayClick) !== null && _b !== void 0 ? _b : true; | ||
} | ||
Modal.prototype.open = function () { | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var success, err_1; | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
_a.trys.push([0, 2, , 3]); | ||
return [4, callBridge('openModal', { | ||
resource: this.resource, | ||
onClose: this.onClose, | ||
size: this.size, | ||
context: this.context | ||
})]; | ||
case 1: | ||
success = _a.sent(); | ||
if (success === false) { | ||
throw new errors_1.BridgeAPIError('Unable to open modal.'); | ||
} | ||
return [3, 3]; | ||
case 2: | ||
err_1 = _a.sent(); | ||
throw new errors_1.BridgeAPIError('Unable to open modal.'); | ||
case 3: return [2]; | ||
open() { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
try { | ||
const success = yield callBridge('openModal', { | ||
resource: this.resource, | ||
onClose: this.onClose, | ||
size: this.size, | ||
context: this.context, | ||
closeOnEscape: this.closeOnEscape, | ||
closeOnOverlayClick: this.closeOnOverlayClick | ||
}); | ||
if (success === false) { | ||
throw new errors_1.BridgeAPIError('Unable to open modal.'); | ||
} | ||
}); | ||
} | ||
catch (err) { | ||
throw new errors_1.BridgeAPIError('Unable to open modal.'); | ||
} | ||
}); | ||
}; | ||
return Modal; | ||
}()); | ||
} | ||
} | ||
exports.Modal = Modal; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
const tslib_1 = require("tslib"); | ||
tslib_1.__exportStar(require("./router"), exports); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.router = void 0; | ||
var tslib_1 = require("tslib"); | ||
var bridge_1 = require("../bridge"); | ||
var callBridge = bridge_1.getCallBridge(); | ||
var navigate = function (url) { return tslib_1.__awaiter(void 0, void 0, void 0, function () { return tslib_1.__generator(this, function (_a) { | ||
return [2, callBridge('navigate', { url: url, type: 'same-tab' })]; | ||
}); }); }; | ||
var open = function (url) { return tslib_1.__awaiter(void 0, void 0, void 0, function () { return tslib_1.__generator(this, function (_a) { | ||
return [2, callBridge('navigate', { url: url, type: 'new-tab' })]; | ||
}); }); }; | ||
const tslib_1 = require("tslib"); | ||
const bridge_1 = require("../bridge"); | ||
const callBridge = bridge_1.getCallBridge(); | ||
const navigate = (url) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { return callBridge('navigate', { url, type: 'same-tab' }); }); | ||
const open = (url) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { return callBridge('navigate', { url, type: 'new-tab' }); }); | ||
exports.router = { | ||
navigate: navigate, | ||
open: open | ||
navigate, | ||
open | ||
}; |
@@ -5,6 +5,6 @@ export declare type InvokePayload = { | ||
export declare type InvokeResponse = Record<string, any> | void; | ||
export declare type ProductResponse = { | ||
body: any; | ||
} & Pick<Response, 'ok' | 'status' | 'statusText'>; | ||
export declare type ProductFetchResponse = { | ||
body?: string; | ||
} & Pick<ResponseInit, 'headers' | 'status' | 'statusText'>; | ||
export declare type FullContext = {}; | ||
//# sourceMappingURL=types.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.withRateLimiter = void 0; | ||
var tslib_1 = require("tslib"); | ||
var errors_1 = require("../errors"); | ||
exports.withRateLimiter = function (wrappedFn, maxOps, intervalInMs, exceededErrorMessage) { | ||
var start = Date.now(); | ||
var numOps = 0; | ||
return function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
const tslib_1 = require("tslib"); | ||
const errors_1 = require("../errors"); | ||
exports.withRateLimiter = (wrappedFn, maxOps, intervalInMs, exceededErrorMessage) => { | ||
let start = Date.now(); | ||
let numOps = 0; | ||
return (...args) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { | ||
const now = Date.now(); | ||
const elapsed = now - start; | ||
if (elapsed > intervalInMs) { | ||
start = now; | ||
numOps = 0; | ||
} | ||
return tslib_1.__awaiter(void 0, void 0, void 0, function () { | ||
var now, elapsed; | ||
return tslib_1.__generator(this, function (_a) { | ||
now = Date.now(); | ||
elapsed = now - start; | ||
if (elapsed > intervalInMs) { | ||
start = now; | ||
numOps = 0; | ||
} | ||
if (numOps >= maxOps) { | ||
throw new errors_1.BridgeAPIError(exceededErrorMessage || 'Too many invocations.'); | ||
} | ||
numOps = numOps + 1; | ||
return [2, wrappedFn.apply(void 0, args)]; | ||
}); | ||
}); | ||
}; | ||
if (numOps >= maxOps) { | ||
throw new errors_1.BridgeAPIError(exceededErrorMessage || 'Too many invocations.'); | ||
} | ||
numOps = numOps + 1; | ||
return wrappedFn(...args); | ||
}); | ||
}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.close = void 0; | ||
var tslib_1 = require("tslib"); | ||
var bridge_1 = require("../bridge"); | ||
var errors_1 = require("../errors"); | ||
var callBridge = bridge_1.getCallBridge(); | ||
exports.close = function (payload) { return tslib_1.__awaiter(void 0, void 0, void 0, function () { | ||
var success, e_1; | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
_a.trys.push([0, 2, , 3]); | ||
return [4, callBridge('close', payload)]; | ||
case 1: | ||
success = _a.sent(); | ||
if (success === false) { | ||
throw new errors_1.BridgeAPIError("this resource's view is not closable."); | ||
} | ||
return [3, 3]; | ||
case 2: | ||
e_1 = _a.sent(); | ||
throw new errors_1.BridgeAPIError("this resource's view is not closable."); | ||
case 3: return [2]; | ||
const tslib_1 = require("tslib"); | ||
const bridge_1 = require("../bridge"); | ||
const errors_1 = require("../errors"); | ||
const callBridge = bridge_1.getCallBridge(); | ||
exports.close = (payload) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { | ||
try { | ||
const success = yield callBridge('close', payload); | ||
if (success === false) { | ||
throw new errors_1.BridgeAPIError("this resource's view is not closable."); | ||
} | ||
}); | ||
}); }; | ||
} | ||
catch (e) { | ||
throw new errors_1.BridgeAPIError("this resource's view is not closable."); | ||
} | ||
}); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createHistory = void 0; | ||
var bridge_1 = require("../bridge"); | ||
var callBridge = bridge_1.getCallBridge(); | ||
exports.createHistory = function () { | ||
return callBridge('createHistory'); | ||
}; | ||
const tslib_1 = require("tslib"); | ||
const bridge_1 = require("../bridge"); | ||
const callBridge = bridge_1.getCallBridge(); | ||
exports.createHistory = () => tslib_1.__awaiter(void 0, void 0, void 0, function* () { | ||
const history = yield callBridge('createHistory'); | ||
history.listen((location) => { | ||
history.location = location; | ||
}); | ||
return history; | ||
}); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getContext = void 0; | ||
var bridge_1 = require("../bridge"); | ||
var callBridge = bridge_1.getCallBridge(); | ||
exports.getContext = function () { | ||
const bridge_1 = require("../bridge"); | ||
const callBridge = bridge_1.getCallBridge(); | ||
exports.getContext = () => { | ||
return callBridge('getContext'); | ||
}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
const tslib_1 = require("tslib"); | ||
tslib_1.__exportStar(require("./view"), exports); |
export declare const view: { | ||
submit: (payload?: any) => Promise<void>; | ||
close: (payload?: any) => Promise<void>; | ||
@@ -3,0 +4,0 @@ createHistory: () => Promise<import("history").History<unknown>>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.view = void 0; | ||
var close_1 = require("./close"); | ||
var createHistory_1 = require("./createHistory"); | ||
var getContext_1 = require("./getContext"); | ||
const submit_1 = require("./submit"); | ||
const close_1 = require("./close"); | ||
const createHistory_1 = require("./createHistory"); | ||
const getContext_1 = require("./getContext"); | ||
exports.view = { | ||
submit: submit_1.submit, | ||
close: close_1.close, | ||
@@ -9,0 +11,0 @@ createHistory: createHistory_1.createHistory, |
{ | ||
"name": "@forge/bridge", | ||
"version": "0.0.0-experimental-819498d", | ||
"version": "0.0.0-experimental-869511d", | ||
"description": "Forge bridge API for custom UI apps", | ||
@@ -19,4 +19,5 @@ "author": "Atlassian", | ||
"history": "4.10.1", | ||
"isomorphic-fetch": "^3.0.0", | ||
"jest-date-mock": "^1.0.8" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
23420
60
311
3
3