vona-module-test-vona 5.0.23 → 5.0.25

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.
@@ -98,6 +98,7 @@ declare module 'vona' {
98
98
  /** bean: end */
99
99
  /** service: begin */
100
100
  export * from '../service/aopMethod.ts';
101
+ export * from '../service/caching.ts';
101
102
  export * from '../service/test.ts';
102
103
  export * from '../service/testApp.ts';
103
104
  export * from '../service/testClass.ts';
@@ -106,6 +107,7 @@ import 'vona';
106
107
  declare module 'vona-module-a-bean' {
107
108
  interface IServiceRecord {
108
109
  'test-vona:aopMethod': never;
110
+ 'test-vona:caching': never;
109
111
  'test-vona:test': never;
110
112
  'test-vona:testApp': never;
111
113
  'test-vona:testClass': never;
@@ -115,6 +117,8 @@ declare module 'vona-module-a-bean' {
115
117
  declare module 'vona-module-test-vona' {
116
118
  interface ServiceAopMethod {
117
119
  }
120
+ interface ServiceCaching {
121
+ }
118
122
  interface ServiceTest {
119
123
  }
120
124
  interface ServiceTestApp {
@@ -127,12 +131,14 @@ declare module 'vona-module-test-vona' {
127
131
  /** service: end */
128
132
  /** service: begin */
129
133
  import type { ServiceAopMethod } from '../service/aopMethod.ts';
134
+ import type { ServiceCaching } from '../service/caching.ts';
130
135
  import type { ServiceTest } from '../service/test.ts';
131
136
  import type { ServiceTestApp } from '../service/testApp.ts';
132
137
  import type { ServiceTestClass } from '../service/testClass.ts';
133
138
  import type { ServiceTransaction } from '../service/transaction.ts';
134
139
  export interface IModuleService {
135
140
  'aopMethod': ServiceAopMethod;
141
+ 'caching': ServiceCaching;
136
142
  'test': ServiceTest;
137
143
  'testApp': ServiceTestApp;
138
144
  'testClass': ServiceTestClass;
@@ -144,6 +150,7 @@ import 'vona';
144
150
  declare module 'vona' {
145
151
  interface IBeanRecordGeneral {
146
152
  'test-vona.service.aopMethod': ServiceAopMethod;
153
+ 'test-vona.service.caching': ServiceCaching;
147
154
  'test-vona.service.test': ServiceTest;
148
155
  'test-vona.service.testApp': ServiceTestApp;
149
156
  'test-vona.service.testClass': ServiceTestClass;
package/dist/index.js CHANGED
@@ -3,9 +3,10 @@ import { Aop, AopMethod, Aspect } from 'vona-module-a-aspect';
3
3
  import { Entity, EntityBase, Model, BeanModelBase, Database } from 'vona-module-a-database';
4
4
  import { Api, v, Arg } from 'vona-module-a-openapi';
5
5
  import { Bean, Service, Scope } from 'vona-module-a-bean';
6
+ import { getKeyHash, CacheMem, BeanCacheMemBase, CacheRedis, BeanCacheRedisBase } from 'vona-module-a-cache';
7
+ import { Caching } from 'vona-module-a-caching';
6
8
  import assert from 'node:assert';
7
9
  import { Broadcast, BeanBroadcastBase } from 'vona-module-a-broadcast';
8
- import { CacheMem, BeanCacheMemBase, CacheRedis, BeanCacheRedisBase } from 'vona-module-a-cache';
9
10
  import { Event, BeanEventBase, EventListener } from 'vona-module-a-event';
10
11
  import { Meta } from 'vona-module-a-meta';
11
12
  import { Queue, BeanQueueBase } from 'vona-module-a-queue';
@@ -19,15 +20,15 @@ import { z } from 'zod';
19
20
  import { DtoJwtToken } from 'vona-module-a-jwt';
20
21
  import { SymbolUploadValue } from 'vona-module-a-upload';
21
22
 
22
- var _dec$z, _dec2$z, _class$z;
23
- let AopRegExp = (_dec$z = Aop({
23
+ var _dec$A, _dec2$A, _class$A;
24
+ let AopRegExp = (_dec$A = Aop({
24
25
  match: [/^test-vona\.service\.test\w+$/, 'testCtx'],
25
26
  meta: {
26
27
  mode: 'test'
27
28
  }
28
- }), _dec2$z = BeanInfo({
29
+ }), _dec2$A = BeanInfo({
29
30
  module: "test-vona"
30
- }), _dec$z(_class$z = _dec2$z(_class$z = class AopRegExp extends BeanAopBase {
31
+ }), _dec$A(_class$A = _dec2$A(_class$A = class AopRegExp extends BeanAopBase {
31
32
  __get_name__(next) {
32
33
  const value = next();
33
34
  return `${value}:regexpaop`;
@@ -49,24 +50,24 @@ let AopRegExp = (_dec$z = Aop({
49
50
  const result = await next();
50
51
  return `${result}:regexpaop`;
51
52
  }
52
- }) || _class$z) || _class$z);
53
+ }) || _class$A) || _class$A);
53
54
 
54
- var _dec$y, _dec2$y, _class$y;
55
+ var _dec$z, _dec2$z, _class$z;
55
56
  class AopSimpleBase extends BeanAopBase {
56
57
  actionSync(_args, next) {
57
58
  const result = next();
58
59
  return `${result}:simpleaop`;
59
60
  }
60
61
  }
61
- let AopSimple = (_dec$y = Aop({
62
+ let AopSimple = (_dec$z = Aop({
62
63
  match: 'testCtx',
63
64
  dependencies: 'test-vona:regExp',
64
65
  meta: {
65
66
  mode: 'test'
66
67
  }
67
- }), _dec2$y = BeanInfo({
68
+ }), _dec2$z = BeanInfo({
68
69
  module: "test-vona"
69
- }), _dec$y(_class$y = _dec2$y(_class$y = class AopSimple extends AopSimpleBase {
70
+ }), _dec$z(_class$z = _dec2$z(_class$z = class AopSimple extends AopSimpleBase {
70
71
  // magic
71
72
  __get__(prop, next) {
72
73
  const value = next();
@@ -106,14 +107,14 @@ let AopSimple = (_dec$y = Aop({
106
107
  const result = await next();
107
108
  return `${result}:simpleaop`;
108
109
  }
109
- }) || _class$y) || _class$y);
110
+ }) || _class$z) || _class$z);
110
111
 
111
- var _dec$x, _dec2$x, _class$x;
112
- let AopMethodTest = (_dec$x = AopMethod({
112
+ var _dec$y, _dec2$y, _class$y;
113
+ let AopMethodTest = (_dec$y = AopMethod({
113
114
  wrapper: ''
114
- }), _dec2$x = BeanInfo({
115
+ }), _dec2$y = BeanInfo({
115
116
  module: "test-vona"
116
- }), _dec$x(_class$x = _dec2$x(_class$x = class AopMethodTest extends BeanAopMethodBase {
117
+ }), _dec$y(_class$y = _dec2$y(_class$y = class AopMethodTest extends BeanAopMethodBase {
117
118
  get(options, next, _receiver, _prop) {
118
119
  const res = next();
119
120
  return this._wrapper(options.wrapper, res);
@@ -140,7 +141,7 @@ let AopMethodTest = (_dec$x = AopMethod({
140
141
  if (index === data.length - wrapper.length) data = data.substring(0, index);
141
142
  return data;
142
143
  }
143
- }) || _class$x) || _class$x);
144
+ }) || _class$y) || _class$y);
144
145
 
145
146
  function _applyDecoratedDescriptor(i, e, r, n, l) {
146
147
  var a = {};
@@ -159,36 +160,36 @@ function _initializerDefineProperty(e, i, r, l) {
159
160
  });
160
161
  }
161
162
 
162
- var _dec$w, _dec2$w, _dec3$g, _dec4$g, _dec5$g, _dec6$g, _class$w, _class2$g, _descriptor$2, _descriptor2$2;
163
- let EntityTest = (_dec$w = Entity('testVona'), _dec2$w = BeanInfo({
163
+ var _dec$x, _dec2$x, _dec3$h, _dec4$h, _dec5$h, _dec6$h, _class$x, _class2$h, _descriptor$2, _descriptor2$2;
164
+ let EntityTest = (_dec$x = Entity('testVona'), _dec2$x = BeanInfo({
164
165
  module: "test-vona"
165
- }), _dec3$g = Api.field(), _dec4$g = Reflect.metadata("design:type", String), _dec5$g = Api.field(), _dec6$g = Reflect.metadata("design:type", String), _dec$w(_class$w = _dec2$w(_class$w = (_class2$g = class EntityTest extends EntityBase {
166
+ }), _dec3$h = Api.field(), _dec4$h = Reflect.metadata("design:type", String), _dec5$h = Api.field(), _dec6$h = Reflect.metadata("design:type", String), _dec$x(_class$x = _dec2$x(_class$x = (_class2$h = class EntityTest extends EntityBase {
166
167
  constructor(...args) {
167
168
  super(...args);
168
169
  _initializerDefineProperty(this, "title", _descriptor$2, this);
169
170
  _initializerDefineProperty(this, "description", _descriptor2$2, this);
170
171
  }
171
- }, _descriptor$2 = _applyDecoratedDescriptor(_class2$g.prototype, "title", [_dec3$g, _dec4$g], {
172
+ }, _descriptor$2 = _applyDecoratedDescriptor(_class2$h.prototype, "title", [_dec3$h, _dec4$h], {
172
173
  configurable: true,
173
174
  enumerable: true,
174
175
  writable: true,
175
176
  initializer: null
176
- }), _descriptor2$2 = _applyDecoratedDescriptor(_class2$g.prototype, "description", [_dec5$g, _dec6$g], {
177
+ }), _descriptor2$2 = _applyDecoratedDescriptor(_class2$h.prototype, "description", [_dec5$h, _dec6$h], {
177
178
  configurable: true,
178
179
  enumerable: true,
179
180
  writable: true,
180
181
  initializer: null
181
- }), _class2$g)) || _class$w) || _class$w);
182
+ }), _class2$h)) || _class$x) || _class$x);
182
183
 
183
- var _dec$v, _dec2$v, _class$v;
184
- let ModelTest = (_dec$v = Model({
184
+ var _dec$w, _dec2$w, _class$w;
185
+ let ModelTest = (_dec$w = Model({
185
186
  entity: EntityTest,
186
187
  clientName: 'default'
187
- }), _dec2$v = BeanInfo({
188
+ }), _dec2$w = BeanInfo({
188
189
  module: "test-vona"
189
- }), _dec$v(_class$v = _dec2$v(_class$v = class ModelTest extends BeanModelBase {}) || _class$v) || _class$v);
190
+ }), _dec$w(_class$w = _dec2$w(_class$w = class ModelTest extends BeanModelBase {}) || _class$w) || _class$w);
190
191
 
191
- var _dec$u, _dec2$u, _class$u;
192
+ var _dec$v, _dec2$v, _class$v;
192
193
  class TestCtx0 extends BeanBase {
193
194
  constructor(...args) {
194
195
  super(...args);
@@ -250,35 +251,35 @@ class TestCtx1 extends TestCtx0 {
250
251
  });
251
252
  }
252
253
  }
253
- let BeanTestCtx = (_dec$u = Bean(), _dec2$u = BeanInfo({
254
+ let BeanTestCtx = (_dec$v = Bean(), _dec2$v = BeanInfo({
254
255
  module: "test-vona"
255
- }), _dec$u(_class$u = _dec2$u(_class$u = class BeanTestCtx extends TestCtx1 {}) || _class$u) || _class$u);
256
+ }), _dec$v(_class$v = _dec2$v(_class$v = class BeanTestCtx extends TestCtx1 {}) || _class$v) || _class$v);
256
257
 
257
- var _dec$t, _dec2$t, _dec3$f, _dec4$f, _class$t, _dec5$f, _dec6$f, _dec7$e, _dec8$a, _dec9$7, _dec0$7, _dec1$7, _dec10$5, _dec11$5, _dec12$5, _dec13$5, _dec14$4, _dec15$4, _dec16$4, _class2$f, _class3;
258
- let ServiceAopMethodBase = (_dec$t = Aspect.aopMethod('test-vona:test', {
258
+ var _dec$u, _dec2$u, _dec3$g, _dec4$g, _class$u, _dec5$g, _dec6$g, _dec7$f, _dec8$b, _dec9$8, _dec0$8, _dec1$8, _dec10$6, _dec11$6, _dec12$6, _dec13$6, _dec14$5, _dec15$5, _dec16$5, _class2$g, _class3;
259
+ let ServiceAopMethodBase = (_dec$u = Aspect.aopMethod('test-vona:test', {
259
260
  wrapper: '+'
260
- }), _dec2$t = Aspect.aopMethod('test-vona:test', {
261
+ }), _dec2$u = Aspect.aopMethod('test-vona:test', {
261
262
  wrapper: '-'
262
- }), _dec3$f = Reflect.metadata("design:type", Function), _dec4$f = Reflect.metadata("design:paramtypes", []), _class$t = class ServiceAopMethodBase extends BeanBase {
263
+ }), _dec3$g = Reflect.metadata("design:type", Function), _dec4$g = Reflect.metadata("design:paramtypes", []), _class$u = class ServiceAopMethodBase extends BeanBase {
263
264
  testSyncBase() {
264
265
  return 'hello';
265
266
  }
266
- }, _applyDecoratedDescriptor(_class$t.prototype, "testSyncBase", [_dec$t, _dec2$t, _dec3$f, _dec4$f], Object.getOwnPropertyDescriptor(_class$t.prototype, "testSyncBase"), _class$t.prototype), _class$t);
267
- let ServiceAopMethod = (_dec5$f = Service(), _dec6$f = BeanInfo({
267
+ }, _applyDecoratedDescriptor(_class$u.prototype, "testSyncBase", [_dec$u, _dec2$u, _dec3$g, _dec4$g], Object.getOwnPropertyDescriptor(_class$u.prototype, "testSyncBase"), _class$u.prototype), _class$u);
268
+ let ServiceAopMethod = (_dec5$g = Service(), _dec6$g = BeanInfo({
268
269
  module: "test-vona"
269
- }), _dec7$e = Aspect.aopMethod('test-vona:test', {
270
+ }), _dec7$f = Aspect.aopMethod('test-vona:test', {
270
271
  wrapper: '+'
271
- }), _dec8$a = Aspect.aopMethod('test-vona:test', {
272
+ }), _dec8$b = Aspect.aopMethod('test-vona:test', {
272
273
  wrapper: '-'
273
- }), _dec9$7 = Reflect.metadata("design:type", Function), _dec0$7 = Reflect.metadata("design:paramtypes", []), _dec1$7 = Aspect.aopMethod('test-vona:test', {
274
+ }), _dec9$8 = Reflect.metadata("design:type", Function), _dec0$8 = Reflect.metadata("design:paramtypes", []), _dec1$8 = Aspect.aopMethod('test-vona:test', {
274
275
  wrapper: '+'
275
- }), _dec10$5 = Aspect.aopMethod('test-vona:test', {
276
+ }), _dec10$6 = Aspect.aopMethod('test-vona:test', {
276
277
  wrapper: '-'
277
- }), _dec11$5 = Reflect.metadata("design:type", Function), _dec12$5 = Reflect.metadata("design:paramtypes", []), _dec13$5 = Aspect.aopMethod('test-vona:test', {
278
+ }), _dec11$6 = Reflect.metadata("design:type", Function), _dec12$6 = Reflect.metadata("design:paramtypes", []), _dec13$6 = Aspect.aopMethod('test-vona:test', {
278
279
  wrapper: '+'
279
- }), _dec14$4 = Aspect.aopMethod('test-vona:test', {
280
+ }), _dec14$5 = Aspect.aopMethod('test-vona:test', {
280
281
  wrapper: '-'
281
- }), _dec15$4 = Reflect.metadata("design:type", Function), _dec16$4 = Reflect.metadata("design:paramtypes", []), _dec5$f(_class2$f = _dec6$f(_class2$f = (_class3 = class ServiceAopMethod extends ServiceAopMethodBase {
282
+ }), _dec15$5 = Reflect.metadata("design:type", Function), _dec16$5 = Reflect.metadata("design:paramtypes", []), _dec5$g(_class2$g = _dec6$g(_class2$g = (_class3 = class ServiceAopMethod extends ServiceAopMethodBase {
282
283
  constructor(...args) {
283
284
  super(...args);
284
285
  this._name = '';
@@ -295,7 +296,93 @@ let ServiceAopMethod = (_dec5$f = Service(), _dec6$f = BeanInfo({
295
296
  set name(value) {
296
297
  this._name = value;
297
298
  }
298
- }, _applyDecoratedDescriptor(_class3.prototype, "testSync", [_dec7$e, _dec8$a, _dec9$7, _dec0$7], Object.getOwnPropertyDescriptor(_class3.prototype, "testSync"), _class3.prototype), _applyDecoratedDescriptor(_class3.prototype, "testAsync", [_dec1$7, _dec10$5, _dec11$5, _dec12$5], Object.getOwnPropertyDescriptor(_class3.prototype, "testAsync"), _class3.prototype), _applyDecoratedDescriptor(_class3.prototype, "name", [_dec13$5, _dec14$4, _dec15$4, _dec16$4], Object.getOwnPropertyDescriptor(_class3.prototype, "name"), _class3.prototype), _class3)) || _class2$f) || _class2$f);
299
+ }, _applyDecoratedDescriptor(_class3.prototype, "testSync", [_dec7$f, _dec8$b, _dec9$8, _dec0$8], Object.getOwnPropertyDescriptor(_class3.prototype, "testSync"), _class3.prototype), _applyDecoratedDescriptor(_class3.prototype, "testAsync", [_dec1$8, _dec10$6, _dec11$6, _dec12$6], Object.getOwnPropertyDescriptor(_class3.prototype, "testAsync"), _class3.prototype), _applyDecoratedDescriptor(_class3.prototype, "name", [_dec13$6, _dec14$5, _dec15$5, _dec16$5], Object.getOwnPropertyDescriptor(_class3.prototype, "name"), _class3.prototype), _class3)) || _class2$g) || _class2$g);
300
+
301
+ var _dec$t, _dec2$t, _dec3$f, _dec4$f, _dec5$f, _dec6$f, _dec7$e, _dec8$a, _dec9$7, _dec0$7, _dec1$7, _dec10$5, _dec11$5, _dec12$5, _dec13$5, _dec14$4, _dec15$4, _dec16$4, _dec17$3, _dec18$3, _dec19$3, _dec20$3, _dec21$3, _dec22$3, _dec23$3, _dec24$3, _dec25$3, _dec26$2, _dec27$2, _class$t, _class2$f;
302
+ function cacheKeyFn(args, prop, options) {
303
+ return `${this.$beanFullName}_${options.cacheProp ?? prop}_${getKeyHash(args)}`;
304
+ }
305
+ let ServiceCaching = (_dec$t = Service(), _dec2$t = BeanInfo({
306
+ module: "test-vona"
307
+ }), _dec3$f = Caching.get({
308
+ cacheName: 'test-vona:test',
309
+ cacheProp: 'test',
310
+ cacheKeyFn: 'cacheKey'
311
+ }), _dec4$f = Reflect.metadata("design:type", Function), _dec5$f = Reflect.metadata("design:paramtypes", [Number]), _dec6$f = Caching.get({
312
+ cacheName: 'test-vona:test',
313
+ cacheProp: 'test',
314
+ cacheKeyFn
315
+ }), _dec7$e = Reflect.metadata("design:type", Function), _dec8$a = Reflect.metadata("design:paramtypes", [Number]), _dec9$7 = Caching.get({
316
+ cacheName: 'test-vona:test',
317
+ cacheProp: 'test',
318
+ cacheKey: 'cel://get(self,"$beanFullName")+"_"+options.cacheProp+"_"+hashkey(args)'
319
+ }), _dec0$7 = Reflect.metadata("design:type", Function), _dec1$7 = Reflect.metadata("design:paramtypes", [Number]), _dec10$5 = Caching.get({
320
+ cacheName: 'test-vona:test',
321
+ cacheProp: 'test'
322
+ }), _dec11$5 = Reflect.metadata("design:type", Function), _dec12$5 = Reflect.metadata("design:paramtypes", [Number]), _dec13$5 = Caching.set({
323
+ cacheName: 'test-vona:test',
324
+ cacheProp: 'test',
325
+ cacheKeyFn: 'cacheKeySet',
326
+ cacheValueFn: 'cacheValueSet'
327
+ }), _dec14$4 = Reflect.metadata("design:type", Function), _dec15$4 = Reflect.metadata("design:paramtypes", [Number, typeof TSummerCacheTestData === "undefined" ? Object : TSummerCacheTestData]), _dec16$4 = Caching.set({
328
+ cacheName: 'test-vona:test',
329
+ cacheProp: 'test',
330
+ cacheKey: 'cel://get(self,"$beanFullName")+"_"+options.cacheProp+"_"+hashkey([args[0]])',
331
+ cacheValue: 'cel://{"id": args[1].id, "name": args[1].name}'
332
+ }), _dec17$3 = Reflect.metadata("design:type", Function), _dec18$3 = Reflect.metadata("design:paramtypes", [Number, typeof TSummerCacheTestData === "undefined" ? Object : TSummerCacheTestData]), _dec19$3 = Caching.set({
333
+ cacheName: 'test-vona:test',
334
+ cacheProp: 'test',
335
+ cacheKeyFn: 'cacheKeySet'
336
+ }), _dec20$3 = Reflect.metadata("design:type", Function), _dec21$3 = Reflect.metadata("design:paramtypes", [Number, typeof TSummerCacheTestData === "undefined" ? Object : TSummerCacheTestData]), _dec22$3 = Caching.del({
337
+ cacheName: 'test-vona:test',
338
+ cacheProp: 'test'
339
+ }), _dec23$3 = Reflect.metadata("design:type", Function), _dec24$3 = Reflect.metadata("design:paramtypes", [Number]), _dec25$3 = Caching.clear({
340
+ cacheName: 'test-vona:test'
341
+ }), _dec26$2 = Reflect.metadata("design:type", Function), _dec27$2 = Reflect.metadata("design:paramtypes", []), _dec$t(_class$t = _dec2$t(_class$t = (_class2$f = class ServiceCaching extends BeanBase {
342
+ cacheKey(args, prop, options) {
343
+ return `${this.$beanFullName}_${options.cacheProp ?? prop}_${getKeyHash(args)}`;
344
+ }
345
+ cacheKeySet(args, prop, options) {
346
+ return `${this.$beanFullName}_${options.cacheProp ?? prop}_${getKeyHash(args.slice(0, -1))}`;
347
+ }
348
+ cacheValueSet(_value, args, _prop, _options) {
349
+ return args[args.length - 1];
350
+ }
351
+ async get(id) {
352
+ return {
353
+ id,
354
+ name: `name_${id}`
355
+ };
356
+ }
357
+ async get2(_id) {
358
+ return undefined;
359
+ }
360
+ async get3(_id) {
361
+ return undefined;
362
+ }
363
+
364
+ // default cacheKey
365
+ async get4(_id) {
366
+ return undefined;
367
+ }
368
+ async set(_id, _value) {
369
+ // do nothing
370
+ }
371
+
372
+ //
373
+ async set2(_id, _value) {
374
+ // do nothing
375
+ }
376
+ async set3(_id, value) {
377
+ return value;
378
+ }
379
+ async del(_id) {
380
+ // do nothing
381
+ }
382
+ async clear() {
383
+ // do nothing
384
+ }
385
+ }, _applyDecoratedDescriptor(_class2$f.prototype, "get", [_dec3$f, _dec4$f, _dec5$f], Object.getOwnPropertyDescriptor(_class2$f.prototype, "get"), _class2$f.prototype), _applyDecoratedDescriptor(_class2$f.prototype, "get2", [_dec6$f, _dec7$e, _dec8$a], Object.getOwnPropertyDescriptor(_class2$f.prototype, "get2"), _class2$f.prototype), _applyDecoratedDescriptor(_class2$f.prototype, "get3", [_dec9$7, _dec0$7, _dec1$7], Object.getOwnPropertyDescriptor(_class2$f.prototype, "get3"), _class2$f.prototype), _applyDecoratedDescriptor(_class2$f.prototype, "get4", [_dec10$5, _dec11$5, _dec12$5], Object.getOwnPropertyDescriptor(_class2$f.prototype, "get4"), _class2$f.prototype), _applyDecoratedDescriptor(_class2$f.prototype, "set", [_dec13$5, _dec14$4, _dec15$4], Object.getOwnPropertyDescriptor(_class2$f.prototype, "set"), _class2$f.prototype), _applyDecoratedDescriptor(_class2$f.prototype, "set2", [_dec16$4, _dec17$3, _dec18$3], Object.getOwnPropertyDescriptor(_class2$f.prototype, "set2"), _class2$f.prototype), _applyDecoratedDescriptor(_class2$f.prototype, "set3", [_dec19$3, _dec20$3, _dec21$3], Object.getOwnPropertyDescriptor(_class2$f.prototype, "set3"), _class2$f.prototype), _applyDecoratedDescriptor(_class2$f.prototype, "del", [_dec22$3, _dec23$3, _dec24$3], Object.getOwnPropertyDescriptor(_class2$f.prototype, "del"), _class2$f.prototype), _applyDecoratedDescriptor(_class2$f.prototype, "clear", [_dec25$3, _dec26$2, _dec27$2], Object.getOwnPropertyDescriptor(_class2$f.prototype, "clear"), _class2$f.prototype), _class2$f)) || _class$t) || _class$t);
299
386
 
300
387
  var _dec$s, _dec2$s, _class$s;
301
388
  let ServiceTest = (_dec$s = Service(), _dec2$s = BeanInfo({
@@ -982,19 +1069,19 @@ let ControllerSummer = (_dec$4 = Controller({
982
1069
 
983
1070
  // get
984
1071
  value = await cache.get(key1);
985
- assert.equal(value.id, key1.id);
1072
+ assert.equal(value?.id, key1.id);
986
1073
 
987
1074
  // get: peek
988
1075
  value = await cache.peek(key1);
989
- assert.equal(value.id, key1.id);
1076
+ assert.equal(value?.id, key1.id);
990
1077
  value = await cache.peek(key1, {
991
1078
  mode: 'mem'
992
1079
  });
993
- assert.equal(value.id, key1.id);
1080
+ assert.equal(value?.id, key1.id);
994
1081
  value = await cache.peek(key1, {
995
1082
  mode: 'redis'
996
1083
  });
997
- assert.equal(value.id, key1.id);
1084
+ assert.equal(value?.id, key1.id);
998
1085
 
999
1086
  // get: peek sleep for mem stale
1000
1087
  await sleep(900);
@@ -1003,7 +1090,7 @@ let ControllerSummer = (_dec$4 = Controller({
1003
1090
  value = await cache.peek(key1, {
1004
1091
  mode: 'redis'
1005
1092
  });
1006
- assert.equal(value.id, key1.id);
1093
+ assert.equal(value?.id, key1.id);
1007
1094
  await retry({
1008
1095
  retries: 3
1009
1096
  }, async () => {
@@ -1035,23 +1122,23 @@ let ControllerSummer = (_dec$4 = Controller({
1035
1122
  // mget
1036
1123
  // mem cache graph: key1
1037
1124
  value = await cache.get(key1);
1038
- assert.equal(value.id, key1.id);
1125
+ assert.equal(value?.id, key1.id);
1039
1126
  // mem cache graph: key2 key3
1040
1127
  values = await cache.mget([key1, key2, key3]); // todo: maybe has bug
1041
- assert.equal(values[0].id, key1.id); // todo: maybe has bug
1042
- assert.equal(values[1].id, key2.id);
1043
- assert.equal(values[2].id, key3.id);
1128
+ assert.equal(values[0]?.id, key1.id); // todo: maybe has bug
1129
+ assert.equal(values[1]?.id, key2.id);
1130
+ assert.equal(values[2]?.id, key3.id);
1044
1131
  // mem cache graph: key3 key1
1045
1132
  values = await cache.mget([key1, key2, key3]);
1046
- assert.equal(values[0].id, key1.id);
1047
- assert.equal(values[1].id, key2.id);
1048
- assert.equal(values[2].id, key3.id);
1133
+ assert.equal(values[0]?.id, key1.id);
1134
+ assert.equal(values[1]?.id, key2.id);
1135
+ assert.equal(values[2]?.id, key3.id);
1049
1136
 
1050
1137
  // mget: peek
1051
1138
  value = await cache.peek(key2, {
1052
1139
  mode: 'redis'
1053
1140
  });
1054
- assert.equal(value.id, key2.id);
1141
+ assert.equal(value?.id, key2.id);
1055
1142
  value = await cache.peek(key2, {
1056
1143
  mode: 'mem'
1057
1144
  });
@@ -1076,15 +1163,15 @@ let ControllerSummer = (_dec$4 = Controller({
1076
1163
 
1077
1164
  // clear
1078
1165
  values = await cache.mget([key1, key2, key3]);
1079
- assert.equal(values[2].id, key3.id);
1166
+ assert.equal(values[2]?.id, key3.id);
1080
1167
  value = await cache.peek(key3, {
1081
1168
  mode: 'redis'
1082
1169
  });
1083
- assert.equal(value.id, key3.id);
1170
+ assert.equal(value?.id, key3.id);
1084
1171
  value = await cache.peek(key3, {
1085
1172
  mode: 'mem'
1086
1173
  });
1087
- assert.equal(value.id, key3.id);
1174
+ assert.equal(value?.id, key3.id);
1088
1175
  await cache.clear();
1089
1176
  value = await cache.peek(key3, {
1090
1177
  mode: 'redis'
@@ -1235,4 +1322,4 @@ function $locale(key) {
1235
1322
  }
1236
1323
  /** scope: end */
1237
1324
 
1238
- export { $locale, AopMethodTest, AopRegExp, AopSimple, BeanTestCtx, BroadcastTest, CacheMemTest, CacheRedisTest, ControllerBean, ControllerCacheMem, ControllerCacheRedis, ControllerGuardPassport, ControllerOnion, ControllerPassport, ControllerPerformAction, ControllerQueue, ControllerSummer, ControllerTail, ControllerTransaction, ControllerUpload, DtoProfile, DtoUser, EntityTest, EventHelloEcho, EventListenerHelloEcho, MetaVersion, ModelTest, QueueTest, ScheduleTest, ScheduleTest3, ScopeModuleTestVona, ServiceAopMethod, ServiceTest, ServiceTestApp, ServiceTestClass, ServiceTransaction, SummerCacheTest, config, locales };
1325
+ export { $locale, AopMethodTest, AopRegExp, AopSimple, BeanTestCtx, BroadcastTest, CacheMemTest, CacheRedisTest, ControllerBean, ControllerCacheMem, ControllerCacheRedis, ControllerGuardPassport, ControllerOnion, ControllerPassport, ControllerPerformAction, ControllerQueue, ControllerSummer, ControllerTail, ControllerTransaction, ControllerUpload, DtoProfile, DtoUser, EntityTest, EventHelloEcho, EventListenerHelloEcho, MetaVersion, ModelTest, QueueTest, ScheduleTest, ScheduleTest3, ScopeModuleTestVona, ServiceAopMethod, ServiceCaching, ServiceTest, ServiceTestApp, ServiceTestClass, ServiceTransaction, SummerCacheTest, config, locales };
@@ -0,0 +1,17 @@
1
+ import type { TypeCachingActionOptions } from 'vona-module-a-caching';
2
+ import type { TSummerCacheTestData } from '../bean/summerCache.test.ts';
3
+ import { BeanBase } from 'vona';
4
+ export declare class ServiceCaching extends BeanBase {
5
+ cacheKey(args: any[], prop: string, options: TypeCachingActionOptions): string;
6
+ cacheKeySet(args: any[], prop: string, options: TypeCachingActionOptions): string;
7
+ cacheValueSet(_value: any, args: any[], _prop: string, _options: TypeCachingActionOptions): any;
8
+ get(id: number): Promise<TSummerCacheTestData>;
9
+ get2(_id: number): Promise<TSummerCacheTestData>;
10
+ get3(_id: number): Promise<TSummerCacheTestData>;
11
+ get4(_id: number): Promise<TSummerCacheTestData>;
12
+ set(_id: number, _value: TSummerCacheTestData): Promise<void>;
13
+ set2(_id: number, _value: TSummerCacheTestData): Promise<void>;
14
+ set3(_id: number, value: TSummerCacheTestData): Promise<TSummerCacheTestData>;
15
+ del(_id: number): Promise<void>;
16
+ clear(): Promise<void>;
17
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vona-module-test-vona",
3
3
  "type": "module",
4
- "version": "5.0.23",
4
+ "version": "5.0.25",
5
5
  "title": "test-vona",
6
6
  "vonaModule": {
7
7
  "fileVersion": 1,