@solidstarters/solid-core 1.2.183 → 1.2.184

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/dev-grooming-docs/ozzy-prompts.txt +32 -0
  2. package/dist/jobs/database/trigger-mcp-client-subscriber-database.service.d.ts +10 -8
  3. package/dist/jobs/database/trigger-mcp-client-subscriber-database.service.d.ts.map +1 -1
  4. package/dist/jobs/database/trigger-mcp-client-subscriber-database.service.js +32 -9
  5. package/dist/jobs/database/trigger-mcp-client-subscriber-database.service.js.map +1 -1
  6. package/dist/services/chatter-message.service.d.ts.map +1 -1
  7. package/dist/services/chatter-message.service.js +9 -2
  8. package/dist/services/chatter-message.service.js.map +1 -1
  9. package/dist/services/genai/mcp-handlers/solid-add-question-to-dashboard-mcp-handler.service.d.ts +12 -0
  10. package/dist/services/genai/mcp-handlers/solid-add-question-to-dashboard-mcp-handler.service.d.ts.map +1 -0
  11. package/dist/services/genai/mcp-handlers/solid-add-question-to-dashboard-mcp-handler.service.js +41 -0
  12. package/dist/services/genai/mcp-handlers/solid-add-question-to-dashboard-mcp-handler.service.js.map +1 -0
  13. package/dist/services/genai/mcp-handlers/solid-add-variable-to-dashboard-mcp-handler.service.d.ts +12 -0
  14. package/dist/services/genai/mcp-handlers/solid-add-variable-to-dashboard-mcp-handler.service.d.ts.map +1 -0
  15. package/dist/services/genai/mcp-handlers/solid-add-variable-to-dashboard-mcp-handler.service.js +42 -0
  16. package/dist/services/genai/mcp-handlers/solid-add-variable-to-dashboard-mcp-handler.service.js.map +1 -0
  17. package/dist/services/genai/mcp-handlers/solid-create-dashboard-mcp-handler.service.d.ts +1 -1
  18. package/dist/services/genai/mcp-handlers/solid-create-dashboard-mcp-handler.service.d.ts.map +1 -1
  19. package/dist/services/genai/mcp-handlers/solid-create-dashboard-mcp-handler.service.js +8 -6
  20. package/dist/services/genai/mcp-handlers/solid-create-dashboard-mcp-handler.service.js.map +1 -1
  21. package/dist/solid-core.module.d.ts.map +1 -1
  22. package/dist/solid-core.module.js +5 -1
  23. package/dist/solid-core.module.js.map +1 -1
  24. package/dist/tsconfig.tsbuildinfo +1 -1
  25. package/package.json +1 -1
  26. package/src/jobs/database/trigger-mcp-client-subscriber-database.service.ts +42 -8
  27. package/src/services/chatter-message.service.ts +11 -3
  28. package/src/services/genai/mcp-handlers/solid-add-question-to-dashboard-mcp-handler.service.ts +43 -0
  29. package/src/services/genai/mcp-handlers/solid-add-variable-to-dashboard-mcp-handler.service.ts +44 -0
  30. package/src/services/genai/mcp-handlers/solid-create-dashboard-mcp-handler.service.ts +4 -3
  31. package/src/solid-core.module.ts +6 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidstarters/solid-core",
3
- "version": "1.2.183",
3
+ "version": "1.2.184",
4
4
  "description": "This module is a NestJS module containing all the required core providers required by a Solid application",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,15 +1,17 @@
1
1
  import { Injectable, Logger } from '@nestjs/common';
2
+ import { ModelMetadataService } from 'src';
3
+ import { SolidRegistry } from 'src/helpers/solid-registry';
2
4
  import { QueueMessage } from 'src/interfaces/mq';
