@codaijs/keel 0.2.2 → 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,163 +1,163 @@
1
- # Push Notifications Sail
2
-
3
- Adds push notification support to your keel application using Capacitor and Firebase Cloud Messaging (FCM).
4
-
5
- ## Features
6
-
7
- - Firebase Cloud Messaging for push delivery (iOS, Android)
8
- - Capacitor integration for native device token management
9
- - Device token registration and storage in PostgreSQL
10
- - Server-side notification sending via firebase-admin
11
- - React hook for permission handling, token lifecycle, and notification taps
12
- - Automatic deep-link navigation on notification tap
13
-
14
- ## Prerequisites
15
-
16
- - A Firebase project (https://console.firebase.google.com)
17
- - Cloud Messaging API (V1) enabled in the Firebase project
18
- - A Firebase service account JSON key file
19
- - For iOS: An APNs authentication key from Apple Developer
20
-
21
- ## Installation
22
-
23
- ```bash
24
- npx tsx sails/push-notifications/install.ts
25
- ```
26
-
27
- The installer will guide you through Firebase setup and collect your service account credentials.
28
-
29
- ## Manual Setup
30
-
31
- ### 1. Firebase Project
32
-
33
- 1. Go to https://console.firebase.google.com
34
- 2. Create a new project (or select existing)
35
- 3. Go to **Project Settings > Cloud Messaging**
36
- 4. Ensure Cloud Messaging API (V1) is enabled
37
-
38
- ### 2. Service Account Key
39
-
40
- 1. Go to **Project Settings > Service Accounts**
41
- 2. Click **Generate new private key**
42
- 3. Download the JSON file
43
- 4. Extract these values for your `.env`:
44
-
45
- ```env
46
- FIREBASE_PROJECT_ID=your-project-id
47
- FIREBASE_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n"
48
- FIREBASE_CLIENT_EMAIL=firebase-adminsdk-xxxxx@your-project.iam.gserviceaccount.com
49
- ```
50
-
51
- ### 3. iOS Configuration (APNs)
52
-
53
- 1. Go to https://developer.apple.com/account/resources/authkeys/list
54
- 2. Create a new key, check **Apple Push Notifications service (APNs)**
55
- 3. Download the `.p8` key file
56
- 4. In Firebase Console > Project Settings > Cloud Messaging > iOS app:
57
- - Upload the APNs authentication key
58
- - Enter the Key ID and Team ID
59
- 5. Run `npx cap sync ios`
60
-
61
- ### 4. Android Configuration
62
-
63
- 1. In Firebase Console, add an Android app (use your app's package name)
64
- 2. Download `google-services.json`
65
- 3. Place it at `android/app/google-services.json`
66
- 4. Run `npx cap sync android`
67
-
68
- ## Architecture
69
-
70
- ### Database Schema
71
-
72
- **push_tokens**
73
- | Column | Type | Description |
74
- |--------|------|-------------|
75
- | id | text | Primary key (UUID) |
76
- | user_id | text | FK to users table (cascade delete) |
77
- | token | text | FCM device token |
78
- | platform | varchar(20) | ios, android, or web |
79
- | created_at | timestamp | Registration time |
80
-
81
- ### API Routes
82
-
83
- | Method | Path | Auth | Description |
84
- |--------|------|------|-------------|
85
- | POST | /api/notifications/register | Yes | Register a device push token |
86
- | DELETE | /api/notifications/unregister | Yes | Remove a device push token |
87
- | POST | /api/notifications/send | Yes | Send a notification to a user |
88
-
89
- ### Backend Service
90
-
91
- The `notifications` service provides two functions:
92
-
93
- ```typescript
94
- import {
95
- sendPushNotification,
96
- sendMultiplePushNotifications,
97
- } from "./services/notifications.js";
98
-
99
- // Send to a single device
100
- await sendPushNotification(token, "Title", "Body", { route: "/notifications" });
101
-
102
- // Send to multiple devices
103
- await sendMultiplePushNotifications(tokens, "Title", "Body");
104
- ```
105
-
106
- ### Frontend Hook
107
-
108
- ```tsx
109
- import { usePushNotifications } from "@/hooks/usePushNotifications";
110
-
111
- function MyComponent() {
112
- const { isRegistered, permissionStatus, register, unregister } =
113
- usePushNotifications();
114
-
115
- return (
116
- <div>
117
- <p>Permission: {permissionStatus}</p>
118
- <p>Registered: {isRegistered ? "Yes" : "No"}</p>
119
- <button onClick={register}>Enable Notifications</button>
120
- <button onClick={unregister}>Disable Notifications</button>
121
- </div>
122
- );
123
- }
124
- ```
125
-
126
- ### PushNotificationInit Component
127
-
128
- The `<PushNotificationInit />` component is placed in `Layout.tsx` and silently handles push registration on app mount. It renders nothing visible.
129
-
130
- ### Deep Linking
131
-
132
- When a user taps a notification, the hook checks for a `route` field in the notification data payload and navigates to it:
133
-
134
- ```typescript
135
- // When sending a notification, include a route:
136
- await sendPushNotification(token, "New Message", "You have a new message", {
137
- route: "/messages/123",
138
- });
139
- ```
140
-
141
- ## Testing
142
-
143
- Push notifications **only work on physical devices**, not simulators or emulators.
144
-
145
- ### Sending Test Notifications
146
-
147
- 1. **Firebase Console**: Go to Messaging > Create your first campaign > Notifications
148
- 2. **API endpoint**: `POST /api/notifications/send` with body:
149
- ```json
150
- {
151
- "userId": "user-id-here",
152
- "title": "Test Notification",
153
- "body": "This is a test push notification",
154
- "data": { "route": "/profile" }
155
- }
156
- ```
157
-
158
- ### Debugging
159
-
160
- - Check the browser/device console for registration logs
161
- - Check server logs for firebase-admin errors
162
- - Verify the FCM token is stored in the `push_tokens` table
163
- - Make sure APNs (iOS) or google-services.json (Android) are configured correctly
1
+ # Push Notifications Sail
2
+
3
+ Adds push notification support to your keel application using Capacitor and Firebase Cloud Messaging (FCM).
4
+
5
+ ## Features
6
+
7
+ - Firebase Cloud Messaging for push delivery (iOS, Android)
8
+ - Capacitor integration for native device token management
9
+ - Device token registration and storage in PostgreSQL
10
+ - Server-side notification sending via firebase-admin
11
+ - React hook for permission handling, token lifecycle, and notification taps
12
+ - Automatic deep-link navigation on notification tap
13
+
14
+ ## Prerequisites
15
+
16
+ - A Firebase project (https://console.firebase.google.com)
17
+ - Cloud Messaging API (V1) enabled in the Firebase project
18
+ - A Firebase service account JSON key file
19
+ - For iOS: An APNs authentication key from Apple Developer
20
+
21
+ ## Installation
22
+
23
+ ```bash
24
+ npx tsx sails/push-notifications/install.ts
25
+ ```
26
+
27
+ The installer will guide you through Firebase setup and collect your service account credentials.
28
+
29
+ ## Manual Setup
30
+
31
+ ### 1. Firebase Project
32
+
33
+ 1. Go to https://console.firebase.google.com
34
+ 2. Create a new project (or select existing)
35
+ 3. Go to **Project Settings > Cloud Messaging**
36
+ 4. Ensure Cloud Messaging API (V1) is enabled
37
+
38
+ ### 2. Service Account Key
39
+
40
+ 1. Go to **Project Settings > Service Accounts**
41
+ 2. Click **Generate new private key**
42
+ 3. Download the JSON file
43
+ 4. Extract these values for your `.env`:
44
+
45
+ ```env
46
+ FIREBASE_PROJECT_ID=your-project-id
47
+ FIREBASE_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n"
48
+ FIREBASE_CLIENT_EMAIL=firebase-adminsdk-xxxxx@your-project.iam.gserviceaccount.com
49
+ ```
50
+
51
+ ### 3. iOS Configuration (APNs)
52
+
53
+ 1. Go to https://developer.apple.com/account/resources/authkeys/list
54
+ 2. Create a new key, check **Apple Push Notifications service (APNs)**
55
+ 3. Download the `.p8` key file
56
+ 4. In Firebase Console > Project Settings > Cloud Messaging > iOS app:
57
+ - Upload the APNs authentication key
58
+ - Enter the Key ID and Team ID
59
+ 5. Run `npx cap sync ios`
60
+
61
+ ### 4. Android Configuration
62
+
63
+ 1. In Firebase Console, add an Android app (use your app's package name)
64
+ 2. Download `google-services.json`
65
+ 3. Place it at `android/app/google-services.json`
66
+ 4. Run `npx cap sync android`
67
+
68
+ ## Architecture
69
+
70
+ ### Database Schema
71
+
72
+ **push_tokens**
73
+ | Column | Type | Description |
74
+ |--------|------|-------------|
75
+ | id | text | Primary key (UUID) |
76
+ | user_id | text | FK to users table (cascade delete) |
77
+ | token | text | FCM device token |
78
+ | platform | varchar(20) | ios, android, or web |
79
+ | created_at | timestamp | Registration time |
80
+
81
+ ### API Routes
82
+
83
+ | Method | Path | Auth | Description |
84
+ |--------|------|------|-------------|
85
+ | POST | /api/notifications/register | Yes | Register a device push token |
86
+ | DELETE | /api/notifications/unregister | Yes | Remove a device push token |
87
+ | POST | /api/notifications/send | Yes | Send a notification to a user |
88
+
89
+ ### Backend Service
90
+
91
+ The `notifications` service provides two functions:
92
+
93
+ ```typescript
94
+ import {
95
+ sendPushNotification,
96
+ sendMultiplePushNotifications,
97
+ } from "./services/notifications.js";
98
+
99
+ // Send to a single device
100
+ await sendPushNotification(token, "Title", "Body", { route: "/notifications" });
101
+
102
+ // Send to multiple devices
103
+ await sendMultiplePushNotifications(tokens, "Title", "Body");
104
+ ```
105
+
106
+ ### Frontend Hook
107
+
108
+ ```tsx
109
+ import { usePushNotifications } from "@/hooks/usePushNotifications";
110
+
111
+ function MyComponent() {
112
+ const { isRegistered, permissionStatus, register, unregister } =
113
+ usePushNotifications();
114
+
115
+ return (
116
+ <div>
117
+ <p>Permission: {permissionStatus}</p>
118
+ <p>Registered: {isRegistered ? "Yes" : "No"}</p>
119
+ <button onClick={register}>Enable Notifications</button>
120
+ <button onClick={unregister}>Disable Notifications</button>
121
+ </div>
122
+ );
123
+ }
124
+ ```
125
+
126
+ ### PushNotificationInit Component
127
+
128
+ The `<PushNotificationInit />` component is placed in `Layout.tsx` and silently handles push registration on app mount. It renders nothing visible.
129
+
130
+ ### Deep Linking
131
+
132
+ When a user taps a notification, the hook checks for a `route` field in the notification data payload and navigates to it:
133
+
134
+ ```typescript
135
+ // When sending a notification, include a route:
136
+ await sendPushNotification(token, "New Message", "You have a new message", {
137
+ route: "/messages/123",
138
+ });
139
+ ```
140
+
141
+ ## Testing
142
+
143
+ Push notifications **only work on physical devices**, not simulators or emulators.
144
+
145
+ ### Sending Test Notifications
146
+
147
+ 1. **Firebase Console**: Go to Messaging > Create your first campaign > Notifications
148
+ 2. **API endpoint**: `POST /api/notifications/send` with body:
149
+ ```json
150
+ {
151
+ "userId": "user-id-here",
152
+ "title": "Test Notification",
153
+ "body": "This is a test push notification",
154
+ "data": { "route": "/profile" }
155
+ }
156
+ ```
157
+
158
+ ### Debugging
159
+
160
+ - Check the browser/device console for registration logs
161
+ - Check server logs for firebase-admin errors
162
+ - Verify the FCM token is stored in the `push_tokens` table
163
+ - Make sure APNs (iOS) or google-services.json (Android) are configured correctly
@@ -1,31 +1,31 @@
1
- {
2
- "name": "push-notifications",
3
- "displayName": "Push Notifications",
4
- "description": "Push notifications via Capacitor + Firebase Cloud Messaging with device token management and server-side sending",
5
- "version": "1.0.0",
6
- "compatibility": ">=1.0.0",
7
- "requiredEnvVars": [
8
- { "key": "FIREBASE_PROJECT_ID", "description": "Firebase project ID (from Firebase Console > Project Settings)" },
9
- { "key": "FIREBASE_PRIVATE_KEY", "description": "Firebase service account private key (the full PEM key including -----BEGIN/END-----)" },
10
- { "key": "FIREBASE_CLIENT_EMAIL", "description": "Firebase service account client email (e.g., firebase-adminsdk-xxxxx@project.iam.gserviceaccount.com)" }
11
- ],
12
- "dependencies": {
13
- "backend": { "firebase-admin": "^13.0.0" },
14
- "frontend": { "@capacitor/push-notifications": "^6.0.0" }
15
- },
16
- "modifies": {
17
- "backend": ["src/index.ts", "src/db/schema/index.ts", "src/env.ts"],
18
- "frontend": ["src/components/layout/Layout.tsx"]
19
- },
20
- "adds": {
21
- "backend": [
22
- "src/db/schema/notifications.ts",
23
- "src/routes/notifications.ts",
24
- "src/services/notifications.ts"
25
- ],
26
- "frontend": [
27
- "src/hooks/usePushNotifications.ts",
28
- "src/components/PushNotificationInit.tsx"
29
- ]
30
- }
31
- }
1
+ {
2
+ "name": "push-notifications",
3
+ "displayName": "Push Notifications",
4
+ "description": "Push notifications via Capacitor + Firebase Cloud Messaging with device token management and server-side sending",
5
+ "version": "1.0.0",
6
+ "compatibility": ">=1.0.0",
7
+ "requiredEnvVars": [
8
+ { "key": "FIREBASE_PROJECT_ID", "description": "Firebase project ID (from Firebase Console > Project Settings)" },
9
+ { "key": "FIREBASE_PRIVATE_KEY", "description": "Firebase service account private key (the full PEM key including -----BEGIN/END-----)" },
10
+ { "key": "FIREBASE_CLIENT_EMAIL", "description": "Firebase service account client email (e.g., firebase-adminsdk-xxxxx@project.iam.gserviceaccount.com)" }
11
+ ],
12
+ "dependencies": {
13
+ "backend": { "firebase-admin": "^13.0.0" },
14
+ "frontend": { "@capacitor/push-notifications": "^8.0.0" }
15
+ },
16
+ "modifies": {
17
+ "backend": ["src/index.ts", "src/db/schema/index.ts", "src/env.ts"],
18
+ "frontend": ["src/components/layout/Layout.tsx"]
19
+ },
20
+ "adds": {
21
+ "backend": [
22
+ "src/db/schema/notifications.ts",
23
+ "src/routes/notifications.ts",
24
+ "src/services/notifications.ts"
25
+ ],
26
+ "frontend": [
27
+ "src/hooks/usePushNotifications.ts",
28
+ "src/components/PushNotificationInit.tsx"
29
+ ]
30
+ }
31
+ }