vona-module-test-vona 5.0.12 → 5.0.13

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 (81) hide show
  1. package/dist/.metadata/index.d.ts +551 -0
  2. package/dist/.metadata/index.js +109 -0
  3. package/dist/.metadata/this.d.ts +2 -0
  4. package/dist/.metadata/this.js +2 -0
  5. package/dist/bean/aop.regExp.d.ts +7 -0
  6. package/dist/bean/aop.regExp.js +35 -0
  7. package/dist/bean/aop.simple.d.ts +14 -0
  8. package/dist/bean/aop.simple.js +59 -0
  9. package/dist/bean/aopMethod.test.d.ts +13 -0
  10. package/dist/bean/aopMethod.test.js +42 -0
  11. package/dist/bean/bean.testCtx.d.ts +21 -0
  12. package/dist/bean/bean.testCtx.js +54 -0
  13. package/dist/bean/broadcast.test.d.ts +8 -0
  14. package/dist/bean/broadcast.test.js +23 -0
  15. package/dist/bean/cacheMem.test.d.ts +5 -0
  16. package/dist/bean/cacheMem.test.js +13 -0
  17. package/dist/bean/cacheRedis.test.d.ts +5 -0
  18. package/dist/bean/cacheRedis.test.js +13 -0
  19. package/dist/bean/event.helloEcho.d.ts +7 -0
  20. package/dist/bean/event.helloEcho.js +13 -0
  21. package/dist/bean/eventListener.helloEcho.d.ts +9 -0
  22. package/dist/bean/eventListener.helloEcho.js +19 -0
  23. package/dist/bean/meta.version.d.ts +5 -0
  24. package/dist/bean/meta.version.js +25 -0
  25. package/dist/bean/queue.test.d.ts +10 -0
  26. package/dist/bean/queue.test.js +16 -0
  27. package/dist/bean/schedule.test.d.ts +5 -0
  28. package/dist/bean/schedule.test.js +17 -0
  29. package/dist/bean/schedule.test3.d.ts +5 -0
  30. package/dist/bean/schedule.test3.js +17 -0
  31. package/dist/bean/summerCache.test.d.ts +12 -0
  32. package/dist/bean/summerCache.test.js +28 -0
  33. package/dist/config/config.d.ts +2 -0
  34. package/dist/config/config.js +3 -0
  35. package/dist/config/locale/en-us.d.ts +12 -0
  36. package/dist/config/locale/en-us.js +11 -0
  37. package/dist/config/locale/zh-cn.d.ts +10 -0
  38. package/dist/config/locale/zh-cn.js +9 -0
  39. package/dist/controller/bean.d.ts +8 -0
  40. package/dist/controller/bean.js +93 -0
  41. package/dist/controller/cacheMem.d.ts +7 -0
  42. package/dist/controller/cacheMem.js +60 -0
  43. package/dist/controller/cacheRedis.d.ts +7 -0
  44. package/dist/controller/cacheRedis.js +60 -0
  45. package/dist/controller/onion.d.ts +15 -0
  46. package/dist/controller/onion.js +132 -0
  47. package/dist/controller/passport.d.ts +16 -0
  48. package/dist/controller/passport.js +82 -0
  49. package/dist/controller/performAction.d.ts +10 -0
  50. package/dist/controller/performAction.js +35 -0
  51. package/dist/controller/queue.d.ts +8 -0
  52. package/dist/controller/queue.js +42 -0
  53. package/dist/controller/summer.d.ts +7 -0
  54. package/dist/controller/summer.js +120 -0
  55. package/dist/controller/tail.d.ts +7 -0
  56. package/dist/controller/tail.js +43 -0
  57. package/dist/controller/transaction.d.ts +8 -0
  58. package/dist/controller/transaction.js +51 -0
  59. package/dist/controller/upload.d.ts +10 -0
  60. package/dist/controller/upload.js +80 -0
  61. package/dist/dto/profile.d.ts +7 -0
  62. package/dist/dto/profile.js +27 -0
  63. package/dist/dto/user.d.ts +10 -0
  64. package/dist/dto/user.js +33 -0
  65. package/dist/entity/test.d.ts +8 -0
  66. package/dist/entity/test.js +27 -0
  67. package/dist/index.d.ts +1 -0
  68. package/dist/index.js +1 -0
  69. package/dist/model/test.d.ts +4 -0
  70. package/dist/model/test.js +14 -0
  71. package/dist/service/aopMethod.d.ts +12 -0
  72. package/dist/service/aopMethod.js +63 -0
  73. package/dist/service/test.d.ts +4 -0
  74. package/dist/service/test.js +17 -0
  75. package/dist/service/testApp.d.ts +5 -0
  76. package/dist/service/testApp.js +20 -0
  77. package/dist/service/testClass.d.ts +8 -0
  78. package/dist/service/testClass.js +22 -0
  79. package/dist/service/transaction.d.ts +5 -0
  80. package/dist/service/transaction.js +39 -0
  81. package/package.json +7 -3
