@atlaskit/link-client-extension 2.2.0 → 2.3.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 +8 -0
- package/dist/cjs/services/use-data-source-client-extension/index.js +32 -2
- package/dist/es2019/services/use-data-source-client-extension/index.js +15 -2
- package/dist/esm/services/use-data-source-client-extension/index.js +32 -2
- package/dist/types/services/use-data-source-client-extension/index.d.ts +1 -0
- package/dist/types-ts4.5/services/use-data-source-client-extension/index.d.ts +1 -0
- package/package.json +2 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/link-client-extension
|
|
2
2
|
|
|
3
|
+
## 2.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#134332](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/134332)
|
|
8
|
+
[`ba2a672c564ec`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/ba2a672c564ec) -
|
|
9
|
+
Expose new method removeDataCacheWithAri to clear cache conditionally
|
|
10
|
+
|
|
3
11
|
## 2.2.0
|
|
4
12
|
|
|
5
13
|
### Minor Changes
|
|
@@ -180,12 +180,42 @@ var useDatasourceClientExtension = exports.useDatasourceClientExtension = functi
|
|
|
180
180
|
return _ref6.apply(this, arguments);
|
|
181
181
|
};
|
|
182
182
|
}(), [resolverUrl]);
|
|
183
|
+
var invalidateDatasourceDataCacheByAri = (0, _react.useCallback)(function (ari) {
|
|
184
|
+
datasourceDataResponsePromiseCache.forEach( /*#__PURE__*/function () {
|
|
185
|
+
var _ref7 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(value, key) {
|
|
186
|
+
var response, targetFound;
|
|
187
|
+
return _regenerator.default.wrap(function _callee7$(_context7) {
|
|
188
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
189
|
+
case 0:
|
|
190
|
+
_context7.next = 2;
|
|
191
|
+
return value;
|
|
192
|
+
case 2:
|
|
193
|
+
response = _context7.sent;
|
|
194
|
+
targetFound = response.data.items.some(function (item) {
|
|
195
|
+
var _item$ari;
|
|
196
|
+
return ((_item$ari = item['ari']) === null || _item$ari === void 0 ? void 0 : _item$ari.data) === ari;
|
|
197
|
+
});
|
|
198
|
+
if (targetFound) {
|
|
199
|
+
datasourceDataResponsePromiseCache.delete(key);
|
|
200
|
+
}
|
|
201
|
+
case 5:
|
|
202
|
+
case "end":
|
|
203
|
+
return _context7.stop();
|
|
204
|
+
}
|
|
205
|
+
}, _callee7);
|
|
206
|
+
}));
|
|
207
|
+
return function (_x14, _x15) {
|
|
208
|
+
return _ref7.apply(this, arguments);
|
|
209
|
+
};
|
|
210
|
+
}());
|
|
211
|
+
}, []);
|
|
183
212
|
return (0, _react.useMemo)(function () {
|
|
184
213
|
return {
|
|
185
214
|
getDatasourceDetails: getDatasourceDetails,
|
|
186
215
|
getDatasourceData: getDatasourceData,
|
|
187
216
|
getDatasourceActionsAndPermissions: getDatasourceActionsAndPermissions,
|
|
188
|
-
executeAtomicAction: executeAtomicAction
|
|
217
|
+
executeAtomicAction: executeAtomicAction,
|
|
218
|
+
invalidateDatasourceDataCacheByAri: invalidateDatasourceDataCacheByAri
|
|
189
219
|
};
|
|
190
|
-
}, [getDatasourceDetails, getDatasourceData, getDatasourceActionsAndPermissions, executeAtomicAction]);
|
|
220
|
+
}, [getDatasourceDetails, getDatasourceData, getDatasourceActionsAndPermissions, executeAtomicAction, invalidateDatasourceDataCacheByAri]);
|
|
191
221
|
};
|
|
@@ -70,10 +70,23 @@ export const useDatasourceClientExtension = () => {
|
|
|
70
70
|
return cachedRequest(resolvedCacheIdKey, data, `${resolverUrl}/actions`, datasourceActionsPermissionsPromiseCache, force);
|
|
71
71
|
}, [resolverUrl]);
|
|
72
72
|
const executeAtomicAction = useCallback(async data => uncachedRequest(data, `${resolverUrl}/actions/execute`), [resolverUrl]);
|
|
73
|
+
const invalidateDatasourceDataCacheByAri = useCallback(ari => {
|
|
74
|
+
datasourceDataResponsePromiseCache.forEach(async (value, key) => {
|
|
75
|
+
const response = await value;
|
|
76
|
+
const targetFound = response.data.items.some(item => {
|
|
77
|
+
var _item$ari;
|
|
78
|
+
return ((_item$ari = item['ari']) === null || _item$ari === void 0 ? void 0 : _item$ari.data) === ari;
|
|
79
|
+
});
|
|
80
|
+
if (targetFound) {
|
|
81
|
+
datasourceDataResponsePromiseCache.delete(key);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}, []);
|
|
73
85
|
return useMemo(() => ({
|
|
74
86
|
getDatasourceDetails,
|
|
75
87
|
getDatasourceData,
|
|
76
88
|
getDatasourceActionsAndPermissions,
|
|
77
|
-
executeAtomicAction
|
|
78
|
-
|
|
89
|
+
executeAtomicAction,
|
|
90
|
+
invalidateDatasourceDataCacheByAri
|
|
91
|
+
}), [getDatasourceDetails, getDatasourceData, getDatasourceActionsAndPermissions, executeAtomicAction, invalidateDatasourceDataCacheByAri]);
|
|
79
92
|
};
|
|
@@ -173,12 +173,42 @@ export var useDatasourceClientExtension = function useDatasourceClientExtension(
|
|
|
173
173
|
return _ref6.apply(this, arguments);
|
|
174
174
|
};
|
|
175
175
|
}(), [resolverUrl]);
|
|
176
|
+
var invalidateDatasourceDataCacheByAri = useCallback(function (ari) {
|
|
177
|
+
datasourceDataResponsePromiseCache.forEach( /*#__PURE__*/function () {
|
|
178
|
+
var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(value, key) {
|
|
179
|
+
var response, targetFound;
|
|
180
|
+
return _regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
181
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
182
|
+
case 0:
|
|
183
|
+
_context7.next = 2;
|
|
184
|
+
return value;
|
|
185
|
+
case 2:
|
|
186
|
+
response = _context7.sent;
|
|
187
|
+
targetFound = response.data.items.some(function (item) {
|
|
188
|
+
var _item$ari;
|
|
189
|
+
return ((_item$ari = item['ari']) === null || _item$ari === void 0 ? void 0 : _item$ari.data) === ari;
|
|
190
|
+
});
|
|
191
|
+
if (targetFound) {
|
|
192
|
+
datasourceDataResponsePromiseCache.delete(key);
|
|
193
|
+
}
|
|
194
|
+
case 5:
|
|
195
|
+
case "end":
|
|
196
|
+
return _context7.stop();
|
|
197
|
+
}
|
|
198
|
+
}, _callee7);
|
|
199
|
+
}));
|
|
200
|
+
return function (_x14, _x15) {
|
|
201
|
+
return _ref7.apply(this, arguments);
|
|
202
|
+
};
|
|
203
|
+
}());
|
|
204
|
+
}, []);
|
|
176
205
|
return useMemo(function () {
|
|
177
206
|
return {
|
|
178
207
|
getDatasourceDetails: getDatasourceDetails,
|
|
179
208
|
getDatasourceData: getDatasourceData,
|
|
180
209
|
getDatasourceActionsAndPermissions: getDatasourceActionsAndPermissions,
|
|
181
|
-
executeAtomicAction: executeAtomicAction
|
|
210
|
+
executeAtomicAction: executeAtomicAction,
|
|
211
|
+
invalidateDatasourceDataCacheByAri: invalidateDatasourceDataCacheByAri
|
|
182
212
|
};
|
|
183
|
-
}, [getDatasourceDetails, getDatasourceData, getDatasourceActionsAndPermissions, executeAtomicAction]);
|
|
213
|
+
}, [getDatasourceDetails, getDatasourceData, getDatasourceActionsAndPermissions, executeAtomicAction, invalidateDatasourceDataCacheByAri]);
|
|
184
214
|
};
|
|
@@ -9,4 +9,5 @@ export declare const useDatasourceClientExtension: () => {
|
|
|
9
9
|
getDatasourceData: (datasourceId: string, data: DatasourceDataRequest, force?: boolean) => Promise<DatasourceDataResponse>;
|
|
10
10
|
getDatasourceActionsAndPermissions: (data: ActionsDiscoveryRequest, force?: boolean) => Promise<ActionsDiscoveryResponse>;
|
|
11
11
|
executeAtomicAction: (data: AtomicActionExecuteRequest) => Promise<AtomicActionExecuteResponse>;
|
|
12
|
+
invalidateDatasourceDataCacheByAri: (ari: string) => void;
|
|
12
13
|
};
|
|
@@ -9,4 +9,5 @@ export declare const useDatasourceClientExtension: () => {
|
|
|
9
9
|
getDatasourceData: (datasourceId: string, data: DatasourceDataRequest, force?: boolean) => Promise<DatasourceDataResponse>;
|
|
10
10
|
getDatasourceActionsAndPermissions: (data: ActionsDiscoveryRequest, force?: boolean) => Promise<ActionsDiscoveryResponse>;
|
|
11
11
|
executeAtomicAction: (data: AtomicActionExecuteRequest) => Promise<AtomicActionExecuteResponse>;
|
|
12
|
+
invalidateDatasourceDataCacheByAri: (ari: string) => void;
|
|
12
13
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/link-client-extension",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "Extension methods for linking platform client",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -9,8 +9,6 @@
|
|
|
9
9
|
},
|
|
10
10
|
"atlassian": {
|
|
11
11
|
"team": "Linking Platform",
|
|
12
|
-
"inPublicMirror": false,
|
|
13
|
-
"releaseModel": "continuous",
|
|
14
12
|
"website": {
|
|
15
13
|
"name": "LinkClientExtension"
|
|
16
14
|
},
|
|
@@ -47,6 +45,7 @@
|
|
|
47
45
|
"react": "^16.8.0 || ^17.0.0 || ^18.0.0"
|
|
48
46
|
},
|
|
49
47
|
"devDependencies": {
|
|
48
|
+
"@atlaskit/link-test-helpers": "^7.5.0",
|
|
50
49
|
"@atlassian/feature-flags-test-utils": "0.2.3",
|
|
51
50
|
"@testing-library/react": "^12.1.5",
|
|
52
51
|
"@testing-library/react-hooks": "^8.0.1",
|