@openfisca/json-model
Version:
Library to handle informations extracted in JSON or YAML format from OpenFisca parameters, variables, etc
71 lines (70 loc) • 2.31 kB
TypeScript
import type { PythonAstFunctionDef } from "./ast";
import type { Metadata } from "./metadata";
import type { PeriodUnit } from "./periods";
import type { ReferencesByInstant } from "./references";
export interface Formula {
ast?: PythonAstFunctionDef;
documentation?: string;
file_path: string;
parameters?: string[];
source_code?: string;
start_line_number: number;
stop_line_number: number;
variables?: string[];
}
export interface InputByVariableName {
[variableName: string]: VariableValues;
}
export interface Percentile {
bucket_count: number;
bucket_mean: number;
bucket_stdev: number;
bucket_sum: number;
count_above_upper_bound: number;
lower_bound: number;
mean_above_upper_bound: number;
ratio_count_above_upper_bound: number;
sum_above_upper_bound: number;
upper_bound: number;
}
export interface Variable {
aggregate?: {
deciles?: Percentile[];
year: number;
};
default_value: VariableValue;
definition_period: PeriodUnit;
description?: ReferencesByInstant;
documentation?: string;
entity: string;
file_path: string;
formulas?: {
[date: string]: Formula | null;
};
input?: boolean;
label?: string;
last_value_still_valid_on?: string;
linked_other_variables?: string[];
name: string;
obsolete?: boolean;
possible_values?: {
[name: string]: string;
};
reference?: ReferencesByInstant;
referring_variables?: string[];
set_input?: string;
start_line_number: number;
stop_line_number: number;
unit?: string;
short_label?: string;
value_type: "bool" | "date" | "Enum" | "float" | "int" | "str";
}
export interface VariableByName {
[name: string]: Variable;
}
export type VariableValue = boolean | number | string;
export type VariableValues = boolean[] | number[] | string[];
export declare function getVariableFormula({ formulas }: Variable, date: string): Formula | null;
export declare function getVariableLatestFormulaDate({ formulas, }: Variable): string | null;
export declare function newFormulaRepositoryUrl(metadata: Metadata, formula: Formula): string | undefined;
export declare function newVariableRepositoryUrl(metadata: Metadata, variable: Variable): string | undefined;