vona-module-test-vona 5.0.82 → 5.0.84

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.
Files changed (66) hide show
  1. package/dist/.metadata/index.d.ts +11 -0
  2. package/dist/bean/summerCache.caching.d.ts +12 -0
  3. package/dist/bean/summerCache.test.d.ts +1 -1
  4. package/dist/controller/order.d.ts +5 -5
  5. package/dist/controller/post.d.ts +6 -7
  6. package/dist/dto/orderCreate.d.ts +1 -1
  7. package/dist/dto/orderQueryPage.d.ts +1 -1
  8. package/dist/dto/orderUpdate.d.ts +1 -1
  9. package/dist/dto/postCreate.d.ts +1 -1
  10. package/dist/dto/postQuery.d.ts +1 -0
  11. package/dist/dto/userCreate.d.ts +1 -1
  12. package/dist/dto/userUpdate.d.ts +1 -1
  13. package/dist/index.js +299 -295
  14. package/dist/service/caching.d.ts +3 -4
  15. package/dist/service/post.d.ts +5 -5
  16. package/package.json +1 -1
  17. package/src/.metadata/index.ts +17 -2
  18. package/src/bean/summerCache.caching.ts +29 -0
  19. package/src/bean/summerCache.test.ts +4 -4
  20. package/src/controller/bean.ts +1 -1
  21. package/src/controller/cacheMem.ts +1 -1
  22. package/src/controller/cacheRedis.ts +1 -1
  23. package/src/controller/dtoTest.ts +1 -1
  24. package/src/controller/onion.ts +1 -1
  25. package/src/controller/order.ts +4 -13
  26. package/src/controller/passport.ts +1 -1
  27. package/src/controller/performAction.ts +1 -1
  28. package/src/controller/post.ts +4 -8
  29. package/src/controller/queue.ts +1 -1
  30. package/src/controller/serializer.ts +1 -1
  31. package/src/controller/summer.ts +3 -3
  32. package/src/controller/tail.ts +1 -1
  33. package/src/controller/transaction.ts +1 -1
  34. package/src/controller/upload.ts +1 -1
  35. package/src/dto/orderQuery.ts +7 -10
  36. package/src/dto/orderQueryPage.ts +1 -1
  37. package/src/dto/postQuery.ts +10 -6
  38. package/src/dto/profile.ts +1 -1
  39. package/src/dto/roleLazy.ts +1 -1
  40. package/src/dto/serializerArray.ts +1 -1
  41. package/src/dto/serializerLazy.ts +1 -1
  42. package/src/dto/serializerSimple.ts +1 -1
  43. package/src/dto/signin.ts +1 -1
  44. package/src/dto/user.ts +1 -1
  45. package/src/dto/userLazy.ts +1 -1
  46. package/src/entity/category.ts +1 -1
  47. package/src/entity/order.ts +1 -1
  48. package/src/entity/post.ts +1 -1
  49. package/src/entity/postContent.ts +1 -1
  50. package/src/entity/product.ts +1 -1
  51. package/src/entity/role.ts +1 -1
  52. package/src/entity/roleUser.ts +1 -1
  53. package/src/entity/test.ts +1 -1
  54. package/src/entity/user.ts +1 -1
  55. package/src/model/testDynamicTable.ts +2 -2
  56. package/src/service/caching.ts +16 -21
  57. package/test/cache/caching.test.ts +5 -2
  58. package/test/database/database.test.ts +2 -2
  59. package/test/database/dtoAggregate.test.ts +1 -1
  60. package/test/database/dtoGet.test.ts +3 -3
  61. package/test/database/dtoGroup.test.ts +1 -1
  62. package/test/database/dtoLazy.test.ts +1 -1
  63. package/test/database/dtoMutate.test.ts +2 -2
  64. package/test/database/dtoQuery.test.ts +9 -0
  65. package/test/upload.test.ts +1 -1
  66. package/test/utils/mappedTypes.test.ts +1 -1
@@ -1,29 +1,24 @@
1
- import type { TypeCachingActionOptions } from 'vona-module-a-caching';
1
+ import type { ICachingActionKeyInfo, ICachingActionValueInfo, TypeCachingActionOptions } from 'vona-module-a-caching';
2
2
  import type { TSummerCacheTestData } from '../bean/summerCache.test.ts';
3
3
  import { BeanBase } from 'vona';
4
4
  import { Service } from 'vona-module-a-bean';
5
- import { getKeyHash } from 'vona-module-a-cache';
6
5
  import { Caching } from 'vona-module-a-caching';
7
6
 
