@codaijs/keel 0.2.3 → 0.2.4

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.
Files changed (80) hide show
  1. package/dist/__tests__/sail-installer.test.js +25 -25
  2. package/dist/sail-installer.js +174 -174
  3. package/dist/scaffold.js +68 -68
  4. package/package.json +58 -58
  5. package/sails/_template/addon.json +20 -20
  6. package/sails/_template/install.ts +402 -402
  7. package/sails/admin-dashboard/README.md +117 -117
  8. package/sails/admin-dashboard/addon.json +28 -28
  9. package/sails/admin-dashboard/files/backend/middleware/admin.ts +34 -34
  10. package/sails/admin-dashboard/files/backend/routes/admin.ts +243 -243
  11. package/sails/admin-dashboard/files/frontend/components/admin/StatsCard.tsx +40 -40
  12. package/sails/admin-dashboard/files/frontend/components/admin/UsersTable.tsx +240 -240
  13. package/sails/admin-dashboard/files/frontend/hooks/useAdmin.ts +149 -149
  14. package/sails/admin-dashboard/files/frontend/pages/admin/Dashboard.tsx +173 -173
  15. package/sails/admin-dashboard/files/frontend/pages/admin/UserDetail.tsx +203 -203
  16. package/sails/admin-dashboard/install.ts +305 -305
  17. package/sails/analytics/README.md +178 -178
  18. package/sails/analytics/addon.json +27 -27
  19. package/sails/analytics/files/frontend/components/AnalyticsProvider.tsx +58 -58
  20. package/sails/analytics/files/frontend/hooks/useAnalytics.ts +64 -64
  21. package/sails/analytics/files/frontend/lib/analytics.ts +103 -103
  22. package/sails/analytics/install.ts +297 -297
  23. package/sails/file-uploads/addon.json +30 -30
  24. package/sails/file-uploads/files/backend/routes/files.ts +198 -198
  25. package/sails/file-uploads/files/backend/schema/files.ts +36 -36
  26. package/sails/file-uploads/files/backend/services/file-storage.ts +128 -128
  27. package/sails/file-uploads/files/frontend/components/FileList.tsx +248 -248
  28. package/sails/file-uploads/files/frontend/components/FileUploadButton.tsx +147 -147
  29. package/sails/file-uploads/files/frontend/hooks/useFileUpload.ts +106 -106
  30. package/sails/file-uploads/files/frontend/hooks/useFiles.ts +118 -118
  31. package/sails/file-uploads/files/frontend/pages/Files.tsx +37 -37
  32. package/sails/file-uploads/install.ts +466 -466
  33. package/sails/gdpr/README.md +174 -174
  34. package/sails/gdpr/addon.json +27 -27
  35. package/sails/gdpr/files/backend/routes/gdpr.ts +140 -140
  36. package/sails/gdpr/files/backend/services/gdpr.ts +293 -293
  37. package/sails/gdpr/files/frontend/components/auth/ConsentCheckboxes.tsx +97 -97
  38. package/sails/gdpr/files/frontend/components/gdpr/AccountDeletionRequest.tsx +192 -192
  39. package/sails/gdpr/files/frontend/components/gdpr/DataExportButton.tsx +75 -75
  40. package/sails/gdpr/files/frontend/pages/PrivacyPolicy.tsx +186 -186
  41. package/sails/gdpr/install.ts +756 -756
  42. package/sails/google-oauth/README.md +121 -121
  43. package/sails/google-oauth/addon.json +22 -22
  44. package/sails/google-oauth/files/GoogleButton.tsx +50 -50
  45. package/sails/google-oauth/install.ts +252 -252
  46. package/sails/i18n/README.md +193 -193
  47. package/sails/i18n/addon.json +30 -30
  48. package/sails/i18n/files/frontend/components/LanguageSwitcher.tsx +108 -108
  49. package/sails/i18n/files/frontend/hooks/useLanguage.ts +31 -31
  50. package/sails/i18n/files/frontend/lib/i18n.ts +32 -32
  51. package/sails/i18n/files/frontend/locales/de/common.json +44 -44
  52. package/sails/i18n/files/frontend/locales/en/common.json +44 -44
  53. package/sails/i18n/install.ts +407 -407
  54. package/sails/push-notifications/README.md +163 -163
  55. package/sails/push-notifications/addon.json +31 -31
  56. package/sails/push-notifications/files/backend/routes/notifications.ts +153 -153
  57. package/sails/push-notifications/files/backend/schema/notifications.ts +31 -31
  58. package/sails/push-notifications/files/backend/services/notifications.ts +117 -117
  59. package/sails/push-notifications/files/frontend/components/PushNotificationInit.tsx +12 -12
  60. package/sails/push-notifications/files/frontend/hooks/usePushNotifications.ts +154 -154
  61. package/sails/push-notifications/install.ts +384 -384
  62. package/sails/r2-storage/addon.json +29 -29
  63. package/sails/r2-storage/files/backend/services/storage.ts +71 -71
  64. package/sails/r2-storage/files/frontend/components/ProfilePictureUpload.tsx +167 -167
  65. package/sails/r2-storage/install.ts +412 -412
  66. package/sails/rate-limiting/addon.json +20 -20
  67. package/sails/rate-limiting/files/backend/middleware/rate-limit-store.ts +104 -104
  68. package/sails/rate-limiting/files/backend/middleware/rate-limit.ts +137 -137
  69. package/sails/rate-limiting/install.ts +300 -300
  70. package/sails/registry.json +107 -107
  71. package/sails/stripe/README.md +214 -214
  72. package/sails/stripe/addon.json +24 -24
  73. package/sails/stripe/files/backend/routes/stripe.ts +154 -154
  74. package/sails/stripe/files/backend/schema/stripe.ts +74 -74
  75. package/sails/stripe/files/backend/services/stripe.ts +224 -224
  76. package/sails/stripe/files/frontend/components/SubscriptionStatus.tsx +135 -135
  77. package/sails/stripe/files/frontend/hooks/useSubscription.ts +86 -86
  78. package/sails/stripe/files/frontend/pages/Checkout.tsx +116 -116
  79. package/sails/stripe/files/frontend/pages/Pricing.tsx +226 -226
  80. package/sails/stripe/install.ts +378 -378
