datakeen-session-react 1.1.140-dev.24 → 1.1.140-dev.25

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.
@@ -1,6 +1,6 @@
1
1
  import { __spreadArray } from '../node_modules/tslib/tslib.es6.js';
2
2
  import { useState, useRef, useEffect } from 'react';
3
- import { getNextStepIndex, getOrderedJourneySteps, updateSessionCurrentStep } from '../services/sessionService.js';
3
+ import { reconstructHistoryToStep, getNextStepIndex, getOrderedJourneySteps, updateSessionCurrentStep } from '../services/sessionService.js';
4
4
 
5
5
  /** Node types that auto-execute and should be skipped when going back */
6
6
  var AUTO_EXECUTING_TYPES = new Set(["external-verification", "condition"]);
@@ -10,8 +10,13 @@ var useStepNavigation = function (sessionId, sessionStatus, initialStep, templat
10
10
  var hasInitialized = useRef(false);
11
11
  var setStep = function (newStep, skipHistory) {
12
12
  if (skipHistory === void 0) { skipHistory = false; }
13
+ console.log("[setStep] newStep:", newStep, "skipHistory:", skipHistory, "currentStep:", step, "history:", __spreadArray([], history, true));
13
14
  if (!skipHistory && newStep !== step) {
14
- setHistory(function (prev) { return __spreadArray(__spreadArray([], prev, true), [newStep], false); });
15
+ setHistory(function (prev) {
16
+ if (prev[prev.length - 1] === newStep)
17
+ return prev;
18
+ return __spreadArray(__spreadArray([], prev, true), [newStep], false);
19
+ });
15
20
  }
16
21
  setStepState(newStep);
17
22
  // Update current step in database
@@ -23,6 +28,7 @@ var useStepNavigation = function (sessionId, sessionStatus, initialStep, templat
23
28
  }
24
29
  };
25
30
  var goBack = function () {
31
+ console.log("[goBack] called — history:", __spreadArray([], history, true), "step:", step);
26
32
  if (history.length > 1) {
27
33
  var newHistory = __spreadArray([], history, true);
28
34
  newHistory.pop(); // Remove current step
@@ -34,7 +40,9 @@ var useStepNavigation = function (sessionId, sessionStatus, initialStep, templat
34
40
  // steps are 1-indexed (step 0 = start, step 1 = first node, etc.)
35
41
  var nodeIndex = candidateStep - 1;
36
42
  var candidateNode = orderedNodes[nodeIndex];
43
+ console.log("[goBack] candidate step:", candidateStep, "node:", candidateNode === null || candidateNode === void 0 ? void 0 : candidateNode.type);
37
44
  if (candidateNode && AUTO_EXECUTING_TYPES.has(candidateNode.type)) {
45
+ console.log("[goBack] skipping auto-executing node:", candidateNode.type);
38
46
  newHistory.pop();
39
47
  }
40
48
  else {
@@ -43,11 +51,12 @@ var useStepNavigation = function (sessionId, sessionStatus, initialStep, templat
43
51
  }
44
52
  }
45
53
  var previousStep = newHistory[newHistory.length - 1];
54
+ console.log("[goBack] navigating to step:", previousStep, "newHistory:", newHistory);
46
55
  setHistory(newHistory);
47
56
  setStep(previousStep, true);
48
57
  }
49
58
  else {
50
- console.warn("[useStepNavigation] No history to go back to");
59
+ console.warn("[goBack] BLOCKED history.length <= 1, history:", __spreadArray([], history, true));
51
60
  }
52
61
  };
53
62
  var goToNextStep = function (currentNodeId, template, handle) {
@@ -72,8 +81,21 @@ var useStepNavigation = function (sessionId, sessionStatus, initialStep, templat
72
81
  }
73
82
  // Only initialize once when initialStep becomes available
74
83
  if (initialStep !== undefined && !hasInitialized.current) {
84
+ console.log("[useStepNavigation] init — initialStep:", initialStep);
75
85
  setStepState(initialStep);
76
- setHistory([initialStep]);
86
+ setHistory(function (prev) {
87
+ // Preserve history if the user already navigated past the initial step
88
+ if (prev.length > 1 && prev[prev.length - 1] === initialStep) {
89
+ console.log("[useStepNavigation] init — preserving existing history:", prev);
90
+ return prev;
91
+ }
92
+ // Reconstruct history by following the graph from step 0
93
+ var reconstructed = template
94
+ ? reconstructHistoryToStep(initialStep, template)
95
+ : initialStep > 0 ? [0, initialStep] : [initialStep];
96
+ console.log("[useStepNavigation] init — reconstructed history:", reconstructed);
97
+ return reconstructed;
98
+ });
77
99
  hasInitialized.current = true;
78
100
  }
79
101
  }, [sessionId, sessionStatus, initialStep]);
@@ -1 +1 @@
1
- {"version":3,"file":"useStepNavigation.js","sources":["../../../../src/hooks/useStepNavigation.ts"],"sourcesContent":["import { useState, useEffect, useRef } from \"react\";\nimport {\n updateSessionCurrentStep,\n getNextStepIndex,\n getOrderedJourneySteps,\n} from \"../services/sessionService\";\nimport type { SessionTemplate } from \"../types/session\";\n\n/** Node types that auto-execute and should be skipped when going back */\nconst AUTO_EXECUTING_TYPES = new Set([\"external-verification\", \"condition\"]);\n\nexport const useStepNavigation = (\n sessionId: string,\n sessionStatus?: string,\n initialStep?: number,\n template?: SessionTemplate,\n) => {\n const [step, setStepState] = useState(initialStep ?? 0);\n const [history, setHistory] = useState<number[]>(initialStep !== undefined ? [initialStep] : [0]);\n const hasInitialized = useRef(false);\n\n const setStep = (newStep: number, skipHistory = false) => {\n if (!skipHistory && newStep !== step) {\n setHistory((prev) => [...prev, newStep]);\n }\n setStepState(newStep);\n\n // Update current step in database\n if (sessionId) {\n updateSessionCurrentStep(sessionId, newStep).catch((error) => {\n console.error(\"Failed to update current step in database:\", error);\n // Non-blocking error - the step is still updated locally\n });\n }\n };\n\n const goBack = () => {\n if (history.length > 1) {\n let newHistory = [...history];\n newHistory.pop(); // Remove current step\n\n // Skip auto-executing nodes when going back\n if (template) {\n const orderedNodes = getOrderedJourneySteps(template);\n while (newHistory.length > 1) {\n const candidateStep = newHistory[newHistory.length - 1];\n // steps are 1-indexed (step 0 = start, step 1 = first node, etc.)\n const nodeIndex = candidateStep - 1;\n const candidateNode = orderedNodes[nodeIndex];\n if (candidateNode && AUTO_EXECUTING_TYPES.has(candidateNode.type)) {\n newHistory.pop();\n } else {\n break;\n }\n }\n }\n\n const previousStep = newHistory[newHistory.length - 1];\n setHistory(newHistory);\n setStep(previousStep, true);\n } else {\n console.warn(\"[useStepNavigation] No history to go back to\");\n }\n };\n\n const goToNextStep = (\n currentNodeId: string,\n template: SessionTemplate,\n handle?: string\n ) => {\n const nextStepIndex = getNextStepIndex(currentNodeId, template, handle);\n\n if (nextStepIndex !== null) {\n console.debug(\n `[useStepNavigation] Navigating from ${currentNodeId} to step index ${nextStepIndex}`\n );\n setStep(nextStepIndex);\n } else {\n console.warn(\n `[useStepNavigation] Could not find next step for node ${currentNodeId}. Staying on current step.`\n );\n }\n };\n\n // Initialize step from session data or status\n useEffect(() => {\n if (!sessionId) {\n return;\n }\n\n // Check if session is already ended\n if (sessionStatus === \"ended\") {\n setStepState(100);\n return;\n }\n\n // Only initialize once when initialStep becomes available\n if (initialStep !== undefined && !hasInitialized.current) {\n setStepState(initialStep);\n setHistory([initialStep]);\n hasInitialized.current = true;\n }\n }, [sessionId, sessionStatus, initialStep]);\n\n const stepObject = {\n setStep,\n goBack,\n goToNextStep,\n step,\n canGoBack: history.length > 1,\n };\n\n return {\n step,\n setStep,\n goBack,\n goToNextStep,\n stepObject,\n };\n};\n"],"names":[],"mappings":";;;;AAQA;AACA,IAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC,CAAC,uBAAuB,EAAE,WAAW,CAAC,CAAC;AAErE,IAAM,iBAAiB,GAAG,UAC/B,SAAiB,EACjB,aAAsB,EACtB,WAAoB,EACpB,QAA0B,EAAA;AAEpB,IAAA,IAAA,KAAuB,QAAQ,CAAC,WAAW,KAAA,IAAA,IAAX,WAAW,KAAA,MAAA,GAAX,WAAW,GAAI,CAAC,CAAC,EAAhD,IAAI,QAAA,EAAE,YAAY,QAA8B;IACjD,IAAA,EAAA,GAAwB,QAAQ,CAAW,WAAW,KAAK,SAAS,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAA1F,OAAO,GAAA,EAAA,CAAA,CAAA,CAAA,EAAE,UAAU,GAAA,EAAA,CAAA,CAAA,CAAuE;AACjG,IAAA,IAAM,cAAc,GAAG,MAAM,CAAC,KAAK,CAAC;AAEpC,IAAA,IAAM,OAAO,GAAG,UAAC,OAAe,EAAE,WAAmB,EAAA;AAAnB,QAAA,IAAA,WAAA,KAAA,MAAA,EAAA,EAAA,WAAA,GAAA,KAAmB,CAAA,CAAA;AACnD,QAAA,IAAI,CAAC,WAAW,IAAI,OAAO,KAAK,IAAI,E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A,IAAA;AACJ,QAAA,OAAO,EAAA,OAAA;AACP,QAAA,MAAM,EAAA,MAAA;AACN,QAAA,YAAY,EAAA,YAAA;AACZ,QAAA,UAAU,EAAA,UAAA;KACX;AACH;;;;"}
1
+ {"version":3,"file":"useStepNavigation.js","sources":["../../../../src/hooks/useStepNavigation.ts"],"sourcesContent":["import { useState, useEffect, useRef } from \"react\";\nimport {\n updateSessionCurrentStep,\n getNextStepIndex,\n getOrderedJourneySteps,\n reconstructHistoryToStep,\n} from \"../services/sessionService\";\nimport type { SessionTemplate } from \"../types/session\";\n\n/** Node types that auto-execute and should be skipped when going back */\nconst AUTO_EXECUTING_TYPES = new Set([\"external-verification\", \"condition\"]);\n\nexport const useStepNavigation = (\n sessionId: string,\n sessionStatus?: string,\n initialStep?: number,\n template?: SessionTemplate,\n) => {\n const [step, setStepState] = useState(initialStep ?? 0);\n const [history, setHistory] = useState<number[]>(initialStep !== undefined ? [initialStep] : [0]);\n const hasInitialized = useRef(false);\n\n const setStep = (newStep: number, skipHistory = false) => {\n console.log(\"[setStep] newStep:\", newStep, \"skipHistory:\", skipHistory, \"currentStep:\", step, \"history:\", [...history]);\n if (!skipHistory && newStep !== step) {\n setHistory((prev) => {\n if (prev[prev.length - 1] === newStep) return prev;\n return [...prev, newStep];\n });\n }\n setStepState(newStep);\n\n // Update current step in database\n if (sessionId) {\n updateSessionCurrentStep(sessionId, newStep).catch((error) => {\n console.error(\"Failed to update current step in database:\", error);\n // Non-blocking error - the step is still updated locally\n });\n }\n };\n\n const goBack = () => {\n console.log(\"[goBack] called — history:\", [...history], \"step:\", step);\n if (history.length > 1) {\n let newHistory = [...history];\n newHistory.pop(); // Remove current step\n\n // Skip auto-executing nodes when going back\n if (template) {\n const orderedNodes = getOrderedJourneySteps(template);\n while (newHistory.length > 1) {\n const candidateStep = newHistory[newHistory.length - 1];\n // steps are 1-indexed (step 0 = start, step 1 = first node, etc.)\n const nodeIndex = candidateStep - 1;\n const candidateNode = orderedNodes[nodeIndex];\n console.log(\"[goBack] candidate step:\", candidateStep, \"node:\", candidateNode?.type);\n if (candidateNode && AUTO_EXECUTING_TYPES.has(candidateNode.type)) {\n console.log(\"[goBack] skipping auto-executing node:\", candidateNode.type);\n newHistory.pop();\n } else {\n break;\n }\n }\n }\n\n const previousStep = newHistory[newHistory.length - 1];\n console.log(\"[goBack] navigating to step:\", previousStep, \"newHistory:\", newHistory);\n setHistory(newHistory);\n setStep(previousStep, true);\n } else {\n console.warn(\"[goBack] BLOCKED history.length <= 1, history:\", [...history]);\n }\n };\n\n const goToNextStep = (\n currentNodeId: string,\n template: SessionTemplate,\n handle?: string\n ) => {\n const nextStepIndex = getNextStepIndex(currentNodeId, template, handle);\n\n if (nextStepIndex !== null) {\n console.debug(\n `[useStepNavigation] Navigating from ${currentNodeId} to step index ${nextStepIndex}`\n );\n setStep(nextStepIndex);\n } else {\n console.warn(\n `[useStepNavigation] Could not find next step for node ${currentNodeId}. Staying on current step.`\n );\n }\n };\n\n // Initialize step from session data or status\n useEffect(() => {\n if (!sessionId) {\n return;\n }\n\n // Check if session is already ended\n if (sessionStatus === \"ended\") {\n setStepState(100);\n return;\n }\n\n // Only initialize once when initialStep becomes available\n if (initialStep !== undefined && !hasInitialized.current) {\n console.log(\"[useStepNavigation] init — initialStep:\", initialStep);\n setStepState(initialStep);\n setHistory((prev) => {\n // Preserve history if the user already navigated past the initial step\n if (prev.length > 1 && prev[prev.length - 1] === initialStep) {\n console.log(\"[useStepNavigation] init — preserving existing history:\", prev);\n return prev;\n }\n // Reconstruct history by following the graph from step 0\n const reconstructed = template\n ? reconstructHistoryToStep(initialStep, template)\n : initialStep > 0 ? [0, initialStep] : [initialStep];\n console.log(\"[useStepNavigation] init — reconstructed history:\", reconstructed);\n return reconstructed;\n });\n hasInitialized.current = true;\n }\n }, [sessionId, sessionStatus, initialStep]);\n\n const stepObject = {\n setStep,\n goBack,\n goToNextStep,\n step,\n canGoBack: history.length > 1,\n };\n\n return {\n step,\n setStep,\n goB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AEd,gBAAA,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,WAAW,EAAE;AAC5D,oBAAA,OAAO,CAAC,GAAG,CAAC,yDAAyD,EAAE,IAAI,CAAC;AAC5E,oBAAA,OAAO,IAAI;gBACb;;gBAEA,IAAM,aAAa,GAAG;AACpB,sBAAE,wBAAwB,CAAC,WAAW,EAAE,QAAQ;AAChD,sBAAE,WAAW,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,WAAW,CAAC,GAAG,CAAC,WAAW,CAAC;AACtD,gBAAA,OAAO,CAAC,GAAG,CAAC,mDAAmD,EAAE,aAAa,CAAC;AAC/E,gBAAA,OAAO,aAAa;AACtB,YAAA,CAAC,CAAC;AACF,YAAA,cAAc,CAAC,OAAO,GAAG,IAAI;QAC/B;IACF,CAAC,EAAE,CAAC,SAAS,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC;AAE3C,IAAA,IAAM,UAAU,GAAG;AACjB,QAAA,OAAO,EAAA,OAAA;AACP,QAAA,MAAM,EAAA,MAAA;AACN,QAAA,YAAY,EAAA,YAAA;AACZ,QAAA,IAAI,EAAA,IAAA;AACJ,QAAA,SAAS,EAAE,OAAO,CAAC,MAAM,GAAG,CAAC;KAC9B;IAED,OAAO;AACL,QAAA,IAAI,EAAA,IAAA;AACJ,QAAA,OAAO,EAAA,OAAA;AACP,QAAA,MAAM,EAAA,MAAA;AACN,QAAA,YAAY,EAAA,YAAA;AACZ,QAAA,UAAU,EAAA,UAAA;KACX;AACH;;;;"}
@@ -8,7 +8,7 @@ import { useI18n } from './useI18n.js';
8
8
 
9
9
  var useUserInputForm = function (_a) {
10
10
  var stepObject = _a.stepObject, setUserInput = _a.setUserInput, initialUserInput = _a.initialUserInput, node = _a.node, template = _a.template, contactInfo = _a.contactInfo, setContactInfo = _a.setContactInfo, onContinueCallback = _a.onContinueCallback;
11
- var setStep = stepObject.setStep, goToNextStep = stepObject.goToNextStep, step = stepObject.step;
11
+ stepObject.setStep; var goBack = stepObject.goBack, goToNextStep = stepObject.goToNextStep, step = stepObject.step;
12
12
  var t = useI18n().t;
13
13
  var informationType = useMemo(function () {
14
14
  var _a;
@@ -500,7 +500,8 @@ var useUserInputForm = function (_a) {
500
500
  }
501
501
  };
502
502
  var goOnPreviousStep = function () {
503
- setStep(Math.max(0, step - 1));
503
+ console.log("[goOnPreviousStep] called — step:", step, "canGoBack:", stepObject.canGoBack);
504
+ goBack();
504
505
  };
505
506
  var pageTitle = node.pageTitle || formTitles[informationType];
506
507
  var pageDescription = node.pageDescription || formDescriptions[informationType];
@@ -1 +1 @@
1
- {"version":3,"file":"useUserInputForm.js","sources":["../../../../src/hooks/useUserInputForm.ts"],"sourcesContent":["import { useEffect, useMemo, useRef, useState } from \"react\";\nimport type { UserInputFormProps } from \"../types/userInput\";\nimport type {\n AddressSuggestion,\n InformationType,\n RequestedFields,\n UserInputFormErrors,\n UserInputFormState,\n} from \"../types/userInputForm\";\nimport {\n DEFAULT_FIELDS,\n FALLBACK_ADDRESS_SUGGESTIONS,\n GEOCODING_AUTOCOMPLETE_ENDPOINT,\n} from \"../constants/userInputForm\";\nimport { API_BASE_URL } from \"../config/env\";\nimport {\n checkIsMajor,\n parseBirthDate,\n resolveInformationType,\n} from \"../utils/userInputForm\";\nimport {\n countNonEmptyListRows,\n getListFieldMinRows,\n} from \"../utils/listFieldUtils\";\nimport { useI18n } from \"./useI18n\";\n\ninterface UseUserInputFormResult {\n form: UserInputFormState;\n errors: UserInputFormErrors;\n informationType: InformationType;\n requestedFields: RequestedFields;\n pageTitle: string;\n pageDescription: string;\n addressSuggestions: AddressSuggestion[];\n showSuggestions: boolean;\n handleFieldChange: (key: keyof UserInputFormState, value: string) => void;\n handleAddressChange: (value: string) => void;\n handleAddressFocus: () => void;\n handleAddressBlur: () => void;\n applyAddressSuggestion: (suggestion: AddressSuggestion) => void;\n goOnNextStep: () => void;\n goOnPreviousStep: () => void;\n // Custom form fields\n customFormData: Record<string, any>;\n customFormErrors: Record<string, boolean>;\n handleCustomFieldChange: (fieldId: string, value: any) => void;\n}\n\nexport const useUserInputForm = ({\n stepObject,\n setUserInput,\n initialUserInput,\n node,\n template,\n contactInfo,\n setContactInfo,\n onContinueCallback,\n}: UserInputFormProps): UseUserInputFormResult => {\n const { setStep, goToNextStep, step } = stepObject;\n const { t } = useI18n();\n\n const informationType = useMemo<InformationType>(() => {\n const resolved = resolveInformationType(\n node.informationType as string,\n \"identity\",\n );\n console.log(\"🔍 [useUserInputForm] Resolving informationType:\", {\n nodeInformationType: node.informationType,\n resolved,\n hasCustomFields: !!node.customFields,\n customFieldsCount: node.customFields?.length,\n });\n return resolved;\n }, [node.informationType, node.customFields]);\n\n const requestedFields = useMemo<RequestedFields>(() => {\n const defaults = DEFAULT_FIELDS[informationType] || [];\n const optional =\n node.optionalFields && node.optionalFields.length > 0\n ? node.optionalFields\n : defaults;\n const merged = new Set<string>(optional);\n\n if (node.requiredFields) {\n node.requiredFields.forEach((field) => merged.add(field));\n }\n\n return merged;\n }, [node.optionalFields, node.requiredFields, informationType]);\n\n const birthDateParts = useMemo(\n () => parseBirthDate(initialUserInput?.birthDate || \"\"),\n [initialUserInput?.birthDate],\n );\n\n const [form, setForm] = useState<UserInputFormState>({\n lastName: initialUserInput?.lastName || \"\",\n firstName: initialUserInput?.firstName || \"\",\n birthDate: initialUserInput?.birthDate || \"\",\n day: birthDateParts.day,\n month: birthDateParts.month,\n year: birthDateParts.year,\n email: initialUserInput?.email || contactInfo?.email || \"\",\n phoneNumber:\n initialUserInput?.phoneNumber || contactInfo?.phoneNumber || \"\",\n sms: initialUserInput?.sms || \"\",\n addressLine1: initialUserInput?.addressLine1 || \"\",\n addressLine2: initialUserInput?.addressLine2 || \"\",\n postalCode: initialUserInput?.postalCode || \"\",\n city: initialUserInput?.city || \"\",\n countryCode: initialUserInput?.countryCode || \"\",\n nationality: initialUserInput?.nationality || \"\",\n companyName: initialUserInput?.companyName || \"\",\n siret: initialUserInput?.siret || \"\",\n tva: initialUserInput?.tva || \"\",\n });\n\n const [errors, setErrors] = useState<UserInputFormErrors>({});\n\n // Custom form state\n const [customFormData, setCustomFormData] = useState<Record<string, any>>(\n () => {\n if (informationType !== \"custom\" || !node.customFields) return {};\n\n const initial: Record<string, any> = {};\n node.customFields.forEach((field) => {\n const savedValue = initialUserInput?.customFormData?.[field.id];\n if (field.valueType === \"list\") {\n initial[field.id] = Array.isArray(savedValue) ? savedValue : [];\n return;\n }\n\n initial[field.id] = savedValue || \"\";\n });\n return initial;\n },\n );\n const [customFormErrors, setCustomFormErrors] = useState<\n Record<string, boolean>\n >({});\n\n const [addressSuggestions, setAddressSuggestions] = useState<\n AddressSuggestion[]\n >([]);\n const [showSuggestions, setShowSuggestions] = useState(false);\n const isFirstRender = useRef(true);\n const hideSuggestionTimeout = useRef<ReturnType<typeof setTimeout> | null>(\n null,\n );\n const addressRequestState = useRef<{\n debounce: ReturnType<typeof setTimeout> | null;\n controller: AbortController | null;\n }>({\n debounce: null,\n controller: null,\n });\n\n const formTitles = useMemo<Record<InformationType, string>>(\n () => ({\n identity: t(\"user_input_form.titles.identity\"),\n \"identity-legal\": t(\"user_input_form.titles.identity_legal\"),\n contact: t(\"user_input_form.titles.contact\"),\n address: t(\"user_input_form.titles.address\"),\n nationality: t(\"user_input_form.titles.nationality\"),\n custom: t(\"user_input_form.titles.custom\"),\n }),\n [t],\n );\n\n const formDescriptions = useMemo<Record<InformationType, string>>(\n () => ({\n identity: t(\"user_input_form.descriptions.identity\"),\n \"identity-legal\": t(\"user_input_form.descriptions.identity_legal\"),\n contact: t(\"user_input_form.descriptions.contact\"),\n address: t(\"user_input_form.descriptions.address\"),\n nationality: t(\"user_input_form.descriptions.nationality\"),\n custom: t(\"user_input_form.descriptions.custom\"),\n }),\n [t],\n );\n\n const applyAddressSuggestion = (suggestion: AddressSuggestion) => {\n const normalizedCountry =\n suggestion.countryCode?.toUpperCase() || suggestion.country || \"\";\n\n setForm((previous) => ({\n ...previous,\n addressLine1: suggestion.addressLine1 || suggestion.label,\n postalCode: suggestion.postalCode || previous.postalCode,\n city: suggestion.city || previous.city,\n countryCode: normalizedCountry || previous.countryCode,\n }));\n setErrors((previous) => ({\n ...previous,\n addressLine1: false,\n postalCode: false,\n city: false,\n country: false,\n }));\n setShowSuggestions(false);\n setAddressSuggestions([]);\n };\n\n const mapGeoapifyFeature = (feature: any): AddressSuggestion | null => {\n if (!feature || !feature.properties) {\n return null;\n }\n\n const { properties } = feature;\n const label: string =\n properties.formatted ||\n properties.address_line1 ||\n [properties.housenumber, properties.street]\n .filter(Boolean)\n .join(\" \")\n .trim();\n\n if (!label) {\n return null;\n }\n\n const addressLine1 =\n [properties.housenumber, properties.street]\n .filter(Boolean)\n .join(\" \")\n .trim() ||\n properties.address_line1 ||\n label;\n\n const city =\n properties.city ||\n properties.town ||\n properties.village ||\n properties.state ||\n \"\";\n\n return {\n id:\n (properties.place_id && String(properties.place_id)) ||\n feature.id ||\n `${properties.lon ?? \"\"}-${properties.lat ?? \"\"}-${label}`,\n label,\n addressLine1,\n postalCode: properties.postcode || \"\",\n city,\n country: properties.country || \"\",\n countryCode: properties.country_code || undefined,\n };\n };\n\n const requestAddressSuggestions = (\n query: string,\n { autoComplete }: { autoComplete: boolean },\n ) => {\n if (addressRequestState.current.debounce) {\n clearTimeout(addressRequestState.current.debounce);\n addressRequestState.current.debounce = null;\n }\n\n if (query.trim().length < 3) {\n if (addressRequestState.current.controller) {\n addressRequestState.current.controller.abort();\n addressRequestState.current.controller = null;\n }\n setAddressSuggestions([]);\n setShowSuggestions(false);\n return;\n }\n\n addressRequestState.current.debounce = setTimeout(async () => {\n if (addressRequestState.current.controller) {\n addressRequestState.current.controller.abort();\n }\n\n const controller = new AbortController();\n addressRequestState.current.controller = controller;\n\n try {\n const searchParams = new URLSearchParams({\n text: query,\n lang: \"fr\",\n });\n\n const response = await fetch(\n `${API_BASE_URL}${GEOCODING_AUTOCOMPLETE_ENDPOINT}?${searchParams.toString()}`,\n { signal: controller.signal },\n );\n\n if (!response.ok) {\n throw new Error(\n `Geocoding request failed with status ${response.status}`,\n );\n }\n\n const payload = await response.json();\n\n const suggestions: AddressSuggestion[] = Array.isArray(\n payload?.features,\n )\n ? payload.features\n .map((feature: any) => mapGeoapifyFeature(feature))\n .filter(\n (\n suggestion: AddressSuggestion | null,\n ): suggestion is AddressSuggestion => Boolean(suggestion),\n )\n : [];\n\n setAddressSuggestions(suggestions);\n setShowSuggestions(suggestions.length > 0);\n\n if (autoComplete && suggestions.length === 1) {\n const single = suggestions[0];\n const normalizedQuery = query.trim().toLowerCase();\n if (\n normalizedQuery.length >= 6 &&\n single.label.toLowerCase().startsWith(normalizedQuery)\n ) {\n applyAddressSuggestion(single);\n }\n }\n } catch (error) {\n if ((error as Error).name === \"AbortError\") {\n return;\n }\n\n const fallback = FALLBACK_ADDRESS_SUGGESTIONS.filter((suggestion) =>\n suggestion.label.toLowerCase().includes(query.toLowerCase()),\n );\n setAddressSuggestions(fallback);\n setShowSuggestions(fallback.length > 0);\n } finally {\n addressRequestState.current.controller = null;\n }\n }, 250);\n };\n\n useEffect(() => {\n if (!initialUserInput) {\n return;\n }\n\n if (\n isFirstRender.current ||\n (!form.firstName &&\n !form.lastName &&\n !form.email &&\n !form.phoneNumber &&\n !form.companyName)\n ) {\n const nextBirthParts = parseBirthDate(initialUserInput.birthDate || \"\");\n setForm((previous) => ({\n ...previous,\n lastName: initialUserInput.lastName || previous.lastName,\n firstName: initialUserInput.firstName || previous.firstName,\n birthDate: initialUserInput.birthDate || previous.birthDate,\n day: nextBirthParts.day,\n month: nextBirthParts.month,\n year: nextBirthParts.year,\n email: initialUserInput.email || previous.email,\n phoneNumber: initialUserInput.phoneNumber || previous.phoneNumber,\n sms: initialUserInput.sms || previous.sms,\n addressLine1: initialUserInput.addressLine1 || previous.addressLine1,\n addressLine2: initialUserInput.addressLine2 || previous.addressLine2,\n postalCode: initialUserInput.postalCode || previous.postalCode,\n city: initialUserInput.city || previous.city,\n countryCode: initialUserInput.countryCode || previous.countryCode,\n nationality: initialUserInput.nationality || previous.nationality,\n companyName: initialUserInput.companyName || previous.companyName,\n siret: initialUserInput.siret || previous.siret,\n tva: initialUserInput.tva || previous.tva,\n }));\n\n isFirstRender.current = false;\n }\n }, [\n initialUserInput,\n form.firstName,\n form.lastName,\n form.email,\n form.phoneNumber,\n form.companyName,\n ]);\n\n useEffect(() => {\n return () => {\n if (hideSuggestionTimeout.current) {\n clearTimeout(hideSuggestionTimeout.current);\n }\n if (addressRequestState.current.debounce) {\n clearTimeout(addressRequestState.current.debounce);\n }\n if (addressRequestState.current.controller) {\n addressRequestState.current.controller.abort();\n }\n };\n }, []);\n\n const handleFieldChange = (key: keyof UserInputFormState, value: string) => {\n setErrors((previous) => ({\n ...previous,\n [key]: false,\n notMajor: false,\n }));\n\n setForm((previous) => {\n const next = { ...previous, [key]: value };\n if (key === \"day\" || key === \"month\" || key === \"year\") {\n const { day, month, year } = next;\n if (day && month && year) {\n const paddedDay = day.padStart(2, \"0\");\n const paddedMonth = month.padStart(2, \"0\");\n next.birthDate = `${paddedDay}-${paddedMonth}-${year}`;\n } else {\n next.birthDate = \"\";\n }\n }\n return next;\n });\n };\n\n const handleAddressChange = (value: string) => {\n handleFieldChange(\"addressLine1\", value);\n requestAddressSuggestions(value, { autoComplete: true });\n };\n\n const handleAddressFocus = () => {\n requestAddressSuggestions(form.addressLine1, { autoComplete: false });\n };\n\n const handleAddressBlur = () => {\n if (hideSuggestionTimeout.current) {\n clearTimeout(hideSuggestionTimeout.current);\n }\n hideSuggestionTimeout.current = setTimeout(() => {\n setShowSuggestions(false);\n hideSuggestionTimeout.current = null;\n }, 150);\n };\n\n const validateForm = () => {\n const nextErrors: UserInputFormErrors = {};\n let hasError = false;\n\n const markError = (key: string) => {\n nextErrors[key] = true;\n hasError = true;\n };\n\n if (informationType === \"identity\") {\n if (requestedFields.has(\"prenom\") && !form.firstName) {\n markError(\"firstName\");\n }\n if (requestedFields.has(\"nom\") && !form.lastName) {\n markError(\"lastName\");\n }\n if (requestedFields.has(\"date_naissance\")) {\n if (!form.birthDate) {\n markError(\"birthDate\");\n } else if (!checkIsMajor(form.birthDate)) {\n nextErrors.notMajor = true;\n hasError = true;\n }\n }\n }\n\n if (informationType === \"identity-legal\") {\n if (requestedFields.has(\"nom\") && !form.companyName) {\n markError(\"companyName\");\n }\n if (requestedFields.has(\"siret\") && !form.siret) {\n markError(\"siret\");\n }\n if (requestedFields.has(\"tva\") && !form.tva) {\n markError(\"tva\");\n }\n }\n\n if (informationType === \"contact\") {\n if (requestedFields.has(\"email\")) {\n const emailRegex = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\n if (!form.email || !emailRegex.test(form.email)) {\n markError(\"email\");\n }\n }\n if (requestedFields.has(\"sms\")) {\n if (\n !form.phoneNumber ||\n form.phoneNumber.replace(/\\D/g, \"\").length < 6\n ) {\n markError(\"phoneNumber\");\n }\n }\n }\n\n if (\n (informationType === \"address\" || informationType === \"identity-legal\") &&\n requestedFields.has(\"adresse\")\n ) {\n if (!form.addressLine1) {\n markError(\"addressLine1\");\n }\n if (!form.postalCode) {\n markError(\"postalCode\");\n }\n if (!form.city) {\n markError(\"city\");\n }\n if (!form.countryCode) {\n markError(\"country\");\n }\n }\n\n if (\n informationType === \"nationality\" &&\n requestedFields.has(\"nationalite\")\n ) {\n if (!form.nationality) {\n markError(\"nationality\");\n }\n }\n\n setErrors(nextErrors);\n return !hasError;\n };\n\n const validateCustomForm = () => {\n const errors: Record<string, boolean> = {};\n let hasError = false;\n\n node.customFields?.forEach((field) => {\n const value = customFormData[field.id];\n\n if (field.valueType === \"list\") {\n const rows = Array.isArray(value) ? value : [];\n const minRows = getListFieldMinRows(field);\n\n if (field.required && countNonEmptyListRows(rows) < minRows) {\n errors[field.id] = true;\n hasError = true;\n }\n return;\n }\n\n // Check if required field is missing\n if (field.required && !value) {\n errors[field.id] = true;\n hasError = true;\n return;\n }\n\n // Type-specific validation\n if (value) {\n switch (field.valueType) {\n case \"number\":\n if (isNaN(Number(value))) {\n errors[field.id] = true;\n hasError = true;\n }\n break;\n\n case \"date\":\n // Date format: DD-MM-YYYY\n // For required dates, all parts must be filled\n if (field.required) {\n const dateParts = value.split(\"-\");\n if (\n dateParts.length !== 3 ||\n !dateParts[0] ||\n !dateParts[1] ||\n !dateParts[2]\n ) {\n errors[field.id] = true;\n hasError = true;\n break;\n }\n\n // Validate month and day ranges\n const day = parseInt(dateParts[0], 10);\n const month = parseInt(dateParts[1], 10);\n const year = parseInt(dateParts[2], 10);\n\n if (\n isNaN(day) ||\n isNaN(month) ||\n isNaN(year) ||\n month < 1 ||\n month > 12 ||\n day < 1 ||\n day > 31\n ) {\n errors[field.id] = true;\n hasError = true;\n }\n }\n break;\n\n case \"address\":\n // Validate address object if required\n if (field.required && typeof value === \"object\") {\n const addressValue = value as {\n addressLine1?: string;\n postalCode?: string;\n city?: string;\n countryCode?: string;\n };\n if (\n !addressValue.addressLine1 ||\n !addressValue.postalCode ||\n !addressValue.city ||\n !addressValue.countryCode\n ) {\n errors[field.id] = true;\n hasError = true;\n }\n }\n break;\n }\n }\n });\n\n setCustomFormErrors(errors);\n return !hasError;\n };\n\n const handleCustomFieldChange = (fieldId: string, value: any) => {\n setCustomFormData((prev) => ({ ...prev, [fieldId]: value }));\n setCustomFormErrors((prev) => ({ ...prev, [fieldId]: false }));\n };\n\n const goOnNextStep = () => {\n // Handle custom form validation and submission\n if (informationType === \"custom\") {\n if (!validateCustomForm()) {\n return;\n }\n\n setUserInput((prev) => ({\n ...prev,\n customFormData: { ...(prev.customFormData ?? {}), ...customFormData },\n }));\n\n if (onContinueCallback) {\n onContinueCallback();\n } else {\n goToNextStep(node.id, template);\n }\n return;\n }\n\n // Standard form validation\n if (!validateForm()) {\n return;\n }\n\n setUserInput((previous) => ({\n ...previous,\n ...(requestedFields.has(\"nom\") && {\n ...(informationType === \"identity-legal\"\n ? { companyName: form.companyName }\n : { lastName: form.lastName }),\n }),\n ...(requestedFields.has(\"prenom\") && { firstName: form.firstName }),\n ...(requestedFields.has(\"date_naissance\") && {\n birthDate: form.birthDate,\n }),\n ...(requestedFields.has(\"email\") && { email: form.email }),\n ...(requestedFields.has(\"sms\") && {\n phoneNumber: form.phoneNumber,\n sms: form.phoneNumber,\n }),\n ...(requestedFields.has(\"adresse\") && {\n addressLine1: form.addressLine1,\n addressLine2: form.addressLine2,\n postalCode: form.postalCode,\n city: form.city,\n countryCode: form.countryCode,\n }),\n ...(requestedFields.has(\"siret\") && { siret: form.siret }),\n ...(requestedFields.has(\"tva\") && { tva: form.tva }),\n ...(requestedFields.has(\"nationalite\") && {\n nationality: form.nationality,\n }),\n }));\n\n if (informationType === \"contact\" && setContactInfo) {\n setContactInfo((previous) => ({\n ...previous,\n ...(requestedFields.has(\"email\") && { email: form.email }),\n ...(requestedFields.has(\"sms\") && { phoneNumber: form.phoneNumber }),\n }));\n }\n\n if (onContinueCallback) {\n onContinueCallback();\n } else {\n goToNextStep(node.id, template);\n }\n };\n\n const goOnPreviousStep = () => {\n setStep(Math.max(0, step - 1));\n };\n\n const pageTitle = node.pageTitle || formTitles[informationType];\n\n const pageDescription =\n node.pageDescription || formDescriptions[informationType];\n\n return {\n form,\n errors,\n informationType,\n requestedFields,\n pageTitle,\n pageDescription,\n addressSuggestions,\n showSuggestions,\n handleFieldChange,\n handleAddressChange,\n handleAddressFocus,\n handleAddressBlur,\n applyAddressSuggestion,\n goOnNextStep,\n goOnPreviousStep,\n customFormData,\n customFormErrors,\n handleCustomFieldChange,\n };\n};\n"],"names":[],"mappings":";;;;;;;;AAgDO,IAAM,gBAAgB,GAAG,UAAC,EASZ,EAAA;QARnB,UAAU,GAAA,EAAA,CAAA,UAAA,EACV,YAAY,GAAA,EAAA,CAAA,YAAA,EACZ,gBAAgB,GAAA,EAAA,CAAA,gBAAA,EAChB,IAAI,GAAA,EAAA,CAAA,IAAA,EACJ,QAAQ,GAAA,EA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,CAAC;AAED,IAAA,IAAM,gBAAgB,GAAG,YAAA;AACvB,QAAA,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,CAAC,CAAC;AAChC,IAAA,CAAC;IAED,IAAM,SAAS,GAAG,IAAI,CAAC,SAAS,IAAI,UAAU,CAAC,eAAe,CAAC;IAE/D,IAAM,eAAe,GACnB,IAAI,CAAC,eAAe,IAAI,gBAAgB,CAAC,eAAe,CAAC;IAE3D,OAAO;AACL,QAAA,IAAI,EAAA,IAAA;AACJ,QAAA,MAAM,EAAA,MAAA;AACN,QAAA,eAAe,EAAA,eAAA;AACf,QAAA,eAAe,EAAA,eAAA;AACf,QAAA,SAAS,EAAA,SAAA;AACT,QAAA,eAAe,EAAA,eAAA;AACf,QAAA,kBAAkB,EAAA,kBAAA;AAClB,QAAA,eAAe,EAAA,eAAA;AACf,QAAA,iBAAiB,EAAA,iBAAA;AACjB,QAAA,mBAAmB,EAAA,mBAAA;AACnB,QAAA,kBAAkB,EAAA,kBAAA;AAClB,QAAA,iBAAiB,EAAA,iBAAA;AACjB,QAAA,sBAAsB,EAAA,sBAAA;AACtB,QAAA,YAAY,EAAA,YAAA;AACZ,QAAA,gBAAgB,EAAA,gBAAA;AAChB,QAAA,cAAc,EAAA,cAAA;AACd,QAAA,gBAAgB,EAAA,gBAAA;AAChB,QAAA,uBAAuB,EAAA,uBAAA;KACxB;AACH;;;;"}
1
+ {"version":3,"file":"useUserInputForm.js","sources":["../../../../src/hooks/useUserInputForm.ts"],"sourcesContent":["import { useEffect, useMemo, useRef, useState } from \"react\";\nimport type { UserInputFormProps } from \"../types/userInput\";\nimport type {\n AddressSuggestion,\n InformationType,\n RequestedFields,\n UserInputFormErrors,\n UserInputFormState,\n} from \"../types/userInputForm\";\nimport {\n DEFAULT_FIELDS,\n FALLBACK_ADDRESS_SUGGESTIONS,\n GEOCODING_AUTOCOMPLETE_ENDPOINT,\n} from \"../constants/userInputForm\";\nimport { API_BASE_URL } from \"../config/env\";\nimport {\n checkIsMajor,\n parseBirthDate,\n resolveInformationType,\n} from \"../utils/userInputForm\";\nimport {\n countNonEmptyListRows,\n getListFieldMinRows,\n} from \"../utils/listFieldUtils\";\nimport { useI18n } from \"./useI18n\";\n\ninterface UseUserInputFormResult {\n form: UserInputFormState;\n errors: UserInputFormErrors;\n informationType: InformationType;\n requestedFields: RequestedFields;\n pageTitle: string;\n pageDescription: string;\n addressSuggestions: AddressSuggestion[];\n showSuggestions: boolean;\n handleFieldChange: (key: keyof UserInputFormState, value: string) => void;\n handleAddressChange: (value: string) => void;\n handleAddressFocus: () => void;\n handleAddressBlur: () => void;\n applyAddressSuggestion: (suggestion: AddressSuggestion) => void;\n goOnNextStep: () => void;\n goOnPreviousStep: () => void;\n // Custom form fields\n customFormData: Record<string, any>;\n customFormErrors: Record<string, boolean>;\n handleCustomFieldChange: (fieldId: string, value: any) => void;\n}\n\nexport const useUserInputForm = ({\n stepObject,\n setUserInput,\n initialUserInput,\n node,\n template,\n contactInfo,\n setContactInfo,\n onContinueCallback,\n}: UserInputFormProps): UseUserInputFormResult => {\n const { setStep, goBack, goToNextStep, step } = stepObject;\n const { t } = useI18n();\n\n const informationType = useMemo<InformationType>(() => {\n const resolved = resolveInformationType(\n node.informationType as string,\n \"identity\",\n );\n console.log(\"🔍 [useUserInputForm] Resolving informationType:\", {\n nodeInformationType: node.informationType,\n resolved,\n hasCustomFields: !!node.customFields,\n customFieldsCount: node.customFields?.length,\n });\n return resolved;\n }, [node.informationType, node.customFields]);\n\n const requestedFields = useMemo<RequestedFields>(() => {\n const defaults = DEFAULT_FIELDS[informationType] || [];\n const optional =\n node.optionalFields && node.optionalFields.length > 0\n ? node.optionalFields\n : defaults;\n const merged = new Set<string>(optional);\n\n if (node.requiredFields) {\n node.requiredFields.forEach((field) => merged.add(field));\n }\n\n return merged;\n }, [node.optionalFields, node.requiredFields, informationType]);\n\n const birthDateParts = useMemo(\n () => parseBirthDate(initialUserInput?.birthDate || \"\"),\n [initialUserInput?.birthDate],\n );\n\n const [form, setForm] = useState<UserInputFormState>({\n lastName: initialUserInput?.lastName || \"\",\n firstName: initialUserInput?.firstName || \"\",\n birthDate: initialUserInput?.birthDate || \"\",\n day: birthDateParts.day,\n month: birthDateParts.month,\n year: birthDateParts.year,\n email: initialUserInput?.email || contactInfo?.email || \"\",\n phoneNumber:\n initialUserInput?.phoneNumber || contactInfo?.phoneNumber || \"\",\n sms: initialUserInput?.sms || \"\",\n addressLine1: initialUserInput?.addressLine1 || \"\",\n addressLine2: initialUserInput?.addressLine2 || \"\",\n postalCode: initialUserInput?.postalCode || \"\",\n city: initialUserInput?.city || \"\",\n countryCode: initialUserInput?.countryCode || \"\",\n nationality: initialUserInput?.nationality || \"\",\n companyName: initialUserInput?.companyName || \"\",\n siret: initialUserInput?.siret || \"\",\n tva: initialUserInput?.tva || \"\",\n });\n\n const [errors, setErrors] = useState<UserInputFormErrors>({});\n\n // Custom form state\n const [customFormData, setCustomFormData] = useState<Record<string, any>>(\n () => {\n if (informationType !== \"custom\" || !node.customFields) return {};\n\n const initial: Record<string, any> = {};\n node.customFields.forEach((field) => {\n const savedValue = initialUserInput?.customFormData?.[field.id];\n if (field.valueType === \"list\") {\n initial[field.id] = Array.isArray(savedValue) ? savedValue : [];\n return;\n }\n\n initial[field.id] = savedValue || \"\";\n });\n return initial;\n },\n );\n const [customFormErrors, setCustomFormErrors] = useState<\n Record<string, boolean>\n >({});\n\n const [addressSuggestions, setAddressSuggestions] = useState<\n AddressSuggestion[]\n >([]);\n const [showSuggestions, setShowSuggestions] = useState(false);\n const isFirstRender = useRef(true);\n const hideSuggestionTimeout = useRef<ReturnType<typeof setTimeout> | null>(\n null,\n );\n const addressRequestState = useRef<{\n debounce: ReturnType<typeof setTimeout> | null;\n controller: AbortController | null;\n }>({\n debounce: null,\n controller: null,\n });\n\n const formTitles = useMemo<Record<InformationType, string>>(\n () => ({\n identity: t(\"user_input_form.titles.identity\"),\n \"identity-legal\": t(\"user_input_form.titles.identity_legal\"),\n contact: t(\"user_input_form.titles.contact\"),\n address: t(\"user_input_form.titles.address\"),\n nationality: t(\"user_input_form.titles.nationality\"),\n custom: t(\"user_input_form.titles.custom\"),\n }),\n [t],\n );\n\n const formDescriptions = useMemo<Record<InformationType, string>>(\n () => ({\n identity: t(\"user_input_form.descriptions.identity\"),\n \"identity-legal\": t(\"user_input_form.descriptions.identity_legal\"),\n contact: t(\"user_input_form.descriptions.contact\"),\n address: t(\"user_input_form.descriptions.address\"),\n nationality: t(\"user_input_form.descriptions.nationality\"),\n custom: t(\"user_input_form.descriptions.custom\"),\n }),\n [t],\n );\n\n const applyAddressSuggestion = (suggestion: AddressSuggestion) => {\n const normalizedCountry =\n suggestion.countryCode?.toUpperCase() || suggestion.country || \"\";\n\n setForm((previous) => ({\n ...previous,\n addressLine1: suggestion.addressLine1 || suggestion.label,\n postalCode: suggestion.postalCode || previous.postalCode,\n city: suggestion.city || previous.city,\n countryCode: normalizedCountry || previous.countryCode,\n }));\n setErrors((previous) => ({\n ...previous,\n addressLine1: false,\n postalCode: false,\n city: false,\n country: false,\n }));\n setShowSuggestions(false);\n setAddressSuggestions([]);\n };\n\n const mapGeoapifyFeature = (feature: any): AddressSuggestion | null => {\n if (!feature || !feature.properties) {\n return null;\n }\n\n const { properties } = feature;\n const label: string =\n properties.formatted ||\n properties.address_line1 ||\n [properties.housenumber, properties.street]\n .filter(Boolean)\n .join(\" \")\n .trim();\n\n if (!label) {\n return null;\n }\n\n const addressLine1 =\n [properties.housenumber, properties.street]\n .filter(Boolean)\n .join(\" \")\n .trim() ||\n properties.address_line1 ||\n label;\n\n const city =\n properties.city ||\n properties.town ||\n properties.village ||\n properties.state ||\n \"\";\n\n return {\n id:\n (properties.place_id && String(properties.place_id)) ||\n feature.id ||\n `${properties.lon ?? \"\"}-${properties.lat ?? \"\"}-${label}`,\n label,\n addressLine1,\n postalCode: properties.postcode || \"\",\n city,\n country: properties.country || \"\",\n countryCode: properties.country_code || undefined,\n };\n };\n\n const requestAddressSuggestions = (\n query: string,\n { autoComplete }: { autoComplete: boolean },\n ) => {\n if (addressRequestState.current.debounce) {\n clearTimeout(addressRequestState.current.debounce);\n addressRequestState.current.debounce = null;\n }\n\n if (query.trim().length < 3) {\n if (addressRequestState.current.controller) {\n addressRequestState.current.controller.abort();\n addressRequestState.current.controller = null;\n }\n setAddressSuggestions([]);\n setShowSuggestions(false);\n return;\n }\n\n addressRequestState.current.debounce = setTimeout(async () => {\n if (addressRequestState.current.controller) {\n addressRequestState.current.controller.abort();\n }\n\n const controller = new AbortController();\n addressRequestState.current.controller = controller;\n\n try {\n const searchParams = new URLSearchParams({\n text: query,\n lang: \"fr\",\n });\n\n const response = await fetch(\n `${API_BASE_URL}${GEOCODING_AUTOCOMPLETE_ENDPOINT}?${searchParams.toString()}`,\n { signal: controller.signal },\n );\n\n if (!response.ok) {\n throw new Error(\n `Geocoding request failed with status ${response.status}`,\n );\n }\n\n const payload = await response.json();\n\n const suggestions: AddressSuggestion[] = Array.isArray(\n payload?.features,\n )\n ? payload.features\n .map((feature: any) => mapGeoapifyFeature(feature))\n .filter(\n (\n suggestion: AddressSuggestion | null,\n ): suggestion is AddressSuggestion => Boolean(suggestion),\n )\n : [];\n\n setAddressSuggestions(suggestions);\n setShowSuggestions(suggestions.length > 0);\n\n if (autoComplete && suggestions.length === 1) {\n const single = suggestions[0];\n const normalizedQuery = query.trim().toLowerCase();\n if (\n normalizedQuery.length >= 6 &&\n single.label.toLowerCase().startsWith(normalizedQuery)\n ) {\n applyAddressSuggestion(single);\n }\n }\n } catch (error) {\n if ((error as Error).name === \"AbortError\") {\n return;\n }\n\n const fallback = FALLBACK_ADDRESS_SUGGESTIONS.filter((suggestion) =>\n suggestion.label.toLowerCase().includes(query.toLowerCase()),\n );\n setAddressSuggestions(fallback);\n setShowSuggestions(fallback.length > 0);\n } finally {\n addressRequestState.current.controller = null;\n }\n }, 250);\n };\n\n useEffect(() => {\n if (!initialUserInput) {\n return;\n }\n\n if (\n isFirstRender.current ||\n (!form.firstName &&\n !form.lastName &&\n !form.email &&\n !form.phoneNumber &&\n !form.companyName)\n ) {\n const nextBirthParts = parseBirthDate(initialUserInput.birthDate || \"\");\n setForm((previous) => ({\n ...previous,\n lastName: initialUserInput.lastName || previous.lastName,\n firstName: initialUserInput.firstName || previous.firstName,\n birthDate: initialUserInput.birthDate || previous.birthDate,\n day: nextBirthParts.day,\n month: nextBirthParts.month,\n year: nextBirthParts.year,\n email: initialUserInput.email || previous.email,\n phoneNumber: initialUserInput.phoneNumber || previous.phoneNumber,\n sms: initialUserInput.sms || previous.sms,\n addressLine1: initialUserInput.addressLine1 || previous.addressLine1,\n addressLine2: initialUserInput.addressLine2 || previous.addressLine2,\n postalCode: initialUserInput.postalCode || previous.postalCode,\n city: initialUserInput.city || previous.city,\n countryCode: initialUserInput.countryCode || previous.countryCode,\n nationality: initialUserInput.nationality || previous.nationality,\n companyName: initialUserInput.companyName || previous.companyName,\n siret: initialUserInput.siret || previous.siret,\n tva: initialUserInput.tva || previous.tva,\n }));\n\n isFirstRender.current = false;\n }\n }, [\n initialUserInput,\n form.firstName,\n form.lastName,\n form.email,\n form.phoneNumber,\n form.companyName,\n ]);\n\n useEffect(() => {\n return () => {\n if (hideSuggestionTimeout.current) {\n clearTimeout(hideSuggestionTimeout.current);\n }\n if (addressRequestState.current.debounce) {\n clearTimeout(addressRequestState.current.debounce);\n }\n if (addressRequestState.current.controller) {\n addressRequestState.current.controller.abort();\n }\n };\n }, []);\n\n const handleFieldChange = (key: keyof UserInputFormState, value: string) => {\n setErrors((previous) => ({\n ...previous,\n [key]: false,\n notMajor: false,\n }));\n\n setForm((previous) => {\n const next = { ...previous, [key]: value };\n if (key === \"day\" || key === \"month\" || key === \"year\") {\n const { day, month, year } = next;\n if (day && month && year) {\n const paddedDay = day.padStart(2, \"0\");\n const paddedMonth = month.padStart(2, \"0\");\n next.birthDate = `${paddedDay}-${paddedMonth}-${year}`;\n } else {\n next.birthDate = \"\";\n }\n }\n return next;\n });\n };\n\n const handleAddressChange = (value: string) => {\n handleFieldChange(\"addressLine1\", value);\n requestAddressSuggestions(value, { autoComplete: true });\n };\n\n const handleAddressFocus = () => {\n requestAddressSuggestions(form.addressLine1, { autoComplete: false });\n };\n\n const handleAddressBlur = () => {\n if (hideSuggestionTimeout.current) {\n clearTimeout(hideSuggestionTimeout.current);\n }\n hideSuggestionTimeout.current = setTimeout(() => {\n setShowSuggestions(false);\n hideSuggestionTimeout.current = null;\n }, 150);\n };\n\n const validateForm = () => {\n const nextErrors: UserInputFormErrors = {};\n let hasError = false;\n\n const markError = (key: string) => {\n nextErrors[key] = true;\n hasError = true;\n };\n\n if (informationType === \"identity\") {\n if (requestedFields.has(\"prenom\") && !form.firstName) {\n markError(\"firstName\");\n }\n if (requestedFields.has(\"nom\") && !form.lastName) {\n markError(\"lastName\");\n }\n if (requestedFields.has(\"date_naissance\")) {\n if (!form.birthDate) {\n markError(\"birthDate\");\n } else if (!checkIsMajor(form.birthDate)) {\n nextErrors.notMajor = true;\n hasError = true;\n }\n }\n }\n\n if (informationType === \"identity-legal\") {\n if (requestedFields.has(\"nom\") && !form.companyName) {\n markError(\"companyName\");\n }\n if (requestedFields.has(\"siret\") && !form.siret) {\n markError(\"siret\");\n }\n if (requestedFields.has(\"tva\") && !form.tva) {\n markError(\"tva\");\n }\n }\n\n if (informationType === \"contact\") {\n if (requestedFields.has(\"email\")) {\n const emailRegex = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\n if (!form.email || !emailRegex.test(form.email)) {\n markError(\"email\");\n }\n }\n if (requestedFields.has(\"sms\")) {\n if (\n !form.phoneNumber ||\n form.phoneNumber.replace(/\\D/g, \"\").length < 6\n ) {\n markError(\"phoneNumber\");\n }\n }\n }\n\n if (\n (informationType === \"address\" || informationType === \"identity-legal\") &&\n requestedFields.has(\"adresse\")\n ) {\n if (!form.addressLine1) {\n markError(\"addressLine1\");\n }\n if (!form.postalCode) {\n markError(\"postalCode\");\n }\n if (!form.city) {\n markError(\"city\");\n }\n if (!form.countryCode) {\n markError(\"country\");\n }\n }\n\n if (\n informationType === \"nationality\" &&\n requestedFields.has(\"nationalite\")\n ) {\n if (!form.nationality) {\n markError(\"nationality\");\n }\n }\n\n setErrors(nextErrors);\n return !hasError;\n };\n\n const validateCustomForm = () => {\n const errors: Record<string, boolean> = {};\n let hasError = false;\n\n node.customFields?.forEach((field) => {\n const value = customFormData[field.id];\n\n if (field.valueType === \"list\") {\n const rows = Array.isArray(value) ? value : [];\n const minRows = getListFieldMinRows(field);\n\n if (field.required && countNonEmptyListRows(rows) < minRows) {\n errors[field.id] = true;\n hasError = true;\n }\n return;\n }\n\n // Check if required field is missing\n if (field.required && !value) {\n errors[field.id] = true;\n hasError = true;\n return;\n }\n\n // Type-specific validation\n if (value) {\n switch (field.valueType) {\n case \"number\":\n if (isNaN(Number(value))) {\n errors[field.id] = true;\n hasError = true;\n }\n break;\n\n case \"date\":\n // Date format: DD-MM-YYYY\n // For required dates, all parts must be filled\n if (field.required) {\n const dateParts = value.split(\"-\");\n if (\n dateParts.length !== 3 ||\n !dateParts[0] ||\n !dateParts[1] ||\n !dateParts[2]\n ) {\n errors[field.id] = true;\n hasError = true;\n break;\n }\n\n // Validate month and day ranges\n const day = parseInt(dateParts[0], 10);\n const month = parseInt(dateParts[1], 10);\n const year = parseInt(dateParts[2], 10);\n\n if (\n isNaN(day) ||\n isNaN(month) ||\n isNaN(year) ||\n month < 1 ||\n month > 12 ||\n day < 1 ||\n day > 31\n ) {\n errors[field.id] = true;\n hasError = true;\n }\n }\n break;\n\n case \"address\":\n // Validate address object if required\n if (field.required && typeof value === \"object\") {\n const addressValue = value as {\n addressLine1?: string;\n postalCode?: string;\n city?: string;\n countryCode?: string;\n };\n if (\n !addressValue.addressLine1 ||\n !addressValue.postalCode ||\n !addressValue.city ||\n !addressValue.countryCode\n ) {\n errors[field.id] = true;\n hasError = true;\n }\n }\n break;\n }\n }\n });\n\n setCustomFormErrors(errors);\n return !hasError;\n };\n\n const handleCustomFieldChange = (fieldId: string, value: any) => {\n setCustomFormData((prev) => ({ ...prev, [fieldId]: value }));\n setCustomFormErrors((prev) => ({ ...prev, [fieldId]: false }));\n };\n\n const goOnNextStep = () => {\n // Handle custom form validation and submission\n if (informationType === \"custom\") {\n if (!validateCustomForm()) {\n return;\n }\n\n setUserInput((prev) => ({\n ...prev,\n customFormData: { ...(prev.customFormData ?? {}), ...customFormData },\n }));\n\n if (onContinueCallback) {\n onContinueCallback();\n } else {\n goToNextStep(node.id, template);\n }\n return;\n }\n\n // Standard form validation\n if (!validateForm()) {\n return;\n }\n\n setUserInput((previous) => ({\n ...previous,\n ...(requestedFields.has(\"nom\") && {\n ...(informationType === \"identity-legal\"\n ? { companyName: form.companyName }\n : { lastName: form.lastName }),\n }),\n ...(requestedFields.has(\"prenom\") && { firstName: form.firstName }),\n ...(requestedFields.has(\"date_naissance\") && {\n birthDate: form.birthDate,\n }),\n ...(requestedFields.has(\"email\") && { email: form.email }),\n ...(requestedFields.has(\"sms\") && {\n phoneNumber: form.phoneNumber,\n sms: form.phoneNumber,\n }),\n ...(requestedFields.has(\"adresse\") && {\n addressLine1: form.addressLine1,\n addressLine2: form.addressLine2,\n postalCode: form.postalCode,\n city: form.city,\n countryCode: form.countryCode,\n }),\n ...(requestedFields.has(\"siret\") && { siret: form.siret }),\n ...(requestedFields.has(\"tva\") && { tva: form.tva }),\n ...(requestedFields.has(\"nationalite\") && {\n nationality: form.nationality,\n }),\n }));\n\n if (informationType === \"contact\" && setContactInfo) {\n setContactInfo((previous) => ({\n ...previous,\n ...(requestedFields.has(\"email\") && { email: form.email }),\n ...(requestedFields.has(\"sms\") && { phoneNumber: form.phoneNumber }),\n }));\n }\n\n if (onContinueCallback) {\n onContinueCallback();\n } else {\n goToNextStep(node.id, template);\n }\n };\n\n const goOnPreviousStep = () => {\n console.log(\"[goOnPreviousStep] called — step:\", step, \"canGoBack:\", stepObject.canGoBack);\n goBack();\n };\n\n const pageTitle = node.pageTitle || formTitles[informationType];\n\n const pageDescription =\n node.pageDescription || formDescriptions[informationType];\n\n return {\n form,\n errors,\n informationType,\n requestedFields,\n pageTitle,\n pageDescription,\n addressSuggestions,\n showSuggestions,\n handleFieldChange,\n handleAddressChange,\n handleAddressFocus,\n handleAddressBlur,\n applyAddressSuggestion,\n goOnNextStep,\n goOnPreviousStep,\n customFormData,\n customFormErrors,\n handleCustomFieldChange,\n };\n};\n"],"names":[],"mappings":";;;;;;;;AAgDO,IAAM,gBAAgB,GAAG,UAAC,EASZ,EAAA;QARnB,UAAU,GAAA,EAAA,CAAA,UAAA,EACV,YAAY,GAAA,EAAA,CAAA,YAAA,EACZ,gBAAgB,GAAA,EAAA,CAAA,gBAAA,EAChB,IAAI,GAAA,EAAA,CAAA,IAAA,EACJ,QAAQ,GAAA,EAAA,CAAA,QAAA,EACR,WAAW,GAAA,EAAA,CAAA,WAAA,EACX,cAAc,GAAA,EAAA,CAAA,cAAA,EACd,kBAAkB,GAAA,EAAA,CAAA,kBAAA;AAEV,IAAwC,UAAU,QAA3C,CAAA,KAAE,MAAM,GAAyB,UAAU,CAAA,MAAnC,EAAE,YAAY,GAAW,UAAU,CAAA,YAArB,CAAA,CAAE,IAAI,GAAK,UAAU;AAClD,IAAA,IAAA,CAAC,GAAK,OAAO,EAAE,EAAd;IAET,IAAM,eAAe,GAAG,OAAO,CAAkB,YAAA;;QAC/C,IAAM,QAAQ,GAAG,sBAAsB,CACrC,IAAI,CAAC,eAAyB,EAC9B,UAAU,CACX;AACD,QAAA,OAAO,CAAC,GAAG,CAAC,kDAAkD,EAAE;YAC9D,mBAAmB,EAAE,IAAI,CAAC,eAAe;AACzC,YAAA,QAAQ,EAAA,QAAA;AACR,YAAA,eAAe,EAAE,CAAC,CAAC,IAAI,CAAC,YAAY;AACpC,YAAA,iBAAiB,EAAE,CAAA,EAAA,GAAA,IAAI,CAAC,YAAY,0CAAE,MAAM;AAC7C,SAAA,CAAC;AACF,QAA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QAAA,iBAAiB,EAAA,iBAAA;AACjB,QAAA,sBAAsB,EAAA,sBAAA;AACtB,QAAA,YAAY,EAAA,YAAA;AACZ,QAAA,gBAAgB,EAAA,gBAAA;AAChB,QAAA,cAAc,EAAA,cAAA;AACd,QAAA,gBAAgB,EAAA,gBAAA;AAChB,QAAA,uBAAuB,EAAA,uBAAA;KACxB;AACH;;;;"}
@@ -247,6 +247,41 @@ var getNextStepIndex = function (currentNodeId, template, handle) {
247
247
  // steps are 1-indexed in the SDK (0 is StartSession)
248
248
  return 1 + targetIndex;
249
249
  };
250
+ /**
251
+ * Reconstructs the navigation history by following the graph from step 0
252
+ * up to (and including) targetStep. Returns [0, ...stepIndices].
253
+ * If the graph path cannot reach targetStep, falls back to [0, targetStep].
254
+ */
255
+ var reconstructHistoryToStep = function (targetStep, template) {
256
+ if (targetStep <= 0)
257
+ return [0];
258
+ var orderedNodes = getOrderedJourneySteps(template);
259
+ var history = [0];
260
+ var currentStep = 1; // first node is step 1
261
+ // Follow the default (first) edge from each node in sequence
262
+ for (var safetyLimit = 0; safetyLimit < orderedNodes.length + 1; safetyLimit++) {
263
+ if (currentStep === targetStep) {
264
+ history.push(currentStep);
265
+ break;
266
+ }
267
+ if (currentStep > targetStep)
268
+ break;
269
+ var nodeIndex = currentStep - 1;
270
+ var currentNode = orderedNodes[nodeIndex];
271
+ if (!currentNode)
272
+ break;
273
+ history.push(currentStep);
274
+ var nextStep = getNextStepIndex(currentNode.id, template);
275
+ if (nextStep === null)
276
+ break;
277
+ currentStep = nextStep;
278
+ }
279
+ // Fallback: if we couldn't reach targetStep via graph, use simple seed
280
+ if (history[history.length - 1] !== targetStep) {
281
+ return [0, targetStep];
282
+ }
283
+ return history;
284
+ };
250
285
  /**
251
286
  * Checks if a session has expired
252
287
  *
@@ -367,5 +402,5 @@ var clearSessionSensitiveData = function (sessionId) {
367
402
  }
368
403
  };
369
404
 
370
- export { clearSessionSensitiveData, fetchSessionById, findOutgoingEdge, getNextStepIndex, getOrderedJourneySteps, isSessionExpired, sendClientInfo, storeDocumentOptions, updateSessionContactInfo, updateSessionCurrentStep, updateSessionStatus, updateSessionUserInput };
405
+ export { clearSessionSensitiveData, fetchSessionById, findOutgoingEdge, getNextStepIndex, getOrderedJourneySteps, isSessionExpired, reconstructHistoryToStep, sendClientInfo, storeDocumentOptions, updateSessionContactInfo, updateSessionCurrentStep, updateSessionStatus, updateSessionUserInput };
371
406
  //# sourceMappingURL=sessionService.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sessionService.js","sources":["../../../../src/services/sessionService.ts"],"sourcesContent":["/**\n * Session Service\n *\n * Service for interacting with the Datakeen Session API.\n * Handles fetching session data by ID.\n */\n\nimport type {\n ClientInfo,\n SessionData,\n SessionTemplate,\n SessionTemplateNode,\n} from \"../types/session\";\nimport { apiService } from \"./api\";\nimport { logStatusModified } from \"./auditTrailService\";\nimport { clearSessionMemory } from \"./sessionMemoryStore\";\n\n/**\n * Fetches session data by ID from the Datakeen backend\n *\n * @param sessionId - The unique identifier of the session\n * @returns The session data\n */\nexport const fetchSessionById = async (\n sessionId: string,\n): Promise<SessionData> => {\n try {\n const response = await apiService.get(`/session/sdk/${sessionId}`);\n return response.data;\n } catch (error) {\n console.error(\"Error fetching session data:\", error);\n throw error;\n }\n};\n\n/** Sends client information (IP, device, browser, OS) to the backend for a specific session\n *\n * @param sessionId - The unique identifier of the session\n * @param clientInfo - The client information to send\n */\nexport const sendClientInfo = async (\n sessionId: string,\n clientInfo: ClientInfo,\n): Promise<void> => {\n try {\n await apiService.post(`/session/sdk/${sessionId}/client-info`, clientInfo);\n } catch (error) {\n console.error(\"Error sending client info:\", error);\n throw error;\n }\n};\n\n/**\n * Determines if the session template has a specific type of node\n *\n * @param template - The session template\n * @param nodeType - The type of node to check for\n * @returns true if the template has a node of the specified type, false otherwise\n */\nexport const hasNodeType = (\n template: SessionTemplate,\n nodeType: string,\n): boolean => {\n return template.nodes.some((node) => node.type === nodeType);\n};\n\n/**\n * Determines if the session template has a node with a specific requiredDocumentType\n *\n * @param template - The session template\n * @param requiredDocumentType - The requiredDocumentType to check for\n * @returns true if the template has a node with the specified requiredDocumentType, false otherwise\n */\nexport const hasDocumentTypeNode = (\n template: SessionTemplate,\n requiredDocumentType: string,\n): boolean => {\n return template.nodes.some(\n (node) => node.requiredDocumentType === requiredDocumentType,\n );\n};\n\n/**\n * Gets all nodes of a specific type\n *\n * @param template - The session template\n * @param nodeType - The type of node to get\n * @returns Array of nodes matching the type\n */\nexport const getNodesByType = (\n template: SessionTemplate,\n nodeType: string,\n): SessionTemplateNode[] => {\n return template.nodes.filter((node) => node.type === nodeType);\n};\n\n/**\n * Gets all nodes with a specific requiredDocumentType\n *\n * @param template - The session template\n * @param requiredDocumentType - The requiredDocumentType to get\n * @returns Array of nodes matching the requiredDocumentType\n */\nexport const getNodesByDocumentType = (\n template: SessionTemplate,\n requiredDocumentType: string,\n): SessionTemplateNode[] => {\n return template.nodes.filter(\n (node) => node.requiredDocumentType === requiredDocumentType,\n );\n};\n\n/**\n * Get document options for a specific document type\n *\n * @param template - The session template\n * @param requiredDocumentType - The document type to get options for\n * @returns Array of document options (empty if none found)\n */\nexport const getDocumentOptions = (\n template: SessionTemplate,\n requiredDocumentType: string,\n): string[] => {\n const node = template.nodes.find(\n (node) => node.requiredDocumentType === requiredDocumentType,\n );\n return node?.selectedOptions || [];\n};\n\n/**\n * Determines if the session template has a selfie step\n *\n * @param template - The session template\n * @returns true if the template has a selfie step, false otherwise\n */\nexport const hasSelfieCaptureStep = (template: SessionTemplate): boolean => {\n return hasNodeType(template, \"selfie-capture\");\n};\n\n/**\n * Determines if the session template has an ID document step\n *\n * @param template - The session template\n * @returns true if the template has an ID document step, false otherwise\n */\nexport const hasDocumentStep = (template: SessionTemplate): boolean => {\n // Check if there's any document-selection node with requiredDocumentType \"id-card\"\n // or if none specified, just check for document-selection nodes\n const hasIDCard = hasDocumentTypeNode(template, \"id-card\");\n return hasIDCard || hasNodeType(template, \"document-selection\");\n};\n\n/**\n * Determines if the session template has a JDD (proof of address) step\n *\n * @param template - The session template\n * @returns true if the template has a JDD step, false otherwise\n */\nexport const hasJDDStep = (template: SessionTemplate): boolean => {\n return hasDocumentTypeNode(template, \"jdd\");\n};\n\n/**\n * Determines if the session template has a proof of funds step\n *\n * @param template - The session template\n * @returns true if the template has a proof of funds step, false otherwise\n */\nexport const hasProofOfFundsStep = (template: SessionTemplate): boolean => {\n return hasDocumentTypeNode(template, \"income-proof\");\n};\n\n/**\n * Determines if the session template has a document collection step\n *\n * @param template - The session template\n * @returns true if the template has a document collection step, false otherwise\n */\nexport const hasDocumentCollectionStep = (\n template: SessionTemplate,\n): boolean => {\n return hasNodeType(template, \"document-collection\");\n};\n\n/**\n * Gets all node types in the template\n *\n * @param template - The session template\n * @returns Array of node types in the template\n */\nexport const getNodeTypes = (template: SessionTemplate): string[] => {\n return Array.from(new Set(template.nodes.map((node) => node.type)));\n};\n\n/**\n * Gets all document types required in the template\n *\n * @param template - The session template\n * @returns Array of document types required in the template\n */\nexport const getRequiredDocumentTypes = (\n template: SessionTemplate,\n): string[] => {\n return Array.from(\n new Set(\n template.nodes\n .filter((node) => node.requiredDocumentType)\n .map((node) => node.requiredDocumentType!),\n ),\n );\n};\n\n/**\n * Converts template document type to internal document type\n * This helps standardize document types between the template and the application\n *\n * @param templateDocType - The document type as defined in the template\n * @returns The internal document type used by the application\n */\nexport const convertTemplateDocTypeToInternal = (\n templateDocType: string,\n): string => {\n if (!templateDocType) return \"\";\n\n // Mapping between template document types and internal document types\n const typeMap: Record<string, string> = {\n \"id-card\": \"id-card\",\n jdd: \"jdd\",\n \"income-proof\": \"income-proof\", // Using consistent naming\n };\n\n return typeMap[templateDocType] || templateDocType;\n};\n\n/**\n * Converts internal document type to template document type\n *\n * @param internalDocType - The document type used internally by the application\n * @returns The document type as expected in the template\n */\nexport const convertInternalDocTypeToTemplate = (\n internalDocType: string,\n): string => {\n if (!internalDocType) return \"\";\n\n // Mapping between internal document types and template document types\n const typeMap: Record<string, string> = {\n \"id-card\": \"id-card\",\n jdd: \"jdd\",\n funds: \"income-proof\", // Map funds to income-proof for backwards compatibility\n \"income-proof\": \"income-proof\",\n };\n\n return typeMap[internalDocType] || internalDocType;\n};\n\n/**\n * Updates session data with user input information\n *\n * @param sessionId - The unique identifier of the session\n * @param userInput - The user input data (firstName, lastName, birthDate)\n * @returns The updated session data\n */\nexport const updateSessionUserInput = async (\n sessionId: string,\n userInput: {\n firstName?: string;\n lastName?: string;\n birthDate?: string;\n [key: string]: unknown;\n },\n): Promise<SessionData> => {\n try {\n const response = await apiService.patch(`/session/sdk/${sessionId}`, {\n userInput,\n });\n return response.data;\n } catch (error) {\n console.error(\"Error updating session data:\", error);\n throw error;\n }\n};\n\n/**\n * Updates session data with contact information\n *\n * @param sessionId - The unique identifier of the session\n * @param contactInfo - The contact information data (email, phoneNumber)\n * @returns The updated session data\n */\nexport const updateSessionContactInfo = async (\n sessionId: string,\n contactInfo: {\n email: string;\n phoneNumber: string;\n [key: string]: unknown;\n },\n): Promise<SessionData> => {\n try {\n const response = await apiService.patch(`/session/sdk/${sessionId}`, {\n contactInfo,\n });\n return response.data;\n } catch (error) {\n console.error(\"Error updating contact information:\", error);\n throw error;\n }\n};\n\n/**\n * Updates session status\n *\n * @param sessionId - The unique identifier of the session\n * @param status - The new status for the session\n * @returns The updated session data\n */\nexport const updateSessionStatus = async (\n sessionId: string,\n status: string,\n): Promise<SessionData> => {\n try {\n const response = await apiService.patch(`/session/sdk/${sessionId}`, {\n status,\n });\n\n // Log status modification in audit trail\n if (response.data && response.data.analysisId) {\n try {\n await logStatusModified(\n sessionId,\n status,\n response.data.clientInfoId || undefined,\n );\n } catch (err) {\n console.error(\"Failed to log status modification in audit trail:\", err);\n // Non-blocking error - continue session\n }\n }\n\n return response.data;\n } catch (error) {\n console.error(\"Error updating session status:\", error);\n throw error;\n }\n};\n\n/**\n * Updates the current step in the session\n *\n * @param sessionId - The unique identifier of the session\n * @param currentStep - The current step index in the workflow\n * @returns The updated session data\n */\nexport const updateSessionCurrentStep = async (\n sessionId: string,\n currentStep: number,\n): Promise<SessionData> => {\n try {\n const response = await apiService.patch(`/session/sdk/${sessionId}`, {\n currentStep,\n });\n return response.data;\n } catch (error) {\n console.error(\"Error updating session current step:\", error);\n throw error;\n }\n};\n\n/**\n * Gets the journey steps from the template in order\n *\n * @param template - The session template\n * @returns Array of ordered steps\n */\nexport const getOrderedJourneySteps = (\n template: SessionTemplate,\n): SessionTemplateNode[] => {\n // Filter out only start nodes, keep end nodes for proper journey completion, then sort by order\n return template.nodes\n .filter((node) => node.type !== \"start\")\n .sort((a, b) => a.order - b.order);\n};\n\nconst normalizeHandle = (value?: string): string => {\n return (value || \"\").trim().toLowerCase();\n};\n\n/**\n * Finds the outgoing edge to follow from a node.\n *\n * Resolution order:\n * 1. Exact handle match via sourceHandle/conditionValue.\n * 2. For condition:false loops, fallback to targetHandle=right.\n * 3. First outgoing edge as final fallback.\n */\nexport const findOutgoingEdge = (\n currentNodeId: string,\n template: SessionTemplate,\n handle?: string,\n): SessionTemplate[\"edges\"][number] | null => {\n const outgoingEdges = (template.edges || []).filter(\n (edge) => edge.source === currentNodeId,\n );\n\n if (outgoingEdges.length === 0) {\n return null;\n }\n\n if (!handle) {\n return outgoingEdges[0];\n }\n\n const normalizedHandle = normalizeHandle(handle);\n const edgeByHandle = outgoingEdges.find((edge) => {\n return (\n normalizeHandle(edge.sourceHandle) === normalizedHandle ||\n normalizeHandle(edge.conditionValue) === normalizedHandle\n );\n });\n\n if (edgeByHandle) {\n return edgeByHandle;\n }\n\n const currentNode = template.nodes.find((node) => node.id === currentNodeId);\n if (currentNode?.type === \"condition\" && normalizedHandle === \"false\") {\n const rightHandleLoopEdge = outgoingEdges.find(\n (edge) => normalizeHandle(edge.targetHandle) === \"right\",\n );\n if (rightHandleLoopEdge) {\n return rightHandleLoopEdge;\n }\n }\n\n return outgoingEdges[0];\n};\n\n/**\n * Gets the next step index by following the graph edge from the current node\n *\n * @param currentNodeId - The ID of the current node\n * @param template - The session template\n * @returns The next step index (1-based) or null if no edge found\n */\nexport const getNextStepIndex = (\n currentNodeId: string,\n template: SessionTemplate,\n handle?: string,\n): number | null => {\n const orderedNodes = getOrderedJourneySteps(template);\n const edge = findOutgoingEdge(currentNodeId, template, handle);\n\n if (!edge) {\n console.debug(\n `[sessionService] No outgoing edge found for node ${currentNodeId}${handle ? ` with handle ${handle}` : \"\"}`,\n );\n return null;\n }\n\n const targetId = edge.target;\n const targetIndex = orderedNodes.findIndex((n) => n.id === targetId);\n\n if (targetIndex === -1) {\n console.debug(\n `[sessionService] Target node ${targetId} not found in ordered steps`,\n );\n return null;\n }\n\n // steps are 1-indexed in the SDK (0 is StartSession)\n return 1 + targetIndex;\n};\n\n/**\n * Maps a template node type to a step component type\n *\n * @param node - The session template node\n * @returns The step component type\n */\nexport const getStepComponentType = (node: SessionTemplateNode): string => {\n // Map from template node types to component types\n const typeMap: Record<string, string> = {\n \"document-selection\": \"document\",\n \"document-collection\": \"document-collection\",\n \"selfie-capture\": \"selfie\",\n \"contact-info\": \"contact-info\",\n \"user-input\": \"user-input\",\n \"otp-verification\": \"otp\",\n };\n\n // First check the node type\n if (node.type in typeMap) {\n return typeMap[node.type];\n }\n\n // Then check the requiredDocumentType\n if (node.requiredDocumentType) {\n return node.requiredDocumentType;\n }\n\n // Default fallback\n return node.type;\n};\n\n/**\n * Checks if a session has expired\n *\n * @param session - The session data to check\n * @returns true if the session has expired, false otherwise\n */\nexport const isSessionExpired = (session: SessionData): boolean => {\n if (!session.expireTime) {\n return false;\n }\n\n const currentTime = Date.now();\n return currentTime > session.expireTime;\n};\n\n/**\n * Stores document options in localStorage for a specific document type\n *\n * @param sessionId - The session ID\n * @param documentTypeId - The document type ID (e.g., 'jdd', 'income-proof')\n * @param options - The options to store\n */\nexport const storeDocumentOptions = (\n sessionId: string,\n documentTypeId: string,\n options: string[],\n): void => {\n if (!sessionId || !documentTypeId || !options || options.length === 0) {\n console.warn(\"Missing data for storeDocumentOptions:\", {\n sessionId,\n documentTypeId,\n options,\n });\n return;\n }\n\n // Create a consistent key format based on document type\n let storageKey = \"\";\n\n switch (documentTypeId) {\n case \"jdd\":\n storageKey = `jddOptions_${sessionId}`;\n break;\n case \"income-proof\":\n storageKey = `fundsOptions_${sessionId}`;\n break;\n case \"id-card\":\n storageKey = `idOptions_${sessionId}`;\n break;\n case \"document-collection\":\n storageKey = `documentCollectionOptions_${sessionId}`;\n break;\n default:\n storageKey = `${documentTypeId}Options_${sessionId}`;\n }\n\n localStorage.setItem(storageKey, JSON.stringify(options));\n};\n\n/**\n * Retrieves document options from localStorage for a specific document type\n *\n * @param sessionId - The session ID\n * @param documentTypeId - The document type ID (e.g., 'jdd', 'income-proof')\n * @returns Array of options or default options if none found\n */\nexport const retrieveDocumentOptions = (\n sessionId: string,\n documentTypeId: string,\n): string[] => {\n if (!sessionId || !documentTypeId) {\n console.warn(\"Missing data for retrieveDocumentOptions:\", {\n sessionId,\n documentTypeId,\n });\n return [];\n }\n\n // Create consistent key formats to check\n const possibleKeys = [\n `${documentTypeId}Options_${sessionId}`,\n documentTypeId === \"jdd\" ? `jddOptions_${sessionId}` : \"\",\n documentTypeId === \"income-proof\" ? `fundsOptions_${sessionId}` : \"\",\n documentTypeId === \"id-card\" ? `idOptions_${sessionId}` : \"\",\n documentTypeId === \"document-collection\"\n ? `documentCollectionOptions_${sessionId}`\n : \"\",\n ].filter(Boolean);\n\n // Try each possible key\n for (const key of possibleKeys) {\n const savedOptions = localStorage.getItem(key);\n if (savedOptions) {\n try {\n const parsedOptions = JSON.parse(savedOptions);\n\n return parsedOptions;\n } catch (e) {\n console.error(\n `Error parsing options for ${documentTypeId} with key ${key}:`,\n e,\n );\n }\n }\n }\n\n // Return default options if none found\n console.warn(`No options found for ${documentTypeId}, using defaults`);\n if (documentTypeId === \"jdd\") {\n return [\n \"Facture d'électricité (< 3 mois)\",\n \"Facture de gaz (< 3 mois)\",\n \"Facture d'eau (< 3 mois)\",\n \"Quittance de loyer (< 3 mois)\",\n \"Facture téléphone/internet (< 3 mois)\",\n \"Attestation d'assurance habitation (< 3 mois)\",\n ];\n } else if (documentTypeId === \"income-proof\") {\n return [\n \"Bulletin de salaire\",\n \"Avis d'imposition\",\n \"Relevé de compte bancaire\",\n \"Attestation de revenus\",\n \"Contrat de travail\",\n ];\n } else if (documentTypeId === \"id-card\") {\n return [\"Carte nationale d'identité\", \"Passeport\", \"Permis de conduire\"];\n } else if (documentTypeId === \"document-collection\") {\n return [\"Document administratif\", \"Justificatif\", \"Attestation\"];\n }\n\n return [];\n};\n\nconst clearStorageBySessionId = (sessionId: string): void => {\n const scopedKeys = [\n `userInput_${sessionId}`,\n `contactInfo_${sessionId}`,\n `sessionData_${sessionId}`,\n ];\n\n scopedKeys.forEach((key) => {\n localStorage.removeItem(key);\n sessionStorage.removeItem(key);\n });\n\n for (let i = localStorage.length - 1; i >= 0; i -= 1) {\n const key = localStorage.key(i);\n if (!key) {\n continue;\n }\n if (key.endsWith(`_${sessionId}`)) {\n localStorage.removeItem(key);\n }\n }\n\n for (let i = sessionStorage.length - 1; i >= 0; i -= 1) {\n const key = sessionStorage.key(i);\n if (!key) {\n continue;\n }\n if (key.endsWith(`_${sessionId}`)) {\n sessionStorage.removeItem(key);\n }\n }\n\n if (localStorage.getItem(\"sessionId\") === sessionId) {\n localStorage.removeItem(\"sessionId\");\n }\n if (sessionStorage.getItem(\"sessionId\") === sessionId) {\n sessionStorage.removeItem(\"sessionId\");\n }\n};\n\n/**\n * Clears all client-side session traces (memory + browser storage)\n * for a given session. This is intentionally aggressive for security.\n */\nexport const clearSessionSensitiveData = (sessionId?: string): void => {\n clearSessionMemory(sessionId);\n\n if (sessionId) {\n clearStorageBySessionId(sessionId);\n return;\n }\n\n localStorage.removeItem(\"sessionId\");\n sessionStorage.removeItem(\"sessionId\");\n\n for (let i = localStorage.length - 1; i >= 0; i -= 1) {\n const key = localStorage.key(i);\n if (!key) {\n continue;\n }\n if (\n key.startsWith(\"userInput_\") ||\n key.startsWith(\"contactInfo_\") ||\n key.includes(\"Options_\")\n ) {\n localStorage.removeItem(key);\n }\n }\n\n for (let i = sessionStorage.length - 1; i >= 0; i -= 1) {\n const key = sessionStorage.key(i);\n if (!key) {\n continue;\n }\n if (\n key.startsWith(\"userInput_\") ||\n key.startsWith(\"contactInfo_\") ||\n key.includes(\"Options_\")\n ) {\n sessionStorage.removeItem(key);\n }\n }\n};\n"],"names":[],"mappings":";;;;;AAAA;;;;;AAKG;AAYH;;;;;AAKG;AACI,IAAM,gBAAgB,GAAG,UAC9B,SAAiB,EAAA,EAAA,OAAA,SAAA,CAAA,MAAA,EAAA,MAAA,EAAA,MAAA,EAAA,YAAA;;;;;;gBAGE,OAAA,CAAA,CAAA,YAAM,UAAU,CAAC,GAAG,CAAC,uBAAgB,SAAS,CAAE,CAAC,CAAA;;AAA5D,gBAAA,QAAQ,GAAG,EAAA,CAAA,IAAA,EAAiD;gBAClE,OAAA,CAAA,CAAA,aAAO,QAAQ,CAAC,IAAI,CAAA;;;AAEpB,gBAAA,OAAO,CAAC,KAAK,CAAC,8BAA8B,EAAE,OAAK,CAAC;AACpD,gBAAA,MAAM,OAAK;;;;;AAIf;;;;AAIG;AACI,IAAM,cAAc,GAAG,UAC5B,SAAiB,EACjB,UAAsB,EAAA,EAAA,OAAA,SAAA,CAAA,MAAA,EAAA,MAAA,EAAA,MAAA,EAAA,YAAA;;;;;;gBAGpB,OAAA,CAAA,CAAA,YAAM,UAAU,CAAC,IAAI,CAAC,eAAA,CAAA,MAAA,CAAgB,SAAS,EAAA,cAAA,CAAc,EAAE,UAAU,CAAC,CAAA;;AAA1E,gBAAA,EAAA,CAAA,IAAA,EAA0E;;;;AAE1E,gBAAA,OAAO,CAAC,KAAK,CAAC,4BAA4B,EAAE,OAAK,CAAC;AAClD,gBAAA,MAAM,OAAK;;;;;AAgNf;;;;;;AAMG;AACI,IAAM,sBAAsB,GAAG,UACpC,SAAiB,EACjB,SAKC,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/sessionService.ts"],"sourcesContent":["/**\n * Session Service\n *\n * Service for interacting with the Datakeen Session API.\n * Handles fetching session data by ID.\n */\n\nimport type {\n ClientInfo,\n SessionData,\n SessionTemplate,\n SessionTemplateNode,\n} from \"../types/session\";\nimport { apiService } from \"./api\";\nimport { logStatusModified } from \"./auditTrailService\";\nimport { clearSessionMemory } from \"./sessionMemoryStore\";\n\n/**\n * Fetches session data by ID from the Datakeen backend\n *\n * @param sessionId - The unique identifier of the session\n * @returns The session data\n */\nexport const fetchSessionById = async (\n sessionId: string,\n): Promise<SessionData> => {\n try {\n const response = await apiService.get(`/session/sdk/${sessionId}`);\n return response.data;\n } catch (error) {\n console.error(\"Error fetching session data:\", error);\n throw error;\n }\n};\n\n/** Sends client information (IP, device, browser, OS) to the backend for a specific session\n *\n * @param sessionId - The unique identifier of the session\n * @param clientInfo - The client information to send\n */\nexport const sendClientInfo = async (\n sessionId: string,\n clientInfo: ClientInfo,\n): Promise<void> => {\n try {\n await apiService.post(`/session/sdk/${sessionId}/client-info`, clientInfo);\n } catch (error) {\n console.error(\"Error sending client info:\", error);\n throw error;\n }\n};\n\n/**\n * Determines if the session template has a specific type of node\n *\n * @param template - The session template\n * @param nodeType - The type of node to check for\n * @returns true if the template has a node of the specified type, false otherwise\n */\nexport const hasNodeType = (\n template: SessionTemplate,\n nodeType: string,\n): boolean => {\n return template.nodes.some((node) => node.type === nodeType);\n};\n\n/**\n * Determines if the session template has a node with a specific requiredDocumentType\n *\n * @param template - The session template\n * @param requiredDocumentType - The requiredDocumentType to check for\n * @returns true if the template has a node with the specified requiredDocumentType, false otherwise\n */\nexport const hasDocumentTypeNode = (\n template: SessionTemplate,\n requiredDocumentType: string,\n): boolean => {\n return template.nodes.some(\n (node) => node.requiredDocumentType === requiredDocumentType,\n );\n};\n\n/**\n * Gets all nodes of a specific type\n *\n * @param template - The session template\n * @param nodeType - The type of node to get\n * @returns Array of nodes matching the type\n */\nexport const getNodesByType = (\n template: SessionTemplate,\n nodeType: string,\n): SessionTemplateNode[] => {\n return template.nodes.filter((node) => node.type === nodeType);\n};\n\n/**\n * Gets all nodes with a specific requiredDocumentType\n *\n * @param template - The session template\n * @param requiredDocumentType - The requiredDocumentType to get\n * @returns Array of nodes matching the requiredDocumentType\n */\nexport const getNodesByDocumentType = (\n template: SessionTemplate,\n requiredDocumentType: string,\n): SessionTemplateNode[] => {\n return template.nodes.filter(\n (node) => node.requiredDocumentType === requiredDocumentType,\n );\n};\n\n/**\n * Get document options for a specific document type\n *\n * @param template - The session template\n * @param requiredDocumentType - The document type to get options for\n * @returns Array of document options (empty if none found)\n */\nexport const getDocumentOptions = (\n template: SessionTemplate,\n requiredDocumentType: string,\n): string[] => {\n const node = template.nodes.find(\n (node) => node.requiredDocumentType === requiredDocumentType,\n );\n return node?.selectedOptions || [];\n};\n\n/**\n * Determines if the session template has a selfie step\n *\n * @param template - The session template\n * @returns true if the template has a selfie step, false otherwise\n */\nexport const hasSelfieCaptureStep = (template: SessionTemplate): boolean => {\n return hasNodeType(template, \"selfie-capture\");\n};\n\n/**\n * Determines if the session template has an ID document step\n *\n * @param template - The session template\n * @returns true if the template has an ID document step, false otherwise\n */\nexport const hasDocumentStep = (template: SessionTemplate): boolean => {\n // Check if there's any document-selection node with requiredDocumentType \"id-card\"\n // or if none specified, just check for document-selection nodes\n const hasIDCard = hasDocumentTypeNode(template, \"id-card\");\n return hasIDCard || hasNodeType(template, \"document-selection\");\n};\n\n/**\n * Determines if the session template has a JDD (proof of address) step\n *\n * @param template - The session template\n * @returns true if the template has a JDD step, false otherwise\n */\nexport const hasJDDStep = (template: SessionTemplate): boolean => {\n return hasDocumentTypeNode(template, \"jdd\");\n};\n\n/**\n * Determines if the session template has a proof of funds step\n *\n * @param template - The session template\n * @returns true if the template has a proof of funds step, false otherwise\n */\nexport const hasProofOfFundsStep = (template: SessionTemplate): boolean => {\n return hasDocumentTypeNode(template, \"income-proof\");\n};\n\n/**\n * Determines if the session template has a document collection step\n *\n * @param template - The session template\n * @returns true if the template has a document collection step, false otherwise\n */\nexport const hasDocumentCollectionStep = (\n template: SessionTemplate,\n): boolean => {\n return hasNodeType(template, \"document-collection\");\n};\n\n/**\n * Gets all node types in the template\n *\n * @param template - The session template\n * @returns Array of node types in the template\n */\nexport const getNodeTypes = (template: SessionTemplate): string[] => {\n return Array.from(new Set(template.nodes.map((node) => node.type)));\n};\n\n/**\n * Gets all document types required in the template\n *\n * @param template - The session template\n * @returns Array of document types required in the template\n */\nexport const getRequiredDocumentTypes = (\n template: SessionTemplate,\n): string[] => {\n return Array.from(\n new Set(\n template.nodes\n .filter((node) => node.requiredDocumentType)\n .map((node) => node.requiredDocumentType!),\n ),\n );\n};\n\n/**\n * Converts template document type to internal document type\n * This helps standardize document types between the template and the application\n *\n * @param templateDocType - The document type as defined in the template\n * @returns The internal document type used by the application\n */\nexport const convertTemplateDocTypeToInternal = (\n templateDocType: string,\n): string => {\n if (!templateDocType) return \"\";\n\n // Mapping between template document types and internal document types\n const typeMap: Record<string, string> = {\n \"id-card\": \"id-card\",\n jdd: \"jdd\",\n \"income-proof\": \"income-proof\", // Using consistent naming\n };\n\n return typeMap[templateDocType] || templateDocType;\n};\n\n/**\n * Converts internal document type to template document type\n *\n * @param internalDocType - The document type used internally by the application\n * @returns The document type as expected in the template\n */\nexport const convertInternalDocTypeToTemplate = (\n internalDocType: string,\n): string => {\n if (!internalDocType) return \"\";\n\n // Mapping between internal document types and template document types\n const typeMap: Record<string, string> = {\n \"id-card\": \"id-card\",\n jdd: \"jdd\",\n funds: \"income-proof\", // Map funds to income-proof for backwards compatibility\n \"income-proof\": \"income-proof\",\n };\n\n return typeMap[internalDocType] || internalDocType;\n};\n\n/**\n * Updates session data with user input information\n *\n * @param sessionId - The unique identifier of the session\n * @param userInput - The user input data (firstName, lastName, birthDate)\n * @returns The updated session data\n */\nexport const updateSessionUserInput = async (\n sessionId: string,\n userInput: {\n firstName?: string;\n lastName?: string;\n birthDate?: string;\n [key: string]: unknown;\n },\n): Promise<SessionData> => {\n try {\n const response = await apiService.patch(`/session/sdk/${sessionId}`, {\n userInput,\n });\n return response.data;\n } catch (error) {\n console.error(\"Error updating session data:\", error);\n throw error;\n }\n};\n\n/**\n * Updates session data with contact information\n *\n * @param sessionId - The unique identifier of the session\n * @param contactInfo - The contact information data (email, phoneNumber)\n * @returns The updated session data\n */\nexport const updateSessionContactInfo = async (\n sessionId: string,\n contactInfo: {\n email: string;\n phoneNumber: string;\n [key: string]: unknown;\n },\n): Promise<SessionData> => {\n try {\n const response = await apiService.patch(`/session/sdk/${sessionId}`, {\n contactInfo,\n });\n return response.data;\n } catch (error) {\n console.error(\"Error updating contact information:\", error);\n throw error;\n }\n};\n\n/**\n * Updates session status\n *\n * @param sessionId - The unique identifier of the session\n * @param status - The new status for the session\n * @returns The updated session data\n */\nexport const updateSessionStatus = async (\n sessionId: string,\n status: string,\n): Promise<SessionData> => {\n try {\n const response = await apiService.patch(`/session/sdk/${sessionId}`, {\n status,\n });\n\n // Log status modification in audit trail\n if (response.data && response.data.analysisId) {\n try {\n await logStatusModified(\n sessionId,\n status,\n response.data.clientInfoId || undefined,\n );\n } catch (err) {\n console.error(\"Failed to log status modification in audit trail:\", err);\n // Non-blocking error - continue session\n }\n }\n\n return response.data;\n } catch (error) {\n console.error(\"Error updating session status:\", error);\n throw error;\n }\n};\n\n/**\n * Updates the current step in the session\n *\n * @param sessionId - The unique identifier of the session\n * @param currentStep - The current step index in the workflow\n * @returns The updated session data\n */\nexport const updateSessionCurrentStep = async (\n sessionId: string,\n currentStep: number,\n): Promise<SessionData> => {\n try {\n const response = await apiService.patch(`/session/sdk/${sessionId}`, {\n currentStep,\n });\n return response.data;\n } catch (error) {\n console.error(\"Error updating session current step:\", error);\n throw error;\n }\n};\n\n/**\n * Gets the journey steps from the template in order\n *\n * @param template - The session template\n * @returns Array of ordered steps\n */\nexport const getOrderedJourneySteps = (\n template: SessionTemplate,\n): SessionTemplateNode[] => {\n // Filter out only start nodes, keep end nodes for proper journey completion, then sort by order\n return template.nodes\n .filter((node) => node.type !== \"start\")\n .sort((a, b) => a.order - b.order);\n};\n\nconst normalizeHandle = (value?: string): string => {\n return (value || \"\").trim().toLowerCase();\n};\n\n/**\n * Finds the outgoing edge to follow from a node.\n *\n * Resolution order:\n * 1. Exact handle match via sourceHandle/conditionValue.\n * 2. For condition:false loops, fallback to targetHandle=right.\n * 3. First outgoing edge as final fallback.\n */\nexport const findOutgoingEdge = (\n currentNodeId: string,\n template: SessionTemplate,\n handle?: string,\n): SessionTemplate[\"edges\"][number] | null => {\n const outgoingEdges = (template.edges || []).filter(\n (edge) => edge.source === currentNodeId,\n );\n\n if (outgoingEdges.length === 0) {\n return null;\n }\n\n if (!handle) {\n return outgoingEdges[0];\n }\n\n const normalizedHandle = normalizeHandle(handle);\n const edgeByHandle = outgoingEdges.find((edge) => {\n return (\n normalizeHandle(edge.sourceHandle) === normalizedHandle ||\n normalizeHandle(edge.conditionValue) === normalizedHandle\n );\n });\n\n if (edgeByHandle) {\n return edgeByHandle;\n }\n\n const currentNode = template.nodes.find((node) => node.id === currentNodeId);\n if (currentNode?.type === \"condition\" && normalizedHandle === \"false\") {\n const rightHandleLoopEdge = outgoingEdges.find(\n (edge) => normalizeHandle(edge.targetHandle) === \"right\",\n );\n if (rightHandleLoopEdge) {\n return rightHandleLoopEdge;\n }\n }\n\n return outgoingEdges[0];\n};\n\n/**\n * Gets the next step index by following the graph edge from the current node\n *\n * @param currentNodeId - The ID of the current node\n * @param template - The session template\n * @returns The next step index (1-based) or null if no edge found\n */\nexport const getNextStepIndex = (\n currentNodeId: string,\n template: SessionTemplate,\n handle?: string,\n): number | null => {\n const orderedNodes = getOrderedJourneySteps(template);\n const edge = findOutgoingEdge(currentNodeId, template, handle);\n\n if (!edge) {\n console.debug(\n `[sessionService] No outgoing edge found for node ${currentNodeId}${handle ? ` with handle ${handle}` : \"\"}`,\n );\n return null;\n }\n\n const targetId = edge.target;\n const targetIndex = orderedNodes.findIndex((n) => n.id === targetId);\n\n if (targetIndex === -1) {\n console.debug(\n `[sessionService] Target node ${targetId} not found in ordered steps`,\n );\n return null;\n }\n\n // steps are 1-indexed in the SDK (0 is StartSession)\n return 1 + targetIndex;\n};\n\n/**\n * Reconstructs the navigation history by following the graph from step 0\n * up to (and including) targetStep. Returns [0, ...stepIndices].\n * If the graph path cannot reach targetStep, falls back to [0, targetStep].\n */\nexport const reconstructHistoryToStep = (\n targetStep: number,\n template: SessionTemplate,\n): number[] => {\n if (targetStep <= 0) return [0];\n\n const orderedNodes = getOrderedJourneySteps(template);\n const history: number[] = [0];\n let currentStep = 1; // first node is step 1\n\n // Follow the default (first) edge from each node in sequence\n for (let safetyLimit = 0; safetyLimit < orderedNodes.length + 1; safetyLimit++) {\n if (currentStep === targetStep) {\n history.push(currentStep);\n break;\n }\n if (currentStep > targetStep) break;\n\n const nodeIndex = currentStep - 1;\n const currentNode = orderedNodes[nodeIndex];\n if (!currentNode) break;\n\n history.push(currentStep);\n\n const nextStep = getNextStepIndex(currentNode.id, template);\n if (nextStep === null) break;\n currentStep = nextStep;\n }\n\n // Fallback: if we couldn't reach targetStep via graph, use simple seed\n if (history[history.length - 1] !== targetStep) {\n return [0, targetStep];\n }\n\n return history;\n};\n\n/**\n * Maps a template node type to a step component type\n *\n * @param node - The session template node\n * @returns The step component type\n */\nexport const getStepComponentType = (node: SessionTemplateNode): string => {\n // Map from template node types to component types\n const typeMap: Record<string, string> = {\n \"document-selection\": \"document\",\n \"document-collection\": \"document-collection\",\n \"selfie-capture\": \"selfie\",\n \"contact-info\": \"contact-info\",\n \"user-input\": \"user-input\",\n \"otp-verification\": \"otp\",\n };\n\n // First check the node type\n if (node.type in typeMap) {\n return typeMap[node.type];\n }\n\n // Then check the requiredDocumentType\n if (node.requiredDocumentType) {\n return node.requiredDocumentType;\n }\n\n // Default fallback\n return node.type;\n};\n\n/**\n * Checks if a session has expired\n *\n * @param session - The session data to check\n * @returns true if the session has expired, false otherwise\n */\nexport const isSessionExpired = (session: SessionData): boolean => {\n if (!session.expireTime) {\n return false;\n }\n\n const currentTime = Date.now();\n return currentTime > session.expireTime;\n};\n\n/**\n * Stores document options in localStorage for a specific document type\n *\n * @param sessionId - The session ID\n * @param documentTypeId - The document type ID (e.g., 'jdd', 'income-proof')\n * @param options - The options to store\n */\nexport const storeDocumentOptions = (\n sessionId: string,\n documentTypeId: string,\n options: string[],\n): void => {\n if (!sessionId || !documentTypeId || !options || options.length === 0) {\n console.warn(\"Missing data for storeDocumentOptions:\", {\n sessionId,\n documentTypeId,\n options,\n });\n return;\n }\n\n // Create a consistent key format based on document type\n let storageKey = \"\";\n\n switch (documentTypeId) {\n case \"jdd\":\n storageKey = `jddOptions_${sessionId}`;\n break;\n case \"income-proof\":\n storageKey = `fundsOptions_${sessionId}`;\n break;\n case \"id-card\":\n storageKey = `idOptions_${sessionId}`;\n break;\n case \"document-collection\":\n storageKey = `documentCollectionOptions_${sessionId}`;\n break;\n default:\n storageKey = `${documentTypeId}Options_${sessionId}`;\n }\n\n localStorage.setItem(storageKey, JSON.stringify(options));\n};\n\n/**\n * Retrieves document options from localStorage for a specific document type\n *\n * @param sessionId - The session ID\n * @param documentTypeId - The document type ID (e.g., 'jdd', 'income-proof')\n * @returns Array of options or default options if none found\n */\nexport const retrieveDocumentOptions = (\n sessionId: string,\n documentTypeId: string,\n): string[] => {\n if (!sessionId || !documentTypeId) {\n console.warn(\"Missing data for retrieveDocumentOptions:\", {\n sessionId,\n documentTypeId,\n });\n return [];\n }\n\n // Create consistent key formats to check\n const possibleKeys = [\n `${documentTypeId}Options_${sessionId}`,\n documentTypeId === \"jdd\" ? `jddOptions_${sessionId}` : \"\",\n documentTypeId === \"income-proof\" ? `fundsOptions_${sessionId}` : \"\",\n documentTypeId === \"id-card\" ? `idOptions_${sessionId}` : \"\",\n documentTypeId === \"document-collection\"\n ? `documentCollectionOptions_${sessionId}`\n : \"\",\n ].filter(Boolean);\n\n // Try each possible key\n for (const key of possibleKeys) {\n const savedOptions = localStorage.getItem(key);\n if (savedOptions) {\n try {\n const parsedOptions = JSON.parse(savedOptions);\n\n return parsedOptions;\n } catch (e) {\n console.error(\n `Error parsing options for ${documentTypeId} with key ${key}:`,\n e,\n );\n }\n }\n }\n\n // Return default options if none found\n console.warn(`No options found for ${documentTypeId}, using defaults`);\n if (documentTypeId === \"jdd\") {\n return [\n \"Facture d'électricité (< 3 mois)\",\n \"Facture de gaz (< 3 mois)\",\n \"Facture d'eau (< 3 mois)\",\n \"Quittance de loyer (< 3 mois)\",\n \"Facture téléphone/internet (< 3 mois)\",\n \"Attestation d'assurance habitation (< 3 mois)\",\n ];\n } else if (documentTypeId === \"income-proof\") {\n return [\n \"Bulletin de salaire\",\n \"Avis d'imposition\",\n \"Relevé de compte bancaire\",\n \"Attestation de revenus\",\n \"Contrat de travail\",\n ];\n } else if (documentTypeId === \"id-card\") {\n return [\"Carte nationale d'identité\", \"Passeport\", \"Permis de conduire\"];\n } else if (documentTypeId === \"document-collection\") {\n return [\"Document administratif\", \"Justificatif\", \"Attestation\"];\n }\n\n return [];\n};\n\nconst clearStorageBySessionId = (sessionId: string): void => {\n const scopedKeys = [\n `userInput_${sessionId}`,\n `contactInfo_${sessionId}`,\n `sessionData_${sessionId}`,\n ];\n\n scopedKeys.forEach((key) => {\n localStorage.removeItem(key);\n sessionStorage.removeItem(key);\n });\n\n for (let i = localStorage.length - 1; i >= 0; i -= 1) {\n const key = localStorage.key(i);\n if (!key) {\n continue;\n }\n if (key.endsWith(`_${sessionId}`)) {\n localStorage.removeItem(key);\n }\n }\n\n for (let i = sessionStorage.length - 1; i >= 0; i -= 1) {\n const key = sessionStorage.key(i);\n if (!key) {\n continue;\n }\n if (key.endsWith(`_${sessionId}`)) {\n sessionStorage.removeItem(key);\n }\n }\n\n if (localStorage.getItem(\"sessionId\") === sessionId) {\n localStorage.removeItem(\"sessionId\");\n }\n if (sessionStorage.getItem(\"sessionId\") === sessionId) {\n sessionStorage.removeItem(\"sessionId\");\n }\n};\n\n/**\n * Clears all client-side session traces (memory + browser storage)\n * for a given session. This is intentionally aggressive for security.\n */\nexport const clearSessionSensitiveData = (sessionId?: string): void => {\n clearSessionMemory(sessionId);\n\n if (sessionId) {\n clearStorageBySessionId(sessionId);\n return;\n }\n\n localStorage.removeItem(\"sessionId\");\n sessionStorage.removeItem(\"sessionId\");\n\n for (let i = localStorage.length - 1; i >= 0; i -= 1) {\n const key = localStorage.key(i);\n if (!key) {\n continue;\n }\n if (\n key.startsWith(\"userInput_\") ||\n key.startsWith(\"contactInfo_\") ||\n key.includes(\"Options_\")\n ) {\n localStorage.removeItem(key);\n }\n }\n\n for (let i = sessionStorage.length - 1; i >= 0; i -= 1) {\n const key = sessionStorage.key(i);\n if (!key) {\n continue;\n }\n if (\n key.startsWith(\"userInput_\") ||\n key.startsWith(\"contactInfo_\") ||\n key.includes(\"Options_\")\n ) {\n sessionStorage.removeItem(key);\n }\n }\n};\n"],"names":[],"mappings":";;;;;AAAA;;;;;AAKG;AAYH;;;;;AAKG;AACI,IAAM,gBAAgB,GAAG,UAC9B,SAAiB,EAAA,EAAA,OAAA,SAAA,CAAA,MAAA,EAAA,MAAA,EAAA,MAAA,EAAA,YAAA;;;;;;gBAGE,OAAA,CAAA,CAAA,YAAM,UAAU,CAAC,GAAG,CAAC,uBAAgB,SAAS,CAAE,CAAC,CAAA;;AAA5D,gBAAA,QAAQ,GAAG,EAAA,CAAA,IAAA,EAAiD;gBAClE,OAAA,CAAA,CAAA,aAAO,QAAQ,CAAC,IAAI,CAAA;;;AAEpB,gBAAA,OAAO,CAAC,KAAK,CAAC,8BAA8B,EAAE,OAAK,CAAC;AACpD,gBAAA,MAAM,OAAK;;;;;AAIf;;;;AAIG;AACI,IAAM,cAAc,GAAG,UAC5B,SAAiB,EACjB,UAAsB,EAAA,EAAA,OAAA,SAAA,CAAA,MAAA,EAAA,MAAA,EAAA,MAAA,EAAA,YAAA;;;;;;gBAGpB,OAAA,CAAA,CAAA,YAAM,UAAU,CAAC,IAAI,CA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AAc,CAAC,UAAU,CAAC,GAAG,CAAC;QAChC;IACF;AACF;;;;"}
package/docs/README.md CHANGED
@@ -8,6 +8,12 @@
8
8
  - Onboarding SDK journey runtime (steps, template nodes, navigation)
9
9
  - How to add a new node safely
10
10
 
11
+ - **[navigation-history.md](./navigation-history.md)**
12
+ - How the step history stack works
13
+ - `goBack()` vs `setStep()` — when to use which
14
+ - Session resume and history reconstruction
15
+ - Common pitfalls
16
+
11
17
  - **[POLLING_SYSTEM.md](./POLLING_SYSTEM.md)** ⭐ **START HERE**
12
18
  - Complete guide to the enhanced polling system
13
19
  - Status mapping and message reference