@lowdefy/server-dev 4.5.2 → 4.6.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.
Files changed (73) hide show
  1. package/{manager/utils/createLogger.mjs → lib/build/app.js} +4 -18
  2. package/lib/build/auth.js +19 -0
  3. package/lib/build/config.js +19 -0
  4. package/lib/build/logger.js +19 -0
  5. package/lib/client/App.js +25 -21
  6. package/lib/client/BuildErrorPage.js +91 -0
  7. package/lib/client/BuildingPage.js +74 -0
  8. package/lib/client/InstallingPluginsPage.js +50 -0
  9. package/lib/client/Page.js +20 -2
  10. package/lib/client/Reload.js +1 -1
  11. package/lib/client/RestartingPage.js +3 -1
  12. package/lib/client/auth/Auth.js +2 -2
  13. package/lib/client/auth/AuthConfigured.js +2 -2
  14. package/lib/client/auth/AuthNotConfigured.js +1 -1
  15. package/lib/client/setPageId.js +1 -1
  16. package/lib/client/utils/request.js +2 -5
  17. package/lib/client/utils/useMutateCache.js +16 -3
  18. package/lib/client/utils/usePageConfig.js +51 -5
  19. package/lib/client/utils/useRootConfig.js +1 -1
  20. package/lib/client/utils/waitForRestartedServer.js +1 -1
  21. package/lib/server/apiWrapper.js +48 -8
  22. package/lib/server/auth/getAuthOptions.js +2 -2
  23. package/lib/server/auth/getMockSession.js +67 -0
  24. package/lib/server/auth/getServerSession.js +10 -3
  25. package/lib/server/fileCache.js +1 -1
  26. package/lib/server/jitPageBuilder.js +162 -0
  27. package/lib/server/log/createHandleError.js +47 -0
  28. package/lib/server/log/createLogger.js +4 -4
  29. package/lib/server/log/logRequest.js +1 -1
  30. package/lib/server/pageCache.mjs +61 -0
  31. package/lib/server/pageCache.test.mjs +80 -0
  32. package/manager/getContext.mjs +26 -4
  33. package/manager/processes/checkMockUserWarning.mjs +42 -0
  34. package/manager/processes/initialBuild.mjs +2 -1
  35. package/manager/processes/installPlugins.mjs +3 -3
  36. package/manager/processes/lowdefyBuild.mjs +16 -5
  37. package/manager/processes/nextBuild.mjs +27 -8
  38. package/manager/processes/readDotEnv.mjs +1 -1
  39. package/manager/processes/reloadClients.mjs +1 -1
  40. package/manager/processes/restartServer.mjs +3 -3
  41. package/manager/processes/shutdownServer.mjs +2 -2
  42. package/manager/processes/startServer.mjs +32 -15
  43. package/manager/processes/startWatchers.mjs +1 -1
  44. package/manager/run.mjs +4 -12
  45. package/manager/utils/BatchChanges.mjs +1 -1
  46. package/manager/utils/checkPortAvailable.mjs +41 -0
  47. package/manager/utils/createCustomPluginTypesMap.mjs +1 -1
  48. package/manager/utils/getLowdefyVersion.mjs +8 -7
  49. package/manager/utils/getNextBin.mjs +1 -1
  50. package/manager/utils/setupWatcher.mjs +1 -1
  51. package/manager/watchers/envWatcher.mjs +1 -1
  52. package/manager/watchers/lowdefyBuildWatcher.mjs +26 -5
  53. package/manager/watchers/nextBuildWatcher.mjs +12 -2
  54. package/next.config.js +3 -2
  55. package/package.json +33 -29
  56. package/package.original.json +32 -28
  57. package/pages/404.js +1 -1
  58. package/pages/[pageId].js +1 -1
  59. package/pages/_app.js +17 -4
  60. package/pages/_document.js +3 -3
  61. package/pages/api/auth/[...nextauth].js +13 -2
  62. package/pages/api/client-error.js +45 -0
  63. package/pages/api/dev-tools.js +1 -1
  64. package/pages/api/endpoints/[endpointId].js +1 -1
  65. package/pages/api/js/[env].js +42 -0
  66. package/pages/api/page/[pageId].js +40 -2
  67. package/pages/api/ping.js +1 -1
  68. package/pages/api/reload.js +6 -3
  69. package/pages/api/request/[pageId]/[requestId].js +6 -3
  70. package/pages/api/root.js +1 -1
  71. package/pages/index.js +1 -1
  72. package/lib/server/log/logError.js +0 -40
  73. package/manager/utils/createStdOutLineHandler.mjs +0 -33
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/server-dev",
3
- "version": "4.5.2",
3
+ "version": "4.6.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "",
6
6
  "homepage": "https://lowdefy.com",
