@atlaskit/util-service-support
Advanced tools
Comparing version 6.1.3 to 6.2.0
# @atlaskit/util-service-support | ||
## 6.2.0 | ||
### Minor Changes | ||
- [`56507598609`](https://bitbucket.org/atlassian/atlassian-frontend/commits/56507598609) - Skip minor dependency bump | ||
## 6.1.3 | ||
@@ -4,0 +10,0 @@ |
"use strict"; | ||
var _typeof = require("@babel/runtime/helpers/typeof"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -12,5 +11,3 @@ value: true | ||
exports.utils = void 0; | ||
var _types = require("./types"); | ||
Object.keys(_types).forEach(function (key) { | ||
@@ -27,5 +24,3 @@ if (key === "default" || key === "__esModule") return; | ||
}); | ||
var _serviceResources = require("./serviceResources"); | ||
Object.keys(_serviceResources).forEach(function (key) { | ||
@@ -42,10 +37,6 @@ if (key === "default" || key === "__esModule") return; | ||
}); | ||
var serviceUtils = _interopRequireWildcard(require("./serviceUtils")); | ||
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); } | ||
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; } | ||
var utils = serviceUtils; | ||
exports.utils = utils; |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -9,9 +8,5 @@ value: true | ||
exports.AbstractResource = void 0; | ||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); | ||
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
var AbstractResource = /*#__PURE__*/function () { | ||
@@ -22,3 +17,2 @@ function AbstractResource() { | ||
} | ||
(0, _createClass2.default)(AbstractResource, [{ | ||
@@ -28,3 +22,2 @@ key: "subscribe", | ||
this.listeners.add(onChange); | ||
if (this.lastResult) { | ||
@@ -77,3 +70,2 @@ // Notify subscribe of last result (i.e. initial state) | ||
}(); | ||
exports.AbstractResource = AbstractResource; |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -9,13 +8,7 @@ value: true | ||
exports.requestService = void 0; | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
var _types = require("./types"); | ||
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; } | ||
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; } | ||
var defaultRequestServiceOptions = {}; | ||
var buildUrl = function buildUrl(baseUrl) { | ||
@@ -25,7 +18,7 @@ var path = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; | ||
var secOptions = arguments.length > 3 ? arguments[3] : undefined; | ||
var searchParam = new URLSearchParams( // For relative urls, the URL class requires base to be set. It's ignored if a url is not relative. | ||
var searchParam = new URLSearchParams( | ||
// For relative urls, the URL class requires base to be set. It's ignored if a url is not relative. | ||
// Since we only care about search params it is fine to have any base url here. | ||
new URL(baseUrl, 'https://BASE_FALLBACK').search || undefined); | ||
baseUrl = baseUrl.split('?')[0]; | ||
if (queryParams) { | ||
@@ -38,3 +31,2 @@ for (var key in queryParams) { | ||
} | ||
if (secOptions && secOptions.params) { | ||
@@ -44,3 +36,2 @@ for (var _key in secOptions.params) { | ||
var values = secOptions.params[_key]; | ||
if (Array.isArray(values)) { | ||
@@ -56,18 +47,12 @@ for (var i = 0; i < values.length; i++) { | ||
} | ||
var separator = ''; | ||
if (path && baseUrl.substr(-1) !== '/' && !path.startsWith('/')) { | ||
separator = '/'; | ||
} | ||
var params = searchParam.toString(); | ||
if (params) { | ||
params = '?' + params; | ||
} | ||
return "".concat(baseUrl).concat(separator).concat(path).concat(params); | ||
}; | ||
var addToHeaders = function addToHeaders(headers, keyValues) { | ||
@@ -78,3 +63,2 @@ if (keyValues) { | ||
var values = keyValues[key]; | ||
if (Array.isArray(values)) { | ||
@@ -91,28 +75,22 @@ for (var i = 0; i < values.length; i++) { | ||
}; | ||
var buildHeaders = function buildHeaders(secOptions, extraHeaders) { | ||
var headers = {}; | ||
addToHeaders(headers, extraHeaders); | ||
if (secOptions) { | ||
addToHeaders(headers, secOptions.headers); | ||
} | ||
return headers; | ||
}; | ||
/** | ||
* @returns Promise containing the json response | ||
*/ | ||
var requestService = function requestService(serviceConfig, options) { | ||
var url = serviceConfig.url, | ||
securityProvider = serviceConfig.securityProvider, | ||
refreshedSecurityProvider = serviceConfig.refreshedSecurityProvider; | ||
securityProvider = serviceConfig.securityProvider, | ||
refreshedSecurityProvider = serviceConfig.refreshedSecurityProvider; | ||
var _ref = options || defaultRequestServiceOptions, | ||
path = _ref.path, | ||
queryParams = _ref.queryParams, | ||
requestInit = _ref.requestInit; | ||
path = _ref.path, | ||
queryParams = _ref.queryParams, | ||
requestInit = _ref.requestInit; | ||
var secOptions = securityProvider && securityProvider(); | ||
@@ -123,3 +101,2 @@ var requestUrl = buildUrl(url, path, queryParams, secOptions); | ||
var ignoreResponsePayload = (options === null || options === void 0 ? void 0 : options.ignoreResponsePayload) || false; | ||
var requestOptions = _objectSpread(_objectSpread({}, requestInit), {}, { | ||
@@ -129,3 +106,2 @@ headers: headers, | ||
}); | ||
return fetch(requestUrl, requestOptions).then(function (response) { | ||
@@ -148,3 +124,2 @@ if (response.status === 204) { | ||
} | ||
return Promise.reject({ | ||
@@ -156,3 +131,2 @@ code: response.status, | ||
}; | ||
exports.requestService = requestService; |
@@ -7,3 +7,2 @@ "use strict"; | ||
exports.buildCredentials = void 0; | ||
/** | ||
@@ -18,5 +17,7 @@ * Defines a typical Resource. | ||
*/ | ||
var buildCredentials = function buildCredentials(secOptions) { | ||
return secOptions && secOptions.omitCredentials ? 'omit' : 'include'; | ||
}; | ||
/** | ||
@@ -27,3 +28,5 @@ * Returns a promise to a SecurityOptions that has just been forcibly refreshed with a | ||
/** | ||
* Returns the current SecurityOptions for the mentions service. | ||
*/ | ||
exports.buildCredentials = buildCredentials; |
{ | ||
"name": "@atlaskit/util-service-support", | ||
"version": "6.1.3" | ||
"version": "6.2.0" | ||
} |
@@ -6,6 +6,4 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty"; | ||
} | ||
subscribe(onChange) { | ||
this.listeners.add(onChange); | ||
if (this.lastResult) { | ||
@@ -16,7 +14,5 @@ // Notify subscribe of last result (i.e. initial state) | ||
} | ||
unsubscribe(onChange) { | ||
this.listeners.delete(onChange); | ||
} | ||
notifyResult(result) { | ||
@@ -27,3 +23,2 @@ this.listeners.forEach(onChange => { | ||
} | ||
notifyError(error) { | ||
@@ -36,3 +31,2 @@ this.listeners.forEach(onChange => { | ||
} | ||
notifyInfo(info) { | ||
@@ -45,3 +39,2 @@ this.listeners.forEach(onChange => { | ||
} | ||
notifyNotReady() { | ||
@@ -54,3 +47,2 @@ this.listeners.forEach(onChange => { | ||
} | ||
} |
import { buildCredentials } from './types'; | ||
const defaultRequestServiceOptions = {}; | ||
const buildUrl = (baseUrl, path = '', queryParams, secOptions) => { | ||
const searchParam = new URLSearchParams( // For relative urls, the URL class requires base to be set. It's ignored if a url is not relative. | ||
const searchParam = new URLSearchParams( | ||
// For relative urls, the URL class requires base to be set. It's ignored if a url is not relative. | ||
// Since we only care about search params it is fine to have any base url here. | ||
new URL(baseUrl, 'https://BASE_FALLBACK').search || undefined); | ||
baseUrl = baseUrl.split('?')[0]; | ||
if (queryParams) { | ||
@@ -17,3 +16,2 @@ for (const key in queryParams) { | ||
} | ||
if (secOptions && secOptions.params) { | ||
@@ -23,3 +21,2 @@ for (const key in secOptions.params) { | ||
const values = secOptions.params[key]; | ||
if (Array.isArray(values)) { | ||
@@ -35,18 +32,12 @@ for (let i = 0; i < values.length; i++) { | ||
} | ||
let separator = ''; | ||
if (path && baseUrl.substr(-1) !== '/' && !path.startsWith('/')) { | ||
separator = '/'; | ||
} | ||
let params = searchParam.toString(); | ||
if (params) { | ||
params = '?' + params; | ||
} | ||
return `${baseUrl}${separator}${path}${params}`; | ||
}; | ||
const addToHeaders = (headers, keyValues) => { | ||
@@ -57,3 +48,2 @@ if (keyValues) { | ||
const values = keyValues[key]; | ||
if (Array.isArray(values)) { | ||
@@ -70,18 +60,14 @@ for (let i = 0; i < values.length; i++) { | ||
}; | ||
const buildHeaders = (secOptions, extraHeaders) => { | ||
const headers = {}; | ||
addToHeaders(headers, extraHeaders); | ||
if (secOptions) { | ||
addToHeaders(headers, secOptions.headers); | ||
} | ||
return headers; | ||
}; | ||
/** | ||
* @returns Promise containing the json response | ||
*/ | ||
export const requestService = (serviceConfig, options) => { | ||
@@ -103,3 +89,4 @@ const { | ||
const ignoreResponsePayload = (options === null || options === void 0 ? void 0 : options.ignoreResponsePayload) || false; | ||
const requestOptions = { ...requestInit, | ||
const requestOptions = { | ||
...requestInit, | ||
headers, | ||
@@ -123,3 +110,2 @@ credentials | ||
} | ||
return Promise.reject({ | ||
@@ -126,0 +112,0 @@ code: response.status, |
@@ -10,8 +10,14 @@ /** | ||
*/ | ||
export const buildCredentials = secOptions => { | ||
return secOptions && secOptions.omitCredentials ? 'omit' : 'include'; | ||
}; | ||
/** | ||
* Returns a promise to a SecurityOptions that has just been forcibly refreshed with a | ||
* new token. Will be used for single retry per request if a 401 is returned. | ||
*/ | ||
/** | ||
* Returns the current SecurityOptions for the mentions service. | ||
*/ |
{ | ||
"name": "@atlaskit/util-service-support", | ||
"version": "6.1.3" | ||
"version": "6.2.0" | ||
} |
@@ -7,6 +7,4 @@ import _classCallCheck from "@babel/runtime/helpers/classCallCheck"; | ||
_classCallCheck(this, AbstractResource); | ||
_defineProperty(this, "listeners", new Set()); | ||
} | ||
_createClass(AbstractResource, [{ | ||
@@ -16,3 +14,2 @@ key: "subscribe", | ||
this.listeners.add(onChange); | ||
if (this.lastResult) { | ||
@@ -63,4 +60,3 @@ // Notify subscribe of last result (i.e. initial state) | ||
}]); | ||
return AbstractResource; | ||
}(); |
import _defineProperty from "@babel/runtime/helpers/defineProperty"; | ||
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; } | ||
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; } | ||
import { buildCredentials } from './types'; | ||
var defaultRequestServiceOptions = {}; | ||
var buildUrl = function buildUrl(baseUrl) { | ||
@@ -14,7 +10,7 @@ var path = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; | ||
var secOptions = arguments.length > 3 ? arguments[3] : undefined; | ||
var searchParam = new URLSearchParams( // For relative urls, the URL class requires base to be set. It's ignored if a url is not relative. | ||
var searchParam = new URLSearchParams( | ||
// For relative urls, the URL class requires base to be set. It's ignored if a url is not relative. | ||
// Since we only care about search params it is fine to have any base url here. | ||
new URL(baseUrl, 'https://BASE_FALLBACK').search || undefined); | ||
baseUrl = baseUrl.split('?')[0]; | ||
if (queryParams) { | ||
@@ -27,3 +23,2 @@ for (var key in queryParams) { | ||
} | ||
if (secOptions && secOptions.params) { | ||
@@ -33,3 +28,2 @@ for (var _key in secOptions.params) { | ||
var values = secOptions.params[_key]; | ||
if (Array.isArray(values)) { | ||
@@ -45,18 +39,12 @@ for (var i = 0; i < values.length; i++) { | ||
} | ||
var separator = ''; | ||
if (path && baseUrl.substr(-1) !== '/' && !path.startsWith('/')) { | ||
separator = '/'; | ||
} | ||
var params = searchParam.toString(); | ||
if (params) { | ||
params = '?' + params; | ||
} | ||
return "".concat(baseUrl).concat(separator).concat(path).concat(params); | ||
}; | ||
var addToHeaders = function addToHeaders(headers, keyValues) { | ||
@@ -67,3 +55,2 @@ if (keyValues) { | ||
var values = keyValues[key]; | ||
if (Array.isArray(values)) { | ||
@@ -80,28 +67,22 @@ for (var i = 0; i < values.length; i++) { | ||
}; | ||
var buildHeaders = function buildHeaders(secOptions, extraHeaders) { | ||
var headers = {}; | ||
addToHeaders(headers, extraHeaders); | ||
if (secOptions) { | ||
addToHeaders(headers, secOptions.headers); | ||
} | ||
return headers; | ||
}; | ||
/** | ||
* @returns Promise containing the json response | ||
*/ | ||
export var requestService = function requestService(serviceConfig, options) { | ||
var url = serviceConfig.url, | ||
securityProvider = serviceConfig.securityProvider, | ||
refreshedSecurityProvider = serviceConfig.refreshedSecurityProvider; | ||
securityProvider = serviceConfig.securityProvider, | ||
refreshedSecurityProvider = serviceConfig.refreshedSecurityProvider; | ||
var _ref = options || defaultRequestServiceOptions, | ||
path = _ref.path, | ||
queryParams = _ref.queryParams, | ||
requestInit = _ref.requestInit; | ||
path = _ref.path, | ||
queryParams = _ref.queryParams, | ||
requestInit = _ref.requestInit; | ||
var secOptions = securityProvider && securityProvider(); | ||
@@ -112,3 +93,2 @@ var requestUrl = buildUrl(url, path, queryParams, secOptions); | ||
var ignoreResponsePayload = (options === null || options === void 0 ? void 0 : options.ignoreResponsePayload) || false; | ||
var requestOptions = _objectSpread(_objectSpread({}, requestInit), {}, { | ||
@@ -118,3 +98,2 @@ headers: headers, | ||
}); | ||
return fetch(requestUrl, requestOptions).then(function (response) { | ||
@@ -137,3 +116,2 @@ if (response.status === 204) { | ||
} | ||
return Promise.reject({ | ||
@@ -140,0 +118,0 @@ code: response.status, |
@@ -10,8 +10,14 @@ /** | ||
*/ | ||
export var buildCredentials = function buildCredentials(secOptions) { | ||
return secOptions && secOptions.omitCredentials ? 'omit' : 'include'; | ||
}; | ||
/** | ||
* Returns a promise to a SecurityOptions that has just been forcibly refreshed with a | ||
* new token. Will be used for single retry per request if a 401 is returned. | ||
*/ | ||
/** | ||
* Returns the current SecurityOptions for the mentions service. | ||
*/ |
{ | ||
"name": "@atlaskit/util-service-support", | ||
"version": "6.1.3" | ||
"version": "6.2.0" | ||
} |
{ | ||
"name": "@atlaskit/util-service-support", | ||
"version": "6.1.3", | ||
"version": "6.2.0", | ||
"description": "A library of support classes for integrating React components with REST HTTP services", | ||
@@ -15,9 +15,2 @@ "publishConfig": { | ||
"types": "dist/types/index.d.ts", | ||
"typesVersions": { | ||
">=4.0 <4.5": { | ||
"*": [ | ||
"dist/types-ts4.0/*" | ||
] | ||
} | ||
}, | ||
"atlaskit:src": "src/index.ts", | ||
@@ -27,3 +20,3 @@ "atlassian": { | ||
"releaseModel": "continuous", | ||
"team": "UIP: Monorepo" | ||
"team": "UIP: Frontend Delivery" | ||
}, | ||
@@ -30,0 +23,0 @@ "config": { |
@@ -0,15 +1,22 @@ | ||
<!-- API Report Version: 2.3 --> | ||
## API Report File for "@atlaskit/util-service-support" | ||
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). | ||
> Do not edit this file. This report is auto-generated using [API Extractor](https://api-extractor.com/). | ||
> [Learn more about API reports](https://hello.atlassian.net/wiki/spaces/UR/pages/1825484529/Package+API+Reports) | ||
<!-- | ||
Generated API Report version: 2.0 | ||
--> | ||
### Table of contents | ||
[Learn more about API reports](https://hello.atlassian.net/wiki/spaces/UR/pages/1825484529/Package+API+Reports) | ||
- [Main Entry Types](#main-entry-types) | ||
- [Peer Dependencies](#peer-dependencies) | ||
### Main Entry Types | ||
<!--SECTION START: Main Entry Types--> | ||
```ts | ||
// @public (undocumented) | ||
export abstract class AbstractResource<Q, R, E, I, O> | ||
implements Provider<Q, R, E, I, O> { | ||
implements Provider<Q, R, E, I, O> | ||
{ | ||
// (undocumented) | ||
@@ -34,3 +41,3 @@ abstract filter(query?: Q, options?: O): void; | ||
secOptions?: SecurityOptions | undefined, | ||
) => 'omit' | 'include'; | ||
) => 'include' | 'omit'; | ||
@@ -119,1 +126,13 @@ // @public (undocumented) | ||
``` | ||
<!--SECTION END: Main Entry Types--> | ||
### Peer Dependencies | ||
<!--SECTION START: Peer Dependencies--> | ||
```json | ||
{} | ||
``` | ||
<!--SECTION END: Peer Dependencies--> |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
45902
29
765