@elqnt/workflow 2.0.7 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/index.d.mts +74 -0
- package/dist/api/index.d.ts +74 -0
- package/dist/api/index.js +36 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/index.mjs +36 -0
- package/dist/api/index.mjs.map +1 -0
- package/dist/chunk-F5G2ALFS.js +391 -0
- package/dist/chunk-F5G2ALFS.js.map +1 -0
- package/dist/chunk-JES2EBNO.js +105 -0
- package/dist/chunk-JES2EBNO.js.map +1 -0
- package/dist/chunk-TZA3EPTC.mjs +391 -0
- package/dist/chunk-TZA3EPTC.mjs.map +1 -0
- package/dist/chunk-UE4ZBFLG.mjs +105 -0
- package/dist/chunk-UE4ZBFLG.mjs.map +1 -0
- package/dist/hooks/index.d.mts +63 -0
- package/dist/hooks/index.d.ts +63 -0
- package/dist/hooks/index.js +14 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/index.mjs +14 -0
- package/dist/hooks/index.mjs.map +1 -0
- package/dist/index.d.mts +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +41 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +40 -0
- package/dist/index.mjs.map +1 -1
- package/dist/models/index.d.mts +56 -1
- package/dist/models/index.d.ts +56 -1
- package/dist/{index-B4xiOlL7.d.mts → workflow-vv0mDt57.d.mts} +1 -54
- package/dist/{index-B4xiOlL7.d.ts → workflow-vv0mDt57.d.ts} +1 -54
- package/package.json +15 -3
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { ApiClientOptions, ApiResponse } from '@elqnt/api-client';
|
|
2
|
+
import { ResponseMetadata } from '@elqnt/types';
|
|
3
|
+
import { L as ListWorkflowDefinitionsResponse, b as WorkflowDefinitionResponse, W as WorkflowDefinition, c as WorkflowInstanceResponse, d as ListWorkflowInstancesResponse } from '../workflow-vv0mDt57.mjs';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Workflow API functions
|
|
7
|
+
*
|
|
8
|
+
* Browser-side API client for workflow operations.
|
|
9
|
+
* Uses @elqnt/api-client for HTTP requests with automatic token management.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
interface WorkflowTemplate {
|
|
13
|
+
id: string;
|
|
14
|
+
name: string;
|
|
15
|
+
title: string;
|
|
16
|
+
description: string;
|
|
17
|
+
category: string;
|
|
18
|
+
variables: Array<{
|
|
19
|
+
name: string;
|
|
20
|
+
type: string;
|
|
21
|
+
required: boolean;
|
|
22
|
+
description?: string;
|
|
23
|
+
}>;
|
|
24
|
+
preview?: string;
|
|
25
|
+
createdAt: string;
|
|
26
|
+
updatedAt: string;
|
|
27
|
+
}
|
|
28
|
+
interface ListWorkflowTemplatesResponse {
|
|
29
|
+
templates: WorkflowTemplate[];
|
|
30
|
+
metadata: ResponseMetadata;
|
|
31
|
+
}
|
|
32
|
+
interface GetWorkflowTemplateResponse {
|
|
33
|
+
template: WorkflowTemplate;
|
|
34
|
+
metadata: ResponseMetadata;
|
|
35
|
+
}
|
|
36
|
+
declare function listWorkflowsApi(options: ApiClientOptions): Promise<ApiResponse<ListWorkflowDefinitionsResponse>>;
|
|
37
|
+
declare function getWorkflowApi(workflowId: string, options: ApiClientOptions): Promise<ApiResponse<WorkflowDefinitionResponse>>;
|
|
38
|
+
declare function createWorkflowApi(workflow: Partial<WorkflowDefinition>, options: ApiClientOptions): Promise<ApiResponse<WorkflowDefinitionResponse & {
|
|
39
|
+
id?: string;
|
|
40
|
+
}>>;
|
|
41
|
+
declare function updateWorkflowApi(workflowId: string, workflow: Partial<WorkflowDefinition>, options: ApiClientOptions): Promise<ApiResponse<WorkflowDefinitionResponse>>;
|
|
42
|
+
declare function deleteWorkflowApi(workflowId: string, options: ApiClientOptions): Promise<ApiResponse<{
|
|
43
|
+
success: boolean;
|
|
44
|
+
metadata: ResponseMetadata;
|
|
45
|
+
}>>;
|
|
46
|
+
declare function createWorkflowInstanceApi(definitionId: string, data: {
|
|
47
|
+
variables?: Record<string, unknown>;
|
|
48
|
+
autoExecute?: boolean;
|
|
49
|
+
}, options: ApiClientOptions): Promise<ApiResponse<WorkflowInstanceResponse & {
|
|
50
|
+
id?: string;
|
|
51
|
+
}>>;
|
|
52
|
+
declare function getWorkflowInstanceApi(instanceId: string, options: ApiClientOptions): Promise<ApiResponse<WorkflowInstanceResponse>>;
|
|
53
|
+
declare function listWorkflowInstancesApi(definitionId: string, options: ApiClientOptions & {
|
|
54
|
+
userId?: string;
|
|
55
|
+
status?: string;
|
|
56
|
+
}): Promise<ApiResponse<ListWorkflowInstancesResponse>>;
|
|
57
|
+
declare function updateWorkflowInstanceStatusApi(instanceId: string, status: string, options: ApiClientOptions): Promise<ApiResponse<WorkflowInstanceResponse>>;
|
|
58
|
+
declare function executeWorkflowNodeApi(instanceId: string, nodeId: string, input: Record<string, unknown>, options: ApiClientOptions): Promise<ApiResponse<{
|
|
59
|
+
success: boolean;
|
|
60
|
+
output?: Record<string, unknown>;
|
|
61
|
+
metadata: ResponseMetadata;
|
|
62
|
+
}>>;
|
|
63
|
+
declare function resumeWorkflowNodeApi(instanceId: string, nodeId: string, result: Record<string, unknown>, options: ApiClientOptions): Promise<ApiResponse<WorkflowInstanceResponse>>;
|
|
64
|
+
declare function retryWorkflowNodeApi(instanceId: string, nodeId: string, options: ApiClientOptions): Promise<ApiResponse<WorkflowInstanceResponse>>;
|
|
65
|
+
declare function listWorkflowTemplatesApi(options: ApiClientOptions & {
|
|
66
|
+
category?: string;
|
|
67
|
+
}): Promise<ApiResponse<ListWorkflowTemplatesResponse>>;
|
|
68
|
+
declare function getWorkflowTemplateApi(templateId: string, options: ApiClientOptions): Promise<ApiResponse<GetWorkflowTemplateResponse>>;
|
|
69
|
+
declare function instantiateWorkflowTemplateApi(templateId: string, params: {
|
|
70
|
+
variables: Record<string, unknown>;
|
|
71
|
+
title?: string;
|
|
72
|
+
}, options: ApiClientOptions): Promise<ApiResponse<WorkflowDefinitionResponse>>;
|
|
73
|
+
|
|
74
|
+
export { type GetWorkflowTemplateResponse, type ListWorkflowTemplatesResponse, type WorkflowTemplate, createWorkflowApi, createWorkflowInstanceApi, deleteWorkflowApi, executeWorkflowNodeApi, getWorkflowApi, getWorkflowInstanceApi, getWorkflowTemplateApi, instantiateWorkflowTemplateApi, listWorkflowInstancesApi, listWorkflowTemplatesApi, listWorkflowsApi, resumeWorkflowNodeApi, retryWorkflowNodeApi, updateWorkflowApi, updateWorkflowInstanceStatusApi };
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { ApiClientOptions, ApiResponse } from '@elqnt/api-client';
|
|
2
|
+
import { ResponseMetadata } from '@elqnt/types';
|
|
3
|
+
import { L as ListWorkflowDefinitionsResponse, b as WorkflowDefinitionResponse, W as WorkflowDefinition, c as WorkflowInstanceResponse, d as ListWorkflowInstancesResponse } from '../workflow-vv0mDt57.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Workflow API functions
|
|
7
|
+
*
|
|
8
|
+
* Browser-side API client for workflow operations.
|
|
9
|
+
* Uses @elqnt/api-client for HTTP requests with automatic token management.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
interface WorkflowTemplate {
|
|
13
|
+
id: string;
|
|
14
|
+
name: string;
|
|
15
|
+
title: string;
|
|
16
|
+
description: string;
|
|
17
|
+
category: string;
|
|
18
|
+
variables: Array<{
|
|
19
|
+
name: string;
|
|
20
|
+
type: string;
|
|
21
|
+
required: boolean;
|
|
22
|
+
description?: string;
|
|
23
|
+
}>;
|
|
24
|
+
preview?: string;
|
|
25
|
+
createdAt: string;
|
|
26
|
+
updatedAt: string;
|
|
27
|
+
}
|
|
28
|
+
interface ListWorkflowTemplatesResponse {
|
|
29
|
+
templates: WorkflowTemplate[];
|
|
30
|
+
metadata: ResponseMetadata;
|
|
31
|
+
}
|
|
32
|
+
interface GetWorkflowTemplateResponse {
|
|
33
|
+
template: WorkflowTemplate;
|
|
34
|
+
metadata: ResponseMetadata;
|
|
35
|
+
}
|
|
36
|
+
declare function listWorkflowsApi(options: ApiClientOptions): Promise<ApiResponse<ListWorkflowDefinitionsResponse>>;
|
|
37
|
+
declare function getWorkflowApi(workflowId: string, options: ApiClientOptions): Promise<ApiResponse<WorkflowDefinitionResponse>>;
|
|
38
|
+
declare function createWorkflowApi(workflow: Partial<WorkflowDefinition>, options: ApiClientOptions): Promise<ApiResponse<WorkflowDefinitionResponse & {
|
|
39
|
+
id?: string;
|
|
40
|
+
}>>;
|
|
41
|
+
declare function updateWorkflowApi(workflowId: string, workflow: Partial<WorkflowDefinition>, options: ApiClientOptions): Promise<ApiResponse<WorkflowDefinitionResponse>>;
|
|
42
|
+
declare function deleteWorkflowApi(workflowId: string, options: ApiClientOptions): Promise<ApiResponse<{
|
|
43
|
+
success: boolean;
|
|
44
|
+
metadata: ResponseMetadata;
|
|
45
|
+
}>>;
|
|
46
|
+
declare function createWorkflowInstanceApi(definitionId: string, data: {
|
|
47
|
+
variables?: Record<string, unknown>;
|
|
48
|
+
autoExecute?: boolean;
|
|
49
|
+
}, options: ApiClientOptions): Promise<ApiResponse<WorkflowInstanceResponse & {
|
|
50
|
+
id?: string;
|
|
51
|
+
}>>;
|
|
52
|
+
declare function getWorkflowInstanceApi(instanceId: string, options: ApiClientOptions): Promise<ApiResponse<WorkflowInstanceResponse>>;
|
|
53
|
+
declare function listWorkflowInstancesApi(definitionId: string, options: ApiClientOptions & {
|
|
54
|
+
userId?: string;
|
|
55
|
+
status?: string;
|
|
56
|
+
}): Promise<ApiResponse<ListWorkflowInstancesResponse>>;
|
|
57
|
+
declare function updateWorkflowInstanceStatusApi(instanceId: string, status: string, options: ApiClientOptions): Promise<ApiResponse<WorkflowInstanceResponse>>;
|
|
58
|
+
declare function executeWorkflowNodeApi(instanceId: string, nodeId: string, input: Record<string, unknown>, options: ApiClientOptions): Promise<ApiResponse<{
|
|
59
|
+
success: boolean;
|
|
60
|
+
output?: Record<string, unknown>;
|
|
61
|
+
metadata: ResponseMetadata;
|
|
62
|
+
}>>;
|
|
63
|
+
declare function resumeWorkflowNodeApi(instanceId: string, nodeId: string, result: Record<string, unknown>, options: ApiClientOptions): Promise<ApiResponse<WorkflowInstanceResponse>>;
|
|
64
|
+
declare function retryWorkflowNodeApi(instanceId: string, nodeId: string, options: ApiClientOptions): Promise<ApiResponse<WorkflowInstanceResponse>>;
|
|
65
|
+
declare function listWorkflowTemplatesApi(options: ApiClientOptions & {
|
|
66
|
+
category?: string;
|
|
67
|
+
}): Promise<ApiResponse<ListWorkflowTemplatesResponse>>;
|
|
68
|
+
declare function getWorkflowTemplateApi(templateId: string, options: ApiClientOptions): Promise<ApiResponse<GetWorkflowTemplateResponse>>;
|
|
69
|
+
declare function instantiateWorkflowTemplateApi(templateId: string, params: {
|
|
70
|
+
variables: Record<string, unknown>;
|
|
71
|
+
title?: string;
|
|
72
|
+
}, options: ApiClientOptions): Promise<ApiResponse<WorkflowDefinitionResponse>>;
|
|
73
|
+
|
|
74
|
+
export { type GetWorkflowTemplateResponse, type ListWorkflowTemplatesResponse, type WorkflowTemplate, createWorkflowApi, createWorkflowInstanceApi, deleteWorkflowApi, executeWorkflowNodeApi, getWorkflowApi, getWorkflowInstanceApi, getWorkflowTemplateApi, instantiateWorkflowTemplateApi, listWorkflowInstancesApi, listWorkflowTemplatesApi, listWorkflowsApi, resumeWorkflowNodeApi, retryWorkflowNodeApi, updateWorkflowApi, updateWorkflowInstanceStatusApi };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
var _chunkJES2EBNOjs = require('../chunk-JES2EBNO.js');
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
exports.createWorkflowApi = _chunkJES2EBNOjs.createWorkflowApi; exports.createWorkflowInstanceApi = _chunkJES2EBNOjs.createWorkflowInstanceApi; exports.deleteWorkflowApi = _chunkJES2EBNOjs.deleteWorkflowApi; exports.executeWorkflowNodeApi = _chunkJES2EBNOjs.executeWorkflowNodeApi; exports.getWorkflowApi = _chunkJES2EBNOjs.getWorkflowApi; exports.getWorkflowInstanceApi = _chunkJES2EBNOjs.getWorkflowInstanceApi; exports.getWorkflowTemplateApi = _chunkJES2EBNOjs.getWorkflowTemplateApi; exports.instantiateWorkflowTemplateApi = _chunkJES2EBNOjs.instantiateWorkflowTemplateApi; exports.listWorkflowInstancesApi = _chunkJES2EBNOjs.listWorkflowInstancesApi; exports.listWorkflowTemplatesApi = _chunkJES2EBNOjs.listWorkflowTemplatesApi; exports.listWorkflowsApi = _chunkJES2EBNOjs.listWorkflowsApi; exports.resumeWorkflowNodeApi = _chunkJES2EBNOjs.resumeWorkflowNodeApi; exports.retryWorkflowNodeApi = _chunkJES2EBNOjs.retryWorkflowNodeApi; exports.updateWorkflowApi = _chunkJES2EBNOjs.updateWorkflowApi; exports.updateWorkflowInstanceStatusApi = _chunkJES2EBNOjs.updateWorkflowInstanceStatusApi;
|
|
36
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/eloquent-packages/eloquent-packages/packages/workflow/dist/api/index.js"],"names":[],"mappings":"AAAA,qFAAY;AACZ;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,uDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,qkCAAC","file":"/home/runner/work/eloquent-packages/eloquent-packages/packages/workflow/dist/api/index.js"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
createWorkflowApi,
|
|
4
|
+
createWorkflowInstanceApi,
|
|
5
|
+
deleteWorkflowApi,
|
|
6
|
+
executeWorkflowNodeApi,
|
|
7
|
+
getWorkflowApi,
|
|
8
|
+
getWorkflowInstanceApi,
|
|
9
|
+
getWorkflowTemplateApi,
|
|
10
|
+
instantiateWorkflowTemplateApi,
|
|
11
|
+
listWorkflowInstancesApi,
|
|
12
|
+
listWorkflowTemplatesApi,
|
|
13
|
+
listWorkflowsApi,
|
|
14
|
+
resumeWorkflowNodeApi,
|
|
15
|
+
retryWorkflowNodeApi,
|
|
16
|
+
updateWorkflowApi,
|
|
17
|
+
updateWorkflowInstanceStatusApi
|
|
18
|
+
} from "../chunk-UE4ZBFLG.mjs";
|
|
19
|
+
export {
|
|
20
|
+
createWorkflowApi,
|
|
21
|
+
createWorkflowInstanceApi,
|
|
22
|
+
deleteWorkflowApi,
|
|
23
|
+
executeWorkflowNodeApi,
|
|
24
|
+
getWorkflowApi,
|
|
25
|
+
getWorkflowInstanceApi,
|
|
26
|
+
getWorkflowTemplateApi,
|
|
27
|
+
instantiateWorkflowTemplateApi,
|
|
28
|
+
listWorkflowInstancesApi,
|
|
29
|
+
listWorkflowTemplatesApi,
|
|
30
|
+
listWorkflowsApi,
|
|
31
|
+
resumeWorkflowNodeApi,
|
|
32
|
+
retryWorkflowNodeApi,
|
|
33
|
+
updateWorkflowApi,
|
|
34
|
+
updateWorkflowInstanceStatusApi
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }"use client";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
var _chunkJES2EBNOjs = require('./chunk-JES2EBNO.js');
|
|
19
|
+
|
|
20
|
+
// hooks/index.ts
|
|
21
|
+
var _react = require('react');
|
|
22
|
+
function useWorkflows(options) {
|
|
23
|
+
const [loading, setLoading] = _react.useState.call(void 0, false);
|
|
24
|
+
const [error, setError] = _react.useState.call(void 0, null);
|
|
25
|
+
const optionsRef = _react.useRef.call(void 0, options);
|
|
26
|
+
_react.useEffect.call(void 0, () => {
|
|
27
|
+
optionsRef.current = options;
|
|
28
|
+
}, [options]);
|
|
29
|
+
const listWorkflows = _react.useCallback.call(void 0, async () => {
|
|
30
|
+
setLoading(true);
|
|
31
|
+
setError(null);
|
|
32
|
+
try {
|
|
33
|
+
const response = await _chunkJES2EBNOjs.listWorkflowsApi.call(void 0, optionsRef.current);
|
|
34
|
+
if (response.error) {
|
|
35
|
+
setError(response.error);
|
|
36
|
+
return [];
|
|
37
|
+
}
|
|
38
|
+
return _optionalChain([response, 'access', _ => _.data, 'optionalAccess', _2 => _2.definitions]) || [];
|
|
39
|
+
} catch (err) {
|
|
40
|
+
const message = err instanceof Error ? err.message : "Failed to load workflows";
|
|
41
|
+
setError(message);
|
|
42
|
+
return [];
|
|
43
|
+
} finally {
|
|
44
|
+
setLoading(false);
|
|
45
|
+
}
|
|
46
|
+
}, []);
|
|
47
|
+
const getWorkflow = _react.useCallback.call(void 0, async (workflowId) => {
|
|
48
|
+
setLoading(true);
|
|
49
|
+
setError(null);
|
|
50
|
+
try {
|
|
51
|
+
const response = await _chunkJES2EBNOjs.getWorkflowApi.call(void 0, workflowId, optionsRef.current);
|
|
52
|
+
if (response.error) {
|
|
53
|
+
setError(response.error);
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
return _optionalChain([response, 'access', _3 => _3.data, 'optionalAccess', _4 => _4.definition]) || null;
|
|
57
|
+
} catch (err) {
|
|
58
|
+
const message = err instanceof Error ? err.message : "Failed to get workflow";
|
|
59
|
+
setError(message);
|
|
60
|
+
return null;
|
|
61
|
+
} finally {
|
|
62
|
+
setLoading(false);
|
|
63
|
+
}
|
|
64
|
+
}, []);
|
|
65
|
+
const createWorkflow = _react.useCallback.call(void 0,
|
|
66
|
+
async (workflow) => {
|
|
67
|
+
setLoading(true);
|
|
68
|
+
setError(null);
|
|
69
|
+
try {
|
|
70
|
+
const response = await _chunkJES2EBNOjs.createWorkflowApi.call(void 0, workflow, optionsRef.current);
|
|
71
|
+
if (response.error) {
|
|
72
|
+
setError(response.error);
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
return _optionalChain([response, 'access', _5 => _5.data, 'optionalAccess', _6 => _6.definition]) || null;
|
|
76
|
+
} catch (err) {
|
|
77
|
+
const message = err instanceof Error ? err.message : "Failed to create workflow";
|
|
78
|
+
setError(message);
|
|
79
|
+
return null;
|
|
80
|
+
} finally {
|
|
81
|
+
setLoading(false);
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
[]
|
|
85
|
+
);
|
|
86
|
+
const updateWorkflow = _react.useCallback.call(void 0,
|
|
87
|
+
async (workflowId, workflow) => {
|
|
88
|
+
setLoading(true);
|
|
89
|
+
setError(null);
|
|
90
|
+
try {
|
|
91
|
+
const response = await _chunkJES2EBNOjs.updateWorkflowApi.call(void 0, workflowId, workflow, optionsRef.current);
|
|
92
|
+
if (response.error) {
|
|
93
|
+
setError(response.error);
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
return _optionalChain([response, 'access', _7 => _7.data, 'optionalAccess', _8 => _8.definition]) || null;
|
|
97
|
+
} catch (err) {
|
|
98
|
+
const message = err instanceof Error ? err.message : "Failed to update workflow";
|
|
99
|
+
setError(message);
|
|
100
|
+
return null;
|
|
101
|
+
} finally {
|
|
102
|
+
setLoading(false);
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
[]
|
|
106
|
+
);
|
|
107
|
+
const deleteWorkflow = _react.useCallback.call(void 0, async (workflowId) => {
|
|
108
|
+
setLoading(true);
|
|
109
|
+
setError(null);
|
|
110
|
+
try {
|
|
111
|
+
const response = await _chunkJES2EBNOjs.deleteWorkflowApi.call(void 0, workflowId, optionsRef.current);
|
|
112
|
+
if (response.error) {
|
|
113
|
+
setError(response.error);
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
return _nullishCoalesce(_optionalChain([response, 'access', _9 => _9.data, 'optionalAccess', _10 => _10.success]), () => ( true));
|
|
117
|
+
} catch (err) {
|
|
118
|
+
const message = err instanceof Error ? err.message : "Failed to delete workflow";
|
|
119
|
+
setError(message);
|
|
120
|
+
return false;
|
|
121
|
+
} finally {
|
|
122
|
+
setLoading(false);
|
|
123
|
+
}
|
|
124
|
+
}, []);
|
|
125
|
+
return _react.useMemo.call(void 0,
|
|
126
|
+
() => ({
|
|
127
|
+
loading,
|
|
128
|
+
error,
|
|
129
|
+
listWorkflows,
|
|
130
|
+
getWorkflow,
|
|
131
|
+
createWorkflow,
|
|
132
|
+
updateWorkflow,
|
|
133
|
+
deleteWorkflow
|
|
134
|
+
}),
|
|
135
|
+
[loading, error, listWorkflows, getWorkflow, createWorkflow, updateWorkflow, deleteWorkflow]
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
function useWorkflowInstances(options) {
|
|
139
|
+
const [loading, setLoading] = _react.useState.call(void 0, false);
|
|
140
|
+
const [error, setError] = _react.useState.call(void 0, null);
|
|
141
|
+
const optionsRef = _react.useRef.call(void 0, options);
|
|
142
|
+
_react.useEffect.call(void 0, () => {
|
|
143
|
+
optionsRef.current = options;
|
|
144
|
+
}, [options]);
|
|
145
|
+
const listInstances = _react.useCallback.call(void 0,
|
|
146
|
+
async (definitionId, filters) => {
|
|
147
|
+
setLoading(true);
|
|
148
|
+
setError(null);
|
|
149
|
+
try {
|
|
150
|
+
const response = await _chunkJES2EBNOjs.listWorkflowInstancesApi.call(void 0, definitionId, {
|
|
151
|
+
...optionsRef.current,
|
|
152
|
+
...filters
|
|
153
|
+
});
|
|
154
|
+
if (response.error) {
|
|
155
|
+
setError(response.error);
|
|
156
|
+
return [];
|
|
157
|
+
}
|
|
158
|
+
return _optionalChain([response, 'access', _11 => _11.data, 'optionalAccess', _12 => _12.instances]) || [];
|
|
159
|
+
} catch (err) {
|
|
160
|
+
const message = err instanceof Error ? err.message : "Failed to list instances";
|
|
161
|
+
setError(message);
|
|
162
|
+
return [];
|
|
163
|
+
} finally {
|
|
164
|
+
setLoading(false);
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
[]
|
|
168
|
+
);
|
|
169
|
+
const getInstance = _react.useCallback.call(void 0, async (instanceId) => {
|
|
170
|
+
setLoading(true);
|
|
171
|
+
setError(null);
|
|
172
|
+
try {
|
|
173
|
+
const response = await _chunkJES2EBNOjs.getWorkflowInstanceApi.call(void 0, instanceId, optionsRef.current);
|
|
174
|
+
if (response.error) {
|
|
175
|
+
setError(response.error);
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
return _optionalChain([response, 'access', _13 => _13.data, 'optionalAccess', _14 => _14.instance]) || null;
|
|
179
|
+
} catch (err) {
|
|
180
|
+
const message = err instanceof Error ? err.message : "Failed to get instance";
|
|
181
|
+
setError(message);
|
|
182
|
+
return null;
|
|
183
|
+
} finally {
|
|
184
|
+
setLoading(false);
|
|
185
|
+
}
|
|
186
|
+
}, []);
|
|
187
|
+
const createInstance = _react.useCallback.call(void 0,
|
|
188
|
+
async (definitionId, data) => {
|
|
189
|
+
setLoading(true);
|
|
190
|
+
setError(null);
|
|
191
|
+
try {
|
|
192
|
+
const response = await _chunkJES2EBNOjs.createWorkflowInstanceApi.call(void 0, definitionId, data || {}, optionsRef.current);
|
|
193
|
+
if (response.error) {
|
|
194
|
+
setError(response.error);
|
|
195
|
+
return null;
|
|
196
|
+
}
|
|
197
|
+
return _optionalChain([response, 'access', _15 => _15.data, 'optionalAccess', _16 => _16.instance]) || null;
|
|
198
|
+
} catch (err) {
|
|
199
|
+
const message = err instanceof Error ? err.message : "Failed to create instance";
|
|
200
|
+
setError(message);
|
|
201
|
+
return null;
|
|
202
|
+
} finally {
|
|
203
|
+
setLoading(false);
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
[]
|
|
207
|
+
);
|
|
208
|
+
const updateStatus = _react.useCallback.call(void 0,
|
|
209
|
+
async (instanceId, status) => {
|
|
210
|
+
setLoading(true);
|
|
211
|
+
setError(null);
|
|
212
|
+
try {
|
|
213
|
+
const response = await _chunkJES2EBNOjs.updateWorkflowInstanceStatusApi.call(void 0, instanceId, status, optionsRef.current);
|
|
214
|
+
if (response.error) {
|
|
215
|
+
setError(response.error);
|
|
216
|
+
return null;
|
|
217
|
+
}
|
|
218
|
+
return _optionalChain([response, 'access', _17 => _17.data, 'optionalAccess', _18 => _18.instance]) || null;
|
|
219
|
+
} catch (err) {
|
|
220
|
+
const message = err instanceof Error ? err.message : "Failed to update status";
|
|
221
|
+
setError(message);
|
|
222
|
+
return null;
|
|
223
|
+
} finally {
|
|
224
|
+
setLoading(false);
|
|
225
|
+
}
|
|
226
|
+
},
|
|
227
|
+
[]
|
|
228
|
+
);
|
|
229
|
+
const executeNode = _react.useCallback.call(void 0,
|
|
230
|
+
async (instanceId, nodeId, input) => {
|
|
231
|
+
setLoading(true);
|
|
232
|
+
setError(null);
|
|
233
|
+
try {
|
|
234
|
+
const response = await _chunkJES2EBNOjs.executeWorkflowNodeApi.call(void 0, instanceId, nodeId, input, optionsRef.current);
|
|
235
|
+
if (response.error) {
|
|
236
|
+
setError(response.error);
|
|
237
|
+
return null;
|
|
238
|
+
}
|
|
239
|
+
return _optionalChain([response, 'access', _19 => _19.data, 'optionalAccess', _20 => _20.output]) || null;
|
|
240
|
+
} catch (err) {
|
|
241
|
+
const message = err instanceof Error ? err.message : "Failed to execute node";
|
|
242
|
+
setError(message);
|
|
243
|
+
return null;
|
|
244
|
+
} finally {
|
|
245
|
+
setLoading(false);
|
|
246
|
+
}
|
|
247
|
+
},
|
|
248
|
+
[]
|
|
249
|
+
);
|
|
250
|
+
const resumeNode = _react.useCallback.call(void 0,
|
|
251
|
+
async (instanceId, nodeId, result) => {
|
|
252
|
+
setLoading(true);
|
|
253
|
+
setError(null);
|
|
254
|
+
try {
|
|
255
|
+
const response = await _chunkJES2EBNOjs.resumeWorkflowNodeApi.call(void 0, instanceId, nodeId, result, optionsRef.current);
|
|
256
|
+
if (response.error) {
|
|
257
|
+
setError(response.error);
|
|
258
|
+
return null;
|
|
259
|
+
}
|
|
260
|
+
return _optionalChain([response, 'access', _21 => _21.data, 'optionalAccess', _22 => _22.instance]) || null;
|
|
261
|
+
} catch (err) {
|
|
262
|
+
const message = err instanceof Error ? err.message : "Failed to resume node";
|
|
263
|
+
setError(message);
|
|
264
|
+
return null;
|
|
265
|
+
} finally {
|
|
266
|
+
setLoading(false);
|
|
267
|
+
}
|
|
268
|
+
},
|
|
269
|
+
[]
|
|
270
|
+
);
|
|
271
|
+
const retryNode = _react.useCallback.call(void 0,
|
|
272
|
+
async (instanceId, nodeId) => {
|
|
273
|
+
setLoading(true);
|
|
274
|
+
setError(null);
|
|
275
|
+
try {
|
|
276
|
+
const response = await _chunkJES2EBNOjs.retryWorkflowNodeApi.call(void 0, instanceId, nodeId, optionsRef.current);
|
|
277
|
+
if (response.error) {
|
|
278
|
+
setError(response.error);
|
|
279
|
+
return null;
|
|
280
|
+
}
|
|
281
|
+
return _optionalChain([response, 'access', _23 => _23.data, 'optionalAccess', _24 => _24.instance]) || null;
|
|
282
|
+
} catch (err) {
|
|
283
|
+
const message = err instanceof Error ? err.message : "Failed to retry node";
|
|
284
|
+
setError(message);
|
|
285
|
+
return null;
|
|
286
|
+
} finally {
|
|
287
|
+
setLoading(false);
|
|
288
|
+
}
|
|
289
|
+
},
|
|
290
|
+
[]
|
|
291
|
+
);
|
|
292
|
+
return _react.useMemo.call(void 0,
|
|
293
|
+
() => ({
|
|
294
|
+
loading,
|
|
295
|
+
error,
|
|
296
|
+
listInstances,
|
|
297
|
+
getInstance,
|
|
298
|
+
createInstance,
|
|
299
|
+
updateStatus,
|
|
300
|
+
executeNode,
|
|
301
|
+
resumeNode,
|
|
302
|
+
retryNode
|
|
303
|
+
}),
|
|
304
|
+
[loading, error, listInstances, getInstance, createInstance, updateStatus, executeNode, resumeNode, retryNode]
|
|
305
|
+
);
|
|
306
|
+
}
|
|
307
|
+
function useWorkflowTemplates(options) {
|
|
308
|
+
const [loading, setLoading] = _react.useState.call(void 0, false);
|
|
309
|
+
const [error, setError] = _react.useState.call(void 0, null);
|
|
310
|
+
const optionsRef = _react.useRef.call(void 0, options);
|
|
311
|
+
_react.useEffect.call(void 0, () => {
|
|
312
|
+
optionsRef.current = options;
|
|
313
|
+
}, [options]);
|
|
314
|
+
const listTemplates = _react.useCallback.call(void 0, async (category) => {
|
|
315
|
+
setLoading(true);
|
|
316
|
+
setError(null);
|
|
317
|
+
try {
|
|
318
|
+
const response = await _chunkJES2EBNOjs.listWorkflowTemplatesApi.call(void 0, {
|
|
319
|
+
...optionsRef.current,
|
|
320
|
+
category
|
|
321
|
+
});
|
|
322
|
+
if (response.error) {
|
|
323
|
+
setError(response.error);
|
|
324
|
+
return [];
|
|
325
|
+
}
|
|
326
|
+
return _optionalChain([response, 'access', _25 => _25.data, 'optionalAccess', _26 => _26.templates]) || [];
|
|
327
|
+
} catch (err) {
|
|
328
|
+
const message = err instanceof Error ? err.message : "Failed to list templates";
|
|
329
|
+
setError(message);
|
|
330
|
+
return [];
|
|
331
|
+
} finally {
|
|
332
|
+
setLoading(false);
|
|
333
|
+
}
|
|
334
|
+
}, []);
|
|
335
|
+
const getTemplate = _react.useCallback.call(void 0, async (templateId) => {
|
|
336
|
+
setLoading(true);
|
|
337
|
+
setError(null);
|
|
338
|
+
try {
|
|
339
|
+
const response = await _chunkJES2EBNOjs.getWorkflowTemplateApi.call(void 0, templateId, optionsRef.current);
|
|
340
|
+
if (response.error) {
|
|
341
|
+
setError(response.error);
|
|
342
|
+
return null;
|
|
343
|
+
}
|
|
344
|
+
return _optionalChain([response, 'access', _27 => _27.data, 'optionalAccess', _28 => _28.template]) || null;
|
|
345
|
+
} catch (err) {
|
|
346
|
+
const message = err instanceof Error ? err.message : "Failed to get template";
|
|
347
|
+
setError(message);
|
|
348
|
+
return null;
|
|
349
|
+
} finally {
|
|
350
|
+
setLoading(false);
|
|
351
|
+
}
|
|
352
|
+
}, []);
|
|
353
|
+
const instantiateTemplate = _react.useCallback.call(void 0,
|
|
354
|
+
async (templateId, params) => {
|
|
355
|
+
setLoading(true);
|
|
356
|
+
setError(null);
|
|
357
|
+
try {
|
|
358
|
+
const response = await _chunkJES2EBNOjs.instantiateWorkflowTemplateApi.call(void 0, templateId, params, optionsRef.current);
|
|
359
|
+
if (response.error) {
|
|
360
|
+
setError(response.error);
|
|
361
|
+
return null;
|
|
362
|
+
}
|
|
363
|
+
return _optionalChain([response, 'access', _29 => _29.data, 'optionalAccess', _30 => _30.definition]) || null;
|
|
364
|
+
} catch (err) {
|
|
365
|
+
const message = err instanceof Error ? err.message : "Failed to instantiate template";
|
|
366
|
+
setError(message);
|
|
367
|
+
return null;
|
|
368
|
+
} finally {
|
|
369
|
+
setLoading(false);
|
|
370
|
+
}
|
|
371
|
+
},
|
|
372
|
+
[]
|
|
373
|
+
);
|
|
374
|
+
return _react.useMemo.call(void 0,
|
|
375
|
+
() => ({
|
|
376
|
+
loading,
|
|
377
|
+
error,
|
|
378
|
+
listTemplates,
|
|
379
|
+
getTemplate,
|
|
380
|
+
instantiateTemplate
|
|
381
|
+
}),
|
|
382
|
+
[loading, error, listTemplates, getTemplate, instantiateTemplate]
|
|
383
|
+
);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
exports.useWorkflows = useWorkflows; exports.useWorkflowInstances = useWorkflowInstances; exports.useWorkflowTemplates = useWorkflowTemplates;
|
|
391
|
+
//# sourceMappingURL=chunk-F5G2ALFS.js.map
|