@lastbrain/app 0.1.30 → 0.1.31
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/dist/auth/useAuthSession.d.ts.map +1 -1
- package/dist/auth/useAuthSession.js +8 -2
- package/dist/components/NotificationContainer.d.ts +2 -0
- package/dist/components/NotificationContainer.d.ts.map +1 -0
- package/dist/components/NotificationContainer.js +8 -0
- package/dist/hooks/useNotifications.d.ts +29 -0
- package/dist/hooks/useNotifications.d.ts.map +1 -0
- package/dist/hooks/useNotifications.js +165 -0
- package/dist/hooks/useNotificationsSimple.d.ts +20 -0
- package/dist/hooks/useNotificationsSimple.d.ts.map +1 -0
- package/dist/hooks/useNotificationsSimple.js +37 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/layouts/AdminLayoutWithSidebar.d.ts.map +1 -1
- package/dist/layouts/AdminLayoutWithSidebar.js +13 -4
- package/dist/layouts/AppProviders.d.ts +15 -2
- package/dist/layouts/AppProviders.d.ts.map +1 -1
- package/dist/layouts/AppProviders.js +21 -8
- package/dist/layouts/AuthLayoutWithSidebar.d.ts.map +1 -1
- package/dist/layouts/AuthLayoutWithSidebar.js +10 -2
- package/dist/layouts/PublicLayout.js +1 -1
- package/dist/layouts/PublicLayoutWithSidebar.d.ts +8 -0
- package/dist/layouts/PublicLayoutWithSidebar.d.ts.map +1 -0
- package/dist/layouts/PublicLayoutWithSidebar.js +19 -0
- package/dist/layouts/RootLayout.d.ts +3 -1
- package/dist/layouts/RootLayout.d.ts.map +1 -1
- package/dist/layouts/RootLayout.js +3 -2
- package/dist/scripts/init-app.d.ts.map +1 -1
- package/dist/scripts/init-app.js +159 -5
- package/dist/scripts/module-build.d.ts.map +1 -1
- package/dist/scripts/module-build.js +52 -0
- package/dist/styles.css +1 -1
- package/dist/templates/DefaultDoc.d.ts.map +1 -1
- package/dist/templates/DefaultDoc.js +64 -1
- package/dist/templates/DocPage.d.ts.map +1 -1
- package/dist/templates/DocPage.js +7 -0
- package/package.json +1 -2
- package/src/auth/useAuthSession.ts +6 -2
- package/src/components/NotificationContainer.tsx +20 -0
- package/src/hooks/useNotifications.ts +216 -0
- package/src/index.ts +4 -1
- package/src/layouts/AdminLayoutWithSidebar.tsx +18 -6
- package/src/layouts/AppProviders.tsx +50 -13
- package/src/layouts/AuthLayoutWithSidebar.tsx +16 -4
- package/src/layouts/PublicLayout.tsx +1 -1
- package/src/layouts/PublicLayoutWithSidebar.tsx +56 -0
- package/src/layouts/RootLayout.tsx +10 -2
- package/src/scripts/generate-realtime-config.mjs +183 -0
- package/src/scripts/init-app.ts +172 -5
- package/src/scripts/module-build.ts +63 -0
- package/src/templates/DefaultDoc.tsx +265 -0
- package/src/templates/DocPage.tsx +7 -0
|
@@ -666,6 +666,271 @@ const proxyUrl = storagePathToProxyUrl("avatar/user_128_123456.webp");
|
|
|
666
666
|
</CardBody>
|
|
667
667
|
</Card>
|
|
668
668
|
|
|
669
|
+
<Card id="section-realtime" className="scroll-mt-32">
|
|
670
|
+
<CardHeader>
|
|
671
|
+
<h2 className="text-2xl font-semibold flex items-center gap-2">
|
|
672
|
+
<Zap size={24} />
|
|
673
|
+
Système Realtime
|
|
674
|
+
</h2>
|
|
675
|
+
</CardHeader>
|
|
676
|
+
<CardBody className="space-y-4">
|
|
677
|
+
<p className="text-slate-600 dark:text-slate-400">
|
|
678
|
+
LastBrain intègre un système de notifications et de synchronisation
|
|
679
|
+
en temps réel basé sur Supabase Realtime. Le système est entièrement
|
|
680
|
+
automatisé et scalable.
|
|
681
|
+
</p>
|
|
682
|
+
|
|
683
|
+
<div>
|
|
684
|
+
<h3 className="text-lg font-semibold mb-2">
|
|
685
|
+
Configuration dans les modules
|
|
686
|
+
</h3>
|
|
687
|
+
<p className="text-sm text-slate-600 dark:text-slate-400 mb-3">
|
|
688
|
+
Ajoutez la configuration realtime dans votre{" "}
|
|
689
|
+
<code className="text-sm bg-slate-100 dark:bg-slate-800 px-2 py-1 rounded">
|
|
690
|
+
build.config.ts
|
|
691
|
+
</code>{" "}
|
|
692
|
+
pour activer la synchronisation en temps réel :
|
|
693
|
+
</p>
|
|
694
|
+
<div className="bg-slate-50 dark:bg-slate-900 p-4 rounded-lg text-sm font-mono overflow-x-auto">
|
|
695
|
+
<pre>{`export default {
|
|
696
|
+
name: "Module Auth",
|
|
697
|
+
description: "Gestion de l'authentification",
|
|
698
|
+
|
|
699
|
+
// Configuration realtime
|
|
700
|
+
realtime: {
|
|
701
|
+
moduleId: "module-auth",
|
|
702
|
+
tables: [
|
|
703
|
+
{
|
|
704
|
+
schema: "public",
|
|
705
|
+
table: "user_notifications",
|
|
706
|
+
event: "*", // INSERT, UPDATE, DELETE ou *
|
|
707
|
+
filter: "owner_id=eq.\${USER_ID}",
|
|
708
|
+
broadcast: "user_notifications_updated"
|
|
709
|
+
},
|
|
710
|
+
{
|
|
711
|
+
schema: "public",
|
|
712
|
+
table: "user_profiles",
|
|
713
|
+
event: "*",
|
|
714
|
+
filter: "owner_id=eq.\${USER_ID}",
|
|
715
|
+
broadcast: "user_profile_updated"
|
|
716
|
+
}
|
|
717
|
+
]
|
|
718
|
+
},
|
|
719
|
+
|
|
720
|
+
pages: [
|
|
721
|
+
// vos pages...
|
|
722
|
+
]
|
|
723
|
+
}`}</pre>
|
|
724
|
+
</div>
|
|
725
|
+
</div>
|
|
726
|
+
|
|
727
|
+
<div>
|
|
728
|
+
<h3 className="text-lg font-semibold mb-2">
|
|
729
|
+
Génération automatique de la configuration
|
|
730
|
+
</h3>
|
|
731
|
+
<p className="text-sm text-slate-600 dark:text-slate-400 mb-2">
|
|
732
|
+
Lors du build des modules, la configuration realtime est
|
|
733
|
+
automatiquement générée :
|
|
734
|
+
</p>
|
|
735
|
+
<Snippet symbol="" hideSymbol className="text-sm mb-3">
|
|
736
|
+
pnpm build:modules
|
|
737
|
+
</Snippet>
|
|
738
|
+
<p className="text-sm text-slate-600 dark:text-slate-400">
|
|
739
|
+
Cela génère automatiquement{" "}
|
|
740
|
+
<code className="text-sm bg-slate-100 dark:bg-slate-800 px-2 py-1 rounded">
|
|
741
|
+
config/realtime.ts
|
|
742
|
+
</code>{" "}
|
|
743
|
+
avec toutes les configurations des modules.
|
|
744
|
+
</p>
|
|
745
|
+
</div>
|
|
746
|
+
|
|
747
|
+
<div>
|
|
748
|
+
<h3 className="text-lg font-semibold mb-2">
|
|
749
|
+
Utilisation dans les composants
|
|
750
|
+
</h3>
|
|
751
|
+
<p className="text-sm text-slate-600 dark:text-slate-400 mb-3">
|
|
752
|
+
Utilisez les hooks pré-construits pour écouter les changements :
|
|
753
|
+
</p>
|
|
754
|
+
<div className="space-y-4">
|
|
755
|
+
<div>
|
|
756
|
+
<h4 className="font-medium mb-2">
|
|
757
|
+
1. Hook générique pour une table
|
|
758
|
+
</h4>
|
|
759
|
+
<div className="bg-slate-50 dark:bg-slate-900 p-4 rounded-lg text-sm font-mono overflow-x-auto">
|
|
760
|
+
<pre>{`import { useTableRealtime } from "@lastbrain/core";
|
|
761
|
+
|
|
762
|
+
function MonComposant() {
|
|
763
|
+
const signal = useTableRealtime("user_notifications");
|
|
764
|
+
|
|
765
|
+
useEffect(() => {
|
|
766
|
+
if (signal.hasUpdates) {
|
|
767
|
+
console.log("Nouvelle notification!");
|
|
768
|
+
// Recharger vos données
|
|
769
|
+
refetchNotifications();
|
|
770
|
+
}
|
|
771
|
+
}, [signal.tick]);
|
|
772
|
+
}`}</pre>
|
|
773
|
+
</div>
|
|
774
|
+
</div>
|
|
775
|
+
|
|
776
|
+
<div>
|
|
777
|
+
<h4 className="font-medium mb-2">
|
|
778
|
+
2. Hook spécialisé pour les notifications
|
|
779
|
+
</h4>
|
|
780
|
+
<div className="bg-slate-50 dark:bg-slate-900 p-4 rounded-lg text-sm font-mono overflow-x-auto">
|
|
781
|
+
<pre>{`import { useNotifications } from "../hooks/useNotifications";
|
|
782
|
+
|
|
783
|
+
function NotificationBell() {
|
|
784
|
+
const { notifications, loading, hasUpdates } = useNotifications();
|
|
785
|
+
|
|
786
|
+
return (
|
|
787
|
+
<div>
|
|
788
|
+
🔔 {notifications.length}
|
|
789
|
+
{hasUpdates && <span>•</span>}
|
|
790
|
+
</div>
|
|
791
|
+
);
|
|
792
|
+
}`}</pre>
|
|
793
|
+
</div>
|
|
794
|
+
</div>
|
|
795
|
+
|
|
796
|
+
<div>
|
|
797
|
+
<h4 className="font-medium mb-2">
|
|
798
|
+
3. Hook bas niveau avec EventBus
|
|
799
|
+
</h4>
|
|
800
|
+
<div className="bg-slate-50 dark:bg-slate-900 p-4 rounded-lg text-sm font-mono overflow-x-auto">
|
|
801
|
+
<pre>{`import { useRealtimeSignal } from "@lastbrain/core";
|
|
802
|
+
|
|
803
|
+
function MonComposant() {
|
|
804
|
+
const signal = useRealtimeSignal("user_notifications_updated");
|
|
805
|
+
|
|
806
|
+
useEffect(() => {
|
|
807
|
+
if (signal.hasUpdates) {
|
|
808
|
+
// Événement spécifique reçu
|
|
809
|
+
const payload = signal.lastPayload;
|
|
810
|
+
console.log("Données reçues:", payload);
|
|
811
|
+
}
|
|
812
|
+
}, [signal.tick]);
|
|
813
|
+
}`}</pre>
|
|
814
|
+
</div>
|
|
815
|
+
</div>
|
|
816
|
+
</div>
|
|
817
|
+
</div>
|
|
818
|
+
|
|
819
|
+
<div>
|
|
820
|
+
<h3 className="text-lg font-semibold mb-2">
|
|
821
|
+
Architecture du système
|
|
822
|
+
</h3>
|
|
823
|
+
<div className="space-y-3">
|
|
824
|
+
<div className="border-l-4 border-blue-500 pl-4">
|
|
825
|
+
<h4 className="font-semibold text-blue-600 dark:text-blue-400">
|
|
826
|
+
🎯 EventBus Global
|
|
827
|
+
</h4>
|
|
828
|
+
<p className="text-sm text-slate-600 dark:text-slate-400">
|
|
829
|
+
Système central de coordination des événements realtime à
|
|
830
|
+
travers toute l'application.
|
|
831
|
+
</p>
|
|
832
|
+
</div>
|
|
833
|
+
|
|
834
|
+
<div className="border-l-4 border-green-500 pl-4">
|
|
835
|
+
<h4 className="font-semibold text-green-600 dark:text-green-400">
|
|
836
|
+
🔌 RealtimeProvider
|
|
837
|
+
</h4>
|
|
838
|
+
<p className="text-sm text-slate-600 dark:text-slate-400">
|
|
839
|
+
Provider React qui établit les connexions Supabase Realtime
|
|
840
|
+
basées sur la configuration des modules.
|
|
841
|
+
</p>
|
|
842
|
+
</div>
|
|
843
|
+
|
|
844
|
+
<div className="border-l-4 border-purple-500 pl-4">
|
|
845
|
+
<h4 className="font-semibold text-purple-600 dark:text-purple-400">
|
|
846
|
+
⚡ Hooks Scalables
|
|
847
|
+
</h4>
|
|
848
|
+
<p className="text-sm text-slate-600 dark:text-slate-400">
|
|
849
|
+
Collection de hooks React pour écouter des tables ou
|
|
850
|
+
événements spécifiques avec auto-refresh.
|
|
851
|
+
</p>
|
|
852
|
+
</div>
|
|
853
|
+
|
|
854
|
+
<div className="border-l-4 border-orange-500 pl-4">
|
|
855
|
+
<h4 className="font-semibold text-orange-600 dark:text-orange-400">
|
|
856
|
+
🛠️ Build intégré
|
|
857
|
+
</h4>
|
|
858
|
+
<p className="text-sm text-slate-600 dark:text-slate-400">
|
|
859
|
+
Génération automatique de la configuration TypeScript lors du
|
|
860
|
+
build des modules.
|
|
861
|
+
</p>
|
|
862
|
+
</div>
|
|
863
|
+
</div>
|
|
864
|
+
</div>
|
|
865
|
+
|
|
866
|
+
<div>
|
|
867
|
+
<h3 className="text-lg font-semibold mb-2">Avantages du système</h3>
|
|
868
|
+
<div className="grid grid-cols-1 md:grid-cols-2 gap-3 text-sm">
|
|
869
|
+
<div className="flex items-start gap-2">
|
|
870
|
+
<span className="text-green-600">✅</span>
|
|
871
|
+
<span>Configuration déclarative dans les modules</span>
|
|
872
|
+
</div>
|
|
873
|
+
<div className="flex items-start gap-2">
|
|
874
|
+
<span className="text-green-600">✅</span>
|
|
875
|
+
<span>Génération automatique de config</span>
|
|
876
|
+
</div>
|
|
877
|
+
<div className="flex items-start gap-2">
|
|
878
|
+
<span className="text-green-600">✅</span>
|
|
879
|
+
<span>Hooks React prêts à l'emploi</span>
|
|
880
|
+
</div>
|
|
881
|
+
<div className="flex items-start gap-2">
|
|
882
|
+
<span className="text-green-600">✅</span>
|
|
883
|
+
<span>Sécurité RLS de Supabase</span>
|
|
884
|
+
</div>
|
|
885
|
+
<div className="flex items-start gap-2">
|
|
886
|
+
<span className="text-green-600">✅</span>
|
|
887
|
+
<span>Scalable pour n'importe quelle table</span>
|
|
888
|
+
</div>
|
|
889
|
+
<div className="flex items-start gap-2">
|
|
890
|
+
<span className="text-green-600">✅</span>
|
|
891
|
+
<span>TypeScript avec types générés</span>
|
|
892
|
+
</div>
|
|
893
|
+
</div>
|
|
894
|
+
</div>
|
|
895
|
+
|
|
896
|
+
<div>
|
|
897
|
+
<h3 className="text-lg font-semibold mb-2">
|
|
898
|
+
Exemples d'utilisation
|
|
899
|
+
</h3>
|
|
900
|
+
<div className="space-y-3">
|
|
901
|
+
<div className="p-3 bg-blue-50 dark:bg-blue-950 rounded-lg">
|
|
902
|
+
<h4 className="font-medium text-blue-700 dark:text-blue-300 mb-1">
|
|
903
|
+
🔔 Notifications
|
|
904
|
+
</h4>
|
|
905
|
+
<p className="text-sm text-blue-600 dark:text-blue-400">
|
|
906
|
+
Affichage en temps réel des nouvelles notifications avec badge
|
|
907
|
+
et auto-refresh
|
|
908
|
+
</p>
|
|
909
|
+
</div>
|
|
910
|
+
|
|
911
|
+
<div className="p-3 bg-purple-50 dark:bg-purple-950 rounded-lg">
|
|
912
|
+
<h4 className="font-medium text-purple-700 dark:text-purple-300 mb-1">
|
|
913
|
+
👥 Utilisateurs en ligne
|
|
914
|
+
</h4>
|
|
915
|
+
<p className="text-sm text-purple-600 dark:text-purple-400">
|
|
916
|
+
Suivi des connexions/déconnexions des utilisateurs en direct
|
|
917
|
+
</p>
|
|
918
|
+
</div>
|
|
919
|
+
|
|
920
|
+
<div className="p-3 bg-green-50 dark:bg-green-950 rounded-lg">
|
|
921
|
+
<h4 className="font-medium text-green-700 dark:text-green-300 mb-1">
|
|
922
|
+
📊 Données collaboratives
|
|
923
|
+
</h4>
|
|
924
|
+
<p className="text-sm text-green-600 dark:text-green-400">
|
|
925
|
+
Synchronisation automatique des modifications de données entre
|
|
926
|
+
utilisateurs
|
|
927
|
+
</p>
|
|
928
|
+
</div>
|
|
929
|
+
</div>
|
|
930
|
+
</div>
|
|
931
|
+
</CardBody>
|
|
932
|
+
</Card>
|
|
933
|
+
|
|
669
934
|
<Card id="section-module-docs" className="scroll-mt-32">
|
|
670
935
|
<CardHeader>
|
|
671
936
|
<h2 className="text-2xl font-semibold flex items-center gap-2">
|
|
@@ -130,6 +130,7 @@ export function DocPage({ modules = [], defaultContent }: DocPageProps) {
|
|
|
130
130
|
"section-create-module",
|
|
131
131
|
"section-database",
|
|
132
132
|
"section-storage",
|
|
133
|
+
"section-realtime",
|
|
133
134
|
"section-ui",
|
|
134
135
|
"section-module-docs",
|
|
135
136
|
"section-links",
|
|
@@ -233,6 +234,12 @@ export function DocPage({ modules = [], defaultContent }: DocPageProps) {
|
|
|
233
234
|
description: "Gestion des fichiers",
|
|
234
235
|
icon: HardDrive,
|
|
235
236
|
},
|
|
237
|
+
{
|
|
238
|
+
id: "section-realtime",
|
|
239
|
+
name: "Système Realtime",
|
|
240
|
+
description: "Synchronisation temps réel",
|
|
241
|
+
icon: Sparkles,
|
|
242
|
+
},
|
|
236
243
|
{
|
|
237
244
|
id: "section-ui",
|
|
238
245
|
name: "Interface utilisateur",
|