From fb0fa171beba9f77cd7f760494165fe5ba49fc76 Mon Sep 17 00:00:00 2001 From: Sasha <64744993+r1tsuu@users.noreply.github.com> Date: Mon, 17 Feb 2025 23:16:46 +0200 Subject: [PATCH] chore(db-mongodb): enable `strict: true` --- packages/db-mongodb/package.json | 1 + packages/db-mongodb/src/connect.ts | 8 +++- packages/db-mongodb/src/count.ts | 9 +++- .../db-mongodb/src/countGlobalVersions.ts | 8 +++- packages/db-mongodb/src/countVersions.ts | 9 +++- packages/db-mongodb/src/create.ts | 24 +++++++--- packages/db-mongodb/src/createGlobal.ts | 13 +++++- .../db-mongodb/src/createGlobalVersion.ts | 27 +++++++---- packages/db-mongodb/src/createMigration.ts | 5 ++- packages/db-mongodb/src/createVersion.ts | 22 +++++---- packages/db-mongodb/src/deleteMany.ts | 8 +++- packages/db-mongodb/src/deleteOne.ts | 20 +++++++-- packages/db-mongodb/src/deleteVersions.ts | 6 ++- packages/db-mongodb/src/find.ts | 27 +++++++---- packages/db-mongodb/src/findGlobal.ts | 15 +++++-- packages/db-mongodb/src/findGlobalVersions.ts | 31 ++++++++----- packages/db-mongodb/src/findOne.ts | 22 ++++++--- packages/db-mongodb/src/findVersions.ts | 36 ++++++++++++--- packages/db-mongodb/src/index.ts | 7 +-- packages/db-mongodb/src/migrateFresh.ts | 2 - .../db-mongodb/src/queries/buildSortParam.ts | 2 +- packages/db-mongodb/src/queryDrafts.ts | 43 ++++++++++++++---- packages/db-mongodb/src/updateGlobal.ts | 16 +++++-- .../db-mongodb/src/updateGlobalVersion.ts | 23 ++++++++-- packages/db-mongodb/src/updateOne.ts | 33 +++++++++++--- packages/db-mongodb/src/updateVersion.ts | 37 ++++++++++----- .../src/utilities/buildJoinAggregation.ts | 6 +-- .../db-mongodb/src/utilities/handleError.ts | 13 ++++-- packages/db-mongodb/tsconfig.json | 5 --- pnpm-lock.yaml | 45 ++++++++++--------- 30 files changed, 378 insertions(+), 145 deletions(-) diff --git a/packages/db-mongodb/package.json b/packages/db-mongodb/package.json index 6e73ea67aa0..d1b8187fd54 100644 --- a/packages/db-mongodb/package.json +++ b/packages/db-mongodb/package.json @@ -55,6 +55,7 @@ "devDependencies": { "@payloadcms/eslint-config": "workspace:*", "@types/mongoose-aggregate-paginate-v2": "1.0.12", + "@types/prompts": "^2.4.5", "mongodb": "6.12.0", "mongodb-memory-server": "^10", "payload": "workspace:*" diff --git a/packages/db-mongodb/src/connect.ts b/packages/db-mongodb/src/connect.ts index 57eea475b86..040c0c1ab95 100644 --- a/packages/db-mongodb/src/connect.ts +++ b/packages/db-mongodb/src/connect.ts @@ -70,9 +70,15 @@ export const connect: Connect = async function connect( await this.migrate({ migrations: this.prodMigrations }) } } catch (err) { + let msg = `Error: cannot connect to MongoDB.` + + if (typeof err === 'object' && err && 'message' in err && typeof err.message === 'string') { + msg = `${msg} Details: ${err.message}` + } + this.payload.logger.error({ err, - msg: `Error: cannot connect to MongoDB. Details: ${err.message}`, + msg, }) process.exit(1) } diff --git a/packages/db-mongodb/src/count.ts b/packages/db-mongodb/src/count.ts index 7d313461bbb..d2d428df6cd 100644 --- a/packages/db-mongodb/src/count.ts +++ b/packages/db-mongodb/src/count.ts @@ -1,7 +1,7 @@ import type { CountOptions } from 'mongodb' import type { Count } from 'payload' -import { flattenWhereToOperators } from 'payload' +import { APIError, flattenWhereToOperators } from 'payload' import type { MongooseAdapter } from './index.js' @@ -9,9 +9,14 @@ import { getSession } from './utilities/getSession.js' export const count: Count = async function count( this: MongooseAdapter, - { collection, locale, req, where }, + { collection, locale, req, where = {} }, ) { const Model = this.collections[collection] + + if (!Model) { + throw new APIError(`Could not find collection model with the name ${collection}`) + } + const options: CountOptions = { session: await getSession(this, req), } diff --git a/packages/db-mongodb/src/countGlobalVersions.ts b/packages/db-mongodb/src/countGlobalVersions.ts index 296f2ca0771..3d3950e8edc 100644 --- a/packages/db-mongodb/src/countGlobalVersions.ts +++ b/packages/db-mongodb/src/countGlobalVersions.ts @@ -1,7 +1,7 @@ import type { CountOptions } from 'mongodb' import type { CountGlobalVersions } from 'payload' -import { flattenWhereToOperators } from 'payload' +import { APIError, flattenWhereToOperators } from 'payload' import type { MongooseAdapter } from './index.js' @@ -9,13 +9,17 @@ import { getSession } from './utilities/getSession.js' export const countGlobalVersions: CountGlobalVersions = async function countGlobalVersions( this: MongooseAdapter, - { global, locale, req, where }, + { global, locale, req, where = {} }, ) { const Model = this.versions[global] const options: CountOptions = { session: await getSession(this, req), } + if (!Model) { + throw new APIError(`Could not find global ${global} version Mongoose model`) + } + let hasNearConstraint = false if (where) { diff --git a/packages/db-mongodb/src/countVersions.ts b/packages/db-mongodb/src/countVersions.ts index 0b91f94ac65..062a983b4ea 100644 --- a/packages/db-mongodb/src/countVersions.ts +++ b/packages/db-mongodb/src/countVersions.ts @@ -1,7 +1,7 @@ import type { CountOptions } from 'mongodb' import type { CountVersions } from 'payload' -import { flattenWhereToOperators } from 'payload' +import { APIError, flattenWhereToOperators } from 'payload' import type { MongooseAdapter } from './index.js' @@ -9,9 +9,14 @@ import { getSession } from './utilities/getSession.js' export const countVersions: CountVersions = async function countVersions( this: MongooseAdapter, - { collection, locale, req, where }, + { collection, locale, req, where = {} }, ) { const Model = this.versions[collection] + + if (!Model) { + throw new APIError(`Could not find collection ${collection} version Mongoose model`) + } + const options: CountOptions = { session: await getSession(this, req), } diff --git a/packages/db-mongodb/src/create.ts b/packages/db-mongodb/src/create.ts index 49e549b7e47..c58f64484f4 100644 --- a/packages/db-mongodb/src/create.ts +++ b/packages/db-mongodb/src/create.ts @@ -1,5 +1,6 @@ import type { CreateOptions } from 'mongoose' -import type { Create, Document } from 'payload' + +import { APIError, type Create, type Document } from 'payload' import type { MongooseAdapter } from './index.js' @@ -9,29 +10,40 @@ import { sanitizeRelationshipIDs } from './utilities/sanitizeRelationshipIDs.js' export const create: Create = async function create( this: MongooseAdapter, - { collection, data, req }, + { collection: collectionSlug, data, req }, ) { - const Model = this.collections[collection] + const Model = this.collections[collectionSlug] + + if (!Model) { + throw new APIError(`Could not find collection ${collectionSlug} Mongoose model`) + } + const options: CreateOptions = { session: await getSession(this, req), } let doc + const collection = this.payload.collections[collectionSlug] + + if (!collection) { + throw new APIError(`Could not find collection ${collectionSlug}`) + } + const sanitizedData = sanitizeRelationshipIDs({ config: this.payload.config, data, - fields: this.payload.collections[collection].config.fields, + fields: collection.config.fields, }) - if (this.payload.collections[collection].customIDType) { + if (collection.customIDType) { sanitizedData._id = sanitizedData.id } try { ;[doc] = await Model.create([sanitizedData], options) } catch (error) { - handleError({ collection, error, req }) + handleError({ collection: collectionSlug, error, req }) } // doc.toJSON does not do stuff like converting ObjectIds to string, or date strings to date objects. That's why we use JSON.parse/stringify here diff --git a/packages/db-mongodb/src/createGlobal.ts b/packages/db-mongodb/src/createGlobal.ts index 969eeaed7ca..6a5c0414e65 100644 --- a/packages/db-mongodb/src/createGlobal.ts +++ b/packages/db-mongodb/src/createGlobal.ts @@ -1,5 +1,6 @@ import type { CreateOptions } from 'mongoose' -import type { CreateGlobal } from 'payload' + +import { APIError, type CreateGlobal } from 'payload' import type { MongooseAdapter } from './index.js' @@ -13,13 +14,21 @@ export const createGlobal: CreateGlobal = async function createGlobal( ) { const Model = this.globals + const globalConfig = this.payload.config.globals.find( + (globalConfig) => globalConfig.slug === slug, + ) + + if (!globalConfig) { + throw new APIError(`Could not find global with slug ${slug}`) + } + const global = sanitizeRelationshipIDs({ config: this.payload.config, data: { globalType: slug, ...data, }, - fields: this.payload.config.globals.find((globalConfig) => globalConfig.slug === slug).fields, + fields: globalConfig.fields, }) const options: CreateOptions = { diff --git a/packages/db-mongodb/src/createGlobalVersion.ts b/packages/db-mongodb/src/createGlobalVersion.ts index a6fe7ccb5f4..2683b77825b 100644 --- a/packages/db-mongodb/src/createGlobalVersion.ts +++ b/packages/db-mongodb/src/createGlobalVersion.ts @@ -1,6 +1,9 @@ -import type { CreateOptions } from 'mongoose' - -import { buildVersionGlobalFields, type CreateGlobalVersion, type Document } from 'payload' +import { + APIError, + buildVersionGlobalFields, + type CreateGlobalVersion, + type Document, +} from 'payload' import type { MongooseAdapter } from './index.js' @@ -22,7 +25,18 @@ export const createGlobalVersion: CreateGlobalVersion = async function createGlo }, ) { const VersionModel = this.versions[globalSlug] - const options: CreateOptions = { + + if (!VersionModel) { + throw new APIError(`Could not find global ${globalSlug} version Mongoose model`) + } + + const globalConfig = this.payload.config.globals.find((global) => global.slug === globalSlug) + + if (!globalConfig) { + throw new APIError(`Could not find global with slug ${globalSlug}`) + } + + const options = { session: await getSession(this, req), } @@ -38,10 +52,7 @@ export const createGlobalVersion: CreateGlobalVersion = async function createGlo updatedAt, version: versionData, }, - fields: buildVersionGlobalFields( - this.payload.config, - this.payload.config.globals.find((global) => global.slug === globalSlug), - ), + fields: buildVersionGlobalFields(this.payload.config, globalConfig), }) const [doc] = await VersionModel.create([data], options, req) diff --git a/packages/db-mongodb/src/createMigration.ts b/packages/db-mongodb/src/createMigration.ts index ae54ba1a683..61b0da7aa66 100644 --- a/packages/db-mongodb/src/createMigration.ts +++ b/packages/db-mongodb/src/createMigration.ts @@ -42,8 +42,9 @@ export const createMigration: CreateMigration = async function createMigration({ const migrationFileContent = migrationTemplate(predefinedMigration) const [yyymmdd, hhmmss] = new Date().toISOString().split('T') - const formattedDate = yyymmdd.replace(/\D/g, '') - const formattedTime = hhmmss.split('.')[0].replace(/\D/g, '') + + const formattedDate = yyymmdd!.replace(/\D/g, '') + const formattedTime = hhmmss!.split('.')[0]!.replace(/\D/g, '') const timestamp = `${formattedDate}_${formattedTime}` diff --git a/packages/db-mongodb/src/createVersion.ts b/packages/db-mongodb/src/createVersion.ts index 3482345e24c..34604554e1b 100644 --- a/packages/db-mongodb/src/createVersion.ts +++ b/packages/db-mongodb/src/createVersion.ts @@ -1,7 +1,5 @@ -import type { CreateOptions } from 'mongoose' - import { Types } from 'mongoose' -import { buildVersionCollectionFields, type CreateVersion, type Document } from 'payload' +import { APIError, buildVersionCollectionFields, type CreateVersion, type Document } from 'payload' import type { MongooseAdapter } from './index.js' @@ -23,7 +21,18 @@ export const createVersion: CreateVersion = async function createVersion( }, ) { const VersionModel = this.versions[collectionSlug] - const options: CreateOptions = { + + if (!VersionModel) { + throw new APIError(`Could not find collection ${collectionSlug} version Mongoose model`) + } + + const collection = this.payload.collections[collectionSlug] + + if (!collection) { + throw new APIError(`Could not find collection ${collectionSlug}`) + } + + const options = { session: await getSession(this, req), } @@ -39,10 +48,7 @@ export const createVersion: CreateVersion = async function createVersion( updatedAt, version: versionData, }, - fields: buildVersionCollectionFields( - this.payload.config, - this.payload.collections[collectionSlug].config, - ), + fields: buildVersionCollectionFields(this.payload.config, collection.config), }) const [doc] = await VersionModel.create([data], options, req) diff --git a/packages/db-mongodb/src/deleteMany.ts b/packages/db-mongodb/src/deleteMany.ts index cdc5470e9b1..9ed2cbb3f17 100644 --- a/packages/db-mongodb/src/deleteMany.ts +++ b/packages/db-mongodb/src/deleteMany.ts @@ -1,5 +1,6 @@ import type { DeleteOptions } from 'mongodb' -import type { DeleteMany } from 'payload' + +import { APIError, type DeleteMany } from 'payload' import type { MongooseAdapter } from './index.js' @@ -10,6 +11,11 @@ export const deleteMany: DeleteMany = async function deleteMany( { collection, req, where }, ) { const Model = this.collections[collection] + + if (!Model) { + throw new APIError(`Could not find collection ${collection} Mongoose model`) + } + const options: DeleteOptions = { session: await getSession(this, req), } diff --git a/packages/db-mongodb/src/deleteOne.ts b/packages/db-mongodb/src/deleteOne.ts index 3d9bc07f08f..c9ccbacfe90 100644 --- a/packages/db-mongodb/src/deleteOne.ts +++ b/packages/db-mongodb/src/deleteOne.ts @@ -1,5 +1,6 @@ import type { QueryOptions } from 'mongoose' -import type { DeleteOne, Document } from 'payload' + +import { APIError, type DeleteOne, type Document } from 'payload' import type { MongooseAdapter } from './index.js' @@ -9,13 +10,24 @@ import { sanitizeInternalFields } from './utilities/sanitizeInternalFields.js' export const deleteOne: DeleteOne = async function deleteOne( this: MongooseAdapter, - { collection, req, select, where }, + { collection: collectionSlug, req, select, where }, ) { - const Model = this.collections[collection] + const Model = this.collections[collectionSlug] + + if (!Model) { + throw new APIError(`Could not find collection ${collectionSlug} Mongoose model`) + } + + const collection = this.payload.collections[collectionSlug] + + if (!collection) { + throw new APIError(`Could not find collection ${collectionSlug}`) + } + const options: QueryOptions = { projection: buildProjectionFromSelect({ adapter: this, - fields: this.payload.collections[collection].config.flattenedFields, + fields: collection.config.flattenedFields, select, }), session: await getSession(this, req), diff --git a/packages/db-mongodb/src/deleteVersions.ts b/packages/db-mongodb/src/deleteVersions.ts index 5ee111f3a8f..901259f02e2 100644 --- a/packages/db-mongodb/src/deleteVersions.ts +++ b/packages/db-mongodb/src/deleteVersions.ts @@ -1,4 +1,4 @@ -import type { DeleteVersions } from 'payload' +import { APIError, type DeleteVersions } from 'payload' import type { MongooseAdapter } from './index.js' @@ -10,6 +10,10 @@ export const deleteVersions: DeleteVersions = async function deleteVersions( ) { const VersionsModel = this.versions[collection] + if (!VersionsModel) { + throw new APIError(`Could not find collection ${collection} version Mongoose model`) + } + const session = await getSession(this, req) const query = await VersionsModel.buildQuery({ diff --git a/packages/db-mongodb/src/find.ts b/packages/db-mongodb/src/find.ts index d953c3484f2..e2118e64770 100644 --- a/packages/db-mongodb/src/find.ts +++ b/packages/db-mongodb/src/find.ts @@ -1,7 +1,7 @@ import type { PaginateOptions } from 'mongoose' import type { Find } from 'payload' -import { flattenWhereToOperators } from 'payload' +import { APIError, flattenWhereToOperators } from 'payload' import type { MongooseAdapter } from './index.js' @@ -14,7 +14,7 @@ import { sanitizeInternalFields } from './utilities/sanitizeInternalFields.js' export const find: Find = async function find( this: MongooseAdapter, { - collection, + collection: collectionSlug, joins = {}, limit = 0, locale, @@ -24,11 +24,22 @@ export const find: Find = async function find( req, select, sort: sortArg, - where, + where = {}, }, ) { - const Model = this.collections[collection] - const collectionConfig = this.payload.collections[collection].config + const Model = this.collections[collectionSlug] + + if (!Model) { + throw new APIError(`Could not find collection ${collectionSlug} Mongoose model`) + } + + const collection = this.payload.collections[collectionSlug] + + if (!collection) { + throw new APIError(`Could not find collection ${collectionSlug}`) + } + + const collectionConfig = collection.config const session = await getSession(this, req) @@ -105,7 +116,7 @@ export const find: Find = async function find( if (limit >= 0) { paginationOptions.limit = limit // limit must also be set here, it's ignored when pagination is false - paginationOptions.options.limit = limit + paginationOptions.options!.limit = limit // Disable pagination if limit is 0 if (limit === 0) { @@ -117,7 +128,7 @@ export const find: Find = async function find( const aggregate = await buildJoinAggregation({ adapter: this, - collection, + collection: collectionSlug, collectionConfig, joins, locale, @@ -130,7 +141,7 @@ export const find: Find = async function find( result = await Model.paginate(query, paginationOptions) } - const docs = JSON.parse(JSON.stringify(result.docs)) + const docs = JSON.parse(JSON.stringify(result.docs)) as any[] return { ...result, diff --git a/packages/db-mongodb/src/findGlobal.ts b/packages/db-mongodb/src/findGlobal.ts index ec51dba5b13..ae966575e43 100644 --- a/packages/db-mongodb/src/findGlobal.ts +++ b/packages/db-mongodb/src/findGlobal.ts @@ -1,7 +1,7 @@ import type { QueryOptions } from 'mongoose' import type { FindGlobal } from 'payload' -import { combineQueries } from 'payload' +import { APIError, combineQueries } from 'payload' import type { MongooseAdapter } from './index.js' @@ -11,14 +11,23 @@ import { sanitizeInternalFields } from './utilities/sanitizeInternalFields.js' export const findGlobal: FindGlobal = async function findGlobal( this: MongooseAdapter, - { slug, locale, req, select, where }, + { slug, locale, req, select, where = {} }, ) { const Model = this.globals + + const globalConfig = this.payload.config.globals.find( + (globalConfig) => globalConfig.slug === slug, + ) + + if (!globalConfig) { + throw new APIError(`Could not find global with slug ${slug}`) + } + const options: QueryOptions = { lean: true, select: buildProjectionFromSelect({ adapter: this, - fields: this.payload.globals.config.find((each) => each.slug === slug).flattenedFields, + fields: globalConfig.flattenedFields, select, }), session: await getSession(this, req), diff --git a/packages/db-mongodb/src/findGlobalVersions.ts b/packages/db-mongodb/src/findGlobalVersions.ts index 3166d894140..3a874340e8a 100644 --- a/packages/db-mongodb/src/findGlobalVersions.ts +++ b/packages/db-mongodb/src/findGlobalVersions.ts @@ -1,7 +1,7 @@ import type { PaginateOptions, QueryOptions } from 'mongoose' import type { FindGlobalVersions } from 'payload' -import { buildVersionGlobalFields, flattenWhereToOperators } from 'payload' +import { APIError, buildVersionGlobalFields, flattenWhereToOperators } from 'payload' import type { MongooseAdapter } from './index.js' @@ -12,15 +12,24 @@ import { sanitizeInternalFields } from './utilities/sanitizeInternalFields.js' export const findGlobalVersions: FindGlobalVersions = async function findGlobalVersions( this: MongooseAdapter, - { global, limit, locale, page, pagination, req, select, skip, sort: sortArg, where }, + { global: slug, limit, locale, page, pagination, req, select, skip, sort: sortArg, where = {} }, ) { - const Model = this.versions[global] - const versionFields = buildVersionGlobalFields( - this.payload.config, - this.payload.globals.config.find(({ slug }) => slug === global), - true, + const Model = this.versions[slug] + + if (!Model) { + throw new APIError(`Could not find global ${slug} version Mongoose model`) + } + + const globalConfig = this.payload.config.globals.find( + (globalConfig) => globalConfig.slug === slug, ) + if (!globalConfig) { + throw new APIError(`Could not find global with slug ${slug}`) + } + + const versionFields = buildVersionGlobalFields(this.payload.config, globalConfig, true) + const session = await getSession(this, req) const options: QueryOptions = { limit, @@ -47,7 +56,7 @@ export const findGlobalVersions: FindGlobalVersions = async function findGlobalV } const query = await Model.buildQuery({ - globalSlug: global, + globalSlug: slug, locale, payload: this.payload, where, @@ -90,10 +99,10 @@ export const findGlobalVersions: FindGlobalVersions = async function findGlobalV } } - if (limit >= 0) { + if (limit && limit >= 0) { paginationOptions.limit = limit // limit must also be set here, it's ignored when pagination is false - paginationOptions.options.limit = limit + paginationOptions.options!.limit = limit // Disable pagination if limit is 0 if (limit === 0) { @@ -102,7 +111,7 @@ export const findGlobalVersions: FindGlobalVersions = async function findGlobalV } const result = await Model.paginate(query, paginationOptions) - const docs = JSON.parse(JSON.stringify(result.docs)) + const docs = JSON.parse(JSON.stringify(result.docs)) as any[] return { ...result, diff --git a/packages/db-mongodb/src/findOne.ts b/packages/db-mongodb/src/findOne.ts index 10d13b6fcf6..0bd309a6c0a 100644 --- a/packages/db-mongodb/src/findOne.ts +++ b/packages/db-mongodb/src/findOne.ts @@ -1,5 +1,6 @@ import type { AggregateOptions, QueryOptions } from 'mongoose' -import type { Document, FindOne } from 'payload' + +import { APIError, type Document, type FindOne } from 'payload' import type { MongooseAdapter } from './index.js' @@ -10,10 +11,21 @@ import { sanitizeInternalFields } from './utilities/sanitizeInternalFields.js' export const findOne: FindOne = async function findOne( this: MongooseAdapter, - { collection, joins, locale, req, select, where }, + { collection: collectionSlug, joins, locale, req, select, where = {} }, ) { - const Model = this.collections[collection] - const collectionConfig = this.payload.collections[collection].config + const Model = this.collections[collectionSlug] + + if (!Model) { + throw new APIError(`Could not find collection ${collectionSlug} Mongoose model`) + } + + const collection = this.payload.collections[collectionSlug] + + if (!collection) { + throw new APIError(`Could not find collection ${collectionSlug}`) + } + + const collectionConfig = collection.config const session = await getSession(this, req) const options: AggregateOptions & QueryOptions = { lean: true, @@ -34,7 +46,7 @@ export const findOne: FindOne = async function findOne( const aggregate = await buildJoinAggregation({ adapter: this, - collection, + collection: collectionSlug, collectionConfig, joins, limit: 1, diff --git a/packages/db-mongodb/src/findVersions.ts b/packages/db-mongodb/src/findVersions.ts index 19abd38d443..b9e37122594 100644 --- a/packages/db-mongodb/src/findVersions.ts +++ b/packages/db-mongodb/src/findVersions.ts @@ -1,7 +1,7 @@ import type { PaginateOptions, QueryOptions } from 'mongoose' import type { FindVersions } from 'payload' -import { buildVersionCollectionFields, flattenWhereToOperators } from 'payload' +import { APIError, buildVersionCollectionFields, flattenWhereToOperators } from 'payload' import type { MongooseAdapter } from './index.js' @@ -12,10 +12,32 @@ import { sanitizeInternalFields } from './utilities/sanitizeInternalFields.js' export const findVersions: FindVersions = async function findVersions( this: MongooseAdapter, - { collection, limit, locale, page, pagination, req = {}, select, skip, sort: sortArg, where }, + { + collection: collectionSlug, + limit, + locale, + page, + pagination, + req = {}, + select, + skip, + sort: sortArg, + where = {}, + }, ) { - const Model = this.versions[collection] - const collectionConfig = this.payload.collections[collection].config + const Model = this.versions[collectionSlug] + + if (!Model) { + throw new APIError(`Could not find collection ${collectionSlug} version Mongoose model`) + } + + const collection = this.payload.collections[collectionSlug] + + if (!collection) { + throw new APIError(`Could not find collection ${collectionSlug}`) + } + + const collectionConfig = collection.config const session = await getSession(this, req) const options: QueryOptions = { limit, @@ -88,10 +110,10 @@ export const findVersions: FindVersions = async function findVersions( } } - if (limit >= 0) { + if (limit && limit >= 0) { paginationOptions.limit = limit // limit must also be set here, it's ignored when pagination is false - paginationOptions.options.limit = limit + paginationOptions.options!.limit = limit // Disable pagination if limit is 0 if (limit === 0) { @@ -100,7 +122,7 @@ export const findVersions: FindVersions = async function findVersions( } const result = await Model.paginate(query, paginationOptions) - const docs = JSON.parse(JSON.stringify(result.docs)) + const docs = JSON.parse(JSON.stringify(result.docs)) as any[] return { ...result, diff --git a/packages/db-mongodb/src/index.ts b/packages/db-mongodb/src/index.ts index 911677c1431..74421df0299 100644 --- a/packages/db-mongodb/src/index.ts +++ b/packages/db-mongodb/src/index.ts @@ -11,6 +11,7 @@ import type { BaseDatabaseAdapter, CollectionSlug, DatabaseAdapterObj, + Migration, Payload, TypeWithID, TypeWithVersion, @@ -105,11 +106,7 @@ export interface Args { * typed as any to avoid dependency */ mongoMemoryServer?: MongoMemoryReplSet - prodMigrations?: { - down: (args: MigrateDownArgs) => Promise - name: string - up: (args: MigrateUpArgs) => Promise - }[] + prodMigrations?: Migration[] transactionOptions?: false | TransactionOptions /** The URL to connect to MongoDB or false to start payload and prevent connecting */ diff --git a/packages/db-mongodb/src/migrateFresh.ts b/packages/db-mongodb/src/migrateFresh.ts index 4db2e76c423..cd9e538629c 100644 --- a/packages/db-mongodb/src/migrateFresh.ts +++ b/packages/db-mongodb/src/migrateFresh.ts @@ -1,5 +1,3 @@ -import type { PayloadRequest } from 'payload' - import { commitTransaction, initTransaction, killTransaction, readMigrationFiles } from 'payload' import prompts from 'prompts' diff --git a/packages/db-mongodb/src/queries/buildSortParam.ts b/packages/db-mongodb/src/queries/buildSortParam.ts index 6f76cbffef2..b180332c775 100644 --- a/packages/db-mongodb/src/queries/buildSortParam.ts +++ b/packages/db-mongodb/src/queries/buildSortParam.ts @@ -6,7 +6,7 @@ import { getLocalizedSortProperty } from './getLocalizedSortProperty.js' type Args = { config: SanitizedConfig fields: FlattenedField[] - locale: string + locale?: string sort: Sort timestamps: boolean } diff --git a/packages/db-mongodb/src/queryDrafts.ts b/packages/db-mongodb/src/queryDrafts.ts index 3ea8cb34d7d..081d043cb89 100644 --- a/packages/db-mongodb/src/queryDrafts.ts +++ b/packages/db-mongodb/src/queryDrafts.ts @@ -1,7 +1,12 @@ import type { PaginateOptions, QueryOptions } from 'mongoose' import type { QueryDrafts } from 'payload' -import { buildVersionCollectionFields, combineQueries, flattenWhereToOperators } from 'payload' +import { + APIError, + buildVersionCollectionFields, + combineQueries, + flattenWhereToOperators, +} from 'payload' import type { MongooseAdapter } from './index.js' @@ -13,10 +18,32 @@ import { sanitizeInternalFields } from './utilities/sanitizeInternalFields.js' export const queryDrafts: QueryDrafts = async function queryDrafts( this: MongooseAdapter, - { collection, joins, limit, locale, page, pagination, req, select, sort: sortArg, where }, + { + collection: collectionSlug, + joins, + limit, + locale, + page, + pagination, + req, + select, + sort: sortArg, + where = {}, + }, ) { - const VersionModel = this.versions[collection] - const collectionConfig = this.payload.collections[collection].config + const VersionModel = this.versions[collectionSlug] + + if (!VersionModel) { + throw new APIError(`Could not find collection ${collectionSlug} version Mongoose model`) + } + + const collection = this.payload.collections[collectionSlug] + + if (!collection) { + throw new APIError(`Could not find collection ${collectionSlug}`) + } + + const collectionConfig = collection.config const options: QueryOptions = { session: await getSession(this, req), } @@ -92,17 +119,17 @@ export const queryDrafts: QueryDrafts = async function queryDrafts( } } - if (limit > 0) { + if (limit && limit > 0) { paginationOptions.limit = limit // limit must also be set here, it's ignored when pagination is false - paginationOptions.options.limit = limit + paginationOptions.options!.limit = limit } let result const aggregate = await buildJoinAggregation({ adapter: this, - collection, + collection: collectionSlug, collectionConfig, joins, locale, @@ -121,7 +148,7 @@ export const queryDrafts: QueryDrafts = async function queryDrafts( result = await VersionModel.paginate(versionQuery, paginationOptions) } - const docs = JSON.parse(JSON.stringify(result.docs)) + const docs = JSON.parse(JSON.stringify(result.docs)) as any[] return { ...result, diff --git a/packages/db-mongodb/src/updateGlobal.ts b/packages/db-mongodb/src/updateGlobal.ts index 239fff5fd92..193d009c367 100644 --- a/packages/db-mongodb/src/updateGlobal.ts +++ b/packages/db-mongodb/src/updateGlobal.ts @@ -1,5 +1,6 @@ import type { QueryOptions } from 'mongoose' -import type { UpdateGlobal } from 'payload' + +import { APIError, type UpdateGlobal } from 'payload' import type { MongooseAdapter } from './index.js' @@ -13,7 +14,16 @@ export const updateGlobal: UpdateGlobal = async function updateGlobal( { slug, data, options: optionsArgs = {}, req, select }, ) { const Model = this.globals - const fields = this.payload.config.globals.find((global) => global.slug === slug).fields + + const globalConfig = this.payload.config.globals.find( + (globalConfig) => globalConfig.slug === slug, + ) + + if (!globalConfig) { + throw new APIError(`Could not find global with slug ${slug}`) + } + + const fields = globalConfig.fields const options: QueryOptions = { ...optionsArgs, @@ -21,7 +31,7 @@ export const updateGlobal: UpdateGlobal = async function updateGlobal( new: true, projection: buildProjectionFromSelect({ adapter: this, - fields: this.payload.config.globals.find((global) => global.slug === slug).flattenedFields, + fields: globalConfig.flattenedFields, select, }), session: await getSession(this, req), diff --git a/packages/db-mongodb/src/updateGlobalVersion.ts b/packages/db-mongodb/src/updateGlobalVersion.ts index af1453840b6..5a30936cdcf 100644 --- a/packages/db-mongodb/src/updateGlobalVersion.ts +++ b/packages/db-mongodb/src/updateGlobalVersion.ts @@ -1,6 +1,11 @@ import type { QueryOptions } from 'mongoose' -import { buildVersionGlobalFields, type TypeWithID, type UpdateGlobalVersionArgs } from 'payload' +import { + APIError, + buildVersionGlobalFields, + type TypeWithID, + type UpdateGlobalVersionArgs, +} from 'payload' import type { MongooseAdapter } from './index.js' @@ -22,10 +27,20 @@ export async function updateGlobalVersion( }: UpdateGlobalVersionArgs, ) { const VersionModel = this.versions[globalSlug] + + if (!VersionModel) { + throw new APIError(`Could not find global ${globalSlug} version Mongoose model`) + } + + const globalConfig = this.payload.config.globals.find((global) => global.slug === globalSlug) + + if (!globalConfig) { + throw new APIError(`Could not find global with slug ${globalSlug}`) + } + const whereToUse = where || { id: { equals: id } } - const currentGlobal = this.payload.config.globals.find((global) => global.slug === globalSlug) - const fields = buildVersionGlobalFields(this.payload.config, currentGlobal) + const fields = buildVersionGlobalFields(this.payload.config, globalConfig) const options: QueryOptions = { ...optionsArgs, @@ -33,7 +48,7 @@ export async function updateGlobalVersion( new: true, projection: buildProjectionFromSelect({ adapter: this, - fields: buildVersionGlobalFields(this.payload.config, currentGlobal, true), + fields: buildVersionGlobalFields(this.payload.config, globalConfig, true), select, }), session: await getSession(this, req), diff --git a/packages/db-mongodb/src/updateOne.ts b/packages/db-mongodb/src/updateOne.ts index 555d46925b2..afd9f98d279 100644 --- a/packages/db-mongodb/src/updateOne.ts +++ b/packages/db-mongodb/src/updateOne.ts @@ -1,5 +1,6 @@ import type { QueryOptions } from 'mongoose' -import type { UpdateOne } from 'payload' + +import { APIError, type UpdateOne } from 'payload' import type { MongooseAdapter } from './index.js' @@ -11,18 +12,38 @@ import { sanitizeRelationshipIDs } from './utilities/sanitizeRelationshipIDs.js' export const updateOne: UpdateOne = async function updateOne( this: MongooseAdapter, - { id, collection, data, locale, options: optionsArgs = {}, req, select, where: whereArg }, + { + id, + collection: collectionSlug, + data, + locale, + options: optionsArgs = {}, + req, + select, + where: whereArg = {}, + }, ) { const where = id ? { id: { equals: id } } : whereArg - const Model = this.collections[collection] - const fields = this.payload.collections[collection].config.fields + const Model = this.collections[collectionSlug] + + if (!Model) { + throw new APIError(`Could not find collection ${collectionSlug} Mongoose model`) + } + + const collection = this.payload.collections[collectionSlug] + + if (!collection) { + throw new APIError(`Could not find collection ${collectionSlug}`) + } + + const fields = collection.config.fields const options: QueryOptions = { ...optionsArgs, lean: true, new: true, projection: buildProjectionFromSelect({ adapter: this, - fields: this.payload.collections[collection].config.flattenedFields, + fields: collection.config.flattenedFields, select, }), session: await getSession(this, req), @@ -45,7 +66,7 @@ export const updateOne: UpdateOne = async function updateOne( try { result = await Model.findOneAndUpdate(query, sanitizedData, options) } catch (error) { - handleError({ collection, error, req }) + handleError({ collection: collectionSlug, error, req }) } result = JSON.parse(JSON.stringify(result)) diff --git a/packages/db-mongodb/src/updateVersion.ts b/packages/db-mongodb/src/updateVersion.ts index 9514e7cb73b..fcf321c9029 100644 --- a/packages/db-mongodb/src/updateVersion.ts +++ b/packages/db-mongodb/src/updateVersion.ts @@ -1,6 +1,6 @@ import type { QueryOptions } from 'mongoose' -import { buildVersionCollectionFields, type UpdateVersion } from 'payload' +import { APIError, buildVersionCollectionFields, type UpdateVersion } from 'payload' import type { MongooseAdapter } from './index.js' @@ -10,14 +10,31 @@ import { sanitizeRelationshipIDs } from './utilities/sanitizeRelationshipIDs.js' export const updateVersion: UpdateVersion = async function updateVersion( this: MongooseAdapter, - { id, collection, locale, options: optionsArgs = {}, req, select, versionData, where }, + { + id, + collection: collectionSlug, + locale, + options: optionsArgs = {}, + req, + select, + versionData, + where, + }, ) { - const VersionModel = this.versions[collection] + const VersionModel = this.versions[collectionSlug] + + if (!VersionModel) { + throw new APIError(`Could not find collection ${collectionSlug} version Mongoose model`) + } + + const collection = this.payload.collections[collectionSlug] + + if (!collection) { + throw new APIError(`Could not find collection ${collectionSlug}`) + } + const whereToUse = where || { id: { equals: id } } - const fields = buildVersionCollectionFields( - this.payload.config, - this.payload.collections[collection].config, - ) + const fields = buildVersionCollectionFields(this.payload.config, collection.config) const options: QueryOptions = { ...optionsArgs, @@ -25,11 +42,7 @@ export const updateVersion: UpdateVersion = async function updateVersion( new: true, projection: buildProjectionFromSelect({ adapter: this, - fields: buildVersionCollectionFields( - this.payload.config, - this.payload.collections[collection].config, - true, - ), + fields: buildVersionCollectionFields(this.payload.config, collection.config, true), select, }), session: await getSession(this, req), diff --git a/packages/db-mongodb/src/utilities/buildJoinAggregation.ts b/packages/db-mongodb/src/utilities/buildJoinAggregation.ts index 50895a0392c..99d976f5e5d 100644 --- a/packages/db-mongodb/src/utilities/buildJoinAggregation.ts +++ b/packages/db-mongodb/src/utilities/buildJoinAggregation.ts @@ -9,13 +9,13 @@ type BuildJoinAggregationArgs = { adapter: MongooseAdapter collection: CollectionSlug collectionConfig: SanitizedCollectionConfig - joins: JoinQuery + joins?: JoinQuery // the number of docs to get at the top collection level limit?: number - locale: string + locale?: string projection?: Record // the where clause for the top collection - query?: Where + query?: Record /** whether the query is from drafts */ versions?: boolean } diff --git a/packages/db-mongodb/src/utilities/handleError.ts b/packages/db-mongodb/src/utilities/handleError.ts index 8cdc20a816c..d7a44656efa 100644 --- a/packages/db-mongodb/src/utilities/handleError.ts +++ b/packages/db-mongodb/src/utilities/handleError.ts @@ -9,7 +9,7 @@ export const handleError = ({ req, }: { collection?: string - error: Error + error: unknown global?: string req?: Partial }) => { @@ -18,14 +18,20 @@ export const handleError = ({ } // Handle uniqueness error from MongoDB - if ('code' in error && error.code === 11000 && 'keyValue' in error && error.keyValue) { + if ( + 'code' in error && + error.code === 11000 && + 'keyValue' in error && + error.keyValue && + typeof error.keyValue === 'object' + ) { throw new ValidationError( { collection, errors: [ { message: req?.t ? req.t('error:valueMustBeUnique') : 'Value must be unique', - path: Object.keys(error.keyValue)[0], + path: Object.keys(error.keyValue)[0] ?? '', }, ], global, @@ -34,5 +40,6 @@ export const handleError = ({ ) } + // eslint-disable-next-line @typescript-eslint/only-throw-error throw error } diff --git a/packages/db-mongodb/tsconfig.json b/packages/db-mongodb/tsconfig.json index ce82aadf9c6..a181cd4bf9b 100644 --- a/packages/db-mongodb/tsconfig.json +++ b/packages/db-mongodb/tsconfig.json @@ -1,9 +1,4 @@ { "extends": "../../tsconfig.base.json", - "compilerOptions": { - /* TODO: remove the following lines */ - "strict": false, - "noUncheckedIndexedAccess": false, - }, "references": [{ "path": "../payload" }, { "path": "../translations" }] } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 49f2fb1cad9..ef56db0668d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -45,7 +45,7 @@ importers: version: 1.50.0 '@sentry/nextjs': specifier: ^8.33.1 - version: 8.37.1(@opentelemetry/core@1.27.0(@opentelemetry/api@1.9.0))(@opentelemetry/instrumentation@0.54.2(@opentelemetry/api@1.9.0))(@opentelemetry/sdk-trace-base@1.27.0(@opentelemetry/api@1.9.0))(next@15.1.5(@opentelemetry/api@1.9.0)(@playwright/test@1.50.0)(babel-plugin-macros@3.1.0)(babel-plugin-react-compiler@19.0.0-beta-714736e-20250131)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(sass@1.77.4))(react@19.0.0)(webpack@5.96.1(@swc/core@1.10.12(@swc/helpers@0.5.15))) + version: 8.37.1(@opentelemetry/core@1.27.0(@opentelemetry/api@1.9.0))(@opentelemetry/instrumentation@0.54.2(@opentelemetry/api@1.9.0))(@opentelemetry/sdk-trace-base@1.27.0(@opentelemetry/api@1.9.0))(next@15.1.5(@babel/core@7.26.7)(@opentelemetry/api@1.9.0)(@playwright/test@1.50.0)(babel-plugin-macros@3.1.0)(babel-plugin-react-compiler@19.0.0-beta-714736e-20250131)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(sass@1.77.4))(react@19.0.0)(webpack@5.96.1(@swc/core@1.10.12(@swc/helpers@0.5.15))(esbuild@0.19.12)) '@sentry/node': specifier: ^8.33.1 version: 8.37.1 @@ -135,7 +135,7 @@ importers: version: 10.1.3(@aws-sdk/credential-providers@3.687.0(@aws-sdk/client-sso-oidc@3.687.0(@aws-sdk/client-sts@3.687.0)))(socks@2.8.3) next: specifier: 15.1.5 - version: 15.1.5(@opentelemetry/api@1.9.0)(@playwright/test@1.50.0)(babel-plugin-macros@3.1.0)(babel-plugin-react-compiler@19.0.0-beta-714736e-20250131)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(sass@1.77.4) + version: 15.1.5(@babel/core@7.26.7)(@opentelemetry/api@1.9.0)(@playwright/test@1.50.0)(babel-plugin-macros@3.1.0)(babel-plugin-react-compiler@19.0.0-beta-714736e-20250131)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(sass@1.77.4) open: specifier: ^10.1.0 version: 10.1.0 @@ -270,6 +270,9 @@ importers: '@types/mongoose-aggregate-paginate-v2': specifier: 1.0.12 version: 1.0.12(@aws-sdk/credential-providers@3.687.0(@aws-sdk/client-sso-oidc@3.687.0(@aws-sdk/client-sts@3.687.0)))(socks@2.8.3) + '@types/prompts': + specifier: ^2.4.5 + version: 2.4.9 mongodb: specifier: 6.12.0 version: 6.12.0(@aws-sdk/credential-providers@3.687.0(@aws-sdk/client-sso-oidc@3.687.0(@aws-sdk/client-sts@3.687.0)))(socks@2.8.3) @@ -1014,7 +1017,7 @@ importers: dependencies: next: specifier: ^15.0.3 - version: 15.1.3(@opentelemetry/api@1.9.0)(@playwright/test@1.50.0)(babel-plugin-macros@3.1.0)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(sass@1.77.4) + version: 15.1.3(@babel/core@7.26.7)(@opentelemetry/api@1.9.0)(@playwright/test@1.50.0)(babel-plugin-macros@3.1.0)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(sass@1.77.4) devDependencies: '@payloadcms/eslint-config': specifier: workspace:* @@ -1076,7 +1079,7 @@ importers: dependencies: '@sentry/nextjs': specifier: ^8.33.1 - version: 8.37.1(@opentelemetry/core@1.27.0(@opentelemetry/api@1.9.0))(@opentelemetry/instrumentation@0.54.2(@opentelemetry/api@1.9.0))(@opentelemetry/sdk-trace-base@1.27.0(@opentelemetry/api@1.9.0))(next@15.1.5(@opentelemetry/api@1.9.0)(@playwright/test@1.50.0)(babel-plugin-macros@3.1.0)(babel-plugin-react-compiler@19.0.0-beta-714736e-20250131)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(sass@1.77.4))(react@19.0.0)(webpack@5.96.1(@swc/core@1.10.12(@swc/helpers@0.5.15))) + version: 8.37.1(@opentelemetry/core@1.27.0(@opentelemetry/api@1.9.0))(@opentelemetry/instrumentation@0.54.2(@opentelemetry/api@1.9.0))(@opentelemetry/sdk-trace-base@1.27.0(@opentelemetry/api@1.9.0))(next@15.1.5(@babel/core@7.26.7)(@opentelemetry/api@1.9.0)(@playwright/test@1.50.0)(babel-plugin-macros@3.1.0)(babel-plugin-react-compiler@19.0.0-beta-714736e-20250131)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(sass@1.77.4))(react@19.0.0)(webpack@5.96.1(@swc/core@1.10.12(@swc/helpers@0.5.15))(esbuild@0.19.12)) '@sentry/types': specifier: ^8.33.1 version: 8.37.1 @@ -1426,7 +1429,7 @@ importers: version: link:../plugin-cloud-storage uploadthing: specifier: 7.3.0 - version: 7.3.0(next@15.1.5(@opentelemetry/api@1.9.0)(@playwright/test@1.50.0)(babel-plugin-macros@3.1.0)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(sass@1.77.4)) + version: 7.3.0(next@15.1.5(@babel/core@7.26.7)(@opentelemetry/api@1.9.0)(@playwright/test@1.50.0)(babel-plugin-macros@3.1.0)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(sass@1.77.4)) devDependencies: payload: specifier: workspace:* @@ -1706,7 +1709,7 @@ importers: version: link:../packages/ui '@sentry/nextjs': specifier: ^8.33.1 - version: 8.37.1(@opentelemetry/core@1.27.0(@opentelemetry/api@1.9.0))(@opentelemetry/instrumentation@0.54.2(@opentelemetry/api@1.9.0))(@opentelemetry/sdk-trace-base@1.27.0(@opentelemetry/api@1.9.0))(next@15.1.5(@opentelemetry/api@1.9.0)(@playwright/test@1.50.0)(babel-plugin-macros@3.1.0)(babel-plugin-react-compiler@19.0.0-beta-714736e-20250131)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(sass@1.77.4))(react@19.0.0)(webpack@5.96.1(@swc/core@1.10.12(@swc/helpers@0.5.15))) + version: 8.37.1(@opentelemetry/core@1.27.0(@opentelemetry/api@1.9.0))(@opentelemetry/instrumentation@0.54.2(@opentelemetry/api@1.9.0))(@opentelemetry/sdk-trace-base@1.27.0(@opentelemetry/api@1.9.0))(next@15.1.5(@babel/core@7.26.7)(@opentelemetry/api@1.9.0)(@playwright/test@1.50.0)(babel-plugin-macros@3.1.0)(babel-plugin-react-compiler@19.0.0-beta-714736e-20250131)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(sass@1.77.4))(react@19.0.0)(webpack@5.96.1(@swc/core@1.10.12(@swc/helpers@0.5.15))(esbuild@0.19.12)) '@sentry/react': specifier: ^7.77.0 version: 7.119.2(react@19.0.0) @@ -1760,7 +1763,7 @@ importers: version: 8.9.5(@aws-sdk/credential-providers@3.687.0(@aws-sdk/client-sso-oidc@3.687.0(@aws-sdk/client-sts@3.687.0)))(socks@2.8.3) next: specifier: 15.1.5 - version: 15.1.5(@opentelemetry/api@1.9.0)(@playwright/test@1.50.0)(babel-plugin-macros@3.1.0)(babel-plugin-react-compiler@19.0.0-beta-714736e-20250131)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(sass@1.77.4) + version: 15.1.5(@babel/core@7.26.7)(@opentelemetry/api@1.9.0)(@playwright/test@1.50.0)(babel-plugin-macros@3.1.0)(babel-plugin-react-compiler@19.0.0-beta-714736e-20250131)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(sass@1.77.4) nodemailer: specifier: 6.9.16 version: 6.9.16 @@ -7841,6 +7844,7 @@ packages: libsql@0.4.7: resolution: {integrity: sha512-T9eIRCs6b0J1SHKYIvD8+KCJMcWZ900iZyxdnSCdqxN12Z1ijzT+jY5nrk72Jw4B0HGzms2NgpryArlJqvc3Lw==} + cpu: [x64, arm64, wasm32] os: [darwin, linux, win32] lie@3.1.1: @@ -13680,7 +13684,7 @@ snapshots: '@sentry/utils': 7.119.2 localforage: 1.10.0 - '@sentry/nextjs@8.37.1(@opentelemetry/core@1.27.0(@opentelemetry/api@1.9.0))(@opentelemetry/instrumentation@0.54.2(@opentelemetry/api@1.9.0))(@opentelemetry/sdk-trace-base@1.27.0(@opentelemetry/api@1.9.0))(next@15.1.5(@opentelemetry/api@1.9.0)(@playwright/test@1.50.0)(babel-plugin-macros@3.1.0)(babel-plugin-react-compiler@19.0.0-beta-714736e-20250131)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(sass@1.77.4))(react@19.0.0)(webpack@5.96.1(@swc/core@1.10.12(@swc/helpers@0.5.15)))': + '@sentry/nextjs@8.37.1(@opentelemetry/core@1.27.0(@opentelemetry/api@1.9.0))(@opentelemetry/instrumentation@0.54.2(@opentelemetry/api@1.9.0))(@opentelemetry/sdk-trace-base@1.27.0(@opentelemetry/api@1.9.0))(next@15.1.5(@babel/core@7.26.7)(@opentelemetry/api@1.9.0)(@playwright/test@1.50.0)(babel-plugin-macros@3.1.0)(babel-plugin-react-compiler@19.0.0-beta-714736e-20250131)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(sass@1.77.4))(react@19.0.0)(webpack@5.96.1(@swc/core@1.10.12(@swc/helpers@0.5.15))(esbuild@0.19.12))': dependencies: '@opentelemetry/api': 1.9.0 '@opentelemetry/instrumentation-http': 0.53.0(@opentelemetry/api@1.9.0) @@ -13694,9 +13698,9 @@ snapshots: '@sentry/types': 8.37.1 '@sentry/utils': 8.37.1 '@sentry/vercel-edge': 8.37.1 - '@sentry/webpack-plugin': 2.22.6(webpack@5.96.1(@swc/core@1.10.12(@swc/helpers@0.5.15))) + '@sentry/webpack-plugin': 2.22.6(webpack@5.96.1(@swc/core@1.10.12(@swc/helpers@0.5.15))(esbuild@0.19.12)) chalk: 3.0.0 - next: 15.1.5(@opentelemetry/api@1.9.0)(@playwright/test@1.50.0)(babel-plugin-macros@3.1.0)(babel-plugin-react-compiler@19.0.0-beta-714736e-20250131)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(sass@1.77.4) + next: 15.1.5(@babel/core@7.26.7)(@opentelemetry/api@1.9.0)(@playwright/test@1.50.0)(babel-plugin-macros@3.1.0)(babel-plugin-react-compiler@19.0.0-beta-714736e-20250131)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(sass@1.77.4) resolve: 1.22.8 rollup: 3.29.5 stacktrace-parser: 0.1.10 @@ -13804,12 +13808,12 @@ snapshots: '@sentry/types': 8.37.1 '@sentry/utils': 8.37.1 - '@sentry/webpack-plugin@2.22.6(webpack@5.96.1(@swc/core@1.10.12(@swc/helpers@0.5.15)))': + '@sentry/webpack-plugin@2.22.6(webpack@5.96.1(@swc/core@1.10.12(@swc/helpers@0.5.15))(esbuild@0.19.12))': dependencies: '@sentry/bundler-plugin-core': 2.22.6 unplugin: 1.0.1 uuid: 9.0.0 - webpack: 5.96.1(@swc/core@1.10.12(@swc/helpers@0.5.15)) + webpack: 5.96.1(@swc/core@1.10.12(@swc/helpers@0.5.15))(esbuild@0.19.12) transitivePeerDependencies: - encoding - supports-color @@ -18188,7 +18192,7 @@ snapshots: - '@babel/core' - babel-plugin-macros - next@15.1.3(@opentelemetry/api@1.9.0)(@playwright/test@1.50.0)(babel-plugin-macros@3.1.0)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(sass@1.77.4): + next@15.1.3(@babel/core@7.26.7)(@opentelemetry/api@1.9.0)(@playwright/test@1.50.0)(babel-plugin-macros@3.1.0)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(sass@1.77.4): dependencies: '@next/env': 15.1.3 '@swc/counter': 0.1.3 @@ -18216,7 +18220,7 @@ snapshots: - '@babel/core' - babel-plugin-macros - next@15.1.5(@opentelemetry/api@1.9.0)(@playwright/test@1.50.0)(babel-plugin-macros@3.1.0)(babel-plugin-react-compiler@19.0.0-beta-714736e-20250131)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(sass@1.77.4): + next@15.1.5(@babel/core@7.26.7)(@opentelemetry/api@1.9.0)(@playwright/test@1.50.0)(babel-plugin-macros@3.1.0)(babel-plugin-react-compiler@19.0.0-beta-714736e-20250131)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(sass@1.77.4): dependencies: '@next/env': 15.1.5 '@swc/counter': 0.1.3 @@ -19622,16 +19626,17 @@ snapshots: ansi-escapes: 4.3.2 supports-hyperlinks: 2.3.0 - terser-webpack-plugin@5.3.10(@swc/core@1.10.12(@swc/helpers@0.5.15))(webpack@5.96.1(@swc/core@1.10.12(@swc/helpers@0.5.15))): + terser-webpack-plugin@5.3.10(@swc/core@1.10.12(@swc/helpers@0.5.15))(esbuild@0.19.12)(webpack@5.96.1(@swc/core@1.10.12(@swc/helpers@0.5.15))(esbuild@0.19.12)): dependencies: '@jridgewell/trace-mapping': 0.3.25 jest-worker: 27.5.1 schema-utils: 3.3.0 serialize-javascript: 6.0.2 terser: 5.36.0 - webpack: 5.96.1(@swc/core@1.10.12(@swc/helpers@0.5.15)) + webpack: 5.96.1(@swc/core@1.10.12(@swc/helpers@0.5.15))(esbuild@0.19.12) optionalDependencies: '@swc/core': 1.10.12(@swc/helpers@0.5.15) + esbuild: 0.19.12 terser@5.36.0: dependencies: @@ -19912,14 +19917,14 @@ snapshots: escalade: 3.2.0 picocolors: 1.1.1 - uploadthing@7.3.0(next@15.1.5(@opentelemetry/api@1.9.0)(@playwright/test@1.50.0)(babel-plugin-macros@3.1.0)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(sass@1.77.4)): + uploadthing@7.3.0(next@15.1.5(@babel/core@7.26.7)(@opentelemetry/api@1.9.0)(@playwright/test@1.50.0)(babel-plugin-macros@3.1.0)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(sass@1.77.4)): dependencies: '@effect/platform': 0.69.8(effect@3.10.3) '@uploadthing/mime-types': 0.3.2 '@uploadthing/shared': 7.1.1 effect: 3.10.3 optionalDependencies: - next: 15.1.5(@opentelemetry/api@1.9.0)(@playwright/test@1.50.0)(babel-plugin-macros@3.1.0)(babel-plugin-react-compiler@19.0.0-beta-714736e-20250131)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(sass@1.77.4) + next: 15.1.5(@babel/core@7.26.7)(@opentelemetry/api@1.9.0)(@playwright/test@1.50.0)(babel-plugin-macros@3.1.0)(babel-plugin-react-compiler@19.0.0-beta-714736e-20250131)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(sass@1.77.4) uri-js@4.4.1: dependencies: @@ -20017,7 +20022,7 @@ snapshots: webpack-virtual-modules@0.5.0: {} - webpack@5.96.1(@swc/core@1.10.12(@swc/helpers@0.5.15)): + webpack@5.96.1(@swc/core@1.10.12(@swc/helpers@0.5.15))(esbuild@0.19.12): dependencies: '@types/eslint-scope': 3.7.7 '@types/estree': 1.0.6 @@ -20039,7 +20044,7 @@ snapshots: neo-async: 2.6.2 schema-utils: 3.3.0 tapable: 2.2.1 - terser-webpack-plugin: 5.3.10(@swc/core@1.10.12(@swc/helpers@0.5.15))(webpack@5.96.1(@swc/core@1.10.12(@swc/helpers@0.5.15))) + terser-webpack-plugin: 5.3.10(@swc/core@1.10.12(@swc/helpers@0.5.15))(esbuild@0.19.12)(webpack@5.96.1(@swc/core@1.10.12(@swc/helpers@0.5.15))(esbuild@0.19.12)) watchpack: 2.4.2 webpack-sources: 3.2.3 transitivePeerDependencies: