mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 22:23:42 +01:00
Enable TS noImplicitAny in web (#31636)
GitOrigin-RevId: 18881694770f2476c475f8fef4c6a2678a2a12fe
This commit is contained in:
committed by
Copybot
parent
b3489a6792
commit
6113c6c291
@@ -65,6 +65,10 @@ async function getDanglingThreads(projectId) {
|
||||
return danglingThreads
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any} projectId
|
||||
* @param {any} docId
|
||||
*/
|
||||
const ensureDocExists = async (projectId, docId) => {
|
||||
const doc = await DocstoreManager.promises.getDoc(projectId, docId)
|
||||
if (!doc) {
|
||||
|
||||
@@ -13,6 +13,9 @@ const WRITE_CONCURRENCY = parseInt(process.env.WRITE_CONCURRENCY || '10', 10)
|
||||
|
||||
const mixpanelSinkQueue = getQueue('analytics-mixpanel-sink')
|
||||
|
||||
/**
|
||||
* @param {any} user
|
||||
*/
|
||||
async function processUser(user) {
|
||||
const analyticsId = user.analyticsId || user._id
|
||||
|
||||
@@ -58,6 +61,9 @@ async function processUser(user) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any} userId
|
||||
*/
|
||||
async function _getGroupSubscriptionPlanCode(userId) {
|
||||
const subscriptions =
|
||||
await SubscriptionLocator.promises.getMemberSubscriptions(userId)
|
||||
@@ -77,6 +83,12 @@ async function _getGroupSubscriptionPlanCode(userId) {
|
||||
return bestPlanCode
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any} analyticsId
|
||||
* @param {any} propertyName
|
||||
* @param {any} propertyValue
|
||||
* @param {any} [createdAt]
|
||||
*/
|
||||
async function _sendPropertyToQueue(
|
||||
analyticsId,
|
||||
propertyName,
|
||||
@@ -94,6 +106,10 @@ async function _sendPropertyToQueue(
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any} _
|
||||
* @param {any} users
|
||||
*/
|
||||
async function processBatch(_, users) {
|
||||
await promiseMapWithLimit(WRITE_CONCURRENCY, users, async user => {
|
||||
await processUser(user)
|
||||
|
||||
@@ -149,6 +149,9 @@ function getProjectIds() {
|
||||
.map(x => x._id.toString())
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any} projectId
|
||||
*/
|
||||
async function getDocs(projectId) {
|
||||
const mongoDocs = db.docs.find(
|
||||
{
|
||||
@@ -192,6 +195,10 @@ async function getDocs(projectId) {
|
||||
return docs
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any} projectId
|
||||
* @param {any} docs
|
||||
*/
|
||||
async function findDanglingThreadIds(projectId, docs) {
|
||||
const threadIds = new Set()
|
||||
for (const doc of docs) {
|
||||
@@ -219,6 +226,9 @@ async function findDanglingThreadIds(projectId, docs) {
|
||||
return Array.from(threadIds)
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any} docs
|
||||
*/
|
||||
function docsHaveTrackedChanges(docs) {
|
||||
for (const doc of docs) {
|
||||
const changes = doc.ranges?.changes ?? []
|
||||
@@ -229,6 +239,9 @@ function docsHaveTrackedChanges(docs) {
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any} docs
|
||||
*/
|
||||
function docsHaveAnyComments(docs) {
|
||||
for (const doc of docs) {
|
||||
const comments = doc.ranges?.comments ?? []
|
||||
|
||||
@@ -48,6 +48,9 @@ async function main(trackProgress) {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any} project
|
||||
*/
|
||||
async function processProject(project) {
|
||||
if (DEBUG) {
|
||||
console.log(
|
||||
|
||||
@@ -29,6 +29,9 @@ function parseArgs() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any} projectId
|
||||
*/
|
||||
async function processProject(projectId) {
|
||||
console.log(`Processing project ${projectId}...`)
|
||||
await DocumentUpdaterHandler.promises.flushProjectToMongoAndDelete(projectId)
|
||||
@@ -49,6 +52,11 @@ async function processProject(projectId) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any} projectId
|
||||
* @param {any} doc
|
||||
* @param {any} threadIds
|
||||
*/
|
||||
async function processDoc(projectId, doc, threadIds) {
|
||||
let commentsDeleted = 0
|
||||
for (const comment of doc.ranges?.comments ?? []) {
|
||||
@@ -66,6 +74,10 @@ async function processDoc(projectId, doc, threadIds) {
|
||||
return commentsDeleted
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any} docId
|
||||
* @param {any} threadId
|
||||
*/
|
||||
async function deleteComment(docId, threadId) {
|
||||
await db.docs.updateOne(
|
||||
{ _id: new ObjectId(docId) },
|
||||
|
||||
@@ -24,6 +24,9 @@ function parseArgs() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any} projectId
|
||||
*/
|
||||
async function processProject(projectId) {
|
||||
console.log(`Processing project ${projectId}...`)
|
||||
const docRanges = await DocstoreManager.promises.getAllRanges(projectId)
|
||||
@@ -38,6 +41,9 @@ async function processProject(projectId) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any} doc
|
||||
*/
|
||||
async function processDoc(doc) {
|
||||
let commentsUpdated = 0
|
||||
for (const comment of doc.ranges.comments ?? []) {
|
||||
|
||||
@@ -42,6 +42,9 @@ if (!doNotListUsers) {
|
||||
*/
|
||||
const parseAsync = promisify(csv.parse)
|
||||
|
||||
/**
|
||||
* @param {any} userId
|
||||
*/
|
||||
async function getV1Affiliations(userId) {
|
||||
const url = `${Settings.apis.v1.url}/api/v2/users/${userId}/affiliations`
|
||||
|
||||
@@ -56,6 +59,10 @@ async function getV1Affiliations(userId) {
|
||||
return affiliations
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any} userId
|
||||
* @param {any} email
|
||||
*/
|
||||
async function removeAffiliationV1(userId, email) {
|
||||
const url = `${Settings.apis.v1.url}/api/v2/users/${userId}/affiliations/remove`
|
||||
|
||||
@@ -92,6 +99,9 @@ const results = {
|
||||
errorRemovingAffiliationInV1: [],
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any} trackProgress
|
||||
*/
|
||||
async function main(trackProgress) {
|
||||
console.time('check_removed_emails')
|
||||
|
||||
@@ -99,6 +109,7 @@ async function main(trackProgress) {
|
||||
const csvContent = await fs.readFile(filePath, 'utf8')
|
||||
const rows = await parseAsync(csvContent)
|
||||
rows.shift() // Remove header row
|
||||
/** @type {Record<string, string[]>} */
|
||||
const emailsByUserId = {}
|
||||
|
||||
for (const [userId, email] of rows) {
|
||||
@@ -124,12 +135,12 @@ async function main(trackProgress) {
|
||||
// nothing to cleanup in v1 if no affiliations for the user
|
||||
continue
|
||||
}
|
||||
} catch (e) {
|
||||
} catch (/** @type {any} */ e) {
|
||||
results.errorCheckingAffiliations.push(userId)
|
||||
}
|
||||
|
||||
const affiliationsEmailsInV1 = affiliations.map(
|
||||
affiliation => affiliation.email
|
||||
(/** @type {any} */ affiliation) => affiliation.email
|
||||
)
|
||||
|
||||
const user = await db.users.findOne(
|
||||
@@ -151,7 +162,9 @@ async function main(trackProgress) {
|
||||
continue
|
||||
}
|
||||
|
||||
const emailOnAccount = user?.emails?.find(e => e.email === email)
|
||||
const emailOnAccount = user?.emails?.find(
|
||||
(/** @type {any} */ e) => e.email === email
|
||||
)
|
||||
|
||||
if (emailOnAccount) {
|
||||
// the email is still on the user account, we should not remove the affiliation in v1
|
||||
@@ -181,7 +194,7 @@ async function main(trackProgress) {
|
||||
// remove the affiliation in v1
|
||||
await removeAffiliationV1(userId, email)
|
||||
results.successfullyRemovedEmailInV1ForUser.push({ userId, email })
|
||||
} catch (e) {
|
||||
} catch (/** @type {any} */ e) {
|
||||
results.errorRemovingAffiliationInV1.push({
|
||||
userId,
|
||||
email,
|
||||
@@ -200,18 +213,18 @@ async function main(trackProgress) {
|
||||
|
||||
console.log('Results:')
|
||||
for (const key in results) {
|
||||
console.log(` ${key}:`, results[key].length)
|
||||
console.log(` ${key}:`, /** @type {any} */ (results)[key].length)
|
||||
}
|
||||
for (const key in results) {
|
||||
if (
|
||||
!doNotListUsers &&
|
||||
results[key].length > 0 &&
|
||||
/** @type {any} */ (results)[key].length > 0 &&
|
||||
key !== 'needToRemoveEmailInV1'
|
||||
) {
|
||||
// skip needToRemoveEmailInV1 since we'll only output that if this list length does not match success list length
|
||||
console.log('----------------------------')
|
||||
console.log(`${key}:`)
|
||||
console.log(results[key])
|
||||
console.log(/** @type {any} */ (results)[key])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ async function main() {
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
/** @type {Record<string, any>} */
|
||||
const localizedAddOnsPricing = {}
|
||||
|
||||
const monthlyPlan = await getPlan(ADD_ON_CODE)
|
||||
@@ -22,10 +23,12 @@ async function main() {
|
||||
process.exit(1)
|
||||
}
|
||||
for (const { currency, unitAmount } of monthlyPlan.currencies ?? []) {
|
||||
if (!localizedAddOnsPricing[currency]) {
|
||||
localizedAddOnsPricing[currency] = { [ADD_ON_CODE]: {} }
|
||||
/** @type {any} */
|
||||
const curr = currency
|
||||
if (!localizedAddOnsPricing[curr]) {
|
||||
localizedAddOnsPricing[curr] = { [ADD_ON_CODE]: {} }
|
||||
}
|
||||
localizedAddOnsPricing[currency][ADD_ON_CODE].monthly = unitAmount
|
||||
localizedAddOnsPricing[curr][ADD_ON_CODE].monthly = unitAmount
|
||||
}
|
||||
|
||||
const annualPlan = await getPlan(`${ADD_ON_CODE}-annual`)
|
||||
@@ -34,11 +37,13 @@ async function main() {
|
||||
process.exit(1)
|
||||
}
|
||||
for (const { currency, unitAmount } of annualPlan.currencies ?? []) {
|
||||
if (!localizedAddOnsPricing[currency]) {
|
||||
localizedAddOnsPricing[currency] = { [ADD_ON_CODE]: {} }
|
||||
/** @type {any} */
|
||||
const curr = currency
|
||||
if (!localizedAddOnsPricing[curr]) {
|
||||
localizedAddOnsPricing[curr] = { [ADD_ON_CODE]: {} }
|
||||
}
|
||||
localizedAddOnsPricing[currency][ADD_ON_CODE].annual = unitAmount
|
||||
localizedAddOnsPricing[currency][ADD_ON_CODE].annualDividedByTwelve =
|
||||
localizedAddOnsPricing[curr][ADD_ON_CODE].annual = unitAmount
|
||||
localizedAddOnsPricing[curr][ADD_ON_CODE].annualDividedByTwelve =
|
||||
(unitAmount || 0) / 12
|
||||
}
|
||||
|
||||
|
||||
@@ -73,6 +73,9 @@ function usage() {
|
||||
where FILE contains the list of subscription ids that are manually collected`)
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any} filename
|
||||
*/
|
||||
function readFile(filename) {
|
||||
const contents = fs.readFileSync(filename, { encoding: 'utf-8' })
|
||||
const subscriptionIds = contents.split('\n').filter(id => id.length > 0)
|
||||
|
||||
@@ -62,6 +62,7 @@ async function getExistingPrices(stripe) {
|
||||
let startingAfter
|
||||
|
||||
do {
|
||||
/** @type {any} */
|
||||
const response = await stripe.prices.list({
|
||||
limit: 100,
|
||||
starting_after: startingAfter,
|
||||
@@ -89,6 +90,7 @@ async function getExistingProducts(stripe) {
|
||||
let startingAfter
|
||||
|
||||
do {
|
||||
/** @type {any} */
|
||||
const response = await stripe.products.list({
|
||||
limit: 100,
|
||||
starting_after: startingAfter,
|
||||
@@ -104,6 +106,9 @@ async function getExistingProducts(stripe) {
|
||||
return productsById
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any} trackProgress
|
||||
*/
|
||||
export async function main(trackProgress) {
|
||||
const args = minimist(process.argv.slice(2), {
|
||||
boolean: ['commit'],
|
||||
@@ -175,7 +180,10 @@ export async function main(trackProgress) {
|
||||
record.productName ||
|
||||
planCode
|
||||
.split(/[_-]/) // Handle underscores or hyphens
|
||||
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
|
||||
.map(
|
||||
/** @param {any} word */
|
||||
word => word.charAt(0).toUpperCase() + word.slice(1)
|
||||
)
|
||||
.join(' ')
|
||||
|
||||
if (commit) {
|
||||
@@ -203,7 +211,7 @@ export async function main(trackProgress) {
|
||||
|
||||
// 2. Handle Prices for each currency column
|
||||
for (const currency of currencyKeys) {
|
||||
const amountValue = parseFloat(record[currency])
|
||||
const amountValue = parseFloat(/** @type {any} */ (record)[currency])
|
||||
if (isNaN(amountValue) || amountValue <= 0) continue
|
||||
|
||||
const currencyLower = currency.toLowerCase()
|
||||
|
||||
Reference in New Issue
Block a user