@atlaskit/util-service-support 6.2.1 → 6.2.2

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,11 @@
1
1
  # @atlaskit/util-service-support
2
2
 
3
+ ## 6.2.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`9d00501a414`](https://bitbucket.org/atlassian/atlassian-frontend/commits/9d00501a414) - Ensure legacy types are published for TS 4.5-4.8
8
+
3
9
  ## 6.2.1
4
10
 
5
11
  ### Patch Changes
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "name": "@atlaskit/util-service-support",
3
- "version": "6.2.1"
3
+ "version": "6.2.2"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "name": "@atlaskit/util-service-support",
3
- "version": "6.2.1"
3
+ "version": "6.2.2"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "name": "@atlaskit/util-service-support",
3
- "version": "6.2.1"
3
+ "version": "6.2.2"
4
4
  }
@@ -0,0 +1,4 @@
1
+ export * from './types';
2
+ export * from './serviceResources';
3
+ import * as serviceUtils from './serviceUtils';
4
+ export declare const utils: typeof serviceUtils;
@@ -0,0 +1,12 @@
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
+ }
@@ -0,0 +1,5 @@
1
+ import { RequestServiceOptions, ServiceConfig } from './types';
2
+ /**
3
+ * @returns Promise containing the json response
4
+ */
5
+ export declare const requestService: <T>(serviceConfig: ServiceConfig, options?: RequestServiceOptions) => Promise<T>;
@@ -0,0 +1,80 @@
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) => "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
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/util-service-support",
3
- "version": "6.2.1",
3
+ "version": "6.2.2",
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/"