@lowdefy/engine 0.0.0-experimental-20251203205559 → 0.0.0-experimental-20260113081624

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/Actions.js CHANGED
@@ -15,6 +15,33 @@
15
15
  */ import { type } from '@lowdefy/helpers';
16
16
  import getActionMethods from './actions/getActionMethods.js';
17
17
  let Actions = class Actions {
18
+ // Log action errors appropriately:
19
+ // - Operator errors (have configKey): use logError for config tracing
20
+ // - Throw errors: log as regular error (intentional, no config trace)
21
+ // - Other errors: log as regular error
22
+ logActionError({ error, action }) {
23
+ const logError = this.context._internal.lowdefy._internal.logError;
24
+ const actionId = action?.id || '';
25
+ // Deduplicate by error message + action id
26
+ const errorKey = `${error?.message || ''}:${actionId}`;
27
+ if (this.loggedActionErrors.has(errorKey)) {
28
+ return;
29
+ }
30
+ this.loggedActionErrors.add(errorKey);
31
+ // Throw errors are intentional - don't log config location
32
+ if (action?.type === 'Throw' || error?.name === 'ThrowError') {
33
+ console.error(`[Throw Action] ${error?.message || 'Action error'}`);
34
+ return;
35
+ }
36
+ // Errors with configKey or isServiceError flag - use logError for proper handling
37
+ if ((error?.configKey || error?.isServiceError) && logError) {
38
+ logError(error);
39
+ return;
40
+ }
41
+ // Other errors - log with action type
42
+ const actionType = action?.type || 'Unknown';
43
+ console.error(`[${actionType} Action] ${error?.message || 'Action error'}`);
44
+ }
18
45
  async callAsyncAction({ action, arrayIndices, block, event, index, responses }) {
19
46
  try {
20
47
  const response = await this.callAction({
@@ -26,9 +53,10 @@ let Actions = class Actions {
26
53
  responses
27
54
  });
28
55
  responses[action.id] = response;
29
- } catch (error) {
30
- responses[action.id] = error;
31
- console.error(error);
56
+ } catch (err) {
57
+ // err is already {error, action, index} from callAction
58
+ responses[action.id] = err;
59
+ this.logActionError(err);
32
60
  }
33
61
  }
34
62
  async callActionLoop({ actions, arrayIndices, block, event, progress, responses }) {
@@ -56,12 +84,10 @@ let Actions = class Actions {
56
84
  });
57
85
  responses[action.id] = response;
58
86
  }
59
- } catch (error) {
60
- responses[action.id] = error;
61
- throw {
62
- error,
63
- action
64
- };
87
+ } catch (err) {
88
+ // err is already {error, action, index} from callAction
89
+ responses[action.id] = err;
90
+ throw err;
65
91
  }
66
92
  }
67
93
  }
@@ -78,7 +104,7 @@ let Actions = class Actions {
78
104
  progress
79
105
  });
