@simitgroup/simpleapp-generator 2.0.0-e-alpha → 2.0.0-g-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/ReleaseNote.md +13 -0
  2. package/dist/buildinschemas/index.d.ts +2 -0
  3. package/dist/buildinschemas/index.d.ts.map +1 -1
  4. package/dist/buildinschemas/index.js +5 -3
  5. package/dist/buildinschemas/index.js.map +1 -1
  6. package/dist/buildinschemas/webhook.js +1 -1
  7. package/dist/generate.js +1 -1
  8. package/dist/generate.js.map +1 -1
  9. package/package.json +1 -1
  10. package/src/buildinschemas/index.ts +2 -2
  11. package/src/buildinschemas/{webhook.ts.backup → webhook.ts} +1 -1
  12. package/src/generate.ts +1 -1
  13. package/templates/basic/nest/module.ts.eta +2 -2
  14. package/templates/basic/nest/service.ts.eta +2 -2
  15. package/templates/nest/src/simple-app/.core/features/document-no-format/document-no-format.module.ts.eta +15 -7
  16. package/templates/nest/src/simple-app/.core/features/document-no-format/document-no-format.schema.ts.eta +41 -42
  17. package/templates/nest/src/simple-app/.core/features/document-no-format/document-no-format.service.ts.eta +11 -11
  18. package/templates/nest/src/simple-app/.core/features/log/log.controller.ts.eta +42 -0
  19. package/templates/nest/src/simple-app/.core/features/log/log.module.ts.eta +11 -8
  20. package/templates/nest/src/simple-app/.core/features/log/log.service.ts.eta +48 -13
  21. package/templates/nest/src/simple-app/.core/features/log/schemas/document-event.schema.ts.eta +23 -1
  22. package/templates/nest/src/simple-app/.core/features/mini-app/mini-app-manager/mini-app-manager-policy.service.ts.eta +13 -6
  23. package/templates/nest/src/simple-app/.core/features/mini-app/mini-app-manager/mini-app-manager.service.ts.eta +5 -2
  24. package/templates/nest/src/simple-app/.core/features/policy/policy.service.ts.eta +6 -5
  25. package/templates/nest/src/simple-app/.core/features/profile/profile.service.ts.eta +3 -1
  26. package/templates/nest/src/simple-app/.core/features/queue/queue-base/queue-base.consumer.ts.eta +7 -5
  27. package/templates/nest/src/simple-app/.core/features/simple-app-core-features.module.ts.eta +3 -3
  28. package/templates/nest/src/simple-app/.core/features/user-context/user.context.ts.eta +11 -0
  29. package/templates/nest/src/simple-app/.core/features/webhook/schemas/webhook.schema.ts.eta +36 -36
  30. package/templates/nest/src/simple-app/.core/framework/base/simple-app.service.ts.eta +188 -165
  31. package/templates/nest/src/simple-app/mini-apps/mini-apps.module.ts._eta +14 -0
  32. package/templates/nest/src/simple-app/simple-app.module.ts.eta +5 -1
  33. package/templates/nuxt/components/form/FormDocnoformat.vue._eta +78 -17
  34. package/templates/nuxt/components/renderer/RendererDocHistories.vue._eta +90 -50
  35. package/templates/nuxt/components/user/UserTenantPicker.vue._eta +6 -1
  36. package/templates/nuxt/composables/docformat.generate.ts.eta +2 -2
  37. package/templates/nuxt/plugins/19.simpleapp-mini-app-store.ts.eta +2 -2
  38. /package/src/buildinschemas/{documentnoformat.ts.backup → documentnoformat.ts} +0 -0
@@ -19,11 +19,12 @@ import { foreignkeys } from '../../features/foreign-key/foreignkeys.dict';
19
19
  import { CustomException } from '../custom-exception';
20
20
 
21
21
  import { camelToKebab } from 'src/simple-app/.core/utils/string-utils';
22
- import { DocumentNoFormatService } from '../../features/document-no-format/document-no-format.service';
22
+ import { SimpleAppDocumentNoFormatService } from '../../features/document-no-format/document-no-format.service';
23
23
  import { UserContext } from '../../features/user-context/user.context';
