@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
@@ -0,0 +1,319 @@
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 "types/external" {
140
+ export type userObject = {
141
+ _id: string;
142
+ Name: string;
143
+ Email: string;
144
+ Role: string;
145
+ };
146
+ export type accountObject = {
147
+ _id: string;
148
+ };
149
+ export type environmentObject = {
150
+ isMobile: boolean;
151
+ };
152
+ }
153
+ declare module "types/internal" {
154
+ import { userObject, accountObject, environmentObject } from "types/external";
155
+ export interface SDKContext {
156
+ formInstanceId: string;
157
+ tableId: string;
158
+ tableRowId: string;
159
+ componentId: string;
160
+ componentMethods?: componentMethodsType[];
161
+ appId: string;
162
+ pageId: string;
163
+ popupId: string;
164
+ user: userObject;
165
+ account: accountObject;
166
+ csrfToken: string;
167
+ envDetails: environmentObject;
168
+ }
169
+ export interface componentMethodsType {
170
+ name: string;
171
+ returnType?: string;
172
+ parameters?: string[];
173
+ }
174
+ export interface ComponentProps {
175
+ componentId: string;
176
+ componentMethods?: componentMethodsType[];
177
+ }
178
+ export interface AppContext {
179
+ appId: string;
180
+ pageId: string;
181
+ }
182
+ export interface PageContext {
183
+ pageId: string;
184
+ }
185
+ export interface PopupContext {
186
+ popupId?: string;
187
+ }
188
+ }
189
+ declare module "app/component" {
190
+ import { BaseSDK } from "core/index";
191
+ import { ComponentProps } from "types/internal";
192
+ export class Component extends BaseSDK {
193
+ #private;
194
+ _id: string;
195
+ type: string;
196
+ constructor(props: ComponentProps);
197
+ onMount(callback: Function): void;
198
+ refresh(): any;
199
+ show(): any;
200
+ hide(): any;
201
+ }
202
+ export class CustomComponent extends BaseSDK {
203
+ type: string;
204
+ _id: string;
205
+ constructor(id: any);
206
+ watchParams(callBack: (data: any) => any): void;
207
+ }
208
+ }
209
+ declare module "app/popup" {
210
+ import { BaseSDK } from "core/index";
211
+ import { Component } from "app/component";
212
+ import { PopupContext } from "types/internal";
213
+ export class Popup extends BaseSDK {
214
+ _id: string;
215
+ type: string;
216
+ constructor(props: PopupContext);
217
+ getParameter(key: string): any;
218
+ getAllParameters(): any;
219
+ close(): any;
220
+ getComponent(componentId: string): Component;
221
+ }
222
+ }
223
+ declare module "app/page" {
224
+ import { BaseSDK } from "core/index";
225
+ import { Component } from "app/component";
226
+ import { Popup } from "app/popup";
227
+ import { PageContext } from "types/internal";
228
+ export class Page extends BaseSDK {
229
+ _id: string;
230
+ popup: Popup;
231
+ type: string;
232
+ constructor(props: PageContext);
233
+ getParameter(key: string): any;
234
+ getAllParameters(): any;
235
+ getVariable(key: string): any;
236
+ setVariable(key: string, value: any): any;
237
+ openPopup(popupId: string, popupParams: object): any;
238
+ getComponent(componentId: string): Component;
239
+ }
240
+ }
241
+ declare module "app/decisiontable" {
242
+ import { BaseSDK } from "core/index";
243
+ export class DecisionTable extends BaseSDK {
244
+ private flowId;
245
+ constructor(flowId: string);
246
+ evaluate(payload?: object): any;
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/index" {
258
+ import { BaseSDK } from "core/index";
259
+ import { Page } from "app/page";
260
+ import { AppContext } from "types/internal";
261
+ import { DecisionTable } from "app/decisiontable";
262
+ import { Dataform } from "app/dataform";
263
+ export class Application extends BaseSDK {
264
+ page: Page;
265
+ _id: string;
266
+ constructor(props: AppContext);
267
+ getVariable(key: string): any;
268
+ setVariable(key: string | object, value?: any): any;
269
+ openPage(pageId: string, pageParams: object): any;
270
+ getDecisionTable(flowId: string): DecisionTable;
271
+ getDataform(flowId: string): Dataform;
272
+ }
273
+ export * from "app/component";
274
+ export { Page };
275
+ export * from "app/popup";
276
+ }
277
+ declare module "window/NDEFReader" {
278
+ import { BaseSDK } from "core/index";
279
+ export class NDEFReader extends BaseSDK {
280
+ id: string;
281
+ constructor();
282
+ scan(): Promise<unknown>;
283
+ write(data: any): Promise<unknown>;
284
+ addEventListener(eventName: string, cb: Function): void;
285
+ makeReadOnly(): Promise<unknown>;
286
+ abortScan(): Promise<unknown>;
287
+ }
288
+ }
289
+ declare module "window/index" {
290
+ import { NDEFReader } from "window/NDEFReader";
291
+ export const window: {
292
+ NDEFReader: typeof NDEFReader;
293
+ };
294
+ }
295
+ declare module "lowcode" {
296
+ import { BaseSDK } from "core/index";
297
+ import { Form, TableForm } from "form/index";
298
+ import { Client, Formatter } from "utils/index";
299
+ import { Application, Page, Component, Popup } from "app/index";
300
+ import { window } from "window/index";
301
+ import { SDKContext } from "types/internal";
302
+ import { userObject, accountObject, environmentObject } from "types/external";
303
+ class LowcodeSDK extends BaseSDK {
304
+ #private;
305
+ context: Component | Form | TableForm | Page | Popup;
306
+ client: Client;
307
+ formatter: Formatter;
308
+ app: Application;
309
+ user: userObject;
310
+ env: environmentObject;
311
+ account: accountObject;
312
+ constructor(props: SDKContext);
313
+ api(url: string, args?: {
314
+ headers: object;
315
+ }): Promise<any>;
316
+ }
317
+ function initSDK(config: SDKContext): LowcodeSDK;
318
+ export { window, initSDK as default };
319
+ }
@@ -0,0 +1,106 @@
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 Component {
43
+ _id: string
44
+ type: string
45
+ onMount(callback: Function): void;
46
+ refresh(): any;
47
+ show(): any;
48
+ hide(): any;
49
+ }
50
+ declare class Popup {
51
+ _id: string
52
+ type: string
53
+ getParameter(key: string): any;
54
+ getAllParameters(): any;
55
+ close(): any;
56
+ getComponent(componentId: string): Component;
57
+ }
58
+ declare class Page {
59
+ _id: string
60
+ popup: Popup
61
+ type: string
62
+ getParameter(key: string): any;
63
+ getAllParameters(): any;
64
+ getVariable(key: string): any;
65
+ setVariable(key: string, value: any): any;
66
+ openPopup(popupId: string, popupParams: object): any;
67
+ getComponent(componentId: string): Component;
68
+ }
69
+ declare class DecisionTable {
70
+ evaluate(payload?: object): any;
71
+ }
72
+ declare class Application {
73
+ page: Page
74
+ _id: string
75
+ getVariable(key: string): any;
76
+ setVariable(key: string | object, value?: any): any;
77
+ openPage(pageId: string, pageParams: object): any;
78
+ getDecisionTable(flowId: string): DecisionTable;
79
+ getDataform(flowId: string): Dataform;
80
+ }
81
+ declare class kf {
82
+ static context: Component
83
+ static client: Client
84
+ static formatter: Formatter
85
+ static app: Application
86
+ static user: userObject
87
+ static env: environmentObject
88
+ static account: accountObject
89
+ api(url: string, args?: {
90
+ headers: object;
91
+ }): Promise<any>;
92
+ }
93
+ declare type userObject = {
94
+ _id: string;
95
+ Name: string;
96
+ Email: string;
97
+ Role: string;
98
+ };
99
+
100
+ declare type accountObject = {
101
+ _id: string;
102
+ };
103
+
104
+ declare type environmentObject = {
105
+ isMobile: boolean
106
+ }