@data-client/core 0.14.2 → 0.14.5
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 +73 -101
- package/dist/index.umd.min.js +1 -1
- package/legacy/index.js +1 -1
- package/legacy/manager/DevtoolsManager.js +50 -52
- package/legacy/manager/LogoutManager.js +3 -8
- package/legacy/manager/NetworkManager.js +13 -22
- package/legacy/manager/SubscriptionManager.js +2 -15
- package/legacy/manager/applyManager.js +5 -3
- package/legacy/middlewareTypes.js +1 -1
- package/legacy/state/reducer/createReducer.js +2 -2
- package/legacy/state/reducer/setReducer.js +3 -3
- package/legacy/state/reducer/setResponseReducer.js +3 -3
- package/legacy/types.js +13 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/manager/DevtoolsManager.d.ts +4 -7
- package/lib/manager/DevtoolsManager.d.ts.map +1 -1
- package/lib/manager/DevtoolsManager.js +50 -52
- package/lib/manager/LogoutManager.d.ts +5 -8
- package/lib/manager/LogoutManager.d.ts.map +1 -1
- package/lib/manager/LogoutManager.js +3 -8
- package/lib/manager/NetworkManager.d.ts +7 -12
- package/lib/manager/NetworkManager.d.ts.map +1 -1
- package/lib/manager/NetworkManager.js +13 -22
- package/lib/manager/SubscriptionManager.d.ts +2 -11
- package/lib/manager/SubscriptionManager.d.ts.map +1 -1
- package/lib/manager/SubscriptionManager.js +2 -15
- package/lib/manager/applyManager.d.ts +8 -5
- package/lib/manager/applyManager.d.ts.map +1 -1
- package/lib/manager/applyManager.js +5 -3
- package/lib/middlewareTypes.d.ts +6 -10
- package/lib/middlewareTypes.d.ts.map +1 -1
- package/lib/middlewareTypes.js +1 -1
- package/lib/state/reducer/createReducer.js +2 -2
- package/lib/state/reducer/expireReducer.d.ts +1 -1
- package/lib/state/reducer/setReducer.d.ts +4 -4
- package/lib/state/reducer/setReducer.js +3 -3
- package/lib/state/reducer/setResponseReducer.d.ts +4 -4
- package/lib/state/reducer/setResponseReducer.js +3 -3
- package/lib/types.d.ts +17 -2
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js +13 -1
- package/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/manager/DevtoolsManager.ts +37 -40
- package/src/manager/LogoutManager.ts +15 -27
- package/src/manager/NetworkManager.ts +58 -71
- package/src/manager/SubscriptionManager.ts +21 -34
- package/src/manager/__tests__/applyManager.ts +61 -1
- package/src/manager/__tests__/logoutManager.ts +8 -10
- package/src/manager/__tests__/manager.ts +2 -3
- package/src/manager/__tests__/networkManager.ts +16 -19
- package/src/manager/__tests__/subscriptionManager.ts +14 -16
- package/src/manager/applyManager.ts +20 -8
- package/src/middlewareTypes.ts +7 -17
- package/src/state/reducer/createReducer.ts +1 -1
- package/src/state/reducer/setReducer.ts +2 -2
- package/src/state/reducer/setResponseReducer.ts +2 -2
- package/src/types.ts +17 -2
- package/ts3.4/index.d.ts +1 -1
- package/ts3.4/manager/DevtoolsManager.d.ts +3 -6
- package/ts3.4/manager/LogoutManager.d.ts +4 -7
- package/ts3.4/manager/NetworkManager.d.ts +7 -12
- package/ts3.4/manager/SubscriptionManager.d.ts +2 -11
- package/ts3.4/manager/applyManager.d.ts +8 -5
- package/ts3.4/middlewareTypes.d.ts +5 -9
- package/ts3.4/state/reducer/expireReducer.d.ts +1 -1
- package/ts3.4/state/reducer/setReducer.d.ts +4 -4
- package/ts3.4/state/reducer/setResponseReducer.d.ts +4 -4
- package/ts3.4/types.d.ts +17 -2
package/src/middlewareTypes.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import type Controller from './controller/Controller.js';
|
|
2
|
-
import { ActionTypes, State } from './types.js';
|
|
2
|
+
import type { ActionTypes, State } from './types.js';
|
|
3
3
|
|
|
4
|
-
type
|
|
4
|
+
export type Dispatch<Actions = ActionTypes> = (value: Actions) => Promise<void>;
|
|
5
|
+
|
|
6
|
+
export interface MiddlewareAPI extends Controller<Dispatch<ActionTypes>> {}
|
|
5
7
|
|
|
6
|
-
export interface MiddlewareAPI<R extends DataClientReducer = DataClientReducer>
|
|
7
|
-
extends Controller<RHDispatch<ActionTypes>> {}
|
|
8
8
|
export interface MiddlewareController<Actions = ActionTypes>
|
|
9
|
-
extends Controller<
|
|
9
|
+
extends Controller<Dispatch<Actions>> {}
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
/** @see https://dataclient.io/docs/api/Manager#middleware */
|
|
12
|
+
export type Middleware<Actions = ActionTypes> = <
|
|
12
13
|
C extends MiddlewareController<Actions>,
|
|
13
14
|
>(
|
|
14
15
|
controller: C,
|
|
@@ -18,14 +19,3 @@ export type DataClientReducer = (
|
|
|
18
19
|
prevState: State<unknown>,
|
|
19
20
|
action: ActionTypes,
|
|
20
21
|
) => State<unknown>;
|
|
21
|
-
|
|
22
|
-
/* The next are types from React; but we don't want dependencies on it */
|
|
23
|
-
export type Dispatch<R extends Reducer<any, any>> = (
|
|
24
|
-
action: ReducerAction<R>,
|
|
25
|
-
) => Promise<void>;
|
|
26
|
-
|
|
27
|
-
export type Reducer<S, A> = (prevState: S, action: A) => S;
|
|
28
|
-
export type ReducerState<R extends Reducer<any, any>> =
|
|
29
|
-
R extends Reducer<infer S, any> ? S : never;
|
|
30
|
-
export type ReducerAction<R extends Reducer<any, any>> =
|
|
31
|
-
R extends Reducer<any, infer A> ? A : never;
|
|
@@ -69,9 +69,8 @@ export function setResponseReducer(
|
|
|
69
69
|
}
|
|
70
70
|
return {
|
|
71
71
|
entities,
|
|
72
|
-
indexes,
|
|
73
72
|
endpoints,
|
|
74
|
-
|
|
73
|
+
indexes,
|
|
75
74
|
meta: {
|
|
76
75
|
...state.meta,
|
|
77
76
|
[action.key]: {
|
|
@@ -80,6 +79,7 @@ export function setResponseReducer(
|
|
|
80
79
|
prevExpiresAt: state.meta[action.key]?.expiresAt,
|
|
81
80
|
},
|
|
82
81
|
},
|
|
82
|
+
entityMeta,
|
|
83
83
|
optimistic: filterOptimistic(state, action),
|
|
84
84
|
lastReset: state.lastReset,
|
|
85
85
|
};
|
package/src/types.ts
CHANGED
|
@@ -18,14 +18,18 @@ export type { AbstractInstanceType, UpdateFunction };
|
|
|
18
18
|
|
|
19
19
|
export type PK = string;
|
|
20
20
|
|
|
21
|
+
/** Normalized state for Reactive Data Client
|
|
22
|
+
*
|
|
23
|
+
* @see https://dataclient.io/docs/concepts/normalization
|
|
24
|
+
*/
|
|
21
25
|
export interface State<T> {
|
|
22
26
|
readonly entities: {
|
|
23
27
|
readonly [entityKey: string]: { readonly [pk: string]: T } | undefined;
|
|
24
28
|
};
|
|
25
|
-
readonly indexes: NormalizedIndex;
|
|
26
29
|
readonly endpoints: {
|
|
27
30
|
readonly [key: string]: unknown | PK[] | PK | undefined;
|
|
28
31
|
};
|
|
32
|
+
readonly indexes: NormalizedIndex;
|
|
29
33
|
readonly meta: {
|
|
30
34
|
readonly [key: string]: {
|
|
31
35
|
readonly date: number;
|
|
@@ -49,9 +53,20 @@ export interface State<T> {
|
|
|
49
53
|
readonly lastReset: number;
|
|
50
54
|
}
|
|
51
55
|
|
|
56
|
+
/** Singletons that handle global side-effects
|
|
57
|
+
*
|
|
58
|
+
* Kind of like useEffect() for the central data store
|
|
59
|
+
*
|
|
60
|
+
* @see https://dataclient.io/docs/api/Manager
|
|
61
|
+
*/
|
|
52
62
|
export interface Manager<Actions = ActionTypes> {
|
|
53
|
-
|
|
63
|
+
/** @see https://dataclient.io/docs/api/Manager#getmiddleware */
|
|
64
|
+
getMiddleware?(): Middleware<Actions>;
|
|
65
|
+
/** @see https://dataclient.io/docs/api/Manager#middleware */
|
|
66
|
+
middleware?: Middleware<Actions>;
|
|
67
|
+
/** @see https://dataclient.io/docs/api/Manager#cleanup */
|
|
54
68
|
cleanup(): void;
|
|
69
|
+
/** @see https://dataclient.io/docs/api/Manager#init */
|
|
55
70
|
init?: (state: State<any>) => void;
|
|
56
71
|
}
|
|
57
72
|
|
package/ts3.4/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as __INTERNAL__1 from './internal.js';
|
|
2
2
|
export { __INTERNAL__1 as __INTERNAL__ };
|
|
3
|
-
export { NetworkError, UnknownError, ErrorTypes, Schema, EndpointInterface, EntityInterface, ResolveType, DenormalizeNullable, Denormalize, Normalize, NormalizeNullable, FetchFunction, EndpointExtraOptions, Queryable, SchemaArgs, NI, } from '@data-client/normalizr';
|
|
3
|
+
export { NetworkError, UnknownError, ErrorTypes, Schema, EndpointInterface, EntityInterface, SchemaClass, ResolveType, DenormalizeNullable, Denormalize, Normalize, NormalizeNullable, FetchFunction, EndpointExtraOptions, Queryable, SchemaArgs, NI, } from '@data-client/normalizr';
|
|
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';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DevToolsConfig } from './devtoolsTypes.js';
|
|
2
|
-
import { Middleware } from './LogoutManager.js';
|
|
3
2
|
import { Controller } from '../index.js';
|
|
3
|
+
import { Middleware } from '../middlewareTypes.js';
|
|
4
4
|
import { Manager, State, ActionTypes } from '../types.js';
|
|
5
5
|
export { DevToolsConfig };
|
|
6
6
|
/** Integrates with https://github.com/reduxjs/redux-devtools
|
|
@@ -10,7 +10,7 @@ export { DevToolsConfig };
|
|
|
10
10
|
* @see https://dataclient.io/docs/api/DevToolsManager
|
|
11
11
|
*/
|
|
12
12
|
export default class DevToolsManager implements Manager {
|
|
13
|
-
|
|
13
|
+
middleware: Middleware;
|
|
14
14
|
protected devTools: undefined | any;
|
|
15
15
|
protected started: boolean;
|
|
16
16
|
protected actions: [
|
|
@@ -18,6 +18,7 @@ export default class DevToolsManager implements Manager {
|
|
|
18
18
|
State<unknown>
|
|
19
19
|
][];
|
|
20
20
|
protected controller: Controller;
|
|
21
|
+
skipLogging?: (action: ActionTypes) => boolean;
|
|
21
22
|
maxBufferLength: number;
|
|
22
23
|
constructor(config?: DevToolsConfig, skipLogging?: (action: ActionTypes) => boolean);
|
|
23
24
|
handleAction(action: any, state: any): void;
|
|
@@ -25,9 +26,5 @@ export default class DevToolsManager implements Manager {
|
|
|
25
26
|
init(state: State<any>): void;
|
|
26
27
|
/** Ensures all subscriptions are cleaned up. */
|
|
27
28
|
cleanup(): void;
|
|
28
|
-
/** Attaches Manager to store
|
|
29
|
-
*
|
|
30
|
-
*/
|
|
31
|
-
getMiddleware(): Middleware;
|
|
32
29
|
}
|
|
33
30
|
//# sourceMappingURL=DevtoolsManager.d.ts.map
|
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
import Controller from '../controller/Controller.js';
|
|
2
2
|
import { UnknownError } from '../index.js';
|
|
3
|
-
import {
|
|
3
|
+
import { Manager, Middleware } from '../types.js';
|
|
4
4
|
/** Handling network unauthorized indicators like HTTP 401
|
|
5
5
|
*
|
|
6
6
|
* @see https://dataclient.io/docs/api/LogoutManager
|
|
7
7
|
*/
|
|
8
8
|
export default class LogoutManager implements Manager {
|
|
9
|
-
protected middleware: Middleware;
|
|
10
9
|
constructor({ handleLogout, shouldLogout }?: Props);
|
|
10
|
+
middleware: Middleware;
|
|
11
11
|
cleanup(): void;
|
|
12
|
-
getMiddleware(): Middleware;
|
|
13
12
|
protected shouldLogout(error: UnknownError): boolean;
|
|
14
|
-
handleLogout(controller: Controller
|
|
13
|
+
handleLogout(controller: Controller): void;
|
|
15
14
|
}
|
|
16
|
-
type
|
|
17
|
-
export type Middleware = <C extends Controller<Dispatch>>(controller: C) => (next: C['dispatch']) => C['dispatch'];
|
|
18
|
-
type HandleLogout = (controller: Controller<Dispatch>) => void;
|
|
15
|
+
type HandleLogout = (controller: Controller) => void;
|
|
19
16
|
interface Props {
|
|
20
17
|
handleLogout?: HandleLogout;
|
|
21
18
|
shouldLogout?: (error: UnknownError) => boolean;
|
|
@@ -28,16 +28,19 @@ export default class NetworkManager implements Manager {
|
|
|
28
28
|
};
|
|
29
29
|
readonly dataExpiryLength: number;
|
|
30
30
|
readonly errorExpiryLength: number;
|
|
31
|
-
protected middleware: Middleware;
|
|
32
31
|
protected controller: Controller;
|
|
33
32
|
cleanupDate?: number;
|
|
34
|
-
constructor(dataExpiryLength
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
constructor({ dataExpiryLength, errorExpiryLength }?: {
|
|
34
|
+
dataExpiryLength?: number | undefined;
|
|
35
|
+
errorExpiryLength?: number | undefined;
|
|
36
|
+
});
|
|
37
|
+
middleware: Middleware;
|
|
37
38
|
/** On mount */
|
|
38
39
|
init(): void;
|
|
39
40
|
/** Ensures all promises are completed by rejecting remaining. */
|
|
40
41
|
cleanup(): void;
|
|
42
|
+
/** Used by DevtoolsManager to determine whether to log an action */
|
|
43
|
+
skipLogging(action: ActionTypes): boolean;
|
|
41
44
|
allSettled(): Promise<PromiseSettledResult<any>[]> | undefined;
|
|
42
45
|
/** Clear all promise state */
|
|
43
46
|
protected clearAll(): void;
|
|
@@ -58,14 +61,6 @@ export default class NetworkManager implements Manager {
|
|
|
58
61
|
* Will resolve the promise associated with set key.
|
|
59
62
|
*/
|
|
60
63
|
protected handleSet(action: SetResponseAction): void;
|
|
61
|
-
/** Attaches NetworkManager to store
|
|
62
|
-
*
|
|
63
|
-
* Intercepts 'rdc/fetch' actions to start requests.
|
|
64
|
-
*
|
|
65
|
-
* Resolve/rejects a request when matching 'rdc/set' event
|
|
66
|
-
* is seen.
|
|
67
|
-
*/
|
|
68
|
-
getMiddleware(): Middleware;
|
|
69
64
|
/** Ensures only one request for a given key is in flight at any time
|
|
70
65
|
*
|
|
71
66
|
* Uses key to either retrieve in-flight promise, or if not
|
|
@@ -18,14 +18,14 @@ export interface SubscriptionConstructable {
|
|
|
18
18
|
*
|
|
19
19
|
* @see https://dataclient.io/docs/api/SubscriptionManager
|
|
20
20
|
*/
|
|
21
|
-
export default class SubscriptionManager<S extends SubscriptionConstructable> implements Manager<Actions> {
|
|
21
|
+
export default class SubscriptionManager<S extends SubscriptionConstructable = SubscriptionConstructable> implements Manager<Actions> {
|
|
22
22
|
protected subscriptions: {
|
|
23
23
|
[key: string]: InstanceType<S>;
|
|
24
24
|
};
|
|
25
25
|
protected readonly Subscription: S;
|
|
26
|
-
protected middleware: Middleware;
|
|
27
26
|
protected controller: Controller;
|
|
28
27
|
constructor(Subscription: S);
|
|
28
|
+
middleware: Middleware;
|
|
29
29
|
/** Ensures all subscriptions are cleaned up. */
|
|
30
30
|
cleanup(): void;
|
|
31
31
|
/** Called when middleware intercepts 'rdc/subscribe' action.
|
|
@@ -36,15 +36,6 @@ export default class SubscriptionManager<S extends SubscriptionConstructable> im
|
|
|
36
36
|
*
|
|
37
37
|
*/
|
|
38
38
|
protected handleUnsubscribe(action: UnsubscribeAction): void;
|
|
39
|
-
/** Attaches Manager to store
|
|
40
|
-
*
|
|
41
|
-
* Intercepts 'rdc/subscribe'/'rest-hordc/ribe' to register resources that
|
|
42
|
-
* need to be kept up to date.
|
|
43
|
-
*
|
|
44
|
-
* Will possibly dispatch 'rdc/fetch' or 'rest-hordc/' to keep resources fresh
|
|
45
|
-
*
|
|
46
|
-
*/
|
|
47
|
-
getMiddleware(): Middleware;
|
|
48
39
|
}
|
|
49
40
|
export {};
|
|
50
41
|
//# sourceMappingURL=SubscriptionManager.d.ts.map
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import Controller from '../controller/Controller.js';
|
|
2
|
-
import { Reducer, Dispatch, ReducerState } from '../middlewareTypes.js';
|
|
3
2
|
import { Manager } from '../types.js';
|
|
4
|
-
export default function applyManager(managers: Manager[], controller: Controller):
|
|
5
|
-
export interface
|
|
3
|
+
export default function applyManager(managers: Manager[], controller: Controller): ReduxMiddleware[];
|
|
4
|
+
export interface ReduxMiddlewareAPI<R extends Reducer<any, any> = Reducer<any, any>> {
|
|
6
5
|
getState: () => ReducerState<R>;
|
|
7
|
-
dispatch:
|
|
6
|
+
dispatch: ReactDispatch<R>;
|
|
8
7
|
}
|
|
9
|
-
export type
|
|
8
|
+
export type ReduxMiddleware = <R extends Reducer<any, any>>({ dispatch, }: ReduxMiddlewareAPI<R>) => (next: ReactDispatch<R>) => ReactDispatch<R>;
|
|
9
|
+
export type ReactDispatch<R extends Reducer<any, any>> = (action: ReducerAction<R>) => Promise<void>;
|
|
10
|
+
export type Reducer<S, A> = (prevState: S, action: A) => S;
|
|
11
|
+
export type ReducerState<R extends Reducer<any, any>> = R extends Reducer<infer S, any> ? S : never;
|
|
12
|
+
export type ReducerAction<R extends Reducer<any, any>> = R extends Reducer<any, infer A> ? A : never;
|
|
10
13
|
//# sourceMappingURL=applyManager.d.ts.map
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import Controller from './controller/Controller.js';
|
|
2
2
|
import { ActionTypes, State } from './types.js';
|
|
3
|
-
type
|
|
4
|
-
export interface MiddlewareAPI
|
|
3
|
+
export type Dispatch<Actions = ActionTypes> = (value: Actions) => Promise<void>;
|
|
4
|
+
export interface MiddlewareAPI extends Controller<Dispatch<ActionTypes>> {
|
|
5
5
|
}
|
|
6
|
-
export interface MiddlewareController<Actions = ActionTypes> extends Controller<
|
|
6
|
+
export interface MiddlewareController<Actions = ActionTypes> extends Controller<Dispatch<Actions>> {
|
|
7
7
|
}
|
|
8
|
-
|
|
8
|
+
/** @see https://dataclient.io/docs/api/Manager#middleware */
|
|
9
|
+
export type Middleware<Actions = ActionTypes> = <C extends MiddlewareController<Actions>>(controller: C) => (next: C['dispatch']) => C['dispatch'];
|
|
9
10
|
export type DataClientReducer = (prevState: State<unknown>, action: ActionTypes) => State<unknown>;
|
|
10
|
-
export type Dispatch<R extends Reducer<any, any>> = (action: ReducerAction<R>) => Promise<void>;
|
|
11
|
-
export type Reducer<S, A> = (prevState: S, action: A) => S;
|
|
12
|
-
export type ReducerState<R extends Reducer<any, any>> = R extends Reducer<infer S, any> ? S : never;
|
|
13
|
-
export type ReducerAction<R extends Reducer<any, any>> = R extends Reducer<any, infer A> ? A : never;
|
|
14
|
-
export {};
|
|
15
11
|
//# sourceMappingURL=middlewareTypes.d.ts.map
|
|
@@ -15,10 +15,10 @@ export declare function expireReducer(state: State<unknown>, action: ExpireAllAc
|
|
|
15
15
|
readonly [pk: string]: unknown;
|
|
16
16
|
} | undefined;
|
|
17
17
|
};
|
|
18
|
-
indexes: import("packages/normalizr/lib/interface.js").NormalizedIndex;
|
|
19
18
|
endpoints: {
|
|
20
19
|
readonly [key: string]: unknown | import("../../types.js").PK[] | import("../../types.js").PK | undefined;
|
|
21
20
|
};
|
|
21
|
+
indexes: import("packages/normalizr/lib/interface.js").NormalizedIndex;
|
|
22
22
|
entityMeta: {
|
|
23
23
|
readonly [entityKey: string]: {
|
|
24
24
|
readonly [pk: string]: {
|
|
@@ -4,13 +4,10 @@ export declare function setReducer(state: State<unknown>, action: SetAction, con
|
|
|
4
4
|
entities: {
|
|
5
5
|
[x: string]: any;
|
|
6
6
|
};
|
|
7
|
-
indexes: import("@data-client/normalizr").NormalizedIndex;
|
|
8
7
|
endpoints: {
|
|
9
8
|
readonly [key: string]: unknown;
|
|
10
9
|
};
|
|
11
|
-
|
|
12
|
-
[x: string]: any;
|
|
13
|
-
}>;
|
|
10
|
+
indexes: import("@data-client/normalizr").NormalizedIndex;
|
|
14
11
|
meta: {
|
|
15
12
|
readonly [key: string]: {
|
|
16
13
|
readonly date: number;
|
|
@@ -21,6 +18,9 @@ export declare function setReducer(state: State<unknown>, action: SetAction, con
|
|
|
21
18
|
readonly errorPolicy?: "hard" | "soft" | undefined;
|
|
22
19
|
};
|
|
23
20
|
};
|
|
21
|
+
entityMeta: import("packages/normalizr/lib/types.js").EntitiesToMeta<{
|
|
22
|
+
[x: string]: any;
|
|
23
|
+
}>;
|
|
24
24
|
optimistic: (import("../../actions.js").SetResponseAction | import("../../actions.js").OptimisticAction<import("@data-client/normalizr").EndpointInterface<import("@data-client/normalizr").FetchFunction, import("@data-client/normalizr").Schema | undefined, boolean | undefined> & {
|
|
25
25
|
update?: import("../../index.js").EndpointUpdateFunction<import("@data-client/normalizr").EndpointInterface>;
|
|
26
26
|
}>)[];
|
|
@@ -4,11 +4,8 @@ export declare function setResponseReducer(state: State<unknown>, action: Optimi
|
|
|
4
4
|
entities: {
|
|
5
5
|
[x: string]: any;
|
|
6
6
|
};
|
|
7
|
-
indexes: import("@data-client/normalizr").NormalizedIndex;
|
|
8
7
|
endpoints: Record<string, unknown>;
|
|
9
|
-
|
|
10
|
-
[x: string]: any;
|
|
11
|
-
}>;
|
|
8
|
+
indexes: import("@data-client/normalizr").NormalizedIndex;
|
|
12
9
|
meta: {
|
|
13
10
|
[x: string]: {
|
|
14
11
|
readonly date: number;
|
|
@@ -23,6 +20,9 @@ export declare function setResponseReducer(state: State<unknown>, action: Optimi
|
|
|
23
20
|
prevExpiresAt: number;
|
|
24
21
|
};
|
|
25
22
|
};
|
|
23
|
+
entityMeta: import("packages/normalizr/lib/types.js").EntitiesToMeta<{
|
|
24
|
+
[x: string]: any;
|
|
25
|
+
}>;
|
|
26
26
|
optimistic: (SetResponseAction | OptimisticAction<import("@data-client/normalizr").EndpointInterface<import("@data-client/normalizr").FetchFunction, import("@data-client/normalizr").Schema | undefined, boolean | undefined> & {
|
|
27
27
|
update?: import("../../index.js").EndpointUpdateFunction<import("@data-client/normalizr").EndpointInterface>;
|
|
28
28
|
}>)[];
|
package/ts3.4/types.d.ts
CHANGED
|
@@ -6,16 +6,20 @@ import { Dispatch, Middleware, MiddlewareAPI } from './middlewareTypes.js';
|
|
|
6
6
|
export * from './actions.js';
|
|
7
7
|
export { AbstractInstanceType, UpdateFunction };
|
|
8
8
|
export type PK = string;
|
|
9
|
+
/** Normalized state for Reactive Data Client
|
|
10
|
+
*
|
|
11
|
+
* @see https://dataclient.io/docs/concepts/normalization
|
|
12
|
+
*/
|
|
9
13
|
export interface State<T> {
|
|
10
14
|
readonly entities: {
|
|
11
15
|
readonly [entityKey: string]: {
|
|
12
16
|
readonly [pk: string]: T;
|
|
13
17
|
} | undefined;
|
|
14
18
|
};
|
|
15
|
-
readonly indexes: NormalizedIndex;
|
|
16
19
|
readonly endpoints: {
|
|
17
20
|
readonly [key: string]: unknown | PK[] | PK | undefined;
|
|
18
21
|
};
|
|
22
|
+
readonly indexes: NormalizedIndex;
|
|
19
23
|
readonly meta: {
|
|
20
24
|
readonly [key: string]: {
|
|
21
25
|
readonly date: number;
|
|
@@ -38,9 +42,20 @@ export interface State<T> {
|
|
|
38
42
|
readonly optimistic: (SetResponseAction | OptimisticAction)[];
|
|
39
43
|
readonly lastReset: number;
|
|
40
44
|
}
|
|
45
|
+
/** Singletons that handle global side-effects
|
|
46
|
+
*
|
|
47
|
+
* Kind of like useEffect() for the central data store
|
|
48
|
+
*
|
|
49
|
+
* @see https://dataclient.io/docs/api/Manager
|
|
50
|
+
*/
|
|
41
51
|
export interface Manager<Actions = ActionTypes> {
|
|
42
|
-
|
|
52
|
+
/** @see https://dataclient.io/docs/api/Manager#getmiddleware */
|
|
53
|
+
getMiddleware?(): Middleware<Actions>;
|
|
54
|
+
/** @see https://dataclient.io/docs/api/Manager#middleware */
|
|
55
|
+
middleware?: Middleware<Actions>;
|
|
56
|
+
/** @see https://dataclient.io/docs/api/Manager#cleanup */
|
|
43
57
|
cleanup(): void;
|
|
58
|
+
/** @see https://dataclient.io/docs/api/Manager#init */
|
|
44
59
|
init?: (state: State<any>) => void;
|
|
45
60
|
}
|
|
46
61
|
export { Dispatch, Middleware, MiddlewareAPI };
|