Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • develop-beta
  • feature/HCP-713-HCP-705-dms-api-changes-liquibase-file-upload
  • feature/fetch-document-by-id
  • fetch-document
  • master
  • uploadDocsAPI
6 results

Target

Select target project
  • roshan.suvarnkar/dms-service
1 result
Select Git revision
  • develop-beta
  • feature/HCP-713-HCP-705-dms-api-changes-liquibase-file-upload
  • feature/fetch-document-by-id
  • fetch-document
  • master
  • uploadDocsAPI
6 results
Show changes

Commits on Source 3

......@@ -38,6 +38,8 @@ export default [
},
rules: {
...safeGoogleRules,
"object-curly-spacing": ["error", "always"],
'new-cap': ['error', {
newIsCap: true,
capIsNew: false, // Allow capitalized functions like decorators
......
......@@ -55,7 +55,48 @@ while ((modelMatch = modelRegex.exec(schema)) !== null) {
enums[name] ?? types[name] ?? ''
);
const fileContent = [...dependencyBlocks, modelBlock].join('\n\n');
let enhancedModelBlock = modelBlock;
enhancedModelBlock = enhancedModelBlock.replace(
/^(\s*)(\w+)\s+String(.*?)$/gm,
(match, indent, field, rest) => {
const isIdField = field.toLowerCase() === 'id' || field.toLowerCase().endsWith('_id');
const alreadyHasId = /@id/.test(rest);
const alreadyHasDefault = /@default/.test(rest);
const alreadyHasDb = /@db\./.test(rest);
if (isIdField && alreadyHasId) {
return `${indent}${field} String @id @default(uuid()) @db.Uuid`;
}
return match;
}
);
// Enhance createdAt field
enhancedModelBlock = enhancedModelBlock.replace(
/^(\s*)(created_at|createdAt)\s+DateTime(.*?)$/gim,
(match, indent, field, rest) => {
const alreadyHasDefault = /@default\(.+\)/.test(rest);
if (!alreadyHasDefault) {
return `${indent}${field} DateTime @default(now())`;
}
return match;
}
);
// Enhance updatedAt field
enhancedModelBlock = enhancedModelBlock.replace(
/^(\s*)(updated_at|updatedAt)\s+DateTime(.*?)$/gim,
(match, indent, field, rest) => {
const alreadyHasUpdatedAt = /@updatedAt/.test(rest);
if (!alreadyHasUpdatedAt) {
return `${indent}${field} DateTime @updatedAt`;
}
return match;
}
);
enhancedModelBlock = alignModelBlock(enhancedModelBlock);
const fileContent = [...dependencyBlocks, enhancedModelBlock].join('\n\n');
const outputPath = path.join(outputDir, `${modelName}.prisma`);
fs.writeFileSync(outputPath, fileContent, 'utf-8');
......@@ -76,3 +117,37 @@ while ((modelMatch = modelRegex.exec(schema)) !== null) {
// fs.writeFileSync(inputPath, headerBlocks + '\n');
fs.writeFileSync(inputPath, '' + '\n');
console.log(`Cleaned introspected.prisma (preserved generator & datasource)`);
function alignModelBlock(block: string): string {
const lines = block.trim().split('\n');
const modelStart = lines[0]; // should be `model Something {`
const modelEnd = lines[lines.length - 1]; // should be `}`
const fieldLines = lines.slice(1, -1);
let maxField = 0;
let maxType = 0;
for (const line of fieldLines) {
const match = line.trim().match(/^(\w+)\s+([^\s\[\]]+)(\s|\[|$)/);
if (match) {
maxField = Math.max(maxField, match[1].length);
maxType = Math.max(maxType, match[2].length);
}
}
const formattedFields = fieldLines.map(line => {
const trimmed = line.trim();
const match = trimmed.match(/^(\w+)\s+([^\s\[\]]+)(.*)/);
if (!match) return ' ' + trimmed;
const [, field, type, rest] = match;
const paddedField = field.padEnd(maxField + 1);
const paddedType = type.padEnd(maxType + 1);
return ` ${paddedField}${paddedType}${rest.trim()}`;
});
return [modelStart, ...formattedFields, modelEnd].join('\n');
}
......@@ -7,7 +7,6 @@
import {
Injectable,
NotFoundException,
} from '@nestjs/common';
import {
PrismaService,
......@@ -136,12 +135,13 @@ export class DocumentService {
},
);
if (!document) throw new NotFoundException('Document not found');
if (!document) throw new AppException('404', 'Document not found');
try {
// const file = await this.fileNetClient.get(document.document_id);//mock
if (document.source === 'FILENET') {
// Mock behavior: return presigned URL if available, otherwise return file content
// Mock behavior: return presigned URL if available,
// otherwise return file content
const usePresignedUrl = document.document_link !== null;
if (usePresignedUrl) {
......