@solidxai/core 0.1.10-beta.22 → 0.1.10-beta.24
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/CLAUDE.md +9 -1
- package/dist/commands/info.command.d.ts.map +1 -1
- package/dist/commands/info.command.js +0 -2
- package/dist/commands/info.command.js.map +1 -1
- package/dist/controllers/dashboard-user-layout.controller.d.ts +43 -0
- package/dist/controllers/dashboard-user-layout.controller.d.ts.map +1 -0
- package/dist/controllers/{dashboard-variable.controller.js → dashboard-user-layout.controller.js} +30 -30
- package/dist/controllers/dashboard-user-layout.controller.js.map +1 -0
- package/dist/controllers/dashboard.controller.d.ts +12 -42
- package/dist/controllers/dashboard.controller.d.ts.map +1 -1
- package/dist/controllers/dashboard.controller.js +71 -141
- package/dist/controllers/dashboard.controller.js.map +1 -1
- package/dist/decorators/dashboard-widget-data-provider.decorator.d.ts +3 -0
- package/dist/decorators/dashboard-widget-data-provider.decorator.d.ts.map +1 -0
- package/dist/decorators/dashboard-widget-data-provider.decorator.js +8 -0
- package/dist/decorators/dashboard-widget-data-provider.decorator.js.map +1 -0
- package/dist/dtos/create-dashboard-user-layout.dto.d.ts +10 -0
- package/dist/dtos/create-dashboard-user-layout.dto.d.ts.map +1 -0
- package/dist/dtos/create-dashboard-user-layout.dto.js +66 -0
- package/dist/dtos/create-dashboard-user-layout.dto.js.map +1 -0
- package/dist/dtos/create-model-metadata.dto.d.ts +2 -2
- package/dist/dtos/create-model-metadata.dto.d.ts.map +1 -1
- package/dist/dtos/create-model-metadata.dto.js +6 -11
- package/dist/dtos/create-model-metadata.dto.js.map +1 -1
- package/dist/dtos/dashboard-variable-options-query.dto.d.ts +7 -0
- package/dist/dtos/dashboard-variable-options-query.dto.d.ts.map +1 -0
- package/dist/dtos/dashboard-variable-options-query.dto.js +40 -0
- package/dist/dtos/dashboard-variable-options-query.dto.js.map +1 -0
- package/dist/dtos/dashboard-widget-data-request.dto.d.ts +12 -0
- package/dist/dtos/dashboard-widget-data-request.dto.d.ts.map +1 -0
- package/dist/dtos/dashboard-widget-data-request.dto.js +65 -0
- package/dist/dtos/dashboard-widget-data-request.dto.js.map +1 -0
- package/dist/dtos/update-dashboard-user-layout.dto.d.ts +11 -0
- package/dist/dtos/update-dashboard-user-layout.dto.d.ts.map +1 -0
- package/dist/dtos/{update-dashboard-layout.dto.js → update-dashboard-user-layout.dto.js} +34 -16
- package/dist/dtos/update-dashboard-user-layout.dto.js.map +1 -0
- package/dist/entities/dashboard-user-layout.entity.d.ts +11 -0
- package/dist/entities/dashboard-user-layout.entity.d.ts.map +1 -0
- package/dist/entities/dashboard-user-layout.entity.js +52 -0
- package/dist/entities/dashboard-user-layout.entity.js.map +1 -0
- package/dist/entities/legacy-common-with-id.entity.d.ts +2 -2
- package/dist/entities/legacy-common-with-id.entity.d.ts.map +1 -1
- package/dist/entities/legacy-common-with-id.entity.js +6 -6
- package/dist/entities/legacy-common-with-id.entity.js.map +1 -1
- package/dist/entities/legacy-common.entity.d.ts +1 -1
- package/dist/entities/legacy-common.entity.d.ts.map +1 -1
- package/dist/entities/legacy-common.entity.js +14 -14
- package/dist/entities/legacy-common.entity.js.map +1 -1
- package/dist/entities/model-metadata.entity.d.ts +2 -2
- package/dist/entities/model-metadata.entity.d.ts.map +1 -1
- package/dist/entities/model-metadata.entity.js +5 -8
- package/dist/entities/model-metadata.entity.js.map +1 -1
- package/dist/enums/legacy-table-type.enum.d.ts +6 -0
- package/dist/enums/legacy-table-type.enum.d.ts.map +1 -0
- package/dist/enums/legacy-table-type.enum.js +10 -0
- package/dist/enums/legacy-table-type.enum.js.map +1 -0
- package/dist/helpers/model-metadata-helper.service.d.ts +2 -1
- package/dist/helpers/model-metadata-helper.service.d.ts.map +1 -1
- package/dist/helpers/model-metadata-helper.service.js +4 -3
- package/dist/helpers/model-metadata-helper.service.js.map +1 -1
- package/dist/helpers/module-metadata-helper.service.d.ts.map +1 -1
- package/dist/helpers/module-metadata-helper.service.js +15 -4
- package/dist/helpers/module-metadata-helper.service.js.map +1 -1
- package/dist/helpers/solid-registry.d.ts +5 -9
- package/dist/helpers/solid-registry.d.ts.map +1 -1
- package/dist/helpers/solid-registry.js +13 -28
- package/dist/helpers/solid-registry.js.map +1 -1
- package/dist/index.d.ts +22 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -5
- package/dist/index.js.map +1 -1
- package/dist/interfaces.d.ts +24 -13
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/interfaces.js.map +1 -1
- package/dist/jobs/database/trigger-mcp-client-subscriber-database.service.d.ts +1 -3
- package/dist/jobs/database/trigger-mcp-client-subscriber-database.service.d.ts.map +1 -1
- package/dist/jobs/database/trigger-mcp-client-subscriber-database.service.js +2 -25
- package/dist/jobs/database/trigger-mcp-client-subscriber-database.service.js.map +1 -1
- package/dist/{repository/dashboard-layout.repository.d.ts → repositories/dashboard-user-layout.repository.d.ts} +5 -5
- package/dist/repositories/dashboard-user-layout.repository.d.ts.map +1 -0
- package/dist/{repository/dashboard-question-sql-dataset-config.repository.js → repositories/dashboard-user-layout.repository.js} +15 -10
- package/dist/repositories/dashboard-user-layout.repository.js.map +1 -0
- package/dist/seeders/module-metadata-seeder.service.d.ts +1 -6
- package/dist/seeders/module-metadata-seeder.service.d.ts.map +1 -1
- package/dist/seeders/module-metadata-seeder.service.js +1 -60
- package/dist/seeders/module-metadata-seeder.service.js.map +1 -1
- package/dist/seeders/seed-data/solid-core-metadata.json +6209 -6690
- package/dist/seeders/system-fields-seeder.service.js +1 -1
- package/dist/seeders/system-fields-seeder.service.js.map +1 -1
- package/dist/services/dashboard-providers/mq-dashboard-avg-elapsed-kpi-provider.service.d.ts +13 -0
- package/dist/services/dashboard-providers/mq-dashboard-avg-elapsed-kpi-provider.service.d.ts.map +1 -0
- package/dist/services/dashboard-providers/mq-dashboard-avg-elapsed-kpi-provider.service.js +55 -0
- package/dist/services/dashboard-providers/mq-dashboard-avg-elapsed-kpi-provider.service.js.map +1 -0
- package/dist/services/dashboard-providers/mq-dashboard-failed-messages-kpi-provider.service.d.ts +13 -0
- package/dist/services/dashboard-providers/mq-dashboard-failed-messages-kpi-provider.service.d.ts.map +1 -0
- package/dist/services/dashboard-providers/mq-dashboard-failed-messages-kpi-provider.service.js +52 -0
- package/dist/services/dashboard-providers/mq-dashboard-failed-messages-kpi-provider.service.js.map +1 -0
- package/dist/services/dashboard-providers/mq-dashboard-inflight-messages-kpi-provider.service.d.ts +13 -0
- package/dist/services/dashboard-providers/mq-dashboard-inflight-messages-kpi-provider.service.d.ts.map +1 -0
- package/dist/services/dashboard-providers/mq-dashboard-inflight-messages-kpi-provider.service.js +52 -0
- package/dist/services/dashboard-providers/mq-dashboard-inflight-messages-kpi-provider.service.js.map +1 -0
- package/dist/services/dashboard-providers/mq-dashboard-latency-trend-provider.service.d.ts +10 -0
- package/dist/services/dashboard-providers/mq-dashboard-latency-trend-provider.service.d.ts.map +1 -0
- package/dist/services/dashboard-providers/mq-dashboard-latency-trend-provider.service.js +62 -0
- package/dist/services/dashboard-providers/mq-dashboard-latency-trend-provider.service.js.map +1 -0
- package/dist/services/dashboard-providers/mq-dashboard-messages-over-time-provider.service.d.ts +10 -0
- package/dist/services/dashboard-providers/mq-dashboard-messages-over-time-provider.service.d.ts.map +1 -0
- package/dist/services/dashboard-providers/mq-dashboard-messages-over-time-provider.service.js +82 -0
- package/dist/services/dashboard-providers/mq-dashboard-messages-over-time-provider.service.js.map +1 -0
- package/dist/services/dashboard-providers/mq-dashboard-provider-utils.d.ts +17 -0
- package/dist/services/dashboard-providers/mq-dashboard-provider-utils.d.ts.map +1 -0
- package/dist/services/dashboard-providers/mq-dashboard-provider-utils.js +130 -0
- package/dist/services/dashboard-providers/mq-dashboard-provider-utils.js.map +1 -0
- package/dist/services/dashboard-providers/mq-dashboard-queue-sla-heatmap-provider.service.d.ts +37 -0
- package/dist/services/dashboard-providers/mq-dashboard-queue-sla-heatmap-provider.service.d.ts.map +1 -0
- package/dist/services/dashboard-providers/mq-dashboard-queue-sla-heatmap-provider.service.js +112 -0
- package/dist/services/dashboard-providers/mq-dashboard-queue-sla-heatmap-provider.service.js.map +1 -0
- package/dist/services/dashboard-providers/mq-dashboard-queue-wise-avg-elapsed-provider.service.d.ts +10 -0
- package/dist/services/dashboard-providers/mq-dashboard-queue-wise-avg-elapsed-provider.service.d.ts.map +1 -0
- package/dist/services/dashboard-providers/mq-dashboard-queue-wise-avg-elapsed-provider.service.js +57 -0
- package/dist/services/dashboard-providers/mq-dashboard-queue-wise-avg-elapsed-provider.service.js.map +1 -0
- package/dist/services/dashboard-providers/mq-dashboard-queue-wise-failures-provider.service.d.ts +10 -0
- package/dist/services/dashboard-providers/mq-dashboard-queue-wise-failures-provider.service.d.ts.map +1 -0
- package/dist/services/dashboard-providers/mq-dashboard-queue-wise-failures-provider.service.js +57 -0
- package/dist/services/dashboard-providers/mq-dashboard-queue-wise-failures-provider.service.js.map +1 -0
- package/dist/services/dashboard-providers/mq-dashboard-recent-failures-provider.service.d.ts +10 -0
- package/dist/services/dashboard-providers/mq-dashboard-recent-failures-provider.service.d.ts.map +1 -0
- package/dist/services/dashboard-providers/mq-dashboard-recent-failures-provider.service.js +100 -0
- package/dist/services/dashboard-providers/mq-dashboard-recent-failures-provider.service.js.map +1 -0
- package/dist/services/dashboard-providers/mq-dashboard-stage-distribution-provider.service.d.ts +10 -0
- package/dist/services/dashboard-providers/mq-dashboard-stage-distribution-provider.service.d.ts.map +1 -0
- package/dist/services/dashboard-providers/mq-dashboard-stage-distribution-provider.service.js +55 -0
- package/dist/services/dashboard-providers/mq-dashboard-stage-distribution-provider.service.js.map +1 -0
- package/dist/services/dashboard-providers/mq-dashboard-succeeded-messages-kpi-provider.service.d.ts +13 -0
- package/dist/services/dashboard-providers/mq-dashboard-succeeded-messages-kpi-provider.service.d.ts.map +1 -0
- package/dist/services/dashboard-providers/mq-dashboard-succeeded-messages-kpi-provider.service.js +52 -0
- package/dist/services/dashboard-providers/mq-dashboard-succeeded-messages-kpi-provider.service.js.map +1 -0
- package/dist/services/dashboard-providers/mq-dashboard-success-rate-kpi-provider.service.d.ts +15 -0
- package/dist/services/dashboard-providers/mq-dashboard-success-rate-kpi-provider.service.d.ts.map +1 -0
- package/dist/services/dashboard-providers/mq-dashboard-success-rate-kpi-provider.service.js +60 -0
- package/dist/services/dashboard-providers/mq-dashboard-success-rate-kpi-provider.service.js.map +1 -0
- package/dist/services/dashboard-providers/mq-dashboard-total-messages-kpi-provider.service.d.ts +13 -0
- package/dist/services/dashboard-providers/mq-dashboard-total-messages-kpi-provider.service.d.ts.map +1 -0
- package/dist/services/dashboard-providers/mq-dashboard-total-messages-kpi-provider.service.js +51 -0
- package/dist/services/dashboard-providers/mq-dashboard-total-messages-kpi-provider.service.js.map +1 -0
- package/dist/services/dashboard-runtime.service.d.ts +31 -0
- package/dist/services/dashboard-runtime.service.d.ts.map +1 -0
- package/dist/services/dashboard-runtime.service.js +408 -0
- package/dist/services/dashboard-runtime.service.js.map +1 -0
- package/dist/services/dashboard-user-layout.service.d.ts +12 -0
- package/dist/services/dashboard-user-layout.service.d.ts.map +1 -0
- package/dist/services/{dashboard-variable.service.js → dashboard-user-layout.service.js} +11 -12
- package/dist/services/dashboard-user-layout.service.js.map +1 -0
- package/dist/services/mediaStorageProviders/file-s3-storage-provider.js +9 -9
- package/dist/services/mediaStorageProviders/file-s3-storage-provider.js.map +1 -1
- package/dist/services/model-metadata.service.d.ts +2 -2
- package/dist/services/model-metadata.service.d.ts.map +1 -1
- package/dist/services/model-metadata.service.js +3 -4
- package/dist/services/model-metadata.service.js.map +1 -1
- package/dist/services/selection-providers/mq-dashboard-message-broker-variable-options-provider.service.d.ts +11 -0
- package/dist/services/selection-providers/mq-dashboard-message-broker-variable-options-provider.service.d.ts.map +1 -0
- package/dist/services/selection-providers/mq-dashboard-message-broker-variable-options-provider.service.js +59 -0
- package/dist/services/selection-providers/mq-dashboard-message-broker-variable-options-provider.service.js.map +1 -0
- package/dist/services/selection-providers/mq-dashboard-queue-name-variable-options-provider.service.d.ts +11 -0
- package/dist/services/selection-providers/mq-dashboard-queue-name-variable-options-provider.service.d.ts.map +1 -0
- package/dist/services/selection-providers/mq-dashboard-queue-name-variable-options-provider.service.js +60 -0
- package/dist/services/selection-providers/mq-dashboard-queue-name-variable-options-provider.service.js.map +1 -0
- package/dist/services/solid-introspect.service.d.ts +1 -2
- package/dist/services/solid-introspect.service.d.ts.map +1 -1
- package/dist/services/solid-introspect.service.js +12 -24
- package/dist/services/solid-introspect.service.js.map +1 -1
- package/dist/solid-core.module.d.ts.map +1 -1
- package/dist/solid-core.module.js +43 -66
- package/dist/solid-core.module.js.map +1 -1
- package/dist/subscribers/model-metadata.subscriber.d.ts.map +1 -1
- package/dist/subscribers/model-metadata.subscriber.js +1 -3
- package/dist/subscribers/model-metadata.subscriber.js.map +1 -1
- package/package.json +1 -1
- package/src/commands/info.command.ts +0 -2
- package/src/controllers/{dashboard-variable.controller.ts → dashboard-user-layout.controller.ts} +10 -10
- package/src/controllers/dashboard.controller.ts +70 -89
- package/src/decorators/dashboard-widget-data-provider.decorator.ts +6 -0
- package/src/dtos/create-dashboard-user-layout.dto.ts +41 -0
- package/src/dtos/create-model-metadata.dto.ts +5 -9
- package/src/dtos/dashboard-variable-options-query.dto.ts +20 -0
- package/src/dtos/dashboard-widget-data-request.dto.ts +34 -0
- package/src/dtos/update-dashboard-user-layout.dto.ts +45 -0
- package/src/entities/dashboard-user-layout.entity.ts +27 -0
- package/src/entities/legacy-common-with-id.entity.ts +2 -2
- package/src/entities/legacy-common.entity.ts +1 -1
- package/src/entities/model-metadata.entity.ts +3 -5
- package/src/enums/legacy-table-type.enum.ts +5 -0
- package/src/helpers/model-metadata-helper.service.ts +4 -3
- package/src/helpers/module-metadata-helper.service.ts +21 -6
- package/src/helpers/solid-registry.ts +15 -36
- package/src/index.ts +22 -5
- package/src/interfaces.ts +32 -19
- package/src/jobs/database/trigger-mcp-client-subscriber-database.service.ts +1 -34
- package/src/repositories/dashboard-user-layout.repository.ts +19 -0
- package/src/seeders/module-metadata-seeder.service.ts +0 -67
- package/src/seeders/seed-data/solid-core-metadata.json +6210 -6691
- package/src/seeders/system-fields-seeder.service.ts +1 -1
- package/src/services/dashboard-providers/README.md +603 -0
- package/src/services/dashboard-providers/mq-dashboard-avg-elapsed-kpi-provider.service.ts +49 -0
- package/src/services/dashboard-providers/mq-dashboard-failed-messages-kpi-provider.service.ts +45 -0
- package/src/services/dashboard-providers/mq-dashboard-inflight-messages-kpi-provider.service.ts +45 -0
- package/src/services/dashboard-providers/mq-dashboard-latency-trend-provider.service.ts +58 -0
- package/src/services/dashboard-providers/mq-dashboard-messages-over-time-provider.service.ts +79 -0
- package/src/services/dashboard-providers/mq-dashboard-provider-utils.ts +165 -0
- package/src/services/dashboard-providers/mq-dashboard-queue-sla-heatmap-provider.service.ts +155 -0
- package/src/services/dashboard-providers/mq-dashboard-queue-wise-avg-elapsed-provider.service.ts +51 -0
- package/src/services/dashboard-providers/mq-dashboard-queue-wise-failures-provider.service.ts +51 -0
- package/src/services/dashboard-providers/mq-dashboard-recent-failures-provider.service.ts +95 -0
- package/src/services/dashboard-providers/mq-dashboard-stage-distribution-provider.service.ts +49 -0
- package/src/services/dashboard-providers/mq-dashboard-succeeded-messages-kpi-provider.service.ts +45 -0
- package/src/services/dashboard-providers/mq-dashboard-success-rate-kpi-provider.service.ts +55 -0
- package/src/services/dashboard-providers/mq-dashboard-total-messages-kpi-provider.service.ts +44 -0
- package/src/services/dashboard-runtime.service.ts +488 -0
- package/src/services/dashboard-user-layout.service.ts +20 -0
- package/src/services/mediaStorageProviders/file-s3-storage-provider.ts +11 -11
- package/src/services/model-metadata.service.ts +6 -8
- package/src/services/selection-providers/mq-dashboard-message-broker-variable-options-provider.service.ts +52 -0
- package/src/services/selection-providers/mq-dashboard-queue-name-variable-options-provider.service.ts +51 -0
- package/src/services/solid-introspect.service.ts +19 -34
- package/src/solid-core.module.ts +43 -72
- package/src/subscribers/model-metadata.subscriber.ts +1 -3
- package/CURRENT_PROMPT +0 -6
- package/dist/controllers/dashboard-layout.controller.d.ts +0 -47
- package/dist/controllers/dashboard-layout.controller.d.ts.map +0 -1
- package/dist/controllers/dashboard-layout.controller.js +0 -204
- package/dist/controllers/dashboard-layout.controller.js.map +0 -1
- package/dist/controllers/dashboard-question-sql-dataset-config.controller.d.ts +0 -43
- package/dist/controllers/dashboard-question-sql-dataset-config.controller.d.ts.map +0 -1
- package/dist/controllers/dashboard-question-sql-dataset-config.controller.js +0 -179
- package/dist/controllers/dashboard-question-sql-dataset-config.controller.js.map +0 -1
- package/dist/controllers/dashboard-question.controller.d.ts +0 -45
- package/dist/controllers/dashboard-question.controller.d.ts.map +0 -1
- package/dist/controllers/dashboard-question.controller.js +0 -194
- package/dist/controllers/dashboard-question.controller.js.map +0 -1
- package/dist/controllers/dashboard-variable.controller.d.ts +0 -43
- package/dist/controllers/dashboard-variable.controller.d.ts.map +0 -1
- package/dist/controllers/dashboard-variable.controller.js.map +0 -1
- package/dist/decorators/dashboard-question-data-provider.decorator.d.ts +0 -3
- package/dist/decorators/dashboard-question-data-provider.decorator.d.ts.map +0 -1
- package/dist/decorators/dashboard-question-data-provider.decorator.js +0 -11
- package/dist/decorators/dashboard-question-data-provider.decorator.js.map +0 -1
- package/dist/decorators/dashboard-selection-provider.decorator.d.ts +0 -3
- package/dist/decorators/dashboard-selection-provider.decorator.d.ts.map +0 -1
- package/dist/decorators/dashboard-selection-provider.decorator.js +0 -11
- package/dist/decorators/dashboard-selection-provider.decorator.js.map +0 -1
- package/dist/dtos/create-dashboard-layout.dto.d.ts +0 -8
- package/dist/dtos/create-dashboard-layout.dto.d.ts.map +0 -1
- package/dist/dtos/create-dashboard-layout.dto.js +0 -53
- package/dist/dtos/create-dashboard-layout.dto.js.map +0 -1
- package/dist/dtos/create-dashboard-question-sql-dataset-config.dto.d.ts +0 -12
- package/dist/dtos/create-dashboard-question-sql-dataset-config.dto.d.ts.map +0 -1
- package/dist/dtos/create-dashboard-question-sql-dataset-config.dto.js +0 -77
- package/dist/dtos/create-dashboard-question-sql-dataset-config.dto.js.map +0 -1
- package/dist/dtos/create-dashboard-question.dto.d.ts +0 -17
- package/dist/dtos/create-dashboard-question.dto.d.ts.map +0 -1
- package/dist/dtos/create-dashboard-question.dto.js +0 -105
- package/dist/dtos/create-dashboard-question.dto.js.map +0 -1
- package/dist/dtos/create-dashboard-variable.dto.d.ts +0 -19
- package/dist/dtos/create-dashboard-variable.dto.d.ts.map +0 -1
- package/dist/dtos/create-dashboard-variable.dto.js +0 -103
- package/dist/dtos/create-dashboard-variable.dto.js.map +0 -1
- package/dist/dtos/create-dashboard.dto.d.ts +0 -17
- package/dist/dtos/create-dashboard.dto.d.ts.map +0 -1
- package/dist/dtos/create-dashboard.dto.js +0 -102
- package/dist/dtos/create-dashboard.dto.js.map +0 -1
- package/dist/dtos/dashboard-variable-selection-dynamic-query.dto.d.ts +0 -8
- package/dist/dtos/dashboard-variable-selection-dynamic-query.dto.d.ts.map +0 -1
- package/dist/dtos/dashboard-variable-selection-dynamic-query.dto.js +0 -52
- package/dist/dtos/dashboard-variable-selection-dynamic-query.dto.js.map +0 -1
- package/dist/dtos/update-dashboard-layout.dto.d.ts +0 -8
- package/dist/dtos/update-dashboard-layout.dto.d.ts.map +0 -1
- package/dist/dtos/update-dashboard-layout.dto.js.map +0 -1
- package/dist/dtos/update-dashboard-question-sql-dataset-config.dto.d.ts +0 -13
- package/dist/dtos/update-dashboard-question-sql-dataset-config.dto.d.ts.map +0 -1
- package/dist/dtos/update-dashboard-question-sql-dataset-config.dto.js +0 -86
- package/dist/dtos/update-dashboard-question-sql-dataset-config.dto.js.map +0 -1
- package/dist/dtos/update-dashboard-question.dto.d.ts +0 -18
- package/dist/dtos/update-dashboard-question.dto.d.ts.map +0 -1
- package/dist/dtos/update-dashboard-question.dto.js +0 -112
- package/dist/dtos/update-dashboard-question.dto.js.map +0 -1
- package/dist/dtos/update-dashboard-variable.dto.d.ts +0 -16
- package/dist/dtos/update-dashboard-variable.dto.d.ts.map +0 -1
- package/dist/dtos/update-dashboard-variable.dto.js +0 -101
- package/dist/dtos/update-dashboard-variable.dto.js.map +0 -1
- package/dist/dtos/update-dashboard.dto.d.ts +0 -18
- package/dist/dtos/update-dashboard.dto.d.ts.map +0 -1
- package/dist/dtos/update-dashboard.dto.js +0 -108
- package/dist/dtos/update-dashboard.dto.js.map +0 -1
- package/dist/entities/dashboard-layout.entity.d.ts +0 -9
- package/dist/entities/dashboard-layout.entity.d.ts.map +0 -1
- package/dist/entities/dashboard-layout.entity.js +0 -41
- package/dist/entities/dashboard-layout.entity.js.map +0 -1
- package/dist/entities/dashboard-question-sql-dataset-config.entity.d.ts +0 -14
- package/dist/entities/dashboard-question-sql-dataset-config.entity.d.ts.map +0 -1
- package/dist/entities/dashboard-question-sql-dataset-config.entity.js +0 -66
- package/dist/entities/dashboard-question-sql-dataset-config.entity.js.map +0 -1
- package/dist/entities/dashboard-question.entity.d.ts +0 -17
- package/dist/entities/dashboard-question.entity.d.ts.map +0 -1
- package/dist/entities/dashboard-question.entity.js +0 -77
- package/dist/entities/dashboard-question.entity.js.map +0 -1
- package/dist/entities/dashboard-variable.entity.d.ts +0 -16
- package/dist/entities/dashboard-variable.entity.d.ts.map +0 -1
- package/dist/entities/dashboard-variable.entity.js +0 -79
- package/dist/entities/dashboard-variable.entity.js.map +0 -1
- package/dist/entities/dashboard.entity.d.ts +0 -16
- package/dist/entities/dashboard.entity.d.ts.map +0 -1
- package/dist/entities/dashboard.entity.js +0 -64
- package/dist/entities/dashboard.entity.js.map +0 -1
- package/dist/mappers/dashboard-mapper.d.ts +0 -6
- package/dist/mappers/dashboard-mapper.d.ts.map +0 -1
- package/dist/mappers/dashboard-mapper.js +0 -62
- package/dist/mappers/dashboard-mapper.js.map +0 -1
- package/dist/repository/dashboard-layout.repository.d.ts.map +0 -1
- package/dist/repository/dashboard-layout.repository.js +0 -34
- package/dist/repository/dashboard-layout.repository.js.map +0 -1
- package/dist/repository/dashboard-question-sql-dataset-config.repository.d.ts +0 -12
- package/dist/repository/dashboard-question-sql-dataset-config.repository.d.ts.map +0 -1
- package/dist/repository/dashboard-question-sql-dataset-config.repository.js.map +0 -1
- package/dist/repository/dashboard-question.repository.d.ts +0 -12
- package/dist/repository/dashboard-question.repository.d.ts.map +0 -1
- package/dist/repository/dashboard-question.repository.js +0 -34
- package/dist/repository/dashboard-question.repository.js.map +0 -1
- package/dist/repository/dashboard-variable.repository.d.ts +0 -12
- package/dist/repository/dashboard-variable.repository.d.ts.map +0 -1
- package/dist/repository/dashboard-variable.repository.js +0 -34
- package/dist/repository/dashboard-variable.repository.js.map +0 -1
- package/dist/repository/dashboard.repository.d.ts +0 -13
- package/dist/repository/dashboard.repository.d.ts.map +0 -1
- package/dist/repository/dashboard.repository.js +0 -104
- package/dist/repository/dashboard.repository.js.map +0 -1
- package/dist/services/dashboard-layout.service.d.ts +0 -20
- package/dist/services/dashboard-layout.service.d.ts.map +0 -1
- package/dist/services/dashboard-layout.service.js +0 -120
- package/dist/services/dashboard-layout.service.js.map +0 -1
- package/dist/services/dashboard-question-sql-dataset-config.service.d.ts +0 -12
- package/dist/services/dashboard-question-sql-dataset-config.service.d.ts.map +0 -1
- package/dist/services/dashboard-question-sql-dataset-config.service.js +0 -38
- package/dist/services/dashboard-question-sql-dataset-config.service.js.map +0 -1
- package/dist/services/dashboard-question.service.d.ts +0 -23
- package/dist/services/dashboard-question.service.d.ts.map +0 -1
- package/dist/services/dashboard-question.service.js +0 -135
- package/dist/services/dashboard-question.service.js.map +0 -1
- package/dist/services/dashboard-selection-providers/dashboard-variable-sql-dynamic-provider.service.d.ts +0 -12
- package/dist/services/dashboard-selection-providers/dashboard-variable-sql-dynamic-provider.service.d.ts.map +0 -1
- package/dist/services/dashboard-selection-providers/dashboard-variable-sql-dynamic-provider.service.js +0 -55
- package/dist/services/dashboard-selection-providers/dashboard-variable-sql-dynamic-provider.service.js.map +0 -1
- package/dist/services/dashboard-selection-providers/dashboard-variable-test-dynamic-provider.service.d.ts +0 -11
- package/dist/services/dashboard-selection-providers/dashboard-variable-test-dynamic-provider.service.d.ts.map +0 -1
- package/dist/services/dashboard-selection-providers/dashboard-variable-test-dynamic-provider.service.js +0 -45
- package/dist/services/dashboard-selection-providers/dashboard-variable-test-dynamic-provider.service.js.map +0 -1
- package/dist/services/dashboard-variable.service.d.ts +0 -13
- package/dist/services/dashboard-variable.service.d.ts.map +0 -1
- package/dist/services/dashboard-variable.service.js.map +0 -1
- package/dist/services/dashboard.service.d.ts +0 -29
- package/dist/services/dashboard.service.d.ts.map +0 -1
- package/dist/services/dashboard.service.js +0 -171
- package/dist/services/dashboard.service.js.map +0 -1
- package/dist/services/genai/mcp-handlers/solid-add-question-to-dashboard-mcp-handler.service.d.ts +0 -12
- package/dist/services/genai/mcp-handlers/solid-add-question-to-dashboard-mcp-handler.service.d.ts.map +0 -1
- package/dist/services/genai/mcp-handlers/solid-add-question-to-dashboard-mcp-handler.service.js +0 -41
- package/dist/services/genai/mcp-handlers/solid-add-question-to-dashboard-mcp-handler.service.js.map +0 -1
- package/dist/services/genai/mcp-handlers/solid-add-variable-to-dashboard-mcp-handler.service.d.ts +0 -12
- package/dist/services/genai/mcp-handlers/solid-add-variable-to-dashboard-mcp-handler.service.d.ts.map +0 -1
- package/dist/services/genai/mcp-handlers/solid-add-variable-to-dashboard-mcp-handler.service.js +0 -42
- package/dist/services/genai/mcp-handlers/solid-add-variable-to-dashboard-mcp-handler.service.js.map +0 -1
- package/dist/services/genai/mcp-handlers/solid-create-dashboard-mcp-handler.service.d.ts +0 -25
- package/dist/services/genai/mcp-handlers/solid-create-dashboard-mcp-handler.service.d.ts.map +0 -1
- package/dist/services/genai/mcp-handlers/solid-create-dashboard-mcp-handler.service.js +0 -116
- package/dist/services/genai/mcp-handlers/solid-create-dashboard-mcp-handler.service.js.map +0 -1
- package/dist/services/genai/mcp-handlers/solid-create-dashboard-question-mcp-handler.service.d.ts +0 -12
- package/dist/services/genai/mcp-handlers/solid-create-dashboard-question-mcp-handler.service.d.ts.map +0 -1
- package/dist/services/genai/mcp-handlers/solid-create-dashboard-question-mcp-handler.service.js +0 -37
- package/dist/services/genai/mcp-handlers/solid-create-dashboard-question-mcp-handler.service.js.map +0 -1
- package/dist/services/genai/mcp-handlers/solid-create-dashboard-question-sql-dataset-config-mcp-handler.service.d.ts +0 -12
- package/dist/services/genai/mcp-handlers/solid-create-dashboard-question-sql-dataset-config-mcp-handler.service.d.ts.map +0 -1
- package/dist/services/genai/mcp-handlers/solid-create-dashboard-question-sql-dataset-config-mcp-handler.service.js +0 -38
- package/dist/services/genai/mcp-handlers/solid-create-dashboard-question-sql-dataset-config-mcp-handler.service.js.map +0 -1
- package/dist/services/genai/mcp-handlers/solid-create-dashboard-widget-mcp-handler.service.d.ts +0 -12
- package/dist/services/genai/mcp-handlers/solid-create-dashboard-widget-mcp-handler.service.d.ts.map +0 -1
- package/dist/services/genai/mcp-handlers/solid-create-dashboard-widget-mcp-handler.service.js +0 -38
- package/dist/services/genai/mcp-handlers/solid-create-dashboard-widget-mcp-handler.service.js.map +0 -1
- package/dist/services/question-data-providers/chartjs-sql-data-provider.service.d.ts +0 -34
- package/dist/services/question-data-providers/chartjs-sql-data-provider.service.d.ts.map +0 -1
- package/dist/services/question-data-providers/chartjs-sql-data-provider.service.js +0 -90
- package/dist/services/question-data-providers/chartjs-sql-data-provider.service.js.map +0 -1
- package/dist/services/question-data-providers/helpers.d.ts +0 -7
- package/dist/services/question-data-providers/helpers.d.ts.map +0 -1
- package/dist/services/question-data-providers/helpers.js +0 -25
- package/dist/services/question-data-providers/helpers.js.map +0 -1
- package/dist/services/question-data-providers/prime-react-datatable-sql-data-provider.service.d.ts +0 -14
- package/dist/services/question-data-providers/prime-react-datatable-sql-data-provider.service.d.ts.map +0 -1
- package/dist/services/question-data-providers/prime-react-datatable-sql-data-provider.service.js +0 -71
- package/dist/services/question-data-providers/prime-react-datatable-sql-data-provider.service.js.map +0 -1
- package/dist/services/question-data-providers/prime-react-meter-group-sql-data-provider.service.d.ts +0 -16
- package/dist/services/question-data-providers/prime-react-meter-group-sql-data-provider.service.d.ts.map +0 -1
- package/dist/services/question-data-providers/prime-react-meter-group-sql-data-provider.service.js +0 -93
- package/dist/services/question-data-providers/prime-react-meter-group-sql-data-provider.service.js.map +0 -1
- package/dist/services/selection-providers/list-of-dashboard-question-providers-selection-provider.service.d.ts +0 -11
- package/dist/services/selection-providers/list-of-dashboard-question-providers-selection-provider.service.d.ts.map +0 -1
- package/dist/services/selection-providers/list-of-dashboard-question-providers-selection-provider.service.js +0 -49
- package/dist/services/selection-providers/list-of-dashboard-question-providers-selection-provider.service.js.map +0 -1
- package/dist/services/selection-providers/list-of-dashboard-variable-providers-selection-provider.service.d.ts +0 -11
- package/dist/services/selection-providers/list-of-dashboard-variable-providers-selection-provider.service.d.ts.map +0 -1
- package/dist/services/selection-providers/list-of-dashboard-variable-providers-selection-provider.service.js +0 -47
- package/dist/services/selection-providers/list-of-dashboard-variable-providers-selection-provider.service.js.map +0 -1
- package/dist/services/sql-expression-resolver.service.d.ts +0 -12
- package/dist/services/sql-expression-resolver.service.d.ts.map +0 -1
- package/dist/services/sql-expression-resolver.service.js +0 -121
- package/dist/services/sql-expression-resolver.service.js.map +0 -1
- package/dist/subscribers/dashboard-question-sql-dataset-config.subscriber.d.ts +0 -16
- package/dist/subscribers/dashboard-question-sql-dataset-config.subscriber.d.ts.map +0 -1
- package/dist/subscribers/dashboard-question-sql-dataset-config.subscriber.js +0 -72
- package/dist/subscribers/dashboard-question-sql-dataset-config.subscriber.js.map +0 -1
- package/dist/subscribers/dashboard-question.subscriber.d.ts +0 -16
- package/dist/subscribers/dashboard-question.subscriber.d.ts.map +0 -1
- package/dist/subscribers/dashboard-question.subscriber.js +0 -72
- package/dist/subscribers/dashboard-question.subscriber.js.map +0 -1
- package/dist/subscribers/dashboard-variable.subscriber.d.ts +0 -16
- package/dist/subscribers/dashboard-variable.subscriber.d.ts.map +0 -1
- package/dist/subscribers/dashboard-variable.subscriber.js +0 -72
- package/dist/subscribers/dashboard-variable.subscriber.js.map +0 -1
- package/dist/subscribers/dashboard.subscriber.d.ts +0 -16
- package/dist/subscribers/dashboard.subscriber.d.ts.map +0 -1
- package/dist/subscribers/dashboard.subscriber.js +0 -71
- package/dist/subscribers/dashboard.subscriber.js.map +0 -1
- package/src/controllers/dashboard-layout.controller.ts +0 -106
- package/src/controllers/dashboard-question-sql-dataset-config.controller.ts +0 -93
- package/src/controllers/dashboard-question.controller.ts +0 -104
- package/src/decorators/dashboard-question-data-provider.decorator.ts +0 -7
- package/src/decorators/dashboard-selection-provider.decorator.ts +0 -7
- package/src/dtos/create-dashboard-layout.dto.ts +0 -31
- package/src/dtos/create-dashboard-question-sql-dataset-config.dto.ts +0 -42
- package/src/dtos/create-dashboard-question.dto.ts +0 -62
- package/src/dtos/create-dashboard-variable.dto.ts +0 -60
- package/src/dtos/create-dashboard.dto.ts +0 -61
- package/src/dtos/dashboard-variable-selection-dynamic-query.dto.ts +0 -29
- package/src/dtos/update-dashboard-layout.dto.ts +0 -30
- package/src/dtos/update-dashboard-question-sql-dataset-config.dto.ts +0 -49
- package/src/dtos/update-dashboard-question.dto.ts +0 -67
- package/src/dtos/update-dashboard-variable.dto.ts +0 -58
- package/src/dtos/update-dashboard.dto.ts +0 -65
- package/src/entities/dashboard-layout.entity.ts +0 -18
- package/src/entities/dashboard-question-sql-dataset-config.entity.ts +0 -37
- package/src/entities/dashboard-question.entity.ts +0 -46
- package/src/entities/dashboard-variable.entity.ts +0 -44
- package/src/entities/dashboard.entity.ts +0 -36
- package/src/mappers/dashboard-mapper.ts +0 -53
- package/src/repository/dashboard-layout.repository.ts +0 -17
- package/src/repository/dashboard-question-sql-dataset-config.repository.ts +0 -17
- package/src/repository/dashboard-question.repository.ts +0 -17
- package/src/repository/dashboard-variable.repository.ts +0 -17
- package/src/repository/dashboard.repository.ts +0 -101
- package/src/services/dashboard-layout.service.ts +0 -111
- package/src/services/dashboard-question-sql-dataset-config.service.ts +0 -25
- package/src/services/dashboard-question.service.ts +0 -150
- package/src/services/dashboard-selection-providers/dashboard-variable-sql-dynamic-provider.service.ts +0 -56
- package/src/services/dashboard-selection-providers/dashboard-variable-test-dynamic-provider.service.ts +0 -37
- package/src/services/dashboard-variable.service.ts +0 -27
- package/src/services/dashboard.service.ts +0 -148
- package/src/services/genai/mcp-handlers/solid-add-question-to-dashboard-mcp-handler.service.ts +0 -43
- package/src/services/genai/mcp-handlers/solid-add-variable-to-dashboard-mcp-handler.service.ts +0 -44
- package/src/services/genai/mcp-handlers/solid-create-dashboard-mcp-handler.service.ts +0 -114
- package/src/services/genai/mcp-handlers/solid-create-dashboard-question-mcp-handler.service.ts +0 -38
- package/src/services/genai/mcp-handlers/solid-create-dashboard-question-sql-dataset-config-mcp-handler.service.ts +0 -40
- package/src/services/genai/mcp-handlers/solid-create-dashboard-widget-mcp-handler.service.ts +0 -39
- package/src/services/question-data-providers/chartjs-sql-data-provider.service.ts +0 -121
- package/src/services/question-data-providers/helpers.ts +0 -30
- package/src/services/question-data-providers/prime-react-datatable-sql-data-provider.service.ts +0 -74
- package/src/services/question-data-providers/prime-react-meter-group-sql-data-provider.service.ts +0 -115
- package/src/services/selection-providers/list-of-dashboard-question-providers-selection-provider.service.ts +0 -44
- package/src/services/selection-providers/list-of-dashboard-variable-providers-selection-provider.service.ts +0 -41
- package/src/services/sql-expression-resolver.service.ts +0 -140
- package/src/subscribers/dashboard-question-sql-dataset-config.subscriber.ts +0 -61
- package/src/subscribers/dashboard-question.subscriber.ts +0 -62
- package/src/subscribers/dashboard-variable.subscriber.ts +0 -63
- package/src/subscribers/dashboard.subscriber.ts +0 -62
package/src/services/question-data-providers/prime-react-datatable-sql-data-provider.service.ts
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { Injectable } from "@nestjs/common";
|
|
2
|
-
import { DashboardQuestionDataProvider } from "src/decorators/dashboard-question-data-provider.decorator";
|
|
3
|
-
import { DashboardQuestion } from "src/entities/dashboard-question.entity";
|
|
4
|
-
import { IDashboardQuestionDataProvider, QuestionSqlDataProviderContext } from "src/interfaces";
|
|
5
|
-
import { EntityManager } from "typeorm";
|
|
6
|
-
import { SqlExpressionResolverService } from "../sql-expression-resolver.service";
|
|
7
|
-
import { Logger } from '@nestjs/common';
|
|
8
|
-
import { SqlExpression } from "./chartjs-sql-data-provider.service";
|
|
9
|
-
import { getKpi } from "./helpers";
|
|
10
|
-
|
|
11
|
-
@DashboardQuestionDataProvider()
|
|
12
|
-
@Injectable()
|
|
13
|
-
export class PrimeReactDatatableSqlDataProvider implements IDashboardQuestionDataProvider<QuestionSqlDataProviderContext, any> {
|
|
14
|
-
private readonly logger = new Logger(PrimeReactDatatableSqlDataProvider.name);
|
|
15
|
-
|
|
16
|
-
constructor(private readonly entityManager: EntityManager, private readonly sqlExpressionResolver: SqlExpressionResolverService) { }
|
|
17
|
-
|
|
18
|
-
help(): string {
|
|
19
|
-
return "Provides data for dashboard questions using a SQL dataset configuration. Configure your SQL dataset in the admin panel, then reference it in your dashboard question to fetch data.";
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
name(): string {
|
|
23
|
-
return "PrimeReactDatatableSqlDataProvider";
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
async getData(question: DashboardQuestion, context?: QuestionSqlDataProviderContext): Promise<any> {
|
|
27
|
-
const expressions: SqlExpression[] = context?.expressions || [];
|
|
28
|
-
|
|
29
|
-
// TODO: put some validation to check if the results of each SQL in each dataset returns the same number of rows
|
|
30
|
-
|
|
31
|
-
// Check the expected response for prime react data tables to understand what is going on here...
|
|
32
|
-
|
|
33
|
-
const kpi: string = await getKpi(question, expressions, this.entityManager, this.sqlExpressionResolver);
|
|
34
|
-
// TODO: Load the set of labels by using a separate field on the question entity.
|
|
35
|
-
const labelSql = question.labelSql;
|
|
36
|
-
const labelResults = await this.entityManager.query(labelSql);
|
|
37
|
-
const columns = [];
|
|
38
|
-
for (let i = 0; i < labelResults.length; i++) {
|
|
39
|
-
const labelResult = labelResults[i];
|
|
40
|
-
columns.push({
|
|
41
|
-
field: labelResult['field'],
|
|
42
|
-
header: labelResult['header'],
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// Load the chart options as a JSON
|
|
47
|
-
// const chartOptions = JSON.parse(question.barChartLabelOptions || '{}');
|
|
48
|
-
|
|
49
|
-
const values = []
|
|
50
|
-
|
|
51
|
-
// For meter group we can assume that we only have one sql dataset config.
|
|
52
|
-
const questionSqlDatasetConfig = question.questionSqlDatasetConfigs[0];
|
|
53
|
-
|
|
54
|
-
const sql = questionSqlDatasetConfig.sql;
|
|
55
|
-
if (!sql) {
|
|
56
|
-
throw new Error(`SQL dataset ${questionSqlDatasetConfig.datasetName} configuration does not contain a valid SQL query.`);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const sqlReplacementResult = this.sqlExpressionResolver.resolveSqlWithExpressions(sql, expressions || []);
|
|
60
|
-
this.logger.debug(`Final Sql query for dataset [${questionSqlDatasetConfig.datasetName}] is query=[${sqlReplacementResult.rawSql}]`);
|
|
61
|
-
this.logger.debug(`Final Sql query for dataset [${questionSqlDatasetConfig.datasetName}] is parameters=[${JSON.stringify(sqlReplacementResult.parameters)}]`);
|
|
62
|
-
const results = await this.entityManager.query(sqlReplacementResult.rawSql, sqlReplacementResult.parameters);
|
|
63
|
-
|
|
64
|
-
return {
|
|
65
|
-
kpi,
|
|
66
|
-
visualisedAs: question.visualisedAs,
|
|
67
|
-
visualizationData: {
|
|
68
|
-
columns,
|
|
69
|
-
rows: results,
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
}
|
package/src/services/question-data-providers/prime-react-meter-group-sql-data-provider.service.ts
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { Injectable } from "@nestjs/common";
|
|
2
|
-
import { DashboardQuestionDataProvider } from "src/decorators/dashboard-question-data-provider.decorator";
|
|
3
|
-
import { DashboardQuestion } from "src/entities/dashboard-question.entity";
|
|
4
|
-
import { IDashboardQuestionDataProvider, QuestionSqlDataProviderContext } from "src/interfaces";
|
|
5
|
-
import { EntityManager } from "typeorm";
|
|
6
|
-
import { SqlExpressionResolverService } from "../sql-expression-resolver.service";
|
|
7
|
-
import { Logger } from '@nestjs/common';
|
|
8
|
-
import { SqlExpression } from "./chartjs-sql-data-provider.service";
|
|
9
|
-
import { getKpi } from "./helpers";
|
|
10
|
-
|
|
11
|
-
@DashboardQuestionDataProvider()
|
|
12
|
-
@Injectable()
|
|
13
|
-
export class PrimeReactMeterGroupSqlDataProvider implements IDashboardQuestionDataProvider<QuestionSqlDataProviderContext, any> {
|
|
14
|
-
private readonly logger = new Logger(PrimeReactMeterGroupSqlDataProvider.name);
|
|
15
|
-
|
|
16
|
-
constructor(private readonly entityManager: EntityManager, private readonly sqlExpressionResolver: SqlExpressionResolverService) { }
|
|
17
|
-
|
|
18
|
-
help(): string {
|
|
19
|
-
return "Provides data for dashboard questions using a SQL dataset configuration. Configure your SQL dataset in the admin panel, then reference it in your dashboard question to fetch data.";
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
name(): string {
|
|
23
|
-
return "PrimeReactMeterGroupSqlDataProvider";
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
hslToHex(h: number, s: number, l: number): string {
|
|
27
|
-
l /= 100;
|
|
28
|
-
s /= 100;
|
|
29
|
-
|
|
30
|
-
const k = (n: number) => (n + h / 30) % 12;
|
|
31
|
-
const a = s * Math.min(l, 1 - l);
|
|
32
|
-
const f = (n: number) =>
|
|
33
|
-
Math.round(255 * (l - a * Math.max(-1, Math.min(k(n) - 3, Math.min(9 - k(n), 1)))));
|
|
34
|
-
|
|
35
|
-
return `#${f(0).toString(16).padStart(2, '0')}${f(8).toString(16).padStart(2, '0')}${f(4)
|
|
36
|
-
.toString(16)
|
|
37
|
-
.padStart(2, '0')}`;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
generateDistinctColors(count: number): string[] {
|
|
41
|
-
const colors: string[] = [];
|
|
42
|
-
|
|
43
|
-
const hueStep = 360 / count;
|
|
44
|
-
const saturation = 65; // keep it vibrant
|
|
45
|
-
const lightness = 55; // balanced for both light/dark themes
|
|
46
|
-
|
|
47
|
-
for (let i = 0; i < count; i++) {
|
|
48
|
-
const hue = Math.round(i * hueStep);
|
|
49
|
-
colors.push(this.hslToHex(hue, saturation, lightness));
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return colors;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
async getData(question: DashboardQuestion, context?: QuestionSqlDataProviderContext): Promise<any> {
|
|
56
|
-
const expressions: SqlExpression[] = context?.expressions || [];
|
|
57
|
-
|
|
58
|
-
// TODO: put some validation to check if the results of each SQL in each dataset returns the same number of rows
|
|
59
|
-
|
|
60
|
-
// This is what we have to return.
|
|
61
|
-
// const values = [
|
|
62
|
-
// { label: 'Apps', color: '#34d399', value: 16 },
|
|
63
|
-
// { label: 'Messages', color: '#fbbf24', value: 8 },
|
|
64
|
-
// { label: 'Media', color: '#60a5fa', value: 24 },
|
|
65
|
-
// { label: 'System', color: '#c084fc', value: 10 }
|
|
66
|
-
// ];
|
|
67
|
-
|
|
68
|
-
// TODO: Load the set of labels by using a separate field on the question entity.
|
|
69
|
-
|
|
70
|
-
const kpi: string = await getKpi(question, expressions, this.entityManager, this.sqlExpressionResolver);
|
|
71
|
-
|
|
72
|
-
// Load the chart options as a JSON
|
|
73
|
-
const chartOptions = JSON.parse(question.chartOptions || '{}');
|
|
74
|
-
|
|
75
|
-
const values = []
|
|
76
|
-
|
|
77
|
-
// For meter group we can assume that we only have one sql dataset config.
|
|
78
|
-
const questionSqlDatasetConfig = question.questionSqlDatasetConfigs[0];
|
|
79
|
-
|
|
80
|
-
const sql = questionSqlDatasetConfig.sql;
|
|
81
|
-
if (!sql) {
|
|
82
|
-
throw new Error(`SQL dataset ${questionSqlDatasetConfig.datasetName} configuration does not contain a valid SQL query.`);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const sqlReplacementResult = this.sqlExpressionResolver.resolveSqlWithExpressions(sql, expressions || []);
|
|
86
|
-
this.logger.debug(`Final Sql query for dataset [${questionSqlDatasetConfig.datasetName}] is query=[${sqlReplacementResult.rawSql}]`);
|
|
87
|
-
this.logger.debug(`Final Sql query for dataset [${questionSqlDatasetConfig.datasetName}] is parameters=[${JSON.stringify(sqlReplacementResult.parameters)}]`);
|
|
88
|
-
const results = await this.entityManager.query(sqlReplacementResult.rawSql, sqlReplacementResult.parameters);
|
|
89
|
-
|
|
90
|
-
const colors = this.generateDistinctColors(results.length);
|
|
91
|
-
|
|
92
|
-
// Also for each data set we create the dataset object as is expected by ChartJs.
|
|
93
|
-
for (let i = 0; i < results.length; i++) {
|
|
94
|
-
const result = results[i];
|
|
95
|
-
|
|
96
|
-
const colorFromChartOptions = chartOptions?.colors?.[result[questionSqlDatasetConfig.labelColumnName]];
|
|
97
|
-
const color = typeof colorFromChartOptions === 'string' ? colorFromChartOptions : colors[i];
|
|
98
|
-
|
|
99
|
-
values.push({
|
|
100
|
-
label: result[questionSqlDatasetConfig.labelColumnName],
|
|
101
|
-
color: color,
|
|
102
|
-
value: result[questionSqlDatasetConfig.valueColumnName]
|
|
103
|
-
})
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return {
|
|
107
|
-
kpi,
|
|
108
|
-
visualizedAs: question.visualisedAs,
|
|
109
|
-
visualizationData: {
|
|
110
|
-
dataset: values
|
|
111
|
-
},
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { Injectable } from "@nestjs/common";
|
|
2
|
-
import { SelectionProvider } from "src/decorators/selection-provider.decorator";
|
|
3
|
-
import { SolidRegistry } from "src/helpers/solid-registry";
|
|
4
|
-
import { IDashboardQuestionDataProvider, IDashboardVariableSelectionProvider, ISelectionProvider, ISelectionProviderContext, ISelectionProviderValues } from "../../interfaces";
|
|
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";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
@SelectionProvider()
|
|
10
|
-
@Injectable()
|
|
11
|
-
export class ListOfDashboardQuestionProvidersSelectionProvider implements ISelectionProvider<ISelectionProviderContext> {
|
|
12
|
-
|
|
13
|
-
constructor(
|
|
14
|
-
private readonly solidRegistry: SolidRegistry,
|
|
15
|
-
) {
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
help(): string {
|
|
19
|
-
return "# Allows one to dynamically fetch all the dashboard providers that are registered in the system. ";
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
name(): string {
|
|
23
|
-
return 'ListOfDashboardQuestionProvidersSelectionProvider';
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
async value(optionValue: string, ctxt: ISelectionProviderContext): Promise<ISelectionProviderValues | any> {
|
|
27
|
-
const dashboardSelectionProvider: IDashboardQuestionDataProvider<any, any> | undefined = this.solidRegistry.getDashboardQuestionDataProviderInstance(optionValue);
|
|
28
|
-
if (!dashboardSelectionProvider) {
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return { label: dashboardSelectionProvider.name(), value: dashboardSelectionProvider.name() };
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
async values(query: string, ctxt: ISelectionProviderContext): Promise<readonly ISelectionProviderValues[]> {
|
|
36
|
-
const dashboardSelectionProviders = this.solidRegistry.getDashboardQuestionDataProviders()
|
|
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)
|
|
38
|
-
return dashboardSelectionProviders
|
|
39
|
-
.filter(provider => !INBUILT_SQL_DATA_PROVIDERS.includes(provider.name()))
|
|
40
|
-
.map(i => {
|
|
41
|
-
return { label: i.name, value: i.name };
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { Injectable } from "@nestjs/common";
|
|
2
|
-
import { SelectionProvider } from "src/decorators/selection-provider.decorator";
|
|
3
|
-
import { SolidRegistry } from "src/helpers/solid-registry";
|
|
4
|
-
import { IDashboardVariableSelectionProvider, ISelectionProvider, ISelectionProviderContext, ISelectionProviderValues } from "../../interfaces";
|
|
5
|
-
import { SQL_DYNAMIC_PROVIDER_NAME } from "../dashboard.service";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
@SelectionProvider()
|
|
9
|
-
@Injectable()
|
|
10
|
-
export class ListOfDashboardVariableProvidersSelectionProvider implements ISelectionProvider<ISelectionProviderContext> {
|
|
11
|
-
|
|
12
|
-
constructor(
|
|
13
|
-
private readonly solidRegistry: SolidRegistry,
|
|
14
|
-
) {
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
help(): string {
|
|
18
|
-
return "# Allows one to dynamically fetch all the dashboard providers that are registered in the system. ";
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
name(): string {
|
|
22
|
-
return 'ListOfDashboardVariableProvidersSelectionProvider';
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
async value(optionValue: string, ctxt: ISelectionProviderContext): Promise<ISelectionProviderValues | any> {
|
|
26
|
-
const dashboardSelectionProvider: IDashboardVariableSelectionProvider<ISelectionProviderContext> | undefined = this.solidRegistry.getDashboardVariableSelectionProviderInstance(optionValue);
|
|
27
|
-
if (!dashboardSelectionProvider) {
|
|
28
|
-
return null;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return { label: dashboardSelectionProvider.name(), value: dashboardSelectionProvider.name() };
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
async values(query: string, ctxt: ISelectionProviderContext): Promise<readonly ISelectionProviderValues[]> {
|
|
35
|
-
const dashboardSelectionProviders = this.solidRegistry.getDashboardVariableSelectionProviders()
|
|
36
|
-
//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.filter(i => (i.name !== SQL_DYNAMIC_PROVIDER_NAME)).map(i => {
|
|
38
|
-
return { label: i.name, value: i.name };
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
}
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import { Injectable } from "@nestjs/common";
|
|
2
|
-
import { SqlExpression, SqlExpressionOperator } from "./question-data-providers/chartjs-sql-data-provider.service";
|
|
3
|
-
import { RequestContextService } from "./request-context.service";
|
|
4
|
-
import { ERROR_MESSAGES } from "src/constants/error-messages";
|
|
5
|
-
|
|
6
|
-
export interface SqlReplacementResult {
|
|
7
|
-
rawSql: string;
|
|
8
|
-
parameters: any[]; // Positional parameters
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
@Injectable()
|
|
12
|
-
export class SqlExpressionResolverService {
|
|
13
|
-
constructor(private readonly requestContextService: RequestContextService) { }
|
|
14
|
-
resolveSqlWithExpressions(sql: string, expressions: SqlExpression[]): SqlReplacementResult {
|
|
15
|
-
const variableToColumnMap: Record<string, string> = {};
|
|
16
|
-
const variablePattern = /{{\s*(\w+)\s*\[\s*([\w.]+)\s*\]\s*}}/g;
|
|
17
|
-
|
|
18
|
-
let paramIndex = 1;
|
|
19
|
-
const parameters: any[] = [];
|
|
20
|
-
|
|
21
|
-
// Handle sql expression tokens like {{$activeUserId}} in the SQL string
|
|
22
|
-
if (sql.includes('{{$activeUserId}}')) {
|
|
23
|
-
const activeUser = this.requestContextService.getActiveUser();
|
|
24
|
-
if (activeUser && activeUser.sub) {
|
|
25
|
-
// Replace custom placeholder with parameter placeholder ($1)
|
|
26
|
-
sql = sql.replace(/\{\{\$activeUserId\}\}/g, `$${paramIndex++}`);
|
|
27
|
-
// Add the active user ID to parameters
|
|
28
|
-
parameters.push(activeUser.sub);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// --- Pass 1: extract variable -> column mappings ---
|
|
33
|
-
let simplifiedSql = sql.replace(variablePattern, (_, variableName, columnName) => {
|
|
34
|
-
variableToColumnMap[variableName] = columnName;
|
|
35
|
-
return `{{${variableName}}}`;
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
// --- Pass 2: Replace each variable with positional fragment ---
|
|
39
|
-
|
|
40
|
-
for (const expr of expressions) {
|
|
41
|
-
const column = variableToColumnMap[expr.variableName];
|
|
42
|
-
if (!column) continue;
|
|
43
|
-
|
|
44
|
-
let sqlFragment = '';
|
|
45
|
-
const placeholder = `{{${expr.variableName}}}`;
|
|
46
|
-
|
|
47
|
-
switch (expr.operator) {
|
|
48
|
-
case SqlExpressionOperator.EQUALS:
|
|
49
|
-
sqlFragment = `${column} = $${paramIndex++}`;
|
|
50
|
-
parameters.push(expr.value[0]);
|
|
51
|
-
break;
|
|
52
|
-
|
|
53
|
-
case SqlExpressionOperator.NOT_EQUALS:
|
|
54
|
-
sqlFragment = `${column} != $${paramIndex++}`;
|
|
55
|
-
parameters.push(expr.value[0]);
|
|
56
|
-
break;
|
|
57
|
-
|
|
58
|
-
case SqlExpressionOperator.CONTAINS:
|
|
59
|
-
sqlFragment = `${column} LIKE $${paramIndex++}`;
|
|
60
|
-
parameters.push(`%${expr.value[0]}%`);
|
|
61
|
-
break;
|
|
62
|
-
|
|
63
|
-
case SqlExpressionOperator.NOT_CONTAINS:
|
|
64
|
-
sqlFragment = `${column} NOT LIKE $${paramIndex++}`;
|
|
65
|
-
parameters.push(`%${expr.value[0]}%`);
|
|
66
|
-
break;
|
|
67
|
-
|
|
68
|
-
case SqlExpressionOperator.STARTS_WITH:
|
|
69
|
-
sqlFragment = `${column} LIKE $${paramIndex++}`;
|
|
70
|
-
parameters.push(`${expr.value[0]}%`);
|
|
71
|
-
break;
|
|
72
|
-
|
|
73
|
-
case SqlExpressionOperator.ENDS_WITH:
|
|
74
|
-
sqlFragment = `${column} LIKE $${paramIndex++}`;
|
|
75
|
-
parameters.push(`%${expr.value[0]}`);
|
|
76
|
-
break;
|
|
77
|
-
|
|
78
|
-
case SqlExpressionOperator.IN:
|
|
79
|
-
const inParams = expr.value.map(val => {
|
|
80
|
-
parameters.push(val);
|
|
81
|
-
return `$${paramIndex++}`;
|
|
82
|
-
});
|
|
83
|
-
sqlFragment = `${column} IN (${inParams.join(", ")})`;
|
|
84
|
-
break;
|
|
85
|
-
|
|
86
|
-
case SqlExpressionOperator.NOT_IN:
|
|
87
|
-
const notInParams = expr.value.map(val => {
|
|
88
|
-
parameters.push(val);
|
|
89
|
-
return `$${paramIndex++}`;
|
|
90
|
-
});
|
|
91
|
-
sqlFragment = `${column} NOT IN (${notInParams.join(", ")})`;
|
|
92
|
-
break;
|
|
93
|
-
|
|
94
|
-
case SqlExpressionOperator.BETWEEN:
|
|
95
|
-
sqlFragment = `${column} BETWEEN $${paramIndex} AND $${paramIndex + 1}`;
|
|
96
|
-
parameters.push(expr.value[0], expr.value[1]);
|
|
97
|
-
paramIndex += 2;
|
|
98
|
-
break;
|
|
99
|
-
|
|
100
|
-
case SqlExpressionOperator.LT:
|
|
101
|
-
sqlFragment = `${column} < $${paramIndex++}`;
|
|
102
|
-
parameters.push(expr.value[0]);
|
|
103
|
-
break;
|
|
104
|
-
|
|
105
|
-
case SqlExpressionOperator.LTE:
|
|
106
|
-
sqlFragment = `${column} <= $${paramIndex++}`;
|
|
107
|
-
parameters.push(expr.value[0]);
|
|
108
|
-
break;
|
|
109
|
-
|
|
110
|
-
case SqlExpressionOperator.GT:
|
|
111
|
-
sqlFragment = `${column} > $${paramIndex++}`;
|
|
112
|
-
parameters.push(expr.value[0]);
|
|
113
|
-
break;
|
|
114
|
-
|
|
115
|
-
case SqlExpressionOperator.GTE:
|
|
116
|
-
sqlFragment = `${column} >= $${paramIndex++}`;
|
|
117
|
-
parameters.push(expr.value[0]);
|
|
118
|
-
break;
|
|
119
|
-
|
|
120
|
-
default:
|
|
121
|
-
throw new Error(ERROR_MESSAGES.UNSUPPORTED_SQL_OPERATOR(expr.operator));
|
|
122
|
-
}
|
|
123
|
-
simplifiedSql = simplifiedSql.replace(placeholder, sqlFragment);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
// --- Final cleanup: remove any remaining placeholders ---
|
|
127
|
-
simplifiedSql = simplifiedSql.replace(/{{\s*\w+\s*}}/g, '');
|
|
128
|
-
|
|
129
|
-
// Remove dangling where clause if no expressions were applied
|
|
130
|
-
simplifiedSql = simplifiedSql.replace(/\bwhere\b\s*$/i, '').trim();
|
|
131
|
-
|
|
132
|
-
// Need to handle scenarios of complex expression i.e with and / or clauses. probably need to have this logic in the sql expression object itself
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
return {
|
|
136
|
-
rawSql: simplifiedSql,
|
|
137
|
-
parameters
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { Injectable, Logger } from "@nestjs/common";
|
|
2
|
-
import { InjectDataSource } from "@nestjs/typeorm";
|
|
3
|
-
import { DashboardQuestionSqlDatasetConfig } from "src/entities/dashboard-question-sql-dataset-config.entity";
|
|
4
|
-
import { DashboardQuestion } from "src/entities/dashboard-question.entity";
|
|
5
|
-
import { ModuleMetadataHelperService } from "src/helpers/module-metadata-helper.service";
|
|
6
|
-
import { DashboardService } from "src/services/dashboard.service";
|
|
7
|
-
import { DataSource, EntityManager, EntitySubscriberInterface, InsertEvent, UpdateEvent } from "typeorm";
|
|
8
|
-
|
|
9
|
-
@Injectable()
|
|
10
|
-
export class DashboardQuestionSqlDatasetConfigSubscriber implements EntitySubscriberInterface<DashboardQuestionSqlDatasetConfig> {
|
|
11
|
-
private readonly logger = new Logger(this.constructor.name);
|
|
12
|
-
constructor(
|
|
13
|
-
@InjectDataSource()
|
|
14
|
-
private readonly dataSource: DataSource,
|
|
15
|
-
readonly moduleMetadataHelperService: ModuleMetadataHelperService,
|
|
16
|
-
readonly dashboardService: DashboardService, // Assuming you have a DashboardService for custom queries
|
|
17
|
-
) {
|
|
18
|
-
this.dataSource.subscribers.push(this);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
listenTo() {
|
|
22
|
-
return DashboardQuestionSqlDatasetConfig;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
async afterInsert(event: InsertEvent<DashboardQuestionSqlDatasetConfig>) {
|
|
26
|
-
const question = event.entity.question;
|
|
27
|
-
if (!question) {
|
|
28
|
-
this.logger.debug('No question found in the QuestionSqlDatasetConfigSubscriber afterInsert method');
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
await this.saveQuestionToConfig(question, event.queryRunner.manager);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
async afterUpdate(event: UpdateEvent<DashboardQuestionSqlDatasetConfig>) {
|
|
35
|
-
const question = event.databaseEntity.question;
|
|
36
|
-
if (!question) {
|
|
37
|
-
this.logger.debug('No question found in the QuestionSqlDatasetConfigSubscriber afterUpdate method');
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
await this.saveQuestionToConfig(question, event.queryRunner.manager);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
private async saveQuestionToConfig(question: DashboardQuestion, entityManager: EntityManager): Promise<void> {
|
|
44
|
-
// Populate the dashboard for the question
|
|
45
|
-
const populatedQuestion = await entityManager.findOne(DashboardQuestion, {
|
|
46
|
-
where: {
|
|
47
|
-
id: question.id,
|
|
48
|
-
},
|
|
49
|
-
relations: ['dashboard', 'dashboard.module', 'dashboard.dashboardVariables', 'dashboard.questions', 'dashboard.questions.questionSqlDatasetConfigs'],
|
|
50
|
-
});
|
|
51
|
-
const dashboard = populatedQuestion?.dashboard;
|
|
52
|
-
|
|
53
|
-
if (!dashboard) {
|
|
54
|
-
throw new Error(`Dashboard not found for question id ${question.id}`);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// Call the saveDashboardToConfig method from the DashboardService
|
|
58
|
-
await this.dashboardService.saveDashboardToConfig(dashboard);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { Injectable, Logger } from "@nestjs/common";
|
|
2
|
-
import { InjectDataSource } from "@nestjs/typeorm";
|
|
3
|
-
import { DashboardQuestion } from "src/entities/dashboard-question.entity";
|
|
4
|
-
import { Dashboard } from "src/entities/dashboard.entity";
|
|
5
|
-
import { ModuleMetadataHelperService } from "src/helpers/module-metadata-helper.service";
|
|
6
|
-
import { DashboardService } from "src/services/dashboard.service";
|
|
7
|
-
import { DataSource, EntityManager, EntitySubscriberInterface, InsertEvent, UpdateEvent } from "typeorm";
|
|
8
|
-
|
|
9
|
-
@Injectable()
|
|
10
|
-
export class DashboardQuestionSubscriber implements EntitySubscriberInterface<DashboardQuestion> {
|
|
11
|
-
private readonly logger = new Logger(this.constructor.name);
|
|
12
|
-
constructor(
|
|
13
|
-
@InjectDataSource()
|
|
14
|
-
private readonly dataSource: DataSource,
|
|
15
|
-
readonly moduleMetadataHelperService: ModuleMetadataHelperService,
|
|
16
|
-
readonly dashboardService: DashboardService,
|
|
17
|
-
) {
|
|
18
|
-
this.dataSource.subscribers.push(this);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
listenTo() {
|
|
22
|
-
return DashboardQuestion;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
async afterInsert(event: InsertEvent<DashboardQuestion>) {
|
|
26
|
-
if (!event.entity) {
|
|
27
|
-
this.logger.debug('No question entity found in the QuestionSubscriber afterInsert method');
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
await this.saveDashboardToConfig(event.entity, event.queryRunner.manager);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
async afterUpdate(event: UpdateEvent<DashboardQuestion>) {
|
|
34
|
-
if (!event.databaseEntity) {
|
|
35
|
-
this.logger.debug('No question entity found in the QuestionSubscriber afterUpdate method');
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
await this.saveDashboardToConfig(event.databaseEntity, event.queryRunner.manager);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
private async saveDashboardToConfig(question: DashboardQuestion, entityManager: EntityManager): Promise<void> {
|
|
42
|
-
const dashboard = question.dashboard;
|
|
43
|
-
// Get the dashboard from the question & call the saveDashboardToConfig method
|
|
44
|
-
if (!dashboard) {
|
|
45
|
-
this.logger.debug(`Dashboard is undefined for question id ${question.id}`);
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// populate the dashboard with its variables
|
|
50
|
-
const populatedDashboard = await entityManager.findOne(Dashboard, {
|
|
51
|
-
where: { id: dashboard.id },
|
|
52
|
-
relations: ['module','dashboardVariables', 'questions', 'questions.questionSqlDatasetConfigs'],
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
if (!populatedDashboard) {
|
|
56
|
-
throw new Error(`Dashboard not found for question id ${populatedDashboard.id}`);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// Call the saveDashboardToConfig method from the DashboardService
|
|
60
|
-
await this.dashboardService.saveDashboardToConfig(populatedDashboard);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { Injectable, Logger } from "@nestjs/common";
|
|
2
|
-
import { InjectDataSource } from "@nestjs/typeorm";
|
|
3
|
-
import { DashboardVariable } from "src/entities/dashboard-variable.entity";
|
|
4
|
-
import { Dashboard } from "src/entities/dashboard.entity";
|
|
5
|
-
import { ModuleMetadataHelperService } from "src/helpers/module-metadata-helper.service";
|
|
6
|
-
import { DashboardVariableService } from "src/services/dashboard-variable.service";
|
|
7
|
-
import { DashboardService } from "src/services/dashboard.service";
|
|
8
|
-
import { EntitySubscriberInterface, DataSource, InsertEvent, UpdateEvent, EntityManager } from "typeorm";
|
|
9
|
-
|
|
10
|
-
@Injectable()
|
|
11
|
-
export class DashboardVariableSubscriber implements EntitySubscriberInterface<DashboardVariable> {
|
|
12
|
-
private readonly logger = new Logger(this.constructor.name);
|
|
13
|
-
constructor(
|
|
14
|
-
@InjectDataSource()
|
|
15
|
-
private readonly dataSource: DataSource,
|
|
16
|
-
readonly moduleMetadataHelperService: ModuleMetadataHelperService,
|
|
17
|
-
readonly dashboardService: DashboardService, // Assuming you have a DashboardService for custom queries
|
|
18
|
-
) {
|
|
19
|
-
this.dataSource.subscribers.push(this);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
listenTo() {
|
|
23
|
-
return DashboardVariable;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
async afterInsert(event: InsertEvent<DashboardVariable>) {
|
|
27
|
-
if (!event.entity) {
|
|
28
|
-
this.logger.debug('No dashboard variable entity found in the DashboardVariableSubscriber afterInsert method');
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
await this.saveDashboardToConfig(event.entity, event.queryRunner.manager);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
async afterUpdate(event: UpdateEvent<DashboardVariable>) {
|
|
35
|
-
if (!event.databaseEntity) {
|
|
36
|
-
this.logger.debug('No dashboard variable entity found in the DashboardVariableSubscriber afterUpdate method');
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
await this.saveDashboardToConfig(event.databaseEntity, event.queryRunner.manager);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
private async saveDashboardToConfig(dashboardVariable: DashboardVariable, entityManager: EntityManager): Promise<void> {
|
|
43
|
-
const dashboard = dashboardVariable.dashboard;
|
|
44
|
-
// Get the dashboard from the question & call the saveDashboardToConfig method
|
|
45
|
-
if (!dashboard) {
|
|
46
|
-
this.logger.debug(`Dashboard is undefined for dashboard variable id ${dashboardVariable.id}`);
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// populate the dashboard with its variables
|
|
51
|
-
const populatedDashboard = await entityManager.findOne(Dashboard, {
|
|
52
|
-
where: { id: dashboard.id },
|
|
53
|
-
relations: ['module','dashboardVariables', 'questions', 'questions.questionSqlDatasetConfigs'],
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
if (!populatedDashboard) {
|
|
57
|
-
throw new Error(`Dashboard not found for question id ${populatedDashboard.id}`);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// Call the saveDashboardToConfig method from the DashboardService
|
|
61
|
-
await this.dashboardService.saveDashboardToConfig(populatedDashboard);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { Injectable, Logger } from '@nestjs/common';
|
|
2
|
-
import { InjectDataSource } from "@nestjs/typeorm";
|
|
3
|
-
import { Dashboard } from 'src/entities/dashboard.entity';
|
|
4
|
-
import { ModuleMetadataHelperService } from "src/helpers/module-metadata-helper.service";
|
|
5
|
-
import { DashboardService } from 'src/services/dashboard.service';
|
|
6
|
-
import { DataSource, EntityManager, EntitySubscriberInterface, InsertEvent, UpdateEvent } from "typeorm";
|
|
7
|
-
|
|
8
|
-
@Injectable()
|
|
9
|
-
export class DashboardSubscriber implements EntitySubscriberInterface<Dashboard> {
|
|
10
|
-
private readonly logger = new Logger(this.constructor.name);
|
|
11
|
-
constructor(
|
|
12
|
-
@InjectDataSource()
|
|
13
|
-
private readonly dataSource: DataSource,
|
|
14
|
-
readonly moduleMetadataHelperService: ModuleMetadataHelperService,
|
|
15
|
-
readonly dashboardService: DashboardService, // Assuming you have a DashboardService for custom queries
|
|
16
|
-
) {
|
|
17
|
-
this.dataSource.subscribers.push(this);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
listenTo() {
|
|
21
|
-
return Dashboard;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
async afterInsert(event: InsertEvent<Dashboard>) {
|
|
25
|
-
if (!event.entity) {
|
|
26
|
-
this.logger.debug('No dashboard entity found in the DashboardSubscriber afterInsert method');
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
await this.saveDashboardToConfig(event.entity, event.queryRunner.manager);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
async afterUpdate(event: UpdateEvent<Dashboard>) {
|
|
33
|
-
if (!event.entity) {
|
|
34
|
-
this.logger.debug('No dashboard entity found in the DashboardSubscriber afterInsert method');
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
await this.saveDashboardToConfig(event.databaseEntity, event.queryRunner.manager);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
private async saveDashboardToConfig(dashboard: Dashboard, entityManager: EntityManager): Promise<void> {
|
|
42
|
-
if (!dashboard || !dashboard.id) {
|
|
43
|
-
this.logger.debug('Dashboard or dashboard id is undefined');
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// Load the dashboard with module relation populated
|
|
48
|
-
const populatedDashboard = await entityManager.findOne(Dashboard, {
|
|
49
|
-
where: { id: dashboard.id },
|
|
50
|
-
relations: ['module','dashboardVariables', 'questions', 'questions.questionSqlDatasetConfigs'],
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
if (!populatedDashboard) {
|
|
54
|
-
this.logger.error(`Dashboard not found for id ${dashboard.id}`);
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// Call the saveDashboardToConfig method from the DashboardService
|
|
59
|
-
await this.dashboardService.saveDashboardToConfig(populatedDashboard);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
}
|