react-redux-cache 0.22.0 → 0.22.1
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/cjs/createActions.js +63 -64
- package/dist/cjs/createCache.js +131 -217
- package/dist/cjs/createReducer.js +291 -348
- package/dist/cjs/createSelectors.js +58 -67
- package/dist/cjs/index.js +26 -89
- package/dist/cjs/mutate.js +69 -153
- package/dist/cjs/query.js +70 -162
- package/dist/cjs/types.js +2 -2
- package/dist/cjs/useMutation.js +42 -71
- package/dist/cjs/useQuery.js +56 -113
- package/dist/cjs/utilsAndConstants.js +151 -204
- package/dist/esm/createActions.js +59 -60
- package/dist/esm/createCache.js +127 -218
- package/dist/esm/createReducer.js +285 -340
- package/dist/esm/createSelectors.js +54 -63
- package/dist/esm/index.js +3 -5
- package/dist/esm/mutate.js +65 -142
- package/dist/esm/query.js +66 -149
- package/dist/esm/types.js +1 -1
- package/dist/esm/useMutation.js +38 -77
- package/dist/esm/useQuery.js +52 -119
- package/dist/esm/utilsAndConstants.js +140 -190
- package/dist/types/createActions.d.ts +83 -107
- package/dist/types/createCache.d.ts +409 -730
- package/dist/types/createReducer.d.ts +3 -11
- package/dist/types/createSelectors.d.ts +18 -80
- package/dist/types/index.d.ts +3 -5
- package/dist/types/mutate.d.ts +4 -94
- package/dist/types/query.d.ts +4 -123
- package/dist/types/types.d.ts +184 -360
- package/dist/types/useMutation.d.ts +4 -39
- package/dist/types/useQuery.d.ts +4 -40
- package/dist/types/utilsAndConstants.d.ts +23 -56
- package/package.json +11 -11
package/dist/types/useQuery.d.ts
CHANGED
|
@@ -1,40 +1,4 @@
|
|
|
1
|
-
import {Actions} from './createActions'
|
|
2
|
-
import {Selectors} from './createSelectors'
|
|
3
|
-
import {Cache, QueryOptions, QueryState, Typenames, UseQueryOptions} from './types'
|
|
4
|
-
|
|
5
|
-
export declare const useQuery: <
|
|
6
|
-
N extends string,
|
|
7
|
-
T extends Typenames,
|
|
8
|
-
QP,
|
|
9
|
-
QR,
|
|
10
|
-
MP,
|
|
11
|
-
MR,
|
|
12
|
-
QK extends keyof (QP & QR)
|
|
13
|
-
>(
|
|
14
|
-
cache: Pick<Cache<N, T, QP, QR, MP, MR>, 'options' | 'globals' | 'queries' | 'storeHooks'>,
|
|
15
|
-
actions: Actions<N, T, QP, QR, MP, MR>,
|
|
16
|
-
selectors: Selectors<N, T, QP, QR, MP, MR>,
|
|
17
|
-
options: UseQueryOptions<N, T, QK, QP, QR, MP, MR>
|
|
18
|
-
) => readonly [
|
|
19
|
-
Omit<
|
|
20
|
-
QueryState<
|
|
21
|
-
T,
|
|
22
|
-
QK extends keyof QP & keyof QR ? QP[QK] : never,
|
|
23
|
-
QK extends keyof QP & keyof QR ? QR[QK] : never
|
|
24
|
-
>,
|
|
25
|
-
'expiresAt'
|
|
26
|
-
>,
|
|
27
|
-
(
|
|
28
|
-
options?: Partial<Pick<QueryOptions<N, T, QP, QR, QK, MP, MR>, 'params' | 'onlyIfExpired'>>
|
|
29
|
-
) => Promise<
|
|
30
|
-
import('./types').QueryResult<
|
|
31
|
-
QK extends infer T_1
|
|
32
|
-
? T_1 extends QK
|
|
33
|
-
? T_1 extends keyof QP & keyof QR
|
|
34
|
-
? QR[T_1]
|
|
35
|
-
: never
|
|
36
|
-
: never
|
|
37
|
-
: never
|
|
38
|
-
>
|
|
39
|
-
>
|
|
40
|
-
]
|
|
1
|
+
import { Actions } from './createActions';
|
|
2
|
+
import { Selectors } from './createSelectors';
|
|
3
|
+
import { Cache, QueryOptions, QueryState, Typenames, UseQueryOptions } from './types';
|
|
4
|
+
export declare const useQuery: <N extends string, T extends Typenames, QP, QR, MP, MR, QK extends keyof (QP & QR)>(cache: Pick<Cache<N, T, QP, QR, MP, MR>, "options" | "globals" | "queries" | "storeHooks">, actions: Actions<N, T, QP, QR, MP, MR>, selectors: Selectors<N, T, QP, QR, MP, MR>, options: UseQueryOptions<N, T, QK, QP, QR, MP, MR>) => readonly [Omit<QueryState<T, QK extends keyof QP & keyof QR ? QP[QK] : never, QK extends keyof QP & keyof QR ? QR[QK] : never>, "expiresAt">, (options?: Partial<Pick<QueryOptions<N, T, QP, QR, QK, MP, MR>, "params" | "onlyIfExpired">>) => Promise<import("./types").QueryResult<QK extends infer T_1 ? T_1 extends QK ? T_1 extends keyof QP & keyof QR ? QR[T_1] : never : never : never>>];
|
|
@@ -1,62 +1,29 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
EntitiesMap,
|
|
4
|
-
EntityChanges,
|
|
5
|
-
Key,
|
|
6
|
-
Mutable,
|
|
7
|
-
QueryState,
|
|
8
|
-
QueryStateComparer,
|
|
9
|
-
Typenames,
|
|
10
|
-
} from './types'
|
|
11
|
-
|
|
12
|
-
export declare const PACKAGE_SHORT_NAME = 'rrc'
|
|
13
|
-
|
|
1
|
+
import type { CacheOptions, EntitiesMap, EntityChanges, Key, Mutable, QueryState, QueryStateComparer, Typenames } from './types';
|
|
2
|
+
export declare const PACKAGE_SHORT_NAME = "rrc";
|
|
14
3
|
export declare const optionalUtils: {
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export declare const
|
|
19
|
-
|
|
20
|
-
export declare const
|
|
21
|
-
|
|
22
|
-
export declare const IS_DEV: boolean
|
|
23
|
-
|
|
24
|
-
export declare const EMPTY_OBJECT: Readonly<{}>
|
|
25
|
-
|
|
26
|
-
export declare const EMPTY_ARRAY: readonly never[]
|
|
27
|
-
|
|
4
|
+
deepEqual?: (a: any, b: any) => boolean;
|
|
5
|
+
};
|
|
6
|
+
export declare const logDebug: (tag: string, data?: unknown) => void;
|
|
7
|
+
export declare const logWarn: (tag: string, data?: unknown) => void;
|
|
8
|
+
export declare const IS_DEV: boolean;
|
|
9
|
+
export declare const EMPTY_OBJECT: Readonly<{}>;
|
|
10
|
+
export declare const EMPTY_ARRAY: readonly never[];
|
|
28
11
|
/** Empty function. */
|
|
29
|
-
export declare const noop: () => void
|
|
30
|
-
|
|
12
|
+
export declare const noop: () => void;
|
|
31
13
|
/** Default getCacheKey implementation. */
|
|
32
|
-
export declare const defaultGetCacheKey: <P = unknown>(params: P) => Key
|
|
33
|
-
|
|
34
|
-
export declare const applyEntityChanges: <T extends Typenames>(
|
|
35
|
-
entities: EntitiesMap<T> & Mutable,
|
|
36
|
-
changes: EntityChanges<T>,
|
|
37
|
-
options: CacheOptions
|
|
38
|
-
) => EntitiesMap<T> | undefined
|
|
39
|
-
|
|
14
|
+
export declare const defaultGetCacheKey: <P = unknown>(params: P) => Key;
|
|
15
|
+
export declare const applyEntityChanges: <T extends Typenames>(entities: EntitiesMap<T> & Mutable, changes: EntityChanges<T>, options: CacheOptions) => EntitiesMap<T> | undefined;
|
|
40
16
|
/** Returns true if object has no keys. */
|
|
41
|
-
export declare const isEmptyObject: (obj: object) => boolean
|
|
42
|
-
|
|
17
|
+
export declare const isEmptyObject: (obj: object) => boolean;
|
|
43
18
|
/** Returns query state comparer that compares only provided fields. Used in implementation of `selectorComparer` option. */
|
|
44
|
-
export declare const createStateComparer: <T extends Typenames = Typenames, Q = unknown, P = unknown>(
|
|
45
|
-
fields: (keyof QueryState<T, Q, P>)[]
|
|
46
|
-
) => QueryStateComparer<T, Q, P>
|
|
47
|
-
|
|
19
|
+
export declare const createStateComparer: <T extends Typenames = Typenames, Q = unknown, P = unknown>(fields: (keyof QueryState<T, Q, P>)[]) => QueryStateComparer<T, Q, P>;
|
|
48
20
|
export declare const FetchPolicy: {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
/** Every fetch trigger. */
|
|
59
|
-
Always: () => boolean
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export declare const incrementChangeKey: (mutable: Mutable) => void
|
|
21
|
+
/**
|
|
22
|
+
* Only if cache does not exist (result is undefined) or expired. Default.
|
|
23
|
+
* @param expired `true` when `expiresAt` is defined and lower than `Date.now()`
|
|
24
|
+
*/
|
|
25
|
+
NoCacheOrExpired: <T extends Typenames = Typenames, P = unknown, R = unknown>(expired: boolean, _params: P, state: QueryState<T, P, R>) => boolean;
|
|
26
|
+
/** Every fetch trigger. */
|
|
27
|
+
Always: () => boolean;
|
|
28
|
+
};
|
|
29
|
+
export declare const incrementChangeKey: (mutable: Mutable) => void;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "react-redux-cache",
|
|
3
3
|
"author": "Alexander Danilov",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "0.22.
|
|
5
|
+
"version": "0.22.1",
|
|
6
6
|
"description": "Powerful data fetching and caching library for Redux and Zustand that supports normalization.",
|
|
7
7
|
"main": "./dist/cjs/index.js",
|
|
8
8
|
"module": "./dist/esm/index.js",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"build-cjs": "tsc -p tsconfig.cjs.json && rm -rf dist/cjs/testing && rm -rf dist/cjs/__tests__",
|
|
24
24
|
"build-esm": "tsc -p tsconfig.esm.json > /dev/null ; rm -rf dist/esm/testing && rm -rf dist/esm/__tests__",
|
|
25
25
|
"build-types": "tsc -p tsconfig.types.json > /dev/null ; rm -rf dist/types/testing && rm -rf dist/types/__tests__",
|
|
26
|
-
"build": "yarn clean && yarn lint && yarn build-cjs && yarn build-esm && yarn build-types && yarn size && yarn
|
|
26
|
+
"build": "yarn clean && yarn lint && yarn build-cjs && yarn build-esm && yarn build-types && yarn size && yarn generate-docs",
|
|
27
27
|
"size": "npx minified-size dist/esm/*.js | grep 'total:' | sed -E 's/.*total: [^,]*, ([^,]*), ([^,]*), ([^,]*).*/<br\\/>minified: \\1<br\\/>gzipped: \\2<br\\/>brotlied: \\3/'",
|
|
28
28
|
"test": "node node_modules/jest/bin/jest.js",
|
|
29
29
|
"preminor-rc": "yarn build && npm version preminor --preid rc",
|
|
@@ -53,19 +53,19 @@
|
|
|
53
53
|
"@types/jest": "29.5.1",
|
|
54
54
|
"@types/node": "20.1.2",
|
|
55
55
|
"@types/redux-logger": "3.0.9",
|
|
56
|
-
"@typescript-eslint/eslint-plugin": "
|
|
57
|
-
"@typescript-eslint/parser": "
|
|
58
|
-
"eslint": "8.
|
|
59
|
-
"eslint-config-prettier": "
|
|
56
|
+
"@typescript-eslint/eslint-plugin": "8.51.0",
|
|
57
|
+
"@typescript-eslint/parser": "8.51.0",
|
|
58
|
+
"eslint": "8.57.1",
|
|
59
|
+
"eslint-config-prettier": "10.1.8",
|
|
60
60
|
"eslint-plugin-import": "2.32.0",
|
|
61
|
-
"eslint-plugin-prettier": "
|
|
62
|
-
"eslint-plugin-react": "7.
|
|
63
|
-
"eslint-plugin-react-hooks": "
|
|
64
|
-
"eslint-plugin-simple-import-sort": "
|
|
61
|
+
"eslint-plugin-prettier": "5.5.4",
|
|
62
|
+
"eslint-plugin-react": "7.37.5",
|
|
63
|
+
"eslint-plugin-react-hooks": "7.0.1",
|
|
64
|
+
"eslint-plugin-simple-import-sort": "12.1.1",
|
|
65
65
|
"jest": "29.5.0",
|
|
66
66
|
"jest-environment-jsdom": "29.7.0",
|
|
67
67
|
"minified-size": "4.0.0",
|
|
68
|
-
"prettier": "
|
|
68
|
+
"prettier": "3.7.4",
|
|
69
69
|
"react": "18.2.0",
|
|
70
70
|
"react-dom": "18.2.0",
|
|
71
71
|
"react-redux": "8.0.5",
|