@kissflow/lowcode-client-sdk 1.0.52 → 1.0.53
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/index.d.ts +202 -153
- package/dist/kf.lowcodeworkersdk.es.js +231 -262
- package/dist/kf.nocodeworkersdk.es.js +761 -0
- package/dist/kfsdk.es.js +295 -246
- package/dist/kfsdk.umd.js +1 -1
- package/dist/lowcode.d.ts +200 -151
- package/dist/lowcode.types.d.ts +74 -136
- package/dist/nocode.d.ts +139 -90
- package/dist/nocode.types.d.ts +8 -9
- package/package.json +1 -1
package/dist/kfsdk.es.js
CHANGED
|
@@ -678,187 +678,6 @@ class DecisionTable extends BaseSDK {
|
|
|
678
678
|
});
|
|
679
679
|
}
|
|
680
680
|
}
|
|
681
|
-
const READ_TIMEOUT_MS$1 = 75e3;
|
|
682
|
-
const EXECUTE_TIMEOUT_MS = 6e4;
|
|
683
|
-
const WATCH_ACK_TIMEOUT_MS$1 = 6e4;
|
|
684
|
-
const WATCH_DEADLINE_MS$1 = 42e4;
|
|
685
|
-
const TERMINAL_STATUSES$1 = ["Completed", "Failed"];
|
|
686
|
-
function sdkError$1(errorCode, error) {
|
|
687
|
-
return { isError: true, error, errorCode };
|
|
688
|
-
}
|
|
689
|
-
function notify$1(callback, value) {
|
|
690
|
-
try {
|
|
691
|
-
callback == null ? void 0 : callback(value);
|
|
692
|
-
} catch (error) {
|
|
693
|
-
console.error(error);
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
const NOT_SENT$1 = sdkError$1("AGENT_REQUEST_NOT_SENT", "The request could not be sent to the host.");
|
|
697
|
-
class Agent extends BaseSDK {
|
|
698
|
-
constructor(agentId) {
|
|
699
|
-
super();
|
|
700
|
-
this.activeWatches = 0;
|
|
701
|
-
this.agentId = agentId;
|
|
702
|
-
this._id = generateId("customagent");
|
|
703
|
-
}
|
|
704
|
-
getContract() {
|
|
705
|
-
return this._postMessageBounded(
|
|
706
|
-
LISTENER_CMDS.CUSTOM_AGENT_GET_CONTRACT,
|
|
707
|
-
{ agentId: this.agentId },
|
|
708
|
-
{
|
|
709
|
-
timeoutMs: READ_TIMEOUT_MS$1,
|
|
710
|
-
timeoutError: sdkError$1("AGENT_HOST_TIMEOUT", "The host did not answer the Agent contract request."),
|
|
711
|
-
sendError: NOT_SENT$1
|
|
712
|
-
}
|
|
713
|
-
).promise;
|
|
714
|
-
}
|
|
715
|
-
execute(options) {
|
|
716
|
-
var _a;
|
|
717
|
-
return this._postMessageBounded(
|
|
718
|
-
LISTENER_CMDS.CUSTOM_AGENT_EXECUTE,
|
|
719
|
-
{ agentId: this.agentId, inputData: (_a = options == null ? void 0 : options.inputData) != null ? _a : {} },
|
|
720
|
-
{
|
|
721
|
-
timeoutMs: EXECUTE_TIMEOUT_MS,
|
|
722
|
-
timeoutError: sdkError$1(
|
|
723
|
-
"AGENT_EXECUTE_OUTCOME_UNKNOWN",
|
|
724
|
-
"The host did not confirm the run; it may still have started."
|
|
725
|
-
),
|
|
726
|
-
sendError: sdkError$1("AGENT_EXECUTE_NOT_SENT", "The run request could not be sent to the host.")
|
|
727
|
-
}
|
|
728
|
-
).promise;
|
|
729
|
-
}
|
|
730
|
-
getExecution(executionId) {
|
|
731
|
-
return this._postMessageBounded(
|
|
732
|
-
LISTENER_CMDS.CUSTOM_AGENT_GET_EXECUTION,
|
|
733
|
-
{ agentId: this.agentId, executionId },
|
|
734
|
-
{
|
|
735
|
-
timeoutMs: READ_TIMEOUT_MS$1,
|
|
736
|
-
timeoutError: sdkError$1("AGENT_HOST_TIMEOUT", "The host did not answer the Agent execution request."),
|
|
737
|
-
sendError: NOT_SENT$1
|
|
738
|
-
}
|
|
739
|
-
).promise;
|
|
740
|
-
}
|
|
741
|
-
onExecutionComplete(executionId, onComplete, onWatchError) {
|
|
742
|
-
const watchId = generateId("agentwatch");
|
|
743
|
-
const eventName = `${EVENT_TYPES.CUSTOM_AGENT_EXECUTION_COMPLETE}:${watchId}`;
|
|
744
|
-
let settled = false;
|
|
745
|
-
let deadline = null;
|
|
746
|
-
let registration = null;
|
|
747
|
-
const end = () => {
|
|
748
|
-
settled = true;
|
|
749
|
-
if (deadline)
|
|
750
|
-
clearTimeout(deadline);
|
|
751
|
-
registration == null ? void 0 : registration.cancel();
|
|
752
|
-
this._removeEventListener(eventName);
|
|
753
|
-
this.activeWatches -= 1;
|
|
754
|
-
if (this.activeWatches === 0)
|
|
755
|
-
Reflect.deleteProperty(globalInstances, this._id);
|
|
756
|
-
};
|
|
757
|
-
const tellHostToStop = () => {
|
|
758
|
-
try {
|
|
759
|
-
this._postMessage(LISTENER_CMDS.CUSTOM_AGENT_STOP_WATCH, { id: this._id, watchId, eventName });
|
|
760
|
-
} catch {
|
|
761
|
-
}
|
|
762
|
-
};
|
|
763
|
-
const fail = (error) => {
|
|
764
|
-
if (settled)
|
|
765
|
-
return;
|
|
766
|
-
end();
|
|
767
|
-
tellHostToStop();
|
|
768
|
-
notify$1(onWatchError, error);
|
|
769
|
-
};
|
|
770
|
-
const listener = (params) => {
|
|
771
|
-
if (settled)
|
|
772
|
-
return;
|
|
773
|
-
if (params == null ? void 0 : params.isError) {
|
|
774
|
-
end();
|
|
775
|
-
notify$1(onWatchError, params);
|
|
776
|
-
return;
|
|
777
|
-
}
|
|
778
|
-
const execution = params;
|
|
779
|
-
if ((execution == null ? void 0 : execution.ExecutionId) !== executionId || TERMINAL_STATUSES$1.indexOf(execution == null ? void 0 : execution.Status) === -1) {
|
|
780
|
-
fail(sdkError$1("AGENT_WATCH_INVALID_EVENT", "The host reported something other than a finished run."));
|
|
781
|
-
return;
|
|
782
|
-
}
|
|
783
|
-
end();
|
|
784
|
-
notify$1(onComplete, execution);
|
|
785
|
-
};
|
|
786
|
-
this.activeWatches += 1;
|
|
787
|
-
globalInstances[this._id] = this;
|
|
788
|
-
this._addEventListener(eventName, listener);
|
|
789
|
-
registration = this._postMessageBounded(
|
|
790
|
-
LISTENER_CMDS.CUSTOM_AGENT_WATCH_EXECUTION,
|
|
791
|
-
{ id: this._id, agentId: this.agentId, executionId, watchId, eventName },
|
|
792
|
-
{
|
|
793
|
-
timeoutMs: WATCH_ACK_TIMEOUT_MS$1,
|
|
794
|
-
timeoutError: sdkError$1("AGENT_HOST_UNSUPPORTED", "The host did not start observing the Agent run."),
|
|
795
|
-
sendError: NOT_SENT$1
|
|
796
|
-
}
|
|
797
|
-
);
|
|
798
|
-
registration.promise.then(
|
|
799
|
-
(acknowledged) => {
|
|
800
|
-
if (settled)
|
|
801
|
-
return;
|
|
802
|
-
if (acknowledged !== true) {
|
|
803
|
-
fail(sdkError$1("AGENT_HOST_UNSUPPORTED", "The host did not start observing the Agent run."));
|
|
804
|
-
return;
|
|
805
|
-
}
|
|
806
|
-
deadline = setTimeout(
|
|
807
|
-
() => fail(sdkError$1("AGENT_OBSERVATION_STOPPED", "Stopped checking the Agent run; read it again later.")),
|
|
808
|
-
WATCH_DEADLINE_MS$1
|
|
809
|
-
);
|
|
810
|
-
},
|
|
811
|
-
(error) => fail(error)
|
|
812
|
-
);
|
|
813
|
-
return () => {
|
|
814
|
-
if (settled)
|
|
815
|
-
return;
|
|
816
|
-
end();
|
|
817
|
-
tellHostToStop();
|
|
818
|
-
};
|
|
819
|
-
}
|
|
820
|
-
}
|
|
821
|
-
const REPORT_FLOW_TYPES = ["Form", "Process", "Case"];
|
|
822
|
-
class Report extends BaseSDK {
|
|
823
|
-
constructor(flowType, flowId, reportId) {
|
|
824
|
-
super();
|
|
825
|
-
this._flowType = flowType;
|
|
826
|
-
this._flowId = flowId;
|
|
827
|
-
this._id = reportId;
|
|
828
|
-
}
|
|
829
|
-
getData(options) {
|
|
830
|
-
return this._send(LISTENER_CMDS.REPORT_GET_DATA, {
|
|
831
|
-
pageNumber: (options == null ? void 0 : options.pageNumber) || 1,
|
|
832
|
-
pageSize: (options == null ? void 0 : options.pageSize) || 50,
|
|
833
|
-
payload: (options == null ? void 0 : options.payload) || {}
|
|
834
|
-
});
|
|
835
|
-
}
|
|
836
|
-
getCount(options) {
|
|
837
|
-
return this._send(LISTENER_CMDS.REPORT_GET_COUNT, { payload: (options == null ? void 0 : options.payload) || {} });
|
|
838
|
-
}
|
|
839
|
-
getFields() {
|
|
840
|
-
return this._send(LISTENER_CMDS.REPORT_GET_FIELDS, {});
|
|
841
|
-
}
|
|
842
|
-
_send(command, args) {
|
|
843
|
-
const missing = requireFieldsAsync([
|
|
844
|
-
{ value: this._flowId, name: "flowId" },
|
|
845
|
-
{ value: this._id, name: "reportId" }
|
|
846
|
-
]);
|
|
847
|
-
if (missing)
|
|
848
|
-
return missing;
|
|
849
|
-
if (REPORT_FLOW_TYPES.indexOf(this._flowType) === -1) {
|
|
850
|
-
return Promise.reject({
|
|
851
|
-
message: `flowType must be one of ${REPORT_FLOW_TYPES.join(", ")}`
|
|
852
|
-
});
|
|
853
|
-
}
|
|
854
|
-
return this._postMessageAsync(command, {
|
|
855
|
-
flowType: this._flowType,
|
|
856
|
-
flowId: this._flowId,
|
|
857
|
-
reportId: this._id,
|
|
858
|
-
...args
|
|
859
|
-
});
|
|
860
|
-
}
|
|
861
|
-
}
|
|
862
681
|
class Form extends BaseSDK {
|
|
863
682
|
constructor(storeId, flowId, instanceId, activityInstanceId) {
|
|
864
683
|
super();
|
|
@@ -888,6 +707,18 @@ class Form extends BaseSDK {
|
|
|
888
707
|
data: args
|
|
889
708
|
});
|
|
890
709
|
}
|
|
710
|
+
getTable(tableId) {
|
|
711
|
+
return new Table(
|
|
712
|
+
this.storeId,
|
|
713
|
+
this.flowId,
|
|
714
|
+
this.instanceId,
|
|
715
|
+
tableId,
|
|
716
|
+
this.activityInstanceId,
|
|
717
|
+
this
|
|
718
|
+
);
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
class CustomComponentForm extends Form {
|
|
891
722
|
getValidationErrors() {
|
|
892
723
|
return this._postMessageAsync(
|
|
893
724
|
LISTENER_CMDS.GET_FORM_VALIDATION_ERRORS,
|
|
@@ -909,24 +740,16 @@ class Form extends BaseSDK {
|
|
|
909
740
|
instanceId: this.instanceId
|
|
910
741
|
});
|
|
911
742
|
}
|
|
912
|
-
getTable(tableId) {
|
|
913
|
-
return new Table(
|
|
914
|
-
this.storeId,
|
|
915
|
-
this.flowId,
|
|
916
|
-
this.instanceId,
|
|
917
|
-
tableId,
|
|
918
|
-
this.activityInstanceId
|
|
919
|
-
);
|
|
920
|
-
}
|
|
921
743
|
}
|
|
922
744
|
class Table extends BaseSDK {
|
|
923
|
-
constructor(storeId, flowId, instanceId, tableId, activityInstanceId) {
|
|
745
|
+
constructor(storeId, flowId, instanceId, tableId, activityInstanceId, parent) {
|
|
924
746
|
super();
|
|
925
747
|
this.tableId = tableId;
|
|
926
748
|
this.storeId = storeId;
|
|
927
749
|
this.flowId = flowId;
|
|
928
750
|
this.instanceId = instanceId;
|
|
929
751
|
this.activityInstanceId = activityInstanceId;
|
|
752
|
+
this.parent = parent;
|
|
930
753
|
}
|
|
931
754
|
toJSON() {
|
|
932
755
|
return this._postMessageAsync(LISTENER_CMDS.TO_JSON, {
|
|
@@ -959,7 +782,8 @@ class Table extends BaseSDK {
|
|
|
959
782
|
this.instanceId,
|
|
960
783
|
this.tableId,
|
|
961
784
|
row.id,
|
|
962
|
-
this.activityInstanceId
|
|
785
|
+
this.activityInstanceId,
|
|
786
|
+
this.parent
|
|
963
787
|
)
|
|
964
788
|
);
|
|
965
789
|
}
|
|
@@ -972,7 +796,8 @@ class Table extends BaseSDK {
|
|
|
972
796
|
this.instanceId,
|
|
973
797
|
this.tableId,
|
|
974
798
|
rowId,
|
|
975
|
-
this.activityInstanceId
|
|
799
|
+
this.activityInstanceId,
|
|
800
|
+
this.parent
|
|
976
801
|
);
|
|
977
802
|
}
|
|
978
803
|
addRow(rowObject) {
|
|
@@ -1009,7 +834,7 @@ class Table extends BaseSDK {
|
|
|
1009
834
|
}
|
|
1010
835
|
}
|
|
1011
836
|
class TableForm extends BaseSDK {
|
|
1012
|
-
constructor(storeId, flowId, instanceId, tableId, rowId, activityInstanceId) {
|
|
837
|
+
constructor(storeId, flowId, instanceId, tableId, rowId, activityInstanceId, parent) {
|
|
1013
838
|
super();
|
|
1014
839
|
this.storeId = storeId;
|
|
1015
840
|
this.flowId = flowId;
|
|
@@ -1018,8 +843,11 @@ class TableForm extends BaseSDK {
|
|
|
1018
843
|
this.tableId = tableId;
|
|
1019
844
|
this.rowId = rowId;
|
|
1020
845
|
this.activityInstanceId = activityInstanceId;
|
|
846
|
+
this.parent = parent;
|
|
1021
847
|
}
|
|
1022
848
|
getParent() {
|
|
849
|
+
if (this.parent)
|
|
850
|
+
return this.parent;
|
|
1023
851
|
return new Form(
|
|
1024
852
|
this.storeId,
|
|
1025
853
|
this.flowId,
|
|
@@ -1146,32 +974,43 @@ class Dataform extends BaseSDK {
|
|
|
1146
974
|
viewId: (options == null ? void 0 : options.viewId) || ""
|
|
1147
975
|
});
|
|
1148
976
|
}
|
|
977
|
+
getFieldOptions(options) {
|
|
978
|
+
const error = requireFieldsAsync([
|
|
979
|
+
{ value: options == null ? void 0 : options.instanceId, name: "instanceId" },
|
|
980
|
+
{ value: options == null ? void 0 : options.fieldId, name: "fieldId" }
|
|
981
|
+
]);
|
|
982
|
+
if (error)
|
|
983
|
+
return error;
|
|
984
|
+
return this._postMessageAsync(
|
|
985
|
+
LISTENER_CMDS.DATAFORM_GET_FIELD_OPTIONS,
|
|
986
|
+
{
|
|
987
|
+
flowId: this._id,
|
|
988
|
+
instanceId: options.instanceId,
|
|
989
|
+
fieldId: options.fieldId,
|
|
990
|
+
fieldType: options.fieldType,
|
|
991
|
+
tableId: options.tableId,
|
|
992
|
+
tableRowId: options.tableRowId,
|
|
993
|
+
pageNumber: options.pageNumber,
|
|
994
|
+
pageSize: options.pageSize,
|
|
995
|
+
searchValue: options.searchValue
|
|
996
|
+
}
|
|
997
|
+
);
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
class CustomComponentDataform extends Dataform {
|
|
1149
1001
|
initForm(instanceId, viewId) {
|
|
1150
1002
|
return this._postMessageAsync(LISTENER_CMDS.DATAFORM_INIT_FORM, {
|
|
1151
1003
|
flowId: this._id,
|
|
1152
1004
|
instanceId: instanceId || "",
|
|
1153
1005
|
viewId: viewId || ""
|
|
1154
1006
|
}).then((response) => {
|
|
1155
|
-
return new
|
|
1007
|
+
return new CustomComponentForm(
|
|
1156
1008
|
response.storeId || instanceId || "",
|
|
1157
1009
|
this._id,
|
|
1158
1010
|
response.itemId || instanceId
|
|
1159
1011
|
);
|
|
1160
1012
|
});
|
|
1161
1013
|
}
|
|
1162
|
-
getFieldOptions(options) {
|
|
1163
|
-
return this._postMessageAsync(
|
|
1164
|
-
LISTENER_CMDS.DATAFORM_GET_FIELD_OPTIONS,
|
|
1165
|
-
{
|
|
1166
|
-
flowId: this._id,
|
|
1167
|
-
instanceId: (options == null ? void 0 : options.instanceId) || "",
|
|
1168
|
-
fieldId: (options == null ? void 0 : options.fieldId) || "",
|
|
1169
|
-
fieldType: options == null ? void 0 : options.fieldType,
|
|
1170
|
-
tableId: options == null ? void 0 : options.tableId,
|
|
1171
|
-
tableRowId: options == null ? void 0 : options.tableRowId
|
|
1172
|
-
}
|
|
1173
|
-
);
|
|
1174
|
-
}
|
|
1175
1014
|
}
|
|
1176
1015
|
class Board extends BaseSDK {
|
|
1177
1016
|
constructor(flowId) {
|
|
@@ -1210,7 +1049,8 @@ class Board extends BaseSDK {
|
|
|
1210
1049
|
return error;
|
|
1211
1050
|
return this._postMessageAsync(LISTENER_CMDS.BOARD_GET_ITEM, {
|
|
1212
1051
|
flowId: this._id,
|
|
1213
|
-
instanceId: options.instanceId
|
|
1052
|
+
instanceId: options.instanceId,
|
|
1053
|
+
viewId: options.viewId || ""
|
|
1214
1054
|
});
|
|
1215
1055
|
}
|
|
1216
1056
|
createItem(options) {
|
|
@@ -1262,23 +1102,10 @@ class Board extends BaseSDK {
|
|
|
1262
1102
|
viewId: (options == null ? void 0 : options.viewId) || ""
|
|
1263
1103
|
});
|
|
1264
1104
|
}
|
|
1265
|
-
initForm(instanceId, viewId) {
|
|
1266
|
-
return this._postMessageAsync(LISTENER_CMDS.BOARD_INIT_FORM, {
|
|
1267
|
-
flowId: this._id,
|
|
1268
|
-
instanceId: instanceId || "",
|
|
1269
|
-
viewId: viewId || ""
|
|
1270
|
-
}).then((response) => {
|
|
1271
|
-
return new Form(
|
|
1272
|
-
response.storeId || instanceId || "",
|
|
1273
|
-
this._id,
|
|
1274
|
-
response.itemId || instanceId
|
|
1275
|
-
);
|
|
1276
|
-
});
|
|
1277
|
-
}
|
|
1278
1105
|
getFieldOptions(options) {
|
|
1279
1106
|
const error = requireFieldsAsync([
|
|
1280
|
-
{ value: options.instanceId, name: "instanceId" },
|
|
1281
|
-
{ value: options.fieldId, name: "fieldId" }
|
|
1107
|
+
{ value: options == null ? void 0 : options.instanceId, name: "instanceId" },
|
|
1108
|
+
{ value: options == null ? void 0 : options.fieldId, name: "fieldId" }
|
|
1282
1109
|
]);
|
|
1283
1110
|
if (error)
|
|
1284
1111
|
return error;
|
|
@@ -1288,7 +1115,25 @@ class Board extends BaseSDK {
|
|
|
1288
1115
|
fieldId: options.fieldId,
|
|
1289
1116
|
fieldType: options.fieldType,
|
|
1290
1117
|
tableId: options == null ? void 0 : options.tableId,
|
|
1291
|
-
tableRowId: options == null ? void 0 : options.tableRowId
|
|
1118
|
+
tableRowId: options == null ? void 0 : options.tableRowId,
|
|
1119
|
+
pageNumber: options == null ? void 0 : options.pageNumber,
|
|
1120
|
+
pageSize: options == null ? void 0 : options.pageSize,
|
|
1121
|
+
searchValue: options == null ? void 0 : options.searchValue
|
|
1122
|
+
});
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
class CustomComponentBoard extends Board {
|
|
1126
|
+
initForm(instanceId, viewId) {
|
|
1127
|
+
return this._postMessageAsync(LISTENER_CMDS.BOARD_INIT_FORM, {
|
|
1128
|
+
flowId: this._id,
|
|
1129
|
+
instanceId: instanceId || "",
|
|
1130
|
+
viewId: viewId || ""
|
|
1131
|
+
}).then((response) => {
|
|
1132
|
+
return new CustomComponentForm(
|
|
1133
|
+
response.storeId || instanceId || "",
|
|
1134
|
+
this._id,
|
|
1135
|
+
response.itemId || instanceId
|
|
1136
|
+
);
|
|
1292
1137
|
});
|
|
1293
1138
|
}
|
|
1294
1139
|
}
|
|
@@ -1575,29 +1420,25 @@ class Process extends BaseSDK {
|
|
|
1575
1420
|
instanceId: options.instanceId
|
|
1576
1421
|
});
|
|
1577
1422
|
}
|
|
1578
|
-
initForm(instanceId, activityInstanceId) {
|
|
1579
|
-
return this._postMessageAsync(LISTENER_CMDS.PROCESS_INIT_FORM, {
|
|
1580
|
-
flowId: this._id,
|
|
1581
|
-
instanceId: instanceId || "",
|
|
1582
|
-
activityInstanceId: activityInstanceId || ""
|
|
1583
|
-
}).then((response) => {
|
|
1584
|
-
return new Form(
|
|
1585
|
-
response.storeId || instanceId || "",
|
|
1586
|
-
this._id,
|
|
1587
|
-
response.itemId || instanceId,
|
|
1588
|
-
response.activityInstanceId || activityInstanceId
|
|
1589
|
-
);
|
|
1590
|
-
});
|
|
1591
|
-
}
|
|
1592
1423
|
getFieldOptions(options) {
|
|
1424
|
+
const error = requireFieldsAsync([
|
|
1425
|
+
{ value: options == null ? void 0 : options.instanceId, name: "instanceId" },
|
|
1426
|
+
{ value: options == null ? void 0 : options.activityInstanceId, name: "activityInstanceId" },
|
|
1427
|
+
{ value: options == null ? void 0 : options.fieldId, name: "fieldId" }
|
|
1428
|
+
]);
|
|
1429
|
+
if (error)
|
|
1430
|
+
return error;
|
|
1593
1431
|
return this._postMessageAsync(LISTENER_CMDS.PROCESS_GET_FIELD_OPTIONS, {
|
|
1594
1432
|
flowId: this._id,
|
|
1595
|
-
instanceId:
|
|
1596
|
-
activityInstanceId:
|
|
1597
|
-
fieldId:
|
|
1598
|
-
fieldType: options
|
|
1599
|
-
tableId: options
|
|
1600
|
-
tableRowId: options
|
|
1433
|
+
instanceId: options.instanceId,
|
|
1434
|
+
activityInstanceId: options.activityInstanceId,
|
|
1435
|
+
fieldId: options.fieldId,
|
|
1436
|
+
fieldType: options.fieldType,
|
|
1437
|
+
tableId: options.tableId,
|
|
1438
|
+
tableRowId: options.tableRowId,
|
|
1439
|
+
pageNumber: options.pageNumber,
|
|
1440
|
+
pageSize: options.pageSize,
|
|
1441
|
+
searchValue: options.searchValue
|
|
1601
1442
|
});
|
|
1602
1443
|
}
|
|
1603
1444
|
parseAttachment(options) {
|
|
@@ -1618,6 +1459,203 @@ class Process extends BaseSDK {
|
|
|
1618
1459
|
});
|
|
1619
1460
|
}
|
|
1620
1461
|
}
|
|
1462
|
+
class CustomComponentProcess extends Process {
|
|
1463
|
+
initForm(instanceId, activityInstanceId) {
|
|
1464
|
+
return this._postMessageAsync(LISTENER_CMDS.PROCESS_INIT_FORM, {
|
|
1465
|
+
flowId: this._id,
|
|
1466
|
+
instanceId: instanceId || "",
|
|
1467
|
+
activityInstanceId: activityInstanceId || ""
|
|
1468
|
+
}).then((response) => {
|
|
1469
|
+
return new CustomComponentForm(
|
|
1470
|
+
response.storeId || instanceId || "",
|
|
1471
|
+
this._id,
|
|
1472
|
+
response.itemId || instanceId,
|
|
1473
|
+
response.activityInstanceId || activityInstanceId
|
|
1474
|
+
);
|
|
1475
|
+
});
|
|
1476
|
+
}
|
|
1477
|
+
}
|
|
1478
|
+
const READ_TIMEOUT_MS$1 = 75e3;
|
|
1479
|
+
const EXECUTE_TIMEOUT_MS = 6e4;
|
|
1480
|
+
const WATCH_ACK_TIMEOUT_MS$1 = 6e4;
|
|
1481
|
+
const WATCH_DEADLINE_MS$1 = 42e4;
|
|
1482
|
+
const TERMINAL_STATUSES$1 = ["Completed", "Failed"];
|
|
1483
|
+
function sdkError$1(errorCode, error) {
|
|
1484
|
+
return { isError: true, error, errorCode };
|
|
1485
|
+
}
|
|
1486
|
+
function notify$1(callback, value) {
|
|
1487
|
+
try {
|
|
1488
|
+
callback == null ? void 0 : callback(value);
|
|
1489
|
+
} catch (error) {
|
|
1490
|
+
console.error(error);
|
|
1491
|
+
}
|
|
1492
|
+
}
|
|
1493
|
+
const NOT_SENT$1 = sdkError$1("AGENT_REQUEST_NOT_SENT", "The request could not be sent to the host.");
|
|
1494
|
+
class Agent extends BaseSDK {
|
|
1495
|
+
constructor(agentId) {
|
|
1496
|
+
super();
|
|
1497
|
+
this.activeWatches = 0;
|
|
1498
|
+
this.agentId = agentId;
|
|
1499
|
+
this._id = generateId("customagent");
|
|
1500
|
+
}
|
|
1501
|
+
getContract() {
|
|
1502
|
+
return this._postMessageBounded(
|
|
1503
|
+
LISTENER_CMDS.CUSTOM_AGENT_GET_CONTRACT,
|
|
1504
|
+
{ agentId: this.agentId },
|
|
1505
|
+
{
|
|
1506
|
+
timeoutMs: READ_TIMEOUT_MS$1,
|
|
1507
|
+
timeoutError: sdkError$1("AGENT_HOST_TIMEOUT", "The host did not answer the Agent contract request."),
|
|
1508
|
+
sendError: NOT_SENT$1
|
|
1509
|
+
}
|
|
1510
|
+
).promise;
|
|
1511
|
+
}
|
|
1512
|
+
execute(options) {
|
|
1513
|
+
var _a;
|
|
1514
|
+
return this._postMessageBounded(
|
|
1515
|
+
LISTENER_CMDS.CUSTOM_AGENT_EXECUTE,
|
|
1516
|
+
{ agentId: this.agentId, inputData: (_a = options == null ? void 0 : options.inputData) != null ? _a : {} },
|
|
1517
|
+
{
|
|
1518
|
+
timeoutMs: EXECUTE_TIMEOUT_MS,
|
|
1519
|
+
timeoutError: sdkError$1(
|
|
1520
|
+
"AGENT_EXECUTE_OUTCOME_UNKNOWN",
|
|
1521
|
+
"The host did not confirm the run; it may still have started."
|
|
1522
|
+
),
|
|
1523
|
+
sendError: sdkError$1("AGENT_EXECUTE_NOT_SENT", "The run request could not be sent to the host.")
|
|
1524
|
+
}
|
|
1525
|
+
).promise;
|
|
1526
|
+
}
|
|
1527
|
+
getExecution(executionId) {
|
|
1528
|
+
return this._postMessageBounded(
|
|
1529
|
+
LISTENER_CMDS.CUSTOM_AGENT_GET_EXECUTION,
|
|
1530
|
+
{ agentId: this.agentId, executionId },
|
|
1531
|
+
{
|
|
1532
|
+
timeoutMs: READ_TIMEOUT_MS$1,
|
|
1533
|
+
timeoutError: sdkError$1("AGENT_HOST_TIMEOUT", "The host did not answer the Agent execution request."),
|
|
1534
|
+
sendError: NOT_SENT$1
|
|
1535
|
+
}
|
|
1536
|
+
).promise;
|
|
1537
|
+
}
|
|
1538
|
+
onExecutionComplete(executionId, onComplete, onWatchError) {
|
|
1539
|
+
const watchId = generateId("agentwatch");
|
|
1540
|
+
const eventName = `${EVENT_TYPES.CUSTOM_AGENT_EXECUTION_COMPLETE}:${watchId}`;
|
|
1541
|
+
let settled = false;
|
|
1542
|
+
let deadline = null;
|
|
1543
|
+
let registration = null;
|
|
1544
|
+
const end = () => {
|
|
1545
|
+
settled = true;
|
|
1546
|
+
if (deadline)
|
|
1547
|
+
clearTimeout(deadline);
|
|
1548
|
+
registration == null ? void 0 : registration.cancel();
|
|
1549
|
+
this._removeEventListener(eventName);
|
|
1550
|
+
this.activeWatches -= 1;
|
|
1551
|
+
if (this.activeWatches === 0)
|
|
1552
|
+
Reflect.deleteProperty(globalInstances, this._id);
|
|
1553
|
+
};
|
|
1554
|
+
const tellHostToStop = () => {
|
|
1555
|
+
try {
|
|
1556
|
+
this._postMessage(LISTENER_CMDS.CUSTOM_AGENT_STOP_WATCH, { id: this._id, watchId, eventName });
|
|
1557
|
+
} catch {
|
|
1558
|
+
}
|
|
1559
|
+
};
|
|
1560
|
+
const fail = (error) => {
|
|
1561
|
+
if (settled)
|
|
1562
|
+
return;
|
|
1563
|
+
end();
|
|
1564
|
+
tellHostToStop();
|
|
1565
|
+
notify$1(onWatchError, error);
|
|
1566
|
+
};
|
|
1567
|
+
const listener = (params) => {
|
|
1568
|
+
if (settled)
|
|
1569
|
+
return;
|
|
1570
|
+
if (params == null ? void 0 : params.isError) {
|
|
1571
|
+
end();
|
|
1572
|
+
notify$1(onWatchError, params);
|
|
1573
|
+
return;
|
|
1574
|
+
}
|
|
1575
|
+
const execution = params;
|
|
1576
|
+
if ((execution == null ? void 0 : execution.ExecutionId) !== executionId || TERMINAL_STATUSES$1.indexOf(execution == null ? void 0 : execution.Status) === -1) {
|
|
1577
|
+
fail(sdkError$1("AGENT_WATCH_INVALID_EVENT", "The host reported something other than a finished run."));
|
|
1578
|
+
return;
|
|
1579
|
+
}
|
|
1580
|
+
end();
|
|
1581
|
+
notify$1(onComplete, execution);
|
|
1582
|
+
};
|
|
1583
|
+
this.activeWatches += 1;
|
|
1584
|
+
globalInstances[this._id] = this;
|
|
1585
|
+
this._addEventListener(eventName, listener);
|
|
1586
|
+
registration = this._postMessageBounded(
|
|
1587
|
+
LISTENER_CMDS.CUSTOM_AGENT_WATCH_EXECUTION,
|
|
1588
|
+
{ id: this._id, agentId: this.agentId, executionId, watchId, eventName },
|
|
1589
|
+
{
|
|
1590
|
+
timeoutMs: WATCH_ACK_TIMEOUT_MS$1,
|
|
1591
|
+
timeoutError: sdkError$1("AGENT_HOST_UNSUPPORTED", "The host did not start observing the Agent run."),
|
|
1592
|
+
sendError: NOT_SENT$1
|
|
1593
|
+
}
|
|
1594
|
+
);
|
|
1595
|
+
registration.promise.then(
|
|
1596
|
+
(acknowledged) => {
|
|
1597
|
+
if (settled)
|
|
1598
|
+
return;
|
|
1599
|
+
if (acknowledged !== true) {
|
|
1600
|
+
fail(sdkError$1("AGENT_HOST_UNSUPPORTED", "The host did not start observing the Agent run."));
|
|
1601
|
+
return;
|
|
1602
|
+
}
|
|
1603
|
+
deadline = setTimeout(
|
|
1604
|
+
() => fail(sdkError$1("AGENT_OBSERVATION_STOPPED", "Stopped checking the Agent run; read it again later.")),
|
|
1605
|
+
WATCH_DEADLINE_MS$1
|
|
1606
|
+
);
|
|
1607
|
+
},
|
|
1608
|
+
(error) => fail(error)
|
|
1609
|
+
);
|
|
1610
|
+
return () => {
|
|
1611
|
+
if (settled)
|
|
1612
|
+
return;
|
|
1613
|
+
end();
|
|
1614
|
+
tellHostToStop();
|
|
1615
|
+
};
|
|
1616
|
+
}
|
|
1617
|
+
}
|
|
1618
|
+
const REPORT_FLOW_TYPES = ["Form", "Process", "Case"];
|
|
1619
|
+
class Report extends BaseSDK {
|
|
1620
|
+
constructor(flowType, flowId, reportId) {
|
|
1621
|
+
super();
|
|
1622
|
+
this._flowType = flowType;
|
|
1623
|
+
this._flowId = flowId;
|
|
1624
|
+
this._id = reportId;
|
|
1625
|
+
}
|
|
1626
|
+
getData(options) {
|
|
1627
|
+
return this._send(LISTENER_CMDS.REPORT_GET_DATA, {
|
|
1628
|
+
pageNumber: (options == null ? void 0 : options.pageNumber) || 1,
|
|
1629
|
+
pageSize: (options == null ? void 0 : options.pageSize) || 50,
|
|
1630
|
+
payload: (options == null ? void 0 : options.payload) || {}
|
|
1631
|
+
});
|
|
1632
|
+
}
|
|
1633
|
+
getCount(options) {
|
|
1634
|
+
return this._send(LISTENER_CMDS.REPORT_GET_COUNT, { payload: (options == null ? void 0 : options.payload) || {} });
|
|
1635
|
+
}
|
|
1636
|
+
getFields() {
|
|
1637
|
+
return this._send(LISTENER_CMDS.REPORT_GET_FIELDS, {});
|
|
1638
|
+
}
|
|
1639
|
+
_send(command, args) {
|
|
1640
|
+
const missing = requireFieldsAsync([
|
|
1641
|
+
{ value: this._flowId, name: "flowId" },
|
|
1642
|
+
{ value: this._id, name: "reportId" }
|
|
1643
|
+
]);
|
|
1644
|
+
if (missing)
|
|
1645
|
+
return missing;
|
|
1646
|
+
if (REPORT_FLOW_TYPES.indexOf(this._flowType) === -1) {
|
|
1647
|
+
return Promise.reject({
|
|
1648
|
+
message: `flowType must be one of ${REPORT_FLOW_TYPES.join(", ")}`
|
|
1649
|
+
});
|
|
1650
|
+
}
|
|
1651
|
+
return this._postMessageAsync(command, {
|
|
1652
|
+
flowType: this._flowType,
|
|
1653
|
+
flowId: this._flowId,
|
|
1654
|
+
reportId: this._id,
|
|
1655
|
+
...args
|
|
1656
|
+
});
|
|
1657
|
+
}
|
|
1658
|
+
}
|
|
1621
1659
|
const READ_TIMEOUT_MS = 3e4;
|
|
1622
1660
|
const RUN_TIMEOUT_MS = 45e3;
|
|
1623
1661
|
const WATCH_ACK_TIMEOUT_MS = 6e4;
|
|
@@ -1790,6 +1828,17 @@ class Application extends BaseSDK {
|
|
|
1790
1828
|
});
|
|
1791
1829
|
}
|
|
1792
1830
|
}
|
|
1831
|
+
class CustomComponentApplication extends Application {
|
|
1832
|
+
getDataform(flowId) {
|
|
1833
|
+
return new CustomComponentDataform(flowId);
|
|
1834
|
+
}
|
|
1835
|
+
getBoard(flowId) {
|
|
1836
|
+
return new CustomComponentBoard(flowId);
|
|
1837
|
+
}
|
|
1838
|
+
getProcess(flowId) {
|
|
1839
|
+
return new CustomComponentProcess(flowId);
|
|
1840
|
+
}
|
|
1841
|
+
}
|
|
1793
1842
|
class CustomComponentSDK extends BaseSDK {
|
|
1794
1843
|
constructor() {
|
|
1795
1844
|
super();
|
|
@@ -1808,7 +1857,7 @@ class CustomComponentSDK extends BaseSDK {
|
|
|
1808
1857
|
{},
|
|
1809
1858
|
true,
|
|
1810
1859
|
(data) => {
|
|
1811
|
-
this.app = new
|
|
1860
|
+
this.app = new CustomComponentApplication(data, true);
|
|
1812
1861
|
this.page = new Page(data, true);
|
|
1813
1862
|
this.context = new CustomComponent(data.componentId);
|
|
1814
1863
|
this.client = new Client();
|