open up access for api import

This commit is contained in:
Yehoshua Sandler 2025-04-15 11:30:48 -05:00
parent 797054a550
commit 13e716e91f
8 changed files with 53 additions and 89721 deletions

View File

@ -12,9 +12,11 @@
"generate:types": "cross-env NODE_OPTIONS=--no-deprecation payload generate:types", "generate:types": "cross-env NODE_OPTIONS=--no-deprecation payload generate:types",
"lint": "cross-env NODE_OPTIONS=--no-deprecation next lint", "lint": "cross-env NODE_OPTIONS=--no-deprecation next lint",
"payload": "cross-env NODE_OPTIONS=--no-deprecation payload", "payload": "cross-env NODE_OPTIONS=--no-deprecation payload",
"start": "cross-env NODE_OPTIONS=--no-deprecation next start" "start": "cross-env NODE_OPTIONS=--no-deprecation next start",
"import": "cd ./import/ && tsc ./parseLibraryThingExport.ts --module esnext && node ./parseLibraryThingExport.js"
}, },
"dependencies": { "dependencies": {
"@payloadcms/db-postgres": "3.31.0",
"@payloadcms/next": "3.31.0", "@payloadcms/next": "3.31.0",
"@payloadcms/payload-cloud": "3.31.0", "@payloadcms/payload-cloud": "3.31.0",
"@payloadcms/richtext-lexical": "3.31.0", "@payloadcms/richtext-lexical": "3.31.0",
@ -24,8 +26,7 @@
"payload": "3.31.0", "payload": "3.31.0",
"react": "19.0.0", "react": "19.0.0",
"react-dom": "19.0.0", "react-dom": "19.0.0",
"sharp": "0.32.6", "sharp": "0.32.6"
"@payloadcms/db-postgres": "3.31.0"
}, },
"devDependencies": { "devDependencies": {
"@eslint/eslintrc": "^3.2.0", "@eslint/eslintrc": "^3.2.0",

View File

@ -1,11 +1,20 @@
import { access } from 'node:fs/promises'
import type { CollectionConfig } from 'payload' import type { CollectionConfig } from 'payload'
export const Authors: CollectionConfig = { export const Authors: CollectionConfig = {
slug: 'authors', slug: 'authors',
admin: { admin: {
useAsTitle: 'lf' useAsTitle: 'lf',
pagination: {
limits: [10, 20, 50, 100, 250],
}
},
access: {
read: () => true,
update: () => true,
create: () => true,
admin: () => true,
}, },
fields: [ fields: [
{ {
name: 'lf', name: 'lf',
@ -31,6 +40,10 @@ export const Authors: CollectionConfig = {
label: 'Translator', label: 'Translator',
value: 'Translator' value: 'Translator'
}, },
{
label: 'Editor',
value: 'Editor'
},
], ],
}, },
], ],

View File

@ -5,6 +5,12 @@ export const Books: CollectionConfig = {
admin: { admin: {
useAsTitle: 'title' useAsTitle: 'title'
}, },
access: {
read: () => true,
update: () => true,
create: () => true,
admin: () => true,
},
fields: [ fields: [
{ {
name: "books_id", // This is from the import name: "books_id", // This is from the import
@ -24,6 +30,7 @@ export const Books: CollectionConfig = {
type: "relationship", type: "relationship",
relationTo: "authors", relationTo: "authors",
hasMany: true, hasMany: true,
maxDepth: 3,
}, },
{ {
name: 'pages', name: 'pages',
@ -32,7 +39,6 @@ export const Books: CollectionConfig = {
{ {
name: 'lcc', name: 'lcc',
type: 'text', type: 'text',
unique: true,
}, },
{ {
name: 'publication', name: 'publication',
@ -41,12 +47,7 @@ export const Books: CollectionConfig = {
{ {
label: 'Publication Date', label: 'Publication Date',
name: 'date', name: 'date',
type: 'date', type: 'string',
admin: {
date: {
pickerAppearance: 'dayOnly'
}
},
}, },
{ {
name: 'genre', name: 'genre',
@ -58,6 +59,10 @@ export const Books: CollectionConfig = {
allowCreate: true allowCreate: true
} }
}, },
{
type: 'textarea',
name: 'summary',
},
{ {
name: 'description', name: 'description',
type: 'richText' type: 'richText'

View File

@ -2,6 +2,15 @@ import { CollectionConfig } from "payload";
export const Genre: CollectionConfig = { export const Genre: CollectionConfig = {
slug: 'genre', slug: 'genre',
admin: {
useAsTitle: 'name',
},
access: {
read: () => true,
update: () => true,
create: () => true,
admin: () => true,
},
fields: [ fields: [
{ {
name: 'name', name: 'name',

View File

@ -9,5 +9,11 @@ export const Users: CollectionConfig = {
fields: [ fields: [
// Email added by default // Email added by default
// Add more fields as needed // Add more fields as needed
{
name: 'role',
type: 'select',
options: ['admin', 'user'],
saveToJWT: true
}
], ],
} }

View File

@ -129,6 +129,7 @@ export interface UserAuthOperations {
*/ */
export interface User { export interface User {
id: number; id: number;
role?: ('admin' | 'user') | null;
updatedAt: string; updatedAt: string;
createdAt: string; createdAt: string;
email: string; email: string;
@ -171,8 +172,8 @@ export interface Book {
pages?: number | null; pages?: number | null;
lcc?: string | null; lcc?: string | null;
publication?: string | null; publication?: string | null;
date?: string | null;
genre?: (number | Genre)[] | null; genre?: (number | Genre)[] | null;
summary?: string | null;
description?: { description?: {
root: { root: {
type: string; type: string;
@ -199,7 +200,7 @@ export interface Author {
id: number; id: number;
lf: string; lf: string;
fl?: string | null; fl?: string | null;
role?: ('Author' | 'Translator') | null; role?: ('Author' | 'Translator' | 'Editor') | null;
updatedAt: string; updatedAt: string;
createdAt: string; createdAt: string;
} }
@ -338,6 +339,7 @@ export interface PayloadMigration {
* via the `definition` "users_select". * via the `definition` "users_select".
*/ */
export interface UsersSelect<T extends boolean = true> { export interface UsersSelect<T extends boolean = true> {
role?: T;
updatedAt?: T; updatedAt?: T;
createdAt?: T; createdAt?: T;
email?: T; email?: T;
@ -379,6 +381,7 @@ export interface BooksSelect<T extends boolean = true> {
publication?: T; publication?: T;
date?: T; date?: T;
genre?: T; genre?: T;
summary?: T;
description?: T; description?: T;
updatedAt?: T; updatedAt?: T;
createdAt?: T; createdAt?: T;

View File

@ -25,8 +25,8 @@ export default buildConfig({
}, },
dateFormat: 'MM/dd/yyyy', dateFormat: 'MM/dd/yyyy',
}, },
cors: [process.env.DOMAIN_NAME || ''], //cors: [process.env.DOMAIN_NAME || ''],
csrf: [process.env.DOMAIN_NAME || ''], //csrf: [process.env.DOMAIN_NAME || ''],
upload: { upload: {
limits: { limits: {
fileSize: 5000000, // in bytes fileSize: 5000000, // in bytes

File diff suppressed because it is too large Load Diff