@kissflow/lowcode-client-sdk 1.0.8 → 1.0.9

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 CHANGED
@@ -12,7 +12,6 @@ promise.
12
12
  import KFSDK from "@kissflow/lowcode-client-sdk";
13
13
  let kf;
14
14
  (async function () {
15
- // Immediately invoked function.
16
15
  kf = await KFSDK.initialise();
17
16
  })();
18
17
  ```
@@ -22,19 +21,18 @@ let kf;
22
21
  SDK can also be loaded directly into HTML by adding:
23
22
 
24
23
  ```html
25
- <script src="https://cdn.jsdelivr.net/npm/@kissflow/lowcode-client-sdk@1/dist/kfsdk.umd.js"></script>
24
+ <script src="https://unpkg.com/@kissflow/lowcode-client-sdk@latest/dist/kfsdk.umd.js""></script>
26
25
  ```
27
26
 
28
27
  > Then SDK can be initialized anywhere by declaring:
29
28
 
30
29
  ```js
31
30
  let kf;
32
- (async function () {
31
+ window.onload = async function () {
33
32
  kf = await window.kf.initialise();
34
- })();
33
+ };
35
34
  ```
36
35
 
37
-
38
36
  ## 1) Context Functions
39
37
 
40
38
  Context functions are polymorphic, it has different classes based on execution
@@ -0,0 +1,92 @@
1
+
2
+ declare class Component {
3
+ _id: string
4
+ type: string
5
+ refresh(): any;
6
+ show(): any;
7
+ hide(): any;
8
+ }
9
+ declare class Popup {
10
+ _id: string
11
+ type: string
12
+ getParameter(key: string): any;
13
+ getAllParameters(): any;
14
+ close(): any;
15
+ getComponent(componentId: string): Component;
16
+ }
17
+ declare class Page {
18
+ _id: string
19
+ popup: Popup
20
+ type: string
21
+ getParameter(key: string): any;
22
+ getAllParameters(): any;
23
+ getVariable(key: string): any;
24
+ setVariable(key: string, value: any): any;
25
+ openPopup(popupId: string, popupParams: object): any;
26
+ getComponent(componentId: string): Component;
27
+ }
28
+ declare class Application {
29
+ page: Page
30
+ _id: string
31
+ getVariable(key: string): any;
32
+ setVariable(key: string | object, value: any): any;
33
+ openPage(pageId: string, pageParams: object): any;
34
+ }
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
+ declare class kf {
74
+ static context: Component
75
+ static client: Client
76
+ static formatter: Formatter
77
+ static app: Application
78
+ static user: userObject
79
+ static account: accountObject
80
+ api(url: string, args?: {}): string | object;
81
+ }
82
+ declare type userObject = {
83
+ _id: string;
84
+ Name: string;
85
+ Email: string;
86
+ UserType: string;
87
+ Role: string;
88
+ };
89
+
90
+ declare type accountObject = {
91
+ _id: string;
92
+ };
@@ -0,0 +1,247 @@
1
+ declare module "constants" {
2
+ export const LISTENER_CMDS: {
3
+ API: string;
4
+ PARAMS: string;
5
+ GET_CONTEXT: string;
6
+ RETURN: string;
7
+ GET_FORM_FIELD: string;
8
+ UPDATE_FORM: string;
9
+ GET_TABLE: string;
10
+ GET_TABLE_ROW: string;
11
+ ADD_TABLE_ROW: 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
+ GET_COMPONENT: string;
37
+ COMPONENT_REFRESH: string;
38
+ COMPONENT_SHOW: string;
39
+ COMPONENT_HIDE: string;
40
+ INITIALIZE_CUST_COMP: string;
41
+ };
42
+ export const EVENT_TYPES: {
43
+ ON_CLOSE: string;
44
+ POPUP_ON_CLOSE: string;
45
+ ON_CHANGE: string;
46
+ ON_LOAD: string;
47
+ };
48
+ export const DEFAULTS: {
49
+ POPUP_ID: string;
50
+ };
51
+ }
52
+ declare module "base" {
53
+ export class BaseSDK {
54
+ #private;
55
+ constructor(props: any);
56
+ _postMessageAsync(command: string, args: any, hasCallBack?: boolean, callBack?: (data: any) => {}): object | string | any;
57
+ _postMessage(command: string, func: (data: any) => {}, args?: {}): void;
58
+ _registerEventListener(_id: string, eventType: string, callback: any): void;
59
+ }
60
+ }
61
+ declare module "types/external" {
62
+ export type userObject = {
63
+ _id: string;
64
+ Name: string;
65
+ Email: string;
66
+ UserType: string;
67
+ Role: string;
68
+ };
69
+ export type accountObject = {
70
+ _id: string;
71
+ };
72
+ }
73
+ declare module "types/internal" {
74
+ import { userObject, accountObject } from "types/external";
75
+ export interface SDKContext {
76
+ formInstanceId: string;
77
+ tableId: string;
78
+ tableRowId: string;
79
+ componentId: string;
80
+ manifestMethods?: manifestMethodsType[];
81
+ appId: string;
82
+ pageId: string;
83
+ popupId: string;
84
+ user: userObject;
85
+ account: accountObject;
86
+ }
87
+ export interface manifestMethodsType {
88
+ name: string;
89
+ returnType?: string;
90
+ parameters?: string[];
91
+ }
92
+ export interface ComponentProps {
93
+ componentId: string;
94
+ manifestMethods?: manifestMethodsType[];
95
+ }
96
+ export interface AppContext {
97
+ appId: string;
98
+ pageId: string;
99
+ }
100
+ export interface PageContext {
101
+ pageId: string;
102
+ }
103
+ export interface PopupContext {
104
+ popupId?: string;
105
+ }
106
+ }
107
+ declare module "component" {
108
+ import { BaseSDK } from "base";
109
+ import { ComponentProps } from "types/internal";
110
+ export class Component extends BaseSDK {
111
+ _id: string;
112
+ type: string;
113
+ constructor(props: ComponentProps);
114
+ refresh(): any;
115
+ show(): any;
116
+ hide(): any;
117
+ }
118
+ export class CustomComponent extends BaseSDK {
119
+ type: string;
120
+ constructor();
121
+ watchParams(func: (data: any) => any): void;
122
+ }
123
+ }
124
+ declare module "popup" {
125
+ import { Component } from "component";
126
+ import { BaseSDK } from "base";
127
+ import { PopupContext } from "types/internal";
128
+ export class Popup extends BaseSDK {
129
+ _id: string;
130
+ type: string;
131
+ constructor(props: PopupContext);
132
+ getParameter(key: string): any;
133
+ getAllParameters(): any;
134
+ close(): any;
135
+ getComponent(componentId: string): Component;
136
+ }
137
+ }
138
+ declare module "page" {
139
+ import { Component } from "component";
140
+ import { BaseSDK } from "base";
141
+ import { Popup } from "popup";
142
+ import { PageContext } from "types/internal";
143
+ export class Page extends BaseSDK {
144
+ _id: string;
145
+ popup: Popup;
146
+ type: string;
147
+ constructor(props: PageContext);
148
+ getParameter(key: string): any;
149
+ getAllParameters(): any;
150
+ getVariable(key: string): any;
151
+ setVariable(key: string, value: any): any;
152
+ openPopup(popupId: string, popupParams: object): any;
153
+ getComponent(componentId: string): Component;
154
+ }
155
+ }
156
+ declare module "app" {
157
+ import { BaseSDK } from "base";
158
+ import { Page } from "page";
159
+ import { AppContext } from "types/internal";
160
+ export class Application extends BaseSDK {
161
+ page: Page;
162
+ _id: string;
163
+ constructor(props: AppContext);
164
+ getVariable(key: string): any;
165
+ setVariable(key: string | object, value: any): any;
166
+ openPage(pageId: string, pageParams: object): any;
167
+ }
168
+ }
169
+ declare module "client" {
170
+ import { BaseSDK } from "base";
171
+ export class Client extends BaseSDK {
172
+ showInfo(message: string): any;
173
+ showConfirm(args: {
174
+ title: string;
175
+ content: string;
176
+ okText: string;
177
+ cancelText: string;
178
+ }): any;
179
+ redirect(url: string): any;
180
+ }
181
+ }
182
+ declare module "form" {
183
+ import { BaseSDK } from "base";
184
+ export class Form extends BaseSDK {
185
+ private instanceId;
186
+ type: string;
187
+ constructor(instanceId: string);
188
+ toJSON(): any;
189
+ getField(fieldId: string): any;
190
+ updateField(args: object): any;
191
+ getTable(tableId: string): Table;
192
+ }
193
+ class Table extends BaseSDK {
194
+ private tableId;
195
+ private instanceId;
196
+ constructor(instanceId: string, tableId: string);
197
+ toJSON(): any;
198
+ getRows(): TableForm[];
199
+ getRow(rowId: string): TableForm;
200
+ addRow(rowObject: object): any;
201
+ deleteRow(rowId: string): any;
202
+ }
203
+ export class TableForm extends BaseSDK {
204
+ private instanceId;
205
+ private tableId;
206
+ private rowId;
207
+ type: string;
208
+ constructor(instanceId: string, tableId: string, rowId: string);
209
+ getParent(): Form;
210
+ toJSON(): any;
211
+ getField(fieldId: string): any;
212
+ updateField(args: object): any;
213
+ }
214
+ }
215
+ declare module "formatter" {
216
+ import { BaseSDK } from "base";
217
+ export class Formatter extends BaseSDK {
218
+ toDate(date: string): any;
219
+ toDateTime(date: string): any;
220
+ toNumber(value: string): any;
221
+ toCurrency(value: string, currencyCode: string): any;
222
+ toBoolean(value: string): any;
223
+ }
224
+ }
225
+ declare module "index" {
226
+ import { BaseSDK } from "base";
227
+ import { Client } from "client";
228
+ import { Formatter } from "formatter";
229
+ import { Application } from "app";
230
+ import { Page } from "page";
231
+ import { CustomComponent } from "component";
232
+ import { userObject, accountObject } from "types/external";
233
+ class CustomComponentSDK extends BaseSDK {
234
+ app: Application;
235
+ page: Page;
236
+ user: userObject;
237
+ account: accountObject;
238
+ context: CustomComponent;
239
+ client: Client;
240
+ formatter: Formatter;
241
+ constructor();
242
+ api(url: string, args?: {}): string | object;
243
+ initialise(): any;
244
+ }
245
+ const _default: CustomComponentSDK;
246
+ export default _default;
247
+ }
@@ -0,0 +1,249 @@
1
+ declare module "constants" {
2
+ export const LISTENER_CMDS: {
3
+ API: string;
4
+ PARAMS: string;
5
+ GET_CONTEXT: string;
6
+ RETURN: string;
7
+ GET_FORM_FIELD: string;
8
+ UPDATE_FORM: string;
9
+ GET_TABLE: string;
10
+ GET_TABLE_ROW: string;
11
+ ADD_TABLE_ROW: 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
+ GET_COMPONENT: string;
37
+ COMPONENT_REFRESH: string;
38
+ COMPONENT_SHOW: string;
39
+ COMPONENT_HIDE: string;
40
+ INITIALIZE_CUST_COMP: string;
41
+ };
42
+ export const EVENT_TYPES: {
43
+ ON_CLOSE: string;
44
+ POPUP_ON_CLOSE: string;
45
+ ON_CHANGE: string;
46
+ ON_LOAD: string;
47
+ };
48
+ export const DEFAULTS: {
49
+ POPUP_ID: string;
50
+ };
51
+ }
52
+ declare module "base" {
53
+ export class BaseSDK {
54
+ #private;
55
+ constructor(props: any);
56
+ _postMessageAsync(command: string, args: any, hasCallBack?: boolean, callBack?: (data: any) => {}): object | string | any;
57
+ _postMessage(command: string, func: (data: any) => {}, args?: {}): void;
58
+ _registerEventListener(_id: string, eventType: string, callback: any): void;
59
+ }
60
+ }
61
+ declare module "types/external" {
62
+ export type userObject = {
63
+ _id: string;
64
+ Name: string;
65
+ Email: string;
66
+ UserType: string;
67
+ Role: string;
68
+ };
69
+ export type accountObject = {
70
+ _id: string;
71
+ };
72
+ }
73
+ declare module "types/internal" {
74
+ import { userObject, accountObject } from "types/external";
75
+ export interface SDKContext {
76
+ formInstanceId: string;
77
+ tableId: string;
78
+ tableRowId: string;
79
+ componentId: string;
80
+ manifestMethods?: manifestMethodsType[];
81
+ appId: string;
82
+ pageId: string;
83
+ popupId: string;
84
+ user: userObject;
85
+ account: accountObject;
86
+ }
87
+ export interface manifestMethodsType {
88
+ name: string;
89
+ returnType?: string;
90
+ parameters?: string[];
91
+ }
92
+ export interface ComponentProps {
93
+ componentId: string;
94
+ manifestMethods?: manifestMethodsType[];
95
+ }
96
+ export interface AppContext {
97
+ appId: string;
98
+ pageId: string;
99
+ }
100
+ export interface PageContext {
101
+ pageId: string;
102
+ }
103
+ export interface PopupContext {
104
+ popupId?: string;
105
+ }
106
+ }
107
+ declare module "component" {
108
+ import { BaseSDK } from "base";
109
+ import { ComponentProps } from "types/internal";
110
+ export class Component extends BaseSDK {
111
+ _id: string;
112
+ type: string;
113
+ constructor(props: ComponentProps);
114
+ refresh(): any;
115
+ show(): any;
116
+ hide(): any;
117
+ }
118
+ export class CustomComponent extends BaseSDK {
119
+ type: string;
120
+ constructor();
121
+ watchParams(func: (data: any) => any): void;
122
+ }
123
+ }
124
+ declare module "popup" {
125
+ import { Component } from "component";
126
+ import { BaseSDK } from "base";
127
+ import { PopupContext } from "types/internal";
128
+ export class Popup extends BaseSDK {
129
+ _id: string;
130
+ type: string;
131
+ constructor(props: PopupContext);
132
+ getParameter(key: string): any;
133
+ getAllParameters(): any;
134
+ close(): any;
135
+ getComponent(componentId: string): Component;
136
+ }
137
+ }
138
+ declare module "page" {
139
+ import { Component } from "component";
140
+ import { BaseSDK } from "base";
141
+ import { Popup } from "popup";
142
+ import { PageContext } from "types/internal";
143
+ export class Page extends BaseSDK {
144
+ _id: string;
145
+ popup: Popup;
146
+ type: string;
147
+ constructor(props: PageContext);
148
+ getParameter(key: string): any;
149
+ getAllParameters(): any;
150
+ getVariable(key: string): any;
151
+ setVariable(key: string, value: any): any;
152
+ openPopup(popupId: string, popupParams: object): any;
153
+ getComponent(componentId: string): Component;
154
+ }
155
+ }
156
+ declare module "app" {
157
+ import { BaseSDK } from "base";
158
+ import { Page } from "page";
159
+ import { AppContext } from "types/internal";
160
+ export class Application extends BaseSDK {
161
+ page: Page;
162
+ _id: string;
163
+ constructor(props: AppContext);
164
+ getVariable(key: string): any;
165
+ setVariable(key: string | object, value: any): any;
166
+ openPage(pageId: string, pageParams: object): any;
167
+ }
168
+ }
169
+ declare module "client" {
170
+ import { BaseSDK } from "base";
171
+ export class Client extends BaseSDK {
172
+ showInfo(message: string): any;
173
+ showConfirm(args: {
174
+ title: string;
175
+ content: string;
176
+ okText: string;
177
+ cancelText: string;
178
+ }): any;
179
+ redirect(url: string): any;
180
+ }
181
+ }
182
+ declare module "form" {
183
+ import { BaseSDK } from "base";
184
+ export class Form extends BaseSDK {
185
+ private instanceId;
186
+ type: string;
187
+ constructor(instanceId: string);
188
+ toJSON(): any;
189
+ getField(fieldId: string): any;
190
+ updateField(args: object): any;
191
+ getTable(tableId: string): Table;
192
+ }
193
+ class Table extends BaseSDK {
194
+ private tableId;
195
+ private instanceId;
196
+ constructor(instanceId: string, tableId: string);
197
+ toJSON(): any;
198
+ getRows(): TableForm[];
199
+ getRow(rowId: string): TableForm;
200
+ addRow(rowObject: object): any;
201
+ deleteRow(rowId: string): any;
202
+ }
203
+ export class TableForm extends BaseSDK {
204
+ private instanceId;
205
+ private tableId;
206
+ private rowId;
207
+ type: string;
208
+ constructor(instanceId: string, tableId: string, rowId: string);
209
+ getParent(): Form;
210
+ toJSON(): any;
211
+ getField(fieldId: string): any;
212
+ updateField(args: object): any;
213
+ }
214
+ }
215
+ declare module "formatter" {
216
+ import { BaseSDK } from "base";
217
+ export class Formatter extends BaseSDK {
218
+ toDate(date: string): any;
219
+ toDateTime(date: string): any;
220
+ toNumber(value: string): any;
221
+ toCurrency(value: string, currencyCode: string): any;
222
+ toBoolean(value: string): any;
223
+ }
224
+ }
225
+ declare module "lowcode" {
226
+ import { BaseSDK } from "base";
227
+ import { Form } from "form";
228
+ import { TableForm } from "form";
229
+ import { Client } from "client";
230
+ import { Formatter } from "formatter";
231
+ import { Application } from "app";
232
+ import { Page } from "page";
233
+ import { Component } from "component";
234
+ import { Popup } from "popup";
235
+ import { SDKContext } from "types/internal";
236
+ import { userObject, accountObject } from "types/external";
237
+ class LowcodeSDK extends BaseSDK {
238
+ context: Component | Form | TableForm | Page | Popup;
239
+ client: Client;
240
+ formatter: Formatter;
241
+ app: Application;
242
+ user: userObject;
243
+ account: accountObject;
244
+ constructor(props: SDKContext);
245
+ api(url: string, args?: {}): string | object;
246
+ }
247
+ function initSDK(config: SDKContext): LowcodeSDK;
248
+ export default initSDK;
249
+ }
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@kissflow/lowcode-client-sdk",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "JavaScript SDK for developing over the Kissflow lowcode platform",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
7
- "dist"
7
+ "dist/"
8
8
  ],
9
9
  "main": "./dist/kfsdk.umd.js",
10
10
  "module": "./dist/kfsdk.es.js",
@@ -21,7 +21,7 @@
21
21
  "start": "vite serve",
22
22
  "customBuild": "node custom.build.mjs",
23
23
  "build": "pnpm run customBuild",
24
- "prepare": "vite build",
24
+ "prepare": "pnpm run customBuild",
25
25
  "serve": "http-server -p 8080"
26
26
  },
27
27
  "repository": {