@kissflow/lowcode-client-sdk 1.0.20 → 1.0.22
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/README.md +184 -53
- package/dist/index.d.ts +22 -0
- package/dist/kf.lowcodeworkersdk.es.js +33 -1
- package/dist/kf.nocodeworkersdk.es.js +3 -1
- package/dist/kfsdk.es.js +33 -1
- package/dist/kfsdk.umd.js +1 -1
- package/dist/lowcode.d.ts +22 -0
- package/dist/lowcode.types.d.ts +8 -0
- package/dist/nocode.d.ts +22 -0
- package/dist/snippets.json +6 -1
- package/dist/worker.js +40 -0
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
# _Kissflow Lowcode JavaScript SDK_
|
|
2
2
|
|
|
3
3
|
JavaScript SDK for developing over the Kissflow lowcode platform
|
|
4
|
+
|
|
4
5
|
### Use as an `npm` module
|
|
5
6
|
|
|
6
|
-
Install the SDK as a module: `npm i @kissflow/lowcode-client-sdk` Then import
|
|
7
|
+
Install the SDK as a module: `npm i @kissflow/lowcode-client-sdk` Then import
|
|
8
|
+
into your project:
|
|
9
|
+
|
|
7
10
|
```js
|
|
8
11
|
import KFSDK from "@kissflow/lowcode-client-sdk";
|
|
9
12
|
let kf;
|
|
@@ -11,14 +14,19 @@ let kf;
|
|
|
11
14
|
kf = await KFSDK.initialize();
|
|
12
15
|
})();
|
|
13
16
|
```
|
|
17
|
+
|
|
14
18
|
> Note: Initializing Kf SDK in custom components returns a promise.
|
|
19
|
+
|
|
15
20
|
### Use as a `<script>` tag directly in HTML
|
|
16
21
|
|
|
17
22
|
SDK can also be loaded directly into HTML by adding:
|
|
23
|
+
|
|
18
24
|
```html
|
|
19
25
|
<script src="https://unpkg.com/@kissflow/lowcode-client-sdk@latest/dist/kfsdk.umd.js"></script>
|
|
20
26
|
```
|
|
27
|
+
|
|
21
28
|
Then SDK can be initialized as:
|
|
29
|
+
|
|
22
30
|
```js
|
|
23
31
|
let kf;
|
|
24
32
|
window.onload = async function () {
|
|
@@ -27,15 +35,20 @@ window.onload = async function () {
|
|
|
27
35
|
```
|
|
28
36
|
|
|
29
37
|
### User and Account details
|
|
38
|
+
|
|
30
39
|
Details of authenticated user can be accessed as following
|
|
40
|
+
|
|
31
41
|
```js
|
|
32
|
-
const { Name, Email, _id } = kf.user
|
|
42
|
+
const { Name, Email, _id } = kf.user;
|
|
33
43
|
```
|
|
44
|
+
|
|
34
45
|
And account id can be accessed as `kf.account._id`
|
|
35
46
|
|
|
36
47
|
### Fetch Api through sdk
|
|
37
|
-
|
|
38
|
-
|
|
48
|
+
|
|
49
|
+
Fetch any other kissflow api & external api using this method. kf.api has header
|
|
50
|
+
tokens by default for making authenticated kissflow api calls
|
|
51
|
+
|
|
39
52
|
> Note: This method has a limit of 10 seconds for an api call
|
|
40
53
|
|
|
41
54
|
```js
|
|
@@ -45,32 +58,36 @@ let resp = await kf.api(url, config)
|
|
|
45
58
|
```
|
|
46
59
|
|
|
47
60
|
## Table of contents
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
-
|
|
51
|
-
|
|
52
|
-
-
|
|
53
|
-
-
|
|
54
|
-
-
|
|
55
|
-
-
|
|
56
|
-
-
|
|
57
|
-
|
|
58
|
-
-
|
|
59
|
-
|
|
60
|
-
-
|
|
61
|
-
-
|
|
61
|
+
|
|
62
|
+
- [1. Context](#1-context)
|
|
63
|
+
- [Custom Components](#custom-component)
|
|
64
|
+
- [Form](#custom-component)
|
|
65
|
+
- [Form Table](#form-table)
|
|
66
|
+
- [Table Row](#table-row)
|
|
67
|
+
- [2. Client](#2-client)
|
|
68
|
+
- [3. Application](#3-application)
|
|
69
|
+
- [4. Page](#4-page)
|
|
70
|
+
- [5. Component](#5-component)
|
|
71
|
+
- [Standard Component methods](#standard-component-methods)
|
|
72
|
+
- [Component Specific methods](#component-specific-methods)
|
|
73
|
+
- [Tab](#521-tab-component)
|
|
74
|
+
- [6. Popup](#6-popup)
|
|
75
|
+
- [7. Formatter](#7-formatter)
|
|
62
76
|
|
|
63
77
|
## 1) Context
|
|
64
78
|
|
|
65
|
-
Context methods are polymorphic, it has different classes pre-initialized based
|
|
79
|
+
Context methods are polymorphic, it has different classes pre-initialized based
|
|
80
|
+
on execution context.
|
|
66
81
|
|
|
67
82
|
### Custom component
|
|
68
83
|
|
|
69
|
-
`kf.context` returns a `CustomComponent` class while using inside custom
|
|
84
|
+
`kf.context` returns a `CustomComponent` class while using inside custom
|
|
85
|
+
component. Custom component supported methods:
|
|
70
86
|
|
|
71
87
|
##### a) Watch Params
|
|
72
88
|
|
|
73
|
-
Listens for changes in parameter given to custom components in lowcode
|
|
89
|
+
Listens for changes in parameter given to custom components in lowcode
|
|
90
|
+
application.
|
|
74
91
|
|
|
75
92
|
```js
|
|
76
93
|
kf.context.watchParams(function (data) {
|
|
@@ -80,14 +97,18 @@ kf.context.watchParams(function (data) {
|
|
|
80
97
|
|
|
81
98
|
### Kissflow Forms
|
|
82
99
|
|
|
83
|
-
`kf.context` returns a `Form` class when it is used inside a kissflow's form
|
|
100
|
+
`kf.context` returns a `Form` class when it is used inside a kissflow's form
|
|
101
|
+
that could be either Process, case or Dataform & it has following supported
|
|
102
|
+
methods
|
|
84
103
|
|
|
85
104
|
##### a) getField()
|
|
86
105
|
|
|
87
106
|
###### Description:
|
|
107
|
+
|
|
88
108
|
Use this function to get the current value of a form field
|
|
89
109
|
|
|
90
110
|
###### Syntax:
|
|
111
|
+
|
|
91
112
|
```js
|
|
92
113
|
kf.context.getField(fieldId).then((res) => {...})
|
|
93
114
|
// or
|
|
@@ -97,9 +118,11 @@ let value = await kf.context.getField(fieldId)
|
|
|
97
118
|
##### b) updateField()
|
|
98
119
|
|
|
99
120
|
###### Description:
|
|
121
|
+
|
|
100
122
|
Use this function to get update any field in the form
|
|
101
123
|
|
|
102
124
|
###### Syntax:
|
|
125
|
+
|
|
103
126
|
```js
|
|
104
127
|
kf.context.updateField({ fieldId_1: fieldValue, fieldId_2: fieldValue });
|
|
105
128
|
```
|
|
@@ -107,14 +130,17 @@ kf.context.updateField({ fieldId_1: fieldValue, fieldId_2: fieldValue });
|
|
|
107
130
|
##### c) toJSON()
|
|
108
131
|
|
|
109
132
|
###### Description:
|
|
133
|
+
|
|
110
134
|
Use this function to get the JSON data of the current form
|
|
111
135
|
|
|
112
136
|
###### Syntax:
|
|
137
|
+
|
|
113
138
|
```js
|
|
114
139
|
const json = await kf.context.toJSON();
|
|
115
140
|
```
|
|
116
141
|
|
|
117
142
|
###### Output:
|
|
143
|
+
|
|
118
144
|
```
|
|
119
145
|
{
|
|
120
146
|
"Untitled_Field": "testing",
|
|
@@ -127,34 +153,40 @@ const json = await kf.context.toJSON();
|
|
|
127
153
|
|
|
128
154
|
### Form Table
|
|
129
155
|
|
|
130
|
-
`kf.context.getTable(tableId)` returns a `Table` class which has the following
|
|
156
|
+
`kf.context.getTable(tableId)` returns a `Table` class which has the following
|
|
157
|
+
methods
|
|
131
158
|
|
|
132
159
|
#### a) addRow()
|
|
133
160
|
|
|
134
161
|
###### Description:
|
|
162
|
+
|
|
135
163
|
Appends row details to the table.
|
|
136
164
|
|
|
137
165
|
###### Syntax:
|
|
166
|
+
|
|
138
167
|
```js
|
|
139
168
|
const table = kf.context.getTable(tableId);
|
|
140
169
|
table.addRow({ columnId1: value, columnId2: value });
|
|
141
170
|
```
|
|
171
|
+
|
|
142
172
|
> ##### Note: If there are more than one rows to be added to table then use `addRows()` instead for these bulk operations
|
|
143
173
|
|
|
144
174
|
#### b) addRows()
|
|
145
175
|
|
|
146
176
|
###### Description:
|
|
177
|
+
|
|
147
178
|
Appends multiple rows details to the table.
|
|
148
179
|
|
|
149
180
|
###### Syntax:
|
|
181
|
+
|
|
150
182
|
```js
|
|
151
183
|
const table = kf.context.getTable(tableId);
|
|
152
184
|
let accumulator = [];
|
|
153
|
-
someArrayOfObjects.forEach(function(rowDetail) {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
185
|
+
someArrayOfObjects.forEach(function (rowDetail) {
|
|
186
|
+
accumulator.push({
|
|
187
|
+
columnId1: rowDetail[columnId1],
|
|
188
|
+
columnId2: rowDetail[columnId2]
|
|
189
|
+
});
|
|
158
190
|
});
|
|
159
191
|
await table.addRows(accumulator);
|
|
160
192
|
```
|
|
@@ -162,21 +194,26 @@ await table.addRows(accumulator);
|
|
|
162
194
|
#### c) deleteRow()
|
|
163
195
|
|
|
164
196
|
###### Description:
|
|
197
|
+
|
|
165
198
|
Deletes a row from the table based on the row id
|
|
166
199
|
|
|
167
200
|
###### Syntax:
|
|
201
|
+
|
|
168
202
|
```js
|
|
169
203
|
const table = kf.context.getTable(tableId);
|
|
170
204
|
await table.deleteRow(rowId);
|
|
171
205
|
```
|
|
206
|
+
|
|
172
207
|
> ##### Note: If there are more than one rows to be deleted then use `deleteRows()` instead.
|
|
173
208
|
|
|
174
209
|
#### d) deleteRows()
|
|
175
210
|
|
|
176
211
|
###### Description:
|
|
212
|
+
|
|
177
213
|
Deletes multiple rows from the table based on given array of strings.
|
|
178
214
|
|
|
179
215
|
###### Syntax:
|
|
216
|
+
|
|
180
217
|
```js
|
|
181
218
|
const table = kf.context.getTable(tableId);
|
|
182
219
|
await table.deleteRows([rowId1, rowId2, rowId3]);
|
|
@@ -185,41 +222,50 @@ await table.deleteRows([rowId1, rowId2, rowId3]);
|
|
|
185
222
|
#### e) getRow()
|
|
186
223
|
|
|
187
224
|
###### Description:
|
|
225
|
+
|
|
188
226
|
Use this function to perform form actions on any row inside a child table
|
|
189
227
|
|
|
190
228
|
###### Syntax:
|
|
229
|
+
|
|
191
230
|
```js
|
|
192
231
|
const table = kf.context.getTable(tableId);
|
|
193
232
|
const row = table.getRow(rowId);
|
|
194
233
|
```
|
|
195
234
|
|
|
196
235
|
###### Output:
|
|
236
|
+
|
|
197
237
|
Returns an instance of `TableForm` class
|
|
198
238
|
|
|
199
239
|
#### f) getRows()
|
|
200
240
|
|
|
201
241
|
###### Description:
|
|
242
|
+
|
|
202
243
|
Gets all the rows of the table
|
|
203
244
|
|
|
204
245
|
###### Syntax:
|
|
246
|
+
|
|
205
247
|
```js
|
|
206
248
|
const rows = await kf.context.getTable(tableId).getRows();
|
|
207
249
|
```
|
|
208
250
|
|
|
209
251
|
###### Output:
|
|
252
|
+
|
|
210
253
|
Returns an array of `TableForm` instances
|
|
211
254
|
|
|
212
255
|
##### g) toJSON()
|
|
213
256
|
|
|
214
257
|
###### Description:
|
|
258
|
+
|
|
215
259
|
Use this function to get the JSON data of the child table
|
|
216
260
|
|
|
217
261
|
###### Syntax:
|
|
262
|
+
|
|
218
263
|
```js
|
|
219
264
|
const json = await kf.context.getTable(tableId).toJSON();
|
|
220
265
|
```
|
|
221
266
|
|
|
222
267
|
###### Output:
|
|
268
|
+
|
|
223
269
|
```
|
|
224
270
|
[{
|
|
225
271
|
"Untitled_Field": "row 1",
|
|
@@ -238,15 +284,17 @@ const json = await kf.context.getTable(tableId).toJSON();
|
|
|
238
284
|
|
|
239
285
|
### Table Row
|
|
240
286
|
|
|
241
|
-
A single row inside a table is known as Table row
|
|
242
|
-
`
|
|
287
|
+
A single row inside a table is known as Table row `kf.context` returns a
|
|
288
|
+
`TableForm` class which has the following methods
|
|
243
289
|
|
|
244
290
|
##### a) getField()
|
|
245
291
|
|
|
246
292
|
###### Description:
|
|
293
|
+
|
|
247
294
|
Use this function to get the value of the table row
|
|
248
295
|
|
|
249
296
|
###### Syntax:
|
|
297
|
+
|
|
250
298
|
```js
|
|
251
299
|
kf.context.getField(fieldId).then((res) => {...})
|
|
252
300
|
// or
|
|
@@ -256,9 +304,11 @@ let value = await kf.context.getField(fieldId)
|
|
|
256
304
|
##### b) updateField()
|
|
257
305
|
|
|
258
306
|
###### Description:
|
|
307
|
+
|
|
259
308
|
Use this function to get update any field in the table row
|
|
260
309
|
|
|
261
310
|
###### Syntax:
|
|
311
|
+
|
|
262
312
|
```js
|
|
263
313
|
kf.context.updateField({ fieldId_1: fieldValue, fieldId_2: fieldValue });
|
|
264
314
|
```
|
|
@@ -266,29 +316,35 @@ kf.context.updateField({ fieldId_1: fieldValue, fieldId_2: fieldValue });
|
|
|
266
316
|
##### c) getParent()
|
|
267
317
|
|
|
268
318
|
###### Description:
|
|
319
|
+
|
|
269
320
|
Use this function to perform form actions on the main form
|
|
270
321
|
|
|
271
322
|
###### Syntax:
|
|
323
|
+
|
|
272
324
|
```js
|
|
273
325
|
const mainForm = kf.context.getParent();
|
|
274
326
|
mainForm.updateField({ fieldId_1: fieldValue, fieldId_2: fieldValue });
|
|
275
327
|
```
|
|
276
328
|
|
|
277
329
|
###### Output:
|
|
330
|
+
|
|
278
331
|
Returns an instance of `Form` class using which we can perform any action on the
|
|
279
332
|
main form
|
|
280
333
|
|
|
281
334
|
##### d) toJson()
|
|
282
335
|
|
|
283
336
|
##### Description:
|
|
337
|
+
|
|
284
338
|
Get JSON output of table row
|
|
285
339
|
|
|
286
340
|
##### Syntax:
|
|
341
|
+
|
|
287
342
|
```js
|
|
288
343
|
const json = await kf.context.toJSON();
|
|
289
344
|
```
|
|
290
345
|
|
|
291
346
|
###### Output:
|
|
347
|
+
|
|
292
348
|
```
|
|
293
349
|
{
|
|
294
350
|
"Untitled_Field": "testing",
|
|
@@ -304,12 +360,15 @@ const json = await kf.context.toJSON();
|
|
|
304
360
|
### 2) Client
|
|
305
361
|
|
|
306
362
|
##### Show Toast
|
|
363
|
+
|
|
307
364
|
```js
|
|
308
365
|
kf.client.showInfo(message);
|
|
309
366
|
```
|
|
310
367
|
|
|
311
368
|
##### Show confirm
|
|
369
|
+
|
|
312
370
|
Displays the confirmation dialog, and returns users's action as a response
|
|
371
|
+
|
|
313
372
|
```js
|
|
314
373
|
kf.client.showConfirm({ title, content }).then((action) => {
|
|
315
374
|
if(action === "OK") // user clicked ok button
|
|
@@ -319,6 +378,7 @@ kf.client.showConfirm({ title, content }).then((action) => {
|
|
|
319
378
|
```
|
|
320
379
|
|
|
321
380
|
##### Redirect to URL
|
|
381
|
+
|
|
322
382
|
```js
|
|
323
383
|
kf.client.redirect(url);
|
|
324
384
|
```
|
|
@@ -328,11 +388,13 @@ kf.client.redirect(url);
|
|
|
328
388
|
`kf.app` represents the active kissflow app and `kf.app._id` returns its id.
|
|
329
389
|
|
|
330
390
|
##### Get value to application variable
|
|
391
|
+
|
|
331
392
|
```js
|
|
332
393
|
const appVarible1 = await kf.app.getVariable("variableId");
|
|
333
394
|
```
|
|
334
395
|
|
|
335
396
|
##### Set value of application variable
|
|
397
|
+
|
|
336
398
|
```js
|
|
337
399
|
let value = await kf.app.setVariable("variableId", value);
|
|
338
400
|
// or
|
|
@@ -343,7 +405,9 @@ await kf.app.setVariable({
|
|
|
343
405
|
```
|
|
344
406
|
|
|
345
407
|
##### Open a page
|
|
408
|
+
|
|
346
409
|
`openPage(id)` returns [Page](#4-page) class instance
|
|
410
|
+
|
|
347
411
|
```js
|
|
348
412
|
const pageInputParameters = {
|
|
349
413
|
param1: value,
|
|
@@ -353,96 +417,163 @@ kf.app.openPage(pageId, pageInputParameters);
|
|
|
353
417
|
// Note: Page Input parameters are optional.
|
|
354
418
|
```
|
|
355
419
|
|
|
420
|
+
##### Get a dataform instance
|
|
421
|
+
|
|
422
|
+
`getDataform(formId)` returns a Dataform class instance
|
|
423
|
+
|
|
424
|
+
```js
|
|
425
|
+
const dfInstance = kf.app.getDataform("dataform_id");
|
|
426
|
+
```
|
|
427
|
+
|
|
356
428
|
### 4) Page
|
|
357
|
-
|
|
429
|
+
|
|
430
|
+
`kf.app.page` returns the active page opened inside application and
|
|
431
|
+
`kf.app.page._id` returns its id.
|
|
358
432
|
|
|
359
433
|
##### Page parameters
|
|
434
|
+
|
|
360
435
|
```js
|
|
361
436
|
let value = await kf.app.page.getParameter("parameterId"); // for retreiving single parameter
|
|
362
437
|
```
|
|
438
|
+
|
|
363
439
|
Get all page parameters
|
|
364
|
-
|
|
365
|
-
|
|
440
|
+
|
|
441
|
+
```js
|
|
442
|
+
let allParams = await kf.app.page.getAllParameters();
|
|
366
443
|
// returns an object
|
|
367
|
-
{
|
|
444
|
+
{
|
|
368
445
|
parameterName: "Sample value",
|
|
369
446
|
parameterName2: "Sample value 2"
|
|
370
447
|
}
|
|
371
448
|
```
|
|
372
449
|
|
|
373
450
|
##### Access a Component
|
|
451
|
+
|
|
374
452
|
`getComponent` returns a [Component](#5-component) class.
|
|
453
|
+
|
|
375
454
|
```js
|
|
376
455
|
const componentName = await kf.app.page.getComponent("componentId");
|
|
377
456
|
```
|
|
378
457
|
|
|
379
458
|
##### Open a popup
|
|
459
|
+
|
|
380
460
|
`openPoup` returns a [Popup](#6-popup) class.
|
|
461
|
+
|
|
381
462
|
```js
|
|
382
463
|
kf.app.page.openPopup("popupId", { inputParam1: "value" });
|
|
383
464
|
// Note: Popup parameters are optional.
|
|
384
465
|
```
|
|
385
466
|
|
|
386
467
|
### 5) Component
|
|
468
|
+
|
|
387
469
|
#### getComponent(id)
|
|
388
|
-
|
|
389
|
-
Returns: Component class instance
|
|
470
|
+
|
|
471
|
+
Parameter: Component's Id Returns: Component class instance
|
|
472
|
+
|
|
390
473
|
```js
|
|
391
474
|
const component = await kf.app.page.getComponent(componentId);
|
|
392
475
|
```
|
|
476
|
+
|
|
393
477
|
##### Standard Component Methods
|
|
478
|
+
|
|
394
479
|
```js
|
|
395
480
|
component.refresh(); // Refreshes the component
|
|
396
481
|
component.hide(); // Hides the component
|
|
397
482
|
component.show(); // Shows the component if it's been hidden previously
|
|
398
483
|
```
|
|
399
|
-
##### Component Specific Methods
|
|
400
484
|
|
|
485
|
+
##### Component Specific Methods
|
|
401
486
|
|
|
402
487
|
##### 5.2.0) Component onMount
|
|
488
|
+
|
|
403
489
|
Component onMount takes in callBack function as argument.
|
|
490
|
+
|
|
404
491
|
> ##### Note: Any component specific methods that are used on Page load must be called inside component's onMount event.
|
|
405
|
-
|
|
492
|
+
>
|
|
493
|
+
> Parameter: function
|
|
494
|
+
|
|
406
495
|
```js
|
|
407
496
|
component.onMount(() => {
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
})
|
|
497
|
+
// function logic goes here... For eg.
|
|
498
|
+
// component.setActiveTab(2)
|
|
499
|
+
});
|
|
411
500
|
```
|
|
501
|
+
|
|
412
502
|
##### 5.2.1) Tab component
|
|
503
|
+
|
|
413
504
|
##### 1) setActiveTab
|
|
414
|
-
|
|
415
|
-
Parameter: Tabs' Number (Starts from 1 to N)
|
|
505
|
+
|
|
506
|
+
Sets specified tab as active. Parameter: Tabs' Number (Starts from 1 to N)
|
|
507
|
+
|
|
416
508
|
```js
|
|
417
|
-
component.setActiveTab(2) // sets 2nd tab as active one
|
|
509
|
+
component.setActiveTab(2); // sets 2nd tab as active one
|
|
418
510
|
```
|
|
419
511
|
|
|
420
|
-
|
|
421
512
|
### 6) Popup
|
|
422
|
-
|
|
423
|
-
|
|
513
|
+
|
|
514
|
+
`kf.app.page.popup` returns the active popup instance opened inside the page and
|
|
515
|
+
its id can be accessed via `kf.app.page.popup._id` And
|
|
516
|
+
`kf.app.page.getPopup(id)` returns this popup class instance.
|
|
424
517
|
|
|
425
518
|
##### Popup parameters
|
|
519
|
+
|
|
426
520
|
```js
|
|
427
521
|
let value = await kf.app.page.popup.getParameter("parameterId"); // for retreiving single popup parameter
|
|
428
522
|
```
|
|
523
|
+
|
|
429
524
|
Get all popup parameters
|
|
430
|
-
|
|
431
|
-
|
|
525
|
+
|
|
526
|
+
```js
|
|
527
|
+
let allParams = await kf.app.page.popup.getAllParameters();
|
|
432
528
|
// Returns an object
|
|
433
|
-
{
|
|
529
|
+
{
|
|
434
530
|
parameterName: "Sample value",
|
|
435
531
|
parameterName2: "Sample value 2"
|
|
436
532
|
}
|
|
437
533
|
```
|
|
438
534
|
|
|
439
535
|
##### Close popup
|
|
536
|
+
|
|
440
537
|
```js
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
538
|
+
kf.app.page.popup.close(); // for active popup
|
|
539
|
+
// or if you already have a popup instance...
|
|
540
|
+
greetPopup.close();
|
|
444
541
|
```
|
|
445
542
|
|
|
543
|
+
### 8) Dataform
|
|
544
|
+
|
|
545
|
+
> Note: Get dataform instance from `kf.app.getDatform`
|
|
546
|
+
|
|
547
|
+
##### Import CSV
|
|
548
|
+
|
|
549
|
+
Opens up the import CSV modal where user could upload CSV file and map
|
|
550
|
+
respective columns to the field.
|
|
551
|
+
|
|
552
|
+
```js
|
|
553
|
+
let defaultValues = { fieldId: "value" };
|
|
554
|
+
dataformInstance.importCSV(defaultValues);
|
|
555
|
+
```
|
|
556
|
+
|
|
557
|
+
###### Example scenario
|
|
558
|
+
|
|
559
|
+
Consider scenario where few fields that aren't exposed to user(basically hidden
|
|
560
|
+
in form visibilty). In such cases Default values can be used to provide data to
|
|
561
|
+
hidden fields
|
|
562
|
+
|
|
563
|
+
```js
|
|
564
|
+
// Here the location field is hidden to user,
|
|
565
|
+
// thus user isn't aware to include this on import csv.
|
|
566
|
+
let defaultValues = { location: "India" };
|
|
567
|
+
dataformInstance.importCSV(defaultValues);
|
|
568
|
+
```
|
|
569
|
+
|
|
570
|
+
> Note:
|
|
571
|
+
> 1. Default values here is optional
|
|
572
|
+
> 2. Any variables or parameter can also be mapped in `defaultValues`.
|
|
573
|
+
> 3. End user can't pass this value if default value is set by dev.
|
|
574
|
+
> 4. Some fields cannot be set as default eg. Auto calculated fields, Sequence numbers etc.
|
|
575
|
+
|
|
576
|
+
|
|
446
577
|
### 7) Formatter
|
|
447
578
|
|
|
448
579
|
##### Format to KF Date
|
package/dist/index.d.ts
CHANGED
|
@@ -46,6 +46,8 @@ declare module "core/constants" {
|
|
|
46
46
|
WINDOW_NDEF_READER_ADD_EVENT_LISTENER: string;
|
|
47
47
|
WINDOW_NDEF_READER_MAKE_READONLY: string;
|
|
48
48
|
WINDOW_NDEF_READER_ABORT_SCAN: string;
|
|
49
|
+
DECISION_TABLE_EXECUTE: string;
|
|
50
|
+
DATAFORM_IMPORT_CSV: string;
|
|
49
51
|
};
|
|
50
52
|
export const EVENT_TYPES: {
|
|
51
53
|
COMPONENT_ON_MOUNT: string;
|
|
@@ -174,10 +176,28 @@ declare module "app/page" {
|
|
|
174
176
|
getComponent(componentId: string): Component;
|
|
175
177
|
}
|
|
176
178
|
}
|
|
179
|
+
declare module "app/decisiontable" {
|
|
180
|
+
import { BaseSDK } from "core/index";
|
|
181
|
+
export class DecisionTable extends BaseSDK {
|
|
182
|
+
private flowId;
|
|
183
|
+
constructor(flowId: string);
|
|
184
|
+
evaluate(payload?: object): any;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
declare module "app/dataform" {
|
|
188
|
+
import { BaseSDK } from "core/index";
|
|
189
|
+
export class Dataform extends BaseSDK {
|
|
190
|
+
private _id;
|
|
191
|
+
constructor(flowId: string);
|
|
192
|
+
importCSV(defaultValues: object): any;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
177
195
|
declare module "app/index" {
|
|
178
196
|
import { BaseSDK } from "core/index";
|
|
179
197
|
import { Page } from "app/page";
|
|
180
198
|
import { AppContext } from "types/internal";
|
|
199
|
+
import { DecisionTable } from "app/decisiontable";
|
|
200
|
+
import { Dataform } from "app/dataform";
|
|
181
201
|
export class Application extends BaseSDK {
|
|
182
202
|
page: Page;
|
|
183
203
|
_id: string;
|
|
@@ -185,6 +205,8 @@ declare module "app/index" {
|
|
|
185
205
|
getVariable(key: string): any;
|
|
186
206
|
setVariable(key: string | object, value?: any): any;
|
|
187
207
|
openPage(pageId: string, pageParams: object): any;
|
|
208
|
+
getDecisionTable(flowId: string): DecisionTable;
|
|
209
|
+
getDataform(flowId: string): Dataform;
|
|
188
210
|
}
|
|
189
211
|
export * from "app/component";
|
|
190
212
|
export { Page };
|
|
@@ -80,7 +80,9 @@ const LISTENER_CMDS = {
|
|
|
80
80
|
WINDOW_NDEF_READER_WRITE: "WINDOW_NDEF_READER_WRITE",
|
|
81
81
|
WINDOW_NDEF_READER_ADD_EVENT_LISTENER: "WINDOW_NDEF_READER_ADD_EVENT_LISTENER",
|
|
82
82
|
WINDOW_NDEF_READER_MAKE_READONLY: "WINDOW_NDEF_READER_MAKE_READONLY",
|
|
83
|
-
WINDOW_NDEF_READER_ABORT_SCAN: "WINDOW_NDEF_READER_ABORT_SCAN"
|
|
83
|
+
WINDOW_NDEF_READER_ABORT_SCAN: "WINDOW_NDEF_READER_ABORT_SCAN",
|
|
84
|
+
DECISION_TABLE_EXECUTE: "DECISION_TABLE_EXECUTE",
|
|
85
|
+
DATAFORM_IMPORT_CSV: "DATAFORM_IMPORT_CSV"
|
|
84
86
|
};
|
|
85
87
|
const EVENT_TYPES = {
|
|
86
88
|
COMPONENT_ON_MOUNT: "componentOnMount",
|
|
@@ -484,6 +486,30 @@ class Page extends BaseSDK {
|
|
|
484
486
|
);
|
|
485
487
|
}
|
|
486
488
|
}
|
|
489
|
+
class DecisionTable extends BaseSDK {
|
|
490
|
+
constructor(flowId) {
|
|
491
|
+
super();
|
|
492
|
+
this.flowId = flowId;
|
|
493
|
+
}
|
|
494
|
+
evaluate(payload) {
|
|
495
|
+
return this._postMessageAsync(LISTENER_CMDS.DECISION_TABLE_EXECUTE, {
|
|
496
|
+
flowId: this.flowId,
|
|
497
|
+
payload
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
class Dataform extends BaseSDK {
|
|
502
|
+
constructor(flowId) {
|
|
503
|
+
super();
|
|
504
|
+
this._id = flowId;
|
|
505
|
+
}
|
|
506
|
+
importCSV(defaultValues) {
|
|
507
|
+
return this._postMessageAsync(LISTENER_CMDS.DATAFORM_IMPORT_CSV, {
|
|
508
|
+
flowId: this._id,
|
|
509
|
+
defaultValues
|
|
510
|
+
});
|
|
511
|
+
}
|
|
512
|
+
}
|
|
487
513
|
class Application extends BaseSDK {
|
|
488
514
|
constructor(props) {
|
|
489
515
|
super();
|
|
@@ -507,6 +533,12 @@ class Application extends BaseSDK {
|
|
|
507
533
|
pageParams
|
|
508
534
|
});
|
|
509
535
|
}
|
|
536
|
+
getDecisionTable(flowId) {
|
|
537
|
+
return new DecisionTable(flowId);
|
|
538
|
+
}
|
|
539
|
+
getDataform(flowId) {
|
|
540
|
+
return new Dataform(flowId);
|
|
541
|
+
}
|
|
510
542
|
}
|
|
511
543
|
class NDEFReader extends BaseSDK {
|
|
512
544
|
constructor() {
|
|
@@ -76,7 +76,9 @@ const LISTENER_CMDS = {
|
|
|
76
76
|
WINDOW_NDEF_READER_WRITE: "WINDOW_NDEF_READER_WRITE",
|
|
77
77
|
WINDOW_NDEF_READER_ADD_EVENT_LISTENER: "WINDOW_NDEF_READER_ADD_EVENT_LISTENER",
|
|
78
78
|
WINDOW_NDEF_READER_MAKE_READONLY: "WINDOW_NDEF_READER_MAKE_READONLY",
|
|
79
|
-
WINDOW_NDEF_READER_ABORT_SCAN: "WINDOW_NDEF_READER_ABORT_SCAN"
|
|
79
|
+
WINDOW_NDEF_READER_ABORT_SCAN: "WINDOW_NDEF_READER_ABORT_SCAN",
|
|
80
|
+
DECISION_TABLE_EXECUTE: "DECISION_TABLE_EXECUTE",
|
|
81
|
+
DATAFORM_IMPORT_CSV: "DATAFORM_IMPORT_CSV"
|
|
80
82
|
};
|
|
81
83
|
function generateId(prefix = "lcncsdk") {
|
|
82
84
|
return `${prefix}-${nanoid()}`;
|
package/dist/kfsdk.es.js
CHANGED
|
@@ -80,7 +80,9 @@ const LISTENER_CMDS = {
|
|
|
80
80
|
WINDOW_NDEF_READER_WRITE: "WINDOW_NDEF_READER_WRITE",
|
|
81
81
|
WINDOW_NDEF_READER_ADD_EVENT_LISTENER: "WINDOW_NDEF_READER_ADD_EVENT_LISTENER",
|
|
82
82
|
WINDOW_NDEF_READER_MAKE_READONLY: "WINDOW_NDEF_READER_MAKE_READONLY",
|
|
83
|
-
WINDOW_NDEF_READER_ABORT_SCAN: "WINDOW_NDEF_READER_ABORT_SCAN"
|
|
83
|
+
WINDOW_NDEF_READER_ABORT_SCAN: "WINDOW_NDEF_READER_ABORT_SCAN",
|
|
84
|
+
DECISION_TABLE_EXECUTE: "DECISION_TABLE_EXECUTE",
|
|
85
|
+
DATAFORM_IMPORT_CSV: "DATAFORM_IMPORT_CSV"
|
|
84
86
|
};
|
|
85
87
|
const EVENT_TYPES = {
|
|
86
88
|
COMPONENT_ON_MOUNT: "componentOnMount",
|
|
@@ -348,6 +350,30 @@ class Page extends BaseSDK {
|
|
|
348
350
|
);
|
|
349
351
|
}
|
|
350
352
|
}
|
|
353
|
+
class DecisionTable extends BaseSDK {
|
|
354
|
+
constructor(flowId) {
|
|
355
|
+
super();
|
|
356
|
+
this.flowId = flowId;
|
|
357
|
+
}
|
|
358
|
+
evaluate(payload) {
|
|
359
|
+
return this._postMessageAsync(LISTENER_CMDS.DECISION_TABLE_EXECUTE, {
|
|
360
|
+
flowId: this.flowId,
|
|
361
|
+
payload
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
class Dataform extends BaseSDK {
|
|
366
|
+
constructor(flowId) {
|
|
367
|
+
super();
|
|
368
|
+
this._id = flowId;
|
|
369
|
+
}
|
|
370
|
+
importCSV(defaultValues) {
|
|
371
|
+
return this._postMessageAsync(LISTENER_CMDS.DATAFORM_IMPORT_CSV, {
|
|
372
|
+
flowId: this._id,
|
|
373
|
+
defaultValues
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
}
|
|
351
377
|
class Application extends BaseSDK {
|
|
352
378
|
constructor(props) {
|
|
353
379
|
super();
|
|
@@ -371,6 +397,12 @@ class Application extends BaseSDK {
|
|
|
371
397
|
pageParams
|
|
372
398
|
});
|
|
373
399
|
}
|
|
400
|
+
getDecisionTable(flowId) {
|
|
401
|
+
return new DecisionTable(flowId);
|
|
402
|
+
}
|
|
403
|
+
getDataform(flowId) {
|
|
404
|
+
return new Dataform(flowId);
|
|
405
|
+
}
|
|
374
406
|
}
|
|
375
407
|
class Client extends BaseSDK {
|
|
376
408
|
showInfo(message) {
|
package/dist/kfsdk.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var h=(E,t,A)=>{if(!t.has(E))throw TypeError("Cannot "+A)};var o=(E,t,A)=>(h(E,t,"read from private field"),A?A.call(E):t.get(E)),p=(E,t,A)=>{if(t.has(E))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(E):t.set(E,A)},l=(E,t,A,N)=>(h(E,t,"write to private field"),N?N.call(E,A):t.set(E,A),A);var g=(E,t,A)=>(h(E,t,"access private method"),A);(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 i,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",ADD_TABLE_ROWS:"ADD_TABLE_ROWS",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",DECISION_TABLE_EXECUTE:"DECISION_TABLE_EXECUTE",DATAFORM_IMPORT_CSV:"DATAFORM_IMPORT_CSV"},A={COMPONENT_ON_MOUNT:"componentOnMount",CC_ON_PARAMS_CHANGE:"onCustomComponentParamsChange"},N={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:a,eventName:c,eventConfig:R={}}=e;let O=P[r];O._dispatchEvent(c,a),R.once&&O._removeEventListener(c);return}let{_req:s,resp:_}=e;s!=null&&s._id&&P[s._id]._dispatchMessageEvents(s,_)}}globalThis.addEventListener("message",d);class S{constructor(){p(this,i,void 0);l(this,i,{})}_addEventListener(e,s){var _;o(this,i)[e]=((_=o(this,i))==null?void 0:_[e])||[],o(this,i)[e].push(s)}_removeEventListener(e,s){if(s){let _=o(this,i)[e].findIndex(s);_>-1&&o(this,i)[e].splice(_,1);return}Reflect.deleteProperty(o(this,i),e)}_dispatchEvent(e,s){return Array.isArray(o(this,i)[e])?(o(this,i)[e].forEach(_=>_(s)),!0):!1}_dispatchMessageEvents(e,s){let _=e._id;Array.isArray(o(this,i)[_])&&(o(this,i)[_].forEach(r=>{try{s&&Object.keys(s).length===1&&e.command!==t.API?r(Object.values(s)[0]):r(s)}catch(a){console.error("Message callback error: ",a)}}),this._removeEventListener(_))}}i=new WeakMap;class T extends S{_postMessageAsync(e,s,_,r){return new Promise((a,c)=>{const R=u(e.toLowerCase());C({_id:R,command:e,...s}),P[R]=this,this._addEventListener(R,async O=>{O!=null&&O.errorMessage?c(O):(_&&r&&(O=await r(O)),a(O))})})}_postMessage(e,s,_){const r=u(e.toLowerCase());C({_id:r,command:e,...s}),_&&this._addEventListener(s.eventName,_)}}class D extends T{constructor(s){super();p(this,M);this._id=s.componentId,this.type="Component",P[this._id]=this,g(this,M,L).call(this,s.componentMethods)}onMount(s){this._postMessage(t.COMPONENT_ADD_EVENT_LISTENER,{id:this._id,eventName:A.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 T{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:A.CC_ON_PARAMS_CHANGE,eventConfig:{once:!1}},e)}}class f extends T{constructor(e){super(),this.type="Popup",this._id=e.popupId||N.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 T{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 T{constructor(e){super(),this.flowId=e}evaluate(e){return this._postMessageAsync(t.DECISION_TABLE_EXECUTE,{flowId:this.flowId,payload:e})}}class F extends T{constructor(e){super(),this._id=e}importCSV(e){return this._postMessageAsync(t.DATAFORM_IMPORT_CSV,{flowId:this._id,defaultValues:e})}}class W extends T{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})}getDecisionTable(e){return new y(e)}getDataform(e){return new F(e)}}class m extends T{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 B extends T{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 U extends T{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 W(e),this.page=new I(e),this.context=new G(e.componentId),this.client=new m,this.formatter=new B,this.user=e.user,this.account=e.account,this.env=e.envDetails,this))}initialise(){return this.initialize()}}var V=new U;return V});
|
package/dist/lowcode.d.ts
CHANGED
|
@@ -46,6 +46,8 @@ declare module "core/constants" {
|
|
|
46
46
|
WINDOW_NDEF_READER_ADD_EVENT_LISTENER: string;
|
|
47
47
|
WINDOW_NDEF_READER_MAKE_READONLY: string;
|
|
48
48
|
WINDOW_NDEF_READER_ABORT_SCAN: string;
|
|
49
|
+
DECISION_TABLE_EXECUTE: string;
|
|
50
|
+
DATAFORM_IMPORT_CSV: string;
|
|
49
51
|
};
|
|
50
52
|
export const EVENT_TYPES: {
|
|
51
53
|
COMPONENT_ON_MOUNT: string;
|
|
@@ -236,10 +238,28 @@ declare module "app/page" {
|
|
|
236
238
|
getComponent(componentId: string): Component;
|
|
237
239
|
}
|
|
238
240
|
}
|
|
241
|
+
declare module "app/decisiontable" {
|
|
242
|
+
import { BaseSDK } from "core/index";
|
|
243
|
+
export class DecisionTable extends BaseSDK {
|
|
244
|
+
private flowId;
|
|
245
|
+
constructor(flowId: string);
|
|
246
|
+
evaluate(payload?: object): any;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
declare module "app/dataform" {
|
|
250
|
+
import { BaseSDK } from "core/index";
|
|
251
|
+
export class Dataform extends BaseSDK {
|
|
252
|
+
private _id;
|
|
253
|
+
constructor(flowId: string);
|
|
254
|
+
importCSV(defaultValues: object): any;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
239
257
|
declare module "app/index" {
|
|
240
258
|
import { BaseSDK } from "core/index";
|
|
241
259
|
import { Page } from "app/page";
|
|
242
260
|
import { AppContext } from "types/internal";
|
|
261
|
+
import { DecisionTable } from "app/decisiontable";
|
|
262
|
+
import { Dataform } from "app/dataform";
|
|
243
263
|
export class Application extends BaseSDK {
|
|
244
264
|
page: Page;
|
|
245
265
|
_id: string;
|
|
@@ -247,6 +267,8 @@ declare module "app/index" {
|
|
|
247
267
|
getVariable(key: string): any;
|
|
248
268
|
setVariable(key: string | object, value?: any): any;
|
|
249
269
|
openPage(pageId: string, pageParams: object): any;
|
|
270
|
+
getDecisionTable(flowId: string): DecisionTable;
|
|
271
|
+
getDataform(flowId: string): Dataform;
|
|
250
272
|
}
|
|
251
273
|
export * from "app/component";
|
|
252
274
|
export { Page };
|
package/dist/lowcode.types.d.ts
CHANGED
|
@@ -66,12 +66,20 @@ declare class Page {
|
|
|
66
66
|
openPopup(popupId: string, popupParams: object): any;
|
|
67
67
|
getComponent(componentId: string): Component;
|
|
68
68
|
}
|
|
69
|
+
declare class DecisionTable {
|
|
70
|
+
evaluate(payload?: object): any;
|
|
71
|
+
}
|
|
72
|
+
declare class Dataform {
|
|
73
|
+
importCSV(defaultValues: object): any;
|
|
74
|
+
}
|
|
69
75
|
declare class Application {
|
|
70
76
|
page: Page
|
|
71
77
|
_id: string
|
|
72
78
|
getVariable(key: string): any;
|
|
73
79
|
setVariable(key: string | object, value?: any): any;
|
|
74
80
|
openPage(pageId: string, pageParams: object): any;
|
|
81
|
+
getDecisionTable(flowId: string): DecisionTable;
|
|
82
|
+
getDataform(flowId: string): Dataform;
|
|
75
83
|
}
|
|
76
84
|
declare class kf {
|
|
77
85
|
static context: Component
|
package/dist/nocode.d.ts
CHANGED
|
@@ -46,6 +46,8 @@ declare module "core/constants" {
|
|
|
46
46
|
WINDOW_NDEF_READER_ADD_EVENT_LISTENER: string;
|
|
47
47
|
WINDOW_NDEF_READER_MAKE_READONLY: string;
|
|
48
48
|
WINDOW_NDEF_READER_ABORT_SCAN: string;
|
|
49
|
+
DECISION_TABLE_EXECUTE: string;
|
|
50
|
+
DATAFORM_IMPORT_CSV: string;
|
|
49
51
|
};
|
|
50
52
|
export const EVENT_TYPES: {
|
|
51
53
|
COMPONENT_ON_MOUNT: string;
|
|
@@ -244,6 +246,22 @@ declare module "app/component" {
|
|
|
244
246
|
watchParams(callBack: (data: any) => any): void;
|
|
245
247
|
}
|
|
246
248
|
}
|
|
249
|
+
declare module "app/dataform" {
|
|
250
|
+
import { BaseSDK } from "core/index";
|
|
251
|
+
export class Dataform extends BaseSDK {
|
|
252
|
+
private _id;
|
|
253
|
+
constructor(flowId: string);
|
|
254
|
+
importCSV(defaultValues: object): any;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
declare module "app/decisiontable" {
|
|
258
|
+
import { BaseSDK } from "core/index";
|
|
259
|
+
export class DecisionTable extends BaseSDK {
|
|
260
|
+
private flowId;
|
|
261
|
+
constructor(flowId: string);
|
|
262
|
+
evaluate(payload?: object): any;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
247
265
|
declare module "app/popup" {
|
|
248
266
|
import { BaseSDK } from "core/index";
|
|
249
267
|
import { Component } from "app/component";
|
|
@@ -280,6 +298,8 @@ declare module "app/index" {
|
|
|
280
298
|
import { BaseSDK } from "core/index";
|
|
281
299
|
import { Page } from "app/page";
|
|
282
300
|
import { AppContext } from "types/internal";
|
|
301
|
+
import { DecisionTable } from "app/decisiontable";
|
|
302
|
+
import { Dataform } from "app/dataform";
|
|
283
303
|
export class Application extends BaseSDK {
|
|
284
304
|
page: Page;
|
|
285
305
|
_id: string;
|
|
@@ -287,6 +307,8 @@ declare module "app/index" {
|
|
|
287
307
|
getVariable(key: string): any;
|
|
288
308
|
setVariable(key: string | object, value?: any): any;
|
|
289
309
|
openPage(pageId: string, pageParams: object): any;
|
|
310
|
+
getDecisionTable(flowId: string): DecisionTable;
|
|
311
|
+
getDataform(flowId: string): Dataform;
|
|
290
312
|
}
|
|
291
313
|
export * from "app/component";
|
|
292
314
|
export { Page };
|
package/dist/snippets.json
CHANGED
|
@@ -15,6 +15,11 @@
|
|
|
15
15
|
"documentation": "Navigate to another page",
|
|
16
16
|
"insertText": "kf.app.openPage(\"${1:pageId}\", { inputParam1: \"value1\" })"
|
|
17
17
|
},
|
|
18
|
+
{
|
|
19
|
+
"label": "evaluate decision table",
|
|
20
|
+
"documentation": "Evaluates the provided data and returns back the matched output",
|
|
21
|
+
"insertText": "let decisionTableInstance = kf.app.getDecisionTable(\"${1:flowId}\");\n let decisionOutput = await decisionTableInstance.evaluate({ conditionField1: \"value\", conditionField2: \"value\" });"
|
|
22
|
+
},
|
|
18
23
|
{
|
|
19
24
|
"label": "get local variable",
|
|
20
25
|
"documentation": "Get value of the local variable",
|
|
@@ -185,4 +190,4 @@
|
|
|
185
190
|
"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}})"
|
|
186
191
|
}
|
|
187
192
|
]
|
|
188
|
-
}
|
|
193
|
+
}
|
package/dist/worker.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import KF_LC_SDK from "./kf.lowcodeworkersdk.es.js";
|
|
2
|
+
import KF_NC_SDK from "./kf.nocodeworkersdk.es.js";
|
|
3
|
+
|
|
4
|
+
const SDK_KIND = {
|
|
5
|
+
LOWCODE: "lowcode",
|
|
6
|
+
NOCODE: "nocode"
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
onmessage = async function (e) {
|
|
10
|
+
if (!self.kf) {
|
|
11
|
+
let { kind = SDK_KIND.LOWCODE } = e.data?.executionContext;
|
|
12
|
+
let lib = KF_LC_SDK;
|
|
13
|
+
if (kind === SDK_KIND.NOCODE) {
|
|
14
|
+
lib = KF_NC_SDK;
|
|
15
|
+
}
|
|
16
|
+
self.kf = lib(e?.data.executionContext);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (e.data?.eventParameters) {
|
|
20
|
+
let { eventParameters } = e.data;
|
|
21
|
+
if (eventParameters) {
|
|
22
|
+
self.kf.eventParameters = { ...eventParameters };
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (e.data.command !== "EXECUTE") return;
|
|
27
|
+
const func = new Function(`
|
|
28
|
+
return (async () => {
|
|
29
|
+
${e.data.code}
|
|
30
|
+
})()`);
|
|
31
|
+
|
|
32
|
+
(async function () {
|
|
33
|
+
await func();
|
|
34
|
+
postMessage({
|
|
35
|
+
_id: Math.floor(Date.now() + 999).toString(36),
|
|
36
|
+
command: "RETURN",
|
|
37
|
+
data: {}
|
|
38
|
+
});
|
|
39
|
+
})();
|
|
40
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kissflow/lowcode-client-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.22",
|
|
4
4
|
"description": "JavaScript SDK for developing over the Kissflow lowcode platform",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"start": "vite serve",
|
|
41
41
|
"customBuild": "node custom.build.mjs",
|
|
42
42
|
"build": "pnpm run customBuild",
|
|
43
|
-
"serve": "http-server -p 8080"
|
|
43
|
+
"serve": "http-server -p 8080",
|
|
44
|
+
"publish-canary": "pnpm publish --tag canary"
|
|
44
45
|
}
|
|
45
46
|
}
|