vona-module-test-vona 5.0.53 → 5.0.55

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.
@@ -0,0 +1 @@
1
+ export * from './serializer.ts';
@@ -0,0 +1 @@
1
+ export declare function SensitiveEmail(): PropertyDecorator;
@@ -50,11 +50,11 @@ export declare class ServicePost extends BeanBase {
50
50
  postContent: "testVonaPostContent";
51
51
  user: "testVonaUser";
52
52
  }>, import("vona-module-a-orm").TypeEntityTableColumnNamesOfModelSelf<ModelPost> | import("vona").TypeRecordValues<{
53
- postContent: "testVonaPostContent.id" | "testVonaPostContent.content" | "testVonaPostContent.iid" | "testVonaPostContent.createdAt" | "testVonaPostContent.updatedAt" | "testVonaPostContent.deleted" | "testVonaPostContent.postId";
53
+ postContent: "testVonaPostContent.content" | "testVonaPostContent.id" | "testVonaPostContent.iid" | "testVonaPostContent.createdAt" | "testVonaPostContent.updatedAt" | "testVonaPostContent.deleted" | "testVonaPostContent.postId";
54
54
  user: "testVonaUser.name" | "testVonaUser.id" | "testVonaUser.iid" | "testVonaUser.createdAt" | "testVonaUser.updatedAt" | "testVonaUser.deleted" | "testVonaUser.age" | "testVonaUser.scores";
55
55
  }>>[] | undefined;
56
56
  orders?: import("vona-module-a-orm").IModelSelectParamsOrder<import("vona-module-a-orm").TypeEntityTableColumnNamesOfModelSelf<ModelPost> | import("vona").TypeRecordValues<{
57
- postContent: "testVonaPostContent.id" | "testVonaPostContent.content" | "testVonaPostContent.iid" | "testVonaPostContent.createdAt" | "testVonaPostContent.updatedAt" | "testVonaPostContent.deleted" | "testVonaPostContent.postId";
57
+ postContent: "testVonaPostContent.content" | "testVonaPostContent.id" | "testVonaPostContent.iid" | "testVonaPostContent.createdAt" | "testVonaPostContent.updatedAt" | "testVonaPostContent.deleted" | "testVonaPostContent.postId";
58
58
  user: "testVonaUser.name" | "testVonaUser.id" | "testVonaUser.iid" | "testVonaUser.createdAt" | "testVonaUser.updatedAt" | "testVonaUser.deleted" | "testVonaUser.age" | "testVonaUser.scores";
59
59
  }>>[] | undefined;
60
60
  limit?: number;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vona-module-test-vona",
3
3
  "type": "module",
4
- "version": "5.0.53",
4
+ "version": "5.0.55",
5
5
  "title": "test-vona",
6
6
  "vonaModule": {
7
7
  "fileVersion": 1,
@@ -1296,6 +1296,31 @@ declare module 'vona-module-test-vona' {
1296
1296
  }
1297
1297
  }
1298
1298
  /** schedule: end */
1299
+ /** serializerTransform: begin */
1300
+ export * from '../bean/serializerTransform.email.ts';
1301
+ import type { ISerializerTransformOptionsEmail } from '../bean/serializerTransform.email.ts';
1302
+ import 'vona';
1303
+ declare module 'vona-module-a-serialization' {
1304
+
1305
+ export interface ISerializerTransformRecord {
1306
+ 'test-vona:email': ISerializerTransformOptionsEmail;
1307
+ }
1308
+
1309
+
1310
+ }
1311
+ declare module 'vona-module-test-vona' {
1312
+
1313
+ export interface SerializerTransformEmail {
1314
+ /** @internal */
1315
+ get scope(): ScopeModuleTestVona;
1316
+ }
1317
+
1318
+ export interface SerializerTransformEmail {
1319
+ get $beanFullName(): 'test-vona.serializerTransform.email';
1320
+ get $onionName(): 'test-vona:email';
1321
+ }
1322
+ }
1323
+ /** serializerTransform: end */
1299
1324
  /** summerCache: begin */
1300
1325
  export * from '../bean/summerCache.test.ts';
1301
1326
 
@@ -1335,12 +1360,16 @@ export * from '../dto/orderQueryPage.ts';
1335
1360
  export * from '../dto/orderResult.ts';
1336
1361
  export * from '../dto/orderResultPage.ts';
1337
1362
  export * from '../dto/orderUpdate.ts';
1363
+ export * from '../dto/postAggregate.ts';
1338
1364
  export * from '../dto/postCreate.ts';
