@forge/bridge 0.0.0-experimental-d3a39c9 → 0.0.0-experimental-edeb51b
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 +71 -3
- package/out/bridge.d.ts.map +1 -1
- package/out/bridge.js +12 -2
- package/out/errors.js +2 -8
- package/out/fetch/fetch.d.ts.map +1 -1
- package/out/fetch/fetch.js +24 -54
- package/out/fetch/index.js +3 -3
- package/out/index.js +1 -1
- package/out/invoke/index.js +1 -1
- package/out/invoke/invoke.d.ts +0 -7
- package/out/invoke/invoke.d.ts.map +1 -1
- package/out/invoke/invoke.js +9 -52
- package/out/modal/index.js +1 -1
- package/out/modal/modal.d.ts +4 -0
- package/out/modal/modal.d.ts.map +1 -1
- package/out/modal/modal.js +29 -34
- package/out/router/index.js +1 -1
- package/out/router/router.js +7 -11
- package/out/utils/index.js +17 -26
- package/out/view/close.js +14 -23
- package/out/view/createHistory.d.ts.map +1 -1
- package/out/view/createHistory.js +10 -5
- package/out/view/getContext.js +3 -3
- package/out/view/index.js +1 -1
- package/out/view/submit.d.ts +2 -0
- package/out/view/submit.d.ts.map +1 -0
- package/out/view/submit.js +13 -0
- package/out/view/view.d.ts +1 -0
- package/out/view/view.d.ts.map +1 -1
- package/out/view/view.js +5 -3
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,10 +1,78 @@
|
|
|
1
1
|
# @forge/bridge
|
|
2
2
|
|
|
3
|
-
## 0.0.0-experimental-
|
|
3
|
+
## 0.0.0-experimental-edeb51b
|
|
4
4
|
|
|
5
|
-
###
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- f5350a5: Change
|
|
8
|
+
- 97ce1f3: update history.location in bridge when route changes
|
|
9
|
+
- 456c10c: Add
|
|
10
|
+
|
|
11
|
+
## 2.2.1-next.0
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- 97ce1f3: update history.location in bridge when route changes
|
|
16
|
+
|
|
17
|
+
## 2.2.0
|
|
18
|
+
|
|
19
|
+
### Minor Changes
|
|
20
|
+
|
|
21
|
+
- 6fe6082: Ability to disable close on escape and overlay click for modals
|
|
22
|
+
|
|
23
|
+
## 2.2.0-next.0
|
|
24
|
+
|
|
25
|
+
### Minor Changes
|
|
26
|
+
|
|
27
|
+
- 6fe60823: Ability to disable close on escape and overlay click for modals
|
|
28
|
+
|
|
29
|
+
## 2.1.3
|
|
30
|
+
|
|
31
|
+
### Patch Changes
|
|
32
|
+
|
|
33
|
+
- 7c11b22: Improve error message for when the Custom UI bridge is not available
|
|
34
|
+
|
|
35
|
+
## 2.1.3-next.0
|
|
36
|
+
|
|
37
|
+
### Patch Changes
|
|
38
|
+
|
|
39
|
+
- 7c11b22: Improve error message for when the Custom UI bridge is not available
|
|
40
|
+
|
|
41
|
+
## 2.1.2
|
|
42
|
+
|
|
43
|
+
### Patch Changes
|
|
44
|
+
|
|
45
|
+
- 06edfce: Fix headers for some REST endpoints
|
|
46
|
+
|
|
47
|
+
## 2.1.2-next.0
|
|
48
|
+
|
|
49
|
+
### Patch Changes
|
|
50
|
+
|
|
51
|
+
- 06edfce: Fix headers for some REST endpoints
|
|
52
|
+
|
|
53
|
+
## 2.1.1
|
|
54
|
+
|
|
55
|
+
### Patch Changes
|
|
56
|
+
|
|
57
|
+
- abf359f: Enable requestJira and requestConfluence in Forge bridge to generate correct content type for form data
|
|
58
|
+
|
|
59
|
+
## 2.1.1-next.0
|
|
60
|
+
|
|
61
|
+
### Patch Changes
|
|
62
|
+
|
|
63
|
+
- abf359f: Enable requestJira and requestConfluence in Forge bridge to generate correct content type for form data
|
|
64
|
+
|
|
65
|
+
## 2.1.0
|
|
66
|
+
|
|
67
|
+
### Minor Changes
|
|
68
|
+
|
|
69
|
+
- 63e5561: Add submit method
|
|
70
|
+
|
|
71
|
+
## 2.1.0-next.0
|
|
72
|
+
|
|
73
|
+
### Minor Changes
|
|
6
74
|
|
|
7
|
-
-
|
|
75
|
+
- 63e5561: Add submit method
|
|
8
76
|
|
|
9
77
|
## 2.0.0
|
|
10
78
|
|
package/out/bridge.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../src/bridge.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../src/bridge.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,aAAa,QAAO,MAAM,CAAC,UAAU,CAAC,CAAC,YAAY,CAS/D,CAAC"}
|
package/out/bridge.js
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getCallBridge = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
const errors_1 = require("./errors");
|
|
5
|
+
function isBridgeAvailable(bridge) {
|
|
6
|
+
return !!(bridge === null || bridge === void 0 ? void 0 : bridge.callBridge);
|
|
7
|
+
}
|
|
8
|
+
exports.getCallBridge = () => {
|
|
9
|
+
if (!isBridgeAvailable(self.__bridge)) {
|
|
10
|
+
throw new errors_1.BridgeAPIError(`
|
|
11
|
+
Unable to establish a connection with the Custom UI bridge.
|
|
12
|
+
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.
|
|
13
|
+
`);
|
|
14
|
+
}
|
|
15
|
+
return self.__bridge.callBridge;
|
|
6
16
|
};
|
package/out/errors.js
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BridgeAPIError = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
tslib_1.__extends(BridgeAPIError, _super);
|
|
7
|
-
function BridgeAPIError() {
|
|
8
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
9
|
-
}
|
|
10
|
-
return BridgeAPIError;
|
|
11
|
-
}(Error));
|
|
4
|
+
class BridgeAPIError extends Error {
|
|
5
|
+
}
|
|
12
6
|
exports.BridgeAPIError = BridgeAPIError;
|
package/out/fetch/fetch.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../src/fetch/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../src/fetch/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAqB1C,eAAO,MAAM,eAAe,eAAgB,UAAU,CAAC,OAAO,aAAa,CAAC;kCAuB1C,MAAM,6CAA+B,OAAO,CAAC,QAAQ,CAAC;4BAG5D,MAAM,6CAA+B,OAAO,CAAC,QAAQ,CAAC;CAGjF,CAAC"}
|
package/out/fetch/fetch.js
CHANGED
|
@@ -1,62 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.productFetchApi = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (!(req.method !== 'GET')) return [3, 2];
|
|
20
|
-
return [4, req.text()];
|
|
21
|
-
case 1:
|
|
22
|
-
_a = _b.sent();
|
|
23
|
-
return [3, 3];
|
|
24
|
-
case 2:
|
|
25
|
-
_a = null;
|
|
26
|
-
_b.label = 3;
|
|
27
|
-
case 3: return [2, _a];
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const parseBodyAndHeaders = (init) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
6
|
+
const req = new Request('', { body: init === null || init === void 0 ? void 0 : init.body, method: init === null || init === void 0 ? void 0 : init.method, headers: init === null || init === void 0 ? void 0 : init.headers });
|
|
7
|
+
const body = req.method !== 'GET' ? yield req.text() : null;
|
|
8
|
+
const headers = Object.fromEntries(req.headers.entries());
|
|
9
|
+
return {
|
|
10
|
+
body,
|
|
11
|
+
headers: new Headers(headers)
|
|
12
|
+
};
|
|
13
|
+
});
|
|
14
|
+
exports.productFetchApi = (callBridge) => {
|
|
15
|
+
const fetch = (product, restPath, init) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
+
const { body: requestBody, headers: requestHeaders } = yield parseBodyAndHeaders(init);
|
|
17
|
+
if (!requestHeaders.has('X-Atlassian-Token')) {
|
|
18
|
+
requestHeaders.set('X-Atlassian-Token', 'no-check');
|
|
28
19
|
}
|
|
20
|
+
const fetchPayload = {
|
|
21
|
+
product,
|
|
22
|
+
restPath,
|
|
23
|
+
fetchRequestInit: Object.assign(Object.assign({}, init), { body: requestBody, headers: [...requestHeaders.entries()] })
|
|
24
|
+
};
|
|
25
|
+
const { body, headers, statusText, status } = yield callBridge('fetchProduct', fetchPayload);
|
|
26
|
+
return new Response(body || null, { headers, status, statusText });
|
|
29
27
|
});
|
|
30
|
-
}); };
|
|
31
|
-
exports.productFetchApi = function (callBridge) {
|
|
32
|
-
var fetch = function (product, restPath, init) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
33
|
-
var fetchPayload, _a, _b, _c, _d, body, headers, statusText, status;
|
|
34
|
-
return tslib_1.__generator(this, function (_e) {
|
|
35
|
-
switch (_e.label) {
|
|
36
|
-
case 0:
|
|
37
|
-
_a = {
|
|
38
|
-
product: product,
|
|
39
|
-
restPath: restPath
|
|
40
|
-
};
|
|
41
|
-
_b = [tslib_1.__assign({}, init)];
|
|
42
|
-
_c = {};
|
|
43
|
-
return [4, parseBody(init)];
|
|
44
|
-
case 1:
|
|
45
|
-
fetchPayload = (_a.fetchRequestInit = tslib_1.__assign.apply(void 0, _b.concat([(_c.body = _e.sent(), _c.headers = parseHeaders(init === null || init === void 0 ? void 0 : init.headers), _c)])),
|
|
46
|
-
_a);
|
|
47
|
-
return [4, callBridge('fetchProduct', fetchPayload)];
|
|
48
|
-
case 2:
|
|
49
|
-
_d = _e.sent(), body = _d.body, headers = _d.headers, statusText = _d.statusText, status = _d.status;
|
|
50
|
-
return [2, new Response(body || null, { headers: headers, status: status, statusText: statusText })];
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
}); };
|
|
54
28
|
return {
|
|
55
|
-
requestConfluence:
|
|
56
|
-
|
|
57
|
-
},
|
|
58
|
-
requestJira: function (restPath, fetchOptions) {
|
|
59
|
-
return fetch('jira', restPath, fetchOptions);
|
|
60
|
-
}
|
|
29
|
+
requestConfluence: (restPath, fetchOptions) => fetch('confluence', restPath, fetchOptions),
|
|
30
|
+
requestJira: (restPath, fetchOptions) => fetch('jira', restPath, fetchOptions)
|
|
61
31
|
};
|
|
62
32
|
};
|
package/out/fetch/index.js
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
var _a;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.requestJira = exports.requestConfluence = void 0;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
const bridge_1 = require("../bridge");
|
|
6
|
+
const fetch_1 = require("./fetch");
|
|
7
|
+
_a = fetch_1.productFetchApi(bridge_1.getCallBridge()), exports.requestConfluence = _a.requestConfluence, exports.requestJira = _a.requestJira;
|
package/out/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
4
|
tslib_1.__exportStar(require("./invoke"), exports);
|
|
5
5
|
tslib_1.__exportStar(require("./view"), exports);
|
|
6
6
|
tslib_1.__exportStar(require("./router"), exports);
|
package/out/invoke/index.js
CHANGED
package/out/invoke/invoke.d.ts
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
1
|
import { InvokePayload } from '../types';
|
|
2
2
|
export declare const invoke: <T>(functionKey: string, payload?: InvokePayload | undefined) => Promise<T>;
|
|
3
|
-
export declare const resolver: {
|
|
4
|
-
get: (fullPath: string, options?: RequestInit | undefined) => Promise<Response>;
|
|
5
|
-
post: (fullPath: string, options?: RequestInit | undefined) => Promise<Response>;
|
|
6
|
-
put: (fullPath: string, options?: RequestInit | undefined) => Promise<Response>;
|
|
7
|
-
patch: (fullPath: string, options?: RequestInit | undefined) => Promise<Response>;
|
|
8
|
-
delete: (fullPath: string, options?: RequestInit | undefined) => Promise<Response>;
|
|
9
|
-
};
|
|
10
3
|
//# sourceMappingURL=invoke.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invoke.d.ts","sourceRoot":"","sources":["../../src/invoke/invoke.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAkB,MAAM,UAAU,CAAC;AAsBzD,eAAO,MAAM,MAAM,6EAAoF,CAAC
|
|
1
|
+
{"version":3,"file":"invoke.d.ts","sourceRoot":"","sources":["../../src/invoke/invoke.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAkB,MAAM,UAAU,CAAC;AAsBzD,eAAO,MAAM,MAAM,6EAAoF,CAAC"}
|
package/out/invoke/invoke.js
CHANGED
|
@@ -1,65 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var validatePayload = function (payload) {
|
|
3
|
+
exports.invoke = void 0;
|
|
4
|
+
const bridge_1 = require("../bridge");
|
|
5
|
+
const errors_1 = require("../errors");
|
|
6
|
+
const utils_1 = require("../utils");
|
|
7
|
+
const callBridge = bridge_1.getCallBridge();
|
|
8
|
+
const validatePayload = (payload) => {
|
|
10
9
|
if (!payload)
|
|
11
10
|
return;
|
|
12
|
-
if (Object.values(payload).some(
|
|
11
|
+
if (Object.values(payload).some((val) => typeof val === 'function')) {
|
|
13
12
|
throw new errors_1.BridgeAPIError('Passing functions as part of the payload is not supported!');
|
|
14
13
|
}
|
|
15
14
|
};
|
|
16
|
-
|
|
15
|
+
const _invoke = (functionKey, payload) => {
|
|
17
16
|
if (typeof functionKey !== 'string') {
|
|
18
17
|
throw new errors_1.BridgeAPIError('functionKey must be a string!');
|
|
19
18
|
}
|
|
20
19
|
validatePayload(payload);
|
|
21
|
-
return callBridge('invoke', { functionKey
|
|
20
|
+
return callBridge('invoke', { functionKey, payload });
|
|
22
21
|
};
|
|
23
22
|
exports.invoke = utils_1.withRateLimiter(_invoke, 20, 2000, 'Resolver calls are rate limited at 20req/2s');
|
|
24
|
-
var parseQs = function (qs) {
|
|
25
|
-
var query = {};
|
|
26
|
-
var items = qs ? qs.split('&') : [];
|
|
27
|
-
items.forEach(function (item) {
|
|
28
|
-
var _a = item.split('='), key = _a[0], value = _a[1];
|
|
29
|
-
query[key] = value;
|
|
30
|
-
});
|
|
31
|
-
return query;
|
|
32
|
-
};
|
|
33
|
-
var provisionResolverMethod = function (method) {
|
|
34
|
-
return function (fullPath, options) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
35
|
-
var _a, path, queryString, query, response;
|
|
36
|
-
return tslib_1.__generator(this, function (_b) {
|
|
37
|
-
switch (_b.label) {
|
|
38
|
-
case 0:
|
|
39
|
-
_a = fullPath.split('?'), path = _a[0], queryString = _a[1];
|
|
40
|
-
query = parseQs(queryString);
|
|
41
|
-
return [4, exports.invoke(path, {
|
|
42
|
-
__meta: {
|
|
43
|
-
headers: options === null || options === void 0 ? void 0 : options.headers,
|
|
44
|
-
body: options === null || options === void 0 ? void 0 : options.body,
|
|
45
|
-
query: query,
|
|
46
|
-
method: method
|
|
47
|
-
}
|
|
48
|
-
})];
|
|
49
|
-
case 1:
|
|
50
|
-
response = _b.sent();
|
|
51
|
-
return [2, new Response(response.body, {
|
|
52
|
-
headers: new Headers(response.headers),
|
|
53
|
-
status: response.statusCode
|
|
54
|
-
})];
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
}); };
|
|
58
|
-
};
|
|
59
|
-
exports.resolver = {
|
|
60
|
-
get: provisionResolverMethod('GET'),
|
|
61
|
-
post: provisionResolverMethod('POST'),
|
|
62
|
-
put: provisionResolverMethod('PUT'),
|
|
63
|
-
patch: provisionResolverMethod('PATCH'),
|
|
64
|
-
delete: provisionResolverMethod('DELETE')
|
|
65
|
-
};
|
package/out/modal/index.js
CHANGED
package/out/modal/modal.d.ts
CHANGED
|
@@ -3,12 +3,16 @@ export interface ModalOptions {
|
|
|
3
3
|
onClose?: (payload: any) => any;
|
|
4
4
|
size?: string;
|
|
5
5
|
context?: any;
|
|
6
|
+
closeOnEscape?: boolean;
|
|
7
|
+
closeOnOverlayClick?: boolean;
|
|
6
8
|
}
|
|
7
9
|
export declare class Modal {
|
|
8
10
|
resource: string | null;
|
|
9
11
|
onClose: NonNullable<ModalOptions['onClose']>;
|
|
10
12
|
size: string;
|
|
11
13
|
context: any;
|
|
14
|
+
closeOnEscape: boolean;
|
|
15
|
+
closeOnOverlayClick: boolean;
|
|
12
16
|
constructor(opts?: ModalOptions);
|
|
13
17
|
open(): Promise<void>;
|
|
14
18
|
}
|
package/out/modal/modal.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal.d.ts","sourceRoot":"","sources":["../../src/modal/modal.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,GAAG,CAAC;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,GAAG,CAAC;
|
|
1
|
+
{"version":3,"file":"modal.d.ts","sourceRoot":"","sources":["../../src/modal/modal.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,GAAG,CAAC;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAKD,qBAAa,KAAK;IAChB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,OAAO,EAAE,WAAW,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC;IAC9C,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,GAAG,CAAC;IACb,aAAa,EAAE,OAAO,CAAC;IACvB,mBAAmB,EAAE,OAAO,CAAC;gBACjB,IAAI,CAAC,EAAE,YAAY;IASzB,IAAI;CAkBX"}
|
package/out/modal/modal.js
CHANGED
|
@@ -1,45 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Modal = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const bridge_1 = require("../bridge");
|
|
6
|
+
const errors_1 = require("../errors");
|
|
7
|
+
const callBridge = bridge_1.getCallBridge();
|
|
8
|
+
const noop = () => { };
|
|
9
|
+
class Modal {
|
|
10
|
+
constructor(opts) {
|
|
11
|
+
var _a, _b;
|
|
11
12
|
this.resource = (opts === null || opts === void 0 ? void 0 : opts.resource) || null;
|
|
12
13
|
this.onClose = (opts === null || opts === void 0 ? void 0 : opts.onClose) || noop;
|
|
13
14
|
this.size = (opts === null || opts === void 0 ? void 0 : opts.size) || 'medium';
|
|
14
15
|
this.context = (opts === null || opts === void 0 ? void 0 : opts.context) || {};
|
|
16
|
+
this.closeOnEscape = (_a = opts === null || opts === void 0 ? void 0 : opts.closeOnEscape) !== null && _a !== void 0 ? _a : true;
|
|
17
|
+
this.closeOnOverlayClick = (_b = opts === null || opts === void 0 ? void 0 : opts.closeOnOverlayClick) !== null && _b !== void 0 ? _b : true;
|
|
15
18
|
}
|
|
16
|
-
|
|
17
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
case 1:
|
|
30
|
-
success = _a.sent();
|
|
31
|
-
if (success === false) {
|
|
32
|
-
throw new errors_1.BridgeAPIError('Unable to open modal.');
|
|
33
|
-
}
|
|
34
|
-
return [3, 3];
|
|
35
|
-
case 2:
|
|
36
|
-
err_1 = _a.sent();
|
|
37
|
-
throw new errors_1.BridgeAPIError('Unable to open modal.');
|
|
38
|
-
case 3: return [2];
|
|
19
|
+
open() {
|
|
20
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
try {
|
|
22
|
+
const success = yield callBridge('openModal', {
|
|
23
|
+
resource: this.resource,
|
|
24
|
+
onClose: this.onClose,
|
|
25
|
+
size: this.size,
|
|
26
|
+
context: this.context,
|
|
27
|
+
closeOnEscape: this.closeOnEscape,
|
|
28
|
+
closeOnOverlayClick: this.closeOnOverlayClick
|
|
29
|
+
});
|
|
30
|
+
if (success === false) {
|
|
31
|
+
throw new errors_1.BridgeAPIError('Unable to open modal.');
|
|
39
32
|
}
|
|
40
|
-
}
|
|
33
|
+
}
|
|
34
|
+
catch (err) {
|
|
35
|
+
throw new errors_1.BridgeAPIError('Unable to open modal.');
|
|
36
|
+
}
|
|
41
37
|
});
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
}());
|
|
38
|
+
}
|
|
39
|
+
}
|
|
45
40
|
exports.Modal = Modal;
|
package/out/router/index.js
CHANGED
package/out/router/router.js
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.router = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}); }); };
|
|
10
|
-
var open = function (url) { return tslib_1.__awaiter(void 0, void 0, void 0, function () { return tslib_1.__generator(this, function (_a) {
|
|
11
|
-
return [2, callBridge('navigate', { url: url, type: 'new-tab' })];
|
|
12
|
-
}); }); };
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const bridge_1 = require("../bridge");
|
|
6
|
+
const callBridge = bridge_1.getCallBridge();
|
|
7
|
+
const navigate = (url) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { return callBridge('navigate', { url, type: 'same-tab' }); });
|
|
8
|
+
const open = (url) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { return callBridge('navigate', { url, type: 'new-tab' }); });
|
|
13
9
|
exports.router = {
|
|
14
|
-
navigate
|
|
15
|
-
open
|
|
10
|
+
navigate,
|
|
11
|
+
open
|
|
16
12
|
};
|
package/out/utils/index.js
CHANGED
|
@@ -1,31 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.withRateLimiter = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports.withRateLimiter =
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return function () {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const errors_1 = require("../errors");
|
|
6
|
+
exports.withRateLimiter = (wrappedFn, maxOps, intervalInMs, exceededErrorMessage) => {
|
|
7
|
+
let start = Date.now();
|
|
8
|
+
let numOps = 0;
|
|
9
|
+
return (...args) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
10
|
+
const now = Date.now();
|
|
11
|
+
const elapsed = now - start;
|
|
12
|
+
if (elapsed > intervalInMs) {
|
|
13
|
+
start = now;
|
|
14
|
+
numOps = 0;
|
|
13
15
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
start = now;
|
|
21
|
-
numOps = 0;
|
|
22
|
-
}
|
|
23
|
-
if (numOps >= maxOps) {
|
|
24
|
-
throw new errors_1.BridgeAPIError(exceededErrorMessage || 'Too many invocations.');
|
|
25
|
-
}
|
|
26
|
-
numOps = numOps + 1;
|
|
27
|
-
return [2, wrappedFn.apply(void 0, args)];
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
};
|
|
16
|
+
if (numOps >= maxOps) {
|
|
17
|
+
throw new errors_1.BridgeAPIError(exceededErrorMessage || 'Too many invocations.');
|
|
18
|
+
}
|
|
19
|
+
numOps = numOps + 1;
|
|
20
|
+
return wrappedFn(...args);
|
|
21
|
+
});
|
|
31
22
|
};
|
package/out/view/close.js
CHANGED
|
@@ -1,27 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.close = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
exports.close =
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
_a.trys.push([0, 2, , 3]);
|
|
14
|
-
return [4, callBridge('close', payload)];
|
|
15
|
-
case 1:
|
|
16
|
-
success = _a.sent();
|
|
17
|
-
if (success === false) {
|
|
18
|
-
throw new errors_1.BridgeAPIError("this resource's view is not closable.");
|
|
19
|
-
}
|
|
20
|
-
return [3, 3];
|
|
21
|
-
case 2:
|
|
22
|
-
e_1 = _a.sent();
|
|
23
|
-
throw new errors_1.BridgeAPIError("this resource's view is not closable.");
|
|
24
|
-
case 3: return [2];
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const bridge_1 = require("../bridge");
|
|
6
|
+
const errors_1 = require("../errors");
|
|
7
|
+
const callBridge = bridge_1.getCallBridge();
|
|
8
|
+
exports.close = (payload) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
9
|
+
try {
|
|
10
|
+
const success = yield callBridge('close', payload);
|
|
11
|
+
if (success === false) {
|
|
12
|
+
throw new errors_1.BridgeAPIError("this resource's view is not closable.");
|
|
25
13
|
}
|
|
26
|
-
}
|
|
27
|
-
|
|
14
|
+
}
|
|
15
|
+
catch (e) {
|
|
16
|
+
throw new errors_1.BridgeAPIError("this resource's view is not closable.");
|
|
17
|
+
}
|
|
18
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createHistory.d.ts","sourceRoot":"","sources":["../../src/view/createHistory.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAIvC,eAAO,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"createHistory.d.ts","sourceRoot":"","sources":["../../src/view/createHistory.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAIvC,eAAO,MAAM,aAAa,QAAa,OAAO,CAAC,OAAO,CAOrD,CAAC"}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createHistory = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const bridge_1 = require("../bridge");
|
|
6
|
+
const callBridge = bridge_1.getCallBridge();
|
|
7
|
+
exports.createHistory = () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
8
|
+
const history = yield callBridge('createHistory');
|
|
9
|
+
history.listen((location) => {
|
|
10
|
+
history.location = location;
|
|
11
|
+
});
|
|
12
|
+
return history;
|
|
13
|
+
});
|
package/out/view/getContext.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getContext = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports.getContext =
|
|
4
|
+
const bridge_1 = require("../bridge");
|
|
5
|
+
const callBridge = bridge_1.getCallBridge();
|
|
6
|
+
exports.getContext = () => {
|
|
7
7
|
return callBridge('getContext');
|
|
8
8
|
};
|
package/out/view/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"submit.d.ts","sourceRoot":"","sources":["../../src/view/submit.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,MAAM,aAAoB,GAAG,kBAKzC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.submit = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const bridge_1 = require("../bridge");
|
|
6
|
+
const errors_1 = require("../errors");
|
|
7
|
+
const callBridge = bridge_1.getCallBridge();
|
|
8
|
+
exports.submit = (payload) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
9
|
+
const success = yield callBridge('submit', payload);
|
|
10
|
+
if (success === false) {
|
|
11
|
+
throw new errors_1.BridgeAPIError("this resource's view is not submittable.");
|
|
12
|
+
}
|
|
13
|
+
});
|
package/out/view/view.d.ts
CHANGED
package/out/view/view.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../src/view/view.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../src/view/view.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,IAAI;;;;;CAKhB,CAAC"}
|
package/out/view/view.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.view = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
const submit_1 = require("./submit");
|
|
5
|
+
const close_1 = require("./close");
|
|
6
|
+
const createHistory_1 = require("./createHistory");
|
|
7
|
+
const getContext_1 = require("./getContext");
|
|
7
8
|
exports.view = {
|
|
9
|
+
submit: submit_1.submit,
|
|
8
10
|
close: close_1.close,
|
|
9
11
|
createHistory: createHistory_1.createHistory,
|
|
10
12
|
getContext: getContext_1.getContext
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forge/bridge",
|
|
3
|
-
"version": "0.0.0-experimental-
|
|
3
|
+
"version": "0.0.0-experimental-edeb51b",
|
|
4
4
|
"description": "Forge bridge API for custom UI apps",
|
|
5
5
|
"author": "Atlassian",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"history": "4.10.1",
|
|
19
|
-
"
|
|
20
|
-
"
|
|
19
|
+
"isomorphic-fetch": "^3.0.0",
|
|
20
|
+
"jest-date-mock": "^1.0.8"
|
|
21
21
|
}
|
|
22
22
|
}
|