@@ -102,6 +102,26 @@ export function truncateActorReadme(readme: string, limit = ACTOR_README_MAX_LEN
102102 const prunedReadme = lines . filter ( ( line ) => line . startsWith ( '#' ) ) ;
103103 return `${ readmeFirst } \n\nREADME was truncated because it was too long. Remaining headers:\n${ prunedReadme . join ( ', ' ) } ` ;
104104}
105+ /**
106+ * Helps determine the type of items in an array schema property.
107+ * Priority order: explicit type in items > prefill type > default value type > editor type.
108+ */
109+ export function inferArrayItemType ( property : SchemaProperties ) : string | null {
110+ return property . items ?. type
111+ || ( property . prefill && typeof property . prefill )
112+ || ( property . default && typeof property . default )
113+ || ( property . editor && getEditorItemType ( property . editor ) )
114+ || null ;
115+
116+ function getEditorItemType ( editor : string ) : string | null {
117+ const editorTypeMap : Record < string , string > = {
118+ requestListSources : 'object' ,
119+ stringList : 'string' ,
120+ } ;
121+ return editorTypeMap [ editor ] || null ;
122+ }
123+ }
124+
105125/**
106126 * Filters schema properties to include only the necessary fields.
107127 * @param properties
@@ -112,24 +132,9 @@ export function filterSchemaProperties(properties: { [key: string]: SchemaProper
112132 const { title, description, enum : enumValues , type, default : defaultValue , prefill } = property ;
113133 filteredProperties [ key ] = { title, description, enum : enumValues , type, default : defaultValue , prefill } ;
114134 if ( type === 'array' ) {
115- const itemsType : string | null = property . items ?. type
116- || ( property . prefill && typeof property . prefill )
117- || ( property . default && typeof property . default )
118- || ( property . editor && getEditorItemType ( property . editor ) )
119- || null ;
120-
135+ const itemsType = inferArrayItemType ( property ) ;
121136 if ( itemsType ) {
122- filteredProperties [ key ] . items = {
123- type : itemsType ,
124- } ;
125- }
126-
127- function getEditorItemType ( editor : string ) : string | null {
128- const editorTypeMap : Record < string , string > = {
129- requestListSources : 'object' ,
130- stringList : 'string' ,
131- } ;
132- return editorTypeMap [ editor ] || null ;
137+ filteredProperties [ key ] . items = { type : itemsType } ;
133138 }
134139 }
135140 }
0 commit comments