2929
3030import fs from 'fs' ;
3131import { animals , uniqueNamesGenerator } from 'unique-names-generator' ;
32+ import { AerieApi } from '../e2e-tests/utilities/api.js' ;
3233import { ConstraintDefinitionType } from '../src/enums/constraint.js' ;
3334import { SchedulingDefinitionType } from '../src/enums/scheduling.js' ;
3435import type { ActivityDirectiveInsertInput } from '../src/types/activity.js' ;
3536import type { SchedulingConditionInsertInput } from '../src/types/scheduling.js' ;
3637import { ResourceType } from '../src/types/simulation.js' ;
3738import { getIntervalFromDoyRange , getUnixEpochTime } from '../src/utilities/time.js' ;
3839import { generateDefaultView } from '../src/utilities/view.js' ;
39- import { AerieApi } from '../e2e-tests/utilities/api.js' ;
4040
4141// Generate unique suffix for this seed run
4242const uniqueSuffix = uniqueNamesGenerator ( { dictionaries : [ animals ] , separator : '-' } ) ;
@@ -189,14 +189,14 @@ const PLANS: PlanConfig[] = [
189189 name : 'Monthly Production' ,
190190 startTime : '2024-001T00:00:00' ,
191191 } ,
192- // {
193- // // Quarter-long mission (10K activities)
194- // activityMix: { BiteBanana: 2500, GrowBanana: 2000, PeelBanana: 2500, PickBanana: 3000 },
195- // description: 'Full quarterly mission with comprehensive operations',
196- // endTime: '2024-091T00:00:00',
197- // name: 'Q1 Mission',
198- // startTime: '2024-001T00:00:00',
199- // },
192+ {
193+ // Quarter-long mission (10K activities)
194+ activityMix : { BiteBanana : 2500 , GrowBanana : 2000 , PeelBanana : 2500 , PickBanana : 3000 } ,
195+ description : 'Full quarterly mission with comprehensive operations' ,
196+ endTime : '2024-091T00:00:00' ,
197+ name : 'Q1 Mission' ,
198+ startTime : '2024-001T00:00:00' ,
199+ } ,
200200] ;
201201
202202// Constraint definitions (EDSL format)
@@ -693,6 +693,9 @@ async function seed() {
693693 . replace ( 'mission_name="GENERIC"' , `mission_name="${ missionName } "` ) ;
694694 const commandDictResult = await api . createDictionary ( commandDictXml ) ;
695695 const commandDictId = commandDictResult . command ?. id ;
696+ if ( commandDictId == null ) {
697+ throw new Error ( 'Command dictionary creation failed: no command ID returned' ) ;
698+ }
696699 console . log ( ` - Created command dictionary (ID: ${ commandDictId } , mission: ${ missionName } )` ) ;
697700
698701 // Read and upload channel dictionary with customized mission name
@@ -724,7 +727,7 @@ async function seed() {
724727 const parcelName = `Seed Parcel (${ uniqueSuffix } )` ;
725728 const parcel = await api . createParcel ( {
726729 channel_dictionary_id : channelDictId ?? null ,
727- command_dictionary_id : commandDictId ! ,
730+ command_dictionary_id : commandDictId ,
728731 name : parcelName ,
729732 sequence_adaptation_id : null , // Adaptations are linked separately
730733 } ) ;
@@ -840,7 +843,7 @@ async function seed() {
840843 // Reusable content
841844 const sequenceContent = `@ID "seed_sequence"\n\nC FSW_CMD_0 "ON" true 0.5\nC FSW_CMD_1 1.0 10 "2024-001T00:00:00" 100 "0000"\n` ;
842845 const textContent = `Seed Workspace Notes\n====================\n\nCreated by seed script. Suffix: ${ uniqueSuffix } \n` ;
843- const jsonContent = ` { seeded_json: ${ uniqueSuffix } }` ;
846+ const jsonContent = JSON . stringify ( { seeded_json : uniqueSuffix } , null , 2 ) ;
844847 const binaryContent = new Uint8Array ( 256 ) . map ( ( ) => Math . floor ( Math . random ( ) * 256 ) ) ;
845848 // Minimal valid JPEG (1x1 pixel)
846849 // prettier-ignore
@@ -870,7 +873,7 @@ async function seed() {
870873 { content : textContent , path : 'seed_notes.txt' } ,
871874 { content : binaryContent , path : 'seed_data.bin' } ,
872875 { content : jpegContent , path : 'seed_image.jpg' } ,
873- { content : jsonContent , path : 'seed_image .json' } ,
876+ { content : jsonContent , path : 'seed_data .json' } ,
874877 { path : 'seed_folder' } , // folder
875878 { content : sequenceContent , path : 'seed_folder/folder_sequence.seq' } ,
876879 { content : binaryContent , path : 'seed_folder/folder_data.bin' } ,
@@ -903,7 +906,7 @@ async function seed() {
903906 let largeWorkspaceItemCount = 0 ;
904907
905908 for ( const project of projects ) {
906- // Create project folder
909+ // Create project folder (must exist before children)
907910 await api . createWorkspaceItem ( largeWorkspaceId , `project_${ project } ` ) ;
908911 largeWorkspaceItemCount ++ ;
909912
@@ -913,30 +916,37 @@ async function seed() {
913916 await api . createWorkspaceItem ( largeWorkspaceId , modulePath ) ;
914917 largeWorkspaceItemCount ++ ;
915918
916- // Create regular files in module
919+ // Create regular files in module in parallel
920+ const filePromises : Promise < void > [ ] = [ ] ;
917921 for ( let f = 1 ; f <= 15 ; f ++ ) {
918922 const ext = fileTypes [ ( f - 1 ) % fileTypes . length ] ;
919923 const filePath = `${ modulePath } /file_${ f . toString ( ) . padStart ( 3 , '0' ) } ${ ext } ` ;
920924 const content = fileMap [ ext ] ;
921- await api . createWorkspaceItem ( largeWorkspaceId , filePath , content ) ;
925+ filePromises . push ( api . createWorkspaceItem ( largeWorkspaceId , filePath , content ) ) ;
922926 largeWorkspaceItemCount ++ ;
923927 }
928+ await Promise . all ( filePromises ) ;
924929
925930 // Add deep nesting for every other module (up to 7 levels deep)
926931 if ( m % 2 === 1 ) {
927932 const depths = [ 'level_1' , 'level_2' , 'level_3' , 'level_4' , 'level_5' ] ;
928933 let currentPath = modulePath ;
929934 for ( const depth of depths ) {
930935 currentPath = `${ currentPath } /${ depth } ` ;
936+ // Create nested folder (must exist before children)
931937 await api . createWorkspaceItem ( largeWorkspaceId , currentPath ) ;
932938 largeWorkspaceItemCount ++ ;
933- // Add a few files at each level
939+ // Create files at this level in parallel
940+ const nestedFilePromises : Promise < void > [ ] = [ ] ;
934941 for ( let f = 1 ; f <= 3 ; f ++ ) {
935942 const ext = fileTypes [ ( f - 1 ) % fileTypes . length ] ;
936943 const content = fileMap [ ext ] ;
937- await api . createWorkspaceItem ( largeWorkspaceId , `${ currentPath } /nested_${ f } ${ ext } ` , content ) ;
944+ nestedFilePromises . push (
945+ api . createWorkspaceItem ( largeWorkspaceId , `${ currentPath } /nested_${ f } ${ ext } ` , content ) ,
946+ ) ;
938947 largeWorkspaceItemCount ++ ;
939948 }
949+ await Promise . all ( nestedFilePromises ) ;
940950 }
941951 }
942952 }
0 commit comments