File tree 3 files changed +46
-0
lines changed
npm-packages/system-udfs/convex
3 files changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ import type * as _system_cli_tables from "../_system/cli/tables.js";
23
23
import type * as _system_frontend_addDocument from "../_system/frontend/addDocument.js" ;
24
24
import type * as _system_frontend_clearTablePage from "../_system/frontend/clearTablePage.js" ;
25
25
import type * as _system_frontend_common from "../_system/frontend/common.js" ;
26
+ import type * as _system_frontend_components from "../_system/frontend/components.js" ;
26
27
import type * as _system_frontend_convexSiteUrl from "../_system/frontend/convexSiteUrl.js" ;
27
28
import type * as _system_frontend_createTable from "../_system/frontend/createTable.js" ;
28
29
import type * as _system_frontend_deleteDocuments from "../_system/frontend/deleteDocuments.js" ;
@@ -76,6 +77,7 @@ declare const fullApi: ApiFromModules<{
76
77
"_system/frontend/addDocument" : typeof _system_frontend_addDocument ;
77
78
"_system/frontend/clearTablePage" : typeof _system_frontend_clearTablePage ;
78
79
"_system/frontend/common" : typeof _system_frontend_common ;
80
+ "_system/frontend/components" : typeof _system_frontend_components ;
79
81
"_system/frontend/convexSiteUrl" : typeof _system_frontend_convexSiteUrl ;
80
82
"_system/frontend/createTable" : typeof _system_frontend_createTable ;
81
83
"_system/frontend/deleteDocuments" : typeof _system_frontend_deleteDocuments ;
Original file line number Diff line number Diff line change
1
+ import { queryPrivateSystem } from "../secretSystemTables" ;
2
+ import { Doc , Id } from "../../_generated/dataModel" ;
3
+
4
+ export const list = queryPrivateSystem ( {
5
+ args : { } ,
6
+ handler : async function ( { db } ) {
7
+ const componentDocs = await db . query ( "_components" ) . collect ( ) ;
8
+ const idToDoc = new Map < Id < "_components" > , Doc < "_components" > > (
9
+ componentDocs . map ( ( doc ) => [ doc . _id , doc ] ) ,
10
+ ) ;
11
+ const idToPath = new Map < string , string > ( ) ;
12
+ function computeIdToPath ( doc : Doc < "_components" > ) : string {
13
+ if ( idToPath . has ( doc . _id ) ) {
14
+ return idToPath . get ( doc . _id ) ! ;
15
+ }
16
+ let path = "" ;
17
+ if ( ! doc . parent ) {
18
+ // Root component
19
+ path = "" ;
20
+ } else {
21
+ const parentPath = computeIdToPath ( idToDoc . get ( doc . parent ) ! ) ;
22
+ if ( parentPath . length === 0 ) {
23
+ path = doc . name ! ;
24
+ } else {
25
+ path = `${ parentPath } /${ doc . name ! } ` ;
26
+ }
27
+ }
28
+ idToPath . set ( doc . _id , path ) ;
29
+ return path ;
30
+ }
31
+ return componentDocs . map ( ( doc ) => ( {
32
+ id : doc . _id ,
33
+ name : doc . name ,
34
+ path : computeIdToPath ( doc ) ,
35
+ args : Object . fromEntries ( doc . args ?? [ ] ) ,
36
+ } ) ) ;
37
+ } ,
38
+ } ) ;
Original file line number Diff line number Diff line change @@ -245,6 +245,12 @@ export default defineSchema({
245
245
v . literal ( "hidden" ) ,
246
246
) ,
247
247
} ) ,
248
+ _components : defineTable ( {
249
+ definitionId : v . id ( "_component_definitions" ) ,
250
+ parent : v . union ( v . id ( "_components" ) , v . null ( ) ) ,
251
+ name : v . union ( v . string ( ) , v . null ( ) ) ,
252
+ args : v . union ( v . array ( v . any ( ) ) , v . null ( ) ) ,
253
+ } ) ,
248
254
_modules : defineTable ( {
249
255
path : v . string ( ) ,
250
256
latestVersion : v . int64 ( ) ,
You can’t perform that action at this time.
0 commit comments