diff --git a/.gitignore b/.gitignore index 95d5c9e19..3b7c92072 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .tags* .tmp +/tmp .DS_Store yarn-error.log package-lock.json diff --git a/modele-social/.yarnrc b/modele-social/.yarnrc new file mode 100644 index 000000000..5770a9574 --- /dev/null +++ b/modele-social/.yarnrc @@ -0,0 +1,2 @@ +version-tag-prefix modele-social-v +version-git-message "⬆ Mise à jour du paquet \"modele-social\" vers %s" diff --git a/systeme-social/CHANGELOG.md b/modele-social/CHANGELOG.md similarity index 100% rename from systeme-social/CHANGELOG.md rename to modele-social/CHANGELOG.md diff --git a/systeme-social/README.md b/modele-social/README.md similarity index 87% rename from systeme-social/README.md rename to modele-social/README.md index 8663f4850..e40933de5 100644 --- a/systeme-social/README.md +++ b/modele-social/README.md @@ -1,4 +1,4 @@ -# Système social français en publicodes +# Modèle social français en publicodes Ce paquet contient les règles publicodes utilisées sur https://mon-entreprise.fr pour le calcul des cotisations sociales, des impôts et des droits sociaux. diff --git a/systeme-social/build.js b/modele-social/build.js similarity index 100% rename from systeme-social/build.js rename to modele-social/build.js diff --git a/modele-social/index.d.ts b/modele-social/index.d.ts new file mode 100644 index 000000000..8cb6cf61e --- /dev/null +++ b/modele-social/index.d.ts @@ -0,0 +1,9 @@ +// Currenty we systematically bundle all the rules even if we only need a +// sub-section of them. We might support "code-splitting" the rules in the +// future. +import { Rule } from 'publicodes' +import { Names } from './dist/names' + +export type DottedName = Names +declare let rules: Record +export default rules diff --git a/systeme-social/package.json b/modele-social/package.json similarity index 93% rename from systeme-social/package.json rename to modele-social/package.json index 121a54a43..5db9ab994 100644 --- a/systeme-social/package.json +++ b/modele-social/package.json @@ -1,5 +1,5 @@ { - "name": "systeme-social", + "name": "modele-social", "version": "0.1.0", "description": "Les règles publicodes du système social français", "main": "./dist/index.js", @@ -7,7 +7,7 @@ "repository": { "type": "git", "url": "https://github.com/betagouv/mon-entreprise.git", - "directory": "systeme-social" + "directory": "modele-social" }, "bugs": "https://github.com/betagouv/mon-entreprise/issues?q=is%3Aopen+is%3Aissue+label%3A%22%F0%9F%93%95+l%C3%A9gislation%22", "homepage": "https://mon-entreprise.fr/int%C3%A9gration/biblioth%C3%A8que-de-calcul", diff --git a/systeme-social/règles/artiste-auteur.yaml b/modele-social/règles/artiste-auteur.yaml similarity index 100% rename from systeme-social/règles/artiste-auteur.yaml rename to modele-social/règles/artiste-auteur.yaml diff --git a/systeme-social/règles/base.yaml b/modele-social/règles/base.yaml similarity index 100% rename from systeme-social/règles/base.yaml rename to modele-social/règles/base.yaml diff --git a/systeme-social/règles/chômage-partiel.yaml b/modele-social/règles/chômage-partiel.yaml similarity index 100% rename from systeme-social/règles/chômage-partiel.yaml rename to modele-social/règles/chômage-partiel.yaml diff --git a/systeme-social/règles/conventions-collectives/bâtiment.yaml b/modele-social/règles/conventions-collectives/bâtiment.yaml similarity index 100% rename from systeme-social/règles/conventions-collectives/bâtiment.yaml rename to modele-social/règles/conventions-collectives/bâtiment.yaml diff --git a/systeme-social/règles/conventions-collectives/experts-comptables.yaml b/modele-social/règles/conventions-collectives/experts-comptables.yaml similarity index 100% rename from systeme-social/règles/conventions-collectives/experts-comptables.yaml rename to modele-social/règles/conventions-collectives/experts-comptables.yaml diff --git a/systeme-social/règles/conventions-collectives/hôtels-cafés-restaurants.yaml b/modele-social/règles/conventions-collectives/hôtels-cafés-restaurants.yaml similarity index 100% rename from systeme-social/règles/conventions-collectives/hôtels-cafés-restaurants.yaml rename to modele-social/règles/conventions-collectives/hôtels-cafés-restaurants.yaml diff --git a/systeme-social/règles/conventions-collectives/optique.yaml b/modele-social/règles/conventions-collectives/optique.yaml similarity index 100% rename from systeme-social/règles/conventions-collectives/optique.yaml rename to modele-social/règles/conventions-collectives/optique.yaml diff --git a/systeme-social/règles/conventions-collectives/spectacle-vivant.yaml b/modele-social/règles/conventions-collectives/spectacle-vivant.yaml similarity index 100% rename from systeme-social/règles/conventions-collectives/spectacle-vivant.yaml rename to modele-social/règles/conventions-collectives/spectacle-vivant.yaml diff --git a/systeme-social/règles/conventions-collectives/sport.yaml b/modele-social/règles/conventions-collectives/sport.yaml similarity index 100% rename from systeme-social/règles/conventions-collectives/sport.yaml rename to modele-social/règles/conventions-collectives/sport.yaml diff --git a/systeme-social/règles/dirigeant.yaml b/modele-social/règles/dirigeant.yaml similarity index 100% rename from systeme-social/règles/dirigeant.yaml rename to modele-social/règles/dirigeant.yaml diff --git a/systeme-social/règles/déclaration-revenu-indépendant.yaml b/modele-social/règles/déclaration-revenu-indépendant.yaml similarity index 100% rename from systeme-social/règles/déclaration-revenu-indépendant.yaml rename to modele-social/règles/déclaration-revenu-indépendant.yaml diff --git a/systeme-social/règles/entreprise-établissement.yaml b/modele-social/règles/entreprise-établissement.yaml similarity index 100% rename from systeme-social/règles/entreprise-établissement.yaml rename to modele-social/règles/entreprise-établissement.yaml diff --git a/systeme-social/règles/aaa-impôt.yaml b/modele-social/règles/impôt.yaml similarity index 100% rename from systeme-social/règles/aaa-impôt.yaml rename to modele-social/règles/impôt.yaml diff --git a/systeme-social/règles/profession-libérale.yaml b/modele-social/règles/profession-libérale.yaml similarity index 100% rename from systeme-social/règles/profession-libérale.yaml rename to modele-social/règles/profession-libérale.yaml diff --git a/systeme-social/règles/protection-sociale.yaml b/modele-social/règles/protection-sociale.yaml similarity index 100% rename from systeme-social/règles/protection-sociale.yaml rename to modele-social/règles/protection-sociale.yaml diff --git a/systeme-social/règles/salarié.yaml b/modele-social/règles/salarié.yaml similarity index 100% rename from systeme-social/règles/salarié.yaml rename to modele-social/règles/salarié.yaml diff --git a/systeme-social/règles/situation-personnelle.yaml b/modele-social/règles/situation-personnelle.yaml similarity index 100% rename from systeme-social/règles/situation-personnelle.yaml rename to modele-social/règles/situation-personnelle.yaml diff --git a/mon-entreprise/package.json b/mon-entreprise/package.json index a1c05c565..a64f68915 100644 --- a/mon-entreprise/package.json +++ b/mon-entreprise/package.json @@ -99,7 +99,7 @@ "reselect": "^4.0.0", "styled-components": "^5.1.0", "swr": "^0.1.16", - "systeme-social": "^0.1.0", + "modele-social": "^0.1.0", "whatwg-fetch": "^3.0.0", "yaml": "^1.9.2" }, diff --git a/mon-entreprise/scripts/i18n/utils.js b/mon-entreprise/scripts/i18n/utils.js index c1bc1886d..ee3aea7ca 100644 --- a/mon-entreprise/scripts/i18n/utils.js +++ b/mon-entreprise/scripts/i18n/utils.js @@ -4,7 +4,7 @@ var fs = require('fs') var path = require('path') let R = require('ramda') var querystring = require('querystring') -let rules = require('systeme-social') +let rules = require('modele-social') let { parse } = require('yaml') let rulesTranslationPath = path.resolve('source/locales/rules-en.yaml') @@ -16,7 +16,7 @@ let attributesToTranslate = [ 'question', 'résumé', 'suggestions', - 'note' + 'note', ] function getRulesMissingTranslations() { @@ -30,7 +30,7 @@ function getRulesMissingTranslations() { dottedName, !rule || !rule.titre // && utils.ruleWithDedicatedDocumentationPage(rule)) ? { ...rule, titre: dottedName.split(' . ').slice(-1)[0] } - : rule + : rule, ]) .map(([dottedName, rule]) => ({ [dottedName]: R.mergeAll( @@ -56,13 +56,13 @@ function getRulesMissingTranslations() { return { ...acc, [frTrad]: currentTranslation[frTrad], - [enTrad]: currentTranslation[enTrad] + [enTrad]: currentTranslation[enTrad], } } missingTranslations.push([dottedName, enTrad, suggestion]) return { ...acc, - [frTrad]: suggestion + [frTrad]: suggestion, } }, {}) } @@ -76,15 +76,15 @@ function getRulesMissingTranslations() { ) return { [enTrad]: currentTranslation[enTrad], - [frTrad]: v + [frTrad]: v, } missingTranslations.push([dottedName, enTrad, v]) return { - [frTrad]: v + [frTrad]: v, } }) - ) + ), })) resolved = R.mergeAll(resolved) return [missingTranslations, resolved] @@ -96,7 +96,7 @@ const getUiMissingTranslations = () => { )) const translatedKeys = parse(fs.readFileSync(UiTranslationPath, 'utf-8')) - const missingTranslations = Object.keys(staticKeys).filter(key => { + const missingTranslations = Object.keys(staticKeys).filter((key) => { if (key.match(/^\{.*\}$/)) { return false } @@ -106,7 +106,7 @@ const getUiMissingTranslations = () => { return R.pick(missingTranslations, staticKeys) } -const fetchTranslation = async text => { +const fetchTranslation = async (text) => { console.log(`Fetch translation for:\n\t${text}`) const response = await fetch( `https://api.deepl.com/v2/translate?${querystring.stringify({ @@ -114,7 +114,7 @@ const fetchTranslation = async text => { auth_key: process.env.DEEPL_API_SECRET, tag_handling: 'xml', source_lang: 'FR', - target_lang: 'EN' + target_lang: 'EN', })}` ) const { translations } = await response.json() @@ -125,5 +125,5 @@ module.exports = { getRulesMissingTranslations, getUiMissingTranslations, rulesTranslationPath, - UiTranslationPath + UiTranslationPath, } diff --git a/mon-entreprise/source/actions/actions.ts b/mon-entreprise/source/actions/actions.ts index f291a3b1e..11c49d9ab 100644 --- a/mon-entreprise/source/actions/actions.ts +++ b/mon-entreprise/source/actions/actions.ts @@ -2,7 +2,7 @@ import { SitePaths } from 'Components/utils/SitePathsContext' import { History } from 'history' import { RootState, SimulationConfig } from 'Reducers/rootReducer' import { ThunkAction } from 'redux-thunk' -import { DottedName } from 'systeme-social' +import { DottedName } from 'modele-social' import { deletePersistedSimulation } from '../storage/persistSimulation' import { CompanyStatusAction } from './companyStatusActions' diff --git a/mon-entreprise/source/components/Distribution.tsx b/mon-entreprise/source/components/Distribution.tsx index 93637452b..c845007c5 100644 --- a/mon-entreprise/source/components/Distribution.tsx +++ b/mon-entreprise/source/components/Distribution.tsx @@ -2,7 +2,7 @@ import { EngineContext, useEngine } from 'Components/utils/EngineContext' import { max } from 'ramda' import { useContext } from 'react' import { useSelector } from 'react-redux' -import { DottedName } from 'systeme-social' +import { DottedName } from 'modele-social' import { targetUnitSelector } from 'Selectors/simulationSelectors' import BarChartBranch from './BarChart' import './Distribution.css' diff --git a/mon-entreprise/source/components/EngineValue.tsx b/mon-entreprise/source/components/EngineValue.tsx index 7abcae83f..6fd6223a6 100644 --- a/mon-entreprise/source/components/EngineValue.tsx +++ b/mon-entreprise/source/components/EngineValue.tsx @@ -1,7 +1,7 @@ import Engine, { formatValue } from 'publicodes' import React, { useContext } from 'react' import { useTranslation } from 'react-i18next' -import { DottedName } from 'systeme-social' +import { DottedName } from 'modele-social' import { coerceArray } from '../utils' import RuleLink from './RuleLink' import { EngineContext, useEngine } from './utils/EngineContext' diff --git a/mon-entreprise/source/components/PaySlip.tsx b/mon-entreprise/source/components/PaySlip.tsx index 2f0f2ba7d..b06b1f800 100644 --- a/mon-entreprise/source/components/PaySlip.tsx +++ b/mon-entreprise/source/components/PaySlip.tsx @@ -10,7 +10,7 @@ import { } from 'publicodes' import { Fragment, useContext } from 'react' import { Trans, useTranslation } from 'react-i18next' -import { DottedName } from 'systeme-social' +import { DottedName } from 'modele-social' import './PaySlip.css' import { Line, SalaireBrutSection, SalaireNetSection } from './PaySlipSections' diff --git a/mon-entreprise/source/components/PaySlipSections.tsx b/mon-entreprise/source/components/PaySlipSections.tsx index 7a5876dda..6d375337f 100644 --- a/mon-entreprise/source/components/PaySlipSections.tsx +++ b/mon-entreprise/source/components/PaySlipSections.tsx @@ -1,7 +1,7 @@ import Value, { Condition, ValueProps } from 'Components/EngineValue' import RuleLink from 'Components/RuleLink' import { Trans } from 'react-i18next' -import { DottedName } from 'systeme-social' +import { DottedName } from 'modele-social' export const SalaireBrutSection = () => { return ( diff --git a/mon-entreprise/source/components/QuickLinks.tsx b/mon-entreprise/source/components/QuickLinks.tsx index 18b6c5a4a..f79006a7c 100644 --- a/mon-entreprise/source/components/QuickLinks.tsx +++ b/mon-entreprise/source/components/QuickLinks.tsx @@ -3,7 +3,7 @@ import { contains, filter, pipe, reject, toPairs } from 'ramda' import { Trans } from 'react-i18next' import { useDispatch, useSelector } from 'react-redux' import { RootState } from 'Reducers/rootReducer' -import { DottedName } from 'systeme-social' +import { DottedName } from 'modele-social' import { useNextQuestions } from './utils/useNextQuestion' import { diff --git a/mon-entreprise/source/components/RuleLink.tsx b/mon-entreprise/source/components/RuleLink.tsx index 05bf95728..8aaea1a73 100644 --- a/mon-entreprise/source/components/RuleLink.tsx +++ b/mon-entreprise/source/components/RuleLink.tsx @@ -1,7 +1,7 @@ import { RuleLink as EngineRuleLink } from 'publicodes' import React, { useContext } from 'react' import { Link } from 'react-router-dom' -import { DottedName } from 'systeme-social' +import { DottedName } from 'modele-social' import { EngineContext } from './utils/EngineContext' import { SitePathsContext } from './utils/SitePathsContext' diff --git a/mon-entreprise/source/components/SchemeComparaison.tsx b/mon-entreprise/source/components/SchemeComparaison.tsx index b8683443d..998f6c639 100644 --- a/mon-entreprise/source/components/SchemeComparaison.tsx +++ b/mon-entreprise/source/components/SchemeComparaison.tsx @@ -10,22 +10,15 @@ import Value from 'Components/EngineValue' import dirigeantComparaison from '../sites/mon-entreprise.fr/pages/Simulateurs/configs/rémunération-dirigeant.yaml' import Engine from 'publicodes' import revenusSVG from 'Images/revenus.svg' -import { - default as React, - useCallback, - useContext, - useMemo, - useState, - useEffect, -} from 'react' +import { useCallback, useMemo, useState, useEffect } from 'react' import emoji from 'react-easy-emoji' import { Trans } from 'react-i18next' import { useDispatch, useSelector } from 'react-redux' import { situationSelector } from 'Selectors/simulationSelectors' import InfoBulle from 'Components/ui/InfoBulle' import './SchemeComparaison.css' -import { EngineContext, useEngine } from './utils/EngineContext' -import { DottedName } from 'Rules' +import { useEngine } from './utils/EngineContext' +import { DottedName } from 'modele-social' type SchemeComparaisonProps = { hideAutoEntrepreneur?: boolean diff --git a/mon-entreprise/source/components/SearchBar.tsx b/mon-entreprise/source/components/SearchBar.tsx index 3489a2644..4c0676965 100644 --- a/mon-entreprise/source/components/SearchBar.tsx +++ b/mon-entreprise/source/components/SearchBar.tsx @@ -1,6 +1,6 @@ import React, { useContext, useEffect, useMemo, useState } from 'react' import { Trans, useTranslation } from 'react-i18next' -import { DottedName } from 'systeme-social' +import { DottedName } from 'modele-social' import Worker from 'worker-loader!./SearchBar.worker.js' import RuleLink from './RuleLink' import './SearchBar.css' diff --git a/mon-entreprise/source/components/StackedBarChart.tsx b/mon-entreprise/source/components/StackedBarChart.tsx index 62a98475b..6a54e51c2 100644 --- a/mon-entreprise/source/components/StackedBarChart.tsx +++ b/mon-entreprise/source/components/StackedBarChart.tsx @@ -3,7 +3,7 @@ import useDisplayOnIntersecting from 'Components/utils/useDisplayOnIntersecting' import { EvaluatedNode, EvaluatedRule } from 'publicodes' import React from 'react' import { animated, useSpring } from 'react-spring' -import { DottedName } from 'systeme-social' +import { DottedName } from 'modele-social' import styled from 'styled-components' const BarStack = styled.div` diff --git a/mon-entreprise/source/components/TargetSelection.tsx b/mon-entreprise/source/components/TargetSelection.tsx index 67a2fddbf..429bd1698 100644 --- a/mon-entreprise/source/components/TargetSelection.tsx +++ b/mon-entreprise/source/components/TargetSelection.tsx @@ -26,7 +26,7 @@ import { Trans, useTranslation } from 'react-i18next' import { useDispatch, useSelector } from 'react-redux' import { useLocation } from 'react-router-dom' import { RootState } from 'Reducers/rootReducer' -import { DottedName } from 'systeme-social' +import { DottedName } from 'modele-social' import { targetUnitSelector } from 'Selectors/simulationSelectors' import CurrencyInput from './CurrencyInput/CurrencyInput' import './TargetSelection.css' diff --git a/mon-entreprise/source/components/conversation/AnswerList.tsx b/mon-entreprise/source/components/conversation/AnswerList.tsx index 8ab39a1e7..a6ec71f3b 100644 --- a/mon-entreprise/source/components/conversation/AnswerList.tsx +++ b/mon-entreprise/source/components/conversation/AnswerList.tsx @@ -6,7 +6,7 @@ import { EvaluatedNode, formatValue } from 'publicodes' import emoji from 'react-easy-emoji' import { Trans, useTranslation } from 'react-i18next' import { useDispatch, useSelector } from 'react-redux' -import { DottedName } from 'systeme-social' +import { DottedName } from 'modele-social' import { situationSelector } from 'Selectors/simulationSelectors' import './AnswerList.css' diff --git a/mon-entreprise/source/components/conversation/Explicable.tsx b/mon-entreprise/source/components/conversation/Explicable.tsx index 97b9e0d13..9b98afa53 100644 --- a/mon-entreprise/source/components/conversation/Explicable.tsx +++ b/mon-entreprise/source/components/conversation/Explicable.tsx @@ -4,7 +4,7 @@ import { EngineContext } from 'Components/utils/EngineContext' import React, { useContext, useState } from 'react' import emoji from 'react-easy-emoji' import { useDispatch } from 'react-redux' -import { DottedName } from 'systeme-social' +import { DottedName } from 'modele-social' import { TrackerContext } from '../utils/withTracker' import './Explicable.css' import usePortal from 'react-useportal' diff --git a/mon-entreprise/source/components/conversation/RuleInput.tsx b/mon-entreprise/source/components/conversation/RuleInput.tsx index ba7cb6689..0c3fa6aba 100644 --- a/mon-entreprise/source/components/conversation/RuleInput.tsx +++ b/mon-entreprise/source/components/conversation/RuleInput.tsx @@ -17,7 +17,7 @@ import { import { Evaluation } from 'publicodes/dist/types/AST/types' import React, { useContext } from 'react' import { useTranslation } from 'react-i18next' -import { DottedName } from 'systeme-social' +import { DottedName } from 'modele-social' import DateInput from './DateInput' import ParagrapheInput from './ParagrapheInput' import SelectEuropeCountry from './select/SelectEuropeCountry' diff --git a/mon-entreprise/source/components/simulationExplanation/AidesCovid.tsx b/mon-entreprise/source/components/simulationExplanation/AidesCovid.tsx index 479e92118..d837bc034 100644 --- a/mon-entreprise/source/components/simulationExplanation/AidesCovid.tsx +++ b/mon-entreprise/source/components/simulationExplanation/AidesCovid.tsx @@ -1,7 +1,7 @@ import Value, { Condition } from 'Components/EngineValue' import emoji from 'react-easy-emoji' import { Trans } from 'react-i18next' -import { DottedName } from 'systeme-social' +import { DottedName } from 'modele-social' type AidesCovidProps = { aidesRule?: DottedName diff --git a/mon-entreprise/source/components/simulationExplanation/IndépendantExplanation.tsx b/mon-entreprise/source/components/simulationExplanation/IndépendantExplanation.tsx index 8d6b1434c..d4c640fd3 100644 --- a/mon-entreprise/source/components/simulationExplanation/IndépendantExplanation.tsx +++ b/mon-entreprise/source/components/simulationExplanation/IndépendantExplanation.tsx @@ -15,7 +15,7 @@ import { max } from 'ramda' import { useContext } from 'react' import { Trans, useTranslation } from 'react-i18next' import { useSelector } from 'react-redux' -import { DottedName } from 'systeme-social' +import { DottedName } from 'modele-social' import { targetUnitSelector } from 'Selectors/simulationSelectors' import styled from 'styled-components' import AidesCovid from './AidesCovid' diff --git a/mon-entreprise/source/components/simulationExplanation/SalaryExplanation.tsx b/mon-entreprise/source/components/simulationExplanation/SalaryExplanation.tsx index 3abdfedaa..41bee8f65 100644 --- a/mon-entreprise/source/components/simulationExplanation/SalaryExplanation.tsx +++ b/mon-entreprise/source/components/simulationExplanation/SalaryExplanation.tsx @@ -2,11 +2,7 @@ import Distribution from 'Components/Distribution' import PaySlip from 'Components/PaySlip' import StackedBarChart from 'Components/StackedBarChart' import { ThemeColorsContext } from 'Components/utils/colors' -import { - EngineContext, - useEngine, - useInversionFail, -} from 'Components/utils/EngineContext' +import { useEngine, useInversionFail } from 'Components/utils/EngineContext' import { useContext, useRef } from 'react' import emoji from 'react-easy-emoji' import { Trans, useTranslation } from 'react-i18next' @@ -14,7 +10,7 @@ import { useSelector } from 'react-redux' import * as Animate from 'Components/ui/animate' import { answeredQuestionsSelector } from 'Selectors/simulationSelectors' import { evaluateRule } from 'publicodes' -import { DottedName } from 'Rules' +import { DottedName } from 'modele-social' export default function SalaryExplanation() { const showDistributionFirst = !useSelector(answeredQuestionsSelector).length diff --git a/mon-entreprise/source/components/utils/EngineContext.tsx b/mon-entreprise/source/components/utils/EngineContext.tsx index e7e326ecd..41e175fd6 100644 --- a/mon-entreprise/source/components/utils/EngineContext.tsx +++ b/mon-entreprise/source/components/utils/EngineContext.tsx @@ -1,6 +1,6 @@ import Engine from 'publicodes' import React, { createContext, useContext } from 'react' -import { DottedName } from 'systeme-social' +import { DottedName } from 'modele-social' export const EngineContext = createContext(new Engine({})) export const EngineProvider = EngineContext.Provider diff --git a/mon-entreprise/source/components/utils/useNextQuestion.tsx b/mon-entreprise/source/components/utils/useNextQuestion.tsx index b747a0f12..393c3fb9c 100644 --- a/mon-entreprise/source/components/utils/useNextQuestion.tsx +++ b/mon-entreprise/source/components/utils/useNextQuestion.tsx @@ -25,7 +25,7 @@ import { import { useContext, useMemo } from 'react' import { useSelector } from 'react-redux' import { Simulation, SimulationConfig } from 'Reducers/rootReducer' -import { DottedName } from 'systeme-social' +import { DottedName } from 'modele-social' import { answeredQuestionsSelector, configSelector, diff --git a/mon-entreprise/source/reducers/rootReducer.ts b/mon-entreprise/source/reducers/rootReducer.ts index 7ea817dea..94a06bbc6 100644 --- a/mon-entreprise/source/reducers/rootReducer.ts +++ b/mon-entreprise/source/reducers/rootReducer.ts @@ -3,7 +3,7 @@ import { defaultTo, omit, without } from 'ramda' import reduceReducers from 'reduce-reducers' import { combineReducers, Reducer } from 'redux' import { SavedSimulation } from 'Selectors/storageSelectors' -import { DottedName } from 'systeme-social' +import { DottedName } from 'modele-social' import { objectifsSelector } from '../selectors/simulationSelectors' import inFranceAppReducer, { Company } from './inFranceAppReducer' import storageRootReducer from './storageReducer' diff --git a/mon-entreprise/source/selectors/simulationSelectors.ts b/mon-entreprise/source/selectors/simulationSelectors.ts index 2cbde0d8b..5e4b8c472 100644 --- a/mon-entreprise/source/selectors/simulationSelectors.ts +++ b/mon-entreprise/source/selectors/simulationSelectors.ts @@ -1,4 +1,4 @@ -import { DottedName } from 'systeme-social' +import { DottedName } from 'modele-social' import { createSelector } from 'reselect' import { RootState, SimulationConfig } from 'Reducers/rootReducer' diff --git a/mon-entreprise/source/selectors/storageSelectors.ts b/mon-entreprise/source/selectors/storageSelectors.ts index 7216471e1..6c912c653 100644 --- a/mon-entreprise/source/selectors/storageSelectors.ts +++ b/mon-entreprise/source/selectors/storageSelectors.ts @@ -1,5 +1,5 @@ import { RootState, Simulation } from 'Reducers/rootReducer' -import { DottedName } from 'systeme-social' +import { DottedName } from 'modele-social' // Note: it is currently not possible to define SavedSimulation as the return // type of the currentSimulationSelector function because the type would then diff --git a/mon-entreprise/source/server.js b/mon-entreprise/source/server.js index 932dad33b..11d422e11 100644 --- a/mon-entreprise/source/server.js +++ b/mon-entreprise/source/server.js @@ -7,7 +7,7 @@ const config = require('../webpack.dev.js') const compiler = webpack(config) const history = require('connect-history-api-fallback') -const { watchDottedNames } = require('../../systeme-social/build') +const { watchDottedNames } = require('../../modele-social/build') watchDottedNames() const rewrite = (basename) => ({ diff --git a/mon-entreprise/source/sites/mon-entreprise.fr/App.tsx b/mon-entreprise/source/sites/mon-entreprise.fr/App.tsx index e87f7828f..1e35b7ca6 100644 --- a/mon-entreprise/source/sites/mon-entreprise.fr/App.tsx +++ b/mon-entreprise/source/sites/mon-entreprise.fr/App.tsx @@ -14,7 +14,7 @@ import { useTranslation } from 'react-i18next' import { useSelector } from 'react-redux' import { Route, Switch } from 'react-router-dom' import createSentryMiddleware from 'redux-sentry-middleware' -import { DottedName } from 'systeme-social' +import { DottedName } from 'modele-social' import { configSituationSelector, situationSelector, diff --git a/mon-entreprise/source/sites/mon-entreprise.fr/entry.en.tsx b/mon-entreprise/source/sites/mon-entreprise.fr/entry.en.tsx index 527a5b416..4c13e2401 100644 --- a/mon-entreprise/source/sites/mon-entreprise.fr/entry.en.tsx +++ b/mon-entreprise/source/sites/mon-entreprise.fr/entry.en.tsx @@ -3,7 +3,7 @@ import { hot } from 'react-hot-loader/root' import { translateRules } from 'publicodes' import { render } from 'react-dom' import 'regenerator-runtime/runtime' -import rules from 'systeme-social' +import rules from 'modele-social' import i18next from '../../i18n' import translations from '../../locales/ui-en.yaml' import ruleTranslations from '../../locales/rules-en.yaml' diff --git a/mon-entreprise/source/sites/mon-entreprise.fr/entry.fr.tsx b/mon-entreprise/source/sites/mon-entreprise.fr/entry.fr.tsx index 06ef6647c..8767966fd 100644 --- a/mon-entreprise/source/sites/mon-entreprise.fr/entry.fr.tsx +++ b/mon-entreprise/source/sites/mon-entreprise.fr/entry.fr.tsx @@ -3,7 +3,7 @@ import 'core-js/stable' import 'react-hot-loader' import { render } from 'react-dom' import 'regenerator-runtime/runtime' -import rules from 'systeme-social' +import rules from 'modele-social' import App from './App' import i18next from '../../i18n' diff --git a/mon-entreprise/source/sites/mon-entreprise.fr/middlewares/trackSimulatorActions.ts b/mon-entreprise/source/sites/mon-entreprise.fr/middlewares/trackSimulatorActions.ts index af6805e37..df1e9e963 100644 --- a/mon-entreprise/source/sites/mon-entreprise.fr/middlewares/trackSimulatorActions.ts +++ b/mon-entreprise/source/sites/mon-entreprise.fr/middlewares/trackSimulatorActions.ts @@ -1,4 +1,4 @@ -import { DottedName } from 'systeme-social' +import { DottedName } from 'modele-social' import { situationSelector } from 'Selectors/simulationSelectors' import Tracker from 'Tracker' diff --git a/mon-entreprise/source/sites/mon-entreprise.fr/pages/Gérer/AideDéclarationIndépendant/index.tsx b/mon-entreprise/source/sites/mon-entreprise.fr/pages/Gérer/AideDéclarationIndépendant/index.tsx index f58a8baeb..221053e3b 100644 --- a/mon-entreprise/source/sites/mon-entreprise.fr/pages/Gérer/AideDéclarationIndépendant/index.tsx +++ b/mon-entreprise/source/sites/mon-entreprise.fr/pages/Gérer/AideDéclarationIndépendant/index.tsx @@ -17,7 +17,7 @@ import emoji from 'react-easy-emoji' import { Trans } from 'react-i18next' import { useDispatch, useSelector } from 'react-redux' import { RootState } from 'Reducers/rootReducer' -import { DottedName } from 'systeme-social' +import { DottedName } from 'modele-social' import { situationSelector } from 'Selectors/simulationSelectors' import styled from 'styled-components' import { CompanySection } from '../Home' diff --git a/mon-entreprise/source/sites/mon-entreprise.fr/pages/Simulateurs/ArtisteAuteur.tsx b/mon-entreprise/source/sites/mon-entreprise.fr/pages/Simulateurs/ArtisteAuteur.tsx index e36b4feff..9323177a9 100644 --- a/mon-entreprise/source/sites/mon-entreprise.fr/pages/Simulateurs/ArtisteAuteur.tsx +++ b/mon-entreprise/source/sites/mon-entreprise.fr/pages/Simulateurs/ArtisteAuteur.tsx @@ -12,7 +12,7 @@ import { equals } from 'ramda' import { createContext, useContext, useEffect, useState } from 'react' import { Trans } from 'react-i18next' import { useDispatch, useSelector } from 'react-redux' -import { DottedName } from 'systeme-social' +import { DottedName } from 'modele-social' import { situationSelector } from 'Selectors/simulationSelectors' import styled from 'styled-components' import config from './configs/artiste-auteur.yaml' diff --git a/mon-entreprise/source/sites/mon-entreprise.fr/pages/Simulateurs/ChômagePartiel.tsx b/mon-entreprise/source/sites/mon-entreprise.fr/pages/Simulateurs/ChômagePartiel.tsx index a91234c71..3244cce31 100644 --- a/mon-entreprise/source/sites/mon-entreprise.fr/pages/Simulateurs/ChômagePartiel.tsx +++ b/mon-entreprise/source/sites/mon-entreprise.fr/pages/Simulateurs/ChômagePartiel.tsx @@ -7,7 +7,7 @@ import { EngineContext, useEngine } from 'Components/utils/EngineContext' import { EvaluatedRule, evaluateRule, formatValue } from 'publicodes' import React, { useContext, useEffect, useState } from 'react' import { useTranslation } from 'react-i18next' -import { DottedName } from 'systeme-social' +import { DottedName } from 'modele-social' import styled from 'styled-components' declare global { diff --git a/mon-entreprise/source/sites/mon-entreprise.fr/pages/integration/Library.tsx b/mon-entreprise/source/sites/mon-entreprise.fr/pages/integration/Library.tsx index 5eec9ad0a..580afa89d 100644 --- a/mon-entreprise/source/sites/mon-entreprise.fr/pages/integration/Library.tsx +++ b/mon-entreprise/source/sites/mon-entreprise.fr/pages/integration/Library.tsx @@ -34,7 +34,7 @@ export default function Library() {

