@forge/api 2.7.0-next.0 → 2.8.0-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @forge/api
2
2
 
3
+ ## 2.8.0-next.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 95913f6: Call product APIs via proxy on Node runtime
8
+
9
+ ## 2.7.0
10
+
11
+ ### Minor Changes
12
+
13
+ - b3ee297: Unblock valid property API keys and handled error propagation
14
+
15
+ ### Patch Changes
16
+
17
+ - Updated dependencies [3c3c42b]
18
+ - @forge/storage@1.3.0
19
+
3
20
  ## 2.7.0-next.0
4
21
 
5
22
  ### Minor Changes
@@ -0,0 +1,14 @@
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 interface ProxyInformation {
7
+ token: string;
8
+ url: string;
9
+ }
10
+ export declare const createProxyFetch: (provider: 'app' | 'user' | undefined, remote: 'jira' | 'confluence' | 'stargate') => FetchFunction;
11
+ export declare function getNodeRuntimeAPI(): FetchAPI;
12
+ export declare function getSandboxRuntimeAPI(): FetchAPI | null;
13
+ export {};
14
+ //# 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,EAAoB,MAAM,YAAY,CAAC;AACzF,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAG9B,aAAK,aAAa,GAAG,CAAC,GAAG,EAAE,WAAW,GAAG,GAAG,EAAE,OAAO,EAAE,WAAW,GAAG,SAAS,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;AAErG,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb;AAED,eAAO,MAAM,gBAAgB,aACjB,KAAK,GAAG,MAAM,GAAG,SAAS,UAC5B,MAAM,GAAG,YAAY,GAAG,UAAU,KACzC,aAiBF,CAAC;AAOF,wBAAgB,iBAAiB,IAAI,QAAQ,CAiB5C;AAED,wBAAgB,oBAAoB,IAAI,QAAQ,GAAG,IAAI,CAOtD"}
@@ -0,0 +1,51 @@
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 polyfill_response_1 = require("./polyfill-response");
8
+ const createProxyFetch = (provider, remote) => {
9
+ return (url, options) => {
10
+ const proxy = global.proxyInfo;
11
+ const request = new node_fetch_1.Request(url, options);
12
+ const headers = new node_fetch_1.Headers(request.headers);
13
+ headers.set('Forge-Proxy-Target-Relative', request.url);
14
+ headers.set('Forge-Proxy-Authorization', `Bearer ${proxy.token}`);
15
+ const proxyRequest = new node_fetch_1.Request(`${proxy.url}/fpp/provider/${provider}/remote/${remote}`, Object.assign(Object.assign({}, request), { headers }));
16
+ return (0, node_fetch_1.default)(proxyRequest);
17
+ };
18
+ };
19
+ exports.createProxyFetch = createProxyFetch;
20
+ const throwNotImplementedError = () => {
21
+ throw new Error('not implemented');
22
+ };
23
+ function getNodeRuntimeAPI() {
24
+ return {
25
+ fetch: throwNotImplementedError,
26
+ requestJira: throwNotImplementedError,
27
+ requestConfluence: throwNotImplementedError,
28
+ asUser: () => ({
29
+ requestJira: (0, _1.wrapRequestProduct)((0, exports.createProxyFetch)('user', 'jira')),
30
+ requestConfluence: (0, _1.wrapRequestProduct)((0, exports.createProxyFetch)('user', 'confluence')),
31
+ requestGraph: (0, _1.wrapRequestGraph)((0, exports.createProxyFetch)('user', 'stargate')),
32
+ withProvider: throwNotImplementedError
33
+ }),
34
+ asApp: () => ({
35
+ requestJira: (0, _1.wrapRequestProduct)((0, exports.createProxyFetch)('app', 'jira')),
36
+ requestConfluence: (0, _1.wrapRequestProduct)((0, exports.createProxyFetch)('app', 'confluence')),
37
+ requestGraph: (0, _1.wrapRequestGraph)((0, exports.createProxyFetch)('app', 'stargate'))
38
+ })
39
+ };
40
+ }
41
+ exports.getNodeRuntimeAPI = getNodeRuntimeAPI;
42
+ function getSandboxRuntimeAPI() {
43
+ const { api: globalAPI } = global;
44
+ if (globalAPI && Object.keys(globalAPI).length) {
45
+ return (0, _1.wrapFetchApiMethods)(globalAPI, polyfill_response_1.transformResponse);
46
+ }
47
+ else {
48
+ return null;
49
+ }
50
+ }
51
+ exports.getSandboxRuntimeAPI = getSandboxRuntimeAPI;
@@ -1,6 +1,8 @@
1
1
  import { RequestInfo, RequestInit } from 'node-fetch';
