Move payload-types dir

This commit is contained in:
tobias 2024-06-23 10:31:42 +02:00
parent e002125805
commit ace6e50b73
4 changed files with 26 additions and 184 deletions

2
.gitignore vendored
View File

@ -41,3 +41,5 @@ next-env.d.ts
.env
/media
/types/payload-types.ts

View File

@ -1,120 +0,0 @@
/* tslint:disable */
/* eslint-disable */
/**
* This file was automatically generated by Payload.
* DO NOT MODIFY IT BY HAND. Instead, modify your source Payload config,
* and re-run `payload generate:types` to regenerate this file.
*/
export interface Config {
collections: {
users: User;
pages: Page;
media: Media;
'payload-preferences': PayloadPreference;
'payload-migrations': PayloadMigration;
};
globals: {};
locale: null;
user: User & {
collection: 'users';
};
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "users".
*/
export interface User {
id: string;
updatedAt: string;
createdAt: string;
email: string;
resetPasswordToken?: string | null;
resetPasswordExpiration?: string | null;
salt?: string | null;
hash?: string | null;
loginAttempts?: number | null;
lockUntil?: string | null;
password?: string | null;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "pages".
*/
export interface Page {
id: string;
title?: string | null;
content?: {
root: {
type: string;
children: {
type: string;
version: number;
[k: string]: unknown;
}[];
direction: ('ltr' | 'rtl') | null;
format: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | '';
indent: number;
version: number;
};
[k: string]: unknown;
} | null;
updatedAt: string;
createdAt: string;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "media".
*/
export interface Media {
id: string;
text?: string | null;
updatedAt: string;
createdAt: string;
url?: string | null;
thumbnailURL?: string | null;
filename?: string | null;
mimeType?: string | null;
filesize?: number | null;
width?: number | null;
height?: number | null;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "payload-preferences".
*/
export interface PayloadPreference {
id: string;
user: {
relationTo: 'users';
value: string | User;
};
key?: string | null;
value?:
| {
[k: string]: unknown;
}
| unknown[]
| string
| number
| boolean
| null;
updatedAt: string;
createdAt: string;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "payload-migrations".
*/
export interface PayloadMigration {
id: string;
name?: string | null;
batch?: number | null;
updatedAt: string;
createdAt: string;
}
declare module 'payload' {
export interface GeneratedTypes extends Config {}
}

View File

@ -1,5 +1,4 @@
import path from 'path'
// import { postgresAdapter } from '@payloadcms/db-postgres'
import { en } from 'payload/i18n/en'
import {
AlignFeature,
@ -19,28 +18,33 @@ import {
UnorderedListFeature,
UploadFeature,
} from '@payloadcms/richtext-lexical'
//import { slateEditor } from '@payloadcms/richtext-slate'
import { mongooseAdapter } from '@payloadcms/db-mongodb'
import { buildConfig } from 'payload/config'
import sharp from 'sharp'
import { fileURLToPath } from 'url'
import Media from '@payload/collections/Media'
import Authors from '@payload/collections/Authors'
import Posts from '@payload/collections/Posts'
import Users from '@payload/collections/Users'
const filename = fileURLToPath(import.meta.url)
const dirname = path.dirname(filename)
export default buildConfig({
//editor: slateEditor({}),
admin: {
autoLogin: {
email: 'dev@payloadcms.com',
password: 'test',
prefillOnly: true,
},
},
editor: lexicalEditor(),
collections: [
{
slug: 'users',
auth: true,
access: {
delete: () => false,
update: () => false,
},
fields: [],
},
Users,
Posts,
Authors,
Media,
{
slug: 'pages',
admin: {
@ -57,45 +61,14 @@ export default buildConfig({
},
],
},
{
slug: 'media',
upload: true,
fields: [
{
name: 'text',
type: 'text',
},
],
},
],
secret: process.env.PAYLOAD_SECRET || '',
typescript: {
outputFile: path.resolve(dirname, 'payload-types.ts'),
outputFile: path.resolve(dirname, 'types/payload-types.ts'),
},
// db: postgresAdapter({
// pool: {
// connectionString: process.env.POSTGRES_URI || ''
// }
// }),
db: mongooseAdapter({
url: process.env.MONGODB_URI || '',
}),
/**
* Payload can now accept specific translations from 'payload/i18n/en'
* This is completely optional and will default to English if not provided
*/
i18n: {
supportedLanguages: { en },
},
admin: {
autoLogin: {
email: 'dev@payloadcms.com',
password: 'test',
prefillOnly: true,
},
},
async onInit(payload) {
const existingUsers = await payload.find({
collection: 'users',

View File

@ -1,11 +1,7 @@
{
"compilerOptions": {
"baseUrl": ".",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
@ -23,22 +19,13 @@
}
],
"paths": {
"@/*": [
"./src/*"
],
"@payload-config": [
"./payload.config.ts"
]
"@/*": ["./src/*"],
"@payload/*": ["./src/app/(payload)/*"],
"@app/*": ["./src/app/(app)/*"],
"@payload-config": ["./payload.config.ts"]
},
"target": "ES2017"
},
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts"
],
"exclude": [
"node_modules"
]
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
}