@simitgroup/simpleapp-generator 2.0.0-f-alpha → 2.0.0-h-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.
package/ReleaseNote.md CHANGED
@@ -1,3 +1,9 @@
1
+ [2.0.0h-alpha]
2
+ 1. add software license config folder
3
+
4
+ [2.0.0g-alpha]
5
+ 1. fix create many no await cause transaction error
6
+
1
7
  [2.0.0f-alpha]
2
8
  1. add back document no and webhook
3
9
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simitgroup/simpleapp-generator",
3
- "version": "2.0.0f-alpha",
3
+ "version": "2.0.0h-alpha",
4
4
  "description": "frontend nuxtjs and backend nests code generator using jsonschema",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -27,7 +27,7 @@ export class SimpleAppLogService {
27
27
  as: 'user',
28
28
  localField: 'createdBy',
29
29
  foreignField: 'uid',
30
- pipeline: [{$match:{tenantId:appUser.getTenantId()}},{ $project: { fullName: 1 } }],
30
+ pipeline: [{ $match: { tenantId: appUser.getTenantId() } }, { $project: { fullName: 1 } }],
31
31
  },
32
32
  },
33
33
  { $unwind: '$user' },
@@ -35,13 +35,13 @@ export class SimpleAppLogService {
35
35
  $project: {
36
36
  _id: 1,
37
37
  fullName: '$user.fullName',
38
- eventType:1,
38
+ eventType: 1,
39
39
  createdBy: 1,
40
40
  created: 1,
41
- eventData: 1
41
+ eventData: 1,
42
42
  },
43
43
  },
44
- {$sort:{created:1}}
44
+ { $sort: { created: 1 } },
45
45
  ]);
46
46
  // find({documentName:documentName,documentId:id},null,{session:appUser.getDBSession()})
47
47
 
@@ -93,6 +93,11 @@ export class SimpleAppLogService {
93
93
  alldata.push(eventdata);
94
94
  }
95
95
  const dbsession = appUser.getDBSession();
96
- this.doc.insertMany(alldata, { session: dbsession });
96
+ try{
97
+ await this.doc.insertMany(alldata, { session: dbsession });
98
+ }catch(e){
99
+ throw e
100
+ }
101
+
97
102
  }
98
103
  }
@@ -5,7 +5,7 @@ import { PolicyService } from 'src/simple-app/.core/features/policy/policy.servi
5
5
  import { Role } from 'src/simple-app/.core/features/auth/role-guard/roles.enum';
6
6
  import { UserContext } from 'src/simple-app/.core/features/user-context/user.context';
7
7
  import { MiniApp } from '../dto';
8
- import * as plans from 'src/simple-app/features/subscription/license/plans'
8
+ import * as licenseTypes from 'src/simple-app/config/license-types';
9
9
  @Injectable()
