diff --git a/src/codice-fiscale.js b/src/codice-fiscale.js index 3839e84..11271bc 100755 --- a/src/codice-fiscale.js +++ b/src/codice-fiscale.js @@ -1,6 +1,8 @@ import { Comune } from './comune' import { CHECK_CODE_CHARS, CHECK_CODE_EVEN, CHECK_CODE_ODD, MONTH_CODES, NUMERIC_POS, OMOCODIA_TABLE, OMOCODIA_TABLE_INVERSE } from './constants' import { extractConsonants, extractVowels, getValidDate, birthplaceFields, getAllSubsets } from './utils' +import { COMUNI_LIST } from './lista-comuni' +import { PROVINCE } from './lista-province' class CodiceFiscale { get day () { @@ -250,4 +252,6 @@ class CodiceFiscale { CodiceFiscale.utils = { birthplaceFields: birthplaceFields } +CodiceFiscale.COMUNI = COMUNI_LIST +CodiceFiscale.PROVINCE = PROVINCE module.exports = CodiceFiscale; \ No newline at end of file diff --git a/src/lista-comuni.js b/src/lista-comuni.js index 5391f57..7246748 100644 --- a/src/lista-comuni.js +++ b/src/lista-comuni.js @@ -13655,3 +13655,11 @@ export const COMUNI = [ ["A001","PD","ABANO BAGNI",0], ["M205","MI","ZUNICO",0], ["M206","CA","ZURI",0], ] + +// Export a more user-friendly structure for external consumption +export const COMUNI_LIST = COMUNI.map(([cc, prov, nome, active]) => ({ + belfioreCode: cc, + province: prov, + name: nome, + active: active === 1 +})) diff --git a/types/codice-fiscale.d.ts b/types/codice-fiscale.d.ts index a4cf424..76f40eb 100644 --- a/types/codice-fiscale.d.ts +++ b/types/codice-fiscale.d.ts @@ -3,6 +3,17 @@ import { birthplaceFields } from "./utils"; export type Gender = "F" | "M"; +export interface IComuneData { + belfioreCode: string; + province: string; + name: string; + active: boolean; +} + +export interface IProvinceData { + [key: string]: string; +} + export interface ICodiceFiscaleObject { name: string; surname: string; @@ -26,6 +37,8 @@ declare class CodiceFiscale { static utils: { birthplaceFields: typeof birthplaceFields; }; + static COMUNI: IComuneData[]; + static PROVINCE: IProvinceData; birthday: Date; birthplace: Comune; name: string; @@ -55,3 +68,6 @@ declare class CodiceFiscale { } export default CodiceFiscale; +export { CodiceFiscale }; +export const COMUNI: IComuneData[]; +export const PROVINCE: IProvinceData;