@solidstarters/solid-core 1.2.140 → 1.2.141

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 (36) hide show
  1. package/dist/repository/view-metadata.repository.d.ts +9 -0
  2. package/dist/repository/view-metadata.repository.d.ts.map +1 -0
  3. package/dist/repository/view-metadata.repository.js +42 -0
  4. package/dist/repository/view-metadata.repository.js.map +1 -0
  5. package/dist/seeders/module-metadata-seeder.service.d.ts +1 -1
  6. package/dist/seeders/module-metadata-seeder.service.d.ts.map +1 -1
  7. package/dist/seeders/module-metadata-seeder.service.js +22 -8
  8. package/dist/seeders/module-metadata-seeder.service.js.map +1 -1
  9. package/dist/services/computed-fields/entity/alpha-num-external-id-computed-field-provider.d.ts +14 -0
  10. package/dist/services/computed-fields/entity/alpha-num-external-id-computed-field-provider.d.ts.map +1 -0
  11. package/dist/services/computed-fields/entity/alpha-num-external-id-computed-field-provider.js +66 -0
  12. package/dist/services/computed-fields/entity/alpha-num-external-id-computed-field-provider.js.map +1 -0
  13. package/dist/services/mcp-tool-response-handlers/solid-create-dashboard-mcp-tool-response-handler.service.d.ts +14 -1
  14. package/dist/services/mcp-tool-response-handlers/solid-create-dashboard-mcp-tool-response-handler.service.d.ts.map +1 -1
  15. package/dist/services/mcp-tool-response-handlers/solid-create-dashboard-mcp-tool-response-handler.service.js +81 -5
  16. package/dist/services/mcp-tool-response-handlers/solid-create-dashboard-mcp-tool-response-handler.service.js.map +1 -1
  17. package/dist/services/mcp-tool-response-handlers/solid-save-model-layout-mcp-tool-response-handler.service.d.ts +12 -0
  18. package/dist/services/mcp-tool-response-handlers/solid-save-model-layout-mcp-tool-response-handler.service.d.ts.map +1 -0
  19. package/dist/services/mcp-tool-response-handlers/solid-save-model-layout-mcp-tool-response-handler.service.js +36 -0
  20. package/dist/services/mcp-tool-response-handlers/solid-save-model-layout-mcp-tool-response-handler.service.js.map +1 -0
  21. package/dist/services/view-metadata.service.d.ts +3 -2
  22. package/dist/services/view-metadata.service.d.ts.map +1 -1
  23. package/dist/services/view-metadata.service.js +2 -3
  24. package/dist/services/view-metadata.service.js.map +1 -1
  25. package/dist/solid-core.module.d.ts.map +1 -1
  26. package/dist/solid-core.module.js +4 -0
  27. package/dist/solid-core.module.js.map +1 -1
  28. package/dist/tsconfig.tsbuildinfo +1 -1
  29. package/package.json +1 -1
  30. package/src/repository/view-metadata.repository.ts +31 -0
  31. package/src/seeders/module-metadata-seeder.service.ts +23 -17
  32. package/src/services/computed-fields/entity/alpha-num-external-id-computed-field-provider.ts +70 -0
  33. package/src/services/mcp-tool-response-handlers/solid-create-dashboard-mcp-tool-response-handler.service.ts +83 -9
  34. package/src/services/mcp-tool-response-handlers/solid-save-model-layout-mcp-tool-response-handler.service.ts +34 -0
  35. package/src/services/view-metadata.service.ts +3 -2
  36. package/src/solid-core.module.ts +4 -0
@@ -13,26 +13,102 @@ exports.SolidCreateDashboardMcpToolResponseHandler = void 0;
13
13
  const common_1 = require("@nestjs/common");
14
14
  const class_transformer_1 = require("class-transformer");
15
15
  const create_dashboard_dto_1 = require("../../dtos/create-dashboard.dto");
16
+ const action_metadata_service_1 = require("../action-metadata.service");
16
17
  const dashboard_service_1 = require("../dashboard.service");
