Merge remote-tracking branch 'origin/v4' into dev-server-reload

This commit is contained in:
Sam Tolmay 2022-01-20 11:23:25 +02:00
commit 3243383fbd
No known key found for this signature in database
GPG Key ID: D004126FCD1A6DF0
10 changed files with 72 additions and 50 deletions

View File

@ -28,9 +28,6 @@ async function validateApp({ components }) {
if (type.isNone(components.app.html)) {
components.app.html = {};
}
if (type.isNone(components.app.style)) {
components.app.style = {};
}
if (type.isNone(components.app.html.appendBody)) {
components.app.html.appendBody = '';
}

View File

@ -28,7 +28,6 @@ test('validateApp no app defined', async () => {
appendBody: '',
appendHead: '',
},
style: {},
},
});
});
@ -42,7 +41,6 @@ test('validateApp empty app object', async () => {
appendBody: '',
appendHead: '',
},
style: {},
},
});
});
@ -56,7 +54,6 @@ test('validateApp empty html', async () => {
appendBody: '',
appendHead: '',
},
style: {},
},
});
});
@ -77,33 +74,6 @@ test('validateApp appendHead and appendHead', async () => {
appendBody: 'body',
appendHead: 'head',
},
style: {},
},
});
});
test('validateApp style', async () => {
const components = {
app: {
style: {
lessVariables: {
'primary-color': '#FF00FF',
},
},
},
};
const result = await validateApp({ components, context });
expect(result).toEqual({
app: {
html: {
appendBody: '',
appendHead: '',
},
style: {
lessVariables: {
'primary-color': '#FF00FF',
},
},
},
});
});

View File

@ -36,6 +36,9 @@ async function validateConfig({ components }) {
if (type.isNone(components.config.auth.pages.roles)) {
components.config.auth.pages.roles = {};
}
if (type.isNone(components.config.theme)) {
components.config.theme = {};
}
validate({
schema: lowdefySchema.definitions.authConfig,
data: components.config.auth,

View File

@ -19,6 +19,48 @@ import testContext from '../test/testContext.js';
const context = testContext();
test('validateConfig no config defined', async () => {
const components = {};
const result = await validateConfig({ components, context });
expect(result).toEqual({
config: {
auth: {
pages: {
roles: {},
},
},
theme: {},
},
});
});
test('validate config theme', async () => {
const components = {
config: {
theme: {
lessVariables: {
'primary-color': '#FF00FF',
},
},
},
};
const result = await validateConfig({ components, context });
expect(result).toEqual({
config: {
auth: {
pages: {
roles: {},
},
},
theme: {
lessVariables: {
'primary-color': '#FF00FF',
},
},
},
});
});
test('validateConfig config not an object', async () => {
const components = {
config: 'config',

View File

@ -63,12 +63,6 @@ export default {
},
},
},
style: {
type: 'object',
errorMessage: {
type: 'App "app.style" should be an object.',
},
},
},
},
authConfig: {
@ -601,6 +595,9 @@ export default {
},
additionalProperties: false,
properties: {
auth: {
$ref: '#/definitions/authConfig',
},
homePageId: {
type: 'string',
description:
@ -609,8 +606,20 @@ export default {
type: 'App "config.homePageId" should be a string.',
},
},
auth: {
$ref: '#/definitions/authConfig',
theme: {
type: 'object',
errorMessage: {
type: 'App "config.theme" should be an object.',
},
properties: {
lessVariables: {
type: 'object',
description: 'App theme less variables.',
errorMessage: {
type: 'App "config.theme.lessVariables" should be an object.',
},
},
},
},
},
},

View File

@ -1,10 +1,10 @@
const withLess = require('next-with-less');
const appConfig = require('./build/app.json');
const lowdefyConfig = require('./build/config.json');
module.exports = withLess({
lessLoaderOptions: {
lessOptions: {
modifyVars: appConfig.style.lessVariables,
modifyVars: lowdefyConfig.theme.lessVariables,
},
},
// reactStrictMode: true,

View File

@ -15,6 +15,7 @@
*/
import { callRequest, createApiContext } from '@lowdefy/api';
import { getSecretsFromEnv } from '@lowdefy/node-utils';
import connections from '../../../../../build/plugins/connections.js';
import operators from '../../../../../build/plugins/operatorsServer.js';
@ -30,8 +31,7 @@ export default async function handler(req, res) {
// TODO: use a logger like pino
logger: console,
operators,
// TODO: get secrets
secrets: {},
secrets: getSecretsFromEnv(),
});
const { pageId, requestId } = req.query;
const { payload } = req.body;

View File

@ -1,10 +1,10 @@
const withLess = require('next-with-less');
const appConfig = require('./build/app.json');
const lowdefyConfig = require('./build/config.json');
module.exports = withLess({
lessLoaderOptions: {
lessOptions: {
modifyVars: appConfig.style.lessVariables,
modifyVars: lowdefyConfig.theme.lessVariables,
},
},
reactStrictMode: true,

View File

@ -46,6 +46,7 @@
"@lowdefy/engine": "4.0.0-alpha.5",
"@lowdefy/helpers": "4.0.0-alpha.5",
"@lowdefy/layout": "4.0.0-alpha.5",
"@lowdefy/node-utils": "4.0.0-alpha.5",
"@lowdefy/operators-js": "4.0.0-alpha.5",
"next": "12.0.3",
"next-auth": "4.0.0-beta.6",
@ -64,4 +65,4 @@
"publishConfig": {
"access": "public"
}
}
}

View File

@ -15,6 +15,7 @@
*/
import { callRequest, createApiContext } from '@lowdefy/api';
import { getSecretsFromEnv } from '@lowdefy/node-utils';
import connections from '../../../../../build/plugins/connections.js';
import operators from '../../../../../build/plugins/operatorsServer.js';
@ -30,8 +31,7 @@ export default async function handler(req, res) {
// TODO: use a logger like pino
logger: console,
operators,
// TODO: get secrets
secrets: {},
secrets: getSecretsFromEnv(),
});
const { pageId, requestId } = req.query;
const { payload } = req.body;