@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,31 @@
|
|
|
1
|
+
import { EntityData, EntityEvents, EntityId } from './types';
|
|
2
|
+
import { MQClientAccessor } from '../client';
|
|
3
|
+
import { EntityState } from './constants';
|
|
4
|
+
export type EntityConstructor<TData = unknown, TEntityId extends EntityId = string, E extends Entity<TData, TEntityId> = Entity<TData, TEntityId>> = new () => E;
|
|
5
|
+
export type EntityConstructorAny = EntityConstructor<EntityData, any, EntityAny>;
|
|
6
|
+
export type EntityAny = Entity<any, any>;
|
|
7
|
+
export type EntityValueKeys<T> = {
|
|
8
|
+
[K in keyof T]: T[K] extends Function ? never : K extends "isDirty" | "state" | "queryHashes" ? never : K;
|
|
9
|
+
}[keyof T] & string;
|
|
10
|
+
export declare abstract class Entity<TData = unknown, TEntityId extends EntityId = string> extends MQClientAccessor {
|
|
11
|
+
abstract id: TEntityId;
|
|
12
|
+
abstract hydrate(data: TData): void;
|
|
13
|
+
readonly queryHashes: Set<string>;
|
|
14
|
+
private events;
|
|
15
|
+
accessor state: EntityState;
|
|
16
|
+
accessor isDirty: boolean;
|
|
17
|
+
private readonly initValuesSnapshot;
|
|
18
|
+
private isHydrated;
|
|
19
|
+
_init(queryHashes: string[], events: EntityEvents<TEntityId>): void;
|
|
20
|
+
_removeQueryHashes(hashes: string[]): void;
|
|
21
|
+
_markAsHydrated(): void;
|
|
22
|
+
private onObservableChange;
|
|
23
|
+
/**
|
|
24
|
+
* Deep clones a value to ensure we store a snapshot, not a reference.
|
|
25
|
+
* Handles primitives, objects, arrays, and MobX observables.
|
|
26
|
+
*/
|
|
27
|
+
private deepCloneValue;
|
|
28
|
+
reset(): void;
|
|
29
|
+
_clearDirty(): void;
|
|
30
|
+
invalidateRelatedQueries(): void;
|
|
31
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { EntityConstructor, EntityConstructorAny } from './Entity';
|
|
2
|
+
import { QueryClient } from '@tanstack/react-query';
|
|
3
|
+
import { EntityDataAny, EntityId } from './types';
|
|
4
|
+
export declare class EntityCollection<TEntityConstructor extends EntityConstructorAny = EntityConstructorAny> {
|
|
5
|
+
private readonly entityConstructor;
|
|
6
|
+
private readonly queryClient;
|
|
7
|
+
accessor collection: Map<EntityId, InstanceType<TEntityConstructor>>;
|
|
8
|
+
accessor deletedRecordIds: Set<EntityId>;
|
|
9
|
+
accessor clientOnlyEntityIds: Set<EntityId>;
|
|
10
|
+
constructor(entityConstructor: EntityConstructor<any, any, InstanceType<TEntityConstructor>>, queryClient: QueryClient);
|
|
11
|
+
get size(): number;
|
|
12
|
+
get entities(): InstanceType<TEntityConstructor>[];
|
|
13
|
+
get clientOnlyEntitiesMap(): Map<EntityId, InstanceType<TEntityConstructor>>;
|
|
14
|
+
get clientOnlyEntities(): InstanceType<TEntityConstructor>[];
|
|
15
|
+
setEntity(data: EntityDataAny, queryHashes?: string[]): InstanceType<TEntityConstructor>;
|
|
16
|
+
setEntities(entityData: EntityDataAny[], queryHashes: string[]): readonly [InstanceType<TEntityConstructor>[], EntityId[]];
|
|
17
|
+
deleteEntity(entityId: EntityId): void;
|
|
18
|
+
getEntityById(entityId: EntityId): InstanceType<TEntityConstructor> | undefined;
|
|
19
|
+
filter(predicate: (value: InstanceType<TEntityConstructor>, index: number) => boolean): InstanceType<TEntityConstructor>[];
|
|
20
|
+
find(predicate: (value: InstanceType<TEntityConstructor>, index: number) => boolean): InstanceType<TEntityConstructor> | undefined;
|
|
21
|
+
findIndex(predicate: (value: InstanceType<TEntityConstructor>, index: number) => boolean): number;
|
|
22
|
+
findLast(predicate: (value: InstanceType<TEntityConstructor>, index: number) => boolean): InstanceType<TEntityConstructor> | undefined;
|
|
23
|
+
findLastIndex(predicate: (value: InstanceType<TEntityConstructor>, index: number) => boolean): number;
|
|
24
|
+
some(predicate: (value: InstanceType<TEntityConstructor>, index: number) => boolean): boolean;
|
|
25
|
+
every(predicate: (value: InstanceType<TEntityConstructor>, index: number) => boolean): boolean;
|
|
26
|
+
map<T>(predicate: (value: InstanceType<TEntityConstructor>, index: number) => T): T[];
|
|
27
|
+
private initQueryClientCacheListener;
|
|
28
|
+
private removeQueryHashesFromAllEntities;
|
|
29
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Entity, EntityConstructorAny, EntityAny } from './Entity';
|
|
2
|
+
import { EntityCollection } from './EntityCollection';
|
|
3
|
+
import { EntityState } from './constants';
|
|
4
|
+
import { EntityId, EntityData, EntityDataAny } from './types';
|
|
5
|
+
export { Entity, EntityState, EntityCollection };
|
|
6
|
+
export type { EntityConstructorAny, EntityAny, EntityData, EntityDataAny, EntityId, };
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
export type EntityId = string | number;
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export interface EntityEvents<TEntityId extends EntityId = string> {
|
|
10
|
-
onAllQueryHashesRemoved: (entityId: TEntityId) => void;
|
|
11
|
-
}
|
|
1
|
+
export type EntityId = string | number;
|
|
2
|
+
export interface EntityData<TEntityId extends EntityId = string> {
|
|
3
|
+
id: TEntityId;
|
|
4
|
+
}
|
|
5
|
+
export type EntityDataAny = EntityData<EntityId>;
|
|
6
|
+
export interface EntityEvents<TEntityId extends EntityId = string> {
|
|
7
|
+
onAllQueryHashesRemoved: (entityId: TEntityId) => void;
|
|
8
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DefaultError, MutationFunctionContext } from '@tanstack/react-query';
|
|
2
|
+
import { EntityConstructorAny, EntityCollection } from '../entity';
|
|
3
|
+
import { BatchMutationInputInternal, UseBatchMutationHookOptions } from './types';
|
|
4
|
+
import { MutationBase } from './MutationBase';
|
|
5
|
+
export declare class BatchMutationBase<TEntityConstructor extends EntityConstructorAny, TError = DefaultError, TMutateResult = unknown> extends MutationBase<TEntityConstructor> {
|
|
6
|
+
protected readonly options: UseBatchMutationHookOptions<TEntityConstructor, TError, TMutateResult>;
|
|
7
|
+
protected readonly collection: EntityCollection<TEntityConstructor>;
|
|
8
|
+
constructor(mutationPrefix: string, options: UseBatchMutationHookOptions<TEntityConstructor, TError, TMutateResult>);
|
|
9
|
+
protected onMutateBase(input: BatchMutationInputInternal<TEntityConstructor>, context: MutationFunctionContext): Promise<TMutateResult>;
|
|
10
|
+
protected onSuccessBase(input: BatchMutationInputInternal<TEntityConstructor>, onMutateResult: TMutateResult | undefined, context: MutationFunctionContext): Promise<void>;
|
|
11
|
+
protected onErrorBase(error: TError, input: BatchMutationInputInternal<TEntityConstructor>, onMutateResult: TMutateResult | undefined, context: MutationFunctionContext): Promise<void>;
|
|
12
|
+
protected onSettledBase(error: TError | null, input: BatchMutationInputInternal<TEntityConstructor>, onMutateResult: TMutateResult | undefined, context: MutationFunctionContext): Promise<void>;
|
|
13
|
+
protected createInternalInput(entities: InstanceType<TEntityConstructor>[]): BatchMutationInputInternal<TEntityConstructor>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DefaultError } from '@tanstack/react-query';
|
|
2
|
+
import { EntityConstructorAny } from '../entity';
|
|
3
|
+
import { BatchMutationBase } from './BatchMutationBase';
|
|
4
|
+
import { UseBatchMutationHookOptions } from './types';
|
|
5
|
+
export declare class BatchUpdateMutation<TEntityConstructor extends EntityConstructorAny, TError = DefaultError, TMutateResult = unknown> extends BatchMutationBase<TEntityConstructor, TError, TMutateResult> {
|
|
6
|
+
static readonly mutationPrefix = "__mutation__batch__update__";
|
|
7
|
+
constructor(options: UseBatchMutationHookOptions<TEntityConstructor, TError, TMutateResult>);
|
|
8
|
+
useMutation(): (entities: InstanceType<TEntityConstructor>[]) => void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { DefaultError } from '@tanstack/react-query';
|
|
2
|
+
import { EntityAny, EntityConstructorAny } from '../entity';
|
|
3
|
+
import { UseCreateMutationHookOptions } from './types';
|
|
4
|
+
import { MutationBase } from './MutationBase';
|
|
5
|
+
export declare class CreateMutation<TInput, TEntityConstructor extends EntityConstructorAny = EntityConstructorAny, TError = DefaultError, TMutateResult = unknown> extends MutationBase<TEntityConstructor> {
|
|
6
|
+
private readonly options;
|
|
7
|
+
static readonly mutationPrefix = "__mutation__create__";
|
|
8
|
+
constructor(options: UseCreateMutationHookOptions<TInput, TEntityConstructor, TError, TMutateResult>);
|
|
9
|
+
useMutation(): (input: TInput) => void;
|
|
10
|
+
private onMutate;
|
|
11
|
+
private onSuccess;
|
|
12
|
+
private onError;
|
|
13
|
+
private onSettled;
|
|
14
|
+
protected createMutationStrategy(entities: EntityAny[]): import('./OptimisticMutationStrategy').OptimisticMutationStrategy;
|
|
15
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DefaultError } from '@tanstack/react-query';
|
|
2
|
+
import { EntityConstructorAny } from '../entity';
|
|
3
|
+
import { UseEntityMutationHookOptions } from './types';
|
|
4
|
+
import { EntityMutationBase } from './EntityMutationBase';
|
|
5
|
+
export declare class DeleteMutation<TEntityConstructor extends EntityConstructorAny, TError = DefaultError, TMutateResult = unknown> extends EntityMutationBase<void, TEntityConstructor, TError, TMutateResult> {
|
|
6
|
+
static readonly mutationPrefix = "__mutation__delete__";
|
|
7
|
+
constructor(options: UseEntityMutationHookOptions<TEntityConstructor, TError, TMutateResult>);
|
|
8
|
+
useMutation(): () => void;
|
|
9
|
+
private onMutate;
|
|
10
|
+
private onSuccess;
|
|
11
|
+
private onError;
|
|
12
|
+
private onSettled;
|
|
13
|
+
mutate(input: void): void;
|
|
14
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { EntityConstructorAny, EntityAny } from '../entity';
|
|
2
|
+
import { OptimisticMutationStrategy } from './OptimisticMutationStrategy';
|
|
3
|
+
import { EntityMutationCallbacks, UseEntityMutationHookOptions } from './types';
|
|
4
|
+
import { DefaultError, MutationFunctionContext } from '@tanstack/react-query';
|
|
5
|
+
import { MutationBase } from './MutationBase';
|
|
6
|
+
/**
|
|
7
|
+
* Base class for mutations that operate ON an existing entity.
|
|
8
|
+
* Use this for update/delete mutations where the entity already exists.
|
|
9
|
+
* For entity-creating mutations, use CollectionMutationBase instead.
|
|
10
|
+
*/
|
|
11
|
+
export declare abstract class EntityMutationBase<TInput, TEntityConstructor extends EntityConstructorAny, TError = DefaultError, TMutateResult = unknown> extends MutationBase<TEntityConstructor> {
|
|
12
|
+
protected readonly options: UseEntityMutationHookOptions<TEntityConstructor, TError, TMutateResult>;
|
|
13
|
+
protected readonly mutationStrategy: OptimisticMutationStrategy;
|
|
14
|
+
constructor(mutationPrefix: string, options: UseEntityMutationHookOptions<TEntityConstructor, TError, TMutateResult>);
|
|
15
|
+
get entityMutationKey(): any[];
|
|
16
|
+
protected onMutateBase(context: MutationFunctionContext): Promise<TMutateResult | undefined>;
|
|
17
|
+
protected onSuccessBase(result: TMutateResult | undefined, ctx: MutationFunctionContext): Promise<void>;
|
|
18
|
+
protected onErrorBase(error: TError, result: TMutateResult | undefined, ctx: MutationFunctionContext): Promise<void>;
|
|
19
|
+
protected onSettledBase(error: TError | null, result: TMutateResult | undefined, ctx: MutationFunctionContext): Promise<void>;
|
|
20
|
+
protected mutateBase(input: TInput, callbacks: EntityMutationCallbacks<EntityAny, TError, TMutateResult>): void;
|
|
21
|
+
abstract mutate(input: TInput): void;
|
|
22
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { EntityAny, EntityConstructorAny } from '../entity';
|
|
2
|
+
import { EntityCollection } from '../entity/EntityCollection';
|
|
3
|
+
import { MQClientAccessor } from '../client';
|
|
4
|
+
import { OptimisticMutationStrategy } from './OptimisticMutationStrategy';
|
|
5
|
+
import { OptimisticMutationStrategyOptions } from './types';
|
|
6
|
+
export declare class MutationBase<TEntityConstructor extends EntityConstructorAny> extends MQClientAccessor {
|
|
7
|
+
protected readonly mutationPrefix: string;
|
|
8
|
+
protected readonly entity: TEntityConstructor;
|
|
9
|
+
protected readonly collection: EntityCollection<TEntityConstructor>;
|
|
10
|
+
constructor(mutationPrefix: string, entity: TEntityConstructor);
|
|
11
|
+
get baseMutationKey(): string[];
|
|
12
|
+
protected createMutationStrategy(entities: EntityAny[], options: OptimisticMutationStrategyOptions): OptimisticMutationStrategy;
|
|
13
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { EntityConstructorAny, EntityAny } from '../entity';
|
|
2
|
+
import { OptimisticMutationStrategyOptions } from './types';
|
|
3
|
+
import { MQClientAccessor } from '../client';
|
|
4
|
+
import { OptimisticMutationErrorStrategy, OptimisticMutationInvalidationStrategy } from './constants';
|
|
5
|
+
export declare class OptimisticMutationStrategy extends MQClientAccessor {
|
|
6
|
+
private readonly entityConstructor;
|
|
7
|
+
private readonly entities;
|
|
8
|
+
private readonly options?;
|
|
9
|
+
constructor(entityConstructor: EntityConstructorAny, entities: EntityAny[], options?: OptimisticMutationStrategyOptions | undefined);
|
|
10
|
+
get invalidationStrategy(): OptimisticMutationInvalidationStrategy;
|
|
11
|
+
get mutationErrorStrategy(): OptimisticMutationErrorStrategy;
|
|
12
|
+
get invalidateOnError(): boolean;
|
|
13
|
+
onMutate(): void;
|
|
14
|
+
onSuccess(): void;
|
|
15
|
+
onError(ignoreReset?: boolean): void;
|
|
16
|
+
private runInvalidationStrategy;
|
|
17
|
+
private invalidateCollectionRelatedQueries;
|
|
18
|
+
private invalidateEntityRelatedQueries;
|
|
19
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DefaultError } from '@tanstack/react-query';
|
|
2
|
+
import { EntityConstructorAny } from '../entity';
|
|
3
|
+
import { UseEntityMutationHookOptions } from './types';
|
|
4
|
+
import { EntityMutationBase } from './EntityMutationBase';
|
|
5
|
+
export declare class UpdateMutation<TEntityConstructor extends EntityConstructorAny, TError = DefaultError, TMutateResult = unknown> extends EntityMutationBase<void, TEntityConstructor, TError, TMutateResult> {
|
|
6
|
+
static readonly mutationPrefix = "__mutation__update__";
|
|
7
|
+
constructor(options: UseEntityMutationHookOptions<TEntityConstructor, TError, TMutateResult>);
|
|
8
|
+
useMutation(): () => void;
|
|
9
|
+
mutate(input: void): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const OptimisticMutationInvalidationStrategy: {
|
|
2
|
+
readonly ALL_QUERIES: "all-queries";
|
|
3
|
+
readonly ALL_ENTITY_QUERIES: "all-entity-queries";
|
|
4
|
+
readonly REFERENCED_QUERIES: "referenced-queries";
|
|
5
|
+
readonly NONE: "none";
|
|
6
|
+
};
|
|
7
|
+
export declare const OptimisticMutationErrorStrategy: {
|
|
8
|
+
readonly ROLLBACK: "rollback";
|
|
9
|
+
readonly KEEP: "keep";
|
|
10
|
+
};
|
|
11
|
+
export type OptimisticMutationInvalidationStrategy = (typeof OptimisticMutationInvalidationStrategy)[keyof typeof OptimisticMutationInvalidationStrategy];
|
|
12
|
+
export type OptimisticMutationErrorStrategy = (typeof OptimisticMutationErrorStrategy)[keyof typeof OptimisticMutationErrorStrategy];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { MutationFn, BatchMutationFn, CreateMutationFn, OptimisticMutationStrategyOptions, UseCreateMutationHookOptions, UseEntityMutationHookOptions, UseBatchMutationHookOptions } from './types';
|
|
2
|
+
import { BatchMutationBase } from './BatchMutationBase';
|
|
3
|
+
import { BatchUpdateMutation } from './BatchUpdateMutation';
|
|
4
|
+
import { CreateMutation } from './CreateMutation';
|
|
5
|
+
import { DeleteMutation } from './DeleteMutation';
|
|
6
|
+
import { EntityMutationBase } from './EntityMutationBase';
|
|
7
|
+
import { UpdateMutation } from './UpdateMutation';
|
|
8
|
+
import { MutationBase } from './MutationBase';
|
|
9
|
+
import { OptimisticMutationErrorStrategy, OptimisticMutationInvalidationStrategy } from './constants';
|
|
10
|
+
export { MutationBase, BatchMutationBase, EntityMutationBase, BatchUpdateMutation, CreateMutation, DeleteMutation, UpdateMutation, OptimisticMutationErrorStrategy, OptimisticMutationInvalidationStrategy, };
|
|
11
|
+
export type { MutationFn, BatchMutationFn, CreateMutationFn, OptimisticMutationStrategyOptions, UseCreateMutationHookOptions, UseEntityMutationHookOptions, UseBatchMutationHookOptions, };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { DefaultError, MutationFunctionContext, UseMutationOptions } from '@tanstack/react-query';
|
|
2
|
+
import { MQClientContextRegistered } from '../client/types';
|
|
3
|
+
import { EntityAny, EntityConstructorAny } from '../entity';
|
|
4
|
+
import { OptimisticMutationStrategy } from './OptimisticMutationStrategy';
|
|
5
|
+
import { OptimisticMutationErrorStrategy, OptimisticMutationInvalidationStrategy } from './constants';
|
|
6
|
+
export type MutationFn<TInput> = (input: TInput, context: MQClientContextRegistered) => Promise<void>;
|
|
7
|
+
export type BatchMutationFn<TEntity extends EntityAny> = (entities: TEntity[], context: MQClientContextRegistered) => Promise<void>;
|
|
8
|
+
export interface CreateMutationInputInternal<TInput, TEntityConstructor extends EntityConstructorAny> {
|
|
9
|
+
input: TInput;
|
|
10
|
+
entity: InstanceType<TEntityConstructor>;
|
|
11
|
+
mutationStrategy: OptimisticMutationStrategy;
|
|
12
|
+
}
|
|
13
|
+
export interface BatchMutationInputInternal<TEntityConstructor extends EntityConstructorAny> {
|
|
14
|
+
strategy: OptimisticMutationStrategy;
|
|
15
|
+
entities: InstanceType<TEntityConstructor>[];
|
|
16
|
+
}
|
|
17
|
+
export interface OptimisticMutationStrategyOptions {
|
|
18
|
+
invalidationStrategy?: OptimisticMutationInvalidationStrategy;
|
|
19
|
+
errorStrategy?: OptimisticMutationErrorStrategy;
|
|
20
|
+
invalidateOnError?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface UseMutationHookCommonOptions<TData = unknown, TError = DefaultError, TVariables = void, TMutateResult = unknown> extends Omit<UseMutationOptions<TData, TError, TVariables, TMutateResult>, "mutationFn" | "mutationKey" | "onSuccess" | "onError" | "onMutate" | "onSettled"> {
|
|
23
|
+
}
|
|
24
|
+
export interface UseCreateMutationHookOptions<TInput, TEntityConstructor extends EntityConstructorAny, TError = DefaultError, TMutateResult = unknown, TEntity extends InstanceType<TEntityConstructor> = InstanceType<TEntityConstructor>> extends UseMutationHookCommonOptions<void, TError, void, TMutateResult>, OptimisticMutationStrategyOptions, CreateEntityMutationCallbacks<TInput, TEntity, TError, TMutateResult> {
|
|
25
|
+
entity: TEntityConstructor;
|
|
26
|
+
mutationFn: CreateMutationFn<TInput, TEntityConstructor>;
|
|
27
|
+
}
|
|
28
|
+
export type CreateMutationFn<TInput, TEntityConstructor extends EntityConstructorAny> = (input: TInput, entity: InstanceType<TEntityConstructor>, context: MQClientContextRegistered) => Promise<void>;
|
|
29
|
+
export interface CreateEntityMutationCallbacks<TInput, TEntity extends EntityAny, TError = DefaultError, TMutateResult = unknown> {
|
|
30
|
+
onMutate?: (input: TInput, entity: TEntity, context: MutationFunctionContext) => (TMutateResult | Promise<TMutateResult | undefined>) | undefined;
|
|
31
|
+
onSuccess?: (input: TInput, entity: TEntity, onMutateResult: TMutateResult | undefined, context: MutationFunctionContext) => void | Promise<void>;
|
|
32
|
+
onError?: (error: TError, input: TInput, entity: TEntity, onMutateResult: TMutateResult | undefined, context: MutationFunctionContext) => void | Promise<void>;
|
|
33
|
+
onSettled?: (input: TInput, entity: TEntity, error: TError | null, onMutateResult: TMutateResult | undefined, context: MutationFunctionContext) => void | Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
export interface EntityMutationCallbacks<TEntity extends EntityAny, TError = DefaultError, TMutateResult = unknown> {
|
|
36
|
+
onMutate?: (entity: TEntity, context: MutationFunctionContext) => (TMutateResult | Promise<TMutateResult | undefined>) | undefined;
|
|
37
|
+
onSuccess?: (entity: TEntity, onMutateResult: TMutateResult | undefined, context: MutationFunctionContext) => void | Promise<void>;
|
|
38
|
+
onError?: (error: TError, entity: TEntity, onMutateResult: TMutateResult | undefined, context: MutationFunctionContext) => void | Promise<void>;
|
|
39
|
+
onSettled?: (entity: TEntity, error: TError | null, onMutateResult: TMutateResult | undefined, context: MutationFunctionContext) => void | Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
export interface UseEntityMutationHookOptions<TEntityConstructor extends EntityConstructorAny, TError = DefaultError, TMutateResult = unknown, TEntity extends InstanceType<TEntityConstructor> = InstanceType<TEntityConstructor>> extends UseMutationHookCommonOptions<void, TError, void, TMutateResult>, OptimisticMutationStrategyOptions, EntityMutationCallbacks<TEntity, TError, TMutateResult> {
|
|
42
|
+
entity: TEntityConstructor;
|
|
43
|
+
instance: TEntity;
|
|
44
|
+
mutationFn: MutationFn<void>;
|
|
45
|
+
}
|
|
46
|
+
export interface EntitiesBatchMutationCallbacks<TEntity extends EntityAny, TError = DefaultError, TMutateResult = unknown> {
|
|
47
|
+
onMutate?: (entities: TEntity[], context: MutationFunctionContext) => (TMutateResult | Promise<TMutateResult | undefined>) | undefined;
|
|
48
|
+
onSuccess?: (entities: TEntity[], context: MutationFunctionContext, onMutateResult: TMutateResult | undefined) => void | Promise<void>;
|
|
49
|
+
onError?: (error: TError, entities: TEntity[], context: MutationFunctionContext, onMutateResult: TMutateResult | undefined) => void | Promise<void>;
|
|
50
|
+
onSettled?: (entities: TEntity[], context: MutationFunctionContext, onMutateResult: TMutateResult | undefined, error: TError | null) => void | Promise<void>;
|
|
51
|
+
}
|
|
52
|
+
export interface UseBatchMutationHookOptions<TEntityConstructor extends EntityConstructorAny, TError = DefaultError, TMutateResult = unknown, TEntity extends EntityAny = InstanceType<TEntityConstructor>> extends UseMutationHookCommonOptions<void, TError, TEntity[], TMutateResult>, OptimisticMutationStrategyOptions, EntitiesBatchMutationCallbacks<TEntity, TError, TMutateResult> {
|
|
53
|
+
entity: TEntityConstructor;
|
|
54
|
+
mutationFn: BatchMutationFn<TEntity>;
|
|
55
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { MQClientAccessor } from '../client';
|
|
2
|
+
import { EntityConstructorAny, EntityDataAny } from '../entity';
|
|
3
|
+
export declare abstract class QueryBase<TArguments = unknown> extends MQClientAccessor {
|
|
4
|
+
private readonly entityConstructors;
|
|
5
|
+
private readonly baseQueryKeysRest;
|
|
6
|
+
constructor(entityConstructors: EntityConstructorAny[], baseQueryKeysRest: () => unknown[]);
|
|
7
|
+
get baseQueryKey(): unknown[];
|
|
8
|
+
get baseQueryHash(): string;
|
|
9
|
+
protected createQueryKey(args: TArguments): unknown[];
|
|
10
|
+
protected createQueryHash(args: TArguments): string;
|
|
11
|
+
useIsFetching(args: TArguments): number;
|
|
12
|
+
protected setOneEntity(data: EntityDataAny, queryKey: unknown[], entityConstructor: EntityConstructorAny): import('..').EntityAny;
|
|
13
|
+
protected setManyEntities(data: EntityDataAny[], queryKey: unknown[], entityConstructor: EntityConstructorAny): readonly [import('..').EntityAny[], import('..').EntityId[]];
|
|
14
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DefaultError } from '@tanstack/react-query';
|
|
2
|
+
import { EntityConstructorAny } from '../entity';
|
|
3
|
+
import { UseQueryManyOptions } from './types';
|
|
4
|
+
import { QueryManyBase } from './QueryManyBase';
|
|
5
|
+
export declare class QueryFragmentMany<TArguments = void, TEntityConstructor extends EntityConstructorAny = EntityConstructorAny, TError extends DefaultError = DefaultError> extends QueryManyBase<TArguments, void, TEntityConstructor, TError> {
|
|
6
|
+
static readonly queryPrefix = "__query__fragment__many__";
|
|
7
|
+
constructor(options: UseQueryManyOptions<TArguments, void, TEntityConstructor, TError>);
|
|
8
|
+
useQuery(args: TArguments): InstanceType<TEntityConstructor>[];
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DefaultError } from '@tanstack/react-query';
|
|
2
|
+
import { EntityConstructorAny } from '../entity';
|
|
3
|
+
import { UseQueryOneOptions } from './types';
|
|
4
|
+
import { QueryOneBase } from './QueryOneBase';
|
|
5
|
+
export declare class QueryFragmentOne<TArguments = void, TEntityConstructor extends EntityConstructorAny = EntityConstructorAny, TError extends DefaultError = DefaultError> extends QueryOneBase<TArguments, void, TEntityConstructor, TError> {
|
|
6
|
+
static readonly queryPrefix = "__query__fragment__one__";
|
|
7
|
+
constructor(options: UseQueryOneOptions<TArguments, void, TEntityConstructor, TError>);
|
|
8
|
+
useQuery(args: TArguments): InstanceType<TEntityConstructor> | null;
|
|
9
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DefaultError } from '@tanstack/react-query';
|
|
2
|
+
import { EntityConstructorAny } from '../entity';
|
|
3
|
+
import { UseQueryManyOptions } from './types';
|
|
4
|
+
import { QueryManyBase } from './QueryManyBase';
|
|
5
|
+
export declare class QueryMany<TArguments = void, TMeta = void, TEntityConstructor extends EntityConstructorAny = EntityConstructorAny, TError extends DefaultError = DefaultError> extends QueryManyBase<TArguments, TMeta, TEntityConstructor, TError> {
|
|
6
|
+
static readonly queryPrefix = "__query__many__";
|
|
7
|
+
constructor(options: UseQueryManyOptions<TArguments, TMeta, TEntityConstructor, TError>);
|
|
8
|
+
useSuspenseQuery(args: TArguments): InstanceType<TEntityConstructor>[];
|
|
9
|
+
useDeferredQuery(args: TArguments): InstanceType<TEntityConstructor>[];
|
|
10
|
+
useQuery(args: TArguments, meta: TMeta): InstanceType<TEntityConstructor>[];
|
|
11
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { DefaultError } from '@tanstack/react-query';
|
|
2
|
+
import { EntityConstructorAny, EntityCollection, EntityId } from '../entity';
|
|
3
|
+
import { InferEntityData } from '../utils';
|
|
4
|
+
import { QueryBase } from './QueryBase';
|
|
5
|
+
import { UseQueryManyOptions } from './types';
|
|
6
|
+
export declare abstract class QueryManyBase<TArguments, TMeta = void, TEntityConstructor extends EntityConstructorAny = EntityConstructorAny, TError extends DefaultError = DefaultError> extends QueryBase<TArguments> {
|
|
7
|
+
protected readonly options: UseQueryManyOptions<TArguments, TMeta, TEntityConstructor, TError>;
|
|
8
|
+
protected readonly collection: EntityCollection<TEntityConstructor>;
|
|
9
|
+
constructor(queryPrefix: string, options: UseQueryManyOptions<TArguments, TMeta, TEntityConstructor, TError>);
|
|
10
|
+
prefetch(args: TArguments): Promise<void>;
|
|
11
|
+
ensureData(args: TArguments): Promise<EntityId[]>;
|
|
12
|
+
invalidate(args: TArguments): void;
|
|
13
|
+
setQueryData(data: InferEntityData<TEntityConstructor>[], args: TArguments): void;
|
|
14
|
+
/**
|
|
15
|
+
* Returns the current entity ID array stored in the TanStack query cache
|
|
16
|
+
* for the given arguments.
|
|
17
|
+
*/
|
|
18
|
+
getQueryIds(args: TArguments): EntityId[];
|
|
19
|
+
/**
|
|
20
|
+
* Directly sets the entity ID array in the TanStack query cache
|
|
21
|
+
* for the given arguments. Used by relation mutations for optimistic updates.
|
|
22
|
+
*/
|
|
23
|
+
setQueryIds(ids: EntityId[], args: TArguments): void;
|
|
24
|
+
/**
|
|
25
|
+
* Public accessor for the query key. Used by relation mutations
|
|
26
|
+
* to construct invalidation targets.
|
|
27
|
+
*/
|
|
28
|
+
getQueryKey(args: TArguments): unknown[];
|
|
29
|
+
protected getEntities(ids: EntityId[]): InstanceType<TEntityConstructor>[];
|
|
30
|
+
protected queryFnWrapper(args: TArguments): {
|
|
31
|
+
run: () => Promise<EntityId[]>;
|
|
32
|
+
queryKey: unknown[];
|
|
33
|
+
};
|
|
34
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DefaultError } from '@tanstack/react-query';
|
|
2
|
+
import { EntityConstructorAny } from '../entity';
|
|
3
|
+
import { UseQueryOneOptions } from './types';
|
|
4
|
+
import { QueryOneBase } from './QueryOneBase';
|
|
5
|
+
export declare class QueryOne<TArguments = void, TMeta = void, TEntityConstructor extends EntityConstructorAny = EntityConstructorAny, TError extends DefaultError = DefaultError> extends QueryOneBase<TArguments, TMeta, TEntityConstructor, TError> {
|
|
6
|
+
static readonly queryPrefix = "__query__one__";
|
|
7
|
+
constructor(options: UseQueryOneOptions<TArguments, TMeta, TEntityConstructor, TError>);
|
|
8
|
+
useSuspenseQuery(args: TArguments): InstanceType<TEntityConstructor> | null;
|
|
9
|
+
useDeferredQuery(args: TArguments): InstanceType<TEntityConstructor> | null;
|
|
10
|
+
useQuery(args: TArguments, meta: TMeta): InstanceType<TEntityConstructor> | null;
|
|
11
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { EntityConstructorAny, EntityCollection, EntityId } from '../entity';
|
|
2
|
+
import { QueryBase } from './QueryBase';
|
|
3
|
+
import { UseQueryOneOptions } from './types';
|
|
4
|
+
import { InferEntityData } from '../utils';
|
|
5
|
+
import { DefaultError } from '@tanstack/react-query';
|
|
6
|
+
export declare class QueryOneBase<TArguments, TMeta = void, TEntityConstructor extends EntityConstructorAny = EntityConstructorAny, TError extends DefaultError = DefaultError> extends QueryBase<TArguments> {
|
|
7
|
+
protected readonly options: UseQueryOneOptions<TArguments, TMeta, TEntityConstructor, TError>;
|
|
8
|
+
protected readonly collection: EntityCollection<TEntityConstructor>;
|
|
9
|
+
constructor(queryPrefix: string, options: UseQueryOneOptions<TArguments, TMeta, TEntityConstructor, TError>);
|
|
10
|
+
prefetch(args: TArguments): Promise<void>;
|
|
11
|
+
ensureData(args: TArguments): Promise<EntityId>;
|
|
12
|
+
invalidate(args: TArguments): void;
|
|
13
|
+
setQueryData(data: InferEntityData<TEntityConstructor>, args: TArguments): void;
|
|
14
|
+
protected getEntity(id: EntityId): InstanceType<TEntityConstructor> | null;
|
|
15
|
+
protected queryFnWrapper(args: TArguments): {
|
|
16
|
+
run: () => Promise<EntityId>;
|
|
17
|
+
queryKey: unknown[];
|
|
18
|
+
};
|
|
19
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { UseQueryManyFunction, UseQueryOneOptions, UseQueryCommonOptions, UseQueryManyOptions, UseQueryOneFunction } from './types';
|
|
2
|
+
import { QueryBase } from './QueryBase';
|
|
3
|
+
import { QueryFragmentMany } from './QueryFragmentMany';
|
|
4
|
+
import { QueryFragmentOne } from './QueryFragmentOne';
|
|
5
|
+
import { QueryMany } from './QueryMany';
|
|
6
|
+
import { QueryManyBase } from './QueryManyBase';
|
|
7
|
+
import { QueryOne } from './QueryOne';
|
|
8
|
+
import { QueryOneBase } from './QueryOneBase';
|
|
9
|
+
export { QueryBase, QueryFragmentMany, QueryFragmentOne, QueryMany, QueryManyBase, QueryOne, QueryOneBase, };
|
|
10
|
+
export type { UseQueryCommonOptions, UseQueryManyFunction, UseQueryManyOptions, UseQueryOneFunction, UseQueryOneOptions, };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { DefaultError, NetworkMode } from '@tanstack/react-query';
|
|
2
|
+
import { EntityConstructorAny } from '../entity';
|
|
3
|
+
import { MQClientContextRegistered } from '../client/types';
|
|
4
|
+
import { InferEntityData } from '../utils';
|
|
5
|
+
export type UseQueryManyFunction<TArguments, TEntityConstructor extends EntityConstructorAny> = (args: TArguments, context: MQClientContextRegistered) => InferEntityData<TEntityConstructor>[] | Promise<InferEntityData<TEntityConstructor>[]>;
|
|
6
|
+
export type UseQueryOneFunction<TArguments, TEntityConstructor extends EntityConstructorAny> = (args: TArguments, context: MQClientContextRegistered) => InferEntityData<TEntityConstructor> | Promise<InferEntityData<TEntityConstructor>>;
|
|
7
|
+
export interface UseQueryCommonOptions<TArguments, TMeta = void, TEntityConstructor extends EntityConstructorAny = EntityConstructorAny, TError extends DefaultError = DefaultError> {
|
|
8
|
+
entity: TEntityConstructor;
|
|
9
|
+
queryKey: () => ReadonlyArray<unknown>;
|
|
10
|
+
staleTime?: number | "static";
|
|
11
|
+
gcTime?: number;
|
|
12
|
+
enabled?: boolean | ((meta: TMeta, args: TArguments) => boolean);
|
|
13
|
+
networkMode?: NetworkMode;
|
|
14
|
+
retry?: boolean | number | ((failureCount: number, error: TError) => boolean);
|
|
15
|
+
retryOnMount?: boolean;
|
|
16
|
+
retryDelay?: number | ((failureCount: number, error: TError) => number);
|
|
17
|
+
}
|
|
18
|
+
export interface UseQueryOneOptions<TArguments, TMeta = void, TEntityConstructor extends EntityConstructorAny = EntityConstructorAny, TError extends DefaultError = DefaultError> extends UseQueryCommonOptions<TArguments, TMeta, TEntityConstructor, TError> {
|
|
19
|
+
queryFn?: UseQueryOneFunction<TArguments, TEntityConstructor>;
|
|
20
|
+
}
|
|
21
|
+
export interface UseQueryManyOptions<TArguments, TMeta = void, TEntityConstructor extends EntityConstructorAny = EntityConstructorAny, TError extends DefaultError = DefaultError> extends UseQueryCommonOptions<TArguments, TMeta, TEntityConstructor, TError> {
|
|
22
|
+
queryFn?: UseQueryManyFunction<TArguments, TEntityConstructor>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { MQClient } from '../client';
|
|
2
|
+
export declare function createReactContext<TMQClient extends MQClient<any>>(): {
|
|
3
|
+
Provider: ({ children, client, }: {
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
client: TMQClient;
|
|
6
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
useContext: () => TMQClient;
|
|
8
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { generateEntityId } from './generateEntityId';
|
|
2
|
+
import { invalidateQueryByHash } from './invalidateQueryByHash';
|
|
3
|
+
import { InferEntity, InferEntityData } from './types';
|
|
4
|
+
export { invalidateQueryByHash, generateEntityId };
|
|
5
|
+
export type { InferEntity, InferEntityData };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { EntityAny, EntityDataAny } from '../entity';
|
|
2
|
+
export type InferEntity<T> = T extends {
|
|
3
|
+
new (...args: any[]): infer E;
|
|
4
|
+
} ? E extends EntityAny ? E : never : T extends EntityAny ? T : never;
|
|
5
|
+
export type InferEntityData<T> = InferEntity<T> extends {
|
|
6
|
+
hydrate(data: infer TData): void;
|
|
7
|
+
} ? TData : T extends EntityDataAny ? T : never;
|
package/package.json
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mobx-query/core",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "smashboy",
|
|
6
6
|
"private": false,
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist"
|
|
12
|
+
],
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"main": "./dist/core.js",
|
|
10
15
|
"scripts": {
|
|
11
16
|
"dev": "vite",
|
|
12
17
|
"build": "tsc -b && vite build",
|
package/.gitattributes
DELETED
package/eslint.config.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import js from "@eslint/js";
|
|
2
|
-
import globals from "globals";
|
|
3
|
-
import reactHooks from "eslint-plugin-react-hooks";
|
|
4
|
-
import reactRefresh from "eslint-plugin-react-refresh";
|
|
5
|
-
import tseslint from "typescript-eslint";
|
|
6
|
-
import { globalIgnores } from "eslint/config";
|
|
7
|
-
|
|
8
|
-
export default tseslint.config([
|
|
9
|
-
globalIgnores(["dist"]),
|
|
10
|
-
{
|
|
11
|
-
files: ["**/*.{ts,tsx}"],
|
|
12
|
-
extends: [
|
|
13
|
-
js.configs.recommended,
|
|
14
|
-
tseslint.configs.recommended,
|
|
15
|
-
reactHooks.configs["recommended-latest"],
|
|
16
|
-
reactRefresh.configs.vite,
|
|
17
|
-
],
|
|
18
|
-
languageOptions: {
|
|
19
|
-
ecmaVersion: 2020,
|
|
20
|
-
globals: globals.browser,
|
|
21
|
-
},
|
|
22
|
-
rules: {
|
|
23
|
-
"@typescript-eslint/no-explicit-any": "off",
|
|
24
|
-
"@typescript-eslint/no-unsafe-function-type": "off",
|
|
25
|
-
"react-hooks/rules-of-hooks": "off",
|
|
26
|
-
"@typescript-eslint/no-empty-object-type": "off",
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
]);
|
package/index.html
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
-
<title>Vite + React + TS</title>
|
|
8
|
-
</head>
|
|
9
|
-
<body>
|
|
10
|
-
<div id="root"></div>
|
|
11
|
-
<script type="module" src="/src/main.tsx"></script>
|
|
12
|
-
</body>
|
|
13
|
-
</html>
|
package/src/App.css
DELETED
|
File without changes
|
package/src/App.tsx
DELETED
package/src/api/constants.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const API_URL = "https://jsonplaceholder.typicode.com";
|