@kissflow/lowcode-client-sdk 1.0.0-beta.4 → 1.0.2-beta.6

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
 
@@ -16,10 +16,12 @@ const kf = KFLowcodeSDK();
16
16
  SDK can also be loaded directly into HTML by adding:
17
17
 
18
18
  ```html
19
- <script type="module" async src="https://cdn.jsdelivr.net/npm/@kissflow/lcnc-sdk-js@1/dist/kflowcode.sdk.module.js"></script>
19
+ <script src="https://cdn.jsdelivr.net/npm/@kissflow/lowcode-client-sdk@1/dist/kflowcode.sdk.js"></script>
20
+ <!-- or -->
21
+ <script type="module" src="https://cdn.jsdelivr.net/npm/@kissflow/lowcode-client-sdk@1/dist/kflowcode.sdk.module.js"></script>
20
22
  ```
21
23
 
22
- > Note specifying script type as "module" is must. Then SDK can be initialized anywhere by declaring:
24
+ > Then SDK can be initialized anywhere by declaring:
23
25
  ```js
24
26
  const kf = window.KF();
25
27
  ```
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", staticDeclarations: true },
9
+ Table: { name: "Table", staticDeclarations: true },
10
+ TableForm: { name: "TableForm", staticDeclarations: true },
9
11
  Formatter: { name: "Formatter" },
10
12
  LowcodeSDK: { name: "kf", staticDeclarations: true }
11
13
  };
@@ -48,7 +50,18 @@ 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.options) {
55
+ let options = _class.fields[i].type.options
56
+ for (let j = 0; j < options.length; j++) {
57
+ className += options[j].typeName;
58
+ if (j < options.length - 1) {
59
+ className += " | ";
60
+ }
61
+ }
62
+ } else {
63
+ className = _class.fields[i].type.typeName;
64
+ }
52
65
  let fieldName = _class.fields[i].name;
53
66
  // console.log(_class.fields[i]);
54
67
  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,10 @@ 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",
13
16
  //Client SDK functions
14
17
  MESSAGE: "MESSAGE",
15
18
  CONFIRM: "CONFIRM",
@@ -31,7 +34,9 @@ exports.LISTENER_CMDS = {
31
34
  GET_PAGE_PARAMS: "GET_PAGE_PARAMS",
32
35
  OPEN_POPUP_PAGE: "OPEN_POPUP_PAGE",
33
36
  PAGE_ON_CLOSE: "PAGE_ON_CLOSE",
34
- COMPONENT_REFRESH: "COMPONENT_REFRESH"
37
+ COMPONENT_REFRESH: "COMPONENT_REFRESH",
38
+ COMPONENT_SHOW: "COMPONENT_SHOW",
39
+ COMPONENT_HIDE: "COMPONENT_HIDE"
35
40
  };
36
41
  exports.EVENT_TYPES = {
37
42
  ON_CLOSE: "onClose",
package/dist/form.js CHANGED
@@ -15,16 +15,19 @@ 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
+ return _this;
25
27
  }
26
28
  Form.prototype.getField = function (fieldId) {
27
29
  return this._postMessageAsync(constants_1.LISTENER_CMDS.GET_FORM_FIELD, {
30
+ instanceId: this.instanceId,
28
31
  fieldId: fieldId
29
32
  });
30
33
  };
@@ -33,12 +36,75 @@ var Form = /** @class */ (function (_super) {
33
36
  data: args
34
37
  });
35
38
  };
