@kissflow/lowcode-client-sdk 1.0.0-beta.5 → 1.0.2-beta.7

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
@@ -1,13 +1,13 @@
1
- # _Kissflow LCNC JavaScript SDK_
1
+ # _Kissflow Lowcode JavaScript SDK_
2
2
 
3
- JavaScript SDK for developing over the Kissflow LCNC platform
3
+ JavaScript SDK for developing over the Kissflow lowcode platform
4
4
 
5
5
  ### Use as an `npm` module
6
6
 
7
- Install the SDK as a module: `npm i @kissflow/kf-sdk-js` Then import into your project:
7
+ Install the SDK as a module: `npm i @kissflow/lowcode-client-sdk` Then import into your project:
8
8
 
9
9
  ```js
10
- import KFLowcodeSDK from "@kissflow/lcnc-sdk-js";
10
+ import KFLowcodeSDK from "@kissflow/lowcode-client-sdk";
11
11
  const kf = KFLowcodeSDK();
12
12
  ```
13
13
 
package/custom.build.js CHANGED
@@ -5,7 +5,9 @@ let classMappings = {
5
5
  Application: { name: "Application" },
6
6
  Client: { name: "Client" },
7
7
  Component: { name: "Component" },
8
- Form: { name: "Form" },
8
+ Form: { name: "Form" },
9
+ Table: { name: "Table" },
10
+ TableForm: { name: "TableForm" },
9
11
  Formatter: { name: "Formatter" },
10
12
  LowcodeSDK: { name: "kf", staticDeclarations: true }
11
13
  };
