@solidxai/core 0.1.10-beta.11 → 0.1.10-beta.14

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 (29) hide show
  1. package/dist/commands/refresh-model.command.d.ts +1 -3
  2. package/dist/commands/refresh-model.command.d.ts.map +1 -1
  3. package/dist/commands/refresh-model.command.js +4 -17
  4. package/dist/commands/refresh-model.command.js.map +1 -1
  5. package/dist/commands/refresh-module.command.d.ts +0 -2
  6. package/dist/commands/refresh-module.command.d.ts.map +1 -1
  7. package/dist/commands/refresh-module.command.js +3 -16
  8. package/dist/commands/refresh-module.command.js.map +1 -1
  9. package/dist/helpers/bootstrap.helper.d.ts +1 -0
  10. package/dist/helpers/bootstrap.helper.d.ts.map +1 -1
  11. package/dist/helpers/bootstrap.helper.js +6 -3
  12. package/dist/helpers/bootstrap.helper.js.map +1 -1
  13. package/dist/services/model-metadata.service.d.ts.map +1 -1
  14. package/dist/services/model-metadata.service.js +2 -1
  15. package/dist/services/model-metadata.service.js.map +1 -1
  16. package/dist/services/module-metadata.service.d.ts.map +1 -1
  17. package/dist/services/module-metadata.service.js +2 -1
  18. package/dist/services/module-metadata.service.js.map +1 -1
  19. package/dist/winston.logger.d.ts +5 -0
  20. package/dist/winston.logger.d.ts.map +1 -1
  21. package/dist/winston.logger.js +6 -4
  22. package/dist/winston.logger.js.map +1 -1
  23. package/package.json +1 -1
  24. package/src/commands/refresh-model.command.ts +5 -19
  25. package/src/commands/refresh-module.command.ts +3 -16
  26. package/src/helpers/bootstrap.helper.ts +13 -6
  27. package/src/services/model-metadata.service.ts +2 -1
  28. package/src/services/module-metadata.service.ts +2 -1
  29. package/src/winston.logger.ts +5 -7
