@solidstarters/solid-core 1.2.169 → 1.2.170

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.
@@ -28,7 +28,7 @@ let HttpExceptionFilter = HttpExceptionFilter_1 = class HttpExceptionFilter {
28
28
  const explicitStatus = isHttp ? exception.getStatus() : undefined;
29
29
  const code = this.errorMapper.mapException(exception);
30
30
  const defaultStatus = this.errorMapper.getHttpStatus(code);
31
- const message = code === 'unknown-error' ? `${exception?.message}` : this.errorMapper.getMessage(code);
31
+ const message = code === 'solidx-unknown-error' ? `${exception?.message}` : this.errorMapper.getMessage(code);
32
32
  const status = explicitStatus ?? defaultStatus ?? 500;
33
33
  this.logger.error(`[${status} ${logging_interceptor_1.HttpStatusCodeMessages[status] || 'Internal Server Error'}] ${request?.method} ${request?.url} - ${exception?.message || message} [code=${code}]`);
34
34
  if (exception?.stack) {
@@ -1 +1 @@
1
- {"version":3,"file":"http-exception.filter.js","sourceRoot":"","sources":["../../src/filters/http-exception.filter.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,2CAOwB;AAExB,6EAA6E;AAC7E,0EAAsE;AAM/D,IAAM,mBAAmB,2BAAzB,MAAM,mBAAmB;IAG5B,YAA6B,WAA+B;QAA/B,gBAAW,GAAX,WAAW,CAAoB;QAF3C,WAAM,GAAG,IAAI,eAAM,CAAC,qBAAmB,CAAC,IAAI,CAAC,CAAC;QAG3D,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACzD,CAAC;IAED,KAAK,CAAC,SAAc,EAAE,IAAmB;QACrC,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QAChC,MAAM,QAAQ,GAAG,GAAG,CAAC,WAAW,EAAY,CAAC;QAC7C,MAAM,OAAO,GAAG,GAAG,CAAC,UAAU,EAAW,CAAC;QAE1C,MAAM,MAAM,GAAG,SAAS,YAAY,sBAAa,CAAC;QAClD,MAAM,cAAc,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nB,mBAAmB;IAF/B,IAAA,cAAK,GAAE;IACP,IAAA,mBAAU,GAAE;qCAIiC,yCAAkB;GAHnD,mBAAmB,CAiD/B","sourcesContent":["// src/common/filters/http-exception.filter.ts\nimport {\n ExceptionFilter,\n Catch,\n ArgumentsHost,\n Logger,\n Injectable,\n HttpException,\n} from '@nestjs/common';\nimport { Response, Request } from 'express';\nimport { HttpStatusCodeMessages } from '../interceptors/logging.interceptor';\nimport { ErrorMapperService } from 'src/helpers/error-mapper.service';\nimport { ErrorCode } from 'src/interfaces';\n\n\n@Catch()\n@Injectable()\nexport class HttpExceptionFilter implements ExceptionFilter {\n private readonly logger = new Logger(HttpExceptionFilter.name);\n\n constructor(private readonly errorMapper: ErrorMapperService) {\n this.logger.debug('HttpExceptionFilter initialized');\n }\n\n catch(exception: any, host: ArgumentsHost) {\n const ctx = host.switchToHttp();\n const response = ctx.getResponse<Response>();\n const request = ctx.getRequest<Request>();\n\n const isHttp = exception instanceof HttpException;\n const explicitStatus = isHttp ? exception.getStatus() : undefined;\n\n // Canonical code + static message\n const code: ErrorCode = this.errorMapper.mapException(exception);\n const defaultStatus = this.errorMapper.getHttpStatus(code);\n const message = code === 'unknown-error' ? `${exception?.message}` : this.errorMapper.getMessage(code);\n\n const status = explicitStatus ?? defaultStatus ?? 500;\n\n // Logging\n this.logger.error(\n `[${status} ${HttpStatusCodeMessages[status] || 'Internal Server Error'}] ${request?.method} ${request?.url} - ${exception?.message || message} [code=${code}]`,\n );\n if (exception?.stack) {\n this.logger.error(exception.stack);\n }\n\n // Preserve any extra data the exception carried (optional)\n const extra =\n (isHttp && (exception.getResponse?.() as any)) ??\n exception?.response ??\n {};\n\n // Keep your legacy shape; add canonical code\n response.status(status).json({\n statusCode: status,\n statusCodeMessage: HttpStatusCodeMessages[status] || 'Internal Server Error',\n // Keeping this for backward compatibility..\n message: message,\n errorCode: code,\n error: message,\n // We can make this conditional based on whether we are running in prod mode or dev mode...\n // errorStack: exception.stack,\n data: extra,\n });\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B,KAAK,OAAO,EAAE,MAAM,IAAI,OAAO,EAAE,GAAG,MAAM,SAAS,EAAE,OAAO,IAAI,OAAO,UAAU,IAAI,GAAG,CAClK,CAAC;QACF,IAAI,SAAS,EAAE,KAAK,EAAE,CAAC;YACnB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACvC,CAAC;QAGD,MAAM,KAAK,GACP,CAAC,MAAM,IAAK,SAAS,CAAC,WAAW,EAAE,EAAU,CAAC;YAC9C,SAAS,EAAE,QAAQ;YACnB,EAAE,CAAC;QAGP,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC;YACzB,UAAU,EAAE,MAAM;YAClB,iBAAiB,EAAE,4CAAsB,CAAC,MAAM,CAAC,IAAI,uBAAuB;YAE5E,OAAO,EAAE,OAAO;YAChB,SAAS,EAAE,IAAI;YACf,KAAK,EAAE,OAAO;YAGd,IAAI,EAAE,KAAK;SACd,CAAC,CAAC;IACP,CAAC;CACJ,CAAA;AAjDY,kDAAmB;8BAAnB,mBAAmB;IAF/B,IAAA,cAAK,GAAE;IACP,IAAA,mBAAU,GAAE;qCAIiC,yCAAkB;GAHnD,mBAAmB,CAiD/B","sourcesContent":["// src/common/filters/http-exception.filter.ts\nimport {\n ExceptionFilter,\n Catch,\n ArgumentsHost,\n Logger,\n Injectable,\n HttpException,\n} from '@nestjs/common';\nimport { Response, Request } from 'express';\nimport { HttpStatusCodeMessages } from '../interceptors/logging.interceptor';\nimport { ErrorMapperService } from 'src/helpers/error-mapper.service';\nimport { ErrorCode } from 'src/interfaces';\n\n\n@Catch()\n@Injectable()\nexport class HttpExceptionFilter implements ExceptionFilter {\n private readonly logger = new Logger(HttpExceptionFilter.name);\n\n constructor(private readonly errorMapper: ErrorMapperService) {\n this.logger.debug('HttpExceptionFilter initialized');\n }\n\n catch(exception: any, host: ArgumentsHost) {\n const ctx = host.switchToHttp();\n const response = ctx.getResponse<Response>();\n const request = ctx.getRequest<Request>();\n\n const isHttp = exception instanceof HttpException;\n const explicitStatus = isHttp ? exception.getStatus() : undefined;\n\n // Canonical code + static message\n const code: ErrorCode = this.errorMapper.mapException(exception);\n const defaultStatus = this.errorMapper.getHttpStatus(code);\n const message = code === 'solidx-unknown-error' ? `${exception?.message}` : this.errorMapper.getMessage(code);\n\n const status = explicitStatus ?? defaultStatus ?? 500;\n\n // Logging\n this.logger.error(\n `[${status} ${HttpStatusCodeMessages[status] || 'Internal Server Error'}] ${request?.method} ${request?.url} - ${exception?.message || message} [code=${code}]`,\n );\n if (exception?.stack) {\n this.logger.error(exception.stack);\n }\n\n // Preserve any extra data the exception carried (optional)\n const extra =\n (isHttp && (exception.getResponse?.() as any)) ??\n exception?.response ??\n {};\n\n // Keep your legacy shape; add canonical code\n response.status(status).json({\n statusCode: status,\n statusCodeMessage: HttpStatusCodeMessages[status] || 'Internal Server Error',\n // Keeping this for backward compatibility..\n message: message,\n errorCode: code,\n error: message,\n // We can make this conditional based on whether we are running in prod mode or dev mode...\n // errorStack: exception.stack,\n data: extra,\n });\n }\n}"]}
@@ -1 +1 @@
1
- {"version":3,"file":"error-mapper.service.d.ts","sourceRoot":"","sources":["../../src/helpers/error-mapper.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,SAAS,EAA4C,MAAM,gBAAgB,CAAC;AAmCrF,qBACa,kBAAkB;IAGf,OAAO,CAAC,QAAQ,CAAC,aAAa;IAF1C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAuC;gBAEjC,aAAa,EAAE,aAAa;IAGzD,YAAY,CAAC,GAAG,EAAE,OAAO,GAAG,SAAS;IAMrC,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS;IAMtD,UAAU,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM;IAMnC,aAAa,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM;IAMtC,OAAO,CAAC,SAAS;IAajB,OAAO,CAAC,UAAU;IAiBlB,OAAO,CAAC,iBAAiB;IAgBzB,OAAO,CAAC,YAAY;IAQpB,OAAO,CAAC,gBAAgB;IAyBxB,OAAO,CAAC,iBAAiB;CAO5B"}
1
+ {"version":3,"file":"error-mapper.service.d.ts","sourceRoot":"","sources":["../../src/helpers/error-mapper.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,SAAS,EAA4C,MAAM,gBAAgB,CAAC;AACrF,qBACa,kBAAkB;IAGf,OAAO,CAAC,QAAQ,CAAC,aAAa;IAF1C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAuC;gBAEjC,aAAa,EAAE,aAAa;IAGzD,YAAY,CAAC,GAAG,EAAE,OAAO,GAAG,SAAS;IAMrC,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS;IAMtD,UAAU,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM;IAMnC,aAAa,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM;IAMtC,OAAO,CAAC,SAAS;IAajB,OAAO,CAAC,UAAU;IAiBlB,OAAO,CAAC,iBAAiB;IAgBzB,OAAO,CAAC,YAAY;IAQpB,OAAO,CAAC,gBAAgB;IAyBxB,OAAO,CAAC,iBAAiB;CAO5B"}
@@ -45,7 +45,7 @@ let ErrorMapperService = ErrorMapperService_1 = class ErrorMapperService {
45
45
  this.logger.warn(`Error rule threw in match(): code=${rule.code} provider? — ${e}`);
46
46
  }
47
47
  }
48
- return 'unknown-error';
48
+ return 'solidx-unknown-error';
49
49
  }
50
50
  lookupMeta(code) {
51
51
  const rules = this.getAllRulesSorted();
@@ -1 +1 @@
1
- {"version":3,"file":"error-mapper.service.js","sourceRoot":"","sources":["../../src/helpers/error-mapper.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,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CAAC,WAAW,EAAE,CAAC;YAC9D,CAAC;YAAC,MAAM,CAAC;YAET,CAAC;QACL,CAAC;QAED,OAAO,MAAM,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;IAC3C,CAAC;IAEO,iBAAiB,CAAC,GAAY;QAClC,IAAI,CAAC;YACD,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;QAC/B,CAAC;QAAC,MAAM,CAAC;YACL,OAAO,EAAE,CAAC;QACd,CAAC;IACL,CAAC;CACJ,CAAA;AApHY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,mBAAU,GAAE;qCAImC,8BAAa;GAHhD,kBAAkB,CAoH9B","sourcesContent":["import { Injectable, Logger } from '@nestjs/common';\nimport { SolidRegistry } from 'src/helpers/solid-registry';\nimport { ErrorCode, ErrorMeta, ErrorRule, IErrorCodeProvider } from 'src/interfaces';\n\n// export const ERROR_CODES = [\n// 'db-duplicate-key',\n// 'db-foreign-key-error',\n// 'solidx-mcp-server-unavailable',\n// 'unknown-error',\n// ] as const;\n\n// export type ErrorCode = typeof ERROR_CODES[number];\n\n// type ErrorMeta = {\n// message: string;\n// httpStatus?: number;\n// };\n\n// const ERROR_MESSAGES: Record<ErrorCode, ErrorMeta> = {\n// 'db-duplicate-key': {\n// message: 'Duplicate key violation. A record with these values already exists.',\n// httpStatus: 409,\n// },\n// 'db-foreign-key-error': {\n// message: 'Foreign key constraint prevents this operation due to related records.',\n// httpStatus: 409,\n// },\n// 'solidx-mcp-server-unavailable': {\n// message: 'SolidX MCP server is unreachable. Please verify the MCP endpoint.',\n// httpStatus: 503,\n// },\n// 'unknown-error': {\n// message: 'An unexpected error occurred.',\n// httpStatus: 500,\n// },\n// };\n\n@Injectable()\nexport class ErrorMapperService {\n private readonly logger = new Logger(ErrorMapperService.name);\n\n constructor(private readonly solidRegistry: SolidRegistry) { }\n\n /** Map an exception object (or string) to a canonical ErrorCode */\n mapException(exc: unknown): ErrorCode {\n const combined = this.combineErrorText(exc);\n return this.matchCode(combined);\n }\n\n /** Map plain message/trace to ErrorCode */\n mapMessage(message: string, trace?: string): ErrorCode {\n const combined = `${message ?? ''}\\n${trace ?? ''}`.toLowerCase();\n return this.matchCode(combined);\n }\n\n /** Get static message for a given code */\n getMessage(code: ErrorCode): string {\n const meta = this.lookupMeta(code);\n return (meta ?? { message: 'An unexpected error occurred.' }).message;\n }\n\n /** Get default HTTP status for a code (falls back to 500) */\n getHttpStatus(code: ErrorCode): number {\n const meta = this.lookupMeta(code);\n return meta?.httpStatus ?? 500;\n }\n\n // ---- internal helpers ----\n private matchCode(combined: string): ErrorCode {\n const rules = this.getAllRulesSorted();\n for (const rule of rules) {\n try {\n if (rule.match(combined)) return rule.code;\n } catch (e) {\n // Defensive: bad provider shouldn't crash mapping\n this.logger.warn(`Error rule threw in match(): code=${rule.code} provider? — ${e}`);\n }\n }\n return 'unknown-error';\n }\n\n private lookupMeta(code: ErrorCode): ErrorMeta | undefined {\n // Prefer the first rule with that code\n const rules = this.getAllRulesSorted();\n const rule = rules.find((r) => r.code === code);\n if (rule?.meta) return rule.meta;\n\n // Optional: ask providers directly if they implement resolve()\n const providers = this.getProviders();\n for (const p of providers) {\n if (p.resolve) {\n const meta = p.resolve(code);\n if (meta) return meta;\n }\n }\n return undefined;\n }\n\n private getAllRulesSorted(): ReadonlyArray<ErrorRule> {\n const providers = this.getProviders();\n const all: ErrorRule[] = [];\n for (const p of providers) {\n try {\n const rules = p.rules() ?? [];\n // Optional: namespace collision check can be added here if desired\n all.push(...rules);\n } catch (e) {\n this.logger.warn(`ErrorCodeProvider.rules() failed for ${p.name?.()}: ${e}`);\n }\n }\n // Sort by priority desc; default 0\n return all.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));\n }\n\n private getProviders(): IErrorCodeProvider[] {\n // convert InstanceWrapper → instance\n return this.solidRegistry\n .getErrorCodeProviders()\n .map((w) => w.instance)\n .filter(Boolean) as IErrorCodeProvider[];\n }\n\n private combineErrorText(exc: unknown): string {\n if (typeof exc === 'string') return exc.toLowerCase();\n\n if (exc instanceof Error) {\n const message = exc.message ?? '';\n const stack = exc.stack ?? '';\n return `${message}\\n${stack}`.toLowerCase();\n }\n\n if (exc && typeof exc === 'object') {\n try {\n const obj = exc as Record<string, unknown>;\n const msg = String(obj.message ?? (obj as any)['Message'] ?? '');\n const name = String(obj.name ?? (obj as any)['__type'] ?? '');\n const stack = String((obj as any).stack ?? '');\n const json = this.safeJsonStringify(obj);\n return `${name}\\n${msg}\\n${stack}\\n${json}`.toLowerCase();\n } catch {\n // ignore\n }\n }\n\n return String(exc ?? '').toLowerCase();\n }\n\n private safeJsonStringify(obj: unknown): string {\n try {\n return JSON.stringify(obj);\n } catch {\n return '';\n }\n }\n}"]}
1
+ {"version":3,"file":"error-mapper.service.js","sourceRoot":"","sources":["../../src/helpers/error-mapper.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAoD;AACpD,qDAA2D;AAGpD,IAAM,kBAAkB,0BAAxB,MAAM,kBAAkB;IAG3B,YAA6B,aAA4B;QAA5B,kBAAa,GAAb,aAAa,CAAe;QAFxC,WAAM,GAAG,IAAI,eAAM,CAAC,oBAAkB,CAAC,IAAI,CAAC,CAAC;IAED,CAAC;IAG9D,YAAY,CAAC,GAAY;QACrB,MAAM,QAAQ,GAAG,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;QAC5C,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IACpC,CAAC;IAGD,UAAU,CAAC,OAAe,EAAE,KAAc;QACtC,MAAM,QAAQ,GAAG,GAAG,OAAO,IAAI,EAAE,KAAK,KAAK,IAAI,EAAE,EAAE,CAAC,WAAW,EAAE,CAAC;QAClE,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IACpC,CAAC;IAGD,UAAU,CAAC,IAAe;QACtB,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,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,WAAW,EAAE,CAAC;QAChD,CAAC;QAED,IAAI,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;YACjC,IAAI,CAAC;gBACD,MAAM,GAAG,GAAG,GAA8B,CAAC;gBAC3C,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,IAAK,GAAW,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC;gBACjE,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,IAAK,GAAW,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;gBAC9D,MAAM,KAAK,GAAG,MAAM,CAAE,GAAW,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;gBAC/C,MAAM,IAAI,GAAG,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC;gBACzC,OAAO,GAAG,IAAI,KAAK,GAAG,KAAK,KAAK,KAAK,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;YAC9D,CAAC;YAAC,MAAM,CAAC;YAET,CAAC;QACL,CAAC;QAED,OAAO,MAAM,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;IAC3C,CAAC;IAEO,iBAAiB,CAAC,GAAY;QAClC,IAAI,CAAC;YACD,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;QAC/B,CAAC;QAAC,MAAM,CAAC;YACL,OAAO,EAAE,CAAC;QACd,CAAC;IACL,CAAC;CACJ,CAAA;AApHY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,mBAAU,GAAE;qCAImC,8BAAa;GAHhD,kBAAkB,CAoH9B","sourcesContent":["import { Injectable, Logger } from '@nestjs/common';\nimport { SolidRegistry } from 'src/helpers/solid-registry';\nimport { ErrorCode, ErrorMeta, ErrorRule, IErrorCodeProvider } from 'src/interfaces';\n@Injectable()\nexport class ErrorMapperService {\n private readonly logger = new Logger(ErrorMapperService.name);\n\n constructor(private readonly solidRegistry: SolidRegistry) { }\n\n /** Map an exception object (or string) to a canonical ErrorCode */\n mapException(exc: unknown): ErrorCode {\n const combined = this.combineErrorText(exc);\n return this.matchCode(combined);\n }\n\n /** Map plain message/trace to ErrorCode */\n mapMessage(message: string, trace?: string): ErrorCode {\n const combined = `${message ?? ''}\\n${trace ?? ''}`.toLowerCase();\n return this.matchCode(combined);\n }\n\n /** Get static message for a given code */\n getMessage(code: ErrorCode): string {\n const meta = this.lookupMeta(code);\n return (meta ?? { message: 'An unexpected error occurred.' }).message;\n }\n\n /** Get default HTTP status for a code (falls back to 500) */\n getHttpStatus(code: ErrorCode): number {\n const meta = this.lookupMeta(code);\n return meta?.httpStatus ?? 500;\n }\n\n // ---- internal helpers ----\n private matchCode(combined: string): ErrorCode {\n const rules = this.getAllRulesSorted();\n for (const rule of rules) {\n try {\n if (rule.match(combined)) return rule.code;\n } catch (e) {\n // Defensive: bad provider shouldn't crash mapping\n this.logger.warn(`Error rule threw in match(): code=${rule.code} provider? — ${e}`);\n }\n }\n return 'solidx-unknown-error';\n }\n\n private lookupMeta(code: ErrorCode): ErrorMeta | undefined {\n // Prefer the first rule with that code\n const rules = this.getAllRulesSorted();\n const rule = rules.find((r) => r.code === code);\n if (rule?.meta) return rule.meta;\n\n // Optional: ask providers directly if they implement resolve()\n const providers = this.getProviders();\n for (const p of providers) {\n if (p.resolve) {\n const meta = p.resolve(code);\n if (meta) return meta;\n }\n }\n return undefined;\n }\n\n private getAllRulesSorted(): ReadonlyArray<ErrorRule> {\n const providers = this.getProviders();\n const all: ErrorRule[] = [];\n for (const p of providers) {\n try {\n const rules = p.rules() ?? [];\n // Optional: namespace collision check can be added here if desired\n all.push(...rules);\n } catch (e) {\n this.logger.warn(`ErrorCodeProvider.rules() failed for ${p.name?.()}: ${e}`);\n }\n }\n // Sort by priority desc; default 0\n return all.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));\n }\n\n private getProviders(): IErrorCodeProvider[] {\n // convert InstanceWrapper → instance\n return this.solidRegistry\n .getErrorCodeProviders()\n .map((w) => w.instance)\n .filter(Boolean) as IErrorCodeProvider[];\n }\n\n private combineErrorText(exc: unknown): string {\n if (typeof exc === 'string') return exc.toLowerCase();\n\n if (exc instanceof Error) {\n const message = exc.message ?? '';\n const stack = exc.stack ?? '';\n return `${message}\\n${stack}`.toLowerCase();\n }\n\n if (exc && typeof exc === 'object') {\n try {\n const obj = exc as Record<string, unknown>;\n const msg = String(obj.message ?? (obj as any)['Message'] ?? '');\n const name = String(obj.name ?? (obj as any)['__type'] ?? '');\n const stack = String((obj as any).stack ?? '');\n const json = this.safeJsonStringify(obj);\n return `${name}\\n${msg}\\n${stack}\\n${json}`.toLowerCase();\n } catch {\n // ignore\n }\n }\n\n return String(exc ?? '').toLowerCase();\n }\n\n private safeJsonStringify(obj: unknown): string {\n try {\n return JSON.stringify(obj);\n } catch {\n return '';\n }\n }\n}"]}
@@ -1 +1 @@
1
- {"version":3,"file":"model-metadata-helper.service.js","sourceRoot":"","sources":["../../src/helpers/model-metadata-helper.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAEA,2CAAoD;AACpD,qDAAiD;AACjD,qCAAyC;AACzC,6CAAmD;AACnD,6EAAmE;AAG5D,IAAM,0BAA0B,kCAAhC,MAAM,0BAA0B;IAGnC,YAA6B,QAAuB,EAEhD,iBAA6D;QAFpC,aAAQ,GAAR,QAAQ,CAAe;QAE/B,sBAAiB,GAAjB,iBAAiB,CAA2B;QAJhD,WAAM,GAAG,IAAI,eAAM,CAAC,4BAA0B,CAAC,IAAI,CAAC,CAAC;IAMtE,CAAC;IAED,uBAAuB;QACnB,MAAM,oBAAoB,GAAG;YACzB;gBACI,IAAI,EAAE,IAAI;gBACV,WAAW,EAAE,IAAI;gBACjB,IAAI,EAAE,KAAK;gBACX,OAAO,EAAE,QAAQ;gBACjB,QAAQ,EAAE,IAAI;aACjB;YACD;gBACI,IAAI,EAAE,WAAW;gBACjB,WAAW,EAAE,YAAY;gBACzB,IAA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AAG,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;YAC7C,CAAC;QACL,CAAC;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ,CAAA;AA/HY,gEAA0B;qCAA1B,0BAA0B;IADtC,IAAA,mBAAU,GAAE;IAKJ,WAAA,IAAA,0BAAgB,EAAC,qCAAa,CAAC,CAAA;qCADG,8BAAa;QAEZ,oBAAU;GALzC,0BAA0B,CA+HtC","sourcesContent":["// Return the system fields metadata for a model\n\nimport { Injectable, Logger } from \"@nestjs/common\";\nimport { SolidRegistry } from \"./solid-registry\";\nimport { In, Repository } from \"typeorm\";\nimport { InjectRepository } from \"@nestjs/typeorm\";\nimport { ModelMetadata } from \"src/entities/model-metadata.entity\";\n\n@Injectable()\nexport class ModelMetadataHelperService {\n private readonly logger = new Logger(ModelMetadataHelperService.name);\n\n constructor(private readonly registry: SolidRegistry,\n @InjectRepository(ModelMetadata)\n private readonly modelMetadataRepo: Repository<ModelMetadata>,\n ) {\n }\n\n getSystemFieldsMetadata(): any[] {\n const systemFieldsMetadata = [\n {\n name: \"id\",\n displayName: \"Id\",\n type: \"int\",\n ormType: \"bigint\",\n isSystem: true,\n },\n {\n name: \"createdAt\",\n displayName: \"Created At\",\n type: \"datetime\",\n ormType: \"timestamp\",\n isSystem: true,\n },\n {\n name: \"updatedAt\",\n displayName: \"Updated At\",\n type: \"datetime\",\n ormType: \"timestamp\",\n isSystem: true,\n },\n {\n name: \"deletedAt\",\n displayName: \"Deleted At\",\n type: \"datetime\",\n ormType: \"timestamp\",\n isSystem: true,\n },\n {\n name: \"deletedTracker\",\n displayName: \"Deleted Tracker\",\n type: \"shortText\",\n ormType: \"varchar\",\n isSystem: true,\n },\n {\n name: \"publishedAt\",\n displayName: \"Published At\",\n type: \"datetime\",\n ormType: \"timestamp\",\n isSystem: true,\n },\n {\n name: \"localeName\",\n displayName: \"Locale\",\n type: \"shortText\",\n ormType: \"varchar\",\n isSystem: true,\n },\n {\n name: \"defaultEntityLocaleId\",\n displayName: \"Default Entity Locale Id\",\n type: \"int\",\n ormType: \"integer\",\n isSystem: true,\n },\n {\n name: \"createdBy\",\n displayName: \"Created By\",\n type: \"relation\",\n ormType: \"integer\",\n isSystem: true,\n relationType: \"many-to-one\",\n relationCoModelSingularName: \"user\",\n relationCreateInverse: false,\n relationCascade: \"restrict\",\n relationModelModuleName: \"solid-core\"\n },\n {\n name: \"updatedBy\",\n displayName: \"Updated By\",\n type: \"relation\",\n ormType: \"integer\",\n isSystem: true,\n relationType: \"many-to-one\",\n relationCoModelSingularName: \"user\",\n relationCreateInverse: false,\n relationCascade: \"restrict\",\n relationModelModuleName: \"solid-core\"\n },\n ]\n\n // Do an additional check and add a warning if the common entity keys and system field metadata keys don't match exactly\n const commonEntityKeys = this.registry.getCommonEntityKeys();\n const systemFieldNames = systemFieldsMetadata.map(field => field.name);\n const missingKeys = commonEntityKeys.filter(key => !systemFieldNames.includes(key));\n if (missingKeys.length > 0) {\n this.logger.warn(`Missing system fields metadata for common entity keys: ${missingKeys.join(', ')}`);\n }\n return systemFieldsMetadata;\n }\n\n 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}"]}
1
+ {"version":3,"file":"model-metadata-helper.service.js","sourceRoot":"","sources":["../../src/helpers/model-metadata-helper.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAEA,2CAAoD;AACpD,qDAAiD;AACjD,qCAAyC;AACzC,6CAAmD;AACnD,6EAAmE;AAG5D,IAAM,0BAA0B,kCAAhC,MAAM,0BAA0B;IAGnC,YAA6B,QAAuB,EAEhD,iBAA6D;QAFpC,aAAQ,GAAR,QAAQ,CAAe;QAE/B,sBA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;gBACH,YAAY,EAAE,SAAS;aAC1B;YACD,SAAS,EAAE;gBACP,MAAM,EAAE,IAAI;gBACZ,WAAW,EAAE;oBACT,MAAM,EAAE,IAAI;iBACf;aACJ;SACJ,CAAC,CAAC;QACH,MAAM,MAAM,GAAU,EAAE,CAAC;QACzB,IAAI,KAAK,EAAE,CAAC;YAER,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;YAG7B,IAAI,KAAK,CAAC,WAAW,EAAE,CAAC;gBACpB,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;YAC7C,CAAC;QACL,CAAC;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ,CAAA;AA/HY,gEAA0B;qCAA1B,0BAA0B;IADtC,IAAA,mBAAU,GAAE;IAKJ,WAAA,IAAA,0BAAgB,EAAC,qCAAa,CAAC,CAAA;qCADG,8BAAa;QAEZ,oBAAU;GALzC,0BAA0B,CA+HtC","sourcesContent":["// Return the system fields metadata for a model\n\nimport { Injectable, Logger } from \"@nestjs/common\";\nimport { SolidRegistry } from \"./solid-registry\";\nimport { In, Repository } from \"typeorm\";\nimport { InjectRepository } from \"@nestjs/typeorm\";\nimport { ModelMetadata } from \"src/entities/model-metadata.entity\";\n\n@Injectable()\nexport class ModelMetadataHelperService {\n private readonly logger = new Logger(ModelMetadataHelperService.name);\n\n constructor(private readonly registry: SolidRegistry,\n @InjectRepository(ModelMetadata)\n private readonly modelMetadataRepo: Repository<ModelMetadata>,\n ) {\n }\n\n getSystemFieldsMetadata(): any[] {\n const systemFieldsMetadata = [\n {\n name: \"id\",\n displayName: \"Id\",\n type: \"int\",\n ormType: \"bigint\",\n isSystem: true,\n },\n {\n name: \"createdAt\",\n displayName: \"Created At\",\n type: \"datetime\",\n ormType: \"timestamp\",\n isSystem: true,\n },\n {\n name: \"updatedAt\",\n displayName: \"Updated At\",\n type: \"datetime\",\n ormType: \"timestamp\",\n isSystem: true,\n },\n {\n name: \"deletedAt\",\n displayName: \"Deleted At\",\n type: \"datetime\",\n ormType: \"timestamp\",\n isSystem: true,\n },\n {\n name: \"deletedTracker\",\n displayName: \"Deleted Tracker\",\n type: \"shortText\",\n ormType: \"varchar\",\n isSystem: true,\n },\n {\n name: \"publishedAt\",\n displayName: \"Published At\",\n type: \"datetime\",\n ormType: \"timestamp\",\n isSystem: true,\n },\n {\n name: \"localeName\",\n displayName: \"Locale\",\n type: \"shortText\",\n ormType: \"varchar\",\n isSystem: true,\n },\n {\n name: \"defaultEntityLocaleId\",\n displayName: \"Default Entity Locale Id\",\n type: \"int\",\n ormType: \"integer\",\n isSystem: true,\n },\n {\n name: \"createdBy\",\n displayName: \"Created By\",\n type: \"relation\",\n ormType: \"integer\",\n isSystem: true,\n relationType: \"many-to-one\",\n relationCoModelSingularName: \"user\",\n relationCreateInverse: false,\n relationCascade: \"restrict\",\n relationModelModuleName: \"solid-core\"\n },\n {\n name: \"updatedBy\",\n displayName: \"Updated By\",\n type: \"relation\",\n ormType: \"integer\",\n isSystem: true,\n relationType: \"many-to-one\",\n relationCoModelSingularName: \"user\",\n relationCreateInverse: false,\n relationCascade: \"restrict\",\n relationModelModuleName: \"solid-core\"\n },\n ]\n\n // Do an additional check and add a warning if the common entity keys and system field metadata keys don't match exactly\n const commonEntityKeys = this.registry.getCommonEntityKeys();\n const systemFieldNames = systemFieldsMetadata.map(field => field.name);\n const missingKeys = commonEntityKeys.filter(key => !systemFieldNames.includes(key));\n if (missingKeys.length > 0) {\n this.logger.warn(`Missing system fields metadata for common entity keys: ${missingKeys.join(', ')}`);\n }\n return systemFieldsMetadata;\n }\n\n 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: any[] = [];\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}"]}
@@ -15,6 +15,7 @@ import { ExcelService } from './excel.service';
15
15
  import { SolidIntrospectService } from './solid-introspect.service';
16
16
  import { ModelMetadata } from 'src/entities/model-metadata.entity';
17
17
  import { UpdateExportTemplateDto } from 'src/dtos/update-export-template.dto';
18
+ import { ModelMetadataHelperService } from 'src/helpers/model-metadata-helper.service';
18
19
  export interface ExportTransactionFileInfo {
19
20
  exportStream: Readable;
20
21
  fileName: string;
@@ -36,8 +37,9 @@ export declare class ExportTransactionService extends CRUDService<ExportTransact
36
37
  readonly fieldRepo: Repository<FieldMetadata>;
37
38
  readonly ModelMetadataRepo: Repository<ModelMetadata>;
38
39
  readonly moduleRef: ModuleRef;
40
+ private readonly modelMetadataHelperService;
39
41
  private logger;
40
- constructor(modelMetadataService: ModelMetadataService, moduleMetadataService: ModuleMetadataService, configService: ConfigService, fileService: FileService, discoveryService: DiscoveryService, crudHelperService: CrudHelperService, entityManager: EntityManager, repo: Repository<ExportTransaction>, introspectService: SolidIntrospectService, excelService: ExcelService, csvService: CsvService, fieldRepo: Repository<FieldMetadata>, ModelMetadataRepo: Repository<ModelMetadata>, moduleRef: ModuleRef);
42
+ constructor(modelMetadataService: ModelMetadataService, moduleMetadataService: ModuleMetadataService, configService: ConfigService, fileService: FileService, discoveryService: DiscoveryService, crudHelperService: CrudHelperService, entityManager: EntityManager, repo: Repository<ExportTransaction>, introspectService: SolidIntrospectService, excelService: ExcelService, csvService: CsvService, fieldRepo: Repository<FieldMetadata>, ModelMetadataRepo: Repository<ModelMetadata>, moduleRef: ModuleRef, modelMetadataHelperService: ModelMetadataHelperService);
41
43
  triggerExportSync(id: number, exportTransactionEntity: any, updateDto: UpdateExportTemplateDto, filters: any): Promise<ExportTransactionFileInfo>;
42
44
  triggerExportAsync(id: number, exportTransactionEntity: any, updateDto: UpdateExportTemplateDto, filters: any): Promise<void>;
43
45
  private loadExportTransaction;
@@ -1 +1 @@
1
-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AAiB,EAEpC,aAAa,EAAE,aAAa,EAE5B,IAAI,EAAE,UAAU,CAAC,iBAAiB,CAAC,EACnC,iBAAiB,EAAE,sBAAsB,EACzC,YAAY,EAAE,YAAY,EAC1B,UAAU,EAAE,UAAU,EAGtB,SAAS,EAAE,UAAU,CAAC,aAAa,CAAC,EAEpC,iBAAiB,EAAE,UAAU,CAAC,aAAa,CAAC,EAC5C,SAAS,EAAE,SAAS,EACZ,0BAA0B,EAAE,0BAA0B;IAOnE,iBAAiB,CAAC,EAAE,EAAE,MAAM,EAAE,uBAAuB,EAAE,GAAG,EAAE,SAAS,EAAE,uBAAuB,EAAE,OAAO,EAAE,GAAG,GAAG,OAAO,CAAC,yBAAyB,CAAC;IAwBjJ,kBAAkB,CAAC,EAAE,EAAE,MAAM,EAAE,uBAAuB,EAAE,GAAG,EAAE,SAAS,EAAE,uBAAuB,EAAE,OAAO,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;YAwBrH,qBAAqB;YAQrB,uBAAuB;YAIvB,sBAAsB;YAuBtB,eAAe;YAef,iBAAiB;IAuB/B,OAAO,CAAC,WAAW;IAKnB,OAAO,CAAC,WAAW;YAIL,kBAAkB;IAqI1B,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,0BAA0B,CAAC,GAAG,OAAO,CAAC,0BAA0B,CAAC;CAS5F"}
@@ -35,6 +35,7 @@ const mediaStorageProviders_1 = require("./mediaStorageProviders");
35
35
  const solid_introspect_service_1 = require("./solid-introspect.service");
36
36
  const model_metadata_entity_1 = require("../entities/model-metadata.entity");
37
37
  const error_messages_1 = require("../constants/error-messages");
38
+ const model_metadata_helper_service_1 = require("../helpers/model-metadata-helper.service");
38
39
  const EXPORT_CHUNK_SIZE = 100;
39
40
  var ExportStatus;
40
41
  (function (ExportStatus) {
@@ -48,7 +49,7 @@ var ExportFormat;
48
49
  ExportFormat["EXCEL"] = "excel";
49
50
  })(ExportFormat || (ExportFormat = {}));
50
51
  let ExportTransactionService = ExportTransactionService_1 = class ExportTransactionService extends crud_service_1.CRUDService {
51
- constructor(modelMetadataService, moduleMetadataService, configService, fileService, discoveryService, crudHelperService, entityManager, repo, introspectService, excelService, csvService, fieldRepo, ModelMetadataRepo, moduleRef) {
52
+ constructor(modelMetadataService, moduleMetadataService, configService, fileService, discoveryService, crudHelperService, entityManager, repo, introspectService, excelService, csvService, fieldRepo, ModelMetadataRepo, moduleRef, modelMetadataHelperService) {
52
53
  super(modelMetadataService, moduleMetadataService, configService, fileService, discoveryService, crudHelperService, entityManager, repo, 'exportTransaction', 'solid-core', moduleRef);
53
54
  this.modelMetadataService = modelMetadataService;
54
55
  this.moduleMetadataService = moduleMetadataService;
@@ -64,6 +65,7 @@ let ExportTransactionService = ExportTransactionService_1 = class ExportTransact
64
65
  this.fieldRepo = fieldRepo;
65
66
  this.ModelMetadataRepo = ModelMetadataRepo;
66
67
  this.moduleRef = moduleRef;
68
+ this.modelMetadataHelperService = modelMetadataHelperService;
67
69
  this.logger = new common_1.Logger(ExportTransactionService_1.name);
68
70
  }
69
71
  async triggerExportSync(id, exportTransactionEntity, updateDto, filters) {
@@ -159,12 +161,11 @@ let ExportTransactionService = ExportTransactionService_1 = class ExportTransact
159
161
  return (fileFormat === ExportFormat.EXCEL) ? 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' : 'text/csv';
160
162
  }
161
163
  async getDataRecordsFunc(fields, modelService, modelMetadata, filters) {
162
- const relatedFieldNames = modelMetadata?.fields
163
- .filter((field) => field.relationType !== null)
164
- .map((field) => field.name);
164
+ const allModelFields = await this.modelMetadataHelperService.loadFieldHierarchy(modelMetadata.singularName);
165
+ const modelFields = allModelFields.filter((f) => fields.includes(f.name));
165
166
  const relatedModelsUserKeyMap = new Map();
166
- for (const field of modelMetadata?.fields || []) {
167
- if (field.relationType && field.relationCoModelSingularName && fields.includes(field.name)) {
167
+ for (const field of modelFields) {
168
+ if (field.relationType && field.relationCoModelSingularName) {
168
169
  const relatedModelMetadata = await this.ModelMetadataRepo.findOne({
169
170
  where: { singularName: field.relationCoModelSingularName },
170
171
  relations: ['userKeyField'],
@@ -174,38 +175,90 @@ let ExportTransactionService = ExportTransactionService_1 = class ExportTransact
174
175
  }
175
176
  }
176
177
  }
178
+ const fieldNameToDisplayName = new Map();
179
+ for (const field of modelFields || []) {
180
+ if (field.name) {
181
+ fieldNameToDisplayName.set(field.name, field.displayName ?? field.name);
182
+ }
183
+ }
177
184
  return async (chunkIndex, chunkSize) => {
178
185
  const offset = chunkIndex * chunkSize;
179
186
  const recordFilterDto = {
180
187
  limit: chunkSize,
181
188
  offset,
182
- populate: relatedFieldNames
189
+ populate: modelFields
190
+ .filter((f) => f.relationType !== null)
191
+ .map((f) => f.name),
183
192
  };
184
193
  const cleanedFilters = cleanNullsFromObject(filters);
185
194
  if (cleanedFilters && Object.keys(cleanedFilters).length > 0) {
186
195
  recordFilterDto.filters = cleanedFilters;
187
196
  }
188
- const nonRelationalFieldSet = new Set(modelMetadata?.fields
189
- .filter((field) => fields.includes(field.name) && field.relationType === null)
190
- .map((field) => field.name));
191
197
  const data = await modelService.instance.find(recordFilterDto);
192
198
  const records = data.records ?? [];
193
199
  const cleanedRecords = records.map((record) => {
194
200
  const newRecord = {};
195
- for (const key of nonRelationalFieldSet) {
196
- newRecord[key] = record[key];
201
+ for (const field of modelFields) {
202
+ if (!field.relationType) {
203
+ const displayKey = fieldNameToDisplayName.get(field.name) ?? field.name;
204
+ const fieldMeta = modelFields.find(f => f.name === field.name);
205
+ if ((fieldMeta?.type === 'datetime' || fieldMeta?.type === 'date') && record[field.name]) {
206
+ newRecord[displayKey] = new Date(record[field.name]).toISOString();
207
+ }
208
+ else {
209
+ newRecord[displayKey] = record[field.name];
210
+ }
211
+ }
197
212
  }
198
213
  for (const [relatedFieldName, userKeyFieldName] of relatedModelsUserKeyMap.entries()) {
199
214
  const relatedData = record[relatedFieldName];
215
+ const displayKey = fieldNameToDisplayName.get(relatedFieldName) ?? relatedFieldName;
200
216
  if (Array.isArray(relatedData)) {
201
- const values = relatedData.map(item => item?.[userKeyFieldName]).filter(Boolean);
202
- newRecord[relatedFieldName] = values.join(', ');
217
+ const values = relatedData
218
+ .map(item => {
219
+ let val = item?.[userKeyFieldName];
220
+ const relatedFieldMeta = modelFields.find(f => f.name === relatedFieldName);
221
+ if ((relatedFieldMeta?.type === 'datetime' || relatedFieldMeta?.type === 'date') && val) {
222
+ val = new Date(val).toISOString();
223
+ }
224
+ return val;
225
+ })
226
+ .filter(Boolean);
227
+ newRecord[displayKey] = values.join(', ');
203
228
  }
204
229
  else if (relatedData && typeof relatedData === 'object') {
205
230
  newRecord[relatedFieldName] = relatedData?.[userKeyFieldName] ?? null;
206
231
  }
207
232
  else {
208
- newRecord[relatedFieldName] = null;
233
+ newRecord[displayKey] = null;
234
+ }
235
+ }
236
+ for (const [relatedFieldName, userKeyFieldName] of relatedModelsUserKeyMap.entries()) {
237
+ const relatedData = record[relatedFieldName];
238
+ const displayKey = fieldNameToDisplayName.get(relatedFieldName) ?? relatedFieldName;
239
+ if (Array.isArray(relatedData)) {
240
+ const values = relatedData
241
+ .map(item => {
242
+ const val = item?.[userKeyFieldName];
243
+ const relatedFieldMeta = modelFields.find(f => f.name === relatedFieldName);
244
+ if ((relatedFieldMeta?.type === 'datetime' || relatedFieldMeta?.type === 'date') && val) {
245
+ return new Date(val).toISOString();
246
+ }
247
+ return val;
248
+ })
249
+ .filter(Boolean);
250
+ newRecord[displayKey] = values.join(', ');
251
+ }
252
+ else if (relatedData && typeof relatedData === 'object') {
253
+ let val = relatedData?.[userKeyFieldName] ?? null;
254
+ const relatedFieldMeta = modelFields.find(f => f.name === relatedFieldName);
255
+ if ((relatedFieldMeta?.type === 'datetime' || relatedFieldMeta?.type === 'date') && val) {
256
+ val = new Date(val).toISOString();
257
+ }
258
+ newRecord[displayKey] = val;
259
+ }
260
+ else {
261
+ newRecord[displayKey] = null;
209
262
  }
210
263
  }
211
264
  return newRecord;
@@ -243,7 +296,8 @@ exports.ExportTransactionService = ExportTransactionService = ExportTransactionS
243
296
  csv_service_1.CsvService,
244
297
  typeorm_2.Repository,
245
298
  typeorm_2.Repository,
246
- core_1.ModuleRef])
299
+ core_1.ModuleRef,
300
+ model_metadata_helper_service_1.ModelMetadataHelperService])
247
301
  ], ExportTransactionService);
248
302
  function cleanNullsFromObject(obj) {
249
303
  if (Array.isArray(obj)) {
@@ -1 +1 @@
1
- {"version":3,"file":"export-transaction.service.js","sourceRoot":"","sources":["../../src/services/export-transaction.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAoD;AACpD,uCAA2D;AAC3D,6CAAwE;AACxE,qCAAoD;AAEpD,2CAA+C;AAC/C,+DAAqE;AACrE,iDAAwD;AACxD,iDAAwD;AAGxD,qEAA2E;AAC3E,uEAA6E;AAG7E,oEAA6E;AAE7E,qDAA2C;AAE3C,yFAAoF;AAEpF,6EAAmE;AAEnE,qFAA0E;AAC1E,+CAA2C;AAC3C,mDAA+C;AAC/C,mEAAkE;AAClE,yEAAoE;AACpE,6EAAmE;AAEnE,gEAA8D;AAE9D,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAC9B,IAAK,YAIJ;AAJD,WAAK,YAAY;IACf,mCAAmB,CAAA;IACnB,uCAAuB,CAAA;IACvB,iCAAiB,CAAA;AACnB,CAAC,EAJI,YAAY,KAAZ,YAAY,QAIhB;AAED,IAAK,YAGJ;AAHD,WAAK,YAAY;IACf,2BAAW,CAAA;IACX,+BAAe,CAAA;AACjB,CAAC,EAHI,YAAY,KAAZ,YAAY,QAGhB;AAUM,IAAM,wBAAwB,gCAA9B,MAAM,wBAAyB,SAAQ,0BAA8B;IAG1E,YACW,oBAA0C,EAC1C,qBAA4C,EAC5C,aAA4B,EAC5B,WAAwB,EACxB,gBAAkC,EAClC,iBAAoC,EAE7C,aAAqC,EAErC,IAA4C,EACnC,iBAAyC,EACzC,YAA0B,EAC1B,UAAsB,EAG/B,SAA6C,EAE7C,iBAAsD,EAC7C,SAAoB;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E,CAAC;YACtB,MAAM,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;YACvB,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;gBAC1C,MAAM,YAAY,GAAG,oBAAoB,CAAC,KAAK,CAAC,CAAC;gBAEjD,IACE,CAAC,OAAO,YAAY,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;oBAC1E,CAAC,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC;oBACxD,OAAO,YAAY,KAAK,QAAQ,EAChC,CAAC;oBACD,MAAM,CAAC,GAAG,CAAC,GAAG,YAAY,CAAC;gBAC7B,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["import { Injectable, Logger } from '@nestjs/common';\nimport { DiscoveryService, ModuleRef } from \"@nestjs/core\";\nimport { InjectEntityManager, InjectRepository } from '@nestjs/typeorm';\nimport { EntityManager, Repository } from 'typeorm';\n\nimport { ConfigService } from '@nestjs/config';\nimport { CrudHelperService } from 'src/services/crud-helper.service';\nimport { CRUDService } from 'src/services/crud.service';\nimport { FileService } from 'src/services/file.service';\nimport { MediaStorageProviderMetadataService } from 'src/services/media-storage-provider-metadata.service';\nimport { MediaService } from 'src/services/media.service';\nimport { ModelMetadataService } from 'src/services/model-metadata.service';\nimport { ModuleMetadataService } from 'src/services/module-metadata.service';\n\n\nimport { classify, dasherize } from '@angular-devkit/core/src/utils/strings';\nimport { InstanceWrapper } from '@nestjs/core/injector/instance-wrapper';\nimport { validate } from 'class-validator';\nimport { BasicFilterDto } from 'src/dtos/basic-filters.dto';\nimport { CreateExportTransactionDto } from 'src/dtos/create-export-transaction.dto';\nimport { MediaStorageProviderType } from 'src/dtos/create-media-storage-provider-metadata.dto';\nimport { FieldMetadata } from 'src/entities/field-metadata.entity';\nimport { Readable } from 'stream';\nimport { ExportTransaction } from '../entities/export-transaction.entity';\nimport { CsvService } from './csv.service';\nimport { ExcelService } from './excel.service';\nimport { getMediaStorageProvider } from './mediaStorageProviders';\nimport { SolidIntrospectService } from './solid-introspect.service';\nimport { ModelMetadata } from 'src/entities/model-metadata.entity';\nimport { UpdateExportTemplateDto } from 'src/dtos/update-export-template.dto';\nimport { ERROR_MESSAGES } from 'src/constants/error-messages';\n\nconst EXPORT_CHUNK_SIZE = 100;\nenum ExportStatus {\n STARTED = 'started',\n COMPLETED = 'completed',\n FAILED = 'failed',\n}\n\nenum ExportFormat {\n CSV = 'csv',\n EXCEL = 'excel',\n}\n\nexport interface ExportTransactionFileInfo {\n exportStream: Readable;\n fileName: string;\n mimeType: string;\n exportTransaction: ExportTransaction;\n}\n\n@Injectable()\nexport class ExportTransactionService extends CRUDService<ExportTransaction> {\n private logger = new Logger(ExportTransactionService.name);\n\n constructor(\n readonly modelMetadataService: ModelMetadataService,\n readonly moduleMetadataService: ModuleMetadataService,\n readonly configService: ConfigService,\n readonly fileService: FileService,\n readonly discoveryService: DiscoveryService,\n readonly crudHelperService: CrudHelperService,\n @InjectEntityManager()\n readonly entityManager: EntityManager,\n @InjectRepository(ExportTransaction, 'default')\n readonly repo: Repository<ExportTransaction>,\n readonly introspectService: SolidIntrospectService,\n readonly excelService: ExcelService,\n readonly csvService: CsvService,\n // readonly fieldMetadataService: FieldMetadataService,\n @InjectRepository(FieldMetadata, 'default')\n readonly fieldRepo: Repository<FieldMetadata>,\n @InjectRepository(ModelMetadata, 'default')\n readonly ModelMetadataRepo : Repository<ModelMetadata>,\n readonly moduleRef: ModuleRef\n ) {\n super(modelMetadataService, moduleMetadataService, configService, fileService, discoveryService, crudHelperService, entityManager, repo, 'exportTransaction', 'solid-core',moduleRef);\n }\n\n // Return the export stream\n async triggerExportSync(id: number, exportTransactionEntity: any, updateDto: UpdateExportTemplateDto , filters: any): Promise<ExportTransactionFileInfo> {\n try {\n // const loadedExportTransaction = await this.loadExportTransaction(id);\n // from updateDto, get modelId and get modelMetadata\n const modeldata = await this.ModelMetadataRepo.findOne({\n where: { id: updateDto?.modelMetadataId},\n relations: { fields: true},\n })\n const modelName = modeldata?.singularName;\n const modelTemplateName = modelName;\n const fields = JSON.parse(updateDto?.fields);\n const templateFormat = updateDto?.templateFormat;\n const { exportStream, templateName, uuid, exportTransaction } = await this.getExportStreamDetails(modelName, modelTemplateName, fields, modeldata, templateFormat, id, exportTransactionEntity, filters);\n this.updateExportTransaction(id, ExportStatus.COMPLETED);\n const fileName = this.getFileName(templateName, uuid, templateFormat);\n const mimeType = this.getMimeType(templateFormat);\n return { exportStream, fileName, mimeType, exportTransaction };\n } catch (error) {\n this.updateExportTransaction(id, ExportStatus.FAILED, error.message);\n throw error;\n }\n }\n\n // Store the export stream using the appropriate storage provider\n async triggerExportAsync(id: number, exportTransactionEntity: any, updateDto: UpdateExportTemplateDto, filters:any): Promise<void> {\n try {\n // const loadedExportTransaction = await this.loadExportTransaction(id)\n // from updateDto, get modelId and get modelMetadata\n const modeldata = await this.ModelMetadataRepo.findOne({\n where: { id: updateDto?.modelMetadataId},\n relations: { fields: true},\n })\n const modelName = modeldata?.singularName;\n const modelTemplateName = modelName;\n const fields = JSON.parse(updateDto?.fields);\n const templateFormat = updateDto?.templateFormat;\n const { exportStream, templateName, uuid, exportTransaction } = await this.getExportStreamDetails(modelName, modelTemplateName, fields, modeldata, templateFormat, id, exportTransactionEntity, filters);\n // const fileFormat = loadedExportTransaction.exportTemplate.templateFormat;\n // Store the file using the appropriate storage provider\n await this.storeExportStream(exportStream, exportTransaction, this.getFileName(templateName, uuid, templateFormat));\n this.updateExportTransaction(id, ExportStatus.COMPLETED);\n } catch (error) {\n this.updateExportTransaction(id, ExportStatus.FAILED, error.message);\n throw error;\n\n }\n }\n\n private async loadExportTransaction(id: number) {\n return await this.repo.findOne({\n where: { id: id },\n relations: { exportTemplate: { modelMetadata: {fields: true} }},\n }\n );\n }\n\n private async updateExportTransaction(id: number, status: string, error?: string) {\n await this.repo.update(id, { status, error });\n }\n\n private async getExportStreamDetails(modelName: string, templateName: string, fields:any, modelData:any, templateFormat:string, id:number, exportTransaction: any, filters: any) {\n // Get the columns which need to be exported & the model id\n // const fields = JSON.parse(exportTransaction.exportTemplate.fields);\n\n // // Get the appropriate service for the model by trying to fetch a model service matching a particular name\n // const modelName = exportTransaction.exportTemplate.modelMetadata.singularName;\n const modelService = this.introspectService.getProvider(`${classify(modelName)}Service`);\n // const templateName = exportTransaction.exportTemplate.templateName;\n const uuid = String(id); //TODO can be renamed to exportTransactionUUID\n // const modelData = exportTransaction.exportTemplate.modelMetadata;\n\n // Get the data records function\n //const dataRecordsFunc = await this.getDataRecordsFunc(fields, modelService,modelData, filters);\n const dataRecordsFunc = await this.getDataRecordsFunc(fields, modelService, modelData, filters);\n\n // Get the export passthru stream (since it is a passthru stream, nothing is stored in memory & it is streamed directly when the stream is read)\n // let exportStream = await this.getExportStream(exportTransaction.exportTemplate.templateFormat, dataRecordsFunc);\n // return { exportStream, templateName, uuid, exportTransaction };\n\n let exportStream = await this.getExportStream(templateFormat, dataRecordsFunc);\n return { exportStream, templateName, uuid, exportTransaction };\n }\n\n private async getExportStream(templateFormat: string, dataRecordsFunc: (chunkIndex: number, chunkSize: number) => Promise<any[]>) {\n let exportStream = null;\n switch (templateFormat) {\n case ExportFormat.EXCEL:\n exportStream = await this.excelService.createExcelStream(dataRecordsFunc, EXPORT_CHUNK_SIZE);\n break;\n case ExportFormat.CSV:\n exportStream = await this.csvService.createCsvStream(dataRecordsFunc, EXPORT_CHUNK_SIZE);\n break;\n default:\n throw new Error(ERROR_MESSAGES.INVALID_FORMAT('export' + templateFormat));\n }\n return exportStream;\n }\n\n private async storeExportStream(exportStream: Readable, exportTransaction: ExportTransaction, fileName: string) {\n const exportedFileMediaField = await this.fieldRepo.findOne({\n where: {\n name: 'exportedFile',\n model: {\n singularName: 'exportTransaction'\n },\n },\n relations: ['model', 'mediaStorageProvider'],\n });\n // const storageProvider = new FileStorageProvider<ExportTransaction>(this.configService, this.fileService, this.mediaService);\n const storageProviderMetadata = exportedFileMediaField.mediaStorageProvider;\n\n // // Use the storage provider metadata to get the appropriate storage provider implementation\n const storageProviderType = storageProviderMetadata.type as MediaStorageProviderType;\n\n // // Get the storage provider implementation\n const storageProvider = await getMediaStorageProvider(this.moduleRef, storageProviderType);\n\n //Commented the below code since we will be direclty images from server on call from ui \n await storageProvider.storeStreams([[exportStream, fileName]], exportTransaction, exportedFileMediaField)\n }\n\n private getFileName(templateName: string, exportTransactionUUID: string, fileFormat: string): string {\n const extension = (fileFormat === ExportFormat.EXCEL) ? 'xlsx' : 'csv';\n return `${dasherize(templateName)}-${exportTransactionUUID}.${extension}`;\n }\n\n private getMimeType(fileFormat: string): string {\n return (fileFormat === ExportFormat.EXCEL) ? 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' : 'text/csv';\n }\n\n private async getDataRecordsFunc(fields: any, modelService: InstanceWrapper<any>, modelMetadata: any, filters:any): Promise<(chunkIndex: number, chunkSize: number) => Promise<any[]>> {\n // Return a function which will take the chunkIndex & chunkSize and return the data\n // Get the relation fields to populate\n const relatedFieldNames = modelMetadata?.fields\n .filter((field: { relationType: any; }) => field.relationType !== null)\n .map((field: { name: any; }) => field.name);\n\n //Get the model metadata of relation field with userKey details\n const relatedModelsUserKeyMap = new Map<string, string>();\n for (const field of modelMetadata?.fields || []) {\n if (field.relationType && field.relationCoModelSingularName && fields.includes(field.name)) {\n const relatedModelMetadata = await this.ModelMetadataRepo.findOne({\n where: { singularName: field.relationCoModelSingularName },\n relations: ['userKeyField'],\n });\n\n if (relatedModelMetadata?.userKeyField?.name) {\n relatedModelsUserKeyMap.set(field.name, relatedModelMetadata.userKeyField.name);\n }\n }\n }\n\n return async (chunkIndex: number, chunkSize: number) => {\n const offset = chunkIndex * chunkSize;\n const recordFilterDto: BasicFilterDto = {\n limit: chunkSize,\n offset,\n populate: relatedFieldNames\n };\n const cleanedFilters = cleanNullsFromObject(filters);\n\n if (cleanedFilters && Object.keys(cleanedFilters).length > 0) {\n recordFilterDto.filters = cleanedFilters;\n }\n\n //Get the non relation fields which are in fields array passed to this function\n const nonRelationalFieldSet = new Set(\n modelMetadata?.fields\n .filter((field: { name: any; relationType: any; }) => fields.includes(field.name) && field.relationType === null)\n .map((field: { name: any; }) => field.name)\n );\n const data = await modelService.instance.find(recordFilterDto);\n const records = data.records ?? [];\n const cleanedRecords = records.map((record: Record<string, any>) => {\n const newRecord: Record<string, any> = {};\n \n // Include non-relational fields\n for (const key of nonRelationalFieldSet as Set<string>) {\n newRecord[key] = record[key];\n }\n \n // Include userKey from each related field\n for (const [relatedFieldName, userKeyFieldName] of relatedModelsUserKeyMap.entries()) {\n const relatedData = record[relatedFieldName];\n \n if (Array.isArray(relatedData)) {\n // For many-to-many or one-to-many\n const values = relatedData.map(item => item?.[userKeyFieldName]).filter(Boolean);\n newRecord[relatedFieldName] = values.join(', ');\n } else if (relatedData && typeof relatedData === 'object') {\n // For many-to-one or one-to-one\n newRecord[relatedFieldName] = relatedData?.[userKeyFieldName] ?? null;\n } else {\n newRecord[relatedFieldName] = null;\n }\n }\n \n return newRecord;\n });\n return cleanedRecords\n }\n}\n\n async toDto(data: Partial<CreateExportTransactionDto>): Promise<CreateExportTransactionDto> {\n const dto = new CreateExportTransactionDto(data);\n const errors = await validate(dto);\n if (errors.length > 0) {\n console.error(\"Validation failed:\", errors);\n return null;\n }\n return dto;\n }\n}\n\nfunction cleanNullsFromObject(obj: any): any {\n if (Array.isArray(obj)) {\n return obj\n .filter(item => item !== null && item !== undefined)\n .map(cleanNullsFromObject);\n } else if (typeof obj === 'object' && obj !== null) {\n const newObj: any = {};\n for (const key in obj) {\n const value = obj[key];\n if (value !== null && value !== undefined) {\n const cleanedValue = cleanNullsFromObject(value);\n // Only assign non-empty objects/arrays or non-null primitives\n if (\n (typeof cleanedValue === 'object' && Object.keys(cleanedValue).length > 0) ||\n (Array.isArray(cleanedValue) && cleanedValue.length > 0) ||\n typeof cleanedValue !== 'object'\n ) {\n newObj[key] = cleanedValue;\n }\n }\n }\n return newObj;\n }\n return obj;\n}\n\n"]}
1
+ {"version":3,"file":"export-transaction.service.js","sourceRoot":"","sources":["../../src/services/export-transaction.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAoD;AACpD,uCAA2D;AAC3D,6CAAwE;AACxE,qCAAoD;AAEpD,2CAA+C;AAC/C,+DAAqE;AACrE,iDAAwD;AACxD,iDAAwD;AAGxD,qEAA2E;AAC3E,uEAA6E;AAG7E,oEAA6E;AAE7E,qDAA2C;AAE3C,yFAAoF;AAEpF,6EAAmE;AAEnE,qFAA0E;AAC1E,+CAA2C;AAC3C,mDAA+C;AAC/C,mEAAkE;AAClE,yEAAoE;AACpE,6EAAmE;AAEnE,gEAA8D;AAC9D,4FAAuF;AAEvF,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAC9B,IAAK,YAIJ;AAJD,WAAK,YAAY;IACf,mCAAmB,CAAA;IACnB,uCAAuB,CAAA;IACvB,iCAAiB,CAAA;AACnB,CAAC,EAJI,YAAY,KAAZ,YAAY,QAIhB;AAED,IAAK,YAGJ;AAHD,WAAK,YAAY;IACf,2BAAW,CAAA;IACX,+BAAe,CAAA;AACjB,CAAC,EAHI,YAAY,KAAZ,YAAY,QAGhB;AAUM,IAAM,wBAAwB,gCAA9B,MAAM,wBAAyB,SAAQ,0BAA8B;IAG1E,YACW,oBAA0C,EAC1C,qBAA4C,EAC5C,aAA4B,EAC5B,WAAwB,EACxB,gBAAkC,EAClC,iBAAoC,EAE7C,aAAqC,EAErC,IAA4C,EACnC,iBAAyC,EACzC,YAA0B,EAC1B,UAAsB,EAG/B,SAA6C,EAE7C,iBAAqD,EAC5C,SAAoB,EACZ,0BAAsD;QAGvE,KAAK,CAAC,oBAAoB,EAAE,qBAAqB,EAAE,aAAa,EAAE,WAAW,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,CAAC,EAAE,CAAC,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,SAAS,CAAC;aACnD,GAAG,CAAC,oBAAoB,CAAC,CAAC;IAC/B,CAAC;SAAM,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;QACnD,MAAM,MAAM,GAAQ,EAAE,CAAC;QACvB,KAAK,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;YACtB,MAAM,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;YACvB,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;gBAC1C,MAAM,YAAY,GAAG,oBAAoB,CAAC,KAAK,CAAC,CAAC;gBAEjD,IACE,CAAC,OAAO,YAAY,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;oBAC1E,CAAC,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC;oBACxD,OAAO,YAAY,KAAK,QAAQ,EAChC,CAAC;oBACD,MAAM,CAAC,GAAG,CAAC,GAAG,YAAY,CAAC;gBAC7B,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["import { Injectable, Logger } from '@nestjs/common';\nimport { DiscoveryService, ModuleRef } from \"@nestjs/core\";\nimport { InjectEntityManager, InjectRepository } from '@nestjs/typeorm';\nimport { EntityManager, Repository } from 'typeorm';\n\nimport { ConfigService } from '@nestjs/config';\nimport { CrudHelperService } from 'src/services/crud-helper.service';\nimport { CRUDService } from 'src/services/crud.service';\nimport { FileService } from 'src/services/file.service';\nimport { MediaStorageProviderMetadataService } from 'src/services/media-storage-provider-metadata.service';\nimport { MediaService } from 'src/services/media.service';\nimport { ModelMetadataService } from 'src/services/model-metadata.service';\nimport { ModuleMetadataService } from 'src/services/module-metadata.service';\n\n\nimport { classify, dasherize } from '@angular-devkit/core/src/utils/strings';\nimport { InstanceWrapper } from '@nestjs/core/injector/instance-wrapper';\nimport { validate } from 'class-validator';\nimport { BasicFilterDto } from 'src/dtos/basic-filters.dto';\nimport { CreateExportTransactionDto } from 'src/dtos/create-export-transaction.dto';\nimport { MediaStorageProviderType } from 'src/dtos/create-media-storage-provider-metadata.dto';\nimport { FieldMetadata } from 'src/entities/field-metadata.entity';\nimport { Readable } from 'stream';\nimport { ExportTransaction } from '../entities/export-transaction.entity';\nimport { CsvService } from './csv.service';\nimport { ExcelService } from './excel.service';\nimport { getMediaStorageProvider } from './mediaStorageProviders';\nimport { SolidIntrospectService } from './solid-introspect.service';\nimport { ModelMetadata } from 'src/entities/model-metadata.entity';\nimport { UpdateExportTemplateDto } from 'src/dtos/update-export-template.dto';\nimport { ERROR_MESSAGES } from 'src/constants/error-messages';\nimport { ModelMetadataHelperService } from 'src/helpers/model-metadata-helper.service';\n\nconst EXPORT_CHUNK_SIZE = 100;\nenum ExportStatus {\n STARTED = 'started',\n COMPLETED = 'completed',\n FAILED = 'failed',\n}\n\nenum ExportFormat {\n CSV = 'csv',\n EXCEL = 'excel',\n}\n\nexport interface ExportTransactionFileInfo {\n exportStream: Readable;\n fileName: string;\n mimeType: string;\n exportTransaction: ExportTransaction;\n}\n\n@Injectable()\nexport class ExportTransactionService extends CRUDService<ExportTransaction> {\n private logger = new Logger(ExportTransactionService.name);\n\n constructor(\n readonly modelMetadataService: ModelMetadataService,\n readonly moduleMetadataService: ModuleMetadataService,\n readonly configService: ConfigService,\n readonly fileService: FileService,\n readonly discoveryService: DiscoveryService,\n readonly crudHelperService: CrudHelperService,\n @InjectEntityManager()\n readonly entityManager: EntityManager,\n @InjectRepository(ExportTransaction, 'default')\n readonly repo: Repository<ExportTransaction>,\n readonly introspectService: SolidIntrospectService,\n readonly excelService: ExcelService,\n readonly csvService: CsvService,\n // readonly fieldMetadataService: FieldMetadataService,\n @InjectRepository(FieldMetadata, 'default')\n readonly fieldRepo: Repository<FieldMetadata>,\n @InjectRepository(ModelMetadata, 'default')\n readonly ModelMetadataRepo: Repository<ModelMetadata>,\n readonly moduleRef: ModuleRef,\n private readonly modelMetadataHelperService: ModelMetadataHelperService,\n\n ) {\n super(modelMetadataService, moduleMetadataService, configService, fileService, discoveryService, crudHelperService, entityManager, repo, 'exportTransaction', 'solid-core', moduleRef);\n }\n\n // Return the export stream\n async triggerExportSync(id: number, exportTransactionEntity: any, updateDto: UpdateExportTemplateDto, filters: any): Promise<ExportTransactionFileInfo> {\n try {\n // const loadedExportTransaction = await this.loadExportTransaction(id);\n // from updateDto, get modelId and get modelMetadata\n const modeldata = await this.ModelMetadataRepo.findOne({\n where: { id: updateDto?.modelMetadataId },\n relations: { fields: true },\n })\n const modelName = modeldata?.singularName;\n const modelTemplateName = modelName;\n const fields = JSON.parse(updateDto?.fields);\n const templateFormat = updateDto?.templateFormat;\n const { exportStream, templateName, uuid, exportTransaction } = await this.getExportStreamDetails(modelName, modelTemplateName, fields, modeldata, templateFormat, id, exportTransactionEntity, filters);\n this.updateExportTransaction(id, ExportStatus.COMPLETED);\n const fileName = this.getFileName(templateName, uuid, templateFormat);\n const mimeType = this.getMimeType(templateFormat);\n return { exportStream, fileName, mimeType, exportTransaction };\n } catch (error) {\n this.updateExportTransaction(id, ExportStatus.FAILED, error.message);\n throw error;\n }\n }\n\n // Store the export stream using the appropriate storage provider\n async triggerExportAsync(id: number, exportTransactionEntity: any, updateDto: UpdateExportTemplateDto, filters: any): Promise<void> {\n try {\n // const loadedExportTransaction = await this.loadExportTransaction(id)\n // from updateDto, get modelId and get modelMetadata\n const modeldata = await this.ModelMetadataRepo.findOne({\n where: { id: updateDto?.modelMetadataId },\n relations: { fields: true },\n })\n const modelName = modeldata?.singularName;\n const modelTemplateName = modelName;\n const fields = JSON.parse(updateDto?.fields);\n const templateFormat = updateDto?.templateFormat;\n const { exportStream, templateName, uuid, exportTransaction } = await this.getExportStreamDetails(modelName, modelTemplateName, fields, modeldata, templateFormat, id, exportTransactionEntity, filters);\n // const fileFormat = loadedExportTransaction.exportTemplate.templateFormat;\n // Store the file using the appropriate storage provider\n await this.storeExportStream(exportStream, exportTransaction, this.getFileName(templateName, uuid, templateFormat));\n this.updateExportTransaction(id, ExportStatus.COMPLETED);\n } catch (error) {\n this.updateExportTransaction(id, ExportStatus.FAILED, error.message);\n throw error;\n\n }\n }\n\n private async loadExportTransaction(id: number) {\n return await this.repo.findOne({\n where: { id: id },\n relations: { exportTemplate: { modelMetadata: { fields: true } } },\n }\n );\n }\n\n private async updateExportTransaction(id: number, status: string, error?: string) {\n await this.repo.update(id, { status, error });\n }\n\n private async getExportStreamDetails(modelName: string, templateName: string, fields: any, modelData: any, templateFormat: string, id: number, exportTransaction: any, filters: any) {\n // Get the columns which need to be exported & the model id\n // const fields = JSON.parse(exportTransaction.exportTemplate.fields);\n\n // // Get the appropriate service for the model by trying to fetch a model service matching a particular name\n // const modelName = exportTransaction.exportTemplate.modelMetadata.singularName;\n const modelService = this.introspectService.getProvider(`${classify(modelName)}Service`);\n // const templateName = exportTransaction.exportTemplate.templateName;\n const uuid = String(id); //TODO can be renamed to exportTransactionUUID\n // const modelData = exportTransaction.exportTemplate.modelMetadata;\n\n // Get the data records function\n //const dataRecordsFunc = await this.getDataRecordsFunc(fields, modelService,modelData, filters);\n const dataRecordsFunc = await this.getDataRecordsFunc(fields, modelService, modelData, filters);\n\n // Get the export passthru stream (since it is a passthru stream, nothing is stored in memory & it is streamed directly when the stream is read)\n // let exportStream = await this.getExportStream(exportTransaction.exportTemplate.templateFormat, dataRecordsFunc);\n // return { exportStream, templateName, uuid, exportTransaction };\n\n let exportStream = await this.getExportStream(templateFormat, dataRecordsFunc);\n return { exportStream, templateName, uuid, exportTransaction };\n }\n\n private async getExportStream(templateFormat: string, dataRecordsFunc: (chunkIndex: number, chunkSize: number) => Promise<any[]>) {\n let exportStream = null;\n switch (templateFormat) {\n case ExportFormat.EXCEL:\n exportStream = await this.excelService.createExcelStream(dataRecordsFunc, EXPORT_CHUNK_SIZE);\n break;\n case ExportFormat.CSV:\n exportStream = await this.csvService.createCsvStream(dataRecordsFunc, EXPORT_CHUNK_SIZE);\n break;\n default:\n throw new Error(ERROR_MESSAGES.INVALID_FORMAT('export' + templateFormat));\n }\n return exportStream;\n }\n\n private async storeExportStream(exportStream: Readable, exportTransaction: ExportTransaction, fileName: string) {\n const exportedFileMediaField = await this.fieldRepo.findOne({\n where: {\n name: 'exportedFile',\n model: {\n singularName: 'exportTransaction'\n },\n },\n relations: ['model', 'mediaStorageProvider'],\n });\n // const storageProvider = new FileStorageProvider<ExportTransaction>(this.configService, this.fileService, this.mediaService);\n const storageProviderMetadata = exportedFileMediaField.mediaStorageProvider;\n\n // // Use the storage provider metadata to get the appropriate storage provider implementation\n const storageProviderType = storageProviderMetadata.type as MediaStorageProviderType;\n\n // // Get the storage provider implementation\n const storageProvider = await getMediaStorageProvider(this.moduleRef, storageProviderType);\n\n //Commented the below code since we will be direclty images from server on call from ui \n await storageProvider.storeStreams([[exportStream, fileName]], exportTransaction, exportedFileMediaField)\n }\n\n private getFileName(templateName: string, exportTransactionUUID: string, fileFormat: string): string {\n const extension = (fileFormat === ExportFormat.EXCEL) ? 'xlsx' : 'csv';\n return `${dasherize(templateName)}-${exportTransactionUUID}.${extension}`;\n }\n\n private getMimeType(fileFormat: string): string {\n return (fileFormat === ExportFormat.EXCEL) ? 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' : 'text/csv';\n }\n\n private async getDataRecordsFunc(fields: any, modelService: InstanceWrapper<any>, modelMetadata: any, filters: any): Promise<(chunkIndex: number, chunkSize: number) => Promise<any[]>> {\n //Load all possible fields for the model\n const allModelFields = await this.modelMetadataHelperService.loadFieldHierarchy(\n modelMetadata.singularName,\n );\n\n // Filter only the fields requested in the export payload\n const modelFields = allModelFields.filter((f: any) =>\n fields.includes(f.name),\n );\n\n //Get the model metadata of relation field with userKey details\n const relatedModelsUserKeyMap = new Map<string, string>();\n for (const field of modelFields) {\n if (field.relationType && field.relationCoModelSingularName) {\n const relatedModelMetadata = await this.ModelMetadataRepo.findOne({\n where: { singularName: field.relationCoModelSingularName },\n relations: ['userKeyField'],\n });\n\n if (relatedModelMetadata?.userKeyField?.name) {\n relatedModelsUserKeyMap.set(field.name, relatedModelMetadata.userKeyField.name);\n }\n }\n }\n\n // Build fieldName -> displayName map\n const fieldNameToDisplayName = new Map<string, string>();\n for (const field of modelFields || []) {\n if (field.name) {\n fieldNameToDisplayName.set(field.name, field.displayName ?? field.name);\n }\n }\n\n\n return async (chunkIndex: number, chunkSize: number) => {\n const offset = chunkIndex * chunkSize;\n const recordFilterDto: BasicFilterDto = {\n limit: chunkSize,\n offset,\n //only contains relational fields (so TypeORM includes relations in the result).\n populate: modelFields\n .filter((f: any) => f.relationType !== null)\n .map((f: any) => f.name),\n };\n const cleanedFilters = cleanNullsFromObject(filters);\n\n if (cleanedFilters && Object.keys(cleanedFilters).length > 0) {\n recordFilterDto.filters = cleanedFilters;\n }\n\n const data = await modelService.instance.find(recordFilterDto);\n const records = data.records ?? [];\n const cleanedRecords = records.map((record: Record<string, any>) => {\n const newRecord: Record<string, any> = {};\n\n // Include non-relational fields\n for (const field of modelFields) {\n if (!field.relationType) {\n // newRecord[field.name] = record[field.name];\n const displayKey = fieldNameToDisplayName.get(field.name) ?? field.name;\n const fieldMeta = modelFields.find(f => f.name === field.name);\n\n if ((fieldMeta?.type === 'datetime' || fieldMeta?.type === 'date') && record[field.name]) {\n newRecord[displayKey] = new Date(record[field.name]).toISOString();\n } else {\n newRecord[displayKey] = record[field.name];\n }\n }\n }\n\n // Include userKey from each related field\n for (const [relatedFieldName, userKeyFieldName] of relatedModelsUserKeyMap.entries()) {\n const relatedData = record[relatedFieldName];\n const displayKey = fieldNameToDisplayName.get(relatedFieldName) ?? relatedFieldName;\n\n if (Array.isArray(relatedData)) {\n // For many-to-many or one-to-many\n const values = relatedData\n .map(item => {\n let val = item?.[userKeyFieldName];\n const relatedFieldMeta = modelFields.find(f => f.name === relatedFieldName);\n if ((relatedFieldMeta?.type === 'datetime' || relatedFieldMeta?.type === 'date') && val) {\n val = new Date(val).toISOString();\n }\n return val;\n })\n .filter(Boolean);\n newRecord[displayKey] = values.join(', ');\n } else if (relatedData && typeof relatedData === 'object') {\n // For many-to-one or one-to-one\n newRecord[relatedFieldName] = relatedData?.[userKeyFieldName] ?? null;\n } else {\n newRecord[displayKey] = null;\n }\n }\n\n // Include userKey from each related field (with displayName)\n for (const [relatedFieldName, userKeyFieldName] of relatedModelsUserKeyMap.entries()) {\n const relatedData = record[relatedFieldName];\n const displayKey = fieldNameToDisplayName.get(relatedFieldName) ?? relatedFieldName;\n\n if (Array.isArray(relatedData)) {\n // For many-to-many or one-to-many\n const values = relatedData\n .map(item => {\n const val = item?.[userKeyFieldName];\n // Convert datetime to ISO if needed\n const relatedFieldMeta = modelFields.find(f => f.name === relatedFieldName);\n if ((relatedFieldMeta?.type === 'datetime' || relatedFieldMeta?.type === 'date') && val) {\n return new Date(val).toISOString();\n }\n return val;\n })\n .filter(Boolean);\n newRecord[displayKey] = values.join(', ');\n } else if (relatedData && typeof relatedData === 'object') {\n let val = relatedData?.[userKeyFieldName] ?? null;\n const relatedFieldMeta = modelFields.find(f => f.name === relatedFieldName);\n if ((relatedFieldMeta?.type === 'datetime' || relatedFieldMeta?.type === 'date') && val) {\n val = new Date(val).toISOString();\n }\n newRecord[displayKey] = val;\n } else {\n newRecord[displayKey] = null;\n }\n }\n return newRecord;\n });\n return cleanedRecords\n }\n }\n\n async toDto(data: Partial<CreateExportTransactionDto>): Promise<CreateExportTransactionDto> {\n const dto = new CreateExportTransactionDto(data);\n const errors = await validate(dto);\n if (errors.length > 0) {\n console.error(\"Validation failed:\", errors);\n return null;\n }\n return dto;\n }\n}\n\nfunction cleanNullsFromObject(obj: any): any {\n if (Array.isArray(obj)) {\n return obj\n .filter(item => item !== null && item !== undefined)\n .map(cleanNullsFromObject);\n } else if (typeof obj === 'object' && obj !== null) {\n const newObj: any = {};\n for (const key in obj) {\n const value = obj[key];\n if (value !== null && value !== undefined) {\n const cleanedValue = cleanNullsFromObject(value);\n // Only assign non-empty objects/arrays or non-null primitives\n if (\n (typeof cleanedValue === 'object' && Object.keys(cleanedValue).length > 0) ||\n (Array.isArray(cleanedValue) && cleanedValue.length > 0) ||\n typeof cleanedValue !== 'object'\n ) {\n newObj[key] = cleanedValue;\n }\n }\n }\n return newObj;\n }\n return obj;\n}\n\n"]}