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.
- package/dist/.metadata/index.d.ts +11 -0
- package/dist/bean/summerCache.caching.d.ts +12 -0
- package/dist/bean/summerCache.test.d.ts +1 -1
- package/dist/controller/order.d.ts +5 -5
- package/dist/controller/post.d.ts +6 -7
- package/dist/dto/orderCreate.d.ts +1 -1
- package/dist/dto/orderQueryPage.d.ts +1 -1
- package/dist/dto/orderUpdate.d.ts +1 -1
- package/dist/dto/postCreate.d.ts +1 -1
- package/dist/dto/postQuery.d.ts +1 -0
- package/dist/dto/userCreate.d.ts +1 -1
- package/dist/dto/userUpdate.d.ts +1 -1
- package/dist/index.js +299 -295
- package/dist/service/caching.d.ts +3 -4
- package/dist/service/post.d.ts +5 -5
- package/package.json +1 -1
- package/src/.metadata/index.ts +17 -2
- package/src/bean/summerCache.caching.ts +29 -0
- package/src/bean/summerCache.test.ts +4 -4
- package/src/controller/bean.ts +1 -1
- package/src/controller/cacheMem.ts +1 -1
- package/src/controller/cacheRedis.ts +1 -1
- package/src/controller/dtoTest.ts +1 -1
- package/src/controller/onion.ts +1 -1
- package/src/controller/order.ts +4 -13
- package/src/controller/passport.ts +1 -1
- package/src/controller/performAction.ts +1 -1
- package/src/controller/post.ts +4 -8
- package/src/controller/queue.ts +1 -1
- package/src/controller/serializer.ts +1 -1
- package/src/controller/summer.ts +3 -3
- package/src/controller/tail.ts +1 -1
- package/src/controller/transaction.ts +1 -1
- package/src/controller/upload.ts +1 -1
- package/src/dto/orderQuery.ts +7 -10
- package/src/dto/orderQueryPage.ts +1 -1
- package/src/dto/postQuery.ts +10 -6
- package/src/dto/profile.ts +1 -1
- package/src/dto/roleLazy.ts +1 -1
- package/src/dto/serializerArray.ts +1 -1
- package/src/dto/serializerLazy.ts +1 -1
- package/src/dto/serializerSimple.ts +1 -1
- package/src/dto/signin.ts +1 -1
- package/src/dto/user.ts +1 -1
- package/src/dto/userLazy.ts +1 -1
- package/src/entity/category.ts +1 -1
- package/src/entity/order.ts +1 -1
- package/src/entity/post.ts +1 -1
- package/src/entity/postContent.ts +1 -1
- package/src/entity/product.ts +1 -1
- package/src/entity/role.ts +1 -1
- package/src/entity/roleUser.ts +1 -1
- package/src/entity/test.ts +1 -1
- package/src/entity/user.ts +1 -1
- package/src/model/testDynamicTable.ts +2 -2
- package/src/service/caching.ts +16 -21
- package/test/cache/caching.test.ts +5 -2
- package/test/database/database.test.ts +2 -2
- package/test/database/dtoAggregate.test.ts +1 -1
- package/test/database/dtoGet.test.ts +3 -3
- package/test/database/dtoGroup.test.ts +1 -1
- package/test/database/dtoLazy.test.ts +1 -1
- package/test/database/dtoMutate.test.ts +2 -2
- package/test/database/dtoQuery.test.ts +9 -0
- package/test/upload.test.ts +1 -1
- package/test/utils/mappedTypes.test.ts +1 -1
package/src/service/caching.ts
CHANGED
|
@@ -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,
|
|
9
|
-
return
|
|
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(
|
|
15
|
-
return
|
|
13
|
+
cacheKey(info: ICachingActionKeyInfo, _options: TypeCachingActionOptions) {
|
|
14
|
+
return info.args[0];
|
|
16
15
|
}
|
|
17
16
|
|
|
18
|
-
|
|
19
|
-
return
|
|
17
|
+
cacheValue(info: ICachingActionValueInfo, _options: TypeCachingActionOptions) {
|
|
18
|
+
return info.args[1];
|
|
20
19
|
}
|
|
21
20
|
|
|
22
|
-
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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
|
|
49
|
-
assert.equal(
|
|
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
|
|
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}_${
|
|
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-
|
|
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-
|
|
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(
|
|
38
|
+
assert.equal(rules.id?.type === 'pipe', true);
|
|
39
39
|
assert.equal(rules.title?.type === 'string', true);
|
|
40
|
-
assert.equal(
|
|
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-
|
|
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-
|
|
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-
|
|
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(
|
|
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);
|
package/test/upload.test.ts
CHANGED
|
@@ -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-
|
|
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-
|
|
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';
|