@forge/api 3.5.0-next.1 → 3.6.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 +18 -0
- package/out/api/ari.js +0 -1
- package/out/api/errors.js +2 -6
- package/out/api/fetch.d.ts.map +1 -1
- package/out/api/fetch.js +29 -24
- package/out/api/index.js +2 -5
- package/out/api/polyfill-response.js +1 -4
- package/out/authorization/index.js +7 -10
- package/out/index.js +1 -4
- package/out/properties/product-scoped-storage.js +0 -2
- package/out/runtime/fetch-and-storage.js +3 -2
- package/out/safeUrl.js +0 -1
- package/out/webTrigger.js +10 -7
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @forge/api
|
|
2
2
|
|
|
3
|
+
## 3.6.0-next.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 1588c76: Embed metrics for external auth method calls in Node Runtime
|
|
8
|
+
|
|
9
|
+
## 3.5.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- 94956a5: Avoid logging NEEDS_AUTHENTICATION_ERR when it is thrown from requestCredentials()
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- f8a4714: Use InMemoryMetrics from the Node monorepo
|
|
18
|
+
- Updated dependencies [f8a4714]
|
|
19
|
+
- @forge/util@1.4.3
|
|
20
|
+
|
|
3
21
|
## 3.5.0-next.1
|
|
4
22
|
|
|
5
23
|
### Minor Changes
|
package/out/api/ari.js
CHANGED
package/out/api/errors.js
CHANGED
|
@@ -15,11 +15,11 @@ function isHostedCodeError(err) {
|
|
|
15
15
|
}
|
|
16
16
|
exports.isHostedCodeError = isHostedCodeError;
|
|
17
17
|
function isExpectedError(err) {
|
|
18
|
-
|
|
18
|
+
var _a;
|
|
19
|
+
return err.name === exports.NEEDS_AUTHENTICATION_ERR && !!((_a = err.options) === null || _a === void 0 ? void 0 : _a.isExpectedError);
|
|
19
20
|
}
|
|
20
21
|
exports.isExpectedError = isExpectedError;
|
|
21
22
|
class HttpError extends Error {
|
|
22
|
-
status;
|
|
23
23
|
constructor(message) {
|
|
24
24
|
super(message);
|
|
25
25
|
}
|
|
@@ -67,8 +67,6 @@ class InvalidWorkspaceRequestedError extends NotAllowedError {
|
|
|
67
67
|
}
|
|
68
68
|
exports.InvalidWorkspaceRequestedError = InvalidWorkspaceRequestedError;
|
|
69
69
|
class NeedsAuthenticationError extends HttpError {
|
|
70
|
-
serviceKey;
|
|
71
|
-
options;
|
|
72
70
|
constructor(error, serviceKey, options) {
|
|
73
71
|
super(error);
|
|
74
72
|
this.serviceKey = serviceKey;
|
|
@@ -80,8 +78,6 @@ class NeedsAuthenticationError extends HttpError {
|
|
|
80
78
|
}
|
|
81
79
|
exports.NeedsAuthenticationError = NeedsAuthenticationError;
|
|
82
80
|
class ProxyRequestError extends HttpError {
|
|
83
|
-
status;
|
|
84
|
-
errorCode;
|
|
85
81
|
constructor(status, errorCode) {
|
|
86
82
|
super(`Forge platform failed to process runtime HTTP request - ${status} - ${errorCode}`);
|
|
87
83
|
this.status = status;
|
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,EAAkC,MAAM,YAAY,CAAC;AAShF,OAAO,EAIL,QAAQ,EACR,WAAW,EAEZ,MAAM,IAAI,CAAC;AAKZ,aAAK,YAAY,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,CAAC;AAC5C,aAAK,SAAS,GAAG,MAAM,GAAG,YAAY,GAAG,UAAU,GAAG,WAAW,CAAC;AAElE,aAAK,oBAAoB,GAAG,MAAM,CAAC;AACnC,aAAK,kBAAkB,GAAG,MAAM,CAAC;AAEjC,aAAK,SAAS,GAAG;IAAE,QAAQ,EAAE,YAAY,CAAC;IAAC,MAAM,EAAE,SAAS,CAAA;CAAE,CAAC;AAC/D,aAAK,qBAAqB,GAAG;IAAE,QAAQ,EAAE,oBAAoB,CAAC;IAAC,MAAM,EAAE,kBAAkB,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../src/api/fetch.ts"],"names":[],"mappings":"AAEA,OAAc,EAAE,WAAW,EAAkC,MAAM,YAAY,CAAC;AAShF,OAAO,EAIL,QAAQ,EACR,WAAW,EAEZ,MAAM,IAAI,CAAC;AAKZ,aAAK,YAAY,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,CAAC;AAC5C,aAAK,SAAS,GAAG,MAAM,GAAG,YAAY,GAAG,UAAU,GAAG,WAAW,CAAC;AAElE,aAAK,oBAAoB,GAAG,MAAM,CAAC;AACnC,aAAK,kBAAkB,GAAG,MAAM,CAAC;AAEjC,aAAK,SAAS,GAAG;IAAE,QAAQ,EAAE,YAAY,CAAC;IAAC,MAAM,EAAE,SAAS,CAAA;CAAE,CAAC;AAC/D,aAAK,qBAAqB,GAAG;IAAE,QAAQ,EAAE,oBAAoB,CAAC;IAAC,MAAM,EAAE,kBAAkB,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAuB7G,wBAAgB,YAAY,CAAC,IAAI,EAAE,SAAS,GAAG,WAAW,CAqBzD;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,qBAAqB,GAAG,WAAW,CA0BpE;AA+GD,eAAO,MAAM,aAAa,EAAE,CAAC,IAAI,CAAC,EAAE,WAAW,EAAE,aAAa,CAAC,EAAE,MAAM,KAAK,WAG1E,CAAC;AAkDH,wBAAgB,iBAAiB,IAAI,QAAQ,CAsB5C;AAED,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,GAAG,GAAG,QAAQ,CAEvD"}
|
package/out/api/fetch.js
CHANGED
|
@@ -7,12 +7,23 @@ const _1 = require(".");
|
|
|
7
7
|
const runtime_1 = require("./runtime");
|
|
8
8
|
const polyfill_response_1 = require("./polyfill-response");
|
|
9
9
|
const errors_1 = require("./errors");
|
|
10
|
+
async function wrapInMetrics(options, cb) {
|
|
11
|
+
const metrics = (0, runtime_1.__getRuntime)().metrics;
|
|
12
|
+
metrics.counter(options.name, options.tags).incr();
|
|
13
|
+
const timer = metrics.timing(options.name, options.tags).measure();
|
|
14
|
+
try {
|
|
15
|
+
return await cb();
|
|
16
|
+
}
|
|
17
|
+
finally {
|
|
18
|
+
timer.stop();
|
|
19
|
+
}
|
|
20
|
+
}
|
|
10
21
|
function fetchProduct(args) {
|
|
11
22
|
return async (path, init) => {
|
|
12
23
|
const url = productURL(args.remote, path);
|
|
13
24
|
init = (0, exports.addMagicAgent)(init);
|
|
14
25
|
if (!hasAuthorizationHeader(init.headers)) {
|
|
15
|
-
init.headers = {
|
|
26
|
+
init.headers = Object.assign(Object.assign({}, init.headers), { authorization: `Forge ${args.provider}` });
|
|
16
27
|
}
|
|
17
28
|
const response = await (0, node_fetch_1.default)(url, init);
|
|
18
29
|
handleProxyResponseErrors(response);
|
|
@@ -29,10 +40,7 @@ function fetchRemote(args) {
|
|
|
29
40
|
}
|
|
30
41
|
remoteUrl.searchParams.append('path', path);
|
|
31
42
|
init = (0, exports.addMagicAgent)(init, 'EXTERNAL_AUTH_REQUEST');
|
|
32
|
-
init.headers = {
|
|
33
|
-
...init.headers,
|
|
34
|
-
authorization: `Forge user ${args.provider} ${args.account}`
|
|
35
|
-
};
|
|
43
|
+
init.headers = Object.assign(Object.assign({}, init.headers), { authorization: `Forge user ${args.provider} ${args.account}` });
|
|
36
44
|
const response = await (0, node_fetch_1.default)(remoteUrl, init);
|
|
37
45
|
handleProxyResponseErrors(response);
|
|
38
46
|
return response;
|
|
@@ -48,7 +56,7 @@ function getDefaultRemote(provider) {
|
|
|
48
56
|
}
|
|
49
57
|
function findExternalAuthProviderConfigOrThrow(provider) {
|
|
50
58
|
const { externalAuth } = (0, runtime_1.__getRuntime)();
|
|
51
|
-
const externalAuthProvider = externalAuth
|
|
59
|
+
const externalAuthProvider = externalAuth === null || externalAuth === void 0 ? void 0 : externalAuth.find((externalAuthMetaData) => {
|
|
52
60
|
return externalAuthMetaData.service === provider;
|
|
53
61
|
});
|
|
54
62
|
if (!externalAuthProvider) {
|
|
@@ -78,23 +86,21 @@ function productURL(remote, path) {
|
|
|
78
86
|
return `https://${remote}${path}`;
|
|
79
87
|
}
|
|
80
88
|
function lazyThrowNeedsAuthenticationError(serviceKey) {
|
|
81
|
-
return async (scopes) => {
|
|
89
|
+
return async (scopes) => wrapInMetrics({ name: 'api.asUser.withProvider.requestCredentials', tags: { passingScopes: String(!!scopes) } }, async () => {
|
|
82
90
|
throw new errors_1.NeedsAuthenticationError('Authentication Required', serviceKey, { scopes, isExpectedError: true });
|
|
83
|
-
};
|
|
91
|
+
});
|
|
84
92
|
}
|
|
85
93
|
function buildExternalAuthAccountsInfo(provider, remote) {
|
|
86
94
|
const { accounts } = findExternalAuthProviderConfigOrThrow(provider);
|
|
87
95
|
const buildAccountModel = (account) => {
|
|
88
|
-
const { externalAccountId: id,
|
|
89
|
-
return {
|
|
96
|
+
const { externalAccountId: id } = account, rest = tslib_1.__rest(account, ["externalAccountId"]);
|
|
97
|
+
return Object.assign(Object.assign({}, rest), { id });
|
|
90
98
|
};
|
|
91
99
|
const buildExternalAuthAccountMethods = (account, outboundAuthAccountId) => ({
|
|
92
|
-
hasCredentials: async (scopes) => !scopes || scopes.every((scope) => account.scopes.includes(scope)),
|
|
100
|
+
hasCredentials: async (scopes) => wrapInMetrics({ name: 'api.asUser.withProvider.hasCredentials', tags: { passingScopes: String(!!scopes) } }, async () => !scopes || scopes.every((scope) => account.scopes.includes(scope))),
|
|
93
101
|
requestCredentials: lazyThrowNeedsAuthenticationError(provider),
|
|
94
|
-
getAccount: async () => {
|
|
95
|
-
|
|
96
|
-
},
|
|
97
|
-
fetch: (0, _1.wrapWithRouteUnwrapper)(fetchRemote({ provider, remote: remote ?? getDefaultRemote(provider), account: outboundAuthAccountId }))
|
|
102
|
+
getAccount: async () => wrapInMetrics({ name: 'api.asUser.withProvider.getAccount' }, async () => account),
|
|
103
|
+
fetch: (0, _1.wrapWithRouteUnwrapper)(fetchRemote({ provider, remote: remote !== null && remote !== void 0 ? remote : getDefaultRemote(provider), account: outboundAuthAccountId }))
|
|
98
104
|
});
|
|
99
105
|
return accounts.map((account) => {
|
|
100
106
|
const authAccount = buildAccountModel(account);
|
|
@@ -104,10 +110,7 @@ function buildExternalAuthAccountsInfo(provider, remote) {
|
|
|
104
110
|
};
|
|
105
111
|
});
|
|
106
112
|
}
|
|
107
|
-
const addMagicAgent = (init, agentOverride) => ({
|
|
108
|
-
...init,
|
|
109
|
-
agent: (agentOverride ?? 'FORGE_PRODUCT_REQUEST')
|
|
110
|
-
});
|
|
113
|
+
const addMagicAgent = (init, agentOverride) => (Object.assign(Object.assign({}, init), { agent: (agentOverride !== null && agentOverride !== void 0 ? agentOverride : 'FORGE_PRODUCT_REQUEST') }));
|
|
111
114
|
exports.addMagicAgent = addMagicAgent;
|
|
112
115
|
const throwNotImplementedError = () => {
|
|
113
116
|
throw new Error('not implemented');
|
|
@@ -122,16 +125,18 @@ const withProvider = (provider, remote) => {
|
|
|
122
125
|
};
|
|
123
126
|
return {
|
|
124
127
|
hasCredentials: async (scopes) => {
|
|
125
|
-
return defaultAccountInfo
|
|
128
|
+
return defaultAccountInfo
|
|
129
|
+
? await defaultAccountInfo.methods.hasCredentials(scopes)
|
|
130
|
+
: await wrapInMetrics({ name: 'api.asUser.withProvider.hasCredentials', tags: { passingScopes: String(!!scopes) } }, async () => false);
|
|
126
131
|
},
|
|
127
|
-
getAccount: async () => {
|
|
132
|
+
getAccount: async () => wrapInMetrics({ name: 'api.asUser.withProvider.getAccount' }, async () => {
|
|
128
133
|
return defaultAccountInfo ? defaultAccountInfo.account : undefined;
|
|
129
|
-
},
|
|
134
|
+
}),
|
|
130
135
|
requestCredentials: lazyThrowNeedsAuthenticationError(provider),
|
|
131
136
|
listCredentials: throwNotImplementedError,
|
|
132
|
-
listAccounts: async () => {
|
|
137
|
+
listAccounts: async () => wrapInMetrics({ name: 'api.asUser.withProvider.listAccounts' }, async () => {
|
|
133
138
|
return accountsInfo.map(({ account }) => account);
|
|
134
|
-
},
|
|
139
|
+
}),
|
|
135
140
|
asAccount: (externalAccountId) => {
|
|
136
141
|
const accountInfo = accountsInfo.find(({ account }) => account.id === externalAccountId);
|
|
137
142
|
if (!accountInfo) {
|
package/out/api/index.js
CHANGED
|
@@ -4,11 +4,8 @@ exports.wrapFetchApiMethods = exports.wrapWithRouteUnwrapper = exports.wrapReque
|
|
|
4
4
|
const safeUrl_1 = require("../safeUrl");
|
|
5
5
|
const wrapRequestGraph = (requestGraphApi) => (query, variables, headers = {}) => requestGraphApi('/graphql', {
|
|
6
6
|
method: 'POST',
|
|
7
|
-
headers: {
|
|
8
|
-
body: JSON.stringify({
|
|
9
|
-
query,
|
|
10
|
-
...(variables ? { variables } : {})
|
|
11
|
-
})
|
|
7
|
+
headers: Object.assign(Object.assign({}, headers), { 'Content-Type': 'application/json' }),
|
|
8
|
+
body: JSON.stringify(Object.assign({ query }, (variables ? { variables } : {})))
|
|
12
9
|
});
|
|
13
10
|
exports.wrapRequestGraph = wrapRequestGraph;
|
|
14
11
|
const wrapRequestConnectedData = (fetch) => (path, init) => {
|
|
@@ -4,9 +4,6 @@ exports.transformResponse = void 0;
|
|
|
4
4
|
const node_fetch_1 = require("node-fetch");
|
|
5
5
|
const transformResponse = (fetchApi) => async (url, init) => {
|
|
6
6
|
const response = await fetchApi(url, init);
|
|
7
|
-
return {
|
|
8
|
-
...response,
|
|
9
|
-
headers: new node_fetch_1.Headers(response.headers)
|
|
10
|
-
};
|
|
7
|
+
return Object.assign(Object.assign({}, response), { headers: new node_fetch_1.Headers(response.headers) });
|
|
11
8
|
};
|
|
12
9
|
exports.transformResponse = transformResponse;
|
|
@@ -14,15 +14,12 @@ const authorize = () => {
|
|
|
14
14
|
if (!accountId) {
|
|
15
15
|
throw new Error(`Couldn’t find the accountId of the invoking user. This API can only be used inside user-invoked modules.`);
|
|
16
16
|
}
|
|
17
|
-
return {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return res.json();
|
|
25
|
-
}, accountId)
|
|
26
|
-
};
|
|
17
|
+
return Object.assign(Object.assign({}, (0, auth_1.authorizeConfluenceWithFetch)(async (path, opts) => {
|
|
18
|
+
const res = await (0, __1.asUser)().requestConfluence((0, __1.assumeTrustedRoute)(path), opts);
|
|
19
|
+
return res.json();
|
|
20
|
+
}, accountId)), (0, auth_1.authorizeJiraWithFetch)(async (path, opts) => {
|
|
21
|
+
const res = await (0, __1.asUser)().requestJira((0, __1.assumeTrustedRoute)(path), opts);
|
|
22
|
+
return res.json();
|
|
23
|
+
}, accountId));
|
|
27
24
|
};
|
|
28
25
|
exports.authorize = authorize;
|
package/out/index.js
CHANGED
|
@@ -44,10 +44,7 @@ const storage = (0, storage_1.getStorageInstanceWithQuery)(new storage_1.GlobalS
|
|
|
44
44
|
exports.storage = storage;
|
|
45
45
|
const properties = properties_1.propertiesApi;
|
|
46
46
|
exports.properties = properties;
|
|
47
|
-
const API = {
|
|
48
|
-
...fetchAPI,
|
|
49
|
-
store: { ...store }
|
|
50
|
-
};
|
|
47
|
+
const API = Object.assign(Object.assign({}, fetchAPI), { store: Object.assign({}, store) });
|
|
51
48
|
exports.privacy = {
|
|
52
49
|
reportPersonalData: (0, privacy_1.createReportPersonalData)((0, fetch_and_storage_1.createRequestStargateAsApp)())
|
|
53
50
|
};
|
|
@@ -3,8 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ProductScopedStorage = void 0;
|
|
4
4
|
const storage_1 = require("@forge/storage");
|
|
5
5
|
class ProductScopedStorage {
|
|
6
|
-
storageApiPath;
|
|
7
|
-
apiClient;
|
|
8
6
|
constructor(storageApiPath, apiClient) {
|
|
9
7
|
this.storageApiPath = storageApiPath;
|
|
10
8
|
this.apiClient = apiClient;
|
|
@@ -3,10 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getFetchAPI = exports.getContextAri = exports.createRequestStargateAsApp = void 0;
|
|
4
4
|
const fetch_1 = require("../api/fetch");
|
|
5
5
|
const runtime_1 = require("../api/runtime");
|
|
6
|
-
const createRequestStargateAsApp = () => global.api
|
|
6
|
+
const createRequestStargateAsApp = () => { var _a, _b; return (_b = (_a = global.api) === null || _a === void 0 ? void 0 : _a.asApp().__requestAtlassian) !== null && _b !== void 0 ? _b : (0, fetch_1.fetchProduct)({ provider: 'app', remote: 'stargate' }); };
|
|
7
7
|
exports.createRequestStargateAsApp = createRequestStargateAsApp;
|
|
8
8
|
const getContextAri = () => {
|
|
9
|
-
|
|
9
|
+
var _a;
|
|
10
|
+
const sandboxGetAppAri = (_a = global.api) === null || _a === void 0 ? void 0 : _a.__getAppAri;
|
|
10
11
|
if (sandboxGetAppAri) {
|
|
11
12
|
return sandboxGetAppAri();
|
|
12
13
|
}
|
package/out/safeUrl.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.assumeTrustedRoute = exports.requireSafeUrl = exports.route = exports.routeFromAbsolute = exports.isRoute = void 0;
|
|
4
4
|
class ReadonlyRoute {
|
|
5
|
-
value_;
|
|
6
5
|
constructor(value_) {
|
|
7
6
|
this.value_ = value_;
|
|
8
7
|
}
|
package/out/webTrigger.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.webTrigger = void 0;
|
|
|
4
4
|
const runtime_1 = require("./api/runtime");
|
|
5
5
|
const fetch_and_storage_1 = require("./runtime/fetch-and-storage");
|
|
6
6
|
const proxyGetWebTriggerURL = (0, runtime_1.wrapInMetrics)('api.getWebTriggerUrl', async (webTriggerModuleKey, forceCreate) => {
|
|
7
|
+
var _a, _b;
|
|
7
8
|
const runtime = (0, runtime_1.__getRuntime)();
|
|
8
9
|
const response = await (0, fetch_and_storage_1.createRequestStargateAsApp)()('/graphql', {
|
|
9
10
|
method: 'POST',
|
|
@@ -31,13 +32,14 @@ const proxyGetWebTriggerURL = (0, runtime_1.wrapInMetrics)('api.getWebTriggerUrl
|
|
|
31
32
|
throw new Error(`Internal error occurred: Failed to get web trigger URL: ${response.statusText}.`);
|
|
32
33
|
}
|
|
33
34
|
const responseBody = await response.json();
|
|
34
|
-
if (!responseBody
|
|
35
|
+
if (!((_b = (_a = responseBody === null || responseBody === void 0 ? void 0 : responseBody.data) === null || _a === void 0 ? void 0 : _a.createWebTriggerUrl) === null || _b === void 0 ? void 0 : _b.url)) {
|
|
35
36
|
throw new Error(`Internal error occurred: Failed to get web trigger URL.`);
|
|
36
37
|
}
|
|
37
38
|
return responseBody.data.createWebTriggerUrl.url;
|
|
38
39
|
});
|
|
39
40
|
const proxyDeleteWebTriggerURL = (0, runtime_1.wrapInMetrics)('api.deleteWebTriggerUrl', async (webTriggerUrl) => {
|
|
40
41
|
const callDelete = async (webTriggerUrlId) => {
|
|
42
|
+
var _a, _b, _c, _d;
|
|
41
43
|
const response = await (0, fetch_and_storage_1.createRequestStargateAsApp)()('/graphql', {
|
|
42
44
|
method: 'POST',
|
|
43
45
|
headers: { 'Content-Type': 'application/json' },
|
|
@@ -59,8 +61,8 @@ const proxyDeleteWebTriggerURL = (0, runtime_1.wrapInMetrics)('api.deleteWebTrig
|
|
|
59
61
|
throw new Error(`Internal error occurred: Failed to delete web trigger URL: ${response.statusText}.`);
|
|
60
62
|
}
|
|
61
63
|
const responseBody = await response.json();
|
|
62
|
-
if (!responseBody
|
|
63
|
-
const errorText = responseBody
|
|
64
|
+
if (!((_b = (_a = responseBody === null || responseBody === void 0 ? void 0 : responseBody.data) === null || _a === void 0 ? void 0 : _a.deleteWebTriggerUrl) === null || _b === void 0 ? void 0 : _b.success)) {
|
|
65
|
+
const errorText = ((_d = (_c = responseBody === null || responseBody === void 0 ? void 0 : responseBody.data) === null || _c === void 0 ? void 0 : _c.deleteWebTriggerUrl) === null || _d === void 0 ? void 0 : _d.message) || 'unknown error';
|
|
64
66
|
throw new Error(`Internal error occurred: Failed to delete web trigger URL: ${errorText}`);
|
|
65
67
|
}
|
|
66
68
|
};
|
|
@@ -70,6 +72,7 @@ const proxyDeleteWebTriggerURL = (0, runtime_1.wrapInMetrics)('api.deleteWebTrig
|
|
|
70
72
|
}
|
|
71
73
|
});
|
|
72
74
|
const proxyGetWebTriggerUrlIds = (0, runtime_1.wrapInMetrics)('api.getWebTriggerUrlIds', async (webTriggerUrl) => {
|
|
75
|
+
var _a;
|
|
73
76
|
const runtime = (0, runtime_1.__getRuntime)();
|
|
74
77
|
const response = await (0, fetch_and_storage_1.createRequestStargateAsApp)()('/graphql', {
|
|
75
78
|
method: 'POST',
|
|
@@ -94,7 +97,7 @@ const proxyGetWebTriggerUrlIds = (0, runtime_1.wrapInMetrics)('api.getWebTrigger
|
|
|
94
97
|
throw new Error(`Internal error occurred: Failed to get web trigger URLs: ${response.statusText}.`);
|
|
95
98
|
}
|
|
96
99
|
const responseBody = await response.json();
|
|
97
|
-
if (!responseBody
|
|
100
|
+
if (!((_a = responseBody === null || responseBody === void 0 ? void 0 : responseBody.data) === null || _a === void 0 ? void 0 : _a.webTriggerUrlsByAppContext) || responseBody.data.webTriggerUrlsByAppContext.length == 0) {
|
|
98
101
|
throw new Error('Internal error occurred: No web trigger URLs found');
|
|
99
102
|
}
|
|
100
103
|
const result = responseBody.data.webTriggerUrlsByAppContext
|
|
@@ -106,7 +109,7 @@ const proxyGetWebTriggerUrlIds = (0, runtime_1.wrapInMetrics)('api.getWebTrigger
|
|
|
106
109
|
return result;
|
|
107
110
|
});
|
|
108
111
|
exports.webTrigger = {
|
|
109
|
-
getUrl: async (webTriggerModuleKey, forceCreate = false) => (global.api
|
|
110
|
-
deleteUrl: async (webTriggerUrl) => (global.api
|
|
111
|
-
getUrlIds: async (webTriggerUrl) => (global.api
|
|
112
|
+
getUrl: async (webTriggerModuleKey, forceCreate = false) => { var _a, _b, _c; return ((_c = (_b = (_a = global.api) === null || _a === void 0 ? void 0 : _a.webTrigger) === null || _b === void 0 ? void 0 : _b.getUrl) !== null && _c !== void 0 ? _c : proxyGetWebTriggerURL)(webTriggerModuleKey, forceCreate); },
|
|
113
|
+
deleteUrl: async (webTriggerUrl) => { var _a, _b, _c; return ((_c = (_b = (_a = global.api) === null || _a === void 0 ? void 0 : _a.webTrigger) === null || _b === void 0 ? void 0 : _b.deleteUrl) !== null && _c !== void 0 ? _c : proxyDeleteWebTriggerURL)(webTriggerUrl); },
|
|
114
|
+
getUrlIds: async (webTriggerUrl) => { var _a, _b, _c; return ((_c = (_b = (_a = global.api) === null || _a === void 0 ? void 0 : _a.webTrigger) === null || _b === void 0 ? void 0 : _b.getUrlIds) !== null && _c !== void 0 ? _c : proxyGetWebTriggerUrlIds)(webTriggerUrl); }
|
|
112
115
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forge/api",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.6.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.
|
|
15
|
+
"@forge/runtime": "5.8.0-next.0",
|
|
16
16
|
"@types/node": "14.18.63",
|
|
17
17
|
"expect-type": "^0.17.3",
|
|
18
18
|
"jest-matcher-specific-error": "^1.0.0",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"@forge/auth": "0.0.5",
|
|
23
23
|
"@forge/egress": "1.2.13",
|
|
24
24
|
"@forge/storage": "1.5.15",
|
|
25
|
-
"@forge/util": "1.4.3
|
|
25
|
+
"@forge/util": "1.4.3",
|
|
26
26
|
"@types/node-fetch": "^2.6.11",
|
|
27
27
|
"node-fetch": "2.7.0"
|
|
28
28
|
}
|