@kissflow/lowcode-client-sdk 1.0.12 → 1.0.13
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 +28 -12
- package/dist/global.types.d.ts +40 -39
- package/dist/index.d.ts +105 -67
- package/dist/kfsdk.es.js +227 -160
- package/dist/kfsdk.umd.js +1 -1
- package/dist/kfworkersdk.es.js +253 -119
- package/dist/lowcode.d.ts +131 -94
- package/package.json +4 -12
package/README.md
CHANGED
|
@@ -54,6 +54,9 @@ let resp = await kf.api(url, config)
|
|
|
54
54
|
- [3. Application](#3-application)
|
|
55
55
|
- [4. Page](#4-page)
|
|
56
56
|
- [5. Component](#5-component)
|
|
57
|
+
- [Standard Component methods](#standard-component-methods)
|
|
58
|
+
- [Component Specific methods](#component-specific-methods)
|
|
59
|
+
- [Tab](#521-tab-component)
|
|
57
60
|
- [6. Popup](#6-popup)
|
|
58
61
|
- [7. Formatter](#7-formatter)
|
|
59
62
|
|
|
@@ -345,26 +348,40 @@ kf.app.page.openPopup("popupId", { inputParam1: "value" });
|
|
|
345
348
|
```
|
|
346
349
|
|
|
347
350
|
### 5) Component
|
|
348
|
-
|
|
351
|
+
#### getComponent(id)
|
|
352
|
+
Parameter: Component's Id
|
|
353
|
+
Returns: Component class instance
|
|
349
354
|
```js
|
|
350
355
|
const component = await kf.app.page.getComponent(componentId);
|
|
351
356
|
```
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
##### Refresh a component
|
|
357
|
+
##### Standard Component Methods
|
|
355
358
|
```js
|
|
356
|
-
component.refresh();
|
|
359
|
+
component.refresh(); // Refreshes the component
|
|
360
|
+
component.hide(); // Hides the component
|
|
361
|
+
component.show(); // Shows the component if it's been hidden previously
|
|
357
362
|
```
|
|
363
|
+
##### Component Specific Methods
|
|
358
364
|
|
|
359
|
-
|
|
365
|
+
|
|
366
|
+
##### 5.2.0) Component onMount
|
|
367
|
+
Component onMount takes in callBack function as argument.
|
|
368
|
+
> ##### Note: Any component specific methods that are used on Page load must be called inside component's onMount event.
|
|
369
|
+
Parameter: function
|
|
360
370
|
```js
|
|
361
|
-
|
|
371
|
+
component.onMount(() => {
|
|
372
|
+
// function logic goes here... For eg.
|
|
373
|
+
// component.setActiveTab(2)
|
|
374
|
+
})
|
|
362
375
|
```
|
|
363
|
-
|
|
364
|
-
#####
|
|
376
|
+
##### 5.2.1) Tab component
|
|
377
|
+
##### 1) setActiveTab
|
|
378
|
+
Sets specified tab as active.
|
|
379
|
+
Parameter: Tabs' Number (Starts from 1 to N)
|
|
365
380
|
```js
|
|
366
|
-
component.
|
|
381
|
+
component.setActiveTab(2) // sets 2nd tab as active one
|
|
367
382
|
```
|
|
383
|
+
|
|
384
|
+
|
|
368
385
|
### 6) Popup
|
|
369
386
|
`kf.app.page.popup` returns the active popup instance opened inside the page and its id can be accessed via `kf.app.page.popup._id`
|
|
370
387
|
And `kf.app.page.getPopup(id)` returns this popup class instance.
|
|
@@ -376,7 +393,7 @@ let value = await kf.app.page.popup.getParameter("parameterId"); // for retreivi
|
|
|
376
393
|
Get all popup parameters
|
|
377
394
|
```js
|
|
378
395
|
let allParams = await kf.app.page.popup.getAllParameters();
|
|
379
|
-
//
|
|
396
|
+
// Returns an object
|
|
380
397
|
{
|
|
381
398
|
parameterName: "Sample value",
|
|
382
399
|
parameterName2: "Sample value 2"
|
|
@@ -441,4 +458,3 @@ let value = await kf.formatter.toBoolean("no");
|
|
|
441
458
|
let value = await kf.formatter.toBoolean("0");
|
|
442
459
|
let value = await kf.formatter.toBoolean("false");
|
|
443
460
|
```
|
|
444
|
-
|
package/dist/global.types.d.ts
CHANGED
|
@@ -1,7 +1,46 @@
|
|
|
1
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
|
+
}
|
|
2
40
|
declare class Component {
|
|
3
41
|
_id: string
|
|
4
42
|
type: string
|
|
43
|
+
onMount(callback: Function): void;
|
|
5
44
|
refresh(): any;
|
|
6
45
|
show(): any;
|
|
7
46
|
hide(): any;
|
|
@@ -29,47 +68,9 @@ declare class Application {
|
|
|
29
68
|
page: Page
|
|
30
69
|
_id: string
|
|
31
70
|
getVariable(key: string): any;
|
|
32
|
-
setVariable(key: string | object, value
|
|
71
|
+
setVariable(key: string | object, value?: any): any;
|
|
33
72
|
openPage(pageId: string, pageParams: object): any;
|
|
34
73
|
}
|
|
35
|
-
declare class Client {
|
|
36
|
-
showInfo(message: string): any;
|
|
37
|
-
showConfirm(args: {
|
|
38
|
-
title: string;
|
|
39
|
-
content: string;
|
|
40
|
-
okText: string;
|
|
41
|
-
cancelText: string;
|
|
42
|
-
}): any;
|
|
43
|
-
redirect(url: string): any;
|
|
44
|
-
}
|
|
45
|
-
declare class Form {
|
|
46
|
-
type: string
|
|
47
|
-
toJSON(): any;
|
|
48
|
-
getField(fieldId: string): any;
|
|
49
|
-
updateField(args: object): any;
|
|
50
|
-
getTable(tableId: string): Table;
|
|
51
|
-
}
|
|
52
|
-
declare class Table {
|
|
53
|
-
toJSON(): any;
|
|
54
|
-
getRows(): TableForm[];
|
|
55
|
-
getRow(rowId: string): TableForm;
|
|
56
|
-
addRow(rowObject: object): any;
|
|
57
|
-
deleteRow(rowId: string): any;
|
|
58
|
-
}
|
|
59
|
-
declare class TableForm {
|
|
60
|
-
type: string
|
|
61
|
-
getParent(): Form;
|
|
62
|
-
toJSON(): any;
|
|
63
|
-
getField(fieldId: string): any;
|
|
64
|
-
updateField(args: object): any;
|
|
65
|
-
}
|
|
66
|
-
declare class Formatter {
|
|
67
|
-
toDate(date: string): any;
|
|
68
|
-
toDateTime(date: string): any;
|
|
69
|
-
toNumber(value: string): any;
|
|
70
|
-
toCurrency(value: string, currencyCode: string): any;
|
|
71
|
-
toBoolean(value: string): any;
|
|
72
|
-
}
|
|
73
74
|
declare class kf {
|
|
74
75
|
static context: Component
|
|
75
76
|
static client: Client
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
declare module "constants" {
|
|
1
|
+
declare module "core/constants" {
|
|
2
2
|
export const LISTENER_CMDS: {
|
|
3
3
|
API: string;
|
|
4
|
-
PARAMS: string;
|
|
5
4
|
GET_CONTEXT: string;
|
|
6
5
|
RETURN: string;
|
|
7
6
|
GET_FORM_FIELD: string;
|
|
@@ -33,30 +32,44 @@ declare module "constants" {
|
|
|
33
32
|
GET_POPUP_PARAMS: string;
|
|
34
33
|
GET_ALL_POPUP_PARAMS: string;
|
|
35
34
|
CLOSE_POPUP: string;
|
|
36
|
-
|
|
35
|
+
COMPONENT_GET: string;
|
|
37
36
|
COMPONENT_REFRESH: string;
|
|
38
37
|
COMPONENT_SHOW: string;
|
|
39
38
|
COMPONENT_HIDE: string;
|
|
40
|
-
|
|
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;
|
|
41
48
|
};
|
|
42
49
|
export const EVENT_TYPES: {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
ON_CHANGE: string;
|
|
46
|
-
ON_LOAD: string;
|
|
50
|
+
COMPONENT_ON_MOUNT: string;
|
|
51
|
+
CC_ON_PARAMS_CHANGE: string;
|
|
47
52
|
};
|
|
48
53
|
export const DEFAULTS: {
|
|
49
54
|
POPUP_ID: string;
|
|
50
55
|
};
|
|
51
56
|
}
|
|
52
|
-
declare module "
|
|
53
|
-
export
|
|
57
|
+
declare module "core/index" {
|
|
58
|
+
export function generateId(prefix?: string): string;
|
|
59
|
+
export const globalInstances: {};
|
|
60
|
+
export class EventBase {
|
|
54
61
|
#private;
|
|
55
|
-
constructor(
|
|
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 {
|
|
56
69
|
_postMessageAsync(command: string, args: any, hasCallBack?: boolean, callBack?: (data: any) => {}): object | string | any;
|
|
57
|
-
_postMessage(command: string,
|
|
58
|
-
_registerEventListener(_id: string, eventType: string, callback: any): void;
|
|
70
|
+
_postMessage(command: string, args: any, callBack?: any): void;
|
|
59
71
|
}
|
|
72
|
+
export * from "core/constants";
|
|
60
73
|
}
|
|
61
74
|
declare module "types/external" {
|
|
62
75
|
export type userObject = {
|
|
@@ -80,7 +93,7 @@ declare module "types/internal" {
|
|
|
80
93
|
tableId: string;
|
|
81
94
|
tableRowId: string;
|
|
82
95
|
componentId: string;
|
|
83
|
-
|
|
96
|
+
componentMethods?: componentMethodsType[];
|
|
84
97
|
appId: string;
|
|
85
98
|
pageId: string;
|
|
86
99
|
popupId: string;
|
|
@@ -89,14 +102,14 @@ declare module "types/internal" {
|
|
|
89
102
|
csrfToken: string;
|
|
90
103
|
envDetails: environmentObject;
|
|
91
104
|
}
|
|
92
|
-
export interface
|
|
105
|
+
export interface componentMethodsType {
|
|
93
106
|
name: string;
|
|
94
107
|
returnType?: string;
|
|
95
108
|
parameters?: string[];
|
|
96
109
|
}
|
|
97
110
|
export interface ComponentProps {
|
|
98
111
|
componentId: string;
|
|
99
|
-
|
|
112
|
+
componentMethods?: componentMethodsType[];
|
|
100
113
|
}
|
|
101
114
|
export interface AppContext {
|
|
102
115
|
appId: string;
|
|
@@ -109,26 +122,29 @@ declare module "types/internal" {
|
|
|
109
122
|
popupId?: string;
|
|
110
123
|
}
|
|
111
124
|
}
|
|
112
|
-
declare module "component" {
|
|
113
|
-
import { BaseSDK } from "
|
|
125
|
+
declare module "app/component" {
|
|
126
|
+
import { BaseSDK } from "core/index";
|
|
114
127
|
import { ComponentProps } from "types/internal";
|
|
115
128
|
export class Component extends BaseSDK {
|
|
129
|
+
#private;
|
|
116
130
|
_id: string;
|
|
117
131
|
type: string;
|
|
118
132
|
constructor(props: ComponentProps);
|
|
133
|
+
onMount(callback: Function): void;
|
|
119
134
|
refresh(): any;
|
|
120
135
|
show(): any;
|
|
121
136
|
hide(): any;
|
|
122
137
|
}
|
|
123
138
|
export class CustomComponent extends BaseSDK {
|
|
124
139
|
type: string;
|
|
125
|
-
|
|
126
|
-
|
|
140
|
+
_id: string;
|
|
141
|
+
constructor(id: any);
|
|
142
|
+
watchParams(callBack: (data: any) => any): void;
|
|
127
143
|
}
|
|
128
144
|
}
|
|
129
|
-
declare module "popup" {
|
|
130
|
-
import {
|
|
131
|
-
import {
|
|
145
|
+
declare module "app/popup" {
|
|
146
|
+
import { BaseSDK } from "core/index";
|
|
147
|
+
import { Component } from "app/component";
|
|
132
148
|
import { PopupContext } from "types/internal";
|
|
133
149
|
export class Popup extends BaseSDK {
|
|
134
150
|
_id: string;
|
|
@@ -140,10 +156,10 @@ declare module "popup" {
|
|
|
140
156
|
getComponent(componentId: string): Component;
|
|
141
157
|
}
|
|
142
158
|
}
|
|
143
|
-
declare module "page" {
|
|
144
|
-
import {
|
|
145
|
-
import {
|
|
146
|
-
import { Popup } from "popup";
|
|
159
|
+
declare module "app/page" {
|
|
160
|
+
import { BaseSDK } from "core/index";
|
|
161
|
+
import { Component } from "app/component";
|
|
162
|
+
import { Popup } from "app/popup";
|
|
147
163
|
import { PageContext } from "types/internal";
|
|
148
164
|
export class Page extends BaseSDK {
|
|
149
165
|
_id: string;
|
|
@@ -158,21 +174,24 @@ declare module "page" {
|
|
|
158
174
|
getComponent(componentId: string): Component;
|
|
159
175
|
}
|
|
160
176
|
}
|
|
161
|
-
declare module "app" {
|
|
162
|
-
import { BaseSDK } from "
|
|
163
|
-
import { Page } from "page";
|
|
177
|
+
declare module "app/index" {
|
|
178
|
+
import { BaseSDK } from "core/index";
|
|
179
|
+
import { Page } from "app/page";
|
|
164
180
|
import { AppContext } from "types/internal";
|
|
165
181
|
export class Application extends BaseSDK {
|
|
166
182
|
page: Page;
|
|
167
183
|
_id: string;
|
|
168
184
|
constructor(props: AppContext);
|
|
169
185
|
getVariable(key: string): any;
|
|
170
|
-
setVariable(key: string | object, value
|
|
186
|
+
setVariable(key: string | object, value?: any): any;
|
|
171
187
|
openPage(pageId: string, pageParams: object): any;
|
|
172
188
|
}
|
|
189
|
+
export * from "app/component";
|
|
190
|
+
export { Page };
|
|
191
|
+
export * from "app/popup";
|
|
173
192
|
}
|
|
174
|
-
declare module "client" {
|
|
175
|
-
import { BaseSDK } from "
|
|
193
|
+
declare module "utils/client" {
|
|
194
|
+
import { BaseSDK } from "core/index";
|
|
176
195
|
export class Client extends BaseSDK {
|
|
177
196
|
showInfo(message: string): any;
|
|
178
197
|
showConfirm(args: {
|
|
@@ -184,8 +203,44 @@ declare module "client" {
|
|
|
184
203
|
redirect(url: string): any;
|
|
185
204
|
}
|
|
186
205
|
}
|
|
187
|
-
declare module "
|
|
188
|
-
import { BaseSDK } from "
|
|
206
|
+
declare module "utils/formatter" {
|
|
207
|
+
import { BaseSDK } from "core/index";
|
|
208
|
+
export class Formatter extends BaseSDK {
|
|
209
|
+
toDate(date: string): any;
|
|
210
|
+
toDateTime(date: string): any;
|
|
211
|
+
toNumber(value: string): any;
|
|
212
|
+
toCurrency(value: string, currencyCode: string): any;
|
|
213
|
+
toBoolean(value: string): any;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
declare module "utils/index" {
|
|
217
|
+
export * from "utils/client";
|
|
218
|
+
export * from "utils/formatter";
|
|
219
|
+
}
|
|
220
|
+
declare module "index" {
|
|
221
|
+
import { BaseSDK } from "core/index";
|
|
222
|
+
import { Application, Page, CustomComponent } from "app/index";
|
|
223
|
+
import { Client, Formatter } from "utils/index";
|
|
224
|
+
import { userObject, accountObject, environmentObject } from "types/external";
|
|
225
|
+
class CustomComponentSDK extends BaseSDK {
|
|
226
|
+
app: Application;
|
|
227
|
+
page: Page;
|
|
228
|
+
user: userObject;
|
|
229
|
+
account: accountObject;
|
|
230
|
+
context: CustomComponent;
|
|
231
|
+
client: Client;
|
|
232
|
+
formatter: Formatter;
|
|
233
|
+
env: environmentObject;
|
|
234
|
+
constructor();
|
|
235
|
+
api(url: string, args?: {}): string | object;
|
|
236
|
+
initialize(): any;
|
|
237
|
+
initialise(): any;
|
|
238
|
+
}
|
|
239
|
+
const _default: CustomComponentSDK;
|
|
240
|
+
export default _default;
|
|
241
|
+
}
|
|
242
|
+
declare module "form/index" {
|
|
243
|
+
import { BaseSDK } from "core/index";
|
|
189
244
|
export class Form extends BaseSDK {
|
|
190
245
|
private instanceId;
|
|
191
246
|
type: string;
|
|
@@ -217,38 +272,21 @@ declare module "form" {
|
|
|
217
272
|
updateField(args: object): any;
|
|
218
273
|
}
|
|
219
274
|
}
|
|
220
|
-
declare module "
|
|
221
|
-
import { BaseSDK } from "
|
|
222
|
-
export class
|
|
223
|
-
|
|
224
|
-
toDateTime(date: string): any;
|
|
225
|
-
toNumber(value: string): any;
|
|
226
|
-
toCurrency(value: string, currencyCode: string): any;
|
|
227
|
-
toBoolean(value: string): any;
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
declare module "index" {
|
|
231
|
-
import { BaseSDK } from "base";
|
|
232
|
-
import { Client } from "client";
|
|
233
|
-
import { Formatter } from "formatter";
|
|
234
|
-
import { Application } from "app";
|
|
235
|
-
import { Page } from "page";
|
|
236
|
-
import { CustomComponent } from "component";
|
|
237
|
-
import { userObject, accountObject, environmentObject } from "types/external";
|
|
238
|
-
class CustomComponentSDK extends BaseSDK {
|
|
239
|
-
app: Application;
|
|
240
|
-
page: Page;
|
|
241
|
-
user: userObject;
|
|
242
|
-
account: accountObject;
|
|
243
|
-
context: CustomComponent;
|
|
244
|
-
client: Client;
|
|
245
|
-
formatter: Formatter;
|
|
246
|
-
env: environmentObject;
|
|
275
|
+
declare module "window/NDEFReader" {
|
|
276
|
+
import { BaseSDK } from "core/index";
|
|
277
|
+
export class NDEFReader extends BaseSDK {
|
|
278
|
+
id: string;
|
|
247
279
|
constructor();
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
280
|
+
scan(): Promise<unknown>;
|
|
281
|
+
write(data: any): Promise<unknown>;
|
|
282
|
+
addEventListener(eventName: string, cb: Function): void;
|
|
283
|
+
makeReadOnly(): Promise<unknown>;
|
|
284
|
+
abortScan(): Promise<unknown>;
|
|
251
285
|
}
|
|
252
|
-
|
|
253
|
-
|
|
286
|
+
}
|
|
287
|
+
declare module "window/index" {
|
|
288
|
+
import { NDEFReader } from "window/NDEFReader";
|
|
289
|
+
export const window: {
|
|
290
|
+
NDEFReader: typeof NDEFReader;
|
|
291
|
+
};
|
|
254
292
|
}
|