@kissflow/lowcode-client-sdk 1.0.44 → 1.0.50
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 +748 -155
- package/dist/kfsdk.es.js +608 -8
- package/dist/kfsdk.umd.js +1 -1
- package/dist/lowcode.d.ts +717 -124
- package/dist/lowcode.types.d.ts +505 -1
- package/dist/nocode.d.ts +726 -133
- package/dist/nocode.types.d.ts +290 -0
- package/dist/snippets.json +5 -0
- package/package.json +7 -2
- package/dist/kf.lowcodeworkersdk.es.js +0 -1233
- package/dist/kf.nocodeworkersdk.es.js +0 -573
package/dist/kfsdk.es.js
CHANGED
|
@@ -40,6 +40,9 @@ const LISTENER_CMDS = {
|
|
|
40
40
|
RETURN: "RETURN",
|
|
41
41
|
GET_FORM_FIELD: "GET_FORM_FIELD",
|
|
42
42
|
UPDATE_FORM: "UPDATE_FORM",
|
|
43
|
+
GET_FORM_VALIDATION_ERRORS: "GET_FORM_VALIDATION_ERRORS",
|
|
44
|
+
GET_FORM_CONFIGURATION: "GET_FORM_CONFIGURATION",
|
|
45
|
+
GET_FORM_FIELD_STATE: "GET_FORM_FIELD_STATE",
|
|
43
46
|
GET_TABLE: "GET_TABLE",
|
|
44
47
|
GET_TABLE_ROW: "GET_TABLE_ROW",
|
|
45
48
|
ADD_TABLE_ROW: "ADD_TABLE_ROW",
|
|
@@ -54,6 +57,13 @@ const LISTENER_CMDS = {
|
|
|
54
57
|
REDIRECT: "REDIRECT",
|
|
55
58
|
OPEN_PAGE: "OPEN_PAGE",
|
|
56
59
|
GET_IMAGE_URL: "GET_IMAGE_URL",
|
|
60
|
+
FILEPICKER_OPEN: "FILEPICKER_OPEN",
|
|
61
|
+
FILEPREVIEW_OPEN: "FILEPREVIEW_OPEN",
|
|
62
|
+
FILE_UPLOAD: "FILE_UPLOAD",
|
|
63
|
+
SCANNER_OPEN: "SCANNER_OPEN",
|
|
64
|
+
GEOLOCATION_OPEN: "GEOLOCATION_OPEN",
|
|
65
|
+
GET_ROLES: "GET_ROLES",
|
|
66
|
+
SWITCH_ROLE: "SWITCH_ROLE",
|
|
57
67
|
FORMAT_DATE: "FORMAT_DATE",
|
|
58
68
|
FORMAT_DATE_TIME: "FORMAT_DATE_TIME",
|
|
59
69
|
FORMAT_NUMBER: "FORMAT_NUMBER",
|
|
@@ -77,12 +87,19 @@ const LISTENER_CMDS = {
|
|
|
77
87
|
COMPONENT_ADD_EVENT_LISTENER: "COMPONENT_ADD_EVENT_LISTENER",
|
|
78
88
|
CC_INITIALIZE: "CC_INITIALIZE",
|
|
79
89
|
CC_WATCH_PARAMS: "CC_WATCH_PARAMS",
|
|
90
|
+
CC_SET_ROUTE: "CC_SET_ROUTE",
|
|
91
|
+
CC_WATCH_ROUTE: "CC_WATCH_ROUTE",
|
|
80
92
|
WINDOW_NDEF_READER_NEW: "WINDOW_NDEF_READER_NEW",
|
|
81
93
|
WINDOW_NDEF_READER_SCAN: "WINDOW_NDEF_READER_SCAN",
|
|
82
94
|
WINDOW_NDEF_READER_WRITE: "WINDOW_NDEF_READER_WRITE",
|
|
83
95
|
WINDOW_NDEF_READER_ADD_EVENT_LISTENER: "WINDOW_NDEF_READER_ADD_EVENT_LISTENER",
|
|
84
96
|
WINDOW_NDEF_READER_MAKE_READONLY: "WINDOW_NDEF_READER_MAKE_READONLY",
|
|
85
97
|
WINDOW_NDEF_READER_ABORT_SCAN: "WINDOW_NDEF_READER_ABORT_SCAN",
|
|
98
|
+
CUSTOM_AGENT_GET_CONTRACT: "CUSTOM_AGENT_GET_CONTRACT",
|
|
99
|
+
CUSTOM_AGENT_EXECUTE: "CUSTOM_AGENT_EXECUTE",
|
|
100
|
+
CUSTOM_AGENT_GET_EXECUTION: "CUSTOM_AGENT_GET_EXECUTION",
|
|
101
|
+
CUSTOM_AGENT_WATCH_EXECUTION: "CUSTOM_AGENT_WATCH_EXECUTION",
|
|
102
|
+
CUSTOM_AGENT_STOP_WATCH: "CUSTOM_AGENT_STOP_WATCH",
|
|
86
103
|
DECISION_TABLE_EXECUTE: "DECISION_TABLE_EXECUTE",
|
|
87
104
|
DATAFORM_IMPORT_CSV: "DATAFORM_IMPORT_CSV",
|
|
88
105
|
DATAFORM_OPEN_FORM: "DATAFORM_OPEN_FORM",
|
|
@@ -94,6 +111,8 @@ const LISTENER_CMDS = {
|
|
|
94
111
|
DATAFORM_DELETE_ITEM: "DATAFORM_DELETE_ITEM",
|
|
95
112
|
DATAFORM_DISCARD_ITEM: "DATAFORM_DISCARD_ITEM",
|
|
96
113
|
DATAFORM_SUBMIT_ITEM: "DATAFORM_SUBMIT_ITEM",
|
|
114
|
+
DATAFORM_INIT_FORM: "DATAFORM_INIT_FORM",
|
|
115
|
+
DATAFORM_GET_FIELD_OPTIONS: "DATAFORM_GET_FIELD_OPTIONS",
|
|
97
116
|
PROCESS_OPEN_FORM: "PROCESS_OPEN_FORM",
|
|
98
117
|
PROCESS_GET_FIELDS: "PROCESS_GET_FIELDS",
|
|
99
118
|
PROCESS_GET_MYTASK_FIELDS: "PROCESS_GET_MYTASK_FIELDS",
|
|
@@ -107,6 +126,8 @@ const LISTENER_CMDS = {
|
|
|
107
126
|
PROCESS_UPDATE_ITEM: "PROCESS_UPDATE_ITEM",
|
|
108
127
|
PROCESS_GET_ITEM: "PROCESS_GET_ITEM",
|
|
109
128
|
PROCESS_DELETE_ITEM: "PROCESS_DELETE_ITEM",
|
|
129
|
+
PROCESS_GET_ADMIN_ITEM: "PROCESS_GET_ADMIN_ITEM",
|
|
130
|
+
PROCESS_UPDATE_ADMIN_ITEM: "PROCESS_UPDATE_ADMIN_ITEM",
|
|
110
131
|
PROCESS_SUBMIT_ITEM: "PROCESS_SUBMIT_ITEM",
|
|
111
132
|
PROCESS_REJECT_ITEM: "PROCESS_REJECT_ITEM",
|
|
112
133
|
PROCESS_WITHDRAW_ITEM: "PROCESS_WITHDRAW_ITEM",
|
|
@@ -116,6 +137,9 @@ const LISTENER_CMDS = {
|
|
|
116
137
|
PROCESS_RESTART_ITEM: "PROCESS_RESTART_ITEM",
|
|
117
138
|
PROCESS_DISCARD_ITEM: "PROCESS_DISCARD_ITEM",
|
|
118
139
|
PROCESS_GET_PROGRESS: "PROCESS_GET_PROGRESS",
|
|
140
|
+
PROCESS_INIT_FORM: "PROCESS_INIT_FORM",
|
|
141
|
+
PROCESS_GET_FIELD_OPTIONS: "PROCESS_GET_FIELD_OPTIONS",
|
|
142
|
+
PROCESS_PARSE_ATTACHMENT: "PROCESS_PARSE_ATTACHMENT",
|
|
119
143
|
BOARD_IMPORT_CSV: "BOARD_IMPORT_CSV",
|
|
120
144
|
BOARD_OPEN_FORM: "BOARD_OPEN_FORM",
|
|
121
145
|
BOARD_GET_FIELDS: "BOARD_GET_FIELDS",
|
|
@@ -125,11 +149,15 @@ const LISTENER_CMDS = {
|
|
|
125
149
|
BOARD_GET_ITEM: "BOARD_GET_ITEM",
|
|
126
150
|
BOARD_DELETE_ITEM: "BOARD_DELETE_ITEM",
|
|
127
151
|
BOARD_SUBMIT_ITEM: "BOARD_SUBMIT_ITEM",
|
|
128
|
-
BOARD_DISCARD_ITEM: "BOARD_DISCARD_ITEM"
|
|
152
|
+
BOARD_DISCARD_ITEM: "BOARD_DISCARD_ITEM",
|
|
153
|
+
BOARD_INIT_FORM: "BOARD_INIT_FORM",
|
|
154
|
+
BOARD_GET_FIELD_OPTIONS: "BOARD_GET_FIELD_OPTIONS"
|
|
129
155
|
};
|
|
130
156
|
const EVENT_TYPES = {
|
|
131
157
|
COMPONENT_ON_MOUNT: "componentOnMount",
|
|
132
|
-
CC_ON_PARAMS_CHANGE: "onCustomComponentParamsChange"
|
|
158
|
+
CC_ON_PARAMS_CHANGE: "onCustomComponentParamsChange",
|
|
159
|
+
CC_ON_ROUTE_CHANGE: "onCustomComponentRouteChange",
|
|
160
|
+
CUSTOM_AGENT_EXECUTION_COMPLETE: "onCustomAgentExecutionComplete"
|
|
133
161
|
};
|
|
134
162
|
const DEFAULTS = {
|
|
135
163
|
POPUP_ID: "ACTIVE_POP_UP"
|
|
@@ -138,6 +166,7 @@ function generateId(prefix = "lcncsdk") {
|
|
|
138
166
|
return `${prefix}-${nanoid()}`;
|
|
139
167
|
}
|
|
140
168
|
const globalInstances = {};
|
|
169
|
+
const pendingRequestIds = /* @__PURE__ */ new Set();
|
|
141
170
|
function processResponse(req, resp) {
|
|
142
171
|
if (resp && Object.keys(resp).length === 1 && req.command !== LISTENER_CMDS.API) {
|
|
143
172
|
let value = Object.values(resp)[0];
|
|
@@ -161,6 +190,8 @@ function onMessage(event) {
|
|
|
161
190
|
if (data == null ? void 0 : data.isEvent) {
|
|
162
191
|
const { target, eventParams, eventName, eventConfig = {} } = data;
|
|
163
192
|
let targetInstance = globalInstances[target];
|
|
193
|
+
if (!targetInstance)
|
|
194
|
+
return;
|
|
164
195
|
targetInstance._dispatchEvent(eventName, eventParams);
|
|
165
196
|
if (eventConfig.once) {
|
|
166
197
|
targetInstance._removeEventListener(eventName);
|
|
@@ -170,7 +201,12 @@ function onMessage(event) {
|
|
|
170
201
|
let { _req: req, resp } = data;
|
|
171
202
|
if (req == null ? void 0 : req._id) {
|
|
172
203
|
let targetInstance = globalInstances[req._id];
|
|
173
|
-
targetInstance
|
|
204
|
+
if (targetInstance) {
|
|
205
|
+
targetInstance._dispatchMessageEvents(req, resp);
|
|
206
|
+
if (pendingRequestIds.delete(req._id)) {
|
|
207
|
+
Reflect.deleteProperty(globalInstances, req._id);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
174
210
|
}
|
|
175
211
|
}
|
|
176
212
|
}
|
|
@@ -187,8 +223,9 @@ class EventBase {
|
|
|
187
223
|
}
|
|
188
224
|
_removeEventListener(eventName, callBack) {
|
|
189
225
|
if (callBack) {
|
|
190
|
-
|
|
191
|
-
index2
|
|
226
|
+
const listeners = __privateGet(this, _listeners)[eventName] || [];
|
|
227
|
+
const index2 = listeners.indexOf(callBack);
|
|
228
|
+
index2 > -1 && listeners.splice(index2, 1);
|
|
192
229
|
return;
|
|
193
230
|
}
|
|
194
231
|
Reflect.deleteProperty(__privateGet(this, _listeners), eventName);
|
|
@@ -224,6 +261,7 @@ class BaseSDK extends EventBase {
|
|
|
224
261
|
const _id = generateId(command.toLowerCase());
|
|
225
262
|
postMessage({ _id, command, ...args });
|
|
226
263
|
globalInstances[_id] = this;
|
|
264
|
+
pendingRequestIds.add(_id);
|
|
227
265
|
this._addEventListener(_id, async (data) => {
|
|
228
266
|
if ((data == null ? void 0 : data.errorMessage) || (data == null ? void 0 : data.isError)) {
|
|
229
267
|
reject(data);
|
|
@@ -236,6 +274,46 @@ class BaseSDK extends EventBase {
|
|
|
236
274
|
});
|
|
237
275
|
});
|
|
238
276
|
}
|
|
277
|
+
_postMessageBounded(command, args, options) {
|
|
278
|
+
const _id = generateId(command.toLowerCase());
|
|
279
|
+
let timer;
|
|
280
|
+
let settled = false;
|
|
281
|
+
const release = () => {
|
|
282
|
+
settled = true;
|
|
283
|
+
clearTimeout(timer);
|
|
284
|
+
this._removeEventListener(_id);
|
|
285
|
+
pendingRequestIds.delete(_id);
|
|
286
|
+
Reflect.deleteProperty(globalInstances, _id);
|
|
287
|
+
};
|
|
288
|
+
const promise = new Promise((resolve, reject) => {
|
|
289
|
+
timer = setTimeout(() => {
|
|
290
|
+
release();
|
|
291
|
+
reject(options.timeoutError);
|
|
292
|
+
}, options.timeoutMs);
|
|
293
|
+
globalInstances[_id] = this;
|
|
294
|
+
pendingRequestIds.add(_id);
|
|
295
|
+
this._addEventListener(_id, (data) => {
|
|
296
|
+
release();
|
|
297
|
+
if ((data == null ? void 0 : data.errorMessage) || (data == null ? void 0 : data.isError))
|
|
298
|
+
reject(data);
|
|
299
|
+
else
|
|
300
|
+
resolve(data);
|
|
301
|
+
});
|
|
302
|
+
try {
|
|
303
|
+
postMessage({ _id, command, ...args });
|
|
304
|
+
} catch (error) {
|
|
305
|
+
release();
|
|
306
|
+
reject(options.sendError);
|
|
307
|
+
}
|
|
308
|
+
});
|
|
309
|
+
return {
|
|
310
|
+
promise,
|
|
311
|
+
cancel: () => {
|
|
312
|
+
if (!settled)
|
|
313
|
+
release();
|
|
314
|
+
}
|
|
315
|
+
};
|
|
316
|
+
}
|
|
239
317
|
_postMessage(command, args, callBack) {
|
|
240
318
|
const _id = generateId(command.toLowerCase());
|
|
241
319
|
postMessage({ _id, command, ...args });
|
|
@@ -321,7 +399,37 @@ class Client extends BaseSDK {
|
|
|
321
399
|
return super._postMessageAsync(LISTENER_CMDS.REDIRECT, { url });
|
|
322
400
|
}
|
|
323
401
|
getImageUrl(imageValue) {
|
|
324
|
-
return this._postMessageAsync(LISTENER_CMDS.GET_IMAGE_URL, {
|
|
402
|
+
return this._postMessageAsync(LISTENER_CMDS.GET_IMAGE_URL, {
|
|
403
|
+
imageValue
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
openFilePicker(options) {
|
|
407
|
+
return this._postMessageAsync(LISTENER_CMDS.FILEPICKER_OPEN, {
|
|
408
|
+
options
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
openScanner(options = {}) {
|
|
412
|
+
return this._postMessageAsync(LISTENER_CMDS.SCANNER_OPEN, {
|
|
413
|
+
options
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
pickLocation(value) {
|
|
417
|
+
return this._postMessageAsync(LISTENER_CMDS.GEOLOCATION_OPEN, {
|
|
418
|
+
value
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
uploadFile(file, fileName) {
|
|
422
|
+
return this._postMessageAsync(LISTENER_CMDS.FILE_UPLOAD, {
|
|
423
|
+
file,
|
|
424
|
+
fileName: fileName != null ? fileName : file.name
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
openFilePreview(args) {
|
|
428
|
+
var _a;
|
|
429
|
+
return this._postMessageAsync(LISTENER_CMDS.FILEPREVIEW_OPEN, {
|
|
430
|
+
files: args.files,
|
|
431
|
+
indexOfFile: (_a = args.indexOfFile) != null ? _a : 0
|
|
432
|
+
});
|
|
325
433
|
}
|
|
326
434
|
}
|
|
327
435
|
class Formatter extends BaseSDK {
|
|
@@ -448,6 +556,19 @@ class CustomComponent extends BaseSDK {
|
|
|
448
556
|
callBack
|
|
449
557
|
);
|
|
450
558
|
}
|
|
559
|
+
watchRoute(callBack) {
|
|
560
|
+
this._postMessage(
|
|
561
|
+
LISTENER_CMDS.CC_WATCH_ROUTE,
|
|
562
|
+
{
|
|
563
|
+
id: this._id,
|
|
564
|
+
eventName: EVENT_TYPES.CC_ON_ROUTE_CHANGE,
|
|
565
|
+
eventConfig: {
|
|
566
|
+
once: false
|
|
567
|
+
}
|
|
568
|
+
},
|
|
569
|
+
callBack
|
|
570
|
+
);
|
|
571
|
+
}
|
|
451
572
|
}
|
|
452
573
|
class Popup extends BaseSDK {
|
|
453
574
|
constructor(props) {
|
|
@@ -482,10 +603,12 @@ class Popup extends BaseSDK {
|
|
|
482
603
|
}
|
|
483
604
|
class Page extends BaseSDK {
|
|
484
605
|
constructor(props, isCustomComponent = false) {
|
|
606
|
+
var _a;
|
|
485
607
|
super();
|
|
486
608
|
this.type = "Page";
|
|
487
609
|
this.popup = new Popup({});
|
|
488
610
|
this._id = props.pageId;
|
|
611
|
+
this._route = (_a = props.initialRoute) != null ? _a : "";
|
|
489
612
|
}
|
|
490
613
|
getParameter(key) {
|
|
491
614
|
return this._postMessageAsync(LISTENER_CMDS.GET_PAGE_PARAMS, {
|
|
@@ -522,6 +645,13 @@ class Page extends BaseSDK {
|
|
|
522
645
|
(data) => new Component(data)
|
|
523
646
|
);
|
|
524
647
|
}
|
|
648
|
+
setRoute(path) {
|
|
649
|
+
this._route = path;
|
|
650
|
+
return this._postMessage(LISTENER_CMDS.CC_SET_ROUTE, { route: path });
|
|
651
|
+
}
|
|
652
|
+
getRoute() {
|
|
653
|
+
return this._route;
|
|
654
|
+
}
|
|
525
655
|
}
|
|
526
656
|
class DecisionTable extends BaseSDK {
|
|
527
657
|
constructor(flowId) {
|
|
@@ -535,6 +665,341 @@ class DecisionTable extends BaseSDK {
|
|
|
535
665
|
});
|
|
536
666
|
}
|
|
537
667
|
}
|
|
668
|
+
const READ_TIMEOUT_MS = 75e3;
|
|
669
|
+
const EXECUTE_TIMEOUT_MS = 6e4;
|
|
670
|
+
const WATCH_ACK_TIMEOUT_MS = 6e4;
|
|
671
|
+
const WATCH_DEADLINE_MS = 42e4;
|
|
672
|
+
const TERMINAL_STATUSES = ["Completed", "Failed"];
|
|
673
|
+
function sdkError(errorCode, error) {
|
|
674
|
+
return { isError: true, error, errorCode };
|
|
675
|
+
}
|
|
676
|
+
function notify(callback, value) {
|
|
677
|
+
try {
|
|
678
|
+
callback == null ? void 0 : callback(value);
|
|
679
|
+
} catch (error) {
|
|
680
|
+
console.error(error);
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
const NOT_SENT = sdkError("AGENT_REQUEST_NOT_SENT", "The request could not be sent to the host.");
|
|
684
|
+
class Agent extends BaseSDK {
|
|
685
|
+
constructor(agentId) {
|
|
686
|
+
super();
|
|
687
|
+
this.activeWatches = 0;
|
|
688
|
+
this.agentId = agentId;
|
|
689
|
+
this._id = generateId("customagent");
|
|
690
|
+
}
|
|
691
|
+
getContract() {
|
|
692
|
+
return this._postMessageBounded(
|
|
693
|
+
LISTENER_CMDS.CUSTOM_AGENT_GET_CONTRACT,
|
|
694
|
+
{ agentId: this.agentId },
|
|
695
|
+
{
|
|
696
|
+
timeoutMs: READ_TIMEOUT_MS,
|
|
697
|
+
timeoutError: sdkError("AGENT_HOST_TIMEOUT", "The host did not answer the Agent contract request."),
|
|
698
|
+
sendError: NOT_SENT
|
|
699
|
+
}
|
|
700
|
+
).promise;
|
|
701
|
+
}
|
|
702
|
+
execute(options) {
|
|
703
|
+
var _a;
|
|
704
|
+
return this._postMessageBounded(
|
|
705
|
+
LISTENER_CMDS.CUSTOM_AGENT_EXECUTE,
|
|
706
|
+
{ agentId: this.agentId, inputData: (_a = options == null ? void 0 : options.inputData) != null ? _a : {} },
|
|
707
|
+
{
|
|
708
|
+
timeoutMs: EXECUTE_TIMEOUT_MS,
|
|
709
|
+
timeoutError: sdkError(
|
|
710
|
+
"AGENT_EXECUTE_OUTCOME_UNKNOWN",
|
|
711
|
+
"The host did not confirm the run; it may still have started."
|
|
712
|
+
),
|
|
713
|
+
sendError: sdkError("AGENT_EXECUTE_NOT_SENT", "The run request could not be sent to the host.")
|
|
714
|
+
}
|
|
715
|
+
).promise;
|
|
716
|
+
}
|
|
717
|
+
getExecution(executionId) {
|
|
718
|
+
return this._postMessageBounded(
|
|
719
|
+
LISTENER_CMDS.CUSTOM_AGENT_GET_EXECUTION,
|
|
720
|
+
{ agentId: this.agentId, executionId },
|
|
721
|
+
{
|
|
722
|
+
timeoutMs: READ_TIMEOUT_MS,
|
|
723
|
+
timeoutError: sdkError("AGENT_HOST_TIMEOUT", "The host did not answer the Agent execution request."),
|
|
724
|
+
sendError: NOT_SENT
|
|
725
|
+
}
|
|
726
|
+
).promise;
|
|
727
|
+
}
|
|
728
|
+
onExecutionComplete(executionId, onComplete, onWatchError) {
|
|
729
|
+
const watchId = generateId("agentwatch");
|
|
730
|
+
const eventName = `${EVENT_TYPES.CUSTOM_AGENT_EXECUTION_COMPLETE}:${watchId}`;
|
|
731
|
+
let settled = false;
|
|
732
|
+
let deadline = null;
|
|
733
|
+
let registration = null;
|
|
734
|
+
const end = () => {
|
|
735
|
+
settled = true;
|
|
736
|
+
if (deadline)
|
|
737
|
+
clearTimeout(deadline);
|
|
738
|
+
registration == null ? void 0 : registration.cancel();
|
|
739
|
+
this._removeEventListener(eventName);
|
|
740
|
+
this.activeWatches -= 1;
|
|
741
|
+
if (this.activeWatches === 0)
|
|
742
|
+
Reflect.deleteProperty(globalInstances, this._id);
|
|
743
|
+
};
|
|
744
|
+
const tellHostToStop = () => {
|
|
745
|
+
try {
|
|
746
|
+
this._postMessage(LISTENER_CMDS.CUSTOM_AGENT_STOP_WATCH, { id: this._id, watchId, eventName });
|
|
747
|
+
} catch {
|
|
748
|
+
}
|
|
749
|
+
};
|
|
750
|
+
const fail = (error) => {
|
|
751
|
+
if (settled)
|
|
752
|
+
return;
|
|
753
|
+
end();
|
|
754
|
+
tellHostToStop();
|
|
755
|
+
notify(onWatchError, error);
|
|
756
|
+
};
|
|
757
|
+
const listener = (params) => {
|
|
758
|
+
if (settled)
|
|
759
|
+
return;
|
|
760
|
+
if (params == null ? void 0 : params.isError) {
|
|
761
|
+
end();
|
|
762
|
+
notify(onWatchError, params);
|
|
763
|
+
return;
|
|
764
|
+
}
|
|
765
|
+
const execution = params;
|
|
766
|
+
if ((execution == null ? void 0 : execution.ExecutionId) !== executionId || TERMINAL_STATUSES.indexOf(execution == null ? void 0 : execution.Status) === -1) {
|
|
767
|
+
fail(sdkError("AGENT_WATCH_INVALID_EVENT", "The host reported something other than a finished run."));
|
|
768
|
+
return;
|
|
769
|
+
}
|
|
770
|
+
end();
|
|
771
|
+
notify(onComplete, execution);
|
|
772
|
+
};
|
|
773
|
+
this.activeWatches += 1;
|
|
774
|
+
globalInstances[this._id] = this;
|
|
775
|
+
this._addEventListener(eventName, listener);
|
|
776
|
+
registration = this._postMessageBounded(
|
|
777
|
+
LISTENER_CMDS.CUSTOM_AGENT_WATCH_EXECUTION,
|
|
778
|
+
{ id: this._id, agentId: this.agentId, executionId, watchId, eventName },
|
|
779
|
+
{
|
|
780
|
+
timeoutMs: WATCH_ACK_TIMEOUT_MS,
|
|
781
|
+
timeoutError: sdkError("AGENT_HOST_UNSUPPORTED", "The host did not start observing the Agent run."),
|
|
782
|
+
sendError: NOT_SENT
|
|
783
|
+
}
|
|
784
|
+
);
|
|
785
|
+
registration.promise.then(
|
|
786
|
+
(acknowledged) => {
|
|
787
|
+
if (settled)
|
|
788
|
+
return;
|
|
789
|
+
if (acknowledged !== true) {
|
|
790
|
+
fail(sdkError("AGENT_HOST_UNSUPPORTED", "The host did not start observing the Agent run."));
|
|
791
|
+
return;
|
|
792
|
+
}
|
|
793
|
+
deadline = setTimeout(
|
|
794
|
+
() => fail(sdkError("AGENT_OBSERVATION_STOPPED", "Stopped checking the Agent run; read it again later.")),
|
|
795
|
+
WATCH_DEADLINE_MS
|
|
796
|
+
);
|
|
797
|
+
},
|
|
798
|
+
(error) => fail(error)
|
|
799
|
+
);
|
|
800
|
+
return () => {
|
|
801
|
+
if (settled)
|
|
802
|
+
return;
|
|
803
|
+
end();
|
|
804
|
+
tellHostToStop();
|
|
805
|
+
};
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
class Form extends BaseSDK {
|
|
809
|
+
constructor(storeId, flowId, instanceId, activityInstanceId) {
|
|
810
|
+
super();
|
|
811
|
+
this.type = "Form";
|
|
812
|
+
this.storeId = storeId;
|
|
813
|
+
this.flowId = flowId;
|
|
814
|
+
this.instanceId = instanceId;
|
|
815
|
+
this.activityInstanceId = activityInstanceId;
|
|
816
|
+
}
|
|
817
|
+
toJSON() {
|
|
818
|
+
return this._postMessageAsync(LISTENER_CMDS.TO_JSON, {
|
|
819
|
+
storeId: this.storeId,
|
|
820
|
+
instanceId: this.instanceId
|
|
821
|
+
});
|
|
822
|
+
}
|
|
823
|
+
getField(fieldId) {
|
|
824
|
+
return this._postMessageAsync(LISTENER_CMDS.GET_FORM_FIELD, {
|
|
825
|
+
storeId: this.storeId,
|
|
826
|
+
instanceId: this.instanceId,
|
|
827
|
+
fieldId
|
|
828
|
+
});
|
|
829
|
+
}
|
|
830
|
+
updateField(args) {
|
|
831
|
+
return this._postMessageAsync(LISTENER_CMDS.UPDATE_FORM, {
|
|
832
|
+
storeId: this.storeId,
|
|
833
|
+
instanceId: this.instanceId,
|
|
834
|
+
data: args
|
|
835
|
+
});
|
|
836
|
+
}
|
|
837
|
+
getValidationErrors() {
|
|
838
|
+
return this._postMessageAsync(
|
|
839
|
+
LISTENER_CMDS.GET_FORM_VALIDATION_ERRORS,
|
|
840
|
+
{
|
|
841
|
+
storeId: this.storeId,
|
|
842
|
+
instanceId: this.instanceId
|
|
843
|
+
}
|
|
844
|
+
);
|
|
845
|
+
}
|
|
846
|
+
getFormConfiguration() {
|
|
847
|
+
return this._postMessageAsync(LISTENER_CMDS.GET_FORM_CONFIGURATION, {
|
|
848
|
+
storeId: this.storeId,
|
|
849
|
+
instanceId: this.instanceId
|
|
850
|
+
});
|
|
851
|
+
}
|
|
852
|
+
getFieldState() {
|
|
853
|
+
return this._postMessageAsync(LISTENER_CMDS.GET_FORM_FIELD_STATE, {
|
|
854
|
+
storeId: this.storeId,
|
|
855
|
+
instanceId: this.instanceId
|
|
856
|
+
});
|
|
857
|
+
}
|
|
858
|
+
getTable(tableId) {
|
|
859
|
+
return new Table(
|
|
860
|
+
this.storeId,
|
|
861
|
+
this.flowId,
|
|
862
|
+
this.instanceId,
|
|
863
|
+
tableId,
|
|
864
|
+
this.activityInstanceId
|
|
865
|
+
);
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
class Table extends BaseSDK {
|
|
869
|
+
constructor(storeId, flowId, instanceId, tableId, activityInstanceId) {
|
|
870
|
+
super();
|
|
871
|
+
this.tableId = tableId;
|
|
872
|
+
this.storeId = storeId;
|
|
873
|
+
this.flowId = flowId;
|
|
874
|
+
this.instanceId = instanceId;
|
|
875
|
+
this.activityInstanceId = activityInstanceId;
|
|
876
|
+
}
|
|
877
|
+
toJSON() {
|
|
878
|
+
return this._postMessageAsync(LISTENER_CMDS.TO_JSON, {
|
|
879
|
+
storeId: this.storeId,
|
|
880
|
+
instanceId: this.instanceId,
|
|
881
|
+
tableId: this.tableId
|
|
882
|
+
});
|
|
883
|
+
}
|
|
884
|
+
getSelectedRows() {
|
|
885
|
+
return this._postMessageAsync(LISTENER_CMDS.GET_SELECTED_TABLE_ROWS, {
|
|
886
|
+
storeId: this.storeId,
|
|
887
|
+
instanceId: this.instanceId,
|
|
888
|
+
tableId: this.tableId
|
|
889
|
+
});
|
|
890
|
+
}
|
|
891
|
+
getRows() {
|
|
892
|
+
return this._postMessageAsync(
|
|
893
|
+
LISTENER_CMDS.GET_TABLE_ROWS,
|
|
894
|
+
{
|
|
895
|
+
storeId: this.storeId,
|
|
896
|
+
instanceId: this.instanceId,
|
|
897
|
+
tableId: this.tableId
|
|
898
|
+
},
|
|
899
|
+
true,
|
|
900
|
+
(data) => {
|
|
901
|
+
return data.map(
|
|
902
|
+
(row) => new TableForm(
|
|
903
|
+
this.storeId,
|
|
904
|
+
this.flowId,
|
|
905
|
+
this.instanceId,
|
|
906
|
+
this.tableId,
|
|
907
|
+
row.id,
|
|
908
|
+
this.activityInstanceId
|
|
909
|
+
)
|
|
910
|
+
);
|
|
911
|
+
}
|
|
912
|
+
);
|
|
913
|
+
}
|
|
914
|
+
getRow(rowId) {
|
|
915
|
+
return new TableForm(
|
|
916
|
+
this.storeId,
|
|
917
|
+
this.flowId,
|
|
918
|
+
this.instanceId,
|
|
919
|
+
this.tableId,
|
|
920
|
+
rowId,
|
|
921
|
+
this.activityInstanceId
|
|
922
|
+
);
|
|
923
|
+
}
|
|
924
|
+
addRow(rowObject) {
|
|
925
|
+
return this._postMessageAsync(LISTENER_CMDS.ADD_TABLE_ROW, {
|
|
926
|
+
storeId: this.storeId,
|
|
927
|
+
instanceId: this.instanceId,
|
|
928
|
+
tableId: this.tableId,
|
|
929
|
+
rowObject
|
|
930
|
+
});
|
|
931
|
+
}
|
|
932
|
+
addRows(rows) {
|
|
933
|
+
return this._postMessageAsync(LISTENER_CMDS.ADD_TABLE_ROWS, {
|
|
934
|
+
storeId: this.storeId,
|
|
935
|
+
instanceId: this.instanceId,
|
|
936
|
+
tableId: this.tableId,
|
|
937
|
+
rows
|
|
938
|
+
});
|
|
939
|
+
}
|
|
940
|
+
deleteRow(rowId) {
|
|
941
|
+
return this._postMessageAsync(LISTENER_CMDS.DELETE_TABLE_ROW, {
|
|
942
|
+
storeId: this.storeId,
|
|
943
|
+
instanceId: this.instanceId,
|
|
944
|
+
tableId: this.tableId,
|
|
945
|
+
rows: [rowId]
|
|
946
|
+
});
|
|
947
|
+
}
|
|
948
|
+
deleteRows(rows) {
|
|
949
|
+
return this._postMessageAsync(LISTENER_CMDS.DELETE_TABLE_ROW, {
|
|
950
|
+
storeId: this.storeId,
|
|
951
|
+
instanceId: this.instanceId,
|
|
952
|
+
tableId: this.tableId,
|
|
953
|
+
rows
|
|
954
|
+
});
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
class TableForm extends BaseSDK {
|
|
958
|
+
constructor(storeId, flowId, instanceId, tableId, rowId, activityInstanceId) {
|
|
959
|
+
super();
|
|
960
|
+
this.storeId = storeId;
|
|
961
|
+
this.flowId = flowId;
|
|
962
|
+
this.instanceId = instanceId;
|
|
963
|
+
this.type = "TabelForm";
|
|
964
|
+
this.tableId = tableId;
|
|
965
|
+
this.rowId = rowId;
|
|
966
|
+
this.activityInstanceId = activityInstanceId;
|
|
967
|
+
}
|
|
968
|
+
getParent() {
|
|
969
|
+
return new Form(
|
|
970
|
+
this.storeId,
|
|
971
|
+
this.flowId,
|
|
972
|
+
this.instanceId,
|
|
973
|
+
this.activityInstanceId
|
|
974
|
+
);
|
|
975
|
+
}
|
|
976
|
+
toJSON() {
|
|
977
|
+
return this._postMessageAsync(LISTENER_CMDS.TO_JSON, {
|
|
978
|
+
storeId: this.storeId,
|
|
979
|
+
instanceId: this.instanceId,
|
|
980
|
+
tableId: this.tableId,
|
|
981
|
+
rowId: this.rowId
|
|
982
|
+
});
|
|
983
|
+
}
|
|
984
|
+
getField(fieldId) {
|
|
985
|
+
return this._postMessageAsync(LISTENER_CMDS.GET_FORM_FIELD, {
|
|
986
|
+
storeId: this.storeId,
|
|
987
|
+
instanceId: this.instanceId,
|
|
988
|
+
tableId: this.tableId,
|
|
989
|
+
rowId: this.rowId,
|
|
990
|
+
fieldId
|
|
991
|
+
});
|
|
992
|
+
}
|
|
993
|
+
updateField(args) {
|
|
994
|
+
return this._postMessageAsync(LISTENER_CMDS.UPDATE_FORM, {
|
|
995
|
+
storeId: this.storeId,
|
|
996
|
+
instanceId: this.instanceId,
|
|
997
|
+
tableId: this.tableId,
|
|
998
|
+
rowId: this.rowId,
|
|
999
|
+
data: args
|
|
1000
|
+
});
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
538
1003
|
class Dataform extends BaseSDK {
|
|
539
1004
|
constructor(flowId) {
|
|
540
1005
|
super();
|
|
@@ -627,6 +1092,32 @@ class Dataform extends BaseSDK {
|
|
|
627
1092
|
viewId: (options == null ? void 0 : options.viewId) || ""
|
|
628
1093
|
});
|
|
629
1094
|
}
|
|
1095
|
+
initForm(instanceId, viewId) {
|
|
1096
|
+
return this._postMessageAsync(LISTENER_CMDS.DATAFORM_INIT_FORM, {
|
|
1097
|
+
flowId: this._id,
|
|
1098
|
+
instanceId: instanceId || "",
|
|
1099
|
+
viewId: viewId || ""
|
|
1100
|
+
}).then((response) => {
|
|
1101
|
+
return new Form(
|
|
1102
|
+
response.storeId || instanceId || "",
|
|
1103
|
+
this._id,
|
|
1104
|
+
response.itemId || instanceId
|
|
1105
|
+
);
|
|
1106
|
+
});
|
|
1107
|
+
}
|
|
1108
|
+
getFieldOptions(options) {
|
|
1109
|
+
return this._postMessageAsync(
|
|
1110
|
+
LISTENER_CMDS.DATAFORM_GET_FIELD_OPTIONS,
|
|
1111
|
+
{
|
|
1112
|
+
flowId: this._id,
|
|
1113
|
+
instanceId: (options == null ? void 0 : options.instanceId) || "",
|
|
1114
|
+
fieldId: (options == null ? void 0 : options.fieldId) || "",
|
|
1115
|
+
fieldType: options == null ? void 0 : options.fieldType,
|
|
1116
|
+
tableId: options == null ? void 0 : options.tableId,
|
|
1117
|
+
tableRowId: options == null ? void 0 : options.tableRowId
|
|
1118
|
+
}
|
|
1119
|
+
);
|
|
1120
|
+
}
|
|
630
1121
|
}
|
|
631
1122
|
class Board extends BaseSDK {
|
|
632
1123
|
constructor(flowId) {
|
|
@@ -717,6 +1208,35 @@ class Board extends BaseSDK {
|
|
|
717
1208
|
viewId: (options == null ? void 0 : options.viewId) || ""
|
|
718
1209
|
});
|
|
719
1210
|
}
|
|
1211
|
+
initForm(instanceId, viewId) {
|
|
1212
|
+
return this._postMessageAsync(LISTENER_CMDS.BOARD_INIT_FORM, {
|
|
1213
|
+
flowId: this._id,
|
|
1214
|
+
instanceId: instanceId || "",
|
|
1215
|
+
viewId: viewId || ""
|
|
1216
|
+
}).then((response) => {
|
|
1217
|
+
return new Form(
|
|
1218
|
+
response.storeId || instanceId || "",
|
|
1219
|
+
this._id,
|
|
1220
|
+
response.itemId || instanceId
|
|
1221
|
+
);
|
|
1222
|
+
});
|
|
1223
|
+
}
|
|
1224
|
+
getFieldOptions(options) {
|
|
1225
|
+
const error = requireFieldsAsync([
|
|
1226
|
+
{ value: options.instanceId, name: "instanceId" },
|
|
1227
|
+
{ value: options.fieldId, name: "fieldId" }
|
|
1228
|
+
]);
|
|
1229
|
+
if (error)
|
|
1230
|
+
return error;
|
|
1231
|
+
return this._postMessageAsync(LISTENER_CMDS.BOARD_GET_FIELD_OPTIONS, {
|
|
1232
|
+
flowId: this._id,
|
|
1233
|
+
instanceId: options.instanceId,
|
|
1234
|
+
fieldId: options.fieldId,
|
|
1235
|
+
fieldType: options.fieldType,
|
|
1236
|
+
tableId: options == null ? void 0 : options.tableId,
|
|
1237
|
+
tableRowId: options == null ? void 0 : options.tableRowId
|
|
1238
|
+
});
|
|
1239
|
+
}
|
|
720
1240
|
}
|
|
721
1241
|
class Process extends BaseSDK {
|
|
722
1242
|
constructor(flowId) {
|
|
@@ -769,12 +1289,16 @@ class Process extends BaseSDK {
|
|
|
769
1289
|
});
|
|
770
1290
|
}
|
|
771
1291
|
getItem(options) {
|
|
772
|
-
const error =
|
|
1292
|
+
const error = requireFieldsAsync([
|
|
1293
|
+
{ value: options.instanceId, name: "instanceId" },
|
|
1294
|
+
{ value: options.activityInstanceId, name: "activityInstanceId" }
|
|
1295
|
+
]);
|
|
773
1296
|
if (error)
|
|
774
1297
|
return error;
|
|
775
1298
|
return this._postMessageAsync(LISTENER_CMDS.PROCESS_GET_ITEM, {
|
|
776
1299
|
flowId: this._id,
|
|
777
|
-
instanceId: options.instanceId
|
|
1300
|
+
instanceId: options.instanceId,
|
|
1301
|
+
activityInstanceId: options.activityInstanceId
|
|
778
1302
|
});
|
|
779
1303
|
}
|
|
780
1304
|
createItem(options) {
|
|
@@ -806,6 +1330,28 @@ class Process extends BaseSDK {
|
|
|
806
1330
|
instanceId: options.instanceId
|
|
807
1331
|
});
|
|
808
1332
|
}
|
|
1333
|
+
getAdminItem(options) {
|
|
1334
|
+
const error = requireFieldAsync(options.instanceId, "instanceId");
|
|
1335
|
+
if (error)
|
|
1336
|
+
return error;
|
|
1337
|
+
return this._postMessageAsync(LISTENER_CMDS.PROCESS_GET_ADMIN_ITEM, {
|
|
1338
|
+
flowId: this._id,
|
|
1339
|
+
instanceId: options.instanceId
|
|
1340
|
+
});
|
|
1341
|
+
}
|
|
1342
|
+
updateAdminItem(options) {
|
|
1343
|
+
const error = requireFieldsAsync([
|
|
1344
|
+
{ value: options.instanceId, name: "instanceId" },
|
|
1345
|
+
{ value: options.data, name: "data" }
|
|
1346
|
+
]);
|
|
1347
|
+
if (error)
|
|
1348
|
+
return error;
|
|
1349
|
+
return this._postMessageAsync(LISTENER_CMDS.PROCESS_UPDATE_ADMIN_ITEM, {
|
|
1350
|
+
flowId: this._id,
|
|
1351
|
+
instanceId: options.instanceId,
|
|
1352
|
+
data: options.data
|
|
1353
|
+
});
|
|
1354
|
+
}
|
|
809
1355
|
openForm(item) {
|
|
810
1356
|
const error = requireFieldsAsync([
|
|
811
1357
|
{ value: item._id, name: "Instance Id (_id)" },
|
|
@@ -975,6 +1521,48 @@ class Process extends BaseSDK {
|
|
|
975
1521
|
instanceId: options.instanceId
|
|
976
1522
|
});
|
|
977
1523
|
}
|
|
1524
|
+
initForm(instanceId, activityInstanceId) {
|
|
1525
|
+
return this._postMessageAsync(LISTENER_CMDS.PROCESS_INIT_FORM, {
|
|
1526
|
+
flowId: this._id,
|
|
1527
|
+
instanceId: instanceId || "",
|
|
1528
|
+
activityInstanceId: activityInstanceId || ""
|
|
1529
|
+
}).then((response) => {
|
|
1530
|
+
return new Form(
|
|
1531
|
+
response.storeId || instanceId || "",
|
|
1532
|
+
this._id,
|
|
1533
|
+
response.itemId || instanceId,
|
|
1534
|
+
response.activityInstanceId || activityInstanceId
|
|
1535
|
+
);
|
|
1536
|
+
});
|
|
1537
|
+
}
|
|
1538
|
+
getFieldOptions(options) {
|
|
1539
|
+
return this._postMessageAsync(LISTENER_CMDS.PROCESS_GET_FIELD_OPTIONS, {
|
|
1540
|
+
flowId: this._id,
|
|
1541
|
+
instanceId: (options == null ? void 0 : options.instanceId) || "",
|
|
1542
|
+
activityInstanceId: (options == null ? void 0 : options.activityInstanceId) || "",
|
|
1543
|
+
fieldId: (options == null ? void 0 : options.fieldId) || "",
|
|
1544
|
+
fieldType: options == null ? void 0 : options.fieldType,
|
|
1545
|
+
tableId: options == null ? void 0 : options.tableId,
|
|
1546
|
+
tableRowId: options == null ? void 0 : options.tableRowId
|
|
1547
|
+
});
|
|
1548
|
+
}
|
|
1549
|
+
parseAttachment(options) {
|
|
1550
|
+
const error = requireFieldsAsync([
|
|
1551
|
+
{ value: options.instanceId, name: "instanceId" },
|
|
1552
|
+
{ value: options.activityInstanceId, name: "activityInstanceId" },
|
|
1553
|
+
{ value: options.fieldId, name: "fieldId" },
|
|
1554
|
+
{ value: options.file, name: "file" }
|
|
1555
|
+
]);
|
|
1556
|
+
if (error)
|
|
1557
|
+
return error;
|
|
1558
|
+
return this._postMessageAsync(LISTENER_CMDS.PROCESS_PARSE_ATTACHMENT, {
|
|
1559
|
+
flowId: this._id,
|
|
1560
|
+
instanceId: options.instanceId,
|
|
1561
|
+
activityInstanceId: options.activityInstanceId,
|
|
1562
|
+
fieldId: options.fieldId,
|
|
1563
|
+
file: options.file
|
|
1564
|
+
});
|
|
1565
|
+
}
|
|
978
1566
|
}
|
|
979
1567
|
class Application extends BaseSDK {
|
|
980
1568
|
constructor(props, isCustomComponent = false) {
|
|
@@ -1002,6 +1590,9 @@ class Application extends BaseSDK {
|
|
|
1002
1590
|
getDecisionTable(flowId) {
|
|
1003
1591
|
return new DecisionTable(flowId);
|
|
1004
1592
|
}
|
|
1593
|
+
getAgent(agentId) {
|
|
1594
|
+
return new Agent(agentId);
|
|
1595
|
+
}
|
|
1005
1596
|
getDataform(flowId) {
|
|
1006
1597
|
return new Dataform(flowId);
|
|
1007
1598
|
}
|
|
@@ -1011,6 +1602,15 @@ class Application extends BaseSDK {
|
|
|
1011
1602
|
getProcess(flowId) {
|
|
1012
1603
|
return new Process(flowId);
|
|
1013
1604
|
}
|
|
1605
|
+
getRoles() {
|
|
1606
|
+
return this._postMessageAsync(LISTENER_CMDS.GET_ROLES, {});
|
|
1607
|
+
}
|
|
1608
|
+
switchRole(args) {
|
|
1609
|
+
return this._postMessageAsync(LISTENER_CMDS.SWITCH_ROLE, {
|
|
1610
|
+
roleId: args.roleId,
|
|
1611
|
+
roleName: args.roleName
|
|
1612
|
+
});
|
|
1613
|
+
}
|
|
1014
1614
|
}
|
|
1015
1615
|
class CustomComponentSDK extends BaseSDK {
|
|
1016
1616
|
constructor() {
|