@simitgroup/simpleapp-generator 1.6.4-c-alpha → 1.6.4-e-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 (66) hide show
  1. package/dist/buildinschemas/documentevent.d.ts +3 -0
  2. package/dist/buildinschemas/documentevent.d.ts.map +1 -0
  3. package/dist/buildinschemas/documentevent.js +38 -0
  4. package/dist/buildinschemas/documentevent.js.map +1 -0
  5. package/dist/buildinschemas/index.d.ts +2 -0
  6. package/dist/buildinschemas/index.d.ts.map +1 -1
  7. package/dist/buildinschemas/index.js +5 -1
  8. package/dist/buildinschemas/index.js.map +1 -1
  9. package/dist/buildinschemas/tenant.d.ts.map +1 -1
  10. package/dist/buildinschemas/tenant.js +9 -0
  11. package/dist/buildinschemas/tenant.js.map +1 -1
  12. package/dist/buildinschemas/webhook.d.ts.map +1 -1
  13. package/dist/buildinschemas/webhook.js +21 -3
  14. package/dist/buildinschemas/webhook.js.map +1 -1
  15. package/dist/buildinschemas/webhookhistory.d.ts +3 -0
  16. package/dist/buildinschemas/webhookhistory.d.ts.map +1 -0
  17. package/dist/buildinschemas/webhookhistory.js +44 -0
  18. package/dist/buildinschemas/webhookhistory.js.map +1 -0
  19. package/dist/framework.js +1 -1
  20. package/dist/framework.js.map +1 -1
  21. package/dist/generate.js +1 -1
  22. package/dist/generate.js.map +1 -1
  23. package/package.json +1 -1
  24. package/src/buildinschemas/documentevent.ts +36 -0
  25. package/src/buildinschemas/index.ts +3 -1
  26. package/src/buildinschemas/tenant.ts +9 -0
  27. package/src/buildinschemas/webhook.ts +22 -3
  28. package/src/buildinschemas/webhookhistory.ts +42 -0
  29. package/src/framework.ts +1 -1
  30. package/src/generate.ts +1 -1
  31. package/templates/basic/nest/apischema.ts.eta +6 -2
  32. package/templates/basic/nest/controller.ts.eta +4 -3
  33. package/templates/basic/nest/default.ts.eta +6 -5
  34. package/templates/basic/nuxt/default.ts.eta +2 -0
  35. package/templates/basic/nuxt/simpleapp.generate.client.ts.eta +1 -6
  36. package/templates/nest/src/simpleapp/apischemas/index.ts._eta +17 -0
  37. package/templates/nest/src/simpleapp/generate/commons/audittrail.service.ts.eta +37 -7
  38. package/templates/nest/src/simpleapp/generate/commons/runwebhook.service.ts.eta +39 -20
  39. package/templates/nest/src/simpleapp/generate/commons/user.context.ts.eta +60 -41
  40. package/templates/nest/src/simpleapp/generate/controllers/simpleapp.controller.ts.eta +3 -3
  41. package/templates/nest/src/simpleapp/generate/processors/simpleapp.processor.ts.eta +100 -34
  42. package/templates/nest/src/simpleapp/profile/profile.controller.ts.eta +16 -8
  43. package/templates/nest/src/simpleapp/profile/profile.service.ts.eta +7 -0
  44. package/templates/nest/src/simpleapp/simpleapp.module.ts.eta +3 -3
  45. package/templates/nest/src/simpleapp/types/index.ts._eta +14 -0
  46. package/templates/nuxt/app.vue.eta +9 -7
  47. package/templates/nuxt/components/image/ImageAvatar.vue.eta._vue +7 -14
  48. package/templates/nuxt/components/list/ListView.vue.eta +97 -111
  49. package/templates/nuxt/components/renderer/RendererDocHistories.vue.eta +102 -42
  50. package/templates/nuxt/components/search/SearchBox.vue._eta +371 -0
  51. package/templates/nuxt/components/search/SearchBoxBefore.vue._eta +11 -0
  52. package/templates/nuxt/components/search/SearchBoxProduct.vue._eta +26 -0
  53. package/templates/nuxt/components/simpleApp/SimpleAppAutocomplete.vue.eta +24 -3
  54. package/templates/nuxt/components/simpleApp/SimpleAppCalendarInput.vue.eta +1 -0
  55. package/templates/nuxt/components/simpleApp/SimpleAppChildrenList.vue.eta +10 -5
  56. package/templates/nuxt/components/simpleApp/SimpleAppFormToolBar.vue._eta +4 -3
  57. package/templates/nuxt/components/user/UserTenantPicker.vue.eta +18 -16
  58. package/templates/nuxt/composables/getOpenApi.generate.ts.eta +6 -49
  59. package/templates/nuxt/composables/stringHelper.generate.ts.eta +2 -2
  60. package/templates/nuxt/middleware/30.acl.global.ts.eta +6 -5
  61. package/templates/nuxt/pages/[xorg]/pickgroup.vue._eta +28 -27
  62. package/templates/nuxt/pages/picktenant.vue._eta +3 -3
  63. package/templates/nuxt/plugins/20.simpleapp-userstore.ts.eta +49 -29
  64. package/templates/nuxt/simpleapp/generate/clients/SimpleAppClient.ts.eta +7 -1
  65. package/templates/nuxt/types/others.ts.eta +7 -1
  66. package/tsconfig.tsbuildinfo +1 -1
