datakeen-session-react 1.1.140-dev.135 → 1.1.140-dev.137

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 +1 @@
1
- {"version":3,"file":"validationUtils.js","sources":["../../../../src/utils/validationUtils.ts"],"sourcesContent":["import type { Prediction } from \"./apiAnalysis\";\n\n/**\n * Default validation points for success scenarios\n */\nconst DEFAULT_SUCCESS_VALIDATION_POINTS = {\n quality: \"success.quality_excellent\",\n readability: \"success.readability_confirmed\",\n authenticity: \"success.authenticity_verified\",\n} as const;\n\n/**\n * Default validation points for error scenarios\n */\nconst DEFAULT_ERROR_VALIDATION_POINTS = {\n quality: \"errors.image_quality_insufficient\",\n readability: \"errors.readability_problematic\",\n authenticity: \"errors.authenticity_not_verified\",\n} as const;\n\n/**\n * Safely extracts error code from predictions array\n */\nexport function getErrorCodeFromPredictions(predictions?: Prediction[] | null): string | null {\n if (!predictions || !Array.isArray(predictions) || predictions.length === 0) {\n return null;\n }\n return predictions[0].code || null;\n}\n\n/**\n * Gets validation points based on error code and scenario type\n * \n * @param errorCode - The error code from API response (e.g., \"1.0\", \"2.1\")\n * @param predictions - Optional predictions array as fallback for error code\n * @param t - Translation function from i18n\n * @param type - Type of scenario: 'success' or 'error'\n * @returns Array of validation point strings\n */\nexport function getValidationPoints(\n errorCode: string | undefined | null,\n predictions: Prediction[] | undefined | null,\n t: any, // Using any to be compatible with i18n TFunction\n type: 'success' | 'error'\n): string[] {\n // Use errorCode from props, or try to get from predictions as fallback\n let code = errorCode;\n if (!code) {\n code = getErrorCodeFromPredictions(predictions);\n }\n\n if (code) {\n // Try to get code-specific validation points from i18n\n const quality = t(`validation_points.${code}.quality`, \"\");\n const readability = t(`validation_points.${code}.readability`, \"\");\n const document = t(`validation_points.${code}.document`, \"\");\n\n // If we have at least quality and readability, use code-specific points\n if (quality && readability) {\n // Filter out empty strings\n return [quality, readability, document].filter(Boolean);\n }\n }\n\n // Fallback to default validation points\n const defaults = type === 'success'\n ? DEFAULT_SUCCESS_VALIDATION_POINTS\n : DEFAULT_ERROR_VALIDATION_POINTS;\n\n return [\n t(defaults.quality, \"\"),\n t(defaults.readability, \"\"),\n t(defaults.authenticity, \"\"),\n ].filter(Boolean);\n}\n"],"names":[],"mappings":"AAEA;;AAEG;AACH,IAAM,iCAAiC,GAAG;AACtC,IAAA,OAAO,EAAE,2BAA2B;AACpC,IAAA,WAAW,EAAE,+BAA+B;AAC5C,IAAA,YAAY,EAAE,+BAA+B;CACvC;AAEV;;AAEG;AACH,IAAM,+BAA+B,GAAG;AACpC,IAAA,OAAO,EAAE,mCAAmC;AAC5C,IAAA,WAAW,EAAE,gCAAgC;AAC7C,IAAA,YAAY,EAAE,kCAAkC;CAC1C;AAEV;;AAEG;AACG,SAAU,2BAA2B,CAAC,WAAiC,EAAA;AACzE,IAAA,IAAI,CAAC,WAAW,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE;AACzE,QAAA,OAAO,IAAI;IACf;IACA,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,IAAI;AACtC;AAEA;;;;;;;;AAQG;AACG,SAAU,mBAAmB,CAC/B,SAAoC,EACpC,WAA4C,EAC5C,CAAM;AACN,IAAyB,EAAA;;IAGzB,IAAI,IAAI,GAAG,SAAS;IACpB,IAAI,CAAC,IAAI,EAAE;AACP,QAAA,IAAI,GAAG,2BAA2B,CAAC,WAAW,CAAC;IACnD;IAEA,IAAI,IAAI,EAAE;;QAEN,IAAM,OAAO,GAAG,CAAC,CAAC,oBAAA,CAAA,MAAA,CAAqB,IAAI,EAAA,UAAA,CAAU,EAAE,EAAE,CAAC;QAC1D,IAAM,WAAW,GAAG,CAAC,CAAC,oBAAA,CAAA,MAAA,CAAqB,IAAI,EAAA,cAAA,CAAc,EAAE,EAAE,CAAC;QAClE,IAAM,UAAQ,GAAG,CAAC,CAAC,oBAAA,CAAA,MAAA,CAAqB,IAAI,EAAA,WAAA,CAAW,EAAE,EAAE,CAAC;;AAG5D,QAAA,IAAI,OAAO,IAAI,WAAW,EAAE;;AAExB,YAAA,OAAO,CAAC,OAAO,EAAE,WAAW,EAAE,UAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC;QAC3D;IACJ;;AAGA,IAAA,IAAM,QAAQ,GAAG,IAAI,KAAK;AACtB,UAAE;UACA,+BAA+B;IAErC,OAAO;AACH,QAAA,CAAC,CAAC,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC;AACvB,QAAA,CAAC,CAAC,QAAQ,CAAC,WAAW,EAAE,EAAE,CAAC;AAC3B,QAAA,CAAC,CAAC,QAAQ,CAAC,YAAY,EAAE,EAAE,CAAC;AAC/B,KAAA,CAAC,MAAM,CAAC,OAAO,CAAC;AACrB;;;;"}
1
+ {"version":3,"file":"validationUtils.js","sources":["../../../../src/utils/validationUtils.ts"],"sourcesContent":["import type { Prediction, JdiMismatchDetail } from \"./apiAnalysis\";\n\n/**\n * Clé i18n (suffixe de `validation_points.7.0.*`) pour chaque champ d'identité\n * en échec. Voir docs backend NFC_JDI_ERROR_MAPPING.md pour le référentiel de\n * codes — 7.0 = \"owner\" (le détenteur du document ne correspond pas à la\n * saisie utilisateur).\n */\nconst MISMATCH_FIELD_KEY: Record<JdiMismatchDetail[\"field\"], string> = {\n firstName: \"mismatch_first_name\",\n lastName: \"mismatch_last_name\",\n birthDate: \"mismatch_birth_date\",\n};\n\n/**\n * Default validation points for success scenarios\n */\nconst DEFAULT_SUCCESS_VALIDATION_POINTS = {\n quality: \"success.quality_excellent\",\n readability: \"success.readability_confirmed\",\n authenticity: \"success.authenticity_verified\",\n} as const;\n\n/**\n * Default validation points for error scenarios\n */\nconst DEFAULT_ERROR_VALIDATION_POINTS = {\n quality: \"errors.image_quality_insufficient\",\n readability: \"errors.readability_problematic\",\n authenticity: \"errors.authenticity_not_verified\",\n} as const;\n\n/**\n * Safely extracts error code from predictions array\n */\nexport function getErrorCodeFromPredictions(predictions?: Prediction[] | null): string | null {\n if (!predictions || !Array.isArray(predictions) || predictions.length === 0) {\n return null;\n }\n return predictions[0].code || null;\n}\n\n/**\n * Gets validation points based on error code and scenario type\n *\n * @param errorCode - The error code from API response (e.g., \"1.0\", \"2.1\")\n * @param predictions - Optional predictions array as fallback for error code\n * @param t - Translation function from i18n\n * @param type - Type of scenario: 'success' or 'error'\n * @param mismatchDetails - Pour le code 7.0 uniquement : champs d'identité en\n * échec (saisi vs lu), calculés côté backend. S'ils sont fournis et non\n * vides, remplacent la bullet \"document\" générique par un message\n * personnalisé par champ. Sinon, comportement inchangé (message générique).\n * @returns Array of validation point strings\n */\nexport function getValidationPoints(\n errorCode: string | undefined | null,\n predictions: Prediction[] | undefined | null,\n t: any, // Using any to be compatible with i18n TFunction\n type: 'success' | 'error',\n mismatchDetails?: JdiMismatchDetail[] | null,\n): string[] {\n // Use errorCode from props, or try to get from predictions as fallback\n let code = errorCode;\n if (!code) {\n code = getErrorCodeFromPredictions(predictions);\n }\n\n if (code) {\n // Try to get code-specific validation points from i18n\n const quality = t(`validation_points.${code}.quality`, \"\");\n const readability = t(`validation_points.${code}.readability`, \"\");\n\n // If we have at least quality and readability, use code-specific points\n if (quality && readability) {\n if (code === '7.0' && mismatchDetails && mismatchDetails.length > 0) {\n const mismatchBullets = mismatchDetails\n .map((detail) => {\n const fieldKey = MISMATCH_FIELD_KEY[detail.field];\n if (!fieldKey) return \"\";\n return t(`validation_points.7.0.${fieldKey}`, {\n entered: detail.entered,\n read: detail.read,\n });\n })\n .filter(Boolean);\n\n if (mismatchBullets.length > 0) {\n return [quality, readability, ...mismatchBullets].filter(Boolean);\n }\n }\n\n const document = t(`validation_points.${code}.document`, \"\");\n // Filter out empty strings\n return [quality, readability, document].filter(Boolean);\n }\n }\n\n // Fallback to default validation points\n const defaults = type === 'success'\n ? DEFAULT_SUCCESS_VALIDATION_POINTS\n : DEFAULT_ERROR_VALIDATION_POINTS;\n\n return [\n t(defaults.quality, \"\"),\n t(defaults.readability, \"\"),\n t(defaults.authenticity, \"\"),\n ].filter(Boolean);\n}\n"],"names":[],"mappings":";;AAEA;;;;;AAKG;AACH,IAAM,kBAAkB,GAA+C;AACnE,IAAA,SAAS,EAAE,qBAAqB;AAChC,IAAA,QAAQ,EAAE,oBAAoB;AAC9B,IAAA,SAAS,EAAE,qBAAqB;CACnC;AAED;;AAEG;AACH,IAAM,iCAAiC,GAAG;AACtC,IAAA,OAAO,EAAE,2BAA2B;AACpC,IAAA,WAAW,EAAE,+BAA+B;AAC5C,IAAA,YAAY,EAAE,+BAA+B;CACvC;AAEV;;AAEG;AACH,IAAM,+BAA+B,GAAG;AACpC,IAAA,OAAO,EAAE,mCAAmC;AAC5C,IAAA,WAAW,EAAE,gCAAgC;AAC7C,IAAA,YAAY,EAAE,kCAAkC;CAC1C;AAEV;;AAEG;AACG,SAAU,2BAA2B,CAAC,WAAiC,EAAA;AACzE,IAAA,IAAI,CAAC,WAAW,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE;AACzE,QAAA,OAAO,IAAI;IACf;IACA,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,IAAI;AACtC;AAEA;;;;;;;;;;;;AAYG;AACG,SAAU,mBAAmB,CAC/B,SAAoC,EACpC,WAA4C,EAC5C,CAAM;AACN,IAAyB,EACzB,eAA4C,EAAA;;IAG5C,IAAI,IAAI,GAAG,SAAS;IACpB,IAAI,CAAC,IAAI,EAAE;AACP,QAAA,IAAI,GAAG,2BAA2B,CAAC,WAAW,CAAC;IACnD;IAEA,IAAI,IAAI,EAAE;;QAEN,IAAM,OAAO,GAAG,CAAC,CAAC,oBAAA,CAAA,MAAA,CAAqB,IAAI,EAAA,UAAA,CAAU,EAAE,EAAE,CAAC;QAC1D,IAAM,WAAW,GAAG,CAAC,CAAC,oBAAA,CAAA,M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C,YAAY,EAAE,EAAE,CAAC;AAC/B,KAAA,CAAC,MAAM,CAAC,OAAO,CAAC;AACrB;;;;"}
@@ -1,3 +1,13 @@
1
+ /**
2
+ * Détail d'un champ d'identité en échec pour le code 7.0 (owner mismatch) :
3
+ * valeur saisie par l'utilisateur vs valeur lue sur le document, telles que
4
+ * calculées côté backend (voir GET /session/sdk/:id/analysis-status).
5
+ */
6
+ interface JdiMismatchDetail {
7
+ field: 'firstName' | 'lastName' | 'birthDate';
8
+ entered: string;
9
+ read: string;
10
+ }
1
11
  interface Prediction {
2
12
  code: string;
3
13
  codeDescription: string;
@@ -8,6 +18,8 @@ interface Prediction {
8
18
  firstName?: string;
9
19
  lastName?: string;
10
20
  };
21
+ /** Présent uniquement pour le code 7.0, quand un mismatch a été détecté. */
22
+ mismatchDetails?: JdiMismatchDetail[];
11
23
  }
12
24
  interface AnalysisResult {
13
25
  predictions: Prediction[];
@@ -29,4 +41,4 @@ declare const hasAnalysisFailed: (predictions: Prediction[]) => boolean;
29
41
  declare const getPrimaryRootCause: (predictions: Prediction[]) => string | null;
30
42
 
31
43
  export { extractRootCauses, getPrimaryRootCause, hasAnalysisFailed };
32
- export type { AnalysisResult, Prediction };
44
+ export type { AnalysisResult, JdiMismatchDetail, Prediction };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datakeen-session-react",
3
- "version": "1.1.140-dev.135",
3
+ "version": "1.1.140-dev.137",
4
4
  "description": "React SDK component to manage and render Datakeen session experiences easily.",
5
5
  "publishConfig": {
6
6
  "access": "public",