vona-module-test-vona 5.0.49 → 5.0.51
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 +8 -0
- package/dist/controller/order.d.ts +5 -1
- package/dist/controller/post.d.ts +22 -21
- package/dist/dto/orderCreate.d.ts +1 -1
- package/dist/dto/orderQuery.d.ts +9 -0
- package/dist/dto/orderUpdate.d.ts +1 -1
- package/dist/dto/postCreate.d.ts +1 -1
- package/dist/dto/signin.d.ts +2 -0
- package/dist/dto/userCreate.d.ts +1 -1
- package/dist/dto/userUpdate.d.ts +1 -1
- package/dist/index.js +384 -329
- package/dist/service/post.d.ts +21 -21
- package/package.json +1 -1
- package/src/.metadata/index.ts +9 -0
- package/src/config/locale/en-us.ts +1 -1
- package/src/config/locale/zh-cn.ts +1 -1
- package/src/controller/captcha.ts +2 -2
- package/src/controller/onion.ts +1 -1
- package/src/controller/order.ts +25 -3
- package/src/controller/passport.ts +2 -2
- package/src/controller/post.ts +5 -4
- package/src/controller/tail.ts +2 -2
- package/src/controller/upload.ts +4 -5
- package/src/dto/orderQuery.ts +28 -0
- package/src/dto/postQuery.ts +7 -8
- package/src/dto/signin.ts +4 -0
- package/test/authSimple.test.ts +1 -0
- package/test/captcha.test.ts +49 -2
- package/test/database/dtoAggregate.test.ts +14 -11
- package/test/database/dtoGet.test.ts +10 -9
- package/test/database/dtoGroup.test.ts +15 -12
- package/test/database/dtoLazy.test.ts +1 -1
- package/test/database/dtoMutate.test.ts +10 -9
- package/test/database/dtoQuery.test.ts +3 -2
- package/test/database/modelWhere.test.ts +1 -0
- package/test/mail.test.ts +14 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { TypeDecoratorRules } from 'vona-module-a-openapiutils';
|
|
1
2
|
import assert from 'node:assert';
|
|
2
3
|
import { describe, it } from 'node:test';
|
|
3
4
|
import { app } from 'vona-mock';
|
|
@@ -12,15 +13,15 @@ describe('dtoMutate.test.ts', () => {
|
|
|
12
13
|
const DtoUserCreate = $Dto.create('test-vona:user', {
|
|
13
14
|
include: { posts: true },
|
|
14
15
|
});
|
|
15
|
-
let rules:
|
|
16
|
+
let rules: TypeDecoratorRules;
|
|
16
17
|
rules = getTargetDecoratorRules(DtoUserCreate.prototype);
|
|
17
|
-
assert.equal(rules.name
|
|
18
|
+
assert.equal(rules.name?.type === 'string', true);
|
|
18
19
|
assert.equal(rules.id, undefined);
|
|
19
20
|
assert.equal(rules.iid, undefined);
|
|
20
21
|
assert.equal(rules.deleted, undefined);
|
|
21
22
|
assert.equal(rules.createdAt, undefined);
|
|
22
23
|
assert.equal(rules.updatedAt, undefined);
|
|
23
|
-
assert.equal(rules.posts
|
|
24
|
+
assert.equal(rules.posts?.type === 'optional', true);
|
|
24
25
|
// update
|
|
25
26
|
const DtoUserUpdate = $Dto.update('test-vona:user', {
|
|
26
27
|
with: {
|
|
@@ -28,13 +29,13 @@ describe('dtoMutate.test.ts', () => {
|
|
|
28
29
|
},
|
|
29
30
|
});
|
|
30
31
|
rules = getTargetDecoratorRules(DtoUserUpdate.prototype);
|
|
31
|
-
assert.equal(rules.name
|
|
32
|
+
assert.equal(rules.name?.type === 'string', true); // ZodOptional
|
|
32
33
|
assert.equal(rules.id, undefined);
|
|
33
34
|
assert.equal(rules.iid, undefined);
|
|
34
35
|
assert.equal(rules.deleted, undefined);
|
|
35
36
|
assert.equal(rules.createdAt, undefined);
|
|
36
37
|
assert.equal(rules.updatedAt, undefined);
|
|
37
|
-
assert.equal(rules.posts
|
|
38
|
+
assert.equal(rules.posts?.type === 'optional', true);
|
|
38
39
|
// create: not mutate post(belongsTo)
|
|
39
40
|
const DtoPostCreate = $Dto.create('test-vona:post', {
|
|
40
41
|
include: {
|
|
@@ -43,10 +44,10 @@ describe('dtoMutate.test.ts', () => {
|
|
|
43
44
|
},
|
|
44
45
|
});
|
|
45
46
|
rules = getTargetDecoratorRules(DtoPostCreate.prototype);
|
|
46
|
-
assert.equal(rules.title
|
|
47
|
-
assert.equal(rules.stars
|
|
48
|
-
assert.equal(['
|
|
49
|
-
assert.equal(rules.postContent
|
|
47
|
+
assert.equal(rules.title?.type === 'string', true); // ZodOptional
|
|
48
|
+
assert.equal(rules.stars?.type === 'optional', true);
|
|
49
|
+
assert.equal(['string', 'number'].includes(rules.userId?.type as string), true);
|
|
50
|
+
assert.equal(rules.postContent?.type === 'optional', true);
|
|
50
51
|
assert.equal(rules.user, undefined);
|
|
51
52
|
assert.equal(rules.id, undefined);
|
|
52
53
|
});
|
|
@@ -16,7 +16,8 @@ describe('dtoQuery.test.ts', () => {
|
|
|
16
16
|
_gt_: 12,
|
|
17
17
|
},
|
|
18
18
|
},
|
|
19
|
-
orders: [['
|
|
19
|
+
// orders: [['userName', 'asc']],
|
|
20
|
+
// orders: [['testVonaPost.createdAt', 'asc']],
|
|
20
21
|
pageNo: 2,
|
|
21
22
|
pageSize: 30,
|
|
22
23
|
title: 'ai',
|
|
@@ -27,7 +28,7 @@ describe('dtoQuery.test.ts', () => {
|
|
|
27
28
|
assert.deepEqual(resEcho.where, {
|
|
28
29
|
'stars': { _gt_: 12 },
|
|
29
30
|
'title': { _includesI_: 'ai' },
|
|
30
|
-
'testVonaUser.name': 'tom',
|
|
31
|
+
'testVonaUser.name': { _eqI_: 'tom' },
|
|
31
32
|
});
|
|
32
33
|
assert.deepEqual(resEcho.orders, [['testVonaPost.createdAt', 'desc']]);
|
|
33
34
|
assert.equal(resEcho.offset, 30);
|
|
@@ -6,6 +6,7 @@ import { app } from 'vona-mock';
|
|
|
6
6
|
describe('modelWhere.test.ts', () => {
|
|
7
7
|
it('action:modelWhere', async () => {
|
|
8
8
|
await app.bean.executor.mockCtx(async () => {
|
|
9
|
+
if (app.bean.database.current.dialectName !== 'pg') return;
|
|
9
10
|
const scopeTest = app.bean.scope('test-vona');
|
|
10
11
|
// ref
|
|
11
12
|
let builder = scopeTest.model.post.builder();
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { describe, it } from 'node:test';
|
|
2
|
+
import { app } from 'vona-mock';
|
|
3
|
+
|
|
4
|
+
describe('mail.test.ts', () => {
|
|
5
|
+
it('action:mail', async () => {
|
|
6
|
+
await app.bean.executor.mockCtx(async () => {
|
|
7
|
+
await app.bean.mail.send({
|
|
8
|
+
to: 'someone@cabloy.com',
|
|
9
|
+
subject: 'this is a test mail',
|
|
10
|
+
text: 'message body!',
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
});
|