File tree Expand file tree Collapse file tree 3 files changed +46
-0
lines changed
npm-packages/system-udfs/convex Expand file tree Collapse file tree 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";
2323import type * as _system_frontend_addDocument from "../_system/frontend/addDocument.js" ;
2424import type * as _system_frontend_clearTablePage from "../_system/frontend/clearTablePage.js" ;
2525import type * as _system_frontend_common from "../_system/frontend/common.js" ;
26+ import type * as _system_frontend_components from "../_system/frontend/components.js" ;
2627import type * as _system_frontend_convexSiteUrl from "../_system/frontend/convexSiteUrl.js" ;
2728import type * as _system_frontend_createTable from "../_system/frontend/createTable.js" ;
2829import type * as _system_frontend_deleteDocuments from "../_system/frontend/deleteDocuments.js" ;
@@ -76,6 +77,7 @@ declare const fullApi: ApiFromModules<{
7677 "_system/frontend/addDocument" : typeof _system_frontend_addDocument ;
7778 "_system/frontend/clearTablePage" : typeof _system_frontend_clearTablePage ;
7879 "_system/frontend/common" : typeof _system_frontend_common ;
80+ "_system/frontend/components" : typeof _system_frontend_components ;
7981 "_system/frontend/convexSiteUrl" : typeof _system_frontend_convexSiteUrl ;
8082 "_system/frontend/createTable" : typeof _system_frontend_createTable ;
8183 "_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({
245245 v . literal ( "hidden" ) ,
246246 ) ,
247247 } ) ,
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+ } ) ,
248254 _modules : defineTable ( {
249255 path : v . string ( ) ,
250256 latestVersion : v . int64 ( ) ,
You can’t perform that action at this time.
0 commit comments