@kissflow/lowcode-client-sdk 1.0.0 → 1.0.2-0.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/dist/index.d.ts CHANGED
@@ -1,12 +1,17 @@
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;
8
7
  UPDATE_FORM: string;
8
+ GET_TABLE: string;
9
+ GET_TABLE_ROW: string;
9
10
  ADD_TABLE_ROW: string;
11
+ ADD_TABLE_ROWS: string;
12
+ DELETE_TABLE_ROW: string;
13
+ TO_JSON: string;
14
+ GET_TABLE_ROWS: string;
10
15
  MESSAGE: string;
11
16
  CONFIRM: string;
12
17
  ALERT: string;
@@ -22,108 +27,279 @@ declare module "constants" {
22
27
  GET_PAGE_VARIABLE: string;
23
28
  SET_PAGE_VARIABLE: string;
24
29
  GET_PAGE_PARAMS: string;
25
- OPEN_POPUP_PAGE: string;
30
+ GET_ALL_PAGE_PARAMS: string;
26
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;
27
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;
28
50
  };
29
51
  export const EVENT_TYPES: {
30
- ON_CLOSE: string;
31
- ON_CHANGE: string;
32
- ON_LOAD: string;
52
+ COMPONENT_ON_MOUNT: string;
53
+ CC_ON_PARAMS_CHANGE: string;
33
54
  };
55
+ export const DEFAULTS: {
56
+ POPUP_ID: string;
57
+ };
58
+ }
59
+ declare module "core/index" {
60
+ export function generateId(prefix?: string): string;
61
+ export const globalInstances: {};
62
+ export class EventBase {
63
+ #private;
64
+ constructor();
65
+ _addEventListener(eventName: string, callBack: Function): void;
66
+ _removeEventListener(eventName: string, callBack?: any): void;
67
+ _dispatchEvent(eventName: string, eventParams: object): boolean;
68
+ _dispatchMessageEvents(req: any, resp: any): void;
69
+ }
70
+ export class BaseSDK extends EventBase {
71
+ _postMessageAsync(command: string, args: any, hasCallBack?: boolean, callBack?: (data: any) => {}): object | string | any;
72
+ _postMessage(command: string, args: any, callBack?: any): void;
73
+ }
74
+ export * from "core/constants";
75
+ }
76
+ declare module "types/external" {
77
+ export type userObject = {
78
+ _id: string;
79
+ Name: string;
80
+ Email: string;
81
+ Role: string;
82
+ };
83
+ export type accountObject = {
84
+ _id: string;
85
+ };
86
+ export type environmentObject = {
87
+ isMobile: boolean;
88
+ };
89
+ }
90
+ declare module "types/internal" {
91
+ import { userObject, accountObject, environmentObject } from "types/external";
92
+ export interface SDKContext {
93
+ formInstanceId: string;
94
+ tableId: string;
95
+ tableRowId: string;
96
+ componentId: string;
97
+ componentMethods?: componentMethodsType[];
98
+ appId: string;
99
+ pageId: string;
100
+ popupId: string;
101
+ user: userObject;
102
+ account: accountObject;
103
+ csrfToken: string;
104
+ envDetails: environmentObject;
105
+ }
106
+ export interface componentMethodsType {
107
+ name: string;
108
+ returnType?: string;
109
+ parameters?: string[];
110
+ }
111
+ export interface ComponentProps {
112
+ componentId: string;
113
+ componentMethods?: componentMethodsType[];
114
+ }
115
+ export interface AppContext {
116
+ appId: string;
117
+ pageId: string;
118
+ }
119
+ export interface PageContext {
120
+ pageId: string;
121
+ }
122
+ export interface PopupContext {
123
+ popupId?: string;
124
+ }
34
125
  }
