@@ -13,18 +13,18 @@ interface ActiveIndex {
1313export class FileWorkflowStore implements WorkflowStore {
1414 async saveWorkflow ( state : WorkflowState ) : Promise < void > {
1515 const file = path . join ( state . artifactRoot , "state.json" ) ;
16- await this . prepareWritableKapiFile ( state . workspace , file ) ;
16+ await this . prepareWritableStateFile ( state . workspace , file ) ;
1717 await fs . writeFile ( file , `${ JSON . stringify ( state , null , 2 ) } \n` , "utf8" ) ;
1818 }
1919
2020 async loadWorkflow ( workspace : string , workflowId : WorkflowState [ "workflowId" ] , slug : string ) : Promise < WorkflowState | undefined > {
2121 const file = this . statePath ( workspace , workflowId , slug ) ;
22- await this . assertKapiAncestorsAreNotSymlinks ( workspace , file ) ;
22+ await this . assertStateAncestorsAreNotSymlinks ( workspace , file ) ;
2323 return this . readJson < WorkflowState > ( file ) ;
2424 }
2525
2626 async loadActive ( workspace : string ) : Promise < WorkflowState | undefined > {
27- await this . assertKapiAncestorsAreNotSymlinks ( workspace , this . activePath ( workspace ) ) ;
27+ await this . assertStateAncestorsAreNotSymlinks ( workspace , this . activePath ( workspace ) ) ;
2828 const active = await this . readJsonOrClearActivePointer < ActiveIndex > ( workspace , this . activePath ( workspace ) ) ;
2929 if ( ! active ) return undefined ;
3030 return this . resolveActivePointer ( workspace , active ) ;
@@ -38,7 +38,7 @@ export class FileWorkflowStore implements WorkflowStore {
3838 updatedAt : state . updatedAt ,
3939 } ;
4040 const file = this . activePath ( state . workspace ) ;
41- await this . prepareWritableKapiFile ( state . workspace , file ) ;
41+ await this . prepareWritableStateFile ( state . workspace , file ) ;
4242 await fs . writeFile ( file , `${ JSON . stringify ( active , null , 2 ) } \n` , "utf8" ) ;
4343 }
4444
@@ -51,13 +51,13 @@ export class FileWorkflowStore implements WorkflowStore {
5151 }
5252
5353 async ensureArtifacts ( state : WorkflowState ) : Promise < void > {
54- await this . assertKapiAncestorsAreNotSymlinks ( state . workspace , path . join ( state . artifactRoot , "state.json" ) ) ;
54+ await this . assertStateAncestorsAreNotSymlinks ( state . workspace , path . join ( state . artifactRoot , "state.json" ) ) ;
5555 await fs . mkdir ( state . artifactRoot , { recursive : true } ) ;
5656 await Promise . all (
5757 state . artifacts . map ( async ( artifact ) => {
5858 this . assertArtifactPathInsideRoot ( state , artifact ) ;
5959 const file = artifact . path ;
60- await this . assertKapiAncestorsAreNotSymlinks ( state . workspace , file ) ;
60+ await this . assertStateAncestorsAreNotSymlinks ( state . workspace , file ) ;
6161 if ( this . isDirectoryArtifact ( state , artifact . name ) ) {
6262 await this . ensureDirectoryArtifact ( state , artifact . name , file ) ;
6363 return ;
@@ -79,20 +79,20 @@ export class FileWorkflowStore implements WorkflowStore {
7979
8080 async readArtifact ( state : WorkflowState , artifactName : string ) : Promise < string | undefined > {
8181 const artifact = this . resolveArtifact ( state , artifactName ) ;
82- await this . assertKapiAncestorsAreNotSymlinks ( state . workspace , artifact . path ) ;
82+ await this . assertStateAncestorsAreNotSymlinks ( state . workspace , artifact . path ) ;
8383 return this . readFileIfExists ( artifact . path ) ;
8484 }
8585
8686 async artifactExists ( state : WorkflowState , artifactName : string ) : Promise < boolean > {
8787 const artifact = this . resolveArtifact ( state , artifactName ) ;
88- await this . assertKapiAncestorsAreNotSymlinks ( state . workspace , artifact . path ) ;
88+ await this . assertStateAncestorsAreNotSymlinks ( state . workspace , artifact . path ) ;
8989 if ( this . isDirectoryArtifact ( state , artifact . name ) ) return this . directoryArtifactExists ( artifact . name , artifact . path ) ;
9090 return this . regularFileExists ( artifact . path ) ;
9191 }
9292
9393 async artifactMetadata ( state : WorkflowState , artifactName : string ) : Promise < { exists : boolean ; isFile : boolean ; isSymlink : boolean ; executable : boolean } > {
9494 const artifact = this . resolveArtifact ( state , artifactName ) ;
95- await this . assertKapiAncestorsAreNotSymlinks ( state . workspace , artifact . path ) ;
95+ await this . assertStateAncestorsAreNotSymlinks ( state . workspace , artifact . path ) ;
9696 const stat = await this . lstatIfExists ( artifact . path ) ;
9797 if ( ! stat ) return { exists : false , isFile : false , isSymlink : false , executable : false } ;
9898 const isSymlink = stat . isSymbolicLink ( ) ;
@@ -113,7 +113,7 @@ export class FileWorkflowStore implements WorkflowStore {
113113 await this . assertArtifactFileIsNotSymlink ( artifactPath ) ;
114114 if ( artifactName !== "specs" ) return ;
115115 const readmePath = path . join ( artifactPath , "README.md" ) ;
116- await this . assertKapiAncestorsAreNotSymlinks ( state . workspace , readmePath ) ;
116+ await this . assertStateAncestorsAreNotSymlinks ( state . workspace , readmePath ) ;
117117 if ( ! ( await this . fileExists ( readmePath ) ) ) {
118118 await fs . writeFile ( readmePath , this . initialSpecsReadmeContent ( state ) , "utf8" ) ;
119119 }
@@ -154,7 +154,7 @@ export class FileWorkflowStore implements WorkflowStore {
154154
155155 private async writableArtifactPath ( state : WorkflowState , artifactName : string ) : Promise < string > {
156156 const artifact = this . resolveArtifact ( state , artifactName ) ;
157- await this . prepareWritableKapiFile ( state . workspace , artifact . path ) ;
157+ await this . prepareWritableStateFile ( state . workspace , artifact . path ) ;
158158 return artifact . path ;
159159 }
160160
@@ -193,7 +193,7 @@ export class FileWorkflowStore implements WorkflowStore {
193193
194194 private async listWorkflowRoot ( workspace : string ) : Promise < WorkflowState [ ] > {
195195 const root = path . join ( workspace , ".ilchul" , "workflows" ) ;
196- await this . assertKapiAncestorsAreNotSymlinks ( workspace , path . join ( root , ".list" ) ) ;
196+ await this . assertStateAncestorsAreNotSymlinks ( workspace , path . join ( root , ".list" ) ) ;
197197 const states : WorkflowState [ ] = [ ] ;
198198 try {
199199 for ( const workflowDir of await fs . readdir ( root , { withFileTypes : true } ) ) {
@@ -227,7 +227,7 @@ export class FileWorkflowStore implements WorkflowStore {
227227 return this . clearActivePointer ( workspace ) ;
228228 }
229229
230- await this . assertKapiAncestorsAreNotSymlinks ( workspace , active . statePath ) ;
230+ await this . assertStateAncestorsAreNotSymlinks ( workspace , active . statePath ) ;
231231 const state = await this . readJsonOrClearActivePointer < WorkflowState > ( workspace , active . statePath ) ;
232232 if ( ! state ) return this . clearActivePointer ( workspace ) ;
233233 if ( ! this . isStateConsistentWithWorkspace ( workspace , state ) ) return this . clearActivePointer ( workspace ) ;
@@ -270,8 +270,8 @@ export class FileWorkflowStore implements WorkflowStore {
270270 return fs . readFile ( file , "utf8" ) ;
271271 }
272272
273- private async prepareWritableKapiFile ( workspace : string , file : string ) : Promise < void > {
274- await this . assertKapiAncestorsAreNotSymlinks ( workspace , file ) ;
273+ private async prepareWritableStateFile ( workspace : string , file : string ) : Promise < void > {
274+ await this . assertStateAncestorsAreNotSymlinks ( workspace , file ) ;
275275 await fs . mkdir ( path . dirname ( file ) , { recursive : true } ) ;
276276 await this . assertArtifactFileIsNotSymlink ( file ) ;
277277 }
@@ -281,7 +281,7 @@ export class FileWorkflowStore implements WorkflowStore {
281281 if ( stat ) this . assertNotSymlink ( file , stat ) ;
282282 }
283283
284- private async assertKapiAncestorsAreNotSymlinks ( workspace : string , file : string ) : Promise < void > {
284+ private async assertStateAncestorsAreNotSymlinks ( workspace : string , file : string ) : Promise < void > {
285285 const workspaceRoot = path . resolve ( workspace ) ;
286286 const resolvedFile = path . resolve ( file ) ;
287287 const relative = path . relative ( workspaceRoot , resolvedFile ) ;
0 commit comments