@kissflow/lowcode-client-sdk 1.0.6 → 1.0.8-beta.2
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 +190 -66
- package/dist/kfsdk.es.js +379 -0
- package/dist/kfsdk.umd.js +1 -0
- package/dist/kfworkersdk.es.js +470 -0
- package/package.json +23 -9
- package/SDK_IN_INTEGRATION.md +0 -78
- package/custom.build.js +0 -103
- package/dist/app.js +0 -48
- package/dist/base.js +0 -170
- package/dist/client.js +0 -44
- package/dist/component.js +0 -45
- package/dist/constants.js +0 -48
- package/dist/form.js +0 -126
- package/dist/formatter.js +0 -54
- package/dist/global.types.d.ts +0 -81
- package/dist/index.d.ts +0 -176
- package/dist/index.html +0 -23
- package/dist/index.js +0 -7
- package/dist/kflowcode.sdk.js +0 -896
- package/dist/kflowcode.sdk.js.map +0 -1
- package/dist/kflowcode.sdk.module.js +0 -896
- package/dist/kflowcode.sdk.module.js.map +0 -1
- package/dist/lowcode.sdk.js +0 -58
- package/dist/page.js +0 -63
- package/dist/sdk.types.js +0 -2
- package/id +0 -55
- package/index.html +0 -23
- package/src/app.ts +0 -31
- package/src/base.ts +0 -108
- package/src/client.ts +0 -28
- package/src/component.ts +0 -25
- package/src/constants.ts +0 -53
- package/src/form.ts +0 -131
- package/src/formatter.ts +0 -35
- package/src/index.ts +0 -7
- package/src/lowcode.sdk.ts +0 -51
- package/src/page.ts +0 -43
- package/src/sdk.types.ts +0 -11
- package/test/lcnc-handler.js +0 -45
- package/test/mock/api.js +0 -16
- package/test/mock/id.js +0 -55
- package/tsconfig.json +0 -7
- package/tsconfig.types.json +0 -18
- package/webpack.config.js +0 -62
package/src/form.ts
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import { BaseSDK } from "./base";
|
|
2
|
-
import { LISTENER_CMDS } from "./constants";
|
|
3
|
-
|
|
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
|
-
}
|
|
18
|
-
getField(fieldId: string) {
|
|
19
|
-
return this._postMessageAsync(LISTENER_CMDS.GET_FORM_FIELD, {
|
|
20
|
-
instanceId: this.instanceId,
|
|
21
|
-
fieldId
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
updateField(args: object) {
|
|
25
|
-
return this._postMessageAsync(LISTENER_CMDS.UPDATE_FORM, {
|
|
26
|
-
data: args
|
|
27
|
-
});
|
|
28
|
-
}
|
|
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) {
|
|
72
|
-
return this._postMessageAsync(LISTENER_CMDS.ADD_TABLE_ROW, {
|
|
73
|
-
tableId: this.tableId,
|
|
74
|
-
rowObject
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
deleteRow(rowId: string) {
|
|
79
|
-
return this._postMessageAsync(LISTENER_CMDS.DELETE_TABLE_ROW, {
|
|
80
|
-
tableId: this.tableId,
|
|
81
|
-
rowId
|
|
82
|
-
});
|
|
83
|
-
}
|
|
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/formatter.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { BaseSDK } from "./base";
|
|
2
|
-
import { LISTENER_CMDS } from "./constants";
|
|
3
|
-
|
|
4
|
-
export class Formatter extends BaseSDK {
|
|
5
|
-
toDate(date: string) {
|
|
6
|
-
return this._postMessageAsync(LISTENER_CMDS.FORMAT_DATE, {
|
|
7
|
-
date,
|
|
8
|
-
});
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
toDateTime(date: string) {
|
|
12
|
-
return this._postMessageAsync(LISTENER_CMDS.FORMAT_DATE_TIME, {
|
|
13
|
-
date,
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
toNumber(value: string) {
|
|
18
|
-
return this._postMessageAsync(LISTENER_CMDS.FORMAT_NUMBER, {
|
|
19
|
-
value,
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
toCurrency(value: string, currencyCode: string) {
|
|
24
|
-
return this._postMessageAsync(LISTENER_CMDS.FORMAT_CURRENCY, {
|
|
25
|
-
value,
|
|
26
|
-
currencyCode,
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
toBoolean(value: string) {
|
|
31
|
-
return this._postMessageAsync(LISTENER_CMDS.FORMAT_BOOLEAN, {
|
|
32
|
-
value
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
}
|
package/src/index.ts
DELETED
package/src/lowcode.sdk.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { BaseSDK } from "./base";
|
|
2
|
-
import { LISTENER_CMDS } from "./constants";
|
|
3
|
-
import { Form } from "./form";
|
|
4
|
-
import { TableForm } from "./form";
|
|
5
|
-
import { Client } from "./client";
|
|
6
|
-
import { Formatter } from "./formatter";
|
|
7
|
-
import { Application } from "./app";
|
|
8
|
-
import { userObject, accountObject } from "./sdk.types";
|
|
9
|
-
|
|
10
|
-
class LowcodeSDK extends BaseSDK {
|
|
11
|
-
currentForm: Form | TableForm;
|
|
12
|
-
client: Client;
|
|
13
|
-
formatter: Formatter;
|
|
14
|
-
app: Application;
|
|
15
|
-
user: userObject;
|
|
16
|
-
account: accountObject;
|
|
17
|
-
|
|
18
|
-
constructor(props: any) {
|
|
19
|
-
super({});
|
|
20
|
-
if (props.tableId && props.rowId) {
|
|
21
|
-
this.currentForm = new TableForm(
|
|
22
|
-
props.instanceId,
|
|
23
|
-
props.tableId,
|
|
24
|
-
props.rowId
|
|
25
|
-
);
|
|
26
|
-
} else if (props.instanceId) {
|
|
27
|
-
this.currentForm = new Form(props.instanceId);
|
|
28
|
-
}
|
|
29
|
-
this.client = new Client({});
|
|
30
|
-
this.formatter = new Formatter({});
|
|
31
|
-
this.app = new Application({});
|
|
32
|
-
this.user = props.user;
|
|
33
|
-
this.account = props.account;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
api(url: string, args = {}): string | object {
|
|
37
|
-
return this._postMessageAsync(LISTENER_CMDS.API, { url, args });
|
|
38
|
-
}
|
|
39
|
-
watchParams(func: (data: any) => any) {
|
|
40
|
-
this._postMessage(LISTENER_CMDS.PARAMS, func);
|
|
41
|
-
}
|
|
42
|
-
getContext(): string | object {
|
|
43
|
-
return this._postMessageAsync(LISTENER_CMDS.GET_CONTEXT, {});
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function initSDK(config: any = {}): LowcodeSDK {
|
|
48
|
-
return new LowcodeSDK(config);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export default initSDK;
|
package/src/page.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { Component } from "./component";
|
|
2
|
-
import { BaseSDK } from "./base";
|
|
3
|
-
import { LISTENER_CMDS, EVENT_TYPES } from "./constants";
|
|
4
|
-
|
|
5
|
-
export class Page extends BaseSDK {
|
|
6
|
-
_id: string;
|
|
7
|
-
constructor(pageId: string) {
|
|
8
|
-
super({});
|
|
9
|
-
this._id = pageId;
|
|
10
|
-
}
|
|
11
|
-
getParameter(key: string) {
|
|
12
|
-
return this._postMessageAsync(LISTENER_CMDS.GET_PAGE_PARAMS, {
|
|
13
|
-
key
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
getVariable(key: string) {
|
|
17
|
-
return this._postMessageAsync(LISTENER_CMDS.GET_PAGE_VARIABLE, {
|
|
18
|
-
key
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
setVariable(key: string, value: any) {
|
|
22
|
-
return this._postMessageAsync(LISTENER_CMDS.SET_PAGE_VARIABLE, {
|
|
23
|
-
key,
|
|
24
|
-
value
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
openPopup(popupId: string, popupParams: object) {
|
|
28
|
-
//TODO: add popup class
|
|
29
|
-
return this._postMessageAsync(LISTENER_CMDS.OPEN_POPUP_PAGE, {
|
|
30
|
-
popupId,
|
|
31
|
-
popupParams
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
closePopup() {
|
|
35
|
-
return this._postMessageAsync(LISTENER_CMDS.CLOSE_POPUP, {});
|
|
36
|
-
}
|
|
37
|
-
getComponent(componentId: string): Component {
|
|
38
|
-
return new Component(componentId);
|
|
39
|
-
}
|
|
40
|
-
onClose(callback: Function) {
|
|
41
|
-
this._registerEventListener(this._id, EVENT_TYPES.ON_CLOSE, callback);
|
|
42
|
-
}
|
|
43
|
-
}
|
package/src/sdk.types.ts
DELETED
package/test/lcnc-handler.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
class LCNCHandler {
|
|
2
|
-
constructor(props) {
|
|
3
|
-
console.log("Initializing LCNC HANDLER", props);
|
|
4
|
-
this._onMessage = this._onMessage.bind(this);
|
|
5
|
-
window.addEventListener("message", this._onMessage, false);
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
_onMessage(event) {
|
|
9
|
-
console.log("Parent receives messsage", event);
|
|
10
|
-
const data = event.data;
|
|
11
|
-
this.execute(event.data, event.source);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
execute(data, sourceWindow) {
|
|
15
|
-
switch (data.command) {
|
|
16
|
-
case "PARAMS":
|
|
17
|
-
this.sendBack(sourceWindow, data, {value: "message from parent"});
|
|
18
|
-
break;
|
|
19
|
-
case "API":
|
|
20
|
-
fetch(data.url, data.args).then(async (resp) => {
|
|
21
|
-
const json = await resp.json();
|
|
22
|
-
this.sendBack(sourceWindow, data, json);
|
|
23
|
-
});
|
|
24
|
-
break;
|
|
25
|
-
case "REDIRECT":
|
|
26
|
-
window.location.href = data.url;
|
|
27
|
-
break;
|
|
28
|
-
default:
|
|
29
|
-
console.log("Command not specified", data);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
sendBack(sourceWindow, req, res) {
|
|
34
|
-
if(req._id) {
|
|
35
|
-
sourceWindow.postMessage({_req :req, ...res}, "*")
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function initHandler(options = {}) {
|
|
42
|
-
return new LCNCHandler(options);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export default initHandler
|
package/test/mock/api.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import idJSON from './id.js';
|
|
2
|
-
|
|
3
|
-
const MockAPI = {
|
|
4
|
-
"/id": idJSON,
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
self.fetch = (url, config) => {
|
|
8
|
-
let json = MockAPI[url] || {"Id": "url doesn't match"}
|
|
9
|
-
const resp = new Response(JSON.stringify(json), { "status" : 200 })
|
|
10
|
-
return new Promise((resolve, reject) => {
|
|
11
|
-
resolve(resp);
|
|
12
|
-
});
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
export default MockAPI
|
package/test/mock/id.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
"_id": "Account001",
|
|
3
|
-
"Name": "OS",
|
|
4
|
-
"UserDetails": {
|
|
5
|
-
"_id": "User001",
|
|
6
|
-
"Name": "Vivek",
|
|
7
|
-
"AppConfig": {
|
|
8
|
-
"Env": "AltairUSP001",
|
|
9
|
-
"ProfileBasePath": "https://s3.amazonaws.com/altair-sss-pro-p001",
|
|
10
|
-
"UploadHost": "https://attachment.kissflow.com"
|
|
11
|
-
},
|
|
12
|
-
"ProfilePicture": {
|
|
13
|
-
"large": {
|
|
14
|
-
"fileExtension": "jpeg",
|
|
15
|
-
"height": 150,
|
|
16
|
-
"key": "AcFlqmVfTZ1X/UsEEpZPxSsvJ/photos/150x150.jpeg",
|
|
17
|
-
"name": "150x150.jpeg",
|
|
18
|
-
"size": 7939,
|
|
19
|
-
"width": 150
|
|
20
|
-
},
|
|
21
|
-
"medium": {
|
|
22
|
-
"fileExtension": "jpeg",
|
|
23
|
-
"height": 130,
|
|
24
|
-
"key": "AcFlqmVfTZ1X/UsEEpZPxSsvJ/photos/130x130.jpeg",
|
|
25
|
-
"name": "130x130.jpeg",
|
|
26
|
-
"size": 6433,
|
|
27
|
-
"width": 130
|
|
28
|
-
},
|
|
29
|
-
"original": {
|
|
30
|
-
"fileExtension": "jpg",
|
|
31
|
-
"height": 2611,
|
|
32
|
-
"key": "AcFlqmVfTZ1X/UsEEpZPxSsvJ/Vivek-Engg.jpg",
|
|
33
|
-
"name": "Vivek-Engg.jpg",
|
|
34
|
-
"size": 1797398,
|
|
35
|
-
"width": 2611
|
|
36
|
-
},
|
|
37
|
-
"preview": {
|
|
38
|
-
"fileExtension": "jpeg",
|
|
39
|
-
"height": 600,
|
|
40
|
-
"key": "AcFlqmVfTZ1X/UsEEpZPxSsvJ/photos/600x600.jpeg",
|
|
41
|
-
"name": "600x600.jpeg",
|
|
42
|
-
"size": 86345,
|
|
43
|
-
"width": 600
|
|
44
|
-
},
|
|
45
|
-
"small": {
|
|
46
|
-
"fileExtension": "jpeg",
|
|
47
|
-
"height": 70,
|
|
48
|
-
"key": "AcFlqmVfTZ1X/UsEEpZPxSsvJ/photos/70x70.jpeg",
|
|
49
|
-
"name": "70x70.jpeg",
|
|
50
|
-
"size": 2691,
|
|
51
|
-
"width": 70
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
package/tsconfig.json
DELETED
package/tsconfig.types.json
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"include": [
|
|
3
|
-
"./src/"
|
|
4
|
-
],
|
|
5
|
-
"exclude": [
|
|
6
|
-
"./src/constants.ts",
|
|
7
|
-
"./src/index.ts",
|
|
8
|
-
"./src/base.ts"
|
|
9
|
-
],
|
|
10
|
-
"compilerOptions": {
|
|
11
|
-
"baseUrl": ".",
|
|
12
|
-
"target": "es6",
|
|
13
|
-
"module": "es2020",
|
|
14
|
-
"declaration": true,
|
|
15
|
-
"emitDeclarationOnly": true,
|
|
16
|
-
"outFile": "./dist/index.d.ts"
|
|
17
|
-
}
|
|
18
|
-
}
|
package/webpack.config.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
const path = require("path");
|
|
2
|
-
const webpack = require("webpack");
|
|
3
|
-
const HtmlWebpackPlugin = require("html-webpack-plugin");
|
|
4
|
-
|
|
5
|
-
let config = {
|
|
6
|
-
devtool: "source-map",
|
|
7
|
-
mode: "development",
|
|
8
|
-
entry: "./src/index.ts",
|
|
9
|
-
devServer: {
|
|
10
|
-
contentBase: path.join(__dirname, "dist"),
|
|
11
|
-
port: 3000,
|
|
12
|
-
open: true
|
|
13
|
-
},
|
|
14
|
-
resolve: {
|
|
15
|
-
extensions: [".ts", ".js"]
|
|
16
|
-
},
|
|
17
|
-
module: {
|
|
18
|
-
rules: [
|
|
19
|
-
{
|
|
20
|
-
test: /\.ts?/,
|
|
21
|
-
use: {
|
|
22
|
-
loader: "ts-loader",
|
|
23
|
-
options: {
|
|
24
|
-
transpileOnly: true
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
exclude: /node_modules/
|
|
28
|
-
}
|
|
29
|
-
]
|
|
30
|
-
},
|
|
31
|
-
plugins: [
|
|
32
|
-
new webpack.DefinePlugin({
|
|
33
|
-
_BUILD: true
|
|
34
|
-
}),
|
|
35
|
-
new HtmlWebpackPlugin({
|
|
36
|
-
template: "./index.html",
|
|
37
|
-
filename: "index.html",
|
|
38
|
-
inject: "body"
|
|
39
|
-
})
|
|
40
|
-
]
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
let moduleLib = Object.assign({}, config, {
|
|
44
|
-
experiments: {
|
|
45
|
-
outputModule: true
|
|
46
|
-
},
|
|
47
|
-
output: {
|
|
48
|
-
filename: "kflowcode.sdk.module.js",
|
|
49
|
-
path: path.resolve(__dirname, "dist"),
|
|
50
|
-
|
|
51
|
-
library: {
|
|
52
|
-
type: "module"
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
let commonLib = Object.assign({}, config, {
|
|
57
|
-
output: {
|
|
58
|
-
filename: "kflowcode.sdk.js",
|
|
59
|
-
path: path.resolve(__dirname, "dist")
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
module.exports = [moduleLib, commonLib];
|