Installation

-					npm install --save publicodes systeme-social
+					npm install --save publicodes modele-social
 				

Les dépendances suivantes sont aussi nécessaires @@ -55,7 +55,7 @@ export default function Library() {

Lancer le calcul

Il ne vous reste plus qu'à paramétrer le moteur avec les règles du - paquet `systeme-social` et à appeler la fonction `evaluate` sur la + paquet `modele-social` et à appeler la fonction `evaluate` sur la règle que dont vous souhaitez la valeur. Voici un exemple pour le calcul brut / net

diff --git a/mon-entreprise/source/sites/publi.codes/Studio.tsx b/mon-entreprise/source/sites/publi.codes/Studio.tsx index 0f68e9a9e..864f4891e 100644 --- a/mon-entreprise/source/sites/publi.codes/Studio.tsx +++ b/mon-entreprise/source/sites/publi.codes/Studio.tsx @@ -4,7 +4,7 @@ import { invertObj, last } from 'ramda' import React, { useCallback, useEffect, useMemo, useState } from 'react' import emoji from 'react-easy-emoji' import MonacoEditor from 'react-monaco-editor' -import { useHistory, useLocation, Redirect } from 'react-router-dom' +import { useHistory, useLocation } from 'react-router-dom' import styled from 'styled-components' import yaml from 'yaml' import { useDebounce } from 'Components/utils' @@ -14,6 +14,7 @@ const EXAMPLE_CODE = ` # Pour en savoir plus sur le langage, consultez le tutoriel : # => https://publi.codes +prix: prix . carottes: 2€/kg prix . champignons: 5€/kg prix . avocat: 2€/avocat diff --git a/mon-entreprise/source/utils.ts b/mon-entreprise/source/utils.ts index 4d44eb1b2..a1d268da1 100644 --- a/mon-entreprise/source/utils.ts +++ b/mon-entreprise/source/utils.ts @@ -1,5 +1,4 @@ -import Engine, { ASTNode, EvaluatedNode, formatValue } from 'publicodes' -import { DottedName } from './rules' +import { formatValue } from 'publicodes' export function capitalise0(name: undefined): undefined export function capitalise0(name: string): string diff --git a/mon-entreprise/test/conversation.test.js b/mon-entreprise/test/conversation.test.js index cfe660b20..6ad0be0bb 100644 --- a/mon-entreprise/test/conversation.test.js +++ b/mon-entreprise/test/conversation.test.js @@ -4,7 +4,7 @@ import { getNextQuestions, getNextSteps, } from '../source/components/utils/useNextQuestion' -import rules from 'systeme-social' +import rules from 'modele-social' describe('conversation', function () { it('should start with the first missing variable', function () { diff --git a/mon-entreprise/test/cycles.test.js b/mon-entreprise/test/cycles.test.js index 2d015b1d1..960fbdcbd 100644 --- a/mon-entreprise/test/cycles.test.js +++ b/mon-entreprise/test/cycles.test.js @@ -1,6 +1,6 @@ import { expect } from 'chai' import { cyclesLib } from 'publicodes' -import rules from 'systeme-social' +import rules from 'modele-social' describe('DottedNames graph', () => { it("shouldn't have cycles", () => { diff --git a/mon-entreprise/test/real-rules.test.js b/mon-entreprise/test/real-rules.test.js index 999fe1bed..926d2023a 100644 --- a/mon-entreprise/test/real-rules.test.js +++ b/mon-entreprise/test/real-rules.test.js @@ -1,7 +1,7 @@ import { AssertionError } from 'chai' import Engine, { parsePublicodes } from 'publicodes' import { disambiguateRuleReference } from '../../publicodes/source/ruleUtils' -import rules from 'systeme-social' +import rules from 'modele-social' // les variables dans les tests peuvent être exprimées relativement à l'espace de nom de la règle, // comme dans sa formule diff --git a/mon-entreprise/test/regressions/simulations.jest.js b/mon-entreprise/test/regressions/simulations.jest.js index 79e189312..aa74a9312 100644 --- a/mon-entreprise/test/regressions/simulations.jest.js +++ b/mon-entreprise/test/regressions/simulations.jest.js @@ -7,7 +7,7 @@ /* eslint-disable no-undef */ import Engine, { evaluateRule } from 'publicodes' -import rules from 'systeme-social' +import rules from 'modele-social' import artisteAuteurConfig from '../../source/sites/mon-entreprise.fr/pages/Simulateurs/configs/artiste-auteur.yaml' import autoentrepreneurConfig from '../../source/sites/mon-entreprise.fr/pages/Simulateurs/configs/auto-entrepreneur.yaml' import independantConfig from '../../source/sites/mon-entreprise.fr/pages/Simulateurs/configs/indépendant.yaml' diff --git a/mon-entreprise/test/unit-translations.test.js b/mon-entreprise/test/unit-translations.test.js index 264265f26..64bb90e9f 100644 --- a/mon-entreprise/test/unit-translations.test.js +++ b/mon-entreprise/test/unit-translations.test.js @@ -1,7 +1,7 @@ import { expect } from 'chai' import { parsePublicodes } from 'publicodes' import { uniq } from 'ramda' -import rawRules from 'systeme-social' +import rawRules from 'modele-social' import unitsTranslations from '../../publicodes/source/locales/units.yaml' it('use unit that exists in publicode', () => { diff --git a/package.json b/package.json index 4dfe8d45a..a1abc0ef3 100644 --- a/package.json +++ b/package.json @@ -119,11 +119,11 @@ "test:regressions": "jest", "clean": "yarn workspaces run clean", "start": "yarn workspace publicodes build --watch & yarn workspace mon-entreprise start", - "syso:up": "yarn workspace systeme-social run up" + "moso:up": "yarn workspace modele-social run up" }, "workspaces": [ "publicodes", - "systeme-social", + "modele-social", "mon-entreprise" ] } diff --git a/systeme-social/.yarnrc b/systeme-social/.yarnrc deleted file mode 100644 index 8094fc503..000000000 --- a/systeme-social/.yarnrc +++ /dev/null @@ -1,2 +0,0 @@ -version-tag-prefix syso-v -version-git-message "⬆ Mise à jour du paquet \"systeme-social\" vers %s" diff --git a/systeme-social/index.d.ts b/systeme-social/index.d.ts deleted file mode 100644 index f20226051..000000000 --- a/systeme-social/index.d.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Currenty we systematically bundle all the rules even if we only need a -// sub-section of them. We might support "code-splitting" the rules in the -// future. -import { - EvaluatedRule as GenericEvaluatedRule, - ParsedRule as GenericParsedRule, - ParsedRules as GenericParsedRules, - Rules as GenericRules -} from 'publicodes' -import { Names } from './dist/names' - -export type DottedName = Names -export type Rules = GenericRules -export type ParsedRules = GenericParsedRules -export type ParsedRule = GenericParsedRule -export type EvaluatedRule = GenericEvaluatedRule -export type Situation = Partial> -declare let rules: Rules -export default rules diff --git a/systeme-social/règles/.gitignore b/systeme-social/règles/.gitignore deleted file mode 100644 index d2785045c..000000000 --- a/systeme-social/règles/.gitignore +++ /dev/null @@ -1 +0,0 @@ -dottednames.json