mirror of
https://github.com/lowdefy/lowdefy.git
synced 2025-03-19 15:01:06 +08:00
Merge remote-tracking branch 'origin/v4' into dev-server-reload
This commit is contained in:
commit
3243383fbd
@ -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 = '';
|
||||
}
|
||||
|
@ -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',
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
|
@ -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,
|
||||
|
@ -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',
|
||||
|
@ -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.',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
|
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user