Merge pull request #28301 from overleaf/ar-fix-tscheck-on-project-helper

[web] Add @ to ts-check annotation in ProjectHelper

GitOrigin-RevId: 3db97fff7e8059f2940b9f446c95ead187d950b2
This commit is contained in:
Andrew Rumble
2025-09-08 09:52:49 +01:00
committed by Copybot
parent 21352c7580
commit e3fb4236be
2 changed files with 21 additions and 9 deletions

View File

@@ -1,4 +1,4 @@
// ts-check
// @ts-check
const { ObjectId } = require('mongodb-legacy')
const _ = require('lodash')
const { promisify } = require('util')
@@ -33,22 +33,22 @@ function compilerFromV1Engine(engine) {
/**
@param {MongoProject} project
@param {string} userId
@param {string} rawUserId
* @returns {boolean}
*/
function isArchived(project, userId) {
userId = new ObjectId(userId)
function isArchived(project, rawUserId) {
const userId = new ObjectId(rawUserId)
return (project.archived || []).some(id => id.equals(userId))
}
/**
* @param {MongoProject} project
* @param {string} userId
* @param {string} rawUserId
* @returns {boolean}
*/
function isTrashed(project, userId) {
userId = new ObjectId(userId)
function isTrashed(project, rawUserId) {
const userId = new ObjectId(rawUserId)
return (project.trashed || []).some(id => id.equals(userId))
}
@@ -62,6 +62,12 @@ function isArchivedOrTrashed(project, userId) {
return isArchived(project, userId) || isTrashed(project, userId)
}
/**
* @param {string[]} nameList
* @param {string} name
* @param {string[]} suffixes
* @param {number} maxLength
*/
function ensureNameIsUnique(nameList, name, suffixes, maxLength, callback) {
// create a set of all project names
if (suffixes == null) {
@@ -98,6 +104,11 @@ function _addSuffixToProjectName(name, suffix, maxLength) {
return name.substr(0, truncatedLength) + suffix
}
/**
* @param {string} name
* @param {Set<string>} allProjectNames
* @param {number} maxLength
*/
function _addNumericSuffixToProjectName(name, allProjectNames, maxLength) {
const NUMERIC_SUFFIX_MATCH = / \((\d+)\)$/
const suffixedName = function (basename, number) {

View File

@@ -3,6 +3,7 @@ import {
GetProjectsRequestBody,
GetProjectsResponseBody,
} from '../../../../types/project/dashboard/api'
import { ObjectId } from 'mongodb-legacy'
export type GetProjectsRequest = express.Request<
unknown,
@@ -19,8 +20,8 @@ export type MongoProject = {
lastUpdated: Date
lastUpdatedBy: string
publicAccesLevel: string
archived: string[]
trashed: boolean
archived: ObjectId[]
trashed: ObjectId[]
owner_ref: string
tokens: {
readOnly: string[]