@forge/bridge
Advanced tools
Comparing version 0.0.0-experimental-906222c to 0.0.0-experimental-d18f8dd
# @forge/bridge | ||
## 0.0.0-experimental-906222c | ||
## 0.0.0-experimental-d18f8dd | ||
### Major Changes | ||
### Patch Changes | ||
- 906222c: Add new resolvers | ||
- d18f8dd: Force bump | ||
## 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 | ||
@@ -10,0 +34,0 @@ |
@@ -5,16 +5,8 @@ "use strict"; | ||
var tslib_1 = require("tslib"); | ||
var isHeadersInstance = function (headers) { | ||
return headers.entries !== undefined; | ||
}; | ||
var parseHeaders = function (headers) { | ||
if (!headers) | ||
return {}; | ||
return isHeadersInstance(headers) ? Object.fromEntries(headers.entries()) : headers; | ||
}; | ||
var parseBody = function (init) { return tslib_1.__awaiter(void 0, void 0, void 0, function () { | ||
var req, _a; | ||
var parseBodyAndHeaders = function (init) { return tslib_1.__awaiter(void 0, void 0, void 0, function () { | ||
var req, body, _a, headers; | ||
return tslib_1.__generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
req = new Request('', { body: init === null || init === void 0 ? void 0 : init.body, method: init === null || init === void 0 ? void 0 : init.method }); | ||
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 }); | ||
if (!(req.method !== 'GET')) return [3, 2]; | ||
@@ -28,3 +20,9 @@ return [4, req.text()]; | ||
_b.label = 3; | ||
case 3: return [2, _a]; | ||
case 3: | ||
body = _a; | ||
headers = Object.fromEntries(req.headers.entries()); | ||
return [2, { | ||
body: body, | ||
headers: headers | ||
}]; | ||
} | ||
@@ -35,5 +33,5 @@ }); | ||
var fetch = function (product, restPath, init) { return tslib_1.__awaiter(void 0, void 0, void 0, function () { | ||
var fetchPayload, _a, _b, _c, _d, body, headers, statusText, status; | ||
return tslib_1.__generator(this, function (_e) { | ||
switch (_e.label) { | ||
var fetchPayload, _a, _b, _c, body, headers, statusText, status; | ||
return tslib_1.__generator(this, function (_d) { | ||
switch (_d.label) { | ||
case 0: | ||
@@ -45,10 +43,9 @@ _a = { | ||
_b = [tslib_1.__assign({}, init)]; | ||
_c = {}; | ||
return [4, parseBody(init)]; | ||
return [4, parseBodyAndHeaders(init)]; | ||
case 1: | ||
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)])), | ||
fetchPayload = (_a.fetchRequestInit = tslib_1.__assign.apply(void 0, _b.concat([(_d.sent())])), | ||
_a); | ||
return [4, callBridge('fetchProduct', fetchPayload)]; | ||
case 2: | ||
_d = _e.sent(), body = _d.body, headers = _d.headers, statusText = _d.statusText, status = _d.status; | ||
_c = _d.sent(), body = _c.body, headers = _c.headers, statusText = _c.statusText, status = _c.status; | ||
return [2, new Response(body || null, { headers: headers, status: status, statusText: statusText })]; | ||
@@ -55,0 +52,0 @@ } |
import { InvokePayload } from '../types'; | ||
export declare const invoke: <T>(functionKey: string, payload?: InvokePayload | undefined) => Promise<T>; | ||
export declare const resolver: { | ||
get: (fullPath: string, options: RequestInit) => Promise<Response>; | ||
post: (fullPath: string, options: RequestInit) => Promise<Response>; | ||
put: (fullPath: string, options: RequestInit) => Promise<Response>; | ||
patch: (fullPath: string, options: RequestInit) => Promise<Response>; | ||
delete: (fullPath: string, options: RequestInit) => Promise<Response>; | ||
}; | ||
//# sourceMappingURL=invoke.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.resolver = exports.invoke = void 0; | ||
var tslib_1 = require("tslib"); | ||
exports.invoke = void 0; | ||
var bridge_1 = require("../bridge"); | ||
@@ -24,43 +23,1 @@ var errors_1 = require("../errors"); | ||
exports.invoke = utils_1.withRateLimiter(_invoke, 20, 2000, 'Resolver calls are rate limited at 20req/2s'); | ||
var parseQs = function (qs) { | ||
var query = {}; | ||
var items = qs.split('&'); | ||
items.forEach(function (item) { | ||
var _a = item.split('='), key = _a[0], value = _a[1]; | ||
query[key] = value; | ||
}); | ||
return query; | ||
}; | ||
var provisionResolverMethod = function (method) { | ||
return function (fullPath, options) { return tslib_1.__awaiter(void 0, void 0, void 0, function () { | ||
var _a, path, queryString, query, response; | ||
return tslib_1.__generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
_a = fullPath.split('?'), path = _a[0], queryString = _a[1]; | ||
query = parseQs(queryString); | ||
return [4, exports.invoke(path, { | ||
__meta: { | ||
headers: options.headers, | ||
body: options.body, | ||
query: query, | ||
method: method | ||
} | ||
})]; | ||
case 1: | ||
response = _b.sent(); | ||
return [2, new Response(response.body, { | ||
headers: new Headers(response.headers), | ||
status: response.statusCode | ||
})]; | ||
} | ||
}); | ||
}); }; | ||
}; | ||
exports.resolver = { | ||
get: provisionResolverMethod('GET'), | ||
post: provisionResolverMethod('POST'), | ||
put: provisionResolverMethod('PUT'), | ||
patch: provisionResolverMethod('PATCH'), | ||
delete: provisionResolverMethod('DELETE') | ||
}; |
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 submit_1 = require("./submit"); | ||
var close_1 = require("./close"); | ||
@@ -8,2 +9,3 @@ var createHistory_1 = require("./createHistory"); | ||
exports.view = { | ||
submit: submit_1.submit, | ||
close: close_1.close, | ||
@@ -10,0 +12,0 @@ createHistory: createHistory_1.createHistory, |
{ | ||
"name": "@forge/bridge", | ||
"version": "0.0.0-experimental-906222c", | ||
"version": "0.0.0-experimental-d18f8dd", | ||
"description": "Forge bridge API for custom UI apps", | ||
@@ -5,0 +5,0 @@ "author": "Atlassian", |
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
60
2
24070
360