@atlaskit/util-service-support 6.4.2 → 7.0.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 CHANGED
@@ -1,5 +1,40 @@
1
1
  # @atlaskit/util-service-support
2
2
 
3
+ ## 7.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`ee28cf33718b0`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ee28cf33718b0) -
8
+ Add @atlassian/react-compiler-gating as a runtime dependency to enable React Compiler platform
9
+ gating.
10
+ - Updated dependencies
11
+
12
+ ## 7.0.0
13
+
14
+ ### Major Changes
15
+
16
+ - [`f2dc9097319f0`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/f2dc9097319f0) - ###
17
+ Dropped support for _legacy_ Typescript 4 types. **Typescript 5 is now the new minimum**.
18
+
19
+ Removes the `typesVersions` property and `dist/types-ts4.5` directory from the dist.
20
+
21
+ Types are now exclusively via the `"types": "dist/types/index.d.ts"` property.
22
+
23
+ ```diff
24
+ - "typesVersions": {
25
+ - ">=4.5 <4.9": {
26
+ - "*": [
27
+ - "dist/types-ts4.5/*",
28
+ - "dist/types-ts4.5/index.d.ts"
29
+ - ]
30
+ - }
31
+ - },
32
+ ```
33
+
34
+ ### Patch Changes
35
+
36
+ - Updated dependencies
37
+
3
38
  ## 6.4.2
4
39
 
5
40
  ### Patch Changes
@@ -27,6 +27,9 @@
27
27
  },
28
28
  {
29
29
  "path": "../../../react-ufo/atlaskit/afm-cc/tsconfig.json"
30
+ },
31
+ {
32
+ "path": "../../../react-compiler/react-compiler-gating/afm-cc/tsconfig.json"
30
33
  }
31
34
  ]
32
35
  }
@@ -27,6 +27,9 @@
27
27
  },
28
28
  {
29
29
  "path": "../../../react-ufo/atlaskit/afm-products/tsconfig.json"
30
+ },
31
+ {
32
+ "path": "../../../react-compiler/react-compiler-gating/afm-products/tsconfig.json"
30
33
  }
31
34
  ]
32
35
  }
@@ -43,8 +43,9 @@ var _requestServiceMultipart = exports.requestServiceMultipart = /*#__PURE__*/fu
43
43
  requestOptions,
44
44
  fetchResponse,
45
45
  parts,
