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