@atlaskit/util-data-test 17.1.0 → 17.1.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 +6 -0
- package/dist/cjs/profilecard/get-mock-profilecard-client.js +80 -28
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/profilecard/get-mock-profilecard-client.js +56 -41
- package/dist/es2019/version.json +1 -1
- package/dist/esm/profilecard/get-mock-profilecard-client.js +77 -25
- package/dist/esm/version.json +1 -1
- package/dist/types/profilecard/get-mock-profilecard-client.d.ts +2 -22
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,7 +6,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.getMockProfilecardClient = getMockProfilecardClient;
|
|
9
|
-
exports.simpleMockProfilecardClient =
|
|
9
|
+
exports.simpleMockProfilecardClient = simpleMockProfilecardClient;
|
|
10
|
+
|
|
11
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
12
|
+
|
|
13
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
14
|
|
|
11
15
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
12
16
|
|
|
@@ -20,6 +24,8 @@ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime
|
|
|
20
24
|
|
|
21
25
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
22
26
|
|
|
27
|
+
var _profilecard = require("@atlaskit/profilecard");
|
|
28
|
+
|
|
23
29
|
var _profilecardData = require("./profilecard-data");
|
|
24
30
|
|
|
25
31
|
var _util = require("./util");
|
|
@@ -82,41 +88,89 @@ function getMockProfilecardClient(BaseProfileClient, modifyResponse) {
|
|
|
82
88
|
}(BaseProfileClient);
|
|
83
89
|
}
|
|
84
90
|
|
|
85
|
-
var
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
var matchError = userId.match(/^error:([0-9a-zA-Z\-]+)$/);
|
|
89
|
-
var error = matchError && matchError[1];
|
|
91
|
+
var getMockProfile = function getMockProfile(userId) {
|
|
92
|
+
var matchError = userId.match(/^error:([0-9a-zA-Z\-]+)$/);
|
|
93
|
+
var error = matchError && matchError[1];
|
|
90
94
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
95
|
+
if (error) {
|
|
96
|
+
return Promise.reject({
|
|
97
|
+
reason: 'error'
|
|
98
|
+
});
|
|
99
|
+
}
|
|
96
100
|
|
|
97
|
-
|
|
101
|
+
var profile = _profilecardData.profilecardData[parseInt(userId, 10)];
|
|
98
102
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
103
|
+
if (!profile) {
|
|
104
|
+
return Promise.reject({
|
|
105
|
+
reason: 'default'
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
var weekday = (0, _util.getWeekday)();
|
|
104
110
|
|
|
105
|
-
|
|
111
|
+
var data = _objectSpread({}, profile);
|
|
106
112
|
|
|
107
|
-
|
|
113
|
+
data.remoteTimeString = (0, _util.getTimeString)();
|
|
114
|
+
data.remoteWeekdayIndex = weekday.index;
|
|
115
|
+
data.remoteWeekdayString = weekday.string;
|
|
116
|
+
return Promise.resolve(data);
|
|
117
|
+
}; // TODO: This function will replace getMockProfilecardClient() on line 13 once the latest `master` branch containing this code has been merged to `develop`
|
|
108
118
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
119
|
+
|
|
120
|
+
function simpleMockProfilecardClient() {
|
|
121
|
+
return {
|
|
122
|
+
flushCache: function flushCache() {
|
|
123
|
+
return undefined;
|
|
113
124
|
},
|
|
114
|
-
|
|
125
|
+
getProfile: function () {
|
|
126
|
+
var _getProfile = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(_cloudId, userId) {
|
|
127
|
+
var timeout;
|
|
128
|
+
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
129
|
+
while (1) {
|
|
130
|
+
switch (_context2.prev = _context2.next) {
|
|
131
|
+
case 0:
|
|
132
|
+
timeout = (0, _util.random)(1500) + 500;
|
|
133
|
+
return _context2.abrupt("return", new Promise(function (resolve, reject) {
|
|
134
|
+
window.setTimeout( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
135
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
136
|
+
while (1) {
|
|
137
|
+
switch (_context.prev = _context.next) {
|
|
138
|
+
case 0:
|
|
139
|
+
getMockProfile(userId).then(function (data) {
|
|
140
|
+
return resolve((0, _profilecard.modifyResponse)(data));
|
|
141
|
+
}).catch(function (error) {
|
|
142
|
+
return reject(error);
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
case 1:
|
|
146
|
+
case "end":
|
|
147
|
+
return _context.stop();
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}, _callee);
|
|
151
|
+
})), timeout);
|
|
152
|
+
}));
|
|
153
|
+
|
|
154
|
+
case 2:
|
|
155
|
+
case "end":
|
|
156
|
+
return _context2.stop();
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}, _callee2);
|
|
160
|
+
}));
|
|
161
|
+
|
|
162
|
+
function getProfile(_x, _x2) {
|
|
163
|
+
return _getProfile.apply(this, arguments);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return getProfile;
|
|
167
|
+
}(),
|
|
168
|
+
getTeamProfile: function getTeamProfile(_teamId, _orgId, _analytics) {
|
|
115
169
|
return Promise.reject({
|
|
116
170
|
reason: 'not built yet'
|
|
117
171
|
});
|
|
118
172
|
},
|
|
119
|
-
getReportingLines: function getReportingLines(
|
|
173
|
+
getReportingLines: function getReportingLines(_userId) {
|
|
120
174
|
var reportingLinesUsers = _profilecardData.profilecardData.map(function (user, index) {
|
|
121
175
|
return {
|
|
122
176
|
accountIdentifier: '123456:12345-67890-' + index,
|
|
@@ -135,6 +189,4 @@ var simpleMockProfilecardClient = function simpleMockProfilecardClient(modifyRes
|
|
|
135
189
|
});
|
|
136
190
|
}
|
|
137
191
|
};
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
exports.simpleMockProfilecardClient = simpleMockProfilecardClient;
|
|
192
|
+
}
|
package/dist/cjs/version.json
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { modifyResponse } from '@atlaskit/profilecard';
|
|
1
2
|
import { profilecardData } from './profilecard-data';
|
|
2
3
|
import { random, getWeekday, getTimeString } from './util';
|
|
3
4
|
export function getMockProfilecardClient(BaseProfileClient, modifyResponse) {
|
|
@@ -36,51 +37,65 @@ export function getMockProfilecardClient(BaseProfileClient, modifyResponse) {
|
|
|
36
37
|
|
|
37
38
|
};
|
|
38
39
|
}
|
|
39
|
-
export const simpleMockProfilecardClient = modifyResponse => ({
|
|
40
|
-
getProfile: (cloudId, userId) => {
|
|
41
|
-
const matchError = userId.match(/^error:([0-9a-zA-Z\-]+)$/);
|
|
42
|
-
const error = matchError && matchError[1];
|
|
43
40
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
});
|
|
48
|
-
}
|
|
41
|
+
const getMockProfile = userId => {
|
|
42
|
+
const matchError = userId.match(/^error:([0-9a-zA-Z\-]+)$/);
|
|
43
|
+
const error = matchError && matchError[1];
|
|
49
44
|
|
|
50
|
-
|
|
45
|
+
if (error) {
|
|
46
|
+
return Promise.reject({
|
|
47
|
+
reason: 'error'
|
|
48
|
+
});
|
|
49
|
+
}
|
|
51
50
|
|
|
52
|
-
|
|
53
|
-
return Promise.reject({
|
|
54
|
-
reason: 'default'
|
|
55
|
-
});
|
|
56
|
-
}
|
|
51
|
+
const profile = profilecardData[parseInt(userId, 10)];
|
|
57
52
|
|
|
58
|
-
|
|
59
|
-
const data = { ...profile
|
|
60
|
-
};
|
|
61
|
-
data.remoteTimeString = getTimeString();
|
|
62
|
-
data.remoteWeekdayIndex = weekday.index;
|
|
63
|
-
data.remoteWeekdayString = weekday.string;
|
|
64
|
-
return Promise.resolve(modifyResponse(data));
|
|
65
|
-
},
|
|
66
|
-
getTeamProfile: (orgId, teamId, analytics) => {
|
|
53
|
+
if (!profile) {
|
|
67
54
|
return Promise.reject({
|
|
68
|
-
reason: '
|
|
69
|
-
});
|
|
70
|
-
},
|
|
71
|
-
getReportingLines: userId => {
|
|
72
|
-
const reportingLinesUsers = profilecardData.map((user, index) => ({
|
|
73
|
-
accountIdentifier: '123456:12345-67890-' + index,
|
|
74
|
-
identifierType: 'ATLASSIAN_ID',
|
|
75
|
-
pii: {
|
|
76
|
-
name: user.User.fullName,
|
|
77
|
-
picture: user.User.avatarUrl
|
|
78
|
-
}
|
|
79
|
-
}));
|
|
80
|
-
const halfCount = Math.ceil(reportingLinesUsers.length / 2);
|
|
81
|
-
return Promise.resolve({
|
|
82
|
-
managers: reportingLinesUsers.slice(0, halfCount),
|
|
83
|
-
reports: reportingLinesUsers.slice(-halfCount)
|
|
55
|
+
reason: 'default'
|
|
84
56
|
});
|
|
85
57
|
}
|
|
86
|
-
|
|
58
|
+
|
|
59
|
+
const weekday = getWeekday();
|
|
60
|
+
const data = { ...profile
|
|
61
|
+
};
|
|
62
|
+
data.remoteTimeString = getTimeString();
|
|
63
|
+
data.remoteWeekdayIndex = weekday.index;
|
|
64
|
+
data.remoteWeekdayString = weekday.string;
|
|
65
|
+
return Promise.resolve(data);
|
|
66
|
+
}; // TODO: This function will replace getMockProfilecardClient() on line 13 once the latest `master` branch containing this code has been merged to `develop`
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
export function simpleMockProfilecardClient() {
|
|
70
|
+
return {
|
|
71
|
+
flushCache: () => undefined,
|
|
72
|
+
getProfile: async (_cloudId, userId) => {
|
|
73
|
+
const timeout = random(1500) + 500;
|
|
74
|
+
return new Promise((resolve, reject) => {
|
|
75
|
+
window.setTimeout(async () => {
|
|
76
|
+
getMockProfile(userId).then(data => resolve(modifyResponse(data))).catch(error => reject(error));
|
|
77
|
+
}, timeout);
|
|
78
|
+
});
|
|
79
|
+
},
|
|
80
|
+
getTeamProfile: (_teamId, _orgId, _analytics) => {
|
|
81
|
+
return Promise.reject({
|
|
82
|
+
reason: 'not built yet'
|
|
83
|
+
});
|
|
84
|
+
},
|
|
85
|
+
getReportingLines: _userId => {
|
|
86
|
+
const reportingLinesUsers = profilecardData.map((user, index) => ({
|
|
87
|
+
accountIdentifier: '123456:12345-67890-' + index,
|
|
88
|
+
identifierType: 'ATLASSIAN_ID',
|
|
89
|
+
pii: {
|
|
90
|
+
name: user.User.fullName,
|
|
91
|
+
picture: user.User.avatarUrl
|
|
92
|
+
}
|
|
93
|
+
}));
|
|
94
|
+
const halfCount = Math.ceil(reportingLinesUsers.length / 2);
|
|
95
|
+
return Promise.resolve({
|
|
96
|
+
managers: reportingLinesUsers.slice(0, halfCount),
|
|
97
|
+
reports: reportingLinesUsers.slice(-halfCount)
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
}
|
package/dist/es2019/version.json
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
1
3
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
4
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
5
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
@@ -13,6 +15,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
13
15
|
|
|
14
16
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
15
17
|
|
|
18
|
+
import { modifyResponse } from '@atlaskit/profilecard';
|
|
16
19
|
import { profilecardData } from './profilecard-data';
|
|
17
20
|
import { random, getWeekday, getTimeString } from './util';
|
|
18
21
|
export function getMockProfilecardClient(BaseProfileClient, modifyResponse) {
|
|
@@ -66,41 +69,90 @@ export function getMockProfilecardClient(BaseProfileClient, modifyResponse) {
|
|
|
66
69
|
return MockProfileClient;
|
|
67
70
|
}(BaseProfileClient);
|
|
68
71
|
}
|
|
69
|
-
export var simpleMockProfilecardClient = function simpleMockProfilecardClient(modifyResponse) {
|
|
70
|
-
return {
|
|
71
|
-
getProfile: function getProfile(cloudId, userId) {
|
|
72
|
-
var matchError = userId.match(/^error:([0-9a-zA-Z\-]+)$/);
|
|
73
|
-
var error = matchError && matchError[1];
|
|
74
72
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
});
|
|
79
|
-
}
|
|
73
|
+
var getMockProfile = function getMockProfile(userId) {
|
|
74
|
+
var matchError = userId.match(/^error:([0-9a-zA-Z\-]+)$/);
|
|
75
|
+
var error = matchError && matchError[1];
|
|
80
76
|
|
|
81
|
-
|
|
77
|
+
if (error) {
|
|
78
|
+
return Promise.reject({
|
|
79
|
+
reason: 'error'
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
82
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
83
|
+
var profile = profilecardData[parseInt(userId, 10)];
|
|
84
|
+
|
|
85
|
+
if (!profile) {
|
|
86
|
+
return Promise.reject({
|
|
87
|
+
reason: 'default'
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
var weekday = getWeekday();
|
|
88
92
|
|
|
89
|
-
|
|
93
|
+
var data = _objectSpread({}, profile);
|
|
90
94
|
|
|
91
|
-
|
|
95
|
+
data.remoteTimeString = getTimeString();
|
|
96
|
+
data.remoteWeekdayIndex = weekday.index;
|
|
97
|
+
data.remoteWeekdayString = weekday.string;
|
|
98
|
+
return Promise.resolve(data);
|
|
99
|
+
}; // TODO: This function will replace getMockProfilecardClient() on line 13 once the latest `master` branch containing this code has been merged to `develop`
|
|
92
100
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
101
|
+
|
|
102
|
+
export function simpleMockProfilecardClient() {
|
|
103
|
+
return {
|
|
104
|
+
flushCache: function flushCache() {
|
|
105
|
+
return undefined;
|
|
97
106
|
},
|
|
98
|
-
|
|
107
|
+
getProfile: function () {
|
|
108
|
+
var _getProfile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_cloudId, userId) {
|
|
109
|
+
var timeout;
|
|
110
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
111
|
+
while (1) {
|
|
112
|
+
switch (_context2.prev = _context2.next) {
|
|
113
|
+
case 0:
|
|
114
|
+
timeout = random(1500) + 500;
|
|
115
|
+
return _context2.abrupt("return", new Promise(function (resolve, reject) {
|
|
116
|
+
window.setTimeout( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
117
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
118
|
+
while (1) {
|
|
119
|
+
switch (_context.prev = _context.next) {
|
|
120
|
+
case 0:
|
|
121
|
+
getMockProfile(userId).then(function (data) {
|
|
122
|
+
return resolve(modifyResponse(data));
|
|
123
|
+
}).catch(function (error) {
|
|
124
|
+
return reject(error);
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
case 1:
|
|
128
|
+
case "end":
|
|
129
|
+
return _context.stop();
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}, _callee);
|
|
133
|
+
})), timeout);
|
|
134
|
+
}));
|
|
135
|
+
|
|
136
|
+
case 2:
|
|
137
|
+
case "end":
|
|
138
|
+
return _context2.stop();
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}, _callee2);
|
|
142
|
+
}));
|
|
143
|
+
|
|
144
|
+
function getProfile(_x, _x2) {
|
|
145
|
+
return _getProfile.apply(this, arguments);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return getProfile;
|
|
149
|
+
}(),
|
|
150
|
+
getTeamProfile: function getTeamProfile(_teamId, _orgId, _analytics) {
|
|
99
151
|
return Promise.reject({
|
|
100
152
|
reason: 'not built yet'
|
|
101
153
|
});
|
|
102
154
|
},
|
|
103
|
-
getReportingLines: function getReportingLines(
|
|
155
|
+
getReportingLines: function getReportingLines(_userId) {
|
|
104
156
|
var reportingLinesUsers = profilecardData.map(function (user, index) {
|
|
105
157
|
return {
|
|
106
158
|
accountIdentifier: '123456:12345-67890-' + index,
|
|
@@ -118,4 +170,4 @@ export var simpleMockProfilecardClient = function simpleMockProfilecardClient(mo
|
|
|
118
170
|
});
|
|
119
171
|
}
|
|
120
172
|
};
|
|
121
|
-
}
|
|
173
|
+
}
|
package/dist/esm/version.json
CHANGED
|
@@ -1,23 +1,3 @@
|
|
|
1
|
+
import { ProfileClient } from '@atlaskit/profilecard/types';
|
|
1
2
|
export declare function getMockProfilecardClient(BaseProfileClient: any, modifyResponse: any): any;
|
|
2
|
-
export declare
|
|
3
|
-
getProfile: (cloudId: string, userId: string) => Promise<any>;
|
|
4
|
-
getTeamProfile: (orgId: string, teamId: string, analytics: any) => Promise<never>;
|
|
5
|
-
getReportingLines: (userId: string) => Promise<{
|
|
6
|
-
managers: {
|
|
7
|
-
accountIdentifier: string;
|
|
8
|
-
identifierType: string;
|
|
9
|
-
pii: {
|
|
10
|
-
name: string;
|
|
11
|
-
picture: string | undefined;
|
|
12
|
-
};
|
|
13
|
-
}[];
|
|
14
|
-
reports: {
|
|
15
|
-
accountIdentifier: string;
|
|
16
|
-
identifierType: string;
|
|
17
|
-
pii: {
|
|
18
|
-
name: string;
|
|
19
|
-
picture: string | undefined;
|
|
20
|
-
};
|
|
21
|
-
}[];
|
|
22
|
-
}>;
|
|
23
|
-
};
|
|
3
|
+
export declare function simpleMockProfilecardClient(): ProfileClient;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/util-data-test",
|
|
3
|
-
"version": "17.1.
|
|
3
|
+
"version": "17.1.1",
|
|
4
4
|
"description": "Shared test and story data",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -68,6 +68,7 @@
|
|
|
68
68
|
"@atlaskit/analytics-next": "^8.0.0",
|
|
69
69
|
"@atlaskit/emoji": "^64.0.0",
|
|
70
70
|
"@atlaskit/mention": "^19.1.0",
|
|
71
|
+
"@atlaskit/profilecard": "^16.2.0",
|
|
71
72
|
"@atlaskit/task-decision": "^17.0.0",
|
|
72
73
|
"@atlaskit/util-service-support": "^6.0.0",
|
|
73
74
|
"@babel/runtime": "^7.0.0",
|