@@ -48,7 +50,25 @@ function transfromTypings() {
48
50
  // fields on Class
49
51
  for (let i = 0; i < _class.fields.length; i++) {
50
52
  // if (_class.fields[i].type.modulePath) {
51
- let className = _class.fields[i].type.typeName;
53
+ let className = "";
54
+ if (!_class.fields[i].type) {
55
+ continue
56
+ } else if(_class.fields[i].type.options) {
57
+ // TODO: currently we add only the first typechecking
58
+ className = _class.fields[i].type.options[0].typeName;
59
+
60
+ // TODO: need to handle when there are multiple type
61
+ // let options = _class.fields[i].type.options
62
+ // for (let j = 0; j < options.length; j++) {
63
+ // className += options[j].typeName;
64
+ // if (j < options.length - 1) {
65
+ // className += " | ";
66
+ // }
67
+ // }
68
+ } else {
69
+ className = _class.fields[i].type.typeName;
70
+ }
71
+
52
72
  let fieldName = _class.fields[i].name;
53
73
  // console.log(_class.fields[i]);
54
74
  toWrite += `\t${
package/dist/component.js CHANGED
@@ -30,6 +30,16 @@ var Component = /** @class */ (function (_super) {
30
30
  id: this.id
31
31
  });
32
32
  };
33
+ Component.prototype.show = function () {
34
+ return this._postMessageAsync(constants_1.LISTENER_CMDS.COMPONENT_SHOW, {
35
+ id: this.id
36
+ });
37
+ };
38
+ Component.prototype.hide = function () {
39
+ return this._postMessageAsync(constants_1.LISTENER_CMDS.COMPONENT_HIDE, {
40
+ id: this.id
41
+ });
42
+ };
33
43
  return Component;
34
44
  }(base_1.BaseSDK));
35
45
  exports.Component = Component;
package/dist/constants.js CHANGED
@@ -9,7 +9,12 @@ exports.LISTENER_CMDS = {
9
9
  //Forms SDK Functions
10
10
  GET_FORM_FIELD: "GET_FORM_FIELD",
11
11
  UPDATE_FORM: "UPDATE_FORM",
12
+ GET_TABLE: "GET_TABLE",
13
+ GET_TABLE_ROW: "GET_TABLE_ROW",
12
14
  ADD_TABLE_ROW: "ADD_TABLE_ROW",
15
+ DELETE_TABLE_ROW: "DELETE_TABLE_ROW",
16
+ TO_JSON: "TO_JSON",
17
+ GET_TABLE_ROWS: "GET_TABLE_ROWS",
13
18
  //Client SDK functions
14
19
  MESSAGE: "MESSAGE",
15
20
  CONFIRM: "CONFIRM",
@@ -31,7 +36,9 @@ exports.LISTENER_CMDS = {
31
36
  GET_PAGE_PARAMS: "GET_PAGE_PARAMS",
32
37
  OPEN_POPUP_PAGE: "OPEN_POPUP_PAGE",
33
38
  PAGE_ON_CLOSE: "PAGE_ON_CLOSE",
34
- COMPONENT_REFRESH: "COMPONENT_REFRESH"
39
+ COMPONENT_REFRESH: "COMPONENT_REFRESH",
40
+ COMPONENT_SHOW: "COMPONENT_SHOW",
41
+ COMPONENT_HIDE: "COMPONENT_HIDE"
35
42
  };
36
43
  exports.EVENT_TYPES = {
37
44
  ON_CLOSE: "onClose",
package/dist/form.js CHANGED
@@ -15,16 +15,25 @@ var __extends = (this && this.__extends) || (function () {
15
15
  };
16
16
  })();
17
17
  exports.__esModule = true;
18
- exports.Form = void 0;
18
+ exports.TableForm = exports.Form = void 0;
19
19
  var base_1 = require("./base");
20
20
  var constants_1 = require("./constants");
21
21
  var Form = /** @class */ (function (_super) {
22
22
  __extends(Form, _super);
23
- function Form() {
24
- return _super !== null && _super.apply(this, arguments) || this;
23
+ function Form(instanceId) {
24
+ var _this = _super.call(this, {}) || this;
25
+ _this.instanceId = instanceId;
26
+ _this.id = instanceId;
27
+ return _this;
25
28
  }
29
+ Form.prototype.toJSON = function () {
30
+ return this._postMessageAsync(constants_1.LISTENER_CMDS.TO_JSON, {
31
+ instanceId: this.instanceId
32
+ });
33
+ };
26
34
  Form.prototype.getField = function (fieldId) {
27
35
  return this._postMessageAsync(constants_1.LISTENER_CMDS.GET_FORM_FIELD, {
36
+ instanceId: this.instanceId,
28
37
  fieldId: fieldId
29
38
  });
30
39
  };
@@ -33,12 +42,87 @@ var Form = /** @class */ (function (_super) {
33
42
  data: args
34
43
  });
35
44
  };
36
- Form.prototype.addTableRow = function (tableId, rowObject) {
45
+ Form.prototype.getTable = function (tableId) {
46
+ return new Table(this.instanceId, tableId);
47
+ };
48
+ return Form;
49
+ }(base_1.BaseSDK));
50
+ exports.Form = Form;
51
+ var Table = /** @class */ (function (_super) {
52
+ __extends(Table, _super);
53
+ function Table(instanceId, tableId) {
54
+ var _this = _super.call(this, {}) || this;
55
+ _this.tableId = tableId;
56
+ _this.instanceId = instanceId;
57
+ _this.id = tableId;
58
+ return _this;
59
+ }
60
+ // list of obj of rows
61
+ Table.prototype.toJSON = function () {
62
+ return this._postMessageAsync(constants_1.LISTENER_CMDS.TO_JSON, {
63
+ tableId: this.tableId
64
+ });
65
+ };
66
+ Table.prototype.getRows = function () {
67
+ var _this = this;
68
+ // list of TableForm class
69
+ return this._postMessageAsync(constants_1.LISTENER_CMDS.GET_TABLE_ROWS, { tableId: this.tableId }, true, // has callBack
70
+ function (data) {
71
+ console.log(data);
72
+ return data.map(function (row) { return new TableForm(_this.instanceId, _this.tableId, row.id); });
73
+ });
74
+ };
75
+ Table.prototype.getRow = function (rowId) {
76
+ return new TableForm(this.instanceId, this.tableId, rowId);
77
+ };
78
+ Table.prototype.addRow = function (rowObject) {
37
79
  return this._postMessageAsync(constants_1.LISTENER_CMDS.ADD_TABLE_ROW, {
38
- tableId: tableId,
80
+ tableId: this.tableId,
39
81
  rowObject: rowObject
40
82
  });
41
83
  };
42
- return Form;
84
+ Table.prototype.deleteRow = function (rowId) {
85
+ return this._postMessageAsync(constants_1.LISTENER_CMDS.DELETE_TABLE_ROW, {
86
+ tableId: this.tableId,
87
+ rowId: rowId
88
+ });
89
+ };
90
+ return Table;
43
91
  }(base_1.BaseSDK));
44
- exports.Form = Form;
92
+ var TableForm = /** @class */ (function (_super) {
93
+ __extends(TableForm, _super);
94
+ function TableForm(instanceId, tableId, rowId) {
95
+ var _this = _super.call(this, {}) || this;
96
+ _this.instanceId = instanceId;
97
+ _this.tableId = tableId;
98
+ _this.rowId = rowId;
99
+ _this.id = rowId;
100
+ _this.parent = new Form(instanceId);
101
+ _this.table = new Table(instanceId, tableId);
102
+ return _this;
103
+ }
104
+ TableForm.prototype.toJSON = function () {
105
+ return this._postMessageAsync(constants_1.LISTENER_CMDS.GET_TABLE_ROW, {
106
+ tableId: this.tableId,
107
+ rowId: this.rowId
108
+ });
109
+ };
110
+ TableForm.prototype.getField = function (fieldId) {
111
+ return this._postMessageAsync(constants_1.LISTENER_CMDS.GET_FORM_FIELD, {
112
+ instanceId: this.instanceId,
113
+ tableId: this.tableId,
114
+ rowId: this.rowId,
115
+ fieldId: fieldId
116
+ });
117
+ };
118
+ TableForm.prototype.updateField = function (args) {
119
+ return this._postMessageAsync(constants_1.LISTENER_CMDS.UPDATE_FORM, {
120
+ instanceId: this.instanceId,
121
+ tableId: this.tableId,
122
+ rowId: this.rowId,
123
+ data: args
124
+ });
125
+ };
126
+ return TableForm;
127
+ }(base_1.BaseSDK));
128
+ exports.TableForm = TableForm;
@@ -1,46 +1,66 @@
1
1
 
2
2
  declare class Page {
3
3
  _id: string
4
- getParameter(key: string): string | object;
5
- getVariable(key: string): string | object;
6
- setVariable(key: string, value: any): string | object;
4
+ getParameter(key: string): any;
5
+ getVariable(key: string): any;
6
+ setVariable(key: string, value: any): any;
7
7
  openPopup(pageId: string, inputParams: object, popupProperties: {
8
8
  w: number;
9
9
  h: number;
10
- }): string | object;
10
+ }): any;
11
11
  onClose(callback: Function): void;
12
12
  }
13
13
  declare class Application {
14
14
  page: Page
15
- getVariable(key: string): string | object;
16
- setVariable(key: string | object, value: any): string | object;
17
- openPage(pageId: string, pageParams: object): string | object;
15
+ getVariable(key: string): any;
16
+ setVariable(key: string | object, value: any): any;
17
+ openPage(pageId: string, pageParams: object): any;
18
18
  }
19
19
  declare class Client {
20
- showInfo(message: string): string | object;
20
+ showInfo(message: string): any;
21
21
  showConfirm(args: {
22
22
  title: string;
23
23
  content: string;
24
24
  okText: string;
25
25
  cancelText: string;
26
- }): string | object;
27
- redirect(url: string): string | object;
26
+ }): any;
27
+ redirect(url: string): any;
28
28
  }
29
29
  declare class Component {
30
30
  id: string
31
- refresh(): string | object;
31
+ refresh(): any;
32
+ show(): any;
33
+ hide(): any;
32
34
  }
33
35
  declare class Form {
34
- getField(fieldId: string): string | object;
35
- updateField(args: object): string | object;
36
- addTableRow(tableId: string, rowObject: object): string | object;
36
+ id: string
37
+ toJSON(): any;
38
+ getField(fieldId: string): any;
39
+ updateField(args: object): any;
40
+ getTable(tableId: string): Table;
41
+ }
42
+ declare class Table {
43
+ id: string
44
+ toJSON(): any;
45
+ getRows(): TableForm[];
46
+ getRow(rowId: string): TableForm;
47
+ addRow(rowObject: object): any;
48
+ deleteRow(rowId: string): any;
49
+ }
50
+ declare class TableForm {
51
+ id: string
52
+ table: Table
53
+ parent: Form
54
+ toJSON(): any;
55
+ getField(fieldId: string): any;
56
+ updateField(args: object): any;
37
57
  }
38
58
  declare class Formatter {
39
- toKfDate(date: string): string | object;
40
- toKfDateTime(date: string): string | object;
41
- toKfNumber(value: string): string | object;
42
- toKfCurrency(value: string, currencyCode: string): string | object;
43
- toBoolean(value: string): string | object;
59
+ toKfDate(date: string): any;
60
+ toKfDateTime(date: string): any;
61
+ toKfNumber(value: string): any;
62
+ toKfCurrency(value: string, currencyCode: string): any;
63
+ toBoolean(value: string): any;
44
64
  }
45
65
  declare class kf {
46
66
  static currentForm: Form
package/dist/index.d.ts CHANGED
@@ -6,7 +6,12 @@ declare module "constants" {
6
6
  RETURN: string;
7
7
  GET_FORM_FIELD: string;
8
8
  UPDATE_FORM: string;
9
+ GET_TABLE: string;
10
+ GET_TABLE_ROW: string;
9
11
  ADD_TABLE_ROW: 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;
@@ -25,6 +30,8 @@ declare module "constants" {
25
30
  OPEN_POPUP_PAGE: string;
26
31
  PAGE_ON_CLOSE: string;
27
32
  COMPONENT_REFRESH: string;
33
+ COMPONENT_SHOW: string;
34
+ COMPONENT_HIDE: string;
28
35
  };
29
36
  export const EVENT_TYPES: {
30
37
  ON_CLOSE: string;
@@ -36,7 +43,7 @@ declare module "base" {
36
43
  export class BaseSDK {
37
44
  #private;
38
45
  constructor(props: any);
39
- _postMessageAsync(command: string, args: any, hasCallBack?: boolean, callBack?: (data: any) => {}): object | string;
46
+ _postMessageAsync(command: string, args: any, hasCallBack?: boolean, callBack?: (data: any) => {}): object | string | any;
40
47
  _postMessage(command: string, func: (data: any) => {}, args?: {}): void;
41
48
  _registerEventListener(_id: string, eventType: string, callback: any): void;
42
49
  }
@@ -46,13 +53,13 @@ declare module "page" {
46
53
  export class Page extends BaseSDK {
47
54
  _id: string;
48
55
  constructor(pageId: string);
49
- getParameter(key: string): string | object;
50
- getVariable(key: string): string | object;
51
- setVariable(key: string, value: any): string | object;
56
+ getParameter(key: string): any;
57
+ getVariable(key: string): any;
58
+ setVariable(key: string, value: any): any;
52
59
  openPopup(pageId: string, inputParams: object, popupProperties: {
53
60
  w: number;
54
61
  h: number;
55
- }): string | object;
62
+ }): any;
56
63
  onClose(callback: Function): void;
57
64
  }
58
65
  }
@@ -62,22 +69,22 @@ declare module "app" {
62
69
  export class Application extends BaseSDK {
63
70
  page: Page;
64
71
  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;
72
+ getVariable(key: string): any;
73
+ setVariable(key: string | object, value: any): any;
74
+ openPage(pageId: string, pageParams: object): any;
68
75
  }
69
76
  }
70
77
  declare module "client" {
71
78
  import { BaseSDK } from "base";
72
79
  export class Client extends BaseSDK {
73
- showInfo(message: string): string | object;
80
+ showInfo(message: string): any;
74
81
  showConfirm(args: {
75
82
  title: string;
76
83
  content: string;
77
84
  okText: string;
78
85
  cancelText: string;
79
- }): string | object;
80
- redirect(url: string): string | object;
86
+ }): any;
87
+ redirect(url: string): any;
81
88
  }
82
89
  }
83
90
  declare module "component" {
@@ -85,36 +92,66 @@ declare module "component" {
85
92
  export class Component extends BaseSDK {
86
93
  id: string;
87
94
  constructor(id: string);
88
- refresh(): string | object;
95
+ refresh(): any;
96
+ show(): any;
97
+ hide(): any;
89
98
  }
90
99
  }
91
100
  declare module "form" {
92
101
  import { BaseSDK } from "base";
93
102
  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;
103
+ private instanceId;
104
+ id: string;
105
+ constructor(instanceId: string);
106
+ toJSON(): any;
107
+ getField(fieldId: string): any;
108
+ updateField(args: object): any;
109
+ getTable(tableId: string): Table;
110
+ }
111
+ class Table extends BaseSDK {
112
+ private tableId;
113
+ private instanceId;
114
+ id: string;
115
+ constructor(instanceId: string, tableId: string);
116
+ toJSON(): any;
117
+ getRows(): TableForm[];
118
+ getRow(rowId: string): TableForm;
119
+ addRow(rowObject: object): any;
120
+ deleteRow(rowId: string): any;
121
+ }
122
+ export class TableForm extends BaseSDK {
123
+ private instanceId;
124
+ private tableId;
125
+ private rowId;
126
+ id: string;
127
+ table: Table;
128
+ parent: Form;
129
+ constructor(instanceId: string, tableId: string, rowId: string);
130
+ toJSON(): any;
131
+ getField(fieldId: string): any;
132
+ updateField(args: object): any;
97
133
  }
98
134
  }
99
135
  declare module "formatter" {
100
136
  import { BaseSDK } from "base";
101
137
  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;
138
+ toKfDate(date: string): any;
139
+ toKfDateTime(date: string): any;
140
+ toKfNumber(value: string): any;
141
+ toKfCurrency(value: string, currencyCode: string): any;
142
+ toBoolean(value: string): any;
107
143
  }
108
144
  }
109
145
  declare module "lowcode.sdk" {
110
146
  import { BaseSDK } from "base";
111
147
  import { Form } from "form";
148
+ import { TableForm } from "form";
112
149
  import { Client } from "client";
113
150
  import { Formatter } from "formatter";
114
151
  import { Application } from "app";
115
152
  import { Component } from "component";
116
- export class LowcodeSDK extends BaseSDK {
117
- currentForm: Form;
153
+ class LowcodeSDK extends BaseSDK {
154
+ currentForm: Form | TableForm;
118
155
  client: Client;
119
156
  formatter: Formatter;
120
157
  app: Application;
package/dist/index.html CHANGED
@@ -14,7 +14,7 @@
14
14
  <iframe id="component2" src="http://localhost:3000" width="500px" height="500px">
15
15
  <p>Your browser does not support iframes.</p>
16
16
  </iframe>
17
- <script defer src="kflowcode.sdk.module.js"></script></body>
17
+ <script defer src="kflowcode.sdk.js"></script></body>
18
18
  <script type="module">
19
19
  import MockAPI from './test/mock/api.js';
20
20
  import LCNCHandler from './test/lcnc-handler.js';
@@ -333,6 +333,16 @@ var Component = /** @class */ (function (_super) {
333
333
  id: this.id
334
334
  });
335
335
  };
336
+ Component.prototype.show = function () {
337
+ return this._postMessageAsync(constants_1.LISTENER_CMDS.COMPONENT_SHOW, {
338
+ id: this.id
339
+ });
340
+ };
341
+ Component.prototype.hide = function () {
342
+ return this._postMessageAsync(constants_1.LISTENER_CMDS.COMPONENT_HIDE, {
343
+ id: this.id
344
+ });
345
+ };
336
346
  return Component;
337
347
  }(base_1.BaseSDK));
338
348
  exports.Component = Component;
@@ -357,7 +367,12 @@ exports.LISTENER_CMDS = {
357
367
  //Forms SDK Functions
358
368
  GET_FORM_FIELD: "GET_FORM_FIELD",
359
369
  UPDATE_FORM: "UPDATE_FORM",
370
+ GET_TABLE: "GET_TABLE",
371
+ GET_TABLE_ROW: "GET_TABLE_ROW",
360
372
  ADD_TABLE_ROW: "ADD_TABLE_ROW",
373
+ DELETE_TABLE_ROW: "DELETE_TABLE_ROW",
374
+ TO_JSON: "TO_JSON",
375
+ GET_TABLE_ROWS: "GET_TABLE_ROWS",
361
376
  //Client SDK functions
362
377
  MESSAGE: "MESSAGE",
363
378
  CONFIRM: "CONFIRM",
@@ -379,7 +394,9 @@ exports.LISTENER_CMDS = {
379
394
  GET_PAGE_PARAMS: "GET_PAGE_PARAMS",
380
395
  OPEN_POPUP_PAGE: "OPEN_POPUP_PAGE",
381
396
  PAGE_ON_CLOSE: "PAGE_ON_CLOSE",
382
- COMPONENT_REFRESH: "COMPONENT_REFRESH"
397
+ COMPONENT_REFRESH: "COMPONENT_REFRESH",
398
+ COMPONENT_SHOW: "COMPONENT_SHOW",
399
+ COMPONENT_HIDE: "COMPONENT_HIDE"
383
400
  };
384
401
  exports.EVENT_TYPES = {
385
402
  ON_CLOSE: "onClose",
@@ -413,16 +430,25 @@ var __extends = (this && this.__extends) || (function () {
413
430
  };
414
431
  })();
415
432
  Object.defineProperty(exports, "__esModule", ({ value: true }));
416
- exports.Form = void 0;
433
+ exports.TableForm = exports.Form = void 0;
417
434
  var base_1 = __webpack_require__(/*! ./base */ "./src/base.ts");
418
435
  var constants_1 = __webpack_require__(/*! ./constants */ "./src/constants.ts");
419
436
  var Form = /** @class */ (function (_super) {
420
437
  __extends(Form, _super);
421
- function Form() {
422
- return _super !== null && _super.apply(this, arguments) || this;
438
+ function Form(instanceId) {
439
+ var _this = _super.call(this, {}) || this;
440
+ _this.instanceId = instanceId;
441
+ _this.id = instanceId;
442
+ return _this;
423
443
  }
444
+ Form.prototype.toJSON = function () {
445
+ return this._postMessageAsync(constants_1.LISTENER_CMDS.TO_JSON, {
446
+ instanceId: this.instanceId
447
+ });
448
+ };
424
449
  Form.prototype.getField = function (fieldId) {
425
450
  return this._postMessageAsync(constants_1.LISTENER_CMDS.GET_FORM_FIELD, {
451
+ instanceId: this.instanceId,
426
452
  fieldId: fieldId
427
453
  });
428
454
  };
@@ -431,15 +457,90 @@ var Form = /** @class */ (function (_super) {
431
457
  data: args
432
458
  });
433
459
  };
434
- Form.prototype.addTableRow = function (tableId, rowObject) {
460
+ Form.prototype.getTable = function (tableId) {
461
+ return new Table(this.instanceId, tableId);
462
+ };
463
+ return Form;
464
+ }(base_1.BaseSDK));
465
+ exports.Form = Form;
466
+ var Table = /** @class */ (function (_super) {
467
+ __extends(Table, _super);
468
+ function Table(instanceId, tableId) {
469
+ var _this = _super.call(this, {}) || this;
470
+ _this.tableId = tableId;
471
+ _this.instanceId = instanceId;
472
+ _this.id = tableId;
473
+ return _this;
474
+ }
475
+ // list of obj of rows
476
+ Table.prototype.toJSON = function () {
477
+ return this._postMessageAsync(constants_1.LISTENER_CMDS.TO_JSON, {
478
+ tableId: this.tableId
479
+ });
480
+ };
481
+ Table.prototype.getRows = function () {
482
+ var _this = this;
483
+ // list of TableForm class
484
+ return this._postMessageAsync(constants_1.LISTENER_CMDS.GET_TABLE_ROWS, { tableId: this.tableId }, true, // has callBack
485
+ function (data) {
486
+ console.log(data);
487
+ return data.map(function (row) { return new TableForm(_this.instanceId, _this.tableId, row.id); });
488
+ });
489
+ };
490
+ Table.prototype.getRow = function (rowId) {
491
+ return new TableForm(this.instanceId, this.tableId, rowId);
492
+ };
493
+ Table.prototype.addRow = function (rowObject) {
435
494
  return this._postMessageAsync(constants_1.LISTENER_CMDS.ADD_TABLE_ROW, {
436
- tableId: tableId,
495
+ tableId: this.tableId,
437
496
  rowObject: rowObject
438
497
  });
439
498
  };
440
- return Form;
499
+ Table.prototype.deleteRow = function (rowId) {
500
+ return this._postMessageAsync(constants_1.LISTENER_CMDS.DELETE_TABLE_ROW, {
501
+ tableId: this.tableId,
502
+ rowId: rowId
503
+ });
504
+ };
505
+ return Table;
441
506
  }(base_1.BaseSDK));
442
- exports.Form = Form;
507
+ var TableForm = /** @class */ (function (_super) {
508
+ __extends(TableForm, _super);
509
+ function TableForm(instanceId, tableId, rowId) {
510
+ var _this = _super.call(this, {}) || this;
511
+ _this.instanceId = instanceId;
512
+ _this.tableId = tableId;
513
+ _this.rowId = rowId;
514
+ _this.id = rowId;
515
+ _this.parent = new Form(instanceId);
516
+ _this.table = new Table(instanceId, tableId);
517
+ return _this;
518
+ }
519
+ TableForm.prototype.toJSON = function () {
520
+ return this._postMessageAsync(constants_1.LISTENER_CMDS.GET_TABLE_ROW, {
521
+ tableId: this.tableId,
522
+ rowId: this.rowId
523
+ });
524
+ };
525
+ TableForm.prototype.getField = function (fieldId) {
526
+ return this._postMessageAsync(constants_1.LISTENER_CMDS.GET_FORM_FIELD, {
527
+ instanceId: this.instanceId,
528
+ tableId: this.tableId,
529
+ rowId: this.rowId,
530
+ fieldId: fieldId
531
+ });
532
+ };
533
+ TableForm.prototype.updateField = function (args) {
534
+ return this._postMessageAsync(constants_1.LISTENER_CMDS.UPDATE_FORM, {
535
+ instanceId: this.instanceId,
536
+ tableId: this.tableId,
537
+ rowId: this.rowId,
538
+ data: args
539
+ });
540
+ };
541
+ return TableForm;
542
+ }(base_1.BaseSDK));
543
+ exports.TableForm = TableForm;
443
544
 
444
545
 
445
546
  /***/ }),
@@ -531,10 +632,10 @@ var __extends = (this && this.__extends) || (function () {
531
632
  };
532
633
  })();
533
634
  Object.defineProperty(exports, "__esModule", ({ value: true }));
534
- exports.LowcodeSDK = void 0;
535
635
  var base_1 = __webpack_require__(/*! ./base */ "./src/base.ts");
536
636
  var constants_1 = __webpack_require__(/*! ./constants */ "./src/constants.ts");
537
637
  var form_1 = __webpack_require__(/*! ./form */ "./src/form.ts");
638
+ var form_2 = __webpack_require__(/*! ./form */ "./src/form.ts");
538
639
  var client_1 = __webpack_require__(/*! ./client */ "./src/client.ts");
539
640
  var formatter_1 = __webpack_require__(/*! ./formatter */ "./src/formatter.ts");
540
641
  var app_1 = __webpack_require__(/*! ./app */ "./src/app.ts");
@@ -543,7 +644,12 @@ var LowcodeSDK = /** @class */ (function (_super) {
543
644
  __extends(LowcodeSDK, _super);
544
645
  function LowcodeSDK(props) {
545
646
  var _this = _super.call(this, {}) || this;
546
- _this.currentForm = new form_1.Form({});
647
+ if (props.tableId && props.rowId) {
648
+ _this.currentForm = new form_2.TableForm(props.instanceId, props.tableId, props.rowId);
649
+ }
650
+ else if (props.instanceId) {
651
+ _this.currentForm = new form_1.Form(props.instanceId);
652
+ }
547
653
  _this.client = new client_1.Client({});
548
654
  _this.formatter = new formatter_1.Formatter({});
549
655
  _this.app = new app_1.Application({});
@@ -564,7 +670,6 @@ var LowcodeSDK = /** @class */ (function (_super) {
564
670
  };
565
671
  return LowcodeSDK;
566
672
  }(base_1.BaseSDK));
567
- exports.LowcodeSDK = LowcodeSDK;
568
673
  function initSDK(config) {
569
674
  if (config === void 0) { config = {}; }
570
675
  return new LowcodeSDK(config);