46
- _args = arguments;
47
- return _regenerator.default.wrap(function _callee$(_context) {
46
+ _args = arguments,
47
+ _t;
48
+ return _regenerator.default.wrap(function (_context) {
48
49
  while (1) switch (_context.prev = _context.next) {
49
50
  case 0:
50
51
  options = _args.length > 1 && _args[1] !== undefined ? _args[1] : _shared.defaultRequestServiceOptions;
@@ -62,38 +63,38 @@ var _requestServiceMultipart = exports.requestServiceMultipart = /*#__PURE__*/fu
62
63
  headers: _objectSpread(_objectSpread({}, headers), tracingHeaders),
63
64
  credentials: credentials
64
65
  });
65
- _context.next = 11;
66
+ _context.next = 1;
66
67
  return fetch(requestUrl, requestOptions);
67
- case 11:
68
+ case 1:
68
69
  fetchResponse = _context.sent;
69
- _context.next = 14;
70
+ _context.next = 2;
70
71
  return (0, _browser.meros)(fetchResponse);
71
- case 14:
72
+ case 2:
72
73
  parts = _context.sent;
73
74
  if (!(fetchResponse.ok && fetchResponse.status !== 204)) {
74
- _context.next = 24;
75
+ _context.next = 5;
75
76
  break;
76
77
  }
77
78
  if (!(parts[Symbol.asyncIterator] < 'u')) {
78
- _context.next = 18;
79
+ _context.next = 3;
79
80
  break;
80
81
  }
81
82
  return _context.abrupt("return", {
82
83
  isMultipart: true,
83
84
  parts: parts
84
85
  });
85
- case 18:
86
- _context.next = 20;
86
+ case 3:
87
+ _context.next = 4;
87
88
  return parts.json();
88
- case 20:
89
- _context.t0 = _context.sent;
89
+ case 4:
90
+ _t = _context.sent;
90
91
  return _context.abrupt("return", {
91
92
  isMultipart: false,
92
- body: _context.t0
93
+ body: _t
93
94
  });
94
- case 24:
95
+ case 5:
95
96
  if (!(fetchResponse.status === 401 && refreshedSecurityProvider)) {
96
- _context.next = 26;
97
+ _context.next = 6;
97
98
  break;
98
99
  }
99
100
  return _context.abrupt("return", refreshedSecurityProvider().then(function (newSecOptions) {
@@ -105,12 +106,12 @@ var _requestServiceMultipart = exports.requestServiceMultipart = /*#__PURE__*/fu
105
106
  };
106
107
  return _requestServiceMultipart(retryServiceConfig, options);
107
108
  }));
108
- case 26:
109
+ case 6:
109
110
  return _context.abrupt("return", Promise.reject({
110
111
  code: fetchResponse.status,
111
112
  reason: fetchResponse.statusText
112
113
  }));
113
- case 27:
114
+ case 7:
114
115
  case "end":
115
116
  return _context.stop();
116
117
  }
@@ -37,8 +37,9 @@ var _requestServiceMultipart = /*#__PURE__*/function () {
37
37
  requestOptions,
38
38
  fetchResponse,
39
39
  parts,
40
- _args = arguments;
41
- return _regeneratorRuntime.wrap(function _callee$(_context) {
40
+ _args = arguments,
41
+ _t;
42
+ return _regeneratorRuntime.wrap(function (_context) {
42
43
  while (1) switch (_context.prev = _context.next) {
43
44
  case 0:
44
45
  options = _args.length > 1 && _args[1] !== undefined ? _args[1] : defaultRequestServiceOptions;
@@ -56,38 +57,38 @@ var _requestServiceMultipart = /*#__PURE__*/function () {
56
57
  headers: _objectSpread(_objectSpread({}, headers), tracingHeaders),
57
58
  credentials: credentials
58
59
  });
59
- _context.next = 11;
60
+ _context.next = 1;
60
61
  return fetch(requestUrl, requestOptions);
61
- case 11:
62
+ case 1:
62
63
  fetchResponse = _context.sent;
63
- _context.next = 14;
64
+ _context.next = 2;
64
65
  return meros(fetchResponse);
65
- case 14:
66
+ case 2:
66
67
  parts = _context.sent;
67
68
  if (!(fetchResponse.ok && fetchResponse.status !== 204)) {
68
- _context.next = 24;
69
+ _context.next = 5;
69
70
  break;
70
71
  }
71
72
  if (!(parts[Symbol.asyncIterator] < 'u')) {
72
- _context.next = 18;
73
+ _context.next = 3;
73
74
  break;
74
75
  }
75
76
  return _context.abrupt("return", {
76
77
  isMultipart: true,
77
78
  parts: parts
78
79
  });
79
- case 18:
80
- _context.next = 20;
80
+ case 3:
81
+ _context.next = 4;
81
82
  return parts.json();
82
- case 20:
83
- _context.t0 = _context.sent;
83
+ case 4:
84
+ _t = _context.sent;
84
85
  return _context.abrupt("return", {
85
86
  isMultipart: false,
86
- body: _context.t0
87
+ body: _t
87
88
  });
88
- case 24:
89
+ case 5:
89
90
  if (!(fetchResponse.status === 401 && refreshedSecurityProvider)) {
90
- _context.next = 26;
91
+ _context.next = 6;
91
92
  break;
92
93
  }
93
94
  return _context.abrupt("return", refreshedSecurityProvider().then(function (newSecOptions) {
@@ -99,12 +100,12 @@ var _requestServiceMultipart = /*#__PURE__*/function () {
99
100
  };
100
101
  return _requestServiceMultipart(retryServiceConfig, options);
101
102
  }));
102
- case 26:
103
+ case 6:
103
104
  return _context.abrupt("return", Promise.reject({
104
105
  code: fetchResponse.status,
105
106
  reason: fetchResponse.statusText
106
107
  }));
107
- case 27:
108
+ case 7:
108
109
  case "end":
109
110
  return _context.stop();
110
111
  }
@@ -3,12 +3,5 @@
3
3
  "main": "../dist/cjs/multipartServiceUtils.js",
4
4
  "module": "../dist/esm/multipartServiceUtils.js",
5
5
  "module:es2019": "../dist/es2019/multipartServiceUtils.js",
6
- "types": "../dist/types/multipartServiceUtils.d.ts",
7
- "typesVersions": {
8
- ">=4.5 <5.9": {
9
- "*": [
10
- "../dist/types-ts4.5/multipartServiceUtils.d.ts"
11
- ]
12
- }
13
- }
6
+ "types": "../dist/types/multipartServiceUtils.d.ts"
14
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/util-service-support",
3
- "version": "6.4.2",
3
+ "version": "7.0.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/"
@@ -12,14 +12,6 @@
12
12
  "module": "dist/esm/index.js",
13
13
  "module:es2019": "dist/es2019/index.js",
14
14
  "types": "dist/types/index.d.ts",
15
- "typesVersions": {
16
- ">=4.5 <4.9": {
17
- "*": [
18
- "dist/types-ts4.5/*",
19
- "dist/types-ts4.5/index.d.ts"
20
- ]
21
- }
22
- },
23
15
  "atlaskit:src": "src/index.ts",
24
16
  "atlassian": {
25
17
  "react-compiler": {
@@ -35,13 +27,13 @@
35
27
  "access": "public"
36
28
  },
37
29
  "dependencies": {
38
- "@atlaskit/platform-feature-flags": "^1.1.0",
39
- "@atlaskit/react-ufo": "^6.0.0",
30
+ "@atlaskit/platform-feature-flags": "^2.0.0",
31
+ "@atlaskit/react-ufo": "^7.1.0",
32
+ "@atlassian/react-compiler-gating": "^0.2.0",
40
33
  "@babel/runtime": "^7.0.0",
41
34
  "meros": "^1.3.0"
42
35
  },
43
36
  "devDependencies": {
44
- "@atlassian/react-compiler-gating": "workspace:^",
45
37
  "es6-promise": "^4.0.5",
46
38
  "fetch-mock": "^8.0.0",
47
39
  "sinon": "^2.2.0"
@@ -3,12 +3,5 @@
3
3
  "main": "../dist/cjs/serviceResources.js",
4
4
  "module": "../dist/esm/serviceResources.js",
5
5
  "module:es2019": "../dist/es2019/serviceResources.js",
6
- "types": "../dist/types/serviceResources.d.ts",
7
- "typesVersions": {
8
- ">=4.5 <5.9": {
9
- "*": [
10
- "../dist/types-ts4.5/serviceResources.d.ts"
11
- ]
12
- }
13
- }
6
+ "types": "../dist/types/serviceResources.d.ts"
14
7
  }
@@ -3,12 +3,5 @@
3
3
  "main": "../dist/cjs/serviceUtils.js",
4
4
  "module": "../dist/esm/serviceUtils.js",
5
5
  "module:es2019": "../dist/es2019/serviceUtils.js",
6
- "types": "../dist/types/serviceUtils.d.ts",
7
- "typesVersions": {
8
- ">=4.5 <5.9": {
9
- "*": [
10
- "../dist/types-ts4.5/serviceUtils.d.ts"
11
- ]
12
- }
13
- }
6
+ "types": "../dist/types/serviceUtils.d.ts"
14
7
  }
@@ -3,12 +3,5 @@
3
3
  "main": "../dist/cjs/types.js",
4
4
  "module": "../dist/esm/types.js",
5
5
  "module:es2019": "../dist/es2019/types.js",
6
- "types": "../dist/types/types.d.ts",
7
- "typesVersions": {
8
- ">=4.5 <5.9": {
9
- "*": [
10
- "../dist/types-ts4.5/types.d.ts"
11
- ]
12
- }
13
- }
6
+ "types": "../dist/types/types.d.ts"
14
7
  }
@@ -1,7 +0,0 @@
1
- export * from './types';
2
- export * from './serviceResources';
3
- import * as serviceUtils from './serviceUtils';
4
- import * as multipartServiceUtils from './multipartServiceUtils';
5
- export declare const utils: typeof serviceUtils;
6
- export declare const multipartUtils: typeof multipartServiceUtils;
7
- export type { RequestServiceResult, PartsGenerator, MultiPartFetchResult, BodyResult, } from './multipartServiceUtils';
@@ -1,34 +0,0 @@
1
- import { type RequestServiceOptions, type ServiceConfig } from './types';
2
- export type PartsGenerator<PartsType> = AsyncGenerator<Part<PartsType, unknown>>;
3
- export type MultiPartFetchResult<PartsType> = {
4
- isMultipart: true;
5
- parts: PartsGenerator<PartsType>;
6
- };
7
- export type BodyResult<T> = {
8
- body: T;
9
- isMultipart: false;
10
- };
11
- export type RequestServiceResult<PartsType, BodyType> = MultiPartFetchResult<PartsType> | BodyResult<BodyType>;
12
- /** Copied from meros types, as there are difficulties with resolving the type in CI */
13
- export type Part<Body, Fallback> = {
14
- body: Fallback;
15
- headers: Record<string, string>;
16
- json: false;
17
- } | {
18
- body: Body;
19
- headers: Record<string, string>;
20
- json: true;
21
- };
22
- type Options = Omit<RequestServiceOptions, 'ignoreResponsePayload'>;
23
- /**
24
- * Make a request that **may** result in an HTTP multipart response from the server.
25
- * @returns an object with a parsed JSON body OR an object with the parts from
26
- * the HTTP multipart response.
27
- *
28
- * PartsType type parameter specifies the type of the response when the server response
29
- * is multipart.
30
- *
31
- * BodyType specifies the type of the response when the server response is not multipart
32
- */
33
- export declare const requestServiceMultipart: <PartsType, BodyType>(serviceConfig: ServiceConfig, options?: Options) => Promise<RequestServiceResult<PartsType, BodyType>>;
34
- export {};
@@ -1,12 +0,0 @@
1
- import { type OnProviderChange, type 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,10 +0,0 @@
1
- import { type RequestServiceOptions, type ServiceConfig } from './types';
2
- /**
3
- * Extracts tracing headers (x-trace-id, atl-request-id) from a Response object.
4
- * Returns only headers that are present in the response.
5
- */
6
- export declare const extractTracingHeaders: (response: Response) => Record<string, string>;
7
- /**
8
- * @returns Promise containing the json response
9
- */
10
- export declare const requestService: <T>(serviceConfig: ServiceConfig, options?: RequestServiceOptions) => Promise<T>;
@@ -1,4 +0,0 @@
1
- import type { RequestServiceOptions, KeyValues, SecurityOptions } from './types';
2
- export declare const defaultRequestServiceOptions: RequestServiceOptions;
3
- export declare const buildUrl: (baseUrl: string, path?: string, queryParams?: KeyValues, secOptions?: SecurityOptions) => string;
4
- export declare const buildHeaders: (secOptions?: SecurityOptions, extraHeaders?: KeyValues) => KeyValues;
@@ -1,85 +0,0 @@
1
- export interface OnProviderChange<R, E, I> {
2
- /**
3
- * When something goes wrong, e.g. underlying service is not available.
4
- */
5
- error?(error: E): void;
6
- /**
7
- * Information to display, e.g. due to slow searches, initial message, etc.
8
- */
9
- info?(info: I): void;
10
- /**
11
- * Notifies if the Resource is not ready and won't respond to searches
12
- * in a timely manner. Note searches that occur while not ready Will
13
- * eventually be fulfilled.
14
- */
15
- notReady?(): void;
16
- /**
17
- * Normal callback on a search result, or updated search result.
18
- */
19
- result(result: R): 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
- headers?: KeyValues;
53
- omitCredentials?: boolean;
54
- params?: KeyValues;
55
- }
56
- export declare const buildCredentials: (secOptions?: SecurityOptions) => "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
- refreshedSecurityProvider?: RefreshSecurityProvider;
72
- securityProvider?: SecurityProvider;
73
- url: string;
74
- }
75
- export interface RequestServiceOptions {
76
- ignoreResponsePayload?: boolean;
77
- path?: string;
78
- queryParams?: KeyValues;
79
- /**
80
- * Optional callback invoked with tracing headers extracted from the response.
81
- * Only exposes x-trace-id and atl-request-id headers.
82
- */
83
- reportTracingHeaders?: (headers: Record<string, string>) => void;
84
- requestInit?: RequestInit;
85
- }