payload-ai 0.0.72 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -0
- package/dev/package.json +7 -10
- package/dev/src/blocks/TextBlock/index.ts +1 -1
- package/dev/src/collections/Examples.ts +1 -1
- package/dev/src/collections/ExamplesWithVersions.ts +1 -1
- package/dev/src/collections/Media.ts +1 -2
- package/dev/src/collections/Users.ts +3 -3
- package/dev/src/payload.config.ts +9 -62
- package/dev/src/server.ts +3 -12
- package/dev-v3/.cursor/rules/access-control-advanced.md +519 -0
- package/dev-v3/.cursor/rules/access-control.md +225 -0
- package/dev-v3/.cursor/rules/adapters.md +209 -0
- package/dev-v3/.cursor/rules/collections.md +171 -0
- package/dev-v3/.cursor/rules/components.md +794 -0
- package/dev-v3/.cursor/rules/endpoints.md +236 -0
- package/dev-v3/.cursor/rules/field-type-guards.md +230 -0
- package/dev-v3/.cursor/rules/fields.md +317 -0
- package/dev-v3/.cursor/rules/hooks.md +175 -0
- package/dev-v3/.cursor/rules/payload-overview.md +126 -0
- package/dev-v3/.cursor/rules/plugin-development.md +323 -0
- package/dev-v3/.cursor/rules/queries.md +223 -0
- package/dev-v3/.cursor/rules/security-critical.mdc +122 -0
- package/dev-v3/.env.example +2 -0
- package/dev-v3/.prettierrc.json +6 -0
- package/dev-v3/.vscode/extensions.json +3 -0
- package/dev-v3/.vscode/launch.json +24 -0
- package/dev-v3/.vscode/settings.json +40 -0
- package/dev-v3/.yarnrc +1 -0
- package/dev-v3/AGENTS.md +1141 -0
- package/dev-v3/Dockerfile +71 -0
- package/dev-v3/README.md +67 -0
- package/dev-v3/docker-compose.yml +43 -0
- package/dev-v3/eslint.config.mjs +38 -0
- package/dev-v3/next.config.mjs +17 -0
- package/dev-v3/package.json +61 -0
- package/dev-v3/playwright.config.ts +41 -0
- package/dev-v3/src/app/(frontend)/layout.tsx +19 -0
- package/dev-v3/src/app/(frontend)/page.tsx +59 -0
- package/dev-v3/src/app/(frontend)/styles.css +164 -0
- package/dev-v3/src/app/(payload)/admin/[[...segments]]/not-found.tsx +24 -0
- package/dev-v3/src/app/(payload)/admin/[[...segments]]/page.tsx +24 -0
- package/dev-v3/src/app/(payload)/admin/importMap.js +7 -0
- package/dev-v3/src/app/(payload)/api/[...slug]/route.ts +19 -0
- package/dev-v3/src/app/(payload)/api/graphql/route.ts +8 -0
- package/dev-v3/src/app/(payload)/api/graphql-playground/route.ts +7 -0
- package/dev-v3/src/app/(payload)/custom.scss +0 -0
- package/dev-v3/src/app/(payload)/layout.tsx +31 -0
- package/dev-v3/src/app/my-route/route.ts +12 -0
- package/dev-v3/src/collections/Media.ts +17 -0
- package/dev-v3/src/collections/Random.ts +16 -0
- package/dev-v3/src/collections/Users.ts +13 -0
- package/dev-v3/src/payload-types.ts +401 -0
- package/dev-v3/src/payload.config.ts +61 -0
- package/dev-v3/test.env +1 -0
- package/dev-v3/tests/e2e/admin.e2e.spec.ts +41 -0
- package/dev-v3/tests/e2e/frontend.e2e.spec.ts +20 -0
- package/dev-v3/tests/helpers/login.ts +31 -0
- package/dev-v3/tests/helpers/seedUser.ts +46 -0
- package/dev-v3/tests/int/api.int.spec.ts +20 -0
- package/dev-v3/tsconfig.json +44 -0
- package/dev-v3/vitest.config.mts +12 -0
- package/dev-v3/vitest.setup.ts +4 -0
- package/dev-v3/yarn.lock +6102 -0
- package/dist/access/admins.d.ts +2 -2
- package/dist/access/adminsOrPublished.d.ts +1 -1
- package/dist/access/anyone.d.ts +1 -1
- package/dist/access/validateAccess.d.ts +1 -1
- package/dist/access/validateAccess.js +22 -8
- package/dist/access/validateAccess.js.map +1 -1
- package/dist/aiCaption.d.ts +1 -1
- package/dist/aiTranslate.d.ts +1 -1
- package/dist/aiTranslate.js +26 -12
- package/dist/aiTranslate.js.map +1 -1
- package/dist/components/Metadata/index.js +6 -9
- package/dist/components/Metadata/index.js.map +1 -1
- package/dist/components/Translator/Translator.scss +64 -4
- package/dist/components/Translator/index.d.ts +0 -1
- package/dist/components/Translator/index.js +84 -95
- package/dist/components/Translator/index.js.map +1 -1
- package/dist/generateImage.js +0 -1
- package/dist/generateImage.js.map +1 -1
- package/dist/generateText.d.ts +1 -1
- package/dist/generateText.js +37 -11
- package/dist/generateText.js.map +1 -1
- package/dist/handleMissingTranslate.d.ts +1 -1
- package/dist/handleMissingTranslate.js +72 -37
- package/dist/handleMissingTranslate.js.map +1 -1
- package/dist/handleTranslate.d.ts +1 -1
- package/dist/handleTranslate.js +62 -23
- package/dist/handleTranslate.js.map +1 -1
- package/dist/onInitExtension.d.ts +1 -1
- package/dist/onInitExtension.js +2 -5
- package/dist/onInitExtension.js.map +1 -1
- package/dist/plugin.d.ts +1 -1
- package/dist/plugin.js +33 -30
- package/dist/plugin.js.map +1 -1
- package/dist/stringTranslations.d.ts +1 -1
- package/dist/stringTranslations.js +47 -34
- package/dist/stringTranslations.js.map +1 -1
- package/dist/translateTextAndObjects.js +0 -2
- package/dist/translateTextAndObjects.js.map +1 -1
- package/dist/webpack.d.ts +1 -1
- package/dist/webpack.js +1 -23
- package/dist/webpack.js.map +1 -1
- package/package.json +7 -4
- package/src/access/admins.ts +2 -2
- package/src/access/adminsOrPublished.ts +1 -1
- package/src/access/anyone.ts +1 -1
- package/src/access/validateAccess.ts +24 -9
- package/src/aiCaption.ts +1 -1
- package/src/aiTranslate.ts +21 -10
- package/src/components/Metadata/index.tsx +2 -6
- package/src/components/Translator/Translator.scss +64 -4
- package/src/components/Translator/index.tsx +131 -108
- package/src/generateImage.ts +0 -2
- package/src/generateText.ts +18 -5
- package/src/handleMissingTranslate.ts +45 -20
- package/src/handleTranslate.ts +42 -15
- package/src/onInitExtension.ts +3 -7
- package/src/plugin.ts +53 -49
- package/src/stringTranslations.ts +23 -22
- package/src/translateTextAndObjects.ts +0 -2
- package/src/webpack.ts +3 -24
package/README.md
CHANGED
|
@@ -185,3 +185,14 @@ plugins: [
|
|
|
185
185
|
- custom overrides for translation
|
|
186
186
|
- generate images based on input
|
|
187
187
|
- generate Open Graph based on content
|
|
188
|
+
|
|
189
|
+
#### Use in hooks
|
|
190
|
+
|
|
191
|
+
TODO: add documentation
|
|
192
|
+
|
|
193
|
+
myCollectionPrompt = ({source}) => {
|
|
194
|
+
|
|
195
|
+
source()
|
|
196
|
+
|
|
197
|
+
return
|
|
198
|
+
}
|
package/dev/package.json
CHANGED
|
@@ -5,27 +5,24 @@
|
|
|
5
5
|
"main": "dist/server.js",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"dev": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts
|
|
8
|
+
"dev": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts payload dev",
|
|
9
9
|
"build:payload": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts payload build",
|
|
10
10
|
"build:server": "tsc",
|
|
11
|
-
"build": "yarn copyfiles && yarn build:payload
|
|
12
|
-
"serve": "cross-env PAYLOAD_CONFIG_PATH=
|
|
11
|
+
"build": "yarn copyfiles && yarn build:payload",
|
|
12
|
+
"serve": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts payload serve",
|
|
13
13
|
"copyfiles": "copyfiles -u 1 \"src/**/*.{html,css,scss,ttf,woff,woff2,eot,svg,jpg,png}\" dist/",
|
|
14
14
|
"generate:types": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts payload generate:types",
|
|
15
15
|
"generate:graphQLSchema": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts payload generate:graphQLSchema",
|
|
16
16
|
"payload": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts payload"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@payloadcms/
|
|
20
|
-
"@payloadcms/
|
|
21
|
-
"@payloadcms/
|
|
22
|
-
"@payloadcms/plugin-seo": "^1.0.15",
|
|
23
|
-
"@payloadcms/richtext-lexical": "^0.5.2",
|
|
24
|
-
"@payloadcms/richtext-slate": "^1.3.1",
|
|
19
|
+
"@payloadcms/db-mongodb": "^3.76.1",
|
|
20
|
+
"@payloadcms/plugin-seo": "^3.76.1",
|
|
21
|
+
"@payloadcms/richtext-lexical": "^3.76.1",
|
|
25
22
|
"cross-env": "^7.0.3",
|
|
26
23
|
"dotenv": "^8.2.0",
|
|
27
24
|
"express": "^4.17.1",
|
|
28
|
-
"payload": "^
|
|
25
|
+
"payload": "^3.76.1"
|
|
29
26
|
},
|
|
30
27
|
"devDependencies": {
|
|
31
28
|
"@types/express": "^4.17.9",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { lexicalEditor } from '@payloadcms/richtext-lexical'
|
|
2
|
-
import { CollectionConfig } from 'payload
|
|
2
|
+
import type { CollectionConfig } from 'payload'
|
|
3
3
|
|
|
4
4
|
// Example Collection - For reference only, this must be added to payload.config.ts to be used.
|
|
5
5
|
const Examples: CollectionConfig = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CollectionConfig } from 'payload
|
|
1
|
+
import type { CollectionConfig } from 'payload'
|
|
2
2
|
|
|
3
3
|
export const Media: CollectionConfig = {
|
|
4
4
|
slug: 'media',
|
|
@@ -6,7 +6,6 @@ export const Media: CollectionConfig = {
|
|
|
6
6
|
read: () => true,
|
|
7
7
|
},
|
|
8
8
|
upload: {
|
|
9
|
-
staticURL: '/media',
|
|
10
9
|
staticDir: 'media',
|
|
11
10
|
imageSizes: [
|
|
12
11
|
{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CollectionConfig } from 'payload
|
|
1
|
+
import type { CollectionConfig } from 'payload'
|
|
2
2
|
|
|
3
3
|
const Users: CollectionConfig = {
|
|
4
4
|
slug: 'users',
|
|
@@ -10,6 +10,6 @@ const Users: CollectionConfig = {
|
|
|
10
10
|
// Email added by default
|
|
11
11
|
// Add more fields as needed
|
|
12
12
|
],
|
|
13
|
-
}
|
|
13
|
+
}
|
|
14
14
|
|
|
15
|
-
export default Users
|
|
15
|
+
export default Users
|
|
@@ -1,74 +1,21 @@
|
|
|
1
|
-
import { buildConfig } from 'payload
|
|
1
|
+
import { buildConfig } from 'payload'
|
|
2
2
|
import path from 'path'
|
|
3
|
-
import Users from './collections/Users'
|
|
4
|
-
import Examples from './collections/Examples'
|
|
5
|
-
import { Media } from './collections/Media'
|
|
3
|
+
import Users from './collections/Users.js'
|
|
4
|
+
import Examples from './collections/Examples.js'
|
|
5
|
+
import { Media } from './collections/Media.js'
|
|
6
6
|
import { mongooseAdapter } from '@payloadcms/db-mongodb'
|
|
7
|
-
import { webpackBundler } from '@payloadcms/bundler-webpack'
|
|
8
7
|
//import { slateEditor } from '@payloadcms/richtext-slate'
|
|
9
|
-
|
|
10
|
-
import
|
|
11
|
-
|
|
12
|
-
BoldTextFeature,
|
|
13
|
-
LinkFeature,
|
|
14
|
-
lexicalEditor,
|
|
15
|
-
} from '@payloadcms/richtext-lexical'
|
|
16
|
-
import { aiTranslatorPlugin, generateDescription, generateTitle } from '../../src/index'
|
|
17
|
-
import ExamplesWithVersions from './collections/ExamplesWithVersions'
|
|
18
|
-
import seo from '@payloadcms/plugin-seo'
|
|
19
|
-
import { TextBlock } from './blocks/TextBlock'
|
|
8
|
+
import { aiTranslatorPlugin, generateDescription, generateTitle } from '../../dist/index.js'
|
|
9
|
+
import ExamplesWithVersions from './collections/ExamplesWithVersions.js'
|
|
10
|
+
import { seoPlugin } from '@payloadcms/plugin-seo'
|
|
20
11
|
|
|
21
12
|
export default buildConfig({
|
|
13
|
+
secret: process.env.PAYLOAD_SECRET || 'dev-secret',
|
|
22
14
|
admin: {
|
|
23
15
|
user: Users.slug,
|
|
24
|
-
bundler: webpackBundler(),
|
|
25
|
-
webpack: config => {
|
|
26
|
-
const newConfig = {
|
|
27
|
-
...config,
|
|
28
|
-
resolve: {
|
|
29
|
-
...config.resolve,
|
|
30
|
-
alias: {
|
|
31
|
-
...(config?.resolve?.alias || {}),
|
|
32
|
-
react: path.join(__dirname, '../node_modules/react'),
|
|
33
|
-
'react-dom': path.join(__dirname, '../node_modules/react-dom'),
|
|
34
|
-
payload: path.join(__dirname, '../node_modules/payload'),
|
|
35
|
-
// payload: path.join(__dirname, '../node_modules/payload'),
|
|
36
|
-
// '@faceless-ui/modal': path.join(__dirname, '../node_modules/@faceless-ui/modal'),
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
}
|
|
40
|
-
return newConfig
|
|
41
|
-
},
|
|
42
16
|
},
|
|
43
17
|
collections: [Examples, ExamplesWithVersions, Users, Media],
|
|
44
18
|
//editor: slateEditor({}),
|
|
45
|
-
|
|
46
|
-
editor: lexicalEditor({
|
|
47
|
-
features: ({ defaultFeatures }) => [
|
|
48
|
-
...defaultFeatures,
|
|
49
|
-
|
|
50
|
-
LinkFeature({
|
|
51
|
-
// Example showing how to customize the built-in fields
|
|
52
|
-
// of the Link feature
|
|
53
|
-
fields: [
|
|
54
|
-
{
|
|
55
|
-
name: 'rel',
|
|
56
|
-
label: 'Rel Attribute',
|
|
57
|
-
type: 'select',
|
|
58
|
-
hasMany: true,
|
|
59
|
-
options: ['noopener', 'noreferrer', 'nofollow'],
|
|
60
|
-
admin: {
|
|
61
|
-
description:
|
|
62
|
-
'The rel attribute defines the relationship between a linked resource and the current document. This is a custom link field.',
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
],
|
|
66
|
-
}),
|
|
67
|
-
BlocksFeature({
|
|
68
|
-
blocks: [TextBlock],
|
|
69
|
-
}),
|
|
70
|
-
],
|
|
71
|
-
}),
|
|
72
19
|
localization: {
|
|
73
20
|
locales: ['en', 'de' /*'ja' 'es','fr', 'it', 'ja' */],
|
|
74
21
|
defaultLocale: 'en',
|
|
@@ -111,7 +58,7 @@ export default buildConfig({
|
|
|
111
58
|
},
|
|
112
59
|
},
|
|
113
60
|
}),
|
|
114
|
-
|
|
61
|
+
seoPlugin({
|
|
115
62
|
collections: ['examples'],
|
|
116
63
|
// uploadsCollection: 'media',
|
|
117
64
|
generateTitle: generateTitle,
|
package/dev/src/server.ts
CHANGED
|
@@ -1,27 +1,18 @@
|
|
|
1
|
-
import express from 'express'
|
|
2
1
|
import payload from 'payload'
|
|
3
|
-
import { InitOptions } from 'payload
|
|
2
|
+
import { InitOptions } from 'payload'
|
|
3
|
+
import config from './payload.config'
|
|
4
4
|
|
|
5
5
|
require('dotenv').config()
|
|
6
|
-
const app = express()
|
|
7
|
-
|
|
8
|
-
// Redirect root to Admin panel
|
|
9
|
-
app.get('/', (_, res) => {
|
|
10
|
-
res.redirect('/admin')
|
|
11
|
-
})
|
|
12
6
|
|
|
13
7
|
export const start = async (args?: Partial<InitOptions>) => {
|
|
14
8
|
// Initialize Payload
|
|
15
9
|
await payload.init({
|
|
16
|
-
|
|
17
|
-
express: app,
|
|
10
|
+
config,
|
|
18
11
|
onInit: async () => {
|
|
19
12
|
payload.logger.info(`Payload Admin URL: ${payload.getAdminURL()}`)
|
|
20
13
|
},
|
|
21
14
|
...(args || {}),
|
|
22
15
|
})
|
|
23
|
-
|
|
24
|
-
app.listen(3000)
|
|
25
16
|
}
|
|
26
17
|
|
|
27
18
|
start()
|