vona-module-test-vona 5.0.13 → 5.0.14
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/index.js +1220 -1
- package/package.json +2 -2
- package/dist/.metadata/index.js +0 -109
- package/dist/.metadata/this.js +0 -2
- package/dist/bean/aop.regExp.js +0 -35
- package/dist/bean/aop.simple.js +0 -59
- package/dist/bean/aopMethod.test.js +0 -42
- package/dist/bean/bean.testCtx.js +0 -54
- package/dist/bean/broadcast.test.js +0 -23
- package/dist/bean/cacheMem.test.js +0 -13
- package/dist/bean/cacheRedis.test.js +0 -13
- package/dist/bean/event.helloEcho.js +0 -13
- package/dist/bean/eventListener.helloEcho.js +0 -19
- package/dist/bean/meta.version.js +0 -25
- package/dist/bean/queue.test.js +0 -16
- package/dist/bean/schedule.test.js +0 -17
- package/dist/bean/schedule.test3.js +0 -17
- package/dist/bean/summerCache.test.js +0 -28
- package/dist/config/config.js +0 -3
- package/dist/config/locale/en-us.js +0 -11
- package/dist/config/locale/zh-cn.js +0 -9
- package/dist/controller/bean.js +0 -93
- package/dist/controller/cacheMem.js +0 -60
- package/dist/controller/cacheRedis.js +0 -60
- package/dist/controller/onion.js +0 -132
- package/dist/controller/passport.js +0 -82
- package/dist/controller/performAction.js +0 -35
- package/dist/controller/queue.js +0 -42
- package/dist/controller/summer.js +0 -120
- package/dist/controller/tail.js +0 -43
- package/dist/controller/transaction.js +0 -51
- package/dist/controller/upload.js +0 -80
- package/dist/dto/profile.js +0 -27
- package/dist/dto/user.js +0 -33
- package/dist/entity/test.js +0 -27
- package/dist/model/test.js +0 -14
- package/dist/service/aopMethod.js +0 -63
- package/dist/service/test.js +0 -17
- package/dist/service/testApp.js +0 -20
- package/dist/service/testClass.js +0 -22
- package/dist/service/transaction.js +0 -39
package/dist/index.js
CHANGED
|
@@ -1 +1,1220 @@
|
|
|
1
|
-
|
|
1
|
+
import { BeanInfo, BeanAopBase, BeanAopMethodBase, BeanBase, cast, retry, BeanScopeBase } from 'vona';
|
|
2
|
+
import { Bean, Scope } from 'vona-module-a-bean';
|
|
3
|
+
import { Aop, AopMethod, Aspect } from 'vona-module-a-aspect';
|
|
4
|
+
import assert from 'node:assert';
|
|
5
|
+
import { Broadcast, BeanBroadcastBase } from 'vona-module-a-broadcast';
|
|
6
|
+
import { CacheMem, BeanCacheMemBase, CacheRedis, BeanCacheRedisBase } from 'vona-module-a-cache';
|
|
7
|
+
import { Event, BeanEventBase, EventListener } from 'vona-module-a-event';
|
|
8
|
+
import { Meta } from 'vona-module-a-meta';
|
|
9
|
+
import { Queue, BeanQueueBase } from 'vona-module-a-queue';
|
|
10
|
+
import { Schedule } from 'vona-module-a-schedule';
|
|
11
|
+
import { SummerCache, BeanSummerCacheBase } from 'vona-module-a-summer';
|
|
12
|
+
import { Api, v, Arg } from 'vona-module-a-openapi';
|
|
13
|
+
import { Passport, $getUserName } from 'vona-module-a-user';
|
|
14
|
+
import { Service, Controller, Web, Dto } from 'vona-module-a-web';
|
|
15
|
+
import { sleep } from '@cabloy/utils';
|
|
16
|
+
import { Core } from 'vona-module-a-core';
|
|
17
|
+
import { EnumTransactionIsolationLevels, Database, Entity, EntityBase, Model, BeanModelBase } from 'vona-module-a-database';
|
|
18
|
+
import { z } from 'zod';
|
|
19
|
+
import { DtoJwtToken } from 'vona-module-a-jwt';
|
|
20
|
+
import { SymbolUploadValue } from 'vona-module-a-upload';
|
|
21
|
+
|
|
22
|
+
var locale_en_us = {
|
|
23
|
+
User: 'User',
|
|
24
|
+
UserId: 'User Id',
|
|
25
|
+
TestHelloWorld: 'Hello World',
|
|
26
|
+
TestApples: '%d apples',
|
|
27
|
+
TestApples_0: 'no apples',
|
|
28
|
+
TestApples_1: 'one apple',
|
|
29
|
+
TestNameApples_: '%s has %d apples',
|
|
30
|
+
TestNameApples_0_1: '%s has no apples',
|
|
31
|
+
TestNameApples_1_1: '%s has one apple'
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
var locale_zh_cn = {
|
|
35
|
+
User: '用户',
|
|
36
|
+
UserId: '用户Id',
|
|
37
|
+
TestHelloWorld: '您好,世界',
|
|
38
|
+
TestApples: '%d个苹果',
|
|
39
|
+
TestApples_0: '没有苹果',
|
|
40
|
+
TestNameApples_: '%s有%d个苹果',
|
|
41
|
+
TestNameApples_0_1: '%s没有苹果'
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
var _dec$y, _dec2$y, _class$y;
|
|
45
|
+
let AopRegExp = (_dec$y = Aop({
|
|
46
|
+
match: [/^test-vona\.service\.test\w+$/, 'testCtx'],
|
|
47
|
+
meta: {
|
|
48
|
+
mode: 'test'
|
|
49
|
+
}
|
|
50
|
+
}), _dec2$y = BeanInfo({
|
|
51
|
+
module: "test-vona"
|
|
52
|
+
}), _dec$y(_class$y = _dec2$y(_class$y = class AopRegExp extends BeanAopBase {
|
|
53
|
+
__get_name__(next) {
|
|
54
|
+
const value = next();
|
|
55
|
+
return `${value}:regexpaop`;
|
|
56
|
+
}
|
|
57
|
+
__set_name__(value, next) {
|
|
58
|
+
const parts = value.split(':');
|
|
59
|
+
const index = parts.indexOf('regexpaop');
|
|
60
|
+
if (index > -1) {
|
|
61
|
+
parts.splice(index, 1);
|
|
62
|
+
}
|
|
63
|
+
value = parts.join(':');
|
|
64
|
+
return next(value);
|
|
65
|
+
}
|
|
66
|
+
actionSync(_args, next) {
|
|
67
|
+
const result = next();
|
|
68
|
+
return `${result}:regexpaop`;
|
|
69
|
+
}
|
|
70
|
+
async actionAsync(_args, next) {
|
|
71
|
+
const result = await next();
|
|
72
|
+
return `${result}:regexpaop`;
|
|
73
|
+
}
|
|
74
|
+
}) || _class$y) || _class$y);
|
|
75
|
+
|
|
76
|
+
var _dec$x, _dec2$x, _class$x;
|
|
77
|
+
class AopSimpleBase extends BeanAopBase {
|
|
78
|
+
actionSync(_args, next) {
|
|
79
|
+
const result = next();
|
|
80
|
+
return `${result}:simpleaop`;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
let AopSimple = (_dec$x = Aop({
|
|
84
|
+
match: 'testCtx',
|
|
85
|
+
dependencies: 'test-vona:regExp',
|
|
86
|
+
meta: {
|
|
87
|
+
mode: 'test'
|
|
88
|
+
}
|
|
89
|
+
}), _dec2$x = BeanInfo({
|
|
90
|
+
module: "test-vona"
|
|
91
|
+
}), _dec$x(_class$x = _dec2$x(_class$x = class AopSimple extends AopSimpleBase {
|
|
92
|
+
// magic
|
|
93
|
+
__get__(prop, next) {
|
|
94
|
+
const value = next();
|
|
95
|
+
if (prop === 'magic') {
|
|
96
|
+
return 'magic:simpleaop';
|
|
97
|
+
}
|
|
98
|
+
if (prop === 'name') {
|
|
99
|
+
return `${value}:simpleaop`;
|
|
100
|
+
}
|
|
101
|
+
return value;
|
|
102
|
+
}
|
|
103
|
+
__set__(prop, value, next) {
|
|
104
|
+
if (prop === 'name') {
|
|
105
|
+
const parts = value.split(':');
|
|
106
|
+
const index = parts.indexOf('simpleaop');
|
|
107
|
+
if (index > -1) {
|
|
108
|
+
parts.splice(index, 1);
|
|
109
|
+
}
|
|
110
|
+
value = parts.join(':');
|
|
111
|
+
}
|
|
112
|
+
return next(value);
|
|
113
|
+
}
|
|
114
|
+
__get_name__(next) {
|
|
115
|
+
const value = next();
|
|
116
|
+
return `${value}:simpleaop`;
|
|
117
|
+
}
|
|
118
|
+
__set_name__(value, next) {
|
|
119
|
+
const parts = value.split(':');
|
|
120
|
+
const index = parts.indexOf('simpleaop');
|
|
121
|
+
if (index > -1) {
|
|
122
|
+
parts.splice(index, 1);
|
|
123
|
+
}
|
|
124
|
+
value = parts.join(':');
|
|
125
|
+
return next(value);
|
|
126
|
+
}
|
|
127
|
+
async actionAsync(_args, next, _receiver) {
|
|
128
|
+
const result = await next();
|
|
129
|
+
return `${result}:simpleaop`;
|
|
130
|
+
}
|
|
131
|
+
}) || _class$x) || _class$x);
|
|
132
|
+
|
|
133
|
+
var _dec$w, _dec2$w, _class$w;
|
|
134
|
+
let AopMethodTest = (_dec$w = AopMethod({
|
|
135
|
+
wrapper: ''
|
|
136
|
+
}), _dec2$w = BeanInfo({
|
|
137
|
+
module: "test-vona"
|
|
138
|
+
}), _dec$w(_class$w = _dec2$w(_class$w = class AopMethodTest extends BeanAopMethodBase {
|
|
139
|
+
get(options, next, _receiver, _prop) {
|
|
140
|
+
const res = next();
|
|
141
|
+
return this._wrapper(options.wrapper, res);
|
|
142
|
+
}
|
|
143
|
+
set(options, value, next, _receiver, _prop) {
|
|
144
|
+
return next(this._unwrapper(options.wrapper, value));
|
|
145
|
+
}
|
|
146
|
+
execute(options, _args, next, _receiver, _prop) {
|
|
147
|
+
const res = next();
|
|
148
|
+
if (res?.then) {
|
|
149
|
+
return res.then(res => {
|
|
150
|
+
return this._wrapper(options.wrapper, res);
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
return this._wrapper(options.wrapper, res);
|
|
154
|
+
}
|
|
155
|
+
_wrapper(wrapper, data) {
|
|
156
|
+
return `${wrapper}${data}${wrapper}`;
|
|
157
|
+
}
|
|
158
|
+
_unwrapper(wrapper, data) {
|
|
159
|
+
let index = data.indexOf(wrapper);
|
|
160
|
+
if (index === 0) data = data.substring(wrapper.length);
|
|
161
|
+
index = data.lastIndexOf(wrapper);
|
|
162
|
+
if (index === data.length - wrapper.length) data = data.substring(0, index);
|
|
163
|
+
return data;
|
|
164
|
+
}
|
|
165
|
+
}) || _class$w) || _class$w);
|
|
166
|
+
|
|
167
|
+
var _dec$v, _dec2$v, _class$v;
|
|
168
|
+
class TestCtx0 extends BeanBase {
|
|
169
|
+
constructor(...args) {
|
|
170
|
+
super(...args);
|
|
171
|
+
this._name = void 0;
|
|
172
|
+
}
|
|
173
|
+
__init__(moduleName) {
|
|
174
|
+
this._name = moduleName;
|
|
175
|
+
}
|
|
176
|
+
__get__(prop) {
|
|
177
|
+
if (prop === 'magicSelf') {
|
|
178
|
+
return this['magic:self'];
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
__set__(prop, value) {
|
|
182
|
+
if (prop === 'magicSelf') {
|
|
183
|
+
this['magic:self'] = value;
|
|
184
|
+
return true;
|
|
185
|
+
}
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
188
|
+
get name() {
|
|
189
|
+
return this._name;
|
|
190
|
+
}
|
|
191
|
+
set name(value) {
|
|
192
|
+
this._name = value;
|
|
193
|
+
}
|
|
194
|
+
actionSync({
|
|
195
|
+
a,
|
|
196
|
+
b
|
|
197
|
+
}) {
|
|
198
|
+
return a + b;
|
|
199
|
+
}
|
|
200
|
+
async actionAsync({
|
|
201
|
+
a,
|
|
202
|
+
b
|
|
203
|
+
}) {
|
|
204
|
+
return Promise.resolve(a + b);
|
|
205
|
+
}
|
|
206
|
+
async actionAsync2({
|
|
207
|
+
a,
|
|
208
|
+
b
|
|
209
|
+
}) {
|
|
210
|
+
const name = this.name;
|
|
211
|
+
const value = await this.actionAsync({
|
|
212
|
+
a,
|
|
213
|
+
b
|
|
214
|
+
});
|
|
215
|
+
return `${name}:${value}`;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
class TestCtx1 extends TestCtx0 {
|
|
219
|
+
async actionAsync3({
|
|
220
|
+
a,
|
|
221
|
+
b
|
|
222
|
+
}) {
|
|
223
|
+
return await this.actionAsync2({
|
|
224
|
+
a,
|
|
225
|
+
b
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
let BeanTestCtx = (_dec$v = Bean(), _dec2$v = BeanInfo({
|
|
230
|
+
module: "test-vona"
|
|
231
|
+
}), _dec$v(_class$v = _dec2$v(_class$v = class BeanTestCtx extends TestCtx1 {}) || _class$v) || _class$v);
|
|
232
|
+
|
|
233
|
+
var _dec$u, _dec2$u, _class$u;
|
|
234
|
+
let BroadcastTest = (_dec$u = Broadcast(), _dec2$u = BeanInfo({
|
|
235
|
+
module: "test-vona"
|
|
236
|
+
}), _dec$u(_class$u = _dec2$u(_class$u = class BroadcastTest extends BeanBroadcastBase {
|
|
237
|
+
async execute(data, isEmitter) {
|
|
238
|
+
// locale
|
|
239
|
+
assert.equal(this.ctx.locale, 'zh-cn');
|
|
240
|
+
// data
|
|
241
|
+
assert.equal(data.message, 'hello');
|
|
242
|
+
}
|
|
243
|
+
}) || _class$u) || _class$u);
|
|
244
|
+
|
|
245
|
+
var _dec$t, _dec2$t, _class$t;
|
|
246
|
+
let CacheMemTest = (_dec$t = CacheMem({
|
|
247
|
+
ttl: 1 * 1000
|
|
248
|
+
}), _dec2$t = BeanInfo({
|
|
249
|
+
module: "test-vona"
|
|
250
|
+
}), _dec$t(_class$t = _dec2$t(_class$t = class CacheMemTest extends BeanCacheMemBase {}) || _class$t) || _class$t);
|
|
251
|
+
|
|
252
|
+
var _dec$s, _dec2$s, _class$s;
|
|
253
|
+
let CacheRedisTest = (_dec$s = CacheRedis({
|
|
254
|
+
ttl: 1 * 1000
|
|
255
|
+
}), _dec2$s = BeanInfo({
|
|
256
|
+
module: "test-vona"
|
|
257
|
+
}), _dec$s(_class$s = _dec2$s(_class$s = class CacheRedisTest extends BeanCacheRedisBase {}) || _class$s) || _class$s);
|
|
258
|
+
|
|
259
|
+
var _dec$r, _dec2$r, _class$r;
|
|
260
|
+
let EventHelloEcho = (_dec$r = Event(), _dec2$r = BeanInfo({
|
|
261
|
+
module: "test-vona"
|
|
262
|
+
}), _dec$r(_class$r = _dec2$r(_class$r = class EventHelloEcho extends BeanEventBase {}) || _class$r) || _class$r);
|
|
263
|
+
|
|
264
|
+
var _dec$q, _dec2$q, _class$q;
|
|
265
|
+
let EventListenerHelloEcho = (_dec$q = EventListener({
|
|
266
|
+
match: 'test-vona:helloEcho'
|
|
267
|
+
}), _dec2$q = BeanInfo({
|
|
268
|
+
module: "test-vona"
|
|
269
|
+
}), _dec$q(_class$q = _dec2$q(_class$q = class EventListenerHelloEcho extends BeanBase {
|
|
270
|
+
async execute(data, next) {
|
|
271
|
+
// next
|
|
272
|
+
const result = await next();
|
|
273
|
+
return `${data.text} ${result}`;
|
|
274
|
+
}
|
|
275
|
+
}) || _class$q) || _class$q);
|
|
276
|
+
|
|
277
|
+
var _dec$p, _dec2$p, _class$p;
|
|
278
|
+
let MetaVersion = (_dec$p = Meta(), _dec2$p = BeanInfo({
|
|
279
|
+
module: "test-vona"
|
|
280
|
+
}), _dec$p(_class$p = _dec2$p(_class$p = class MetaVersion extends BeanBase {
|
|
281
|
+
async update(options) {
|
|
282
|
+
if (options.version === 1) {
|
|
283
|
+
// testVona
|
|
284
|
+
const entity = this.scope.entity.test;
|
|
285
|
+
await this.bean.model.createTable(entity.$table, table => {
|
|
286
|
+
table.basicFields();
|
|
287
|
+
table.string(entity.$column('title'), 255);
|
|
288
|
+
table.string(entity.$column('description'), 255);
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}) || _class$p) || _class$p);
|
|
293
|
+
|
|
294
|
+
var _dec$o, _dec2$o, _class$o;
|
|
295
|
+
let QueueTest = (_dec$o = Queue(), _dec2$o = BeanInfo({
|
|
296
|
+
module: "test-vona"
|
|
297
|
+
}), _dec$o(_class$o = _dec2$o(_class$o = class QueueTest extends BeanQueueBase {
|
|
298
|
+
async execute(data, _options) {
|
|
299
|
+
return data.a + data.b;
|
|
300
|
+
}
|
|
301
|
+
}) || _class$o) || _class$o);
|
|
302
|
+
|
|
303
|
+
var _dec$n, _dec2$n, _class$n;
|
|
304
|
+
let ScheduleTest3 = (_dec$n = Schedule({
|
|
305
|
+
enable: false,
|
|
306
|
+
repeat: {
|
|
307
|
+
every: 5000
|
|
308
|
+
}
|
|
309
|
+
}), _dec2$n = BeanInfo({
|
|
310
|
+
module: "test-vona"
|
|
311
|
+
}), _dec$n(_class$n = _dec2$n(_class$n = class ScheduleTest3 extends BeanBase {
|
|
312
|
+
async execute(job) {
|
|
313
|
+
this.$logger.silly(`Schedule Test3: iid=${this.ctx.instance.id}, every=${job?.data.options?.jobOptions?.repeat?.every}, ${new Date()}`);
|
|
314
|
+
}
|
|
315
|
+
}) || _class$n) || _class$n);
|
|
316
|
+
|
|
317
|
+
var _dec$m, _dec2$m, _class$m;
|
|
318
|
+
let ScheduleTest = (_dec$m = Schedule({
|
|
319
|
+
enable: false,
|
|
320
|
+
repeat: {
|
|
321
|
+
every: 3000
|
|
322
|
+
}
|
|
323
|
+
}), _dec2$m = BeanInfo({
|
|
324
|
+
module: "test-vona"
|
|
325
|
+
}), _dec$m(_class$m = _dec2$m(_class$m = class ScheduleTest extends BeanBase {
|
|
326
|
+
async execute(job) {
|
|
327
|
+
this.$logger.silly(`Schedule Test: iid=${this.ctx.instance.id}, every=${job?.data.options?.jobOptions?.repeat?.every}, ${new Date()}`);
|
|
328
|
+
}
|
|
329
|
+
}) || _class$m) || _class$m);
|
|
330
|
+
|
|
331
|
+
var _dec$l, _dec2$l, _class$l;
|
|
332
|
+
let SummerCacheTest = (_dec$l = SummerCache({
|
|
333
|
+
mode: 'all',
|
|
334
|
+
mem: {
|
|
335
|
+
max: 2,
|
|
336
|
+
ttl: 1 * 1000
|
|
337
|
+
},
|
|
338
|
+
redis: {
|
|
339
|
+
ttl: 3 * 1000
|
|
340
|
+
}
|
|
341
|
+
}), _dec2$l = BeanInfo({
|
|
342
|
+
module: "test-vona"
|
|
343
|
+
}), _dec$l(_class$l = _dec2$l(_class$l = class SummerCacheTest extends BeanSummerCacheBase {
|
|
344
|
+
async getNative(key, _options) {
|
|
345
|
+
return {
|
|
346
|
+
id: key.id,
|
|
347
|
+
name: `name_${key.id}`
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
}) || _class$l) || _class$l);
|
|
351
|
+
|
|
352
|
+
function config(_app) {
|
|
353
|
+
return {};
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
function _applyDecoratedDescriptor(i, e, r, n, l) {
|
|
357
|
+
var a = {};
|
|
358
|
+
return Object.keys(n).forEach(function (i) {
|
|
359
|
+
a[i] = n[i];
|
|
360
|
+
}), a.enumerable = !!a.enumerable, a.configurable = !!a.configurable, ("value" in a || a.initializer) && (a.writable = true), a = r.slice().reverse().reduce(function (r, n) {
|
|
361
|
+
return n(i, e, r) || r;
|
|
362
|
+
}, a), l && void 0 !== a.initializer && (a.value = a.initializer ? a.initializer.call(l) : void 0, a.initializer = void 0), void 0 === a.initializer ? (Object.defineProperty(i, e, a), null) : a;
|
|
363
|
+
}
|
|
364
|
+
function _initializerDefineProperty(e, i, r, l) {
|
|
365
|
+
r && Object.defineProperty(e, i, {
|
|
366
|
+
enumerable: r.enumerable,
|
|
367
|
+
configurable: r.configurable,
|
|
368
|
+
writable: r.writable,
|
|
369
|
+
value: r.initializer ? r.initializer.call(l) : void 0
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
const __ThisModule__ = 'test-vona';
|
|
374
|
+
|
|
375
|
+
var _dec$k, _dec2$k, _class$k;
|
|
376
|
+
let ServiceTest = (_dec$k = Service(), _dec2$k = BeanInfo({
|
|
377
|
+
module: "test-vona"
|
|
378
|
+
}), _dec$k(_class$k = _dec2$k(_class$k = class ServiceTest extends BeanBase {
|
|
379
|
+
get name() {
|
|
380
|
+
return 'serviceTest';
|
|
381
|
+
}
|
|
382
|
+
}) || _class$k) || _class$k);
|
|
383
|
+
|
|
384
|
+
var _dec$j, _dec2$j, _dec3$f, _dec4$f, _dec5$f, _dec6$f, _dec7$d, _dec8$9, _dec9$6, _dec0$6, _dec1$6, _class$j, _class2$f;
|
|
385
|
+
let ControllerBean = (_dec$j = Controller({
|
|
386
|
+
path: 'bean',
|
|
387
|
+
meta: {
|
|
388
|
+
mode: 'test'
|
|
389
|
+
}
|
|
390
|
+
}), _dec2$j = Api.exclude(), _dec3$f = Passport.public(), _dec4$f = BeanInfo({
|
|
391
|
+
module: "test-vona"
|
|
392
|
+
}), _dec5$f = Web.get('test'), _dec6$f = Reflect.metadata("design:type", Function), _dec7$d = Reflect.metadata("design:paramtypes", []), _dec8$9 = Web.get('service'), _dec9$6 = Passport.public(), _dec0$6 = Reflect.metadata("design:type", Function), _dec1$6 = Reflect.metadata("design:paramtypes", []), _dec$j(_class$j = _dec2$j(_class$j = _dec3$f(_class$j = _dec4$f(_class$j = (_class2$f = class ControllerBean extends BeanBase {
|
|
393
|
+
async test() {
|
|
394
|
+
const a = 3;
|
|
395
|
+
const b = 4;
|
|
396
|
+
let res;
|
|
397
|
+
|
|
398
|
+
// app.bean
|
|
399
|
+
assert.equal(this.app.bean._getBean('test-vona.service.testApp'), this.app.bean['test-vona.service.testApp']);
|
|
400
|
+
res = this.app.bean['test-vona.service.testApp'].actionSync({
|
|
401
|
+
a,
|
|
402
|
+
b
|
|
403
|
+
});
|
|
404
|
+
assert.equal(res, `${a + b}:regexpaop`);
|
|
405
|
+
res = await this.app.bean['test-vona.service.testApp'].actionAsync({
|
|
406
|
+
a,
|
|
407
|
+
b
|
|
408
|
+
});
|
|
409
|
+
assert.equal(res, `${a + b}:regexpaop`);
|
|
410
|
+
|
|
411
|
+
// ctx.bean: global
|
|
412
|
+
assert.equal(this.bean.testCtx, this.app.bean.testCtx);
|
|
413
|
+
|
|
414
|
+
// magic
|
|
415
|
+
res = cast(this.bean.testCtx).magic;
|
|
416
|
+
assert.equal(res, 'magic:simpleaop');
|
|
417
|
+
|
|
418
|
+
// name
|
|
419
|
+
this.bean.testCtx.name = 'test-vona:simpleaop:regexpaop';
|
|
420
|
+
res = this.bean.testCtx.name;
|
|
421
|
+
assert.equal(res, 'test-vona:simpleaop:regexpaop');
|
|
422
|
+
res = this.bean.testCtx.actionSync({
|
|
423
|
+
a,
|
|
424
|
+
b
|
|
425
|
+
});
|
|
426
|
+
assert.equal(res, `${a + b}:simpleaop:regexpaop`);
|
|
427
|
+
res = await this.bean.testCtx.actionAsync({
|
|
428
|
+
a,
|
|
429
|
+
b
|
|
430
|
+
});
|
|
431
|
+
assert.equal(res, `${a + b}:simpleaop:regexpaop`);
|
|
432
|
+
res = await this.bean.testCtx.actionAsync2({
|
|
433
|
+
a,
|
|
434
|
+
b
|
|
435
|
+
});
|
|
436
|
+
assert.equal(res, `test-vona:simpleaop:regexpaop:${a + b}:simpleaop:regexpaop`);
|
|
437
|
+
res = await this.bean.testCtx.actionAsync3({
|
|
438
|
+
a,
|
|
439
|
+
b
|
|
440
|
+
});
|
|
441
|
+
assert.equal(res, `test-vona:simpleaop:regexpaop:${a + b}:simpleaop:regexpaop`);
|
|
442
|
+
|
|
443
|
+
// ctx.bean: class
|
|
444
|
+
assert.equal(this.bean['test-vona.service.testClass'], this.app.bean['test-vona.service.testClass']);
|
|
445
|
+
res = this.bean['test-vona.service.testClass'].actionSync({
|
|
446
|
+
a,
|
|
447
|
+
b
|
|
448
|
+
});
|
|
449
|
+
assert.equal(res, `${a + b}:regexpaop`);
|
|
450
|
+
res = await this.bean['test-vona.service.testClass'].actionAsync({
|
|
451
|
+
a,
|
|
452
|
+
b
|
|
453
|
+
});
|
|
454
|
+
assert.equal(res, `${a + b}:regexpaop`);
|
|
455
|
+
|
|
456
|
+
// magic of self
|
|
457
|
+
cast(this.bean.testCtx).magicSelf = '__magicSelf__';
|
|
458
|
+
res = cast(this.app.bean.testCtx).magicSelf;
|
|
459
|
+
assert.equal(res, '__magicSelf__');
|
|
460
|
+
res = cast(this.app.bean.testCtx)['magic:self'];
|
|
461
|
+
assert.equal(res, '__magicSelf__');
|
|
462
|
+
}
|
|
463
|
+
async service() {
|
|
464
|
+
let res;
|
|
465
|
+
|
|
466
|
+
// general way
|
|
467
|
+
res = this.bean._getBean(ServiceTest).name;
|
|
468
|
+
assert.equal(res, 'serviceTest');
|
|
469
|
+
res = this.bean._getBean('test-vona.service.test').name;
|
|
470
|
+
assert.equal(res, 'serviceTest');
|
|
471
|
+
|
|
472
|
+
// this scope
|
|
473
|
+
res = this.scope.service.test.name;
|
|
474
|
+
assert.equal(res, 'serviceTest');
|
|
475
|
+
|
|
476
|
+
// general scope
|
|
477
|
+
res = this.bean.scope(__ThisModule__).service.test.name;
|
|
478
|
+
assert.equal(res, 'serviceTest');
|
|
479
|
+
res = this.$scope.testVona.service.test.name;
|
|
480
|
+
assert.equal(res, 'serviceTest');
|
|
481
|
+
}
|
|
482
|
+
}, _applyDecoratedDescriptor(_class2$f.prototype, "test", [_dec5$f, _dec6$f, _dec7$d], Object.getOwnPropertyDescriptor(_class2$f.prototype, "test"), _class2$f.prototype), _applyDecoratedDescriptor(_class2$f.prototype, "service", [_dec8$9, _dec9$6, _dec0$6, _dec1$6], Object.getOwnPropertyDescriptor(_class2$f.prototype, "service"), _class2$f.prototype), _class2$f)) || _class$j) || _class$j) || _class$j) || _class$j);
|
|
483
|
+
|
|
484
|
+
var _dec$i, _dec2$i, _dec3$e, _dec4$e, _dec5$e, _dec6$e, _dec7$c, _class$i, _class2$e;
|
|
485
|
+
let ControllerCacheMem = (_dec$i = Controller({
|
|
486
|
+
path: 'cacheMem',
|
|
487
|
+
meta: {
|
|
488
|
+
mode: 'test'
|
|
489
|
+
}
|
|
490
|
+
}), _dec2$i = Api.exclude(), _dec3$e = Passport.public(), _dec4$e = BeanInfo({
|
|
491
|
+
module: "test-vona"
|
|
492
|
+
}), _dec5$e = Web.post(), _dec6$e = Reflect.metadata("design:type", Function), _dec7$c = Reflect.metadata("design:paramtypes", []), _dec$i(_class$i = _dec2$i(_class$i = _dec3$e(_class$i = _dec4$e(_class$i = (_class2$e = class ControllerCacheMem extends BeanBase {
|
|
493
|
+
async mem() {
|
|
494
|
+
let res;
|
|
495
|
+
let value;
|
|
496
|
+
|
|
497
|
+
// set
|
|
498
|
+
value = this.scope.cacheMem.test.getset('zhen.nann');
|
|
499
|
+
assert.equal(value, undefined);
|
|
500
|
+
value = this.scope.cacheMem.test.getset('zhennann');
|
|
501
|
+
assert.equal(value, 'zhen.nann');
|
|
502
|
+
|
|
503
|
+
// has
|
|
504
|
+
res = this.scope.cacheMem.test.has();
|
|
505
|
+
assert.equal(!!res, true);
|
|
506
|
+
|
|
507
|
+
// get
|
|
508
|
+
value = this.scope.cacheMem.test.get();
|
|
509
|
+
assert.equal(value, 'zhennann');
|
|
510
|
+
|
|
511
|
+
// del
|
|
512
|
+
this.scope.cacheMem.test.del();
|
|
513
|
+
res = this.scope.cacheMem.test.has();
|
|
514
|
+
assert.equal(res, false);
|
|
515
|
+
|
|
516
|
+
// set again
|
|
517
|
+
this.scope.cacheMem.test.set('zhennann'); // will be expired after 1s
|
|
518
|
+
|
|
519
|
+
// get
|
|
520
|
+
value = this.scope.cacheMem.test.get();
|
|
521
|
+
assert.equal(value, 'zhennann');
|
|
522
|
+
|
|
523
|
+
// peek after timeout
|
|
524
|
+
await sleep(900);
|
|
525
|
+
await retry({
|
|
526
|
+
retries: 3
|
|
527
|
+
}, async () => {
|
|
528
|
+
await sleep(100);
|
|
529
|
+
value = this.scope.cacheMem.test.peek();
|
|
530
|
+
assert.equal(value, undefined);
|
|
531
|
+
});
|
|
532
|
+
}
|
|
533
|
+
}, _applyDecoratedDescriptor(_class2$e.prototype, "mem", [_dec5$e, _dec6$e, _dec7$c], Object.getOwnPropertyDescriptor(_class2$e.prototype, "mem"), _class2$e.prototype), _class2$e)) || _class$i) || _class$i) || _class$i) || _class$i);
|
|
534
|
+
|
|
535
|
+
var _dec$h, _dec2$h, _dec3$d, _dec4$d, _dec5$d, _dec6$d, _dec7$b, _class$h, _class2$d;
|
|
536
|
+
let ControllerCacheRedis = (_dec$h = Controller({
|
|
537
|
+
path: 'cacheRedis',
|
|
538
|
+
meta: {
|
|
539
|
+
mode: 'test'
|
|
540
|
+
}
|
|
541
|
+
}), _dec2$h = Api.exclude(), _dec3$d = Passport.public(), _dec4$d = BeanInfo({
|
|
542
|
+
module: "test-vona"
|
|
543
|
+
}), _dec5$d = Web.post(), _dec6$d = Reflect.metadata("design:type", Function), _dec7$b = Reflect.metadata("design:paramtypes", []), _dec$h(_class$h = _dec2$h(_class$h = _dec3$d(_class$h = _dec4$d(_class$h = (_class2$d = class ControllerCacheRedis extends BeanBase {
|
|
544
|
+
async redis() {
|
|
545
|
+
let res;
|
|
546
|
+
let value;
|
|
547
|
+
|
|
548
|
+
// getset
|
|
549
|
+
value = await this.scope.cacheRedis.test.getset('zhen.nann');
|
|
550
|
+
assert.equal(value, undefined);
|
|
551
|
+
value = await this.scope.cacheRedis.test.getset('zhennann');
|
|
552
|
+
assert.equal(value, 'zhen.nann');
|
|
553
|
+
|
|
554
|
+
// has
|
|
555
|
+
res = await this.scope.cacheRedis.test.has();
|
|
556
|
+
assert.equal(res, true);
|
|
557
|
+
|
|
558
|
+
// get
|
|
559
|
+
value = await this.scope.cacheRedis.test.get();
|
|
560
|
+
assert.equal(value, 'zhennann');
|
|
561
|
+
|
|
562
|
+
// del
|
|
563
|
+
await this.scope.cacheRedis.test.del();
|
|
564
|
+
res = await this.scope.cacheRedis.test.has();
|
|
565
|
+
assert.equal(res, false);
|
|
566
|
+
|
|
567
|
+
// set again
|
|
568
|
+
await this.scope.cacheRedis.test.set('zhennann'); // will be expired after 1s
|
|
569
|
+
|
|
570
|
+
// get
|
|
571
|
+
value = await this.scope.cacheRedis.test.get();
|
|
572
|
+
assert.equal(value, 'zhennann');
|
|
573
|
+
|
|
574
|
+
// peek after timeout
|
|
575
|
+
await sleep(900);
|
|
576
|
+
await retry({
|
|
577
|
+
retries: 3
|
|
578
|
+
}, async () => {
|
|
579
|
+
await sleep(100);
|
|
580
|
+
value = await this.scope.cacheRedis.test.peek();
|
|
581
|
+
assert.equal(value, undefined);
|
|
582
|
+
});
|
|
583
|
+
}
|
|
584
|
+
}, _applyDecoratedDescriptor(_class2$d.prototype, "redis", [_dec5$d, _dec6$d, _dec7$b], Object.getOwnPropertyDescriptor(_class2$d.prototype, "redis"), _class2$d.prototype), _class2$d)) || _class$h) || _class$h) || _class$h) || _class$h);
|
|
585
|
+
|
|
586
|
+
var _dec$g, _dec2$g, _dec3$c, _dec4$c, _dec5$c, _dec6$c, _dec7$a, _dec8$8, _class$g, _class2$c, _descriptor$2, _descriptor2$2, _descriptor3;
|
|
587
|
+
let DtoUser = (_dec$g = Dto({
|
|
588
|
+
openapi: {
|
|
589
|
+
title: $locale('User')
|
|
590
|
+
}
|
|
591
|
+
}), _dec2$g = BeanInfo({
|
|
592
|
+
module: "test-vona"
|
|
593
|
+
}), _dec3$c = Api.field(v.title($locale('UserId')), v.tableIdentity()), _dec4$c = Reflect.metadata("design:type", typeof TableIdentity === "undefined" ? Object : TableIdentity), _dec5$c = Api.field(v.min(3)), _dec6$c = Reflect.metadata("design:type", String), _dec7$a = Api.field(), _dec8$8 = Reflect.metadata("design:type", Boolean), _dec$g(_class$g = _dec2$g(_class$g = (_class2$c = class DtoUser {
|
|
594
|
+
constructor() {
|
|
595
|
+
_initializerDefineProperty(this, "id", _descriptor$2, this);
|
|
596
|
+
_initializerDefineProperty(this, "name", _descriptor2$2, this);
|
|
597
|
+
_initializerDefineProperty(this, "married", _descriptor3, this);
|
|
598
|
+
}
|
|
599
|
+
}, _descriptor$2 = _applyDecoratedDescriptor(_class2$c.prototype, "id", [_dec3$c, _dec4$c], {
|
|
600
|
+
configurable: true,
|
|
601
|
+
enumerable: true,
|
|
602
|
+
writable: true,
|
|
603
|
+
initializer: null
|
|
604
|
+
}), _descriptor2$2 = _applyDecoratedDescriptor(_class2$c.prototype, "name", [_dec5$c, _dec6$c], {
|
|
605
|
+
configurable: true,
|
|
606
|
+
enumerable: true,
|
|
607
|
+
writable: true,
|
|
608
|
+
initializer: null
|
|
609
|
+
}), _descriptor3 = _applyDecoratedDescriptor(_class2$c.prototype, "married", [_dec7$a, _dec8$8], {
|
|
610
|
+
configurable: true,
|
|
611
|
+
enumerable: true,
|
|
612
|
+
writable: true,
|
|
613
|
+
initializer: null
|
|
614
|
+
}), _class2$c)) || _class$g) || _class$g);
|
|
615
|
+
|
|
616
|
+
var _dec$f, _dec2$f, _dec3$b, _dec4$b, _dec5$b, _dec6$b, _dec7$9, _dec8$7, _dec9$5, _dec0$5, _dec1$5, _dec10$4, _dec11$4, _dec12$4, _dec13$4, _dec14$3, _dec15$3, _dec16$3, _dec17$2, _dec18$2, _dec19$2, _dec20$2, _dec21$2, _dec22$2, _dec23$2, _dec24$2, _dec25$2, _dec26$1, _dec27$1, _dec28, _dec29, _dec30, _dec31, _dec32, _dec33, _dec34, _dec35, _dec36, _dec37, _dec38, _dec39, _dec40, _dec41, _dec42, _dec43, _dec44, _dec45, _dec46, _dec47, _dec48, _class$f, _class2$b;
|
|
617
|
+
let ControllerOnion = (_dec$f = Controller({
|
|
618
|
+
path: 'onion',
|
|
619
|
+
tags: ['Onion'],
|
|
620
|
+
meta: {
|
|
621
|
+
mode: ['local', 'test']
|
|
622
|
+
}
|
|
623
|
+
}), _dec2$f = BeanInfo({
|
|
624
|
+
module: "test-vona"
|
|
625
|
+
}), _dec3$b = Web.get('/'), _dec4$b = Aspect.aopMethod('a-database:transaction', {
|
|
626
|
+
enable: true,
|
|
627
|
+
meta: {
|
|
628
|
+
mode: 'local'
|
|
629
|
+
}
|
|
630
|
+
}), _dec5$b = Aspect.guardGlobal('a-user:passport', {
|
|
631
|
+
public: true
|
|
632
|
+
}), _dec6$b = Reflect.metadata("design:type", Function), _dec7$9 = Reflect.metadata("design:paramtypes", []), _dec8$7 = Web.post('//echo'), _dec9$5 = Aspect.guardGlobal('a-user:passport', {
|
|
633
|
+
public: true
|
|
634
|
+
}), _dec0$5 = Aspect.middlewareGlobal('a-core:gate', {
|
|
635
|
+
gate: {
|
|
636
|
+
mode: 'local'
|
|
637
|
+
}
|
|
638
|
+
}), _dec1$5 = Core.gate({
|
|
639
|
+
gate: {
|
|
640
|
+
mode: 'local'
|
|
641
|
+
}
|
|
642
|
+
}), _dec10$4 = Aspect.aopMethod('a-database:transaction', {
|
|
643
|
+
isolationLevel: EnumTransactionIsolationLevels.SERIALIZABLE,
|
|
644
|
+
readOnly: true
|
|
645
|
+
}), _dec11$4 = Database.transaction({
|
|
646
|
+
isolationLevel: EnumTransactionIsolationLevels.READ_COMMITTED,
|
|
647
|
+
readOnly: false
|
|
648
|
+
}), _dec12$4 = Api.body(v.optional(), z.string()), _dec13$4 = function (target, key) {
|
|
649
|
+
return Arg.query('id', v.default(0), z.number())(target, key, 0);
|
|
650
|
+
}, _dec14$3 = function (target, key) {
|
|
651
|
+
return Arg.query('name', z.number().optional())(target, key, 2);
|
|
652
|
+
}, _dec15$3 = function (target, key) {
|
|
653
|
+
return Arg.body(v.title($locale('User')), z.object({
|
|
654
|
+
id: z.number().openapi({
|
|
655
|
+
title: $locale('UserId')
|
|
656
|
+
})
|
|
657
|
+
}))(target, key, 3);
|
|
658
|
+
}, _dec16$3 = Reflect.metadata("design:type", Function), _dec17$2 = Reflect.metadata("design:paramtypes", [Number, String, String, typeof DtoUser === "undefined" ? Object : DtoUser]), _dec18$2 = Web.post('echo2/:userId/:userName'), _dec19$2 = Aspect.guardGlobal('a-user:passport', {
|
|
659
|
+
public: true
|
|
660
|
+
}), _dec20$2 = function (target, key) {
|
|
661
|
+
return Arg.param('userId', v.title($locale('UserId')), v.example('example:1'))(target, key, 0);
|
|
662
|
+
}, _dec21$2 = function (target, key) {
|
|
663
|
+
return Arg.param('userName', v.title($locale('UserId')), v.example('example:1'))(target, key, 1);
|
|
664
|
+
}, _dec22$2 = function (target, key) {
|
|
665
|
+
return Arg.query(DtoUser)(target, key, 2);
|
|
666
|
+
}, _dec23$2 = function (target, key) {
|
|
667
|
+
return Arg.body(v.title($locale('User')), z.object({
|
|
668
|
+
id: z.number().openapi({
|
|
669
|
+
title: $locale('UserId')
|
|
670
|
+
})
|
|
671
|
+
}))(target, key, 3);
|
|
672
|
+
}, _dec24$2 = Reflect.metadata("design:type", Function), _dec25$2 = Reflect.metadata("design:paramtypes", [Number, String, typeof DtoUser === "undefined" ? Object : DtoUser, typeof DtoUser === "undefined" ? Object : DtoUser]), _dec26$1 = Web.get('echo3/:userId'), _dec27$1 = Aspect.guardGlobal('a-user:passport', {
|
|
673
|
+
public: true
|
|
674
|
+
}), _dec28 = function (target, key) {
|
|
675
|
+
return Arg.param('userId')(target, key, 0);
|
|
676
|
+
}, _dec29 = function (target, key) {
|
|
677
|
+
return Arg.query('id', v.optional())(target, key, 1);
|
|
678
|
+
}, _dec30 = function (target, key) {
|
|
679
|
+
return Arg.headers('Accept', v.title($locale('UserId')))(target, key, 2);
|
|
680
|
+
}, _dec31 = Reflect.metadata("design:type", Function), _dec32 = Reflect.metadata("design:paramtypes", [Number, Number, String]), _dec33 = Web.post('echo4'), _dec34 = Aspect.guardGlobal('a-user:passport', {
|
|
681
|
+
public: true
|
|
682
|
+
}), _dec35 = Aspect.filterGlobal('a-error:error', {
|
|
683
|
+
enable: true,
|
|
684
|
+
logs: {
|
|
685
|
+
422: true
|
|
686
|
+
}
|
|
687
|
+
}), _dec36 = Api.body(v.array(DtoUser)), _dec37 = function (target, key) {
|
|
688
|
+
return Arg.body(v.optional(), v.array(), v.object(DtoUser))(target, key, 0);
|
|
689
|
+
}, _dec38 = Reflect.metadata("design:type", Function), _dec39 = Reflect.metadata("design:paramtypes", [Array]), _dec40 = Web.get('echo5'), _dec41 = Passport.public(), _dec42 = function (target, key) {
|
|
690
|
+
return Arg.query('ids', v.default([1]), v.array(Number, {
|
|
691
|
+
separator: '-'
|
|
692
|
+
}))(target, key, 0);
|
|
693
|
+
}, _dec43 = Reflect.metadata("design:type", Function), _dec44 = Reflect.metadata("design:paramtypes", [Array]), _dec45 = Web.get('echo6'), _dec46 = Passport.admin(), _dec47 = Reflect.metadata("design:type", Function), _dec48 = Reflect.metadata("design:paramtypes", []), _dec$f(_class$f = _dec2$f(_class$f = (_class2$b = class ControllerOnion extends BeanBase {
|
|
694
|
+
index() {
|
|
695
|
+
return this.ctx.db.inTransaction;
|
|
696
|
+
// return 'Hello Vona';
|
|
697
|
+
}
|
|
698
|
+
echo(id, temp, name, _user) {
|
|
699
|
+
return `echo: ${id}:${temp}:${name}`;
|
|
700
|
+
}
|
|
701
|
+
// echo2(@Arg.query(v.object(DtoUser, { passthrough: false, strict: false })) book: Partial<DtoUser>) {
|
|
702
|
+
echo2(_userId, _userName, _user, user) {
|
|
703
|
+
// const ctx = this.app.currentContext;
|
|
704
|
+
// this.$logger.silly(ctx === this.ctx);
|
|
705
|
+
return user;
|
|
706
|
+
}
|
|
707
|
+
echo3(_userId, id, accept) {
|
|
708
|
+
this.$logger.silly(this.ctx.path);
|
|
709
|
+
// const ctx = this.app.currentContext;
|
|
710
|
+
// this.$logger.silly(ctx === this.ctx);
|
|
711
|
+
return `${id}:${accept}`;
|
|
712
|
+
}
|
|
713
|
+
echo4(users) {
|
|
714
|
+
return users;
|
|
715
|
+
}
|
|
716
|
+
echo5(ids) {
|
|
717
|
+
// const ctx = this.app.currentContext;
|
|
718
|
+
// this.$logger.silly(ctx === this.ctx);
|
|
719
|
+
return ids;
|
|
720
|
+
}
|
|
721
|
+
echo6() {
|
|
722
|
+
return this.bean.passport.isAuthenticated;
|
|
723
|
+
}
|
|
724
|
+
}, _applyDecoratedDescriptor(_class2$b.prototype, "index", [_dec3$b, _dec4$b, _dec5$b, _dec6$b, _dec7$9], Object.getOwnPropertyDescriptor(_class2$b.prototype, "index"), _class2$b.prototype), _applyDecoratedDescriptor(_class2$b.prototype, "echo", [_dec8$7, _dec9$5, _dec0$5, _dec1$5, _dec10$4, _dec11$4, _dec12$4, _dec13$4, _dec14$3, _dec15$3, _dec16$3, _dec17$2], Object.getOwnPropertyDescriptor(_class2$b.prototype, "echo"), _class2$b.prototype), _applyDecoratedDescriptor(_class2$b.prototype, "echo2", [_dec18$2, _dec19$2, _dec20$2, _dec21$2, _dec22$2, _dec23$2, _dec24$2, _dec25$2], Object.getOwnPropertyDescriptor(_class2$b.prototype, "echo2"), _class2$b.prototype), _applyDecoratedDescriptor(_class2$b.prototype, "echo3", [_dec26$1, _dec27$1, _dec28, _dec29, _dec30, _dec31, _dec32], Object.getOwnPropertyDescriptor(_class2$b.prototype, "echo3"), _class2$b.prototype), _applyDecoratedDescriptor(_class2$b.prototype, "echo4", [_dec33, _dec34, _dec35, _dec36, _dec37, _dec38, _dec39], Object.getOwnPropertyDescriptor(_class2$b.prototype, "echo4"), _class2$b.prototype), _applyDecoratedDescriptor(_class2$b.prototype, "echo5", [_dec40, _dec41, _dec42, _dec43, _dec44], Object.getOwnPropertyDescriptor(_class2$b.prototype, "echo5"), _class2$b.prototype), _applyDecoratedDescriptor(_class2$b.prototype, "echo6", [_dec45, _dec46, _dec47, _dec48], Object.getOwnPropertyDescriptor(_class2$b.prototype, "echo6"), _class2$b.prototype), _class2$b)) || _class$f) || _class$f);
|
|
725
|
+
|
|
726
|
+
var _dec$e, _dec2$e, _dec3$a, _dec4$a, _dec5$a, _dec6$a, _dec7$8, _dec8$6, _dec9$4, _dec0$4, _dec1$4, _dec10$3, _dec11$3, _dec12$3, _dec13$3, _dec14$2, _dec15$2, _dec16$2, _dec17$1, _dec18$1, _dec19$1, _dec20$1, _dec21$1, _dec22$1, _dec23$1, _dec24$1, _dec25$1, _class$e, _class2$a;
|
|
727
|
+
let ControllerPassport = (_dec$e = Controller({
|
|
728
|
+
path: 'passport',
|
|
729
|
+
meta: {
|
|
730
|
+
mode: 'test'
|
|
731
|
+
}
|
|
732
|
+
}), _dec2$e = Api.exclude(), _dec3$a = BeanInfo({
|
|
733
|
+
module: "test-vona"
|
|
734
|
+
}), _dec4$a = Web.get('echo/:name'), _dec5$a = Passport.public(), _dec6$a = function (target, key) {
|
|
735
|
+
return Arg.param('name')(target, key, 0);
|
|
736
|
+
}, _dec7$8 = function (target, key) {
|
|
737
|
+
return Arg.user()(target, key, 1);
|
|
738
|
+
}, _dec8$6 = Reflect.metadata("design:type", Function), _dec9$4 = Reflect.metadata("design:paramtypes", [String, typeof IUserBase === "undefined" ? Object : IUserBase]), _dec0$4 = Web.post('login'), _dec1$4 = Api.body(v.object(DtoJwtToken)), _dec10$3 = Passport.public(), _dec11$3 = function (target, key) {
|
|
739
|
+
return Arg.body('name')(target, key, 0);
|
|
740
|
+
}, _dec12$3 = Reflect.metadata("design:type", Function), _dec13$3 = Reflect.metadata("design:paramtypes", [String]), _dec14$2 = Web.get('isAuthenticated'), _dec15$2 = Reflect.metadata("design:type", Function), _dec16$2 = Reflect.metadata("design:paramtypes", []), _dec17$1 = Web.post('refresh'), _dec18$1 = Api.body(v.object(DtoJwtToken)), _dec19$1 = Passport.public(), _dec20$1 = function (target, key) {
|
|
741
|
+
return Arg.body('refreshToken')(target, key, 0);
|
|
742
|
+
}, _dec21$1 = Reflect.metadata("design:type", Function), _dec22$1 = Reflect.metadata("design:paramtypes", [String]), _dec23$1 = Web.post('logout'), _dec24$1 = Reflect.metadata("design:type", Function), _dec25$1 = Reflect.metadata("design:paramtypes", []), _dec$e(_class$e = _dec2$e(_class$e = _dec3$a(_class$e = (_class2$a = class ControllerPassport extends BeanBase {
|
|
743
|
+
echo(name, user) {
|
|
744
|
+
assert.equal(name, 'admin');
|
|
745
|
+
assert.equal($getUserName(user), 'admin');
|
|
746
|
+
return {
|
|
747
|
+
name,
|
|
748
|
+
user
|
|
749
|
+
};
|
|
750
|
+
}
|
|
751
|
+
async login(name) {
|
|
752
|
+
const jwt = await this.bean.passport.signinMock(name);
|
|
753
|
+
return jwt;
|
|
754
|
+
}
|
|
755
|
+
isAuthenticated() {
|
|
756
|
+
return this.bean.passport.isAuthenticated;
|
|
757
|
+
}
|
|
758
|
+
async refresh(refreshToken) {
|
|
759
|
+
return await this.bean.passport.refreshAuthToken(refreshToken);
|
|
760
|
+
}
|
|
761
|
+
async logout() {
|
|
762
|
+
return await this.bean.passport.signout();
|
|
763
|
+
}
|
|
764
|
+
}, _applyDecoratedDescriptor(_class2$a.prototype, "echo", [_dec4$a, _dec5$a, _dec6$a, _dec7$8, _dec8$6, _dec9$4], Object.getOwnPropertyDescriptor(_class2$a.prototype, "echo"), _class2$a.prototype), _applyDecoratedDescriptor(_class2$a.prototype, "login", [_dec0$4, _dec1$4, _dec10$3, _dec11$3, _dec12$3, _dec13$3], Object.getOwnPropertyDescriptor(_class2$a.prototype, "login"), _class2$a.prototype), _applyDecoratedDescriptor(_class2$a.prototype, "isAuthenticated", [_dec14$2, _dec15$2, _dec16$2], Object.getOwnPropertyDescriptor(_class2$a.prototype, "isAuthenticated"), _class2$a.prototype), _applyDecoratedDescriptor(_class2$a.prototype, "refresh", [_dec17$1, _dec18$1, _dec19$1, _dec20$1, _dec21$1, _dec22$1], Object.getOwnPropertyDescriptor(_class2$a.prototype, "refresh"), _class2$a.prototype), _applyDecoratedDescriptor(_class2$a.prototype, "logout", [_dec23$1, _dec24$1, _dec25$1], Object.getOwnPropertyDescriptor(_class2$a.prototype, "logout"), _class2$a.prototype), _class2$a)) || _class$e) || _class$e) || _class$e);
|
|
765
|
+
|
|
766
|
+
var _dec$d, _dec2$d, _dec3$9, _dec4$9, _dec5$9, _dec6$9, _dec7$7, _dec8$5, _class$d, _class2$9;
|
|
767
|
+
let ControllerPerformAction = (_dec$d = Controller({
|
|
768
|
+
path: 'performAction',
|
|
769
|
+
meta: {
|
|
770
|
+
mode: 'test'
|
|
771
|
+
}
|
|
772
|
+
}), _dec2$d = Api.exclude(), _dec3$9 = BeanInfo({
|
|
773
|
+
module: "test-vona"
|
|
774
|
+
}), _dec4$9 = Web.post('echo'), _dec5$9 = Passport.public(), _dec6$9 = function (target, key) {
|
|
775
|
+
return Arg.body('id')(target, key, 0);
|
|
776
|
+
}, _dec7$7 = Reflect.metadata("design:type", Function), _dec8$5 = Reflect.metadata("design:paramtypes", [Number]), _dec$d(_class$d = _dec2$d(_class$d = _dec3$9(_class$d = (_class2$9 = class ControllerPerformAction extends BeanBase {
|
|
777
|
+
echo(id) {
|
|
778
|
+
const url = this.scope.util.combineApiPath('performAction/echo');
|
|
779
|
+
return {
|
|
780
|
+
id,
|
|
781
|
+
url
|
|
782
|
+
};
|
|
783
|
+
}
|
|
784
|
+
}, _applyDecoratedDescriptor(_class2$9.prototype, "echo", [_dec4$9, _dec5$9, _dec6$9, _dec7$7, _dec8$5], Object.getOwnPropertyDescriptor(_class2$9.prototype, "echo"), _class2$9.prototype), _class2$9)) || _class$d) || _class$d) || _class$d);
|
|
785
|
+
|
|
786
|
+
var _dec$c, _dec2$c, _dec3$8, _dec4$8, _dec5$8, _dec6$8, _dec7$6, _dec8$4, _dec9$3, _dec0$3, _dec1$3, _class$c, _class2$8;
|
|
787
|
+
let ControllerQueue = (_dec$c = Controller({
|
|
788
|
+
path: 'queue',
|
|
789
|
+
meta: {
|
|
790
|
+
mode: 'test'
|
|
791
|
+
}
|
|
792
|
+
}), _dec2$c = Api.exclude(), _dec3$8 = BeanInfo({
|
|
793
|
+
module: "test-vona"
|
|
794
|
+
}), _dec4$8 = Web.post('pushAsync'), _dec5$8 = Passport.public(), _dec6$8 = Reflect.metadata("design:type", Function), _dec7$6 = Reflect.metadata("design:paramtypes", []), _dec8$4 = Web.post('push'), _dec9$3 = Passport.public(), _dec0$3 = Reflect.metadata("design:type", Function), _dec1$3 = Reflect.metadata("design:paramtypes", []), _dec$c(_class$c = _dec2$c(_class$c = _dec3$8(_class$c = (_class2$8 = class ControllerQueue extends BeanBase {
|
|
795
|
+
async pushAsync() {
|
|
796
|
+
const res = await this.scope.queue.test.pushAsync({
|
|
797
|
+
a: 1,
|
|
798
|
+
b: 2
|
|
799
|
+
});
|
|
800
|
+
assert.equal(res, 3);
|
|
801
|
+
}
|
|
802
|
+
push() {
|
|
803
|
+
this.scope.queue.test.push({
|
|
804
|
+
a: 1,
|
|
805
|
+
b: 2
|
|
806
|
+
});
|
|
807
|
+
}
|
|
808
|
+
}, _applyDecoratedDescriptor(_class2$8.prototype, "pushAsync", [_dec4$8, _dec5$8, _dec6$8, _dec7$6], Object.getOwnPropertyDescriptor(_class2$8.prototype, "pushAsync"), _class2$8.prototype), _applyDecoratedDescriptor(_class2$8.prototype, "push", [_dec8$4, _dec9$3, _dec0$3, _dec1$3], Object.getOwnPropertyDescriptor(_class2$8.prototype, "push"), _class2$8.prototype), _class2$8)) || _class$c) || _class$c) || _class$c);
|
|
809
|
+
|
|
810
|
+
var _dec$b, _dec2$b, _dec3$7, _dec4$7, _dec5$7, _dec6$7, _dec7$5, _class$b, _class2$7;
|
|
811
|
+
let ControllerSummer = (_dec$b = Controller({
|
|
812
|
+
path: 'summer',
|
|
813
|
+
meta: {
|
|
814
|
+
mode: 'test'
|
|
815
|
+
}
|
|
816
|
+
}), _dec2$b = Api.exclude(), _dec3$7 = BeanInfo({
|
|
817
|
+
module: "test-vona"
|
|
818
|
+
}), _dec4$7 = Web.post(), _dec5$7 = Passport.public(), _dec6$7 = Reflect.metadata("design:type", Function), _dec7$5 = Reflect.metadata("design:paramtypes", []), _dec$b(_class$b = _dec2$b(_class$b = _dec3$7(_class$b = (_class2$7 = class ControllerSummer extends BeanBase {
|
|
819
|
+
async test() {
|
|
820
|
+
// name
|
|
821
|
+
const name = 'test';
|
|
822
|
+
const key1 = {
|
|
823
|
+
id: 1
|
|
824
|
+
};
|
|
825
|
+
const key2 = {
|
|
826
|
+
id: 2
|
|
827
|
+
};
|
|
828
|
+
const key3 = {
|
|
829
|
+
id: 3
|
|
830
|
+
};
|
|
831
|
+
|
|
832
|
+
// getCache
|
|
833
|
+
const cache = this.scope.summerCache.test;
|
|
834
|
+
assert.equal(!!cache, true);
|
|
835
|
+
let cacheOtherModule = this.$scope.testVona.summerCache.test;
|
|
836
|
+
assert.equal(cache, cacheOtherModule);
|
|
837
|
+
cacheOtherModule = this.bean.summer.cache(`${__ThisModule__}.summerCache.${name}`);
|
|
838
|
+
assert.equal(cache, cacheOtherModule);
|
|
839
|
+
let value;
|
|
840
|
+
let values;
|
|
841
|
+
|
|
842
|
+
// get: peek
|
|
843
|
+
value = await cache.peek(key1);
|
|
844
|
+
assert.equal(value, undefined);
|
|
845
|
+
|
|
846
|
+
// get
|
|
847
|
+
value = await cache.get(key1);
|
|
848
|
+
assert.equal(value.id, key1.id);
|
|
849
|
+
|
|
850
|
+
// get: peek
|
|
851
|
+
value = await cache.peek(key1);
|
|
852
|
+
assert.equal(value.id, key1.id);
|
|
853
|
+
value = await cache.peek(key1, {
|
|
854
|
+
mode: 'mem'
|
|
855
|
+
});
|
|
856
|
+
assert.equal(value.id, key1.id);
|
|
857
|
+
value = await cache.peek(key1, {
|
|
858
|
+
mode: 'redis'
|
|
859
|
+
});
|
|
860
|
+
assert.equal(value.id, key1.id);
|
|
861
|
+
|
|
862
|
+
// get: peek sleep for mem stale
|
|
863
|
+
await sleep(900);
|
|
864
|
+
|
|
865
|
+
// get: peek again
|
|
866
|
+
value = await cache.peek(key1, {
|
|
867
|
+
mode: 'redis'
|
|
868
|
+
});
|
|
869
|
+
assert.equal(value.id, key1.id);
|
|
870
|
+
await retry({
|
|
871
|
+
retries: 3
|
|
872
|
+
}, async () => {
|
|
873
|
+
await sleep(100);
|
|
874
|
+
value = await cache.peek(key1, {
|
|
875
|
+
mode: 'mem'
|
|
876
|
+
});
|
|
877
|
+
assert.equal(value, undefined);
|
|
878
|
+
});
|
|
879
|
+
|
|
880
|
+
// get: peek sleep for redis stale
|
|
881
|
+
await sleep(1900);
|
|
882
|
+
|
|
883
|
+
// get: peek again
|
|
884
|
+
await retry({
|
|
885
|
+
retries: 3
|
|
886
|
+
}, async () => {
|
|
887
|
+
await sleep(100);
|
|
888
|
+
value = await cache.peek(key1, {
|
|
889
|
+
mode: 'redis'
|
|
890
|
+
});
|
|
891
|
+
assert.equal(value, undefined);
|
|
892
|
+
});
|
|
893
|
+
value = await cache.peek(key1, {
|
|
894
|
+
mode: 'mem'
|
|
895
|
+
});
|
|
896
|
+
assert.equal(value, undefined);
|
|
897
|
+
|
|
898
|
+
// mget
|
|
899
|
+
// mem cache graph: key1
|
|
900
|
+
value = await cache.get(key1);
|
|
901
|
+
assert.equal(value.id, key1.id);
|
|
902
|
+
// mem cache graph: key2 key3
|
|
903
|
+
values = await cache.mget([key1, key2, key3]); // todo: maybe has bug
|
|
904
|
+
assert.equal(values[0].id, key1.id); // todo: maybe has bug
|
|
905
|
+
assert.equal(values[1].id, key2.id);
|
|
906
|
+
assert.equal(values[2].id, key3.id);
|
|
907
|
+
// mem cache graph: key3 key1
|
|
908
|
+
values = await cache.mget([key1, key2, key3]);
|
|
909
|
+
assert.equal(values[0].id, key1.id);
|
|
910
|
+
assert.equal(values[1].id, key2.id);
|
|
911
|
+
assert.equal(values[2].id, key3.id);
|
|
912
|
+
|
|
913
|
+
// mget: peek
|
|
914
|
+
value = await cache.peek(key2, {
|
|
915
|
+
mode: 'redis'
|
|
916
|
+
});
|
|
917
|
+
assert.equal(value.id, key2.id);
|
|
918
|
+
value = await cache.peek(key2, {
|
|
919
|
+
mode: 'mem'
|
|
920
|
+
});
|
|
921
|
+
assert.equal(value, undefined);
|
|
922
|
+
|
|
923
|
+
// del
|
|
924
|
+
await cache.del(key1);
|
|
925
|
+
await cache.del(key2);
|
|
926
|
+
|
|
927
|
+
// mdel
|
|
928
|
+
await cache.mdel([key1, key2, key3]);
|
|
929
|
+
|
|
930
|
+
// mdel: peek
|
|
931
|
+
value = await cache.peek(key3, {
|
|
932
|
+
mode: 'redis'
|
|
933
|
+
});
|
|
934
|
+
assert.equal(value, undefined);
|
|
935
|
+
value = await cache.peek(key3, {
|
|
936
|
+
mode: 'mem'
|
|
937
|
+
});
|
|
938
|
+
assert.equal(value, undefined);
|
|
939
|
+
|
|
940
|
+
// clear
|
|
941
|
+
values = await cache.mget([key1, key2, key3]);
|
|
942
|
+
assert.equal(values[2].id, key3.id);
|
|
943
|
+
value = await cache.peek(key3, {
|
|
944
|
+
mode: 'redis'
|
|
945
|
+
});
|
|
946
|
+
assert.equal(value.id, key3.id);
|
|
947
|
+
value = await cache.peek(key3, {
|
|
948
|
+
mode: 'mem'
|
|
949
|
+
});
|
|
950
|
+
assert.equal(value.id, key3.id);
|
|
951
|
+
await cache.clear();
|
|
952
|
+
value = await cache.peek(key3, {
|
|
953
|
+
mode: 'redis'
|
|
954
|
+
});
|
|
955
|
+
assert.equal(value, undefined);
|
|
956
|
+
value = await cache.peek(key3, {
|
|
957
|
+
mode: 'mem'
|
|
958
|
+
});
|
|
959
|
+
assert.equal(value, undefined);
|
|
960
|
+
}
|
|
961
|
+
}, _applyDecoratedDescriptor(_class2$7.prototype, "test", [_dec4$7, _dec5$7, _dec6$7, _dec7$5], Object.getOwnPropertyDescriptor(_class2$7.prototype, "test"), _class2$7.prototype), _class2$7)) || _class$b) || _class$b) || _class$b);
|
|
962
|
+
|
|
963
|
+
var _dec$a, _dec2$a, _dec3$6, _dec4$6, _dec5$6, _dec6$6, _dec7$4, _class$a, _class2$6;
|
|
964
|
+
let ControllerTail = (_dec$a = Controller({
|
|
965
|
+
path: 'tail',
|
|
966
|
+
meta: {
|
|
967
|
+
mode: 'test'
|
|
968
|
+
}
|
|
969
|
+
}), _dec2$a = Api.exclude(), _dec3$6 = BeanInfo({
|
|
970
|
+
module: "test-vona"
|
|
971
|
+
}), _dec4$6 = Web.post(), _dec5$6 = Passport.public(), _dec6$6 = Reflect.metadata("design:type", Function), _dec7$4 = Reflect.metadata("design:paramtypes", []), _dec$a(_class$a = _dec2$a(_class$a = _dec3$6(_class$a = (_class2$6 = class ControllerTail extends BeanBase {
|
|
972
|
+
tail() {
|
|
973
|
+
// 1
|
|
974
|
+
cast(this.ctx)._tail_test = 1;
|
|
975
|
+
|
|
976
|
+
// tail
|
|
977
|
+
this.ctx.db.commit(() => {
|
|
978
|
+
assert.equal(cast(this.ctx)._tail_test_als_caller, undefined);
|
|
979
|
+
assert.equal(cast(this.ctx)._tail_test, 2);
|
|
980
|
+
this.ctx.db.commit(() => {
|
|
981
|
+
assert.equal(cast(this.ctx)._tail_test, 3);
|
|
982
|
+
});
|
|
983
|
+
cast(this.ctx)._tail_test = 3;
|
|
984
|
+
});
|
|
985
|
+
|
|
986
|
+
// 2
|
|
987
|
+
cast(this.ctx)._tail_test = 2;
|
|
988
|
+
}
|
|
989
|
+
}, _applyDecoratedDescriptor(_class2$6.prototype, "tail", [_dec4$6, _dec5$6, _dec6$6, _dec7$4], Object.getOwnPropertyDescriptor(_class2$6.prototype, "tail"), _class2$6.prototype), _class2$6)) || _class$a) || _class$a) || _class$a);
|
|
990
|
+
|
|
991
|
+
var _dec$9, _dec2$9, _dec3$5, _dec4$5, _dec5$5, _dec6$5, _dec7$3, _dec8$3, _dec9$2, _dec0$2, _dec1$2, _dec10$2, _dec11$2, _dec12$2, _dec13$2, _class$9, _class2$5;
|
|
992
|
+
const tableNameFail$1 = '__tempTransactionFail';
|
|
993
|
+
const tableNameSuccess$1 = '__tempTransactionSuccess';
|
|
994
|
+
let ControllerTransaction = (_dec$9 = Controller({
|
|
995
|
+
path: 'transaction',
|
|
996
|
+
meta: {
|
|
997
|
+
mode: 'test'
|
|
998
|
+
}
|
|
999
|
+
}), _dec2$9 = Api.exclude(), _dec3$5 = BeanInfo({
|
|
1000
|
+
module: "test-vona"
|
|
1001
|
+
}), _dec4$5 = Web.post('fail'), _dec5$5 = Database.transaction(), _dec6$5 = Passport.public(), _dec7$3 = function (target, key) {
|
|
1002
|
+
return Arg.body()(target, key, 0);
|
|
1003
|
+
}, _dec8$3 = Reflect.metadata("design:type", Function), _dec9$2 = Reflect.metadata("design:paramtypes", [Object]), _dec0$2 = Web.post('success'), _dec1$2 = Database.transaction(), _dec10$2 = Passport.public(), _dec11$2 = function (target, key) {
|
|
1004
|
+
return Arg.body()(target, key, 0);
|
|
1005
|
+
}, _dec12$2 = Reflect.metadata("design:type", Function), _dec13$2 = Reflect.metadata("design:paramtypes", [Object]), _dec$9(_class$9 = _dec2$9(_class$9 = _dec3$5(_class$9 = (_class2$5 = class ControllerTransaction extends BeanBase {
|
|
1006
|
+
async fail(item) {
|
|
1007
|
+
await this.app.bean.model.update(`${tableNameFail$1}`, item);
|
|
1008
|
+
await this.app.bean.model.update(`${tableNameFail$1}error`, item);
|
|
1009
|
+
}
|
|
1010
|
+
async success(item) {
|
|
1011
|
+
await this.app.bean.model.update(tableNameSuccess$1, item);
|
|
1012
|
+
}
|
|
1013
|
+
}, _applyDecoratedDescriptor(_class2$5.prototype, "fail", [_dec4$5, _dec5$5, _dec6$5, _dec7$3, _dec8$3, _dec9$2], Object.getOwnPropertyDescriptor(_class2$5.prototype, "fail"), _class2$5.prototype), _applyDecoratedDescriptor(_class2$5.prototype, "success", [_dec0$2, _dec1$2, _dec10$2, _dec11$2, _dec12$2, _dec13$2], Object.getOwnPropertyDescriptor(_class2$5.prototype, "success"), _class2$5.prototype), _class2$5)) || _class$9) || _class$9) || _class$9);
|
|
1014
|
+
|
|
1015
|
+
var _dec$8, _dec2$8, _dec3$4, _dec4$4, _dec5$4, _dec6$4, _dec7$2, _dec8$2, _dec9$1, _dec0$1, _dec1$1, _dec10$1, _dec11$1, _dec12$1, _dec13$1, _dec14$1, _dec15$1, _dec16$1, _dec17, _dec18, _dec19, _dec20, _dec21, _dec22, _dec23, _dec24, _dec25, _dec26, _dec27, _class$8, _class2$4;
|
|
1016
|
+
let ControllerUpload = (_dec$8 = Controller({
|
|
1017
|
+
path: 'upload',
|
|
1018
|
+
meta: {
|
|
1019
|
+
mode: ['test', 'local']
|
|
1020
|
+
}
|
|
1021
|
+
}), _dec2$8 = BeanInfo({
|
|
1022
|
+
module: "test-vona"
|
|
1023
|
+
}), _dec3$4 = Web.post('fields'), _dec4$4 = Passport.public(), _dec5$4 = Aspect.interceptor('a-upload:upload'), _dec6$4 = Api.contentType('application/json'), _dec7$2 = function (target, key) {
|
|
1024
|
+
return Arg.fields()(target, key, 0);
|
|
1025
|
+
}, _dec8$2 = function (target, key) {
|
|
1026
|
+
return Arg.fields('checkes', v.array(z.string()))(target, key, 1);
|
|
1027
|
+
}, _dec9$1 = function (target, key) {
|
|
1028
|
+
return Arg.field('name', v.default('zhennann'), v.title('your name'))(target, key, 2);
|
|
1029
|
+
}, _dec0$1 = Reflect.metadata("design:type", Function), _dec1$1 = Reflect.metadata("design:paramtypes", [Array, Array, String]), _dec10$1 = Web.post('file'), _dec11$1 = Passport.public(), _dec12$1 = Aspect.interceptor('a-upload:upload'), _dec13$1 = Api.contentType('application/json'), _dec14$1 = function (target, key) {
|
|
1030
|
+
return Arg.field('name', v.default('zhennann'))(target, key, 0);
|
|
1031
|
+
}, _dec15$1 = function (target, key) {
|
|
1032
|
+
return Arg.file('welcome')(target, key, 1);
|
|
1033
|
+
}, _dec16$1 = Reflect.metadata("design:type", Function), _dec17 = Reflect.metadata("design:paramtypes", [String, typeof IUploadFile === "undefined" ? Object : IUploadFile]), _dec18 = Web.post('files'), _dec19 = Passport.public(), _dec20 = Aspect.interceptor('a-upload:upload'), _dec21 = Api.contentType('application/json'), _dec22 = function (target, key) {
|
|
1034
|
+
return Arg.files(v.title('more files'))(target, key, 0);
|
|
1035
|
+
}, _dec23 = function (target, key) {
|
|
1036
|
+
return Arg.files('images', v.title('images'))(target, key, 1);
|
|
1037
|
+
}, _dec24 = function (target, key) {
|
|
1038
|
+
return Arg.file('welcome1', v.title('single file'))(target, key, 2);
|
|
1039
|
+
}, _dec25 = function (target, key) {
|
|
1040
|
+
return Arg.file('welcome2')(target, key, 3);
|
|
1041
|
+
}, _dec26 = Reflect.metadata("design:type", Function), _dec27 = Reflect.metadata("design:paramtypes", [Array, Array, typeof IUploadFile === "undefined" ? Object : IUploadFile, typeof IUploadFile === "undefined" ? Object : IUploadFile]), _dec$8(_class$8 = _dec2$8(_class$8 = (_class2$4 = class ControllerUpload extends BeanBase {
|
|
1042
|
+
fields(fields, checkes, name) {
|
|
1043
|
+
assert.equal(fields.find(item => item.name === 'name')?.value, 'zhennann');
|
|
1044
|
+
assert.equal(checkes.length > 0, true);
|
|
1045
|
+
assert.equal(name, 'zhennann');
|
|
1046
|
+
return this.ctx[SymbolUploadValue];
|
|
1047
|
+
}
|
|
1048
|
+
file(name, file) {
|
|
1049
|
+
assert.equal(name, 'zhennann');
|
|
1050
|
+
assert.equal(file.name, 'welcome');
|
|
1051
|
+
return this.ctx[SymbolUploadValue];
|
|
1052
|
+
}
|
|
1053
|
+
files(files, images, file1, file2) {
|
|
1054
|
+
assert.equal(files.find(item => item.name === 'welcome1')?.name, 'welcome1');
|
|
1055
|
+
assert.equal(images.find(item => item.name === 'images')?.name, 'images');
|
|
1056
|
+
assert.equal(file1.name, 'welcome1');
|
|
1057
|
+
assert.equal(file2.name, 'welcome2');
|
|
1058
|
+
return this.ctx[SymbolUploadValue];
|
|
1059
|
+
}
|
|
1060
|
+
}, _applyDecoratedDescriptor(_class2$4.prototype, "fields", [_dec3$4, _dec4$4, _dec5$4, _dec6$4, _dec7$2, _dec8$2, _dec9$1, _dec0$1, _dec1$1], Object.getOwnPropertyDescriptor(_class2$4.prototype, "fields"), _class2$4.prototype), _applyDecoratedDescriptor(_class2$4.prototype, "file", [_dec10$1, _dec11$1, _dec12$1, _dec13$1, _dec14$1, _dec15$1, _dec16$1, _dec17], Object.getOwnPropertyDescriptor(_class2$4.prototype, "file"), _class2$4.prototype), _applyDecoratedDescriptor(_class2$4.prototype, "files", [_dec18, _dec19, _dec20, _dec21, _dec22, _dec23, _dec24, _dec25, _dec26, _dec27], Object.getOwnPropertyDescriptor(_class2$4.prototype, "files"), _class2$4.prototype), _class2$4)) || _class$8) || _class$8);
|
|
1061
|
+
|
|
1062
|
+
var _dec$7, _dec2$7, _dec3$3, _dec4$3, _dec5$3, _dec6$3, _class$7, _class2$3, _descriptor$1, _descriptor2$1;
|
|
1063
|
+
let DtoProfile = (_dec$7 = Dto(), _dec2$7 = BeanInfo({
|
|
1064
|
+
module: "test-vona"
|
|
1065
|
+
}), _dec3$3 = Api.field(), _dec4$3 = Reflect.metadata("design:type", Number), _dec5$3 = Api.field(v.email()), _dec6$3 = Reflect.metadata("design:type", String), _dec$7(_class$7 = _dec2$7(_class$7 = (_class2$3 = class DtoProfile {
|
|
1066
|
+
constructor() {
|
|
1067
|
+
_initializerDefineProperty(this, "id", _descriptor$1, this);
|
|
1068
|
+
_initializerDefineProperty(this, "email", _descriptor2$1, this);
|
|
1069
|
+
}
|
|
1070
|
+
}, _descriptor$1 = _applyDecoratedDescriptor(_class2$3.prototype, "id", [_dec3$3, _dec4$3], {
|
|
1071
|
+
configurable: true,
|
|
1072
|
+
enumerable: true,
|
|
1073
|
+
writable: true,
|
|
1074
|
+
initializer: null
|
|
1075
|
+
}), _descriptor2$1 = _applyDecoratedDescriptor(_class2$3.prototype, "email", [_dec5$3, _dec6$3], {
|
|
1076
|
+
configurable: true,
|
|
1077
|
+
enumerable: true,
|
|
1078
|
+
writable: true,
|
|
1079
|
+
initializer: null
|
|
1080
|
+
}), _class2$3)) || _class$7) || _class$7);
|
|
1081
|
+
|
|
1082
|
+
var _dec$6, _dec2$6, _dec3$2, _dec4$2, _dec5$2, _dec6$2, _class$6, _class2$2, _descriptor, _descriptor2;
|
|
1083
|
+
let EntityTest = (_dec$6 = Entity('testVona'), _dec2$6 = BeanInfo({
|
|
1084
|
+
module: "test-vona"
|
|
1085
|
+
}), _dec3$2 = Api.field(), _dec4$2 = Reflect.metadata("design:type", String), _dec5$2 = Api.field(), _dec6$2 = Reflect.metadata("design:type", String), _dec$6(_class$6 = _dec2$6(_class$6 = (_class2$2 = class EntityTest extends EntityBase {
|
|
1086
|
+
constructor(...args) {
|
|
1087
|
+
super(...args);
|
|
1088
|
+
_initializerDefineProperty(this, "title", _descriptor, this);
|
|
1089
|
+
_initializerDefineProperty(this, "description", _descriptor2, this);
|
|
1090
|
+
}
|
|
1091
|
+
}, _descriptor = _applyDecoratedDescriptor(_class2$2.prototype, "title", [_dec3$2, _dec4$2], {
|
|
1092
|
+
configurable: true,
|
|
1093
|
+
enumerable: true,
|
|
1094
|
+
writable: true,
|
|
1095
|
+
initializer: null
|
|
1096
|
+
}), _descriptor2 = _applyDecoratedDescriptor(_class2$2.prototype, "description", [_dec5$2, _dec6$2], {
|
|
1097
|
+
configurable: true,
|
|
1098
|
+
enumerable: true,
|
|
1099
|
+
writable: true,
|
|
1100
|
+
initializer: null
|
|
1101
|
+
}), _class2$2)) || _class$6) || _class$6);
|
|
1102
|
+
|
|
1103
|
+
var _dec$5, _dec2$5, _class$5;
|
|
1104
|
+
let ModelTest = (_dec$5 = Model({
|
|
1105
|
+
entity: EntityTest,
|
|
1106
|
+
clientName: 'default'
|
|
1107
|
+
}), _dec2$5 = BeanInfo({
|
|
1108
|
+
module: "test-vona"
|
|
1109
|
+
}), _dec$5(_class$5 = _dec2$5(_class$5 = class ModelTest extends BeanModelBase {}) || _class$5) || _class$5);
|
|
1110
|
+
|
|
1111
|
+
var _dec$4, _dec2$4, _dec3$1, _dec4$1, _class$4, _dec5$1, _dec6$1, _dec7$1, _dec8$1, _dec9, _dec0, _dec1, _dec10, _dec11, _dec12, _dec13, _dec14, _dec15, _dec16, _class2$1, _class3;
|
|
1112
|
+
let ServiceAopMethodBase = (_dec$4 = Aspect.aopMethod('test-vona:test', {
|
|
1113
|
+
wrapper: '+'
|
|
1114
|
+
}), _dec2$4 = Aspect.aopMethod('test-vona:test', {
|
|
1115
|
+
wrapper: '-'
|
|
1116
|
+
}), _dec3$1 = Reflect.metadata("design:type", Function), _dec4$1 = Reflect.metadata("design:paramtypes", []), _class$4 = class ServiceAopMethodBase extends BeanBase {
|
|
1117
|
+
testSyncBase() {
|
|
1118
|
+
return 'hello';
|
|
1119
|
+
}
|
|
1120
|
+
}, _applyDecoratedDescriptor(_class$4.prototype, "testSyncBase", [_dec$4, _dec2$4, _dec3$1, _dec4$1], Object.getOwnPropertyDescriptor(_class$4.prototype, "testSyncBase"), _class$4.prototype), _class$4);
|
|
1121
|
+
let ServiceAopMethod = (_dec5$1 = Service(), _dec6$1 = BeanInfo({
|
|
1122
|
+
module: "test-vona"
|
|
1123
|
+
}), _dec7$1 = Aspect.aopMethod('test-vona:test', {
|
|
1124
|
+
wrapper: '+'
|
|
1125
|
+
}), _dec8$1 = Aspect.aopMethod('test-vona:test', {
|
|
1126
|
+
wrapper: '-'
|
|
1127
|
+
}), _dec9 = Reflect.metadata("design:type", Function), _dec0 = Reflect.metadata("design:paramtypes", []), _dec1 = Aspect.aopMethod('test-vona:test', {
|
|
1128
|
+
wrapper: '+'
|
|
1129
|
+
}), _dec10 = Aspect.aopMethod('test-vona:test', {
|
|
1130
|
+
wrapper: '-'
|
|
1131
|
+
}), _dec11 = Reflect.metadata("design:type", Function), _dec12 = Reflect.metadata("design:paramtypes", []), _dec13 = Aspect.aopMethod('test-vona:test', {
|
|
1132
|
+
wrapper: '+'
|
|
1133
|
+
}), _dec14 = Aspect.aopMethod('test-vona:test', {
|
|
1134
|
+
wrapper: '-'
|
|
1135
|
+
}), _dec15 = Reflect.metadata("design:type", Function), _dec16 = Reflect.metadata("design:paramtypes", []), _dec5$1(_class2$1 = _dec6$1(_class2$1 = (_class3 = class ServiceAopMethod extends ServiceAopMethodBase {
|
|
1136
|
+
constructor(...args) {
|
|
1137
|
+
super(...args);
|
|
1138
|
+
this._name = '';
|
|
1139
|
+
}
|
|
1140
|
+
testSync() {
|
|
1141
|
+
return 'hello';
|
|
1142
|
+
}
|
|
1143
|
+
async testAsync() {
|
|
1144
|
+
return 'hello';
|
|
1145
|
+
}
|
|
1146
|
+
get name() {
|
|
1147
|
+
return this._name;
|
|
1148
|
+
}
|
|
1149
|
+
set name(value) {
|
|
1150
|
+
this._name = value;
|
|
1151
|
+
}
|
|
1152
|
+
}, _applyDecoratedDescriptor(_class3.prototype, "testSync", [_dec7$1, _dec8$1, _dec9, _dec0], Object.getOwnPropertyDescriptor(_class3.prototype, "testSync"), _class3.prototype), _applyDecoratedDescriptor(_class3.prototype, "testAsync", [_dec1, _dec10, _dec11, _dec12], Object.getOwnPropertyDescriptor(_class3.prototype, "testAsync"), _class3.prototype), _applyDecoratedDescriptor(_class3.prototype, "name", [_dec13, _dec14, _dec15, _dec16], Object.getOwnPropertyDescriptor(_class3.prototype, "name"), _class3.prototype), _class3)) || _class2$1) || _class2$1);
|
|
1153
|
+
|
|
1154
|
+
var _dec$3, _dec2$3, _class$3;
|
|
1155
|
+
let ServiceTestApp = (_dec$3 = Service(), _dec2$3 = BeanInfo({
|
|
1156
|
+
module: "test-vona"
|
|
1157
|
+
}), _dec$3(_class$3 = _dec2$3(_class$3 = class ServiceTestApp extends BeanBase {
|
|
1158
|
+
actionSync({
|
|
1159
|
+
a,
|
|
1160
|
+
b
|
|
1161
|
+
}) {
|
|
1162
|
+
return a + b;
|
|
1163
|
+
}
|
|
1164
|
+
async actionAsync({
|
|
1165
|
+
a,
|
|
1166
|
+
b
|
|
1167
|
+
}) {
|
|
1168
|
+
return Promise.resolve(a + b);
|
|
1169
|
+
}
|
|
1170
|
+
}) || _class$3) || _class$3);
|
|
1171
|
+
|
|
1172
|
+
var _dec$2, _dec2$2, _class$2;
|
|
1173
|
+
class ClassBeanBase extends BeanBase {
|
|
1174
|
+
actionSync({
|
|
1175
|
+
a,
|
|
1176
|
+
b
|
|
1177
|
+
}) {
|
|
1178
|
+
return a + b;
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
1181
|
+
let ServiceTestClass = (_dec$2 = Service(), _dec2$2 = BeanInfo({
|
|
1182
|
+
module: "test-vona"
|
|
1183
|
+
}), _dec$2(_class$2 = _dec2$2(_class$2 = class ServiceTestClass extends ClassBeanBase {
|
|
1184
|
+
async actionAsync({
|
|
1185
|
+
a,
|
|
1186
|
+
b
|
|
1187
|
+
}) {
|
|
1188
|
+
return Promise.resolve(a + b);
|
|
1189
|
+
}
|
|
1190
|
+
}) || _class$2) || _class$2);
|
|
1191
|
+
|
|
1192
|
+
var _dec$1, _dec2$1, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _class$1, _class2;
|
|
1193
|
+
const tableNameFail = '__tempTransactionFail';
|
|
1194
|
+
const tableNameSuccess = '__tempTransactionSuccess';
|
|
1195
|
+
let ServiceTransaction = (_dec$1 = Service(), _dec2$1 = BeanInfo({
|
|
1196
|
+
module: "test-vona"
|
|
1197
|
+
}), _dec3 = Database.transaction(), _dec4 = Reflect.metadata("design:type", Function), _dec5 = Reflect.metadata("design:paramtypes", [Object]), _dec6 = Database.transaction(), _dec7 = Reflect.metadata("design:type", Function), _dec8 = Reflect.metadata("design:paramtypes", [Object]), _dec$1(_class$1 = _dec2$1(_class$1 = (_class2 = class ServiceTransaction extends BeanBase {
|
|
1198
|
+
async fail(item) {
|
|
1199
|
+
await this.app.bean.model.update(`${tableNameFail}`, item);
|
|
1200
|
+
await this.app.bean.model.update(`${tableNameFail}error`, item);
|
|
1201
|
+
}
|
|
1202
|
+
async success(item) {
|
|
1203
|
+
await this.app.bean.model.update(tableNameSuccess, item);
|
|
1204
|
+
}
|
|
1205
|
+
}, _applyDecoratedDescriptor(_class2.prototype, "fail", [_dec3, _dec4, _dec5], Object.getOwnPropertyDescriptor(_class2.prototype, "fail"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "success", [_dec6, _dec7, _dec8], Object.getOwnPropertyDescriptor(_class2.prototype, "success"), _class2.prototype), _class2)) || _class$1) || _class$1);
|
|
1206
|
+
|
|
1207
|
+
var _dec, _dec2, _class;
|
|
1208
|
+
const locales = {
|
|
1209
|
+
'en-us': locale_en_us,
|
|
1210
|
+
'zh-cn': locale_zh_cn
|
|
1211
|
+
};
|
|
1212
|
+
let ScopeModuleTestVona = (_dec = Scope(), _dec2 = BeanInfo({
|
|
1213
|
+
module: "test-vona"
|
|
1214
|
+
}), _dec(_class = _dec2(_class = class ScopeModuleTestVona extends BeanScopeBase {}) || _class) || _class);
|
|
1215
|
+
function $locale(key) {
|
|
1216
|
+
return `test-vona::${key}`;
|
|
1217
|
+
}
|
|
1218
|
+
/** scope: end */
|
|
1219
|
+
|
|
1220
|
+
export { $locale, AopMethodTest, AopRegExp, AopSimple, BeanTestCtx, BroadcastTest, CacheMemTest, CacheRedisTest, ControllerBean, ControllerCacheMem, ControllerCacheRedis, 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 };
|