2
- import { FetchAPI } from '..';
3
- export { transformResponse } from './polyfill-response';
4
- export declare type FetchWrapper = (fetchApi: Function) => (url: RequestInfo, init?: RequestInit) => any;
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
@@ -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,EAQT,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,QA+BvE,CAAC"}
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,QA+BvE,CAAC"}
package/out/api/index.js CHANGED
@@ -1,34 +1,35 @@
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.wrapFetchApiMethods = (api, wrapFetch) => {
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)),
25
26
  asUser: () => ({
26
- requestJira: wrapRequestProduct(wrapFetch(api.asUser().requestJira)),
27
- requestConfluence: wrapRequestProduct(wrapFetch(api.asUser().requestConfluence)),
28
- requestGraph: wrapRequestGraph(wrapFetch(api.asUser().requestGraph)),
27
+ requestJira: (0, exports.wrapRequestProduct)(wrapFetch(api.asUser().requestJira)),
28
+ requestConfluence: (0, exports.wrapRequestProduct)(wrapFetch(api.asUser().requestConfluence)),
29
+ requestGraph: (0, exports.wrapRequestGraph)(wrapFetch(api.asUser().requestGraph)),
29
30
  withProvider: (provider, remoteName, tokenId) => {
30
31
  const { hasCredentials, requestCredentials, listCredentials, fetch: withProviderFetch } = api.asUser().withProvider(provider, remoteName, tokenId);
31
- const wrappedRequestRemote = wrapWithRouteUnwrapper(wrapFetch(withProviderFetch));
32
+ const wrappedRequestRemote = (0, exports.wrapWithRouteUnwrapper)(wrapFetch(withProviderFetch));
32
33
  return {
33
34
  hasCredentials,
34
35
  requestCredentials,
@@ -38,9 +39,10 @@ exports.wrapFetchApiMethods = (api, wrapFetch) => {
38
39
  }
39
40
  }),
40
41
  asApp: () => ({
41
- requestJira: wrapRequestProduct(wrapFetch(api.asApp().requestJira)),
42
- requestConfluence: wrapRequestProduct(wrapFetch(api.asApp().requestConfluence)),
43
- requestGraph: wrapRequestGraph(wrapFetch(api.asApp().requestGraph))
42
+ requestJira: (0, exports.wrapRequestProduct)(wrapFetch(api.asApp().requestJira)),
43
+ requestConfluence: (0, exports.wrapRequestProduct)(wrapFetch(api.asApp().requestConfluence)),
44
+ requestGraph: (0, exports.wrapRequestGraph)(wrapFetch(api.asApp().requestGraph))
44
45
  })
45
46
  };
46
47
  };
