datakeen-session-react 1.1.195 → 1.1.197
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/template/ExternalVerificationNodeHandler.js +78 -36
- package/dist/cjs/components/template/ExternalVerificationNodeHandler.js.map +1 -1
- package/dist/cjs/i18n/en.json.js +2 -0
- package/dist/cjs/i18n/en.json.js.map +1 -1
- package/dist/cjs/i18n/es.json.js +2 -0
- package/dist/cjs/i18n/es.json.js.map +1 -1
- package/dist/cjs/i18n/fr.json.js +2 -0
- package/dist/cjs/i18n/fr.json.js.map +1 -1
- package/dist/cjs/types/session.js.map +1 -1
- package/dist/esm/components/template/ExternalVerificationNodeHandler.js +78 -36
- package/dist/esm/components/template/ExternalVerificationNodeHandler.js.map +1 -1
- package/dist/esm/i18n/en.json.js +2 -0
- package/dist/esm/i18n/en.json.js.map +1 -1
- package/dist/esm/i18n/es.json.js +2 -0
- package/dist/esm/i18n/es.json.js.map +1 -1
- package/dist/esm/i18n/fr.json.js +2 -0
- package/dist/esm/i18n/fr.json.js.map +1 -1
- package/dist/esm/types/session.js.map +1 -1
- package/package.json +1 -1
|
@@ -9,6 +9,7 @@ import LoadingState from '../states/LoadingState.js';
|
|
|
9
9
|
import Title from '../ui/Title.js';
|
|
10
10
|
import Subtitle from '../ui/Subtitle.js';
|
|
11
11
|
import Button from '../ui/Button.js';
|
|
12
|
+
import { labelToKey } from '../../utils/labelToKey.js';
|
|
12
13
|
|
|
13
14
|
// ─── Helpers ──────────────────────────────────────────────────────────────────
|
|
14
15
|
var FIELD_ALIASES = {
|
|
@@ -101,6 +102,36 @@ var findValueByKeyName = function (sources, referenceField) {
|
|
|
101
102
|
return undefined;
|
|
102
103
|
};
|
|
103
104
|
var expandFieldKey = function (key) { var _a; return __spreadArray([key], ((_a = STANDARD_FIELD_ALIASES[key]) !== null && _a !== void 0 ? _a : []), true); };
|
|
105
|
+
/**
|
|
106
|
+
* Clés (clé aplatie dérivée du label + id du champ custom) des champs du nœud
|
|
107
|
+
* `nodeId` — et lui seul — qui correspondent au type recherché (siren/siret).
|
|
108
|
+
*
|
|
109
|
+
* Sans ce filtrage par nœud, la résolution retombe sur une recherche globale
|
|
110
|
+
* par nom de clé canonique (`findValueByKeyName` / repli 9-14 chiffres) qui
|
|
111
|
+
* ne sait pas distinguer deux nœuds ayant chacun un champ SIREN : un nœud
|
|
112
|
+
* "Identification de la société mère" (champ "SIREN" → clé `siren`) a ainsi
|
|
113
|
+
* capté la résolution d'un nœud "Votre entreprise" (champ "N° de SIREN" →
|
|
114
|
+
* clé `n_de_siren`) configuré comme référence, car `siren` matchait en
|
|
115
|
+
* premier la clé canonique — l'appel INPI est parti sur le mauvais SIREN.
|
|
116
|
+
*/
|
|
117
|
+
var getNodeScopedFieldKeys = function (templateNodes, nodeId, referenceField) {
|
|
118
|
+
var _a;
|
|
119
|
+
var node = templateNodes === null || templateNodes === void 0 ? void 0 : templateNodes.find(function (n) { return n.id === nodeId; });
|
|
120
|
+
var keys = [];
|
|
121
|
+
var _loop_2 = function (field) {
|
|
122
|
+
var normalized = normalizeKeyName(labelToKey(field.label));
|
|
123
|
+
if (!normalized.includes(referenceField))
|
|
124
|
+
return "continue";
|
|
125
|
+
if (THIRD_PARTY_KEY_MARKERS.some(function (marker) { return normalized.includes(marker); }))
|
|
126
|
+
return "continue";
|
|
127
|
+
keys.push(labelToKey(field.label), field.id);
|
|
128
|
+
};
|
|
129
|
+
for (var _i = 0, _b = (_a = node === null || node === void 0 ? void 0 : node.customFields) !== null && _a !== void 0 ? _a : []; _i < _b.length; _i++) {
|
|
130
|
+
var field = _b[_i];
|
|
131
|
+
_loop_2(field);
|
|
132
|
+
}
|
|
133
|
+
return keys;
|
|
134
|
+
};
|
|
104
135
|
// ─── Component ────────────────────────────────────────────────────────────────
|
|
105
136
|
var ExternalVerificationNodeHandler = function (_a) {
|
|
106
137
|
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
@@ -158,10 +189,10 @@ var ExternalVerificationNodeHandler = function (_a) {
|
|
|
158
189
|
useEffect(function () {
|
|
159
190
|
var abortController = new AbortController();
|
|
160
191
|
var run = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
161
|
-
var result, referenceField, referenceValueMasked, resolvedReferenceValue, referenceNodeId, referenceVariable, submittedFirstName, submittedLastName, submittedSiren, nodeInput, userInputFlat, lookupKeys, referenceValue, allCustomFields, _i, _a, _b, value, str, comparisonConfig, cfg, personNodeInput, flat, isPersonneMorale, sirenKeys, firstNameKeys, lastNameKeys, birthDateKeys, dateOfBirth, response, res, apiErr_1, apiResult, inpi, cfg, isPersonneMorale_1;
|
|
162
|
-
var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
163
|
-
return __generator(this, function (
|
|
164
|
-
switch (
|
|
192
|
+
var result, referenceField, referenceValueMasked, resolvedReferenceValue, referenceNodeId, referenceVariable, submittedFirstName, submittedLastName, submittedSiren, nodeInput, userInputFlat, nodeScopedKeys, lookupKeys, referenceValue, allCustomFields, _i, _a, _b, value, str, comparisonConfig, cfg, personNodeInput, flat, isPersonneMorale, sirenKeys, firstNameKeys, lastNameKeys, birthDateKeys, dateOfBirth, response, res, apiErr_1, apiResult, inpi, cfg, isPersonneMorale_1;
|
|
193
|
+
var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
194
|
+
return __generator(this, function (_w) {
|
|
195
|
+
switch (_w.label) {
|
|
165
196
|
case 0:
|
|
166
197
|
result = {
|
|
167
198
|
isVerified: false,
|
|
@@ -175,9 +206,9 @@ var ExternalVerificationNodeHandler = function (_a) {
|
|
|
175
206
|
submittedFirstName = '';
|
|
176
207
|
submittedLastName = '';
|
|
177
208
|
submittedSiren = '';
|
|
178
|
-
|
|
209
|
+
_w.label = 1;
|
|
179
210
|
case 1:
|
|
180
|
-
|
|
211
|
+
_w.trys.push([1, 9, , 10]);
|
|
181
212
|
if (!(session === null || session === void 0 ? void 0 : session.id))
|
|
182
213
|
throw new Error('Session ID is missing');
|
|
183
214
|
referenceField = normalizeReferenceField(String(nodeData.referenceField || referenceVariable || ''));
|
|
@@ -192,7 +223,8 @@ var ExternalVerificationNodeHandler = function (_a) {
|
|
|
192
223
|
case 2:
|
|
193
224
|
nodeInput = userInput[referenceNodeId];
|
|
194
225
|
userInputFlat = userInput;
|
|
195
|
-
|
|
226
|
+
nodeScopedKeys = getNodeScopedFieldKeys((_c = session === null || session === void 0 ? void 0 : session.template) === null || _c === void 0 ? void 0 : _c.nodes, referenceNodeId, referenceField);
|
|
227
|
+
lookupKeys = Array.from(new Set(__spreadArray(__spreadArray(__spreadArray([], nodeScopedKeys, true), [referenceVariable, referenceField], false), FIELD_ALIASES[referenceField], true).filter(Boolean)));
|
|
196
228
|
referenceValue = resolveFieldValue(nodeInput, userInputFlat, lookupKeys);
|
|
197
229
|
// 2e passe : la clé porte le nom du champ sans être canonique
|
|
198
230
|
// (cas de tout formulaire personnalisé).
|
|
@@ -235,14 +267,14 @@ var ExternalVerificationNodeHandler = function (_a) {
|
|
|
235
267
|
resolvedReferenceValue = referenceValue;
|
|
236
268
|
referenceValueMasked = maskReferenceValue(referenceValue);
|
|
237
269
|
comparisonConfig = void 0;
|
|
238
|
-
if (isInpiRbe && ((
|
|
270
|
+
if (isInpiRbe && ((_d = nodeData.comparisonConfig) === null || _d === void 0 ? void 0 : _d.personReferenceNodeId)) {
|
|
239
271
|
cfg = nodeData.comparisonConfig;
|
|
240
|
-
personNodeInput = (
|
|
272
|
+
personNodeInput = (_e = userInput[cfg.personReferenceNodeId]) !== null && _e !== void 0 ? _e : {};
|
|
241
273
|
flat = userInput;
|
|
242
274
|
isPersonneMorale = cfg.personType === 'MORALE';
|
|
243
275
|
if (isPersonneMorale) {
|
|
244
|
-
sirenKeys = expandFieldKey((
|
|
245
|
-
submittedSiren = (
|
|
276
|
+
sirenKeys = expandFieldKey((_f = cfg.personSirenField) !== null && _f !== void 0 ? _f : '').filter(Boolean);
|
|
277
|
+
submittedSiren = (_g = resolveFieldValue(personNodeInput, flat, sirenKeys)) !== null && _g !== void 0 ? _g : '';
|
|
246
278
|
if (submittedSiren) {
|
|
247
279
|
comparisonConfig = {
|
|
248
280
|
personType: 'MORALE',
|
|
@@ -255,46 +287,46 @@ var ExternalVerificationNodeHandler = function (_a) {
|
|
|
255
287
|
}
|
|
256
288
|
}
|
|
257
289
|
else {
|
|
258
|
-
firstNameKeys = expandFieldKey((
|
|
259
|
-
lastNameKeys = expandFieldKey((
|
|
290
|
+
firstNameKeys = expandFieldKey((_h = cfg.personFirstNameField) !== null && _h !== void 0 ? _h : '').filter(Boolean);
|
|
291
|
+
lastNameKeys = expandFieldKey((_j = cfg.personLastNameField) !== null && _j !== void 0 ? _j : '').filter(Boolean);
|
|
260
292
|
birthDateKeys = cfg.personBirthDateField
|
|
261
293
|
? expandFieldKey(cfg.personBirthDateField).filter(Boolean)
|
|
262
294
|
: [];
|
|
263
|
-
submittedFirstName = (
|
|
264
|
-
submittedLastName = (
|
|
295
|
+
submittedFirstName = (_k = resolveFieldValue(personNodeInput, flat, firstNameKeys)) !== null && _k !== void 0 ? _k : '';
|
|
296
|
+
submittedLastName = (_l = resolveFieldValue(personNodeInput, flat, lastNameKeys)) !== null && _l !== void 0 ? _l : '';
|
|
265
297
|
dateOfBirth = cfg.compareBirthDate && birthDateKeys.length
|
|
266
298
|
? resolveFieldValue(personNodeInput, flat, birthDateKeys)
|
|
267
299
|
: undefined;
|
|
268
300
|
if (submittedFirstName && submittedLastName) {
|
|
269
|
-
comparisonConfig = __assign({ firstName: submittedFirstName, lastName: submittedLastName, compareTargets: (
|
|
301
|
+
comparisonConfig = __assign({ firstName: submittedFirstName, lastName: submittedLastName, compareTargets: (_m = cfg.compareTargets) !== null && _m !== void 0 ? _m : ['mandataires'] }, (dateOfBirth ? { dateOfBirth: dateOfBirth } : {}));
|
|
270
302
|
}
|
|
271
303
|
}
|
|
272
304
|
}
|
|
273
305
|
if (isInpiRbe)
|
|
274
306
|
advanceStep(1);
|
|
275
|
-
|
|
307
|
+
_w.label = 4;
|
|
276
308
|
case 4:
|
|
277
|
-
|
|
278
|
-
return [4 /*yield*/, apiService.post("/session/sdk/".concat(session.id, "/verify-external/").concat(node.id), __assign({ apiType: apiType, referenceValue: referenceValue, referenceField: referenceField, enableRnaFallback: isInpiRbe && nodeData.rnaFallbackEnabled === true }, (comparisonConfig ? { comparisonConfig: comparisonConfig } : {})), { signal: abortController.signal })];
|
|
309
|
+
_w.trys.push([4, 7, , 8]);
|
|
310
|
+
return [4 /*yield*/, apiService.post("/session/sdk/".concat(session.id, "/verify-external/").concat(node.id), __assign({ apiType: apiType, referenceValue: referenceValue, referenceField: referenceField, enableRnaFallback: isInpiRbe && nodeData.rnaFallbackEnabled === true, enableInseeFallback: isInpiRbe && nodeData.enableInseeFallback === true }, (comparisonConfig ? { comparisonConfig: comparisonConfig } : {})), { signal: abortController.signal })];
|
|
279
311
|
case 5:
|
|
280
|
-
response =
|
|
312
|
+
response = _w.sent();
|
|
281
313
|
if (isInpiRbe)
|
|
282
314
|
advanceStep(2);
|
|
283
315
|
return [4 /*yield*/, new Promise(function (r) { return setTimeout(r, 600); })];
|
|
284
316
|
case 6:
|
|
285
|
-
|
|
286
|
-
res = (
|
|
317
|
+
_w.sent();
|
|
318
|
+
res = (_o = response.data) === null || _o === void 0 ? void 0 : _o.data;
|
|
287
319
|
if (res && typeof res.isVerified === 'boolean') {
|
|
288
320
|
result = res;
|
|
289
321
|
}
|
|
290
322
|
return [3 /*break*/, 8];
|
|
291
323
|
case 7:
|
|
292
|
-
apiErr_1 =
|
|
324
|
+
apiErr_1 = _w.sent();
|
|
293
325
|
if (abortController.signal.aborted)
|
|
294
326
|
return [2 /*return*/];
|
|
295
327
|
if (isInpiRbe)
|
|
296
328
|
advanceStep(2);
|
|
297
|
-
apiResult = (
|
|
329
|
+
apiResult = (_q = (_p = apiErr_1 === null || apiErr_1 === void 0 ? void 0 : apiErr_1.response) === null || _p === void 0 ? void 0 : _p.data) === null || _q === void 0 ? void 0 : _q.data;
|
|
298
330
|
if (apiResult && typeof apiResult.isVerified === 'boolean') {
|
|
299
331
|
result = apiResult;
|
|
300
332
|
}
|
|
@@ -309,7 +341,7 @@ var ExternalVerificationNodeHandler = function (_a) {
|
|
|
309
341
|
return [3 /*break*/, 8];
|
|
310
342
|
case 8: return [3 /*break*/, 10];
|
|
311
343
|
case 9:
|
|
312
|
-
|
|
344
|
+
_w.sent();
|
|
313
345
|
result = {
|
|
314
346
|
isVerified: false,
|
|
315
347
|
status: 'external_error',
|
|
@@ -347,13 +379,13 @@ var ExternalVerificationNodeHandler = function (_a) {
|
|
|
347
379
|
// En mode personne morale, seuls les mandataires personne morale ont
|
|
348
380
|
// un sens (un RBE est toujours une personne physique) ; en mode
|
|
349
381
|
// physique, comportement inchangé (mandataires individus uniquement).
|
|
350
|
-
mandataires: ((
|
|
382
|
+
mandataires: ((_r = inpi === null || inpi === void 0 ? void 0 : inpi.mandataires) !== null && _r !== void 0 ? _r : []).filter(function (m) {
|
|
351
383
|
return isPersonneMorale_1 ? m.type === 'personne_morale' : m.type === 'individu';
|
|
352
384
|
}),
|
|
353
|
-
beneficiairesEffectifs: (
|
|
354
|
-
compareTargets: isPersonneMorale_1 ? ['mandataires'] : ((
|
|
355
|
-
personNodeId: (
|
|
356
|
-
targetDenomination: (
|
|
385
|
+
beneficiairesEffectifs: (_s = inpi === null || inpi === void 0 ? void 0 : inpi.beneficiairesEffectifs) !== null && _s !== void 0 ? _s : [],
|
|
386
|
+
compareTargets: isPersonneMorale_1 ? ['mandataires'] : ((_t = cfg === null || cfg === void 0 ? void 0 : cfg.compareTargets) !== null && _t !== void 0 ? _t : ['mandataires']),
|
|
387
|
+
personNodeId: (_u = cfg === null || cfg === void 0 ? void 0 : cfg.personReferenceNodeId) !== null && _u !== void 0 ? _u : '',
|
|
388
|
+
targetDenomination: (_v = inpi === null || inpi === void 0 ? void 0 : inpi.identite) === null || _v === void 0 ? void 0 : _v.denomination,
|
|
357
389
|
siren: resolvedReferenceValue,
|
|
358
390
|
sirenNodeId: referenceNodeId,
|
|
359
391
|
source: inpi === null || inpi === void 0 ? void 0 : inpi.source,
|
|
@@ -379,13 +411,16 @@ var ExternalVerificationNodeHandler = function (_a) {
|
|
|
379
411
|
setPhase('success');
|
|
380
412
|
setTimeout(onNext, 1200);
|
|
381
413
|
}
|
|
382
|
-
else if (result.status === 'config_error') {
|
|
383
|
-
setPhase('success');
|
|
384
|
-
setTimeout(onNext, 800);
|
|
385
|
-
}
|
|
386
414
|
else {
|
|
415
|
+
// config_error / external_error / any other non-blocking technical
|
|
416
|
+
// failure (missing API key, registry down…) — never a fault of the
|
|
417
|
+
// end user. The backend already maps these to a 'done' analysisrun,
|
|
418
|
+
// never 'ai_rejected' (reviewed manually in backoffice), so the SDK
|
|
419
|
+
// stays non-blocking here too — but must never claim success
|
|
420
|
+
// (config_error used to show the success screen) and must never
|
|
421
|
+
// leave a blank screen (this phase previously had no render block).
|
|
387
422
|
setPhase('error');
|
|
388
|
-
setTimeout(onNext,
|
|
423
|
+
setTimeout(onNext, 1200);
|
|
389
424
|
}
|
|
390
425
|
return [2 /*return*/];
|
|
391
426
|
}
|
|
@@ -409,12 +444,19 @@ var ExternalVerificationNodeHandler = function (_a) {
|
|
|
409
444
|
};
|
|
410
445
|
// ─── Loading phase ─────────────────────────────────────────────────────────
|
|
411
446
|
if (phase === 'loading') {
|
|
412
|
-
return (jsx("div", { className: "flex flex-col justify-between h-full w-full", children: jsx("div", { className: "flex-1 px-4 py-6 pt-11 md:px-8 md:py-8", children: jsxs("div", { className: "w-full max-w-md mx-auto space-y-6", children: [jsxs("div", { className: "text-center space-y-4", children: [jsx(Title, { className: "text-xl md:text-2xl lg:text-3xl", children: t('verification_node.verifying_title', 'Vérification en cours…') }), jsx(Subtitle, { className: "text-sm text-gray-600 leading-relaxed", children: t('verification_node.verifying_desc', 'Nous vérifions vos informations. Cela peut prendre quelques instants.') })] }), jsx("div", { className: "w-full flex justify-center", children: jsx("div", { className: "space-y-5", children: steps.map(function (step, index) { return (jsxs("div", { className: "flex items-start", children: [jsx("div", { className: "mr-4 mt-1
|
|
447
|
+
return (jsx("div", { className: "flex flex-col justify-between h-full w-full", children: jsx("div", { className: "flex-1 px-4 py-6 pt-11 md:px-8 md:py-8", children: jsxs("div", { className: "w-full max-w-md mx-auto space-y-6", children: [jsxs("div", { className: "text-center space-y-4", children: [jsx(Title, { className: "text-xl md:text-2xl lg:text-3xl", children: t('verification_node.verifying_title', 'Vérification en cours…') }), jsx(Subtitle, { className: "text-sm text-gray-600 leading-relaxed", children: t('verification_node.verifying_desc', 'Nous vérifions vos informations. Cela peut prendre quelques instants.') })] }), jsx("div", { className: "w-full flex justify-center", children: jsx("div", { className: "space-y-5", children: steps.map(function (step, index) { return (jsxs("div", { className: "flex items-start", children: [jsx("div", { className: "mr-4 mt-1 shrink-0", children: step.status === 'done' ? (jsx("div", { className: "flex items-center justify-center w-6 h-6 rounded-full bg-[#11E5C5] text-white text-xs", children: "\u2713" })) : step.status === 'active' ? (jsx("div", { className: "w-6 h-6 rounded-full border-2 border-t-[#11E5C5] border-r-[#11E5C5] border-b-[#11E5C5] border-l-transparent animate-spin" })) : (jsx("div", { className: "w-6 h-6 rounded-full border-2 border-gray-300" })) }), jsxs("div", { className: "flex-1 min-w-0", children: [jsx("p", { className: "font-medium text-[#3C3C40] text-sm", children: step.title }), jsx("p", { className: "text-xs text-gray-500 mt-1", children: step.subtitle })] })] }, index)); }) }) })] }) }) }));
|
|
413
448
|
}
|
|
414
449
|
// ─── Success phase ─────────────────────────────────────────────────────────
|
|
415
450
|
if (phase === 'success') {
|
|
416
451
|
return (jsxs("div", { className: "flex flex-col items-center justify-center h-full px-6 py-8 text-center space-y-4", children: [jsx("img", { src: checkIcon, alt: "success", className: "w-24 h-24" }), jsx("h3", { className: "text-[#3C3C40] font-poppins text-xl font-bold", children: t('inpi_verification.success_title', 'Vérification réussie') }), jsx("p", { className: "text-gray-500 text-sm", children: t('inpi_verification.success_desc', "Passage à l'étape suivante…") })] }));
|
|
417
452
|
}
|
|
453
|
+
// ─── Technical error phase (config_error / external_error) ────────────────
|
|
454
|
+
//
|
|
455
|
+
// Non-blocking (the flow already auto-advances via the useEffect above) but
|
|
456
|
+
// must never look like a success — neutral wording, no checkmark.
|
|
457
|
+
if (phase === 'error') {
|
|
458
|
+
return (jsxs("div", { className: "flex flex-col items-center justify-center h-full px-6 py-8 text-center space-y-4", children: [jsx("div", { className: "w-16 h-16 bg-gray-100 rounded-full flex items-center justify-center", children: jsx("span", { className: "text-gray-500 text-2xl font-bold", children: "!" }) }), jsx("h3", { className: "text-[#3C3C40] font-poppins text-xl font-bold", children: t('inpi_verification.technical_error_title', 'Vérification en cours de traitement') }), jsx("p", { className: "text-gray-500 text-sm", children: t('inpi_verification.technical_error_desc', 'Un problème technique est survenu. Votre dossier sera examiné manuellement.') })] }));
|
|
459
|
+
}
|
|
418
460
|
// ─── Mismatch phase ────────────────────────────────────────────────────────
|
|
419
461
|
if (phase === 'mismatch') {
|
|
420
462
|
var d = errorScreenData;
|