refactor: enhance DocumentSchema with detailed field descriptions and adjust random sync logic
- Updated DocumentSchema to include detailed descriptions for fields, improving API documentation and usability. - Adjusted the random sync logic threshold from 0.05 to 0.005 to reduce the frequency of sync requests, optimizing performance. - Added new fields for collaboration session management, enhancing document interaction capabilities.
This commit is contained in:
@@ -23,16 +23,37 @@ export class DocumentSchema extends PothosSchema {
|
|||||||
document() {
|
document() {
|
||||||
return this.builder.prismaObject('Document', {
|
return this.builder.prismaObject('Document', {
|
||||||
fields: (t) => ({
|
fields: (t) => ({
|
||||||
id: t.exposeID('id'),
|
id: t.exposeID('id', { description: 'The ID of the document.', nullable: false }),
|
||||||
name: t.exposeString('name'),
|
name: t.exposeString('name', { description: 'The name of the document.', nullable: false }),
|
||||||
fileUrl: t.exposeString('fileUrl'),
|
fileUrl: t.exposeString('fileUrl', { description: 'The file URL of the document.', nullable: false }),
|
||||||
previewImage: t.relation('previewImage', { nullable: true }),
|
previewImage: t.relation('previewImage', {
|
||||||
createdAt: t.expose('createdAt', { type: 'DateTime' }),
|
description: 'The preview image of the document.',
|
||||||
updatedAt: t.expose('updatedAt', { type: 'DateTime' }),
|
nullable: true,
|
||||||
owner: t.relation('owner'),
|
}),
|
||||||
ownerId: t.exposeID('ownerId'),
|
owner: t.relation('owner', { description: 'The owner of the document.', nullable: false }),
|
||||||
collaborators: t.relation('collaborators'),
|
collaborators: t.relation('collaborators', {
|
||||||
isPublic: t.exposeBoolean('isPublic'),
|
description: 'The collaborators of the document.',
|
||||||
|
nullable: false,
|
||||||
|
}),
|
||||||
|
isPublic: t.exposeBoolean('isPublic', { description: 'Whether the document is public.', nullable: false }),
|
||||||
|
collaborationSession: t.relation('collaborationSession', {
|
||||||
|
description: 'The collaboration session of the document.',
|
||||||
|
nullable: true,
|
||||||
|
}),
|
||||||
|
collaborationSessionId: t.exposeID('collaborationSessionId', {
|
||||||
|
description: 'The ID of the collaboration session of the document.',
|
||||||
|
nullable: true,
|
||||||
|
}),
|
||||||
|
createdAt: t.expose('createdAt', {
|
||||||
|
description: 'The creation time of the document.',
|
||||||
|
type: 'DateTime',
|
||||||
|
nullable: false,
|
||||||
|
}),
|
||||||
|
updatedAt: t.expose('updatedAt', {
|
||||||
|
description: 'The update time of the document.',
|
||||||
|
type: 'DateTime',
|
||||||
|
nullable: false,
|
||||||
|
}),
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -524,7 +545,7 @@ export class DocumentSchema extends PothosSchema {
|
|||||||
// using randomize sync mechanism to avoid performance issue
|
// using randomize sync mechanism to avoid performance issue
|
||||||
const random = Math.random()
|
const random = Math.random()
|
||||||
// 0.5% chance to request sync
|
// 0.5% chance to request sync
|
||||||
if (random <= 0.05) {
|
if (random <= 0.005) {
|
||||||
// check grammar too
|
// check grammar too
|
||||||
this.documentService.checkGrammarForPage(payload.documentId, payload.pageIndex)
|
this.documentService.checkGrammarForPage(payload.documentId, payload.pageIndex)
|
||||||
Logger.log('request sync', 'request sync')
|
Logger.log('request sync', 'request sync')
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ async function bootstrap() {
|
|||||||
maxFiles: 10,
|
maxFiles: 10,
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
// biome-ignore lint/suspicious/noExplicitAny: error type should be any to get the error message
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
Logger.error(`Error in file upload middleware: ${error.message}`, 'Bootstrap')
|
Logger.error(`Error in file upload middleware: ${error.message}`, 'Bootstrap')
|
||||||
// Optionally, you can handle the error further or rethrow it
|
// Optionally, you can handle the error further or rethrow it
|
||||||
|
|||||||
Reference in New Issue
Block a user