@@ -41,6 +41,7 @@ import {
41
41
  MoreProjectionType,
42
42
  DeleteResultType,
43
43
  WorkflowName,
44
+ TextSearchBody,
44
45
  } from '../types';
45
46
  @Injectable()
46
47
  export class SimpleAppService<T extends { _id?: string; __v?: number }> {
@@ -269,6 +270,7 @@ export class SimpleAppService<T extends { _id?: string; __v?: number }> {
269
270
  .sort(sort);
270
271
  } else {
271
272
  const pipelines = this.searchToAggregate(
273
+ appuser,
272
274
  filters,
273
275
  projection,
274
276
  sort,
@@ -293,14 +295,17 @@ export class SimpleAppService<T extends { _id?: string; __v?: number }> {
293
295
  // return this;
294
296
  }
295
297
 
296
- async fullTextSearch(appuser: UserContext, keyword: string) {
298
+ async fullTextSearch(appuser: UserContext, body: TextSearchBody) {
297
299
  const isolationFilter = { ...this.getIsolationFilter(appuser) };
298
300
  this.polishIsolationFilter(isolationFilter);
299
301
 
300
- const filters = { $text: { $search: keyword } };
302
+ const filters = { $text: { $search: body.keyword } };
301
303
  const newfilters: FilterQuery<T> = { ...filters, ...isolationFilter };
302
-
303
- return await this.doc.find(newfilters);
304
+ const fields = body.fields;
305
+ const sorts = body.sorts;
306
+ //not yet support lookup mapper
307
+ const lookup = body.lookup;
308
+ return await this.doc.find(newfilters, fields, sorts);
304
309
  }
305
310
  async findById(appuser: UserContext, id: string) {
306
311
  if (this.hooks.beforeFetchRecord)
@@ -335,7 +340,14 @@ export class SimpleAppService<T extends { _id?: string; __v?: number }> {
335
340
  await this.validateData(appuser, data);
336
341
  this.applyNestedDateTime(appuser, data, 'create');
337
342
  }
343
+
338
344
  const result = await this.doc.insertMany(datas);
345
+ await this.audittrail.addManyEvents(
346
+ appuser,
347
+ this.documentName,
348
+ 'createMany',
349
+ datas,
350
+ );
339
351
  return result;
340
352
  } else {
341
353
  throw new BadRequestException(
@@ -346,6 +358,7 @@ export class SimpleAppService<T extends { _id?: string; __v?: number }> {
346
358
 
347
359
  async create(appuser: UserContext, data: T) {
348
360
  let result;
361
+
349
362
  if (!data._id) {
350
363
  data._id = crypto.randomUUID();
351
364
  }
@@ -354,6 +367,7 @@ export class SimpleAppService<T extends { _id?: string; __v?: number }> {
354
367
  dbsession.startTransaction();
355
368
  }
356
369
 
370
+
357
371
  this.logger.debug(
358
372
  'this.withDocNumberFormat :' +
359
373
  this.withDocNumberFormat +
@@ -365,7 +379,7 @@ export class SimpleAppService<T extends { _id?: string; __v?: number }> {
365
379
  await this.genNewDocNo(appuser, data);
366
380
  }
367
381
 
368
- if (this.hooks.beforeCreate) await this.hooks.beforeCreate(appuser, data);
382
+
369
383
  let isolationFilter: any = { ...appuser.getCreateFilter() };
370
384
  isolationFilter = this.polishIsolationFilter(isolationFilter, data);
371
385
 
@@ -379,11 +393,19 @@ export class SimpleAppService<T extends { _id?: string; __v?: number }> {
379
393
  this.logger.debug(data, `after create validation`);
380
394
  this.applyNestedDateTime(appuser, data, 'create');
381
395
 
396
+ if (this.hooks.beforeCreate) await this.hooks.beforeCreate(appuser, data);
382
397
  this.logger.debug(data, `Create Record ${this.documentName}`);
383
398
  const newdoc = new this.doc(data);
384
399
  await this.identifyForeignKeys(appuser, data);
385
400
  try {
386
401
  result = await newdoc.save({ session: dbsession });
402
+ await this.audittrail.addEvent(
403
+ appuser,
404
+ this.documentName,
405
+ result._id,
406
+ 'create',
407
+ data,
408
+ );
387
409
  appuser.addInsertedRecordId(this.documentName, result._id);
388
410
  } catch (err) {
389
411
  this.logger.error(err);
@@ -543,6 +565,13 @@ export class SimpleAppService<T extends { _id?: string; __v?: number }> {
543
565
  const result = await this.doc
544
566
  .deleteOne(filterIsolation)
545
567
  .session(dbsession);
568
+ await this.audittrail.addEvent(
569
+ appuser,
570
+ this.documentName,
571
+ id,
572
+ 'delete',
573
+ deletedata,
574
+ );
546
575
 
547
576
  appuser.addDeletedRecordId(this.documentName, id);
548
577
  const deleteresult: DeleteResultType<T> = {
@@ -576,50 +605,64 @@ export class SimpleAppService<T extends { _id?: string; __v?: number }> {
576
605
  // };
577
606
 
578
607
  findIdThenUpdate = async (appuser: UserContext, id: string, data: T) => {
579
-
580
608
  try {
581
- //version exists, need ensure different only 1
609
+ //version exists, need ensure different only 1
582
610
  const existingdata = await this.findById(appuser, id);
583
- if(!existingdata) throw new NotFoundException(`${this.documentName} findIdThenUpdate: _id:${id} not found`, 'not found');
611
+ if (!existingdata)
612
+ throw new NotFoundException(
613
+ `${this.documentName} findIdThenUpdate: _id:${id} not found`,
614
+ 'not found',
615
+ );
584
616
 
585
- this.logger.debug("update id:"+id,this.documentName+' findIdThenUpdate')
617
+ this.logger.debug(
618
+ 'update id:' + id,
619
+ this.documentName + ' findIdThenUpdate',
620
+ );
586
621
  if (typeof data.__v == 'number' && data.__v != existingdata.__v) {
587
622
  throw new BadRequestException(
588
623
  `You submit older version data "v${data.__v}"" but latest version = "v${existingdata.__v}"`,
589
624
  );
590
625
  }
591
- this.logger.debug("warn1",existingdata)
592
- data.__v = existingdata.__v + 1;
593
- // if (!existingdata) {
594
- // throw new NotFoundException(`${id} not found`, 'not found');
595
- // }
596
- this.logger.debug("warn2")
597
- if (this.hooks.beforeUpdate)
598
- await this.hooks.beforeUpdate(appuser, id, data, existingdata);
626
+ this.logger.debug('warn1', existingdata);
627
+ data.__v = existingdata.__v + 1;
628
+ // if (!existingdata) {
629
+ // throw new NotFoundException(`${id} not found`, 'not found');
630
+ // }
631
+ this.logger.debug('warn2');
632
+ if (this.hooks.beforeUpdate)
633
+ await this.hooks.beforeUpdate(appuser, id, data, existingdata);
634
+
635
+ const dbsession = appuser.getDBSession();
636
+ if (dbsession && !dbsession.inTransaction()) {
637
+ dbsession.startTransaction();
638
+ }
639
+ // try {
640
+ Object.assign(data, appuser.getUpdateFilter());
641
+ // Object.assign(existingdata, data);
599
642
 
600
- const dbsession = appuser.getDBSession();
601
- if (dbsession && !dbsession.inTransaction()) {
602
- dbsession.startTransaction();
603
- }
604
- // try {
605
- Object.assign(data, appuser.getUpdateFilter());
606
- // Object.assign(existingdata, data);
643
+ delete data['_id'];
644
+ this.reCalculateValue(data);
607
645
 
608
- delete data['_id'];
609
- this.reCalculateValue(data);
646
+ // existingdata['_id']=''
647
+ await this.validateData(appuser, data, id);
610
648
 
611
- // existingdata['_id']=''
612
- await this.validateData(appuser, data, id);
649
+ const isolationFilter = { ...this.getIsolationFilter(appuser) };
650
+ this.polishIsolationFilter(isolationFilter);
651
+ isolationFilter['_id'] = id;
652
+ this.applyNestedDateTime(appuser, data, 'update');
613
653
 
614
- const isolationFilter = { ...this.getIsolationFilter(appuser) };
615
- this.polishIsolationFilter(isolationFilter);
616
- isolationFilter['_id'] = id;
617
- this.applyNestedDateTime(appuser, data, 'update');
618
-
619
654
  const result = await this.doc.findOneAndReplace(isolationFilter, data, {
620
655
  session: dbsession,
621
656
  new: true,
622
657
  });
658
+ await this.audittrail.addEvent(
659
+ appuser,
660
+ this.documentName,
661
+ id,
662
+ 'update',
663
+ data,
664
+ );
665
+
623
666
  appuser.addUpdatedRecordId(this.documentName, data._id);
624
667
  if (this.hooks.afterUpdate)
625
668
  await this.hooks.afterUpdate(appuser, id, existingdata, result);
@@ -679,7 +722,13 @@ export class SimpleAppService<T extends { _id?: string; __v?: number }> {
679
722
  session: dbsession,
680
723
  new: true,
681
724
  });
682
-
725
+ await this.audittrail.addEvent(
726
+ appuser,
727
+ this.documentName,
728
+ id,
729
+ 'patch',
730
+ data,
731
+ );
683
732
  appuser.addUpdatedRecordId(this.documentName, data._id);
684
733
 
685
734
  if (this.hooks.afterUpdate)
@@ -781,12 +830,27 @@ export class SimpleAppService<T extends { _id?: string; __v?: number }> {
781
830
  const createresult = await this.create(appuser, data);
782
831
  if (this.hooks.afterSetStatus)
783
832
  await this.hooks.afterSetStatus(appuser, docstatus, createresult);
833
+ await this.audittrail.addEvent(
834
+ appuser,
835
+ this.documentName,
836
+ id,
837
+ docstatus,
838
+ data,
839
+ );
840
+
784
841
  return createresult;
785
842
  } else {
786
843
  const updateresult = await this.findIdThenPatch(appuser, id, data);
787
844
  const finaldata = await this.findById(appuser, id);
788
845
  if (this.hooks.afterSetStatus)
789
846
  await this.hooks.afterSetStatus(appuser, docstatus, finaldata);
847
+ await this.audittrail.addEvent(
848
+ appuser,
849
+ this.documentName,
850
+ id,
851
+ docstatus,
852
+ data,
853
+ );
790
854
 
791
855
  this.callWebhook(appuser, docstatus, finaldata);
792
856
  return updateresult;
@@ -975,6 +1039,7 @@ export class SimpleAppService<T extends { _id?: string; __v?: number }> {
975
1039
  }
976
1040
 
977
1041
  searchToAggregate(
1042
+ appuser: UserContext,
978
1043
  filter: FilterQuery<T>,
979
1044
  columns: string[],
980
1045
  sort: string[][],
@@ -1002,6 +1067,7 @@ export class SimpleAppService<T extends { _id?: string; __v?: number }> {
1002
1067
  as: '_' + to,
1003
1068
  localField: lookup[tokey],
1004
1069
  foreignField: foreignField,
1070
+ pipeline: [{ $match: { tenantId: appuser.getTenantId() } }],
1005
1071
  },
1006
1072
  });
1007
1073
  pipelines.push({ $unwind: '$_' + to });
@@ -67,7 +67,6 @@ export class ProfileController {
67
67
  }
68
68
  }
69
69
 
70
-
71
70
  @Get('session')
72
71
  @Roles(Role.Everyone, Role.User)
73
72
  @ApiOperation({
@@ -80,15 +79,15 @@ export class ProfileController {
80
79
  description: 'Success',
81
80
  })
82
81
  @ApiResponse({ status: 401, type: Object, description: 'Expired' })
83
- async getSession(@AppUser() appuser: UserContext) {
84
- const result = await this.profileservice.getSession(appuser);
82
+ async getSession(@AppUser() appuser: UserContext) {
83
+ const result = await this.profileservice.getSession(appuser);
85
84
  if (result) {
86
85
  return result;
87
86
  } else {
88
87
  throw new HttpException('Forbidden', HttpStatus.FORBIDDEN);
89
88
  }
90
89
  }
91
-
90
+
92
91
  @Get('/tenants')
93
92
  @Roles(Role.Everyone, Role.User)
94
93
  @ApiOperation({
@@ -127,9 +126,16 @@ export class ProfileController {
127
126
  @AppUser() appuser: UserContext,
128
127
  @Body('tenantName') tenantName: string,
129
128
  @Body('timeZone') timeZone: string,
130
- @Body('utcOffset') utcOffset:number
129
+ @Body('utcOffset') utcOffset: number,
130
+ @Body('businessType') businessType: string,
131
131
  ) {
132
- const result = await this.profileservice.createTenant(appuser, tenantName,timeZone,utcOffset);
132
+ const result = await this.profileservice.createTenant(
133
+ appuser,
134
+ tenantName,
135
+ timeZone,
136
+ utcOffset,
137
+ businessType,
138
+ );
133
139
  if (result) {
134
140
  return result;
135
141
  } else {
@@ -170,9 +176,11 @@ export class ProfileController {
170
176
  async runTourComplete(
171
177
  @AppUser() appuser: UserContext,
172
178
  @Param('guidename') guidename: string,
173
-
174
179
  ) {
175
- const result = await this.profileservice.runTourComplete(appuser,guidename,);
180
+ const result = await this.profileservice.runTourComplete(
181
+ appuser,
182
+ guidename,
183
+ );
176
184
  if (result) {
177
185
  return result;
178
186
  } else {
@@ -92,6 +92,7 @@ export class ProfileService {
92
92
  tenantName: string,
93
93
  timeZone: string,
94
94
  utcOffset: number,
95
+ businessType: string,
95
96
  ) {
96
97
  // try{
97
98
  const timezonedata = countrytimezone.getCountriesForTimezone(timeZone)[0];
@@ -103,6 +104,12 @@ export class ProfileService {
103
104
  const tenantdata: Tenant = {
104
105
  tenantId: 1,
105
106
  tenantName: tenantName,
107
+ businessType: businessType,
108
+ clientSetting: {
109
+ auditTrail: false,
110
+ webhook: false,
111
+ support: false,
112
+ },
106
113
  active: true,
107
114
  owner: {
108
115
  _id: appuser.getId(),
@@ -8,9 +8,9 @@ import { Module } from '@nestjs/common';
8
8
  import { MongooseModule } from '@nestjs/mongoose';
9
9
  import {DocNumberFormatGenerator} from './generate/commons/docnogenerator.service'
10
10
  import { AuditTrail } from './generate/commons/audittrail.service';
11
- import { CloudapiModule } from 'src/cloudapi/cloudapi.module';
12
- import { PrintapiModule } from 'src/printapi/printapi.module';
13
- import { RunWebhookService } from 'src/simpleapp/generate/commons/runwebhook.service'
11
+ import { CloudapiModule } from '../cloudapi/cloudapi.module';
12
+ import { PrintapiModule } from '../printapi/printapi.module';
13
+ import { RunWebhookService } from '../simpleapp/generate/commons/runwebhook.service'
14
14
  import { UserResolverService } from './services/userresolver.service';
15
15
  // auto import modules
16
16
  <% for(let i=0;i<it.modules.length; i++){ %>
@@ -29,3 +29,17 @@ export type UserPermission = {
29
29
  groups: string[]
30
30
  userId : string
31
31
  }
32
+ export type OutstandingByStudent = {
33
+ _id: string;
34
+ student: ForeignKey;
35
+ level: ForeignKey;
36
+ totalAmt: number;
37
+ invoices: ForeignKey[];
38
+ };
39
+
40
+ export type TextSearchBody = {
41
+ keyword:string;
42
+ fields?:string[];
43
+ sorts?:string[][];
44
+ lookup?: Record<string,string>;
45
+ }
@@ -1,5 +1,7 @@
1
1
  <template>
2
- <NuxtLayout :name="getLayout()">
2
+ <NuxtLayout>
3
+
4
+ <!-- <NuxtLayout :name="getLayout()"> -->
3
5
  <ConfirmDialog></ConfirmDialog>
4
6
  <DynamicDialog />
5
7
  <SessionBlock/>
@@ -28,13 +30,13 @@ watch(()=>useRoute().params['xorg'],async (newval,oldvalue)=>{
28
30
  })
29
31
 
30
32
  const getLayout = ()=>{
31
- const { status } = useAuth();
33
+ // const { status } = useAuth();
32
34
 
33
- if(status.value=='unauthenticated') return 'loginlayout'
34
- else {
35
- if (isMobile()) return 'mobile'
36
- else 'default'
37
- }
35
+ // if(status.value=='unauthenticated') return 'loginlayout'
36
+ // else {
37
+ // if (isMobile()) return 'mobile'
38
+ // else 'default'
39
+ // }
38
40
  }
39
41
 
40
42
  onMounted(()=>{
@@ -1,30 +1,23 @@
1
1
  <template>
2
- <div class="inline-block border rounded-lg w-20 h-20 bg-white">
3
- <Avatar v-if="email"
4
- :image="getAvatarLink(<string>email, size)"
2
+ <div :class="`inline-block border rounded-lg w-${size} h-${size} bg-white`">
3
+ <Avatar
4
+ :image="getAvatarLink(<string>id, size*3)"
5
5
  shape="circle"
6
- size="xlarge"
7
- />
8
- <Avatar v-else-if="id"
9
- :image="getAvatarByUid(<string>id, size)"
10
- shape="circle"
11
- size="xlarge"
6
+ class="w-full h-full"
12
7
  />
8
+
9
+
13
10
  </div>
14
-
15
-
16
11
  </template>
17
12
  <script lang="ts" setup>
18
13
  /**
19
- * This file was automatically generated by simpleapp generator during initialization.
14
+ * This file was automatically generated by simpleapp generator during initialization.
20
15
  * --remove-this-line-to-prevent-override--
21
16
  * last change 2024-04-06
22
17
  * author: Ks Tan
23
18
  */
24
19
  const props = defineProps<{
25
- email?: string;
26
20
  id?: string;
27
21
  size: number;
28
22
  }>();
29
-
30
23
  </script>