Skip to content
This repository has been archived by the owner on Feb 14, 2025. It is now read-only.

Commit

Permalink
fix: types
Browse files Browse the repository at this point in the history
  • Loading branch information
Clemog committed May 16, 2024
1 parent 0c8371c commit bcb13ba
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 22 deletions.
1 change: 0 additions & 1 deletion source/migration/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,3 @@ Then, calling `migrateSituation` with the situation and the migration instructio
*/

export * from './migrateSituation'
export * from './types'
15 changes: 14 additions & 1 deletion source/migration/migrateSituation.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
import { DottedName, MigrationType, Situation } from './types'
import { getValueWithoutQuotes } from './migrateSituation/getValueWithoutQuotes'
import { handleSituationKeysMigration } from './migrateSituation/handleSituationKeysMigration'
import { handleSituationValuesMigration } from './migrateSituation/handleSituationValuesMigration'
import { handleSpecialCases } from './migrateSituation/handleSpecialCases'
import { Evaluation } from 'publicodes'

export type NodeValue = Evaluation

export type Situation = {
[key: string]: NodeValue
}

export type DottedName = string

export type MigrationType = {
keysToMigrate: Record<DottedName, DottedName>
valuesToMigrate: Record<DottedName, Record<string, NodeValue>>
}

/**
* Migrate rules and answers from a situation which used to work with an old version of a model to a new version according to the migration instructions.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DottedName, Situation } from '../types'
import { DottedName, Situation } from '../migrateSituation'

/**
* Delete a key from the situation and from the foldedSteps if it exists.
Expand Down
2 changes: 1 addition & 1 deletion source/migration/migrateSituation/getValueWithoutQuotes.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NodeValue } from '../types'
import { NodeValue } from '../migrateSituation'

/**
* Returns the value without quotes if it is a string.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { DottedName, MigrationType, NodeValue, Situation } from '../types'
import {
DottedName,
MigrationType,
NodeValue,
Situation,
} from '../migrateSituation'
import { deleteKeyFromSituationAndFoldedSteps } from './deleteKeyFromSituationAndFoldedSteps'

type Props = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { DottedName, MigrationType, NodeValue, Situation } from '../types'
import {
DottedName,
MigrationType,
NodeValue,
Situation,
} from '../migrateSituation'
import { deleteKeyFromSituationAndFoldedSteps } from './deleteKeyFromSituationAndFoldedSteps'

type Props = {
Expand Down
7 changes: 5 additions & 2 deletions source/migration/migrateSituation/handleSpecialCases.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { DottedName, Situation } from '../migrateSituation'

type Props = {
ruleName: string
ruleName: DottedName
// Should be fixed
nodeValue: any
situation: any
situation: Situation
}

// Handle migration of old value format : an object { valeur: number, unité: string }
Expand Down
14 changes: 0 additions & 14 deletions source/migration/types.ts

This file was deleted.

0 comments on commit bcb13ba

Please sign in to comment.