@solidxai/core 0.1.6-beta.9 → 0.1.6

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 (115) hide show
  1. package/.claude/settings.local.json +15 -0
  2. package/dist/controllers/scheduled-job.controller.d.ts +0 -1
  3. package/dist/controllers/scheduled-job.controller.d.ts.map +1 -1
  4. package/dist/controllers/scheduled-job.controller.js +0 -12
  5. package/dist/controllers/scheduled-job.controller.js.map +1 -1
  6. package/dist/entities/chatter-message-details.entity.d.ts +0 -1
  7. package/dist/entities/chatter-message-details.entity.d.ts.map +1 -1
  8. package/dist/entities/chatter-message-details.entity.js +1 -5
  9. package/dist/entities/chatter-message-details.entity.js.map +1 -1
  10. package/dist/entities/common.entity.js +1 -1
  11. package/dist/entities/common.entity.js.map +1 -1
  12. package/dist/entities/legacy-common.entity.d.ts.map +1 -1
  13. package/dist/entities/legacy-common.entity.js +1 -1
  14. package/dist/entities/legacy-common.entity.js.map +1 -1
  15. package/dist/helpers/field-crud-managers/MediaFieldCrudManager.d.ts +1 -0
  16. package/dist/helpers/field-crud-managers/MediaFieldCrudManager.d.ts.map +1 -1
  17. package/dist/helpers/field-crud-managers/MediaFieldCrudManager.js +8 -9
  18. package/dist/helpers/field-crud-managers/MediaFieldCrudManager.js.map +1 -1
  19. package/dist/interfaces.d.ts +1 -4
  20. package/dist/interfaces.d.ts.map +1 -1
  21. package/dist/interfaces.js.map +1 -1
  22. package/dist/seeders/seed-data/solid-core-metadata.json +3 -73
  23. package/dist/services/authentication.service.d.ts.map +1 -1
  24. package/dist/services/authentication.service.js +21 -45
  25. package/dist/services/authentication.service.js.map +1 -1
  26. package/dist/services/chatter-message.service.d.ts.map +1 -1
  27. package/dist/services/chatter-message.service.js +0 -26
  28. package/dist/services/chatter-message.service.js.map +1 -1
  29. package/dist/services/dashboard-question.service.d.ts +0 -4
  30. package/dist/services/dashboard-question.service.d.ts.map +1 -1
  31. package/dist/services/dashboard-question.service.js +8 -22
  32. package/dist/services/dashboard-question.service.js.map +1 -1
  33. package/dist/services/model-metadata.service.d.ts.map +1 -1
  34. package/dist/services/model-metadata.service.js +6 -101
  35. package/dist/services/model-metadata.service.js.map +1 -1
  36. package/dist/services/question-data-providers/chartjs-sql-data-provider.service.d.ts +4 -2
  37. package/dist/services/question-data-providers/chartjs-sql-data-provider.service.d.ts.map +1 -1
  38. package/dist/services/question-data-providers/chartjs-sql-data-provider.service.js +1 -2
  39. package/dist/services/question-data-providers/chartjs-sql-data-provider.service.js.map +1 -1
  40. package/dist/services/question-data-providers/prime-react-datatable-sql-data-provider.service.d.ts +5 -2
  41. package/dist/services/question-data-providers/prime-react-datatable-sql-data-provider.service.d.ts.map +1 -1
  42. package/dist/services/question-data-providers/prime-react-datatable-sql-data-provider.service.js +1 -2
  43. package/dist/services/question-data-providers/prime-react-datatable-sql-data-provider.service.js.map +1 -1
  44. package/dist/services/question-data-providers/prime-react-meter-group-sql-data-provider.service.d.ts +5 -2
  45. package/dist/services/question-data-providers/prime-react-meter-group-sql-data-provider.service.d.ts.map +1 -1
  46. package/dist/services/question-data-providers/prime-react-meter-group-sql-data-provider.service.js +1 -2
  47. package/dist/services/question-data-providers/prime-react-meter-group-sql-data-provider.service.js.map +1 -1
  48. package/dist/services/queues/database-subscriber.service.d.ts +2 -4
  49. package/dist/services/queues/database-subscriber.service.d.ts.map +1 -1
  50. package/dist/services/queues/database-subscriber.service.js +1 -9
  51. package/dist/services/queues/database-subscriber.service.js.map +1 -1
  52. package/dist/services/queues/publisher-factory.service.d.ts.map +1 -1
  53. package/dist/services/queues/publisher-factory.service.js +6 -4
  54. package/dist/services/queues/publisher-factory.service.js.map +1 -1
  55. package/dist/services/queues/rabbitmq-subscriber.service.d.ts +2 -4
  56. package/dist/services/queues/rabbitmq-subscriber.service.d.ts.map +1 -1
  57. package/dist/services/queues/rabbitmq-subscriber.service.js +1 -9
  58. package/dist/services/queues/rabbitmq-subscriber.service.js.map +1 -1
  59. package/dist/services/scheduled-job.service.d.ts +1 -6
  60. package/dist/services/scheduled-job.service.d.ts.map +1 -1
  61. package/dist/services/scheduled-job.service.js +2 -26
  62. package/dist/services/scheduled-job.service.js.map +1 -1
  63. package/dist/services/scheduled-jobs/scheduler.interface.d.ts +0 -2
  64. package/dist/services/scheduled-jobs/scheduler.interface.d.ts.map +1 -1
  65. package/dist/services/scheduled-jobs/scheduler.interface.js.map +1 -1
  66. package/dist/services/scheduled-jobs/scheduler.service.d.ts +2 -6
  67. package/dist/services/scheduled-jobs/scheduler.service.d.ts.map +1 -1
  68. package/dist/services/scheduled-jobs/scheduler.service.js +15 -55
  69. package/dist/services/scheduled-jobs/scheduler.service.js.map +1 -1
  70. package/dist/services/selection-providers/list-of-dashboard-question-providers-selection-provider.service.d.ts.map +1 -1
  71. package/dist/services/selection-providers/list-of-dashboard-question-providers-selection-provider.service.js +1 -4
  72. package/dist/services/selection-providers/list-of-dashboard-question-providers-selection-provider.service.js.map +1 -1
  73. package/dist/transformers/typeorm/local-date-time-transformer.d.ts +4 -4
  74. package/dist/transformers/typeorm/local-date-time-transformer.d.ts.map +1 -1
  75. package/dist/transformers/typeorm/local-date-time-transformer.js +28 -25
  76. package/dist/transformers/typeorm/local-date-time-transformer.js.map +1 -1
  77. package/package.json +1 -1
  78. package/src/controllers/scheduled-job.controller.ts +0 -6
  79. package/src/entities/chatter-message-details.entity.ts +0 -3
  80. package/src/entities/common.entity.ts +2 -2
  81. package/src/entities/legacy-common.entity.ts +4 -3
  82. package/src/helpers/field-crud-managers/MediaFieldCrudManager.ts +9 -9
  83. package/src/interfaces.ts +1 -7
  84. package/src/seeders/seed-data/solid-core-metadata.json +3 -73
  85. package/src/services/1.js +6 -0
  86. package/src/services/authentication.service.ts +24 -47
  87. package/src/services/chatter-message.service.ts +0 -26
  88. package/src/services/dashboard-question.service.ts +4 -23
  89. package/src/services/model-metadata.service.ts +7 -109
  90. package/src/services/question-data-providers/chartjs-sql-data-provider.service.ts +7 -3
  91. package/src/services/question-data-providers/prime-react-datatable-sql-data-provider.service.ts +8 -4
  92. package/src/services/question-data-providers/prime-react-meter-group-sql-data-provider.service.ts +8 -4
  93. package/src/services/queues/database-subscriber.service.ts +1 -12
  94. package/src/services/queues/publisher-factory.service.ts +6 -8
  95. package/src/services/queues/rabbitmq-subscriber.service.ts +1 -12
  96. package/src/services/scheduled-job.service.ts +2 -31
  97. package/src/services/scheduled-jobs/scheduler.interface.ts +1 -4
  98. package/src/services/scheduled-jobs/scheduler.service.ts +16 -60
  99. package/src/services/selection-providers/list-of-dashboard-question-providers-selection-provider.service.ts +1 -4
  100. package/src/transformers/typeorm/local-date-time-transformer.ts +33 -41
  101. package/dist/services/question-data-providers/interfaces.d.ts +0 -1
  102. package/dist/services/question-data-providers/interfaces.d.ts.map +0 -1
  103. package/dist/services/question-data-providers/interfaces.js +0 -1
  104. package/dist/services/question-data-providers/interfaces.js.map +0 -1
  105. package/dist-tests/api/authenticate.spec.js +0 -119
  106. package/dist-tests/api/authenticate.spec.js.map +0 -1
  107. package/dist-tests/api/crud-service.findOne.cityMaster.spec.js +0 -97
  108. package/dist-tests/api/crud-service.findOne.cityMaster.spec.js.map +0 -1
  109. package/dist-tests/api/ping.spec.js +0 -21
  110. package/dist-tests/api/ping.spec.js.map +0 -1
  111. package/dist-tests/helpers/auth.js +0 -41
  112. package/dist-tests/helpers/auth.js.map +0 -1
  113. package/dist-tests/helpers/env.js +0 -11
  114. package/dist-tests/helpers/env.js.map +0 -1
  115. package/src/services/question-data-providers/interfaces.ts +0 -0
