@treeviz/gedcom-parser 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (321) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +954 -0
  3. package/dist/classes/common.d.ts +87 -0
  4. package/dist/classes/common.d.ts.map +1 -0
  5. package/dist/classes/common.js +481 -0
  6. package/dist/classes/date.d.ts +26 -0
  7. package/dist/classes/date.d.ts.map +1 -0
  8. package/dist/classes/date.js +176 -0
  9. package/dist/classes/fam.d.ts +19 -0
  10. package/dist/classes/fam.d.ts.map +1 -0
  11. package/dist/classes/fam.js +38 -0
  12. package/dist/classes/fams.d.ts +16 -0
  13. package/dist/classes/fams.d.ts.map +1 -0
  14. package/dist/classes/fams.js +41 -0
  15. package/dist/classes/gedcom.d.ts +89 -0
  16. package/dist/classes/gedcom.d.ts.map +1 -0
  17. package/dist/classes/gedcom.js +421 -0
  18. package/dist/classes/index.d.ts +19 -0
  19. package/dist/classes/index.d.ts.map +1 -0
  20. package/dist/classes/index.js +19 -0
  21. package/dist/classes/indi.d.ts +298 -0
  22. package/dist/classes/indi.d.ts.map +1 -0
  23. package/dist/classes/indi.js +2049 -0
  24. package/dist/classes/indis.d.ts +54 -0
  25. package/dist/classes/indis.d.ts.map +1 -0
  26. package/dist/classes/indis.js +439 -0
  27. package/dist/classes/list.d.ts +55 -0
  28. package/dist/classes/list.d.ts.map +1 -0
  29. package/dist/classes/list.js +440 -0
  30. package/dist/classes/name.d.ts +20 -0
  31. package/dist/classes/name.d.ts.map +1 -0
  32. package/dist/classes/name.js +48 -0
  33. package/dist/classes/note.d.ts +12 -0
  34. package/dist/classes/note.d.ts.map +1 -0
  35. package/dist/classes/note.js +46 -0
  36. package/dist/classes/obje.d.ts +12 -0
  37. package/dist/classes/obje.d.ts.map +1 -0
  38. package/dist/classes/obje.js +81 -0
  39. package/dist/classes/objes.d.ts +8 -0
  40. package/dist/classes/objes.d.ts.map +1 -0
  41. package/dist/classes/objes.js +13 -0
  42. package/dist/classes/repo.d.ts +11 -0
  43. package/dist/classes/repo.d.ts.map +1 -0
  44. package/dist/classes/repo.js +6 -0
  45. package/dist/classes/repos.d.ts +8 -0
  46. package/dist/classes/repos.d.ts.map +1 -0
  47. package/dist/classes/repos.js +13 -0
  48. package/dist/classes/sour.d.ts +11 -0
  49. package/dist/classes/sour.d.ts.map +1 -0
  50. package/dist/classes/sour.js +6 -0
  51. package/dist/classes/sours.d.ts +8 -0
  52. package/dist/classes/sours.d.ts.map +1 -0
  53. package/dist/classes/sours.js +13 -0
  54. package/dist/classes/subm.d.ts +10 -0
  55. package/dist/classes/subm.d.ts.map +1 -0
  56. package/dist/classes/subm.js +6 -0
  57. package/dist/classes/subms.d.ts +8 -0
  58. package/dist/classes/subms.d.ts.map +1 -0
  59. package/dist/classes/subms.js +13 -0
  60. package/dist/constants/constants.d.ts +14 -0
  61. package/dist/constants/constants.d.ts.map +1 -0
  62. package/dist/constants/constants.js +13 -0
  63. package/dist/constants/filters.d.ts +17 -0
  64. package/dist/constants/filters.d.ts.map +1 -0
  65. package/dist/constants/filters.js +44 -0
  66. package/dist/constants/index.d.ts +4 -0
  67. package/dist/constants/index.d.ts.map +1 -0
  68. package/dist/constants/index.js +4 -0
  69. package/dist/constants/orders.d.ts +17 -0
  70. package/dist/constants/orders.d.ts.map +1 -0
  71. package/dist/constants/orders.js +240 -0
  72. package/dist/factories/cache-factory.d.ts +30 -0
  73. package/dist/factories/cache-factory.d.ts.map +1 -0
  74. package/dist/factories/cache-factory.js +43 -0
  75. package/dist/factories/date-locale-factory.d.ts +30 -0
  76. package/dist/factories/date-locale-factory.d.ts.map +1 -0
  77. package/dist/factories/date-locale-factory.js +34 -0
  78. package/dist/factories/i18n-factory.d.ts +40 -0
  79. package/dist/factories/i18n-factory.d.ts.map +1 -0
  80. package/dist/factories/i18n-factory.js +44 -0
  81. package/dist/factories/index.d.ts +5 -0
  82. package/dist/factories/index.d.ts.map +1 -0
  83. package/dist/factories/index.js +5 -0
  84. package/dist/factories/kinship-factory.d.ts +38 -0
  85. package/dist/factories/kinship-factory.d.ts.map +1 -0
  86. package/dist/factories/kinship-factory.js +35 -0
  87. package/dist/factories/place-parser-provider.d.ts +32 -0
  88. package/dist/factories/place-parser-provider.d.ts.map +1 -0
  89. package/dist/factories/place-parser-provider.js +35 -0
  90. package/dist/factories/place-translator-provider.d.ts +32 -0
  91. package/dist/factories/place-translator-provider.d.ts.map +1 -0
  92. package/dist/factories/place-translator-provider.js +35 -0
  93. package/dist/index.d.ts +78 -0
  94. package/dist/index.d.ts.map +1 -0
  95. package/dist/index.js +44 -0
  96. package/dist/interfaces/common.d.ts +43 -0
  97. package/dist/interfaces/common.d.ts.map +1 -0
  98. package/dist/interfaces/common.js +1 -0
  99. package/dist/interfaces/fam.d.ts +11 -0
  100. package/dist/interfaces/fam.d.ts.map +1 -0
  101. package/dist/interfaces/fam.js +1 -0
  102. package/dist/interfaces/fams.d.ts +9 -0
  103. package/dist/interfaces/fams.d.ts.map +1 -0
  104. package/dist/interfaces/fams.js +1 -0
  105. package/dist/interfaces/gedcom.d.ts +30 -0
  106. package/dist/interfaces/gedcom.d.ts.map +1 -0
  107. package/dist/interfaces/gedcom.js +1 -0
  108. package/dist/interfaces/index.d.ts +12 -0
  109. package/dist/interfaces/index.d.ts.map +1 -0
  110. package/dist/interfaces/index.js +1 -0
  111. package/dist/interfaces/indi.d.ts +109 -0
  112. package/dist/interfaces/indi.d.ts.map +1 -0
  113. package/dist/interfaces/indi.js +1 -0
  114. package/dist/interfaces/indis.d.ts +31 -0
  115. package/dist/interfaces/indis.d.ts.map +1 -0
  116. package/dist/interfaces/indis.js +1 -0
  117. package/dist/interfaces/list.d.ts +52 -0
  118. package/dist/interfaces/list.d.ts.map +1 -0
  119. package/dist/interfaces/list.js +1 -0
  120. package/dist/interfaces/obje.d.ts +7 -0
  121. package/dist/interfaces/obje.d.ts.map +1 -0
  122. package/dist/interfaces/obje.js +1 -0
  123. package/dist/interfaces/repo.d.ts +7 -0
  124. package/dist/interfaces/repo.d.ts.map +1 -0
  125. package/dist/interfaces/repo.js +1 -0
  126. package/dist/interfaces/sour.d.ts +7 -0
  127. package/dist/interfaces/sour.d.ts.map +1 -0
  128. package/dist/interfaces/sour.js +1 -0
  129. package/dist/interfaces/subm.d.ts +6 -0
  130. package/dist/interfaces/subm.d.ts.map +1 -0
  131. package/dist/interfaces/subm.js +1 -0
  132. package/dist/kinship-translator/index.d.ts +11 -0
  133. package/dist/kinship-translator/index.d.ts.map +1 -0
  134. package/dist/kinship-translator/index.js +10 -0
  135. package/dist/kinship-translator/kinship-translator.basic.d.ts +30 -0
  136. package/dist/kinship-translator/kinship-translator.basic.d.ts.map +1 -0
  137. package/dist/kinship-translator/kinship-translator.basic.js +74 -0
  138. package/dist/kinship-translator/kinship-translator.d.ts +26 -0
  139. package/dist/kinship-translator/kinship-translator.d.ts.map +1 -0
  140. package/dist/kinship-translator/kinship-translator.de.d.ts +18 -0
  141. package/dist/kinship-translator/kinship-translator.de.d.ts.map +1 -0
  142. package/dist/kinship-translator/kinship-translator.de.js +180 -0
  143. package/dist/kinship-translator/kinship-translator.en.d.ts +18 -0
  144. package/dist/kinship-translator/kinship-translator.en.d.ts.map +1 -0
  145. package/dist/kinship-translator/kinship-translator.en.js +182 -0
  146. package/dist/kinship-translator/kinship-translator.es.d.ts +18 -0
  147. package/dist/kinship-translator/kinship-translator.es.d.ts.map +1 -0
  148. package/dist/kinship-translator/kinship-translator.es.js +181 -0
  149. package/dist/kinship-translator/kinship-translator.fr.d.ts +18 -0
  150. package/dist/kinship-translator/kinship-translator.fr.d.ts.map +1 -0
  151. package/dist/kinship-translator/kinship-translator.fr.js +181 -0
  152. package/dist/kinship-translator/kinship-translator.hu.d.ts +19 -0
  153. package/dist/kinship-translator/kinship-translator.hu.d.ts.map +1 -0
  154. package/dist/kinship-translator/kinship-translator.hu.js +226 -0
  155. package/dist/kinship-translator/kinship-translator.interface.d.ts +19 -0
  156. package/dist/kinship-translator/kinship-translator.interface.d.ts.map +1 -0
  157. package/dist/kinship-translator/kinship-translator.interface.js +1 -0
  158. package/dist/kinship-translator/kinship-translator.js +103 -0
  159. package/dist/kinship-translator/patterns.de.d.ts +2 -0
  160. package/dist/kinship-translator/patterns.de.d.ts.map +1 -0
  161. package/dist/kinship-translator/patterns.de.js +14 -0
  162. package/dist/kinship-translator/patterns.en.d.ts +2 -0
  163. package/dist/kinship-translator/patterns.en.d.ts.map +1 -0
  164. package/dist/kinship-translator/patterns.en.js +14 -0
  165. package/dist/kinship-translator/patterns.es.d.ts +2 -0
  166. package/dist/kinship-translator/patterns.es.d.ts.map +1 -0
  167. package/dist/kinship-translator/patterns.es.js +14 -0
  168. package/dist/kinship-translator/patterns.fr.d.ts +2 -0
  169. package/dist/kinship-translator/patterns.fr.d.ts.map +1 -0
  170. package/dist/kinship-translator/patterns.fr.js +14 -0
  171. package/dist/kinship-translator/patterns.hu.d.ts +6 -0
  172. package/dist/kinship-translator/patterns.hu.d.ts.map +1 -0
  173. package/dist/kinship-translator/patterns.hu.js +97 -0
  174. package/dist/kinship-translator/translators.d.ts +6 -0
  175. package/dist/kinship-translator/translators.d.ts.map +1 -0
  176. package/dist/kinship-translator/translators.js +5 -0
  177. package/dist/kinship-translator/types.d.ts +9 -0
  178. package/dist/kinship-translator/types.d.ts.map +1 -0
  179. package/dist/kinship-translator/types.js +1 -0
  180. package/dist/structures/address.d.ts +14 -0
  181. package/dist/structures/address.d.ts.map +1 -0
  182. package/dist/structures/address.js +1 -0
  183. package/dist/structures/association.d.ts +13 -0
  184. package/dist/structures/association.d.ts.map +1 -0
  185. package/dist/structures/association.js +1 -0
  186. package/dist/structures/change-date.d.ts +8 -0
  187. package/dist/structures/change-date.d.ts.map +1 -0
  188. package/dist/structures/change-date.js +1 -0
  189. package/dist/structures/creation-date.d.ts +7 -0
  190. package/dist/structures/creation-date.d.ts.map +1 -0
  191. package/dist/structures/creation-date.js +1 -0
  192. package/dist/structures/date.d.ts +9 -0
  193. package/dist/structures/date.d.ts.map +1 -0
  194. package/dist/structures/date.js +1 -0
  195. package/dist/structures/event-detail-structure.d.ts +25 -0
  196. package/dist/structures/event-detail-structure.d.ts.map +1 -0
  197. package/dist/structures/event-detail-structure.js +1 -0
  198. package/dist/structures/family.d.ts +34 -0
  199. package/dist/structures/family.d.ts.map +1 -0
  200. package/dist/structures/family.js +1 -0
  201. package/dist/structures/gedcom.d.ts +60 -0
  202. package/dist/structures/gedcom.d.ts.map +1 -0
  203. package/dist/structures/gedcom.js +1 -0
  204. package/dist/structures/index.d.ts +25 -0
  205. package/dist/structures/index.d.ts.map +1 -0
  206. package/dist/structures/index.js +1 -0
  207. package/dist/structures/individual-event-detail-structure.d.ts +9 -0
  208. package/dist/structures/individual-event-detail-structure.d.ts.map +1 -0
  209. package/dist/structures/individual-event-detail-structure.js +1 -0
  210. package/dist/structures/individual-event-structure.d.ts +83 -0
  211. package/dist/structures/individual-event-structure.d.ts.map +1 -0
  212. package/dist/structures/individual-event-structure.js +1 -0
  213. package/dist/structures/individual.d.ts +40 -0
  214. package/dist/structures/individual.d.ts.map +1 -0
  215. package/dist/structures/individual.js +1 -0
  216. package/dist/structures/lds-ordinance-detail.d.ts +17 -0
  217. package/dist/structures/lds-ordinance-detail.d.ts.map +1 -0
  218. package/dist/structures/lds-ordinance-detail.js +1 -0
  219. package/dist/structures/lds-spouse-sealing.d.ts +7 -0
  220. package/dist/structures/lds-spouse-sealing.d.ts.map +1 -0
  221. package/dist/structures/lds-spouse-sealing.js +1 -0
  222. package/dist/structures/marriage-date.d.ts +11 -0
  223. package/dist/structures/marriage-date.d.ts.map +1 -0
  224. package/dist/structures/marriage-date.js +1 -0
  225. package/dist/structures/multimedia-link.d.ts +16 -0
  226. package/dist/structures/multimedia-link.d.ts.map +1 -0
  227. package/dist/structures/multimedia-link.js +1 -0
  228. package/dist/structures/non-event.d.ts +12 -0
  229. package/dist/structures/non-event.d.ts.map +1 -0
  230. package/dist/structures/non-event.js +1 -0
  231. package/dist/structures/note.d.ts +16 -0
  232. package/dist/structures/note.d.ts.map +1 -0
  233. package/dist/structures/note.js +1 -0
  234. package/dist/structures/personal-name-pieces.d.ts +11 -0
  235. package/dist/structures/personal-name-pieces.d.ts.map +1 -0
  236. package/dist/structures/personal-name-pieces.js +1 -0
  237. package/dist/structures/personal-name.d.ts +16 -0
  238. package/dist/structures/personal-name.d.ts.map +1 -0
  239. package/dist/structures/personal-name.js +1 -0
  240. package/dist/structures/place.d.ts +20 -0
  241. package/dist/structures/place.d.ts.map +1 -0
  242. package/dist/structures/place.js +1 -0
  243. package/dist/structures/repository.d.ts +6 -0
  244. package/dist/structures/repository.d.ts.map +1 -0
  245. package/dist/structures/repository.js +1 -0
  246. package/dist/structures/source-citation.d.ts +27 -0
  247. package/dist/structures/source-citation.d.ts.map +1 -0
  248. package/dist/structures/source-citation.js +1 -0
  249. package/dist/structures/source-repository-citation.d.ts +13 -0
  250. package/dist/structures/source-repository-citation.d.ts.map +1 -0
  251. package/dist/structures/source-repository-citation.js +1 -0
  252. package/dist/structures/source.d.ts +28 -0
  253. package/dist/structures/source.d.ts.map +1 -0
  254. package/dist/structures/source.js +1 -0
  255. package/dist/types/ancestry-media.d.ts +65 -0
  256. package/dist/types/ancestry-media.d.ts.map +1 -0
  257. package/dist/types/ancestry-media.js +1 -0
  258. package/dist/types/index.d.ts +4 -0
  259. package/dist/types/index.d.ts.map +1 -0
  260. package/dist/types/index.js +4 -0
  261. package/dist/types/settings.d.ts +12 -0
  262. package/dist/types/settings.d.ts.map +1 -0
  263. package/dist/types/settings.js +1 -0
  264. package/dist/types/types.d.ts +220 -0
  265. package/dist/types/types.d.ts.map +1 -0
  266. package/dist/types/types.js +26 -0
  267. package/dist/utils/cache.d.ts +22 -0
  268. package/dist/utils/cache.d.ts.map +1 -0
  269. package/dist/utils/cache.js +57 -0
  270. package/dist/utils/common-creator.d.ts +13 -0
  271. package/dist/utils/common-creator.d.ts.map +1 -0
  272. package/dist/utils/common-creator.js +72 -0
  273. package/dist/utils/date-formatter.d.ts +35 -0
  274. package/dist/utils/date-formatter.d.ts.map +1 -0
  275. package/dist/utils/date-formatter.js +207 -0
  276. package/dist/utils/get-all-prop.d.ts +4 -0
  277. package/dist/utils/get-all-prop.d.ts.map +1 -0
  278. package/dist/utils/get-all-prop.js +5 -0
  279. package/dist/utils/get-family-with.d.ts +5 -0
  280. package/dist/utils/get-family-with.d.ts.map +1 -0
  281. package/dist/utils/get-family-with.js +11 -0
  282. package/dist/utils/get-places.d.ts +21 -0
  283. package/dist/utils/get-places.d.ts.map +1 -0
  284. package/dist/utils/get-places.js +77 -0
  285. package/dist/utils/get-product-details.d.ts +4 -0
  286. package/dist/utils/get-product-details.d.ts.map +1 -0
  287. package/dist/utils/get-product-details.js +6 -0
  288. package/dist/utils/get-raw-size.d.ts +2 -0
  289. package/dist/utils/get-raw-size.d.ts.map +1 -0
  290. package/dist/utils/get-raw-size.js +3 -0
  291. package/dist/utils/index.d.ts +17 -0
  292. package/dist/utils/index.d.ts.map +1 -0
  293. package/dist/utils/index.js +18 -0
  294. package/dist/utils/logger.d.ts +3 -0
  295. package/dist/utils/logger.d.ts.map +1 -0
  296. package/dist/utils/logger.js +11 -0
  297. package/dist/utils/name-formatter.d.ts +10 -0
  298. package/dist/utils/name-formatter.d.ts.map +1 -0
  299. package/dist/utils/name-formatter.js +45 -0
  300. package/dist/utils/nested-group.d.ts +4 -0
  301. package/dist/utils/nested-group.d.ts.map +1 -0
  302. package/dist/utils/nested-group.js +34 -0
  303. package/dist/utils/ordinalize.d.ts +3 -0
  304. package/dist/utils/ordinalize.d.ts.map +1 -0
  305. package/dist/utils/ordinalize.js +104 -0
  306. package/dist/utils/parser.d.ts +17 -0
  307. package/dist/utils/parser.d.ts.map +1 -0
  308. package/dist/utils/parser.js +322 -0
  309. package/dist/utils/place-parser.d.ts +16 -0
  310. package/dist/utils/place-parser.d.ts.map +1 -0
  311. package/dist/utils/place-parser.js +46 -0
  312. package/dist/utils/place-translator.d.ts +6 -0
  313. package/dist/utils/place-translator.d.ts.map +1 -0
  314. package/dist/utils/place-translator.js +8 -0
  315. package/dist/utils/place-types.d.ts +27 -0
  316. package/dist/utils/place-types.d.ts.map +1 -0
  317. package/dist/utils/place-types.js +14 -0
  318. package/dist/utils/range.d.ts +19 -0
  319. package/dist/utils/range.d.ts.map +1 -0
  320. package/dist/utils/range.js +265 -0
  321. package/package.json +153 -0
