@astral/mobx-query 0.1.0 → 0.1.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/MobxQuery/MobxQuery.d.ts +4 -4
- package/MobxQuery/MobxQuery.js +2 -2
- package/{MutationQuery/MutationQuery.d.ts → Mutation/Mutation.d.ts} +3 -3
- package/{MutationQuery/MutationQuery.js → Mutation/Mutation.js} +1 -1
- package/Mutation/index.d.ts +1 -0
- package/Mutation/index.js +1 -0
- package/index.d.ts +4 -1
- package/index.js +4 -1
- package/package.json +1 -1
- package/MutationQuery/index.d.ts +0 -1
- package/MutationQuery/index.js +0 -1
package/MobxQuery/MobxQuery.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Query, QueryExecutor, QueryParams } from '../Query';
|
|
2
2
|
import { InfiniteExecutor, InfiniteQuery, InfiniteQueryParams } from '../InfiniteQuery';
|
|
3
|
-
import {
|
|
3
|
+
import { Mutation, MutationExecutor, MutationParams } from '../Mutation';
|
|
4
4
|
import { CacheKey, FetchPolicy } from '../types';
|
|
5
5
|
/**
|
|
6
6
|
* @description стандартный обработчик ошибки запроса,
|
|
@@ -16,7 +16,7 @@ type MobxQueryParams = {
|
|
|
16
16
|
*/
|
|
17
17
|
enabledAutoFetch?: boolean;
|
|
18
18
|
};
|
|
19
|
-
type
|
|
19
|
+
type CreateQueryParams<TResult, TError> = Omit<QueryParams<TResult, TError>, 'dataStorage'>;
|
|
20
20
|
type CreateInfiniteQueryParams<TResult, TError> = Omit<InfiniteQueryParams<TResult, TError>, 'dataStorage'>;
|
|
21
21
|
/**
|
|
22
22
|
* @description Сервис, позволяющий кэшировать данные.
|
|
@@ -66,7 +66,7 @@ export declare class MobxQuery {
|
|
|
66
66
|
/**
|
|
67
67
|
* @description метод создания стора, кешируется
|
|
68
68
|
*/
|
|
69
|
-
createQuery: <TResult, TError>(key: CacheKey[], executor: QueryExecutor<TResult>, params?:
|
|
69
|
+
createQuery: <TResult, TError>(key: CacheKey[], executor: QueryExecutor<TResult>, params?: CreateQueryParams<TResult, TError> | undefined) => Query<TResult, TError>;
|
|
70
70
|
/**
|
|
71
71
|
* @description метод создания инфинит стора, кешируется
|
|
72
72
|
*/
|
|
@@ -74,6 +74,6 @@ export declare class MobxQuery {
|
|
|
74
74
|
/**
|
|
75
75
|
* @description метод создания мутации, не кешируется
|
|
76
76
|
*/
|
|
77
|
-
|
|
77
|
+
createMutation: <TResult, TError, TExecutorParams>(executor: MutationExecutor<TResult, TExecutorParams>, params?: MutationParams<TResult, TError> | undefined) => Mutation<TResult, TError, TExecutorParams>;
|
|
78
78
|
}
|
|
79
79
|
export {};
|
package/MobxQuery/MobxQuery.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Query } from '../Query';
|
|
2
2
|
import { InfiniteQuery, } from '../InfiniteQuery';
|
|
3
|
-
import {
|
|
3
|
+
import { Mutation } from '../Mutation';
|
|
4
4
|
import { DataStorageFactory } from '../DataStorage';
|
|
5
5
|
/**
|
|
6
6
|
* @description Сервис, позволяющий кэшировать данные.
|
|
@@ -77,7 +77,7 @@ export class MobxQuery {
|
|
|
77
77
|
/**
|
|
78
78
|
* @description метод создания мутации, не кешируется
|
|
79
79
|
*/
|
|
80
|
-
this.
|
|
80
|
+
this.createMutation = (executor, params) => new Mutation(executor, Object.assign(Object.assign({}, params), { onError: (params === null || params === void 0 ? void 0 : params.onError) || this.defaultErrorHandler }));
|
|
81
81
|
this.defaultErrorHandler = onError;
|
|
82
82
|
this.defaultFetchPolicy = fetchPolicy;
|
|
83
83
|
this.defaultEnabledAutoFetch = enabledAutoFetch;
|
|
@@ -3,7 +3,7 @@ import { QueryBaseActions, Sync, SyncParams } from '../types';
|
|
|
3
3
|
* @description исполнитель запроса
|
|
4
4
|
*/
|
|
5
5
|
export type MutationExecutor<TResult, TParams> = (params: TParams) => Promise<TResult>;
|
|
6
|
-
export type
|
|
6
|
+
export type MutationParams<TResult, TError> = {
|
|
7
7
|
/**
|
|
8
8
|
* @description обработчик ошибки, вызываемый по умолчанию
|
|
9
9
|
*/
|
|
@@ -13,7 +13,7 @@ export type MutationQueryParams<TResult, TError> = {
|
|
|
13
13
|
* @description простой стор для запросов, которые не требуют кэширования,
|
|
14
14
|
* пример - POST запросы
|
|
15
15
|
*/
|
|
16
|
-
export declare class
|
|
16
|
+
export declare class Mutation<TResult, TError = void, TExecutorParams = void> implements QueryBaseActions<TResult, TError, TExecutorParams> {
|
|
17
17
|
/**
|
|
18
18
|
* @description инстанс вспомогательного стора
|
|
19
19
|
*/
|
|
@@ -27,7 +27,7 @@ export declare class MutationQuery<TResult, TError = void, TExecutorParams = voi
|
|
|
27
27
|
* @description обработчик ошибки, вызываемый по умолчанию
|
|
28
28
|
*/
|
|
29
29
|
private defaultOnError?;
|
|
30
|
-
constructor(executor: MutationExecutor<TResult, TExecutorParams>, { onError }?:
|
|
30
|
+
constructor(executor: MutationExecutor<TResult, TExecutorParams>, { onError }?: MutationParams<TResult, TError>);
|
|
31
31
|
/**
|
|
32
32
|
* @description синхронный метод получения/отправки данных
|
|
33
33
|
*/
|
|
@@ -4,7 +4,7 @@ import { AuxiliaryQuery } from '../AuxiliaryQuery';
|
|
|
4
4
|
* @description простой стор для запросов, которые не требуют кэширования,
|
|
5
5
|
* пример - POST запросы
|
|
6
6
|
*/
|
|
7
|
-
export class
|
|
7
|
+
export class Mutation {
|
|
8
8
|
constructor(executor, { onError } = {}) {
|
|
9
9
|
/**
|
|
10
10
|
* @description инстанс вспомогательного стора
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Mutation';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Mutation';
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
package/package.json
CHANGED
package/MutationQuery/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './MutationQuery';
|
package/MutationQuery/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './MutationQuery';
|