@@ -464,6 +464,10 @@ export class AuthenticationService {
464
464
 
465
465
  private async notifyUserOnOtpInitiateRegistration(user: User, registrationValidationSource: string) {
466
466
  const companyLogo = await this.getCompanyLogo();
467
+ const dummyOtp = this.getDummyOtpForUser(user);
468
+
469
+ if (dummyOtp)
470
+ return; // Do nothing if dummy otp is configured.
467
471
  if (registrationValidationSource === PasswordlessLoginValidateWhatSources.EMAIL) {
468
472
  const mailService = this.mailServiceFactory.getMailService();
469
473
  mailService.sendEmailUsingTemplate(
@@ -590,12 +594,13 @@ export class AuthenticationService {
590
594
  return true;
591
595
  }
592
596
 
593
- private async otp(): Promise<otp> {
597
+ private async otp(user?: User): Promise<otp> {
594
598
  const now = new Date();
595
599
  const otpExpiry = this.settingService.getConfigValue<SolidCoreSetting>('otpExpiry');
600
+ const dummyOtp = this.getDummyOtpForUser(user);
596
601
  now.setMinutes(now.getMinutes() + otpExpiry);
597
602
  return {
598
- token: randomInt(100000, 999999).toString(),
603
+ token: dummyOtp ? dummyOtp : randomInt(100000, 999999).toString(),
599
604
  expiresAt: now,
600
605
  };
601
606
  }
@@ -687,11 +692,8 @@ export class AuthenticationService {
687
692
 
688
693
  const type = this.resolveLoginType(signInDto);
689
694
  const user = await this.findUserForLogin(type, signInDto.identifier);
690
- const dummyOtp = this.getDummyOtpForUser(user);
691
- if (!dummyOtp) {
692
- await this.assignLoginOtp(user, type);
693
- this.notifyUserOnOtpInititateLogin(user, type);
694
- }
695
+ await this.assignLoginOtp(user, type);
696
+ this.notifyUserOnOtpInititateLogin(user, type);
695
697
  return this.buildLoginOtpResponse(user, type);
696
698
  }
697
699
 
@@ -736,22 +738,15 @@ export class AuthenticationService {
736
738
  }
737
739
 
738
740
  private async assignLoginOtp(user: User, type: PasswordlessLoginValidateWhatSources): Promise<void> {
739
- const { token, expiresAt } = await this.otp();
741
+ const { token, expiresAt } = await this.otp(user);
740
742
  if (type === PasswordlessLoginValidateWhatSources.EMAIL) {
741
743
  user.emailVerificationTokenOnLogin = token;
742
744
  user.emailVerificationTokenOnLoginExpiresAt = expiresAt;
743
- await this.userRepository.update(user.id, {
744
- emailVerificationTokenOnLogin: token,
745
- emailVerificationTokenOnLoginExpiresAt: expiresAt,
746
- });
747
745
  } else {
748
746
  user.mobileVerificationTokenOnLogin = token;
749
747
  user.mobileVerificationTokenOnLoginExpiresAt = expiresAt;
750
- await this.userRepository.update(user.id, {
751
- mobileVerificationTokenOnLogin: token,
752
- mobileVerificationTokenOnLoginExpiresAt: expiresAt,
753
- });
754
748
  }
749
+ await this.userRepository.save(user);
755
750
  }
756
751
 
757
752
  private buildLoginOtpResponse(user: User, type: PasswordlessLoginValidateWhatSources) {
@@ -820,15 +815,6 @@ export class AuthenticationService {
820
815
 
821
816
  const user = await this.findUserForLogin(type, identifier, { withRoles: true });
822
817
  this.checkAccountBlocked(user);
823
- const dummyOtp = this.getDummyOtpForUser(user);
824
-
825
- if (dummyOtp) {
826
- if (otp !== dummyOtp) {
827
- throw new UnauthorizedException(ERROR_MESSAGES.INVALID_OTP);
828
- }
829
- return this.buildLoginTokenResponse(user);
830
- }
831
-
832
818
  try {
833
819
  this.validateLoginOtp(user, otp, type);
834
820
  } catch (e) {
@@ -836,9 +822,13 @@ export class AuthenticationService {
836
822
  throw e;
837
823
  }
838
824
 
839
- await this.clearLoginOtp(user, type);
840
- await this.userActivityHistoryService.logEvent('login', user);
841
- await this.resetFailedAttempts(user);
825
+ // we do not need to clear the otp when dummy otp is configured...
826
+ const dummyOtp = this.getDummyOtpForUser(user);
827
+ if (!dummyOtp)
828
+ this.clearLoginOtp(user, type);
829
+
830
+ user.failedLoginAttempts = 0;
831
+ await this.userRepository.save(user);
842
832
  return this.buildLoginTokenResponse(user);
843
833
  }
844
834
 
@@ -855,27 +845,15 @@ export class AuthenticationService {
855
845
  }
856
846
  }
857
847
 
858
- private async clearLoginOtp(user: User, type: PasswordlessLoginValidateWhatSources): Promise<void> {
848
+ private clearLoginOtp(user: User, type: PasswordlessLoginValidateWhatSources): void {
859
849
  if (type === PasswordlessLoginValidateWhatSources.EMAIL) {
860
- const verifiedAt = new Date();
861
- user.emailVerifiedOnLoginAt = verifiedAt;
850
+ user.emailVerifiedOnLoginAt = new Date();
862
851
  user.emailVerificationTokenOnLogin = null;
863
852
  user.emailVerificationTokenOnLoginExpiresAt = null;
864
- await this.userRepository.update(user.id, {
865
- emailVerifiedOnLoginAt: verifiedAt,
866
- emailVerificationTokenOnLogin: null,
867
- emailVerificationTokenOnLoginExpiresAt: null,
868
- });
869
853
  } else {
870
- const verifiedAt = new Date();
871
- user.mobileVerifiedOnLoginAt = verifiedAt;
854
+ user.mobileVerifiedOnLoginAt = new Date();
872
855
  user.mobileVerificationTokenOnLogin = null;
873
856
  user.mobileVerificationTokenOnLoginExpiresAt = null;
874
- await this.userRepository.update(user.id, {
875
- mobileVerifiedOnLoginAt: verifiedAt,
876
- mobileVerificationTokenOnLogin: null,
877
- mobileVerificationTokenOnLoginExpiresAt: null,
878
- });
879
857
  }
880
858
  }
881
859
 
@@ -1318,15 +1296,14 @@ export class AuthenticationService {
1318
1296
  }
1319
1297
 
1320
1298
  private async incrementFailedAttempts(user: User): Promise<void> {
1321
- const nextFailedAttempts = (user.failedLoginAttempts ?? 0) + 1;
1322
- user.failedLoginAttempts = nextFailedAttempts;
1323
- await this.userRepository.update(user.id, { failedLoginAttempts: nextFailedAttempts });
1299
+ user.failedLoginAttempts += 1;
1300
+ await this.userRepository.save(user);
1324
1301
  }
1325
1302
 
1326
1303
  private async resetFailedAttempts(user: User): Promise<void> {
1327
1304
  if (user.failedLoginAttempts === 0) return;
1328
1305
  user.failedLoginAttempts = 0;
1329
- await this.userRepository.update(user.id, { failedLoginAttempts: 0 });
1306
+ await this.userRepository.save(user);
1330
1307
  }
1331
1308
 
1332
1309
  //FIXME - Pending implementation
@@ -1,4 +1,3 @@
1
- import { LocalDateTimeTransformer, serializeDate } from 'src/transformers/typeorm/local-date-time-transformer';
2
1
  import { forwardRef, Inject, Injectable } from '@nestjs/common';
3
2
  import { ModuleRef } from "@nestjs/core";
4
3
  import { InjectEntityManager } from '@nestjs/typeorm';
@@ -142,7 +141,6 @@ export class ChatterMessageService extends CRUDService<ChatterMessage> {
142
141
  messageDetail.chatterMessage = savedMessage;
143
142
  messageDetail.fieldName = field.name;
144
143
  messageDetail.fieldDisplayName = field.displayName;
145
- messageDetail.fieldType = field.type;
146
144
  messageDetail.oldValue = null;
147
145
  messageDetail.oldValueDisplay = null;
148
146
  messageDetail.newValue = this.formatFieldValue(field, fieldValue);
@@ -259,7 +257,6 @@ export class ChatterMessageService extends CRUDService<ChatterMessage> {
259
257
  messageDetail.chatterMessage = savedMessage;
260
258
  messageDetail.fieldName = field.name;
261
259
  messageDetail.fieldDisplayName = field.displayName;
262
- messageDetail.fieldType = field.type;
263
260
  messageDetail.oldValue = this.formatFieldValue(field, oldValue);
264
261
  messageDetail.newValue = this.formatFieldValue(field, newValue);
265
262
  messageDetail.oldValueDisplay = await this.formatFieldValueDisplay(field, oldValue);
@@ -323,9 +320,6 @@ export class ChatterMessageService extends CRUDService<ChatterMessage> {
323
320
  }
324
321
  }
325
322
 
326
- if (value instanceof Date) {
327
- return serializeDate(value);
328
- }
329
323
 
330
324
  return value.toString();
331
325
  }
@@ -339,10 +333,6 @@ export class ChatterMessageService extends CRUDService<ChatterMessage> {
339
333
  return `${value}`;
340
334
  }
341
335
 
342
- if (['date', 'datetime', 'time'].includes(field.type)) {
343
- return null;
344
- }
345
-
346
336
  if (field.type === 'relation') {
347
337
  if (field.relationType === "many-to-one") {
348
338
  if (value.name) {
@@ -628,22 +618,6 @@ export class ChatterMessageService extends CRUDService<ChatterMessage> {
628
618
  const [entities, count] = await qb.getManyAndCount();
629
619
  this.logHeapUsed('getChatterMessages-entitiesLoaded');
630
620
 
631
- // Convert date strings in message details to ISO format for consistent handling on the frontend
632
- const DATE_FIELD_TYPES = ['date', 'datetime', 'time'];
633
- for (const entity of entities) {
634
- for (const detail of entity.chatterMessageDetails ?? []) {
635
- if (!detail.fieldType || !DATE_FIELD_TYPES.includes(detail.fieldType)) continue;
636
- if (detail.oldValue) {
637
- const d = LocalDateTimeTransformer.from(detail.oldValue);
638
- if (d) detail.oldValue = d.toISOString();
639
- }
640
- if (detail.newValue) {
641
- const d = LocalDateTimeTransformer.from(detail.newValue);
642
- if (d) detail.newValue = d.toISOString();
643
- }
644
- }
645
- }
646
-
647
621
  if (populateMedia && populateMedia.length > 0) {
648
622
  const normalizedPopulateMedia = this.crudHelperService.normalize(populateMedia);
649
623
  this.logHeapUsed('getChatterMessages-beforePopulateMedia');
@@ -11,18 +11,15 @@ import { SolidRegistry } from 'src/helpers/solid-registry';
11
11
  import { DashboardQuestion } from '../entities/dashboard-question.entity';
12
12
  import { SqlExpression, SqlExpressionOperator } from './question-data-providers/chartjs-sql-data-provider.service';
13
13
  import { DashboardQuestionRepository } from 'src/repository/dashboard-question.repository';
14
- import { QuestionSqlDataProviderContext } from 'src';
15
14
 
16
15
  enum SOURCE_TYPE {
17
16
  SQL = 'sql',
18
17
  PROVIDER = 'provider',
19
18
  }
20
19
 
21
- export const CHARTJS_SQL_DATA_PROVIDER_NAME = 'ChartJsSqlDataProvider';
22
- export const PRIME_REACT_METER_GROUP_SQL_DATA_PROVIDER_NAME = 'PrimeReactMeterGroupSqlDataProvider';
23
- export const PRIME_REACT_DATATABLE_SQL_DATA_PROVIDER_NAME = 'PrimeReactDatatableSqlDataProvider';
24
-
25
- export const INBUILT_SQL_DATA_PROVIDERS = [CHARTJS_SQL_DATA_PROVIDER_NAME, PRIME_REACT_METER_GROUP_SQL_DATA_PROVIDER_NAME, PRIME_REACT_DATATABLE_SQL_DATA_PROVIDER_NAME];
20
+ const CHARTJS_SQL_DATA_PROVIDER_NAME = 'ChartJsSqlDataProvider';
21
+ const PRIME_REACT_METER_GROUP_SQL_DATA_PROVIDER_NAME = 'PrimeReactMeterGroupSqlDataProvider';
22
+ const PRIME_REACT_DATATABLE_SQL_DATA_PROVIDER_NAME = 'PrimeReactDatatableSqlDataProvider';
26
23
 
27
24
  @Injectable()
28
25
  export class DashboardQuestionService extends CRUDService<DashboardQuestion> {
@@ -53,38 +50,22 @@ export class DashboardQuestionService extends CRUDService<DashboardQuestion> {
53
50
 
54
51
  // Try to resolve the dataProvider based on a combination of sourceType and visualisedAs
55
52
  let dataProvider = null;
56
- let context = {};
57
53
 
58
- // Decide which data provider to use based on the question visualisation type if sourceType is SQL.
59
54
  if (question.sourceType === SOURCE_TYPE.SQL && ['bar', 'pie', 'line', 'donut'].includes(question.visualisedAs)) {
60
55
  dataProvider = this.solidRegistry.getDashboardQuestionDataProviderInstance(CHARTJS_SQL_DATA_PROVIDER_NAME);
61
- context = {
62
- expressions,
63
- } as QuestionSqlDataProviderContext;
64
56
  }
65
57
  if (question.sourceType === SOURCE_TYPE.SQL && ['prime-meter-group'].includes(question.visualisedAs)) {
66
58
  dataProvider = this.solidRegistry.getDashboardQuestionDataProviderInstance(PRIME_REACT_METER_GROUP_SQL_DATA_PROVIDER_NAME);
67
- context = {
68
- expressions,
69
- } as QuestionSqlDataProviderContext;
70
59
  }
71
60
  if (question.sourceType === SOURCE_TYPE.SQL && ['prime-datatable'].includes(question.visualisedAs)) {
72
61
  dataProvider = this.solidRegistry.getDashboardQuestionDataProviderInstance(PRIME_REACT_DATATABLE_SQL_DATA_PROVIDER_NAME);
73
- context = {
74
- expressions,
75
- } as QuestionSqlDataProviderContext;
76
- }
77
-
78
- // If a custom provider is specified, use that one instead
79
- if (question.sourceType === SOURCE_TYPE.PROVIDER) {
80
- dataProvider = this.solidRegistry.getDashboardQuestionDataProviderInstance(question.providerName);
81
62
  }
82
63
 
83
64
  if (!dataProvider) {
84
65
  throw new NotImplementedException(`Invalid data source type ${question.sourceType}`);
85
66
  }
86
67
 
87
- return await dataProvider.getData(question, context);
68
+ return await dataProvider.getData(question, expressions);
88
69
 
89
70
  }
90
71
 
@@ -225,7 +225,6 @@ export class ModelMetadataService {
225
225
  let userKeyField = null;
226
226
  const listViewLayout = [];
227
227
  const formViewLayout = [];
228
- const treeViewLayout = [];
229
228
 
230
229
  for (let k = 0; k < fieldsMetadata.length; k++) {
231
230
  const fieldMetadata = fieldsMetadata[k];
@@ -246,7 +245,6 @@ export class ModelMetadataService {
246
245
  }
247
246
  listViewLayout.push({ type: "field", attrs: { name: `${affectedField.name}` } })
248
247
  formViewLayout.push({ type: "field", attrs: { name: `${affectedField.name}` } })
249
- treeViewLayout.push({ type: "field", attrs: { name: `${affectedField.name}` } })
250
248
 
251
249
  }
252
250
 
@@ -820,7 +818,6 @@ export class ModelMetadataService {
820
818
  const metaData = await this.moduleMetadataHelperService.getModuleMetadataConfiguration(filePath);
821
819
 
822
820
  const listViewLayoutFields = [{ type: "field", attrs: { name: `id` } }];
823
- const treeViewLayoutFields = [{ type: "field", attrs: { name: `id` } }];
824
821
  const formViewLayoutFields = [];
825
822
 
826
823
  for (let i = 0; i < model.fields.length; i++) {
@@ -828,9 +825,8 @@ export class ModelMetadataService {
828
825
  if (field.isSystem) continue;
829
826
  listViewLayoutFields.push({ type: "field", attrs: { name: `${field.name}` } })
830
827
  formViewLayoutFields.push({ type: "field", attrs: { name: `${field.name}` } })
831
- treeViewLayoutFields.push({ type: "field", attrs: { name: `${field.name}` } })
832
828
  }
833
- this.populateVAMConfigInFileInternal(formViewLayoutFields, model, listViewLayoutFields, treeViewLayoutFields, metaData);
829
+ this.populateVAMConfigInFileInternal(formViewLayoutFields, model, listViewLayoutFields, metaData);
834
830
  // Write the updated object back to the file
835
831
  const updatedContent = JSON.stringify(metaData, null, 2);
836
832
  await fs.writeFile(filePath, updatedContent);
@@ -843,7 +839,7 @@ export class ModelMetadataService {
843
839
  }
844
840
 
845
841
  // Populate the View, Actions and Menus in the config file
846
- private populateVAMConfigInFileInternal(formViewLayoutFields: any[], model: ModelMetadata, listViewLayoutFields: { type: string; attrs: { name: string; }; }[], treeViewLayoutFields: { type: string; attrs: { name: string; }; }[], metaData: any) {
842
+ private populateVAMConfigInFileInternal(formViewLayoutFields: any[], model: ModelMetadata, listViewLayoutFields: { type: string; attrs: { name: string; }; }[], metaData: any) {
847
843
  const column1Fields = [];
848
844
  const column2Fields = [];
849
845
 
@@ -856,9 +852,7 @@ export class ModelMetadataService {
856
852
  }
857
853
  }
858
854
  const actionName = `${model.singularName}-list-action`;
859
- const treeViewActionName = `${model.singularName}-tree-view-action`;
860
- const listViewName = `${model.singularName}-list-view`;
861
- const treeViewName = `${model.singularName}-tree-view`;
855
+ const viewName = `${model.singularName}-list-view`;
862
856
  const formViewName = `${model.singularName}-form-view`;
863
857
  const menuName = `${model.singularName}-menu-item`;
864
858
 
@@ -871,21 +865,7 @@ export class ModelMetadataService {
871
865
  customComponent: ``,
872
866
  customIsModal: true,
873
867
  serverEndpoint: "",
874
- viewUserKey: listViewName,
875
- moduleUserKey: `${model.module.name}`,
876
- modelUserKey: `${model.singularName}`
877
- };
878
-
879
- const treeViewAction = {
880
- displayName: `${model.displayName} Tree View Action`,
881
- name: treeViewActionName,
882
- type: "solid",
883
- domain: "",
884
- context: "",
885
- customComponent: ``,
886
- customIsModal: true,
887
- serverEndpoint: "",
888
- viewUserKey: treeViewName,
868
+ viewUserKey: viewName,
889
869
  moduleUserKey: `${model.module.name}`,
890
870
  modelUserKey: `${model.singularName}`
891
871
  };
@@ -897,11 +877,11 @@ export class ModelMetadataService {
897
877
  actionUserKey: actionName,
898
878
  moduleUserKey: `${model.module.name}`,
899
879
  parentMenuItemUserKey: "",
900
- iconName: ""
880
+ iconName : ""
901
881
  };
902
882
 
903
883
  const modelListview = {
904
- name: listViewName,
884
+ name: viewName,
905
885
  displayName: `${model.displayName}`,
906
886
  type: "list",
907
887
  context: "{}",
@@ -925,31 +905,6 @@ export class ModelMetadataService {
925
905
  }
926
906
  };
927
907
 
928
- const modelTreeview = {
929
- name: treeViewName,
930
- displayName: `${model.displayName}`,
931
- type: "tree",
932
- context: "{}",
933
- moduleUserKey: `${model.module.name}`,
934
- modelUserKey: `${model.singularName}`,
935
- layout: {
936
- type: "tree",
937
- attrs: {
938
- pagination: true,
939
- pageSizeOptions: [
940
- 10,
941
- 25,
942
- 50
943
- ],
944
- enableGlobalSearch: true,
945
- create: true,
946
- edit: true,
947
- delete: true
948
- },
949
- children: treeViewLayoutFields
950
- }
951
- };
952
-
953
908
 
954
909
  const modelFormView = {
955
910
  name: formViewName,
@@ -999,18 +954,10 @@ export class ModelMetadataService {
999
954
  metaData.actions.push(action);
1000
955
  }
1001
956
 
1002
- if (notExists(metaData.actions, treeViewActionName)) {
1003
- metaData.actions.push(treeViewAction);
1004
- }
1005
-
1006
- if (notExists(metaData.views, listViewName)) {
957
+ if (notExists(metaData.views, viewName)) {
1007
958
  metaData.views.push(modelListview);
1008
959
  }
1009
960
 
1010
- if (notExists(metaData.views, treeViewName)) {
1011
- metaData.views.push(modelTreeview);
1012
- }
1013
-
1014
961
  if (notExists(metaData.views, formViewName)) {
1015
962
  metaData.views.push(modelFormView);
1016
963
  }
@@ -1032,14 +979,6 @@ export class ModelMetadataService {
1032
979
  }
1033
980
  }));
1034
981
 
1035
- const treeViewLayout = jsonFieldsList.map(field => ({
1036
- type: "field",
1037
- attrs: {
1038
- name: `${field.name}`,
1039
- isSearchable: true,
1040
- }
1041
- }));
1042
-
1043
982
  const formViewLayout = jsonFieldsList.map(field => ({
1044
983
  type: "field",
1045
984
  attrs: {
@@ -1080,26 +1019,6 @@ export class ModelMetadataService {
1080
1019
  children: listViewLayout
1081
1020
  }, null, 3)
1082
1021
  },
1083
- {
1084
- name: `${model.singularName}-tree-view`,
1085
- displayName: `${model.displayName}`,
1086
- type: 'tree',
1087
- context: "{}",
1088
- module: resolvedModule,
1089
- model: model,
1090
- layout: JSON.stringify({
1091
- type: "tree",
1092
- attrs: {
1093
- pagination: true,
1094
- pageSizeOptions: [10, 25, 50],
1095
- enableGlobalSearch: true,
1096
- create: true,
1097
- edit: true,
1098
- delete: true
1099
- },
1100
- children: treeViewLayout
1101
- }, null, 3)
1102
- },
1103
1022
  {
1104
1023
  name: `${model.singularName}-form-view`,
1105
1024
  displayName: `${model.displayName}`,
@@ -1148,7 +1067,6 @@ export class ModelMetadataService {
1148
1067
  }
1149
1068
 
1150
1069
  let view = await viewRepo.findOne({ where: { name: `${model.singularName}-list-view` } });
1151
- let treeView = await viewRepo.findOne({ where: { name: `${model.singularName}-tree-view` } });
1152
1070
 
1153
1071
  const actionData = {
1154
1072
  displayName: `${model.displayName} List Action`,
@@ -1164,33 +1082,13 @@ export class ModelMetadataService {
1164
1082
  model: model
1165
1083
  };
1166
1084
 
1167
- const treeViewActionData = {
1168
- displayName: `${model.displayName} Tree View Action`,
1169
- name: `${model.singularName}-tree-view-action`,
1170
- type: "solid",
1171
- domain: "",
1172
- context: "",
1173
- customComponent: ``,
1174
- customIsModal: true,
1175
- serverEndpoint: "",
1176
- view: treeView,
1177
- module: resolvedModule,
1178
- model: model
1179
- };
1180
-
1181
1085
  let existingAction = await actionRepo.findOne({ where: { name: actionData.name } });
1182
- let existingTreeViewAction = await actionRepo.findOne({ where: { name: treeViewActionData.name } });
1183
1086
 
1184
1087
  if (!existingAction) {
1185
1088
  const createdAction = actionRepo.create(actionData);
1186
1089
  existingAction = await actionRepo.save(createdAction);
1187
1090
  }
1188
1091
 
1189
- if (!existingTreeViewAction) {
1190
- const createdTreeViewAction = actionRepo.create(treeViewActionData);
1191
- existingTreeViewAction = await actionRepo.save(createdTreeViewAction);
1192
- }
1193
-
1194
1092
  const adminRole = await this.roleService.findRoleByName('Admin');
1195
1093
 
1196
1094
  const menuData = {
@@ -1,11 +1,16 @@
1
1
  import { Injectable, Logger } from "@nestjs/common";
2
2
  import { DashboardQuestionDataProvider } from "src/decorators/dashboard-question-data-provider.decorator";
3
3
  import { DashboardQuestion } from "src/entities/dashboard-question.entity";
4
- import { IDashboardQuestionDataProvider, QuestionSqlDataProviderContext } from "src/interfaces";
4
+ import { IDashboardQuestionDataProvider } from "src/interfaces";
5
5
  import { EntityManager } from "typeorm";
6
6
  import { SqlExpressionResolverService } from "../sql-expression-resolver.service";
7
7
  import { getKpi, getLabels } from "./helpers";
8
8
 
9
+ export interface QuestionSqlDataProviderContext {
10
+ // questionSqlDatasetConfig: QuestionSqlDatasetConfig;
11
+ // questionId: number;
12
+ // question: Question;
13
+ }
9
14
 
10
15
  export enum SqlExpressionOperator {
11
16
  EQUALS = '$equals',
@@ -44,8 +49,7 @@ export class ChartJsSqlDataProvider implements IDashboardQuestionDataProvider<Qu
44
49
  return "ChartJsSqlDataProvider";
45
50
  }
46
51
 
47
- async getData(question: DashboardQuestion, context?: QuestionSqlDataProviderContext): Promise<any> {
48
- const expressions: SqlExpression[] = context?.expressions || [];
52
+ async getData(question: DashboardQuestion, expressions?: SqlExpression[], context?: QuestionSqlDataProviderContext): Promise<any> {
49
53
  // TODO: put some validation to check if the results of each SQL in each dataset returns the same number of rows
50
54
 
51
55
  // This is what we have to return.
@@ -1,13 +1,19 @@
1
1
  import { Injectable } from "@nestjs/common";
2
2
  import { DashboardQuestionDataProvider } from "src/decorators/dashboard-question-data-provider.decorator";
3
3
  import { DashboardQuestion } from "src/entities/dashboard-question.entity";
4
- import { IDashboardQuestionDataProvider, QuestionSqlDataProviderContext } from "src/interfaces";
4
+ import { IDashboardQuestionDataProvider } from "src/interfaces";
5
5
  import { EntityManager } from "typeorm";
6
6
  import { SqlExpressionResolverService } from "../sql-expression-resolver.service";
7
7
  import { Logger } from '@nestjs/common';
8
8
  import { SqlExpression } from "./chartjs-sql-data-provider.service";
9
9
  import { getKpi } from "./helpers";
10
10
 
11
+ export interface QuestionSqlDataProviderContext {
12
+ // questionSqlDatasetConfig: QuestionSqlDatasetConfig;
13
+ // questionId: number;
14
+ // question: Question;
15
+ }
16
+
11
17
  @DashboardQuestionDataProvider()
12
18
  @Injectable()
13
19
  export class PrimeReactDatatableSqlDataProvider implements IDashboardQuestionDataProvider<QuestionSqlDataProviderContext, any> {
@@ -23,9 +29,7 @@ export class PrimeReactDatatableSqlDataProvider implements IDashboardQuestionDat
23
29
  return "PrimeReactDatatableSqlDataProvider";
24
30
  }
25
31
 
26
- async getData(question: DashboardQuestion, context?: QuestionSqlDataProviderContext): Promise<any> {
27
- const expressions: SqlExpression[] = context?.expressions || [];
28
-
32
+ async getData(question: DashboardQuestion, expressions?: SqlExpression[], context?: QuestionSqlDataProviderContext): Promise<any> {
29
33
  // TODO: put some validation to check if the results of each SQL in each dataset returns the same number of rows
30
34
 
31
35
  // Check the expected response for prime react data tables to understand what is going on here...
@@ -1,13 +1,19 @@
1
1
  import { Injectable } from "@nestjs/common";
2
2
  import { DashboardQuestionDataProvider } from "src/decorators/dashboard-question-data-provider.decorator";
3
3
  import { DashboardQuestion } from "src/entities/dashboard-question.entity";
4
- import { IDashboardQuestionDataProvider, QuestionSqlDataProviderContext } from "src/interfaces";
4
+ import { IDashboardQuestionDataProvider } from "src/interfaces";
5
5
  import { EntityManager } from "typeorm";
6
6
  import { SqlExpressionResolverService } from "../sql-expression-resolver.service";
7
7
  import { Logger } from '@nestjs/common';
8
8
  import { SqlExpression } from "./chartjs-sql-data-provider.service";
9
9
  import { getKpi } from "./helpers";
10
10
 
11
+ export interface QuestionSqlDataProviderContext {
12
+ // questionSqlDatasetConfig: QuestionSqlDatasetConfig;
13
+ // questionId: number;
14
+ // question: Question;
15
+ }
16
+
11
17
  @DashboardQuestionDataProvider()
12
18
  @Injectable()
13
19
  export class PrimeReactMeterGroupSqlDataProvider implements IDashboardQuestionDataProvider<QuestionSqlDataProviderContext, any> {
@@ -52,9 +58,7 @@ export class PrimeReactMeterGroupSqlDataProvider implements IDashboardQuestionDa
52
58
  return colors;
53
59
  }
54
60
 
55
- async getData(question: DashboardQuestion, context?: QuestionSqlDataProviderContext): Promise<any> {
56
- const expressions: SqlExpression[] = context?.expressions || [];
57
-
61
+ async getData(question: DashboardQuestion, expressions?: SqlExpression[], context?: QuestionSqlDataProviderContext): Promise<any> {
58
62
  // TODO: put some validation to check if the results of each SQL in each dataset returns the same number of rows
59
63
 
60
64
  // This is what we have to return.
@@ -7,7 +7,7 @@ import { PollerService } from '../poller.service';
7
7
  import { buildNamespacedQueueName } from './common';
8
8
 
9
9
  export abstract class DatabaseSubscriber<T> implements OnModuleInit, QueueSubscriber<T> {
10
- private _loggerInstance?: Logger;
10
+ private readonly logger = new Logger(DatabaseSubscriber.name);
11
11
  private readonly url: string;
12
12
  private readonly serviceRole: string;
13
13
 
@@ -23,17 +23,6 @@ export abstract class DatabaseSubscriber<T> implements OnModuleInit, QueueSubscr
23
23
  // this.logger.debug(`DatabaseSubscriber instance created with options: ${JSON.stringify(this.options())}`);
24
24
  }
25
25
 
26
- protected get loggerContext(): string {
27
- return this.constructor.name;
28
- }
29
-
30
- protected get logger(): Logger {
31
- if (!this._loggerInstance) {
32
- this._loggerInstance = new Logger(this.loggerContext);
33
- }
34
- return this._loggerInstance;
35
- }
36
-
37
26
  abstract subscribe(message: QueueMessage<T>);
38
27
 
39
28
  abstract options(): QueuesModuleOptions;
@@ -23,16 +23,14 @@ export class PublisherFactory<T> {
23
23
  // Register all ISolidDatabaseModules implementations
24
24
  let actualPublisherToUse = this.solidIntrospectionService.getProvider(resolvedPublisherName);
25
25
  if (!actualPublisherToUse) {
26
- // Relaxed extra check in place to make sure we do not have to refactor old publishers or publishers named without the ____RabbitMq or ____Database convention
27
- actualPublisherToUse = this.solidIntrospectionService.getProvider(publisherName);
28
26
 
29
27
  // Extra check in place to make sure we do not have to refactor old publishers which have been created earlier.
30
- // if (defaultBrokerToUse === 'rabbitmq') {
31
- // actualPublisherToUse = this.solidIntrospectionService.getProvider(publisherName);
32
- // }
33
- }
34
- if (!actualPublisherToUse) {
35
- throw new Error(`Unable to locate publisher with name ${resolvedPublisherName}`);
28
+ if (defaultBrokerToUse === 'rabbitmq') {
29
+ actualPublisherToUse = this.solidIntrospectionService.getProvider(publisherName);
30
+ if (!actualPublisherToUse) {
31
+ throw new Error(`Unable to locate publisher with name ${resolvedPublisherName}`);
32
+ }
33
+ }
36
34
  }
37
35
 
38
36
  // type safe
@@ -8,7 +8,7 @@ import { buildNamespacedQueueName } from './common';
8
8
 
9
9
 
10
10
  export abstract class RabbitMqSubscriber<T> implements OnModuleInit, QueueSubscriber<T> { // TODO This can be made a generic type for better type visibility
11
- private _loggerInstance?: Logger;
11
+ private readonly logger = new Logger(RabbitMqSubscriber.name);
12
12
  private readonly url: string;
13
13
  private readonly serviceRole: string;
14
14
  private connection: amqp.Connection | null = null;
@@ -30,17 +30,6 @@ export abstract class RabbitMqSubscriber<T> implements OnModuleInit, QueueSubscr
30
30
  // this.logger.debug(`RabbitMqSubscriber instance created with options: ${JSON.stringify(this.options())} and url: ${this.url}`);
31
31
  }
32
32
 
33
- protected get loggerContext(): string {
34
- return this.constructor.name;
35
- }
36
-
37
- protected get logger(): Logger {
38
- if (!this._loggerInstance) {
39
- this._loggerInstance = new Logger(this.loggerContext);
40
- }
41
- return this._loggerInstance;
42
- }
43
-
44
33
  abstract subscribe(message: QueueMessage<T>);
45
34
 
46
35
  abstract options(): QueuesModuleOptions;