@kissflow/lowcode-client-sdk 1.0.1 → 1.0.2-1.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 +392 -95
- package/dist/index.d.ts +263 -76
- package/dist/kf.lowcodeworkersdk.es.js +665 -0
- package/dist/kf.nocodeworkersdk.es.js +455 -0
- package/dist/kfsdk.es.js +483 -0
- package/dist/kfsdk.umd.js +1 -0
- package/dist/lowcode.d.ts +319 -0
- package/dist/lowcode.types.d.ts +106 -0
- package/dist/nocode.d.ts +316 -0
- package/dist/nocode.types.d.ts +65 -0
- package/dist/snippets.json +193 -0
- package/dist/worker.js +40 -0
- package/package.json +44 -39
- package/custom.build.js +0 -79
- package/dist/app.js +0 -48
- package/dist/base.js +0 -171
- package/dist/client.js +0 -44
- package/dist/component.js +0 -35
- package/dist/constants.js +0 -40
- package/dist/form.js +0 -44
- package/dist/formatter.js +0 -54
- package/dist/global.types.d.ts +0 -54
- package/dist/index.html +0 -23
- package/dist/index.js +0 -7
- package/dist/kflowcode.sdk.js +0 -822
- package/dist/kflowcode.sdk.js.map +0 -1
- package/dist/kflowcode.sdk.module.js +0 -808
- package/dist/kflowcode.sdk.module.js.map +0 -1
- package/dist/lowcode.sdk.js +0 -56
- package/dist/page.js +0 -62
- package/id +0 -55
- package/index.html +0 -23
- package/src/app.ts +0 -31
- package/src/base.ts +0 -109
- package/src/client.ts +0 -28
- package/src/component.ts +0 -15
- package/src/constants.ts +0 -45
- package/src/form.ts +0 -21
- package/src/formatter.ts +0 -35
- package/src/index.ts +0 -7
- package/src/lowcode.sdk.ts +0 -41
- package/src/page.ts +0 -51
- 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 -63
package/dist/nocode.d.ts
ADDED
|
@@ -0,0 +1,316 @@
|
|
|
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
|
+
ADD_TABLE_ROWS: string;
|
|
12
|
+
DELETE_TABLE_ROW: string;
|
|
13
|
+
TO_JSON: string;
|
|
14
|
+
GET_TABLE_ROWS: string;
|
|
15
|
+
MESSAGE: string;
|
|
16
|
+
CONFIRM: string;
|
|
17
|
+
ALERT: string;
|
|
18
|
+
REDIRECT: string;
|
|
19
|
+
OPEN_PAGE: string;
|
|
20
|
+
FORMAT_DATE: string;
|
|
21
|
+
FORMAT_DATE_TIME: string;
|
|
22
|
+
FORMAT_NUMBER: string;
|
|
23
|
+
FORMAT_CURRENCY: string;
|
|
24
|
+
FORMAT_BOOLEAN: string;
|
|
25
|
+
GET_APP_VARIABLE: string;
|
|
26
|
+
SET_APP_VARIABLE: string;
|
|
27
|
+
GET_PAGE_VARIABLE: string;
|
|
28
|
+
SET_PAGE_VARIABLE: string;
|
|
29
|
+
GET_PAGE_PARAMS: string;
|
|
30
|
+
GET_ALL_PAGE_PARAMS: string;
|
|
31
|
+
PAGE_ON_CLOSE: string;
|
|
32
|
+
OPEN_POPUP: string;
|
|
33
|
+
GET_POPUP_PARAMS: string;
|
|
34
|
+
GET_ALL_POPUP_PARAMS: string;
|
|
35
|
+
CLOSE_POPUP: string;
|
|
36
|
+
COMPONENT_GET: string;
|
|
37
|
+
COMPONENT_REFRESH: string;
|
|
38
|
+
COMPONENT_SHOW: string;
|
|
39
|
+
COMPONENT_HIDE: string;
|
|
40
|
+
COMPONENT_ADD_EVENT_LISTENER: string;
|
|
41
|
+
CC_INITIALIZE: string;
|
|
42
|
+
CC_WATCH_PARAMS: string;
|
|
43
|
+
WINDOW_NDEF_READER_NEW: string;
|
|
44
|
+
WINDOW_NDEF_READER_SCAN: string;
|
|
45
|
+
WINDOW_NDEF_READER_WRITE: string;
|
|
46
|
+
WINDOW_NDEF_READER_ADD_EVENT_LISTENER: string;
|
|
47
|
+
WINDOW_NDEF_READER_MAKE_READONLY: string;
|
|
48
|
+
WINDOW_NDEF_READER_ABORT_SCAN: string;
|
|
49
|
+
DECISION_TABLE_EXECUTE: string;
|
|
50
|
+
DATAFORM_IMPORT_CSV: string;
|
|
51
|
+
};
|
|
52
|
+
export const EVENT_TYPES: {
|
|
53
|
+
COMPONENT_ON_MOUNT: string;
|
|
54
|
+
CC_ON_PARAMS_CHANGE: string;
|
|
55
|
+
};
|
|
56
|
+
export const DEFAULTS: {
|
|
57
|
+
POPUP_ID: string;
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
declare module "core/index" {
|
|
61
|
+
export function generateId(prefix?: string): string;
|
|
62
|
+
export const globalInstances: {};
|
|
63
|
+
export class EventBase {
|
|
64
|
+
#private;
|
|
65
|
+
constructor();
|
|
66
|
+
_addEventListener(eventName: string, callBack: Function): void;
|
|
67
|
+
_removeEventListener(eventName: string, callBack?: any): void;
|
|
68
|
+
_dispatchEvent(eventName: string, eventParams: object): boolean;
|
|
69
|
+
_dispatchMessageEvents(req: any, resp: any): void;
|
|
70
|
+
}
|
|
71
|
+
export class BaseSDK extends EventBase {
|
|
72
|
+
_postMessageAsync(command: string, args: any, hasCallBack?: boolean, callBack?: (data: any) => {}): object | string | any;
|
|
73
|
+
_postMessage(command: string, args: any, callBack?: any): void;
|
|
74
|
+
}
|
|
75
|
+
export * from "core/constants";
|
|
76
|
+
}
|
|
77
|
+
declare module "form/index" {
|
|
78
|
+
import { BaseSDK } from "core/index";
|
|
79
|
+
export class Form extends BaseSDK {
|
|
80
|
+
private instanceId;
|
|
81
|
+
type: string;
|
|
82
|
+
constructor(instanceId: string);
|
|
83
|
+
toJSON(): any;
|
|
84
|
+
getField(fieldId: string): any;
|
|
85
|
+
updateField(args: object): any;
|
|
86
|
+
getTable(tableId: string): Table;
|
|
87
|
+
}
|
|
88
|
+
class Table extends BaseSDK {
|
|
89
|
+
private tableId;
|
|
90
|
+
private instanceId;
|
|
91
|
+
constructor(instanceId: string, tableId: string);
|
|
92
|
+
toJSON(): any;
|
|
93
|
+
getRows(): TableForm[];
|
|
94
|
+
getRow(rowId: string): TableForm;
|
|
95
|
+
addRow(rowObject: object): any;
|
|
96
|
+
addRows(rows: [object]): any;
|
|
97
|
+
deleteRow(rowId: string): any;
|
|
98
|
+
deleteRows(rows: [string]): any;
|
|
99
|
+
}
|
|
100
|
+
export class TableForm extends BaseSDK {
|
|
101
|
+
private instanceId;
|
|
102
|
+
private tableId;
|
|
103
|
+
private rowId;
|
|
104
|
+
type: string;
|
|
105
|
+
constructor(instanceId: string, tableId: string, rowId: string);
|
|
106
|
+
getParent(): Form;
|
|
107
|
+
toJSON(): any;
|
|
108
|
+
getField(fieldId: string): any;
|
|
109
|
+
updateField(args: object): any;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
declare module "utils/client" {
|
|
113
|
+
import { BaseSDK } from "core/index";
|
|
114
|
+
export class Client extends BaseSDK {
|
|
115
|
+
showInfo(message: string): any;
|
|
116
|
+
showConfirm(args: {
|
|
117
|
+
title: string;
|
|
118
|
+
content: string;
|
|
119
|
+
okText: string;
|
|
120
|
+
cancelText: string;
|
|
121
|
+
}): any;
|
|
122
|
+
redirect(url: string): any;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
declare module "utils/formatter" {
|
|
126
|
+
import { BaseSDK } from "core/index";
|
|
127
|
+
export class Formatter extends BaseSDK {
|
|
128
|
+
toDate(date: string): any;
|
|
129
|
+
toDateTime(date: string): any;
|
|
130
|
+
toNumber(value: string): any;
|
|
131
|
+
toCurrency(value: string, currencyCode: string): any;
|
|
132
|
+
toBoolean(value: string): any;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
declare module "utils/index" {
|
|
136
|
+
export * from "utils/client";
|
|
137
|
+
export * from "utils/formatter";
|
|
138
|
+
}
|
|
139
|
+
declare module "window/NDEFReader" {
|
|
140
|
+
import { BaseSDK } from "core/index";
|
|
141
|
+
export class NDEFReader extends BaseSDK {
|
|
142
|
+
id: string;
|
|
143
|
+
constructor();
|
|
144
|
+
scan(): Promise<unknown>;
|
|
145
|
+
write(data: any): Promise<unknown>;
|
|
146
|
+
addEventListener(eventName: string, cb: Function): void;
|
|
147
|
+
makeReadOnly(): Promise<unknown>;
|
|
148
|
+
abortScan(): Promise<unknown>;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
declare module "window/index" {
|
|
152
|
+
import { NDEFReader } from "window/NDEFReader";
|
|
153
|
+
export const window: {
|
|
154
|
+
NDEFReader: typeof NDEFReader;
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
declare module "types/external" {
|
|
158
|
+
export type userObject = {
|
|
159
|
+
_id: string;
|
|
160
|
+
Name: string;
|
|
161
|
+
Email: string;
|
|
162
|
+
Role: string;
|
|
163
|
+
};
|
|
164
|
+
export type accountObject = {
|
|
165
|
+
_id: string;
|
|
166
|
+
};
|
|
167
|
+
export type environmentObject = {
|
|
168
|
+
isMobile: boolean;
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
declare module "types/internal" {
|
|
172
|
+
import { userObject, accountObject, environmentObject } from "types/external";
|
|
173
|
+
export interface SDKContext {
|
|
174
|
+
formInstanceId: string;
|
|
175
|
+
tableId: string;
|
|
176
|
+
tableRowId: string;
|
|
177
|
+
componentId: string;
|
|
178
|
+
componentMethods?: componentMethodsType[];
|
|
179
|
+
appId: string;
|
|
180
|
+
pageId: string;
|
|
181
|
+
popupId: string;
|
|
182
|
+
user: userObject;
|
|
183
|
+
account: accountObject;
|
|
184
|
+
csrfToken: string;
|
|
185
|
+
envDetails: environmentObject;
|
|
186
|
+
}
|
|
187
|
+
export interface componentMethodsType {
|
|
188
|
+
name: string;
|
|
189
|
+
returnType?: string;
|
|
190
|
+
parameters?: string[];
|
|
191
|
+
}
|
|
192
|
+
export interface ComponentProps {
|
|
193
|
+
componentId: string;
|
|
194
|
+
componentMethods?: componentMethodsType[];
|
|
195
|
+
}
|
|
196
|
+
export interface AppContext {
|
|
197
|
+
appId: string;
|
|
198
|
+
pageId: string;
|
|
199
|
+
}
|
|
200
|
+
export interface PageContext {
|
|
201
|
+
pageId: string;
|
|
202
|
+
}
|
|
203
|
+
export interface PopupContext {
|
|
204
|
+
popupId?: string;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
declare module "nocode" {
|
|
208
|
+
import { BaseSDK } from "core/index";
|
|
209
|
+
import { Form, TableForm } from "form/index";
|
|
210
|
+
import { Client, Formatter } from "utils/index";
|
|
211
|
+
import { window } from "window/index";
|
|
212
|
+
import { SDKContext } from "types/internal";
|
|
213
|
+
import { userObject, accountObject } from "types/external";
|
|
214
|
+
class NocodeSDK extends BaseSDK {
|
|
215
|
+
#private;
|
|
216
|
+
context: Form | TableForm;
|
|
217
|
+
client: Client;
|
|
218
|
+
formatter: Formatter;
|
|
219
|
+
user: userObject;
|
|
220
|
+
account: accountObject;
|
|
221
|
+
constructor(props: SDKContext);
|
|
222
|
+
api(url: string, args?: {
|
|
223
|
+
headers: object;
|
|
224
|
+
}): Promise<any>;
|
|
225
|
+
}
|
|
226
|
+
function initSDK(config: SDKContext): NocodeSDK;
|
|
227
|
+
export { window, initSDK as default };
|
|
228
|
+
}
|
|
229
|
+
declare module "app/component" {
|
|
230
|
+
import { BaseSDK } from "core/index";
|
|
231
|
+
import { ComponentProps } from "types/internal";
|
|
232
|
+
export class Component extends BaseSDK {
|
|
233
|
+
#private;
|
|
234
|
+
_id: string;
|
|
235
|
+
type: string;
|
|
236
|
+
constructor(props: ComponentProps);
|
|
237
|
+
onMount(callback: Function): void;
|
|
238
|
+
refresh(): any;
|
|
239
|
+
show(): any;
|
|
240
|
+
hide(): any;
|
|
241
|
+
}
|
|
242
|
+
export class CustomComponent extends BaseSDK {
|
|
243
|
+
type: string;
|
|
244
|
+
_id: string;
|
|
245
|
+
constructor(id: any);
|
|
246
|
+
watchParams(callBack: (data: any) => any): void;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
declare module "app/dataform" {
|
|
250
|
+
import { BaseSDK } from "core/index";
|
|
251
|
+
export class Dataform extends BaseSDK {
|
|
252
|
+
private _id;
|
|
253
|
+
constructor(flowId: string);
|
|
254
|
+
importCSV(defaultValues: object): any;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
declare module "app/decisiontable" {
|
|
258
|
+
import { BaseSDK } from "core/index";
|
|
259
|
+
export class DecisionTable extends BaseSDK {
|
|
260
|
+
private flowId;
|
|
261
|
+
constructor(flowId: string);
|
|
262
|
+
evaluate(payload?: object): any;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
declare module "app/popup" {
|
|
266
|
+
import { BaseSDK } from "core/index";
|
|
267
|
+
import { Component } from "app/component";
|
|
268
|
+
import { PopupContext } from "types/internal";
|
|
269
|
+
export class Popup extends BaseSDK {
|
|
270
|
+
_id: string;
|
|
271
|
+
type: string;
|
|
272
|
+
constructor(props: PopupContext);
|
|
273
|
+
getParameter(key: string): any;
|
|
274
|
+
getAllParameters(): any;
|
|
275
|
+
close(): any;
|
|
276
|
+
getComponent(componentId: string): Component;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
declare module "app/page" {
|
|
280
|
+
import { BaseSDK } from "core/index";
|
|
281
|
+
import { Component } from "app/component";
|
|
282
|
+
import { Popup } from "app/popup";
|
|
283
|
+
import { PageContext } from "types/internal";
|
|
284
|
+
export class Page extends BaseSDK {
|
|
285
|
+
_id: string;
|
|
286
|
+
popup: Popup;
|
|
287
|
+
type: string;
|
|
288
|
+
constructor(props: PageContext);
|
|
289
|
+
getParameter(key: string): any;
|
|
290
|
+
getAllParameters(): any;
|
|
291
|
+
getVariable(key: string): any;
|
|
292
|
+
setVariable(key: string, value: any): any;
|
|
293
|
+
openPopup(popupId: string, popupParams: object): any;
|
|
294
|
+
getComponent(componentId: string): Component;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
declare module "app/index" {
|
|
298
|
+
import { BaseSDK } from "core/index";
|
|
299
|
+
import { Page } from "app/page";
|
|
300
|
+
import { AppContext } from "types/internal";
|
|
301
|
+
import { DecisionTable } from "app/decisiontable";
|
|
302
|
+
import { Dataform } from "app/dataform";
|
|
303
|
+
export class Application extends BaseSDK {
|
|
304
|
+
page: Page;
|
|
305
|
+
_id: string;
|
|
306
|
+
constructor(props: AppContext);
|
|
307
|
+
getVariable(key: string): any;
|
|
308
|
+
setVariable(key: string | object, value?: any): any;
|
|
309
|
+
openPage(pageId: string, pageParams: object): any;
|
|
310
|
+
getDecisionTable(flowId: string): DecisionTable;
|
|
311
|
+
getDataform(flowId: string): Dataform;
|
|
312
|
+
}
|
|
313
|
+
export * from "app/component";
|
|
314
|
+
export { Page };
|
|
315
|
+
export * from "app/popup";
|
|
316
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
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
|
+
addRows(rows: [object]): any;
|
|
15
|
+
deleteRow(rowId: string): any;
|
|
16
|
+
deleteRows(rows: [string]): any;
|
|
17
|
+
}
|
|
18
|
+
declare class TableForm {
|
|
19
|
+
type: string
|
|
20
|
+
getParent(): Form;
|
|
21
|
+
toJSON(): any;
|
|
22
|
+
getField(fieldId: string): any;
|
|
23
|
+
updateField(args: object): any;
|
|
24
|
+
}
|
|
25
|
+
declare class Client {
|
|
26
|
+
showInfo(message: string): any;
|
|
27
|
+
showConfirm(args: {
|
|
28
|
+
title: string;
|
|
29
|
+
content: string;
|
|
30
|
+
okText: string;
|
|
31
|
+
cancelText: string;
|
|
32
|
+
}): any;
|
|
33
|
+
redirect(url: string): any;
|
|
34
|
+
}
|
|
35
|
+
declare class Formatter {
|
|
36
|
+
toDate(date: string): any;
|
|
37
|
+
toDateTime(date: string): any;
|
|
38
|
+
toNumber(value: string): any;
|
|
39
|
+
toCurrency(value: string, currencyCode: string): any;
|
|
40
|
+
toBoolean(value: string): any;
|
|
41
|
+
}
|
|
42
|
+
declare class kf {
|
|
43
|
+
static context: Form
|
|
44
|
+
static client: Client
|
|
45
|
+
static formatter: Formatter
|
|
46
|
+
static user: userObject
|
|
47
|
+
static account: accountObject
|
|
48
|
+
api(url: string, args?: {
|
|
49
|
+
headers: object;
|
|
50
|
+
}): Promise<any>;
|
|
51
|
+
}
|
|
52
|
+
declare type userObject = {
|
|
53
|
+
_id: string;
|
|
54
|
+
Name: string;
|
|
55
|
+
Email: string;
|
|
56
|
+
Role: string;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
declare type accountObject = {
|
|
60
|
+
_id: string;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
declare type environmentObject = {
|
|
64
|
+
isMobile: boolean
|
|
65
|
+
}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
{
|
|
2
|
+
"lowcode": [
|
|
3
|
+
{
|
|
4
|
+
"label": "get app variable",
|
|
5
|
+
"documentation": "Get value of the global variable",
|
|
6
|
+
"insertText": "let variableName = await kf.app.getVariable(\"${1:variableId}\")"
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"label": "set app variable",
|
|
10
|
+
"documentation": "Sets a new value to the global variable",
|
|
11
|
+
"insertText": "kf.app.setVariable(\"${1:variableId}\", \"${2:newValue}\")"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"label": "open or navigate page",
|
|
15
|
+
"documentation": "Navigate to another page",
|
|
16
|
+
"insertText": "kf.app.openPage(\"${1:pageId}\", { inputParam1: \"value1\" })"
|
|
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
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"label": "get local variable",
|
|
25
|
+
"documentation": "Get value of the local variable",
|
|
26
|
+
"insertText": "let variableName = await kf.app.page.getVariable(\"${1:variableId}\")"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"label": "set local variable",
|
|
30
|
+
"documentation": "Sets specified variable to new value in page scope",
|
|
31
|
+
"insertText": "kf.app.page.setVariable(\"${1:variableId}\", \"${2:newValue}\")"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"label": "get input parameter",
|
|
35
|
+
"documentation": "Get specific input parameter of the page",
|
|
36
|
+
"insertText": "let value = await kf.app.page.getParameter(\"${1:parameterId}\"); "
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"label": "get all input parameters",
|
|
40
|
+
"documentation": "Get all input parameters in the page",
|
|
41
|
+
"insertText": "let allParams = await kf.app.page.getAllParameters();"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"label": "open a popup",
|
|
45
|
+
"documentation": "Opens a popup in the page",
|
|
46
|
+
"insertText": "kf.app.page.openPopup(\"${1:popupId}\", { popupParam1: \"value\" });"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"label": "get component in page",
|
|
50
|
+
"documentation": "Get the specified component instance from the current page",
|
|
51
|
+
"insertText": "let componentInstance = await kf.app.page.getComponent(\"${1:componentId}\")"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"label": "refresh the component",
|
|
55
|
+
"documentation": "Refreshes the component",
|
|
56
|
+
"insertText": "componentInstance.refresh()"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"label": "hide the component",
|
|
60
|
+
"documentation": "Hides the component from page",
|
|
61
|
+
"insertText": "componentInstance.hide()"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"label": "show the component",
|
|
65
|
+
"documentation": "Shows the hidden component from page",
|
|
66
|
+
"insertText": "componentInstance.show()"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"label": "set active tab",
|
|
70
|
+
"documentation": "Sets the specified tab index as active - works only for the tab component",
|
|
71
|
+
"insertText": "// sets 2nd tab as active\ncomponentInstance.setActiveTab(${1:2})"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"label": "set selected item",
|
|
75
|
+
"documentation": "Sets the specified instance as selected item - works only for master detail component",
|
|
76
|
+
"insertText": "componentInstance.setSelectedItem(\"${1:instanceId}\")"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"label": "get popup parameter",
|
|
80
|
+
"documentation": "Get specific parameter in the popup",
|
|
81
|
+
"insertText": "let value = await kf.app.page.popup.getParameter(\"${1:parameterId}\"); "
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"label": "get all popup parameters",
|
|
85
|
+
"documentation": "Get all parameters in the popup as object",
|
|
86
|
+
"insertText": "let allParams = await kf.app.page.popup.getAllParameters();"
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"label": "close active popup",
|
|
90
|
+
"documentation": "Closes the active popup in the page",
|
|
91
|
+
"insertText": "kf.app.page.popup.close()"
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"label": "get instance id",
|
|
95
|
+
"documentation": "Get the instance id from event arguments",
|
|
96
|
+
"insertText": "kf.eventParameters._id"
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"label": "get activity instance id",
|
|
100
|
+
"documentation": "Get the activity instance id from event arguments",
|
|
101
|
+
"insertText": "kf.eventParameters._activity_instance_id"
|
|
102
|
+
}
|
|
103
|
+
],
|
|
104
|
+
"nocode": [
|
|
105
|
+
{
|
|
106
|
+
"label": "get field value",
|
|
107
|
+
"documentation": "Get value of a field in form",
|
|
108
|
+
"insertText": "let fieldValue = await kf.context.getField(\"${1:fieldId}\");"
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"label": "set field value",
|
|
112
|
+
"documentation": "Set value of a field in form",
|
|
113
|
+
"insertText": "kf.context.updateField({\"${1:fieldId}\": \"${2:value}\"});"
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
"label": "set field value - bulk",
|
|
117
|
+
"documentation": "Set value of a field in form",
|
|
118
|
+
"insertText": "let payload = { \"fieldId\": \"value\", \"fieldId2\": \"value2\" };\nkf.context.updateField(payload);"
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"label": "get form json",
|
|
122
|
+
"documentation": "Returns whole data of current form in json format",
|
|
123
|
+
"insertText": "let formJSON = await kf.context.getJSON();"
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"label": "get table instance",
|
|
127
|
+
"documentation": "Get instance of table, which can be further used to add or delete rows",
|
|
128
|
+
"insertText": "let tableInstance = kf.context.getTable(\"${1:tableId}\");"
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"label": "add a row in table",
|
|
132
|
+
"documentation": "Appends a row entry to table",
|
|
133
|
+
"insertText": "let rowDetails = { \"columnId1\": \"value1\", \"columnId2\": \"value2\" };\ntableInstance.addRow(rowDetails)"
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"label": "get table row",
|
|
137
|
+
"documentation": "Returns all columns with values in specified row",
|
|
138
|
+
"insertText": "tableInstance.getRow(\"${1:rowId}\")"
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
"label": "get table json",
|
|
142
|
+
"documentation": "Returns all rows & columns data inside table in json format",
|
|
143
|
+
"insertText": "let tableJSON = await kf.context.getJSON();"
|
|
144
|
+
}
|
|
145
|
+
],
|
|
146
|
+
"common": [
|
|
147
|
+
{
|
|
148
|
+
"label": "showinfo",
|
|
149
|
+
"documentation": "Shows toast information",
|
|
150
|
+
"insertText": "kf.client.showInfo(\"${1:message}\")"
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
"label": "api call",
|
|
154
|
+
"documentation": "Makes an API call to any kissflow rest api end points",
|
|
155
|
+
"insertText": "kf.api(`/${1:url}`)\n.then((resp) => {${2}})\n.catch((err) => {${3}})"
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
"label": "get account id",
|
|
159
|
+
"documentation": "Retrieves the acccount id",
|
|
160
|
+
"insertText": "kf.account._id"
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
"label": "get dataform item",
|
|
164
|
+
"documentation": "API call to get dataform item",
|
|
165
|
+
"insertText": "kf.api(`/form/2/${kf.account._id}/${1:formId}/${2:instanceId}`)\n.then((resp) => {${3}})\n.catch((err) => {${4}})"
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
"label": "update dataform item",
|
|
169
|
+
"documentation": "API call to update dataform item",
|
|
170
|
+
"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}})"
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
"label": "delete dataform item",
|
|
174
|
+
"documentation": "API call to delete dataform item",
|
|
175
|
+
"insertText": "let payload = {};\nkf.api(`/form/2/${kf.account._id}/${1:formId}/${2:instanceId}`, { method: \"DELETE\" })\n.then((resp) => {${3}})\n.catch((err) => {${4}})"
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
"label": "create new dataform item",
|
|
179
|
+
"documentation": "API call to create new dataform item",
|
|
180
|
+
"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}})"
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
"label": "create new case item",
|
|
184
|
+
"documentation": "API call to create new case item",
|
|
185
|
+
"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}})"
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
"label": "create new process item",
|
|
189
|
+
"documentation": "API call to create new process item",
|
|
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}})"
|
|
191
|
+
}
|
|
192
|
+
]
|
|
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
|
+
};
|