datakeen-session-react 1.1.140-rc.73 → 1.1.140-rc.74

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.
@@ -75,7 +75,7 @@ var ConditionNodeHandler = function (_a) {
75
75
  stepObject.goToNextStep(node.id, freshSession.template, "true");
76
76
  return [2 /*return*/];
77
77
  }
78
- if (node.conditionFalseMode === "loop") {
78
+ if (node.conditionFalseMode !== "retry") {
79
79
  stepObject.goToNextStep(node.id, freshSession.template, "false");
80
80
  return [2 /*return*/];
81
81
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ConditionNodeHandler.js","sources":["../../../../../src/components/template/ConditionNodeHandler.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useRef, useState } from \"react\";\nimport LoadingState from \"../states/LoadingState\";\nimport type { SessionData, SessionTemplateNode } from \"../../types/session\";\nimport type { stepObject } from \"../../types/session\";\nimport type { UserInput } from \"../../types/userInput\";\nimport type { ContactInfo } from \"../../types/contactInfo\";\nimport { useI18n } from \"../../hooks/useI18n\";\nimport {\n evaluateConditionTokens,\n parseConditionExpression,\n} from \"../../utils/conditionEvaluator\";\nimport {\n fetchSessionById,\n findOutgoingEdge,\n} from \"../../services/sessionService\";\nimport {\n getNodeRetryCount,\n updateNodeRetryCount,\n} from \"../../services/retryService\";\nimport {\n hasExceededConditionMaxRetries,\n normalizeConditionMaxRetries,\n normalizeConditionMaxRetryAction,\n} from \"./conditionNodePolicy\";\n\ninterface ConditionNodeHandlerProps {\n node: SessionTemplateNode;\n session: SessionData;\n templateNodes: SessionTemplateNode[];\n stepObject: stepObject;\n userInput: UserInput;\n contactInfo: ContactInfo;\n}\n\ninterface FalseConditionState {\n message: string;\n retryCount: number;\n maxRetries: number;\n template: SessionData[\"template\"];\n}\n\nconst ConditionNodeHandler: React.FC<ConditionNodeHandlerProps> = ({\n node,\n session,\n templateNodes,\n stepObject,\n userInput,\n contactInfo,\n}) => {\n const { t } = useI18n();\n const [errorMessage, setErrorMessage] = useState<string | null>(null);\n const [isLoadingSession, setIsLoadingSession] = useState(false);\n const [falseConditionState, setFalseConditionState] =\n useState<FalseConditionState | null>(null);\n const hasEvaluatedRef = useRef(false);\n\n const tokens = useMemo(() => {\n return (\n (node.conditionTokens && node.conditionTokens.length > 0\n ? node.conditionTokens\n : parseConditionExpression(node.conditionExpression || \"\")) || []\n );\n }, [node.conditionExpression, node.conditionTokens]);\n\n useEffect(() => {\n hasEvaluatedRef.current = false;\n setErrorMessage(null);\n setFalseConditionState(null);\n }, [node.id]);\n\n useEffect(() => {\n if (hasEvaluatedRef.current) {\n return;\n }\n hasEvaluatedRef.current = true;\n\n const evaluateCondition = async () => {\n if (!session?.template) {\n setErrorMessage(\n t(\n \"condition_node.error_missing_template\",\n \"Aucun template disponible pour évaluer la condition.\",\n ),\n );\n return;\n }\n\n if (tokens.length === 0) {\n setErrorMessage(\n t(\n \"condition_node.error_missing_tokens\",\n \"Aucune expression de condition n'est définie pour ce nœud.\",\n ),\n );\n return;\n }\n\n setIsLoadingSession(true);\n let freshSession: SessionData;\n try {\n freshSession = await fetchSessionById(session.id);\n } catch (error) {\n console.error(\"[ConditionNodeHandler] Error fetching fresh session:\", error);\n freshSession = session;\n } finally {\n setIsLoadingSession(false);\n }\n\n try {\n const evaluationResult = evaluateConditionTokens(tokens, {\n session: freshSession,\n userInput,\n contactInfo,\n });\n\n if (evaluationResult) {\n stepObject.goToNextStep(node.id, freshSession.template, \"true\");\n return;\n }\n\n if (node.conditionFalseMode === \"loop\") {\n stepObject.goToNextStep(node.id, freshSession.template, \"false\");\n return;\n }\n\n const maxRetries = normalizeConditionMaxRetries(node.conditionMaxRetries);\n const maxRetryAction = normalizeConditionMaxRetryAction(\n node.conditionMaxRetryAction,\n );\n const currentRetryCount = getNodeRetryCount(freshSession, node.id);\n const retryCountAfterFailure = currentRetryCount + 1;\n\n try {\n await updateNodeRetryCount(\n session.id,\n node.id,\n retryCountAfterFailure,\n );\n } catch (retryError) {\n console.error(\n \"[ConditionNodeHandler] Failed to persist retry count:\",\n retryError,\n );\n }\n\n if (\n hasExceededConditionMaxRetries(retryCountAfterFailure, maxRetries)\n ) {\n if (maxRetryAction === \"force-true\") {\n stepObject.goToNextStep(node.id, freshSession.template, \"true\");\n return;\n }\n stepObject.goToNextStep(node.id, freshSession.template, \"false\");\n return;\n }\n\n const falseEdge = findOutgoingEdge(node.id, freshSession.template, \"false\");\n if (!falseEdge) {\n throw new Error(\"No outgoing false edge defined for condition node\");\n }\n\n setFalseConditionState({\n message:\n node.conditionFalseErrorMessage?.trim() ||\n t(\n \"condition_node.false_error_default\",\n \"Les informations ne respectent pas les conditions demandées.\",\n ),\n retryCount: retryCountAfterFailure,\n maxRetries,\n template: freshSession.template,\n });\n } catch (error) {\n console.error(\"Failed to evaluate condition node\", error);\n setErrorMessage(\n t(\n \"condition_node.error_evaluation\",\n \"Impossible d'évaluer cette condition. Vous pouvez poursuivre manuellement.\",\n ),\n );\n }\n };\n\n evaluateCondition();\n }, [contactInfo, node, session, stepObject, t, tokens, userInput, templateNodes]);\n\n const handleRetry = () => {\n if (!falseConditionState) {\n return;\n }\n stepObject.goToNextStep(node.id, falseConditionState.template, \"false\");\n };\n\n if (isLoadingSession) {\n return (\n <LoadingState\n message={t(\n \"condition_node.loading_analysis\",\n \"Chargement des données d'analyse...\",\n )}\n subtitle={t(\n \"condition_node.loading_description\",\n \"Récupération des informations nécessaires pour évaluer la condition.\",\n )}\n />\n );\n }\n\n if (falseConditionState) {\n return (\n <div className=\"flex flex-col justify-between h-full w-full\">\n <div className=\"flex-1 px-4 py-6 pt-11 md:px-8 md:py-8\">\n <div className=\"w-full max-w-md mx-auto space-y-6\">\n <div className=\"text-center\">\n <div className=\"mx-auto w-16 h-16 bg-red-100 rounded-full flex items-center justify-center mb-4\">\n <div className=\"w-8 h-8 bg-red-500 rounded-full flex items-center justify-center\">\n <span className=\"text-white text-lg\">✕</span>\n </div>\n </div>\n </div>\n\n <div className=\"text-center space-y-4\">\n <h2 className=\"text-xl font-bold text-red-600\">\n {t(\"condition_node.false_error_title\", \"Condition non remplie\")}\n </h2>\n <p className=\"text-sm text-gray-600 leading-relaxed\">\n {falseConditionState.message}\n </p>\n </div>\n\n <div className=\"bg-orange-50 border border-orange-200 rounded-lg p-4\">\n <p className=\"text-sm text-orange-800\">\n {t(\n \"condition_node.retry_counter\",\n \"Tentative {{current}}/{{max}}\",\n {\n current: falseConditionState.retryCount,\n max: falseConditionState.maxRetries,\n },\n )}\n </p>\n </div>\n </div>\n </div>\n\n <div className=\"sticky bottom-0 md:static bg-white border-t md:border-t-0 p-4 md:p-0 md:pb-8\">\n <div className=\"w-full max-w-md mx-auto\">\n <button\n className=\"w-full px-4 py-2 bg-primary text-white rounded hover:bg-primary-dark transition-colors\"\n onClick={handleRetry}\n >\n {t(\"condition_node.buttons.retry\", \"Réessayer\")}\n </button>\n </div>\n </div>\n </div>\n );\n }\n\n if (errorMessage) {\n return (\n <div className=\"flex flex-col items-center justify-center h-full p-4 text-center\">\n <div className=\"text-red-500 text-4xl mb-4\">⚠️</div>\n <h2 className=\"text-xl font-bold text-red-600 mb-2\">\n {t(\"condition_node.title\", \"Condition\")}\n </h2>\n <p className=\"text-gray-600 mb-4\">{errorMessage}</p>\n <button\n className=\"px-4 py-2 bg-primary text-white rounded hover:bg-primary-dark transition-colors\"\n onClick={() => stepObject.setStep(stepObject.step + 1)}\n >\n {t(\"condition_node.buttons.skip\", \"Continuer\")}\n </button>\n </div>\n );\n }\n\n return (\n <LoadingState\n message={t(\n \"condition_node.evaluating\",\n \"Évaluation de la condition en cours...\",\n )}\n subtitle={t(\n \"condition_node.evaluating_description\",\n \"Merci de patienter pendant que nous déterminons la prochaine étape.\",\n )}\n />\n );\n};\n\nexport default ConditionNodeHandler;\n"],"names":["useI18n","useState","useRef","useMemo","parseConditionExpression","useEffect","__awaiter","fetchSessionById","evaluateConditionTokens","normalizeConditionMaxRetries","normalizeConditionMaxRetryAction","getNodeRetryCount","updateNod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,wFAAwF,EAClG,OAAO,EAAE,WAAW,EAAA,QAAA,EAEnB,CAAC,CAAC,8BAA8B,EAAE,WAAW,CAAC,EAAA,CACxC,EAAA,CACL,EAAA,CACF,CAAA,EAAA,CACF;IAEV;IAEA,IAAI,YAAY,EAAE;AAChB,QAAA,QACEE,eAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,kEAAkE,EAAA,QAAA,EAAA,CAC/EF,cAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,4BAA4B,EAAA,QAAA,EAAA,cAAA,EAAA,CAAS,EACpDA,uBAAI,SAAS,EAAC,qCAAqC,EAAA,QAAA,EAChD,CAAC,CAAC,sBAAsB,EAAE,WAAW,CAAC,EAAA,CACpC,EACLA,cAAA,CAAA,GAAA,EAAA,EAAG,SAAS,EAAC,oBAAoB,YAAE,YAAY,EAAA,CAAK,EACpDA,cAAA,CAAA,QAAA,EAAA,EACE,SAAS,EAAC,iFAAiF,EAC3F,OAAO,EAAE,YAAA,EAAM,OAAA,UAAU,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,GAAG,CAAC,CAAC,CAAA,CAAvC,CAAuC,EAAA,QAAA,EAErD,CAAC,CAAC,6BAA6B,EAAE,WAAW,CAAC,EAAA,CACvC,CAAA,EAAA,CACL;IAEV;IAEA,QACEA,eAACC,oBAAY,EAAA,EACX,OAAO,EAAE,CAAC,CACR,2BAA2B,EAC3B,wCAAwC,CACzC,EACD,QAAQ,EAAE,CAAC,CACT,uCAAuC,EACvC,qEAAqE,CACtE,EAAA,CACD;AAEN;;;;"}
1
+ {"version":3,"file":"ConditionNodeHandler.js","sources":["../../../../../src/components/template/ConditionNodeHandler.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useRef, useState } from \"react\";\nimport LoadingState from \"../states/LoadingState\";\nimport type { SessionData, SessionTemplateNode } from \"../../types/session\";\nimport type { stepObject } from \"../../types/session\";\nimport type { UserInput } from \"../../types/userInput\";\nimport type { ContactInfo } from \"../../types/contactInfo\";\nimport { useI18n } from \"../../hooks/useI18n\";\nimport {\n evaluateConditionTokens,\n parseConditionExpression,\n} from \"../../utils/conditionEvaluator\";\nimport {\n fetchSessionById,\n findOutgoingEdge,\n} from \"../../services/sessionService\";\nimport {\n getNodeRetryCount,\n updateNodeRetryCount,\n} from \"../../services/retryService\";\nimport {\n hasExceededConditionMaxRetries,\n normalizeConditionMaxRetries,\n normalizeConditionMaxRetryAction,\n} from \"./conditionNodePolicy\";\n\ninterface ConditionNodeHandlerProps {\n node: SessionTemplateNode;\n session: SessionData;\n templateNodes: SessionTemplateNode[];\n stepObject: stepObject;\n userInput: UserInput;\n contactInfo: ContactInfo;\n}\n\ninterface FalseConditionState {\n message: string;\n retryCount: number;\n maxRetries: number;\n template: SessionData[\"template\"];\n}\n\nconst ConditionNodeHandler: React.FC<ConditionNodeHandlerProps> = ({\n node,\n session,\n templateNodes,\n stepObject,\n userInput,\n contactInfo,\n}) => {\n const { t } = useI18n();\n const [errorMessage, setErrorMessage] = useState<string | null>(null);\n const [isLoadingSession, setIsLoadingSession] = useState(false);\n const [falseConditionState, setFalseConditionState] =\n useState<FalseConditionState | null>(null);\n const hasEvaluatedRef = useRef(false);\n\n const tokens = useMemo(() => {\n return (\n (node.conditionTokens && node.conditionTokens.length > 0\n ? node.conditionTokens\n : parseConditionExpression(node.conditionExpression || \"\")) || []\n );\n }, [node.conditionExpression, node.conditionTokens]);\n\n useEffect(() => {\n hasEvaluatedRef.current = false;\n setErrorMessage(null);\n setFalseConditionState(null);\n }, [node.id]);\n\n useEffect(() => {\n if (hasEvaluatedRef.current) {\n return;\n }\n hasEvaluatedRef.current = true;\n\n const evaluateCondition = async () => {\n if (!session?.template) {\n setErrorMessage(\n t(\n \"condition_node.error_missing_template\",\n \"Aucun template disponible pour évaluer la condition.\",\n ),\n );\n return;\n }\n\n if (tokens.length === 0) {\n setErrorMessage(\n t(\n \"condition_node.error_missing_tokens\",\n \"Aucune expression de condition n'est définie pour ce nœud.\",\n ),\n );\n return;\n }\n\n setIsLoadingSession(true);\n let freshSession: SessionData;\n try {\n freshSession = await fetchSessionById(session.id);\n } catch (error) {\n console.error(\"[ConditionNodeHandler] Error fetching fresh session:\", error);\n freshSession = session;\n } finally {\n setIsLoadingSession(false);\n }\n\n try {\n const evaluationResult = evaluateConditionTokens(tokens, {\n session: freshSession,\n userInput,\n contactInfo,\n });\n\n if (evaluationResult) {\n stepObject.goToNextStep(node.id, freshSession.template, \"true\");\n return;\n }\n\n if (node.conditionFalseMode !== \"retry\") {\n stepObject.goToNextStep(node.id, freshSession.template, \"false\");\n return;\n }\n\n const maxRetries = normalizeConditionMaxRetries(node.conditionMaxRetries);\n const maxRetryAction = normalizeConditionMaxRetryAction(\n node.conditionMaxRetryAction,\n );\n const currentRetryCount = getNodeRetryCount(freshSession, node.id);\n const retryCountAfterFailure = currentRetryCount + 1;\n\n try {\n await updateNodeRetryCount(\n session.id,\n node.id,\n retryCountAfterFailure,\n );\n } catch (retryError) {\n console.error(\n \"[ConditionNodeHandler] Failed to persist retry count:\",\n retryError,\n );\n }\n\n if (\n hasExceededConditionMaxRetries(retryCountAfterFailure, maxRetries)\n ) {\n if (maxRetryAction === \"force-true\") {\n stepObject.goToNextStep(node.id, freshSession.template, \"true\");\n return;\n }\n stepObject.goToNextStep(node.id, freshSession.template, \"false\");\n return;\n }\n\n const falseEdge = findOutgoingEdge(node.id, freshSession.template, \"false\");\n if (!falseEdge) {\n throw new Error(\"No outgoing false edge defined for condition node\");\n }\n\n setFalseConditionState({\n message:\n node.conditionFalseErrorMessage?.trim() ||\n t(\n \"condition_node.false_error_default\",\n \"Les informations ne respectent pas les conditions demandées.\",\n ),\n retryCount: retryCountAfterFailure,\n maxRetries,\n template: freshSession.template,\n });\n } catch (error) {\n console.error(\"Failed to evaluate condition node\", error);\n setErrorMessage(\n t(\n \"condition_node.error_evaluation\",\n \"Impossible d'évaluer cette condition. Vous pouvez poursuivre manuellement.\",\n ),\n );\n }\n };\n\n evaluateCondition();\n }, [contactInfo, node, session, stepObject, t, tokens, userInput, templateNodes]);\n\n const handleRetry = () => {\n if (!falseConditionState) {\n return;\n }\n stepObject.goToNextStep(node.id, falseConditionState.template, \"false\");\n };\n\n if (isLoadingSession) {\n return (\n <LoadingState\n message={t(\n \"condition_node.loading_analysis\",\n \"Chargement des données d'analyse...\",\n )}\n subtitle={t(\n \"condition_node.loading_description\",\n \"Récupération des informations nécessaires pour évaluer la condition.\",\n )}\n />\n );\n }\n\n if (falseConditionState) {\n return (\n <div className=\"flex flex-col justify-between h-full w-full\">\n <div className=\"flex-1 px-4 py-6 pt-11 md:px-8 md:py-8\">\n <div className=\"w-full max-w-md mx-auto space-y-6\">\n <div className=\"text-center\">\n <div className=\"mx-auto w-16 h-16 bg-red-100 rounded-full flex items-center justify-center mb-4\">\n <div className=\"w-8 h-8 bg-red-500 rounded-full flex items-center justify-center\">\n <span className=\"text-white text-lg\">✕</span>\n </div>\n </div>\n </div>\n\n <div className=\"text-center space-y-4\">\n <h2 className=\"text-xl font-bold text-red-600\">\n {t(\"condition_node.false_error_title\", \"Condition non remplie\")}\n </h2>\n <p className=\"text-sm text-gray-600 leading-relaxed\">\n {falseConditionState.message}\n </p>\n </div>\n\n <div className=\"bg-orange-50 border border-orange-200 rounded-lg p-4\">\n <p className=\"text-sm text-orange-800\">\n {t(\n \"condition_node.retry_counter\",\n \"Tentative {{current}}/{{max}}\",\n {\n current: falseConditionState.retryCount,\n max: falseConditionState.maxRetries,\n },\n )}\n </p>\n </div>\n </div>\n </div>\n\n <div className=\"sticky bottom-0 md:static bg-white border-t md:border-t-0 p-4 md:p-0 md:pb-8\">\n <div className=\"w-full max-w-md mx-auto\">\n <button\n className=\"w-full px-4 py-2 bg-primary text-white rounded hover:bg-primary-dark transition-colors\"\n onClick={handleRetry}\n >\n {t(\"condition_node.buttons.retry\", \"Réessayer\")}\n </button>\n </div>\n </div>\n </div>\n );\n }\n\n if (errorMessage) {\n return (\n <div className=\"flex flex-col items-center justify-center h-full p-4 text-center\">\n <div className=\"text-red-500 text-4xl mb-4\">⚠️</div>\n <h2 className=\"text-xl font-bold text-red-600 mb-2\">\n {t(\"condition_node.title\", \"Condition\")}\n </h2>\n <p className=\"text-gray-600 mb-4\">{errorMessage}</p>\n <button\n className=\"px-4 py-2 bg-primary text-white rounded hover:bg-primary-dark transition-colors\"\n onClick={() => stepObject.setStep(stepObject.step + 1)}\n >\n {t(\"condition_node.buttons.skip\", \"Continuer\")}\n </button>\n </div>\n );\n }\n\n return (\n <LoadingState\n message={t(\n \"condition_node.evaluating\",\n \"Évaluation de la condition en cours...\",\n )}\n subtitle={t(\n \"condition_node.evaluating_description\",\n \"Merci de patienter pendant que nous déterminons la prochaine étape.\",\n )}\n />\n );\n};\n\nexport default ConditionNodeHandler;\n"],"names":["useI18n","useState","useRef","useMemo","parseConditionExpression","useEffect","__awaiter","fetchSessionById","evaluateConditionTokens","normalizeConditionMaxRetries","normalizeConditionMaxRetryAction","getNodeRetryCount","updateNodeRetryCount","hasExceededConditionMaxRetries","findOutgoingEdge","_jsx","LoadingState","_jsxs"],"mappings":";;;;;;;;;;;;;;AAyCA,IAAM,oBAAoB,GAAwC,UAAC,EAOlE,EAAA;AANC,IAAA,IAAA,IAAI,GAAA,EAAA,CAAA,IAAA,EACJ,OAAO,GAAA,EAAA,CAAA,OAAA,EACP,aAAa,GAAA,EAAA,CAAA,aAAA,EACb,UAAU,gBAAA,EACV,SAAS,GAAA,EAAA,CAAA,SAAA,EACT,WAAW,GAAA,EAAA,CAAA,WAAA;AAEH,IAAA,IAAA,CAAC,GAAKA,eAAO,EAAE,EAAd;IACH,IAAA,EAAA,GAAkCC,cAAQ,CAAgB,IAAI,CAAC,EAA9D,YAAY,GAAA,EAAA,CAAA,CAAA,CAAA,EAAE,eAAe,GAAA,EAAA,CAAA,CAAA,CAAiC;IAC/D,IAAA,EAAA,GAA0CA,cAAQ,CAAC,KAAK,CAAC,EAAxD,gBAAgB,GAAA,EAAA,CAAA,CAAA,CAAA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AM,OAAA,UAAU,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,GAAG,CAAC,CAAC,CAAA,CAAvC,CAAuC,EAAA,QAAA,EAErD,CAAC,CAAC,6BAA6B,EAAE,WAAW,CAAC,EAAA,CACvC,CAAA,EAAA,CACL;IAEV;IAEA,QACEA,eAACC,oBAAY,EAAA,EACX,OAAO,EAAE,CAAC,CACR,2BAA2B,EAC3B,wCAAwC,CACzC,EACD,QAAQ,EAAE,CAAC,CACT,uCAAuC,EACvC,qEAAqE,CACtE,EAAA,CACD;AAEN;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"session.js","sources":["../../../../src/types/session.ts"],"sourcesContent":["import type React from \"react\";\n\nexport interface SessionConfig {\n selfie?: boolean;\n requireMobile?: boolean;\n}\n\nexport interface DatakeenSessionProps {\n sessionId: string;\n sessionConfig?: SessionConfig;\n apiBaseUrl?: string; // Optional API base URL for dynamic environment configuration\n}\n\nexport interface UseSessionReturn {\n SessionComponent: React.ReactElement;\n}\n\nexport type stepObject = {\n setStep: (step: number, skipHistory?: boolean) => void;\n goBack: () => void;\n /** Retour arrière vers un nœud précis (ex: \"Corriger ma saisie\") :\n * tronque l'historique jusqu'à `targetStep` au lieu de l'empiler. */\n goBackToStep: (targetStep: number) => void;\n goToNextStep: (\n currentNodeId: string,\n template: SessionTemplate,\n handle?: string,\n ) => void;\n step: number;\n canGoBack: boolean;\n};\n\nexport interface ProcessingStep {\n title: string;\n subtitle: string;\n hasError?: boolean;\n}\n\nexport type ConditionTokenType = \"variable\" | \"control\" | \"operator\" | \"input\";\n\nexport interface ConditionToken {\n type: ConditionTokenType;\n value: string;\n label?: string;\n sourceNodeId?: string;\n}\n\n/**\n * Type for custom field value types\n */\nexport type CustomFieldValueType =\n | \"text\"\n | \"enum\"\n | \"number\"\n | \"boolean\"\n | \"date\"\n | \"email\"\n | \"address\"\n | \"list\";\n\n/**\n * Display formats supported for date fields (top-level and list columns).\n */\nexport type DateDisplayFormat = \"dd/mm/yyyy\" | \"mm/dd/yyyy\" | \"yyyy-mm-dd\";\n\nexport const DEFAULT_DATE_DISPLAY_FORMAT: DateDisplayFormat = \"dd/mm/yyyy\";\n\n/**\n * Column definition for a list-type custom field\n */\nexport interface ListColumn {\n label: string;\n type: \"text\" | \"enum\" | \"date\" | \"email\";\n options?: string[]; // required when type === 'enum'\n placeholder?: string; // text/email/date — shown to the end user\n regex?: string; // text — JS regex source (without slashes)\n regexErrorMessage?: string; // text — message displayed when regex fails\n dateFormat?: DateDisplayFormat; // date — display format expected\n}\n\n/**\n * Interface for custom field definition\n */\nexport interface CustomField {\n id: string;\n label: string;\n placeholder?: string;\n description?: string;\n valueType: CustomFieldValueType;\n enumOptions?: string[];\n listColumns?: ListColumn[]; // for list type: column definitions\n minRows?: number; // for list type: minimum rows expected\n required?: boolean;\n regex?: string; // text — JS regex source (without slashes)\n regexErrorMessage?: string; // text — message displayed when regex fails\n dateFormat?: DateDisplayFormat; // date — display format expected\n lockedFromApi?: boolean;\n userInputKey?: string;\n}\n\n/**\n * Interface for session template node\n */\nexport interface SessionTemplateNode {\n id: string;\n type: string;\n title: string;\n description: string;\n informationType?:\n | \"identity\"\n | \"identity-legal\"\n | \"contact\"\n | \"address\"\n | \"nationality\"\n | \"custom\";\n position: {\n x: number;\n y: number;\n };\n options: unknown[];\n selectedOptions: string[];\n requiredDocumentType?: string;\n isRequired: boolean;\n order: number;\n optionalFields?: string[];\n requiredFields?: string[];\n pageTitle?: string;\n pageDescription?: string;\n // Properties for document-collection node type\n allowedDocumentTypes?: Array<{\n id: string;\n name: string;\n /**\n * Optional side information coming from the template.\n * When provided and equals to two (\"two\", 2, \"double\", \"recto-verso\"),\n * consumers should allow uploading two sides (front/back).\n */\n side?: string | number;\n }>;\n allowedAddingMethods?: string[];\n introductionPage?: {\n title?: string;\n description?: string;\n };\n documentSelection?: {\n title?: string;\n description?: string;\n };\n // Start node specific properties\n welcomeTitle?: string;\n welcomeSubtitle?: string;\n welcomeDescription?: string;\n welcomeImage?: string;\n qrCodeTitle?: string;\n qrCodeDescription?: string;\n showLegacyCGU?: boolean; // default: true — rétrocompatibilité\n\n // Legal consent node specific properties\n consentDescription?: string;\n consentDescription2?: string;\n cguUrl?: string;\n privacyPolicyUrl?: string;\n checkboxText?: string;\n // Identity control specific properties\n automaticPhotoCapture?: boolean;\n nfcEnabled?: boolean;\n // \"nfcAndApi\" reste accepté pour rétrocompat (parcours legacy) ; à normaliser à la lecture.\n nfcMode?: \"nfcOnly\" | \"nfcOrPhoto\" | \"nfcAndApi\";\n acceptedCountries?: AcceptedCountry[];\n // End node specific properties\n callbackURL?: string | null;\n // Résultat forcé par le nœud `end` (configuré dans le builder). Sert au SDK à\n // afficher la variante « erreur conservée » de l'écran de fin quand la branche\n // fausse d'une condition pointe directement vers un end non_compliant.\n expectedResult?: string;\n // Condition node specific properties\n conditionExpression?: string;\n conditionTokens?: ConditionToken[];\n conditionFalseErrorMessage?: string;\n conditionMaxRetries?: number;\n conditionMaxRetryAction?: \"end-journey\" | \"force-true\";\n conditionFalseMode?: \"retry\" | \"loop\";\n\n // External verification specific properties\n targetApi?: \"INSEE\";\n referenceNodeId?: string;\n referenceNodeType?:\n | \"information-input\"\n | \"document-collection\"\n | \"identity-control\";\n referenceField?: \"siren\" | \"siret\";\n referenceVariable?: string;\n // Custom form fields (for information-input with type 'custom')\n customFields?: CustomField[];\n\n // Electronic signature specific properties\n templateId?: string;\n external_id?: string;\n fieldMappings?: Array<{\n sourceFieldId: string;\n label: string;\n docusealType: string;\n readonly: boolean;\n role?: string;\n sourceNodeId?: string;\n }>;\n /** If set, the generated PDF from this upstream pdf-generation node will be used as the document to sign */\n sourcePdfNodeId?: string;\n\n // PDF generation node specific properties\n // Note: htmlTemplate is intentionally NOT included — it is server-side only and never sent to the client\n pdfMode?: \"upload\" | \"html-template\";\n sourceNodeIds?: string[];\n\n // retry properties\n allowResubmission: boolean;\n maxResubmissionAttempts?: number;\n}\n\n/**\n * Interface for accepted countries\n */\nexport interface AcceptedCountry {\n code: string;\n documents: {\n passport: string[];\n idCard: string[];\n driverLicense: string[];\n residencePermit: string[];\n pinkDriverLicense: string[];\n };\n}\n\n/**\n * Interface for session template edge\n */\nexport interface SessionTemplateEdge {\n id: string;\n source: string;\n target: string;\n sourceHandle?: string;\n targetHandle?: string;\n conditionValue?: string;\n}\n\n/**\n * Interface for platform information\n */\nexport interface PlatformInfo {\n mobile: boolean;\n desktop: boolean;\n backoffice: boolean;\n}\n\n/**\n * Interface for session template\n */\n/** Clé du catalogue d'icônes des écrans de fin (mappée vers lucide-react au rendu). */\nexport type EndScreenIcon =\n | \"thanks\"\n | \"send\"\n | \"mail\"\n | \"check\"\n | \"clock\"\n | \"shield\"\n | \"user\"\n | \"info\";\n\nexport interface EndScreenItem {\n icon: EndScreenIcon;\n text: string;\n}\n\nexport interface EndScreenCase {\n title?: string;\n items: EndScreenItem[];\n}\n\n/** Textes de fin personnalisés (config globale du journey). Vide → fallback standard. */\nexport interface EndScreenConfig {\n compliant?: EndScreenCase;\n nonCompliant?: EndScreenCase;\n}\n\nexport interface SessionTemplate {\n id: string;\n name: string;\n description: string;\n version: string;\n languages: string[];\n nodes: SessionTemplateNode[];\n edges: SessionTemplateEdge[];\n groupId: string;\n userId: string | null;\n created_at: string;\n updated_at: string;\n platforms?: PlatformInfo;\n logo?: string;\n showQRCode?: boolean;\n buttonBgColor?: string;\n buttonTextColor?: string;\n endScreenConfig?: EndScreenConfig;\n}\n\n/**\n * Interface for session data\n */\nexport interface SessionData {\n id: string;\n userId: string | null;\n token: string;\n templateId: string;\n templateKey: string;\n expireTime: number;\n status: string;\n result: Record<string, unknown>;\n landingPage: unknown;\n withSelfie: boolean | null;\n groupId: string | null;\n userInput: Record<string, unknown>;\n contactInfo?: {\n email: string;\n phoneNumber: string;\n };\n callbackURL?: string | null;\n webhookURL: string;\n analysisTemplateId: string | null;\n userAgent: unknown[];\n mobile: boolean;\n analysisId: string | null;\n currentStep?: number;\n nfcStatus?: \"pending\" | \"opened\" | \"completed\" | \"skipped\" | \"failed\";\n createdAt: string;\n updatedAt: string;\n auditTrail: unknown[];\n user: unknown | null;\n analysis: unknown[];\n documents: unknown[];\n template: SessionTemplate;\n retryCounts?: Record<string, number>; // nodeId -> retry count\n}\n\nexport interface ClientInfo {\n ip?: string;\n location?: string;\n device: string;\n browser: string;\n os: string;\n}\n"],"names":[],"mappings":";;AAiEO,IAAM,2BAA2B,GAAsB;;;;"}
1
+ {"version":3,"file":"session.js","sources":["../../../../src/types/session.ts"],"sourcesContent":["import type React from \"react\";\n\nexport interface SessionConfig {\n selfie?: boolean;\n requireMobile?: boolean;\n}\n\nexport interface DatakeenSessionProps {\n sessionId: string;\n sessionConfig?: SessionConfig;\n apiBaseUrl?: string; // Optional API base URL for dynamic environment configuration\n}\n\nexport interface UseSessionReturn {\n SessionComponent: React.ReactElement;\n}\n\nexport type stepObject = {\n setStep: (step: number, skipHistory?: boolean) => void;\n goBack: () => void;\n /** Retour arrière vers un nœud précis (ex: \"Corriger ma saisie\") :\n * tronque l'historique jusqu'à `targetStep` au lieu de l'empiler. */\n goBackToStep: (targetStep: number) => void;\n goToNextStep: (\n currentNodeId: string,\n template: SessionTemplate,\n handle?: string,\n ) => void;\n step: number;\n canGoBack: boolean;\n};\n\nexport interface ProcessingStep {\n title: string;\n subtitle: string;\n hasError?: boolean;\n}\n\nexport type ConditionTokenType = \"variable\" | \"control\" | \"operator\" | \"input\";\n\nexport interface ConditionToken {\n type: ConditionTokenType;\n value: string;\n label?: string;\n sourceNodeId?: string;\n}\n\n/**\n * Type for custom field value types\n */\nexport type CustomFieldValueType =\n | \"text\"\n | \"enum\"\n | \"number\"\n | \"boolean\"\n | \"date\"\n | \"email\"\n | \"address\"\n | \"list\";\n\n/**\n * Display formats supported for date fields (top-level and list columns).\n */\nexport type DateDisplayFormat = \"dd/mm/yyyy\" | \"mm/dd/yyyy\" | \"yyyy-mm-dd\";\n\nexport const DEFAULT_DATE_DISPLAY_FORMAT: DateDisplayFormat = \"dd/mm/yyyy\";\n\n/**\n * Column definition for a list-type custom field\n */\nexport interface ListColumn {\n label: string;\n type: \"text\" | \"enum\" | \"date\" | \"email\";\n options?: string[]; // required when type === 'enum'\n placeholder?: string; // text/email/date — shown to the end user\n regex?: string; // text — JS regex source (without slashes)\n regexErrorMessage?: string; // text — message displayed when regex fails\n dateFormat?: DateDisplayFormat; // date — display format expected\n}\n\n/**\n * Interface for custom field definition\n */\nexport interface CustomField {\n id: string;\n label: string;\n placeholder?: string;\n description?: string;\n valueType: CustomFieldValueType;\n enumOptions?: string[];\n listColumns?: ListColumn[]; // for list type: column definitions\n minRows?: number; // for list type: minimum rows expected\n required?: boolean;\n regex?: string; // text — JS regex source (without slashes)\n regexErrorMessage?: string; // text — message displayed when regex fails\n dateFormat?: DateDisplayFormat; // date — display format expected\n lockedFromApi?: boolean;\n userInputKey?: string;\n}\n\n/**\n * Interface for session template node\n */\nexport interface SessionTemplateNode {\n id: string;\n type: string;\n title: string;\n description: string;\n informationType?:\n | \"identity\"\n | \"identity-legal\"\n | \"contact\"\n | \"address\"\n | \"nationality\"\n | \"custom\";\n position: {\n x: number;\n y: number;\n };\n options: unknown[];\n selectedOptions: string[];\n requiredDocumentType?: string;\n isRequired: boolean;\n order: number;\n optionalFields?: string[];\n requiredFields?: string[];\n pageTitle?: string;\n pageDescription?: string;\n // Properties for document-collection node type\n allowedDocumentTypes?: Array<{\n id: string;\n name: string;\n /**\n * Optional side information coming from the template.\n * When provided and equals to two (\"two\", 2, \"double\", \"recto-verso\"),\n * consumers should allow uploading two sides (front/back).\n */\n side?: string | number;\n }>;\n allowedAddingMethods?: string[];\n introductionPage?: {\n title?: string;\n description?: string;\n };\n documentSelection?: {\n title?: string;\n description?: string;\n };\n // Start node specific properties\n welcomeTitle?: string;\n welcomeSubtitle?: string;\n welcomeDescription?: string;\n welcomeImage?: string;\n qrCodeTitle?: string;\n qrCodeDescription?: string;\n showLegacyCGU?: boolean; // default: true — rétrocompatibilité\n\n // Legal consent node specific properties\n consentDescription?: string;\n consentDescription2?: string;\n cguUrl?: string;\n privacyPolicyUrl?: string;\n checkboxText?: string;\n // Identity control specific properties\n automaticPhotoCapture?: boolean;\n nfcEnabled?: boolean;\n // \"nfcAndApi\" reste accepté pour rétrocompat (parcours legacy) ; à normaliser à la lecture.\n nfcMode?: \"nfcOnly\" | \"nfcOrPhoto\" | \"nfcAndApi\";\n acceptedCountries?: AcceptedCountry[];\n // End node specific properties\n callbackURL?: string | null;\n // Résultat forcé par le nœud `end` (configuré dans le builder). Sert au SDK à\n // afficher la variante « erreur conservée » de l'écran de fin quand la branche\n // fausse d'une condition pointe directement vers un end non_compliant.\n expectedResult?: string;\n // Condition node specific properties\n conditionExpression?: string;\n conditionTokens?: ConditionToken[];\n conditionFalseErrorMessage?: string;\n conditionMaxRetries?: number;\n conditionMaxRetryAction?: \"end-journey\" | \"force-true\";\n // Undefined is treated as \"loop\" by the SDK for legacy templates.\n conditionFalseMode?: \"retry\" | \"loop\";\n\n // External verification specific properties\n targetApi?: \"INSEE\";\n referenceNodeId?: string;\n referenceNodeType?:\n | \"information-input\"\n | \"document-collection\"\n | \"identity-control\";\n referenceField?: \"siren\" | \"siret\";\n referenceVariable?: string;\n // Custom form fields (for information-input with type 'custom')\n customFields?: CustomField[];\n\n // Electronic signature specific properties\n templateId?: string;\n external_id?: string;\n fieldMappings?: Array<{\n sourceFieldId: string;\n label: string;\n docusealType: string;\n readonly: boolean;\n role?: string;\n sourceNodeId?: string;\n }>;\n /** If set, the generated PDF from this upstream pdf-generation node will be used as the document to sign */\n sourcePdfNodeId?: string;\n\n // PDF generation node specific properties\n // Note: htmlTemplate is intentionally NOT included — it is server-side only and never sent to the client\n pdfMode?: \"upload\" | \"html-template\";\n sourceNodeIds?: string[];\n\n // retry properties\n allowResubmission: boolean;\n maxResubmissionAttempts?: number;\n}\n\n/**\n * Interface for accepted countries\n */\nexport interface AcceptedCountry {\n code: string;\n documents: {\n passport: string[];\n idCard: string[];\n driverLicense: string[];\n residencePermit: string[];\n pinkDriverLicense: string[];\n };\n}\n\n/**\n * Interface for session template edge\n */\nexport interface SessionTemplateEdge {\n id: string;\n source: string;\n target: string;\n sourceHandle?: string;\n targetHandle?: string;\n conditionValue?: string;\n}\n\n/**\n * Interface for platform information\n */\nexport interface PlatformInfo {\n mobile: boolean;\n desktop: boolean;\n backoffice: boolean;\n}\n\n/**\n * Interface for session template\n */\n/** Clé du catalogue d'icônes des écrans de fin (mappée vers lucide-react au rendu). */\nexport type EndScreenIcon =\n | \"thanks\"\n | \"send\"\n | \"mail\"\n | \"check\"\n | \"clock\"\n | \"shield\"\n | \"user\"\n | \"info\";\n\nexport interface EndScreenItem {\n icon: EndScreenIcon;\n text: string;\n}\n\nexport interface EndScreenCase {\n title?: string;\n items: EndScreenItem[];\n}\n\n/** Textes de fin personnalisés (config globale du journey). Vide → fallback standard. */\nexport interface EndScreenConfig {\n compliant?: EndScreenCase;\n nonCompliant?: EndScreenCase;\n}\n\nexport interface SessionTemplate {\n id: string;\n name: string;\n description: string;\n version: string;\n languages: string[];\n nodes: SessionTemplateNode[];\n edges: SessionTemplateEdge[];\n groupId: string;\n userId: string | null;\n created_at: string;\n updated_at: string;\n platforms?: PlatformInfo;\n logo?: string;\n showQRCode?: boolean;\n buttonBgColor?: string;\n buttonTextColor?: string;\n endScreenConfig?: EndScreenConfig;\n}\n\n/**\n * Interface for session data\n */\nexport interface SessionData {\n id: string;\n userId: string | null;\n token: string;\n templateId: string;\n templateKey: string;\n expireTime: number;\n status: string;\n result: Record<string, unknown>;\n landingPage: unknown;\n withSelfie: boolean | null;\n groupId: string | null;\n userInput: Record<string, unknown>;\n contactInfo?: {\n email: string;\n phoneNumber: string;\n };\n callbackURL?: string | null;\n webhookURL: string;\n analysisTemplateId: string | null;\n userAgent: unknown[];\n mobile: boolean;\n analysisId: string | null;\n currentStep?: number;\n nfcStatus?: \"pending\" | \"opened\" | \"completed\" | \"skipped\" | \"failed\";\n createdAt: string;\n updatedAt: string;\n auditTrail: unknown[];\n user: unknown | null;\n analysis: unknown[];\n documents: unknown[];\n template: SessionTemplate;\n retryCounts?: Record<string, number>; // nodeId -> retry count\n}\n\nexport interface ClientInfo {\n ip?: string;\n location?: string;\n device: string;\n browser: string;\n os: string;\n}\n"],"names":[],"mappings":";;AAiEO,IAAM,2BAA2B,GAAsB;;;;"}
@@ -71,7 +71,7 @@ var ConditionNodeHandler = function (_a) {
71
71
  stepObject.goToNextStep(node.id, freshSession.template, "true");
72
72
  return [2 /*return*/];
73
73
  }
