@lowdefy/server-e2e 5.2.0 → 5.4.0
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/build/appMeta.js +19 -0
- package/lib/build/theme.js +19 -0
- package/lib/server/apiWrapper.js +2 -0
- package/lib/server/serverSidePropsWrapper.js +2 -0
- package/lowdefy/build.mjs +3 -8
- package/lowdefy/createCustomPluginTypesMap.mjs +6 -1
- package/lowdefy/createCustomPluginTypesMap.test.mjs +115 -0
- package/next.config.js +7 -21
- package/package.json +28 -23
- package/package.original.json +27 -22
- package/pages/404.js +2 -0
- package/pages/{[pageId].js → [[...pageId]].js} +35 -1
- package/pages/_app.js +45 -27
- package/pages/_document.js +41 -0
- package/pages/api/client-error.js +24 -2
- package/pages/api/endpoints/{[endpointId].js → [...endpointId].js} +1 -1
- package/pages/api/request/{[pageId]/[requestId].js → [...path].js} +8 -2
- package/pages/api/usage.js +1 -2
- package/pages/index.js +0 -58
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2026 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
|
+
import { serializer } from '@lowdefy/helpers';
|
|
17
|
+
import raw from '../../build/appMeta.json';
|
|
18
|
+
|
|
19
|
+
export default serializer.deserialize(raw);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2026 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
|
+
import { serializer } from '@lowdefy/helpers';
|
|
17
|
+
import raw from '../../build/theme.json';
|
|
18
|
+
|
|
19
|
+
export default serializer.deserialize(raw);
|
package/lib/server/apiWrapper.js
CHANGED
|
@@ -19,6 +19,7 @@ import { createApiContext } from '@lowdefy/api';
|
|
|
19
19
|
import { serializer } from '@lowdefy/helpers';
|
|
20
20
|
import { v4 as uuid } from 'uuid';
|
|
21
21
|
|
|
22
|
+
import appMeta from '../build/appMeta.js';
|
|
22
23
|
import config from '../build/config.js';
|
|
23
24
|
import connections from '../../build/plugins/connections.js';
|
|
24
25
|
import createLogger from './log/createLogger.js';
|
|
@@ -37,6 +38,7 @@ function apiWrapper(handler) {
|
|
|
37
38
|
const context = {
|
|
38
39
|
// Important to give absolute path so Next can trace build files
|
|
39
40
|
rid: uuid(),
|
|
41
|
+
appMeta,
|
|
40
42
|
buildDirectory: path.join(process.cwd(), 'build'),
|
|
41
43
|
configDirectory: process.env.LOWDEFY_DIRECTORY_CONFIG || process.cwd(),
|
|
42
44
|
config,
|
|
@@ -18,6 +18,7 @@ import path from 'path';
|
|
|
18
18
|
import { createApiContext } from '@lowdefy/api';
|
|
19
19
|
import { v4 as uuid } from 'uuid';
|
|
20
20
|
|
|
21
|
+
import appMeta from '../build/appMeta.js';
|
|
21
22
|
import config from '../build/config.js';
|
|
22
23
|
import createLogger from './log/createLogger.js';
|
|
23
24
|
import fileCache from './fileCache.js';
|
|
@@ -30,6 +31,7 @@ function serverSidePropsWrapper(handler) {
|
|
|
30
31
|
const context = {
|
|
31
32
|
// Important to give absolute path so Next can trace build files
|
|
32
33
|
rid: uuid(),
|
|
34
|
+
appMeta,
|
|
33
35
|
buildDirectory: path.join(process.cwd(), 'build'),
|
|
34
36
|
configDirectory: process.env.LOWDEFY_DIRECTORY_CONFIG || process.cwd(),
|
|
35
37
|
config,
|
package/lowdefy/build.mjs
CHANGED
|
@@ -20,6 +20,7 @@ import yargs from 'yargs';
|
|
|
20
20
|
import { hideBin } from 'yargs/helpers';
|
|
21
21
|
|
|
22
22
|
import build from '@lowdefy/build';
|
|
23
|
+
import { BuildError } from '@lowdefy/errors';
|
|
23
24
|
import { createNodeLogger } from '@lowdefy/logger/node';
|
|
24
25
|
import createCustomPluginTypesMap from './createCustomPluginTypesMap.mjs';
|
|
25
26
|
|
|
@@ -39,15 +40,10 @@ async function run() {
|
|
|
39
40
|
|
|
40
41
|
const customTypesMap = await createCustomPluginTypesMap({ directories });
|
|
41
42
|
|
|
42
|
-
|
|
43
|
-
logger = createNodeLogger({
|
|
43
|
+
const logger = createNodeLogger({
|
|
44
44
|
name: 'lowdefy_build',
|
|
45
45
|
level: process.env.LOWDEFY_LOG_LEVEL ?? 'info',
|
|
46
46
|
base: { pid: undefined, hostname: undefined },
|
|
47
|
-
mixin: (context, level) => ({
|
|
48
|
-
...context,
|
|
49
|
-
print: context.print ?? logger.levels.labels[level],
|
|
50
|
-
}),
|
|
51
47
|
});
|
|
52
48
|
|
|
53
49
|
await build({
|
|
@@ -59,8 +55,7 @@ async function run() {
|
|
|
59
55
|
}
|
|
60
56
|
|
|
61
57
|
run().catch((error) => {
|
|
62
|
-
|
|
63
|
-
if (error.isFormatted || error.hideStack) {
|
|
58
|
+
if (error instanceof BuildError) {
|
|
64
59
|
console.error(error.message);
|
|
65
60
|
process.exit(1);
|
|
66
61
|
}
|
|
@@ -29,6 +29,9 @@ async function getPluginDefinitions({ directories }) {
|
|
|
29
29
|
if (!lowdefyYaml) {
|
|
30
30
|
lowdefyYaml = await readFile(path.join(directories.config, 'lowdefy.yml'));
|
|
31
31
|
}
|
|
32
|
+
if (!lowdefyYaml) {
|
|
33
|
+
return [];
|
|
34
|
+
}
|
|
32
35
|
const lowdefy = YAML.parse(lowdefyYaml);
|
|
33
36
|
return get(lowdefy, 'plugins', { default: [] });
|
|
34
37
|
}
|
|
@@ -36,12 +39,14 @@ async function getPluginDefinitions({ directories }) {
|
|
|
36
39
|
async function createCustomPluginTypesMap({ directories }) {
|
|
37
40
|
const customTypesMap = {
|
|
38
41
|
actions: {},
|
|
42
|
+
agents: {},
|
|
39
43
|
auth: {
|
|
40
44
|
adapters: {},
|
|
41
45
|
callbacks: {},
|
|
42
46
|
events: {},
|
|
43
47
|
providers: {},
|
|
44
48
|
},
|
|
49
|
+
blockMetas: {},
|
|
45
50
|
blocks: {},
|
|
46
51
|
connections: {},
|
|
47
52
|
icons: {},
|
|
@@ -57,7 +62,7 @@ async function createCustomPluginTypesMap({ directories }) {
|
|
|
57
62
|
for (const plugin of pluginDefinitions) {
|
|
58
63
|
const types = require(`${plugin.name}/types`);
|
|
59
64
|
createPluginTypesMap({
|
|
60
|
-
packageTypes: types,
|
|
65
|
+
packageTypes: types.default ?? types,
|
|
61
66
|
typesMap: customTypesMap,
|
|
62
67
|
packageName: plugin.name,
|
|
63
68
|
version: plugin.version,
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2026 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 { jest } from '@jest/globals';
|
|
18
|
+
|
|
19
|
+
const pluginYaml = `
|
|
20
|
+
plugins:
|
|
21
|
+
- name: fake-plugin
|
|
22
|
+
version: 1.0.0
|
|
23
|
+
`;
|
|
24
|
+
|
|
25
|
+
const pluginTypesEsm = {
|
|
26
|
+
__esModule: true,
|
|
27
|
+
default: {
|
|
28
|
+
actions: ['FakeAction'],
|
|
29
|
+
blocks: ['FakeBlock'],
|
|
30
|
+
blockMetas: {
|
|
31
|
+
FakeBlock: { category: 'display' },
|
|
32
|
+
},
|
|
33
|
+
operators: {
|
|
34
|
+
client: ['_fakeClientOp'],
|
|
35
|
+
server: ['_fakeServerOp'],
|
|
36
|
+
},
|
|
37
|
+
requests: ['FakeRequest'],
|
|
38
|
+
icons: {
|
|
39
|
+
FakeBlock: 'icon-name',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
jest.unstable_mockModule('@lowdefy/node-utils', () => ({
|
|
45
|
+
cleanDirectory: jest.fn(),
|
|
46
|
+
copyFileOrDirectory: jest.fn(),
|
|
47
|
+
getFileExtension: jest.fn(),
|
|
48
|
+
getFileSubExtension: jest.fn(),
|
|
49
|
+
getSecretsFromEnv: jest.fn(),
|
|
50
|
+
spawnProcess: jest.fn(),
|
|
51
|
+
readFile: jest.fn(async () => pluginYaml),
|
|
52
|
+
writeFile: jest.fn(),
|
|
53
|
+
}));
|
|
54
|
+
|
|
55
|
+
jest.unstable_mockModule('node:module', () => ({
|
|
56
|
+
createRequire: () => (moduleName) => {
|
|
57
|
+
if (moduleName === 'fake-plugin/types') {
|
|
58
|
+
return pluginTypesEsm;
|
|
59
|
+
}
|
|
60
|
+
throw new Error(`Unexpected require: ${moduleName}`);
|
|
61
|
+
},
|
|
62
|
+
}));
|
|
63
|
+
|
|
64
|
+
beforeEach(() => {
|
|
65
|
+
jest.clearAllMocks();
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
test('unwraps ESM default export when loading plugin types', async () => {
|
|
69
|
+
const { default: createCustomPluginTypesMap } = await import('./createCustomPluginTypesMap.mjs');
|
|
70
|
+
const result = await createCustomPluginTypesMap({ directories: { config: '/config' } });
|
|
71
|
+
expect(result.actions).toEqual({
|
|
72
|
+
FakeAction: { package: 'fake-plugin', originalTypeName: 'FakeAction', version: '1.0.0' },
|
|
73
|
+
});
|
|
74
|
+
expect(result.blocks).toEqual({
|
|
75
|
+
FakeBlock: { package: 'fake-plugin', originalTypeName: 'FakeBlock', version: '1.0.0' },
|
|
76
|
+
});
|
|
77
|
+
expect(result.operators.client).toEqual({
|
|
78
|
+
_fakeClientOp: { package: 'fake-plugin', originalTypeName: '_fakeClientOp', version: '1.0.0' },
|
|
79
|
+
});
|
|
80
|
+
expect(result.operators.server).toEqual({
|
|
81
|
+
_fakeServerOp: { package: 'fake-plugin', originalTypeName: '_fakeServerOp', version: '1.0.0' },
|
|
82
|
+
});
|
|
83
|
+
expect(result.requests).toEqual({
|
|
84
|
+
FakeRequest: { package: 'fake-plugin', originalTypeName: 'FakeRequest', version: '1.0.0' },
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
test('populates blockMetas from plugin types', async () => {
|
|
89
|
+
const { default: createCustomPluginTypesMap } = await import('./createCustomPluginTypesMap.mjs');
|
|
90
|
+
const result = await createCustomPluginTypesMap({ directories: { config: '/config' } });
|
|
91
|
+
expect(result.blockMetas).toEqual({
|
|
92
|
+
FakeBlock: { category: 'display' },
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
test('populates icons from plugin types', async () => {
|
|
97
|
+
const { default: createCustomPluginTypesMap } = await import('./createCustomPluginTypesMap.mjs');
|
|
98
|
+
const result = await createCustomPluginTypesMap({ directories: { config: '/config' } });
|
|
99
|
+
expect(result.icons).toEqual({
|
|
100
|
+
FakeBlock: 'icon-name',
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
test('returns empty typesMap when neither lowdefy.yaml nor lowdefy.yml exists', async () => {
|
|
105
|
+
const { readFile } = await import('@lowdefy/node-utils');
|
|
106
|
+
readFile.mockResolvedValue(undefined);
|
|
107
|
+
const { default: createCustomPluginTypesMap } = await import('./createCustomPluginTypesMap.mjs');
|
|
108
|
+
const result = await createCustomPluginTypesMap({ directories: { config: '/config' } });
|
|
109
|
+
expect(result.actions).toEqual({});
|
|
110
|
+
expect(result.blocks).toEqual({});
|
|
111
|
+
expect(result.blockMetas).toEqual({});
|
|
112
|
+
expect(result.icons).toEqual({});
|
|
113
|
+
expect(result.requests).toEqual({});
|
|
114
|
+
expect(result.operators).toEqual({ client: {}, server: {} });
|
|
115
|
+
});
|
package/next.config.js
CHANGED
|
@@ -1,34 +1,20 @@
|
|
|
1
1
|
const lowdefyConfig = require('./build/config.json');
|
|
2
|
+
const blockPackages = require('./build/blockPackages.json');
|
|
3
|
+
const serverExternalPackages = require('./build/serverExternalPackages.json');
|
|
2
4
|
|
|
3
5
|
const nextConfig = {
|
|
4
6
|
basePath: lowdefyConfig.basePath,
|
|
5
7
|
reactStrictMode: true,
|
|
6
8
|
transpilePackages: [
|
|
7
9
|
'@lowdefy/client',
|
|
8
|
-
'@
|
|
9
|
-
'@
|
|
10
|
-
|
|
10
|
+
'@ant-design/x',
|
|
11
|
+
'@ant-design/x-markdown',
|
|
12
|
+
...blockPackages,
|
|
11
13
|
],
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
config.resolve.fallback = {
|
|
15
|
-
assert: false,
|
|
16
|
-
buffer: false,
|
|
17
|
-
crypto: false,
|
|
18
|
-
events: false,
|
|
19
|
-
fs: false,
|
|
20
|
-
path: false,
|
|
21
|
-
process: require.resolve('process/browser'),
|
|
22
|
-
util: false,
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
return config;
|
|
26
|
-
},
|
|
14
|
+
serverExternalPackages,
|
|
15
|
+
turbopack: {},
|
|
27
16
|
poweredByHeader: false,
|
|
28
17
|
output: process.env.LOWDEFY_BUILD_OUTPUT_STANDALONE === '1' ? 'standalone' : undefined,
|
|
29
|
-
eslint: {
|
|
30
|
-
ignoreDuringBuilds: true,
|
|
31
|
-
},
|
|
32
18
|
};
|
|
33
19
|
|
|
34
20
|
module.exports = nextConfig;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lowdefy/server-e2e",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.4.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "Lowdefy e2e testing server with cookie-based user injection",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
|
@@ -39,39 +39,43 @@
|
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@ant-design/cssinjs": "2.1.2",
|
|
42
|
-
"@lowdefy/actions-core": "5.
|
|
43
|
-
"@lowdefy/api": "5.
|
|
44
|
-
"@lowdefy/block-utils": "5.
|
|
45
|
-
"@lowdefy/blocks-antd": "5.
|
|
46
|
-
"@lowdefy/blocks-
|
|
47
|
-
"@lowdefy/blocks-
|
|
48
|
-
"@lowdefy/blocks-
|
|
49
|
-
"@lowdefy/blocks-
|
|
50
|
-
"@lowdefy/
|
|
51
|
-
"@lowdefy/
|
|
52
|
-
"@lowdefy/connection-
|
|
53
|
-
"@lowdefy/
|
|
54
|
-
"@lowdefy/
|
|
55
|
-
"@lowdefy/
|
|
56
|
-
"@lowdefy/
|
|
57
|
-
"@lowdefy/
|
|
58
|
-
"@lowdefy/
|
|
59
|
-
"@lowdefy/operators-
|
|
60
|
-
"@lowdefy/operators-
|
|
42
|
+
"@lowdefy/actions-core": "5.4.0",
|
|
43
|
+
"@lowdefy/api": "5.4.0",
|
|
44
|
+
"@lowdefy/block-utils": "5.4.0",
|
|
45
|
+
"@lowdefy/blocks-antd": "5.4.0",
|
|
46
|
+
"@lowdefy/blocks-antd-x": "5.4.0",
|
|
47
|
+
"@lowdefy/blocks-basic": "5.4.0",
|
|
48
|
+
"@lowdefy/blocks-loaders": "5.4.0",
|
|
49
|
+
"@lowdefy/blocks-markdown": "5.4.0",
|
|
50
|
+
"@lowdefy/blocks-tiptap": "5.4.0",
|
|
51
|
+
"@lowdefy/client": "5.4.0",
|
|
52
|
+
"@lowdefy/connection-axios-http": "5.4.0",
|
|
53
|
+
"@lowdefy/connection-mongodb": "5.4.0",
|
|
54
|
+
"@lowdefy/errors": "5.4.0",
|
|
55
|
+
"@lowdefy/helpers": "5.4.0",
|
|
56
|
+
"@lowdefy/layout": "5.4.0",
|
|
57
|
+
"@lowdefy/logger": "5.4.0",
|
|
58
|
+
"@lowdefy/node-utils": "5.4.0",
|
|
59
|
+
"@lowdefy/operators-js": "5.4.0",
|
|
60
|
+
"@lowdefy/operators-nunjucks": "5.4.0",
|
|
61
|
+
"@lowdefy/operators-uuid": "5.4.0",
|
|
62
|
+
"@tailwindcss/postcss": "4.2.1",
|
|
61
63
|
"antd": "6.3.1",
|
|
62
64
|
"dayjs": "1.11.19",
|
|
63
65
|
"next": "16.1.6",
|
|
64
66
|
"pino": "8.16.2",
|
|
65
|
-
"process": "0.11.10",
|
|
66
67
|
"react": "18.2.0",
|
|
67
68
|
"react-dom": "18.2.0",
|
|
68
69
|
"react-icons": "5.6.0",
|
|
70
|
+
"tailwindcss": "4.2.1",
|
|
69
71
|
"uuid": "13.0.0"
|
|
70
72
|
},
|
|
71
73
|
"devDependencies": {
|
|
72
|
-
"@
|
|
74
|
+
"@jest/globals": "28.1.3",
|
|
75
|
+
"@lowdefy/build": "5.4.0",
|
|
73
76
|
"@next/eslint-plugin-next": "16.1.6",
|
|
74
77
|
"@tailwindcss/postcss": "4.2.1",
|
|
78
|
+
"jest": "28.1.3",
|
|
75
79
|
"tailwindcss": "4.2.1",
|
|
76
80
|
"webpack": "5.94.0",
|
|
77
81
|
"yaml": "2.3.4",
|
|
@@ -90,6 +94,7 @@
|
|
|
90
94
|
"dev": "next dev",
|
|
91
95
|
"start": "next start",
|
|
92
96
|
"lint": "next lint",
|
|
93
|
-
"next": "next"
|
|
97
|
+
"next": "next",
|
|
98
|
+
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js"
|
|
94
99
|
}
|
|
95
100
|
}
|
package/package.original.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lowdefy/server-e2e",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.4.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "Lowdefy e2e testing server with cookie-based user injection",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
|
@@ -45,43 +45,48 @@
|
|
|
45
45
|
"start": "next start",
|
|
46
46
|
"lint": "next lint",
|
|
47
47
|
"next": "next",
|
|
48
|
+
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
|
|
48
49
|
"prepublishOnly": "pnpm build"
|
|
49
50
|
},
|
|
50
51
|
"dependencies": {
|
|
51
52
|
"@ant-design/cssinjs": "2.1.2",
|
|
52
|
-
"@lowdefy/actions-core": "5.
|
|
53
|
-
"@lowdefy/api": "5.
|
|
54
|
-
"@lowdefy/block-utils": "5.
|
|
55
|
-
"@lowdefy/blocks-antd": "5.
|
|
56
|
-
"@lowdefy/blocks-
|
|
57
|
-
"@lowdefy/blocks-
|
|
58
|
-
"@lowdefy/blocks-
|
|
59
|
-
"@lowdefy/blocks-
|
|
60
|
-
"@lowdefy/
|
|
61
|
-
"@lowdefy/
|
|
62
|
-
"@lowdefy/connection-
|
|
63
|
-
"@lowdefy/
|
|
64
|
-
"@lowdefy/
|
|
65
|
-
"@lowdefy/
|
|
66
|
-
"@lowdefy/
|
|
67
|
-
"@lowdefy/
|
|
68
|
-
"@lowdefy/
|
|
69
|
-
"@lowdefy/operators-
|
|
70
|
-
"@lowdefy/operators-
|
|
53
|
+
"@lowdefy/actions-core": "5.4.0",
|
|
54
|
+
"@lowdefy/api": "5.4.0",
|
|
55
|
+
"@lowdefy/block-utils": "5.4.0",
|
|
56
|
+
"@lowdefy/blocks-antd": "5.4.0",
|
|
57
|
+
"@lowdefy/blocks-antd-x": "5.4.0",
|
|
58
|
+
"@lowdefy/blocks-basic": "5.4.0",
|
|
59
|
+
"@lowdefy/blocks-loaders": "5.4.0",
|
|
60
|
+
"@lowdefy/blocks-markdown": "5.4.0",
|
|
61
|
+
"@lowdefy/blocks-tiptap": "5.4.0",
|
|
62
|
+
"@lowdefy/client": "5.4.0",
|
|
63
|
+
"@lowdefy/connection-axios-http": "5.4.0",
|
|
64
|
+
"@lowdefy/connection-mongodb": "5.4.0",
|
|
65
|
+
"@lowdefy/errors": "5.4.0",
|
|
66
|
+
"@lowdefy/helpers": "5.4.0",
|
|
67
|
+
"@lowdefy/layout": "5.4.0",
|
|
68
|
+
"@lowdefy/logger": "5.4.0",
|
|
69
|
+
"@lowdefy/node-utils": "5.4.0",
|
|
70
|
+
"@lowdefy/operators-js": "5.4.0",
|
|
71
|
+
"@lowdefy/operators-nunjucks": "5.4.0",
|
|
72
|
+
"@lowdefy/operators-uuid": "5.4.0",
|
|
73
|
+
"@tailwindcss/postcss": "4.2.1",
|
|
71
74
|
"antd": "6.3.1",
|
|
72
75
|
"dayjs": "1.11.19",
|
|
73
76
|
"next": "16.1.6",
|
|
74
77
|
"pino": "8.16.2",
|
|
75
|
-
"process": "0.11.10",
|
|
76
78
|
"react": "18.2.0",
|
|
77
79
|
"react-dom": "18.2.0",
|
|
78
80
|
"react-icons": "5.6.0",
|
|
81
|
+
"tailwindcss": "4.2.1",
|
|
79
82
|
"uuid": "13.0.0"
|
|
80
83
|
},
|
|
81
84
|
"devDependencies": {
|
|
82
|
-
"@
|
|
85
|
+
"@jest/globals": "28.1.3",
|
|
86
|
+
"@lowdefy/build": "5.4.0",
|
|
83
87
|
"@next/eslint-plugin-next": "16.1.6",
|
|
84
88
|
"@tailwindcss/postcss": "4.2.1",
|
|
89
|
+
"jest": "28.1.3",
|
|
85
90
|
"tailwindcss": "4.2.1",
|
|
86
91
|
"webpack": "5.94.0",
|
|
87
92
|
"yaml": "2.3.4",
|
package/pages/404.js
CHANGED
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
import path from 'path';
|
|
18
18
|
import { createApiContext, getPageConfig, getRootConfig } from '@lowdefy/api';
|
|
19
19
|
|
|
20
|
+
import appMeta from '../lib/build/appMeta.js';
|
|
20
21
|
import config from '../lib/build/config.js';
|
|
21
22
|
import fileCache from '../lib/server/fileCache.js';
|
|
22
23
|
import Page from '../lib/client/Page.js';
|
|
@@ -24,6 +25,7 @@ import Page from '../lib/client/Page.js';
|
|
|
24
25
|
export async function getStaticProps() {
|
|
25
26
|
// Important to give absolute path so Next can trace build files
|
|
26
27
|
const context = {
|
|
28
|
+
appMeta,
|
|
27
29
|
buildDirectory: path.join(process.cwd(), 'build'),
|
|
28
30
|
config,
|
|
29
31
|
fileCache,
|
|
@@ -20,8 +20,42 @@ import serverSidePropsWrapper from '../lib/server/serverSidePropsWrapper.js';
|
|
|
20
20
|
import Page from '../lib/client/Page.js';
|
|
21
21
|
|
|
22
22
|
async function getServerSidePropsHandler({ context, nextContext }) {
|
|
23
|
-
const
|
|
23
|
+
const segments = nextContext.params.pageId ?? [];
|
|
24
|
+
const pageId = segments.join('/');
|
|
24
25
|
const { logger, session } = context;
|
|
26
|
+
|
|
27
|
+
if (!pageId) {
|
|
28
|
+
const rootConfig = await getRootConfig(context);
|
|
29
|
+
const { home } = rootConfig;
|
|
30
|
+
if (home.configured === false) {
|
|
31
|
+
logger.info({ event: 'redirect_to_homepage', pageId: home.pageId });
|
|
32
|
+
return {
|
|
33
|
+
redirect: {
|
|
34
|
+
destination: `/${home.pageId}`,
|
|
35
|
+
permanent: false,
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
const pageConfig = await getPageConfig(context, { pageId: home.pageId });
|
|
40
|
+
if (!pageConfig) {
|
|
41
|
+
logger.info({ event: 'redirect_page_not_found', pageId: home.pageId });
|
|
42
|
+
return {
|
|
43
|
+
redirect: {
|
|
44
|
+
destination: '/404',
|
|
45
|
+
permanent: false,
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
logger.info({ event: 'page_view', pageId: home.pageId });
|
|
50
|
+
return {
|
|
51
|
+
props: {
|
|
52
|
+
pageConfig,
|
|
53
|
+
rootConfig,
|
|
54
|
+
session,
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
25
59
|
const [rootConfig, pageConfig] = await Promise.all([
|
|
26
60
|
getRootConfig(context),
|
|
27
61
|
getPageConfig(context, { pageId }),
|
package/pages/_app.js
CHANGED
|
@@ -23,6 +23,7 @@ import React, { useCallback, useRef } from 'react';
|
|
|
23
23
|
import dynamic from 'next/dynamic';
|
|
24
24
|
|
|
25
25
|
import { ErrorBoundary } from '@lowdefy/block-utils';
|
|
26
|
+
import { useDarkMode } from '@lowdefy/client';
|
|
26
27
|
import { StyleProvider } from '@ant-design/cssinjs';
|
|
27
28
|
import { App as AntdApp, ConfigProvider, theme as antdTheme } from 'antd';
|
|
28
29
|
|
|
@@ -32,22 +33,35 @@ import createLogUsage from '../lib/client/createLogUsage.js';
|
|
|
32
33
|
// Must be in _app due to next specifications.
|
|
33
34
|
import '../build/globals.css';
|
|
34
35
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
function resolveAlgorithm(algorithm) {
|
|
42
|
-
if (Array.isArray(algorithm)) {
|
|
43
|
-
return algorithm.map((a) => algorithmMap[a] || antdTheme.defaultAlgorithm);
|
|
36
|
+
function ThemeTokenResolver({ lowdefyRef, children }) {
|
|
37
|
+
const { token } = antdTheme.useToken();
|
|
38
|
+
if (!lowdefyRef.current.theme) {
|
|
39
|
+
lowdefyRef.current.theme = {};
|
|
44
40
|
}
|
|
45
|
-
|
|
41
|
+
lowdefyRef.current.theme._resolvedAntdToken = token;
|
|
42
|
+
return children;
|
|
46
43
|
}
|
|
47
44
|
|
|
48
45
|
function App({ Component, pageProps: { session, rootConfig, pageConfig } }) {
|
|
49
46
|
const usageDataRef = useRef({});
|
|
50
47
|
const lowdefyRef = useRef({ eventCallback: createLogUsage({ usageDataRef }) });
|
|
48
|
+
if (rootConfig?.theme) {
|
|
49
|
+
lowdefyRef.current.theme = rootConfig.theme;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const { algorithm, token, components } = useDarkMode({
|
|
53
|
+
antd: lowdefyRef.current.theme?.antd,
|
|
54
|
+
configDarkMode: lowdefyRef.current.theme?.darkMode,
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const {
|
|
58
|
+
lightToken: _lightToken,
|
|
59
|
+
darkToken: _darkToken,
|
|
60
|
+
lightComponents: _lightComponents,
|
|
61
|
+
darkComponents: _darkComponents,
|
|
62
|
+
...antdConfig
|
|
63
|
+
} = lowdefyRef.current.theme?.antd ?? {};
|
|
64
|
+
|
|
51
65
|
const handleError = useCallback((error) => {
|
|
52
66
|
if (lowdefyRef.current?._internal?.handleError) {
|
|
53
67
|
lowdefyRef.current._internal.handleError(error);
|
|
@@ -60,28 +74,32 @@ function App({ Component, pageProps: { session, rootConfig, pageConfig } }) {
|
|
|
60
74
|
<StyleProvider layer>
|
|
61
75
|
<ConfigProvider
|
|
62
76
|
theme={{
|
|
63
|
-
...
|
|
77
|
+
...antdConfig,
|
|
78
|
+
token,
|
|
79
|
+
components,
|
|
64
80
|
cssVar: { key: 'lowdefy' },
|
|
65
81
|
hashed: false,
|
|
66
|
-
algorithm
|
|
82
|
+
algorithm,
|
|
67
83
|
}}
|
|
68
84
|
>
|
|
69
85
|
<AntdApp>
|
|
70
|
-
<
|
|
71
|
-
<
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
86
|
+
<ThemeTokenResolver lowdefyRef={lowdefyRef}>
|
|
87
|
+
<ErrorBoundary fullPage onError={handleError}>
|
|
88
|
+
<Auth session={session}>
|
|
89
|
+
{(auth) => {
|
|
90
|
+
usageDataRef.current.user = auth.session?.hashed_id;
|
|
91
|
+
return (
|
|
92
|
+
<Component
|
|
93
|
+
auth={auth}
|
|
94
|
+
lowdefy={lowdefyRef.current}
|
|
95
|
+
rootConfig={rootConfig}
|
|
96
|
+
pageConfig={pageConfig}
|
|
97
|
+
/>
|
|
98
|
+
);
|
|
99
|
+
}}
|
|
100
|
+
</Auth>
|
|
101
|
+
</ErrorBoundary>
|
|
102
|
+
</ThemeTokenResolver>
|
|
85
103
|
</AntdApp>
|
|
86
104
|
</ConfigProvider>
|
|
87
105
|
</StyleProvider>
|
package/pages/_document.js
CHANGED
|
@@ -19,8 +19,34 @@ import Document, { Html, Head, Main, NextScript } from 'next/document';
|
|
|
19
19
|
|
|
20
20
|
import appJson from '../lib/build/app.js';
|
|
21
21
|
import lowdefyConfig from '../lib/build/config.js';
|
|
22
|
+
import themeConfig from '../lib/build/theme.js';
|
|
22
23
|
|
|
23
24
|
const basePath = lowdefyConfig.basePath ?? '';
|
|
25
|
+
const VALID_COLOR_MODES = ['system', 'light', 'dark'];
|
|
26
|
+
const configColorMode = VALID_COLOR_MODES.includes(themeConfig.darkMode)
|
|
27
|
+
? themeConfig.darkMode
|
|
28
|
+
: 'system';
|
|
29
|
+
const darkBg = themeConfig?.antd?.darkToken?.colorBgLayout ?? '#000';
|
|
30
|
+
const lightBg = themeConfig?.antd?.lightToken?.colorBgLayout ?? '';
|
|
31
|
+
|
|
32
|
+
// Escape characters that could break out of the enclosing <script> tag or
|
|
33
|
+
// terminate a JS string literal. Used to defuse the js/bad-code-sanitization
|
|
34
|
+
// class of injection for values embedded into the pre-hydration inline script.
|
|
35
|
+
const SCRIPT_ESCAPES = {
|
|
36
|
+
'<': '\\u003C',
|
|
37
|
+
'>': '\\u003E',
|
|
38
|
+
'\b': '\\b',
|
|
39
|
+
'\f': '\\f',
|
|
40
|
+
'\n': '\\n',
|
|
41
|
+
'\r': '\\r',
|
|
42
|
+
'\t': '\\t',
|
|
43
|
+
'\0': '\\0',
|
|
44
|
+
'\u2028': '\\u2028',
|
|
45
|
+
'\u2029': '\\u2029',
|
|
46
|
+
};
|
|
47
|
+
function safeScriptJson(value) {
|
|
48
|
+
return JSON.stringify(value).replace(/[<>\b\f\n\r\t\0\u2028\u2029]/g, (c) => SCRIPT_ESCAPES[c]);
|
|
49
|
+
}
|
|
24
50
|
|
|
25
51
|
class LowdefyDocument extends Document {
|
|
26
52
|
render() {
|
|
@@ -38,6 +64,21 @@ class LowdefyDocument extends Document {
|
|
|
38
64
|
__html: `(function(){var s=document.createElement("style");s.id="__lf-layer-order";s.textContent="@layer theme, base, antd, components, utilities;";document.head.prepend(s);new MutationObserver(function(){if(document.head.firstChild!==s)document.head.prepend(s)}).observe(document.head,{childList:true})})();`,
|
|
39
65
|
}}
|
|
40
66
|
/>
|
|
67
|
+
{/* Synchronous pre-hydration background script — prevents mode-mismatch
|
|
68
|
+
flash on page navigation. Mirrors useDarkMode.js resolution order:
|
|
69
|
+
configDarkMode → localStorage → prefers-color-scheme. Uses the user's
|
|
70
|
+
configured colorBgLayout tokens when present (theme.antd.darkToken and
|
|
71
|
+
theme.antd.lightToken), falling back to #000 in dark and no inline style
|
|
72
|
+
in light so default behavior is unchanged. */}
|
|
73
|
+
<script
|
|
74
|
+
dangerouslySetInnerHTML={{
|
|
75
|
+
__html: `(function(){var c=${safeScriptJson(configColorMode)};var db=${safeScriptJson(
|
|
76
|
+
darkBg
|
|
77
|
+
)};var lb=${safeScriptJson(
|
|
78
|
+
lightBg
|
|
79
|
+
)};var d;if(c==="dark")d=true;else if(c==="light")d=false;else{try{var p=localStorage.getItem("lowdefy_darkMode");if(p==="dark")d=true;else if(p==="light")d=false;else d=window.matchMedia("(prefers-color-scheme:dark)").matches}catch(e){d=window.matchMedia("(prefers-color-scheme:dark)").matches}}var bg=d?db:lb;if(bg)document.documentElement.style.backgroundColor=bg})();`,
|
|
80
|
+
}}
|
|
81
|
+
/>
|
|
41
82
|
<link rel="manifest" href={`${basePath}/manifest.webmanifest`} />
|
|
42
83
|
<link rel="icon" type="image/svg+xml" href={`${basePath}/icon.svg`} />
|
|
43
84
|
<link rel="apple-touch-icon" href={`${basePath}/apple-touch-icon.png`} />
|
|
@@ -22,8 +22,30 @@ async function handler({ context, req, res }) {
|
|
|
22
22
|
if (req.method !== 'POST') {
|
|
23
23
|
throw new Error('Only POST requests are supported.');
|
|
24
24
|
}
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
|
|
26
|
+
const origin = req.headers.origin;
|
|
27
|
+
if (!origin) {
|
|
28
|
+
res.status(403).json({ error: 'Forbidden' });
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
try {
|
|
32
|
+
if (new URL(origin).host !== req.headers.host) {
|
|
33
|
+
res.status(403).json({ error: 'Forbidden' });
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
} catch {
|
|
37
|
+
res.status(403).json({ error: 'Forbidden' });
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Strip received from payload — prod doesn't need it for schema validation
|
|
42
|
+
if (req.body?.['~e']) {
|
|
43
|
+
delete req.body['~e'].received;
|
|
44
|
+
}
|
|
45
|
+
// eslint-disable-next-line no-unused-vars
|
|
46
|
+
const { error, ...response } = await logClientError(context, req.body);
|
|
47
|
+
|
|
48
|
+
res.status(200).json({ success: true });
|
|
27
49
|
}
|
|
28
50
|
|
|
29
51
|
export default apiWrapper(handler);
|
|
@@ -22,7 +22,7 @@ async function handler({ context, req, res }) {
|
|
|
22
22
|
if (req.method !== 'POST') {
|
|
23
23
|
throw new Error('Only POST requests are supported.');
|
|
24
24
|
}
|
|
25
|
-
const
|
|
25
|
+
const endpointId = req.query.endpointId.join('/');
|
|
26
26
|
const { blockId, payload, pageId } = req.body;
|
|
27
27
|
context.logger.info({ event: 'call_api_endpoint', blockId, endpointId, pageId });
|
|
28
28
|
const response = await callEndpoint(context, { blockId, endpointId, pageId, payload });
|
|
@@ -16,13 +16,19 @@
|
|
|
16
16
|
|
|
17
17
|
import { callRequest } from '@lowdefy/api';
|
|
18
18
|
|
|
19
|
-
import apiWrapper from '
|
|
19
|
+
import apiWrapper from '../../../lib/server/apiWrapper.js';
|
|
20
20
|
|
|
21
21
|
async function handler({ context, req, res }) {
|
|
22
22
|
if (req.method !== 'POST') {
|
|
23
23
|
throw new Error('Only POST requests are supported.');
|
|
24
24
|
}
|
|
25
|
-
const
|
|
25
|
+
const segments = req.query.path;
|
|
26
|
+
if (!Array.isArray(segments) || segments.length < 2) {
|
|
27
|
+
res.status(400).json({ error: 'Invalid request path' });
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const requestId = segments[segments.length - 1];
|
|
31
|
+
const pageId = segments.slice(0, -1).join('/');
|
|
26
32
|
const { actionId, blockId, payload } = req.body;
|
|
27
33
|
context.logger.info({ event: 'call_request', pageId, requestId, blockId, actionId });
|
|
28
34
|
const response = await callRequest(context, { blockId, pageId, payload, requestId });
|
package/pages/api/usage.js
CHANGED
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import appJson from '../../lib/build/app.js';
|
|
18
17
|
import packageJson from '../../package.json';
|
|
19
18
|
import apiWrapper from '../../lib/server/apiWrapper.js';
|
|
20
19
|
|
|
@@ -31,7 +30,7 @@ async function handler({ context, req, res }) {
|
|
|
31
30
|
return res.status(200).json({
|
|
32
31
|
offline: false,
|
|
33
32
|
data: {
|
|
34
|
-
|
|
33
|
+
gitSha: context.appMeta.gitSha,
|
|
35
34
|
host,
|
|
36
35
|
machine,
|
|
37
36
|
timestamp,
|
package/pages/index.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2026 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 { getPageConfig, getRootConfig } from '@lowdefy/api';
|
|
18
|
-
|
|
19
|
-
import serverSidePropsWrapper from '../lib/server/serverSidePropsWrapper.js';
|
|
20
|
-
import Page from '../lib/client/Page.js';
|
|
21
|
-
|
|
22
|
-
async function getServerSidePropsHandler({ context }) {
|
|
23
|
-
const rootConfig = await getRootConfig(context);
|
|
24
|
-
const { home } = rootConfig;
|
|
25
|
-
const { logger, session } = context;
|
|
26
|
-
|
|
27
|
-
if (home.configured === false) {
|
|
28
|
-
logger.info({ event: 'redirect_to_homepage', pageId: home.pageId });
|
|
29
|
-
return {
|
|
30
|
-
redirect: {
|
|
31
|
-
destination: `/${home.pageId}`,
|
|
32
|
-
permanent: false,
|
|
33
|
-
},
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
const pageConfig = await getPageConfig(context, { pageId: home.pageId });
|
|
37
|
-
if (!pageConfig) {
|
|
38
|
-
logger.info({ event: 'redirect_page_not_found', pageId: home.pageId });
|
|
39
|
-
return {
|
|
40
|
-
redirect: {
|
|
41
|
-
destination: '/404',
|
|
42
|
-
permanent: false,
|
|
43
|
-
},
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
logger.info({ event: 'page_view', pageId: home.pageId });
|
|
47
|
-
return {
|
|
48
|
-
props: {
|
|
49
|
-
pageConfig,
|
|
50
|
-
rootConfig,
|
|
51
|
-
session,
|
|
52
|
-
},
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export const getServerSideProps = serverSidePropsWrapper(getServerSidePropsHandler);
|
|
57
|
-
|
|
58
|
-
export default Page;
|