@forge/api 3.7.1-next.0 → 3.8.0-next.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/CHANGELOG.md +12 -0
- package/out/api/errors.d.ts +5 -0
- package/out/api/errors.d.ts.map +1 -1
- package/out/api/errors.js +12 -1
- package/out/api/fetch.d.ts +4 -1
- package/out/api/fetch.d.ts.map +1 -1
- package/out/api/fetch.js +20 -12
- package/out/api/remote.d.ts +8 -0
- package/out/api/remote.d.ts.map +1 -0
- package/out/api/remote.js +30 -0
- package/out/index.d.ts +3 -1
- package/out/index.d.ts.map +1 -1
- package/out/index.js +5 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @forge/api
|
|
2
2
|
|
|
3
|
+
## 3.8.0-next.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 567b79a: Add invokeRemote to @forge/api
|
|
8
|
+
|
|
9
|
+
## 3.7.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 6b04ab2: Fix \_\_requestAtlassianAsUser to use asUser on sandbox runtime
|
|
14
|
+
|
|
3
15
|
## 3.7.1-next.0
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/out/api/errors.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export declare const FUNCTION_ERR = "FUNCTION_ERR";
|
|
|
2
2
|
export declare const REQUEST_EGRESS_ALLOWLIST_ERR = "REQUEST_EGRESS_ALLOWLIST_ERR";
|
|
3
3
|
export declare const FUNCTION_FETCH_ERR = "FUNCTION_FETCH_ERR";
|
|
4
4
|
export declare const NEEDS_AUTHENTICATION_ERR = "NEEDS_AUTHENTICATION_ERR";
|
|
5
|
+
export declare const INVALID_REMOTE_ERR = "INVALID_REMOTE_ERR";
|
|
5
6
|
export declare const PROXY_ERR = "PROXY_ERR";
|
|
6
7
|
export declare function isForgePlatformError(err: Error): boolean;
|
|
7
8
|
export declare function isHostedCodeError(err: Error | string): boolean;
|
|
@@ -37,6 +38,10 @@ export declare class NeedsAuthenticationError extends HttpError {
|
|
|
37
38
|
readonly options?: NeedsAuthenticationErrorOptions | undefined;
|
|
38
39
|
constructor(error: string, serviceKey: string, options?: NeedsAuthenticationErrorOptions | undefined);
|
|
39
40
|
}
|
|
41
|
+
export declare class InvalidRemoteError extends HttpError {
|
|
42
|
+
readonly remoteKey: string;
|
|
43
|
+
constructor(error: string, remoteKey: string);
|
|
44
|
+
}
|
|
40
45
|
export declare class ProxyRequestError extends HttpError {
|
|
41
46
|
status: number;
|
|
42
47
|
errorCode: string;
|
package/out/api/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/api/errors.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY,iBAAiB,CAAC;AAC3C,eAAO,MAAM,4BAA4B,iCAAiC,CAAC;AAC3E,eAAO,MAAM,kBAAkB,uBAAuB,CAAC;AACvD,eAAO,MAAM,wBAAwB,6BAA6B,CAAC;AACnE,eAAO,MAAM,SAAS,cAAc,CAAC;AAErC,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,KAAK,WAE9C;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,KAAK,GAAG,MAAM,WAIpD;AAKD,wBAAgB,eAAe,CAAC,GAAG,EAAE,KAAK,GAAG,OAAO,CAEnD;AAED,qBAAa,SAAU,SAAQ,KAAK;IAClC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;gBACf,OAAO,EAAE,MAAM;CAG5B;AAED,qBAAa,UAAW,SAAQ,KAAK;gBACvB,KAAK,EAAE,MAAM;CAK1B;AAED,qBAAa,eAAgB,SAAQ,SAAS;gBAChC,OAAO,EAAE,MAAM;CAM5B;AAED,qBAAa,+BAAgC,SAAQ,eAAe;gBACtD,SAAS,EAAE,MAAM;CA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AAE,MAAM;CAG5B;AAED,qBAAa,UAAW,SAAQ,KAAK;gBACvB,KAAK,EAAE,MAAM;CAK1B;AAED,qBAAa,eAAgB,SAAQ,SAAS;gBAChC,OAAO,EAAE,MAAM;CAM5B;AAED,qBAAa,+BAAgC,SAAQ,eAAe;gBACtD,SAAS,EAAE,MAAM;CAK9B;AAED,qBAAa,8BAA+B,SAAQ,eAAe;gBACrD,SAAS,EAAE,MAAM;CAG9B;AAED,qBAAa,6BAA8B,SAAQ,eAAe;gBACpD,gBAAgB,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM;CAGhE;AAED,qBAAa,8BAA+B,SAAQ,eAAe;gBACrD,SAAS,EAAE,MAAM;CAG9B;AAED,MAAM,WAAW,+BAA+B;IAI9C,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAKlB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,qBAAa,wBAAyB,SAAQ,SAAS;aAGnC,UAAU,EAAE,MAAM;aAClB,OAAO,CAAC;gBAFxB,KAAK,EAAE,MAAM,EACG,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,6CAAiC;CAO5D;AAED,qBAAa,kBAAmB,SAAQ,SAAS;aAG7B,SAAS,EAAE,MAAM;gBADjC,KAAK,EAAE,MAAM,EACG,SAAS,EAAE,MAAM;CAMpC;AAED,qBAAa,iBAAkB,SAAQ,SAAS;IAErC,MAAM,EAAE,MAAM;IACd,SAAS,EAAE,MAAM;gBADjB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM;CAK3B"}
|
package/out/api/errors.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ProxyRequestError = exports.NeedsAuthenticationError = exports.InvalidWorkspaceRequestedError = exports.RequestProductNotAllowedError = exports.ProductEndpointNotAllowedError = exports.ExternalEndpointNotAllowedError = exports.NotAllowedError = exports.FetchError = exports.HttpError = exports.isExpectedError = exports.isHostedCodeError = exports.isForgePlatformError = exports.PROXY_ERR = exports.NEEDS_AUTHENTICATION_ERR = exports.FUNCTION_FETCH_ERR = exports.REQUEST_EGRESS_ALLOWLIST_ERR = exports.FUNCTION_ERR = void 0;
|
|
3
|
+
exports.ProxyRequestError = exports.InvalidRemoteError = exports.NeedsAuthenticationError = exports.InvalidWorkspaceRequestedError = exports.RequestProductNotAllowedError = exports.ProductEndpointNotAllowedError = exports.ExternalEndpointNotAllowedError = exports.NotAllowedError = exports.FetchError = exports.HttpError = exports.isExpectedError = exports.isHostedCodeError = exports.isForgePlatformError = exports.PROXY_ERR = exports.INVALID_REMOTE_ERR = exports.NEEDS_AUTHENTICATION_ERR = exports.FUNCTION_FETCH_ERR = exports.REQUEST_EGRESS_ALLOWLIST_ERR = exports.FUNCTION_ERR = void 0;
|
|
4
4
|
exports.FUNCTION_ERR = 'FUNCTION_ERR';
|
|
5
5
|
exports.REQUEST_EGRESS_ALLOWLIST_ERR = 'REQUEST_EGRESS_ALLOWLIST_ERR';
|
|
6
6
|
exports.FUNCTION_FETCH_ERR = 'FUNCTION_FETCH_ERR';
|
|
7
7
|
exports.NEEDS_AUTHENTICATION_ERR = 'NEEDS_AUTHENTICATION_ERR';
|
|
8
|
+
exports.INVALID_REMOTE_ERR = 'INVALID_REMOTE_ERR';
|
|
8
9
|
exports.PROXY_ERR = 'PROXY_ERR';
|
|
9
10
|
function isForgePlatformError(err) {
|
|
10
11
|
return [exports.REQUEST_EGRESS_ALLOWLIST_ERR, exports.FUNCTION_FETCH_ERR, exports.NEEDS_AUTHENTICATION_ERR, exports.PROXY_ERR].includes(err.name);
|
|
@@ -79,6 +80,16 @@ class NeedsAuthenticationError extends HttpError {
|
|
|
79
80
|
}
|
|
80
81
|
}
|
|
81
82
|
exports.NeedsAuthenticationError = NeedsAuthenticationError;
|
|
83
|
+
class InvalidRemoteError extends HttpError {
|
|
84
|
+
remoteKey;
|
|
85
|
+
constructor(error, remoteKey) {
|
|
86
|
+
super(error);
|
|
87
|
+
this.remoteKey = remoteKey;
|
|
88
|
+
this.name = exports.INVALID_REMOTE_ERR;
|
|
89
|
+
this.status = 400;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
exports.InvalidRemoteError = InvalidRemoteError;
|
|
82
93
|
class ProxyRequestError extends HttpError {
|
|
83
94
|
status;
|
|
84
95
|
errorCode;
|
package/out/api/fetch.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RequestInit } from 'node-fetch';
|
|
1
|
+
import { RequestInit, Response } from 'node-fetch';
|
|
2
2
|
import { FetchAPI, FetchMethod } from '..';
|
|
3
3
|
export declare type AuthProvider = 'app' | 'user' | 'none';
|
|
4
4
|
declare type RemoteAPI = 'jira' | 'confluence' | 'stargate' | 'bitbucket';
|
|
@@ -15,6 +15,9 @@ declare type ExternalAuthFetchArgs = {
|
|
|
15
15
|
};
|
|
16
16
|
export declare function fetchProduct(args: FetchArgs): FetchMethod;
|
|
17
17
|
export declare function fetchRemote(args: ExternalAuthFetchArgs): FetchMethod;
|
|
18
|
+
export declare function createRemoteUrlWithPath(baseUrl: string, path: string): URL;
|
|
19
|
+
export declare const getForgeProxyError: (response: Response) => string | null;
|
|
20
|
+
export declare const handleProxyResponseErrors: (response: Response) => void;
|
|
18
21
|
export declare const addMagicAgent: (init?: RequestInit, agentOverride?: string) => RequestInit;
|
|
19
22
|
export declare function getNodeRuntimeAPI(): FetchAPI;
|
|
20
23
|
export declare function getSandboxRuntimeAPI(api: any): FetchAPI;
|
package/out/api/fetch.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../src/api/fetch.ts"],"names":[],"mappings":"AAEA,OAAc,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../src/api/fetch.ts"],"names":[],"mappings":"AAEA,OAAc,EAAE,WAAW,EAAE,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RuntimeAPI = exports.getNodeRuntimeAPI = exports.addMagicAgent = exports.fetchRemote = exports.fetchProduct = void 0;
|
|
3
|
+
exports.getSandboxRuntimeAPI = exports.getNodeRuntimeAPI = exports.addMagicAgent = exports.handleProxyResponseErrors = exports.getForgeProxyError = exports.createRemoteUrlWithPath = exports.fetchRemote = exports.fetchProduct = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const node_fetch_1 = tslib_1.__importStar(require("node-fetch"));
|
|
6
6
|
const _1 = require(".");
|
|
@@ -26,30 +26,35 @@ function fetchProduct(args) {
|
|
|
26
26
|
init.headers = { ...init.headers, authorization: `Forge ${args.provider}` };
|
|
27
27
|
}
|
|
28
28
|
const response = await (0, node_fetch_1.default)(url, init);
|
|
29
|
-
handleProxyResponseErrors(response);
|
|
29
|
+
(0, exports.handleProxyResponseErrors)(response);
|
|
30
30
|
return response;
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
33
|
exports.fetchProduct = fetchProduct;
|
|
34
34
|
function fetchRemote(args) {
|
|
35
35
|
return async (path, init) => {
|
|
36
|
-
const remoteUrl =
|
|
37
|
-
const url = new URL(path, remoteUrl);
|
|
38
|
-
if (url.hostname !== remoteUrl.hostname) {
|
|
39
|
-
throw new Error(`Invalid path provided ${path}`);
|
|
40
|
-
}
|
|
41
|
-
remoteUrl.searchParams.append('path', path);
|
|
36
|
+
const remoteUrl = createRemoteUrlWithPath(`https://${args.remote}`, path);
|
|
42
37
|
init = (0, exports.addMagicAgent)(init, 'EXTERNAL_AUTH_REQUEST');
|
|
43
38
|
init.headers = {
|
|
44
39
|
...init.headers,
|
|
45
40
|
authorization: `Forge user ${args.provider} ${args.account}`
|
|
46
41
|
};
|
|
47
42
|
const response = await (0, node_fetch_1.default)(remoteUrl, init);
|
|
48
|
-
handleProxyResponseErrors(response);
|
|
43
|
+
(0, exports.handleProxyResponseErrors)(response);
|
|
49
44
|
return response;
|
|
50
45
|
};
|
|
51
46
|
}
|
|
52
47
|
exports.fetchRemote = fetchRemote;
|
|
48
|
+
function createRemoteUrlWithPath(baseUrl, path) {
|
|
49
|
+
const remoteUrl = new URL(baseUrl);
|
|
50
|
+
const url = new URL(path, remoteUrl);
|
|
51
|
+
if (url.hostname !== remoteUrl.hostname) {
|
|
52
|
+
throw new Error(`Invalid path provided ${path}`);
|
|
53
|
+
}
|
|
54
|
+
remoteUrl.searchParams.append('path', path);
|
|
55
|
+
return remoteUrl;
|
|
56
|
+
}
|
|
57
|
+
exports.createRemoteUrlWithPath = createRemoteUrlWithPath;
|
|
53
58
|
function getDefaultRemote(provider) {
|
|
54
59
|
const externalAuthProvider = findExternalAuthProviderConfigOrThrow(provider);
|
|
55
60
|
if (!externalAuthProvider.remotes.length) {
|
|
@@ -68,15 +73,18 @@ function findExternalAuthProviderConfigOrThrow(provider) {
|
|
|
68
73
|
return externalAuthProvider;
|
|
69
74
|
}
|
|
70
75
|
const ATLASSIAN_TOKEN_SERVICE_KEY = 'atlassian-token-service-key';
|
|
76
|
+
const getForgeProxyError = (response) => response.headers.get('forge-proxy-error');
|
|
77
|
+
exports.getForgeProxyError = getForgeProxyError;
|
|
71
78
|
const handleProxyResponseErrors = (response) => {
|
|
72
|
-
|
|
73
|
-
|
|
79
|
+
const errorReason = (0, exports.getForgeProxyError)(response);
|
|
80
|
+
if (errorReason) {
|
|
74
81
|
if (errorReason === 'NEEDS_AUTHENTICATION_ERR') {
|
|
75
82
|
throw new errors_1.NeedsAuthenticationError('Authentication Required', ATLASSIAN_TOKEN_SERVICE_KEY);
|
|
76
83
|
}
|
|
77
|
-
throw new errors_1.ProxyRequestError(response.status,
|
|
84
|
+
throw new errors_1.ProxyRequestError(response.status, errorReason);
|
|
78
85
|
}
|
|
79
86
|
};
|
|
87
|
+
exports.handleProxyResponseErrors = handleProxyResponseErrors;
|
|
80
88
|
const hasAuthorizationHeader = (headersInit) => {
|
|
81
89
|
if (!headersInit)
|
|
82
90
|
return false;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { RequestInit } from 'node-fetch';
|
|
2
|
+
import { APIResponse } from '../index';
|
|
3
|
+
declare type InvokeRemoteOptions = {
|
|
4
|
+
path: string;
|
|
5
|
+
};
|
|
6
|
+
export declare function invokeRemote(remoteKey: string, options: RequestInit & InvokeRemoteOptions): Promise<APIResponse>;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=remote.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote.d.ts","sourceRoot":"","sources":["../../src/api/remote.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,WAAW,EAAY,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAIvC,aAAK,mBAAmB,GAAG;IACzB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,wBAAsB,YAAY,CAChC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,WAAW,GAAG,mBAAmB,GACzC,OAAO,CAAC,WAAW,CAAC,CAoBtB"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.invokeRemote = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const node_fetch_1 = tslib_1.__importDefault(require("node-fetch"));
|
|
6
|
+
const errors_1 = require("./errors");
|
|
7
|
+
const fetch_1 = require("./fetch");
|
|
8
|
+
async function invokeRemote(remoteKey, options) {
|
|
9
|
+
const { path, ...fetchOptions } = options;
|
|
10
|
+
if (!remoteKey) {
|
|
11
|
+
throw new Error('Missing remote key provided to invokeRemote');
|
|
12
|
+
}
|
|
13
|
+
if (!path) {
|
|
14
|
+
throw new Error('Missing or empty path provided to invokeRemote');
|
|
15
|
+
}
|
|
16
|
+
const url = (0, fetch_1.createRemoteUrlWithPath)('https://atl-paas.net', path);
|
|
17
|
+
url.searchParams.set('remoteKey', remoteKey);
|
|
18
|
+
const init = (0, fetch_1.addMagicAgent)(fetchOptions, 'FORGE_REMOTE_COMPUTE_REQUEST');
|
|
19
|
+
const response = await (0, node_fetch_1.default)(url, init);
|
|
20
|
+
handleResponseErrors(response, remoteKey);
|
|
21
|
+
return response;
|
|
22
|
+
}
|
|
23
|
+
exports.invokeRemote = invokeRemote;
|
|
24
|
+
function handleResponseErrors(response, remoteKey) {
|
|
25
|
+
const forgeProxyError = (0, fetch_1.getForgeProxyError)(response);
|
|
26
|
+
if (forgeProxyError === 'INVALID_REMOTE') {
|
|
27
|
+
throw new errors_1.InvalidRemoteError(`Invalid remote key provided: "${remoteKey}"`, remoteKey);
|
|
28
|
+
}
|
|
29
|
+
(0, fetch_1.handleProxyResponseErrors)(response);
|
|
30
|
+
}
|
package/out/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { authorize } from './authorization';
|
|
|
4
4
|
import { Route } from './safeUrl';
|
|
5
5
|
import { webTrigger } from './webTrigger';
|
|
6
6
|
import { __requestAtlassianAsApp, __requestAtlassianAsUser } from './runtime/fetch-and-storage';
|
|
7
|
+
import { invokeRemote } from './api/remote';
|
|
7
8
|
export declare type APIResponse = Pick<Response, 'json' | 'text' | 'arrayBuffer' | 'ok' | 'status' | 'statusText' | 'headers'>;
|
|
8
9
|
export declare type FetchMethod = (url: string, init?: RequestInit) => Promise<APIResponse>;
|
|
9
10
|
export declare type FetchMethodAllowingRoute = (url: string | Route, init?: RequestInit) => Promise<APIResponse>;
|
|
@@ -73,6 +74,7 @@ export interface FetchAPI extends RequestProductMethods {
|
|
|
73
74
|
}
|
|
74
75
|
export interface ForgeAPI extends FetchAPI {
|
|
75
76
|
store: StoreAPI;
|
|
77
|
+
invokeRemote: typeof invokeRemote;
|
|
76
78
|
}
|
|
77
79
|
declare const asUser: () => AsUserFetchMethods;
|
|
78
80
|
declare const asApp: () => AsAppFetchMethods;
|
|
@@ -88,7 +90,7 @@ export declare const privacy: {
|
|
|
88
90
|
reportPersonalData: (accounts: import("./privacy").Account[]) => Promise<import("./privacy").AccountUpdate[]>;
|
|
89
91
|
};
|
|
90
92
|
export default API;
|
|
91
|
-
export { asUser, asApp, authorize, fetch, requestJira, requestConfluence, requestBitbucket, store, storage, properties, webTrigger, __requestAtlassianAsApp, __requestAtlassianAsUser };
|
|
93
|
+
export { asUser, asApp, authorize, fetch, requestJira, requestConfluence, requestBitbucket, invokeRemote, store, storage, properties, webTrigger, __requestAtlassianAsApp, __requestAtlassianAsUser };
|
|
92
94
|
export declare const createRequestStargateAsApp: () => FetchMethod;
|
|
93
95
|
export { QueryBuilder, QueryApi, EntityStorageApi, Condition, ListResult, Predicate, Result, Value, WherePredicate, FilterPredicate, startsWith, WhereConditions, FilterConditions, SortOrder } from '@forge/storage';
|
|
94
96
|
export { route, assumeTrustedRoute, routeFromAbsolute, Route } from './safeUrl';
|
package/out/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAA8C,QAAQ,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAExG,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAGL,uBAAuB,EACvB,wBAAwB,EACzB,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAA8C,QAAQ,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAExG,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;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AAU,EACV,+BAA+B,EAC/B,8BAA8B,EAC9B,6BAA6B,EAC7B,eAAe,EACf,8BAA8B,EAC9B,SAAS,EACT,YAAY,EACZ,oBAAoB,EACpB,iBAAiB,EACjB,eAAe,EAChB,MAAM,cAAc,CAAC"}
|
package/out/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isExpectedError = exports.isHostedCodeError = exports.isForgePlatformError = exports.FUNCTION_ERR = exports.HttpError = exports.InvalidWorkspaceRequestedError = exports.NotAllowedError = exports.RequestProductNotAllowedError = exports.ProductEndpointNotAllowedError = exports.ExternalEndpointNotAllowedError = exports.FetchError = exports.ProxyRequestError = exports.NeedsAuthenticationError = exports.__getRuntime = exports.getAppContext = exports.routeFromAbsolute = exports.assumeTrustedRoute = exports.route = exports.SortOrder = exports.FilterConditions = exports.WhereConditions = exports.startsWith = exports.createRequestStargateAsApp = exports.__requestAtlassianAsUser = exports.__requestAtlassianAsApp = exports.webTrigger = exports.properties = exports.storage = exports.store = exports.requestBitbucket = exports.requestConfluence = exports.requestJira = exports.fetch = exports.authorize = exports.asApp = exports.asUser = exports.privacy = void 0;
|
|
3
|
+
exports.isExpectedError = exports.isHostedCodeError = exports.isForgePlatformError = exports.FUNCTION_ERR = exports.HttpError = exports.InvalidWorkspaceRequestedError = exports.NotAllowedError = exports.RequestProductNotAllowedError = exports.ProductEndpointNotAllowedError = exports.ExternalEndpointNotAllowedError = exports.FetchError = exports.ProxyRequestError = exports.NeedsAuthenticationError = exports.__getRuntime = exports.getAppContext = exports.routeFromAbsolute = exports.assumeTrustedRoute = exports.route = exports.SortOrder = exports.FilterConditions = exports.WhereConditions = exports.startsWith = exports.createRequestStargateAsApp = exports.__requestAtlassianAsUser = exports.__requestAtlassianAsApp = exports.webTrigger = exports.properties = exports.storage = exports.store = exports.invokeRemote = exports.requestBitbucket = exports.requestConfluence = exports.requestJira = exports.fetch = exports.authorize = exports.asApp = exports.asUser = exports.privacy = void 0;
|
|
4
4
|
const storage_1 = require("@forge/storage");
|
|
5
5
|
const authorization_1 = require("./authorization");
|
|
6
6
|
Object.defineProperty(exports, "authorize", { enumerable: true, get: function () { return authorization_1.authorize; } });
|
|
@@ -11,6 +11,8 @@ Object.defineProperty(exports, "webTrigger", { enumerable: true, get: function (
|
|
|
11
11
|
const fetch_and_storage_1 = require("./runtime/fetch-and-storage");
|
|
12
12
|
Object.defineProperty(exports, "__requestAtlassianAsApp", { enumerable: true, get: function () { return fetch_and_storage_1.__requestAtlassianAsApp; } });
|
|
13
13
|
Object.defineProperty(exports, "__requestAtlassianAsUser", { enumerable: true, get: function () { return fetch_and_storage_1.__requestAtlassianAsUser; } });
|
|
14
|
+
const remote_1 = require("./api/remote");
|
|
15
|
+
Object.defineProperty(exports, "invokeRemote", { enumerable: true, get: function () { return remote_1.invokeRemote; } });
|
|
14
16
|
function withDeprecatedMessage(method, message) {
|
|
15
17
|
const wrappedMethod = (...args) => {
|
|
16
18
|
console.warn(message);
|
|
@@ -47,7 +49,8 @@ const properties = properties_1.propertiesApi;
|
|
|
47
49
|
exports.properties = properties;
|
|
48
50
|
const API = {
|
|
49
51
|
...fetchAPI,
|
|
50
|
-
store: { ...store }
|
|
52
|
+
store: { ...store },
|
|
53
|
+
invokeRemote: remote_1.invokeRemote
|
|
51
54
|
};
|
|
52
55
|
exports.privacy = {
|
|
53
56
|
reportPersonalData: (0, privacy_1.createReportPersonalData)(fetch_and_storage_1.__requestAtlassianAsApp)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forge/api",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.8.0-next.0",
|
|
4
4
|
"description": "Forge API methods",
|
|
5
5
|
"author": "Atlassian",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"compile": "tsc -b -v"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
|
-
"@forge/runtime": "5.8.
|
|
15
|
+
"@forge/runtime": "5.8.1",
|
|
16
16
|
"@types/node": "14.18.63",
|
|
17
17
|
"expect-type": "^0.17.3",
|
|
18
18
|
"jest-matcher-specific-error": "^1.0.0",
|