@@ -48,15 +48,15 @@ export interface DomainRoot {
4848 * @param nested The nested fields to add
4949 * @param tail The tail of parameters in nested selects, required to resolve RPC payloads
5050 */
51- addFields : ( nested : FormanSchemaField [ ] , tail ?: string [ ] ) => void ;
51+ addFields : ( nested : ( FormanSchemaField | string ) [ ] , tail ?: string [ ] ) => void ;
5252}
5353
5454/**
5555 * Buffer of fields to be added to a domain before the root has been identified
5656 */
5757export type FormanDomainBuffer = {
5858 /** Field to add */
59- field : FormanSchemaField ;
59+ field : FormanSchemaField | string ;
6060 /** Tail of parameters in nested selects, required to resolve RPC payloads */
6161 tail ?: string [ ] ;
6262} ;
@@ -92,6 +92,7 @@ const FORMAN_TYPE_MAP: Readonly<Record<string, JSONSchema7['type']>> = {
9292 collection : 'object' ,
9393 dynamicCollection : 'object' ,
9494 text : 'string' ,
95+ editor : 'string' ,
9596 number : 'number' ,
9697 boolean : 'boolean' ,
9798 date : 'string' ,
@@ -228,7 +229,15 @@ function handleCollectionType(field: FormanSchemaField, result: JSONSchema7, con
228229 required : [ ] ,
229230 } ) ;
230231
231- function addField ( subField : FormanSchemaField , tail ?: string [ ] ) {
232+ function addField ( subField : FormanSchemaField | string , tail ?: string [ ] ) {
233+ if ( typeof subField === 'string' ) {
234+ const value = { $ref : appendQueryString ( subField , context . domain , tail || context . tail ) } ;
235+
236+ result . allOf ||= [ ] ;
237+ result . allOf . push ( value ) ;
238+ return ;
239+ }
240+
232241 if ( isVisualType ( subField . type ) ) {
233242 return ;
234243 }
@@ -275,7 +284,7 @@ function handleCollectionType(field: FormanSchemaField, result: JSONSchema7, con
275284 const buffer = context . roots [ domainRoot ] ?. buffer ;
276285
277286 context . roots [ domainRoot ] = {
278- addFields : ( nested : FormanSchemaField [ ] , tail ?: string [ ] ) => {
287+ addFields : ( nested : ( FormanSchemaField | string ) [ ] , tail ?: string [ ] ) => {
279288 nested . forEach ( subField => addField ( subField , tail ) ) ;
280289 } ,
281290 } ;
@@ -483,22 +492,20 @@ function handleSelectType(field: FormanSchemaField, result: JSONSchema7, context
483492 }
484493
485494 if ( nested && domain && domain !== context . domain ) {
486- if ( typeof nested === 'string' || nestedContainsStrings ) {
487- throw new SchemaConversionError ( 'Dynamic nested fields with domain change are not supported.' ) ;
488- }
495+ const normalizedNested = typeof nested === 'string' ? [ nested ] : nested ;
489496
490497 let root = context . roots [ domain ] ;
491498 if ( ! root ) {
492499 const buffer : FormanDomainBuffer [ ] = [ ] ;
493500 root = context . roots [ domain ] = {
494501 buffer,
495- addFields : ( nested : FormanSchemaField [ ] , tail ?: string [ ] ) => {
502+ addFields : ( nested : ( FormanSchemaField | string ) [ ] , tail ?: string [ ] ) => {
496503 buffer . push ( ...nested . map ( field => ( { field, tail } ) ) ) ;
497504 } ,
498505 } ;
499506 }
500507
501- root . addFields ( nested as FormanSchemaField [ ] , [ ...context . tail , field . name ! ] ) ;
508+ root . addFields ( normalizedNested , [ ...context . tail , field . name ! ] ) ;
502509 } else if ( nested ) {
503510 Object . defineProperty ( result , 'x-nested' , {
504511 configurable : true ,
0 commit comments