From 0970202c8777e2a9b89b23c09c50de43350478c2 Mon Sep 17 00:00:00 2001 From: Renaud Genevois Date: Thu, 27 Jun 2024 15:09:05 +0200 Subject: [PATCH 1/4] remote component with http get --- package.json | 1 + .../remote-component/remote-component.tsx | 21 ++- src/components/type.ts | 2 +- src/stories/RemoteComponent/data.json | 6 + src/stories/RemoteComponent/mock-server.js | 44 ++++-- .../remoteComponent.stories.jsx | 3 +- src/stories/RemoteComponent/source.json | 143 +++++++++++++----- .../fill-component-expressions.ts | 6 +- yarn.lock | 33 ++++ 9 files changed, 185 insertions(+), 74 deletions(-) create mode 100644 src/stories/RemoteComponent/data.json diff --git a/package.json b/package.json index 4dd1fc09c..827b1136f 100644 --- a/package.json +++ b/package.json @@ -146,6 +146,7 @@ "jest": "^29.4.3", "jsdom": "^21.1.0", "jsdom-global": "^3.0.2", + "path-match": "^1.2.4", "postcss": "^8.2.6", "postcss-scss": "^3.0.4", "prettier": "^2.0.5", diff --git a/src/components/remote-component/remote-component.tsx b/src/components/remote-component/remote-component.tsx index fb66da260..16b658839 100644 --- a/src/components/remote-component/remote-component.tsx +++ b/src/components/remote-component/remote-component.tsx @@ -12,20 +12,20 @@ const RETRY = 3; */ const fetchFromServer = ( remote: string, - values: unknown, + retry = RETRY, latency = LATENCY ): Promise> => { + return new Promise((resolve) => { fetch(remote, { - method: 'POST', + method: "GET", headers: { 'Content-Type': 'application/json', }, - body: JSON.stringify(values), }) .then((response) => { - if (response.ok) { + if (response.status === 200) { return response.json(); } else { resolve({ RESPONSE: false }); @@ -37,7 +37,7 @@ const fetchFromServer = ( .catch(() => { if (retry > 0) { window.setTimeout(() => { - resolve(fetchFromServer(remote, values, retry - 1)); + resolve(fetchFromServer(remote, retry - 1, latency)); }, latency); } else { resolve({ RESPONSE: false }); @@ -63,7 +63,7 @@ export function RemoteComponent( executeExpression, iteration, retry = RETRY, - latency = LATENCY, + latency = LATENCY, pendingMessage = "En attente..." } = props; const loading = useRef(false); @@ -72,7 +72,7 @@ export function RemoteComponent( useEffect(() => { if (remote && !loading.current && !fetched.current) { loading.current = true; - fetchFromServer(remote, value, retry, latency).then( + fetchFromServer(remote, retry, latency).then( (response: Record) => { fetched.current = true; if (response) { @@ -83,11 +83,8 @@ export function RemoteComponent( } ); } - }, [remote, value, handleChange, retry, latency]); + }, [remote, handleChange, retry, latency]); - /** - * // TODO Gérer les component Set - */ if (fetched.current) { if (components && components.length) { return components.map((c, i) => { @@ -106,5 +103,5 @@ export function RemoteComponent( return <>Nothing to display!; } - return
waiting
; + return <>{pendingMessage}; } diff --git a/src/components/type.ts b/src/components/type.ts index a52cb08e4..a1d57ee69 100644 --- a/src/components/type.ts +++ b/src/components/type.ts @@ -238,7 +238,7 @@ type ComponentPropsByType = { RemoteComponent: LunaticBaseProps & { components: LunaticComponentDefinition[]; remote: string; - responses?: Array<{ responses: { name: string } }>; + pendingMessage: ReactNode; value: Record; latency?: number; retry?: number; diff --git a/src/stories/RemoteComponent/data.json b/src/stories/RemoteComponent/data.json new file mode 100644 index 000000000..d408af23c --- /dev/null +++ b/src/stories/RemoteComponent/data.json @@ -0,0 +1,6 @@ +{ + "EXTERNAL": { + "DEP_CODE": "75", + "COM_CODE": "012" + } +} diff --git a/src/stories/RemoteComponent/mock-server.js b/src/stories/RemoteComponent/mock-server.js index 98a05e7ae..e20855af9 100644 --- a/src/stories/RemoteComponent/mock-server.js +++ b/src/stories/RemoteComponent/mock-server.js @@ -1,28 +1,40 @@ const express = require('express'); const cors = require('cors'); +const parse = require('url').parse; +const parser = require('path-match')({ + // path-to-regexp options + sensitive: false, + strict: false, + end: false, +}); const bodyParser = require('body-parser'); const app = express(); const port = 4000; +const router = express.Router(); +const match = parser('/api/recensement/adresse/departement/:DEP_CODE/commune/:COM_CODE') +router.use(function timeLog(req, res, next) { + console.log('Time: ', Date.now()); + next(); +}); + app.use(cors()); app.use(bodyParser.json()); +app.use('/', router); + + +router.get('/api/recensement/adresse/*', function (request, response) { + console.log(request.path) -app.post('/api/recensement/adresse', (request, response) => { - console.log('body', request.body); // on n'en fait rien, c juste un mock ! - const { ZC, ADR_RANG, LOG_RANG } = request.body; - if (ZC && ADR_RANG && LOG_RANG) { - response.status(201).json({ - NUMVOI_LOC: '14', - BISTER_LOC: null, - TYPEVOI_LOC: 'Rue', - NOMVOI_LOC: 'de Picpus', - CPOST_LOC: '75012', - LIBELLE_COMMUNE: 'Paris', - RESPONSE: true, - }); - } else { - response.status(201).json({ RESPONSE: false }); - } + var params = match(request.path); + console.log(request.originalUrl, params) + response.status(200).json({ + "NUMVOI_LOC_SUGG": "14", + "BISTER_LOC_SUGG": null, + "TYPEVOI_LOC_SUGG": "rue", + "NOMVOI_LOC_SUGG": "de Picpus", + RESPONSE: true + }); }); app.listen(port, () => { diff --git a/src/stories/RemoteComponent/remoteComponent.stories.jsx b/src/stories/RemoteComponent/remoteComponent.stories.jsx index 53b680d65..606b10353 100644 --- a/src/stories/RemoteComponent/remoteComponent.stories.jsx +++ b/src/stories/RemoteComponent/remoteComponent.stories.jsx @@ -1,5 +1,6 @@ import Orchestrator from '../utils/orchestrator'; import source from './source'; +import data from "./data" import defaultArgTypes from '../utils/default-arg-types'; const stories = { @@ -20,4 +21,4 @@ export default stories; const Template = (args) => ; export const Default = Template.bind({}); -Default.args = { id: 'radio', source, pagination: true }; +Default.args = { id: 'radio', source, data, pagination: true }; diff --git a/src/stories/RemoteComponent/source.json b/src/stories/RemoteComponent/source.json index f5cb21d6e..345ec5884 100644 --- a/src/stories/RemoteComponent/source.json +++ b/src/stories/RemoteComponent/source.json @@ -125,7 +125,7 @@ "conditionFilter": { "value": "true", "type": "VTL" }, "page": "2", "label": { - "value": "if RESPONSE = true then \"## Basé sur les rangs d'adresse que vous avez entré, nous avons identifié cette adresse pour votre logement : \" else \" Quelle est l'adresse de votre logement ? \"", + "value": "if (RESPONSE = true and IDENTIFICATION_OK) then \"## Vous résidez dans la commune de \" || LIBELLE_COMMUNE|| \". Basé sur les rangs d'adresse que vous avez saisis, nous avons identifié cette adresse pour votre logement : \" else \" Quelle est l'adresse de votre logement ? \"", "type": "VTL|MD" }, "description": { @@ -136,32 +136,33 @@ { "id": "remote", "componentType": "RemoteComponent", - "mandatory": false, "retry": 6, - "latency": 2000, - "remote": "http://localhost:4000/api/recensement/adresse", + "latency": 1000, + "remote": { + "value": "\"http://localhost:4000/api/recensement/adresse/departement/\" || DEP_CODE || \"/commune/\" || COM_CODE || \"/zc/\" || ZC || \"/rang-l/\" || LOG_RANG || \"/rang-a/\" || ADR_RANG", + "type": "VTL" + }, "conditionFilter": { - "value": "true", + "value": "not(nvl(ZC, \"\") = \"\") and not(nvl(LOG_RANG, \"\") = \"\") and not(nvl(ADR_RANG, \"\") = \"\")", "type": "VTL" }, + "pendingMessage": { + "value": "\"***Pour votre localisation dans la commune de\" || LIBELLE_COMMUNE || \", nous cherchons une adresse éventuelle, à vous suggérer.***\"", + "type": "VTL|MD" + }, "components": [ { "id": "Subsequence", "componentType": "Subsequence", "label": { "type": "VTL|MD", - "value": "\"## \" || VOI_CONCAT || COMMUNE_CONCAT \n\n" + "value": "\"## \" || VOI_CONCAT\n\n" }, "conditionFilter": { "value": "RESPONSE", "type": "VTL" } } - ], - "responses": [ - { "response": { "name": "ZC" } }, - { "response": { "name": "ADR_RANG" } }, - { "response": { "name": "LOG_RANG" } } ] }, { @@ -170,10 +171,13 @@ "mandatory": false, "page": "2", "label": { - "value": "\"### L'adresse de votre logement est-elle correcte ?\"", + "value": "\"### Cette adresse, pour votre logement, est-elle correcte ?\"", "type": "VTL|MD" }, - "conditionFilter": { "value": "true", "type": "VTL" }, + "conditionFilter": { + "value": "RESPONSE = true and IDENTIFICATION_OK = true", + "type": "VTL" + }, "options": [ { "value": "1", @@ -192,7 +196,7 @@ "label": { "value": "\"non\"", "type": "VTL|MD" } } ], - "response": { "name": "MODIFICATION_LOC" } + "response": { "name": "ADR_SUGG_OK" } }, { "id": "num-voi-loc", @@ -204,7 +208,7 @@ "description": { "value": "\"Exemple : 56\"", "type": "VTL" }, "maxLength": 80, "conditionFilter": { - "value": "if MODIFICATION_LOC = \"2\" then true else false", + "value": "ADR_SUGG_OK = \"2\" or RESPONSE = false or IDENTIFICATION_OK = false", "type": "VTL|MD" }, "response": { @@ -222,7 +226,7 @@ "maxLength": 80, "controls": [], "conditionFilter": { - "value": "MODIFICATION_LOC = \"2\" or RESPONSE = false", + "value": "ADR_SUGG_OK = \"2\" or RESPONSE = false or IDENTIFICATION_OK = false", "type": "VTL" }, "response": { @@ -240,7 +244,7 @@ "maxLength": 80, "controls": [], "conditionFilter": { - "value": "MODIFICATION_LOC = \"2\" or RESPONSE = false", + "value": "ADR_SUGG_OK = \"2\" or RESPONSE = false or IDENTIFICATION_OK = false", "type": "VTL" }, "response": { @@ -261,7 +265,7 @@ "maxLength": 80, "controls": [], "conditionFilter": { - "value": "MODIFICATION_LOC = \"2\" or RESPONSE = false", + "value": "ADR_SUGG_OK = \"2\" or RESPONSE = false or IDENTIFICATION_OK = false", "type": "VTL" }, "response": { @@ -279,7 +283,7 @@ "maxLength": 80, "controls": [], "conditionFilter": { - "value": "MODIFICATION_LOC = \"2\" or RESPONSE = false", + "value": "ADR_SUGG_OK = \"2\" or RESPONSE = false or IDENTIFICATION_OK = false", "type": "VTL" }, "response": { @@ -301,7 +305,7 @@ "maxLength": 80, "controls": [], "conditionFilter": { - "value": "MODIFICATION_LOC = \"2\" or RESPONSE = false", + "value": "ADR_SUGG_OK = \"2\" or RESPONSE = false or IDENTIFICATION_OK = false", "type": "VTL" }, "response": { @@ -312,7 +316,7 @@ "id": "component-set-complements-adresse", "componentType": "ComponentSet", "conditionFilter": { - "value": "MODIFICATION_LOC = \"1\" or MODIFICATION_LOC = \"2\"", + "value": "(ADR_SUGG_OK = \"1\" or ADR_SUGG_OK = \"2\") or RESPONSE = false or IDENTIFICATION_OK = false", "type": "VTL" }, "page": "2", @@ -375,7 +379,7 @@ "type": "VTL" }, "description": { - "value": "Exemple : A", + "value": "\"Exemple : A\"", "type": "VTL" }, "maxLength": 80, @@ -451,12 +455,23 @@ } ], "variables": [ + { "variableType": "EXTERNAL", "name": "DEP_CODE", "value": null }, + { "variableType": "EXTERNAL", "name": "COM_CODE", "value": null }, + { "variableType": "EXTERNAL", "name": "LIBELLE_COMMUNE", "value": null }, + + { "variableType": "EXTERNAL", "name": "NUMVOI_LOC_SUGG", "value": null }, + { "variableType": "EXTERNAL", "name": "BISTER_LOC_SUGG", "value": null }, + { "variableType": "EXTERNAL", "name": "TYPEVOI_LOC_SUGG", "value": null }, + { "variableType": "EXTERNAL", "name": "NOMVOI_LOC_SUGG", "value": null }, + + { "variableType": "EXTERNAL", "name": "RESPONSE", "value": null }, + { "variableType": "COLLECTED", "name": "ADR_RANG", "values": { "PREVIOUS": null, - "COLLECTED": null, + "COLLECTED": "AAA", "FORCED": null, "EDITED": null, "INPUTTED": null @@ -467,7 +482,7 @@ "name": "LOG_RANG", "values": { "PREVIOUS": null, - "COLLECTED": null, + "COLLECTED": "AAA", "FORCED": null, "EDITED": null, "INPUTTED": null @@ -478,7 +493,7 @@ "name": "ZC", "values": { "PREVIOUS": null, - "COLLECTED": null, + "COLLECTED": "AAAA", "FORCED": null, "EDITED": null, "INPUTTED": null @@ -495,6 +510,17 @@ "INPUTTED": null } }, + { + "variableType": "COLLECTED", + "name": "NUMVOI_LOC_SUGG", + "values": { + "PREVIOUS": null, + "COLLECTED": null, + "FORCED": null, + "EDITED": null, + "INPUTTED": null + } + }, { "variableType": "COLLECTED", "name": "BISTER_LOC", @@ -506,6 +532,17 @@ "INPUTTED": null } }, + { + "variableType": "COLLECTED", + "name": "BISTER_LOC_SUGG", + "values": { + "PREVIOUS": null, + "COLLECTED": null, + "FORCED": null, + "EDITED": null, + "INPUTTED": null + } + }, { "variableType": "COLLECTED", "name": "TYPEVOI_LOC", @@ -519,7 +556,7 @@ }, { "variableType": "COLLECTED", - "name": "NOMVOI_LOC", + "name": "TYPEVOI_LOC_SUGG", "values": { "PREVIOUS": null, "COLLECTED": null, @@ -530,7 +567,7 @@ }, { "variableType": "COLLECTED", - "name": "RES_LOC", + "name": "NOMVOI_LOC", "values": { "PREVIOUS": null, "COLLECTED": null, @@ -541,7 +578,7 @@ }, { "variableType": "COLLECTED", - "name": "BAT_LOC", + "name": "NOMVOI_LOC_SUGG", "values": { "PREVIOUS": null, "COLLECTED": null, @@ -564,6 +601,17 @@ { "variableType": "COLLECTED", "name": "LIBELLE_COMMUNE", + "values": { + "PREVIOUS": null, + "COLLECTED": "Paris(12)", + "FORCED": null, + "EDITED": null, + "INPUTTED": null + } + }, + { + "variableType": "COLLECTED", + "name": "LIBELLE_COMMUNE_SUGG", "values": { "PREVIOUS": null, "COLLECTED": null, @@ -574,7 +622,7 @@ }, { "variableType": "COLLECTED", - "name": "ESC_LOC", + "name": "RES_LOC", "values": { "PREVIOUS": null, "COLLECTED": null, @@ -585,7 +633,7 @@ }, { "variableType": "COLLECTED", - "name": "ETAGE_LOC", + "name": "BAT_LOC", "values": { "PREVIOUS": null, "COLLECTED": null, @@ -596,7 +644,7 @@ }, { "variableType": "COLLECTED", - "name": "N_PORTE_LOC", + "name": "ESC_LOC", "values": { "PREVIOUS": null, "COLLECTED": null, @@ -607,10 +655,21 @@ }, { "variableType": "COLLECTED", - "name": "RESPONSE", + "name": "ETAGE_LOC", "values": { "PREVIOUS": null, - "COLLECTED": false, + "COLLECTED": null, + "FORCED": null, + "EDITED": null, + "INPUTTED": null + } + }, + { + "variableType": "COLLECTED", + "name": "N_PORTE_LOC", + "values": { + "PREVIOUS": null, + "COLLECTED": null, "FORCED": null, "EDITED": null, "INPUTTED": null @@ -618,7 +677,7 @@ }, { "variableType": "COLLECTED", - "name": "MODIFICATION_LOC", + "name": "ADR_SUGG_OK", "values": { "PREVIOUS": null, "COLLECTED": null, @@ -642,25 +701,25 @@ "variableType": "CALCULATED", "name": "VOI_CONCAT", "expression": { - "value": "(if (isnull(NUMVOI_LOC)) then \"\" else (NUMVOI_LOC || \" \")) || (if (isnull(BISTER_LOC)) then \"\" else (BISTER_LOC || \" \")) || (if (isnull(TYPEVOI_LOC)) then \"\" else (TYPEVOI_LOC || \" \")) || (if (isnull(NOMVOI_LOC)) then \"\" else (NOMVOI_LOC || \" \"))", + "value": "(if (isnull(NUMVOI_LOC_SUGG)) then \"\" else (NUMVOI_LOC_SUGG || \" \")) || (if (isnull(BISTER_LOC_SUGG)) then \"\" else (BISTER_LOC_SUGG || \" \")) || (if (isnull(TYPEVOI_LOC_SUGG)) then \"\" else (TYPEVOI_LOC_SUGG || \" \")) || (if (isnull(NOMVOI_LOC_SUGG)) then \"\" else (NOMVOI_LOC_SUGG || \" \"))", "type": "VTL" }, "bindingDependencies": [ - "NUMVOI_LOC", - "BISTER_LOC", - "TYPEVOI_LOC", - "NOMVOI_LOC" + "NUMVOI_LOC_SUGG", + "BISTER_LOC_SUGG", + "TYPEVOI_LOC_SUGG", + "NOMVOI_LOC_SUGG" ], "inFilter": "false" }, { "variableType": "CALCULATED", - "name": "COMMUNE_CONCAT", + "name": "IDENTIFICATION_OK", "expression": { - "value": "(if (isnull(CPOST_LOC)) then \"\" else (CPOST_LOC || \" \")) || (if (isnull(LIBELLE_COMMUNE)) then \"\" else (LIBELLE_COMMUNE || \" \")) ", + "value": "not(nvl(ZC, \"\") = \"\") and not(nvl(LOG_RANG, \"\") = \"\") and not(nvl(ADR_RANG, \"\") = \"\")", "type": "VTL" }, - "bindingDependencies": ["CPOST_LOC", "LIBELLE_COMMUNE"], + "bindingDependencies": ["ZC", "LOG_RANG", "ADR_RANG"], "inFilter": "false" } ] diff --git a/src/use-lunatic/commons/fill-components/fill-component-expressions.ts b/src/use-lunatic/commons/fill-components/fill-component-expressions.ts index f789796da..333afa84e 100644 --- a/src/use-lunatic/commons/fill-components/fill-component-expressions.ts +++ b/src/use-lunatic/commons/fill-components/fill-component-expressions.ts @@ -20,6 +20,8 @@ const VTL_ATTRIBUTES = [ // Disable controls compilation // 'controls.control', // 'controls.errorMessage', + 'remote', + 'pendingMessage', 'controls.iterations', 'lines.min', 'lines.max', @@ -41,8 +43,8 @@ export type DeepTranslateExpression = T extends LunaticExpression ? ReactNode : T extends { [k: string | number]: unknown } ? { - [key in keyof T]: DeepTranslateExpression; - } + [key in keyof T]: DeepTranslateExpression; + } : T; function createCrawl({ diff --git a/yarn.lock b/yarn.lock index 5dc008457..d840b3c60 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8884,6 +8884,14 @@ http-errors@2.0.0: statuses "2.0.1" toidentifier "1.0.1" +http-errors@~1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.4.0.tgz#6c0242dea6b3df7afda153c71089b31c6e82aabf" + integrity sha512-oLjPqve1tuOl5aRhv8GK5eHpqP1C9fb+Ol+XTLjKfLltE44zdDbEdjPSbU7Ch5rSNsVFqZn97SrMmZLdu1/YMw== + dependencies: + inherits "2.0.1" + statuses ">= 1.2.1 < 2" + http-proxy-agent@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/http-proxy-agent/-/http-proxy-agent-5.0.0.tgz#5129800203520d434f142bc78ff3c170800f2b43" @@ -9048,6 +9056,11 @@ inherits@2, inherits@2.0.4, inherits@^2.0.0, inherits@^2.0.1, inherits@^2.0.3, i resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== +inherits@2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.1.tgz#b17d08d326b4423e568eff719f91b0b1cbdf69f1" + integrity sha512-8nWq2nLTAwd02jTqJExUYFSD/fKq6VH9Y/oG2accc/kdI0V98Bag8d5a4gi3XHz73rDWa2PvTtvcWYquKqSENA== + inherits@2.0.3: version "2.0.3" resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" @@ -12289,6 +12302,14 @@ path-key@^3.0.0, path-key@^3.1.0: resolved "https://registry.yarnpkg.com/path-key/-/path-key-3.1.1.tgz#581f6ade658cbba65a0d3380de7753295054f375" integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q== +path-match@^1.2.4: + version "1.2.4" + resolved "https://registry.yarnpkg.com/path-match/-/path-match-1.2.4.tgz#a62747f3c7e0c2514762697f24443585b09100ea" + integrity sha512-UWlehEdqu36jmh4h5CWJ7tARp1OEVKGHKm6+dg9qMq5RKUTV5WJrGgaZ3dN2m7WFAXDbjlHzvJvL/IUpy84Ktw== + dependencies: + http-errors "~1.4.0" + path-to-regexp "^1.0.0" + path-parse@^1.0.7: version "1.0.7" resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735" @@ -12299,6 +12320,13 @@ path-to-regexp@0.1.7: resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-0.1.7.tgz#df604178005f522f15eb4490e7247a1bfaa67f8c" integrity sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ== +path-to-regexp@^1.0.0: + version "1.8.0" + resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-1.8.0.tgz#887b3ba9d84393e87a0a0b9f4cb756198b53548a" + integrity sha512-n43JRhlUKUAlibEJhPeir1ncUID16QnEjNpwzNdO3Lm4ywrBpBZ5oLD0I6br9evr1Y9JTqwRtAh7JLoOzAQdVA== + dependencies: + isarray "0.0.1" + path-type@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/path-type/-/path-type-1.1.0.tgz#59c44f7ee491da704da415da5a4070ba4f8fe441" @@ -14173,6 +14201,11 @@ statuses@2.0.1: resolved "https://registry.yarnpkg.com/statuses/-/statuses-2.0.1.tgz#55cb000ccf1d48728bd23c685a063998cf1a1b63" integrity sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ== +"statuses@>= 1.2.1 < 2": + version "1.5.0" + resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c" + integrity sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA== + std-env@^3.3.1: version "3.7.0" resolved "https://registry.yarnpkg.com/std-env/-/std-env-3.7.0.tgz#c9f7386ced6ecf13360b6c6c55b8aaa4ef7481d2" From 2f62fe7a75651ef7ea7fd891ab4a24b8dafd996c Mon Sep 17 00:00:00 2001 From: Renaud Genevois Date: Thu, 27 Jun 2024 16:08:27 +0200 Subject: [PATCH 2/4] remove warn in mock-server for RemoteComponent --- src/stories/RemoteComponent/mock-server.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/stories/RemoteComponent/mock-server.js b/src/stories/RemoteComponent/mock-server.js index e20855af9..35090d862 100644 --- a/src/stories/RemoteComponent/mock-server.js +++ b/src/stories/RemoteComponent/mock-server.js @@ -1,6 +1,5 @@ const express = require('express'); const cors = require('cors'); -const parse = require('url').parse; const parser = require('path-match')({ // path-to-regexp options sensitive: false, From 3e53e65e2cde4dad94117461679aa115200f0e95 Mon Sep 17 00:00:00 2001 From: Renaud Genevois Date: Thu, 27 Jun 2024 16:19:11 +0200 Subject: [PATCH 3/4] format with prettier --- src/components/remote-component/remote-component.tsx | 6 +++--- .../commons/fill-components/fill-component-expressions.ts | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/remote-component/remote-component.tsx b/src/components/remote-component/remote-component.tsx index 16b658839..59c7722eb 100644 --- a/src/components/remote-component/remote-component.tsx +++ b/src/components/remote-component/remote-component.tsx @@ -16,10 +16,9 @@ const fetchFromServer = ( retry = RETRY, latency = LATENCY ): Promise> => { - return new Promise((resolve) => { fetch(remote, { - method: "GET", + method: 'GET', headers: { 'Content-Type': 'application/json', }, @@ -63,7 +62,8 @@ export function RemoteComponent( executeExpression, iteration, retry = RETRY, - latency = LATENCY, pendingMessage = "En attente..." + latency = LATENCY, + pendingMessage = 'En attente...', } = props; const loading = useRef(false); diff --git a/src/use-lunatic/commons/fill-components/fill-component-expressions.ts b/src/use-lunatic/commons/fill-components/fill-component-expressions.ts index 333afa84e..eb3b959de 100644 --- a/src/use-lunatic/commons/fill-components/fill-component-expressions.ts +++ b/src/use-lunatic/commons/fill-components/fill-component-expressions.ts @@ -43,8 +43,8 @@ export type DeepTranslateExpression = T extends LunaticExpression ? ReactNode : T extends { [k: string | number]: unknown } ? { - [key in keyof T]: DeepTranslateExpression; - } + [key in keyof T]: DeepTranslateExpression; + } : T; function createCrawl({ From 015c7d45c11c1bc6e0d86eeccabc83e62a025ddf Mon Sep 17 00:00:00 2001 From: Laurent Caouissin <38245508+laurentC35@users.noreply.github.com> Date: Mon, 1 Jul 2024 15:08:09 +0200 Subject: [PATCH 4/4] bump: version to "2.6.12" --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 827b1136f..2d0b6c043 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@inseefr/lunatic", - "version": "2.6.11", + "version": "2.6.12", "workersVersion": "0.3.0-experimental", "description": "Library of questionnaire components", "repository": {