@lowdefy/server 4.0.0-alpha.10 → 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/lib/Page.js +13 -1
- package/lowdefy/createCustomPluginTypesMap.mjs +5 -0
- package/package.json +15 -14
- package/pages/404.js +0 -1
- package/pages/[pageId].js +8 -2
- package/pages/_app.js +8 -2
- package/pages/api/auth/[...nextauth].js +7 -10
- package/pages/api/request/[pageId]/[requestId].js +7 -5
- package/pages/index.js +9 -3
package/lib/Page.js
CHANGED
|
@@ -20,22 +20,34 @@ import { useRouter } from 'next/router';
|
|
|
20
20
|
import Client from '@lowdefy/client';
|
|
21
21
|
import Head from 'next/head';
|
|
22
22
|
import Link from 'next/link';
|
|
23
|
+
import { signIn, signOut, useSession } from 'next-auth/react';
|
|
23
24
|
|
|
24
25
|
import actions from '../build/plugins/actions.js';
|
|
25
26
|
import blocks from '../build/plugins/blocks.js';
|
|
26
27
|
import icons from '../build/plugins/icons.js';
|
|
27
|
-
import operators from '../build/plugins/
|
|
28
|
+
import operators from '../build/plugins/operators/client.js';
|
|
28
29
|
|
|
29
30
|
const Page = ({ pageConfig, rootConfig }) => {
|
|
30
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
|
+
|
|
31
41
|
return (
|
|
32
42
|
<Client
|
|
43
|
+
auth={{ signIn, signOut }}
|
|
33
44
|
Components={{ Head, Link }}
|
|
34
45
|
config={{
|
|
35
46
|
pageConfig,
|
|
36
47
|
rootConfig,
|
|
37
48
|
}}
|
|
38
49
|
router={router}
|
|
50
|
+
session={session}
|
|
39
51
|
types={{
|
|
40
52
|
actions,
|
|
41
53
|
blocks,
|
|
@@ -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: {},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lowdefy/server",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.11",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
|
@@ -42,25 +42,26 @@
|
|
|
42
42
|
"next": "next"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@lowdefy/actions-core": "4.0.0-alpha.
|
|
46
|
-
"@lowdefy/api": "4.0.0-alpha.
|
|
47
|
-
"@lowdefy/blocks-antd": "4.0.0-alpha.
|
|
48
|
-
"@lowdefy/blocks-basic": "4.0.0-alpha.
|
|
49
|
-
"@lowdefy/blocks-loaders": "4.0.0-alpha.
|
|
50
|
-
"@lowdefy/client": "4.0.0-alpha.
|
|
51
|
-
"@lowdefy/helpers": "4.0.0-alpha.
|
|
52
|
-
"@lowdefy/layout": "4.0.0-alpha.
|
|
53
|
-
"@lowdefy/node-utils": "4.0.0-alpha.
|
|
54
|
-
"@lowdefy/operators-js": "4.0.0-alpha.
|
|
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",
|
|
55
56
|
"next": "12.0.10",
|
|
56
|
-
"next-auth": "4.
|
|
57
|
+
"next-auth": "4.3.4",
|
|
57
58
|
"process": "0.11.10",
|
|
58
59
|
"react": "17.0.2",
|
|
59
60
|
"react-dom": "17.0.2",
|
|
60
61
|
"react-icons": "4.3.1"
|
|
61
62
|
},
|
|
62
63
|
"devDependencies": {
|
|
63
|
-
"@lowdefy/build": "4.0.0-alpha.
|
|
64
|
+
"@lowdefy/build": "4.0.0-alpha.11",
|
|
64
65
|
"@next/eslint-plugin-next": "12.0.10",
|
|
65
66
|
"less": "4.1.2",
|
|
66
67
|
"less-loader": "10.2.0",
|
|
@@ -71,5 +72,5 @@
|
|
|
71
72
|
"publishConfig": {
|
|
72
73
|
"access": "public"
|
|
73
74
|
},
|
|
74
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "810fb2d8cb9ee8b0586b55fbbf26a5a5a0da3b2a"
|
|
75
76
|
}
|
package/pages/404.js
CHANGED
|
@@ -19,7 +19,6 @@ import { createApiContext, getPageConfig, getRootConfig } from '@lowdefy/api';
|
|
|
19
19
|
import Page from '../lib/Page.js';
|
|
20
20
|
|
|
21
21
|
export async function getStaticProps() {
|
|
22
|
-
// TODO: get the right api context options
|
|
23
22
|
const apiContext = await createApiContext({ buildDirectory: './build' });
|
|
24
23
|
|
|
25
24
|
const [rootConfig, pageConfig] = await Promise.all([
|
package/pages/[pageId].js
CHANGED
|
@@ -15,13 +15,18 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import { createApiContext, getPageConfig, getRootConfig } from '@lowdefy/api';
|
|
18
|
+
import { getSession } from 'next-auth/react';
|
|
18
19
|
|
|
19
20
|
import Page from '../lib/Page.js';
|
|
20
21
|
|
|
21
22
|
export async function getServerSideProps(context) {
|
|
22
23
|
const { pageId } = context.params;
|
|
23
|
-
|
|
24
|
-
const apiContext = await createApiContext({
|
|
24
|
+
const session = await getSession(context);
|
|
25
|
+
const apiContext = await createApiContext({
|
|
26
|
+
buildDirectory: './build',
|
|
27
|
+
logger: console,
|
|
28
|
+
session,
|
|
29
|
+
});
|
|
25
30
|
|
|
26
31
|
const [rootConfig, pageConfig] = await Promise.all([
|
|
27
32
|
getRootConfig(apiContext),
|
|
@@ -41,6 +46,7 @@ export async function getServerSideProps(context) {
|
|
|
41
46
|
props: {
|
|
42
47
|
pageConfig,
|
|
43
48
|
rootConfig,
|
|
49
|
+
session,
|
|
44
50
|
},
|
|
45
51
|
};
|
|
46
52
|
}
|
package/pages/_app.js
CHANGED
|
@@ -16,12 +16,18 @@
|
|
|
16
16
|
|
|
17
17
|
import React from 'react';
|
|
18
18
|
import dynamic from 'next/dynamic';
|
|
19
|
+
import { SessionProvider } from 'next-auth/react';
|
|
19
20
|
|
|
20
21
|
// Must be in _app due to next specifications.
|
|
21
22
|
import '../build/plugins/styles.less';
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
// TODO: SessionProvider requires basebath
|
|
25
|
+
function App({ Component, pageProps: { session, ...pageProps } }) {
|
|
26
|
+
return (
|
|
27
|
+
<SessionProvider session={session}>
|
|
28
|
+
<Component {...pageProps} />
|
|
29
|
+
</SessionProvider>
|
|
30
|
+
);
|
|
25
31
|
}
|
|
26
32
|
|
|
27
33
|
const DynamicApp = dynamic(() => Promise.resolve(App), {
|
|
@@ -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 } }));
|
|
@@ -16,26 +16,28 @@
|
|
|
16
16
|
|
|
17
17
|
import { callRequest, createApiContext } from '@lowdefy/api';
|
|
18
18
|
import { getSecretsFromEnv } from '@lowdefy/node-utils';
|
|
19
|
+
import { getSession } from 'next-auth/react';
|
|
19
20
|
import connections from '../../../../build/plugins/connections.js';
|
|
20
|
-
import operators from '../../../../build/plugins/
|
|
21
|
+
import operators from '../../../../build/plugins/operators/server.js';
|
|
21
22
|
|
|
22
23
|
export default async function handler(req, res) {
|
|
23
24
|
try {
|
|
24
25
|
if (req.method !== 'POST') {
|
|
25
26
|
throw new Error('Only POST requests are supported.');
|
|
26
27
|
}
|
|
27
|
-
|
|
28
|
+
const session = await getSession({ req });
|
|
28
29
|
const apiContext = await createApiContext({
|
|
29
30
|
buildDirectory: './build',
|
|
30
31
|
connections,
|
|
31
|
-
//
|
|
32
|
-
logger:
|
|
32
|
+
// logger: console,
|
|
33
|
+
logger: { debug: () => {} },
|
|
33
34
|
operators,
|
|
34
35
|
secrets: getSecretsFromEnv(),
|
|
36
|
+
session,
|
|
35
37
|
});
|
|
38
|
+
|
|
36
39
|
const { pageId, requestId } = req.query;
|
|
37
40
|
const { payload } = req.body;
|
|
38
|
-
|
|
39
41
|
const response = await callRequest(apiContext, { pageId, payload, requestId });
|
|
40
42
|
res.status(200).json(response);
|
|
41
43
|
} catch (error) {
|
package/pages/index.js
CHANGED
|
@@ -15,12 +15,17 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import { createApiContext, getPageConfig, getRootConfig } from '@lowdefy/api';
|
|
18
|
+
import { getSession } from 'next-auth/react';
|
|
18
19
|
|
|
19
20
|
import Page from '../lib/Page.js';
|
|
20
21
|
|
|
21
|
-
export async function getServerSideProps() {
|
|
22
|
-
|
|
23
|
-
const apiContext = await createApiContext({
|
|
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
|
+
});
|
|
24
29
|
const rootConfig = await getRootConfig(apiContext);
|
|
25
30
|
const { home } = rootConfig;
|
|
26
31
|
if (home.configured === false) {
|
|
@@ -44,6 +49,7 @@ export async function getServerSideProps() {
|
|
|
44
49
|
props: {
|
|
45
50
|
pageConfig,
|
|
46
51
|
rootConfig,
|
|
52
|
+
session,
|
|
47
53
|
},
|
|
48
54
|
};
|
|
49
55
|
}
|