@resolution/atlassian-api-common 0.1.0
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/LICENSE.md +19 -0
- package/README.md +5 -0
- package/lib/ApiError.d.ts +13 -0
- package/lib/ApiError.js +20 -0
- package/lib/ApiError.js.map +1 -0
- package/lib/fetch/common/index.d.ts +2 -0
- package/lib/fetch/common/index.js +7 -0
- package/lib/fetch/common/index.js.map +1 -0
- package/lib/fetch/createAceFetch.d.ts +23 -0
- package/lib/fetch/createAceFetch.js +75 -0
- package/lib/fetch/createAceFetch.js.map +1 -0
- package/lib/fetch/createApFetch.d.ts +14 -0
- package/lib/fetch/createApFetch.js +91 -0
- package/lib/fetch/createApFetch.js.map +1 -0
- package/lib/fetch/createForgeApiExternalFetch.d.ts +16 -0
- package/lib/fetch/createForgeApiExternalFetch.js +64 -0
- package/lib/fetch/createForgeApiExternalFetch.js.map +1 -0
- package/lib/fetch/createForgeApiFetch.d.ts +19 -0
- package/lib/fetch/createForgeApiFetch.js +54 -0
- package/lib/fetch/createForgeApiFetch.js.map +1 -0
- package/lib/fetch/createForgeBridgeFetch.d.ts +10 -0
- package/lib/fetch/createForgeBridgeFetch.js +65 -0
- package/lib/fetch/createForgeBridgeFetch.js.map +1 -0
- package/lib/fetch/index.d.ts +12 -0
- package/lib/fetch/index.js +88 -0
- package/lib/fetch/index.js.map +1 -0
- package/lib/index.d.ts +7 -0
- package/lib/index.js +10 -0
- package/lib/index.js.map +1 -0
- package/package.json +44 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (c) 2024 resolution Reichert Network Solutions GmbH
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
|
11
|
+
all copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
+
THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { CommonHttpClientFetchRequest, CommonHttpClientFetchResponse, CommonHttpClientOptions } from "api-typescript-generator/openapi-client";
|
|
2
|
+
/**
|
|
3
|
+
* API Error for all API-Client libraries.
|
|
4
|
+
*
|
|
5
|
+
* Stored in common package in order to have the same class pointer for all the packages.
|
|
6
|
+
*/
|
|
7
|
+
export declare class ApiError extends Error {
|
|
8
|
+
readonly url: URL;
|
|
9
|
+
readonly request: CommonHttpClientFetchRequest | undefined;
|
|
10
|
+
readonly response: CommonHttpClientFetchResponse | undefined;
|
|
11
|
+
readonly options: CommonHttpClientOptions | undefined;
|
|
12
|
+
constructor(url: URL, request: CommonHttpClientFetchRequest | undefined, response: CommonHttpClientFetchResponse | undefined, options: CommonHttpClientOptions | undefined, message: string);
|
|
13
|
+
}
|
package/lib/ApiError.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiError = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* API Error for all API-Client libraries.
|
|
6
|
+
*
|
|
7
|
+
* Stored in common package in order to have the same class pointer for all the packages.
|
|
8
|
+
*/
|
|
9
|
+
class ApiError extends Error {
|
|
10
|
+
constructor(url, request, response, options, message) {
|
|
11
|
+
super(message);
|
|
12
|
+
this.name = "ApiError";
|
|
13
|
+
this.url = url;
|
|
14
|
+
this.request = request;
|
|
15
|
+
this.response = response;
|
|
16
|
+
this.options = options;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.ApiError = ApiError;
|
|
20
|
+
//# sourceMappingURL=ApiError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApiError.js","sourceRoot":"","sources":["../src/ApiError.ts"],"names":[],"mappings":";;;AAMA;;;;GAIG;AACH,MAAa,QAAS,SAAQ,KAAK;IAKjC,YACE,GAAQ,EACR,OAAiD,EACjD,QAAmD,EACnD,OAA4C,EAC5C,OAAe;QAEf,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;QACvB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF;AAnBD,4BAmBC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isJsonMediaType = exports.contentTypeHeaderName = void 0;
|
|
4
|
+
exports.contentTypeHeaderName = "content-type";
|
|
5
|
+
const isJsonMediaType = (mediaType) => Boolean(mediaType.match(/^application\/(\w+\+)?json/));
|
|
6
|
+
exports.isJsonMediaType = isJsonMediaType;
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/fetch/common/index.ts"],"names":[],"mappings":";;;AAAa,QAAA,qBAAqB,GAAG,cAAc,CAAC;AAE7C,MAAM,eAAe,GAAG,CAAC,SAAiB,EAAW,EAAE,CAC5D,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC,CAAC;AAD5C,QAAA,eAAe,mBAC6B"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { CommonHttpClientFetchRequest, CommonHttpClientFetchResponse } from "api-typescript-generator/openapi-client";
|
|
2
|
+
import type { AddOn } from "atlassian-connect-express";
|
|
3
|
+
/**
|
|
4
|
+
* ACE-based API client options.
|
|
5
|
+
*/
|
|
6
|
+
export interface ApiClientAceOptions {
|
|
7
|
+
/**
|
|
8
|
+
* ACE instance.
|
|
9
|
+
*/
|
|
10
|
+
ace: AddOn;
|
|
11
|
+
/**
|
|
12
|
+
* ACE client key.
|
|
13
|
+
*/
|
|
14
|
+
clientKey: string;
|
|
15
|
+
/**
|
|
16
|
+
* ACE user account ID. If not provided, the request will be made on behalf of the add-on.
|
|
17
|
+
*/
|
|
18
|
+
userAccountId?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Creates a fetch function for ACE-based API client.
|
|
22
|
+
*/
|
|
23
|
+
export declare function createAceFetch({ ace, clientKey, userAccountId, }: ApiClientAceOptions): (url: URL, request: CommonHttpClientFetchRequest) => Promise<CommonHttpClientFetchResponse>;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createAceFetch = void 0;
|
|
4
|
+
const common_1 = require("./common");
|
|
5
|
+
/**
|
|
6
|
+
* Creates a fetch function for ACE-based API client.
|
|
7
|
+
*/
|
|
8
|
+
function createAceFetch({ ace, clientKey, userAccountId, }) {
|
|
9
|
+
let httpClient = ace.httpClient({ clientKey, userAccountId });
|
|
10
|
+
if (userAccountId) {
|
|
11
|
+
httpClient = httpClient.asUserByAccountId(userAccountId);
|
|
12
|
+
}
|
|
13
|
+
function toLowerCase(input) {
|
|
14
|
+
return input.toLowerCase();
|
|
15
|
+
}
|
|
16
|
+
function getJsonFromAceResponse(body) {
|
|
17
|
+
if (typeof body === "object" &&
|
|
18
|
+
body !== null &&
|
|
19
|
+
body.constructor !== undefined &&
|
|
20
|
+
body.constructor.name === "Buffer") {
|
|
21
|
+
const buffer = body;
|
|
22
|
+
const textDecoder = new TextDecoder();
|
|
23
|
+
const text = textDecoder.decode(buffer.subarray(buffer.byteOffset, buffer.byteOffset + buffer.byteLength));
|
|
24
|
+
try {
|
|
25
|
+
return JSON.parse(text);
|
|
26
|
+
}
|
|
27
|
+
catch (e) {
|
|
28
|
+
throw new Error(`Failed to parse JSON: ${e}, source: ${text}`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return body;
|
|
32
|
+
}
|
|
33
|
+
function getBlob(buffer) {
|
|
34
|
+
return new Blob([
|
|
35
|
+
buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength),
|
|
36
|
+
]);
|
|
37
|
+
}
|
|
38
|
+
return function aceFetch(url, request) {
|
|
39
|
+
const lowerMethodName = toLowerCase(request.method);
|
|
40
|
+
if (lowerMethodName === "connect" || lowerMethodName === "options") {
|
|
41
|
+
throw new Error(`${request.method} is not supported`);
|
|
42
|
+
}
|
|
43
|
+
const methodName = lowerMethodName === "delete" ? "del" : lowerMethodName;
|
|
44
|
+
return new Promise((resolve, reject) => {
|
|
45
|
+
const bodyOrFormData = {};
|
|
46
|
+
if (request.headers[common_1.contentTypeHeaderName] !== undefined &&
|
|
47
|
+
request.headers[common_1.contentTypeHeaderName].includes("multipart/form-data") === true) {
|
|
48
|
+
bodyOrFormData.multipartFormData = request.body;
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
bodyOrFormData.body = request.body;
|
|
52
|
+
}
|
|
53
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
54
|
+
httpClient[methodName](Object.assign(Object.assign({ json: true, url: `${url.pathname}${url.search}`, headers: request.headers }, bodyOrFormData), { followRedirect: request.redirect === "follow", encoding: null }), (error, response, body) => {
|
|
55
|
+
if (error) {
|
|
56
|
+
return reject(error);
|
|
57
|
+
}
|
|
58
|
+
resolve({
|
|
59
|
+
url: response.request.uri.href,
|
|
60
|
+
headers: response.headers,
|
|
61
|
+
status: response.statusCode,
|
|
62
|
+
statusText: response.statusMessage,
|
|
63
|
+
customRequestProps: request.customRequestProps,
|
|
64
|
+
ok: response.statusCode >= 200 && response.statusCode < 300,
|
|
65
|
+
body: response.headers[common_1.contentTypeHeaderName] !== undefined &&
|
|
66
|
+
(0, common_1.isJsonMediaType)(response.headers[common_1.contentTypeHeaderName])
|
|
67
|
+
? { type: "json", data: getJsonFromAceResponse(body) }
|
|
68
|
+
: { type: "blob", data: getBlob(body) },
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
exports.createAceFetch = createAceFetch;
|
|
75
|
+
//# sourceMappingURL=createAceFetch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createAceFetch.js","sourceRoot":"","sources":["../../src/fetch/createAceFetch.ts"],"names":[],"mappings":";;;AAOA,qCAAkE;AAoBlE;;GAEG;AACH,SAAgB,cAAc,CAAC,EAC7B,GAAG,EACH,SAAS,EACT,aAAa,GACO;IACpB,IAAI,UAAU,GAAG,GAAG,CAAC,UAAU,CAAC,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC,CAAC;IAC9D,IAAI,aAAa,EAAE,CAAC;QAClB,UAAU,GAAG,UAAU,CAAC,iBAAiB,CAAC,aAAa,CAAC,CAAC;IAC3D,CAAC;IAED,SAAS,WAAW,CAAmB,KAAQ;QAC7C,O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,QAAQ,CAAC,OAAO,CAAC,8BAAqB,CAAC,KAAK,SAAS;wBACrD,IAAA,wBAAe,EAAC,QAAQ,CAAC,OAAO,CAAC,8BAAqB,CAAC,CAAC;wBACtD,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,sBAAsB,CAAC,IAAI,CAAC,EAAE;wBACtD,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,IAAc,CAAC,EAAE;iBACtD,CAAC,CAAC;YACL,CAAC,CACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AA7GD,wCA6GC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CommonHttpClientFetchRequest, CommonHttpClientFetchResponse } from "api-typescript-generator/openapi-client";
|
|
2
|
+
/**
|
|
3
|
+
* AP-based API client options.
|
|
4
|
+
*/
|
|
5
|
+
export interface ApiClientApOptions {
|
|
6
|
+
/**
|
|
7
|
+
* AP instance. Can be accessed via `window.AP`.
|
|
8
|
+
*/
|
|
9
|
+
AP: typeof window.AP;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Creates a fetch function for AP-based API client.
|
|
13
|
+
*/
|
|
14
|
+
export declare function createApFetch({ AP }: ApiClientApOptions): (url: URL, request: CommonHttpClientFetchRequest) => Promise<CommonHttpClientFetchResponse>;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.createApFetch = void 0;
|
|
13
|
+
const common_1 = require("./common");
|
|
14
|
+
/**
|
|
15
|
+
* Creates a fetch function for AP-based API client.
|
|
16
|
+
*/
|
|
17
|
+
function createApFetch({ AP }) {
|
|
18
|
+
function extractHeaders(xhr) {
|
|
19
|
+
return Object.fromEntries(xhr
|
|
20
|
+
.getAllResponseHeaders()
|
|
21
|
+
.split("\r\n")
|
|
22
|
+
.map((s) => s.trim())
|
|
23
|
+
.map((s) => s.match(/^([^:]+):.*$/))
|
|
24
|
+
.filter((match) => Boolean(match))
|
|
25
|
+
.map((match) => match[1])
|
|
26
|
+
.map((headerName) => [
|
|
27
|
+
headerName.toLowerCase(),
|
|
28
|
+
xhr.getResponseHeader(headerName),
|
|
29
|
+
])
|
|
30
|
+
.filter((headerEntry) => headerEntry[1] !== null));
|
|
31
|
+
}
|
|
32
|
+
function buildResponse({ xhr, body, request, }) {
|
|
33
|
+
const headers = extractHeaders(xhr);
|
|
34
|
+
return {
|
|
35
|
+
url: xhr.responseURL,
|
|
36
|
+
headers,
|
|
37
|
+
status: xhr.status,
|
|
38
|
+
statusText: xhr.statusText,
|
|
39
|
+
customRequestProps: request.customRequestProps,
|
|
40
|
+
ok: xhr.status >= 200 && xhr.status < 300,
|
|
41
|
+
body: headers[common_1.contentTypeHeaderName] !== undefined &&
|
|
42
|
+
(0, common_1.isJsonMediaType)(headers[common_1.contentTypeHeaderName])
|
|
43
|
+
? { type: "json", data: JSON.parse(textDecoder.decode(body)) }
|
|
44
|
+
: { type: "blob", data: new Blob([body]) },
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
const textDecoder = new TextDecoder();
|
|
48
|
+
return function apFetch(url, request) {
|
|
49
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
try {
|
|
51
|
+
const { body, xhr } = yield AP.request({
|
|
52
|
+
url: `${url.pathname}${url.search}`,
|
|
53
|
+
type: request.method,
|
|
54
|
+
contentType: request.headers[common_1.contentTypeHeaderName],
|
|
55
|
+
data: request.body,
|
|
56
|
+
headers: request.headers,
|
|
57
|
+
cache: request.cache === "force-cache",
|
|
58
|
+
binaryAttachment: true,
|
|
59
|
+
});
|
|
60
|
+
return buildResponse({ xhr, body, request });
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
if (typeof error === "object" &&
|
|
64
|
+
error &&
|
|
65
|
+
"xhr" in error &&
|
|
66
|
+
"err" in error) {
|
|
67
|
+
// Apparently, that's how AP.request errors are thrown.
|
|
68
|
+
// https://bitbucket.org/atlassian/atlassian-connect-js-extra/src/973398917b69f3e68686216f44bdfafd5043ae76/packages/atlassian-connect-js-request/src/plugin/index.js#lines-123
|
|
69
|
+
// `err` is defined in multiple places with completely different types:
|
|
70
|
+
// https://bitbucket.org/atlassian/atlassian-connect-js-extra/src/973398917b69f3e68686216f44bdfafd5043ae76/packages/atlassian-connect-js-request/src/host/index.js#lines-316
|
|
71
|
+
// https://bitbucket.org/atlassian/atlassian-connect-js-extra/src/973398917b69f3e68686216f44bdfafd5043ae76/packages/atlassian-connect-js-request/src/host/index.js#lines-327
|
|
72
|
+
// https://bitbucket.org/atlassian/atlassian-connect-js-extra/src/973398917b69f3e68686216f44bdfafd5043ae76/packages/atlassian-connect-js-request/src/host/index.js#lines-352
|
|
73
|
+
const { xhr, err } = error;
|
|
74
|
+
if (err instanceof Error) {
|
|
75
|
+
throw err;
|
|
76
|
+
}
|
|
77
|
+
if (typeof err === "string") {
|
|
78
|
+
throw new Error(err);
|
|
79
|
+
}
|
|
80
|
+
if (xhr.status === 0) {
|
|
81
|
+
throw new Error(textDecoder.decode(err));
|
|
82
|
+
}
|
|
83
|
+
return buildResponse({ xhr, body: err, request });
|
|
84
|
+
}
|
|
85
|
+
throw error;
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
exports.createApFetch = createApFetch;
|
|
91
|
+
//# sourceMappingURL=createApFetch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createApFetch.js","sourceRoot":"","sources":["../../src/fetch/createApFetch.ts"],"names":[],"mappings":";;;;;;;;;;;;AAMA,qCAAkE;AAYlE;;GAEG;AACH,SAAgB,aAAa,CAAC,EAAE,EAAE,EAAsB;IACtD,SAAS,cAAc,CACrB,GAAmB;QAEnB,OAAO,MAAM,CAAC,WAAW,CACvB,GAAG;aACA,qBAAqB,EAAE;aACvB,KAAK,CAAC,MAAM,CAAC;aACb,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;aACpB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;aACnC,MAAM,CAAC,CAAC,KAAK,EAA6B,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;aAC5D,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;aACxB,GAAG,CACF,CAAC,UAAU,EAAE,EAAE,CACb;YACE,UAAU,CAAC,WAAW,EAAE;YACxB,GAAG,CAAC,iBAAiB,CAAC,UAAU,CAAC;SACzB,CACb;aACA,MAAM,CACL,CAAC,WAAW,EAAmC,EAAE,CAC/C,WAAW,CAAC,CAAC,CAAC,KAAK,IAAI,CAC1B,CACJ,CAAC;IACJ,CAAC;IAED,SAAS,aAAa,CAAC,EACrB,GAAG,EACH,IAAI,EACJ,OAAO,GAKR;QACC,MAAM,OAAO,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC;QACpC,OAAO;YACL,GAAG,EAAE,GAAG,CAAC,WAAW;YACpB,OAAO;YACP,MAAM,EAAE,GAAG,CAAC,MAAM;YAClB,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AAQ;oBACzB,KAAK;oBACL,KAAK,IAAI,KAAK;oBACd,KAAK,IAAI,KAAK,EACd,CAAC;oBACD,uDAAuD;oBACvD,8KAA8K;oBAC9K,uEAAuE;oBACvE,4KAA4K;oBAC5K,4KAA4K;oBAC5K,4KAA4K;oBAC5K,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,KAGpB,CAAC;oBACF,IAAI,GAAG,YAAY,KAAK,EAAE,CAAC;wBACzB,MAAM,GAAG,CAAC;oBACZ,CAAC;oBACD,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;wBAC5B,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC;oBACvB,CAAC;oBACD,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;wBACrB,MAAM,IAAI,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;oBAC3C,CAAC;oBACD,OAAO,aAAa,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,CAAC;gBACpD,CAAC;gBACD,MAAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC;KAAA,CAAC;AACJ,CAAC;AAlGD,sCAkGC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { fetch as externalFetch } from "@forge/api";
|
|
2
|
+
import type { CommonHttpClientFetchRequest, CommonHttpClientFetchResponse } from "api-typescript-generator/openapi-client";
|
|
3
|
+
/**
|
|
4
|
+
* Options for creating a Forge API fetch function.
|
|
5
|
+
*/
|
|
6
|
+
export interface ApiClientForgeApiExternalOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Fetch function from the browser or `@forge/api` package.
|
|
9
|
+
*/
|
|
10
|
+
fetch: typeof externalFetch;
|
|
11
|
+
/**
|
|
12
|
+
* Base URL for the cloud website.
|
|
13
|
+
*/
|
|
14
|
+
baseUrl: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function createForgeApiExternalFetch({ fetch, }: ApiClientForgeApiExternalOptions): (url: URL, request: CommonHttpClientFetchRequest) => Promise<CommonHttpClientFetchResponse>;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
+
t[p] = s[p];
|
|
15
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.createForgeApiExternalFetch = void 0;
|
|
24
|
+
const common_1 = require("./common");
|
|
25
|
+
function createForgeApiExternalFetch({ fetch, }) {
|
|
26
|
+
return function forgeBridgeFetch(url, request) {
|
|
27
|
+
var _a;
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
const requestProps = __rest(request, []);
|
|
30
|
+
const requestInit = requestProps;
|
|
31
|
+
const response = yield fetch(url.toString(), Object.assign(Object.assign({}, requestInit), { headers: request.headers,
|
|
32
|
+
// Body types should be compatible.
|
|
33
|
+
body: request.body }));
|
|
34
|
+
const body = (0, common_1.isJsonMediaType)((_a = response.headers.get(common_1.contentTypeHeaderName)) !== null && _a !== void 0 ? _a : "")
|
|
35
|
+
? {
|
|
36
|
+
type: "json",
|
|
37
|
+
data: yield response.json(),
|
|
38
|
+
}
|
|
39
|
+
: {
|
|
40
|
+
type: "blob",
|
|
41
|
+
data: new Blob([yield response.arrayBuffer()]),
|
|
42
|
+
};
|
|
43
|
+
const headers = {};
|
|
44
|
+
response.headers.forEach((value, key) => {
|
|
45
|
+
headers[key] = value;
|
|
46
|
+
});
|
|
47
|
+
if (response.headers.has("set-cookie") === true &&
|
|
48
|
+
"getSetCookie" in response.headers) {
|
|
49
|
+
headers["set-cookie"] = response.headers.getSetCookie();
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
status: response.status,
|
|
53
|
+
statusText: response.statusText,
|
|
54
|
+
body,
|
|
55
|
+
url: url.toString(),
|
|
56
|
+
headers,
|
|
57
|
+
ok: response.ok,
|
|
58
|
+
customRequestProps: request.customRequestProps,
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
exports.createForgeApiExternalFetch = createForgeApiExternalFetch;
|
|
64
|
+
//# sourceMappingURL=createForgeApiExternalFetch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createForgeApiExternalFetch.js","sourceRoot":"","sources":["../../src/fetch/createForgeApiExternalFetch.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAQA,qCAAkE;AAgBlE,SAAgB,2BAA2B,CAAC,EAC1C,KAAK,GAC4B;IACjC,OAAO,SAAe,gBAAgB,CACpC,GAAQ,EACR,OAAqC;;;YAErC,MAAW,YAAY,UAAK,OAAO,EAA7B,EAAmB,CAAU,CAAC;YACp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CAAC;;KACH,CAAC;AACJ,CAAC;AAlDD,kEAkDC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type * as ForgeApi from "@forge/api";
|
|
2
|
+
import type { CommonHttpClientFetchRequest, CommonHttpClientFetchResponse } from "api-typescript-generator/openapi-client";
|
|
3
|
+
/**
|
|
4
|
+
* Forge-based API client options.
|
|
5
|
+
*/
|
|
6
|
+
export interface ApiClientForgeApiOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Forge API namespace. Can be imported using: import * as forgeApi from `@forge/api`;
|
|
9
|
+
*/
|
|
10
|
+
forgeApi: typeof ForgeApi;
|
|
11
|
+
/**
|
|
12
|
+
* Whether to make requests as an app. If not provided, the request will be made on behalf of the user.
|
|
13
|
+
*/
|
|
14
|
+
asApp?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Creates a fetch function for Forge-based API client.
|
|
18
|
+
*/
|
|
19
|
+
export declare function createForgeApiFetch({ forgeApi, asApp, }: ApiClientForgeApiOptions): (url: URL, request: CommonHttpClientFetchRequest) => Promise<CommonHttpClientFetchResponse>;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.createForgeApiFetch = void 0;
|
|
13
|
+
const common_1 = require("./common");
|
|
14
|
+
/**
|
|
15
|
+
* Creates a fetch function for Forge-based API client.
|
|
16
|
+
*/
|
|
17
|
+
function createForgeApiFetch({ forgeApi, asApp, }) {
|
|
18
|
+
return function forgeApiFetch(url, request) {
|
|
19
|
+
var _a;
|
|
20
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
const response = yield (asApp ? forgeApi.asApp() : forgeApi.asUser()).requestJira(forgeApi.assumeTrustedRoute(`${url.pathname}${url.search}`), Object.assign(Object.assign({}, request), {
|
|
22
|
+
// Forge API package uses BodyInit from `node-fetch` package, which is a bit different to the native one.
|
|
23
|
+
body: request.body }));
|
|
24
|
+
const body = (0, common_1.isJsonMediaType)((_a = response.headers.get(common_1.contentTypeHeaderName)) !== null && _a !== void 0 ? _a : "")
|
|
25
|
+
? {
|
|
26
|
+
type: "json",
|
|
27
|
+
data: yield response.json(),
|
|
28
|
+
}
|
|
29
|
+
: {
|
|
30
|
+
type: "blob",
|
|
31
|
+
data: new Blob([yield response.arrayBuffer()]),
|
|
32
|
+
};
|
|
33
|
+
const headers = {};
|
|
34
|
+
response.headers.forEach((value, key) => {
|
|
35
|
+
headers[key] = value;
|
|
36
|
+
});
|
|
37
|
+
if (response.headers.has("set-cookie") === true &&
|
|
38
|
+
"getSetCookie" in response.headers) {
|
|
39
|
+
headers["set-cookie"] = response.headers.getSetCookie();
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
status: response.status,
|
|
43
|
+
statusText: response.statusText,
|
|
44
|
+
body,
|
|
45
|
+
url: url.toString(),
|
|
46
|
+
headers,
|
|
47
|
+
ok: response.ok,
|
|
48
|
+
customRequestProps: request.customRequestProps,
|
|
49
|
+
};
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
exports.createForgeApiFetch = createForgeApiFetch;
|
|
54
|
+
//# sourceMappingURL=createForgeApiFetch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create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CAAC,YAAY,CAAC,GACnB,QAAQ,CAAC,OAGV,CAAC,YAAY,EAAE,CAAC;YACnB,CAAC;YACD,OAAO;gBACL,MAAM,EAAE,QAAQ,CAAC,MAAM;gBACvB,UAAU,EAAE,QAAQ,CAAC,UAAU;gBAC/B,IAAI;gBACJ,GAAG,EAAE,GAAG,CAAC,QAAQ,EAAE;gBACnB,OAAO;gBACP,EAAE,EAAE,QAAQ,CAAC,EAAE;gBACf,kBAAkB,EAAE,OAAO,CAAC,kBAAkB;aAC/C,CAAC;;KACH,CAAC;AACJ,CAAC;AAlDD,kDAkDC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { requestConfluence, requestJira } from "@forge/bridge";
|
|
2
|
+
import type { CommonHttpClientFetchRequest, CommonHttpClientFetchResponse } from "api-typescript-generator/openapi-client";
|
|
3
|
+
export type JiraApiClientForgeBridgeOptions = {
|
|
4
|
+
requestJira: typeof requestJira;
|
|
5
|
+
};
|
|
6
|
+
export type ConfluenceApiClientForgeBridgeOptions = {
|
|
7
|
+
requestConfluence: typeof requestConfluence;
|
|
8
|
+
};
|
|
9
|
+
export declare const createJiraForgeBridgeFetch: ({ requestJira, }: JiraApiClientForgeBridgeOptions) => (url: URL, request: CommonHttpClientFetchRequest) => Promise<CommonHttpClientFetchResponse>;
|
|
10
|
+
export declare const createConfluenceForgeBridgeFetch: ({ requestConfluence, }: ConfluenceApiClientForgeBridgeOptions) => (url: URL, request: CommonHttpClientFetchRequest) => Promise<CommonHttpClientFetchResponse>;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
+
t[p] = s[p];
|
|
15
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.createConfluenceForgeBridgeFetch = exports.createJiraForgeBridgeFetch = void 0;
|
|
24
|
+
const index_1 = require("./common/index");
|
|
25
|
+
const createJiraForgeBridgeFetch = ({ requestJira, }) => createForgeBridgeFetch({ bridgeRequest: requestJira });
|
|
26
|
+
exports.createJiraForgeBridgeFetch = createJiraForgeBridgeFetch;
|
|
27
|
+
const createConfluenceForgeBridgeFetch = ({ requestConfluence, }) => createForgeBridgeFetch({ bridgeRequest: requestConfluence });
|
|
28
|
+
exports.createConfluenceForgeBridgeFetch = createConfluenceForgeBridgeFetch;
|
|
29
|
+
function createForgeBridgeFetch({ bridgeRequest, }) {
|
|
30
|
+
return function forgeBridgeFetch(url, request) {
|
|
31
|
+
var _a;
|
|
32
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
const requestProps = __rest(request, []);
|
|
34
|
+
const requestInit = requestProps;
|
|
35
|
+
const response = yield bridgeRequest(`${url.pathname}${url.search}`, requestInit);
|
|
36
|
+
const body = (0, index_1.isJsonMediaType)((_a = response.headers.get("content-type")) !== null && _a !== void 0 ? _a : "")
|
|
37
|
+
? {
|
|
38
|
+
type: "json",
|
|
39
|
+
data: yield response.json(),
|
|
40
|
+
}
|
|
41
|
+
: {
|
|
42
|
+
type: "blob",
|
|
43
|
+
data: yield response.blob(),
|
|
44
|
+
};
|
|
45
|
+
const headers = {};
|
|
46
|
+
response.headers.forEach((value, key) => {
|
|
47
|
+
headers[key] = value;
|
|
48
|
+
});
|
|
49
|
+
if (response.headers.has("set-cookie") === true &&
|
|
50
|
+
"getSetCookie" in response.headers) {
|
|
51
|
+
headers["set-cookie"] = response.headers.getSetCookie();
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
status: response.status,
|
|
55
|
+
statusText: response.statusText,
|
|
56
|
+
body,
|
|
57
|
+
url: response.url,
|
|
58
|
+
headers,
|
|
59
|
+
ok: response.ok,
|
|
60
|
+
customRequestProps: request.customRequestProps,
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=createForgeBridgeFetch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createForgeBridgeFetch.js","sourceRoot":"","sources":["../../src/fetch/createForgeBridgeFetch.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAQA,0CAAiD;AAU1C,MAAM,0BAA0B,GAAG,CAAC,EACzC,WAAW,GACqB,EAAE,EAAE,CACpC,sBAAsB,CAAC,EAAE,aAAa,EAAE,WAAW,EAAE,CAAC,CAAC;AAH5C,QAAA,0BAA0B,8BAGkB;AAElD,MAAM,gCAAgC,GAAG,CAAC,EAC/C,iBAAiB,GACqB,EAAE,EAAE,CAC1C,sBAAsB,CAAC,EAAE,aAAa,EAAE,iBAAiB,EAAE,CAAC,CAAC;AAHlD,QAAA,gCAAgC,oCAGkB;AAQ/D,SAAS,sBAAsB,CAAC,EAC9B,aAAa,GACe;IAC5B,OAA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,CAAC;;KACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CommonHttpClientOptions } from "api-typescript-generator/openapi-client";
|
|
2
|
+
import { type ApiClientAceOptions } from "./createAceFetch";
|
|
3
|
+
import { type ApiClientApOptions } from "./createApFetch";
|
|
4
|
+
import { type ApiClientForgeApiExternalOptions } from "./createForgeApiExternalFetch";
|
|
5
|
+
import { type ApiClientForgeApiOptions } from "./createForgeApiFetch";
|
|
6
|
+
import { type ConfluenceApiClientForgeBridgeOptions, type JiraApiClientForgeBridgeOptions } from "./createForgeBridgeFetch";
|
|
7
|
+
export type AllOpenApiClientOptions = ApiClientAceOptions | ApiClientApOptions | ApiClientForgeApiOptions | JiraApiClientForgeBridgeOptions | ConfluenceApiClientForgeBridgeOptions | ApiClientForgeApiExternalOptions;
|
|
8
|
+
export declare function getApiClientOptions<TOptions extends AllOpenApiClientOptions>(options: TOptions): Partial<CommonHttpClientOptions>;
|
|
9
|
+
type CommonApiClientOptions = ApiClientAceOptions | ApiClientApOptions | ApiClientForgeApiOptions | ApiClientForgeApiExternalOptions;
|
|
10
|
+
export declare function createAsAppMethod<TClass extends new (options: CommonApiClientOptions) => unknown>(): () => InstanceType<TClass>;
|
|
11
|
+
export declare function createAsUserMethod<TClass extends new (options: CommonApiClientOptions) => unknown>(): (userAccountId: string) => InstanceType<TClass>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createAsUserMethod = exports.createAsAppMethod = exports.getApiClientOptions = void 0;
|
|
4
|
+
const ApiError_1 = require("../ApiError");
|
|
5
|
+
const createAceFetch_1 = require("./createAceFetch");
|
|
6
|
+
const createApFetch_1 = require("./createApFetch");
|
|
7
|
+
const createForgeApiExternalFetch_1 = require("./createForgeApiExternalFetch");
|
|
8
|
+
const createForgeApiFetch_1 = require("./createForgeApiFetch");
|
|
9
|
+
const createForgeBridgeFetch_1 = require("./createForgeBridgeFetch");
|
|
10
|
+
/**
|
|
11
|
+
* Get fetch function by API client options.
|
|
12
|
+
* We have a huge number of fetch-functions here!
|
|
13
|
+
*/
|
|
14
|
+
function getFetchByOptions(options) {
|
|
15
|
+
if ("forgeApi" in options) {
|
|
16
|
+
return (0, createForgeApiFetch_1.createForgeApiFetch)(options);
|
|
17
|
+
}
|
|
18
|
+
else if ("ace" in options) {
|
|
19
|
+
return (0, createAceFetch_1.createAceFetch)(options);
|
|
20
|
+
}
|
|
21
|
+
else if ("AP" in options) {
|
|
22
|
+
return (0, createApFetch_1.createApFetch)(options);
|
|
23
|
+
}
|
|
24
|
+
else if ("requestJira" in options) {
|
|
25
|
+
return (0, createForgeBridgeFetch_1.createJiraForgeBridgeFetch)(options);
|
|
26
|
+
}
|
|
27
|
+
else if ("requestConfluence" in options) {
|
|
28
|
+
return (0, createForgeBridgeFetch_1.createConfluenceForgeBridgeFetch)(options);
|
|
29
|
+
}
|
|
30
|
+
else if ("fetch" in options) {
|
|
31
|
+
return (0, createForgeApiExternalFetch_1.createForgeApiExternalFetch)(options);
|
|
32
|
+
}
|
|
33
|
+
throw new Error("Unknown API Client options.");
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Error format description: https://developer.atlassian.com/cloud/jira/platform/rest/v3/intro/#status-codes
|
|
37
|
+
*/
|
|
38
|
+
function formatHttpErrorMessage(response) {
|
|
39
|
+
let additionalDetails = "";
|
|
40
|
+
if (response.body.type === "json" &&
|
|
41
|
+
typeof response.body.data === "object" &&
|
|
42
|
+
response.body.data !== null) {
|
|
43
|
+
if ("errorMessages" in response.body.data &&
|
|
44
|
+
Array.isArray(response.body.data.errorMessages)) {
|
|
45
|
+
additionalDetails += ": " + response.body.data.errorMessages.join(",");
|
|
46
|
+
}
|
|
47
|
+
if ("errors" in response.body.data &&
|
|
48
|
+
typeof response.body.data.errors === "object" &&
|
|
49
|
+
response.body.data.errors !== null) {
|
|
50
|
+
additionalDetails +=
|
|
51
|
+
": " +
|
|
52
|
+
Object.entries(response.body.data.errors)
|
|
53
|
+
.map(([key, value]) => `${key}: ${value}`)
|
|
54
|
+
.join(",");
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return `HTTP Error ${response.status} (${response.statusText})${additionalDetails}`;
|
|
58
|
+
}
|
|
59
|
+
function getApiClientOptions(options) {
|
|
60
|
+
return {
|
|
61
|
+
fetch: getFetchByOptions(options),
|
|
62
|
+
formatHttpErrorMessage,
|
|
63
|
+
errorClass: ApiError_1.ApiError,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
exports.getApiClientOptions = getApiClientOptions;
|
|
67
|
+
function createAsAppMethod() {
|
|
68
|
+
return function asAppMethod() {
|
|
69
|
+
if (!("forgeApi" in this.options) && !("ace" in this.options)) {
|
|
70
|
+
throw new Error("Cannot switch to asApp for non ForgeAPI/ACE-based JiraApiClient.");
|
|
71
|
+
}
|
|
72
|
+
return new this.constructor(Object.assign(Object.assign({}, this.options), { asApp: true, userAccountId: undefined }));
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
exports.createAsAppMethod = createAsAppMethod;
|
|
76
|
+
function createAsUserMethod() {
|
|
77
|
+
return function asUserMethod(userAccountId) {
|
|
78
|
+
if (!("ace" in this.options) && !("forgeApi" in this.options)) {
|
|
79
|
+
throw new Error("Cannot switch to asApp for non ForgeAPI/ACE-based API Client.");
|
|
80
|
+
}
|
|
81
|
+
if ("ace" in this.options && !userAccountId) {
|
|
82
|
+
throw new Error("userAccountId is required for ACE-based JiraApiClient.");
|
|
83
|
+
}
|
|
84
|
+
return new this.constructor(Object.assign(Object.assign({}, this.options), { userAccountId, asApp: false }));
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
exports.createAsUserMethod = createAsUserMethod;
|
|
88
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRo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,EACX,aAAa,EAAE,SAAS,IACf,CAAC;IACd,CAAC,CAAC;AACJ,CAAC;AAfD,8CAeC;AAED,SAAgB,kBAAkB;IAGhC,OAAO,SAAS,YAAY,CAE1B,aAAqB;QAErB,IAAI,CAAC,CAAC,KAAK,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,UAAU,IAAI,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;YAC9D,MAAM,IAAI,KAAK,CACb,+DAA+D,CAChE,CAAC;QACJ,CAAC;QACD,IAAI,KAAK,IAAI,IAAI,CAAC,OAAO,IAAI,CAAC,aAAa,EAAE,CAAC;YAC5C,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;QAC5E,CAAC;QACD,OAAO,IAAK,IAAI,CAAC,WAAsB,iCAClC,IAAI,CAAC,OAAO,KACf,aAAa,EACb,KAAK,EAAE,KAAK,IACH,CAAC;IACd,CAAC,CAAC;AACJ,CAAC;AArBD,gDAqBC"}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { ApiError } from "./ApiError";
|
|
2
|
+
export { createAsAppMethod, createAsUserMethod, getApiClientOptions, } from "./fetch";
|
|
3
|
+
export { ApiClientAceOptions } from "./fetch/createAceFetch";
|
|
4
|
+
export { ApiClientApOptions } from "./fetch/createApFetch";
|
|
5
|
+
export { ApiClientForgeApiOptions } from "./fetch/createForgeApiFetch";
|
|
6
|
+
export { ApiClientForgeApiExternalOptions } from "./fetch/createForgeApiExternalFetch";
|
|
7
|
+
export { JiraApiClientForgeBridgeOptions, ConfluenceApiClientForgeBridgeOptions, } from "./fetch/createForgeBridgeFetch";
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getApiClientOptions = exports.createAsUserMethod = exports.createAsAppMethod = exports.ApiError = void 0;
|
|
4
|
+
var ApiError_1 = require("./ApiError");
|
|
5
|
+
Object.defineProperty(exports, "ApiError", { enumerable: true, get: function () { return ApiError_1.ApiError; } });
|
|
6
|
+
var fetch_1 = require("./fetch");
|
|
7
|
+
Object.defineProperty(exports, "createAsAppMethod", { enumerable: true, get: function () { return fetch_1.createAsAppMethod; } });
|
|
8
|
+
Object.defineProperty(exports, "createAsUserMethod", { enumerable: true, get: function () { return fetch_1.createAsUserMethod; } });
|
|
9
|
+
Object.defineProperty(exports, "getApiClientOptions", { enumerable: true, get: function () { return fetch_1.getApiClientOptions; } });
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AACjB,iCAIiB;AAHf,0GAAA,iBAAiB,OAAA;AACjB,2GAAA,kBAAkB,OAAA;AAClB,4GAAA,mBAAmB,OAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@resolution/atlassian-api-common",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Shared code across different implementations of Atlassian API Clients.",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"lint": "yarn run -T eslint src config",
|
|
8
|
+
"build": "yarn run -T tsc -p tsconfig.build.json"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"lib",
|
|
12
|
+
"README.md"
|
|
13
|
+
],
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://bitbucket.org/resolutiongmbh/atlassian-api-clients.git"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"atlassian",
|
|
20
|
+
"api",
|
|
21
|
+
"openapi",
|
|
22
|
+
"client"
|
|
23
|
+
],
|
|
24
|
+
"author": "Marat Dulin (Resolution GmbH)",
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"bugs": {
|
|
27
|
+
"url": "https://bitbucket.org/resolutiongmbh/atlassian-api-clients/issues"
|
|
28
|
+
},
|
|
29
|
+
"homepage": "https://bitbucket.org/resolutiongmbh/atlassian-api-clients#readme",
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@forge/api": "^3.6.0",
|
|
32
|
+
"@forge/bridge": "^3.4.0",
|
|
33
|
+
"@types/atlassian-connect-js": "^5.2.17",
|
|
34
|
+
"@types/request": "^2.48.12",
|
|
35
|
+
"atlassian-connect-express": "^10.0.2"
|
|
36
|
+
},
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"zod": ">=3.23.8"
|
|
39
|
+
},
|
|
40
|
+
"publishConfig": {
|
|
41
|
+
"access": "public"
|
|
42
|
+
},
|
|
43
|
+
"gitHead": "3df939a1dcdef2794f26a40a676620ff452783de"
|
|
44
|
+
}
|