• Migrate a situation from an old version of a model to a new version according to the provided migration instructions.

    Parameters

    • situation: Partial<Record<string, ASTNode<"rule" | "reference" | "arrondi" | "barème" | "durée" | "grille" | "est non applicable" | "est non défini" | "inversion" | "operation" | "une possibilité" | "contexte" | "simplifier unité" | "résoudre référence circulaire" | "taux progressif" | "unité" | "variations" | "condition" | "constant" | "replacementRule" | "variable manquante" | "texte"> | PublicodesExpression>>

      The situation object containing all answers for a given simulation.

    • instructions: Migration

      The migration instructions object.

    Returns Situation<RuleName>

    The migrated situation (and foldedSteps if specified).

    Example

    import { migrateSituation } from '@publicodes/tools/migration'

    const situation = {
    "age": 25
    "job": "developer",
    "city": "Paris"
    }

    const instructions = {
    keysToMigrate: {
    // The rule `age` will be renamed to `âge`.
    age: 'âge',
    // The rule `city` will be removed.
    city: ''
    },
    valuesToMigrate: {
    job: {
    // The value `developer` will be translated to `développeur`.
    developer: 'développeur'
    }
    }
    }

    migrateSituation(situation, instructions) // { "âge": 25, "job": "'développeur'" }

    Note

    An example of instructions can be found here.

Generated using TypeDoc