77
88import { Duration , omit } from '@salesforce/kit' ;
99import { Flags } from '@salesforce/sf-plugins-core' ;
10- import { Lifecycle , Messages , SandboxInfo , SandboxEvents , SandboxProcessObject , SfError } from '@salesforce/core' ;
10+ import { Lifecycle , Messages , SandboxInfo , SandboxEvents , SfError } from '@salesforce/core' ;
1111import { Ux } from '@salesforce/sf-plugins-core' ;
1212import { Interfaces } from '@oclif/core' ;
1313import requestFunctions from '../../../shared/sandboxRequest.js' ;
14- import { SandboxCommandBase } from '../../../shared/sandboxCommandBase.js' ;
14+ import { SandboxCommandBase , SandboxCommandResponse } from '../../../shared/sandboxCommandBase.js' ;
1515
1616type SandboxInfoRecord = SandboxInfo & {
1717 attributes : {
@@ -41,7 +41,7 @@ const fields = [
4141Messages . importMessagesDirectoryFromMetaUrl ( import . meta. url ) ;
4242const messages = Messages . loadMessages ( '@salesforce/plugin-org' , 'refresh.sandbox' ) ;
4343
44- export default class RefreshSandbox extends SandboxCommandBase < SandboxProcessObject > {
44+ export default class RefreshSandbox extends SandboxCommandBase < SandboxCommandResponse > {
4545 public static summary = messages . getMessage ( 'summary' ) ;
4646 public static description = messages . getMessage ( 'description' ) ;
4747 public static examples = messages . getMessages ( 'examples' ) ;
@@ -104,7 +104,7 @@ export default class RefreshSandbox extends SandboxCommandBase<SandboxProcessObj
104104
105105 private sbxConfig ! : SandboxInfo ;
106106
107- public async run ( ) : Promise < SandboxProcessObject > {
107+ public async run ( ) : Promise < SandboxCommandResponse > {
108108 this . sandboxRequestConfig = await this . getSandboxRequestConfig ( ) ;
109109 this . flags = ( await this . parse ( RefreshSandbox ) ) . flags ;
110110 this . validateFlags ( ) ;
@@ -121,13 +121,13 @@ export default class RefreshSandbox extends SandboxCommandBase<SandboxProcessObj
121121 ] ;
122122 }
123123
124- private async refreshSandbox ( ) : Promise < SandboxProcessObject > {
125- const prodOrg = this . flags [ 'target-org' ] ;
124+ private async refreshSandbox ( ) : Promise < SandboxCommandResponse > {
125+ this . prodOrg = this . flags [ 'target-org' ] ;
126126
127127 await this . confirmSandboxRefresh ( this . sbxConfig ) ;
128128
129129 const lifecycle = Lifecycle . getInstance ( ) ;
130- this . registerLifecycleListeners ( lifecycle , { isAsync : this . flags [ 'async' ] , prodOrg } ) ;
130+ this . registerLifecycleListeners ( lifecycle , { isAsync : this . flags [ 'async' ] , prodOrg : this . prodOrg } ) ;
131131
132132 // remove uneditable fields before refresh
133133 const updateableSandboxInfo = omit ( this . sbxConfig , uneditableFields ) ;
@@ -139,7 +139,7 @@ export default class RefreshSandbox extends SandboxCommandBase<SandboxProcessObj
139139 this . spinner . start ( 'Sandbox Refresh' ) ;
140140 }
141141
142- const sandboxProcessObject = await prodOrg . refreshSandbox ( updateableSandboxInfo , {
142+ const sandboxProcessObject = await this . prodOrg . refreshSandbox ( updateableSandboxInfo , {
143143 wait : this . flags [ 'wait' ] ,
144144 interval : this . flags [ 'poll-interval' ] ,
145145 async : this . flags [ 'async' ] ,
@@ -157,13 +157,13 @@ export default class RefreshSandbox extends SandboxCommandBase<SandboxProcessObj
157157 if ( this . flags . async ) {
158158 process . exitCode = 68 ;
159159 }
160- return sandboxProcessObject ;
160+ return this . getSandboxCommandResponse ( ) ;
161161 } catch ( err ) {
162162 this . spinner . stop ( ) ;
163163 if ( this . pollingTimeOut && this . latestSandboxProgressObj ) {
164164 void lifecycle . emit ( SandboxEvents . EVENT_ASYNC_RESULT , undefined ) ;
165165 process . exitCode = 68 ;
166- return this . latestSandboxProgressObj ;
166+ return this . getSandboxCommandResponse ( ) ;
167167 } else if (
168168 err instanceof SfError &&
169169 err . name === 'SandboxRefreshNotCompleteError' &&
0 commit comments