@kissflow/lowcode-client-sdk 1.0.13 → 1.0.14

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.
@@ -0,0 +1,441 @@
1
+ var __accessCheck = (obj, member, msg) => {
2
+ if (!member.has(obj))
3
+ throw TypeError("Cannot " + msg);
4
+ };
5
+ var __privateGet = (obj, member, getter) => {
6
+ __accessCheck(obj, member, "read from private field");
7
+ return getter ? getter.call(obj) : member.get(obj);
8
+ };
9
+ var __privateAdd = (obj, member, value) => {
10
+ if (member.has(obj))
11
+ throw TypeError("Cannot add the same private member more than once");
12
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
13
+ };
14
+ var __privateSet = (obj, member, value, setter) => {
15
+ __accessCheck(obj, member, "write to private field");
16
+ setter ? setter.call(obj, value) : member.set(obj, value);
17
+ return value;
18
+ };
19
+ var _listeners, _csrfToken;
20
+ let nanoid = (size = 21) => crypto.getRandomValues(new Uint8Array(size)).reduce((id, byte) => {
21
+ byte &= 63;
22
+ if (byte < 36) {
23
+ id += byte.toString(36);
24
+ } else if (byte < 62) {
25
+ id += (byte - 26).toString(36).toUpperCase();
26
+ } else if (byte > 62) {
27
+ id += "-";
28
+ } else {
29
+ id += "_";
30
+ }
31
+ return id;
32
+ }, "");
33
+ const LISTENER_CMDS = {
34
+ API: "API",
35
+ GET_CONTEXT: "GET_CONTEXT",
36
+ RETURN: "RETURN",
37
+ GET_FORM_FIELD: "GET_FORM_FIELD",
38
+ UPDATE_FORM: "UPDATE_FORM",
39
+ GET_TABLE: "GET_TABLE",
40
+ GET_TABLE_ROW: "GET_TABLE_ROW",
41
+ ADD_TABLE_ROW: "ADD_TABLE_ROW",
42
+ DELETE_TABLE_ROW: "DELETE_TABLE_ROW",
43
+ TO_JSON: "TO_JSON",
44
+ GET_TABLE_ROWS: "GET_TABLE_ROWS",
45
+ MESSAGE: "MESSAGE",
46
+ CONFIRM: "CONFIRM",
47
+ ALERT: "ALERT",
48
+ REDIRECT: "REDIRECT",
49
+ OPEN_PAGE: "OPEN_PAGE",
50
+ FORMAT_DATE: "FORMAT_DATE",
51
+ FORMAT_DATE_TIME: "FORMAT_DATE_TIME",
52
+ FORMAT_NUMBER: "FORMAT_NUMBER",
53
+ FORMAT_CURRENCY: "FORMAT_CURRENCY",
54
+ FORMAT_BOOLEAN: "FORMAT_BOOLEAN",
55
+ GET_APP_VARIABLE: "GET_APP_VARIABLE",
56
+ SET_APP_VARIABLE: "SET_APP_VARIABLE",
57
+ GET_PAGE_VARIABLE: "GET_PAGE_VARIABLE",
58
+ SET_PAGE_VARIABLE: "SET_PAGE_VARIABLE",
59
+ GET_PAGE_PARAMS: "GET_PAGE_PARAMS",
60
+ GET_ALL_PAGE_PARAMS: "GET_ALL_PAGE_PARAMS",
61
+ PAGE_ON_CLOSE: "PAGE_ON_CLOSE",
62
+ OPEN_POPUP: "OPEN_POPUP",
63
+ GET_POPUP_PARAMS: "GET_POPUP_PARAMS",
64
+ GET_ALL_POPUP_PARAMS: "GET_ALL_POPUP_PARAMS",
65
+ CLOSE_POPUP: "CLOSE_POPUP",
66
+ COMPONENT_GET: "COMPONENT_GET",
67
+ COMPONENT_REFRESH: "COMPONENT_REFRESH",
68
+ COMPONENT_SHOW: "COMPONENT_SHOW",
69
+ COMPONENT_HIDE: "COMPONENT_HIDE",
70
+ COMPONENT_ADD_EVENT_LISTENER: "COMPONENT_ADD_EVENT_LISTENER",
71
+ CC_INITIALIZE: "CC_INITIALIZE",
72
+ CC_WATCH_PARAMS: "CC_WATCH_PARAMS",
73
+ WINDOW_NDEF_READER_NEW: "WINDOW_NDEF_READER_NEW",
74
+ WINDOW_NDEF_READER_SCAN: "WINDOW_NDEF_READER_SCAN",
75
+ WINDOW_NDEF_READER_WRITE: "WINDOW_NDEF_READER_WRITE",
76
+ WINDOW_NDEF_READER_ADD_EVENT_LISTENER: "WINDOW_NDEF_READER_ADD_EVENT_LISTENER",
77
+ WINDOW_NDEF_READER_MAKE_READONLY: "WINDOW_NDEF_READER_MAKE_READONLY",
78
+ WINDOW_NDEF_READER_ABORT_SCAN: "WINDOW_NDEF_READER_ABORT_SCAN"
79
+ };
80
+ function generateId(prefix = "lcncsdk") {
81
+ return `${prefix}-${nanoid()}`;
82
+ }
83
+ const globalInstances = {};
84
+ function postMessage(args) {
85
+ if (globalThis.parent && globalThis.parent !== globalThis) {
86
+ globalThis.parent.postMessage(args, "*");
87
+ } else {
88
+ globalThis.postMessage(args);
89
+ }
90
+ }
91
+ function onMessage(event) {
92
+ if (event.origin !== globalThis.location.origin) {
93
+ const data = event.data;
94
+ if (data == null ? void 0 : data.isEvent) {
95
+ const { target, eventParams, eventName, eventConfig = {} } = data;
96
+ let targetInstance = globalInstances[target];
97
+ targetInstance._dispatchEvent(eventName, eventParams);
98
+ if (eventConfig.once) {
99
+ targetInstance._removeEventListener(eventName);
100
+ }
101
+ return;
102
+ }
103
+ let { _req: req, resp } = data;
104
+ if (req == null ? void 0 : req._id) {
105
+ let targetInstance = globalInstances[req._id];
106
+ targetInstance._dispatchMessageEvents(req, resp);
107
+ }
108
+ }
109
+ }
110
+ globalThis.addEventListener("message", onMessage);
111
+ class EventBase {
112
+ constructor() {
113
+ __privateAdd(this, _listeners, void 0);
114
+ __privateSet(this, _listeners, {});
115
+ }
116
+ _addEventListener(eventName, callBack) {
117
+ var _a;
118
+ __privateGet(this, _listeners)[eventName] = ((_a = __privateGet(this, _listeners)) == null ? void 0 : _a[eventName]) || [];
119
+ __privateGet(this, _listeners)[eventName].push(callBack);
120
+ }
121
+ _removeEventListener(eventName, callBack) {
122
+ if (callBack) {
123
+ let index = __privateGet(this, _listeners)[eventName].findIndex(callBack);
124
+ index > -1 && __privateGet(this, _listeners)[eventName].splice(index, 1);
125
+ return;
126
+ }
127
+ Reflect.deleteProperty(__privateGet(this, _listeners), eventName);
128
+ }
129
+ _dispatchEvent(eventName, eventParams) {
130
+ if (Array.isArray(__privateGet(this, _listeners)[eventName])) {
131
+ __privateGet(this, _listeners)[eventName].forEach(
132
+ (callBack) => callBack(eventParams)
133
+ );
134
+ return true;
135
+ }
136
+ return false;
137
+ }
138
+ _dispatchMessageEvents(req, resp) {
139
+ let target = req._id;
140
+ if (Array.isArray(__privateGet(this, _listeners)[target])) {
141
+ __privateGet(this, _listeners)[target].forEach((listener) => {
142
+ try {
143
+ if (resp && Object.keys(resp).length === 1 && req.command !== LISTENER_CMDS.API) {
144
+ listener(Object.values(resp)[0]);
145
+ } else {
146
+ listener(resp);
147
+ }
148
+ } catch (err) {
149
+ console.error("Message callback error: ", err);
150
+ }
151
+ });
152
+ this._removeEventListener(target);
153
+ }
154
+ }
155
+ }
156
+ _listeners = new WeakMap();
157
+ class BaseSDK extends EventBase {
158
+ _postMessageAsync(command, args, hasCallBack, callBack) {
159
+ return new Promise((resolve, reject) => {
160
+ const _id = generateId(command.toLowerCase());
161
+ postMessage({ _id, command, ...args });
162
+ globalInstances[_id] = this;
163
+ this._addEventListener(_id, async (data) => {
164
+ if (data == null ? void 0 : data.errorMessage) {
165
+ reject(data);
166
+ } else {
167
+ if (hasCallBack && callBack) {
168
+ data = await callBack(data);
169
+ }
170
+ resolve(data);
171
+ }
172
+ });
173
+ });
174
+ }
175
+ _postMessage(command, args, callBack) {
176
+ const _id = generateId(command.toLowerCase());
177
+ postMessage({ _id, command, ...args });
178
+ if (callBack) {
179
+ this._addEventListener(args.eventName, callBack);
180
+ }
181
+ }
182
+ }
183
+ class Form extends BaseSDK {
184
+ constructor(instanceId) {
185
+ super();
186
+ this.type = "Form";
187
+ this.instanceId = instanceId;
188
+ }
189
+ toJSON() {
190
+ return this._postMessageAsync(LISTENER_CMDS.TO_JSON, {
191
+ instanceId: this.instanceId
192
+ });
193
+ }
194
+ getField(fieldId) {
195
+ return this._postMessageAsync(LISTENER_CMDS.GET_FORM_FIELD, {
196
+ instanceId: this.instanceId,
197
+ fieldId
198
+ });
199
+ }
200
+ updateField(args) {
201
+ return this._postMessageAsync(LISTENER_CMDS.UPDATE_FORM, {
202
+ data: args
203
+ });
204
+ }
205
+ getTable(tableId) {
206
+ return new Table(this.instanceId, tableId);
207
+ }
208
+ }
209
+ class Table extends BaseSDK {
210
+ constructor(instanceId, tableId) {
211
+ super();
212
+ this.tableId = tableId;
213
+ this.instanceId = instanceId;
214
+ }
215
+ toJSON() {
216
+ return this._postMessageAsync(
217
+ LISTENER_CMDS.TO_JSON,
218
+ {
219
+ tableId: this.tableId
220
+ }
221
+ );
222
+ }
223
+ getRows() {
224
+ return this._postMessageAsync(
225
+ LISTENER_CMDS.GET_TABLE_ROWS,
226
+ { tableId: this.tableId },
227
+ true,
228
+ (data) => {
229
+ return data.map((row) => new TableForm(this.instanceId, this.tableId, row.id));
230
+ }
231
+ );
232
+ }
233
+ getRow(rowId) {
234
+ return new TableForm(this.instanceId, this.tableId, rowId);
235
+ }
236
+ addRow(rowObject) {
237
+ return this._postMessageAsync(LISTENER_CMDS.ADD_TABLE_ROW, {
238
+ tableId: this.tableId,
239
+ rowObject
240
+ });
241
+ }
242
+ deleteRow(rowId) {
243
+ return this._postMessageAsync(LISTENER_CMDS.DELETE_TABLE_ROW, {
244
+ tableId: this.tableId,
245
+ rowId
246
+ });
247
+ }
248
+ }
249
+ class TableForm extends BaseSDK {
250
+ constructor(instanceId, tableId, rowId) {
251
+ super();
252
+ this.instanceId = instanceId;
253
+ this.type = "TabelForm";
254
+ this.tableId = tableId;
255
+ this.rowId = rowId;
256
+ }
257
+ getParent() {
258
+ return new Form(this.instanceId);
259
+ }
260
+ toJSON() {
261
+ return this._postMessageAsync(LISTENER_CMDS.TO_JSON, {
262
+ tableId: this.tableId,
263
+ rowId: this.rowId
264
+ });
265
+ }
266
+ getField(fieldId) {
267
+ return this._postMessageAsync(LISTENER_CMDS.GET_FORM_FIELD, {
268
+ instanceId: this.instanceId,
269
+ tableId: this.tableId,
270
+ rowId: this.rowId,
271
+ fieldId
272
+ });
273
+ }
274
+ updateField(args) {
275
+ return this._postMessageAsync(LISTENER_CMDS.UPDATE_FORM, {
276
+ instanceId: this.instanceId,
277
+ tableId: this.tableId,
278
+ rowId: this.rowId,
279
+ data: args
280
+ });
281
+ }
282
+ }
283
+ class Client extends BaseSDK {
284
+ showInfo(message) {
285
+ return super._postMessageAsync(LISTENER_CMDS.MESSAGE, { message });
286
+ }
287
+ showConfirm(args) {
288
+ return super._postMessageAsync(LISTENER_CMDS.CONFIRM, {
289
+ data: {
290
+ title: args.title,
291
+ content: args.content,
292
+ okText: args.okText || "Ok",
293
+ cancelText: args.cancelText || "Cancel"
294
+ }
295
+ });
296
+ }
297
+ redirect(url) {
298
+ return super._postMessageAsync(LISTENER_CMDS.REDIRECT, { url });
299
+ }
300
+ }
301
+ class Formatter extends BaseSDK {
302
+ toDate(date) {
303
+ return this._postMessageAsync(LISTENER_CMDS.FORMAT_DATE, {
304
+ date
305
+ });
306
+ }
307
+ toDateTime(date) {
308
+ return this._postMessageAsync(LISTENER_CMDS.FORMAT_DATE_TIME, {
309
+ date
310
+ });
311
+ }
312
+ toNumber(value) {
313
+ return this._postMessageAsync(LISTENER_CMDS.FORMAT_NUMBER, {
314
+ value
315
+ });
316
+ }
317
+ toCurrency(value, currencyCode) {
318
+ return this._postMessageAsync(LISTENER_CMDS.FORMAT_CURRENCY, {
319
+ value,
320
+ currencyCode
321
+ });
322
+ }
323
+ toBoolean(value) {
324
+ return this._postMessageAsync(LISTENER_CMDS.FORMAT_BOOLEAN, {
325
+ value
326
+ });
327
+ }
328
+ }
329
+ class NDEFReader extends BaseSDK {
330
+ constructor() {
331
+ super();
332
+ this.id = generateId(LISTENER_CMDS.WINDOW_NDEF_READER_NEW);
333
+ globalInstances[this.id] = this;
334
+ this._postMessage(
335
+ LISTENER_CMDS.WINDOW_NDEF_READER_NEW,
336
+ {
337
+ id: this.id,
338
+ operation: "new"
339
+ },
340
+ (data) => {
341
+ }
342
+ );
343
+ }
344
+ scan() {
345
+ return new Promise((resolve, reject) => {
346
+ this._postMessage(
347
+ LISTENER_CMDS.WINDOW_NDEF_READER_SCAN,
348
+ { id: this.id, operation: "scan" },
349
+ ({ data, err }) => {
350
+ console.log("scan data from main window ", data);
351
+ resolve(data);
352
+ }
353
+ );
354
+ });
355
+ }
356
+ write(data) {
357
+ return new Promise((resolve, reject) => {
358
+ this._postMessage(
359
+ LISTENER_CMDS.WINDOW_NDEF_READER_WRITE,
360
+ { id: this.id, operation: "write", data },
361
+ ({ data: data2, err }) => {
362
+ }
363
+ );
364
+ });
365
+ }
366
+ addEventListener(eventName, cb) {
367
+ this._postMessage(
368
+ LISTENER_CMDS.WINDOW_NDEF_READER_ADD_EVENT_LISTENER,
369
+ {
370
+ id: this.id,
371
+ operation: "addEventListener",
372
+ eventName
373
+ },
374
+ () => {
375
+ }
376
+ );
377
+ }
378
+ makeReadOnly() {
379
+ return new Promise((resolve, reject) => {
380
+ this._postMessage(
381
+ LISTENER_CMDS.WINDOW_NDEF_READER_MAKE_READONLY,
382
+ { id: this.id, operation: "makeReadOnly" },
383
+ ({ data, err }) => {
384
+ }
385
+ );
386
+ });
387
+ }
388
+ abortScan() {
389
+ return new Promise((resolve, reject) => {
390
+ this._postMessage(
391
+ LISTENER_CMDS.WINDOW_NDEF_READER_ABORT_SCAN,
392
+ { id: this.id, operation: "abortScan" },
393
+ ({ data, err }) => {
394
+ }
395
+ );
396
+ });
397
+ }
398
+ }
399
+ const window = {
400
+ NDEFReader
401
+ };
402
+ class NocodeSDK extends BaseSDK {
403
+ constructor(props) {
404
+ super();
405
+ __privateAdd(this, _csrfToken, void 0);
406
+ if (props.tableId && props.tableRowId) {
407
+ this.context = new TableForm(
408
+ props.formInstanceId,
409
+ props.tableId,
410
+ props.tableRowId
411
+ );
412
+ } else if (props.formInstanceId) {
413
+ this.context = new Form(props.formInstanceId);
414
+ }
415
+ this.client = new Client();
416
+ this.formatter = new Formatter();
417
+ this.user = props.user;
418
+ this.account = props.account;
419
+ __privateSet(this, _csrfToken, props.csrfToken);
420
+ }
421
+ async api(url, args) {
422
+ const response = await globalThis.fetch(url, {
423
+ ...args,
424
+ headers: {
425
+ ...(args == null ? void 0 : args.headers) || {},
426
+ "X-Csrf-Token": __privateGet(this, _csrfToken)
427
+ }
428
+ });
429
+ const contentType = response.headers.get("content-type");
430
+ if (contentType && contentType.includes("application/json")) {
431
+ return await response.json();
432
+ } else {
433
+ return response;
434
+ }
435
+ }
436
+ }
437
+ _csrfToken = new WeakMap();
438
+ function initSDK(config) {
439
+ return new NocodeSDK(config);
440
+ }
441
+ export { initSDK as default, window };
@@ -0,0 +1,292 @@
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
+ DELETE_TABLE_ROW: string;
12
+ TO_JSON: string;
13
+ GET_TABLE_ROWS: string;
14
+ MESSAGE: string;
15
+ CONFIRM: string;
16
+ ALERT: string;
17
+ REDIRECT: string;
18
+ OPEN_PAGE: string;
19
+ FORMAT_DATE: string;
20
+ FORMAT_DATE_TIME: string;
21
+ FORMAT_NUMBER: string;
22
+ FORMAT_CURRENCY: string;
23
+ FORMAT_BOOLEAN: string;
24
+ GET_APP_VARIABLE: string;
25
+ SET_APP_VARIABLE: string;
26
+ GET_PAGE_VARIABLE: string;
27
+ SET_PAGE_VARIABLE: string;
28
+ GET_PAGE_PARAMS: string;
29
+ GET_ALL_PAGE_PARAMS: string;
30
+ PAGE_ON_CLOSE: string;
31
+ OPEN_POPUP: string;
32
+ GET_POPUP_PARAMS: string;
33
+ GET_ALL_POPUP_PARAMS: string;
34
+ CLOSE_POPUP: string;
35
+ COMPONENT_GET: string;
36
+ COMPONENT_REFRESH: string;
37
+ COMPONENT_SHOW: string;
38
+ COMPONENT_HIDE: string;
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;
48
+ };
49
+ export const EVENT_TYPES: {
50
+ COMPONENT_ON_MOUNT: string;
51
+ CC_ON_PARAMS_CHANGE: string;
52
+ };
53
+ export const DEFAULTS: {
54
+ POPUP_ID: string;
55
+ };
56
+ }
57
+ declare module "core/index" {
58
+ export function generateId(prefix?: string): string;
59
+ export const globalInstances: {};
60
+ export class EventBase {
61
+ #private;
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 {
69
+ _postMessageAsync(command: string, args: any, hasCallBack?: boolean, callBack?: (data: any) => {}): object | string | any;
70
+ _postMessage(command: string, args: any, callBack?: any): void;
71
+ }
72
+ export * from "core/constants";
73
+ }
74
+ declare module "form/index" {
75
+ import { BaseSDK } from "core/index";
76
+ export class Form extends BaseSDK {
77
+ private instanceId;
78
+ type: string;
79
+ constructor(instanceId: string);
80
+ toJSON(): any;
81
+ getField(fieldId: string): any;
82
+ updateField(args: object): any;
83
+ getTable(tableId: string): Table;
84
+ }
85
+ class Table extends BaseSDK {
86
+ private tableId;
87
+ private instanceId;
88
+ constructor(instanceId: string, tableId: string);
89
+ toJSON(): any;
90
+ getRows(): TableForm[];
91
+ getRow(rowId: string): TableForm;
92
+ addRow(rowObject: object): any;
93
+ deleteRow(rowId: string): any;
94
+ }
95
+ export class TableForm extends BaseSDK {
96
+ private instanceId;
97
+ private tableId;
98
+ private rowId;
99
+ type: string;
100
+ constructor(instanceId: string, tableId: string, rowId: string);
101
+ getParent(): Form;
102
+ toJSON(): any;
103
+ getField(fieldId: string): any;
104
+ updateField(args: object): any;
105
+ }
106
+ }
107
+ declare module "utils/client" {
108
+ import { BaseSDK } from "core/index";
109
+ export class Client extends BaseSDK {
110
+ showInfo(message: string): any;
111
+ showConfirm(args: {
112
+ title: string;
113
+ content: string;
114
+ okText: string;
115
+ cancelText: string;
116
+ }): any;
117
+ redirect(url: string): any;
118
+ }
119
+ }
120
+ declare module "utils/formatter" {
121
+ import { BaseSDK } from "core/index";
122
+ export class Formatter extends BaseSDK {
123
+ toDate(date: string): any;
124
+ toDateTime(date: string): any;
125
+ toNumber(value: string): any;
126
+ toCurrency(value: string, currencyCode: string): any;
127
+ toBoolean(value: string): any;
128
+ }
129
+ }
130
+ declare module "utils/index" {
131
+ export * from "utils/client";
132
+ export * from "utils/formatter";
133
+ }
134
+ declare module "window/NDEFReader" {
135
+ import { BaseSDK } from "core/index";
136
+ export class NDEFReader extends BaseSDK {
137
+ id: string;
138
+ constructor();
139
+ scan(): Promise<unknown>;
140
+ write(data: any): Promise<unknown>;
141
+ addEventListener(eventName: string, cb: Function): void;
142
+ makeReadOnly(): Promise<unknown>;
143
+ abortScan(): Promise<unknown>;
144
+ }
145
+ }
146
+ declare module "window/index" {
147
+ import { NDEFReader } from "window/NDEFReader";
148
+ export const window: {
149
+ NDEFReader: typeof NDEFReader;
150
+ };
151
+ }
152
+ declare module "types/external" {
153
+ export type userObject = {
154
+ _id: string;
155
+ Name: string;
156
+ Email: string;
157
+ UserType: string;
158
+ Role: string;
159
+ };
160
+ export type accountObject = {
161
+ _id: string;
162
+ };
163
+ export type environmentObject = {
164
+ isMobile: boolean;
165
+ };
166
+ }
167
+ declare module "types/internal" {
168
+ import { userObject, accountObject, environmentObject } from "types/external";
169
+ export interface SDKContext {
170
+ formInstanceId: string;
171
+ tableId: string;
172
+ tableRowId: string;
173
+ componentId: string;
174
+ componentMethods?: componentMethodsType[];
175
+ appId: string;
176
+ pageId: string;
177
+ popupId: string;
178
+ user: userObject;
179
+ account: accountObject;
180
+ csrfToken: string;
181
+ envDetails: environmentObject;
182
+ }
183
+ export interface componentMethodsType {
184
+ name: string;
185
+ returnType?: string;
186
+ parameters?: string[];
187
+ }
188
+ export interface ComponentProps {
189
+ componentId: string;
190
+ componentMethods?: componentMethodsType[];
191
+ }
192
+ export interface AppContext {
193
+ appId: string;
194
+ pageId: string;
195
+ }
196
+ export interface PageContext {
197
+ pageId: string;
198
+ }
199
+ export interface PopupContext {
200
+ popupId?: string;
201
+ }
202
+ }
203
+ declare module "nocode" {
204
+ import { BaseSDK } from "core/index";
205
+ import { Form, TableForm } from "form/index";
206
+ import { Client, Formatter } from "utils/index";
207
+ import { window } from "window/index";
208
+ import { SDKContext } from "types/internal";
209
+ import { userObject, accountObject } from "types/external";
210
+ class NocodeSDK extends BaseSDK {
211
+ #private;
212
+ context: Form | TableForm;
213
+ client: Client;
214
+ formatter: Formatter;
215
+ user: userObject;
216
+ account: accountObject;
217
+ constructor(props: SDKContext);
218
+ api(url: string, args?: {
219
+ headers: object;
220
+ }): Promise<any>;
221
+ }
222
+ function initSDK(config: SDKContext): NocodeSDK;
223
+ export { window, initSDK as default };
224
+ }
225
+ declare module "app/component" {
226
+ import { BaseSDK } from "core/index";
227
+ import { ComponentProps } from "types/internal";
228
+ export class Component extends BaseSDK {
229
+ #private;
230
+ _id: string;
231
+ type: string;
232
+ constructor(props: ComponentProps);
233
+ onMount(callback: Function): void;
234
+ refresh(): any;
235
+ show(): any;
236
+ hide(): any;
237
+ }
238
+ export class CustomComponent extends BaseSDK {
239
+ type: string;
240
+ _id: string;
241
+ constructor(id: any);
242
+ watchParams(callBack: (data: any) => any): void;
243
+ }
244
+ }
245
+ declare module "app/popup" {
246
+ import { BaseSDK } from "core/index";
247
+ import { Component } from "app/component";
248
+ import { PopupContext } from "types/internal";
249
+ export class Popup extends BaseSDK {
250
+ _id: string;
251
+ type: string;
252
+ constructor(props: PopupContext);
253
+ getParameter(key: string): any;
254
+ getAllParameters(): any;
255
+ close(): any;
256
+ getComponent(componentId: string): Component;
257
+ }
258
+ }
259
+ declare module "app/page" {
260
+ import { BaseSDK } from "core/index";
261
+ import { Component } from "app/component";
262
+ import { Popup } from "app/popup";
263
+ import { PageContext } from "types/internal";
264
+ export class Page extends BaseSDK {
265
+ _id: string;
266
+ popup: Popup;
267
+ type: string;
268
+ constructor(props: PageContext);
269
+ getParameter(key: string): any;
270
+ getAllParameters(): any;
271
+ getVariable(key: string): any;
272
+ setVariable(key: string, value: any): any;
273
+ openPopup(popupId: string, popupParams: object): any;
274
+ getComponent(componentId: string): Component;
275
+ }
276
+ }
277
+ declare module "app/index" {
278
+ import { BaseSDK } from "core/index";
279
+ import { Page } from "app/page";
280
+ import { AppContext } from "types/internal";
281
+ export class Application extends BaseSDK {
282
+ page: Page;
283
+ _id: string;
284
+ constructor(props: AppContext);
285
+ getVariable(key: string): any;
286
+ setVariable(key: string | object, value?: any): any;
287
+ openPage(pageId: string, pageParams: object): any;
288
+ }
289
+ export * from "app/component";
290
+ export { Page };
291
+ export * from "app/popup";
292
+ }
@@ -0,0 +1,64 @@
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
+ }
40
+ declare class kf {
41
+ static context: Form
42
+ static client: Client
43
+ static formatter: Formatter
44
+ static user: userObject
45
+ static account: accountObject
46
+ api(url: string, args?: {
47
+ headers: object;
48
+ }): Promise<any>;
49
+ }
50
+ declare type userObject = {
51
+ _id: string;
52
+ Name: string;
53
+ Email: string;
54
+ UserType: string;
55
+ Role: string;
56
+ };
57
+
58
+ declare type accountObject = {
59
+ _id: string;
60
+ };
61
+
62
+ declare type environmentObject = {
63
+ isMobile: boolean
64
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kissflow/lowcode-client-sdk",
3
- "version": "1.0.13",
3
+ "version": "1.0.14",
4
4
  "description": "JavaScript SDK for developing over the Kissflow lowcode platform",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
@@ -14,7 +14,7 @@
14
14
  "require": "./dist/kfsdk.umd.js"
15
15
  },
16
16
  "./lowcode": {
17
- "import": "./dist/kfworkersdk.es.js"
17
+ "import": "./dist/kf.lowcodeworkersdk.es.js"
18
18
  }
19
19
  },
20
20
  "repository": {
File without changes