1365
+ export * from '../dto/postGroup.ts';
1339
1366
  export * from '../dto/postQuery.ts';
1340
1367
  export * from '../dto/postQueryRes.ts';
1341
1368
  export * from '../dto/profile.ts';
1342
1369
  export * from '../dto/roleLazy.ts';
1343
- export * from '../dto/serializerTest.ts';
1370
+ export * from '../dto/serializerArray.ts';
1371
+ export * from '../dto/serializerLazy.ts';
1372
+ export * from '../dto/serializerSimple.ts';
1344
1373
  export * from '../dto/signin.ts';
1345
1374
  export * from '../dto/user.ts';
1346
1375
  export * from '../dto/userCreate.ts';
@@ -1353,12 +1382,16 @@ import type { IDtoOptionsOrderQueryPage } from '../dto/orderQueryPage.ts';
1353
1382
  import type { IDtoOptionsOrderResult } from '../dto/orderResult.ts';
1354
1383
  import type { IDtoOptionsOrderResultPage } from '../dto/orderResultPage.ts';
1355
1384
  import type { IDtoOptionsOrderUpdate } from '../dto/orderUpdate.ts';
1385
+ import type { IDtoOptionsPostAggregate } from '../dto/postAggregate.ts';
1356
1386
  import type { IDtoOptionsPostCreate } from '../dto/postCreate.ts';
1387
+ import type { IDtoOptionsPostGroup } from '../dto/postGroup.ts';
1357
1388
  import type { IDtoOptionsPostQuery } from '../dto/postQuery.ts';
1358
1389
  import type { IDtoOptionsPostQueryRes } from '../dto/postQueryRes.ts';
1359
1390
  import type { IDtoOptionsProfile } from '../dto/profile.ts';
1360
1391
  import type { IDtoOptionsRoleLazy } from '../dto/roleLazy.ts';
1361
- import type { IDtoOptionsSerializerTest } from '../dto/serializerTest.ts';
1392
+ import type { IDtoOptionsSerializerArray } from '../dto/serializerArray.ts';
1393
+ import type { IDtoOptionsSerializerLazy } from '../dto/serializerLazy.ts';
1394
+ import type { IDtoOptionsSerializerSimple } from '../dto/serializerSimple.ts';
1362
1395
  import type { IDtoOptionsSignin } from '../dto/signin.ts';
1363
1396
  import type { IDtoOptionsUser } from '../dto/user.ts';
1364
1397
  import type { IDtoOptionsUserCreate } from '../dto/userCreate.ts';