74
- if (node.conditionFalseMode === "loop") {
74
+ if (node.conditionFalseMode !== "retry") {
75
75
  stepObject.goToNextStep(node.id, freshSession.template, "false");
76
76
  return [2 /*return*/];
77
77
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ConditionNodeHandler.js","sources":["../../../../../src/components/template/ConditionNodeHandler.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useRef, useState } from \"react\";\nimport LoadingState from \"../states/LoadingState\";\nimport type { SessionData, SessionTemplateNode } from \"../../types/session\";\nimport type { stepObject } from \"../../types/session\";\nimport type { UserInput } from \"../../types/userInput\";\nimport type { ContactInfo } from \"../../types/contactInfo\";\nimport { useI18n } from \"../../hooks/useI18n\";\nimport {\n evaluateConditionTokens,\n parseConditionExpression,\n} from \"../../utils/conditionEvaluator\";\nimport {\n fetchSessionById,\n findOutgoingEdge,\n} from \"../../services/sessionService\";\nimport {\n getNodeRetryCount,\n updateNodeRetryCount,\n} from \"../../services/retryService\";\nimport {\n hasExceededConditionMaxRetries,\n normalizeConditionMaxRetries,\n normalizeConditionMaxRetryAction,\n} from \"./conditionNodePolicy\";\n\ninterface ConditionNodeHandlerProps {\n node: SessionTemplateNode;\n session: SessionData;\n templateNodes: SessionTemplateNode[];\n stepObject: stepObject;\n userInput: UserInput;\n contactInfo: ContactInfo;\n}\n\ninterface FalseConditionState {\n message: string;\n retryCount: number;\n maxRetries: number;\n template: SessionData[\"template\"];\n}\n\nconst ConditionNodeHandler: React.FC<ConditionNodeHandlerProps> = ({\n node,\n session,\n templateNodes,\n stepObject,\n userInput,\n contactInfo,\n}) => {\n const { t } = useI18n();\n const [errorMessage, setErrorMessage] = useState<string | null>(null);\n const [isLoadingSession, setIsLoadingSession] = useState(false);\n const [falseConditionState, setFalseConditionState] =\n useState<FalseConditionState | null>(null);\n const hasEvaluatedRef = useRef(false);\n\n const tokens = useMemo(() => {\n return (\n (node.conditionTokens && node.conditionTokens.length > 0\n ? node.conditionTokens\n : parseConditionExpression(node.conditionExpression || \"\")) || []\n );\n }, [node.conditionExpression, node.conditionTokens]);\n\n useEffect(() => {\n hasEvaluatedRef.current = false;\n setErrorMessage(null);\n setFalseConditionState(null);\n }, [node.id]);\n\n useEffect(() => {\n if (hasEvaluatedRef.current) {\n return;\n }\n hasEvaluatedRef.current = true;\n\n const evaluateCondition = async () => {\n if (!session?.template) {\n setErrorMessage(\n t(\n \"condition_node.error_missing_template\",\n \"Aucun template disponible pour évaluer la condition.\",\n ),\n );\n return;\n }\n\n if (tokens.length === 0) {\n setErrorMessage(\n t(\n \"condition_node.error_missing_tokens\",\n \"Aucune expression de condition n'est définie pour ce nœud.\",\n ),\n );\n return;\n }\n\n setIsLoadingSession(true);\n let freshSession: SessionData;\n try {\n freshSession = await fetchSessionById(session.id);\n } catch (error) {\n console.error(\"[ConditionNodeHandler] Error fetching fresh session:\", error);\n freshSession = session;\n } finally {\n setIsLoadingSession(false);\n }\n\n try {\n const evaluationResult = evaluateConditionTokens(tokens, {\n session: freshSession,\n userInput,\n contactInfo,\n });\n\n if (evaluationResult) {\n stepObject.goToNextStep(node.id, freshSession.template, \"true\");\n return;\n }\n\n if (node.conditionFalseMode === \"loop\") {\n stepObject.goToNextStep(node.id, freshSession.template, \"false\");\n return;\n }\n\n const maxRetries = normalizeConditionMaxRetries(node.conditionMaxRetries);\n const maxRetryAction = normalizeConditionMaxRetryAction(\n node.conditionMaxRetryAction,\n );\n const currentRetryCount = getNodeRetryCount(freshSession, node.id);\n const retryCountAfterFailure = currentRetryCount + 1;\n\n try {\n await updateNodeRetryCount(\n session.id,\n node.id,\n retryCountAfterFailure,\n );\n } catch (retryError) {\n console.error(\n \"[ConditionNodeHandler] Failed to persist retry count:\",\n retryError,\n );\n }\n\n if (\n hasExceededConditionMaxRetries(retryCountAfterFailure, maxRetries)\n ) {\n if (maxRetryAction === \"force-true\") {\n stepObject.goToNextStep(node.id, freshSession.template, \"true\");\n return;\n }\n stepObject.goToNextStep(node.id, freshSession.template, \"false\");\n return;\n }\n\n const falseEdge = findOutgoingEdge(node.id, freshSession.template, \"false\");\n if (!falseEdge) {\n throw new Error(\"No outgoing false edge defined for condition node\");\n }\n\n setFalseConditionState({\n message:\n node.conditionFalseErrorMessage?.trim() ||\n t(\n \"condition_node.false_error_default\",\n \"Les informations ne respectent pas les conditions demandées.\",\n ),\n retryCount: retryCountAfterFailure,\n maxRetries,\n template: freshSession.template,\n });\n } catch (error) {\n console.error(\"Failed to evaluate condition node\", error);\n setErrorMessage(\n t(\n \"condition_node.error_evaluation\",\n \"Impossible d'évaluer cette condition. Vous pouvez poursuivre manuellement.\",\n ),\n );\n }\n };\n\n evaluateCondition();\n }, [contactInfo, node, session, stepObject, t, tokens, userInput, templateNodes]);\n\n const handleRetry = () => {\n if (!falseConditionState) {\n return;\n }\n stepObject.goToNextStep(node.id, falseConditionState.template, \"false\");\n };\n\n if (isLoadingSession) {\n return (\n <LoadingState\n message={t(\n \"condition_node.loading_analysis\",\n \"Chargement des données d'analyse...\",\n )}\n subtitle={t(\n \"condition_node.loading_description\",\n \"Récupération des informations nécessaires pour évaluer la condition.\",\n )}\n />\n );\n }\n\n if (falseConditionState) {\n return (\n <div className=\"flex flex-col justify-between h-full w-full\">\n <div className=\"flex-1 px-4 py-6 pt-11 md:px-8 md:py-8\">\n <div className=\"w-full max-w-md mx-auto space-y-6\">\n <div className=\"text-center\">\n <div className=\"mx-auto w-16 h-16 bg-red-100 rounded-full flex items-center justify-center mb-4\">\n <div className=\"w-8 h-8 bg-red-500 rounded-full flex items-center justify-center\">\n <span className=\"text-white text-lg\">✕</span>\n </div>\n </div>\n </div>\n\n <div className=\"text-center space-y-4\">\n <h2 className=\"text-xl font-bold text-red-600\">\n {t(\"condition_node.false_error_title\", \"Condition non remplie\")}\n </h2>\n <p className=\"text-sm text-gray-600 leading-relaxed\">\n {falseConditionState.message}\n </p>\n </div>\n\n <div className=\"bg-orange-50 border border-orange-200 rounded-lg p-4\">\n <p className=\"text-sm text-orange-800\">\n {t(\n \"condition_node.retry_counter\",\n \"Tentative {{current}}/{{max}}\",\n {\n current: falseConditionState.retryCount,\n max: falseConditionState.maxRetries,\n },\n )}\n </p>\n </div>\n </div>\n </div>\n\n <div className=\"sticky bottom-0 md:static bg-white border-t md:border-t-0 p-4 md:p-0 md:pb-8\">\n <div className=\"w-full max-w-md mx-auto\">\n <button\n className=\"w-full px-4 py-2 bg-primary text-white rounded hover:bg-primary-dark transition-colors\"\n onClick={handleRetry}\n >\n {t(\"condition_node.buttons.retry\", \"Réessayer\")}\n </button>\n </div>\n </div>\n </div>\n );\n }\n\n if (errorMessage) {\n return (\n <div className=\"flex flex-col items-center justify-center h-full p-4 text-center\">\n <div className=\"text-red-500 text-4xl mb-4\">⚠️</div>\n <h2 className=\"text-xl font-bold text-red-600 mb-2\">\n {t(\"condition_node.title\", \"Condition\")}\n </h2>\n <p className=\"text-gray-600 mb-4\">{errorMessage}</p>\n <button\n className=\"px-4 py-2 bg-primary text-white rounded hover:bg-primary-dark transition-colors\"\n onClick={() => stepObject.setStep(stepObject.step + 1)}\n >\n {t(\"condition_node.buttons.skip\", \"Continuer\")}\n </button>\n </div>\n );\n }\n\n return (\n <LoadingState\n message={t(\n \"condition_node.evaluating\",\n \"Évaluation de la condition en cours...\",\n )}\n subtitle={t(\n \"condition_node.evaluating_description\",\n \"Merci de patienter pendant que nous déterminons la prochaine étape.\",\n )}\n />\n );\n};\n\nexport default ConditionNodeHandler;\n"],"names":["_jsx","_jsxs"],"mapp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,CACxC,EAAA,CACL,EAAA,CACF,CAAA,EAAA,CACF;IAEV;IAEA,IAAI,YAAY,EAAE;AAChB,QAAA,QACEC,IAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,kEAAkE,EAAA,QAAA,EAAA,CAC/ED,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,4BAA4B,EAAA,QAAA,EAAA,cAAA,EAAA,CAAS,EACpDA,YAAI,SAAS,EAAC,qCAAqC,EAAA,QAAA,EAChD,CAAC,CAAC,sBAAsB,EAAE,WAAW,CAAC,EAAA,CACpC,EACLA,GAAA,CAAA,GAAA,EAAA,EAAG,SAAS,EAAC,oBAAoB,YAAE,YAAY,EAAA,CAAK,EACpDA,GAAA,CAAA,QAAA,EAAA,EACE,SAAS,EAAC,iFAAiF,EAC3F,OAAO,EAAE,YAAA,EAAM,OAAA,UAAU,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,GAAG,CAAC,CAAC,CAAA,CAAvC,CAAuC,EAAA,QAAA,EAErD,CAAC,CAAC,6BAA6B,EAAE,WAAW,CAAC,EAAA,CACvC,CAAA,EAAA,CACL;IAEV;IAEA,QACEA,IAAC,YAAY,EAAA,EACX,OAAO,EAAE,CAAC,CACR,2BAA2B,EAC3B,wCAAwC,CACzC,EACD,QAAQ,EAAE,CAAC,CACT,uCAAuC,EACvC,qEAAqE,CACtE,EAAA,CACD;AAEN;;;;"}
1
+ {"version":3,"file":"ConditionNodeHandler.js","sources":["../../../../../src/components/template/ConditionNodeHandler.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useRef, useState } from \"react\";\nimport LoadingState from \"../states/LoadingState\";\nimport type { SessionData, SessionTemplateNode } from \"../../types/session\";\nimport type { stepObject } from \"../../types/session\";\nimport type { UserInput } from \"../../types/userInput\";\nimport type { ContactInfo } from \"../../types/contactInfo\";\nimport { useI18n } from \"../../hooks/useI18n\";\nimport {\n evaluateConditionTokens,\n parseConditionExpression,\n} from \"../../utils/conditionEvaluator\";\nimport {\n fetchSessionById,\n findOutgoingEdge,\n} from \"../../services/sessionService\";\nimport {\n getNodeRetryCount,\n updateNodeRetryCount,\n} from \"../../services/retryService\";\nimport {\n hasExceededConditionMaxRetries,\n normalizeConditionMaxRetries,\n normalizeConditionMaxRetryAction,\n} from \"./conditionNodePolicy\";\n\ninterface ConditionNodeHandlerProps {\n node: SessionTemplateNode;\n session: SessionData;\n templateNodes: SessionTemplateNode[];\n stepObject: stepObject;\n userInput: UserInput;\n contactInfo: ContactInfo;\n}\n\ninterface FalseConditionState {\n message: string;\n retryCount: number;\n maxRetries: number;\n template: SessionData[\"template\"];\n}\n\nconst ConditionNodeHandler: React.FC<ConditionNodeHandlerProps> = ({\n node,\n session,\n templateNodes,\n stepObject,\n userInput,\n contactInfo,\n}) => {\n const { t } = useI18n();\n const [errorMessage, setErrorMessage] = useState<string | null>(null);\n const [isLoadingSession, setIsLoadingSession] = useState(false);\n const [falseConditionState, setFalseConditionState] =\n useState<FalseConditionState | null>(null);\n const hasEvaluatedRef = useRef(false);\n\n const tokens = useMemo(() => {\n return (\n (node.conditionTokens && node.conditionTokens.length > 0\n ? node.conditionTokens\n : parseConditionExpression(node.conditionExpression || \"\")) || []\n );\n }, [node.conditionExpression, node.conditionTokens]);\n\n useEffect(() => {\n hasEvaluatedRef.current = false;\n setErrorMessage(null);\n setFalseConditionState(null);\n }, [node.id]);\n\n useEffect(() => {\n if (hasEvaluatedRef.current) {\n return;\n }\n hasEvaluatedRef.current = true;\n\n const evaluateCondition = async () => {\n if (!session?.template) {\n setErrorMessage(\n t(\n \"condition_node.error_missing_template\",\n \"Aucun template disponible pour évaluer la condition.\",\n ),\n );\n return;\n }\n\n if (tokens.length === 0) {\n setErrorMessage(\n t(\n \"condition_node.error_missing_tokens\",\n \"Aucune expression de condition n'est définie pour ce nœud.\",\n ),\n );\n return;\n }\n\n setIsLoadingSession(true);\n let freshSession: SessionData;\n try {\n freshSession = await fetchSessionById(session.id);\n } catch (error) {\n console.error(\"[ConditionNodeHandler] Error fetching fresh session:\", error);\n freshSession = session;\n } finally {\n setIsLoadingSession(false);\n }\n\n try {\n const evaluationResult = evaluateConditionTokens(tokens, {\n session: freshSession,\n userInput,\n contactInfo,\n });\n\n if (evaluationResult) {\n stepObject.goToNextStep(node.id, freshSession.template, \"true\");\n return;\n }\n\n if (node.conditionFalseMode !== \"retry\") {\n stepObject.goToNextStep(node.id, freshSession.template, \"false\");\n return;\n }\n\n const maxRetries = normalizeConditionMaxRetries(node.conditionMaxRetries);\n const maxRetryAction = normalizeConditionMaxRetryAction(\n node.conditionMaxRetryAction,\n );\n const currentRetryCount = getNodeRetryCount(freshSession, node.id);\n const retryCountAfterFailure = currentRetryCount + 1;\n\n try {\n await updateNodeRetryCount(\n session.id,\n node.id,\n retryCountAfterFailure,\n );\n } catch (retryError) {\n console.error(\n \"[ConditionNodeHandler] Failed to persist retry count:\",\n retryError,\n );\n }\n\n if (\n hasExceededConditionMaxRetries(retryCountAfterFailure, maxRetries)\n ) {\n if (maxRetryAction === \"force-true\") {\n stepObject.goToNextStep(node.id, freshSession.template, \"true\");\n return;\n }\n stepObject.goToNextStep(node.id, freshSession.template, \"false\");\n return;\n }\n\n const falseEdge = findOutgoingEdge(node.id, freshSession.template, \"false\");\n if (!falseEdge) {\n throw new Error(\"No outgoing false edge defined for condition node\");\n }\n\n setFalseConditionState({\n message:\n node.conditionFalseErrorMessage?.trim() ||\n t(\n \"condition_node.false_error_default\",\n \"Les informations ne respectent pas les conditions demandées.\",\n ),\n retryCount: retryCountAfterFailure,\n maxRetries,\n template: freshSession.template,\n });\n } catch (error) {\n console.error(\"Failed to evaluate condition node\", error);\n setErrorMessage(\n t(\n \"condition_node.error_evaluation\",\n \"Impossible d'évaluer cette condition. Vous pouvez poursuivre manuellement.\",\n ),\n );\n }\n };\n\n evaluateCondition();\n }, [contactInfo, node, session, stepObject, t, tokens, userInput, templateNodes]);\n\n const handleRetry = () => {\n if (!falseConditionState) {\n return;\n }\n stepObject.goToNextStep(node.id, falseConditionState.template, \"false\");\n };\n\n if (isLoadingSession) {\n return (\n <LoadingState\n message={t(\n \"condition_node.loading_analysis\",\n \"Chargement des données d'analyse...\",\n )}\n subtitle={t(\n \"condition_node.loading_description\",\n \"Récupération des informations nécessaires pour évaluer la condition.\",\n )}\n />\n );\n }\n\n if (falseConditionState) {\n return (\n <div className=\"flex flex-col justify-between h-full w-full\">\n <div className=\"flex-1 px-4 py-6 pt-11 md:px-8 md:py-8\">\n <div className=\"w-full max-w-md mx-auto space-y-6\">\n <div className=\"text-center\">\n <div className=\"mx-auto w-16 h-16 bg-red-100 rounded-full flex items-center justify-center mb-4\">\n <div className=\"w-8 h-8 bg-red-500 rounded-full flex items-center justify-center\">\n <span className=\"text-white text-lg\">✕</span>\n </div>\n </div>\n </div>\n\n <div className=\"text-center space-y-4\">\n <h2 className=\"text-xl font-bold text-red-600\">\n {t(\"condition_node.false_error_title\", \"Condition non remplie\")}\n </h2>\n <p className=\"text-sm text-gray-600 leading-relaxed\">\n {falseConditionState.message}\n </p>\n </div>\n\n <div className=\"bg-orange-50 border border-orange-200 rounded-lg p-4\">\n <p className=\"text-sm text-orange-800\">\n {t(\n \"condition_node.retry_counter\",\n \"Tentative {{current}}/{{max}}\",\n {\n current: falseConditionState.retryCount,\n max: falseConditionState.maxRetries,\n },\n )}\n </p>\n </div>\n </div>\n </div>\n\n <div className=\"sticky bottom-0 md:static bg-white border-t md:border-t-0 p-4 md:p-0 md:pb-8\">\n <div className=\"w-full max-w-md mx-auto\">\n <button\n className=\"w-full px-4 py-2 bg-primary text-white rounded hover:bg-primary-dark transition-colors\"\n onClick={handleRetry}\n >\n {t(\"condition_node.buttons.retry\", \"Réessayer\")}\n </button>\n </div>\n </div>\n </div>\n );\n }\n\n if (errorMessage) {\n return (\n <div className=\"flex flex-col items-center justify-center h-full p-4 text-center\">\n <div className=\"text-red-500 text-4xl mb-4\">⚠️</div>\n <h2 className=\"text-xl font-bold text-red-600 mb-2\">\n {t(\"condition_node.title\", \"Condition\")}\n </h2>\n <p className=\"text-gray-600 mb-4\">{errorMessage}</p>\n <button\n className=\"px-4 py-2 bg-primary text-white rounded hover:bg-primary-dark transition-colors\"\n onClick={() => stepObject.setStep(stepObject.step + 1)}\n >\n {t(\"condition_node.buttons.skip\", \"Continuer\")}\n </button>\n </div>\n );\n }\n\n return (\n <LoadingState\n message={t(\n \"condition_node.evaluating\",\n \"Évaluation de la condition en cours...\",\n )}\n subtitle={t(\n \"condition_node.evaluating_description\",\n \"Merci de patienter pendant que nous déterminons la prochaine étape.\",\n )}\n />\n );\n};\n\nexport default ConditionNodeHandler;\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;;;AAyCA,IAAM,oBAAoB,GAAwC,UAAC,EAOlE,EAAA;AANC,IAAA,IAAA,IAAI,GAAA,EAAA,CAAA,IAAA,EACJ,OAAO,GAAA,EAAA,CAAA,OAAA,EACP,aAAa,GAAA,EAAA,CAAA,aAAA,EACb,UAAU,gBAAA,EACV,SAAS,GAAA,EAAA,CAAA,SAAA,EACT,WAAW,GAAA,EAAA,CAAA,WAAA;AAEH,IAAA,IAAA,CAAC,GAAK,OAAO,EAAE,EAAd;IACH,IAAA,EAAA,GAAkC,QAAQ,CAAgB,IAAI,CAAC,EAA9D,YAAY,GAAA,EAAA,CAAA,CAAA,CAAA,EAAE,eAAe,GAAA,EAAA,CAAA,CAAA,CAAiC;IAC/D,IAAA,EAAA,GAA0C,QAAQ,CAAC,KAAK,CAAC,EAAxD,gBAAgB,GAAA,EAAA,CAAA,CAAA,CAAA,EAAE,mBAAmB,GAAA,EAAA,CAAA,CAAA,CAAmB;IACzD,IAAA,EAAA,GACJ,QAAQ,CAA6B,IAAI,CAAC,EADrC,mBAAmB,GAAA,EAAA,CAAA,CAAA,CAAA,EAAE,sBAAsB,GAAA,EAAA,CAAA,CAAA,CACN;AAC5C,IAAA,IAAM,eAAe,GAAG,MAAM,CAAC,KAAK,CAAC;IAErC,IAAM,MAAM,GAAG,OAAO,CA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uCAAuC,EACvC,qEAAqE,CACtE,EAAA,CACD;AAEN;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"session.js","sources":["../../../../src/types/session.ts"],"sourcesContent":["import type React from \"react\";\n\nexport interface SessionConfig {\n selfie?: boolean;\n requireMobile?: boolean;\n}\n\nexport interface DatakeenSessionProps {\n sessionId: string;\n sessionConfig?: SessionConfig;\n apiBaseUrl?: string; // Optional API base URL for dynamic environment configuration\n}\n\nexport interface UseSessionReturn {\n SessionComponent: React.ReactElement;\n}\n\nexport type stepObject = {\n setStep: (step: number, skipHistory?: boolean) => void;\n goBack: () => void;\n /** Retour arrière vers un nœud précis (ex: \"Corriger ma saisie\") :\n * tronque l'historique jusqu'à `targetStep` au lieu de l'empiler. */\n goBackToStep: (targetStep: number) => void;\n goToNextStep: (\n currentNodeId: string,\n template: SessionTemplate,\n handle?: string,\n ) => void;\n step: number;\n canGoBack: boolean;\n};\n\nexport interface ProcessingStep {\n title: string;\n subtitle: string;\n hasError?: boolean;\n}\n\nexport type ConditionTokenType = \"variable\" | \"control\" | \"operator\" | \"input\";\n\nexport interface ConditionToken {\n type: ConditionTokenType;\n value: string;\n label?: string;\n sourceNodeId?: string;\n}\n\n/**\n * Type for custom field value types\n */\nexport type CustomFieldValueType =\n | \"text\"\n | \"enum\"\n | \"number\"\n | \"boolean\"\n | \"date\"\n | \"email\"\n | \"address\"\n | \"list\";\n\n/**\n * Display formats supported for date fields (top-level and list columns).\n */\nexport type DateDisplayFormat = \"dd/mm/yyyy\" | \"mm/dd/yyyy\" | \"yyyy-mm-dd\";\n\nexport const DEFAULT_DATE_DISPLAY_FORMAT: DateDisplayFormat = \"dd/mm/yyyy\";\n\n/**\n * Column definition for a list-type custom field\n */\nexport interface ListColumn {\n label: string;\n type: \"text\" | \"enum\" | \"date\" | \"email\";\n options?: string[]; // required when type === 'enum'\n placeholder?: string; // text/email/date — shown to the end user\n regex?: string; // text — JS regex source (without slashes)\n regexErrorMessage?: string; // text — message displayed when regex fails\n dateFormat?: DateDisplayFormat; // date — display format expected\n}\n\n/**\n * Interface for custom field definition\n */\nexport interface CustomField {\n id: string;\n label: string;\n placeholder?: string;\n description?: string;\n valueType: CustomFieldValueType;\n enumOptions?: string[];\n listColumns?: ListColumn[]; // for list type: column definitions\n minRows?: number; // for list type: minimum rows expected\n required?: boolean;\n regex?: string; // text — JS regex source (without slashes)\n regexErrorMessage?: string; // text — message displayed when regex fails\n dateFormat?: DateDisplayFormat; // date — display format expected\n lockedFromApi?: boolean;\n userInputKey?: string;\n}\n\n/**\n * Interface for session template node\n */\nexport interface SessionTemplateNode {\n id: string;\n type: string;\n title: string;\n description: string;\n informationType?:\n | \"identity\"\n | \"identity-legal\"\n | \"contact\"\n | \"address\"\n | \"nationality\"\n | \"custom\";\n position: {\n x: number;\n y: number;\n };\n options: unknown[];\n selectedOptions: string[];\n requiredDocumentType?: string;\n isRequired: boolean;\n order: number;\n optionalFields?: string[];\n requiredFields?: string[];\n pageTitle?: string;\n pageDescription?: string;\n // Properties for document-collection node type\n allowedDocumentTypes?: Array<{\n id: string;\n name: string;\n /**\n * Optional side information coming from the template.\n * When provided and equals to two (\"two\", 2, \"double\", \"recto-verso\"),\n * consumers should allow uploading two sides (front/back).\n */\n side?: string | number;\n }>;\n allowedAddingMethods?: string[];\n introductionPage?: {\n title?: string;\n description?: string;\n };\n documentSelection?: {\n title?: string;\n description?: string;\n };\n // Start node specific properties\n welcomeTitle?: string;\n welcomeSubtitle?: string;\n welcomeDescription?: string;\n welcomeImage?: string;\n qrCodeTitle?: string;\n qrCodeDescription?: string;\n showLegacyCGU?: boolean; // default: true — rétrocompatibilité\n\n // Legal consent node specific properties\n consentDescription?: string;\n consentDescription2?: string;\n cguUrl?: string;\n privacyPolicyUrl?: string;\n checkboxText?: string;\n // Identity control specific properties\n automaticPhotoCapture?: boolean;\n nfcEnabled?: boolean;\n // \"nfcAndApi\" reste accepté pour rétrocompat (parcours legacy) ; à normaliser à la lecture.\n nfcMode?: \"nfcOnly\" | \"nfcOrPhoto\" | \"nfcAndApi\";\n acceptedCountries?: AcceptedCountry[];\n // End node specific properties\n callbackURL?: string | null;\n // Résultat forcé par le nœud `end` (configuré dans le builder). Sert au SDK à\n // afficher la variante « erreur conservée » de l'écran de fin quand la branche\n // fausse d'une condition pointe directement vers un end non_compliant.\n expectedResult?: string;\n // Condition node specific properties\n conditionExpression?: string;\n conditionTokens?: ConditionToken[];\n conditionFalseErrorMessage?: string;\n conditionMaxRetries?: number;\n conditionMaxRetryAction?: \"end-journey\" | \"force-true\";\n conditionFalseMode?: \"retry\" | \"loop\";\n\n // External verification specific properties\n targetApi?: \"INSEE\";\n referenceNodeId?: string;\n referenceNodeType?:\n | \"information-input\"\n | \"document-collection\"\n | \"identity-control\";\n referenceField?: \"siren\" | \"siret\";\n referenceVariable?: string;\n // Custom form fields (for information-input with type 'custom')\n customFields?: CustomField[];\n\n // Electronic signature specific properties\n templateId?: string;\n external_id?: string;\n fieldMappings?: Array<{\n sourceFieldId: string;\n label: string;\n docusealType: string;\n readonly: boolean;\n role?: string;\n sourceNodeId?: string;\n }>;\n /** If set, the generated PDF from this upstream pdf-generation node will be used as the document to sign */\n sourcePdfNodeId?: string;\n\n // PDF generation node specific properties\n // Note: htmlTemplate is intentionally NOT included — it is server-side only and never sent to the client\n pdfMode?: \"upload\" | \"html-template\";\n sourceNodeIds?: string[];\n\n // retry properties\n allowResubmission: boolean;\n maxResubmissionAttempts?: number;\n}\n\n/**\n * Interface for accepted countries\n */\nexport interface AcceptedCountry {\n code: string;\n documents: {\n passport: string[];\n idCard: string[];\n driverLicense: string[];\n residencePermit: string[];\n pinkDriverLicense: string[];\n };\n}\n\n/**\n * Interface for session template edge\n */\nexport interface SessionTemplateEdge {\n id: string;\n source: string;\n target: string;\n sourceHandle?: string;\n targetHandle?: string;\n conditionValue?: string;\n}\n\n/**\n * Interface for platform information\n */\nexport interface PlatformInfo {\n mobile: boolean;\n desktop: boolean;\n backoffice: boolean;\n}\n\n/**\n * Interface for session template\n */\n/** Clé du catalogue d'icônes des écrans de fin (mappée vers lucide-react au rendu). */\nexport type EndScreenIcon =\n | \"thanks\"\n | \"send\"\n | \"mail\"\n | \"check\"\n | \"clock\"\n | \"shield\"\n | \"user\"\n | \"info\";\n\nexport interface EndScreenItem {\n icon: EndScreenIcon;\n text: string;\n}\n\nexport interface EndScreenCase {\n title?: string;\n items: EndScreenItem[];\n}\n\n/** Textes de fin personnalisés (config globale du journey). Vide → fallback standard. */\nexport interface EndScreenConfig {\n compliant?: EndScreenCase;\n nonCompliant?: EndScreenCase;\n}\n\nexport interface SessionTemplate {\n id: string;\n name: string;\n description: string;\n version: string;\n languages: string[];\n nodes: SessionTemplateNode[];\n edges: SessionTemplateEdge[];\n groupId: string;\n userId: string | null;\n created_at: string;\n updated_at: string;\n platforms?: PlatformInfo;\n logo?: string;\n showQRCode?: boolean;\n buttonBgColor?: string;\n buttonTextColor?: string;\n endScreenConfig?: EndScreenConfig;\n}\n\n/**\n * Interface for session data\n */\nexport interface SessionData {\n id: string;\n userId: string | null;\n token: string;\n templateId: string;\n templateKey: string;\n expireTime: number;\n status: string;\n result: Record<string, unknown>;\n landingPage: unknown;\n withSelfie: boolean | null;\n groupId: string | null;\n userInput: Record<string, unknown>;\n contactInfo?: {\n email: string;\n phoneNumber: string;\n };\n callbackURL?: string | null;\n webhookURL: string;\n analysisTemplateId: string | null;\n userAgent: unknown[];\n mobile: boolean;\n analysisId: string | null;\n currentStep?: number;\n nfcStatus?: \"pending\" | \"opened\" | \"completed\" | \"skipped\" | \"failed\";\n createdAt: string;\n updatedAt: string;\n auditTrail: unknown[];\n user: unknown | null;\n analysis: unknown[];\n documents: unknown[];\n template: SessionTemplate;\n retryCounts?: Record<string, number>; // nodeId -> retry count\n}\n\nexport interface ClientInfo {\n ip?: string;\n location?: string;\n device: string;\n browser: string;\n os: string;\n}\n"],"names":[],"mappings":"AAiEO,IAAM,2BAA2B,GAAsB;;;;"}
1
+ {"version":3,"file":"session.js","sources":["../../../../src/types/session.ts"],"sourcesContent":["import type React from \"react\";\n\nexport interface SessionConfig {\n selfie?: boolean;\n requireMobile?: boolean;\n}\n\nexport interface DatakeenSessionProps {\n sessionId: string;\n sessionConfig?: SessionConfig;\n apiBaseUrl?: string; // Optional API base URL for dynamic environment configuration\n}\n\nexport interface UseSessionReturn {\n SessionComponent: React.ReactElement;\n}\n\nexport type stepObject = {\n setStep: (step: number, skipHistory?: boolean) => void;\n goBack: () => void;\n /** Retour arrière vers un nœud précis (ex: \"Corriger ma saisie\") :\n * tronque l'historique jusqu'à `targetStep` au lieu de l'empiler. */\n goBackToStep: (targetStep: number) => void;\n goToNextStep: (\n currentNodeId: string,\n template: SessionTemplate,\n handle?: string,\n ) => void;\n step: number;\n canGoBack: boolean;\n};\n\nexport interface ProcessingStep {\n title: string;\n subtitle: string;\n hasError?: boolean;\n}\n\nexport type ConditionTokenType = \"variable\" | \"control\" | \"operator\" | \"input\";\n\nexport interface ConditionToken {\n type: ConditionTokenType;\n value: string;\n label?: string;\n sourceNodeId?: string;\n}\n\n/**\n * Type for custom field value types\n */\nexport type CustomFieldValueType =\n | \"text\"\n | \"enum\"\n | \"number\"\n | \"boolean\"\n | \"date\"\n | \"email\"\n | \"address\"\n | \"list\";\n\n/**\n * Display formats supported for date fields (top-level and list columns).\n */\nexport type DateDisplayFormat = \"dd/mm/yyyy\" | \"mm/dd/yyyy\" | \"yyyy-mm-dd\";\n\nexport const DEFAULT_DATE_DISPLAY_FORMAT: DateDisplayFormat = \"dd/mm/yyyy\";\n\n/**\n * Column definition for a list-type custom field\n */\nexport interface ListColumn {\n label: string;\n type: \"text\" | \"enum\" | \"date\" | \"email\";\n options?: string[]; // required when type === 'enum'\n placeholder?: string; // text/email/date — shown to the end user\n regex?: string; // text — JS regex source (without slashes)\n regexErrorMessage?: string; // text — message displayed when regex fails\n dateFormat?: DateDisplayFormat; // date — display format expected\n}\n\n/**\n * Interface for custom field definition\n */\nexport interface CustomField {\n id: string;\n label: string;\n placeholder?: string;\n description?: string;\n valueType: CustomFieldValueType;\n enumOptions?: string[];\n listColumns?: ListColumn[]; // for list type: column definitions\n minRows?: number; // for list type: minimum rows expected\n required?: boolean;\n regex?: string; // text — JS regex source (without slashes)\n regexErrorMessage?: string; // text — message displayed when regex fails\n dateFormat?: DateDisplayFormat; // date — display format expected\n lockedFromApi?: boolean;\n userInputKey?: string;\n}\n\n/**\n * Interface for session template node\n */\nexport interface SessionTemplateNode {\n id: string;\n type: string;\n title: string;\n description: string;\n informationType?:\n | \"identity\"\n | \"identity-legal\"\n | \"contact\"\n | \"address\"\n | \"nationality\"\n | \"custom\";\n position: {\n x: number;\n y: number;\n };\n options: unknown[];\n selectedOptions: string[];\n requiredDocumentType?: string;\n isRequired: boolean;\n order: number;\n optionalFields?: string[];\n requiredFields?: string[];\n pageTitle?: string;\n pageDescription?: string;\n // Properties for document-collection node type\n allowedDocumentTypes?: Array<{\n id: string;\n name: string;\n /**\n * Optional side information coming from the template.\n * When provided and equals to two (\"two\", 2, \"double\", \"recto-verso\"),\n * consumers should allow uploading two sides (front/back).\n */\n side?: string | number;\n }>;\n allowedAddingMethods?: string[];\n introductionPage?: {\n title?: string;\n description?: string;\n };\n documentSelection?: {\n title?: string;\n description?: string;\n };\n // Start node specific properties\n welcomeTitle?: string;\n welcomeSubtitle?: string;\n welcomeDescription?: string;\n welcomeImage?: string;\n qrCodeTitle?: string;\n qrCodeDescription?: string;\n showLegacyCGU?: boolean; // default: true — rétrocompatibilité\n\n // Legal consent node specific properties\n consentDescription?: string;\n consentDescription2?: string;\n cguUrl?: string;\n privacyPolicyUrl?: string;\n checkboxText?: string;\n // Identity control specific properties\n automaticPhotoCapture?: boolean;\n nfcEnabled?: boolean;\n // \"nfcAndApi\" reste accepté pour rétrocompat (parcours legacy) ; à normaliser à la lecture.\n nfcMode?: \"nfcOnly\" | \"nfcOrPhoto\" | \"nfcAndApi\";\n acceptedCountries?: AcceptedCountry[];\n // End node specific properties\n callbackURL?: string | null;\n // Résultat forcé par le nœud `end` (configuré dans le builder). Sert au SDK à\n // afficher la variante « erreur conservée » de l'écran de fin quand la branche\n // fausse d'une condition pointe directement vers un end non_compliant.\n expectedResult?: string;\n // Condition node specific properties\n conditionExpression?: string;\n conditionTokens?: ConditionToken[];\n conditionFalseErrorMessage?: string;\n conditionMaxRetries?: number;\n conditionMaxRetryAction?: \"end-journey\" | \"force-true\";\n // Undefined is treated as \"loop\" by the SDK for legacy templates.\n conditionFalseMode?: \"retry\" | \"loop\";\n\n // External verification specific properties\n targetApi?: \"INSEE\";\n referenceNodeId?: string;\n referenceNodeType?:\n | \"information-input\"\n | \"document-collection\"\n | \"identity-control\";\n referenceField?: \"siren\" | \"siret\";\n referenceVariable?: string;\n // Custom form fields (for information-input with type 'custom')\n customFields?: CustomField[];\n\n // Electronic signature specific properties\n templateId?: string;\n external_id?: string;\n fieldMappings?: Array<{\n sourceFieldId: string;\n label: string;\n docusealType: string;\n readonly: boolean;\n role?: string;\n sourceNodeId?: string;\n }>;\n /** If set, the generated PDF from this upstream pdf-generation node will be used as the document to sign */\n sourcePdfNodeId?: string;\n\n // PDF generation node specific properties\n // Note: htmlTemplate is intentionally NOT included — it is server-side only and never sent to the client\n pdfMode?: \"upload\" | \"html-template\";\n sourceNodeIds?: string[];\n\n // retry properties\n allowResubmission: boolean;\n maxResubmissionAttempts?: number;\n}\n\n/**\n * Interface for accepted countries\n */\nexport interface AcceptedCountry {\n code: string;\n documents: {\n passport: string[];\n idCard: string[];\n driverLicense: string[];\n residencePermit: string[];\n pinkDriverLicense: string[];\n };\n}\n\n/**\n * Interface for session template edge\n */\nexport interface SessionTemplateEdge {\n id: string;\n source: string;\n target: string;\n sourceHandle?: string;\n targetHandle?: string;\n conditionValue?: string;\n}\n\n/**\n * Interface for platform information\n */\nexport interface PlatformInfo {\n mobile: boolean;\n desktop: boolean;\n backoffice: boolean;\n}\n\n/**\n * Interface for session template\n */\n/** Clé du catalogue d'icônes des écrans de fin (mappée vers lucide-react au rendu). */\nexport type EndScreenIcon =\n | \"thanks\"\n | \"send\"\n | \"mail\"\n | \"check\"\n | \"clock\"\n | \"shield\"\n | \"user\"\n | \"info\";\n\nexport interface EndScreenItem {\n icon: EndScreenIcon;\n text: string;\n}\n\nexport interface EndScreenCase {\n title?: string;\n items: EndScreenItem[];\n}\n\n/** Textes de fin personnalisés (config globale du journey). Vide → fallback standard. */\nexport interface EndScreenConfig {\n compliant?: EndScreenCase;\n nonCompliant?: EndScreenCase;\n}\n\nexport interface SessionTemplate {\n id: string;\n name: string;\n description: string;\n version: string;\n languages: string[];\n nodes: SessionTemplateNode[];\n edges: SessionTemplateEdge[];\n groupId: string;\n userId: string | null;\n created_at: string;\n updated_at: string;\n platforms?: PlatformInfo;\n logo?: string;\n showQRCode?: boolean;\n buttonBgColor?: string;\n buttonTextColor?: string;\n endScreenConfig?: EndScreenConfig;\n}\n\n/**\n * Interface for session data\n */\nexport interface SessionData {\n id: string;\n userId: string | null;\n token: string;\n templateId: string;\n templateKey: string;\n expireTime: number;\n status: string;\n result: Record<string, unknown>;\n landingPage: unknown;\n withSelfie: boolean | null;\n groupId: string | null;\n userInput: Record<string, unknown>;\n contactInfo?: {\n email: string;\n phoneNumber: string;\n };\n callbackURL?: string | null;\n webhookURL: string;\n analysisTemplateId: string | null;\n userAgent: unknown[];\n mobile: boolean;\n analysisId: string | null;\n currentStep?: number;\n nfcStatus?: \"pending\" | \"opened\" | \"completed\" | \"skipped\" | \"failed\";\n createdAt: string;\n updatedAt: string;\n auditTrail: unknown[];\n user: unknown | null;\n analysis: unknown[];\n documents: unknown[];\n template: SessionTemplate;\n retryCounts?: Record<string, number>; // nodeId -> retry count\n}\n\nexport interface ClientInfo {\n ip?: string;\n location?: string;\n device: string;\n browser: string;\n os: string;\n}\n"],"names":[],"mappings":"AAiEO,IAAM,2BAA2B,GAAsB;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datakeen-session-react",
3
- "version": "1.1.140-rc.73",
3
+ "version": "1.1.140-rc.74",
4
4
  "description": "React SDK component to manage and render Datakeen session experiences easily.",
5
5
  "publishConfig": {
6
6
  "access": "public",