@mobx-query/core 0.2.2 → 0.2.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.
- package/dist/client/MQClient.d.ts +23 -0
- package/dist/client/MQClientAccessor.d.ts +12 -0
- package/dist/client/index.d.ts +5 -0
- package/{src/libs/mobx-query/client/types.ts → dist/client/types.d.ts} +31 -37
- package/dist/core.js +1830 -0
- package/dist/entity/Entity.d.ts +31 -0
- package/dist/entity/EntityCollection.d.ts +29 -0
- package/dist/entity/constants.d.ts +6 -0
- package/dist/entity/index.d.ts +6 -0
- package/{src/libs/mobx-query/entity/types.ts → dist/entity/types.d.ts} +8 -11
- package/dist/index.d.ts +6 -0
- package/dist/mutations/BatchMutationBase.d.ts +14 -0
- package/dist/mutations/BatchUpdateMutation.d.ts +9 -0
- package/dist/mutations/CreateMutation.d.ts +15 -0
- package/dist/mutations/DeleteMutation.d.ts +14 -0
- package/dist/mutations/EntityMutationBase.d.ts +22 -0
- package/dist/mutations/MutationBase.d.ts +13 -0
- package/dist/mutations/OptimisticMutationStrategy.d.ts +19 -0
- package/dist/mutations/UpdateMutation.d.ts +10 -0
- package/dist/mutations/constants.d.ts +12 -0
- package/dist/mutations/index.d.ts +11 -0
- package/dist/mutations/types.d.ts +55 -0
- package/dist/queries/QueryBase.d.ts +14 -0
- package/dist/queries/QueryFragmentMany.d.ts +9 -0
- package/dist/queries/QueryFragmentOne.d.ts +9 -0
- package/dist/queries/QueryMany.d.ts +11 -0
- package/dist/queries/QueryManyBase.d.ts +34 -0
- package/dist/queries/QueryOne.d.ts +11 -0
- package/dist/queries/QueryOneBase.d.ts +19 -0
- package/dist/queries/index.d.ts +10 -0
- package/dist/queries/types.d.ts +23 -0
- package/dist/react/createReactContext.d.ts +8 -0
- package/dist/react/index.d.ts +2 -0
- package/dist/utils/generateEntityId.d.ts +2 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/invalidateQueryByHash.d.ts +2 -0
- package/dist/utils/types.d.ts +7 -0
- package/package.json +6 -1
- package/.gitattributes +0 -2
- package/eslint.config.js +0 -29
- package/index.html +0 -13
- package/src/App.css +0 -0
- package/src/App.tsx +0 -5
- package/src/api/constants.ts +0 -1
- package/src/api/fetch.ts +0 -29
- package/src/api/todos.ts +0 -14
- package/src/api/types.ts +0 -30
- package/src/api/users.ts +0 -19
- package/src/assets/react.svg +0 -1
- package/src/index.css +0 -60
- package/src/libs/mobx-query/client/MQClient.ts +0 -75
- package/src/libs/mobx-query/client/MQClientAccessor.ts +0 -74
- package/src/libs/mobx-query/client/index.ts +0 -8
- package/src/libs/mobx-query/entity/Entity.ts +0 -232
- package/src/libs/mobx-query/entity/EntityCollection.ts +0 -285
- package/src/libs/mobx-query/entity/constants.ts +0 -7
- package/src/libs/mobx-query/entity/index.ts +0 -15
- package/src/libs/mobx-query/index.ts +0 -6
- package/src/libs/mobx-query/mutations/BatchMutationBase.ts +0 -105
- package/src/libs/mobx-query/mutations/BatchUpdateMutation.ts +0 -48
- package/src/libs/mobx-query/mutations/CreateMutation.ts +0 -172
- package/src/libs/mobx-query/mutations/DeleteMutation.ts +0 -94
- package/src/libs/mobx-query/mutations/EntityMutationBase.ts +0 -110
- package/src/libs/mobx-query/mutations/MutationBase.ts +0 -40
- package/src/libs/mobx-query/mutations/OptimisticMutationStrategy.ts +0 -122
- package/src/libs/mobx-query/mutations/UpdateMutation.ts +0 -76
- package/src/libs/mobx-query/mutations/constants.ts +0 -16
- package/src/libs/mobx-query/mutations/index.ts +0 -44
- package/src/libs/mobx-query/mutations/types.ts +0 -205
- package/src/libs/mobx-query/queries/QueryBase.ts +0 -65
- package/src/libs/mobx-query/queries/QueryFragmentMany.ts +0 -31
- package/src/libs/mobx-query/queries/QueryFragmentOne.ts +0 -35
- package/src/libs/mobx-query/queries/QueryMany.ts +0 -80
- package/src/libs/mobx-query/queries/QueryManyBase.ts +0 -135
- package/src/libs/mobx-query/queries/QueryOne.ts +0 -84
- package/src/libs/mobx-query/queries/QueryOneBase.ts +0 -93
- package/src/libs/mobx-query/queries/index.ts +0 -33
- package/src/libs/mobx-query/queries/types.ts +0 -60
- package/src/libs/mobx-query/react/createReactContext.tsx +0 -23
- package/src/libs/mobx-query/react/index.ts +0 -3
- package/src/libs/mobx-query/utils/generateEntityId.ts +0 -12
- package/src/libs/mobx-query/utils/index.ts +0 -8
- package/src/libs/mobx-query/utils/invalidateQueryByHash.ts +0 -18
- package/src/libs/mobx-query/utils/types.ts +0 -18
- package/src/libs/react-query.ts +0 -11
- package/src/main.tsx +0 -16
- package/src/utils.ts +0 -3
- package/src/vite-env.d.ts +0 -1
- package/tsconfig.app.json +0 -27
- package/tsconfig.json +0 -7
- package/tsconfig.node.json +0 -25
- package/vite.config.ts +0 -52
- /package/{public → dist}/vite.svg +0 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { EntityConstructorAny, EntityCollection } from '../entity';
|
|
2
|
+
import { MQClientContextRegistered } from './types';
|
|
3
|
+
import { OptimisticMutationErrorStrategy, OptimisticMutationInvalidationStrategy } from '../mutations';
|
|
4
|
+
export interface MQClientOptions {
|
|
5
|
+
invalidationStrategy?: OptimisticMutationInvalidationStrategy;
|
|
6
|
+
errorStrategy?: OptimisticMutationErrorStrategy;
|
|
7
|
+
invalidateOnError?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface MQClientProps<T> extends MQClientOptions {
|
|
10
|
+
context: MQClientContextRegistered;
|
|
11
|
+
entities: EntityConstructorAny[];
|
|
12
|
+
rootStore: () => T;
|
|
13
|
+
}
|
|
14
|
+
export declare const __MOBX_QUERY__: {
|
|
15
|
+
state: Map<string, EntityCollection>;
|
|
16
|
+
context: MQClientContextRegistered | null;
|
|
17
|
+
options: Required<MQClientOptions>;
|
|
18
|
+
};
|
|
19
|
+
export declare class MQClient<T> {
|
|
20
|
+
readonly rootStore: T;
|
|
21
|
+
constructor(props: MQClientProps<T>);
|
|
22
|
+
getEntityCollection<TEntityConstructor extends EntityConstructorAny>(entity: TEntityConstructor): EntityCollection<TEntityConstructor>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DefaultError, MutationOptions, QueryClient } from '@tanstack/react-query';
|
|
2
|
+
import { MQClientContextRegistered } from './types';
|
|
3
|
+
import { EntityCollection, EntityConstructorAny } from '../entity';
|
|
4
|
+
import { MutationFn } from '../mutations';
|
|
5
|
+
export declare abstract class MQClientAccessor {
|
|
6
|
+
protected readonly queryClient: QueryClient;
|
|
7
|
+
protected readonly context: MQClientContextRegistered;
|
|
8
|
+
private readonly globalState;
|
|
9
|
+
constructor();
|
|
10
|
+
protected getEntityCollection<TEntityConstructor extends EntityConstructorAny = EntityConstructorAny>(entityConstructor: TEntityConstructor): EntityCollection<TEntityConstructor>;
|
|
11
|
+
protected runSyncMutation<TInput, TError = DefaultError, TMutateResult = unknown>(input: TInput, mutationFn: MutationFn<TInput>, options?: MutationOptions<void, TError, TInput, TMutateResult>): void;
|
|
12
|
+
}
|
|
@@ -1,37 +1,31 @@
|
|
|
1
|
-
import { QueryClient } from '@tanstack/react-query'
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
*/
|
|
33
|
-
export type MQClientContextRegistered = MobXQuery.RegisteredContext extends {
|
|
34
|
-
context: infer TContext extends MQClientContext
|
|
35
|
-
}
|
|
36
|
-
? TContext
|
|
37
|
-
: MQClientContext
|
|
1
|
+
import { QueryClient } from '@tanstack/react-query';
|
|
2
|
+
export interface MQClientContext {
|
|
3
|
+
queryClient: QueryClient;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Global namespace that users can augment to register their custom context type.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* declare global {
|
|
11
|
+
* namespace MobXQuery {
|
|
12
|
+
* interface RegisteredContext {
|
|
13
|
+
* context: MyCustomContext
|
|
14
|
+
* }
|
|
15
|
+
* }
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
declare global {
|
|
20
|
+
namespace MobXQuery {
|
|
21
|
+
interface RegisteredContext {
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Extracts the user's registered context type or falls back to base MQClientContext.
|
|
27
|
+
* This allows users to define their context type once via global namespace augmentation.
|
|
28
|
+
*/
|
|
29
|
+
export type MQClientContextRegistered = MobXQuery.RegisteredContext extends {
|
|
30
|
+
context: infer TContext extends MQClientContext;
|
|
31
|
+
} ? TContext : MQClientContext;
|