@solidxai/core 0.1.6-beta.2 → 0.1.6-beta.21
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/dist/controllers/dashboard-layout.controller.d.ts +47 -0
- package/dist/controllers/dashboard-layout.controller.d.ts.map +1 -0
- package/dist/controllers/dashboard-layout.controller.js +204 -0
- package/dist/controllers/dashboard-layout.controller.js.map +1 -0
- package/dist/controllers/scheduled-job.controller.d.ts +1 -0
- package/dist/controllers/scheduled-job.controller.d.ts.map +1 -1
- package/dist/controllers/scheduled-job.controller.js +12 -0
- package/dist/controllers/scheduled-job.controller.js.map +1 -1
- package/dist/dtos/create-dashboard-layout.dto.d.ts +8 -0
- package/dist/dtos/create-dashboard-layout.dto.d.ts.map +1 -0
- package/dist/dtos/create-dashboard-layout.dto.js +53 -0
- package/dist/dtos/create-dashboard-layout.dto.js.map +1 -0
- package/dist/dtos/create-dashboard-variable.dto.d.ts +1 -0
- package/dist/dtos/create-dashboard-variable.dto.d.ts.map +1 -1
- package/dist/dtos/create-dashboard-variable.dto.js +7 -1
- package/dist/dtos/create-dashboard-variable.dto.js.map +1 -1
- package/dist/dtos/update-dashboard-layout.dto.d.ts +8 -0
- package/dist/dtos/update-dashboard-layout.dto.d.ts.map +1 -0
- package/dist/dtos/update-dashboard-layout.dto.js +53 -0
- package/dist/dtos/update-dashboard-layout.dto.js.map +1 -0
- package/dist/dtos/update-dashboard-variable.dto.d.ts +1 -0
- package/dist/dtos/update-dashboard-variable.dto.d.ts.map +1 -1
- package/dist/dtos/update-dashboard-variable.dto.js +7 -1
- package/dist/dtos/update-dashboard-variable.dto.js.map +1 -1
- package/dist/entities/action-metadata.entity.d.ts.map +1 -1
- package/dist/entities/action-metadata.entity.js.map +1 -1
- package/dist/entities/ai-interaction.entity.d.ts.map +1 -1
- package/dist/entities/ai-interaction.entity.js +5 -4
- package/dist/entities/ai-interaction.entity.js.map +1 -1
- package/dist/entities/chatter-message-details.entity.d.ts +1 -0
- package/dist/entities/chatter-message-details.entity.d.ts.map +1 -1
- package/dist/entities/chatter-message-details.entity.js +9 -4
- package/dist/entities/chatter-message-details.entity.js.map +1 -1
- package/dist/entities/chatter-message.entity.d.ts.map +1 -1
- package/dist/entities/chatter-message.entity.js +4 -3
- package/dist/entities/chatter-message.entity.js.map +1 -1
- package/dist/entities/common.entity.js +1 -1
- package/dist/entities/common.entity.js.map +1 -1
- package/dist/entities/dashboard-layout.entity.d.ts +9 -0
- package/dist/entities/dashboard-layout.entity.d.ts.map +1 -0
- package/dist/entities/dashboard-layout.entity.js +41 -0
- package/dist/entities/dashboard-layout.entity.js.map +1 -0
- package/dist/entities/dashboard-question-sql-dataset-config.entity.d.ts.map +1 -1
- package/dist/entities/dashboard-question-sql-dataset-config.entity.js +5 -4
- package/dist/entities/dashboard-question-sql-dataset-config.entity.js.map +1 -1
- package/dist/entities/dashboard-question.entity.d.ts.map +1 -1
- package/dist/entities/dashboard-question.entity.js +5 -4
- package/dist/entities/dashboard-question.entity.js.map +1 -1
- package/dist/entities/dashboard-variable.entity.d.ts +1 -0
- package/dist/entities/dashboard-variable.entity.d.ts.map +1 -1
- package/dist/entities/dashboard-variable.entity.js +10 -4
- package/dist/entities/dashboard-variable.entity.js.map +1 -1
- package/dist/entities/dashboard.entity.d.ts +2 -0
- package/dist/entities/dashboard.entity.d.ts.map +1 -1
- package/dist/entities/dashboard.entity.js +9 -3
- package/dist/entities/dashboard.entity.js.map +1 -1
- package/dist/entities/email-attachment.entity.d.ts.map +1 -1
- package/dist/entities/email-attachment.entity.js +2 -1
- package/dist/entities/email-attachment.entity.js.map +1 -1
- package/dist/entities/email-template.entity.js +1 -1
- package/dist/entities/email-template.entity.js.map +1 -1
- package/dist/entities/export-transaction.entity.d.ts.map +1 -1
- package/dist/entities/export-transaction.entity.js +2 -1
- package/dist/entities/export-transaction.entity.js.map +1 -1
- package/dist/entities/field-metadata.entity.js +2 -2
- package/dist/entities/field-metadata.entity.js.map +1 -1
- package/dist/entities/import-transaction-error-log.entity.d.ts.map +1 -1
- package/dist/entities/import-transaction-error-log.entity.js +3 -2
- package/dist/entities/import-transaction-error-log.entity.js.map +1 -1
- package/dist/entities/import-transaction.entity.d.ts.map +1 -1
- package/dist/entities/import-transaction.entity.js +2 -1
- package/dist/entities/import-transaction.entity.js.map +1 -1
- package/dist/entities/legacy-common.entity.d.ts.map +1 -1
- package/dist/entities/legacy-common.entity.js +1 -1
- package/dist/entities/legacy-common.entity.js.map +1 -1
- package/dist/entities/mq-message.entity.d.ts.map +1 -1
- package/dist/entities/mq-message.entity.js +5 -3
- package/dist/entities/mq-message.entity.js.map +1 -1
- package/dist/entities/saved-filters.entity.d.ts.map +1 -1
- package/dist/entities/saved-filters.entity.js +3 -2
- package/dist/entities/saved-filters.entity.js.map +1 -1
- package/dist/entities/security-rule.entity.d.ts.map +1 -1
- package/dist/entities/security-rule.entity.js +2 -1
- package/dist/entities/security-rule.entity.js.map +1 -1
- package/dist/entities/sms-template.entity.js +1 -1
- package/dist/entities/sms-template.entity.js.map +1 -1
- package/dist/entities/user-view-metadata.entity.d.ts.map +1 -1
- package/dist/entities/user-view-metadata.entity.js +2 -1
- package/dist/entities/user-view-metadata.entity.js.map +1 -1
- package/dist/entities/user.entity.d.ts.map +1 -1
- package/dist/entities/user.entity.js +2 -0
- package/dist/entities/user.entity.js.map +1 -1
- package/dist/entities/view-metadata.entity.d.ts.map +1 -1
- package/dist/entities/view-metadata.entity.js.map +1 -1
- package/dist/helpers/bootstrap.helper.d.ts +14 -0
- package/dist/helpers/bootstrap.helper.d.ts.map +1 -0
- package/dist/helpers/bootstrap.helper.js +132 -0
- package/dist/helpers/bootstrap.helper.js.map +1 -0
- package/dist/helpers/cache.helper.d.ts +2 -0
- package/dist/helpers/cache.helper.d.ts.map +1 -0
- package/dist/helpers/cache.helper.js +8 -0
- package/dist/helpers/cache.helper.js.map +1 -0
- package/dist/helpers/field-crud-managers/MediaFieldCrudManager.d.ts +1 -0
- package/dist/helpers/field-crud-managers/MediaFieldCrudManager.d.ts.map +1 -1
- package/dist/helpers/field-crud-managers/MediaFieldCrudManager.js +8 -9
- package/dist/helpers/field-crud-managers/MediaFieldCrudManager.js.map +1 -1
- package/dist/helpers/field-crud-managers/SelectionDynamicFieldCrudManager.d.ts +2 -2
- package/dist/helpers/field-crud-managers/SelectionDynamicFieldCrudManager.d.ts.map +1 -1
- package/dist/helpers/field-crud-managers/SelectionDynamicFieldCrudManager.js +8 -5
- package/dist/helpers/field-crud-managers/SelectionDynamicFieldCrudManager.js.map +1 -1
- package/dist/helpers/solid-registry.d.ts.map +1 -1
- package/dist/helpers/solid-registry.js.map +1 -1
- package/dist/helpers/typeorm-db-helper.d.ts.map +1 -1
- package/dist/helpers/typeorm-db-helper.js +21 -0
- package/dist/helpers/typeorm-db-helper.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/interfaces.d.ts +5 -1
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/interfaces.js.map +1 -1
- package/dist/jobs/computed-field-evaluation-queue-options.d.ts +1 -0
- package/dist/jobs/computed-field-evaluation-queue-options.d.ts.map +1 -1
- package/dist/jobs/computed-field-evaluation-queue-options.js +1 -0
- package/dist/jobs/computed-field-evaluation-queue-options.js.map +1 -1
- package/dist/repository/dashboard-layout.repository.d.ts +12 -0
- package/dist/repository/dashboard-layout.repository.d.ts.map +1 -0
- package/dist/repository/dashboard-layout.repository.js +34 -0
- package/dist/repository/dashboard-layout.repository.js.map +1 -0
- package/dist/seeders/module-metadata-seeder.service.js +4 -4
- package/dist/seeders/module-metadata-seeder.service.js.map +1 -1
- package/dist/seeders/seed-data/solid-core-metadata.json +445 -35
- package/dist/services/authentication.service.d.ts.map +1 -1
- package/dist/services/authentication.service.js +44 -21
- package/dist/services/authentication.service.js.map +1 -1
- package/dist/services/chatter-message.service.d.ts +0 -1
- package/dist/services/chatter-message.service.d.ts.map +1 -1
- package/dist/services/chatter-message.service.js +22 -19
- package/dist/services/chatter-message.service.js.map +1 -1
- package/dist/services/computed-fields/entity/sequence-num-computed-field-provider.d.ts +7 -3
- package/dist/services/computed-fields/entity/sequence-num-computed-field-provider.d.ts.map +1 -1
- package/dist/services/computed-fields/entity/sequence-num-computed-field-provider.js +61 -22
- package/dist/services/computed-fields/entity/sequence-num-computed-field-provider.js.map +1 -1
- package/dist/services/crud.service.js +1 -1
- package/dist/services/crud.service.js.map +1 -1
- package/dist/services/dashboard-layout.service.d.ts +20 -0
- package/dist/services/dashboard-layout.service.d.ts.map +1 -0
- package/dist/services/dashboard-layout.service.js +120 -0
- package/dist/services/dashboard-layout.service.js.map +1 -0
- package/dist/services/dashboard-question.service.d.ts +4 -0
- package/dist/services/dashboard-question.service.d.ts.map +1 -1
- package/dist/services/dashboard-question.service.js +22 -8
- package/dist/services/dashboard-question.service.js.map +1 -1
- package/dist/services/dashboard.service.d.ts +2 -0
- package/dist/services/dashboard.service.d.ts.map +1 -1
- package/dist/services/dashboard.service.js +4 -0
- package/dist/services/dashboard.service.js.map +1 -1
- package/dist/services/model-metadata.service.d.ts +6 -1
- package/dist/services/model-metadata.service.d.ts.map +1 -1
- package/dist/services/model-metadata.service.js +151 -8
- package/dist/services/model-metadata.service.js.map +1 -1
- package/dist/services/permission-metadata.service.d.ts +5 -1
- package/dist/services/permission-metadata.service.d.ts.map +1 -1
- package/dist/services/permission-metadata.service.js +66 -20
- package/dist/services/permission-metadata.service.js.map +1 -1
- package/dist/services/question-data-providers/chartjs-sql-data-provider.service.d.ts +2 -4
- package/dist/services/question-data-providers/chartjs-sql-data-provider.service.d.ts.map +1 -1
- package/dist/services/question-data-providers/chartjs-sql-data-provider.service.js +2 -1
- package/dist/services/question-data-providers/chartjs-sql-data-provider.service.js.map +1 -1
- package/dist/services/question-data-providers/interfaces.d.ts +1 -0
- package/dist/services/question-data-providers/interfaces.d.ts.map +1 -0
- package/dist/services/question-data-providers/interfaces.js +1 -0
- package/dist/services/question-data-providers/interfaces.js.map +1 -0
- package/dist/services/question-data-providers/prime-react-datatable-sql-data-provider.service.d.ts +2 -5
- package/dist/services/question-data-providers/prime-react-datatable-sql-data-provider.service.d.ts.map +1 -1
- package/dist/services/question-data-providers/prime-react-datatable-sql-data-provider.service.js +2 -1
- package/dist/services/question-data-providers/prime-react-datatable-sql-data-provider.service.js.map +1 -1
- package/dist/services/question-data-providers/prime-react-meter-group-sql-data-provider.service.d.ts +2 -5
- package/dist/services/question-data-providers/prime-react-meter-group-sql-data-provider.service.d.ts.map +1 -1
- package/dist/services/question-data-providers/prime-react-meter-group-sql-data-provider.service.js +2 -1
- package/dist/services/question-data-providers/prime-react-meter-group-sql-data-provider.service.js.map +1 -1
- package/dist/services/queues/database-subscriber.service.d.ts +4 -2
- package/dist/services/queues/database-subscriber.service.d.ts.map +1 -1
- package/dist/services/queues/database-subscriber.service.js +15 -2
- package/dist/services/queues/database-subscriber.service.js.map +1 -1
- package/dist/services/queues/publisher-factory.service.d.ts.map +1 -1
- package/dist/services/queues/publisher-factory.service.js +4 -6
- package/dist/services/queues/publisher-factory.service.js.map +1 -1
- package/dist/services/queues/rabbitmq-subscriber.service.d.ts +8 -3
- package/dist/services/queues/rabbitmq-subscriber.service.d.ts.map +1 -1
- package/dist/services/queues/rabbitmq-subscriber.service.js +78 -6
- package/dist/services/queues/rabbitmq-subscriber.service.js.map +1 -1
- package/dist/services/scheduled-job.service.d.ts +6 -1
- package/dist/services/scheduled-job.service.d.ts.map +1 -1
- package/dist/services/scheduled-job.service.js +26 -2
- package/dist/services/scheduled-job.service.js.map +1 -1
- package/dist/services/scheduled-jobs/scheduler.interface.d.ts +2 -0
- package/dist/services/scheduled-jobs/scheduler.interface.d.ts.map +1 -1
- package/dist/services/scheduled-jobs/scheduler.interface.js.map +1 -1
- package/dist/services/scheduled-jobs/scheduler.service.d.ts +6 -2
- package/dist/services/scheduled-jobs/scheduler.service.d.ts.map +1 -1
- package/dist/services/scheduled-jobs/scheduler.service.js +75 -17
- package/dist/services/scheduled-jobs/scheduler.service.js.map +1 -1
- package/dist/services/selection-providers/list-of-dashboard-question-providers-selection-provider.service.d.ts.map +1 -1
- package/dist/services/selection-providers/list-of-dashboard-question-providers-selection-provider.service.js +4 -1
- package/dist/services/selection-providers/list-of-dashboard-question-providers-selection-provider.service.js.map +1 -1
- package/dist/services/solid-ts-morph.service.d.ts +9 -0
- package/dist/services/solid-ts-morph.service.d.ts.map +1 -1
- package/dist/services/solid-ts-morph.service.js +76 -0
- package/dist/services/solid-ts-morph.service.js.map +1 -1
- package/dist/solid-core.module.d.ts.map +1 -1
- package/dist/solid-core.module.js +8 -0
- package/dist/solid-core.module.js.map +1 -1
- package/dist/subscribers/computed-entity-field.subscriber.js +3 -1
- package/dist/subscribers/computed-entity-field.subscriber.js.map +1 -1
- package/dist/transformers/typeorm/local-date-time-transformer.d.ts +4 -4
- package/dist/transformers/typeorm/local-date-time-transformer.d.ts.map +1 -1
- package/dist/transformers/typeorm/local-date-time-transformer.js +25 -28
- package/dist/transformers/typeorm/local-date-time-transformer.js.map +1 -1
- package/dist-tests/api/authenticate.spec.js +119 -0
- package/dist-tests/api/authenticate.spec.js.map +1 -0
- package/dist-tests/api/crud-service.findOne.cityMaster.spec.js +97 -0
- package/dist-tests/api/crud-service.findOne.cityMaster.spec.js.map +1 -0
- package/dist-tests/api/ping.spec.js +21 -0
- package/dist-tests/api/ping.spec.js.map +1 -0
- package/dist-tests/helpers/auth.js +41 -0
- package/dist-tests/helpers/auth.js.map +1 -0
- package/dist-tests/helpers/env.js +11 -0
- package/dist-tests/helpers/env.js.map +1 -0
- package/package.json +3 -1
- package/sql/default/mariadb/proc_CleanupModelMetadata.sql +153 -0
- package/sql/default/mariadb/proc_CleanupModuleMetadata.sql +56 -0
- package/sql/default/mysql/proc_CleanupModelMetadata.sql +153 -0
- package/sql/default/mysql/proc_CleanupModuleMetadata.sql +56 -0
- package/src/controllers/dashboard-layout.controller.ts +106 -0
- package/src/controllers/scheduled-job.controller.ts +6 -0
- package/src/dtos/create-dashboard-layout.dto.ts +31 -0
- package/src/dtos/create-dashboard-variable.dto.ts +4 -0
- package/src/dtos/update-dashboard-layout.dto.ts +30 -0
- package/src/dtos/update-dashboard-variable.dto.ts +5 -1
- package/src/entities/action-metadata.entity.ts +3 -2
- package/src/entities/ai-interaction.entity.ts +5 -4
- package/src/entities/chatter-message-details.entity.ts +7 -3
- package/src/entities/chatter-message.entity.ts +4 -3
- package/src/entities/common.entity.ts +2 -2
- package/src/entities/dashboard-layout.entity.ts +18 -0
- package/src/entities/dashboard-question-sql-dataset-config.entity.ts +5 -4
- package/src/entities/dashboard-question.entity.ts +5 -4
- package/src/entities/dashboard-variable.entity.ts +9 -4
- package/src/entities/dashboard.entity.ts +7 -2
- package/src/entities/email-attachment.entity.ts +2 -1
- package/src/entities/email-template.entity.ts +1 -1
- package/src/entities/export-transaction.entity.ts +2 -1
- package/src/entities/field-metadata.entity.ts +2 -2
- package/src/entities/import-transaction-error-log.entity.ts +3 -2
- package/src/entities/import-transaction.entity.ts +2 -1
- package/src/entities/legacy-common.entity.ts +3 -4
- package/src/entities/mq-message.entity.ts +5 -3
- package/src/entities/saved-filters.entity.ts +3 -2
- package/src/entities/security-rule.entity.ts +2 -1
- package/src/entities/sms-template.entity.ts +1 -1
- package/src/entities/user-view-metadata.entity.ts +2 -1
- package/src/entities/user.entity.ts +37 -2
- package/src/entities/view-metadata.entity.ts +3 -0
- package/src/helpers/bootstrap.helper.ts +222 -0
- package/src/helpers/cache.helper.ts +5 -0
- package/src/helpers/field-crud-managers/MediaFieldCrudManager.ts +9 -9
- package/src/helpers/field-crud-managers/SelectionDynamicFieldCrudManager.ts +9 -6
- package/src/helpers/solid-registry.ts +1 -5
- package/src/helpers/typeorm-db-helper.ts +26 -0
- package/src/index.ts +3 -0
- package/src/interfaces.ts +9 -1
- package/src/jobs/computed-field-evaluation-queue-options.ts +1 -0
- package/src/repository/dashboard-layout.repository.ts +17 -0
- package/src/seeders/module-metadata-seeder.service.ts +5 -5
- package/src/seeders/seed-data/solid-core-metadata.json +446 -36
- package/src/services/authentication.service.ts +46 -24
- package/src/services/chatter-message.service.ts +21 -21
- package/src/services/computed-fields/entity/sequence-num-computed-field-provider.ts +79 -40
- package/src/services/crud.service.ts +1 -1
- package/src/services/dashboard-layout.service.ts +111 -0
- package/src/services/dashboard-question.service.ts +23 -4
- package/src/services/dashboard.service.ts +7 -0
- package/src/services/model-metadata.service.ts +173 -50
- package/src/services/permission-metadata.service.ts +73 -20
- package/src/services/question-data-providers/chartjs-sql-data-provider.service.ts +3 -7
- package/src/services/question-data-providers/interfaces.ts +0 -0
- package/src/services/question-data-providers/prime-react-datatable-sql-data-provider.service.ts +4 -8
- package/src/services/question-data-providers/prime-react-meter-group-sql-data-provider.service.ts +4 -8
- package/src/services/queues/database-subscriber.service.ts +19 -2
- package/src/services/queues/publisher-factory.service.ts +8 -6
- package/src/services/queues/rabbitmq-subscriber.service.ts +123 -6
- package/src/services/scheduled-job.service.ts +31 -2
- package/src/services/scheduled-jobs/scheduler.interface.ts +4 -1
- package/src/services/scheduled-jobs/scheduler.service.ts +82 -20
- package/src/services/selection-providers/list-of-dashboard-question-providers-selection-provider.service.ts +4 -1
- package/src/services/solid-ts-morph.service.ts +98 -0
- package/src/solid-core.module.ts +13 -0
- package/src/subscribers/computed-entity-field.subscriber.ts +3 -3
- package/src/transformers/typeorm/local-date-time-transformer.ts +41 -33
- package/.claude/settings.local.json +0 -15
- package/src/services/1.js +0 -6
|
@@ -6,9 +6,20 @@ import { MqMessageQueueService } from '../mq-message-queue.service';
|
|
|
6
6
|
import { MqMessageService } from '../mq-message.service';
|
|
7
7
|
import { buildNamespacedQueueName } from './common';
|
|
8
8
|
|
|
9
|
+
class ConsumerProcessingTimeoutError extends Error {
|
|
10
|
+
constructor(
|
|
11
|
+
readonly queueName: string,
|
|
12
|
+
readonly messageId: string,
|
|
13
|
+
readonly timeoutMs: number,
|
|
14
|
+
) {
|
|
15
|
+
super(`Subscriber processing timed out after ${timeoutMs}ms for queue ${queueName} and messageId ${messageId}`);
|
|
16
|
+
this.name = 'ConsumerProcessingTimeoutError';
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
9
20
|
|
|
10
21
|
export abstract class RabbitMqSubscriber<T> implements OnModuleInit, QueueSubscriber<T> { // TODO This can be made a generic type for better type visibility
|
|
11
|
-
private
|
|
22
|
+
private _loggerInstance?: Logger;
|
|
12
23
|
private readonly url: string;
|
|
13
24
|
private readonly serviceRole: string;
|
|
14
25
|
private connection: amqp.Connection | null = null;
|
|
@@ -30,6 +41,17 @@ export abstract class RabbitMqSubscriber<T> implements OnModuleInit, QueueSubscr
|
|
|
30
41
|
// this.logger.debug(`RabbitMqSubscriber instance created with options: ${JSON.stringify(this.options())} and url: ${this.url}`);
|
|
31
42
|
}
|
|
32
43
|
|
|
44
|
+
protected get loggerContext(): string {
|
|
45
|
+
return this.constructor.name;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
protected get logger(): Logger {
|
|
49
|
+
if (!this._loggerInstance) {
|
|
50
|
+
this._loggerInstance = new Logger(this.loggerContext);
|
|
51
|
+
}
|
|
52
|
+
return this._loggerInstance;
|
|
53
|
+
}
|
|
54
|
+
|
|
33
55
|
abstract subscribe(message: QueueMessage<T>);
|
|
34
56
|
|
|
35
57
|
abstract options(): QueuesModuleOptions;
|
|
@@ -62,9 +84,15 @@ export abstract class RabbitMqSubscriber<T> implements OnModuleInit, QueueSubscr
|
|
|
62
84
|
const defaultBroker = process.env.QUEUES_DEFAULT_BROKER || 'rabbitmq';
|
|
63
85
|
const solidCliRunning = process.env.SOLID_CLI_RUNNING || "false";
|
|
64
86
|
const queueNameRegex = (process.env.QUEUES_QUEUE_NAME_REGEX_TO_ENABLE || '').trim();
|
|
87
|
+
const roleAllowed = ['both', 'subscriber'].includes(this.serviceRole);
|
|
88
|
+
|
|
89
|
+
if (!roleAllowed) {
|
|
90
|
+
this.logger.log(`RabbitMqSubscriber is disabled because QUEUES_SERVICE_ROLE is "${this.serviceRole}". Expected "both" or "subscriber".`);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
65
93
|
|
|
66
94
|
// we will start subscriber only if the current service role is subscriber.
|
|
67
|
-
if (this.url &&
|
|
95
|
+
if (this.url && solidCliRunning === "false" && defaultBroker === 'rabbitmq') {
|
|
68
96
|
const options = this.options();
|
|
69
97
|
const queueName = options.queueName;
|
|
70
98
|
|
|
@@ -102,6 +130,10 @@ export abstract class RabbitMqSubscriber<T> implements OnModuleInit, QueueSubscr
|
|
|
102
130
|
if (prefetch < 1) {
|
|
103
131
|
throw new Error(`RabbitMqSubscriber prefetch must be >= 1 for queue ${queueName}`);
|
|
104
132
|
}
|
|
133
|
+
const processingTimeoutMs = this.resolveProcessingTimeoutMs();
|
|
134
|
+
if (processingTimeoutMs > 0) {
|
|
135
|
+
this.logger.log(`RabbitMqSubscriber using processing timeout ${processingTimeoutMs}ms for queue ${queueName}`);
|
|
136
|
+
}
|
|
105
137
|
|
|
106
138
|
let connection: amqp.Connection;
|
|
107
139
|
try {
|
|
@@ -186,7 +218,7 @@ export abstract class RabbitMqSubscriber<T> implements OnModuleInit, QueueSubscr
|
|
|
186
218
|
if (!message.currentRetry) message.currentRetry = 0;
|
|
187
219
|
|
|
188
220
|
try {
|
|
189
|
-
await this.processMessage(message, rawMessage, channel);
|
|
221
|
+
await this.processMessage(message, rawMessage, channel, queueName);
|
|
190
222
|
} catch (error) {
|
|
191
223
|
await this.handleProcessingError(message, rawMessage, channel, error, queueName);
|
|
192
224
|
}
|
|
@@ -201,7 +233,7 @@ export abstract class RabbitMqSubscriber<T> implements OnModuleInit, QueueSubscr
|
|
|
201
233
|
// Retry flow: update DB -> increment retry -> send to retry queue with per-message expiration -> ack original.
|
|
202
234
|
private async handleProcessingError(message: QueueMessage<T>, rawMessage: amqp.ConsumeMessage, channel: amqp.Channel, error: any, queueName: string): Promise<void> {
|
|
203
235
|
const errorMessage = (error as Error)?.message || String(error);
|
|
204
|
-
this.logger.error(`Error processing message on queue ${queueName}: ${errorMessage}
|
|
236
|
+
this.logger.error(`Error processing message on queue ${queueName}: ${errorMessage}`, (error as Error)?.stack);
|
|
205
237
|
|
|
206
238
|
if (message.currentRetry < message.retryCount) {
|
|
207
239
|
await this.updateStatusInDatabase('retrying', message);
|
|
@@ -322,11 +354,11 @@ export abstract class RabbitMqSubscriber<T> implements OnModuleInit, QueueSubscr
|
|
|
322
354
|
/**
|
|
323
355
|
* Abstract method for message processing logic.
|
|
324
356
|
*/
|
|
325
|
-
protected async processMessage(message: QueueMessage<T>, rawMessage, channel): Promise<void> {
|
|
357
|
+
protected async processMessage(message: QueueMessage<T>, rawMessage, channel, queueName: string): Promise<void> {
|
|
326
358
|
await this.updateStatusInDatabase('started', message);
|
|
327
359
|
|
|
328
360
|
// Capture the results of handling the task.
|
|
329
|
-
const result = await this.
|
|
361
|
+
const result = await this.subscribeWithTimeout(message, queueName);
|
|
330
362
|
|
|
331
363
|
// Ack the message.
|
|
332
364
|
channel.ack(rawMessage);
|
|
@@ -370,4 +402,89 @@ export abstract class RabbitMqSubscriber<T> implements OnModuleInit, QueueSubscr
|
|
|
370
402
|
|
|
371
403
|
}
|
|
372
404
|
|
|
405
|
+
private resolveProcessingTimeoutMs(): number {
|
|
406
|
+
// Broker-side delivery-ack timeout (ms). If not provided, assume RabbitMQ default
|
|
407
|
+
// behavior used in this project: 30 minutes.
|
|
408
|
+
// Example (RabbitMQ broker):
|
|
409
|
+
// - Broker ack timeout: 30m => 1,800,000ms (QUEUES_RABBITMQ_CONSUMER_ACK_TIMEOUT_MS)
|
|
410
|
+
// - App soft timeout should be slightly lower, e.g. 29m30s => 1,770,000ms
|
|
411
|
+
// (QUEUES_RABBITMQ_SUBSCRIBER_PROCESSING_TIMEOUT_MS), so application code fails first,
|
|
412
|
+
// records DB state/error, and avoids broker-forced channel close as primary failure signal.
|
|
413
|
+
const brokerTimeoutMs = this.parsePositiveInt(process.env.QUEUES_RABBITMQ_CONSUMER_ACK_TIMEOUT_MS, 30 * 60 * 1000);
|
|
414
|
+
|
|
415
|
+
// Soft timeout should fire *before* broker timeout so we can fail explicitly,
|
|
416
|
+
// persist status/error, and avoid broker-forced channel closure as primary signal.
|
|
417
|
+
// Keep at least 1s to avoid zero/negative values when broker timeout is very small.
|
|
418
|
+
const defaultSoftTimeoutMs = Math.max(1_000, brokerTimeoutMs - 30_000);
|
|
419
|
+
|
|
420
|
+
// Final timeout precedence:
|
|
421
|
+
// 1) QUEUES_RABBITMQ_SUBSCRIBER_PROCESSING_TIMEOUT_MS (if valid positive int)
|
|
422
|
+
// 2) Derived defaultSoftTimeoutMs (broker timeout - 30s)
|
|
423
|
+
return this.parsePositiveInt(process.env.QUEUES_RABBITMQ_SUBSCRIBER_PROCESSING_TIMEOUT_MS, defaultSoftTimeoutMs);
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
private parsePositiveInt(value: string | undefined, fallback: number): number {
|
|
427
|
+
// Shared env parsing helper:
|
|
428
|
+
// - missing/invalid/non-positive => fallback
|
|
429
|
+
// - valid positive integer => parsed value
|
|
430
|
+
if (!value) return fallback;
|
|
431
|
+
const parsed = Number.parseInt(value, 10);
|
|
432
|
+
return Number.isFinite(parsed) && parsed > 0 ? parsed : fallback;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
private async subscribeWithTimeout(message: QueueMessage<T>, queueName: string): Promise<any> {
|
|
436
|
+
const timeoutMs = this.resolveProcessingTimeoutMs();
|
|
437
|
+
const messageId = message?.messageId || 'unknown';
|
|
438
|
+
|
|
439
|
+
// Allow an escape hatch: non-positive timeout means run without a soft timeout.
|
|
440
|
+
if (timeoutMs <= 0) {
|
|
441
|
+
return this.subscribe(message);
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
let timedOut = false;
|
|
445
|
+
let timeoutHandle: NodeJS.Timeout | null = null;
|
|
446
|
+
|
|
447
|
+
// Main subscriber work promise.
|
|
448
|
+
// If timeout has already fired, suppress rethrow to avoid unhandled rejection noise
|
|
449
|
+
// (the timeout error is already the authoritative failure we track).
|
|
450
|
+
const subscribePromise = this.subscribe(message).catch((error) => {
|
|
451
|
+
if (timedOut) {
|
|
452
|
+
this.logger.error(
|
|
453
|
+
`Subscriber promise rejected after timeout for queue ${queueName} and messageId ${messageId}: ${(error as Error)?.message || String(error)}`,
|
|
454
|
+
(error as Error)?.stack,
|
|
455
|
+
);
|
|
456
|
+
return undefined;
|
|
457
|
+
}
|
|
458
|
+
throw error;
|
|
459
|
+
});
|
|
460
|
+
|
|
461
|
+
// Timeout promise rejects after timeoutMs with an explicit domain-specific error.
|
|
462
|
+
const timeoutPromise = new Promise<never>((_, reject) => {
|
|
463
|
+
timeoutHandle = setTimeout(() => {
|
|
464
|
+
timedOut = true;
|
|
465
|
+
reject(new ConsumerProcessingTimeoutError(queueName, messageId, timeoutMs));
|
|
466
|
+
}, timeoutMs);
|
|
467
|
+
});
|
|
468
|
+
|
|
469
|
+
try {
|
|
470
|
+
// Promise.race settles as soon as the *first* promise settles.
|
|
471
|
+
// - If subscribePromise resolves/rejects first, we use that outcome.
|
|
472
|
+
// - If timeoutPromise rejects first, we fail fast with timeout error.
|
|
473
|
+
// This ensures we mark DB status via normal error handling before broker ack-timeout.
|
|
474
|
+
return await Promise.race([subscribePromise, timeoutPromise]);
|
|
475
|
+
} catch (error) {
|
|
476
|
+
const errorMessage = (error as Error)?.message || String(error);
|
|
477
|
+
this.logger.error(
|
|
478
|
+
`Subscriber execution failed for queue ${queueName} and messageId ${messageId}: ${errorMessage}`,
|
|
479
|
+
(error as Error)?.stack,
|
|
480
|
+
);
|
|
481
|
+
throw error;
|
|
482
|
+
} finally {
|
|
483
|
+
// Always clear timer once race settles to avoid timer leaks.
|
|
484
|
+
if (timeoutHandle) {
|
|
485
|
+
clearTimeout(timeoutHandle);
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
|
|
373
490
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { Injectable, Logger } from '@nestjs/common';
|
|
1
|
+
import { BadRequestException, Injectable, Logger, NotFoundException } from '@nestjs/common';
|
|
2
2
|
import { ModuleRef } from "@nestjs/core";
|
|
3
3
|
import { InjectEntityManager } from '@nestjs/typeorm';
|
|
4
4
|
import { ScheduledJob } from 'src/entities/scheduled-job.entity';
|
|
5
|
+
import { SolidRegistry } from 'src/helpers/solid-registry';
|
|
5
6
|
import { ScheduledJobRepository } from 'src/repository/scheduled-job.repository';
|
|
6
7
|
import { EntityManager } from 'typeorm';
|
|
7
8
|
import { CRUDService } from './crud.service';
|
|
9
|
+
import { SchedulerServiceImpl } from './scheduled-jobs/scheduler.service';
|
|
8
10
|
|
|
9
11
|
@Injectable()
|
|
10
12
|
export class ScheduledJobService extends CRUDService<ScheduledJob> {
|
|
@@ -16,9 +18,36 @@ export class ScheduledJobService extends CRUDService<ScheduledJob> {
|
|
|
16
18
|
// @InjectRepository(ScheduledJob)
|
|
17
19
|
// readonly repo: Repository<ScheduledJob>,
|
|
18
20
|
readonly repo: ScheduledJobRepository,
|
|
19
|
-
readonly moduleRef: ModuleRef
|
|
21
|
+
readonly moduleRef: ModuleRef,
|
|
22
|
+
private readonly solidRegistry: SolidRegistry,
|
|
23
|
+
private readonly schedulerService: SchedulerServiceImpl,
|
|
20
24
|
|
|
21
25
|
) {
|
|
22
26
|
super(entityManager, repo, 'scheduledJob', 'solid-core', moduleRef);
|
|
23
27
|
}
|
|
28
|
+
|
|
29
|
+
async triggerRun(id: number): Promise<ScheduledJob> {
|
|
30
|
+
const job = await this.repo.findOne({ where: { id } });
|
|
31
|
+
if (!job) {
|
|
32
|
+
throw new NotFoundException(`Scheduled job with id ${id} not found`);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const handler = this.solidRegistry.getScheduledJobProviderInstance(job.job);
|
|
36
|
+
if (!handler) {
|
|
37
|
+
throw new BadRequestException(`Scheduled job handler not found: ${job.job}`);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
this.logger.log(`Manually triggering scheduled job id=${job.id}, job=${job.job}`);
|
|
41
|
+
|
|
42
|
+
await handler.execute(job);
|
|
43
|
+
|
|
44
|
+
const finishedAt = new Date();
|
|
45
|
+
job.lastRunAt = finishedAt;
|
|
46
|
+
job.nextRunAt = this.schedulerService.computeNextRunAt(job, finishedAt);
|
|
47
|
+
await this.repo.save(job);
|
|
48
|
+
|
|
49
|
+
this.logger.log(`Completed manual trigger for scheduled job id=${job.id}, nextRunAt=${job.nextRunAt?.toISOString?.()}`);
|
|
50
|
+
|
|
51
|
+
return job;
|
|
52
|
+
}
|
|
24
53
|
}
|
|
@@ -24,13 +24,23 @@ export class SchedulerServiceImpl implements ISchedulerService {
|
|
|
24
24
|
async runScheduledJobs(): Promise<void> {
|
|
25
25
|
const solidSchedulerEnabled = process.env.SOLID_SCHEDULER_ENABLED || "true";
|
|
26
26
|
if (solidSchedulerEnabled.toLowerCase() !== "true") {
|
|
27
|
-
|
|
27
|
+
this.logger.debug('Solid scheduler is disabled via environment variable');
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
30
|
const solidCliRunning = process.env.SOLID_CLI_RUNNING || "false";
|
|
31
31
|
if (solidCliRunning === "true") {
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
|
+
const jobsRegexToEnable = (process.env.SOLID_SCHEDULER_JOBS_REGEX_TO_ENABLE || '').trim();
|
|
35
|
+
let jobsRegex: RegExp | null = null;
|
|
36
|
+
if (jobsRegexToEnable && jobsRegexToEnable !== "all") {
|
|
37
|
+
try {
|
|
38
|
+
jobsRegex = new RegExp(jobsRegexToEnable);
|
|
39
|
+
} catch (error) {
|
|
40
|
+
this.logger.error(`Invalid SOLID_SCHEDULER_JOBS_REGEX_TO_ENABLE regex "${jobsRegexToEnable}". Scheduler loop will skip this run.`);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
34
44
|
|
|
35
45
|
const now = new Date();
|
|
36
46
|
|
|
@@ -53,6 +63,12 @@ export class SchedulerServiceImpl implements ISchedulerService {
|
|
|
53
63
|
|
|
54
64
|
for (const job of dueJobs) {
|
|
55
65
|
const jobKey = String(job.id ?? job.scheduleName ?? job.job);
|
|
66
|
+
const jobName = String(job.job ?? '');
|
|
67
|
+
|
|
68
|
+
if (jobsRegex && !jobsRegex.test(jobName)) {
|
|
69
|
+
this.logger.log(`[${now.getTime()}]: scheduler service skipping job ${jobName} because it does not match SOLID_SCHEDULER_JOBS_REGEX_TO_ENABLE=${jobsRegexToEnable}`);
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
56
72
|
|
|
57
73
|
if (this.runningJobs.has(jobKey)) {
|
|
58
74
|
this.logger.log(`[${now.getTime()}]: scheduler service skipping job ${job.job} because a run is already in progress`);
|
|
@@ -94,22 +110,21 @@ export class SchedulerServiceImpl implements ISchedulerService {
|
|
|
94
110
|
}
|
|
95
111
|
|
|
96
112
|
private shouldRunNow(job: ScheduledJob, now: Date): boolean {
|
|
97
|
-
const today = now
|
|
98
|
-
|
|
113
|
+
const today = new Date(now);
|
|
114
|
+
today.setHours(0, 0, 0, 0);
|
|
115
|
+
const timeNow = this.toHHMM(now); // hh:mm
|
|
99
116
|
|
|
100
117
|
// 1. Check startDate / endDate
|
|
101
|
-
|
|
102
|
-
|
|
118
|
+
const startDate = this.toDateOnly(job.startDate as unknown as Date | string | null);
|
|
119
|
+
const endDate = this.toDateOnly(job.endDate as unknown as Date | string | null);
|
|
120
|
+
if (startDate && today < startDate) return false;
|
|
121
|
+
if (endDate && today > endDate) return false;
|
|
103
122
|
|
|
104
123
|
// 2. Check startTime / endTime
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
if (job.endTime) {
|
|
110
|
-
const jobEnd = job.endTime.toTimeString().slice(0, 5);
|
|
111
|
-
if (timeNow > jobEnd) return false;
|
|
112
|
-
}
|
|
124
|
+
const jobStart = this.toHHMM(job.startTime as unknown as Date | string | null);
|
|
125
|
+
const jobEnd = this.toHHMM(job.endTime as unknown as Date | string | null);
|
|
126
|
+
if (jobStart && timeNow < jobStart) return false;
|
|
127
|
+
if (jobEnd && timeNow > jobEnd) return false;
|
|
113
128
|
|
|
114
129
|
// 3. Check custom frequency
|
|
115
130
|
if (job.frequency.toLowerCase() === 'custom') {
|
|
@@ -121,8 +136,7 @@ export class SchedulerServiceImpl implements ISchedulerService {
|
|
|
121
136
|
// 3. Check dayOfWeek (for weekly)
|
|
122
137
|
if (job.frequency.toLowerCase() === 'weekly' && job.dayOfWeek) {
|
|
123
138
|
const todayName = now.toLocaleString('en-US', { weekday: 'long' }); // e.g., "Monday"
|
|
124
|
-
|
|
125
|
-
const days = JSON.parse(job.dayOfWeek) as string[];
|
|
139
|
+
const days = this.parseDayOfWeek(job.dayOfWeek);
|
|
126
140
|
if (!days.includes(todayName)) return false;
|
|
127
141
|
}
|
|
128
142
|
|
|
@@ -135,7 +149,53 @@ export class SchedulerServiceImpl implements ISchedulerService {
|
|
|
135
149
|
return true;
|
|
136
150
|
}
|
|
137
151
|
|
|
138
|
-
private
|
|
152
|
+
private parseDayOfWeek(dayOfWeek: string): string[] {
|
|
153
|
+
try {
|
|
154
|
+
const parsed = JSON.parse(dayOfWeek);
|
|
155
|
+
return Array.isArray(parsed) ? parsed : [];
|
|
156
|
+
} catch (error) {
|
|
157
|
+
this.logger.warn(`Invalid dayOfWeek JSON '${dayOfWeek}'`, error as any);
|
|
158
|
+
return [];
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
private toDateOnly(value: Date | string | null | undefined): Date | null {
|
|
163
|
+
if (!value) return null;
|
|
164
|
+
|
|
165
|
+
if (value instanceof Date) {
|
|
166
|
+
const d = new Date(value);
|
|
167
|
+
d.setHours(0, 0, 0, 0);
|
|
168
|
+
return d;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
const parsed = new Date(value);
|
|
172
|
+
if (Number.isNaN(parsed.getTime())) return null;
|
|
173
|
+
|
|
174
|
+
parsed.setHours(0, 0, 0, 0);
|
|
175
|
+
return parsed;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
private toHHMM(value: Date | string | null | undefined): string | null {
|
|
179
|
+
if (!value) return null;
|
|
180
|
+
|
|
181
|
+
if (value instanceof Date) {
|
|
182
|
+
return value.toTimeString().slice(0, 5);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
if (typeof value === 'string') {
|
|
186
|
+
const match = value.match(/^(\d{2}):(\d{2})/);
|
|
187
|
+
if (match) return `${match[1]}:${match[2]}`;
|
|
188
|
+
|
|
189
|
+
const parsed = new Date(value);
|
|
190
|
+
if (!Number.isNaN(parsed.getTime())) {
|
|
191
|
+
return parsed.toTimeString().slice(0, 5);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
return null;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
public computeNextRunForCustomCron(job: ScheduledJob, from: Date): Date {
|
|
139
199
|
const base = new Date(from);
|
|
140
200
|
|
|
141
201
|
if (!job.cronExpression) {
|
|
@@ -150,22 +210,24 @@ export class SchedulerServiceImpl implements ISchedulerService {
|
|
|
150
210
|
tz: 'UTC'
|
|
151
211
|
});
|
|
152
212
|
const nextRun = interval.next().toDate();
|
|
213
|
+
const runAfterNext = interval.next().toDate();
|
|
153
214
|
|
|
154
|
-
// Validate minimum 1 minute
|
|
155
|
-
|
|
215
|
+
// Validate minimum 1 minute cadence between consecutive runs.
|
|
216
|
+
// Comparing nextRun to "from" is incorrect near minute boundaries.
|
|
217
|
+
if (runAfterNext.getTime() - nextRun.getTime() < 60000) {
|
|
156
218
|
throw new Error('Cron expression interval must be at least 1 minute');
|
|
157
219
|
}
|
|
158
220
|
|
|
159
221
|
this.logger.log(`Custom cron '${job.cronExpression}' next run: ${nextRun}`);
|
|
160
222
|
return nextRun;
|
|
161
223
|
} catch (error) {
|
|
162
|
-
this.logger.error(`Invalid cron expression for job ${job.scheduleName}: ${job.cronExpression}
|
|
224
|
+
this.logger.error(`Invalid cron expression for job ${job.scheduleName}: ${job.cronExpression}. Reason: ${(error as Error).message}`);
|
|
163
225
|
// Fallback to daily if cron parsing fails
|
|
164
226
|
return new Date(base.getTime() + 24 * 60 * 60 * 1000);
|
|
165
227
|
}
|
|
166
228
|
}
|
|
167
229
|
|
|
168
|
-
|
|
230
|
+
public computeNextRunAt(job: ScheduledJob, from: Date): Date {
|
|
169
231
|
const base = new Date(from);
|
|
170
232
|
|
|
171
233
|
switch (job.frequency.toLowerCase()) {
|
|
@@ -3,6 +3,7 @@ import { SelectionProvider } from "src/decorators/selection-provider.decorator";
|
|
|
3
3
|
import { SolidRegistry } from "src/helpers/solid-registry";
|
|
4
4
|
import { IDashboardQuestionDataProvider, IDashboardVariableSelectionProvider, ISelectionProvider, ISelectionProviderContext, ISelectionProviderValues } from "../../interfaces";
|
|
5
5
|
import { SQL_DYNAMIC_PROVIDER_NAME } from "../dashboard.service";
|
|
6
|
+
import { CHARTJS_SQL_DATA_PROVIDER_NAME, INBUILT_SQL_DATA_PROVIDERS, PRIME_REACT_DATATABLE_SQL_DATA_PROVIDER_NAME, PRIME_REACT_METER_GROUP_SQL_DATA_PROVIDER_NAME } from "../dashboard-question.service";
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
@SelectionProvider()
|
|
@@ -34,7 +35,9 @@ export class ListOfDashboardQuestionProvidersSelectionProvider implements ISelec
|
|
|
34
35
|
async values(query: string, ctxt: ISelectionProviderContext): Promise<readonly ISelectionProviderValues[]> {
|
|
35
36
|
const dashboardSelectionProviders = this.solidRegistry.getDashboardQuestionDataProviders()
|
|
36
37
|
//Exclude the SQL dynamic provider from the list, (since although it is a dashboard selection provider, it is not a valid option for the user to select)
|
|
37
|
-
return dashboardSelectionProviders
|
|
38
|
+
return dashboardSelectionProviders
|
|
39
|
+
.filter(provider => !INBUILT_SQL_DATA_PROVIDERS.includes(provider.name()))
|
|
40
|
+
.map(i => {
|
|
38
41
|
return { label: i.name, value: i.name };
|
|
39
42
|
});
|
|
40
43
|
}
|
|
@@ -324,6 +324,104 @@ export class SolidTsMorphService {
|
|
|
324
324
|
return { staged: true, overwritten: false, skipped: false };
|
|
325
325
|
}
|
|
326
326
|
|
|
327
|
+
|
|
328
|
+
//Removes all import declarations from a file whose module specifier matches the given predicate.
|
|
329
|
+
//Returns the set of identifier names that were imported by the removed declarations.
|
|
330
|
+
removeImports(
|
|
331
|
+
filePath: string,
|
|
332
|
+
filter: (moduleSpecifier: string) => boolean
|
|
333
|
+
): { removedIdentifiers: Set<string>; staged: boolean; skipped: boolean } {
|
|
334
|
+
const abs = this.resolveRepoPath(filePath);
|
|
335
|
+
if (!existsSync(abs)) {
|
|
336
|
+
this.logger.warn(`removeImport: file not found at ${filePath}, skipping.`);
|
|
337
|
+
return { removedIdentifiers: new Set(), staged: false, skipped: true };
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
const existing = this.project.getSourceFile(abs);
|
|
341
|
+
const sourceFile = existing
|
|
342
|
+
? existing
|
|
343
|
+
: this.project.createSourceFile(abs, readFileSync(abs, "utf8"), { overwrite: true });
|
|
344
|
+
|
|
345
|
+
const importsToRemove = sourceFile.getImportDeclarations().filter(decl => {
|
|
346
|
+
const spec = decl.getModuleSpecifierValue().replace(/\\/g, "/");
|
|
347
|
+
return filter(spec);
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
if (importsToRemove.length === 0) {
|
|
351
|
+
return { removedIdentifiers: new Set(), staged: false, skipped: true };
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
const removedIdentifiers = new Set<string>();
|
|
355
|
+
for (const decl of importsToRemove) {
|
|
356
|
+
for (const named of decl.getNamedImports()) {
|
|
357
|
+
removedIdentifiers.add(named.getAliasNode()?.getText() ?? named.getName());
|
|
358
|
+
}
|
|
359
|
+
const defaultImport = decl.getDefaultImport();
|
|
360
|
+
if (defaultImport) removedIdentifiers.add(defaultImport.getText());
|
|
361
|
+
decl.remove();
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
this.dirtySourceFiles.add(abs);
|
|
365
|
+
this.logger.log(`Staged removal of ${importsToRemove.length} import(s) in: ${this.rel(abs)}`);
|
|
366
|
+
return { removedIdentifiers, staged: true, skipped: false };
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
//Removes the given identifier names from all @Module decorator array properties
|
|
370
|
+
removeModuleMembers(
|
|
371
|
+
filePath: string,
|
|
372
|
+
names: Set<string> | string[]
|
|
373
|
+
): { staged: boolean; skipped: boolean } {
|
|
374
|
+
const abs = this.resolveRepoPath(filePath);
|
|
375
|
+
if (!existsSync(abs)) {
|
|
376
|
+
this.logger.warn(`removeImportMembers: file not found at ${filePath}, skipping.`);
|
|
377
|
+
return { staged: false, skipped: true };
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
const identifiers = names instanceof Set ? names : new Set(names);
|
|
381
|
+
if (identifiers.size === 0) return { staged: false, skipped: true };
|
|
382
|
+
|
|
383
|
+
const existing = this.project.getSourceFile(abs);
|
|
384
|
+
const sourceFile = existing
|
|
385
|
+
? existing
|
|
386
|
+
: this.project.createSourceFile(abs, readFileSync(abs, "utf8"), { overwrite: true });
|
|
387
|
+
|
|
388
|
+
const nestModuleClass = sourceFile.getClasses().find(cls =>
|
|
389
|
+
cls.getDecorators().some(dec => dec.getName() === "Module")
|
|
390
|
+
);
|
|
391
|
+
if (!nestModuleClass) {
|
|
392
|
+
this.logger.warn(`removeImportMembers: no @Module() class found in ${filePath}`);
|
|
393
|
+
return { staged: false, skipped: true };
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
const moduleDec = nestModuleClass.getDecorators().find(dec => dec.getName() === "Module");
|
|
397
|
+
const arg0 = moduleDec?.getCallExpression()?.getArguments()[0];
|
|
398
|
+
if (!arg0 || !Node.isObjectLiteralExpression(arg0)) return { staged: false, skipped: true };
|
|
399
|
+
|
|
400
|
+
const meta = arg0 as ObjectLiteralExpression;
|
|
401
|
+
for (const propName of ["imports", "providers", "controllers", "exports"] as const) {
|
|
402
|
+
const prop = meta.getProperty(propName);
|
|
403
|
+
if (!prop || !Node.isPropertyAssignment(prop)) continue;
|
|
404
|
+
const init = prop.getInitializer();
|
|
405
|
+
if (!init || !Node.isArrayLiteralExpression(init)) continue;
|
|
406
|
+
const arr = init as ArrayLiteralExpression;
|
|
407
|
+
const elements = arr.getElements();
|
|
408
|
+
for (let i = elements.length - 1; i >= 0; i--) {
|
|
409
|
+
const elemText = elements[i].getText().trim();
|
|
410
|
+
// Match direct identifiers (e.g. TestService) or call expressions that reference them (e.g. TypeOrmModule.forFeature([Test])).
|
|
411
|
+
const shouldRemove = identifiers.has(elemText) ||
|
|
412
|
+
[...identifiers].some(id => new RegExp(`\\b${id}\\b`).test(elemText));
|
|
413
|
+
if (shouldRemove) {
|
|
414
|
+
arr.removeElement(i);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
this.dirtySourceFiles.add(abs);
|
|
420
|
+
this.logger.log(`Staged removal of [${[...identifiers].join(", ")}] from @Module arrays in: ${this.rel(abs)}`);
|
|
421
|
+
return { staged: true, skipped: false };
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
|
|
327
425
|
addImport(
|
|
328
426
|
filePath: string,
|
|
329
427
|
importLine: string
|
package/src/solid-core.module.ts
CHANGED
|
@@ -133,6 +133,8 @@ import { ChatterMessageController } from './controllers/chatter-message.controll
|
|
|
133
133
|
import { DashboardQuestionSqlDatasetConfigController } from './controllers/dashboard-question-sql-dataset-config.controller';
|
|
134
134
|
import { DashboardQuestionController } from './controllers/dashboard-question.controller';
|
|
135
135
|
import { DashboardVariableController } from './controllers/dashboard-variable.controller';
|
|
136
|
+
import { DashboardLayoutController } from './controllers/dashboard-layout.controller';
|
|
137
|
+
|
|
136
138
|
import { DashboardController } from './controllers/dashboard.controller';
|
|
137
139
|
import { ExportTemplateController } from './controllers/export-template.controller';
|
|
138
140
|
import { ExportTransactionController } from './controllers/export-transaction.controller';
|
|
@@ -156,6 +158,8 @@ import { ChatterMessage } from './entities/chatter-message.entity';
|
|
|
156
158
|
import { DashboardQuestionSqlDatasetConfig } from './entities/dashboard-question-sql-dataset-config.entity';
|
|
157
159
|
import { DashboardQuestion } from './entities/dashboard-question.entity';
|
|
158
160
|
import { DashboardVariable } from './entities/dashboard-variable.entity';
|
|
161
|
+
import { DashboardLayout } from './entities/dashboard-layout.entity';
|
|
162
|
+
|
|
159
163
|
import { Dashboard } from './entities/dashboard.entity';
|
|
160
164
|
import { ExportTemplate } from './entities/export-template.entity';
|
|
161
165
|
import { ExportTransaction } from './entities/export-transaction.entity';
|
|
@@ -221,6 +225,8 @@ import { DashboardQuestionSqlDatasetConfigRepository } from './repository/dashbo
|
|
|
221
225
|
import { DashboardQuestionRepository } from './repository/dashboard-question.repository';
|
|
222
226
|
import { DashboardVariableRepository } from './repository/dashboard-variable.repository';
|
|
223
227
|
import { DashboardRepository } from './repository/dashboard.repository';
|
|
228
|
+
import { DashboardLayoutRepository } from './repository/dashboard-layout.repository';
|
|
229
|
+
|
|
224
230
|
import { EmailTemplateRepository } from './repository/email-template.repository';
|
|
225
231
|
import { ExportTemplateRepository } from './repository/export-template.repository';
|
|
226
232
|
import { ExportTransactionRepository } from './repository/export-transaction.repository';
|
|
@@ -263,6 +269,8 @@ import { DashboardVariableSQLDynamicProvider } from './services/dashboard-select
|
|
|
263
269
|
import { DasbhoardVariableTestDynamicProvider } from './services/dashboard-selection-providers/dashboard-variable-test-dynamic-provider.service';
|
|
264
270
|
import { DashboardVariableService } from './services/dashboard-variable.service';
|
|
265
271
|
import { DashboardService } from './services/dashboard.service';
|
|
272
|
+
import { DashboardLayoutService } from './services/dashboard-layout.service';
|
|
273
|
+
|
|
266
274
|
import { ExcelService } from './services/excel.service';
|
|
267
275
|
import { ExportTemplateService } from './services/export-template.service';
|
|
268
276
|
import { ExportTransactionService } from './services/export-transaction.service';
|
|
@@ -329,6 +337,7 @@ import { ImageEncodingService } from './helpers/image-encoding.helper';
|
|
|
329
337
|
import { SolidMicroserviceAdapter } from './helpers/solid-microservice-adapter.service';
|
|
330
338
|
import { InfoCommand } from './commands/info.command';
|
|
331
339
|
import { ListOfRolesSelectionProvider } from './services/selection-providers/list-of-roles-selectionproviders.service';
|
|
340
|
+
import { Entity } from 'typeorm';
|
|
332
341
|
|
|
333
342
|
|
|
334
343
|
@Global()
|
|
@@ -343,6 +352,7 @@ import { ListOfRolesSelectionProvider } from './services/selection-providers/lis
|
|
|
343
352
|
DashboardQuestion,
|
|
344
353
|
DashboardQuestionSqlDatasetConfig,
|
|
345
354
|
DashboardVariable,
|
|
355
|
+
DashboardLayout,
|
|
346
356
|
EmailAttachment,
|
|
347
357
|
EmailTemplate,
|
|
348
358
|
ExportTemplate,
|
|
@@ -414,6 +424,7 @@ import { ListOfRolesSelectionProvider } from './services/selection-providers/lis
|
|
|
414
424
|
DashboardQuestionController,
|
|
415
425
|
DashboardQuestionSqlDatasetConfigController,
|
|
416
426
|
DashboardVariableController,
|
|
427
|
+
DashboardLayoutController,
|
|
417
428
|
EmailTemplateController,
|
|
418
429
|
ExportTemplateController,
|
|
419
430
|
ExportTransactionController,
|
|
@@ -638,6 +649,7 @@ import { ListOfRolesSelectionProvider } from './services/selection-providers/lis
|
|
|
638
649
|
UserActivityHistoryService,
|
|
639
650
|
DashboardService,
|
|
640
651
|
DashboardVariableService,
|
|
652
|
+
DashboardLayoutService,
|
|
641
653
|
DashboardQuestionService,
|
|
642
654
|
DashboardVariableSQLDynamicProvider,
|
|
643
655
|
DasbhoardVariableTestDynamicProvider,
|
|
@@ -682,6 +694,7 @@ import { ListOfRolesSelectionProvider } from './services/selection-providers/lis
|
|
|
682
694
|
DashboardQuestionSqlDatasetConfigRepository,
|
|
683
695
|
DashboardQuestionRepository,
|
|
684
696
|
DashboardVariableRepository,
|
|
697
|
+
DashboardLayoutRepository,
|
|
685
698
|
EmailTemplateRepository,
|
|
686
699
|
ExportTemplateRepository,
|
|
687
700
|
ExportTransactionRepository,
|
|
@@ -78,9 +78,9 @@ export class ComputedEntityFieldSubscriber implements EntitySubscriberInterface
|
|
|
78
78
|
modelName
|
|
79
79
|
);
|
|
80
80
|
//TODO: We can add a feature i.e dependsOn, where we can check if the computed field depends on other computed fields and evaluate them first
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
for (const computedField of computedFieldsTobeEvaluated) {
|
|
82
|
+
await this.evaluateComputedField(this.attachContext(computedField, eventContext), entity, currentOperation);
|
|
83
|
+
}
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
private handleComputedFieldEvaluationJob(entity: any, currentOperation: ComputedFieldTriggerOperation, modelName: string, eventContext?: TypeOrmEventContext) {
|