@@ -9,26 +9,26 @@ import {
99} from "@polywrap/client-config-builder-js" ;
1010
1111export class JobRunner {
12- private jobOutput : Map < string , JobResult > ;
13- private client : CoreClient ;
12+ private _jobOutput : Map < string , JobResult > ;
13+ private _client : CoreClient ;
1414
1515 constructor (
16- private configBuilder : IClientConfigBuilder ,
17- private onExecution ?: ( id : string , JobResult : JobResult ) => MaybeAsync < void >
16+ private _configBuilder : IClientConfigBuilder ,
17+ private _onExecution ?: ( id : string , JobResult : JobResult ) => MaybeAsync < void >
1818 ) {
19- this . jobOutput = new Map ( ) ;
20- this . client = new PolywrapClient ( this . configBuilder . buildCoreConfig ( ) , {
19+ this . _jobOutput = new Map ( ) ;
20+ this . _client = new PolywrapClient ( this . _configBuilder . buildCoreConfig ( ) , {
2121 noDefaults : true ,
2222 } ) ;
2323 }
2424
2525 async run ( jobs : WorkflowJobs , ids : string [ ] ) : Promise < void > {
2626 const running = ids . map ( async ( absJobId ) => {
27- const jobId = this . getJobId ( absJobId ) ;
27+ const jobId = this . _getJobId ( absJobId ) ;
2828
2929 const steps : Step [ ] | undefined = jobs [ jobId ] . steps as Step [ ] ;
3030 if ( steps ) {
31- await this . executeSteps ( absJobId , steps ) ;
31+ await this . _executeSteps ( absJobId , steps ) ;
3232 }
3333
3434 const subJobs : WorkflowJobs | undefined = jobs [ jobId ] . jobs ;
@@ -40,15 +40,15 @@ export class JobRunner {
4040 await Promise . all ( running ) ;
4141 }
4242
43- private getJobId ( absJobId : string ) : string {
43+ private _getJobId ( absJobId : string ) : string {
4444 const dotIdx = absJobId . lastIndexOf ( "." ) ;
4545 if ( dotIdx > - 1 ) {
4646 return absJobId . substring ( dotIdx + 1 ) ;
4747 }
4848 return absJobId ;
4949 }
5050
51- private followAccessors (
51+ private _followAccessors (
5252 jobResult : JobResult ,
5353 accessors : string [ ] ,
5454 referenceId : string ,
@@ -69,7 +69,7 @@ export class JobRunner {
6969 return val ;
7070 }
7171
72- private resolveReference (
72+ private _resolveReference (
7373 absJobId : string ,
7474 stepId : number ,
7575 reference : string
@@ -87,12 +87,12 @@ export class JobRunner {
8787
8888 // get reference job output
8989 const referenceId : string = reference . substring ( 1 , dataOrErrorIdx ) ;
90- if ( ! this . jobOutput . has ( referenceId ) ) {
90+ if ( ! this . _jobOutput . has ( referenceId ) ) {
9191 throw new Error (
9292 `Could not resolve reference id ${ referenceId } for step ${ absJobId } .${ stepId } `
9393 ) ;
9494 }
95- const refJobResult = this . jobOutput . get ( referenceId ) as JobResult ;
95+ const refJobResult = this . _jobOutput . get ( referenceId ) as JobResult ;
9696
9797 // parse and validate accessors
9898 const accessors : string [ ] = reference
@@ -119,7 +119,7 @@ export class JobRunner {
119119 }
120120
121121 // follow accessors through reference output to get requested data
122- return this . followAccessors (
122+ return this . _followAccessors (
123123 refJobResult ,
124124 accessors ,
125125 referenceId ,
@@ -128,51 +128,51 @@ export class JobRunner {
128128 ) ;
129129 }
130130
131- private resolveRecord (
131+ private _resolveRecord (
132132 absJobId : string ,
133133 stepId : number ,
134134 record : Record < string , unknown >
135135 ) : Record < string , unknown > {
136136 const resolved : Record < string , unknown > = { } ;
137137 for ( const [ key , value ] of Object . entries ( record ) ) {
138- resolved [ key ] = this . resolveValue ( absJobId , stepId , value ) ;
138+ resolved [ key ] = this . _resolveValue ( absJobId , stepId , value ) ;
139139 }
140140 return resolved ;
141141 }
142142
143- private resolveArray (
143+ private _resolveArray (
144144 absJobId : string ,
145145 stepId : number ,
146146 array : Array < unknown >
147147 ) : Array < unknown > {
148- return array . map ( ( v ) => this . resolveValue ( absJobId , stepId , v ) ) ;
148+ return array . map ( ( v ) => this . _resolveValue ( absJobId , stepId , v ) ) ;
149149 }
150150
151- private resolveValue (
151+ private _resolveValue (
152152 absJobId : string ,
153153 stepId : number ,
154154 value : unknown
155155 ) : unknown {
156- if ( this . isReference ( value ) ) {
157- return this . resolveReference ( absJobId , stepId , value ) ;
156+ if ( this . _isReference ( value ) ) {
157+ return this . _resolveReference ( absJobId , stepId , value ) ;
158158 } else if ( Array . isArray ( value ) ) {
159- return this . resolveArray ( absJobId , stepId , value ) ;
160- } else if ( this . isRecord ( value ) ) {
161- return this . resolveRecord ( absJobId , stepId , value ) ;
159+ return this . _resolveArray ( absJobId , stepId , value ) ;
160+ } else if ( this . _isRecord ( value ) ) {
161+ return this . _resolveRecord ( absJobId , stepId , value ) ;
162162 } else {
163163 return value ;
164164 }
165165 }
166166
167- private async execStep (
167+ private async _execStep (
168168 absJobId : string ,
169169 stepId : number ,
170170 step : Step
171171 ) : Promise < JobResult > {
172172 let args : Record < string , unknown > | undefined ;
173173 if ( step . args ) {
174174 try {
175- args = this . resolveRecord ( absJobId , stepId , step . args ) ;
175+ args = this . _resolveRecord ( absJobId , stepId , step . args ) ;
176176 } catch ( e ) {
177177 return {
178178 error : e ,
@@ -181,12 +181,12 @@ export class JobRunner {
181181 }
182182 }
183183
184- let finalClient = this . client ;
184+ let finalClient = this . _client ;
185185
186186 if ( step . config ) {
187187 const finalConfig = ( step . config as Partial < CoreClientConfig > ) . resolver
188188 ? ( step . config as CoreClientConfig )
189- : this . configBuilder
189+ : this . _configBuilder
190190 . add ( step . config as Partial < ClientConfig > )
191191 . buildCoreConfig ( ) ;
192192
@@ -206,26 +206,26 @@ export class JobRunner {
206206 }
207207 }
208208
209- private async executeSteps ( absJobId : string , steps : Step [ ] ) {
209+ private async _executeSteps ( absJobId : string , steps : Step [ ] ) {
210210 for ( let i = 0 ; i < steps . length ; i ++ ) {
211211 const step = steps [ i ] ;
212212 const absId = `${ absJobId } .${ i } ` ;
213213
214- const result : JobResult = await this . execStep ( absJobId , i , step ) ;
214+ const result : JobResult = await this . _execStep ( absJobId , i , step ) ;
215215
216- this . jobOutput . set ( absId , result ) ;
216+ this . _jobOutput . set ( absId , result ) ;
217217
218- if ( this . onExecution ) {
219- await this . onExecution ( absId , result ) ;
218+ if ( this . _onExecution ) {
219+ await this . _onExecution ( absId , result ) ;
220220 }
221221 }
222222 }
223223
224- private isReference ( value : unknown ) : value is string {
224+ private _isReference ( value : unknown ) : value is string {
225225 return typeof value === "string" && value . startsWith ( "$" ) ;
226226 }
227227
228- private isRecord ( value : unknown ) : value is Record < string , unknown > {
228+ private _isRecord ( value : unknown ) : value is Record < string , unknown > {
229229 return typeof value === "object" && value !== null ;
230230 }
231231}
0 commit comments