@forge/bridge 2.4.0 → 2.5.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,11 @@
1
1
  # @forge/bridge
2
2
 
3
+ ## 2.5.0-next.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 6269d73d: Fix return type for getContext method
8
+
3
9
  ## 2.4.0
4
10
 
5
11
  ### Minor Changes
package/out/bridge.js CHANGED
@@ -5,7 +5,7 @@ const errors_1 = require("./errors");
5
5
  function isBridgeAvailable(bridge) {
6
6
  return !!(bridge === null || bridge === void 0 ? void 0 : bridge.callBridge);
7
7
  }
8
- exports.getCallBridge = () => {
8
+ const getCallBridge = () => {
9
9
  if (!isBridgeAvailable(window.__bridge)) {
10
10
  throw new errors_1.BridgeAPIError(`
11
11
  Unable to establish a connection with the Custom UI bridge.
@@ -14,3 +14,4 @@ exports.getCallBridge = () => {
14
14
  }
15
15
  return window.__bridge.callBridge;
16
16
  };
17
+ exports.getCallBridge = getCallBridge;
@@ -1 +1 @@
1
- {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/events/events.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAYxC,eAAO,MAAM,MAAM;kBARE,MAAM,YAAY,GAAG,KAAG,OAAO,CAAC,IAAI,CAAC;gBAIvC,MAAM,uBAAuB,GAAG,KAAK,GAAG,KAAG,OAAO,CAAC,YAAY,CAAC;CAOlF,CAAC"}
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/events/events.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAYxC,eAAO,MAAM,MAAM;kBARE,MAAM,YAAY,GAAG,KAAG,QAAQ,IAAI,CAAC;gBAIvC,MAAM,uBAAuB,GAAG,KAAK,GAAG,KAAG,QAAQ,YAAY,CAAC;CAOlF,CAAC"}
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.events = void 0;
4
4
  const bridge_1 = require("../bridge");
5
- const callBridge = bridge_1.getCallBridge();
5
+ const callBridge = (0, bridge_1.getCallBridge)();
6
6
  const emit = (event, payload) => {
7
7
  return callBridge('emit', { event, payload });
8
8
  };
@@ -1,6 +1,6 @@
1
1
  import { getCallBridge } from '../bridge';
2
2
  export declare const productFetchApi: (callBridge: ReturnType<typeof getCallBridge>) => {
3
- requestConfluence: (restPath: string, fetchOptions?: RequestInit | undefined) => Promise<Response>;
4
- requestJira: (restPath: string, fetchOptions?: RequestInit | undefined) => Promise<Response>;
3
+ requestConfluence: (restPath: string, fetchOptions?: RequestInit) => Promise<Response>;
4
+ requestJira: (restPath: string, fetchOptions?: RequestInit) => Promise<Response>;
5
5
  };
6
6
  //# sourceMappingURL=fetch.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../src/fetch/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAqB1C,eAAO,MAAM,eAAe,eAAgB,UAAU,CAAC,OAAO,aAAa,CAAC;kCAuB1C,MAAM,6CAA+B,OAAO,CAAC,QAAQ,CAAC;4BAG5D,MAAM,6CAA+B,OAAO,CAAC,QAAQ,CAAC;CAGjF,CAAC"}
1
+ {"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../src/fetch/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAqB1C,eAAO,MAAM,eAAe,eAAgB,WAAW,oBAAoB,CAAC;kCAuB1C,MAAM,iBAAiB,WAAW,KAAG,QAAQ,QAAQ,CAAC;4BAG5D,MAAM,iBAAiB,WAAW,KAAG,QAAQ,QAAQ,CAAC;CAGjF,CAAC"}
@@ -11,7 +11,7 @@ const parseBodyAndHeaders = (init) => tslib_1.__awaiter(void 0, void 0, void 0,
11
11
  headers: new Headers(headers)
12
12
  };
13
13
  });
14
- exports.productFetchApi = (callBridge) => {
14
+ const productFetchApi = (callBridge) => {
15
15
  const fetch = (product, restPath, init) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
16
16
  const { body: requestBody, headers: requestHeaders } = yield parseBodyAndHeaders(init);
17
17
  if (!requestHeaders.has('X-Atlassian-Token')) {
@@ -30,3 +30,4 @@ exports.productFetchApi = (callBridge) => {
30
30
  requestJira: (restPath, fetchOptions) => fetch('jira', restPath, fetchOptions)
31
31
  };
32
32
  };
33
+ exports.productFetchApi = productFetchApi;
@@ -1,2 +1,2 @@
1
- export declare const requestConfluence: (restPath: string, fetchOptions?: RequestInit | undefined) => Promise<Response>, requestJira: (restPath: string, fetchOptions?: RequestInit | undefined) => Promise<Response>;
1
+ export declare const requestConfluence: (restPath: string, fetchOptions?: RequestInit) => Promise<Response>, requestJira: (restPath: string, fetchOptions?: RequestInit) => Promise<Response>;
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/fetch/index.ts"],"names":[],"mappings":"AAQA,eAAO,MAAQ,iBAAiB,aAJA,MAAM,6CAAiC,OAAO,CAAC,QAAQ,CAAC,EAItD,WAAW,aAHnB,MAAM,6CAAiC,OAAO,CAAC,QAAQ,CAGoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/fetch/index.ts"],"names":[],"mappings":"AAQA,eAAO,MAAQ,iBAAiB,aAJA,MAAM,iBAAiB,WAAW,KAAK,QAAQ,QAAQ,CAAC,EAItD,WAAW,aAHnB,MAAM,iBAAiB,WAAW,KAAK,QAAQ,QAAQ,CAGoB,CAAC"}
@@ -4,4 +4,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.requestJira = exports.requestConfluence = void 0;
5
5
  const bridge_1 = require("../bridge");
6
6
  const fetch_1 = require("./fetch");
7
- _a = fetch_1.productFetchApi(bridge_1.getCallBridge()), exports.requestConfluence = _a.requestConfluence, exports.requestJira = _a.requestJira;
7
+ _a = (0, fetch_1.productFetchApi)((0, bridge_1.getCallBridge)()), exports.requestConfluence = _a.requestConfluence, exports.requestJira = _a.requestJira;
package/out/flag/flag.js CHANGED
@@ -4,8 +4,8 @@ exports.showFlag = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const bridge_1 = require("../bridge");
6
6
  const errors_1 = require("../errors");
7
- const callBridge = bridge_1.getCallBridge();
8
- exports.showFlag = (options) => {
7
+ const callBridge = (0, bridge_1.getCallBridge)();
8
+ const showFlag = (options) => {
9
9
  var _a;
10
10
  if (!options.id) {
11
11
  throw new errors_1.BridgeAPIError('"id" must be defined in flag options');
@@ -18,3 +18,4 @@ exports.showFlag = (options) => {
18
18
  })
19
19
  };
20
20
  };
21
+ exports.showFlag = showFlag;
package/out/flag/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.showFlag = void 0;
3
4
  var flag_1 = require("./flag");
4
5
  Object.defineProperty(exports, "showFlag", { enumerable: true, get: function () { return flag_1.showFlag; } });
@@ -4,7 +4,7 @@ exports.invoke = void 0;
4
4
  const bridge_1 = require("../bridge");
5
5
  const errors_1 = require("../errors");
6
6
  const utils_1 = require("../utils");
7
- const callBridge = bridge_1.getCallBridge();
7
+ const callBridge = (0, bridge_1.getCallBridge)();
8
8
  const validatePayload = (payload) => {
9
9
  if (!payload)
10
10
  return;
@@ -19,4 +19,4 @@ const _invoke = (functionKey, payload) => {
19
19
  validatePayload(payload);
20
20
  return callBridge('invoke', { functionKey, payload });
21
21
  };
22
- exports.invoke = utils_1.withRateLimiter(_invoke, 20, 2000, 'Resolver calls are rate limited at 20req/2s');
22
+ exports.invoke = (0, utils_1.withRateLimiter)(_invoke, 20, 2000, 'Resolver calls are rate limited at 20req/2s');
@@ -4,7 +4,7 @@ exports.Modal = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const bridge_1 = require("../bridge");
6
6
  const errors_1 = require("../errors");
7
- const callBridge = bridge_1.getCallBridge();
7
+ const callBridge = (0, bridge_1.getCallBridge)();
8
8
  const noop = () => { };
9
9
  class Modal {
10
10
  constructor(opts) {
@@ -1 +1 @@
1
- {"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../src/router/router.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,MAAM;oBANG,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC;gBAE5B,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC;kBAEtB,OAAO,CAAC,IAAI,CAAC;CAMhC,CAAC"}
1
+ {"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../src/router/router.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,MAAM;oBANG,MAAM,KAAK,QAAQ,IAAI,CAAC;gBAE5B,MAAM,KAAK,QAAQ,IAAI,CAAC;kBAEtB,QAAQ,IAAI,CAAC;CAMhC,CAAC"}
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.router = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const bridge_1 = require("../bridge");
6
- const callBridge = bridge_1.getCallBridge();
6
+ const callBridge = (0, bridge_1.getCallBridge)();
7
7
  const navigate = (url) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { return callBridge('navigate', { url, type: 'same-tab' }); });
8
8
  const open = (url) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { return callBridge('navigate', { url, type: 'new-tab' }); });
9
9
  const reload = () => tslib_1.__awaiter(void 0, void 0, void 0, function* () { return callBridge('reload'); });
package/out/types.d.ts CHANGED
@@ -5,8 +5,25 @@ export declare type InvokeResponse = Record<string, any> | void;
5
5
  export declare type ProductFetchResponse = {
6
6
  body?: string;
7
7
  } & Pick<ResponseInit, 'headers' | 'status' | 'statusText'>;
8
- export declare type FullContext = {};
8
+ export interface FullContext {
9
+ accountId?: string;
10
+ cloudId?: string;
11
+ extension: ExtensionData;
12
+ license?: LicenseState;
13
+ localId: string;
14
+ locale: string;
15
+ moduleKey: string;
16
+ siteUrl: string;
17
+ timezone: string;
18
+ }
19
+ interface ExtensionData {
20
+ [k: string]: any;
21
+ }
22
+ interface LicenseState {
23
+ isActive?: boolean;
24
+ }
9
25
  export declare type Subscription = {
10
26
  unsubscribe: () => void;
11
27
  };
28
+ export {};
12
29
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,oBAAY,aAAa,GAAG;KACzB,GAAG,IAAI,MAAM,GAAG,MAAM,GAAG,GAAG;CAC9B,CAAC;AAEF,oBAAY,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC;AAExD,oBAAY,oBAAoB,GAAG;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAAC,YAAY,EAAE,SAAS,GAAG,QAAQ,GAAG,YAAY,CAAC,CAAC;AAE/G,oBAAY,WAAW,GAAG,EAAE,CAAC;AAE7B,oBAAY,YAAY,GAAG;IACzB,WAAW,EAAE,MAAM,IAAI,CAAC;CACzB,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,oBAAY,aAAa,GAAG;KACzB,GAAG,IAAI,MAAM,GAAG,MAAM,GAAG,GAAG;CAC9B,CAAC;AAEF,oBAAY,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC;AAExD,oBAAY,oBAAoB,GAAG;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAAC,YAAY,EAAE,SAAS,GAAG,QAAQ,GAAG,YAAY,CAAC,CAAC;AAE/G,MAAM,WAAW,WAAW;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,aAAa,CAAC;IACzB,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB;AACD,UAAU,aAAa;IACrB,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC;CAClB;AAED,UAAU,YAAY;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,oBAAY,YAAY,GAAG;IACzB,WAAW,EAAE,MAAM,IAAI,CAAC;CACzB,CAAC"}
@@ -1,2 +1,2 @@
1
- export declare const withRateLimiter: <Fn extends (...args: any[]) => any>(wrappedFn: Fn, maxOps: number, intervalInMs: number, exceededErrorMessage?: string | undefined) => <T>(...args: Parameters<Fn>) => Promise<T>;
1
+ export declare const withRateLimiter: <Fn extends (...args: any[]) => any>(wrappedFn: Fn, maxOps: number, intervalInMs: number, exceededErrorMessage?: string) => <T>(...args: Parameters<Fn>) => Promise<T>;
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe,wBAAyB,GAAG,EAAE,KAAK,GAAG,yBAExD,MAAM,gBACA,MAAM,0FAsBrB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe,wBAAyB,GAAG,EAAE,KAAK,GAAG,yBAExD,MAAM,gBACA,MAAM,yBACG,MAAM,+CAqB9B,CAAC"}
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.withRateLimiter = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const errors_1 = require("../errors");
6
- exports.withRateLimiter = (wrappedFn, maxOps, intervalInMs, exceededErrorMessage) => {
6
+ const withRateLimiter = (wrappedFn, maxOps, intervalInMs, exceededErrorMessage) => {
7
7
  let start = Date.now();
8
8
  let numOps = 0;
9
9
  return (...args) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
@@ -20,3 +20,4 @@ exports.withRateLimiter = (wrappedFn, maxOps, intervalInMs, exceededErrorMessage
20
20
  return wrappedFn(...args);
21
21
  });
22
22
  };
23
+ exports.withRateLimiter = withRateLimiter;
package/out/view/close.js CHANGED
@@ -4,8 +4,8 @@ exports.close = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const bridge_1 = require("../bridge");
6
6
  const errors_1 = require("../errors");
7
- const callBridge = bridge_1.getCallBridge();
8
- exports.close = (payload) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
7
+ const callBridge = (0, bridge_1.getCallBridge)();
8
+ const close = (payload) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
9
9
  try {
10
10
  const success = yield callBridge('close', payload);
11
11
  if (success === false) {
@@ -16,3 +16,4 @@ exports.close = (payload) => tslib_1.__awaiter(void 0, void 0, void 0, function*
16
16
  throw new errors_1.BridgeAPIError("this resource's view is not closable.");
17
17
  }
18
18
  });
19
+ exports.close = close;
@@ -1 +1 @@
1
- {"version":3,"file":"createHistory.d.ts","sourceRoot":"","sources":["../../src/view/createHistory.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAIvC,eAAO,MAAM,aAAa,QAAa,OAAO,CAAC,OAAO,CAOrD,CAAC"}
1
+ {"version":3,"file":"createHistory.d.ts","sourceRoot":"","sources":["../../src/view/createHistory.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAIvC,eAAO,MAAM,aAAa,QAAa,QAAQ,OAAO,CAOrD,CAAC"}
@@ -3,11 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createHistory = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const bridge_1 = require("../bridge");
6
- const callBridge = bridge_1.getCallBridge();
7
- exports.createHistory = () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
6
+ const callBridge = (0, bridge_1.getCallBridge)();
7
+ const createHistory = () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
8
8
  const history = yield callBridge('createHistory');
9
9
  history.listen((location) => {
10
10
  history.location = location;
11
11
  });
12
12
  return history;
13
13
  });
14
+ exports.createHistory = createHistory;
@@ -1 +1 @@
1
- {"version":3,"file":"getContext.d.ts","sourceRoot":"","sources":["../../src/view/getContext.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAIvC,eAAO,MAAM,UAAU,QAAO,OAAO,CAAC,WAAW,CAEhD,CAAC"}
1
+ {"version":3,"file":"getContext.d.ts","sourceRoot":"","sources":["../../src/view/getContext.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAIvC,eAAO,MAAM,UAAU,QAAO,QAAQ,WAAW,CAEhD,CAAC"}
@@ -2,7 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getContext = void 0;
4
4
  const bridge_1 = require("../bridge");
5
- const callBridge = bridge_1.getCallBridge();
6
- exports.getContext = () => {
5
+ const callBridge = (0, bridge_1.getCallBridge)();
6
+ const getContext = () => {
7
7
  return callBridge('getContext');
8
8
  };
9
+ exports.getContext = getContext;
@@ -4,10 +4,11 @@ exports.refresh = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const bridge_1 = require("../bridge");
6
6
  const errors_1 = require("../errors");
7
- const callBridge = bridge_1.getCallBridge();
8
- exports.refresh = (payload) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
7
+ const callBridge = (0, bridge_1.getCallBridge)();
8
+ const refresh = (payload) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
9
9
  const success = yield callBridge('refresh', payload);
10
10
  if (success === false) {
11
11
  throw new errors_1.BridgeAPIError("this resource's view is not refreshable.");
12
12
  }
13
13
  });
14
+ exports.refresh = refresh;
@@ -4,10 +4,11 @@ exports.submit = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const bridge_1 = require("../bridge");
6
6
  const errors_1 = require("../errors");
7
- const callBridge = bridge_1.getCallBridge();
8
- exports.submit = (payload) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
7
+ const callBridge = (0, bridge_1.getCallBridge)();
8
+ const submit = (payload) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
9
9
  const success = yield callBridge('submit', payload);
10
10
  if (success === false) {
11
11
  throw new errors_1.BridgeAPIError("this resource's view is not submittable.");
12
12
  }
13
13
  });
14
+ exports.submit = submit;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forge/bridge",
3
- "version": "2.4.0",
3
+ "version": "2.5.0-next.0",
4
4
  "description": "Forge bridge API for custom UI apps",
5
5
  "author": "Atlassian",
6
6
  "license": "UNLICENSED",