@lowdefy/client 0.0.0-experimental-20260114142524 → 0.0.0-experimental-20260122121633

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.
@@ -0,0 +1,40 @@
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
+ */ import { ConfigError } from '@lowdefy/helpers';
16
+ function createLogError(lowdefy) {
17
+ // Track logged errors for deduplication
18
+ const loggedErrors = new Set();
19
+ return async function logError(error) {
20
+ // Deduplicate by message + configKey
21
+ const errorKey = `${error.message}:${error.configKey || ''}`;
22
+ if (loggedErrors.has(errorKey)) {
23
+ return;
24
+ }
25
+ loggedErrors.add(errorKey);
26
+ // Service errors just log without resolution
27
+ if (error.isServiceError === true) {
28
+ console.error(`[Service Error] ${error.message}`);
29
+ return;
30
+ }
31
+ // Wrap in ConfigError if not already (handles plain errors with configKey attached)
32
+ const configError = error instanceof ConfigError ? error : ConfigError.from({
33
+ error,
34
+ configKey: error.configKey
35
+ });
36
+ // Resolve location and log (non-blocking)
37
+ await configError.log(lowdefy);
38
+ };
39
+ }
40
+ export default createLogError;
@@ -17,74 +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 createLogError from './createLogError.js';
20
21
  import setupLink from './setupLink.js';
21
- function createLogError(lowdefy, windowObj) {
22
- // Track logged errors for deduplication
23
- const loggedErrors = new Set();
24
- return async function logError(error) {
25
- // Deduplicate by message + configKey
26
- const errorKey = `${error.message}:${error.configKey || ''}`;
27
- if (loggedErrors.has(errorKey)) {
28
- return;
29
- }
30
- loggedErrors.add(errorKey);
31
- const isServiceError = error.isServiceError === true;
32
- const errorData = {
33
- message: error.message,
34
- name: error.name,
35
- configKey: error.configKey,
36
- isServiceError,
37
- pageId: lowdefy.pageId,
38
- timestamp: new Date().toISOString()
39
- };
40
- // Try to send to server first with 1s timeout (same-origin)
41
- const controller = new AbortController();
42
- const timeoutId = setTimeout(()=>controller.abort(), 1000);
43
- try {
44
- const response = await windowObj.fetch(`${lowdefy.basePath}/api/client-error`, {
45
- method: 'POST',
46
- headers: {
47
- 'Content-Type': 'application/json'
48
- },
49
- body: JSON.stringify(errorData),
50
- signal: controller.signal,
51
- credentials: 'same-origin'
52
- });
53
- clearTimeout(timeoutId);
54
- if (response.ok) {
55
- const result = await response.json();
56
- const errorType = result.isServiceError ? 'Service Error' : 'Config Error';
57
- if (result.isServiceError) {
58
- // Service errors don't need config location
59
- console.error(`[${errorType}] ${error.message}`);
60
- } else {
61
- // Config errors show location info
62
- let vscodeLink = '';
63
- if (result.link) {
64
- const match = result.link.match(/^(.+):(\d+)$/);
65
- if (match) {
66
- const [, filePath, line] = match;
67
- vscodeLink = `vscode://file${filePath}?line=${line}`;
68
- } else {
69
- vscodeLink = `vscode://file${result.link}`;
70
- }
71
- }
72
- const source = result.source ? `${result.source} at ${result.config}` : '';
73
- console.error(`[${errorType}] ${error.message}\n ${source}\n ${vscodeLink}`);
74
- }
75
- } else {
76
- // Server returned error - log locally as fallback
77
- const errorType = isServiceError ? 'Service Error' : 'Config Error';
78
- console.error(`[${errorType}] ${error.message}`);
79
- }
80
- } catch (fetchError) {
81
- clearTimeout(timeoutId);
82
- // Server unreachable or timeout - log locally as fallback
83
- const errorType = isServiceError ? 'Service Error' : 'Config Error';
84
- console.error(`[${errorType}] ${error.message}`);
85
- }
86
- };
87
- }
88
22
  function initLowdefyContext({ auth, Components, config, lowdefy, router, stage, types, window }) {
89
23
  if (!lowdefy._internal?.initialised) {
90
24
  lowdefy._internal = {
@@ -125,7 +59,7 @@ function initLowdefyContext({ auth, Components, config, lowdefy, router, stage,
125
59
  lowdefy._internal.components.Link = createLinkComponent(lowdefy, Components.Link);
126
60
  lowdefy._internal.link = setupLink(lowdefy);
127
61
  lowdefy._internal.updateBlock = (blockId)=>lowdefy._internal.updaters[blockId] && lowdefy._internal.updaters[blockId]();
128
- lowdefy._internal.logError = createLogError(lowdefy, window);
62
+ lowdefy._internal.logError = createLogError(lowdefy);
129
63
  if (stage === 'dev') {
130
64
  window.lowdefy = lowdefy;
131
65
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/client",
3
- "version": "0.0.0-experimental-20260114142524",
3
+ "version": "0.0.0-experimental-20260122121633",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Lowdefy Client",
6
6
  "homepage": "https://lowdefy.com",
@@ -34,10 +34,10 @@
34
34
  ],
35
35
  "dependencies": {
36
36
  "@ant-design/icons": "4.8.0",
37
- "@lowdefy/block-utils": "0.0.0-experimental-20260114142524",
38
- "@lowdefy/engine": "0.0.0-experimental-20260114142524",
39
- "@lowdefy/helpers": "0.0.0-experimental-20260114142524",
40
- "@lowdefy/layout": "0.0.0-experimental-20260114142524",
37
+ "@lowdefy/block-utils": "0.0.0-experimental-20260122121633",
38
+ "@lowdefy/engine": "0.0.0-experimental-20260122121633",
39
+ "@lowdefy/helpers": "0.0.0-experimental-20260122121633",
40
+ "@lowdefy/layout": "0.0.0-experimental-20260122121633",
41
41
  "classnames": "2.3.2",
42
42
  "react": "18.2.0",
43
43
  "react-dom": "18.2.0"
@@ -45,7 +45,7 @@
45
45
  "devDependencies": {
46
46
  "@emotion/jest": "11.10.5",
47
47
  "@jest/globals": "28.1.3",
48
- "@lowdefy/jest-yaml-transform": "0.0.0-experimental-20260114142524",
48
+ "@lowdefy/jest-yaml-transform": "0.0.0-experimental-20260122121633",
49
49
  "@swc/cli": "0.1.63",
50
50
  "@swc/core": "1.3.99",
51
51
  "@swc/jest": "0.2.29",