80
106
  } catch (error) {
81
- console.error(error);
107
+ this.logActionError(error);
82
108
  try {
83
109
  await this.callActionLoop({
84
110
  actions: catchActions,
@@ -89,7 +115,7 @@ let Actions = class Actions {
89
115
  progress
90
116
  });
91
117
  } catch (errorCatch) {
92
- console.error(errorCatch);
118
+ this.logActionError(errorCatch);
93
119
  return {
94
120
  blockId: block.blockId,
95
121
  bounced: false,
@@ -128,9 +154,12 @@ let Actions = class Actions {
128
154
  }
129
155
  async callAction({ action, arrayIndices, block, event, index, progress, responses }) {
130
156
  if (!this.actions[action.type]) {
157
+ const error = new Error(`Invalid action type "${action.type}" at "${block.blockId}".`);
158
+ // Attach action's configKey so error can be traced to config
159
+ error.configKey = action['~k'];
131
160
  throw {
132
- error: new Error(`Invalid action type "${action.type}" at "${block.blockId}".`),
133
- type: action.type,
161
+ error,
162
+ action,
134
163
  index
135
164
  };
136
165
  }
@@ -142,9 +171,10 @@ let Actions = class Actions {
142
171
  location: block.blockId
143
172
  });
144
173
  if (parserErrors.length > 0) {
174
+ // Parser errors already have configKey from operator
145
175
  throw {
146
176
  error: parserErrors[0],
147
- type: action.type,
177
+ action,
148
178
  index
149
179
  };
150
180
  }
@@ -178,9 +208,9 @@ let Actions = class Actions {
178
208
  if (progress) {
179
209
  progress();
180
210
  }
181
- } catch (error) {
211
+ } catch (err) {
182
212
  responses[action.id] = {
183
- error,
213
+ error: err,
184
214
  index,
185
215
  type: action.type
186
216
  };
@@ -195,21 +225,22 @@ let Actions = class Actions {
195
225
  // this condition is very unlikely since parser errors usually occur in the first parse.
196
226
  throw {
197
227
  error: parserErrors[0],
198
- type: action.type,
228
+ action,
199
229
  index
200
230
  };
201
231
  }
202
232
  closeLoading();
203
233
  this.displayMessage({
204
- defaultMessage: error.message,
234
+ defaultMessage: err.message,
205
235
  duration: 6,
206
236
  hideExplicitly: true,
207
237
  message: (parsedMessages || {}).error,
208
238
  status: 'error'
209
239
  });
240
+ // Don't attach configKey to action errors (e.g. Throw) - they are intentional
210
241
  throw {
211
- type: action.type,
212
- error,
242
+ error: err,
243
+ action,
213
244
  index
214
245
  };
215
246
  }
@@ -242,7 +273,9 @@ let Actions = class Actions {
242
273
  this.callActionLoop = this.callActionLoop.bind(this);
243
274
  this.callActions = this.callActions.bind(this);
244
275
  this.displayMessage = this.displayMessage.bind(this);
276
+ this.logActionError = this.logActionError.bind(this);
245
277
  this.actions = context._internal.lowdefy._internal.actions;
278
+ this.loggedActionErrors = new Set();
246
279
  }
247
280
  };
248
281
  export default Actions;
package/dist/Block.js CHANGED
@@ -29,7 +29,7 @@ import { applyArrayIndices, get, serializer, swap, type } from '@lowdefy/helpers
29
29
  import Events from './Events.js';
30
30
  import Areas from './Areas.js';
31
31
  let Block = class Block {
32
- constructor({ context, arrayIndices }, { id, blockId, events, layout, loading, properties, required, skeleton, style, validate, visible, type: blockType, areas }){
32
+ constructor({ context, arrayIndices }, blockConfig){
33
33
  _define_property(this, "_initInput", ()=>{
34
34
  this.setValue = (value)=>{
35
35
  this.value = type.enforceType(this.meta.valueType, value);
@@ -356,9 +356,22 @@ let Block = class Block {
356
356
  _define_property(this, "render", ()=>{
357
357
  if (!this.update) return;
358
358
  this.update = false;
359
+ // Collect parse errors from all eval results
360
+ const parseErrors = [
361
+ ...this.propertiesEval.errors || [],
362
+ ...this.styleEval.errors || [],
363
+ ...this.layoutEval.errors || [],
364
+ ...this.visibleEval.errors || [],
365
+ ...this.loadingEval.errors || [],
366
+ ...this.requiredEval.errors || [],
367
+ ...this.skeletonEval.errors || [],
368
+ ...this.areasLayoutEval.errors || []
369
+ ];
359
370
  this.eval = {
360
371
  areas: this.areasLayoutEval.output,
372
+ configKey: this.configKey,
361
373
  events: type.isNone(this.Events.events) ? null : this.Events.events,
374
+ parseErrors: parseErrors.length > 0 ? parseErrors : null,
362
375
  properties: this.propertiesEval.output,
363
376
  loading: this.loadingEval.output,
364
377
  skeleton: this.skeletonEval.output,
@@ -374,8 +387,10 @@ let Block = class Block {
374
387
  };
375
388
  this.context._internal.lowdefy._internal.updateBlock(this.id);
376
389
  });
390
+ const { id, blockId, events, layout, loading, properties, required, skeleton, style, validate, visible, type: blockType, areas } = blockConfig;
377
391
  this.context = context;
378
392
  this.arrayIndices = arrayIndices;
393
+ this.configKey = blockConfig['~k'];
379
394
  this.idPattern = id;
380
395
  this.blockIdPattern = blockId;
381
396
  this.id = applyArrayIndices(this.arrayIndices, this.idPattern);
@@ -17,7 +17,9 @@ import Actions from './Actions.js';
17
17
  import Areas from './Areas.js';
18
18
  import Requests from './Requests.js';
19
19
  import State from './State.js';
20
- const blockData = ({ areas, blockId, blocks, events, field, id, layout, pageId, properties, requests, required, style, type, validate, visible })=>({
20
+ const blockData = (config)=>{
21
+ const { areas, blockId, blocks, events, field, id, layout, pageId, properties, requests, required, style, type, validate, visible } = config;
22
+ const result = {
21
23
  areas,
22
24
  blockId,
23
25
  blocks,
@@ -33,7 +35,18 @@ const blockData = ({ areas, blockId, blocks, events, field, id, layout, pageId,
33
35
  type,
34
36
  validate,
35
37
  visible
36
- });
38
+ };
39
+ // Preserve ~k (configKey) for error tracing - it's non-enumerable so must be copied explicitly
40
+ if (config['~k']) {
41
+ Object.defineProperty(result, '~k', {
42
+ value: config['~k'],
43
+ enumerable: false,
44
+ writable: true,
45
+ configurable: true
46
+ });
47
+ }
48
+ return result;
49
+ };
37
50
  function getContext({ config, jsMap = {}, lowdefy, resetContext = {
38
51
  reset: false,
39
52
  setReset: ()=>undefined
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/engine",
3
- "version": "0.0.0-experimental-20251203205559",
3
+ "version": "0.0.0-experimental-20260113081624",
4
4
  "license": "Apache-2.0",
5
5
  "description": "",
6
6
  "homepage": "https://lowdefy.com",
@@ -30,15 +30,15 @@
30
30
  "dist/*"
31
31
  ],
32
32
  "dependencies": {
33
- "@lowdefy/helpers": "0.0.0-experimental-20251203205559",
34
- "@lowdefy/operators": "0.0.0-experimental-20251203205559"
33
+ "@lowdefy/helpers": "0.0.0-experimental-20260113081624",
34
+ "@lowdefy/operators": "0.0.0-experimental-20260113081624"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@jest/globals": "28.1.3",
38
- "@lowdefy/actions-core": "0.0.0-experimental-20251203205559",
39
- "@lowdefy/build": "0.0.0-experimental-20251203205559",
40
- "@lowdefy/operators-js": "0.0.0-experimental-20251203205559",
41
- "@lowdefy/operators-mql": "0.0.0-experimental-20251203205559",
38
+ "@lowdefy/actions-core": "0.0.0-experimental-20260113081624",
39
+ "@lowdefy/build": "0.0.0-experimental-20260113081624",
40
+ "@lowdefy/operators-js": "0.0.0-experimental-20260113081624",
41
+ "@lowdefy/operators-mql": "0.0.0-experimental-20260113081624",
42
42
  "@swc/cli": "0.1.63",
43
43
  "@swc/core": "1.3.99",
44
44
  "@swc/jest": "0.2.29",