35
- declare module "base" {
36
- export class BaseSDK {
126
+ declare module "app/component" {
127
+ import { BaseSDK } from "core/index";
128
+ import { ComponentProps } from "types/internal";
129
+ export class Component extends BaseSDK {
37
130
  #private;
38
- constructor(props: any);
39
- _postMessageAsync(command: string, args: any, hasCallBack?: boolean, callBack?: (data: any) => {}): object | string;
40
- _postMessage(command: string, func: (data: any) => {}, args?: {}): void;
41
- _registerEventListener(_id: string, eventType: string, callback: any): void;
131
+ _id: string;
132
+ type: string;
133
+ constructor(props: ComponentProps);
134
+ onMount(callback: Function): void;
135
+ refresh(): any;
136
+ show(): any;
137
+ hide(): any;
138
+ }
139
+ export class CustomComponent extends BaseSDK {
140
+ type: string;
141
+ _id: string;
142
+ constructor(id: any);
143
+ watchParams(callBack: (data: any) => any): void;
144
+ }
145
+ }
146
+ declare module "app/popup" {
147
+ import { BaseSDK } from "core/index";
148
+ import { Component } from "app/component";
149
+ import { PopupContext } from "types/internal";
150
+ export class Popup extends BaseSDK {
151
+ _id: string;
152
+ type: string;
153
+ constructor(props: PopupContext);
154
+ getParameter(key: string): any;
155
+ getAllParameters(): any;
156
+ close(): any;
157
+ getComponent(componentId: string): Component;
42
158
  }
43
159
  }
44
- declare module "page" {
45
- import { BaseSDK } from "base";
160
+ declare module "app/page" {
161
+ import { BaseSDK } from "core/index";
162
+ import { Component } from "app/component";
163
+ import { Popup } from "app/popup";
164
+ import { PageContext } from "types/internal";
46
165
  export class Page extends BaseSDK {
47
166
  _id: string;
48
- constructor(pageId: string);
49
- getParameter(key: string): string | object;
50
- getVariable(key: string): string | object;
51
- setVariable(key: string, value: any): string | object;
52
- openPopup(pageId: string, inputParams: object, popupProperties: {
53
- w: number;
54
- h: number;
55
- }): string | object;
56
- onClose(callback: Function): void;
57
- }
58
- }
59
- declare module "app" {
60
- import { BaseSDK } from "base";
61
- import { Page } from "page";
167
+ popup: Popup;
168
+ type: string;
169
+ constructor(props: PageContext);
170
+ getParameter(key: string): any;
171
+ getAllParameters(): any;
172
+ getVariable(key: string): any;
173
+ setVariable(key: string, value: any): any;
174
+ openPopup(popupId: string, popupParams: object): any;
175
+ getComponent(componentId: string): Component;
176
+ }
177
+ }
178
+ declare module "app/decisiontable" {
179
+ import { BaseSDK } from "core/index";
180
+ export class DecisionTable extends BaseSDK {
181
+ private flowId;
182
+ constructor(flowId: string);
183
+ evaluate(payload?: object): any;
184
+ }
185
+ }
186
+ declare module "app/index" {
187
+ import { BaseSDK } from "core/index";
188
+ import { Page } from "app/page";
189
+ import { AppContext } from "types/internal";
190
+ import { DecisionTable } from "app/decisiontable";
62
191
  export class Application extends BaseSDK {
63
192
  page: Page;
64
- constructor(props: any);
65
- getVariable(key: string): string | object;
66
- setVariable(key: string | object, value: any): string | object;
67
- openPage(pageId: string, pageParams: object): string | object;
193
+ _id: string;
194
+ constructor(props: AppContext);
195
+ getVariable(key: string): any;
196
+ setVariable(key: string | object, value?: any): any;
197
+ openPage(pageId: string, pageParams: object): any;
198
+ getDecisionTable(flowId: string): DecisionTable;
68
199
  }
200
+ export * from "app/component";
201
+ export { Page };
202
+ export * from "app/popup";
69
203
  }
70
- declare module "client" {
71
- import { BaseSDK } from "base";
204
+ declare module "utils/client" {
205
+ import { BaseSDK } from "core/index";
72
206
  export class Client extends BaseSDK {
73
- showInfo(message: string): string | object;
207
+ showInfo(message: string): any;
74
208
  showConfirm(args: {
75
209
  title: string;
76
210
  content: string;
77
211
  okText: string;
78
212
  cancelText: string;
79
- }): string | object;
80
- redirect(url: string): string | object;
213
+ }): any;
214
+ redirect(url: string): any;
81
215
  }
82
216
  }
83
- declare module "component" {
84
- import { BaseSDK } from "base";
85
- export class Component extends BaseSDK {
86
- id: string;
87
- constructor(id: string);
88
- refresh(): string | object;
217
+ declare module "utils/formatter" {
218
+ import { BaseSDK } from "core/index";
219
+ export class Formatter extends BaseSDK {
220
+ toDate(date: string): any;
221
+ toDateTime(date: string): any;
222
+ toNumber(value: string): any;
223
+ toCurrency(value: string, currencyCode: string): any;
224
+ toBoolean(value: string): any;
89
225
  }
90
226
  }
91
- declare module "form" {
92
- import { BaseSDK } from "base";
93
- export class Form extends BaseSDK {
94
- getField(fieldId: string): string | object;
95
- updateField(args: object): string | object;
96
- addTableRow(tableId: string, rowObject: object): string | object;
97
- }
227
+ declare module "utils/index" {
228
+ export * from "utils/client";
229
+ export * from "utils/formatter";
98
230
  }
99
- declare module "formatter" {
100
- import { BaseSDK } from "base";
101
- export class Formatter extends BaseSDK {
102
- toKfDate(date: string): string | object;
103
- toKfDateTime(date: string): string | object;
104
- toKfNumber(value: string): string | object;
105
- toKfCurrency(value: string, currencyCode: string): string | object;
106
- toBoolean(value: string): string | object;
107
- }
108
- }
109
- declare module "lowcode.sdk" {
110
- import { BaseSDK } from "base";
111
- import { Form } from "form";
112
- import { Client } from "client";
113
- import { Formatter } from "formatter";
114
- import { Application } from "app";
115
- import { Component } from "component";
116
- export class LowcodeSDK extends BaseSDK {
117
- currentForm: Form;
231
+ declare module "index" {
232
+ import { BaseSDK } from "core/index";
233
+ import { Application, Page, CustomComponent } from "app/index";
234
+ import { Client, Formatter } from "utils/index";
235
+ import { userObject, accountObject, environmentObject } from "types/external";
236
+ class CustomComponentSDK extends BaseSDK {
237
+ app: Application;
238
+ page: Page;
239
+ user: userObject;
240
+ account: accountObject;
241
+ context: CustomComponent;
118
242
  client: Client;
119
243
  formatter: Formatter;
120
- app: Application;
121
- constructor(props: any);
244
+ env: environmentObject;
245
+ constructor();
122
246
  api(url: string, args?: {}): string | object;
123
- watchParams(func: (data: any) => any): void;
124
- getContext(): string | object;
125
- getComponent(componentId: string): Component;
247
+ initialize(): any;
248
+ initialise(): any;
249
+ }
250
+ const _default: CustomComponentSDK;
251
+ export default _default;
252
+ }
253
+ declare module "form/index" {
254
+ import { BaseSDK } from "core/index";
255
+ export class Form extends BaseSDK {
256
+ private instanceId;
257
+ type: string;
258
+ constructor(instanceId: string);
259
+ toJSON(): any;
260
+ getField(fieldId: string): any;
261
+ updateField(args: object): any;
262
+ getTable(tableId: string): Table;
263
+ }
264
+ class Table extends BaseSDK {
265
+ private tableId;
266
+ private instanceId;
267
+ constructor(instanceId: string, tableId: string);
268
+ toJSON(): any;
269
+ getRows(): TableForm[];
270
+ getRow(rowId: string): TableForm;
271
+ addRow(rowObject: object): any;
272
+ addRows(rows: [object]): any;
273
+ deleteRow(rowId: string): any;
274
+ deleteRows(rows: [string]): any;
126
275
  }
127
- function initSDK(config?: any): LowcodeSDK;
128
- export default initSDK;
276
+ export class TableForm extends BaseSDK {
277
+ private instanceId;
278
+ private tableId;
279
+ private rowId;
280
+ type: string;
281
+ constructor(instanceId: string, tableId: string, rowId: string);
282
+ getParent(): Form;
283
+ toJSON(): any;
284
+ getField(fieldId: string): any;
285
+ updateField(args: object): any;
286
+ }
287
+ }
288
+ declare module "window/NDEFReader" {
289
+ import { BaseSDK } from "core/index";
290
+ export class NDEFReader extends BaseSDK {
291
+ id: string;
292
+ constructor();
293
+ scan(): Promise<unknown>;
294
+ write(data: any): Promise<unknown>;
295
+ addEventListener(eventName: string, cb: Function): void;
296
+ makeReadOnly(): Promise<unknown>;
297
+ abortScan(): Promise<unknown>;
298
+ }
299
+ }
300
+ declare module "window/index" {
301
+ import { NDEFReader } from "window/NDEFReader";
302
+ export const window: {
303
+ NDEFReader: typeof NDEFReader;
304
+ };
129
305
  }