@kissflow/lowcode-client-sdk 1.0.1 → 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 +4 -4
- package/custom.build.js +15 -2
- package/dist/component.js +10 -0
- package/dist/constants.js +6 -1
- package/dist/form.js +73 -7
- package/dist/global.types.d.ts +21 -2
- package/dist/index.d.ts +31 -3
- package/dist/kflowcode.sdk.js +96 -11
- package/dist/kflowcode.sdk.js.map +1 -1
- package/dist/kflowcode.sdk.module.js +116 -17
- package/dist/kflowcode.sdk.module.js.map +1 -1
- package/dist/lowcode.sdk.js +7 -3
- package/package.json +1 -1
- package/src/component.ts +10 -0
- package/src/constants.ts +6 -1
- package/src/form.ts +86 -2
- package/src/lowcode.sdk.ts +9 -3
- package/webpack.config.js +1 -2
package/dist/lowcode.sdk.js
CHANGED
|
@@ -15,10 +15,10 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
15
15
|
};
|
|
16
16
|
})();
|
|
17
17
|
exports.__esModule = true;
|
|
18
|
-
exports.LowcodeSDK = void 0;
|
|
19
18
|
var base_1 = require("./base");
|
|
20
19
|
var constants_1 = require("./constants");
|
|
21
20
|
var form_1 = require("./form");
|
|
21
|
+
var form_2 = require("./form");
|
|
22
22
|
var client_1 = require("./client");
|
|
23
23
|
var formatter_1 = require("./formatter");
|
|
24
24
|
var app_1 = require("./app");
|
|
@@ -27,7 +27,12 @@ var LowcodeSDK = /** @class */ (function (_super) {
|
|
|
27
27
|
__extends(LowcodeSDK, _super);
|
|
28
28
|
function LowcodeSDK(props) {
|
|
29
29
|
var _this = _super.call(this, {}) || this;
|
|
30
|
-
|
|
30
|
+
if (props.tableId && props.rowId) {
|
|
31
|
+
_this.currentForm = new form_2.TableForm(props.instanceId, props.tableId, props.rowId);
|
|
32
|
+
}
|
|
33
|
+
else if (props.instanceId) {
|
|
34
|
+
_this.currentForm = new form_1.Form(props.instanceId);
|
|
35
|
+
}
|
|
31
36
|
_this.client = new client_1.Client({});
|
|
32
37
|
_this.formatter = new formatter_1.Formatter({});
|
|
33
38
|
_this.app = new app_1.Application({});
|
|
@@ -48,7 +53,6 @@ var LowcodeSDK = /** @class */ (function (_super) {
|
|
|
48
53
|
};
|
|
49
54
|
return LowcodeSDK;
|
|
50
55
|
}(base_1.BaseSDK));
|
|
51
|
-
exports.LowcodeSDK = LowcodeSDK;
|
|
52
56
|
function initSDK(config) {
|
|
53
57
|
if (config === void 0) { config = {}; }
|
|
54
58
|
return new LowcodeSDK(config);
|
package/package.json
CHANGED
package/src/component.ts
CHANGED
|
@@ -12,4 +12,14 @@ export class Component extends BaseSDK {
|
|
|
12
12
|
id: this.id
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
|
+
show() {
|
|
16
|
+
return this._postMessageAsync(LISTENER_CMDS.COMPONENT_SHOW, {
|
|
17
|
+
id: this.id
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
hide() {
|
|
21
|
+
return this._postMessageAsync(LISTENER_CMDS.COMPONENT_HIDE, {
|
|
22
|
+
id: this.id
|
|
23
|
+
});
|
|
24
|
+
}
|
|
15
25
|
}
|
package/src/constants.ts
CHANGED
|
@@ -7,7 +7,10 @@ export const LISTENER_CMDS = {
|
|
|
7
7
|
//Forms SDK Functions
|
|
8
8
|
GET_FORM_FIELD: "GET_FORM_FIELD",
|
|
9
9
|
UPDATE_FORM: "UPDATE_FORM",
|
|
10
|
+
GET_TABLE: "GET_TABLE",
|
|
11
|
+
GET_TABLE_ROW: "GET_TABLE_ROW",
|
|
10
12
|
ADD_TABLE_ROW: "ADD_TABLE_ROW",
|
|
13
|
+
DELETE_TABLE_ROW: "DELETE_TABLE_ROW",
|
|
11
14
|
|
|
12
15
|
//Client SDK functions
|
|
13
16
|
MESSAGE: "MESSAGE",
|
|
@@ -34,7 +37,9 @@ export const LISTENER_CMDS = {
|
|
|
34
37
|
OPEN_POPUP_PAGE: "OPEN_POPUP_PAGE",
|
|
35
38
|
PAGE_ON_CLOSE: "PAGE_ON_CLOSE",
|
|
36
39
|
|
|
37
|
-
COMPONENT_REFRESH: "COMPONENT_REFRESH"
|
|
40
|
+
COMPONENT_REFRESH: "COMPONENT_REFRESH",
|
|
41
|
+
COMPONENT_SHOW: "COMPONENT_SHOW",
|
|
42
|
+
COMPONENT_HIDE: "COMPONENT_HIDE"
|
|
38
43
|
};
|
|
39
44
|
|
|
40
45
|
|
package/src/form.ts
CHANGED
|
@@ -2,8 +2,14 @@ import { BaseSDK } from "./base";
|
|
|
2
2
|
import { LISTENER_CMDS } from "./constants";
|
|
3
3
|
|
|
4
4
|
export class Form extends BaseSDK {
|
|
5
|
+
instanceId: string;
|
|
6
|
+
constructor(instanceId: string) {
|
|
7
|
+
super({});
|
|
8
|
+
this.instanceId = instanceId;
|
|
9
|
+
}
|
|
5
10
|
getField(fieldId: string) {
|
|
6
11
|
return this._postMessageAsync(LISTENER_CMDS.GET_FORM_FIELD, {
|
|
12
|
+
instanceId: this.instanceId,
|
|
7
13
|
fieldId
|
|
8
14
|
});
|
|
9
15
|
}
|
|
@@ -12,10 +18,88 @@ export class Form extends BaseSDK {
|
|
|
12
18
|
data: args
|
|
13
19
|
});
|
|
14
20
|
}
|
|
15
|
-
|
|
21
|
+
getTable(tableId: string) {
|
|
22
|
+
return this._postMessageAsync(
|
|
23
|
+
LISTENER_CMDS.GET_TABLE,
|
|
24
|
+
{ tableId: tableId },
|
|
25
|
+
true, // has callBack
|
|
26
|
+
(data) => {
|
|
27
|
+
return new Table(this.instanceId, tableId); // callBack function
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
class Table extends BaseSDK {
|
|
34
|
+
tableId: string;
|
|
35
|
+
instanceId: string;
|
|
36
|
+
constructor(instanceId: string,tableId: string) {
|
|
37
|
+
super({});
|
|
38
|
+
this.tableId = tableId;
|
|
39
|
+
this.instanceId = instanceId
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
getRow(rowId: string) {
|
|
43
|
+
return this._postMessageAsync(
|
|
44
|
+
LISTENER_CMDS.GET_TABLE_ROW,
|
|
45
|
+
{
|
|
46
|
+
tableId: this.tableId,
|
|
47
|
+
rowId
|
|
48
|
+
},
|
|
49
|
+
true, // has callBack
|
|
50
|
+
(data) => {
|
|
51
|
+
return new TableForm(this.instanceId, this.tableId, rowId); // callBack function
|
|
52
|
+
}
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
addRow( rowObject: object) {
|
|
16
57
|
return this._postMessageAsync(LISTENER_CMDS.ADD_TABLE_ROW, {
|
|
17
|
-
tableId,
|
|
58
|
+
tableId: this.tableId,
|
|
18
59
|
rowObject
|
|
19
60
|
});
|
|
20
61
|
}
|
|
62
|
+
|
|
63
|
+
deleteRow(rowId: string) {
|
|
64
|
+
return this._postMessageAsync(LISTENER_CMDS.DELETE_TABLE_ROW, {
|
|
65
|
+
tableId: this.tableId,
|
|
66
|
+
rowId
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export class TableForm extends BaseSDK {
|
|
72
|
+
instanceId: string;
|
|
73
|
+
tableId: string;
|
|
74
|
+
rowId: string;
|
|
75
|
+
table: Table;
|
|
76
|
+
parent: Form;
|
|
77
|
+
|
|
78
|
+
constructor(instanceId: string, tableId: string, rowId: string) {
|
|
79
|
+
super({});
|
|
80
|
+
this.instanceId = instanceId;
|
|
81
|
+
this.tableId = tableId;
|
|
82
|
+
this.rowId = rowId;
|
|
83
|
+
this.parent = new Form(instanceId);
|
|
84
|
+
this.table = new Table(instanceId, tableId);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
getField(fieldId: string) {
|
|
88
|
+
return this._postMessageAsync(LISTENER_CMDS.GET_FORM_FIELD, {
|
|
89
|
+
instanceId: this.instanceId,
|
|
90
|
+
tableId: this.tableId,
|
|
91
|
+
rowId: this.rowId,
|
|
92
|
+
fieldId
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
updateField(args: object) {
|
|
97
|
+
return this._postMessageAsync(LISTENER_CMDS.UPDATE_FORM, {
|
|
98
|
+
instanceId: this.instanceId,
|
|
99
|
+
tableId: this.tableId,
|
|
100
|
+
rowId: this.rowId,
|
|
101
|
+
data: args
|
|
102
|
+
});
|
|
103
|
+
}
|
|
21
104
|
}
|
|
105
|
+
|
package/src/lowcode.sdk.ts
CHANGED
|
@@ -1,20 +1,26 @@
|
|
|
1
1
|
import { BaseSDK } from "./base";
|
|
2
2
|
import { LISTENER_CMDS } from "./constants";
|
|
3
3
|
import { Form } from "./form";
|
|
4
|
+
import { TableForm } from "./form";
|
|
4
5
|
import { Client } from "./client";
|
|
5
6
|
import { Formatter } from './formatter';
|
|
6
7
|
import { Application } from "./app";
|
|
7
8
|
import { Component } from "./component";
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
currentForm: Form;
|
|
10
|
+
class LowcodeSDK extends BaseSDK {
|
|
11
|
+
currentForm: Form | TableForm;
|
|
11
12
|
client: Client;
|
|
12
13
|
formatter: Formatter;
|
|
13
14
|
app: Application;
|
|
14
15
|
|
|
15
16
|
constructor(props: any) {
|
|
16
17
|
super({});
|
|
17
|
-
|
|
18
|
+
if (props.tableId && props.rowId) {
|
|
19
|
+
this.currentForm = new TableForm(props.instanceId, props.tableId, props.rowId);
|
|
20
|
+
}
|
|
21
|
+
else if(props.instanceId) {
|
|
22
|
+
this.currentForm = new Form(props.instanceId);
|
|
23
|
+
}
|
|
18
24
|
this.client = new Client({});
|
|
19
25
|
this.formatter = new Formatter({});
|
|
20
26
|
this.app = new Application({});
|
package/webpack.config.js
CHANGED
|
@@ -5,6 +5,7 @@ const HtmlWebpackPlugin = require("html-webpack-plugin");
|
|
|
5
5
|
let config = {
|
|
6
6
|
devtool: "source-map",
|
|
7
7
|
mode: "development",
|
|
8
|
+
entry: "./src/index.ts",
|
|
8
9
|
devServer: {
|
|
9
10
|
contentBase: path.join(__dirname, "dist"),
|
|
10
11
|
port: 3000,
|
|
@@ -43,7 +44,6 @@ let moduleLib = Object.assign({}, config, {
|
|
|
43
44
|
experiments: {
|
|
44
45
|
outputModule: true
|
|
45
46
|
},
|
|
46
|
-
entry: "./src/lowcode.sdk.ts",
|
|
47
47
|
output: {
|
|
48
48
|
filename: "kflowcode.sdk.module.js",
|
|
49
49
|
path: path.resolve(__dirname, "dist"),
|
|
@@ -54,7 +54,6 @@ let moduleLib = Object.assign({}, config, {
|
|
|
54
54
|
}
|
|
55
55
|
});
|
|
56
56
|
let commonLib = Object.assign({}, config, {
|
|
57
|
-
entry: "./src/index.ts",
|
|
58
57
|
output: {
|
|
59
58
|
filename: "kflowcode.sdk.js",
|
|
60
59
|
path: path.resolve(__dirname, "dist")
|