@astral/mobx-query 1.10.1 → 1.10.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.
@@ -76,6 +76,7 @@ export class AuxiliaryQuery {
76
76
  */
77
77
  this.submitError = (error) => {
78
78
  this.checkBackgroundAndSet((storage) => this.setError(storage, error));
79
+ this.isInvalid = false;
79
80
  };
80
81
  this.setLoading = (storage) => {
81
82
  storage.isLoading = true;
@@ -16,6 +16,7 @@ export declare class DataStorage<TData> {
16
16
  * Метод для установки данных
17
17
  */
18
18
  setData: (value: TData) => void;
19
+ cleanData: () => void;
19
20
  /**
20
21
  * Геттер данных
21
22
  */
@@ -15,6 +15,9 @@ export class DataStorage {
15
15
  this.setData = (value) => {
16
16
  this.internalData = value;
17
17
  };
18
+ this.cleanData = () => {
19
+ this.internalData = undefined;
20
+ };
18
21
  makeAutoObservable(this);
19
22
  }
20
23
  /**
@@ -92,6 +92,9 @@ export class InfiniteQuery extends QueryContainer {
92
92
  })
93
93
  .catch((e) => {
94
94
  var _a;
95
+ if (!this.background) {
96
+ this.storage.cleanData();
97
+ }
95
98
  if (onError) {
96
99
  onError(e);
97
100
  }
@@ -163,8 +163,8 @@ export declare class MobxQuery<TDefaultError = void> {
163
163
  * Создает набор мутаций для единого интерфейса с query sets
164
164
  * @param executor - Функция-исполнитель мутации. Она должна возвращать промис с результатом выполнения мутации.
165
165
  * @example
166
- * const editDocMutationSet = mobxQuery.createMutationSet((params: DocsEndpointsDTO.EditDocInput) => {
167
- * return docsEndpoint.editDoc(params);
166
+ * const editDocMutationSet = mobxQuery.createMutationSet((params: DocsDTO.EditDocInput) => {
167
+ * return docsEndpoints.editDoc(params);
168
168
  * });
169
169
  *
170
170
  * const editDocMutation = editDocMutationSet.create();
@@ -205,8 +205,8 @@ export class MobxQuery {
205
205
  * Создает набор мутаций для единого интерфейса с query sets
206
206
  * @param executor - Функция-исполнитель мутации. Она должна возвращать промис с результатом выполнения мутации.
207
207
  * @example
208
- * const editDocMutationSet = mobxQuery.createMutationSet((params: DocsEndpointsDTO.EditDocInput) => {
209
- * return docsEndpoint.editDoc(params);
208
+ * const editDocMutationSet = mobxQuery.createMutationSet((params: DocsDTO.EditDocInput) => {
209
+ * return docsEndpoints.editDoc(params);
210
210
  * });
211
211
  *
212
212
  * const editDocMutation = editDocMutationSet.create();
package/Query/Query.js CHANGED
@@ -53,6 +53,9 @@ export class Query extends QueryContainer {
53
53
  })
54
54
  .catch((e) => {
55
55
  var _a;
56
+ if (!this.background) {
57
+ this.storage.cleanData();
58
+ }
56
59
  if (onError) {
57
60
  onError(e);
58
61
  }
package/README.md CHANGED
@@ -86,12 +86,12 @@ export const cacheService = createCacheService();
86
86
  const docsFetcher = {
87
87
  queries: {
88
88
  doc: cacheService.createQuerySet((id: string) => ({
89
- execute: () => docsEndpoint.getDoc(id).then(({ data }) => data),
89
+ execute: () => docsEndpoints.getDoc(id).then(({ data }) => data),
90
90
  })),
91
91
  },
92
92
  infiniteQueries: {
93
93
  docList: cacheService.createInfiniteQuerySet(
94
- (filters: Omit<DocsEndpointsDTO.DocListFilters, 'offset' | 'count'>) => ({
94
+ (filters: Omit<DocsDTO.DocListFilters, 'offset' | 'count'>) => ({
95
95
  execute: ({ offset, count }) =>
96
96
  docsEndpoint
97
97
  .getDocList({ offset, count, ...filters })
@@ -101,7 +101,7 @@ const docsFetcher = {
101
101
  },
102
102
  mutations: {
103
103
  editDoc: cacheService.createMutationSet(
104
- (params: DocsEndpointsDTO.EditDocInput) => docsEndpoint.editDoc(params),
104
+ (params: DocsDTO.EditDocInput) => docsEndpoints.editDoc(params),
105
105
  ),
106
106
  },
107
107
  };
@@ -186,7 +186,7 @@ class DocManagerStore {
186
186
  const docsFetcher = {
187
187
  queries: {
188
188
  doc: mobxQuery.createQuerySet((id: string) => ({
189
- execute: () => docsEndpoint.getDoc(id).then(({ data }) => data),
189
+ execute: () => docsEndpoints.getDoc(id).then(({ data }) => data),
190
190
  })),
191
191
  },
192
192
  };
@@ -200,7 +200,7 @@ const docsFetcher = {
200
200
  const docsFetcher = {
201
201
  queries: {
202
202
  doc: mobxQuery.createQuerySet((id: string) => ({
203
- execute: () => docsEndpoint.getDoc(id).then(({ data }) => data),
203
+ execute: () => docsEndpoints.getDoc(id).then(({ data }) => data),
204
204
  })),
205
205
  },
206
206
  };
@@ -281,7 +281,7 @@ docQuery.isLoading; // true
281
281
  const docsFetcher = {
282
282
  infiniteQueries: {
283
283
  docList: mobxQuery.createInfiniteQuerySet(
284
- (filters: Omit<DocsEndpointsDTO.DocListFilters, 'offset' | 'count'>) => ({
284
+ (filters: Omit<DocsDTO.DocListFilters, 'offset' | 'count'>) => ({
285
285
  execute: ({ offset, count }) =>
286
286
  docsEndpoint
287
287
  .getDocList({ offset, count, ...filters })
@@ -301,7 +301,7 @@ const docsFetcher = {
301
301
  infiniteQueries: {
302
302
  docList: mobxQuery.createInfiniteQuerySet(
303
303
  // Omit необходим для того, чтобы не передавать offset и count при вызове запроса из логики. Offset и count будут сформированы и переданы автоматически
304
- (filters: Omit<DocsEndpointsDTO.DocListFilters, 'offset' | 'count'>) => ({
304
+ (filters: Omit<DocsDTO.DocListFilters, 'offset' | 'count'>) => ({
305
305
  execute: ({ offset, count }) =>
306
306
  docsEndpoint
307
307
  .getDocList({ offset, count, ...filters })
@@ -312,7 +312,7 @@ const docsFetcher = {
312
312
  },
313
313
  };
314
314
 
315
- // первым параметром create является - filters: Omit<DocsEndpointsDTO.DocListFilters, 'offset' | 'count'>
315
+ // первым параметром create является - filters: Omit<DocsDTO.DocListFilters, 'offset' | 'count'>
316
316
  const docListQuery = docsFetcher.infiniteQueries.docList.create({ search: 'test' });
317
317
  ```
318
318
 
@@ -382,13 +382,13 @@ const docListQuery = docsFetcher.infiniteQueries.docList.createWithConfig(
382
382
  ```ts
383
383
  const docsFetcher = {
384
384
  mutations: {
385
- editDoc: mobxQuery.createMutationSet((params: DocsEndpointsDTO.EditDocInput) => docsEndpoint.editDoc(params)),
385
+ editDoc: mobxQuery.createMutationSet((params: DocsDTO.EditDocInput) => docsEndpoints.editDoc(params)),
386
386
  },
387
387
  };
388
388
 
389
389
  const editDocMutation = docsFetcher.mutations.editDoc.create();
390
390
 
391
- // params являются параметрами, указанными при определении mutation - DocsEndpointsDTO.EditDocInput
391
+ // params являются параметрами, указанными при определении mutation - DocsDTO.EditDocInput
392
392
  await editDocMutation.async({ params: { id: 'docID', name: 'test' } });
393
393
  ```
394
394
 
@@ -498,7 +498,7 @@ await docQueryWithCache.async(); // запрос не будет выполне
498
498
  const docFetcher = {
499
499
  queries: {
500
500
  doc: mobxQuery.createQuerySet((id: string, filters: { search: string }) => ({
501
- execute: () => docsEndpoint.getDoc(id, filters),
501
+ execute: () => docsEndpoints.getDoc(id, filters),
502
502
  })),
503
503
  },
504
504
  };
@@ -552,7 +552,7 @@ docsFetcher.queries.doc.invalidate(); // данные docQuery1 и docQuery2 п
552
552
  const docsFetcher = {
553
553
  queries: {
554
554
  doc: mobxQuery.createQuerySet((id: string) => ({
555
- execute: () => docsEndpoint.getDoc(id).then(({ data }) => data),
555
+ execute: () => docsEndpoints.getDoc(id).then(({ data }) => data),
556
556
  })),
557
557
  },
558
558
  };
@@ -566,7 +566,7 @@ docsFetcher.queries.doc.invalidate('1'); // документ с id = 1 буде
566
566
  const docsFetcher = {
567
567
  queries: {
568
568
  doc: mobxQuery.createQuerySet((id: string, search: string, filters: Filters) => ({
569
- execute: () => docsEndpoint.getDoc(id, search, filters),
569
+ execute: () => docsEndpoints.getDoc(id, search, filters),
570
570
  })),
571
571
  },
572
572
  };
@@ -580,7 +580,7 @@ docsFetcher.queries.doc.invalidate('1', 'test', { sort: 'asc' });
580
580
  const docsFetcher = {
581
581
  queries: {
582
582
  doc: mobxQuery.createQuerySet((id: string, filters: { sort: string; search: string }) => ({
583
- execute: () => docsEndpoint.getDoc(id, filters),
583
+ execute: () => docsEndpoints.getDoc(id, filters),
584
584
  })),
585
585
  },
586
586
  };
@@ -603,7 +603,7 @@ const docsFetcher = {
603
603
  doc: mobxQuery.createQuerySet(
604
604
  (id: string, search: string) => ({
605
605
  keys: [id],
606
- execute: () => docsEndpoint.getDoc(id, search),
606
+ execute: () => docsEndpoints.getDoc(id, search),
607
607
  }),
608
608
  { name: 'doc' }
609
609
  ),
@@ -655,7 +655,7 @@ docQuery.forceUpdate({ name: 'test' });
655
655
  type Fetcher = {
656
656
  queries: Record<string, QuerySet<any[], any>>;
657
657
  infiniteQueries: Record<InfiniteQuerySet<any[], any>>;
658
- mutations: Record<MutationSet<any[], any>>;
658
+ mutations: Record<MutationSet<any, any>>;
659
659
  };
660
660
 
661
661
  const mockFetcher = <TFetcher extends Fetcher>(config: DeepPartial<TFetcher>) => config as TFetcher;
@@ -677,7 +677,7 @@ const createMobxQuery = () => new MobxQuery({
677
677
  ```ts
678
678
  export const booksFetcher = {
679
679
  queries: {
680
- bookList: mobxQuery.createQuerySet((params: BooksEndpointsDTO.BookListInput) => ({
680
+ bookList: mobxQuery.createQuerySet((params: BooksDTO.BookListInput) => ({
681
681
  execute: () => booksEndpoint.getBookList(params),
682
682
  })),
683
683
  },
@@ -765,7 +765,7 @@ describe('BooksListStore', () => {
765
765
  const createDocQuery = (id: string) =>
766
766
  // первый параметр - ключи, по которому в кэше будет храниться ответ запроса
767
767
  cacheService.createQuery(['doc', id],
768
- (params: { id: string }) => docsEndpoint.getDoc(params.id)
768
+ (params: { id: string }) => docsEndpoints.getDoc(params.id)
769
769
  );
770
770
  ```
771
771
 
@@ -775,7 +775,7 @@ const createDocQuery = (id: string) =>
775
775
  const createDocQuery = (id: string) =>
776
776
  // первый параметр - ключи, по которому в кэше будет храниться ответ запроса
777
777
  cacheService.createQuery(['doc', id],
778
- (params: { id: string }) => docsEndpoint.getDoc(params.id)
778
+ (params: { id: string }) => docsEndpoints.getDoc(params.id)
779
779
  );
780
780
 
781
781
  const docQuery = createDocQuery('docID');
@@ -866,7 +866,7 @@ export type Query<TResult = unknown, TError = unknown, TIsBackground = boolean>
866
866
  const createDocQuery = (id: string) =>
867
867
  // первый параметр - ключи, по которому в кэше будет храниться ответ запроса
868
868
  cacheService.createQuery(['doc', id],
869
- (params: { id: string }) => docsEndpoint.getDoc(params.id)
869
+ (params: { id: string }) => docsEndpoints.getDoc(params.id)
870
870
  );
871
871
 
872
872
  const docQuery = createDocQuery('docID');
@@ -892,7 +892,7 @@ docQuery.isLoading;
892
892
  const createDocQuery = (id: string) =>
893
893
  // первый параметр - ключи, по которому в кэше будет храниться ответ запроса
894
894
  cacheService.createQuery(['doc', id],
895
- (params: { id: string }) => docsEndpoint.getDoc(params.id)
895
+ (params: { id: string }) => docsEndpoints.getDoc(params.id)
896
896
  );
897
897
 
898
898
  const docQuery = createDocQuery('docID');
@@ -913,7 +913,7 @@ const cacheService = new MobxQuery({ enableAutoFetch: true });
913
913
  const createDocQuery = (id: string) =>
914
914
  // первый параметр - ключи, по которому в кэше будет храниться ответ запроса
915
915
  cacheService.createQuery(['doc', id],
916
- (params: { id: string }) => docsEndpoint.getDoc(params.id)
916
+ (params: { id: string }) => docsEndpoints.getDoc(params.id)
917
917
  );
918
918
 
919
919
  docQuery.data; // триггер запроса данных
@@ -925,7 +925,7 @@ docQuery.isLoading; // true
925
925
  ```ts
926
926
  const createDocQuery = (id: string) =>
927
927
  cacheService.createQuery(['doc', id],
928
- (params: { id: string }) => docsEndpoint.getDoc(params.id),
928
+ (params: { id: string }) => docsEndpoints.getDoc(params.id),
929
929
  { enableAutoFetch: true }
930
930
  );
931
931
 
@@ -943,21 +943,21 @@ docQuery.isLoading; // true
943
943
  В примере ниже будет создан docList InfiniteQuery. После успешного выполнения запроса данные будут закэшированы.
944
944
 
945
945
  ```ts
946
- const createDocListInfiniteQuery = (filters: Omit<DocsEndpointsDTO.DocListFilters, 'offset' | 'count'>) =>
946
+ const createDocListInfiniteQuery = (filters: Omit<DocsDTO.DocListFilters, 'offset' | 'count'>) =>
947
947
  cacheService.createInfiniteQuery(['docList', filters],
948
- (params: { offset: number; count: number }) => docsEndpoint.getDocList({ offset: params.offset, count: params.count, ...filters })
948
+ (params: { offset: number; count: number }) => docsEndpoints.getDocList({ offset: params.offset, count: params.count, ...filters })
949
949
  );
950
950
  ```
951
951
 
952
952
  #### Использование InfiniteQuery
953
953
 
954
954
  ```ts
955
- const createDocListInfiniteQuery = (filters: Omit<DocsEndpointsDTO.DocListFilters, 'offset' | 'count'>) =>
955
+ const createDocListInfiniteQuery = (filters: Omit<DocsDTO.DocListFilters, 'offset' | 'count'>) =>
956
956
  cacheService.createInfiniteQuery(['docList', filters],
957
- (params: { offset: number; count: number }) => docsEndpoint.getDocList({ offset: params.offset, count: params.count, ...filters })
957
+ (params: { offset: number; count: number }) => docsEndpoints.getDocList({ offset: params.offset, count: params.count, ...filters })
958
958
  );
959
959
 
960
- // первым параметром create является - filters: Omit<DocsEndpointsDTO.DocListFilters, 'offset' | 'count'>
960
+ // первым параметром create является - filters: Omit<DocsDTO.DocListFilters, 'offset' | 'count'>
961
961
  const docListQuery = createDocListInfiniteQuery({ search: 'test' });
962
962
  ```
963
963
 
@@ -966,9 +966,9 @@ const docListQuery = createDocListInfiniteQuery({ search: 'test' });
966
966
  ```ts
967
967
  import { when } from 'mobx';
968
968
 
969
- const createDocListInfiniteQuery = (filters: Omit<DocsEndpointsDTO.DocListFilters, 'offset' | 'count'>) =>
969
+ const createDocListInfiniteQuery = (filters: Omit<DocsDTO.DocListFilters, 'offset' | 'count'>) =>
970
970
  cacheService.createInfiniteQuery(['docList', filters],
971
- (params: { offset: number; count: number }) => docsEndpoint.getDocList({ offset: params.offset, count: params.count, ...filters })
971
+ (params: { offset: number; count: number }) => docsEndpoints.getDocList({ offset: params.offset, count: params.count, ...filters })
972
972
  );
973
973
 
974
974
  const docListQuery = createDocListInfiniteQuery({ search: 'test' });
@@ -991,9 +991,9 @@ docListQuery.data.length; // 60 записей
991
991
  ```ts
992
992
  import { when } from 'mobx';
993
993
 
994
- const createDocListInfiniteQuery = (filters: Omit<DocsEndpointsDTO.DocListFilters, 'offset' | 'count'>) =>
994
+ const createDocListInfiniteQuery = (filters: Omit<DocsDTO.DocListFilters, 'offset' | 'count'>) =>
995
995
  cacheService.createInfiniteQuery(['docList', filters],
996
- (params: { offset: number; count: number }) => docsEndpoint.getDocList({ offset: params.offset, count: params.count, ...filters })
996
+ (params: { offset: number; count: number }) => docsEndpoints.getDocList({ offset: params.offset, count: params.count, ...filters })
997
997
  );
998
998
 
999
999
  const docListQuery = createDocListInfiniteQuery({ search: 'test' });
@@ -1018,9 +1018,9 @@ docListQuery.isEndReached; // true
1018
1018
 
1019
1019
  Для изменения конфигурации InfiniteQuery необходимо использовать третий параметр `config`:
1020
1020
  ```ts
1021
- const createDocListInfiniteQuery = (filters: Omit<DocsEndpointsDTO.DocListFilters, 'offset' | 'count'>) =>
1021
+ const createDocListInfiniteQuery = (filters: Omit<DocsDTO.DocListFilters, 'offset' | 'count'>) =>
1022
1022
  cacheService.createInfiniteQuery(['docList', filters],
1023
- (params: { offset: number; count: number }) => docsEndpoint.getDocList({ offset: params.offset, count: params.count, ...filters }),
1023
+ (params: { offset: number; count: number }) => docsEndpoints.getDocList({ offset: params.offset, count: params.count, ...filters }),
1024
1024
  { incrementCount: 10 }
1025
1025
  );
1026
1026
  ```
@@ -1061,12 +1061,12 @@ export type InfiniteQueryConfig = {
1061
1061
 
1062
1062
  В примере ниже будет создан `editDoc` mutation, который отправляет данные на сервер для редактирования документа:
1063
1063
  ```ts
1064
- const createEditDocMutation = (params: DocsEndpointsDTO.EditDocInput) =>
1065
- cacheService.createMutation((params: DocsEndpointsDTO.EditDocInput) => docsEndpoint.editDoc(params));
1064
+ const createEditDocMutation = (params: DocsDTO.EditDocInput) =>
1065
+ cacheService.createMutation((params: DocsDTO.EditDocInput) => docsEndpoints.editDoc(params));
1066
1066
 
1067
1067
  const editDocMutation = createEditDocMutation();
1068
1068
 
1069
- // params являются параметрами, указанными при определении mutation - DocsEndpointsDTO.EditDocInput
1069
+ // params являются параметрами, указанными при определении mutation - DocsDTO.EditDocInput
1070
1070
  await editDocMutation.async({ params: { id: 'docID', name: 'test' } });
1071
1071
  ```
1072
1072
 
@@ -1142,8 +1142,8 @@ type Mutation<TResult, TError = unknown, TExecutorParams = void> = {
1142
1142
 
1143
1143
  Метод `sync` позволяет синхронно запустить запрос:
1144
1144
  ```ts
1145
- const createEditDocMutation = (params: DocsEndpointsDTO.EditDocInput) =>
1146
- cacheService.createMutation((params: DocsEndpointsDTO.EditDocInput) => docsEndpoint.editDoc(params));
1145
+ const createEditDocMutation = (params: DocsDTO.EditDocInput) =>
1146
+ cacheService.createMutation((params: DocsDTO.EditDocInput) => docsEndpoints.editDoc(params));
1147
1147
 
1148
1148
  const editDocMutation = createEditDocMutation();
1149
1149
 
@@ -1166,8 +1166,8 @@ editDocMutation.isLoading;
1166
1166
 
1167
1167
  Метод `async` позволяет асинхронно запустить запрос:
1168
1168
  ```ts
1169
- const createEditDocMutation = (params: DocsEndpointsDTO.EditDocInput) =>
1170
- cacheService.createMutation((params: DocsEndpointsDTO.EditDocInput) => docsEndpoint.editDoc(params));
1169
+ const createEditDocMutation = (params: DocsDTO.EditDocInput) =>
1170
+ cacheService.createMutation((params: DocsDTO.EditDocInput) => docsEndpoints.editDoc(params));
1171
1171
 
1172
1172
  const editDocMutation = createEditDocMutation();
1173
1173
 
@@ -5,13 +5,13 @@ import { type Mutation, type MutationExecutor } from '../../Mutation';
5
5
  * @example
6
6
  * const docFetcher = {
7
7
  * mutations: {
8
- * editDoc: mobxQuery.createMutationSet((params: DocsEndpointsDTO.EditDocInput) => {
9
- * return docsEndpoint.editDoc(params);
8
+ * editDoc: mobxQuery.createMutationSet((params: DocsDTO.EditDocInput) => {
9
+ * return docsEndpoints.editDoc(params);
10
10
  * }),
11
11
  * },
12
12
  * queries: {
13
13
  * doc: mobxQuery.createQuerySet((id: string) => ({
14
- * execute: () => docsEndpoint.getDoc(id).then(({ data }) => data),
14
+ * execute: () => docsEndpoints.getDoc(id).then(({ data }) => data),
15
15
  * })),
16
16
  * },
17
17
  * }
@@ -3,13 +3,13 @@
3
3
  * @example
4
4
  * const docFetcher = {
5
5
  * mutations: {
6
- * editDoc: mobxQuery.createMutationSet((params: DocsEndpointsDTO.EditDocInput) => {
7
- * return docsEndpoint.editDoc(params);
6
+ * editDoc: mobxQuery.createMutationSet((params: DocsDTO.EditDocInput) => {
7
+ * return docsEndpoints.editDoc(params);
8
8
  * }),
9
9
  * },
10
10
  * queries: {
11
11
  * doc: mobxQuery.createQuerySet((id: string) => ({
12
- * execute: () => docsEndpoint.getDoc(id).then(({ data }) => data),
12
+ * execute: () => docsEndpoints.getDoc(id).then(({ data }) => data),
13
13
  * })),
14
14
  * },
15
15
  * }
@@ -79,6 +79,7 @@ class AuxiliaryQuery {
79
79
  */
80
80
  this.submitError = (error) => {
81
81
  this.checkBackgroundAndSet((storage) => this.setError(storage, error));
82
+ this.isInvalid = false;
82
83
  };
83
84
  this.setLoading = (storage) => {
84
85
  storage.isLoading = true;
@@ -16,6 +16,7 @@ export declare class DataStorage<TData> {
16
16
  * Метод для установки данных
17
17
  */
18
18
  setData: (value: TData) => void;
19
+ cleanData: () => void;
19
20
  /**
20
21
  * Геттер данных
21
22
  */
@@ -18,6 +18,9 @@ class DataStorage {
18
18
  this.setData = (value) => {
19
19
  this.internalData = value;
20
20
  };
21
+ this.cleanData = () => {
22
+ this.internalData = undefined;
23
+ };
21
24
  (0, mobx_1.makeAutoObservable)(this);
22
25
  }
23
26
  /**
@@ -95,6 +95,9 @@ class InfiniteQuery extends QueryContainer_1.QueryContainer {
95
95
  })
96
96
  .catch((e) => {
97
97
  var _a;
98
+ if (!this.background) {
99
+ this.storage.cleanData();
100
+ }
98
101
  if (onError) {
99
102
  onError(e);
100
103
  }
@@ -163,8 +163,8 @@ export declare class MobxQuery<TDefaultError = void> {
163
163
  * Создает набор мутаций для единого интерфейса с query sets
164
164
  * @param executor - Функция-исполнитель мутации. Она должна возвращать промис с результатом выполнения мутации.
165
165
  * @example
166
- * const editDocMutationSet = mobxQuery.createMutationSet((params: DocsEndpointsDTO.EditDocInput) => {
167
- * return docsEndpoint.editDoc(params);
166
+ * const editDocMutationSet = mobxQuery.createMutationSet((params: DocsDTO.EditDocInput) => {
167
+ * return docsEndpoints.editDoc(params);
168
168
  * });
169
169
  *
170
170
  * const editDocMutation = editDocMutationSet.create();
@@ -208,8 +208,8 @@ class MobxQuery {
208
208
  * Создает набор мутаций для единого интерфейса с query sets
209
209
  * @param executor - Функция-исполнитель мутации. Она должна возвращать промис с результатом выполнения мутации.
210
210
  * @example
211
- * const editDocMutationSet = mobxQuery.createMutationSet((params: DocsEndpointsDTO.EditDocInput) => {
212
- * return docsEndpoint.editDoc(params);
211
+ * const editDocMutationSet = mobxQuery.createMutationSet((params: DocsDTO.EditDocInput) => {
212
+ * return docsEndpoints.editDoc(params);
213
213
  * });
214
214
  *
215
215
  * const editDocMutation = editDocMutationSet.create();
@@ -56,6 +56,9 @@ class Query extends QueryContainer_1.QueryContainer {
56
56
  })
57
57
  .catch((e) => {
58
58
  var _a;
59
+ if (!this.background) {
60
+ this.storage.cleanData();
61
+ }
59
62
  if (onError) {
60
63
  onError(e);
61
64
  }
@@ -5,13 +5,13 @@ import { type Mutation, type MutationExecutor } from '../../Mutation';
5
5
  * @example
6
6
  * const docFetcher = {
7
7
  * mutations: {
8
- * editDoc: mobxQuery.createMutationSet((params: DocsEndpointsDTO.EditDocInput) => {
9
- * return docsEndpoint.editDoc(params);
8
+ * editDoc: mobxQuery.createMutationSet((params: DocsDTO.EditDocInput) => {
9
+ * return docsEndpoints.editDoc(params);
10
10
  * }),
11
11
  * },
12
12
  * queries: {
13
13
  * doc: mobxQuery.createQuerySet((id: string) => ({
14
- * execute: () => docsEndpoint.getDoc(id).then(({ data }) => data),
14
+ * execute: () => docsEndpoints.getDoc(id).then(({ data }) => data),
15
15
  * })),
16
16
  * },
17
17
  * }
@@ -6,13 +6,13 @@ exports.MutationSet = void 0;
6
6
  * @example
7
7
  * const docFetcher = {
8
8
  * mutations: {
9
- * editDoc: mobxQuery.createMutationSet((params: DocsEndpointsDTO.EditDocInput) => {
10
- * return docsEndpoint.editDoc(params);
9
+ * editDoc: mobxQuery.createMutationSet((params: DocsDTO.EditDocInput) => {
10
+ * return docsEndpoints.editDoc(params);
11
11
  * }),
12
12
  * },
13
13
  * queries: {
14
14
  * doc: mobxQuery.createQuerySet((id: string) => ({
15
- * execute: () => docsEndpoint.getDoc(id).then(({ data }) => data),
15
+ * execute: () => docsEndpoints.getDoc(id).then(({ data }) => data),
16
16
  * })),
17
17
  * },
18
18
  * }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astral/mobx-query",
3
- "version": "1.10.1",
3
+ "version": "1.10.3",
4
4
  "browser": "./index.js",
5
5
  "main": "./node/index.js",
6
6
  "dependencies": {