@kissflow/lowcode-client-sdk 1.0.1 → 1.0.2-beta.8
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 +152 -13
- package/custom.build.js +22 -2
- package/dist/component.js +10 -0
- package/dist/constants.js +8 -1
- package/dist/form.js +89 -7
- package/dist/global.types.d.ts +39 -23
- package/dist/index.d.ts +64 -31
- package/dist/kflowcode.sdk.js +118 -15
- package/dist/kflowcode.sdk.js.map +1 -1
- package/dist/kflowcode.sdk.module.js +138 -21
- package/dist/kflowcode.sdk.module.js.map +1 -1
- package/dist/lowcode.sdk.js +7 -7
- package/dist/page.js +4 -0
- package/package.json +1 -1
- package/src/base.ts +1 -1
- package/src/component.ts +10 -0
- package/src/constants.ts +8 -1
- package/src/form.ts +112 -2
- package/src/lowcode.sdk.ts +9 -6
- package/src/page.ts +4 -0
- package/webpack.config.js +1 -2
package/src/form.ts
CHANGED
|
@@ -2,8 +2,22 @@ import { BaseSDK } from "./base";
|
|
|
2
2
|
import { LISTENER_CMDS } from "./constants";
|
|
3
3
|
|
|
4
4
|
export class Form extends BaseSDK {
|
|
5
|
+
private instanceId: string;
|
|
6
|
+
constructor(instanceId: string) {
|
|
7
|
+
super({});
|
|
8
|
+
this.instanceId = instanceId;
|
|
9
|
+
}
|
|
10
|
+
toJSON() {
|
|
11
|
+
return this._postMessageAsync(
|
|
12
|
+
LISTENER_CMDS.TO_JSON,
|
|
13
|
+
{
|
|
14
|
+
instanceId: this.instanceId
|
|
15
|
+
},
|
|
16
|
+
);
|
|
17
|
+
}
|
|
5
18
|
getField(fieldId: string) {
|
|
6
19
|
return this._postMessageAsync(LISTENER_CMDS.GET_FORM_FIELD, {
|
|
20
|
+
instanceId: this.instanceId,
|
|
7
21
|
fieldId
|
|
8
22
|
});
|
|
9
23
|
}
|
|
@@ -12,10 +26,106 @@ export class Form extends BaseSDK {
|
|
|
12
26
|
data: args
|
|
13
27
|
});
|
|
14
28
|
}
|
|
15
|
-
|
|
29
|
+
getTable(tableId: string) {
|
|
30
|
+
return new Table(this.instanceId, tableId);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
class Table extends BaseSDK {
|
|
35
|
+
private tableId: string;
|
|
36
|
+
private instanceId: string;
|
|
37
|
+
|
|
38
|
+
constructor(instanceId: string,tableId: string) {
|
|
39
|
+
super({});
|
|
40
|
+
this.tableId = tableId;
|
|
41
|
+
this.instanceId = instanceId
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// list of obj of rows
|
|
45
|
+
toJSON() {
|
|
46
|
+
return this._postMessageAsync(
|
|
47
|
+
LISTENER_CMDS.TO_JSON,
|
|
48
|
+
{
|
|
49
|
+
tableId: this.tableId
|
|
50
|
+
},
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
getRows():TableForm[] {
|
|
55
|
+
// list of TableForm class
|
|
56
|
+
return this._postMessageAsync(
|
|
57
|
+
LISTENER_CMDS.GET_TABLE_ROWS,
|
|
58
|
+
{ tableId: this.tableId },
|
|
59
|
+
true, // has callBack
|
|
60
|
+
(data) => {
|
|
61
|
+
console.log(data);
|
|
62
|
+
return data.map((row) => new TableForm(this.instanceId, this.tableId, row.id))
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
getRow(rowId: string) {
|
|
68
|
+
return new TableForm(this.instanceId, this.tableId, rowId);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
addRow(rowObject: object) {
|
|
16
72
|
return this._postMessageAsync(LISTENER_CMDS.ADD_TABLE_ROW, {
|
|
17
|
-
tableId,
|
|
73
|
+
tableId: this.tableId,
|
|
18
74
|
rowObject
|
|
19
75
|
});
|
|
20
76
|
}
|
|
77
|
+
|
|
78
|
+
deleteRow(rowId: string) {
|
|
79
|
+
return this._postMessageAsync(LISTENER_CMDS.DELETE_TABLE_ROW, {
|
|
80
|
+
tableId: this.tableId,
|
|
81
|
+
rowId
|
|
82
|
+
});
|
|
83
|
+
}
|
|
21
84
|
}
|
|
85
|
+
|
|
86
|
+
export class TableForm extends BaseSDK {
|
|
87
|
+
private instanceId: string;
|
|
88
|
+
private tableId: string;
|
|
89
|
+
private rowId: string;
|
|
90
|
+
|
|
91
|
+
constructor(instanceId: string, tableId: string, rowId: string) {
|
|
92
|
+
super({});
|
|
93
|
+
this.instanceId = instanceId;
|
|
94
|
+
this.tableId = tableId;
|
|
95
|
+
this.rowId = rowId;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
getParent() {
|
|
99
|
+
return new Form(this.instanceId);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
toJSON() {
|
|
103
|
+
return this._postMessageAsync(
|
|
104
|
+
LISTENER_CMDS.TO_JSON,
|
|
105
|
+
{
|
|
106
|
+
tableId: this.tableId,
|
|
107
|
+
rowId: this.rowId
|
|
108
|
+
},
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
getField(fieldId: string) {
|
|
114
|
+
return this._postMessageAsync(LISTENER_CMDS.GET_FORM_FIELD, {
|
|
115
|
+
instanceId: this.instanceId,
|
|
116
|
+
tableId: this.tableId,
|
|
117
|
+
rowId: this.rowId,
|
|
118
|
+
fieldId
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
updateField(args: object) {
|
|
123
|
+
return this._postMessageAsync(LISTENER_CMDS.UPDATE_FORM, {
|
|
124
|
+
instanceId: this.instanceId,
|
|
125
|
+
tableId: this.tableId,
|
|
126
|
+
rowId: this.rowId,
|
|
127
|
+
data: args
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
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({});
|
|
@@ -29,9 +35,6 @@ export class LowcodeSDK extends BaseSDK {
|
|
|
29
35
|
getContext(): string | object {
|
|
30
36
|
return this._postMessageAsync(LISTENER_CMDS.GET_CONTEXT, {});
|
|
31
37
|
}
|
|
32
|
-
getComponent(componentId: string): Component {
|
|
33
|
-
return new Component(componentId);
|
|
34
|
-
}
|
|
35
38
|
}
|
|
36
39
|
|
|
37
40
|
function initSDK(config: any = {}): LowcodeSDK {
|
package/src/page.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Component } from './component';
|
|
1
2
|
import { BaseSDK } from "./base";
|
|
2
3
|
import { LISTENER_CMDS, EVENT_TYPES } from "./constants";
|
|
3
4
|
|
|
@@ -45,6 +46,9 @@ export class Page extends BaseSDK {
|
|
|
45
46
|
}
|
|
46
47
|
);
|
|
47
48
|
}
|
|
49
|
+
getComponent(componentId: string): Component {
|
|
50
|
+
return new Component(componentId);
|
|
51
|
+
}
|
|
48
52
|
onClose(callback: Function) {
|
|
49
53
|
this._registerEventListener(this._id, EVENT_TYPES.ON_CLOSE, callback);
|
|
50
54
|
}
|
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")
|