@kissflow/lowcode-client-sdk 1.0.4-beta.1 → 1.0.6-beta

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/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
@@ -1,7 +0,0 @@
1
- import LowcodeSDK from "./lowcode.sdk";
2
-
3
- if (typeof _BUILD !== "undefined" && _BUILD) {
4
- self.KF = LowcodeSDK;
5
- }
6
-
7
- export default LowcodeSDK;
@@ -1,44 +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 { Component } from "./component";
9
-
10
- class LowcodeSDK extends BaseSDK {
11
- currentForm: Form | TableForm;
12
- client: Client;
13
- formatter: Formatter;
14
- app: Application;
15
-
16
- constructor(props: any) {
17
- super({});
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
- }
24
- this.client = new Client({});
25
- this.formatter = new Formatter({});
26
- this.app = new Application({});
27
- }
28
-
29
- api(url: string, args = {}): string | object {
30
- return this._postMessageAsync(LISTENER_CMDS.API, { url, args });
31
- }
32
- watchParams(func: (data: any) => any) {
33
- this._postMessage(LISTENER_CMDS.PARAMS, func);
34
- }
35
- getContext(): string | object {
36
- return this._postMessageAsync(LISTENER_CMDS.GET_CONTEXT, {});
37
- }
38
- }
39
-
40
- function initSDK(config: any = {}): LowcodeSDK {
41
- return new LowcodeSDK(config);
42
- }
43
-
44
- 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
- }
@@ -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
@@ -1,7 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "lib": ["es2016"],
4
- "rootDir": "./src",
5
- "outDir": "./dist"
6
- }
7
- }
@@ -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];