@atlaskit/link-client-extension 1.5.4 → 1.6.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 +7 -0
- package/dist/cjs/index.js +7 -1
- package/dist/cjs/services/use-data-source-client-extension/index.js +90 -7
- package/dist/cjs/services/use-data-source-client-extension/mocks.js +4 -4
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/index.js +1 -1
- package/dist/es2019/services/use-data-source-client-extension/index.js +27 -2
- package/dist/es2019/services/use-data-source-client-extension/mocks.js +2 -2
- package/dist/es2019/version.json +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/services/use-data-source-client-extension/index.js +86 -6
- package/dist/esm/services/use-data-source-client-extension/mocks.js +2 -2
- package/dist/esm/version.json +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/services/use-data-source-client-extension/index.d.ts +5 -2
- package/dist/types/services/use-data-source-client-extension/mocks.d.ts +1 -1
- package/dist/types-ts4.5/index.d.ts +1 -1
- package/dist/types-ts4.5/services/use-data-source-client-extension/index.d.ts +5 -2
- package/dist/types-ts4.5/services/use-data-source-client-extension/mocks.d.ts +1 -1
- package/package.json +4 -3
- package/report.api.md +5 -1
- package/tmp/api-report-tmp.d.ts +5 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @atlaskit/link-client-extension
|
|
2
2
|
|
|
3
|
+
## 1.6.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`5bc0af1de85`](https://bitbucket.org/atlassian/atlassian-frontend/commits/5bc0af1de85) - Introduce caching layer for both `getDatasourceDetails` and `getDatasourceData` calls. Export new member - `mockDatasourceDetailsResponse` that has same value as previously exported `mockDatasourceResponse`
|
|
8
|
+
- [`b3b6782c3a0`](https://bitbucket.org/atlassian/atlassian-frontend/commits/b3b6782c3a0) - Add new member `mockDatasourceDetailsResponse` that has same value as existing `mockDatasourceResponse`; Add third optional boolean argument to `getDatasourceDetails` and `getDatasourceData` from `useDatasourceClientExtension` hook called `force` — when it is false (Default) cached version of response promise will be returned (in case request with same parameters has been made), when true new request will be made regardless of cache state.
|
|
9
|
+
|
|
3
10
|
## 1.5.4
|
|
4
11
|
|
|
5
12
|
### Patch Changes
|
package/dist/cjs/index.js
CHANGED
|
@@ -15,10 +15,16 @@ Object.defineProperty(exports, "mockDatasourceDataResponseWithSchema", {
|
|
|
15
15
|
return _mocks.mockDatasourceDataResponseWithSchema;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
+
Object.defineProperty(exports, "mockDatasourceDetailsResponse", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function get() {
|
|
21
|
+
return _mocks.mockDatasourceDetailsResponse;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
18
24
|
Object.defineProperty(exports, "mockDatasourceResponse", {
|
|
19
25
|
enumerable: true,
|
|
20
26
|
get: function get() {
|
|
21
|
-
return _mocks.
|
|
27
|
+
return _mocks.mockDatasourceDetailsResponse;
|
|
22
28
|
}
|
|
23
29
|
});
|
|
24
30
|
Object.defineProperty(exports, "useDatasourceClientExtension", {
|
|
@@ -1,23 +1,106 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
|
-
exports.useDatasourceClientExtension = void 0;
|
|
7
|
+
exports.useDatasourceClientExtension = exports.datasourceDetailsResponsePromiseCache = exports.datasourceDataResponsePromiseCache = void 0;
|
|
8
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
7
10
|
var _react = require("react");
|
|
11
|
+
var _lru_map = require("lru_map");
|
|
8
12
|
var _linkProvider = require("@atlaskit/link-provider");
|
|
9
13
|
var _linkingCommon = require("@atlaskit/linking-common");
|
|
10
14
|
var _useResolverUrl = require("../use-resolver-url");
|
|
15
|
+
var URL_RESPONSE_CACHE_SIZE = 50;
|
|
16
|
+
var datasourceDetailsResponsePromiseCache = new _lru_map.LRUMap(URL_RESPONSE_CACHE_SIZE);
|
|
17
|
+
exports.datasourceDetailsResponsePromiseCache = datasourceDetailsResponsePromiseCache;
|
|
18
|
+
var datasourceDataResponsePromiseCache = new _lru_map.LRUMap(URL_RESPONSE_CACHE_SIZE);
|
|
19
|
+
exports.datasourceDataResponsePromiseCache = datasourceDataResponsePromiseCache;
|
|
11
20
|
var useDatasourceClientExtension = function useDatasourceClientExtension() {
|
|
12
21
|
var _useSmartLinkContext = (0, _linkProvider.useSmartLinkContext)(),
|
|
13
22
|
client = _useSmartLinkContext.connections.client;
|
|
14
23
|
var resolverUrl = (0, _useResolverUrl.useResolverUrl)(client);
|
|
15
|
-
var
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
24
|
+
var cachedRequest = /*#__PURE__*/function () {
|
|
25
|
+
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(datasourceId, data, url, lruMap, force) {
|
|
26
|
+
var cacheKey, responsePromise;
|
|
27
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
28
|
+
while (1) switch (_context.prev = _context.next) {
|
|
29
|
+
case 0:
|
|
30
|
+
cacheKey = JSON.stringify({
|
|
31
|
+
datasourceId: datasourceId,
|
|
32
|
+
data: data
|
|
33
|
+
});
|
|
34
|
+
if (force) {
|
|
35
|
+
lruMap.delete(cacheKey);
|
|
36
|
+
}
|
|
37
|
+
responsePromise = lruMap.get(cacheKey);
|
|
38
|
+
if (!responsePromise) {
|
|
39
|
+
_context.next = 5;
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
return _context.abrupt("return", responsePromise);
|
|
43
|
+
case 5:
|
|
44
|
+
_context.prev = 5;
|
|
45
|
+
responsePromise = (0, _linkingCommon.request)('post', url, data, undefined, [200, 201, 202, 203, 204]);
|
|
46
|
+
lruMap.set(cacheKey, responsePromise);
|
|
47
|
+
_context.next = 10;
|
|
48
|
+
return responsePromise;
|
|
49
|
+
case 10:
|
|
50
|
+
return _context.abrupt("return", _context.sent);
|
|
51
|
+
case 13:
|
|
52
|
+
_context.prev = 13;
|
|
53
|
+
_context.t0 = _context["catch"](5);
|
|
54
|
+
lruMap.delete(cacheKey);
|
|
55
|
+
throw _context.t0;
|
|
56
|
+
case 17:
|
|
57
|
+
case "end":
|
|
58
|
+
return _context.stop();
|
|
59
|
+
}
|
|
60
|
+
}, _callee, null, [[5, 13]]);
|
|
61
|
+
}));
|
|
62
|
+
return function cachedRequest(_x, _x2, _x3, _x4, _x5) {
|
|
63
|
+
return _ref.apply(this, arguments);
|
|
64
|
+
};
|
|
65
|
+
}();
|
|
66
|
+
var getDatasourceDetails = (0, _react.useCallback)( /*#__PURE__*/function () {
|
|
67
|
+
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(datasourceId, data) {
|
|
68
|
+
var force,
|
|
69
|
+
_args2 = arguments;
|
|
70
|
+
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
71
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
72
|
+
case 0:
|
|
73
|
+
force = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : false;
|
|
74
|
+
return _context2.abrupt("return", cachedRequest(datasourceId, data, "".concat(resolverUrl, "/datasource/").concat(datasourceId, "/fetch/details"), datasourceDetailsResponsePromiseCache, force));
|
|
75
|
+
case 2:
|
|
76
|
+
case "end":
|
|
77
|
+
return _context2.stop();
|
|
78
|
+
}
|
|
79
|
+
}, _callee2);
|
|
80
|
+
}));
|
|
81
|
+
return function (_x6, _x7) {
|
|
82
|
+
return _ref2.apply(this, arguments);
|
|
83
|
+
};
|
|
84
|
+
}(), [resolverUrl]);
|
|
85
|
+
var getDatasourceData = (0, _react.useCallback)( /*#__PURE__*/function () {
|
|
86
|
+
var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(datasourceId, data) {
|
|
87
|
+
var force,
|
|
88
|
+
_args3 = arguments;
|
|
89
|
+
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
90
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
91
|
+
case 0:
|
|
92
|
+
force = _args3.length > 2 && _args3[2] !== undefined ? _args3[2] : false;
|
|
93
|
+
return _context3.abrupt("return", cachedRequest(datasourceId, data, "".concat(resolverUrl, "/datasource/").concat(datasourceId, "/fetch/data"), datasourceDataResponsePromiseCache, force));
|
|
94
|
+
case 2:
|
|
95
|
+
case "end":
|
|
96
|
+
return _context3.stop();
|
|
97
|
+
}
|
|
98
|
+
}, _callee3);
|
|
99
|
+
}));
|
|
100
|
+
return function (_x8, _x9) {
|
|
101
|
+
return _ref3.apply(this, arguments);
|
|
102
|
+
};
|
|
103
|
+
}(), [resolverUrl]);
|
|
21
104
|
return (0, _react.useMemo)(function () {
|
|
22
105
|
return {
|
|
23
106
|
getDatasourceDetails: getDatasourceDetails,
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.
|
|
7
|
+
exports.mockDatasourceDetailsResponse = exports.mockDatasourceDataResponseWithSchema = exports.mockDatasourceDataResponse = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
10
10
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
@@ -113,7 +113,7 @@ var mockDatasourceDataResponse = {
|
|
|
113
113
|
}
|
|
114
114
|
};
|
|
115
115
|
exports.mockDatasourceDataResponse = mockDatasourceDataResponse;
|
|
116
|
-
var
|
|
116
|
+
var mockDatasourceDetailsResponse = {
|
|
117
117
|
meta: {
|
|
118
118
|
key: 'jira-object-provider',
|
|
119
119
|
access: 'granted',
|
|
@@ -183,11 +183,11 @@ var mockDatasourceResponse = {
|
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
185
|
};
|
|
186
|
-
exports.
|
|
186
|
+
exports.mockDatasourceDetailsResponse = mockDatasourceDetailsResponse;
|
|
187
187
|
var mockDatasourceDataResponseWithSchema = _objectSpread(_objectSpread({}, mockDatasourceDataResponse), {}, {
|
|
188
188
|
data: _objectSpread(_objectSpread({}, mockDatasourceDataResponse.data), {}, {
|
|
189
189
|
schema: {
|
|
190
|
-
properties:
|
|
190
|
+
properties: mockDatasourceDetailsResponse.data.schema.properties
|
|
191
191
|
}
|
|
192
192
|
})
|
|
193
193
|
});
|
package/dist/cjs/version.json
CHANGED
package/dist/es2019/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { useSmartLinkClientExtension } from './services/use-smart-link-client-extension';
|
|
2
2
|
export { useDatasourceClientExtension } from './services/use-data-source-client-extension';
|
|
3
|
-
export { mockDatasourceResponse, mockDatasourceDataResponse, mockDatasourceDataResponseWithSchema } from './services/use-data-source-client-extension/mocks';
|
|
3
|
+
export { mockDatasourceDetailsResponse as mockDatasourceResponse, mockDatasourceDetailsResponse, mockDatasourceDataResponse, mockDatasourceDataResponseWithSchema } from './services/use-data-source-client-extension/mocks';
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { useCallback, useMemo } from 'react';
|
|
2
|
+
import { LRUMap } from 'lru_map';
|
|
2
3
|
import { useSmartLinkContext } from '@atlaskit/link-provider';
|
|
3
4
|
import { request } from '@atlaskit/linking-common';
|
|
4
5
|
import { useResolverUrl } from '../use-resolver-url';
|
|
6
|
+
const URL_RESPONSE_CACHE_SIZE = 50;
|
|
7
|
+
export const datasourceDetailsResponsePromiseCache = new LRUMap(URL_RESPONSE_CACHE_SIZE);
|
|
8
|
+
export const datasourceDataResponsePromiseCache = new LRUMap(URL_RESPONSE_CACHE_SIZE);
|
|
5
9
|
export const useDatasourceClientExtension = () => {
|
|
6
10
|
const {
|
|
7
11
|
connections: {
|
|
@@ -9,8 +13,29 @@ export const useDatasourceClientExtension = () => {
|
|
|
9
13
|
}
|
|
10
14
|
} = useSmartLinkContext();
|
|
11
15
|
const resolverUrl = useResolverUrl(client);
|
|
12
|
-
const
|
|
13
|
-
|
|
16
|
+
const cachedRequest = async (datasourceId, data, url, lruMap, force) => {
|
|
17
|
+
const cacheKey = JSON.stringify({
|
|
18
|
+
datasourceId,
|
|
19
|
+
data
|
|
20
|
+
});
|
|
21
|
+
if (force) {
|
|
22
|
+
lruMap.delete(cacheKey);
|
|
23
|
+
}
|
|
24
|
+
let responsePromise = lruMap.get(cacheKey);
|
|
25
|
+
if (responsePromise) {
|
|
26
|
+
return responsePromise;
|
|
27
|
+
}
|
|
28
|
+
try {
|
|
29
|
+
responsePromise = request('post', url, data, undefined, [200, 201, 202, 203, 204]);
|
|
30
|
+
lruMap.set(cacheKey, responsePromise);
|
|
31
|
+
return await responsePromise;
|
|
32
|
+
} catch (e) {
|
|
33
|
+
lruMap.delete(cacheKey);
|
|
34
|
+
throw e;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
const getDatasourceDetails = useCallback(async (datasourceId, data, force = false) => cachedRequest(datasourceId, data, `${resolverUrl}/datasource/${datasourceId}/fetch/details`, datasourceDetailsResponsePromiseCache, force), [resolverUrl]);
|
|
38
|
+
const getDatasourceData = useCallback(async (datasourceId, data, force = false) => cachedRequest(datasourceId, data, `${resolverUrl}/datasource/${datasourceId}/fetch/data`, datasourceDataResponsePromiseCache, force), [resolverUrl]);
|
|
14
39
|
return useMemo(() => ({
|
|
15
40
|
getDatasourceDetails,
|
|
16
41
|
getDatasourceData
|
|
@@ -102,7 +102,7 @@ export const mockDatasourceDataResponse = {
|
|
|
102
102
|
nextPageCursor: 'c3RhcnRBdD01'
|
|
103
103
|
}
|
|
104
104
|
};
|
|
105
|
-
export const
|
|
105
|
+
export const mockDatasourceDetailsResponse = {
|
|
106
106
|
meta: {
|
|
107
107
|
key: 'jira-object-provider',
|
|
108
108
|
access: 'granted',
|
|
@@ -177,7 +177,7 @@ export const mockDatasourceDataResponseWithSchema = {
|
|
|
177
177
|
data: {
|
|
178
178
|
...mockDatasourceDataResponse.data,
|
|
179
179
|
schema: {
|
|
180
|
-
properties:
|
|
180
|
+
properties: mockDatasourceDetailsResponse.data.schema.properties
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
183
|
};
|
package/dist/es2019/version.json
CHANGED
package/dist/esm/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { useSmartLinkClientExtension } from './services/use-smart-link-client-extension';
|
|
2
2
|
export { useDatasourceClientExtension } from './services/use-data-source-client-extension';
|
|
3
|
-
export { mockDatasourceResponse, mockDatasourceDataResponse, mockDatasourceDataResponseWithSchema } from './services/use-data-source-client-extension/mocks';
|
|
3
|
+
export { mockDatasourceDetailsResponse as mockDatasourceResponse, mockDatasourceDetailsResponse, mockDatasourceDataResponse, mockDatasourceDataResponseWithSchema } from './services/use-data-source-client-extension/mocks';
|
|
@@ -1,17 +1,97 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
1
3
|
import { useCallback, useMemo } from 'react';
|
|
4
|
+
import { LRUMap } from 'lru_map';
|
|
2
5
|
import { useSmartLinkContext } from '@atlaskit/link-provider';
|
|
3
6
|
import { request } from '@atlaskit/linking-common';
|
|
4
7
|
import { useResolverUrl } from '../use-resolver-url';
|
|
8
|
+
var URL_RESPONSE_CACHE_SIZE = 50;
|
|
9
|
+
export var datasourceDetailsResponsePromiseCache = new LRUMap(URL_RESPONSE_CACHE_SIZE);
|
|
10
|
+
export var datasourceDataResponsePromiseCache = new LRUMap(URL_RESPONSE_CACHE_SIZE);
|
|
5
11
|
export var useDatasourceClientExtension = function useDatasourceClientExtension() {
|
|
6
12
|
var _useSmartLinkContext = useSmartLinkContext(),
|
|
7
13
|
client = _useSmartLinkContext.connections.client;
|
|
8
14
|
var resolverUrl = useResolverUrl(client);
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
var cachedRequest = /*#__PURE__*/function () {
|
|
16
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(datasourceId, data, url, lruMap, force) {
|
|
17
|
+
var cacheKey, responsePromise;
|
|
18
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
19
|
+
while (1) switch (_context.prev = _context.next) {
|
|
20
|
+
case 0:
|
|
21
|
+
cacheKey = JSON.stringify({
|
|
22
|
+
datasourceId: datasourceId,
|
|
23
|
+
data: data
|
|
24
|
+
});
|
|
25
|
+
if (force) {
|
|
26
|
+
lruMap.delete(cacheKey);
|
|
27
|
+
}
|
|
28
|
+
responsePromise = lruMap.get(cacheKey);
|
|
29
|
+
if (!responsePromise) {
|
|
30
|
+
_context.next = 5;
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
return _context.abrupt("return", responsePromise);
|
|
34
|
+
case 5:
|
|
35
|
+
_context.prev = 5;
|
|
36
|
+
responsePromise = request('post', url, data, undefined, [200, 201, 202, 203, 204]);
|
|
37
|
+
lruMap.set(cacheKey, responsePromise);
|
|
38
|
+
_context.next = 10;
|
|
39
|
+
return responsePromise;
|
|
40
|
+
case 10:
|
|
41
|
+
return _context.abrupt("return", _context.sent);
|
|
42
|
+
case 13:
|
|
43
|
+
_context.prev = 13;
|
|
44
|
+
_context.t0 = _context["catch"](5);
|
|
45
|
+
lruMap.delete(cacheKey);
|
|
46
|
+
throw _context.t0;
|
|
47
|
+
case 17:
|
|
48
|
+
case "end":
|
|
49
|
+
return _context.stop();
|
|
50
|
+
}
|
|
51
|
+
}, _callee, null, [[5, 13]]);
|
|
52
|
+
}));
|
|
53
|
+
return function cachedRequest(_x, _x2, _x3, _x4, _x5) {
|
|
54
|
+
return _ref.apply(this, arguments);
|
|
55
|
+
};
|
|
56
|
+
}();
|
|
57
|
+
var getDatasourceDetails = useCallback( /*#__PURE__*/function () {
|
|
58
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(datasourceId, data) {
|
|
59
|
+
var force,
|
|
60
|
+
_args2 = arguments;
|
|
61
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
62
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
63
|
+
case 0:
|
|
64
|
+
force = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : false;
|
|
65
|
+
return _context2.abrupt("return", cachedRequest(datasourceId, data, "".concat(resolverUrl, "/datasource/").concat(datasourceId, "/fetch/details"), datasourceDetailsResponsePromiseCache, force));
|
|
66
|
+
case 2:
|
|
67
|
+
case "end":
|
|
68
|
+
return _context2.stop();
|
|
69
|
+
}
|
|
70
|
+
}, _callee2);
|
|
71
|
+
}));
|
|
72
|
+
return function (_x6, _x7) {
|
|
73
|
+
return _ref2.apply(this, arguments);
|
|
74
|
+
};
|
|
75
|
+
}(), [resolverUrl]);
|
|
76
|
+
var getDatasourceData = useCallback( /*#__PURE__*/function () {
|
|
77
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(datasourceId, data) {
|
|
78
|
+
var force,
|
|
79
|
+
_args3 = arguments;
|
|
80
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
81
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
82
|
+
case 0:
|
|
83
|
+
force = _args3.length > 2 && _args3[2] !== undefined ? _args3[2] : false;
|
|
84
|
+
return _context3.abrupt("return", cachedRequest(datasourceId, data, "".concat(resolverUrl, "/datasource/").concat(datasourceId, "/fetch/data"), datasourceDataResponsePromiseCache, force));
|
|
85
|
+
case 2:
|
|
86
|
+
case "end":
|
|
87
|
+
return _context3.stop();
|
|
88
|
+
}
|
|
89
|
+
}, _callee3);
|
|
90
|
+
}));
|
|
91
|
+
return function (_x8, _x9) {
|
|
92
|
+
return _ref3.apply(this, arguments);
|
|
93
|
+
};
|
|
94
|
+
}(), [resolverUrl]);
|
|
15
95
|
return useMemo(function () {
|
|
16
96
|
return {
|
|
17
97
|
getDatasourceDetails: getDatasourceDetails,
|
|
@@ -105,7 +105,7 @@ export var mockDatasourceDataResponse = {
|
|
|
105
105
|
nextPageCursor: 'c3RhcnRBdD01'
|
|
106
106
|
}
|
|
107
107
|
};
|
|
108
|
-
export var
|
|
108
|
+
export var mockDatasourceDetailsResponse = {
|
|
109
109
|
meta: {
|
|
110
110
|
key: 'jira-object-provider',
|
|
111
111
|
access: 'granted',
|
|
@@ -178,7 +178,7 @@ export var mockDatasourceResponse = {
|
|
|
178
178
|
export var mockDatasourceDataResponseWithSchema = _objectSpread(_objectSpread({}, mockDatasourceDataResponse), {}, {
|
|
179
179
|
data: _objectSpread(_objectSpread({}, mockDatasourceDataResponse.data), {}, {
|
|
180
180
|
schema: {
|
|
181
|
-
properties:
|
|
181
|
+
properties: mockDatasourceDetailsResponse.data.schema.properties
|
|
182
182
|
}
|
|
183
183
|
})
|
|
184
184
|
});
|
package/dist/esm/version.json
CHANGED
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { useSmartLinkClientExtension } from './services/use-smart-link-client-extension';
|
|
2
2
|
export { useDatasourceClientExtension } from './services/use-data-source-client-extension';
|
|
3
|
-
export { mockDatasourceResponse, mockDatasourceDataResponse, mockDatasourceDataResponseWithSchema, } from './services/use-data-source-client-extension/mocks';
|
|
3
|
+
export { mockDatasourceDetailsResponse as mockDatasourceResponse, mockDatasourceDetailsResponse, mockDatasourceDataResponse, mockDatasourceDataResponseWithSchema, } from './services/use-data-source-client-extension/mocks';
|
|
4
4
|
export type { JsonLdDatasourceResponse, DatasourceResolveResponse, } from './types';
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import { LRUMap } from 'lru_map';
|
|
1
2
|
import type { DatasourceDataRequest, DatasourceDataResponse, DatasourceDetailsRequest, DatasourceDetailsResponse } from '@atlaskit/linking-types';
|
|
3
|
+
export declare const datasourceDetailsResponsePromiseCache: LRUMap<string, Promise<DatasourceDetailsResponse>>;
|
|
4
|
+
export declare const datasourceDataResponsePromiseCache: LRUMap<string, Promise<DatasourceDataResponse>>;
|
|
2
5
|
export declare const useDatasourceClientExtension: () => {
|
|
3
|
-
getDatasourceDetails: (datasourceId: string, data: DatasourceDetailsRequest) => Promise<DatasourceDetailsResponse>;
|
|
4
|
-
getDatasourceData: (datasourceId: string, data: DatasourceDataRequest) => Promise<DatasourceDataResponse>;
|
|
6
|
+
getDatasourceDetails: (datasourceId: string, data: DatasourceDetailsRequest, force?: any) => Promise<DatasourceDetailsResponse>;
|
|
7
|
+
getDatasourceData: (datasourceId: string, data: DatasourceDataRequest, force?: any) => Promise<DatasourceDataResponse>;
|
|
5
8
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { DatasourceDataResponse, DatasourceDetailsResponse } from '@atlaskit/linking-types';
|
|
2
2
|
export declare const mockDatasourceDataResponse: DatasourceDataResponse;
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const mockDatasourceDetailsResponse: DatasourceDetailsResponse;
|
|
4
4
|
export declare const mockDatasourceDataResponseWithSchema: DatasourceDataResponse;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { useSmartLinkClientExtension } from './services/use-smart-link-client-extension';
|
|
2
2
|
export { useDatasourceClientExtension } from './services/use-data-source-client-extension';
|
|
3
|
-
export { mockDatasourceResponse, mockDatasourceDataResponse, mockDatasourceDataResponseWithSchema, } from './services/use-data-source-client-extension/mocks';
|
|
3
|
+
export { mockDatasourceDetailsResponse as mockDatasourceResponse, mockDatasourceDetailsResponse, mockDatasourceDataResponse, mockDatasourceDataResponseWithSchema, } from './services/use-data-source-client-extension/mocks';
|
|
4
4
|
export type { JsonLdDatasourceResponse, DatasourceResolveResponse, } from './types';
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import { LRUMap } from 'lru_map';
|
|
1
2
|
import type { DatasourceDataRequest, DatasourceDataResponse, DatasourceDetailsRequest, DatasourceDetailsResponse } from '@atlaskit/linking-types';
|
|
3
|
+
export declare const datasourceDetailsResponsePromiseCache: LRUMap<string, Promise<DatasourceDetailsResponse>>;
|
|
4
|
+
export declare const datasourceDataResponsePromiseCache: LRUMap<string, Promise<DatasourceDataResponse>>;
|
|
2
5
|
export declare const useDatasourceClientExtension: () => {
|
|
3
|
-
getDatasourceDetails: (datasourceId: string, data: DatasourceDetailsRequest) => Promise<DatasourceDetailsResponse>;
|
|
4
|
-
getDatasourceData: (datasourceId: string, data: DatasourceDataRequest) => Promise<DatasourceDataResponse>;
|
|
6
|
+
getDatasourceDetails: (datasourceId: string, data: DatasourceDetailsRequest, force?: any) => Promise<DatasourceDetailsResponse>;
|
|
7
|
+
getDatasourceData: (datasourceId: string, data: DatasourceDataRequest, force?: any) => Promise<DatasourceDataResponse>;
|
|
5
8
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { DatasourceDataResponse, DatasourceDetailsResponse } from '@atlaskit/linking-types';
|
|
2
2
|
export declare const mockDatasourceDataResponse: DatasourceDataResponse;
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const mockDatasourceDetailsResponse: DatasourceDetailsResponse;
|
|
4
4
|
export declare const mockDatasourceDataResponseWithSchema: DatasourceDataResponse;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/link-client-extension",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "Extension methods for linking platform client",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -34,10 +34,11 @@
|
|
|
34
34
|
".": "./src/index.ts"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@atlaskit/linking-common": "^4.
|
|
37
|
+
"@atlaskit/linking-common": "^4.3.0",
|
|
38
38
|
"@atlaskit/linking-types": "^8.2.0",
|
|
39
39
|
"@babel/runtime": "^7.0.0",
|
|
40
|
-
"json-ld-types": "3.8.0"
|
|
40
|
+
"json-ld-types": "3.8.0",
|
|
41
|
+
"lru_map": "^0.4.1"
|
|
41
42
|
},
|
|
42
43
|
"peerDependencies": {
|
|
43
44
|
"@atlaskit/link-provider": "^1.6.4",
|
package/report.api.md
CHANGED
|
@@ -48,17 +48,21 @@ export const mockDatasourceDataResponse: DatasourceDataResponse;
|
|
|
48
48
|
export const mockDatasourceDataResponseWithSchema: DatasourceDataResponse;
|
|
49
49
|
|
|
50
50
|
// @public (undocumented)
|
|
51
|
-
|
|
51
|
+
const mockDatasourceDetailsResponse: DatasourceDetailsResponse;
|
|
52
|
+
export { mockDatasourceDetailsResponse };
|
|
53
|
+
export { mockDatasourceDetailsResponse as mockDatasourceResponse };
|
|
52
54
|
|
|
53
55
|
// @public (undocumented)
|
|
54
56
|
export const useDatasourceClientExtension: () => {
|
|
55
57
|
getDatasourceDetails: (
|
|
56
58
|
datasourceId: string,
|
|
57
59
|
data: DatasourceDetailsRequest,
|
|
60
|
+
force?: any,
|
|
58
61
|
) => Promise<DatasourceDetailsResponse>;
|
|
59
62
|
getDatasourceData: (
|
|
60
63
|
datasourceId: string,
|
|
61
64
|
data: DatasourceDataRequest,
|
|
65
|
+
force?: any,
|
|
62
66
|
) => Promise<DatasourceDataResponse>;
|
|
63
67
|
};
|
|
64
68
|
|
package/tmp/api-report-tmp.d.ts
CHANGED
|
@@ -37,12 +37,14 @@ export const mockDatasourceDataResponse: DatasourceDataResponse;
|
|
|
37
37
|
export const mockDatasourceDataResponseWithSchema: DatasourceDataResponse;
|
|
38
38
|
|
|
39
39
|
// @public (undocumented)
|
|
40
|
-
|
|
40
|
+
const mockDatasourceDetailsResponse: DatasourceDetailsResponse;
|
|
41
|
+
export { mockDatasourceDetailsResponse }
|
|
42
|
+
export { mockDatasourceDetailsResponse as mockDatasourceResponse }
|
|
41
43
|
|
|
42
44
|
// @public (undocumented)
|
|
43
45
|
export const useDatasourceClientExtension: () => {
|
|
44
|
-
getDatasourceDetails: (datasourceId: string, data: DatasourceDetailsRequest) => Promise<DatasourceDetailsResponse>;
|
|
45
|
-
getDatasourceData: (datasourceId: string, data: DatasourceDataRequest) => Promise<DatasourceDataResponse>;
|
|
46
|
+
getDatasourceDetails: (datasourceId: string, data: DatasourceDetailsRequest, force?: any) => Promise<DatasourceDetailsResponse>;
|
|
47
|
+
getDatasourceData: (datasourceId: string, data: DatasourceDataRequest, force?: any) => Promise<DatasourceDataResponse>;
|
|
46
48
|
};
|
|
47
49
|
|
|
48
50
|
// @public
|