@data-client/core 0.15.4 → 0.16.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/CHANGELOG.md +39 -0
- package/dist/index.js +28 -11
- package/dist/index.umd.min.js +1 -1
- package/dist/mock.js +24 -11
- package/legacy/controller/actions/createOptimistic.js +3 -2
- package/legacy/manager/ConnectionListener.js +1 -1
- package/legacy/manager/DevtoolsManager.js +18 -4
- package/legacy/manager/NetworkManager.js +2 -2
- package/legacy/state/GCPolicy.js +4 -1
- package/legacy/state/reducer/setReducer.js +1 -1
- package/legacy/state/reducer/setResponseReducer.js +1 -1
- package/lib/controller/actions/createOptimistic.d.ts.map +1 -1
- package/lib/controller/actions/createOptimistic.js +3 -2
- package/lib/manager/ConnectionListener.d.ts +12 -0
- package/lib/manager/ConnectionListener.d.ts.map +1 -1
- package/lib/manager/ConnectionListener.js +1 -1
- package/lib/manager/DevtoolsManager.d.ts +1 -0
- package/lib/manager/DevtoolsManager.d.ts.map +1 -1
- package/lib/manager/DevtoolsManager.js +19 -5
- package/lib/manager/NetworkManager.d.ts +1 -1
- package/lib/manager/NetworkManager.js +2 -2
- package/lib/state/GCPolicy.d.ts.map +1 -1
- package/lib/state/GCPolicy.js +4 -1
- package/lib/state/reducer/expireReducer.d.ts +2 -2
- package/lib/state/reducer/invalidateReducer.d.ts +2 -2
- package/lib/state/reducer/setReducer.d.ts +1 -27
- package/lib/state/reducer/setReducer.d.ts.map +1 -1
- package/lib/state/reducer/setReducer.js +1 -1
- package/lib/state/reducer/setResponseReducer.d.ts +1 -30
- package/lib/state/reducer/setResponseReducer.d.ts.map +1 -1
- package/lib/state/reducer/setResponseReducer.js +1 -1
- package/package.json +3 -3
- package/src/controller/__tests__/get.ts +8 -8
- package/src/controller/actions/createOptimistic.ts +2 -1
- package/src/manager/ConnectionListener.ts +12 -0
- package/src/manager/DevtoolsManager.ts +21 -6
- package/src/manager/NetworkManager.ts +1 -1
- package/src/state/GCPolicy.ts +3 -0
- package/src/state/__tests__/GCPolicy.test.ts +2 -0
- package/src/state/reducer/setReducer.ts +1 -1
- package/src/state/reducer/setResponseReducer.ts +1 -1
- package/ts3.4/manager/ConnectionListener.d.ts +12 -0
- package/ts3.4/manager/DevtoolsManager.d.ts +1 -0
- package/ts3.4/manager/NetworkManager.d.ts +1 -1
- package/ts3.4/state/reducer/expireReducer.d.ts +2 -2
- package/ts3.4/state/reducer/invalidateReducer.d.ts +2 -2
- package/ts3.4/state/reducer/setReducer.d.ts +1 -27
- package/ts3.4/state/reducer/setResponseReducer.d.ts +1 -30
|
@@ -7,7 +7,7 @@ export function setReducer(
|
|
|
7
7
|
state: State<unknown>,
|
|
8
8
|
action: SetAction,
|
|
9
9
|
controller: Controller,
|
|
10
|
-
) {
|
|
10
|
+
): State<unknown> {
|
|
11
11
|
let value: any;
|
|
12
12
|
if (typeof action.value === 'function') {
|
|
13
13
|
const previousValue = controller.get(action.schema, ...action.args, state);
|
|
@@ -1,8 +1,20 @@
|
|
|
1
|
+
/** Listens to online/offline events for triggering re-fetches on reconnect.
|
|
2
|
+
*
|
|
3
|
+
* Implement this interface to provide custom connectivity detection
|
|
4
|
+
* (e.g., for React Native or Node.js environments).
|
|
5
|
+
*
|
|
6
|
+
* @see https://dataclient.io/docs/api/PollingSubscription
|
|
7
|
+
*/
|
|
1
8
|
export default interface ConnectionListener {
|
|
9
|
+
/** Returns whether the client is currently connected to the network. */
|
|
2
10
|
isOnline: () => boolean;
|
|
11
|
+
/** Register a handler to be called when the client comes back online. */
|
|
3
12
|
addOnlineListener: (handler: () => void) => void;
|
|
13
|
+
/** Remove a previously registered online handler. */
|
|
4
14
|
removeOnlineListener: (handler: () => void) => void;
|
|
15
|
+
/** Register a handler to be called when the client goes offline. */
|
|
5
16
|
addOfflineListener: (handler: () => void) => void;
|
|
17
|
+
/** Remove a previously registered offline handler. */
|
|
6
18
|
removeOfflineListener: (handler: () => void) => void;
|
|
7
19
|
}
|
|
8
20
|
//# sourceMappingURL=ConnectionListener.d.ts.map
|
|
@@ -19,6 +19,7 @@ export default class DevToolsManager implements Manager {
|
|
|
19
19
|
][];
|
|
20
20
|
protected controller: Controller;
|
|
21
21
|
skipLogging?: (action: ActionTypes) => boolean;
|
|
22
|
+
devtoolsName: string;
|
|
22
23
|
maxBufferLength: number;
|
|
23
24
|
constructor(config?: DevToolsConfig, skipLogging?: (action: ActionTypes) => boolean);
|
|
24
25
|
handleAction(action: any, state: any): void;
|
|
@@ -62,7 +62,7 @@ export default class NetworkManager implements Manager {
|
|
|
62
62
|
* create a new promise and call fetch.
|
|
63
63
|
*
|
|
64
64
|
* Note: The new promise is not actually tied to fetch at all,
|
|
65
|
-
* but is resolved when the expected '
|
|
65
|
+
* but is resolved when the expected 'receive' action is processed.
|
|
66
66
|
* This ensures promises are resolved only once their data is processed
|
|
67
67
|
* by the reducer.
|
|
68
68
|
*/
|
|
@@ -6,7 +6,7 @@ export declare function expireReducer(state: State<unknown>, action: ExpireAllAc
|
|
|
6
6
|
readonly fetchedAt: number;
|
|
7
7
|
readonly expiresAt: number;
|
|
8
8
|
readonly prevExpiresAt?: number;
|
|
9
|
-
readonly error?: import("
|
|
9
|
+
readonly error?: import("@data-client/normalizr").ErrorTypes;
|
|
10
10
|
readonly invalidated?: boolean;
|
|
11
11
|
readonly errorPolicy?: "hard" | "soft" | undefined;
|
|
12
12
|
};
|
|
@@ -19,7 +19,7 @@ export declare function expireReducer(state: State<unknown>, action: ExpireAllAc
|
|
|
19
19
|
endpoints: {
|
|
20
20
|
readonly [key: string]: unknown | import("../../types.js").PK[] | import("../../types.js").PK | undefined;
|
|
21
21
|
};
|
|
22
|
-
indexes: import("
|
|
22
|
+
indexes: import("@data-client/normalizr").NormalizedIndex;
|
|
23
23
|
entitiesMeta: {
|
|
24
24
|
readonly [entityKey: string]: {
|
|
25
25
|
readonly [pk: string]: {
|
|
@@ -9,7 +9,7 @@ export declare function invalidateReducer(state: State<unknown>, action: Invalid
|
|
|
9
9
|
readonly fetchedAt: number;
|
|
10
10
|
readonly expiresAt: number;
|
|
11
11
|
readonly prevExpiresAt?: number;
|
|
12
|
-
readonly error?: import("
|
|
12
|
+
readonly error?: import("@data-client/normalizr").ErrorTypes;
|
|
13
13
|
readonly invalidated?: boolean;
|
|
14
14
|
readonly errorPolicy?: "hard" | "soft" | undefined;
|
|
15
15
|
};
|
|
@@ -19,7 +19,7 @@ export declare function invalidateReducer(state: State<unknown>, action: Invalid
|
|
|
19
19
|
readonly [pk: string]: unknown;
|
|
20
20
|
} | undefined;
|
|
21
21
|
};
|
|
22
|
-
indexes: import("
|
|
22
|
+
indexes: import("@data-client/normalizr").NormalizedIndex;
|
|
23
23
|
entitiesMeta: {
|
|
24
24
|
readonly [entityKey: string]: {
|
|
25
25
|
readonly [pk: string]: {
|
|
@@ -1,30 +1,4 @@
|
|
|
1
1
|
import Controller from '../../controller/Controller.js';
|
|
2
2
|
import { State, SetAction } from '../../types.js';
|
|
3
|
-
export declare function setReducer(state: State<unknown>, action: SetAction, controller: Controller): State<unknown
|
|
4
|
-
entities: {
|
|
5
|
-
[x: string]: any;
|
|
6
|
-
};
|
|
7
|
-
endpoints: {
|
|
8
|
-
readonly [key: string]: unknown;
|
|
9
|
-
};
|
|
10
|
-
indexes: import("@data-client/normalizr").NormalizedIndex;
|
|
11
|
-
meta: {
|
|
12
|
-
readonly [key: string]: {
|
|
13
|
-
readonly date: number;
|
|
14
|
-
readonly fetchedAt: number;
|
|
15
|
-
readonly expiresAt: number;
|
|
16
|
-
readonly prevExpiresAt?: number;
|
|
17
|
-
readonly error?: import("@data-client/normalizr").ErrorTypes;
|
|
18
|
-
readonly invalidated?: boolean;
|
|
19
|
-
readonly errorPolicy?: "hard" | "soft" | undefined;
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
entitiesMeta: import("packages/normalizr/lib/types.js").EntitiesToMeta<{
|
|
23
|
-
[x: string]: any;
|
|
24
|
-
}>;
|
|
25
|
-
optimistic: (import("../../actions.js").OptimisticAction<import("@data-client/normalizr").EndpointInterface<import("@data-client/normalizr").FetchFunction, import("@data-client/normalizr").Schema | undefined, boolean | undefined> & {
|
|
26
|
-
update?: import("../../index.js").EndpointUpdateFunction<import("@data-client/normalizr").EndpointInterface>;
|
|
27
|
-
}> | import("../../actions.js").SetResponseAction)[];
|
|
28
|
-
lastReset: number;
|
|
29
|
-
};
|
|
3
|
+
export declare function setReducer(state: State<unknown>, action: SetAction, controller: Controller): State<unknown>;
|
|
30
4
|
//# sourceMappingURL=setReducer.d.ts.map
|
|
@@ -1,33 +1,4 @@
|
|
|
1
1
|
import Controller from '../../controller/Controller.js';
|
|
2
2
|
import { State, SetResponseAction, OptimisticAction } from '../../types.js';
|
|
3
|
-
export declare function setResponseReducer(state: State<unknown>, action: OptimisticAction | SetResponseAction, controller: Controller): State<unknown
|
|
4
|
-
entities: {
|
|
5
|
-
[x: string]: any;
|
|
6
|
-
};
|
|
7
|
-
endpoints: Record<string, unknown>;
|
|
8
|
-
indexes: import("@data-client/normalizr").NormalizedIndex;
|
|
9
|
-
meta: {
|
|
10
|
-
[x: string]: {
|
|
11
|
-
readonly date: number;
|
|
12
|
-
readonly fetchedAt: number;
|
|
13
|
-
readonly expiresAt: number;
|
|
14
|
-
readonly prevExpiresAt?: number;
|
|
15
|
-
readonly error?: import("@data-client/normalizr").ErrorTypes;
|
|
16
|
-
readonly invalidated?: boolean;
|
|
17
|
-
readonly errorPolicy?: "hard" | "soft" | undefined;
|
|
18
|
-
} | {
|
|
19
|
-
date: number;
|
|
20
|
-
fetchedAt: number;
|
|
21
|
-
expiresAt: number;
|
|
22
|
-
prevExpiresAt: number;
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
entitiesMeta: import("packages/normalizr/lib/types.js").EntitiesToMeta<{
|
|
26
|
-
[x: string]: any;
|
|
27
|
-
}>;
|
|
28
|
-
optimistic: (OptimisticAction<import("@data-client/normalizr").EndpointInterface<import("@data-client/normalizr").FetchFunction, import("@data-client/normalizr").Schema | undefined, boolean | undefined> & {
|
|
29
|
-
update?: import("../../index.js").EndpointUpdateFunction<import("@data-client/normalizr").EndpointInterface>;
|
|
30
|
-
}> | SetResponseAction)[];
|
|
31
|
-
lastReset: number;
|
|
32
|
-
};
|
|
3
|
+
export declare function setResponseReducer(state: State<unknown>, action: OptimisticAction | SetResponseAction, controller: Controller): State<unknown>;
|
|
33
4
|
//# sourceMappingURL=setResponseReducer.d.ts.map
|