@@ -36,33 +36,34 @@
36
36
  ".npmrc"
37
37
  ],
38
38
  "dependencies": {
39
- "@lowdefy/actions-core": "4.5.2",
40
- "@lowdefy/api": "4.5.2",
41
- "@lowdefy/block-utils": "4.5.2",
42
- "@lowdefy/blocks-aggrid": "4.5.2",
43
- "@lowdefy/blocks-antd": "4.5.2",
44
- "@lowdefy/blocks-basic": "4.5.2",
45
- "@lowdefy/blocks-color-selectors": "4.5.2",
46
- "@lowdefy/blocks-echarts": "4.5.2",
47
- "@lowdefy/blocks-loaders": "4.5.2",
48
- "@lowdefy/blocks-markdown": "4.5.2",
49
- "@lowdefy/blocks-qr": "4.5.2",
50
- "@lowdefy/build": "4.5.2",
51
- "@lowdefy/client": "4.5.2",
52
- "@lowdefy/connection-axios-http": "4.5.2",
53
- "@lowdefy/engine": "4.5.2",
54
- "@lowdefy/helpers": "4.5.2",
55
- "@lowdefy/layout": "4.5.2",
56
- "@lowdefy/node-utils": "4.5.2",
57
- "@lowdefy/operators-change-case": "4.5.2",
58
- "@lowdefy/operators-diff": "4.5.2",
59
- "@lowdefy/operators-js": "4.5.2",
60
- "@lowdefy/operators-moment": "4.5.2",
61
- "@lowdefy/operators-mql": "4.5.2",
62
- "@lowdefy/operators-nunjucks": "4.5.2",
63
- "@lowdefy/operators-uuid": "4.5.2",
64
- "@lowdefy/operators-yaml": "4.5.2",
65
- "@lowdefy/plugin-next-auth": "4.5.2",
39
+ "@lowdefy/actions-core": "4.6.0",
40
+ "@lowdefy/api": "4.6.0",
41
+ "@lowdefy/block-utils": "4.6.0",
42
+ "@lowdefy/blocks-aggrid": "4.6.0",
43
+ "@lowdefy/blocks-antd": "4.6.0",
44
+ "@lowdefy/blocks-basic": "4.6.0",
45
+ "@lowdefy/blocks-color-selectors": "4.6.0",
46
+ "@lowdefy/blocks-echarts": "4.6.0",
47
+ "@lowdefy/blocks-loaders": "4.6.0",
48
+ "@lowdefy/blocks-markdown": "4.6.0",
49
+ "@lowdefy/blocks-qr": "4.6.0",
50
+ "@lowdefy/build": "4.6.0",
51
+ "@lowdefy/client": "4.6.0",
52
+ "@lowdefy/engine": "4.6.0",
53
+ "@lowdefy/errors": "4.6.0",
54
+ "@lowdefy/helpers": "4.6.0",
55
+ "@lowdefy/layout": "4.6.0",
56
+ "@lowdefy/logger": "4.6.0",
57
+ "@lowdefy/node-utils": "4.6.0",
58
+ "@lowdefy/operators-change-case": "4.6.0",
59
+ "@lowdefy/operators-diff": "4.6.0",
60
+ "@lowdefy/operators-js": "4.6.0",
61
+ "@lowdefy/operators-moment": "4.6.0",
62
+ "@lowdefy/operators-mql": "4.6.0",
63
+ "@lowdefy/operators-nunjucks": "4.6.0",
64
+ "@lowdefy/operators-uuid": "4.6.0",
65
+ "@lowdefy/operators-yaml": "4.6.0",
66
+ "@lowdefy/plugin-next-auth": "4.6.0",
66
67
  "chokidar": "3.5.3",
67
68
  "dotenv": "16.3.1",
68
69
  "next": "13.5.4",
@@ -74,11 +75,13 @@
74
75
  "react-dom": "18.2.0",
75
76
  "react-icons": "4.12.0",
76
77
  "swr": "2.2.4",
78
+ "uuid": "13.0.0",
77
79
  "yaml": "2.3.4",
78
80
  "yargs": "17.7.2"
79
81
  },