@@ -0,0 +1,11 @@
1
+ /* eslint-disable no-console */
2
+ /* eslint-disable @typescript-eslint/no-explicit-any */
3
+ const debugAll = false;
4
+ const debugError = true;
5
+ export const implemented = (type, ...args) => {
6
+ debugAll && console.info(`[Implemented] ${type}`, ...args);
7
+ };
8
+ export const notImplemented = (type, ...args) => {
9
+ (debugAll || debugError) &&
10
+ console.error(`[Not Implemented] ${type}`, ...args);
11
+ };
@@ -0,0 +1,10 @@
1
+ import { type IndiType } from "../classes/indi";
2
+ import type { Settings } from "../types/settings";
3
+ export declare const nameFormatter: (indiName?: IndiType | string, settings?: Partial<Settings>, letterOnAll?: boolean, indi?: IndiType, debug?: 3) => {
4
+ suffix: string;
5
+ givenname: string;
6
+ surname: string;
7
+ inOrder: [string, string, string];
8
+ letter: string;
9
+ };
10
+ //# sourceMappingURL=name-formatter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"name-formatter.d.ts","sourceRoot":"","sources":["../../src/utils/name-formatter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAEtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAElD,eAAO,MAAM,aAAa,GACzB,WAAW,QAAQ,GAAG,MAAM,EAC5B,WAAW,OAAO,CAAC,QAAQ,CAAC,EAC5B,qBAAkB,EAClB,OAAO,QAAQ,EACf,QAAQ,CAAC;;;;;;CAyDT,CAAC"}
@@ -0,0 +1,45 @@
1
+ import { Indi } from "../classes/indi";
2
+ import { createCommonName } from "../classes/name";
3
+ export const nameFormatter = (indiName, settings, letterOnAll = true, indi, debug) => {
4
+ const { nameOrder = "first-last", maxGivennames = 0, maxSurnames = 0, } = settings ?? {};
5
+ const rawName = indiName instanceof Indi
6
+ ? indiName?.NAME
7
+ : createCommonName(undefined, undefined, indi).name(indiName);
8
+ const name = rawName?.toList().index(0);
9
+ let givenname = name?.GIVN?.toValueList().first()?.value || "";
10
+ let surname = name?.SURN?.toValueList().first()?.value || "";
11
+ let suffix = name?.NSFX?.toValueList().first()?.value || "";
12
+ const displayedName = name?.DISPLAY?.toValueList().first()?.value || "";
13
+ if (!givenname && !surname) {
14
+ givenname = displayedName;
15
+ }
16
+ if (maxGivennames > 0) {
17
+ givenname = givenname.split(" ").slice(0, maxGivennames).join(" ");
18
+ }
19
+ if (maxSurnames > 0) {
20
+ surname = surname.split(" ").slice(0, maxSurnames).join(" ");
21
+ }
22
+ if (debug) {
23
+ suffix = suffix || "Dr";
24
+ for (let i = 1; i < debug; i++) {
25
+ givenname = `${givenname} ${givenname}`;
26
+ surname = `${surname} ${surname}`;
27
+ }
28
+ }
29
+ const inOrder = [
30
+ suffix,
31
+ ...(nameOrder === "last-first"
32
+ ? [surname, givenname]
33
+ : [givenname, surname]),
34
+ ];
35
+ const lName = (letterOnAll
36
+ ? [inOrder[1], inOrder[2]].filter(Boolean).join(" ")
37
+ : inOrder[1]).toLowerCase();
38
+ const firstLetter = lName.match(/^(dzs|cs|dz|gy|ly|ny|sz|ty|zs|\w)/i)?.[0] ??
39
+ lName.substring(0, 1) ??
40
+ "";
41
+ const validFirstLetter = `${firstLetter
42
+ .substring(0, 1)
43
+ .toUpperCase()}${firstLetter.substring(1)}`;
44
+ return { suffix, givenname, surname, inOrder, letter: validFirstLetter };
45
+ };
@@ -0,0 +1,4 @@
1
+ import type { Individuals } from "../classes/indis";
2
+ import type { NestedGroup } from "../types/types";
3
+ export declare const setNestedGroup: (obj: NestedGroup, key: string | string[], value: Individuals, uniqueCounting?: boolean) => void;
4
+ //# sourceMappingURL=nested-group.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nested-group.d.ts","sourceRoot":"","sources":["../../src/utils/nested-group.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAKlD,eAAO,MAAM,cAAc,GAC1B,KAAK,WAAW,EAChB,KAAK,MAAM,GAAG,MAAM,EAAE,EACtB,OAAO,WAAW,EAClB,wBAAqB,SAmCrB,CAAC"}
@@ -0,0 +1,34 @@
1
+ import get from "lodash/get";
2
+ import set from "lodash/set";
3
+ import { Individuals as IndividualsClass } from "../classes/indis";
4
+ // Use a WeakMap to track unique items for each node without polluting the object
5
+ const uniqueItemsCache = new WeakMap();
6
+ export const setNestedGroup = (obj, key, value, uniqueCounting = true) => {
7
+ const parts = Array.isArray(key) ? key : key.split(/,\s*/);
8
+ // Set items only at the leaf level (deepest level of this path)
9
+ set(obj, [...parts, "items"], value);
10
+ // Update lengths at all parent levels by tracking unique items incrementally
11
+ parts.forEach((_, index) => {
12
+ if (!uniqueCounting) {
13
+ // If not unique counting, simply set the length to the number of items at this level
14
+ const key = [...parts.toSpliced(index + 1), "length"];
15
+ const length = get(obj, key);
16
+ set(obj, key, (length ?? 0) + value.length);
17
+ return;
18
+ }
19
+ const pathKey = [...parts.toSpliced(index + 1)];
20
+ const node = get(obj, pathKey);
21
+ if (node) {
22
+ // Get or create the unique items collection for this node
23
+ let uniqueItems = uniqueItemsCache.get(node);
24
+ if (!uniqueItems) {
25
+ uniqueItems = new IndividualsClass();
26
+ uniqueItemsCache.set(node, uniqueItems);
27
+ }
28
+ // Merge the new items to track unique individuals
29
+ uniqueItems.merge(value);
30
+ // Update the length to be the count of unique items
31
+ set(obj, [...pathKey, "length"], uniqueItems.length);
32
+ }
33
+ });
34
+ };
@@ -0,0 +1,3 @@
1
+ export declare const ordinalize: (n: number) => string;
2
+ export declare const hungarianOrdinalize: (n: number) => string;
3
+ //# sourceMappingURL=ordinalize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ordinalize.d.ts","sourceRoot":"","sources":["../../src/utils/ordinalize.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,GAAI,GAAG,MAAM,KAAG,MAsBtC,CAAC;AAeF,eAAO,MAAM,mBAAmB,GAAI,GAAG,MAAM,WAqF5C,CAAC"}
@@ -0,0 +1,104 @@
1
+ export const ordinalize = (n) => {
2
+ const num = Math.round(n);
3
+ const numString = num.toString();
4
+ // If the ten's place is 1, the suffix is always "th"
5
+ // (10th, 11th, 12th, 13th, 14th, 111th, 112th, etc.)
6
+ if (Math.floor(num / 10) % 10 === 1) {
7
+ return numString + "th";
8
+ }
9
+ // Otherwise, the suffix depends on the one's place as follows
10
+ // (1st, 2nd, 3rd, 4th, 21st, 22nd, etc.)
11
+ switch (num % 10) {
12
+ case 1:
13
+ return numString + "st";
14
+ case 2:
15
+ return numString + "nd";
16
+ case 3:
17
+ return numString + "rd";
18
+ default:
19
+ return numString + "th";
20
+ }
21
+ };
22
+ export const hungarianOrdinalize = (n) => {
23
+ const numberPrefix = [
24
+ "",
25
+ "",
26
+ "két",
27
+ "három",
28
+ "négy",
29
+ "öt",
30
+ "hat",
31
+ "hét",
32
+ "nyolc",
33
+ "kilenc",
34
+ ];
35
+ const ordinals = [
36
+ [
37
+ "",
38
+ ["első", "egyed"],
39
+ ["másod", "ketted"],
40
+ "harmad",
41
+ "negyed",
42
+ "ötöd",
43
+ "hatod",
44
+ "heted",
45
+ "nyolcad",
46
+ "kilenced",
47
+ ],
48
+ [
49
+ "",
50
+ ["tized", "tizen"],
51
+ ["huszad", "huszon"],
52
+ "harmincad",
53
+ "negyvened",
54
+ "ötvened",
55
+ "hatvanad",
56
+ "hetvened",
57
+ "nyolcvanad",
58
+ "kilencvened",
59
+ ],
60
+ "század",
61
+ ["ezred", "ezer"],
62
+ ];
63
+ const parts = [];
64
+ let fractionIndex = 0;
65
+ let fractions = 1;
66
+ let nr = Math.abs(n);
67
+ let part;
68
+ do {
69
+ const nextFractions = fractions * 10;
70
+ const index = fractions > 1
71
+ ? (nr % nextFractions) / fractions
72
+ : nr % nextFractions;
73
+ const ordinalList = ordinals[fractionIndex++];
74
+ if (typeof ordinalList === "string") {
75
+ part = `${numberPrefix[index]}${ordinalList}`;
76
+ }
77
+ else if (ordinalList.length === 2) {
78
+ part = ordinalList;
79
+ }
80
+ else {
81
+ part = ordinalList?.[index];
82
+ }
83
+ if (Array.isArray(part)) {
84
+ if (fractions === 1) {
85
+ part = part[nr < 10 ? 0 : 1];
86
+ }
87
+ else {
88
+ part = part[n % 10 === 0 ? 0 : 1];
89
+ }
90
+ }
91
+ else if (fractions > 1 && n % 10 !== 0) {
92
+ part = part?.substring(0, part.length - 2);
93
+ }
94
+ if (part !== undefined) {
95
+ parts.unshift(part);
96
+ }
97
+ fractions = nextFractions;
98
+ nr = Math.floor(nr / nextFractions) * nextFractions;
99
+ if (nr < nextFractions) {
100
+ break;
101
+ }
102
+ } while (part !== undefined);
103
+ return parts.join("");
104
+ };
@@ -0,0 +1,17 @@
1
+ import { Common } from "../classes/common";
2
+ import type { Settings } from "../types/settings";
3
+ import { type MultiTag } from "../types/types";
4
+ declare const GedcomTree: {
5
+ parse: (content: string, options?: {
6
+ settings?: Settings;
7
+ }) => any;
8
+ parseHierarchy: (content: string, options?: {
9
+ settings?: Settings;
10
+ }) => {
11
+ gedcom: import("../classes/gedcom").GedComType;
12
+ raw: string;
13
+ };
14
+ addToList: (id: string, type: MultiTag, common: Common, prev: Common) => void;
15
+ };
16
+ export default GedcomTree;
17
+ //# sourceMappingURL=parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/utils/parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAoB,MAAM,mBAAmB,CAAC;AAgB7D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAiC,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAuD9E,QAAA,MAAM,UAAU;qBACW,MAAM,YAAY;QAAE,QAAQ,CAAC,EAAE,QAAQ,CAAA;KAAE;8BAIzD,MAAM,YACL;QAAE,QAAQ,CAAC,EAAE,QAAQ,CAAA;KAAE;;;;oBAuQ7B,MAAM,QACJ,QAAQ,UACN,MAAM,QACR,MAAM;CAuBb,CAAC;AAOF,eAAe,UAAU,CAAC"}
@@ -0,0 +1,322 @@
1
+ import { Common, getListTag, isId } from "../classes/common";
2
+ import { Families } from "../classes/fams";
3
+ import { createGedCom } from "../classes/gedcom";
4
+ import { Indi } from "../classes/indi";
5
+ import { Individuals } from "../classes/indis";
6
+ import { List } from "../classes/list";
7
+ import { Objects } from "../classes/objes";
8
+ import { Repositories } from "../classes/repos";
9
+ import { Sources } from "../classes/sours";
10
+ import { Submitters } from "../classes/subms";
11
+ import { LINE_REG, MAX_FILE_SIZE_TO_SYNC, REF_LINE_REG, } from "../constants/constants";
12
+ import { create } from "./common-creator";
13
+ import { isDevelopment } from "./get-product-details";
14
+ import { getRawSize } from "./get-raw-size";
15
+ const isDev = isDevelopment();
16
+ // let lastTime: number | undefined;
17
+ // interface Props {
18
+ // index:
19
+ // | number
20
+ // | `${number}.${number}`
21
+ // | `${number}.${number}.${number}`
22
+ // | `${number}.${number}.${number}.${number}`;
23
+ // label?: string;
24
+ // lastTime?: number;
25
+ // }
26
+ // const printTime = (
27
+ // {
28
+ // index,
29
+ // label = "RunTimeTest",
30
+ // lastTime: lastTimeProp,
31
+ // // eslint-disable-next-line @typescript-eslint/no-explicit-any
32
+ // }: Props,
33
+ // ...args: any[]
34
+ // ) => {
35
+ // // if (!isDev) {
36
+ // // return;
37
+ // // }
38
+ // if (lastTimeProp !== undefined) {
39
+ // lastTime = lastTimeProp;
40
+ // }
41
+ // const date = Date.now();
42
+ // const diff = lastTime === undefined ? "Not provided" : date - lastTime;
43
+ // const func = (
44
+ // diff === "Not provided" || diff <= 150
45
+ // ? console.log
46
+ // : diff > 500
47
+ // ? console.error
48
+ // : console.warn
49
+ // ).bind(console);
50
+ // func(
51
+ // label,
52
+ // {
53
+ // index,
54
+ // date,
55
+ // diff,
56
+ // },
57
+ // ...args
58
+ // );
59
+ // lastTime = date;
60
+ // };
61
+ const GedcomTree = {
62
+ parse: function (content, options) {
63
+ return this.parseHierarchy(content, options);
64
+ },
65
+ parseHierarchy: function (content, options) {
66
+ // printTime{ index: 0, label: "[Debug]", lastTime: Date.now() });
67
+ const { settings } = options ?? {};
68
+ const { linkedPersons = "skip", linkingKey } = settings ?? {};
69
+ const gedcom = createGedCom();
70
+ gedcom.removeValue();
71
+ const reg = LINE_REG;
72
+ let key;
73
+ let type;
74
+ let idCheck;
75
+ let value;
76
+ let indent = 0;
77
+ let prevIndent = 0;
78
+ let curNode = gedcom;
79
+ let prevNode;
80
+ let mainNode;
81
+ const curPar = [];
82
+ // printTime{ index: 1, label: "[Debug]" });
83
+ let prevLineIndent = 0;
84
+ let prevRefLines;
85
+ let prevLines;
86
+ const refMatch = content.match(REF_LINE_REG);
87
+ // printTime{ index: 2, label: "[Debug]" });
88
+ const refs = refMatch && Array.isArray(refMatch)
89
+ ? refMatch.reduce((acc, curr) => {
90
+ const [_refIndent, refId, refType] = curr.split(" ");
91
+ if (refId && refType) {
92
+ acc[refId] = refType.toUpperCase();
93
+ }
94
+ return acc;
95
+ }, {})
96
+ : {};
97
+ const links = new Individuals();
98
+ const tags = [];
99
+ // printTime{ index: 3, label: "[Debug]" });
100
+ let lines = `${content.replace(/\n0 TRLR(\r?\n)*$/, "")}\n0 TRLR\n`
101
+ .split(/\r?\n/)
102
+ .reduce((acc, line) => {
103
+ const lineMatch = line.match(LINE_REG);
104
+ if (lineMatch) {
105
+ const lineIndent = Number(lineMatch?.groups?.indent ?? 0);
106
+ const lineValue = lineMatch?.groups?.value ?? "";
107
+ if (lineIndent > 0 &&
108
+ lineIndent > prevLineIndent &&
109
+ lineValue &&
110
+ isId(lineValue)) {
111
+ const refLines = lineValue
112
+ .split(/,\s*/)
113
+ .map((id) => line.replace(lineValue, id));
114
+ if (refLines.length > 1) {
115
+ prevLineIndent = lineIndent;
116
+ prevRefLines = refLines;
117
+ }
118
+ else {
119
+ acc.push(line);
120
+ }
121
+ }
122
+ else {
123
+ if (prevRefLines) {
124
+ if (lineIndent > prevLineIndent) {
125
+ if (!prevLines) {
126
+ prevLines = [];
127
+ }
128
+ prevLines.push(line);
129
+ }
130
+ else {
131
+ prevRefLines.forEach((prevRefLine) => {
132
+ acc.push(prevRefLine, ...(prevLines ?? []));
133
+ });
134
+ prevLineIndent = 0;
135
+ prevRefLines = undefined;
136
+ prevLines = undefined;
137
+ acc.push(line);
138
+ }
139
+ }
140
+ else {
141
+ acc.push(line);
142
+ }
143
+ }
144
+ }
145
+ else {
146
+ if (acc[acc.length - 1] !== undefined) {
147
+ acc[acc.length - 1] = `${acc[acc.length - 1]}${line}`;
148
+ }
149
+ }
150
+ return acc;
151
+ }, []);
152
+ let linesJoined = lines.join("\n");
153
+ // printTime{ index: 4, label: "[Debug]" }, { lines: lines.join("\n") });
154
+ if (!linesJoined.includes("1 _IS_PURGED true") &&
155
+ getRawSize(linesJoined) > MAX_FILE_SIZE_TO_SYNC) {
156
+ linesJoined = linesJoined
157
+ .replace(/1\s(NOTE|OBJE|SOUR)([^\n]*\n)([23456789]\s.+\n)*/gm, "")
158
+ .replace(/0\s(@[^@]+@)(\sSOUR[^\n]*\n)([123456789]\s.+\n)*/, "")
159
+ .replace(/0 HEAD(.*)\n/, "0 HEAD$1\n1 _IS_PURGED true\n");
160
+ lines = linesJoined.split("\n");
161
+ // printTime{ index: 6, label: "[Debug]" }, { lines: lines.join("\n") });
162
+ }
163
+ lines.forEach((line, index) => {
164
+ if (line.length === 0) {
165
+ return; // skip empty
166
+ }
167
+ const match = reg.exec(line);
168
+ if (match?.[1] === undefined) {
169
+ throw new Error(`Can't parse line #${index}: ${line}`);
170
+ }
171
+ try {
172
+ indent = Number(match[1]);
173
+ if (indent > prevIndent + 1) {
174
+ indent = prevIndent + 1;
175
+ }
176
+ if (match?.[2] !== undefined) {
177
+ key = match?.[3] + match?.[2];
178
+ }
179
+ else {
180
+ key = match?.[3];
181
+ }
182
+ value = match?.[4];
183
+ [type, idCheck] = (key?.split("@") ?? []);
184
+ type = type?.toUpperCase();
185
+ const id = idCheck ? `@${idCheck}@` : undefined;
186
+ if (indent > prevIndent) {
187
+ curPar.push(curNode);
188
+ curNode = prevNode;
189
+ }
190
+ else if (indent < prevIndent) {
191
+ for (let i = 0; i < prevIndent - indent; ++i) {
192
+ curNode = curPar.pop();
193
+ }
194
+ }
195
+ const newCommon = create(gedcom, type, id, {
196
+ mainNode,
197
+ curNode,
198
+ prevNode,
199
+ });
200
+ prevNode = newCommon.prevNode;
201
+ mainNode = newCommon.mainNode;
202
+ if (prevNode instanceof Common) {
203
+ if (mainNode instanceof Indi && type === "_MTTAG") {
204
+ tags.push(prevNode);
205
+ }
206
+ if (value) {
207
+ prevNode.value = value;
208
+ if (isId(value) && refs[value]) {
209
+ prevNode.refType = refs[value];
210
+ mainNode?.addRef(prevNode);
211
+ if (linkingKey &&
212
+ linkingKey === type &&
213
+ curNode instanceof Indi &&
214
+ curNode?.id) {
215
+ links.item(curNode.id, curNode);
216
+ }
217
+ }
218
+ }
219
+ else {
220
+ prevNode.removeValue();
221
+ }
222
+ }
223
+ if (type && type !== "value") {
224
+ const curCommon = curNode;
225
+ if (id) {
226
+ this.addToList(id, type, curCommon, prevNode);
227
+ }
228
+ else {
229
+ curCommon.assign(type, prevNode);
230
+ }
231
+ }
232
+ prevIndent = indent;
233
+ }
234
+ catch (err) {
235
+ console.log("ASDXX", err);
236
+ throw new Error(`Can't parse line #${index}: ${line}`, {
237
+ cause: err,
238
+ });
239
+ }
240
+ });
241
+ if (tags.length) {
242
+ gedcom.tagMembers = tags.reduce((acc, tag) => {
243
+ const tagName = tag?.get("NAME")?.toValue();
244
+ if (!tagName ||
245
+ !tag?.ref ||
246
+ !tag?.main ||
247
+ !(tag.main instanceof Indi)) {
248
+ return acc;
249
+ }
250
+ if (!acc[tagName]) {
251
+ acc[tagName] = {
252
+ tag: tag.ref,
253
+ indis: new Individuals(),
254
+ };
255
+ }
256
+ acc[tagName].indis.append(tag.main);
257
+ return acc;
258
+ }, {});
259
+ }
260
+ try {
261
+ if ("@@INDI" in gedcom) {
262
+ gedcom["@@INDI"] = gedcom["@@INDI"]?.filter((item) => {
263
+ return !item.isIgnoredMember();
264
+ });
265
+ }
266
+ }
267
+ catch (err) {
268
+ throw new Error(`Malformed GEDCOM`, {
269
+ cause: err,
270
+ });
271
+ }
272
+ if (linkingKey) {
273
+ links.forEach((linkingIndi, _linkingId) => {
274
+ const linking = linkingIndi;
275
+ const linked = linking?.get(linkingKey)
276
+ ?.ref;
277
+ if (!linking) {
278
+ return;
279
+ }
280
+ if (linkedPersons === "merge") {
281
+ gedcom.mergeIndis(linked, linking);
282
+ }
283
+ else if (linkedPersons === "clone") {
284
+ gedcom.cloneIndis(linked, linking, ["FAMS"]);
285
+ }
286
+ });
287
+ }
288
+ return { gedcom, raw: linesJoined };
289
+ },
290
+ addToList: function (id, type, common, prev) {
291
+ const listTag = getListTag(type);
292
+ let curValue = common.get(listTag);
293
+ if (type === "INDI" || type === "_INDI") {
294
+ curValue = curValue || new Individuals();
295
+ }
296
+ else if (type === "FAM") {
297
+ curValue = curValue || new Families();
298
+ }
299
+ else if (type === "OBJE") {
300
+ curValue = curValue || new Objects();
301
+ }
302
+ else if (type === "REPO") {
303
+ curValue = curValue || new Repositories();
304
+ }
305
+ else if (type === "SUBM") {
306
+ curValue = curValue || new Submitters();
307
+ }
308
+ else if (type === "SOUR") {
309
+ curValue = curValue || new Sources();
310
+ }
311
+ else {
312
+ curValue = curValue || new List();
313
+ }
314
+ common.set(listTag, curValue);
315
+ curValue.item(id, prev);
316
+ },
317
+ };
318
+ if (isDev) {
319
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
320
+ globalThis.GedcomTree = GedcomTree;
321
+ }
322
+ export default GedcomTree;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Minimal place parsing stub for gedcom-parser
3
+ * This is a simplified version - consumer apps can implement full place parsing if needed
4
+ */
5
+ export interface PlaceParts {
6
+ leftParts?: string[];
7
+ town?: string;
8
+ county?: string;
9
+ country?: string;
10
+ }
11
+ /**
12
+ * Simple place parser - splits by commas
13
+ * Consumer apps can implement more sophisticated parsing if needed
14
+ */
15
+ export declare const getPlaceParts: (place?: string | (string | undefined)[]) => PlaceParts[];
16
+ //# sourceMappingURL=place-parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"place-parser.d.ts","sourceRoot":"","sources":["../../src/utils/place-parser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,UAAU;IAC1B,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,eAAO,MAAM,aAAa,GACzB,QAAO,MAAM,GAAG,CAAC,MAAM,GAAG,SAAS,CAAC,EAAO,KACzC,UAAU,EAwCZ,CAAC"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Minimal place parsing stub for gedcom-parser
3
+ * This is a simplified version - consumer apps can implement full place parsing if needed
4
+ */
5
+ /**
6
+ * Simple place parser - splits by commas
7
+ * Consumer apps can implement more sophisticated parsing if needed
8
+ */
9
+ export const getPlaceParts = (place = []) => {
10
+ const partsString = Array.isArray(place)
11
+ ? place.filter(Boolean).join(", ")
12
+ : place;
13
+ if (!partsString) {
14
+ return [{}];
15
+ }
16
+ // Simple split by comma
17
+ const parts = partsString
18
+ .split(/,\s*/)
19
+ .map((p) => p.trim())
20
+ .filter(Boolean);
21
+ if (parts.length === 0) {
22
+ return [{}];
23
+ }
24
+ // Simple heuristic: last part is country, second-to-last is county, rest is town/city
25
+ const result = {};
26
+ if (parts.length === 1) {
27
+ result.town = parts[0];
28
+ }
29
+ else if (parts.length === 2) {
30
+ result.town = parts[0];
31
+ result.country = parts[1];
32
+ }
33
+ else if (parts.length === 3) {
34
+ result.town = parts[0];
35
+ result.county = parts[1];
36
+ result.country = parts[2];
37
+ }
38
+ else {
39
+ // More than 3 parts - put extras in leftParts
40
+ result.leftParts = parts.slice(0, parts.length - 3);
41
+ result.town = parts[parts.length - 3];
42
+ result.county = parts[parts.length - 2];
43
+ result.country = parts[parts.length - 1];
44
+ }
45
+ return [result];
46
+ };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Place translator stub for gedcom-parser
3
+ * This is a minimal no-op implementation - consumer apps can implement translation if needed
4
+ */
5
+ export declare const placeTranslator: (place: string | string[]) => string;
6
+ //# sourceMappingURL=place-translator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"place-translator.d.ts","sourceRoot":"","sources":["../../src/utils/place-translator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,eAAO,MAAM,eAAe,GAAI,OAAO,MAAM,GAAG,MAAM,EAAE,KAAG,MAG1D,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Place translator stub for gedcom-parser
3
+ * This is a minimal no-op implementation - consumer apps can implement translation if needed
4
+ */
5
+ export const placeTranslator = (place) => {
6
+ // No-op stub - return place as-is (join if array)
7
+ return Array.isArray(place) ? place.join(", ") : place;
8
+ };