reactjrx 1.65.0 → 1.67.4

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.
Files changed (44) hide show
  1. package/dist/index.cjs +1 -2396
  2. package/dist/index.d.ts +1 -1
  3. package/dist/index.js +1584 -2042
  4. package/dist/lib/queries/client/cache/registerResultInCache.d.ts +1 -1
  5. package/dist/lib/queries/client/createClient.d.ts +11 -9
  6. package/dist/lib/queries/client/fetch/notifyQueryResult.d.ts +1 -1
  7. package/dist/lib/queries/client/fetch/queryFetch.d.ts +2 -2
  8. package/dist/lib/queries/client/mutations/cache/MutationCache.d.ts +19 -27
  9. package/dist/lib/queries/client/mutations/cache/types.d.ts +8 -1
  10. package/dist/lib/queries/client/mutations/defaultMutationState.d.ts +1 -1
  11. package/dist/lib/queries/client/mutations/filters.d.ts +1 -1
  12. package/dist/lib/queries/client/mutations/mutation/Mutation.d.ts +36 -0
  13. package/dist/lib/queries/client/mutations/mutation/executeMutation.d.ts +6 -0
  14. package/dist/lib/queries/client/mutations/mutation/types.d.ts +51 -0
  15. package/dist/lib/queries/client/mutations/mutations.test.d.ts +1 -0
  16. package/dist/lib/queries/client/mutations/observers/MutationObserver.d.ts +27 -11
  17. package/dist/lib/queries/client/mutations/observers/mutationObserver.rq.test.d.ts +1 -0
  18. package/dist/lib/queries/client/mutations/observers/types.d.ts +7 -1
  19. package/dist/lib/queries/client/mutations/runner/MutationRunner.d.ts +17 -0
  20. package/dist/lib/queries/client/mutations/runner/mutationRunner.test.d.ts +1 -0
  21. package/dist/lib/queries/client/mutations/types.d.ts +4 -45
  22. package/dist/lib/queries/client/operators.d.ts +6 -2
  23. package/dist/lib/queries/client/refetch/client.d.ts +1 -1
  24. package/dist/lib/queries/client/store/createQueryStore.d.ts +1 -1
  25. package/dist/lib/queries/client/store/updateStoreWithNewQuery.d.ts +1 -1
  26. package/dist/lib/queries/client/tests/utils.d.ts +2 -2
  27. package/dist/lib/queries/client/triggers.d.ts +1 -1
  28. package/dist/lib/queries/client/types.d.ts +2 -1
  29. package/dist/lib/queries/react/mutations/types.d.ts +18 -0
  30. package/dist/lib/queries/react/mutations/useMutation.d.ts +2 -19
  31. package/dist/lib/queries/react/mutations/useMutation.rq.test.d.ts +1 -0
  32. package/dist/lib/queries/react/mutations/useMutationState.d.ts +3 -2
  33. package/dist/lib/queries/react/queries/helpers.d.ts +1 -0
  34. package/dist/lib/utils/{retryBackoff.d.ts → operators/retryBackoff.d.ts} +5 -3
  35. package/dist/lib/utils/operators/trackSubscriptions.d.ts +2 -0
  36. package/package.json +2 -1
  37. package/dist/lib/queries/client/mutations/Mutation.d.ts +0 -27
  38. package/dist/lib/queries/client/mutations/operators.d.ts +0 -3
  39. package/dist/lib/queries/client/mutations/runners/MutationRunner.d.ts +0 -19
  40. package/dist/lib/queries/client/mutations/runners/MutationRunners.d.ts +0 -54
  41. package/dist/lib/utils/trackSubscriptions.d.ts +0 -2
  42. /package/dist/lib/queries/{react/mutations/useMutation.cancel.test.d.ts → client/mutations/mutation/mutation.options.test.d.ts} +0 -0
  43. /package/dist/lib/utils/{emitToSubject.d.ts → operators/emitToSubject.d.ts} +0 -0
  44. /package/dist/lib/utils/{shareLatest.d.ts → operators/shareLatest.d.ts} +0 -0
