@lowdefy/server 3.23.3 → 4.0.0-alpha.11
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/README.md +17 -1
- package/lib/Page.js +62 -0
- package/lowdefy/build.mjs +51 -0
- package/lowdefy/createCustomPluginTypesMap.mjs +71 -0
- package/next.config.js +36 -0
- package/package.json +38 -25
- package/pages/404.js +37 -0
- package/pages/[pageId].js +54 -0
- package/pages/_app.js +37 -0
- package/pages/_document.js +38 -0
- package/pages/api/auth/[...nextauth].js +25 -0
- package/pages/api/request/[pageId]/[requestId].js +46 -0
- package/pages/index.js +57 -0
- package/public/apple-touch-icon.png +0 -0
- package/public/favicon.ico +0 -0
- package/public/icon-512.png +0 -0
- package/public/icon.svg +17 -0
- package/public/logo-dark-theme.png +0 -0
- package/public/logo-light-theme.png +0 -0
- package/public/logo-square-dark-theme.png +0 -0
- package/public/logo-square-light-theme.png +0 -0
- package/public/manifest.webmanifest +16 -0
- package/dist/index.js +0 -106
package/.eslintrc.yaml
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
extends: 'plugin:@next/next/core-web-vitals'
|
package/README.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @lowdefy/server
|
|
2
2
|
|
|
3
|
+
## Development
|
|
4
|
+
|
|
5
|
+
To run the server in locally as a development server, run the following:
|
|
6
|
+
|
|
7
|
+
- Run `yarn && yarn build` at the root of the repository.
|
|
8
|
+
- Add a `lowdefy.yaml` file in the server directory (`packages/server`).
|
|
9
|
+
- run `yarn dev` in the server directory.
|
|
10
|
+
|
|
11
|
+
To run the server in locally as a development server, with a next production build, run the following:
|
|
12
|
+
|
|
13
|
+
- Run `yarn && yarn build` at the root of the repository.
|
|
14
|
+
- Add a `lowdefy.yaml` file in the server directory (`packages/server`).
|
|
15
|
+
- run `yarn dev:prod` in the server directory.
|
|
16
|
+
|
|
17
|
+
> When running a development server, the `package.json` file is updated with the plugins used in the Lowdefy app. Please do not commit the changes made to the `package.json`, `.pnp.cjs` and `yarn.lock` files.
|
|
18
|
+
|
|
3
19
|
## Licence
|
|
4
20
|
|
|
5
|
-
[Apache-2.0](https://github.com/lowdefy/lowdefy/blob/main/LICENSE)
|
|
21
|
+
[Apache-2.0](https://github.com/lowdefy/lowdefy/blob/main/LICENSE)
|
package/lib/Page.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2022 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
|
+
import Client from '@lowdefy/client';
|
|
21
|
+
import Head from 'next/head';
|
|
22
|
+
import Link from 'next/link';
|
|
23
|
+
import { signIn, signOut, useSession } from 'next-auth/react';
|
|
24
|
+
|
|
25
|
+
import actions from '../build/plugins/actions.js';
|
|
26
|
+
import blocks from '../build/plugins/blocks.js';
|
|
27
|
+
import icons from '../build/plugins/icons.js';
|
|
28
|
+
import operators from '../build/plugins/operators/client.js';
|
|
29
|
+
|
|
30
|
+
const Page = ({ pageConfig, rootConfig }) => {
|
|
31
|
+
const router = useRouter();
|
|
32
|
+
const { data: session, status } = useSession();
|
|
33
|
+
|
|
34
|
+
// If session is passed to SessionProvider from getServerSideProps
|
|
35
|
+
// we won't have a loading state here.
|
|
36
|
+
// But 404 uses getStaticProps so we have this for 404.
|
|
37
|
+
if (status === 'loading') {
|
|
38
|
+
return '';
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<Client
|
|
43
|
+
auth={{ signIn, signOut }}
|
|
44
|
+
Components={{ Head, Link }}
|
|
45
|
+
config={{
|
|
46
|
+
pageConfig,
|
|
47
|
+
rootConfig,
|
|
48
|
+
}}
|
|
49
|
+
router={router}
|
|
50
|
+
session={session}
|
|
51
|
+
types={{
|
|
52
|
+
actions,
|
|
53
|
+
blocks,
|
|
54
|
+
icons,
|
|
55
|
+
operators,
|
|
56
|
+
}}
|
|
57
|
+
window={window}
|
|
58
|
+
/>
|
|
59
|
+
);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export default Page;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/*
|
|
3
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
4
|
+
|
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
you may not use this file except in compliance with the License.
|
|
7
|
+
You may obtain a copy of the License at
|
|
8
|
+
|
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
|
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
See the License for the specific language governing permissions and
|
|
15
|
+
limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import path from 'path';
|
|
19
|
+
import yargs from 'yargs';
|
|
20
|
+
import { hideBin } from 'yargs/helpers';
|
|
21
|
+
|
|
22
|
+
import build from '@lowdefy/build';
|
|
23
|
+
import createCustomPluginTypesMap from './createCustomPluginTypesMap.mjs';
|
|
24
|
+
|
|
25
|
+
const argv = yargs(hideBin(process.argv)).argv;
|
|
26
|
+
|
|
27
|
+
async function run() {
|
|
28
|
+
const directories = {
|
|
29
|
+
build: path.resolve(
|
|
30
|
+
argv.buildDirectory ||
|
|
31
|
+
process.env.LOWDEFY_DIRECTORY_BUILD ||
|
|
32
|
+
path.join(process.cwd(), 'build')
|
|
33
|
+
),
|
|
34
|
+
config: path.resolve(
|
|
35
|
+
argv.configDirectory || process.env.LOWDEFY_DIRECTORY_CONFIG || process.cwd()
|
|
36
|
+
),
|
|
37
|
+
server: path.resolve(
|
|
38
|
+
argv.serverDirectory || process.env.LOWDEFY_DIRECTORY_SERVER || process.cwd()
|
|
39
|
+
),
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const customTypesMap = await createCustomPluginTypesMap({ directories });
|
|
43
|
+
await build({
|
|
44
|
+
customTypesMap,
|
|
45
|
+
directories,
|
|
46
|
+
logger: console,
|
|
47
|
+
refResolver: argv.refResolver || process.env.LOWDEFY_BUILD_REF_RESOLVER,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
run();
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/*
|
|
3
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
4
|
+
|
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
you may not use this file except in compliance with the License.
|
|
7
|
+
You may obtain a copy of the License at
|
|
8
|
+
|
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
|
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
See the License for the specific language governing permissions and
|
|
15
|
+
limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import path from 'path';
|
|
19
|
+
import { get } from '@lowdefy/helpers';
|
|
20
|
+
import { readFile } from '@lowdefy/node-utils';
|
|
21
|
+
import { createPluginTypesMap } from '@lowdefy/build';
|
|
22
|
+
import YAML from 'yaml';
|
|
23
|
+
|
|
24
|
+
async function getPluginDefinitions({ directories }) {
|
|
25
|
+
let lowdefyYaml = await readFile(path.join(directories.config, 'lowdefy.yaml'));
|
|
26
|
+
if (!lowdefyYaml) {
|
|
27
|
+
lowdefyYaml = await readFile(path.join(directories.config, 'lowdefy.yml'));
|
|
28
|
+
}
|
|
29
|
+
const lowdefy = YAML.parse(lowdefyYaml);
|
|
30
|
+
return get(lowdefy, 'plugins', { default: [] });
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async function createCustomPluginTypesMap({ directories }) {
|
|
34
|
+
const customTypesMap = {
|
|
35
|
+
actions: {},
|
|
36
|
+
auth: {
|
|
37
|
+
callbacks: {},
|
|
38
|
+
events: {},
|
|
39
|
+
providers: {},
|
|
40
|
+
},
|
|
41
|
+
blocks: {},
|
|
42
|
+
connections: {},
|
|
43
|
+
icons: {},
|
|
44
|
+
operators: {
|
|
45
|
+
client: {},
|
|
46
|
+
server: {},
|
|
47
|
+
},
|
|
48
|
+
requests: {},
|
|
49
|
+
styles: {
|
|
50
|
+
packages: {},
|
|
51
|
+
blocks: {},
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const pluginDefinitions = await getPluginDefinitions({ directories });
|
|
56
|
+
|
|
57
|
+
for (const plugin of pluginDefinitions) {
|
|
58
|
+
const { default: types } = await import(`${plugin.name}/types`);
|
|
59
|
+
createPluginTypesMap({
|
|
60
|
+
packageTypes: types,
|
|
61
|
+
typesMap: customTypesMap,
|
|
62
|
+
packageName: plugin.name,
|
|
63
|
+
version: plugin.version,
|
|
64
|
+
typePrefix: plugin.typePrefix,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return customTypesMap;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export default createCustomPluginTypesMap;
|
package/next.config.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const withLess = require('next-with-less');
|
|
2
|
+
const lowdefyConfig = require('./build/config.json');
|
|
3
|
+
|
|
4
|
+
// TODO: Trace env and args from cli that is required on the server.
|
|
5
|
+
module.exports = withLess({
|
|
6
|
+
basePath: process.env.LOWDEFY_BASE_PATH || lowdefyConfig.basePath,
|
|
7
|
+
lessLoaderOptions: {
|
|
8
|
+
lessOptions: {
|
|
9
|
+
modifyVars: lowdefyConfig.theme.lessVariables,
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
reactStrictMode: true,
|
|
13
|
+
webpack: (config, { isServer }) => {
|
|
14
|
+
if (!isServer) {
|
|
15
|
+
config.resolve.fallback = {
|
|
16
|
+
assert: false,
|
|
17
|
+
buffer: false,
|
|
18
|
+
crypto: false,
|
|
19
|
+
events: false,
|
|
20
|
+
fs: false,
|
|
21
|
+
path: false,
|
|
22
|
+
process: require.resolve('process/browser'),
|
|
23
|
+
util: false,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
return config;
|
|
27
|
+
},
|
|
28
|
+
poweredByHeader: false,
|
|
29
|
+
// productionBrowserSourceMaps: true
|
|
30
|
+
// experimental: {
|
|
31
|
+
// concurrentFeatures: true,
|
|
32
|
+
// },
|
|
33
|
+
eslint: {
|
|
34
|
+
ignoreDuringBuilds: true,
|
|
35
|
+
},
|
|
36
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lowdefy/server",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-alpha.11",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
|
@@ -25,39 +25,52 @@
|
|
|
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
|
+
"lib/*",
|
|
30
|
+
"lowdefy/*",
|
|
31
|
+
"pages/*",
|
|
32
|
+
"public/*",
|
|
33
|
+
"next.config.js",
|
|
34
|
+
".eslintrc.yaml"
|
|
31
35
|
],
|
|
32
36
|
"scripts": {
|
|
33
|
-
"
|
|
34
|
-
"build": "
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
37
|
+
"build:lowdefy": "node lowdefy/build.mjs",
|
|
38
|
+
"build:next": "next build",
|
|
39
|
+
"dev": "next dev",
|
|
40
|
+
"start": "next start",
|
|
41
|
+
"lint": "next lint",
|
|
42
|
+
"next": "next"
|
|
38
43
|
},
|
|
39
44
|
"dependencies": {
|
|
40
|
-
"@lowdefy/
|
|
41
|
-
"@lowdefy/
|
|
42
|
-
"@lowdefy/
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
45
|
+
"@lowdefy/actions-core": "4.0.0-alpha.11",
|
|
46
|
+
"@lowdefy/api": "4.0.0-alpha.11",
|
|
47
|
+
"@lowdefy/blocks-antd": "4.0.0-alpha.11",
|
|
48
|
+
"@lowdefy/blocks-basic": "4.0.0-alpha.11",
|
|
49
|
+
"@lowdefy/blocks-loaders": "4.0.0-alpha.11",
|
|
50
|
+
"@lowdefy/client": "4.0.0-alpha.11",
|
|
51
|
+
"@lowdefy/helpers": "4.0.0-alpha.11",
|
|
52
|
+
"@lowdefy/layout": "4.0.0-alpha.11",
|
|
53
|
+
"@lowdefy/node-utils": "4.0.0-alpha.11",
|
|
54
|
+
"@lowdefy/operators-js": "4.0.0-alpha.11",
|
|
55
|
+
"@lowdefy/plugin-next-auth": "4.0.0-alpha.11",
|
|
56
|
+
"next": "12.0.10",
|
|
57
|
+
"next-auth": "4.3.4",
|
|
58
|
+
"process": "0.11.10",
|
|
59
|
+
"react": "17.0.2",
|
|
60
|
+
"react-dom": "17.0.2",
|
|
61
|
+
"react-icons": "4.3.1"
|
|
47
62
|
},
|
|
48
63
|
"devDependencies": {
|
|
49
|
-
"@
|
|
50
|
-
"@
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"jest": "26.6.3",
|
|
57
|
-
"nodemon": "2.0.7"
|
|
64
|
+
"@lowdefy/build": "4.0.0-alpha.11",
|
|
65
|
+
"@next/eslint-plugin-next": "12.0.10",
|
|
66
|
+
"less": "4.1.2",
|
|
67
|
+
"less-loader": "10.2.0",
|
|
68
|
+
"next-with-less": "2.0.4",
|
|
69
|
+
"yaml": "1.10.2",
|
|
70
|
+
"yargs": "17.3.1"
|
|
58
71
|
},
|
|
59
72
|
"publishConfig": {
|
|
60
73
|
"access": "public"
|
|
61
74
|
},
|
|
62
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "810fb2d8cb9ee8b0586b55fbbf26a5a5a0da3b2a"
|
|
63
76
|
}
|
package/pages/404.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2022 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 '../lib/Page.js';
|
|
20
|
+
|
|
21
|
+
export async function getStaticProps() {
|
|
22
|
+
const apiContext = await createApiContext({ buildDirectory: './build' });
|
|
23
|
+
|
|
24
|
+
const [rootConfig, pageConfig] = await Promise.all([
|
|
25
|
+
getRootConfig(apiContext),
|
|
26
|
+
getPageConfig(apiContext, { pageId: '404' }),
|
|
27
|
+
]);
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
props: {
|
|
31
|
+
pageConfig,
|
|
32
|
+
rootConfig,
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export default Page;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2022 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
|
+
import { getSession } from 'next-auth/react';
|
|
19
|
+
|
|
20
|
+
import Page from '../lib/Page.js';
|
|
21
|
+
|
|
22
|
+
export async function getServerSideProps(context) {
|
|
23
|
+
const { pageId } = context.params;
|
|
24
|
+
const session = await getSession(context);
|
|
25
|
+
const apiContext = await createApiContext({
|
|
26
|
+
buildDirectory: './build',
|
|
27
|
+
logger: console,
|
|
28
|
+
session,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const [rootConfig, pageConfig] = await Promise.all([
|
|
32
|
+
getRootConfig(apiContext),
|
|
33
|
+
getPageConfig(apiContext, { pageId }),
|
|
34
|
+
]);
|
|
35
|
+
|
|
36
|
+
if (!pageConfig) {
|
|
37
|
+
return {
|
|
38
|
+
redirect: {
|
|
39
|
+
destination: '/404',
|
|
40
|
+
permanent: false,
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return {
|
|
46
|
+
props: {
|
|
47
|
+
pageConfig,
|
|
48
|
+
rootConfig,
|
|
49
|
+
session,
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export default Page;
|
package/pages/_app.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2022 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 dynamic from 'next/dynamic';
|
|
19
|
+
import { SessionProvider } from 'next-auth/react';
|
|
20
|
+
|
|
21
|
+
// Must be in _app due to next specifications.
|
|
22
|
+
import '../build/plugins/styles.less';
|
|
23
|
+
|
|
24
|
+
// TODO: SessionProvider requires basebath
|
|
25
|
+
function App({ Component, pageProps: { session, ...pageProps } }) {
|
|
26
|
+
return (
|
|
27
|
+
<SessionProvider session={session}>
|
|
28
|
+
<Component {...pageProps} />
|
|
29
|
+
</SessionProvider>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const DynamicApp = dynamic(() => Promise.resolve(App), {
|
|
34
|
+
ssr: false,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
export default DynamicApp;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2022 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;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2022 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 { getNextAuthConfig } from '@lowdefy/api';
|
|
19
|
+
|
|
20
|
+
import authJson from '../../../build/auth.json';
|
|
21
|
+
import callbacks from '../../../build/plugins/auth/callbacks.js';
|
|
22
|
+
import events from '../../../build/plugins/auth/events.js';
|
|
23
|
+
import providers from '../../../build/plugins/auth/providers.js';
|
|
24
|
+
|
|
25
|
+
export default NextAuth(getNextAuthConfig({ authJson, plugins: { callbacks, events, providers } }));
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2022 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 { getSession } from 'next-auth/react';
|
|
20
|
+
import connections from '../../../../build/plugins/connections.js';
|
|
21
|
+
import operators from '../../../../build/plugins/operators/server.js';
|
|
22
|
+
|
|
23
|
+
export default async function handler(req, res) {
|
|
24
|
+
try {
|
|
25
|
+
if (req.method !== 'POST') {
|
|
26
|
+
throw new Error('Only POST requests are supported.');
|
|
27
|
+
}
|
|
28
|
+
const session = await getSession({ req });
|
|
29
|
+
const apiContext = await createApiContext({
|
|
30
|
+
buildDirectory: './build',
|
|
31
|
+
connections,
|
|
32
|
+
// logger: console,
|
|
33
|
+
logger: { debug: () => {} },
|
|
34
|
+
operators,
|
|
35
|
+
secrets: getSecretsFromEnv(),
|
|
36
|
+
session,
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const { pageId, requestId } = req.query;
|
|
40
|
+
const { payload } = req.body;
|
|
41
|
+
const response = await callRequest(apiContext, { pageId, payload, requestId });
|
|
42
|
+
res.status(200).json(response);
|
|
43
|
+
} catch (error) {
|
|
44
|
+
res.status(500).json({ name: error.name, message: error.message });
|
|
45
|
+
}
|
|
46
|
+
}
|
package/pages/index.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2022 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
|
+
import { getSession } from 'next-auth/react';
|
|
19
|
+
|
|
20
|
+
import Page from '../lib/Page.js';
|
|
21
|
+
|
|
22
|
+
export async function getServerSideProps(context) {
|
|
23
|
+
const session = await getSession(context);
|
|
24
|
+
const apiContext = await createApiContext({
|
|
25
|
+
buildDirectory: './build',
|
|
26
|
+
logger: console,
|
|
27
|
+
session,
|
|
28
|
+
});
|
|
29
|
+
const rootConfig = await getRootConfig(apiContext);
|
|
30
|
+
const { home } = rootConfig;
|
|
31
|
+
if (home.configured === false) {
|
|
32
|
+
return {
|
|
33
|
+
redirect: {
|
|
34
|
+
destination: `/${home.pageId}`,
|
|
35
|
+
permanent: false,
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
const pageConfig = await getPageConfig(apiContext, { pageId: home.pageId });
|
|
40
|
+
if (!pageConfig) {
|
|
41
|
+
return {
|
|
42
|
+
redirect: {
|
|
43
|
+
destination: '/404',
|
|
44
|
+
permanent: false,
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
props: {
|
|
50
|
+
pageConfig,
|
|
51
|
+
rootConfig,
|
|
52
|
+
session,
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export default Page;
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/public/icon.svg
ADDED
|
@@ -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
|
+
}
|
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;
|