chore: misc cleanup (#9206)
- Proper error logger usage - Some no-fallthrough warning cleanup
This commit is contained in:
@@ -29,7 +29,6 @@
|
|||||||
"types": "./src/index.ts",
|
"types": "./src/index.ts",
|
||||||
"files": [
|
"files": [
|
||||||
"dist",
|
"dist",
|
||||||
"mock.js",
|
|
||||||
"predefinedMigrations"
|
"predefinedMigrations"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -106,7 +106,6 @@ const traverseFields = ({
|
|||||||
switch (field.type) {
|
switch (field.type) {
|
||||||
case 'array':
|
case 'array':
|
||||||
case 'group':
|
case 'group':
|
||||||
|
|
||||||
case 'tab': {
|
case 'tab': {
|
||||||
let fieldSelect: SelectType
|
let fieldSelect: SelectType
|
||||||
|
|
||||||
|
|||||||
@@ -58,8 +58,8 @@ export const traverseFields = (args: Args) => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
case 'collapsible':
|
|
||||||
|
|
||||||
|
case 'collapsible':
|
||||||
case 'row': {
|
case 'row': {
|
||||||
return traverseFields({
|
return traverseFields({
|
||||||
...args,
|
...args,
|
||||||
@@ -84,7 +84,6 @@ export const traverseFields = (args: Args) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case 'relationship':
|
case 'relationship':
|
||||||
|
|
||||||
case 'upload': {
|
case 'upload': {
|
||||||
if (typeof field.relationTo === 'string') {
|
if (typeof field.relationTo === 'string') {
|
||||||
if (field.type === 'upload' || !field.hasMany) {
|
if (field.type === 'upload' || !field.hasMany) {
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import type { DrizzleAdapter } from '@payloadcms/drizzle/types'
|
import type { DrizzleAdapter } from '@payloadcms/drizzle/types'
|
||||||
import type { LibSQLDatabase } from 'drizzle-orm/libsql'
|
|
||||||
import type { Connect } from 'payload'
|
import type { Connect } from 'payload'
|
||||||
|
|
||||||
import { createClient } from '@libsql/client'
|
import { createClient } from '@libsql/client'
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import type {
|
|||||||
SQLiteTableWithColumns,
|
SQLiteTableWithColumns,
|
||||||
UniqueConstraintBuilder,
|
UniqueConstraintBuilder,
|
||||||
} from 'drizzle-orm/sqlite-core'
|
} from 'drizzle-orm/sqlite-core'
|
||||||
import type { Field, SanitizedJoins } from 'payload'
|
import type { Field } from 'payload'
|
||||||
|
|
||||||
import { buildIndexName, createTableName } from '@payloadcms/drizzle'
|
import { buildIndexName, createTableName } from '@payloadcms/drizzle'
|
||||||
import { relations, sql } from 'drizzle-orm'
|
import { relations, sql } from 'drizzle-orm'
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import type { DrizzleAdapter } from '@payloadcms/drizzle/types'
|
import type { DrizzleAdapter } from '@payloadcms/drizzle/types'
|
||||||
import type { Relation } from 'drizzle-orm'
|
import type { Relation } from 'drizzle-orm'
|
||||||
import type { IndexBuilder, SQLiteColumnBuilder } from 'drizzle-orm/sqlite-core'
|
import type { IndexBuilder, SQLiteColumnBuilder } from 'drizzle-orm/sqlite-core'
|
||||||
import type { Field, SanitizedJoins, TabAsField } from 'payload'
|
import type { Field, TabAsField } from 'payload'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
buildIndexName,
|
buildIndexName,
|
||||||
@@ -472,16 +472,15 @@ export const traverseFields = ({
|
|||||||
targetTable[fieldName] = withDefault(integer(columnName, { mode: 'boolean' }), field)
|
targetTable[fieldName] = withDefault(integer(columnName, { mode: 'boolean' }), field)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'code':
|
case 'code':
|
||||||
|
|
||||||
case 'email':
|
case 'email':
|
||||||
|
|
||||||
case 'textarea': {
|
case 'textarea': {
|
||||||
targetTable[fieldName] = withDefault(text(columnName), field)
|
targetTable[fieldName] = withDefault(text(columnName), field)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
case 'collapsible':
|
|
||||||
|
|
||||||
|
case 'collapsible':
|
||||||
case 'row': {
|
case 'row': {
|
||||||
const disableNotNullFromHere = Boolean(field.admin?.condition) || disableNotNull
|
const disableNotNullFromHere = Boolean(field.admin?.condition) || disableNotNull
|
||||||
const {
|
const {
|
||||||
@@ -654,7 +653,6 @@ export const traverseFields = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
case 'json':
|
case 'json':
|
||||||
|
|
||||||
case 'richText': {
|
case 'richText': {
|
||||||
targetTable[fieldName] = withDefault(text(columnName, { mode: 'json' }), field)
|
targetTable[fieldName] = withDefault(text(columnName, { mode: 'json' }), field)
|
||||||
break
|
break
|
||||||
@@ -691,8 +689,8 @@ export const traverseFields = ({
|
|||||||
case 'point': {
|
case 'point': {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
case 'radio':
|
|
||||||
|
|
||||||
|
case 'radio':
|
||||||
case 'select': {
|
case 'select': {
|
||||||
const options = field.options.map((option) => {
|
const options = field.options.map((option) => {
|
||||||
if (optionIsObject(option)) {
|
if (optionIsObject(option)) {
|
||||||
|
|||||||
@@ -58,8 +58,8 @@ export const traverseFields = (args: Args) => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
case 'collapsible':
|
|
||||||
|
|
||||||
|
case 'collapsible':
|
||||||
case 'row': {
|
case 'row': {
|
||||||
return traverseFields({
|
return traverseFields({
|
||||||
...args,
|
...args,
|
||||||
@@ -84,7 +84,6 @@ export const traverseFields = (args: Args) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case 'relationship':
|
case 'relationship':
|
||||||
|
|
||||||
case 'upload': {
|
case 'upload': {
|
||||||
if (typeof field.relationTo === 'string') {
|
if (typeof field.relationTo === 'string') {
|
||||||
if (field.type === 'upload' || !field.hasMany) {
|
if (field.type === 'upload' || !field.hasMany) {
|
||||||
|
|||||||
@@ -87,9 +87,8 @@ export const sendEmail = async (
|
|||||||
return emailPromise
|
return emailPromise
|
||||||
} catch (err: unknown) {
|
} catch (err: unknown) {
|
||||||
payload.logger.error({
|
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) {
|
} catch (err: unknown) {
|
||||||
const msg = `Error while sending one or more emails in form submission id: ${formSubmissionID}.`
|
const msg = `Error while sending one or more emails in form submission id: ${formSubmissionID}.`
|
||||||
payload.logger.error({ err: msg })
|
payload.logger.error({ err, msg })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -113,7 +113,10 @@ export const syncWithSearch: SyncWithSearch = async (args) => {
|
|||||||
where: { id: { in: duplicativeDocIDs } },
|
where: { id: { in: duplicativeDocIDs } },
|
||||||
})
|
})
|
||||||
} catch (err: unknown) {
|
} 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,
|
req,
|
||||||
})
|
})
|
||||||
} catch (err: unknown) {
|
} catch (err: unknown) {
|
||||||
payload.logger.error(`Error updating ${searchSlug} document.`)
|
payload.logger.error({ err, msg: `Error updating ${searchSlug} document.` })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (deleteDrafts && status === 'draft') {
|
if (deleteDrafts && status === 'draft') {
|
||||||
|
|||||||
@@ -213,7 +213,6 @@ export const buildTableState = async (
|
|||||||
}
|
}
|
||||||
|
|
||||||
const fields = collectionConfig.fields
|
const fields = collectionConfig.fields
|
||||||
const clientFields = clientCollectionConfig?.fields || []
|
|
||||||
|
|
||||||
let docs = docsFromArgs
|
let docs = docsFromArgs
|
||||||
let data: PaginatedDocs
|
let data: PaginatedDocs
|
||||||
|
|||||||
Reference in New Issue
Block a user