@solidxai/core 0.1.10-beta.21 → 0.1.10-beta.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/settings.local.json +15 -0
- package/CLAUDE.md +18 -0
- package/CURRENT_PROMPT +6 -0
- package/dist/helpers/bootstrap.helper.js +1 -1
- package/dist/helpers/bootstrap.helper.js.map +1 -1
- package/dist/seeders/seed-data/solid-core-metadata.json +159 -81
- package/dist/services/module-metadata.service.js +1 -1
- package/dist/services/module-metadata.service.js.map +1 -1
- package/dist/testing/adapters/ui/playwright-adapter.d.ts +1 -0
- package/dist/testing/adapters/ui/playwright-adapter.d.ts.map +1 -1
- package/dist/testing/adapters/ui/playwright-adapter.js +3 -0
- package/dist/testing/adapters/ui/playwright-adapter.js.map +1 -1
- package/dist/testing/steps/ui/index.d.ts.map +1 -1
- package/dist/testing/steps/ui/index.js +2 -0
- package/dist/testing/steps/ui/index.js.map +1 -1
- package/dist/testing/steps/ui/manual.step.d.ts +3 -0
- package/dist/testing/steps/ui/manual.step.d.ts.map +1 -0
- package/dist/testing/steps/ui/manual.step.js +56 -0
- package/dist/testing/steps/ui/manual.step.js.map +1 -0
- package/package.json +1 -1
- package/src/helpers/bootstrap.helper.ts +1 -1
- package/src/helpers/field-crud-managers/field-quality-check-fixes.md +36 -6
- package/src/seeders/seed-data/solid-core-metadata.json +159 -81
- package/src/services/1.js +6 -0
- package/src/services/module-metadata.service.ts +1 -1
- package/src/testing/README.md +42 -4
- package/src/testing/adapters/ui/playwright-adapter.ts +4 -0
- package/src/testing/steps/ui/index.ts +2 -0
- package/src/testing/steps/ui/manual.step.ts +80 -0
- package/dist-tests/api/authenticate.spec.js +0 -119
- package/dist-tests/api/authenticate.spec.js.map +0 -1
- package/dist-tests/api/crud-service.findOne.cityMaster.spec.js +0 -97
- package/dist-tests/api/crud-service.findOne.cityMaster.spec.js.map +0 -1
- package/dist-tests/api/ping.spec.js +0 -21
- package/dist-tests/api/ping.spec.js.map +0 -1
- package/dist-tests/helpers/auth.js +0 -41
- package/dist-tests/helpers/auth.js.map +0 -1
- package/dist-tests/helpers/env.js +0 -11
- package/dist-tests/helpers/env.js.map +0 -1
- package/docs/grouping-enhancements.md +0 -89
- package/docs/java-spring/README.md +0 -3
- package/docs/java-spring/solid-core-module-deep-dive-report.md +0 -1317
- package/docs/seed-changes.md +0 -65
- package/docs/test-data-workflow.md +0 -200
- package/docs/type-declaration-import-issue.md +0 -24
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"permissions": {
|
|
3
|
+
"allow": [
|
|
4
|
+
"Bash(node -e:*)",
|
|
5
|
+
"WebFetch(domain:docs.solidxai.com)",
|
|
6
|
+
"WebFetch(domain:github.com)",
|
|
7
|
+
"Read(//Users/oswald/projects/Solid_Starters/solidctl/**)",
|
|
8
|
+
"Read(//Users/oswald/projects/Solid_Starters/**)",
|
|
9
|
+
"Bash(find /Users/oswald/projects/Solid_Starters/solid-core-module -type d -name migration* -o -name *database*)"
|
|
10
|
+
],
|
|
11
|
+
"additionalDirectories": [
|
|
12
|
+
"/Users/oswald/projects/Solid_Starters/solidctl"
|
|
13
|
+
]
|
|
14
|
+
}
|
|
15
|
+
}
|
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# This is the SolidX API project.
|
|
2
|
+
This is included as a dependency in consuming projects.
|
|
3
|
+
|
|
4
|
+
# SolidX UI
|
|
5
|
+
# The corresponding UI project is at the below path:
|
|
6
|
+
/Users/oswald/projects/Solid_Starters/solid-core-ui
|
|
7
|
+
|
|
8
|
+
# SolidX Docs
|
|
9
|
+
# The documentation project is at the below path:
|
|
10
|
+
/Users/oswald/projects/solidxai-docs
|
|
11
|
+
|
|
12
|
+
# SolidX Agent
|
|
13
|
+
# The agent project which has the skills for helping users configure, build and use SolidX is at the below path:
|
|
14
|
+
/Users/oswald/projects/Solid_Starters/agent
|
|
15
|
+
|
|
16
|
+
# SolidX Control Plane Commands
|
|
17
|
+
# The control plane commands for managing SolidX instances are in the below path:
|
|
18
|
+
/Users/oswald/projects/Solid_Starters/solidctl
|
package/CURRENT_PROMPT
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
Have a look at the generate command in the control plane project. It generates code i.e boilerplate for modules and models. For the generation of api code is delegate to the solid cli in the api project.
|
|
2
|
+
|
|
3
|
+
The modelMetadataService generateCode and moduleMetadataService generateCode are what are called eventually. These are called from both the refresh-model and refresh-module commands and the controllers for module-metadata and model-metadata.
|
|
4
|
+
|
|
5
|
+
Change the code in schematic service to use the solidctl generate command instead of using the schematic command directly. This will ensure that the code generation is consistent and follows the same patterns as the rest of the project.
|
|
6
|
+
|
|
@@ -113,7 +113,7 @@ async function bootstrapSolidApp(appModuleFactory, options = {}) {
|
|
|
113
113
|
await app.listen(port);
|
|
114
114
|
app.useLogger(app.get(nest_winston_1.WINSTON_MODULE_NEST_PROVIDER));
|
|
115
115
|
const elapsed = ((Date.now() - startTime) / 1000).toFixed(2);
|
|
116
|
-
|
|
116
|
+
process.stdout.write(`\x1b[32mServer started on port ${port} in ${elapsed}s\x1b[0m\n`);
|
|
117
117
|
}
|
|
118
118
|
async function bootstrapSolidCli(appModuleFactory) {
|
|
119
119
|
registerGlobalProcessHandlers();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap.helper.js","sourceRoot":"","sources":["../../src/helpers/bootstrap.helper.ts"],"names":[],"mappings":";;;;;AAoEA,8CA2HC;AAgBD,8CA0CC;AAzPD,2CAAgD;AAChD,uCAA2C;AAC3C,qDAAgD;AAChD,6CAAiE;AAEjE,oDAA4B;AAC5B,4CAAoB;AACpB,2BAAgC;AAChC,+BAA+B;AAC/B,+CAA2E;AAC3E,mDAAgD;AAChD,sDAA8D;AAC9D,yFAAoF;AACpF,+CAAwD;AACxD,uDAA6H;AAC7H,6DAAuD;AAIvD,SAAS,6BAA6B;IACpC,OAAO,CAAC,EAAE,CAAC,oBAA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c,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;IAC3C,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,KAAK,CAAC,sCAAsC,EAAE,CAAC,CAAC,CAAC;QACzD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC","sourcesContent":["import { ValidationPipe } from '@nestjs/common';\nimport { NestFactory } from '@nestjs/core';\nimport { WsAdapter } from '@nestjs/platform-ws';\nimport { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';\nimport { NextFunction, Request, Response } from 'express';\nimport helmet from 'helmet';\nimport qs from 'qs';\nimport { existsSync } from 'fs';\nimport { resolve } from 'path';\nimport { WINSTON_MODULE_NEST_PROVIDER, WinstonModule } from 'nest-winston';\nimport { CommandFactory } from 'nest-commander';\nimport { createWinstonLoggerConfig } from '../winston.logger';\nimport { WrapResponseInterceptor } from '../interceptors/wrap-response.interceptor';\nimport { buildDefaultCorsOptions } from './cors.helper';\nimport { buildDefaultSecurityHeaderOptions, buildPermissionsPolicyHeader, PermissionsPolicyConfig } from './security.helper';\nimport { parseBooleanEnv } from './environment.helper';\n\n// ---- Shared process handlers ----\n\nfunction registerGlobalProcessHandlers() {\n process.on('unhandledRejection', (reason, promise) => {\n console.error('Unhandled Rejection at:', promise, 'reason:', reason);\n });\n\n process.on('uncaughtException', (err) => {\n console.error('Uncaught Exception thrown:', err);\n });\n\n // Suppress pg deprecation warning caused by TypeORM's internal query scheduling\n process.on('warning', (warning) => {\n if (warning.name === 'DeprecationWarning' && (warning.message.includes('client.query()') || warning.message.includes('punycode'))) {\n return;\n }\n console.warn(warning);\n });\n}\n\n// ---- HTTP server bootstrap ----\n\nexport interface SolidSwaggerOptions {\n title?: string;\n description?: string;\n version?: string;\n}\n\nexport interface SolidBootstrapOptions {\n /** Global API prefix. Defaults to 'api'. Set to '' to disable. */\n globalPrefix?: string;\n /** Swagger configuration. Set to false to disable Swagger entirely. */\n swagger?: SolidSwaggerOptions | false;\n /** Permissions-Policy header overrides (merged with defaults). */\n permissionsPolicyOverrides?: Partial<PermissionsPolicyConfig>;\n /** Show full NestJS init logs during bootstrap (route mapping, module deps, pollers). Defaults to false. */\n verboseBootstrap?: boolean;\n}\n\n/**\n * Bootstraps a SolidX NestJS HTTP application with sensible defaults:\n * security headers, CORS, Winston logger, ValidationPipe,\n * WrapResponseInterceptor, qs deep query parsing, Swagger, and the\n * pg BIGINT type parser.\n *\n * @example\n * // main.ts\n * bootstrapSolidApp(() => AppModule.forRoot(), {\n * swagger: { title: 'My API', description: 'My API description' },\n * });\n */\nexport async function bootstrapSolidApp(\n appModuleFactory: () => Promise<any>,\n options: SolidBootstrapOptions = {},\n): Promise<void> {\n registerGlobalProcessHandlers();\n\n const { globalPrefix = 'api', swagger = {}, permissionsPolicyOverrides = {}, verboseBootstrap = false } = options;\n\n const startTime = Date.now();\n const appModule = await appModuleFactory();\n const app = await NestFactory.create(appModule, {\n logger: WinstonModule.createLogger({ ...createWinstonLoggerConfig(), level: verboseBootstrap ? 'debug' : 'error' }),\n });\n\n const apiEnabled = parseBooleanEnv('API_ENABLED', true);\n\n if (!apiEnabled) {\n await app.init();\n app\n .get(WINSTON_MODULE_NEST_PROVIDER)\n .log('API server disabled via API_ENABLED=false. Skipping HTTP listen.', 'Bootstrap');\n return;\n }\n\n // Health check at root path\n const server = app.getHttpAdapter().getInstance();\n server.get('/', (_req, res) => res.status(200).send('SOLID OK'));\n\n // Security headers\n app.use(helmet(buildDefaultSecurityHeaderOptions()));\n\n // Nest's Swagger UI HTML injects inline styles; keep CSP strict elsewhere.\n const isSwaggerPath = (path: string) =>\n path === '/docs' ||\n path === '/docs/' ||\n path.startsWith('/docs/') ||\n path === '/docs-json' ||\n path === '/docs-yaml';\n\n app.use((req: Request, res: Response, next: NextFunction) => {\n if (isSwaggerPath(req.path)) {\n res.removeHeader('Content-Security-Policy');\n }\n next();\n });\n\n // Permissions-Policy header\n app.use((_req: Request, res: Response, next: NextFunction) => {\n res.setHeader('Permissions-Policy', buildPermissionsPolicyHeader(permissionsPolicyOverrides));\n next();\n });\n\n const port = process.env.PORT || 3000;\n\n if (globalPrefix) {\n app.setGlobalPrefix(globalPrefix);\n }\n\n // qs-based deep query parsing (dot notation, nested objects, arrays)\n app.use((req: Request, _res: Response, next: NextFunction) => {\n if (req.query) {\n req.query = qs.parse(req.url.split('?')[1], {\n allowDots: true,\n depth: 20,\n arrayLimit: 100,\n });\n }\n next();\n });\n\n // Global ValidationPipe\n app.useGlobalPipes(\n new ValidationPipe({\n transform: true,\n transformOptions: { enableImplicitConversion: true },\n }),\n );\n\n // Swagger\n if (swagger !== false) {\n const { title = process.env.SOLID_APP_NAME, description = process.env.SOLID_APP_DESCRIPTION, version = '1.0' } = swagger;\n const swaggerConfig = new DocumentBuilder()\n .setTitle(title)\n .setDescription(description)\n .setVersion(version)\n .setExternalDoc('Postman Collection', '/docs-json')\n .addBearerAuth(\n {\n description: 'Please enter token in following format: Bearer <JWT>',\n name: 'Authorization',\n bearerFormat: 'Bearer',\n scheme: 'Bearer',\n type: 'http',\n in: 'Header',\n },\n 'jwt',\n )\n .build();\n const document = SwaggerModule.createDocument(app, swaggerConfig);\n SwaggerModule.setup('/docs', app, document);\n }\n\n // Global interceptor\n app.useGlobalInterceptors(new WrapResponseInterceptor());\n\n // CORS\n app.enableCors(buildDefaultCorsOptions());\n\n // Fix pg returning BIGINT columns as strings\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const types = require('pg').types;\n types.setTypeParser(types.builtins.INT8, (val: string) => parseInt(val));\n\n app.useWebSocketAdapter(new WsAdapter(app));\n\n await app.listen(port);\n\n // Wire up Winston as the runtime logger only AFTER listen — this suppresses all\n // framework init noise (route mapping, module deps, onModuleInit) during boot.\n app.useLogger(app.get(WINSTON_MODULE_NEST_PROVIDER));\n\n const elapsed = ((Date.now() - startTime) / 1000).toFixed(2);\n app.get(WINSTON_MODULE_NEST_PROVIDER).log(`\\x1b[32mServer started on port ${port} in ${elapsed}s\\x1b[0m`, 'Bootstrap');\n}\n\n// ---- CLI bootstrap ----\n\n/**\n * Bootstraps a SolidX NestJS CLI application using nest-commander.\n * Handles verbose flag stripping, project root validation, and clean process exit.\n *\n * @example\n * // main-cli.ts\n * #!/usr/bin/env node\n * import { bootstrapSolidCli } from '@solidxai/core';\n * import { AppModule } from './app.module';\n *\n * bootstrapSolidCli(() => AppModule.forRoot());\n */\nexport async function bootstrapSolidCli(\n appModuleFactory: () => Promise<any>,\n): Promise<void> {\n registerGlobalProcessHandlers();\n\n process.on('exit', (code) => {\n if (code !== 0) {\n console.error(`Exiting with error status code: ${code}`);\n }\n });\n\n // Validate that cwd is a valid Solid API project\n const packageJsonPath = resolve(process.cwd(), 'package.json');\n if (!existsSync(packageJsonPath)) {\n console.error('Does not seem to be a valid solid-api project.');\n console.error('Exit reason: missing package.json in the current directory.');\n process.exit(1);\n }\n\n // Strip --verbose / -v before nest-commander processes argv\n const showLogs = process.argv.includes('--verbose') || process.argv.includes('-v');\n for (const flag of ['--verbose', '-v']) {\n const idx = process.argv.indexOf(flag);\n if (idx !== -1) process.argv.splice(idx, 1);\n }\n\n const appModule = await appModuleFactory();\n process.env.SOLID_CLI_RUNNING = 'true';\n\n // @ts-ignore\n const app = await CommandFactory.createWithoutRunning(appModule, {\n logger: showLogs ? ['debug', 'error', 'fatal', 'log', 'verbose', 'warn'] : false,\n });\n\n try {\n await CommandFactory.runApplication(app);\n } catch (e) {\n console.error('CLI exited abruptly due to an error:', e);\n process.exit(1);\n }\n\n process.exit(0);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"bootstrap.helper.js","sourceRoot":"","sources":["../../src/helpers/bootstrap.helper.ts"],"names":[],"mappings":";;;;;AAoEA,8CA2HC;AAgBD,8CA0CC;AAzPD,2CAAgD;AAChD,uCAA2C;AAC3C,qDAAgD;AAChD,6CAAiE;AAEjE,oDAA4B;AAC5B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C,CAAC,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK;KACjF,CAAC,CAAC;IAEH,IAAI,CAAC;QACH,MAAM,+BAAc,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;IAC3C,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,KAAK,CAAC,sCAAsC,EAAE,CAAC,CAAC,CAAC;QACzD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC","sourcesContent":["import { ValidationPipe } from '@nestjs/common';\nimport { NestFactory } from '@nestjs/core';\nimport { WsAdapter } from '@nestjs/platform-ws';\nimport { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';\nimport { NextFunction, Request, Response } from 'express';\nimport helmet from 'helmet';\nimport qs from 'qs';\nimport { existsSync } from 'fs';\nimport { resolve } from 'path';\nimport { WINSTON_MODULE_NEST_PROVIDER, WinstonModule } from 'nest-winston';\nimport { CommandFactory } from 'nest-commander';\nimport { createWinstonLoggerConfig } from '../winston.logger';\nimport { WrapResponseInterceptor } from '../interceptors/wrap-response.interceptor';\nimport { buildDefaultCorsOptions } from './cors.helper';\nimport { buildDefaultSecurityHeaderOptions, buildPermissionsPolicyHeader, PermissionsPolicyConfig } from './security.helper';\nimport { parseBooleanEnv } from './environment.helper';\n\n// ---- Shared process handlers ----\n\nfunction registerGlobalProcessHandlers() {\n process.on('unhandledRejection', (reason, promise) => {\n console.error('Unhandled Rejection at:', promise, 'reason:', reason);\n });\n\n process.on('uncaughtException', (err) => {\n console.error('Uncaught Exception thrown:', err);\n });\n\n // Suppress pg deprecation warning caused by TypeORM's internal query scheduling\n process.on('warning', (warning) => {\n if (warning.name === 'DeprecationWarning' && (warning.message.includes('client.query()') || warning.message.includes('punycode'))) {\n return;\n }\n console.warn(warning);\n });\n}\n\n// ---- HTTP server bootstrap ----\n\nexport interface SolidSwaggerOptions {\n title?: string;\n description?: string;\n version?: string;\n}\n\nexport interface SolidBootstrapOptions {\n /** Global API prefix. Defaults to 'api'. Set to '' to disable. */\n globalPrefix?: string;\n /** Swagger configuration. Set to false to disable Swagger entirely. */\n swagger?: SolidSwaggerOptions | false;\n /** Permissions-Policy header overrides (merged with defaults). */\n permissionsPolicyOverrides?: Partial<PermissionsPolicyConfig>;\n /** Show full NestJS init logs during bootstrap (route mapping, module deps, pollers). Defaults to false. */\n verboseBootstrap?: boolean;\n}\n\n/**\n * Bootstraps a SolidX NestJS HTTP application with sensible defaults:\n * security headers, CORS, Winston logger, ValidationPipe,\n * WrapResponseInterceptor, qs deep query parsing, Swagger, and the\n * pg BIGINT type parser.\n *\n * @example\n * // main.ts\n * bootstrapSolidApp(() => AppModule.forRoot(), {\n * swagger: { title: 'My API', description: 'My API description' },\n * });\n */\nexport async function bootstrapSolidApp(\n appModuleFactory: () => Promise<any>,\n options: SolidBootstrapOptions = {},\n): Promise<void> {\n registerGlobalProcessHandlers();\n\n const { globalPrefix = 'api', swagger = {}, permissionsPolicyOverrides = {}, verboseBootstrap = false } = options;\n\n const startTime = Date.now();\n const appModule = await appModuleFactory();\n const app = await NestFactory.create(appModule, {\n logger: WinstonModule.createLogger({ ...createWinstonLoggerConfig(), level: verboseBootstrap ? 'debug' : 'error' }),\n });\n\n const apiEnabled = parseBooleanEnv('API_ENABLED', true);\n\n if (!apiEnabled) {\n await app.init();\n app\n .get(WINSTON_MODULE_NEST_PROVIDER)\n .log('API server disabled via API_ENABLED=false. Skipping HTTP listen.', 'Bootstrap');\n return;\n }\n\n // Health check at root path\n const server = app.getHttpAdapter().getInstance();\n server.get('/', (_req, res) => res.status(200).send('SOLID OK'));\n\n // Security headers\n app.use(helmet(buildDefaultSecurityHeaderOptions()));\n\n // Nest's Swagger UI HTML injects inline styles; keep CSP strict elsewhere.\n const isSwaggerPath = (path: string) =>\n path === '/docs' ||\n path === '/docs/' ||\n path.startsWith('/docs/') ||\n path === '/docs-json' ||\n path === '/docs-yaml';\n\n app.use((req: Request, res: Response, next: NextFunction) => {\n if (isSwaggerPath(req.path)) {\n res.removeHeader('Content-Security-Policy');\n }\n next();\n });\n\n // Permissions-Policy header\n app.use((_req: Request, res: Response, next: NextFunction) => {\n res.setHeader('Permissions-Policy', buildPermissionsPolicyHeader(permissionsPolicyOverrides));\n next();\n });\n\n const port = process.env.PORT || 3000;\n\n if (globalPrefix) {\n app.setGlobalPrefix(globalPrefix);\n }\n\n // qs-based deep query parsing (dot notation, nested objects, arrays)\n app.use((req: Request, _res: Response, next: NextFunction) => {\n if (req.query) {\n req.query = qs.parse(req.url.split('?')[1], {\n allowDots: true,\n depth: 20,\n arrayLimit: 100,\n });\n }\n next();\n });\n\n // Global ValidationPipe\n app.useGlobalPipes(\n new ValidationPipe({\n transform: true,\n transformOptions: { enableImplicitConversion: true },\n }),\n );\n\n // Swagger\n if (swagger !== false) {\n const { title = process.env.SOLID_APP_NAME, description = process.env.SOLID_APP_DESCRIPTION, version = '1.0' } = swagger;\n const swaggerConfig = new DocumentBuilder()\n .setTitle(title)\n .setDescription(description)\n .setVersion(version)\n .setExternalDoc('Postman Collection', '/docs-json')\n .addBearerAuth(\n {\n description: 'Please enter token in following format: Bearer <JWT>',\n name: 'Authorization',\n bearerFormat: 'Bearer',\n scheme: 'Bearer',\n type: 'http',\n in: 'Header',\n },\n 'jwt',\n )\n .build();\n const document = SwaggerModule.createDocument(app, swaggerConfig);\n SwaggerModule.setup('/docs', app, document);\n }\n\n // Global interceptor\n app.useGlobalInterceptors(new WrapResponseInterceptor());\n\n // CORS\n app.enableCors(buildDefaultCorsOptions());\n\n // Fix pg returning BIGINT columns as strings\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const types = require('pg').types;\n types.setTypeParser(types.builtins.INT8, (val: string) => parseInt(val));\n\n app.useWebSocketAdapter(new WsAdapter(app));\n\n await app.listen(port);\n\n // Wire up Winston as the runtime logger only AFTER listen — this suppresses all\n // framework init noise (route mapping, module deps, onModuleInit) during boot.\n app.useLogger(app.get(WINSTON_MODULE_NEST_PROVIDER));\n\n const elapsed = ((Date.now() - startTime) / 1000).toFixed(2);\n process.stdout.write(`\\x1b[32mServer started on port ${port} in ${elapsed}s\\x1b[0m\\n`);\n}\n\n// ---- CLI bootstrap ----\n\n/**\n * Bootstraps a SolidX NestJS CLI application using nest-commander.\n * Handles verbose flag stripping, project root validation, and clean process exit.\n *\n * @example\n * // main-cli.ts\n * #!/usr/bin/env node\n * import { bootstrapSolidCli } from '@solidxai/core';\n * import { AppModule } from './app.module';\n *\n * bootstrapSolidCli(() => AppModule.forRoot());\n */\nexport async function bootstrapSolidCli(\n appModuleFactory: () => Promise<any>,\n): Promise<void> {\n registerGlobalProcessHandlers();\n\n process.on('exit', (code) => {\n if (code !== 0) {\n console.error(`Exiting with error status code: ${code}`);\n }\n });\n\n // Validate that cwd is a valid Solid API project\n const packageJsonPath = resolve(process.cwd(), 'package.json');\n if (!existsSync(packageJsonPath)) {\n console.error('Does not seem to be a valid solid-api project.');\n console.error('Exit reason: missing package.json in the current directory.');\n process.exit(1);\n }\n\n // Strip --verbose / -v before nest-commander processes argv\n const showLogs = process.argv.includes('--verbose') || process.argv.includes('-v');\n for (const flag of ['--verbose', '-v']) {\n const idx = process.argv.indexOf(flag);\n if (idx !== -1) process.argv.splice(idx, 1);\n }\n\n const appModule = await appModuleFactory();\n process.env.SOLID_CLI_RUNNING = 'true';\n\n // @ts-ignore\n const app = await CommandFactory.createWithoutRunning(appModule, {\n logger: showLogs ? ['debug', 'error', 'fatal', 'log', 'verbose', 'warn'] : false,\n });\n\n try {\n await CommandFactory.runApplication(app);\n } catch (e) {\n console.error('CLI exited abruptly due to an error:', e);\n process.exit(1);\n }\n\n process.exit(0);\n}\n"]}
|
|
@@ -14000,34 +14000,16 @@
|
|
|
14000
14000
|
"children": [
|
|
14001
14001
|
{
|
|
14002
14002
|
"type": "column",
|
|
14003
|
-
"attrs": { "name": "col-1", "label": "", "className": "col-12
|
|
14003
|
+
"attrs": { "name": "col-1", "label": "", "className": "col-12" },
|
|
14004
14004
|
"children": [
|
|
14005
14005
|
{ "type": "field", "attrs": { "name": "sessionId" } },
|
|
14006
14006
|
{ "type": "field", "attrs": { "name": "modelName" } },
|
|
14007
14007
|
{ "type": "field", "attrs": { "name": "status" } },
|
|
14008
|
-
{ "type": "field", "attrs": { "name": "projectRoot" } }
|
|
14009
|
-
]
|
|
14010
|
-
},
|
|
14011
|
-
{
|
|
14012
|
-
"type": "column",
|
|
14013
|
-
"attrs": { "name": "col-2", "label": "", "className": "col-12 sm:col-12 md:col-6 lg:col-6" },
|
|
14014
|
-
"children": [
|
|
14008
|
+
{ "type": "field", "attrs": { "name": "projectRoot" } },
|
|
14015
14009
|
{ "type": "field", "attrs": { "name": "totalSteps" } },
|
|
14016
14010
|
{ "type": "field", "attrs": { "name": "totalCost" } },
|
|
14017
14011
|
{ "type": "field", "attrs": { "name": "totalInputTokens" } },
|
|
14018
|
-
{ "type": "field", "attrs": { "name": "totalOutputTokens" } }
|
|
14019
|
-
]
|
|
14020
|
-
}
|
|
14021
|
-
]
|
|
14022
|
-
},
|
|
14023
|
-
{
|
|
14024
|
-
"type": "row",
|
|
14025
|
-
"attrs": { "name": "row-2" },
|
|
14026
|
-
"children": [
|
|
14027
|
-
{
|
|
14028
|
-
"type": "column",
|
|
14029
|
-
"attrs": { "name": "col-summary", "label": "", "className": "col-12" },
|
|
14030
|
-
"children": [
|
|
14012
|
+
{ "type": "field", "attrs": { "name": "totalOutputTokens" } },
|
|
14031
14013
|
{ "type": "field", "attrs": { "name": "summary" } }
|
|
14032
14014
|
]
|
|
14033
14015
|
}
|
|
@@ -14091,46 +14073,94 @@
|
|
|
14091
14073
|
"attrs": { "name": "sheet-1" },
|
|
14092
14074
|
"children": [
|
|
14093
14075
|
{
|
|
14094
|
-
"type": "
|
|
14095
|
-
"attrs": { "name": "
|
|
14076
|
+
"type": "notebook",
|
|
14077
|
+
"attrs": { "name": "notebook-1" },
|
|
14096
14078
|
"children": [
|
|
14097
14079
|
{
|
|
14098
|
-
"type": "
|
|
14099
|
-
"attrs": { "name": "
|
|
14080
|
+
"type": "page",
|
|
14081
|
+
"attrs": { "name": "page-general", "label": "General" },
|
|
14100
14082
|
"children": [
|
|
14101
|
-
{
|
|
14102
|
-
|
|
14103
|
-
|
|
14104
|
-
|
|
14105
|
-
|
|
14106
|
-
|
|
14083
|
+
{
|
|
14084
|
+
"type": "row",
|
|
14085
|
+
"attrs": { "name": "page-general-row-1" },
|
|
14086
|
+
"children": [
|
|
14087
|
+
{
|
|
14088
|
+
"type": "column",
|
|
14089
|
+
"attrs": { "name": "page-general-col-1", "label": "", "className": "col-12" },
|
|
14090
|
+
"children": [
|
|
14091
|
+
{ "type": "field", "attrs": { "name": "sessionId" } },
|
|
14092
|
+
{ "type": "field", "attrs": { "name": "eventType" } },
|
|
14093
|
+
{ "type": "field", "attrs": { "name": "turnNumber" } },
|
|
14094
|
+
{ "type": "field", "attrs": { "name": "stepNumber" } },
|
|
14095
|
+
{ "type": "field", "attrs": { "name": "toolName" } },
|
|
14096
|
+
{ "type": "field", "attrs": { "name": "modelUsed" } },
|
|
14097
|
+
{ "type": "field", "attrs": { "name": "durationMs" } },
|
|
14098
|
+
{ "type": "field", "attrs": { "name": "cost" } },
|
|
14099
|
+
{ "type": "field", "attrs": { "name": "inputTokens" } },
|
|
14100
|
+
{ "type": "field", "attrs": { "name": "outputTokens" } },
|
|
14101
|
+
{ "type": "field", "attrs": { "name": "toolReturncode" } },
|
|
14102
|
+
{ "type": "field", "attrs": { "name": "content" } }
|
|
14103
|
+
]
|
|
14104
|
+
}
|
|
14105
|
+
]
|
|
14106
|
+
}
|
|
14107
14107
|
]
|
|
14108
14108
|
},
|
|
14109
14109
|
{
|
|
14110
|
-
"type": "
|
|
14111
|
-
"attrs": { "name": "
|
|
14110
|
+
"type": "page",
|
|
14111
|
+
"attrs": { "name": "page-tool-arguments", "label": "Tool Arguments" },
|
|
14112
14112
|
"children": [
|
|
14113
|
-
{
|
|
14114
|
-
|
|
14115
|
-
|
|
14116
|
-
|
|
14117
|
-
|
|
14113
|
+
{
|
|
14114
|
+
"type": "row",
|
|
14115
|
+
"attrs": { "name": "page-tool-arguments-row-1" },
|
|
14116
|
+
"children": [
|
|
14117
|
+
{
|
|
14118
|
+
"type": "column",
|
|
14119
|
+
"attrs": { "name": "page-tool-arguments-col-1", "label": "", "className": "col-12" },
|
|
14120
|
+
"children": [
|
|
14121
|
+
{ "type": "field", "attrs": { "name": "toolArguments", "viewWidget": "SolidJsonFormViewWidget" } }
|
|
14122
|
+
]
|
|
14123
|
+
}
|
|
14124
|
+
]
|
|
14125
|
+
}
|
|
14118
14126
|
]
|
|
14119
|
-
}
|
|
14120
|
-
]
|
|
14121
|
-
},
|
|
14122
|
-
{
|
|
14123
|
-
"type": "row",
|
|
14124
|
-
"attrs": { "name": "row-2" },
|
|
14125
|
-
"children": [
|
|
14127
|
+
},
|
|
14126
14128
|
{
|
|
14127
|
-
"type": "
|
|
14128
|
-
"attrs": { "name": "
|
|
14129
|
+
"type": "page",
|
|
14130
|
+
"attrs": { "name": "page-tool-output", "label": "Tool Output" },
|
|
14129
14131
|
"children": [
|
|
14130
|
-
{
|
|
14131
|
-
|
|
14132
|
-
|
|
14133
|
-
|
|
14132
|
+
{
|
|
14133
|
+
"type": "row",
|
|
14134
|
+
"attrs": { "name": "page-tool-output-row-1" },
|
|
14135
|
+
"children": [
|
|
14136
|
+
{
|
|
14137
|
+
"type": "column",
|
|
14138
|
+
"attrs": { "name": "page-tool-output-col-1", "label": "", "className": "col-12" },
|
|
14139
|
+
"children": [
|
|
14140
|
+
{ "type": "field", "attrs": { "name": "toolOutput", "viewWidget": "SolidJsonFormViewWidget" } }
|
|
14141
|
+
]
|
|
14142
|
+
}
|
|
14143
|
+
]
|
|
14144
|
+
}
|
|
14145
|
+
]
|
|
14146
|
+
},
|
|
14147
|
+
{
|
|
14148
|
+
"type": "page",
|
|
14149
|
+
"attrs": { "name": "page-event-data", "label": "Event Data" },
|
|
14150
|
+
"children": [
|
|
14151
|
+
{
|
|
14152
|
+
"type": "row",
|
|
14153
|
+
"attrs": { "name": "page-event-data-row-1" },
|
|
14154
|
+
"children": [
|
|
14155
|
+
{
|
|
14156
|
+
"type": "column",
|
|
14157
|
+
"attrs": { "name": "page-event-data-col-1", "label": "", "className": "col-12" },
|
|
14158
|
+
"children": [
|
|
14159
|
+
{ "type": "field", "attrs": { "name": "eventData", "viewWidget": "SolidJsonFormViewWidget" } }
|
|
14160
|
+
]
|
|
14161
|
+
}
|
|
14162
|
+
]
|
|
14163
|
+
}
|
|
14134
14164
|
]
|
|
14135
14165
|
}
|
|
14136
14166
|
]
|
|
@@ -14193,46 +14223,94 @@
|
|
|
14193
14223
|
"attrs": { "name": "sheet-1" },
|
|
14194
14224
|
"children": [
|
|
14195
14225
|
{
|
|
14196
|
-
"type": "
|
|
14197
|
-
"attrs": { "name": "
|
|
14226
|
+
"type": "notebook",
|
|
14227
|
+
"attrs": { "name": "notebook-1" },
|
|
14198
14228
|
"children": [
|
|
14199
14229
|
{
|
|
14200
|
-
"type": "
|
|
14201
|
-
"attrs": { "name": "
|
|
14230
|
+
"type": "page",
|
|
14231
|
+
"attrs": { "name": "page-general", "label": "General" },
|
|
14202
14232
|
"children": [
|
|
14203
|
-
{
|
|
14204
|
-
|
|
14205
|
-
|
|
14206
|
-
|
|
14207
|
-
|
|
14208
|
-
|
|
14233
|
+
{
|
|
14234
|
+
"type": "row",
|
|
14235
|
+
"attrs": { "name": "page-general-row-1" },
|
|
14236
|
+
"children": [
|
|
14237
|
+
{
|
|
14238
|
+
"type": "column",
|
|
14239
|
+
"attrs": { "name": "page-general-col-1", "label": "", "className": "col-12" },
|
|
14240
|
+
"children": [
|
|
14241
|
+
{ "type": "field", "attrs": { "name": "method" } },
|
|
14242
|
+
{ "type": "field", "attrs": { "name": "toolName" } },
|
|
14243
|
+
{ "type": "field", "attrs": { "name": "status" } },
|
|
14244
|
+
{ "type": "field", "attrs": { "name": "transport" } },
|
|
14245
|
+
{ "type": "field", "attrs": { "name": "mcpSessionId" } },
|
|
14246
|
+
{ "type": "field", "attrs": { "name": "requestId" } },
|
|
14247
|
+
{ "type": "field", "attrs": { "name": "userId" } },
|
|
14248
|
+
{ "type": "field", "attrs": { "name": "apiKeyId" } },
|
|
14249
|
+
{ "type": "field", "attrs": { "name": "username" } },
|
|
14250
|
+
{ "type": "field", "attrs": { "name": "clientAddr" } },
|
|
14251
|
+
{ "type": "field", "attrs": { "name": "durationMs" } },
|
|
14252
|
+
{ "type": "field", "attrs": { "name": "errorCode" } }
|
|
14253
|
+
]
|
|
14254
|
+
}
|
|
14255
|
+
]
|
|
14256
|
+
}
|
|
14209
14257
|
]
|
|
14210
14258
|
},
|
|
14211
14259
|
{
|
|
14212
|
-
"type": "
|
|
14213
|
-
"attrs": { "name": "
|
|
14260
|
+
"type": "page",
|
|
14261
|
+
"attrs": { "name": "page-request-params", "label": "Request Params" },
|
|
14214
14262
|
"children": [
|
|
14215
|
-
{
|
|
14216
|
-
|
|
14217
|
-
|
|
14218
|
-
|
|
14219
|
-
|
|
14220
|
-
|
|
14263
|
+
{
|
|
14264
|
+
"type": "row",
|
|
14265
|
+
"attrs": { "name": "page-request-params-row-1" },
|
|
14266
|
+
"children": [
|
|
14267
|
+
{
|
|
14268
|
+
"type": "column",
|
|
14269
|
+
"attrs": { "name": "page-request-params-col-1", "label": "", "className": "col-12" },
|
|
14270
|
+
"children": [
|
|
14271
|
+
{ "type": "field", "attrs": { "name": "requestParams", "viewWidget": "SolidJsonFormViewWidget" } }
|
|
14272
|
+
]
|
|
14273
|
+
}
|
|
14274
|
+
]
|
|
14275
|
+
}
|
|
14221
14276
|
]
|
|
14222
|
-
}
|
|
14223
|
-
]
|
|
14224
|
-
},
|
|
14225
|
-
{
|
|
14226
|
-
"type": "row",
|
|
14227
|
-
"attrs": { "name": "row-2" },
|
|
14228
|
-
"children": [
|
|
14277
|
+
},
|
|
14229
14278
|
{
|
|
14230
|
-
"type": "
|
|
14231
|
-
"attrs": { "name": "
|
|
14279
|
+
"type": "page",
|
|
14280
|
+
"attrs": { "name": "page-response-result", "label": "Response Result" },
|
|
14281
|
+
"children": [
|
|
14282
|
+
{
|
|
14283
|
+
"type": "row",
|
|
14284
|
+
"attrs": { "name": "page-response-result-row-1" },
|
|
14285
|
+
"children": [
|
|
14286
|
+
{
|
|
14287
|
+
"type": "column",
|
|
14288
|
+
"attrs": { "name": "page-response-result-col-1", "label": "", "className": "col-12" },
|
|
14289
|
+
"children": [
|
|
14290
|
+
{ "type": "field", "attrs": { "name": "responseResult", "viewWidget": "SolidJsonFormViewWidget" } }
|
|
14291
|
+
]
|
|
14292
|
+
}
|
|
14293
|
+
]
|
|
14294
|
+
}
|
|
14295
|
+
]
|
|
14296
|
+
},
|
|
14297
|
+
{
|
|
14298
|
+
"type": "page",
|
|
14299
|
+
"attrs": { "name": "page-error-message", "label": "Error Message" },
|
|
14232
14300
|
"children": [
|
|
14233
|
-
{
|
|
14234
|
-
|
|
14235
|
-
|
|
14301
|
+
{
|
|
14302
|
+
"type": "row",
|
|
14303
|
+
"attrs": { "name": "page-error-message-row-1" },
|
|
14304
|
+
"children": [
|
|
14305
|
+
{
|
|
14306
|
+
"type": "column",
|
|
14307
|
+
"attrs": { "name": "page-error-message-col-1", "label": "", "className": "col-12" },
|
|
14308
|
+
"children": [
|
|
14309
|
+
{ "type": "field", "attrs": { "name": "errorMessage" } }
|
|
14310
|
+
]
|
|
14311
|
+
}
|
|
14312
|
+
]
|
|
14313
|
+
}
|
|
14236
14314
|
]
|
|
14237
14315
|
}
|
|
14238
14316
|
]
|
|
@@ -374,7 +374,7 @@ let ModuleMetadataService = ModuleMetadataService_1 = class ModuleMetadataServic
|
|
|
374
374
|
const module = await this.findOne(moduleId);
|
|
375
375
|
return this.commandService.executeCommandWithArgs({
|
|
376
376
|
command: 'npx',
|
|
377
|
-
args: ['@
|
|
377
|
+
args: ['@solidxai/solidctl@latest', 'generate', 'module', `--name=${module.name}`],
|
|
378
378
|
cwd: path.join(process.cwd(), '..'),
|
|
379
379
|
});
|
|
380
380
|
}
|
|
@@ -1 +1 @@
|
|
|
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,gDAAkC;AAClC,2CAA6B;AAC7B,gEAA8D;AAC9D,qGAAuF;AACvF,8FAAyF;AACzF,yFAAqF;AACrF,sGAAiG;AACjG,iCAAoD;AAGpD,oEAGsC;AACtC,gEAA4D;AAC5D,8DAA0D;AAE1D,+DAA0D;AAC1D,qEAAgE;AAChE,uDAAmD;AAG5C,IAAM,qBAAqB,6BAA3B,MAAM,qBAAqB;IAGhC,YAEE,UAAuC,EAGtB,kBAA4C,EAC5C,iBAAoC,EACpC,gBAAkC,EAClC,cAA8B,EAC9B,WAA4B,EAC5B,cAA8B,EAE9B,wBAAyD,EAE1E,oBAA2D,EAC1C,aAA4B,EAC5B,2BAAwD;QAdxD,eAAU,GAAV,UAAU,CAAY;QAGtB,uBAAkB,GAAlB,kBAAkB,CAA0B;QAC5C,sBAAiB,GAAjB,iBAAiB,CAAmB;QACpC,qBAAgB,GAAhB,gBAAgB,CAAkB;QAClC,mBAAc,GAAd,cAAc,CAAgB;QAC9B,gBAAW,GAAX,WAAW,CAAiB;QAC5B,mBAAc,GAAd,cAAc,CAAgB;QAE9B,6BAAwB,GAAxB,wBAAwB,CAAiC;QAEzD,yBAAoB,GAApB,oBAAoB,CAAsB;QAC1C,kBAAa,GAAb,aAAa,CAAe;QAC5B,gCAA2B,GAA3B,2BAA2B,CAA6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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
|
+
{"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,gDAAkC;AAClC,2CAA6B;AAC7B,gEAA8D;AAC9D,qGAAuF;AACvF,8FAAyF;AACzF,yFAAqF;AACrF,sGAAiG;AACjG,iCAAoD;AAGpD,oEAGsC;AACtC,gEAA4D;AAC5D,8DAA0D;AAE1D,+DAA0D;AAC1D,qEAAgE;AAChE,uDAAmD;AAG5C,IAAM,qBAAqB,6BAA3B,MAAM,qBAAqB;IAGhC,YAEE,UAAuC,EAGtB,kBAA4C,EAC5C,iBAAoC,EACpC,gBAAkC,EAClC,cAA8B,EAC9B,WAA4B,EAC5B,cAA8B,EAE9B,wBAAyD,EAE1E,oBAA2D,EAC1C,aAA4B,EAC5B,2BAAwD;QAdxD,eAAU,GAAV,UAAU,CAAY;QAGtB,uBAAkB,GAAlB,kBAAkB,CAA0B;QAC5C,sBAAiB,GAAjB,iBAAiB,CAAmB;QACpC,qBAAgB,GAAhB,gBAAgB,CAAkB;QAClC,mBAAc,GAAd,cAAc,CAAgB;QAC9B,gBAAW,GAAX,WAAW,CAAiB;QAC5B,mBAAc,GAAd,cAAc,CAAgB;QAE9B,6BAAwB,GAAxB,wBAAwB,CAAiC;QAEzD,yBAAoB,GAApB,oBAAoB,CAAsB;QAC1C,kBAAa,GAAb,aAAa,CAAe;QAC5B,g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Content":["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: ['@solidxai/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"]}
|