@lowdefy/server-dev 4.0.0-alpha.10 → 4.0.0-alpha.13
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/lib/App.js +3 -2
- package/lib/Page.js +3 -1
- package/lib/auth/Auth.js +35 -0
- package/lib/auth/AuthConfigured.js +47 -0
- package/lib/auth/AuthNotConfigured.js +32 -0
- package/lib/auth/getServerSession.js +27 -0
- package/lib/utils/usePageConfig.js +0 -2
- package/lib/utils/useRootConfig.js +0 -3
- package/manager/getContext.mjs +6 -7
- package/manager/processes/initialBuild.mjs +1 -1
- package/manager/processes/installPlugins.mjs +2 -2
- package/manager/processes/lowdefyBuild.mjs +1 -0
- package/manager/processes/readDotEnv.mjs +2 -4
- package/manager/processes/startNextServer.mjs +0 -1
- package/manager/run.mjs +3 -1
- package/manager/utils/createCustomPluginTypesMap.mjs +5 -0
- package/manager/utils/getNextBin.mjs +36 -0
- package/manager/watchers/envWatcher.mjs +3 -2
- package/manager/watchers/nextBuildWatcher.mjs +8 -2
- package/next.config.js +1 -1
- package/package.json +37 -35
- package/pages/_app.js +4 -2
- package/pages/api/auth/[...nextauth].js +7 -10
- package/pages/api/page/[pageId].js +8 -2
- package/pages/api/request/[pageId]/[requestId].js +8 -7
- package/pages/api/root.js +8 -2
package/lib/App.js
CHANGED
|
@@ -29,9 +29,9 @@ import useRootConfig from './utils/useRootConfig.js';
|
|
|
29
29
|
import actions from '../build/plugins/actions.js';
|
|
30
30
|
import blocks from '../build/plugins/blocks.js';
|
|
31
31
|
import icons from '../build/plugins/icons.js';
|
|
32
|
-
import operators from '../build/plugins/
|
|
32
|
+
import operators from '../build/plugins/operators/client.js';
|
|
33
33
|
|
|
34
|
-
const App = () => {
|
|
34
|
+
const App = ({ auth }) => {
|
|
35
35
|
const router = useRouter();
|
|
36
36
|
const { data: rootConfig } = useRootConfig(router.basePath);
|
|
37
37
|
|
|
@@ -44,6 +44,7 @@ const App = () => {
|
|
|
44
44
|
<Reload basePath={router.basePath}>
|
|
45
45
|
{(resetContext) => (
|
|
46
46
|
<Page
|
|
47
|
+
auth={auth}
|
|
47
48
|
Components={{ Head, Link }}
|
|
48
49
|
config={{
|
|
49
50
|
rootConfig,
|
package/lib/Page.js
CHANGED
|
@@ -20,8 +20,9 @@ import Client from '@lowdefy/client';
|
|
|
20
20
|
import RestartingPage from './RestartingPage.js';
|
|
21
21
|
import usePageConfig from './utils/usePageConfig.js';
|
|
22
22
|
|
|
23
|
-
const Page = ({ Components, config, pageId, resetContext, router, types }) => {
|
|
23
|
+
const Page = ({ auth, Components, config, pageId, resetContext, router, types }) => {
|
|
24
24
|
const { data: pageConfig } = usePageConfig(pageId, router.basePath);
|
|
25
|
+
|
|
25
26
|
if (!pageConfig) {
|
|
26
27
|
router.replace(`/404`);
|
|
27
28
|
return '';
|
|
@@ -31,6 +32,7 @@ const Page = ({ Components, config, pageId, resetContext, router, types }) => {
|
|
|
31
32
|
}
|
|
32
33
|
return (
|
|
33
34
|
<Client
|
|
35
|
+
auth={auth}
|
|
34
36
|
Components={Components}
|
|
35
37
|
config={{
|
|
36
38
|
...config,
|
package/lib/auth/Auth.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
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
|
+
/* eslint-disable react/jsx-props-no-spreading */
|
|
17
|
+
|
|
18
|
+
import React from 'react';
|
|
19
|
+
import AuthConfigured from './AuthConfigured.js';
|
|
20
|
+
import AuthNotConfigured from './AuthNotConfigured.js';
|
|
21
|
+
|
|
22
|
+
import authConfig from '../../build/auth.json';
|
|
23
|
+
|
|
24
|
+
function Auth({ children, session }) {
|
|
25
|
+
if (authConfig.configured === true) {
|
|
26
|
+
return (
|
|
27
|
+
<AuthConfigured session={session} authConfig={authConfig}>
|
|
28
|
+
{(auth) => children(auth)}
|
|
29
|
+
</AuthConfigured>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
return <AuthNotConfigured authConfig={authConfig}>{(auth) => children(auth)}</AuthNotConfigured>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export default Auth;
|
|
@@ -0,0 +1,47 @@
|
|
|
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
|
+
/* eslint-disable react/jsx-props-no-spreading */
|
|
17
|
+
|
|
18
|
+
import React from 'react';
|
|
19
|
+
import { SessionProvider, signIn, signOut, useSession } from 'next-auth/react';
|
|
20
|
+
|
|
21
|
+
function Session({ children }) {
|
|
22
|
+
const { data: session, status } = useSession();
|
|
23
|
+
// If session is passed to SessionProvider from getServerSideProps
|
|
24
|
+
// we won't have a loading state here.
|
|
25
|
+
// But 404 uses getStaticProps so we have this for 404.
|
|
26
|
+
if (status === 'loading') {
|
|
27
|
+
return '';
|
|
28
|
+
}
|
|
29
|
+
return children(session);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function AuthConfigured({ authConfig, children, serverSession }) {
|
|
33
|
+
const auth = { signIn, signOut, authConfig };
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<SessionProvider session={serverSession}>
|
|
37
|
+
<Session>
|
|
38
|
+
{(session) => {
|
|
39
|
+
auth.session = session;
|
|
40
|
+
return children(auth);
|
|
41
|
+
}}
|
|
42
|
+
</Session>
|
|
43
|
+
</SessionProvider>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export default AuthConfigured;
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
/* eslint-disable react/jsx-props-no-spreading */
|
|
17
|
+
|
|
18
|
+
function authNotConfigured() {
|
|
19
|
+
throw new Error('Auth not configured.');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function AuthNotConfigured({ authConfig, children }) {
|
|
23
|
+
const auth = {
|
|
24
|
+
authConfig,
|
|
25
|
+
signIn: authNotConfigured,
|
|
26
|
+
signOut: authNotConfigured,
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
return children(auth);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default AuthNotConfigured;
|
|
@@ -0,0 +1,27 @@
|
|
|
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 { getSession } from 'next-auth/react';
|
|
18
|
+
import authJson from '../../build/auth.json';
|
|
19
|
+
|
|
20
|
+
async function getServerSession(context) {
|
|
21
|
+
if (authJson.configured === true) {
|
|
22
|
+
return await getSession(context);
|
|
23
|
+
}
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export default getServerSession;
|
package/manager/getContext.mjs
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
/* eslint-disable no-console */
|
|
17
17
|
|
|
18
18
|
import path from 'path';
|
|
19
|
-
|
|
19
|
+
|
|
20
20
|
import yargs from 'yargs';
|
|
21
21
|
import { hideBin } from 'yargs/helpers';
|
|
22
22
|
|
|
@@ -30,19 +30,16 @@ import restartServer from './processes/restartServer.mjs';
|
|
|
30
30
|
import shutdownServer from './processes/shutdownServer.mjs';
|
|
31
31
|
import startWatchers from './processes/startWatchers.mjs';
|
|
32
32
|
|
|
33
|
+
import getNextBin from './utils/getNextBin.mjs';
|
|
34
|
+
|
|
33
35
|
const argv = yargs(hideBin(process.argv)).array('watch').array('watchIgnore').argv;
|
|
34
|
-
const require = createRequire(import.meta.url);
|
|
35
36
|
|
|
36
37
|
async function getContext() {
|
|
37
38
|
const env = process.env;
|
|
38
39
|
|
|
39
|
-
const nextPageJson = require('next/package.json');
|
|
40
40
|
const context = {
|
|
41
41
|
bin: {
|
|
42
|
-
next:
|
|
43
|
-
require.resolve('next').replace(nextPageJson.main.substring(1), ''),
|
|
44
|
-
nextPageJson.bin.next
|
|
45
|
-
),
|
|
42
|
+
next: getNextBin(),
|
|
46
43
|
},
|
|
47
44
|
directories: {
|
|
48
45
|
build: path.resolve(process.cwd(), './build'),
|
|
@@ -65,6 +62,8 @@ async function getContext() {
|
|
|
65
62
|
version: env.npm_package_version,
|
|
66
63
|
};
|
|
67
64
|
|
|
65
|
+
context.packageManagerCmd =
|
|
66
|
+
process.platform === 'win32' ? `${context.packageManager}.cmd` : context.packageManager;
|
|
68
67
|
context.initialBuild = initialBuild(context);
|
|
69
68
|
context.installPlugins = installPlugins(context);
|
|
70
69
|
context.lowdefyBuild = lowdefyBuild(context);
|
|
@@ -21,12 +21,12 @@ const args = {
|
|
|
21
21
|
yarn: ['install'],
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
function installPlugins({ packageManager, options }) {
|
|
24
|
+
function installPlugins({ packageManager, packageManagerCmd, options }) {
|
|
25
25
|
return async () => {
|
|
26
26
|
console.log('Installing plugins...');
|
|
27
27
|
await spawnProcess({
|
|
28
28
|
logger: console,
|
|
29
|
-
command:
|
|
29
|
+
command: packageManagerCmd,
|
|
30
30
|
args: args[packageManager],
|
|
31
31
|
silent: !options.verbose,
|
|
32
32
|
});
|
|
@@ -16,12 +16,10 @@
|
|
|
16
16
|
|
|
17
17
|
import path from 'path';
|
|
18
18
|
import dotenv from 'dotenv';
|
|
19
|
-
import { readFile } from '@lowdefy/node-utils';
|
|
20
19
|
|
|
21
20
|
function readDotEnv(context) {
|
|
22
|
-
return
|
|
23
|
-
|
|
24
|
-
context.serverEnv = dotenv.parse(dotEnv || '');
|
|
21
|
+
return () => {
|
|
22
|
+
dotenv.config({ path: path.join(context.directories.config, '.env'), silent: true });
|
|
25
23
|
};
|
|
26
24
|
}
|
|
27
25
|
|
package/manager/run.mjs
CHANGED
|
@@ -80,7 +80,9 @@ async function run() {
|
|
|
80
80
|
try {
|
|
81
81
|
const serverPromise = startServer(context);
|
|
82
82
|
await wait(800);
|
|
83
|
-
|
|
83
|
+
if (process.env.LOWDEFY_SERVER_DEV_OPEN_BROWSER === 'true') {
|
|
84
|
+
opener(`http://localhost:${context.options.port}`);
|
|
85
|
+
}
|
|
84
86
|
await serverPromise;
|
|
85
87
|
} catch (error) {
|
|
86
88
|
console.log(error);
|
|
@@ -33,6 +33,11 @@ async function getPluginDefinitions({ directories }) {
|
|
|
33
33
|
async function createCustomPluginTypesMap({ directories }) {
|
|
34
34
|
const customTypesMap = {
|
|
35
35
|
actions: {},
|
|
36
|
+
auth: {
|
|
37
|
+
callbacks: {},
|
|
38
|
+
events: {},
|
|
39
|
+
providers: {},
|
|
40
|
+
},
|
|
36
41
|
blocks: {},
|
|
37
42
|
connections: {},
|
|
38
43
|
icons: {},
|
|
@@ -0,0 +1,36 @@
|
|
|
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 path from 'path';
|
|
18
|
+
import { createRequire } from 'module';
|
|
19
|
+
|
|
20
|
+
function getNextBin() {
|
|
21
|
+
const require = createRequire(import.meta.url);
|
|
22
|
+
const nextPackageJson = require('next/package.json');
|
|
23
|
+
|
|
24
|
+
const nextPath = require.resolve('next');
|
|
25
|
+
let nextMainFragment = nextPackageJson.main.substring(1);
|
|
26
|
+
let nextBinFragment = nextPackageJson.bin.next;
|
|
27
|
+
|
|
28
|
+
if (process.platform === 'win32') {
|
|
29
|
+
nextMainFragment = nextMainFragment.replaceAll('/', '\\');
|
|
30
|
+
nextBinFragment = nextBinFragment.replaceAll('/', '\\');
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return path.join(nextPath.replace(nextMainFragment, ''), nextBinFragment);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export default getNextBin;
|
|
@@ -21,13 +21,14 @@ import setupWatcher from '../utils/setupWatcher.mjs';
|
|
|
21
21
|
function envWatcher(context) {
|
|
22
22
|
const callback = async () => {
|
|
23
23
|
console.warn('.env file changed.');
|
|
24
|
-
|
|
24
|
+
context.readDotEnv();
|
|
25
|
+
await context.lowdefyBuild();
|
|
25
26
|
context.restartServer();
|
|
26
27
|
};
|
|
27
28
|
return setupWatcher({
|
|
28
29
|
callback,
|
|
29
|
-
watchPaths: [path.join(context.directories.config, '.env')],
|
|
30
30
|
watchDotfiles: true,
|
|
31
|
+
watchPaths: [path.join(context.directories.config, '.env')],
|
|
31
32
|
});
|
|
32
33
|
}
|
|
33
34
|
|
|
@@ -23,13 +23,17 @@ import setupWatcher from '../utils/setupWatcher.mjs';
|
|
|
23
23
|
const hashes = {};
|
|
24
24
|
|
|
25
25
|
const watchedFiles = [
|
|
26
|
+
'build/auth.json',
|
|
26
27
|
'build/config.json',
|
|
27
28
|
'build/plugins/actions.js',
|
|
29
|
+
'build/plugins/auth/callbacks.js',
|
|
30
|
+
'build/plugins/auth/events.js',
|
|
31
|
+
'build/plugins/auth/providers.js',
|
|
28
32
|
'build/plugins/blocks.js',
|
|
29
33
|
'build/plugins/connections.js',
|
|
30
34
|
'build/plugins/icons.js',
|
|
31
|
-
'build/plugins/
|
|
32
|
-
'build/plugins/
|
|
35
|
+
'build/plugins/operators/client.js',
|
|
36
|
+
'build/plugins/operators/server.js',
|
|
33
37
|
'build/plugins/styles.less',
|
|
34
38
|
'package.json',
|
|
35
39
|
];
|
|
@@ -83,8 +87,10 @@ async function nextBuildWatcher(context) {
|
|
|
83
87
|
|
|
84
88
|
return setupWatcher({
|
|
85
89
|
callback,
|
|
90
|
+
watchDotfiles: true,
|
|
86
91
|
watchPaths: [
|
|
87
92
|
path.join(context.directories.build, 'plugins'),
|
|
93
|
+
path.join(context.directories.build, 'auth.json'),
|
|
88
94
|
path.join(context.directories.build, 'config.json'),
|
|
89
95
|
path.join(context.directories.server, 'package.json'),
|
|
90
96
|
],
|
package/next.config.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lowdefy/server-dev",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.13",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
|
@@ -39,48 +39,50 @@
|
|
|
39
39
|
"next": "next"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@lowdefy/actions-core": "4.0.0-alpha.
|
|
43
|
-
"@lowdefy/api": "4.0.0-alpha.
|
|
44
|
-
"@lowdefy/blocks-antd": "4.0.0-alpha.
|
|
45
|
-
"@lowdefy/blocks-basic": "4.0.0-alpha.
|
|
46
|
-
"@lowdefy/blocks-color-selectors": "4.0.0-alpha.
|
|
47
|
-
"@lowdefy/blocks-echarts": "4.0.0-alpha.
|
|
48
|
-
"@lowdefy/blocks-loaders": "4.0.0-alpha.
|
|
49
|
-
"@lowdefy/blocks-markdown": "4.0.0-alpha.
|
|
50
|
-
"@lowdefy/build": "4.0.0-alpha.
|
|
51
|
-
"@lowdefy/client": "4.0.0-alpha.
|
|
52
|
-
"@lowdefy/connection-axios-http": "4.0.0-alpha.
|
|
53
|
-
"@lowdefy/engine": "4.0.0-alpha.
|
|
54
|
-
"@lowdefy/helpers": "4.0.0-alpha.
|
|
55
|
-
"@lowdefy/layout": "4.0.0-alpha.
|
|
56
|
-
"@lowdefy/node-utils": "4.0.0-alpha.
|
|
57
|
-
"@lowdefy/operators-change-case": "4.0.0-alpha.
|
|
58
|
-
"@lowdefy/operators-diff": "4.0.0-alpha.
|
|
59
|
-
"@lowdefy/operators-js": "4.0.0-alpha.
|
|
60
|
-
"@lowdefy/operators-mql": "4.0.0-alpha.
|
|
61
|
-
"@lowdefy/operators-nunjucks": "4.0.0-alpha.
|
|
62
|
-
"@lowdefy/operators-uuid": "4.0.0-alpha.
|
|
63
|
-
"@lowdefy/operators-yaml": "4.0.0-alpha.
|
|
42
|
+
"@lowdefy/actions-core": "4.0.0-alpha.13",
|
|
43
|
+
"@lowdefy/api": "4.0.0-alpha.13",
|
|
44
|
+
"@lowdefy/blocks-antd": "4.0.0-alpha.13",
|
|
45
|
+
"@lowdefy/blocks-basic": "4.0.0-alpha.13",
|
|
46
|
+
"@lowdefy/blocks-color-selectors": "4.0.0-alpha.13",
|
|
47
|
+
"@lowdefy/blocks-echarts": "4.0.0-alpha.13",
|
|
48
|
+
"@lowdefy/blocks-loaders": "4.0.0-alpha.13",
|
|
49
|
+
"@lowdefy/blocks-markdown": "4.0.0-alpha.13",
|
|
50
|
+
"@lowdefy/build": "4.0.0-alpha.13",
|
|
51
|
+
"@lowdefy/client": "4.0.0-alpha.13",
|
|
52
|
+
"@lowdefy/connection-axios-http": "4.0.0-alpha.13",
|
|
53
|
+
"@lowdefy/engine": "4.0.0-alpha.13",
|
|
54
|
+
"@lowdefy/helpers": "4.0.0-alpha.13",
|
|
55
|
+
"@lowdefy/layout": "4.0.0-alpha.13",
|
|
56
|
+
"@lowdefy/node-utils": "4.0.0-alpha.13",
|
|
57
|
+
"@lowdefy/operators-change-case": "4.0.0-alpha.13",
|
|
58
|
+
"@lowdefy/operators-diff": "4.0.0-alpha.13",
|
|
59
|
+
"@lowdefy/operators-js": "4.0.0-alpha.13",
|
|
60
|
+
"@lowdefy/operators-mql": "4.0.0-alpha.13",
|
|
61
|
+
"@lowdefy/operators-nunjucks": "4.0.0-alpha.13",
|
|
62
|
+
"@lowdefy/operators-uuid": "4.0.0-alpha.13",
|
|
63
|
+
"@lowdefy/operators-yaml": "4.0.0-alpha.13",
|
|
64
|
+
"@lowdefy/plugin-next-auth": "4.0.0-alpha.13",
|
|
64
65
|
"chokidar": "3.5.3",
|
|
65
|
-
"dotenv": "
|
|
66
|
-
"next": "12.
|
|
67
|
-
"next-auth": "4.
|
|
66
|
+
"dotenv": "16.0.1",
|
|
67
|
+
"next": "12.1.6",
|
|
68
|
+
"next-auth": "4.3.4",
|
|
68
69
|
"opener": "1.5.2",
|
|
69
|
-
"
|
|
70
|
-
"react
|
|
70
|
+
"process": "0.11.10",
|
|
71
|
+
"react": "18.1.0",
|
|
72
|
+
"react-dom": "18.1.0",
|
|
71
73
|
"react-icons": "4.3.1",
|
|
72
|
-
"swr": "1.
|
|
73
|
-
"yaml": "2.
|
|
74
|
-
"yargs": "17.
|
|
74
|
+
"swr": "1.3.0",
|
|
75
|
+
"yaml": "2.1.1",
|
|
76
|
+
"yargs": "17.5.1"
|
|
75
77
|
},
|
|
76
78
|
"devDependencies": {
|
|
77
|
-
"@next/eslint-plugin-next": "12.
|
|
79
|
+
"@next/eslint-plugin-next": "12.1.6",
|
|
78
80
|
"less": "4.1.2",
|
|
79
|
-
"less-loader": "
|
|
80
|
-
"next-with-less": "2.0.
|
|
81
|
+
"less-loader": "11.0.0",
|
|
82
|
+
"next-with-less": "2.0.5"
|
|
81
83
|
},
|
|
82
84
|
"publishConfig": {
|
|
83
85
|
"access": "public"
|
|
84
86
|
},
|
|
85
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "e99b4b6c1f59804982fc148c0fe39dcf13b35d77"
|
|
86
88
|
}
|
package/pages/_app.js
CHANGED
|
@@ -17,13 +17,15 @@
|
|
|
17
17
|
import React, { Suspense } from 'react';
|
|
18
18
|
import dynamic from 'next/dynamic';
|
|
19
19
|
|
|
20
|
+
import Auth from '../lib/auth/Auth.js';
|
|
21
|
+
|
|
20
22
|
// Must be in _app due to next specifications.
|
|
21
23
|
import '../build/plugins/styles.less';
|
|
22
24
|
|
|
23
|
-
function App({ Component
|
|
25
|
+
function App({ Component }) {
|
|
24
26
|
return (
|
|
25
27
|
<Suspense fallback="">
|
|
26
|
-
<Component {
|
|
28
|
+
<Auth>{(auth) => <Component auth={auth} />}</Auth>
|
|
27
29
|
</Suspense>
|
|
28
30
|
);
|
|
29
31
|
}
|
|
@@ -15,14 +15,11 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import NextAuth from 'next-auth';
|
|
18
|
-
import
|
|
18
|
+
import { getNextAuthConfig } from '@lowdefy/api';
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}),
|
|
27
|
-
],
|
|
28
|
-
});
|
|
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 } }));
|
|
@@ -15,11 +15,17 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import { createApiContext, getPageConfig } from '@lowdefy/api';
|
|
18
|
+
import getServerSession from '../../../lib/auth/getServerSession.js';
|
|
18
19
|
|
|
19
20
|
export default async function handler(req, res) {
|
|
21
|
+
const session = await getServerSession({ req });
|
|
22
|
+
const apiContext = await createApiContext({
|
|
23
|
+
buildDirectory: './build',
|
|
24
|
+
logger: console,
|
|
25
|
+
session,
|
|
26
|
+
});
|
|
27
|
+
|
|
20
28
|
const { pageId } = req.query;
|
|
21
|
-
// TODO: get the right api context options
|
|
22
|
-
const apiContext = await createApiContext({ buildDirectory: './build' });
|
|
23
29
|
const pageConfig = await getPageConfig(apiContext, { pageId });
|
|
24
30
|
if (pageConfig === null) {
|
|
25
31
|
res.status(404).send('Page not found.');
|
|
@@ -16,28 +16,29 @@
|
|
|
16
16
|
|
|
17
17
|
import { callRequest, createApiContext } from '@lowdefy/api';
|
|
18
18
|
import { getSecretsFromEnv } from '@lowdefy/node-utils';
|
|
19
|
+
|
|
19
20
|
import connections from '../../../../build/plugins/connections.js';
|
|
20
|
-
import
|
|
21
|
+
import getServerSession from '../../../../lib/auth/getServerSession.js';
|
|
22
|
+
import operators from '../../../../build/plugins/operators/server.js';
|
|
21
23
|
|
|
22
24
|
export default async function handler(req, res) {
|
|
23
25
|
try {
|
|
24
26
|
if (req.method !== 'POST') {
|
|
25
27
|
throw new Error('Only POST requests are supported.');
|
|
26
28
|
}
|
|
27
|
-
|
|
28
|
-
// TODO: configure build directory?
|
|
29
|
+
const session = await getServerSession({ req });
|
|
29
30
|
const apiContext = await createApiContext({
|
|
30
31
|
buildDirectory: './build',
|
|
31
32
|
connections,
|
|
32
|
-
// TODO: use a logger like pino
|
|
33
33
|
logger: console,
|
|
34
34
|
operators,
|
|
35
35
|
secrets: getSecretsFromEnv(),
|
|
36
|
+
session,
|
|
36
37
|
});
|
|
37
|
-
const { pageId, requestId } = req.query;
|
|
38
|
-
const { payload } = req.body;
|
|
39
38
|
|
|
40
|
-
const
|
|
39
|
+
const { blockId, pageId, requestId } = req.query;
|
|
40
|
+
const { payload } = req.body;
|
|
41
|
+
const response = await callRequest(apiContext, { blockId, pageId, payload, requestId });
|
|
41
42
|
res.status(200).json(response);
|
|
42
43
|
} catch (error) {
|
|
43
44
|
res.status(500).json({ name: error.name, message: error.message });
|
package/pages/api/root.js
CHANGED
|
@@ -16,9 +16,15 @@
|
|
|
16
16
|
|
|
17
17
|
import { createApiContext, getRootConfig } from '@lowdefy/api';
|
|
18
18
|
|
|
19
|
+
import getServerSession from '../../lib/auth/getServerSession.js';
|
|
20
|
+
|
|
19
21
|
export default async function handler(req, res) {
|
|
20
|
-
|
|
21
|
-
const apiContext = await createApiContext({
|
|
22
|
+
const session = await getServerSession({ req });
|
|
23
|
+
const apiContext = await createApiContext({
|
|
24
|
+
buildDirectory: './build',
|
|
25
|
+
logger: console,
|
|
26
|
+
session,
|
|
27
|
+
});
|
|
22
28
|
const rootConfig = await getRootConfig(apiContext);
|
|
23
29
|
|
|
24
30
|
res.status(200).json(rootConfig);
|