@data-client/core 0.1.0 → 0.2.0
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/dist/index.js +133 -409
- package/dist/index.umd.min.js +1 -1
- package/dist/next.js +61 -101
- package/legacy/actionTypes.js +2 -2
- package/legacy/controller/Controller.js +276 -6
- package/legacy/controller/createFetch.js +3 -14
- package/legacy/controller/createInvalidate.js +1 -1
- package/legacy/controller/createInvalidateAll.js +1 -1
- package/legacy/controller/createOptimistic.js +1 -7
- package/legacy/controller/createReset.js +1 -1
- package/legacy/controller/createSet.js +31 -0
- package/legacy/controller/createSubscription.js +3 -7
- package/legacy/index.js +2 -5
- package/legacy/internal.js +2 -2
- package/legacy/manager/DevtoolsManager.js +2 -2
- package/legacy/manager/LogoutManager.js +2 -2
- package/legacy/manager/NetworkManager.js +28 -59
- package/legacy/manager/PollingSubscription.js +18 -27
- package/legacy/manager/SubscriptionManager.js +16 -42
- package/legacy/middlewareTypes.js +1 -1
- package/legacy/newActions.js +1 -1
- package/legacy/next/index.js +3 -3
- package/legacy/state/reducer/createReducer.js +2 -6
- package/legacy/state/reducer/fetchReducer.js +3 -13
- package/legacy/state/reducer/invalidateReducer.js +1 -1
- package/legacy/state/reducer/setReducer.js +9 -16
- package/legacy/types.js +2 -6
- package/lib/actionTypes.d.ts +1 -0
- package/lib/actionTypes.d.ts.map +1 -1
- package/lib/actionTypes.js +2 -2
- package/lib/controller/Controller.d.ts +126 -6
- package/lib/controller/Controller.d.ts.map +1 -1
- package/lib/controller/Controller.js +276 -6
- package/lib/controller/createFetch.d.ts +2 -2
- package/lib/controller/createFetch.d.ts.map +1 -1
- package/lib/controller/createFetch.js +3 -14
- package/lib/controller/createInvalidate.d.ts +1 -1
- package/lib/controller/createInvalidate.d.ts.map +1 -1
- package/lib/controller/createInvalidate.js +1 -1
- package/lib/controller/createInvalidateAll.d.ts +1 -1
- package/lib/controller/createInvalidateAll.d.ts.map +1 -1
- package/lib/controller/createInvalidateAll.js +1 -1
- package/lib/controller/createOptimistic.d.ts +2 -2
- package/lib/controller/createOptimistic.d.ts.map +1 -1
- package/lib/controller/createOptimistic.js +1 -7
- package/lib/controller/createReset.d.ts +1 -1
- package/lib/controller/createReset.d.ts.map +1 -1
- package/lib/controller/createReset.js +1 -1
- package/lib/controller/{createReceive.d.ts → createSet.d.ts} +6 -6
- package/lib/controller/createSet.d.ts.map +1 -0
- package/lib/controller/createSet.js +31 -0
- package/lib/controller/createSubscription.d.ts +3 -3
- package/lib/controller/createSubscription.d.ts.map +1 -1
- package/lib/controller/createSubscription.js +3 -7
- package/lib/index.d.ts +2 -6
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -5
- package/lib/internal.d.ts +1 -1
- package/lib/internal.d.ts.map +1 -1
- package/lib/internal.js +2 -2
- package/lib/manager/DevtoolsManager.d.ts +1 -1
- package/lib/manager/DevtoolsManager.js +2 -2
- package/lib/manager/LogoutManager.d.ts +4 -5
- package/lib/manager/LogoutManager.d.ts.map +1 -1
- package/lib/manager/LogoutManager.js +2 -2
- package/lib/manager/NetworkManager.d.ts +4 -5
- package/lib/manager/NetworkManager.d.ts.map +1 -1
- package/lib/manager/NetworkManager.js +28 -61
- package/lib/manager/PollingSubscription.d.ts +9 -9
- package/lib/manager/PollingSubscription.d.ts.map +1 -1
- package/lib/manager/PollingSubscription.js +18 -27
- package/lib/manager/SubscriptionManager.d.ts +10 -15
- package/lib/manager/SubscriptionManager.d.ts.map +1 -1
- package/lib/manager/SubscriptionManager.js +16 -42
- package/lib/middlewareTypes.d.ts +5 -5
- package/lib/middlewareTypes.d.ts.map +1 -1
- package/lib/middlewareTypes.js +1 -1
- package/lib/newActions.d.ts +26 -18
- package/lib/newActions.d.ts.map +1 -1
- package/lib/newActions.js +1 -1
- package/lib/next/index.d.ts +2 -2
- package/lib/next/index.d.ts.map +1 -1
- package/lib/next/index.js +3 -3
- package/lib/state/reducer/createReducer.d.ts.map +1 -1
- package/lib/state/reducer/createReducer.js +2 -6
- package/lib/state/reducer/fetchReducer.d.ts +1 -2
- package/lib/state/reducer/fetchReducer.d.ts.map +1 -1
- package/lib/state/reducer/fetchReducer.js +3 -14
- package/lib/state/reducer/invalidateReducer.d.ts +3 -4
- package/lib/state/reducer/invalidateReducer.d.ts.map +1 -1
- package/lib/state/reducer/invalidateReducer.js +1 -1
- package/lib/state/reducer/setReducer.d.ts +2 -38
- package/lib/state/reducer/setReducer.d.ts.map +1 -1
- package/lib/state/reducer/setReducer.js +9 -17
- package/lib/types.d.ts +9 -30
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js +2 -6
- package/package.json +3 -3
- package/src/actionTypes.ts +1 -1
- package/src/controller/Controller.ts +491 -10
- package/src/controller/createFetch.ts +4 -19
- package/src/controller/createInvalidate.ts +1 -1
- package/src/controller/createInvalidateAll.ts +1 -1
- package/src/controller/createOptimistic.ts +3 -9
- package/src/controller/createReset.ts +1 -1
- package/src/controller/{createReceive.ts → createSet.ts} +9 -17
- package/src/controller/createSubscription.ts +3 -10
- package/src/index.ts +2 -16
- package/src/internal.ts +1 -1
- package/src/manager/DevtoolsManager.ts +1 -1
- package/src/manager/LogoutManager.ts +4 -5
- package/src/manager/NetworkManager.ts +31 -80
- package/src/manager/PollingSubscription.ts +26 -27
- package/src/manager/SubscriptionManager.ts +22 -54
- package/src/manager/__tests__/__snapshots__/pollingSubscription.ts.snap +10 -8
- package/src/manager/__tests__/logoutManager.ts +5 -5
- package/src/manager/__tests__/manager.ts +2 -4
- package/src/manager/__tests__/networkManager.ts +8 -42
- package/src/manager/__tests__/pollingSubscription.ts +259 -151
- package/src/manager/__tests__/subscriptionManager.ts +7 -13
- package/src/middlewareTypes.ts +5 -10
- package/src/newActions.ts +33 -23
- package/src/next/index.ts +2 -2
- package/src/state/__tests__/reducer.ts +59 -297
- package/src/state/reducer/createReducer.ts +3 -11
- package/src/state/reducer/fetchReducer.ts +5 -18
- package/src/state/reducer/invalidateReducer.ts +2 -2
- package/src/state/reducer/setReducer.ts +10 -22
- package/src/types.ts +9 -78
- package/ts3.4/actionTypes.d.ts +1 -0
- package/ts3.4/controller/Controller.d.ts +168 -6
- package/ts3.4/controller/createFetch.d.ts +2 -2
- package/ts3.4/controller/createInvalidate.d.ts +1 -1
- package/ts3.4/controller/createInvalidateAll.d.ts +1 -1
- package/ts3.4/controller/createOptimistic.d.ts +1 -1
- package/ts3.4/controller/createReset.d.ts +1 -1
- package/ts3.4/controller/{createReceive.d.ts → createSet.d.ts} +6 -6
- package/ts3.4/controller/createSubscription.d.ts +3 -3
- package/ts3.4/index.d.ts +2 -7
- package/ts3.4/internal.d.ts +1 -1
- package/ts3.4/manager/DevtoolsManager.d.ts +1 -1
- package/ts3.4/manager/LogoutManager.d.ts +4 -5
- package/ts3.4/manager/NetworkManager.d.ts +4 -5
- package/ts3.4/manager/PollingSubscription.d.ts +9 -9
- package/ts3.4/manager/SubscriptionManager.d.ts +10 -15
- package/ts3.4/middlewareTypes.d.ts +5 -5
- package/ts3.4/newActions.d.ts +26 -18
- package/ts3.4/next/index.d.ts +2 -2
- package/ts3.4/state/reducer/fetchReducer.d.ts +1 -2
- package/ts3.4/state/reducer/invalidateReducer.d.ts +3 -4
- package/ts3.4/state/reducer/setReducer.d.ts +2 -38
- package/ts3.4/types.d.ts +8 -30
- package/legacy/compatibleActions.js +0 -2
- package/legacy/controller/BaseController.js +0 -289
- package/legacy/controller/createReceive.js +0 -36
- package/legacy/endpoint/index.js +0 -2
- package/legacy/endpoint/shapes.js +0 -2
- package/legacy/endpoint/types.js +0 -2
- package/legacy/legacyActions.js +0 -2
- package/legacy/next/Controller.js +0 -24
- package/legacy/previousActions.js +0 -2
- package/legacy/state/applyUpdatersToResults.js +0 -4
- package/legacy/state/legacy-actions/createFetch.js +0 -62
- package/legacy/state/legacy-actions/createReceive.js +0 -37
- package/legacy/state/legacy-actions/createReceiveError.js +0 -28
- package/legacy/state/legacy-actions/index.js +0 -4
- package/legacy/state/reducerInstance.js +0 -9
- package/lib/compatibleActions.d.ts +0 -47
- package/lib/compatibleActions.d.ts.map +0 -1
- package/lib/compatibleActions.js +0 -2
- package/lib/controller/BaseController.d.ts +0 -128
- package/lib/controller/BaseController.d.ts.map +0 -1
- package/lib/controller/BaseController.js +0 -289
- package/lib/controller/createReceive.d.ts.map +0 -1
- package/lib/controller/createReceive.js +0 -36
- package/lib/endpoint/index.d.ts +0 -3
- package/lib/endpoint/index.d.ts.map +0 -1
- package/lib/endpoint/index.js +0 -2
- package/lib/endpoint/shapes.d.ts +0 -25
- package/lib/endpoint/shapes.d.ts.map +0 -1
- package/lib/endpoint/shapes.js +0 -2
- package/lib/endpoint/types.d.ts +0 -45
- package/lib/endpoint/types.d.ts.map +0 -1
- package/lib/endpoint/types.js +0 -2
- package/lib/legacyActions.d.ts +0 -92
- package/lib/legacyActions.d.ts.map +0 -1
- package/lib/legacyActions.js +0 -2
- package/lib/next/Controller.d.ts +0 -14
- package/lib/next/Controller.d.ts.map +0 -1
- package/lib/next/Controller.js +0 -24
- package/lib/previousActions.d.ts +0 -91
- package/lib/previousActions.d.ts.map +0 -1
- package/lib/previousActions.js +0 -2
- package/lib/state/applyUpdatersToResults.d.ts +0 -13
- package/lib/state/applyUpdatersToResults.d.ts.map +0 -1
- package/lib/state/applyUpdatersToResults.js +0 -7
- package/lib/state/legacy-actions/createFetch.d.ts +0 -19
- package/lib/state/legacy-actions/createFetch.d.ts.map +0 -1
- package/lib/state/legacy-actions/createFetch.js +0 -62
- package/lib/state/legacy-actions/createReceive.d.ts +0 -14
- package/lib/state/legacy-actions/createReceive.d.ts.map +0 -1
- package/lib/state/legacy-actions/createReceive.js +0 -37
- package/lib/state/legacy-actions/createReceiveError.d.ts +0 -9
- package/lib/state/legacy-actions/createReceiveError.d.ts.map +0 -1
- package/lib/state/legacy-actions/createReceiveError.js +0 -28
- package/lib/state/legacy-actions/index.d.ts +0 -4
- package/lib/state/legacy-actions/index.d.ts.map +0 -1
- package/lib/state/legacy-actions/index.js +0 -4
- package/lib/state/reducerInstance.d.ts +0 -7
- package/lib/state/reducerInstance.d.ts.map +0 -1
- package/lib/state/reducerInstance.js +0 -9
- package/src/compatibleActions.ts +0 -96
- package/src/controller/BaseController.ts +0 -508
- package/src/endpoint/index.ts +0 -14
- package/src/endpoint/shapes.ts +0 -53
- package/src/endpoint/types.ts +0 -72
- package/src/legacyActions.ts +0 -163
- package/src/manager/__tests__/__snapshots__/pollingSubscription-endpoint.ts.snap +0 -49
- package/src/manager/__tests__/networkManager-legacy.ts +0 -394
- package/src/manager/__tests__/pollingSubscription-endpoint.ts +0 -423
- package/src/next/Controller.ts +0 -39
- package/src/previousActions.ts +0 -159
- package/src/state/__tests__/applyUpdatersToResults.ts +0 -40
- package/src/state/applyUpdatersToResults.ts +0 -29
- package/src/state/legacy-actions/createFetch.ts +0 -95
- package/src/state/legacy-actions/createReceive.ts +0 -68
- package/src/state/legacy-actions/createReceiveError.ts +0 -43
- package/src/state/legacy-actions/index.ts +0 -3
- package/src/state/reducerInstance.ts +0 -14
- package/ts3.4/compatibleActions.d.ts +0 -47
- package/ts3.4/controller/BaseController.d.ts +0 -170
- package/ts3.4/endpoint/index.d.ts +0 -3
- package/ts3.4/endpoint/shapes.d.ts +0 -25
- package/ts3.4/endpoint/types.d.ts +0 -45
- package/ts3.4/legacyActions.d.ts +0 -95
- package/ts3.4/next/Controller.d.ts +0 -14
- package/ts3.4/previousActions.d.ts +0 -94
- package/ts3.4/state/applyUpdatersToResults.d.ts +0 -13
- package/ts3.4/state/legacy-actions/createFetch.d.ts +0 -19
- package/ts3.4/state/legacy-actions/createReceive.d.ts +0 -14
- package/ts3.4/state/legacy-actions/createReceiveError.d.ts +0 -9
- package/ts3.4/state/legacy-actions/index.d.ts +0 -4
- package/ts3.4/state/reducerInstance.d.ts +0 -7
package/src/types.ts
CHANGED
|
@@ -1,30 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
EndpointInterface,
|
|
3
|
-
NormalizedIndex,
|
|
4
|
-
Schema,
|
|
5
|
-
} from '@data-client/normalizr';
|
|
1
|
+
import { NormalizedIndex } from '@data-client/normalizr';
|
|
6
2
|
import type {
|
|
7
3
|
UpdateFunction,
|
|
8
4
|
AbstractInstanceType,
|
|
9
5
|
} from '@data-client/normalizr';
|
|
10
6
|
import type { ErrorTypes } from '@data-client/normalizr';
|
|
11
7
|
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
CompatibleReceiveAction,
|
|
16
|
-
CompatibleSubscribeAction,
|
|
17
|
-
CompatibleUnsubscribeAction,
|
|
18
|
-
} from './compatibleActions.js';
|
|
19
|
-
import { EndpointUpdateFunction } from './controller/types.js';
|
|
20
|
-
import * as legacyActions from './legacyActions.js';
|
|
21
|
-
import { Dispatch, Middleware, MiddlewareAPI } from './middlewareTypes.js';
|
|
22
|
-
import * as newActions from './newActions.js';
|
|
23
|
-
import * as previousActions from './previousActions.js';
|
|
8
|
+
import { SET_TYPE } from './actionTypes.js';
|
|
9
|
+
import type { Dispatch, Middleware, MiddlewareAPI } from './middlewareTypes.js';
|
|
10
|
+
import type { ActionTypes, SetAction, OptimisticAction } from './newActions.js';
|
|
24
11
|
|
|
25
12
|
export type { AbstractInstanceType, UpdateFunction };
|
|
26
13
|
|
|
27
|
-
export type ReceiveTypes = typeof
|
|
14
|
+
export type ReceiveTypes = typeof SET_TYPE;
|
|
28
15
|
|
|
29
16
|
export type PK = string;
|
|
30
17
|
|
|
@@ -53,70 +40,14 @@ export interface State<T> {
|
|
|
53
40
|
};
|
|
54
41
|
};
|
|
55
42
|
};
|
|
56
|
-
readonly optimistic: (
|
|
57
|
-
|
|
58
|
-
| previousActions.OptimisticAction
|
|
59
|
-
)[];
|
|
60
|
-
readonly lastReset: Date | number;
|
|
43
|
+
readonly optimistic: (SetAction | OptimisticAction)[];
|
|
44
|
+
readonly lastReset: number;
|
|
61
45
|
}
|
|
62
46
|
|
|
63
|
-
export * as legacyActions from './legacyActions.js';
|
|
64
47
|
export * as newActions from './newActions.js';
|
|
65
|
-
export
|
|
66
|
-
|
|
67
|
-
/* maintain backwards compatibility */
|
|
68
|
-
/* TODO: switch to only include newActions in future */
|
|
69
|
-
export type OptimisticAction<
|
|
70
|
-
E extends EndpointInterface & {
|
|
71
|
-
update?: EndpointUpdateFunction<E>;
|
|
72
|
-
} = EndpointInterface & {
|
|
73
|
-
update?: EndpointUpdateFunction<EndpointInterface>;
|
|
74
|
-
},
|
|
75
|
-
> = newActions.OptimisticAction<E>;
|
|
76
|
-
export type InvalidateAction = newActions.InvalidateAction;
|
|
77
|
-
export type ResetAction = newActions.ResetAction | legacyActions.ResetAction;
|
|
78
|
-
export type GCAction = newActions.GCAction;
|
|
79
|
-
export type FetchAction<
|
|
80
|
-
Payload extends object | string | number | null =
|
|
81
|
-
| object
|
|
82
|
-
| string
|
|
83
|
-
| number
|
|
84
|
-
| null,
|
|
85
|
-
S extends Schema | undefined = any,
|
|
86
|
-
> = CompatibleFetchAction | legacyActions.FetchAction<Payload, S>;
|
|
87
|
-
export type ReceiveAction<
|
|
88
|
-
Payload extends object | string | number | null =
|
|
89
|
-
| object
|
|
90
|
-
| string
|
|
91
|
-
| number
|
|
92
|
-
| null,
|
|
93
|
-
S extends Schema | undefined = any,
|
|
94
|
-
> = CompatibleReceiveAction | legacyActions.ReceiveAction<Payload, S>;
|
|
95
|
-
export type SubscribeAction =
|
|
96
|
-
| CompatibleSubscribeAction
|
|
97
|
-
| legacyActions.SubscribeAction;
|
|
98
|
-
export type UnsubscribeAction =
|
|
99
|
-
| CompatibleUnsubscribeAction
|
|
100
|
-
| legacyActions.UnsubscribeAction;
|
|
101
|
-
|
|
102
|
-
export type ResponseActions = ReceiveAction;
|
|
103
|
-
|
|
104
|
-
// put other actions here in union
|
|
105
|
-
export type OldActionTypes = previousActions.ActionTypes;
|
|
106
|
-
|
|
107
|
-
export type CombinedActionTypes =
|
|
108
|
-
| OptimisticAction
|
|
109
|
-
| InvalidateAction
|
|
110
|
-
| ResetAction
|
|
111
|
-
| GCAction
|
|
112
|
-
| FetchAction
|
|
113
|
-
| ReceiveAction
|
|
114
|
-
| SubscribeAction
|
|
115
|
-
| UnsubscribeAction;
|
|
116
|
-
|
|
117
|
-
export type ActionTypes = CombinedActionTypes;
|
|
48
|
+
export * from './newActions.js';
|
|
118
49
|
|
|
119
|
-
export interface Manager<Actions =
|
|
50
|
+
export interface Manager<Actions = ActionTypes> {
|
|
120
51
|
getMiddleware(): Middleware<Actions>;
|
|
121
52
|
cleanup(): void;
|
|
122
53
|
init?: (state: State<any>) => void;
|
package/ts3.4/actionTypes.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare const FETCH_TYPE: "rest-hooks/fetch";
|
|
2
|
+
/** @deprecated use SET_TYPE instead */
|
|
2
3
|
export declare const RECEIVE_TYPE: "rest-hooks/receive";
|
|
3
4
|
export declare const SET_TYPE: "rest-hooks/receive";
|
|
4
5
|
export declare const OPTIMISTIC_TYPE: "rest-hooks/optimistic";
|
|
@@ -1,14 +1,176 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { ErrorTypes, SnapshotInterface, DenormalizeCache, Schema, Denormalize } from '@data-client/normalizr';
|
|
2
|
+
import { ExpiryStatus, EndpointInterface, FetchFunction, DenormalizeNullable } from '@data-client/normalizr';
|
|
3
3
|
import { EndpointUpdateFunction } from './types.js';
|
|
4
|
-
|
|
4
|
+
import { ActionTypes, State } from '../types.js';
|
|
5
|
+
export type GenericDispatch = (value: any) => Promise<void>;
|
|
6
|
+
export type DataClientDispatch = (value: ActionTypes) => Promise<void>;
|
|
7
|
+
interface ConstructorProps<D extends GenericDispatch = DataClientDispatch> {
|
|
8
|
+
dispatch?: D;
|
|
9
|
+
getState?: () => State<unknown>;
|
|
10
|
+
globalCache?: DenormalizeCache;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Imperative control of Rest Hooks store
|
|
14
|
+
* @see https://resthooks.io/docs/api/Controller
|
|
15
|
+
*/
|
|
16
|
+
export default class Controller<D extends GenericDispatch = DataClientDispatch> {
|
|
17
|
+
/**
|
|
18
|
+
* Dispatches an action to Rest Hooks reducer.
|
|
19
|
+
*
|
|
20
|
+
* @see https://resthooks.io/docs/api/Controller#dispatch
|
|
21
|
+
*/
|
|
22
|
+
readonly dispatch: D;
|
|
23
|
+
/**
|
|
24
|
+
* Gets the latest state snapshot that is fully committed.
|
|
25
|
+
*
|
|
26
|
+
* This can be useful for imperative use-cases like event handlers.
|
|
27
|
+
* This should *not* be used to render; instead useSuspense() or useCache()
|
|
28
|
+
* @see https://resthooks.io/docs/api/Controller#getState
|
|
29
|
+
*/
|
|
30
|
+
readonly getState: () => State<unknown>;
|
|
31
|
+
readonly globalCache: DenormalizeCache;
|
|
32
|
+
constructor({ dispatch, getState, globalCache, }?: ConstructorProps<D>);
|
|
33
|
+
/*************** Action Dispatchers ***************/
|
|
5
34
|
/**
|
|
6
35
|
* Fetches the endpoint with given args, updating the Rest Hooks cache with the response or error upon completion.
|
|
7
36
|
* @see https://resthooks.io/docs/api/Controller#fetch
|
|
8
37
|
*/
|
|
9
|
-
fetch: <E extends EndpointInterface<
|
|
38
|
+
fetch: <E extends EndpointInterface<FetchFunction, Schema | undefined, boolean | undefined> & {
|
|
39
|
+
update?: EndpointUpdateFunction<E> | undefined;
|
|
40
|
+
}>(endpoint: E, ...args_0: Parameters<E>) => E["schema"] extends null | undefined ? ReturnType<E> : Promise<Denormalize<E["schema"]>>;
|
|
41
|
+
/**
|
|
42
|
+
* Forces refetching and suspense on useSuspense with the same Endpoint and parameters.
|
|
43
|
+
* @see https://resthooks.io/docs/api/Controller#invalidate
|
|
44
|
+
*/
|
|
45
|
+
invalidate: <E extends EndpointInterface<FetchFunction, Schema | undefined, boolean | undefined>>(endpoint: E, ...args: readonly [
|
|
46
|
+
...Parameters<E>
|
|
47
|
+
] | readonly [
|
|
48
|
+
null
|
|
49
|
+
]) => Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* Forces refetching and suspense on useSuspense on all matching endpoint result keys.
|
|
52
|
+
* @see https://resthooks.io/docs/api/Controller#invalidateAll
|
|
53
|
+
*/
|
|
54
|
+
invalidateAll: (options: {
|
|
55
|
+
testKey: (key: string) => boolean;
|
|
56
|
+
}) => Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* Resets the entire Rest Hooks cache. All inflight requests will not resolve.
|
|
59
|
+
* @see https://resthooks.io/docs/api/Controller#resetEntireStore
|
|
60
|
+
*/
|
|
61
|
+
resetEntireStore: () => Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* Stores response in cache for given Endpoint and args.
|
|
64
|
+
* @see https://resthooks.io/docs/api/Controller#set
|
|
65
|
+
*/
|
|
66
|
+
setResponse: <E extends EndpointInterface<FetchFunction, Schema | undefined, boolean | undefined> & {
|
|
67
|
+
update?: EndpointUpdateFunction<E> | undefined;
|
|
68
|
+
}>(endpoint: E, ...rest: readonly [
|
|
69
|
+
...Parameters<E>,
|
|
70
|
+
any
|
|
71
|
+
]) => Promise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* @deprecated use https://resthooks.io/docs/api/Controller#setResponse instead
|
|
74
|
+
*/
|
|
75
|
+
receive: <E extends EndpointInterface<FetchFunction, Schema | undefined, boolean | undefined> & {
|
|
76
|
+
update?: EndpointUpdateFunction<E> | undefined;
|
|
77
|
+
}>(endpoint: E, ...rest: readonly [
|
|
78
|
+
...Parameters<E>,
|
|
79
|
+
any
|
|
80
|
+
]) => Promise<void>;
|
|
81
|
+
/**
|
|
82
|
+
* Stores the result of Endpoint and args as the error provided.
|
|
83
|
+
* @see https://resthooks.io/docs/api/Controller#setError
|
|
84
|
+
*/
|
|
85
|
+
setError: <E extends EndpointInterface<FetchFunction, Schema | undefined, boolean | undefined> & {
|
|
86
|
+
update?: EndpointUpdateFunction<E> | undefined;
|
|
87
|
+
}>(endpoint: E, ...rest: readonly [
|
|
88
|
+
...Parameters<E>,
|
|
89
|
+
Error
|
|
90
|
+
]) => Promise<void>;
|
|
91
|
+
/**
|
|
92
|
+
* Another name for setError
|
|
93
|
+
* @deprecated use https://resthooks.io/docs/api/Controller#setError instead
|
|
94
|
+
*/
|
|
95
|
+
receiveError: <E extends EndpointInterface<FetchFunction, Schema | undefined, boolean | undefined> & {
|
|
10
96
|
update?: EndpointUpdateFunction<E> | undefined;
|
|
11
|
-
}>(endpoint: E, ...
|
|
97
|
+
}>(endpoint: E, ...rest: readonly [
|
|
98
|
+
...Parameters<E>,
|
|
99
|
+
Error
|
|
100
|
+
]) => Promise<void>;
|
|
101
|
+
/**
|
|
102
|
+
* Resolves an inflight fetch. `fetchedAt` should `fetch`'s `createdAt`
|
|
103
|
+
* @see https://resthooks.io/docs/api/Controller#resolve
|
|
104
|
+
*/
|
|
105
|
+
resolve: <E extends EndpointInterface<FetchFunction, Schema | undefined, boolean | undefined> & {
|
|
106
|
+
update?: EndpointUpdateFunction<E> | undefined;
|
|
107
|
+
}>(endpoint: E, meta: {
|
|
108
|
+
args: readonly [
|
|
109
|
+
...Parameters<E>
|
|
110
|
+
];
|
|
111
|
+
response: Error;
|
|
112
|
+
fetchedAt: number;
|
|
113
|
+
error: true;
|
|
114
|
+
} | {
|
|
115
|
+
args: readonly [
|
|
116
|
+
...Parameters<E>
|
|
117
|
+
];
|
|
118
|
+
response: any;
|
|
119
|
+
fetchedAt: number;
|
|
120
|
+
error?: false | undefined;
|
|
121
|
+
}) => Promise<void>;
|
|
122
|
+
/**
|
|
123
|
+
* Marks a new subscription to a given Endpoint.
|
|
124
|
+
* @see https://resthooks.io/docs/api/Controller#subscribe
|
|
125
|
+
*/
|
|
126
|
+
subscribe: <E extends EndpointInterface<FetchFunction, Schema | undefined, false | undefined>>(endpoint: E, ...args: readonly [
|
|
127
|
+
null
|
|
128
|
+
] | readonly [
|
|
129
|
+
...Parameters<E>
|
|
130
|
+
]) => Promise<void>;
|
|
131
|
+
/**
|
|
132
|
+
* Marks completion of subscription to a given Endpoint.
|
|
133
|
+
* @see https://resthooks.io/docs/api/Controller#unsubscribe
|
|
134
|
+
*/
|
|
135
|
+
unsubscribe: <E extends EndpointInterface<FetchFunction, Schema | undefined, false | undefined>>(endpoint: E, ...args: readonly [
|
|
136
|
+
null
|
|
137
|
+
] | readonly [
|
|
138
|
+
...Parameters<E>
|
|
139
|
+
]) => Promise<void>;
|
|
140
|
+
/*************** More ***************/
|
|
141
|
+
/**
|
|
142
|
+
* Gets a snapshot (https://resthooks.io/docs/api/Snapshot)
|
|
143
|
+
* @see https://resthooks.io/docs/api/Controller#snapshot
|
|
144
|
+
*/
|
|
145
|
+
snapshot: (state: State<unknown>, fetchedAt?: number) => SnapshotInterface;
|
|
146
|
+
/**
|
|
147
|
+
* Gets the error, if any, for a given endpoint. Returns undefined for no errors.
|
|
148
|
+
* @see https://resthooks.io/docs/api/Controller#getError
|
|
149
|
+
*/
|
|
150
|
+
getError: <E extends Pick<EndpointInterface<FetchFunction, Schema | undefined, boolean | undefined>, "key">, Args extends readonly [
|
|
151
|
+
null
|
|
152
|
+
] | readonly [
|
|
153
|
+
...Parameters<E["key"]>
|
|
154
|
+
]>(endpoint: E, ...rest: [
|
|
155
|
+
...Args,
|
|
156
|
+
State<unknown>
|
|
157
|
+
]) => ErrorTypes | undefined;
|
|
158
|
+
/**
|
|
159
|
+
* Gets the (globally referentially stable) response for a given endpoint/args pair from state given.
|
|
160
|
+
* @see https://resthooks.io/docs/api/Controller#getResponse
|
|
161
|
+
*/
|
|
162
|
+
getResponse: <E extends Pick<EndpointInterface<FetchFunction, Schema | undefined, boolean | undefined>, "schema" | "key" | "invalidIfStale">, Args extends readonly [
|
|
163
|
+
null
|
|
164
|
+
] | readonly [
|
|
165
|
+
...Parameters<E["key"]>
|
|
166
|
+
]>(endpoint: E, ...rest: [
|
|
167
|
+
...Args,
|
|
168
|
+
State<unknown>
|
|
169
|
+
]) => {
|
|
170
|
+
data: DenormalizeNullable<E["schema"]>;
|
|
171
|
+
expiryStatus: ExpiryStatus;
|
|
172
|
+
expiresAt: number;
|
|
173
|
+
};
|
|
12
174
|
}
|
|
13
|
-
export
|
|
175
|
+
export { ErrorTypes };
|
|
14
176
|
//# sourceMappingURL=Controller.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EndpointInterface } from '@data-client/normalizr';
|
|
2
2
|
import { EndpointUpdateFunction } from './types.js';
|
|
3
|
-
import {
|
|
3
|
+
import { FetchAction } from '../types.js';
|
|
4
4
|
/**
|
|
5
5
|
* Requesting a fetch to begin
|
|
6
6
|
*/
|
|
@@ -10,5 +10,5 @@ export default function createFetch<E extends EndpointInterface & {
|
|
|
10
10
|
args: readonly [
|
|
11
11
|
...Parameters<E>
|
|
12
12
|
];
|
|
13
|
-
}):
|
|
13
|
+
}): FetchAction<E>;
|
|
14
14
|
//# sourceMappingURL=createFetch.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EndpointInterface } from '@data-client/normalizr';
|
|
2
|
-
import { InvalidateAction } from '../
|
|
2
|
+
import { InvalidateAction } from '../types.js';
|
|
3
3
|
export default function createInvalidate<E extends EndpointInterface>(endpoint: E, { args }: {
|
|
4
4
|
args: readonly [
|
|
5
5
|
...Parameters<E>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EndpointInterface } from '@data-client/normalizr';
|
|
2
2
|
import { EndpointUpdateFunction } from './types.js';
|
|
3
|
-
import { OptimisticAction } from '../
|
|
3
|
+
import { OptimisticAction } from '../types.js';
|
|
4
4
|
export default function createOptimistic<E extends EndpointInterface & {
|
|
5
5
|
update?: EndpointUpdateFunction<E>;
|
|
6
6
|
}>(endpoint: E, { args, fetchedAt, }: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EndpointInterface, ResolveType } from '@data-client/normalizr';
|
|
2
2
|
import { EndpointUpdateFunction } from './types.js';
|
|
3
|
-
import {
|
|
4
|
-
export default function
|
|
3
|
+
import { SetAction } from '../types.js';
|
|
4
|
+
export default function createSet<E extends EndpointInterface & {
|
|
5
5
|
update?: EndpointUpdateFunction<E>;
|
|
6
6
|
}>(endpoint: E, options: {
|
|
7
7
|
args: readonly [
|
|
@@ -10,8 +10,8 @@ export default function createReceive<E extends EndpointInterface & {
|
|
|
10
10
|
response: Error;
|
|
11
11
|
fetchedAt?: number;
|
|
12
12
|
error: true;
|
|
13
|
-
}):
|
|
14
|
-
export default function
|
|
13
|
+
}): SetAction<E>;
|
|
14
|
+
export default function createSet<E extends EndpointInterface & {
|
|
15
15
|
update?: EndpointUpdateFunction<E>;
|
|
16
16
|
}>(endpoint: E, options: {
|
|
17
17
|
args: readonly [
|
|
@@ -20,5 +20,5 @@ export default function createReceive<E extends EndpointInterface & {
|
|
|
20
20
|
response: ResolveType<E>;
|
|
21
21
|
fetchedAt?: number;
|
|
22
22
|
error?: false;
|
|
23
|
-
}):
|
|
24
|
-
//# sourceMappingURL=
|
|
23
|
+
}): SetAction<E>;
|
|
24
|
+
//# sourceMappingURL=createSet.d.ts.map
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { EndpointInterface } from '@data-client/normalizr';
|
|
2
|
-
import {
|
|
2
|
+
import { SubscribeAction, UnsubscribeAction } from '../types.js';
|
|
3
3
|
export declare function createSubscription<E extends EndpointInterface>(endpoint: E, { args }: {
|
|
4
4
|
args: readonly [
|
|
5
5
|
...Parameters<E>
|
|
6
6
|
];
|
|
7
|
-
}):
|
|
7
|
+
}): SubscribeAction<E>;
|
|
8
8
|
export declare function createUnsubscription<E extends EndpointInterface>(endpoint: E, { args }: {
|
|
9
9
|
args: readonly [
|
|
10
10
|
...Parameters<E>
|
|
11
11
|
];
|
|
12
|
-
}):
|
|
12
|
+
}): UnsubscribeAction<E>;
|
|
13
13
|
//# sourceMappingURL=createSubscription.d.ts.map
|
package/ts3.4/index.d.ts
CHANGED
|
@@ -4,19 +4,14 @@ export { NetworkError, UnknownError, ErrorTypes, Schema, EndpointInterface, Enti
|
|
|
4
4
|
export { ExpiryStatus } from '@data-client/normalizr';
|
|
5
5
|
export { default as NetworkManager, ResetError, } from './manager/NetworkManager.js';
|
|
6
6
|
export { default as createReducer, initialState, } from './state/reducer/createReducer.js';
|
|
7
|
-
export { default as reducer } from './state/reducerInstance.js';
|
|
8
7
|
export { default as applyManager } from './manager/applyManager.js';
|
|
9
8
|
export { default as Controller } from './controller/Controller.js';
|
|
10
|
-
export {
|
|
9
|
+
export { DataClientDispatch, GenericDispatch, } from './controller/Controller.js';
|
|
11
10
|
export { default as createFetch } from './controller/createFetch.js';
|
|
12
|
-
export { default as createReceive } from './controller/
|
|
11
|
+
export { default as createReceive } from './controller/createSet.js';
|
|
13
12
|
export * from './controller/types.js';
|
|
14
|
-
import * as legacyActions_1 from './state/legacy-actions/index.js';
|
|
15
|
-
export { legacyActions_1 as legacyActions };
|
|
16
13
|
import * as actionTypes_1 from './actionTypes.js';
|
|
17
14
|
export { actionTypes_1 as actionTypes };
|
|
18
15
|
export * from './types.js';
|
|
19
|
-
export { FetchShape, ReadShape, MutateShape, DeleteShape, } from './endpoint/shapes.js';
|
|
20
|
-
export { SetShapeParams, ParamsFromShape, BodyFromShape, ReturnFromShape, } from './endpoint/types.js';
|
|
21
16
|
export * from './manager/index.js';
|
|
22
17
|
//# sourceMappingURL=index.d.ts.map
|
package/ts3.4/internal.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { inferResults, DELETED } from '@data-client/normalizr';
|
|
1
|
+
export { inferResults, DELETED, INVALID } from '@data-client/normalizr';
|
|
2
2
|
export { default as RIC } from './state/RIC.js';
|
|
3
3
|
export { initialState } from './state/reducer/createReducer.js';
|
|
4
4
|
//# sourceMappingURL=internal.d.ts.map
|
|
@@ -6,7 +6,7 @@ export { DevToolsConfig };
|
|
|
6
6
|
*
|
|
7
7
|
* Options: https://github.com/reduxjs/redux-devtools/blob/main/extension/docs/API/Arguments.md
|
|
8
8
|
*
|
|
9
|
-
* @see https://
|
|
9
|
+
* @see https://dataclient.io/docs/api/DevToolsManager
|
|
10
10
|
*/
|
|
11
11
|
export default class DevToolsManager implements Manager {
|
|
12
12
|
protected middleware: Middleware;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import Controller from '../controller/Controller.js';
|
|
2
2
|
import { UnknownError } from '../index.js';
|
|
3
|
-
import {
|
|
4
|
-
import { Manager } from '../types.js';
|
|
3
|
+
import { ActionTypes, Manager } from '../types.js';
|
|
5
4
|
/** Handling network unauthorized indicators like HTTP 401
|
|
6
5
|
*
|
|
7
|
-
* @see https://
|
|
6
|
+
* @see https://dataclient.io/docs/api/LogoutManager
|
|
8
7
|
*/
|
|
9
|
-
export default class LogoutManager implements Manager
|
|
8
|
+
export default class LogoutManager implements Manager {
|
|
10
9
|
protected middleware: Middleware;
|
|
11
10
|
constructor({ handleLogout, shouldLogout }?: Props);
|
|
12
11
|
cleanup(): void;
|
|
@@ -14,7 +13,7 @@ export default class LogoutManager implements Manager<CombinedActionTypes> {
|
|
|
14
13
|
protected shouldLogout(error: UnknownError): boolean;
|
|
15
14
|
handleLogout(controller: Controller<Dispatch>): void;
|
|
16
15
|
}
|
|
17
|
-
type Dispatch = (value:
|
|
16
|
+
type Dispatch = (value: ActionTypes) => Promise<void>;
|
|
18
17
|
export type Middleware = <C extends Controller<Dispatch>>(controller: C) => (next: C['dispatch']) => C['dispatch'];
|
|
19
18
|
type HandleLogout = (controller: Controller<Dispatch>) => void;
|
|
20
19
|
interface Props {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Controller from '../controller/Controller.js';
|
|
2
|
-
import { FetchAction,
|
|
2
|
+
import { FetchAction, Manager, ActionTypes, Middleware, SetAction } from '../types.js';
|
|
3
3
|
export declare class ResetError extends Error {
|
|
4
4
|
name: string;
|
|
5
5
|
constructor();
|
|
@@ -11,7 +11,7 @@ export declare class ResetError extends Error {
|
|
|
11
11
|
*
|
|
12
12
|
* Interfaces with store via a redux-compatible middleware.
|
|
13
13
|
*
|
|
14
|
-
* @see https://
|
|
14
|
+
* @see https://dataclient.io/docs/api/NetworkManager
|
|
15
15
|
*/
|
|
16
16
|
export default class NetworkManager implements Manager {
|
|
17
17
|
protected fetched: {
|
|
@@ -29,7 +29,6 @@ export default class NetworkManager implements Manager {
|
|
|
29
29
|
readonly dataExpiryLength: number;
|
|
30
30
|
readonly errorExpiryLength: number;
|
|
31
31
|
protected middleware: Middleware;
|
|
32
|
-
protected getState: () => State<unknown>;
|
|
33
32
|
protected controller: Controller;
|
|
34
33
|
cleanupDate?: number;
|
|
35
34
|
constructor(dataExpiryLength?: number, errorExpiryLength?: number);
|
|
@@ -53,12 +52,12 @@ export default class NetworkManager implements Manager {
|
|
|
53
52
|
* Uses throttle only when instructed by action meta. This is valuable
|
|
54
53
|
* for ensures mutation requests always go through.
|
|
55
54
|
*/
|
|
56
|
-
protected handleFetch(action: FetchAction
|
|
55
|
+
protected handleFetch(action: FetchAction): Promise<any>;
|
|
57
56
|
/** Called when middleware intercepts a receive action.
|
|
58
57
|
*
|
|
59
58
|
* Will resolve the promise associated with receive key.
|
|
60
59
|
*/
|
|
61
|
-
protected handleReceive(action:
|
|
60
|
+
protected handleReceive(action: SetAction): void;
|
|
62
61
|
/** Attaches NetworkManager to store
|
|
63
62
|
*
|
|
64
63
|
* Intercepts 'rest-hooks/fetch' actions to start requests.
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EndpointInterface } from '@data-client/normalizr';
|
|
2
2
|
import ConnectionListener from './ConnectionListener.js';
|
|
3
|
-
import { Subscription
|
|
4
|
-
import
|
|
3
|
+
import { Subscription } from './SubscriptionManager.js';
|
|
4
|
+
import Controller from '../controller/Controller.js';
|
|
5
|
+
import { SubscribeAction } from '../types.js';
|
|
5
6
|
/**
|
|
6
7
|
* PollingSubscription keeps a given resource updated by
|
|
7
8
|
* dispatching a fetch at a rate equal to the minimum update
|
|
8
9
|
* interval requested.
|
|
9
10
|
*
|
|
10
|
-
* @see https://
|
|
11
|
+
* @see https://dataclient.io/docs/api/PollingSubscription
|
|
11
12
|
*/
|
|
12
13
|
export default class PollingSubscription implements Subscription {
|
|
13
|
-
protected readonly
|
|
14
|
-
protected readonly
|
|
14
|
+
protected readonly endpoint: EndpointInterface;
|
|
15
|
+
protected readonly args: readonly any[];
|
|
15
16
|
protected readonly key: string;
|
|
16
17
|
protected frequency: number;
|
|
17
18
|
protected frequencyHistogram: Map<number, number>;
|
|
18
|
-
protected
|
|
19
|
-
protected getState: () => State<unknown>;
|
|
19
|
+
protected controller: Controller;
|
|
20
20
|
protected intervalId?: ReturnType<typeof setInterval>;
|
|
21
21
|
protected lastIntervalId?: ReturnType<typeof setInterval>;
|
|
22
22
|
protected startId?: ReturnType<typeof setTimeout>;
|
|
23
23
|
private connectionListener;
|
|
24
|
-
constructor(
|
|
24
|
+
constructor(action: Pick<SubscribeAction, Exclude<keyof SubscribeAction, 'type'>>, controller: Controller, connectionListener?: ConnectionListener);
|
|
25
25
|
/** Subscribe to a frequency */
|
|
26
26
|
add(frequency?: number): void;
|
|
27
27
|
/** Unsubscribe from a frequency */
|
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Manager,
|
|
3
|
-
|
|
4
|
-
export interface SubscriptionInit {
|
|
5
|
-
schema?: Schema | undefined;
|
|
6
|
-
fetch: () => Promise<any>;
|
|
7
|
-
key: string;
|
|
8
|
-
getState: () => State<unknown>;
|
|
9
|
-
frequency?: number | undefined;
|
|
10
|
-
}
|
|
1
|
+
import Controller from '../controller/Controller.js';
|
|
2
|
+
import { Manager, Middleware, UnsubscribeAction, SubscribeAction } from '../types.js';
|
|
3
|
+
type Actions = UnsubscribeAction | SubscribeAction;
|
|
11
4
|
/** Interface handling a single resource subscription */
|
|
12
5
|
export interface Subscription {
|
|
13
6
|
add(frequency?: number): void;
|
|
@@ -16,32 +9,33 @@ export interface Subscription {
|
|
|
16
9
|
}
|
|
17
10
|
/** The static class that constructs Subscription */
|
|
18
11
|
export interface SubscriptionConstructable {
|
|
19
|
-
new (
|
|
12
|
+
new (action: Pick<SubscribeAction, Exclude<keyof SubscribeAction, 'type'>>, controller: Controller): Subscription;
|
|
20
13
|
}
|
|
21
14
|
/** Handles subscription actions -> fetch or receive actions
|
|
22
15
|
*
|
|
23
16
|
* Constructor takes a SubscriptionConstructable class to control how
|
|
24
17
|
* subscriptions are handled. (e.g., polling, websockets)
|
|
25
18
|
*
|
|
26
|
-
* @see https://
|
|
19
|
+
* @see https://dataclient.io/docs/api/SubscriptionManager
|
|
27
20
|
*/
|
|
28
|
-
export default class SubscriptionManager<S extends SubscriptionConstructable> implements Manager {
|
|
21
|
+
export default class SubscriptionManager<S extends SubscriptionConstructable> implements Manager<Actions> {
|
|
29
22
|
protected subscriptions: {
|
|
30
23
|
[key: string]: InstanceType<S>;
|
|
31
24
|
};
|
|
32
25
|
protected readonly Subscription: S;
|
|
33
26
|
protected middleware: Middleware;
|
|
27
|
+
protected controller: Controller;
|
|
34
28
|
constructor(Subscription: S);
|
|
35
29
|
/** Ensures all subscriptions are cleaned up. */
|
|
36
30
|
cleanup(): void;
|
|
37
31
|
/** Called when middleware intercepts 'rest-hooks/subscribe' action.
|
|
38
32
|
*
|
|
39
33
|
*/
|
|
40
|
-
protected handleSubscribe(action: SubscribeAction
|
|
34
|
+
protected handleSubscribe(action: SubscribeAction): void;
|
|
41
35
|
/** Called when middleware intercepts 'rest-hooks/unsubscribe' action.
|
|
42
36
|
*
|
|
43
37
|
*/
|
|
44
|
-
protected handleUnsubscribe(action: UnsubscribeAction
|
|
38
|
+
protected handleUnsubscribe(action: UnsubscribeAction): void;
|
|
45
39
|
/** Attaches Manager to store
|
|
46
40
|
*
|
|
47
41
|
* Intercepts 'rest-hooks/subscribe'/'rest-hooks/unsubscribe' to register resources that
|
|
@@ -52,4 +46,5 @@ export default class SubscriptionManager<S extends SubscriptionConstructable> im
|
|
|
52
46
|
*/
|
|
53
47
|
getMiddleware(): Middleware;
|
|
54
48
|
}
|
|
49
|
+
export {};
|
|
55
50
|
//# sourceMappingURL=SubscriptionManager.d.ts.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import Controller from './controller/Controller.js';
|
|
2
|
-
import { ActionTypes } from './
|
|
3
|
-
import { ActionTypes as LegacyActionTypes, CombinedActionTypes, State } from './types.js';
|
|
2
|
+
import { ActionTypes, State } from './types.js';
|
|
4
3
|
type RHDispatch<Actions = any> = (value: Actions) => Promise<void>;
|
|
5
|
-
export interface MiddlewareAPI<R extends RestHooksReducer = RestHooksReducer> extends Controller<RHDispatch<
|
|
6
|
-
|
|
4
|
+
export interface MiddlewareAPI<R extends RestHooksReducer = RestHooksReducer> extends Controller<RHDispatch<ActionTypes>> {
|
|
5
|
+
/** @deprecated use members directly instead */
|
|
6
|
+
controller: Controller<RHDispatch<ActionTypes>>;
|
|
7
7
|
}
|
|
8
|
-
export interface MiddlewareController<Actions =
|
|
8
|
+
export interface MiddlewareController<Actions = ActionTypes> extends Controller<RHDispatch<Actions>> {
|
|
9
9
|
controller: Controller<RHDispatch<Actions>>;
|
|
10
10
|
}
|
|
11
11
|
export type Middleware<Actions = any> = <C extends MiddlewareController<Actions>>(controller: C) => (next: C['dispatch']) => C['dispatch'];
|