@atlaskit/smart-hooks 1.0.1 → 1.2.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 +14 -0
- package/dist/cjs/entry-points/transform-recommendations-to-options.js +13 -0
- package/dist/cjs/entry-points/use-user-recommendations.js +13 -0
- package/dist/cjs/services/use-user-recommendations/analytics.js +1 -1
- package/dist/cjs/services/use-user-recommendations/index.js +16 -16
- package/dist/es2019/entry-points/transform-recommendations-to-options.js +1 -0
- package/dist/es2019/entry-points/use-user-recommendations.js +1 -0
- package/dist/es2019/services/use-user-recommendations/analytics.js +1 -1
- package/dist/esm/entry-points/transform-recommendations-to-options.js +1 -0
- package/dist/esm/entry-points/use-user-recommendations.js +1 -0
- package/dist/esm/services/use-user-recommendations/analytics.js +1 -1
- package/dist/esm/services/use-user-recommendations/index.js +16 -16
- package/dist/types/entry-points/transform-recommendations-to-options.d.ts +1 -0
- package/dist/types/entry-points/use-user-recommendations.d.ts +1 -0
- package/dist/types-ts4.5/entry-points/transform-recommendations-to-options.d.ts +1 -0
- package/dist/types-ts4.5/entry-points/use-user-recommendations.d.ts +1 -0
- package/package.json +4 -3
- package/transform-recommendations-to-options/package.json +15 -0
- package/use-user-recommendations/package.json +15 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/smart-hooks
|
|
2
2
|
|
|
3
|
+
## 1.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`fbb51c73ed426`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/fbb51c73ed426) -
|
|
8
|
+
Update i18n NPM package versions for linking-platform,smart-experiences (Group 15)
|
|
9
|
+
|
|
10
|
+
## 1.1.0
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- [`3f23aba4db7f2`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/3f23aba4db7f2) -
|
|
15
|
+
Autofix: add explicit package exports (barrel removal)
|
|
16
|
+
|
|
3
17
|
## 1.0.1
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
Object.defineProperty(exports, "transformRecommendationsToOptions", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function get() {
|
|
10
|
+
return _index.default;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
var _index = _interopRequireDefault(require("../utils/transform-recommendations-to-options/index"));
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
Object.defineProperty(exports, "useUserRecommendations", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function get() {
|
|
10
|
+
return _index.default;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
var _index = _interopRequireDefault(require("../services/use-user-recommendations/index"));
|
|
@@ -21,7 +21,7 @@ var createEvent = function createEvent(eventType, action, actionSubject) {
|
|
|
21
21
|
source: '@atlaskit/smart-hooks/use-user-recommendations',
|
|
22
22
|
attributes: _objectSpread({
|
|
23
23
|
packageName: "@atlaskit/smart-hooks",
|
|
24
|
-
packageVersion: "
|
|
24
|
+
packageVersion: "1.1.0"
|
|
25
25
|
}, attributes)
|
|
26
26
|
};
|
|
27
27
|
};
|
|
@@ -91,8 +91,8 @@ var useUserRecommendations = function useUserRecommendations(props) {
|
|
|
91
91
|
}, [childObjectId, containerId, fieldId, includeTeams, maxNumberOfResults, objectId, preload, principalId, productKey, renderId, tenantId]);
|
|
92
92
|
var fetchRecommendations = (0, _react.useCallback)( /*#__PURE__*/function () {
|
|
93
93
|
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(query) {
|
|
94
|
-
var _lastAbortController$, currentController, recommendedUsersResult;
|
|
95
|
-
return _regenerator.default.wrap(function
|
|
94
|
+
var _lastAbortController$, currentController, recommendedUsersResult, _t;
|
|
95
|
+
return _regenerator.default.wrap(function (_context) {
|
|
96
96
|
while (1) switch (_context.prev = _context.next) {
|
|
97
97
|
case 0:
|
|
98
98
|
setIsLoading(true);
|
|
@@ -100,7 +100,7 @@ var useUserRecommendations = function useUserRecommendations(props) {
|
|
|
100
100
|
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
101
101
|
sessionId.current = (0, _uuid.v4)();
|
|
102
102
|
_ufoExperiences.UsersFetchedUfoExperience.getInstance(fieldId).start();
|
|
103
|
-
_context.prev =
|
|
103
|
+
_context.prev = 1;
|
|
104
104
|
if (lastAbortController.current) {
|
|
105
105
|
(_lastAbortController$ = lastAbortController.current) === null || _lastAbortController$ === void 0 || _lastAbortController$.abort();
|
|
106
106
|
}
|
|
@@ -108,7 +108,7 @@ var useUserRecommendations = function useUserRecommendations(props) {
|
|
|
108
108
|
// IE has no timeout applied on fetch since AbortController isn't available
|
|
109
109
|
currentController = typeof AbortController !== 'undefined' ? new AbortController() : null;
|
|
110
110
|
lastAbortController.current = currentController;
|
|
111
|
-
_context.next =
|
|
111
|
+
_context.next = 2;
|
|
112
112
|
return (0, _smartCommon.fetchUserRecommendations)({
|
|
113
113
|
baseUrl: baseUrl,
|
|
114
114
|
context: {
|
|
@@ -129,7 +129,7 @@ var useUserRecommendations = function useUserRecommendations(props) {
|
|
|
129
129
|
searchQuery: cpusSearchQuery,
|
|
130
130
|
query: query
|
|
131
131
|
}, currentController === null || currentController === void 0 ? void 0 : currentController.signal);
|
|
132
|
-
case
|
|
132
|
+
case 2:
|
|
133
133
|
recommendedUsersResult = _context.sent;
|
|
134
134
|
currentQuery.current = query !== null && query !== void 0 ? query : '';
|
|
135
135
|
_ufoExperiences.UsersFetchedUfoExperience.getInstance(fieldId).success({
|
|
@@ -138,33 +138,33 @@ var useUserRecommendations = function useUserRecommendations(props) {
|
|
|
138
138
|
})
|
|
139
139
|
});
|
|
140
140
|
setRecommendations(recommendedUsersResult);
|
|
141
|
-
_context.next =
|
|
141
|
+
_context.next = 5;
|
|
142
142
|
break;
|
|
143
|
-
case
|
|
144
|
-
_context.prev =
|
|
145
|
-
|
|
146
|
-
if (!(
|
|
147
|
-
_context.next =
|
|
143
|
+
case 3:
|
|
144
|
+
_context.prev = 3;
|
|
145
|
+
_t = _context["catch"](1);
|
|
146
|
+
if (!(_t instanceof Error && _t.name === 'AbortError')) {
|
|
147
|
+
_context.next = 4;
|
|
148
148
|
break;
|
|
149
149
|
}
|
|
150
150
|
// Request aborted client-side
|
|
151
151
|
_ufoExperiences.UsersFetchedUfoExperience.getInstance(fieldId).abort();
|
|
152
152
|
// return early to prevent disabling isLoading
|
|
153
153
|
return _context.abrupt("return");
|
|
154
|
-
case
|
|
154
|
+
case 4:
|
|
155
155
|
_ufoExperiences.UsersFetchedUfoExperience.getInstance(fieldId).failure({
|
|
156
156
|
metadata: getAnalyticsAttributes()
|
|
157
157
|
});
|
|
158
|
-
setError(
|
|
159
|
-
case
|
|
158
|
+
setError(_t);
|
|
159
|
+
case 5:
|
|
160
160
|
setIsLoading(false);
|
|
161
161
|
// clear abort controller
|
|
162
162
|
lastAbortController.current = undefined;
|
|
163
|
-
case
|
|
163
|
+
case 6:
|
|
164
164
|
case "end":
|
|
165
165
|
return _context.stop();
|
|
166
166
|
}
|
|
167
|
-
}, _callee, null, [[
|
|
167
|
+
}, _callee, null, [[1, 3]]);
|
|
168
168
|
}));
|
|
169
169
|
return function (_x) {
|
|
170
170
|
return _ref.apply(this, arguments);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as transformRecommendationsToOptions } from '../utils/transform-recommendations-to-options/index';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as useUserRecommendations } from '../services/use-user-recommendations/index';
|
|
@@ -10,7 +10,7 @@ const createEvent = (eventType, action, actionSubject, attributes = {}) => ({
|
|
|
10
10
|
source: '@atlaskit/smart-hooks/use-user-recommendations',
|
|
11
11
|
attributes: {
|
|
12
12
|
packageName: "@atlaskit/smart-hooks",
|
|
13
|
-
packageVersion: "
|
|
13
|
+
packageVersion: "1.1.0",
|
|
14
14
|
...attributes
|
|
15
15
|
}
|
|
16
16
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as transformRecommendationsToOptions } from '../utils/transform-recommendations-to-options/index';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as useUserRecommendations } from '../services/use-user-recommendations/index';
|
|
@@ -15,7 +15,7 @@ var createEvent = function createEvent(eventType, action, actionSubject) {
|
|
|
15
15
|
source: '@atlaskit/smart-hooks/use-user-recommendations',
|
|
16
16
|
attributes: _objectSpread({
|
|
17
17
|
packageName: "@atlaskit/smart-hooks",
|
|
18
|
-
packageVersion: "
|
|
18
|
+
packageVersion: "1.1.0"
|
|
19
19
|
}, attributes)
|
|
20
20
|
};
|
|
21
21
|
};
|
|
@@ -85,8 +85,8 @@ var useUserRecommendations = function useUserRecommendations(props) {
|
|
|
85
85
|
}, [childObjectId, containerId, fieldId, includeTeams, maxNumberOfResults, objectId, preload, principalId, productKey, renderId, tenantId]);
|
|
86
86
|
var fetchRecommendations = useCallback( /*#__PURE__*/function () {
|
|
87
87
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(query) {
|
|
88
|
-
var _lastAbortController$, currentController, recommendedUsersResult;
|
|
89
|
-
return _regeneratorRuntime.wrap(function
|
|
88
|
+
var _lastAbortController$, currentController, recommendedUsersResult, _t;
|
|
89
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
90
90
|
while (1) switch (_context.prev = _context.next) {
|
|
91
91
|
case 0:
|
|
92
92
|
setIsLoading(true);
|
|
@@ -94,7 +94,7 @@ var useUserRecommendations = function useUserRecommendations(props) {
|
|
|
94
94
|
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
95
95
|
sessionId.current = uuid();
|
|
96
96
|
UsersFetchedUfoExperience.getInstance(fieldId).start();
|
|
97
|
-
_context.prev =
|
|
97
|
+
_context.prev = 1;
|
|
98
98
|
if (lastAbortController.current) {
|
|
99
99
|
(_lastAbortController$ = lastAbortController.current) === null || _lastAbortController$ === void 0 || _lastAbortController$.abort();
|
|
100
100
|
}
|
|
@@ -102,7 +102,7 @@ var useUserRecommendations = function useUserRecommendations(props) {
|
|
|
102
102
|
// IE has no timeout applied on fetch since AbortController isn't available
|
|
103
103
|
currentController = typeof AbortController !== 'undefined' ? new AbortController() : null;
|
|
104
104
|
lastAbortController.current = currentController;
|
|
105
|
-
_context.next =
|
|
105
|
+
_context.next = 2;
|
|
106
106
|
return fetchUserRecommendations({
|
|
107
107
|
baseUrl: baseUrl,
|
|
108
108
|
context: {
|
|
@@ -123,7 +123,7 @@ var useUserRecommendations = function useUserRecommendations(props) {
|
|
|
123
123
|
searchQuery: cpusSearchQuery,
|
|
124
124
|
query: query
|
|
125
125
|
}, currentController === null || currentController === void 0 ? void 0 : currentController.signal);
|
|
126
|
-
case
|
|
126
|
+
case 2:
|
|
127
127
|
recommendedUsersResult = _context.sent;
|
|
128
128
|
currentQuery.current = query !== null && query !== void 0 ? query : '';
|
|
129
129
|
UsersFetchedUfoExperience.getInstance(fieldId).success({
|
|
@@ -132,33 +132,33 @@ var useUserRecommendations = function useUserRecommendations(props) {
|
|
|
132
132
|
})
|
|
133
133
|
});
|
|
134
134
|
setRecommendations(recommendedUsersResult);
|
|
135
|
-
_context.next =
|
|
135
|
+
_context.next = 5;
|
|
136
136
|
break;
|
|
137
|
-
case
|
|
138
|
-
_context.prev =
|
|
139
|
-
|
|
140
|
-
if (!(
|
|
141
|
-
_context.next =
|
|
137
|
+
case 3:
|
|
138
|
+
_context.prev = 3;
|
|
139
|
+
_t = _context["catch"](1);
|
|
140
|
+
if (!(_t instanceof Error && _t.name === 'AbortError')) {
|
|
141
|
+
_context.next = 4;
|
|
142
142
|
break;
|
|
143
143
|
}
|
|
144
144
|
// Request aborted client-side
|
|
145
145
|
UsersFetchedUfoExperience.getInstance(fieldId).abort();
|
|
146
146
|
// return early to prevent disabling isLoading
|
|
147
147
|
return _context.abrupt("return");
|
|
148
|
-
case
|
|
148
|
+
case 4:
|
|
149
149
|
UsersFetchedUfoExperience.getInstance(fieldId).failure({
|
|
150
150
|
metadata: getAnalyticsAttributes()
|
|
151
151
|
});
|
|
152
|
-
setError(
|
|
153
|
-
case
|
|
152
|
+
setError(_t);
|
|
153
|
+
case 5:
|
|
154
154
|
setIsLoading(false);
|
|
155
155
|
// clear abort controller
|
|
156
156
|
lastAbortController.current = undefined;
|
|
157
|
-
case
|
|
157
|
+
case 6:
|
|
158
158
|
case "end":
|
|
159
159
|
return _context.stop();
|
|
160
160
|
}
|
|
161
|
-
}, _callee, null, [[
|
|
161
|
+
}, _callee, null, [[1, 3]]);
|
|
162
162
|
}));
|
|
163
163
|
return function (_x) {
|
|
164
164
|
return _ref.apply(this, arguments);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as transformRecommendationsToOptions } from '../utils/transform-recommendations-to-options/index';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as useUserRecommendations } from '../services/use-user-recommendations/index';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as transformRecommendationsToOptions } from '../utils/transform-recommendations-to-options/index';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as useUserRecommendations } from '../services/use-user-recommendations/index';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/smart-hooks",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -25,13 +25,13 @@
|
|
|
25
25
|
"team": "Search Platform: Search Experience"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@atlaskit/afm-i18n-platform-smart-experiences-smart-hooks": "2.
|
|
28
|
+
"@atlaskit/afm-i18n-platform-smart-experiences-smart-hooks": "2.138.0",
|
|
29
29
|
"@atlaskit/analytics-gas-types": "^5.1.0",
|
|
30
30
|
"@atlaskit/analytics-listeners": "^10.1.0",
|
|
31
31
|
"@atlaskit/analytics-next": "^11.2.0",
|
|
32
32
|
"@atlaskit/smart-common": "^2.1.0",
|
|
33
33
|
"@atlaskit/ufo": "^0.5.0",
|
|
34
|
-
"@atlaskit/user-picker": "^12.
|
|
34
|
+
"@atlaskit/user-picker": "^12.1.0",
|
|
35
35
|
"@babel/runtime": "^7.0.0",
|
|
36
36
|
"lodash": "^4.17.21",
|
|
37
37
|
"memoize-one": "^6.0.0",
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
"@welldone-software/why-did-you-render": "^6.2.0",
|
|
48
48
|
"enzyme": "^3.10.0",
|
|
49
49
|
"fetch-mock": "^8.0.0",
|
|
50
|
+
"react": "^18.2.0",
|
|
50
51
|
"react-dom": "^18.2.0",
|
|
51
52
|
"react-intl": "^6.6.2",
|
|
52
53
|
"wait-for-expect": "^1.2.0"
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@atlaskit/smart-hooks/transform-recommendations-to-options",
|
|
3
|
+
"main": "../dist/cjs/entry-points/transform-recommendations-to-options.js",
|
|
4
|
+
"module": "../dist/esm/entry-points/transform-recommendations-to-options.js",
|
|
5
|
+
"module:es2019": "../dist/es2019/entry-points/transform-recommendations-to-options.js",
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"types": "../dist/types/entry-points/transform-recommendations-to-options.d.ts",
|
|
8
|
+
"typesVersions": {
|
|
9
|
+
">=4.5 <5.9": {
|
|
10
|
+
"*": [
|
|
11
|
+
"../dist/types-ts4.5/entry-points/transform-recommendations-to-options.d.ts"
|
|
12
|
+
]
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@atlaskit/smart-hooks/use-user-recommendations",
|
|
3
|
+
"main": "../dist/cjs/entry-points/use-user-recommendations.js",
|
|
4
|
+
"module": "../dist/esm/entry-points/use-user-recommendations.js",
|
|
5
|
+
"module:es2019": "../dist/es2019/entry-points/use-user-recommendations.js",
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"types": "../dist/types/entry-points/use-user-recommendations.d.ts",
|
|
8
|
+
"typesVersions": {
|
|
9
|
+
">=4.5 <5.9": {
|
|
10
|
+
"*": [
|
|
11
|
+
"../dist/types-ts4.5/entry-points/use-user-recommendations.d.ts"
|
|
12
|
+
]
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|