@kissflow/lowcode-client-sdk 1.0.19 → 1.0.21
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 +25 -9
- package/dist/index.d.ts +12 -0
- package/dist/kf.lowcodeworkersdk.es.js +24 -2
- package/dist/kf.nocodeworkersdk.es.js +9 -2
- package/dist/kfsdk.es.js +17 -1
- package/dist/kfsdk.umd.js +1 -1
- package/dist/lowcode.d.ts +12 -0
- package/dist/lowcode.types.d.ts +5 -0
- package/dist/nocode.d.ts +12 -0
- package/dist/nocode.types.d.ts +1 -0
- package/dist/snippets.json +6 -1
- package/dist/worker.js +40 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -139,6 +139,7 @@ Appends row details to the table.
|
|
|
139
139
|
const table = kf.context.getTable(tableId);
|
|
140
140
|
table.addRow({ columnId1: value, columnId2: value });
|
|
141
141
|
```
|
|
142
|
+
> ##### Note: If there are more than one rows to be added to table then use `addRows()` instead for these bulk operations
|
|
142
143
|
|
|
143
144
|
#### b) addRows()
|
|
144
145
|
|
|
@@ -148,11 +149,14 @@ Appends multiple rows details to the table.
|
|
|
148
149
|
###### Syntax:
|
|
149
150
|
```js
|
|
150
151
|
const table = kf.context.getTable(tableId);
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
{
|
|
154
|
-
|
|
155
|
-
]
|
|
152
|
+
let accumulator = [];
|
|
153
|
+
someArrayOfObjects.forEach(function(rowDetail) {
|
|
154
|
+
accumulator.push({
|
|
155
|
+
columnId1: rowDetail[columnId1],
|
|
156
|
+
columnId2: rowDetail[columnId2]
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
await table.addRows(accumulator);
|
|
156
160
|
```
|
|
157
161
|
|
|
158
162
|
#### c) deleteRow()
|
|
@@ -163,10 +167,22 @@ Deletes a row from the table based on the row id
|
|
|
163
167
|
###### Syntax:
|
|
164
168
|
```js
|
|
165
169
|
const table = kf.context.getTable(tableId);
|
|
166
|
-
table.deleteRow(rowId);
|
|
170
|
+
await table.deleteRow(rowId);
|
|
171
|
+
```
|
|
172
|
+
> ##### Note: If there are more than one rows to be deleted then use `deleteRows()` instead.
|
|
173
|
+
|
|
174
|
+
#### d) deleteRows()
|
|
175
|
+
|
|
176
|
+
###### Description:
|
|
177
|
+
Deletes multiple rows from the table based on given array of strings.
|
|
178
|
+
|
|
179
|
+
###### Syntax:
|
|
180
|
+
```js
|
|
181
|
+
const table = kf.context.getTable(tableId);
|
|
182
|
+
await table.deleteRows([rowId1, rowId2, rowId3]);
|
|
167
183
|
```
|
|
168
184
|
|
|
169
|
-
####
|
|
185
|
+
#### e) getRow()
|
|
170
186
|
|
|
171
187
|
###### Description:
|
|
172
188
|
Use this function to perform form actions on any row inside a child table
|
|
@@ -180,7 +196,7 @@ const row = table.getRow(rowId);
|
|
|
180
196
|
###### Output:
|
|
181
197
|
Returns an instance of `TableForm` class
|
|
182
198
|
|
|
183
|
-
####
|
|
199
|
+
#### f) getRows()
|
|
184
200
|
|
|
185
201
|
###### Description:
|
|
186
202
|
Gets all the rows of the table
|
|
@@ -193,7 +209,7 @@ const rows = await kf.context.getTable(tableId).getRows();
|
|
|
193
209
|
###### Output:
|
|
194
210
|
Returns an array of `TableForm` instances
|
|
195
211
|
|
|
196
|
-
#####
|
|
212
|
+
##### g) toJSON()
|
|
197
213
|
|
|
198
214
|
###### Description:
|
|
199
215
|
Use this function to get the JSON data of the child table
|
package/dist/index.d.ts
CHANGED
|
@@ -46,6 +46,7 @@ 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;
|
|
49
50
|
};
|
|
50
51
|
export const EVENT_TYPES: {
|
|
51
52
|
COMPONENT_ON_MOUNT: string;
|
|
@@ -174,10 +175,19 @@ declare module "app/page" {
|
|
|
174
175
|
getComponent(componentId: string): Component;
|
|
175
176
|
}
|
|
176
177
|
}
|
|
178
|
+
declare module "app/decisiontable" {
|
|
179
|
+
import { BaseSDK } from "core/index";
|
|
180
|
+
export class DecisionTable extends BaseSDK {
|
|
181
|
+
private flowId;
|
|
182
|
+
constructor(flowId: string);
|
|
183
|
+
evaluate(payload?: object): any;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
177
186
|
declare module "app/index" {
|
|
178
187
|
import { BaseSDK } from "core/index";
|
|
179
188
|
import { Page } from "app/page";
|
|
180
189
|
import { AppContext } from "types/internal";
|
|
190
|
+
import { DecisionTable } from "app/decisiontable";
|
|
181
191
|
export class Application extends BaseSDK {
|
|
182
192
|
page: Page;
|
|
183
193
|
_id: string;
|
|
@@ -185,6 +195,7 @@ declare module "app/index" {
|
|
|
185
195
|
getVariable(key: string): any;
|
|
186
196
|
setVariable(key: string | object, value?: any): any;
|
|
187
197
|
openPage(pageId: string, pageParams: object): any;
|
|
198
|
+
getDecisionTable(flowId: string): DecisionTable;
|
|
188
199
|
}
|
|
189
200
|
export * from "app/component";
|
|
190
201
|
export { Page };
|
|
@@ -260,6 +271,7 @@ declare module "form/index" {
|
|
|
260
271
|
addRow(rowObject: object): any;
|
|
261
272
|
addRows(rows: [object]): any;
|
|
262
273
|
deleteRow(rowId: string): any;
|
|
274
|
+
deleteRows(rows: [string]): any;
|
|
263
275
|
}
|
|
264
276
|
export class TableForm extends BaseSDK {
|
|
265
277
|
private instanceId;
|
|
@@ -80,7 +80,8 @@ 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"
|
|
84
85
|
};
|
|
85
86
|
const EVENT_TYPES = {
|
|
86
87
|
COMPONENT_ON_MOUNT: "componentOnMount",
|
|
@@ -259,7 +260,13 @@ class Table extends BaseSDK {
|
|
|
259
260
|
deleteRow(rowId) {
|
|
260
261
|
return this._postMessageAsync(LISTENER_CMDS.DELETE_TABLE_ROW, {
|
|
261
262
|
tableId: this.tableId,
|
|
262
|
-
rowId
|
|
263
|
+
rows: [rowId]
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
deleteRows(rows) {
|
|
267
|
+
return this._postMessageAsync(LISTENER_CMDS.DELETE_TABLE_ROW, {
|
|
268
|
+
tableId: this.tableId,
|
|
269
|
+
rows
|
|
263
270
|
});
|
|
264
271
|
}
|
|
265
272
|
}
|
|
@@ -478,6 +485,18 @@ class Page extends BaseSDK {
|
|
|
478
485
|
);
|
|
479
486
|
}
|
|
480
487
|
}
|
|
488
|
+
class DecisionTable extends BaseSDK {
|
|
489
|
+
constructor(flowId) {
|
|
490
|
+
super();
|
|
491
|
+
this.flowId = flowId;
|
|
492
|
+
}
|
|
493
|
+
evaluate(payload) {
|
|
494
|
+
return this._postMessageAsync(LISTENER_CMDS.DECISION_TABLE_EXECUTE, {
|
|
495
|
+
flowId: this.flowId,
|
|
496
|
+
payload
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
}
|
|
481
500
|
class Application extends BaseSDK {
|
|
482
501
|
constructor(props) {
|
|
483
502
|
super();
|
|
@@ -501,6 +520,9 @@ class Application extends BaseSDK {
|
|
|
501
520
|
pageParams
|
|
502
521
|
});
|
|
503
522
|
}
|
|
523
|
+
getDecisionTable(flowId) {
|
|
524
|
+
return new DecisionTable(flowId);
|
|
525
|
+
}
|
|
504
526
|
}
|
|
505
527
|
class NDEFReader extends BaseSDK {
|
|
506
528
|
constructor() {
|
|
@@ -76,7 +76,8 @@ 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"
|
|
80
81
|
};
|
|
81
82
|
function generateId(prefix = "lcncsdk") {
|
|
82
83
|
return `${prefix}-${nanoid()}`;
|
|
@@ -248,7 +249,13 @@ class Table extends BaseSDK {
|
|
|
248
249
|
deleteRow(rowId) {
|
|
249
250
|
return this._postMessageAsync(LISTENER_CMDS.DELETE_TABLE_ROW, {
|
|
250
251
|
tableId: this.tableId,
|
|
251
|
-
rowId
|
|
252
|
+
rows: [rowId]
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
deleteRows(rows) {
|
|
256
|
+
return this._postMessageAsync(LISTENER_CMDS.DELETE_TABLE_ROW, {
|
|
257
|
+
tableId: this.tableId,
|
|
258
|
+
rows
|
|
252
259
|
});
|
|
253
260
|
}
|
|
254
261
|
}
|
package/dist/kfsdk.es.js
CHANGED
|
@@ -80,7 +80,8 @@ 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"
|
|
84
85
|
};
|
|
85
86
|
const EVENT_TYPES = {
|
|
86
87
|
COMPONENT_ON_MOUNT: "componentOnMount",
|
|
@@ -348,6 +349,18 @@ class Page extends BaseSDK {
|
|
|
348
349
|
);
|
|
349
350
|
}
|
|
350
351
|
}
|
|
352
|
+
class DecisionTable extends BaseSDK {
|
|
353
|
+
constructor(flowId) {
|
|
354
|
+
super();
|
|
355
|
+
this.flowId = flowId;
|
|
356
|
+
}
|
|
357
|
+
evaluate(payload) {
|
|
358
|
+
return this._postMessageAsync(LISTENER_CMDS.DECISION_TABLE_EXECUTE, {
|
|
359
|
+
flowId: this.flowId,
|
|
360
|
+
payload
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
}
|
|
351
364
|
class Application extends BaseSDK {
|
|
352
365
|
constructor(props) {
|
|
353
366
|
super();
|
|
@@ -371,6 +384,9 @@ class Application extends BaseSDK {
|
|
|
371
384
|
pageParams
|
|
372
385
|
});
|
|
373
386
|
}
|
|
387
|
+
getDecisionTable(flowId) {
|
|
388
|
+
return new DecisionTable(flowId);
|
|
389
|
+
}
|
|
374
390
|
}
|
|
375
391
|
class Client extends BaseSDK {
|
|
376
392
|
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,R)=>(h(E,t,"write to private field"),R?R.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"},A={COMPONENT_ON_MOUNT:"componentOnMount",CC_ON_PARAMS_CHANGE:"onCustomComponentParamsChange"},R={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:N={}}=e;let T=P[r];T._dispatchEvent(c,a),N.once&&T._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 O extends S{_postMessageAsync(e,s,_,r){return new Promise((a,c)=>{const N=u(e.toLowerCase());C({_id:N,command:e,...s}),P[N]=this,this._addEventListener(N,async T=>{T!=null&&T.errorMessage?c(T):(_&&r&&(T=await r(T)),a(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,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 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:A.CC_ON_PARAMS_CHANGE,eventConfig:{once:!1}},e)}}class f extends O{constructor(e){super(),this.type="Popup",this._id=e.popupId||R.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 W extends O{constructor(e){super(),this.flowId=e}evaluate(e){return this._postMessageAsync(t.DECISION_TABLE_EXECUTE,{flowId:this.flowId,payload:e})}}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})}getDecisionTable(e){return new W(e)}}class F 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 m 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 B 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 F,this.formatter=new m,this.user=e.user,this.account=e.account,this.env=e.envDetails,this))}initialise(){return this.initialize()}}var U=new B;return U});
|
package/dist/lowcode.d.ts
CHANGED
|
@@ -46,6 +46,7 @@ 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;
|
|
49
50
|
};
|
|
50
51
|
export const EVENT_TYPES: {
|
|
51
52
|
COMPONENT_ON_MOUNT: string;
|
|
@@ -93,6 +94,7 @@ declare module "form/index" {
|
|
|
93
94
|
addRow(rowObject: object): any;
|
|
94
95
|
addRows(rows: [object]): any;
|
|
95
96
|
deleteRow(rowId: string): any;
|
|
97
|
+
deleteRows(rows: [string]): any;
|
|
96
98
|
}
|
|
97
99
|
export class TableForm extends BaseSDK {
|
|
98
100
|
private instanceId;
|
|
@@ -235,10 +237,19 @@ declare module "app/page" {
|
|
|
235
237
|
getComponent(componentId: string): Component;
|
|
236
238
|
}
|
|
237
239
|
}
|
|
240
|
+
declare module "app/decisiontable" {
|
|
241
|
+
import { BaseSDK } from "core/index";
|
|
242
|
+
export class DecisionTable extends BaseSDK {
|
|
243
|
+
private flowId;
|
|
244
|
+
constructor(flowId: string);
|
|
245
|
+
evaluate(payload?: object): any;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
238
248
|
declare module "app/index" {
|
|
239
249
|
import { BaseSDK } from "core/index";
|
|
240
250
|
import { Page } from "app/page";
|
|
241
251
|
import { AppContext } from "types/internal";
|
|
252
|
+
import { DecisionTable } from "app/decisiontable";
|
|
242
253
|
export class Application extends BaseSDK {
|
|
243
254
|
page: Page;
|
|
244
255
|
_id: string;
|
|
@@ -246,6 +257,7 @@ declare module "app/index" {
|
|
|
246
257
|
getVariable(key: string): any;
|
|
247
258
|
setVariable(key: string | object, value?: any): any;
|
|
248
259
|
openPage(pageId: string, pageParams: object): any;
|
|
260
|
+
getDecisionTable(flowId: string): DecisionTable;
|
|
249
261
|
}
|
|
250
262
|
export * from "app/component";
|
|
251
263
|
export { Page };
|
package/dist/lowcode.types.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ declare class Table {
|
|
|
13
13
|
addRow(rowObject: object): any;
|
|
14
14
|
addRows(rows: [object]): any;
|
|
15
15
|
deleteRow(rowId: string): any;
|
|
16
|
+
deleteRows(rows: [string]): any;
|
|
16
17
|
}
|
|
17
18
|
declare class TableForm {
|
|
18
19
|
type: string
|
|
@@ -65,12 +66,16 @@ declare class Page {
|
|
|
65
66
|
openPopup(popupId: string, popupParams: object): any;
|
|
66
67
|
getComponent(componentId: string): Component;
|
|
67
68
|
}
|
|
69
|
+
declare class DecisionTable {
|
|
70
|
+
evaluate(payload?: object): any;
|
|
71
|
+
}
|
|
68
72
|
declare class Application {
|
|
69
73
|
page: Page
|
|
70
74
|
_id: string
|
|
71
75
|
getVariable(key: string): any;
|
|
72
76
|
setVariable(key: string | object, value?: any): any;
|
|
73
77
|
openPage(pageId: string, pageParams: object): any;
|
|
78
|
+
getDecisionTable(flowId: string): DecisionTable;
|
|
74
79
|
}
|
|
75
80
|
declare class kf {
|
|
76
81
|
static context: Component
|
package/dist/nocode.d.ts
CHANGED
|
@@ -46,6 +46,7 @@ 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;
|
|
49
50
|
};
|
|
50
51
|
export const EVENT_TYPES: {
|
|
51
52
|
COMPONENT_ON_MOUNT: string;
|
|
@@ -93,6 +94,7 @@ declare module "form/index" {
|
|
|
93
94
|
addRow(rowObject: object): any;
|
|
94
95
|
addRows(rows: [object]): any;
|
|
95
96
|
deleteRow(rowId: string): any;
|
|
97
|
+
deleteRows(rows: [string]): any;
|
|
96
98
|
}
|
|
97
99
|
export class TableForm extends BaseSDK {
|
|
98
100
|
private instanceId;
|
|
@@ -243,6 +245,14 @@ declare module "app/component" {
|
|
|
243
245
|
watchParams(callBack: (data: any) => any): void;
|
|
244
246
|
}
|
|
245
247
|
}
|
|
248
|
+
declare module "app/decisiontable" {
|
|
249
|
+
import { BaseSDK } from "core/index";
|
|
250
|
+
export class DecisionTable extends BaseSDK {
|
|
251
|
+
private flowId;
|
|
252
|
+
constructor(flowId: string);
|
|
253
|
+
evaluate(payload?: object): any;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
246
256
|
declare module "app/popup" {
|
|
247
257
|
import { BaseSDK } from "core/index";
|
|
248
258
|
import { Component } from "app/component";
|
|
@@ -279,6 +289,7 @@ declare module "app/index" {
|
|
|
279
289
|
import { BaseSDK } from "core/index";
|
|
280
290
|
import { Page } from "app/page";
|
|
281
291
|
import { AppContext } from "types/internal";
|
|
292
|
+
import { DecisionTable } from "app/decisiontable";
|
|
282
293
|
export class Application extends BaseSDK {
|
|
283
294
|
page: Page;
|
|
284
295
|
_id: string;
|
|
@@ -286,6 +297,7 @@ declare module "app/index" {
|
|
|
286
297
|
getVariable(key: string): any;
|
|
287
298
|
setVariable(key: string | object, value?: any): any;
|
|
288
299
|
openPage(pageId: string, pageParams: object): any;
|
|
300
|
+
getDecisionTable(flowId: string): DecisionTable;
|
|
289
301
|
}
|
|
290
302
|
export * from "app/component";
|
|
291
303
|
export { Page };
|
package/dist/nocode.types.d.ts
CHANGED
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
|
+
};
|