36
- Form.prototype.addTableRow = function (tableId, rowObject) {
37
- return this._postMessageAsync(constants_1.LISTENER_CMDS.ADD_TABLE_ROW, {
38
- tableId: tableId,
39
- rowObject: rowObject
39
+ Form.prototype.getTable = function (tableId) {
40
+ var _this = this;
41
+ return this._postMessageAsync(constants_1.LISTENER_CMDS.GET_TABLE, { tableId: tableId }, true, // has callBack
42
+ function (data) {
43
+ return new Table(_this.instanceId, tableId); // callBack function
40
44
  });
41
45
  };
42
46
  return Form;
43
47
  }(base_1.BaseSDK));
44
48
  exports.Form = Form;
49
+ var Table = /** @class */ (function (_super) {
50
+ __extends(Table, _super);
51
+ function Table(instanceId, tableId) {
52
+ var _this = _super.call(this, {}) || this;
53
+ _this.tableId = tableId;
54
+ _this.instanceId = instanceId;
55
+ return _this;
56
+ }
57
+ Table.prototype.getRow = function (rowId) {
58
+ var _this = this;
59
+ return this._postMessageAsync(constants_1.LISTENER_CMDS.GET_TABLE_ROW, {
60
+ tableId: this.tableId,
61
+ rowId: rowId
62
+ }, true, // has callBack
63
+ function (data) {
64
+ return new TableForm(_this.instanceId, _this.tableId, rowId); // callBack function
65
+ });
66
+ };
67
+ Table.prototype.addRow = function (rowObject) {
68
+ return this._postMessageAsync(constants_1.LISTENER_CMDS.ADD_TABLE_ROW, {
69
+ tableId: this.tableId,
70
+ rowObject: rowObject
71
+ });
72
+ };
73
+ Table.prototype.deleteRow = function (rowId) {
74
+ return this._postMessageAsync(constants_1.LISTENER_CMDS.DELETE_TABLE_ROW, {
75
+ tableId: this.tableId,
76
+ rowId: rowId
77
+ });
78
+ };
79
+ return Table;
80
+ }(base_1.BaseSDK));
81
+ var TableForm = /** @class */ (function (_super) {
82
+ __extends(TableForm, _super);
83
+ function TableForm(instanceId, tableId, rowId) {
84
+ var _this = _super.call(this, {}) || this;
85
+ _this.instanceId = instanceId;
86
+ _this.tableId = tableId;
87
+ _this.rowId = rowId;
88
+ _this.parent = new Form(instanceId);
89
+ _this.table = new Table(instanceId, tableId);
90
+ return _this;
91
+ }
92
+ TableForm.prototype.getField = function (fieldId) {
93
+ return this._postMessageAsync(constants_1.LISTENER_CMDS.GET_FORM_FIELD, {
94
+ instanceId: this.instanceId,
95
+ tableId: this.tableId,
96
+ rowId: this.rowId,
97
+ fieldId: fieldId
98
+ });
99
+ };
100
+ TableForm.prototype.updateField = function (args) {
101
+ return this._postMessageAsync(constants_1.LISTENER_CMDS.UPDATE_FORM, {
102
+ instanceId: this.instanceId,
103
+ tableId: this.tableId,
104
+ rowId: this.rowId,
105
+ data: args
106
+ });
107
+ };
108
+ return TableForm;
109
+ }(base_1.BaseSDK));
110
+ exports.TableForm = TableForm;
@@ -29,11 +29,30 @@ declare class Client {
29
29
  declare class Component {
30
30
  id: string
31
31
  refresh(): string | object;
32
+ show(): string | object;
33
+ hide(): string | object;
32
34
  }
33
35
  declare class Form {
36
+ static instanceId: string
37
+ getField(fieldId: string): string | object;
38
+ updateField(args: object): string | object;
39
+ getTable(tableId: string): string | object;
40
+ }
41
+ declare class Table {
42
+ static tableId: string
43
+ static instanceId: string
44
+ getRow(rowId: string): string | object;
45
+ addRow(rowObject: object): string | object;
46
+ deleteRow(rowId: string): string | object;
47
+ }
48
+ declare class TableForm {
49
+ static instanceId: string
50
+ static tableId: string
51
+ static rowId: string
52
+ static table: Table
53
+ static parent: Form
34
54
  getField(fieldId: string): string | object;
35
55
  updateField(args: object): string | object;
36
- addTableRow(tableId: string, rowObject: object): string | object;
37
56
  }
38
57
  declare class Formatter {
39
58
  toKfDate(date: string): string | object;
@@ -43,7 +62,7 @@ declare class Formatter {
43
62
  toBoolean(value: string): string | object;
44
63
  }
45
64
  declare class kf {
46
- static currentForm: Form
65
+ static currentForm: Form | TableForm
47
66
  static client: Client
48
67
  static formatter: Formatter
49
68
  static app: Application
package/dist/index.d.ts CHANGED
@@ -6,7 +6,10 @@ 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;
10
13
  MESSAGE: string;
11
14
  CONFIRM: string;
12
15
  ALERT: string;
@@ -25,6 +28,8 @@ declare module "constants" {
25
28
  OPEN_POPUP_PAGE: string;
26
29
  PAGE_ON_CLOSE: string;
27
30
  COMPONENT_REFRESH: string;
31
+ COMPONENT_SHOW: string;
32
+ COMPONENT_HIDE: string;
28
33
  };
29
34
  export const EVENT_TYPES: {
30
35
  ON_CLOSE: string;
@@ -86,14 +91,36 @@ declare module "component" {
86
91
  id: string;
87
92
  constructor(id: string);
88
93
  refresh(): string | object;
94
+ show(): string | object;
95
+ hide(): string | object;
89
96
  }
90
97
  }
91
98
  declare module "form" {
92
99
  import { BaseSDK } from "base";
93
100
  export class Form extends BaseSDK {
101
+ instanceId: string;
102
+ constructor(instanceId: string);
103
+ getField(fieldId: string): string | object;
104
+ updateField(args: object): string | object;
105
+ getTable(tableId: string): string | object;
106
+ }
107
+ class Table extends BaseSDK {
108
+ tableId: string;
109
+ instanceId: string;
110
+ constructor(instanceId: string, tableId: string);
111
+ getRow(rowId: string): string | object;
112
+ addRow(rowObject: object): string | object;
113
+ deleteRow(rowId: string): string | object;
114
+ }
115
+ export class TableForm extends BaseSDK {
116
+ instanceId: string;
117
+ tableId: string;
118
+ rowId: string;
119
+ table: Table;
120
+ parent: Form;
121
+ constructor(instanceId: string, tableId: string, rowId: string);
94
122
  getField(fieldId: string): string | object;
95
123
  updateField(args: object): string | object;
96
- addTableRow(tableId: string, rowObject: object): string | object;
97
124
  }
98
125
  }
99
126
  declare module "formatter" {
@@ -109,12 +136,13 @@ declare module "formatter" {
109
136
  declare module "lowcode.sdk" {
110
137
  import { BaseSDK } from "base";
111
138
  import { Form } from "form";
139
+ import { TableForm } from "form";
112
140
  import { Client } from "client";
113
141
  import { Formatter } from "formatter";
114
142
  import { Application } from "app";
115
143
  import { Component } from "component";
116
- export class LowcodeSDK extends BaseSDK {
117
- currentForm: Form;
144
+ class LowcodeSDK extends BaseSDK {
145
+ currentForm: Form | TableForm;
118
146
  client: Client;
119
147
  formatter: Formatter;
120
148
  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.mjs"></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';
package/dist/index.js CHANGED
@@ -2,6 +2,6 @@
2
2
  exports.__esModule = true;
3
3
  var lowcode_sdk_1 = require("./lowcode.sdk");
4
4
  if (typeof _BUILD !== "undefined" && _BUILD) {
5
- self.kf = lowcode_sdk_1["default"];
5
+ self.KF = lowcode_sdk_1["default"];
6
6
  }
7
7
  exports["default"] = lowcode_sdk_1["default"];
@@ -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,10 @@ 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",
361
374
  //Client SDK functions
362
375
  MESSAGE: "MESSAGE",
363
376
  CONFIRM: "CONFIRM",
@@ -379,7 +392,9 @@ exports.LISTENER_CMDS = {
379
392
  GET_PAGE_PARAMS: "GET_PAGE_PARAMS",
380
393
  OPEN_POPUP_PAGE: "OPEN_POPUP_PAGE",
381
394
  PAGE_ON_CLOSE: "PAGE_ON_CLOSE",
382
- COMPONENT_REFRESH: "COMPONENT_REFRESH"
395
+ COMPONENT_REFRESH: "COMPONENT_REFRESH",
396
+ COMPONENT_SHOW: "COMPONENT_SHOW",
397
+ COMPONENT_HIDE: "COMPONENT_HIDE"
383
398
  };
384
399
  exports.EVENT_TYPES = {
385
400
  ON_CLOSE: "onClose",
@@ -413,16 +428,19 @@ var __extends = (this && this.__extends) || (function () {
413
428
  };
414
429
  })();
415
430
  Object.defineProperty(exports, "__esModule", ({ value: true }));
416
- exports.Form = void 0;
431
+ exports.TableForm = exports.Form = void 0;
417
432
  var base_1 = __webpack_require__(/*! ./base */ "./src/base.ts");
418
433
  var constants_1 = __webpack_require__(/*! ./constants */ "./src/constants.ts");
419
434
  var Form = /** @class */ (function (_super) {
420
435
  __extends(Form, _super);
421
- function Form() {
422
- return _super !== null && _super.apply(this, arguments) || this;
436
+ function Form(instanceId) {
437
+ var _this = _super.call(this, {}) || this;
438
+ _this.instanceId = instanceId;
439
+ return _this;
423
440
  }
424
441
  Form.prototype.getField = function (fieldId) {
425
442
  return this._postMessageAsync(constants_1.LISTENER_CMDS.GET_FORM_FIELD, {
443
+ instanceId: this.instanceId,
426
444
  fieldId: fieldId
427
445
  });
428
446
  };
@@ -431,15 +449,78 @@ var Form = /** @class */ (function (_super) {
431
449
  data: args
432
450
  });
433
451
  };
434
- Form.prototype.addTableRow = function (tableId, rowObject) {
435
- return this._postMessageAsync(constants_1.LISTENER_CMDS.ADD_TABLE_ROW, {
436
- tableId: tableId,
437
- rowObject: rowObject
452
+ Form.prototype.getTable = function (tableId) {
453
+ var _this = this;
454
+ return this._postMessageAsync(constants_1.LISTENER_CMDS.GET_TABLE, { tableId: tableId }, true, // has callBack
455
+ function (data) {
456
+ return new Table(_this.instanceId, tableId); // callBack function
438
457
  });
439
458
  };
440
459
  return Form;
441
460
  }(base_1.BaseSDK));
442
461
  exports.Form = Form;
462
+ var Table = /** @class */ (function (_super) {
463
+ __extends(Table, _super);
464
+ function Table(instanceId, tableId) {
465
+ var _this = _super.call(this, {}) || this;
466
+ _this.tableId = tableId;
467
+ _this.instanceId = instanceId;
468
+ return _this;
469
+ }
470
+ Table.prototype.getRow = function (rowId) {
471
+ var _this = this;
472
+ return this._postMessageAsync(constants_1.LISTENER_CMDS.GET_TABLE_ROW, {
473
+ tableId: this.tableId,
474
+ rowId: rowId
475
+ }, true, // has callBack
476
+ function (data) {
477
+ return new TableForm(_this.instanceId, _this.tableId, rowId); // callBack function
478
+ });
479
+ };
480
+ Table.prototype.addRow = function (rowObject) {
481
+ return this._postMessageAsync(constants_1.LISTENER_CMDS.ADD_TABLE_ROW, {
482
+ tableId: this.tableId,
483
+ rowObject: rowObject
484
+ });
485
+ };
486
+ Table.prototype.deleteRow = function (rowId) {
487
+ return this._postMessageAsync(constants_1.LISTENER_CMDS.DELETE_TABLE_ROW, {
488
+ tableId: this.tableId,
489
+ rowId: rowId
490
+ });
491
+ };
492
+ return Table;
493
+ }(base_1.BaseSDK));
494
+ var TableForm = /** @class */ (function (_super) {
495
+ __extends(TableForm, _super);
496
+ function TableForm(instanceId, tableId, rowId) {
497
+ var _this = _super.call(this, {}) || this;
498
+ _this.instanceId = instanceId;
499
+ _this.tableId = tableId;
500
+ _this.rowId = rowId;
501
+ _this.parent = new Form(instanceId);
502
+ _this.table = new Table(instanceId, tableId);
503
+ return _this;
504
+ }
505
+ TableForm.prototype.getField = function (fieldId) {
506
+ return this._postMessageAsync(constants_1.LISTENER_CMDS.GET_FORM_FIELD, {
507
+ instanceId: this.instanceId,
508
+ tableId: this.tableId,
509
+ rowId: this.rowId,
510
+ fieldId: fieldId
511
+ });
512
+ };
513
+ TableForm.prototype.updateField = function (args) {
514
+ return this._postMessageAsync(constants_1.LISTENER_CMDS.UPDATE_FORM, {
515
+ instanceId: this.instanceId,
516
+ tableId: this.tableId,
517
+ rowId: this.rowId,
518
+ data: args
519
+ });
520
+ };
521
+ return TableForm;
522
+ }(base_1.BaseSDK));
523
+ exports.TableForm = TableForm;
443
524
 
444
525
 
445
526
  /***/ }),
@@ -531,10 +612,10 @@ var __extends = (this && this.__extends) || (function () {
531
612
  };
532
613
  })();
533
614
  Object.defineProperty(exports, "__esModule", ({ value: true }));
534
- exports.LowcodeSDK = void 0;
535
615
  var base_1 = __webpack_require__(/*! ./base */ "./src/base.ts");
536
616
  var constants_1 = __webpack_require__(/*! ./constants */ "./src/constants.ts");
537
617
  var form_1 = __webpack_require__(/*! ./form */ "./src/form.ts");
618
+ var form_2 = __webpack_require__(/*! ./form */ "./src/form.ts");
538
619
  var client_1 = __webpack_require__(/*! ./client */ "./src/client.ts");
539
620
  var formatter_1 = __webpack_require__(/*! ./formatter */ "./src/formatter.ts");
540
621
  var app_1 = __webpack_require__(/*! ./app */ "./src/app.ts");
@@ -543,7 +624,12 @@ var LowcodeSDK = /** @class */ (function (_super) {
543
624
  __extends(LowcodeSDK, _super);
544
625
  function LowcodeSDK(props) {
545
626
  var _this = _super.call(this, {}) || this;
546
- _this.currentForm = new form_1.Form({});
627
+ if (props.tableId && props.rowId) {
628
+ _this.currentForm = new form_2.TableForm(props.instanceId, props.tableId, props.rowId);
629
+ }
630
+ else if (props.instanceId) {
631
+ _this.currentForm = new form_1.Form(props.instanceId);
632
+ }
547
633
  _this.client = new client_1.Client({});
548
634
  _this.formatter = new formatter_1.Formatter({});
549
635
  _this.app = new app_1.Application({});
@@ -564,7 +650,6 @@ var LowcodeSDK = /** @class */ (function (_super) {
564
650
  };
565
651
  return LowcodeSDK;
566
652
  }(base_1.BaseSDK));
567
- exports.LowcodeSDK = LowcodeSDK;
568
653
  function initSDK(config) {
569
654
  if (config === void 0) { config = {}; }
570
655
  return new LowcodeSDK(config);
@@ -811,7 +896,7 @@ var exports = __webpack_exports__;
811
896
  Object.defineProperty(exports, "__esModule", ({ value: true }));
812
897
  var lowcode_sdk_1 = __webpack_require__(/*! ./lowcode.sdk */ "./src/lowcode.sdk.ts");
813
898
  if (true) {
814
- self.kf = lowcode_sdk_1.default;
899
+ self.KF = lowcode_sdk_1.default;
815
900
  }
816
901
  exports["default"] = lowcode_sdk_1.default;
817
902