@@ -488,6 +488,90 @@ describe('apify actor generate-schema-types', () => {
488488 } ) ;
489489 } ) ;
490490
491+ describe ( 'directory path argument' , ( ) => {
492+ it ( 'should discover and generate all schema types from a directory' , async ( ) => {
493+ const projectDir = joinPath ( 'my-actor-project' ) ;
494+ await mkdir ( projectDir , { recursive : true } ) ;
495+
496+ await setupActorConfig ( projectDir , {
497+ datasetSchemaRef : validDatasetSchemaPath ,
498+ outputSchemaRef : validOutputSchemaPath ,
499+ kvsSchemaRef : validKvsSchemaPath ,
500+ } ) ;
501+
502+ await testRunCommand ( ActorGenerateSchemaTypesCommand , {
503+ args_path : projectDir ,
504+ } ) ;
505+
506+ // All schema types should be generated inside the project directory
507+ const outputDir = join ( projectDir , 'src' , '__generated__' , 'actor' ) ;
508+
509+ const inputFile = await readFile ( join ( outputDir , 'input.ts' ) , 'utf-8' ) ;
510+ expect ( inputFile ) . toContain ( 'export interface' ) ;
511+
512+ const datasetFile = await readFile ( join ( outputDir , 'dataset.ts' ) , 'utf-8' ) ;
513+ expect ( datasetFile ) . toContain ( 'export interface' ) ;
514+
515+ const outputFile = await readFile ( join ( outputDir , 'output.ts' ) , 'utf-8' ) ;
516+ expect ( outputFile ) . toContain ( 'export interface' ) ;
517+
518+ const kvsFile = await readFile ( join ( outputDir , 'key-value-store.ts' ) , 'utf-8' ) ;
519+ expect ( kvsFile ) . toContain ( 'export interface' ) ;
520+ } ) ;
521+
522+ it ( 'should discover input schema from default locations in the directory' , async ( ) => {
523+ const projectDir = joinPath ( 'default-locations-project' ) ;
524+ const actorDir = join ( projectDir , '.actor' ) ;
525+ await mkdir ( actorDir , { recursive : true } ) ;
526+
527+ // Place input schema at a default location without actor.json referencing it
528+ const inputSchema = {
529+ title : 'Test' ,
530+ type : 'object' ,
531+ schemaVersion : 1 ,
532+ properties : {
533+ query : { title : 'Query' , description : 'Search query' , type : 'string' , editor : 'textfield' } ,
534+ } ,
535+ } ;
536+
537+ await writeFile ( join ( actorDir , 'INPUT_SCHEMA.json' ) , JSON . stringify ( inputSchema ) ) ;
538+
539+ await testRunCommand ( ActorGenerateSchemaTypesCommand , {
540+ args_path : projectDir ,
541+ } ) ;
542+
543+ const outputDir = join ( projectDir , 'src' , '__generated__' , 'actor' ) ;
544+ const generatedFile = await readFile ( join ( outputDir , 'input.ts' ) , 'utf-8' ) ;
545+ expect ( generatedFile ) . toContain ( 'export interface' ) ;
546+ expect ( generatedFile ) . toContain ( 'query' ) ;
547+ } ) ;
548+
549+ it ( 'should output types inside the provided directory by default' , async ( ) => {
550+ const projectDir = joinPath ( 'output-location-project' ) ;
551+ await setupActorConfig ( projectDir , { } ) ;
552+
553+ await testRunCommand ( ActorGenerateSchemaTypesCommand , {
554+ args_path : projectDir ,
555+ } ) ;
556+
557+ // Output should be inside the project directory, not in cwd
558+ const outputFile = join ( projectDir , 'src' , '__generated__' , 'actor' , 'input.ts' ) ;
559+ const generatedFile = await readFile ( outputFile , 'utf-8' ) ;
560+ expect ( generatedFile ) . toContain ( 'export interface' ) ;
561+ } ) ;
562+
563+ it ( 'should fail with clear error when directory has no schemas' , async ( ) => {
564+ const emptyDir = joinPath ( 'empty-project' ) ;
565+ await mkdir ( emptyDir , { recursive : true } ) ;
566+
567+ await testRunCommand ( ActorGenerateSchemaTypesCommand , {
568+ args_path : emptyDir ,
569+ } ) ;
570+
571+ expect ( lastErrorMessage ( ) ) . include ( 'Input schema has not been found' ) ;
572+ } ) ;
573+ } ) ;
574+
491575 it ( 'should write successful schemas and report error for the failing one' , async ( ) => {
492576 const outputDir = joinPath ( 'partial-fail-output' ) ;
493577
0 commit comments