@lowdefy/server-e2e 0.0.0-experimental-20260720072521 → 0.0.0-experimental-20260720135014
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/.eslintrc.yaml +1 -0
- package/lib/build/app.js +1 -8
- package/lib/build/appMeta.js +1 -8
- package/lib/build/auth.js +1 -8
- package/lib/build/config.js +1 -8
- package/lib/build/logger.js +1 -8
- package/lib/build/theme.js +1 -8
- package/lib/client/Page.js +57 -0
- package/{src/lib/getPathSegments.js → lib/client/auth/Auth.js} +22 -7
- package/lib/server/apiWrapper.js +80 -0
- package/lib/server/auth/{getUser.js → getServerSession.js} +7 -10
- package/lib/server/log/logRequest.js +3 -1
- package/lib/server/serverSidePropsWrapper.js +64 -0
- package/lowdefy/createCustomPluginTypesMap.mjs +2 -3
- package/lowdefy/createCustomPluginTypesMap.test.mjs +0 -2
- package/next.config.js +20 -0
- package/package.json +41 -50
- package/package.original.json +49 -53
- package/pages/404.js +49 -0
- package/pages/[[...pageId]].js +85 -0
- package/{client/App.jsx → pages/_app.js} +30 -45
- package/pages/_document.js +106 -0
- package/{src/routes/sessionMock.js → pages/api/auth/session.js} +5 -7
- package/{src/routes/clientError.js → pages/api/client-error.js} +18 -14
- package/{src/routes/endpoints.js → pages/api/endpoints/[...endpointId].js} +7 -8
- package/{src/routes/request.js → pages/api/request/[...path].js} +10 -10
- package/{src/routes → pages/api}/usage.js +8 -11
- package/client/Page.jsx +0 -93
- package/client/main.jsx +0 -39
- package/lib/build/i18n.js +0 -26
- package/lib/client/auth/Auth.jsx +0 -69
- package/postcss.config.cjs +0 -1
- package/src/app.js +0 -80
- package/src/html/getAssets.js +0 -45
- package/src/html/renderPage.js +0 -78
- package/src/html/template.js +0 -94
- package/src/index.js +0 -40
- package/src/lib/safeScriptJson.js +0 -38
- package/src/middleware/apiContext.js +0 -87
- package/src/middleware/errorHandler.js +0 -45
- package/src/routes/apiPage.js +0 -35
- package/src/routes/user.js +0 -27
- package/src/routes/websocket.js +0 -46
- package/vite.config.js +0 -45
|
@@ -1,87 +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 path from 'node:path';
|
|
18
|
-
import { createApiContext, normalizeInjectedCaller } from '@lowdefy/api';
|
|
19
|
-
import { v4 as uuid } from 'uuid';
|
|
20
|
-
|
|
21
|
-
import agents from '../../build/plugins/agents.js';
|
|
22
|
-
import appMeta from '../../lib/build/appMeta.js';
|
|
23
|
-
import config from '../../lib/build/config.js';
|
|
24
|
-
import connections from '../../build/plugins/connections.js';
|
|
25
|
-
import createHandleError from '../../lib/server/log/createHandleError.js';
|
|
26
|
-
import createLogger from '../../lib/server/log/createLogger.js';
|
|
27
|
-
import fileCache from '../../lib/server/fileCache.js';
|
|
28
|
-
import getE2eSecrets from '../../lib/server/getE2eSecrets.js';
|
|
29
|
-
import getUser from '../../lib/server/auth/getUser.js';
|
|
30
|
-
import i18nConfig from '../../lib/build/i18n.js';
|
|
31
|
-
import jsMap from '../../build/plugins/operators/serverJsMap.js';
|
|
32
|
-
import logRequest from '../../lib/server/log/logRequest.js';
|
|
33
|
-
import operators from '../../build/plugins/operators/server.js';
|
|
34
|
-
import steps from '../../build/plugins/steps.js';
|
|
35
|
-
import websockets from '../../build/plugins/websockets.js';
|
|
36
|
-
|
|
37
|
-
const secrets = getE2eSecrets();
|
|
38
|
-
|
|
39
|
-
// Replaces lib/server/apiWrapper.js. Builds the request context consumed by
|
|
40
|
-
// @lowdefy/api functions. Errors thrown by handlers are routed by Hono to the
|
|
41
|
-
// app-level error handler (src/middleware/errorHandler.js), which reads this
|
|
42
|
-
// context back from the Hono context.
|
|
43
|
-
function apiContext() {
|
|
44
|
-
return async function apiContextMiddleware(c, next) {
|
|
45
|
-
// The page-route mount ('/*') also matches /api/* paths that already
|
|
46
|
-
// built a context — never build twice for one request.
|
|
47
|
-
if (c.get('lowdefyContext')) {
|
|
48
|
-
return next();
|
|
49
|
-
}
|
|
50
|
-
const rid = uuid();
|
|
51
|
-
const context = {
|
|
52
|
-
rid,
|
|
53
|
-
agents,
|
|
54
|
-
appMeta,
|
|
55
|
-
buildDirectory: path.join(process.cwd(), 'build'),
|
|
56
|
-
config,
|
|
57
|
-
configDirectory: process.env.LOWDEFY_DIRECTORY_CONFIG || process.cwd(),
|
|
58
|
-
connections,
|
|
59
|
-
fileCache,
|
|
60
|
-
headers: c.req.header(),
|
|
61
|
-
i18n: i18nConfig,
|
|
62
|
-
jsMap,
|
|
63
|
-
logger: createLogger({ rid }),
|
|
64
|
-
operators,
|
|
65
|
-
req: {
|
|
66
|
-
url: c.req.path,
|
|
67
|
-
method: c.req.method,
|
|
68
|
-
hostname: c.req.header('host'),
|
|
69
|
-
},
|
|
70
|
-
secrets,
|
|
71
|
-
steps,
|
|
72
|
-
websockets,
|
|
73
|
-
};
|
|
74
|
-
context.handleError = createHandleError({ context });
|
|
75
|
-
// The cookie user is a pre-resolved caller substituting for
|
|
76
|
-
// resolveAuthentication - normalizeInjectedCaller floors it to the
|
|
77
|
-
// resolved-caller shape. An absent cookie stays a logged-out (null) caller.
|
|
78
|
-
const user = getUser(c);
|
|
79
|
-
context.user = user ? normalizeInjectedCaller(user) : null;
|
|
80
|
-
createApiContext(context);
|
|
81
|
-
logRequest({ context });
|
|
82
|
-
c.set('lowdefyContext', context);
|
|
83
|
-
return next();
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export default apiContext;
|
|
@@ -1,45 +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 { serializer } from '@lowdefy/helpers';
|
|
18
|
-
|
|
19
|
-
// Hono routes every handler error to the app-level error handler — upstream
|
|
20
|
-
// middleware try/catch never sees them (compose catches per dispatch level).
|
|
21
|
-
// API routes get the serialized error JSON the old apiWrapper returned;
|
|
22
|
-
// page routes get a plain 500.
|
|
23
|
-
function createErrorHandler({ basePath = '', logger }) {
|
|
24
|
-
return async function errorHandler(error, c) {
|
|
25
|
-
const context = c.get('lowdefyContext');
|
|
26
|
-
if (context) {
|
|
27
|
-
await context.handleError(error);
|
|
28
|
-
} else {
|
|
29
|
-
logger.error(error);
|
|
30
|
-
}
|
|
31
|
-
const path = basePath ? c.req.path.replace(basePath, '') : c.req.path;
|
|
32
|
-
if (path.startsWith('/api/')) {
|
|
33
|
-
const serialized = serializer.serialize(error);
|
|
34
|
-
if (serialized?.['~e']) {
|
|
35
|
-
delete serialized['~e'].received;
|
|
36
|
-
delete serialized['~e'].stack;
|
|
37
|
-
delete serialized['~e'].configKey;
|
|
38
|
-
}
|
|
39
|
-
return c.json(serialized, 500);
|
|
40
|
-
}
|
|
41
|
-
return c.text('Internal Server Error', 500);
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export default createErrorHandler;
|
package/src/routes/apiPage.js
DELETED
|
@@ -1,35 +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 } from '@lowdefy/api';
|
|
18
|
-
|
|
19
|
-
import getPathSegments from '../lib/getPathSegments.js';
|
|
20
|
-
|
|
21
|
-
// Page config as JSON for client-side SPA navigation. The first page load is
|
|
22
|
-
// served embedded in the HTML; subsequent navigations fetch from here.
|
|
23
|
-
async function apiPageHandler(c) {
|
|
24
|
-
const context = c.get('lowdefyContext');
|
|
25
|
-
const pageId = getPathSegments(c, '/api/page/').join('/');
|
|
26
|
-
const result = await getPageConfig(context, { pageId });
|
|
27
|
-
if (result.status !== 'ok') {
|
|
28
|
-
context.logger.info({ event: 'api_page_not_found', pageId });
|
|
29
|
-
return c.json({ pageConfig: null }, 404);
|
|
30
|
-
}
|
|
31
|
-
context.logger.info({ event: 'api_page_view', pageId });
|
|
32
|
-
return c.json({ pageConfig: result.pageConfig });
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export default apiPageHandler;
|
package/src/routes/user.js
DELETED
|
@@ -1,27 +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
|
-
// The resolved caller for the client - the same resolveAuthentication output
|
|
18
|
-
// the first page load embeds. The base session carries neither roles (read
|
|
19
|
-
// live from the active member row) nor the merged attributes bag, so the
|
|
20
|
-
// client re-syncs from here (UpdateSession) after a session change such as
|
|
21
|
-
// SetActiveOrganization.
|
|
22
|
-
async function userHandler(c) {
|
|
23
|
-
const context = c.get('lowdefyContext');
|
|
24
|
-
return c.json({ user: context.user ?? null });
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export default userHandler;
|
package/src/routes/websocket.js
DELETED
|
@@ -1,46 +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 { upgradeWebSocket } from '@hono/node-server';
|
|
18
|
-
import { createChannelRegistry, createWebSocketConnection } from '@lowdefy/api';
|
|
19
|
-
|
|
20
|
-
// One registry per server process — channels and their running source
|
|
21
|
-
// resolvers are shared across all websocket connections on this instance.
|
|
22
|
-
const registry = createChannelRegistry();
|
|
23
|
-
|
|
24
|
-
const websocketHandler = upgradeWebSocket((c) => {
|
|
25
|
-
const context = c.get('lowdefyContext');
|
|
26
|
-
let connection;
|
|
27
|
-
return {
|
|
28
|
-
onOpen(event, ws) {
|
|
29
|
-
connection = createWebSocketConnection(context, {
|
|
30
|
-
registry,
|
|
31
|
-
send: (message) => ws.send(message),
|
|
32
|
-
});
|
|
33
|
-
},
|
|
34
|
-
onMessage(event) {
|
|
35
|
-
connection?.handleMessage(event.data);
|
|
36
|
-
},
|
|
37
|
-
onClose() {
|
|
38
|
-
connection?.close();
|
|
39
|
-
},
|
|
40
|
-
onError(event) {
|
|
41
|
-
context.logger.debug({ event: 'ws_error' }, String(event?.error ?? 'WebSocket error'));
|
|
42
|
-
},
|
|
43
|
-
};
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
export default websocketHandler;
|
package/vite.config.js
DELETED
|
@@ -1,45 +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 fs from 'node:fs';
|
|
18
|
-
import { defineConfig } from 'vite';
|
|
19
|
-
import react from '@vitejs/plugin-react';
|
|
20
|
-
|
|
21
|
-
// basePath from the Lowdefy build — assets are served under it.
|
|
22
|
-
let basePath = '';
|
|
23
|
-
try {
|
|
24
|
-
const config = JSON.parse(fs.readFileSync('./build/config.json', 'utf8'));
|
|
25
|
-
basePath = config.basePath ?? '';
|
|
26
|
-
} catch (e) {
|
|
27
|
-
// No build yet (e.g. editor tooling) — default base.
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export default defineConfig(({ mode }) => ({
|
|
31
|
-
base: `${basePath}/`,
|
|
32
|
-
plugins: [react()],
|
|
33
|
-
define: {
|
|
34
|
-
// Vite does not replace process.env.NODE_ENV inside dependencies —
|
|
35
|
-
// plugin and client code branch on it.
|
|
36
|
-
'process.env.NODE_ENV': JSON.stringify(mode === 'production' ? 'production' : 'development'),
|
|
37
|
-
},
|
|
38
|
-
build: {
|
|
39
|
-
outDir: 'dist/client',
|
|
40
|
-
manifest: true,
|
|
41
|
-
rollupOptions: {
|
|
42
|
-
input: 'client/main.jsx',
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
}));
|