@kissflow/lowcode-client-sdk 1.0.13-beta → 1.0.14-beta
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/kf.lowcodeworkersdk.es.js +109 -70
- package/dist/kf.nocodeworkersdk.es.js +75 -54
- package/dist/kfsdk.es.js +66 -53
- package/dist/kfsdk.umd.js +1 -1
- package/dist/snippets.json +183 -0
- package/package.json +1 -1
|
@@ -1,22 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
1
|
var __accessCheck = (obj, member, msg) => {
|
|
21
2
|
if (!member.has(obj))
|
|
22
3
|
throw TypeError("Cannot " + msg);
|
|
@@ -158,7 +139,9 @@ class EventBase {
|
|
|
158
139
|
}
|
|
159
140
|
_dispatchEvent(eventName, eventParams) {
|
|
160
141
|
if (Array.isArray(__privateGet(this, _listeners)[eventName])) {
|
|
161
|
-
__privateGet(this, _listeners)[eventName].forEach(
|
|
142
|
+
__privateGet(this, _listeners)[eventName].forEach(
|
|
143
|
+
(callBack) => callBack(eventParams)
|
|
144
|
+
);
|
|
162
145
|
return true;
|
|
163
146
|
}
|
|
164
147
|
return false;
|
|
@@ -186,7 +169,7 @@ class BaseSDK extends EventBase {
|
|
|
186
169
|
_postMessageAsync(command, args, hasCallBack, callBack) {
|
|
187
170
|
return new Promise((resolve, reject) => {
|
|
188
171
|
const _id = generateId(command.toLowerCase());
|
|
189
|
-
postMessage(
|
|
172
|
+
postMessage({ _id, command, ...args });
|
|
190
173
|
globalInstances[_id] = this;
|
|
191
174
|
this._addEventListener(_id, async (data) => {
|
|
192
175
|
if (data == null ? void 0 : data.errorMessage) {
|
|
@@ -202,7 +185,7 @@ class BaseSDK extends EventBase {
|
|
|
202
185
|
}
|
|
203
186
|
_postMessage(command, args, callBack) {
|
|
204
187
|
const _id = generateId(command.toLowerCase());
|
|
205
|
-
postMessage(
|
|
188
|
+
postMessage({ _id, command, ...args });
|
|
206
189
|
if (callBack) {
|
|
207
190
|
this._addEventListener(args.eventName, callBack);
|
|
208
191
|
}
|
|
@@ -241,14 +224,22 @@ class Table extends BaseSDK {
|
|
|
241
224
|
this.instanceId = instanceId;
|
|
242
225
|
}
|
|
243
226
|
toJSON() {
|
|
244
|
-
return this._postMessageAsync(
|
|
245
|
-
|
|
246
|
-
|
|
227
|
+
return this._postMessageAsync(
|
|
228
|
+
LISTENER_CMDS.TO_JSON,
|
|
229
|
+
{
|
|
230
|
+
tableId: this.tableId
|
|
231
|
+
}
|
|
232
|
+
);
|
|
247
233
|
}
|
|
248
234
|
getRows() {
|
|
249
|
-
return this._postMessageAsync(
|
|
250
|
-
|
|
251
|
-
|
|
235
|
+
return this._postMessageAsync(
|
|
236
|
+
LISTENER_CMDS.GET_TABLE_ROWS,
|
|
237
|
+
{ tableId: this.tableId },
|
|
238
|
+
true,
|
|
239
|
+
(data) => {
|
|
240
|
+
return data.map((row) => new TableForm(this.instanceId, this.tableId, row.id));
|
|
241
|
+
}
|
|
242
|
+
);
|
|
252
243
|
}
|
|
253
244
|
getRow(rowId) {
|
|
254
245
|
return new TableForm(this.instanceId, this.tableId, rowId);
|
|
@@ -356,13 +347,17 @@ class Component extends BaseSDK {
|
|
|
356
347
|
__privateMethod(this, _registerComponentAPIs, registerComponentAPIs_fn).call(this, props.componentMethods);
|
|
357
348
|
}
|
|
358
349
|
onMount(callback) {
|
|
359
|
-
this._postMessage(
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
350
|
+
this._postMessage(
|
|
351
|
+
LISTENER_CMDS.COMPONENT_ADD_EVENT_LISTENER,
|
|
352
|
+
{
|
|
353
|
+
id: this._id,
|
|
354
|
+
eventName: EVENT_TYPES.COMPONENT_ON_MOUNT,
|
|
355
|
+
eventConfig: {
|
|
356
|
+
once: true
|
|
357
|
+
}
|
|
358
|
+
},
|
|
359
|
+
callback
|
|
360
|
+
);
|
|
366
361
|
}
|
|
367
362
|
refresh() {
|
|
368
363
|
return this._postMessageAsync(LISTENER_CMDS.COMPONENT_REFRESH, {
|
|
@@ -390,11 +385,15 @@ registerComponentAPIs_fn = function(componentAPIs) {
|
|
|
390
385
|
parameters: args
|
|
391
386
|
});
|
|
392
387
|
} else if (Api.type === "event") {
|
|
393
|
-
this._postMessage(
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
388
|
+
this._postMessage(
|
|
389
|
+
LISTENER_CMDS.COMPONENT_ADD_EVENT_LISTENER,
|
|
390
|
+
{
|
|
391
|
+
id: this._id,
|
|
392
|
+
eventName: Api.name,
|
|
393
|
+
eventConfig: args[1]
|
|
394
|
+
},
|
|
395
|
+
args[0]
|
|
396
|
+
);
|
|
398
397
|
}
|
|
399
398
|
};
|
|
400
399
|
});
|
|
@@ -420,9 +419,14 @@ class Popup extends BaseSDK {
|
|
|
420
419
|
return this._postMessageAsync(LISTENER_CMDS.CLOSE_POPUP, {});
|
|
421
420
|
}
|
|
422
421
|
getComponent(componentId) {
|
|
423
|
-
return this._postMessageAsync(
|
|
424
|
-
|
|
425
|
-
|
|
422
|
+
return this._postMessageAsync(
|
|
423
|
+
LISTENER_CMDS.COMPONENT_GET,
|
|
424
|
+
{ componentId },
|
|
425
|
+
true,
|
|
426
|
+
(data) => {
|
|
427
|
+
return new Component(data);
|
|
428
|
+
}
|
|
429
|
+
);
|
|
426
430
|
}
|
|
427
431
|
}
|
|
428
432
|
class Page extends BaseSDK {
|
|
@@ -460,7 +464,12 @@ class Page extends BaseSDK {
|
|
|
460
464
|
});
|
|
461
465
|
}
|
|
462
466
|
getComponent(componentId) {
|
|
463
|
-
return this._postMessageAsync(
|
|
467
|
+
return this._postMessageAsync(
|
|
468
|
+
LISTENER_CMDS.COMPONENT_GET,
|
|
469
|
+
{ componentId },
|
|
470
|
+
true,
|
|
471
|
+
(data) => new Component(data)
|
|
472
|
+
);
|
|
464
473
|
}
|
|
465
474
|
}
|
|
466
475
|
class Application extends BaseSDK {
|
|
@@ -492,44 +501,68 @@ class NDEFReader extends BaseSDK {
|
|
|
492
501
|
super();
|
|
493
502
|
this.id = generateId(LISTENER_CMDS.WINDOW_NDEF_READER_NEW);
|
|
494
503
|
globalInstances[this.id] = this;
|
|
495
|
-
this._postMessage(
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
504
|
+
this._postMessage(
|
|
505
|
+
LISTENER_CMDS.WINDOW_NDEF_READER_NEW,
|
|
506
|
+
{
|
|
507
|
+
id: this.id,
|
|
508
|
+
operation: "new"
|
|
509
|
+
},
|
|
510
|
+
(data) => {
|
|
511
|
+
}
|
|
512
|
+
);
|
|
500
513
|
}
|
|
501
514
|
scan() {
|
|
502
515
|
return new Promise((resolve, reject) => {
|
|
503
|
-
this._postMessage(
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
516
|
+
this._postMessage(
|
|
517
|
+
LISTENER_CMDS.WINDOW_NDEF_READER_SCAN,
|
|
518
|
+
{ id: this.id, operation: "scan" },
|
|
519
|
+
({ data, err }) => {
|
|
520
|
+
console.log("scan data from main window ", data);
|
|
521
|
+
resolve(data);
|
|
522
|
+
}
|
|
523
|
+
);
|
|
507
524
|
});
|
|
508
525
|
}
|
|
509
526
|
write(data) {
|
|
510
527
|
return new Promise((resolve, reject) => {
|
|
511
|
-
this._postMessage(
|
|
512
|
-
|
|
528
|
+
this._postMessage(
|
|
529
|
+
LISTENER_CMDS.WINDOW_NDEF_READER_WRITE,
|
|
530
|
+
{ id: this.id, operation: "write", data },
|
|
531
|
+
({ data: data2, err }) => {
|
|
532
|
+
}
|
|
533
|
+
);
|
|
513
534
|
});
|
|
514
535
|
}
|
|
515
536
|
addEventListener(eventName, cb) {
|
|
516
|
-
this._postMessage(
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
537
|
+
this._postMessage(
|
|
538
|
+
LISTENER_CMDS.WINDOW_NDEF_READER_ADD_EVENT_LISTENER,
|
|
539
|
+
{
|
|
540
|
+
id: this.id,
|
|
541
|
+
operation: "addEventListener",
|
|
542
|
+
eventName
|
|
543
|
+
},
|
|
544
|
+
() => {
|
|
545
|
+
}
|
|
546
|
+
);
|
|
522
547
|
}
|
|
523
548
|
makeReadOnly() {
|
|
524
549
|
return new Promise((resolve, reject) => {
|
|
525
|
-
this._postMessage(
|
|
526
|
-
|
|
550
|
+
this._postMessage(
|
|
551
|
+
LISTENER_CMDS.WINDOW_NDEF_READER_MAKE_READONLY,
|
|
552
|
+
{ id: this.id, operation: "makeReadOnly" },
|
|
553
|
+
({ data, err }) => {
|
|
554
|
+
}
|
|
555
|
+
);
|
|
527
556
|
});
|
|
528
557
|
}
|
|
529
558
|
abortScan() {
|
|
530
559
|
return new Promise((resolve, reject) => {
|
|
531
|
-
this._postMessage(
|
|
532
|
-
|
|
560
|
+
this._postMessage(
|
|
561
|
+
LISTENER_CMDS.WINDOW_NDEF_READER_ABORT_SCAN,
|
|
562
|
+
{ id: this.id, operation: "abortScan" },
|
|
563
|
+
({ data, err }) => {
|
|
564
|
+
}
|
|
565
|
+
);
|
|
533
566
|
});
|
|
534
567
|
}
|
|
535
568
|
}
|
|
@@ -541,7 +574,11 @@ class LowcodeSDK extends BaseSDK {
|
|
|
541
574
|
super();
|
|
542
575
|
__privateAdd(this, _csrfToken, void 0);
|
|
543
576
|
if (props.tableId && props.tableRowId) {
|
|
544
|
-
this.context = new TableForm(
|
|
577
|
+
this.context = new TableForm(
|
|
578
|
+
props.formInstanceId,
|
|
579
|
+
props.tableId,
|
|
580
|
+
props.tableRowId
|
|
581
|
+
);
|
|
545
582
|
} else if (props.formInstanceId) {
|
|
546
583
|
this.context = new Form(props.formInstanceId);
|
|
547
584
|
} else if (props.popupId) {
|
|
@@ -562,11 +599,13 @@ class LowcodeSDK extends BaseSDK {
|
|
|
562
599
|
__privateSet(this, _csrfToken, props.csrfToken);
|
|
563
600
|
}
|
|
564
601
|
async api(url, args) {
|
|
565
|
-
const response = await globalThis.fetch(url,
|
|
566
|
-
|
|
602
|
+
const response = await globalThis.fetch(url, {
|
|
603
|
+
...args,
|
|
604
|
+
headers: {
|
|
605
|
+
...(args == null ? void 0 : args.headers) || {},
|
|
567
606
|
"X-Csrf-Token": __privateGet(this, _csrfToken)
|
|
568
|
-
}
|
|
569
|
-
})
|
|
607
|
+
}
|
|
608
|
+
});
|
|
570
609
|
const contentType = response.headers.get("content-type");
|
|
571
610
|
if (contentType && contentType.includes("application/json")) {
|
|
572
611
|
return await response.json();
|
|
@@ -1,22 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
1
|
var __accessCheck = (obj, member, msg) => {
|
|
21
2
|
if (!member.has(obj))
|
|
22
3
|
throw TypeError("Cannot " + msg);
|
|
@@ -147,7 +128,9 @@ class EventBase {
|
|
|
147
128
|
}
|
|
148
129
|
_dispatchEvent(eventName, eventParams) {
|
|
149
130
|
if (Array.isArray(__privateGet(this, _listeners)[eventName])) {
|
|
150
|
-
__privateGet(this, _listeners)[eventName].forEach(
|
|
131
|
+
__privateGet(this, _listeners)[eventName].forEach(
|
|
132
|
+
(callBack) => callBack(eventParams)
|
|
133
|
+
);
|
|
151
134
|
return true;
|
|
152
135
|
}
|
|
153
136
|
return false;
|
|
@@ -175,7 +158,7 @@ class BaseSDK extends EventBase {
|
|
|
175
158
|
_postMessageAsync(command, args, hasCallBack, callBack) {
|
|
176
159
|
return new Promise((resolve, reject) => {
|
|
177
160
|
const _id = generateId(command.toLowerCase());
|
|
178
|
-
postMessage(
|
|
161
|
+
postMessage({ _id, command, ...args });
|
|
179
162
|
globalInstances[_id] = this;
|
|
180
163
|
this._addEventListener(_id, async (data) => {
|
|
181
164
|
if (data == null ? void 0 : data.errorMessage) {
|
|
@@ -191,7 +174,7 @@ class BaseSDK extends EventBase {
|
|
|
191
174
|
}
|
|
192
175
|
_postMessage(command, args, callBack) {
|
|
193
176
|
const _id = generateId(command.toLowerCase());
|
|
194
|
-
postMessage(
|
|
177
|
+
postMessage({ _id, command, ...args });
|
|
195
178
|
if (callBack) {
|
|
196
179
|
this._addEventListener(args.eventName, callBack);
|
|
197
180
|
}
|
|
@@ -230,14 +213,22 @@ class Table extends BaseSDK {
|
|
|
230
213
|
this.instanceId = instanceId;
|
|
231
214
|
}
|
|
232
215
|
toJSON() {
|
|
233
|
-
return this._postMessageAsync(
|
|
234
|
-
|
|
235
|
-
|
|
216
|
+
return this._postMessageAsync(
|
|
217
|
+
LISTENER_CMDS.TO_JSON,
|
|
218
|
+
{
|
|
219
|
+
tableId: this.tableId
|
|
220
|
+
}
|
|
221
|
+
);
|
|
236
222
|
}
|
|
237
223
|
getRows() {
|
|
238
|
-
return this._postMessageAsync(
|
|
239
|
-
|
|
240
|
-
|
|
224
|
+
return this._postMessageAsync(
|
|
225
|
+
LISTENER_CMDS.GET_TABLE_ROWS,
|
|
226
|
+
{ tableId: this.tableId },
|
|
227
|
+
true,
|
|
228
|
+
(data) => {
|
|
229
|
+
return data.map((row) => new TableForm(this.instanceId, this.tableId, row.id));
|
|
230
|
+
}
|
|
231
|
+
);
|
|
241
232
|
}
|
|
242
233
|
getRow(rowId) {
|
|
243
234
|
return new TableForm(this.instanceId, this.tableId, rowId);
|
|
@@ -340,44 +331,68 @@ class NDEFReader extends BaseSDK {
|
|
|
340
331
|
super();
|
|
341
332
|
this.id = generateId(LISTENER_CMDS.WINDOW_NDEF_READER_NEW);
|
|
342
333
|
globalInstances[this.id] = this;
|
|
343
|
-
this._postMessage(
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
334
|
+
this._postMessage(
|
|
335
|
+
LISTENER_CMDS.WINDOW_NDEF_READER_NEW,
|
|
336
|
+
{
|
|
337
|
+
id: this.id,
|
|
338
|
+
operation: "new"
|
|
339
|
+
},
|
|
340
|
+
(data) => {
|
|
341
|
+
}
|
|
342
|
+
);
|
|
348
343
|
}
|
|
349
344
|
scan() {
|
|
350
345
|
return new Promise((resolve, reject) => {
|
|
351
|
-
this._postMessage(
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
346
|
+
this._postMessage(
|
|
347
|
+
LISTENER_CMDS.WINDOW_NDEF_READER_SCAN,
|
|
348
|
+
{ id: this.id, operation: "scan" },
|
|
349
|
+
({ data, err }) => {
|
|
350
|
+
console.log("scan data from main window ", data);
|
|
351
|
+
resolve(data);
|
|
352
|
+
}
|
|
353
|
+
);
|
|
355
354
|
});
|
|
356
355
|
}
|
|
357
356
|
write(data) {
|
|
358
357
|
return new Promise((resolve, reject) => {
|
|
359
|
-
this._postMessage(
|
|
360
|
-
|
|
358
|
+
this._postMessage(
|
|
359
|
+
LISTENER_CMDS.WINDOW_NDEF_READER_WRITE,
|
|
360
|
+
{ id: this.id, operation: "write", data },
|
|
361
|
+
({ data: data2, err }) => {
|
|
362
|
+
}
|
|
363
|
+
);
|
|
361
364
|
});
|
|
362
365
|
}
|
|
363
366
|
addEventListener(eventName, cb) {
|
|
364
|
-
this._postMessage(
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
367
|
+
this._postMessage(
|
|
368
|
+
LISTENER_CMDS.WINDOW_NDEF_READER_ADD_EVENT_LISTENER,
|
|
369
|
+
{
|
|
370
|
+
id: this.id,
|
|
371
|
+
operation: "addEventListener",
|
|
372
|
+
eventName
|
|
373
|
+
},
|
|
374
|
+
() => {
|
|
375
|
+
}
|
|
376
|
+
);
|
|
370
377
|
}
|
|
371
378
|
makeReadOnly() {
|
|
372
379
|
return new Promise((resolve, reject) => {
|
|
373
|
-
this._postMessage(
|
|
374
|
-
|
|
380
|
+
this._postMessage(
|
|
381
|
+
LISTENER_CMDS.WINDOW_NDEF_READER_MAKE_READONLY,
|
|
382
|
+
{ id: this.id, operation: "makeReadOnly" },
|
|
383
|
+
({ data, err }) => {
|
|
384
|
+
}
|
|
385
|
+
);
|
|
375
386
|
});
|
|
376
387
|
}
|
|
377
388
|
abortScan() {
|
|
378
389
|
return new Promise((resolve, reject) => {
|
|
379
|
-
this._postMessage(
|
|
380
|
-
|
|
390
|
+
this._postMessage(
|
|
391
|
+
LISTENER_CMDS.WINDOW_NDEF_READER_ABORT_SCAN,
|
|
392
|
+
{ id: this.id, operation: "abortScan" },
|
|
393
|
+
({ data, err }) => {
|
|
394
|
+
}
|
|
395
|
+
);
|
|
381
396
|
});
|
|
382
397
|
}
|
|
383
398
|
}
|
|
@@ -389,7 +404,11 @@ class NocodeSDK extends BaseSDK {
|
|
|
389
404
|
super();
|
|
390
405
|
__privateAdd(this, _csrfToken, void 0);
|
|
391
406
|
if (props.tableId && props.tableRowId) {
|
|
392
|
-
this.context = new TableForm(
|
|
407
|
+
this.context = new TableForm(
|
|
408
|
+
props.formInstanceId,
|
|
409
|
+
props.tableId,
|
|
410
|
+
props.tableRowId
|
|
411
|
+
);
|
|
393
412
|
} else if (props.formInstanceId) {
|
|
394
413
|
this.context = new Form(props.formInstanceId);
|
|
395
414
|
}
|
|
@@ -400,11 +419,13 @@ class NocodeSDK extends BaseSDK {
|
|
|
400
419
|
__privateSet(this, _csrfToken, props.csrfToken);
|
|
401
420
|
}
|
|
402
421
|
async api(url, args) {
|
|
403
|
-
const response = await globalThis.fetch(url,
|
|
404
|
-
|
|
422
|
+
const response = await globalThis.fetch(url, {
|
|
423
|
+
...args,
|
|
424
|
+
headers: {
|
|
425
|
+
...(args == null ? void 0 : args.headers) || {},
|
|
405
426
|
"X-Csrf-Token": __privateGet(this, _csrfToken)
|
|
406
|
-
}
|
|
407
|
-
})
|
|
427
|
+
}
|
|
428
|
+
});
|
|
408
429
|
const contentType = response.headers.get("content-type");
|
|
409
430
|
if (contentType && contentType.includes("application/json")) {
|
|
410
431
|
return await response.json();
|
package/dist/kfsdk.es.js
CHANGED
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
-
var __spreadValues = (a, b) => {
|
|
7
|
-
for (var prop in b || (b = {}))
|
|
8
|
-
if (__hasOwnProp.call(b, prop))
|
|
9
|
-
__defNormalProp(a, prop, b[prop]);
|
|
10
|
-
if (__getOwnPropSymbols)
|
|
11
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
-
if (__propIsEnum.call(b, prop))
|
|
13
|
-
__defNormalProp(a, prop, b[prop]);
|
|
14
|
-
}
|
|
15
|
-
return a;
|
|
16
|
-
};
|
|
17
1
|
var __accessCheck = (obj, member, msg) => {
|
|
18
2
|
if (!member.has(obj))
|
|
19
3
|
throw TypeError("Cannot " + msg);
|
|
@@ -155,7 +139,9 @@ class EventBase {
|
|
|
155
139
|
}
|
|
156
140
|
_dispatchEvent(eventName, eventParams) {
|
|
157
141
|
if (Array.isArray(__privateGet(this, _listeners)[eventName])) {
|
|
158
|
-
__privateGet(this, _listeners)[eventName].forEach(
|
|
142
|
+
__privateGet(this, _listeners)[eventName].forEach(
|
|
143
|
+
(callBack) => callBack(eventParams)
|
|
144
|
+
);
|
|
159
145
|
return true;
|
|
160
146
|
}
|
|
161
147
|
return false;
|
|
@@ -183,7 +169,7 @@ class BaseSDK extends EventBase {
|
|
|
183
169
|
_postMessageAsync(command, args, hasCallBack, callBack) {
|
|
184
170
|
return new Promise((resolve, reject) => {
|
|
185
171
|
const _id = generateId(command.toLowerCase());
|
|
186
|
-
postMessage(
|
|
172
|
+
postMessage({ _id, command, ...args });
|
|
187
173
|
globalInstances[_id] = this;
|
|
188
174
|
this._addEventListener(_id, async (data) => {
|
|
189
175
|
if (data == null ? void 0 : data.errorMessage) {
|
|
@@ -199,7 +185,7 @@ class BaseSDK extends EventBase {
|
|
|
199
185
|
}
|
|
200
186
|
_postMessage(command, args, callBack) {
|
|
201
187
|
const _id = generateId(command.toLowerCase());
|
|
202
|
-
postMessage(
|
|
188
|
+
postMessage({ _id, command, ...args });
|
|
203
189
|
if (callBack) {
|
|
204
190
|
this._addEventListener(args.eventName, callBack);
|
|
205
191
|
}
|
|
@@ -215,13 +201,17 @@ class Component extends BaseSDK {
|
|
|
215
201
|
__privateMethod(this, _registerComponentAPIs, registerComponentAPIs_fn).call(this, props.componentMethods);
|
|
216
202
|
}
|
|
217
203
|
onMount(callback) {
|
|
218
|
-
this._postMessage(
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
204
|
+
this._postMessage(
|
|
205
|
+
LISTENER_CMDS.COMPONENT_ADD_EVENT_LISTENER,
|
|
206
|
+
{
|
|
207
|
+
id: this._id,
|
|
208
|
+
eventName: EVENT_TYPES.COMPONENT_ON_MOUNT,
|
|
209
|
+
eventConfig: {
|
|
210
|
+
once: true
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
callback
|
|
214
|
+
);
|
|
225
215
|
}
|
|
226
216
|
refresh() {
|
|
227
217
|
return this._postMessageAsync(LISTENER_CMDS.COMPONENT_REFRESH, {
|
|
@@ -249,11 +239,15 @@ registerComponentAPIs_fn = function(componentAPIs) {
|
|
|
249
239
|
parameters: args
|
|
250
240
|
});
|
|
251
241
|
} else if (Api.type === "event") {
|
|
252
|
-
this._postMessage(
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
242
|
+
this._postMessage(
|
|
243
|
+
LISTENER_CMDS.COMPONENT_ADD_EVENT_LISTENER,
|
|
244
|
+
{
|
|
245
|
+
id: this._id,
|
|
246
|
+
eventName: Api.name,
|
|
247
|
+
eventConfig: args[1]
|
|
248
|
+
},
|
|
249
|
+
args[0]
|
|
250
|
+
);
|
|
257
251
|
}
|
|
258
252
|
};
|
|
259
253
|
});
|
|
@@ -266,13 +260,17 @@ class CustomComponent extends BaseSDK {
|
|
|
266
260
|
globalInstances[this._id] = this;
|
|
267
261
|
}
|
|
268
262
|
watchParams(callBack) {
|
|
269
|
-
this._postMessage(
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
263
|
+
this._postMessage(
|
|
264
|
+
LISTENER_CMDS.CC_WATCH_PARAMS,
|
|
265
|
+
{
|
|
266
|
+
id: this._id,
|
|
267
|
+
eventName: EVENT_TYPES.CC_ON_PARAMS_CHANGE,
|
|
268
|
+
eventConfig: {
|
|
269
|
+
once: false
|
|
270
|
+
}
|
|
271
|
+
},
|
|
272
|
+
callBack
|
|
273
|
+
);
|
|
276
274
|
}
|
|
277
275
|
}
|
|
278
276
|
class Popup extends BaseSDK {
|
|
@@ -296,9 +294,14 @@ class Popup extends BaseSDK {
|
|
|
296
294
|
return this._postMessageAsync(LISTENER_CMDS.CLOSE_POPUP, {});
|
|
297
295
|
}
|
|
298
296
|
getComponent(componentId) {
|
|
299
|
-
return this._postMessageAsync(
|
|
300
|
-
|
|
301
|
-
|
|
297
|
+
return this._postMessageAsync(
|
|
298
|
+
LISTENER_CMDS.COMPONENT_GET,
|
|
299
|
+
{ componentId },
|
|
300
|
+
true,
|
|
301
|
+
(data) => {
|
|
302
|
+
return new Component(data);
|
|
303
|
+
}
|
|
304
|
+
);
|
|
302
305
|
}
|
|
303
306
|
}
|
|
304
307
|
class Page extends BaseSDK {
|
|
@@ -336,7 +339,12 @@ class Page extends BaseSDK {
|
|
|
336
339
|
});
|
|
337
340
|
}
|
|
338
341
|
getComponent(componentId) {
|
|
339
|
-
return this._postMessageAsync(
|
|
342
|
+
return this._postMessageAsync(
|
|
343
|
+
LISTENER_CMDS.COMPONENT_GET,
|
|
344
|
+
{ componentId },
|
|
345
|
+
true,
|
|
346
|
+
(data) => new Component(data)
|
|
347
|
+
);
|
|
340
348
|
}
|
|
341
349
|
}
|
|
342
350
|
class Application extends BaseSDK {
|
|
@@ -417,17 +425,22 @@ class CustomComponentSDK extends BaseSDK {
|
|
|
417
425
|
return this._postMessageAsync(LISTENER_CMDS.API, { url, args });
|
|
418
426
|
}
|
|
419
427
|
initialize() {
|
|
420
|
-
return this._postMessageAsync(
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
428
|
+
return this._postMessageAsync(
|
|
429
|
+
LISTENER_CMDS.CC_INITIALIZE,
|
|
430
|
+
{},
|
|
431
|
+
true,
|
|
432
|
+
(data) => {
|
|
433
|
+
this.app = new Application(data);
|
|
434
|
+
this.page = new Page(data);
|
|
435
|
+
this.context = new CustomComponent(data.componentId);
|
|
436
|
+
this.client = new Client();
|
|
437
|
+
this.formatter = new Formatter();
|
|
438
|
+
this.user = data.user;
|
|
439
|
+
this.account = data.account;
|
|
440
|
+
this.env = data.envDetails;
|
|
441
|
+
return this;
|
|
442
|
+
}
|
|
443
|
+
);
|
|
431
444
|
}
|
|
432
445
|
initialise() {
|
|
433
446
|
return this.initialize();
|
package/dist/kfsdk.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var c=(E,t,i)=>{if(!t.has(E))throw TypeError("Cannot "+i)};var o=(E,t,i)=>(c(E,t,"read from private field"),i?i.call(E):t.get(E)),p=(E,t,i)=>{if(t.has(E))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(E):t.set(E,i)},g=(E,t,i,a)=>(c(E,t,"write to private field"),a?a.call(E,i):t.set(E,i),i);var l=(E,t,i)=>(c(E,t,"access private method"),i);(function(E,t){typeof exports=="object"&&typeof module!="undefined"?module.exports=t():typeof define=="function"&&define.amd?define(t):(E=typeof globalThis!="undefined"?globalThis:E||self,E.kf=t())})(this,function(){var A,M,L;"use strict";let E=(n=21)=>crypto.getRandomValues(new Uint8Array(n)).reduce((e,s)=>(s&=63,s<36?e+=s.toString(36):s<62?e+=(s-26).toString(36).toUpperCase():s>62?e+="-":e+="_",e),"");const t={API:"API",GET_CONTEXT:"GET_CONTEXT",RETURN:"RETURN",GET_FORM_FIELD:"GET_FORM_FIELD",UPDATE_FORM:"UPDATE_FORM",GET_TABLE:"GET_TABLE",GET_TABLE_ROW:"GET_TABLE_ROW",ADD_TABLE_ROW:"ADD_TABLE_ROW",DELETE_TABLE_ROW:"DELETE_TABLE_ROW",TO_JSON:"TO_JSON",GET_TABLE_ROWS:"GET_TABLE_ROWS",MESSAGE:"MESSAGE",CONFIRM:"CONFIRM",ALERT:"ALERT",REDIRECT:"REDIRECT",OPEN_PAGE:"OPEN_PAGE",FORMAT_DATE:"FORMAT_DATE",FORMAT_DATE_TIME:"FORMAT_DATE_TIME",FORMAT_NUMBER:"FORMAT_NUMBER",FORMAT_CURRENCY:"FORMAT_CURRENCY",FORMAT_BOOLEAN:"FORMAT_BOOLEAN",GET_APP_VARIABLE:"GET_APP_VARIABLE",SET_APP_VARIABLE:"SET_APP_VARIABLE",GET_PAGE_VARIABLE:"GET_PAGE_VARIABLE",SET_PAGE_VARIABLE:"SET_PAGE_VARIABLE",GET_PAGE_PARAMS:"GET_PAGE_PARAMS",GET_ALL_PAGE_PARAMS:"GET_ALL_PAGE_PARAMS",PAGE_ON_CLOSE:"PAGE_ON_CLOSE",OPEN_POPUP:"OPEN_POPUP",GET_POPUP_PARAMS:"GET_POPUP_PARAMS",GET_ALL_POPUP_PARAMS:"GET_ALL_POPUP_PARAMS",CLOSE_POPUP:"CLOSE_POPUP",COMPONENT_GET:"COMPONENT_GET",COMPONENT_REFRESH:"COMPONENT_REFRESH",COMPONENT_SHOW:"COMPONENT_SHOW",COMPONENT_HIDE:"COMPONENT_HIDE",COMPONENT_ADD_EVENT_LISTENER:"COMPONENT_ADD_EVENT_LISTENER",CC_INITIALIZE:"CC_INITIALIZE",CC_WATCH_PARAMS:"CC_WATCH_PARAMS",WINDOW_NDEF_READER_NEW:"WINDOW_NDEF_READER_NEW",WINDOW_NDEF_READER_SCAN:"WINDOW_NDEF_READER_SCAN",WINDOW_NDEF_READER_WRITE:"WINDOW_NDEF_READER_WRITE",WINDOW_NDEF_READER_ADD_EVENT_LISTENER:"WINDOW_NDEF_READER_ADD_EVENT_LISTENER",WINDOW_NDEF_READER_MAKE_READONLY:"WINDOW_NDEF_READER_MAKE_READONLY",WINDOW_NDEF_READER_ABORT_SCAN:"WINDOW_NDEF_READER_ABORT_SCAN"},i={COMPONENT_ON_MOUNT:"componentOnMount",CC_ON_PARAMS_CHANGE:"onCustomComponentParamsChange"},a={POPUP_ID:"ACTIVE_POP_UP"};function u(n="lcncsdk"){return`${n}-${E()}`}const P={};function C(n){globalThis.parent&&globalThis.parent!==globalThis?globalThis.parent.postMessage(n,"*"):globalThis.postMessage(n)}function d(n){if(n.origin!==globalThis.location.origin){const e=n.data;if(e!=null&&e.isEvent){const{target:r,eventParams:R,eventName:h,eventConfig:N={}}=e;let T=P[r];T._dispatchEvent(h,R),N.once&&T._removeEventListener(h);return}let{_req:s,resp:_}=e;s!=null&&s._id&&P[s._id]._dispatchMessageEvents(s,_)}}globalThis.addEventListener("message",d);class S{constructor(){p(this,A,void 0);g(this,A,{})}_addEventListener(e,s){var _;o(this,A)[e]=((_=o(this,A))==null?void 0:_[e])||[],o(this,A)[e].push(s)}_removeEventListener(e,s){if(s){let _=o(this,A)[e].findIndex(s);_>-1&&o(this,A)[e].splice(_,1);return}Reflect.deleteProperty(o(this,A),e)}_dispatchEvent(e,s){return Array.isArray(o(this,A)[e])?(o(this,A)[e].forEach(_=>_(s)),!0):!1}_dispatchMessageEvents(e,s){let _=e._id;Array.isArray(o(this,A)[_])&&(o(this,A)[_].forEach(r=>{try{s&&Object.keys(s).length===1&&e.command!==t.API?r(Object.values(s)[0]):r(s)}catch(R){console.error("Message callback error: ",R)}}),this._removeEventListener(_))}}A=new WeakMap;class O extends S{_postMessageAsync(e,s,_,r){return new Promise((R,h)=>{const N=u(e.toLowerCase());C({_id:N,command:e,...s}),P[N]=this,this._addEventListener(N,async T=>{T!=null&&T.errorMessage?h(T):(_&&r&&(T=await r(T)),R(T))})})}_postMessage(e,s,_){const r=u(e.toLowerCase());C({_id:r,command:e,...s}),_&&this._addEventListener(s.eventName,_)}}class D extends O{constructor(s){super();p(this,M);this._id=s.componentId,this.type="Component",P[this._id]=this,l(this,M,L).call(this,s.componentMethods)}onMount(s){this._postMessage(t.COMPONENT_ADD_EVENT_LISTENER,{id:this._id,eventName:i.COMPONENT_ON_MOUNT,eventConfig:{once:!0}},s)}refresh(){return this._postMessageAsync(t.COMPONENT_REFRESH,{id:this._id})}show(){return this._postMessageAsync(t.COMPONENT_SHOW,{id:this._id})}hide(){return this._postMessageAsync(t.COMPONENT_HIDE,{id:this._id})}}M=new WeakSet,L=function(s){s==null||s.forEach(_=>{this[_.name]=(...r)=>{if(_.type==="method")return this._postMessageAsync(`COMPONENT_${_.name}`,{id:this._id,parameters:r});_.type==="event"&&this._postMessage(t.COMPONENT_ADD_EVENT_LISTENER,{id:this._id,eventName:_.name,eventConfig:r[1]},r[0])}})};class G extends O{constructor(e){super(),this._id=e,this.type="CustomComponent",P[this._id]=this}watchParams(e){this._postMessage(t.CC_WATCH_PARAMS,{id:this._id,eventName:i.CC_ON_PARAMS_CHANGE,eventConfig:{once:!1}},e)}}class f extends O{constructor(e){super(),this.type="Popup",this._id=e.popupId||a.POPUP_ID}getParameter(e){return this._postMessageAsync(t.GET_POPUP_PARAMS,{key:e,popupId:this._id})}getAllParameters(){return this._postMessageAsync(t.GET_ALL_POPUP_PARAMS,{popupId:this._id})}close(){return this._postMessageAsync(t.CLOSE_POPUP,{})}getComponent(e){return this._postMessageAsync(t.COMPONENT_GET,{componentId:e},!0,s=>new D(s))}}class I extends O{constructor(e){super(),this.type="Page",this.popup=new f({}),this._id=e.pageId}getParameter(e){return this._postMessageAsync(t.GET_PAGE_PARAMS,{key:e})}getAllParameters(){return this._postMessageAsync(t.GET_ALL_PAGE_PARAMS,{pageId:this._id})}getVariable(e){return this._postMessageAsync(t.GET_PAGE_VARIABLE,{key:e})}setVariable(e,s){return this._postMessageAsync(t.SET_PAGE_VARIABLE,{key:e,value:s})}openPopup(e,s){return this._postMessageAsync(t.OPEN_POPUP,{popupId:e,popupParams:s})}getComponent(e){return this._postMessageAsync(t.COMPONENT_GET,{componentId:e},!0,s=>new D(s))}}class y extends O{constructor(e){super(),this._id=e.appId,this.page=new I(e)}getVariable(e){return this._postMessageAsync(t.GET_APP_VARIABLE,{key:e})}setVariable(e,s){return this._postMessageAsync(t.SET_APP_VARIABLE,{key:e,value:s})}openPage(e,s){return this._postMessageAsync(t.OPEN_PAGE,{pageId:e,pageParams:s})}}class W extends O{showInfo(e){return super._postMessageAsync(t.MESSAGE,{message:e})}showConfirm(e){return super._postMessageAsync(t.CONFIRM,{data:{title:e.title,content:e.content,okText:e.okText||"Ok",cancelText:e.cancelText||"Cancel"}})}redirect(e){return super._postMessageAsync(t.REDIRECT,{url:e})}}class F extends O{toDate(e){return this._postMessageAsync(t.FORMAT_DATE,{date:e})}toDateTime(e){return this._postMessageAsync(t.FORMAT_DATE_TIME,{date:e})}toNumber(e){return this._postMessageAsync(t.FORMAT_NUMBER,{value:e})}toCurrency(e,s){return this._postMessageAsync(t.FORMAT_CURRENCY,{value:e,currencyCode:s})}toBoolean(e){return this._postMessageAsync(t.FORMAT_BOOLEAN,{value:e})}}class m extends O{constructor(){super()}api(e,s={}){return this._postMessageAsync(t.API,{url:e,args:s})}initialize(){return this._postMessageAsync(t.CC_INITIALIZE,{},!0,e=>(this.app=new y(e),this.page=new I(e),this.context=new G(e.componentId),this.client=new W,this.formatter=new F,this.user=e.user,this.account=e.account,this.env=e.envDetails,this))}initialise(){return this.initialize()}}var B=new m;return B});
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
{
|
|
2
|
+
"lowcode": [
|
|
3
|
+
{
|
|
4
|
+
"label": "get app variable",
|
|
5
|
+
"documentation": "Get variable value from global app scope",
|
|
6
|
+
"insertText": "let variableName = await kf.app.getVariable(\"${1:variableId}\")"
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"label": "set app variable",
|
|
10
|
+
"documentation": "Sets variable to new value in global app scope",
|
|
11
|
+
"insertText": "kf.app.setVariable(\"${1:variableId}\", \"${2:newValue}\")"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"label": "open or navigate page",
|
|
15
|
+
"documentation": "Navigate to another page\nRemove 2nd args if you dont have any input parameters to page",
|
|
16
|
+
"insertText": "kf.app.openPage(\"${1:pageId}\", { inputParam1: \"value1\" })"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"label": "get local(page) variable",
|
|
20
|
+
"documentation": "Get variable value from page scope",
|
|
21
|
+
"insertText": "let variableName = await kf.app.page.getVariable(\"${1:variableId}\")"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"label": "set local(page) variable",
|
|
25
|
+
"documentation": "Sets specified variable to new value in page scope",
|
|
26
|
+
"insertText": "kf.app.page.setVariable(\"${1:variableId}\", \"${2:newValue}\")"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"label": "get input parameter",
|
|
30
|
+
"documentation": "Get specific input parameter of the page",
|
|
31
|
+
"insertText": "let value = await kf.app.page.getParameter(\"${1:parameterId}\"); "
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"label": "get all input parameters",
|
|
35
|
+
"documentation": "Get all input parameters in the page",
|
|
36
|
+
"insertText": "let allParams = await kf.app.page.getAllParameters();"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"label": "open a popup",
|
|
40
|
+
"documentation": "Opens a popup in the page",
|
|
41
|
+
"insertText": "// remove 2nd argument if popup doesnt have any popup params\nkf.app.page.openPopup(\"${1:popupId}\", { popupParam1: \"value\" });"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"label": "get component in page",
|
|
45
|
+
"documentation": "Get instance of the components inside the page",
|
|
46
|
+
"insertText": "let componentInstance = await kf.app.page.getComponent(\"${1:componentId}\")"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"label": "refresh the component",
|
|
50
|
+
"documentation": "Refreshes the component",
|
|
51
|
+
"insertText": "componentInstance.refresh()"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"label": "hide the component",
|
|
55
|
+
"documentation": "Hides the component from page",
|
|
56
|
+
"insertText": "componentInstance.hide()"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"label": "show the component",
|
|
60
|
+
"documentation": "Shows the hidden component from page",
|
|
61
|
+
"insertText": "componentInstance.show()"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"label": "set active tab (only for tab component)",
|
|
65
|
+
"documentation": "Sets the specified tab index as active",
|
|
66
|
+
"insertText": "// sets 2nd tab as active\ncomponentInstance.setActiveTab(${1:2})"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"label": "get popup parameter",
|
|
70
|
+
"documentation": "Get specific parameter in the popup",
|
|
71
|
+
"insertText": "let value = await kf.app.page.popup.getParameter(\"${1:parameterId}\"); "
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"label": "get all popup parameters",
|
|
75
|
+
"documentation": "Get all parameters in the popup",
|
|
76
|
+
"insertText": "// returns all popup parameters as object\nlet allParams = await kf.app.page.popup.getAllParameters();"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"label": "close active popup",
|
|
80
|
+
"insertText": "kf.app.page.popup.close()"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"label": "get instance id",
|
|
84
|
+
"documentation": "Get the instance id from event arguments",
|
|
85
|
+
"insertText": "kf.eventParameters._id"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"label": "get activity instance id",
|
|
89
|
+
"documentation": "Get the activity instance id from event arguments",
|
|
90
|
+
"insertText": "kf.eventParameters._activity_instance_id"
|
|
91
|
+
}
|
|
92
|
+
],
|
|
93
|
+
"nocode": [
|
|
94
|
+
{
|
|
95
|
+
"label": "get field value",
|
|
96
|
+
"documentation": "Get value of a field in form",
|
|
97
|
+
"insertText": "let fieldValue = await kf.context.getField(\"${1:fieldId}\");"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"label": "set field value",
|
|
101
|
+
"documentation": "Set value of a field in form",
|
|
102
|
+
"insertText": "kf.context.updateField({\"${1:fieldId}\": \"${2:value}\"});"
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"label": "set field value - bulk",
|
|
106
|
+
"documentation": "Set value of a field in form",
|
|
107
|
+
"insertText": "let payload = { \"fieldId\": \"value\", \"fieldId2\": \"value2\" };\nkf.context.updateField(payload);"
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"label": "get form json",
|
|
111
|
+
"documentation": "Returns whole data of current form in json format",
|
|
112
|
+
"insertText": "let formJSON = await kf.context.getJSON();"
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"label": "get table instance",
|
|
116
|
+
"documentation": "Get instance of table, which can be further used to add or delete rows",
|
|
117
|
+
"insertText": "let tableInstance = kf.context.getTable(\"${1:tableId}\");"
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
"label": "add a row in table",
|
|
121
|
+
"documentation": "Appends a row entry to table",
|
|
122
|
+
"insertText": "let rowDetails = { \"columnId1\": \"value1\", \"columnId2\": \"value2\" };\ntableInstance.addRow(rowDetails)"
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"label": "get table row",
|
|
126
|
+
"documentation": "Returns all columns with values in specified row",
|
|
127
|
+
"insertText": "tableInstance.getRow(\"${1:rowId}\")"
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
"label": "get table json",
|
|
131
|
+
"documentation": "Returns all rows & columns data inside table in json format",
|
|
132
|
+
"insertText": "let tableJSON = await kf.context.getJSON();"
|
|
133
|
+
}
|
|
134
|
+
],
|
|
135
|
+
"common": [
|
|
136
|
+
{
|
|
137
|
+
"label": "showinfo",
|
|
138
|
+
"documentation": "Shows toast information",
|
|
139
|
+
"insertText": "kf.client.showInfo(\"${1:message}\")"
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
"label": "api call",
|
|
143
|
+
"documentation": "Makes an API call to any kissflow rest api end points",
|
|
144
|
+
"insertText": "kf.api(`/${1:url}`)\n.then((resp) => {${2}})\n.catch((err) => {${3}})"
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
"label": "get account id",
|
|
148
|
+
"documentation": "Retrieves the acccount id",
|
|
149
|
+
"insertText": "kf.account._id"
|
|
150
|
+
},
|
|
151
|
+
|
|
152
|
+
{
|
|
153
|
+
"label": "get dataform item",
|
|
154
|
+
"documentation": "Api call to get dataform item",
|
|
155
|
+
"insertText": "kf.api(`/form/2/${kf.account._id}/${1:formId}/${2:instanceId}`)\n.then((resp) => {${3}})\n.catch((err) => {${4}})"
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
"label": "update dataform item",
|
|
159
|
+
"documentation": "Api call to update dataform item",
|
|
160
|
+
"insertText": "let payload = {};\nkf.api(`/form/2/${kf.account._id}/${1:formId}/${2:instanceId}`, {\n\tmethod: \"POST\",\n\tbody: JSON.stringify(payload)\n})\n.then((resp) => {${4}})\n.catch((err) => {${5}})"
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
"label": "delete dataform item",
|
|
164
|
+
"documentation": "Api call to delete dataform item",
|
|
165
|
+
"insertText": "let payload = {};\nkf.api(`/form/2/${kf.account._id}/${1:formId}/${2:instanceId}`, { method: \"DELETE\" })\n.then((resp) => {${3}})\n.catch((err) => {${4}})"
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
"label": "create new dataform item",
|
|
169
|
+
"documentation": "Api call to create new dataform item",
|
|
170
|
+
"insertText": "let payload = {};\nkf.api(`/form/2/${kf.account._id}/${1:formId}/`,{\n\tmethod: \"POST\",\n\tbody: JSON.stringify(payload)\n})\n.then((resp) => {${2}})\n.catch((err) => {${3}})"
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
"label": "create new case item",
|
|
174
|
+
"documentation": "Api call to create new case item",
|
|
175
|
+
"insertText": "let payload = {};\nkf.api(`/case/2/${kf.account._id}/${1:caseId}/`, {\n\tmethod: \"POST\",\n\tbody: JSON.stringify(payload)\n})\n.then((resp) => {${2}})\n.catch((err) => {${3}})"
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
"label": "create new process item",
|
|
179
|
+
"documentation": "Api call to create new process item",
|
|
180
|
+
"insertText": "let payload = {}:\nkf.api(`/process/2/${kf.account._id}/${1:processId}/`, {\n\tmethod: \"POST\",\n\tbody: JSON.stringify(payload)\n})\n.then((resp) => {${2}})\n.catch((err) => {${3}})"
|
|
181
|
+
}
|
|
182
|
+
]
|
|
183
|
+
}
|