@kissflow/lowcode-client-sdk 1.0.49 → 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 +190 -0
- package/dist/kfsdk.es.js +203 -4
- package/dist/kfsdk.umd.js +1 -1
- package/dist/lowcode.d.ts +190 -0
- package/dist/lowcode.types.d.ts +149 -0
- package/dist/nocode.d.ts +190 -0
- package/dist/nocode.types.d.ts +93 -0
- package/dist/snippets.json +5 -0
- package/package.json +4 -2
- package/dist/kf.lowcodeworkersdk.es.js +0 -1510
|
@@ -1,1510 +0,0 @@
|
|
|
1
|
-
var __accessCheck = (obj, member, msg) => {
|
|
2
|
-
if (!member.has(obj))
|
|
3
|
-
throw TypeError("Cannot " + msg);
|
|
4
|
-
};
|
|
5
|
-
var __privateGet = (obj, member, getter) => {
|
|
6
|
-
__accessCheck(obj, member, "read from private field");
|
|
7
|
-
return getter ? getter.call(obj) : member.get(obj);
|
|
8
|
-
};
|
|
9
|
-
var __privateAdd = (obj, member, value) => {
|
|
10
|
-
if (member.has(obj))
|
|
11
|
-
throw TypeError("Cannot add the same private member more than once");
|
|
12
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
13
|
-
};
|
|
14
|
-
var __privateSet = (obj, member, value, setter) => {
|
|
15
|
-
__accessCheck(obj, member, "write to private field");
|
|
16
|
-
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
17
|
-
return value;
|
|
18
|
-
};
|
|
19
|
-
var __privateMethod = (obj, member, method) => {
|
|
20
|
-
__accessCheck(obj, member, "access private method");
|
|
21
|
-
return method;
|
|
22
|
-
};
|
|
23
|
-
var _listeners, _textEncoder, _textDecoder, _registerComponentAPIs, registerComponentAPIs_fn, _csrfToken;
|
|
24
|
-
let nanoid = (size = 21) => crypto.getRandomValues(new Uint8Array(size)).reduce((id, byte) => {
|
|
25
|
-
byte &= 63;
|
|
26
|
-
if (byte < 36) {
|
|
27
|
-
id += byte.toString(36);
|
|
28
|
-
} else if (byte < 62) {
|
|
29
|
-
id += (byte - 26).toString(36).toUpperCase();
|
|
30
|
-
} else if (byte > 62) {
|
|
31
|
-
id += "-";
|
|
32
|
-
} else {
|
|
33
|
-
id += "_";
|
|
34
|
-
}
|
|
35
|
-
return id;
|
|
36
|
-
}, "");
|
|
37
|
-
const LISTENER_CMDS = {
|
|
38
|
-
API: "API",
|
|
39
|
-
GET_CONTEXT: "GET_CONTEXT",
|
|
40
|
-
RETURN: "RETURN",
|
|
41
|
-
GET_FORM_FIELD: "GET_FORM_FIELD",
|
|
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",
|
|
46
|
-
GET_TABLE: "GET_TABLE",
|
|
47
|
-
GET_TABLE_ROW: "GET_TABLE_ROW",
|
|
48
|
-
ADD_TABLE_ROW: "ADD_TABLE_ROW",
|
|
49
|
-
ADD_TABLE_ROWS: "ADD_TABLE_ROWS",
|
|
50
|
-
DELETE_TABLE_ROW: "DELETE_TABLE_ROW",
|
|
51
|
-
TO_JSON: "TO_JSON",
|
|
52
|
-
GET_TABLE_ROWS: "GET_TABLE_ROWS",
|
|
53
|
-
GET_SELECTED_TABLE_ROWS: "GET_SELECTED_TABLE_ROWS",
|
|
54
|
-
MESSAGE: "MESSAGE",
|
|
55
|
-
CONFIRM: "CONFIRM",
|
|
56
|
-
ALERT: "ALERT",
|
|
57
|
-
REDIRECT: "REDIRECT",
|
|
58
|
-
OPEN_PAGE: "OPEN_PAGE",
|
|
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",
|
|
67
|
-
FORMAT_DATE: "FORMAT_DATE",
|
|
68
|
-
FORMAT_DATE_TIME: "FORMAT_DATE_TIME",
|
|
69
|
-
FORMAT_NUMBER: "FORMAT_NUMBER",
|
|
70
|
-
FORMAT_CURRENCY: "FORMAT_CURRENCY",
|
|
71
|
-
FORMAT_BOOLEAN: "FORMAT_BOOLEAN",
|
|
72
|
-
GET_APP_VARIABLE: "GET_APP_VARIABLE",
|
|
73
|
-
SET_APP_VARIABLE: "SET_APP_VARIABLE",
|
|
74
|
-
GET_PAGE_VARIABLE: "GET_PAGE_VARIABLE",
|
|
75
|
-
SET_PAGE_VARIABLE: "SET_PAGE_VARIABLE",
|
|
76
|
-
GET_PAGE_PARAMS: "GET_PAGE_PARAMS",
|
|
77
|
-
GET_ALL_PAGE_PARAMS: "GET_ALL_PAGE_PARAMS",
|
|
78
|
-
PAGE_ON_CLOSE: "PAGE_ON_CLOSE",
|
|
79
|
-
OPEN_POPUP: "OPEN_POPUP",
|
|
80
|
-
GET_POPUP_PARAMS: "GET_POPUP_PARAMS",
|
|
81
|
-
GET_ALL_POPUP_PARAMS: "GET_ALL_POPUP_PARAMS",
|
|
82
|
-
CLOSE_POPUP: "CLOSE_POPUP",
|
|
83
|
-
COMPONENT_GET: "COMPONENT_GET",
|
|
84
|
-
COMPONENT_REFRESH: "COMPONENT_REFRESH",
|
|
85
|
-
COMPONENT_SHOW: "COMPONENT_SHOW",
|
|
86
|
-
COMPONENT_HIDE: "COMPONENT_HIDE",
|
|
87
|
-
COMPONENT_ADD_EVENT_LISTENER: "COMPONENT_ADD_EVENT_LISTENER",
|
|
88
|
-
CC_INITIALIZE: "CC_INITIALIZE",
|
|
89
|
-
CC_WATCH_PARAMS: "CC_WATCH_PARAMS",
|
|
90
|
-
CC_SET_ROUTE: "CC_SET_ROUTE",
|
|
91
|
-
CC_WATCH_ROUTE: "CC_WATCH_ROUTE",
|
|
92
|
-
WINDOW_NDEF_READER_NEW: "WINDOW_NDEF_READER_NEW",
|
|
93
|
-
WINDOW_NDEF_READER_SCAN: "WINDOW_NDEF_READER_SCAN",
|
|
94
|
-
WINDOW_NDEF_READER_WRITE: "WINDOW_NDEF_READER_WRITE",
|
|
95
|
-
WINDOW_NDEF_READER_ADD_EVENT_LISTENER: "WINDOW_NDEF_READER_ADD_EVENT_LISTENER",
|
|
96
|
-
WINDOW_NDEF_READER_MAKE_READONLY: "WINDOW_NDEF_READER_MAKE_READONLY",
|
|
97
|
-
WINDOW_NDEF_READER_ABORT_SCAN: "WINDOW_NDEF_READER_ABORT_SCAN",
|
|
98
|
-
DECISION_TABLE_EXECUTE: "DECISION_TABLE_EXECUTE",
|
|
99
|
-
DATAFORM_IMPORT_CSV: "DATAFORM_IMPORT_CSV",
|
|
100
|
-
DATAFORM_OPEN_FORM: "DATAFORM_OPEN_FORM",
|
|
101
|
-
DATAFORM_GET_FIELDS: "DATAFORM_GET_FIELDS",
|
|
102
|
-
DATAFORM_GET_ITEMS: "DATAFORM_GET_ITEMS",
|
|
103
|
-
DATAFORM_CREATE_ITEM: "DATAFORM_CREATE_ITEM",
|
|
104
|
-
DATAFORM_UPDATE_ITEM: "DATAFORM_UPDATE_ITEM",
|
|
105
|
-
DATAFORM_GET_ITEM: "DATAFORM_GET_ITEM",
|
|
106
|
-
DATAFORM_DELETE_ITEM: "DATAFORM_DELETE_ITEM",
|
|
107
|
-
DATAFORM_DISCARD_ITEM: "DATAFORM_DISCARD_ITEM",
|
|
108
|
-
DATAFORM_SUBMIT_ITEM: "DATAFORM_SUBMIT_ITEM",
|
|
109
|
-
DATAFORM_INIT_FORM: "DATAFORM_INIT_FORM",
|
|
110
|
-
DATAFORM_GET_FIELD_OPTIONS: "DATAFORM_GET_FIELD_OPTIONS",
|
|
111
|
-
PROCESS_OPEN_FORM: "PROCESS_OPEN_FORM",
|
|
112
|
-
PROCESS_GET_FIELDS: "PROCESS_GET_FIELDS",
|
|
113
|
-
PROCESS_GET_MYTASK_FIELDS: "PROCESS_GET_MYTASK_FIELDS",
|
|
114
|
-
PROCESS_GET_PARTICIPATED_FIELDS: "PROCESS_GET_PARTICIPATED_FIELDS",
|
|
115
|
-
PROCESS_GET_MY_ITEMS_FIELDS: "PROCESS_GET_MY_ITEMS_FIELDS",
|
|
116
|
-
PROCESS_GET_MY_ITEMS: "PROCESS_GET_MY_ITEMS",
|
|
117
|
-
PROCESS_GET_MY_TASKS_ITEMS: "PROCESS_GET_MY_TASKS_ITEMS",
|
|
118
|
-
PROCESS_GET_PARTICIPATED_ITEMS: "PROCESS_GET_PARTICIPATED_ITEMS",
|
|
119
|
-
PROCESS_GET_ADMIN_ITEMS: "PROCESS_GET_ADMIN_ITEMS",
|
|
120
|
-
PROCESS_CREATE_ITEM: "PROCESS_CREATE_ITEM",
|
|
121
|
-
PROCESS_UPDATE_ITEM: "PROCESS_UPDATE_ITEM",
|
|
122
|
-
PROCESS_GET_ITEM: "PROCESS_GET_ITEM",
|
|
123
|
-
PROCESS_DELETE_ITEM: "PROCESS_DELETE_ITEM",
|
|
124
|
-
PROCESS_GET_ADMIN_ITEM: "PROCESS_GET_ADMIN_ITEM",
|
|
125
|
-
PROCESS_UPDATE_ADMIN_ITEM: "PROCESS_UPDATE_ADMIN_ITEM",
|
|
126
|
-
PROCESS_SUBMIT_ITEM: "PROCESS_SUBMIT_ITEM",
|
|
127
|
-
PROCESS_REJECT_ITEM: "PROCESS_REJECT_ITEM",
|
|
128
|
-
PROCESS_WITHDRAW_ITEM: "PROCESS_WITHDRAW_ITEM",
|
|
129
|
-
PROCESS_SENDBACK_ITEM: "PROCESS_SENDBACK_ITEM",
|
|
130
|
-
PROCESS_REASSIGN_ITEM: "PROCESS_REASSIGN_ITEM",
|
|
131
|
-
PROCESS_GET_REASSIGNEES: "PROCESS_GET_REASSIGNEES",
|
|
132
|
-
PROCESS_RESTART_ITEM: "PROCESS_RESTART_ITEM",
|
|
133
|
-
PROCESS_DISCARD_ITEM: "PROCESS_DISCARD_ITEM",
|
|
134
|
-
PROCESS_GET_PROGRESS: "PROCESS_GET_PROGRESS",
|
|
135
|
-
PROCESS_INIT_FORM: "PROCESS_INIT_FORM",
|
|
136
|
-
PROCESS_GET_FIELD_OPTIONS: "PROCESS_GET_FIELD_OPTIONS",
|
|
137
|
-
PROCESS_PARSE_ATTACHMENT: "PROCESS_PARSE_ATTACHMENT",
|
|
138
|
-
BOARD_IMPORT_CSV: "BOARD_IMPORT_CSV",
|
|
139
|
-
BOARD_OPEN_FORM: "BOARD_OPEN_FORM",
|
|
140
|
-
BOARD_GET_FIELDS: "BOARD_GET_FIELDS",
|
|
141
|
-
BOARD_GET_ITEMS: "BOARD_GET_ITEMS",
|
|
142
|
-
BOARD_CREATE_ITEM: "BOARD_CREATE_ITEM",
|
|
143
|
-
BOARD_UPDATE_ITEM: "BOARD_UPDATE_ITEM",
|
|
144
|
-
BOARD_GET_ITEM: "BOARD_GET_ITEM",
|
|
145
|
-
BOARD_DELETE_ITEM: "BOARD_DELETE_ITEM",
|
|
146
|
-
BOARD_SUBMIT_ITEM: "BOARD_SUBMIT_ITEM",
|
|
147
|
-
BOARD_DISCARD_ITEM: "BOARD_DISCARD_ITEM",
|
|
148
|
-
BOARD_INIT_FORM: "BOARD_INIT_FORM",
|
|
149
|
-
BOARD_GET_FIELD_OPTIONS: "BOARD_GET_FIELD_OPTIONS"
|
|
150
|
-
};
|
|
151
|
-
const EVENT_TYPES = {
|
|
152
|
-
COMPONENT_ON_MOUNT: "componentOnMount",
|
|
153
|
-
CC_ON_PARAMS_CHANGE: "onCustomComponentParamsChange",
|
|
154
|
-
CC_ON_ROUTE_CHANGE: "onCustomComponentRouteChange"
|
|
155
|
-
};
|
|
156
|
-
const DEFAULTS = {
|
|
157
|
-
POPUP_ID: "ACTIVE_POP_UP"
|
|
158
|
-
};
|
|
159
|
-
function generateId(prefix = "lcncsdk") {
|
|
160
|
-
return `${prefix}-${nanoid()}`;
|
|
161
|
-
}
|
|
162
|
-
const globalInstances = {};
|
|
163
|
-
function processResponse(req, resp) {
|
|
164
|
-
if (resp && Object.keys(resp).length === 1 && req.command !== LISTENER_CMDS.API) {
|
|
165
|
-
let value = Object.values(resp)[0];
|
|
166
|
-
if (value === "undefined")
|
|
167
|
-
return void 0;
|
|
168
|
-
return value;
|
|
169
|
-
} else {
|
|
170
|
-
return resp;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
function postMessage(args) {
|
|
174
|
-
if (globalThis.parent && globalThis.parent !== globalThis) {
|
|
175
|
-
globalThis.parent.postMessage(args, "*");
|
|
176
|
-
} else {
|
|
177
|
-
globalThis.postMessage(args);
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
function onMessage(event) {
|
|
181
|
-
if (event.origin !== globalThis.location.origin) {
|
|
182
|
-
const data = event.data;
|
|
183
|
-
if (data == null ? void 0 : data.isEvent) {
|
|
184
|
-
const { target, eventParams, eventName, eventConfig = {} } = data;
|
|
185
|
-
let targetInstance = globalInstances[target];
|
|
186
|
-
targetInstance._dispatchEvent(eventName, eventParams);
|
|
187
|
-
if (eventConfig.once) {
|
|
188
|
-
targetInstance._removeEventListener(eventName);
|
|
189
|
-
}
|
|
190
|
-
return;
|
|
191
|
-
}
|
|
192
|
-
let { _req: req, resp } = data;
|
|
193
|
-
if (req == null ? void 0 : req._id) {
|
|
194
|
-
let targetInstance = globalInstances[req._id];
|
|
195
|
-
targetInstance._dispatchMessageEvents(req, resp);
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
globalThis.addEventListener("message", onMessage);
|
|
200
|
-
class EventBase {
|
|
201
|
-
constructor() {
|
|
202
|
-
__privateAdd(this, _listeners, void 0);
|
|
203
|
-
__privateSet(this, _listeners, {});
|
|
204
|
-
}
|
|
205
|
-
_addEventListener(eventName, callBack) {
|
|
206
|
-
var _a;
|
|
207
|
-
__privateGet(this, _listeners)[eventName] = ((_a = __privateGet(this, _listeners)) == null ? void 0 : _a[eventName]) || [];
|
|
208
|
-
__privateGet(this, _listeners)[eventName].push(callBack);
|
|
209
|
-
}
|
|
210
|
-
_removeEventListener(eventName, callBack) {
|
|
211
|
-
if (callBack) {
|
|
212
|
-
let index = __privateGet(this, _listeners)[eventName].findIndex(callBack);
|
|
213
|
-
index > -1 && __privateGet(this, _listeners)[eventName].splice(index, 1);
|
|
214
|
-
return;
|
|
215
|
-
}
|
|
216
|
-
Reflect.deleteProperty(__privateGet(this, _listeners), eventName);
|
|
217
|
-
}
|
|
218
|
-
_dispatchEvent(eventName, eventParams) {
|
|
219
|
-
if (Array.isArray(__privateGet(this, _listeners)[eventName])) {
|
|
220
|
-
__privateGet(this, _listeners)[eventName].forEach(
|
|
221
|
-
(callBack) => callBack(eventParams)
|
|
222
|
-
);
|
|
223
|
-
return true;
|
|
224
|
-
}
|
|
225
|
-
return false;
|
|
226
|
-
}
|
|
227
|
-
_dispatchMessageEvents(req, resp) {
|
|
228
|
-
let target = req._id;
|
|
229
|
-
if (Array.isArray(__privateGet(this, _listeners)[target])) {
|
|
230
|
-
__privateGet(this, _listeners)[target].forEach((listener) => {
|
|
231
|
-
try {
|
|
232
|
-
let processedResp = processResponse(req, resp);
|
|
233
|
-
listener(processedResp);
|
|
234
|
-
} catch (err) {
|
|
235
|
-
console.error("Message callback error: ", err);
|
|
236
|
-
}
|
|
237
|
-
});
|
|
238
|
-
this._removeEventListener(target);
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
_listeners = new WeakMap();
|
|
243
|
-
class BaseSDK extends EventBase {
|
|
244
|
-
_postMessageAsync(command, args, hasCallBack, callBack) {
|
|
245
|
-
return new Promise((resolve, reject) => {
|
|
246
|
-
const _id = generateId(command.toLowerCase());
|
|
247
|
-
postMessage({ _id, command, ...args });
|
|
248
|
-
globalInstances[_id] = this;
|
|
249
|
-
this._addEventListener(_id, async (data) => {
|
|
250
|
-
if ((data == null ? void 0 : data.errorMessage) || (data == null ? void 0 : data.isError)) {
|
|
251
|
-
reject(data);
|
|
252
|
-
} else {
|
|
253
|
-
if (hasCallBack && callBack) {
|
|
254
|
-
data = await callBack(data);
|
|
255
|
-
}
|
|
256
|
-
resolve(data);
|
|
257
|
-
}
|
|
258
|
-
});
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
_postMessage(command, args, callBack) {
|
|
262
|
-
const _id = generateId(command.toLowerCase());
|
|
263
|
-
postMessage({ _id, command, ...args });
|
|
264
|
-
if (callBack) {
|
|
265
|
-
this._addEventListener(args.eventName, callBack);
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
_postMessageSync(command, args) {
|
|
269
|
-
let intialValue = 0;
|
|
270
|
-
const _id = generateId(command.toLowerCase());
|
|
271
|
-
let data = { _id, command, ...args };
|
|
272
|
-
let atomics = new AtomicsHandler();
|
|
273
|
-
atomics.reset();
|
|
274
|
-
atomics.store(0, intialValue);
|
|
275
|
-
atomics.encodeData(1, data);
|
|
276
|
-
postMessage(atomics.sab);
|
|
277
|
-
atomics.wait(0, intialValue, 1e4);
|
|
278
|
-
let decodedData = atomics.decodeData();
|
|
279
|
-
let { _req: req, resp } = decodedData;
|
|
280
|
-
let processedResp = processResponse(req, resp);
|
|
281
|
-
if (processedResp == null ? void 0 : processedResp.isError) {
|
|
282
|
-
throw new Error(`Error: ${JSON.stringify(processedResp, null, 2)}`);
|
|
283
|
-
}
|
|
284
|
-
return processedResp;
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
let sharedArrayBufferInstance;
|
|
288
|
-
class AtomicsHandler {
|
|
289
|
-
constructor() {
|
|
290
|
-
__privateAdd(this, _textEncoder, void 0);
|
|
291
|
-
__privateAdd(this, _textDecoder, void 0);
|
|
292
|
-
__privateSet(this, _textEncoder, new TextEncoder());
|
|
293
|
-
__privateSet(this, _textDecoder, new TextDecoder());
|
|
294
|
-
sharedArrayBufferInstance = sharedArrayBufferInstance || new SharedArrayBuffer(1024 * 1024);
|
|
295
|
-
this.sab = sharedArrayBufferInstance;
|
|
296
|
-
this.int32Array = new Int32Array(this.sab);
|
|
297
|
-
}
|
|
298
|
-
load(index = 0) {
|
|
299
|
-
return Atomics.load(this.int32Array, index);
|
|
300
|
-
}
|
|
301
|
-
store(index = 0, data) {
|
|
302
|
-
return Atomics.store(this.int32Array, index, data);
|
|
303
|
-
}
|
|
304
|
-
reset() {
|
|
305
|
-
return this.int32Array.fill(0);
|
|
306
|
-
}
|
|
307
|
-
notify(index = 0, count = 1) {
|
|
308
|
-
return Atomics.notify(this.int32Array, index, count);
|
|
309
|
-
}
|
|
310
|
-
wait(index, value, timeout) {
|
|
311
|
-
return Atomics.wait(this.int32Array, index, value, timeout);
|
|
312
|
-
}
|
|
313
|
-
encodeData(index = 0, data) {
|
|
314
|
-
const replacer = (key, value) => value === void 0 ? "undefined" : value;
|
|
315
|
-
let string = JSON.stringify(data, replacer);
|
|
316
|
-
let encodedData = __privateGet(this, _textEncoder).encode(string);
|
|
317
|
-
this.int32Array.set(encodedData, index);
|
|
318
|
-
return this.int32Array;
|
|
319
|
-
}
|
|
320
|
-
decodeData() {
|
|
321
|
-
let uInt8Array = new Uint8Array(this.int32Array);
|
|
322
|
-
let string = __privateGet(this, _textDecoder).decode(uInt8Array).replaceAll(/\x00/g, "");
|
|
323
|
-
return JSON.parse(string);
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
_textEncoder = new WeakMap();
|
|
327
|
-
_textDecoder = new WeakMap();
|
|
328
|
-
class Form extends BaseSDK {
|
|
329
|
-
constructor(storeId, flowId, instanceId, activityInstanceId) {
|
|
330
|
-
super();
|
|
331
|
-
this.type = "Form";
|
|
332
|
-
this.storeId = storeId;
|
|
333
|
-
this.flowId = flowId;
|
|
334
|
-
this.instanceId = instanceId;
|
|
335
|
-
this.activityInstanceId = activityInstanceId;
|
|
336
|
-
}
|
|
337
|
-
toJSON() {
|
|
338
|
-
return this._postMessageAsync(LISTENER_CMDS.TO_JSON, {
|
|
339
|
-
storeId: this.storeId,
|
|
340
|
-
instanceId: this.instanceId
|
|
341
|
-
});
|
|
342
|
-
}
|
|
343
|
-
getField(fieldId) {
|
|
344
|
-
return this._postMessageAsync(LISTENER_CMDS.GET_FORM_FIELD, {
|
|
345
|
-
storeId: this.storeId,
|
|
346
|
-
instanceId: this.instanceId,
|
|
347
|
-
fieldId
|
|
348
|
-
});
|
|
349
|
-
}
|
|
350
|
-
updateField(args) {
|
|
351
|
-
return this._postMessageAsync(LISTENER_CMDS.UPDATE_FORM, {
|
|
352
|
-
storeId: this.storeId,
|
|
353
|
-
instanceId: this.instanceId,
|
|
354
|
-
data: args
|
|
355
|
-
});
|
|
356
|
-
}
|
|
357
|
-
getValidationErrors() {
|
|
358
|
-
return this._postMessageAsync(
|
|
359
|
-
LISTENER_CMDS.GET_FORM_VALIDATION_ERRORS,
|
|
360
|
-
{
|
|
361
|
-
storeId: this.storeId,
|
|
362
|
-
instanceId: this.instanceId
|
|
363
|
-
}
|
|
364
|
-
);
|
|
365
|
-
}
|
|
366
|
-
getFormConfiguration() {
|
|
367
|
-
return this._postMessageAsync(LISTENER_CMDS.GET_FORM_CONFIGURATION, {
|
|
368
|
-
storeId: this.storeId,
|
|
369
|
-
instanceId: this.instanceId
|
|
370
|
-
});
|
|
371
|
-
}
|
|
372
|
-
getFieldState() {
|
|
373
|
-
return this._postMessageAsync(LISTENER_CMDS.GET_FORM_FIELD_STATE, {
|
|
374
|
-
storeId: this.storeId,
|
|
375
|
-
instanceId: this.instanceId
|
|
376
|
-
});
|
|
377
|
-
}
|
|
378
|
-
getTable(tableId) {
|
|
379
|
-
return new Table(
|
|
380
|
-
this.storeId,
|
|
381
|
-
this.flowId,
|
|
382
|
-
this.instanceId,
|
|
383
|
-
tableId,
|
|
384
|
-
this.activityInstanceId
|
|
385
|
-
);
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
class Table extends BaseSDK {
|
|
389
|
-
constructor(storeId, flowId, instanceId, tableId, activityInstanceId) {
|
|
390
|
-
super();
|
|
391
|
-
this.tableId = tableId;
|
|
392
|
-
this.storeId = storeId;
|
|
393
|
-
this.flowId = flowId;
|
|
394
|
-
this.instanceId = instanceId;
|
|
395
|
-
this.activityInstanceId = activityInstanceId;
|
|
396
|
-
}
|
|
397
|
-
toJSON() {
|
|
398
|
-
return this._postMessageAsync(LISTENER_CMDS.TO_JSON, {
|
|
399
|
-
storeId: this.storeId,
|
|
400
|
-
instanceId: this.instanceId,
|
|
401
|
-
tableId: this.tableId
|
|
402
|
-
});
|
|
403
|
-
}
|
|
404
|
-
getSelectedRows() {
|
|
405
|
-
return this._postMessageAsync(LISTENER_CMDS.GET_SELECTED_TABLE_ROWS, {
|
|
406
|
-
storeId: this.storeId,
|
|
407
|
-
instanceId: this.instanceId,
|
|
408
|
-
tableId: this.tableId
|
|
409
|
-
});
|
|
410
|
-
}
|
|
411
|
-
getRows() {
|
|
412
|
-
return this._postMessageAsync(
|
|
413
|
-
LISTENER_CMDS.GET_TABLE_ROWS,
|
|
414
|
-
{
|
|
415
|
-
storeId: this.storeId,
|
|
416
|
-
instanceId: this.instanceId,
|
|
417
|
-
tableId: this.tableId
|
|
418
|
-
},
|
|
419
|
-
true,
|
|
420
|
-
(data) => {
|
|
421
|
-
return data.map(
|
|
422
|
-
(row) => new TableForm(
|
|
423
|
-
this.storeId,
|
|
424
|
-
this.flowId,
|
|
425
|
-
this.instanceId,
|
|
426
|
-
this.tableId,
|
|
427
|
-
row.id,
|
|
428
|
-
this.activityInstanceId
|
|
429
|
-
)
|
|
430
|
-
);
|
|
431
|
-
}
|
|
432
|
-
);
|
|
433
|
-
}
|
|
434
|
-
getRow(rowId) {
|
|
435
|
-
return new TableForm(
|
|
436
|
-
this.storeId,
|
|
437
|
-
this.flowId,
|
|
438
|
-
this.instanceId,
|
|
439
|
-
this.tableId,
|
|
440
|
-
rowId,
|
|
441
|
-
this.activityInstanceId
|
|
442
|
-
);
|
|
443
|
-
}
|
|
444
|
-
addRow(rowObject) {
|
|
445
|
-
return this._postMessageAsync(LISTENER_CMDS.ADD_TABLE_ROW, {
|
|
446
|
-
storeId: this.storeId,
|
|
447
|
-
instanceId: this.instanceId,
|
|
448
|
-
tableId: this.tableId,
|
|
449
|
-
rowObject
|
|
450
|
-
});
|
|
451
|
-
}
|
|
452
|
-
addRows(rows) {
|
|
453
|
-
return this._postMessageAsync(LISTENER_CMDS.ADD_TABLE_ROWS, {
|
|
454
|
-
storeId: this.storeId,
|
|
455
|
-
instanceId: this.instanceId,
|
|
456
|
-
tableId: this.tableId,
|
|
457
|
-
rows
|
|
458
|
-
});
|
|
459
|
-
}
|
|
460
|
-
deleteRow(rowId) {
|
|
461
|
-
return this._postMessageAsync(LISTENER_CMDS.DELETE_TABLE_ROW, {
|
|
462
|
-
storeId: this.storeId,
|
|
463
|
-
instanceId: this.instanceId,
|
|
464
|
-
tableId: this.tableId,
|
|
465
|
-
rows: [rowId]
|
|
466
|
-
});
|
|
467
|
-
}
|
|
468
|
-
deleteRows(rows) {
|
|
469
|
-
return this._postMessageAsync(LISTENER_CMDS.DELETE_TABLE_ROW, {
|
|
470
|
-
storeId: this.storeId,
|
|
471
|
-
instanceId: this.instanceId,
|
|
472
|
-
tableId: this.tableId,
|
|
473
|
-
rows
|
|
474
|
-
});
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
class TableForm extends BaseSDK {
|
|
478
|
-
constructor(storeId, flowId, instanceId, tableId, rowId, activityInstanceId) {
|
|
479
|
-
super();
|
|
480
|
-
this.storeId = storeId;
|
|
481
|
-
this.flowId = flowId;
|
|
482
|
-
this.instanceId = instanceId;
|
|
483
|
-
this.type = "TabelForm";
|
|
484
|
-
this.tableId = tableId;
|
|
485
|
-
this.rowId = rowId;
|
|
486
|
-
this.activityInstanceId = activityInstanceId;
|
|
487
|
-
}
|
|
488
|
-
getParent() {
|
|
489
|
-
return new Form(
|
|
490
|
-
this.storeId,
|
|
491
|
-
this.flowId,
|
|
492
|
-
this.instanceId,
|
|
493
|
-
this.activityInstanceId
|
|
494
|
-
);
|
|
495
|
-
}
|
|
496
|
-
toJSON() {
|
|
497
|
-
return this._postMessageAsync(LISTENER_CMDS.TO_JSON, {
|
|
498
|
-
storeId: this.storeId,
|
|
499
|
-
instanceId: this.instanceId,
|
|
500
|
-
tableId: this.tableId,
|
|
501
|
-
rowId: this.rowId
|
|
502
|
-
});
|
|
503
|
-
}
|
|
504
|
-
getField(fieldId) {
|
|
505
|
-
return this._postMessageAsync(LISTENER_CMDS.GET_FORM_FIELD, {
|
|
506
|
-
storeId: this.storeId,
|
|
507
|
-
instanceId: this.instanceId,
|
|
508
|
-
tableId: this.tableId,
|
|
509
|
-
rowId: this.rowId,
|
|
510
|
-
fieldId
|
|
511
|
-
});
|
|
512
|
-
}
|
|
513
|
-
updateField(args) {
|
|
514
|
-
return this._postMessageAsync(LISTENER_CMDS.UPDATE_FORM, {
|
|
515
|
-
storeId: this.storeId,
|
|
516
|
-
instanceId: this.instanceId,
|
|
517
|
-
tableId: this.tableId,
|
|
518
|
-
rowId: this.rowId,
|
|
519
|
-
data: args
|
|
520
|
-
});
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
class Client extends BaseSDK {
|
|
524
|
-
showInfo(message) {
|
|
525
|
-
return super._postMessageAsync(LISTENER_CMDS.MESSAGE, { message });
|
|
526
|
-
}
|
|
527
|
-
showConfirm(args) {
|
|
528
|
-
return super._postMessageAsync(LISTENER_CMDS.CONFIRM, {
|
|
529
|
-
data: {
|
|
530
|
-
title: args.title,
|
|
531
|
-
content: args.content,
|
|
532
|
-
okText: args.okText || "Ok",
|
|
533
|
-
cancelText: args.cancelText || "Cancel"
|
|
534
|
-
}
|
|
535
|
-
});
|
|
536
|
-
}
|
|
537
|
-
redirect(url) {
|
|
538
|
-
return super._postMessageAsync(LISTENER_CMDS.REDIRECT, { url });
|
|
539
|
-
}
|
|
540
|
-
getImageUrl(imageValue) {
|
|
541
|
-
return this._postMessageAsync(LISTENER_CMDS.GET_IMAGE_URL, {
|
|
542
|
-
imageValue
|
|
543
|
-
});
|
|
544
|
-
}
|
|
545
|
-
openFilePicker(options) {
|
|
546
|
-
return this._postMessageAsync(LISTENER_CMDS.FILEPICKER_OPEN, {
|
|
547
|
-
options
|
|
548
|
-
});
|
|
549
|
-
}
|
|
550
|
-
openScanner(options = {}) {
|
|
551
|
-
return this._postMessageAsync(LISTENER_CMDS.SCANNER_OPEN, {
|
|
552
|
-
options
|
|
553
|
-
});
|
|
554
|
-
}
|
|
555
|
-
pickLocation(value) {
|
|
556
|
-
return this._postMessageAsync(LISTENER_CMDS.GEOLOCATION_OPEN, {
|
|
557
|
-
value
|
|
558
|
-
});
|
|
559
|
-
}
|
|
560
|
-
uploadFile(file, fileName) {
|
|
561
|
-
return this._postMessageAsync(LISTENER_CMDS.FILE_UPLOAD, {
|
|
562
|
-
file,
|
|
563
|
-
fileName: fileName != null ? fileName : file.name
|
|
564
|
-
});
|
|
565
|
-
}
|
|
566
|
-
openFilePreview(args) {
|
|
567
|
-
var _a;
|
|
568
|
-
return this._postMessageAsync(LISTENER_CMDS.FILEPREVIEW_OPEN, {
|
|
569
|
-
files: args.files,
|
|
570
|
-
indexOfFile: (_a = args.indexOfFile) != null ? _a : 0
|
|
571
|
-
});
|
|
572
|
-
}
|
|
573
|
-
}
|
|
574
|
-
class Formatter extends BaseSDK {
|
|
575
|
-
toDate(date) {
|
|
576
|
-
return this._postMessageAsync(LISTENER_CMDS.FORMAT_DATE, {
|
|
577
|
-
date
|
|
578
|
-
});
|
|
579
|
-
}
|
|
580
|
-
toDateTime(date) {
|
|
581
|
-
return this._postMessageAsync(LISTENER_CMDS.FORMAT_DATE_TIME, {
|
|
582
|
-
date
|
|
583
|
-
});
|
|
584
|
-
}
|
|
585
|
-
toNumber(value) {
|
|
586
|
-
return this._postMessageAsync(LISTENER_CMDS.FORMAT_NUMBER, {
|
|
587
|
-
value
|
|
588
|
-
});
|
|
589
|
-
}
|
|
590
|
-
toCurrency(value, currencyCode) {
|
|
591
|
-
return this._postMessageAsync(LISTENER_CMDS.FORMAT_CURRENCY, {
|
|
592
|
-
value,
|
|
593
|
-
currencyCode
|
|
594
|
-
});
|
|
595
|
-
}
|
|
596
|
-
toBoolean(value) {
|
|
597
|
-
return this._postMessageAsync(LISTENER_CMDS.FORMAT_BOOLEAN, {
|
|
598
|
-
value
|
|
599
|
-
});
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
function requireFieldAsync(value, fieldName) {
|
|
603
|
-
if (!value) {
|
|
604
|
-
return Promise.reject({ message: `${fieldName} is required` });
|
|
605
|
-
}
|
|
606
|
-
return null;
|
|
607
|
-
}
|
|
608
|
-
function requireFieldsAsync(fields) {
|
|
609
|
-
const missingFields = fields.filter((f) => !f.value).map((f) => f.name);
|
|
610
|
-
if (missingFields.length > 0) {
|
|
611
|
-
return Promise.reject({
|
|
612
|
-
message: `${missingFields.join(" and ")} ${missingFields.length > 1 ? "are" : "is"} required`
|
|
613
|
-
});
|
|
614
|
-
}
|
|
615
|
-
return null;
|
|
616
|
-
}
|
|
617
|
-
class Component extends BaseSDK {
|
|
618
|
-
constructor(props) {
|
|
619
|
-
super();
|
|
620
|
-
__privateAdd(this, _registerComponentAPIs);
|
|
621
|
-
this._id = props.componentId;
|
|
622
|
-
this.type = "Component";
|
|
623
|
-
globalInstances[this._id] = this;
|
|
624
|
-
__privateMethod(this, _registerComponentAPIs, registerComponentAPIs_fn).call(this, props.componentMethods);
|
|
625
|
-
}
|
|
626
|
-
onMount(callback) {
|
|
627
|
-
this._postMessage(
|
|
628
|
-
LISTENER_CMDS.COMPONENT_ADD_EVENT_LISTENER,
|
|
629
|
-
{
|
|
630
|
-
id: this._id,
|
|
631
|
-
eventName: EVENT_TYPES.COMPONENT_ON_MOUNT,
|
|
632
|
-
eventConfig: {
|
|
633
|
-
once: true
|
|
634
|
-
}
|
|
635
|
-
},
|
|
636
|
-
callback
|
|
637
|
-
);
|
|
638
|
-
}
|
|
639
|
-
refresh() {
|
|
640
|
-
return this._postMessageAsync(LISTENER_CMDS.COMPONENT_REFRESH, {
|
|
641
|
-
id: this._id
|
|
642
|
-
});
|
|
643
|
-
}
|
|
644
|
-
show() {
|
|
645
|
-
return this._postMessageAsync(LISTENER_CMDS.COMPONENT_SHOW, {
|
|
646
|
-
id: this._id
|
|
647
|
-
});
|
|
648
|
-
}
|
|
649
|
-
hide() {
|
|
650
|
-
return this._postMessageAsync(LISTENER_CMDS.COMPONENT_HIDE, {
|
|
651
|
-
id: this._id
|
|
652
|
-
});
|
|
653
|
-
}
|
|
654
|
-
}
|
|
655
|
-
_registerComponentAPIs = new WeakSet();
|
|
656
|
-
registerComponentAPIs_fn = function(componentAPIs) {
|
|
657
|
-
componentAPIs == null ? void 0 : componentAPIs.forEach((Api) => {
|
|
658
|
-
this[Api.name] = (...args) => {
|
|
659
|
-
if (Api.type === "method") {
|
|
660
|
-
return this._postMessageAsync(`COMPONENT_${Api.name}`, {
|
|
661
|
-
id: this._id,
|
|
662
|
-
parameters: args
|
|
663
|
-
});
|
|
664
|
-
} else if (Api.type === "event") {
|
|
665
|
-
this._postMessage(
|
|
666
|
-
LISTENER_CMDS.COMPONENT_ADD_EVENT_LISTENER,
|
|
667
|
-
{
|
|
668
|
-
id: this._id,
|
|
669
|
-
eventName: Api.name,
|
|
670
|
-
eventConfig: args[1]
|
|
671
|
-
},
|
|
672
|
-
args[0]
|
|
673
|
-
);
|
|
674
|
-
}
|
|
675
|
-
};
|
|
676
|
-
});
|
|
677
|
-
};
|
|
678
|
-
class Popup extends BaseSDK {
|
|
679
|
-
constructor(props) {
|
|
680
|
-
super();
|
|
681
|
-
this.type = "Popup";
|
|
682
|
-
this._id = props.popupId || DEFAULTS.POPUP_ID;
|
|
683
|
-
}
|
|
684
|
-
getParameter(key) {
|
|
685
|
-
return this._postMessageAsync(LISTENER_CMDS.GET_POPUP_PARAMS, {
|
|
686
|
-
key,
|
|
687
|
-
popupId: this._id
|
|
688
|
-
});
|
|
689
|
-
}
|
|
690
|
-
getAllParameters() {
|
|
691
|
-
return this._postMessageAsync(LISTENER_CMDS.GET_ALL_POPUP_PARAMS, {
|
|
692
|
-
popupId: this._id
|
|
693
|
-
});
|
|
694
|
-
}
|
|
695
|
-
close() {
|
|
696
|
-
return this._postMessageAsync(LISTENER_CMDS.CLOSE_POPUP, {});
|
|
697
|
-
}
|
|
698
|
-
getComponent(componentId) {
|
|
699
|
-
return this._postMessageAsync(
|
|
700
|
-
LISTENER_CMDS.COMPONENT_GET,
|
|
701
|
-
{ componentId },
|
|
702
|
-
true,
|
|
703
|
-
(data) => {
|
|
704
|
-
return new Component(data);
|
|
705
|
-
}
|
|
706
|
-
);
|
|
707
|
-
}
|
|
708
|
-
}
|
|
709
|
-
class Page extends BaseSDK {
|
|
710
|
-
constructor(props, isCustomComponent = false) {
|
|
711
|
-
var _a;
|
|
712
|
-
super();
|
|
713
|
-
this.type = "Page";
|
|
714
|
-
this.popup = new Popup({});
|
|
715
|
-
this._id = props.pageId;
|
|
716
|
-
this._route = (_a = props.initialRoute) != null ? _a : "";
|
|
717
|
-
}
|
|
718
|
-
getParameter(key) {
|
|
719
|
-
return this._postMessageAsync(LISTENER_CMDS.GET_PAGE_PARAMS, {
|
|
720
|
-
key
|
|
721
|
-
});
|
|
722
|
-
}
|
|
723
|
-
getAllParameters() {
|
|
724
|
-
return this._postMessageAsync(LISTENER_CMDS.GET_ALL_PAGE_PARAMS, {
|
|
725
|
-
pageId: this._id
|
|
726
|
-
});
|
|
727
|
-
}
|
|
728
|
-
getVariable(key) {
|
|
729
|
-
return this._postMessageAsync(LISTENER_CMDS.GET_PAGE_VARIABLE, {
|
|
730
|
-
key
|
|
731
|
-
});
|
|
732
|
-
}
|
|
733
|
-
setVariable(key, value) {
|
|
734
|
-
return this._postMessageAsync(LISTENER_CMDS.SET_PAGE_VARIABLE, {
|
|
735
|
-
key,
|
|
736
|
-
value
|
|
737
|
-
});
|
|
738
|
-
}
|
|
739
|
-
openPopup(popupId, popupParams) {
|
|
740
|
-
return this._postMessageAsync(LISTENER_CMDS.OPEN_POPUP, {
|
|
741
|
-
popupId,
|
|
742
|
-
popupParams
|
|
743
|
-
});
|
|
744
|
-
}
|
|
745
|
-
getComponent(componentId) {
|
|
746
|
-
return this._postMessageAsync(
|
|
747
|
-
LISTENER_CMDS.COMPONENT_GET,
|
|
748
|
-
{ componentId },
|
|
749
|
-
true,
|
|
750
|
-
(data) => new Component(data)
|
|
751
|
-
);
|
|
752
|
-
}
|
|
753
|
-
setRoute(path) {
|
|
754
|
-
this._route = path;
|
|
755
|
-
return this._postMessage(LISTENER_CMDS.CC_SET_ROUTE, { route: path });
|
|
756
|
-
}
|
|
757
|
-
getRoute() {
|
|
758
|
-
return this._route;
|
|
759
|
-
}
|
|
760
|
-
}
|
|
761
|
-
class DecisionTable extends BaseSDK {
|
|
762
|
-
constructor(flowId) {
|
|
763
|
-
super();
|
|
764
|
-
this.flowId = flowId;
|
|
765
|
-
}
|
|
766
|
-
evaluate(payload) {
|
|
767
|
-
return this._postMessageAsync(LISTENER_CMDS.DECISION_TABLE_EXECUTE, {
|
|
768
|
-
flowId: this.flowId,
|
|
769
|
-
payload
|
|
770
|
-
});
|
|
771
|
-
}
|
|
772
|
-
}
|
|
773
|
-
class Dataform extends BaseSDK {
|
|
774
|
-
constructor(flowId) {
|
|
775
|
-
super();
|
|
776
|
-
this._id = flowId;
|
|
777
|
-
}
|
|
778
|
-
getItems(options) {
|
|
779
|
-
return this._postMessageAsync(LISTENER_CMDS.DATAFORM_GET_ITEMS, {
|
|
780
|
-
flowId: this._id,
|
|
781
|
-
viewId: (options == null ? void 0 : options.viewId) || "",
|
|
782
|
-
searchValue: (options == null ? void 0 : options.searchValue) || "",
|
|
783
|
-
pageNumber: (options == null ? void 0 : options.pageNumber) || 1,
|
|
784
|
-
pageSize: (options == null ? void 0 : options.pageSize) || 50,
|
|
785
|
-
payload: (options == null ? void 0 : options.payload) || {}
|
|
786
|
-
});
|
|
787
|
-
}
|
|
788
|
-
getItem(options) {
|
|
789
|
-
const error = requireFieldAsync(options.itemId, "itemId");
|
|
790
|
-
if (error)
|
|
791
|
-
return error;
|
|
792
|
-
return this._postMessageAsync(LISTENER_CMDS.DATAFORM_GET_ITEM, {
|
|
793
|
-
flowId: this._id,
|
|
794
|
-
itemId: options.itemId,
|
|
795
|
-
viewId: options.viewId || ""
|
|
796
|
-
});
|
|
797
|
-
}
|
|
798
|
-
createItem(options) {
|
|
799
|
-
return this._postMessageAsync(LISTENER_CMDS.DATAFORM_CREATE_ITEM, {
|
|
800
|
-
flowId: this._id,
|
|
801
|
-
data: (options == null ? void 0 : options.data) || {},
|
|
802
|
-
viewId: (options == null ? void 0 : options.viewId) || ""
|
|
803
|
-
});
|
|
804
|
-
}
|
|
805
|
-
updateItem(options) {
|
|
806
|
-
const error = requireFieldAsync(options.itemId, "itemId");
|
|
807
|
-
if (error)
|
|
808
|
-
return error;
|
|
809
|
-
return this._postMessageAsync(LISTENER_CMDS.DATAFORM_UPDATE_ITEM, {
|
|
810
|
-
flowId: this._id,
|
|
811
|
-
itemId: options.itemId,
|
|
812
|
-
data: options.data,
|
|
813
|
-
viewId: options.viewId || ""
|
|
814
|
-
});
|
|
815
|
-
}
|
|
816
|
-
importCSV(defaultValues) {
|
|
817
|
-
return this._postMessageAsync(LISTENER_CMDS.DATAFORM_IMPORT_CSV, {
|
|
818
|
-
flowId: this._id,
|
|
819
|
-
defaultValues
|
|
820
|
-
});
|
|
821
|
-
}
|
|
822
|
-
openForm(item) {
|
|
823
|
-
const error = requireFieldAsync(item._id, "Instance Id (_id)");
|
|
824
|
-
if (error)
|
|
825
|
-
return error;
|
|
826
|
-
return this._postMessageAsync(LISTENER_CMDS.DATAFORM_OPEN_FORM, {
|
|
827
|
-
flowId: this._id,
|
|
828
|
-
itemId: item._id,
|
|
829
|
-
viewId: item._view_id || ""
|
|
830
|
-
});
|
|
831
|
-
}
|
|
832
|
-
deleteItem(options) {
|
|
833
|
-
const error = requireFieldAsync(options.itemId, "itemId");
|
|
834
|
-
if (error)
|
|
835
|
-
return error;
|
|
836
|
-
return this._postMessageAsync(LISTENER_CMDS.DATAFORM_DELETE_ITEM, {
|
|
837
|
-
flowId: this._id,
|
|
838
|
-
itemId: options.itemId,
|
|
839
|
-
viewId: options.viewId || ""
|
|
840
|
-
});
|
|
841
|
-
}
|
|
842
|
-
discardItem(options) {
|
|
843
|
-
return this._postMessageAsync(LISTENER_CMDS.DATAFORM_DISCARD_ITEM, {
|
|
844
|
-
flowId: this._id,
|
|
845
|
-
viewId: (options == null ? void 0 : options.viewId) || ""
|
|
846
|
-
});
|
|
847
|
-
}
|
|
848
|
-
submitItem(options) {
|
|
849
|
-
const error = requireFieldAsync(options.itemId, "itemId");
|
|
850
|
-
if (error)
|
|
851
|
-
return error;
|
|
852
|
-
return this._postMessageAsync(LISTENER_CMDS.DATAFORM_SUBMIT_ITEM, {
|
|
853
|
-
flowId: this._id,
|
|
854
|
-
itemId: options.itemId,
|
|
855
|
-
data: options.data || {},
|
|
856
|
-
viewId: options.viewId || ""
|
|
857
|
-
});
|
|
858
|
-
}
|
|
859
|
-
getFields(options) {
|
|
860
|
-
return this._postMessageAsync(LISTENER_CMDS.DATAFORM_GET_FIELDS, {
|
|
861
|
-
flowId: this._id,
|
|
862
|
-
viewId: (options == null ? void 0 : options.viewId) || ""
|
|
863
|
-
});
|
|
864
|
-
}
|
|
865
|
-
initForm(instanceId, viewId) {
|
|
866
|
-
return this._postMessageAsync(LISTENER_CMDS.DATAFORM_INIT_FORM, {
|
|
867
|
-
flowId: this._id,
|
|
868
|
-
instanceId: instanceId || "",
|
|
869
|
-
viewId: viewId || ""
|
|
870
|
-
}).then((response) => {
|
|
871
|
-
return new Form(
|
|
872
|
-
response.storeId || instanceId || "",
|
|
873
|
-
this._id,
|
|
874
|
-
response.itemId || instanceId
|
|
875
|
-
);
|
|
876
|
-
});
|
|
877
|
-
}
|
|
878
|
-
getFieldOptions(options) {
|
|
879
|
-
return this._postMessageAsync(
|
|
880
|
-
LISTENER_CMDS.DATAFORM_GET_FIELD_OPTIONS,
|
|
881
|
-
{
|
|
882
|
-
flowId: this._id,
|
|
883
|
-
instanceId: (options == null ? void 0 : options.instanceId) || "",
|
|
884
|
-
fieldId: (options == null ? void 0 : options.fieldId) || "",
|
|
885
|
-
fieldType: options == null ? void 0 : options.fieldType,
|
|
886
|
-
tableId: options == null ? void 0 : options.tableId,
|
|
887
|
-
tableRowId: options == null ? void 0 : options.tableRowId
|
|
888
|
-
}
|
|
889
|
-
);
|
|
890
|
-
}
|
|
891
|
-
}
|
|
892
|
-
class Board extends BaseSDK {
|
|
893
|
-
constructor(flowId) {
|
|
894
|
-
super();
|
|
895
|
-
this._id = flowId;
|
|
896
|
-
}
|
|
897
|
-
importCSV(defaultValues) {
|
|
898
|
-
return this._postMessageAsync(LISTENER_CMDS.BOARD_IMPORT_CSV, {
|
|
899
|
-
flowId: this._id,
|
|
900
|
-
defaultValues
|
|
901
|
-
});
|
|
902
|
-
}
|
|
903
|
-
openForm(item) {
|
|
904
|
-
const error = requireFieldAsync(item._id, "Instance Id (_id)");
|
|
905
|
-
if (error)
|
|
906
|
-
return error;
|
|
907
|
-
return this._postMessageAsync(LISTENER_CMDS.BOARD_OPEN_FORM, {
|
|
908
|
-
flowId: this._id,
|
|
909
|
-
itemId: item._id,
|
|
910
|
-
viewId: item._view_id
|
|
911
|
-
});
|
|
912
|
-
}
|
|
913
|
-
getItems(options) {
|
|
914
|
-
return this._postMessageAsync(LISTENER_CMDS.BOARD_GET_ITEMS, {
|
|
915
|
-
flowId: this._id,
|
|
916
|
-
viewId: (options == null ? void 0 : options.viewId) || "",
|
|
917
|
-
searchValue: (options == null ? void 0 : options.searchValue) || "",
|
|
918
|
-
pageNumber: (options == null ? void 0 : options.pageNumber) || 1,
|
|
919
|
-
pageSize: (options == null ? void 0 : options.pageSize) || 50,
|
|
920
|
-
payload: (options == null ? void 0 : options.payload) || {}
|
|
921
|
-
});
|
|
922
|
-
}
|
|
923
|
-
getItem(options) {
|
|
924
|
-
const error = requireFieldAsync(options.instanceId, "instanceId");
|
|
925
|
-
if (error)
|
|
926
|
-
return error;
|
|
927
|
-
return this._postMessageAsync(LISTENER_CMDS.BOARD_GET_ITEM, {
|
|
928
|
-
flowId: this._id,
|
|
929
|
-
instanceId: options.instanceId
|
|
930
|
-
});
|
|
931
|
-
}
|
|
932
|
-
createItem(options) {
|
|
933
|
-
return this._postMessageAsync(LISTENER_CMDS.BOARD_CREATE_ITEM, {
|
|
934
|
-
flowId: this._id,
|
|
935
|
-
data: (options == null ? void 0 : options.data) || {}
|
|
936
|
-
});
|
|
937
|
-
}
|
|
938
|
-
updateItem(options) {
|
|
939
|
-
const error = requireFieldAsync(options.instanceId, "instanceId");
|
|
940
|
-
if (error)
|
|
941
|
-
return error;
|
|
942
|
-
return this._postMessageAsync(LISTENER_CMDS.BOARD_UPDATE_ITEM, {
|
|
943
|
-
flowId: this._id,
|
|
944
|
-
instanceId: options.instanceId,
|
|
945
|
-
data: options.data
|
|
946
|
-
});
|
|
947
|
-
}
|
|
948
|
-
deleteItem(options) {
|
|
949
|
-
const error = requireFieldAsync(options.instanceId, "instanceId");
|
|
950
|
-
if (error)
|
|
951
|
-
return error;
|
|
952
|
-
return this._postMessageAsync(LISTENER_CMDS.BOARD_DELETE_ITEM, {
|
|
953
|
-
flowId: this._id,
|
|
954
|
-
instanceId: options.instanceId
|
|
955
|
-
});
|
|
956
|
-
}
|
|
957
|
-
submitItem(options) {
|
|
958
|
-
const error = requireFieldAsync(options.instanceId, "instanceId");
|
|
959
|
-
if (error)
|
|
960
|
-
return error;
|
|
961
|
-
return this._postMessageAsync(LISTENER_CMDS.BOARD_SUBMIT_ITEM, {
|
|
962
|
-
flowId: this._id,
|
|
963
|
-
instanceId: options.instanceId
|
|
964
|
-
});
|
|
965
|
-
}
|
|
966
|
-
discardItem(options) {
|
|
967
|
-
const error = requireFieldAsync(options.instanceId, "instanceId");
|
|
968
|
-
if (error)
|
|
969
|
-
return error;
|
|
970
|
-
return this._postMessageAsync(LISTENER_CMDS.BOARD_DISCARD_ITEM, {
|
|
971
|
-
flowId: this._id,
|
|
972
|
-
instanceId: options.instanceId
|
|
973
|
-
});
|
|
974
|
-
}
|
|
975
|
-
getFields(options) {
|
|
976
|
-
return this._postMessageAsync(LISTENER_CMDS.BOARD_GET_FIELDS, {
|
|
977
|
-
flowId: this._id,
|
|
978
|
-
viewId: (options == null ? void 0 : options.viewId) || ""
|
|
979
|
-
});
|
|
980
|
-
}
|
|
981
|
-
initForm(instanceId, viewId) {
|
|
982
|
-
return this._postMessageAsync(LISTENER_CMDS.BOARD_INIT_FORM, {
|
|
983
|
-
flowId: this._id,
|
|
984
|
-
instanceId: instanceId || "",
|
|
985
|
-
viewId: viewId || ""
|
|
986
|
-
}).then((response) => {
|
|
987
|
-
return new Form(
|
|
988
|
-
response.storeId || instanceId || "",
|
|
989
|
-
this._id,
|
|
990
|
-
response.itemId || instanceId
|
|
991
|
-
);
|
|
992
|
-
});
|
|
993
|
-
}
|
|
994
|
-
getFieldOptions(options) {
|
|
995
|
-
const error = requireFieldsAsync([
|
|
996
|
-
{ value: options.instanceId, name: "instanceId" },
|
|
997
|
-
{ value: options.fieldId, name: "fieldId" }
|
|
998
|
-
]);
|
|
999
|
-
if (error)
|
|
1000
|
-
return error;
|
|
1001
|
-
return this._postMessageAsync(LISTENER_CMDS.BOARD_GET_FIELD_OPTIONS, {
|
|
1002
|
-
flowId: this._id,
|
|
1003
|
-
instanceId: options.instanceId,
|
|
1004
|
-
fieldId: options.fieldId,
|
|
1005
|
-
fieldType: options.fieldType,
|
|
1006
|
-
tableId: options == null ? void 0 : options.tableId,
|
|
1007
|
-
tableRowId: options == null ? void 0 : options.tableRowId
|
|
1008
|
-
});
|
|
1009
|
-
}
|
|
1010
|
-
}
|
|
1011
|
-
class Process extends BaseSDK {
|
|
1012
|
-
constructor(flowId) {
|
|
1013
|
-
super();
|
|
1014
|
-
this._id = flowId;
|
|
1015
|
-
}
|
|
1016
|
-
getMyItems(options) {
|
|
1017
|
-
return this._postMessageAsync(LISTENER_CMDS.PROCESS_GET_MY_ITEMS, {
|
|
1018
|
-
flowId: this._id,
|
|
1019
|
-
status: (options == null ? void 0 : options.status) || "all",
|
|
1020
|
-
searchValue: (options == null ? void 0 : options.searchValue) || "",
|
|
1021
|
-
pageNumber: (options == null ? void 0 : options.pageNumber) || 1,
|
|
1022
|
-
pageSize: (options == null ? void 0 : options.pageSize) || 50,
|
|
1023
|
-
payload: (options == null ? void 0 : options.payload) || {}
|
|
1024
|
-
});
|
|
1025
|
-
}
|
|
1026
|
-
getMyTasksItems(options) {
|
|
1027
|
-
return this._postMessageAsync(
|
|
1028
|
-
LISTENER_CMDS.PROCESS_GET_MY_TASKS_ITEMS,
|
|
1029
|
-
{
|
|
1030
|
-
flowId: this._id,
|
|
1031
|
-
activityId: (options == null ? void 0 : options.activityId) || "",
|
|
1032
|
-
searchValue: (options == null ? void 0 : options.searchValue) || "",
|
|
1033
|
-
pageNumber: (options == null ? void 0 : options.pageNumber) || 1,
|
|
1034
|
-
pageSize: (options == null ? void 0 : options.pageSize) || 50,
|
|
1035
|
-
payload: (options == null ? void 0 : options.payload) || {}
|
|
1036
|
-
}
|
|
1037
|
-
);
|
|
1038
|
-
}
|
|
1039
|
-
getParticipatedItems(options) {
|
|
1040
|
-
return this._postMessageAsync(
|
|
1041
|
-
LISTENER_CMDS.PROCESS_GET_PARTICIPATED_ITEMS,
|
|
1042
|
-
{
|
|
1043
|
-
flowId: this._id,
|
|
1044
|
-
activityId: (options == null ? void 0 : options.activityId) || "",
|
|
1045
|
-
searchValue: (options == null ? void 0 : options.searchValue) || "",
|
|
1046
|
-
pageNumber: (options == null ? void 0 : options.pageNumber) || 1,
|
|
1047
|
-
pageSize: (options == null ? void 0 : options.pageSize) || 50,
|
|
1048
|
-
payload: (options == null ? void 0 : options.payload) || {}
|
|
1049
|
-
}
|
|
1050
|
-
);
|
|
1051
|
-
}
|
|
1052
|
-
getAdminItems(options) {
|
|
1053
|
-
return this._postMessageAsync(LISTENER_CMDS.PROCESS_GET_ADMIN_ITEMS, {
|
|
1054
|
-
flowId: this._id,
|
|
1055
|
-
searchValue: (options == null ? void 0 : options.searchValue) || "",
|
|
1056
|
-
pageNumber: (options == null ? void 0 : options.pageNumber) || 1,
|
|
1057
|
-
pageSize: (options == null ? void 0 : options.pageSize) || 50,
|
|
1058
|
-
payload: (options == null ? void 0 : options.payload) || {}
|
|
1059
|
-
});
|
|
1060
|
-
}
|
|
1061
|
-
getItem(options) {
|
|
1062
|
-
const error = requireFieldsAsync([
|
|
1063
|
-
{ value: options.instanceId, name: "instanceId" },
|
|
1064
|
-
{ value: options.activityInstanceId, name: "activityInstanceId" }
|
|
1065
|
-
]);
|
|
1066
|
-
if (error)
|
|
1067
|
-
return error;
|
|
1068
|
-
return this._postMessageAsync(LISTENER_CMDS.PROCESS_GET_ITEM, {
|
|
1069
|
-
flowId: this._id,
|
|
1070
|
-
instanceId: options.instanceId,
|
|
1071
|
-
activityInstanceId: options.activityInstanceId
|
|
1072
|
-
});
|
|
1073
|
-
}
|
|
1074
|
-
createItem(options) {
|
|
1075
|
-
return this._postMessageAsync(LISTENER_CMDS.PROCESS_CREATE_ITEM, {
|
|
1076
|
-
flowId: this._id,
|
|
1077
|
-
data: (options == null ? void 0 : options.data) || {}
|
|
1078
|
-
});
|
|
1079
|
-
}
|
|
1080
|
-
updateItem(options) {
|
|
1081
|
-
const error = requireFieldsAsync([
|
|
1082
|
-
{ value: options.instanceId, name: "instanceId" },
|
|
1083
|
-
{ value: options.activityInstanceId, name: "activityInstanceId" }
|
|
1084
|
-
]);
|
|
1085
|
-
if (error)
|
|
1086
|
-
return error;
|
|
1087
|
-
return this._postMessageAsync(LISTENER_CMDS.PROCESS_UPDATE_ITEM, {
|
|
1088
|
-
flowId: this._id,
|
|
1089
|
-
instanceId: options.instanceId,
|
|
1090
|
-
activityInstanceId: options.activityInstanceId,
|
|
1091
|
-
data: options.data
|
|
1092
|
-
});
|
|
1093
|
-
}
|
|
1094
|
-
deleteItem(options) {
|
|
1095
|
-
const error = requireFieldAsync(options.instanceId, "instanceId");
|
|
1096
|
-
if (error)
|
|
1097
|
-
return error;
|
|
1098
|
-
return this._postMessageAsync(LISTENER_CMDS.PROCESS_DELETE_ITEM, {
|
|
1099
|
-
flowId: this._id,
|
|
1100
|
-
instanceId: options.instanceId
|
|
1101
|
-
});
|
|
1102
|
-
}
|
|
1103
|
-
getAdminItem(options) {
|
|
1104
|
-
const error = requireFieldAsync(options.instanceId, "instanceId");
|
|
1105
|
-
if (error)
|
|
1106
|
-
return error;
|
|
1107
|
-
return this._postMessageAsync(LISTENER_CMDS.PROCESS_GET_ADMIN_ITEM, {
|
|
1108
|
-
flowId: this._id,
|
|
1109
|
-
instanceId: options.instanceId
|
|
1110
|
-
});
|
|
1111
|
-
}
|
|
1112
|
-
updateAdminItem(options) {
|
|
1113
|
-
const error = requireFieldsAsync([
|
|
1114
|
-
{ value: options.instanceId, name: "instanceId" },
|
|
1115
|
-
{ value: options.data, name: "data" }
|
|
1116
|
-
]);
|
|
1117
|
-
if (error)
|
|
1118
|
-
return error;
|
|
1119
|
-
return this._postMessageAsync(LISTENER_CMDS.PROCESS_UPDATE_ADMIN_ITEM, {
|
|
1120
|
-
flowId: this._id,
|
|
1121
|
-
instanceId: options.instanceId,
|
|
1122
|
-
data: options.data
|
|
1123
|
-
});
|
|
1124
|
-
}
|
|
1125
|
-
openForm(item) {
|
|
1126
|
-
const error = requireFieldsAsync([
|
|
1127
|
-
{ value: item._id, name: "Instance Id (_id)" },
|
|
1128
|
-
{
|
|
1129
|
-
value: item._activity_instance_id,
|
|
1130
|
-
name: "Activity Instance Id (_activity_instance_id)"
|
|
1131
|
-
}
|
|
1132
|
-
]);
|
|
1133
|
-
if (error)
|
|
1134
|
-
return error;
|
|
1135
|
-
return this._postMessageAsync(LISTENER_CMDS.PROCESS_OPEN_FORM, {
|
|
1136
|
-
flowId: this._id,
|
|
1137
|
-
instanceId: item._id,
|
|
1138
|
-
activityInstanceId: item._activity_instance_id
|
|
1139
|
-
});
|
|
1140
|
-
}
|
|
1141
|
-
submitItem(options) {
|
|
1142
|
-
const error = requireFieldsAsync([
|
|
1143
|
-
{ value: options.instanceId, name: "instanceId" },
|
|
1144
|
-
{ value: options.activityInstanceId, name: "activityInstanceId" }
|
|
1145
|
-
]);
|
|
1146
|
-
if (error)
|
|
1147
|
-
return error;
|
|
1148
|
-
return this._postMessageAsync(LISTENER_CMDS.PROCESS_SUBMIT_ITEM, {
|
|
1149
|
-
flowId: this._id,
|
|
1150
|
-
instanceId: options.instanceId,
|
|
1151
|
-
activityInstanceId: options.activityInstanceId,
|
|
1152
|
-
comment: options.comment || ""
|
|
1153
|
-
});
|
|
1154
|
-
}
|
|
1155
|
-
rejectItem(options) {
|
|
1156
|
-
const error = requireFieldsAsync([
|
|
1157
|
-
{ value: options.instanceId, name: "instanceId" },
|
|
1158
|
-
{ value: options.activityInstanceId, name: "activityInstanceId" },
|
|
1159
|
-
{ value: options.comment, name: "comment" }
|
|
1160
|
-
]);
|
|
1161
|
-
if (error)
|
|
1162
|
-
return error;
|
|
1163
|
-
return this._postMessageAsync(LISTENER_CMDS.PROCESS_REJECT_ITEM, {
|
|
1164
|
-
flowId: this._id,
|
|
1165
|
-
instanceId: options.instanceId,
|
|
1166
|
-
activityInstanceId: options.activityInstanceId,
|
|
1167
|
-
comment: options.comment
|
|
1168
|
-
});
|
|
1169
|
-
}
|
|
1170
|
-
withdrawItem(options) {
|
|
1171
|
-
const error = requireFieldAsync(options.instanceId, "instanceId");
|
|
1172
|
-
if (error)
|
|
1173
|
-
return error;
|
|
1174
|
-
return this._postMessageAsync(LISTENER_CMDS.PROCESS_WITHDRAW_ITEM, {
|
|
1175
|
-
flowId: this._id,
|
|
1176
|
-
instanceId: options.instanceId,
|
|
1177
|
-
comment: options.comment || ""
|
|
1178
|
-
});
|
|
1179
|
-
}
|
|
1180
|
-
sendbackItem(options) {
|
|
1181
|
-
const error = requireFieldsAsync([
|
|
1182
|
-
{ value: options.instanceId, name: "instanceId" },
|
|
1183
|
-
{ value: options.activityInstanceId, name: "activityInstanceId" },
|
|
1184
|
-
{ value: options.stepId, name: "stepId" },
|
|
1185
|
-
{ value: options.comment, name: "comment" }
|
|
1186
|
-
]);
|
|
1187
|
-
if (error)
|
|
1188
|
-
return error;
|
|
1189
|
-
return this._postMessageAsync(LISTENER_CMDS.PROCESS_SENDBACK_ITEM, {
|
|
1190
|
-
flowId: this._id,
|
|
1191
|
-
instanceId: options.instanceId,
|
|
1192
|
-
activityInstanceId: options.activityInstanceId,
|
|
1193
|
-
stepId: options.stepId,
|
|
1194
|
-
comment: options.comment
|
|
1195
|
-
});
|
|
1196
|
-
}
|
|
1197
|
-
reassignItem(options) {
|
|
1198
|
-
const error = requireFieldsAsync([
|
|
1199
|
-
{ value: options.instanceId, name: "instanceId" },
|
|
1200
|
-
{ value: options.activityInstanceId, name: "activityInstanceId" },
|
|
1201
|
-
{ value: options.reassignTo, name: "reassignTo" },
|
|
1202
|
-
{ value: options.comment, name: "comment" }
|
|
1203
|
-
]);
|
|
1204
|
-
if (error)
|
|
1205
|
-
return error;
|
|
1206
|
-
return this._postMessageAsync(LISTENER_CMDS.PROCESS_REASSIGN_ITEM, {
|
|
1207
|
-
flowId: this._id,
|
|
1208
|
-
instanceId: options.instanceId,
|
|
1209
|
-
activityInstanceId: options.activityInstanceId,
|
|
1210
|
-
reassignTo: options.reassignTo,
|
|
1211
|
-
comment: options.comment,
|
|
1212
|
-
reassignType: options.reassignType || "approver",
|
|
1213
|
-
reassignedFrom: options.reassignedFrom || []
|
|
1214
|
-
});
|
|
1215
|
-
}
|
|
1216
|
-
getReassignees(options) {
|
|
1217
|
-
const error = requireFieldsAsync([
|
|
1218
|
-
{ value: options.instanceId, name: "instanceId" },
|
|
1219
|
-
{ value: options.activityInstanceId, name: "activityInstanceId" }
|
|
1220
|
-
]);
|
|
1221
|
-
if (error)
|
|
1222
|
-
return error;
|
|
1223
|
-
return this._postMessageAsync(LISTENER_CMDS.PROCESS_GET_REASSIGNEES, {
|
|
1224
|
-
flowId: this._id,
|
|
1225
|
-
instanceId: options.instanceId,
|
|
1226
|
-
activityInstanceId: options.activityInstanceId,
|
|
1227
|
-
pageNumber: options.pageNumber || 1,
|
|
1228
|
-
pageSize: options.pageSize || 50,
|
|
1229
|
-
query: options.query
|
|
1230
|
-
});
|
|
1231
|
-
}
|
|
1232
|
-
restartItem(options) {
|
|
1233
|
-
const error = requireFieldsAsync([
|
|
1234
|
-
{ value: options.instanceId, name: "instanceId" },
|
|
1235
|
-
{ value: options.activityInstanceId, name: "activityInstanceId" }
|
|
1236
|
-
]);
|
|
1237
|
-
if (error)
|
|
1238
|
-
return error;
|
|
1239
|
-
return this._postMessageAsync(LISTENER_CMDS.PROCESS_RESTART_ITEM, {
|
|
1240
|
-
flowId: this._id,
|
|
1241
|
-
instanceId: options.instanceId,
|
|
1242
|
-
activityInstanceId: options.activityInstanceId
|
|
1243
|
-
});
|
|
1244
|
-
}
|
|
1245
|
-
discardItem(options) {
|
|
1246
|
-
const error = requireFieldAsync(options.instanceId, "instanceId");
|
|
1247
|
-
if (error)
|
|
1248
|
-
return error;
|
|
1249
|
-
return this._postMessageAsync(LISTENER_CMDS.PROCESS_DISCARD_ITEM, {
|
|
1250
|
-
flowId: this._id,
|
|
1251
|
-
instanceId: options.instanceId
|
|
1252
|
-
});
|
|
1253
|
-
}
|
|
1254
|
-
getFields() {
|
|
1255
|
-
return this._postMessageAsync(LISTENER_CMDS.PROCESS_GET_FIELDS, {
|
|
1256
|
-
flowId: this._id
|
|
1257
|
-
});
|
|
1258
|
-
}
|
|
1259
|
-
getMyTaskFields(options) {
|
|
1260
|
-
return this._postMessageAsync(LISTENER_CMDS.PROCESS_GET_MYTASK_FIELDS, {
|
|
1261
|
-
flowId: this._id,
|
|
1262
|
-
activityId: options.activityId,
|
|
1263
|
-
isParticipated: false
|
|
1264
|
-
});
|
|
1265
|
-
}
|
|
1266
|
-
getParticipatedFields(options) {
|
|
1267
|
-
return this._postMessageAsync(
|
|
1268
|
-
LISTENER_CMDS.PROCESS_GET_PARTICIPATED_FIELDS,
|
|
1269
|
-
{
|
|
1270
|
-
flowId: this._id,
|
|
1271
|
-
activityId: options.activityId,
|
|
1272
|
-
isParticipated: true
|
|
1273
|
-
}
|
|
1274
|
-
);
|
|
1275
|
-
}
|
|
1276
|
-
getMyItemsFields(options) {
|
|
1277
|
-
return this._postMessageAsync(
|
|
1278
|
-
LISTENER_CMDS.PROCESS_GET_MY_ITEMS_FIELDS,
|
|
1279
|
-
{
|
|
1280
|
-
flowId: this._id,
|
|
1281
|
-
status: options.status
|
|
1282
|
-
}
|
|
1283
|
-
);
|
|
1284
|
-
}
|
|
1285
|
-
getProgress(options) {
|
|
1286
|
-
const error = requireFieldAsync(options.instanceId, "instanceId");
|
|
1287
|
-
if (error)
|
|
1288
|
-
return error;
|
|
1289
|
-
return this._postMessageAsync(LISTENER_CMDS.PROCESS_GET_PROGRESS, {
|
|
1290
|
-
flowId: this._id,
|
|
1291
|
-
instanceId: options.instanceId
|
|
1292
|
-
});
|
|
1293
|
-
}
|
|
1294
|
-
initForm(instanceId, activityInstanceId) {
|
|
1295
|
-
return this._postMessageAsync(LISTENER_CMDS.PROCESS_INIT_FORM, {
|
|
1296
|
-
flowId: this._id,
|
|
1297
|
-
instanceId: instanceId || "",
|
|
1298
|
-
activityInstanceId: activityInstanceId || ""
|
|
1299
|
-
}).then((response) => {
|
|
1300
|
-
return new Form(
|
|
1301
|
-
response.storeId || instanceId || "",
|
|
1302
|
-
this._id,
|
|
1303
|
-
response.itemId || instanceId,
|
|
1304
|
-
response.activityInstanceId || activityInstanceId
|
|
1305
|
-
);
|
|
1306
|
-
});
|
|
1307
|
-
}
|
|
1308
|
-
getFieldOptions(options) {
|
|
1309
|
-
return this._postMessageAsync(LISTENER_CMDS.PROCESS_GET_FIELD_OPTIONS, {
|
|
1310
|
-
flowId: this._id,
|
|
1311
|
-
instanceId: (options == null ? void 0 : options.instanceId) || "",
|
|
1312
|
-
activityInstanceId: (options == null ? void 0 : options.activityInstanceId) || "",
|
|
1313
|
-
fieldId: (options == null ? void 0 : options.fieldId) || "",
|
|
1314
|
-
fieldType: options == null ? void 0 : options.fieldType,
|
|
1315
|
-
tableId: options == null ? void 0 : options.tableId,
|
|
1316
|
-
tableRowId: options == null ? void 0 : options.tableRowId
|
|
1317
|
-
});
|
|
1318
|
-
}
|
|
1319
|
-
parseAttachment(options) {
|
|
1320
|
-
const error = requireFieldsAsync([
|
|
1321
|
-
{ value: options.instanceId, name: "instanceId" },
|
|
1322
|
-
{ value: options.activityInstanceId, name: "activityInstanceId" },
|
|
1323
|
-
{ value: options.fieldId, name: "fieldId" },
|
|
1324
|
-
{ value: options.file, name: "file" }
|
|
1325
|
-
]);
|
|
1326
|
-
if (error)
|
|
1327
|
-
return error;
|
|
1328
|
-
return this._postMessageAsync(LISTENER_CMDS.PROCESS_PARSE_ATTACHMENT, {
|
|
1329
|
-
flowId: this._id,
|
|
1330
|
-
instanceId: options.instanceId,
|
|
1331
|
-
activityInstanceId: options.activityInstanceId,
|
|
1332
|
-
fieldId: options.fieldId,
|
|
1333
|
-
file: options.file
|
|
1334
|
-
});
|
|
1335
|
-
}
|
|
1336
|
-
}
|
|
1337
|
-
class Application extends BaseSDK {
|
|
1338
|
-
constructor(props, isCustomComponent = false) {
|
|
1339
|
-
super();
|
|
1340
|
-
this._id = props.appId;
|
|
1341
|
-
this.page = new Page(props);
|
|
1342
|
-
}
|
|
1343
|
-
getVariable(key) {
|
|
1344
|
-
return this._postMessageAsync(LISTENER_CMDS.GET_APP_VARIABLE, {
|
|
1345
|
-
key
|
|
1346
|
-
});
|
|
1347
|
-
}
|
|
1348
|
-
setVariable(key, value) {
|
|
1349
|
-
return this._postMessageAsync(LISTENER_CMDS.SET_APP_VARIABLE, {
|
|
1350
|
-
key,
|
|
1351
|
-
value
|
|
1352
|
-
});
|
|
1353
|
-
}
|
|
1354
|
-
openPage(pageId, pageParams) {
|
|
1355
|
-
return this._postMessageAsync(LISTENER_CMDS.OPEN_PAGE, {
|
|
1356
|
-
pageId,
|
|
1357
|
-
pageParams
|
|
1358
|
-
});
|
|
1359
|
-
}
|
|
1360
|
-
getDecisionTable(flowId) {
|
|
1361
|
-
return new DecisionTable(flowId);
|
|
1362
|
-
}
|
|
1363
|
-
getDataform(flowId) {
|
|
1364
|
-
return new Dataform(flowId);
|
|
1365
|
-
}
|
|
1366
|
-
getBoard(flowId) {
|
|
1367
|
-
return new Board(flowId);
|
|
1368
|
-
}
|
|
1369
|
-
getProcess(flowId) {
|
|
1370
|
-
return new Process(flowId);
|
|
1371
|
-
}
|
|
1372
|
-
getRoles() {
|
|
1373
|
-
return this._postMessageAsync(LISTENER_CMDS.GET_ROLES, {});
|
|
1374
|
-
}
|
|
1375
|
-
switchRole(args) {
|
|
1376
|
-
return this._postMessageAsync(LISTENER_CMDS.SWITCH_ROLE, {
|
|
1377
|
-
roleId: args.roleId,
|
|
1378
|
-
roleName: args.roleName
|
|
1379
|
-
});
|
|
1380
|
-
}
|
|
1381
|
-
}
|
|
1382
|
-
class NDEFReader extends BaseSDK {
|
|
1383
|
-
constructor() {
|
|
1384
|
-
super();
|
|
1385
|
-
this.id = generateId(LISTENER_CMDS.WINDOW_NDEF_READER_NEW);
|
|
1386
|
-
globalInstances[this.id] = this;
|
|
1387
|
-
this._postMessage(
|
|
1388
|
-
LISTENER_CMDS.WINDOW_NDEF_READER_NEW,
|
|
1389
|
-
{
|
|
1390
|
-
id: this.id,
|
|
1391
|
-
operation: "new"
|
|
1392
|
-
},
|
|
1393
|
-
(data) => {
|
|
1394
|
-
}
|
|
1395
|
-
);
|
|
1396
|
-
}
|
|
1397
|
-
scan() {
|
|
1398
|
-
return new Promise((resolve, reject) => {
|
|
1399
|
-
this._postMessage(
|
|
1400
|
-
LISTENER_CMDS.WINDOW_NDEF_READER_SCAN,
|
|
1401
|
-
{ id: this.id, operation: "scan" },
|
|
1402
|
-
({ data, err }) => {
|
|
1403
|
-
console.log("scan data from main window ", data);
|
|
1404
|
-
resolve(data);
|
|
1405
|
-
}
|
|
1406
|
-
);
|
|
1407
|
-
});
|
|
1408
|
-
}
|
|
1409
|
-
write(data) {
|
|
1410
|
-
return new Promise((resolve, reject) => {
|
|
1411
|
-
this._postMessage(
|
|
1412
|
-
LISTENER_CMDS.WINDOW_NDEF_READER_WRITE,
|
|
1413
|
-
{ id: this.id, operation: "write", data },
|
|
1414
|
-
({ data: data2, err }) => {
|
|
1415
|
-
}
|
|
1416
|
-
);
|
|
1417
|
-
});
|
|
1418
|
-
}
|
|
1419
|
-
addEventListener(eventName, cb) {
|
|
1420
|
-
this._postMessage(
|
|
1421
|
-
LISTENER_CMDS.WINDOW_NDEF_READER_ADD_EVENT_LISTENER,
|
|
1422
|
-
{
|
|
1423
|
-
id: this.id,
|
|
1424
|
-
operation: "addEventListener",
|
|
1425
|
-
eventName
|
|
1426
|
-
},
|
|
1427
|
-
() => {
|
|
1428
|
-
}
|
|
1429
|
-
);
|
|
1430
|
-
}
|
|
1431
|
-
makeReadOnly() {
|
|
1432
|
-
return new Promise((resolve, reject) => {
|
|
1433
|
-
this._postMessage(
|
|
1434
|
-
LISTENER_CMDS.WINDOW_NDEF_READER_MAKE_READONLY,
|
|
1435
|
-
{ id: this.id, operation: "makeReadOnly" },
|
|
1436
|
-
({ data, err }) => {
|
|
1437
|
-
}
|
|
1438
|
-
);
|
|
1439
|
-
});
|
|
1440
|
-
}
|
|
1441
|
-
abortScan() {
|
|
1442
|
-
return new Promise((resolve, reject) => {
|
|
1443
|
-
this._postMessage(
|
|
1444
|
-
LISTENER_CMDS.WINDOW_NDEF_READER_ABORT_SCAN,
|
|
1445
|
-
{ id: this.id, operation: "abortScan" },
|
|
1446
|
-
({ data, err }) => {
|
|
1447
|
-
}
|
|
1448
|
-
);
|
|
1449
|
-
});
|
|
1450
|
-
}
|
|
1451
|
-
}
|
|
1452
|
-
const window = {
|
|
1453
|
-
NDEFReader
|
|
1454
|
-
};
|
|
1455
|
-
class LowcodeSDK extends BaseSDK {
|
|
1456
|
-
constructor(props) {
|
|
1457
|
-
super();
|
|
1458
|
-
__privateAdd(this, _csrfToken, void 0);
|
|
1459
|
-
if (props.tableId && props.tableRowId) {
|
|
1460
|
-
this.context = new TableForm(
|
|
1461
|
-
props.formInstanceId,
|
|
1462
|
-
props.flowId,
|
|
1463
|
-
props.formInstanceId,
|
|
1464
|
-
props.tableId,
|
|
1465
|
-
props.tableRowId
|
|
1466
|
-
);
|
|
1467
|
-
} else if (props.formInstanceId) {
|
|
1468
|
-
this.context = new Form(
|
|
1469
|
-
props.formInstanceId,
|
|
1470
|
-
props.flowId,
|
|
1471
|
-
props.formInstanceId
|
|
1472
|
-
);
|
|
1473
|
-
} else if (props.popupId) {
|
|
1474
|
-
this.context = new Popup(props);
|
|
1475
|
-
} else if (props.pageId && !props.componentId) {
|
|
1476
|
-
this.context = new Page(props);
|
|
1477
|
-
} else if (props.componentId) {
|
|
1478
|
-
this.context = new Component(props);
|
|
1479
|
-
}
|
|
1480
|
-
this.client = new Client();
|
|
1481
|
-
this.formatter = new Formatter();
|
|
1482
|
-
if (props.appId) {
|
|
1483
|
-
this.app = new Application(props);
|
|
1484
|
-
}
|
|
1485
|
-
this.user = props.user;
|
|
1486
|
-
this.env = props.envDetails;
|
|
1487
|
-
this.account = props.account;
|
|
1488
|
-
__privateSet(this, _csrfToken, props.csrfToken);
|
|
1489
|
-
}
|
|
1490
|
-
async api(url, args) {
|
|
1491
|
-
const response = await globalThis.fetch(url, {
|
|
1492
|
-
...args,
|
|
1493
|
-
headers: {
|
|
1494
|
-
...(args == null ? void 0 : args.headers) || {},
|
|
1495
|
-
"X-Csrf-Token": __privateGet(this, _csrfToken)
|
|
1496
|
-
}
|
|
1497
|
-
});
|
|
1498
|
-
const contentType = response.headers.get("content-type");
|
|
1499
|
-
if (contentType && contentType.includes("application/json")) {
|
|
1500
|
-
return await response.json();
|
|
1501
|
-
} else {
|
|
1502
|
-
return response;
|
|
1503
|
-
}
|
|
1504
|
-
}
|
|
1505
|
-
}
|
|
1506
|
-
_csrfToken = new WeakMap();
|
|
1507
|
-
function initSDK(config) {
|
|
1508
|
-
return new LowcodeSDK(config);
|
|
1509
|
-
}
|
|
1510
|
-
export { initSDK as default, window };
|