@data-client/core 0.1.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/LICENSE +201 -0
- package/README.md +71 -0
- package/dist/index.js +1643 -0
- package/dist/index.umd.min.js +1 -0
- package/dist/next.js +461 -0
- package/dist/package.json +1 -0
- package/legacy/actionTypes.js +12 -0
- package/legacy/compatibleActions.js +2 -0
- package/legacy/controller/BaseController.js +289 -0
- package/legacy/controller/Controller.js +20 -0
- package/legacy/controller/createFetch.js +42 -0
- package/legacy/controller/createInvalidate.js +12 -0
- package/legacy/controller/createInvalidateAll.js +8 -0
- package/legacy/controller/createOptimistic.js +33 -0
- package/legacy/controller/createReceive.js +36 -0
- package/legacy/controller/createReset.js +8 -0
- package/legacy/controller/createSubscription.js +30 -0
- package/legacy/controller/types.js +2 -0
- package/legacy/endpoint/index.js +2 -0
- package/legacy/endpoint/shapes.js +2 -0
- package/legacy/endpoint/types.js +2 -0
- package/legacy/fsa.js +2 -0
- package/legacy/index.js +22 -0
- package/legacy/internal.js +4 -0
- package/legacy/legacyActions.js +2 -0
- package/legacy/manager/ConnectionListener.js +2 -0
- package/legacy/manager/DefaultConnectionListener.js +40 -0
- package/legacy/manager/DevtoolsManager.js +73 -0
- package/legacy/manager/LogoutManager.js +34 -0
- package/legacy/manager/NetworkManager.js +291 -0
- package/legacy/manager/PollingSubscription.js +159 -0
- package/legacy/manager/SubscriptionManager.js +117 -0
- package/legacy/manager/applyManager.js +23 -0
- package/legacy/manager/devtoolsTypes.js +2 -0
- package/legacy/manager/index.js +6 -0
- package/legacy/middlewareTypes.js +2 -0
- package/legacy/newActions.js +2 -0
- package/legacy/next/Controller.js +24 -0
- package/legacy/next/index.js +3 -0
- package/legacy/previousActions.js +2 -0
- package/legacy/state/RIC.js +3 -0
- package/legacy/state/applyUpdatersToResults.js +4 -0
- package/legacy/state/legacy-actions/createFetch.js +62 -0
- package/legacy/state/legacy-actions/createReceive.js +37 -0
- package/legacy/state/legacy-actions/createReceiveError.js +28 -0
- package/legacy/state/legacy-actions/index.js +4 -0
- package/legacy/state/reducer/createReducer.js +54 -0
- package/legacy/state/reducer/fetchReducer.js +32 -0
- package/legacy/state/reducer/invalidateReducer.js +28 -0
- package/legacy/state/reducer/setReducer.js +113 -0
- package/legacy/state/reducerInstance.js +9 -0
- package/legacy/state/selectMeta.js +4 -0
- package/legacy/types.js +8 -0
- package/lib/actionTypes.d.ts +11 -0
- package/lib/actionTypes.d.ts.map +1 -0
- package/lib/actionTypes.js +12 -0
- package/lib/compatibleActions.d.ts +47 -0
- package/lib/compatibleActions.d.ts.map +1 -0
- package/lib/compatibleActions.js +2 -0
- package/lib/controller/BaseController.d.ts +128 -0
- package/lib/controller/BaseController.d.ts.map +1 -0
- package/lib/controller/BaseController.js +289 -0
- package/lib/controller/Controller.d.ts +14 -0
- package/lib/controller/Controller.d.ts.map +1 -0
- package/lib/controller/Controller.js +20 -0
- package/lib/controller/createFetch.d.ts +12 -0
- package/lib/controller/createFetch.d.ts.map +1 -0
- package/lib/controller/createFetch.js +42 -0
- package/lib/controller/createInvalidate.d.ts +6 -0
- package/lib/controller/createInvalidate.d.ts.map +1 -0
- package/lib/controller/createInvalidate.js +12 -0
- package/lib/controller/createInvalidateAll.d.ts +3 -0
- package/lib/controller/createInvalidateAll.d.ts.map +1 -0
- package/lib/controller/createInvalidateAll.js +8 -0
- package/lib/controller/createOptimistic.d.ts +10 -0
- package/lib/controller/createOptimistic.d.ts.map +1 -0
- package/lib/controller/createOptimistic.js +33 -0
- package/lib/controller/createReceive.d.ts +20 -0
- package/lib/controller/createReceive.d.ts.map +1 -0
- package/lib/controller/createReceive.js +36 -0
- package/lib/controller/createReset.d.ts +3 -0
- package/lib/controller/createReset.d.ts.map +1 -0
- package/lib/controller/createReset.js +8 -0
- package/lib/controller/createSubscription.d.ts +9 -0
- package/lib/controller/createSubscription.d.ts.map +1 -0
- package/lib/controller/createSubscription.js +30 -0
- package/lib/controller/types.d.ts +6 -0
- package/lib/controller/types.d.ts.map +1 -0
- package/lib/controller/types.js +2 -0
- package/lib/endpoint/index.d.ts +3 -0
- package/lib/endpoint/index.d.ts.map +1 -0
- package/lib/endpoint/index.js +2 -0
- package/lib/endpoint/shapes.d.ts +25 -0
- package/lib/endpoint/shapes.d.ts.map +1 -0
- package/lib/endpoint/shapes.js +2 -0
- package/lib/endpoint/types.d.ts +45 -0
- package/lib/endpoint/types.d.ts.map +1 -0
- package/lib/endpoint/types.js +2 -0
- package/lib/fsa.d.ts +41 -0
- package/lib/fsa.d.ts.map +1 -0
- package/lib/fsa.js +2 -0
- package/lib/index.d.ts +19 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +22 -0
- package/lib/internal.d.ts +4 -0
- package/lib/internal.d.ts.map +1 -0
- package/lib/internal.js +4 -0
- package/lib/legacyActions.d.ts +92 -0
- package/lib/legacyActions.d.ts.map +1 -0
- package/lib/legacyActions.js +2 -0
- package/lib/manager/ConnectionListener.d.ts +8 -0
- package/lib/manager/ConnectionListener.d.ts.map +1 -0
- package/lib/manager/ConnectionListener.js +2 -0
- package/lib/manager/DefaultConnectionListener.d.ts +20 -0
- package/lib/manager/DefaultConnectionListener.d.ts.map +1 -0
- package/lib/manager/DefaultConnectionListener.js +40 -0
- package/lib/manager/DevtoolsManager.d.ts +24 -0
- package/lib/manager/DevtoolsManager.d.ts.map +1 -0
- package/lib/manager/DevtoolsManager.js +74 -0
- package/lib/manager/LogoutManager.d.ts +25 -0
- package/lib/manager/LogoutManager.d.ts.map +1 -0
- package/lib/manager/LogoutManager.js +34 -0
- package/lib/manager/NetworkManager.d.ts +82 -0
- package/lib/manager/NetworkManager.d.ts.map +1 -0
- package/lib/manager/NetworkManager.js +295 -0
- package/lib/manager/PollingSubscription.d.ts +45 -0
- package/lib/manager/PollingSubscription.d.ts.map +1 -0
- package/lib/manager/PollingSubscription.js +159 -0
- package/lib/manager/SubscriptionManager.d.ts +55 -0
- package/lib/manager/SubscriptionManager.d.ts.map +1 -0
- package/lib/manager/SubscriptionManager.js +117 -0
- package/lib/manager/applyManager.d.ts +10 -0
- package/lib/manager/applyManager.d.ts.map +1 -0
- package/lib/manager/applyManager.js +23 -0
- package/lib/manager/devtoolsTypes.d.ts +205 -0
- package/lib/manager/devtoolsTypes.d.ts.map +1 -0
- package/lib/manager/devtoolsTypes.js +2 -0
- package/lib/manager/index.d.ts +8 -0
- package/lib/manager/index.d.ts.map +1 -0
- package/lib/manager/index.js +6 -0
- package/lib/middlewareTypes.d.ts +18 -0
- package/lib/middlewareTypes.d.ts.map +1 -0
- package/lib/middlewareTypes.js +2 -0
- package/lib/newActions.d.ts +85 -0
- package/lib/newActions.d.ts.map +1 -0
- package/lib/newActions.js +2 -0
- package/lib/next/Controller.d.ts +14 -0
- package/lib/next/Controller.d.ts.map +1 -0
- package/lib/next/Controller.js +24 -0
- package/lib/next/index.d.ts +3 -0
- package/lib/next/index.d.ts.map +1 -0
- package/lib/next/index.js +3 -0
- package/lib/previousActions.d.ts +91 -0
- package/lib/previousActions.d.ts.map +1 -0
- package/lib/previousActions.js +2 -0
- package/lib/state/RIC.d.ts +2 -0
- package/lib/state/RIC.js +3 -0
- package/lib/state/applyUpdatersToResults.d.ts +13 -0
- package/lib/state/applyUpdatersToResults.d.ts.map +1 -0
- package/lib/state/applyUpdatersToResults.js +7 -0
- package/lib/state/legacy-actions/createFetch.d.ts +19 -0
- package/lib/state/legacy-actions/createFetch.d.ts.map +1 -0
- package/lib/state/legacy-actions/createFetch.js +62 -0
- package/lib/state/legacy-actions/createReceive.d.ts +14 -0
- package/lib/state/legacy-actions/createReceive.d.ts.map +1 -0
- package/lib/state/legacy-actions/createReceive.js +37 -0
- package/lib/state/legacy-actions/createReceiveError.d.ts +9 -0
- package/lib/state/legacy-actions/createReceiveError.d.ts.map +1 -0
- package/lib/state/legacy-actions/createReceiveError.js +28 -0
- package/lib/state/legacy-actions/index.d.ts +4 -0
- package/lib/state/legacy-actions/index.d.ts.map +1 -0
- package/lib/state/legacy-actions/index.js +4 -0
- package/lib/state/reducer/createReducer.d.ts +7 -0
- package/lib/state/reducer/createReducer.d.ts.map +1 -0
- package/lib/state/reducer/createReducer.js +55 -0
- package/lib/state/reducer/fetchReducer.d.ts +4 -0
- package/lib/state/reducer/fetchReducer.d.ts.map +1 -0
- package/lib/state/reducer/fetchReducer.js +34 -0
- package/lib/state/reducer/invalidateReducer.d.ts +37 -0
- package/lib/state/reducer/invalidateReducer.d.ts.map +1 -0
- package/lib/state/reducer/invalidateReducer.js +34 -0
- package/lib/state/reducer/setReducer.d.ts +40 -0
- package/lib/state/reducer/setReducer.d.ts.map +1 -0
- package/lib/state/reducer/setReducer.js +119 -0
- package/lib/state/reducerInstance.d.ts +7 -0
- package/lib/state/reducerInstance.d.ts.map +1 -0
- package/lib/state/reducerInstance.js +9 -0
- package/lib/state/selectMeta.d.ts +3 -0
- package/lib/state/selectMeta.d.ts.map +1 -0
- package/lib/state/selectMeta.js +4 -0
- package/lib/types.d.ts +71 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +8 -0
- package/node.mjs +1 -0
- package/package.json +127 -0
- package/src/actionTypes.ts +11 -0
- package/src/compatibleActions.ts +96 -0
- package/src/controller/BaseController.ts +508 -0
- package/src/controller/Controller.ts +32 -0
- package/src/controller/__tests__/Controller.ts +29 -0
- package/src/controller/__tests__/__snapshots__/getResponse.ts.snap +35 -0
- package/src/controller/__tests__/getResponse.ts +182 -0
- package/src/controller/createFetch.ts +54 -0
- package/src/controller/createInvalidate.ts +16 -0
- package/src/controller/createInvalidateAll.ts +11 -0
- package/src/controller/createOptimistic.ts +47 -0
- package/src/controller/createReceive.ts +85 -0
- package/src/controller/createReset.ts +9 -0
- package/src/controller/createSubscription.ts +39 -0
- package/src/controller/types.ts +22 -0
- package/src/endpoint/index.ts +14 -0
- package/src/endpoint/shapes.ts +53 -0
- package/src/endpoint/types.ts +72 -0
- package/src/fsa.ts +99 -0
- package/src/index.ts +61 -0
- package/src/internal.ts +3 -0
- package/src/legacyActions.ts +163 -0
- package/src/manager/ConnectionListener.ts +7 -0
- package/src/manager/DefaultConnectionListener.ts +54 -0
- package/src/manager/DevtoolsManager.ts +99 -0
- package/src/manager/LogoutManager.ts +57 -0
- package/src/manager/NetworkManager.ts +346 -0
- package/src/manager/PollingSubscription.ts +190 -0
- package/src/manager/SubscriptionManager.ts +156 -0
- package/src/manager/__tests__/__snapshots__/pollingSubscription-endpoint.ts.snap +49 -0
- package/src/manager/__tests__/__snapshots__/pollingSubscription.ts.snap +43 -0
- package/src/manager/__tests__/logoutManager.ts +112 -0
- package/src/manager/__tests__/manager.ts +44 -0
- package/src/manager/__tests__/networkManager-legacy.ts +394 -0
- package/src/manager/__tests__/networkManager.ts +426 -0
- package/src/manager/__tests__/pollingSubscription-endpoint.ts +423 -0
- package/src/manager/__tests__/pollingSubscription.ts +313 -0
- package/src/manager/__tests__/subscriptionManager.ts +208 -0
- package/src/manager/applyManager.ts +33 -0
- package/src/manager/devtoolsTypes.ts +210 -0
- package/src/manager/index.ts +7 -0
- package/src/middlewareTypes.ts +49 -0
- package/src/newActions.ts +140 -0
- package/src/next/Controller.ts +39 -0
- package/src/next/index.ts +2 -0
- package/src/package.json +1 -0
- package/src/previousActions.ts +159 -0
- package/src/state/RIC.d.ts +2 -0
- package/src/state/RIC.js +5 -0
- package/src/state/__tests__/RIC.web.ts +16 -0
- package/src/state/__tests__/__snapshots__/reducer.ts.snap +56 -0
- package/src/state/__tests__/applyUpdatersToResults.ts +40 -0
- package/src/state/__tests__/reducer.ts +868 -0
- package/src/state/applyUpdatersToResults.ts +29 -0
- package/src/state/legacy-actions/createFetch.ts +95 -0
- package/src/state/legacy-actions/createReceive.ts +68 -0
- package/src/state/legacy-actions/createReceiveError.ts +43 -0
- package/src/state/legacy-actions/index.ts +3 -0
- package/src/state/reducer/createReducer.ts +80 -0
- package/src/state/reducer/fetchReducer.ts +48 -0
- package/src/state/reducer/invalidateReducer.ts +39 -0
- package/src/state/reducer/setReducer.ts +157 -0
- package/src/state/reducerInstance.ts +14 -0
- package/src/state/selectMeta.ts +8 -0
- package/src/types.ts +125 -0
- package/ts3.4/actionTypes.d.ts +11 -0
- package/ts3.4/compatibleActions.d.ts +47 -0
- package/ts3.4/controller/BaseController.d.ts +170 -0
- package/ts3.4/controller/Controller.d.ts +14 -0
- package/ts3.4/controller/createFetch.d.ts +14 -0
- package/ts3.4/controller/createInvalidate.d.ts +8 -0
- package/ts3.4/controller/createInvalidateAll.d.ts +3 -0
- package/ts3.4/controller/createOptimistic.d.ts +12 -0
- package/ts3.4/controller/createReceive.d.ts +24 -0
- package/ts3.4/controller/createReset.d.ts +3 -0
- package/ts3.4/controller/createSubscription.d.ts +13 -0
- package/ts3.4/controller/types.d.ts +6 -0
- package/ts3.4/endpoint/index.d.ts +3 -0
- package/ts3.4/endpoint/shapes.d.ts +25 -0
- package/ts3.4/endpoint/types.d.ts +45 -0
- package/ts3.4/fsa.d.ts +41 -0
- package/ts3.4/index.d.ts +22 -0
- package/ts3.4/internal.d.ts +4 -0
- package/ts3.4/legacyActions.d.ts +95 -0
- package/ts3.4/manager/ConnectionListener.d.ts +8 -0
- package/ts3.4/manager/DefaultConnectionListener.d.ts +20 -0
- package/ts3.4/manager/DevtoolsManager.d.ts +24 -0
- package/ts3.4/manager/LogoutManager.d.ts +25 -0
- package/ts3.4/manager/NetworkManager.d.ts +82 -0
- package/ts3.4/manager/PollingSubscription.d.ts +45 -0
- package/ts3.4/manager/SubscriptionManager.d.ts +55 -0
- package/ts3.4/manager/applyManager.d.ts +10 -0
- package/ts3.4/manager/devtoolsTypes.d.ts +205 -0
- package/ts3.4/manager/index.d.ts +8 -0
- package/ts3.4/middlewareTypes.d.ts +18 -0
- package/ts3.4/newActions.d.ts +88 -0
- package/ts3.4/next/Controller.d.ts +14 -0
- package/ts3.4/next/index.d.ts +3 -0
- package/ts3.4/previousActions.d.ts +94 -0
- package/ts3.4/state/RIC.d.ts +2 -0
- package/ts3.4/state/applyUpdatersToResults.d.ts +13 -0
- package/ts3.4/state/legacy-actions/createFetch.d.ts +19 -0
- package/ts3.4/state/legacy-actions/createReceive.d.ts +14 -0
- package/ts3.4/state/legacy-actions/createReceiveError.d.ts +9 -0
- package/ts3.4/state/legacy-actions/index.d.ts +4 -0
- package/ts3.4/state/reducer/createReducer.d.ts +7 -0
- package/ts3.4/state/reducer/fetchReducer.d.ts +4 -0
- package/ts3.4/state/reducer/invalidateReducer.d.ts +37 -0
- package/ts3.4/state/reducer/setReducer.d.ts +40 -0
- package/ts3.4/state/reducerInstance.d.ts +7 -0
- package/ts3.4/state/selectMeta.d.ts +3 -0
- package/ts3.4/types.d.ts +73 -0
- package/typescript.svg +8 -0
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
type Action = any;
|
|
2
|
+
type ActionCreator<T> = any;
|
|
3
|
+
|
|
4
|
+
// taken from https://github.com/reduxjs/redux-devtools/blob/main/packages/redux-devtools-extension/src/index.ts
|
|
5
|
+
|
|
6
|
+
export interface EnhancerOptions {
|
|
7
|
+
/**
|
|
8
|
+
* the instance name to be showed on the monitor page. Default value is `document.title`.
|
|
9
|
+
* If not specified and there's no document title, it will consist of `tabId` and `instanceId`.
|
|
10
|
+
*/
|
|
11
|
+
name?: string;
|
|
12
|
+
/**
|
|
13
|
+
* action creators functions to be available in the Dispatcher.
|
|
14
|
+
*/
|
|
15
|
+
actionCreators?: ActionCreator<any>[] | { [key: string]: ActionCreator<any> };
|
|
16
|
+
/**
|
|
17
|
+
* if more than one action is dispatched in the indicated interval, all new actions will be collected and sent at once.
|
|
18
|
+
* It is the joint between performance and speed. When set to `0`, all actions will be sent instantly.
|
|
19
|
+
* Set it to a higher value when experiencing perf issues (also `maxAge` to a lower value).
|
|
20
|
+
*
|
|
21
|
+
* @default 500 ms.
|
|
22
|
+
*/
|
|
23
|
+
latency?: number;
|
|
24
|
+
/**
|
|
25
|
+
* (> 1) - maximum allowed actions to be stored in the history tree. The oldest actions are removed once maxAge is reached. It's critical for performance.
|
|
26
|
+
*
|
|
27
|
+
* @default 50
|
|
28
|
+
*/
|
|
29
|
+
maxAge?: number;
|
|
30
|
+
/**
|
|
31
|
+
* Customizes how actions and state are serialized and deserialized. Can be a boolean or object. If given a boolean, the behavior is the same as if you
|
|
32
|
+
* were to pass an object and specify `options` as a boolean. Giving an object allows fine-grained customization using the `replacer` and `reviver`
|
|
33
|
+
* functions.
|
|
34
|
+
*/
|
|
35
|
+
serialize?:
|
|
36
|
+
| boolean
|
|
37
|
+
| {
|
|
38
|
+
/**
|
|
39
|
+
* - `undefined` - will use regular `JSON.stringify` to send data (it's the fast mode).
|
|
40
|
+
* - `false` - will handle also circular references.
|
|
41
|
+
* - `true` - will handle also date, regex, undefined, error objects, symbols, maps, sets and functions.
|
|
42
|
+
* - object, which contains `date`, `regex`, `undefined`, `error`, `symbol`, `map`, `set` and `function` keys.
|
|
43
|
+
* For each of them you can indicate if to include (by setting as `true`).
|
|
44
|
+
* For `function` key you can also specify a custom function which handles serialization.
|
|
45
|
+
* See [`jsan`](https://github.com/kolodny/jsan) for more details.
|
|
46
|
+
*/
|
|
47
|
+
options?:
|
|
48
|
+
| undefined
|
|
49
|
+
| boolean
|
|
50
|
+
| {
|
|
51
|
+
date?: true;
|
|
52
|
+
regex?: true;
|
|
53
|
+
undefined?: true;
|
|
54
|
+
error?: true;
|
|
55
|
+
symbol?: true;
|
|
56
|
+
map?: true;
|
|
57
|
+
set?: true;
|
|
58
|
+
function?: true | ((fn: (...args: any[]) => any) => string);
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* [JSON replacer function](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#The_replacer_parameter) used for both actions and states stringify.
|
|
62
|
+
* In addition, you can specify a data type by adding a [`__serializedType__`](https://github.com/zalmoxisus/remotedev-serialize/blob/master/helpers/index.js#L4)
|
|
63
|
+
* key. So you can deserialize it back while importing or persisting data.
|
|
64
|
+
* Moreover, it will also [show a nice preview showing the provided custom type](https://cloud.githubusercontent.com/assets/7957859/21814330/a17d556a-d761-11e6-85ef-159dd12f36c5.png):
|
|
65
|
+
*/
|
|
66
|
+
replacer?: (key: string, value: unknown) => any;
|
|
67
|
+
/**
|
|
68
|
+
* [JSON `reviver` function](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#Using_the_reviver_parameter)
|
|
69
|
+
* used for parsing the imported actions and states. See [`remotedev-serialize`](https://github.com/zalmoxisus/remotedev-serialize/blob/master/immutable/serialize.js#L8-L41)
|
|
70
|
+
* as an example on how to serialize special data types and get them back.
|
|
71
|
+
*/
|
|
72
|
+
reviver?: (key: string, value: unknown) => any;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* function which takes `action` object and id number as arguments, and should return `action` object back.
|
|
76
|
+
*/
|
|
77
|
+
actionSanitizer?: <A extends Action>(action: A, id: number) => A;
|
|
78
|
+
/**
|
|
79
|
+
* function which takes `state` object and index as arguments, and should return `state` object back.
|
|
80
|
+
*/
|
|
81
|
+
stateSanitizer?: <S>(state: S, index: number) => S;
|
|
82
|
+
/**
|
|
83
|
+
* *string or array of strings as regex* - actions types to be hidden / shown in the monitors (while passed to the reducers).
|
|
84
|
+
* If `actionsWhitelist` specified, `actionsBlacklist` is ignored.
|
|
85
|
+
* @deprecated Use actionsDenylist instead.
|
|
86
|
+
*/
|
|
87
|
+
actionsBlacklist?: string | string[];
|
|
88
|
+
/**
|
|
89
|
+
* *string or array of strings as regex* - actions types to be hidden / shown in the monitors (while passed to the reducers).
|
|
90
|
+
* If `actionsWhitelist` specified, `actionsBlacklist` is ignored.
|
|
91
|
+
* @deprecated Use actionsAllowlist instead.
|
|
92
|
+
*/
|
|
93
|
+
actionsWhitelist?: string | string[];
|
|
94
|
+
/**
|
|
95
|
+
* *string or array of strings as regex* - actions types to be hidden / shown in the monitors (while passed to the reducers).
|
|
96
|
+
* If `actionsAllowlist` specified, `actionsDenylist` is ignored.
|
|
97
|
+
*/
|
|
98
|
+
actionsDenylist?: string | string[];
|
|
99
|
+
/**
|
|
100
|
+
* *string or array of strings as regex* - actions types to be hidden / shown in the monitors (while passed to the reducers).
|
|
101
|
+
* If `actionsAllowlist` specified, `actionsDenylist` is ignored.
|
|
102
|
+
*/
|
|
103
|
+
actionsAllowlist?: string | string[];
|
|
104
|
+
/**
|
|
105
|
+
* called for every action before sending, takes `state` and `action` object, and returns `true` in case it allows sending the current data to the monitor.
|
|
106
|
+
* Use it as a more advanced version of `actionsDenylist`/`actionsAllowlist` parameters.
|
|
107
|
+
*/
|
|
108
|
+
predicate?: <S, A extends Action>(state: S, action: A) => boolean;
|
|
109
|
+
/**
|
|
110
|
+
* if specified as `false`, it will not record the changes till clicking on `Start recording` button.
|
|
111
|
+
* Available only for Redux enhancer, for others use `autoPause`.
|
|
112
|
+
*
|
|
113
|
+
* @default true
|
|
114
|
+
*/
|
|
115
|
+
shouldRecordChanges?: boolean;
|
|
116
|
+
/**
|
|
117
|
+
* if specified, whenever clicking on `Pause recording` button and there are actions in the history log, will add this action type.
|
|
118
|
+
* If not specified, will commit when paused. Available only for Redux enhancer.
|
|
119
|
+
*
|
|
120
|
+
* @default "@@PAUSED""
|
|
121
|
+
*/
|
|
122
|
+
pauseActionType?: string;
|
|
123
|
+
/**
|
|
124
|
+
* auto pauses when the extension’s window is not opened, and so has zero impact on your app when not in use.
|
|
125
|
+
* Not available for Redux enhancer (as it already does it but storing the data to be sent).
|
|
126
|
+
*
|
|
127
|
+
* @default false
|
|
128
|
+
*/
|
|
129
|
+
autoPause?: boolean;
|
|
130
|
+
/**
|
|
131
|
+
* if specified as `true`, it will not allow any non-monitor actions to be dispatched till clicking on `Unlock changes` button.
|
|
132
|
+
* Available only for Redux enhancer.
|
|
133
|
+
*
|
|
134
|
+
* @default false
|
|
135
|
+
*/
|
|
136
|
+
shouldStartLocked?: boolean;
|
|
137
|
+
/**
|
|
138
|
+
* if set to `false`, will not recompute the states on hot reloading (or on replacing the reducers). Available only for Redux enhancer.
|
|
139
|
+
*
|
|
140
|
+
* @default true
|
|
141
|
+
*/
|
|
142
|
+
shouldHotReload?: boolean;
|
|
143
|
+
/**
|
|
144
|
+
* if specified as `true`, whenever there's an exception in reducers, the monitors will show the error message, and next actions will not be dispatched.
|
|
145
|
+
*
|
|
146
|
+
* @default false
|
|
147
|
+
*/
|
|
148
|
+
shouldCatchErrors?: boolean;
|
|
149
|
+
/**
|
|
150
|
+
* If you want to restrict the extension, specify the features you allow.
|
|
151
|
+
* If not specified, all of the features are enabled. When set as an object, only those included as `true` will be allowed.
|
|
152
|
+
* Note that except `true`/`false`, `import` and `export` can be set as `custom` (which is by default for Redux enhancer), meaning that the importing/exporting occurs on the client side.
|
|
153
|
+
* Otherwise, you'll get/set the data right from the monitor part.
|
|
154
|
+
*/
|
|
155
|
+
features?: {
|
|
156
|
+
/**
|
|
157
|
+
* start/pause recording of dispatched actions
|
|
158
|
+
*/
|
|
159
|
+
pause?: boolean;
|
|
160
|
+
/**
|
|
161
|
+
* lock/unlock dispatching actions and side effects
|
|
162
|
+
*/
|
|
163
|
+
lock?: boolean;
|
|
164
|
+
/**
|
|
165
|
+
* persist states on page reloading
|
|
166
|
+
*/
|
|
167
|
+
persist?: boolean;
|
|
168
|
+
/**
|
|
169
|
+
* export history of actions in a file
|
|
170
|
+
*/
|
|
171
|
+
export?: boolean | 'custom';
|
|
172
|
+
/**
|
|
173
|
+
* import history of actions from a file
|
|
174
|
+
*/
|
|
175
|
+
import?: boolean | 'custom';
|
|
176
|
+
/**
|
|
177
|
+
* jump back and forth (time travelling)
|
|
178
|
+
*/
|
|
179
|
+
jump?: boolean;
|
|
180
|
+
/**
|
|
181
|
+
* skip (cancel) actions
|
|
182
|
+
*/
|
|
183
|
+
skip?: boolean;
|
|
184
|
+
/**
|
|
185
|
+
* drag and drop actions in the history list
|
|
186
|
+
*/
|
|
187
|
+
reorder?: boolean;
|
|
188
|
+
/**
|
|
189
|
+
* dispatch custom actions or action creators
|
|
190
|
+
*/
|
|
191
|
+
dispatch?: boolean;
|
|
192
|
+
/**
|
|
193
|
+
* generate tests for the selected actions
|
|
194
|
+
*/
|
|
195
|
+
test?: boolean;
|
|
196
|
+
};
|
|
197
|
+
/**
|
|
198
|
+
* Set to true or a stacktrace-returning function to record call stack traces for dispatched actions.
|
|
199
|
+
* Defaults to false.
|
|
200
|
+
*/
|
|
201
|
+
trace?: boolean | (<A extends Action>(action: A) => string);
|
|
202
|
+
/**
|
|
203
|
+
* The maximum number of stack trace entries to record per action. Defaults to 10.
|
|
204
|
+
*/
|
|
205
|
+
traceLimit?: number;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export interface DevToolsConfig extends EnhancerOptions {
|
|
209
|
+
type?: string;
|
|
210
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type { default as ConnectionListener } from './ConnectionListener.js';
|
|
2
|
+
export { default as DefaultConnectionListener } from './DefaultConnectionListener.js';
|
|
3
|
+
export { default as PollingSubscription } from './PollingSubscription.js';
|
|
4
|
+
export { default as SubscriptionManager } from './SubscriptionManager.js';
|
|
5
|
+
export { default as DevToolsManager } from './DevtoolsManager.js';
|
|
6
|
+
export { default as LogoutManager } from './LogoutManager.js';
|
|
7
|
+
export type { DevToolsConfig } from './DevtoolsManager.js';
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type Controller from './controller/Controller.js';
|
|
2
|
+
//import type { ActionTypes as LegacyActionTypes } from './legacyActions.js';
|
|
3
|
+
import type { ActionTypes } from './newActions.js';
|
|
4
|
+
import {
|
|
5
|
+
ActionTypes as LegacyActionTypes,
|
|
6
|
+
CombinedActionTypes,
|
|
7
|
+
State,
|
|
8
|
+
} from './types.js';
|
|
9
|
+
|
|
10
|
+
type RHDispatch<Actions = any> = (value: Actions) => Promise<void>;
|
|
11
|
+
|
|
12
|
+
export interface MiddlewareAPI<R extends RestHooksReducer = RestHooksReducer>
|
|
13
|
+
extends Controller<RHDispatch<CombinedActionTypes>> {
|
|
14
|
+
controller: Controller<RHDispatch<CombinedActionTypes>>;
|
|
15
|
+
}
|
|
16
|
+
export interface MiddlewareController<Actions = LegacyActionTypes>
|
|
17
|
+
extends Controller<RHDispatch<Actions>> {
|
|
18
|
+
controller: Controller<RHDispatch<Actions>>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type Middleware<Actions = any> = <
|
|
22
|
+
C extends MiddlewareController<Actions>,
|
|
23
|
+
>(
|
|
24
|
+
controller: C,
|
|
25
|
+
) => (next: C['dispatch']) => C['dispatch'];
|
|
26
|
+
|
|
27
|
+
export type RestHooksReducer = (
|
|
28
|
+
prevState: State<unknown>,
|
|
29
|
+
action: ActionTypes,
|
|
30
|
+
) => State<unknown>;
|
|
31
|
+
|
|
32
|
+
/* The next are types from React; but we don't want dependencies on it */
|
|
33
|
+
export type Dispatch<R extends Reducer<any, any>> = (
|
|
34
|
+
action: ReducerAction<R>,
|
|
35
|
+
) => Promise<void>;
|
|
36
|
+
|
|
37
|
+
export type Reducer<S, A> = (prevState: S, action: A) => S;
|
|
38
|
+
export type ReducerState<R extends Reducer<any, any>> = R extends Reducer<
|
|
39
|
+
infer S,
|
|
40
|
+
any
|
|
41
|
+
>
|
|
42
|
+
? S
|
|
43
|
+
: never;
|
|
44
|
+
export type ReducerAction<R extends Reducer<any, any>> = R extends Reducer<
|
|
45
|
+
any,
|
|
46
|
+
infer A
|
|
47
|
+
>
|
|
48
|
+
? A
|
|
49
|
+
: never;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
EndpointInterface,
|
|
3
|
+
ResolveType,
|
|
4
|
+
UnknownError,
|
|
5
|
+
} from '@data-client/normalizr';
|
|
6
|
+
|
|
7
|
+
import type {
|
|
8
|
+
SET_TYPE,
|
|
9
|
+
RESET_TYPE,
|
|
10
|
+
FETCH_TYPE,
|
|
11
|
+
SUBSCRIBE_TYPE,
|
|
12
|
+
UNSUBSCRIBE_TYPE,
|
|
13
|
+
INVALIDATE_TYPE,
|
|
14
|
+
GC_TYPE,
|
|
15
|
+
OPTIMISTIC_TYPE,
|
|
16
|
+
INVALIDATEALL_TYPE,
|
|
17
|
+
} from './actionTypes.js';
|
|
18
|
+
import type { EndpointUpdateFunction } from './controller/types.js';
|
|
19
|
+
|
|
20
|
+
/* RECEIVE */
|
|
21
|
+
export interface ReceiveMeta {
|
|
22
|
+
args: readonly any[];
|
|
23
|
+
fetchedAt: number;
|
|
24
|
+
date: number;
|
|
25
|
+
expiresAt: number;
|
|
26
|
+
}
|
|
27
|
+
export interface ReceiveActionSuccess<
|
|
28
|
+
E extends EndpointInterface = EndpointInterface,
|
|
29
|
+
> {
|
|
30
|
+
type: typeof SET_TYPE;
|
|
31
|
+
endpoint: E;
|
|
32
|
+
meta: ReceiveMeta;
|
|
33
|
+
payload: ResolveType<E>;
|
|
34
|
+
error?: false;
|
|
35
|
+
}
|
|
36
|
+
export interface ReceiveActionError<
|
|
37
|
+
E extends EndpointInterface = EndpointInterface,
|
|
38
|
+
> {
|
|
39
|
+
type: typeof SET_TYPE;
|
|
40
|
+
endpoint: E;
|
|
41
|
+
meta: ReceiveMeta;
|
|
42
|
+
payload: UnknownError;
|
|
43
|
+
error: true;
|
|
44
|
+
}
|
|
45
|
+
export type ReceiveAction<E extends EndpointInterface = EndpointInterface> =
|
|
46
|
+
| ReceiveActionSuccess<E>
|
|
47
|
+
| ReceiveActionError<E>;
|
|
48
|
+
|
|
49
|
+
export type SetAction<E extends EndpointInterface = EndpointInterface> =
|
|
50
|
+
ReceiveAction<E>;
|
|
51
|
+
|
|
52
|
+
/* FETCH */
|
|
53
|
+
export interface FetchMeta {
|
|
54
|
+
args: readonly any[];
|
|
55
|
+
throttle: boolean;
|
|
56
|
+
resolve: (value?: any | PromiseLike<any>) => void;
|
|
57
|
+
reject: (reason?: any) => void;
|
|
58
|
+
promise: PromiseLike<any>;
|
|
59
|
+
createdAt: number;
|
|
60
|
+
// indicates whether network manager processed it
|
|
61
|
+
nm?: boolean;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface FetchAction<E extends EndpointInterface = EndpointInterface> {
|
|
65
|
+
type: typeof FETCH_TYPE;
|
|
66
|
+
endpoint: E;
|
|
67
|
+
meta: FetchMeta;
|
|
68
|
+
payload: () => ReturnType<E>;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/* OPTIMISTIC */
|
|
72
|
+
export interface OptimisticAction<
|
|
73
|
+
E extends EndpointInterface & {
|
|
74
|
+
update?: EndpointUpdateFunction<E>;
|
|
75
|
+
} = EndpointInterface & {
|
|
76
|
+
update?: EndpointUpdateFunction<EndpointInterface>;
|
|
77
|
+
},
|
|
78
|
+
> {
|
|
79
|
+
type: typeof OPTIMISTIC_TYPE;
|
|
80
|
+
endpoint: E;
|
|
81
|
+
meta: ReceiveMeta;
|
|
82
|
+
error?: boolean;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/* SUBSCRIBE */
|
|
86
|
+
export interface SubscribeAction<
|
|
87
|
+
E extends EndpointInterface = EndpointInterface,
|
|
88
|
+
> {
|
|
89
|
+
type: typeof SUBSCRIBE_TYPE;
|
|
90
|
+
endpoint: E;
|
|
91
|
+
meta: {
|
|
92
|
+
args: readonly any[];
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export interface UnsubscribeAction<
|
|
97
|
+
E extends EndpointInterface = EndpointInterface,
|
|
98
|
+
> {
|
|
99
|
+
type: typeof UNSUBSCRIBE_TYPE;
|
|
100
|
+
endpoint: E;
|
|
101
|
+
meta: {
|
|
102
|
+
args: readonly any[];
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/* INVALIDATE */
|
|
107
|
+
export interface InvalidateAllAction {
|
|
108
|
+
type: typeof INVALIDATEALL_TYPE;
|
|
109
|
+
testKey: (key: string) => boolean;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export interface InvalidateAction {
|
|
113
|
+
type: typeof INVALIDATE_TYPE;
|
|
114
|
+
meta: {
|
|
115
|
+
key: string;
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/* RESET */
|
|
120
|
+
export interface ResetAction {
|
|
121
|
+
type: typeof RESET_TYPE;
|
|
122
|
+
date: number;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/* GC */
|
|
126
|
+
export interface GCAction {
|
|
127
|
+
type: typeof GC_TYPE;
|
|
128
|
+
entities: [string, string][];
|
|
129
|
+
results: string[];
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export type ActionTypes =
|
|
133
|
+
| FetchAction
|
|
134
|
+
| OptimisticAction
|
|
135
|
+
| ReceiveAction
|
|
136
|
+
| SubscribeAction
|
|
137
|
+
| UnsubscribeAction
|
|
138
|
+
| InvalidateAction
|
|
139
|
+
| ResetAction
|
|
140
|
+
| GCAction;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { EndpointInterface, Denormalize } from '@data-client/normalizr';
|
|
2
|
+
import { denormalize } from '@data-client/normalizr';
|
|
3
|
+
|
|
4
|
+
import BaseController, {
|
|
5
|
+
CompatibleDispatch,
|
|
6
|
+
GenericDispatch,
|
|
7
|
+
} from '../controller/BaseController.js';
|
|
8
|
+
import createFetch from '../controller/createFetch.js';
|
|
9
|
+
import type { EndpointUpdateFunction } from '../controller/types.js';
|
|
10
|
+
|
|
11
|
+
export default class Controller<
|
|
12
|
+
D extends GenericDispatch = CompatibleDispatch,
|
|
13
|
+
> extends BaseController<D> {
|
|
14
|
+
/**
|
|
15
|
+
* Fetches the endpoint with given args, updating the Rest Hooks cache with the response or error upon completion.
|
|
16
|
+
* @see https://resthooks.io/docs/api/Controller#fetch
|
|
17
|
+
*/
|
|
18
|
+
fetch = <
|
|
19
|
+
E extends EndpointInterface & { update?: EndpointUpdateFunction<E> },
|
|
20
|
+
>(
|
|
21
|
+
endpoint: E,
|
|
22
|
+
...args: readonly [...Parameters<E>]
|
|
23
|
+
): E['schema'] extends undefined | null
|
|
24
|
+
? ReturnType<E>
|
|
25
|
+
: Promise<Denormalize<E['schema']>> => {
|
|
26
|
+
const action = createFetch(endpoint, {
|
|
27
|
+
args,
|
|
28
|
+
});
|
|
29
|
+
this.dispatch(action);
|
|
30
|
+
|
|
31
|
+
if (endpoint.schema) {
|
|
32
|
+
return action.meta.promise.then(input =>
|
|
33
|
+
denormalize(input, endpoint.schema, {}, args),
|
|
34
|
+
) as any;
|
|
35
|
+
}
|
|
36
|
+
return action.meta.promise as any;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export * from '../controller/BaseController.js';
|
package/src/package.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import {
|
|
2
|
+
EndpointExtraOptions,
|
|
3
|
+
EndpointInterface,
|
|
4
|
+
Schema,
|
|
5
|
+
} from '@data-client/normalizr';
|
|
6
|
+
import type { UpdateFunction } from '@data-client/normalizr';
|
|
7
|
+
import { FSAWithMeta, FSAWithPayloadAndMeta } from 'flux-standard-action';
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
FETCH_TYPE,
|
|
11
|
+
GC_TYPE,
|
|
12
|
+
INVALIDATE_TYPE,
|
|
13
|
+
OPTIMISTIC_TYPE,
|
|
14
|
+
RECEIVE_TYPE,
|
|
15
|
+
RESET_TYPE,
|
|
16
|
+
SUBSCRIBE_TYPE,
|
|
17
|
+
UNSUBSCRIBE_TYPE,
|
|
18
|
+
} from './actionTypes.js';
|
|
19
|
+
import { EndpointUpdateFunction } from './controller/types.js';
|
|
20
|
+
import { FetchShape } from './endpoint/index.js';
|
|
21
|
+
import { ErrorableFSAWithPayloadAndMeta } from './fsa.js';
|
|
22
|
+
import type { InvalidateAction, InvalidateAllAction } from './newActions.js';
|
|
23
|
+
|
|
24
|
+
export interface ReceiveMeta<S extends Schema | undefined> {
|
|
25
|
+
schema?: S;
|
|
26
|
+
key: string;
|
|
27
|
+
args?: readonly any[];
|
|
28
|
+
updaters?: Record<string, UpdateFunction<S, any>>;
|
|
29
|
+
update?: (result: any, ...args: any) => Record<string, (...args: any) => any>;
|
|
30
|
+
fetchedAt?: number;
|
|
31
|
+
date: number;
|
|
32
|
+
expiresAt: number;
|
|
33
|
+
errorPolicy?: (error: any) => 'hard' | 'soft' | undefined;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export type ReceiveAction<
|
|
37
|
+
Payload extends object | string | number | null =
|
|
38
|
+
| object
|
|
39
|
+
| string
|
|
40
|
+
| number
|
|
41
|
+
| null,
|
|
42
|
+
S extends Schema | undefined = any,
|
|
43
|
+
> = ErrorableFSAWithPayloadAndMeta<
|
|
44
|
+
typeof RECEIVE_TYPE,
|
|
45
|
+
Payload,
|
|
46
|
+
ReceiveMeta<S>
|
|
47
|
+
> & { endpoint?: EndpointInterface };
|
|
48
|
+
|
|
49
|
+
export type OptimisticAction<
|
|
50
|
+
E extends EndpointInterface & {
|
|
51
|
+
update?: EndpointUpdateFunction<E>;
|
|
52
|
+
} = EndpointInterface & {
|
|
53
|
+
update?: EndpointUpdateFunction<EndpointInterface>;
|
|
54
|
+
},
|
|
55
|
+
> = {
|
|
56
|
+
type: typeof OPTIMISTIC_TYPE;
|
|
57
|
+
meta: {
|
|
58
|
+
schema: E['schema'];
|
|
59
|
+
key: string;
|
|
60
|
+
args: readonly any[];
|
|
61
|
+
update?: (
|
|
62
|
+
result: any,
|
|
63
|
+
...args: any
|
|
64
|
+
) => Record<string, (...args: any) => any>;
|
|
65
|
+
fetchedAt: number;
|
|
66
|
+
date: number;
|
|
67
|
+
expiresAt: number;
|
|
68
|
+
errorPolicy?: (error: any) => 'hard' | 'soft' | undefined;
|
|
69
|
+
};
|
|
70
|
+
endpoint: E;
|
|
71
|
+
error?: undefined;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export interface ResetAction {
|
|
75
|
+
type: typeof RESET_TYPE;
|
|
76
|
+
date: number | Date;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
interface FetchMeta<
|
|
80
|
+
Payload extends object | string | number | null =
|
|
81
|
+
| object
|
|
82
|
+
| string
|
|
83
|
+
| number
|
|
84
|
+
| null,
|
|
85
|
+
S extends Schema | undefined = any,
|
|
86
|
+
> {
|
|
87
|
+
type: FetchShape<any, any>['type'];
|
|
88
|
+
schema?: S;
|
|
89
|
+
key: string;
|
|
90
|
+
args?: readonly any[];
|
|
91
|
+
updaters?: Record<string, UpdateFunction<S, any>>;
|
|
92
|
+
update?: (result: any, ...args: any) => Record<string, (...args: any) => any>;
|
|
93
|
+
options?: EndpointExtraOptions;
|
|
94
|
+
throttle: boolean;
|
|
95
|
+
resolve: (value?: any | PromiseLike<any>) => void;
|
|
96
|
+
reject: (reason?: any) => void;
|
|
97
|
+
promise: PromiseLike<any>;
|
|
98
|
+
createdAt: number | Date;
|
|
99
|
+
optimisticResponse?: Payload;
|
|
100
|
+
// indicates whether network manager processed it
|
|
101
|
+
nm?: boolean;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export interface FetchAction<
|
|
105
|
+
Payload extends object | string | number | null =
|
|
106
|
+
| object
|
|
107
|
+
| string
|
|
108
|
+
| number
|
|
109
|
+
| null,
|
|
110
|
+
S extends Schema | undefined = any,
|
|
111
|
+
> extends FSAWithPayloadAndMeta<
|
|
112
|
+
typeof FETCH_TYPE,
|
|
113
|
+
() => Promise<Payload>,
|
|
114
|
+
FetchMeta<any, any>
|
|
115
|
+
> {
|
|
116
|
+
meta: FetchMeta<Payload, S>;
|
|
117
|
+
endpoint?: EndpointInterface;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export interface SubscribeAction
|
|
121
|
+
extends FSAWithMeta<typeof SUBSCRIBE_TYPE, undefined, any> {
|
|
122
|
+
endpoint?: EndpointInterface;
|
|
123
|
+
meta: {
|
|
124
|
+
args?: readonly any[];
|
|
125
|
+
schema: Schema | undefined;
|
|
126
|
+
fetch: () => Promise<any>;
|
|
127
|
+
key: string;
|
|
128
|
+
options: EndpointExtraOptions | undefined;
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export interface UnsubscribeAction
|
|
133
|
+
extends FSAWithMeta<typeof UNSUBSCRIBE_TYPE, undefined, any> {
|
|
134
|
+
endpoint?: EndpointInterface;
|
|
135
|
+
meta: {
|
|
136
|
+
args?: readonly any[];
|
|
137
|
+
key: string;
|
|
138
|
+
options: EndpointExtraOptions | undefined;
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export type { InvalidateAction, InvalidateAllAction };
|
|
143
|
+
|
|
144
|
+
export interface GCAction {
|
|
145
|
+
type: typeof GC_TYPE;
|
|
146
|
+
entities: [string, string][];
|
|
147
|
+
results: string[];
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export type ActionTypes =
|
|
151
|
+
| FetchAction
|
|
152
|
+
| OptimisticAction
|
|
153
|
+
| ReceiveAction
|
|
154
|
+
| SubscribeAction
|
|
155
|
+
| UnsubscribeAction
|
|
156
|
+
| InvalidateAction
|
|
157
|
+
| InvalidateAllAction
|
|
158
|
+
| ResetAction
|
|
159
|
+
| GCAction;
|
package/src/state/RIC.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
describe('RequestIdleCallback', () => {
|
|
2
|
+
it('should still run when requestIdleCallback is not available', () => {
|
|
3
|
+
const requestIdle = (global as any).requestIdleCallback;
|
|
4
|
+
(global as any).requestIdleCallback = undefined;
|
|
5
|
+
jest.resetModules();
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
7
|
+
const RIC = require('../RIC').default;
|
|
8
|
+
const fn = jest.fn();
|
|
9
|
+
jest.useFakeTimers();
|
|
10
|
+
RIC(fn, {});
|
|
11
|
+
jest.runAllTimers();
|
|
12
|
+
expect(fn).toBeCalled();
|
|
13
|
+
(global as any).requestIdleCallback = requestIdle;
|
|
14
|
+
jest.useRealTimers();
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`reducer should set error in meta for "receive" 1`] = `
|
|
4
|
+
{
|
|
5
|
+
"entities": {},
|
|
6
|
+
"entityMeta": {},
|
|
7
|
+
"indexes": {},
|
|
8
|
+
"lastReset": 0,
|
|
9
|
+
"meta": {
|
|
10
|
+
"GET http://test.com/article/20": {
|
|
11
|
+
"date": 5000000000,
|
|
12
|
+
"error": [Error: hi],
|
|
13
|
+
"errorPolicy": undefined,
|
|
14
|
+
"expiresAt": 5000500000,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
"optimistic": [],
|
|
18
|
+
"results": {},
|
|
19
|
+
}
|
|
20
|
+
`;
|
|
21
|
+
|
|
22
|
+
exports[`reducer singles should update state correctly 1`] = `
|
|
23
|
+
{
|
|
24
|
+
"entities": {
|
|
25
|
+
"Article": {
|
|
26
|
+
"20": {
|
|
27
|
+
"content": "this is the content",
|
|
28
|
+
"id": 20,
|
|
29
|
+
"title": "hi",
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
"entityMeta": {
|
|
34
|
+
"Article": {
|
|
35
|
+
"20": {
|
|
36
|
+
"date": 5000000000,
|
|
37
|
+
"expiresAt": 5000500000,
|
|
38
|
+
"fetchedAt": 5000000000,
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
"indexes": {},
|
|
43
|
+
"lastReset": 0,
|
|
44
|
+
"meta": {
|
|
45
|
+
"http://test.com/article/20": {
|
|
46
|
+
"date": 5000000000,
|
|
47
|
+
"expiresAt": 5000500000,
|
|
48
|
+
"prevExpiresAt": undefined,
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
"optimistic": [],
|
|
52
|
+
"results": {
|
|
53
|
+
"http://test.com/article/20": "20",
|
|
54
|
+
},
|
|
55
|
+
}
|
|
56
|
+
`;
|