@mobx-query/core 0.2.1 → 0.2.3

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 (93) hide show
  1. package/dist/client/MQClient.d.ts +23 -0
  2. package/dist/client/MQClientAccessor.d.ts +12 -0
  3. package/dist/client/index.d.ts +5 -0
  4. package/{src/libs/mobx-query/client/types.ts → dist/client/types.d.ts} +31 -37
  5. package/dist/core.js +1830 -0
  6. package/dist/entity/Entity.d.ts +31 -0
  7. package/dist/entity/EntityCollection.d.ts +29 -0
  8. package/dist/entity/constants.d.ts +6 -0
  9. package/dist/entity/index.d.ts +6 -0
  10. package/{src/libs/mobx-query/entity/types.ts → dist/entity/types.d.ts} +8 -11
  11. package/dist/index.d.ts +6 -0
  12. package/dist/mutations/BatchMutationBase.d.ts +14 -0
  13. package/dist/mutations/BatchUpdateMutation.d.ts +9 -0
  14. package/dist/mutations/CreateMutation.d.ts +15 -0
  15. package/dist/mutations/DeleteMutation.d.ts +14 -0
  16. package/dist/mutations/EntityMutationBase.d.ts +22 -0
  17. package/dist/mutations/MutationBase.d.ts +13 -0
  18. package/dist/mutations/OptimisticMutationStrategy.d.ts +19 -0
  19. package/dist/mutations/UpdateMutation.d.ts +10 -0
  20. package/dist/mutations/constants.d.ts +12 -0
  21. package/dist/mutations/index.d.ts +11 -0
  22. package/dist/mutations/types.d.ts +55 -0
  23. package/dist/queries/QueryBase.d.ts +14 -0
  24. package/dist/queries/QueryFragmentMany.d.ts +9 -0
  25. package/dist/queries/QueryFragmentOne.d.ts +9 -0
  26. package/dist/queries/QueryMany.d.ts +11 -0
  27. package/dist/queries/QueryManyBase.d.ts +34 -0
  28. package/dist/queries/QueryOne.d.ts +11 -0
  29. package/dist/queries/QueryOneBase.d.ts +19 -0
  30. package/dist/queries/index.d.ts +10 -0
  31. package/dist/queries/types.d.ts +23 -0
  32. package/dist/react/createReactContext.d.ts +8 -0
  33. package/dist/react/index.d.ts +2 -0
  34. package/dist/utils/generateEntityId.d.ts +2 -0
  35. package/dist/utils/index.d.ts +5 -0
  36. package/dist/utils/invalidateQueryByHash.d.ts +2 -0
  37. package/dist/utils/types.d.ts +7 -0
  38. package/package.json +8 -18
  39. package/.gitattributes +0 -2
  40. package/eslint.config.js +0 -29
  41. package/index.html +0 -13
  42. package/src/App.css +0 -0
  43. package/src/App.tsx +0 -5
  44. package/src/api/constants.ts +0 -1
  45. package/src/api/fetch.ts +0 -29
  46. package/src/api/todos.ts +0 -14
  47. package/src/api/types.ts +0 -30
  48. package/src/api/users.ts +0 -19
  49. package/src/assets/react.svg +0 -1
  50. package/src/index.css +0 -60
  51. package/src/libs/mobx-query/client/MQClient.ts +0 -75
  52. package/src/libs/mobx-query/client/MQClientAccessor.ts +0 -74
  53. package/src/libs/mobx-query/client/index.ts +0 -8
  54. package/src/libs/mobx-query/entity/Entity.ts +0 -232
  55. package/src/libs/mobx-query/entity/EntityCollection.ts +0 -285
  56. package/src/libs/mobx-query/entity/constants.ts +0 -7
  57. package/src/libs/mobx-query/entity/index.ts +0 -15
  58. package/src/libs/mobx-query/index.ts +0 -6
  59. package/src/libs/mobx-query/mutations/BatchMutationBase.ts +0 -105
  60. package/src/libs/mobx-query/mutations/BatchUpdateMutation.ts +0 -48
  61. package/src/libs/mobx-query/mutations/CreateMutation.ts +0 -172
  62. package/src/libs/mobx-query/mutations/DeleteMutation.ts +0 -94
  63. package/src/libs/mobx-query/mutations/EntityMutationBase.ts +0 -110
  64. package/src/libs/mobx-query/mutations/MutationBase.ts +0 -40
  65. package/src/libs/mobx-query/mutations/OptimisticMutationStrategy.ts +0 -122
  66. package/src/libs/mobx-query/mutations/UpdateMutation.ts +0 -76
  67. package/src/libs/mobx-query/mutations/constants.ts +0 -16
  68. package/src/libs/mobx-query/mutations/index.ts +0 -44
  69. package/src/libs/mobx-query/mutations/types.ts +0 -205
  70. package/src/libs/mobx-query/queries/QueryBase.ts +0 -65
  71. package/src/libs/mobx-query/queries/QueryFragmentMany.ts +0 -31
  72. package/src/libs/mobx-query/queries/QueryFragmentOne.ts +0 -35
  73. package/src/libs/mobx-query/queries/QueryMany.ts +0 -80
  74. package/src/libs/mobx-query/queries/QueryManyBase.ts +0 -135
  75. package/src/libs/mobx-query/queries/QueryOne.ts +0 -84
  76. package/src/libs/mobx-query/queries/QueryOneBase.ts +0 -93
  77. package/src/libs/mobx-query/queries/index.ts +0 -33
  78. package/src/libs/mobx-query/queries/types.ts +0 -60
  79. package/src/libs/mobx-query/react/createReactContext.tsx +0 -23
  80. package/src/libs/mobx-query/react/index.ts +0 -3
  81. package/src/libs/mobx-query/utils/generateEntityId.ts +0 -12
  82. package/src/libs/mobx-query/utils/index.ts +0 -8
  83. package/src/libs/mobx-query/utils/invalidateQueryByHash.ts +0 -18
  84. package/src/libs/mobx-query/utils/types.ts +0 -18
  85. package/src/libs/react-query.ts +0 -11
  86. package/src/main.tsx +0 -16
  87. package/src/utils.ts +0 -3
  88. package/src/vite-env.d.ts +0 -1
  89. package/tsconfig.app.json +0 -27
  90. package/tsconfig.json +0 -7
  91. package/tsconfig.node.json +0 -25
  92. package/vite.config.ts +0 -52
  93. /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