10
10
  export class MiniAppManagerPolicyService {
11
11
  readonly _RELEASED_STATUSES = [MiniAppStatusEnum.PUBLISHED];
@@ -29,15 +29,14 @@ export class MiniAppManagerPolicyService {
29
29
  }
30
30
 
31
31
  hasRequiredPlan(appUser: UserContext, miniApp: MiniApp) {
32
- const currentPlan = appUser.tenantInfo.package;
32
+ const currentLicense = appUser.tenantInfo?.license ?? 'free';
33
33
  // const requiredPlans = miniApp.access.requiredPlans ?? [];
34
-
35
- if(plans[currentPlan]){
36
- const plansetting = plans[currentPlan]()
37
- return plansetting?.features?.advance?.features?.miniApp ?? false
38
34
 
39
- }else{
40
- return false
35
+ if (licenseTypes[currentLicense]) {
36
+ const licenseSetting = licenseTypes[currentLicense]();
37
+ return licenseSetting?.features?.advance?.features?.miniApp ?? false;
38
+ } else {
39
+ return false;
41
40
  }
42
41
  // if (_.isEmpty(requiredPlans)) return true;
43
42
 
@@ -9,7 +9,7 @@ import { MiniAppInstallationService } from 'src/simple-app/.core/resources/mini-
9
9
  import _ from 'lodash';
10
10
  import { MiniAppManagerPolicyService } from './mini-app-manager-policy.service';
11
11
  import { MiniAppError } from './mini-app-manager.error';
12
- import * as plans from 'src/simple-app/features/subscription/license/plans'
12
+
13
13
  @Injectable()
14
14
  export class MiniAppManagerService {
15
15
  constructor(
@@ -82,7 +82,7 @@ export class MiniAppManagerService {
82
82
  });
83
83
 
84
84
  const permissions = this.getMiniAppActionAccess(appUser);
85
-
85
+
86
86
  const installedMiniApps = miniAppInstallations.map((installation) => {
87
87
  const miniApp = miniApps.find((miniApp) => miniApp._id === installation.miniApp._id);
88
88
  if (!miniApp) {
@@ -175,10 +175,7 @@ export class MiniAppManagerService {
175
175
  };
176
176
  }
177
177
 
178
- private getMiniAppActionAccess(appUser: UserContext) {
179
- const currentPlan = appUser.tenantInfo.package;
180
- const planSetting = plans[currentPlan]()
181
-
178
+ private getMiniAppActionAccess(appUser: UserContext) {
182
179
  return {
183
180
  hasMiniAppFeature: this.policyService.hasFeature(appUser),
184
181
  canInstall: this.policyService.canInstall(appUser),
@@ -1,7 +1,7 @@
1
1
  import { Injectable } from '@nestjs/common';
2
2
  import { Role } from 'src/simple-app/.core/features/auth/role-guard/roles.enum';
3
3
  import { UserContext } from 'src/simple-app/.core/features/user-context/user.context';
4
- import * as plans from 'src/simple-app/features/subscription/license/plans'
4
+ import * as licenseTypes from 'src/simple-app/config/license-types';
5
5
  @Injectable()
6
6
  export class PolicyService {
7
7
  private readonly _HIGH_PRIVILEGE_ROLES = [Role.SuperAdmin, Role.SuperUser, Role.TenantOwner];
@@ -27,12 +27,12 @@ export class PolicyService {
27
27
  * - plans/pro.ts
28
28
  * - plans/enterprise.ts
29
29
  */
30
- hasFeature(appUser: UserContext, feature: keyof typeof this._FEATURES): boolean {
31
- const appPackage = appUser.tenantInfo.package;
32
- const allowedPlans = this._FEATURES[feature];
33
- const planSetting = plans[appPackage]();
34
- const allowed = planSetting.features?.advance?.features[feature] ?? false;
35
- return allowed
30
+ hasFeature(appUser: UserContext, feature: keyof typeof this._FEATURES): boolean {
31
+ const appLicense = appUser.tenantInfo?.license ?? 'free';
32
+ // const allowedPlans = this._FEATURES[feature];
33
+ const licenseSetting = licenseTypes[appLicense]();
34
+ const allowed = licenseSetting.features?.advance?.features[feature] ?? false;
35
+ return allowed;
36
36
  }
37
37
 
38
38
  can(appUser: UserContext, role: Role) {
@@ -50,11 +50,13 @@ export class ProfileService {
50
50
  this.logger.verbose(`get userprofile for ${appuser.getUid()} for tenantId ${accessTenantId}`, 'getProfile');
51
51
  const userinfo: UserContextInfo = await appuser.getUserInfo();
52
52
 
53
- if (userinfo._id == '') {
53
+ if (!userinfo._id) {
54
54
  this.logger.warn('unknown _id for ', appuser.getUid());
55
55
 
56
56
  let newprofile;
57
+
57
58
  if (accessTenantId == 0) {
59
+
58
60
  newprofile = await this.createUserProfile(appuser);
59
61
  newprofile['time'] = new Date().toISOString();
60
62
  return newprofile;
@@ -31,12 +31,11 @@ export abstract class BaseQueueConsumer extends WorkerHost {
31
31
  async startSession(appUser: UserContext) {
32
32
  const session = await this.connection.startSession();
33
33
  appUser.setDBSession(session);
34
- appUser.getDBSession().startTransaction({ readPreference: 'primary' });
35
34
  }
36
35
 
37
36
  async process(job: Job) {
38
37
  // console.log("process job", job.data)
39
- const { userContext, payload } = job.data
38
+ const { userContext, payload } = job.data;
40
39
 
41
40
  const appUser = this.createUserContext(userContext.user);
42
41
  await this.startSession(appUser);
@@ -46,13 +45,16 @@ export abstract class BaseQueueConsumer extends WorkerHost {
46
45
  // this.queueUserContext.assign(userContext);
47
46
 
48
47
  await this.dispatch(appUser, job, payload);
49
-
50
- await appUser.getDBSession().commitTransaction();
48
+ if(appUser.getDBSession().inTransaction()) {
49
+ await appUser.getDBSession().commitTransaction();
50
+ }
51
51
  return {
52
52
  success: true,
53
53
  };
54
54
  } catch (e) {
55
- await appUser.getDBSession().abortTransaction();
55
+ if(appUser.getDBSession().inTransaction()) {
56
+ await appUser.getDBSession().abortTransaction();
57
+ }
56
58
  throw e;
57
59
  } finally {
58
60
  appUser.getDBSession().endSession();
@@ -24,6 +24,7 @@ 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> {
@@ -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: SimpleAppDocumentNoFormatService,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 @@
1
+ export const license1 = {id:"app"}
@@ -13,7 +13,12 @@
13
13
  <NuxtLink :to="`/${item.xOrg}`" external>
14
14
  <div class="flex flex-row gap-2 hover:bg-primary-100">
15
15
  <div class="min-w-14 p=2">
16
- <ImageOrganization :orgRecordId="item.orgRecordId" :size="12" />
16
+ <ImageOrganization
17
+ v-if="tenant?.permissions.length > 0"
18
+ class="w-10 h-10"
19
+ :orgRecordId="tenant?.permissions[0]?.orgRecordId"
20
+ :size="PHOTOSIZE.S40"
21
+ />
17
22
  </div>
18
23
  <div class="flex flex-col w-full justify-end gap-2">
19
24
  <div class="flex flex-row gap-2">