papermark icon indicating copy to clipboard operation
papermark copied to clipboard

Title: returning same fields three times document overview API

Open himanshu8github opened this issue 6 months ago • 3 comments

noticed a possible issue in the document overview API route.

File: pages/api/teams/[teamId]/documents/[id]/overview.ts this is the response I'm getting which look like repeating. { "document": { "id": "cmp2a4wj202oxjl04dzi6neie", "name": "Unit-14.pdf", "description": null, "file": "cmp29snft04yxjo04xkdhso5g/doc_MF85fwJ7t4z2BQqNJKsJuc/unit-14.pdf", "originalFile": "cmp29snft04yxjo04xkdhso5g/doc_MF85fwJ7t4z2BQqNJKsJuc/unit-14.pdf", "type": "pdf", "contentType": "application/pdf", "storageType": "S3_PATH", "numPages": 18, "ownerId": "cmp29sls10005l204u3b1y2f2", "teamId": "cmp29snft04yxjo04xkdhso5g", "agentsEnabled": false, "advancedExcelEnabled": false, "downloadOnly": false, "createdAt": {}, "updatedAt": {}, "folderId": null, "isExternalUpload": false, "versions": [ { "id": "cmp2a4wj202oyjl04j8sl60jv", "versionNumber": 1, "documentId": "cmp2a4wj202oxjl04dzi6neie", "file": "cmp29snft04yxjo04xkdhso5g/doc_MF85fwJ7t4z2BQqNJKsJuc/unit-14.pdf", "originalFile": "cmp29snft04yxjo04xkdhso5g/doc_MF85fwJ7t4z2BQqNJKsJuc/unit-14.pdf", "type": "pdf", "contentType": "application/pdf", "fileSize": 372438, "storageType": "S3_PATH", "numPages": 18, "isPrimary": true, "isVertical": false, "fileId": null, "vectorStoreFileId": null, "hasPages": false, "length": null, "createdAt": {}, "updatedAt": {} } ], "folder": null, "datarooms": [], "_count": { "links": 0, "views": 0 }, "primaryVersion": { "id": "cmp2a4wj202oyjl04j8sl60jv", "versionNumber": 1, "documentId": "cmp2a4wj202oxjl04dzi6neie", "file": "cmp29snft04yxjo04xkdhso5g/doc_MF85fwJ7t4z2BQqNJKsJuc/unit-14.pdf", "originalFile": "cmp29snft04yxjo04xkdhso5g/doc_MF85fwJ7t4z2BQqNJKsJuc/unit-14.pdf", "type": "pdf", "contentType": "application/pdf", "fileSize": 372438, "storageType": "S3_PATH", "numPages": 18, "isPrimary": true, "isVertical": false, "fileId": null, "vectorStoreFileId": null, "hasPages": false, "length": null, "createdAt": {}, "updatedAt": {} }, "hasPageLinks": false, "isEmpty": true }, "limits": { "canAddLinks": true, "canAddDocuments": true, "canAddUsers": false }, "featureFlags": { "annotations": false }, "team": { "plan": "free", "isTrial": false }, "counts": { "links": 0, "views": 0 } }

Image Image

I wanted to raise this in case it could cause unexpected behavior or typing inconsistencies depending on Prisma version/schema configuration.

Happy to work on a fix if this is considered valid.

himanshu8github avatar May 12 '26 07:05 himanshu8github

i want to work on this if you allow me.

himanshu8github avatar May 12 '26 07:05 himanshu8github

Hi @himanshu8github, if I am getting the issue right data is no repeated, "versions" list contains all the versions and "primaryVersion" version contains the primary version only.

ankit0tech avatar Jun 01 '26 18:06 ankit0tech

fix is in https://github.com/papermark/papermark/pull/2204

overview was sending versions plus primaryVersion (and _count plus counts). response now only has primaryVersion / counts, and the swr types match that.

thedhruvhegde avatar Sep 06 '26 17:09 thedhruvhegde