@lowdefy/server 4.0.0-alpha.6 → 4.0.0-alpha.9

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 CHANGED
@@ -1,7 +1,9 @@
1
1
  const withLess = require('next-with-less');
2
2
  const lowdefyConfig = require('./build/config.json');
3
3
 
4
+ // TODO: Trace env and args from cli that is required on the server.
4
5
  module.exports = withLess({
6
+ basePath: process.env.LOWDEFY_BASE_PATH || lowdefyConfig.basePath,
5
7
  lessLoaderOptions: {
6
8
  lessOptions: {
7
9
  modifyVars: lowdefyConfig.theme.lessVariables,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/server",
3
- "version": "4.0.0-alpha.6",
3
+ "version": "4.0.0-alpha.9",
4
4
  "license": "Apache-2.0",
5
5
  "description": "",
6
6
  "homepage": "https://lowdefy.com",
@@ -32,38 +32,42 @@
32
32
  ".eslintrc.yaml"
33
33
  ],
34
34
  "scripts": {
35
- "build:lowdefy": "lowdefy-build",
35
+ "build:lowdefy": "node lowdefy/build.mjs",
36
36
  "build:next": "next build",
37
- "dev": "yarn build:lowdefy && yarn && next dev",
38
- "dev:prod": "yarn build:lowdefy && yarn && yarn build:next && next start",
37
+ "dev": "next dev",
39
38
  "start": "next start",
40
39
  "lint": "next lint",
41
40
  "next": "next"
42
41
  },
43
42
  "dependencies": {
44
- "@lowdefy/api": "4.0.0-alpha.6",
45
- "@lowdefy/block-utils": "4.0.0-alpha.6",
46
- "@lowdefy/engine": "4.0.0-alpha.6",
47
- "@lowdefy/helpers": "4.0.0-alpha.6",
48
- "@lowdefy/layout": "4.0.0-alpha.6",
49
- "@lowdefy/node-utils": "4.0.0-alpha.6",
50
- "@lowdefy/operators-js": "4.0.0-alpha.6",
51
- "next": "12.0.3",
52
- "next-auth": "4.0.0-beta.6",
43
+ "@lowdefy/actions-core": "4.0.0-alpha.9",
44
+ "@lowdefy/api": "4.0.0-alpha.9",
45
+ "@lowdefy/blocks-antd": "4.0.0-alpha.9",
46
+ "@lowdefy/blocks-basic": "4.0.0-alpha.9",
47
+ "@lowdefy/blocks-loaders": "4.0.0-alpha.9",
48
+ "@lowdefy/client": "4.0.0-alpha.9",
49
+ "@lowdefy/helpers": "4.0.0-alpha.9",
50
+ "@lowdefy/layout": "4.0.0-alpha.9",
51
+ "@lowdefy/node-utils": "4.0.0-alpha.9",
52
+ "@lowdefy/operators-js": "4.0.0-alpha.9",
53
+ "next": "12.0.10",
54
+ "next-auth": "4.1.2",
53
55
  "process": "0.11.10",
54
- "react": "18.0.0-alpha-327d5c484-20211106",
55
- "react-dom": "18.0.0-alpha-327d5c484-20211106",
56
+ "react": "17.0.2",
57
+ "react-dom": "17.0.2",
56
58
  "react-icons": "4.3.1"
57
59
  },
58
60
  "devDependencies": {
59
- "@lowdefy/build": "4.0.0-alpha.6",
60
- "@next/eslint-plugin-next": "12.0.4",
61
+ "@lowdefy/build": "4.0.0-alpha.9",
62
+ "@next/eslint-plugin-next": "12.0.10",
61
63
  "less": "4.1.2",
62
64
  "less-loader": "10.2.0",
63
- "next-with-less": "2.0.2"
65
+ "next-with-less": "2.0.4",
66
+ "yaml": "1.10.2",
67
+ "yargs": "17.3.1"
64
68
  },
65
69
  "publishConfig": {
66
70
  "access": "public"
67
71
  },
68
- "gitHead": "2530e31af795b6a3c75ac8f72c8dbe0ab5d1251b"
72
+ "gitHead": "98b544eca231bdcfca6c3a8601a891835d5ce571"
69
73
  }
package/public/.DS_Store DELETED
Binary file
@@ -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;
@@ -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,49 +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 callRequest from '../utils/callRequest.js';
20
- import blockComponents from '../../build/plugins/blocks.js';
21
- import operators from '../../build/plugins/operatorsClient.js';
22
- import components from './components.js';
23
-
24
- const LowdefyContext = ({ children }) => {
25
- const lowdefy = {
26
- _internal: {
27
- blockComponents,
28
- callRequest,
29
- components,
30
- document,
31
- operators,
32
- updaters: {},
33
- window,
34
- displayMessage: ({ content }) => {
35
- alert(content);
36
- return () => undefined;
37
- },
38
- link: () => undefined,
39
- },
40
- contexts: {},
41
- inputs: {},
42
- lowdefyGlobal: {},
43
- };
44
- lowdefy._internal.updateBlock = (blockId) =>
45
- lowdefy._internal.updaters[blockId] && lowdefy._internal.updaters[blockId]();
46
- return <>{children(lowdefy)}</>;
47
- };
48
-
49
- export default LowdefyContext;
@@ -1,60 +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 { 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;
@@ -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,120 +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
- // 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.home.pageId}
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.home.pageId}
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;
@@ -1,87 +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._internal.basePath}
69
- blockId={block.blockId}
70
- components={lowdefy._internal.components}
71
- content={content}
72
- events={block.eval.events}
73
- homePageId={lowdefy.home.pageId}
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;
@@ -1,94 +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._internal.basePath}
76
- blockId={block.blockId}
77
- components={lowdefy._internal.components}
78
- events={block.eval.events}
79
- homePageId={lowdefy.home.pageId}
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;
@@ -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,25 +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 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
- };
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;
@@ -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 { 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
- // TODO: Maybe we can only get rootConfig once?
27
- // We can't do getServerSideProps on _app :(
28
- const [rootConfig, pageConfig] = await Promise.all([
29
- getRootConfig(apiContext),
30
- getPageConfig(apiContext, { pageId }),
31
- ]);
32
-
33
- if (!pageConfig) {
34
- return {
35
- redirect: {
36
- destination: '/404',
37
- permanent: false,
38
- },
39
- };
40
- }
41
-
42
- return {
43
- props: {
44
- pageConfig,
45
- rootConfig,
46
- },
47
- };
48
- }
49
-
50
- export default Page;
package/src/pages/_app.js DELETED
@@ -1,37 +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
- 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;
@@ -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
- }
@@ -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 { createApiContext, 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: './build' });
23
- const rootConfig = await getRootConfig(apiContext);
24
- const { home } = rootConfig;
25
- if (home.configured === false) {
26
- return {
27
- redirect: {
28
- destination: `/${home.pageId}`,
29
- permanent: false,
30
- },
31
- };
32
- }
33
- const pageConfig = await getPageConfig(apiContext, { pageId: home.pageId });
34
- if (!pageConfig) {
35
- return {
36
- redirect: {
37
- destination: '/404',
38
- permanent: false,
39
- },
40
- };
41
- }
42
- return {
43
- props: {
44
- pageConfig,
45
- rootConfig,
46
- },
47
- };
48
- }
49
-
50
- export default Page;
@@ -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;
@@ -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;
@@ -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 { 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;