@kissflow/lowcode-client-sdk 1.0.17 → 1.0.19-beta.1
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 +31 -7
- package/dist/index.d.ts +2 -0
- package/dist/kf.lowcodeworkersdk.es.js +13 -7
- package/dist/kf.nocodeworkersdk.es.js +13 -7
- package/dist/kfsdk.es.js +1 -0
- package/dist/kfsdk.umd.js +1 -1
- package/dist/lowcode.d.ts +2 -0
- package/dist/lowcode.types.d.ts +1 -0
- package/dist/nocode.d.ts +2 -0
- package/dist/nocode.types.d.ts +1 -0
- package/dist/snippets.json +6 -2
- package/dist/worker.js +40 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -132,15 +132,34 @@ const json = await kf.context.toJSON();
|
|
|
132
132
|
#### a) addRow()
|
|
133
133
|
|
|
134
134
|
###### Description:
|
|
135
|
-
Appends row details to the
|
|
135
|
+
Appends row details to the table.
|
|
136
136
|
|
|
137
137
|
###### Syntax:
|
|
138
138
|
```js
|
|
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
|
-
#### b)
|
|
144
|
+
#### b) addRows()
|
|
145
|
+
|
|
146
|
+
###### Description:
|
|
147
|
+
Appends multiple rows details to the table.
|
|
148
|
+
|
|
149
|
+
###### Syntax:
|
|
150
|
+
```js
|
|
151
|
+
const table = kf.context.getTable(tableId);
|
|
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);
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
#### c) deleteRow()
|
|
144
163
|
|
|
145
164
|
###### Description:
|
|
146
165
|
Deletes a row from the table based on the row id
|
|
@@ -148,10 +167,10 @@ Deletes a row from the table based on the row id
|
|
|
148
167
|
###### Syntax:
|
|
149
168
|
```js
|
|
150
169
|
const table = kf.context.getTable(tableId);
|
|
151
|
-
table.deleteRow(rowId);
|
|
170
|
+
await table.deleteRow(rowId);
|
|
152
171
|
```
|
|
153
172
|
|
|
154
|
-
####
|
|
173
|
+
#### d) getRow()
|
|
155
174
|
|
|
156
175
|
###### Description:
|
|
157
176
|
Use this function to perform form actions on any row inside a child table
|
|
@@ -165,7 +184,7 @@ const row = table.getRow(rowId);
|
|
|
165
184
|
###### Output:
|
|
166
185
|
Returns an instance of `TableForm` class
|
|
167
186
|
|
|
168
|
-
####
|
|
187
|
+
#### e) getRows()
|
|
169
188
|
|
|
170
189
|
###### Description:
|
|
171
190
|
Gets all the rows of the table
|
|
@@ -178,7 +197,7 @@ const rows = await kf.context.getTable(tableId).getRows();
|
|
|
178
197
|
###### Output:
|
|
179
198
|
Returns an array of `TableForm` instances
|
|
180
199
|
|
|
181
|
-
#####
|
|
200
|
+
##### f) toJSON()
|
|
182
201
|
|
|
183
202
|
###### Description:
|
|
184
203
|
Use this function to get the JSON data of the child table
|
|
@@ -278,8 +297,13 @@ kf.client.showInfo(message);
|
|
|
278
297
|
```
|
|
279
298
|
|
|
280
299
|
##### Show confirm
|
|
300
|
+
Displays the confirmation dialog, and returns users's action as a response
|
|
281
301
|
```js
|
|
282
|
-
kf.client.showConfirm({ title, content })
|
|
302
|
+
kf.client.showConfirm({ title, content }).then((action) => {
|
|
303
|
+
if(action === "OK") // user clicked ok button
|
|
304
|
+
|
|
305
|
+
else // user clicked cancel button or clicked outside the popup
|
|
306
|
+
})
|
|
283
307
|
```
|
|
284
308
|
|
|
285
309
|
##### Redirect to URL
|
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ declare module "core/constants" {
|
|
|
8
8
|
GET_TABLE: string;
|
|
9
9
|
GET_TABLE_ROW: string;
|
|
10
10
|
ADD_TABLE_ROW: string;
|
|
11
|
+
ADD_TABLE_ROWS: string;
|
|
11
12
|
DELETE_TABLE_ROW: string;
|
|
12
13
|
TO_JSON: string;
|
|
13
14
|
GET_TABLE_ROWS: string;
|
|
@@ -257,6 +258,7 @@ declare module "form/index" {
|
|
|
257
258
|
getRows(): TableForm[];
|
|
258
259
|
getRow(rowId: string): TableForm;
|
|
259
260
|
addRow(rowObject: object): any;
|
|
261
|
+
addRows(rows: [object]): any;
|
|
260
262
|
deleteRow(rowId: string): any;
|
|
261
263
|
}
|
|
262
264
|
export class TableForm extends BaseSDK {
|
|
@@ -43,6 +43,7 @@ const LISTENER_CMDS = {
|
|
|
43
43
|
GET_TABLE: "GET_TABLE",
|
|
44
44
|
GET_TABLE_ROW: "GET_TABLE_ROW",
|
|
45
45
|
ADD_TABLE_ROW: "ADD_TABLE_ROW",
|
|
46
|
+
ADD_TABLE_ROWS: "ADD_TABLE_ROWS",
|
|
46
47
|
DELETE_TABLE_ROW: "DELETE_TABLE_ROW",
|
|
47
48
|
TO_JSON: "TO_JSON",
|
|
48
49
|
GET_TABLE_ROWS: "GET_TABLE_ROWS",
|
|
@@ -224,12 +225,9 @@ class Table extends BaseSDK {
|
|
|
224
225
|
this.instanceId = instanceId;
|
|
225
226
|
}
|
|
226
227
|
toJSON() {
|
|
227
|
-
return this._postMessageAsync(
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
tableId: this.tableId
|
|
231
|
-
}
|
|
232
|
-
);
|
|
228
|
+
return this._postMessageAsync(LISTENER_CMDS.TO_JSON, {
|
|
229
|
+
tableId: this.tableId
|
|
230
|
+
});
|
|
233
231
|
}
|
|
234
232
|
getRows() {
|
|
235
233
|
return this._postMessageAsync(
|
|
@@ -237,7 +235,9 @@ class Table extends BaseSDK {
|
|
|
237
235
|
{ tableId: this.tableId },
|
|
238
236
|
true,
|
|
239
237
|
(data) => {
|
|
240
|
-
return data.map(
|
|
238
|
+
return data.map(
|
|
239
|
+
(row) => new TableForm(this.instanceId, this.tableId, row.id)
|
|
240
|
+
);
|
|
241
241
|
}
|
|
242
242
|
);
|
|
243
243
|
}
|
|
@@ -250,6 +250,12 @@ class Table extends BaseSDK {
|
|
|
250
250
|
rowObject
|
|
251
251
|
});
|
|
252
252
|
}
|
|
253
|
+
addRows(rows) {
|
|
254
|
+
return this._postMessageAsync(LISTENER_CMDS.ADD_TABLE_ROWS, {
|
|
255
|
+
tableId: this.tableId,
|
|
256
|
+
rows
|
|
257
|
+
});
|
|
258
|
+
}
|
|
253
259
|
deleteRow(rowId) {
|
|
254
260
|
return this._postMessageAsync(LISTENER_CMDS.DELETE_TABLE_ROW, {
|
|
255
261
|
tableId: this.tableId,
|
|
@@ -39,6 +39,7 @@ const LISTENER_CMDS = {
|
|
|
39
39
|
GET_TABLE: "GET_TABLE",
|
|
40
40
|
GET_TABLE_ROW: "GET_TABLE_ROW",
|
|
41
41
|
ADD_TABLE_ROW: "ADD_TABLE_ROW",
|
|
42
|
+
ADD_TABLE_ROWS: "ADD_TABLE_ROWS",
|
|
42
43
|
DELETE_TABLE_ROW: "DELETE_TABLE_ROW",
|
|
43
44
|
TO_JSON: "TO_JSON",
|
|
44
45
|
GET_TABLE_ROWS: "GET_TABLE_ROWS",
|
|
@@ -213,12 +214,9 @@ class Table extends BaseSDK {
|
|
|
213
214
|
this.instanceId = instanceId;
|
|
214
215
|
}
|
|
215
216
|
toJSON() {
|
|
216
|
-
return this._postMessageAsync(
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
tableId: this.tableId
|
|
220
|
-
}
|
|
221
|
-
);
|
|
217
|
+
return this._postMessageAsync(LISTENER_CMDS.TO_JSON, {
|
|
218
|
+
tableId: this.tableId
|
|
219
|
+
});
|
|
222
220
|
}
|
|
223
221
|
getRows() {
|
|
224
222
|
return this._postMessageAsync(
|
|
@@ -226,7 +224,9 @@ class Table extends BaseSDK {
|
|
|
226
224
|
{ tableId: this.tableId },
|
|
227
225
|
true,
|
|
228
226
|
(data) => {
|
|
229
|
-
return data.map(
|
|
227
|
+
return data.map(
|
|
228
|
+
(row) => new TableForm(this.instanceId, this.tableId, row.id)
|
|
229
|
+
);
|
|
230
230
|
}
|
|
231
231
|
);
|
|
232
232
|
}
|
|
@@ -239,6 +239,12 @@ class Table extends BaseSDK {
|
|
|
239
239
|
rowObject
|
|
240
240
|
});
|
|
241
241
|
}
|
|
242
|
+
addRows(rows) {
|
|
243
|
+
return this._postMessageAsync(LISTENER_CMDS.ADD_TABLE_ROWS, {
|
|
244
|
+
tableId: this.tableId,
|
|
245
|
+
rows
|
|
246
|
+
});
|
|
247
|
+
}
|
|
242
248
|
deleteRow(rowId) {
|
|
243
249
|
return this._postMessageAsync(LISTENER_CMDS.DELETE_TABLE_ROW, {
|
|
244
250
|
tableId: this.tableId,
|
package/dist/kfsdk.es.js
CHANGED
package/dist/kfsdk.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var c=(E,t,
|
|
1
|
+
var c=(E,t,A)=>{if(!t.has(E))throw TypeError("Cannot "+A)};var o=(E,t,A)=>(c(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)},g=(E,t,A,a)=>(c(E,t,"write to private field"),a?a.call(E,A):t.set(E,A),A);var L=(E,t,A)=>(c(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"},A={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,i,void 0);g(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(R){console.error("Message callback error: ",R)}}),this._removeEventListener(_))}}i=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: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||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 W 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 y 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 W(e),this.page=new I(e),this.context=new G(e.componentId),this.client=new y,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});
|
package/dist/lowcode.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ declare module "core/constants" {
|
|
|
8
8
|
GET_TABLE: string;
|
|
9
9
|
GET_TABLE_ROW: string;
|
|
10
10
|
ADD_TABLE_ROW: string;
|
|
11
|
+
ADD_TABLE_ROWS: string;
|
|
11
12
|
DELETE_TABLE_ROW: string;
|
|
12
13
|
TO_JSON: string;
|
|
13
14
|
GET_TABLE_ROWS: string;
|
|
@@ -90,6 +91,7 @@ declare module "form/index" {
|
|
|
90
91
|
getRows(): TableForm[];
|
|
91
92
|
getRow(rowId: string): TableForm;
|
|
92
93
|
addRow(rowObject: object): any;
|
|
94
|
+
addRows(rows: [object]): any;
|
|
93
95
|
deleteRow(rowId: string): any;
|
|
94
96
|
}
|
|
95
97
|
export class TableForm extends BaseSDK {
|
package/dist/lowcode.types.d.ts
CHANGED
package/dist/nocode.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ declare module "core/constants" {
|
|
|
8
8
|
GET_TABLE: string;
|
|
9
9
|
GET_TABLE_ROW: string;
|
|
10
10
|
ADD_TABLE_ROW: string;
|
|
11
|
+
ADD_TABLE_ROWS: string;
|
|
11
12
|
DELETE_TABLE_ROW: string;
|
|
12
13
|
TO_JSON: string;
|
|
13
14
|
GET_TABLE_ROWS: string;
|
|
@@ -90,6 +91,7 @@ declare module "form/index" {
|
|
|
90
91
|
getRows(): TableForm[];
|
|
91
92
|
getRow(rowId: string): TableForm;
|
|
92
93
|
addRow(rowObject: object): any;
|
|
94
|
+
addRows(rows: [object]): any;
|
|
93
95
|
deleteRow(rowId: string): any;
|
|
94
96
|
}
|
|
95
97
|
export class TableForm extends BaseSDK {
|
package/dist/nocode.types.d.ts
CHANGED
package/dist/snippets.json
CHANGED
|
@@ -65,6 +65,11 @@
|
|
|
65
65
|
"documentation": "Sets the specified tab index as active - works only for the tab component",
|
|
66
66
|
"insertText": "// sets 2nd tab as active\ncomponentInstance.setActiveTab(${1:2})"
|
|
67
67
|
},
|
|
68
|
+
{
|
|
69
|
+
"label": "set selected item",
|
|
70
|
+
"documentation": "Sets the specified instance as selected item - works only for master detail component",
|
|
71
|
+
"insertText": "componentInstance.setSelectedItem(\"${1:instanceId}\")"
|
|
72
|
+
},
|
|
68
73
|
{
|
|
69
74
|
"label": "get popup parameter",
|
|
70
75
|
"documentation": "Get specific parameter in the popup",
|
|
@@ -149,7 +154,6 @@
|
|
|
149
154
|
"documentation": "Retrieves the acccount id",
|
|
150
155
|
"insertText": "kf.account._id"
|
|
151
156
|
},
|
|
152
|
-
|
|
153
157
|
{
|
|
154
158
|
"label": "get dataform item",
|
|
155
159
|
"documentation": "API call to get dataform item",
|
|
@@ -181,4 +185,4 @@
|
|
|
181
185
|
"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}})"
|
|
182
186
|
}
|
|
183
187
|
]
|
|
184
|
-
}
|
|
188
|
+
}
|
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
|
+
};
|