@@ -1375,12 +1408,16 @@ declare module 'vona-module-a-web' {
1375
1408
  'test-vona:orderResult': IDtoOptionsOrderResult;
1376
1409
  'test-vona:orderResultPage': IDtoOptionsOrderResultPage;
1377
1410
  'test-vona:orderUpdate': IDtoOptionsOrderUpdate;
1411
+ 'test-vona:postAggregate': IDtoOptionsPostAggregate;
1378
1412
  'test-vona:postCreate': IDtoOptionsPostCreate;
1413
+ 'test-vona:postGroup': IDtoOptionsPostGroup;
1379
1414
  'test-vona:postQuery': IDtoOptionsPostQuery;
1380
1415
  'test-vona:postQueryRes': IDtoOptionsPostQueryRes;
1381
1416
  'test-vona:profile': IDtoOptionsProfile;
1382
1417
  'test-vona:roleLazy': IDtoOptionsRoleLazy;
1383
- 'test-vona:serializerTest': IDtoOptionsSerializerTest;
1418
+ 'test-vona:serializerArray': IDtoOptionsSerializerArray;
1419
+ 'test-vona:serializerLazy': IDtoOptionsSerializerLazy;
1420
+ 'test-vona:serializerSimple': IDtoOptionsSerializerSimple;
1384
1421
  'test-vona:signin': IDtoOptionsSignin;
1385
1422
  'test-vona:user': IDtoOptionsUser;
1386
1423
  'test-vona:userCreate': IDtoOptionsUserCreate;
@@ -1402,12 +1439,16 @@ import type { DtoOrderQueryPage } from '../dto/orderQueryPage.ts';
1402
1439
  import type { DtoOrderResult } from '../dto/orderResult.ts';
1403
1440
  import type { DtoOrderResultPage } from '../dto/orderResultPage.ts';
1404
1441
  import type { DtoOrderUpdate } from '../dto/orderUpdate.ts';
1442
+ import type { DtoPostAggregate } from '../dto/postAggregate.ts';
1405
1443
  import type { DtoPostCreate } from '../dto/postCreate.ts';
1444
+ import type { DtoPostGroup } from '../dto/postGroup.ts';
1406
1445
  import type { DtoPostQuery } from '../dto/postQuery.ts';
1407
1446
  import type { DtoPostQueryRes } from '../dto/postQueryRes.ts';
1408
1447
  import type { DtoProfile } from '../dto/profile.ts';
1409
1448
  import type { DtoRoleLazy } from '../dto/roleLazy.ts';
1410
- import type { DtoSerializerTest } from '../dto/serializerTest.ts';
1449
+ import type { DtoSerializerArray } from '../dto/serializerArray.ts';
1450
+ import type { DtoSerializerLazy } from '../dto/serializerLazy.ts';
1451
+ import type { DtoSerializerSimple } from '../dto/serializerSimple.ts';
1411
1452
  import type { DtoSignin } from '../dto/signin.ts';
1412
1453
  import type { DtoUser } from '../dto/user.ts';
1413
1454
  import type { DtoUserCreate } from '../dto/userCreate.ts';
@@ -1443,10 +1484,18 @@ declare module 'vona-module-test-vona' {
1443
1484
  fields?: TypeEntityOptionsFields<DtoOrderUpdate, IDtoOptionsOrderUpdate[TypeSymbolKeyFieldsMore]>;
1444
1485
  }
1445
1486
 
1487
+ export interface IDtoOptionsPostAggregate {
1488
+ fields?: TypeEntityOptionsFields<DtoPostAggregate, IDtoOptionsPostAggregate[TypeSymbolKeyFieldsMore]>;
1489
+ }
1490
+
1446
1491
  export interface IDtoOptionsPostCreate {
1447
1492
  fields?: TypeEntityOptionsFields<DtoPostCreate, IDtoOptionsPostCreate[TypeSymbolKeyFieldsMore]>;
1448
1493
  }
1449
1494
 
1495
+ export interface IDtoOptionsPostGroup {
1496
+ fields?: TypeEntityOptionsFields<DtoPostGroup, IDtoOptionsPostGroup[TypeSymbolKeyFieldsMore]>;
1497
+ }
1498
+
1450
1499
  export interface IDtoOptionsPostQuery {
1451
1500
  fields?: TypeEntityOptionsFields<DtoPostQuery, IDtoOptionsPostQuery[TypeSymbolKeyFieldsMore]>;
1452
1501
  }
@@ -1463,8 +1512,16 @@ declare module 'vona-module-test-vona' {
1463
1512
  fields?: TypeEntityOptionsFields<DtoRoleLazy, IDtoOptionsRoleLazy[TypeSymbolKeyFieldsMore]>;
1464
1513
  }
1465
1514
 
1466
- export interface IDtoOptionsSerializerTest {
1467
- fields?: TypeEntityOptionsFields<DtoSerializerTest, IDtoOptionsSerializerTest[TypeSymbolKeyFieldsMore]>;
1515
+ export interface IDtoOptionsSerializerArray {
1516
+ fields?: TypeEntityOptionsFields<DtoSerializerArray, IDtoOptionsSerializerArray[TypeSymbolKeyFieldsMore]>;
1517
+ }
1518
+
1519
+ export interface IDtoOptionsSerializerLazy {
1520
+ fields?: TypeEntityOptionsFields<DtoSerializerLazy, IDtoOptionsSerializerLazy[TypeSymbolKeyFieldsMore]>;
1521
+ }
1522
+
1523
+ export interface IDtoOptionsSerializerSimple {
1524
+ fields?: TypeEntityOptionsFields<DtoSerializerSimple, IDtoOptionsSerializerSimple[TypeSymbolKeyFieldsMore]>;
1468
1525
  }
1469
1526
 
1470
1527
  export interface IDtoOptionsSignin {
@@ -1501,6 +1558,7 @@ export * from '../controller/passport.ts';
1501
1558
  export * from '../controller/performAction.ts';
1502
1559
  export * from '../controller/post.ts';
1503
1560
  export * from '../controller/queue.ts';
1561
+ export * from '../controller/serializer.ts';
1504
1562
  export * from '../controller/summer.ts';
1505
1563
  export * from '../controller/tail.ts';
1506
1564
  export * from '../controller/transaction.ts';
@@ -1517,6 +1575,7 @@ import type { IControllerOptionsPassport } from '../controller/passport.ts';
1517
1575
  import type { IControllerOptionsPerformAction } from '../controller/performAction.ts';
1518
1576
  import type { IControllerOptionsPost } from '../controller/post.ts';
1519
1577
  import type { IControllerOptionsQueue } from '../controller/queue.ts';
1578
+ import type { IControllerOptionsSerializer } from '../controller/serializer.ts';
1520
1579
  import type { IControllerOptionsSummer } from '../controller/summer.ts';
1521
1580
  import type { IControllerOptionsTail } from '../controller/tail.ts';
1522
1581
  import type { IControllerOptionsTransaction } from '../controller/transaction.ts';
@@ -1537,6 +1596,7 @@ declare module 'vona-module-a-web' {
1537
1596
  'test-vona:performAction': IControllerOptionsPerformAction;
1538
1597
  'test-vona:post': IControllerOptionsPost;
1539
1598
  'test-vona:queue': IControllerOptionsQueue;
1599
+ 'test-vona:serializer': IControllerOptionsSerializer;
1540
1600
  'test-vona:summer': IControllerOptionsSummer;
1541
1601
  'test-vona:tail': IControllerOptionsTail;
1542
1602
  'test-vona:transaction': IControllerOptionsTransaction;
@@ -1667,6 +1727,16 @@ declare module 'vona-module-test-vona' {
1667
1727
  get $onionName(): 'test-vona:queue';
1668
1728
  }
1669
1729
 
1730
+ export interface ControllerSerializer {
1731
+ /** @internal */
1732
+ get scope(): ScopeModuleTestVona;
1733
+ }
1734
+
1735
+ export interface ControllerSerializer {
1736
+ get $beanFullName(): 'test-vona.controller.serializer';
1737
+ get $onionName(): 'test-vona:serializer';
1738
+ }
1739
+
1670
1740
  export interface ControllerSummer {
1671
1741
  /** @internal */
1672
1742
  get scope(): ScopeModuleTestVona;
@@ -1734,6 +1804,8 @@ import type { ControllerPost } from '../controller/post.ts';
1734
1804
  // @ts-ignore ignore
1735
1805
  import type { ControllerQueue } from '../controller/queue.ts';
1736
1806
  // @ts-ignore ignore
1807
+ import type { ControllerSerializer } from '../controller/serializer.ts';
1808
+ // @ts-ignore ignore
1737
1809
  import type { ControllerSummer } from '../controller/summer.ts';
1738
1810
  // @ts-ignore ignore
1739
1811
  import type { ControllerTail } from '../controller/tail.ts';
@@ -1791,6 +1863,10 @@ declare module 'vona-module-test-vona' {
1791
1863
  actions?: TypeControllerOptionsActions<ControllerQueue>;
1792
1864
  }
1793
1865
 
1866
+ export interface IControllerOptionsSerializer {
1867
+ actions?: TypeControllerOptionsActions<ControllerSerializer>;
1868
+ }
1869
+
1794
1870
  export interface IControllerOptionsSummer {
1795
1871
  actions?: TypeControllerOptionsActions<ControllerSummer>;
1796
1872
  }
@@ -1829,6 +1905,8 @@ declare module 'vona-module-a-web' {
1829
1905
  '/test/vona/order/findMany': undefined;
1830
1906
  '/test/vona/passport/echo/:name': undefined;
1831
1907
  '/test/vona/passport/isAuthenticated': undefined;
1908
+ '/test/vona/post/group': undefined;
1909
+ '/test/vona/post/aggregate': undefined;
1832
1910
  '/test/vona/post/findManyEcho': undefined;
1833
1911
  '/test/vona/post/findMany': undefined;
1834
1912
  }
@@ -1848,6 +1926,9 @@ export interface IApiPathPostRecord{
1848
1926
  '/test/vona/performAction/echo': undefined;
1849
1927
  '/test/vona/queue/pushAsync': undefined;
1850
1928
  '/test/vona/queue/push': undefined;
1929
+ '/test/vona/serializer/echoSimple': undefined;
1930
+ '/test/vona/serializer/echoArray': undefined;
1931
+ '/test/vona/serializer/echoLazy': undefined;
1851
1932
  '/test/vona/summer': undefined;
1852
1933
  '/test/vona/tail': undefined;
1853
1934
  '/test/vona/transaction/fail': undefined;
@@ -0,0 +1,28 @@
1
+ import type { IDecoratorSerializerTransformOptions, ISerializerTransform } from 'vona-module-a-serialization';
2
+ import { BeanBase } from 'vona';
3
+ import { SerializerTransform } from 'vona-module-a-serialization';
4
+
5
+ export type TypeSerializerTransformEmailValue = string | undefined;
6
+
7
+ export type TypeSerializerTransformEmailData = unknown;
8
+
9
+ export type TypeSerializerTransformEmailResult = TypeSerializerTransformEmailValue;
10
+
11
+ export interface ISerializerTransformOptionsEmail extends IDecoratorSerializerTransformOptions {}
12
+
13
+ @SerializerTransform<ISerializerTransformOptionsEmail>()
14
+ export class SerializerTransformEmail extends BeanBase
15
+ implements ISerializerTransform<
16
+ TypeSerializerTransformEmailValue,
17
+ TypeSerializerTransformEmailData,
18
+ TypeSerializerTransformEmailResult
19
+ > {
20
+ async transform(
21
+ value: TypeSerializerTransformEmailValue,
22
+ _data: TypeSerializerTransformEmailData,
23
+ _options: ISerializerTransformOptionsEmail,
24
+ ): Promise<TypeSerializerTransformEmailResult> {
25
+ // eslint-disable-next-line
26
+ return value?.replace(/(\w?)(\w+)(\w)(@\w+\.[a-z]+)/, '$1****$3$4');
27
+ }
28
+ }
@@ -2,9 +2,11 @@ import type { IQueryParams } from 'vona-module-a-orm';
2
2
  import type { IDecoratorControllerOptions, IPipeOptionsQueryTransformInfo } from 'vona-module-a-web';
3
3
  import type { ModelPost } from '../model/post.ts';
4
4
  import { BeanBase } from 'vona';
5
- import { Api } from 'vona-module-a-openapi';
5
+ import { Api, v } from 'vona-module-a-openapi';
6
6
  import { Passport } from 'vona-module-a-user';
7
7
  import { Arg, Controller, Web } from 'vona-module-a-web';
8
+ import { DtoPostAggregate } from '../dto/postAggregate.ts';
9
+ import { DtoPostGroup } from '../dto/postGroup.ts';
8
10
  import { DtoPostQuery } from '../dto/postQuery.ts';
9
11
  import { DtoPostQueryRes } from '../dto/postQueryRes.ts';
10
12
 
@@ -12,6 +14,32 @@ export interface IControllerOptionsPost extends IDecoratorControllerOptions {}
12
14
 
13
15
  @Controller<IControllerOptionsPost>('post', { meta: { mode: ['test', 'dev'] } })
14
16
  export class ControllerPost extends BeanBase {
17
+ @Web.get('group')
18
+ @Api.body(v.array(DtoPostGroup))
19
+ async group(): Promise<DtoPostGroup[]> {
20
+ return await this.scope.model.post.group({
21
+ groups: 'userId',
22
+ aggrs: {
23
+ count: '*',
24
+ sum: 'stars',
25
+ },
26
+ });
27
+ }
28
+
29
+ @Web.get('aggregate')
30
+ @Api.body(DtoPostAggregate)
31
+ async aggregate(): Promise<DtoPostAggregate> {
32
+ return await this.scope.model.post.aggregate({
33
+ aggrs: {
34
+ count: ['*', 'stars'],
35
+ sum: 'stars',
36
+ avg: 'stars',
37
+ min: 'stars',
38
+ max: 'stars',
39
+ },
40
+ });
41
+ }
42
+
15
43
  @Web.get('findManyEcho')
16
44
  @Api.body(DtoPostQueryRes)
17
45
  @Passport.public()
@@ -0,0 +1,38 @@
1
+ import type { IDecoratorControllerOptions } from 'vona-module-a-web';
2
+ import { BeanBase } from 'vona';
3
+ import { Api, v } from 'vona-module-a-openapi';
4
+ import { Serializer } from 'vona-module-a-serialization';
5
+ import { Passport } from 'vona-module-a-user';
6
+ import { Arg, Controller, Web } from 'vona-module-a-web';
7
+ import { DtoSerializerArray } from '../dto/serializerArray.ts';
8
+ import { DtoSerializerLazy } from '../dto/serializerLazy.ts';
9
+ import { DtoSerializerSimple } from '../dto/serializerSimple.ts';
10
+
11
+ export interface IControllerOptionsSerializer extends IDecoratorControllerOptions {}
12
+
13
+ @Controller<IControllerOptionsSerializer>({ path: 'serializer', meta: { mode: ['test', 'dev'] } })
14
+ export class ControllerSerializer extends BeanBase {
15
+ @Web.post('echoSimple')
16
+ @Api.body(DtoSerializerSimple)
17
+ @Passport.public()
18
+ @Serializer.enable()
19
+ echoSimple(@Arg.body() data: DtoSerializerSimple) {
20
+ return data;
21
+ }
22
+
23
+ @Web.post('echoArray')
24
+ @Api.body(v.array(DtoSerializerArray))
25
+ @Passport.public()
26
+ @Serializer.enable()
27
+ echoArray(@Arg.body(v.array(DtoSerializerArray)) data: DtoSerializerArray[]) {
28
+ return data;
29
+ }
30
+
31
+ @Web.post('echoLazy')
32
+ @Api.body(DtoSerializerLazy)
33
+ @Passport.public()
34
+ @Serializer.enable()
35
+ echoLazy(@Arg.body(DtoSerializerLazy) data: DtoSerializerLazy) {
36
+ return data;
37
+ }
38
+ }
@@ -0,0 +1,16 @@
1
+ import type { IDecoratorDtoOptions } from 'vona-module-a-web';
2
+ import { $Dto } from 'vona-module-a-orm';
3
+ import { Dto } from 'vona-module-a-web';
4
+ import { ModelPost } from '../model/post.ts';
5
+
6
+ export interface IDtoOptionsPostAggregate extends IDecoratorDtoOptions {}
7
+
8
+ @Dto<IDtoOptionsPostAggregate>()
9
+ export class DtoPostAggregate
10
+ extends $Dto.aggregate(() => ModelPost, {
11
+ count: ['*', 'stars'],
12
+ sum: 'stars',
13
+ avg: 'stars',
14
+ min: 'stars',
15
+ max: 'stars',
16
+ }) {}
@@ -0,0 +1,13 @@
1
+ import type { IDecoratorDtoOptions } from 'vona-module-a-web';
2
+ import { $Dto } from 'vona-module-a-orm';
3
+ import { Dto } from 'vona-module-a-web';
4
+ import { ModelPost } from '../model/post.ts';
5
+
6
+ export interface IDtoOptionsPostGroup extends IDecoratorDtoOptions {}
7
+
8
+ @Dto<IDtoOptionsPostGroup>()
9
+ export class DtoPostGroup
10
+ extends $Dto.group(() => ModelPost, 'userId', {
11
+ count: '*',
12
+ sum: 'stars',
13
+ }) {}
@@ -0,0 +1,29 @@
1
+ import type { IDecoratorDtoOptions } from 'vona-module-a-web';
2
+ import { Api, v } from 'vona-module-a-openapi';
3
+ import { Dto } from 'vona-module-a-web';
4
+ import { DtoSerializerSimple } from './serializerSimple.ts';
5
+
6
+ export interface IDtoOptionsSerializerArray extends IDecoratorDtoOptions {}
7
+
8
+ @Dto<IDtoOptionsSerializerArray>()
9
+ export class DtoSerializerArray {
10
+ @Api.field(v.serializerGetter((value: DtoSerializerSimple[], _data: DtoSerializerArray) => {
11
+ return value.map(item => {
12
+ return {
13
+ ...item,
14
+ password: '111111',
15
+ };
16
+ });
17
+ }), v.title('Simple'), v.array(DtoSerializerSimple))
18
+ simples: DtoSerializerSimple[];
19
+
20
+ @Api.field(v.serializerGetter((value: DtoSerializerSimple[], _data: DtoSerializerArray) => {
21
+ return value.map(item => {
22
+ return {
23
+ ...item,
24
+ password: '111111',
25
+ };
26
+ });
27
+ }), v.title('Simple'), v.array(v.lazy(() => DtoSerializerSimple)))
28
+ simplesLazy: DtoSerializerSimple[];
29
+ }
@@ -0,0 +1,32 @@
1
+ import type { IDecoratorDtoOptions } from 'vona-module-a-web';
2
+ import { Api, v } from 'vona-module-a-openapi';
3
+ import { Dto } from 'vona-module-a-web';
4
+ import { DtoSerializerSimple } from './serializerSimple.ts';
5
+
6
+ export interface IDtoOptionsSerializerLazy extends IDecoratorDtoOptions {}
7
+
8
+ @Dto<IDtoOptionsSerializerLazy>()
9
+ export class DtoSerializerLazy {
10
+ @Api.field(
11
+ v.serializerGetter((value: DtoSerializerSimple) => {
12
+ return { ...value, password: '111111' };
13
+ }),
14
+ v.object(DtoSerializerSimple),
15
+ )
16
+ simple: DtoSerializerSimple;
17
+
18
+ @Api.field(
19
+ v.serializerGetter((value: DtoSerializerSimple) => {
20
+ return { ...value, password: '111111' };
21
+ }),
22
+ v.title('title'),
23
+ v.optional(),
24
+ v.lazy(
25
+ v.description('description'),
26
+ () => {
27
+ return DtoSerializerSimple;
28
+ },
29
+ ),
30
+ )
31
+ simpleLazy: DtoSerializerSimple;
32
+ }
@@ -0,0 +1,98 @@
1
+ import type { IDecoratorDtoOptions } from 'vona-module-a-web';
2
+ import { Api, v } from 'vona-module-a-openapi';
3
+ import { Serializer } from 'vona-module-a-serialization';
4
+ import { Dto } from 'vona-module-a-web';
5
+ import { SensitiveEmail } from '../lib/serializer.ts';
6
+
7
+ export interface IDtoOptionsSerializerSimple extends IDecoratorDtoOptions {}
8
+
9
+ @Dto<IDtoOptionsSerializerSimple>()
10
+ export class DtoSerializerSimple {
11
+ @Serializer.exclude()
12
+ @Api.field(v.min(6))
13
+ password: string;
14
+
15
+ @Api.field(v.serializerExclude(), v.min(6))
16
+ password2: string;
17
+
18
+ @Serializer.transform('test-vona:email')
19
+ email: string;
20
+
21
+ @Serializer.transform(
22
+ 'a-serialization:sensitive',
23
+ {
24
+ // eslint-disable-next-line
25
+ patternFrom: /(\w?)(\w+)(\w)(@\w+\.[a-z]+)/,
26
+ patternTo: '$1****$3$4',
27
+ },
28
+ )
29
+ @Api.field(v.email())
30
+ email2: string;
31
+
32
+ @Serializer.sensitive({
33
+ // eslint-disable-next-line
34
+ patternFrom: /(\w?)(\w+)(\w)(@\w+\.[a-z]+)/,
35
+ patternTo: '$1****$3$4',
36
+ })
37
+ @Api.field(v.email())
38
+ email3: string;
39
+
40
+ @SensitiveEmail()
41
+ email4: string;
42
+
43
+ @Api.field(
44
+ v.openapi({
45
+ serializerTransforms: {
46
+ 'a-serialization:sensitive': {
47
+ // eslint-disable-next-line
48
+ patternFrom: /(\w?)(\w+)(\w)(@\w+\.[a-z]+)/,
49
+ patternTo: '$1****$3$4',
50
+ },
51
+ },
52
+ }),
53
+ v.email(),
54
+ )
55
+ email5: string;
56
+
57
+ @Api.field(
58
+ v.serializerTransform('a-serialization:sensitive', {
59
+ // eslint-disable-next-line
60
+ patternFrom: /(\w?)(\w+)(\w)(@\w+\.[a-z]+)/,
61
+ patternTo: '$1****$3$4',
62
+ }),
63
+ v.email(),
64
+ )
65
+ email6: string;
66
+
67
+ @Api.field(
68
+ v.serializerSensitive({
69
+ // eslint-disable-next-line
70
+ patternFrom: /(\w?)(\w+)(\w)(@\w+\.[a-z]+)/,
71
+ patternTo: '$1****$3$4',
72
+ }),
73
+ v.email(),
74
+ )
75
+ email7: string;
76
+
77
+ @Api.field()
78
+ firstName: string;
79
+
80
+ @Api.field()
81
+ lastName: string;
82
+
83
+ @Serializer.getter(function (this: DtoSerializerSimple) {
84
+ return `${this.firstName} ${this.lastName}`;
85
+ })
86
+ @Api.field(v.optional())
87
+ fullName: string;
88
+
89
+ @Api.field(v.serializerGetter(function (this: DtoSerializerSimple) {
90
+ return `${this.firstName} ${this.lastName}`;
91
+ }), v.optional())
92
+ fullName2: string;
93
+
94
+ @Api.field(v.optional())
95
+ get fullName3(): string {
96
+ return `${this.firstName} ${this.lastName}`;
97
+ }
98
+ }
package/src/index.ts CHANGED
@@ -1 +1,2 @@
1
1
  export * from './.metadata/index.ts';
2
+ export * from './lib/index.ts';
@@ -0,0 +1 @@
1
+ export * from './serializer.ts';
@@ -0,0 +1,9 @@
1
+ import { Serializer } from 'vona-module-a-serialization';
2
+
3
+ export function SensitiveEmail(): PropertyDecorator {
4
+ return Serializer.sensitive({
5
+ // eslint-disable-next-line
6
+ patternFrom: /(\w?)(\w+)(\w)(@\w+\.[a-z]+)/,
7
+ patternTo: '$1****$3$4',
8
+ });
9
+ }
@@ -0,0 +1,64 @@
1
+ import type { DtoSerializerArray, DtoSerializerLazy, DtoSerializerSimple } from 'vona-module-test-vona';
2
+ import assert from 'node:assert';
3
+ import { describe, it } from 'node:test';
4
+ import { app } from 'vona-mock';
5
+
6
+ describe('serializer.test.ts', () => {
7
+ const dataSimple = {
8
+ password: '123456',
9
+ password2: '123456',
10
+ email: 'kevin@cabloy.com',
11
+ email2: 'kevin@cabloy.com',
12
+ email3: 'kevin@cabloy.com',
13
+ email4: 'kevin@cabloy.com',
14
+ email5: 'kevin@cabloy.com',
15
+ email6: 'kevin@cabloy.com',
16
+ email7: 'kevin@cabloy.com',
17
+ firstName: 'k',
18
+ lastName: 'v',
19
+ } as DtoSerializerSimple;
20
+ it('action:serializerSimple', async () => {
21
+ await app.bean.executor.mockCtx(async () => {
22
+ const res: DtoSerializerSimple = await app.bean.executor.performAction('post', '/test/vona/serializer/echoSimple', {
23
+ body: dataSimple,
24
+ });
25
+ assert.equal(res.password, undefined);
26
+ assert.equal(res.password2, undefined);
27
+ assert.equal(res.email, 'k****n@cabloy.com');
28
+ assert.equal(res.email2, 'k****n@cabloy.com');
29
+ assert.equal(res.email3, 'k****n@cabloy.com');
30
+ assert.equal(res.email4, 'k****n@cabloy.com');
31
+ assert.equal(res.email5, 'k****n@cabloy.com');
32
+ assert.equal(res.email6, 'k****n@cabloy.com');
33
+ assert.equal(res.email7, 'k****n@cabloy.com');
34
+ assert.equal(res.fullName, 'k v');
35
+ assert.equal(res.fullName2, 'k v');
36
+ assert.equal(res.fullName3, 'k v');
37
+ });
38
+ });
39
+ it('action:serializerArray', async () => {
40
+ await app.bean.executor.mockCtx(async () => {
41
+ const res: DtoSerializerArray[] = await app.bean.executor.performAction('post', '/test/vona/serializer/echoArray', {
42
+ body: [{ simples: [dataSimple], simplesLazy: [dataSimple] }],
43
+ });
44
+ assert.equal(res[0].simples[0].password, '111111');
45
+ assert.equal(res[0].simples[0].password2, undefined);
46
+ assert.equal(res[0].simplesLazy[0].password, '111111');
47
+ assert.equal(res[0].simplesLazy[0].password2, undefined);
48
+ });
49
+ });
50
+ it('action:serializerLazy', async () => {
51
+ await app.bean.executor.mockCtx(async () => {
52
+ const res: DtoSerializerLazy = await app.bean.executor.performAction('post', '/test/vona/serializer/echoLazy', {
53
+ body: {
54
+ simple: dataSimple,
55
+ simpleLazy: dataSimple,
56
+ },
57
+ });
58
+ assert.equal(res.simple.password, '111111');
59
+ assert.equal(res.simple.password2, undefined);
60
+ assert.equal(res.simpleLazy.password, '111111');
61
+ assert.equal(res.simpleLazy.password2, undefined);
62
+ });
63
+ });
64
+ });
@@ -1,6 +0,0 @@
1
- import type { IDecoratorDtoOptions } from 'vona-module-a-web';
2
- export interface IDtoOptionsSerializerTest extends IDecoratorDtoOptions {
3
- }
4
- export declare class DtoSerializerTest {
5
- password: string;
6
- }
@@ -1,13 +0,0 @@
1
- import type { IDecoratorDtoOptions } from 'vona-module-a-web';
2
- import { Api, v } from 'vona-module-a-openapi';
3
- import { Serializer } from 'vona-module-a-serialization';
4
- import { Dto } from 'vona-module-a-web';
5
-
6
- export interface IDtoOptionsSerializerTest extends IDecoratorDtoOptions {}
7
-
8
- @Dto<IDtoOptionsSerializerTest>()
9
- export class DtoSerializerTest {
10
- @Serializer.exclude()
11
- @Api.field(v.min(6))
12
- password: string;
13
- }