@@ -1,174 +1,174 @@
1
- # GDPR/DSGVO Compliance Sail
2
-
3
- Adds full GDPR (General Data Protection Regulation) compliance to your keel application, including consent tracking, data export, account deletion, and a privacy policy page.
4
-
5
- ## Features
6
-
7
- - Consent tracking for privacy policy, terms of service, marketing, and analytics
8
- - Consent checkboxes on the signup form
9
- - Consent management toggles in account settings
10
- - Data export (download all personal data as JSON)
11
- - Account deletion with 30-day grace period
12
- - Immediate account deletion with password confirmation
13
- - Cron endpoint for processing scheduled deletions
14
- - Privacy policy page
15
- - GDPR-compliant email notifications
16
-
17
- ## Prerequisites
18
-
19
- - A running keel project with authentication configured
20
- - A cron service for processing scheduled deletions (e.g., cron-job.org, Vercel Cron, Railway Cron)
21
-
22
- ## Installation
23
-
24
- ```bash
25
- npx tsx sails/gdpr/install.ts
26
- ```
27
-
28
- The installer will guide you through the setup, including generating a secret for the deletion cron endpoint.
29
-
30
- ## Environment Variables
31
-
32
- ```env
33
- DELETION_CRON_SECRET=your-secure-cron-secret
34
- ```
35
-
36
- ## Architecture
37
-
38
- ### Database Schema
39
-
40
- **consent_records**
41
- | Column | Type | Description |
42
- |--------|------|-------------|
43
- | id | uuid | Primary key |
44
- | user_id | text | FK to users table |
45
- | consent_type | varchar(50) | Type of consent (privacy_policy, tos, marketing, analytics) |
46
- | granted | boolean | Whether consent was granted |
47
- | version | varchar(20) | Version of the policy |
48
- | ip_address | text | IP address at time of consent |
49
- | user_agent | text | User agent at time of consent |
50
- | granted_at | timestamp | When consent was granted |
51
- | revoked_at | timestamp | When consent was revoked (null if active) |
52
-
53
- **deletion_requests**
54
- | Column | Type | Description |
55
- |--------|------|-------------|
56
- | id | uuid | Primary key |
57
- | user_id | text | FK to users table |
58
- | status | varchar(20) | pending, cancelled, completed |
59
- | reason | text | User-provided reason for deletion |
60
- | requested_at | timestamp | When deletion was requested |
61
- | scheduled_deletion_at | timestamp | When deletion will be executed (30 days) |
62
- | cancelled_at | timestamp | When deletion was cancelled |
63
- | completed_at | timestamp | When deletion was completed |
64
-
65
- ### API Routes
66
-
67
- | Method | Path | Auth | Description |
68
- |--------|------|------|-------------|
69
- | GET | /api/gdpr/export | Yes | Export all user data as JSON |
70
- | POST | /api/gdpr/deletion | Yes | Request account deletion (30-day grace) |
71
- | POST | /api/gdpr/deletion/cancel | Yes | Cancel pending deletion request |
72
- | DELETE | /api/gdpr/account | Yes | Immediately delete account (requires password) |
73
- | GET | /api/gdpr/consents | Yes | Get active user consents |
74
- | POST | /api/gdpr/consents | Yes | Record a new consent |
75
- | DELETE | /api/gdpr/consents/:consentType | Yes | Revoke a specific consent |
76
- | POST | /api/gdpr/process-deletions | Cron | Process expired deletion requests |
77
-
78
- ### Deletion Flow
79
-
80
- 1. User requests account deletion from Settings
81
- 2. A deletion request is created with a 30-day grace period
82
- 3. User receives an email with a link to cancel
83
- 4. User can cancel the deletion from Settings at any time
84
- 5. A daily cron job processes expired deletion requests
85
- 6. When processed, the user's data is permanently deleted (cascading)
86
- 7. A final confirmation email is sent
87
-
88
- ### Immediate Deletion
89
-
90
- Users can also request immediate deletion (bypassing the 30-day grace period) by confirming their password. This is useful for users who want their data removed right away.
91
-
92
- ### Email Templates
93
-
94
- The GDPR sail uses these email functions from the email package:
95
-
96
- - `sendDeletionRequestedEmail` - Sent when a user requests deletion
97
- - `sendDeletionCompletedEmail` - Sent after data is permanently deleted
98
- - `sendDeletionCancelledEmail` - Sent when a user cancels a deletion request
99
- - `sendDataExportReadyEmail` - Sent when a data export is ready for download
100
- - `sendConsentUpdatedEmail` - Sent when consent preferences are changed
101
-
102
- ## Frontend Components
103
-
104
- ### ConsentCheckboxes
105
-
106
- Added to the signup form. Requires acceptance of Privacy Policy and Terms of Service before registration. Marketing and analytics consent are optional.
107
-
108
- ### DataExportButton
109
-
110
- A button in Account Settings that triggers a JSON download of all user data.
111
-
112
- ### AccountDeletionRequest
113
-
114
- A section in Account Settings that shows the current deletion status and allows requesting or cancelling deletion.
115
-
116
- ### PrivacyPolicy Page
117
-
118
- A public page at `/privacy-policy` with GDPR-compliant privacy policy content. Customize this for your specific use case.
119
-
120
- ## Cron Job Setup
121
-
122
- Set up a daily cron job to process scheduled deletions:
123
-
124
- ```bash
125
- # Using curl
126
- curl -X POST https://your-backend.com/api/gdpr/process-deletions \
127
- -H "x-cron-secret: your-deletion-cron-secret"
128
- ```
129
-
130
- ### Example: cron-job.org
131
-
132
- 1. Create a new cron job
133
- 2. URL: `https://your-backend.com/api/gdpr/process-deletions`
134
- 3. Method: POST
135
- 4. Header: `x-cron-secret: your-deletion-cron-secret`
136
- 5. Schedule: Daily at 2:00 AM
137
-
138
- ### Example: Vercel Cron
139
-
140
- Add to `vercel.json`:
141
- ```json
142
- {
143
- "crons": [{
144
- "path": "/api/gdpr/process-deletions",
145
- "schedule": "0 2 * * *"
146
- }]
147
- }
148
- ```
149
-
150
- ## Customization
151
-
152
- ### Privacy Policy
153
-
154
- Edit `packages/frontend/src/pages/PrivacyPolicy.tsx` to match your company's privacy policy. Update:
155
-
156
- - Company name and contact information
157
- - Data Protection Officer details
158
- - Specific data processing purposes
159
- - Third-party services used
160
- - Data retention periods
161
-
162
- ### Consent Types
163
-
164
- The default consent types are:
165
- - `privacyPolicy` (required)
166
- - `termsOfService` (required)
167
- - `marketingEmails` (optional)
168
- - `analytics` (optional)
169
-
170
- To add custom consent types, modify `ConsentCheckboxes.tsx` and the consent recording logic.
171
-
172
- ### Grace Period
173
-
174
- The default deletion grace period is 30 days. To change this, modify the `requestDeletion` function in `packages/backend/src/services/gdpr.ts`.
1
+ # GDPR/DSGVO Compliance Sail
2
+
3
+ Adds full GDPR (General Data Protection Regulation) compliance to your keel application, including consent tracking, data export, account deletion, and a privacy policy page.
4
+
5
+ ## Features
6
+
7
+ - Consent tracking for privacy policy, terms of service, marketing, and analytics
8
+ - Consent checkboxes on the signup form
9
+ - Consent management toggles in account settings
10
+ - Data export (download all personal data as JSON)
11
+ - Account deletion with 30-day grace period
12
+ - Immediate account deletion with password confirmation
13
+ - Cron endpoint for processing scheduled deletions
14
+ - Privacy policy page
15
+ - GDPR-compliant email notifications
16
+
17
+ ## Prerequisites
18
+
19
+ - A running keel project with authentication configured
20
+ - A cron service for processing scheduled deletions (e.g., cron-job.org, Vercel Cron, Railway Cron)
21
+
22
+ ## Installation
23
+
24
+ ```bash
25
+ npx tsx sails/gdpr/install.ts
26
+ ```
27
+
28
+ The installer will guide you through the setup, including generating a secret for the deletion cron endpoint.
29
+
30
+ ## Environment Variables
31
+
32
+ ```env
33
+ DELETION_CRON_SECRET=your-secure-cron-secret
34
+ ```
35
+
36
+ ## Architecture
37
+
38
+ ### Database Schema
39
+
40
+ **consent_records**
41
+ | Column | Type | Description |
42
+ |--------|------|-------------|
43
+ | id | uuid | Primary key |
44
+ | user_id | text | FK to users table |
45
+ | consent_type | varchar(50) | Type of consent (privacy_policy, tos, marketing, analytics) |
46
+ | granted | boolean | Whether consent was granted |
47
+ | version | varchar(20) | Version of the policy |
48
+ | ip_address | text | IP address at time of consent |
49
+ | user_agent | text | User agent at time of consent |
50
+ | granted_at | timestamp | When consent was granted |
51
+ | revoked_at | timestamp | When consent was revoked (null if active) |
52
+
53
+ **deletion_requests**
54
+ | Column | Type | Description |
55
+ |--------|------|-------------|
56
+ | id | uuid | Primary key |
57
+ | user_id | text | FK to users table |
58
+ | status | varchar(20) | pending, cancelled, completed |
59
+ | reason | text | User-provided reason for deletion |
60
+ | requested_at | timestamp | When deletion was requested |
61
+ | scheduled_deletion_at | timestamp | When deletion will be executed (30 days) |
62
+ | cancelled_at | timestamp | When deletion was cancelled |
63
+ | completed_at | timestamp | When deletion was completed |
64
+
65
+ ### API Routes
66
+
67
+ | Method | Path | Auth | Description |
68
+ |--------|------|------|-------------|
69
+ | GET | /api/gdpr/export | Yes | Export all user data as JSON |
70
+ | POST | /api/gdpr/deletion | Yes | Request account deletion (30-day grace) |
71
+ | POST | /api/gdpr/deletion/cancel | Yes | Cancel pending deletion request |
72
+ | DELETE | /api/gdpr/account | Yes | Immediately delete account (requires password) |
73
+ | GET | /api/gdpr/consents | Yes | Get active user consents |
74
+ | POST | /api/gdpr/consents | Yes | Record a new consent |
75
+ | DELETE | /api/gdpr/consents/:consentType | Yes | Revoke a specific consent |
76
+ | POST | /api/gdpr/process-deletions | Cron | Process expired deletion requests |
77
+
78
+ ### Deletion Flow
79
+
80
+ 1. User requests account deletion from Settings
81
+ 2. A deletion request is created with a 30-day grace period
82
+ 3. User receives an email with a link to cancel
83
+ 4. User can cancel the deletion from Settings at any time
84
+ 5. A daily cron job processes expired deletion requests
85
+ 6. When processed, the user's data is permanently deleted (cascading)
86
+ 7. A final confirmation email is sent
87
+
88
+ ### Immediate Deletion
89
+
90
+ Users can also request immediate deletion (bypassing the 30-day grace period) by confirming their password. This is useful for users who want their data removed right away.
91
+
92
+ ### Email Templates
93
+
94
+ The GDPR sail uses these email functions from the email package:
95
+
96
+ - `sendDeletionRequestedEmail` - Sent when a user requests deletion
97
+ - `sendDeletionCompletedEmail` - Sent after data is permanently deleted
98
+ - `sendDeletionCancelledEmail` - Sent when a user cancels a deletion request
99
+ - `sendDataExportReadyEmail` - Sent when a data export is ready for download
100
+ - `sendConsentUpdatedEmail` - Sent when consent preferences are changed
101
+
102
+ ## Frontend Components
103
+
104
+ ### ConsentCheckboxes
105
+
106
+ Added to the signup form. Requires acceptance of Privacy Policy and Terms of Service before registration. Marketing and analytics consent are optional.
107
+
108
+ ### DataExportButton
109
+
110
+ A button in Account Settings that triggers a JSON download of all user data.
111
+
112
+ ### AccountDeletionRequest
113
+
114
+ A section in Account Settings that shows the current deletion status and allows requesting or cancelling deletion.
115
+
116
+ ### PrivacyPolicy Page
117
+
118
+ A public page at `/privacy-policy` with GDPR-compliant privacy policy content. Customize this for your specific use case.
119
+
120
+ ## Cron Job Setup
121
+
122
+ Set up a daily cron job to process scheduled deletions:
123
+
124
+ ```bash
125
+ # Using curl
126
+ curl -X POST https://your-backend.com/api/gdpr/process-deletions \
127
+ -H "x-cron-secret: your-deletion-cron-secret"
128
+ ```
129
+
130
+ ### Example: cron-job.org
131
+
132
+ 1. Create a new cron job
133
+ 2. URL: `https://your-backend.com/api/gdpr/process-deletions`
134
+ 3. Method: POST
135
+ 4. Header: `x-cron-secret: your-deletion-cron-secret`
136
+ 5. Schedule: Daily at 2:00 AM
137
+
138
+ ### Example: Vercel Cron
139
+
140
+ Add to `vercel.json`:
141
+ ```json
142
+ {
143
+ "crons": [{
144
+ "path": "/api/gdpr/process-deletions",
145
+ "schedule": "0 2 * * *"
146
+ }]
147
+ }
148
+ ```
149
+
150
+ ## Customization
151
+
152
+ ### Privacy Policy
153
+
154
+ Edit `packages/frontend/src/pages/PrivacyPolicy.tsx` to match your company's privacy policy. Update:
155
+
156
+ - Company name and contact information
157
+ - Data Protection Officer details
158
+ - Specific data processing purposes
159
+ - Third-party services used
160
+ - Data retention periods
161
+
162
+ ### Consent Types
163
+
164
+ The default consent types are:
165
+ - `privacyPolicy` (required)
166
+ - `termsOfService` (required)
167
+ - `marketingEmails` (optional)
168
+ - `analytics` (optional)
169
+
170
+ To add custom consent types, modify `ConsentCheckboxes.tsx` and the consent recording logic.
171
+
172
+ ### Grace Period
173
+
174
+ The default deletion grace period is 30 days. To change this, modify the `requestDeletion` function in `packages/backend/src/services/gdpr.ts`.
@@ -1,27 +1,27 @@
1
- {
2
- "name": "gdpr",
3
- "displayName": "GDPR/DSGVO Compliance",
4
- "description": "Full GDPR compliance: consent tracking, data export, account deletion (30-day grace period), privacy policy page",
5
- "version": "1.0.0",
6
- "compatibility": ">=1.0.0",
7
- "requiredEnvVars": [
8
- { "key": "DELETION_CRON_SECRET", "description": "Secret for the deletion cron endpoint" }
9
- ],
10
- "dependencies": {
11
- "backend": {},
12
- "frontend": {}
13
- },
14
- "modifies": {
15
- "backend": ["src/index.ts", "src/db/schema.ts", "src/env.ts"],
16
- "frontend": ["src/router.tsx", "src/components/auth/SignupForm.tsx", "src/components/profile/AccountSettings.tsx"]
17
- },
18
- "adds": {
19
- "backend": ["src/services/gdpr.ts", "src/routes/gdpr.ts"],
20
- "frontend": [
21
- "src/components/gdpr/DataExportButton.tsx",
22
- "src/components/gdpr/AccountDeletionRequest.tsx",
23
- "src/components/auth/ConsentCheckboxes.tsx",
24
- "src/pages/PrivacyPolicy.tsx"
25
- ]
26
- }
27
- }
1
+ {
2
+ "name": "gdpr",
3
+ "displayName": "GDPR/DSGVO Compliance",
4
+ "description": "Full GDPR compliance: consent tracking, data export, account deletion (30-day grace period), privacy policy page",
5
+ "version": "1.0.0",
6
+ "compatibility": ">=1.0.0",
7
+ "requiredEnvVars": [
8
+ { "key": "DELETION_CRON_SECRET", "description": "Secret for the deletion cron endpoint" }
9
+ ],
10
+ "dependencies": {
11
+ "backend": {},
12
+ "frontend": {}
13
+ },
14
+ "modifies": {
15
+ "backend": ["src/index.ts", "src/db/schema.ts", "src/env.ts"],
16
+ "frontend": ["src/router.tsx", "src/components/auth/SignupForm.tsx", "src/components/profile/AccountSettings.tsx"]
17
+ },
18
+ "adds": {
19
+ "backend": ["src/services/gdpr.ts", "src/routes/gdpr.ts"],
20
+ "frontend": [
21
+ "src/components/gdpr/DataExportButton.tsx",
22
+ "src/components/gdpr/AccountDeletionRequest.tsx",
23
+ "src/components/auth/ConsentCheckboxes.tsx",
24
+ "src/pages/PrivacyPolicy.tsx"
25
+ ]
26
+ }
27
+ }