payload-plugin-newsletter 0.1.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/CHANGELOG.md +35 -0
- package/CLAUDE.md +110 -0
- package/FEEDBACK.md +148 -0
- package/LICENSE +21 -0
- package/README-DEVELOPMENT.md +80 -0
- package/README.md +430 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/collections/Subscribers.d.ts +4 -0
- package/dist/collections/Subscribers.d.ts.map +1 -0
- package/dist/components/MagicLinkVerify.d.ts +27 -0
- package/dist/components/MagicLinkVerify.d.ts.map +1 -0
- package/dist/components/NewsletterForm.d.ts +5 -0
- package/dist/components/NewsletterForm.d.ts.map +1 -0
- package/dist/components/PreferencesForm.d.ts +5 -0
- package/dist/components/PreferencesForm.d.ts.map +1 -0
- package/dist/components/index.d.ts +5 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/endpoints/index.d.ts +4 -0
- package/dist/endpoints/index.d.ts.map +1 -0
- package/dist/endpoints/preferences.d.ts +5 -0
- package/dist/endpoints/preferences.d.ts.map +1 -0
- package/dist/endpoints/subscribe.d.ts +4 -0
- package/dist/endpoints/subscribe.d.ts.map +1 -0
- package/dist/endpoints/unsubscribe.d.ts +4 -0
- package/dist/endpoints/unsubscribe.d.ts.map +1 -0
- package/dist/endpoints/verify-magic-link.d.ts +4 -0
- package/dist/endpoints/verify-magic-link.d.ts.map +1 -0
- package/dist/exports/client.d.ts +6 -0
- package/dist/exports/client.d.ts.map +1 -0
- package/dist/exports/components.d.ts +2 -0
- package/dist/exports/components.d.ts.map +1 -0
- package/dist/exports/types.d.ts +2 -0
- package/dist/exports/types.d.ts.map +1 -0
- package/dist/fields/newsletterScheduling.d.ts +4 -0
- package/dist/fields/newsletterScheduling.d.ts.map +1 -0
- package/dist/globals/EmailSettings.d.ts +4 -0
- package/dist/globals/EmailSettings.d.ts.map +1 -0
- package/dist/hooks/useNewsletterAuth.d.ts +16 -0
- package/dist/hooks/useNewsletterAuth.d.ts.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/providers/broadcast.d.ts +19 -0
- package/dist/providers/broadcast.d.ts.map +1 -0
- package/dist/providers/index.d.ts +23 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/resend.d.ts +20 -0
- package/dist/providers/resend.d.ts.map +1 -0
- package/dist/providers/types.d.ts +46 -0
- package/dist/providers/types.d.ts.map +1 -0
- package/dist/src/collections/Subscribers.js +344 -0
- package/dist/src/collections/Subscribers.js.map +1 -0
- package/dist/src/components/MagicLinkVerify.js +180 -0
- package/dist/src/components/MagicLinkVerify.js.map +1 -0
- package/dist/src/components/NewsletterForm.js +326 -0
- package/dist/src/components/NewsletterForm.js.map +1 -0
- package/dist/src/components/PreferencesForm.js +524 -0
- package/dist/src/components/PreferencesForm.js.map +1 -0
- package/dist/src/components/index.js +5 -0
- package/dist/src/components/index.js.map +1 -0
- package/dist/src/endpoints/index.js +17 -0
- package/dist/src/endpoints/index.js.map +1 -0
- package/dist/src/endpoints/preferences.js +124 -0
- package/dist/src/endpoints/preferences.js.map +1 -0
- package/dist/src/endpoints/subscribe.js +140 -0
- package/dist/src/endpoints/subscribe.js.map +1 -0
- package/dist/src/endpoints/unsubscribe.js +97 -0
- package/dist/src/endpoints/unsubscribe.js.map +1 -0
- package/dist/src/endpoints/verify-magic-link.js +93 -0
- package/dist/src/endpoints/verify-magic-link.js.map +1 -0
- package/dist/src/exports/client.js +7 -0
- package/dist/src/exports/client.js.map +1 -0
- package/dist/src/exports/components.js +6 -0
- package/dist/src/exports/components.js.map +1 -0
- package/dist/src/exports/types.js +3 -0
- package/dist/src/exports/types.js.map +1 -0
- package/dist/src/fields/newsletterScheduling.js +195 -0
- package/dist/src/fields/newsletterScheduling.js.map +1 -0
- package/dist/src/globals/EmailSettings.js +252 -0
- package/dist/src/globals/EmailSettings.js.map +1 -0
- package/dist/src/hooks/useNewsletterAuth.js +112 -0
- package/dist/src/hooks/useNewsletterAuth.js.map +1 -0
- package/dist/src/index.js +124 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/providers/broadcast.js +158 -0
- package/dist/src/providers/broadcast.js.map +1 -0
- package/dist/src/providers/index.js +63 -0
- package/dist/src/providers/index.js.map +1 -0
- package/dist/src/providers/resend.js +122 -0
- package/dist/src/providers/resend.js.map +1 -0
- package/dist/src/providers/types.js +12 -0
- package/dist/src/providers/types.js.map +1 -0
- package/dist/src/templates/BaseTemplate.js +105 -0
- package/dist/src/templates/BaseTemplate.js.map +1 -0
- package/dist/src/templates/MagicLinkTemplate.js +178 -0
- package/dist/src/templates/MagicLinkTemplate.js.map +1 -0
- package/dist/src/templates/NewsletterTemplate.js +150 -0
- package/dist/src/templates/NewsletterTemplate.js.map +1 -0
- package/dist/src/templates/WelcomeTemplate.js +192 -0
- package/dist/src/templates/WelcomeTemplate.js.map +1 -0
- package/dist/src/templates/index.js +6 -0
- package/dist/src/templates/index.js.map +1 -0
- package/dist/src/types/index.js +3 -0
- package/dist/src/types/index.js.map +1 -0
- package/dist/src/utils/jwt.js +91 -0
- package/dist/src/utils/jwt.js.map +1 -0
- package/dist/src/utils/validation.js +66 -0
- package/dist/src/utils/validation.js.map +1 -0
- package/dist/templates/BaseTemplate.d.ts +45 -0
- package/dist/templates/BaseTemplate.d.ts.map +1 -0
- package/dist/templates/MagicLinkTemplate.d.ts +67 -0
- package/dist/templates/MagicLinkTemplate.d.ts.map +1 -0
- package/dist/templates/NewsletterTemplate.d.ts +112 -0
- package/dist/templates/NewsletterTemplate.d.ts.map +1 -0
- package/dist/templates/WelcomeTemplate.d.ts +55 -0
- package/dist/templates/WelcomeTemplate.d.ts.map +1 -0
- package/dist/templates/index.d.ts +7 -0
- package/dist/templates/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +332 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/utils/jwt.d.ts +32 -0
- package/dist/utils/jwt.d.ts.map +1 -0
- package/dist/utils/validation.d.ts +25 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/package.json +128 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [0.1.0] - 2025-06-15
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- Initial release of Payload Newsletter Plugin
|
|
12
|
+
- Subscribers collection with comprehensive field schema
|
|
13
|
+
- Email settings global for admin UI configuration
|
|
14
|
+
- Magic link authentication system (separate from Payload auth)
|
|
15
|
+
- Email service providers: Resend and Broadcast
|
|
16
|
+
- Newsletter scheduling for any collection
|
|
17
|
+
- Automatic markdown generation from rich text fields
|
|
18
|
+
- Customizable email templates using React Email
|
|
19
|
+
- React components: NewsletterForm, PreferencesForm, MagicLinkVerify
|
|
20
|
+
- useNewsletterAuth hook for client-side state management
|
|
21
|
+
- API endpoints for subscription, authentication, and preferences
|
|
22
|
+
- Full TypeScript support with comprehensive types
|
|
23
|
+
- Internationalization support
|
|
24
|
+
- UTM tracking and analytics data collection
|
|
25
|
+
- Lead magnet support
|
|
26
|
+
- Rate limiting and security features
|
|
27
|
+
|
|
28
|
+
### Security
|
|
29
|
+
- JWT-based authentication for magic links
|
|
30
|
+
- Session token management
|
|
31
|
+
- Rate limiting by IP address
|
|
32
|
+
- Domain restriction options
|
|
33
|
+
- Input validation and sanitization
|
|
34
|
+
|
|
35
|
+
[0.1.0]: https://github.com/aniketpanjwani/payload-plugin-email-newsletter/releases/tag/v0.1.0
|
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# Claude Development Guidelines
|
|
2
|
+
|
|
3
|
+
This file contains development guidelines and reference information for Claude when working on the Payload Newsletter Plugin.
|
|
4
|
+
|
|
5
|
+
## Important Security Guidelines
|
|
6
|
+
|
|
7
|
+
**NEVER include any of the following in the repository:**
|
|
8
|
+
- API keys or tokens (use environment variables)
|
|
9
|
+
- Email addresses or personal information
|
|
10
|
+
- Specific company/project names (keep everything generic)
|
|
11
|
+
- Production URLs or endpoints
|
|
12
|
+
- Any credentials or sensitive configuration
|
|
13
|
+
|
|
14
|
+
## Reference Repositories
|
|
15
|
+
|
|
16
|
+
These local repositories contain reference implementations and examples:
|
|
17
|
+
|
|
18
|
+
1. **Medellin Newsletter Implementation** (source for newsletter logic):
|
|
19
|
+
- Location: `/Users/aniketpanjwani/Projects/medellin_newsletter/medellin_insider`
|
|
20
|
+
- Use for: Understanding newsletter implementation patterns
|
|
21
|
+
- DO NOT: Copy any specific business logic, API keys, or Medellin-specific references
|
|
22
|
+
|
|
23
|
+
2. **Payload CMS Source**:
|
|
24
|
+
- Location: `/Users/aniketpanjwani/Projects/reference_repos/payload`
|
|
25
|
+
- Docs: `/Users/aniketpanjwani/Projects/reference_repos/payload/docs`
|
|
26
|
+
- Templates: `/Users/aniketpanjwani/Projects/reference_repos/payload/templates`
|
|
27
|
+
- Use for: Understanding Payload patterns and best practices
|
|
28
|
+
|
|
29
|
+
3. **Official Payload Plugins** (examples to follow):
|
|
30
|
+
- SEO Plugin: `/Users/aniketpanjwani/Projects/reference_repos/payload/packages/plugin-seo`
|
|
31
|
+
- Form Builder: `/Users/aniketpanjwani/Projects/reference_repos/payload/packages/plugin-form-builder`
|
|
32
|
+
- Use for: Plugin architecture patterns and conventions
|
|
33
|
+
|
|
34
|
+
## Development Setup
|
|
35
|
+
|
|
36
|
+
This project uses **Bun** as the preferred package manager and runtime.
|
|
37
|
+
|
|
38
|
+
### Available Commands
|
|
39
|
+
- `bun install` - Install dependencies
|
|
40
|
+
- `bun typecheck` - Run TypeScript type checking
|
|
41
|
+
- `bun generate:types` - Generate TypeScript declarations
|
|
42
|
+
- `bun build` - Build the project (JS + types)
|
|
43
|
+
- `bun dev` - Watch mode for development
|
|
44
|
+
- `bun lint` - Run ESLint
|
|
45
|
+
- `bun clean` - Clean build artifacts
|
|
46
|
+
|
|
47
|
+
## Development Guidelines
|
|
48
|
+
|
|
49
|
+
### Code Style
|
|
50
|
+
- Follow Payload's patterns from official plugins
|
|
51
|
+
- Use TypeScript for everything
|
|
52
|
+
- No comments unless specifically requested
|
|
53
|
+
- Keep implementations generic and reusable
|
|
54
|
+
|
|
55
|
+
### Plugin Design Principles
|
|
56
|
+
1. **Generic by Default**: Everything should work for any Payload project
|
|
57
|
+
2. **Configuration Over Code**: Use config options rather than hardcoded values
|
|
58
|
+
3. **Follow Payload Patterns**: Match the style of official plugins
|
|
59
|
+
4. **User-Friendly**: Clear documentation and intuitive defaults
|
|
60
|
+
|
|
61
|
+
### Testing Approach
|
|
62
|
+
- Test with generic data only
|
|
63
|
+
- Use example.com for email addresses
|
|
64
|
+
- Use placeholder text for content
|
|
65
|
+
- Never use real API keys in tests
|
|
66
|
+
|
|
67
|
+
### Documentation
|
|
68
|
+
- Keep README focused on user needs
|
|
69
|
+
- Include clear examples
|
|
70
|
+
- Document all configuration options
|
|
71
|
+
- Link to FEEDBACK.md for design decisions
|
|
72
|
+
|
|
73
|
+
## Common Tasks
|
|
74
|
+
|
|
75
|
+
### When Adding New Features
|
|
76
|
+
1. Check reference implementations for patterns
|
|
77
|
+
2. Keep everything configurable
|
|
78
|
+
3. Add TypeScript types
|
|
79
|
+
4. Update documentation
|
|
80
|
+
5. Make progressive commits
|
|
81
|
+
|
|
82
|
+
### When Reviewing Reference Code
|
|
83
|
+
- Extract patterns, not implementations
|
|
84
|
+
- Generalize any specific logic
|
|
85
|
+
- Remove all identifying information
|
|
86
|
+
- Focus on the architecture
|
|
87
|
+
|
|
88
|
+
## Environment Variables
|
|
89
|
+
|
|
90
|
+
When documenting environment variables, always use generic examples:
|
|
91
|
+
```bash
|
|
92
|
+
RESEND_API_KEY=your_resend_api_key_here
|
|
93
|
+
BROADCAST_TOKEN=your_broadcast_token_here
|
|
94
|
+
JWT_SECRET=your_jwt_secret_here
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Git Workflow
|
|
98
|
+
|
|
99
|
+
1. Make small, focused commits
|
|
100
|
+
2. Use conventional commit messages (feat:, fix:, docs:, etc.)
|
|
101
|
+
3. Push regularly to: https://github.com/aniketpanjwani/payload-plugin-email-newsletter
|
|
102
|
+
4. Keep sensitive information in gitignored directories
|
|
103
|
+
|
|
104
|
+
## Questions to Always Consider
|
|
105
|
+
|
|
106
|
+
Before implementing any feature, ask:
|
|
107
|
+
1. Is this generic enough for any Payload project?
|
|
108
|
+
2. Are there any hardcoded values that should be configurable?
|
|
109
|
+
3. Does this follow Payload's established patterns?
|
|
110
|
+
4. Is this well-documented for users?
|
package/FEEDBACK.md
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# Feedback & Design Decisions
|
|
2
|
+
|
|
3
|
+
We'd love your feedback on the Payload Newsletter Plugin! This document outlines key design decisions we've made and areas where community input would be especially valuable.
|
|
4
|
+
|
|
5
|
+
## 🤔 Design Decisions We'd Like Feedback On
|
|
6
|
+
|
|
7
|
+
### 1. Magic Link Authentication Approach
|
|
8
|
+
|
|
9
|
+
**Current Design**: We've implemented a custom JWT-based magic link system that's completely separate from Payload's built-in authentication.
|
|
10
|
+
|
|
11
|
+
**Rationale**:
|
|
12
|
+
- Newsletter subscribers typically don't need full CMS access
|
|
13
|
+
- Passwordless is more user-friendly for newsletter management
|
|
14
|
+
- Keeps subscriber auth separate from admin auth
|
|
15
|
+
|
|
16
|
+
**Questions for the Community**:
|
|
17
|
+
- Would you prefer an option to integrate with Payload's auth system?
|
|
18
|
+
- Is the current token expiration (7 days) appropriate?
|
|
19
|
+
- Should we support other passwordless methods (OTP, social login)?
|
|
20
|
+
|
|
21
|
+
### 2. Email Provider Architecture
|
|
22
|
+
|
|
23
|
+
**Current Design**: We support Resend and Broadcast with a provider-agnostic interface.
|
|
24
|
+
|
|
25
|
+
**Questions for the Community**:
|
|
26
|
+
- Which other email providers should we prioritize? (SendGrid, Mailgun, AWS SES, Postmark?)
|
|
27
|
+
- Should we support multiple providers simultaneously (e.g., failover)?
|
|
28
|
+
- Is the current provider interface flexible enough for your needs?
|
|
29
|
+
|
|
30
|
+
### 3. Newsletter Scheduling Integration
|
|
31
|
+
|
|
32
|
+
**Current Design**: We inject fields into your existing articles collection rather than creating a separate newsletter collection.
|
|
33
|
+
|
|
34
|
+
**Rationale**:
|
|
35
|
+
- Leverages existing content
|
|
36
|
+
- Avoids duplication
|
|
37
|
+
- Simpler mental model
|
|
38
|
+
|
|
39
|
+
**Questions for the Community**:
|
|
40
|
+
- Would you prefer a dedicated newsletters collection?
|
|
41
|
+
- Should we support scheduling multiple article types (not just articles)?
|
|
42
|
+
- What additional scheduling features would be valuable?
|
|
43
|
+
|
|
44
|
+
### 4. Component Library Approach
|
|
45
|
+
|
|
46
|
+
**Current Design**: React-only components using Payload's UI library.
|
|
47
|
+
|
|
48
|
+
**Questions for the Community**:
|
|
49
|
+
- Would you like vanilla JS examples for non-React frontends?
|
|
50
|
+
- Should we provide more component variants (embedded, modal, etc.)?
|
|
51
|
+
- What styling/theming options would be most useful?
|
|
52
|
+
|
|
53
|
+
### 5. Data Collection & Analytics
|
|
54
|
+
|
|
55
|
+
**Current Design**: We collect UTM parameters and basic metadata but don't include analytics dashboards.
|
|
56
|
+
|
|
57
|
+
**Questions for the Community**:
|
|
58
|
+
- What analytics would be most valuable to track?
|
|
59
|
+
- Should we integrate with analytics platforms (GA, Plausible, etc.)?
|
|
60
|
+
- Would you want a built-in analytics dashboard?
|
|
61
|
+
|
|
62
|
+
### 6. Default Field Schema
|
|
63
|
+
|
|
64
|
+
**Current Design**: We include a comprehensive set of fields (name, locale, preferences, segments, etc.).
|
|
65
|
+
|
|
66
|
+
**Questions for the Community**:
|
|
67
|
+
- Are there fields we should add or remove by default?
|
|
68
|
+
- Should some fields be opt-in rather than default?
|
|
69
|
+
- How can we better support custom field requirements?
|
|
70
|
+
|
|
71
|
+
## 💡 Feature Requests
|
|
72
|
+
|
|
73
|
+
We're considering these features for future releases:
|
|
74
|
+
|
|
75
|
+
1. **Double opt-in workflow** - Email confirmation before activation
|
|
76
|
+
2. **A/B testing** - Test subject lines and content
|
|
77
|
+
3. **Automation workflows** - Welcome series, drip campaigns
|
|
78
|
+
4. **Segmentation UI** - Visual segment builder
|
|
79
|
+
5. **Template marketplace** - Share email templates
|
|
80
|
+
6. **Import/Export tools** - Migrate from other platforms
|
|
81
|
+
7. **Webhook support** - Notify external services of events
|
|
82
|
+
8. **Email preview** - See how emails look before sending
|
|
83
|
+
|
|
84
|
+
**What features would you prioritize?**
|
|
85
|
+
|
|
86
|
+
## 🐛 Known Limitations
|
|
87
|
+
|
|
88
|
+
Current limitations we're aware of:
|
|
89
|
+
|
|
90
|
+
1. No built-in unsubscribe page (API only)
|
|
91
|
+
2. No email bounce handling
|
|
92
|
+
3. No GDPR compliance features (by design, but reconsidering)
|
|
93
|
+
4. Limited email template customization
|
|
94
|
+
5. No support for attachments
|
|
95
|
+
|
|
96
|
+
**Which limitations affect you most?**
|
|
97
|
+
|
|
98
|
+
## 📝 How to Provide Feedback
|
|
99
|
+
|
|
100
|
+
We welcome all feedback! Here's how to contribute:
|
|
101
|
+
|
|
102
|
+
1. **GitHub Issues**: For bugs and feature requests
|
|
103
|
+
- [Create an issue](https://github.com/aniketpanjwani/payload-plugin-email-newsletter/issues)
|
|
104
|
+
|
|
105
|
+
2. **GitHub Discussions**: For design discussions and questions
|
|
106
|
+
- [Start a discussion](https://github.com/aniketpanjwani/payload-plugin-email-newsletter/discussions)
|
|
107
|
+
|
|
108
|
+
3. **Pull Requests**: For direct contributions
|
|
109
|
+
- Fork the repo and submit a PR
|
|
110
|
+
- Include tests for new features
|
|
111
|
+
- Update documentation as needed
|
|
112
|
+
|
|
113
|
+
4. **Discord**: For quick questions and community discussion
|
|
114
|
+
- Join the [Payload Discord](https://discord.gg/payload)
|
|
115
|
+
- Find us in #plugins channel
|
|
116
|
+
|
|
117
|
+
## 🚀 Roadmap Influence
|
|
118
|
+
|
|
119
|
+
Your feedback directly influences our roadmap. We review all feedback monthly and prioritize based on:
|
|
120
|
+
|
|
121
|
+
1. Community votes/reactions
|
|
122
|
+
2. Implementation complexity
|
|
123
|
+
3. Alignment with Payload patterns
|
|
124
|
+
4. Benefit to most users
|
|
125
|
+
|
|
126
|
+
## Example Use Cases
|
|
127
|
+
|
|
128
|
+
We'd love to hear about your use cases! Some we've considered:
|
|
129
|
+
|
|
130
|
+
- **SaaS applications**: Product updates and announcements
|
|
131
|
+
- **Content sites**: Weekly digests and new post notifications
|
|
132
|
+
- **E-commerce**: Order updates and promotional emails
|
|
133
|
+
- **Communities**: Event notifications and member updates
|
|
134
|
+
- **Educational**: Course updates and learning resources
|
|
135
|
+
|
|
136
|
+
**What's your use case?**
|
|
137
|
+
|
|
138
|
+
## Contributing Code
|
|
139
|
+
|
|
140
|
+
If you'd like to contribute:
|
|
141
|
+
|
|
142
|
+
1. Check existing issues/discussions first
|
|
143
|
+
2. Propose significant changes via discussion before implementing
|
|
144
|
+
3. Follow Payload's coding standards
|
|
145
|
+
4. Include tests and documentation
|
|
146
|
+
5. Keep PRs focused on a single feature/fix
|
|
147
|
+
|
|
148
|
+
Thank you for helping make this plugin better for everyone! 🙏
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Aniket Panjwani
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# Development Guide
|
|
2
|
+
|
|
3
|
+
## Quick Start
|
|
4
|
+
|
|
5
|
+
This project uses Bun as the preferred package manager and runtime.
|
|
6
|
+
|
|
7
|
+
### Install Dependencies
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
bun install
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### Type Checking
|
|
14
|
+
|
|
15
|
+
Run TypeScript type checking without emitting files:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
bun typecheck
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Generate Type Definitions
|
|
22
|
+
|
|
23
|
+
Generate TypeScript declaration files:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
bun generate:types
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Build
|
|
30
|
+
|
|
31
|
+
Build the project (both JavaScript and type definitions):
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
bun build
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Development Mode
|
|
38
|
+
|
|
39
|
+
Watch for changes and rebuild:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
bun dev
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Linting
|
|
46
|
+
|
|
47
|
+
Run ESLint on the source code:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
bun lint
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Clean Build Artifacts
|
|
54
|
+
|
|
55
|
+
Remove the dist directory:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
bun clean
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Common TypeScript Issues
|
|
62
|
+
|
|
63
|
+
If you encounter TypeScript errors during build:
|
|
64
|
+
|
|
65
|
+
1. **Module Resolution**: The project uses ESM modules. Import statements should include file extensions for relative imports.
|
|
66
|
+
2. **Type Errors**: Run `bun typecheck` to see all TypeScript errors without building.
|
|
67
|
+
3. **Missing Types**: Some Payload types might need explicit imports or type assertions.
|
|
68
|
+
|
|
69
|
+
## Publishing
|
|
70
|
+
|
|
71
|
+
Before publishing to npm:
|
|
72
|
+
|
|
73
|
+
1. Ensure all tests pass (when tests are added)
|
|
74
|
+
2. Run `bun typecheck` to ensure no TypeScript errors
|
|
75
|
+
3. Update version in package.json
|
|
76
|
+
4. Update CHANGELOG.md
|
|
77
|
+
5. Run `bun build` to ensure it builds successfully
|
|
78
|
+
6. Tag the release: `git tag v0.x.x`
|
|
79
|
+
7. Push tags: `git push --tags`
|
|
80
|
+
8. Publish: `npm publish`
|