Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,8 @@ jobs:

- name: Build
run: pnpm build

# The dev app is the only place dev/ is type-checked and where the plugin
# source is compiled by Next.js, so build it to keep the playground working.
- name: Build dev app
run: pnpm dev:build
1 change: 1 addition & 0 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ pnpm test # unit tests (src/**/*.test.ts)
pnpm test:int # integration tests: boots the dev app against SQLite (dev/int.spec.ts)
pnpm test:e2e # Playwright against `pnpm dev` on port 3300 (dev/e2e.spec.ts)
pnpm build # compile to dist/
pnpm dev:build # production build of the dev app (type-checks dev/ and src/ together)
```

CI (`.github/workflows/ci.yml`) runs `scripts/check-readme-peer-version.sh`,
Expand Down
25 changes: 12 additions & 13 deletions dev/app/(frontend)/dashboard/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use client'

import { useState, useEffect } from 'react'
import Link from 'next/link'

interface EmailStats {
total: number
Expand Down Expand Up @@ -111,7 +110,7 @@ export default function HomePage() {
</p>

<div style={{ display: 'flex', gap: '16px', justifyContent: 'center', flexWrap: 'wrap' }}>
<Link
<a
href="/admin"
style={{
backgroundColor: '#3b82f6',
Expand All @@ -124,8 +123,8 @@ export default function HomePage() {
}}
>
📊 Admin Panel
</Link>
<Link
</a>
<a
href="/mailing-test"
style={{
backgroundColor: '#10b981',
Expand All @@ -138,8 +137,8 @@ export default function HomePage() {
}}
>
🧪 Test Interface
</Link>
<Link
</a>
<a
href="/sent-emails"
style={{
backgroundColor: '#8b5cf6',
Expand All @@ -152,7 +151,7 @@ export default function HomePage() {
}}
>
📬 Sent Emails
</Link>
</a>
</div>
</div>

Expand Down Expand Up @@ -260,7 +259,7 @@ export default function HomePage() {
<p style={{ color: '#6b7280', marginBottom: '12px', fontSize: '0.9rem' }}>
Send test emails using templates with the interactive testing interface.
</p>
<Link
<a
href="/mailing-test"
style={{
color: '#3b82f6',
Expand All @@ -269,15 +268,15 @@ export default function HomePage() {
}}
>
Open Test Interface →
</Link>
</a>
</div>

<div style={{ padding: '16px', backgroundColor: '#f9fafb', borderRadius: '8px' }}>
<h4 style={{ marginBottom: '8px', color: '#1f2937' }}>📝 Manage Templates</h4>
<p style={{ color: '#6b7280', marginBottom: '12px', fontSize: '0.9rem' }}>
Create and edit email templates in the Payload admin interface.
</p>
<Link
<a
href="/admin/collections/email-templates"
style={{
color: '#3b82f6',
Expand All @@ -286,15 +285,15 @@ export default function HomePage() {
}}
>
Manage Templates →
</Link>
</a>
</div>

<div style={{ padding: '16px', backgroundColor: '#f9fafb', borderRadius: '8px' }}>
<h4 style={{ marginBottom: '8px', color: '#1f2937' }}>📬 Email Queue</h4>
<p style={{ color: '#6b7280', marginBottom: '12px', fontSize: '0.9rem' }}>
View and manage the email outbox and delivery status.
</p>
<Link
<a
href="/admin/collections/emails"
style={{
color: '#3b82f6',
Expand All @@ -303,7 +302,7 @@ export default function HomePage() {
}}
>
View Email Queue →
</Link>
</a>
</div>
</div>
</div>
Expand Down
File renamed without changes.
9 changes: 4 additions & 5 deletions dev/app/(frontend)/sent-emails/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use client'

import Link from 'next/link'
import { useCallback, useEffect, useState } from 'react'

interface CapturedEmail {
Expand Down Expand Up @@ -55,9 +54,9 @@ export default function SentEmailsPage() {
<div style={{ backgroundColor: '#f9fafb', minHeight: '100vh', padding: '40px 20px' }}>
<div style={{ margin: '0 auto', maxWidth: '1200px' }}>
<div style={{ alignItems: 'center', display: 'flex', gap: '16px', marginBottom: '8px' }}>
<Link href="/dashboard" style={{ color: '#3b82f6', fontSize: '0.9rem', textDecoration: 'none' }}>
<a href="/dashboard" style={{ color: '#3b82f6', fontSize: '0.9rem', textDecoration: 'none' }}>
← Dashboard
</Link>
</a>
</div>
<div
style={{
Expand Down Expand Up @@ -121,9 +120,9 @@ export default function SentEmailsPage() {
}}
>
No emails sent yet. Create a user or use the{' '}
<Link href="/mailing-test" style={{ color: '#3b82f6' }}>
<a href="/mailing-test" style={{ color: '#3b82f6' }}>
Test interface
</Link>{' '}
</a>{' '}
to send one.
</div>
) : (
Expand Down
7 changes: 5 additions & 2 deletions dev/app/api/test-email/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ export async function POST(request: Request) {
export async function GET() {
try {
const payload = await getPayload({ config })
// The plugin attaches its context to the Payload instance at init; it is
// not part of Payload's own type.
const mailing = (payload as { mailing?: { service?: unknown } }).mailing

// Get email templates
const { docs: templates } = await payload.find({
Expand All @@ -118,8 +121,8 @@ export async function GET() {
total: totalDocs,
},
mailing: {
pluginActive: 'mailing' in payload && !!payload.mailing,
service: 'mailing' in payload && payload.mailing && 'service' in payload.mailing && !!payload.mailing.service,
pluginActive: !!mailing,
service: !!mailing?.service,
},
})
} catch (error) {
Expand Down
3 changes: 2 additions & 1 deletion dev/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
/// <reference path="./.next/types/routes.d.ts" />
import "./.next/types/routes.d.ts";
import "./.next/types/root-params.d.ts";

// NOTE: This file should not be edited
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
57 changes: 45 additions & 12 deletions dev/payload-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export interface Config {
media: Media;
'email-templates': EmailTemplate;
emails: Email;
'payload-kv': PayloadKv;
'payload-jobs': PayloadJob;
'payload-locked-documents': PayloadLockedDocument;
'payload-preferences': PayloadPreference;
Expand All @@ -84,6 +85,7 @@ export interface Config {
media: MediaSelect<false> | MediaSelect<true>;
'email-templates': EmailTemplatesSelect<false> | EmailTemplatesSelect<true>;
emails: EmailsSelect<false> | EmailsSelect<true>;
'payload-kv': PayloadKvSelect<false> | PayloadKvSelect<true>;
'payload-jobs': PayloadJobsSelect<false> | PayloadJobsSelect<true>;
'payload-locked-documents': PayloadLockedDocumentsSelect<false> | PayloadLockedDocumentsSelect<true>;
'payload-preferences': PayloadPreferencesSelect<false> | PayloadPreferencesSelect<true>;
Expand All @@ -92,12 +94,14 @@ export interface Config {
db: {
defaultIDType: number;
};
fallbackLocale: null;
globals: {};
globalsSelect: {};
locale: null;
user: User & {
collection: 'users';
widgets: {
collections: CollectionsWidget;
};
user: User;
jobs: {
tasks: {
'process-email': TaskProcessEmail;
Expand Down Expand Up @@ -142,6 +146,7 @@ export interface User {
resetPasswordExpiration?: string | null;
salt?: string | null;
hash?: string | null;
resetPasswordRequestedAt?: string | null;
loginAttempts?: number | null;
lockUntil?: string | null;
sessions?:
Expand All @@ -152,6 +157,7 @@ export interface User {
}[]
| null;
password?: string | null;
collection: 'users';
}
/**
* This interface was referenced by `Config`'s JSON-Schema
Expand Down Expand Up @@ -205,7 +211,7 @@ export interface EmailTemplate {
root: {
type: string;
children: {
type: string;
type: any;
version: number;
[k: string]: unknown;
}[];
Expand Down Expand Up @@ -446,6 +452,23 @@ export interface PayloadJob {
updatedAt: string;
createdAt: string;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "payload-kv".
*/
export interface PayloadKv {
id: number;
key: string;
data:
| {
[k: string]: unknown;
}
| unknown[]
| string
| number
| boolean
| null;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "payload-locked-documents".
Expand All @@ -472,10 +495,6 @@ export interface PayloadLockedDocument {
| ({
relationTo: 'emails';
value: number | Email;
} | null)
| ({
relationTo: 'payload-jobs';
value: number | PayloadJob;
} | null);
globalSlug?: string | null;
user: {
Expand Down Expand Up @@ -533,6 +552,7 @@ export interface UsersSelect<T extends boolean = true> {
resetPasswordExpiration?: T;
salt?: T;
hash?: T;
resetPasswordRequestedAt?: T;
loginAttempts?: T;
lockUntil?: T;
sessions?:
Expand Down Expand Up @@ -618,6 +638,14 @@ export interface EmailsSelect<T extends boolean = true> {
updatedAt?: T;
createdAt?: T;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "payload-kv_select".
*/
export interface PayloadKvSelect<T extends boolean = true> {
key?: T;
data?: T;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "payload-jobs_select".
Expand Down Expand Up @@ -681,6 +709,16 @@ export interface PayloadMigrationsSelect<T extends boolean = true> {
updatedAt?: T;
createdAt?: T;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "collections_widget".
*/
export interface CollectionsWidget {
data?: {
[k: string]: unknown;
};
width: 'full';
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "TaskProcess-email".
Expand All @@ -705,8 +743,3 @@ export interface TaskProcessEmail {
export interface Auth {
[k: string]: unknown;
}


declare module 'payload' {
export interface GeneratedTypes extends Config {}
}
9 changes: 9 additions & 0 deletions dev/payload.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,15 @@ Unsubscribe: https://example.com/unsubscribe`,
secret: process.env.PAYLOAD_SECRET || 'test-secret_key',
sharp,
typescript: {
// Types are regenerated on demand with `pnpm dev:generate-types`, never as
// a side effect of starting the dev server or the tests.
autoGenerate: false,
// Leave out the `declare module 'payload'` block. It would narrow
// Payload's types to this app's collections for every file in the
// program, including the plugin's own source (dev/tsconfig.json includes
// ../src), which has to compile for any host app and so takes collection
// slugs as plain strings. With the block, `next build` fails type-checking.
declare: false,
outputFile: path.resolve(dirname, 'payload-types.ts'),
},
})
2 changes: 2 additions & 0 deletions dev/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
"../src/exports/rsc.ts"
]
},
"composite": false,
"declaration": false,
"noEmit": true,
"emitDeclarationOnly": false,
"plugins": [
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"clean": "rimraf {dist,*.tsbuildinfo}",
"copyfiles": "copyfiles -u 1 \"src/**/*.{html,css,scss,ttf,woff,woff2,eot,svg,jpg,png,json}\" dist/",
"dev": "next dev dev --turbo",
"dev:build": "next build dev",
"dev:generate-importmap": "npm run dev:payload generate:importmap",
"dev:generate-types": "npm run dev:payload generate:types",
"dev:payload": "cross-env PAYLOAD_CONFIG_PATH=./dev/payload.config.ts payload",
Expand Down Expand Up @@ -71,7 +72,6 @@
},
"devDependencies": {
"@eslint/eslintrc": "^3.3.7",
"@payloadcms/db-mongodb": "3.94.2",
"@payloadcms/db-postgres": "3.94.2",
"@payloadcms/db-sqlite": "3.94.2",
"@payloadcms/eslint-config": "^3.28.0",
Expand Down
Loading
Loading