@lowdefy/client 4.5.2 → 4.7.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/dist/Client.js +1 -1
- package/dist/Context.js +1 -1
- package/dist/DisplayMessage.js +1 -1
- package/dist/Head.js +1 -1
- package/dist/MountEvents.js +1 -1
- package/dist/auth/createAuthMethods.js +2 -2
- package/dist/block/Block.js +32 -3
- package/dist/block/CategorySwitch.js +1 -1
- package/dist/block/Container.js +1 -1
- package/dist/block/InputContainer.js +1 -1
- package/dist/block/List.js +1 -1
- package/dist/block/LoadingBlock.js +1 -1
- package/dist/block/LoadingContainer.js +1 -1
- package/dist/block/LoadingList.js +1 -1
- package/dist/createCallAPI.js +1 -1
- package/dist/createCallRequest.js +4 -2
- package/dist/createHandleError.js +71 -0
- package/dist/createIcon.js +1 -1
- package/dist/index.js +1 -1
- package/dist/initLowdefyContext.js +6 -2
- package/dist/request.js +6 -5
- package/dist/setupLink.js +1 -1
- package/dist/style.less +1 -1
- package/package.json +8 -6
package/dist/Client.js
CHANGED
package/dist/Context.js
CHANGED
package/dist/DisplayMessage.js
CHANGED
package/dist/Head.js
CHANGED
package/dist/MountEvents.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
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.
|
|
@@ -20,7 +20,7 @@ function getCallbackUrl({ lowdefy, callbackUrl = {} }) {
|
|
|
20
20
|
!pageId,
|
|
21
21
|
!url
|
|
22
22
|
].filter((v)=>!v).length > 1) {
|
|
23
|
-
throw Error(`Invalid Link: To avoid ambiguity, only one of 'home', 'pageId' or 'url' can be defined.`);
|
|
23
|
+
throw new Error(`Invalid Link: To avoid ambiguity, only one of 'home', 'pageId' or 'url' can be defined.`);
|
|
24
24
|
}
|
|
25
25
|
const query = type.isNone(urlQuery) ? '' : `${urlQueryFn.stringify(urlQuery)}`;
|
|
26
26
|
if (home === true) {
|
package/dist/block/Block.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
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.
|
|
@@ -12,14 +12,43 @@
|
|
|
12
12
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
|
-
*/ import React, { useState } from 'react';
|
|
15
|
+
*/ import React, { useEffect, useRef, useState } from 'react';
|
|
16
16
|
import { ErrorBoundary } from '@lowdefy/block-utils';
|
|
17
17
|
import CategorySwitch from './CategorySwitch.js';
|
|
18
18
|
import MountEvents from '../MountEvents.js';
|
|
19
19
|
const Block = ({ block, Blocks, context, lowdefy, parentLoading })=>{
|
|
20
20
|
const [updates, setUpdate] = useState(0);
|
|
21
|
+
const loggedErrorsRef = useRef(new Set());
|
|
21
22
|
lowdefy._internal.updaters[block.id] = ()=>setUpdate(updates + 1);
|
|
22
|
-
|
|
23
|
+
const handleError = (error)=>{
|
|
24
|
+
if (lowdefy._internal.handleError) {
|
|
25
|
+
lowdefy._internal.handleError(error);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
// Log parse errors to server
|
|
29
|
+
useEffect(()=>{
|
|
30
|
+
if (block.eval?.parseErrors && lowdefy._internal.handleError) {
|
|
31
|
+
block.eval.parseErrors.forEach((error)=>{
|
|
32
|
+
// Use error message as key to avoid duplicate logs
|
|
33
|
+
const errorKey = `${block.id}:${error.message}`;
|
|
34
|
+
if (!loggedErrorsRef.current.has(errorKey)) {
|
|
35
|
+
loggedErrorsRef.current.add(errorKey);
|
|
36
|
+
lowdefy._internal.handleError(error);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}, [
|
|
41
|
+
block.eval?.parseErrors,
|
|
42
|
+
block.id,
|
|
43
|
+
lowdefy._internal
|
|
44
|
+
]);
|
|
45
|
+
return /*#__PURE__*/ React.createElement(ErrorBoundary, {
|
|
46
|
+
blockId: block.blockId,
|
|
47
|
+
blockType: block.type,
|
|
48
|
+
configKey: block.eval?.configKey,
|
|
49
|
+
onError: handleError,
|
|
50
|
+
properties: block.eval?.properties
|
|
51
|
+
}, /*#__PURE__*/ React.createElement(MountEvents, {
|
|
23
52
|
context: context,
|
|
24
53
|
triggerEvent: async ()=>{
|
|
25
54
|
context._internal.lowdefy._internal.progress.dispatch({
|
package/dist/block/Container.js
CHANGED
package/dist/block/List.js
CHANGED
package/dist/createCallAPI.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
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,11 +14,13 @@
|
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import request from './request.js';
|
|
16
16
|
function createCallRequest({ basePath }) {
|
|
17
|
-
function callRequest({ pageId, payload, requestId }) {
|
|
17
|
+
function callRequest({ actionId, blockId, pageId, payload, requestId }) {
|
|
18
18
|
return request({
|
|
19
19
|
url: `${basePath}/api/request/${pageId}/${requestId}`,
|
|
20
20
|
method: 'POST',
|
|
21
21
|
body: {
|
|
22
|
+
actionId,
|
|
23
|
+
blockId,
|
|
22
24
|
payload
|
|
23
25
|
}
|
|
24
26
|
});
|
|
@@ -0,0 +1,71 @@
|
|
|
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
|
+
*/ import { UserError } from '@lowdefy/errors';
|
|
16
|
+
import { serializer } from '@lowdefy/helpers';
|
|
17
|
+
function createHandleError(lowdefy) {
|
|
18
|
+
const loggedErrors = new Set();
|
|
19
|
+
const logger = lowdefy._internal.logger;
|
|
20
|
+
return async function handleError(error) {
|
|
21
|
+
const errorKey = `${error.message}:${error.configKey || ''}`;
|
|
22
|
+
if (loggedErrors.has(errorKey)) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
loggedErrors.add(errorKey);
|
|
26
|
+
// UserError is client-only — log to browser console, never send to server
|
|
27
|
+
if (error instanceof UserError) {
|
|
28
|
+
logger.error(error);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
// Send known error types to server for logging with location resolution
|
|
32
|
+
if (error.isLowdefyError) {
|
|
33
|
+
// Server-originated errors already have source resolved — just display locally
|
|
34
|
+
if (error.source) {
|
|
35
|
+
logger.error(error);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
// Client-originated errors — send to server for logging + location resolution
|
|
39
|
+
try {
|
|
40
|
+
const serialized = serializer.serialize(error);
|
|
41
|
+
const response = await fetch(`${lowdefy?.basePath ?? ''}/api/client-error`, {
|
|
42
|
+
method: 'POST',
|
|
43
|
+
headers: {
|
|
44
|
+
'Content-Type': 'application/json'
|
|
45
|
+
},
|
|
46
|
+
body: JSON.stringify(serialized),
|
|
47
|
+
credentials: 'same-origin'
|
|
48
|
+
});
|
|
49
|
+
if (response.ok) {
|
|
50
|
+
const { source: resolvedSource, configError: serializedConfigError } = await response.json();
|
|
51
|
+
if (resolvedSource) {
|
|
52
|
+
error.source = resolvedSource;
|
|
53
|
+
}
|
|
54
|
+
// If server produced a consolidated ConfigError, log it and return early
|
|
55
|
+
// (cause chain includes original error)
|
|
56
|
+
if (serializedConfigError) {
|
|
57
|
+
logger.error(serializer.deserialize(serializedConfigError));
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
} catch {
|
|
62
|
+
// Server logging failed - continue with local console
|
|
63
|
+
}
|
|
64
|
+
logger.error(error);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
// Other errors - just log locally
|
|
68
|
+
logger.error(error);
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
export default createHandleError;
|
package/dist/createIcon.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
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,6 +17,8 @@ import createAuthMethods from './auth/createAuthMethods.js';
|
|
|
17
17
|
import createCallRequest from './createCallRequest.js';
|
|
18
18
|
import createIcon from './createIcon.js';
|
|
19
19
|
import createLinkComponent from './createLinkComponent.js';
|
|
20
|
+
import createHandleError from './createHandleError.js';
|
|
21
|
+
import { createBrowserLogger } from '@lowdefy/logger/browser';
|
|
20
22
|
import setupLink from './setupLink.js';
|
|
21
23
|
function initLowdefyContext({ auth, Components, config, lowdefy, router, stage, types, window }) {
|
|
22
24
|
if (!lowdefy._internal?.initialised) {
|
|
@@ -58,7 +60,9 @@ function initLowdefyContext({ auth, Components, config, lowdefy, router, stage,
|
|
|
58
60
|
lowdefy._internal.components.Link = createLinkComponent(lowdefy, Components.Link);
|
|
59
61
|
lowdefy._internal.link = setupLink(lowdefy);
|
|
60
62
|
lowdefy._internal.updateBlock = (blockId)=>lowdefy._internal.updaters[blockId] && lowdefy._internal.updaters[blockId]();
|
|
61
|
-
|
|
63
|
+
lowdefy._internal.logger = createBrowserLogger();
|
|
64
|
+
lowdefy._internal.handleError = createHandleError(lowdefy);
|
|
65
|
+
if (stage === 'dev' || stage === 'e2e') {
|
|
62
66
|
window.lowdefy = lowdefy;
|
|
63
67
|
}
|
|
64
68
|
}
|
package/dist/request.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
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.
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
|
-
*/
|
|
15
|
+
*/ import { serializer } from '@lowdefy/helpers';
|
|
16
|
+
async function request({ url, method = 'GET', body }) {
|
|
16
17
|
const res = await fetch(url, {
|
|
17
18
|
method,
|
|
18
19
|
headers: {
|
|
@@ -21,10 +22,10 @@
|
|
|
21
22
|
body: JSON.stringify(body)
|
|
22
23
|
});
|
|
23
24
|
if (!res.ok) {
|
|
24
|
-
// TODO: check
|
|
25
25
|
const body = await res.json();
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
if (body?.['~e']) {
|
|
27
|
+
throw serializer.deserialize(body);
|
|
28
|
+
}
|
|
28
29
|
throw new Error(body.message || 'Request error');
|
|
29
30
|
}
|
|
30
31
|
return res.json();
|
package/dist/setupLink.js
CHANGED
package/dist/style.less
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lowdefy/client",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.7.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "Lowdefy Client",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
|
@@ -34,10 +34,12 @@
|
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@ant-design/icons": "4.8.0",
|
|
37
|
-
"@lowdefy/block-utils": "4.
|
|
38
|
-
"@lowdefy/engine": "4.
|
|
39
|
-
"@lowdefy/
|
|
40
|
-
"@lowdefy/
|
|
37
|
+
"@lowdefy/block-utils": "4.7.0",
|
|
38
|
+
"@lowdefy/engine": "4.7.0",
|
|
39
|
+
"@lowdefy/errors": "4.7.0",
|
|
40
|
+
"@lowdefy/helpers": "4.7.0",
|
|
41
|
+
"@lowdefy/layout": "4.7.0",
|
|
42
|
+
"@lowdefy/logger": "4.7.0",
|
|
41
43
|
"classnames": "2.3.2",
|
|
42
44
|
"react": "18.2.0",
|
|
43
45
|
"react-dom": "18.2.0"
|
|
@@ -45,7 +47,7 @@
|
|
|
45
47
|
"devDependencies": {
|
|
46
48
|
"@emotion/jest": "11.10.5",
|
|
47
49
|
"@jest/globals": "28.1.3",
|
|
48
|
-
"@lowdefy/jest-yaml-transform": "4.
|
|
50
|
+
"@lowdefy/jest-yaml-transform": "4.7.0",
|
|
49
51
|
"@swc/cli": "0.1.63",
|
|
50
52
|
"@swc/core": "1.3.99",
|
|
51
53
|
"@swc/jest": "0.2.29",
|