@@ -31,10 +31,10 @@ function getSchemaImportPath(
3131 refName : string ,
3232 context : ContextSpec ,
3333) : string | undefined {
34- if ( context . output . factoryMethods . mode === 'inline-with-schema ' ) {
34+ if ( context . output . factoryMethods ? .mode === 'single ' ) {
3535 return undefined ;
3636 }
37- let outputDir = context . output . factoryMethods . outputDirectory ;
37+ let outputDir = context . output . factoryMethods ? .outputDirectory ;
3838 let schemasPath = getSchemasPath ( context ) ;
3939
4040 if ( context . output . workspace ) {
@@ -128,14 +128,15 @@ export function generateFactory(
128128 name : string ,
129129 context : ContextSpec ,
130130) : { model : string ; imports : GeneratorImport [ ] } | undefined {
131- if ( ! canGenerateSchema ( schema ) ) return undefined ;
131+ if ( ! canGenerateSchema ( schema ) || ! context . output . factoryMethods )
132+ return undefined ;
132133
133134 const { functionNamePrefix, mode } = context . output . factoryMethods ;
134135 const factoryName = `${ functionNamePrefix } ${ pascal ( name ) } ` ;
135136 const imports : GeneratorImport [ ] = [ ] ;
136137 const payload = buildPayload ( schema , context , [ name ] , imports ) ;
137138
138- if ( mode !== 'inline-with-schema ' ) {
139+ if ( mode !== 'single ' ) {
139140 const schemaImportPath = getSchemaImportPath ( name , context ) ;
140141 imports . push ( { name, importPath : schemaImportPath } ) ;
141142 }
@@ -287,10 +288,10 @@ function buildRefPayload(
287288 return `{} as ${ refName } ` ;
288289 }
289290
290- const { functionNamePrefix, mode } = context . output . factoryMethods ;
291+ const { functionNamePrefix, mode } = context . output . factoryMethods ! ;
291292 const refFactoryName = `${ functionNamePrefix } ${ pascal ( refName ) } ` ;
292293
293- if ( mode !== 'combined-separate-file ' ) {
294+ if ( mode !== 'single-split ' ) {
294295 const importPath = resolveImportPath ( mode , refName , context ) ;
295296 imports . push ( { name : refFactoryName , importPath, isConstant : true } ) ;
296297 }
@@ -310,13 +311,13 @@ function resolveImportPath(
310311) : string | undefined {
311312 const baseName = conventionName ( refName , context . output . namingConvention ) ;
312313 switch ( mode ) {
313- case 'separate-file ' : {
314+ case 'split ' : {
314315 return `./${ baseName } .factory` ;
315316 }
316- case 'combined-separate-file ' : {
317+ case 'single-split ' : {
317318 return `./${ conventionName ( 'factoryMethods' , context . output . namingConvention ) } ` ;
318319 }
319- case 'inline-with-schema ' : {
320+ case 'single ' : {
320321 return `./${ baseName } ` ;
321322 }
322323 }
@@ -350,7 +351,7 @@ function buildObjectPayload(
350351 parents : string [ ] ,
351352 imports : GeneratorImport [ ] ,
352353) : string {
353- const { optionalPropertyStrategy } = context . output . factoryMethods ;
354+ const { includeOptionalProperty } = context . output . factoryMethods ! ;
354355 const props = getProperties ( schema ) ;
355356 const requiredProps : string [ ] =
356357 ( schema . required as string [ ] | undefined ) ?? [ ] ;
@@ -360,7 +361,7 @@ function buildObjectPayload(
360361 entries . sort ( ( [ a ] , [ b ] ) => a . localeCompare ( b ) ) ;
361362 }
362363
363- const includeOptional = optionalPropertyStrategy === 'include' ;
364+ const includeOptional = includeOptionalProperty ;
364365 const lines : string [ ] = [ ] ;
365366
366367 for ( const [ key , prop ] of entries ) {
0 commit comments