🦚 Renomme "systeme-social" en "modele-social"

pull/1299/head
Maxime Quandalle 2020-12-09 12:41:58 +01:00
parent 0bdd5d128e
commit a357baf7f1
68 changed files with 73 additions and 94 deletions

1
.gitignore vendored
View File

@ -1,5 +1,6 @@
.tags*
.tmp
/tmp
.DS_Store
yarn-error.log
package-lock.json

2
modele-social/.yarnrc Normal file
View File

@ -0,0 +1,2 @@
version-tag-prefix modele-social-v
version-git-message "⬆ Mise à jour du paquet \"modele-social\" vers %s"

View File

@ -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.

9
modele-social/index.d.ts vendored Normal file
View File

@ -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<Names, Rule>
export default rules

View File

@ -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",

View File

@ -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"
},

View File

@ -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,
}

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -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 (

View File

@ -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 {

View File

@ -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'

View File

@ -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

View File

@ -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'

View File

@ -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`

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -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

View File

@ -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'

View File

@ -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

View File

@ -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<Engine>(new Engine({}))
export const EngineProvider = EngineContext.Provider

View File

@ -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,

View File

@ -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'

View File

@ -1,4 +1,4 @@
import { DottedName } from 'systeme-social'
import { DottedName } from 'modele-social'
import { createSelector } from 'reselect'
import { RootState, SimulationConfig } from 'Reducers/rootReducer'

View File

@ -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

View File

@ -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) => ({

View File

@ -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,

View File

@ -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'

View File

@ -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'

View File

@ -1,4 +1,4 @@
import { DottedName } from 'systeme-social'
import { DottedName } from 'modele-social'
import { situationSelector } from 'Selectors/simulationSelectors'
import Tracker from 'Tracker'

View File

@ -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'

View File

@ -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'

View File

@ -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 {

View File

@ -34,7 +34,7 @@ export default function Library() {
</p>
<h3>Installation</h3>
<pre>
<code>npm install --save publicodes systeme-social</code>
<code>npm install --save publicodes modele-social</code>
</pre>
<p>
<Emoji emoji="🚧" /> Les dépendances suivantes sont aussi nécessaires
@ -55,7 +55,7 @@ export default function Library() {
<h3>Lancer le calcul</h3>
<p>
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
</p>

View File

@ -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

View File

@ -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

View File

@ -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 () {

View File

@ -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", () => {

View File

@ -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

View File

@ -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'

View File

@ -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', () => {

View File

@ -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"
]
}

View File

@ -1,2 +0,0 @@
version-tag-prefix syso-v
version-git-message "⬆ Mise à jour du paquet \"systeme-social\" vers %s"

View File

@ -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<Names>
export type ParsedRules = GenericParsedRules<Names>
export type ParsedRule = GenericParsedRule<Names>
export type EvaluatedRule = GenericEvaluatedRule<Names>
export type Situation = Partial<Record<Names, string>>
declare let rules: Rules
export default rules

View File

@ -1 +0,0 @@
dottednames.json