@lastbrain/app 0.1.34 → 0.1.37

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 (38) hide show
  1. package/README.md +23 -5
  2. package/dist/__tests__/module-registry.test.js +5 -16
  3. package/dist/scripts/init-app.d.ts.map +1 -1
  4. package/dist/scripts/init-app.js +2 -2
  5. package/dist/scripts/module-add.d.ts +0 -11
  6. package/dist/scripts/module-add.d.ts.map +1 -1
  7. package/dist/scripts/module-add.js +45 -22
  8. package/dist/scripts/module-build.d.ts.map +1 -1
  9. package/dist/scripts/module-build.js +90 -1
  10. package/dist/scripts/module-create.d.ts +23 -0
  11. package/dist/scripts/module-create.d.ts.map +1 -1
  12. package/dist/scripts/module-create.js +737 -52
  13. package/dist/scripts/module-delete.d.ts +6 -0
  14. package/dist/scripts/module-delete.d.ts.map +1 -0
  15. package/dist/scripts/module-delete.js +143 -0
  16. package/dist/scripts/module-list.d.ts.map +1 -1
  17. package/dist/scripts/module-list.js +2 -2
  18. package/dist/scripts/module-remove.d.ts.map +1 -1
  19. package/dist/scripts/module-remove.js +20 -4
  20. package/dist/styles.css +1 -1
  21. package/dist/templates/DefaultDoc.d.ts.map +1 -1
  22. package/dist/templates/DefaultDoc.js +170 -30
  23. package/dist/templates/DocPage.d.ts.map +1 -1
  24. package/dist/templates/DocPage.js +25 -8
  25. package/dist/templates/migrations/20201010100000_app_base.sql +23 -24
  26. package/package.json +4 -4
  27. package/src/__tests__/module-registry.test.ts +5 -17
  28. package/src/scripts/db-init.ts +2 -2
  29. package/src/scripts/init-app.ts +5 -2
  30. package/src/scripts/module-add.ts +55 -23
  31. package/src/scripts/module-build.ts +109 -1
  32. package/src/scripts/module-create.ts +885 -63
  33. package/src/scripts/module-delete.ts +202 -0
  34. package/src/scripts/module-list.ts +9 -2
  35. package/src/scripts/module-remove.ts +36 -4
  36. package/src/templates/DefaultDoc.tsx +1163 -753
  37. package/src/templates/DocPage.tsx +28 -11
  38. package/src/templates/migrations/20201010100000_app_base.sql +23 -24
@@ -28,6 +28,7 @@ import {
28
28
  Link,
29
29
  Blocks,
30
30
  HardDrive,
31
+ RotateCcw,
31
32
  } from "lucide-react";
32
33
  import { DefaultDocumentation } from "./DefaultDoc.js";
33
34
 
