@solidstarters/solid-core 1.2.146 → 1.2.149
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/common.config.d.ts +10 -0
- package/dist/config/common.config.d.ts.map +1 -1
- package/dist/config/common.config.js +5 -0
- package/dist/config/common.config.js.map +1 -1
- package/dist/controllers/ai-interaction.controller.d.ts +1 -1
- package/dist/controllers/ai-interaction.controller.js +1 -1
- package/dist/dtos/create-ai-interaction.dto.d.ts +3 -0
- package/dist/dtos/create-ai-interaction.dto.d.ts.map +1 -1
- package/dist/dtos/create-ai-interaction.dto.js +20 -1
- package/dist/dtos/create-ai-interaction.dto.js.map +1 -1
- package/dist/dtos/update-ai-interaction.dto.d.ts +3 -0
- package/dist/dtos/update-ai-interaction.dto.d.ts.map +1 -1
- package/dist/dtos/update-ai-interaction.dto.js +19 -1
- package/dist/dtos/update-ai-interaction.dto.js.map +1 -1
- package/dist/entities/ai-interaction.entity.d.ts +3 -0
- package/dist/entities/ai-interaction.entity.d.ts.map +1 -1
- package/dist/entities/ai-interaction.entity.js +17 -1
- package/dist/entities/ai-interaction.entity.js.map +1 -1
- package/dist/helpers/environment.helper.d.ts +2 -0
- package/dist/helpers/environment.helper.d.ts.map +1 -0
- package/dist/helpers/environment.helper.js +11 -0
- package/dist/helpers/environment.helper.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/interfaces.d.ts +5 -5
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/interfaces.js.map +1 -1
- package/dist/jobs/database/api-email-subscriber-database.service.d.ts +3 -1
- package/dist/jobs/database/api-email-subscriber-database.service.d.ts.map +1 -1
- package/dist/jobs/database/api-email-subscriber-database.service.js +6 -3
- package/dist/jobs/database/api-email-subscriber-database.service.js.map +1 -1
- package/dist/jobs/database/computed-field-evaluation-subscriber.service.d.ts +3 -1
- package/dist/jobs/database/computed-field-evaluation-subscriber.service.d.ts.map +1 -1
- package/dist/jobs/database/computed-field-evaluation-subscriber.service.js +6 -3
- package/dist/jobs/database/computed-field-evaluation-subscriber.service.js.map +1 -1
- package/dist/jobs/database/generate-code-subscriber-database.service.d.ts +3 -1
- package/dist/jobs/database/generate-code-subscriber-database.service.d.ts.map +1 -1
- package/dist/jobs/database/generate-code-subscriber-database.service.js +6 -3
- package/dist/jobs/database/generate-code-subscriber-database.service.js.map +1 -1
- package/dist/jobs/database/otp-subscriber-database.service.d.ts +3 -1
- package/dist/jobs/database/otp-subscriber-database.service.d.ts.map +1 -1
- package/dist/jobs/database/otp-subscriber-database.service.js +5 -2
- package/dist/jobs/database/otp-subscriber-database.service.js.map +1 -1
- package/dist/jobs/database/sms-subscriber-database.service.d.ts +4 -2
- package/dist/jobs/database/sms-subscriber-database.service.d.ts.map +1 -1
- package/dist/jobs/database/sms-subscriber-database.service.js +7 -4
- package/dist/jobs/database/sms-subscriber-database.service.js.map +1 -1
- package/dist/jobs/database/smtp-email-subscriber-database.service.d.ts +4 -2
- package/dist/jobs/database/smtp-email-subscriber-database.service.d.ts.map +1 -1
- package/dist/jobs/database/smtp-email-subscriber-database.service.js +6 -3
- package/dist/jobs/database/smtp-email-subscriber-database.service.js.map +1 -1
- package/dist/jobs/database/test-queue-subscriber-database.service.d.ts +3 -1
- package/dist/jobs/database/test-queue-subscriber-database.service.d.ts.map +1 -1
- package/dist/jobs/database/test-queue-subscriber-database.service.js +6 -3
- package/dist/jobs/database/test-queue-subscriber-database.service.js.map +1 -1
- package/dist/jobs/database/trigger-mcp-client-subscriber-database.service.d.ts +3 -1
- 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 +7 -2
- package/dist/jobs/database/trigger-mcp-client-subscriber-database.service.js.map +1 -1
- package/dist/jobs/database/twilio-sms-publisher-database.service.d.ts +11 -0
- package/dist/jobs/database/twilio-sms-publisher-database.service.d.ts.map +1 -0
- package/dist/jobs/database/twilio-sms-publisher-database.service.js +39 -0
- package/dist/jobs/database/twilio-sms-publisher-database.service.js.map +1 -0
- package/dist/jobs/database/twilio-sms-queue-database-options.d.ts +8 -0
- package/dist/jobs/database/twilio-sms-queue-database-options.d.ts.map +1 -0
- package/dist/jobs/database/twilio-sms-queue-database-options.js +10 -0
- package/dist/jobs/database/twilio-sms-queue-database-options.js.map +1 -0
- package/dist/jobs/database/twilio-sms-subscriber-database.service.d.ts +17 -0
- package/dist/jobs/database/twilio-sms-subscriber-database.service.d.ts.map +1 -0
- package/dist/jobs/database/twilio-sms-subscriber-database.service.js +48 -0
- package/dist/jobs/database/twilio-sms-subscriber-database.service.js.map +1 -0
- package/dist/jobs/database/whatsapp-subscriber-database.service.d.ts +3 -1
- package/dist/jobs/database/whatsapp-subscriber-database.service.d.ts.map +1 -1
- package/dist/jobs/database/whatsapp-subscriber-database.service.js +6 -3
- package/dist/jobs/database/whatsapp-subscriber-database.service.js.map +1 -1
- package/dist/jobs/sms-subscriber.service.d.ts +1 -1
- package/dist/jobs/sms-subscriber.service.js +1 -1
- package/dist/jobs/sms-subscriber.service.js.map +1 -1
- package/dist/jobs/smtp-email-subscriber.service.d.ts +1 -1
- package/dist/seeders/module-metadata-seeder.service.d.ts +1 -1
- package/dist/seeders/module-metadata-seeder.service.d.ts.map +1 -1
- package/dist/seeders/module-metadata-seeder.service.js +15 -4
- package/dist/seeders/module-metadata-seeder.service.js.map +1 -1
- package/dist/seeders/seed-data/solid-core-metadata.json +83 -3
- package/dist/services/ai-interaction.service.d.ts +1 -1
- package/dist/services/ai-interaction.service.d.ts.map +1 -1
- package/dist/services/ai-interaction.service.js +5 -1
- package/dist/services/ai-interaction.service.js.map +1 -1
- package/dist/services/mail/smtp-email.service.d.ts +4 -4
- package/dist/services/mail/smtp-email.service.d.ts.map +1 -1
- package/dist/services/mail/smtp-email.service.js +12 -8
- package/dist/services/mail/smtp-email.service.js.map +1 -1
- package/dist/services/mq-message.service.d.ts +9 -0
- package/dist/services/mq-message.service.d.ts.map +1 -1
- package/dist/services/mq-message.service.js +61 -0
- package/dist/services/mq-message.service.js.map +1 -1
- package/dist/services/poller.service.d.ts +24 -0
- package/dist/services/poller.service.d.ts.map +1 -0
- package/dist/services/poller.service.js +131 -0
- package/dist/services/poller.service.js.map +1 -0
- package/dist/services/queues/database-subscriber.service.d.ts +4 -1
- package/dist/services/queues/database-subscriber.service.d.ts.map +1 -1
- package/dist/services/queues/database-subscriber.service.js +13 -13
- package/dist/services/queues/database-subscriber.service.js.map +1 -1
- package/dist/services/sms/Msg91BaseSMSService.d.ts +2 -2
- package/dist/services/sms/Msg91BaseSMSService.d.ts.map +1 -1
- package/dist/services/sms/Msg91BaseSMSService.js.map +1 -1
- package/dist/services/sms/Msg91OTPService.d.ts +1 -1
- package/dist/services/sms/Msg91OTPService.d.ts.map +1 -1
- package/dist/services/sms/Msg91OTPService.js.map +1 -1
- package/dist/services/sms/Msg91SMSService.d.ts +1 -1
- package/dist/services/sms/Msg91SMSService.d.ts.map +1 -1
- package/dist/services/sms/Msg91SMSService.js.map +1 -1
- package/dist/services/sms/TwilioSMSService.d.ts +18 -0
- package/dist/services/sms/TwilioSMSService.d.ts.map +1 -0
- package/dist/services/sms/TwilioSMSService.js +115 -0
- package/dist/services/sms/TwilioSMSService.js.map +1 -0
- package/dist/solid-core.module.d.ts.map +1 -1
- package/dist/solid-core.module.js +11 -0
- package/dist/solid-core.module.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -3
- package/src/config/common.config.ts +5 -0
- package/src/dtos/create-ai-interaction.dto.ts +16 -5
- package/src/dtos/update-ai-interaction.dto.ts +16 -5
- package/src/entities/ai-interaction.entity.ts +11 -3
- package/src/helpers/environment.helper.ts +7 -0
- package/src/index.ts +5 -0
- package/src/interfaces.ts +5 -5
- package/src/jobs/database/api-email-subscriber-database.service.ts +3 -1
- package/src/jobs/database/computed-field-evaluation-subscriber.service.ts +4 -2
- package/src/jobs/database/generate-code-subscriber-database.service.ts +3 -1
- package/src/jobs/database/otp-subscriber-database.service.ts +3 -1
- package/src/jobs/database/sms-subscriber-database.service.ts +4 -2
- package/src/jobs/database/smtp-email-subscriber-database.service.ts +3 -1
- package/src/jobs/database/test-queue-subscriber-database.service.ts +3 -1
- package/src/jobs/database/trigger-mcp-client-subscriber-database.service.ts +5 -1
- package/src/jobs/database/twilio-sms-publisher-database.service.ts +23 -0
- package/src/jobs/database/twilio-sms-queue-database-options.ts +9 -0
- package/src/jobs/database/twilio-sms-subscriber-database.service.ts +32 -0
- package/src/jobs/database/whatsapp-subscriber-database.service.ts +3 -1
- package/src/jobs/sms-subscriber.service.ts +1 -1
- package/src/seeders/module-metadata-seeder.service.ts +18 -15
- package/src/seeders/seed-data/solid-core-metadata.json +83 -3
- package/src/services/ai-interaction.service.ts +8 -3
- package/src/services/mail/smtp-email.service.ts +18 -17
- package/src/services/mq-message.service.ts +116 -0
- package/src/services/poller.service.ts +163 -0
- package/src/services/queues/database-subscriber.service.ts +39 -12
- package/src/services/sms/Msg91BaseSMSService.ts +2 -2
- package/src/services/sms/Msg91OTPService.ts +1 -1
- package/src/services/sms/Msg91SMSService.ts +1 -1
- package/src/services/sms/TwilioSMSService.ts +118 -0
- package/src/solid-core.module.ts +14 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module-metadata-seeder.service.js","sourceRoot":"","sources":["../../src/seeders/module-metadata-seeder.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA4D;AAC5D,uCAAyB;AACzB,2CAA6B;AAE7B,sFAA4D;AAG5D,iFAA4E;AAE5E,+EAA0E;AAC1E,iHAA0G;AAC1G,+EAA0E;AAC1E,2DAAwD;AACxD,+EAA4E;AAC5E,+HAAuH;AAEvH,+EAA2E;AAC3E,2EAAuE;AAEvE,6EAAwE;AACxE,iFAA4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AA2B;IADvC,IAAA,mBAAU,GAAE;IAmBJ,YAAA,IAAA,0BAAgB,EAAC,+CAAkB,CAAC,CAAA;IAGpC,YAAA,IAAA,eAAM,EAAC,4BAAgB,CAAC,GAAG,CAAC,CAAA;IAE5B,YAAA,IAAA,eAAM,EAAC,sBAAS,CAAC,GAAG,CAAC,CAAA;IACrB,YAAA,IAAA,eAAM,EAAC,uBAAY,CAAC,GAAG,CAAC,CAAA;IAGxB,YAAA,IAAA,0BAAgB,EAAC,wBAAO,EAAE,SAAS,CAAC,CAAA;qCAvBG,+CAAqB;QACtB,6CAAoB;QACpB,6CAAoB;QACL,6EAAmC;QAC3D,2CAAmB;QACnB,0BAAW;QACD,8CAAqB;QACxB,+CAAqB;QACnB,oDAAuB;QAC3B,2CAAmB;QACF,0FAAyC;QACtD,6CAAoB;QACtB,yCAAkB;QACjB,4CAAmB;QAExB,oBAAU;QACX,8BAAa,0BAMZ,gCAAc;QAExB,oBAAU;QACN,iDAAsB;QACb,wDAAyB;QACrC,0CAAmB;GA/BtC,2BAA2B,CAgiBvC","sourcesContent":["import { Inject, Injectable, Logger } from '@nestjs/common';\nimport * as fs from 'fs';\nimport * as path from 'path';\n\nimport appBuilderConfig from '../config/app-builder.config';\nimport { ConfigType } from '@nestjs/config';\nimport { CreateModuleMetadataDto } from '../dtos/create-module-metadata.dto';\nimport { ModuleMetadataService } from '../services/module-metadata.service';\nimport { CreateModelMetadataDto } from '../dtos/create-model-metadata.dto';\nimport { ModelMetadataService } from '../services/model-metadata.service';\nimport { MediaStorageProviderMetadataService } from '../services/media-storage-provider-metadata.service';\nimport { FieldMetadataService } from '../services/field-metadata.service';\nimport { UserService } from 'src/services/user.service';\nimport { AuthenticationService } from 'src/services/authentication.service';\nimport { MediaStorageProviderMetadataSeederService } from '../services/media-storage-provider-metadata-seeder.service';\nimport { CreateEmailTemplateDto } from 'src/dtos/create-email-template.dto';\nimport { EmailTemplateService } from 'src/services/email-template.service';\nimport { SmsTemplateService } from 'src/services/sms-template.service';\nimport { CreateSmsTemplateDto } from 'src/dtos/create-sms-template.dto';\nimport { ViewMetadataService } from '../services/view-metadata.service';\nimport { ActionMetadataService } from '../services/action-metadata.service';\nimport { MenuItemMetadataService } from '../services/menu-item-metadata.service';\nimport { InjectRepository } from '@nestjs/typeorm';\nimport { PermissionMetadata } from '../entities/permission-metadata.entity';\nimport { Repository } from 'typeorm';\nimport { SolidRegistry } from '../helpers/solid-registry';\nimport { RoleMetadataService } from '../services/role-metadata.service';\nimport { getCoreModuleNames, getDynamicModuleNames } from '../helpers/module.helper';\nimport solidCoreMetadata from './seed-data/solid-core-metadata.json';\nimport { iamConfig } from 'src/config/iam.config';\nimport commonConfig from 'src/config/common.config';\nimport { CreateSettingDto } from 'src/dtos/create-setting.dto';\nimport { SettingService } from 'src/services/setting.service';\nimport { Setting } from 'src/entities/setting.entity';\nimport { CreateSecurityRuleDto } from 'src/dtos/create-security-rule.dto';\nimport { SecurityRuleRepository } from 'src/repository/security-rule.repository';\nimport { ListOfValuesService } from 'src/services/list-of-values.service';\nimport { CreateListOfValuesDto } from 'src/dtos/create-list-of-values.dto';\nimport { SystemFieldsSeederService } from './system-fields-seeder.service';\nimport { CreateDashboardDto } from 'src/dtos/create-dashboard.dto';\nimport { DashboardRepository } from 'src/repository/dashboard.repository';\n\n@Injectable()\nexport class ModuleMetadataSeederService {\n private readonly logger = new Logger(ModuleMetadataSeederService.name);\n\n constructor(\n private readonly moduleMetadataService: ModuleMetadataService,\n private readonly modelMetadataService: ModelMetadataService,\n private readonly fieldMetadataService: FieldMetadataService,\n private readonly mediaStorageProviderMetadataService: MediaStorageProviderMetadataService,\n private readonly roleService: RoleMetadataService,\n private readonly userService: UserService,\n private readonly authenticationService: AuthenticationService,\n private readonly solidActionService: ActionMetadataService,\n private readonly solidMenuItemService: MenuItemMetadataService,\n private readonly solidViewService: ViewMetadataService,\n private readonly mediaStorageProviderSeederService: MediaStorageProviderMetadataSeederService,\n private readonly emailTemplateService: EmailTemplateService,\n private readonly smsTemplateService: SmsTemplateService,\n private readonly listOfValuesService: ListOfValuesService,\n @InjectRepository(PermissionMetadata)\n private readonly permissionRepo: Repository<PermissionMetadata>,\n private readonly solidRegistry: SolidRegistry,\n @Inject(appBuilderConfig.KEY)\n private readonly appBuilderConfiguration: ConfigType<typeof appBuilderConfig>,\n @Inject(iamConfig.KEY) private readonly iamConfiguration: ConfigType<typeof iamConfig>,\n @Inject(commonConfig.KEY)\n private readonly commonConfiguration: ConfigType<typeof commonConfig>,\n private readonly seetingService: SettingService,\n @InjectRepository(Setting, 'default')\n readonly settingsRepo: Repository<Setting>,\n readonly securityRuleRepo: SecurityRuleRepository,\n readonly systemFieldsSeederService: SystemFieldsSeederService,\n readonly dashboardRepo: DashboardRepository,\n ) { }\n\n async seed() {\n\n const typedSolidCoreMetadata: any = structuredClone(solidCoreMetadata);\n\n // Run the permissions seeder. \n // await this.permissionsSeederService.seed();\n this.logger.log(`Seeding permissions`);\n await this.seedPermissions();\n\n // TODO: move this also the main loop processing. Generate the media storage providers required by default\n this.logger.log(`Seeding media storage providers`);\n await this.mediaStorageProviderSeederService.seed();\n\n // Seed any missing system fields metadata for all models.\n this.logger.log(`Seeding system fields metadata`);\n await this.systemFieldsSeederService.seed();\n\n // Read the module metadata from a file specified in the .env \n // Add the core json file as the first entry in the above array.\n // Please note the sequence of core files is important below...\n const coreModules = getCoreModuleNames();\n const seedDataFiles = [\n // 'src/common/seeders/seed-data/common-metadata.json',\n // 'src/iam/seeders/seed-data/iam-metadata.json',\n // 'src/app-builder/seeders/seed-data/app-builder-metadata.json',\n // 'src/queues/seeders/seed-data/queues-metadata.json',\n // ...coreModules.map(module => `src/${module}/seeders/seed-data/${module}-metadata.json`),\n typedSolidCoreMetadata\n ];\n this.logger.debug(`getting dynamics modules`);\n const enabledModules = getDynamicModuleNames();\n this.logger.log(`Seeding metadata`);\n\n for (let i = 0; i < enabledModules.length; i++) {\n const enabledModule = enabledModules[i];\n const enabledModuleSeedFile = `module-metadata/${enabledModule}/${enabledModule}-metadata.json`\n const fullPath = path.join(process.cwd(), enabledModuleSeedFile);\n if (fs.existsSync(fullPath)) {\n const overallMetadata: any = JSON.parse(fs.readFileSync(fullPath, 'utf-8').toString());\n\n seedDataFiles.push(overallMetadata)\n }\n }\n\n this.logger.debug(`Seed data files are: ${seedDataFiles}`);\n let usersDetail;\n for (let i = 0; i < seedDataFiles.length; i++) {\n\n // Module, model & field handling.\n const overallMetadata = seedDataFiles[i];\n // const fullPath = path.join(process.cwd(), seedDataFile);\n\n // For each module metadata seed file provided, read contents, parse & convert to a variable. \n // this.logger.log(`[Start] module seed data: ${fullPath}`);\n\n // const overallMetadata: any = JSON.parse(fs.readFileSync(fullPath, 'utf-8').toString());\n\n // Process module metadata first. \n const moduleMetadata: CreateModuleMetadataDto = overallMetadata.moduleMetadata;\n this.logger.log(`[Start] Processing module metadata for ${moduleMetadata.name}`)\n await this.seedModuleModelFields(moduleMetadata);\n this.logger.log(`[End] Processing module metadata for ${moduleMetadata.name}`)\n\n // Media Storage provider templates\n this.logger.log(`[Start] Processing Media Storage Provider for ${moduleMetadata.name}`);\n const mediaStorageProviders = overallMetadata.mediaStorageProviders;\n await this.seedMediaStorageProviders(mediaStorageProviders);\n this.logger.log(`[End] Processing Media Storage Provider for ${moduleMetadata.name}`);\n\n // Custom role handling\n this.logger.log(`[End] Processing roles for ${moduleMetadata.name}`)\n const roles = overallMetadata.roles;\n\n // Every role configuration in the seeder json can optionally have a permissions attribute. \n // While creating roles we are only passing the role name to be used. \n await this.roleService.createRolesIfNotExists(roles.map(role => { return { name: role.name } }));\n\n // After roles are created, we iterate over all roles and attach permissions (if specified in the seeder json) to the respective role.\n for (let roleI = 0; roleI < roles.length; roleI++) {\n const role = roles[roleI];\n if (role.permissions) {\n await this.roleService.addPermissionsToRole(role.name, role.permissions)\n }\n }\n this.logger.log(`[End] Processing roles for ${moduleMetadata.name}`)\n\n // Custom user handling\n this.logger.log(`[Start] Processing users for ${moduleMetadata.name}`);\n const users = overallMetadata.users;\n usersDetail = users;\n await this.seedUsers(users);\n this.logger.log(`[End] Processing users for ${moduleMetadata.name}`)\n\n // Application Module View handling \n this.logger.log(`[Start] Processing views for ${moduleMetadata.name}`);\n const views = overallMetadata.views;\n await this.seedViews(views);\n this.logger.log(`[End] Processing views for ${moduleMetadata.name}`)\n\n // Application Module Action handling\n this.logger.log(`[Start] Processing actions for ${moduleMetadata.name}`);\n const actions = overallMetadata.actions;\n await this.seedActions(actions);\n this.logger.log(`[End] Processing actions for ${moduleMetadata.name}`)\n\n // Application Module Menu handling \n this.logger.log(`[Start] Processing menus for ${moduleMetadata.name}`);\n const menus = overallMetadata.menus;\n await this.seedMenus(menus);\n this.logger.log(`[End] Processing menus for ${moduleMetadata.name}`)\n\n // Email templates \n this.logger.log(`[Start] Processing email templates for ${moduleMetadata.name}`);\n const emailTemplates: CreateEmailTemplateDto[] = overallMetadata.emailTemplates;\n await this.seedEmailTemplates(emailTemplates, moduleMetadata);\n this.logger.log(`[End] Processing email templates for ${moduleMetadata.name}`);\n\n // Sms templates\n this.logger.log(`[Start] Processing sms templates for ${moduleMetadata.name}`);\n const smsTemplates: CreateSmsTemplateDto[] = overallMetadata.smsTemplates;\n await this.seedSmsTemplates(smsTemplates);\n this.logger.log(`[End] Processing sms templates for ${moduleMetadata.name}`);\n\n // Settings\n this.logger.log(`[Start] Processing settings for ${moduleMetadata.name}`);\n await this.seetingService.seedDefaultSettings();\n this.logger.log(`[End] Processing settings for ${moduleMetadata.name}`);\n\n // Security rules\n this.logger.log(`[Start] Processing security rules for ${moduleMetadata.name}`);\n const securityRules: CreateSecurityRuleDto[] = overallMetadata.securityRules;\n await this.seedSecurityRules(securityRules);\n this.logger.log(`[End] Processing security rules for ${moduleMetadata.name}`);\n\n // List Of Values\n this.logger.log(`[Start] Processing List Of Values for ${moduleMetadata.name}`);\n const listOfValues: CreateListOfValuesDto[] = overallMetadata.listOfValues;\n await this.seedListOfValues(listOfValues);\n this.logger.log(`[End] Processing List Of Values for ${moduleMetadata.name}`);\n\n // Dashboards\n this.logger.log(`[Start] Processing dashboards for ${moduleMetadata.name}`);\n const dashboards: CreateDashboardDto[] = overallMetadata.dashboards;\n await this.seedDashboards(dashboards);\n this.logger.log(`[End] Processing dashboards for ${moduleMetadata.name}`);\n\n\n this.logger.debug(`[End] module seed data: ${overallMetadata}`);\n\n }\n\n // Post seed data file processing. \n\n // 1. Give all permissions to the Admin role.\n this.logger.log(`About to add all permissions to the Admin role`);\n await this.roleService.addAllPermissionsToRole(\"Admin\");\n // 2. Give wrapSettings permissions to the Public role.\n const internalRolePermission = [\n 'UserController.findMany',\n 'UserController.checkIfPermissionExists',\n 'UserController.findOne',\n 'MenuItemMetadataController.findMany',\n 'MenuItemMetadataController.findUserMenus',\n 'MenuItemMetadataController.findOne',\n 'ViewMetadataController.getLayout',\n 'ViewMetadataController.findMany',\n 'ViewMetadataController.findOne',\n 'AuthenticationController.changePassword',\n 'FieldMetadataController.getSelectionDynamicValues',\n 'FieldMetadataController.getSelectionDynamicValue',\n 'FieldMetadataController.findFieldDefaultMetaData',\n 'SavedFiltersController.delete',\n 'SavedFiltersController.deleteMany',\n 'SavedFiltersController.findOne',\n 'SavedFiltersController.findMany',\n 'SavedFiltersController.recover',\n 'SavedFiltersController.recoverMany',\n 'SavedFiltersController.partialUpdate',\n 'SavedFiltersController.update',\n 'SavedFiltersController.insertMany',\n 'SavedFiltersController.create',\n 'AuthenticationController.logout'\n ]\n await this.roleService.addPermissionToRole('Internal User', internalRolePermission);\n await this.roleService.addPermissionToRole('Public', ['SettingController.wrapSettings','AuthenticationController.logout']);\n this.logger.log(`All Seeders finished`);\n this.logger.log(`Newly created username is: ${usersDetail?.length > 0 ? usersDetail[0]?.username : ''} and password is ${usersDetail?.length > 0 ? usersDetail[0]?.password : ''}`);\n }\n\n\n async seedPermissions() {\n\n const controllers = this.solidRegistry.getControllers();\n\n // Loop over the countries and create them.\n for (let id = 0; id < controllers.length; id++) {\n try {\n const controller = controllers[id];\n this.logger.log(`Resolving controller: ${controller.name}`);\n\n const methods = controller.methods;\n for (let mId = 0; mId < methods.length; mId++) {\n\n const methodName = methods[mId];\n const permissionName = `${controller.name}.${methodName}`;\n\n const existingPermission = await this.permissionRepo.findOne({\n where: {\n name: permissionName\n }\n });\n\n if (existingPermission) {\n this.logger.log(`Permission ${permissionName} already exists.`);\n }\n else {\n this.logger.log(`Permission ${permissionName} does not exist, creating new.`);\n\n const newPermission = this.permissionRepo.create({\n name: permissionName\n });\n await this.permissionRepo.save(newPermission);\n\n }\n }\n\n } catch (error) {\n this.logger.error(error);\n }\n }\n }\n\n async seedMediaStorageProviders(mediaStorageProviders: any) {\n for (let i = 0; i < mediaStorageProviders.length; i++) {\n const mediaStorageProivder = mediaStorageProviders[i];\n await this.mediaStorageProviderMetadataService.upsert(mediaStorageProivder);\n }\n }\n\n async seedEmailTemplates(emailTemplates: CreateEmailTemplateDto[], moduleMetadata: CreateModuleMetadataDto) {\n if (!emailTemplates) {\n return;\n }\n\n for (let i = 0; i < emailTemplates.length; i++) {\n const emailTemplate = emailTemplates[i];\n this.logger.log(`Found ${emailTemplate.name} email template`);\n\n // We need to load the actual template contents. \n if (moduleMetadata.name === 'solid-core') {\n const modulePath = path.dirname(require.resolve('@solidstarters/solid-core'));\n const seedDataPath = path.join(modulePath, '../src/seeders/seed-data/email-templates');\n const filePath = path.join(seedDataPath, emailTemplate.body);\n this.logger.log(`Seeding email template from solid-core at path: ${filePath}`);\n if (fs.existsSync(filePath)) {\n emailTemplate.body = fs.readFileSync(filePath, 'utf-8').toString();\n }\n }\n else {\n // Check if file exists\n const emailTemplateHandlebar = `module-metadata/${moduleMetadata.name}/email-templates/${emailTemplate.body}`\n const fullPath = path.join(process.cwd(), emailTemplateHandlebar);\n this.logger.log(`Seeding custom email template from consuming model at path: ${fullPath}`);\n if (fs.existsSync(fullPath)) {\n emailTemplate.body = fs.readFileSync(fullPath, 'utf-8').toString();\n }\n }\n\n // Save to DB.\n await this.emailTemplateService.removeByName(emailTemplate.name);\n await this.emailTemplateService.create(emailTemplate);\n }\n\n }\n\n async seedSmsTemplates(smsTemplates: CreateSmsTemplateDto[]) {\n if (!smsTemplates) {\n return;\n }\n\n for (let i = 0; i < smsTemplates.length; i++) {\n const smsTemplate = smsTemplates[i];\n this.logger.log(`Found ${smsTemplate.name} sms template`);\n\n // We need to load the actual template contents. \n if (smsTemplate.body) {\n // const smsTemplateFilePath = path.join(process.cwd(), smsTemplate.body);\n // smsTemplate.body = fs.readFileSync(smsTemplateFilePath, 'utf-8').toString()\n\n const modulePath = path.dirname(require.resolve('@solidstarters/solid-core'));\n\n // Resolve the `src` folder\n const seedDataPath = path.join(modulePath, '../src/seeders/seed-data/sms-templates');\n\n // Example usage\n const filePath = path.join(seedDataPath, smsTemplate.body);\n\n\n smsTemplate.body = fs.readFileSync(filePath, 'utf-8').toString();\n\n }\n\n // Save to DB.\n await this.smsTemplateService.removeByName(smsTemplate.name);\n await this.smsTemplateService.create(smsTemplate);\n }\n }\n\n async seedMenus(menus: any) {\n if (!menus) {\n return;\n }\n\n for (let j = 0; j < menus.length; j++) {\n const menuData = menus[j];\n\n const adminRole = await this.roleService.findRoleByName('Admin');\n\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.solidActionService.findOneByUserKey(menuData.actionUserKey);\n menuData['module'] = await this.moduleMetadataService.findOneByUserKey(menuData.moduleUserKey);\n\n if (menuData.parentMenuItemUserKey) {\n menuData['parentMenuItem'] = await this.solidMenuItemService.findOneByUserKey(menuData.parentMenuItemUserKey);\n } else {\n menuData['parentMenuItem'] = null\n }\n await this.solidMenuItemService.upsert(menuData);\n }\n }\n\n async seedActions(actions: any) {\n if (!actions) {\n return;\n }\n\n for (let j = 0; j < actions.length; j++) {\n const actionData = actions[j];\n actionData['module'] = await this.moduleMetadataService.findOneByUserKey(actionData.moduleUserKey);\n if (actionData.type === 'solid') {\n actionData['model'] = await this.modelMetadataService.findOneByUserKey(actionData.modelUserKey);\n actionData['view'] = await this.solidViewService.findOneByUserKey(actionData.viewUserKey);\n }\n else {\n if (actionData.modelUserKey) {\n actionData['model'] = await this.modelMetadataService.findOneByUserKey(actionData.modelUserKey);\n }\n }\n await this.solidActionService.upsert(actionData);\n }\n }\n\n async seedViews(views: any) {\n if (!views) {\n return;\n }\n\n for (let j = 0; j < views.length; j++) {\n const viewData = views[j];\n\n // preety format the layout & context. \n viewData['layout'] = JSON.stringify(viewData['layout'], null, 2);\n // viewData['context'] = JSON.stringify(viewData['context'], null, 2);\n\n viewData['module'] = await this.moduleMetadataService.findOneByUserKey(viewData.moduleUserKey);\n viewData['model'] = await this.modelMetadataService.findOneByUserKey(viewData.modelUserKey);\n // await this.solidViewService.upsert(viewData);\n // First check if module already exists using name\n\n // Changed the below to upsert as now we are saving modifications to the view json to file system also.\n // await this.solidViewService.createIfNotPresent(viewData);\n await this.solidViewService.upsert(viewData);\n }\n }\n\n async seedUsers(users) {\n if (!users) {\n return;\n }\n\n for (let l = 0; l < users.length; l++) {\n const user = users[l];\n let exisitingUser = await this.userService.findOneByUsername(user.username);\n if (!exisitingUser) {\n exisitingUser = await this.authenticationService.signUp(user);\n\n this.logger.log(`Newly created user is ${user}`);\n }\n // now add Roles to user.\n // for (let m = 0; m < roles.length; m++) {\n // const role = roles[m];\n // await this.userService.addRoleToUser(user.email, role.name);\n // }\n }\n }\n\n async seedModuleModelFields(moduleMetadata: CreateModuleMetadataDto) {\n\n // First we create the module. \n // await this.moduleMetadataService.removeByName(moduleMetadata.name);\n // const module = await this.moduleMetadataService.create(moduleMetadata);\n const module = await this.moduleMetadataService.upsert(moduleMetadata);\n\n // Next create all the models. \n const modelsMetadata: CreateModelMetadataDto[] = moduleMetadata.models;\n for (let j = 0; j < modelsMetadata.length; j++) {\n const modelMetadata = modelsMetadata[j];\n\n // Before creating the model, we need to make sure we are linking it to the newly created module.\n // modelMetdata['moduleId'] = module.id;\n modelMetadata['module'] = module;\n\n // Please note that all the fields will also get created as we have setup the relation in model.entity.ts as cascade=true\n // await this.modelMetadataService.removeBySingularName(modelMetdata.singularName);\n // await this.modelMetadataService.modelSeeder(modelMetdata);\n\n // upsert the model information.\n // const fieldsMetadata = modelMetdata.fields;\n // delete modelMetdata['fields'];\n const { fields: fieldsMetadata, ...modelMetaDataWithoutFields } = modelMetadata;\n\n // Load and set the parent model if it exists.\n if (modelMetadata.isChild && modelMetadata.parentModelUserKey) {\n const parentModel = await this.modelMetadataService.findOneByUserKey(modelMetadata.parentModelUserKey);\n modelMetaDataWithoutFields['parentModel'] = parentModel;\n }\n\n await this.modelMetadataService.upsert(modelMetaDataWithoutFields);\n const model = await this.modelMetadataService.findOneBySingularName(modelMetadata.singularName)\n\n // iterate over all fields and upsert. \n let userKeyField = null;\n const userKeyFieldName = modelMetadata.userKeyFieldUserKey;\n for (let k = 0; k < fieldsMetadata.length; k++) {\n const fieldMetadata = fieldsMetadata[k];\n\n // TODO: resolve model & mediaStorageProvider. \n fieldMetadata['model'] = model;\n if (fieldMetadata.mediaStorageProviderUserKey) {\n fieldMetadata['mediaStorageProvider'] = await this.mediaStorageProviderMetadataService.findOneByUserKey(fieldMetadata.mediaStorageProviderUserKey);\n }\n // console.log(fieldMetadata.displayName);\n\n const affectedField = await this.fieldMetadataService.upsert(fieldMetadata);\n if (fieldMetadata.name === userKeyFieldName) {\n const { model, ...fieldData } = affectedField;\n userKeyField = fieldData;\n }\n }\n\n // Now that we have created fields & model update the model to stamp the userKeyField. \n if (userKeyField) {\n modelMetaDataWithoutFields['userKeyField'] = userKeyField;\n await this.modelMetadataService.upsert(modelMetaDataWithoutFields);\n }\n }\n }\n\n async seedSettings(createDto: CreateSettingDto) {\n const settingsArray: any[] = await this.settingsRepo.find();\n if (!settingsArray || settingsArray.length === 0) {\n this.seetingService.create(createDto);\n }\n }\n\n async seedSecurityRules(rulesDto: CreateSecurityRuleDto[]) {\n if (!rulesDto || rulesDto.length === 0) {\n this.logger.debug(`No security rules found to seed`);\n return;\n }\n for (const dto of rulesDto) {\n await this.securityRuleRepo.upsertWithDto({ ...dto, securityRuleConfig: JSON.stringify(dto.securityRuleConfig) });\n }\n }\n\n async seedListOfValues(listOfValuesDto: CreateListOfValuesDto[]) {\n if (!listOfValuesDto || listOfValuesDto.length === 0) {\n this.logger.debug(`No List Of Values found to seed`);\n return;\n }\n for (let j = 0; j < listOfValuesDto.length; j++) {\n await this.listOfValuesService.upsert(listOfValuesDto);\n }\n }\n\n async seedDashboards(dashboardDtos: CreateDashboardDto[]) {\n if (!dashboardDtos || dashboardDtos.length === 0) {\n this.logger.debug(`No dashboards found to seed`);\n return;\n }\n for (const dto of dashboardDtos) {\n await this.dashboardRepo.upsertWithDto(dto);\n }\n }\n\n}"]}
|
|
1
|
+
{"version":3,"file":"module-metadata-seeder.service.js","sourceRoot":"","sources":["../../src/seeders/module-metadata-seeder.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA4D;AAC5D,uCAAyB;AACzB,2CAA6B;AAE7B,sFAA4D;AAG5D,iFAA4E;AAE5E,+EAA0E;AAC1E,iHAA0G;AAC1G,+EAA0E;AAC1E,2DAAwD;AACxD,+EAA4E;AAC5E,+HAAuH;AAEvH,+EAA2E;AAC3E,2EAAuE;AAEvE,6EAAwE;AACxE,iFAA4E;AAC5E,uFAAiF;AACjF,6CAAmD;AACnD,uFAA4E;AAC5E,qCAAqC;AACrC,8DAA0D;AAC1D,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,CAmiBvC","sourcesContent":["import { Inject, Injectable, Logger } from '@nestjs/common';\nimport * as fs from 'fs';\nimport * as path from 'path';\n\nimport appBuilderConfig from '../config/app-builder.config';\nimport { ConfigType } from '@nestjs/config';\nimport { CreateModuleMetadataDto } from '../dtos/create-module-metadata.dto';\nimport { ModuleMetadataService } from '../services/module-metadata.service';\nimport { CreateModelMetadataDto } from '../dtos/create-model-metadata.dto';\nimport { ModelMetadataService } from '../services/model-metadata.service';\nimport { MediaStorageProviderMetadataService } from '../services/media-storage-provider-metadata.service';\nimport { FieldMetadataService } from '../services/field-metadata.service';\nimport { UserService } from 'src/services/user.service';\nimport { AuthenticationService } from 'src/services/authentication.service';\nimport { MediaStorageProviderMetadataSeederService } from '../services/media-storage-provider-metadata-seeder.service';\nimport { CreateEmailTemplateDto } from 'src/dtos/create-email-template.dto';\nimport { EmailTemplateService } from 'src/services/email-template.service';\nimport { SmsTemplateService } from 'src/services/sms-template.service';\nimport { CreateSmsTemplateDto } from 'src/dtos/create-sms-template.dto';\nimport { ViewMetadataService } from '../services/view-metadata.service';\nimport { ActionMetadataService } from '../services/action-metadata.service';\nimport { MenuItemMetadataService } from '../services/menu-item-metadata.service';\nimport { InjectRepository } from '@nestjs/typeorm';\nimport { PermissionMetadata } from '../entities/permission-metadata.entity';\nimport { Repository } from 'typeorm';\nimport { SolidRegistry } from '../helpers/solid-registry';\nimport { RoleMetadataService } from '../services/role-metadata.service';\nimport { getCoreModuleNames, getDynamicModuleNames } from '../helpers/module.helper';\nimport solidCoreMetadata from './seed-data/solid-core-metadata.json';\nimport { iamConfig } from 'src/config/iam.config';\nimport commonConfig from 'src/config/common.config';\nimport { CreateSettingDto } from 'src/dtos/create-setting.dto';\nimport { SettingService } from 'src/services/setting.service';\nimport { Setting } from 'src/entities/setting.entity';\nimport { CreateSecurityRuleDto } from 'src/dtos/create-security-rule.dto';\nimport { SecurityRuleRepository } from 'src/repository/security-rule.repository';\nimport { ListOfValuesService } from 'src/services/list-of-values.service';\nimport { CreateListOfValuesDto } from 'src/dtos/create-list-of-values.dto';\nimport { SystemFieldsSeederService } from './system-fields-seeder.service';\nimport { CreateDashboardDto } from 'src/dtos/create-dashboard.dto';\nimport { DashboardRepository } from 'src/repository/dashboard.repository';\n\n@Injectable()\nexport class ModuleMetadataSeederService {\n private readonly logger = new Logger(ModuleMetadataSeederService.name);\n\n constructor(\n private readonly moduleMetadataService: ModuleMetadataService,\n private readonly modelMetadataService: ModelMetadataService,\n private readonly fieldMetadataService: FieldMetadataService,\n private readonly mediaStorageProviderMetadataService: MediaStorageProviderMetadataService,\n private readonly roleService: RoleMetadataService,\n private readonly userService: UserService,\n private readonly authenticationService: AuthenticationService,\n private readonly solidActionService: ActionMetadataService,\n private readonly solidMenuItemService: MenuItemMetadataService,\n private readonly solidViewService: ViewMetadataService,\n private readonly mediaStorageProviderSeederService: MediaStorageProviderMetadataSeederService,\n private readonly emailTemplateService: EmailTemplateService,\n private readonly smsTemplateService: SmsTemplateService,\n private readonly listOfValuesService: ListOfValuesService,\n @InjectRepository(PermissionMetadata)\n private readonly permissionRepo: Repository<PermissionMetadata>,\n private readonly solidRegistry: SolidRegistry,\n @Inject(appBuilderConfig.KEY)\n private readonly appBuilderConfiguration: ConfigType<typeof appBuilderConfig>,\n @Inject(iamConfig.KEY) private readonly iamConfiguration: ConfigType<typeof iamConfig>,\n @Inject(commonConfig.KEY)\n private readonly commonConfiguration: ConfigType<typeof commonConfig>,\n private readonly seetingService: SettingService,\n @InjectRepository(Setting, 'default')\n readonly settingsRepo: Repository<Setting>,\n readonly securityRuleRepo: SecurityRuleRepository,\n readonly systemFieldsSeederService: SystemFieldsSeederService,\n readonly dashboardRepo: DashboardRepository,\n ) { }\n\n async seed() {\n\n const typedSolidCoreMetadata: any = structuredClone(solidCoreMetadata);\n\n // Run the permissions seeder. \n // await this.permissionsSeederService.seed();\n this.logger.log(`Seeding permissions`);\n await this.seedPermissions();\n\n // TODO: move this also the main loop processing. Generate the media storage providers required by default\n this.logger.log(`Seeding media storage providers`);\n await this.mediaStorageProviderSeederService.seed();\n\n // Seed any missing system fields metadata for all models.\n this.logger.log(`Seeding system fields metadata`);\n await this.systemFieldsSeederService.seed();\n\n // Read the module metadata from a file specified in the .env \n // Add the core json file as the first entry in the above array.\n // Please note the sequence of core files is important below...\n const coreModules = getCoreModuleNames();\n const seedDataFiles = [\n // 'src/common/seeders/seed-data/common-metadata.json',\n // 'src/iam/seeders/seed-data/iam-metadata.json',\n // 'src/app-builder/seeders/seed-data/app-builder-metadata.json',\n // 'src/queues/seeders/seed-data/queues-metadata.json',\n // ...coreModules.map(module => `src/${module}/seeders/seed-data/${module}-metadata.json`),\n typedSolidCoreMetadata\n ];\n this.logger.debug(`getting dynamics modules`);\n const enabledModules = getDynamicModuleNames();\n this.logger.log(`Seeding metadata`);\n\n for (let i = 0; i < enabledModules.length; i++) {\n const enabledModule = enabledModules[i];\n const enabledModuleSeedFile = `module-metadata/${enabledModule}/${enabledModule}-metadata.json`\n const fullPath = path.join(process.cwd(), enabledModuleSeedFile);\n if (fs.existsSync(fullPath)) {\n const overallMetadata: any = JSON.parse(fs.readFileSync(fullPath, 'utf-8').toString());\n\n seedDataFiles.push(overallMetadata)\n }\n }\n\n this.logger.debug(`Seed data files are: ${seedDataFiles}`);\n let usersDetail;\n for (let i = 0; i < seedDataFiles.length; i++) {\n\n // Module, model & field handling.\n const overallMetadata = seedDataFiles[i];\n // const fullPath = path.join(process.cwd(), seedDataFile);\n\n // For each module metadata seed file provided, read contents, parse & convert to a variable. \n // this.logger.log(`[Start] module seed data: ${fullPath}`);\n\n // const overallMetadata: any = JSON.parse(fs.readFileSync(fullPath, 'utf-8').toString());\n\n // Process module metadata first. \n const moduleMetadata: CreateModuleMetadataDto = overallMetadata.moduleMetadata;\n this.logger.log(`[Start] Processing module metadata for ${moduleMetadata.name}`)\n await this.seedModuleModelFields(moduleMetadata);\n this.logger.log(`[End] Processing module metadata for ${moduleMetadata.name}`)\n\n // Media Storage provider templates\n this.logger.log(`[Start] Processing Media Storage Provider for ${moduleMetadata.name}`);\n const mediaStorageProviders = overallMetadata.mediaStorageProviders;\n await this.seedMediaStorageProviders(mediaStorageProviders);\n this.logger.log(`[End] Processing Media Storage Provider for ${moduleMetadata.name}`);\n\n // Custom role handling\n this.logger.log(`[End] Processing roles for ${moduleMetadata.name}`)\n const roles = overallMetadata.roles;\n\n // Every role configuration in the seeder json can optionally have a permissions attribute. \n // While creating roles we are only passing the role name to be used. \n await this.roleService.createRolesIfNotExists(roles.map(role => { return { name: role.name } }));\n\n // After roles are created, we iterate over all roles and attach permissions (if specified in the seeder json) to the respective role.\n for (let roleI = 0; roleI < roles.length; roleI++) {\n const role = roles[roleI];\n if (role.permissions) {\n await this.roleService.addPermissionsToRole(role.name, role.permissions)\n }\n }\n this.logger.log(`[End] Processing roles for ${moduleMetadata.name}`)\n\n // Custom user handling\n this.logger.log(`[Start] Processing users for ${moduleMetadata.name}`);\n const users = overallMetadata.users;\n usersDetail = users;\n await this.seedUsers(users);\n this.logger.log(`[End] Processing users for ${moduleMetadata.name}`)\n\n // Application Module View handling \n this.logger.log(`[Start] Processing views for ${moduleMetadata.name}`);\n const views = overallMetadata.views;\n await this.seedViews(views);\n this.logger.log(`[End] Processing views for ${moduleMetadata.name}`)\n\n // Application Module Action handling\n this.logger.log(`[Start] Processing actions for ${moduleMetadata.name}`);\n const actions = overallMetadata.actions;\n await this.seedActions(actions);\n this.logger.log(`[End] Processing actions for ${moduleMetadata.name}`)\n\n // Application Module Menu handling \n this.logger.log(`[Start] Processing menus for ${moduleMetadata.name}`);\n const menus = overallMetadata.menus;\n await this.seedMenus(menus);\n this.logger.log(`[End] Processing menus for ${moduleMetadata.name}`)\n\n // Email templates \n this.logger.log(`[Start] Processing email templates for ${moduleMetadata.name}`);\n const emailTemplates: CreateEmailTemplateDto[] = overallMetadata.emailTemplates;\n await this.seedEmailTemplates(emailTemplates, moduleMetadata);\n this.logger.log(`[End] Processing email templates for ${moduleMetadata.name}`);\n\n // Sms templates\n this.logger.log(`[Start] Processing sms templates for ${moduleMetadata.name}`);\n const smsTemplates: CreateSmsTemplateDto[] = overallMetadata.smsTemplates;\n await this.seedSmsTemplates(smsTemplates, moduleMetadata);\n this.logger.log(`[End] Processing sms templates for ${moduleMetadata.name}`);\n\n // Settings\n this.logger.log(`[Start] Processing settings for ${moduleMetadata.name}`);\n await this.seetingService.seedDefaultSettings();\n this.logger.log(`[End] Processing settings for ${moduleMetadata.name}`);\n\n // Security rules\n this.logger.log(`[Start] Processing security rules for ${moduleMetadata.name}`);\n const securityRules: CreateSecurityRuleDto[] = overallMetadata.securityRules;\n await this.seedSecurityRules(securityRules);\n this.logger.log(`[End] Processing security rules for ${moduleMetadata.name}`);\n\n // List Of Values\n this.logger.log(`[Start] Processing List Of Values for ${moduleMetadata.name}`);\n const listOfValues: CreateListOfValuesDto[] = overallMetadata.listOfValues;\n await this.seedListOfValues(listOfValues);\n this.logger.log(`[End] Processing List Of Values for ${moduleMetadata.name}`);\n\n // Dashboards\n this.logger.log(`[Start] Processing dashboards for ${moduleMetadata.name}`);\n const dashboards: CreateDashboardDto[] = overallMetadata.dashboards;\n await this.seedDashboards(dashboards);\n this.logger.log(`[End] Processing dashboards for ${moduleMetadata.name}`);\n\n\n this.logger.debug(`[End] module seed data: ${overallMetadata}`);\n\n }\n\n // Post seed data file processing. \n\n // 1. Give all permissions to the Admin role.\n this.logger.log(`About to add all permissions to the Admin role`);\n await this.roleService.addAllPermissionsToRole(\"Admin\");\n // 2. Give wrapSettings permissions to the Public role.\n const internalRolePermission = [\n 'UserController.findMany',\n 'UserController.checkIfPermissionExists',\n 'UserController.findOne',\n 'MenuItemMetadataController.findMany',\n 'MenuItemMetadataController.findUserMenus',\n 'MenuItemMetadataController.findOne',\n 'ViewMetadataController.getLayout',\n 'ViewMetadataController.findMany',\n 'ViewMetadataController.findOne',\n 'AuthenticationController.changePassword',\n 'FieldMetadataController.getSelectionDynamicValues',\n 'FieldMetadataController.getSelectionDynamicValue',\n 'FieldMetadataController.findFieldDefaultMetaData',\n 'SavedFiltersController.delete',\n 'SavedFiltersController.deleteMany',\n 'SavedFiltersController.findOne',\n 'SavedFiltersController.findMany',\n 'SavedFiltersController.recover',\n 'SavedFiltersController.recoverMany',\n 'SavedFiltersController.partialUpdate',\n 'SavedFiltersController.update',\n 'SavedFiltersController.insertMany',\n 'SavedFiltersController.create',\n 'AuthenticationController.logout'\n ]\n await this.roleService.addPermissionToRole('Internal User', internalRolePermission);\n await this.roleService.addPermissionToRole('Public', ['SettingController.wrapSettings', 'AuthenticationController.logout']);\n this.logger.log(`All Seeders finished`);\n this.logger.log(`Newly created username is: ${usersDetail?.length > 0 ? usersDetail[0]?.username : ''} and password is ${usersDetail?.length > 0 ? usersDetail[0]?.password : ''}`);\n }\n\n\n async seedPermissions() {\n\n const controllers = this.solidRegistry.getControllers();\n\n // Loop over the countries and create them.\n for (let id = 0; id < controllers.length; id++) {\n try {\n const controller = controllers[id];\n this.logger.log(`Resolving controller: ${controller.name}`);\n\n const methods = controller.methods;\n for (let mId = 0; mId < methods.length; mId++) {\n\n const methodName = methods[mId];\n const permissionName = `${controller.name}.${methodName}`;\n\n const existingPermission = await this.permissionRepo.findOne({\n where: {\n name: permissionName\n }\n });\n\n if (existingPermission) {\n this.logger.log(`Permission ${permissionName} already exists.`);\n }\n else {\n this.logger.log(`Permission ${permissionName} does not exist, creating new.`);\n\n const newPermission = this.permissionRepo.create({\n name: permissionName\n });\n await this.permissionRepo.save(newPermission);\n\n }\n }\n\n } catch (error) {\n this.logger.error(error);\n }\n }\n }\n\n async seedMediaStorageProviders(mediaStorageProviders: any) {\n for (let i = 0; i < mediaStorageProviders.length; i++) {\n const mediaStorageProivder = mediaStorageProviders[i];\n await this.mediaStorageProviderMetadataService.upsert(mediaStorageProivder);\n }\n }\n\n async seedEmailTemplates(emailTemplates: CreateEmailTemplateDto[], moduleMetadata: CreateModuleMetadataDto) {\n if (!emailTemplates) {\n return;\n }\n\n for (let i = 0; i < emailTemplates.length; i++) {\n const emailTemplate = emailTemplates[i];\n this.logger.log(`Found ${emailTemplate.name} email template`);\n\n // We need to load the actual template contents. \n if (moduleMetadata.name === 'solid-core') {\n const modulePath = path.dirname(require.resolve('@solidstarters/solid-core'));\n const seedDataPath = path.join(modulePath, '../src/seeders/seed-data/email-templates');\n const filePath = path.join(seedDataPath, emailTemplate.body);\n this.logger.log(`Seeding email template from solid-core at path: ${filePath}`);\n if (fs.existsSync(filePath)) {\n emailTemplate.body = fs.readFileSync(filePath, 'utf-8').toString();\n }\n }\n else {\n // Check if file exists\n const emailTemplateHandlebar = `module-metadata/${moduleMetadata.name}/email-templates/${emailTemplate.body}`\n const fullPath = path.join(process.cwd(), emailTemplateHandlebar);\n this.logger.log(`Seeding custom email template from consuming model at path: ${fullPath}`);\n if (fs.existsSync(fullPath)) {\n emailTemplate.body = fs.readFileSync(fullPath, 'utf-8').toString();\n }\n }\n\n // Save to DB.\n await this.emailTemplateService.removeByName(emailTemplate.name);\n await this.emailTemplateService.create(emailTemplate);\n }\n\n }\n\n async seedSmsTemplates(smsTemplates: CreateSmsTemplateDto[], moduleMetadata: CreateModuleMetadataDto) {\n if (!smsTemplates) {\n return;\n }\n\n for (let i = 0; i < smsTemplates.length; i++) {\n const smsTemplate = smsTemplates[i];\n this.logger.log(`Found ${smsTemplate.name} sms template`);\n\n // We need to load the actual template contents. \n if (moduleMetadata.name === 'solid-core') {\n const modulePath = path.dirname(require.resolve('@solidstarters/solid-core'));\n const seedDataPath = path.join(modulePath, '../src/seeders/seed-data/sms-templates');\n const filePath = path.join(seedDataPath, smsTemplate.body);\n this.logger.log(`Seeding sms template from solid-core at path: ${filePath}`);\n if (fs.existsSync(filePath)) {\n smsTemplate.body = fs.readFileSync(filePath, 'utf-8').toString();\n }\n }\n else {\n // Check if file exists\n const emailTemplateHandlebar = `module-metadata/${moduleMetadata.name}/sms-templates/${smsTemplate.body}`\n const fullPath = path.join(process.cwd(), emailTemplateHandlebar);\n this.logger.log(`Seeding custom sms template from consuming model at path: ${fullPath}`);\n if (fs.existsSync(fullPath)) {\n smsTemplate.body = fs.readFileSync(fullPath, 'utf-8').toString();\n }\n }\n\n\n // Save to DB.\n await this.smsTemplateService.removeByName(smsTemplate.name);\n await this.smsTemplateService.create(smsTemplate);\n }\n }\n\n async seedMenus(menus: any) {\n if (!menus) {\n return;\n }\n\n for (let j = 0; j < menus.length; j++) {\n const menuData = menus[j];\n\n const adminRole = await this.roleService.findRoleByName('Admin');\n\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.solidActionService.findOneByUserKey(menuData.actionUserKey);\n menuData['module'] = await this.moduleMetadataService.findOneByUserKey(menuData.moduleUserKey);\n\n if (menuData.parentMenuItemUserKey) {\n menuData['parentMenuItem'] = await this.solidMenuItemService.findOneByUserKey(menuData.parentMenuItemUserKey);\n } else {\n menuData['parentMenuItem'] = null\n }\n await this.solidMenuItemService.upsert(menuData);\n }\n }\n\n async seedActions(actions: any) {\n if (!actions) {\n return;\n }\n\n for (let j = 0; j < actions.length; j++) {\n const actionData = actions[j];\n actionData['module'] = await this.moduleMetadataService.findOneByUserKey(actionData.moduleUserKey);\n if (actionData.type === 'solid') {\n actionData['model'] = await this.modelMetadataService.findOneByUserKey(actionData.modelUserKey);\n actionData['view'] = await this.solidViewService.findOneByUserKey(actionData.viewUserKey);\n }\n else {\n if (actionData.modelUserKey) {\n actionData['model'] = await this.modelMetadataService.findOneByUserKey(actionData.modelUserKey);\n }\n }\n await this.solidActionService.upsert(actionData);\n }\n }\n\n async seedViews(views: any) {\n if (!views) {\n return;\n }\n\n for (let j = 0; j < views.length; j++) {\n const viewData = views[j];\n\n // preety format the layout & context. \n viewData['layout'] = JSON.stringify(viewData['layout'], null, 2);\n // viewData['context'] = JSON.stringify(viewData['context'], null, 2);\n\n viewData['module'] = await this.moduleMetadataService.findOneByUserKey(viewData.moduleUserKey);\n viewData['model'] = await this.modelMetadataService.findOneByUserKey(viewData.modelUserKey);\n // await this.solidViewService.upsert(viewData);\n // First check if module already exists using name\n\n // Changed the below to upsert as now we are saving modifications to the view json to file system also.\n // await this.solidViewService.createIfNotPresent(viewData);\n await this.solidViewService.upsert(viewData);\n }\n }\n\n async seedUsers(users) {\n if (!users) {\n return;\n }\n\n for (let l = 0; l < users.length; l++) {\n const user = users[l];\n let exisitingUser = await this.userService.findOneByUsername(user.username);\n if (!exisitingUser) {\n exisitingUser = await this.authenticationService.signUp(user);\n\n this.logger.log(`Newly created user is ${user}`);\n }\n // now add Roles to user.\n // for (let m = 0; m < roles.length; m++) {\n // const role = roles[m];\n // await this.userService.addRoleToUser(user.email, role.name);\n // }\n }\n }\n\n async seedModuleModelFields(moduleMetadata: CreateModuleMetadataDto) {\n\n // First we create the module. \n // await this.moduleMetadataService.removeByName(moduleMetadata.name);\n // const module = await this.moduleMetadataService.create(moduleMetadata);\n const module = await this.moduleMetadataService.upsert(moduleMetadata);\n\n // Next create all the models. \n const modelsMetadata: CreateModelMetadataDto[] = moduleMetadata.models;\n for (let j = 0; j < modelsMetadata.length; j++) {\n const modelMetadata = modelsMetadata[j];\n\n // Before creating the model, we need to make sure we are linking it to the newly created module.\n // modelMetdata['moduleId'] = module.id;\n modelMetadata['module'] = module;\n\n // Please note that all the fields will also get created as we have setup the relation in model.entity.ts as cascade=true\n // await this.modelMetadataService.removeBySingularName(modelMetdata.singularName);\n // await this.modelMetadataService.modelSeeder(modelMetdata);\n\n // upsert the model information.\n // const fieldsMetadata = modelMetdata.fields;\n // delete modelMetdata['fields'];\n const { fields: fieldsMetadata, ...modelMetaDataWithoutFields } = modelMetadata;\n\n // Load and set the parent model if it exists.\n if (modelMetadata.isChild && modelMetadata.parentModelUserKey) {\n const parentModel = await this.modelMetadataService.findOneByUserKey(modelMetadata.parentModelUserKey);\n modelMetaDataWithoutFields['parentModel'] = parentModel;\n }\n\n await this.modelMetadataService.upsert(modelMetaDataWithoutFields);\n const model = await this.modelMetadataService.findOneBySingularName(modelMetadata.singularName)\n\n // iterate over all fields and upsert. \n let userKeyField = null;\n const userKeyFieldName = modelMetadata.userKeyFieldUserKey;\n for (let k = 0; k < fieldsMetadata.length; k++) {\n const fieldMetadata = fieldsMetadata[k];\n\n // TODO: resolve model & mediaStorageProvider. \n fieldMetadata['model'] = model;\n if (fieldMetadata.mediaStorageProviderUserKey) {\n fieldMetadata['mediaStorageProvider'] = await this.mediaStorageProviderMetadataService.findOneByUserKey(fieldMetadata.mediaStorageProviderUserKey);\n }\n // console.log(fieldMetadata.displayName);\n\n const affectedField = await this.fieldMetadataService.upsert(fieldMetadata);\n if (fieldMetadata.name === userKeyFieldName) {\n const { model, ...fieldData } = affectedField;\n userKeyField = fieldData;\n }\n }\n\n // Now that we have created fields & model update the model to stamp the userKeyField. \n if (userKeyField) {\n modelMetaDataWithoutFields['userKeyField'] = userKeyField;\n await this.modelMetadataService.upsert(modelMetaDataWithoutFields);\n }\n }\n }\n\n async seedSettings(createDto: CreateSettingDto) {\n const settingsArray: any[] = await this.settingsRepo.find();\n if (!settingsArray || settingsArray.length === 0) {\n this.seetingService.create(createDto);\n }\n }\n\n async seedSecurityRules(rulesDto: CreateSecurityRuleDto[]) {\n if (!rulesDto || rulesDto.length === 0) {\n this.logger.debug(`No security rules found to seed`);\n return;\n }\n for (const dto of rulesDto) {\n await this.securityRuleRepo.upsertWithDto({ ...dto, securityRuleConfig: JSON.stringify(dto.securityRuleConfig) });\n }\n }\n\n async seedListOfValues(listOfValuesDto: CreateListOfValuesDto[]) {\n if (!listOfValuesDto || listOfValuesDto.length === 0) {\n this.logger.debug(`No List Of Values found to seed`);\n return;\n }\n for (let j = 0; j < listOfValuesDto.length; j++) {\n await this.listOfValuesService.upsert(listOfValuesDto);\n }\n }\n\n async seedDashboards(dashboardDtos: CreateDashboardDto[]) {\n if (!dashboardDtos || dashboardDtos.length === 0) {\n this.logger.debug(`No dashboards found to seed`);\n return;\n }\n for (const dto of dashboardDtos) {\n await this.dashboardRepo.upsertWithDto(dto);\n }\n }\n\n}"]}
|
|
@@ -4919,7 +4919,7 @@
|
|
|
4919
4919
|
"tableName": "ss_ai_interactions",
|
|
4920
4920
|
"dataSource": "default",
|
|
4921
4921
|
"dataSourceType": "postgres",
|
|
4922
|
-
"userKeyFieldUserKey": "
|
|
4922
|
+
"userKeyFieldUserKey": "externalId",
|
|
4923
4923
|
"isSystem": false,
|
|
4924
4924
|
"fields": [
|
|
4925
4925
|
{
|
|
@@ -4938,6 +4938,35 @@
|
|
|
4938
4938
|
"relationModelModuleName": "solid-core",
|
|
4939
4939
|
"isSystem": true
|
|
4940
4940
|
},
|
|
4941
|
+
{
|
|
4942
|
+
"name": "externalId",
|
|
4943
|
+
"displayName": "External ID",
|
|
4944
|
+
"description": "Used to track using a reference number of each ai interaction.",
|
|
4945
|
+
"type": "computed",
|
|
4946
|
+
"ormType": "varchar",
|
|
4947
|
+
"isSystem": false,
|
|
4948
|
+
"computedFieldValueType": "string",
|
|
4949
|
+
"computedFieldTriggerConfig": [
|
|
4950
|
+
{
|
|
4951
|
+
"modelName": "aiInteraction",
|
|
4952
|
+
"moduleName": "solid-core",
|
|
4953
|
+
"operations": [
|
|
4954
|
+
"before-insert"
|
|
4955
|
+
]
|
|
4956
|
+
}
|
|
4957
|
+
],
|
|
4958
|
+
"computedFieldValueProvider": "AlphaNumExternalIdComputationProvider",
|
|
4959
|
+
"computedFieldValueProviderCtxt": "{\n \"prefix\": \"AI\",\n \"length\": \"10\"\n}",
|
|
4960
|
+
"required": true,
|
|
4961
|
+
"unique": true,
|
|
4962
|
+
"index": true,
|
|
4963
|
+
"private": false,
|
|
4964
|
+
"encrypt": false,
|
|
4965
|
+
"encryptionType": null,
|
|
4966
|
+
"decryptWhen": null,
|
|
4967
|
+
"columnName": null,
|
|
4968
|
+
"isUserKey": true
|
|
4969
|
+
},
|
|
4941
4970
|
{
|
|
4942
4971
|
"name": "threadId",
|
|
4943
4972
|
"displayName": "Thread ID",
|
|
@@ -4950,6 +4979,22 @@
|
|
|
4950
4979
|
"private": false,
|
|
4951
4980
|
"encrypt": false
|
|
4952
4981
|
},
|
|
4982
|
+
{
|
|
4983
|
+
"name": "parentInteraction",
|
|
4984
|
+
"displayName": "Parent Interaction",
|
|
4985
|
+
"type": "relation",
|
|
4986
|
+
"required": false,
|
|
4987
|
+
"unique": false,
|
|
4988
|
+
"index": true,
|
|
4989
|
+
"private": false,
|
|
4990
|
+
"encrypt": false,
|
|
4991
|
+
"relationType": "many-to-one",
|
|
4992
|
+
"relationCoModelSingularName": "aiInteraction",
|
|
4993
|
+
"relationCreateInverse": false,
|
|
4994
|
+
"relationCascade": "set null",
|
|
4995
|
+
"relationModelModuleName": "solid-core",
|
|
4996
|
+
"isSystem": true
|
|
4997
|
+
},
|
|
4953
4998
|
{
|
|
4954
4999
|
"name": "role",
|
|
4955
5000
|
"displayName": "Role",
|
|
@@ -5057,6 +5102,17 @@
|
|
|
5057
5102
|
"index": false,
|
|
5058
5103
|
"private": false,
|
|
5059
5104
|
"encrypt": false
|
|
5105
|
+
},
|
|
5106
|
+
{
|
|
5107
|
+
"name": "isAutoApply",
|
|
5108
|
+
"displayName": "Is Auto Apply",
|
|
5109
|
+
"type": "boolean",
|
|
5110
|
+
"ormType": "boolean",
|
|
5111
|
+
"required": false,
|
|
5112
|
+
"unique": false,
|
|
5113
|
+
"index": false,
|
|
5114
|
+
"private": false,
|
|
5115
|
+
"encrypt": false
|
|
5060
5116
|
}
|
|
5061
5117
|
]
|
|
5062
5118
|
}
|
|
@@ -11867,7 +11923,7 @@
|
|
|
11867
11923
|
}
|
|
11868
11924
|
},
|
|
11869
11925
|
{
|
|
11870
|
-
"name": "
|
|
11926
|
+
"name": "aiInteraction-list-view",
|
|
11871
11927
|
"displayName": "AI Interaction",
|
|
11872
11928
|
"type": "list",
|
|
11873
11929
|
"context": "{}",
|
|
@@ -11900,6 +11956,18 @@
|
|
|
11900
11956
|
"name": "threadId"
|
|
11901
11957
|
}
|
|
11902
11958
|
},
|
|
11959
|
+
{
|
|
11960
|
+
"type": "field",
|
|
11961
|
+
"attrs": {
|
|
11962
|
+
"name": "externalId"
|
|
11963
|
+
}
|
|
11964
|
+
},
|
|
11965
|
+
{
|
|
11966
|
+
"type": "field",
|
|
11967
|
+
"attrs": {
|
|
11968
|
+
"name": "parentInteraction"
|
|
11969
|
+
}
|
|
11970
|
+
},
|
|
11903
11971
|
{
|
|
11904
11972
|
"type": "field",
|
|
11905
11973
|
"attrs": {
|
|
@@ -11934,7 +12002,7 @@
|
|
|
11934
12002
|
}
|
|
11935
12003
|
},
|
|
11936
12004
|
{
|
|
11937
|
-
"name": "
|
|
12005
|
+
"name": "aiInteraction-form-view",
|
|
11938
12006
|
"displayName": "AI Interaction",
|
|
11939
12007
|
"type": "form",
|
|
11940
12008
|
"context": "{}",
|
|
@@ -11987,6 +12055,12 @@
|
|
|
11987
12055
|
"name": "user"
|
|
11988
12056
|
}
|
|
11989
12057
|
},
|
|
12058
|
+
{
|
|
12059
|
+
"type": "field",
|
|
12060
|
+
"attrs": {
|
|
12061
|
+
"name": "externalId"
|
|
12062
|
+
}
|
|
12063
|
+
},
|
|
11990
12064
|
{
|
|
11991
12065
|
"type": "field",
|
|
11992
12066
|
"attrs": {
|
|
@@ -12034,6 +12108,12 @@
|
|
|
12034
12108
|
"attrs": {
|
|
12035
12109
|
"name": "responseTimeMs"
|
|
12036
12110
|
}
|
|
12111
|
+
},
|
|
12112
|
+
{
|
|
12113
|
+
"type": "field",
|
|
12114
|
+
"attrs": {
|
|
12115
|
+
"name": "parentInteraction"
|
|
12116
|
+
}
|
|
12037
12117
|
}
|
|
12038
12118
|
]
|
|
12039
12119
|
}
|
|
@@ -26,7 +26,7 @@ export declare class AiInteractionService extends CRUDService<AiInteraction> {
|
|
|
26
26
|
readonly mcpToolResponseHandlerFactory: McpToolResponseHandlerFactory;
|
|
27
27
|
private readonly logger;
|
|
28
28
|
constructor(modelMetadataService: ModelMetadataService, moduleMetadataService: ModuleMetadataService, configService: ConfigService, fileService: FileService, discoveryService: DiscoveryService, crudHelperService: CrudHelperService, entityManager: EntityManager, repo: Repository<AiInteraction>, moduleRef: ModuleRef, publisherFactory: PublisherFactory<TriggerMcpClientOptions>, requestContextService: RequestContextService, mcpToolResponseHandlerFactory: McpToolResponseHandlerFactory);
|
|
29
|
-
triggerMcpClientJob(prompt: string): Promise<
|
|
29
|
+
triggerMcpClientJob(prompt: string): Promise<any>;
|
|
30
30
|
runMcpPrompt(prompt: string): Promise<McpResponse>;
|
|
31
31
|
cleanResponse(response: string): string;
|
|
32
32
|
applySolidAiInteraction(id: number): Promise<any>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-interaction.service.d.ts","sourceRoot":"","sources":["../../src/services/ai-interaction.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAEpD,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,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAErE,O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a;IAErC,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC,aAAa,CAAC;IACxC,QAAQ,CAAC,SAAS,EAAE,SAAS;IAC7B,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB,CAAC,uBAAuB,CAAC;IACpE,QAAQ,CAAC,qBAAqB,EAAE,qBAAqB;IACrD,QAAQ,CAAC,6BAA6B,EAAE,6BAA6B;IAhBvE,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAyC;gBAGrD,oBAAoB,EAAE,oBAAoB,EAC1C,qBAAqB,EAAE,qBAAqB,EAC5C,aAAa,EAAE,aAAa,EAC5B,WAAW,EAAE,WAAW,EACxB,gBAAgB,EAAE,gBAAgB,EAClC,iBAAiB,EAAE,iBAAiB,EAEpC,aAAa,EAAE,aAAa,EAE5B,IAAI,EAAE,UAAU,CAAC,aAAa,CAAC,EAC/B,SAAS,EAAE,SAAS,EACpB,gBAAgB,EAAE,gBAAgB,CAAC,uBAAuB,CAAC,EAC3D,qBAAqB,EAAE,qBAAqB,EAC5C,6BAA6B,EAAE,6BAA6B;IAMjE,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAmCjD,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IA2ExD,aAAa,CAAC,QAAQ,EAAE,MAAM;IAexB,uBAAuB,CAAC,EAAE,EAAE,MAAM;CAiDzC"}
|
|
@@ -101,7 +101,11 @@ let AiInteractionService = AiInteractionService_1 = class AiInteractionService e
|
|
|
101
101
|
parentEntity: 'aiInteraction',
|
|
102
102
|
parentEntityId: aiInteraction.id,
|
|
103
103
|
};
|
|
104
|
-
|
|
104
|
+
const queueMessageId = await this.publisherFactory.publish(m, 'TriggerMcpClientPublisher');
|
|
105
|
+
return {
|
|
106
|
+
queueMessageId: queueMessageId,
|
|
107
|
+
aiInteractionId: aiInteraction.id
|
|
108
|
+
};
|
|
105
109
|
}
|
|
106
110
|
async runMcpPrompt(prompt) {
|
|
107
111
|
const pythonExecutable = process.env.MCP_PYTHON_EXECUTABLE;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-interaction.service.js","sourceRoot":"","sources":["../../src/services/ai-interaction.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAyE;AACzE,6CAAwE;AACxE,uCAA2D;AAC3D,qCAAoD;AAEpD,iDAAwD;AACxD,qEAA2E;AAC3E,uEAA6E;AAC7E,2CAA+C;AAC/C,iDAAwD;AACxD,+DAAqE;AACrE,iDAAsC;AACtC,6EAAkE;AAClE,gDAAkC;AAElC,kFAAsE;AACtE,uEAAkE;AAElE,sIAAuH;AACvH,gEAA8D;AAGvD,IAAM,oBAAoB,4BAA1B,MAAM,oBAAqB,SAAQ,0BAA0B;IAGlE,YACW,oBAA0C,EAC1C,qBAA4C,EAC5C,aAA4B,EAC5B,WAAwB,EACxB,gBAAkC,EAClC,iBAAoC,EAE7C,aAAqC,EAErC,IAAwC,EAC/B,SAAoB,EACpB,gBAA2D,EAC3D,qBAA4C,EAC5C,6BAA4D;QAGrE,KAAK,CAAC,oBAAoB,EAAE,qBAAqB,EAAE,aAAa,EAAE,WAAW,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,aAAa,EAAE,IAAI,EAAE,eAAe,EAAE,YAAY,EAAE,SAAS,CAAC,CAAC;QAhB1K,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;QAEpC,kBAAa,GAAb,aAAa,CAAe;QAE5B,SAAI,GAAJ,IAAI,CAA2B;QAC/B,cAAS,GAAT,SAAS,CAAW;QACpB,qBAAgB,GAAhB,gBAAgB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IAAI,CAAC,CAAC;QAEnE,OAAO,0BAA0B,CAAC;IACpC,CAAC;CACF,CAAA;AAhMY,oDAAoB;+BAApB,oBAAoB;IADhC,IAAA,mBAAU,GAAE;IAWR,WAAA,IAAA,6BAAmB,GAAE,CAAA;IAErB,WAAA,IAAA,0BAAgB,EAAC,qCAAa,EAAE,SAAS,CAAC,CAAA;qCARZ,6CAAoB;QACnB,+CAAqB;QAC7B,sBAAa;QACf,0BAAW;QACN,uBAAgB;QACf,uCAAiB;QAErB,uBAAa;QAEtB,oBAAU;QACL,gBAAS;QACF,4CAAgB;QACX,+CAAqB;QACb,yEAA6B;GAjB5D,oBAAoB,CAgMhC","sourcesContent":["import { BadRequestException, Logger, Injectable } from '@nestjs/common';\nimport { InjectEntityManager, InjectRepository } from '@nestjs/typeorm';\nimport { DiscoveryService, ModuleRef } from \"@nestjs/core\";\nimport { EntityManager, Repository } from 'typeorm';\n\nimport { CRUDService } from 'src/services/crud.service';\nimport { ModelMetadataService } from 'src/services/model-metadata.service';\nimport { ModuleMetadataService } from 'src/services/module-metadata.service';\nimport { ConfigService } from '@nestjs/config';\nimport { FileService } from 'src/services/file.service';\nimport { CrudHelperService } from 'src/services/crud-helper.service';\nimport { spawn } from 'child_process';\nimport { AiInteraction } from '../entities/ai-interaction.entity';\nimport * as fs from 'fs/promises';\nimport { McpResponse, TriggerMcpClientOptions } from 'src/interfaces';\nimport { PublisherFactory } from './queues/publisher-factory.service';\nimport { RequestContextService } from './request-context.service';\nimport { ActiveUserData } from 'src/interfaces/active-user-data.interface';\nimport { McpToolResponseHandlerFactory } from './mcp-tool-response-handlers/mcp-tool-response-handler-factory.service';\nimport { ERROR_MESSAGES } from 'src/constants/error-messages';\n\n@Injectable()\nexport class AiInteractionService extends CRUDService<AiInteraction> {\n private readonly logger = new Logger(AiInteractionService.name);\n\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 @InjectEntityManager()\n readonly entityManager: EntityManager,\n @InjectRepository(AiInteraction, 'default')\n readonly repo: Repository<AiInteraction>,\n readonly moduleRef: ModuleRef,\n readonly publisherFactory: PublisherFactory<TriggerMcpClientOptions>,\n readonly requestContextService: RequestContextService,\n readonly mcpToolResponseHandlerFactory: McpToolResponseHandlerFactory,\n\n ) {\n super(modelMetadataService, moduleMetadataService, configService, fileService, discoveryService, crudHelperService, entityManager, repo, 'aiInteraction', 'solid-core', moduleRef);\n }\n\n async triggerMcpClientJob(prompt: string): Promise<string> {\n const activeUser: ActiveUserData = this.requestContextService.getActiveUser();\n\n const aiInteraction = await this.create({\n userId: activeUser.sub,\n threadId: `thread-${activeUser.sub}`,\n role: 'human',\n message: prompt,\n contentType: '',\n errorMessage: '',\n modelUsed: '',\n responseTimeMs: 0,\n metadata: ''\n });\n const m = {\n payload: {\n aiInteractionId: aiInteraction.id,\n },\n parentEntity: 'aiInteraction',\n parentEntityId: aiInteraction.id,\n };\n\n return await this.publisherFactory.publish(m, 'TriggerMcpClientPublisher');\n }\n\n /**\n * Runs the Python MCP client with a prompt and returns the parsed JSON embedded in the 'response'.\n * @param prompt - The question or instruction to send to the MCP client.\n * @returns The parsed object inside the 'response' field of the JSON output.\n */\n async runMcpPrompt(prompt: string): Promise<McpResponse> {\n const pythonExecutable = process.env.MCP_PYTHON_EXECUTABLE;\n const mcpClient = process.env.MCP_CLIENT;\n\n // TODO: We can return an error if the above env variables are not properly setup...\n if (!pythonExecutable || !mcpClient) {\n throw new BadRequestException(ERROR_MESSAGES.PYTHON_EXECUTABLE_NOT_CONFIGURED);\n }\n\n // Check if both paths are valid and accessible\n try {\n const [pyStat, clientStat] = await Promise.all([\n fs.stat(pythonExecutable),\n fs.stat(mcpClient),\n ]);\n\n if (!pyStat.isFile()) {\n throw new BadRequestException(`MCP_PYTHON_EXECUTABLE path is not a file: ${pythonExecutable}`);\n }\n\n if (!clientStat.isFile()) {\n throw new BadRequestException(`MCP_CLIENT path is not a file: ${mcpClient}`);\n }\n\n } catch (err: any) {\n throw new BadRequestException(`Invalid MCP executable or client path: ${err.message}`);\n }\n\n // TODO: Refactor to use the command.service.ts instead...\n return new Promise((resolve, reject) => {\n this.logger.log(`Attempting to run command:`)\n this.logger.log(`${pythonExecutable} ${mcpClient} \"${prompt}\"`);\n\n const python = spawn(pythonExecutable, [mcpClient, `\"${prompt}\"`]);\n\n let stdout = '';\n let stderr = '';\n\n python.stdout.on('data', (data) => {\n stdout += data.toString();\n });\n\n python.stderr.on('data', (data) => {\n stderr += data.toString();\n });\n\n python.on('close', (code) => {\n this.logger.log(`Python script exited with code ${code}`);\n\n if (code !== 0) {\n this.logger.error(`Python script exited with a non-zero exit code: ${stderr}`);\n return reject(new Error(`Python script exited with a non-zero exit code: ${stderr}`));\n }\n\n try {\n this.logger.log(`Python script exited with zero exit code: ${stdout}`);\n const raw: McpResponse = JSON.parse(stdout);\n\n // if (!raw.success) {\n // return reject(new Error(`MCP error: ${raw.errors?.join(', ')}`));\n // }\n // let cleaned = raw.response.trim();\n\n // Don't need to re-parse this...\n // const parsed = JSON.parse(cleaned);\n // resolve(cleaned);\n\n resolve(raw);\n } catch (err: any) {\n reject(new Error(`Mcp Invocation Failed: ${err.message}`));\n }\n });\n });\n }\n\n cleanResponse(response: string) {\n this.logger.log(`mcp server response is: ${response}`);\n\n // Remove markdown-style code block wrapper\n if (response.startsWith('```json')) {\n response = response.replace(/^```json/, '').trim();\n }\n if (response.endsWith('```')) {\n response = response.replace(/```$/, '').trim();\n }\n this.logger.log(`mcp server response after removing doc tags is: ${response}`);\n\n return response;\n }\n\n async applySolidAiInteraction(id: number) {\n // Fetch the aiInteraction\n const aiInteraction = await this.findOne(id, {\n populate: ['user']\n });\n if (!aiInteraction) {\n const m = `Unable to identified the aiInteraction entry that triggered this job... using id: ${id}`\n\n // TODO: RESPONSE SHAPE ALERT Check if we want to control the shape of the response....\n throw new Error(m);\n }\n\n // TODO: Validation: Check if JSON.parse(metadata).tools_invoked starts with solid_\n let metadata = {};\n try {\n metadata = JSON.parse(aiInteraction.metadata);\n }\n catch (e) {\n // TODO: RESPONSE SHAPE ALERT Check if we want to control the shape of the response....\n throw new Error(e);\n }\n\n const toolsInvoked = metadata['tools_invoked'];\n if (!toolsInvoked) {\n // TODO: RESPONSE SHAPE ALERT Check if we want to control the shape of the response....\n throw new Error(ERROR_MESSAGES.UNABLE_TO_RESOLVE_SOLID_COMMAND);\n }\n\n // TODO: OPTIMISATION for chained tool invocation, for now we are assuming only 1 tool was used.\n const toolInvoked = toolsInvoked[0];\n\n // TODO: use the toolInvoked to identify a service using some convention.\n // TODO: Eg. if toolInvoked is solid_create_module <> SolidCreateModuleMcpToolHandler ... create a factory class to do this mapping and identify the relevant provider. \n const mcpToolHandler = this.mcpToolResponseHandlerFactory.getInstance(toolInvoked);\n if (!mcpToolHandler) {\n // TODO: RESPONSE SHAPE ALERT Check if we want to control the shape of the response....\n throw new Error(ERROR_MESSAGES.UNABLE_TO_RESOLVE_MCP_HANDLER);\n }\n\n const handlerApplicationResponse = await mcpToolHandler.apply(aiInteraction);\n\n // TODO: This provider to implement an interface - IMcpToolResponseHandler ... apply(aiInteraction: AiInteraction)\n // throw new Error('Method not implemented.');\n \n // Mark the interaction as applied\n await this.update(aiInteraction.id, { isApplied: true }, [], true);\n\n return handlerApplicationResponse;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ai-interaction.service.js","sourceRoot":"","sources":["../../src/services/ai-interaction.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAyE;AACzE,6CAAwE;AACxE,uCAA2D;AAC3D,qCAAoD;AAEpD,iDAAwD;AACxD,qEAA2E;AAC3E,uEAA6E;AAC7E,2CAA+C;AAC/C,iDAAwD;AACxD,+DAAqE;AACrE,iDAAsC;AACtC,6EAAkE;AAClE,gDAAkC;AA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BAAU;QACL,gBAAS;QACF,4CAAgB;QACX,+CAAqB;QACb,yEAA6B;GAjB5D,oBAAoB,CAqMhC","sourcesContent":["import { BadRequestException, Logger, Injectable } from '@nestjs/common';\nimport { InjectEntityManager, InjectRepository } from '@nestjs/typeorm';\nimport { DiscoveryService, ModuleRef } from \"@nestjs/core\";\nimport { EntityManager, Repository } from 'typeorm';\n\nimport { CRUDService } from 'src/services/crud.service';\nimport { ModelMetadataService } from 'src/services/model-metadata.service';\nimport { ModuleMetadataService } from 'src/services/module-metadata.service';\nimport { ConfigService } from '@nestjs/config';\nimport { FileService } from 'src/services/file.service';\nimport { CrudHelperService } from 'src/services/crud-helper.service';\nimport { spawn } from 'child_process';\nimport { AiInteraction } from '../entities/ai-interaction.entity';\nimport * as fs from 'fs/promises';\nimport { McpResponse, TriggerMcpClientOptions } from 'src/interfaces';\nimport { PublisherFactory } from './queues/publisher-factory.service';\nimport { RequestContextService } from './request-context.service';\nimport { ActiveUserData } from 'src/interfaces/active-user-data.interface';\nimport { McpToolResponseHandlerFactory } from './mcp-tool-response-handlers/mcp-tool-response-handler-factory.service';\nimport { ERROR_MESSAGES } from 'src/constants/error-messages';\n\n@Injectable()\nexport class AiInteractionService extends CRUDService<AiInteraction> {\n private readonly logger = new Logger(AiInteractionService.name);\n\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 @InjectEntityManager()\n readonly entityManager: EntityManager,\n @InjectRepository(AiInteraction, 'default')\n readonly repo: Repository<AiInteraction>,\n readonly moduleRef: ModuleRef,\n readonly publisherFactory: PublisherFactory<TriggerMcpClientOptions>,\n readonly requestContextService: RequestContextService,\n readonly mcpToolResponseHandlerFactory: McpToolResponseHandlerFactory,\n\n ) {\n super(modelMetadataService, moduleMetadataService, configService, fileService, discoveryService, crudHelperService, entityManager, repo, 'aiInteraction', 'solid-core', moduleRef);\n }\n\n async triggerMcpClientJob(prompt: string): Promise<any> {\n const activeUser: ActiveUserData = this.requestContextService.getActiveUser();\n\n const aiInteraction = await this.create({\n userId: activeUser.sub,\n threadId: `thread-${activeUser.sub}`,\n role: 'human',\n message: prompt,\n contentType: '',\n errorMessage: '',\n modelUsed: '',\n responseTimeMs: 0,\n metadata: ''\n });\n const m = {\n payload: {\n aiInteractionId: aiInteraction.id,\n },\n parentEntity: 'aiInteraction',\n parentEntityId: aiInteraction.id,\n };\n\n const queueMessageId = await this.publisherFactory.publish(m, 'TriggerMcpClientPublisher');\n\n return {\n queueMessageId: queueMessageId,\n aiInteractionId: aiInteraction.id\n }\n }\n\n /**\n * Runs the Python MCP client with a prompt and returns the parsed JSON embedded in the 'response'.\n * @param prompt - The question or instruction to send to the MCP client.\n * @returns The parsed object inside the 'response' field of the JSON output.\n */\n async runMcpPrompt(prompt: string): Promise<McpResponse> {\n const pythonExecutable = process.env.MCP_PYTHON_EXECUTABLE;\n const mcpClient = process.env.MCP_CLIENT;\n\n // TODO: We can return an error if the above env variables are not properly setup...\n if (!pythonExecutable || !mcpClient) {\n throw new BadRequestException(ERROR_MESSAGES.PYTHON_EXECUTABLE_NOT_CONFIGURED);\n }\n\n // Check if both paths are valid and accessible\n try {\n const [pyStat, clientStat] = await Promise.all([\n fs.stat(pythonExecutable),\n fs.stat(mcpClient),\n ]);\n\n if (!pyStat.isFile()) {\n throw new BadRequestException(`MCP_PYTHON_EXECUTABLE path is not a file: ${pythonExecutable}`);\n }\n\n if (!clientStat.isFile()) {\n throw new BadRequestException(`MCP_CLIENT path is not a file: ${mcpClient}`);\n }\n\n } catch (err: any) {\n throw new BadRequestException(`Invalid MCP executable or client path: ${err.message}`);\n }\n\n // TODO: Refactor to use the command.service.ts instead...\n return new Promise((resolve, reject) => {\n this.logger.log(`Attempting to run command:`)\n this.logger.log(`${pythonExecutable} ${mcpClient} \"${prompt}\"`);\n\n const python = spawn(pythonExecutable, [mcpClient, `\"${prompt}\"`]);\n\n let stdout = '';\n let stderr = '';\n\n python.stdout.on('data', (data) => {\n stdout += data.toString();\n });\n\n python.stderr.on('data', (data) => {\n stderr += data.toString();\n });\n\n python.on('close', (code) => {\n this.logger.log(`Python script exited with code ${code}`);\n\n if (code !== 0) {\n this.logger.error(`Python script exited with a non-zero exit code: ${stderr}`);\n return reject(new Error(`Python script exited with a non-zero exit code: ${stderr}`));\n }\n\n try {\n this.logger.log(`Python script exited with zero exit code: ${stdout}`);\n const raw: McpResponse = JSON.parse(stdout);\n\n // if (!raw.success) {\n // return reject(new Error(`MCP error: ${raw.errors?.join(', ')}`));\n // }\n // let cleaned = raw.response.trim();\n\n // Don't need to re-parse this...\n // const parsed = JSON.parse(cleaned);\n // resolve(cleaned);\n\n resolve(raw);\n } catch (err: any) {\n reject(new Error(`Mcp Invocation Failed: ${err.message}`));\n }\n });\n });\n }\n\n cleanResponse(response: string) {\n this.logger.log(`mcp server response is: ${response}`);\n\n // Remove markdown-style code block wrapper\n if (response.startsWith('```json')) {\n response = response.replace(/^```json/, '').trim();\n }\n if (response.endsWith('```')) {\n response = response.replace(/```$/, '').trim();\n }\n this.logger.log(`mcp server response after removing doc tags is: ${response}`);\n\n return response;\n }\n\n async applySolidAiInteraction(id: number) {\n // Fetch the aiInteraction\n const aiInteraction = await this.findOne(id, {\n populate: ['user']\n });\n if (!aiInteraction) {\n const m = `Unable to identified the aiInteraction entry that triggered this job... using id: ${id}`\n\n // TODO: RESPONSE SHAPE ALERT Check if we want to control the shape of the response....\n throw new Error(m);\n }\n\n // TODO: Validation: Check if JSON.parse(metadata).tools_invoked starts with solid_\n let metadata = {};\n try {\n metadata = JSON.parse(aiInteraction.metadata);\n }\n catch (e) {\n // TODO: RESPONSE SHAPE ALERT Check if we want to control the shape of the response....\n throw new Error(e);\n }\n\n const toolsInvoked = metadata['tools_invoked'];\n if (!toolsInvoked) {\n // TODO: RESPONSE SHAPE ALERT Check if we want to control the shape of the response....\n throw new Error(ERROR_MESSAGES.UNABLE_TO_RESOLVE_SOLID_COMMAND);\n }\n\n // TODO: OPTIMISATION for chained tool invocation, for now we are assuming only 1 tool was used.\n const toolInvoked = toolsInvoked[0];\n\n // TODO: use the toolInvoked to identify a service using some convention.\n // TODO: Eg. if toolInvoked is solid_create_module <> SolidCreateModuleMcpToolHandler ... create a factory class to do this mapping and identify the relevant provider. \n const mcpToolHandler = this.mcpToolResponseHandlerFactory.getInstance(toolInvoked);\n if (!mcpToolHandler) {\n // TODO: RESPONSE SHAPE ALERT Check if we want to control the shape of the response....\n throw new Error(ERROR_MESSAGES.UNABLE_TO_RESOLVE_MCP_HANDLER);\n }\n\n const handlerApplicationResponse = await mcpToolHandler.apply(aiInteraction);\n\n // TODO: This provider to implement an interface - IMcpToolResponseHandler ... apply(aiInteraction: AiInteraction)\n // throw new Error('Method not implemented.');\n\n // Mark the interaction as applied\n await this.update(aiInteraction.id, { isApplied: true }, [], true);\n\n return handlerApplicationResponse;\n }\n}\n"]}
|
|
@@ -11,9 +11,9 @@ export declare class SMTPEMailService implements IMail {
|
|
|
11
11
|
private readonly logger;
|
|
12
12
|
private readonly transporter;
|
|
13
13
|
constructor(commonConfiguration: ConfigType<typeof commonConfig>, publisherFactory: PublisherFactory<any>, emailTemplateService: EmailTemplateService);
|
|
14
|
-
sendEmailUsingTemplate(to: string, templateName: string, templateParams: any, shouldQueueEmails?: boolean, wrapperAttachments?: MailAttachmentWrapper[], attachments?: MailAttachment[], parentEntity?: any, parentEntityId?: any, cc?: string[], bcc?: string[], from?: string): Promise<
|
|
15
|
-
sendEmail(to: string, subject: string, body: string, shouldQueueEmails?: boolean, wrapperAttachments?: MailAttachmentWrapper[], attachments?: MailAttachment[], parentEntity?: any, parentEntityId?: any, cc?: string[], bcc?: string[], from?: string): Promise<
|
|
16
|
-
sendEmailAsynchronously(message: any): Promise<
|
|
17
|
-
sendEmailSynchronously(message: QueueMessage<any>): Promise<
|
|
14
|
+
sendEmailUsingTemplate(to: string, templateName: string, templateParams: any, shouldQueueEmails?: boolean, wrapperAttachments?: MailAttachmentWrapper[], attachments?: MailAttachment[], parentEntity?: any, parentEntityId?: any, cc?: string[], bcc?: string[], from?: string): Promise<any>;
|
|
15
|
+
sendEmail(to: string, subject: string, body: string, shouldQueueEmails?: boolean, wrapperAttachments?: MailAttachmentWrapper[], attachments?: MailAttachment[], parentEntity?: any, parentEntityId?: any, cc?: string[], bcc?: string[], from?: string): Promise<any>;
|
|
16
|
+
sendEmailAsynchronously(message: any): Promise<string>;
|
|
17
|
+
sendEmailSynchronously(message: QueueMessage<any>): Promise<any>;
|
|
18
18
|
}
|
|
19
19
|
//# sourceMappingURL=smtp-email.service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smtp-email.service.d.ts","sourceRoot":"","sources":["../../../src/services/mail/smtp-email.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,OAAO,YAAY,MAAM,0BAA0B,CAAC;AAEpD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AAIvE,qBAEa,gBAAiB,YAAW,KAAK;IAMtC,OAAO,CAAC,QAAQ,CAAC,mBAAmB;IAGpC,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IACjC,OAAO,CAAC,QAAQ,CAAC,oBAAoB;IATzC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAqC;IAC5D,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAM;gBAIb,mBAAmB,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,EAGpD,gBAAgB,EAAE,gBAAgB,CAAC,GAAG,CAAC,EACvC,oBAAoB,EA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AAG,EACnB,iBAAiB,UAAQ,EACzB,kBAAkB,CAAC,EAAE,qBAAqB,EAAE,EAC5C,WAAW,CAAC,EAAE,cAAc,EAAE,EAC9B,YAAY,CAAC,EAAE,GAAG,EAClB,cAAc,CAAC,EAAE,GAAG,EACpB,EAAE,CAAC,EAAE,MAAM,EAAE,EACb,GAAG,CAAC,EAAE,MAAM,EAAE,EACd,IAAI,CAAC,EAAE,MAAM;IAoBX,SAAS,CACX,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,iBAAiB,UAAQ,EACzB,kBAAkB,CAAC,EAAE,qBAAqB,EAAE,EAC5C,WAAW,CAAC,EAAE,cAAc,EAAE,EAC9B,YAAY,CAAC,EAAE,GAAG,EAClB,cAAc,CAAC,EAAE,GAAG,EACpB,EAAE,CAAC,EAAE,MAAM,EAAE,EACb,GAAG,CAAC,EAAE,MAAM,EAAE,EACd,IAAI,CAAC,EAAE,MAAM;IA8BX,uBAAuB,CAAC,OAAO,KAAA;IAM/B,sBAAsB,CAAC,OAAO,EAAE,YAAY,CAAC,GAAG,CAAC;CAsC1D"}
|
|
@@ -49,7 +49,7 @@ let SMTPEMailService = SMTPEMailService_1 = class SMTPEMailService {
|
|
|
49
49
|
const body = bodyTemplate(templateParams);
|
|
50
50
|
const subjectTemplate = handlebars_1.default.compile(emailTemplate.subject);
|
|
51
51
|
const subject = subjectTemplate(templateParams);
|
|
52
|
-
await this.sendEmail(to, subject, body, shouldQueueEmails, wrapperAttachments, attachments, parentEntity, parentEntityId, cc, bcc, from);
|
|
52
|
+
return await this.sendEmail(to, subject, body, shouldQueueEmails, wrapperAttachments, attachments, parentEntity, parentEntityId, cc, bcc, from);
|
|
53
53
|
}
|
|
54
54
|
async sendEmail(to, subject, body, shouldQueueEmails = false, wrapperAttachments, attachments, parentEntity, parentEntityId, cc, bcc, from) {
|
|
55
55
|
const message = {
|
|
@@ -66,23 +66,27 @@ let SMTPEMailService = SMTPEMailService_1 = class SMTPEMailService {
|
|
|
66
66
|
parentEntityId: parentEntityId,
|
|
67
67
|
};
|
|
68
68
|
if (shouldQueueEmails === true) {
|
|
69
|
-
this.sendEmailAsynchronously(message);
|
|
69
|
+
return this.sendEmailAsynchronously(message);
|
|
70
70
|
}
|
|
71
71
|
else if (shouldQueueEmails == false && this.commonConfiguration.shouldQueueEmails === true) {
|
|
72
|
-
this.sendEmailAsynchronously(message);
|
|
72
|
+
return this.sendEmailAsynchronously(message);
|
|
73
73
|
}
|
|
74
74
|
else {
|
|
75
|
-
await this.sendEmailSynchronously(message);
|
|
75
|
+
return await this.sendEmailSynchronously(message);
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
async sendEmailAsynchronously(message) {
|
|
79
79
|
const { to, subject, body } = message.payload;
|
|
80
|
-
this.publisherFactory.publish(message, 'SmtpEmailQueuePublisher');
|
|
81
80
|
this.logger.debug(`Queueing email to ${to} with subject ${subject} and body ${body}`);
|
|
81
|
+
return this.publisherFactory.publish(message, 'SmtpEmailQueuePublisher');
|
|
82
82
|
}
|
|
83
83
|
async sendEmailSynchronously(message) {
|
|
84
|
-
const { from, to, subject, body, attachments, cc, bcc } = message.payload;
|
|
85
|
-
|
|
84
|
+
const { from, to, subject, body, attachments = [], cc, bcc } = message.payload;
|
|
85
|
+
if (!from || !to || !subject || !body) {
|
|
86
|
+
this.logger.error(`Required fields are missing in the email message: ${JSON.stringify(message.payload)}`);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
const attachmentsList = attachments?.map((attachment) => {
|
|
86
90
|
const attachmentEntry = {
|
|
87
91
|
filename: attachment.filename,
|
|
88
92
|
contentType: attachment.contentType,
|
|
@@ -94,7 +98,7 @@ let SMTPEMailService = SMTPEMailService_1 = class SMTPEMailService {
|
|
|
94
98
|
attachmentEntry['content'] = attachment.content;
|
|
95
99
|
}
|
|
96
100
|
return attachmentEntry;
|
|
97
|
-
});
|
|
101
|
+
}) || [];
|
|
98
102
|
const r = await this.transporter.sendMail({
|
|
99
103
|
from: from,
|
|
100
104
|
to: to,
|