@atlaskit/link-client-extension 1.5.4 → 1.6.1
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 +13 -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 +12 -8
- 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 +8 -4
- 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 +10 -6
- 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/dist/cjs/version.json +0 -5
- package/dist/es2019/version.json +0 -5
- package/dist/esm/version.json +0 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @atlaskit/link-client-extension
|
|
2
2
|
|
|
3
|
+
## 1.6.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`a21cffb7b23`](https://bitbucket.org/atlassian/atlassian-frontend/commits/a21cffb7b23) - Extended mock response returned for datasources
|
|
8
|
+
|
|
9
|
+
## 1.6.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [`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`
|
|
14
|
+
- [`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.
|
|
15
|
+
|
|
3
16
|
## 1.5.4
|
|
4
17
|
|
|
5
18
|
### 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,10 +4,10 @@ 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
|
-
function ownKeys(
|
|
10
|
-
function _objectSpread(
|
|
9
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
10
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
11
11
|
var mockDatasourceDataResponse = {
|
|
12
12
|
meta: {
|
|
13
13
|
key: 'jira-object-provider',
|
|
@@ -15,7 +15,9 @@ var mockDatasourceDataResponse = {
|
|
|
15
15
|
auth: [],
|
|
16
16
|
definitionId: 'object-resolver-service',
|
|
17
17
|
product: 'jira',
|
|
18
|
-
visibility: 'restricted'
|
|
18
|
+
visibility: 'restricted',
|
|
19
|
+
extensionKey: 'jira-object-provider',
|
|
20
|
+
destinationObjectTypes: ['issue']
|
|
19
21
|
},
|
|
20
22
|
data: {
|
|
21
23
|
totalCount: 1234,
|
|
@@ -113,14 +115,16 @@ var mockDatasourceDataResponse = {
|
|
|
113
115
|
}
|
|
114
116
|
};
|
|
115
117
|
exports.mockDatasourceDataResponse = mockDatasourceDataResponse;
|
|
116
|
-
var
|
|
118
|
+
var mockDatasourceDetailsResponse = {
|
|
117
119
|
meta: {
|
|
118
120
|
key: 'jira-object-provider',
|
|
119
121
|
access: 'granted',
|
|
120
122
|
auth: [],
|
|
121
123
|
definitionId: 'object-resolver-service',
|
|
122
124
|
product: 'jira',
|
|
123
|
-
visibility: 'restricted'
|
|
125
|
+
visibility: 'restricted',
|
|
126
|
+
extensionKey: 'jira-object-provider',
|
|
127
|
+
destinationObjectTypes: ['issue']
|
|
124
128
|
},
|
|
125
129
|
data: {
|
|
126
130
|
ari: 'ari:cloud:linking-platform:datasource/12e74246-a3f1-46c1-9fd9-8d952aa9f12f',
|
|
@@ -183,11 +187,11 @@ var mockDatasourceResponse = {
|
|
|
183
187
|
}
|
|
184
188
|
}
|
|
185
189
|
};
|
|
186
|
-
exports.
|
|
190
|
+
exports.mockDatasourceDetailsResponse = mockDatasourceDetailsResponse;
|
|
187
191
|
var mockDatasourceDataResponseWithSchema = _objectSpread(_objectSpread({}, mockDatasourceDataResponse), {}, {
|
|
188
192
|
data: _objectSpread(_objectSpread({}, mockDatasourceDataResponse.data), {}, {
|
|
189
193
|
schema: {
|
|
190
|
-
properties:
|
|
194
|
+
properties: mockDatasourceDetailsResponse.data.schema.properties
|
|
191
195
|
}
|
|
192
196
|
})
|
|
193
197
|
});
|
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
|
|
@@ -5,7 +5,9 @@ export const mockDatasourceDataResponse = {
|
|
|
5
5
|
auth: [],
|
|
6
6
|
definitionId: 'object-resolver-service',
|
|
7
7
|
product: 'jira',
|
|
8
|
-
visibility: 'restricted'
|
|
8
|
+
visibility: 'restricted',
|
|
9
|
+
extensionKey: 'jira-object-provider',
|
|
10
|
+
destinationObjectTypes: ['issue']
|
|
9
11
|
},
|
|
10
12
|
data: {
|
|
11
13
|
totalCount: 1234,
|
|
@@ -102,14 +104,16 @@ export const mockDatasourceDataResponse = {
|
|
|
102
104
|
nextPageCursor: 'c3RhcnRBdD01'
|
|
103
105
|
}
|
|
104
106
|
};
|
|
105
|
-
export const
|
|
107
|
+
export const mockDatasourceDetailsResponse = {
|
|
106
108
|
meta: {
|
|
107
109
|
key: 'jira-object-provider',
|
|
108
110
|
access: 'granted',
|
|
109
111
|
auth: [],
|
|
110
112
|
definitionId: 'object-resolver-service',
|
|
111
113
|
product: 'jira',
|
|
112
|
-
visibility: 'restricted'
|
|
114
|
+
visibility: 'restricted',
|
|
115
|
+
extensionKey: 'jira-object-provider',
|
|
116
|
+
destinationObjectTypes: ['issue']
|
|
113
117
|
},
|
|
114
118
|
data: {
|
|
115
119
|
ari: 'ari:cloud:linking-platform:datasource/12e74246-a3f1-46c1-9fd9-8d952aa9f12f',
|
|
@@ -177,7 +181,7 @@ export const mockDatasourceDataResponseWithSchema = {
|
|
|
177
181
|
data: {
|
|
178
182
|
...mockDatasourceDataResponse.data,
|
|
179
183
|
schema: {
|
|
180
|
-
properties:
|
|
184
|
+
properties: mockDatasourceDetailsResponse.data.schema.properties
|
|
181
185
|
}
|
|
182
186
|
}
|
|
183
187
|
};
|
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,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
function ownKeys(
|
|
3
|
-
function _objectSpread(
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
4
|
export var mockDatasourceDataResponse = {
|
|
5
5
|
meta: {
|
|
6
6
|
key: 'jira-object-provider',
|
|
@@ -8,7 +8,9 @@ export var mockDatasourceDataResponse = {
|
|
|
8
8
|
auth: [],
|
|
9
9
|
definitionId: 'object-resolver-service',
|
|
10
10
|
product: 'jira',
|
|
11
|
-
visibility: 'restricted'
|
|
11
|
+
visibility: 'restricted',
|
|
12
|
+
extensionKey: 'jira-object-provider',
|
|
13
|
+
destinationObjectTypes: ['issue']
|
|
12
14
|
},
|
|
13
15
|
data: {
|
|
14
16
|
totalCount: 1234,
|
|
@@ -105,14 +107,16 @@ export var mockDatasourceDataResponse = {
|
|
|
105
107
|
nextPageCursor: 'c3RhcnRBdD01'
|
|
106
108
|
}
|
|
107
109
|
};
|
|
108
|
-
export var
|
|
110
|
+
export var mockDatasourceDetailsResponse = {
|
|
109
111
|
meta: {
|
|
110
112
|
key: 'jira-object-provider',
|
|
111
113
|
access: 'granted',
|
|
112
114
|
auth: [],
|
|
113
115
|
definitionId: 'object-resolver-service',
|
|
114
116
|
product: 'jira',
|
|
115
|
-
visibility: 'restricted'
|
|
117
|
+
visibility: 'restricted',
|
|
118
|
+
extensionKey: 'jira-object-provider',
|
|
119
|
+
destinationObjectTypes: ['issue']
|
|
116
120
|
},
|
|
117
121
|
data: {
|
|
118
122
|
ari: 'ari:cloud:linking-platform:datasource/12e74246-a3f1-46c1-9fd9-8d952aa9f12f',
|
|
@@ -178,7 +182,7 @@ export var mockDatasourceResponse = {
|
|
|
178
182
|
export var mockDatasourceDataResponseWithSchema = _objectSpread(_objectSpread({}, mockDatasourceDataResponse), {}, {
|
|
179
183
|
data: _objectSpread(_objectSpread({}, mockDatasourceDataResponse.data), {}, {
|
|
180
184
|
schema: {
|
|
181
|
-
properties:
|
|
185
|
+
properties: mockDatasourceDetailsResponse.data.schema.properties
|
|
182
186
|
}
|
|
183
187
|
})
|
|
184
188
|
});
|
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.1",
|
|
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.6.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
|
package/dist/cjs/version.json
DELETED
package/dist/es2019/version.json
DELETED