vona-module-a-caching 5.0.4 → 5.0.7

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.
@@ -19,11 +19,27 @@ declare module 'vona-module-a-aspect' {
19
19
  declare module 'vona-module-a-caching' {
20
20
  interface AopMethodCachingClear {
21
21
  }
22
+ interface AopMethodCachingClear {
23
+ get $beanFullName(): 'a-caching.aopMethod.cachingClear';
24
+ get $onionName(): 'a-caching:cachingClear';
25
+ }
26
+ interface AopMethodCachingDel {
27
+ }
22
28
  interface AopMethodCachingDel {
29
+ get $beanFullName(): 'a-caching.aopMethod.cachingDel';
30
+ get $onionName(): 'a-caching:cachingDel';
23
31
  }
24
32
  interface AopMethodCachingGet {
25
33
  }
34
+ interface AopMethodCachingGet {
35
+ get $beanFullName(): 'a-caching.aopMethod.cachingGet';
36
+ get $onionName(): 'a-caching:cachingGet';
37
+ }
38
+ interface AopMethodCachingSet {
39
+ }
26
40
  interface AopMethodCachingSet {
41
+ get $beanFullName(): 'a-caching.aopMethod.cachingSet';
42
+ get $onionName(): 'a-caching:cachingSet';
27
43
  }
28
44
  }
29
45
  /** aopMethod: end */
@@ -4,17 +4,16 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
4
4
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
- import { isNil } from '@cabloy/utils';
8
7
  import { BeanAopMethodBase, beanFullNameFromOnionName } from 'vona';
9
8
  import { AopMethod } from 'vona-module-a-aspect';
10
- import { combineCachingKey } from "../lib/utils.js";
9
+ import { combineCachingKey, isCachingKeyValid } from "../lib/utils.js";
11
10
  let AopMethodCachingDel = class AopMethodCachingDel extends BeanAopMethodBase {
12
11
  async execute(options, args, next, receiver, prop) {
13
12
  // next
14
13
  const value = await next();
15
14
  // key
16
15
  const key = combineCachingKey(options, args, receiver, prop);
17
- if (isNil(key) || key === false || key === '')
16
+ if (!isCachingKeyValid(key))
18
17
  return value;
19
18
  // cache
20
19
  const cache = this.bean.summer.cache(beanFullNameFromOnionName(options.cacheName, 'summerCache'));
@@ -4,15 +4,14 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
4
4
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
- import { isNil } from '@cabloy/utils';
8
7
  import { BeanAopMethodBase, beanFullNameFromOnionName } from 'vona';
9
8
  import { AopMethod } from 'vona-module-a-aspect';
10
- import { combineCachingKey } from "../lib/utils.js";
9
+ import { combineCachingKey, isCachingKeyValid } from "../lib/utils.js";
11
10
  let AopMethodCachingGet = class AopMethodCachingGet extends BeanAopMethodBase {
12
11
  async execute(options, args, next, receiver, prop) {
13
12
  // key
14
13
  const key = combineCachingKey(options, args, receiver, prop);
15
- if (isNil(key) || key === false || key === '')
14
+ if (!isCachingKeyValid(key))
16
15
  return next();
17
16
  // cache
18
17
  const cache = this.bean.summer.cache(beanFullNameFromOnionName(options.cacheName, 'summerCache'));
@@ -4,17 +4,16 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
4
4
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
- import { isNil } from '@cabloy/utils';
8
7
  import { BeanAopMethodBase, beanFullNameFromOnionName } from 'vona';
9
8
  import { AopMethod } from 'vona-module-a-aspect';
10
- import { combineCachingKey, combineCachingValue } from "../lib/utils.js";
9
+ import { combineCachingKey, combineCachingValue, isCachingKeyValid } from "../lib/utils.js";
11
10
  let AopMethodCachingSet = class AopMethodCachingSet extends BeanAopMethodBase {
12
11
  async execute(options, args, next, receiver, prop) {
13
12
  // next
14
13
  const value = await next();
15
14
  // key
16
15
  const key = combineCachingKey(options, args, receiver, prop);
17
- if (isNil(key) || key === false || key === '')
16
+ if (!isCachingKeyValid(key))
18
17
  return value;
19
18
  // value
20
19
  const cacheValue = combineCachingValue(options, args, receiver, prop, value);
@@ -3,3 +3,4 @@ import type { IAopMethodOptionsCachingSet } from '../bean/aopMethod.cachingSet.t
3
3
  import type { TypeCachingActionOptions } from '../types/caching.ts';
4
4
  export declare function combineCachingKey(options: TypeCachingActionOptions, args: [], receiver: BeanBase, prop: string): any;
5
5
  export declare function combineCachingValue(options: IAopMethodOptionsCachingSet, args: [], receiver: BeanBase, prop: string, value: any): any;
6
+ export declare function isCachingKeyValid(key: any): boolean;
package/dist/lib/utils.js CHANGED
@@ -19,6 +19,8 @@ export function combineCachingKey(options, args, receiver, prop) {
19
19
  prop,
20
20
  options,
21
21
  self: receiver,
22
+ app: cast(receiver).app,
23
+ ctx: cast(receiver).ctx,
22
24
  });
23
25
  }
24
26
  // default
@@ -43,8 +45,13 @@ export function combineCachingValue(options, args, receiver, prop, value) {
43
45
  prop,
44
46
  options,
45
47
  self: receiver,
48
+ app: cast(receiver).app,
49
+ ctx: cast(receiver).ctx,
46
50
  });
47
51
  }
48
52
  // default
49
53
  return value;
50
54
  }
55
+ export function isCachingKeyValid(key) {
56
+ return !isNil(key) && key !== false && key !== '';
57
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vona-module-a-caching",
3
3
  "type": "module",
4
- "version": "5.0.4",
4
+ "version": "5.0.7",
5
5
  "title": "a-caching",
6
6
  "vonaModule": {
7
7
  "dependencies": {}