@@ -107,12 +107,40 @@ export function createApi(client) {
107107}
108108
109109// ---------------------------------------------------------------------------
110- // Response-shape helpers — canonical implementations live in lib/TaskExecution.js
110+ // Response-shape helpers (duplicated from lib/TaskExecution.js — kept in sync
111+ // manually to avoid .js/.mjs cross-extension imports)
111112// ---------------------------------------------------------------------------
112113
113- export {
114- getProcessDefinitionKey ,
115- getProcessInstanceKey ,
116- getProcessInstanceState ,
117- hasProcessInstanceIncident
118- } from '../lib/TaskExecution.js' ;
114+ export function getProcessDefinitionKey ( deployResponse , processId ) {
115+ const { deployments = [ ] } = deployResponse ;
116+ for ( const deployment of deployments ) {
117+ if ( 'processDefinition' in deployment ) {
118+ const { processDefinition } = deployment ;
119+ if ( processDefinition . processDefinitionId === processId ) {
120+ return processDefinition . processDefinitionKey ;
121+ }
122+ }
123+ }
124+ return null ;
125+ }
126+
127+ export function getProcessInstanceKey ( response ) {
128+ const { processInstanceKey } = response ;
129+ return processInstanceKey || null ;
130+ }
131+
132+ function getProcessInstance ( response , processInstanceKey ) {
133+ const { items = [ ] } = response ;
134+ if ( ! items . length ) return null ;
135+ return items . find ( item => item . processInstanceKey === processInstanceKey ) || null ;
136+ }
137+
138+ export function getProcessInstanceState ( response , processInstanceKey ) {
139+ const processInstance = getProcessInstance ( response , processInstanceKey ) ;
140+ return processInstance ? processInstance . state : null ;
141+ }
142+
143+ export function hasProcessInstanceIncident ( response , processInstanceKey ) {
144+ const processInstance = getProcessInstance ( response , processInstanceKey ) ;
145+ return processInstance ? ( processInstance . hasIncident || false ) : false ;
146+ }
0 commit comments