1 | import type { Middleware } from 'redux';
|
2 | /**
|
3 | * Returns true if the passed value is "plain", i.e. a value that is either
|
4 | * directly JSON-serializable (boolean, number, string, array, plain object)
|
5 | * or `undefined`.
|
6 | *
|
7 | * @param val The value to check.
|
8 | *
|
9 | * @public
|
10 | */
|
11 | export declare function isPlain(val: any): boolean;
|
12 | interface NonSerializableValue {
|
13 | keyPath: string;
|
14 | value: unknown;
|
15 | }
|
16 | declare type IgnorePaths = readonly (string | RegExp)[];
|
17 | /**
|
18 | * @public
|
19 | */
|
20 | export declare function findNonSerializableValue(value: unknown, path?: string, isSerializable?: (value: unknown) => boolean, getEntries?: (value: unknown) => [string, any][], ignoredPaths?: IgnorePaths, cache?: WeakSet<object>): NonSerializableValue | false;
|
21 | export declare function isNestedFrozen(value: object): boolean;
|
22 | /**
|
23 | * Options for `createSerializableStateInvariantMiddleware()`.
|
24 | *
|
25 | * @public
|
26 | */
|
27 | export interface SerializableStateInvariantMiddlewareOptions {
|
28 | /**
|
29 | * The function to check if a value is considered serializable. This
|
30 | * function is applied recursively to every value contained in the
|
31 | * state. Defaults to `isPlain()`.
|
32 | */
|
33 | isSerializable?: (value: any) => boolean;
|
34 | /**
|
35 | * The function that will be used to retrieve entries from each
|
36 | * value. If unspecified, `Object.entries` will be used. Defaults
|
37 | * to `undefined`.
|
38 | */
|
39 | getEntries?: (value: any) => [string, any][];
|
40 | /**
|
41 | * An array of action types to ignore when checking for serializability.
|
42 | * Defaults to []
|
43 | */
|
44 | ignoredActions?: string[];
|
45 | /**
|
46 | * An array of dot-separated path strings or regular expressions to ignore
|
47 | * when checking for serializability, Defaults to
|
48 | * ['meta.arg', 'meta.baseQueryMeta']
|
49 | */
|
50 | ignoredActionPaths?: (string | RegExp)[];
|
51 | /**
|
52 | * An array of dot-separated path strings or regular expressions to ignore
|
53 | * when checking for serializability, Defaults to []
|
54 | */
|
55 | ignoredPaths?: (string | RegExp)[];
|
56 | /**
|
57 | * Execution time warning threshold. If the middleware takes longer
|
58 | * than `warnAfter` ms, a warning will be displayed in the console.
|
59 | * Defaults to 32ms.
|
60 | */
|
61 | warnAfter?: number;
|
62 | /**
|
63 | * Opt out of checking state. When set to `true`, other state-related params will be ignored.
|
64 | */
|
65 | ignoreState?: boolean;
|
66 | /**
|
67 | * Opt out of checking actions. When set to `true`, other action-related params will be ignored.
|
68 | */
|
69 | ignoreActions?: boolean;
|
70 | /**
|
71 | * Opt out of caching the results. The cache uses a WeakSet and speeds up repeated checking processes.
|
72 | * The cache is automatically disabled if no browser support for WeakSet is present.
|
73 | */
|
74 | disableCache?: boolean;
|
75 | }
|
76 | /**
|
77 | * Creates a middleware that, after every state change, checks if the new
|
78 | * state is serializable. If a non-serializable value is found within the
|
79 | * state, an error is printed to the console.
|
80 | *
|
81 | * @param options Middleware options.
|
82 | *
|
83 | * @public
|
84 | */
|
85 | export declare function createSerializableStateInvariantMiddleware(options?: SerializableStateInvariantMiddlewareOptions): Middleware;
|
86 | export {};
|