24
24
  import { RunWebhookService } from '../../features/webhook/run-webhook.service';
25
25
  import { UniqueKeyExistResponse, DeleteResultType, IsolationType, MoreProjectionType, SchemaFields, TextSearchBody, PatchManyRequest } from '../schemas';
26
26
  import { SimpleAppLogService } from '../../features/log/log.service';
27
+ import { ProcessErrorException } from 'src/simple-app/features/exception/process-error.exception';
27
28
 
28
29
  @Injectable()
29
30
  export class SimpleAppService<T extends SchemaFields> {
@@ -38,7 +39,7 @@ export class SimpleAppService<T extends SchemaFields> {
38
39
  // @Inject(AuditTrail)
39
40
  // protected audittrail: AuditTrail;
40
41
  // @Inject(DocNumberFormatGenerator)
41
- protected docnogenerator: DocumentNoFormatService;
42
+ protected docnogenerator: SimpleAppDocumentNoFormatService;
42
43
  protected logger = new Logger();
43
44
  protected strictIsolation = true;
44
45
  protected jsonschema: any = {
@@ -62,10 +63,19 @@ export class SimpleAppService<T extends SchemaFields> {
62
63
  protected withDocNumberFormat = false;
63
64
  protected foreignkeys = {};
64
65
  private eventEmitter: EventEmitter2;
65
- private logSvc:SimpleAppLogService;
66
+ private logSvc: SimpleAppLogService;
66
67
  // protected userprovider = new UserContext() ;
67
68
 
68
- constructor(doctype: string, docname: string, newdoc: Model<T>, isolationtype: IsolationType = IsolationType.org, eventEmitter: EventEmitter2, docnogenerator: DocumentNoFormatService,logSvc: SimpleAppLogService,runWebHook: RunWebhookService) {
69
+ constructor(
70
+ doctype: string,
71
+ docname: string,
72
+ newdoc: Model<T>,
73
+ isolationtype: IsolationType = IsolationType.org,
74
+ eventEmitter: EventEmitter2,
75
+ docnogenerator: SimpleAppDocumentNoFormatService,
76
+ logSvc: SimpleAppLogService,
77
+ runWebHook: RunWebhookService,
78
+ ) {
69
79
  // console.log("-------init simpleapp service abstract class -------userprovider=",typeof this.userprovider)
70
80
  this.eventEmitter = eventEmitter;
71
81
  this.documentType = doctype.toUpperCase();
@@ -73,8 +83,8 @@ export class SimpleAppService<T extends SchemaFields> {
73
83
  this.doc = newdoc;
74
84
  this.docnogenerator = docnogenerator;
75
85
  this.isolationtype = isolationtype;
76
- this.logSvc = logSvc
77
- this.runWebHook = runWebHook
86
+ this.logSvc = logSvc;
87
+ this.runWebHook = runWebHook;
78
88
  // this.tenantdoc = tenantdoc
79
89
  }
80
90
  getDocumentType = () => this.documentType;
@@ -348,100 +358,105 @@ export class SimpleAppService<T extends SchemaFields> {
348
358
  }
349
359
  }
350
360
 
351
- async createManyWithId(appuser: UserContext, datas: T[]) {
352
- if (Array.isArray(datas)) {
353
- for (let i = 0; i < datas.length; i++) {
354
- const data = datas[i];
355
- let isolationFilter: any = { ...appuser.getCreateFilterWithId() };
356
- isolationFilter = this.polishIsolationFilter(isolationFilter, data);
357
-
358
- Object.assign(data, isolationFilter);
359
- this.reCalculateValue(data);
360
- await this.validateData(appuser, data);
361
- this.applyNestedDateTime(appuser, data, 'create');
362
- }
363
-
364
- const dbsession = appuser.getDBSession();
365
- if (dbsession && !dbsession.inTransaction()) {
366
- dbsession.startTransaction({ readPreference: 'primary' });
367
- }
368
-
369
- const result = await this.doc.insertMany(datas, { session: dbsession });
370
- await this.addManyAuditEvents(appuser, this.documentName, 'createMany', datas);
371
- for (let i = 0; i < datas.length; i++) {
372
- appuser.addInsertedRecordId(this.documentName, datas[i]._id);
373
- }
374
- return result;
375
- } else {
376
- throw new BadRequestException(this.getDocumentType() + ': create many only support array');
377
- }
378
- }
361
+ // seems no use, and confusing
362
+ // async createManyWithId(appuser: UserContext, datas: T[]) {
363
+ // if (Array.isArray(datas)) {
364
+ // for (let i = 0; i < datas.length; i++) {
365
+ // const data = datas[i];
366
+ // let isolationFilter: any = { ...appuser.getCreateFilterWithId() };
367
+ // isolationFilter = this.polishIsolationFilter(isolationFilter, data);
368
+
369
+ // Object.assign(data, isolationFilter);
370
+ // this.reCalculateValue(data);
371
+ // await this.validateData(appuser, data);
372
+ // this.applyNestedDateTime(appuser, data, 'create');
373
+ // }
374
+
375
+ // const dbsession = appuser.getDBSession();
376
+ // if (dbsession && !dbsession.inTransaction()) {
377
+ // dbsession.startTransaction({ readPreference: 'primary' });
378
+ // }
379
+
380
+ // const result = await this.doc.insertMany(datas, { session: dbsession });
381
+ // await this.addManyAuditEvents(appuser, this.documentName, 'createMany', datas);
382
+ // for (let i = 0; i < datas.length; i++) {
383
+ // appuser.addInsertedRecordId(this.documentName, datas[i]._id);
384
+ // }
385
+ // return result;
386
+ // } else {
387
+ // throw new BadRequestException(this.getDocumentType() + ': create many only support array');
388
+ // }
389
+ // }
379
390
 
380
391
  /**
381
392
  * create many from array with hooks (temporary used for generate sample data only)
382
393
  * @param appuser
383
394
  * @param datas
384
395
  */
385
- async createManyWithHook(appuser: UserContext, datas: T[]) {
386
- if (Array.isArray(datas)) {
387
- for (let i = 0; i < datas.length; i++) {
388
- const data = datas[i];
389
-
390
- let result;
391
- const dbsession = appuser.getDBSession();
392
- if (dbsession && !dbsession.inTransaction()) {
393
- dbsession.startTransaction({ readPreference: 'primary' });
394
- }
395
-
396
- if (this.withDocNumberFormat && !data[this.documentIdentityCode]) {
397
- await this.genNewDocNo(appuser, data);
398
- }
399
-
400
- let isolationFilter: any = { ...appuser.getCreateFilterWithId() };
401
- isolationFilter = this.polishIsolationFilter(isolationFilter, data);
402
-
403
- Object.assign(data, isolationFilter);
404
- this.reCalculateValue(data);
405
- await this.validateData(appuser, data);
406
- this.applyNestedDateTime(appuser, data, 'create');
407
-
408
- //new way of hook
409
- await this.runEvent(appuser, this.setHookName('beforeCreate'), { data: data }, false);
410
-
411
- const newdoc = new this.doc(data);
412
-
413
- try {
414
- result = await newdoc.save({ session: dbsession });
415
- await this.addAuditEvent(appuser, this.documentName, result._id, 'create', data);
416
- appuser.addInsertedRecordId(this.documentName, result._id);
417
- } catch (err) {
418
- this.logger.error(err);
419
- const processdata = await this.runEvent(appuser, 'processdata.processError', {
420
- err: err,
421
- });
422
-
423
- if (!processdata) {
424
- throw new InternalServerErrorException(err);
425
- } else {
426
- throw new CustomException(processdata.code, processdata.msg);
427
- }
428
- }
429
-
430
- try {
431
- //new way of hook
432
- await this.runEvent(appuser, this.setHookName('afterCreate'), { data: data }, false);
433
- await this.callWebhook(appuser, 'create', result);
434
-
435
- // return result as T;
436
- } catch (err) {
437
- throw new InternalServerErrorException(`createHook ${this.documentType} error: ${JSON.stringify(err)}`, `${this.documentType} createHook error`);
438
- }
439
- }
440
- } else {
441
- throw new BadRequestException(this.getDocumentType() + ': create many only support array');
442
- }
443
- return 'ok';
444
- }
396
+ //seems nobody use. also confusing
397
+ // async createManyWithHook(appuser: UserContext, datas: T[]) {
398
+ // if (Array.isArray(datas)) {
399
+ // for (let i = 0; i < datas.length; i++) {
400
+ // const data = datas[i];
401
+
402
+ // let result;
403
+ // const dbsession = appuser.getDBSession();
404
+ // if (dbsession && !dbsession.inTransaction()) {
405
+ // dbsession.startTransaction({ readPreference: 'primary' });
406
+ // }
407
+
408
+ // if (this.withDocNumberFormat && !data[this.documentIdentityCode]) {
409
+ // await this.genNewDocNo(appuser, data);
410
+ // }
411
+
412
+ // let isolationFilter: any = { ...appuser.getCreateFilterWithId() };
413
+ // isolationFilter = this.polishIsolationFilter(isolationFilter, data);
414
+
415
+ // Object.assign(data, isolationFilter);
416
+ // this.reCalculateValue(data);
417
+ // await this.validateData(appuser, data);
418
+ // this.applyNestedDateTime(appuser, data, 'create');
419
+
420
+ // //new way of hook
421
+ // await this.runEvent(appuser, this.setHookName('beforeCreate'), { data: data }, false);
422
+
423
+ // const newdoc = new this.doc(data);
424
+
425
+ // try {
426
+ // result = await newdoc.save({ session: dbsession });
427
+ // await this.addAuditEvent(appuser, this.documentName, result._id, 'create', data);
428
+ // appuser.addInsertedRecordId(this.documentName, result._id);
429
+ // } catch (err) {
430
+ // this.logger.error(err);
431
+ // throw new ProcessErrorException('ERR_CREATE_MANY',err.message,{
432
+ // err:err
433
+ // })
434
+ // // const processdata = await this.runEvent(appuser, 'processdata.processError', {
435
+ // // err: err,
436
+ // // });
437
+
438
+ // // if (!processdata) {
439
+ // // throw new InternalServerErrorException(err);
440
+ // // } else {
441
+ // // throw new CustomException(processdata.code, processdata.msg);
442
+ // // }
443
+ // }
444
+
445
+ // try {
446
+ // //new way of hook
447
+ // await this.runEvent(appuser, this.setHookName('afterCreate'), { data: data }, false);
448
+ // await this.callWebhook(appuser, 'create', result);
449
+
450
+ // // return result as T;
451
+ // } catch (err) {
452
+ // throw new InternalServerErrorException(`createHook ${this.documentType} error: ${JSON.stringify(err)}`, `${this.documentType} createHook error`);
453
+ // }
454
+ // }
455
+ // } else {
456
+ // throw new BadRequestException(this.getDocumentType() + ': create many only support array');
457
+ // }
458
+ // return 'ok';
459
+ // }
445
460
 
446
461
  /**
447
462
  * create many from array, for performance reason it submit all item in 1 go, so it won't implement hooks
@@ -464,76 +479,85 @@ export class SimpleAppService<T extends SchemaFields> {
464
479
  if (dbsession && !dbsession.inTransaction()) {
465
480
  dbsession.startTransaction({ readPreference: 'primary' });
466
481
  }
467
- const result = await this.doc.insertMany(datas, { session: dbsession });
468
- await this.addManyAuditEvents(appuser, this.documentName, 'createMany', datas);
469
- return result;
482
+
483
+ try{
484
+ const result = await this.doc.insertMany(datas, { session: dbsession });
485
+ await this.addManyAuditEvents(appuser, this.documentName, 'createMany', datas);
486
+ return result;
487
+ }catch(e){
488
+ throw e
489
+ }
490
+
491
+
470
492
  } else {
471
493
  throw new BadRequestException(this.getDocumentType() + ': create many only support array');
472
494
  }
473
495
  }
474
- async createWithId(appuser: UserContext, data: T) {
475
- let result;
476
496
 
477
- if (!data._id) {
478
- data._id = crypto.randomUUID();
479
- }
480
- const dbsession = appuser.getDBSession();
481
- if (dbsession && !dbsession.inTransaction()) {
482
- dbsession.startTransaction({ readPreference: 'primary' });
483
- }
484
-
485
- this.logger.debug('this.withDocNumberFormat :' + this.withDocNumberFormat + ' && ' + '!data[this.documentIdentityCode] ==' + !data[this.documentIdentityCode]);
486
- if (this.withDocNumberFormat && !data[this.documentIdentityCode]) {
487
- await this.genNewDocNo(appuser, data);
488
- }
489
-
490
- let isolationFilter: any = { ...appuser.getCreateFilterWithId() };
491
- isolationFilter = this.polishIsolationFilter(isolationFilter, data);
492
-
493
- this.logger.debug('isolationFilter', 'SimpleAppService');
494
- this.logger.debug(isolationFilter, 'SimpleAppService');
495
- this.logger.debug('Create data before isolation', 'SimpleAppService');
496
- this.logger.debug(data, 'SimpleAppService');
497
- Object.assign(data, isolationFilter);
498
- this.reCalculateValue(data);
499
- await this.validateData(appuser, data);
500
- this.logger.debug(data, `after create validation`);
501
- this.applyNestedDateTime(appuser, data, 'create');
502
-
503
- //new way of hook
504
-
505
- await this.runEvent(appuser, this.setHookName('beforeCreate'), { data: data }, false);
506
-
507
- this.logger.debug(data, `Create Record ${this.documentName}`);
508
- const newdoc = new this.doc(data);
509
- await this.identifyForeignKeys(appuser, data);
510
- try {
511
- result = await newdoc.save({ session: dbsession });
512
- await this.addAuditEvent(appuser, this.documentName, result._id, 'create', data);
513
- appuser.addInsertedRecordId(this.documentName, result._id);
514
- } catch (err) {
515
- this.logger.error(err);
516
- const processdata = await this.runEvent(appuser, 'processdata.processError', {
517
- err: err,
518
- });
519
-
520
- if (!processdata) {
521
- throw new InternalServerErrorException(err);
522
- } else {
523
- throw new CustomException(processdata.code, processdata.msg);
524
- }
525
- }
526
-
527
- try {
528
- //new way of hook
529
- await this.runEvent(appuser, this.setHookName('afterCreate'), { data: result }, false);
530
-
531
- await this.callWebhook(appuser, 'create', result);
532
- return result as T;
533
- } catch (err) {
534
- throw new InternalServerErrorException(`createHook ${this.documentType} error: ${JSON.stringify(err)}`, `${this.documentType} createHook error`);
535
- }
536
- }
497
+ //seems nobody use, also confusing
498
+ // async createWithId(appuser: UserContext, data: T) {
499
+ // let result;
500
+
501
+ // if (!data._id) {
502
+ // data._id = crypto.randomUUID();
503
+ // }
504
+ // const dbsession = appuser.getDBSession();
505
+ // if (dbsession && !dbsession.inTransaction()) {
506
+ // dbsession.startTransaction({ readPreference: 'primary' });
507
+ // }
508
+
509
+ // this.logger.debug('this.withDocNumberFormat :' + this.withDocNumberFormat + ' && ' + '!data[this.documentIdentityCode] ==' + !data[this.documentIdentityCode]);
510
+ // if (this.withDocNumberFormat && !data[this.documentIdentityCode]) {
511
+ // await this.genNewDocNo(appuser, data);
512
+ // }
513
+
514
+ // let isolationFilter: any = { ...appuser.getCreateFilterWithId() };
515
+ // isolationFilter = this.polishIsolationFilter(isolationFilter, data);
516
+
517
+ // this.logger.debug('isolationFilter', 'SimpleAppService');
518
+ // this.logger.debug(isolationFilter, 'SimpleAppService');
519
+ // this.logger.debug('Create data before isolation', 'SimpleAppService');
520
+ // this.logger.debug(data, 'SimpleAppService');
521
+ // Object.assign(data, isolationFilter);
522
+ // this.reCalculateValue(data);
523
+ // await this.validateData(appuser, data);
524
+ // this.logger.debug(data, `after create validation`);
525
+ // this.applyNestedDateTime(appuser, data, 'create');
526
+
527
+ // //new way of hook
528
+
529
+ // await this.runEvent(appuser, this.setHookName('beforeCreate'), { data: data }, false);
530
+
531
+ // this.logger.debug(data, `Create Record ${this.documentName}`);
532
+ // const newdoc = new this.doc(data);
533
+ // await this.identifyForeignKeys(appuser, data);
534
+ // try {
535
+ // result = await newdoc.save({ session: dbsession });
536
+ // await this.addAuditEvent(appuser, this.documentName, result._id, 'create', data);
537
+ // appuser.addInsertedRecordId(this.documentName, result._id);
538
+ // } catch (err) {
539
+ // this.logger.error(err);
540
+ // const processdata = await this.runEvent(appuser, 'processdata.processError', {
541
+ // err: err,
542
+ // });
543
+
544
+ // if (!processdata) {
545
+ // throw new InternalServerErrorException(err);
546
+ // } else {
547
+ // throw new CustomException(processdata.code, processdata.msg);
548
+ // }
549
+ // }
550
+
551
+ // try {
552
+ // //new way of hook
553
+ // await this.runEvent(appuser, this.setHookName('afterCreate'), { data: result }, false);
554
+
555
+ // await this.callWebhook(appuser, 'create', result);
556
+ // return result as T;
557
+ // } catch (err) {
558
+ // throw new InternalServerErrorException(`createHook ${this.documentType} error: ${JSON.stringify(err)}`, `${this.documentType} createHook error`);
559
+ // }
560
+ // }
537
561
 
538
562
  async create(appuser: UserContext, data: T, noStartTransaction: boolean = false) {
539
563
  let result;
@@ -1038,7 +1062,7 @@ export class SimpleAppService<T extends SchemaFields> {
1038
1062
  return createresult;
1039
1063
  } else {
1040
1064
  const updateresult = await this.findIdThenPatch(appuser, id, data);
1041
- const finaldata = await this.findById(appuser, id);
1065
+ const finaldata = await this.findById(appuser, id);
1042
1066
  await this.runEvent(appuser, this.setHookName('afterSetStatus'), { docStatus: docstatus, data: finaldata }, false);
1043
1067
  await this.addAuditEvent(appuser, this.documentName, id, docstatus, data);
1044
1068
 
@@ -1078,10 +1102,9 @@ export class SimpleAppService<T extends SchemaFields> {
1078
1102
  */
1079
1103
  async runEvent(appuser: UserContext, eventName: string, payloads: any, enforce: boolean = true) {
1080
1104
  try {
1081
-
1082
1105
  if (enforce && !this.eventEmitter.hasListeners(eventName)) {
1083
1106
  throw new InternalServerErrorException(`${eventName} seems no listener`);
1084
- } else if (this.eventEmitter.hasListeners(eventName)) {
1107
+ } else if (this.eventEmitter.hasListeners(eventName)) {
1085
1108
  const res = await this.eventEmitter.emitAsync(eventName, appuser, payloads);
1086
1109
 
1087
1110
  if (!res) {
@@ -1276,16 +1299,16 @@ export class SimpleAppService<T extends SchemaFields> {
1276
1299
  //only realtime webhook supported at this moment
1277
1300
  async callWebhook(appuser: UserContext, actionName: string, data: any) {
1278
1301
  try {
1279
- await this.runWebHook.run(appuser, this.documentName, actionName, data);
1302
+ await this.runWebHook.run(appuser, this.documentName, actionName, data);
1280
1303
  } catch (e) {
1281
1304
  throw new InternalServerErrorException(e);
1282
1305
  }
1283
1306
  }
1284
1307
 
1285
1308
  async addAuditEvent(appUser: UserContext, documentName: string, id: string, eventType: string, data: any) {
1286
- await this.logSvc.addEvent(appUser,documentName,id,eventType,data)
1309
+ await this.logSvc.addEvent(appUser, documentName, id, eventType, data);
1287
1310
  }
1288
1311
  async addManyAuditEvents(appUser: UserContext, documentName: string, eventType: string, datas: any) {
1289
- await this.logSvc.addManyEvents(appUser,documentName,eventType,datas)
1312
+ await this.logSvc.addManyEvents(appUser, documentName, eventType, datas);
1290
1313
  }
1291
1314
  }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * This file was automatically generated by simpleapp generator.
3
+ * --remove-this-line-to-prevent-override--
4
+ * last change 2025-09-01
5
+ * Author: Ks Tan
6
+ */
7
+ import { Module } from '@nestjs/common';
8
+ @Module({
9
+ // QueueTuitionClassModule
10
+ imports: [],
11
+ providers: [],
12
+ exports: [],
13
+ })
14
+ export class SimpleAppMiniAppsModule {}
@@ -11,7 +11,7 @@ import {SimpleAppEventsModule} from './events/events.module'
11
11
  import {SimpleAppFeaturesModule} from './features/features.module'
12
12
 
13
13
  import { SimpleAppResourceApiModule } from './apis/resource-api.module';
14
-
14
+ import { SimpleAppMiniAppsModule } from './mini-apps/mini-apps.module';
15
15
 
16
16
  @Module({
17
17
  imports: [
@@ -19,6 +19,8 @@ import { SimpleAppResourceApiModule } from './apis/resource-api.module';
19
19
  SimpleAppResourcesModule,
20
20
  SimpleAppEventsModule,
21
21
  SimpleAppResourceApiModule,
22
+ SimpleAppFeaturesModule,
23
+ SimpleAppMiniAppsModule
22
24
  ],
23
25
  controllers: [],
24
26
  providers: [],
@@ -27,6 +29,8 @@ import { SimpleAppResourceApiModule } from './apis/resource-api.module';
27
29
  SimpleAppResourcesModule,
28
30
  SimpleAppEventsModule,
29
31
  SimpleAppResourceApiModule,
32
+ SimpleAppFeaturesModule,
33
+ SimpleAppMiniAppsModule
30
34
  ]
31
35
  })
32
36
  export class SimpleAppModule {}
@@ -7,9 +7,7 @@
7
7
  :document="doc"
8
8
  @on="actionListener"
9
9
  ></SimpleAppFormToolBar>
10
- <div
11
- class="grid grid-cols-1 lg:grid-cols-2 gap-4 p-2"
12
- >
10
+ <div class="grid grid-cols-1 lg:grid-cols-2 gap-4 p-2">
13
11
  <SimpleAppInput
14
12
  :input-type="SimpleAppInputType.autocomplete"
15
13
  :setting="o.getField('#/properties/branch')"
@@ -19,11 +17,15 @@
19
17
  :readonly="!doc.isNew()"
20
18
  :input-type="SimpleAppInputType.select"
21
19
  :setting="o.getField('#/properties/docNoType')"
22
- :options="getAllDocFormats().map((item) => item.docType)"
20
+ :options="
21
+ getAllDocFormats().map((item) => ({
22
+ label: docNoTypeMapping[item.docType] || item.docType,
23
+ value: item.docType,
24
+ }))
25
+ "
23
26
  v-model="data.docNoType"
24
27
  />
25
28
 
26
-
27
29
  <SimpleAppInput
28
30
  :input-type="SimpleAppInputType.text"
29
31
  :setting="o.getField('#/properties/docNoFormatNo')"
@@ -47,7 +49,6 @@
47
49
  v-model="data.default"
48
50
  />
49
51
 
50
-
51
52
  <SimpleAppInput
52
53
  :input-type="SimpleAppInputType.text"
53
54
  :setting="o.getField('#/properties/docNoPattern')"
@@ -65,27 +66,43 @@
65
66
  </div>
66
67
  </SimpleAppForm>
67
68
  <DebugDocumentData v-model="data" :label="doc.getDocName()" />
69
+ <DataTable
70
+ :value="formatParams"
71
+ class="p-datatable-sm mt-6"
72
+ stripedRows
73
+ responsiveLayout="scroll"
74
+ >
75
+ <template #header>
76
+ <div class="text-sm font-semibold">Format Parameters</div>
77
+ </template>
78
+ <Column
79
+ field="placeholder"
80
+ header="Placeholder"
81
+ style="width: 30%"
82
+ class="text-xs"
83
+ />
84
+ <Column field="description" header="Description" class="text-xs" />
85
+ </DataTable>
68
86
  </div>
69
87
  </template>
70
88
 
71
89
  <script setup lang="ts">
72
90
  /**
73
- * This file was automatically generated by simpleapp generator during initialization. It is changable.
74
- * --remove-this-line-to-prevent-override--
91
+ * This file was automatically generated by simpleapp generator.
75
92
  * last change 2024-02-16
76
93
  * Author: Ks Tan
77
94
  */
78
95
  import { SimpleAppInputType, FormCrudEvent } from "~/types";
79
- import { Docnoformat } from "~/simpleapp/generate/types";
80
- import { DocnoformatDoc } from "~/simpleapp/docs/DocnoformatDoc";
96
+ import { DocumentNoFormat } from "~/simpleapp/generate/openapi";
97
+ import { DocumentnoformatDoc } from "~/simpleapp/docs/DocumentnoformatDoc";
81
98
 
82
99
  const props = defineProps<{
83
100
  _id?: string;
84
- doc?: DocnoformatDoc;
85
- paras?: Docnoformat;
101
+ doc?: DocumentnoformatDoc;
102
+ paras?: Partial<DocumentNoFormat>;
86
103
  }>();
87
104
 
88
- const doc = props.doc ?? useNuxtApp().$DocnoformatDoc();
105
+ const doc = props.doc ?? useNuxtApp().$DocumentnoformatDoc()
89
106
  const data = doc.getReactiveData();
90
107
  const sample = ref("");
91
108
  const emits = defineEmits(["after"]);
@@ -94,9 +111,41 @@ const id = computed(() => props._id ?? "");
94
111
  /************ start default methods ****************/
95
112
 
96
113
  const newData = () => {
97
- doc.setNew()
98
- delete data.value.branch
99
- }
114
+ doc.setNew();
115
+ delete data.value.branch;
116
+ };
117
+
118
+ const formatParams = [
119
+ {
120
+ placeholder: "[0000]",
121
+ description: "0001 displays the transaction numbering.",
122
+ },
123
+ {
124
+ placeholder: "{YYYY}",
125
+ description: "Displays 4-digit current year (e.g., 2025-9999).",
126
+ },
127
+ {
128
+ placeholder: "{YY}",
129
+ description: "Displays 2-digit current year (e.g., 25).",
130
+ },
131
+ {
132
+ placeholder: "{MM}",
133
+ description: "Displays 2-digit current month (e.g., 01-12).",
134
+ },
135
+ { placeholder: "{ddd}", description: "Displays current day (e.g., Tue)." },
136
+ {
137
+ placeholder: "{DD}",
138
+ description: "Displays 2-digit day of the month (e.g., 01-31).",
139
+ },
140
+ {
141
+ placeholder: "{YYMM}",
142
+ description: "Displays 2-digit year and 2-digit month (e.g., 2504).",
143
+ },
144
+ {
145
+ placeholder: "{YYYYMM}",
146
+ description: "Displays 4-digit year and 2-digit month (e.g., 202504).",
147
+ },
148
+ ];
100
149
 
101
150
  const getRecord = async () => {
102
151
  if (id.value && id.value != "new") {
@@ -106,6 +155,18 @@ const getRecord = async () => {
106
155
  }
107
156
  };
108
157
 
158
+ const docNoTypeMapping: Record<string, string> = {
159
+ CN: "Credit Note",
160
+ ANNOUNCEMENT: "Announcement",
161
+ ENROLL: "Enrolment",
162
+ INV: "Invoice",
163
+ PAY: "Payment",
164
+ REFUND: "Refund",
165
+ STU: "Student",
166
+ TEACHER: "Teacher",
167
+ TUITION: "Tuition Class",
168
+ };
169
+
109
170
  getRecord();
110
171
  watch(id, async () => await getRecord());
111
172
  /************ end default methods ****************/
@@ -134,7 +195,7 @@ onMounted(async () => {
134
195
  // };
135
196
  /************ end api methods ****************/
136
197
  const updateSample = () => {
137
- sample.value = "Example: " + previewDocNo();
198
+ sample.value = "Format Sample: " + previewDocNo();
138
199
  };
139
200
 
140
201
  const previewDocNo = (): string => {