Răsfoiți Sursa

Adding types to github sync export handler and up the stack (#31390)

* Adding types to github sync export handler and up the stack

* promsifying file and addressing review comments

* reverting tsconfig and updating response type

* importing correct type

* reverting Jenkinsfile to main

GitOrigin-RevId: 96496920b8faf38fc32ffedb6fc4b8d6596d4112
l-obrien-overleaf 5 luni în urmă
părinte
comite
92d7077878

+ 10 - 0
services/web/app/src/Features/Project/ProjectEntityHandler.mjs

@@ -6,6 +6,12 @@ import { callbackifyAll } from '@overleaf/promise-utils'
 import OError from '@overleaf/o-error'
 import { iterablePaths } from './IterablePath.mjs'
 
+/** @import {ProjectDoc, ProjectFile} from './types' */
+
+/**
+ * @param {string} projectId
+ * @returns {Promise<Record<string, ProjectDoc>>}
+ */
 async function getAllDocs(projectId) {
   // We get the path and name info from the project, and the lines and
   // version info from the doc store.
@@ -37,6 +43,10 @@ async function getAllDocs(projectId) {
   return docs
 }
 
+/**
+ * @param {string} projectId
+ * @returns {Promise<Record<string, ProjectFile>>}
+ */
 async function getAllFiles(projectId) {
   const folders = await _getAllFolders(projectId)
   const files = {}

+ 17 - 0
services/web/app/src/Features/Project/types.d.ts

@@ -5,6 +5,7 @@ import {
   ProjectAccessLevel,
   UserRef,
 } from '../../../../types/project/dashboard/api'
+import { Folder } from '../../../../types/folder'
 import { ObjectId } from 'mongodb-legacy'
 import { Source } from '../Authorization/types'
 
@@ -62,3 +63,19 @@ export type FormattedProject = {
   accessLevel: ProjectAccessLevel
   source: Source
 }
+
+export type ProjectDoc = {
+  _id: ObjectId
+  name: string
+  lines: string[]
+  rev: number
+  folder: Folder
+}
+
+export type ProjectFile = {
+  _id: ObjectId
+  name: string
+  hash: string
+  rev: number
+  folder: Folder
+}