chore: updates db-mongodb imports for ESM

This commit is contained in:
Kendell Joseph
2024-03-06 13:55:05 -05:00
parent 38798aec73
commit 3090e7c163
32 changed files with 102 additions and 102 deletions

View File

@@ -4,7 +4,7 @@ import type { Connect } from 'payload/database'
import mongoose from 'mongoose' import mongoose from 'mongoose'
import type { MongooseAdapter } from '.' import type { MongooseAdapter } from './index.d.ts'
export const connect: Connect = async function connect( export const connect: Connect = async function connect(
this: MongooseAdapter, this: MongooseAdapter,

View File

@@ -1,10 +1,10 @@
import type { Create } from 'payload/database' import type { Create } from 'payload/database'
import type { Document, PayloadRequest } from 'payload/types' import type { Document, PayloadRequest } from 'payload/types'
import type { MongooseAdapter } from '.' import type { MongooseAdapter } from './index.d.ts'
import handleError from './utilities/handleError' import handleError from './utilities/handleError.js'
import { withSession } from './withSession' import { withSession } from './withSession.js'
export const create: Create = async function create( export const create: Create = async function create(
this: MongooseAdapter, this: MongooseAdapter,

View File

@@ -1,10 +1,10 @@
import type { CreateGlobal } from 'payload/database' import type { CreateGlobal } from 'payload/database'
import type { PayloadRequest } from 'payload/types' import type { PayloadRequest } from 'payload/types'
import type { MongooseAdapter } from '.' import type { MongooseAdapter } from './index.d.ts'
import sanitizeInternalFields from './utilities/sanitizeInternalFields' import sanitizeInternalFields from './utilities/sanitizeInternalFields.js'
import { withSession } from './withSession' import { withSession } from './withSession.js'
export const createGlobal: CreateGlobal = async function createGlobal( export const createGlobal: CreateGlobal = async function createGlobal(
this: MongooseAdapter, this: MongooseAdapter,

View File

@@ -2,9 +2,9 @@ import type { CreateGlobalVersion } from 'payload/database'
import type { PayloadRequest } from 'payload/types' import type { PayloadRequest } from 'payload/types'
import type { Document } from 'payload/types' import type { Document } from 'payload/types'
import type { MongooseAdapter } from '.' import type { MongooseAdapter } from './index.d.ts'
import { withSession } from './withSession' import { withSession } from './withSession.js'
export const createGlobalVersion: CreateGlobalVersion = async function createGlobalVersion( export const createGlobalVersion: CreateGlobalVersion = async function createGlobalVersion(
this: MongooseAdapter, this: MongooseAdapter,

View File

@@ -2,9 +2,9 @@ import type { CreateVersion } from 'payload/database'
import type { PayloadRequest } from 'payload/types' import type { PayloadRequest } from 'payload/types'
import type { Document } from 'payload/types' import type { Document } from 'payload/types'
import type { MongooseAdapter } from '.' import type { MongooseAdapter } from './index.d.ts'
import { withSession } from './withSession' import { withSession } from './withSession.js'
export const createVersion: CreateVersion = async function createVersion( export const createVersion: CreateVersion = async function createVersion(
this: MongooseAdapter, this: MongooseAdapter,

View File

@@ -1,9 +1,9 @@
import type { DeleteMany } from 'payload/database' import type { DeleteMany } from 'payload/database'
import type { PayloadRequest } from 'payload/types' import type { PayloadRequest } from 'payload/types'
import type { MongooseAdapter } from '.' import type { MongooseAdapter } from './index.d.ts'
import { withSession } from './withSession' import { withSession } from './withSession.js'
export const deleteMany: DeleteMany = async function deleteMany( export const deleteMany: DeleteMany = async function deleteMany(
this: MongooseAdapter, this: MongooseAdapter,

View File

@@ -2,10 +2,10 @@ import type { DeleteOne } from 'payload/database'
import type { PayloadRequest } from 'payload/types' import type { PayloadRequest } from 'payload/types'
import type { Document } from 'payload/types' import type { Document } from 'payload/types'
import type { MongooseAdapter } from '.' import type { MongooseAdapter } from './index.d.ts'
import sanitizeInternalFields from './utilities/sanitizeInternalFields' import sanitizeInternalFields from './utilities/sanitizeInternalFields.js'
import { withSession } from './withSession' import { withSession } from './withSession.js'
export const deleteOne: DeleteOne = async function deleteOne( export const deleteOne: DeleteOne = async function deleteOne(
this: MongooseAdapter, this: MongooseAdapter,

View File

@@ -1,9 +1,9 @@
import type { DeleteVersions } from 'payload/database' import type { DeleteVersions } from 'payload/database'
import type { PayloadRequest } from 'payload/types' import type { PayloadRequest } from 'payload/types'
import type { MongooseAdapter } from '.' import type { MongooseAdapter } from './index.d.ts'
import { withSession } from './withSession' import { withSession } from './withSession.js'
export const deleteVersions: DeleteVersions = async function deleteVersions( export const deleteVersions: DeleteVersions = async function deleteVersions(
this: MongooseAdapter, this: MongooseAdapter,

View File

@@ -2,7 +2,7 @@ import type { Destroy } from 'payload/database'
import mongoose from 'mongoose' import mongoose from 'mongoose'
import type { MongooseAdapter } from './index' import type { MongooseAdapter } from './index.d.ts'
export const destroy: Destroy = async function destroy(this: MongooseAdapter) { export const destroy: Destroy = async function destroy(this: MongooseAdapter) {
if (this.mongoMemoryServer) { if (this.mongoMemoryServer) {

View File

@@ -4,11 +4,11 @@ import type { PayloadRequest } from 'payload/types'
import { flattenWhereToOperators } from 'payload/database' import { flattenWhereToOperators } from 'payload/database'
import type { MongooseAdapter } from '.' import type { MongooseAdapter } from './index.d.ts'
import { buildSortParam } from './queries/buildSortParam' import { buildSortParam } from './queries/buildSortParam.js'
import sanitizeInternalFields from './utilities/sanitizeInternalFields' import sanitizeInternalFields from './utilities/sanitizeInternalFields.js'
import { withSession } from './withSession' import { withSession } from './withSession.js'
export const find: Find = async function find( export const find: Find = async function find(
this: MongooseAdapter, this: MongooseAdapter,

View File

@@ -3,10 +3,10 @@ import type { PayloadRequest } from 'payload/types'
import { combineQueries } from 'payload/database' import { combineQueries } from 'payload/database'
import type { MongooseAdapter } from '.' import type { MongooseAdapter } from './index.d.ts'
import sanitizeInternalFields from './utilities/sanitizeInternalFields' import sanitizeInternalFields from './utilities/sanitizeInternalFields.js'
import { withSession } from './withSession' import { withSession } from './withSession.js'
export const findGlobal: FindGlobal = async function findGlobal( export const findGlobal: FindGlobal = async function findGlobal(
this: MongooseAdapter, this: MongooseAdapter,

View File

@@ -5,11 +5,11 @@ import type { PayloadRequest } from 'payload/types'
import { flattenWhereToOperators } from 'payload/database' import { flattenWhereToOperators } from 'payload/database'
import { buildVersionGlobalFields } from 'payload/versions' import { buildVersionGlobalFields } from 'payload/versions'
import type { MongooseAdapter } from '.' import type { MongooseAdapter } from './index.d.ts'
import { buildSortParam } from './queries/buildSortParam' import { buildSortParam } from './queries/buildSortParam.js'
import sanitizeInternalFields from './utilities/sanitizeInternalFields' import sanitizeInternalFields from './utilities/sanitizeInternalFields.js'
import { withSession } from './withSession' import { withSession } from './withSession.js'
export const findGlobalVersions: FindGlobalVersions = async function findGlobalVersions( export const findGlobalVersions: FindGlobalVersions = async function findGlobalVersions(
this: MongooseAdapter, this: MongooseAdapter,

View File

@@ -3,10 +3,10 @@ import type { FindOne } from 'payload/database'
import type { PayloadRequest } from 'payload/types' import type { PayloadRequest } from 'payload/types'
import type { Document } from 'payload/types' import type { Document } from 'payload/types'
import type { MongooseAdapter } from '.' import type { MongooseAdapter } from './index.d.ts'
import sanitizeInternalFields from './utilities/sanitizeInternalFields' import sanitizeInternalFields from './utilities/sanitizeInternalFields.js'
import { withSession } from './withSession' import { withSession } from './withSession.js'
export const findOne: FindOne = async function findOne( export const findOne: FindOne = async function findOne(
this: MongooseAdapter, this: MongooseAdapter,

View File

@@ -4,11 +4,11 @@ import type { PayloadRequest } from 'payload/types'
import { flattenWhereToOperators } from 'payload/database' import { flattenWhereToOperators } from 'payload/database'
import type { MongooseAdapter } from '.' import type { MongooseAdapter } from './index.d.ts'
import { buildSortParam } from './queries/buildSortParam' import { buildSortParam } from './queries/buildSortParam.js'
import sanitizeInternalFields from './utilities/sanitizeInternalFields' import sanitizeInternalFields from './utilities/sanitizeInternalFields.js'
import { withSession } from './withSession' import { withSession } from './withSession.js'
export const findVersions: FindVersions = async function findVersions( export const findVersions: FindVersions = async function findVersions(
this: MongooseAdapter, this: MongooseAdapter,

View File

@@ -8,35 +8,35 @@ import mongoose from 'mongoose'
import path from 'path' import path from 'path'
import { createDatabaseAdapter } from 'payload/database' import { createDatabaseAdapter } from 'payload/database'
import type { CollectionModel, GlobalModel } from './types' import type { CollectionModel, GlobalModel } from './types.d.ts'
import { connect } from './connect' import { connect } from './connect.js'
import { create } from './create' import { create } from './create.js'
import { createGlobal } from './createGlobal' import { createGlobal } from './createGlobal.js'
import { createGlobalVersion } from './createGlobalVersion' import { createGlobalVersion } from './createGlobalVersion.js'
import { createMigration } from './createMigration' import { createMigration } from './createMigration.js'
import { createVersion } from './createVersion' import { createVersion } from './createVersion.js'
import { deleteMany } from './deleteMany' import { deleteMany } from './deleteMany.js'
import { deleteOne } from './deleteOne' import { deleteOne } from './deleteOne.js'
import { deleteVersions } from './deleteVersions' import { deleteVersions } from './deleteVersions.js'
import { destroy } from './destroy' import { destroy } from './destroy.js'
import { find } from './find' import { find } from './find.js'
import { findGlobal } from './findGlobal' import { findGlobal } from './findGlobal.js'
import { findGlobalVersions } from './findGlobalVersions' import { findGlobalVersions } from './findGlobalVersions.js'
import { findOne } from './findOne' import { findOne } from './findOne.js'
import { findVersions } from './findVersions' import { findVersions } from './findVersions.js'
import { init } from './init' import { init } from './init.js'
import { migrateFresh } from './migrateFresh' import { migrateFresh } from './migrateFresh.js'
import { queryDrafts } from './queryDrafts' import { queryDrafts } from './queryDrafts.js'
import { beginTransaction } from './transactions/beginTransaction' import { beginTransaction } from './transactions/beginTransaction.js'
import { commitTransaction } from './transactions/commitTransaction' import { commitTransaction } from './transactions/commitTransaction.js'
import { rollbackTransaction } from './transactions/rollbackTransaction' import { rollbackTransaction } from './transactions/rollbackTransaction.js'
import { updateGlobal } from './updateGlobal' import { updateGlobal } from './updateGlobal.js'
import { updateGlobalVersion } from './updateGlobalVersion' import { updateGlobalVersion } from './updateGlobalVersion.js'
import { updateOne } from './updateOne' import { updateOne } from './updateOne.js'
import { updateVersion } from './updateVersion' import { updateVersion } from './updateVersion.js'
export type { MigrateDownArgs, MigrateUpArgs } from './types' export type { MigrateDownArgs, MigrateUpArgs } from './types.d.ts'
import type { DatabaseAdapterObj } from 'payload/database' import type { DatabaseAdapterObj } from 'payload/database'
export interface Args { export interface Args {

View File

@@ -11,13 +11,13 @@ import {
getVersionsModelName, getVersionsModelName,
} from 'payload/versions' } from 'payload/versions'
import type { MongooseAdapter } from '.' import type { MongooseAdapter } from './index.d.ts'
import type { CollectionModel } from './types' import type { CollectionModel } from './types.d.ts'
import buildCollectionSchema from './models/buildCollectionSchema' import buildCollectionSchema from './models/buildCollectionSchema.js'
import { buildGlobalModel } from './models/buildGlobalModel' import { buildGlobalModel } from './models/buildGlobalModel.js'
import buildSchema from './models/buildSchema' import buildSchema from './models/buildSchema.js'
import getBuildQueryPlugin from './queries/buildQuery' import getBuildQueryPlugin from './queries/buildQuery.js'
export const init: Init = function init(this: MongooseAdapter) { export const init: Init = function init(this: MongooseAdapter) {
this.payload.config.collections.forEach((collection: SanitizedCollectionConfig) => { this.payload.config.collections.forEach((collection: SanitizedCollectionConfig) => {

View File

@@ -8,7 +8,7 @@ import {
} from 'payload/database' } from 'payload/database'
import prompts from 'prompts' import prompts from 'prompts'
import type { MongooseAdapter } from '.' import type { MongooseAdapter } from './index.d.ts'
/** /**
* Drop the current database and run all migrate up functions * Drop the current database and run all migrate up functions

View File

@@ -4,8 +4,8 @@ import type { SanitizedCollectionConfig } from 'payload/types'
import paginate from 'mongoose-paginate-v2' import paginate from 'mongoose-paginate-v2'
import getBuildQueryPlugin from '../queries/buildQuery' import getBuildQueryPlugin from '../queries/buildQuery.js'
import buildSchema from './buildSchema' import buildSchema from './buildSchema.js'
const buildCollectionSchema = ( const buildCollectionSchema = (
collection: SanitizedCollectionConfig, collection: SanitizedCollectionConfig,

View File

@@ -2,10 +2,10 @@ import type { SanitizedConfig } from 'payload/config'
import mongoose from 'mongoose' import mongoose from 'mongoose'
import type { GlobalModel } from '../types' import type { GlobalModel } from '../types.d.ts'
import getBuildQueryPlugin from '../queries/buildQuery' import getBuildQueryPlugin from '../queries/buildQuery.js'
import buildSchema from './buildSchema' import buildSchema from './buildSchema.js'
export const buildGlobalModel = (config: SanitizedConfig): GlobalModel | null => { export const buildGlobalModel = (config: SanitizedConfig): GlobalModel | null => {
if (config.globals && config.globals.length > 0) { if (config.globals && config.globals.length > 0) {

View File

@@ -3,7 +3,7 @@ import type { Field, Where } from 'payload/types'
import { QueryError } from 'payload/errors' import { QueryError } from 'payload/errors'
import { parseParams } from './parseParams' import { parseParams } from './parseParams.js'
type GetBuildQueryPluginArgs = { type GetBuildQueryPluginArgs = {
collectionSlug?: string collectionSlug?: string

View File

@@ -9,10 +9,10 @@ import { getLocalizedPaths } from 'payload/database'
import { fieldAffectsData } from 'payload/types' import { fieldAffectsData } from 'payload/types'
import { validOperators } from 'payload/types' import { validOperators } from 'payload/types'
import type { MongooseAdapter } from '..' import type { MongooseAdapter } from '../index.d.ts'
import { operatorMap } from './operatorMap' import { operatorMap } from './operatorMap.js'
import { sanitizeQueryValue } from './sanitizeQueryValue' import { sanitizeQueryValue } from './sanitizeQueryValue.js'
type SearchParam = { type SearchParam = {
path?: string path?: string

View File

@@ -2,7 +2,7 @@ import type { PaginateOptions } from 'mongoose'
import type { SanitizedConfig } from 'payload/config' import type { SanitizedConfig } from 'payload/config'
import type { Field } from 'payload/types' import type { Field } from 'payload/types'
import { getLocalizedSortProperty } from './getLocalizedSortProperty' import { getLocalizedSortProperty } from './getLocalizedSortProperty.js'
type Args = { type Args = {
config: SanitizedConfig config: SanitizedConfig

View File

@@ -1,6 +1,6 @@
import { sanitizeConfig } from 'payload/config' import { sanitizeConfig } from 'payload/config'
import { Config } from 'payload/config' import { Config } from 'payload/config'
import { getLocalizedSortProperty } from './getLocalizedSortProperty' import { getLocalizedSortProperty } from './getLocalizedSortProperty.js'
const config = { const config = {
localization: { localization: {

View File

@@ -9,8 +9,8 @@ import deepmerge from 'deepmerge'
import { validOperators } from 'payload/types' import { validOperators } from 'payload/types'
import { combineMerge } from 'payload/utilities' import { combineMerge } from 'payload/utilities'
import { buildAndOrConditions } from './buildAndOrConditions' import { buildAndOrConditions } from './buildAndOrConditions.js'
import { buildSearchParam } from './buildSearchParams' import { buildSearchParam } from './buildSearchParams.js'
export async function parseParams({ export async function parseParams({
collectionSlug, collectionSlug,

View File

@@ -4,11 +4,11 @@ import type { PayloadRequest } from 'payload/types'
import { combineQueries, flattenWhereToOperators } from 'payload/database' import { combineQueries, flattenWhereToOperators } from 'payload/database'
import type { MongooseAdapter } from '.' import type { MongooseAdapter } from './index.d.ts'
import { buildSortParam } from './queries/buildSortParam' import { buildSortParam } from './queries/buildSortParam.js'
import sanitizeInternalFields from './utilities/sanitizeInternalFields' import sanitizeInternalFields from './utilities/sanitizeInternalFields.js'
import { withSession } from './withSession' import { withSession } from './withSession.js'
export const queryDrafts: QueryDrafts = async function queryDrafts( export const queryDrafts: QueryDrafts = async function queryDrafts(
this: MongooseAdapter, this: MongooseAdapter,

View File

@@ -4,7 +4,7 @@ import type { BeginTransaction } from 'payload/database'
import { APIError } from 'payload/errors' import { APIError } from 'payload/errors'
import { v4 as uuid } from 'uuid' import { v4 as uuid } from 'uuid'
import type { MongooseAdapter } from '../index' import type { MongooseAdapter } from '../index.d.ts'
export const beginTransaction: BeginTransaction = async function beginTransaction( export const beginTransaction: BeginTransaction = async function beginTransaction(
this: MongooseAdapter, this: MongooseAdapter,

View File

@@ -25,7 +25,7 @@ import type {
UploadField, UploadField,
} from 'payload/types' } from 'payload/types'
import type { BuildQueryArgs } from './queries/buildQuery' import type { BuildQueryArgs } from './queries/buildQuery.d.ts'
export interface CollectionModel extends Model<any>, PaginateModel<any> { export interface CollectionModel extends Model<any>, PaginateModel<any> {
/** buildQuery is used to transform payload's where operator into what can be used by mongoose (e.g. id => _id) */ /** buildQuery is used to transform payload's where operator into what can be used by mongoose (e.g. id => _id) */

View File

@@ -1,10 +1,10 @@
import type { UpdateGlobal } from 'payload/database' import type { UpdateGlobal } from 'payload/database'
import type { PayloadRequest } from 'payload/types' import type { PayloadRequest } from 'payload/types'
import type { MongooseAdapter } from '.' import type { MongooseAdapter } from './index.d.ts'
import sanitizeInternalFields from './utilities/sanitizeInternalFields' import sanitizeInternalFields from './utilities/sanitizeInternalFields.js'
import { withSession } from './withSession' import { withSession } from './withSession.js'
export const updateGlobal: UpdateGlobal = async function updateGlobal( export const updateGlobal: UpdateGlobal = async function updateGlobal(
this: MongooseAdapter, this: MongooseAdapter,

View File

@@ -1,9 +1,9 @@
import type { UpdateGlobalVersionArgs } from 'payload/database' import type { UpdateGlobalVersionArgs } from 'payload/database'
import type { PayloadRequest, TypeWithID } from 'payload/types' import type { PayloadRequest, TypeWithID } from 'payload/types'
import type { MongooseAdapter } from '.' import type { MongooseAdapter } from './index.d.ts'
import { withSession } from './withSession' import { withSession } from './withSession.js'
export async function updateGlobalVersion<T extends TypeWithID>( export async function updateGlobalVersion<T extends TypeWithID>(
this: MongooseAdapter, this: MongooseAdapter,

View File

@@ -1,11 +1,11 @@
import type { UpdateOne } from 'payload/database' import type { UpdateOne } from 'payload/database'
import type { PayloadRequest } from 'payload/types' import type { PayloadRequest } from 'payload/types'
import type { MongooseAdapter } from '.' import type { MongooseAdapter } from './index.d.ts'
import handleError from './utilities/handleError' import handleError from './utilities/handleError.js'
import sanitizeInternalFields from './utilities/sanitizeInternalFields' import sanitizeInternalFields from './utilities/sanitizeInternalFields.js'
import { withSession } from './withSession' import { withSession } from './withSession.js'
export const updateOne: UpdateOne = async function updateOne( export const updateOne: UpdateOne = async function updateOne(
this: MongooseAdapter, this: MongooseAdapter,

View File

@@ -1,9 +1,9 @@
import type { UpdateVersion } from 'payload/database' import type { UpdateVersion } from 'payload/database'
import type { PayloadRequest } from 'payload/types' import type { PayloadRequest } from 'payload/types'
import type { MongooseAdapter } from '.' import type { MongooseAdapter } from './index.d.ts'
import { withSession } from './withSession' import { withSession } from './withSession.js'
export const updateVersion: UpdateVersion = async function updateVersion( export const updateVersion: UpdateVersion = async function updateVersion(
this: MongooseAdapter, this: MongooseAdapter,

View File

@@ -1,6 +1,6 @@
import type { ClientSession } from 'mongoose' import type { ClientSession } from 'mongoose'
import type { MongooseAdapter } from './index' import type { MongooseAdapter } from './index.d.ts'
/** /**
* returns the session belonging to the transaction of the req.session if exists * returns the session belonging to the transaction of the req.session if exists