@forge/bridge
7.3.0-next.17.2.2-next.0-experimental-65945d2
out/fetch/fetch.js~
out/fetch/fetch.jsModified+5−18
Index: package/out/fetch/fetch.js
===================================================================
--- package/out/fetch/fetch.js
+++ package/out/fetch/fetch.js
@@ -70,22 +70,10 @@
requestRemote: (remoteKey, fetchOptions) => fetch(remoteKey, fetchOptions)
};
};
exports.remoteFetchApi = remoteFetchApi;
-const validateRequestTarget = (target) => {
- const restPath = typeof target === 'string' ? target : target === null || target === void 0 ? void 0 : target.path;
- const contextAri = typeof target === 'string' ? undefined : target === null || target === void 0 ? void 0 : target.contextAri;
- if (!restPath || typeof restPath !== 'string') {
- throw new Error('Request target must be a path string or an object with a non-empty `path` string.');
- }
- if (contextAri !== undefined && (typeof contextAri !== 'string' || !contextAri.startsWith('ari:'))) {
- throw new Error(`Invalid contextAri '${String(contextAri)}'. Expected an ARI such as 'ari:cloud:jira::site/<cloudId>'.`);
- }
- return { restPath, contextAri };
-};
const productFetchApi = (callBridge) => {
- const fetch = async (product, target, init) => {
- const { restPath, contextAri } = validateRequestTarget(target);
+ const fetch = async (product, restPath, init) => {
const validatedInit = validateFetchOptions(init);
const { body: requestBody, headers: requestHeaders, isMultipartFormData } = await parseRequest('product', validatedInit);
// https://ecosystem.atlassian.net/browse/BUILD-1118 Skip xsrf check for oauth request
if (!requestHeaders.has('X-Atlassian-Token')) {
@@ -98,18 +86,17 @@
...validatedInit,
body: requestBody,
headers: [...requestHeaders.entries()]
},
- isMultipartFormData,
- ...(contextAri !== undefined ? { contextAri } : {})
+ isMultipartFormData
};
const { body, headers, statusText, status, isAttachment } = await callBridge('fetchProduct', fetchPayload);
const responseBody = isAttachment ? (0, blobParser_1.base64ToBlob)(body, headers['content-type']) : body;
return new Response(responseBody || null, { headers, status, statusText });
};
return {
- requestConfluence: (target, fetchOptions) => fetch('confluence', target, fetchOptions),
- requestJira: (target, fetchOptions) => fetch('jira', target, fetchOptions),
- requestBitbucket: (target, fetchOptions) => fetch('bitbucket', target, fetchOptions)
+ requestConfluence: (restPath, fetchOptions) => fetch('confluence', restPath, fetchOptions),
+ requestJira: (restPath, fetchOptions) => fetch('jira', restPath, fetchOptions),
+ requestBitbucket: (restPath, fetchOptions) => fetch('bitbucket', restPath, fetchOptions)
};
};
exports.productFetchApi = productFetchApi;