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
|
@@ -13,6 +13,7 @@ var LoadingState = require('../states/LoadingState.js');
|
|
|
13
13
|
var Title = require('../ui/Title.js');
|
|
14
14
|
var Subtitle = require('../ui/Subtitle.js');
|
|
15
15
|
var Button = require('../ui/Button.js');
|
|
16
|
+
var labelToKey = require('../../utils/labelToKey.js');
|
|
16
17
|
|
|
17
18
|
// ─── Helpers ──────────────────────────────────────────────────────────────────
|
|
18
19
|
var FIELD_ALIASES = {
|
|
@@ -105,6 +106,36 @@ var findValueByKeyName = function (sources, referenceField) {
|
|
|
105
106
|
return undefined;
|
|
106
107
|
};
|
|
107
108
|
var expandFieldKey = function (key) { var _a; return tslib_es6.__spreadArray([key], ((_a = STANDARD_FIELD_ALIASES[key]) !== null && _a !== void 0 ? _a : []), true); };
|
|
109
|
+
/**
|
|
110
|
+
* Clés (clé aplatie dérivée du label + id du champ custom) des champs du nœud
|
|
111
|
+
* `nodeId` — et lui seul — qui correspondent au type recherché (siren/siret).
|
|
112
|
+
*
|
|
113
|
+
* Sans ce filtrage par nœud, la résolution retombe sur une recherche globale
|
|
114
|
+
* par nom de clé canonique (`findValueByKeyName` / repli 9-14 chiffres) qui
|
|
115
|
+
* ne sait pas distinguer deux nœuds ayant chacun un champ SIREN : un nœud
|
|
116
|
+
* "Identification de la société mère" (champ "SIREN" → clé `siren`) a ainsi
|
|
117
|
+
* capté la résolution d'un nœud "Votre entreprise" (champ "N° de SIREN" →
|
|
118
|
+
* clé `n_de_siren`) configuré comme référence, car `siren` matchait en
|
|
119
|
+
* premier la clé canonique — l'appel INPI est parti sur le mauvais SIREN.
|
|
120
|
+
*/
|
|
121
|
+
var getNodeScopedFieldKeys = function (templateNodes, nodeId, referenceField) {
|
|
122
|
+
var _a;
|
|
123
|
+
var node = templateNodes === null || templateNodes === void 0 ? void 0 : templateNodes.find(function (n) { return n.id === nodeId; });
|
|
124
|
+
var keys = [];
|
|
125
|
+
var _loop_2 = function (field) {
|
|
126
|
+
var normalized = normalizeKeyName(labelToKey.labelToKey(field.label));
|
|
127
|
+
if (!normalized.includes(referenceField))
|
|
128
|
+
return "continue";
|
|
129
|
+
if (THIRD_PARTY_KEY_MARKERS.some(function (marker) { return normalized.includes(marker); }))
|
|
130
|
+
return "continue";
|
|
131
|
+
keys.push(labelToKey.labelToKey(field.label), field.id);
|
|
132
|
+
};
|
|
133
|
+
for (var _i = 0, _b = (_a = node === null || node === void 0 ? void 0 : node.customFields) !== null && _a !== void 0 ? _a : []; _i < _b.length; _i++) {
|
|
134
|
+
var field = _b[_i];
|
|
135
|
+
_loop_2(field);
|
|
136
|
+
}
|
|
137
|
+
return keys;
|
|
138
|
+
};
|
|
108
139
|
// ─── Component ────────────────────────────────────────────────────────────────
|
|
109
140
|
var ExternalVerificationNodeHandler = function (_a) {
|
|
110
141
|
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
@@ -162,10 +193,10 @@ var ExternalVerificationNodeHandler = function (_a) {
|
|
|
162
193
|
React.useEffect(function () {
|
|
163
194
|
var abortController = new AbortController();
|
|
164
195
|
var run = function () { return tslib_es6.__awaiter(void 0, void 0, void 0, function () {
|
|
165
|
-
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;
|
|
166
|
-
var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
167
|
-
return tslib_es6.__generator(this, function (
|
|
168
|
-
switch (
|
|
196
|
+
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;
|
|
197
|
+
var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
198
|
+
return tslib_es6.__generator(this, function (_w) {
|
|
199
|
+
switch (_w.label) {
|
|
169
200
|
case 0:
|
|
170
201
|
result = {
|
|
171
202
|
isVerified: false,
|
|
@@ -179,9 +210,9 @@ var ExternalVerificationNodeHandler = function (_a) {
|
|
|
179
210
|
submittedFirstName = '';
|
|
180
211
|
submittedLastName = '';
|
|
181
212
|
submittedSiren = '';
|
|
182
|
-
|
|
213
|
+
_w.label = 1;
|
|
183
214
|
case 1:
|
|
184
|
-
|
|
215
|
+
_w.trys.push([1, 9, , 10]);
|
|
185
216
|
if (!(session === null || session === void 0 ? void 0 : session.id))
|
|
186
217
|
throw new Error('Session ID is missing');
|
|
187
218
|
referenceField = normalizeReferenceField(String(nodeData.referenceField || referenceVariable || ''));
|
|
@@ -196,7 +227,8 @@ var ExternalVerificationNodeHandler = function (_a) {
|
|
|
196
227
|
case 2:
|
|
197
228
|
nodeInput = userInput[referenceNodeId];
|
|
198
229
|
userInputFlat = userInput;
|
|
199
|
-
|
|
230
|
+
nodeScopedKeys = getNodeScopedFieldKeys((_c = session === null || session === void 0 ? void 0 : session.template) === null || _c === void 0 ? void 0 : _c.nodes, referenceNodeId, referenceField);
|
|
231
|
+
lookupKeys = Array.from(new Set(tslib_es6.__spreadArray(tslib_es6.__spreadArray(tslib_es6.__spreadArray([], nodeScopedKeys, true), [referenceVariable, referenceField], false), FIELD_ALIASES[referenceField], true).filter(Boolean)));
|
|
200
232
|
referenceValue = resolveFieldValue(nodeInput, userInputFlat, lookupKeys);
|
|
201
233
|
// 2e passe : la clé porte le nom du champ sans être canonique
|
|
202
234
|
// (cas de tout formulaire personnalisé).
|
|
@@ -239,14 +271,14 @@ var ExternalVerificationNodeHandler = function (_a) {
|
|
|
239
271
|
resolvedReferenceValue = referenceValue;
|
|
240
272
|
referenceValueMasked = maskReferenceValue(referenceValue);
|
|
241
273
|
comparisonConfig = void 0;
|
|
242
|
-
if (isInpiRbe && ((
|
|
274
|
+
if (isInpiRbe && ((_d = nodeData.comparisonConfig) === null || _d === void 0 ? void 0 : _d.personReferenceNodeId)) {
|
|
243
275
|
cfg = nodeData.comparisonConfig;
|
|
244
|
-
personNodeInput = (
|
|
276
|
+
personNodeInput = (_e = userInput[cfg.personReferenceNodeId]) !== null && _e !== void 0 ? _e : {};
|
|
245
277
|
flat = userInput;
|
|
246
278
|
isPersonneMorale = cfg.personType === 'MORALE';
|
|
247
279
|
if (isPersonneMorale) {
|
|
248
|
-
sirenKeys = expandFieldKey((
|
|
249
|
-
submittedSiren = (
|
|
280
|
+
sirenKeys = expandFieldKey((_f = cfg.personSirenField) !== null && _f !== void 0 ? _f : '').filter(Boolean);
|
|
281
|
+
submittedSiren = (_g = resolveFieldValue(personNodeInput, flat, sirenKeys)) !== null && _g !== void 0 ? _g : '';
|
|
250
282
|
if (submittedSiren) {
|
|
251
283
|
comparisonConfig = {
|
|
252
284
|
personType: 'MORALE',
|
|
@@ -259,46 +291,46 @@ var ExternalVerificationNodeHandler = function (_a) {
|
|
|
259
291
|
}
|
|
260
292
|
}
|
|
261
293
|
else {
|
|
262
|
-
firstNameKeys = expandFieldKey((
|
|
263
|
-
lastNameKeys = expandFieldKey((
|
|
294
|
+
firstNameKeys = expandFieldKey((_h = cfg.personFirstNameField) !== null && _h !== void 0 ? _h : '').filter(Boolean);
|
|
295
|
+
lastNameKeys = expandFieldKey((_j = cfg.personLastNameField) !== null && _j !== void 0 ? _j : '').filter(Boolean);
|
|
264
296
|
birthDateKeys = cfg.personBirthDateField
|
|
265
297
|
? expandFieldKey(cfg.personBirthDateField).filter(Boolean)
|
|
266
298
|
: [];
|
|
267
|
-
submittedFirstName = (
|
|
268
|
-
submittedLastName = (
|
|
299
|
+
submittedFirstName = (_k = resolveFieldValue(personNodeInput, flat, firstNameKeys)) !== null && _k !== void 0 ? _k : '';
|
|
300
|
+
submittedLastName = (_l = resolveFieldValue(personNodeInput, flat, lastNameKeys)) !== null && _l !== void 0 ? _l : '';
|
|
269
301
|
dateOfBirth = cfg.compareBirthDate && birthDateKeys.length
|
|
270
302
|
? resolveFieldValue(personNodeInput, flat, birthDateKeys)
|
|
271
303
|
: undefined;
|
|
272
304
|
if (submittedFirstName && submittedLastName) {
|
|
273
|
-
comparisonConfig = tslib_es6.__assign({ firstName: submittedFirstName, lastName: submittedLastName, compareTargets: (
|
|
305
|
+
comparisonConfig = tslib_es6.__assign({ firstName: submittedFirstName, lastName: submittedLastName, compareTargets: (_m = cfg.compareTargets) !== null && _m !== void 0 ? _m : ['mandataires'] }, (dateOfBirth ? { dateOfBirth: dateOfBirth } : {}));
|
|
274
306
|
}
|
|
275
307
|
}
|
|
276
308
|
}
|
|
277
309
|
if (isInpiRbe)
|
|
278
310
|
advanceStep(1);
|
|
279
|
-
|
|
311
|
+
_w.label = 4;
|
|
280
312
|
case 4:
|
|
281
|
-
|
|
282
|
-
return [4 /*yield*/, api.apiService.post("/session/sdk/".concat(session.id, "/verify-external/").concat(node.id), tslib_es6.__assign({ apiType: apiType, referenceValue: referenceValue, referenceField: referenceField, enableRnaFallback: isInpiRbe && nodeData.rnaFallbackEnabled === true }, (comparisonConfig ? { comparisonConfig: comparisonConfig } : {})), { signal: abortController.signal })];
|
|
313
|
+
_w.trys.push([4, 7, , 8]);
|
|
314
|
+
return [4 /*yield*/, api.apiService.post("/session/sdk/".concat(session.id, "/verify-external/").concat(node.id), tslib_es6.__assign({ apiType: apiType, referenceValue: referenceValue, referenceField: referenceField, enableRnaFallback: isInpiRbe && nodeData.rnaFallbackEnabled === true, enableInseeFallback: isInpiRbe && nodeData.enableInseeFallback === true }, (comparisonConfig ? { comparisonConfig: comparisonConfig } : {})), { signal: abortController.signal })];
|
|
283
315
|
case 5:
|
|
284
|
-
response =
|
|
316
|
+
response = _w.sent();
|
|
285
317
|
if (isInpiRbe)
|
|
286
318
|
advanceStep(2);
|
|
287
319
|
return [4 /*yield*/, new Promise(function (r) { return setTimeout(r, 600); })];
|
|
288
320
|
case 6:
|
|
289
|
-
|
|
290
|
-
res = (
|
|
321
|
+
_w.sent();
|
|
322
|
+
res = (_o = response.data) === null || _o === void 0 ? void 0 : _o.data;
|
|
291
323
|
if (res && typeof res.isVerified === 'boolean') {
|
|
292
324
|
result = res;
|
|
293
325
|
}
|
|
294
326
|
return [3 /*break*/, 8];
|
|
295
327
|
case 7:
|
|
296
|
-
apiErr_1 =
|
|
328
|
+
apiErr_1 = _w.sent();
|
|
297
329
|
if (abortController.signal.aborted)
|
|
298
330
|
return [2 /*return*/];
|
|
299
331
|
if (isInpiRbe)
|
|
300
332
|
advanceStep(2);
|
|
301
|
-
apiResult = (
|
|
333
|
+
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;
|
|
302
334
|
if (apiResult && typeof apiResult.isVerified === 'boolean') {
|
|
303
335
|
result = apiResult;
|
|
304
336
|
}
|
|
@@ -313,7 +345,7 @@ var ExternalVerificationNodeHandler = function (_a) {
|
|
|
313
345
|
return [3 /*break*/, 8];
|
|
314
346
|
case 8: return [3 /*break*/, 10];
|
|
315
347
|
case 9:
|
|
316
|
-
|
|
348
|
+
_w.sent();
|
|
317
349
|
result = {
|
|
318
350
|
isVerified: false,
|
|
319
351
|
status: 'external_error',
|
|
@@ -351,13 +383,13 @@ var ExternalVerificationNodeHandler = function (_a) {
|
|
|
351
383
|
// En mode personne morale, seuls les mandataires personne morale ont
|
|
352
384
|
// un sens (un RBE est toujours une personne physique) ; en mode
|
|
353
385
|
// physique, comportement inchangé (mandataires individus uniquement).
|
|
354
|
-
mandataires: ((
|
|
386
|
+
mandataires: ((_r = inpi === null || inpi === void 0 ? void 0 : inpi.mandataires) !== null && _r !== void 0 ? _r : []).filter(function (m) {
|
|
355
387
|
return isPersonneMorale_1 ? m.type === 'personne_morale' : m.type === 'individu';
|
|
356
388
|
}),
|
|
357
|
-
beneficiairesEffectifs: (
|
|
358
|
-
compareTargets: isPersonneMorale_1 ? ['mandataires'] : ((
|
|
359
|
-
personNodeId: (
|
|
360
|
-
targetDenomination: (
|
|
389
|
+
beneficiairesEffectifs: (_s = inpi === null || inpi === void 0 ? void 0 : inpi.beneficiairesEffectifs) !== null && _s !== void 0 ? _s : [],
|
|
390
|
+
compareTargets: isPersonneMorale_1 ? ['mandataires'] : ((_t = cfg === null || cfg === void 0 ? void 0 : cfg.compareTargets) !== null && _t !== void 0 ? _t : ['mandataires']),
|
|
391
|
+
personNodeId: (_u = cfg === null || cfg === void 0 ? void 0 : cfg.personReferenceNodeId) !== null && _u !== void 0 ? _u : '',
|
|
392
|
+
targetDenomination: (_v = inpi === null || inpi === void 0 ? void 0 : inpi.identite) === null || _v === void 0 ? void 0 : _v.denomination,
|
|
361
393
|
siren: resolvedReferenceValue,
|
|
362
394
|
sirenNodeId: referenceNodeId,
|
|
363
395
|
source: inpi === null || inpi === void 0 ? void 0 : inpi.source,
|
|
@@ -383,13 +415,16 @@ var ExternalVerificationNodeHandler = function (_a) {
|
|
|
383
415
|
setPhase('success');
|
|
384
416
|
setTimeout(onNext, 1200);
|
|
385
417
|
}
|
|
386
|
-
else if (result.status === 'config_error') {
|
|
387
|
-
setPhase('success');
|
|
388
|
-
setTimeout(onNext, 800);
|
|
389
|
-
}
|
|
390
418
|
else {
|
|
419
|
+
// config_error / external_error / any other non-blocking technical
|
|
420
|
+
// failure (missing API key, registry down…) — never a fault of the
|
|
421
|
+
// end user. The backend already maps these to a 'done' analysisrun,
|
|
422
|
+
// never 'ai_rejected' (reviewed manually in backoffice), so the SDK
|
|
423
|
+
// stays non-blocking here too — but must never claim success
|
|
424
|
+
// (config_error used to show the success screen) and must never
|
|
425
|
+
// leave a blank screen (this phase previously had no render block).
|
|
391
426
|
setPhase('error');
|
|
392
|
-
setTimeout(onNext,
|
|
427
|
+
setTimeout(onNext, 1200);
|
|
393
428
|
}
|
|
394
429
|
return [2 /*return*/];
|
|
395
430
|
}
|
|
@@ -413,12 +448,19 @@ var ExternalVerificationNodeHandler = function (_a) {
|
|
|
413
448
|
};
|
|
414
449
|
// ─── Loading phase ─────────────────────────────────────────────────────────
|
|
415
450
|
if (phase === 'loading') {
|
|
416
|
-
return (jsxRuntime.jsx("div", { className: "flex flex-col justify-between h-full w-full", children: jsxRuntime.jsx("div", { className: "flex-1 px-4 py-6 pt-11 md:px-8 md:py-8", children: jsxRuntime.jsxs("div", { className: "w-full max-w-md mx-auto space-y-6", children: [jsxRuntime.jsxs("div", { className: "text-center space-y-4", children: [jsxRuntime.jsx(Title.default, { className: "text-xl md:text-2xl lg:text-3xl", children: t('verification_node.verifying_title', 'Vérification en cours…') }), jsxRuntime.jsx(Subtitle.default, { className: "text-sm text-gray-600 leading-relaxed", children: t('verification_node.verifying_desc', 'Nous vérifions vos informations. Cela peut prendre quelques instants.') })] }), jsxRuntime.jsx("div", { className: "w-full flex justify-center", children: jsxRuntime.jsx("div", { className: "space-y-5", children: steps.map(function (step, index) { return (jsxRuntime.jsxs("div", { className: "flex items-start", children: [jsxRuntime.jsx("div", { className: "mr-4 mt-1
|
|
451
|
+
return (jsxRuntime.jsx("div", { className: "flex flex-col justify-between h-full w-full", children: jsxRuntime.jsx("div", { className: "flex-1 px-4 py-6 pt-11 md:px-8 md:py-8", children: jsxRuntime.jsxs("div", { className: "w-full max-w-md mx-auto space-y-6", children: [jsxRuntime.jsxs("div", { className: "text-center space-y-4", children: [jsxRuntime.jsx(Title.default, { className: "text-xl md:text-2xl lg:text-3xl", children: t('verification_node.verifying_title', 'Vérification en cours…') }), jsxRuntime.jsx(Subtitle.default, { className: "text-sm text-gray-600 leading-relaxed", children: t('verification_node.verifying_desc', 'Nous vérifions vos informations. Cela peut prendre quelques instants.') })] }), jsxRuntime.jsx("div", { className: "w-full flex justify-center", children: jsxRuntime.jsx("div", { className: "space-y-5", children: steps.map(function (step, index) { return (jsxRuntime.jsxs("div", { className: "flex items-start", children: [jsxRuntime.jsx("div", { className: "mr-4 mt-1 shrink-0", children: step.status === 'done' ? (jsxRuntime.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' ? (jsxRuntime.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" })) : (jsxRuntime.jsx("div", { className: "w-6 h-6 rounded-full border-2 border-gray-300" })) }), jsxRuntime.jsxs("div", { className: "flex-1 min-w-0", children: [jsxRuntime.jsx("p", { className: "font-medium text-[#3C3C40] text-sm", children: step.title }), jsxRuntime.jsx("p", { className: "text-xs text-gray-500 mt-1", children: step.subtitle })] })] }, index)); }) }) })] }) }) }));
|
|
417
452
|
}
|
|
418
453
|
// ─── Success phase ─────────────────────────────────────────────────────────
|
|
419
454
|
if (phase === 'success') {
|
|
420
455
|
return (jsxRuntime.jsxs("div", { className: "flex flex-col items-center justify-center h-full px-6 py-8 text-center space-y-4", children: [jsxRuntime.jsx("img", { src: check.default, alt: "success", className: "w-24 h-24" }), jsxRuntime.jsx("h3", { className: "text-[#3C3C40] font-poppins text-xl font-bold", children: t('inpi_verification.success_title', 'Vérification réussie') }), jsxRuntime.jsx("p", { className: "text-gray-500 text-sm", children: t('inpi_verification.success_desc', "Passage à l'étape suivante…") })] }));
|
|
421
456
|
}
|
|
457
|
+
// ─── Technical error phase (config_error / external_error) ────────────────
|
|
458
|
+
//
|
|
459
|
+
// Non-blocking (the flow already auto-advances via the useEffect above) but
|
|
460
|
+
// must never look like a success — neutral wording, no checkmark.
|
|
461
|
+
if (phase === 'error') {
|
|
462
|
+
return (jsxRuntime.jsxs("div", { className: "flex flex-col items-center justify-center h-full px-6 py-8 text-center space-y-4", children: [jsxRuntime.jsx("div", { className: "w-16 h-16 bg-gray-100 rounded-full flex items-center justify-center", children: jsxRuntime.jsx("span", { className: "text-gray-500 text-2xl font-bold", children: "!" }) }), jsxRuntime.jsx("h3", { className: "text-[#3C3C40] font-poppins text-xl font-bold", children: t('inpi_verification.technical_error_title', 'Vérification en cours de traitement') }), jsxRuntime.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.') })] }));
|
|
463
|
+
}
|
|
422
464
|
// ─── Mismatch phase ────────────────────────────────────────────────────────
|
|
423
465
|
if (phase === 'mismatch') {
|
|
424
466
|
var d = errorScreenData;
|