+ }
@@ -0,0 +1,5 @@
1
+ import { MQClient } from './MQClient';
2
+ import { MQClientAccessor } from './MQClientAccessor';
3
+ import { MQClientContext, MQClientContextRegistered } from './types';
4
+ export { MQClient, MQClientAccessor };
5
+ export type { MQClientContext, MQClientContextRegistered };
@@ -1,37 +1,31 @@
1
- import { QueryClient } from '@tanstack/react-query'
2
-
3
- export interface MQClientContext {
4
- queryClient: QueryClient
5
- }
6
-
7
- /**
8
- * Global namespace that users can augment to register their custom context type.
9
- *
10
- * @example
11
- * ```ts
12
- * declare global {
13
- * namespace MobXQuery {
14
- * interface RegisteredContext {
15
- * context: MyCustomContext
16
- * }
17
- * }
18
- * }
19
- * ```
20
- */
21
- declare global {
22
- // eslint-disable-next-line @typescript-eslint/no-namespace
23
- namespace MobXQuery {
24
- // eslint-disable-next-line @typescript-eslint/no-empty-object-type
25
- interface RegisteredContext {}
26
- }
27
- }
28
-
29
- /**
30
- * Extracts the user's registered context type or falls back to base MQClientContext.
31
- * This allows users to define their context type once via global namespace augmentation.
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;