@@ -54,8 +54,9 @@ export async function loadPocketbaseCollections(connection: Connection | undefin
54
54
if ( ! connection ) throw new Error ( 'Missing connection parameters' ) ;
55
55
const { url, email, password } = connection ;
56
56
const pb = new PocketBase ( url ) ;
57
- await pb . admins . authWithPassword ( email , password ) ;
58
- return pb . collections . getFullList ( ) ;
57
+ pb . collection ( '_superusers' ) . authWithPassword ( email , password ) ;
58
+
59
+ return await pb . collections . getFullList ( ) ;
59
60
}
60
61
61
62
const genericMarkupDirectives = Object . entries ( {
@@ -75,26 +76,36 @@ export function generateMarkup(
75
76
{ direction, algorithm, showSystemAttributes, markRequiredAttributes, showSelectValues } : Settings
76
77
) {
77
78
const entities : Record < string , Entity > = Object . fromEntries (
78
- collections . map ( ( { id, name, schema, $isView } ) => {
79
- let attributes : Attribute [ ] = [
80
- ...( showSystemAttributes
81
- ? $isView
82
- ? viewSystemAttributes
83
- : collectionSystemAttributes
84
- : [ ] )
85
- ] ;
86
- attributes = attributes . concat (
87
- schema . map ( ( { name, type, options, required } ) => ( {
88
- name,
89
- type,
90
- options : options as AttributeOptions ,
91
- required,
92
- isRelation : type === 'relation'
93
- } ) )
94
- ) ;
95
-
96
- return [ id , { id : sanitizeId ( id ) , name, attributes, isView : $isView } ] ;
97
- } )
79
+ collections
80
+ . filter ( ( { system } ) => ! system ) // Filter out system collections
81
+ . map ( ( { id, name, fields, $isView } ) => {
82
+ let attributes : Attribute [ ] = [
83
+ ...( showSystemAttributes
84
+ ? $isView
85
+ ? viewSystemAttributes
86
+ : collectionSystemAttributes
87
+ : [ ] )
88
+ ] ;
89
+ attributes = attributes . concat (
90
+ fields . map ( ( field ) => ( {
91
+ name : field . name ,
92
+ type : field . type ,
93
+ options : {
94
+ min : field . min ,
95
+ max : field . max ,
96
+ minSelect : field . minSelect ,
97
+ maxSelect : field . maxSelect ,
98
+ cascadeDelete : field . cascadeDelete ,
99
+ collectionId : field . collectionId ,
100
+ values : field . values
101
+ } as AttributeOptions ,
102
+ required : field . required ,
103
+ isRelation : field . type === 'relation'
104
+ } ) )
105
+ ) ;
106
+
107
+ return [ id , { id : sanitizeId ( id ) , name, attributes, isView : $isView } ] ;
108
+ } )
98
109
) ;
99
110
100
111
const entityValues = Object . values ( entities ) ;
0 commit comments