18
+ const menu_item_metadata_service_1 = require("../menu-item-metadata.service");
19
+ const model_metadata_service_1 = require("../model-metadata.service");
20
+ const module_metadata_service_1 = require("../module-metadata.service");
21
+ const role_metadata_service_1 = require("../role-metadata.service");
17
22
  let SolidCreateDashboardMcpToolResponseHandler = class SolidCreateDashboardMcpToolResponseHandler {
18
- constructor(dashboardService) {
23
+ constructor(dashboardService, actionMetadataService, menuItemMetadataService, moduleMetadataService, modelMetadataService, roleService) {
19
24
  this.dashboardService = dashboardService;
25
+ this.actionMetadataService = actionMetadataService;
26
+ this.menuItemMetadataService = menuItemMetadataService;
27
+ this.moduleMetadataService = moduleMetadataService;
28
+ this.modelMetadataService = modelMetadataService;
29
+ this.roleService = roleService;
20
30
  }
21
31
  async apply(aiInteraction) {
22
32
  const escapedMessage = aiInteraction.message.replace(/\\'/g, "'");
23
33
  const aiResponseMessage = JSON.parse(escapedMessage);
24
- const dashboardDto = (0, class_transformer_1.plainToInstance)(create_dashboard_dto_1.CreateDashboardDto, aiResponseMessage);
25
- dashboardDto['layoutJson'] = JSON.stringify(dashboardDto['layoutJson']);
26
- const dashboard = await this.dashboardService.create(dashboardDto, []);
34
+ const { dashboardDto, dashboard } = await this.createDashboard(aiResponseMessage);
35
+ const { moduleUserKey, actionMetadataEntity } = await this.createActionMetadataEntry(dashboardDto, dashboard);
36
+ await this.createMenuItemEntry(dashboard, moduleUserKey, actionMetadataEntity);
27
37
  return {
28
38
  seedingRequired: false,
29
39
  serverRebooting: false,
30
40
  };
31
41
  }
42
+ async createMenuItemEntry(dashboard, moduleUserKey, actionMetadataEntity) {
43
+ const menuData = {
44
+ displayName: dashboard.displayName || dashboard.name,
45
+ name: `${moduleUserKey}-${dashboard.name}-dashboard-menu-item`,
46
+ sequenceNumber: 1,
47
+ actionUserKey: actionMetadataEntity.name,
48
+ moduleUserKey: moduleUserKey,
49
+ parentMenuItemUserKey: '',
50
+ };
51
+ const adminRole = await this.roleService.findRoleByName('Admin');
52
+ const specifiedRoles = menuData['roles'];
53
+ const specifiedRoleObjects = [adminRole];
54
+ if (specifiedRoles) {
55
+ for (let i = 0; i < specifiedRoles.length; i++) {
56
+ const specifiedRole = specifiedRoles[i];
57
+ const specifiedRoleObject = await this.roleService.findRoleByName(specifiedRole);
58
+ if (!specifiedRoleObject) {
59
+ throw new Error(`Invalid role: (${specifiedRole}) specified against menu with display name ${menuData.displayName}.`);
60
+ }
61
+ specifiedRoleObjects.push(specifiedRoleObject);
62
+ }
63
+ }
64
+ menuData['roles'] = specifiedRoleObjects;
65
+ menuData['action'] = await this.actionMetadataService.findOneByUserKey(menuData.actionUserKey);
66
+ menuData['module'] = await this.moduleMetadataService.findOneByUserKey(menuData.moduleUserKey);
67
+ if (menuData.parentMenuItemUserKey) {
68
+ menuData['parentMenuItem'] = await this.menuItemMetadataService.findOneByUserKey(menuData.parentMenuItemUserKey);
69
+ }
70
+ else {
71
+ menuData['parentMenuItem'] = null;
72
+ }
73
+ await this.menuItemMetadataService.upsert(menuData);
74
+ }
75
+ async createActionMetadataEntry(dashboardDto, dashboard) {
76
+ const moduleUserKey = dashboardDto.moduleUserKey;
77
+ const actionMetadata = {
78
+ name: `${dashboard.name}-view`,
79
+ displayName: dashboard.displayName || dashboard.name,
80
+ type: 'custom',
81
+ domain: "{}",
82
+ context: "{}",
83
+ customComponent: `/admin/core/${moduleUserKey}/dashboards?dashboardName=${dashboard.name}`,
84
+ customIsModal: true,
85
+ serverEndpoint: '',
86
+ moduleUserKey: moduleUserKey,
87
+ modelUserKey: '',
88
+ viewUserKey: `${dashboard.name}-view`,
89
+ };
90
+ actionMetadata['module'] = await this.moduleMetadataService.findOneByUserKey(actionMetadata.moduleUserKey);
91
+ if (actionMetadata.modelUserKey) {
92
+ actionMetadata['model'] = await this.modelMetadataService.findOneByUserKey(actionMetadata.modelUserKey);
93
+ }
94
+ const actionMetadataEntity = await this.actionMetadataService.upsert(actionMetadata);
95
+ return { moduleUserKey, actionMetadataEntity };
96
+ }
97
+ async createDashboard(aiResponseMessage) {
98
+ const dashboardDto = (0, class_transformer_1.plainToInstance)(create_dashboard_dto_1.CreateDashboardDto, aiResponseMessage);
99
+ dashboardDto['layoutJson'] = JSON.stringify(dashboardDto['layoutJson']);
100
+ const dashboard = await this.dashboardService.create(dashboardDto, []);
101
+ return { dashboardDto, dashboard };
102
+ }
32
103
  };
33
104
  exports.SolidCreateDashboardMcpToolResponseHandler = SolidCreateDashboardMcpToolResponseHandler;
34
105
  exports.SolidCreateDashboardMcpToolResponseHandler = SolidCreateDashboardMcpToolResponseHandler = __decorate([
35
106
  (0, common_1.Injectable)(),
36
- __metadata("design:paramtypes", [dashboard_service_1.DashboardService])
107
+ __metadata("design:paramtypes", [dashboard_service_1.DashboardService,
108
+ action_metadata_service_1.ActionMetadataService,
109
+ menu_item_metadata_service_1.MenuItemMetadataService,
110
+ module_metadata_service_1.ModuleMetadataService,
111
+ model_metadata_service_1.ModelMetadataService,
112
+ role_metadata_service_1.RoleMetadataService])
37
113
  ], SolidCreateDashboardMcpToolResponseHandler);
38
114
  //# sourceMappingURL=solid-create-dashboard-mcp-tool-response-handler.service.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"solid-create-dashboard-mcp-tool-response-handler.service.js","sourceRoot":"","sources":["../../../src/services/mcp-tool-response-handlers/solid-create-dashboard-mcp-tool-response-handler.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,yDAAoD;AACpD,0EAAmE;AAGnE,4DAAwD;AAGjD,IAAM,0CAA0C,GAAhD,MAAM,0CAA0C;IAEnD,YACqB,gBAAkC;QAAlC,qBAAgB,GAAhB,gBAAgB,CAAkB;IAEvD,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,aAA4B;QACpC,MAAM,cAAc,GAAG,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAClE,MAAM,iBAAiB,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;QAQrD,MAAM,YAAY,GAAG,IAAA,mCAAe,EAAC,yCAAkB,EAAE,iBAAiB,CAAC,CAAC;QAC5E,YAAY,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC,CAAC;QAGxE,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;QAGvE,OAAO;YACH,eAAe,EAAE,KAAK;YACtB,eAAe,EAAE,KAAK;SACzB,CAAA;IACL,CAAC;CAEJ,CAAA;AA9BY,gGAA0C;qDAA1C,0CAA0C;IADtD,IAAA,mBAAU,GAAE;qCAI8B,oCAAgB;GAH9C,0CAA0C,CA8BtD","sourcesContent":["import { Injectable } from \"@nestjs/common\";\nimport { plainToInstance } from \"class-transformer\";\nimport { CreateDashboardDto } from \"src/dtos/create-dashboard.dto\";\nimport { AiInteraction } from \"src/entities/ai-interaction.entity\";\nimport { IMcpToolResponseHandler } from \"../../interfaces\";\nimport { DashboardService } from \"../dashboard.service\";\n\n@Injectable()\nexport class SolidCreateDashboardMcpToolResponseHandler implements IMcpToolResponseHandler {\n\n constructor(\n private readonly dashboardService: DashboardService,\n ) {\n }\n\n async apply(aiInteraction: AiInteraction) {\n const escapedMessage = aiInteraction.message.replace(/\\\\'/g, \"'\");\n const aiResponseMessage = JSON.parse(escapedMessage);\n\n // const aiResponse = JSON.parse(aiInteraction.message);\n\n //FIXME: Replace \\' with ' in the response, since the AI response seems to contain \\' which is invalid JSON.\n // This is a workaround for now, until we find a better solution.\n // const aiResponseMessageReplaced = aiResponse['message'].replace(/\\\\'/g, \"'\");\n\n const dashboardDto = plainToInstance(CreateDashboardDto, aiResponseMessage);\n dashboardDto['layoutJson'] = JSON.stringify(dashboardDto['layoutJson']);\n\n\n const dashboard = await this.dashboardService.create(dashboardDto, []);\n\n // TODO: decide on some shape to return hre...\n return {\n seedingRequired: false,\n serverRebooting: false,\n }\n }\n\n}"]}
1
+ {"version":3,"file":"solid-create-dashboard-mcp-tool-response-handler.service.js","sourceRoot":"","sources":["../../../src/services/mcp-tool-response-handlers/solid-create-dashboard-mcp-tool-response-handler.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,yDAAoD;AACpD,0EAAmE;AAKnE,wEAAmE;AACnE,4DAAwD;AACxD,8EAAwE;AACxE,sEAAiE;AACjE,wEAAmE;AACnE,oEAA+D;AAGxD,IAAM,0CAA0C,GAAhD,MAAM,0CAA0C;IAEnD,YACqB,gBAAkC,EAClC,qBAA4C,EAC5C,uBAAgD,EAChD,qBAA4C,EAC5C,oBAA0C,EAC1C,WAAgC;QALhC,qBAAgB,GAAhB,gBAAgB,CAAkB;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QACvE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,CAAC;IACvC,CAAC;CACJ,CAAA;AAjGY,gGAA0C;qDAA1C,0CAA0C;IADtD,IAAA,mBAAU,GAAE;qCAI8B,oCAAgB;QACX,+CAAqB;QACnB,oDAAuB;QACzB,+CAAqB;QACtB,6CAAoB;QAC7B,2CAAmB;GAR5C,0CAA0C,CAiGtD","sourcesContent":["import { Injectable } from \"@nestjs/common\";\nimport { plainToInstance } from \"class-transformer\";\nimport { CreateDashboardDto } from \"src/dtos/create-dashboard.dto\";\nimport { UpdateMenuItemMetadataDto } from \"src/dtos/update-menu-item-metadata.dto\";\nimport { AiInteraction } from \"src/entities/ai-interaction.entity\";\nimport { Dashboard } from \"src/entities/dashboard.entity\";\nimport { IMcpToolResponseHandler } from \"../../interfaces\";\nimport { ActionMetadataService } from \"../action-metadata.service\";\nimport { DashboardService } from \"../dashboard.service\";\nimport { MenuItemMetadataService } from \"../menu-item-metadata.service\";\nimport { ModelMetadataService } from \"../model-metadata.service\";\nimport { ModuleMetadataService } from \"../module-metadata.service\";\nimport { RoleMetadataService } from \"../role-metadata.service\";\n\n@Injectable()\nexport class SolidCreateDashboardMcpToolResponseHandler implements IMcpToolResponseHandler {\n\n constructor(\n private readonly dashboardService: DashboardService,\n private readonly actionMetadataService: ActionMetadataService,\n private readonly menuItemMetadataService: MenuItemMetadataService,\n private readonly moduleMetadataService: ModuleMetadataService,\n private readonly modelMetadataService: ModelMetadataService,\n private readonly roleService: RoleMetadataService, // Assuming roleService is a Mongoose model, adjust as necessary\n ) {\n }\n\n async apply(aiInteraction: AiInteraction) {\n const escapedMessage = aiInteraction.message.replace(/\\\\'/g, \"'\");\n const aiResponseMessage = JSON.parse(escapedMessage);\n\n const { dashboardDto, dashboard } = await this.createDashboard(aiResponseMessage);\n\n const { moduleUserKey, actionMetadataEntity } = await this.createActionMetadataEntry(dashboardDto, dashboard);\n\n await this.createMenuItemEntry(dashboard, moduleUserKey, actionMetadataEntity);\n\n // TODO: decide on some shape to return hre...\n return {\n seedingRequired: false,\n serverRebooting: false,\n }\n }\n\n\n private async createMenuItemEntry(dashboard: Dashboard, moduleUserKey: string, actionMetadataEntity: any) {\n const menuData = {\n displayName: dashboard.displayName || dashboard.name,\n name: `${moduleUserKey}-${dashboard.name}-dashboard-menu-item`,\n sequenceNumber: 1,\n actionUserKey: actionMetadataEntity.name,\n moduleUserKey: moduleUserKey,\n parentMenuItemUserKey: '',\n };\n\n const adminRole = await this.roleService.findRoleByName('Admin');\n const specifiedRoles = menuData['roles'];\n\n // If the developer has specified roles, then resolve them, making sure that admin role is also given.\n const specifiedRoleObjects = [adminRole];\n if (specifiedRoles) {\n for (let i = 0; i < specifiedRoles.length; i++) {\n const specifiedRole = specifiedRoles[i];\n const specifiedRoleObject = await this.roleService.findRoleByName(specifiedRole);\n if (!specifiedRoleObject) {\n throw new Error(`Invalid role: (${specifiedRole}) specified against menu with display name ${menuData.displayName}.`);\n }\n specifiedRoleObjects.push(specifiedRoleObject);\n }\n }\n\n menuData['roles'] = specifiedRoleObjects;\n menuData['action'] = await this.actionMetadataService.findOneByUserKey(menuData.actionUserKey);\n menuData['module'] = await this.moduleMetadataService.findOneByUserKey(menuData.moduleUserKey);\n\n if (menuData.parentMenuItemUserKey) {\n menuData['parentMenuItem'] = await this.menuItemMetadataService.findOneByUserKey(menuData.parentMenuItemUserKey);\n } else {\n menuData['parentMenuItem'] = null;\n }\n await this.menuItemMetadataService.upsert(menuData as unknown as UpdateMenuItemMetadataDto);\n }\n\n private async createActionMetadataEntry(dashboardDto: CreateDashboardDto, dashboard: Dashboard) {\n const moduleUserKey = dashboardDto.moduleUserKey;\n const actionMetadata = {\n name: `${dashboard.name}-view`,\n displayName: dashboard.displayName || dashboard.name,\n type: 'custom',\n domain: \"{}\",\n context: \"{}\",\n customComponent: `/admin/core/${moduleUserKey}/dashboards?dashboardName=${dashboard.name}`,\n customIsModal: true,\n serverEndpoint: '',\n moduleUserKey: moduleUserKey,\n modelUserKey: '',\n viewUserKey: `${dashboard.name}-view`,\n };\n actionMetadata['module'] = await this.moduleMetadataService.findOneByUserKey(actionMetadata.moduleUserKey);\n if (actionMetadata.modelUserKey) {\n actionMetadata['model'] = await this.modelMetadataService.findOneByUserKey(actionMetadata.modelUserKey);\n }\n const actionMetadataEntity = await this.actionMetadataService.upsert(actionMetadata);\n return { moduleUserKey, actionMetadataEntity };\n }\n\n private async createDashboard(aiResponseMessage: any) {\n const dashboardDto = plainToInstance(CreateDashboardDto, aiResponseMessage);\n dashboardDto['layoutJson'] = JSON.stringify(dashboardDto['layoutJson']);\n const dashboard = await this.dashboardService.create(dashboardDto, []);\n return { dashboardDto, dashboard };\n }\n}"]}
@@ -0,0 +1,12 @@
1
+ import { AiInteraction } from "src/entities/ai-interaction.entity";
2
+ import { ViewMetadataRepository } from "src/repository/view-metadata.repository";
3
+ import { IMcpToolResponseHandler } from "../../interfaces";
4
+ export declare class SolidCreateModelLayoutMcpToolResponseHandler implements IMcpToolResponseHandler {
5
+ private readonly viewMetadataRepository;
6
+ constructor(viewMetadataRepository: ViewMetadataRepository);
7
+ apply(aiInteraction: AiInteraction): Promise<{
8
+ seedingRequired: boolean;
9
+ serverRebooting: boolean;
10
+ }>;
11
+ }
12
+ //# sourceMappingURL=solid-save-model-layout-mcp-tool-response-handler.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"solid-save-model-layout-mcp-tool-response-handler.service.d.ts","sourceRoot":"","sources":["../../../src/services/mcp-tool-response-handlers/solid-save-model-layout-mcp-tool-response-handler.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AACjF,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAE3D,qBACa,4CAA6C,YAAW,uBAAuB;IAGpF,OAAO,CAAC,QAAQ,CAAC,sBAAsB;gBAAtB,sBAAsB,EAAE,sBAAsB;IAI7D,KAAK,CAAC,aAAa,EAAE,aAAa;;;;CAoB3C"}
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.SolidCreateModelLayoutMcpToolResponseHandler = void 0;
13
+ const common_1 = require("@nestjs/common");
14
+ const view_metadata_repository_1 = require("../../repository/view-metadata.repository");
15
+ let SolidCreateModelLayoutMcpToolResponseHandler = class SolidCreateModelLayoutMcpToolResponseHandler {
16
+ constructor(viewMetadataRepository) {
17
+ this.viewMetadataRepository = viewMetadataRepository;
18
+ }
19
+ async apply(aiInteraction) {
20
+ const aiResponse = JSON.parse(aiInteraction.message);
21
+ const { name, modelUserKey, moduleUserKey, layout } = aiResponse;
22
+ const viewMetadata = await this.viewMetadataRepository.findByNameAndModelNameAndModuleName(name, modelUserKey, moduleUserKey);
23
+ viewMetadata.layout = JSON.stringify(layout);
24
+ await this.viewMetadataRepository.save(viewMetadata);
25
+ return {
26
+ seedingRequired: false,
27
+ serverRebooting: false,
28
+ };
29
+ }
30
+ };
31
+ exports.SolidCreateModelLayoutMcpToolResponseHandler = SolidCreateModelLayoutMcpToolResponseHandler;
32
+ exports.SolidCreateModelLayoutMcpToolResponseHandler = SolidCreateModelLayoutMcpToolResponseHandler = __decorate([
33
+ (0, common_1.Injectable)(),
34
+ __metadata("design:paramtypes", [view_metadata_repository_1.ViewMetadataRepository])
35
+ ], SolidCreateModelLayoutMcpToolResponseHandler);
36
+ //# sourceMappingURL=solid-save-model-layout-mcp-tool-response-handler.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"solid-save-model-layout-mcp-tool-response-handler.service.js","sourceRoot":"","sources":["../../../src/services/mcp-tool-response-handlers/solid-save-model-layout-mcp-tool-response-handler.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAE5C,wFAAiF;AAI1E,IAAM,4CAA4C,GAAlD,MAAM,4CAA4C;IAErD,YACqB,sBAA8C;QAA9C,2BAAsB,GAAtB,sBAAsB,CAAwB;IAEnE,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,aAA4B;QACpC,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QAGrD,MAAM,EAAC,IAAI,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,EAAC,GAAG,UAAU,CAAC;QAG/D,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,sBAAsB,CAAC,mCAAmC,CAAC,IAAI,EAAE,YAAY,EAAE,aAAa,CAAC,CAAC;QAE9H,YAAY,CAAC,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAE7C,MAAM,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAGrD,OAAO;YACH,eAAe,EAAE,KAAK;YACtB,eAAe,EAAE,KAAK;SACzB,CAAA;IACL,CAAC;CAEJ,CAAA;AA3BY,oGAA4C;uDAA5C,4CAA4C;IADxD,IAAA,mBAAU,GAAE;qCAIoC,iDAAsB;GAH1D,4CAA4C,CA2BxD","sourcesContent":["import { Injectable } from \"@nestjs/common\";\nimport { AiInteraction } from \"src/entities/ai-interaction.entity\";\nimport { ViewMetadataRepository } from \"src/repository/view-metadata.repository\";\nimport { IMcpToolResponseHandler } from \"../../interfaces\";\n\n@Injectable()\nexport class SolidCreateModelLayoutMcpToolResponseHandler implements IMcpToolResponseHandler {\n\n constructor(\n private readonly viewMetadataRepository: ViewMetadataRepository,\n ) {\n }\n\n async apply(aiInteraction: AiInteraction) {\n const aiResponse = JSON.parse(aiInteraction.message);\n\n // Get the data for resolving the view metadata\n const {name, modelUserKey, moduleUserKey, layout} = aiResponse;\n\n // Fetch the view metadata for the given model and module and the view name\n const viewMetadata = await this.viewMetadataRepository.findByNameAndModelNameAndModuleName(name, modelUserKey, moduleUserKey);\n\n viewMetadata.layout = JSON.stringify(layout);\n // Save the updated view metadata\n await this.viewMetadataRepository.save(viewMetadata);\n\n // TODO: decide on some shape to return hre...\n return {\n seedingRequired: false,\n serverRebooting: false,\n }\n }\n\n}"]}
@@ -13,6 +13,7 @@ import { ViewMetadata } from '../entities/view-metadata.entity';
13
13
  import { ActionMetadataService } from './action-metadata.service';
14
14
  import { SolidIntrospectService } from './solid-introspect.service';
15
15
  import { UserViewMetadataService } from './user-view-metadata.service';
16
+ import { ViewMetadataRepository } from 'src/repository/view-metadata.repository';
16
17
  export declare class ViewMetadataService extends CRUDService<ViewMetadata> {
17
18
  readonly modelMetadataService: ModelMetadataService;
18
19
  readonly moduleMetadataService: ModuleMetadataService;
@@ -24,11 +25,11 @@ export declare class ViewMetadataService extends CRUDService<ViewMetadata> {
24
25
  readonly introspectService: SolidIntrospectService;
25
26
  readonly userViewMetadataService: UserViewMetadataService;
26
27
  readonly entityManager: EntityManager;
27
- readonly repo: Repository<ViewMetadata>;
28
+ readonly repo: ViewMetadataRepository;
28
29
  private readonly fieldMetadataRepo;
29
30
  private readonly modelMetadataRepo;
30
31
  readonly moduleRef: ModuleRef;
31
- constructor(modelMetadataService: ModelMetadataService, moduleMetadataService: ModuleMetadataService, configService: ConfigService, fileService: FileService, discoveryService: DiscoveryService, crudHelperService: CrudHelperService, actionMetadataService: ActionMetadataService, introspectService: SolidIntrospectService, userViewMetadataService: UserViewMetadataService, entityManager: EntityManager, repo: Repository<ViewMetadata>, fieldMetadataRepo: Repository<FieldMetadata>, modelMetadataRepo: Repository<ModelMetadata>, moduleRef: ModuleRef);
32
+ constructor(modelMetadataService: ModelMetadataService, moduleMetadataService: ModuleMetadataService, configService: ConfigService, fileService: FileService, discoveryService: DiscoveryService, crudHelperService: CrudHelperService, actionMetadataService: ActionMetadataService, introspectService: SolidIntrospectService, userViewMetadataService: UserViewMetadataService, entityManager: EntityManager, repo: ViewMetadataRepository, fieldMetadataRepo: Repository<FieldMetadata>, modelMetadataRepo: Repository<ModelMetadata>, moduleRef: ModuleRef);
32
33
  private readonly logger;
33
34
  private getEntityRecordsInAllLocales;
34
35
  getLayout(query: any, activeUser: any): Promise<{
@@ -1 +1 @@
1
- {"version":3,"file":"view-metadata.service.d.ts","sourceRoot":"","sources":["../../src/services/view-metadata.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAMpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EA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AAK;IAU7C,MAAM,CAAC,kBAAkB,EAAE,qBAAqB;IAgBhD,kBAAkB,CAAC,kBAAkB,EAAE,qBAAqB;CAgBnE"}
@@ -29,10 +29,10 @@ const locale_entity_1 = require("../entities/locale.entity");
29
29
  const solid_registry_1 = require("../helpers/solid-registry");
30
30
  const field_metadata_entity_1 = require("../entities/field-metadata.entity");
31
31
  const model_metadata_entity_1 = require("../entities/model-metadata.entity");
32
- const view_metadata_entity_1 = require("../entities/view-metadata.entity");
33
32
  const action_metadata_service_1 = require("./action-metadata.service");
34
33
  const solid_introspect_service_1 = require("./solid-introspect.service");
35
34
  const user_view_metadata_service_1 = require("./user-view-metadata.service");
35
+ const view_metadata_repository_1 = require("../repository/view-metadata.repository");
36
36
  let ViewMetadataService = ViewMetadataService_1 = class ViewMetadataService extends crud_service_1.CRUDService {
37
37
  constructor(modelMetadataService, moduleMetadataService, configService, fileService, discoveryService, crudHelperService, actionMetadataService, introspectService, userViewMetadataService, entityManager, repo, fieldMetadataRepo, modelMetadataRepo, moduleRef) {
38
38
  super(modelMetadataService, moduleMetadataService, configService, fileService, discoveryService, crudHelperService, entityManager, repo, 'viewMetadata', 'solid-core', moduleRef);
@@ -260,7 +260,6 @@ exports.ViewMetadataService = ViewMetadataService;
260
260
  exports.ViewMetadataService = ViewMetadataService = ViewMetadataService_1 = __decorate([
261
261
  (0, common_1.Injectable)(),
262
262
  __param(9, (0, typeorm_1.InjectEntityManager)()),
263
- __param(10, (0, typeorm_1.InjectRepository)(view_metadata_entity_1.ViewMetadata, 'default')),
264
263
  __param(11, (0, typeorm_1.InjectRepository)(field_metadata_entity_1.FieldMetadata)),
265
264
  __param(12, (0, typeorm_1.InjectRepository)(model_metadata_entity_1.ModelMetadata)),
266
265
  __metadata("design:paramtypes", [model_metadata_service_1.ModelMetadataService,
@@ -273,7 +272,7 @@ exports.ViewMetadataService = ViewMetadataService = ViewMetadataService_1 = __de
273
272
  solid_introspect_service_1.SolidIntrospectService,
274
273
  user_view_metadata_service_1.UserViewMetadataService,
275
274
  typeorm_2.EntityManager,
276
- typeorm_2.Repository,
275
+ view_metadata_repository_1.ViewMetadataRepository,
277
276
  typeorm_2.Repository,
278
277
  typeorm_2.Repository,
279
278
  core_1.ModuleRef])
@@ -1 +1 @@
1
- {"version":3,"file":"view-metadata.service.js","sourceRoot":"","sources":["../../src/services/view-metadata.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyE;AACzE,2CAA+C;AAC/C,uCAA2D;AAC3D,6CAAwE;AACxE,+DAAqE;AACrE,iDAAwD;AACxD,iDAAwD;AACxD,qEAA2E;AAC3E,uEAA6E;AAC7E,qCAAoD;AAGpD,oEAAkE;AAClE,6DAAoD;AACpD,8DAA2D;AAE3D,6EAAkE;AAClE,6EAAkE;AAClE,2EAAgE;AAChE,uEAAkE;AAClE,yEAAoE;AACpE,6EAAuE;AAGhE,IAAM,mBAAmB,2BAAzB,MAAM,mBAAoB,SAAQ,0BAAyB;IAChE,YACW,oBAA0C,EAC1C,qBAA4C,EAC5C,aAA4B,EAC5B,WAAwB,EACxB,gBAAkC,EAClC,iBAAoC,EACpC,qBAA4C,EAC5C,iBAAyC,EACzC,uBAAgD,EAEzD,aAAqC,EAErC,IAAuC,EAEvC,iBAA6D,EAE7D,iBAA6D,EACpD,SAAoB;QAE7B,KAAK,CAAC,oBAAoB,EAAE,qBAAqB,EAAE,aAAa,EAAE,WAAW,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,aAAa,EAAE,IAAI,EAAE,cAAc,EAAE,YAAY,EAAE,SAAS,CAAC,CAAC;QAnBzK,yBAAoB,GAApB,oBAAoB,CAAsB;QAC1C,0BAAqB,GAArB,qBAAqB,CAAuB;QAC5C,kBAAa,GAAb,aAAa,CAAe;QAC5B,gBAAW,GAAX,WAAW,CAAa;QACxB,qBAAgB,GAAhB,gBAAgB,CAAkB;QAClC,sBAAiB,GAAjB,iBAAiB,CAAmB;QACpC,0BAAqB,GAArB,qBAAqB,CAA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uB;QAEjC,uBAAa;QAEtB,oBAAU;QAEW,oBAAU;QAEV,oBAAU;QAC1B,gBAAS;GAnBpB,mBAAmB,CA6X/B","sourcesContent":["import { BadRequestException, Injectable, Logger } from '@nestjs/common';\nimport { ConfigService } from '@nestjs/config';\nimport { DiscoveryService, ModuleRef } from \"@nestjs/core\";\nimport { InjectEntityManager, InjectRepository } from '@nestjs/typeorm';\nimport { CrudHelperService } from \"src/services/crud-helper.service\";\nimport { CRUDService } from 'src/services/crud.service';\nimport { FileService } from \"src/services/file.service\";\nimport { ModelMetadataService } from 'src/services/model-metadata.service';\nimport { ModuleMetadataService } from 'src/services/module-metadata.service';\nimport { EntityManager, Repository } from 'typeorm';\n\n\nimport { classify } from '@angular-devkit/core/src/utils/strings';\nimport { Locale } from 'src/entities/locale.entity';\nimport { SolidRegistry } from 'src/helpers/solid-registry';\nimport { UpdateViewMetadataDto } from '../dtos/update-view-metadata.dto';\nimport { FieldMetadata } from '../entities/field-metadata.entity';\nimport { ModelMetadata } from '../entities/model-metadata.entity';\nimport { ViewMetadata } from '../entities/view-metadata.entity';\nimport { ActionMetadataService } from './action-metadata.service';\nimport { SolidIntrospectService } from './solid-introspect.service';\nimport { UserViewMetadataService } from './user-view-metadata.service';\n\n@Injectable()\nexport class ViewMetadataService extends CRUDService<ViewMetadata> {\n constructor(\n readonly modelMetadataService: ModelMetadataService,\n readonly moduleMetadataService: ModuleMetadataService,\n readonly configService: ConfigService,\n readonly fileService: FileService,\n readonly discoveryService: DiscoveryService,\n readonly crudHelperService: CrudHelperService,\n readonly actionMetadataService: ActionMetadataService,\n readonly introspectService: SolidIntrospectService,\n readonly userViewMetadataService: UserViewMetadataService,\n @InjectEntityManager()\n readonly entityManager: EntityManager,\n @InjectRepository(ViewMetadata, 'default')\n readonly repo: Repository<ViewMetadata>,\n @InjectRepository(FieldMetadata)\n private readonly fieldMetadataRepo: Repository<FieldMetadata>,\n @InjectRepository(ModelMetadata)\n private readonly modelMetadataRepo: Repository<ModelMetadata>,\n readonly moduleRef: ModuleRef\n ) {\n super(modelMetadataService, moduleMetadataService, configService, fileService, discoveryService, crudHelperService, entityManager, repo, 'viewMetadata', 'solid-core', moduleRef);\n }\n\n private readonly logger = new Logger(ViewMetadataService.name);\n\n //for locales \n private async getEntityRecordsInAllLocales(\n modelName: string,\n id: string,\n defaultEntityLocaleIdFromQuery?: string\n): Promise<{ records: any[], defaultEntityLocaleId: string | null }> {\n const solidRegistry = await this.moduleRef.get(SolidRegistry, { strict: false });\n // const currentEntityTarget = solidRegistry.getEntityTarget(this.entityManager, classify(modelName));\n const currentEntityRepository = this.entityManager.getRepository(classify(modelName));\n\n // Case 1: Creating a new record with no defaultEntityLocaleId to clone\n if (id === 'new' && !defaultEntityLocaleIdFromQuery) {\n this.logger.debug(`Creating new record without cloning from any defaultEntityLocaleId.`);\n return { records: [], defaultEntityLocaleId: null };\n }\n\n // Case 2: Creating a new record and cloning from an existing defaultEntityLocaleId\n if (id === 'new' && defaultEntityLocaleIdFromQuery) {\n this.logger.debug(`Creating new record by cloning translations from defaultEntityLocaleId: ${defaultEntityLocaleIdFromQuery}`);\n\n const records = await currentEntityRepository.find({\n where: [\n { defaultEntityLocaleId: defaultEntityLocaleIdFromQuery },\n { id: defaultEntityLocaleIdFromQuery }\n ]\n });\n\n this.logger.debug(`Found ${records.length} cloned records for new entity.`);\n return { records, defaultEntityLocaleId: defaultEntityLocaleIdFromQuery };\n }\n\n // Case 3: Editing an existing entity\n const entityRecord = await currentEntityRepository.findOne({ where: { id } });\n\n if (!entityRecord) {\n this.logger.warn(`No entity found for id ${id}`);\n return { records: [], defaultEntityLocaleId: null };\n }\n\n const defaultLocale = await this.entityManager.getRepository(Locale).findOne({ where: { isDefault: true } });\n\n let defaultEntityLocaleId: string;\n if (entityRecord.localeName === defaultLocale?.locale) {\n defaultEntityLocaleId = entityRecord.id;\n this.logger.debug(`Editing default locale record with id ${defaultEntityLocaleId}`);\n } else {\n defaultEntityLocaleId = entityRecord.defaultEntityLocaleId;\n this.logger.debug(`Editing non-default locale record. DefaultEntityLocaleId: ${defaultEntityLocaleId}`);\n }\n\n const records = await currentEntityRepository.find({\n where: [\n { defaultEntityLocaleId: defaultEntityLocaleId },\n { id: defaultEntityLocaleId }\n ]\n });\n\n this.logger.debug(`Found ${records.length} records in all locales for existing entity.`);\n\n return { records, defaultEntityLocaleId };\n }\n\n // START: Custom Service Methods\n async getLayout(query, activeUser) {\n let { modelName, moduleName, viewType, id, populate } = query;\n\n // modelName = camelize(modelName);\n\n // 1. Fetch the view based on module, model & view name.\n const entity = await this.repo.findOne({\n where: {\n model: { singularName: modelName },\n module: { name: moduleName },\n type: viewType,\n },\n relations: {\n model: {\n userKeyField: true,\n },\n module: true,\n }\n });\n\n if (!entity) {\n throw new BadRequestException(`Unable to identify view for module: ${moduleName}, model: ${modelName} and viewType: ${viewType}`);\n }\n if (!activeUser?.sub) {\n throw new BadRequestException(`Unable to identify user for module: ${moduleName}, model: ${modelName} and viewType: ${viewType}`);\n }\n\n // 2. See if we have a user specific layout for this view.\n const userLayout = await this.userViewMetadataService.repo.findOne({\n where: {\n user: { id: activeUser?.sub },\n viewMetadata: { id: entity.id },\n },\n });\n // Based on where we found the layout we are converting it from string to json.\n if (userLayout) {\n entity.layout = JSON.parse(userLayout.layout);\n } else {\n entity.layout = JSON.parse(entity.layout);\n }\n\n\n // 3. We are resolving the create & edit actions if specified in the layout.\n if (entity?.layout?.attrs?.createAction) {\n const actionName: string = entity.layout.attrs.createAction;\n entity.layout.attrs.createAction = await this.actionMetadataService.findOneByUserKey(actionName)\n }\n if (entity?.layout?.attrs?.editAction) {\n const actionName: string = entity.layout.attrs.editAction;\n entity.layout.attrs.editAction = await this.actionMetadataService.findOneByUserKey(actionName)\n }\n\n // 4. For form views we need to fetch the workflow field metadata if specified.\n let workflowFieldName = null;\n let workflowField = null;\n if (viewType === 'form') {\n workflowFieldName = entity.layout?.attrs?.workflowField;\n }\n\n // 5. Create an easy to use map of field metadata, rather than sending an array of fields it becomes easier to use in the frontend.\n const fields = await this.loadFieldHierarchy(modelName);\n const fieldsMap = new Map<string, FieldMetadata>();\n for (let i = 0; i < fields.length; i++) {\n const field = fields[i];\n\n // We need to identify the workflowField metadata if specified. \n if (workflowFieldName && field.name === workflowFieldName) {\n workflowField = field;\n }\n\n // For fields of type relation & relationType many-to-one\n // We fetch metadata regarding the relationCoModelSingularName\n if (field.type === 'relation') {\n const relationModel = await this.modelMetadataRepo.find({\n where: {\n singularName: field.relationCoModelSingularName\n },\n relations: {\n userKeyField: true\n }\n });\n\n if (relationModel) {\n field['relationModel'] = relationModel[0];\n }\n }\n if (!fieldsMap.has(field.name)) {\n fieldsMap.set(field.name, field);\n }\n }\n\n // 6. Use the resolved workflowField to populate workflow specific metadata.\n // Check if we were able to resolve an actual workflowField.\n let solidFormViewWorkflowData = [];\n if (viewType === 'form' && workflowField) {\n // check for type of workflow field. \n // for workflowFields of type selectionStatic we simply return the key/values from field metadata AS-IS\n if (workflowField.type === 'selectionStatic') {\n solidFormViewWorkflowData = workflowField.selectionStaticValues.map(item => {\n const [value, label] = item.split(\":\");\n return { label, value };\n });\n }\n // for workflowFields of type relation.many-to-one we need to query the co-model, and return data in key/value format.\n if (workflowField.type === 'relation' && workflowField.relationType === 'many-to-one') {\n const comodelCrudService = this.introspectService.getCRUDService(workflowField.relationCoModelSingularName);\n const data = await comodelCrudService.find({ limit: 100, offset: 0, });\n const records = data.records ?? [];\n const workflowFieldMetadata = fieldsMap.get(workflowFieldName);\n const workflowFielUserkey = workflowFieldMetadata['relationModel']['userKeyField']['name'];\n\n // iterate over the comodel records extracting the label & value. \n solidFormViewWorkflowData = records.map(item => ({ 'label': item[workflowFielUserkey], 'value': item['id'] }))\n }\n }\n\n // 7. If this model supports internationalisation, we need to load the locales applicable with the id of an actual record for each locale if present.\n // This is the shape of locales that will be returned \n /**\n * [\n * {locale: 'en', displayName: 'English', isDefault: 'yes', defaultEntityLocaleId: '', entityId: '1'}, \n * {locale: 'en-IN', displayName: 'English (India)', isDefault: 'no', defaultEntityLocaleId: '1', entityId: '2'}, \n * {locale: 'en-SG', displayName: 'English (Singapore)', isDefault: 'no', defaultEntityLocaleId: '', entityId: '3'}, \n * {locale: 'fr', displayName: 'French', isDefault: 'no', defaultEntityLocaleId: '', entityId: ''}\n * ]\n */\n\n const applicableLocales: any = []\n // if (entity.model.internationalisation) {\n // const allLocales = await this.entityManager.getRepository(Locale).find({});\n\n // if (id === 'new') {\n // allLocales.forEach(locale => {\n // applicableLocales.push({\n // locale: locale.locale,\n // displayName: locale.displayName,\n // isDefault: locale.isDefault ? 'yes' : 'no',\n // defaultEntityLocaleId: null,\n // entityId: null\n // });\n // });\n // }\n // else {\n // const defaultLocale = allLocales.find(locale => locale.isDefault);\n // this.logger.debug(`Default locale is: ${defaultLocale.locale}`);\n\n // // Get hold of the repository for the current model\n // const solidRegistry = await this.moduleRef.get(SolidRegistry, { strict: false });\n // const currentEntityTarget = solidRegistry.getEntityTarget(this.entityManager, classify(modelName));\n // const currentEntityRepository = this.entityManager.getRepository(currentEntityTarget);\n\n // // We are in edit mode, the id that is being edited could be a record tagged with the default locale or it could be tagged with a non-default locale.\n // const entityRecord = await currentEntityRepository.findOne({\n // where: {\n // id: id,\n // }\n // });\n // if(entityRecord){\n // // Resolve the default entity locale id....\n // let defaultEntityLocaleId = null;\n // if (entityRecord.localeName === defaultLocale.locale) {\n // defaultEntityLocaleId = entityRecord.id;\n // this.logger.debug(`You are editing a record tagged with the default locale: ${entityRecord.localeName}.`);\n // }\n // else {\n // defaultEntityLocaleId = entityRecord.defaultEntityLocaleId;\n // this.logger.debug(`You are editing a record tagged with the non-default locale: ${entityRecord.localeName}. `);\n // }\n // this.logger.debug(`Identified default Entity Locale Id: ${defaultEntityLocaleId}`);\n\n // // Now we query for all records in the same model matching the defaultEntityLocaleId\n // // Get all records mathcing the defaultEntityLocaleId or where the id is same as the defaultEntityLocaleId\n // const entityRecordsInAllLocales = await currentEntityRepository.find({\n // where: [\n // { defaultEntityLocaleId: defaultEntityLocaleId },\n // { id: defaultEntityLocaleId }\n // ],\n // });\n // this.logger.debug(`Found ${entityRecordsInAllLocales.length} records in all locales for the defaultEntityLocaleId: ${defaultEntityLocaleId}`);\n\n // // Loop over all locales and populate the applicableLocales array\n // for (const locale of allLocales) {\n // // Find the record in the entityRecordsInAllLocales that matches the current locale\n // const matchingRecord = entityRecordsInAllLocales.find(record => record.localeName === locale.locale);\n\n // applicableLocales.push({\n // locale: locale.locale,\n // displayName: locale.displayName,\n // isDefault: locale.isDefault ? 'yes' : 'no',\n // defaultEntityLocaleId: defaultEntityLocaleId,\n // entityId: (matchingRecord ? matchingRecord.id : null)\n // });\n // }\n // }else{\n // this.logger.warn(`No record found for id: ${id} in model: ${modelName}. Cannot determine applicable locales.`);\n // }\n // }\n // }\n if (entity.model.internationalisation) {\n const defaultEntityLocaleIdFromQuery = query?.defaultEntityLocaleId;\n const { records: entityRecordsInAllLocales, defaultEntityLocaleId } =\n await this.getEntityRecordsInAllLocales(modelName, id, defaultEntityLocaleIdFromQuery);\n const allLocales = await this.entityManager.getRepository(Locale).find({});\n for (const locale of allLocales) {\n const matchingRecord = entityRecordsInAllLocales.find(record => record.localeName === locale.locale);\n applicableLocales.push({\n locale: locale.locale,\n displayName: locale.displayName,\n isDefault: locale.isDefault ? 'yes' : 'no',\n defaultEntityLocaleId: defaultEntityLocaleId,\n entityId: matchingRecord ? matchingRecord.id : null\n });\n }\n }\n\n const r = {\n 'solidView': entity,\n 'solidFieldsMetadata': Object.fromEntries(fieldsMap),\n 'solidFormViewWorkflowData': solidFormViewWorkflowData,\n 'applicableLocales': applicableLocales\n }\n\n return r;\n }\n\n private async loadFieldHierarchy(modelName: any) {\n const model = await this.modelMetadataRepo.findOne({\n where: {\n singularName: modelName,\n },\n relations: {\n fields: true,\n parentModel: {\n fields: true,\n }\n }\n });\n const fields = [];\n if (model) {\n // Add the fields of the current model\n fields.push(...model.fields);\n\n // Add the fields of the parent model\n if (model.parentModel) {\n fields.push(...model.parentModel.fields);\n }\n }\n return fields;\n }\n\n async findOneByUserKey(name: string, relations = {}) {\n const entity = await this.repo.findOne({\n where: {\n name: name,\n },\n relations: relations,\n });\n return entity;\n }\n\n async upsert(updateSolidViewDto: UpdateViewMetadataDto) {\n // First check if module already exists using name\n const existingSolidView = await this.findOneByUserKey(updateSolidViewDto.name);\n\n // if found\n if (existingSolidView) {\n const updatedSolidViewDto = { ...existingSolidView, ...updateSolidViewDto };\n return this.repo.save(updatedSolidViewDto);\n }\n // if not found - create new \n else {\n const viewData = this.repo.create(updateSolidViewDto);\n return this.repo.save(viewData);\n }\n }\n\n async createIfNotPresent(updateSolidViewDto: UpdateViewMetadataDto) {\n // First check if module already exists using name\n const existingSolidView = await this.findOneByUserKey(updateSolidViewDto.name);\n\n // if found\n if (existingSolidView) {\n }\n // if not found - create new \n else {\n const viewData = this.repo.create(updateSolidViewDto);\n return this.repo.save(viewData);\n }\n }\n\n // END: Custom Service Methods\n\n}\n"]}
1
+ {"version":3,"file":"view-metadata.service.js","sourceRoot":"","sources":["../../src/services/view-metadata.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyE;AACzE,2CAA+C;AAC/C,uCAA2D;AAC3D,6CAAwE;AACxE,+DAAqE;AACrE,iDAAwD;AACxD,iDAAwD;AACxD,qEAA2E;AAC3E,uEAA6E;AAC7E,qCAAoD;AAGpD,oEAAkE;AAClE,6DAAoD;AACpD,8DAA2D;AAE3D,6EAAkE;AAClE,6EAAkE;AAElE,uEAAkE;AAClE,yEAAoE;AACpE,6EAAuE;AACvE,qFAAiF;AAG1E,IAAM,mBAAmB,2BAAzB,MAAM,mBAAoB,SAAQ,0BAAyB;IAChE,YACW,oBAA0C,EAC1C,qBAA4C,EAC5C,aAA4B,EAC5B,WAAwB,EACxB,gBAAkC,EAClC,iBAAoC,EACpC,qBAA4C,EAC5C,iBAAyC,EACzC,uBAAgD,EAEzD,aAAqC,EAE5B,IAA4B,EAErC,iB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,CAAC,QAAQ,CAAC,CAAC;QAClC,CAAC;IACH,CAAC;CAIF,CAAA;AA7XY,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,mBAAU,GAAE;IAYR,WAAA,IAAA,6BAAmB,GAAE,CAAA;IAIrB,YAAA,IAAA,0BAAgB,EAAC,qCAAa,CAAC,CAAA;IAE/B,YAAA,IAAA,0BAAgB,EAAC,qCAAa,CAAC,CAAA;qCAfD,6CAAoB;QACnB,+CAAqB;QAC7B,sBAAa;QACf,0BAAW;QACN,uBAAgB;QACf,uCAAiB;QACb,+CAAqB;QACzB,iDAAsB;QAChB,oDAAuB;QAEjC,uBAAa;QAEtB,iDAAsB;QAED,oBAAU;QAEV,oBAAU;QAC1B,gBAAS;GAnBpB,mBAAmB,CA6X/B","sourcesContent":["import { BadRequestException, Injectable, Logger } from '@nestjs/common';\nimport { ConfigService } from '@nestjs/config';\nimport { DiscoveryService, ModuleRef } from \"@nestjs/core\";\nimport { InjectEntityManager, InjectRepository } from '@nestjs/typeorm';\nimport { CrudHelperService } from \"src/services/crud-helper.service\";\nimport { CRUDService } from 'src/services/crud.service';\nimport { FileService } from \"src/services/file.service\";\nimport { ModelMetadataService } from 'src/services/model-metadata.service';\nimport { ModuleMetadataService } from 'src/services/module-metadata.service';\nimport { EntityManager, Repository } from 'typeorm';\n\n\nimport { classify } from '@angular-devkit/core/src/utils/strings';\nimport { Locale } from 'src/entities/locale.entity';\nimport { SolidRegistry } from 'src/helpers/solid-registry';\nimport { UpdateViewMetadataDto } from '../dtos/update-view-metadata.dto';\nimport { FieldMetadata } from '../entities/field-metadata.entity';\nimport { ModelMetadata } from '../entities/model-metadata.entity';\nimport { ViewMetadata } from '../entities/view-metadata.entity';\nimport { ActionMetadataService } from './action-metadata.service';\nimport { SolidIntrospectService } from './solid-introspect.service';\nimport { UserViewMetadataService } from './user-view-metadata.service';\nimport { ViewMetadataRepository } from 'src/repository/view-metadata.repository';\n\n@Injectable()\nexport class ViewMetadataService extends CRUDService<ViewMetadata> {\n constructor(\n readonly modelMetadataService: ModelMetadataService,\n readonly moduleMetadataService: ModuleMetadataService,\n readonly configService: ConfigService,\n readonly fileService: FileService,\n readonly discoveryService: DiscoveryService,\n readonly crudHelperService: CrudHelperService,\n readonly actionMetadataService: ActionMetadataService,\n readonly introspectService: SolidIntrospectService,\n readonly userViewMetadataService: UserViewMetadataService,\n @InjectEntityManager()\n readonly entityManager: EntityManager,\n // @InjectRepository(ViewMetadata, 'default')\n readonly repo: ViewMetadataRepository,\n @InjectRepository(FieldMetadata)\n private readonly fieldMetadataRepo: Repository<FieldMetadata>,\n @InjectRepository(ModelMetadata)\n private readonly modelMetadataRepo: Repository<ModelMetadata>,\n readonly moduleRef: ModuleRef\n ) {\n super(modelMetadataService, moduleMetadataService, configService, fileService, discoveryService, crudHelperService, entityManager, repo, 'viewMetadata', 'solid-core', moduleRef);\n }\n\n private readonly logger = new Logger(ViewMetadataService.name);\n\n //for locales \n private async getEntityRecordsInAllLocales(\n modelName: string,\n id: string,\n defaultEntityLocaleIdFromQuery?: string\n): Promise<{ records: any[], defaultEntityLocaleId: string | null }> {\n const solidRegistry = await this.moduleRef.get(SolidRegistry, { strict: false });\n // const currentEntityTarget = solidRegistry.getEntityTarget(this.entityManager, classify(modelName));\n const currentEntityRepository = this.entityManager.getRepository(classify(modelName));\n\n // Case 1: Creating a new record with no defaultEntityLocaleId to clone\n if (id === 'new' && !defaultEntityLocaleIdFromQuery) {\n this.logger.debug(`Creating new record without cloning from any defaultEntityLocaleId.`);\n return { records: [], defaultEntityLocaleId: null };\n }\n\n // Case 2: Creating a new record and cloning from an existing defaultEntityLocaleId\n if (id === 'new' && defaultEntityLocaleIdFromQuery) {\n this.logger.debug(`Creating new record by cloning translations from defaultEntityLocaleId: ${defaultEntityLocaleIdFromQuery}`);\n\n const records = await currentEntityRepository.find({\n where: [\n { defaultEntityLocaleId: defaultEntityLocaleIdFromQuery },\n { id: defaultEntityLocaleIdFromQuery }\n ]\n });\n\n this.logger.debug(`Found ${records.length} cloned records for new entity.`);\n return { records, defaultEntityLocaleId: defaultEntityLocaleIdFromQuery };\n }\n\n // Case 3: Editing an existing entity\n const entityRecord = await currentEntityRepository.findOne({ where: { id } });\n\n if (!entityRecord) {\n this.logger.warn(`No entity found for id ${id}`);\n return { records: [], defaultEntityLocaleId: null };\n }\n\n const defaultLocale = await this.entityManager.getRepository(Locale).findOne({ where: { isDefault: true } });\n\n let defaultEntityLocaleId: string;\n if (entityRecord.localeName === defaultLocale?.locale) {\n defaultEntityLocaleId = entityRecord.id;\n this.logger.debug(`Editing default locale record with id ${defaultEntityLocaleId}`);\n } else {\n defaultEntityLocaleId = entityRecord.defaultEntityLocaleId;\n this.logger.debug(`Editing non-default locale record. DefaultEntityLocaleId: ${defaultEntityLocaleId}`);\n }\n\n const records = await currentEntityRepository.find({\n where: [\n { defaultEntityLocaleId: defaultEntityLocaleId },\n { id: defaultEntityLocaleId }\n ]\n });\n\n this.logger.debug(`Found ${records.length} records in all locales for existing entity.`);\n\n return { records, defaultEntityLocaleId };\n }\n\n // START: Custom Service Methods\n async getLayout(query, activeUser) {\n let { modelName, moduleName, viewType, id, populate } = query;\n\n // modelName = camelize(modelName);\n\n // 1. Fetch the view based on module, model & view name.\n const entity = await this.repo.findOne({\n where: {\n model: { singularName: modelName },\n module: { name: moduleName },\n type: viewType,\n },\n relations: {\n model: {\n userKeyField: true,\n },\n module: true,\n }\n });\n\n if (!entity) {\n throw new BadRequestException(`Unable to identify view for module: ${moduleName}, model: ${modelName} and viewType: ${viewType}`);\n }\n if (!activeUser?.sub) {\n throw new BadRequestException(`Unable to identify user for module: ${moduleName}, model: ${modelName} and viewType: ${viewType}`);\n }\n\n // 2. See if we have a user specific layout for this view.\n const userLayout = await this.userViewMetadataService.repo.findOne({\n where: {\n user: { id: activeUser?.sub },\n viewMetadata: { id: entity.id },\n },\n });\n // Based on where we found the layout we are converting it from string to json.\n if (userLayout) {\n entity.layout = JSON.parse(userLayout.layout);\n } else {\n entity.layout = JSON.parse(entity.layout);\n }\n\n\n // 3. We are resolving the create & edit actions if specified in the layout.\n if (entity?.layout?.attrs?.createAction) {\n const actionName: string = entity.layout.attrs.createAction;\n entity.layout.attrs.createAction = await this.actionMetadataService.findOneByUserKey(actionName)\n }\n if (entity?.layout?.attrs?.editAction) {\n const actionName: string = entity.layout.attrs.editAction;\n entity.layout.attrs.editAction = await this.actionMetadataService.findOneByUserKey(actionName)\n }\n\n // 4. For form views we need to fetch the workflow field metadata if specified.\n let workflowFieldName = null;\n let workflowField = null;\n if (viewType === 'form') {\n workflowFieldName = entity.layout?.attrs?.workflowField;\n }\n\n // 5. Create an easy to use map of field metadata, rather than sending an array of fields it becomes easier to use in the frontend.\n const fields = await this.loadFieldHierarchy(modelName);\n const fieldsMap = new Map<string, FieldMetadata>();\n for (let i = 0; i < fields.length; i++) {\n const field = fields[i];\n\n // We need to identify the workflowField metadata if specified. \n if (workflowFieldName && field.name === workflowFieldName) {\n workflowField = field;\n }\n\n // For fields of type relation & relationType many-to-one\n // We fetch metadata regarding the relationCoModelSingularName\n if (field.type === 'relation') {\n const relationModel = await this.modelMetadataRepo.find({\n where: {\n singularName: field.relationCoModelSingularName\n },\n relations: {\n userKeyField: true\n }\n });\n\n if (relationModel) {\n field['relationModel'] = relationModel[0];\n }\n }\n if (!fieldsMap.has(field.name)) {\n fieldsMap.set(field.name, field);\n }\n }\n\n // 6. Use the resolved workflowField to populate workflow specific metadata.\n // Check if we were able to resolve an actual workflowField.\n let solidFormViewWorkflowData = [];\n if (viewType === 'form' && workflowField) {\n // check for type of workflow field. \n // for workflowFields of type selectionStatic we simply return the key/values from field metadata AS-IS\n if (workflowField.type === 'selectionStatic') {\n solidFormViewWorkflowData = workflowField.selectionStaticValues.map(item => {\n const [value, label] = item.split(\":\");\n return { label, value };\n });\n }\n // for workflowFields of type relation.many-to-one we need to query the co-model, and return data in key/value format.\n if (workflowField.type === 'relation' && workflowField.relationType === 'many-to-one') {\n const comodelCrudService = this.introspectService.getCRUDService(workflowField.relationCoModelSingularName);\n const data = await comodelCrudService.find({ limit: 100, offset: 0, });\n const records = data.records ?? [];\n const workflowFieldMetadata = fieldsMap.get(workflowFieldName);\n const workflowFielUserkey = workflowFieldMetadata['relationModel']['userKeyField']['name'];\n\n // iterate over the comodel records extracting the label & value. \n solidFormViewWorkflowData = records.map(item => ({ 'label': item[workflowFielUserkey], 'value': item['id'] }))\n }\n }\n\n // 7. If this model supports internationalisation, we need to load the locales applicable with the id of an actual record for each locale if present.\n // This is the shape of locales that will be returned \n /**\n * [\n * {locale: 'en', displayName: 'English', isDefault: 'yes', defaultEntityLocaleId: '', entityId: '1'}, \n * {locale: 'en-IN', displayName: 'English (India)', isDefault: 'no', defaultEntityLocaleId: '1', entityId: '2'}, \n * {locale: 'en-SG', displayName: 'English (Singapore)', isDefault: 'no', defaultEntityLocaleId: '', entityId: '3'}, \n * {locale: 'fr', displayName: 'French', isDefault: 'no', defaultEntityLocaleId: '', entityId: ''}\n * ]\n */\n\n const applicableLocales: any = []\n // if (entity.model.internationalisation) {\n // const allLocales = await this.entityManager.getRepository(Locale).find({});\n\n // if (id === 'new') {\n // allLocales.forEach(locale => {\n // applicableLocales.push({\n // locale: locale.locale,\n // displayName: locale.displayName,\n // isDefault: locale.isDefault ? 'yes' : 'no',\n // defaultEntityLocaleId: null,\n // entityId: null\n // });\n // });\n // }\n // else {\n // const defaultLocale = allLocales.find(locale => locale.isDefault);\n // this.logger.debug(`Default locale is: ${defaultLocale.locale}`);\n\n // // Get hold of the repository for the current model\n // const solidRegistry = await this.moduleRef.get(SolidRegistry, { strict: false });\n // const currentEntityTarget = solidRegistry.getEntityTarget(this.entityManager, classify(modelName));\n // const currentEntityRepository = this.entityManager.getRepository(currentEntityTarget);\n\n // // We are in edit mode, the id that is being edited could be a record tagged with the default locale or it could be tagged with a non-default locale.\n // const entityRecord = await currentEntityRepository.findOne({\n // where: {\n // id: id,\n // }\n // });\n // if(entityRecord){\n // // Resolve the default entity locale id....\n // let defaultEntityLocaleId = null;\n // if (entityRecord.localeName === defaultLocale.locale) {\n // defaultEntityLocaleId = entityRecord.id;\n // this.logger.debug(`You are editing a record tagged with the default locale: ${entityRecord.localeName}.`);\n // }\n // else {\n // defaultEntityLocaleId = entityRecord.defaultEntityLocaleId;\n // this.logger.debug(`You are editing a record tagged with the non-default locale: ${entityRecord.localeName}. `);\n // }\n // this.logger.debug(`Identified default Entity Locale Id: ${defaultEntityLocaleId}`);\n\n // // Now we query for all records in the same model matching the defaultEntityLocaleId\n // // Get all records mathcing the defaultEntityLocaleId or where the id is same as the defaultEntityLocaleId\n // const entityRecordsInAllLocales = await currentEntityRepository.find({\n // where: [\n // { defaultEntityLocaleId: defaultEntityLocaleId },\n // { id: defaultEntityLocaleId }\n // ],\n // });\n // this.logger.debug(`Found ${entityRecordsInAllLocales.length} records in all locales for the defaultEntityLocaleId: ${defaultEntityLocaleId}`);\n\n // // Loop over all locales and populate the applicableLocales array\n // for (const locale of allLocales) {\n // // Find the record in the entityRecordsInAllLocales that matches the current locale\n // const matchingRecord = entityRecordsInAllLocales.find(record => record.localeName === locale.locale);\n\n // applicableLocales.push({\n // locale: locale.locale,\n // displayName: locale.displayName,\n // isDefault: locale.isDefault ? 'yes' : 'no',\n // defaultEntityLocaleId: defaultEntityLocaleId,\n // entityId: (matchingRecord ? matchingRecord.id : null)\n // });\n // }\n // }else{\n // this.logger.warn(`No record found for id: ${id} in model: ${modelName}. Cannot determine applicable locales.`);\n // }\n // }\n // }\n if (entity.model.internationalisation) {\n const defaultEntityLocaleIdFromQuery = query?.defaultEntityLocaleId;\n const { records: entityRecordsInAllLocales, defaultEntityLocaleId } =\n await this.getEntityRecordsInAllLocales(modelName, id, defaultEntityLocaleIdFromQuery);\n const allLocales = await this.entityManager.getRepository(Locale).find({});\n for (const locale of allLocales) {\n const matchingRecord = entityRecordsInAllLocales.find(record => record.localeName === locale.locale);\n applicableLocales.push({\n locale: locale.locale,\n displayName: locale.displayName,\n isDefault: locale.isDefault ? 'yes' : 'no',\n defaultEntityLocaleId: defaultEntityLocaleId,\n entityId: matchingRecord ? matchingRecord.id : null\n });\n }\n }\n\n const r = {\n 'solidView': entity,\n 'solidFieldsMetadata': Object.fromEntries(fieldsMap),\n 'solidFormViewWorkflowData': solidFormViewWorkflowData,\n 'applicableLocales': applicableLocales\n }\n\n return r;\n }\n\n private async loadFieldHierarchy(modelName: any) {\n const model = await this.modelMetadataRepo.findOne({\n where: {\n singularName: modelName,\n },\n relations: {\n fields: true,\n parentModel: {\n fields: true,\n }\n }\n });\n const fields = [];\n if (model) {\n // Add the fields of the current model\n fields.push(...model.fields);\n\n // Add the fields of the parent model\n if (model.parentModel) {\n fields.push(...model.parentModel.fields);\n }\n }\n return fields;\n }\n\n async findOneByUserKey(name: string, relations = {}) {\n const entity = await this.repo.findOne({\n where: {\n name: name,\n },\n relations: relations,\n });\n return entity;\n }\n\n async upsert(updateSolidViewDto: UpdateViewMetadataDto) {\n // First check if module already exists using name\n const existingSolidView = await this.findOneByUserKey(updateSolidViewDto.name);\n\n // if found\n if (existingSolidView) {\n const updatedSolidViewDto = { ...existingSolidView, ...updateSolidViewDto };\n return this.repo.save(updatedSolidViewDto);\n }\n // if not found - create new \n else {\n const viewData = this.repo.create(updateSolidViewDto);\n return this.repo.save(viewData);\n }\n }\n\n async createIfNotPresent(updateSolidViewDto: UpdateViewMetadataDto) {\n // First check if module already exists using name\n const existingSolidView = await this.findOneByUserKey(updateSolidViewDto.name);\n\n // if found\n if (existingSolidView) {\n }\n // if not found - create new \n else {\n const viewData = this.repo.create(updateSolidViewDto);\n return this.repo.save(viewData);\n }\n }\n\n // END: Custom Service Methods\n\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"solid-core.module.d.ts","sourceRoot":"","sources":["../src/solid-core.module.ts"],"names":[],"mappings":"AAmQA,qBAoUa,eAAe;CAAI"}
1
+ {"version":3,"file":"solid-core.module.d.ts","sourceRoot":"","sources":["../src/solid-core.module.ts"],"names":[],"mappings":"AAqQA,qBAsUa,eAAe;CAAI"}
@@ -250,6 +250,8 @@ const view_metadata_subscriber_1 = require("./subscribers/view-metadata.subscrib
250
250
  const solid_create_dashboard_widget_mcp_tool_response_handler_service_1 = require("./services/mcp-tool-response-handlers/solid-create-dashboard-widget-mcp-tool-response-handler.service");
251
251
  const solid_create_model_with_fields_mcp_tool_response_handler_service_1 = require("./services/mcp-tool-response-handlers/solid-create-model-with-fields-mcp-tool-response-handler.service");
252
252
  const solid_add_field_mcp_tool_response_handler_service_1 = require("./services/mcp-tool-response-handlers/solid-add-field-mcp-tool-response-handler.service");
253
+ const view_metadata_repository_1 = require("./repository/view-metadata.repository");
254
+ const solid_save_model_layout_mcp_tool_response_handler_service_1 = require("./services/mcp-tool-response-handlers/solid-save-model-layout-mcp-tool-response-handler.service");
253
255
  let SolidCoreModule = class SolidCoreModule {
254
256
  };
255
257
  exports.SolidCoreModule = SolidCoreModule;
@@ -534,6 +536,8 @@ exports.SolidCoreModule = SolidCoreModule = __decorate([
534
536
  solid_create_dashboard_widget_mcp_tool_response_handler_service_1.SolidCreateDashboardWidgetMcpToolResponseHandler,
535
537
  solid_create_model_with_fields_mcp_tool_response_handler_service_1.SolidCreateModelWithFieldsMcpToolResponseHandler,
536
538
  solid_add_field_mcp_tool_response_handler_service_1.SolidAddFieldMcpToolResponseHandler,
539
+ view_metadata_repository_1.ViewMetadataRepository,
540
+ solid_save_model_layout_mcp_tool_response_handler_service_1.SolidCreateModelLayoutMcpToolResponseHandler,
537
541
  ],
538
542
  exports: [
539
543
  module_metadata_service_1.ModuleMetadataService,