@data-client/core 0.14.10 → 0.14.16
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/README.md +7 -1
- package/data_client_logo_and_text.svg +9 -8
- package/dist/index.js +62 -40
- package/dist/index.umd.min.js +1 -1
- package/legacy/actionTypes.js +23 -12
- package/legacy/actions.js +1 -1
- package/legacy/controller/actions/createExpireAll.js +3 -3
- package/legacy/controller/actions/createFetch.js +3 -3
- package/legacy/controller/actions/createInvalidate.js +3 -3
- package/legacy/controller/actions/createInvalidateAll.js +3 -3
- package/legacy/controller/actions/createOptimistic.js +3 -3
- package/legacy/controller/actions/createReset.js +3 -3
- package/legacy/controller/actions/createSet.js +3 -3
- package/legacy/controller/actions/createSetResponse.js +3 -3
- package/legacy/controller/actions/createSubscription.js +4 -4
- package/legacy/index.js +2 -1
- package/legacy/manager/LogoutManager.js +3 -3
- package/legacy/manager/NetworkManager.js +6 -6
- package/legacy/manager/SubscriptionManager.js +4 -4
- package/legacy/state/reducer/createReducer.js +11 -11
- package/legacy/state/reducer/invalidateReducer.js +3 -3
- package/legacy/state/reducer/setResponseReducer.js +4 -4
- package/lib/actionTypes.d.ts +11 -0
- package/lib/actionTypes.d.ts.map +1 -1
- package/lib/actionTypes.js +23 -12
- package/lib/actions.d.ts +13 -12
- package/lib/actions.d.ts.map +1 -1
- package/lib/actions.js +1 -1
- package/lib/controller/Controller.d.ts +2 -2
- package/lib/controller/Controller.d.ts.map +1 -1
- package/lib/controller/actions/createExpireAll.js +3 -3
- package/lib/controller/actions/createFetch.js +3 -3
- package/lib/controller/actions/createInvalidate.js +3 -3
- package/lib/controller/actions/createInvalidateAll.js +3 -3
- package/lib/controller/actions/createOptimistic.js +3 -3
- package/lib/controller/actions/createReset.js +3 -3
- package/lib/controller/actions/createSet.js +3 -3
- package/lib/controller/actions/createSetResponse.js +3 -3
- package/lib/controller/actions/createSubscription.js +4 -4
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -1
- package/lib/manager/LogoutManager.js +3 -3
- package/lib/manager/NetworkManager.js +6 -6
- package/lib/manager/SubscriptionManager.js +4 -4
- package/lib/state/reducer/createReducer.js +11 -11
- package/lib/state/reducer/invalidateReducer.js +3 -3
- package/lib/state/reducer/setResponseReducer.js +4 -4
- package/package.json +2 -2
- package/src/actionTypes.ts +23 -11
- package/src/actions.ts +23 -22
- package/src/controller/actions/createExpireAll.ts +2 -2
- package/src/controller/actions/createFetch.ts +2 -2
- package/src/controller/actions/createInvalidate.ts +2 -2
- package/src/controller/actions/createInvalidateAll.ts +2 -2
- package/src/controller/actions/createOptimistic.ts +2 -2
- package/src/controller/actions/createReset.ts +2 -2
- package/src/controller/actions/createSet.ts +2 -2
- package/src/controller/actions/createSetResponse.ts +2 -2
- package/src/controller/actions/createSubscription.ts +3 -3
- package/src/index.ts +1 -0
- package/src/manager/LogoutManager.ts +2 -2
- package/src/manager/NetworkManager.ts +5 -5
- package/src/manager/SubscriptionManager.ts +3 -3
- package/src/manager/__tests__/logoutManager.ts +3 -3
- package/src/manager/__tests__/networkManager.ts +6 -6
- package/src/manager/__tests__/subscriptionManager.ts +4 -4
- package/src/state/__tests__/reducer.ts +22 -22
- package/src/state/reducer/createReducer.ts +18 -18
- package/src/state/reducer/invalidateReducer.ts +2 -2
- package/src/state/reducer/setResponseReducer.ts +3 -3
- package/ts3.4/actionTypes.d.ts +11 -0
- package/ts3.4/actions.d.ts +13 -12
- package/ts3.4/controller/Controller.d.ts +2 -2
- package/ts3.4/index.d.ts +1 -0
package/ts3.4/actions.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Denormalize, EndpointInterface, Queryable, ResolveType, UnknownError } from '@data-client/normalizr';
|
|
2
|
-
import {
|
|
2
|
+
import { SET, RESET, FETCH, SUBSCRIBE, UNSUBSCRIBE, INVALIDATE, GC, OPTIMISTIC, INVALIDATEALL, EXPIREALL, SET_RESPONSE } from './actionTypes.js';
|
|
3
3
|
import { EndpointUpdateFunction } from './controller/types.js';
|
|
4
4
|
type EndpointAndUpdate<E extends EndpointInterface> = EndpointInterface & {
|
|
5
5
|
update?: EndpointUpdateFunction<E>;
|
|
@@ -15,14 +15,14 @@ export interface ActionMeta {
|
|
|
15
15
|
}
|
|
16
16
|
/** Action for Controller.set() */
|
|
17
17
|
export interface SetAction<S extends Queryable = any> {
|
|
18
|
-
type: typeof
|
|
18
|
+
type: typeof SET;
|
|
19
19
|
schema: S;
|
|
20
20
|
args: readonly any[];
|
|
21
21
|
meta: ActionMeta;
|
|
22
22
|
value: {} | ((previousValue: Denormalize<S>) => {});
|
|
23
23
|
}
|
|
24
24
|
export interface SetResponseActionBase<E extends EndpointAndUpdate<E> = EndpointDefault> {
|
|
25
|
-
type: typeof
|
|
25
|
+
type: typeof SET_RESPONSE;
|
|
26
26
|
endpoint: E;
|
|
27
27
|
args: readonly any[];
|
|
28
28
|
key: string;
|
|
@@ -46,7 +46,7 @@ export interface FetchMeta {
|
|
|
46
46
|
}
|
|
47
47
|
/** Action for Controller.fetch() */
|
|
48
48
|
export interface FetchAction<E extends EndpointAndUpdate<E> = EndpointDefault> {
|
|
49
|
-
type: typeof
|
|
49
|
+
type: typeof FETCH;
|
|
50
50
|
endpoint: E;
|
|
51
51
|
args: readonly [
|
|
52
52
|
...Parameters<E>
|
|
@@ -56,7 +56,7 @@ export interface FetchAction<E extends EndpointAndUpdate<E> = EndpointDefault> {
|
|
|
56
56
|
}
|
|
57
57
|
/** Action for Endpoint.getOptimisticResponse() */
|
|
58
58
|
export interface OptimisticAction<E extends EndpointAndUpdate<E> = EndpointDefault> {
|
|
59
|
-
type: typeof
|
|
59
|
+
type: typeof OPTIMISTIC;
|
|
60
60
|
endpoint: E;
|
|
61
61
|
args: readonly any[];
|
|
62
62
|
key: string;
|
|
@@ -65,42 +65,43 @@ export interface OptimisticAction<E extends EndpointAndUpdate<E> = EndpointDefau
|
|
|
65
65
|
}
|
|
66
66
|
/** Action for Controller.subscribe() */
|
|
67
67
|
export interface SubscribeAction<E extends EndpointAndUpdate<E> = EndpointDefault> {
|
|
68
|
-
type: typeof
|
|
68
|
+
type: typeof SUBSCRIBE;
|
|
69
69
|
endpoint: E;
|
|
70
70
|
args: readonly any[];
|
|
71
71
|
key: string;
|
|
72
72
|
}
|
|
73
73
|
/** Action for Controller.unsubscribe() */
|
|
74
74
|
export interface UnsubscribeAction<E extends EndpointAndUpdate<E> = EndpointDefault> {
|
|
75
|
-
type: typeof
|
|
75
|
+
type: typeof UNSUBSCRIBE;
|
|
76
76
|
endpoint: E;
|
|
77
77
|
args: readonly any[];
|
|
78
78
|
key: string;
|
|
79
79
|
}
|
|
80
80
|
export interface ExpireAllAction {
|
|
81
|
-
type: typeof
|
|
81
|
+
type: typeof EXPIREALL;
|
|
82
82
|
testKey: (key: string) => boolean;
|
|
83
83
|
}
|
|
84
84
|
export interface InvalidateAllAction {
|
|
85
|
-
type: typeof
|
|
85
|
+
type: typeof INVALIDATEALL;
|
|
86
86
|
testKey: (key: string) => boolean;
|
|
87
87
|
}
|
|
88
88
|
export interface InvalidateAction {
|
|
89
|
-
type: typeof
|
|
89
|
+
type: typeof INVALIDATE;
|
|
90
90
|
key: string;
|
|
91
91
|
}
|
|
92
92
|
export interface ResetAction {
|
|
93
|
-
type: typeof
|
|
93
|
+
type: typeof RESET;
|
|
94
94
|
date: number;
|
|
95
95
|
}
|
|
96
96
|
export interface GCAction {
|
|
97
|
-
type: typeof
|
|
97
|
+
type: typeof GC;
|
|
98
98
|
entities: [
|
|
99
99
|
string,
|
|
100
100
|
string
|
|
101
101
|
][];
|
|
102
102
|
endpoints: string[];
|
|
103
103
|
}
|
|
104
|
+
/** @see https://dataclient.io/docs/api/Actions */
|
|
104
105
|
export type ActionTypes = FetchAction | OptimisticAction | SetAction | SetResponseAction | SubscribeAction | UnsubscribeAction | InvalidateAction | InvalidateAllAction | ExpireAllAction | ResetAction | GCAction;
|
|
105
106
|
export {};
|
|
106
107
|
//# sourceMappingURL=actions.d.ts.map
|
|
@@ -40,14 +40,14 @@ export default class Controller<D extends GenericDispatch = DataClientDispatch>
|
|
|
40
40
|
*/
|
|
41
41
|
fetch: <E extends EndpointInterface & {
|
|
42
42
|
update?: EndpointUpdateFunction<E>;
|
|
43
|
-
}>(endpoint: E, ...
|
|
43
|
+
}>(endpoint: E, ...args: Parameters<E>) => E["schema"] extends undefined | null ? ReturnType<E> : Promise<Denormalize<E["schema"]>>;
|
|
44
44
|
/**
|
|
45
45
|
* Fetches only if endpoint is considered 'stale'; otherwise returns undefined
|
|
46
46
|
* @see https://dataclient.io/docs/api/Controller#fetchIfStale
|
|
47
47
|
*/
|
|
48
48
|
fetchIfStale: <E extends EndpointInterface & {
|
|
49
49
|
update?: EndpointUpdateFunction<E>;
|
|
50
|
-
}>(endpoint: E, ...
|
|
50
|
+
}>(endpoint: E, ...args: Parameters<E>) => E["schema"] extends undefined | null ? ReturnType<E> | ResolveType<E> : Promise<Denormalize<E["schema"]>> | Denormalize<E["schema"]>;
|
|
51
51
|
/**
|
|
52
52
|
* Forces refetching and suspense on useSuspense with the same Endpoint and parameters.
|
|
53
53
|
* @see https://dataclient.io/docs/api/Controller#invalidate
|
package/ts3.4/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ import * as actions_1 from './controller/actions/index.js';
|
|
|
11
11
|
export { actions_1 as actions };
|
|
12
12
|
export * from './controller/types.js';
|
|
13
13
|
import * as actionTypes_1 from './actionTypes.js';
|
|
14
|
+
/*@see https://dataclient.io/docs/api/Actions */
|
|
14
15
|
export { actionTypes_1 as actionTypes };
|
|
15
16
|
export * from './types.js';
|
|
16
17
|
export * from './manager/index.js';
|