80
82
  "devDependencies": {
81
83
  "@next/eslint-plugin-next": "13.5.4",
84
+ "jest": "28.1.3",
82
85
  "less": "4.1.3",
83
86
  "less-loader": "11.1.3",
84
87
  "next-with-less": "3.0.1",
@@ -94,6 +97,7 @@
94
97
  "build": "cp package.json package.original.json || copy package.json package.original.json",
95
98
  "start": "node manager/run.mjs",
96
99
  "lint": "next lint",
97
- "next": "next"
100
+ "next": "next",
101
+ "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js"
98
102
  }
99
103
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/server-dev",
3
- "version": "4.5.2",
3
+ "version": "4.6.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "",
6
6
  "homepage": "https://lowdefy.com",
@@ -40,36 +40,38 @@
40
40
  "start": "node manager/run.mjs",
41
41
  "lint": "next lint",
42
42
  "next": "next",
43
+ "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
43
44
  "prepublishOnly": "pnpm build"
44
45
  },
45
46
  "dependencies": {
46
- "@lowdefy/actions-core": "4.5.2",
47
- "@lowdefy/api": "4.5.2",
48
- "@lowdefy/block-utils": "4.5.2",
49
- "@lowdefy/blocks-aggrid": "4.5.2",
50
- "@lowdefy/blocks-antd": "4.5.2",
51
- "@lowdefy/blocks-basic": "4.5.2",
52
- "@lowdefy/blocks-color-selectors": "4.5.2",
53
- "@lowdefy/blocks-echarts": "4.5.2",
54
- "@lowdefy/blocks-loaders": "4.5.2",
55
- "@lowdefy/blocks-markdown": "4.5.2",
56
- "@lowdefy/blocks-qr": "4.5.2",
57
- "@lowdefy/build": "4.5.2",
58
- "@lowdefy/client": "4.5.2",
59
- "@lowdefy/connection-axios-http": "4.5.2",
60
- "@lowdefy/engine": "4.5.2",
61
- "@lowdefy/helpers": "4.5.2",
62
- "@lowdefy/layout": "4.5.2",
63
- "@lowdefy/node-utils": "4.5.2",
64
- "@lowdefy/operators-change-case": "4.5.2",
65
- "@lowdefy/operators-diff": "4.5.2",
66
- "@lowdefy/operators-js": "4.5.2",
67
- "@lowdefy/operators-moment": "4.5.2",
68
- "@lowdefy/operators-mql": "4.5.2",
69
- "@lowdefy/operators-nunjucks": "4.5.2",
70
- "@lowdefy/operators-uuid": "4.5.2",
71
- "@lowdefy/operators-yaml": "4.5.2",
72
- "@lowdefy/plugin-next-auth": "4.5.2",
47
+ "@lowdefy/actions-core": "4.6.0",
48
+ "@lowdefy/api": "4.6.0",
49
+ "@lowdefy/block-utils": "4.6.0",
50
+ "@lowdefy/blocks-aggrid": "4.6.0",
51
+ "@lowdefy/blocks-antd": "4.6.0",
52
+ "@lowdefy/blocks-basic": "4.6.0",
53
+ "@lowdefy/blocks-color-selectors": "4.6.0",
54
+ "@lowdefy/blocks-echarts": "4.6.0",
55
+ "@lowdefy/blocks-loaders": "4.6.0",
56
+ "@lowdefy/blocks-markdown": "4.6.0",
57
+ "@lowdefy/blocks-qr": "4.6.0",
58
+ "@lowdefy/build": "4.6.0",
59
+ "@lowdefy/client": "4.6.0",
60
+ "@lowdefy/engine": "4.6.0",
61
+ "@lowdefy/errors": "4.6.0",
62
+ "@lowdefy/helpers": "4.6.0",
63
+ "@lowdefy/layout": "4.6.0",
64
+ "@lowdefy/logger": "4.6.0",
65
+ "@lowdefy/node-utils": "4.6.0",
66
+ "@lowdefy/operators-change-case": "4.6.0",
67
+ "@lowdefy/operators-diff": "4.6.0",
68
+ "@lowdefy/operators-js": "4.6.0",
69
+ "@lowdefy/operators-moment": "4.6.0",
70
+ "@lowdefy/operators-mql": "4.6.0",
71
+ "@lowdefy/operators-nunjucks": "4.6.0",
72
+ "@lowdefy/operators-uuid": "4.6.0",
73
+ "@lowdefy/operators-yaml": "4.6.0",
74
+ "@lowdefy/plugin-next-auth": "4.6.0",
73
75
  "chokidar": "3.5.3",
74
76
  "dotenv": "16.3.1",
75
77
  "next": "13.5.4",
@@ -81,11 +83,13 @@
81
83
  "react-dom": "18.2.0",
82
84
  "react-icons": "4.12.0",
83
85
  "swr": "2.2.4",
86
+ "uuid": "13.0.0",
84
87
  "yaml": "2.3.4",
85
88
  "yargs": "17.7.2"
86
89
  },
