Types are now auto-generated by default.
You can opt-out of this behavior by setting:
```ts
buildConfig({
// Rest of config
typescript: {
autoGenerate: false
},
})
```
63 lines
1.4 KiB
TypeScript
63 lines
1.4 KiB
TypeScript
import { fileURLToPath } from 'node:url'
|
|
import path from 'path'
|
|
const filename = fileURLToPath(import.meta.url)
|
|
const dirname = path.dirname(filename)
|
|
import { buildConfigWithDefaults } from '../buildConfigWithDefaults.js'
|
|
import { devUser } from '../credentials.js'
|
|
import { arraySlug } from './shared.js'
|
|
|
|
export default buildConfigWithDefaults({
|
|
collections: [
|
|
{
|
|
slug: arraySlug,
|
|
fields: [
|
|
{
|
|
name: 'arrayOfFields',
|
|
type: 'array',
|
|
admin: {
|
|
initCollapsed: true,
|
|
},
|
|
fields: [
|
|
{
|
|
type: 'text',
|
|
name: 'required',
|
|
required: true,
|
|
},
|
|
{
|
|
type: 'text',
|
|
name: 'optional',
|
|
},
|
|
{
|
|
name: 'innerArrayOfFields',
|
|
type: 'array',
|
|
fields: [
|
|
{
|
|
type: 'text',
|
|
name: 'required',
|
|
required: true,
|
|
},
|
|
{
|
|
type: 'text',
|
|
name: 'optional',
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
],
|
|
onInit: async (payload) => {
|
|
await payload.create({
|
|
collection: 'users',
|
|
data: {
|
|
email: devUser.email,
|
|
password: devUser.password,
|
|
},
|
|
})
|
|
},
|
|
typescript: {
|
|
outputFile: path.resolve(dirname, 'payload-types.ts'),
|
|
},
|
|
})
|