@lowdefy/server 3.23.0-alpha.0 → 4.0.0-alpha.4
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/.eslintrc.yaml +1 -0
- package/next.config.js +32 -0
- package/package.json +30 -25
- package/src/components/Context.js +61 -0
- package/src/components/Head.js +28 -0
- package/src/components/LowdefyContext.js +47 -0
- package/src/components/Page.js +60 -0
- package/src/components/block/Block.js +57 -0
- package/src/components/block/CategorySwitch.js +120 -0
- package/src/components/block/Container.js +87 -0
- package/src/components/block/List.js +94 -0
- package/src/components/block/LoadingBlock.js +22 -0
- package/src/components/block/MountEvents.js +46 -0
- package/src/components/components.js +25 -0
- package/src/pages/[pageId].js +49 -0
- package/src/pages/_app.js +37 -0
- package/src/pages/api/auth/[...nextauth].js +28 -0
- package/src/pages/api/request/[pageId]/[requestId].js +41 -0
- package/src/pages/index.js +55 -0
- package/src/public/apple-touch-icon.png +0 -0
- package/src/public/icon-32.png +0 -0
- package/src/public/icon-512.png +0 -0
- package/src/public/icon.svg +17 -0
- package/src/public/logo-dark-theme.png +0 -0
- package/src/public/logo-light-theme.png +0 -0
- package/src/public/logo-square-dark-theme.png +0 -0
- package/src/public/logo-square-light-theme.png +0 -0
- package/src/public/manifest.webmanifest +16 -0
- package/src/utils/callRequest.js +27 -0
- package/src/utils/request.js +35 -0
- package/src/utils/setupLink.js +44 -0
- package/dist/index.js +0 -106
package/.eslintrc.yaml
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
extends: 'plugin:@next/next/core-web-vitals'
|
package/next.config.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const withLess = require('next-with-less');
|
|
2
|
+
|
|
3
|
+
module.exports = withLess({
|
|
4
|
+
lessLoaderOptions: {
|
|
5
|
+
lessOptions: {
|
|
6
|
+
modifyVars: {
|
|
7
|
+
'primary-color': '#9900FF',
|
|
8
|
+
},
|
|
9
|
+
},
|
|
10
|
+
},
|
|
11
|
+
reactStrictMode: true,
|
|
12
|
+
webpack: (config, { isServer }) => {
|
|
13
|
+
if (!isServer) {
|
|
14
|
+
config.resolve.fallback = {
|
|
15
|
+
assert: false,
|
|
16
|
+
buffer: false,
|
|
17
|
+
crypto: false,
|
|
18
|
+
events: false,
|
|
19
|
+
fs: false,
|
|
20
|
+
path: false,
|
|
21
|
+
process: false,
|
|
22
|
+
util: false,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
return config;
|
|
26
|
+
},
|
|
27
|
+
poweredByHeader: false,
|
|
28
|
+
// productionBrowserSourceMaps: true
|
|
29
|
+
// experimental: {
|
|
30
|
+
// concurrentFeatures: true,
|
|
31
|
+
// },
|
|
32
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lowdefy/server",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-alpha.4",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
|
@@ -25,39 +25,44 @@
|
|
|
25
25
|
"type": "git",
|
|
26
26
|
"url": "https://github.com/lowdefy/lowdefy.git"
|
|
27
27
|
},
|
|
28
|
-
"main": "dist/index.js",
|
|
29
28
|
"files": [
|
|
30
|
-
"
|
|
29
|
+
"src/*",
|
|
30
|
+
"next.config.js",
|
|
31
|
+
".eslintrc.yaml"
|
|
31
32
|
],
|
|
32
33
|
"scripts": {
|
|
33
|
-
"
|
|
34
|
-
"build": "
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"start": "
|
|
34
|
+
"build": "lowdefy-build && next build",
|
|
35
|
+
"build:lowdefy": "lowdefy-build",
|
|
36
|
+
"build:next": "next build",
|
|
37
|
+
"dev": "next dev",
|
|
38
|
+
"start": "next start",
|
|
39
|
+
"lint": "next lint",
|
|
40
|
+
"next": "next"
|
|
38
41
|
},
|
|
39
42
|
"dependencies": {
|
|
40
|
-
"@lowdefy/
|
|
41
|
-
"@lowdefy/
|
|
42
|
-
"@lowdefy/
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
43
|
+
"@lowdefy/api": "4.0.0-alpha.4",
|
|
44
|
+
"@lowdefy/block-utils": "4.0.0-alpha.4",
|
|
45
|
+
"@lowdefy/blocks-antd": "4.0.0-alpha.4",
|
|
46
|
+
"@lowdefy/blocks-basic": "4.0.0-alpha.4",
|
|
47
|
+
"@lowdefy/connection-axios-http": "4.0.0-alpha.4",
|
|
48
|
+
"@lowdefy/engine": "4.0.0-alpha.4",
|
|
49
|
+
"@lowdefy/helpers": "4.0.0-alpha.4",
|
|
50
|
+
"@lowdefy/layout": "4.0.0-alpha.4",
|
|
51
|
+
"next": "12.0.3",
|
|
52
|
+
"next-auth": "4.0.0-beta.6",
|
|
53
|
+
"react": "18.0.0-alpha-327d5c484-20211106",
|
|
54
|
+
"react-dom": "18.0.0-alpha-327d5c484-20211106",
|
|
55
|
+
"react-icons": "4.3.1"
|
|
47
56
|
},
|
|
48
57
|
"devDependencies": {
|
|
49
|
-
"@
|
|
50
|
-
"@
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"babel-jest": "26.6.3",
|
|
55
|
-
"babel-loader": "8.2.2",
|
|
56
|
-
"jest": "26.6.3",
|
|
57
|
-
"nodemon": "2.0.7"
|
|
58
|
+
"@lowdefy/build": "4.0.0-alpha.4",
|
|
59
|
+
"@next/eslint-plugin-next": "12.0.4",
|
|
60
|
+
"less": "4.1.2",
|
|
61
|
+
"less-loader": "10.2.0",
|
|
62
|
+
"next-with-less": "2.0.2"
|
|
58
63
|
},
|
|
59
64
|
"publishConfig": {
|
|
60
65
|
"access": "public"
|
|
61
66
|
},
|
|
62
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "537d166ba3f6e017b8a61c2a7e5c12fd0a48bf67"
|
|
63
68
|
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2021 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import React, { useEffect, useState } from 'react';
|
|
18
|
+
import getContext from '@lowdefy/engine';
|
|
19
|
+
|
|
20
|
+
import MountEvents from './block/MountEvents.js';
|
|
21
|
+
|
|
22
|
+
const Context = ({ children, lowdefy, config }) => {
|
|
23
|
+
const [context, setContext] = useState({});
|
|
24
|
+
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
let mounted = true;
|
|
27
|
+
const mount = async () => {
|
|
28
|
+
const ctx = await getContext({
|
|
29
|
+
config,
|
|
30
|
+
lowdefy,
|
|
31
|
+
});
|
|
32
|
+
if (mounted) {
|
|
33
|
+
setContext(ctx);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
mount();
|
|
37
|
+
return () => {
|
|
38
|
+
mounted = false;
|
|
39
|
+
};
|
|
40
|
+
}, [config, lowdefy]);
|
|
41
|
+
const loadingPage = context.id !== config.id;
|
|
42
|
+
|
|
43
|
+
if (loadingPage) {
|
|
44
|
+
return children(context, loadingPage, 'pager');
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<MountEvents
|
|
49
|
+
asyncEventName="onEnterAsync"
|
|
50
|
+
context={context}
|
|
51
|
+
eventName="onEnter"
|
|
52
|
+
triggerEvent={({ name, context }) =>
|
|
53
|
+
context._internal.RootBlocks.areas.root.blocks[0].triggerEvent({ name })
|
|
54
|
+
}
|
|
55
|
+
>
|
|
56
|
+
{(loading) => children(context, loading, 'mounter')}
|
|
57
|
+
</MountEvents>
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export default Context;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2021 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import React from 'react';
|
|
18
|
+
import Head from 'next/head';
|
|
19
|
+
|
|
20
|
+
const BindHead = ({ properties }) => {
|
|
21
|
+
return (
|
|
22
|
+
<Head>
|
|
23
|
+
<title>{properties.title}</title>
|
|
24
|
+
</Head>
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export default BindHead;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2021 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import React from 'react';
|
|
18
|
+
|
|
19
|
+
import callRequest from '../utils/callRequest.js';
|
|
20
|
+
import blockComponents from '../../build/plugins/blocks.js';
|
|
21
|
+
import components from './components.js';
|
|
22
|
+
|
|
23
|
+
const LowdefyContext = ({ children }) => {
|
|
24
|
+
const lowdefy = {
|
|
25
|
+
_internal: {
|
|
26
|
+
blockComponents,
|
|
27
|
+
callRequest,
|
|
28
|
+
components,
|
|
29
|
+
document,
|
|
30
|
+
updaters: {},
|
|
31
|
+
window,
|
|
32
|
+
displayMessage: ({ content }) => {
|
|
33
|
+
alert(content);
|
|
34
|
+
return () => undefined;
|
|
35
|
+
},
|
|
36
|
+
link: () => undefined,
|
|
37
|
+
},
|
|
38
|
+
contexts: {},
|
|
39
|
+
inputs: {},
|
|
40
|
+
lowdefyGlobal: {},
|
|
41
|
+
};
|
|
42
|
+
lowdefy._internal.updateBlock = (blockId) =>
|
|
43
|
+
lowdefy._internal.updaters[blockId] && lowdefy._internal.updaters[blockId]();
|
|
44
|
+
return <>{children(lowdefy)}</>;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export default LowdefyContext;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2021 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import React from 'react';
|
|
18
|
+
|
|
19
|
+
import { useRouter } from 'next/router';
|
|
20
|
+
|
|
21
|
+
import Context from './Context.js';
|
|
22
|
+
import Head from './Head.js';
|
|
23
|
+
import Block from './block/Block.js';
|
|
24
|
+
import setupLink from '../utils/setupLink.js';
|
|
25
|
+
|
|
26
|
+
const LoadingBlock = () => <div>Loading...</div>;
|
|
27
|
+
|
|
28
|
+
const Page = ({ lowdefy, pageConfig, rootConfig }) => {
|
|
29
|
+
const router = useRouter();
|
|
30
|
+
lowdefy._internal.basePath = router.basePath;
|
|
31
|
+
lowdefy._internal.pathname = router.pathname;
|
|
32
|
+
lowdefy._internal.query = router.query;
|
|
33
|
+
lowdefy._internal.router = router;
|
|
34
|
+
lowdefy._internal.link = setupLink({ lowdefy });
|
|
35
|
+
lowdefy.home = rootConfig.home;
|
|
36
|
+
lowdefy.lowdefyGlobal = rootConfig.lowdefyGlobal;
|
|
37
|
+
lowdefy.menus = rootConfig.menus;
|
|
38
|
+
return (
|
|
39
|
+
<Context config={pageConfig} lowdefy={lowdefy}>
|
|
40
|
+
{(context, loading) => {
|
|
41
|
+
if (loading) {
|
|
42
|
+
return <LoadingBlock />;
|
|
43
|
+
}
|
|
44
|
+
return (
|
|
45
|
+
<>
|
|
46
|
+
<Head properties={context._internal.RootBlocks.map[pageConfig.id].eval.properties} />
|
|
47
|
+
<Block
|
|
48
|
+
block={context._internal.RootBlocks.map[pageConfig.id]}
|
|
49
|
+
Blocks={context._internal.RootBlocks}
|
|
50
|
+
context={context}
|
|
51
|
+
lowdefy={lowdefy}
|
|
52
|
+
/>
|
|
53
|
+
</>
|
|
54
|
+
);
|
|
55
|
+
}}
|
|
56
|
+
</Context>
|
|
57
|
+
);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export default Page;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2021 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import React, { Suspense, useState } from 'react';
|
|
18
|
+
|
|
19
|
+
import { ErrorBoundary } from '@lowdefy/block-utils';
|
|
20
|
+
|
|
21
|
+
import CategorySwitch from './CategorySwitch.js';
|
|
22
|
+
import LoadingBlock from './LoadingBlock.js';
|
|
23
|
+
import MountEvents from './MountEvents.js';
|
|
24
|
+
|
|
25
|
+
const Block = ({ block, Blocks, context, isRoot, lowdefy }) => {
|
|
26
|
+
const [updates, setUpdate] = useState(0);
|
|
27
|
+
lowdefy._internal.updaters[block.id] = () => setUpdate(updates + 1);
|
|
28
|
+
return (
|
|
29
|
+
<ErrorBoundary>
|
|
30
|
+
<Suspense fallback={<LoadingBlock block={block} lowdefy={lowdefy} />}>
|
|
31
|
+
<MountEvents
|
|
32
|
+
asyncEventName="onMountAsync"
|
|
33
|
+
context={context}
|
|
34
|
+
eventName="onMount"
|
|
35
|
+
triggerEvent={block.triggerEvent}
|
|
36
|
+
>
|
|
37
|
+
{(loading) =>
|
|
38
|
+
loading ? (
|
|
39
|
+
<LoadingBlock block={block} lowdefy={lowdefy} />
|
|
40
|
+
) : (
|
|
41
|
+
<CategorySwitch
|
|
42
|
+
block={block}
|
|
43
|
+
Blocks={Blocks}
|
|
44
|
+
context={context}
|
|
45
|
+
isRoot={isRoot}
|
|
46
|
+
lowdefy={lowdefy}
|
|
47
|
+
updates={updates}
|
|
48
|
+
/>
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
</MountEvents>
|
|
52
|
+
</Suspense>
|
|
53
|
+
</ErrorBoundary>
|
|
54
|
+
);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export default Block;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2021 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import React from 'react';
|
|
18
|
+
import { BlockLayout } from '@lowdefy/layout';
|
|
19
|
+
import { makeCssClass } from '@lowdefy/block-utils';
|
|
20
|
+
|
|
21
|
+
import Container from './Container.js';
|
|
22
|
+
import List from './List.js';
|
|
23
|
+
|
|
24
|
+
const CategorySwitch = ({ block, Blocks, context, lowdefy }) => {
|
|
25
|
+
if (!block.eval) return null; // Renderer updates before eval is executed for the first time on lists. See #520
|
|
26
|
+
if (block.eval.visible === false)
|
|
27
|
+
return <div id={`vs-${block.blockId}`} style={{ display: 'none' }} />;
|
|
28
|
+
const Component = lowdefy._internal.blockComponents[block.type];
|
|
29
|
+
switch (Component.meta.category) {
|
|
30
|
+
case 'list':
|
|
31
|
+
return (
|
|
32
|
+
<List
|
|
33
|
+
block={block}
|
|
34
|
+
Blocks={Blocks}
|
|
35
|
+
Component={Component}
|
|
36
|
+
context={context}
|
|
37
|
+
lowdefy={lowdefy}
|
|
38
|
+
/>
|
|
39
|
+
);
|
|
40
|
+
case 'container':
|
|
41
|
+
return (
|
|
42
|
+
<Container
|
|
43
|
+
block={block}
|
|
44
|
+
Blocks={Blocks}
|
|
45
|
+
Component={Component}
|
|
46
|
+
context={context}
|
|
47
|
+
lowdefy={lowdefy}
|
|
48
|
+
/>
|
|
49
|
+
);
|
|
50
|
+
case 'input':
|
|
51
|
+
return (
|
|
52
|
+
<BlockLayout
|
|
53
|
+
id={`bl-${block.blockId}`}
|
|
54
|
+
blockStyle={block.eval.style}
|
|
55
|
+
highlightBorders={lowdefy.lowdefyGlobal.highlightBorders}
|
|
56
|
+
layout={block.eval.layout || {}}
|
|
57
|
+
makeCssClass={makeCssClass}
|
|
58
|
+
>
|
|
59
|
+
<Component
|
|
60
|
+
methods={Object.assign(block.methods, {
|
|
61
|
+
makeCssClass,
|
|
62
|
+
registerEvent: block.registerEvent,
|
|
63
|
+
registerMethod: block.registerMethod,
|
|
64
|
+
setValue: block.setValue,
|
|
65
|
+
triggerEvent: block.triggerEvent,
|
|
66
|
+
})}
|
|
67
|
+
// TODO: React throws a basePath warning
|
|
68
|
+
basePath={lowdefy._internal.basePath}
|
|
69
|
+
blockId={block.blockId}
|
|
70
|
+
components={lowdefy._internal.components}
|
|
71
|
+
events={block.eval.events}
|
|
72
|
+
homePageId={lowdefy.homePageId}
|
|
73
|
+
key={block.blockId}
|
|
74
|
+
loading={block.loading}
|
|
75
|
+
menus={lowdefy.menus}
|
|
76
|
+
pageId={lowdefy.pageId}
|
|
77
|
+
properties={block.eval.properties}
|
|
78
|
+
required={block.eval.required}
|
|
79
|
+
user={lowdefy.user}
|
|
80
|
+
validation={block.eval.validation}
|
|
81
|
+
value={block.value}
|
|
82
|
+
/>
|
|
83
|
+
</BlockLayout>
|
|
84
|
+
);
|
|
85
|
+
default:
|
|
86
|
+
return (
|
|
87
|
+
<BlockLayout
|
|
88
|
+
id={`bl-${block.blockId}`}
|
|
89
|
+
blockStyle={block.eval.style}
|
|
90
|
+
highlightBorders={lowdefy.lowdefyGlobal.highlightBorders}
|
|
91
|
+
layout={block.eval.layout || {}}
|
|
92
|
+
makeCssClass={makeCssClass}
|
|
93
|
+
>
|
|
94
|
+
<Component
|
|
95
|
+
methods={Object.assign(block.methods, {
|
|
96
|
+
makeCssClass,
|
|
97
|
+
registerEvent: block.registerEvent,
|
|
98
|
+
registerMethod: block.registerMethod,
|
|
99
|
+
triggerEvent: block.triggerEvent,
|
|
100
|
+
})}
|
|
101
|
+
basePath={lowdefy._internal.basePath}
|
|
102
|
+
blockId={block.blockId}
|
|
103
|
+
components={lowdefy._internal.components}
|
|
104
|
+
events={block.eval.events}
|
|
105
|
+
homePageId={lowdefy.homePageId}
|
|
106
|
+
key={block.blockId}
|
|
107
|
+
loading={block.loading}
|
|
108
|
+
menus={lowdefy.menus}
|
|
109
|
+
pageId={lowdefy.pageId}
|
|
110
|
+
properties={block.eval.properties}
|
|
111
|
+
required={block.eval.required}
|
|
112
|
+
user={lowdefy.user}
|
|
113
|
+
validation={block.eval.validation}
|
|
114
|
+
/>
|
|
115
|
+
</BlockLayout>
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
export default CategorySwitch;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2021 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import React from 'react';
|
|
18
|
+
import { Area, BlockLayout, layoutParamsToArea } from '@lowdefy/layout';
|
|
19
|
+
import { makeCssClass } from '@lowdefy/block-utils';
|
|
20
|
+
|
|
21
|
+
import Block from './Block.js';
|
|
22
|
+
|
|
23
|
+
const Container = ({ block, Blocks, Component, context, lowdefy }) => {
|
|
24
|
+
const content = {};
|
|
25
|
+
// eslint-disable-next-line prefer-destructuring
|
|
26
|
+
const areas = Blocks.subBlocks[block.id][0].areas;
|
|
27
|
+
Object.keys(areas).forEach((areaKey) => {
|
|
28
|
+
content[areaKey] = (areaStyle) => (
|
|
29
|
+
<Area
|
|
30
|
+
id={`ar-${block.blockId}-${areaKey}`}
|
|
31
|
+
key={`ar-${block.blockId}-${areaKey}`}
|
|
32
|
+
area={layoutParamsToArea({
|
|
33
|
+
area: block.eval.areas[areaKey] || {},
|
|
34
|
+
areaKey,
|
|
35
|
+
layout: block.eval.layout || {},
|
|
36
|
+
})}
|
|
37
|
+
areaStyle={[areaStyle, block.eval.areas[areaKey] && block.eval.areas[areaKey].style]}
|
|
38
|
+
highlightBorders={lowdefy.lowdefyGlobal.highlightBorders}
|
|
39
|
+
makeCssClass={makeCssClass}
|
|
40
|
+
>
|
|
41
|
+
{areas[areaKey].blocks.map((bl) => (
|
|
42
|
+
<Block
|
|
43
|
+
key={`co-${bl.blockId}`}
|
|
44
|
+
Blocks={Blocks.subBlocks[block.id][0]}
|
|
45
|
+
block={bl}
|
|
46
|
+
context={context}
|
|
47
|
+
lowdefy={lowdefy}
|
|
48
|
+
/>
|
|
49
|
+
))}
|
|
50
|
+
</Area>
|
|
51
|
+
);
|
|
52
|
+
});
|
|
53
|
+
return (
|
|
54
|
+
<BlockLayout
|
|
55
|
+
id={`bl-${block.blockId}`}
|
|
56
|
+
blockStyle={block.eval.style}
|
|
57
|
+
highlightBorders={lowdefy.lowdefyGlobal.highlightBorders}
|
|
58
|
+
layout={block.eval.layout || {}}
|
|
59
|
+
makeCssClass={makeCssClass}
|
|
60
|
+
>
|
|
61
|
+
<Component
|
|
62
|
+
methods={Object.assign(block.methods, {
|
|
63
|
+
makeCssClass,
|
|
64
|
+
registerEvent: block.registerEvent,
|
|
65
|
+
registerMethod: block.registerMethod,
|
|
66
|
+
triggerEvent: block.triggerEvent,
|
|
67
|
+
})}
|
|
68
|
+
basePath={lowdefy._internal.basePath}
|
|
69
|
+
blockId={block.blockId}
|
|
70
|
+
components={lowdefy._internal.components}
|
|
71
|
+
content={content}
|
|
72
|
+
events={block.eval.events}
|
|
73
|
+
homePageId={lowdefy.homePageId}
|
|
74
|
+
key={block.blockId}
|
|
75
|
+
loading={block.loading}
|
|
76
|
+
menus={lowdefy.menus}
|
|
77
|
+
pageId={lowdefy.pageId}
|
|
78
|
+
properties={block.eval.properties}
|
|
79
|
+
required={block.eval.required}
|
|
80
|
+
user={lowdefy.user}
|
|
81
|
+
validation={block.eval.validation}
|
|
82
|
+
/>
|
|
83
|
+
</BlockLayout>
|
|
84
|
+
);
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export default Container;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2021 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import React from 'react';
|
|
18
|
+
import { Area, BlockLayout, layoutParamsToArea } from '@lowdefy/layout';
|
|
19
|
+
import { makeCssClass } from '@lowdefy/block-utils';
|
|
20
|
+
|
|
21
|
+
import Block from './Block.js';
|
|
22
|
+
|
|
23
|
+
const List = ({ block, Blocks, Component, context, lowdefy }) => {
|
|
24
|
+
const content = {};
|
|
25
|
+
const contentList = [];
|
|
26
|
+
Blocks.subBlocks[block.id].forEach((SBlock) => {
|
|
27
|
+
Object.keys(SBlock.areas).forEach((areaKey) => {
|
|
28
|
+
content[areaKey] = (areaStyle) => (
|
|
29
|
+
<Area
|
|
30
|
+
id={`ar-${block.blockId}-${SBlock.id}-${areaKey}`}
|
|
31
|
+
key={`ar-${block.blockId}-${SBlock.id}-${areaKey}`}
|
|
32
|
+
area={layoutParamsToArea({
|
|
33
|
+
area: block.eval.areas[areaKey] || {},
|
|
34
|
+
areaKey,
|
|
35
|
+
layout: block.eval.layout || {},
|
|
36
|
+
})}
|
|
37
|
+
areaStyle={[areaStyle, block.eval.areas[areaKey] && block.eval.areas[areaKey].style]}
|
|
38
|
+
highlightBorders={lowdefy.lowdefyGlobal.highlightBorders}
|
|
39
|
+
makeCssClass={makeCssClass}
|
|
40
|
+
>
|
|
41
|
+
{SBlock.areas[areaKey].blocks.map((bl) => (
|
|
42
|
+
<Block
|
|
43
|
+
key={`ls-${bl.blockId}`}
|
|
44
|
+
Blocks={SBlock}
|
|
45
|
+
block={bl}
|
|
46
|
+
context={context}
|
|
47
|
+
lowdefy={lowdefy}
|
|
48
|
+
/>
|
|
49
|
+
))}
|
|
50
|
+
</Area>
|
|
51
|
+
);
|
|
52
|
+
});
|
|
53
|
+
contentList.push({ ...content });
|
|
54
|
+
});
|
|
55
|
+
return (
|
|
56
|
+
<BlockLayout
|
|
57
|
+
id={`bl-${block.blockId}`}
|
|
58
|
+
blockStyle={block.eval.style}
|
|
59
|
+
highlightBorders={lowdefy.lowdefyGlobal.highlightBorders}
|
|
60
|
+
layout={block.eval.layout || {}}
|
|
61
|
+
makeCssClass={makeCssClass}
|
|
62
|
+
>
|
|
63
|
+
<Component
|
|
64
|
+
methods={Object.assign(block.methods, {
|
|
65
|
+
makeCssClass,
|
|
66
|
+
moveItemDown: block.moveItemDown,
|
|
67
|
+
moveItemUp: block.moveItemUp,
|
|
68
|
+
pushItem: block.pushItem,
|
|
69
|
+
registerEvent: block.registerEvent,
|
|
70
|
+
registerMethod: block.registerMethod,
|
|
71
|
+
removeItem: block.removeItem,
|
|
72
|
+
triggerEvent: block.triggerEvent,
|
|
73
|
+
unshiftItem: block.unshiftItem,
|
|
74
|
+
})}
|
|
75
|
+
basePath={lowdefy._internal.basePath}
|
|
76
|
+
blockId={block.blockId}
|
|
77
|
+
components={lowdefy._internal.components}
|
|
78
|
+
events={block.eval.events}
|
|
79
|
+
homePageId={lowdefy.homePageId}
|
|
80
|
+
key={block.blockId}
|
|
81
|
+
list={contentList}
|
|
82
|
+
loading={block.loading}
|
|
83
|
+
menus={lowdefy.menus}
|
|
84
|
+
pageId={lowdefy.pageId}
|
|
85
|
+
properties={block.eval.properties}
|
|
86
|
+
required={block.eval.required}
|
|
87
|
+
user={lowdefy.user}
|
|
88
|
+
validation={block.eval.validation}
|
|
89
|
+
/>
|
|
90
|
+
</BlockLayout>
|
|
91
|
+
);
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export default List;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
// import { Loading, makeCssClass } from '@lowdefy/block-utils';
|
|
3
|
+
// import { get } from '@lowdefy/helpers';
|
|
4
|
+
// import { BlockLayout } from '@lowdefy/layout';
|
|
5
|
+
|
|
6
|
+
const LoadingBlock = ({ block, lowdefy }) => (
|
|
7
|
+
<div>LoadingBlock</div>
|
|
8
|
+
// <BlockLayout
|
|
9
|
+
// id={`bl-loading-${block.blockId}`}
|
|
10
|
+
// blockStyle={get(block, 'eval.style') || get(block, 'meta.loading.style', { default: {} })}
|
|
11
|
+
// highlightBorders={lowdefy.lowdefyGlobal.highlightBorders}
|
|
12
|
+
// layout={get(block, 'eval.layout') || get(block, 'meta.loading.layout', { default: {} })}
|
|
13
|
+
// makeCssClass={makeCssClass}
|
|
14
|
+
// >
|
|
15
|
+
// <Loading
|
|
16
|
+
// properties={get(block, 'meta.loading.properties')}
|
|
17
|
+
// type={get(block, 'meta.loading.type')}
|
|
18
|
+
// />
|
|
19
|
+
// </BlockLayout>
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
export default LoadingBlock;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2021 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import React, { useEffect, useState } from 'react';
|
|
18
|
+
|
|
19
|
+
const MountEvents = ({ asyncEventName, context, eventName, triggerEvent, children }) => {
|
|
20
|
+
const [loading, setLoading] = useState(true);
|
|
21
|
+
const [error, setError] = useState(null);
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
let mounted = true;
|
|
24
|
+
const mount = async () => {
|
|
25
|
+
try {
|
|
26
|
+
await triggerEvent({ name: eventName, context });
|
|
27
|
+
if (mounted) {
|
|
28
|
+
triggerEvent({ name: asyncEventName, context });
|
|
29
|
+
setLoading(false);
|
|
30
|
+
}
|
|
31
|
+
} catch (err) {
|
|
32
|
+
setError(err);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
mount();
|
|
36
|
+
return () => {
|
|
37
|
+
mounted = false;
|
|
38
|
+
};
|
|
39
|
+
}, [context]);
|
|
40
|
+
|
|
41
|
+
if (error) throw error;
|
|
42
|
+
|
|
43
|
+
return <>{children(loading)}</>;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export default MountEvents;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2021 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import Link from 'next/link';
|
|
18
|
+
import { createIcon } from '@lowdefy/block-utils';
|
|
19
|
+
|
|
20
|
+
import icons from '../../build/plugins/icons.js';
|
|
21
|
+
|
|
22
|
+
export default {
|
|
23
|
+
Link,
|
|
24
|
+
Icon: createIcon(icons),
|
|
25
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2021 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { createApiContext, getPageConfig, getRootConfig } from '@lowdefy/api';
|
|
18
|
+
|
|
19
|
+
import Page from '../components/Page.js';
|
|
20
|
+
|
|
21
|
+
export async function getServerSideProps(context) {
|
|
22
|
+
const { pageId } = context.params;
|
|
23
|
+
const apiContext = await createApiContext({ buildDirectory: './.lowdefy/build' });
|
|
24
|
+
|
|
25
|
+
// TODO: Maybe we can only get rootConfig once?
|
|
26
|
+
// We can't do getServerSideProps on _app :(
|
|
27
|
+
const [rootConfig, pageConfig] = await Promise.all([
|
|
28
|
+
getRootConfig(apiContext),
|
|
29
|
+
getPageConfig(apiContext, { pageId }),
|
|
30
|
+
]);
|
|
31
|
+
|
|
32
|
+
if (!pageConfig) {
|
|
33
|
+
return {
|
|
34
|
+
redirect: {
|
|
35
|
+
destination: '/404',
|
|
36
|
+
permanent: false,
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
props: {
|
|
43
|
+
pageConfig,
|
|
44
|
+
rootConfig,
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export default Page;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2021 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import React, { Suspense } from 'react';
|
|
18
|
+
|
|
19
|
+
import { ErrorBoundary } from '@lowdefy/block-utils';
|
|
20
|
+
|
|
21
|
+
import LowdefyContext from '../components/LowdefyContext.js';
|
|
22
|
+
|
|
23
|
+
import '../../build/plugins/styles.less';
|
|
24
|
+
|
|
25
|
+
function App({ Component, pageProps }) {
|
|
26
|
+
return (
|
|
27
|
+
<ErrorBoundary>
|
|
28
|
+
<Suspense>
|
|
29
|
+
<LowdefyContext>
|
|
30
|
+
{(lowdefy) => <Component lowdefy={lowdefy} {...pageProps} />}
|
|
31
|
+
</LowdefyContext>
|
|
32
|
+
</Suspense>
|
|
33
|
+
</ErrorBoundary>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export default App;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2021 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import NextAuth from 'next-auth';
|
|
18
|
+
import Auth0Provider from 'next-auth/providers/auth0';
|
|
19
|
+
|
|
20
|
+
export default NextAuth({
|
|
21
|
+
providers: [
|
|
22
|
+
Auth0Provider({
|
|
23
|
+
clientId: process.env.AUTH0_CLIENT_ID,
|
|
24
|
+
clientSecret: process.env.AUTH0_CLIENT_SECRET,
|
|
25
|
+
issuer: process.env.AUTH0_ISSUER,
|
|
26
|
+
}),
|
|
27
|
+
],
|
|
28
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2021 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { callRequest, createApiContext } from '@lowdefy/api';
|
|
18
|
+
import connections from '../../../../../build/plugins/connections.js';
|
|
19
|
+
|
|
20
|
+
export default async function handler(req, res) {
|
|
21
|
+
try {
|
|
22
|
+
if (req.method !== 'POST') {
|
|
23
|
+
throw new Error('Only POST requests are supported.');
|
|
24
|
+
}
|
|
25
|
+
const apiContext = await createApiContext({
|
|
26
|
+
buildDirectory: './.lowdefy/build',
|
|
27
|
+
connections,
|
|
28
|
+
// TODO
|
|
29
|
+
logger: console,
|
|
30
|
+
// TODO
|
|
31
|
+
secrets: {},
|
|
32
|
+
});
|
|
33
|
+
const { pageId, requestId } = req.query;
|
|
34
|
+
const { payload } = req.body;
|
|
35
|
+
|
|
36
|
+
const response = await callRequest(apiContext, { pageId, payload, requestId });
|
|
37
|
+
res.status(200).json(response);
|
|
38
|
+
} catch (error) {
|
|
39
|
+
res.status(500).json({ name: error.name, message: error.message });
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2021 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { createApiContext, getHome, getPageConfig, getRootConfig } from '@lowdefy/api';
|
|
18
|
+
|
|
19
|
+
import Page from '../components/Page.js';
|
|
20
|
+
|
|
21
|
+
export async function getServerSideProps() {
|
|
22
|
+
const apiContext = await createApiContext({ buildDirectory: './.lowdefy/build' });
|
|
23
|
+
const home = await getHome(apiContext);
|
|
24
|
+
if (home.configured === false) {
|
|
25
|
+
return {
|
|
26
|
+
redirect: {
|
|
27
|
+
destination: `/${home.pageId}`,
|
|
28
|
+
permanent: false,
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const [rootConfig, pageConfig] = await Promise.all([
|
|
34
|
+
getRootConfig(apiContext),
|
|
35
|
+
getPageConfig(apiContext, { pageId: home.pageId }),
|
|
36
|
+
]);
|
|
37
|
+
|
|
38
|
+
if (!pageConfig) {
|
|
39
|
+
return {
|
|
40
|
+
redirect: {
|
|
41
|
+
destination: '/404',
|
|
42
|
+
permanent: false,
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
props: {
|
|
49
|
+
pageConfig,
|
|
50
|
+
rootConfig,
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export default Page;
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
2
|
+
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
|
3
|
+
<svg width="100%" height="100%" viewBox="0 0 94 94" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
|
|
4
|
+
<g transform="matrix(1,0,0,1,-979.672,-59.6924)">
|
|
5
|
+
<g transform="matrix(1,0,0,1.03297,-38.3284,-294.615)">
|
|
6
|
+
<g transform="matrix(1,0,0,1,952,232)">
|
|
7
|
+
<path d="M160,129.634C160,119.35 151.375,111 140.751,111L85.249,111C74.625,111 66,119.35 66,129.634L66,183.366C66,193.65 74.625,202 85.249,202L140.751,202C151.375,202 160,193.65 160,183.366L160,129.634Z"/>
|
|
8
|
+
</g>
|
|
9
|
+
<g transform="matrix(0.872141,0,0,1,1002.6,346)">
|
|
10
|
+
<rect x="36" y="12" width="36" height="59" style="fill:white;"/>
|
|
11
|
+
</g>
|
|
12
|
+
<g transform="matrix(0.78125,0,0,0.862069,1010.84,356.663)">
|
|
13
|
+
<rect x="77" y="41" width="32" height="29" style="fill:rgb(24,144,255);"/>
|
|
14
|
+
</g>
|
|
15
|
+
</g>
|
|
16
|
+
</g>
|
|
17
|
+
</svg>
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"short_name": "Lowdefy App",
|
|
3
|
+
"name": "Lowdefy App",
|
|
4
|
+
"description": "Lowdefy App",
|
|
5
|
+
"icons": [
|
|
6
|
+
{
|
|
7
|
+
"src": "/public/icon-512.png",
|
|
8
|
+
"type": "image/png",
|
|
9
|
+
"sizes": "512x512"
|
|
10
|
+
}
|
|
11
|
+
],
|
|
12
|
+
"start_url": "/",
|
|
13
|
+
"background_color": "#FFFFFF",
|
|
14
|
+
"display": "browser",
|
|
15
|
+
"scope": "/"
|
|
16
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2021 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import request from './request.js';
|
|
18
|
+
|
|
19
|
+
function callRequest({ pageId, payload, requestId }) {
|
|
20
|
+
return request({
|
|
21
|
+
url: `/api/request/${pageId}/${requestId}`,
|
|
22
|
+
method: 'POST',
|
|
23
|
+
body: { payload },
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export default callRequest;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2021 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
async function request({ url, method = 'GET', body }) {
|
|
18
|
+
const res = await fetch(url, {
|
|
19
|
+
method,
|
|
20
|
+
headers: {
|
|
21
|
+
'Content-Type': 'application/json',
|
|
22
|
+
},
|
|
23
|
+
body: JSON.stringify(body),
|
|
24
|
+
});
|
|
25
|
+
if (!res.ok) {
|
|
26
|
+
// TODO: check
|
|
27
|
+
const body = await res.json();
|
|
28
|
+
console.log(res);
|
|
29
|
+
console.log(body);
|
|
30
|
+
throw new Error(body.message || 'Request error');
|
|
31
|
+
}
|
|
32
|
+
return res.json();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export default request;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2021 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { createLink } from '@lowdefy/engine';
|
|
18
|
+
|
|
19
|
+
function setupLink({ lowdefy }) {
|
|
20
|
+
const { router, window } = lowdefy._internal;
|
|
21
|
+
const sameOriginLink = (path, newTab) => {
|
|
22
|
+
if (newTab) {
|
|
23
|
+
return window.open(`${window.location.origin}${lowdefy.basePath}${path}`, '_blank').focus();
|
|
24
|
+
} else {
|
|
25
|
+
// Next handles the basePath here.
|
|
26
|
+
return router.push({
|
|
27
|
+
pathname: path,
|
|
28
|
+
// TODO: Do we handle urlQuery as a param here?
|
|
29
|
+
// query: {},
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
const newOriginLink = (path, newTab) => {
|
|
34
|
+
if (newTab) {
|
|
35
|
+
return window.open(path, '_blank').focus();
|
|
36
|
+
} else {
|
|
37
|
+
return (window.location.href = path);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
const backLink = () => window.history.back();
|
|
41
|
+
return createLink({ backLink, lowdefy, newOriginLink, sameOriginLink });
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export default setupLink;
|
package/dist/index.js
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _path = _interopRequireDefault(require("path"));
|
|
9
|
-
|
|
10
|
-
var _express = _interopRequireDefault(require("express"));
|
|
11
|
-
|
|
12
|
-
var _apolloServerExpress = require("apollo-server-express");
|
|
13
|
-
|
|
14
|
-
var _graphql = require("@lowdefy/graphql");
|
|
15
|
-
|
|
16
|
-
var _helpers = require("@lowdefy/helpers");
|
|
17
|
-
|
|
18
|
-
var _nodeUtils = require("@lowdefy/node-utils");
|
|
19
|
-
|
|
20
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
-
|
|
22
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
23
|
-
|
|
24
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
25
|
-
|
|
26
|
-
function getServer(_ref) {
|
|
27
|
-
var {
|
|
28
|
-
buildDirectory,
|
|
29
|
-
development = false,
|
|
30
|
-
getSecrets,
|
|
31
|
-
gqlExpressPath,
|
|
32
|
-
gqlUri,
|
|
33
|
-
logger,
|
|
34
|
-
publicDirectory,
|
|
35
|
-
serverBasePath = '',
|
|
36
|
-
serveStaticFiles = true,
|
|
37
|
-
shellDirectory
|
|
38
|
-
} = _ref;
|
|
39
|
-
var context = (0, _graphql.createContext)({
|
|
40
|
-
CONFIGURATION_BASE_PATH: buildDirectory,
|
|
41
|
-
development,
|
|
42
|
-
getSecrets,
|
|
43
|
-
gqlUri,
|
|
44
|
-
logger
|
|
45
|
-
});
|
|
46
|
-
var gqlServer = new _apolloServerExpress.ApolloServer({
|
|
47
|
-
typeDefs: _graphql.typeDefs,
|
|
48
|
-
resolvers: _graphql.resolvers,
|
|
49
|
-
context
|
|
50
|
-
});
|
|
51
|
-
var indexHtml = null;
|
|
52
|
-
|
|
53
|
-
if (serverBasePath !== '') {
|
|
54
|
-
serverBasePath = "/".concat(serverBasePath);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
var serveIndex = /*#__PURE__*/function () {
|
|
58
|
-
var _ref2 = _asyncToGenerator(function* (req, res) {
|
|
59
|
-
// TODO: can do better here?
|
|
60
|
-
if (!indexHtml || development) {
|
|
61
|
-
indexHtml = yield (0, _nodeUtils.readFile)(_path.default.resolve(shellDirectory, 'index.html'));
|
|
62
|
-
var appConfig = yield (0, _nodeUtils.readFile)(_path.default.resolve(buildDirectory, 'app.json'));
|
|
63
|
-
appConfig = JSON.parse(appConfig);
|
|
64
|
-
indexHtml = indexHtml.replace('<!-- __LOWDEFY_APP_HEAD_HTML__ -->', (0, _helpers.get)(appConfig, 'html.appendHead', {
|
|
65
|
-
default: ''
|
|
66
|
-
}));
|
|
67
|
-
indexHtml = indexHtml.replace('<!-- __LOWDEFY_APP_BODY_HTML__ -->', (0, _helpers.get)(appConfig, 'html.appendBody', {
|
|
68
|
-
default: ''
|
|
69
|
-
}));
|
|
70
|
-
indexHtml = indexHtml.replace(/__LOWDEFY_SERVER_BASE_PATH__/g, serverBasePath);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
res.send(indexHtml);
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
return function serveIndex(_x, _x2) {
|
|
77
|
-
return _ref2.apply(this, arguments);
|
|
78
|
-
};
|
|
79
|
-
}();
|
|
80
|
-
|
|
81
|
-
var server = (0, _express.default)();
|
|
82
|
-
gqlServer.applyMiddleware({
|
|
83
|
-
app: server,
|
|
84
|
-
path: gqlExpressPath || "".concat(serverBasePath, "/api/graphql"),
|
|
85
|
-
bodyParserConfig: {
|
|
86
|
-
limit: '5mb'
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
if (serveStaticFiles) {
|
|
91
|
-
// serve index.html with appended html
|
|
92
|
-
// else static server serves without appended html
|
|
93
|
-
server.get("".concat(serverBasePath, "/"), serveIndex);
|
|
94
|
-
server.use("".concat(serverBasePath, "/shell"), _express.default.static(_path.default.resolve(shellDirectory))); // serve public files
|
|
95
|
-
|
|
96
|
-
server.use("".concat(serverBasePath, "/public"), _express.default.static(_path.default.resolve(publicDirectory))); // Redirect all 404 to index.html with status 200
|
|
97
|
-
// This should always be the last route
|
|
98
|
-
|
|
99
|
-
server.use("".concat(serverBasePath, "/*"), serveIndex);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
return server;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
var _default = getServer;
|
|
106
|
-
exports.default = _default;
|