3
- import { MqMessageService } from '../../services/mq-message.service';
4
- import { MqMessageQueueService } from '../../services/mq-message-queue.service';
5
- import { McpResponse, QueuesModuleOptions, TriggerMcpClientOptions } from "../../interfaces";
6
- import { DatabaseSubscriber } from 'src/services/queues/database-subscriber.service';
7
- import triggerMcpClientQueueOptions from "./trigger-mcp-client-queue-options";
5
+ import { DashboardRepository } from 'src/repository/dashboard.repository';
8
6
  import { AiInteractionService } from 'src/services/ai-interaction.service';
9
- import { PollerService } from 'src/services/poller.service';
10
- import { SolidRegistry } from 'src/helpers/solid-registry';
11
7
  import { ModuleMetadataService } from 'src/services/module-metadata.service';
12
- import { ModelMetadataService } from 'src';
8
+ import { PollerService } from 'src/services/poller.service';
9
+ import { DatabaseSubscriber } from 'src/services/queues/database-subscriber.service';
10
+ import { Not } from 'typeorm';
11
+ import { McpResponse, QueuesModuleOptions, TriggerMcpClientOptions } from "../../interfaces";
12
+ import { MqMessageQueueService } from '../../services/mq-message-queue.service';
13
+ import { MqMessageService } from '../../services/mq-message.service';
14
+ import triggerMcpClientQueueOptions from "./trigger-mcp-client-queue-options";
13
15
 
14
16
  @Injectable()
15
17
  export class TriggerMcpClientSubscriberDatabase extends DatabaseSubscriber<TriggerMcpClientOptions> {
@@ -23,6 +25,8 @@ export class TriggerMcpClientSubscriberDatabase extends DatabaseSubscriber<Trigg
23
25
  readonly moduleMetadataService: ModuleMetadataService,
24
26
  readonly modelMetadataService: ModelMetadataService,
25
27
  private readonly solidRegistry: SolidRegistry,
28
+ // private readonly dashboardService: DashboardService
29
+ private readonly dashboardRepository: DashboardRepository
26
30
 
27
31
  ) {
28
32
  super(mqMessageService, mqMessageQueueService, poller);
@@ -122,6 +126,22 @@ export class TriggerMcpClientSubscriberDatabase extends DatabaseSubscriber<Trigg
122
126
  populate: ['module']
123
127
  });
124
128
 
129
+ // Get the list of dashboards
130
+ //TODO: Ideally we should fetch dashboard like below, but used below approach to avoid below CLS issues for now.
131
+ // Cannot set the key "filter". No CLS context available, please make sure that a ClsMiddleware/Guard/Interceptor has set up the context, or wrap any calls that depend on CLS with "ClsService#run"
132
+ // const { records: existingDashboards } = await this.dashboardService.find({
133
+ // fields
134
+ // })
135
+ const existingDashboards = await this.dashboardRepository.find(
136
+ {
137
+ where: {
138
+ module: {
139
+ name: Not('solid-core')
140
+ }
141
+ },
142
+ }
143
+ );
144
+
125
145
  // Build markdown sections using template interpolation
126
146
  const modulesSection = (existingModules ?? [])
127
147
  .map(m => [
@@ -140,6 +160,14 @@ export class TriggerMcpClientSubscriberDatabase extends DatabaseSubscriber<Trigg
140
160
  ].join('\n'))
141
161
  .join('\n\n');
142
162
 
163
+ const dashboardsSection = (existingDashboards ?? [])
164
+ .map(d => [
165
+ `### ${d.displayName}`,
166
+ `- name: ${d.name}`,
167
+ `- description: ${d.description ?? ""}`,
168
+ ].join('\n'))
169
+ .join('\n\n');
170
+
143
171
  const computationProvidersSection = (existingComputationProviders ?? [])
144
172
  .map(m => [
145
173
  `### ${m.instance.name()}`,
@@ -148,6 +176,7 @@ export class TriggerMcpClientSubscriberDatabase extends DatabaseSubscriber<Trigg
148
176
  ].join('\n'))
149
177
  .join('\n\n');
150
178
 