@@ -0,0 +1,93 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import assert from 'node:assert';
11
+ import { BeanBase, cast } from 'vona';
12
+ import { Api } from 'vona-module-a-openapi';
13
+ import { Passport } from 'vona-module-a-user';
14
+ import { Controller, Web } from 'vona-module-a-web';
15
+ import { __ThisModule__ } from "../.metadata/this.js";
16
+ import { ServiceTest } from "../service/test.js";
17
+ let ControllerBean = class ControllerBean extends BeanBase {
18
+ async test() {
19
+ const a = 3;
20
+ const b = 4;
21
+ let res;
22
+ // app.bean
23
+ assert.equal(this.app.bean._getBean('test-vona.service.testApp'), this.app.bean['test-vona.service.testApp']);
24
+ res = this.app.bean['test-vona.service.testApp'].actionSync({ a, b });
25
+ assert.equal(res, `${a + b}:regexpaop`);
26
+ res = await this.app.bean['test-vona.service.testApp'].actionAsync({ a, b });
27
+ assert.equal(res, `${a + b}:regexpaop`);
28
+ // ctx.bean: global
29
+ assert.equal(this.bean.testCtx, this.app.bean.testCtx);
30
+ // magic
31
+ res = cast(this.bean.testCtx).magic;
32
+ assert.equal(res, 'magic:simpleaop');
33
+ // name
34
+ this.bean.testCtx.name = 'test-vona:simpleaop:regexpaop';
35
+ res = this.bean.testCtx.name;
36
+ assert.equal(res, 'test-vona:simpleaop:regexpaop');
37
+ res = this.bean.testCtx.actionSync({ a, b });
38
+ assert.equal(res, `${a + b}:simpleaop:regexpaop`);
39
+ res = await this.bean.testCtx.actionAsync({ a, b });
40
+ assert.equal(res, `${a + b}:simpleaop:regexpaop`);
41
+ res = await this.bean.testCtx.actionAsync2({ a, b });
42
+ assert.equal(res, `test-vona:simpleaop:regexpaop:${a + b}:simpleaop:regexpaop`);
43
+ res = await this.bean.testCtx.actionAsync3({ a, b });
44
+ assert.equal(res, `test-vona:simpleaop:regexpaop:${a + b}:simpleaop:regexpaop`);
45
+ // ctx.bean: class
46
+ assert.equal(this.bean['test-vona.service.testClass'], this.app.bean['test-vona.service.testClass']);
47
+ res = this.bean['test-vona.service.testClass'].actionSync({ a, b });
48
+ assert.equal(res, `${a + b}:regexpaop`);
49
+ res = await this.bean['test-vona.service.testClass'].actionAsync({ a, b });
50
+ assert.equal(res, `${a + b}:regexpaop`);
51
+ // magic of self
52
+ cast(this.bean.testCtx).magicSelf = '__magicSelf__';
53
+ res = cast(this.app.bean.testCtx).magicSelf;
54
+ assert.equal(res, '__magicSelf__');
55
+ res = cast(this.app.bean.testCtx)['magic:self'];
56
+ assert.equal(res, '__magicSelf__');
57
+ }
58
+ async service() {
59
+ let res;
60
+ // general way
61
+ res = this.bean._getBean(ServiceTest).name;
62
+ assert.equal(res, 'serviceTest');
63
+ res = this.bean._getBean('test-vona.service.test').name;
64
+ assert.equal(res, 'serviceTest');
65
+ // this scope
66
+ res = this.scope.service.test.name;
67
+ assert.equal(res, 'serviceTest');
68
+ // general scope
69
+ res = this.bean.scope(__ThisModule__).service.test.name;
70
+ assert.equal(res, 'serviceTest');
71
+ res = this.$scope.testVona.service.test.name;
72
+ assert.equal(res, 'serviceTest');
73
+ }
74
+ };
75
+ __decorate([
76
+ Web.get('test'),
77
+ __metadata("design:type", Function),
78
+ __metadata("design:paramtypes", []),
79
+ __metadata("design:returntype", Promise)
80
+ ], ControllerBean.prototype, "test", null);
81
+ __decorate([
82
+ Web.get('service'),
83
+ Passport.public(),
84
+ __metadata("design:type", Function),
85
+ __metadata("design:paramtypes", []),
86
+ __metadata("design:returntype", Promise)
87
+ ], ControllerBean.prototype, "service", null);
88
+ ControllerBean = __decorate([
89
+ Controller({ path: 'bean', meta: { mode: 'test' } }),
90
+ Api.exclude(),
91
+ Passport.public()
92
+ ], ControllerBean);
93
+ export { ControllerBean };
@@ -0,0 +1,7 @@
1
+ import type { IDecoratorControllerOptions } from 'vona-module-a-web';
2
+ import { BeanBase } from 'vona';
3
+ export interface IControllerOptionsCacheMem extends IDecoratorControllerOptions {
4
+ }
5
+ export declare class ControllerCacheMem extends BeanBase {
6
+ mem(): Promise<void>;
7
+ }
@@ -0,0 +1,60 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import assert from 'node:assert';
11
+ import { sleep } from '@cabloy/utils';
12
+ import { BeanBase, retry } from 'vona';
13
+ import { Api } from 'vona-module-a-openapi';
14
+ import { Passport } from 'vona-module-a-user';
15
+ import { Controller, Web } from 'vona-module-a-web';
16
+ let ControllerCacheMem = class ControllerCacheMem extends BeanBase {
17
+ async mem() {
18
+ let res;
19
+ let value;
20
+ // set
21
+ value = this.scope.cacheMem.test.getset('zhen.nann');
22
+ assert.equal(value, undefined);
23
+ value = this.scope.cacheMem.test.getset('zhennann');
24
+ assert.equal(value, 'zhen.nann');
25
+ // has
26
+ res = this.scope.cacheMem.test.has();
27
+ assert.equal(!!res, true);
28
+ // get
29
+ value = this.scope.cacheMem.test.get();
30
+ assert.equal(value, 'zhennann');
31
+ // del
32
+ this.scope.cacheMem.test.del();
33
+ res = this.scope.cacheMem.test.has();
34
+ assert.equal(res, false);
35
+ // set again
36
+ this.scope.cacheMem.test.set('zhennann'); // will be expired after 1s
37
+ // get
38
+ value = this.scope.cacheMem.test.get();
39
+ assert.equal(value, 'zhennann');
40
+ // peek after timeout
41
+ await sleep(900);
42
+ await retry({ retries: 3 }, async () => {
43
+ await sleep(100);
44
+ value = this.scope.cacheMem.test.peek();
45
+ assert.equal(value, undefined);
46
+ });
47
+ }
48
+ };
49
+ __decorate([
50
+ Web.post(),
51
+ __metadata("design:type", Function),
52
+ __metadata("design:paramtypes", []),
53
+ __metadata("design:returntype", Promise)
54
+ ], ControllerCacheMem.prototype, "mem", null);
55
+ ControllerCacheMem = __decorate([
56
+ Controller({ path: 'cacheMem', meta: { mode: 'test' } }),
57
+ Api.exclude(),
58
+ Passport.public()
59
+ ], ControllerCacheMem);
60
+ export { ControllerCacheMem };
@@ -0,0 +1,7 @@
1
+ import type { IDecoratorControllerOptions } from 'vona-module-a-web';
2
+ import { BeanBase } from 'vona';
3
+ export interface IControllerOptionsCacheRedis extends IDecoratorControllerOptions {
4
+ }
5
+ export declare class ControllerCacheRedis extends BeanBase {
6
+ redis(): Promise<void>;
7
+ }
@@ -0,0 +1,60 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import assert from 'node:assert';
11
+ import { sleep } from '@cabloy/utils';
12
+ import { BeanBase, retry } from 'vona';
13
+ import { Api } from 'vona-module-a-openapi';
14
+ import { Passport } from 'vona-module-a-user';
15
+ import { Controller, Web } from 'vona-module-a-web';
16
+ let ControllerCacheRedis = class ControllerCacheRedis extends BeanBase {
17
+ async redis() {
18
+ let res;
19
+ let value;
20
+ // getset
21
+ value = await this.scope.cacheRedis.test.getset('zhen.nann');
22
+ assert.equal(value, undefined);
23
+ value = await this.scope.cacheRedis.test.getset('zhennann');
24
+ assert.equal(value, 'zhen.nann');
25
+ // has
26
+ res = await this.scope.cacheRedis.test.has();
27
+ assert.equal(res, true);
28
+ // get
29
+ value = await this.scope.cacheRedis.test.get();
30
+ assert.equal(value, 'zhennann');
31
+ // del
32
+ await this.scope.cacheRedis.test.del();
33
+ res = await this.scope.cacheRedis.test.has();
34
+ assert.equal(res, false);
35
+ // set again
36
+ await this.scope.cacheRedis.test.set('zhennann'); // will be expired after 1s
37
+ // get
38
+ value = await this.scope.cacheRedis.test.get();
39
+ assert.equal(value, 'zhennann');
40
+ // peek after timeout
41
+ await sleep(900);
42
+ await retry({ retries: 3 }, async () => {
43
+ await sleep(100);
44
+ value = await this.scope.cacheRedis.test.peek();
45
+ assert.equal(value, undefined);
46
+ });
47
+ }
48
+ };
49
+ __decorate([
50
+ Web.post(),
51
+ __metadata("design:type", Function),
52
+ __metadata("design:paramtypes", []),
53
+ __metadata("design:returntype", Promise)
54
+ ], ControllerCacheRedis.prototype, "redis", null);
55
+ ControllerCacheRedis = __decorate([
56
+ Controller({ path: 'cacheRedis', meta: { mode: 'test' } }),
57
+ Api.exclude(),
58
+ Passport.public()
59
+ ], ControllerCacheRedis);
60
+ export { ControllerCacheRedis };
@@ -0,0 +1,15 @@
1
+ import type { IDecoratorControllerOptions } from 'vona-module-a-web';
2
+ import { BeanBase } from 'vona';
3
+ import '../.metadata/index.ts';
4
+ import { DtoUser } from '../dto/user.ts';
5
+ export interface IControllerOptionsOnion extends IDecoratorControllerOptions {
6
+ }
7
+ export declare class ControllerOnion extends BeanBase {
8
+ index(): boolean;
9
+ echo(id: number, temp: string, name: string, _user: DtoUser): string | undefined;
10
+ echo2(_userId: number, _userName: string, _user: DtoUser, user: DtoUser): DtoUser;
11
+ echo3(_userId: number, id: number, accept: string): string;
12
+ echo4(users: DtoUser[]): DtoUser[];
13
+ echo5(ids: number[]): number[];
14
+ echo6(): boolean;
15
+ }
@@ -0,0 +1,132 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
11
+ return function (target, key) { decorator(target, key, paramIndex); }
12
+ };
13
+ import { BeanBase } from 'vona';
14
+ import { Aspect } from 'vona-module-a-aspect';
15
+ import { Core } from 'vona-module-a-core';
16
+ import { Database, EnumTransactionIsolationLevels } from 'vona-module-a-database';
17
+ import { Api, Arg, v } from 'vona-module-a-openapi';
18
+ import { Passport } from 'vona-module-a-user';
19
+ import { Controller, Web } from 'vona-module-a-web';
20
+ import { z } from 'zod';
21
+ import { $locale } from "../.metadata/index.js";
22
+ import { DtoUser } from "../dto/user.js";
23
+ let ControllerOnion = class ControllerOnion extends BeanBase {
24
+ index() {
25
+ return this.ctx.db.inTransaction;
26
+ // return 'Hello Vona';
27
+ }
28
+ echo(id, temp, name, _user) {
29
+ return `echo: ${id}:${temp}:${name}`;
30
+ }
31
+ // echo2(@Arg.query(v.object(DtoUser, { passthrough: false, strict: false })) book: Partial<DtoUser>) {
32
+ echo2(_userId, _userName, _user, user) {
33
+ // const ctx = this.app.currentContext;
34
+ // this.$logger.silly(ctx === this.ctx);
35
+ return user;
36
+ }
37
+ echo3(_userId, id, accept) {
38
+ this.$logger.silly(this.ctx.path);
39
+ // const ctx = this.app.currentContext;
40
+ // this.$logger.silly(ctx === this.ctx);
41
+ return `${id}:${accept}`;
42
+ }
43
+ echo4(users) {
44
+ return users;
45
+ }
46
+ echo5(ids) {
47
+ // const ctx = this.app.currentContext;
48
+ // this.$logger.silly(ctx === this.ctx);
49
+ return ids;
50
+ }
51
+ echo6() {
52
+ return this.bean.passport.isAuthenticated;
53
+ }
54
+ };
55
+ __decorate([
56
+ Web.get('/'),
57
+ Aspect.aopMethod('a-database:transaction', { enable: true, meta: { mode: 'local' } }),
58
+ Aspect.guardGlobal('a-user:passport', { public: true }),
59
+ __metadata("design:type", Function),
60
+ __metadata("design:paramtypes", []),
61
+ __metadata("design:returntype", void 0)
62
+ ], ControllerOnion.prototype, "index", null);
63
+ __decorate([
64
+ Web.post('//echo'),
65
+ Aspect.guardGlobal('a-user:passport', { public: true }),
66
+ Aspect.middlewareGlobal('a-core:gate', { gate: { mode: 'local' } }),
67
+ Core.gate({ gate: { mode: 'local' } }),
68
+ Aspect.aopMethod('a-database:transaction', { isolationLevel: EnumTransactionIsolationLevels.SERIALIZABLE, readOnly: true }),
69
+ Database.transaction({ isolationLevel: EnumTransactionIsolationLevels.READ_COMMITTED, readOnly: false }),
70
+ Api.body(v.optional(), z.string()),
71
+ __param(0, Arg.query('id', v.default(0), z.number())),
72
+ __param(2, Arg.query('name', z.number().optional())),
73
+ __param(3, Arg.body(v.title($locale('User')), z.object({ id: z.number().openapi({ title: $locale('UserId') }) }))),
74
+ __metadata("design:type", Function),
75
+ __metadata("design:paramtypes", [Number, String, String, DtoUser]),
76
+ __metadata("design:returntype", Object)
77
+ ], ControllerOnion.prototype, "echo", null);
78
+ __decorate([
79
+ Web.post('echo2/:userId/:userName')
80
+ // @Aspect.middlewareGlobal('a-core:gate', { gate: { mode: 'local' } })
81
+ ,
82
+ Aspect.guardGlobal('a-user:passport', { public: true })
83
+ // echo2(@Arg.query(v.object(DtoUser, { passthrough: false, strict: false })) book: Partial<DtoUser>) {
84
+ ,
85
+ __param(0, Arg.param('userId', v.title($locale('UserId')), v.example('example:1'))),
86
+ __param(1, Arg.param('userName', v.title($locale('UserId')), v.example('example:1'))),
87
+ __param(2, Arg.query(DtoUser)),
88
+ __param(3, Arg.body(v.title($locale('User')), z.object({ id: z.number().openapi({ title: $locale('UserId') }) }))),
89
+ __metadata("design:type", Function),
90
+ __metadata("design:paramtypes", [Number, String, DtoUser,
91
+ DtoUser]),
92
+ __metadata("design:returntype", DtoUser)
93
+ ], ControllerOnion.prototype, "echo2", null);
94
+ __decorate([
95
+ Web.get('echo3/:userId'),
96
+ Aspect.guardGlobal('a-user:passport', { public: true }),
97
+ __param(0, Arg.param('userId')),
98
+ __param(1, Arg.query('id', v.optional())),
99
+ __param(2, Arg.headers('Accept', v.title($locale('UserId')))),
100
+ __metadata("design:type", Function),
101
+ __metadata("design:paramtypes", [Number, Number, String]),
102
+ __metadata("design:returntype", void 0)
103
+ ], ControllerOnion.prototype, "echo3", null);
104
+ __decorate([
105
+ Web.post('echo4'),
106
+ Aspect.guardGlobal('a-user:passport', { public: true }),
107
+ Aspect.filterGlobal('a-error:error', { enable: true, logs: { 422: true } }),
108
+ Api.body(v.array(DtoUser)),
109
+ __param(0, Arg.body(v.optional(), v.array(), v.object(DtoUser))),
110
+ __metadata("design:type", Function),
111
+ __metadata("design:paramtypes", [Array]),
112
+ __metadata("design:returntype", Array)
113
+ ], ControllerOnion.prototype, "echo4", null);
114
+ __decorate([
115
+ Web.get('echo5'),
116
+ Passport.public(),
117
+ __param(0, Arg.query('ids', v.default([1]), v.array(Number, { separator: '-' }))),
118
+ __metadata("design:type", Function),
119
+ __metadata("design:paramtypes", [Array]),
120
+ __metadata("design:returntype", void 0)
121
+ ], ControllerOnion.prototype, "echo5", null);
122
+ __decorate([
123
+ Web.get('echo6'),
124
+ Passport.admin(),
125
+ __metadata("design:type", Function),
126
+ __metadata("design:paramtypes", []),
127
+ __metadata("design:returntype", void 0)
128
+ ], ControllerOnion.prototype, "echo6", null);
129
+ ControllerOnion = __decorate([
130
+ Controller({ path: 'onion', tags: ['Onion'], meta: { mode: ['local', 'test'] } })
131
+ ], ControllerOnion);
132
+ export { ControllerOnion };
@@ -0,0 +1,16 @@
1
+ import type { IJwtToken } from 'vona-module-a-jwt';
2
+ import type { IUserBase } from 'vona-module-a-user';
3
+ import type { IDecoratorControllerOptions } from 'vona-module-a-web';
4
+ import { BeanBase } from 'vona';
5
+ export interface IControllerOptionsPassport extends IDecoratorControllerOptions {
6
+ }
7
+ export declare class ControllerPassport extends BeanBase {
8
+ echo(name: string, user: IUserBase): {
9
+ name: string;
10
+ user: IUserBase;
11
+ };
12
+ login(name: string): Promise<IJwtToken>;
13
+ isAuthenticated(): boolean;
14
+ refresh(refreshToken: string): Promise<IJwtToken>;
15
+ logout(): Promise<void>;
16
+ }
@@ -0,0 +1,82 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
11
+ return function (target, key) { decorator(target, key, paramIndex); }
12
+ };
13
+ import assert from 'node:assert';
14
+ import { BeanBase } from 'vona';
15
+ import { DtoJwtToken } from 'vona-module-a-jwt';
16
+ import { Api, Arg, v } from 'vona-module-a-openapi';
17
+ import { $getUserName, Passport } from 'vona-module-a-user';
18
+ import { Controller, Web } from 'vona-module-a-web';
19
+ let ControllerPassport = class ControllerPassport extends BeanBase {
20
+ echo(name, user) {
21
+ assert.equal(name, 'admin');
22
+ assert.equal($getUserName(user), 'admin');
23
+ return { name, user };
24
+ }
25
+ async login(name) {
26
+ const jwt = await this.bean.passport.signinMock(name);
27
+ return jwt;
28
+ }
29
+ isAuthenticated() {
30
+ return this.bean.passport.isAuthenticated;
31
+ }
32
+ async refresh(refreshToken) {
33
+ return await this.bean.passport.refreshAuthToken(refreshToken);
34
+ }
35
+ async logout() {
36
+ return await this.bean.passport.signout();
37
+ }
38
+ };
39
+ __decorate([
40
+ Web.get('echo/:name'),
41
+ Passport.public(),
42
+ __param(0, Arg.param('name')),
43
+ __param(1, Arg.user()),
44
+ __metadata("design:type", Function),
45
+ __metadata("design:paramtypes", [String, Object]),
46
+ __metadata("design:returntype", void 0)
47
+ ], ControllerPassport.prototype, "echo", null);
48
+ __decorate([
49
+ Web.post('login'),
50
+ Api.body(v.object(DtoJwtToken)),
51
+ Passport.public(),
52
+ __param(0, Arg.body('name')),
53
+ __metadata("design:type", Function),
54
+ __metadata("design:paramtypes", [String]),
55
+ __metadata("design:returntype", Promise)
56
+ ], ControllerPassport.prototype, "login", null);
57
+ __decorate([
58
+ Web.get('isAuthenticated'),
59
+ __metadata("design:type", Function),
60
+ __metadata("design:paramtypes", []),
61
+ __metadata("design:returntype", Boolean)
62
+ ], ControllerPassport.prototype, "isAuthenticated", null);
63
+ __decorate([
64
+ Web.post('refresh'),
65
+ Api.body(v.object(DtoJwtToken)),
66
+ Passport.public(),
67
+ __param(0, Arg.body('refreshToken')),
68
+ __metadata("design:type", Function),
69
+ __metadata("design:paramtypes", [String]),
70
+ __metadata("design:returntype", Promise)
71
+ ], ControllerPassport.prototype, "refresh", null);
72
+ __decorate([
73
+ Web.post('logout'),
74
+ __metadata("design:type", Function),
75
+ __metadata("design:paramtypes", []),
76
+ __metadata("design:returntype", Promise)
77
+ ], ControllerPassport.prototype, "logout", null);
78
+ ControllerPassport = __decorate([
79
+ Controller({ path: 'passport', meta: { mode: 'test' } }),
80
+ Api.exclude()
81
+ ], ControllerPassport);
82
+ export { ControllerPassport };
@@ -0,0 +1,10 @@
1
+ import type { IDecoratorControllerOptions } from 'vona-module-a-web';
2
+ import { BeanBase } from 'vona';
3
+ export interface IControllerOptionsPerformAction extends IDecoratorControllerOptions {
4
+ }
5
+ export declare class ControllerPerformAction extends BeanBase {
6
+ echo(id: number): {
7
+ id: number;
8
+ url: string;
9
+ };
10
+ }
@@ -0,0 +1,35 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
11
+ return function (target, key) { decorator(target, key, paramIndex); }
12
+ };
13
+ import { BeanBase } from 'vona';
14
+ import { Api, Arg } from 'vona-module-a-openapi';
15
+ import { Passport } from 'vona-module-a-user';
16
+ import { Controller, Web } from 'vona-module-a-web';
17
+ let ControllerPerformAction = class ControllerPerformAction extends BeanBase {
18
+ echo(id) {
19
+ const url = this.scope.util.combineApiPath('performAction/echo');
20
+ return { id, url };
21
+ }
22
+ };
23
+ __decorate([
24
+ Web.post('echo'),
25
+ Passport.public(),
26
+ __param(0, Arg.body('id')),
27
+ __metadata("design:type", Function),
28
+ __metadata("design:paramtypes", [Number]),
29
+ __metadata("design:returntype", void 0)
30
+ ], ControllerPerformAction.prototype, "echo", null);
31
+ ControllerPerformAction = __decorate([
32
+ Controller({ path: 'performAction', meta: { mode: 'test' } }),
33
+ Api.exclude()
34
+ ], ControllerPerformAction);
35
+ export { ControllerPerformAction };
@@ -0,0 +1,8 @@
1
+ import type { IDecoratorControllerOptions } from 'vona-module-a-web';
2
+ import { BeanBase } from 'vona';
3
+ export interface IControllerOptionsQueue extends IDecoratorControllerOptions {
4
+ }
5
+ export declare class ControllerQueue extends BeanBase {
6
+ pushAsync(): Promise<void>;
7
+ push(): void;
8
+ }
@@ -0,0 +1,42 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import assert from 'node:assert';
11
+ import { BeanBase } from 'vona';
12
+ import { Api } from 'vona-module-a-openapi';
13
+ import { Passport } from 'vona-module-a-user';
14
+ import { Controller, Web } from 'vona-module-a-web';
15
+ let ControllerQueue = class ControllerQueue extends BeanBase {
16
+ async pushAsync() {
17
+ const res = await this.scope.queue.test.pushAsync({ a: 1, b: 2 });
18
+ assert.equal(res, 3);
19
+ }
20
+ push() {
21
+ this.scope.queue.test.push({ a: 1, b: 2 });
22
+ }
23
+ };
24
+ __decorate([
25
+ Web.post('pushAsync'),
26
+ Passport.public(),
27
+ __metadata("design:type", Function),
28
+ __metadata("design:paramtypes", []),
29
+ __metadata("design:returntype", Promise)
30
+ ], ControllerQueue.prototype, "pushAsync", null);
31
+ __decorate([
32
+ Web.post('push'),
33
+ Passport.public(),
34
+ __metadata("design:type", Function),
35
+ __metadata("design:paramtypes", []),
36
+ __metadata("design:returntype", void 0)
37
+ ], ControllerQueue.prototype, "push", null);
38
+ ControllerQueue = __decorate([
39
+ Controller({ path: 'queue', meta: { mode: 'test' } }),
40
+ Api.exclude()
41
+ ], ControllerQueue);
42
+ export { ControllerQueue };
@@ -0,0 +1,7 @@
1
+ import type { IDecoratorControllerOptions } from 'vona-module-a-web';
2
+ import { BeanBase } from 'vona';
3
+ export interface IControllerOptionsSummer extends IDecoratorControllerOptions {
4
+ }
5
+ export declare class ControllerSummer extends BeanBase {
6
+ test(): Promise<void>;
7
+ }