lisichatbot 2.1.2 → 2.1.4

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +16 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisichatbot",
3
- "version": "2.1.2",
3
+ "version": "2.1.4",
4
4
  "type": "module",
5
5
  "main": "./src/index.js",
6
6
  "exports": {
package/src/index.js CHANGED
@@ -2363,7 +2363,16 @@ async function handleNext() {
2363
2363
  }
2364
2364
  });
2365
2365
  }
2366
-
2366
+
2367
+ // ✅ Support updating chatState.data from onNext (same as onStart)
2368
+ if (result && typeof result === 'object' && result.data && typeof result.data === 'object') {
2369
+ console.log(` 📝 onNext returned data to update chatState.data:`, result.data);
2370
+ Object.keys(result.data).forEach(key => {
2371
+ chatState.data[key] = result.data[key];
2372
+ console.log(` → chatState.data.${key} = ${JSON.stringify(result.data[key])}`);
2373
+ });
2374
+ }
2375
+
2367
2376
  // ✅ NEW: Check if onNext wants to jump to step by name
2368
2377
  if (result && typeof result === 'object' && result.goToStepName) {
2369
2378
  console.log(`🎯 onNext requested jump to step name: "${result.goToStepName}"`);
@@ -3657,8 +3666,12 @@ function init(flowName, flowConfig, options = {}) {
3657
3666
  flowData = flowConfig;
3658
3667
 
3659
3668
  chatState.step = 0;
3660
- chatState.chatMode = mode; // ✅ NEW: Store mode in chatState as chatMode
3661
-
3669
+ chatState.chatMode = mode;
3670
+ chatState.returnToStep = null;
3671
+ chatState.completed = false;
3672
+ chatState.editPath = [];
3673
+ chatState.prefillOverrideFields = null;
3674
+
3662
3675
  // ✅ NEW: Merge initialData with editData for edit mode
3663
3676
  if (mode === 'edit' && editData && Object.keys(editData).length > 0) {
3664
3677
  console.log('🔧 Edit mode enabled - pre-filling with data:', editData);