Skip to content

Commit c5f1573

Browse files
committed
wip-feat(types): migrate to orchestration cluster api types
1 parent 5415047 commit c5f1573

File tree

2 files changed

+82
-68
lines changed

2 files changed

+82
-68
lines changed

lib/TaskExecution.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ export default class TaskExecution extends EventEmitter {
282282
/**
283283
* Get the process instance key from the response.
284284
*
285-
* @param {CreateProcessInstanceResponse} response
285+
* @param {import('./types').CreateProcessInstanceResult} response
286286
*
287287
* @returns {string|null} The process instance key or null if not found.
288288
*/
@@ -381,7 +381,7 @@ function getScope(variable, elementInstances, processInstance, elementId) {
381381
/**
382382
* Get the process definition key from the deployment response.
383383
*
384-
* @param {import('@camunda8/sdk/dist/c8/lib/C8Dto').DeployResourceResponse} deployResponse
384+
* @param {import('./types').ExtendedDeploymentResponse} deployResponse
385385
* @param {string} processId
386386
*
387387
* @returns {string|null}
@@ -390,7 +390,7 @@ export function getProcessDefinitionKey(deployResponse, processId) {
390390
const { deployments = [] } = deployResponse;
391391

392392
for (const deployment of deployments) {
393-
if ('processDefinition' in deployment) {
393+
if (deployment.processDefinition) {
394394
const { processDefinition } = deployment;
395395

396396
if (processDefinition.processDefinitionId === processId) {

lib/types.ts

Lines changed: 79 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,114 +1,128 @@
11
import type {
2-
CreateProcessInstanceResponse,
3-
DeployResourceResponse,
4-
SearchProcessInstanceResponse,
5-
SearchVariablesResponse,
6-
SearchElementInstancesResponse,
7-
SearchIncidentsResponse
8-
} from '@camunda8/sdk/dist/c8/lib/C8Dto';
2+
CreateProcessInstanceResult,
3+
SearchElementInstancesResponse,
4+
SearchIncidentsResponse,
5+
SearchProcessInstancesResponse,
6+
SearchVariablesResponse,
7+
CamundaClient
8+
} from '@camunda8/orchestration-cluster-api';
9+
10+
declare type ExtendedDeploymentResponse = Awaited<ReturnType<CamundaClient['createDeployment']>>
11+
12+
export type {
13+
CreateProcessInstanceResult,
14+
SearchElementInstancesResponse,
15+
SearchIncidentsResponse,
16+
SearchProcessInstancesResponse,
17+
SearchVariablesResponse,
18+
ExtendedDeploymentResponse
19+
}
20+
921

1022
import type {
1123
ModdleElement
1224
} from "bpmn-js/lib/model/Types";
1325

1426
export type Input = {
15-
[elementId: string]: string;
27+
[elementId: string]: string;
1628
};
1729

1830
export type Output = {
19-
[elementId: string]: ElementOutput
31+
[elementId: string]: ElementOutput
2032
};
2133

2234
export type VARIABLE_SCOPE = 'LOCAL' | 'PROCESS';
2335

2436
export type ElementOutputVariables = {
25-
[id: string]: {
26-
name: string;
27-
value: any;
28-
scope: VARIABLE_SCOPE;
29-
}
37+
[id: string]: {
38+
name: string;
39+
value: any;
40+
scope: VARIABLE_SCOPE;
41+
}
3042
};
3143

3244
export type ElementOutput = {
33-
success: boolean;
34-
variables?: ElementOutputVariables;
35-
error?: TaskExecutionError;
36-
incident?: any;
37-
operateUrl?: string;
38-
[key: string]: any;
45+
success: boolean;
46+
variables?: ElementOutputVariables;
47+
error?: TaskExecutionError;
48+
incident?: any;
49+
operateUrl?: string;
50+
[key: string]: any;
3951
} | undefined;
4052

4153
export type Config = {
42-
input: Input;
43-
output: Output;
54+
input: Input;
55+
output: Output;
4456
};
4557

4658
export type Variable = {
47-
name: string;
48-
type?: string;
49-
info?: string;
50-
isList?: boolean;
51-
entries?: Variable[];
52-
scope?: ModdleElement;
59+
name: string;
60+
type?: string;
61+
info?: string;
62+
isList?: boolean;
63+
entries?: Variable[];
64+
scope?: ModdleElement;
5365
};
5466

5567
export type Variables = Variable[];
5668

5769
export type ApiResponse<T> =
58-
| {
59-
success: true;
60-
response: T;
61-
}
62-
| {
63-
success: false;
64-
error: string;
65-
}
70+
| {
71+
success: true;
72+
response: T;
73+
}
74+
| {
75+
success: false;
76+
error: string;
77+
}
6678

6779
export type TaskExecutionApi = {
68-
deploy: () => Promise<ApiResponse<DeployResourceResponse>>;
69-
startInstance: (processDefinitionKey: string, elementId: string, variables: { [key: string]: any }) => Promise<ApiResponse<CreateProcessInstanceResponse>>;
70-
getProcessInstance: (processInstanceKey: string) => Promise<ApiResponse<SearchProcessInstanceResponse>>;
71-
getProcessInstanceVariables: (processInstanceKey: string) => Promise<ApiResponse<SearchVariablesResponse>>;
72-
getProcessInstanceElementInstances: (processInstanceKey: string) => Promise<ApiResponse<SearchElementInstancesResponse>>;
73-
getProcessInstanceIncident: (processInstanceKey: string) => Promise<ApiResponse<SearchIncidentsResponse>>;
80+
deploy: () => Promise<ApiResponse<ExtendedDeploymentResponse>>;
81+
startInstance: (processDefinitionKey: string, elementId: string, variables: {
82+
[key: string]: any
83+
}) => Promise<ApiResponse<CreateProcessInstanceResult>>;
84+
getProcessInstance: (processInstanceKey: string) => Promise<ApiResponse<SearchProcessInstancesResponse>>;
85+
getProcessInstanceVariables: (processInstanceKey: string) => Promise<ApiResponse<SearchVariablesResponse>>;
86+
getProcessInstanceElementInstances: (processInstanceKey: string) => Promise<ApiResponse<SearchElementInstancesResponse>>;
87+
getProcessInstanceIncident: (processInstanceKey: string) => Promise<ApiResponse<SearchIncidentsResponse>>;
7488
};
7589

7690
export type TaskExecutionStatus =
77-
'idle' |
78-
'deploying' |
79-
'starting-instance' |
80-
'executing';
91+
'idle' |
92+
'deploying' |
93+
'starting-instance' |
94+
'executing';
8195

8296
export type TaskExecutionEvents =
83-
'taskExecution.status.changed' |
84-
'taskExecution.finished' |
85-
'taskExecution.error' |
86-
'taskExecution.interrupted';
97+
'taskExecution.status.changed' |
98+
'taskExecution.finished' |
99+
'taskExecution.error' |
100+
'taskExecution.interrupted';
87101

88102
export type TaskExecutionResult = {
89-
success: boolean;
90-
variables?: ElementOutputVariables;
91-
error?: TaskExecutionError;
92-
incident?: any;
103+
success: boolean;
104+
variables?: ElementOutputVariables;
105+
error?: TaskExecutionError;
106+
incident?: any;
93107
}
94108

95109
export type TaskExecutionError = {
96-
message: string;
97-
response?: any;
110+
message: string;
111+
response?: any;
98112
};
99113

100-
export type { Element, ModdleElement } from 'bpmn-js/lib/model/Types';
114+
export type {Element, ModdleElement} from 'bpmn-js/lib/model/Types';
101115

102116
export type Plugin = {
103-
priority?: number;
104-
render: Function;
105-
type: string;
106-
[key: string]: any;
117+
priority?: number;
118+
render: Function;
119+
type: string;
120+
[key: string]: any;
107121
};
108122

109123
export type PluginContextValue = {
110-
plugins: Plugin[];
111-
registerPlugin: (plugin: Plugin) => void;
112-
unregisterPlugin: (plugin: Plugin) => void;
113-
getPlugins: (pluginPoint: string) => Plugin[];
124+
plugins: Plugin[];
125+
registerPlugin: (plugin: Plugin) => void;
126+
unregisterPlugin: (plugin: Plugin) => void;
127+
getPlugins: (pluginPoint: string) => Plugin[];
114128
};

0 commit comments

Comments
 (0)