@@ -1 +1 @@
1
- {"version":3,"file":"module-metadata.service.js","sourceRoot":"","sources":["../../src/services/module-metadata.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAgH;AA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AC,GAAG,IAAI,GAAG,CAAC,EAAE,CAAC;YACjE,OAAO,QAAQ,CAAC;QAClB,CAAC;QACD,OAAO,GAAG,IAAI,IAAI,QAAQ,EAAE,CAAC;IAC/B,CAAC;IAEO,WAAW,CAAC,IAAyB;QAC3C,OAAO,GAAG,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;IACjD,CAAC;CAEF,CAAA;AAvcY,sDAAqB;AA0S1B;IADL,IAAA,uDAAoB,GAAE;;;;mDAMtB;AAyEK;IADL,IAAA,uDAAoB,GAAE;;;;+DAOtB;AAGK;IADL,IAAA,uDAAoB,GAAE;;;;yDAsBtB;gCAtZU,qBAAqB;IADjC,IAAA,mBAAU,GAAE;IAKR,WAAA,IAAA,0BAAgB,GAAE,CAAA;IAYlB,WAAA,IAAA,eAAM,EAAC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,6CAAoB,CAAC,CAAC,CAAA;qCAXlB,oBAAU;QAGF,qDAAwB;QACzB,uCAAiB;QAClB,oCAAgB;QAClB,gCAAc;QACjB,sBAAe;QACZ,gCAAc;QAEJ,oEAA+B;QAEnC,6CAAoB;QAC3B,8BAAa;QACC,4DAA2B;GAnBhE,qBAAqB,CAucjC","sourcesContent":["import { BadRequestException, forwardRef, Inject, Injectable, Logger, NotFoundException } from '@nestjs/common';\nimport { InjectDataSource } from '@nestjs/typeorm';\nimport { DEFAULT_MEDIA_FILE_STORAGE_DIR } from \"src/services/settings/default-settings-provider.service\";\nimport type { SolidCoreSetting } from \"src/services/settings/default-settings-provider.service\";\nimport { DataSource, EntityManager, SelectQueryBuilder } from 'typeorm';\nimport { CreateModuleMetadataDto } from '../dtos/create-module-metadata.dto';\nimport { ModuleMetadata } from '../entities/module-metadata.entity';\n\nimport { classify } from '../helpers/string.helper';\nimport { ConfigService } from '@nestjs/config';\nimport * as fs from 'fs/promises'; // Use the Promise-based version of fs for async/await\nimport * as path from 'path'; // To handle file paths\nimport { ERROR_MESSAGES } from 'src/constants/error-messages';\nimport { DisallowInProduction } from 'src/decorators/disallow-in-production.decorator';\nimport { ModuleMetadataHelperService } from 'src/helpers/module-metadata-helper.service';\nimport { ModuleMetadataRepository } from 'src/repository/module-metadata.repository';\nimport { PermissionMetadataSeederService } from 'src/seeders/permission-metadata-seeder.service';\nimport { DiskFileService } from 'src/services/file';\nimport { BasicFilterDto } from '../dtos/basic-filters.dto';\nimport { UpdateModuleMetadataDto } from '../dtos/update-module-metadata.dto';\nimport {\n ADD_MODULE_COMMAND,\n SchematicService,\n} from '../helpers/schematic.service';\nimport { CommandService } from '../helpers/command.service';\nimport { SolidRegistry } from '../helpers/solid-registry';\nimport { CodeGenerationOptions, ModuleMetadataConfiguration } from '../interfaces';\nimport { CrudHelperService } from './crud-helper.service';\nimport { ModelMetadataService } from './model-metadata.service';\nimport { SettingService } from './setting.service';\n\n@Injectable()\nexport class ModuleMetadataService {\n private readonly logger = new Logger(ModuleMetadataService.name);\n\n constructor(\n @InjectDataSource()\n private readonly dataSource: DataSource,\n // @InjectRepository(ModuleMetadata)\n // private readonly moduleMetadataRepo: Repository<ModuleMetadata>,\n private readonly moduleMetadataRepo: ModuleMetadataRepository,\n private readonly crudHelperService: CrudHelperService,\n private readonly schematicService: SchematicService,\n private readonly commandService: CommandService,\n private readonly fileService: DiskFileService,\n private readonly settingService: SettingService,\n\n private readonly permissionsSeederService: PermissionMetadataSeederService,\n @Inject(forwardRef(() => ModelMetadataService))\n private readonly modelMetadataService: ModelMetadataService,\n private readonly solidRegistry: SolidRegistry,\n private readonly moduleMetadataHelperService: ModuleMetadataHelperService,\n ) { }\n\n async findMany(basicFilterDto: BasicFilterDto) {\n const alias = 'moduleMetadata';\n // Extract the required keys from the input query\n let { limit, offset } = basicFilterDto;\n\n // Create above query on pincode table using query builder\n var qb: SelectQueryBuilder<ModuleMetadata> = await this.moduleMetadataRepo.createSecurityRuleAwareQueryBuilder(alias)\n qb = await this.crudHelperService.buildFilterQuery(qb, basicFilterDto, alias);\n\n // Get the records and the count\n const [entities, count] = await qb.getManyAndCount();\n\n const currentPage = Math.floor(offset / limit) + 1;\n const totalPages = Math.ceil(count / limit);\n\n const nextPage = currentPage < totalPages ? currentPage + 1 : null;\n const prevPage = currentPage > 1 ? currentPage - 1 : null;\n\n const r = {\n meta: {\n totalRecords: count,\n currentPage: currentPage,\n nextPage: nextPage,\n prevPage: prevPage,\n totalPages: totalPages,\n perPage: +limit,\n },\n records: entities\n };\n return r\n }\n\n async find(basicFilterDto: BasicFilterDto) {\n return this.findMany(basicFilterDto);\n }\n\n async findOneByUserKey(name: string, relations = {}) {\n if (!name) {\n throw new BadRequestException(ERROR_MESSAGES.ENTITY_NAME_REQUIRED);\n }\n const entity = await this.moduleMetadataRepo.findOne({\n where: {\n name: name,\n },\n relations: relations,\n });\n return entity;\n }\n\n async findOne(id: number, relations = {}) {\n if (!id) {\n throw new BadRequestException(ERROR_MESSAGES.ENTITY_ID_REQUIRED);\n }\n const entity = await this.moduleMetadataRepo.findOne({\n where: {\n id: id,\n },\n relations: relations,\n });\n if (!entity) {\n throw new NotFoundException(ERROR_MESSAGES.ENTITY_NOT_FOUND());\n }\n return entity;\n }\n\n async create(createDto: CreateModuleMetadataDto, files: Express.Multer.File[] = []) {\n try {\n return await this.dataSource.transaction(async (manager: EntityManager) => {\n // Step 1: Write initial data to the database\n const module = await this.createInDB(manager, createDto, files);\n await this.createInFile(module);\n return module\n });\n } catch (error: any) {\n // console.error('Transaction failed:', error);\n this.logger.error('Transaction failed:', error);\n throw error;\n }\n }\n\n async createInDB(manager: EntityManager, createDto: CreateModuleMetadataDto, files: Express.Multer.File[] = []) {\n if (files.length > 0) {\n const fileStoragePath = this.getFullFilePathForDisk(this.getFileName(files[0]));\n this.fileService.copy(files[0].path, fileStoragePath);\n this.fileService.delete(files[0].path);\n createDto.menuIconUrl = fileStoragePath;\n }\n const moduleMetadata = this.moduleMetadataRepo.create(createDto);\n return manager.save(moduleMetadata); // Use the provided manager to perform DB operations\n }\n\n async createInFile(module: ModuleMetadata) {\n try {\n // Prepare the metadata JSON structure\n\n const moduleMetaDataJson: ModuleMetadataConfiguration = {\n moduleMetadata: {\n name: module?.name,\n displayName: module?.displayName,\n description: module?.description,\n defaultDataSource: module?.defaultDataSource,\n menuIconUrl: module?.menuIconUrl,\n menuSequenceNumber: module?.menuSequenceNumber,\n isSystem: module?.isSystem,\n models: [],\n },\n roles: [],\n users: [],\n actions: [\n {\n displayName: `${module?.name} Home`,\n name: `${module?.name}-home-action`,\n type: \"custom\",\n domain: \"\",\n context: \"\",\n customComponent: `/admin/core/${module?.name}/home`,\n customIsModal: true,\n serverEndpoint: \"\",\n viewUserKey: \"\",\n moduleUserKey: module?.name,\n modelUserKey: \"\"\n }\n ],\n menus: [\n {\n displayName: \"Home\",\n name: `${module?.name}-home-menu`,\n sequenceNumber: 1,\n actionUserKey: `${module?.name}-home-action`,\n moduleUserKey: module?.name,\n parentMenuItemUserKey: \"\",\n iconName: \"home\"\n }\n ],\n views: [],\n emailTemplates: [],\n smsTemplates: [],\n mediaStorageProviders: [],\n securityRules: [],\n };\n\n // Convert the object to JSON string\n const metadataJson = JSON.stringify(moduleMetaDataJson, null, 2);\n\n // Create the folder path inside 'module-metadata'\n const folderPath = path.resolve(process.cwd(), 'module-metadata', module.name);\n const filePath = await this.moduleMetadataHelperService.getModuleMetadataFilePath(module.name);\n\n // Ensure the folder exists\n await fs.mkdir(folderPath, { recursive: true });\n\n // Write the JSON to the file\n await fs.writeFile(filePath, metadataJson);\n\n } catch (error: any) {\n // console.error('File creation failed:', error);\n this.logger.error('File creation failed:', error);\n throw new Error(ERROR_MESSAGES.FILE_WRITE_FAILED); // Trigger rollback\n }\n }\n\n async update(id: number, updateModuleMetadataDto: UpdateModuleMetadataDto, files: Express.Multer.File[] = []) {\n try {\n return await this.dataSource.transaction(async (manager: EntityManager) => {\n // Step 1: Write initial data to the database\n const module = await this.updateInDB(manager, id, updateModuleMetadataDto, files);\n await this.updateInFile(module);\n return module\n });\n } catch (error: any) {\n // console.error('Transaction failed:', error);\n this.logger.error('Transaction failed:', error);\n throw error;\n }\n }\n\n async updateInDB(manager: EntityManager, id: number, updateModuleMetadataDto: UpdateModuleMetadataDto, files: Express.Multer.File[] = []) {\n\n const module = await this.moduleMetadataRepo.preload({\n id,\n ...updateModuleMetadataDto,\n });\n\n if (!module) {\n throw new NotFoundException(ERROR_MESSAGES.MODULE_ID_NOT_FOUND(id));\n }\n if (files.length > 0) {\n\n const fileStoragePath = this.getFullFilePathForDisk(this.getFileName(files[0]));\n this.fileService.copy(files[0].path, fileStoragePath);\n this.fileService.delete(files[0].path);\n module.menuIconUrl = fileStoragePath;\n }\n return manager.save(ModuleMetadata, module);\n }\n\n async updateInFile(module: ModuleMetadata) {\n try {\n const filePath = await this.moduleMetadataHelperService.getModuleMetadataFilePath(module.name);\n\n // Read the existing JSON file\n let metaData;\n try {\n metaData = await this.moduleMetadataHelperService.getModuleMetadataConfiguration(filePath);\n\n } catch (error: any) {\n metaData = {\n moduleMetadata: {\n name: null,\n displayName: null,\n description: null,\n defaultDataSource: null,\n menuIconUrl: null,\n menuSequenceNumber: null,\n isSystem: null,\n models: [],\n },\n roles: [],\n users: [],\n actions: [],\n menus: [],\n views: [],\n emailTemplates: [],\n smsTemplates: [],\n mediaStorageProviders: [],\n };\n }\n\n metaData.moduleMetadata.name = module?.name;\n metaData.moduleMetadata.displayName = module?.displayName;\n metaData.moduleMetadata.description = module?.description;\n metaData.moduleMetadata.defaultDataSource = module?.defaultDataSource;\n metaData.moduleMetadata.menuIconUrl = module?.menuIconUrl;\n metaData.moduleMetadata.menuSequenceNumber = module?.menuSequenceNumber;\n metaData.moduleMetadata.isSystem = module?.isSystem;\n\n // Write the JSON to the file\n const updatedContent = JSON.stringify(metaData, null, 2);\n await fs.writeFile(filePath, updatedContent);\n\n } catch (error: any) {\n // console.error('File creation failed:', error);\n this.logger.error('File creation failed:', error);\n throw new Error(ERROR_MESSAGES.FILE_WRITE_FAILED); // Trigger rollback\n }\n }\n\n async upsert(updateModuleMetadataDto: UpdateModuleMetadataDto) {\n this.logger.debug(`Module Upsert called for : ${updateModuleMetadataDto.name}`);\n // First check if module already exists using name\n const existingModuleMetadata = await this.moduleMetadataRepo.findOne({\n where: {\n name: updateModuleMetadataDto.name\n }\n })\n const { models, ...restUpdateModuleMetadataDto } = updateModuleMetadataDto;\n // if found\n if (existingModuleMetadata) {\n const updatedModuleMetadata = { ...existingModuleMetadata, ...restUpdateModuleMetadataDto };\n return this.moduleMetadataRepo.save(updatedModuleMetadata);\n }\n // if not found - create new \n else {\n const moduleMetadata = this.moduleMetadataRepo.create(restUpdateModuleMetadataDto);\n return this.moduleMetadataRepo.save(moduleMetadata);\n }\n }\n\n async removeByName(name: string) {\n const entity = await this.findOneByUserKey(name);\n if (entity) {\n await this.moduleMetadataRepo.remove(entity);\n }\n }\n\n @DisallowInProduction()\n async remove(id: number) {\n const entity = await this.findOne(id);\n await this.cleanupOnDelete(entity.id);\n const r = await this.moduleMetadataRepo.remove(entity);\n return r\n }\n\n async cleanupOnDelete(moduleEntityId: number) {\n const moduleEntity = await this.moduleMetadataRepo.findOne({\n where: {\n // @ts-ignore\n id: moduleEntityId,\n }\n });\n\n if (!moduleEntity) {\n this.logger.log(`Invalid moduleEntityId: ${moduleEntityId} unable to resolve model metadata`);\n return;\n }\n if (moduleEntity.id !== moduleEntityId) {\n this.logger.log(`Invalid moduleEntityId: ${moduleEntityId} unable to resolve model metadata id ${moduleEntity.id} not matching with the one passed as argument ${moduleEntityId}`);\n return;\n }\n\n this.logger.log(`Cleaning up for module: ${moduleEntity.name}.`);\n\n const modulePath = await this.moduleMetadataHelperService.getModulePath(moduleEntity.name);\n if (modulePath) {\n\n this.logger.log(`Module path: ${modulePath}`);\n\n // Metadata file to be deleted\n const moduleMetadataPAth = await this.moduleMetadataHelperService.getModuleMetadataFolderPath(moduleEntity.name)\n this.logger.log(`About to delete module metadata path: ${moduleMetadataPAth}`);\n\n try {\n await fs.rm(modulePath, { recursive: true, force: true });\n await fs.rm(moduleMetadataPAth, { recursive: true, force: true });\n this.logger.log(`Deleted file: ${moduleMetadataPAth}`);\n } catch (error: any) {\n this.logger.error(`Error deleting file: ${moduleMetadataPAth}`, error);\n throw new Error(ERROR_MESSAGES.FILE_DELETE_FAILED); // Trigger rollback\n }\n }\n await this.dataSource.query(\n `CALL cleanup_module_metadata($1, $2)`,\n [moduleEntity.name, true],\n );\n }\n\n async deleteMany(ids: number[]): Promise<any> {\n if (!ids || ids.length === 0) {\n throw new Error(ERROR_MESSAGES.DELETE_IDS_REQUIRED);\n }\n const removedEntities = [];\n for (let i = 0; i < ids.length; i++) {\n const id = ids[i]\n const entity = await this.moduleMetadataRepo.findOne({\n where: {\n //@ts-ignore\n id: id,\n }\n });\n // if (!entity) {\n // throw new Error(`Entity with id ${id} not found`);\n // }\n removedEntities.push(await this.moduleMetadataRepo.remove(entity));\n }\n\n return removedEntities\n }\n\n async refreshPermission() {\n await this.permissionsSeederService.seed();\n return true\n }\n\n @DisallowInProduction()\n async generateCodeViaCtl(moduleId: number): Promise<string> {\n return this.commandService.executeCommandWithArgs({\n command: 'npx',\n args: ['@solixai/solidctl@latest', 'generate', 'module', `--id=${moduleId}`],\n cwd: path.join(process.cwd(), '..'),\n });\n }\n\n @DisallowInProduction()\n async generateCode(options: CodeGenerationOptions): Promise<string> {\n if (!options.moduleId && !options.moduleUserKey) {\n throw new BadRequestException(ERROR_MESSAGES.MODEL_REQUIRED_FOR_CODE_GENERATION);\n }\n const module = options.moduleId ? await this.findOne(options.moduleId) : await this.findOneByUserKey(options.moduleUserKey);\n\n // Check if the module exists\n if (!module) {\n throw new NotFoundException(ERROR_MESSAGES.MODULE_ID_NOT_FOUND(options.moduleId));\n }\n\n // Check if the module name already exists and is loaded\n const moduleInstance = this.solidRegistry.getModule(`${classify(module.name)}Module`);\n\n if (!moduleInstance) {\n const addModuleOutput = await this.generateAddModuleCode(options);\n const refreshModuleOutput = await this.generateRefreshModuleCode(options);\n return `${addModuleOutput}\\n${refreshModuleOutput}`;\n } else {\n return await this.generateRefreshModuleCode(options);\n }\n }\n\n private async generateAddModuleCode(options: CodeGenerationOptions = { dryRun: false }): Promise<string> {\n if (!options.moduleId && !options.moduleUserKey) {\n throw new BadRequestException(ERROR_MESSAGES.MODEL_REQUIRED_FOR_CODE_GENERATION);\n }\n const module = options.moduleId ? await this.findOne(options.moduleId) : await this.findOneByUserKey(options.moduleUserKey);\n\n //Generate the module\n const output = await this.schematicService.executeSchematicCommand(\n ADD_MODULE_COMMAND,\n { module: module.name },\n options.dryRun ?? false\n );\n this.logger.debug(`Schematic output : ${output}`);\n return output;\n }\n\n private async generateRefreshModuleCode(options: CodeGenerationOptions): Promise<string> {\n const query = {\n relations: { models: { fields: true } },\n };\n const module = options.moduleId ? await this.findOne(options.moduleId, query.relations) : await this.findOneByUserKey(options.moduleUserKey, query.relations);\n const outputLines = []\n for (const model of module.models) {\n const codeGenerationOptions = {\n modelId: model.id,\n dryRun: options.dryRun,\n };\n const output = await this.modelMetadataService.handleGenerateCode(codeGenerationOptions);\n this.logger.debug(`Schematic output : ${output}`);\n outputLines.push(output)\n }\n return outputLines.join('\\n');\n }\n\n private getFullFilePathForDisk(fileName: string): string {\n const base = this.settingService.getConfigValue<SolidCoreSetting>(\"fileStorageDir\")\n || DEFAULT_MEDIA_FILE_STORAGE_DIR;\n if (path.isAbsolute(fileName) || fileName.startsWith(`${base}/`)) {\n return fileName;\n }\n return `${base}/${fileName}`;\n }\n\n private getFileName(file: Express.Multer.File): string {\n return `${file.filename}-${file.originalname}`;\n }\n\n}\n"]}
1
+ {"version":3,"file":"module-metadata.service.js","sourceRoot":"","sources":["../../src/services/module-metadata.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAgH;AAChH,6CAAmD;AACnD,oGAAyG;AAEzG,qCAAwE;AAExE,+EAAoE;AAEpE,4DAAoD;AAEpD,gDA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AC,GAAG,IAAI,GAAG,CAAC,EAAE,CAAC;YACjE,OAAO,QAAQ,CAAC;QAClB,CAAC;QACD,OAAO,GAAG,IAAI,IAAI,QAAQ,EAAE,CAAC;IAC/B,CAAC;IAEO,WAAW,CAAC,IAAyB;QAC3C,OAAO,GAAG,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;IACjD,CAAC;CAEF,CAAA;AAxcY,sDAAqB;AA0S1B;IADL,IAAA,uDAAoB,GAAE;;;;mDAMtB;AAyEK;IADL,IAAA,uDAAoB,GAAE;;;;+DAQtB;AAGK;IADL,IAAA,uDAAoB,GAAE;;;;yDAsBtB;gCAvZU,qBAAqB;IADjC,IAAA,mBAAU,GAAE;IAKR,WAAA,IAAA,0BAAgB,GAAE,CAAA;IAYlB,WAAA,IAAA,eAAM,EAAC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,6CAAoB,CAAC,CAAC,CAAA;qCAXlB,oBAAU;QAGF,qDAAwB;QACzB,uCAAiB;QAClB,oCAAgB;QAClB,gCAAc;QACjB,sBAAe;QACZ,gCAAc;QAEJ,oEAA+B;QAEnC,6CAAoB;QAC3B,8BAAa;QACC,4DAA2B;GAnBhE,qBAAqB,CAwcjC","sourcesContent":["import { BadRequestException, forwardRef, Inject, Injectable, Logger, NotFoundException } from '@nestjs/common';\nimport { InjectDataSource } from '@nestjs/typeorm';\nimport { DEFAULT_MEDIA_FILE_STORAGE_DIR } from \"src/services/settings/default-settings-provider.service\";\nimport type { SolidCoreSetting } from \"src/services/settings/default-settings-provider.service\";\nimport { DataSource, EntityManager, SelectQueryBuilder } from 'typeorm';\nimport { CreateModuleMetadataDto } from '../dtos/create-module-metadata.dto';\nimport { ModuleMetadata } from '../entities/module-metadata.entity';\n\nimport { classify } from '../helpers/string.helper';\nimport { ConfigService } from '@nestjs/config';\nimport * as fs from 'fs/promises'; // Use the Promise-based version of fs for async/await\nimport * as path from 'path'; // To handle file paths\nimport { ERROR_MESSAGES } from 'src/constants/error-messages';\nimport { DisallowInProduction } from 'src/decorators/disallow-in-production.decorator';\nimport { ModuleMetadataHelperService } from 'src/helpers/module-metadata-helper.service';\nimport { ModuleMetadataRepository } from 'src/repository/module-metadata.repository';\nimport { PermissionMetadataSeederService } from 'src/seeders/permission-metadata-seeder.service';\nimport { DiskFileService } from 'src/services/file';\nimport { BasicFilterDto } from '../dtos/basic-filters.dto';\nimport { UpdateModuleMetadataDto } from '../dtos/update-module-metadata.dto';\nimport {\n ADD_MODULE_COMMAND,\n SchematicService,\n} from '../helpers/schematic.service';\nimport { CommandService } from '../helpers/command.service';\nimport { SolidRegistry } from '../helpers/solid-registry';\nimport { CodeGenerationOptions, ModuleMetadataConfiguration } from '../interfaces';\nimport { CrudHelperService } from './crud-helper.service';\nimport { ModelMetadataService } from './model-metadata.service';\nimport { SettingService } from './setting.service';\n\n@Injectable()\nexport class ModuleMetadataService {\n private readonly logger = new Logger(ModuleMetadataService.name);\n\n constructor(\n @InjectDataSource()\n private readonly dataSource: DataSource,\n // @InjectRepository(ModuleMetadata)\n // private readonly moduleMetadataRepo: Repository<ModuleMetadata>,\n private readonly moduleMetadataRepo: ModuleMetadataRepository,\n private readonly crudHelperService: CrudHelperService,\n private readonly schematicService: SchematicService,\n private readonly commandService: CommandService,\n private readonly fileService: DiskFileService,\n private readonly settingService: SettingService,\n\n private readonly permissionsSeederService: PermissionMetadataSeederService,\n @Inject(forwardRef(() => ModelMetadataService))\n private readonly modelMetadataService: ModelMetadataService,\n private readonly solidRegistry: SolidRegistry,\n private readonly moduleMetadataHelperService: ModuleMetadataHelperService,\n ) { }\n\n async findMany(basicFilterDto: BasicFilterDto) {\n const alias = 'moduleMetadata';\n // Extract the required keys from the input query\n let { limit, offset } = basicFilterDto;\n\n // Create above query on pincode table using query builder\n var qb: SelectQueryBuilder<ModuleMetadata> = await this.moduleMetadataRepo.createSecurityRuleAwareQueryBuilder(alias)\n qb = await this.crudHelperService.buildFilterQuery(qb, basicFilterDto, alias);\n\n // Get the records and the count\n const [entities, count] = await qb.getManyAndCount();\n\n const currentPage = Math.floor(offset / limit) + 1;\n const totalPages = Math.ceil(count / limit);\n\n const nextPage = currentPage < totalPages ? currentPage + 1 : null;\n const prevPage = currentPage > 1 ? currentPage - 1 : null;\n\n const r = {\n meta: {\n totalRecords: count,\n currentPage: currentPage,\n nextPage: nextPage,\n prevPage: prevPage,\n totalPages: totalPages,\n perPage: +limit,\n },\n records: entities\n };\n return r\n }\n\n async find(basicFilterDto: BasicFilterDto) {\n return this.findMany(basicFilterDto);\n }\n\n async findOneByUserKey(name: string, relations = {}) {\n if (!name) {\n throw new BadRequestException(ERROR_MESSAGES.ENTITY_NAME_REQUIRED);\n }\n const entity = await this.moduleMetadataRepo.findOne({\n where: {\n name: name,\n },\n relations: relations,\n });\n return entity;\n }\n\n async findOne(id: number, relations = {}) {\n if (!id) {\n throw new BadRequestException(ERROR_MESSAGES.ENTITY_ID_REQUIRED);\n }\n const entity = await this.moduleMetadataRepo.findOne({\n where: {\n id: id,\n },\n relations: relations,\n });\n if (!entity) {\n throw new NotFoundException(ERROR_MESSAGES.ENTITY_NOT_FOUND());\n }\n return entity;\n }\n\n async create(createDto: CreateModuleMetadataDto, files: Express.Multer.File[] = []) {\n try {\n return await this.dataSource.transaction(async (manager: EntityManager) => {\n // Step 1: Write initial data to the database\n const module = await this.createInDB(manager, createDto, files);\n await this.createInFile(module);\n return module\n });\n } catch (error: any) {\n // console.error('Transaction failed:', error);\n this.logger.error('Transaction failed:', error);\n throw error;\n }\n }\n\n async createInDB(manager: EntityManager, createDto: CreateModuleMetadataDto, files: Express.Multer.File[] = []) {\n if (files.length > 0) {\n const fileStoragePath = this.getFullFilePathForDisk(this.getFileName(files[0]));\n this.fileService.copy(files[0].path, fileStoragePath);\n this.fileService.delete(files[0].path);\n createDto.menuIconUrl = fileStoragePath;\n }\n const moduleMetadata = this.moduleMetadataRepo.create(createDto);\n return manager.save(moduleMetadata); // Use the provided manager to perform DB operations\n }\n\n async createInFile(module: ModuleMetadata) {\n try {\n // Prepare the metadata JSON structure\n\n const moduleMetaDataJson: ModuleMetadataConfiguration = {\n moduleMetadata: {\n name: module?.name,\n displayName: module?.displayName,\n description: module?.description,\n defaultDataSource: module?.defaultDataSource,\n menuIconUrl: module?.menuIconUrl,\n menuSequenceNumber: module?.menuSequenceNumber,\n isSystem: module?.isSystem,\n models: [],\n },\n roles: [],\n users: [],\n actions: [\n {\n displayName: `${module?.name} Home`,\n name: `${module?.name}-home-action`,\n type: \"custom\",\n domain: \"\",\n context: \"\",\n customComponent: `/admin/core/${module?.name}/home`,\n customIsModal: true,\n serverEndpoint: \"\",\n viewUserKey: \"\",\n moduleUserKey: module?.name,\n modelUserKey: \"\"\n }\n ],\n menus: [\n {\n displayName: \"Home\",\n name: `${module?.name}-home-menu`,\n sequenceNumber: 1,\n actionUserKey: `${module?.name}-home-action`,\n moduleUserKey: module?.name,\n parentMenuItemUserKey: \"\",\n iconName: \"home\"\n }\n ],\n views: [],\n emailTemplates: [],\n smsTemplates: [],\n mediaStorageProviders: [],\n securityRules: [],\n };\n\n // Convert the object to JSON string\n const metadataJson = JSON.stringify(moduleMetaDataJson, null, 2);\n\n // Create the folder path inside 'module-metadata'\n const folderPath = path.resolve(process.cwd(), 'module-metadata', module.name);\n const filePath = await this.moduleMetadataHelperService.getModuleMetadataFilePath(module.name);\n\n // Ensure the folder exists\n await fs.mkdir(folderPath, { recursive: true });\n\n // Write the JSON to the file\n await fs.writeFile(filePath, metadataJson);\n\n } catch (error: any) {\n // console.error('File creation failed:', error);\n this.logger.error('File creation failed:', error);\n throw new Error(ERROR_MESSAGES.FILE_WRITE_FAILED); // Trigger rollback\n }\n }\n\n async update(id: number, updateModuleMetadataDto: UpdateModuleMetadataDto, files: Express.Multer.File[] = []) {\n try {\n return await this.dataSource.transaction(async (manager: EntityManager) => {\n // Step 1: Write initial data to the database\n const module = await this.updateInDB(manager, id, updateModuleMetadataDto, files);\n await this.updateInFile(module);\n return module\n });\n } catch (error: any) {\n // console.error('Transaction failed:', error);\n this.logger.error('Transaction failed:', error);\n throw error;\n }\n }\n\n async updateInDB(manager: EntityManager, id: number, updateModuleMetadataDto: UpdateModuleMetadataDto, files: Express.Multer.File[] = []) {\n\n const module = await this.moduleMetadataRepo.preload({\n id,\n ...updateModuleMetadataDto,\n });\n\n if (!module) {\n throw new NotFoundException(ERROR_MESSAGES.MODULE_ID_NOT_FOUND(id));\n }\n if (files.length > 0) {\n\n const fileStoragePath = this.getFullFilePathForDisk(this.getFileName(files[0]));\n this.fileService.copy(files[0].path, fileStoragePath);\n this.fileService.delete(files[0].path);\n module.menuIconUrl = fileStoragePath;\n }\n return manager.save(ModuleMetadata, module);\n }\n\n async updateInFile(module: ModuleMetadata) {\n try {\n const filePath = await this.moduleMetadataHelperService.getModuleMetadataFilePath(module.name);\n\n // Read the existing JSON file\n let metaData;\n try {\n metaData = await this.moduleMetadataHelperService.getModuleMetadataConfiguration(filePath);\n\n } catch (error: any) {\n metaData = {\n moduleMetadata: {\n name: null,\n displayName: null,\n description: null,\n defaultDataSource: null,\n menuIconUrl: null,\n menuSequenceNumber: null,\n isSystem: null,\n models: [],\n },\n roles: [],\n users: [],\n actions: [],\n menus: [],\n views: [],\n emailTemplates: [],\n smsTemplates: [],\n mediaStorageProviders: [],\n };\n }\n\n metaData.moduleMetadata.name = module?.name;\n metaData.moduleMetadata.displayName = module?.displayName;\n metaData.moduleMetadata.description = module?.description;\n metaData.moduleMetadata.defaultDataSource = module?.defaultDataSource;\n metaData.moduleMetadata.menuIconUrl = module?.menuIconUrl;\n metaData.moduleMetadata.menuSequenceNumber = module?.menuSequenceNumber;\n metaData.moduleMetadata.isSystem = module?.isSystem;\n\n // Write the JSON to the file\n const updatedContent = JSON.stringify(metaData, null, 2);\n await fs.writeFile(filePath, updatedContent);\n\n } catch (error: any) {\n // console.error('File creation failed:', error);\n this.logger.error('File creation failed:', error);\n throw new Error(ERROR_MESSAGES.FILE_WRITE_FAILED); // Trigger rollback\n }\n }\n\n async upsert(updateModuleMetadataDto: UpdateModuleMetadataDto) {\n this.logger.debug(`Module Upsert called for : ${updateModuleMetadataDto.name}`);\n // First check if module already exists using name\n const existingModuleMetadata = await this.moduleMetadataRepo.findOne({\n where: {\n name: updateModuleMetadataDto.name\n }\n })\n const { models, ...restUpdateModuleMetadataDto } = updateModuleMetadataDto;\n // if found\n if (existingModuleMetadata) {\n const updatedModuleMetadata = { ...existingModuleMetadata, ...restUpdateModuleMetadataDto };\n return this.moduleMetadataRepo.save(updatedModuleMetadata);\n }\n // if not found - create new \n else {\n const moduleMetadata = this.moduleMetadataRepo.create(restUpdateModuleMetadataDto);\n return this.moduleMetadataRepo.save(moduleMetadata);\n }\n }\n\n async removeByName(name: string) {\n const entity = await this.findOneByUserKey(name);\n if (entity) {\n await this.moduleMetadataRepo.remove(entity);\n }\n }\n\n @DisallowInProduction()\n async remove(id: number) {\n const entity = await this.findOne(id);\n await this.cleanupOnDelete(entity.id);\n const r = await this.moduleMetadataRepo.remove(entity);\n return r\n }\n\n async cleanupOnDelete(moduleEntityId: number) {\n const moduleEntity = await this.moduleMetadataRepo.findOne({\n where: {\n // @ts-ignore\n id: moduleEntityId,\n }\n });\n\n if (!moduleEntity) {\n this.logger.log(`Invalid moduleEntityId: ${moduleEntityId} unable to resolve model metadata`);\n return;\n }\n if (moduleEntity.id !== moduleEntityId) {\n this.logger.log(`Invalid moduleEntityId: ${moduleEntityId} unable to resolve model metadata id ${moduleEntity.id} not matching with the one passed as argument ${moduleEntityId}`);\n return;\n }\n\n this.logger.log(`Cleaning up for module: ${moduleEntity.name}.`);\n\n const modulePath = await this.moduleMetadataHelperService.getModulePath(moduleEntity.name);\n if (modulePath) {\n\n this.logger.log(`Module path: ${modulePath}`);\n\n // Metadata file to be deleted\n const moduleMetadataPAth = await this.moduleMetadataHelperService.getModuleMetadataFolderPath(moduleEntity.name)\n this.logger.log(`About to delete module metadata path: ${moduleMetadataPAth}`);\n\n try {\n await fs.rm(modulePath, { recursive: true, force: true });\n await fs.rm(moduleMetadataPAth, { recursive: true, force: true });\n this.logger.log(`Deleted file: ${moduleMetadataPAth}`);\n } catch (error: any) {\n this.logger.error(`Error deleting file: ${moduleMetadataPAth}`, error);\n throw new Error(ERROR_MESSAGES.FILE_DELETE_FAILED); // Trigger rollback\n }\n }\n await this.dataSource.query(\n `CALL cleanup_module_metadata($1, $2)`,\n [moduleEntity.name, true],\n );\n }\n\n async deleteMany(ids: number[]): Promise<any> {\n if (!ids || ids.length === 0) {\n throw new Error(ERROR_MESSAGES.DELETE_IDS_REQUIRED);\n }\n const removedEntities = [];\n for (let i = 0; i < ids.length; i++) {\n const id = ids[i]\n const entity = await this.moduleMetadataRepo.findOne({\n where: {\n //@ts-ignore\n id: id,\n }\n });\n // if (!entity) {\n // throw new Error(`Entity with id ${id} not found`);\n // }\n removedEntities.push(await this.moduleMetadataRepo.remove(entity));\n }\n\n return removedEntities\n }\n\n async refreshPermission() {\n await this.permissionsSeederService.seed();\n return true\n }\n\n @DisallowInProduction()\n async generateCodeViaCtl(moduleId: number): Promise<string> {\n const module = await this.findOne(moduleId);\n return this.commandService.executeCommandWithArgs({\n command: 'npx',\n args: ['@solixai/solidctl@latest', 'generate', 'module', `--name=${module.name}`],\n cwd: path.join(process.cwd(), '..'),\n });\n }\n\n @DisallowInProduction()\n async generateCode(options: CodeGenerationOptions): Promise<string> {\n if (!options.moduleId && !options.moduleUserKey) {\n throw new BadRequestException(ERROR_MESSAGES.MODEL_REQUIRED_FOR_CODE_GENERATION);\n }\n const module = options.moduleId ? await this.findOne(options.moduleId) : await this.findOneByUserKey(options.moduleUserKey);\n\n // Check if the module exists\n if (!module) {\n throw new NotFoundException(ERROR_MESSAGES.MODULE_ID_NOT_FOUND(options.moduleId));\n }\n\n // Check if the module name already exists and is loaded\n const moduleInstance = this.solidRegistry.getModule(`${classify(module.name)}Module`);\n\n if (!moduleInstance) {\n const addModuleOutput = await this.generateAddModuleCode(options);\n const refreshModuleOutput = await this.generateRefreshModuleCode(options);\n return `${addModuleOutput}\\n${refreshModuleOutput}`;\n } else {\n return await this.generateRefreshModuleCode(options);\n }\n }\n\n private async generateAddModuleCode(options: CodeGenerationOptions = { dryRun: false }): Promise<string> {\n if (!options.moduleId && !options.moduleUserKey) {\n throw new BadRequestException(ERROR_MESSAGES.MODEL_REQUIRED_FOR_CODE_GENERATION);\n }\n const module = options.moduleId ? await this.findOne(options.moduleId) : await this.findOneByUserKey(options.moduleUserKey);\n\n //Generate the module\n const output = await this.schematicService.executeSchematicCommand(\n ADD_MODULE_COMMAND,\n { module: module.name },\n options.dryRun ?? false\n );\n this.logger.debug(`Schematic output : ${output}`);\n return output;\n }\n\n private async generateRefreshModuleCode(options: CodeGenerationOptions): Promise<string> {\n const query = {\n relations: { models: { fields: true } },\n };\n const module = options.moduleId ? await this.findOne(options.moduleId, query.relations) : await this.findOneByUserKey(options.moduleUserKey, query.relations);\n const outputLines = []\n for (const model of module.models) {\n const codeGenerationOptions = {\n modelId: model.id,\n dryRun: options.dryRun,\n };\n const output = await this.modelMetadataService.handleGenerateCode(codeGenerationOptions);\n this.logger.debug(`Schematic output : ${output}`);\n outputLines.push(output)\n }\n return outputLines.join('\\n');\n }\n\n private getFullFilePathForDisk(fileName: string): string {\n const base = this.settingService.getConfigValue<SolidCoreSetting>(\"fileStorageDir\")\n || DEFAULT_MEDIA_FILE_STORAGE_DIR;\n if (path.isAbsolute(fileName) || fileName.startsWith(`${base}/`)) {\n return fileName;\n }\n return `${base}/${fileName}`;\n }\n\n private getFileName(file: Express.Multer.File): string {\n return `${file.filename}-${file.originalname}`;\n }\n\n}\n"]}
@@ -1,6 +1,11 @@
1
1
  import { Logger as TypeORMLogger, QueryRunner } from 'typeorm';
2
2
  import { Logger } from 'winston';
3
3
  import * as winston from 'winston';
4
+ export declare const createWinstonLoggerConfig: () => {
5
+ level: string;
6
+ format: winston.Logform.Format;
7
+ transports: (winston.transports.ConsoleTransportInstance | winston.transports.FileTransportInstance)[];
8
+ };
4
9
  export declare const WinstonLoggerConfig: {
5
10
  level: string;
6
11
  format: winston.Logform.Format;
@@ -1 +1 @@
1
- {"version":3,"file":"winston.logger.d.ts","sourceRoot":"","sources":["../src/winston.logger.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,IAAI,aAAa,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAGjC,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AAGnC,eAAO,MAAM,mBAAmB;;;;CAgC/B,CAAC;AAEF,qBAAa,oBAAqB,YAAW,aAAa;IACT,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,MAAM;IAE5E,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,GAAG,EAAE,EAAE,WAAW,CAAC,EAAE,WAAW,GAAG,IAAI;IAM5E,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,GAAG,EAAE,EAAE,WAAW,CAAC,EAAE,WAAW,GAAG,IAAI;IAIhG,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,GAAG,EAAE,EAAE,WAAW,CAAC,EAAE,WAAW,GAAG,IAAI;IAI9F,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,WAAW,GAAG,IAAI;IAIhE,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,WAAW,GAAG,IAAI;IAI9D,GAAG,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,EAAE,OAAO,EAAE,GAAG,GAAG,IAAI;CAGpE"}
1
+ {"version":3,"file":"winston.logger.d.ts","sourceRoot":"","sources":["../src/winston.logger.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,IAAI,aAAa,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAGjC,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AAGnC,eAAO,MAAM,yBAAyB;;;;CA4BpC,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;CAA8B,CAAC;AAE/D,qBAAa,oBAAqB,YAAW,aAAa;IACT,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,MAAM;IAE5E,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,GAAG,EAAE,EAAE,WAAW,CAAC,EAAE,WAAW,GAAG,IAAI;IAM5E,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,GAAG,EAAE,EAAE,WAAW,CAAC,EAAE,WAAW,GAAG,IAAI;IAIhG,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,GAAG,EAAE,EAAE,WAAW,CAAC,EAAE,WAAW,GAAG,IAAI;IAI9F,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,WAAW,GAAG,IAAI;IAIhE,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,WAAW,GAAG,IAAI;IAI9D,GAAG,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,EAAE,OAAO,EAAE,GAAG,GAAG,IAAI;CAGpE"}
@@ -45,14 +45,14 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
45
45
  return function (target, key) { decorator(target, key, paramIndex); }
46
46
  };
47
47
  Object.defineProperty(exports, "__esModule", { value: true });
48
- exports.WinstonTypeORMLogger = exports.WinstonLoggerConfig = void 0;
48
+ exports.WinstonTypeORMLogger = exports.WinstonLoggerConfig = exports.createWinstonLoggerConfig = void 0;
49
49
  const winston_1 = require("winston");
50
50
  const common_1 = require("@nestjs/common");
51
51
  const nest_winston_1 = require("nest-winston");
52
52
  const winston = __importStar(require("winston"));
53
53
  const disallow_in_production_decorator_1 = require("./decorators/disallow-in-production.decorator");
54
- exports.WinstonLoggerConfig = {
55
- level: process.env.LOG_LEVEL || (process.env.ENV === disallow_in_production_decorator_1.Environment.Production ? 'info' : 'debug'),
54
+ const createWinstonLoggerConfig = () => ({
55
+ level: process.env.LOG_LEVEL || (process.env.ENV === disallow_in_production_decorator_1.Environment.Production ? 'warn' : 'info'),
56
56
  format: winston.format.combine(winston.format.timestamp(), winston.format.errors({ stack: true }), winston.format.printf(({ level, message, timestamp }) => {
57
57
  if (!message) {
58
58
  return `[${timestamp}] ${level.toUpperCase()}: (No message provided)`;
@@ -73,7 +73,9 @@ exports.WinstonLoggerConfig = {
73
73
  level: 'error',
74
74
  }),
75
75
  ],
76
- };
76
+ });
77
+ exports.createWinstonLoggerConfig = createWinstonLoggerConfig;
78
+ exports.WinstonLoggerConfig = (0, exports.createWinstonLoggerConfig)();
77
79
  let WinstonTypeORMLogger = class WinstonTypeORMLogger {
78
80
  constructor(logger) {
79
81
  this.logger = logger;
@@ -1 +1 @@
1
- {"version":3,"file":"winston.logger.js","sourceRoot":"","sources":["../src/winston.logger.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,qCAAiC;AACjC,2CAAwC;AACxC,+CAAuD;AACvD,iDAAmC;AACnC,oGAA4E;AAE/D,QAAA,mBAAmB,GAAG;IAC/B,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,8CAAW,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;IAC/F,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,OAAO,CAC1B,OAAO,CAA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,CAAC,IAAI,CAAC,UAAU,KAAK,gBAAgB,UAAU,EAAE,CAAC,CAAC;QAClE,CAAC;IACL,CAAC;IAED,aAAa,CAAC,KAAa,EAAE,KAAa,EAAE,UAAkB,EAAE,WAAyB;QACrF,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,iBAAiB,KAAK,aAAa,KAAK,kBAAkB,UAAU,EAAE,CAAC,CAAC;IAC9F,CAAC;IAED,YAAY,CAAC,IAAY,EAAE,KAAa,EAAE,UAAkB,EAAE,WAAyB;QACnF,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,eAAe,IAAI,eAAe,KAAK,kBAAkB,UAAU,EAAE,CAAC,CAAC;IAC5F,CAAC;IAED,cAAc,CAAC,OAAe,EAAE,WAAyB;QACrD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,iBAAiB,OAAO,EAAE,CAAC,CAAC;IACjD,CAAC;IAED,YAAY,CAAC,OAAe,EAAE,WAAyB;QACnD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,OAAO,EAAE,CAAC,CAAC;IAC9C,CAAC;IAED,GAAG,CAAC,KAAwC,EAAE,OAAY;QACtD,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC;CACJ,CAAA;AA5BY,oDAAoB;+BAApB,oBAAoB;IAChB,WAAA,IAAA,eAAM,EAAC,sCAAuB,CAAC,CAAA;qCAA0B,gBAAM;GADnE,oBAAoB,CA4BhC","sourcesContent":["\nimport { Logger as TypeORMLogger, QueryRunner } from 'typeorm';\nimport { Logger } from 'winston';\nimport { Inject } from '@nestjs/common';\nimport { WINSTON_MODULE_PROVIDER } from 'nest-winston';\nimport * as winston from 'winston';\nimport { Environment } from './decorators/disallow-in-production.decorator';\n\nexport const WinstonLoggerConfig = {\n level: process.env.LOG_LEVEL || (process.env.ENV === Environment.Production ? 'info' : 'debug'),\n format: winston.format.combine(\n winston.format.timestamp(),\n winston.format.errors({ stack: true }),\n winston.format.printf(({ level, message, timestamp }) => {\n if (!message) {\n return `[${timestamp}] ${level.toUpperCase()}: (No message provided)`;\n }\n return `[${timestamp}] ${level.toUpperCase()}: ${message}`;\n }),\n ),\n transports: [\n new winston.transports.Console({\n format: winston.format.combine(\n // winston.format.colorize(),\n // winston.format.timestamp(),\n winston.format.printf(({ level, message, timestamp }) => {\n return `[${timestamp}] ${level.toUpperCase()}: ${message}`;\n }),\n ),\n }),\n new winston.transports.File({\n filename: 'logs/application.log',\n // format: winston.format.json(),\n }),\n new winston.transports.File({\n filename: 'logs/error.log',\n level: 'error',\n // format: winston.format.json(),\n }),\n ],\n};\n\nexport class WinstonTypeORMLogger implements TypeORMLogger {\n constructor(@Inject(WINSTON_MODULE_PROVIDER) private readonly logger: Logger) { }\n\n logQuery(query: string, parameters?: any[], queryRunner?: QueryRunner): void {\n if (Boolean(process.env.DEFAULT_DATABASE_LOGGING)) {\n this.logger.info(`Query: ${query} Parameters: ${parameters}`);\n }\n }\n\n logQueryError(error: string, query: string, parameters?: any[], queryRunner?: QueryRunner): void {\n this.logger.error(`Query failed: ${error} | Query: ${query} | Parameters: ${parameters}`);\n }\n\n logQuerySlow(time: number, query: string, parameters?: any[], queryRunner?: QueryRunner): void {\n this.logger.warn(`Slow query: ${time}ms | Query: ${query} | Parameters: ${parameters}`);\n }\n\n logSchemaBuild(message: string, queryRunner?: QueryRunner): void {\n this.logger.info(`Schema Build: ${message}`);\n }\n\n logMigration(message: string, queryRunner?: QueryRunner): void {\n this.logger.info(`Migration: ${message}`);\n }\n\n log(level: 'log' | 'info' | 'warn' | 'error', message: any): void {\n this.logger[level](message);\n }\n}"]}
1
+ {"version":3,"file":"winston.logger.js","sourceRoot":"","sources":["../src/winston.logger.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,qCAAiC;AACjC,2CAAwC;AACxC,+CAAuD;AACvD,iDAAmC;AACnC,oGAA4E;AAErE,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EAAC,sCAAuB,CAAC,CAAA;qCAA0B,gBAAM;GADnE,oBAAoB,CA4BhC","sourcesContent":["\nimport { Logger as TypeORMLogger, QueryRunner } from 'typeorm';\nimport { Logger } from 'winston';\nimport { Inject } from '@nestjs/common';\nimport { WINSTON_MODULE_PROVIDER } from 'nest-winston';\nimport * as winston from 'winston';\nimport { Environment } from './decorators/disallow-in-production.decorator';\n\nexport const createWinstonLoggerConfig = () => ({\n level: process.env.LOG_LEVEL || (process.env.ENV === Environment.Production ? 'warn' : 'info'),\n format: winston.format.combine(\n winston.format.timestamp(),\n winston.format.errors({ stack: true }),\n winston.format.printf(({ level, message, timestamp }) => {\n if (!message) {\n return `[${timestamp}] ${level.toUpperCase()}: (No message provided)`;\n }\n return `[${timestamp}] ${level.toUpperCase()}: ${message}`;\n }),\n ),\n transports: [\n new winston.transports.Console({\n format: winston.format.combine(\n winston.format.printf(({ level, message, timestamp }) => {\n return `[${timestamp}] ${level.toUpperCase()}: ${message}`;\n }),\n ),\n }),\n new winston.transports.File({\n filename: 'logs/application.log',\n }),\n new winston.transports.File({\n filename: 'logs/error.log',\n level: 'error',\n }),\n ],\n});\n\nexport const WinstonLoggerConfig = createWinstonLoggerConfig();\n\nexport class WinstonTypeORMLogger implements TypeORMLogger {\n constructor(@Inject(WINSTON_MODULE_PROVIDER) private readonly logger: Logger) { }\n\n logQuery(query: string, parameters?: any[], queryRunner?: QueryRunner): void {\n if (Boolean(process.env.DEFAULT_DATABASE_LOGGING)) {\n this.logger.info(`Query: ${query} Parameters: ${parameters}`);\n }\n }\n\n logQueryError(error: string, query: string, parameters?: any[], queryRunner?: QueryRunner): void {\n this.logger.error(`Query failed: ${error} | Query: ${query} | Parameters: ${parameters}`);\n }\n\n logQuerySlow(time: number, query: string, parameters?: any[], queryRunner?: QueryRunner): void {\n this.logger.warn(`Slow query: ${time}ms | Query: ${query} | Parameters: ${parameters}`);\n }\n\n logSchemaBuild(message: string, queryRunner?: QueryRunner): void {\n this.logger.info(`Schema Build: ${message}`);\n }\n\n logMigration(message: string, queryRunner?: QueryRunner): void {\n this.logger.info(`Migration: ${message}`);\n }\n\n log(level: 'log' | 'info' | 'warn' | 'error', message: any): void {\n this.logger[level](message);\n }\n}"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidxai/core",
3
- "version": "0.1.10-beta.11",
3
+ "version": "0.1.10-beta.14",
4
4
  "description": "This module is a NestJS module containing all the required core providers required by a Solid application",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -4,8 +4,7 @@ import { ModelMetadataService } from 'src/services/model-metadata.service';
4
4
  import { CommandError } from './helper';
5
5
 
6
6
  interface CommandOptions {
7
- name?: string;
8
- id?: number;
7
+ name: string;
9
8
  dryRun?: boolean;
10
9
  }
11
10
 
@@ -30,32 +29,20 @@ export class RefreshModelCommand extends CommandRunner {
30
29
  }
31
30
 
32
31
  const codeGenerationOptions = {
33
- modelId: options.id,
34
32
  modelUserKey: options.name,
35
33
  dryRun: options.dryRun,
36
34
  };
37
35
  await this.modelMetadataService.handleGenerateCode(codeGenerationOptions);
38
36
  }
39
37
 
40
- // Accept the model ID as an argument
41
38
  @Option({
42
- flags: '-i, --id [model ID]',
43
- description: 'Model ID from the ss_model_metadata table',
44
- })
45
- parseId(val: string): number {
46
- return +val;
47
- }
48
-
49
- // Accept the module name as an argument
50
- @Option({
51
- flags: '-n, --name [model name]',
52
- description: 'Model Name from the ss_model_metadata table',
39
+ flags: '-n, --name <model name>',
40
+ description: 'Model name (singularName) from the ss_model_metadata table',
53
41
  })
54
42
  parseName(val: string): string {
55
43
  return val;
56
44
  }
57
45
 
58
- // Accept dry run as an argument
59
46
  @Option({
60
47
  flags: '-d, --dryRun [dry run]',
61
48
  description: 'Dry run the command',
@@ -65,10 +52,9 @@ export class RefreshModelCommand extends CommandRunner {
65
52
  return (val === 'false') ? false : true;
66
53
  }
67
54
 
68
- // Validate the options passed
69
55
  private validate(options: CommandOptions): CommandError[] {
70
- if (!options.id && !options.name) {
71
- return [new CommandError('Model ID or Model Name is required')];
56
+ if (!options.name) {
57
+ return [new CommandError('Model Name is required')];
72
58
  }
73
59
  return [];
74
60
  }
@@ -4,7 +4,6 @@ import { ModuleMetadataService } from '../services/module-metadata.service';
4
4
  import { CommandError } from './helper';
5
5
 
6
6
  interface CommandOptions {
7
- id: number;
8
7
  name: string;
9
8
  dryRun: boolean;
10
9
  }
@@ -28,7 +27,6 @@ export class RefreshModuleCommand extends CommandRunner {
28
27
  return;
29
28
  }
30
29
  const codeGenerationOptions = {
31
- moduleId: options.id,
32
30
  moduleUserKey: options.name,
33
31
  dryRun: options.dryRun,
34
32
  };
@@ -36,16 +34,7 @@ export class RefreshModuleCommand extends CommandRunner {
36
34
  }
37
35
 
38
36
  @Option({
39
- flags: '-i, --id [module ID]',
40
- description: 'Module ID from the ss_module_metadata table',
41
- })
42
- parseId(val: string): number {
43
- return +val;
44
- }
45
-
46
- // Accept the module name as an argument
47
- @Option({
48
- flags: '-n, --name [module name]',
37
+ flags: '-n, --name <module name>',
49
38
  description: 'Module Name from the ss_module_metadata table',
50
39
  })
51
40
  parseName(val: string): string {
@@ -61,11 +50,9 @@ export class RefreshModuleCommand extends CommandRunner {
61
50
  return (val === 'false') ? false : true;
62
51
  }
63
52
 
64
-
65
- // Validate the options passed
66
53
  validate(options: CommandOptions): CommandError[] {
67
- if (!options.id && !options.name) {
68
- return [new CommandError('Module ID or Module Name is required')];
54
+ if (!options.name) {
55
+ return [new CommandError('Module Name is required')];
69
56
  }
70
57
  return [];
71
58
  }
@@ -9,7 +9,7 @@ import { existsSync } from 'fs';
9
9
  import { resolve } from 'path';
10
10
  import { WINSTON_MODULE_NEST_PROVIDER, WinstonModule } from 'nest-winston';
11
11
  import { CommandFactory } from 'nest-commander';
12
- import { WinstonLoggerConfig } from '../winston.logger';
12
+ import { createWinstonLoggerConfig } from '../winston.logger';
13
13
  import { WrapResponseInterceptor } from '../interceptors/wrap-response.interceptor';
14
14
  import { buildDefaultCorsOptions } from './cors.helper';
15
15
  import { buildDefaultSecurityHeaderOptions, buildPermissionsPolicyHeader, PermissionsPolicyConfig } from './security.helper';
@@ -50,6 +50,8 @@ export interface SolidBootstrapOptions {
50
50
  swagger?: SolidSwaggerOptions | false;
51
51
  /** Permissions-Policy header overrides (merged with defaults). */
52
52
  permissionsPolicyOverrides?: Partial<PermissionsPolicyConfig>;
53
+ /** Show full NestJS init logs during bootstrap (route mapping, module deps, pollers). Defaults to false. */
54
+ verboseBootstrap?: boolean;
53
55
  }
54
56
 
55
57
  /**
@@ -70,11 +72,12 @@ export async function bootstrapSolidApp(
70
72
  ): Promise<void> {
71
73
  registerGlobalProcessHandlers();
72
74
 
73
- const { globalPrefix = 'api', swagger = {}, permissionsPolicyOverrides = {} } = options;
75
+ const { globalPrefix = 'api', swagger = {}, permissionsPolicyOverrides = {}, verboseBootstrap = false } = options;
74
76
 
77
+ const startTime = Date.now();
75
78
  const appModule = await appModuleFactory();
76
79
  const app = await NestFactory.create(appModule, {
77
- logger: WinstonModule.createLogger(WinstonLoggerConfig),
80
+ logger: WinstonModule.createLogger({ ...createWinstonLoggerConfig(), level: verboseBootstrap ? 'debug' : 'error' }),
78
81
  });
79
82
 
80
83
  const apiEnabled = parseBooleanEnv('API_ENABLED', true);
@@ -115,9 +118,6 @@ export async function bootstrapSolidApp(
115
118
  next();
116
119
  });
117
120
 
118
- // Winston logger
119
- app.useLogger(app.get(WINSTON_MODULE_NEST_PROVIDER));
120
-
121
121
  const port = process.env.PORT || 3000;
122
122
 
123
123
  if (globalPrefix) {
@@ -182,6 +182,13 @@ export async function bootstrapSolidApp(
182
182
  app.useWebSocketAdapter(new WsAdapter(app));
183
183
 
184
184
  await app.listen(port);
185
+
186
+ // Wire up Winston as the runtime logger only AFTER listen — this suppresses all
187
+ // framework init noise (route mapping, module deps, onModuleInit) during boot.
188
+ app.useLogger(app.get(WINSTON_MODULE_NEST_PROVIDER));
189
+
190
+ const elapsed = ((Date.now() - startTime) / 1000).toFixed(2);
191
+ app.get(WINSTON_MODULE_NEST_PROVIDER).log(`Server started on port ${port} in ${elapsed}s`, 'Bootstrap');
185
192
  }
186
193
 
187
194
  // ---- CLI bootstrap ----
@@ -739,9 +739,10 @@ export class ModelMetadataService {
739
739
 
740
740
  @DisallowInProduction()
741
741
  async generateCodeViaCtl(modelId: number): Promise<string> {
742
+ const model = await this.findOne(modelId);
742
743
  return this.commandService.executeCommandWithArgs({
743
744
  command: 'npx',
744
- args: ['@solixai/solidctl@latest', 'generate', 'model', `--id=${modelId}`],
745
+ args: ['@solixai/solidctl@latest', 'generate', 'model', `--name=${model.singularName}`],
745
746
  cwd: path.join(process.cwd(), '..'),
746
747
  });
747
748
  }
@@ -407,9 +407,10 @@ export class ModuleMetadataService {
407
407
 
408
408
  @DisallowInProduction()
409
409
  async generateCodeViaCtl(moduleId: number): Promise<string> {
410
+ const module = await this.findOne(moduleId);
410
411
  return this.commandService.executeCommandWithArgs({
411
412
  command: 'npx',
412
- args: ['@solixai/solidctl@latest', 'generate', 'module', `--id=${moduleId}`],
413
+ args: ['@solixai/solidctl@latest', 'generate', 'module', `--name=${module.name}`],
413
414
  cwd: path.join(process.cwd(), '..'),
414
415
  });
415
416
  }
@@ -6,8 +6,8 @@ import { WINSTON_MODULE_PROVIDER } from 'nest-winston';
6
6
  import * as winston from 'winston';
7
7
  import { Environment } from './decorators/disallow-in-production.decorator';
8
8
 
9
- export const WinstonLoggerConfig = {
10
- level: process.env.LOG_LEVEL || (process.env.ENV === Environment.Production ? 'info' : 'debug'),
9
+ export const createWinstonLoggerConfig = () => ({
10
+ level: process.env.LOG_LEVEL || (process.env.ENV === Environment.Production ? 'warn' : 'info'),
11
11
  format: winston.format.combine(
12
12
  winston.format.timestamp(),
13
13
  winston.format.errors({ stack: true }),
@@ -21,8 +21,6 @@ export const WinstonLoggerConfig = {
21
21
  transports: [
22
22
  new winston.transports.Console({
23
23
  format: winston.format.combine(
24
- // winston.format.colorize(),
25
- // winston.format.timestamp(),
26
24
  winston.format.printf(({ level, message, timestamp }) => {
27
25
  return `[${timestamp}] ${level.toUpperCase()}: ${message}`;
28
26
  }),
@@ -30,15 +28,15 @@ export const WinstonLoggerConfig = {
30
28
  }),
31
29
  new winston.transports.File({
32
30
  filename: 'logs/application.log',
33
- // format: winston.format.json(),
34
31
  }),
35
32
  new winston.transports.File({
36
33
  filename: 'logs/error.log',
37
34
  level: 'error',
38
- // format: winston.format.json(),
39
35
  }),
40
36
  ],
41
- };
37
+ });
38
+
39
+ export const WinstonLoggerConfig = createWinstonLoggerConfig();
42
40
 
43
41
  export class WinstonTypeORMLogger implements TypeORMLogger {
44
42
  constructor(@Inject(WINSTON_MODULE_PROVIDER) private readonly logger: Logger) { }