@@ -1,11 +1,13 @@
1
1
  import { type Observable } from "rxjs";
2
- export interface RetryBackoffConfig {
2
+ export interface RetryBackoffConfig<T> {
3
3
  initialInterval: number;
4
4
  maxRetries?: number;
5
5
  maxInterval?: number;
6
6
  resetOnSuccess?: boolean;
7
7
  shouldRetry?: (attempt: number, error: any) => boolean;
8
8
  backoffDelay?: (iteration: number, initialInterval: number) => number;
9
+ caughtError?: (attempt: number, error: any) => void | Observable<T>;
10
+ catchError?: (attempt: number, error: any) => Observable<T>;
9
11
  }
10
12
  /** Calculates the actual delay which can be limited by maxInterval */
11
13
  export declare function getDelay(backoffDelay: number, maxInterval: number): number;
@@ -16,7 +18,7 @@ export declare function exponentialBackoffDelay(iteration: number, initialInterv
16
18
  * of an error. If the source Observable calls error, rather than propagating
17
19
  * the error call this method will resubscribe to the source Observable with
18
20
  * exponentially increasing interval and up to a maximum of count
19
- * resubscriptions (if provided). Retrying can be cancelled at any point if
21
+ * re-subscriptions (if provided). Retrying can be cancelled at any point if
20
22
  * shouldRetry returns false.
21
23
  */
22
- export declare function retryBackoff(config: number | RetryBackoffConfig): <T>(source: Observable<T>) => Observable<T>;
24
+ export declare function retryBackoff<T>(config: RetryBackoffConfig<T>): <T_1>(source: Observable<T_1>) => Observable<T | T_1>;
@@ -0,0 +1,2 @@
1
+ import { Observable } from "rxjs";
2
+ export declare function trackSubscriptions(onCountUpdate: (activeSubscriptions: number) => void): <T>(source: Observable<T>) => Observable<T>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "reactjrx",
3
3
  "private": false,
4
- "version": "1.65.0",
4
+ "version": "1.67.4",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist"
@@ -54,6 +54,7 @@
54
54
  "global-jsdom": "^9.0.1",
55
55
  "jsdom": "^22.0.0",
56
56
  "prettier": "^3.1.0",
57
+ "react-error-boundary": "^4.0.12",
57
58
  "rollup-plugin-node-externals": "^6.1.2",
58
59
  "rxjs": "^7.8.0",
59
60
  "semantic-release": "^22.0.7",
@@ -1,27 +0,0 @@
1
- import { Subject, Observable, BehaviorSubject } from "rxjs";
2
- import { type MutationState, type MutationOptions } from "./types";
3
- import { type DefaultError } from "../types";
4
- import { type MutationCache } from "./cache/MutationCache";
5
- export declare class Mutation<TData = unknown, TError = DefaultError, TVariables = void, TContext = unknown> {
6
- state: MutationState<TData, TError, TVariables, TContext>;
7
- state$: Observable<typeof this.state>;
8
- options: MutationOptions<TData, TError, TVariables, TContext>;
9
- mutationCache: MutationCache;
10
- protected observerCount: BehaviorSubject<number>;
11
- observerCount$: Observable<number>;
12
- protected cancelSubject: Subject<void>;
13
- protected executeSubject: Subject<TVariables>;
14
- constructor({ options, mutationCache }: {
15
- mutationCache: MutationCache;
16
- options: MutationOptions<TData, TError, TVariables, TContext>;
17
- });
18
- createMutation(variables: TVariables): Observable<MutationState<TData, TError, TVariables, TContext>>;
19
- observeTillFinished(): Observable<MutationState<TData, TError, TVariables, TContext>>;
20
- /**
21
- * @important
22
- * The resulting observable will complete as soon as the mutation
23
- * is over, unlike the state which can be re-subscribed later.
24
- */
25
- execute(variables: TVariables): Observable<MutationState<TData, TError, TVariables, TContext>>;
26
- cancel(): void;
27
- }
@@ -1,3 +0,0 @@
1
- import { type Observable } from "rxjs";
2
- import { type MutationState } from "./types";
3
- export declare const mergeResults: <TData = unknown, TError = unknown, TVariables = unknown, TContext = unknown>(stream$: Observable<Partial<MutationState<TData, TError, TVariables, TContext>>>) => Observable<MutationState<TData, TError, TVariables, TContext>>;
@@ -1,19 +0,0 @@
1
- import { Subject } from "rxjs";
2
- import { type MutationOptions } from "../types";
3
- import { type MutationCache } from "../cache/MutationCache";
4
- import { type QueryClient } from "../../createClient";
5
- export type MutationRunner = ReturnType<typeof createMutationRunner>;
6
- export declare const createMutationRunner: <TData, TError = Error, MutationArg = void, TContext = unknown>({ __queryFinalizeHook, __queryInitHook, __queryTriggerHook, mutationKey, mutationCache, }: {
7
- mutationCache: MutationCache;
8
- client: QueryClient;
9
- } & Pick<MutationOptions<TData, TError, MutationArg, TContext>, "__queryInitHook" | "__queryTriggerHook" | "__queryFinalizeHook" | "mutationKey">) => {
10
- mutationKey: import("../types").MutationKey;
11
- runner$: import("rxjs").Observable<import("../types").MutationState<unknown, unknown, unknown, unknown>>;
12
- trigger: ({ args, options }: {
13
- args: MutationArg;
14
- options: MutationOptions<TData, TError, MutationArg, TContext>;
15
- }) => void;
16
- cancel$: Subject<void>;
17
- destroy: () => void;
18
- getClosed: () => boolean;
19
- };
@@ -1,54 +0,0 @@
1
- import { BehaviorSubject } from "rxjs";
2
- import { type MutationOptions } from "../types";
3
- import { createMutationRunner } from "./MutationRunner";
4
- import { type QueryClient } from "../../createClient";
5
- import { type DefaultError } from "../../types";
6
- export declare class MutationRunners {
7
- client: QueryClient;
8
- /**
9
- * Contain all active mutation for a given key.
10
- * A mutation ca have several triggers running (it is not necessarily one function running)
11
- *
12
- * @important
13
- * - automatically cleaned as soon as the last mutation is done for a given key
14
- */
15
- mutationRunnersByKey$: BehaviorSubject<Map<string, {
16
- mutationKey: import("../types").MutationKey;
17
- runner$: import("rxjs").Observable<import("../types").MutationState<unknown, unknown, unknown, unknown>>;
18
- trigger: ({ args, options }: {
19
- args: any;
20
- options: MutationOptions<any, any, any, any>;
21
- }) => void;
22
- cancel$: import("rxjs").Subject<void>;
23
- destroy: () => void;
24
- getClosed: () => boolean;
25
- }>>;
26
- constructor(client: QueryClient);
27
- /**
28
- * @helper
29
- */
30
- setMutationRunnersByKey(key: string, value: ReturnType<typeof createMutationRunner>): void;
31
- /**
32
- * @helper
33
- */
34
- deleteMutationRunnersByKey(key: string): void;
35
- /**
36
- * @helper
37
- */
38
- getMutationRunnersByKey(key: string): {
39
- mutationKey: import("../types").MutationKey;
40
- runner$: import("rxjs").Observable<import("../types").MutationState<unknown, unknown, unknown, unknown>>;
41
- trigger: ({ args, options }: {
42
- args: any;
43
- options: MutationOptions<any, any, any, any>;
44
- }) => void;
45
- cancel$: import("rxjs").Subject<void>;
46
- destroy: () => void;
47
- getClosed: () => boolean;
48
- } | undefined;
49
- mutate<TData, TError = DefaultError, TVariables = void, TContext = unknown>(params: {
50
- options: MutationOptions<TData, TError, TVariables, TContext>;
51
- args: TVariables;
52
- }): Promise<import("../types").MutationState<TData, TError, TVariables, TContext>>;
53
- destroy(): void;
54
- }
@@ -1,2 +0,0 @@
1
- import { type Observable } from "rxjs";
2
- export declare function trackSubscriptions(onCountUpdate: (activeSubscriptions: number) => void): <T>(source$: Observable<T>) => Observable<T>;