48
+ 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;AAEjC,eAAO,MAAM,iBAAiB,EAAE,YAM/B,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
- exports.transformResponse = (fetchApi) => async (url, init) => {
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;
@@ -1,7 +1,7 @@
1
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>;
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
- exports.authorize = () => {
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;
@@ -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;AAGtF,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,oBAAY,WAAW,GAAG,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,aAAa,GAAG,IAAI,GAAG,QAAQ,GAAG,YAAY,GAAG,SAAS,CAAC,CAAC;AACvH,oBAAY,WAAW,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;AACpF,oBAAY,wBAAwB,GAAG,CAAC,GAAG,E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AmB,GAAG,gCAAgC,CAAC;IACzF,KAAK,IAAI,qBAAqB,GAAG,mBAAmB,CAAC;IACrD,KAAK,EAAE,wBAAwB,CAAC;CACjC;AAED,MAAM,WAAW,QAAS,SAAQ,QAAQ;IACxC,KAAK,EAAE,QAAQ,CAAC;CACjB;AAaD,QAAA,MAAM,MAAM,QApBA,qBAAqB,GAAG,mBAAmB,GAAG,gCAoB5B,CAAC;AAC/B,QAAA,MAAM,KAAK,QApBA,qBAAqB,GAAG,mBAoBP,CAAC;AAC7B,QAAA,MAAM,KAAK,0BAAiB,CAAC;AAC7B,QAAA,MAAM,WAAW,sBAAuB,CAAC;AACzC,QAAA,MAAM,iBAAiB,sBAA6B,CAAC;AAerD,QAAA,MAAM,KAAK,eAA0B,CAAC;AAEtC,QAAA,MAAM,OAAO,EAAE,eAEd,CAAC;AAEF,QAAA,MAAM,UAAU,EAAE,aAA6B,CAAC;AAEhD,QAAA,MAAM,GAAG,EAAE,QAGV,CAAC;AAGF,eAAO,MAAM,OAAO;;CAEnB,CAAC;AAEF,eAAe,GAAG,CAAC;AACnB,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC;AACnH,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACzG,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,OAAO,EAAE,KAAK,EAAE,kBAAkB,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC"}
package/out/index.js CHANGED
@@ -1,14 +1,15 @@
1
1
  "use strict";
2
+ var _a, _b, _c, _d;
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.assumeTrustedRoute = exports.route = exports.startsWith = 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
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_1 = require("./api/fetch");
12
13
  function withDeprecatedMessage(method, message) {
13
14
  const wrappedMethod = (...args) => {
14
15
  console.warn(message);
@@ -16,16 +17,16 @@ function withDeprecatedMessage(method, message) {
16
17
  };
17
18
  return wrappedMethod;
18
19
  }
19
- const FetchAPI = api_1.wrapFetchApiMethods(global.api, api_1.transformResponse);
20
- const asUser = FetchAPI.asUser;
20
+ const fetchAPI = (_a = (0, fetch_1.getSandboxRuntimeAPI)()) !== null && _a !== void 0 ? _a : (0, fetch_1.getNodeRuntimeAPI)();
21
+ const asUser = fetchAPI.asUser;
21
22
  exports.asUser = asUser;
22
- const asApp = FetchAPI.asApp;
23
+ const asApp = fetchAPI.asApp;
23
24
  exports.asApp = asApp;
24
- const fetch = FetchAPI.fetch;
25
+ const fetch = fetchAPI.fetch;
25
26
  exports.fetch = fetch;
26
- const requestJira = FetchAPI.requestJira;
27
+ const requestJira = fetchAPI.requestJira;
27
28
  exports.requestJira = requestJira;
28
- const requestConfluence = FetchAPI.requestConfluence;
29
+ const requestConfluence = fetchAPI.requestConfluence;
29
30
  exports.requestConfluence = requestConfluence;
30
31
  const deprecatedPropertiesApi = Object.entries(properties_1.propertiesApi)
31
32
  .map(([name, method]) => {
@@ -37,13 +38,13 @@ const deprecatedPropertiesApi = Object.entries(properties_1.propertiesApi)
37
38
  .reduce((acc, next) => Object.assign(acc, next), {});
38
39
  const store = deprecatedPropertiesApi;
39
40
  exports.store = store;
40
- const storage = storage_1.getStorageInstanceWithQuery(new storage_1.GlobalStorage(global.api.__getAppAri, global.api.asApp().__requestAtlassian));
41
+ const storage = (0, storage_1.getStorageInstanceWithQuery)(new storage_1.GlobalStorage((_b = global.api) === null || _b === void 0 ? void 0 : _b.__getAppAri, (_c = global.api) === null || _c === void 0 ? void 0 : _c.asApp().__requestAtlassian));
41
42
  exports.storage = storage;
42
43
  const properties = properties_1.propertiesApi;
43
44
  exports.properties = properties;
44
- const API = Object.assign(Object.assign({}, FetchAPI), { store: Object.assign({}, store) });
45
+ const API = Object.assign(Object.assign({}, fetchAPI), { store: Object.assign({}, store) });
45
46
  exports.privacy = {
46
- reportPersonalData: privacy_1.createReportPersonalData(global.api.asApp().__requestAtlassian)
47
+ reportPersonalData: (0, privacy_1.createReportPersonalData)((_d = global.api) === null || _d === void 0 ? void 0 : _d.asApp().__requestAtlassian)
47
48
  };
48
49
  exports.default = API;
49
50
  var storage_2 = require("@forge/storage");
@@ -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,OAAO,CAAC,WAAW,CAAC,gBAEnC,OAAO,EAAE,KAAG,OAAO,CAAC,aAAa,EAAE,CAqB3E,CAAC"}
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"}
@@ -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
- exports.createReportPersonalData = (requestAtlassian) => {
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) {
@@ -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(projectKey, index_1.asApp().requestJira)),
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: "POST" | "PUT";
12
+ method: "PUT" | "POST";
13
13
  body: string;
14
14
  headers: {
15
15
  'content-type': string;
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.sanitizedKey = void 0;
4
- exports.sanitizedKey = (input) => {
4
+ const sanitizedKey = (input) => {
5
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forge/api",
3
- "version": "2.7.0-next.0",
3
+ "version": "2.8.0-next.0",
4
4
  "description": "Forge API methods",
5
5
  "author": "Atlassian",
6
6
  "license": "UNLICENSED",
@@ -16,7 +16,7 @@
16
16
  },
17
17
  "dependencies": {
18
18
  "@forge/auth": "^0.0.1",
19
- "@forge/storage": "^1.3.0-next.0",
19
+ "@forge/storage": "^1.3.0",
20
20
  "@types/node-fetch": "^2.5.7",
21
21
  "node-fetch": "2.6.1"
22
22
  }