@forge/bridge
Advanced tools
Comparing version 2.6.0-next.0 to 2.6.0-next.1
# @forge/bridge | ||
## 2.6.0-next.1 | ||
### Minor Changes | ||
- cf983b29: Fix for downloading binary data from requestJira/requestConfluence API calls | ||
## 2.6.0-next.0 | ||
@@ -4,0 +10,0 @@ |
@@ -5,8 +5,3 @@ "use strict"; | ||
const tslib_1 = require("tslib"); | ||
const toBase64 = (file) => new Promise((resolve, reject) => { | ||
const reader = new FileReader(); | ||
reader.readAsDataURL(file); | ||
reader.onload = () => resolve(reader.result); | ||
reader.onerror = (error) => reject(error); | ||
}); | ||
const blobParser_1 = require("../utils/blobParser"); | ||
const parseFormData = (form) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { | ||
@@ -18,3 +13,3 @@ const parsed = {}; | ||
const fileType = value.type; | ||
parsed['file'] = yield toBase64(value); | ||
parsed['file'] = yield (0, blobParser_1.blobToBase64)(value); | ||
parsed['__fileName'] = fileName; | ||
@@ -29,3 +24,3 @@ parsed['__fileType'] = fileType; | ||
}); | ||
const parseBodyAndHeaders = (init) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { | ||
const parseRequest = (init) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { | ||
const isFormData = (init === null || init === void 0 ? void 0 : init.body) instanceof FormData ? true : false; | ||
@@ -44,3 +39,3 @@ const requestBody = isFormData ? yield parseFormData(init === null || init === void 0 ? void 0 : init.body) : init === null || init === void 0 ? void 0 : init.body; | ||
const fetch = (product, restPath, init) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { | ||
const { body: requestBody, headers: requestHeaders, isMultipartFormData } = yield parseBodyAndHeaders(init); | ||
const { body: requestBody, headers: requestHeaders, isMultipartFormData } = yield parseRequest(init); | ||
if (!requestHeaders.has('X-Atlassian-Token')) { | ||
@@ -55,4 +50,5 @@ requestHeaders.set('X-Atlassian-Token', 'no-check'); | ||
}; | ||
const { body, headers, statusText, status } = yield callBridge('fetchProduct', fetchPayload); | ||
return new Response(body || null, { headers, status, statusText }); | ||
const { body, headers, statusText, status, isAttachment } = yield callBridge('fetchProduct', fetchPayload); | ||
const responseBody = isAttachment ? (0, blobParser_1.base64ToBlob)(body, headers['content-type']) : body; | ||
return new Response(responseBody || null, { headers, status, statusText }); | ||
}); | ||
@@ -59,0 +55,0 @@ return { |
@@ -7,3 +7,7 @@ export declare type InvokePayload = { | ||
body?: string; | ||
} & Pick<ResponseInit, 'headers' | 'status' | 'statusText'>; | ||
headers: { | ||
[key: string]: string; | ||
}; | ||
isAttachment?: boolean; | ||
} & Pick<ResponseInit, 'status' | 'statusText'>; | ||
export interface FullContext { | ||
@@ -10,0 +14,0 @@ accountId?: string; |
{ | ||
"name": "@forge/bridge", | ||
"version": "2.6.0-next.0", | ||
"version": "2.6.0-next.1", | ||
"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
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
38064
81
506