lisichatbot 1.5.5 → 1.5.7
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/package.json +1 -1
- package/src/index.js +125 -0
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -1864,6 +1864,23 @@ async function handleNext() {
|
|
|
1864
1864
|
disableNextButton();
|
|
1865
1865
|
return;
|
|
1866
1866
|
}
|
|
1867
|
+
|
|
1868
|
+
// ✅ NEW: Validate min/max for number inputs
|
|
1869
|
+
const inputConfig = currentStep.input || {};
|
|
1870
|
+
const min = inputConfig.min;
|
|
1871
|
+
const max = inputConfig.max;
|
|
1872
|
+
|
|
1873
|
+
if (min !== undefined && value < min) {
|
|
1874
|
+
console.log(`❌ Number input below minimum (${value} < ${min}) - cannot proceed`);
|
|
1875
|
+
disableNextButton();
|
|
1876
|
+
return;
|
|
1877
|
+
}
|
|
1878
|
+
|
|
1879
|
+
if (max !== undefined && value > max) {
|
|
1880
|
+
console.log(`❌ Number input above maximum (${value} > ${max}) - cannot proceed`);
|
|
1881
|
+
disableNextButton();
|
|
1882
|
+
return;
|
|
1883
|
+
}
|
|
1867
1884
|
}
|
|
1868
1885
|
|
|
1869
1886
|
console.log(`✅ ${inputType} input validation passed:`, value);
|
|
@@ -1970,6 +1987,60 @@ async function handleNext() {
|
|
|
1970
1987
|
scrollToBottom();
|
|
1971
1988
|
}
|
|
1972
1989
|
|
|
1990
|
+
// ✅ NEW: Check if onNext wants to update steps by field name
|
|
1991
|
+
if (result && typeof result === 'object' && result.updateStepByField) {
|
|
1992
|
+
console.log('🎯 onNext returned data to update steps by field name:', result.updateStepByField);
|
|
1993
|
+
|
|
1994
|
+
// Iterate through all field updates
|
|
1995
|
+
Object.keys(result.updateStepByField).forEach(fieldName => {
|
|
1996
|
+
const updates = result.updateStepByField[fieldName];
|
|
1997
|
+
|
|
1998
|
+
// Find the step with this field name
|
|
1999
|
+
const targetStepIndex = flowData.flow.findIndex(step =>
|
|
2000
|
+
step.input && step.input.field === fieldName
|
|
2001
|
+
);
|
|
2002
|
+
|
|
2003
|
+
if (targetStepIndex !== -1) {
|
|
2004
|
+
const targetStep = flowData.flow[targetStepIndex];
|
|
2005
|
+
console.log(` ✅ Found step ${targetStepIndex} with field "${fieldName}"`);
|
|
2006
|
+
|
|
2007
|
+
// Update the step's input properties
|
|
2008
|
+
if (updates.options !== undefined) {
|
|
2009
|
+
targetStep.input.options = updates.options;
|
|
2010
|
+
console.log(` → Updated options (${updates.options.length} items)`);
|
|
2011
|
+
}
|
|
2012
|
+
|
|
2013
|
+
if (updates.min !== undefined) {
|
|
2014
|
+
targetStep.input.min = updates.min;
|
|
2015
|
+
console.log(` → Updated min: ${updates.min}`);
|
|
2016
|
+
}
|
|
2017
|
+
|
|
2018
|
+
if (updates.max !== undefined) {
|
|
2019
|
+
targetStep.input.max = updates.max;
|
|
2020
|
+
console.log(` → Updated max: ${updates.max}`);
|
|
2021
|
+
}
|
|
2022
|
+
|
|
2023
|
+
if (updates.selectedInputValueType !== undefined) {
|
|
2024
|
+
targetStep.input.selectedInputValueType = updates.selectedInputValueType;
|
|
2025
|
+
}
|
|
2026
|
+
|
|
2027
|
+
if (updates.selectedInputPrefix !== undefined) {
|
|
2028
|
+
targetStep.input.selectedInputPrefix = updates.selectedInputPrefix;
|
|
2029
|
+
}
|
|
2030
|
+
|
|
2031
|
+
if (updates.selectedInputSuffix !== undefined) {
|
|
2032
|
+
targetStep.input.selectedInputSuffix = updates.selectedInputSuffix;
|
|
2033
|
+
}
|
|
2034
|
+
|
|
2035
|
+
if (updates.custom !== undefined) {
|
|
2036
|
+
targetStep.input.custom = updates.custom;
|
|
2037
|
+
}
|
|
2038
|
+
} else {
|
|
2039
|
+
console.warn(` ⚠️ No step found with field name "${fieldName}"`);
|
|
2040
|
+
}
|
|
2041
|
+
});
|
|
2042
|
+
}
|
|
2043
|
+
|
|
1973
2044
|
// ✅ NEW: Check if onNext wants to jump to a specific step
|
|
1974
2045
|
if (result && typeof result === 'object' && typeof result.goToStep === 'number') {
|
|
1975
2046
|
console.log(`🎯 onNext requested jump to step ${result.goToStep}`);
|
|
@@ -2248,6 +2319,60 @@ async function showNextStep() {
|
|
|
2248
2319
|
try {
|
|
2249
2320
|
const result = await nextStep.onStart(chatState.data);
|
|
2250
2321
|
|
|
2322
|
+
// ✅ NEW: Check if onStart wants to update steps by field name
|
|
2323
|
+
if (result && typeof result === 'object' && result.updateStepByField) {
|
|
2324
|
+
console.log('🎯 onStart returned data to update steps by field name:', result.updateStepByField);
|
|
2325
|
+
|
|
2326
|
+
// Iterate through all field updates
|
|
2327
|
+
Object.keys(result.updateStepByField).forEach(fieldName => {
|
|
2328
|
+
const updates = result.updateStepByField[fieldName];
|
|
2329
|
+
|
|
2330
|
+
// Find the step with this field name
|
|
2331
|
+
const targetStepIndex = flowData.flow.findIndex(step =>
|
|
2332
|
+
step.input && step.input.field === fieldName
|
|
2333
|
+
);
|
|
2334
|
+
|
|
2335
|
+
if (targetStepIndex !== -1) {
|
|
2336
|
+
const targetStep = flowData.flow[targetStepIndex];
|
|
2337
|
+
console.log(` ✅ Found step ${targetStepIndex} with field "${fieldName}"`);
|
|
2338
|
+
|
|
2339
|
+
// Update the step's input properties
|
|
2340
|
+
if (updates.options !== undefined) {
|
|
2341
|
+
targetStep.input.options = updates.options;
|
|
2342
|
+
console.log(` → Updated options (${updates.options.length} items)`);
|
|
2343
|
+
}
|
|
2344
|
+
|
|
2345
|
+
if (updates.min !== undefined) {
|
|
2346
|
+
targetStep.input.min = updates.min;
|
|
2347
|
+
console.log(` → Updated min: ${updates.min}`);
|
|
2348
|
+
}
|
|
2349
|
+
|
|
2350
|
+
if (updates.max !== undefined) {
|
|
2351
|
+
targetStep.input.max = updates.max;
|
|
2352
|
+
console.log(` → Updated max: ${updates.max}`);
|
|
2353
|
+
}
|
|
2354
|
+
|
|
2355
|
+
if (updates.selectedInputValueType !== undefined) {
|
|
2356
|
+
targetStep.input.selectedInputValueType = updates.selectedInputValueType;
|
|
2357
|
+
}
|
|
2358
|
+
|
|
2359
|
+
if (updates.selectedInputPrefix !== undefined) {
|
|
2360
|
+
targetStep.input.selectedInputPrefix = updates.selectedInputPrefix;
|
|
2361
|
+
}
|
|
2362
|
+
|
|
2363
|
+
if (updates.selectedInputSuffix !== undefined) {
|
|
2364
|
+
targetStep.input.selectedInputSuffix = updates.selectedInputSuffix;
|
|
2365
|
+
}
|
|
2366
|
+
|
|
2367
|
+
if (updates.custom !== undefined) {
|
|
2368
|
+
targetStep.input.custom = updates.custom;
|
|
2369
|
+
}
|
|
2370
|
+
} else {
|
|
2371
|
+
console.warn(` ⚠️ No step found with field name "${fieldName}"`);
|
|
2372
|
+
}
|
|
2373
|
+
});
|
|
2374
|
+
}
|
|
2375
|
+
|
|
2251
2376
|
// ✅ NEW: Check if onStart returned data to update current step
|
|
2252
2377
|
if (result && typeof result === 'object' && result.updateCurrentStep) {
|
|
2253
2378
|
console.log('📝 onStart returned data to update current step:', result);
|