87
90
  "devDependencies": {
88
91
  "@next/eslint-plugin-next": "13.5.4",
92
+ "jest": "28.1.3",
89
93
  "less": "4.1.3",
90
94
  "less-loader": "11.1.3",
91
95
  "next-with-less": "3.0.1",
package/pages/404.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2024 Lowdefy, Inc
2
+ Copyright 2020-2026 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
package/pages/[pageId].js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2024 Lowdefy, Inc
2
+ Copyright 2020-2026 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
package/pages/_app.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2024 Lowdefy, Inc
2
+ Copyright 2020-2026 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
14
14
  limitations under the License.
15
15
  */
16
16
 
17
- import React, { Suspense, useRef } from 'react';
17
+ import React, { Suspense, useCallback, useRef } from 'react';
18
18
  import dynamic from 'next/dynamic';
19
19
 
20
20
  import { ErrorBoundary } from '@lowdefy/block-utils';
@@ -26,10 +26,23 @@ import '../build/plugins/styles.less';
26
26
 
27
27
  function App({ Component }) {
28
28
  const lowdefyRef = useRef({});
29
+
30
+ const handleError = useCallback((error) => {
31
+ if (lowdefyRef.current?._internal?.handleError) {
32
+ lowdefyRef.current._internal.handleError(error);
33
+ } else {
34
+ console.error(error);
35
+ }
36
+ }, []);
37
+
29
38
  return (
30
- <ErrorBoundary fullPage>
39
+ <ErrorBoundary fullPage onError={handleError}>
31
40
  <Suspense fallback="">
32
- <Auth>{(auth) => <Component auth={auth} lowdefy={lowdefyRef.current} />}</Auth>
41
+ <Auth>
42
+ {(auth) => {
43
+ return <Component auth={auth} lowdefy={lowdefyRef.current} />;
44
+ }}
45
+ </Auth>
33
46
  </Suspense>
34
47
  </ErrorBoundary>
35
48
  );
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2024 Lowdefy, Inc
2
+ Copyright 2020-2026 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -17,8 +17,8 @@
17
17
  import React from 'react';
18
18
  import Document, { Html, Head, Main, NextScript } from 'next/document';
19
19
 
20
- import appJson from '../build/app.json';
21
- import lowdefyConfig from '../build/config.json';
20
+ import appJson from '../lib/build/app.js';
21
+ import lowdefyConfig from '../lib/build/config.js';
22
22
 
23
23
  const basePath = lowdefyConfig.basePath ?? '';
24
24
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2024 Lowdefy, Inc
2
+ Copyright 2020-2026 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -17,7 +17,8 @@
17
17
  import NextAuth from 'next-auth';
18
18
 
19
19
  import apiWrapper from '../../../lib/server/apiWrapper.js';
20
- import authJson from '../../../build/auth.json';
20
+ import authJson from '../../../lib/build/auth.js';
21
+ import getMockSession from '../../../lib/server/auth/getMockSession.js';
21
22
 
22
23
  async function handler({ context, req, res }) {
23
24
  if (authJson.configured !== true) {
@@ -31,6 +32,16 @@ async function handler({ context, req, res }) {
31
32
  if (req.method === 'HEAD') {
32
33
  return res.status(200).end();
33
34
  }
35
+
36
+ // Return mock session for session requests (dev server only)
37
+ const nextauthPath = req.query.nextauth ?? [];
38
+ if (nextauthPath[0] === 'session') {
39
+ const mockSession = await getMockSession();
40
+ if (mockSession) {
41
+ return res.status(200).json(mockSession);
42
+ }
43
+ }
44
+
34
45
  return NextAuth(req, res, context.authOptions);
35
46
  }
36
47
 
@@ -0,0 +1,45 @@
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 { logClientError } from '@lowdefy/api';
18
+
19
+ import apiWrapper from '../../lib/server/apiWrapper.js';
20
+
21
+ async function handler({ context, req, res }) {
22
+ if (req.method !== 'POST') {
23
+ throw new Error('Only POST requests are supported.');
24
+ }
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
+ const { error, ...response } = await logClientError(context, req.body);
42
+ res.status(200).json(response);
43
+ }
44
+
45
+ export default apiWrapper(handler);
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2024 Lowdefy, Inc
2
+ Copyright 2020-2026 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2024 Lowdefy, Inc
2
+ Copyright 2020-2026 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -0,0 +1,42 @@
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 fs from 'fs';
18
+ import path from 'path';
19
+
20
+ async function handler(req, res) {
21
+ const { env } = req.query;
22
+
23
+ if (env !== 'client' && env !== 'server') {
24
+ res.status(400).send('Invalid env parameter. Use "client" or "server".');
25
+ return;
26
+ }
27
+
28
+ const fileName = env === 'client' ? 'clientJsMap.js' : 'serverJsMap.js';
29
+ const filePath = path.join(process.cwd(), 'build', 'plugins', 'operators', fileName);
30
+
31
+ try {
32
+ const content = fs.readFileSync(filePath, 'utf8');
33
+ res.setHeader('Content-Type', 'application/javascript');
34
+ res.status(200).send(content);
35
+ } catch {
36
+ // Return empty default export if file doesn't exist yet
37
+ res.setHeader('Content-Type', 'application/javascript');
38
+ res.status(200).send('export default {};');
39
+ }
40
+ }
41
+
42
+ export default handler;
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2024 Lowdefy, Inc
2
+ Copyright 2020-2026 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -17,11 +17,49 @@
17
17
  import { getPageConfig } from '@lowdefy/api';
18
18
 
19
19
  import apiWrapper from '../../../lib/server/apiWrapper.js';
20
+ import buildPageIfNeeded from '../../../lib/server/jitPageBuilder.js';
20
21
 
21
22
  async function handler({ context, req, res }) {
22
23
  const { pageId } = req.query;
24
+
25
+ // Attempt JIT build if page not yet compiled
26
+ let buildResult;
27
+ try {
28
+ buildResult = await buildPageIfNeeded({
29
+ pageId,
30
+ buildDirectory: context.buildDirectory,
31
+ configDirectory: context.configDirectory,
32
+ });
33
+ } catch (error) {
34
+ const rawErrors = error.buildErrors ?? [error];
35
+ const errors = [];
36
+ for (const err of rawErrors) {
37
+ await context.handleError(err);
38
+ errors.push({
39
+ type: err.name ?? 'Error',
40
+ message: err.message,
41
+ source: err.source ?? null,
42
+ });
43
+ }
44
+ res.status(500).json({
45
+ buildError: true,
46
+ errors,
47
+ // Keep top-level message/source for backward compatibility
48
+ message: error.message,
49
+ source: error.source ?? null,
50
+ });
51
+ return;
52
+ }
53
+
54
+ if (buildResult && buildResult.installing) {
55
+ res.status(200).json({
56
+ installing: true,
57
+ packages: buildResult.packages,
58
+ });
59
+ return;
60
+ }
61
+
23
62
  const pageConfig = await getPageConfig(context, { pageId });
24
- // TODO: Do we log here?
25
63
  if (pageConfig === null) {
26
64
  res.status(404).send('Page not found.');
27
65
  } else {
package/pages/api/ping.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2024 Lowdefy, Inc
2
+ Copyright 2020-2026 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2024 Lowdefy, Inc
2
+ Copyright 2020-2026 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -31,12 +31,15 @@ const handler = async (req, res) => {
31
31
  try {
32
32
  res.write(`event: reload\ndata: ${JSON.stringify({})}\n\n`);
33
33
  } catch (e) {
34
- console.log(e);
34
+ console.error(e);
35
35
  }
36
36
  };
37
37
  watcher.on('add', () => reload());
38
38
  watcher.on('change', () => reload());
39
- watcher.on('unlink', () => reload());
39
+ // Do not reload on unlink cleanBuildDirectory deletes build/reload during
40
+ // skeleton rebuilds, which would send a premature SSE event before the new
41
+ // build artifacts are written. The real reload comes via add/change when
42
+ // reloadClients() creates the file after the build completes.
40
43
 
41
44
  // TODO: This isn't working.
42
45
  req.on('close', () => {
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2024 Lowdefy, Inc
2
+ Copyright 2020-2026 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -23,8 +23,11 @@ async function handler({ context, req, res }) {
23
23
  throw new Error('Only POST requests are supported.');
24
24
  }
25
25
  const { pageId, requestId } = req.query;
26
- const { blockId, payload } = req.body;
27
- context.logger.info({ event: 'call_request', pageId, requestId, blockId });
26
+ const { actionId, blockId, payload } = req.body;
27
+ context.logger.info(
28
+ { color: 'gray' },
29
+ `Request: ${pageId} · ${blockId} · ${actionId} → ${requestId}`
30
+ );
28
31
  const response = await callRequest(context, { blockId, pageId, payload, requestId });
29
32
  res.status(200).json(response);
30
33
  }
package/pages/api/root.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2024 Lowdefy, Inc
2
+ Copyright 2020-2026 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
package/pages/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2024 Lowdefy, Inc
2
+ Copyright 2020-2026 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -1,40 +0,0 @@
1
- /*
2
- Copyright 2020-2024 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
- function logError({ context, error }) {
18
- try {
19
- const { user = {} } = context;
20
-
21
- context.logger.error({
22
- err: error,
23
- user: {
24
- id: user.id,
25
- roles: user.roles,
26
- sub: user.sub,
27
- session_id: user.session_id,
28
- },
29
- url: context.req.url,
30
- method: context.req.method,
31
- resolvedUrl: context.nextContext?.resolvedUrl,
32
- });
33
- } catch (e) {
34
- console.error(error);
35
- console.error('An error occurred while logging the error.');
36
- console.error(e);
37
- }
38
- }
39
-
40
- export default logError;
@@ -1,33 +0,0 @@
1
- /*
2
- Copyright 2020-2024 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
- function createStdOutLineHandler({ context }) {
18
- const { logger } = context;
19
- function stdOutLineHandler(line) {
20
- try {
21
- const { level, name, time, rid, ...msgObj } = JSON.parse(line);
22
- if (level) {
23
- const print = level === 30 ? 'log' : logger.levels.labels[level];
24
- logger[logger.levels.labels[level]]({ print }, JSON.stringify(msgObj));
25
- }
26
- } catch (error) {
27
- logger.info({ print: 'log' }, line);
28
- }
29
- }
30
- return stdOutLineHandler;
31
- }
32
-
33
- export default createStdOutLineHandler;