8
- function cacheKeyFn(this: ServiceCaching, args: [], prop: string, options: TypeCachingActionOptions): any {
9
- return `${this.$beanFullName}_${options.cacheProp ?? prop}_${getKeyHash(args)}`;
7
+ function cacheKeyFn(this: ServiceCaching, info: ICachingActionKeyInfo, _options: TypeCachingActionOptions): any {
8
+ return info.args[0];
10
9
  }
11
10
 
12
11
  @Service()
13
12
  export class ServiceCaching extends BeanBase {
14
- cacheKey(args: any[], prop: string, options: TypeCachingActionOptions) {
15
- return `${this.$beanFullName}_${options.cacheProp ?? prop}_${getKeyHash(args)}`;
13
+ cacheKey(info: ICachingActionKeyInfo, _options: TypeCachingActionOptions) {
14
+ return info.args[0];
16
15
  }
17
16
 
18
- cacheKeySet(args: any[], prop: string, options: TypeCachingActionOptions) {
19
- return `${this.$beanFullName}_${options.cacheProp ?? prop}_${getKeyHash(args.slice(0, -1))}`;
17
+ cacheValue(info: ICachingActionValueInfo, _options: TypeCachingActionOptions) {
18
+ return info.args[1];
20
19
  }
21
20
 
22
- cacheValueSet(_value: any, args: any[], _prop: string, _options: TypeCachingActionOptions) {
23
- return args[args.length - 1];
24
- }
25
-
26
- @Caching.get({ cacheName: 'test-vona:test', cacheProp: 'test', cacheKeyFn: 'cacheKey' })
21
+ @Caching.get({ cacheName: 'test-vona:caching', cacheKeyFn: 'cacheKey' })
27
22
  async get(id: number): Promise<TSummerCacheTestData> {
28
23
  return {
29
24
  id,
@@ -31,44 +26,44 @@ export class ServiceCaching extends BeanBase {
31
26
  };
32
27
  }
33
28
 
34
- @Caching.get({ cacheName: 'test-vona:test', cacheProp: 'test', cacheKeyFn })
29
+ @Caching.get({ cacheName: 'test-vona:caching', cacheKeyFn })
35
30
  async get2(_id: number): Promise<TSummerCacheTestData> {
36
31
  return undefined as any;
37
32
  }
38
33
 
39
- @Caching.get({ cacheName: 'test-vona:test', cacheProp: 'test', cacheKey: 'cel://join([get(self,"$beanFullName"),options.cacheProp,hashkey(args)],"_")' })
34
+ @Caching.get({ cacheName: 'test-vona:caching', cacheKey: 'cel://args[0]' })
40
35
  async get3(_id: number): Promise<TSummerCacheTestData> {
41
36
  return undefined as any;
42
37
  }
43
38
 
44
39
  // default cacheKey
45
- @Caching.get({ cacheName: 'test-vona:test', cacheProp: 'test' })
40
+ @Caching.get({ cacheName: 'test-vona:caching' })
46
41
  async get4(_id: number): Promise<TSummerCacheTestData> {
47
42
  return undefined as any;
48
43
  }
49
44
 
50
- @Caching.set({ cacheName: 'test-vona:test', cacheProp: 'test', cacheKeyFn: 'cacheKeySet', cacheValueFn: 'cacheValueSet' })
45
+ @Caching.set({ cacheName: 'test-vona:caching', cacheKeyFn: 'cacheKey', cacheValueFn: 'cacheValue' })
51
46
  async set(_id: number, _value: TSummerCacheTestData): Promise<void> {
52
47
  // do nothing
53
48
  }
54
49
 
55
50
  //
56
- @Caching.set({ cacheName: 'test-vona:test', cacheProp: 'test', cacheKey: 'cel://join([get(self,"$beanFullName"),options.cacheProp,hashkey([args[0]])],"_")', cacheValue: 'cel://{"id": args[1].id, "name": args[1].name}' })
51
+ @Caching.set({ cacheName: 'test-vona:caching', cacheKey: 'cel://args[0]', cacheValue: 'cel://{"id": args[1].id, "name": args[1].name}' })
57
52
  async set2(_id: number, _value: TSummerCacheTestData): Promise<void> {
58
53
  // do nothing
59
54
  }
60
55
 
61
- @Caching.set({ cacheName: 'test-vona:test', cacheProp: 'test', cacheKeyFn: 'cacheKeySet' })
56
+ @Caching.set({ cacheName: 'test-vona:caching', cacheKeyFn: 'cacheKey' })
62
57
  async set3(_id: number, value: TSummerCacheTestData): Promise<TSummerCacheTestData> {
63
58
  return value;
64
59
  }
65
60
 
66
- @Caching.del({ cacheName: 'test-vona:test', cacheProp: 'test' })
61
+ @Caching.del({ cacheName: 'test-vona:caching' })
67
62
  async del(_id: number): Promise<void> {
68
63
  // do nothing
69
64
  }
70
65
 
71
- @Caching.clear({ cacheName: 'test-vona:test' })
66
+ @Caching.clear({ cacheName: 'test-vona:caching' })
72
67
  async clear(): Promise<void> {
73
68
  // do nothing
74
69
  }
@@ -45,8 +45,11 @@ describe('caching.test.ts', () => {
45
45
  const res9 = await scopeTest.service.caching.get4(2);
46
46
  assert.equal(res9, undefined);
47
47
  // cache again
48
- const res10 = await scopeTest.service.caching.get(2);
49
- assert.equal(res10.id, 2);
48
+ const res10_1 = await scopeTest.service.caching.get(2);
49
+ assert.equal(res10_1, undefined);
50
+ await scopeTest.service.caching.del(2);
51
+ const res10_2 = await scopeTest.service.caching.get(2);
52
+ assert.equal(res10_2.id, 2);
50
53
  const res11 = await scopeTest.service.caching.get4(2);
51
54
  assert.equal(res11.id, 2);
52
55
  // clear
@@ -1,7 +1,7 @@
1
1
  import assert from 'node:assert';
2
2
  import { describe, it } from 'node:test';
3
3
  import { catchError } from '@cabloy/utils';
4
- import moment from 'moment';
4
+ import { DateTime } from 'luxon';
5
5
  import { app } from 'vona-mock';
6
6
 
7
7
  describe('database.test.ts', () => {
@@ -100,7 +100,7 @@ describe('database.test.ts', () => {
100
100
  const entityTest = scopeTest.entity.test;
101
101
  const modelTest = scopeTest.model.testDynamicTable;
102
102
  // tableName
103
- const tableName = `${entityTest.$table}_${moment().format('YYYYMMDD')}`;
103
+ const tableName = `${entityTest.$table}_${DateTime.now().toFormat('yyyyMMdd')}`;
104
104
  // create table
105
105
  await app.bean.model.createTable(tableName, table => {
106
106
  table.basicFields();
@@ -3,7 +3,7 @@ import type z from 'zod';
3
3
  import assert from 'node:assert';
4
4
  import { describe, it } from 'node:test';
5
5
  import { app } from 'vona-mock';
6
- import { getTargetDecoratorRules } from 'vona-module-a-openapi';
6
+ import { getTargetDecoratorRules } from 'vona-module-a-openapiutils';
7
7
  import { $Dto } from 'vona-module-a-orm';
8
8
  import { ModelUserStats } from 'vona-module-test-vona';
9
9
 
@@ -2,7 +2,7 @@ import type { TypeDecoratorRules } from 'vona-module-a-openapiutils';
2
2
  import assert from 'node:assert';
3
3
  import { describe, it } from 'node:test';
4
4
  import { app } from 'vona-mock';
5
- import { getTargetDecoratorRules } from 'vona-module-a-openapi';
5
+ import { getTargetDecoratorRules } from 'vona-module-a-openapiutils';
6
6
  import { $Dto, $relationDynamic } from 'vona-module-a-orm';
7
7
  import { ModelPost, ModelPostContent, ModelRole, ModelRoleUser, ModelUser } from 'vona-module-test-vona';
8
8
 
@@ -35,9 +35,9 @@ describe('dtoGet.test.ts', () => {
35
35
  },
36
36
  });
37
37
  const rules: TypeDecoratorRules = getTargetDecoratorRules(DtoPostNew.prototype);
38
- assert.equal(['string', 'number'].includes(rules.id?.type as string), true);
38
+ assert.equal(rules.id?.type === 'pipe', true);
39
39
  assert.equal(rules.title?.type === 'string', true);
40
- assert.equal(['string', 'number'].includes(rules.userId?.type as string), true);
40
+ assert.equal(rules.userId?.type === 'pipe', true);
41
41
  assert.equal(rules.iid, undefined);
42
42
  assert.equal(rules.postContent?.type === 'optional', true);
43
43
  assert.equal(rules.user?.type === 'optional', true);
@@ -3,7 +3,7 @@ import type z from 'zod';
3
3
  import assert from 'node:assert';
4
4
  import { describe, it } from 'node:test';
5
5
  import { app } from 'vona-mock';
6
- import { getTargetDecoratorRules } from 'vona-module-a-openapi';
6
+ import { getTargetDecoratorRules } from 'vona-module-a-openapiutils';
7
7
  import { $Dto } from 'vona-module-a-orm';
8
8
  import { ModelUserStatsGroup } from 'vona-module-test-vona';
9
9
 
@@ -3,7 +3,7 @@ import { describe, it } from 'node:test';
3
3
  import { OpenApiGeneratorV31, OpenAPIRegistry } from '@cabloy/zod-to-openapi';
4
4
  import { appResource, cast } from 'vona';
5
5
  import { app } from 'vona-mock';
6
- import { $schema } from 'vona-module-a-openapi';
6
+ import { $schema } from 'vona-module-a-openapiutils';
7
7
  import { DtoUserLazy } from 'vona-module-test-vona';
8
8
 
9
9
  describe('dtoLazy.test.ts', () => {
@@ -2,7 +2,7 @@ import type { TypeDecoratorRules } from 'vona-module-a-openapiutils';
2
2
  import assert from 'node:assert';
3
3
  import { describe, it } from 'node:test';
4
4
  import { app } from 'vona-mock';
5
- import { getTargetDecoratorRules } from 'vona-module-a-openapi';
5
+ import { getTargetDecoratorRules } from 'vona-module-a-openapiutils';
6
6
  import { $Dto, $relationDynamic } from 'vona-module-a-orm';
7
7
  import { ModelPost } from 'vona-module-test-vona';
8
8
 
@@ -46,7 +46,7 @@ describe('dtoMutate.test.ts', () => {
46
46
  rules = getTargetDecoratorRules(DtoPostCreate.prototype);
47
47
  assert.equal(rules.title?.type === 'string', true); // ZodOptional
48
48
  assert.equal(rules.stars?.type === 'optional', true);
49
- assert.equal(['string', 'number'].includes(rules.userId?.type as string), true);
49
+ assert.equal(rules.userId?.type === 'pipe', true);
50
50
  assert.equal(rules.postContent?.type === 'optional', true);
51
51
  assert.equal(rules.user, undefined);
52
52
  assert.equal(rules.id, undefined);
@@ -2,6 +2,7 @@ import type { IQueryParams } from 'vona-module-a-orm';
2
2
  import assert from 'node:assert';
3
3
  import { describe, it } from 'node:test';
4
4
  import { isNil } from '@cabloy/utils';
5
+ import { $customKey } from 'vona';
5
6
  import { app } from 'vona-mock';
6
7
 
7
8
  describe('dtoQuery.test.ts', () => {
@@ -9,6 +10,9 @@ describe('dtoQuery.test.ts', () => {
9
10
  await app.bean.executor.mockCtx(async () => {
10
11
  // findManyEcho
11
12
  const resEcho: IQueryParams = await app.bean.executor.performAction('get', '/test/vona/post/findManyEcho', {
13
+ headers: {
14
+ [$customKey('x-vona-tz')]: 'Asia/Tokyo',
15
+ },
12
16
  query: {
13
17
  columns: 'id,title', // ['id', 'title'],
14
18
  where: {
@@ -22,6 +26,7 @@ describe('dtoQuery.test.ts', () => {
22
26
  pageSize: 30,
23
27
  title: 'ai',
24
28
  userName: 'tom',
29
+ createdAt: '2025-12-01 - 2025-12-02',
25
30
  },
26
31
  });
27
32
  assert.deepEqual(resEcho.columns, ['id', 'title']);
@@ -29,6 +34,10 @@ describe('dtoQuery.test.ts', () => {
29
34
  'stars': { _gt_: 12 },
30
35
  'title': { _includesI_: 'ai' },
31
36
  'testVonaUser.name': { _eqI_: 'tom' },
37
+ 'createdAt': {
38
+ _gte_: new Date('2025-11-30T15:00:00.000Z'),
39
+ _lt_: new Date('2025-12-02T15:00:00.000Z'),
40
+ },
32
41
  });
33
42
  assert.deepEqual(resEcho.orders, [['testVonaPost.createdAt', 'desc']]);
34
43
  assert.equal(resEcho.offset, 30);
@@ -2,7 +2,7 @@ import assert from 'node:assert';
2
2
  import { Blob } from 'node:buffer';
3
3
  import { describe, it } from 'node:test';
4
4
  import { app } from 'vona-mock';
5
- import { $apiPath } from 'vona-module-a-web';
5
+ import { $apiPath } from 'vona-module-a-openapiutils';
6
6
 
7
7
  describe('upload.test.ts', () => {
8
8
  it('action:upload:fields', async () => {
@@ -4,7 +4,7 @@ import { describe, it } from 'node:test';
4
4
  import { catchError } from '@cabloy/utils';
5
5
  import { $Class, cast } from 'vona';
6
6
  import { app } from 'vona-mock';
7
- import { Api } from 'vona-module-a-openapi';
7
+ import { Api } from 'vona-module-a-openapiutils';
8
8
  import { Dto } from 'vona-module-a-web';
9
9
  import { DtoProfile } from '../../src/dto/profile.ts';
10
10
  import { DtoUser } from '../../src/dto/user.ts';