@atlaskit/util-service-support 6.1.3 → 6.2.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 +12 -0
- package/dist/cjs/index.js +0 -9
- package/dist/cjs/serviceResources.js +0 -8
- package/dist/cjs/serviceUtils.js +8 -34
- package/dist/cjs/types.js +5 -2
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/serviceResources.js +0 -8
- package/dist/es2019/serviceUtils.js +5 -19
- package/dist/es2019/types.js +6 -0
- package/dist/es2019/version.json +1 -1
- package/dist/esm/serviceResources.js +0 -4
- package/dist/esm/serviceUtils.js +8 -30
- package/dist/esm/types.js +6 -0
- package/dist/esm/version.json +1 -1
- package/dist/types/serviceUtils.d.ts +1 -1
- package/dist/types/types.d.ts +1 -1
- package/package.json +6 -5
- package/report.api.md +28 -9
- package/serviceResources/package.json +2 -2
- package/serviceUtils/package.json +2 -2
- package/tmp/api-report-tmp.d.ts +109 -0
- package/types/package.json +2 -2
- package/dist/types-ts4.0/index.d.ts +0 -4
- package/dist/types-ts4.0/serviceResources.d.ts +0 -12
- package/dist/types-ts4.0/serviceUtils.d.ts +0 -5
- package/dist/types-ts4.0/types.d.ts +0 -80
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/util-service-support
|
|
2
2
|
|
|
3
|
+
## 6.2.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`41fae2c6f68`](https://bitbucket.org/atlassian/atlassian-frontend/commits/41fae2c6f68) - Upgrade Typescript from `4.5.5` to `4.9.5`
|
|
8
|
+
|
|
9
|
+
## 6.2.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [`56507598609`](https://bitbucket.org/atlassian/atlassian-frontend/commits/56507598609) - Skip minor dependency bump
|
|
14
|
+
|
|
3
15
|
## 6.1.3
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
@@ -9,9 +8,7 @@ var _exportNames = {
|
|
|
9
8
|
utils: true
|
|
10
9
|
};
|
|
11
10
|
exports.utils = void 0;
|
|
12
|
-
|
|
13
11
|
var _types = require("./types");
|
|
14
|
-
|
|
15
12
|
Object.keys(_types).forEach(function (key) {
|
|
16
13
|
if (key === "default" || key === "__esModule") return;
|
|
17
14
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -23,9 +20,7 @@ Object.keys(_types).forEach(function (key) {
|
|
|
23
20
|
}
|
|
24
21
|
});
|
|
25
22
|
});
|
|
26
|
-
|
|
27
23
|
var _serviceResources = require("./serviceResources");
|
|
28
|
-
|
|
29
24
|
Object.keys(_serviceResources).forEach(function (key) {
|
|
30
25
|
if (key === "default" || key === "__esModule") return;
|
|
31
26
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -37,12 +32,8 @@ Object.keys(_serviceResources).forEach(function (key) {
|
|
|
37
32
|
}
|
|
38
33
|
});
|
|
39
34
|
});
|
|
40
|
-
|
|
41
35
|
var serviceUtils = _interopRequireWildcard(require("./serviceUtils"));
|
|
42
|
-
|
|
43
36
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
44
|
-
|
|
45
37
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
46
|
-
|
|
47
38
|
var utils = serviceUtils;
|
|
48
39
|
exports.utils = utils;
|
|
@@ -1,29 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.AbstractResource = void 0;
|
|
9
|
-
|
|
10
8
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
-
|
|
12
9
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
-
|
|
14
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
15
|
-
|
|
16
11
|
var AbstractResource = /*#__PURE__*/function () {
|
|
17
12
|
function AbstractResource() {
|
|
18
13
|
(0, _classCallCheck2.default)(this, AbstractResource);
|
|
19
14
|
(0, _defineProperty2.default)(this, "listeners", new Set());
|
|
20
15
|
}
|
|
21
|
-
|
|
22
16
|
(0, _createClass2.default)(AbstractResource, [{
|
|
23
17
|
key: "subscribe",
|
|
24
18
|
value: function subscribe(onChange) {
|
|
25
19
|
this.listeners.add(onChange);
|
|
26
|
-
|
|
27
20
|
if (this.lastResult) {
|
|
28
21
|
// Notify subscribe of last result (i.e. initial state)
|
|
29
22
|
onChange.result(this.lastResult);
|
|
@@ -71,5 +64,4 @@ var AbstractResource = /*#__PURE__*/function () {
|
|
|
71
64
|
}]);
|
|
72
65
|
return AbstractResource;
|
|
73
66
|
}();
|
|
74
|
-
|
|
75
67
|
exports.AbstractResource = AbstractResource;
|
package/dist/cjs/serviceUtils.js
CHANGED
|
@@ -1,31 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.requestService = void 0;
|
|
9
|
-
|
|
10
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
9
|
var _types = require("./types");
|
|
13
|
-
|
|
14
10
|
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; }
|
|
15
|
-
|
|
16
11
|
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; }
|
|
17
|
-
|
|
18
12
|
var defaultRequestServiceOptions = {};
|
|
19
|
-
|
|
20
13
|
var buildUrl = function buildUrl(baseUrl) {
|
|
21
14
|
var path = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
22
15
|
var queryParams = arguments.length > 2 ? arguments[2] : undefined;
|
|
23
16
|
var secOptions = arguments.length > 3 ? arguments[3] : undefined;
|
|
24
|
-
var searchParam = new URLSearchParams(
|
|
17
|
+
var searchParam = new URLSearchParams(
|
|
18
|
+
// For relative urls, the URL class requires base to be set. It's ignored if a url is not relative.
|
|
25
19
|
// Since we only care about search params it is fine to have any base url here.
|
|
26
20
|
new URL(baseUrl, 'https://BASE_FALLBACK').search || undefined);
|
|
27
21
|
baseUrl = baseUrl.split('?')[0];
|
|
28
|
-
|
|
29
22
|
if (queryParams) {
|
|
30
23
|
for (var key in queryParams) {
|
|
31
24
|
if ({}.hasOwnProperty.call(queryParams, key)) {
|
|
@@ -33,12 +26,10 @@ var buildUrl = function buildUrl(baseUrl) {
|
|
|
33
26
|
}
|
|
34
27
|
}
|
|
35
28
|
}
|
|
36
|
-
|
|
37
29
|
if (secOptions && secOptions.params) {
|
|
38
30
|
for (var _key in secOptions.params) {
|
|
39
31
|
if ({}.hasOwnProperty.call(secOptions.params, _key)) {
|
|
40
32
|
var values = secOptions.params[_key];
|
|
41
|
-
|
|
42
33
|
if (Array.isArray(values)) {
|
|
43
34
|
for (var i = 0; i < values.length; i++) {
|
|
44
35
|
searchParam.append(_key, values[i]);
|
|
@@ -49,28 +40,21 @@ var buildUrl = function buildUrl(baseUrl) {
|
|
|
49
40
|
}
|
|
50
41
|
}
|
|
51
42
|
}
|
|
52
|
-
|
|
53
43
|
var separator = '';
|
|
54
|
-
|
|
55
44
|
if (path && baseUrl.substr(-1) !== '/' && !path.startsWith('/')) {
|
|
56
45
|
separator = '/';
|
|
57
46
|
}
|
|
58
|
-
|
|
59
47
|
var params = searchParam.toString();
|
|
60
|
-
|
|
61
48
|
if (params) {
|
|
62
49
|
params = '?' + params;
|
|
63
50
|
}
|
|
64
|
-
|
|
65
51
|
return "".concat(baseUrl).concat(separator).concat(path).concat(params);
|
|
66
52
|
};
|
|
67
|
-
|
|
68
53
|
var addToHeaders = function addToHeaders(headers, keyValues) {
|
|
69
54
|
if (keyValues) {
|
|
70
55
|
for (var key in keyValues) {
|
|
71
56
|
if ({}.hasOwnProperty.call(keyValues, key)) {
|
|
72
57
|
var values = keyValues[key];
|
|
73
|
-
|
|
74
58
|
if (Array.isArray(values)) {
|
|
75
59
|
for (var i = 0; i < values.length; i++) {
|
|
76
60
|
headers[key] = values[i];
|
|
@@ -82,43 +66,35 @@ var addToHeaders = function addToHeaders(headers, keyValues) {
|
|
|
82
66
|
}
|
|
83
67
|
}
|
|
84
68
|
};
|
|
85
|
-
|
|
86
69
|
var buildHeaders = function buildHeaders(secOptions, extraHeaders) {
|
|
87
70
|
var headers = {};
|
|
88
71
|
addToHeaders(headers, extraHeaders);
|
|
89
|
-
|
|
90
72
|
if (secOptions) {
|
|
91
73
|
addToHeaders(headers, secOptions.headers);
|
|
92
74
|
}
|
|
93
|
-
|
|
94
75
|
return headers;
|
|
95
76
|
};
|
|
77
|
+
|
|
96
78
|
/**
|
|
97
79
|
* @returns Promise containing the json response
|
|
98
80
|
*/
|
|
99
|
-
|
|
100
|
-
|
|
101
81
|
var requestService = function requestService(serviceConfig, options) {
|
|
102
82
|
var url = serviceConfig.url,
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
83
|
+
securityProvider = serviceConfig.securityProvider,
|
|
84
|
+
refreshedSecurityProvider = serviceConfig.refreshedSecurityProvider;
|
|
106
85
|
var _ref = options || defaultRequestServiceOptions,
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
86
|
+
path = _ref.path,
|
|
87
|
+
queryParams = _ref.queryParams,
|
|
88
|
+
requestInit = _ref.requestInit;
|
|
111
89
|
var secOptions = securityProvider && securityProvider();
|
|
112
90
|
var requestUrl = buildUrl(url, path, queryParams, secOptions);
|
|
113
91
|
var headers = buildHeaders(secOptions, requestInit && requestInit.headers);
|
|
114
92
|
var credentials = (0, _types.buildCredentials)(secOptions);
|
|
115
93
|
var ignoreResponsePayload = (options === null || options === void 0 ? void 0 : options.ignoreResponsePayload) || false;
|
|
116
|
-
|
|
117
94
|
var requestOptions = _objectSpread(_objectSpread({}, requestInit), {}, {
|
|
118
95
|
headers: headers,
|
|
119
96
|
credentials: credentials
|
|
120
97
|
});
|
|
121
|
-
|
|
122
98
|
return fetch(requestUrl, requestOptions).then(function (response) {
|
|
123
99
|
if (response.status === 204) {
|
|
124
100
|
return Promise.resolve();
|
|
@@ -136,12 +112,10 @@ var requestService = function requestService(serviceConfig, options) {
|
|
|
136
112
|
return requestService(retryServiceConfig, options);
|
|
137
113
|
});
|
|
138
114
|
}
|
|
139
|
-
|
|
140
115
|
return Promise.reject({
|
|
141
116
|
code: response.status,
|
|
142
117
|
reason: response.statusText
|
|
143
118
|
});
|
|
144
119
|
});
|
|
145
120
|
};
|
|
146
|
-
|
|
147
121
|
exports.requestService = requestService;
|
package/dist/cjs/types.js
CHANGED
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.buildCredentials = void 0;
|
|
7
|
-
|
|
8
7
|
/**
|
|
9
8
|
* Defines a typical Resource.
|
|
10
9
|
*
|
|
@@ -14,13 +13,17 @@ exports.buildCredentials = void 0;
|
|
|
14
13
|
* I = info type
|
|
15
14
|
* O = options that filter can accept
|
|
16
15
|
*/
|
|
16
|
+
|
|
17
17
|
var buildCredentials = function buildCredentials(secOptions) {
|
|
18
18
|
return secOptions && secOptions.omitCredentials ? 'omit' : 'include';
|
|
19
19
|
};
|
|
20
|
+
|
|
20
21
|
/**
|
|
21
22
|
* Returns a promise to a SecurityOptions that has just been forcibly refreshed with a
|
|
22
23
|
* new token. Will be used for single retry per request if a 401 is returned.
|
|
23
24
|
*/
|
|
24
25
|
|
|
25
|
-
|
|
26
|
+
/**
|
|
27
|
+
* Returns the current SecurityOptions for the mentions service.
|
|
28
|
+
*/
|
|
26
29
|
exports.buildCredentials = buildCredentials;
|
package/dist/cjs/version.json
CHANGED
|
@@ -3,26 +3,21 @@ export class AbstractResource {
|
|
|
3
3
|
constructor() {
|
|
4
4
|
_defineProperty(this, "listeners", new Set());
|
|
5
5
|
}
|
|
6
|
-
|
|
7
6
|
subscribe(onChange) {
|
|
8
7
|
this.listeners.add(onChange);
|
|
9
|
-
|
|
10
8
|
if (this.lastResult) {
|
|
11
9
|
// Notify subscribe of last result (i.e. initial state)
|
|
12
10
|
onChange.result(this.lastResult);
|
|
13
11
|
}
|
|
14
12
|
}
|
|
15
|
-
|
|
16
13
|
unsubscribe(onChange) {
|
|
17
14
|
this.listeners.delete(onChange);
|
|
18
15
|
}
|
|
19
|
-
|
|
20
16
|
notifyResult(result) {
|
|
21
17
|
this.listeners.forEach(onChange => {
|
|
22
18
|
onChange.result(result);
|
|
23
19
|
});
|
|
24
20
|
}
|
|
25
|
-
|
|
26
21
|
notifyError(error) {
|
|
27
22
|
this.listeners.forEach(onChange => {
|
|
28
23
|
if (onChange.error) {
|
|
@@ -30,7 +25,6 @@ export class AbstractResource {
|
|
|
30
25
|
}
|
|
31
26
|
});
|
|
32
27
|
}
|
|
33
|
-
|
|
34
28
|
notifyInfo(info) {
|
|
35
29
|
this.listeners.forEach(onChange => {
|
|
36
30
|
if (onChange.info) {
|
|
@@ -38,7 +32,6 @@ export class AbstractResource {
|
|
|
38
32
|
}
|
|
39
33
|
});
|
|
40
34
|
}
|
|
41
|
-
|
|
42
35
|
notifyNotReady() {
|
|
43
36
|
this.listeners.forEach(onChange => {
|
|
44
37
|
if (onChange.notReady) {
|
|
@@ -46,5 +39,4 @@ export class AbstractResource {
|
|
|
46
39
|
}
|
|
47
40
|
});
|
|
48
41
|
}
|
|
49
|
-
|
|
50
42
|
}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { buildCredentials } from './types';
|
|
2
2
|
const defaultRequestServiceOptions = {};
|
|
3
|
-
|
|
4
3
|
const buildUrl = (baseUrl, path = '', queryParams, secOptions) => {
|
|
5
|
-
const searchParam = new URLSearchParams(
|
|
4
|
+
const searchParam = new URLSearchParams(
|
|
5
|
+
// For relative urls, the URL class requires base to be set. It's ignored if a url is not relative.
|
|
6
6
|
// Since we only care about search params it is fine to have any base url here.
|
|
7
7
|
new URL(baseUrl, 'https://BASE_FALLBACK').search || undefined);
|
|
8
8
|
baseUrl = baseUrl.split('?')[0];
|
|
9
|
-
|
|
10
9
|
if (queryParams) {
|
|
11
10
|
for (const key in queryParams) {
|
|
12
11
|
if ({}.hasOwnProperty.call(queryParams, key)) {
|
|
@@ -14,12 +13,10 @@ const buildUrl = (baseUrl, path = '', queryParams, secOptions) => {
|
|
|
14
13
|
}
|
|
15
14
|
}
|
|
16
15
|
}
|
|
17
|
-
|
|
18
16
|
if (secOptions && secOptions.params) {
|
|
19
17
|
for (const key in secOptions.params) {
|
|
20
18
|
if ({}.hasOwnProperty.call(secOptions.params, key)) {
|
|
21
19
|
const values = secOptions.params[key];
|
|
22
|
-
|
|
23
20
|
if (Array.isArray(values)) {
|
|
24
21
|
for (let i = 0; i < values.length; i++) {
|
|
25
22
|
searchParam.append(key, values[i]);
|
|
@@ -30,28 +27,21 @@ const buildUrl = (baseUrl, path = '', queryParams, secOptions) => {
|
|
|
30
27
|
}
|
|
31
28
|
}
|
|
32
29
|
}
|
|
33
|
-
|
|
34
30
|
let separator = '';
|
|
35
|
-
|
|
36
31
|
if (path && baseUrl.substr(-1) !== '/' && !path.startsWith('/')) {
|
|
37
32
|
separator = '/';
|
|
38
33
|
}
|
|
39
|
-
|
|
40
34
|
let params = searchParam.toString();
|
|
41
|
-
|
|
42
35
|
if (params) {
|
|
43
36
|
params = '?' + params;
|
|
44
37
|
}
|
|
45
|
-
|
|
46
38
|
return `${baseUrl}${separator}${path}${params}`;
|
|
47
39
|
};
|
|
48
|
-
|
|
49
40
|
const addToHeaders = (headers, keyValues) => {
|
|
50
41
|
if (keyValues) {
|
|
51
42
|
for (const key in keyValues) {
|
|
52
43
|
if ({}.hasOwnProperty.call(keyValues, key)) {
|
|
53
44
|
const values = keyValues[key];
|
|
54
|
-
|
|
55
45
|
if (Array.isArray(values)) {
|
|
56
46
|
for (let i = 0; i < values.length; i++) {
|
|
57
47
|
headers[key] = values[i];
|
|
@@ -63,22 +53,18 @@ const addToHeaders = (headers, keyValues) => {
|
|
|
63
53
|
}
|
|
64
54
|
}
|
|
65
55
|
};
|
|
66
|
-
|
|
67
56
|
const buildHeaders = (secOptions, extraHeaders) => {
|
|
68
57
|
const headers = {};
|
|
69
58
|
addToHeaders(headers, extraHeaders);
|
|
70
|
-
|
|
71
59
|
if (secOptions) {
|
|
72
60
|
addToHeaders(headers, secOptions.headers);
|
|
73
61
|
}
|
|
74
|
-
|
|
75
62
|
return headers;
|
|
76
63
|
};
|
|
64
|
+
|
|
77
65
|
/**
|
|
78
66
|
* @returns Promise containing the json response
|
|
79
67
|
*/
|
|
80
|
-
|
|
81
|
-
|
|
82
68
|
export const requestService = (serviceConfig, options) => {
|
|
83
69
|
const {
|
|
84
70
|
url,
|
|
@@ -95,7 +81,8 @@ export const requestService = (serviceConfig, options) => {
|
|
|
95
81
|
const headers = buildHeaders(secOptions, requestInit && requestInit.headers);
|
|
96
82
|
const credentials = buildCredentials(secOptions);
|
|
97
83
|
const ignoreResponsePayload = (options === null || options === void 0 ? void 0 : options.ignoreResponsePayload) || false;
|
|
98
|
-
const requestOptions = {
|
|
84
|
+
const requestOptions = {
|
|
85
|
+
...requestInit,
|
|
99
86
|
headers,
|
|
100
87
|
credentials
|
|
101
88
|
};
|
|
@@ -114,7 +101,6 @@ export const requestService = (serviceConfig, options) => {
|
|
|
114
101
|
return requestService(retryServiceConfig, options);
|
|
115
102
|
});
|
|
116
103
|
}
|
|
117
|
-
|
|
118
104
|
return Promise.reject({
|
|
119
105
|
code: response.status,
|
|
120
106
|
reason: response.statusText
|
package/dist/es2019/types.js
CHANGED
|
@@ -7,10 +7,16 @@
|
|
|
7
7
|
* I = info type
|
|
8
8
|
* O = options that filter can accept
|
|
9
9
|
*/
|
|
10
|
+
|
|
10
11
|
export const buildCredentials = secOptions => {
|
|
11
12
|
return secOptions && secOptions.omitCredentials ? 'omit' : 'include';
|
|
12
13
|
};
|
|
14
|
+
|
|
13
15
|
/**
|
|
14
16
|
* Returns a promise to a SecurityOptions that has just been forcibly refreshed with a
|
|
15
17
|
* new token. Will be used for single retry per request if a 401 is returned.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Returns the current SecurityOptions for the mentions service.
|
|
16
22
|
*/
|
package/dist/es2019/version.json
CHANGED
|
@@ -4,15 +4,12 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
4
4
|
export var AbstractResource = /*#__PURE__*/function () {
|
|
5
5
|
function AbstractResource() {
|
|
6
6
|
_classCallCheck(this, AbstractResource);
|
|
7
|
-
|
|
8
7
|
_defineProperty(this, "listeners", new Set());
|
|
9
8
|
}
|
|
10
|
-
|
|
11
9
|
_createClass(AbstractResource, [{
|
|
12
10
|
key: "subscribe",
|
|
13
11
|
value: function subscribe(onChange) {
|
|
14
12
|
this.listeners.add(onChange);
|
|
15
|
-
|
|
16
13
|
if (this.lastResult) {
|
|
17
14
|
// Notify subscribe of last result (i.e. initial state)
|
|
18
15
|
onChange.result(this.lastResult);
|
|
@@ -58,6 +55,5 @@ export var AbstractResource = /*#__PURE__*/function () {
|
|
|
58
55
|
});
|
|
59
56
|
}
|
|
60
57
|
}]);
|
|
61
|
-
|
|
62
58
|
return AbstractResource;
|
|
63
59
|
}();
|
package/dist/esm/serviceUtils.js
CHANGED
|
@@ -1,21 +1,17 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
|
|
3
2
|
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; }
|
|
4
|
-
|
|
5
3
|
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) { _defineProperty(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; }
|
|
6
|
-
|
|
7
4
|
import { buildCredentials } from './types';
|
|
8
5
|
var defaultRequestServiceOptions = {};
|
|
9
|
-
|
|
10
6
|
var buildUrl = function buildUrl(baseUrl) {
|
|
11
7
|
var path = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
12
8
|
var queryParams = arguments.length > 2 ? arguments[2] : undefined;
|
|
13
9
|
var secOptions = arguments.length > 3 ? arguments[3] : undefined;
|
|
14
|
-
var searchParam = new URLSearchParams(
|
|
10
|
+
var searchParam = new URLSearchParams(
|
|
11
|
+
// For relative urls, the URL class requires base to be set. It's ignored if a url is not relative.
|
|
15
12
|
// Since we only care about search params it is fine to have any base url here.
|
|
16
13
|
new URL(baseUrl, 'https://BASE_FALLBACK').search || undefined);
|
|
17
14
|
baseUrl = baseUrl.split('?')[0];
|
|
18
|
-
|
|
19
15
|
if (queryParams) {
|
|
20
16
|
for (var key in queryParams) {
|
|
21
17
|
if ({}.hasOwnProperty.call(queryParams, key)) {
|
|
@@ -23,12 +19,10 @@ var buildUrl = function buildUrl(baseUrl) {
|
|
|
23
19
|
}
|
|
24
20
|
}
|
|
25
21
|
}
|
|
26
|
-
|
|
27
22
|
if (secOptions && secOptions.params) {
|
|
28
23
|
for (var _key in secOptions.params) {
|
|
29
24
|
if ({}.hasOwnProperty.call(secOptions.params, _key)) {
|
|
30
25
|
var values = secOptions.params[_key];
|
|
31
|
-
|
|
32
26
|
if (Array.isArray(values)) {
|
|
33
27
|
for (var i = 0; i < values.length; i++) {
|
|
34
28
|
searchParam.append(_key, values[i]);
|
|
@@ -39,28 +33,21 @@ var buildUrl = function buildUrl(baseUrl) {
|
|
|
39
33
|
}
|
|
40
34
|
}
|
|
41
35
|
}
|
|
42
|
-
|
|
43
36
|
var separator = '';
|
|
44
|
-
|
|
45
37
|
if (path && baseUrl.substr(-1) !== '/' && !path.startsWith('/')) {
|
|
46
38
|
separator = '/';
|
|
47
39
|
}
|
|
48
|
-
|
|
49
40
|
var params = searchParam.toString();
|
|
50
|
-
|
|
51
41
|
if (params) {
|
|
52
42
|
params = '?' + params;
|
|
53
43
|
}
|
|
54
|
-
|
|
55
44
|
return "".concat(baseUrl).concat(separator).concat(path).concat(params);
|
|
56
45
|
};
|
|
57
|
-
|
|
58
46
|
var addToHeaders = function addToHeaders(headers, keyValues) {
|
|
59
47
|
if (keyValues) {
|
|
60
48
|
for (var key in keyValues) {
|
|
61
49
|
if ({}.hasOwnProperty.call(keyValues, key)) {
|
|
62
50
|
var values = keyValues[key];
|
|
63
|
-
|
|
64
51
|
if (Array.isArray(values)) {
|
|
65
52
|
for (var i = 0; i < values.length; i++) {
|
|
66
53
|
headers[key] = values[i];
|
|
@@ -72,43 +59,35 @@ var addToHeaders = function addToHeaders(headers, keyValues) {
|
|
|
72
59
|
}
|
|
73
60
|
}
|
|
74
61
|
};
|
|
75
|
-
|
|
76
62
|
var buildHeaders = function buildHeaders(secOptions, extraHeaders) {
|
|
77
63
|
var headers = {};
|
|
78
64
|
addToHeaders(headers, extraHeaders);
|
|
79
|
-
|
|
80
65
|
if (secOptions) {
|
|
81
66
|
addToHeaders(headers, secOptions.headers);
|
|
82
67
|
}
|
|
83
|
-
|
|
84
68
|
return headers;
|
|
85
69
|
};
|
|
70
|
+
|
|
86
71
|
/**
|
|
87
72
|
* @returns Promise containing the json response
|
|
88
73
|
*/
|
|
89
|
-
|
|
90
|
-
|
|
91
74
|
export var requestService = function requestService(serviceConfig, options) {
|
|
92
75
|
var url = serviceConfig.url,
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
76
|
+
securityProvider = serviceConfig.securityProvider,
|
|
77
|
+
refreshedSecurityProvider = serviceConfig.refreshedSecurityProvider;
|
|
96
78
|
var _ref = options || defaultRequestServiceOptions,
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
79
|
+
path = _ref.path,
|
|
80
|
+
queryParams = _ref.queryParams,
|
|
81
|
+
requestInit = _ref.requestInit;
|
|
101
82
|
var secOptions = securityProvider && securityProvider();
|
|
102
83
|
var requestUrl = buildUrl(url, path, queryParams, secOptions);
|
|
103
84
|
var headers = buildHeaders(secOptions, requestInit && requestInit.headers);
|
|
104
85
|
var credentials = buildCredentials(secOptions);
|
|
105
86
|
var ignoreResponsePayload = (options === null || options === void 0 ? void 0 : options.ignoreResponsePayload) || false;
|
|
106
|
-
|
|
107
87
|
var requestOptions = _objectSpread(_objectSpread({}, requestInit), {}, {
|
|
108
88
|
headers: headers,
|
|
109
89
|
credentials: credentials
|
|
110
90
|
});
|
|
111
|
-
|
|
112
91
|
return fetch(requestUrl, requestOptions).then(function (response) {
|
|
113
92
|
if (response.status === 204) {
|
|
114
93
|
return Promise.resolve();
|
|
@@ -126,7 +105,6 @@ export var requestService = function requestService(serviceConfig, options) {
|
|
|
126
105
|
return requestService(retryServiceConfig, options);
|
|
127
106
|
});
|
|
128
107
|
}
|
|
129
|
-
|
|
130
108
|
return Promise.reject({
|
|
131
109
|
code: response.status,
|
|
132
110
|
reason: response.statusText
|
package/dist/esm/types.js
CHANGED
|
@@ -7,10 +7,16 @@
|
|
|
7
7
|
* I = info type
|
|
8
8
|
* O = options that filter can accept
|
|
9
9
|
*/
|
|
10
|
+
|
|
10
11
|
export var buildCredentials = function buildCredentials(secOptions) {
|
|
11
12
|
return secOptions && secOptions.omitCredentials ? 'omit' : 'include';
|
|
12
13
|
};
|
|
14
|
+
|
|
13
15
|
/**
|
|
14
16
|
* Returns a promise to a SecurityOptions that has just been forcibly refreshed with a
|
|
15
17
|
* new token. Will be used for single retry per request if a 401 is returned.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Returns the current SecurityOptions for the mentions service.
|
|
16
22
|
*/
|
package/dist/esm/version.json
CHANGED
|
@@ -2,4 +2,4 @@ import { RequestServiceOptions, ServiceConfig } from './types';
|
|
|
2
2
|
/**
|
|
3
3
|
* @returns Promise containing the json response
|
|
4
4
|
*/
|
|
5
|
-
export declare const requestService: <T>(serviceConfig: ServiceConfig, options?: RequestServiceOptions
|
|
5
|
+
export declare const requestService: <T>(serviceConfig: ServiceConfig, options?: RequestServiceOptions) => Promise<T>;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -53,7 +53,7 @@ export interface SecurityOptions {
|
|
|
53
53
|
headers?: KeyValues;
|
|
54
54
|
omitCredentials?: boolean;
|
|
55
55
|
}
|
|
56
|
-
export declare const buildCredentials: (secOptions?: SecurityOptions
|
|
56
|
+
export declare const buildCredentials: (secOptions?: SecurityOptions) => "omit" | "include";
|
|
57
57
|
/**
|
|
58
58
|
* Returns a promise to a SecurityOptions that has just been forcibly refreshed with a
|
|
59
59
|
* new token. Will be used for single retry per request if a 401 is returned.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/util-service-support",
|
|
3
|
-
"version": "6.1
|
|
3
|
+
"version": "6.2.1",
|
|
4
4
|
"description": "A library of support classes for integrating React components with REST HTTP services",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -13,9 +13,10 @@
|
|
|
13
13
|
"module:es2019": "dist/es2019/index.js",
|
|
14
14
|
"types": "dist/types/index.d.ts",
|
|
15
15
|
"typesVersions": {
|
|
16
|
-
">=4.
|
|
16
|
+
">=4.5 <4.9": {
|
|
17
17
|
"*": [
|
|
18
|
-
"dist/types-ts4.
|
|
18
|
+
"dist/types-ts4.5/*",
|
|
19
|
+
"dist/types-ts4.5/index.d.ts"
|
|
19
20
|
]
|
|
20
21
|
}
|
|
21
22
|
},
|
|
@@ -23,7 +24,7 @@
|
|
|
23
24
|
"atlassian": {
|
|
24
25
|
"deprecatedAutoEntryPoints": true,
|
|
25
26
|
"releaseModel": "continuous",
|
|
26
|
-
"team": "UIP:
|
|
27
|
+
"team": "UIP: Frontend Delivery"
|
|
27
28
|
},
|
|
28
29
|
"config": {
|
|
29
30
|
"access": "public"
|
|
@@ -37,7 +38,7 @@
|
|
|
37
38
|
"es6-promise": "^4.0.5",
|
|
38
39
|
"fetch-mock": "^8.0.0",
|
|
39
40
|
"sinon": "^2.2.0",
|
|
40
|
-
"typescript": "4.
|
|
41
|
+
"typescript": "~4.9.5"
|
|
41
42
|
},
|
|
42
43
|
"keywords": [
|
|
43
44
|
"fabric",
|
package/report.api.md
CHANGED
|
@@ -1,17 +1,24 @@
|
|
|
1
|
+
<!-- API Report Version: 2.3 -->
|
|
2
|
+
|
|
1
3
|
## API Report File for "@atlaskit/util-service-support"
|
|
2
4
|
|
|
3
|
-
> Do not edit this file.
|
|
5
|
+
> Do not edit this file. This report is auto-generated using [API Extractor](https://api-extractor.com/).
|
|
6
|
+
> [Learn more about API reports](https://hello.atlassian.net/wiki/spaces/UR/pages/1825484529/Package+API+Reports)
|
|
7
|
+
|
|
8
|
+
### Table of contents
|
|
9
|
+
|
|
10
|
+
- [Main Entry Types](#main-entry-types)
|
|
11
|
+
- [Peer Dependencies](#peer-dependencies)
|
|
4
12
|
|
|
5
|
-
|
|
6
|
-
Generated API Report version: 2.0
|
|
7
|
-
-->
|
|
13
|
+
### Main Entry Types
|
|
8
14
|
|
|
9
|
-
|
|
15
|
+
<!--SECTION START: Main Entry Types-->
|
|
10
16
|
|
|
11
17
|
```ts
|
|
12
18
|
// @public (undocumented)
|
|
13
19
|
export abstract class AbstractResource<Q, R, E, I, O>
|
|
14
|
-
implements Provider<Q, R, E, I, O>
|
|
20
|
+
implements Provider<Q, R, E, I, O>
|
|
21
|
+
{
|
|
15
22
|
// (undocumented)
|
|
16
23
|
abstract filter(query?: Q, options?: O): void;
|
|
17
24
|
// (undocumented)
|
|
@@ -30,8 +37,8 @@ export abstract class AbstractResource<Q, R, E, I, O>
|
|
|
30
37
|
|
|
31
38
|
// @public (undocumented)
|
|
32
39
|
export const buildCredentials: (
|
|
33
|
-
secOptions?: SecurityOptions
|
|
34
|
-
) => '
|
|
40
|
+
secOptions?: SecurityOptions,
|
|
41
|
+
) => 'include' | 'omit';
|
|
35
42
|
|
|
36
43
|
// @public (undocumented)
|
|
37
44
|
export interface KeyValues {
|
|
@@ -65,7 +72,7 @@ export interface RefreshSecurityProvider {
|
|
|
65
72
|
// @public (undocumented)
|
|
66
73
|
const requestService: <T>(
|
|
67
74
|
serviceConfig: ServiceConfig,
|
|
68
|
-
options?: RequestServiceOptions
|
|
75
|
+
options?: RequestServiceOptions,
|
|
69
76
|
) => Promise<T>;
|
|
70
77
|
|
|
71
78
|
// @public (undocumented)
|
|
@@ -115,3 +122,15 @@ export const utils: typeof serviceUtils;
|
|
|
115
122
|
|
|
116
123
|
// (No @packageDocumentation comment for this package)
|
|
117
124
|
```
|
|
125
|
+
|
|
126
|
+
<!--SECTION END: Main Entry Types-->
|
|
127
|
+
|
|
128
|
+
### Peer Dependencies
|
|
129
|
+
|
|
130
|
+
<!--SECTION START: Peer Dependencies-->
|
|
131
|
+
|
|
132
|
+
```json
|
|
133
|
+
{}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
<!--SECTION END: Peer Dependencies-->
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
"module:es2019": "../dist/es2019/serviceResources.js",
|
|
6
6
|
"types": "../dist/types/serviceResources.d.ts",
|
|
7
7
|
"typesVersions": {
|
|
8
|
-
">=4.
|
|
8
|
+
">=4.5 <4.9": {
|
|
9
9
|
"*": [
|
|
10
|
-
"../dist/types-ts4.
|
|
10
|
+
"../dist/types-ts4.5/serviceResources.d.ts"
|
|
11
11
|
]
|
|
12
12
|
}
|
|
13
13
|
}
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
"module:es2019": "../dist/es2019/serviceUtils.js",
|
|
6
6
|
"types": "../dist/types/serviceUtils.d.ts",
|
|
7
7
|
"typesVersions": {
|
|
8
|
-
">=4.
|
|
8
|
+
">=4.5 <4.9": {
|
|
9
9
|
"*": [
|
|
10
|
-
"../dist/types-ts4.
|
|
10
|
+
"../dist/types-ts4.5/serviceUtils.d.ts"
|
|
11
11
|
]
|
|
12
12
|
}
|
|
13
13
|
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
## API Report File for "@atlaskit/util-service-support"
|
|
2
|
+
|
|
3
|
+
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
|
|
7
|
+
// @public (undocumented)
|
|
8
|
+
export abstract class AbstractResource<Q, R, E, I, O> implements Provider<Q, R, E, I, O> {
|
|
9
|
+
// (undocumented)
|
|
10
|
+
abstract filter(query?: Q, options?: O): void;
|
|
11
|
+
// (undocumented)
|
|
12
|
+
protected notifyError(error: E): void;
|
|
13
|
+
// (undocumented)
|
|
14
|
+
protected notifyInfo(info: I): void;
|
|
15
|
+
// (undocumented)
|
|
16
|
+
protected notifyNotReady(): void;
|
|
17
|
+
// (undocumented)
|
|
18
|
+
protected notifyResult(result: R): void;
|
|
19
|
+
// (undocumented)
|
|
20
|
+
subscribe(onChange: OnProviderChange<R, E, I>): void;
|
|
21
|
+
// (undocumented)
|
|
22
|
+
unsubscribe(onChange: OnProviderChange<R, E, I>): void;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// @public (undocumented)
|
|
26
|
+
export const buildCredentials: (secOptions?: SecurityOptions) => "include" | "omit";
|
|
27
|
+
|
|
28
|
+
// @public (undocumented)
|
|
29
|
+
export interface KeyValues {
|
|
30
|
+
// (undocumented)
|
|
31
|
+
[index: string]: any;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// @public (undocumented)
|
|
35
|
+
export interface OnProviderChange<R, E, I> {
|
|
36
|
+
error?(error: E): void;
|
|
37
|
+
info?(info: I): void;
|
|
38
|
+
notReady?(): void;
|
|
39
|
+
result(result: R): void;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// @public
|
|
43
|
+
export interface Provider<Q, R, E, I, O> {
|
|
44
|
+
filter(query?: Q, options?: O): void;
|
|
45
|
+
// (undocumented)
|
|
46
|
+
subscribe(onChange: OnProviderChange<R, E, I>): void;
|
|
47
|
+
// (undocumented)
|
|
48
|
+
unsubscribe(onChange: OnProviderChange<R, E, I>): void;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// @public
|
|
52
|
+
export interface RefreshSecurityProvider {
|
|
53
|
+
// (undocumented)
|
|
54
|
+
(): Promise<SecurityOptions>;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// @public (undocumented)
|
|
58
|
+
const requestService: <T>(serviceConfig: ServiceConfig, options?: RequestServiceOptions) => Promise<T>;
|
|
59
|
+
|
|
60
|
+
// @public (undocumented)
|
|
61
|
+
export interface RequestServiceOptions {
|
|
62
|
+
// (undocumented)
|
|
63
|
+
ignoreResponsePayload?: boolean;
|
|
64
|
+
// (undocumented)
|
|
65
|
+
path?: string;
|
|
66
|
+
// (undocumented)
|
|
67
|
+
queryParams?: KeyValues;
|
|
68
|
+
// (undocumented)
|
|
69
|
+
requestInit?: RequestInit;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// @public (undocumented)
|
|
73
|
+
export interface SecurityOptions {
|
|
74
|
+
// (undocumented)
|
|
75
|
+
headers?: KeyValues;
|
|
76
|
+
// (undocumented)
|
|
77
|
+
omitCredentials?: boolean;
|
|
78
|
+
// (undocumented)
|
|
79
|
+
params?: KeyValues;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// @public
|
|
83
|
+
export interface SecurityProvider {
|
|
84
|
+
// (undocumented)
|
|
85
|
+
(): SecurityOptions;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// @public (undocumented)
|
|
89
|
+
export interface ServiceConfig {
|
|
90
|
+
// (undocumented)
|
|
91
|
+
refreshedSecurityProvider?: RefreshSecurityProvider;
|
|
92
|
+
// (undocumented)
|
|
93
|
+
securityProvider?: SecurityProvider;
|
|
94
|
+
// (undocumented)
|
|
95
|
+
url: string;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
declare namespace serviceUtils {
|
|
99
|
+
export {
|
|
100
|
+
requestService
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// @public (undocumented)
|
|
105
|
+
export const utils: typeof serviceUtils;
|
|
106
|
+
|
|
107
|
+
// (No @packageDocumentation comment for this package)
|
|
108
|
+
|
|
109
|
+
```
|
package/types/package.json
CHANGED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { OnProviderChange, Provider } from './types';
|
|
2
|
-
export declare abstract class AbstractResource<Q, R, E, I, O> implements Provider<Q, R, E, I, O> {
|
|
3
|
-
private lastResult;
|
|
4
|
-
private listeners;
|
|
5
|
-
abstract filter(query?: Q, options?: O): void;
|
|
6
|
-
subscribe(onChange: OnProviderChange<R, E, I>): void;
|
|
7
|
-
unsubscribe(onChange: OnProviderChange<R, E, I>): void;
|
|
8
|
-
protected notifyResult(result: R): void;
|
|
9
|
-
protected notifyError(error: E): void;
|
|
10
|
-
protected notifyInfo(info: I): void;
|
|
11
|
-
protected notifyNotReady(): void;
|
|
12
|
-
}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
export interface OnProviderChange<R, E, I> {
|
|
2
|
-
/**
|
|
3
|
-
* Normal callback on a search result, or updated search result.
|
|
4
|
-
*/
|
|
5
|
-
result(result: R): void;
|
|
6
|
-
/**
|
|
7
|
-
* When something goes wrong, e.g. underlying service is not available.
|
|
8
|
-
*/
|
|
9
|
-
error?(error: E): void;
|
|
10
|
-
/**
|
|
11
|
-
* Information to display, e.g. due to slow searches, initial message, etc.
|
|
12
|
-
*/
|
|
13
|
-
info?(info: I): void;
|
|
14
|
-
/**
|
|
15
|
-
* Notifies if the Resource is not ready and won't respond to searches
|
|
16
|
-
* in a timely manner. Note searches that occur while not ready Will
|
|
17
|
-
* eventually be fulfilled.
|
|
18
|
-
*/
|
|
19
|
-
notReady?(): void;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Defines a typical Resource.
|
|
23
|
-
*
|
|
24
|
-
* Q = query type
|
|
25
|
-
* R = result type
|
|
26
|
-
* E = error type
|
|
27
|
-
* I = info type
|
|
28
|
-
* O = options that filter can accept
|
|
29
|
-
*/
|
|
30
|
-
export interface Provider<Q, R, E, I, O> {
|
|
31
|
-
/**
|
|
32
|
-
* Results are returned to the OnSearchResult
|
|
33
|
-
* in the subscriber.
|
|
34
|
-
*
|
|
35
|
-
* There may not be a 1-on-1 relationship between a search
|
|
36
|
-
* and a callback.
|
|
37
|
-
*
|
|
38
|
-
* For example, multiple queries may result in one callback if the
|
|
39
|
-
* responses are out of order (i.e. old responses are dropped). Or
|
|
40
|
-
* multiple callbacks may be fired, for example if the underlying data
|
|
41
|
-
* set to search has changed, the last search may be executed again
|
|
42
|
-
* with updated results.
|
|
43
|
-
*/
|
|
44
|
-
filter(query?: Q, options?: O): void;
|
|
45
|
-
subscribe(onChange: OnProviderChange<R, E, I>): void;
|
|
46
|
-
unsubscribe(onChange: OnProviderChange<R, E, I>): void;
|
|
47
|
-
}
|
|
48
|
-
export interface KeyValues {
|
|
49
|
-
[index: string]: any;
|
|
50
|
-
}
|
|
51
|
-
export interface SecurityOptions {
|
|
52
|
-
params?: KeyValues;
|
|
53
|
-
headers?: KeyValues;
|
|
54
|
-
omitCredentials?: boolean;
|
|
55
|
-
}
|
|
56
|
-
export declare const buildCredentials: (secOptions?: SecurityOptions | undefined) => "omit" | "include";
|
|
57
|
-
/**
|
|
58
|
-
* Returns a promise to a SecurityOptions that has just been forcibly refreshed with a
|
|
59
|
-
* new token. Will be used for single retry per request if a 401 is returned.
|
|
60
|
-
*/
|
|
61
|
-
export interface RefreshSecurityProvider {
|
|
62
|
-
(): Promise<SecurityOptions>;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Returns the current SecurityOptions for the mentions service.
|
|
66
|
-
*/
|
|
67
|
-
export interface SecurityProvider {
|
|
68
|
-
(): SecurityOptions;
|
|
69
|
-
}
|
|
70
|
-
export interface ServiceConfig {
|
|
71
|
-
url: string;
|
|
72
|
-
securityProvider?: SecurityProvider;
|
|
73
|
-
refreshedSecurityProvider?: RefreshSecurityProvider;
|
|
74
|
-
}
|
|
75
|
-
export interface RequestServiceOptions {
|
|
76
|
-
path?: string;
|
|
77
|
-
queryParams?: KeyValues;
|
|
78
|
-
requestInit?: RequestInit;
|
|
79
|
-
ignoreResponsePayload?: boolean;
|
|
80
|
-
}
|