@amaster.ai/client 1.1.3 → 1.1.4

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/types/bpm.d.ts CHANGED
@@ -338,7 +338,7 @@ export interface HistoryTask {
338
338
  * @example
339
339
  * Complete BPM flow:
340
340
  * ```typescript
341
- * const client = createClient({ baseURL: 'https://api.amaster.ai' });
341
+ * const client = createClient();
342
342
  *
343
343
  * // 1. Start a process
344
344
  * const process = await client.bpm.startProcess('approval', {
@@ -534,7 +534,7 @@ export interface BpmClientAPI {
534
534
  *
535
535
  * @example
536
536
  * const result = await client.bpm.getTask('task-123');
537
- * if (result.success) {
537
+ * if (result.data) {
538
538
  * console.log('Task:', result.data.name);
539
539
  * }
540
540
  *
@@ -640,12 +640,137 @@ export interface BpmClientAPI {
640
640
  params?: HistoryProcessInstanceQueryParams
641
641
  ): Promise<ClientResult<{ count: number }>>;
642
642
 
643
+ /**
644
+ * Get a single historical process instance by ID
645
+ */
646
+ getHistoryProcessInstance(
647
+ processInstanceId: string
648
+ ): Promise<ClientResult<HistoryProcessInstance>>;
649
+
650
+ /**
651
+ * Query process variables by process instance
652
+ */
653
+ getProcessVariables(params: {
654
+ processInstanceId: string;
655
+ variableName?: string;
656
+ }): Promise<ClientResult<ProcessVariable[]>>;
657
+
658
+ /**
659
+ * Get process definition list
660
+ */
661
+ getProcessDefinitions(
662
+ params?: ProcessDefinitionQueryParams
663
+ ): Promise<ClientResult<ProcessDefinitionFull[]>>;
664
+
665
+ /**
666
+ * Get BPMN XML for a process definition key
667
+ */
668
+ getProcessXml(processKey: string): Promise<ClientResult<ProcessXmlResponse>>;
669
+
670
+ /**
671
+ * Get the runtime activity instance tree for a process instance
672
+ */
673
+ getActivityInstanceTree(
674
+ processInstanceId: string
675
+ ): Promise<ClientResult<ActivityInstanceTree>>;
676
+
677
+ /**
678
+ * Get runtime variables for a process instance
679
+ */
680
+ getRuntimeVariables(
681
+ processInstanceId: string
682
+ ): Promise<ClientResult<Record<string, { value: CamundaVariableValue; type: string }>>>;
683
+
684
+ /**
685
+ * Delegate a task to another user
686
+ */
687
+ delegateTask(taskId: string, userId: string): Promise<ClientResult<null>>;
688
+
689
+ /**
690
+ * Get task form metadata
691
+ */
692
+ getTaskForm(taskId: string): Promise<ClientResult<TaskFormData>>;
693
+
694
+ /**
695
+ * Get rendered task form HTML
696
+ */
697
+ getTaskRenderedForm(taskId: string): Promise<ClientResult<string>>;
698
+
643
699
  /**
644
700
  * Get deployed Camunda form definition for a task
645
701
  */
646
702
  getTaskDeployedForm(
647
703
  taskId: string
648
704
  ): Promise<ClientResult<CamundaFormDefinition>>;
705
+
706
+ /**
707
+ * Get start form metadata
708
+ */
709
+ getStartFormInfo(processKey: string): Promise<ClientResult<StartFormInfo>>;
710
+
711
+ /**
712
+ * Get start form variables
713
+ */
714
+ getStartFormVariables(processKey: string): Promise<ClientResult<TaskFormVariables>>;
715
+
716
+ /**
717
+ * Get deployed start form definition
718
+ */
719
+ getDeployedStartForm(processKey: string): Promise<ClientResult<CamundaFormDefinition>>;
720
+
721
+ /**
722
+ * Query historical activity instances
723
+ */
724
+ getHistoryActivityInstances(
725
+ params?: HistoryActivityQueryParams
726
+ ): Promise<ClientResult<HistoryActivityInstance[]>>;
727
+
728
+ /**
729
+ * Query historical variable instances
730
+ */
731
+ getHistoryVariableInstances(
732
+ params?: HistoryVariableQueryParams
733
+ ): Promise<ClientResult<HistoryVariableInstance[]>>;
734
+
735
+ /**
736
+ * Query user operation logs
737
+ */
738
+ getUserOperationLogs(
739
+ params?: UserOperationLogQueryParams
740
+ ): Promise<ClientResult<UserOperationLog[]>>;
741
+
742
+ /**
743
+ * Delete a historical process instance
744
+ */
745
+ deleteHistoryProcessInstance(processInstanceId: string): Promise<ClientResult<null>>;
746
+
747
+ /**
748
+ * Suspend a running process instance
749
+ */
750
+ suspendProcessInstance(processInstanceId: string): Promise<ClientResult<null>>;
751
+
752
+ /**
753
+ * Activate a suspended process instance
754
+ */
755
+ activateProcessInstance(processInstanceId: string): Promise<ClientResult<null>>;
756
+
757
+ /**
758
+ * Modify a process instance for jump/cancel/start operations
759
+ */
760
+ modifyProcessInstance(
761
+ processInstanceId: string,
762
+ modification: ProcessInstanceModification
763
+ ): Promise<ClientResult<null>>;
764
+
765
+ /**
766
+ * Get available roles in the current tenant
767
+ */
768
+ getRoles(): Promise<ClientResult<Role[]>>;
769
+
770
+ /**
771
+ * Get roles assigned to a user
772
+ */
773
+ getUserRoles(userId: string): Promise<ClientResult<Role[]>>;
649
774
  }
650
775
 
651
776
  /**
@@ -682,8 +807,12 @@ export interface HistoryProcessInstanceQueryParams {
682
807
  startedBy?: string;
683
808
  /** Filter finished/unfinished processes */
684
809
  finished?: boolean;
810
+ /** Filter unfinished processes */
811
+ unfinished?: boolean;
685
812
  /** Filter by process definition key */
686
813
  processDefinitionKey?: string;
814
+ /** Access scope: strict "my initiated" view */
815
+ scope?: "initiated";
687
816
  /** Sort field */
688
817
  sortBy?: string;
689
818
  /** Sort order */
@@ -706,6 +835,8 @@ export interface HistoryTaskQueryParams {
706
835
  finished?: boolean;
707
836
  /** Filter unfinished tasks */
708
837
  unfinished?: boolean;
838
+ /** Access scope: strict "my handled" view */
839
+ scope?: "handled";
709
840
  /** Pagination: first result index */
710
841
  firstResult?: number;
711
842
  /** Pagination: max results to return */
@@ -742,3 +873,235 @@ export interface CamundaFormComponent {
742
873
  values?: Array<{ label: string; value: string }>;
743
874
  properties?: Record<string, unknown>;
744
875
  }
876
+
877
+ /**
878
+ * Full process definition information
879
+ */
880
+ export interface ProcessDefinitionFull {
881
+ id: string;
882
+ key: string;
883
+ name: string;
884
+ version: number;
885
+ deploymentId: string;
886
+ resourceName: string;
887
+ category?: string;
888
+ description?: string;
889
+ diagram?: string;
890
+ suspended: boolean;
891
+ tenantId?: string;
892
+ versionTag?: string;
893
+ historyTimeToLive?: number;
894
+ startableInTasklist: boolean;
895
+ }
896
+
897
+ /**
898
+ * Process definition query parameters
899
+ */
900
+ export interface ProcessDefinitionQueryParams {
901
+ key?: string;
902
+ name?: string;
903
+ latestVersion?: boolean;
904
+ active?: boolean;
905
+ suspended?: boolean;
906
+ sortBy?: string;
907
+ sortOrder?: 'asc' | 'desc';
908
+ [key: string]: string | number | boolean | undefined;
909
+ }
910
+
911
+ /**
912
+ * BPMN XML response
913
+ */
914
+ export interface ProcessXmlResponse {
915
+ bpmn20Xml: string;
916
+ processDefinitionId: string;
917
+ }
918
+
919
+ /**
920
+ * Runtime activity instance tree
921
+ */
922
+ export interface ActivityInstanceTree {
923
+ id: string;
924
+ activityId: string;
925
+ activityName: string;
926
+ activityType: string;
927
+ processInstanceId: string;
928
+ processDefinitionId: string;
929
+ childActivityInstances: ActivityInstanceTree[];
930
+ childTransitionInstances: TransitionInstance[];
931
+ executionIds: string[];
932
+ incidentIds: string[];
933
+ }
934
+
935
+ /**
936
+ * Runtime transition instance
937
+ */
938
+ export interface TransitionInstance {
939
+ id: string;
940
+ activityId: string;
941
+ activityName: string;
942
+ activityType: string;
943
+ processInstanceId: string;
944
+ processDefinitionId: string;
945
+ executionId: string;
946
+ incidentIds: string[];
947
+ }
948
+
949
+ /**
950
+ * Historical activity instance
951
+ */
952
+ export interface HistoryActivityInstance {
953
+ id: string;
954
+ activityId: string;
955
+ activityName: string;
956
+ activityType: string;
957
+ processDefinitionId: string;
958
+ processDefinitionKey: string;
959
+ processInstanceId: string;
960
+ executionId: string;
961
+ taskId?: string;
962
+ assignee?: string;
963
+ calledProcessInstanceId?: string;
964
+ calledCaseInstanceId?: string;
965
+ startTime: string;
966
+ endTime?: string;
967
+ durationInMillis?: number;
968
+ canceled: boolean;
969
+ completeScope: boolean;
970
+ tenantId?: string;
971
+ removalTime?: string;
972
+ rootProcessInstanceId: string;
973
+ }
974
+
975
+ /**
976
+ * Historical activity query parameters
977
+ */
978
+ export interface HistoryActivityQueryParams {
979
+ processInstanceId?: string;
980
+ activityId?: string;
981
+ activityType?: string;
982
+ finished?: boolean;
983
+ sortBy?: string;
984
+ sortOrder?: 'asc' | 'desc';
985
+ [key: string]: string | number | boolean | undefined;
986
+ }
987
+
988
+ /**
989
+ * Historical variable instance
990
+ */
991
+ export interface HistoryVariableInstance {
992
+ id: string;
993
+ name: string;
994
+ type: string;
995
+ value: CamundaVariableValue;
996
+ valueInfo?: Record<string, unknown>;
997
+ processDefinitionKey: string;
998
+ processDefinitionId: string;
999
+ processInstanceId: string;
1000
+ executionId: string;
1001
+ activityInstanceId?: string;
1002
+ taskId?: string;
1003
+ tenantId?: string;
1004
+ errorMessage?: string;
1005
+ state: string;
1006
+ createTime: string;
1007
+ removalTime?: string;
1008
+ rootProcessInstanceId: string;
1009
+ }
1010
+
1011
+ /**
1012
+ * Historical variable query parameters
1013
+ */
1014
+ export interface HistoryVariableQueryParams {
1015
+ processInstanceId?: string;
1016
+ variableName?: string;
1017
+ deserializeValues?: boolean;
1018
+ [key: string]: string | number | boolean | undefined;
1019
+ }
1020
+
1021
+ /**
1022
+ * Task form metadata
1023
+ */
1024
+ export interface TaskFormData {
1025
+ key?: string;
1026
+ contextPath?: string;
1027
+ camundaFormRef?: {
1028
+ key: string;
1029
+ binding: string;
1030
+ version?: number;
1031
+ };
1032
+ }
1033
+
1034
+ /**
1035
+ * Start form metadata
1036
+ */
1037
+ export interface StartFormInfo {
1038
+ key?: string;
1039
+ contextPath?: string;
1040
+ camundaFormRef?: {
1041
+ key: string;
1042
+ binding: string;
1043
+ version?: number;
1044
+ };
1045
+ }
1046
+
1047
+ /**
1048
+ * User operation log entry
1049
+ */
1050
+ export interface UserOperationLog {
1051
+ id: string;
1052
+ processDefinitionId?: string;
1053
+ processDefinitionKey?: string;
1054
+ processInstanceId?: string;
1055
+ executionId?: string;
1056
+ taskId?: string;
1057
+ userId: string;
1058
+ timestamp: string;
1059
+ operationId: string;
1060
+ operationType: string;
1061
+ entityType: string;
1062
+ property?: string;
1063
+ orgValue?: string;
1064
+ newValue?: string;
1065
+ tenantId?: string;
1066
+ }
1067
+
1068
+ /**
1069
+ * User operation log query parameters
1070
+ */
1071
+ export interface UserOperationLogQueryParams {
1072
+ processInstanceId?: string;
1073
+ taskId?: string;
1074
+ userId?: string;
1075
+ operationType?: string;
1076
+ sortBy?: string;
1077
+ sortOrder?: 'asc' | 'desc';
1078
+ firstResult?: number;
1079
+ maxResults?: number;
1080
+ [key: string]: string | number | boolean | undefined;
1081
+ }
1082
+
1083
+ /**
1084
+ * Process instance modification request
1085
+ */
1086
+ export interface ProcessInstanceModification {
1087
+ instructions: Array<{
1088
+ type: 'cancel' | 'startBeforeActivity' | 'startAfterActivity' | 'startTransition';
1089
+ activityId?: string;
1090
+ transitionId?: string;
1091
+ activityInstanceId?: string;
1092
+ transitionInstanceId?: string;
1093
+ ancestorActivityInstanceId?: string;
1094
+ variables?: Record<string, { value: CamundaVariableValue; type?: string }>;
1095
+ }>;
1096
+ skipCustomListeners?: boolean;
1097
+ skipIoMappings?: boolean;
1098
+ }
1099
+
1100
+ /**
1101
+ * BPM role information
1102
+ */
1103
+ export interface Role {
1104
+ code: string;
1105
+ name: string;
1106
+ description?: string;
1107
+ }
package/types/common.d.ts CHANGED
@@ -1,62 +1,53 @@
1
1
  /**
2
2
  * Error information structure
3
- *
3
+ *
4
4
  * @since 1.1.0
5
5
  */
6
6
  export interface ClientError {
7
- /**
8
- * HTTP status code
9
- */
10
- status: number;
11
-
12
7
  /**
13
8
  * Error message
14
9
  */
15
10
  message: string;
16
-
11
+
12
+ /**
13
+ * HTTP status code
14
+ */
15
+ status?: number;
16
+
17
17
  /**
18
18
  * Application-specific error code (e.g., 'INVALID_TOKEN', 'PERMISSION_DENIED')
19
- *
20
- * @since 1.1.0
21
19
  */
22
20
  code?: string;
23
-
21
+
24
22
  /**
25
23
  * Additional error details (optional)
26
24
  */
27
25
  details?: unknown;
28
-
29
- /**
30
- * Error timestamp (ISO 8601 format)
31
- *
32
- * @since 1.1.0
33
- */
34
- timestamp?: string;
35
26
  }
36
27
 
37
28
  /**
38
29
  * Standard API response wrapper
39
- *
30
+ *
40
31
  * All Amaster API methods return results wrapped in this structure for
41
32
  * consistent error handling and type safety.
42
- *
33
+ *
43
34
  * @template T - The type of the successful response data
44
- *
35
+ *
45
36
  * @example
46
37
  * // Success case
47
38
  * const result = await client.entity.list('default', 'users');
48
- * if (result.success) {
39
+ * if (result.data) {
49
40
  * console.log('Data:', result.data);
50
41
  * }
51
- *
42
+ *
52
43
  * @example
53
44
  * // Error case
54
45
  * const result = await client.auth.login({ email, password });
55
- * if (!result.success) {
46
+ * if (result.error) {
56
47
  * console.error('Error:', result.error.message);
57
48
  * console.error('Code:', result.error.code);
58
49
  * }
59
- *
50
+ *
60
51
  * @since 1.0.0
61
52
  */
62
53
  export interface ClientResult<T> {
@@ -64,25 +55,16 @@ export interface ClientResult<T> {
64
55
  * Response data (null if error occurred)
65
56
  */
66
57
  data: T | null;
67
-
58
+
68
59
  /**
69
60
  * Error information (null if successful)
70
61
  */
71
62
  error: ClientError | null;
72
-
63
+
73
64
  /**
74
65
  * HTTP response status code
75
66
  */
76
67
  status: number;
77
-
78
- /**
79
- * Convenience flag for checking if request was successful
80
- *
81
- * Equivalent to `error === null`
82
- *
83
- * @since 1.1.0
84
- */
85
- success: boolean;
86
68
  }
87
69
 
88
70
  /**
@@ -99,7 +81,7 @@ export interface PaginationParams {
99
81
  * @default 1
100
82
  */
101
83
  page?: number;
102
-
84
+
103
85
  /**
104
86
  * Number of items per page
105
87
  * @default 20
@@ -109,7 +91,7 @@ export interface PaginationParams {
109
91
 
110
92
  /**
111
93
  * Paginated response structure
112
- *
94
+ *
113
95
  * @template T - The type of items in the list
114
96
  */
115
97
  export interface PaginatedResult<T> {
@@ -117,22 +99,22 @@ export interface PaginatedResult<T> {
117
99
  * Array of items for current page
118
100
  */
119
101
  items: T[];
120
-
102
+
121
103
  /**
122
104
  * Total number of items across all pages
123
105
  */
124
106
  total: number;
125
-
107
+
126
108
  /**
127
109
  * Current page number (1-based)
128
110
  */
129
111
  page: number;
130
-
112
+
131
113
  /**
132
114
  * Number of items per page
133
115
  */
134
116
  perPage: number;
135
-
117
+
136
118
  /**
137
119
  * Total number of pages
138
120
  */
package/types/entity.d.ts CHANGED
@@ -241,7 +241,7 @@ export interface EntityClientAPI {
241
241
  * // With type safety
242
242
  * type User = { id: number; name: string; email: string };
243
243
  * const result = await client.entity.list<User>('default', 'users');
244
- * if (result.success) {
244
+ * if (result.data) {
245
245
  * result.data.items.forEach(user => {
246
246
  * console.log(user.name); // Type-safe
247
247
  * });
@@ -266,7 +266,7 @@ export interface EntityClientAPI {
266
266
  *
267
267
  * @example
268
268
  * const result = await client.entity.get('default', 'users', 123);
269
- * if (result.success) {
269
+ * if (result.data) {
270
270
  * console.log('User:', result.data);
271
271
  * }
272
272
  *
@@ -299,7 +299,7 @@ export interface EntityClientAPI {
299
299
  * status: 'active'
300
300
  * });
301
301
  *
302
- * if (result.success) {
302
+ * if (result.data) {
303
303
  * console.log('Created user with ID:', result.data.id);
304
304
  * }
305
305
  *
@@ -327,7 +327,7 @@ export interface EntityClientAPI {
327
327
  * status: 'inactive'
328
328
  * });
329
329
  *
330
- * if (result.success) {
330
+ * if (result.data) {
331
331
  * console.log('Updated:', result.data);
332
332
  * }
333
333
  *
@@ -350,7 +350,7 @@ export interface EntityClientAPI {
350
350
  *
351
351
  * @example
352
352
  * const result = await client.entity.delete('default', 'users', 123);
353
- * if (result.success) {
353
+ * if (!result.error) {
354
354
  * console.log('User deleted');
355
355
  * }
356
356
  *
@@ -373,7 +373,7 @@ export interface EntityClientAPI {
373
373
  *
374
374
  * @example
375
375
  * const result = await client.entity.options('default', 'users', ['id', 'name']);
376
- * if (result.success) {
376
+ * if (result.data) {
377
377
  * result.data.forEach(opt => console.log(opt.name));
378
378
  * }
379
379
  *
@@ -419,7 +419,7 @@ export interface EntityClientAPI {
419
419
  *
420
420
  * @example
421
421
  * const result = await client.entity.bulkDelete('default', 'users', [1, 2, 3]);
422
- * if (result.success) {
422
+ * if (!result.error) {
423
423
  * console.log('3 users deleted');
424
424
  * }
425
425
  *
@@ -28,7 +28,7 @@ export interface FunctionClientAPI {
28
28
  * body: 'Welcome!'
29
29
  * });
30
30
  *
31
- * if (result.success) {
31
+ * if (result.data) {
32
32
  * console.log(result.data.message);
33
33
  * }
34
34
  *