179
+
151
180
  const finalPrompt = `
152
181
  # User Prompt:
153
182
  ${prompt}
@@ -171,6 +200,11 @@ Use the below list of modules to infer which module the user is referring to.
171
200
 
172
201
  ${modelsSection}
173
202
 
203
+ ## LIST OF EXISTING DASHBOARDS
204
+ Use the below list of dashboards to infer which dashboard the user is referring to.
205
+
206
+ ${dashboardsSection}
207
+
174
208
  ## LIST OF EXISTING COMPUTED FIELD PROVIDERS
175
209
  Use the below list of computed field providers to infer which provider the user is referring to.
176
210
 
@@ -1,7 +1,7 @@
1
1
  import { Injectable } from '@nestjs/common';
2
2
  import { InjectEntityManager, InjectRepository } from '@nestjs/typeorm';
3
3
  import { DiscoveryService, ModuleRef } from "@nestjs/core";
4
- import { EntityManager, Repository, EntityMetadata } from 'typeorm';
4
+ import { EntityManager, Repository, EntityMetadata, Brackets } from 'typeorm';
5
5
 
6
6
  import { CRUDService } from 'src/services/crud.service';
7
7
  import { ModelMetadataService } from 'src/services/model-metadata.service';
@@ -514,7 +514,7 @@ export class ChatterMessageService extends CRUDService<ChatterMessage> {
514
514
  entityName: string,
515
515
  query: any
516
516
  ) {
517
- const { limit = 25, offset = 0, sort, populate = [], populateMedia = [] } = query;
517
+ const { limit = 25, offset = 0, populate = [], populateMedia = [], filters } = query;
518
518
 
519
519
  const model = await this.modelMetadataRepo.findOne({
520
520
  where: {
@@ -575,7 +575,9 @@ export class ChatterMessageService extends CRUDService<ChatterMessage> {
575
575
  }
576
576
  }
577
577
 
578
- qb.where(orConditions.join(' OR '), parameters);
578
+ qb.where(new Brackets(qb => {
579
+ qb.where(orConditions.join(' OR '), parameters);
580
+ }));
579
581
 
580
582
  const relations = ['chatterMessageDetails', 'user'];
581
583
  if (populate && populate.length > 0) {
@@ -587,6 +589,12 @@ export class ChatterMessageService extends CRUDService<ChatterMessage> {
587
589
  qb.leftJoinAndSelect(`entity.${relation}`, relation);
588
590
  });
589
591
 
592
+ if (filters) {
593
+ qb.andWhere(new Brackets(whereQb => {
594
+ this.crudHelperService.applyFilters(whereQb, filters, 'entity', qb);
595
+ }));
596
+ }
597
+
590
598
  qb.orderBy('entity.createdAt', 'DESC');
591
599
 
592
600
  qb.skip(offset).take(limit);
@@ -0,0 +1,43 @@
1
+ import { Injectable } from "@nestjs/common";
2
+ import { plainToInstance } from "class-transformer";
3
+ import { CreateDashboardQuestionDto } from "src/dtos/create-dashboard-question.dto";
4
+ import { AiInteraction } from "src/entities/ai-interaction.entity";
5
+ import { IMcpToolResponseHandler } from "../../../interfaces";
6
+ import { DashboardQuestionService } from "../../dashboard-question.service";
7
+
8
+ @Injectable()
9
+ export class SolidAddQuestionToDashboardMcpHandler implements IMcpToolResponseHandler {
10
+
11
+ constructor(
12
+ private readonly dashboardQuestionService: DashboardQuestionService,
13
+ ) {
14
+ }
15
+
16
+ async apply(aiInteraction: AiInteraction) {
17
+ const escapedMessage = aiInteraction.message.replace(/\\'/g, "'");
18
+ const aiResponseMessage = JSON.parse(escapedMessage);
19
+
20
+ const {data} = aiResponseMessage;
21
+ const { dashboardUserKey, schema} = data;
22
+
23
+ //FIXME: Replace \' with ' in the response, since the AI response seems to contain \' which is invalid JSON.
24
+ // This is a workaround for now, until we find a better solution.
25
+ // const aiResponseMessageReplaced = aiResponseMessage['message'].replace(/\\'/g, "'");
26
+ // const dashboardUserKey = aiResponseMessageReplaced['dashboardUserKey'];
27
+ // if (!dashboardUserKey) {
28
+ // throw new Error("Dashboard User Key is required to create a Dashboard Question.");
29
+ // }
30
+ const dashboardQuestionDto = plainToInstance(CreateDashboardQuestionDto, schema);
31
+ dashboardQuestionDto['questionSqlDatasetConfigsCommand'] = "update";
32
+ dashboardQuestionDto['dashboardUserKey'] = dashboardUserKey;
33
+
34
+ const dashboardQuestion = await this.dashboardQuestionService.create(dashboardQuestionDto, []);
35
+
36
+ // TODO: decide on some shape to return hre...
37
+ return {
38
+ seedingRequired: false,
39
+ serverRebooting: false,
40
+ }
41
+ }
42
+
43
+ }
@@ -0,0 +1,44 @@
1
+ import { Injectable } from "@nestjs/common";
2
+ import { plainToInstance } from "class-transformer";
3
+ import { CreateDashboardVariableDto } from "src/dtos/create-dashboard-variable.dto";
4
+ import { AiInteraction } from "src/entities/ai-interaction.entity";
5
+ import { DashboardVariableService } from "src/services/dashboard-variable.service";
6
+ import { IMcpToolResponseHandler } from "../../../interfaces";
7
+
8
+ @Injectable()
9
+ export class SolidAddVariableToDashboardMcpHandler implements IMcpToolResponseHandler {
10
+
11
+ constructor(
12
+ private readonly dashboardVariableService: DashboardVariableService,
13
+ ) {
14
+ }
15
+
16
+ async apply(aiInteraction: AiInteraction) {
17
+ const escapedMessage = aiInteraction.message.replace(/\\'/g, "'");
18
+ const aiResponseMessage = JSON.parse(escapedMessage);
19
+
20
+ const {data} = aiResponseMessage;
21
+ const { dashboardUserKey, schema} = data;
22
+
23
+ //FIXME: Replace \' with ' in the response, since the AI response seems to contain \' which is invalid JSON.
24
+ // This is a workaround for now, until we find a better solution.
25
+ // const aiResponseMessageReplaced = aiResponseMessage['message'].replace(/\\'/g, "'");
26
+ // const dashboardUserKey = aiResponseMessageReplaced['dashboardUserKey'];
27
+ // if (!dashboardUserKey) {
28
+ // throw new Error("Dashboard User Key is required to create a Dashboard Question.");
29
+ // }
30
+ const dashboardVariableDto = plainToInstance(CreateDashboardVariableDto, schema);
31
+ dashboardVariableDto['selectionStaticValues'] = JSON.stringify(dashboardVariableDto['selectionStaticValues'] || []);
32
+ dashboardVariableDto['defaultValue'] = JSON.stringify(dashboardVariableDto['defaultValue'] || []);
33
+ dashboardVariableDto['dashboardUserKey'] = dashboardUserKey;
34
+
35
+ const dashboardVariable = await this.dashboardVariableService.create(dashboardVariableDto, []);
36
+
37
+ // TODO: decide on some shape to return hre...
38
+ return {
39
+ seedingRequired: false,
40
+ serverRebooting: false,
41
+ }
42
+ }
43
+
44
+ }
@@ -13,7 +13,7 @@ import { ModuleMetadataService } from "../../module-metadata.service";
13
13
  import { RoleMetadataService } from "../../role-metadata.service";
14
14
 
15
15
  @Injectable()
16
- export class SolidCreateDashboardMcpHandler implements IMcpToolResponseHandler {
16
+ export class SolidCreateDashboardWithWidgetsMcpHandler implements IMcpToolResponseHandler {
17
17
 
18
18
  constructor(
19
19
  private readonly dashboardService: DashboardService,
@@ -28,8 +28,9 @@ export class SolidCreateDashboardMcpHandler implements IMcpToolResponseHandler {
28
28
  async apply(aiInteraction: AiInteraction) {
29
29
  const escapedMessage = aiInteraction.message.replace(/\\'/g, "'");
30
30
  const aiResponseMessage = JSON.parse(escapedMessage);
31
-
32
- const { dashboardDto, dashboard } = await this.createDashboard(aiResponseMessage);
31
+ const { data } = aiResponseMessage;
32
+ const { schema } = data;
33
+ const { dashboardDto, dashboard } = await this.createDashboard(schema);
33
34
 
34
35
  const { moduleUserKey, actionMetadataEntity } = await this.createActionMetadataEntry(dashboardDto, dashboard);
35
36
 
@@ -288,12 +288,14 @@ import { SolidCreateModuleMcpHandler } from './services/genai/mcp-handlers/solid
288
288
  import { SolidCreateModelWithFieldsMcpHandler } from './services/genai/mcp-handlers/solid-create-model-with-fields-mcp-handler.service';
289
289
  import { SolidAddFieldsToModelMcpHandler } from './services/genai/mcp-handlers/solid-add-fields-to-model-mcp-handler.service';
290
290
  import { SolidUpdateLayoutMcpHandler } from './services/genai/mcp-handlers/solid-update-layout-mcp-handler.service';
291
- import { SolidCreateDashboardMcpHandler } from './services/genai/mcp-handlers/solid-create-dashboard-mcp-handler.service';
291
+ import { SolidCreateDashboardWithWidgetsMcpHandler } from './services/genai/mcp-handlers/solid-create-dashboard-mcp-handler.service';
292
292
  import { SolidCreateDashboardQuestionMcpHandler } from './services/genai/mcp-handlers/solid-create-dashboard-question-mcp-handler.service';
293
293
  import { SolidCreateDashboardQuestionSqlDatasetConfigMcpHandler } from './services/genai/mcp-handlers/solid-create-dashboard-question-sql-dataset-config-mcp-handler.service';
294
294
  import { SolidCreateDashboardWidgetMcpHandler } from './services/genai/mcp-handlers/solid-create-dashboard-widget-mcp-handler.service';
295
295
  import { SolidCreateComputedProviderMcpHandler } from './services/genai/mcp-handlers/solid-create-computed-provider-mcp-handler.service';
296
296
  import { SolidTsMorphService } from './services/solid-ts-morph.service';
297
+ import { SolidAddVariableToDashboardMcpHandler } from './services/genai/mcp-handlers/solid-add-variable-to-dashboard-mcp-handler.service';
298
+ import { SolidAddQuestionToDashboardMcpHandler } from './services/genai/mcp-handlers/solid-add-question-to-dashboard-mcp-handler.service';
297
299
 
298
300
 
299
301
  @Global()
@@ -631,11 +633,13 @@ import { SolidTsMorphService } from './services/solid-ts-morph.service';
631
633
  SolidAddFieldsToModelMcpHandler,
632
634
  SolidUpdateLayoutMcpHandler,
633
635
 
634
- SolidCreateDashboardMcpHandler,
636
+ SolidCreateDashboardWithWidgetsMcpHandler,
635
637
  SolidCreateDashboardQuestionMcpHandler,
636
638
  SolidCreateDashboardQuestionSqlDatasetConfigMcpHandler,
637
639
  SolidCreateDashboardWidgetMcpHandler,
638
640
  SolidCreateComputedProviderMcpHandler,
641
+ SolidAddVariableToDashboardMcpHandler,
642
+ SolidAddQuestionToDashboardMcpHandler,
639
643
  SolidTsMorphService,
640
644
 
641
645
  ViewMetadataRepository,