zova-module-a-model 5.0.11 → 5.0.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zova-module-a-model",
3
- "version": "5.0.11",
3
+ "version": "5.0.13",
4
4
  "title": "a-model",
5
5
  "zovaModule": {
6
6
  "capabilities": {
@@ -14,12 +14,6 @@
14
14
  ],
15
15
  "output": "tanstack"
16
16
  },
17
- {
18
- "match": [
19
- "js-cookie"
20
- ],
21
- "output": "js-cookie"
22
- },
23
17
  {
24
18
  "match": [
25
19
  "localforage"
@@ -59,9 +53,7 @@
59
53
  "dependencies": {
60
54
  "@tanstack/query-persist-client-core": "^5.45.0",
61
55
  "@tanstack/vue-query": "^5.45.0",
62
- "@types/js-cookie": "^3.0.6",
63
- "js-cookie": "^3.0.5",
64
56
  "localforage": "^1.10.0"
65
57
  },
66
- "gitHead": "d7ecefeb8b5f566e4b4831d7b3a02e9e7a765c15"
58
+ "gitHead": "14e181241069cfa0d5325cfb19f21259420c19de"
67
59
  }
@@ -1,7 +1,6 @@
1
1
  import { QueryMetaPersister } from '../../types.js';
2
2
  import { experimental_createPersister } from '@tanstack/query-persist-client-core';
3
3
  import { Query, QueryKey } from '@tanstack/vue-query';
4
- import { cookieStorage } from '../../common/cookieStorage.js';
5
4
  import localforage from 'localforage';
6
5
  import { SymbolBeanFullName } from 'zova';
7
6
  import { BeanModelLast } from './bean.model.last.js';
@@ -125,7 +124,7 @@ export class BeanModelPersister<TScopeModule = unknown> extends BeanModelLast<TS
125
124
  protected _getPersisterStorage(options?: QueryMetaPersister | boolean) {
126
125
  options = this._adjustPersisterOptions(options);
127
126
  if (!options) return undefined;
128
- if (options.storage === 'cookie') return cookieStorage;
127
+ if (options.storage === 'cookie') return this.app.meta.cookie;
129
128
  if (options.storage === 'local') return localStorage;
130
129
  if (options.storage === 'db') return localforage;
131
130
  }
@@ -1,5 +1,22 @@
1
+ import { DefaultOptions, defaultShouldDehydrateQuery } from '@tanstack/vue-query';
1
2
  import { ZovaApplication } from 'zova';
2
3
 
4
+ const defaultOptions: DefaultOptions = {
5
+ queries: {
6
+ retry: false,
7
+ refetchOnWindowFocus: false,
8
+ refetchOnMount: false,
9
+ refetchOnReconnect: true,
10
+ gcTime: 1000 * 60 * 5,
11
+ },
12
+ dehydrate: {
13
+ shouldDehydrateQuery(query) {
14
+ if (query.meta?.ssr?.dehydrate === false) return false;
15
+ return defaultShouldDehydrateQuery(query);
16
+ },
17
+ },
18
+ };
19
+
3
20
  export const config = (_app: ZovaApplication) => {
4
21
  return {
5
22
  persister: {
@@ -10,5 +27,8 @@ export const config = (_app: ZovaApplication) => {
10
27
  maxAge: 1000 * 60 * 60 * 24, // 24 hours
11
28
  },
12
29
  },
30
+ queryClientConfig: {
31
+ defaultOptions,
32
+ },
13
33
  };
14
34
  };
@@ -1,27 +1,13 @@
1
1
  import { BeanBase, Local } from 'zova';
2
2
  import { ScopeModule } from '../resource/this.js';
3
- import { VueQueryPlugin, VueQueryPluginOptions, defaultShouldDehydrateQuery } from '@tanstack/vue-query';
3
+ import { VueQueryPlugin, VueQueryPluginOptions } from '@tanstack/vue-query';
4
4
 
5
5
  @Local()
6
6
  export class Storage extends BeanBase<ScopeModule> {
7
7
  protected async __init__() {
8
8
  const vueQueryPluginOptions: VueQueryPluginOptions = {
9
9
  queryClientConfig: {
10
- defaultOptions: {
11
- queries: {
12
- retry: false,
13
- refetchOnWindowFocus: false,
14
- refetchOnMount: false,
15
- refetchOnReconnect: false,
16
- // gcTime: 1000 * 60 * 5,
17
- },
18
- dehydrate: {
19
- shouldDehydrateQuery(query) {
20
- if (query.meta?.ssr?.dehydrate === false) return false;
21
- return defaultShouldDehydrateQuery(query);
22
- },
23
- },
24
- },
10
+ defaultOptions: this.scope.config.queryClientConfig.defaultOptions,
25
11
  },
26
12
  };
27
13
  this.app.vue.use(VueQueryPlugin, vueQueryPluginOptions);
@@ -1,13 +0,0 @@
1
- import Cookies from 'js-cookie';
2
-
3
- export const cookieStorage = {
4
- getItem(key: string): string | undefined {
5
- return Cookies.get(key);
6
- },
7
- setItem(key: string, value: string): void {
8
- Cookies.set(key, value);
9
- },
10
- removeItem(key: string): void {
11
- Cookies.remove(key);
12
- },
13
- };