@lowdefy/server 4.0.0-alpha.7 → 4.0.0-alpha.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/next.config.js +1 -1
- package/package.json +16 -14
- package/src/components/Context.js +0 -61
- package/src/components/Head.js +0 -28
- package/src/components/LowdefyContext.js +0 -50
- package/src/components/Page.js +0 -64
- package/src/components/block/Block.js +0 -57
- package/src/components/block/CategorySwitch.js +0 -117
- package/src/components/block/Container.js +0 -86
- package/src/components/block/List.js +0 -93
- package/src/components/block/LoadingBlock.js +0 -22
- package/src/components/block/MountEvents.js +0 -46
- package/src/components/createComponents.js +0 -29
- package/src/components/createLinkComponent.js +0 -97
- package/src/pages/404.js +0 -38
- package/src/pages/[pageId].js +0 -48
- package/src/pages/_app.js +0 -39
- package/src/pages/_document.js +0 -38
- package/src/pages/api/auth/[...nextauth].js +0 -28
- package/src/pages/api/request/[pageId]/[requestId].js +0 -44
- package/src/pages/index.js +0 -51
- package/src/utils/callRequest.js +0 -27
- package/src/utils/request.js +0 -35
- package/src/utils/setupLink.js +0 -52
package/next.config.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const withLess = require('next-with-less');
|
|
2
2
|
const lowdefyConfig = require('./build/config.json');
|
|
3
3
|
|
|
4
|
-
// TODO:
|
|
4
|
+
// TODO: Trace env and args from cli that is required on the server.
|
|
5
5
|
module.exports = withLess({
|
|
6
6
|
basePath: process.env.LOWDEFY_BASE_PATH || lowdefyConfig.basePath,
|
|
7
7
|
lessLoaderOptions: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lowdefy/server",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.8",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
".eslintrc.yaml"
|
|
33
33
|
],
|
|
34
34
|
"scripts": {
|
|
35
|
-
"build:lowdefy": "lowdefy
|
|
35
|
+
"build:lowdefy": "node lowdefy/build.mjs",
|
|
36
36
|
"build:next": "next build",
|
|
37
37
|
"dev": "next dev",
|
|
38
38
|
"start": "next start",
|
|
@@ -40,29 +40,31 @@
|
|
|
40
40
|
"next": "next"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@lowdefy/api": "4.0.0-alpha.
|
|
44
|
-
"@lowdefy/block-utils": "4.0.0-alpha.
|
|
45
|
-
"@lowdefy/engine": "4.0.0-alpha.
|
|
46
|
-
"@lowdefy/helpers": "4.0.0-alpha.
|
|
47
|
-
"@lowdefy/layout": "4.0.0-alpha.
|
|
48
|
-
"@lowdefy/node-utils": "4.0.0-alpha.
|
|
49
|
-
"@lowdefy/operators-js": "4.0.0-alpha.
|
|
43
|
+
"@lowdefy/api": "4.0.0-alpha.8",
|
|
44
|
+
"@lowdefy/block-utils": "4.0.0-alpha.8",
|
|
45
|
+
"@lowdefy/engine": "4.0.0-alpha.8",
|
|
46
|
+
"@lowdefy/helpers": "4.0.0-alpha.8",
|
|
47
|
+
"@lowdefy/layout": "4.0.0-alpha.8",
|
|
48
|
+
"@lowdefy/node-utils": "4.0.0-alpha.8",
|
|
49
|
+
"@lowdefy/operators-js": "4.0.0-alpha.8",
|
|
50
50
|
"next": "12.0.10",
|
|
51
51
|
"next-auth": "4.1.2",
|
|
52
52
|
"process": "0.11.10",
|
|
53
|
-
"react": "
|
|
54
|
-
"react-dom": "
|
|
53
|
+
"react": "17.0.2",
|
|
54
|
+
"react-dom": "17.0.2",
|
|
55
55
|
"react-icons": "4.3.1"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@lowdefy/build": "4.0.0-alpha.
|
|
58
|
+
"@lowdefy/build": "4.0.0-alpha.8",
|
|
59
59
|
"@next/eslint-plugin-next": "12.0.10",
|
|
60
60
|
"less": "4.1.2",
|
|
61
61
|
"less-loader": "10.2.0",
|
|
62
|
-
"next-with-less": "2.0.4"
|
|
62
|
+
"next-with-less": "2.0.4",
|
|
63
|
+
"yaml": "1.10.2",
|
|
64
|
+
"yargs": "17.3.1"
|
|
63
65
|
},
|
|
64
66
|
"publishConfig": {
|
|
65
67
|
"access": "public"
|
|
66
68
|
},
|
|
67
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "9d56b83cf45e868afe3a1eeba750fe826eb74c8c"
|
|
68
70
|
}
|
|
@@ -1,61 +0,0 @@
|
|
|
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;
|
package/src/components/Head.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
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;
|
|
@@ -1,50 +0,0 @@
|
|
|
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 actions from '../../build/plugins/actions.js';
|
|
20
|
-
import callRequest from '../utils/callRequest.js';
|
|
21
|
-
import blockComponents from '../../build/plugins/blocks.js';
|
|
22
|
-
import operators from '../../build/plugins/operatorsClient.js';
|
|
23
|
-
|
|
24
|
-
const LowdefyContext = ({ children, lowdefy }) => {
|
|
25
|
-
if (!lowdefy._internal) {
|
|
26
|
-
lowdefy._internal = {
|
|
27
|
-
actions,
|
|
28
|
-
blockComponents,
|
|
29
|
-
callRequest,
|
|
30
|
-
components: {},
|
|
31
|
-
document,
|
|
32
|
-
operators,
|
|
33
|
-
updaters: {},
|
|
34
|
-
window,
|
|
35
|
-
displayMessage: ({ content }) => {
|
|
36
|
-
console.log(content);
|
|
37
|
-
return () => undefined;
|
|
38
|
-
},
|
|
39
|
-
link: () => undefined,
|
|
40
|
-
};
|
|
41
|
-
lowdefy.contexts = {};
|
|
42
|
-
lowdefy.inputs = {};
|
|
43
|
-
lowdefy.lowdefyGlobal = {};
|
|
44
|
-
}
|
|
45
|
-
lowdefy._internal.updateBlock = (blockId) =>
|
|
46
|
-
lowdefy._internal.updaters[blockId] && lowdefy._internal.updaters[blockId]();
|
|
47
|
-
return <>{children}</>;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
export default LowdefyContext;
|
package/src/components/Page.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
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 { urlQuery } from '@lowdefy/helpers';
|
|
20
|
-
import { useRouter } from 'next/router';
|
|
21
|
-
|
|
22
|
-
import Context from './Context.js';
|
|
23
|
-
import Head from './Head.js';
|
|
24
|
-
import Block from './block/Block.js';
|
|
25
|
-
import setupLink from '../utils/setupLink.js';
|
|
26
|
-
import createComponents from './createComponents.js';
|
|
27
|
-
|
|
28
|
-
const LoadingBlock = () => <div>Loading...</div>;
|
|
29
|
-
|
|
30
|
-
const Page = ({ lowdefy, pageConfig, rootConfig }) => {
|
|
31
|
-
const router = useRouter();
|
|
32
|
-
lowdefy._internal.router = router;
|
|
33
|
-
lowdefy._internal.link = setupLink(lowdefy);
|
|
34
|
-
lowdefy._internal.components = createComponents(lowdefy);
|
|
35
|
-
|
|
36
|
-
lowdefy.basePath = lowdefy._internal.router.basePath;
|
|
37
|
-
lowdefy.home = rootConfig.home;
|
|
38
|
-
lowdefy.lowdefyGlobal = rootConfig.lowdefyGlobal;
|
|
39
|
-
lowdefy.menus = rootConfig.menus;
|
|
40
|
-
lowdefy.urlQuery = urlQuery.parse(window.location.search.slice(1));
|
|
41
|
-
|
|
42
|
-
return (
|
|
43
|
-
<Context config={pageConfig} lowdefy={lowdefy}>
|
|
44
|
-
{(context, loading) => {
|
|
45
|
-
if (loading) {
|
|
46
|
-
return <LoadingBlock />;
|
|
47
|
-
}
|
|
48
|
-
return (
|
|
49
|
-
<>
|
|
50
|
-
<Head properties={context._internal.RootBlocks.map[pageConfig.id].eval.properties} />
|
|
51
|
-
<Block
|
|
52
|
-
block={context._internal.RootBlocks.map[pageConfig.id]}
|
|
53
|
-
Blocks={context._internal.RootBlocks}
|
|
54
|
-
context={context}
|
|
55
|
-
lowdefy={lowdefy}
|
|
56
|
-
/>
|
|
57
|
-
</>
|
|
58
|
-
);
|
|
59
|
-
}}
|
|
60
|
-
</Context>
|
|
61
|
-
);
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
export default Page;
|
|
@@ -1,57 +0,0 @@
|
|
|
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;
|
|
@@ -1,117 +0,0 @@
|
|
|
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
|
-
basePath={lowdefy.basePath}
|
|
68
|
-
blockId={block.blockId}
|
|
69
|
-
components={lowdefy._internal.components}
|
|
70
|
-
events={block.eval.events}
|
|
71
|
-
key={block.blockId}
|
|
72
|
-
loading={block.loading}
|
|
73
|
-
menus={lowdefy.menus}
|
|
74
|
-
pageId={lowdefy.pageId}
|
|
75
|
-
properties={block.eval.properties}
|
|
76
|
-
required={block.eval.required}
|
|
77
|
-
user={lowdefy.user}
|
|
78
|
-
validation={block.eval.validation}
|
|
79
|
-
value={block.value}
|
|
80
|
-
/>
|
|
81
|
-
</BlockLayout>
|
|
82
|
-
);
|
|
83
|
-
default:
|
|
84
|
-
return (
|
|
85
|
-
<BlockLayout
|
|
86
|
-
id={`bl-${block.blockId}`}
|
|
87
|
-
blockStyle={block.eval.style}
|
|
88
|
-
highlightBorders={lowdefy.lowdefyGlobal.highlightBorders}
|
|
89
|
-
layout={block.eval.layout || {}}
|
|
90
|
-
makeCssClass={makeCssClass}
|
|
91
|
-
>
|
|
92
|
-
<Component
|
|
93
|
-
methods={Object.assign(block.methods, {
|
|
94
|
-
makeCssClass,
|
|
95
|
-
registerEvent: block.registerEvent,
|
|
96
|
-
registerMethod: block.registerMethod,
|
|
97
|
-
triggerEvent: block.triggerEvent,
|
|
98
|
-
})}
|
|
99
|
-
basePath={lowdefy.basePath}
|
|
100
|
-
blockId={block.blockId}
|
|
101
|
-
components={lowdefy._internal.components}
|
|
102
|
-
events={block.eval.events}
|
|
103
|
-
key={block.blockId}
|
|
104
|
-
loading={block.loading}
|
|
105
|
-
menus={lowdefy.menus}
|
|
106
|
-
pageId={lowdefy.pageId}
|
|
107
|
-
properties={block.eval.properties}
|
|
108
|
-
required={block.eval.required}
|
|
109
|
-
user={lowdefy.user}
|
|
110
|
-
validation={block.eval.validation}
|
|
111
|
-
/>
|
|
112
|
-
</BlockLayout>
|
|
113
|
-
);
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
export default CategorySwitch;
|
|
@@ -1,86 +0,0 @@
|
|
|
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.basePath}
|
|
69
|
-
blockId={block.blockId}
|
|
70
|
-
components={lowdefy._internal.components}
|
|
71
|
-
content={content}
|
|
72
|
-
events={block.eval.events}
|
|
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
|
-
/>
|
|
82
|
-
</BlockLayout>
|
|
83
|
-
);
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
export default Container;
|
|
@@ -1,93 +0,0 @@
|
|
|
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.basePath}
|
|
76
|
-
blockId={block.blockId}
|
|
77
|
-
components={lowdefy._internal.components}
|
|
78
|
-
events={block.eval.events}
|
|
79
|
-
key={block.blockId}
|
|
80
|
-
list={contentList}
|
|
81
|
-
loading={block.loading}
|
|
82
|
-
menus={lowdefy.menus}
|
|
83
|
-
pageId={lowdefy.pageId}
|
|
84
|
-
properties={block.eval.properties}
|
|
85
|
-
required={block.eval.required}
|
|
86
|
-
user={lowdefy.user}
|
|
87
|
-
validation={block.eval.validation}
|
|
88
|
-
/>
|
|
89
|
-
</BlockLayout>
|
|
90
|
-
);
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
export default List;
|
|
@@ -1,22 +0,0 @@
|
|
|
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;
|
|
@@ -1,46 +0,0 @@
|
|
|
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;
|
|
@@ -1,29 +0,0 @@
|
|
|
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 { createIcon } from '@lowdefy/block-utils';
|
|
18
|
-
|
|
19
|
-
import createLinkComponent from './createLinkComponent.js';
|
|
20
|
-
import icons from '../../build/plugins/icons.js';
|
|
21
|
-
|
|
22
|
-
const createComponents = (lowdefy) => {
|
|
23
|
-
return {
|
|
24
|
-
Link: createLinkComponent(lowdefy),
|
|
25
|
-
Icon: createIcon(icons),
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export default createComponents;
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import NextLink from 'next/link';
|
|
3
|
-
import { createLink } from '@lowdefy/engine';
|
|
4
|
-
import { type } from '@lowdefy/helpers';
|
|
5
|
-
|
|
6
|
-
const createLinkComponent = (lowdefy) => {
|
|
7
|
-
const backLink = ({ ariaLabel, children, className, id, rel }) => (
|
|
8
|
-
<a
|
|
9
|
-
id={id}
|
|
10
|
-
onClick={() => lowdefy._internal.router.back()}
|
|
11
|
-
className={className}
|
|
12
|
-
rel={rel}
|
|
13
|
-
aria-label={ariaLabel || 'back'}
|
|
14
|
-
>
|
|
15
|
-
{type.isFunction(children) ? children(id) : children}
|
|
16
|
-
</a>
|
|
17
|
-
);
|
|
18
|
-
const newOriginLink = ({
|
|
19
|
-
ariaLabel,
|
|
20
|
-
children,
|
|
21
|
-
className,
|
|
22
|
-
id,
|
|
23
|
-
newTab,
|
|
24
|
-
pageId,
|
|
25
|
-
query,
|
|
26
|
-
rel,
|
|
27
|
-
url,
|
|
28
|
-
}) => {
|
|
29
|
-
return (
|
|
30
|
-
<a
|
|
31
|
-
id={id}
|
|
32
|
-
aria-label={ariaLabel}
|
|
33
|
-
className={className}
|
|
34
|
-
href={`${url}${query ? `?${query}` : ''}`}
|
|
35
|
-
rel={rel || (newTab && 'noopener noreferrer')}
|
|
36
|
-
target={newTab && '_blank'}
|
|
37
|
-
>
|
|
38
|
-
{type.isFunction(children) ? children(pageId || url || id) : children}
|
|
39
|
-
</a>
|
|
40
|
-
);
|
|
41
|
-
};
|
|
42
|
-
const sameOriginLink = ({
|
|
43
|
-
ariaLabel,
|
|
44
|
-
children,
|
|
45
|
-
className,
|
|
46
|
-
id,
|
|
47
|
-
newTab,
|
|
48
|
-
pageId,
|
|
49
|
-
pathname,
|
|
50
|
-
query,
|
|
51
|
-
rel,
|
|
52
|
-
replace,
|
|
53
|
-
scroll,
|
|
54
|
-
setInput,
|
|
55
|
-
url,
|
|
56
|
-
}) => {
|
|
57
|
-
if (newTab) {
|
|
58
|
-
return (
|
|
59
|
-
// eslint-disable-next-line react/jsx-no-target-blank
|
|
60
|
-
<a
|
|
61
|
-
id={id}
|
|
62
|
-
aria-label={ariaLabel}
|
|
63
|
-
className={className}
|
|
64
|
-
href={`${window.location.origin}${lowdefy.basePath}${pathname}${
|
|
65
|
-
query ? `?${query}` : ''
|
|
66
|
-
}`}
|
|
67
|
-
rel={rel || 'noopener noreferrer'}
|
|
68
|
-
target="_blank"
|
|
69
|
-
>
|
|
70
|
-
{type.isFunction(children) ? children(pageId || url || id) : children}
|
|
71
|
-
</a>
|
|
72
|
-
);
|
|
73
|
-
}
|
|
74
|
-
return (
|
|
75
|
-
<NextLink href={{ pathname, query }} replace={replace} scroll={scroll}>
|
|
76
|
-
<a id={id} aria-label={ariaLabel} className={className} rel={rel} onClick={setInput}>
|
|
77
|
-
{type.isFunction(children) ? children(pageId || url || id) : children}
|
|
78
|
-
</a>
|
|
79
|
-
</NextLink>
|
|
80
|
-
);
|
|
81
|
-
};
|
|
82
|
-
const noLink = ({ className, children, id }) => (
|
|
83
|
-
<span id={id} className={className}>
|
|
84
|
-
{type.isFunction(children) ? children(id) : children}
|
|
85
|
-
</span>
|
|
86
|
-
);
|
|
87
|
-
return createLink({
|
|
88
|
-
backLink,
|
|
89
|
-
lowdefy,
|
|
90
|
-
newOriginLink,
|
|
91
|
-
sameOriginLink,
|
|
92
|
-
noLink,
|
|
93
|
-
disabledLink: noLink,
|
|
94
|
-
});
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
export default createLinkComponent;
|
package/src/pages/404.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
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 getStaticProps() {
|
|
22
|
-
// TODO: get the right api context options
|
|
23
|
-
const apiContext = await createApiContext({ buildDirectory: './build' });
|
|
24
|
-
|
|
25
|
-
const [rootConfig, pageConfig] = await Promise.all([
|
|
26
|
-
getRootConfig(apiContext),
|
|
27
|
-
getPageConfig(apiContext, { pageId: '404' }),
|
|
28
|
-
]);
|
|
29
|
-
|
|
30
|
-
return {
|
|
31
|
-
props: {
|
|
32
|
-
pageConfig,
|
|
33
|
-
rootConfig,
|
|
34
|
-
},
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export default Page;
|
package/src/pages/[pageId].js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
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
|
-
// TODO: get the right api context options
|
|
24
|
-
const apiContext = await createApiContext({ buildDirectory: './build' });
|
|
25
|
-
|
|
26
|
-
const [rootConfig, pageConfig] = await Promise.all([
|
|
27
|
-
getRootConfig(apiContext),
|
|
28
|
-
getPageConfig(apiContext, { pageId }),
|
|
29
|
-
]);
|
|
30
|
-
|
|
31
|
-
if (!pageConfig) {
|
|
32
|
-
return {
|
|
33
|
-
redirect: {
|
|
34
|
-
destination: '/404',
|
|
35
|
-
permanent: false,
|
|
36
|
-
},
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return {
|
|
41
|
-
props: {
|
|
42
|
-
pageConfig,
|
|
43
|
-
rootConfig,
|
|
44
|
-
},
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export default Page;
|
package/src/pages/_app.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
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
|
-
const lowdefy = {};
|
|
26
|
-
|
|
27
|
-
function App({ Component, pageProps }) {
|
|
28
|
-
return (
|
|
29
|
-
<ErrorBoundary>
|
|
30
|
-
<Suspense>
|
|
31
|
-
<LowdefyContext lowdefy={lowdefy}>
|
|
32
|
-
<Component lowdefy={lowdefy} {...pageProps} />
|
|
33
|
-
</LowdefyContext>
|
|
34
|
-
</Suspense>
|
|
35
|
-
</ErrorBoundary>
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export default App;
|
package/src/pages/_document.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
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 Document, { Html, Head, Main, NextScript } from 'next/document';
|
|
19
|
-
|
|
20
|
-
class LowdefyDocument extends Document {
|
|
21
|
-
render() {
|
|
22
|
-
return (
|
|
23
|
-
<Html>
|
|
24
|
-
<Head>
|
|
25
|
-
<link rel="manifest" href="/manifest.webmanifest" />
|
|
26
|
-
<link rel="icon" type="image/svg+xml" href="/icon.svg" />
|
|
27
|
-
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
|
|
28
|
-
</Head>
|
|
29
|
-
<body>
|
|
30
|
-
<Main />
|
|
31
|
-
<NextScript />
|
|
32
|
-
</body>
|
|
33
|
-
</Html>
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export default LowdefyDocument;
|
|
@@ -1,28 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1,44 +0,0 @@
|
|
|
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 { getSecretsFromEnv } from '@lowdefy/node-utils';
|
|
19
|
-
import connections from '../../../../../build/plugins/connections.js';
|
|
20
|
-
import operators from '../../../../../build/plugins/operatorsServer.js';
|
|
21
|
-
|
|
22
|
-
export default async function handler(req, res) {
|
|
23
|
-
try {
|
|
24
|
-
if (req.method !== 'POST') {
|
|
25
|
-
throw new Error('Only POST requests are supported.');
|
|
26
|
-
}
|
|
27
|
-
// TODO: configure API context
|
|
28
|
-
const apiContext = await createApiContext({
|
|
29
|
-
buildDirectory: './build',
|
|
30
|
-
connections,
|
|
31
|
-
// TODO: use a logger like pino
|
|
32
|
-
logger: console,
|
|
33
|
-
operators,
|
|
34
|
-
secrets: getSecretsFromEnv(),
|
|
35
|
-
});
|
|
36
|
-
const { pageId, requestId } = req.query;
|
|
37
|
-
const { payload } = req.body;
|
|
38
|
-
|
|
39
|
-
const response = await callRequest(apiContext, { pageId, payload, requestId });
|
|
40
|
-
res.status(200).json(response);
|
|
41
|
-
} catch (error) {
|
|
42
|
-
res.status(500).json({ name: error.name, message: error.message });
|
|
43
|
-
}
|
|
44
|
-
}
|
package/src/pages/index.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
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() {
|
|
22
|
-
// TODO: is this build directory configurable from the cli?
|
|
23
|
-
const apiContext = await createApiContext({ buildDirectory: './build' });
|
|
24
|
-
const rootConfig = await getRootConfig(apiContext);
|
|
25
|
-
const { home } = rootConfig;
|
|
26
|
-
if (home.configured === false) {
|
|
27
|
-
return {
|
|
28
|
-
redirect: {
|
|
29
|
-
destination: `/${home.pageId}`,
|
|
30
|
-
permanent: false,
|
|
31
|
-
},
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
const pageConfig = await getPageConfig(apiContext, { pageId: home.pageId });
|
|
35
|
-
if (!pageConfig) {
|
|
36
|
-
return {
|
|
37
|
-
redirect: {
|
|
38
|
-
destination: '/404',
|
|
39
|
-
permanent: false,
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
return {
|
|
44
|
-
props: {
|
|
45
|
-
pageConfig,
|
|
46
|
-
rootConfig,
|
|
47
|
-
},
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export default Page;
|
package/src/utils/callRequest.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
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;
|
package/src/utils/request.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
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;
|
package/src/utils/setupLink.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
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 backLink = () => router.back();
|
|
22
|
-
const disabledLink = () => {};
|
|
23
|
-
const newOriginLink = ({ url, query, newTab }) => {
|
|
24
|
-
if (newTab) {
|
|
25
|
-
return window.open(`${url}${query ? `?${query}` : ''}`, '_blank').focus();
|
|
26
|
-
} else {
|
|
27
|
-
return window.location.assign(`${url}${query ? `?${query}` : ''}`);
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
const sameOriginLink = ({ newTab, pathname, query, setInput }) => {
|
|
31
|
-
if (newTab) {
|
|
32
|
-
return window
|
|
33
|
-
.open(
|
|
34
|
-
`${window.location.origin}${lowdefy.basePath}${pathname}${query ? `?${query}` : ''}`,
|
|
35
|
-
'_blank'
|
|
36
|
-
)
|
|
37
|
-
.focus();
|
|
38
|
-
} else {
|
|
39
|
-
setInput();
|
|
40
|
-
return router.push({
|
|
41
|
-
pathname,
|
|
42
|
-
query,
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
const noLink = () => {
|
|
47
|
-
throw new Error(`Invalid Link.`);
|
|
48
|
-
};
|
|
49
|
-
return createLink({ backLink, disabledLink, lowdefy, newOriginLink, noLink, sameOriginLink });
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export default setupLink;
|