@@ -53,8 +54,10 @@ const NavigationListbox: React.FC<NavigationListboxProps> = ({
53
54
  setSelectedModule,
54
55
  }) => (
55
56
  <Listbox
57
+ key={`listbox-${selectedModule}`}
56
58
  aria-label="Navigation"
57
59
  selectionMode="single"
60
+ variant="solid"
58
61
  selectedKeys={selectedModule ? [selectedModule] : []}
59
62
  onSelectionChange={(keys) => {
60
63
  const key = Array.from(keys)[0] as string;
@@ -74,7 +77,7 @@ const NavigationListbox: React.FC<NavigationListboxProps> = ({
74
77
  key={item.id}
75
78
  textValue={item.name}
76
79
  description={item.description}
77
- color={item.color}
80
+ color={"default"}
78
81
  variant="solid"
79
82
  endContent={
80
83
  item.number && (
@@ -83,7 +86,6 @@ const NavigationListbox: React.FC<NavigationListboxProps> = ({
83
86
  </Chip>
84
87
  )
85
88
  }
86
- className={`${selectedModule === item.id ? "bg-default-200/40" : ""}`}
87
89
  startContent={<IconComponent size={18} className="shrink-0" />}
88
90
  >
89
91
  {item.name}
@@ -197,62 +199,78 @@ export function DocPage({ modules = [], defaultContent }: DocPageProps) {
197
199
  name: "Documentation",
198
200
  description: "Accueil",
199
201
  icon: Home,
202
+ color: "default" as const,
200
203
  },
201
204
  {
202
205
  id: "section-welcome",
203
206
  name: "Bienvenue",
204
207
  description: "",
205
208
  icon: Sparkles,
209
+ color: "default" as const,
206
210
  },
207
211
  {
208
212
  id: "section-quickstart",
209
213
  name: "Démarrage rapide",
210
214
  description: "",
211
215
  icon: Rocket,
216
+ color: "default" as const,
212
217
  },
213
218
  {
214
219
  id: "section-architecture",
215
220
  name: "Architecture",
216
221
  description: "",
217
222
  icon: Building2,
223
+ color: "default" as const,
218
224
  },
219
225
  {
220
226
  id: "section-create-module",
221
227
  name: "Créer un module",
222
228
  description: "",
223
229
  icon: Package,
230
+ color: "default" as const,
224
231
  },
225
232
  {
226
233
  id: "section-database",
227
234
  name: "Base de données",
228
235
  description: "",
229
236
  icon: Database,
237
+ color: "default" as const,
230
238
  },
231
239
  {
232
240
  id: "section-storage",
233
241
  name: "Proxy Storage",
234
242
  description: "Gestion des fichiers",
235
243
  icon: HardDrive,
244
+ color: "default" as const,
236
245
  },
237
246
  {
238
247
  id: "section-realtime",
239
248
  name: "Système Realtime",
240
249
  description: "Synchronisation temps réel",
241
- icon: Sparkles,
250
+ icon: RotateCcw,
251
+ color: "default" as const,
242
252
  },
243
253
  {
244
254
  id: "section-ui",
245
255
  name: "Interface utilisateur",
246
256
  description: "",
247
257
  icon: Palette,
258
+ color: "default" as const,
248
259
  },
249
260
  {
250
261
  id: "section-module-docs",
251
262
  name: "Doc des modules",
252
263
  description: "",
253
264
  icon: BookOpen,
265
+ color: "default" as const,
266
+ },
267
+ {
268
+ id: "section-links",
269
+ name: "Liens utiles",
270
+ description: "",
271
+ icon: Link,
272
+ color: "default" as const,
254
273
  },
255
- { id: "section-links", name: "Liens utiles", description: "", icon: Link },
256
274
  ...(modules.length > 0
257
275
  ? [
258
276
  {
@@ -261,6 +279,7 @@ export function DocPage({ modules = [], defaultContent }: DocPageProps) {
261
279
  description: "",
262
280
  icon: Blocks,
263
281
  number: modules.length,
282
+ color: "default" as const,
264
283
  },
265
284
  ]
266
285
  : []),
@@ -272,7 +291,7 @@ export function DocPage({ modules = [], defaultContent }: DocPageProps) {
272
291
  name: m.name,
273
292
  description: m.description,
274
293
  icon: Package,
275
- color: "primary",
294
+ color: "primary" as const,
276
295
  })),
277
296
  ];
278
297
 
@@ -313,13 +332,10 @@ export function DocPage({ modules = [], defaultContent }: DocPageProps) {
313
332
  </DrawerContent>
314
333
  </Drawer>
315
334
 
316
- <div className="flex gap-8">
335
+ <div className="flex gap-4">
317
336
  {/* Desktop Navigation sidebar */}
318
- <aside className="hidden lg:block w-64 shrink-0 sticky top-18 self-start">
337
+ <aside className="hidden lg:block w-72 shrink-0 sticky top-18 self-start">
319
338
  <Card>
320
- <CardHeader className="pb-2">
321
- <h2 className="text-xl font-semibold">Navigation</h2>
322
- </CardHeader>
323
339
  <CardBody>
324
340
  <NavigationListbox
325
341
  navigationItems={navigationItems}
@@ -371,7 +387,8 @@ export function DocPage({ modules = [], defaultContent }: DocPageProps) {
371
387
  >
372
388
  <CardBody>
373
389
  <div className="flex items-start justify-between mb-2">
374
- <h3 className="text-lg font-semibold">
390
+ <h3 className="text-lg font-semibold flex flex-inline items-center gap-2">
391
+ <Blocks size={20} className="shrink-0" />
375
392
  {module.name}
376
393
  </h3>
377
394
  <Chip
@@ -177,33 +177,32 @@ BEGIN
177
177
  ), false
178
178
  ) as is_foreign_key,
179
179
  (
180
- SELECT ccu.table_name::text
181
- FROM information_schema.table_constraints tc
182
- JOIN information_schema.key_column_usage kcu
183
- ON tc.constraint_name = kcu.constraint_name
184
- AND tc.table_schema = kcu.table_schema
185
- JOIN information_schema.constraint_column_usage ccu
186
- ON ccu.constraint_name = tc.constraint_name
187
- AND ccu.table_schema = tc.table_schema
188
- WHERE tc.constraint_type = 'FOREIGN KEY'
189
- AND tc.table_schema = 'public'
190
- AND tc.table_name = p_table_name
191
- AND kcu.column_name = c.column_name
180
+ SELECT
181
+ CASE
182
+ WHEN nsp.nspname = 'public' THEN ref_table.relname::text
183
+ ELSE nsp.nspname::text || '.' || ref_table.relname::text
184
+ END
185
+ FROM pg_constraint con
186
+ JOIN pg_attribute att ON att.attrelid = con.conrelid AND att.attnum = ANY(con.conkey)
187
+ JOIN pg_class tbl ON tbl.oid = con.conrelid
188
+ JOIN pg_class ref_table ON ref_table.oid = con.confrelid
189
+ JOIN pg_namespace nsp ON nsp.oid = ref_table.relnamespace
190
+ WHERE con.contype = 'f'
191
+ AND tbl.relnamespace = (SELECT oid FROM pg_namespace WHERE nspname = 'public')
192
+ AND tbl.relname = p_table_name
193
+ AND att.attname = c.column_name
192
194
  LIMIT 1
193
195
  ) as foreign_table,
194
196
  (
195
- SELECT ccu.column_name::text
196
- FROM information_schema.table_constraints tc
197
- JOIN information_schema.key_column_usage kcu
198
- ON tc.constraint_name = kcu.constraint_name
199
- AND tc.table_schema = kcu.table_schema
200
- JOIN information_schema.constraint_column_usage ccu
201
- ON ccu.constraint_name = tc.constraint_name
202
- AND ccu.table_schema = tc.table_schema
203
- WHERE tc.constraint_type = 'FOREIGN KEY'
204
- AND tc.table_schema = 'public'
205
- AND tc.table_name = p_table_name
206
- AND kcu.column_name = c.column_name
197
+ SELECT ref_att.attname::text
198
+ FROM pg_constraint con
199
+ JOIN pg_attribute att ON att.attrelid = con.conrelid AND att.attnum = ANY(con.conkey)
200
+ JOIN pg_class tbl ON tbl.oid = con.conrelid
201
+ JOIN pg_attribute ref_att ON ref_att.attrelid = con.confrelid AND ref_att.attnum = ANY(con.confkey)
202
+ WHERE con.contype = 'f'
203
+ AND tbl.relnamespace = (SELECT oid FROM pg_namespace WHERE nspname = 'public')
204
+ AND tbl.relname = p_table_name
205
+ AND att.attname = c.column_name
207
206
  LIMIT 1
208
207
  ) as foreign_column,
209
208
  pgd.description::text