lisichatbot 1.5.4 → 1.5.5

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 +18 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisichatbot",
3
- "version": "1.5.4",
3
+ "version": "1.5.5",
4
4
  "type": "module",
5
5
  "main": "./src/index.js",
6
6
  "exports": {
package/src/index.js CHANGED
@@ -2589,8 +2589,14 @@ function init(flowName, flowConfig, options = {}) {
2589
2589
  Object.assign(config.customRangeErrors, options.customRangeErrors);
2590
2590
  }
2591
2591
 
2592
+ // ✅ NEW: Support mode and data parameters
2593
+ const mode = options.mode || 'create'; // 'create' or 'edit'
2594
+ const editData = options.data || {};
2595
+
2592
2596
  console.log('✅ Flow initialized:', {
2593
2597
  flowName,
2598
+ mode,
2599
+ hasEditData: Object.keys(editData).length > 0,
2594
2600
  selectedBackground: config.selectedBackground,
2595
2601
  autoAdvanceDelay: config.autoAdvanceDelay,
2596
2602
  customRangeErrors: config.customRangeErrors
@@ -2599,7 +2605,18 @@ function init(flowName, flowConfig, options = {}) {
2599
2605
  flowData = flowConfig;
2600
2606
 
2601
2607
  chatState.step = 0;
2602
- chatState.data = flowConfig.initialData || {};
2608
+
2609
+ // ✅ NEW: Merge initialData with editData for edit mode
2610
+ if (mode === 'edit' && editData && Object.keys(editData).length > 0) {
2611
+ console.log('🔧 Edit mode enabled - pre-filling with data:', editData);
2612
+ chatState.data = {
2613
+ ...(flowConfig.initialData || {}),
2614
+ ...editData // Edit data takes precedence
2615
+ };
2616
+ } else {
2617
+ chatState.data = flowConfig.initialData || {};
2618
+ }
2619
+
2603
2620
  chatState.history = [];
2604
2621
  chatState.currentSelection = null;
2605
2622