@kissflow/lowcode-client-sdk 1.0.5 → 1.0.7
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 +190 -66
- package/dist/kfsdk.es.js +379 -0
- package/dist/kfsdk.umd.js +1 -0
- package/dist/kfworkersdk.es.js +470 -0
- package/package.json +23 -9
- package/SDK_IN_INTEGRATION.md +0 -78
- package/custom.build.js +0 -99
- package/dist/app.js +0 -48
- package/dist/base.js +0 -170
- package/dist/client.js +0 -44
- package/dist/component.js +0 -45
- package/dist/constants.js +0 -48
- package/dist/form.js +0 -126
- package/dist/formatter.js +0 -54
- package/dist/global.types.d.ts +0 -68
- package/dist/index.d.ts +0 -161
- package/dist/index.html +0 -23
- package/dist/index.js +0 -7
- package/dist/kflowcode.sdk.js +0 -922
- package/dist/kflowcode.sdk.js.map +0 -1
- package/dist/kflowcode.sdk.module.js +0 -922
- package/dist/kflowcode.sdk.module.js.map +0 -1
- package/dist/lowcode.sdk.js +0 -56
- package/dist/page.js +0 -63
- package/id +0 -55
- package/index.html +0 -23
- package/src/app.ts +0 -31
- package/src/base.ts +0 -108
- package/src/client.ts +0 -28
- package/src/component.ts +0 -25
- package/src/constants.ts +0 -53
- package/src/form.ts +0 -131
- package/src/formatter.ts +0 -35
- package/src/index.ts +0 -7
- package/src/lowcode.sdk.ts +0 -44
- package/src/page.ts +0 -43
- package/test/lcnc-handler.js +0 -45
- package/test/mock/api.js +0 -16
- package/test/mock/id.js +0 -55
- package/tsconfig.json +0 -7
- package/tsconfig.types.json +0 -18
- package/webpack.config.js +0 -62
package/README.md
CHANGED
|
@@ -4,11 +4,17 @@ JavaScript SDK for developing over the Kissflow lowcode platform
|
|
|
4
4
|
|
|
5
5
|
### Use as an `npm` module
|
|
6
6
|
|
|
7
|
-
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: Note: Initializing Kf SDK in custom components returns a
|
|
9
|
+
promise.
|
|
8
10
|
|
|
9
11
|
```js
|
|
10
|
-
import
|
|
11
|
-
|
|
12
|
+
import KFSDK from "@kissflow/lowcode-client-sdk";
|
|
13
|
+
let kf;
|
|
14
|
+
(async function () {
|
|
15
|
+
// Immediately invoked function.
|
|
16
|
+
kf = await KFSDK.initialise();
|
|
17
|
+
})();
|
|
12
18
|
```
|
|
13
19
|
|
|
14
20
|
### Use as a `<script>` tag directly in HTML
|
|
@@ -16,49 +22,86 @@ const kf = KFLowcodeSDK();
|
|
|
16
22
|
SDK can also be loaded directly into HTML by adding:
|
|
17
23
|
|
|
18
24
|
```html
|
|
19
|
-
<script src="https://cdn.jsdelivr.net/npm/@kissflow/lowcode-client-sdk@1/dist/
|
|
20
|
-
<!-- or -->
|
|
21
|
-
<script type="module" src="https://cdn.jsdelivr.net/npm/@kissflow/lowcode-client-sdk@1/dist/kflowcode.sdk.module.js"></script>
|
|
25
|
+
<script src="https://cdn.jsdelivr.net/npm/@kissflow/lowcode-client-sdk@1/dist/kfsdk.umd.js"></script>
|
|
22
26
|
```
|
|
23
27
|
|
|
24
28
|
> Then SDK can be initialized anywhere by declaring:
|
|
29
|
+
|
|
25
30
|
```js
|
|
26
|
-
|
|
31
|
+
let kf;
|
|
32
|
+
(async function () {
|
|
33
|
+
kf = await window.kf.initialise();
|
|
34
|
+
})();
|
|
27
35
|
```
|
|
28
36
|
|
|
29
|
-
|
|
37
|
+
|
|
38
|
+
## 1) Context Functions
|
|
39
|
+
|
|
40
|
+
Context functions are polymorphic, it has different classes based on execution
|
|
41
|
+
context.
|
|
42
|
+
|
|
43
|
+
### Custom component functions
|
|
44
|
+
|
|
45
|
+
`kf.context` returns a `CustomComponent` class while using inside custom
|
|
46
|
+
component. Custom component supported functions:
|
|
47
|
+
|
|
48
|
+
##### a) Watch Params
|
|
49
|
+
|
|
50
|
+
Listens for changes in parameter given to custom components in lowcode
|
|
51
|
+
application.
|
|
52
|
+
|
|
53
|
+
```js
|
|
54
|
+
kf.context.watchParams(function (data) {
|
|
55
|
+
console.log(data);
|
|
56
|
+
});
|
|
57
|
+
```
|
|
30
58
|
|
|
31
59
|
### Main form functions
|
|
32
60
|
|
|
33
|
-
`kf.
|
|
61
|
+
`kf.context` returns a `Form` class when it is used inside a kissflow's form
|
|
62
|
+
that could be either Process, case or Dataform & it has following supported
|
|
63
|
+
functions
|
|
34
64
|
|
|
35
65
|
##### a) getField()
|
|
66
|
+
|
|
36
67
|
###### Description:
|
|
68
|
+
|
|
37
69
|
Use this function to get the current value of a form field
|
|
38
70
|
|
|
39
71
|
###### Syntax:
|
|
72
|
+
|
|
40
73
|
```js
|
|
41
|
-
kf.
|
|
74
|
+
kf.context.getField(fieldId).then((res) => {...})
|
|
42
75
|
// or
|
|
43
|
-
let value = await kf.
|
|
76
|
+
let value = await kf.context.getField(fieldId)
|
|
44
77
|
```
|
|
45
78
|
|
|
46
79
|
##### b) updateField()
|
|
80
|
+
|
|
47
81
|
###### Description:
|
|
82
|
+
|
|
48
83
|
Use this function to get update any field in the form
|
|
84
|
+
|
|
49
85
|
###### Syntax:
|
|
86
|
+
|
|
50
87
|
```js
|
|
51
|
-
kf.
|
|
88
|
+
kf.context.updateField({ fieldId_1: fieldValue, fieldId_2: fieldValue });
|
|
52
89
|
```
|
|
53
90
|
|
|
54
91
|
##### c) toJSON()
|
|
92
|
+
|
|
55
93
|
###### Description:
|
|
94
|
+
|
|
56
95
|
Use this function to get the JSON data of the current form
|
|
96
|
+
|
|
57
97
|
###### Syntax:
|
|
98
|
+
|
|
58
99
|
```js
|
|
59
|
-
const json = await kf.
|
|
100
|
+
const json = await kf.context.toJSON();
|
|
60
101
|
```
|
|
102
|
+
|
|
61
103
|
###### Output:
|
|
104
|
+
|
|
62
105
|
```
|
|
63
106
|
{
|
|
64
107
|
"Untitled_Field": "testing",
|
|
@@ -68,54 +111,87 @@ const json = await kf.currentForm.toJSON();
|
|
|
68
111
|
"_modified_at": "2022-03-01T03:04:09Z"
|
|
69
112
|
}
|
|
70
113
|
```
|
|
114
|
+
|
|
71
115
|
---
|
|
116
|
+
|
|
72
117
|
### Table functions
|
|
73
|
-
|
|
118
|
+
|
|
119
|
+
`kf.currentForm.getTable(tableId)` returns a `Table` class which has the
|
|
120
|
+
following functions
|
|
121
|
+
|
|
74
122
|
#### a) addRow()
|
|
123
|
+
|
|
75
124
|
###### Description:
|
|
125
|
+
|
|
76
126
|
Appends row details to the end of table.
|
|
127
|
+
|
|
77
128
|
###### Syntax:
|
|
129
|
+
|
|
78
130
|
```js
|
|
79
|
-
const table = kf.
|
|
131
|
+
const table = kf.context.getTable(tableId);
|
|
80
132
|
table.addRow({ columnId1: value, columnId2: value });
|
|
81
133
|
```
|
|
134
|
+
|
|
82
135
|
#### b) deleteRow()
|
|
136
|
+
|
|
83
137
|
###### Description:
|
|
138
|
+
|
|
84
139
|
Deletes a row from the table based on the row id
|
|
140
|
+
|
|
85
141
|
###### Syntax:
|
|
142
|
+
|
|
86
143
|
```js
|
|
87
|
-
const table = kf.
|
|
144
|
+
const table = kf.context.getTable(tableId);
|
|
88
145
|
table.deleteRow(rowId);
|
|
89
146
|
```
|
|
147
|
+
|
|
90
148
|
#### c) getRow()
|
|
149
|
+
|
|
91
150
|
###### Description:
|
|
151
|
+
|
|
92
152
|
Use this function to perform form actions on any row inside a child table
|
|
153
|
+
|
|
93
154
|
###### Syntax:
|
|
155
|
+
|
|
94
156
|
```js
|
|
95
|
-
const table = kf.
|
|
157
|
+
const table = kf.context.getTable(tableId);
|
|
96
158
|
const row = table.getRow(rowId);
|
|
97
159
|
```
|
|
160
|
+
|
|
98
161
|
###### Output:
|
|
162
|
+
|
|
99
163
|
Returns an instance of `TableForm` class
|
|
100
164
|
|
|
101
165
|
#### d) getRows()
|
|
166
|
+
|
|
102
167
|
###### Description:
|
|
168
|
+
|
|
103
169
|
Gets all the rows of the table
|
|
170
|
+
|
|
104
171
|
###### Syntax:
|
|
172
|
+
|
|
105
173
|
```js
|
|
106
|
-
const rows = await kf.
|
|
174
|
+
const rows = await kf.context.getTable(tableId).getRows();
|
|
107
175
|
```
|
|
176
|
+
|
|
108
177
|
###### Output:
|
|
178
|
+
|
|
109
179
|
Returns an array of `TableForm` instances
|
|
110
180
|
|
|
111
181
|
##### e) toJSON()
|
|
182
|
+
|
|
112
183
|
###### Description:
|
|
184
|
+
|
|
113
185
|
Use this function to get the JSON data of the child table
|
|
186
|
+
|
|
114
187
|
###### Syntax:
|
|
188
|
+
|
|
115
189
|
```js
|
|
116
|
-
const json = await kf.
|
|
190
|
+
const json = await kf.context.getTable(tableId).toJSON();
|
|
117
191
|
```
|
|
192
|
+
|
|
118
193
|
###### Output:
|
|
194
|
+
|
|
119
195
|
```
|
|
120
196
|
[{
|
|
121
197
|
"Untitled_Field": "row 1",
|
|
@@ -131,44 +207,71 @@ const json = await kf.currentForm.getTable(tableId).toJSON();
|
|
|
131
207
|
"_modified_at": "2022-03-01T03:04:09Z"
|
|
132
208
|
}]
|
|
133
209
|
```
|
|
210
|
+
|
|
134
211
|
---
|
|
212
|
+
|
|
135
213
|
### Table Row functions
|
|
214
|
+
|
|
136
215
|
`kf.currentForm` returns a `TableForm` class which has the following functions
|
|
137
|
-
|
|
216
|
+
|
|
138
217
|
##### a) getField()
|
|
218
|
+
|
|
139
219
|
###### Description:
|
|
220
|
+
|
|
140
221
|
Use this function to get the value of the table row
|
|
222
|
+
|
|
141
223
|
###### Syntax:
|
|
224
|
+
|
|
142
225
|
```js
|
|
143
|
-
kf.
|
|
226
|
+
kf.context.getField(fieldId).then((res) => {...})
|
|
144
227
|
// or
|
|
145
|
-
let value = await kf.
|
|
228
|
+
let value = await kf.context.getField(fieldId)
|
|
146
229
|
```
|
|
230
|
+
|
|
147
231
|
##### b) updateField()
|
|
232
|
+
|
|
148
233
|
###### Description:
|
|
234
|
+
|
|
149
235
|
Use this function to get update any field in the table row
|
|
236
|
+
|
|
150
237
|
###### Syntax:
|
|
238
|
+
|
|
151
239
|
```js
|
|
152
240
|
kf.currentForm.updateField({ fieldId_1: fieldValue, fieldId_2: fieldValue });
|
|
153
241
|
```
|
|
242
|
+
|
|
154
243
|
##### c) getParent()
|
|
244
|
+
|
|
155
245
|
###### Description:
|
|
246
|
+
|
|
156
247
|
Use this function to perform form actions on the main form
|
|
248
|
+
|
|
157
249
|
###### Syntax:
|
|
250
|
+
|
|
158
251
|
```js
|
|
159
|
-
const mainForm = kf.
|
|
252
|
+
const mainForm = kf.context.getParent();
|
|
160
253
|
mainForm.updateField({ fieldId_1: fieldValue, fieldId_2: fieldValue });
|
|
161
254
|
```
|
|
255
|
+
|
|
162
256
|
###### Output:
|
|
163
|
-
|
|
257
|
+
|
|
258
|
+
Returns an instance of `Form` class using which we can perform any action on the
|
|
259
|
+
main form
|
|
260
|
+
|
|
164
261
|
##### d) toJson()
|
|
262
|
+
|
|
165
263
|
##### Description:
|
|
264
|
+
|
|
166
265
|
Get JSON output of table row
|
|
266
|
+
|
|
167
267
|
##### Syntax:
|
|
268
|
+
|
|
168
269
|
```js
|
|
169
|
-
const json = await kf.
|
|
270
|
+
const json = await kf.context.toJSON();
|
|
170
271
|
```
|
|
272
|
+
|
|
171
273
|
###### Output:
|
|
274
|
+
|
|
172
275
|
```
|
|
173
276
|
{
|
|
174
277
|
"Untitled_Field": "testing",
|
|
@@ -178,43 +281,71 @@ const json = await kf.currentForm.toJSON();
|
|
|
178
281
|
"_modified_at": "2022-03-01T03:04:09Z"
|
|
179
282
|
}
|
|
180
283
|
```
|
|
284
|
+
|
|
181
285
|
---
|
|
286
|
+
|
|
182
287
|
### 2) Client Functions
|
|
288
|
+
|
|
183
289
|
##### Show Toast
|
|
290
|
+
|
|
184
291
|
```js
|
|
185
292
|
kf.client.showInfo(message);
|
|
186
293
|
```
|
|
294
|
+
|
|
187
295
|
##### Show confirm
|
|
296
|
+
|
|
188
297
|
```js
|
|
189
298
|
kf.client.showConfirm({ title, content });
|
|
190
299
|
```
|
|
300
|
+
|
|
191
301
|
##### Redirect to URL
|
|
302
|
+
|
|
192
303
|
```js
|
|
193
304
|
kf.client.redirect(url);
|
|
194
305
|
```
|
|
306
|
+
|
|
195
307
|
---
|
|
308
|
+
|
|
196
309
|
### 3) Component Functions
|
|
310
|
+
|
|
311
|
+
getComponent(id) inside page returns component class instance.
|
|
312
|
+
|
|
313
|
+
```js
|
|
314
|
+
const componentName = await kf.app.page.getComponent(componentId);
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
By using component instance we can invoke following methods.
|
|
318
|
+
|
|
197
319
|
#### Refresh a component
|
|
320
|
+
|
|
198
321
|
```js
|
|
199
|
-
|
|
322
|
+
componentName.refresh();
|
|
200
323
|
```
|
|
324
|
+
|
|
201
325
|
#### Show a component
|
|
326
|
+
|
|
202
327
|
```js
|
|
203
|
-
|
|
328
|
+
componentName.show();
|
|
204
329
|
```
|
|
330
|
+
|
|
205
331
|
#### Hide a component
|
|
332
|
+
|
|
206
333
|
```js
|
|
207
|
-
|
|
334
|
+
componentName.hide();
|
|
208
335
|
```
|
|
209
|
-
---
|
|
210
336
|
|
|
211
337
|
### 4) Lowcode application functions
|
|
338
|
+
|
|
212
339
|
Application variables has global context to application,
|
|
340
|
+
|
|
213
341
|
##### Get value to application variable
|
|
342
|
+
|
|
343
|
+
```js
|
|
344
|
+
const appVarible1 = await kf.app.getVariable("variableId");
|
|
214
345
|
```
|
|
215
|
-
|
|
216
|
-
```
|
|
346
|
+
|
|
217
347
|
##### Set value of application variable
|
|
348
|
+
|
|
218
349
|
```js
|
|
219
350
|
let value = await kf.app.setVariable("variableId", value);
|
|
220
351
|
// or
|
|
@@ -223,8 +354,11 @@ await kf.app.setVariable({
|
|
|
223
354
|
variableId_2: 3345
|
|
224
355
|
});
|
|
225
356
|
```
|
|
357
|
+
|
|
226
358
|
##### Open a page
|
|
359
|
+
|
|
227
360
|
> Note: Page Input parameters are optional.
|
|
361
|
+
|
|
228
362
|
```js
|
|
229
363
|
let pageInputParameters = {
|
|
230
364
|
param1: value,
|
|
@@ -232,96 +366,85 @@ let pageInputParameters = {
|
|
|
232
366
|
};
|
|
233
367
|
kf.app.openPage(pageId, pageInputParameters);
|
|
234
368
|
```
|
|
369
|
+
|
|
235
370
|
##### Get values of page input parameters
|
|
371
|
+
|
|
236
372
|
```js
|
|
237
373
|
let value = await kf.app.page.getParameter();
|
|
238
374
|
```
|
|
375
|
+
|
|
239
376
|
##### Open a popup
|
|
377
|
+
|
|
240
378
|
```js
|
|
241
|
-
kf.app.page.openPopup(popupId, { inputParam1: 2 })
|
|
379
|
+
kf.app.page.openPopup(popupId, { inputParam1: 2 });
|
|
242
380
|
```
|
|
381
|
+
|
|
243
382
|
##### Close popup
|
|
383
|
+
|
|
244
384
|
> Closes the active popup in the page.
|
|
245
|
-
```js
|
|
246
|
-
kf.app.page.closePopup();
|
|
247
|
-
```
|
|
248
|
-
##### Page onClose event
|
|
249
|
-
```js
|
|
250
|
-
kf.app.page.onClose(() => {});
|
|
251
|
-
```
|
|
252
|
-
---
|
|
253
385
|
|
|
254
|
-
### 6) Get context
|
|
255
|
-
Returns the current account, user, page, and application.
|
|
256
386
|
```js
|
|
257
|
-
kf.
|
|
258
|
-
// or
|
|
259
|
-
let ctx = await kf.getContext()
|
|
260
|
-
/*
|
|
261
|
-
returns the context object like.
|
|
262
|
-
ctx = {
|
|
263
|
-
app: {_id },
|
|
264
|
-
page: { _id },
|
|
265
|
-
user: { Name, Email, UserType, _id },
|
|
266
|
-
account: { _id }
|
|
267
|
-
}
|
|
268
|
-
*/
|
|
387
|
+
kf.app.page.closePopup();
|
|
269
388
|
```
|
|
270
|
-
---
|
|
271
389
|
|
|
272
|
-
###
|
|
390
|
+
### 5) Fetch Api through kf sdk
|
|
273
391
|
|
|
274
392
|
Fetch any external api & other kissflow api using this method.
|
|
393
|
+
|
|
275
394
|
> Note: This method has a limit of 10 seconds for an api call
|
|
395
|
+
|
|
276
396
|
```js
|
|
277
397
|
kf.api(url, config).then((res) => {...})
|
|
278
398
|
// or
|
|
279
399
|
let resp = await kf.api(url, config)
|
|
280
400
|
```
|
|
281
|
-
---
|
|
282
401
|
|
|
283
|
-
### 8) Watch params
|
|
284
|
-
Listens for changes in parameter given to custom components in lowcode
|
|
285
|
-
application.
|
|
286
|
-
```js
|
|
287
|
-
kf.watchParams(function (data) {
|
|
288
|
-
console.log(data);
|
|
289
|
-
});
|
|
290
|
-
```
|
|
291
402
|
---
|
|
292
403
|
|
|
293
|
-
###
|
|
404
|
+
### 6) Formatter Functions
|
|
405
|
+
|
|
294
406
|
##### Format to KF Date
|
|
407
|
+
|
|
295
408
|
```js
|
|
296
409
|
kf.formatter.toDate("08-24-2021").then((res) => {...})
|
|
297
410
|
// or
|
|
298
411
|
let value = await kf.formatter.toDate("08-24-2021");
|
|
299
412
|
```
|
|
413
|
+
|
|
300
414
|
##### Format to KF Date Time
|
|
415
|
+
|
|
301
416
|
```js
|
|
302
417
|
kf.formatter.toDateTime("2021-08-26T14:30").then((res) => {...})
|
|
303
418
|
// or
|
|
304
419
|
let value = await kf.formatter.toDateTime("2021-08-26T14:30");
|
|
305
420
|
```
|
|
421
|
+
|
|
306
422
|
##### Format to KF Number
|
|
423
|
+
|
|
307
424
|
```js
|
|
308
425
|
kf.formatter.toNumber("1,00,000.500000").then((res) => {...})
|
|
309
426
|
// or
|
|
310
427
|
let value = await kf.formatter.toNumber("1,00,000.500000");
|
|
311
428
|
```
|
|
429
|
+
|
|
312
430
|
##### Format to KF Currency
|
|
431
|
+
|
|
313
432
|
```js
|
|
314
433
|
kf.formatter.toCurrency("1,00,000.500000", "USD").then((res) => {...})
|
|
315
434
|
// or
|
|
316
435
|
let value = await kf.formatter.toCurrency("1,00,000.500000", "USD");
|
|
317
436
|
```
|
|
437
|
+
|
|
318
438
|
##### Format to KF Boolean
|
|
439
|
+
|
|
319
440
|
```js
|
|
320
441
|
kf.formatter.toBoolean("yes").then((res) => {...})
|
|
321
442
|
// or
|
|
322
443
|
let value = await kf.formatter.toBoolean("yes");
|
|
323
444
|
```
|
|
445
|
+
|
|
324
446
|
##### Other supported Boolean values
|
|
447
|
+
|
|
325
448
|
```js
|
|
326
449
|
let value = await kf.formatter.toBoolean("1");
|
|
327
450
|
let value = await kf.formatter.toBoolean("true");
|
|
@@ -329,4 +452,5 @@ let value = await kf.formatter.toBoolean("no");
|
|
|
329
452
|
let value = await kf.formatter.toBoolean("0");
|
|
330
453
|
let value = await kf.formatter.toBoolean("false");
|
|
331
454
|
```
|
|
455
|
+
|
|
332
456
|
---
|