@solidxai/core 0.1.10 → 0.1.11-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/controllers/datasource-introspection.controller.d.ts +234 -0
- package/dist/controllers/datasource-introspection.controller.d.ts.map +1 -0
- package/dist/controllers/datasource-introspection.controller.js +98 -0
- package/dist/controllers/datasource-introspection.controller.js.map +1 -0
- package/dist/controllers/datasource-management.controller.d.ts +18 -0
- package/dist/controllers/datasource-management.controller.d.ts.map +1 -0
- package/dist/controllers/datasource-management.controller.js +55 -0
- package/dist/controllers/datasource-management.controller.js.map +1 -0
- package/dist/dtos/create-datasource-management.dto.d.ts +25 -0
- package/dist/dtos/create-datasource-management.dto.d.ts.map +1 -0
- package/dist/dtos/create-datasource-management.dto.js +169 -0
- package/dist/dtos/create-datasource-management.dto.js.map +1 -0
- package/dist/dtos/datasource-introspection-mapping.dto.d.ts +45 -0
- package/dist/dtos/datasource-introspection-mapping.dto.d.ts.map +1 -0
- package/dist/dtos/datasource-introspection-mapping.dto.js +233 -0
- package/dist/dtos/datasource-introspection-mapping.dto.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/interfaces/datasource-introspection-provider.interface.d.ts +26 -0
- package/dist/interfaces/datasource-introspection-provider.interface.d.ts.map +1 -0
- package/dist/interfaces/datasource-introspection-provider.interface.js +3 -0
- package/dist/interfaces/datasource-introspection-provider.interface.js.map +1 -0
- package/dist/repository/scheduled-job.repository.d.ts +3 -0
- package/dist/repository/scheduled-job.repository.d.ts.map +1 -1
- package/dist/repository/scheduled-job.repository.js +60 -0
- package/dist/repository/scheduled-job.repository.js.map +1 -1
- package/dist/seeders/module-metadata-seeder.service.d.ts +32 -1
- package/dist/seeders/module-metadata-seeder.service.d.ts.map +1 -1
- package/dist/seeders/module-metadata-seeder.service.js +1011 -230
- package/dist/seeders/module-metadata-seeder.service.js.map +1 -1
- package/dist/seeders/seed-data/solid-core-metadata.json +21 -0
- package/dist/services/action-metadata.service.d.ts +7 -0
- package/dist/services/action-metadata.service.d.ts.map +1 -1
- package/dist/services/action-metadata.service.js +76 -3
- package/dist/services/action-metadata.service.js.map +1 -1
- package/dist/services/authentication.service.js +1 -1
- package/dist/services/authentication.service.js.map +1 -1
- package/dist/services/dashboard-providers/mq-dashboard-latency-trend-provider.service.d.ts.map +1 -1
- package/dist/services/dashboard-providers/mq-dashboard-latency-trend-provider.service.js +2 -2
- package/dist/services/dashboard-providers/mq-dashboard-latency-trend-provider.service.js.map +1 -1
- package/dist/services/dashboard-providers/mq-dashboard-messages-over-time-provider.service.d.ts.map +1 -1
- package/dist/services/dashboard-providers/mq-dashboard-messages-over-time-provider.service.js +2 -2
- package/dist/services/dashboard-providers/mq-dashboard-messages-over-time-provider.service.js.map +1 -1
- package/dist/services/dashboard-providers/mq-dashboard-provider-utils.d.ts +3 -0
- package/dist/services/dashboard-providers/mq-dashboard-provider-utils.d.ts.map +1 -1
- package/dist/services/dashboard-providers/mq-dashboard-provider-utils.js +71 -0
- package/dist/services/dashboard-providers/mq-dashboard-provider-utils.js.map +1 -1
- package/dist/services/dashboard-providers/mq-dashboard-queue-sla-heatmap-provider.service.d.ts.map +1 -1
- package/dist/services/dashboard-providers/mq-dashboard-queue-sla-heatmap-provider.service.js +3 -3
- package/dist/services/dashboard-providers/mq-dashboard-queue-sla-heatmap-provider.service.js.map +1 -1
- package/dist/services/datasource-introspection/mssql-datasource-introspection-provider.service.d.ts +11 -0
- package/dist/services/datasource-introspection/mssql-datasource-introspection-provider.service.d.ts.map +1 -0
- package/dist/services/datasource-introspection/mssql-datasource-introspection-provider.service.js +181 -0
- package/dist/services/datasource-introspection/mssql-datasource-introspection-provider.service.js.map +1 -0
- package/dist/services/datasource-introspection/mysql-datasource-introspection-provider.service.d.ts +11 -0
- package/dist/services/datasource-introspection/mysql-datasource-introspection-provider.service.d.ts.map +1 -0
- package/dist/services/datasource-introspection/mysql-datasource-introspection-provider.service.js +90 -0
- package/dist/services/datasource-introspection/mysql-datasource-introspection-provider.service.js.map +1 -0
- package/dist/services/datasource-introspection/postgres-datasource-introspection-provider.service.d.ts +11 -0
- package/dist/services/datasource-introspection/postgres-datasource-introspection-provider.service.d.ts.map +1 -0
- package/dist/services/datasource-introspection/postgres-datasource-introspection-provider.service.js +156 -0
- package/dist/services/datasource-introspection/postgres-datasource-introspection-provider.service.js.map +1 -0
- package/dist/services/datasource-introspection.service.d.ts +288 -0
- package/dist/services/datasource-introspection.service.d.ts.map +1 -0
- package/dist/services/datasource-introspection.service.js +1278 -0
- package/dist/services/datasource-introspection.service.js.map +1 -0
- package/dist/services/datasource-management.service.d.ts +60 -0
- package/dist/services/datasource-management.service.d.ts.map +1 -0
- package/dist/services/datasource-management.service.js +461 -0
- package/dist/services/datasource-management.service.js.map +1 -0
- package/dist/services/field-metadata.service.d.ts.map +1 -1
- package/dist/services/field-metadata.service.js +19 -0
- package/dist/services/field-metadata.service.js.map +1 -1
- package/dist/services/model-metadata.service.d.ts +1 -3
- package/dist/services/model-metadata.service.d.ts.map +1 -1
- package/dist/services/model-metadata.service.js +47 -15
- package/dist/services/model-metadata.service.js.map +1 -1
- package/dist/services/role-metadata.service.d.ts +5 -0
- package/dist/services/role-metadata.service.d.ts.map +1 -1
- package/dist/services/role-metadata.service.js +85 -31
- package/dist/services/role-metadata.service.js.map +1 -1
- package/dist/services/selection-providers/mq-dashboard-message-broker-variable-options-provider.service.d.ts.map +1 -1
- package/dist/services/selection-providers/mq-dashboard-message-broker-variable-options-provider.service.js +2 -3
- package/dist/services/selection-providers/mq-dashboard-message-broker-variable-options-provider.service.js.map +1 -1
- package/dist/services/selection-providers/mq-dashboard-queue-name-variable-options-provider.service.d.ts.map +1 -1
- package/dist/services/selection-providers/mq-dashboard-queue-name-variable-options-provider.service.js +2 -3
- package/dist/services/selection-providers/mq-dashboard-queue-name-variable-options-provider.service.js.map +1 -1
- package/dist/services/setting.service.d.ts +1 -0
- package/dist/services/setting.service.d.ts.map +1 -1
- package/dist/services/setting.service.js +32 -8
- package/dist/services/setting.service.js.map +1 -1
- package/dist/services/solid-ts-morph.service.d.ts +1 -1
- package/dist/services/solid-ts-morph.service.d.ts.map +1 -1
- package/dist/services/solid-ts-morph.service.js.map +1 -1
- package/dist/services/view-metadata.service.d.ts +6 -0
- package/dist/services/view-metadata.service.d.ts.map +1 -1
- package/dist/services/view-metadata.service.js +66 -1
- package/dist/services/view-metadata.service.js.map +1 -1
- package/dist/solid-core.module.d.ts.map +1 -1
- package/dist/solid-core.module.js +16 -0
- package/dist/solid-core.module.js.map +1 -1
- package/dist-tests/api/authenticate.spec.js +119 -0
- package/dist-tests/api/authenticate.spec.js.map +1 -0
- package/dist-tests/api/crud-service.findOne.cityMaster.spec.js +97 -0
- package/dist-tests/api/crud-service.findOne.cityMaster.spec.js.map +1 -0
- package/dist-tests/api/ping.spec.js +21 -0
- package/dist-tests/api/ping.spec.js.map +1 -0
- package/dist-tests/helpers/auth.js +41 -0
- package/dist-tests/helpers/auth.js.map +1 -0
- package/dist-tests/helpers/env.js +11 -0
- package/dist-tests/helpers/env.js.map +1 -0
- package/docs/agent-hub-grooming.md +301 -0
- package/docs/dashboards/AGENTIC_DASHBOARD_IMPLEMENTATION_PLAN.md +438 -0
- package/docs/dashboards/dashboard-curl-smoke-tests.txt +146 -0
- package/docs/dashboards/delete-legacy-dashboard-metadata.sql +172 -0
- package/docs/datasource-introspection-ddl-analysis.md +326 -0
- package/docs/datasource-introspection-implementation-plan.md +306 -0
- package/docs/grouping-enhancements.md +89 -0
- package/docs/java-spring/README.md +3 -0
- package/docs/java-spring/solid-core-module-deep-dive-report.md +1317 -0
- package/docs/module-package-import-handoff.md +691 -0
- package/docs/seed-changes.md +65 -0
- package/docs/test-data-workflow.md +200 -0
- package/docs/type-declaration-import-issue.md +24 -0
- package/package.json +1 -1
- package/src/controllers/datasource-introspection.controller.ts +58 -0
- package/src/controllers/datasource-management.controller.ts +24 -0
- package/src/dtos/create-datasource-management.dto.ts +139 -0
- package/src/dtos/datasource-introspection-mapping.dto.ts +182 -0
- package/src/index.ts +5 -0
- package/src/interfaces/datasource-introspection-provider.interface.ts +28 -0
- package/src/repository/scheduled-job.repository.ts +73 -0
- package/src/seeders/module-metadata-seeder.service.ts +1223 -262
- package/src/seeders/seed-data/solid-core-metadata.json +22 -1
- package/src/services/action-metadata.service.ts +87 -2
- package/src/services/authentication.service.ts +1 -1
- package/src/services/dashboard-providers/mq-dashboard-latency-trend-provider.service.ts +9 -4
- package/src/services/dashboard-providers/mq-dashboard-messages-over-time-provider.service.ts +9 -4
- package/src/services/dashboard-providers/mq-dashboard-provider-utils.ts +82 -0
- package/src/services/dashboard-providers/mq-dashboard-queue-sla-heatmap-provider.service.ts +10 -4
- package/src/services/datasource-introspection/mssql-datasource-introspection-provider.service.ts +185 -0
- package/src/services/datasource-introspection/mysql-datasource-introspection-provider.service.ts +95 -0
- package/src/services/datasource-introspection/postgres-datasource-introspection-provider.service.ts +160 -0
- package/src/services/datasource-introspection.service.ts +1536 -0
- package/src/services/datasource-management.service.ts +566 -0
- package/src/services/field-metadata.service.ts +21 -1
- package/src/services/model-metadata.service.ts +50 -13
- package/src/services/role-metadata.service.ts +100 -47
- package/src/services/selection-providers/mq-dashboard-message-broker-variable-options-provider.service.ts +2 -4
- package/src/services/selection-providers/mq-dashboard-queue-name-variable-options-provider.service.ts +2 -4
- package/src/services/setting.service.ts +43 -12
- package/src/services/solid-ts-morph.service.ts +2 -2
- package/src/services/view-metadata.service.ts +79 -1
- package/src/solid-core.module.ts +16 -0
- package/.claude/settings.local.json +0 -15
- package/src/services/1.js +0 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"solid-ts-morph.service.js","sourceRoot":"","sources":["../../src/services/solid-ts-morph.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,2CAAoD;AACpD,yCAA2E;AAC3E,qCAA6E;AA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CAAC;QAGD,IAAI,UAAkB,CAAC;QACvB,IAAI,eAAe,KAAK,CAAC,CAAC,EAAE,CAAC;YACzB,UAAU;gBACN,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,eAAe,CAAC;oBACrC,IAAI;oBACJ,UAAU,CAAC,IAAI,EAAE;oBACjB,IAAI;oBACJ,WAAW,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;QAC3C,CAAC;aAAM,CAAC;YAEJ,UAAU,GAAG,UAAU,CAAC,IAAI,EAAE,GAAG,MAAM,GAAG,WAAW,CAAC;QAC1D,CAAC;QAED,IAAA,uBAAa,EAAC,GAAG,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC;QAEvC,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC/B,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,oBAAoB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,UAAU,EAAE,CAAC,CAAC;QACpE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAChE,CAAC;CAIJ,CAAA;AAvcY,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,mBAAU,GAAE;;GACA,mBAAmB,CAuc/B","sourcesContent":["// src/ai/services/solid-ts-morph.service.ts\nimport { Injectable, Logger } from \"@nestjs/common\";\nimport { join, dirname, normalize, isAbsolute, basename } from \"node:path\";\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { Project, Node, ObjectLiteralExpression, ArrayLiteralExpression, QuoteKind, IndentationText } from \"ts-morph\";\nimport { MethodDeclarationStructure, StructureKind } from \"ts-morph\";\n\ntype Bucket = \"providers\" | \"exports\";\n\n// interface SolidTsMorphOptions {\n// /** Absolute path to monorepo root. Defaults to auto-detect or ENV. */\n// repoRoot?: string;\n// /** Map of workspace prefixes to absolute directories. Defaults for solid-api / solid-ui. */\n// workspaceMap?: Record<string, string>;\n// }\n\n@Injectable()\nexport class SolidTsMorphService {\n private readonly logger = new Logger(SolidTsMorphService.name);\n private project: Project;\n\n // transaction state\n private inTxn = false;\n private stagedWrites = new Map<string, { content: string; overwrite: boolean }>(); // absPath -> write\n private dirtySourceFiles = new Set<string>(); // absPath\n\n // path roots\n private readonly repoRoot: string;\n private readonly workspaceMap: Record<string, string>;\n\n // constructor(opts: SolidTsMorphOptions = {}) {\n constructor() {\n // this.repoRoot = this.discoverRepoRoot(opts.repoRoot);\n this.repoRoot = this.discoverRepoRoot();\n this.workspaceMap = {\n \"solid-api\": join(this.repoRoot, \"solid-api\"),\n \"solid-ui\": join(this.repoRoot, \"solid-ui\"),\n // ...(opts.workspaceMap ?? {}),\n };\n\n this.project = new Project({\n skipAddingFilesFromTsConfig: true,\n manipulationSettings: {\n quoteKind: QuoteKind.Double,\n indentationText: IndentationText.FourSpaces,\n insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces: true,\n },\n });\n\n this.logger.debug(`SolidTsMorphService repoRoot = ${this.repoRoot}`);\n Object.entries(this.workspaceMap).forEach(([k, v]) => this.logger.debug(`workspace '${k}' => ${v}`));\n }\n\n // ---- repo-root discovery ----\n private discoverRepoRoot(): string {\n // if (input && isAbsolute(input)) return normalize(input);\n\n // ENV override\n const envRoot = process.env.SOLID_REPO_ROOT;\n if (envRoot && isAbsolute(envRoot)) return normalize(envRoot);\n\n // Auto-detect: if current cwd is a workspace (solid-api/solid-ui), then repoRoot = parent(cwd)\n const cwd = normalize(process.cwd());\n const base = basename(cwd);\n if (base === \"solid-api\" || base === \"solid-ui\") {\n return normalize(dirname(cwd));\n }\n\n // Otherwise assume cwd itself is the repo root\n return cwd;\n }\n\n /** Resolve a repo-relative path with optional workspace prefix (e.g. 'solid-api/...', 'solid-ui/...'). */\n private resolveRepoPath(relPath: string): string {\n if (!relPath) throw new Error(\"resolveRepoPath: empty path\");\n const p = normalize(relPath);\n\n if (isAbsolute(p)) return p;\n\n // Prefix-aware mapping: 'solid-api/...', 'solid-ui/...'\n for (const [prefix, root] of Object.entries(this.workspaceMap)) {\n if (p === prefix || p.startsWith(prefix + \"/\") || p.startsWith(prefix + \"\\\\\")) {\n const suffix = p.slice(prefix.length + (p.length > prefix.length ? 1 : 0));\n return normalize(join(root, suffix));\n }\n }\n\n // Default: treat as repo-root relative\n return normalize(join(this.repoRoot, p));\n }\n\n private rel(abs: string): string {\n const root = this.repoRoot.replace(/\\\\/g, \"/\");\n return abs.replace(/\\\\/g, \"/\").replace(root + \"/\", \"\");\n }\n\n // ---- transaction API ----\n begin(): void {\n if (this.inTxn) {\n this.logger.warn(\"begin(): already in a transaction; reusing current transaction.\");\n return;\n }\n this.inTxn = true;\n this.stagedWrites.clear();\n this.dirtySourceFiles.clear();\n this.project = new Project({\n skipAddingFilesFromTsConfig: true,\n manipulationSettings: {\n quoteKind: QuoteKind.Double,\n indentationText: IndentationText.FourSpaces,\n insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces: true,\n },\n });\n this.logger.log(\"Transaction started.\");\n }\n\n rollback(): void {\n if (!this.inTxn) return;\n this.inTxn = false;\n this.stagedWrites.clear();\n this.dirtySourceFiles.clear();\n this.project = new Project({\n skipAddingFilesFromTsConfig: true,\n manipulationSettings: {\n quoteKind: QuoteKind.Double,\n indentationText: IndentationText.FourSpaces,\n insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces: true,\n },\n });\n this.logger.log(\"Transaction rolled back.\");\n }\n\n async commit(): Promise<{ wrote: number }> {\n if (!this.inTxn) {\n this.logger.log(\"commit(): not in a transaction; nothing to commit.\");\n return { wrote: 0 };\n }\n\n let writes = 0;\n\n // 1) write staged new/overwritten files\n for (const [abs, { content, overwrite }] of this.stagedWrites.entries()) {\n const dir = dirname(abs);\n if (!existsSync(dir)) mkdirSync(dir, { recursive: true });\n if (existsSync(abs) && !overwrite) {\n this.logger.log(`createNewFile (staged): skipped (exists) ${this.rel(abs)}`);\n } else {\n writeFileSync(abs, content, \"utf8\");\n writes++;\n this.logger.log(`${existsSync(abs) && overwrite ? \"Overwrote\" : \"Created\"} file: ${this.rel(abs)}`);\n }\n }\n\n // 2) save all mutated module files once\n for (const abs of this.dirtySourceFiles.values()) {\n const sf = this.project.getSourceFile(abs);\n if (!sf) continue;\n sf.fixMissingImports();\n sf.organizeImports();\n await sf.save();\n writes++;\n this.logger.log(`Updated module: ${this.rel(abs)}`);\n }\n\n // end txn\n this.inTxn = false;\n this.stagedWrites.clear();\n this.dirtySourceFiles.clear();\n this.project = new Project({\n skipAddingFilesFromTsConfig: true,\n manipulationSettings: {\n quoteKind: QuoteKind.Double,\n indentationText: IndentationText.FourSpaces,\n insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces: true,\n },\n });\n\n return { wrote: writes };\n }\n\n // ---- operations ----\n createNewFile(path: string, content: string, overwrite = false): { createdOrStaged: boolean; skipped: boolean } {\n const abs = this.resolveRepoPath(path);\n const dir = dirname(abs);\n\n if (this.inTxn) {\n if (!existsSync(dir)) mkdirSync(dir, { recursive: true });\n this.stagedWrites.set(abs, { content, overwrite });\n this.logger.log(`Staged createNewFile: ${this.rel(abs)} (overwrite=${overwrite})`);\n return { createdOrStaged: true, skipped: false };\n }\n\n if (!existsSync(dir)) mkdirSync(dir, { recursive: true });\n if (existsSync(abs) && !overwrite) {\n this.logger.log(`createNewFile: skipped (exists): ${path}`);\n return { createdOrStaged: false, skipped: true };\n }\n writeFileSync(abs, content, \"utf8\");\n this.logger.log(`${existsSync(abs) && overwrite ? \"Overwrote\" : \"Created\"} file: ${path}`);\n return { createdOrStaged: true, skipped: false };\n }\n\n registerNestProvider(\n modulePath: string,\n providerClassName: string,\n importFrom: string,\n registerIn: Array<Bucket>,\n uniqueGuard = true\n ): { staged: boolean } {\n const abs = this.resolveRepoPath(modulePath);\n if (!existsSync(abs)) throw new Error(`registerNestProvider: module file not found at ${modulePath}`);\n\n const existing = this.project.getSourceFile(abs);\n const sourceFile = existing\n ? existing\n : this.project.createSourceFile(abs, readFileSync(abs, \"utf8\"), { overwrite: true });\n\n // ensure import\n const imp = sourceFile.getImportDeclarations().find(d => d.getModuleSpecifierValue() === importFrom);\n if (imp) {\n const has = imp.getNamedImports().some(ni => ni.getName() === providerClassName);\n if (!has) imp.addNamedImport(providerClassName);\n } else {\n sourceFile.addImportDeclaration({ moduleSpecifier: importFrom, namedImports: [providerClassName] });\n }\n\n // mutate @Module metadata\n const nestModuleClass = sourceFile.getClasses().find(cls =>\n cls.getDecorators().some(dec => dec.getName() === \"Module\")\n );\n if (!nestModuleClass) throw new Error(`registerNestProvider: No @Module() class found in ${modulePath}`);\n\n const moduleDec = nestModuleClass.getDecorators().find(dec => dec.getName() === \"Module\");\n const callExpr = moduleDec!.getCallExpression();\n const arg0 = callExpr?.getArguments()[0];\n if (!arg0 || !Node.isObjectLiteralExpression(arg0)) {\n throw new Error(`registerNestProvider: Malformed @Module() in ${modulePath}`);\n }\n const meta = arg0 as ObjectLiteralExpression;\n\n const ensureInArray = (propName: Bucket) => {\n let prop = meta.getProperty(propName);\n if (!prop) {\n meta.addPropertyAssignment({ name: propName, initializer: \"[]\" });\n prop = meta.getProperty(propName);\n }\n let arr: ArrayLiteralExpression | undefined;\n if (Node.isPropertyAssignment(prop)) {\n const init = prop.getInitializer();\n if (init && Node.isArrayLiteralExpression(init)) arr = init;\n }\n if (!arr) throw new Error(`registerNestProvider: Property ${propName} is not an array in ${modulePath}`);\n\n const exists = arr.getElements().some(el => el.getText().replace(/\\s/g, \"\") === providerClassName);\n if (!exists || !uniqueGuard) arr.addElement(providerClassName);\n };\n\n for (const bucket of registerIn) ensureInArray(bucket);\n\n this.dirtySourceFiles.add(abs); // defer save to commit()\n this.logger.log(`Staged provider registration in: ${this.rel(abs)} (${registerIn.join(\", \")})`);\n return { staged: true };\n }\n\n\n addMethodToExistingClass(\n filePath: string,\n className: string,\n methodName: string,\n methodCode: string,\n ): { staged: boolean; overwritten: boolean; skipped: boolean } {\n const abs = this.resolveRepoPath(filePath);\n if (!existsSync(abs))\n throw new Error(`addMethodToExistingClass: File not found at ${filePath}`);\n\n const existing = this.project.getSourceFile(abs);\n const sourceFile = existing\n ? existing\n : this.project.createSourceFile(abs, readFileSync(abs, \"utf8\"), { overwrite: true });\n\n const targetClass = sourceFile.getClass(className);\n if (!targetClass)\n throw new Error(`addMethodToExistingClass: Class ${className} not found in ${filePath}`);\n\n const existingMethod = targetClass.getMethod(methodName);\n if (existingMethod) {\n\n this.logger.log(`Skipped adding method '${methodName}' (already exists)`);\n return { staged: false, overwritten: false, skipped: true };\n }\n // Add the LLM-generated method directly\n targetClass.addMember(methodCode);\n\n\n this.dirtySourceFiles.add(abs);\n this.logger.log(`Staged method '${methodName}' in class ${className} at ${this.rel(abs)}`);\n return { staged: true, overwritten: !!existingMethod, skipped: false };\n }\n\n registerSolidUiExtension(\n filePath: string,\n lineToAdd: string\n ): { staged: boolean; overwritten: boolean; skipped: boolean } {\n const abs = this.resolveRepoPath(filePath);\n if (!existsSync(abs))\n throw new Error(`registerSolidUiExtension: File not found at ${filePath}`);\n\n const fileContent = readFileSync(abs, \"utf8\");\n\n // Check if the line already exists (avoid duplicates)\n if (fileContent.includes(lineToAdd.trim())) {\n this.logger.log(`Skipped adding line (already exists): ${lineToAdd}`);\n return { staged: false, overwritten: false, skipped: true };\n }\n\n // Append the new line at the end, ensuring newline\n const newContent = fileContent.trimEnd() + \"\\n\" + lineToAdd.trim() + \"\\n\";\n\n // Write updated content back\n writeFileSync(abs, newContent, \"utf8\");\n\n this.dirtySourceFiles.add(abs);\n this.logger.log(`Staged new line in ${this.rel(abs)}: ${lineToAdd}`);\n return { staged: true, overwritten: false, skipped: false };\n }\n\n\n //Removes all import declarations from a file whose module specifier matches the given predicate.\n //Returns the set of identifier names that were imported by the removed declarations.\n removeImports(\n filePath: string,\n filter: (moduleSpecifier: string) => boolean\n ): { removedIdentifiers: Set<string>; staged: boolean; skipped: boolean } {\n const abs = this.resolveRepoPath(filePath);\n if (!existsSync(abs)) {\n this.logger.warn(`removeImport: file not found at ${filePath}, skipping.`);\n return { removedIdentifiers: new Set(), staged: false, skipped: true };\n }\n\n const existing = this.project.getSourceFile(abs);\n const sourceFile = existing\n ? existing\n : this.project.createSourceFile(abs, readFileSync(abs, \"utf8\"), { overwrite: true });\n\n const importsToRemove = sourceFile.getImportDeclarations().filter(decl => {\n const spec = decl.getModuleSpecifierValue().replace(/\\\\/g, \"/\");\n return filter(spec);\n });\n\n if (importsToRemove.length === 0) {\n return { removedIdentifiers: new Set(), staged: false, skipped: true };\n }\n\n const removedIdentifiers = new Set<string>();\n for (const decl of importsToRemove) {\n for (const named of decl.getNamedImports()) {\n removedIdentifiers.add(named.getAliasNode()?.getText() ?? named.getName());\n }\n const defaultImport = decl.getDefaultImport();\n if (defaultImport) removedIdentifiers.add(defaultImport.getText());\n decl.remove();\n }\n\n this.dirtySourceFiles.add(abs);\n this.logger.log(`Staged removal of ${importsToRemove.length} import(s) in: ${this.rel(abs)}`);\n return { removedIdentifiers, staged: true, skipped: false };\n }\n\n //Removes the given identifier names from all @Module decorator array properties\n removeModuleMembers(\n filePath: string,\n names: Set<string> | string[]\n ): { staged: boolean; skipped: boolean } {\n const abs = this.resolveRepoPath(filePath);\n if (!existsSync(abs)) {\n this.logger.warn(`removeImportMembers: file not found at ${filePath}, skipping.`);\n return { staged: false, skipped: true };\n }\n\n const identifiers = names instanceof Set ? names : new Set(names);\n if (identifiers.size === 0) return { staged: false, skipped: true };\n\n const existing = this.project.getSourceFile(abs);\n const sourceFile = existing\n ? existing\n : this.project.createSourceFile(abs, readFileSync(abs, \"utf8\"), { overwrite: true });\n\n const nestModuleClass = sourceFile.getClasses().find(cls =>\n cls.getDecorators().some(dec => dec.getName() === \"Module\")\n );\n if (!nestModuleClass) {\n this.logger.warn(`removeImportMembers: no @Module() class found in ${filePath}`);\n return { staged: false, skipped: true };\n }\n\n const moduleDec = nestModuleClass.getDecorators().find(dec => dec.getName() === \"Module\");\n const arg0 = moduleDec?.getCallExpression()?.getArguments()[0];\n if (!arg0 || !Node.isObjectLiteralExpression(arg0)) return { staged: false, skipped: true };\n\n const meta = arg0 as ObjectLiteralExpression;\n for (const propName of [\"imports\", \"providers\", \"controllers\", \"exports\"] as const) {\n const prop = meta.getProperty(propName);\n if (!prop || !Node.isPropertyAssignment(prop)) continue;\n const init = prop.getInitializer();\n if (!init || !Node.isArrayLiteralExpression(init)) continue;\n const arr = init as ArrayLiteralExpression;\n const elements = arr.getElements();\n for (let i = elements.length - 1; i >= 0; i--) {\n const elemText = elements[i].getText().trim();\n // Match direct identifiers (e.g. TestService) or call expressions that reference them (e.g. TypeOrmModule.forFeature([Test])).\n const shouldRemove = identifiers.has(elemText) ||\n [...identifiers].some(id => new RegExp(`\\\\b${id}\\\\b`).test(elemText));\n if (shouldRemove) {\n arr.removeElement(i);\n }\n }\n }\n\n this.dirtySourceFiles.add(abs);\n this.logger.log(`Staged removal of [${[...identifiers].join(\", \")}] from @Module arrays in: ${this.rel(abs)}`);\n return { staged: true, skipped: false };\n }\n\n\n addImport(\n filePath: string,\n importLine: string\n ): { staged: boolean; overwritten: boolean; skipped: boolean } {\n const abs = this.resolveRepoPath(filePath);\n if (!existsSync(abs))\n throw new Error(`addImport: File not found at ${filePath}`);\n\n let fileContent = readFileSync(abs, \"utf8\");\n\n // If import already exists — skip\n if (fileContent.includes(importLine.trim())) {\n this.logger.log(`Skipped adding import (already exists): ${importLine}`);\n return { staged: false, overwritten: false, skipped: true };\n }\n\n // Find last import statement (so we can insert after all imports)\n const importRegex = /^import .+ from .+;$/gm;\n let lastImportMatch: RegExpExecArray | null;\n let lastImportIndex = -1;\n\n while ((lastImportMatch = importRegex.exec(fileContent)) !== null) {\n lastImportIndex = lastImportMatch.index + lastImportMatch[0].length;\n }\n\n // Insert after last import (or at top if none exist)\n let newContent: string;\n if (lastImportIndex !== -1) {\n newContent =\n fileContent.slice(0, lastImportIndex) +\n \"\\n\" +\n importLine.trim() +\n \"\\n\" +\n fileContent.slice(lastImportIndex);\n } else {\n // No imports found — insert at top\n newContent = importLine.trim() + \"\\n\\n\" + fileContent;\n }\n\n writeFileSync(abs, newContent, \"utf8\");\n\n this.dirtySourceFiles.add(abs);\n this.logger.log(`Staged import in ${this.rel(abs)}: ${importLine}`);\n return { staged: true, overwritten: false, skipped: false };\n }\n\n\n\n}"]}
|
|
1
|
+
{"version":3,"file":"solid-ts-morph.service.js","sourceRoot":"","sources":["../../src/services/solid-ts-morph.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,2CAAoD;AACpD,yCAA2E;AAC3E,qCAA6E;AAC7E,uCAAsH;AAa/G,IAAM,mBAAmB,2BAAzB,MAAM,mBAAmB;IAc5B;QAbiB,WAAM,GAAG,IAAI,eAAM,CAAC,qBAAmB,CAAC,IAAI,CAAC,CAAC;QAIvD,UAAK,GAAG,KAAK,CAAC;QACd,iBAAY,GAAG,IAAI,GAAG,EAAmD,CAAC;QAC1E,qBAAgB,GAAG,IAAI,GAAG,EAAU,CAAC;QASzC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACxC,IAAI,CAAC,YAAY,GAAG;YAChB,WAAW,EAAE,IAAA,gBAAI,EAAC,IAAI,CAAC,QAAQ,EAAE,WAAW,CAAC;YAC7C,UAAU,EAAE,IAAA,gBAAI,EAAC,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC;SAE9C,CAAC;QAEF,IAAI,CAAC,OAAO,GAAG,IAAI,kBAAO,CAAC;YACvB,2BAA2B,EAAE,IAAI;YACjC,oBAAoB,EAAE;gBAClB,SAAS,EAAE,oBAAS,CAAC,MAAM;gBAC3B,eAAe,EAAE,0BAAe,CAAC,UAAU;gBAC3C,qDAAqD,EAAE,IAAI;aAC9D;SACJ,CAAC,CAAC;QAEH,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,kCAAkC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QACrE,MAAM,CAAC,OAAO,CAAC,IAAI,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ger } from \"@nestjs/common\";\nimport { join, dirname, normalize, isAbsolute, basename } from \"node:path\";\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { Project, Node, ObjectLiteralExpression, ArrayLiteralExpression, QuoteKind, IndentationText } from \"ts-morph\";\nimport { MethodDeclarationStructure, StructureKind } from \"ts-morph\";\n\ntype Bucket = \"imports\" | \"providers\" | \"exports\";\n\n// interface SolidTsMorphOptions {\n// /** Absolute path to monorepo root. Defaults to auto-detect or ENV. */\n// repoRoot?: string;\n// /** Map of workspace prefixes to absolute directories. Defaults for solid-api / solid-ui. */\n// workspaceMap?: Record<string, string>;\n// }\n\n@Injectable()\nexport class SolidTsMorphService {\n private readonly logger = new Logger(SolidTsMorphService.name);\n private project: Project;\n\n // transaction state\n private inTxn = false;\n private stagedWrites = new Map<string, { content: string; overwrite: boolean }>(); // absPath -> write\n private dirtySourceFiles = new Set<string>(); // absPath\n\n // path roots\n private readonly repoRoot: string;\n private readonly workspaceMap: Record<string, string>;\n\n // constructor(opts: SolidTsMorphOptions = {}) {\n constructor() {\n // this.repoRoot = this.discoverRepoRoot(opts.repoRoot);\n this.repoRoot = this.discoverRepoRoot();\n this.workspaceMap = {\n \"solid-api\": join(this.repoRoot, \"solid-api\"),\n \"solid-ui\": join(this.repoRoot, \"solid-ui\"),\n // ...(opts.workspaceMap ?? {}),\n };\n\n this.project = new Project({\n skipAddingFilesFromTsConfig: true,\n manipulationSettings: {\n quoteKind: QuoteKind.Double,\n indentationText: IndentationText.FourSpaces,\n insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces: true,\n },\n });\n\n this.logger.debug(`SolidTsMorphService repoRoot = ${this.repoRoot}`);\n Object.entries(this.workspaceMap).forEach(([k, v]) => this.logger.debug(`workspace '${k}' => ${v}`));\n }\n\n // ---- repo-root discovery ----\n private discoverRepoRoot(): string {\n // if (input && isAbsolute(input)) return normalize(input);\n\n // ENV override\n const envRoot = process.env.SOLID_REPO_ROOT;\n if (envRoot && isAbsolute(envRoot)) return normalize(envRoot);\n\n // Auto-detect: if current cwd is a workspace (solid-api/solid-ui), then repoRoot = parent(cwd)\n const cwd = normalize(process.cwd());\n const base = basename(cwd);\n if (base === \"solid-api\" || base === \"solid-ui\") {\n return normalize(dirname(cwd));\n }\n\n // Otherwise assume cwd itself is the repo root\n return cwd;\n }\n\n /** Resolve a repo-relative path with optional workspace prefix (e.g. 'solid-api/...', 'solid-ui/...'). */\n private resolveRepoPath(relPath: string): string {\n if (!relPath) throw new Error(\"resolveRepoPath: empty path\");\n const p = normalize(relPath);\n\n if (isAbsolute(p)) return p;\n\n // Prefix-aware mapping: 'solid-api/...', 'solid-ui/...'\n for (const [prefix, root] of Object.entries(this.workspaceMap)) {\n if (p === prefix || p.startsWith(prefix + \"/\") || p.startsWith(prefix + \"\\\\\")) {\n const suffix = p.slice(prefix.length + (p.length > prefix.length ? 1 : 0));\n return normalize(join(root, suffix));\n }\n }\n\n // Default: treat as repo-root relative\n return normalize(join(this.repoRoot, p));\n }\n\n private rel(abs: string): string {\n const root = this.repoRoot.replace(/\\\\/g, \"/\");\n return abs.replace(/\\\\/g, \"/\").replace(root + \"/\", \"\");\n }\n\n // ---- transaction API ----\n begin(): void {\n if (this.inTxn) {\n this.logger.warn(\"begin(): already in a transaction; reusing current transaction.\");\n return;\n }\n this.inTxn = true;\n this.stagedWrites.clear();\n this.dirtySourceFiles.clear();\n this.project = new Project({\n skipAddingFilesFromTsConfig: true,\n manipulationSettings: {\n quoteKind: QuoteKind.Double,\n indentationText: IndentationText.FourSpaces,\n insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces: true,\n },\n });\n this.logger.log(\"Transaction started.\");\n }\n\n rollback(): void {\n if (!this.inTxn) return;\n this.inTxn = false;\n this.stagedWrites.clear();\n this.dirtySourceFiles.clear();\n this.project = new Project({\n skipAddingFilesFromTsConfig: true,\n manipulationSettings: {\n quoteKind: QuoteKind.Double,\n indentationText: IndentationText.FourSpaces,\n insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces: true,\n },\n });\n this.logger.log(\"Transaction rolled back.\");\n }\n\n async commit(): Promise<{ wrote: number }> {\n if (!this.inTxn) {\n this.logger.log(\"commit(): not in a transaction; nothing to commit.\");\n return { wrote: 0 };\n }\n\n let writes = 0;\n\n // 1) write staged new/overwritten files\n for (const [abs, { content, overwrite }] of this.stagedWrites.entries()) {\n const dir = dirname(abs);\n if (!existsSync(dir)) mkdirSync(dir, { recursive: true });\n if (existsSync(abs) && !overwrite) {\n this.logger.log(`createNewFile (staged): skipped (exists) ${this.rel(abs)}`);\n } else {\n writeFileSync(abs, content, \"utf8\");\n writes++;\n this.logger.log(`${existsSync(abs) && overwrite ? \"Overwrote\" : \"Created\"} file: ${this.rel(abs)}`);\n }\n }\n\n // 2) save all mutated module files once\n for (const abs of this.dirtySourceFiles.values()) {\n const sf = this.project.getSourceFile(abs);\n if (!sf) continue;\n sf.fixMissingImports();\n sf.organizeImports();\n await sf.save();\n writes++;\n this.logger.log(`Updated module: ${this.rel(abs)}`);\n }\n\n // end txn\n this.inTxn = false;\n this.stagedWrites.clear();\n this.dirtySourceFiles.clear();\n this.project = new Project({\n skipAddingFilesFromTsConfig: true,\n manipulationSettings: {\n quoteKind: QuoteKind.Double,\n indentationText: IndentationText.FourSpaces,\n insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces: true,\n },\n });\n\n return { wrote: writes };\n }\n\n // ---- operations ----\n createNewFile(path: string, content: string, overwrite = false): { createdOrStaged: boolean; skipped: boolean } {\n const abs = this.resolveRepoPath(path);\n const dir = dirname(abs);\n\n if (this.inTxn) {\n if (!existsSync(dir)) mkdirSync(dir, { recursive: true });\n this.stagedWrites.set(abs, { content, overwrite });\n this.logger.log(`Staged createNewFile: ${this.rel(abs)} (overwrite=${overwrite})`);\n return { createdOrStaged: true, skipped: false };\n }\n\n if (!existsSync(dir)) mkdirSync(dir, { recursive: true });\n if (existsSync(abs) && !overwrite) {\n this.logger.log(`createNewFile: skipped (exists): ${path}`);\n return { createdOrStaged: false, skipped: true };\n }\n writeFileSync(abs, content, \"utf8\");\n this.logger.log(`${existsSync(abs) && overwrite ? \"Overwrote\" : \"Created\"} file: ${path}`);\n return { createdOrStaged: true, skipped: false };\n }\n\n registerNestProvider(\n modulePath: string,\n providerClassName: string,\n importFrom: string,\n registerIn: Array<Bucket>,\n uniqueGuard = true\n ): { staged: boolean } {\n const abs = this.resolveRepoPath(modulePath);\n if (!existsSync(abs)) throw new Error(`registerNestProvider: module file not found at ${modulePath}`);\n\n const existing = this.project.getSourceFile(abs);\n const sourceFile = existing\n ? existing\n : this.project.createSourceFile(abs, readFileSync(abs, \"utf8\"), { overwrite: true });\n\n // ensure import\n const imp = sourceFile.getImportDeclarations().find(d => d.getModuleSpecifierValue() === importFrom);\n if (imp) {\n const has = imp.getNamedImports().some(ni => ni.getName() === providerClassName);\n if (!has) imp.addNamedImport(providerClassName);\n } else {\n sourceFile.addImportDeclaration({ moduleSpecifier: importFrom, namedImports: [providerClassName] });\n }\n\n // mutate @Module metadata\n const nestModuleClass = sourceFile.getClasses().find(cls =>\n cls.getDecorators().some(dec => dec.getName() === \"Module\")\n );\n if (!nestModuleClass) throw new Error(`registerNestProvider: No @Module() class found in ${modulePath}`);\n\n const moduleDec = nestModuleClass.getDecorators().find(dec => dec.getName() === \"Module\");\n const callExpr = moduleDec!.getCallExpression();\n const arg0 = callExpr?.getArguments()[0];\n if (!arg0 || !Node.isObjectLiteralExpression(arg0)) {\n throw new Error(`registerNestProvider: Malformed @Module() in ${modulePath}`);\n }\n const meta = arg0 as ObjectLiteralExpression;\n\n const ensureInArray = (propName: Bucket) => {\n let prop = meta.getProperty(propName);\n if (!prop) {\n meta.addPropertyAssignment({ name: propName, initializer: \"[]\" });\n prop = meta.getProperty(propName);\n }\n let arr: ArrayLiteralExpression | undefined;\n if (Node.isPropertyAssignment(prop)) {\n const init = prop.getInitializer();\n if (init && Node.isArrayLiteralExpression(init)) arr = init;\n }\n if (!arr) throw new Error(`registerNestProvider: Property ${propName} is not an array in ${modulePath}`);\n\n const exists = arr.getElements().some(el => el.getText().replace(/\\s/g, \"\") === providerClassName);\n if (!exists || !uniqueGuard) arr.addElement(providerClassName);\n };\n\n for (const bucket of registerIn) ensureInArray(bucket);\n\n this.dirtySourceFiles.add(abs); // defer save to commit()\n this.logger.log(`Staged provider registration in: ${this.rel(abs)} (${registerIn.join(\", \")})`);\n return { staged: true };\n }\n\n\n addMethodToExistingClass(\n filePath: string,\n className: string,\n methodName: string,\n methodCode: string,\n ): { staged: boolean; overwritten: boolean; skipped: boolean } {\n const abs = this.resolveRepoPath(filePath);\n if (!existsSync(abs))\n throw new Error(`addMethodToExistingClass: File not found at ${filePath}`);\n\n const existing = this.project.getSourceFile(abs);\n const sourceFile = existing\n ? existing\n : this.project.createSourceFile(abs, readFileSync(abs, \"utf8\"), { overwrite: true });\n\n const targetClass = sourceFile.getClass(className);\n if (!targetClass)\n throw new Error(`addMethodToExistingClass: Class ${className} not found in ${filePath}`);\n\n const existingMethod = targetClass.getMethod(methodName);\n if (existingMethod) {\n\n this.logger.log(`Skipped adding method '${methodName}' (already exists)`);\n return { staged: false, overwritten: false, skipped: true };\n }\n // Add the LLM-generated method directly\n targetClass.addMember(methodCode);\n\n\n this.dirtySourceFiles.add(abs);\n this.logger.log(`Staged method '${methodName}' in class ${className} at ${this.rel(abs)}`);\n return { staged: true, overwritten: !!existingMethod, skipped: false };\n }\n\n registerSolidUiExtension(\n filePath: string,\n lineToAdd: string\n ): { staged: boolean; overwritten: boolean; skipped: boolean } {\n const abs = this.resolveRepoPath(filePath);\n if (!existsSync(abs))\n throw new Error(`registerSolidUiExtension: File not found at ${filePath}`);\n\n const fileContent = readFileSync(abs, \"utf8\");\n\n // Check if the line already exists (avoid duplicates)\n if (fileContent.includes(lineToAdd.trim())) {\n this.logger.log(`Skipped adding line (already exists): ${lineToAdd}`);\n return { staged: false, overwritten: false, skipped: true };\n }\n\n // Append the new line at the end, ensuring newline\n const newContent = fileContent.trimEnd() + \"\\n\" + lineToAdd.trim() + \"\\n\";\n\n // Write updated content back\n writeFileSync(abs, newContent, \"utf8\");\n\n this.dirtySourceFiles.add(abs);\n this.logger.log(`Staged new line in ${this.rel(abs)}: ${lineToAdd}`);\n return { staged: true, overwritten: false, skipped: false };\n }\n\n\n //Removes all import declarations from a file whose module specifier matches the given predicate.\n //Returns the set of identifier names that were imported by the removed declarations.\n removeImports(\n filePath: string,\n filter: (moduleSpecifier: string) => boolean\n ): { removedIdentifiers: Set<string>; staged: boolean; skipped: boolean } {\n const abs = this.resolveRepoPath(filePath);\n if (!existsSync(abs)) {\n this.logger.warn(`removeImport: file not found at ${filePath}, skipping.`);\n return { removedIdentifiers: new Set(), staged: false, skipped: true };\n }\n\n const existing = this.project.getSourceFile(abs);\n const sourceFile = existing\n ? existing\n : this.project.createSourceFile(abs, readFileSync(abs, \"utf8\"), { overwrite: true });\n\n const importsToRemove = sourceFile.getImportDeclarations().filter(decl => {\n const spec = decl.getModuleSpecifierValue().replace(/\\\\/g, \"/\");\n return filter(spec);\n });\n\n if (importsToRemove.length === 0) {\n return { removedIdentifiers: new Set(), staged: false, skipped: true };\n }\n\n const removedIdentifiers = new Set<string>();\n for (const decl of importsToRemove) {\n for (const named of decl.getNamedImports()) {\n removedIdentifiers.add(named.getAliasNode()?.getText() ?? named.getName());\n }\n const defaultImport = decl.getDefaultImport();\n if (defaultImport) removedIdentifiers.add(defaultImport.getText());\n decl.remove();\n }\n\n this.dirtySourceFiles.add(abs);\n this.logger.log(`Staged removal of ${importsToRemove.length} import(s) in: ${this.rel(abs)}`);\n return { removedIdentifiers, staged: true, skipped: false };\n }\n\n //Removes the given identifier names from all @Module decorator array properties\n removeModuleMembers(\n filePath: string,\n names: Set<string> | string[]\n ): { staged: boolean; skipped: boolean } {\n const abs = this.resolveRepoPath(filePath);\n if (!existsSync(abs)) {\n this.logger.warn(`removeImportMembers: file not found at ${filePath}, skipping.`);\n return { staged: false, skipped: true };\n }\n\n const identifiers = names instanceof Set ? names : new Set(names);\n if (identifiers.size === 0) return { staged: false, skipped: true };\n\n const existing = this.project.getSourceFile(abs);\n const sourceFile = existing\n ? existing\n : this.project.createSourceFile(abs, readFileSync(abs, \"utf8\"), { overwrite: true });\n\n const nestModuleClass = sourceFile.getClasses().find(cls =>\n cls.getDecorators().some(dec => dec.getName() === \"Module\")\n );\n if (!nestModuleClass) {\n this.logger.warn(`removeImportMembers: no @Module() class found in ${filePath}`);\n return { staged: false, skipped: true };\n }\n\n const moduleDec = nestModuleClass.getDecorators().find(dec => dec.getName() === \"Module\");\n const arg0 = moduleDec?.getCallExpression()?.getArguments()[0];\n if (!arg0 || !Node.isObjectLiteralExpression(arg0)) return { staged: false, skipped: true };\n\n const meta = arg0 as ObjectLiteralExpression;\n for (const propName of [\"imports\", \"providers\", \"controllers\", \"exports\"] as const) {\n const prop = meta.getProperty(propName);\n if (!prop || !Node.isPropertyAssignment(prop)) continue;\n const init = prop.getInitializer();\n if (!init || !Node.isArrayLiteralExpression(init)) continue;\n const arr = init as ArrayLiteralExpression;\n const elements = arr.getElements();\n for (let i = elements.length - 1; i >= 0; i--) {\n const elemText = elements[i].getText().trim();\n // Match direct identifiers (e.g. TestService) or call expressions that reference them (e.g. TypeOrmModule.forFeature([Test])).\n const shouldRemove = identifiers.has(elemText) ||\n [...identifiers].some(id => new RegExp(`\\\\b${id}\\\\b`).test(elemText));\n if (shouldRemove) {\n arr.removeElement(i);\n }\n }\n }\n\n this.dirtySourceFiles.add(abs);\n this.logger.log(`Staged removal of [${[...identifiers].join(\", \")}] from @Module arrays in: ${this.rel(abs)}`);\n return { staged: true, skipped: false };\n }\n\n\n addImport(\n filePath: string,\n importLine: string\n ): { staged: boolean; overwritten: boolean; skipped: boolean } {\n const abs = this.resolveRepoPath(filePath);\n if (!existsSync(abs))\n throw new Error(`addImport: File not found at ${filePath}`);\n\n let fileContent = readFileSync(abs, \"utf8\");\n\n // If import already exists — skip\n if (fileContent.includes(importLine.trim())) {\n this.logger.log(`Skipped adding import (already exists): ${importLine}`);\n return { staged: false, overwritten: false, skipped: true };\n }\n\n // Find last import statement (so we can insert after all imports)\n const importRegex = /^import .+ from .+;$/gm;\n let lastImportMatch: RegExpExecArray | null;\n let lastImportIndex = -1;\n\n while ((lastImportMatch = importRegex.exec(fileContent)) !== null) {\n lastImportIndex = lastImportMatch.index + lastImportMatch[0].length;\n }\n\n // Insert after last import (or at top if none exist)\n let newContent: string;\n if (lastImportIndex !== -1) {\n newContent =\n fileContent.slice(0, lastImportIndex) +\n \"\\n\" +\n importLine.trim() +\n \"\\n\" +\n fileContent.slice(lastImportIndex);\n } else {\n // No imports found — insert at top\n newContent = importLine.trim() + \"\\n\\n\" + fileContent;\n }\n\n writeFileSync(abs, newContent, \"utf8\");\n\n this.dirtySourceFiles.add(abs);\n this.logger.log(`Staged import in ${this.rel(abs)}: ${importLine}`);\n return { staged: true, overwritten: false, skipped: false };\n }\n\n\n\n}\n"]}
|
|
@@ -21,6 +21,12 @@ export declare class ViewMetadataService extends CRUDService<ViewMetadata> {
|
|
|
21
21
|
private readonly modelMetadataRepo;
|
|
22
22
|
private readonly modelMetadataHelperService;
|
|
23
23
|
readonly moduleRef: ModuleRef;
|
|
24
|
+
private readonly comparableFields;
|
|
25
|
+
private readonly relationCompareFields;
|
|
26
|
+
private readonly jsonCompareFields;
|
|
27
|
+
private normalizeJsonFieldValue;
|
|
28
|
+
private getCanonicalJsonFieldString;
|
|
29
|
+
private hasChanges;
|
|
24
30
|
constructor(actionMetadataService: ActionMetadataService, menuItemMetadataService: MenuItemMetadataService, introspectService: SolidIntrospectService, userViewMetadataService: UserViewMetadataService, entityManager: EntityManager, repo: ViewMetadataRepository, modelMetadataRepo: ModelMetadataRepository, modelMetadataHelperService: ModelMetadataHelperService, moduleRef: ModuleRef);
|
|
25
31
|
private readonly logger;
|
|
26
32
|
private getEntityRecordsInAllLocales;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"view-metadata.service.d.ts","sourceRoot":"","sources":["../../src/services/view-metadata.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAIxC,OAAO,EAAE,0BAA0B,EAAE,MAAM,2CAA2C,CAAC;AAEvF,OAAO,EAAE,uBAAuB,EAAE,MAAM,0CAA0C,CAAC;AACnF,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AACjF,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAGvE,qBACa,mBAAoB,SAAQ,WAAW,CAAC,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"view-metadata.service.d.ts","sourceRoot":"","sources":["../../src/services/view-metadata.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAIxC,OAAO,EAAE,0BAA0B,EAAE,MAAM,2CAA2C,CAAC;AAEvF,OAAO,EAAE,uBAAuB,EAAE,MAAM,0CAA0C,CAAC;AACnF,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AACjF,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACz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Q,CAAC,MAAM,CAAwC;YAGjD,4BAA4B;IA8DpC,SAAS,CAAC,KAAK,KAAA,EAAE,UAAU,KAAA;;;;;;;;;YAsSnB,kBAAkB;IAyB1B,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,KAAK;IAU7C,MAAM,CAAC,kBAAkB,EAAE,qBAAqB;IA0BhD,kBAAkB,CAAC,kBAAkB,EAAE,qBAAqB;CAgBnE"}
|
|
@@ -30,6 +30,52 @@ const menu_item_metadata_service_1 = require("./menu-item-metadata.service");
|
|
|
30
30
|
const solid_introspect_service_1 = require("./solid-introspect.service");
|
|
31
31
|
const user_view_metadata_service_1 = require("./user-view-metadata.service");
|
|
32
32
|
let ViewMetadataService = ViewMetadataService_1 = class ViewMetadataService extends crud_service_1.CRUDService {
|
|
33
|
+
normalizeJsonFieldValue(value) {
|
|
34
|
+
if (typeof value === 'string') {
|
|
35
|
+
const trimmedValue = value.trim();
|
|
36
|
+
if ((trimmedValue.startsWith('{') && trimmedValue.endsWith('}')) ||
|
|
37
|
+
(trimmedValue.startsWith('[') && trimmedValue.endsWith(']'))) {
|
|
38
|
+
try {
|
|
39
|
+
return this.normalizeJsonFieldValue(JSON.parse(trimmedValue));
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
return value;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return value;
|
|
46
|
+
}
|
|
47
|
+
if (Array.isArray(value)) {
|
|
48
|
+
return value.map((item) => this.normalizeJsonFieldValue(item));
|
|
49
|
+
}
|
|
50
|
+
if (value && typeof value === 'object') {
|
|
51
|
+
return Object.keys(value)
|
|
52
|
+
.sort()
|
|
53
|
+
.reduce((result, key) => {
|
|
54
|
+
result[key] = this.normalizeJsonFieldValue(value[key]);
|
|
55
|
+
return result;
|
|
56
|
+
}, {});
|
|
57
|
+
}
|
|
58
|
+
return value;
|
|
59
|
+
}
|
|
60
|
+
getCanonicalJsonFieldString(value) {
|
|
61
|
+
return JSON.stringify(this.normalizeJsonFieldValue(value) ?? null);
|
|
62
|
+
}
|
|
63
|
+
hasChanges(existingSolidView, updateSolidViewDto) {
|
|
64
|
+
return this.comparableFields.some((key) => {
|
|
65
|
+
const value = updateSolidViewDto[key];
|
|
66
|
+
if (typeof value === 'undefined') {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
if (this.relationCompareFields.has(key)) {
|
|
70
|
+
const relationValue = value;
|
|
71
|
+
return existingSolidView[key]?.id !== relationValue?.id;
|
|
72
|
+
}
|
|
73
|
+
if (this.jsonCompareFields.has(key)) {
|
|
74
|
+
return this.getCanonicalJsonFieldString(existingSolidView[key]) !== this.getCanonicalJsonFieldString(value);
|
|
75
|
+
}
|
|
76
|
+
return existingSolidView[key] !== value;
|
|
77
|
+
});
|
|
78
|
+
}
|
|
33
79
|
constructor(actionMetadataService, menuItemMetadataService, introspectService, userViewMetadataService, entityManager, repo, modelMetadataRepo, modelMetadataHelperService, moduleRef) {
|
|
34
80
|
super(entityManager, repo, 'viewMetadata', 'solid-core', moduleRef);
|
|
35
81
|
this.actionMetadataService = actionMetadataService;
|
|
@@ -41,6 +87,17 @@ let ViewMetadataService = ViewMetadataService_1 = class ViewMetadataService exte
|
|
|
41
87
|
this.modelMetadataRepo = modelMetadataRepo;
|
|
42
88
|
this.modelMetadataHelperService = modelMetadataHelperService;
|
|
43
89
|
this.moduleRef = moduleRef;
|
|
90
|
+
this.comparableFields = [
|
|
91
|
+
'name',
|
|
92
|
+
'displayName',
|
|
93
|
+
'type',
|
|
94
|
+
'context',
|
|
95
|
+
'layout',
|
|
96
|
+
'module',
|
|
97
|
+
'model',
|
|
98
|
+
];
|
|
99
|
+
this.relationCompareFields = new Set(['module', 'model']);
|
|
100
|
+
this.jsonCompareFields = new Set(['layout', 'context']);
|
|
44
101
|
this.logger = new common_1.Logger(ViewMetadataService_1.name);
|
|
45
102
|
}
|
|
46
103
|
async getEntityRecordsInAllLocales(modelName, id, defaultEntityLocaleIdFromQuery) {
|
|
@@ -289,8 +346,16 @@ let ViewMetadataService = ViewMetadataService_1 = class ViewMetadataService exte
|
|
|
289
346
|
return entity;
|
|
290
347
|
}
|
|
291
348
|
async upsert(updateSolidViewDto) {
|
|
292
|
-
const existingSolidView = await this.findOneByUserKey(updateSolidViewDto.name
|
|
349
|
+
const existingSolidView = await this.findOneByUserKey(updateSolidViewDto.name, {
|
|
350
|
+
module: true,
|
|
351
|
+
model: true,
|
|
352
|
+
});
|
|
293
353
|
if (existingSolidView) {
|
|
354
|
+
const hasChanges = this.hasChanges(existingSolidView, updateSolidViewDto);
|
|
355
|
+
if (!hasChanges) {
|
|
356
|
+
this.logger.debug(`Skipping view upsert for ${updateSolidViewDto.name}; no changes detected.`);
|
|
357
|
+
return existingSolidView;
|
|
358
|
+
}
|
|
294
359
|
const updatedSolidViewDto = { ...existingSolidView, ...updateSolidViewDto };
|
|
295
360
|
return this.repo.save(updatedSolidViewDto);
|
|
296
361
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"view-metadata.service.js","sourceRoot":"","sources":["../../src/services/view-metadata.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAA6F;AAC7F,uCAAyC;AACzC,6CAAsD;AACtD,iDAAwD;AACxD,qCAAwC;AAExC,4DAAoD;AACpD,6DAAoD;AACpD,4FAAuF;AACvF,8DAA2D;AAC3D,uFAAmF;AACnF,qFAAiF;AAIjF,uEAAkE;AAClE,6EAAuE;AACvE,yEAAoE;AACpE,6EAAuE;AAIhE,IAAM,mBAAmB,2BAAzB,MAAM,mBAAoB,SAAQ,0BAAyB;IAChE,YACW,qBAA4C,EAC5C,uBAAgD,EAChD,iBAAyC,EACzC,uBAAgD,EAEzD,aAAqC,EAE5B,IAA4B,EAMrC,iBAA2D,EAC1C,0BAAsD,EAC9D,SAAoB;QAE7B,KAAK,CAAC,aAAa,EAAE,IAAI,EAAE,cAAc,EAAE,YAAY,EAAE,SAAS,CAAC,CAAC;QAjB3D,0BA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,CAAC;QAG/E,IAAI,iBAAiB,EAAE,CAAC;QACxB,CAAC;aAEI,CAAC;YACJ,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC;YACtD,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAClC,CAAC;IACH,CAAC;CAIF,CAAA;AAhcY,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,mBAAU,GAAE;IAOR,WAAA,IAAA,6BAAmB,GAAE,CAAA;IAQrB,WAAA,IAAA,eAAM,EAAC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,mDAAuB,CAAC,CAAC,CAAA;qCAZlB,+CAAqB;QACnB,oDAAuB;QAC7B,iDAAsB;QAChB,oDAAuB;QAEjC,uBAAa;QAEtB,iDAAsB;QAMD,mDAAuB;QACd,0DAA0B;QACnD,gBAAS;GAjBpB,mBAAmB,CAgc/B","sourcesContent":["import { BadRequestException, forwardRef, Inject, Injectable, Logger } from '@nestjs/common';\nimport { ModuleRef } from \"@nestjs/core\";\nimport { InjectEntityManager } from '@nestjs/typeorm';\nimport { CRUDService } from 'src/services/crud.service';\nimport { EntityManager } from 'typeorm';\n\nimport { classify } from '../helpers/string.helper';\nimport { Locale } from 'src/entities/locale.entity';\nimport { ModelMetadataHelperService } from 'src/helpers/model-metadata-helper.service';\nimport { SolidRegistry } from 'src/helpers/solid-registry';\nimport { ModelMetadataRepository } from 'src/repository/model-metadata.repository';\nimport { ViewMetadataRepository } from 'src/repository/view-metadata.repository';\nimport { UpdateViewMetadataDto } from '../dtos/update-view-metadata.dto';\nimport { FieldMetadata } from '../entities/field-metadata.entity';\nimport { ViewMetadata } from '../entities/view-metadata.entity';\nimport { ActionMetadataService } from './action-metadata.service';\nimport { MenuItemMetadataService } from './menu-item-metadata.service';\nimport { SolidIntrospectService } from './solid-introspect.service';\nimport { UserViewMetadataService } from './user-view-metadata.service';\nimport { MenuItemMetadata } from 'src/entities/menu-item-metadata.entity';\n\n@Injectable()\nexport class ViewMetadataService extends CRUDService<ViewMetadata> {\n constructor(\n readonly actionMetadataService: ActionMetadataService,\n readonly menuItemMetadataService: MenuItemMetadataService,\n readonly introspectService: SolidIntrospectService,\n readonly userViewMetadataService: UserViewMetadataService,\n @InjectEntityManager()\n readonly entityManager: EntityManager,\n // @InjectRepository(ViewMetadata, 'default')\n readonly repo: ViewMetadataRepository,\n // @InjectRepository(FieldMetadata)\n // private readonly fieldMetadataRepo: Repository<FieldMetadata>,\n // @InjectRepository(ModelMetadata)\n // private readonly modelMetadataRepo: Repository<ModelMetadata>,\n @Inject(forwardRef(() => ModelMetadataRepository))\n private readonly modelMetadataRepo: ModelMetadataRepository,\n private readonly modelMetadataHelperService: ModelMetadataHelperService,\n readonly moduleRef: ModuleRef\n ) {\n super(entityManager, repo, 'viewMetadata', 'solid-core', moduleRef);\n }\n\n private readonly logger = new Logger(ViewMetadataService.name);\n\n //for locales \n private async getEntityRecordsInAllLocales(\n modelName: string,\n id: string,\n defaultEntityLocaleIdFromQuery?: string\n ): Promise<{ records: any[], defaultEntityLocaleId: string | null }> {\n const solidRegistry = await this.moduleRef.get(SolidRegistry, { strict: false });\n // const currentEntityTarget = solidRegistry.getEntityTarget(this.entityManager, classify(modelName));\n const currentEntityRepository = this.entityManager.getRepository(classify(modelName));\n\n // Case 1: Creating a new record with no defaultEntityLocaleId to clone\n if (id === 'new' && !defaultEntityLocaleIdFromQuery) {\n this.logger.debug(`Creating new record without cloning from any defaultEntityLocaleId.`);\n return { records: [], defaultEntityLocaleId: null };\n }\n\n // Case 2: Creating a new record and cloning from an existing defaultEntityLocaleId\n if (id === 'new' && defaultEntityLocaleIdFromQuery) {\n this.logger.debug(`Creating new record by cloning translations from defaultEntityLocaleId: ${defaultEntityLocaleIdFromQuery}`);\n\n const records = await currentEntityRepository.find({\n where: [\n { defaultEntityLocaleId: defaultEntityLocaleIdFromQuery },\n { id: defaultEntityLocaleIdFromQuery }\n ]\n });\n\n this.logger.debug(`Found ${records.length} cloned records for new entity.`);\n return { records, defaultEntityLocaleId: defaultEntityLocaleIdFromQuery };\n }\n\n // Case 3: Editing an existing entity\n const entityRecord = await currentEntityRepository.findOne({ where: { id } });\n\n if (!entityRecord) {\n this.logger.warn(`No entity found for id ${id}`);\n return { records: [], defaultEntityLocaleId: null };\n }\n\n const defaultLocale = await this.entityManager.getRepository(Locale).findOne({ where: { isDefault: true } });\n\n let defaultEntityLocaleId: string;\n if (entityRecord.localeName === defaultLocale?.locale) {\n defaultEntityLocaleId = entityRecord.id;\n this.logger.debug(`Editing default locale record with id ${defaultEntityLocaleId}`);\n } else {\n defaultEntityLocaleId = entityRecord.defaultEntityLocaleId;\n this.logger.debug(`Editing non-default locale record. DefaultEntityLocaleId: ${defaultEntityLocaleId}`);\n }\n\n const records = await currentEntityRepository.find({\n where: [\n { defaultEntityLocaleId: defaultEntityLocaleId },\n { id: defaultEntityLocaleId }\n ]\n });\n\n this.logger.debug(`Found ${records.length} records in all locales for existing entity.`);\n\n return { records, defaultEntityLocaleId };\n }\n\n // START: Custom Service Methods\n async getLayout(query, activeUser) {\n let { modelName, moduleName, viewType, id, populate, menuItemId, menuItemName, actionId, actionName } = query;\n\n // 1. Fetch the action based on actionId.\n const solidRequestContext = {\n activeUser: activeUser\n }\n const actionQuery = {\n populate: [\"view\"]\n }\n let action = null;\n if (actionId) {\n action = await this.actionMetadataService.findOne(actionId, actionQuery, solidRequestContext);\n }\n\n // 2. Fetch the menu based on menuItemId.\n const menuItemQuery = {\n populate: ['action', 'action.model', 'module']\n }\n let menuItem: MenuItemMetadata = null;\n if (menuItemId) {\n menuItem = await this.menuItemMetadataService.findOne(menuItemId, menuItemQuery, solidRequestContext);\n }\n\n let viewModes = [];\n const menuItemModelId = menuItem?.action?.model?.id;\n const menuItemModuleId = menuItem?.module?.id;\n const collectionViewTypes = ['card', 'list', 'kanban', 'tree'];\n if (menuItemModelId && menuItemModuleId) {\n const actionQb = await this.actionMetadataService.repo.createSecurityRuleAwareQueryBuilder('action');\n const actionsForViewModes = await actionQb\n .leftJoinAndSelect('action.model', 'model')\n .leftJoinAndSelect('action.module', 'module')\n .leftJoinAndSelect('action.view', 'view')\n .where('model.id = :modelId', { modelId: menuItemModelId })\n .andWhere('module.id = :moduleId', { moduleId: menuItemModuleId })\n .andWhere('view.type IN (:...viewTypes)', { viewTypes: collectionViewTypes })\n .getMany();\n\n const canonicalActionsByViewType = new Map();\n for (const actionItem of actionsForViewModes) {\n const resolvedViewType = actionItem.view?.type;\n if (!resolvedViewType || canonicalActionsByViewType.has(resolvedViewType)) {\n continue;\n }\n canonicalActionsByViewType.set(resolvedViewType, actionItem);\n }\n\n if (action?.view?.type && collectionViewTypes.includes(action.view.type) && action?.id) {\n canonicalActionsByViewType.set(action.view.type, action);\n }\n\n viewModes = collectionViewTypes\n .map((resolvedViewType) => canonicalActionsByViewType.get(resolvedViewType))\n .filter(Boolean)\n .map(actionItem => ({\n type: actionItem.view?.type ?? '',\n menuItemId: menuItem.id,\n menuItemName: menuItem.displayName,\n actionId: actionItem.id ?? '',\n actionName: actionItem.displayName ?? '',\n }));\n }\n\n const viewId = action?.view?.id\n // 3. Fetch the view based on module, model & view name.\n const entity = await this.repo.findOne({\n where: {\n model: { singularName: modelName },\n module: { name: moduleName },\n ...(actionId && viewId ? { id: action.view.id } : { type: viewType })\n },\n relations: {\n model: {\n userKeyField: true,\n },\n module: true,\n }\n });\n\n if (!entity) {\n throw new BadRequestException(`Unable to identify view for module: ${moduleName}, model: ${modelName} and viewType: ${viewType}`);\n }\n if (!activeUser?.sub) {\n throw new BadRequestException(`Unable to identify user for module: ${moduleName}, model: ${modelName} and viewType: ${viewType}`);\n }\n\n // 4. add action and menuItem to Entity which is our solid View\n if (actionId) {\n delete action.view;\n entity['action'] = action\n }\n if (menuItemId) {\n entity['menu'] = menuItem\n }\n\n // 5. See if we have a user specific layout for this view.\n const userLayout = await this.userViewMetadataService.repo.findOne({\n where: {\n user: { id: activeUser?.sub },\n viewMetadata: { id: entity.id },\n },\n });\n // Based on where we found the layout we are converting it from string to json.\n if (userLayout) {\n entity.layout = JSON.parse(userLayout.layout);\n } else {\n entity.layout = JSON.parse(entity.layout);\n }\n\n // 6. We are resolving the create & edit actions if specified in the layout.\n if (entity?.layout?.attrs?.createAction) {\n const actionName: string = entity.layout.attrs.createAction;\n entity.layout.attrs.createAction = await this.actionMetadataService.findOneByUserKey(actionName)\n }\n if (entity?.layout?.attrs?.editAction) {\n const actionName: string = entity.layout.attrs.editAction;\n entity.layout.attrs.editAction = await this.actionMetadataService.findOneByUserKey(actionName)\n }\n\n // 7. For form views we need to fetch the workflow field metadata if specified.\n let workflowFieldName = null;\n let workflowField = null;\n if (viewType === 'form') {\n workflowFieldName = entity.layout?.attrs?.workflowField;\n }\n\n // 8. Create an easy to use map of field metadata, rather than sending an array of fields it becomes easier to use in the frontend.\n const fields = await this.modelMetadataHelperService.loadFieldHierarchy(modelName);\n const fieldsMap = new Map<string, FieldMetadata>();\n for (let i = 0; i < fields.length; i++) {\n const field = fields[i];\n\n // We need to identify the workflowField metadata if specified. \n if (workflowFieldName && field.name === workflowFieldName) {\n workflowField = field;\n }\n\n // For fields of type relation & relationType many-to-one\n // We fetch metadata regarding the relationCoModelSingularName\n if (field.type === 'relation') {\n const relationModel = await this.modelMetadataRepo.find({\n where: {\n singularName: field.relationCoModelSingularName\n },\n relations: {\n userKeyField: true\n }\n });\n\n if (relationModel) {\n field['relationModel'] = relationModel[0];\n }\n }\n if (!fieldsMap.has(field.name)) {\n fieldsMap.set(field.name, field);\n }\n }\n\n // 9. Use the resolved workflowField to populate workflow specific metadata.\n // Check if we were able to resolve an actual workflowField.\n let solidFormViewWorkflowData = [];\n if (viewType === 'form' && workflowField) {\n // check for type of workflow field. \n // for workflowFields of type selectionStatic we simply return the key/values from field metadata AS-IS\n if (workflowField.type === 'selectionStatic') {\n solidFormViewWorkflowData = workflowField.selectionStaticValues.map(item => {\n const [value, label] = item.split(\":\");\n return { label, value };\n });\n }\n // for workflowFields of type relation.many-to-one we need to query the co-model, and return data in key/value format.\n if (workflowField.type === 'relation' && workflowField.relationType === 'many-to-one') {\n const comodelCrudService = this.introspectService.getCRUDService(workflowField.relationCoModelSingularName);\n const data = await comodelCrudService.find({ limit: 100, offset: 0, });\n const records = data.records ?? [];\n const workflowFieldMetadata = fieldsMap.get(workflowFieldName);\n const workflowFielUserkey = workflowFieldMetadata['relationModel']['userKeyField']['name'];\n\n // iterate over the comodel records extracting the label & value. \n solidFormViewWorkflowData = records.map(item => ({ 'label': item[workflowFielUserkey], 'value': item['id'] }))\n }\n }\n\n // 10. If this model supports internationalisation, we need to load the locales applicable with the id of an actual record for each locale if present.\n // This is the shape of locales that will be returned \n /**\n * [\n * {locale: 'en', displayName: 'English', isDefault: 'yes', defaultEntityLocaleId: '', entityId: '1'}, \n * {locale: 'en-IN', displayName: 'English (India)', isDefault: 'no', defaultEntityLocaleId: '1', entityId: '2'}, \n * {locale: 'en-SG', displayName: 'English (Singapore)', isDefault: 'no', defaultEntityLocaleId: '', entityId: '3'}, \n * {locale: 'fr', displayName: 'French', isDefault: 'no', defaultEntityLocaleId: '', entityId: ''}\n * ]\n */\n\n const applicableLocales: any = []\n // if (entity.model.internationalisation) {\n // const allLocales = await this.entityManager.getRepository(Locale).find({});\n\n // if (id === 'new') {\n // allLocales.forEach(locale => {\n // applicableLocales.push({\n // locale: locale.locale,\n // displayName: locale.displayName,\n // isDefault: locale.isDefault ? 'yes' : 'no',\n // defaultEntityLocaleId: null,\n // entityId: null\n // });\n // });\n // }\n // else {\n // const defaultLocale = allLocales.find(locale => locale.isDefault);\n // this.logger.debug(`Default locale is: ${defaultLocale.locale}`);\n\n // // Get hold of the repository for the current model\n // const solidRegistry = await this.moduleRef.get(SolidRegistry, { strict: false });\n // const currentEntityTarget = solidRegistry.getEntityTarget(this.entityManager, classify(modelName));\n // const currentEntityRepository = this.entityManager.getRepository(currentEntityTarget);\n\n // // We are in edit mode, the id that is being edited could be a record tagged with the default locale or it could be tagged with a non-default locale.\n // const entityRecord = await currentEntityRepository.findOne({\n // where: {\n // id: id,\n // }\n // });\n // if(entityRecord){\n // // Resolve the default entity locale id....\n // let defaultEntityLocaleId = null;\n // if (entityRecord.localeName === defaultLocale.locale) {\n // defaultEntityLocaleId = entityRecord.id;\n // this.logger.debug(`You are editing a record tagged with the default locale: ${entityRecord.localeName}.`);\n // }\n // else {\n // defaultEntityLocaleId = entityRecord.defaultEntityLocaleId;\n // this.logger.debug(`You are editing a record tagged with the non-default locale: ${entityRecord.localeName}. `);\n // }\n // this.logger.debug(`Identified default Entity Locale Id: ${defaultEntityLocaleId}`);\n\n // // Now we query for all records in the same model matching the defaultEntityLocaleId\n // // Get all records mathcing the defaultEntityLocaleId or where the id is same as the defaultEntityLocaleId\n // const entityRecordsInAllLocales = await currentEntityRepository.find({\n // where: [\n // { defaultEntityLocaleId: defaultEntityLocaleId },\n // { id: defaultEntityLocaleId }\n // ],\n // });\n // this.logger.debug(`Found ${entityRecordsInAllLocales.length} records in all locales for the defaultEntityLocaleId: ${defaultEntityLocaleId}`);\n\n // // Loop over all locales and populate the applicableLocales array\n // for (const locale of allLocales) {\n // // Find the record in the entityRecordsInAllLocales that matches the current locale\n // const matchingRecord = entityRecordsInAllLocales.find(record => record.localeName === locale.locale);\n\n // applicableLocales.push({\n // locale: locale.locale,\n // displayName: locale.displayName,\n // isDefault: locale.isDefault ? 'yes' : 'no',\n // defaultEntityLocaleId: defaultEntityLocaleId,\n // entityId: (matchingRecord ? matchingRecord.id : null)\n // });\n // }\n // }else{\n // this.logger.warn(`No record found for id: ${id} in model: ${modelName}. Cannot determine applicable locales.`);\n // }\n // }\n // }\n if (entity.model.internationalisation) {\n const defaultEntityLocaleIdFromQuery = query?.defaultEntityLocaleId;\n const { records: entityRecordsInAllLocales, defaultEntityLocaleId } =\n await this.getEntityRecordsInAllLocales(modelName, id, defaultEntityLocaleIdFromQuery);\n const allLocales = await this.entityManager.getRepository(Locale).find({});\n for (const locale of allLocales) {\n const matchingRecord = entityRecordsInAllLocales.find(record => record.localeName === locale.locale);\n applicableLocales.push({\n locale: locale.locale,\n displayName: locale.displayName,\n isDefault: locale.isDefault ? 'yes' : 'no',\n defaultEntityLocaleId: defaultEntityLocaleId,\n entityId: matchingRecord ? matchingRecord.id : null\n });\n }\n }\n\n const r = {\n 'solidView': entity,\n 'solidFieldsMetadata': Object.fromEntries(fieldsMap),\n 'solidFormViewWorkflowData': solidFormViewWorkflowData,\n 'applicableLocales': applicableLocales,\n 'viewModes': viewModes\n }\n\n return r;\n }\n\n private async loadFieldHierarchy(modelName: any) {\n const model = await this.modelMetadataRepo.findOne({\n where: {\n singularName: modelName,\n },\n relations: {\n fields: true,\n parentModel: {\n fields: true,\n }\n }\n });\n const fields = [];\n if (model) {\n // Add the fields of the current model\n fields.push(...model.fields);\n\n // Add the fields of the parent model\n if (model.parentModel) {\n fields.push(...model.parentModel.fields);\n }\n }\n return fields;\n }\n\n async findOneByUserKey(name: string, relations = {}) {\n const entity = await this.repo.findOne({\n where: {\n name: name,\n },\n relations: relations,\n });\n return entity;\n }\n\n async upsert(updateSolidViewDto: UpdateViewMetadataDto) {\n // First check if module already exists using name\n const existingSolidView = await this.findOneByUserKey(updateSolidViewDto.name);\n\n // if found\n if (existingSolidView) {\n const updatedSolidViewDto = { ...existingSolidView, ...updateSolidViewDto };\n return this.repo.save(updatedSolidViewDto);\n }\n // if not found - create new \n else {\n const viewData = this.repo.create(updateSolidViewDto);\n return this.repo.save(viewData);\n }\n }\n\n async createIfNotPresent(updateSolidViewDto: UpdateViewMetadataDto) {\n // First check if module already exists using name\n const existingSolidView = await this.findOneByUserKey(updateSolidViewDto.name);\n\n // if found\n if (existingSolidView) {\n }\n // if not found - create new \n else {\n const viewData = this.repo.create(updateSolidViewDto);\n return this.repo.save(viewData);\n }\n }\n\n // END: Custom Service Methods\n\n}\n"]}
|
|
1
|
+
{"version":3,"file":"view-metadata.service.js","sourceRo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DAAsB;QAChB,oDAAuB;QAEjC,uBAAa;QAEtB,iDAAsB;QAMD,mDAAuB;QACd,0DAA0B;QACnD,gBAAS;GArFpB,mBAAmB,CA8gB/B","sourcesContent":["import { BadRequestException, forwardRef, Inject, Injectable, Logger } from '@nestjs/common';\nimport { ModuleRef } from \"@nestjs/core\";\nimport { InjectEntityManager } from '@nestjs/typeorm';\nimport { CRUDService } from 'src/services/crud.service';\nimport { EntityManager } from 'typeorm';\n\nimport { classify } from '../helpers/string.helper';\nimport { Locale } from 'src/entities/locale.entity';\nimport { ModelMetadataHelperService } from 'src/helpers/model-metadata-helper.service';\nimport { SolidRegistry } from 'src/helpers/solid-registry';\nimport { ModelMetadataRepository } from 'src/repository/model-metadata.repository';\nimport { ViewMetadataRepository } from 'src/repository/view-metadata.repository';\nimport { UpdateViewMetadataDto } from '../dtos/update-view-metadata.dto';\nimport { FieldMetadata } from '../entities/field-metadata.entity';\nimport { ViewMetadata } from '../entities/view-metadata.entity';\nimport { ActionMetadataService } from './action-metadata.service';\nimport { MenuItemMetadataService } from './menu-item-metadata.service';\nimport { SolidIntrospectService } from './solid-introspect.service';\nimport { UserViewMetadataService } from './user-view-metadata.service';\nimport { MenuItemMetadata } from 'src/entities/menu-item-metadata.entity';\n\n@Injectable()\nexport class ViewMetadataService extends CRUDService<ViewMetadata> {\n private readonly comparableFields = [\n 'name',\n 'displayName',\n 'type',\n 'context',\n 'layout',\n 'module',\n 'model',\n ] as const;\n private readonly relationCompareFields = new Set(['module', 'model']);\n private readonly jsonCompareFields = new Set(['layout', 'context']);\n\n private normalizeJsonFieldValue(value: any): any {\n if (typeof value === 'string') {\n const trimmedValue = value.trim();\n if (\n (trimmedValue.startsWith('{') && trimmedValue.endsWith('}')) ||\n (trimmedValue.startsWith('[') && trimmedValue.endsWith(']'))\n ) {\n try {\n return this.normalizeJsonFieldValue(JSON.parse(trimmedValue));\n } catch {\n return value;\n }\n }\n return value;\n }\n\n if (Array.isArray(value)) {\n return value.map((item) => this.normalizeJsonFieldValue(item));\n }\n\n if (value && typeof value === 'object') {\n return Object.keys(value)\n .sort()\n .reduce((result, key) => {\n result[key] = this.normalizeJsonFieldValue(value[key]);\n return result;\n }, {} as Record<string, any>);\n }\n\n return value;\n }\n\n private getCanonicalJsonFieldString(value: any): string {\n return JSON.stringify(this.normalizeJsonFieldValue(value) ?? null);\n }\n\n private hasChanges(existingSolidView: ViewMetadata, updateSolidViewDto: UpdateViewMetadataDto): boolean {\n return this.comparableFields.some((key) => {\n const value = (updateSolidViewDto as any)[key];\n if (typeof value === 'undefined') {\n return false;\n }\n\n if (this.relationCompareFields.has(key)) {\n const relationValue = value as any;\n return (existingSolidView as any)[key]?.id !== relationValue?.id;\n }\n\n if (this.jsonCompareFields.has(key)) {\n return this.getCanonicalJsonFieldString((existingSolidView as any)[key]) !== this.getCanonicalJsonFieldString(value);\n }\n\n return (existingSolidView as any)[key] !== value;\n });\n }\n\n constructor(\n readonly actionMetadataService: ActionMetadataService,\n readonly menuItemMetadataService: MenuItemMetadataService,\n readonly introspectService: SolidIntrospectService,\n readonly userViewMetadataService: UserViewMetadataService,\n @InjectEntityManager()\n readonly entityManager: EntityManager,\n // @InjectRepository(ViewMetadata, 'default')\n readonly repo: ViewMetadataRepository,\n // @InjectRepository(FieldMetadata)\n // private readonly fieldMetadataRepo: Repository<FieldMetadata>,\n // @InjectRepository(ModelMetadata)\n // private readonly modelMetadataRepo: Repository<ModelMetadata>,\n @Inject(forwardRef(() => ModelMetadataRepository))\n private readonly modelMetadataRepo: ModelMetadataRepository,\n private readonly modelMetadataHelperService: ModelMetadataHelperService,\n readonly moduleRef: ModuleRef\n ) {\n super(entityManager, repo, 'viewMetadata', 'solid-core', moduleRef);\n }\n\n private readonly logger = new Logger(ViewMetadataService.name);\n\n //for locales \n private async getEntityRecordsInAllLocales(\n modelName: string,\n id: string,\n defaultEntityLocaleIdFromQuery?: string\n ): Promise<{ records: any[], defaultEntityLocaleId: string | null }> {\n const solidRegistry = await this.moduleRef.get(SolidRegistry, { strict: false });\n // const currentEntityTarget = solidRegistry.getEntityTarget(this.entityManager, classify(modelName));\n const currentEntityRepository = this.entityManager.getRepository(classify(modelName));\n\n // Case 1: Creating a new record with no defaultEntityLocaleId to clone\n if (id === 'new' && !defaultEntityLocaleIdFromQuery) {\n this.logger.debug(`Creating new record without cloning from any defaultEntityLocaleId.`);\n return { records: [], defaultEntityLocaleId: null };\n }\n\n // Case 2: Creating a new record and cloning from an existing defaultEntityLocaleId\n if (id === 'new' && defaultEntityLocaleIdFromQuery) {\n this.logger.debug(`Creating new record by cloning translations from defaultEntityLocaleId: ${defaultEntityLocaleIdFromQuery}`);\n\n const records = await currentEntityRepository.find({\n where: [\n { defaultEntityLocaleId: defaultEntityLocaleIdFromQuery },\n { id: defaultEntityLocaleIdFromQuery }\n ]\n });\n\n this.logger.debug(`Found ${records.length} cloned records for new entity.`);\n return { records, defaultEntityLocaleId: defaultEntityLocaleIdFromQuery };\n }\n\n // Case 3: Editing an existing entity\n const entityRecord = await currentEntityRepository.findOne({ where: { id } });\n\n if (!entityRecord) {\n this.logger.warn(`No entity found for id ${id}`);\n return { records: [], defaultEntityLocaleId: null };\n }\n\n const defaultLocale = await this.entityManager.getRepository(Locale).findOne({ where: { isDefault: true } });\n\n let defaultEntityLocaleId: string;\n if (entityRecord.localeName === defaultLocale?.locale) {\n defaultEntityLocaleId = entityRecord.id;\n this.logger.debug(`Editing default locale record with id ${defaultEntityLocaleId}`);\n } else {\n defaultEntityLocaleId = entityRecord.defaultEntityLocaleId;\n this.logger.debug(`Editing non-default locale record. DefaultEntityLocaleId: ${defaultEntityLocaleId}`);\n }\n\n const records = await currentEntityRepository.find({\n where: [\n { defaultEntityLocaleId: defaultEntityLocaleId },\n { id: defaultEntityLocaleId }\n ]\n });\n\n this.logger.debug(`Found ${records.length} records in all locales for existing entity.`);\n\n return { records, defaultEntityLocaleId };\n }\n\n // START: Custom Service Methods\n async getLayout(query, activeUser) {\n let { modelName, moduleName, viewType, id, populate, menuItemId, menuItemName, actionId, actionName } = query;\n\n // 1. Fetch the action based on actionId.\n const solidRequestContext = {\n activeUser: activeUser\n }\n const actionQuery = {\n populate: [\"view\"]\n }\n let action = null;\n if (actionId) {\n action = await this.actionMetadataService.findOne(actionId, actionQuery, solidRequestContext);\n }\n\n // 2. Fetch the menu based on menuItemId.\n const menuItemQuery = {\n populate: ['action', 'action.model', 'module']\n }\n let menuItem: MenuItemMetadata = null;\n if (menuItemId) {\n menuItem = await this.menuItemMetadataService.findOne(menuItemId, menuItemQuery, solidRequestContext);\n }\n\n let viewModes = [];\n const menuItemModelId = menuItem?.action?.model?.id;\n const menuItemModuleId = menuItem?.module?.id;\n const collectionViewTypes = ['card', 'list', 'kanban', 'tree'];\n if (menuItemModelId && menuItemModuleId) {\n const actionQb = await this.actionMetadataService.repo.createSecurityRuleAwareQueryBuilder('action');\n const actionsForViewModes = await actionQb\n .leftJoinAndSelect('action.model', 'model')\n .leftJoinAndSelect('action.module', 'module')\n .leftJoinAndSelect('action.view', 'view')\n .where('model.id = :modelId', { modelId: menuItemModelId })\n .andWhere('module.id = :moduleId', { moduleId: menuItemModuleId })\n .andWhere('view.type IN (:...viewTypes)', { viewTypes: collectionViewTypes })\n .getMany();\n\n const canonicalActionsByViewType = new Map();\n for (const actionItem of actionsForViewModes) {\n const resolvedViewType = actionItem.view?.type;\n if (!resolvedViewType || canonicalActionsByViewType.has(resolvedViewType)) {\n continue;\n }\n canonicalActionsByViewType.set(resolvedViewType, actionItem);\n }\n\n if (action?.view?.type && collectionViewTypes.includes(action.view.type) && action?.id) {\n canonicalActionsByViewType.set(action.view.type, action);\n }\n\n viewModes = collectionViewTypes\n .map((resolvedViewType) => canonicalActionsByViewType.get(resolvedViewType))\n .filter(Boolean)\n .map(actionItem => ({\n type: actionItem.view?.type ?? '',\n menuItemId: menuItem.id,\n menuItemName: menuItem.displayName,\n actionId: actionItem.id ?? '',\n actionName: actionItem.displayName ?? '',\n }));\n }\n\n const viewId = action?.view?.id\n // 3. Fetch the view based on module, model & view name.\n const entity = await this.repo.findOne({\n where: {\n model: { singularName: modelName },\n module: { name: moduleName },\n ...(actionId && viewId ? { id: action.view.id } : { type: viewType })\n },\n relations: {\n model: {\n userKeyField: true,\n },\n module: true,\n }\n });\n\n if (!entity) {\n throw new BadRequestException(`Unable to identify view for module: ${moduleName}, model: ${modelName} and viewType: ${viewType}`);\n }\n if (!activeUser?.sub) {\n throw new BadRequestException(`Unable to identify user for module: ${moduleName}, model: ${modelName} and viewType: ${viewType}`);\n }\n\n // 4. add action and menuItem to Entity which is our solid View\n if (actionId) {\n delete action.view;\n entity['action'] = action\n }\n if (menuItemId) {\n entity['menu'] = menuItem\n }\n\n // 5. See if we have a user specific layout for this view.\n const userLayout = await this.userViewMetadataService.repo.findOne({\n where: {\n user: { id: activeUser?.sub },\n viewMetadata: { id: entity.id },\n },\n });\n // Based on where we found the layout we are converting it from string to json.\n if (userLayout) {\n entity.layout = JSON.parse(userLayout.layout);\n } else {\n entity.layout = JSON.parse(entity.layout);\n }\n\n // 6. We are resolving the create & edit actions if specified in the layout.\n if (entity?.layout?.attrs?.createAction) {\n const actionName: string = entity.layout.attrs.createAction;\n entity.layout.attrs.createAction = await this.actionMetadataService.findOneByUserKey(actionName)\n }\n if (entity?.layout?.attrs?.editAction) {\n const actionName: string = entity.layout.attrs.editAction;\n entity.layout.attrs.editAction = await this.actionMetadataService.findOneByUserKey(actionName)\n }\n\n // 7. For form views we need to fetch the workflow field metadata if specified.\n let workflowFieldName = null;\n let workflowField = null;\n if (viewType === 'form') {\n workflowFieldName = entity.layout?.attrs?.workflowField;\n }\n\n // 8. Create an easy to use map of field metadata, rather than sending an array of fields it becomes easier to use in the frontend.\n const fields = await this.modelMetadataHelperService.loadFieldHierarchy(modelName);\n const fieldsMap = new Map<string, FieldMetadata>();\n for (let i = 0; i < fields.length; i++) {\n const field = fields[i];\n\n // We need to identify the workflowField metadata if specified. \n if (workflowFieldName && field.name === workflowFieldName) {\n workflowField = field;\n }\n\n // For fields of type relation & relationType many-to-one\n // We fetch metadata regarding the relationCoModelSingularName\n if (field.type === 'relation') {\n const relationModel = await this.modelMetadataRepo.find({\n where: {\n singularName: field.relationCoModelSingularName\n },\n relations: {\n userKeyField: true\n }\n });\n\n if (relationModel) {\n field['relationModel'] = relationModel[0];\n }\n }\n if (!fieldsMap.has(field.name)) {\n fieldsMap.set(field.name, field);\n }\n }\n\n // 9. Use the resolved workflowField to populate workflow specific metadata.\n // Check if we were able to resolve an actual workflowField.\n let solidFormViewWorkflowData = [];\n if (viewType === 'form' && workflowField) {\n // check for type of workflow field. \n // for workflowFields of type selectionStatic we simply return the key/values from field metadata AS-IS\n if (workflowField.type === 'selectionStatic') {\n solidFormViewWorkflowData = workflowField.selectionStaticValues.map(item => {\n const [value, label] = item.split(\":\");\n return { label, value };\n });\n }\n // for workflowFields of type relation.many-to-one we need to query the co-model, and return data in key/value format.\n if (workflowField.type === 'relation' && workflowField.relationType === 'many-to-one') {\n const comodelCrudService = this.introspectService.getCRUDService(workflowField.relationCoModelSingularName);\n const data = await comodelCrudService.find({ limit: 100, offset: 0, });\n const records = data.records ?? [];\n const workflowFieldMetadata = fieldsMap.get(workflowFieldName);\n const workflowFielUserkey = workflowFieldMetadata['relationModel']['userKeyField']['name'];\n\n // iterate over the comodel records extracting the label & value. \n solidFormViewWorkflowData = records.map(item => ({ 'label': item[workflowFielUserkey], 'value': item['id'] }))\n }\n }\n\n // 10. If this model supports internationalisation, we need to load the locales applicable with the id of an actual record for each locale if present.\n // This is the shape of locales that will be returned \n /**\n * [\n * {locale: 'en', displayName: 'English', isDefault: 'yes', defaultEntityLocaleId: '', entityId: '1'}, \n * {locale: 'en-IN', displayName: 'English (India)', isDefault: 'no', defaultEntityLocaleId: '1', entityId: '2'}, \n * {locale: 'en-SG', displayName: 'English (Singapore)', isDefault: 'no', defaultEntityLocaleId: '', entityId: '3'}, \n * {locale: 'fr', displayName: 'French', isDefault: 'no', defaultEntityLocaleId: '', entityId: ''}\n * ]\n */\n\n const applicableLocales: any = []\n // if (entity.model.internationalisation) {\n // const allLocales = await this.entityManager.getRepository(Locale).find({});\n\n // if (id === 'new') {\n // allLocales.forEach(locale => {\n // applicableLocales.push({\n // locale: locale.locale,\n // displayName: locale.displayName,\n // isDefault: locale.isDefault ? 'yes' : 'no',\n // defaultEntityLocaleId: null,\n // entityId: null\n // });\n // });\n // }\n // else {\n // const defaultLocale = allLocales.find(locale => locale.isDefault);\n // this.logger.debug(`Default locale is: ${defaultLocale.locale}`);\n\n // // Get hold of the repository for the current model\n // const solidRegistry = await this.moduleRef.get(SolidRegistry, { strict: false });\n // const currentEntityTarget = solidRegistry.getEntityTarget(this.entityManager, classify(modelName));\n // const currentEntityRepository = this.entityManager.getRepository(currentEntityTarget);\n\n // // We are in edit mode, the id that is being edited could be a record tagged with the default locale or it could be tagged with a non-default locale.\n // const entityRecord = await currentEntityRepository.findOne({\n // where: {\n // id: id,\n // }\n // });\n // if(entityRecord){\n // // Resolve the default entity locale id....\n // let defaultEntityLocaleId = null;\n // if (entityRecord.localeName === defaultLocale.locale) {\n // defaultEntityLocaleId = entityRecord.id;\n // this.logger.debug(`You are editing a record tagged with the default locale: ${entityRecord.localeName}.`);\n // }\n // else {\n // defaultEntityLocaleId = entityRecord.defaultEntityLocaleId;\n // this.logger.debug(`You are editing a record tagged with the non-default locale: ${entityRecord.localeName}. `);\n // }\n // this.logger.debug(`Identified default Entity Locale Id: ${defaultEntityLocaleId}`);\n\n // // Now we query for all records in the same model matching the defaultEntityLocaleId\n // // Get all records mathcing the defaultEntityLocaleId or where the id is same as the defaultEntityLocaleId\n // const entityRecordsInAllLocales = await currentEntityRepository.find({\n // where: [\n // { defaultEntityLocaleId: defaultEntityLocaleId },\n // { id: defaultEntityLocaleId }\n // ],\n // });\n // this.logger.debug(`Found ${entityRecordsInAllLocales.length} records in all locales for the defaultEntityLocaleId: ${defaultEntityLocaleId}`);\n\n // // Loop over all locales and populate the applicableLocales array\n // for (const locale of allLocales) {\n // // Find the record in the entityRecordsInAllLocales that matches the current locale\n // const matchingRecord = entityRecordsInAllLocales.find(record => record.localeName === locale.locale);\n\n // applicableLocales.push({\n // locale: locale.locale,\n // displayName: locale.displayName,\n // isDefault: locale.isDefault ? 'yes' : 'no',\n // defaultEntityLocaleId: defaultEntityLocaleId,\n // entityId: (matchingRecord ? matchingRecord.id : null)\n // });\n // }\n // }else{\n // this.logger.warn(`No record found for id: ${id} in model: ${modelName}. Cannot determine applicable locales.`);\n // }\n // }\n // }\n if (entity.model.internationalisation) {\n const defaultEntityLocaleIdFromQuery = query?.defaultEntityLocaleId;\n const { records: entityRecordsInAllLocales, defaultEntityLocaleId } =\n await this.getEntityRecordsInAllLocales(modelName, id, defaultEntityLocaleIdFromQuery);\n const allLocales = await this.entityManager.getRepository(Locale).find({});\n for (const locale of allLocales) {\n const matchingRecord = entityRecordsInAllLocales.find(record => record.localeName === locale.locale);\n applicableLocales.push({\n locale: locale.locale,\n displayName: locale.displayName,\n isDefault: locale.isDefault ? 'yes' : 'no',\n defaultEntityLocaleId: defaultEntityLocaleId,\n entityId: matchingRecord ? matchingRecord.id : null\n });\n }\n }\n\n const r = {\n 'solidView': entity,\n 'solidFieldsMetadata': Object.fromEntries(fieldsMap),\n 'solidFormViewWorkflowData': solidFormViewWorkflowData,\n 'applicableLocales': applicableLocales,\n 'viewModes': viewModes\n }\n\n return r;\n }\n\n private async loadFieldHierarchy(modelName: any) {\n const model = await this.modelMetadataRepo.findOne({\n where: {\n singularName: modelName,\n },\n relations: {\n fields: true,\n parentModel: {\n fields: true,\n }\n }\n });\n const fields = [];\n if (model) {\n // Add the fields of the current model\n fields.push(...model.fields);\n\n // Add the fields of the parent model\n if (model.parentModel) {\n fields.push(...model.parentModel.fields);\n }\n }\n return fields;\n }\n\n async findOneByUserKey(name: string, relations = {}) {\n const entity = await this.repo.findOne({\n where: {\n name: name,\n },\n relations: relations,\n });\n return entity;\n }\n\n async upsert(updateSolidViewDto: UpdateViewMetadataDto) {\n // First check if module already exists using name\n const existingSolidView = await this.findOneByUserKey(updateSolidViewDto.name, {\n module: true,\n model: true,\n });\n\n // if found\n if (existingSolidView) {\n const hasChanges = this.hasChanges(existingSolidView, updateSolidViewDto);\n\n if (!hasChanges) {\n this.logger.debug(`Skipping view upsert for ${updateSolidViewDto.name}; no changes detected.`);\n return existingSolidView;\n }\n\n const updatedSolidViewDto = { ...existingSolidView, ...updateSolidViewDto };\n return this.repo.save(updatedSolidViewDto);\n }\n // if not found - create new \n else {\n const viewData = this.repo.create(updateSolidViewDto);\n return this.repo.save(viewData);\n }\n }\n\n async createIfNotPresent(updateSolidViewDto: UpdateViewMetadataDto) {\n // First check if module already exists using name\n const existingSolidView = await this.findOneByUserKey(updateSolidViewDto.name);\n\n // if found\n if (existingSolidView) {\n }\n // if not found - create new \n else {\n const viewData = this.repo.create(updateSolidViewDto);\n return this.repo.save(viewData);\n }\n }\n\n // END: Custom Service Methods\n\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"solid-core.module.d.ts","sourceRoot":"","sources":["../src/solid-core.module.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,CAAC;AAChB,OAAO,EAAU,kBAAkB,EAAU,UAAU,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"solid-core.module.d.ts","sourceRoot":"","sources":["../src/solid-core.module.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,CAAC;AAChB,OAAO,EAAU,kBAAkB,EAAU,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAoYhF,qBAmea,eAAgB,YAAW,UAAU;IAChD,SAAS,CAAC,QAAQ,EAAE,kBAAkB;CAQvC"}
|
|
@@ -55,6 +55,8 @@ const model_metadata_controller_1 = require("./controllers/model-metadata.contro
|
|
|
55
55
|
const module_metadata_explorer_controller_1 = require("./controllers/module-metadata-explorer.controller");
|
|
56
56
|
const module_metadata_controller_1 = require("./controllers/module-metadata.controller");
|
|
57
57
|
const module_package_controller_1 = require("./controllers/module-package.controller");
|
|
58
|
+
const datasource_management_controller_1 = require("./controllers/datasource-management.controller");
|
|
59
|
+
const datasource_introspection_controller_1 = require("./controllers/datasource-introspection.controller");
|
|
58
60
|
const test_controller_1 = require("./controllers/test.controller");
|
|
59
61
|
const field_metadata_entity_1 = require("./entities/field-metadata.entity");
|
|
60
62
|
const list_of_values_entity_1 = require("./entities/list-of-values.entity");
|
|
@@ -71,6 +73,8 @@ const pseudo_foreign_key_selection_provider_service_1 = require("./services/sele
|
|
|
71
73
|
const module_metadata_seeder_service_1 = require("./seeders/module-metadata-seeder.service");
|
|
72
74
|
const module_test_data_service_1 = require("./seeders/module-test-data.service");
|
|
73
75
|
const crud_helper_service_1 = require("./services/crud-helper.service");
|
|
76
|
+
const datasource_management_service_1 = require("./services/datasource-management.service");
|
|
77
|
+
const datasource_introspection_service_1 = require("./services/datasource-introspection.service");
|
|
74
78
|
const field_metadata_service_1 = require("./services/field-metadata.service");
|
|
75
79
|
const dashboard_runtime_service_1 = require("./services/dashboard-runtime.service");
|
|
76
80
|
const list_of_values_service_1 = require("./services/list-of-values.service");
|
|
@@ -388,6 +392,9 @@ const dashboard_user_layout_entity_1 = require("./entities/dashboard-user-layout
|
|
|
388
392
|
const dashboard_user_layout_service_1 = require("./services/dashboard-user-layout.service");
|
|
389
393
|
const dashboard_user_layout_controller_1 = require("./controllers/dashboard-user-layout.controller");
|
|
390
394
|
const dashboard_user_layout_repository_1 = require("./repositories/dashboard-user-layout.repository");
|
|
395
|
+
const mssql_datasource_introspection_provider_service_1 = require("./services/datasource-introspection/mssql-datasource-introspection-provider.service");
|
|
396
|
+
const mysql_datasource_introspection_provider_service_1 = require("./services/datasource-introspection/mysql-datasource-introspection-provider.service");
|
|
397
|
+
const postgres_datasource_introspection_provider_service_1 = require("./services/datasource-introspection/postgres-datasource-introspection-provider.service");
|
|
391
398
|
let SolidCoreModule = class SolidCoreModule {
|
|
392
399
|
configure(consumer) {
|
|
393
400
|
consumer
|
|
@@ -473,6 +480,8 @@ exports.SolidCoreModule = SolidCoreModule = __decorate([
|
|
|
473
480
|
export_transaction_controller_1.ExportTransactionController,
|
|
474
481
|
field_metadata_controller_1.FieldMetadataController,
|
|
475
482
|
dashboard_controller_1.DashboardController,
|
|
483
|
+
datasource_management_controller_1.DatasourceManagementController,
|
|
484
|
+
datasource_introspection_controller_1.DatasourceIntrospectionController,
|
|
476
485
|
google_authentication_controller_1.GoogleAuthenticationController,
|
|
477
486
|
facebook_authentication_controller_1.FacebookAuthenticationController,
|
|
478
487
|
microsoft_authentication_controller_1.MicrosoftAuthenticationController,
|
|
@@ -536,6 +545,8 @@ exports.SolidCoreModule = SolidCoreModule = __decorate([
|
|
|
536
545
|
useClass: http_exception_filter_1.HttpExceptionFilter,
|
|
537
546
|
},
|
|
538
547
|
module_metadata_service_1.ModuleMetadataService,
|
|
548
|
+
datasource_management_service_1.DatasourceManagementService,
|
|
549
|
+
datasource_introspection_service_1.DatasourceIntrospectionService,
|
|
539
550
|
module_metadata_explorer_service_1.ModuleMetadataExplorerService,
|
|
540
551
|
module_metadata_helper_service_1.ModuleMetadataHelperService,
|
|
541
552
|
module_package_service_1.ModulePackageService,
|
|
@@ -729,7 +740,11 @@ exports.SolidCoreModule = SolidCoreModule = __decorate([
|
|
|
729
740
|
export_transaction_service_1.ExportTransactionService,
|
|
730
741
|
excel_service_1.ExcelService,
|
|
731
742
|
csv_service_1.CsvService,
|
|
743
|
+
datasource_management_service_1.DatasourceManagementService,
|
|
732
744
|
dashboard_runtime_service_1.DashboardRuntimeService,
|
|
745
|
+
mssql_datasource_introspection_provider_service_1.MssqlDatasourceIntrospectionProviderService,
|
|
746
|
+
mysql_datasource_introspection_provider_service_1.MysqlDatasourceIntrospectionProviderService,
|
|
747
|
+
postgres_datasource_introspection_provider_service_1.PostgresDatasourceIntrospectionProviderService,
|
|
733
748
|
import_transaction_service_1.ImportTransactionService,
|
|
734
749
|
import_transaction_error_log_service_1.ImportTransactionErrorLogService,
|
|
735
750
|
created_by_updated_by_subscriber_1.CreatedByUpdatedBySubscriber,
|
|
@@ -827,6 +842,7 @@ exports.SolidCoreModule = SolidCoreModule = __decorate([
|
|
|
827
842
|
model_metadata_helper_service_1.ModelMetadataHelperService,
|
|
828
843
|
model_metadata_service_1.ModelMetadataService,
|
|
829
844
|
module_metadata_service_1.ModuleMetadataService,
|
|
845
|
+
datasource_introspection_service_1.DatasourceIntrospectionService,
|
|
830
846
|
module_metadata_explorer_service_1.ModuleMetadataExplorerService,
|
|
831
847
|
module_package_service_1.ModulePackageService,
|
|
832
848
|
mq_message_queue_service_1.MqMessageQueueService,
|