@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,118 +1,118 @@
1
- import { useState, useEffect, useCallback } from "react";
2
-
3
- interface FileRecord {
4
- id: string;
5
- fileName: string;
6
- contentType: string | null;
7
- sizeBytes: number | null;
8
- createdAt: string;
9
- }
10
-
11
- interface UseFilesResult {
12
- /** Array of the current user's files. */
13
- files: FileRecord[];
14
- /** Whether the file list is loading. */
15
- isLoading: boolean;
16
- /** Last error message, if any. */
17
- error: string | null;
18
- /** Delete a file by ID. */
19
- deleteFile: (id: string) => Promise<boolean>;
20
- /** Get a temporary download URL for a file. */
21
- getDownloadUrl: (id: string) => Promise<string | null>;
22
- /** Manually refresh the file list. */
23
- refresh: () => Promise<void>;
24
- }
25
-
26
- /**
27
- * Hook for managing the current user's files.
28
- *
29
- * Automatically fetches the file list on mount.
30
- *
31
- * Usage:
32
- * const { files, isLoading, deleteFile, getDownloadUrl, refresh } = useFiles();
33
- */
34
- export function useFiles(): UseFilesResult {
35
- const [files, setFiles] = useState<FileRecord[]>([]);
36
- const [isLoading, setIsLoading] = useState(true);
37
- const [error, setError] = useState<string | null>(null);
38
-
39
- const fetchFiles = useCallback(async () => {
40
- setIsLoading(true);
41
- setError(null);
42
-
43
- try {
44
- const response = await fetch("/api/files", {
45
- credentials: "include",
46
- });
47
-
48
- if (!response.ok) {
49
- throw new Error(`Failed to fetch files: ${response.statusText}`);
50
- }
51
-
52
- const data = await response.json();
53
- setFiles(data.files ?? []);
54
- } catch (err) {
55
- setError(
56
- err instanceof Error ? err.message : "Failed to load files",
57
- );
58
- setFiles([]);
59
- } finally {
60
- setIsLoading(false);
61
- }
62
- }, []);
63
-
64
- useEffect(() => {
65
- fetchFiles();
66
- }, [fetchFiles]);
67
-
68
- const deleteFile = useCallback(async (id: string): Promise<boolean> => {
69
- try {
70
- const response = await fetch(`/api/files/${id}`, {
71
- method: "DELETE",
72
- credentials: "include",
73
- });
74
-
75
- if (!response.ok) {
76
- throw new Error("Failed to delete file");
77
- }
78
-
79
- // Remove from local state.
80
- setFiles((prev) => prev.filter((f) => f.id !== id));
81
- return true;
82
- } catch (err) {
83
- setError(
84
- err instanceof Error ? err.message : "Failed to delete file",
85
- );
86
- return false;
87
- }
88
- }, []);
89
-
90
- const getDownloadUrl = useCallback(
91
- async (id: string): Promise<string | null> => {
92
- try {
93
- const response = await fetch(`/api/files/${id}`, {
94
- credentials: "include",
95
- });
96
-
97
- if (!response.ok) {
98
- throw new Error("Failed to get download URL");
99
- }
100
-
101
- const data = await response.json();
102
- return data.file?.downloadUrl ?? null;
103
- } catch {
104
- return null;
105
- }
106
- },
107
- [],
108
- );
109
-
110
- return {
111
- files,
112
- isLoading,
113
- error,
114
- deleteFile,
115
- getDownloadUrl,
116
- refresh: fetchFiles,
117
- };
118
- }
1
+ import { useState, useEffect, useCallback } from "react";
2
+
3
+ interface FileRecord {
4
+ id: string;
5
+ fileName: string;
6
+ contentType: string | null;
7
+ sizeBytes: number | null;
8
+ createdAt: string;
9
+ }
10
+
11
+ interface UseFilesResult {
12
+ /** Array of the current user's files. */
13
+ files: FileRecord[];
14
+ /** Whether the file list is loading. */
15
+ isLoading: boolean;
16
+ /** Last error message, if any. */
17
+ error: string | null;
18
+ /** Delete a file by ID. */
19
+ deleteFile: (id: string) => Promise<boolean>;
20
+ /** Get a temporary download URL for a file. */
21
+ getDownloadUrl: (id: string) => Promise<string | null>;
22
+ /** Manually refresh the file list. */
23
+ refresh: () => Promise<void>;
24
+ }
25
+
26
+ /**
27
+ * Hook for managing the current user's files.
28
+ *
29
+ * Automatically fetches the file list on mount.
30
+ *
31
+ * Usage:
32
+ * const { files, isLoading, deleteFile, getDownloadUrl, refresh } = useFiles();
33
+ */
34
+ export function useFiles(): UseFilesResult {
35
+ const [files, setFiles] = useState<FileRecord[]>([]);
36
+ const [isLoading, setIsLoading] = useState(true);
37
+ const [error, setError] = useState<string | null>(null);
38
+
39
+ const fetchFiles = useCallback(async () => {
40
+ setIsLoading(true);
41
+ setError(null);
42
+
43
+ try {
44
+ const response = await fetch("/api/files", {
45
+ credentials: "include",
46
+ });
47
+
48
+ if (!response.ok) {
49
+ throw new Error(`Failed to fetch files: ${response.statusText}`);
50
+ }
51
+
52
+ const data = await response.json();
53
+ setFiles(data.files ?? []);
54
+ } catch (err) {
55
+ setError(
56
+ err instanceof Error ? err.message : "Failed to load files",
57
+ );
58
+ setFiles([]);
59
+ } finally {
60
+ setIsLoading(false);
61
+ }
62
+ }, []);
63
+
64
+ useEffect(() => {
65
+ fetchFiles();
66
+ }, [fetchFiles]);
67
+
68
+ const deleteFile = useCallback(async (id: string): Promise<boolean> => {
69
+ try {
70
+ const response = await fetch(`/api/files/${id}`, {
71
+ method: "DELETE",
72
+ credentials: "include",
73
+ });
74
+
75
+ if (!response.ok) {
76
+ throw new Error("Failed to delete file");
77
+ }
78
+
79
+ // Remove from local state.
80
+ setFiles((prev) => prev.filter((f) => f.id !== id));
81
+ return true;
82
+ } catch (err) {
83
+ setError(
84
+ err instanceof Error ? err.message : "Failed to delete file",
85
+ );
86
+ return false;
87
+ }
88
+ }, []);
89
+
90
+ const getDownloadUrl = useCallback(
91
+ async (id: string): Promise<string | null> => {
92
+ try {
93
+ const response = await fetch(`/api/files/${id}`, {
94
+ credentials: "include",
95
+ });
96
+
97
+ if (!response.ok) {
98
+ throw new Error("Failed to get download URL");
99
+ }
100
+
101
+ const data = await response.json();
102
+ return data.file?.downloadUrl ?? null;
103
+ } catch {
104
+ return null;
105
+ }
106
+ },
107
+ [],
108
+ );
109
+
110
+ return {
111
+ files,
112
+ isLoading,
113
+ error,
114
+ deleteFile,
115
+ getDownloadUrl,
116
+ refresh: fetchFiles,
117
+ };
118
+ }
@@ -1,37 +1,37 @@
1
- import { useCallback } from "react";
2
- import { FileUploadButton } from "@/components/files/FileUploadButton";
3
- import { FileList } from "@/components/files/FileList";
4
- import { useFiles } from "@/hooks/useFiles";
5
-
6
- /**
7
- * Files page.
8
- *
9
- * Combines the file upload button and file browser into a single page.
10
- */
11
- export function FilesPage() {
12
- const { refresh } = useFiles();
13
-
14
- const handleUploadComplete = useCallback(() => {
15
- // Refresh the file list after a successful upload.
16
- refresh();
17
- }, [refresh]);
18
-
19
- return (
20
- <div className="mx-auto max-w-4xl px-4 py-10 sm:px-6 lg:px-8">
21
- <div className="mb-8">
22
- <h1 className="text-2xl font-bold text-white">Files</h1>
23
- <p className="mt-1 text-sm text-keel-gray-400">
24
- Upload, manage, and download your files.
25
- </p>
26
- </div>
27
-
28
- {/* Upload zone */}
29
- <div className="mb-8">
30
- <FileUploadButton onUploadComplete={handleUploadComplete} />
31
- </div>
32
-
33
- {/* File browser */}
34
- <FileList />
35
- </div>
36
- );
37
- }
1
+ import { useCallback } from "react";
2
+ import { FileUploadButton } from "@/components/files/FileUploadButton";
3
+ import { FileList } from "@/components/files/FileList";
4
+ import { useFiles } from "@/hooks/useFiles";
5
+
6
+ /**
7
+ * Files page.
8
+ *
9
+ * Combines the file upload button and file browser into a single page.
10
+ */
11
+ export function FilesPage() {
12
+ const { refresh } = useFiles();
13
+
14
+ const handleUploadComplete = useCallback(() => {
15
+ // Refresh the file list after a successful upload.
16
+ refresh();
17
+ }, [refresh]);
18
+
19
+ return (
20
+ <div className="mx-auto max-w-4xl px-4 py-10 sm:px-6 lg:px-8">
21
+ <div className="mb-8">
22
+ <h1 className="text-2xl font-bold text-white">Files</h1>
23
+ <p className="mt-1 text-sm text-keel-gray-400">
24
+ Upload, manage, and download your files.
25
+ </p>
26
+ </div>
27
+
28
+ {/* Upload zone */}
29
+ <div className="mb-8">
30
+ <FileUploadButton onUploadComplete={handleUploadComplete} />
31
+ </div>
32
+
33
+ {/* File browser */}
34
+ <FileList />
35
+ </div>
36
+ );
37
+ }