@forge/api 0.0.0-experimental-490cfcf → 0.0.0-experimental-9b81865
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 +131 -2
- package/out/api/fetch.d.ts +10 -0
- package/out/api/fetch.d.ts.map +1 -0
- package/out/api/fetch.js +57 -0
- package/out/api/index.d.ts +5 -3
- package/out/api/index.d.ts.map +1 -1
- package/out/api/index.js +21 -16
- package/out/api/polyfill-response.d.ts.map +1 -1
- package/out/api/polyfill-response.js +2 -1
- package/out/api/runtime.d.ts +13 -0
- package/out/api/runtime.d.ts.map +1 -0
- package/out/api/runtime.js +11 -0
- package/out/authorization/index.d.ts +4 -4
- package/out/authorization/index.js +4 -3
- package/out/index.d.ts +21 -7
- package/out/index.d.ts.map +1 -1
- package/out/index.js +20 -11
- package/out/privacy/index.d.ts.map +1 -1
- package/out/privacy/index.js +2 -1
- package/out/properties/confluence-page.js +1 -1
- package/out/properties/confluence-space.js +1 -1
- package/out/properties/index.d.ts.map +1 -1
- package/out/properties/index.js +7 -7
- package/out/properties/jira-issue.js +1 -1
- package/out/properties/jira-project.js +1 -1
- package/out/properties/product-scoped-storage.d.ts +1 -1
- package/out/properties/product-scoped-storage.d.ts.map +1 -1
- package/out/properties/product-scoped-storage.js +1 -1
- package/out/properties/sanitized-key.js +3 -2
- package/out/runtime/fetch-and-storage.d.ts +4 -0
- package/out/runtime/fetch-and-storage.d.ts.map +1 -0
- package/out/runtime/fetch-and-storage.js +29 -0
- package/out/safeUrl.d.ts +1 -0
- package/out/safeUrl.d.ts.map +1 -1
- package/out/safeUrl.js +6 -1
- package/package.json +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,11 +1,140 @@
|
|
|
1
1
|
# @forge/api
|
|
2
2
|
|
|
3
|
-
## 0.0.0-experimental-
|
|
3
|
+
## 0.0.0-experimental-9b81865
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 9b81865: Add NodeJS runtime support for Events API
|
|
8
|
+
|
|
9
|
+
## 2.10.1-next.0
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- dfab69c: Add NodeJS runtime support for Events API
|
|
14
|
+
|
|
15
|
+
## 2.10.0
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- e0e3587: Add NodeJS runtime support for Storage API
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- 37f48c5: Fix contextAri for nodejs runtime
|
|
24
|
+
- ca8551d: Fix proxy fetch not respecting requestInit options
|
|
25
|
+
|
|
26
|
+
## 2.10.0-next.2
|
|
27
|
+
|
|
28
|
+
### Patch Changes
|
|
29
|
+
|
|
30
|
+
- 37f48c5: Fix contextAri for nodejs runtime
|
|
31
|
+
|
|
32
|
+
## 2.10.0-next.1
|
|
33
|
+
|
|
34
|
+
### Minor Changes
|
|
35
|
+
|
|
36
|
+
- e0e3587a: Add NodeJS runtime support for Storage API
|
|
37
|
+
|
|
38
|
+
## 2.9.2-next.0
|
|
39
|
+
|
|
40
|
+
### Patch Changes
|
|
41
|
+
|
|
42
|
+
- ca8551dd: Fix proxy fetch not respecting requestInit options
|
|
43
|
+
|
|
44
|
+
## 2.9.1
|
|
45
|
+
|
|
46
|
+
### Patch Changes
|
|
47
|
+
|
|
48
|
+
- 73b929a: Export routeFromAbsolute
|
|
49
|
+
- 8d0dc10: Use a single global to pass information from the runtime
|
|
50
|
+
- 7a4fa35: Support internet egress calls in the new runtime
|
|
51
|
+
|
|
52
|
+
## 2.9.1-next.2
|
|
53
|
+
|
|
54
|
+
### Patch Changes
|
|
55
|
+
|
|
56
|
+
- 8d0dc104: Use a single global to pass information from the runtime
|
|
57
|
+
|
|
58
|
+
## 2.9.1-next.1
|
|
59
|
+
|
|
60
|
+
### Patch Changes
|
|
61
|
+
|
|
62
|
+
- 73b929a: Export routeFromAbsolute
|
|
63
|
+
|
|
64
|
+
## 2.9.1-next.0
|
|
65
|
+
|
|
66
|
+
### Patch Changes
|
|
67
|
+
|
|
68
|
+
- 7a4fa35: Support internet egress calls in the new runtime
|
|
69
|
+
|
|
70
|
+
## 2.9.0
|
|
71
|
+
|
|
72
|
+
### Minor Changes
|
|
73
|
+
|
|
74
|
+
- e5dd325: support for requestBitbucket
|
|
75
|
+
|
|
76
|
+
## 2.9.0-next.0
|
|
77
|
+
|
|
78
|
+
### Minor Changes
|
|
79
|
+
|
|
80
|
+
- e5dd325d: support for requestBitbucket
|
|
81
|
+
|
|
82
|
+
## 2.8.1
|
|
83
|
+
|
|
84
|
+
### Patch Changes
|
|
85
|
+
|
|
86
|
+
- 8e2a5a6: Update node-fetch version
|
|
87
|
+
- Updated dependencies [8e2a5a6]
|
|
88
|
+
- @forge/storage@1.3.1
|
|
89
|
+
|
|
90
|
+
## 2.8.1-next.0
|
|
91
|
+
|
|
92
|
+
### Patch Changes
|
|
93
|
+
|
|
94
|
+
- 8e2a5a6: Update node-fetch version
|
|
95
|
+
- Updated dependencies [8e2a5a6]
|
|
96
|
+
- @forge/storage@1.3.1-next.0
|
|
97
|
+
|
|
98
|
+
## 2.8.0
|
|
99
|
+
|
|
100
|
+
### Minor Changes
|
|
101
|
+
|
|
102
|
+
- 95913f6: Call product APIs via proxy on Node runtime
|
|
103
|
+
|
|
104
|
+
## 2.8.0-next.0
|
|
105
|
+
|
|
106
|
+
### Minor Changes
|
|
107
|
+
|
|
108
|
+
- 95913f6: Call product APIs via proxy on Node runtime
|
|
109
|
+
|
|
110
|
+
## 2.7.0
|
|
111
|
+
|
|
112
|
+
### Minor Changes
|
|
113
|
+
|
|
114
|
+
- b3ee297: Unblock valid property API keys and handled error propagation
|
|
115
|
+
|
|
116
|
+
### Patch Changes
|
|
117
|
+
|
|
118
|
+
- Updated dependencies [3c3c42b]
|
|
119
|
+
- @forge/storage@1.3.0
|
|
120
|
+
|
|
121
|
+
## 2.7.0-next.0
|
|
122
|
+
|
|
123
|
+
### Minor Changes
|
|
124
|
+
|
|
125
|
+
- b3ee2973: Unblock valid property API keys and handled error propagation
|
|
126
|
+
|
|
127
|
+
### Patch Changes
|
|
128
|
+
|
|
129
|
+
- Updated dependencies [3c3c42b9]
|
|
130
|
+
- @forge/storage@1.3.0-next.0
|
|
131
|
+
|
|
132
|
+
## 2.6.1
|
|
4
133
|
|
|
5
134
|
### Patch Changes
|
|
6
135
|
|
|
7
136
|
- Updated dependencies [21e392d]
|
|
8
|
-
- @forge/storage@
|
|
137
|
+
- @forge/storage@1.2.0
|
|
9
138
|
|
|
10
139
|
## 2.6.1-next.0
|
|
11
140
|
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { RequestInfo, RequestInit, Response } from 'node-fetch';
|
|
3
|
+
import { Url } from 'url';
|
|
4
|
+
import { FetchAPI } from '..';
|
|
5
|
+
declare type FetchFunction = (url: RequestInfo | Url, options: RequestInit | undefined) => Promise<Response>;
|
|
6
|
+
export declare const createProxyFetch: (provider: 'app' | 'user' | undefined, remote: 'jira' | 'confluence' | 'stargate' | 'bitbucket') => FetchFunction;
|
|
7
|
+
export declare function getNodeRuntimeAPI(): FetchAPI;
|
|
8
|
+
export declare function getSandboxRuntimeAPI(api: any): FetchAPI;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=fetch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../src/api/fetch.ts"],"names":[],"mappings":";AAAA,OAAc,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAW,MAAM,YAAY,CAAC;AAChF,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAK9B,aAAK,aAAa,GAAG,CAAC,GAAG,EAAE,WAAW,GAAG,GAAG,EAAE,OAAO,EAAE,WAAW,GAAG,SAAS,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;AAErG,eAAO,MAAM,gBAAgB,aACjB,KAAK,GAAG,MAAM,GAAG,SAAS,UAC5B,MAAM,GAAG,YAAY,GAAG,UAAU,GAAG,WAAW,KACvD,aAWF,CAAC;AAuBF,wBAAgB,iBAAiB,IAAI,QAAQ,CAoB5C;AAED,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,GAAG,GAAG,QAAQ,CAEvD"}
|
package/out/api/fetch.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSandboxRuntimeAPI = exports.getNodeRuntimeAPI = exports.createProxyFetch = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const node_fetch_1 = tslib_1.__importStar(require("node-fetch"));
|
|
6
|
+
const _1 = require(".");
|
|
7
|
+
const runtime_1 = require("./runtime");
|
|
8
|
+
const polyfill_response_1 = require("./polyfill-response");
|
|
9
|
+
const egress_1 = require("@forge/egress");
|
|
10
|
+
const createProxyFetch = (provider, remote) => {
|
|
11
|
+
return (url, options) => {
|
|
12
|
+
const { proxy } = (0, runtime_1.getRuntime)();
|
|
13
|
+
const request = new node_fetch_1.Request(url, options);
|
|
14
|
+
const proxyRequest = new node_fetch_1.Request(`${proxy.url}/fpp/provider/${provider}/remote/${remote}`, request);
|
|
15
|
+
proxyRequest.headers.set('Forge-Proxy-Target-Relative', request.url);
|
|
16
|
+
proxyRequest.headers.set('Forge-Proxy-Authorization', `Bearer ${proxy.token}`);
|
|
17
|
+
return (0, node_fetch_1.default)(proxyRequest);
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
exports.createProxyFetch = createProxyFetch;
|
|
21
|
+
const throwNotImplementedError = () => {
|
|
22
|
+
throw new Error('not implemented');
|
|
23
|
+
};
|
|
24
|
+
const wrapExternalEgress = (url, options) => {
|
|
25
|
+
const { allowedEgress } = (0, runtime_1.getRuntime)();
|
|
26
|
+
const egressFilteringService = new egress_1.EgressFilteringService(allowedEgress);
|
|
27
|
+
if (!egressFilteringService.isValidUrl(url)) {
|
|
28
|
+
throw new Error(`URL not included in the external fetch backend permissions: ${url}. Visit go.atlassian.com/forge-egress for more information.`);
|
|
29
|
+
}
|
|
30
|
+
return (0, node_fetch_1.default)(url, options);
|
|
31
|
+
};
|
|
32
|
+
function getNodeRuntimeAPI() {
|
|
33
|
+
return {
|
|
34
|
+
fetch: (0, _1.wrapWithRouteUnwrapper)(wrapExternalEgress),
|
|
35
|
+
requestJira: throwNotImplementedError,
|
|
36
|
+
requestConfluence: throwNotImplementedError,
|
|
37
|
+
requestBitbucket: throwNotImplementedError,
|
|
38
|
+
asUser: () => ({
|
|
39
|
+
requestJira: (0, _1.wrapRequestProduct)((0, exports.createProxyFetch)('user', 'jira')),
|
|
40
|
+
requestConfluence: (0, _1.wrapRequestProduct)((0, exports.createProxyFetch)('user', 'confluence')),
|
|
41
|
+
requestBitbucket: throwNotImplementedError,
|
|
42
|
+
requestGraph: (0, _1.wrapRequestGraph)((0, exports.createProxyFetch)('user', 'stargate')),
|
|
43
|
+
withProvider: throwNotImplementedError
|
|
44
|
+
}),
|
|
45
|
+
asApp: () => ({
|
|
46
|
+
requestJira: (0, _1.wrapRequestProduct)((0, exports.createProxyFetch)('app', 'jira')),
|
|
47
|
+
requestConfluence: (0, _1.wrapRequestProduct)((0, exports.createProxyFetch)('app', 'confluence')),
|
|
48
|
+
requestGraph: (0, _1.wrapRequestGraph)((0, exports.createProxyFetch)('app', 'stargate')),
|
|
49
|
+
requestBitbucket: throwNotImplementedError
|
|
50
|
+
})
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
exports.getNodeRuntimeAPI = getNodeRuntimeAPI;
|
|
54
|
+
function getSandboxRuntimeAPI(api) {
|
|
55
|
+
return (0, _1.wrapFetchApiMethods)(api, polyfill_response_1.transformResponse);
|
|
56
|
+
}
|
|
57
|
+
exports.getSandboxRuntimeAPI = getSandboxRuntimeAPI;
|
package/out/api/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { RequestInfo, RequestInit } from 'node-fetch';
|
|
2
|
-
import { FetchAPI } from '..';
|
|
3
|
-
export
|
|
4
|
-
export declare
|
|
2
|
+
import { FetchAPI, FetchMethod, RequestProductMethod, FetchMethodAllowingRoute, APIResponse } from '..';
|
|
3
|
+
export declare type FetchWrapper = (fetchApi: Function) => (url: RequestInfo, init?: RequestInit) => Promise<APIResponse>;
|
|
4
|
+
export declare const wrapRequestGraph: (requestGraphApi: FetchMethod) => (query: string, variables?: any, headers?: {}) => Promise<APIResponse>;
|
|
5
|
+
export declare const wrapRequestProduct: (x: FetchMethod) => RequestProductMethod;
|
|
6
|
+
export declare const wrapWithRouteUnwrapper: (x: FetchMethod) => FetchMethodAllowingRoute;
|
|
5
7
|
export declare const wrapFetchApiMethods: (api: any, wrapFetch: FetchWrapper) => FetchAPI;
|
|
6
8
|
//# sourceMappingURL=index.d.ts.map
|
package/out/api/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EACL,QAAQ,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EACL,QAAQ,EAER,WAAW,EAEX,oBAAoB,EACpB,wBAAwB,EAGxB,WAAW,EACZ,MAAM,IAAI,CAAC;AAIZ,oBAAY,YAAY,GAAG,CAAC,QAAQ,EAAE,QAAQ,KAAK,CAAC,GAAG,EAAE,WAAW,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;AAElH,eAAO,MAAM,gBAAgB,oBAAqB,WAAW,aAAa,MAAM,cAAc,GAAG,uCAQ7F,CAAC;AAEL,eAAO,MAAM,kBAAkB,EAAE,CAAC,CAAC,EAAE,WAAW,KAAK,oBAGpD,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,CAAC,CAAC,EAAE,WAAW,KAAK,wBAGxD,CAAC;AAEF,eAAO,MAAM,mBAAmB,QAAS,GAAG,aAAa,YAAY,KAAG,QAkCvE,CAAC"}
|
package/out/api/index.js
CHANGED
|
@@ -1,34 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.wrapFetchApiMethods = void 0;
|
|
4
|
-
var polyfill_response_1 = require("./polyfill-response");
|
|
5
|
-
Object.defineProperty(exports, "transformResponse", { enumerable: true, get: function () { return polyfill_response_1.transformResponse; } });
|
|
3
|
+
exports.wrapFetchApiMethods = exports.wrapWithRouteUnwrapper = exports.wrapRequestProduct = exports.wrapRequestGraph = void 0;
|
|
6
4
|
const safeUrl_1 = require("../safeUrl");
|
|
7
5
|
const wrapRequestGraph = (requestGraphApi) => (query, variables, headers = {}) => requestGraphApi('/graphql', {
|
|
8
6
|
method: 'POST',
|
|
9
7
|
headers: Object.assign(Object.assign({}, headers), { 'Content-Type': 'application/json' }),
|
|
10
8
|
body: JSON.stringify(Object.assign({ query }, (variables ? { variables } : {})))
|
|
11
9
|
});
|
|
10
|
+
exports.wrapRequestGraph = wrapRequestGraph;
|
|
12
11
|
const wrapRequestProduct = (requestProduct) => (path, init) => {
|
|
13
|
-
const safeUrl = safeUrl_1.requireSafeUrl(path);
|
|
12
|
+
const safeUrl = (0, safeUrl_1.requireSafeUrl)(path);
|
|
14
13
|
return requestProduct(safeUrl.value, init);
|
|
15
14
|
};
|
|
15
|
+
exports.wrapRequestProduct = wrapRequestProduct;
|
|
16
16
|
const wrapWithRouteUnwrapper = (fetch) => (path, init) => {
|
|
17
|
-
const stringPath = safeUrl_1.isRoute(path) ? path.value : path;
|
|
17
|
+
const stringPath = (0, safeUrl_1.isRoute)(path) ? path.value : path;
|
|
18
18
|
return fetch(stringPath, init);
|
|
19
19
|
};
|
|
20
|
-
exports.
|
|
20
|
+
exports.wrapWithRouteUnwrapper = wrapWithRouteUnwrapper;
|
|
21
|
+
const wrapFetchApiMethods = (api, wrapFetch) => {
|
|
21
22
|
return {
|
|
22
|
-
fetch: wrapWithRouteUnwrapper(wrapFetch(api.fetch)),
|
|
23
|
-
requestJira: wrapRequestProduct(wrapFetch(api.requestJira)),
|
|
24
|
-
requestConfluence: wrapRequestProduct(wrapFetch(api.requestConfluence)),
|
|
23
|
+
fetch: (0, exports.wrapWithRouteUnwrapper)(wrapFetch(api.fetch)),
|
|
24
|
+
requestJira: (0, exports.wrapRequestProduct)(wrapFetch(api.requestJira)),
|
|
25
|
+
requestConfluence: (0, exports.wrapRequestProduct)(wrapFetch(api.requestConfluence)),
|
|
26
|
+
requestBitbucket: (0, exports.wrapRequestProduct)(wrapFetch(api.requestBitbucket)),
|
|
25
27
|
asUser: () => ({
|
|
26
|
-
requestJira: wrapRequestProduct(wrapFetch(api.asUser().requestJira)),
|
|
27
|
-
requestConfluence: wrapRequestProduct(wrapFetch(api.asUser().requestConfluence)),
|
|
28
|
-
|
|
28
|
+
requestJira: (0, exports.wrapRequestProduct)(wrapFetch(api.asUser().requestJira)),
|
|
29
|
+
requestConfluence: (0, exports.wrapRequestProduct)(wrapFetch(api.asUser().requestConfluence)),
|
|
30
|
+
requestBitbucket: (0, exports.wrapRequestProduct)(wrapFetch(api.asUser().requestBitbucket)),
|
|
31
|
+
requestGraph: (0, exports.wrapRequestGraph)(wrapFetch(api.asUser().requestGraph)),
|
|
29
32
|
withProvider: (provider, remoteName, tokenId) => {
|
|
30
33
|
const { hasCredentials, requestCredentials, listCredentials, fetch: withProviderFetch } = api.asUser().withProvider(provider, remoteName, tokenId);
|
|
31
|
-
const wrappedRequestRemote = wrapWithRouteUnwrapper(wrapFetch(withProviderFetch));
|
|
34
|
+
const wrappedRequestRemote = (0, exports.wrapWithRouteUnwrapper)(wrapFetch(withProviderFetch));
|
|
32
35
|
return {
|
|
33
36
|
hasCredentials,
|
|
34
37
|
requestCredentials,
|
|
@@ -38,9 +41,11 @@ exports.wrapFetchApiMethods = (api, wrapFetch) => {
|
|
|
38
41
|
}
|
|
39
42
|
}),
|
|
40
43
|
asApp: () => ({
|
|
41
|
-
requestJira: wrapRequestProduct(wrapFetch(api.asApp().requestJira)),
|
|
42
|
-
requestConfluence: wrapRequestProduct(wrapFetch(api.asApp().requestConfluence)),
|
|
43
|
-
requestGraph: wrapRequestGraph(wrapFetch(api.asApp().requestGraph))
|
|
44
|
+
requestJira: (0, exports.wrapRequestProduct)(wrapFetch(api.asApp().requestJira)),
|
|
45
|
+
requestConfluence: (0, exports.wrapRequestProduct)(wrapFetch(api.asApp().requestConfluence)),
|
|
46
|
+
requestGraph: (0, exports.wrapRequestGraph)(wrapFetch(api.asApp().requestGraph)),
|
|
47
|
+
requestBitbucket: (0, exports.wrapRequestProduct)(wrapFetch(api.asApp().requestBitbucket))
|
|
44
48
|
})
|
|
45
49
|
};
|
|
46
50
|
};
|
|
51
|
+
exports.wrapFetchApiMethods = wrapFetchApiMethods;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"polyfill-response.d.ts","sourceRoot":"","sources":["../../src/api/polyfill-response.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,GAAG,CAAC;
|
|
1
|
+
{"version":3,"file":"polyfill-response.d.ts","sourceRoot":"","sources":["../../src/api/polyfill-response.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,GAAG,CAAC;AAGjC,eAAO,MAAM,iBAAiB,EAAE,YAM/B,CAAC"}
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
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
7
|
return Object.assign(Object.assign({}, response), { headers: new node_fetch_1.Headers(response.headers) });
|
|
8
8
|
};
|
|
9
|
+
exports.transformResponse = transformResponse;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare type ForgeRuntime = {
|
|
2
|
+
proxy: {
|
|
3
|
+
token: string;
|
|
4
|
+
url: string;
|
|
5
|
+
};
|
|
6
|
+
contextAri: string;
|
|
7
|
+
allowedEgress: string[];
|
|
8
|
+
lambdaContext: {
|
|
9
|
+
awsRequestId: string;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
export declare function getRuntime(): ForgeRuntime;
|
|
13
|
+
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/api/runtime.ts"],"names":[],"mappings":"AAKA,oBAAY,YAAY,GAAG;IACzB,KAAK,EAAE;QACL,KAAK,EAAE,MAAM,CAAC;QACd,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;IACF,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,aAAa,EAAE;QACb,YAAY,EAAE,MAAM,CAAC;KACtB,CAAC;CACH,CAAC;AAEF,wBAAgB,UAAU,IAAI,YAAY,CAOzC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRuntime = void 0;
|
|
4
|
+
function getRuntime() {
|
|
5
|
+
const runtime = global.__forge_runtime__;
|
|
6
|
+
if (!runtime) {
|
|
7
|
+
throw new Error('Forge runtime not found.');
|
|
8
|
+
}
|
|
9
|
+
return runtime;
|
|
10
|
+
}
|
|
11
|
+
exports.getRuntime = getRuntime;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare const authorize: () => {
|
|
2
|
-
readonly onJira: (projectPermissionsInput: import("
|
|
3
|
-
readonly onJiraProject: (projects:
|
|
4
|
-
readonly onJiraIssue: (issues:
|
|
5
|
-
readonly onConfluenceContent: (contentId: string | number) => Record<string, import("
|
|
2
|
+
readonly onJira: (projectPermissionsInput: import("packages/forge-auth/out/jira").ProjectPermission[]) => Promise<import("packages/forge-auth/out/jira").ProjectPermissionResponse[]>;
|
|
3
|
+
readonly onJiraProject: (projects: import("packages/forge-auth/out/jira").Id | import("packages/forge-auth/out/jira").Id[]) => Record<string, import("packages/forge-auth/out/types").PermissionCheck>;
|
|
4
|
+
readonly onJiraIssue: (issues: import("packages/forge-auth/out/jira").Id | import("packages/forge-auth/out/jira").Id[]) => Record<string, import("packages/forge-auth/out/types").PermissionCheck>;
|
|
5
|
+
readonly onConfluenceContent: (contentId: string | number) => Record<string, import("packages/forge-auth/out/types").PermissionCheck>;
|
|
6
6
|
};
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -3,15 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.authorize = void 0;
|
|
4
4
|
const auth_1 = require("@forge/auth");
|
|
5
5
|
const api = global.api;
|
|
6
|
-
|
|
6
|
+
const authorize = () => {
|
|
7
7
|
if (!process.env.__CURRENT_USER_ACCOUNT_ID)
|
|
8
8
|
throw new Error(`Couldn’t find the accountId of the invoking user. This API can only be used inside user-invoked modules.`);
|
|
9
9
|
const accountId = process.env.__CURRENT_USER_ACCOUNT_ID;
|
|
10
|
-
return Object.assign(Object.assign({}, auth_1.authorizeConfluenceWithFetch(async (path, opts) => {
|
|
10
|
+
return Object.assign(Object.assign({}, (0, auth_1.authorizeConfluenceWithFetch)(async (path, opts) => {
|
|
11
11
|
const res = await api.asUser().requestConfluence(path, opts);
|
|
12
12
|
return res.json();
|
|
13
|
-
}, accountId)), auth_1.authorizeJiraWithFetch(async (path, opts) => {
|
|
13
|
+
}, accountId)), (0, auth_1.authorizeJiraWithFetch)(async (path, opts) => {
|
|
14
14
|
const res = await api.asUser().requestJira(path, opts);
|
|
15
15
|
return res.json();
|
|
16
16
|
}, accountId));
|
|
17
17
|
};
|
|
18
|
+
exports.authorize = authorize;
|
package/out/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { RequestInit, Response } from 'node-fetch';
|
|
2
|
-
import { QueryApi } from '@forge/storage';
|
|
2
|
+
import { QueryApi, EntityStorageApi, CustomEntity } from '@forge/storage';
|
|
3
3
|
import { authorize } from './authorization';
|
|
4
4
|
import { Route } from './safeUrl';
|
|
5
5
|
import { webTrigger } from './webTrigger';
|
|
6
|
+
import { createRequestStargateAsApp } from './runtime/fetch-and-storage';
|
|
6
7
|
export declare type APIResponse = Pick<Response, 'json' | 'text' | 'arrayBuffer' | 'ok' | 'status' | 'statusText' | 'headers'>;
|
|
7
8
|
export declare type FetchMethod = (url: string, init?: RequestInit) => Promise<APIResponse>;
|
|
8
9
|
export declare type FetchMethodAllowingRoute = (url: string | Route, init?: RequestInit) => Promise<APIResponse>;
|
|
@@ -11,6 +12,7 @@ export declare type FetchOptions = RequestInit;
|
|
|
11
12
|
export interface RequestProductMethods {
|
|
12
13
|
requestJira: RequestProductMethod;
|
|
13
14
|
requestConfluence: RequestProductMethod;
|
|
15
|
+
requestBitbucket: RequestProductMethod;
|
|
14
16
|
}
|
|
15
17
|
export interface GraphQLFetchMethods {
|
|
16
18
|
requestGraph: (query: string, variables?: any, headers?: Record<string, any>) => Promise<APIResponse>;
|
|
@@ -28,6 +30,7 @@ export interface StorageMethods {
|
|
|
28
30
|
get: (key: string) => Promise<any>;
|
|
29
31
|
set: (key: string, value: any) => Promise<void>;
|
|
30
32
|
delete: (key: string) => Promise<void>;
|
|
33
|
+
upsertCustomEntities(schemas: CustomEntity[]): Promise<void>;
|
|
31
34
|
}
|
|
32
35
|
export interface PropertiesAPI {
|
|
33
36
|
onJiraProject: (context: string) => StorageMethods;
|
|
@@ -35,7 +38,7 @@ export interface PropertiesAPI {
|
|
|
35
38
|
onConfluencePage: (context: string) => StorageMethods;
|
|
36
39
|
onConfluenceSpace: (context: string) => StorageMethods;
|
|
37
40
|
}
|
|
38
|
-
export interface StorageAPI extends StorageMethods, QueryApi {
|
|
41
|
+
export interface StorageAPI extends StorageMethods, QueryApi, EntityStorageApi {
|
|
39
42
|
}
|
|
40
43
|
export interface ForgeStorageAPI extends StorageAPI {
|
|
41
44
|
getSecret: (key: string) => Promise<any>;
|
|
@@ -61,16 +64,27 @@ declare const asApp: () => RequestProductMethods & GraphQLFetchMethods;
|
|
|
61
64
|
declare const fetch: FetchMethodAllowingRoute;
|
|
62
65
|
declare const requestJira: RequestProductMethod;
|
|
63
66
|
declare const requestConfluence: RequestProductMethod;
|
|
67
|
+
declare const requestBitbucket: RequestProductMethod;
|
|
64
68
|
declare const store: PropertiesAPI;
|
|
65
|
-
declare const storage:
|
|
69
|
+
declare const storage: {
|
|
70
|
+
get: (key: string) => Promise<any>;
|
|
71
|
+
set: (key: string, value: any) => Promise<void>;
|
|
72
|
+
delete: (key: string) => Promise<void>;
|
|
73
|
+
getSecret: (key: string) => Promise<any>;
|
|
74
|
+
setSecret: (key: string, value: any) => Promise<void>;
|
|
75
|
+
deleteSecret: (key: string) => Promise<void>;
|
|
76
|
+
query: () => import("packages/forge-storage/out/query-api").DefaultQueryBuilder;
|
|
77
|
+
entity: (entityName: string) => import("packages/forge-storage/out/entity-storage").EntityStorageBuilder;
|
|
78
|
+
upsertCustomEntities: (schemas: CustomEntity[]) => Promise<void>;
|
|
79
|
+
};
|
|
66
80
|
declare const properties: PropertiesAPI;
|
|
67
81
|
declare const API: ForgeAPI;
|
|
68
82
|
export declare const privacy: {
|
|
69
83
|
reportPersonalData: (accounts: import("./privacy").Account[]) => Promise<import("./privacy").AccountUpdate[]>;
|
|
70
84
|
};
|
|
71
85
|
export default API;
|
|
72
|
-
export { asUser, asApp, authorize, fetch, requestJira, requestConfluence, store, storage, properties, webTrigger };
|
|
73
|
-
export { QueryBuilder, QueryApi, Condition, ListResult, Predicate, Result, Value } from '@forge/storage';
|
|
74
|
-
export {
|
|
75
|
-
export {
|
|
86
|
+
export { asUser, asApp, authorize, fetch, requestJira, requestConfluence, requestBitbucket, store, storage, properties, webTrigger, createRequestStargateAsApp };
|
|
87
|
+
export { QueryBuilder, QueryApi, Condition, ListResult, Predicate, Result, Value, WherePredicate, FilterPredicate, startsWith, WhereConditions, FilterConditions } from '@forge/storage';
|
|
88
|
+
export { route, assumeTrustedRoute, routeFromAbsolute, Route } from './safeUrl';
|
|
89
|
+
export { ForgeRuntime, getRuntime } from './api/runtime';
|
|
76
90
|
//# sourceMappingURL=index.d.ts.map
|
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,MAAM,gBAAgB,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,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEtH,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,EAAe,0BAA0B,EAAiB,MAAM,6BAA6B,CAAC;AAErG,oBAAY,WAAW,GAAG,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,MAA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BAAiB,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAChF,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC"}
|
package/out/index.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var _a;
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.webTrigger = exports.properties = exports.storage = exports.store = exports.requestConfluence = exports.requestJira = exports.fetch = exports.authorize = exports.asApp = exports.asUser = exports.privacy = void 0;
|
|
4
|
+
exports.getRuntime = exports.routeFromAbsolute = exports.assumeTrustedRoute = exports.route = exports.FilterConditions = exports.WhereConditions = exports.startsWith = exports.createRequestStargateAsApp = 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;
|
|
4
5
|
const storage_1 = require("@forge/storage");
|
|
5
|
-
const api_1 = require("./api");
|
|
6
6
|
const authorization_1 = require("./authorization");
|
|
7
7
|
Object.defineProperty(exports, "authorize", { enumerable: true, get: function () { return authorization_1.authorize; } });
|
|
8
8
|
const properties_1 = require("./properties");
|
|
9
9
|
const privacy_1 = require("./privacy");
|
|
10
10
|
const webTrigger_1 = require("./webTrigger");
|
|
11
11
|
Object.defineProperty(exports, "webTrigger", { enumerable: true, get: function () { return webTrigger_1.webTrigger; } });
|
|
12
|
+
const fetch_and_storage_1 = require("./runtime/fetch-and-storage");
|
|
13
|
+
Object.defineProperty(exports, "createRequestStargateAsApp", { enumerable: true, get: function () { return fetch_and_storage_1.createRequestStargateAsApp; } });
|
|
12
14
|
function withDeprecatedMessage(method, message) {
|
|
13
15
|
const wrappedMethod = (...args) => {
|
|
14
16
|
console.warn(message);
|
|
@@ -16,17 +18,19 @@ function withDeprecatedMessage(method, message) {
|
|
|
16
18
|
};
|
|
17
19
|
return wrappedMethod;
|
|
18
20
|
}
|
|
19
|
-
const
|
|
20
|
-
const asUser =
|
|
21
|
+
const fetchAPI = (0, fetch_and_storage_1.getFetchAPI)();
|
|
22
|
+
const asUser = fetchAPI.asUser;
|
|
21
23
|
exports.asUser = asUser;
|
|
22
|
-
const asApp =
|
|
24
|
+
const asApp = fetchAPI.asApp;
|
|
23
25
|
exports.asApp = asApp;
|
|
24
|
-
const fetch =
|
|
26
|
+
const fetch = fetchAPI.fetch;
|
|
25
27
|
exports.fetch = fetch;
|
|
26
|
-
const requestJira =
|
|
28
|
+
const requestJira = fetchAPI.requestJira;
|
|
27
29
|
exports.requestJira = requestJira;
|
|
28
|
-
const requestConfluence =
|
|
30
|
+
const requestConfluence = fetchAPI.requestConfluence;
|
|
29
31
|
exports.requestConfluence = requestConfluence;
|
|
32
|
+
const requestBitbucket = fetchAPI.requestBitbucket;
|
|
33
|
+
exports.requestBitbucket = requestBitbucket;
|
|
30
34
|
const deprecatedPropertiesApi = Object.entries(properties_1.propertiesApi)
|
|
31
35
|
.map(([name, method]) => {
|
|
32
36
|
const wrappedMethod = withDeprecatedMessage(method, `store.${name}() is deprecated. Use properties.${name}() imported from '@forge/api' instead`);
|
|
@@ -37,17 +41,22 @@ const deprecatedPropertiesApi = Object.entries(properties_1.propertiesApi)
|
|
|
37
41
|
.reduce((acc, next) => Object.assign(acc, next), {});
|
|
38
42
|
const store = deprecatedPropertiesApi;
|
|
39
43
|
exports.store = store;
|
|
40
|
-
const storage = storage_1.getStorageInstanceWithQuery(new storage_1.GlobalStorage(
|
|
44
|
+
const storage = (0, storage_1.getStorageInstanceWithQuery)(new storage_1.GlobalStorage(fetch_and_storage_1.getContextAri, (0, fetch_and_storage_1.createRequestStargateAsApp)()));
|
|
41
45
|
exports.storage = storage;
|
|
42
46
|
const properties = properties_1.propertiesApi;
|
|
43
47
|
exports.properties = properties;
|
|
44
|
-
const API = Object.assign(Object.assign({},
|
|
48
|
+
const API = Object.assign(Object.assign({}, fetchAPI), { store: Object.assign({}, store) });
|
|
45
49
|
exports.privacy = {
|
|
46
|
-
reportPersonalData: privacy_1.createReportPersonalData(global.api.asApp().__requestAtlassian)
|
|
50
|
+
reportPersonalData: (0, privacy_1.createReportPersonalData)((_a = global.api) === null || _a === void 0 ? void 0 : _a.asApp().__requestAtlassian)
|
|
47
51
|
};
|
|
48
52
|
exports.default = API;
|
|
49
53
|
var storage_2 = require("@forge/storage");
|
|
50
54
|
Object.defineProperty(exports, "startsWith", { enumerable: true, get: function () { return storage_2.startsWith; } });
|
|
55
|
+
Object.defineProperty(exports, "WhereConditions", { enumerable: true, get: function () { return storage_2.WhereConditions; } });
|
|
56
|
+
Object.defineProperty(exports, "FilterConditions", { enumerable: true, get: function () { return storage_2.FilterConditions; } });
|
|
51
57
|
var safeUrl_1 = require("./safeUrl");
|
|
52
58
|
Object.defineProperty(exports, "route", { enumerable: true, get: function () { return safeUrl_1.route; } });
|
|
53
59
|
Object.defineProperty(exports, "assumeTrustedRoute", { enumerable: true, get: function () { return safeUrl_1.assumeTrustedRoute; } });
|
|
60
|
+
Object.defineProperty(exports, "routeFromAbsolute", { enumerable: true, get: function () { return safeUrl_1.routeFromAbsolute; } });
|
|
61
|
+
var runtime_1 = require("./api/runtime");
|
|
62
|
+
Object.defineProperty(exports, "getRuntime", { enumerable: true, get: function () { return runtime_1.getRuntime; } });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/privacy/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,KAAK,CAAC;AAElC,eAAO,MAAM,GAAG,yBAAyB,CAAC;AAC1C,eAAO,MAAM,KAAK,KAAK,CAAC;AAExB,oBAAY,OAAO,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC;AAC/D,oBAAY,aAAa,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,SAAS,GAAG,QAAQ,CAAA;CAAE,CAAC;AAEhF,eAAO,MAAM,wBAAwB,2BACX,MAAM,QAAQ,WAAW,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/privacy/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,KAAK,CAAC;AAElC,eAAO,MAAM,GAAG,yBAAyB,CAAC;AAC1C,eAAO,MAAM,KAAK,KAAK,CAAC;AAExB,oBAAY,OAAO,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC;AAC/D,oBAAY,aAAa,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,SAAS,GAAG,QAAQ,CAAA;CAAE,CAAC;AAEhF,eAAO,MAAM,wBAAwB,2BACX,MAAM,QAAQ,WAAW,KAAK,QAAQ,WAAW,CAAC,gBAEnC,OAAO,EAAE,KAAG,QAAQ,aAAa,EAAE,CAqB3E,CAAC"}
|
package/out/privacy/index.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createReportPersonalData = exports.LIMIT = exports.URL = void 0;
|
|
4
4
|
exports.URL = '/app/report-accounts';
|
|
5
5
|
exports.LIMIT = 90;
|
|
6
|
-
|
|
6
|
+
const createReportPersonalData = (requestAtlassian) => {
|
|
7
7
|
return function fetchUpdates(accounts) {
|
|
8
8
|
if (accounts.length === 0) {
|
|
9
9
|
return Promise.resolve([]);
|
|
@@ -24,3 +24,4 @@ exports.createReportPersonalData = (requestAtlassian) => {
|
|
|
24
24
|
return Promise.all([request, fetchUpdates(accounts.slice(exports.LIMIT))]).then(([first, second]) => first.concat(second));
|
|
25
25
|
};
|
|
26
26
|
};
|
|
27
|
+
exports.createReportPersonalData = createReportPersonalData;
|
|
@@ -5,7 +5,7 @@ const safeUrl_1 = require("../safeUrl");
|
|
|
5
5
|
const confluence_versioned_storage_1 = require("./confluence-versioned-storage");
|
|
6
6
|
class ConfluencePageStorage extends confluence_versioned_storage_1.ConfluenceVersionedStorage {
|
|
7
7
|
constructor(pageId, apiClient) {
|
|
8
|
-
const storageApiPath = (key) => safeUrl_1.route `/wiki/rest/api/content/${pageId}/property/${key}`;
|
|
8
|
+
const storageApiPath = (key) => (0, safeUrl_1.route) `/wiki/rest/api/content/${pageId}/property/${key}`;
|
|
9
9
|
super(storageApiPath, apiClient);
|
|
10
10
|
}
|
|
11
11
|
async set(key, value) {
|
|
@@ -5,7 +5,7 @@ const safeUrl_1 = require("../safeUrl");
|
|
|
5
5
|
const confluence_versioned_storage_1 = require("./confluence-versioned-storage");
|
|
6
6
|
class ConfluenceSpaceStorage extends confluence_versioned_storage_1.ConfluenceVersionedStorage {
|
|
7
7
|
constructor(spaceId, apiClient) {
|
|
8
|
-
const storageApiPath = (key) => safeUrl_1.route `/wiki/rest/api/space/${spaceId}/property/${key}`;
|
|
8
|
+
const storageApiPath = (key) => (0, safeUrl_1.route) `/wiki/rest/api/space/${spaceId}/property/${key}`;
|
|
9
9
|
super(storageApiPath, apiClient);
|
|
10
10
|
}
|
|
11
11
|
async set(key, value) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/properties/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAS,cAAc,EAAE,MAAM,UAAU,CAAC;AAiBjD,eAAO,MAAM,aAAa;4BACA,MAAM;gCAEF,MAAM;+
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/properties/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAS,cAAc,EAAE,MAAM,UAAU,CAAC;AAiBjD,eAAO,MAAM,aAAa;4BACA,MAAM;gCAEF,MAAM;+BACP,MAAM;iCAEJ,MAAM;CAEpC,CAAC"}
|
package/out/properties/index.js
CHANGED
|
@@ -9,15 +9,15 @@ const confluence_space_1 = require("./confluence-space");
|
|
|
9
9
|
const sanitized_key_1 = require("./sanitized-key");
|
|
10
10
|
const getPropertiesInstance = (adapter) => {
|
|
11
11
|
const storage = {
|
|
12
|
-
get: (key) => adapter.get(sanitized_key_1.sanitizedKey(key)),
|
|
13
|
-
set: (key, value) => adapter.set(sanitized_key_1.sanitizedKey(key), value),
|
|
14
|
-
delete: (key) => adapter.delete(sanitized_key_1.sanitizedKey(key))
|
|
12
|
+
get: (key) => adapter.get((0, sanitized_key_1.sanitizedKey)(key)),
|
|
13
|
+
set: (key, value) => adapter.set((0, sanitized_key_1.sanitizedKey)(key), value),
|
|
14
|
+
delete: (key) => adapter.delete((0, sanitized_key_1.sanitizedKey)(key))
|
|
15
15
|
};
|
|
16
16
|
return storage;
|
|
17
17
|
};
|
|
18
18
|
exports.propertiesApi = {
|
|
19
|
-
onJiraIssue: (issueKey) => getPropertiesInstance(new jira_issue_1.JiraIssueStorage(sanitized_key_1.sanitizedKey(issueKey), index_1.asApp().requestJira)),
|
|
20
|
-
onJiraProject: (projectKey) => getPropertiesInstance(new jira_project_1.JiraProjectStorage(
|
|
21
|
-
onConfluencePage: (pageId) => getPropertiesInstance(new confluence_page_1.ConfluencePageStorage(sanitized_key_1.sanitizedKey(pageId), index_1.asApp().requestConfluence)),
|
|
22
|
-
onConfluenceSpace: (spaceId) => getPropertiesInstance(new confluence_space_1.ConfluenceSpaceStorage(sanitized_key_1.sanitizedKey(spaceId), index_1.asApp().requestConfluence))
|
|
19
|
+
onJiraIssue: (issueKey) => getPropertiesInstance(new jira_issue_1.JiraIssueStorage((0, sanitized_key_1.sanitizedKey)(issueKey), (0, index_1.asApp)().requestJira)),
|
|
20
|
+
onJiraProject: (projectKey) => getPropertiesInstance(new jira_project_1.JiraProjectStorage(projectKey, (0, index_1.asApp)().requestJira)),
|
|
21
|
+
onConfluencePage: (pageId) => getPropertiesInstance(new confluence_page_1.ConfluencePageStorage((0, sanitized_key_1.sanitizedKey)(pageId), (0, index_1.asApp)().requestConfluence)),
|
|
22
|
+
onConfluenceSpace: (spaceId) => getPropertiesInstance(new confluence_space_1.ConfluenceSpaceStorage((0, sanitized_key_1.sanitizedKey)(spaceId), (0, index_1.asApp)().requestConfluence))
|
|
23
23
|
};
|
|
@@ -5,7 +5,7 @@ const product_scoped_storage_1 = require("./product-scoped-storage");
|
|
|
5
5
|
const safeUrl_1 = require("../safeUrl");
|
|
6
6
|
class JiraIssueStorage extends product_scoped_storage_1.ProductScopedStorage {
|
|
7
7
|
constructor(issueKey, apiClient) {
|
|
8
|
-
const storageApiPath = (key) => safeUrl_1.route `/rest/api/3/issue/${issueKey}/properties/${key}`;
|
|
8
|
+
const storageApiPath = (key) => (0, safeUrl_1.route) `/rest/api/3/issue/${issueKey}/properties/${key}`;
|
|
9
9
|
super(storageApiPath, apiClient);
|
|
10
10
|
}
|
|
11
11
|
}
|
|
@@ -5,7 +5,7 @@ const product_scoped_storage_1 = require("./product-scoped-storage");
|
|
|
5
5
|
const safeUrl_1 = require("../safeUrl");
|
|
6
6
|
class JiraProjectStorage extends product_scoped_storage_1.ProductScopedStorage {
|
|
7
7
|
constructor(projectKey, apiClient) {
|
|
8
|
-
const storageApiPath = (key) => safeUrl_1.route `/rest/api/3/project/${projectKey}/properties/${key}`;
|
|
8
|
+
const storageApiPath = (key) => (0, safeUrl_1.route) `/rest/api/3/project/${projectKey}/properties/${key}`;
|
|
9
9
|
super(storageApiPath, apiClient);
|
|
10
10
|
}
|
|
11
11
|
}
|
|
@@ -9,7 +9,7 @@ export declare class ProductScopedStorage implements StorageAdapter {
|
|
|
9
9
|
set(key: string, value: any): Promise<void>;
|
|
10
10
|
delete(key: string): Promise<void>;
|
|
11
11
|
protected buildSetRequestOptions(requestBody: any, requestMethod: 'PUT' | 'POST'): {
|
|
12
|
-
method: "
|
|
12
|
+
method: "PUT" | "POST";
|
|
13
13
|
body: string;
|
|
14
14
|
headers: {
|
|
15
15
|
'content-type': string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"product-scoped-storage.d.ts","sourceRoot":"","sources":["../../src/properties/product-scoped-storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAEhD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,qBAAa,oBAAqB,YAAW,cAAc;IAC7C,SAAS,CAAC,cAAc,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,KAAK;IAAE,SAAS,CAAC,SAAS,EAAE,oBAAoB;gBAAjF,cAAc,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,KAAK,EAAY,SAAS,EAAE,oBAAoB;IAEjG,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;
|
|
1
|
+
{"version":3,"file":"product-scoped-storage.d.ts","sourceRoot":"","sources":["../../src/properties/product-scoped-storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAEhD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,qBAAa,oBAAqB,YAAW,cAAc;IAC7C,SAAS,CAAC,cAAc,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,KAAK;IAAE,SAAS,CAAC,SAAS,EAAE,oBAAoB;gBAAjF,cAAc,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,KAAK,EAAY,SAAS,EAAE,oBAAoB;IAEjG,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAc9B,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ3C,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQxC,SAAS,CAAC,sBAAsB,CAAC,WAAW,EAAE,GAAG,EAAE,aAAa,EAAE,KAAK,GAAG,MAAM;;;;;;;CASjF"}
|
|
@@ -10,7 +10,7 @@ class ProductScopedStorage {
|
|
|
10
10
|
async get(key) {
|
|
11
11
|
const response = await this.apiClient(this.storageApiPath(key));
|
|
12
12
|
if (!response.ok) {
|
|
13
|
-
if (/
|
|
13
|
+
if (/403|404/.test(response.status.toString())) {
|
|
14
14
|
return undefined;
|
|
15
15
|
}
|
|
16
16
|
throw storage_1.APIError.forStatus(response.status);
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.sanitizedKey = void 0;
|
|
4
|
-
|
|
5
|
-
const regex = /^(~)?[A-Za-z0-9_
|
|
4
|
+
const sanitizedKey = (input) => {
|
|
5
|
+
const regex = /^(~)?[A-Za-z0-9_\-\.]+$/;
|
|
6
6
|
if (!regex.test(input)) {
|
|
7
7
|
throw new Error('Invalid context/property key');
|
|
8
8
|
}
|
|
9
9
|
return input;
|
|
10
10
|
};
|
|
11
|
+
exports.sanitizedKey = sanitizedKey;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch-and-storage.d.ts","sourceRoot":"","sources":["../../src/runtime/fetch-and-storage.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,0BAA0B,WACiD,CAAC;AAEzF,eAAO,MAAM,aAAa,WAQzB,CAAC;AAEF,eAAO,MAAM,WAAW,6BAOvB,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getFetchAPI = exports.getContextAri = exports.createRequestStargateAsApp = void 0;
|
|
4
|
+
const fetch_1 = require("../api/fetch");
|
|
5
|
+
const runtime_1 = require("../api/runtime");
|
|
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.createProxyFetch)('app', 'stargate'); };
|
|
7
|
+
exports.createRequestStargateAsApp = createRequestStargateAsApp;
|
|
8
|
+
const getContextAri = () => {
|
|
9
|
+
var _a;
|
|
10
|
+
const sandboxGetAppAri = (_a = global.api) === null || _a === void 0 ? void 0 : _a.__getAppAri;
|
|
11
|
+
if (sandboxGetAppAri) {
|
|
12
|
+
return sandboxGetAppAri();
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
const runtime = (0, runtime_1.getRuntime)();
|
|
16
|
+
return runtime.contextAri;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
exports.getContextAri = getContextAri;
|
|
20
|
+
const getFetchAPI = () => {
|
|
21
|
+
const { api: sandboxAPI } = global;
|
|
22
|
+
if (sandboxAPI && Object.keys(sandboxAPI).length) {
|
|
23
|
+
return (0, fetch_1.getSandboxRuntimeAPI)(sandboxAPI);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
return (0, fetch_1.getNodeRuntimeAPI)();
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
exports.getFetchAPI = getFetchAPI;
|
package/out/safeUrl.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export declare type Route = {
|
|
|
2
2
|
readonly value: string;
|
|
3
3
|
};
|
|
4
4
|
export declare function isRoute(x: unknown): x is Route;
|
|
5
|
+
export declare function routeFromAbsolute(absolutePath: string): Route;
|
|
5
6
|
export declare function route(path: TemplateStringsArray, ...parameters: (string | number | URLSearchParams | Route)[]): Route;
|
|
6
7
|
export declare function requireSafeUrl(url: unknown): Route;
|
|
7
8
|
export declare function assumeTrustedRoute(route: string): Route;
|
package/out/safeUrl.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"safeUrl.d.ts","sourceRoot":"","sources":["../src/safeUrl.ts"],"names":[],"mappings":"AAAA,oBAAY,KAAK,GAAG;IAClB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB,CAAC;AAcF,wBAAgB,OAAO,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,KAAK,CAE9C;AAED,wBAAgB,KAAK,CAAC,IAAI,EAAE,oBAAoB,EAAE,GAAG,UAAU,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,eAAe,GAAG,KAAK,CAAC,EAAE,GAAG,KAAK,CAqBrH;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,GAAG,KAAK,CASlD;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,CAEvD"}
|
|
1
|
+
{"version":3,"file":"safeUrl.d.ts","sourceRoot":"","sources":["../src/safeUrl.ts"],"names":[],"mappings":"AAAA,oBAAY,KAAK,GAAG;IAClB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB,CAAC;AAcF,wBAAgB,OAAO,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,KAAK,CAE9C;AAED,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,MAAM,GAAG,KAAK,CAG7D;AAED,wBAAgB,KAAK,CAAC,IAAI,EAAE,oBAAoB,EAAE,GAAG,UAAU,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,eAAe,GAAG,KAAK,CAAC,EAAE,GAAG,KAAK,CAqBrH;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,GAAG,KAAK,CASlD;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,CAEvD"}
|
package/out/safeUrl.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.assumeTrustedRoute = exports.requireSafeUrl = exports.route = exports.isRoute = void 0;
|
|
3
|
+
exports.assumeTrustedRoute = exports.requireSafeUrl = exports.route = exports.routeFromAbsolute = exports.isRoute = void 0;
|
|
4
4
|
class ReadonlyRoute {
|
|
5
5
|
constructor(value_) {
|
|
6
6
|
this.value_ = value_;
|
|
@@ -16,6 +16,11 @@ function isRoute(x) {
|
|
|
16
16
|
return x instanceof ReadonlyRoute;
|
|
17
17
|
}
|
|
18
18
|
exports.isRoute = isRoute;
|
|
19
|
+
function routeFromAbsolute(absolutePath) {
|
|
20
|
+
const absoluteURL = new URL(absolutePath);
|
|
21
|
+
return assumeTrustedRoute(`${absoluteURL.pathname}${absoluteURL.search}`);
|
|
22
|
+
}
|
|
23
|
+
exports.routeFromAbsolute = routeFromAbsolute;
|
|
19
24
|
function route(path, ...parameters) {
|
|
20
25
|
let fullPath = '';
|
|
21
26
|
for (let i = 0; i < path.length; i++) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forge/api",
|
|
3
|
-
"version": "0.0.0-experimental-
|
|
3
|
+
"version": "0.0.0-experimental-9b81865",
|
|
4
4
|
"description": "Forge API methods",
|
|
5
5
|
"author": "Atlassian",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -16,8 +16,9 @@
|
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@forge/auth": "^0.0.1",
|
|
19
|
-
"@forge/
|
|
19
|
+
"@forge/egress": "^1.1.1",
|
|
20
|
+
"@forge/storage": "^1.3.1",
|
|
20
21
|
"@types/node-fetch": "^2.5.7",
|
|
21
|
-
"node-fetch": "2.6.
|
|
22
|
+
"node-fetch": "2.6.7"
|
|
22
23
|
}
|
|
23
24
|
}
|