chore: misc cleanup (#9206)

- Proper error logger usage
- Some no-fallthrough warning cleanup
This commit is contained in:
Elliot DeNolf
2024-11-14 11:14:08 -05:00
committed by GitHub
parent e6d04436a8
commit 5ff1bb366c
11 changed files with 15 additions and 21 deletions

View File

@@ -29,7 +29,6 @@
"types": "./src/index.ts",
"files": [
"dist",
"mock.js",
"predefinedMigrations"
],
"scripts": {

View File

@@ -106,7 +106,6 @@ const traverseFields = ({
switch (field.type) {
case 'array':
case 'group':
case 'tab': {
let fieldSelect: SelectType

View File

@@ -58,8 +58,8 @@ export const traverseFields = (args: Args) => {
})
})
}
case 'collapsible':
case 'collapsible':
case 'row': {
return traverseFields({
...args,
@@ -84,7 +84,6 @@ export const traverseFields = (args: Args) => {
}
case 'relationship':
case 'upload': {
if (typeof field.relationTo === 'string') {
if (field.type === 'upload' || !field.hasMany) {

View File

@@ -1,5 +1,4 @@
import type { DrizzleAdapter } from '@payloadcms/drizzle/types'
import type { LibSQLDatabase } from 'drizzle-orm/libsql'
import type { Connect } from 'payload'
import { createClient } from '@libsql/client'

View File

@@ -8,7 +8,7 @@ import type {
SQLiteTableWithColumns,
UniqueConstraintBuilder,
} from 'drizzle-orm/sqlite-core'
import type { Field, SanitizedJoins } from 'payload'
import type { Field } from 'payload'
import { buildIndexName, createTableName } from '@payloadcms/drizzle'
import { relations, sql } from 'drizzle-orm'

View File

@@ -1,7 +1,7 @@
import type { DrizzleAdapter } from '@payloadcms/drizzle/types'
import type { Relation } from 'drizzle-orm'
import type { IndexBuilder, SQLiteColumnBuilder } from 'drizzle-orm/sqlite-core'
import type { Field, SanitizedJoins, TabAsField } from 'payload'
import type { Field, TabAsField } from 'payload'
import {
buildIndexName,
@@ -472,16 +472,15 @@ export const traverseFields = ({
targetTable[fieldName] = withDefault(integer(columnName, { mode: 'boolean' }), field)
break
}
case 'code':
case 'email':
case 'textarea': {
targetTable[fieldName] = withDefault(text(columnName), field)
break
}
case 'collapsible':
case 'collapsible':
case 'row': {
const disableNotNullFromHere = Boolean(field.admin?.condition) || disableNotNull
const {
@@ -654,7 +653,6 @@ export const traverseFields = ({
}
case 'json':
case 'richText': {
targetTable[fieldName] = withDefault(text(columnName, { mode: 'json' }), field)
break
@@ -691,8 +689,8 @@ export const traverseFields = ({
case 'point': {
break
}
case 'radio':
case 'radio':
case 'select': {
const options = field.options.map((option) => {
if (optionIsObject(option)) {

View File

@@ -58,8 +58,8 @@ export const traverseFields = (args: Args) => {
})
})
}
case 'collapsible':
case 'collapsible':
case 'row': {
return traverseFields({
...args,
@@ -84,7 +84,6 @@ export const traverseFields = (args: Args) => {
}
case 'relationship':
case 'upload': {
if (typeof field.relationTo === 'string') {
if (field.type === 'upload' || !field.hasMany) {

View File

@@ -87,9 +87,8 @@ export const sendEmail = async (
return emailPromise
} catch (err: unknown) {
payload.logger.error({
err: `Error while sending email to address: ${to}. Email not sent: ${JSON.stringify(
err,
)}`,
err,
msg: `Error while sending email to address: ${to}. Email not sent.`,
})
}
}),
@@ -99,7 +98,7 @@ export const sendEmail = async (
}
} catch (err: unknown) {
const msg = `Error while sending one or more emails in form submission id: ${formSubmissionID}.`
payload.logger.error({ err: msg })
payload.logger.error({ err, msg })
}
}

View File

@@ -113,7 +113,10 @@ export const syncWithSearch: SyncWithSearch = async (args) => {
where: { id: { in: duplicativeDocIDs } },
})
} catch (err: unknown) {
payload.logger.error(`Error deleting duplicative ${searchSlug} documents.`)
payload.logger.error({
err,
msg: `Error deleting duplicative ${searchSlug} documents.`,
})
}
}
@@ -134,7 +137,7 @@ export const syncWithSearch: SyncWithSearch = async (args) => {
req,
})
} catch (err: unknown) {
payload.logger.error(`Error updating ${searchSlug} document.`)
payload.logger.error({ err, msg: `Error updating ${searchSlug} document.` })
}
}
if (deleteDrafts && status === 'draft') {

View File

@@ -213,7 +213,6 @@ export const buildTableState = async (
}
const fields = collectionConfig.fields
const clientFields = clientCollectionConfig?.fields || []
let docs = docsFromArgs
let data: PaginatedDocs