@forge/api 0.0.0-experimental-4e6084f → 0.0.0-experimental-d18f8dd
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 -4
- package/out/api/index.d.ts.map +1 -1
- package/out/api/index.js +18 -9
- package/out/authorization/index.d.ts +7 -0
- package/out/authorization/index.d.ts.map +1 -0
- package/out/authorization/index.js +17 -0
- package/out/index.d.ts +27 -17
- package/out/index.d.ts.map +1 -1
- package/out/index.js +7 -2
- package/out/properties/confluence-page.d.ts +2 -3
- package/out/properties/confluence-page.d.ts.map +1 -1
- package/out/properties/confluence-page.js +2 -2
- package/out/properties/confluence-space.d.ts +2 -3
- package/out/properties/confluence-space.d.ts.map +1 -1
- package/out/properties/confluence-space.js +2 -2
- package/out/properties/confluence-versioned-storage.js +2 -2
- package/out/properties/jira-issue.d.ts +2 -3
- package/out/properties/jira-issue.d.ts.map +1 -1
- package/out/properties/jira-issue.js +2 -2
- package/out/properties/jira-project.d.ts +2 -3
- package/out/properties/jira-project.d.ts.map +1 -1
- package/out/properties/jira-project.js +2 -2
- package/out/properties/product-scoped-storage.d.ts +5 -4
- package/out/properties/product-scoped-storage.d.ts.map +1 -1
- package/out/properties/product-scoped-storage.js +3 -3
- package/out/safeUrl.d.ts +8 -0
- package/out/safeUrl.d.ts.map +1 -0
- package/out/safeUrl.js +53 -0
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,15 +1,142 @@
|
|
|
1
1
|
# @forge/api
|
|
2
2
|
|
|
3
|
-
## 0.0.0-experimental-
|
|
3
|
+
## 0.0.0-experimental-d18f8dd
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- d18f8dd: Force bump
|
|
8
|
+
- Updated dependencies [d18f8dd]
|
|
9
|
+
- @forge/auth@0.0.0-experimental-d18f8dd
|
|
10
|
+
- @forge/storage@0.0.0-experimental-d18f8dd
|
|
11
|
+
|
|
12
|
+
## 2.3.0
|
|
4
13
|
|
|
5
14
|
### Minor Changes
|
|
6
15
|
|
|
7
|
-
-
|
|
16
|
+
- 0d7fe27: Support secret storage API
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- df58629: Allow custom headers in requestGraph
|
|
21
|
+
- Updated dependencies [0d7fe27]
|
|
22
|
+
- @forge/storage@1.1.0
|
|
23
|
+
|
|
24
|
+
## 2.3.0-next.1
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- df58629: Allow custom headers in requestGraph
|
|
29
|
+
|
|
30
|
+
## 2.3.0-next.0
|
|
31
|
+
|
|
32
|
+
### Minor Changes
|
|
33
|
+
|
|
34
|
+
- 0d7fe27: Support secret storage API
|
|
35
|
+
|
|
36
|
+
### Patch Changes
|
|
37
|
+
|
|
38
|
+
- Updated dependencies [0d7fe27]
|
|
39
|
+
- @forge/storage@1.1.0-next.0
|
|
40
|
+
|
|
41
|
+
## 2.2.1
|
|
8
42
|
|
|
9
43
|
### Patch Changes
|
|
10
44
|
|
|
11
|
-
- Updated dependencies [
|
|
12
|
-
- @forge/storage@
|
|
45
|
+
- Updated dependencies [0700578]
|
|
46
|
+
- @forge/storage@1.0.5
|
|
47
|
+
|
|
48
|
+
## 2.2.1-next.0
|
|
49
|
+
|
|
50
|
+
### Patch Changes
|
|
51
|
+
|
|
52
|
+
- Updated dependencies [0700578]
|
|
53
|
+
- @forge/storage@1.0.5-next.0
|
|
54
|
+
|
|
55
|
+
## 2.2.0
|
|
56
|
+
|
|
57
|
+
### Minor Changes
|
|
58
|
+
|
|
59
|
+
- 5dcb9bd: Routes can be passed to api.fetch. Routes can be partially-constructed using other Routes.
|
|
60
|
+
|
|
61
|
+
## 2.2.0-next.0
|
|
62
|
+
|
|
63
|
+
### Minor Changes
|
|
64
|
+
|
|
65
|
+
- 5dcb9bd: Routes can be passed to api.fetch. Routes can be partially-constructed using other Routes.
|
|
66
|
+
|
|
67
|
+
## 2.1.0
|
|
68
|
+
|
|
69
|
+
### Minor Changes
|
|
70
|
+
|
|
71
|
+
- 339a8ad: Export StorageAPI interface
|
|
72
|
+
- 390e3d0: Add authorize API
|
|
73
|
+
|
|
74
|
+
### Patch Changes
|
|
75
|
+
|
|
76
|
+
- fef6d3a: Export Route as type for @forge/api
|
|
77
|
+
- 85ce23a: Update error message and build config
|
|
78
|
+
- Updated dependencies [5ff60ec]
|
|
79
|
+
- Updated dependencies [4eda18e]
|
|
80
|
+
- Updated dependencies [85ce23a]
|
|
81
|
+
- Updated dependencies [2d3bec6]
|
|
82
|
+
- @forge/storage@1.0.4
|
|
83
|
+
- @forge/auth@0.0.1
|
|
84
|
+
|
|
85
|
+
## 2.1.0-next.4
|
|
86
|
+
|
|
87
|
+
### Patch Changes
|
|
88
|
+
|
|
89
|
+
- 85ce23a: Update error message and build config
|
|
90
|
+
- Updated dependencies [85ce23a]
|
|
91
|
+
- @forge/auth@0.0.1-next.2
|
|
92
|
+
|
|
93
|
+
## 2.1.0-next.3
|
|
94
|
+
|
|
95
|
+
### Minor Changes
|
|
96
|
+
|
|
97
|
+
- 390e3d0: Add authorize API
|
|
98
|
+
|
|
99
|
+
### Patch Changes
|
|
100
|
+
|
|
101
|
+
- Updated dependencies [4eda18e]
|
|
102
|
+
- @forge/auth@0.0.1-next.0
|
|
103
|
+
|
|
104
|
+
## 2.1.0-next.2
|
|
105
|
+
|
|
106
|
+
### Patch Changes
|
|
107
|
+
|
|
108
|
+
- fef6d3a: Export Route as type for @forge/api
|
|
109
|
+
|
|
110
|
+
## 2.1.0-next.1
|
|
111
|
+
|
|
112
|
+
### Minor Changes
|
|
113
|
+
|
|
114
|
+
- 339a8ad: Export StorageAPI interface
|
|
115
|
+
|
|
116
|
+
## 2.0.2-next.0
|
|
117
|
+
|
|
118
|
+
### Patch Changes
|
|
119
|
+
|
|
120
|
+
- Updated dependencies [5ff60ec]
|
|
121
|
+
- @forge/storage@1.0.4-next.0
|
|
122
|
+
|
|
123
|
+
## 2.0.1
|
|
124
|
+
|
|
125
|
+
### Patch Changes
|
|
126
|
+
|
|
127
|
+
- d3d180e: Remove engines limitation
|
|
128
|
+
|
|
129
|
+
## 2.0.1-next.0
|
|
130
|
+
|
|
131
|
+
### Patch Changes
|
|
132
|
+
|
|
133
|
+
- d3d180e: Remove engines limitation
|
|
134
|
+
|
|
135
|
+
## 2.0.0
|
|
136
|
+
|
|
137
|
+
### Major Changes
|
|
138
|
+
|
|
139
|
+
- 4ae62248a: `@forge/api` requires usage of a new route helper when calling requestJira/requestConfluence
|
|
13
140
|
|
|
14
141
|
## 1.2.0
|
|
15
142
|
|
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,
|
|
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,EAMT,MAAM,IAAI,CAAC;AACZ,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAIxD,oBAAY,YAAY,GAAG,CAAC,QAAQ,EAAE,QAAQ,KAAK,CAAC,GAAG,EAAE,WAAW,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,GAAG,CAAC;AAsBjG,eAAO,MAAM,mBAAmB,QAAS,GAAG,aAAa,YAAY,KAAG,QAgBvE,CAAC"}
|
package/out/api/index.js
CHANGED
|
@@ -3,24 +3,33 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.wrapFetchApiMethods = void 0;
|
|
4
4
|
var polyfill_response_1 = require("./polyfill-response");
|
|
5
5
|
Object.defineProperty(exports, "transformResponse", { enumerable: true, get: function () { return polyfill_response_1.transformResponse; } });
|
|
6
|
-
const
|
|
6
|
+
const safeUrl_1 = require("../safeUrl");
|
|
7
|
+
const wrapRequestGraph = (requestGraphApi) => (query, variables, headers = {}) => requestGraphApi('/graphql', {
|
|
7
8
|
method: 'POST',
|
|
8
|
-
headers: { 'Content-Type': 'application/json' },
|
|
9
|
+
headers: Object.assign(Object.assign({}, headers), { 'Content-Type': 'application/json' }),
|
|
9
10
|
body: JSON.stringify(Object.assign({ query }, (variables ? { variables } : {})))
|
|
10
11
|
});
|
|
12
|
+
const wrapRequestProduct = (requestProduct) => (path, init) => {
|
|
13
|
+
const safeUrl = safeUrl_1.requireSafeUrl(path);
|
|
14
|
+
return requestProduct(safeUrl.value, init);
|
|
15
|
+
};
|
|
16
|
+
const wrapWithRouteUnwrapper = (fetch) => (path, init) => {
|
|
17
|
+
const stringPath = safeUrl_1.isRoute(path) ? path.value : path;
|
|
18
|
+
return fetch(stringPath, init);
|
|
19
|
+
};
|
|
11
20
|
exports.wrapFetchApiMethods = (api, wrapFetch) => {
|
|
12
21
|
return {
|
|
13
|
-
fetch: wrapFetch(api.fetch),
|
|
14
|
-
requestJira: wrapFetch(api.requestJira),
|
|
15
|
-
requestConfluence: wrapFetch(api.requestConfluence),
|
|
22
|
+
fetch: wrapWithRouteUnwrapper(wrapFetch(api.fetch)),
|
|
23
|
+
requestJira: wrapRequestProduct(wrapFetch(api.requestJira)),
|
|
24
|
+
requestConfluence: wrapRequestProduct(wrapFetch(api.requestConfluence)),
|
|
16
25
|
asUser: () => ({
|
|
17
|
-
requestJira: wrapFetch(api.asUser().requestJira),
|
|
18
|
-
requestConfluence: wrapFetch(api.asUser().requestConfluence),
|
|
26
|
+
requestJira: wrapRequestProduct(wrapFetch(api.asUser().requestJira)),
|
|
27
|
+
requestConfluence: wrapRequestProduct(wrapFetch(api.asUser().requestConfluence)),
|
|
19
28
|
requestGraph: wrapRequestGraph(wrapFetch(api.asUser().requestGraph))
|
|
20
29
|
}),
|
|
21
30
|
asApp: () => ({
|
|
22
|
-
requestJira: wrapFetch(api.asApp().requestJira),
|
|
23
|
-
requestConfluence: wrapFetch(api.asApp().requestConfluence),
|
|
31
|
+
requestJira: wrapRequestProduct(wrapFetch(api.asApp().requestJira)),
|
|
32
|
+
requestConfluence: wrapRequestProduct(wrapFetch(api.asApp().requestConfluence)),
|
|
24
33
|
requestGraph: wrapRequestGraph(wrapFetch(api.asApp().requestGraph))
|
|
25
34
|
})
|
|
26
35
|
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const authorize: () => {
|
|
2
|
+
readonly onJira: (projectPermissionsInput: import("@forge/auth/out/jira").ProjectPermission[]) => Promise<import("@forge/auth/out/jira").ProjectPermissionResponse[]>;
|
|
3
|
+
readonly onJiraProject: (projects: string | number | (string | number)[]) => Record<string, import("@forge/auth/out/types").PermissionCheck>;
|
|
4
|
+
readonly onJiraIssue: (issues: string | number | (string | number)[]) => Record<string, import("@forge/auth/out/types").PermissionCheck>;
|
|
5
|
+
readonly onConfluenceContent: (contentId: string | number) => Record<string, import("@forge/auth/out/types").PermissionCheck>;
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/authorization/index.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,SAAS;;;;;CAgBrB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.authorize = void 0;
|
|
4
|
+
const auth_1 = require("@forge/auth");
|
|
5
|
+
const api = global.api;
|
|
6
|
+
exports.authorize = () => {
|
|
7
|
+
if (!process.env.__CURRENT_USER_ACCOUNT_ID)
|
|
8
|
+
throw new Error(`Couldn’t find the accountId of the invoking user. This API can only be used inside user-invoked modules.`);
|
|
9
|
+
const accountId = process.env.__CURRENT_USER_ACCOUNT_ID;
|
|
10
|
+
return Object.assign(Object.assign({}, auth_1.authorizeConfluenceWithFetch(async (path, opts) => {
|
|
11
|
+
const res = await api.asUser().requestConfluence(path, opts);
|
|
12
|
+
return res.json();
|
|
13
|
+
}, accountId)), auth_1.authorizeJiraWithFetch(async (path, opts) => {
|
|
14
|
+
const res = await api.asUser().requestJira(path, opts);
|
|
15
|
+
return res.json();
|
|
16
|
+
}, accountId));
|
|
17
|
+
};
|
package/out/index.d.ts
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import { RequestInit, Response } from 'node-fetch';
|
|
2
|
-
import { webTrigger } from './webTrigger';
|
|
3
2
|
import { QueryApi } from '@forge/storage';
|
|
3
|
+
import { authorize } from './authorization';
|
|
4
|
+
import { Route } from './safeUrl';
|
|
5
|
+
import { webTrigger } from './webTrigger';
|
|
4
6
|
export declare type APIResponse = Pick<Response, 'json' | 'text' | 'arrayBuffer' | 'ok' | 'status' | 'statusText' | 'headers'>;
|
|
5
7
|
export declare type FetchMethod = (url: string, init?: RequestInit) => Promise<APIResponse>;
|
|
8
|
+
export declare type FetchMethodAllowingRoute = (url: string | Route, init?: RequestInit) => Promise<APIResponse>;
|
|
9
|
+
export declare type RequestProductMethod = (url: Route, init?: RequestInit) => Promise<APIResponse>;
|
|
6
10
|
export declare type FetchOptions = RequestInit;
|
|
7
|
-
export interface
|
|
8
|
-
requestJira:
|
|
9
|
-
requestConfluence:
|
|
11
|
+
export interface RequestProductMethods {
|
|
12
|
+
requestJira: RequestProductMethod;
|
|
13
|
+
requestConfluence: RequestProductMethod;
|
|
10
14
|
}
|
|
11
15
|
export interface GraphQLFetchMethods {
|
|
12
|
-
requestGraph: (query: string, variables?: any) => Promise<APIResponse>;
|
|
16
|
+
requestGraph: (query: string, variables?: any, headers?: Record<string, any>) => Promise<APIResponse>;
|
|
13
17
|
}
|
|
14
18
|
export interface StorageMethods {
|
|
15
19
|
get: (key: string) => Promise<any>;
|
|
@@ -22,7 +26,12 @@ export interface PropertiesAPI {
|
|
|
22
26
|
onConfluencePage: (context: string) => StorageMethods;
|
|
23
27
|
onConfluenceSpace: (context: string) => StorageMethods;
|
|
24
28
|
}
|
|
25
|
-
interface StorageAPI extends StorageMethods, QueryApi {
|
|
29
|
+
export interface StorageAPI extends StorageMethods, QueryApi {
|
|
30
|
+
}
|
|
31
|
+
export interface ForgeStorageAPI extends StorageAPI {
|
|
32
|
+
getSecret: (key: string) => Promise<any>;
|
|
33
|
+
setSecret: (key: string, value: any) => Promise<void>;
|
|
34
|
+
deleteSecret: (key: string) => Promise<void>;
|
|
26
35
|
}
|
|
27
36
|
export interface StoreAPI extends PropertiesAPI {
|
|
28
37
|
onJiraProject: (context: string) => StorageMethods;
|
|
@@ -30,28 +39,29 @@ export interface StoreAPI extends PropertiesAPI {
|
|
|
30
39
|
onConfluencePage: (context: string) => StorageMethods;
|
|
31
40
|
onConfluenceSpace: (context: string) => StorageMethods;
|
|
32
41
|
}
|
|
33
|
-
export interface FetchAPI extends
|
|
34
|
-
asUser():
|
|
35
|
-
asApp():
|
|
36
|
-
fetch:
|
|
42
|
+
export interface FetchAPI extends RequestProductMethods {
|
|
43
|
+
asUser(): RequestProductMethods & GraphQLFetchMethods;
|
|
44
|
+
asApp(): RequestProductMethods & GraphQLFetchMethods;
|
|
45
|
+
fetch: FetchMethodAllowingRoute;
|
|
37
46
|
}
|
|
38
47
|
export interface ForgeAPI extends FetchAPI {
|
|
39
48
|
store: StoreAPI;
|
|
40
49
|
}
|
|
41
|
-
declare const asUser: () =>
|
|
42
|
-
declare const asApp: () =>
|
|
43
|
-
declare const fetch:
|
|
44
|
-
declare const requestJira:
|
|
45
|
-
declare const requestConfluence:
|
|
50
|
+
declare const asUser: () => RequestProductMethods & GraphQLFetchMethods;
|
|
51
|
+
declare const asApp: () => RequestProductMethods & GraphQLFetchMethods;
|
|
52
|
+
declare const fetch: FetchMethodAllowingRoute;
|
|
53
|
+
declare const requestJira: RequestProductMethod;
|
|
54
|
+
declare const requestConfluence: RequestProductMethod;
|
|
46
55
|
declare const store: PropertiesAPI;
|
|
47
|
-
declare const storage:
|
|
56
|
+
declare const storage: ForgeStorageAPI;
|
|
48
57
|
declare const properties: PropertiesAPI;
|
|
49
58
|
declare const API: ForgeAPI;
|
|
50
59
|
export declare const privacy: {
|
|
51
60
|
reportPersonalData: (accounts: import("./privacy").Account[]) => Promise<import("./privacy").AccountUpdate[]>;
|
|
52
61
|
};
|
|
53
62
|
export default API;
|
|
54
|
-
export { asUser, asApp, fetch, requestJira, requestConfluence, store, storage, properties, webTrigger };
|
|
63
|
+
export { asUser, asApp, authorize, fetch, requestJira, requestConfluence, store, storage, properties, webTrigger };
|
|
55
64
|
export { QueryBuilder, QueryApi, Condition, ListResult, Predicate, Result, Value } from '@forge/storage';
|
|
56
65
|
export { startsWith } from '@forge/storage';
|
|
66
|
+
export { route, assumeTrustedRoute, Route } from './safeUrl';
|
|
57
67
|
//# 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;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"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"}
|
package/out/index.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.webTrigger = exports.properties = exports.storage = exports.store = exports.requestConfluence = exports.requestJira = exports.fetch = exports.asApp = exports.asUser = exports.privacy = void 0;
|
|
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
|
+
const storage_1 = require("@forge/storage");
|
|
4
5
|
const api_1 = require("./api");
|
|
6
|
+
const authorization_1 = require("./authorization");
|
|
7
|
+
Object.defineProperty(exports, "authorize", { enumerable: true, get: function () { return authorization_1.authorize; } });
|
|
5
8
|
const properties_1 = require("./properties");
|
|
6
9
|
const privacy_1 = require("./privacy");
|
|
7
10
|
const webTrigger_1 = require("./webTrigger");
|
|
8
11
|
Object.defineProperty(exports, "webTrigger", { enumerable: true, get: function () { return webTrigger_1.webTrigger; } });
|
|
9
|
-
const storage_1 = require("@forge/storage");
|
|
10
12
|
function withDeprecatedMessage(method, message) {
|
|
11
13
|
const wrappedMethod = (...args) => {
|
|
12
14
|
console.warn(message);
|
|
@@ -46,3 +48,6 @@ exports.privacy = {
|
|
|
46
48
|
exports.default = API;
|
|
47
49
|
var storage_2 = require("@forge/storage");
|
|
48
50
|
Object.defineProperty(exports, "startsWith", { enumerable: true, get: function () { return storage_2.startsWith; } });
|
|
51
|
+
var safeUrl_1 = require("./safeUrl");
|
|
52
|
+
Object.defineProperty(exports, "route", { enumerable: true, get: function () { return safeUrl_1.route; } });
|
|
53
|
+
Object.defineProperty(exports, "assumeTrustedRoute", { enumerable: true, get: function () { return safeUrl_1.assumeTrustedRoute; } });
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RequestProductMethod } from '../index';
|
|
2
2
|
import { ConfluenceVersionedStorage } from './confluence-versioned-storage';
|
|
3
3
|
export declare class ConfluencePageStorage extends ConfluenceVersionedStorage {
|
|
4
|
-
|
|
5
|
-
constructor(pageId: string, apiClient: FetchMethod);
|
|
4
|
+
constructor(pageId: string, apiClient: RequestProductMethod);
|
|
6
5
|
set(key: string, value: any): Promise<void>;
|
|
7
6
|
}
|
|
8
7
|
//# sourceMappingURL=confluence-page.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"confluence-page.d.ts","sourceRoot":"","sources":["../../src/properties/confluence-page.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"confluence-page.d.ts","sourceRoot":"","sources":["../../src/properties/confluence-page.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAEhD,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAE5E,qBAAa,qBAAsB,SAAQ,0BAA0B;gBACvD,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,oBAAoB;IAMrD,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;CAGlD"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ConfluencePageStorage = void 0;
|
|
4
|
+
const safeUrl_1 = require("../safeUrl");
|
|
4
5
|
const confluence_versioned_storage_1 = require("./confluence-versioned-storage");
|
|
5
6
|
class ConfluencePageStorage extends confluence_versioned_storage_1.ConfluenceVersionedStorage {
|
|
6
7
|
constructor(pageId, apiClient) {
|
|
7
|
-
const storageApiPath =
|
|
8
|
+
const storageApiPath = (key) => safeUrl_1.route `/wiki/rest/api/content/${pageId}/property/${key}`;
|
|
8
9
|
super(storageApiPath, apiClient);
|
|
9
10
|
}
|
|
10
11
|
async set(key, value) {
|
|
@@ -12,4 +13,3 @@ class ConfluencePageStorage extends confluence_versioned_storage_1.ConfluenceVer
|
|
|
12
13
|
}
|
|
13
14
|
}
|
|
14
15
|
exports.ConfluencePageStorage = ConfluencePageStorage;
|
|
15
|
-
ConfluencePageStorage.API_PATH = '/wiki/rest/api/content/';
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RequestProductMethod } from '../index';
|
|
2
2
|
import { ConfluenceVersionedStorage } from './confluence-versioned-storage';
|
|
3
3
|
export declare class ConfluenceSpaceStorage extends ConfluenceVersionedStorage {
|
|
4
|
-
|
|
5
|
-
constructor(spaceId: string, apiClient: FetchMethod);
|
|
4
|
+
constructor(spaceId: string, apiClient: RequestProductMethod);
|
|
6
5
|
set(key: string, value: any): Promise<void>;
|
|
7
6
|
}
|
|
8
7
|
//# sourceMappingURL=confluence-space.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"confluence-space.d.ts","sourceRoot":"","sources":["../../src/properties/confluence-space.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"confluence-space.d.ts","sourceRoot":"","sources":["../../src/properties/confluence-space.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAEhD,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAE5E,qBAAa,sBAAuB,SAAQ,0BAA0B;gBACxD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,oBAAoB;IAMtD,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;CAGlD"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ConfluenceSpaceStorage = void 0;
|
|
4
|
+
const safeUrl_1 = require("../safeUrl");
|
|
4
5
|
const confluence_versioned_storage_1 = require("./confluence-versioned-storage");
|
|
5
6
|
class ConfluenceSpaceStorage extends confluence_versioned_storage_1.ConfluenceVersionedStorage {
|
|
6
7
|
constructor(spaceId, apiClient) {
|
|
7
|
-
const storageApiPath =
|
|
8
|
+
const storageApiPath = (key) => safeUrl_1.route `/wiki/rest/api/space/${spaceId}/property/${key}`;
|
|
8
9
|
super(storageApiPath, apiClient);
|
|
9
10
|
}
|
|
10
11
|
async set(key, value) {
|
|
@@ -12,4 +13,3 @@ class ConfluenceSpaceStorage extends confluence_versioned_storage_1.ConfluenceVe
|
|
|
12
13
|
}
|
|
13
14
|
}
|
|
14
15
|
exports.ConfluenceSpaceStorage = ConfluenceSpaceStorage;
|
|
15
|
-
ConfluenceSpaceStorage.API_PATH = '/wiki/rest/api/space/';
|
|
@@ -5,7 +5,7 @@ const product_scoped_storage_1 = require("./product-scoped-storage");
|
|
|
5
5
|
const storage_1 = require("@forge/storage");
|
|
6
6
|
class ConfluenceVersionedStorage extends product_scoped_storage_1.ProductScopedStorage {
|
|
7
7
|
async versionedSet(key, value) {
|
|
8
|
-
const versionResponse = await this.apiClient(
|
|
8
|
+
const versionResponse = await this.apiClient(this.storageApiPath(key));
|
|
9
9
|
if (!versionResponse.ok && versionResponse.status !== 404) {
|
|
10
10
|
throw storage_1.APIError.forStatus(versionResponse.status);
|
|
11
11
|
}
|
|
@@ -17,7 +17,7 @@ class ConfluenceVersionedStorage extends product_scoped_storage_1.ProductScopedS
|
|
|
17
17
|
number: updatedVersionNumber
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
|
-
await this.apiClient(
|
|
20
|
+
await this.apiClient(this.storageApiPath(key), this.buildSetRequestOptions(requestBody, requestMethod));
|
|
21
21
|
}
|
|
22
22
|
async getUpdatedVersion(versionResponse) {
|
|
23
23
|
if (!versionResponse.ok) {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ProductScopedStorage } from './product-scoped-storage';
|
|
2
|
-
import {
|
|
2
|
+
import { RequestProductMethod } from '../index';
|
|
3
3
|
export declare class JiraIssueStorage extends ProductScopedStorage {
|
|
4
|
-
|
|
5
|
-
constructor(issueKey: string, apiClient: FetchMethod);
|
|
4
|
+
constructor(issueKey: string, apiClient: RequestProductMethod);
|
|
6
5
|
}
|
|
7
6
|
//# sourceMappingURL=jira-issue.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jira-issue.d.ts","sourceRoot":"","sources":["../../src/properties/jira-issue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"jira-issue.d.ts","sourceRoot":"","sources":["../../src/properties/jira-issue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAGhD,qBAAa,gBAAiB,SAAQ,oBAAoB;gBAC5C,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,oBAAoB;CAK9D"}
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.JiraIssueStorage = void 0;
|
|
4
4
|
const product_scoped_storage_1 = require("./product-scoped-storage");
|
|
5
|
+
const safeUrl_1 = require("../safeUrl");
|
|
5
6
|
class JiraIssueStorage extends product_scoped_storage_1.ProductScopedStorage {
|
|
6
7
|
constructor(issueKey, apiClient) {
|
|
7
|
-
const storageApiPath =
|
|
8
|
+
const storageApiPath = (key) => safeUrl_1.route `/rest/api/3/issue/${issueKey}/properties/${key}`;
|
|
8
9
|
super(storageApiPath, apiClient);
|
|
9
10
|
}
|
|
10
11
|
}
|
|
11
12
|
exports.JiraIssueStorage = JiraIssueStorage;
|
|
12
|
-
JiraIssueStorage.API_PATH = '/rest/api/3/issue/';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ProductScopedStorage } from './product-scoped-storage';
|
|
2
|
-
import {
|
|
2
|
+
import { RequestProductMethod } from '../index';
|
|
3
3
|
export declare class JiraProjectStorage extends ProductScopedStorage {
|
|
4
|
-
|
|
5
|
-
constructor(projectKey: string, apiClient: FetchMethod);
|
|
4
|
+
constructor(projectKey: string, apiClient: RequestProductMethod);
|
|
6
5
|
}
|
|
7
6
|
//# sourceMappingURL=jira-project.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jira-project.d.ts","sourceRoot":"","sources":["../../src/properties/jira-project.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"jira-project.d.ts","sourceRoot":"","sources":["../../src/properties/jira-project.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAGhD,qBAAa,kBAAmB,SAAQ,oBAAoB;gBAC9C,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,oBAAoB;CAKhE"}
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.JiraProjectStorage = void 0;
|
|
4
4
|
const product_scoped_storage_1 = require("./product-scoped-storage");
|
|
5
|
+
const safeUrl_1 = require("../safeUrl");
|
|
5
6
|
class JiraProjectStorage extends product_scoped_storage_1.ProductScopedStorage {
|
|
6
7
|
constructor(projectKey, apiClient) {
|
|
7
|
-
const storageApiPath =
|
|
8
|
+
const storageApiPath = (key) => safeUrl_1.route `/rest/api/3/project/${projectKey}/properties/${key}`;
|
|
8
9
|
super(storageApiPath, apiClient);
|
|
9
10
|
}
|
|
10
11
|
}
|
|
11
12
|
exports.JiraProjectStorage = JiraProjectStorage;
|
|
12
|
-
JiraProjectStorage.API_PATH = '/rest/api/3/project/';
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { StorageAdapter } from './storage-adapter';
|
|
2
|
-
import {
|
|
2
|
+
import { RequestProductMethod } from '../index';
|
|
3
|
+
import { Route } from '../safeUrl';
|
|
3
4
|
export declare class ProductScopedStorage implements StorageAdapter {
|
|
4
|
-
protected storageApiPath: string;
|
|
5
|
-
protected apiClient:
|
|
6
|
-
constructor(storageApiPath: string, apiClient:
|
|
5
|
+
protected storageApiPath: (key: string) => Route;
|
|
6
|
+
protected apiClient: RequestProductMethod;
|
|
7
|
+
constructor(storageApiPath: (key: string) => Route, apiClient: RequestProductMethod);
|
|
7
8
|
get(key: string): Promise<any>;
|
|
8
9
|
set(key: string, value: any): Promise<void>;
|
|
9
10
|
delete(key: string): Promise<void>;
|
|
@@ -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,
|
|
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;IAe9B,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"}
|
|
@@ -8,7 +8,7 @@ class ProductScopedStorage {
|
|
|
8
8
|
this.apiClient = apiClient;
|
|
9
9
|
}
|
|
10
10
|
async get(key) {
|
|
11
|
-
const response = await this.apiClient(
|
|
11
|
+
const response = await this.apiClient(this.storageApiPath(key));
|
|
12
12
|
if (!response.ok) {
|
|
13
13
|
if (/400|401|403|404/.test(response.status.toString())) {
|
|
14
14
|
return undefined;
|
|
@@ -19,13 +19,13 @@ class ProductScopedStorage {
|
|
|
19
19
|
return value;
|
|
20
20
|
}
|
|
21
21
|
async set(key, value) {
|
|
22
|
-
const response = await this.apiClient(
|
|
22
|
+
const response = await this.apiClient(this.storageApiPath(key), this.buildSetRequestOptions(value, 'PUT'));
|
|
23
23
|
if (!response.ok) {
|
|
24
24
|
throw storage_1.APIError.forStatus(response.status);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
async delete(key) {
|
|
28
|
-
const response = await this.apiClient(
|
|
28
|
+
const response = await this.apiClient(this.storageApiPath(key), { method: 'DELETE' });
|
|
29
29
|
if (!response.ok) {
|
|
30
30
|
throw storage_1.APIError.forStatus(response.status);
|
|
31
31
|
}
|
package/out/safeUrl.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare type Route = {
|
|
2
|
+
readonly value: string;
|
|
3
|
+
};
|
|
4
|
+
export declare function isRoute(x: unknown): x is Route;
|
|
5
|
+
export declare function route(path: TemplateStringsArray, ...parameters: (string | number | URLSearchParams | Route)[]): Route;
|
|
6
|
+
export declare function requireSafeUrl(url: unknown): Route;
|
|
7
|
+
export declare function assumeTrustedRoute(route: string): Route;
|
|
8
|
+
//# sourceMappingURL=safeUrl.d.ts.map
|
|
@@ -0,0 +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"}
|
package/out/safeUrl.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assumeTrustedRoute = exports.requireSafeUrl = exports.route = exports.isRoute = void 0;
|
|
4
|
+
class ReadonlyRoute {
|
|
5
|
+
constructor(value_) {
|
|
6
|
+
this.value_ = value_;
|
|
7
|
+
}
|
|
8
|
+
set value(_) {
|
|
9
|
+
throw new Error('modification of a Route is not allowed');
|
|
10
|
+
}
|
|
11
|
+
get value() {
|
|
12
|
+
return this.value_;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function isRoute(x) {
|
|
16
|
+
return x instanceof ReadonlyRoute;
|
|
17
|
+
}
|
|
18
|
+
exports.isRoute = isRoute;
|
|
19
|
+
function route(path, ...parameters) {
|
|
20
|
+
let fullPath = '';
|
|
21
|
+
for (let i = 0; i < path.length; i++) {
|
|
22
|
+
fullPath += path[i];
|
|
23
|
+
if (i < parameters.length) {
|
|
24
|
+
const parameter = parameters[i];
|
|
25
|
+
if (parameter === '..') {
|
|
26
|
+
throw new Error('Disallowing path traversal attempt');
|
|
27
|
+
}
|
|
28
|
+
else if (isRoute(parameter)) {
|
|
29
|
+
fullPath += parameter.value;
|
|
30
|
+
}
|
|
31
|
+
else if (parameter instanceof URLSearchParams) {
|
|
32
|
+
fullPath += parameter.toString();
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
fullPath += encodeURIComponent(parameter);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return new ReadonlyRoute(fullPath);
|
|
40
|
+
}
|
|
41
|
+
exports.route = route;
|
|
42
|
+
function requireSafeUrl(url) {
|
|
43
|
+
if (url instanceof ReadonlyRoute) {
|
|
44
|
+
return url;
|
|
45
|
+
}
|
|
46
|
+
throw new Error(`You must create your route using the 'route' export from '@forge/api'.
|
|
47
|
+
See https://go.atlassian.com/forge-fetch-route for more information.`);
|
|
48
|
+
}
|
|
49
|
+
exports.requireSafeUrl = requireSafeUrl;
|
|
50
|
+
function assumeTrustedRoute(route) {
|
|
51
|
+
return new ReadonlyRoute(route);
|
|
52
|
+
}
|
|
53
|
+
exports.assumeTrustedRoute = assumeTrustedRoute;
|
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-d18f8dd",
|
|
4
4
|
"description": "Forge API methods",
|
|
5
5
|
"author": "Atlassian",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
"@types/node": "^12.12.63"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@forge/
|
|
18
|
+
"@forge/auth": "^0.0.0-experimental-d18f8dd",
|
|
19
|
+
"@forge/storage": "^0.0.0-experimental-d18f8dd",
|
|
19
20
|
"@types/node-fetch": "^2.5.7",
|
|
20
21
|
"node-fetch": "^2.6.1"
|
|
21
22
|
}
|