@kissflow/lowcode-client-sdk 1.0.13 → 1.0.14-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/kf.nocodeworkersdk.es.js +441 -0
- package/dist/nocode.d.ts +292 -0
- package/dist/nocode.types.d.ts +64 -0
- package/dist/snippets.json +183 -0
- package/package.json +2 -2
- /package/dist/{kfworkersdk.es.js → kf.lowcodeworkersdk.es.js} +0 -0
- /package/dist/{global.types.d.ts → lowcode.types.d.ts} +0 -0
|
@@ -0,0 +1,441 @@
|
|
|
1
|
+
var __accessCheck = (obj, member, msg) => {
|
|
2
|
+
if (!member.has(obj))
|
|
3
|
+
throw TypeError("Cannot " + msg);
|
|
4
|
+
};
|
|
5
|
+
var __privateGet = (obj, member, getter) => {
|
|
6
|
+
__accessCheck(obj, member, "read from private field");
|
|
7
|
+
return getter ? getter.call(obj) : member.get(obj);
|
|
8
|
+
};
|
|
9
|
+
var __privateAdd = (obj, member, value) => {
|
|
10
|
+
if (member.has(obj))
|
|
11
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
12
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
13
|
+
};
|
|
14
|
+
var __privateSet = (obj, member, value, setter) => {
|
|
15
|
+
__accessCheck(obj, member, "write to private field");
|
|
16
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
17
|
+
return value;
|
|
18
|
+
};
|
|
19
|
+
var _listeners, _csrfToken;
|
|
20
|
+
let nanoid = (size = 21) => crypto.getRandomValues(new Uint8Array(size)).reduce((id, byte) => {
|
|
21
|
+
byte &= 63;
|
|
22
|
+
if (byte < 36) {
|
|
23
|
+
id += byte.toString(36);
|
|
24
|
+
} else if (byte < 62) {
|
|
25
|
+
id += (byte - 26).toString(36).toUpperCase();
|
|
26
|
+
} else if (byte > 62) {
|
|
27
|
+
id += "-";
|
|
28
|
+
} else {
|
|
29
|
+
id += "_";
|
|
30
|
+
}
|
|
31
|
+
return id;
|
|
32
|
+
}, "");
|
|
33
|
+
const LISTENER_CMDS = {
|
|
34
|
+
API: "API",
|
|
35
|
+
GET_CONTEXT: "GET_CONTEXT",
|
|
36
|
+
RETURN: "RETURN",
|
|
37
|
+
GET_FORM_FIELD: "GET_FORM_FIELD",
|
|
38
|
+
UPDATE_FORM: "UPDATE_FORM",
|
|
39
|
+
GET_TABLE: "GET_TABLE",
|
|
40
|
+
GET_TABLE_ROW: "GET_TABLE_ROW",
|
|
41
|
+
ADD_TABLE_ROW: "ADD_TABLE_ROW",
|
|
42
|
+
DELETE_TABLE_ROW: "DELETE_TABLE_ROW",
|
|
43
|
+
TO_JSON: "TO_JSON",
|
|
44
|
+
GET_TABLE_ROWS: "GET_TABLE_ROWS",
|
|
45
|
+
MESSAGE: "MESSAGE",
|
|
46
|
+
CONFIRM: "CONFIRM",
|
|
47
|
+
ALERT: "ALERT",
|
|
48
|
+
REDIRECT: "REDIRECT",
|
|
49
|
+
OPEN_PAGE: "OPEN_PAGE",
|
|
50
|
+
FORMAT_DATE: "FORMAT_DATE",
|
|
51
|
+
FORMAT_DATE_TIME: "FORMAT_DATE_TIME",
|
|
52
|
+
FORMAT_NUMBER: "FORMAT_NUMBER",
|
|
53
|
+
FORMAT_CURRENCY: "FORMAT_CURRENCY",
|
|
54
|
+
FORMAT_BOOLEAN: "FORMAT_BOOLEAN",
|
|
55
|
+
GET_APP_VARIABLE: "GET_APP_VARIABLE",
|
|
56
|
+
SET_APP_VARIABLE: "SET_APP_VARIABLE",
|
|
57
|
+
GET_PAGE_VARIABLE: "GET_PAGE_VARIABLE",
|
|
58
|
+
SET_PAGE_VARIABLE: "SET_PAGE_VARIABLE",
|
|
59
|
+
GET_PAGE_PARAMS: "GET_PAGE_PARAMS",
|
|
60
|
+
GET_ALL_PAGE_PARAMS: "GET_ALL_PAGE_PARAMS",
|
|
61
|
+
PAGE_ON_CLOSE: "PAGE_ON_CLOSE",
|
|
62
|
+
OPEN_POPUP: "OPEN_POPUP",
|
|
63
|
+
GET_POPUP_PARAMS: "GET_POPUP_PARAMS",
|
|
64
|
+
GET_ALL_POPUP_PARAMS: "GET_ALL_POPUP_PARAMS",
|
|
65
|
+
CLOSE_POPUP: "CLOSE_POPUP",
|
|
66
|
+
COMPONENT_GET: "COMPONENT_GET",
|
|
67
|
+
COMPONENT_REFRESH: "COMPONENT_REFRESH",
|
|
68
|
+
COMPONENT_SHOW: "COMPONENT_SHOW",
|
|
69
|
+
COMPONENT_HIDE: "COMPONENT_HIDE",
|
|
70
|
+
COMPONENT_ADD_EVENT_LISTENER: "COMPONENT_ADD_EVENT_LISTENER",
|
|
71
|
+
CC_INITIALIZE: "CC_INITIALIZE",
|
|
72
|
+
CC_WATCH_PARAMS: "CC_WATCH_PARAMS",
|
|
73
|
+
WINDOW_NDEF_READER_NEW: "WINDOW_NDEF_READER_NEW",
|
|
74
|
+
WINDOW_NDEF_READER_SCAN: "WINDOW_NDEF_READER_SCAN",
|
|
75
|
+
WINDOW_NDEF_READER_WRITE: "WINDOW_NDEF_READER_WRITE",
|
|
76
|
+
WINDOW_NDEF_READER_ADD_EVENT_LISTENER: "WINDOW_NDEF_READER_ADD_EVENT_LISTENER",
|
|
77
|
+
WINDOW_NDEF_READER_MAKE_READONLY: "WINDOW_NDEF_READER_MAKE_READONLY",
|
|
78
|
+
WINDOW_NDEF_READER_ABORT_SCAN: "WINDOW_NDEF_READER_ABORT_SCAN"
|
|
79
|
+
};
|
|
80
|
+
function generateId(prefix = "lcncsdk") {
|
|
81
|
+
return `${prefix}-${nanoid()}`;
|
|
82
|
+
}
|
|
83
|
+
const globalInstances = {};
|
|
84
|
+
function postMessage(args) {
|
|
85
|
+
if (globalThis.parent && globalThis.parent !== globalThis) {
|
|
86
|
+
globalThis.parent.postMessage(args, "*");
|
|
87
|
+
} else {
|
|
88
|
+
globalThis.postMessage(args);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function onMessage(event) {
|
|
92
|
+
if (event.origin !== globalThis.location.origin) {
|
|
93
|
+
const data = event.data;
|
|
94
|
+
if (data == null ? void 0 : data.isEvent) {
|
|
95
|
+
const { target, eventParams, eventName, eventConfig = {} } = data;
|
|
96
|
+
let targetInstance = globalInstances[target];
|
|
97
|
+
targetInstance._dispatchEvent(eventName, eventParams);
|
|
98
|
+
if (eventConfig.once) {
|
|
99
|
+
targetInstance._removeEventListener(eventName);
|
|
100
|
+
}
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
let { _req: req, resp } = data;
|
|
104
|
+
if (req == null ? void 0 : req._id) {
|
|
105
|
+
let targetInstance = globalInstances[req._id];
|
|
106
|
+
targetInstance._dispatchMessageEvents(req, resp);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
globalThis.addEventListener("message", onMessage);
|
|
111
|
+
class EventBase {
|
|
112
|
+
constructor() {
|
|
113
|
+
__privateAdd(this, _listeners, void 0);
|
|
114
|
+
__privateSet(this, _listeners, {});
|
|
115
|
+
}
|
|
116
|
+
_addEventListener(eventName, callBack) {
|
|
117
|
+
var _a;
|
|
118
|
+
__privateGet(this, _listeners)[eventName] = ((_a = __privateGet(this, _listeners)) == null ? void 0 : _a[eventName]) || [];
|
|
119
|
+
__privateGet(this, _listeners)[eventName].push(callBack);
|
|
120
|
+
}
|
|
121
|
+
_removeEventListener(eventName, callBack) {
|
|
122
|
+
if (callBack) {
|
|
123
|
+
let index = __privateGet(this, _listeners)[eventName].findIndex(callBack);
|
|
124
|
+
index > -1 && __privateGet(this, _listeners)[eventName].splice(index, 1);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
Reflect.deleteProperty(__privateGet(this, _listeners), eventName);
|
|
128
|
+
}
|
|
129
|
+
_dispatchEvent(eventName, eventParams) {
|
|
130
|
+
if (Array.isArray(__privateGet(this, _listeners)[eventName])) {
|
|
131
|
+
__privateGet(this, _listeners)[eventName].forEach(
|
|
132
|
+
(callBack) => callBack(eventParams)
|
|
133
|
+
);
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
138
|
+
_dispatchMessageEvents(req, resp) {
|
|
139
|
+
let target = req._id;
|
|
140
|
+
if (Array.isArray(__privateGet(this, _listeners)[target])) {
|
|
141
|
+
__privateGet(this, _listeners)[target].forEach((listener) => {
|
|
142
|
+
try {
|
|
143
|
+
if (resp && Object.keys(resp).length === 1 && req.command !== LISTENER_CMDS.API) {
|
|
144
|
+
listener(Object.values(resp)[0]);
|
|
145
|
+
} else {
|
|
146
|
+
listener(resp);
|
|
147
|
+
}
|
|
148
|
+
} catch (err) {
|
|
149
|
+
console.error("Message callback error: ", err);
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
this._removeEventListener(target);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
_listeners = new WeakMap();
|
|
157
|
+
class BaseSDK extends EventBase {
|
|
158
|
+
_postMessageAsync(command, args, hasCallBack, callBack) {
|
|
159
|
+
return new Promise((resolve, reject) => {
|
|
160
|
+
const _id = generateId(command.toLowerCase());
|
|
161
|
+
postMessage({ _id, command, ...args });
|
|
162
|
+
globalInstances[_id] = this;
|
|
163
|
+
this._addEventListener(_id, async (data) => {
|
|
164
|
+
if (data == null ? void 0 : data.errorMessage) {
|
|
165
|
+
reject(data);
|
|
166
|
+
} else {
|
|
167
|
+
if (hasCallBack && callBack) {
|
|
168
|
+
data = await callBack(data);
|
|
169
|
+
}
|
|
170
|
+
resolve(data);
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
_postMessage(command, args, callBack) {
|
|
176
|
+
const _id = generateId(command.toLowerCase());
|
|
177
|
+
postMessage({ _id, command, ...args });
|
|
178
|
+
if (callBack) {
|
|
179
|
+
this._addEventListener(args.eventName, callBack);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
class Form extends BaseSDK {
|
|
184
|
+
constructor(instanceId) {
|
|
185
|
+
super();
|
|
186
|
+
this.type = "Form";
|
|
187
|
+
this.instanceId = instanceId;
|
|
188
|
+
}
|
|
189
|
+
toJSON() {
|
|
190
|
+
return this._postMessageAsync(LISTENER_CMDS.TO_JSON, {
|
|
191
|
+
instanceId: this.instanceId
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
getField(fieldId) {
|
|
195
|
+
return this._postMessageAsync(LISTENER_CMDS.GET_FORM_FIELD, {
|
|
196
|
+
instanceId: this.instanceId,
|
|
197
|
+
fieldId
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
updateField(args) {
|
|
201
|
+
return this._postMessageAsync(LISTENER_CMDS.UPDATE_FORM, {
|
|
202
|
+
data: args
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
getTable(tableId) {
|
|
206
|
+
return new Table(this.instanceId, tableId);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
class Table extends BaseSDK {
|
|
210
|
+
constructor(instanceId, tableId) {
|
|
211
|
+
super();
|
|
212
|
+
this.tableId = tableId;
|
|
213
|
+
this.instanceId = instanceId;
|
|
214
|
+
}
|
|
215
|
+
toJSON() {
|
|
216
|
+
return this._postMessageAsync(
|
|
217
|
+
LISTENER_CMDS.TO_JSON,
|
|
218
|
+
{
|
|
219
|
+
tableId: this.tableId
|
|
220
|
+
}
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
getRows() {
|
|
224
|
+
return this._postMessageAsync(
|
|
225
|
+
LISTENER_CMDS.GET_TABLE_ROWS,
|
|
226
|
+
{ tableId: this.tableId },
|
|
227
|
+
true,
|
|
228
|
+
(data) => {
|
|
229
|
+
return data.map((row) => new TableForm(this.instanceId, this.tableId, row.id));
|
|
230
|
+
}
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
getRow(rowId) {
|
|
234
|
+
return new TableForm(this.instanceId, this.tableId, rowId);
|
|
235
|
+
}
|
|
236
|
+
addRow(rowObject) {
|
|
237
|
+
return this._postMessageAsync(LISTENER_CMDS.ADD_TABLE_ROW, {
|
|
238
|
+
tableId: this.tableId,
|
|
239
|
+
rowObject
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
deleteRow(rowId) {
|
|
243
|
+
return this._postMessageAsync(LISTENER_CMDS.DELETE_TABLE_ROW, {
|
|
244
|
+
tableId: this.tableId,
|
|
245
|
+
rowId
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
class TableForm extends BaseSDK {
|
|
250
|
+
constructor(instanceId, tableId, rowId) {
|
|
251
|
+
super();
|
|
252
|
+
this.instanceId = instanceId;
|
|
253
|
+
this.type = "TabelForm";
|
|
254
|
+
this.tableId = tableId;
|
|
255
|
+
this.rowId = rowId;
|
|
256
|
+
}
|
|
257
|
+
getParent() {
|
|
258
|
+
return new Form(this.instanceId);
|
|
259
|
+
}
|
|
260
|
+
toJSON() {
|
|
261
|
+
return this._postMessageAsync(LISTENER_CMDS.TO_JSON, {
|
|
262
|
+
tableId: this.tableId,
|
|
263
|
+
rowId: this.rowId
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
getField(fieldId) {
|
|
267
|
+
return this._postMessageAsync(LISTENER_CMDS.GET_FORM_FIELD, {
|
|
268
|
+
instanceId: this.instanceId,
|
|
269
|
+
tableId: this.tableId,
|
|
270
|
+
rowId: this.rowId,
|
|
271
|
+
fieldId
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
updateField(args) {
|
|
275
|
+
return this._postMessageAsync(LISTENER_CMDS.UPDATE_FORM, {
|
|
276
|
+
instanceId: this.instanceId,
|
|
277
|
+
tableId: this.tableId,
|
|
278
|
+
rowId: this.rowId,
|
|
279
|
+
data: args
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
class Client extends BaseSDK {
|
|
284
|
+
showInfo(message) {
|
|
285
|
+
return super._postMessageAsync(LISTENER_CMDS.MESSAGE, { message });
|
|
286
|
+
}
|
|
287
|
+
showConfirm(args) {
|
|
288
|
+
return super._postMessageAsync(LISTENER_CMDS.CONFIRM, {
|
|
289
|
+
data: {
|
|
290
|
+
title: args.title,
|
|
291
|
+
content: args.content,
|
|
292
|
+
okText: args.okText || "Ok",
|
|
293
|
+
cancelText: args.cancelText || "Cancel"
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
redirect(url) {
|
|
298
|
+
return super._postMessageAsync(LISTENER_CMDS.REDIRECT, { url });
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
class Formatter extends BaseSDK {
|
|
302
|
+
toDate(date) {
|
|
303
|
+
return this._postMessageAsync(LISTENER_CMDS.FORMAT_DATE, {
|
|
304
|
+
date
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
toDateTime(date) {
|
|
308
|
+
return this._postMessageAsync(LISTENER_CMDS.FORMAT_DATE_TIME, {
|
|
309
|
+
date
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
toNumber(value) {
|
|
313
|
+
return this._postMessageAsync(LISTENER_CMDS.FORMAT_NUMBER, {
|
|
314
|
+
value
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
toCurrency(value, currencyCode) {
|
|
318
|
+
return this._postMessageAsync(LISTENER_CMDS.FORMAT_CURRENCY, {
|
|
319
|
+
value,
|
|
320
|
+
currencyCode
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
toBoolean(value) {
|
|
324
|
+
return this._postMessageAsync(LISTENER_CMDS.FORMAT_BOOLEAN, {
|
|
325
|
+
value
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
class NDEFReader extends BaseSDK {
|
|
330
|
+
constructor() {
|
|
331
|
+
super();
|
|
332
|
+
this.id = generateId(LISTENER_CMDS.WINDOW_NDEF_READER_NEW);
|
|
333
|
+
globalInstances[this.id] = this;
|
|
334
|
+
this._postMessage(
|
|
335
|
+
LISTENER_CMDS.WINDOW_NDEF_READER_NEW,
|
|
336
|
+
{
|
|
337
|
+
id: this.id,
|
|
338
|
+
operation: "new"
|
|
339
|
+
},
|
|
340
|
+
(data) => {
|
|
341
|
+
}
|
|
342
|
+
);
|
|
343
|
+
}
|
|
344
|
+
scan() {
|
|
345
|
+
return new Promise((resolve, reject) => {
|
|
346
|
+
this._postMessage(
|
|
347
|
+
LISTENER_CMDS.WINDOW_NDEF_READER_SCAN,
|
|
348
|
+
{ id: this.id, operation: "scan" },
|
|
349
|
+
({ data, err }) => {
|
|
350
|
+
console.log("scan data from main window ", data);
|
|
351
|
+
resolve(data);
|
|
352
|
+
}
|
|
353
|
+
);
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
write(data) {
|
|
357
|
+
return new Promise((resolve, reject) => {
|
|
358
|
+
this._postMessage(
|
|
359
|
+
LISTENER_CMDS.WINDOW_NDEF_READER_WRITE,
|
|
360
|
+
{ id: this.id, operation: "write", data },
|
|
361
|
+
({ data: data2, err }) => {
|
|
362
|
+
}
|
|
363
|
+
);
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
addEventListener(eventName, cb) {
|
|
367
|
+
this._postMessage(
|
|
368
|
+
LISTENER_CMDS.WINDOW_NDEF_READER_ADD_EVENT_LISTENER,
|
|
369
|
+
{
|
|
370
|
+
id: this.id,
|
|
371
|
+
operation: "addEventListener",
|
|
372
|
+
eventName
|
|
373
|
+
},
|
|
374
|
+
() => {
|
|
375
|
+
}
|
|
376
|
+
);
|
|
377
|
+
}
|
|
378
|
+
makeReadOnly() {
|
|
379
|
+
return new Promise((resolve, reject) => {
|
|
380
|
+
this._postMessage(
|
|
381
|
+
LISTENER_CMDS.WINDOW_NDEF_READER_MAKE_READONLY,
|
|
382
|
+
{ id: this.id, operation: "makeReadOnly" },
|
|
383
|
+
({ data, err }) => {
|
|
384
|
+
}
|
|
385
|
+
);
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
abortScan() {
|
|
389
|
+
return new Promise((resolve, reject) => {
|
|
390
|
+
this._postMessage(
|
|
391
|
+
LISTENER_CMDS.WINDOW_NDEF_READER_ABORT_SCAN,
|
|
392
|
+
{ id: this.id, operation: "abortScan" },
|
|
393
|
+
({ data, err }) => {
|
|
394
|
+
}
|
|
395
|
+
);
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
const window = {
|
|
400
|
+
NDEFReader
|
|
401
|
+
};
|
|
402
|
+
class NocodeSDK extends BaseSDK {
|
|
403
|
+
constructor(props) {
|
|
404
|
+
super();
|
|
405
|
+
__privateAdd(this, _csrfToken, void 0);
|
|
406
|
+
if (props.tableId && props.tableRowId) {
|
|
407
|
+
this.context = new TableForm(
|
|
408
|
+
props.formInstanceId,
|
|
409
|
+
props.tableId,
|
|
410
|
+
props.tableRowId
|
|
411
|
+
);
|
|
412
|
+
} else if (props.formInstanceId) {
|
|
413
|
+
this.context = new Form(props.formInstanceId);
|
|
414
|
+
}
|
|
415
|
+
this.client = new Client();
|
|
416
|
+
this.formatter = new Formatter();
|
|
417
|
+
this.user = props.user;
|
|
418
|
+
this.account = props.account;
|
|
419
|
+
__privateSet(this, _csrfToken, props.csrfToken);
|
|
420
|
+
}
|
|
421
|
+
async api(url, args) {
|
|
422
|
+
const response = await globalThis.fetch(url, {
|
|
423
|
+
...args,
|
|
424
|
+
headers: {
|
|
425
|
+
...(args == null ? void 0 : args.headers) || {},
|
|
426
|
+
"X-Csrf-Token": __privateGet(this, _csrfToken)
|
|
427
|
+
}
|
|
428
|
+
});
|
|
429
|
+
const contentType = response.headers.get("content-type");
|
|
430
|
+
if (contentType && contentType.includes("application/json")) {
|
|
431
|
+
return await response.json();
|
|
432
|
+
} else {
|
|
433
|
+
return response;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
_csrfToken = new WeakMap();
|
|
438
|
+
function initSDK(config) {
|
|
439
|
+
return new NocodeSDK(config);
|
|
440
|
+
}
|
|
441
|
+
export { initSDK as default, window };
|
package/dist/nocode.d.ts
ADDED
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
declare module "core/constants" {
|
|
2
|
+
export const LISTENER_CMDS: {
|
|
3
|
+
API: string;
|
|
4
|
+
GET_CONTEXT: string;
|
|
5
|
+
RETURN: string;
|
|
6
|
+
GET_FORM_FIELD: string;
|
|
7
|
+
UPDATE_FORM: string;
|
|
8
|
+
GET_TABLE: string;
|
|
9
|
+
GET_TABLE_ROW: string;
|
|
10
|
+
ADD_TABLE_ROW: string;
|
|
11
|
+
DELETE_TABLE_ROW: string;
|
|
12
|
+
TO_JSON: string;
|
|
13
|
+
GET_TABLE_ROWS: string;
|
|
14
|
+
MESSAGE: string;
|
|
15
|
+
CONFIRM: string;
|
|
16
|
+
ALERT: string;
|
|
17
|
+
REDIRECT: string;
|
|
18
|
+
OPEN_PAGE: string;
|
|
19
|
+
FORMAT_DATE: string;
|
|
20
|
+
FORMAT_DATE_TIME: string;
|
|
21
|
+
FORMAT_NUMBER: string;
|
|
22
|
+
FORMAT_CURRENCY: string;
|
|
23
|
+
FORMAT_BOOLEAN: string;
|
|
24
|
+
GET_APP_VARIABLE: string;
|
|
25
|
+
SET_APP_VARIABLE: string;
|
|
26
|
+
GET_PAGE_VARIABLE: string;
|
|
27
|
+
SET_PAGE_VARIABLE: string;
|
|
28
|
+
GET_PAGE_PARAMS: string;
|
|
29
|
+
GET_ALL_PAGE_PARAMS: string;
|
|
30
|
+
PAGE_ON_CLOSE: string;
|
|
31
|
+
OPEN_POPUP: string;
|
|
32
|
+
GET_POPUP_PARAMS: string;
|
|
33
|
+
GET_ALL_POPUP_PARAMS: string;
|
|
34
|
+
CLOSE_POPUP: string;
|
|
35
|
+
COMPONENT_GET: string;
|
|
36
|
+
COMPONENT_REFRESH: string;
|
|
37
|
+
COMPONENT_SHOW: string;
|
|
38
|
+
COMPONENT_HIDE: string;
|
|
39
|
+
COMPONENT_ADD_EVENT_LISTENER: string;
|
|
40
|
+
CC_INITIALIZE: string;
|
|
41
|
+
CC_WATCH_PARAMS: string;
|
|
42
|
+
WINDOW_NDEF_READER_NEW: string;
|
|
43
|
+
WINDOW_NDEF_READER_SCAN: string;
|
|
44
|
+
WINDOW_NDEF_READER_WRITE: string;
|
|
45
|
+
WINDOW_NDEF_READER_ADD_EVENT_LISTENER: string;
|
|
46
|
+
WINDOW_NDEF_READER_MAKE_READONLY: string;
|
|
47
|
+
WINDOW_NDEF_READER_ABORT_SCAN: string;
|
|
48
|
+
};
|
|
49
|
+
export const EVENT_TYPES: {
|
|
50
|
+
COMPONENT_ON_MOUNT: string;
|
|
51
|
+
CC_ON_PARAMS_CHANGE: string;
|
|
52
|
+
};
|
|
53
|
+
export const DEFAULTS: {
|
|
54
|
+
POPUP_ID: string;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
declare module "core/index" {
|
|
58
|
+
export function generateId(prefix?: string): string;
|
|
59
|
+
export const globalInstances: {};
|
|
60
|
+
export class EventBase {
|
|
61
|
+
#private;
|
|
62
|
+
constructor();
|
|
63
|
+
_addEventListener(eventName: string, callBack: Function): void;
|
|
64
|
+
_removeEventListener(eventName: string, callBack?: any): void;
|
|
65
|
+
_dispatchEvent(eventName: string, eventParams: object): boolean;
|
|
66
|
+
_dispatchMessageEvents(req: any, resp: any): void;
|
|
67
|
+
}
|
|
68
|
+
export class BaseSDK extends EventBase {
|
|
69
|
+
_postMessageAsync(command: string, args: any, hasCallBack?: boolean, callBack?: (data: any) => {}): object | string | any;
|
|
70
|
+
_postMessage(command: string, args: any, callBack?: any): void;
|
|
71
|
+
}
|
|
72
|
+
export * from "core/constants";
|
|
73
|
+
}
|
|
74
|
+
declare module "form/index" {
|
|
75
|
+
import { BaseSDK } from "core/index";
|
|
76
|
+
export class Form extends BaseSDK {
|
|
77
|
+
private instanceId;
|
|
78
|
+
type: string;
|
|
79
|
+
constructor(instanceId: string);
|
|
80
|
+
toJSON(): any;
|
|
81
|
+
getField(fieldId: string): any;
|
|
82
|
+
updateField(args: object): any;
|
|
83
|
+
getTable(tableId: string): Table;
|
|
84
|
+
}
|
|
85
|
+
class Table extends BaseSDK {
|
|
86
|
+
private tableId;
|
|
87
|
+
private instanceId;
|
|
88
|
+
constructor(instanceId: string, tableId: string);
|
|
89
|
+
toJSON(): any;
|
|
90
|
+
getRows(): TableForm[];
|
|
91
|
+
getRow(rowId: string): TableForm;
|
|
92
|
+
addRow(rowObject: object): any;
|
|
93
|
+
deleteRow(rowId: string): any;
|
|
94
|
+
}
|
|
95
|
+
export class TableForm extends BaseSDK {
|
|
96
|
+
private instanceId;
|
|
97
|
+
private tableId;
|
|
98
|
+
private rowId;
|
|
99
|
+
type: string;
|
|
100
|
+
constructor(instanceId: string, tableId: string, rowId: string);
|
|
101
|
+
getParent(): Form;
|
|
102
|
+
toJSON(): any;
|
|
103
|
+
getField(fieldId: string): any;
|
|
104
|
+
updateField(args: object): any;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
declare module "utils/client" {
|
|
108
|
+
import { BaseSDK } from "core/index";
|
|
109
|
+
export class Client extends BaseSDK {
|
|
110
|
+
showInfo(message: string): any;
|
|
111
|
+
showConfirm(args: {
|
|
112
|
+
title: string;
|
|
113
|
+
content: string;
|
|
114
|
+
okText: string;
|
|
115
|
+
cancelText: string;
|
|
116
|
+
}): any;
|
|
117
|
+
redirect(url: string): any;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
declare module "utils/formatter" {
|
|
121
|
+
import { BaseSDK } from "core/index";
|
|
122
|
+
export class Formatter extends BaseSDK {
|
|
123
|
+
toDate(date: string): any;
|
|
124
|
+
toDateTime(date: string): any;
|
|
125
|
+
toNumber(value: string): any;
|
|
126
|
+
toCurrency(value: string, currencyCode: string): any;
|
|
127
|
+
toBoolean(value: string): any;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
declare module "utils/index" {
|
|
131
|
+
export * from "utils/client";
|
|
132
|
+
export * from "utils/formatter";
|
|
133
|
+
}
|
|
134
|
+
declare module "window/NDEFReader" {
|
|
135
|
+
import { BaseSDK } from "core/index";
|
|
136
|
+
export class NDEFReader extends BaseSDK {
|
|
137
|
+
id: string;
|
|
138
|
+
constructor();
|
|
139
|
+
scan(): Promise<unknown>;
|
|
140
|
+
write(data: any): Promise<unknown>;
|
|
141
|
+
addEventListener(eventName: string, cb: Function): void;
|
|
142
|
+
makeReadOnly(): Promise<unknown>;
|
|
143
|
+
abortScan(): Promise<unknown>;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
declare module "window/index" {
|
|
147
|
+
import { NDEFReader } from "window/NDEFReader";
|
|
148
|
+
export const window: {
|
|
149
|
+
NDEFReader: typeof NDEFReader;
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
declare module "types/external" {
|
|
153
|
+
export type userObject = {
|
|
154
|
+
_id: string;
|
|
155
|
+
Name: string;
|
|
156
|
+
Email: string;
|
|
157
|
+
UserType: string;
|
|
158
|
+
Role: string;
|
|
159
|
+
};
|
|
160
|
+
export type accountObject = {
|
|
161
|
+
_id: string;
|
|
162
|
+
};
|
|
163
|
+
export type environmentObject = {
|
|
164
|
+
isMobile: boolean;
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
declare module "types/internal" {
|
|
168
|
+
import { userObject, accountObject, environmentObject } from "types/external";
|
|
169
|
+
export interface SDKContext {
|
|
170
|
+
formInstanceId: string;
|
|
171
|
+
tableId: string;
|
|
172
|
+
tableRowId: string;
|
|
173
|
+
componentId: string;
|
|
174
|
+
componentMethods?: componentMethodsType[];
|
|
175
|
+
appId: string;
|
|
176
|
+
pageId: string;
|
|
177
|
+
popupId: string;
|
|
178
|
+
user: userObject;
|
|
179
|
+
account: accountObject;
|
|
180
|
+
csrfToken: string;
|
|
181
|
+
envDetails: environmentObject;
|
|
182
|
+
}
|
|
183
|
+
export interface componentMethodsType {
|
|
184
|
+
name: string;
|
|
185
|
+
returnType?: string;
|
|
186
|
+
parameters?: string[];
|
|
187
|
+
}
|
|
188
|
+
export interface ComponentProps {
|
|
189
|
+
componentId: string;
|
|
190
|
+
componentMethods?: componentMethodsType[];
|
|
191
|
+
}
|
|
192
|
+
export interface AppContext {
|
|
193
|
+
appId: string;
|
|
194
|
+
pageId: string;
|
|
195
|
+
}
|
|
196
|
+
export interface PageContext {
|
|
197
|
+
pageId: string;
|
|
198
|
+
}
|
|
199
|
+
export interface PopupContext {
|
|
200
|
+
popupId?: string;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
declare module "nocode" {
|
|
204
|
+
import { BaseSDK } from "core/index";
|
|
205
|
+
import { Form, TableForm } from "form/index";
|
|
206
|
+
import { Client, Formatter } from "utils/index";
|
|
207
|
+
import { window } from "window/index";
|
|
208
|
+
import { SDKContext } from "types/internal";
|
|
209
|
+
import { userObject, accountObject } from "types/external";
|
|
210
|
+
class NocodeSDK extends BaseSDK {
|
|
211
|
+
#private;
|
|
212
|
+
context: Form | TableForm;
|
|
213
|
+
client: Client;
|
|
214
|
+
formatter: Formatter;
|
|
215
|
+
user: userObject;
|
|
216
|
+
account: accountObject;
|
|
217
|
+
constructor(props: SDKContext);
|
|
218
|
+
api(url: string, args?: {
|
|
219
|
+
headers: object;
|
|
220
|
+
}): Promise<any>;
|
|
221
|
+
}
|
|
222
|
+
function initSDK(config: SDKContext): NocodeSDK;
|
|
223
|
+
export { window, initSDK as default };
|
|
224
|
+
}
|
|
225
|
+
declare module "app/component" {
|
|
226
|
+
import { BaseSDK } from "core/index";
|
|
227
|
+
import { ComponentProps } from "types/internal";
|
|
228
|
+
export class Component extends BaseSDK {
|
|
229
|
+
#private;
|
|
230
|
+
_id: string;
|
|
231
|
+
type: string;
|
|
232
|
+
constructor(props: ComponentProps);
|
|
233
|
+
onMount(callback: Function): void;
|
|
234
|
+
refresh(): any;
|
|
235
|
+
show(): any;
|
|
236
|
+
hide(): any;
|
|
237
|
+
}
|
|
238
|
+
export class CustomComponent extends BaseSDK {
|
|
239
|
+
type: string;
|
|
240
|
+
_id: string;
|
|
241
|
+
constructor(id: any);
|
|
242
|
+
watchParams(callBack: (data: any) => any): void;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
declare module "app/popup" {
|
|
246
|
+
import { BaseSDK } from "core/index";
|
|
247
|
+
import { Component } from "app/component";
|
|
248
|
+
import { PopupContext } from "types/internal";
|
|
249
|
+
export class Popup extends BaseSDK {
|
|
250
|
+
_id: string;
|
|
251
|
+
type: string;
|
|
252
|
+
constructor(props: PopupContext);
|
|
253
|
+
getParameter(key: string): any;
|
|
254
|
+
getAllParameters(): any;
|
|
255
|
+
close(): any;
|
|
256
|
+
getComponent(componentId: string): Component;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
declare module "app/page" {
|
|
260
|
+
import { BaseSDK } from "core/index";
|
|
261
|
+
import { Component } from "app/component";
|
|
262
|
+
import { Popup } from "app/popup";
|
|
263
|
+
import { PageContext } from "types/internal";
|
|
264
|
+
export class Page extends BaseSDK {
|
|
265
|
+
_id: string;
|
|
266
|
+
popup: Popup;
|
|
267
|
+
type: string;
|
|
268
|
+
constructor(props: PageContext);
|
|
269
|
+
getParameter(key: string): any;
|
|
270
|
+
getAllParameters(): any;
|
|
271
|
+
getVariable(key: string): any;
|
|
272
|
+
setVariable(key: string, value: any): any;
|
|
273
|
+
openPopup(popupId: string, popupParams: object): any;
|
|
274
|
+
getComponent(componentId: string): Component;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
declare module "app/index" {
|
|
278
|
+
import { BaseSDK } from "core/index";
|
|
279
|
+
import { Page } from "app/page";
|
|
280
|
+
import { AppContext } from "types/internal";
|
|
281
|
+
export class Application extends BaseSDK {
|
|
282
|
+
page: Page;
|
|
283
|
+
_id: string;
|
|
284
|
+
constructor(props: AppContext);
|
|
285
|
+
getVariable(key: string): any;
|
|
286
|
+
setVariable(key: string | object, value?: any): any;
|
|
287
|
+
openPage(pageId: string, pageParams: object): any;
|
|
288
|
+
}
|
|
289
|
+
export * from "app/component";
|
|
290
|
+
export { Page };
|
|
291
|
+
export * from "app/popup";
|
|
292
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
|
|
2
|
+
declare class Form {
|
|
3
|
+
type: string
|
|
4
|
+
toJSON(): any;
|
|
5
|
+
getField(fieldId: string): any;
|
|
6
|
+
updateField(args: object): any;
|
|
7
|
+
getTable(tableId: string): Table;
|
|
8
|
+
}
|
|
9
|
+
declare class Table {
|
|
10
|
+
toJSON(): any;
|
|
11
|
+
getRows(): TableForm[];
|
|
12
|
+
getRow(rowId: string): TableForm;
|
|
13
|
+
addRow(rowObject: object): any;
|
|
14
|
+
deleteRow(rowId: string): any;
|
|
15
|
+
}
|
|
16
|
+
declare class TableForm {
|
|
17
|
+
type: string
|
|
18
|
+
getParent(): Form;
|
|
19
|
+
toJSON(): any;
|
|
20
|
+
getField(fieldId: string): any;
|
|
21
|
+
updateField(args: object): any;
|
|
22
|
+
}
|
|
23
|
+
declare class Client {
|
|
24
|
+
showInfo(message: string): any;
|
|
25
|
+
showConfirm(args: {
|
|
26
|
+
title: string;
|
|
27
|
+
content: string;
|
|
28
|
+
okText: string;
|
|
29
|
+
cancelText: string;
|
|
30
|
+
}): any;
|
|
31
|
+
redirect(url: string): any;
|
|
32
|
+
}
|
|
33
|
+
declare class Formatter {
|
|
34
|
+
toDate(date: string): any;
|
|
35
|
+
toDateTime(date: string): any;
|
|
36
|
+
toNumber(value: string): any;
|
|
37
|
+
toCurrency(value: string, currencyCode: string): any;
|
|
38
|
+
toBoolean(value: string): any;
|
|
39
|
+
}
|
|
40
|
+
declare class kf {
|
|
41
|
+
static context: Form
|
|
42
|
+
static client: Client
|
|
43
|
+
static formatter: Formatter
|
|
44
|
+
static user: userObject
|
|
45
|
+
static account: accountObject
|
|
46
|
+
api(url: string, args?: {
|
|
47
|
+
headers: object;
|
|
48
|
+
}): Promise<any>;
|
|
49
|
+
}
|
|
50
|
+
declare type userObject = {
|
|
51
|
+
_id: string;
|
|
52
|
+
Name: string;
|
|
53
|
+
Email: string;
|
|
54
|
+
UserType: string;
|
|
55
|
+
Role: string;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
declare type accountObject = {
|
|
59
|
+
_id: string;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
declare type environmentObject = {
|
|
63
|
+
isMobile: boolean
|
|
64
|
+
}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
{
|
|
2
|
+
"lowcode": [
|
|
3
|
+
{
|
|
4
|
+
"label": "get app variable",
|
|
5
|
+
"documentation": "Get variable value from global app scope",
|
|
6
|
+
"insertText": "let variableName = await kf.app.getVariable(\"${1:variableId}\")"
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"label": "set app variable",
|
|
10
|
+
"documentation": "Sets variable to new value in global app scope",
|
|
11
|
+
"insertText": "kf.app.setVariable(\"${1:variableId}\", \"${2:newValue}\")"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"label": "open or navigate page",
|
|
15
|
+
"documentation": "Navigate to another page\nRemove 2nd args if you dont have any input parameters to page",
|
|
16
|
+
"insertText": "kf.app.openPage(\"${1:pageId}\", { inputParam1: \"value1\" })"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"label": "get local(page) variable",
|
|
20
|
+
"documentation": "Get variable value from page scope",
|
|
21
|
+
"insertText": "let variableName = await kf.app.page.getVariable(\"${1:variableId}\")"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"label": "set local(page) variable",
|
|
25
|
+
"documentation": "Sets specified variable to new value in page scope",
|
|
26
|
+
"insertText": "kf.app.page.setVariable(\"${1:variableId}\", \"${2:newValue}\")"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"label": "get input parameter",
|
|
30
|
+
"documentation": "Get specific input parameter of the page",
|
|
31
|
+
"insertText": "let value = await kf.app.page.getParameter(\"${1:parameterId}\"); "
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"label": "get all input parameters",
|
|
35
|
+
"documentation": "Get all input parameters in the page",
|
|
36
|
+
"insertText": "let allParams = await kf.app.page.getAllParameters();"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"label": "open a popup",
|
|
40
|
+
"documentation": "Opens a popup in the page",
|
|
41
|
+
"insertText": "// remove 2nd argument if popup doesnt have any popup params\nkf.app.page.openPopup(\"${1:popupId}\", { popupParam1: \"value\" });"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"label": "get component in page",
|
|
45
|
+
"documentation": "Get instance of the components inside the page",
|
|
46
|
+
"insertText": "let componentInstance = await kf.app.page.getComponent(\"${1:componentId}\")"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"label": "refresh the component",
|
|
50
|
+
"documentation": "Refreshes the component",
|
|
51
|
+
"insertText": "componentInstance.refresh()"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"label": "hide the component",
|
|
55
|
+
"documentation": "Hides the component from page",
|
|
56
|
+
"insertText": "componentInstance.hide()"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"label": "show the component",
|
|
60
|
+
"documentation": "Shows the hidden component from page",
|
|
61
|
+
"insertText": "componentInstance.show()"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"label": "set active tab (only for tab component)",
|
|
65
|
+
"documentation": "Sets the specified tab index as active",
|
|
66
|
+
"insertText": "// sets 2nd tab as active\ncomponentInstance.setActiveTab(${1:2})"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"label": "get popup parameter",
|
|
70
|
+
"documentation": "Get specific parameter in the popup",
|
|
71
|
+
"insertText": "let value = await kf.app.page.popup.getParameter(\"${1:parameterId}\"); "
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"label": "get all popup parameters",
|
|
75
|
+
"documentation": "Get all parameters in the popup",
|
|
76
|
+
"insertText": "// returns all popup parameters as object\nlet allParams = await kf.app.page.popup.getAllParameters();"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"label": "close active popup",
|
|
80
|
+
"insertText": "kf.app.page.popup.close()"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"label": "get instance id",
|
|
84
|
+
"documentation": "Get the instance id from event arguments",
|
|
85
|
+
"insertText": "kf.eventParameters._id"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"label": "get activity instance id",
|
|
89
|
+
"documentation": "Get the activity instance id from event arguments",
|
|
90
|
+
"insertText": "kf.eventParameters._activity_instance_id"
|
|
91
|
+
}
|
|
92
|
+
],
|
|
93
|
+
"nocode": [
|
|
94
|
+
{
|
|
95
|
+
"label": "get field value",
|
|
96
|
+
"documentation": "Get value of a field in form",
|
|
97
|
+
"insertText": "let fieldValue = await kf.context.getField(\"${1:fieldId}\");"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"label": "set field value",
|
|
101
|
+
"documentation": "Set value of a field in form",
|
|
102
|
+
"insertText": "kf.context.updateField({\"${1:fieldId}\": \"${2:value}\"});"
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"label": "set field value - bulk",
|
|
106
|
+
"documentation": "Set value of a field in form",
|
|
107
|
+
"insertText": "let payload = { \"fieldId\": \"value\", \"fieldId2\": \"value2\" };\nkf.context.updateField(payload);"
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"label": "get form json",
|
|
111
|
+
"documentation": "Returns whole data of current form in json format",
|
|
112
|
+
"insertText": "let formJSON = await kf.context.getJSON();"
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"label": "get table instance",
|
|
116
|
+
"documentation": "Get instance of table, which can be further used to add or delete rows",
|
|
117
|
+
"insertText": "let tableInstance = kf.context.getTable(\"${1:tableId}\");"
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
"label": "add a row in table",
|
|
121
|
+
"documentation": "Appends a row entry to table",
|
|
122
|
+
"insertText": "let rowDetails = { \"columnId1\": \"value1\", \"columnId2\": \"value2\" };\ntableInstance.addRow(rowDetails)"
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"label": "get table row",
|
|
126
|
+
"documentation": "Returns all columns with values in specified row",
|
|
127
|
+
"insertText": "tableInstance.getRow(\"${1:rowId}\")"
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
"label": "get table json",
|
|
131
|
+
"documentation": "Returns all rows & columns data inside table in json format",
|
|
132
|
+
"insertText": "let tableJSON = await kf.context.getJSON();"
|
|
133
|
+
}
|
|
134
|
+
],
|
|
135
|
+
"common": [
|
|
136
|
+
{
|
|
137
|
+
"label": "showinfo",
|
|
138
|
+
"documentation": "Shows toast information",
|
|
139
|
+
"insertText": "kf.client.showInfo(\"${1:message}\")"
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
"label": "api call",
|
|
143
|
+
"documentation": "Makes an API call to any kissflow rest api end points",
|
|
144
|
+
"insertText": "kf.api(`/${1:url}`)\n.then((resp) => {${2}})\n.catch((err) => {${3}})"
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
"label": "get account id",
|
|
148
|
+
"documentation": "Retrieves the acccount id",
|
|
149
|
+
"insertText": "kf.account._id"
|
|
150
|
+
},
|
|
151
|
+
|
|
152
|
+
{
|
|
153
|
+
"label": "get dataform item",
|
|
154
|
+
"documentation": "Api call to get dataform item",
|
|
155
|
+
"insertText": "kf.api(`/form/2/${kf.account._id}/${1:formId}/${2:instanceId}`)\n.then((resp) => {${3}})\n.catch((err) => {${4}})"
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
"label": "update dataform item",
|
|
159
|
+
"documentation": "Api call to update dataform item",
|
|
160
|
+
"insertText": "let payload = {};\nkf.api(`/form/2/${kf.account._id}/${1:formId}/${2:instanceId}`, {\n\tmethod: \"POST\",\n\tbody: JSON.stringify(payload)\n})\n.then((resp) => {${4}})\n.catch((err) => {${5}})"
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
"label": "delete dataform item",
|
|
164
|
+
"documentation": "Api call to delete dataform item",
|
|
165
|
+
"insertText": "let payload = {};\nkf.api(`/form/2/${kf.account._id}/${1:formId}/${2:instanceId}`, { method: \"DELETE\" })\n.then((resp) => {${3}})\n.catch((err) => {${4}})"
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
"label": "create new dataform item",
|
|
169
|
+
"documentation": "Api call to create new dataform item",
|
|
170
|
+
"insertText": "let payload = {};\nkf.api(`/form/2/${kf.account._id}/${1:formId}/`,{\n\tmethod: \"POST\",\n\tbody: JSON.stringify(payload)\n})\n.then((resp) => {${2}})\n.catch((err) => {${3}})"
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
"label": "create new case item",
|
|
174
|
+
"documentation": "Api call to create new case item",
|
|
175
|
+
"insertText": "let payload = {};\nkf.api(`/case/2/${kf.account._id}/${1:caseId}/`, {\n\tmethod: \"POST\",\n\tbody: JSON.stringify(payload)\n})\n.then((resp) => {${2}})\n.catch((err) => {${3}})"
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
"label": "create new process item",
|
|
179
|
+
"documentation": "Api call to create new process item",
|
|
180
|
+
"insertText": "let payload = {}:\nkf.api(`/process/2/${kf.account._id}/${1:processId}/`, {\n\tmethod: \"POST\",\n\tbody: JSON.stringify(payload)\n})\n.then((resp) => {${2}})\n.catch((err) => {${3}})"
|
|
181
|
+
}
|
|
182
|
+
]
|
|
183
|
+
}
|
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.14-beta",
|
|
4
4
|
"description": "JavaScript SDK for developing over the Kissflow lowcode platform",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"require": "./dist/kfsdk.umd.js"
|
|
15
15
|
},
|
|
16
16
|
"./lowcode": {
|
|
17
|
-
"import": "./dist/
|
|
17
|
+
"import": "./dist/kf.lowcodeworkersdk.es.js"
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
"repository": {
|
|
File without changes
|
|
File without changes
|