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 .env
/media /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 path from 'path'
// import { postgresAdapter } from '@payloadcms/db-postgres'
import { en } from 'payload/i18n/en' import { en } from 'payload/i18n/en'
import { import {
AlignFeature, AlignFeature,
@ -19,28 +18,33 @@ import {
UnorderedListFeature, UnorderedListFeature,
UploadFeature, UploadFeature,
} from '@payloadcms/richtext-lexical' } from '@payloadcms/richtext-lexical'
//import { slateEditor } from '@payloadcms/richtext-slate'
import { mongooseAdapter } from '@payloadcms/db-mongodb' import { mongooseAdapter } from '@payloadcms/db-mongodb'
import { buildConfig } from 'payload/config' import { buildConfig } from 'payload/config'
import sharp from 'sharp' import sharp from 'sharp'
import { fileURLToPath } from 'url' 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 filename = fileURLToPath(import.meta.url)
const dirname = path.dirname(filename) const dirname = path.dirname(filename)
export default buildConfig({ export default buildConfig({
//editor: slateEditor({}), admin: {
autoLogin: {
email: 'dev@payloadcms.com',
password: 'test',
prefillOnly: true,
},
},
editor: lexicalEditor(), editor: lexicalEditor(),
collections: [ collections: [
{ Users,
slug: 'users', Posts,
auth: true, Authors,
access: { Media,
delete: () => false,
update: () => false,
},
fields: [],
},
{ {
slug: 'pages', slug: 'pages',
admin: { admin: {
@ -57,45 +61,14 @@ export default buildConfig({
}, },
], ],
}, },
{
slug: 'media',
upload: true,
fields: [
{
name: 'text',
type: 'text',
},
],
},
], ],
secret: process.env.PAYLOAD_SECRET || '', secret: process.env.PAYLOAD_SECRET || '',
typescript: { 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({ db: mongooseAdapter({
url: process.env.MONGODB_URI || '', 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) { async onInit(payload) {
const existingUsers = await payload.find({ const existingUsers = await payload.find({
collection: 'users', collection: 'users',

View File

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