@treeviz/familysearch-sdk 1.0.10

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.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/gedcom-converter.ts"],"names":["parentId"],"mappings":";;;AAmBA,SAAS,yBAAyB,GAAA,EAAqB;AAEtD,EAAA,IAAI,CAAC,GAAA,CAAI,QAAA,CAAS,yBAAyB,CAAA,EAAG;AAC7C,IAAA,OAAO,GAAA;AAAA,EACR;AAGA,EAAA,MAAM,QAAA,GAAW,GAAA,CAAI,KAAA,CAAM,mBAAmB,IAAI,CAAC,CAAA;AACnD,EAAA,IAAI,CAAC,QAAA,EAAU;AACd,IAAA,OAAO,GAAA;AAAA,EACR;AAGA,EAAA,IAAI,OAAA,GAAU,8BAAA;AAEd,EAAA,IACC,IAAI,QAAA,CAAS,8BAA8B,KAC3C,GAAA,CAAI,QAAA,CAAS,4BAA4B,CAAA,EACxC;AACD,IAAA,OAAA,GAAU,sCAAA;AAAA,EACX,CAAA,MAAA,IACC,IAAI,QAAA,CAAS,uBAAuB,KACpC,GAAA,CAAI,QAAA,CAAS,0BAA0B,CAAA,EACtC;AACD,IAAA,OAAA,GAAU,+BAAA;AAAA,EACX;AAEA,EAAA,OAAO,CAAA,EAAG,OAAO,CAAA,aAAA,EAAgB,QAAQ,CAAA,CAAA;AAC1C;AAsBA,SAAS,mBAAmB,GAAA,EAAqB;AAChD,EAAA,IAAI,CAAC,KAAK,OAAO,GAAA;AAGjB,EAAA,IAAI,CAAC,IAAI,QAAA,CAAS,YAAY,KAAK,GAAA,CAAI,QAAA,CAAS,MAAM,CAAA,EAAG;AACxD,IAAA,OAAO,GAAA;AAAA,EACR;AAGA,EAAA,MAAM,QAAA,GAAW,GAAA,CAAI,KAAA,CAAM,sBAAsB,CAAA;AACjD,EAAA,IAAI,CAAC,QAAA,EAAU;AACd,IAAA,OAAO,GAAA;AAAA,EACR;AAEA,EAAA,MAAM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CAAM,OAAA,CAAQ,CAAC,CAAA,KAAM;AACtB,UAAA,IAAI,CAAA,CAAE,IAAA,EAAM,QAAA,CAAS,UAAU,CAAA,EAAG;AACjC,YAAA,aAAA,CAAc,KAAK,CAAC,CAAA;AAAA,UACrB;AAAA,QACD,CAAC,CAAA;AAAA,MACF;AAAA,IACD,CAAC,CAAA;AAAA,EACF;AAGA,EAAA,aAAA,CAAc,OAAA,CAAQ,CAAC,EAAA,KAAO;AAC7B,IAAA,MAAM,SAAA,GAAY,oBAAoB,EAAE,CAAA;AACxC,IAAA,SAAA,CAAU,QAAQ,CAAC,IAAA,KAAS,KAAA,CAAM,IAAA,CAAK,IAAI,CAAC,CAAA;AAAA,EAC7C,CAAC,CAAA;AACF;AAGO,IAAM,2BAAA,GAA8B","file":"index.cjs","sourcesContent":["/**\n * FamilySearch to GEDCOM Converter\n *\n * Converts FamilySearch API responses into GEDCOM 5.5 format\n */\n\nimport type {\n\tEnhancedPedigreeData,\n\tPersonData,\n\tPersonFact,\n\tRelationship,\n\tSourceDescription,\n\tSourceReference,\n} from \"../types\";\n\n/**\n * Transform FamilySearch API URLs to web URLs\n * Supports: apibeta.familysearch.org, beta.familysearch.org, integration.familysearch.org\n */\nfunction transformFamilySearchUrl(url: string): string {\n\t// If it's not an API URL, return as-is\n\tif (!url.includes(\"/platform/tree/persons/\")) {\n\t\treturn url;\n\t}\n\n\t// Extract person ID from API URL\n\tconst personId = url.match(/persons\\/([^/?]+)/)?.[1];\n\tif (!personId) {\n\t\treturn url;\n\t}\n\n\t// Detect environment from the URL\n\tlet baseUrl = \"https://www.familysearch.org\";\n\n\tif (\n\t\turl.includes(\"integration.familysearch.org\") ||\n\t\turl.includes(\"api-integ.familysearch.org\")\n\t) {\n\t\tbaseUrl = \"https://integration.familysearch.org\";\n\t} else if (\n\t\turl.includes(\"beta.familysearch.org\") ||\n\t\turl.includes(\"apibeta.familysearch.org\")\n\t) {\n\t\tbaseUrl = \"https://beta.familysearch.org\";\n\t}\n\n\treturn `${baseUrl}/tree/person/${personId}`;\n}\n\n/**\n * Transform FamilySearch source URLs to web-accessible ARK URLs\n *\n * FamilySearch API returns source URLs in the format:\n * - https://api.familysearch.org/platform/sources/ark:/NAAN/Name\n * - https://apibeta.familysearch.org/platform/sources/ark:/NAAN/Name\n * - https://api-integ.familysearch.org/platform/sources/ark:/NAAN/Name\n *\n * These need to be transformed to web-accessible URLs:\n * - https://www.familysearch.org/ark:/NAAN/Name\n * - https://beta.familysearch.org/ark:/NAAN/Name\n * - https://integration.familysearch.org/ark:/NAAN/Name\n *\n * ARK (Archival Resource Key) format: ark:/NAAN/Name\n * - NAAN: Name Assigning Authority Number\n * - Name: Unique identifier\n *\n * @param url - FamilySearch API source URL\n * @returns Web-accessible ARK URL\n */\nfunction transformSourceUrl(url: string): string {\n\tif (!url) return url;\n\n\t// If it's already a web URL (not API URL with /platform/), return as-is\n\tif (!url.includes(\"/platform/\") && url.includes(\"ark:\")) {\n\t\treturn url;\n\t}\n\n\t// Extract ARK identifier from URL\n\tconst arkMatch = url.match(/ark:\\/[^/?]+\\/[^/?]+/);\n\tif (!arkMatch) {\n\t\treturn url;\n\t}\n\n\tconst arkId = arkMatch[0];\n\n\t// Detect environment from URL\n\tlet baseUrl = \"https://www.familysearch.org\";\n\n\tif (\n\t\turl.includes(\"integration.familysearch.org\") ||\n\t\turl.includes(\"api-integ.familysearch.org\")\n\t) {\n\t\tbaseUrl = \"https://integration.familysearch.org\";\n\t} else if (\n\t\turl.includes(\"beta.familysearch.org\") ||\n\t\turl.includes(\"apibeta.familysearch.org\")\n\t) {\n\t\tbaseUrl = \"https://beta.familysearch.org\";\n\t}\n\n\treturn `${baseUrl}/${arkId}`;\n}\n\n/**\n * Extract name from FamilySearch person\n */\nfunction extractName(person?: PersonData): string | null {\n\tif (!person) return null;\n\n\t// Try structured name\n\tif (person.names?.[0]?.nameForms?.[0]) {\n\t\tconst nameForm = person.names[0].nameForms[0];\n\n\t\t// Build from parts\n\t\tconst parts = nameForm.parts || [];\n\t\tconst given = parts.find((p) => p.type?.includes(\"Given\"))?.value || \"\";\n\t\tconst surname =\n\t\t\tparts.find((p) => p.type?.includes(\"Surname\"))?.value || \"\";\n\n\t\tif (given || surname) {\n\t\t\treturn `${given} /${surname}/`.trim();\n\t\t}\n\n\t\tif (nameForm.fullText) {\n\t\t\treturn nameForm.fullText;\n\t\t}\n\t}\n\n\t// Try display name\n\tif (person.display?.name) {\n\t\treturn person.display.name;\n\t}\n\n\treturn null;\n}\n\n/**\n * Extract gender from FamilySearch person\n */\nfunction extractGender(person?: PersonData): string | null {\n\tif (!person) return null;\n\n\tif (person.gender?.type?.includes(\"Male\")) {\n\t\treturn \"M\";\n\t} else if (person.gender?.type?.includes(\"Female\")) {\n\t\treturn \"F\";\n\t} else if (person.display?.gender === \"Male\") {\n\t\treturn \"M\";\n\t} else if (person.display?.gender === \"Female\") {\n\t\treturn \"F\";\n\t}\n\n\treturn null;\n}\n\n/**\n * Extract a specific fact (like birth or death) from FamilySearch person\n */\nfunction extractFact(\n\tperson: PersonData | undefined,\n\tfactType: \"BIRTH\" | \"DEATH\"\n): { date?: string; place?: string } | null {\n\tif (!person) return null;\n\n\tconst result: { date?: string; place?: string } = {};\n\n\t// Try structured facts\n\tconst factTypeUrl = `http://gedcomx.org/${factType === \"BIRTH\" ? \"Birth\" : \"Death\"}`;\n\tconst fact = person.facts?.find((f) => f.type === factTypeUrl);\n\n\tif (fact) {\n\t\tif (fact.date?.formal || fact.date?.original) {\n\t\t\tresult.date = (fact.date?.formal || fact.date?.original)?.replace(\n\t\t\t\t/^(-|\\+)/,\n\t\t\t\t\"\"\n\t\t\t);\n\t\t}\n\t\tif (fact.place?.original) {\n\t\t\tresult.place = fact.place.original;\n\t\t}\n\t}\n\n\t// Try display data\n\tif (factType === \"BIRTH\") {\n\t\tresult.date = result.date || person.display?.birthDate;\n\t\tresult.place = result.place || person.display?.birthPlace;\n\t} else if (factType === \"DEATH\") {\n\t\tresult.date = result.date || person.display?.deathDate;\n\t\tresult.place = result.place || person.display?.deathPlace;\n\t}\n\n\treturn result.date || result.place ? result : null;\n}\n\n/**\n * Format a date for GEDCOM\n */\nfunction formatDateForGedcom(date: Date): string {\n\tconst months = [\n\t\t\"JAN\",\n\t\t\"FEB\",\n\t\t\"MAR\",\n\t\t\"APR\",\n\t\t\"MAY\",\n\t\t\"JUN\",\n\t\t\"JUL\",\n\t\t\"AUG\",\n\t\t\"SEP\",\n\t\t\"OCT\",\n\t\t\"NOV\",\n\t\t\"DEC\",\n\t];\n\n\tconst day = date.getDate();\n\tconst month = months[date.getMonth()];\n\tconst year = date.getFullYear();\n\n\treturn `${day} ${month} ${year}`;\n}\n\n/**\n * Convert a FamilySearch fact to GEDCOM lines\n */\nfunction convertFactToGedcom(fact: PersonFact): string[] {\n\tconst lines: string[] = [];\n\n\tif (!fact.type) return lines;\n\n\t// Map FamilySearch fact types to GEDCOM tags\n\tconst typeMap: Record<string, string> = {\n\t\t\"http://gedcomx.org/Burial\": \"BURI\",\n\t\t\"http://gedcomx.org/Christening\": \"CHR\",\n\t\t\"http://gedcomx.org/Baptism\": \"BAPM\",\n\t\t\"http://gedcomx.org/Marriage\": \"MARR\",\n\t\t\"http://gedcomx.org/Divorce\": \"DIV\",\n\t\t\"http://gedcomx.org/Residence\": \"RESI\",\n\t\t\"http://gedcomx.org/Occupation\": \"OCCU\",\n\t\t\"http://gedcomx.org/Immigration\": \"IMMI\",\n\t\t\"http://gedcomx.org/Emigration\": \"EMIG\",\n\t\t\"http://gedcomx.org/Naturalization\": \"NATU\",\n\t\t\"http://gedcomx.org/Census\": \"CENS\",\n\t};\n\n\tconst gedcomTag = typeMap[fact.type] || \"EVEN\";\n\n\t// Special handling for occupation with value\n\tif (gedcomTag === \"OCCU\" && fact.value) {\n\t\tlines.push(`1 OCCU ${fact.value}`);\n\t} else {\n\t\tlines.push(`1 ${gedcomTag}`);\n\t}\n\n\t// Add FamilySearch link for this specific fact/event (conclusion link)\n\tif (fact.links?.conclusion?.href) {\n\t\tconst webUrl = transformFamilySearchUrl(fact.links.conclusion.href);\n\t\tlines.push(`2 _FS_LINK ${webUrl}`);\n\t}\n\n\t// Add date\n\tif (fact.date?.formal || fact.date?.original) {\n\t\tlines.push(\n\t\t\t`2 DATE ${(fact.date?.formal || fact.date?.original)?.replace(/^(-|\\+)/, \"\")}`\n\t\t);\n\t}\n\n\t// Add place\n\tif (fact.place?.original) {\n\t\tlines.push(`2 PLAC ${fact.place.original}`);\n\t}\n\n\t// Add value as note for non-occupation facts\n\tif (fact.value && gedcomTag !== \"OCCU\") {\n\t\tlines.push(`2 NOTE ${fact.value}`);\n\t}\n\n\treturn lines;\n}\n\n/**\n * Options for GEDCOM conversion\n */\nexport interface GedcomConversionOptions {\n\t/** Tree name for the GEDCOM file header */\n\ttreeName?: string;\n\t/** Include FamilySearch links in output */\n\tincludeLinks?: boolean;\n\t/** Include notes in output */\n\tincludeNotes?: boolean;\n\n\t/** FamilySearch environment (production, beta, integration) */\n\tenvironment?: \"production\" | \"beta\" | \"integration\";\n\n\t/** Allow orphan families (families not connected to root person) */\n\tallowOrphanFamilies?: boolean;\n\n\t/**\n\t * Set of person IDs who are in the direct ancestry of the root person.\n\t * These are the persons returned by the ancestry API before fullTree expansion.\n\t * Used to determine which persons are \"connectable\" to the root person.\n\t */\n\tancestryPersonIds?: Set<string>;\n}\n\n/**\n * Convert FamilySearch pedigree data to GEDCOM format\n *\n * @param pedigreeData - Enhanced pedigree data from FamilySearch\n * @param options - Conversion options\n * @returns GEDCOM 5.5 formatted string\n *\n * @example\n * ```typescript\n * const pedigree = await fetchPedigree(sdk);\n * const gedcom = convertToGedcom(pedigree, { treeName: \"My Family Tree\" });\n * ```\n */\nexport function convertToGedcom(\n\tpedigreeData: EnhancedPedigreeData,\n\toptions: GedcomConversionOptions = {}\n): string {\n\tconst {\n\t\ttreeName = \"FamilySearch Import\",\n\t\tincludeLinks = true,\n\t\tincludeNotes = true,\n\t\tenvironment = \"production\",\n\t} = options;\n\n\tif (!pedigreeData || !pedigreeData.persons) {\n\t\tthrow new Error(\"Invalid FamilySearch data: no persons found\");\n\t}\n\n\tconst lines: string[] = [];\n\n\t// GEDCOM Header\n\tlines.push(\"0 HEAD\");\n\tlines.push(\"1 SOUR FamilySearch\");\n\tlines.push(\"2 VERS 1.0\");\n\tlines.push(\"2 NAME FamilySearch API\");\n\tlines.push(\"1 DEST ANY\");\n\tlines.push(\"1 DATE \" + formatDateForGedcom(new Date()));\n\tlines.push(\"1 SUBM @SUBM1@\");\n\tlines.push(\"1 FILE \" + treeName);\n\tlines.push(\"1 GEDC\");\n\tlines.push(\"2 VERS 5.5\");\n\tlines.push(\"2 FORM LINEAGE-LINKED\");\n\tlines.push(\"1 CHAR UTF-8\");\n\n\t// Submitter record\n\tlines.push(\"0 @SUBM1@ SUBM\");\n\n\t// ==============================================\n\t// COLLECT AND CREATE SOURCE RECORDS\n\t// ==============================================\n\tconst sourceMap = new Map<string, SourceDescription>();\n\tlet sourceCounter = 1;\n\n\t// Extract source descriptions from all persons\n\tpedigreeData.persons.forEach((person) => {\n\t\tconst sourceDescriptions = person.fullDetails?.sourceDescriptions;\n\n\t\tif (sourceDescriptions && Array.isArray(sourceDescriptions)) {\n\t\t\tsourceDescriptions.forEach((source) => {\n\t\t\t\tif (source.id && !sourceMap.has(source.id)) {\n\t\t\t\t\tsourceMap.set(source.id, source);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t});\n\n\t// Create GEDCOM SOUR records for each source\n\tsourceMap.forEach((source) => {\n\t\tconst sourceId = `@S${sourceCounter++}@`;\n\n\t\tlines.push(`0 ${sourceId} SOUR`);\n\n\t\t// Add title (use titles[0] if available, otherwise default)\n\t\tconst title = source.titles?.[0]?.value || \"FamilySearch Source\";\n\t\tlines.push(`1 TITL ${title}`);\n\n\t\t// Add citation as TEXT\n\t\tif (source.citations?.[0]?.value) {\n\t\t\tlines.push(`1 TEXT ${source.citations[0].value}`);\n\t\t}\n\n\t\t// Add web link if available\n\t\tif (source.about) {\n\t\t\tconst webUrl = transformSourceUrl(source.about);\n\t\t\tlines.push(`1 WWW ${webUrl}`);\n\t\t}\n\n\t\t// Add resource type as NOTE\n\t\tif (source.resourceType) {\n\t\t\tlines.push(`1 NOTE Resource Type: ${source.resourceType}`);\n\t\t}\n\t});\n\n\t// ==============================================\n\t// STEP 1: BUILD PERSON ID MAPPING ONLY\n\t// Create GEDCOM IDs for all persons (for relationship processing)\n\t// INDI records will be created later after filtering\n\t// ==============================================\n\tconst personIdMap = new Map<string, string>();\n\tpedigreeData.persons.forEach((person, index) => {\n\t\tconst gedcomId = `@I${index + 1}@`;\n\t\tpersonIdMap.set(person.id, gedcomId);\n\t});\n\n\t// Build family data structures\n\tconst families = new Map<\n\t\tstring,\n\t\t{ spouses: Set<string>; children: string[] }\n\t>();\n\tconst childToParents = new Map<string, string[]>();\n\n\t// ==============================================\n\t// COLLECT ALL RELATIONSHIPS (from pedigree AND person details)\n\t// ==============================================\n\tconst allRelationships: Relationship[] = [\n\t\t...(pedigreeData.relationships || []),\n\t];\n\n\t// Extract relationships from person.fullDetails.relationships\n\tpedigreeData.persons.forEach((person) => {\n\t\tconst personRelationships = person.fullDetails\n\t\t\t?.relationships as Relationship[];\n\n\t\tif (personRelationships && Array.isArray(personRelationships)) {\n\t\t\tpersonRelationships.forEach((rel) => {\n\t\t\t\tconst exists = allRelationships.some((r) => r.id === rel.id);\n\t\t\t\tif (!exists) {\n\t\t\t\t\tallRelationships.push(rel);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\t// Extract childAndParentsRelationships and convert to standard format\n\t\tconst childAndParentsRels = person.fullDetails\n\t\t\t?.childAndParentsRelationships as Array<{\n\t\t\tid: string;\n\t\t\tparent1?: { resourceId: string };\n\t\t\tparent2?: { resourceId: string };\n\t\t\tchild?: { resourceId: string };\n\t\t}>;\n\n\t\tif (childAndParentsRels && Array.isArray(childAndParentsRels)) {\n\t\t\tchildAndParentsRels.forEach((capRel) => {\n\t\t\t\t// Convert to ParentChild relationship format\n\t\t\t\tif (capRel.parent1 && capRel.child) {\n\t\t\t\t\tconst rel: Relationship = {\n\t\t\t\t\t\tid: `${capRel.id}-p1`,\n\t\t\t\t\t\ttype: \"http://gedcomx.org/ParentChild\",\n\t\t\t\t\t\tperson1: { resourceId: capRel.parent1.resourceId },\n\t\t\t\t\t\tperson2: { resourceId: capRel.child.resourceId },\n\t\t\t\t\t\tparent2: capRel.parent2\n\t\t\t\t\t\t\t? { resourceId: capRel.parent2.resourceId }\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t};\n\n\t\t\t\t\tconst exists = allRelationships.some(\n\t\t\t\t\t\t(r) => r.id === rel.id\n\t\t\t\t\t);\n\t\t\t\t\tif (!exists) {\n\t\t\t\t\t\tallRelationships.push(rel);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// If parent2 exists, also add relationship for parent2\n\t\t\t\tif (capRel.parent2 && capRel.child) {\n\t\t\t\t\tconst rel: Relationship = {\n\t\t\t\t\t\tid: `${capRel.id}-p2`,\n\t\t\t\t\t\ttype: \"http://gedcomx.org/ParentChild\",\n\t\t\t\t\t\tperson1: { resourceId: capRel.parent2.resourceId },\n\t\t\t\t\t\tperson2: { resourceId: capRel.child.resourceId },\n\t\t\t\t\t\tparent2: capRel.parent1\n\t\t\t\t\t\t\t? { resourceId: capRel.parent1.resourceId }\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t};\n\n\t\t\t\t\tconst exists = allRelationships.some(\n\t\t\t\t\t\t(r) => r.id === rel.id\n\t\t\t\t\t);\n\t\t\t\t\tif (!exists) {\n\t\t\t\t\t\tallRelationships.push(rel);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t});\n\n\t// Create a Set of valid person IDs for fast lookup\n\tconst validPersonIds = new Set(pedigreeData.persons.map((p) => p.id));\n\n\t// Process all relationships, filtering out invalid person IDs\n\tallRelationships.forEach((rel) => {\n\t\tif (rel.type?.includes(\"ParentChild\")) {\n\t\t\tconst parentId = rel.person1?.resourceId;\n\t\t\tconst childId = rel.person2?.resourceId;\n\t\t\tconst parent2Id = rel.parent2?.resourceId;\n\n\t\t\t// Validate all person IDs exist in dataset\n\t\t\tif (!parentId || !childId) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Skip if child doesn't exist in dataset\n\t\t\tif (!validPersonIds.has(childId)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Filter parent IDs - only include parents who exist in dataset\n\t\t\tconst validParents: string[] = [];\n\t\t\tif (validPersonIds.has(parentId)) {\n\t\t\t\tvalidParents.push(parentId);\n\t\t\t}\n\t\t\tif (parent2Id && validPersonIds.has(parent2Id)) {\n\t\t\t\tvalidParents.push(parent2Id);\n\t\t\t}\n\n\t\t\t// Only add relationship if at least one parent exists\n\t\t\tif (validParents.length > 0) {\n\t\t\t\tif (!childToParents.has(childId)) {\n\t\t\t\t\tchildToParents.set(childId, []);\n\t\t\t\t}\n\t\t\t\tconst parents = childToParents.get(childId)!;\n\t\t\t\tvalidParents.forEach((parentId) => {\n\t\t\t\t\tif (!parents.includes(parentId)) {\n\t\t\t\t\t\tparents.push(parentId);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t} else if (rel.type?.includes(\"Couple\")) {\n\t\t\tconst person1 = rel.person1?.resourceId;\n\t\t\tconst person2 = rel.person2?.resourceId;\n\n\t\t\tif (!person1 || !person2) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Only add couple if BOTH persons exist in dataset\n\t\t\tif (validPersonIds.has(person1) && validPersonIds.has(person2)) {\n\t\t\t\tconst famKey = [person1, person2].sort().join(\"-\");\n\t\t\t\tif (!families.has(famKey)) {\n\t\t\t\t\tfamilies.set(famKey, {\n\t\t\t\t\t\tspouses: new Set([person1, person2]),\n\t\t\t\t\t\tchildren: [],\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t});\n\n\t// Add children to their families\n\tchildToParents.forEach((parents, childId) => {\n\t\tif (parents.length >= 2) {\n\t\t\tconst famKey = parents.slice(0, 2).sort().join(\"-\");\n\t\t\tif (!families.has(famKey)) {\n\t\t\t\tfamilies.set(famKey, {\n\t\t\t\t\tspouses: new Set(parents.slice(0, 2)),\n\t\t\t\t\tchildren: [],\n\t\t\t\t});\n\t\t\t}\n\t\t\tfamilies.get(famKey)!.children.push(childId);\n\t\t} else if (parents.length === 1) {\n\t\t\tconst famKey = `single-${parents[0]}`;\n\t\t\tif (!families.has(famKey)) {\n\t\t\t\tfamilies.set(famKey, {\n\t\t\t\t\tspouses: new Set([parents[0]]),\n\t\t\t\t\tchildren: [],\n\t\t\t\t});\n\t\t\t}\n\t\t\tfamilies.get(famKey)!.children.push(childId);\n\t\t}\n\t});\n\n\t// Build set of persons who are \"connectable\" to the root person\n\t// A person is connectable if:\n\t// 1. They are in the direct ancestry (ancestryPersonIds)\n\t// 2. They are a spouse of someone in the ancestry\n\t// 3. They are a descendant of someone in the ancestry (recursive)\n\t// 4. They are a spouse of a descendant (recursive)\n\tconst connectablePersons = new Set<string>();\n\n\t// If ancestryPersonIds is provided, use graph traversal\n\t// Otherwise, fall back to old logic (everyone in childToParents)\n\tif (options.ancestryPersonIds && options.ancestryPersonIds.size > 0) {\n\t\t// Step 1: Add all ancestry persons\n\t\toptions.ancestryPersonIds.forEach((personId) => {\n\t\t\tconnectablePersons.add(personId);\n\t\t});\n\n\t\t// Step 2: Add spouses of ancestry persons\n\t\tfamilies.forEach((family) => {\n\t\t\tconst spouses = Array.from(family.spouses);\n\t\t\t// If any spouse is in ancestry, add all spouses\n\t\t\tif (spouses.some((spouseId) => connectablePersons.has(spouseId))) {\n\t\t\t\tspouses.forEach((spouseId) => connectablePersons.add(spouseId));\n\t\t\t}\n\t\t});\n\n\t\t// Step 3: Recursively expand the graph DOWNWARD and SIDEWAYS only\n\t\t// Add: descendants + their spouses (NO upward traversal to parents)\n\t\t// Keep iterating until no new persons are added\n\t\tlet addedNewPersons = true;\n\t\twhile (addedNewPersons) {\n\t\t\taddedNewPersons = false;\n\t\t\tconst beforeSize = connectablePersons.size;\n\n\t\t\t// 3a. Add children of connectable persons (downward traversal)\n\t\t\tchildToParents.forEach((parents, childId) => {\n\t\t\t\t// If any parent is connectable, the child is connectable\n\t\t\t\tif (\n\t\t\t\t\tparents.some((parentId) => connectablePersons.has(parentId))\n\t\t\t\t) {\n\t\t\t\t\tif (!connectablePersons.has(childId)) {\n\t\t\t\t\t\tconnectablePersons.add(childId);\n\t\t\t\t\t\taddedNewPersons = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\n\t\t\t// 3b. Add spouses of connectable persons (sideways traversal)\n\t\t\tfamilies.forEach((family) => {\n\t\t\t\tconst spouses = Array.from(family.spouses);\n\t\t\t\tconst hasConnectableSpouse = spouses.some((spouseId) =>\n\t\t\t\t\tconnectablePersons.has(spouseId)\n\t\t\t\t);\n\t\t\t\tconst hasConnectableChild = family.children.some((childId) =>\n\t\t\t\t\tconnectablePersons.has(childId)\n\t\t\t\t);\n\n\t\t\t\t// If any spouse OR child is connectable, add all spouses\n\t\t\t\tif (hasConnectableSpouse || hasConnectableChild) {\n\t\t\t\t\tspouses.forEach((spouseId) => {\n\t\t\t\t\t\tif (!connectablePersons.has(spouseId)) {\n\t\t\t\t\t\t\tconnectablePersons.add(spouseId);\n\t\t\t\t\t\t\taddedNewPersons = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tconst afterSize = connectablePersons.size;\n\t\t\tif (afterSize > beforeSize) {\n\t\t\t\taddedNewPersons = afterSize !== beforeSize;\n\t\t\t}\n\t\t}\n\t} else {\n\t\t// Fallback: old logic (everyone in parent-child relationships)\n\t\tchildToParents.forEach((parents, childId) => {\n\t\t\tconnectablePersons.add(childId);\n\t\t\tparents.forEach((parentId) => connectablePersons.add(parentId));\n\t\t});\n\t}\n\n\t// ==============================================\n\t// STEP 4: DETECT ORPHAN FAMILIES AND BUILD PERSON-TO-FAMILY MAPPING\n\t// Identify which families are orphan (disconnected from ancestry)\n\t// ==============================================\n\tconst allowOrphanFamilies = options.allowOrphanFamilies === true; // Default to false\n\tconst orphanFamKeys = new Set<string>(); // Keys of families that are orphan\n\n\t// Build a map from personId to all their FAM keys (as spouse or child)\n\tconst personToFamKeys = new Map<string, Set<string>>();\n\tfamilies.forEach((family, key) => {\n\t\tconst spouseArray = Array.from(family.spouses);\n\n\t\t// Check if this is an orphan family\n\t\tconst anyMemberConnectable =\n\t\t\tspouseArray.some((spouseId) => connectablePersons.has(spouseId)) ||\n\t\t\tfamily.children.some((childId) => connectablePersons.has(childId));\n\n\t\tconst isOrphanFamily = !anyMemberConnectable;\n\n\t\t// Track orphan family keys\n\t\tif (isOrphanFamily) {\n\t\t\torphanFamKeys.add(key);\n\t\t}\n\n\t\t// Map each person to their families\n\t\tspouseArray.forEach((spouseId) => {\n\t\t\tif (!personToFamKeys.has(spouseId))\n\t\t\t\tpersonToFamKeys.set(spouseId, new Set());\n\t\t\tpersonToFamKeys.get(spouseId)!.add(key);\n\t\t});\n\t\tfamily.children.forEach((childId) => {\n\t\t\tif (!personToFamKeys.has(childId))\n\t\t\t\tpersonToFamKeys.set(childId, new Set());\n\t\t\tpersonToFamKeys.get(childId)!.add(key);\n\t\t});\n\t});\n\n\t// ==============================================\n\t// STEP 5: CREATE INDI RECORDS (WITH ORPHAN FILTERING)\n\t// ==============================================\n\n\tpedigreeData.persons.forEach((person) => {\n\t\tconst gedcomId = personIdMap.get(person.id);\n\t\tif (!gedcomId) {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.warn(\n\t\t\t\t`[GEDCOM] Person ${person.id} not found in personIdMap`\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\t// ==============================================\n\t\t// ORPHAN PERSON FILTERING\n\t\t// If allowOrphanFamilies=false, skip persons who are ONLY in orphan families\n\t\t// ==============================================\n\t\tif (!allowOrphanFamilies) {\n\t\t\tconst famKeys = personToFamKeys.get(person.id);\n\t\t\t// If person belongs to families, check if ALL of them are orphan families\n\t\t\tif (\n\t\t\t\tfamKeys &&\n\t\t\t\tfamKeys.size > 0 &&\n\t\t\t\tArray.from(famKeys).every((key) => orphanFamKeys.has(key))\n\t\t\t) {\n\t\t\t\treturn; // Skip this orphan person\n\t\t\t}\n\t\t}\n\n\t\tlines.push(`0 ${gedcomId} INDI`);\n\n\t\t// Add FamilySearch ID tag\n\t\tif (person.id) {\n\t\t\tlines.push(`1 _FS_ID ${person.id}`);\n\t\t}\n\n\t\t// Add FamilySearch link for this person\n\t\tif (includeLinks) {\n\t\t\tconst personLink =\n\t\t\t\tperson.links?.person?.href ||\n\t\t\t\tperson.identifiers?.[\"http://gedcomx.org/Persistent\"]?.[0];\n\n\t\t\tif (personLink) {\n\t\t\t\tconst webUrl = transformFamilySearchUrl(personLink);\n\t\t\t\tlines.push(`1 _FS_LINK ${webUrl}`);\n\t\t\t} else if (person.id) {\n\t\t\t\t// Fallback: construct web URL from person ID if no link provided\n\t\t\t\tlet baseUrl = \"https://www.familysearch.org\";\n\t\t\t\tif (environment === \"beta\") {\n\t\t\t\t\tbaseUrl = \"https://beta.familysearch.org\";\n\t\t\t\t} else if (environment === \"integration\") {\n\t\t\t\t\tbaseUrl = \"https://integration.familysearch.org\";\n\t\t\t\t}\n\t\t\t\tconst webUrl = `${baseUrl}/tree/person/${person.id}`;\n\t\t\t\tlines.push(`1 _FS_LINK ${webUrl}`);\n\t\t\t}\n\t\t}\n\n\t\t// Extract from fullDetails if available, otherwise use basic person data\n\t\tconst personData = person.fullDetails?.persons?.[0] || person;\n\n\t\t// Name\n\t\tconst name = extractName(personData);\n\t\tif (name) {\n\t\t\tlines.push(`1 NAME ${name}`);\n\t\t}\n\n\t\t// Gender\n\t\tconst gender = extractGender(personData);\n\t\tif (gender) {\n\t\t\tlines.push(`1 SEX ${gender}`);\n\t\t}\n\n\t\t// Birth\n\t\tconst birth = extractFact(personData, \"BIRTH\");\n\t\tif (birth) {\n\t\t\tlines.push(\"1 BIRT\");\n\t\t\tif (birth.date) {\n\t\t\t\tlines.push(`2 DATE ${birth.date}`);\n\t\t\t}\n\t\t\tif (birth.place) {\n\t\t\t\tlines.push(`2 PLAC ${birth.place}`);\n\t\t\t}\n\t\t}\n\n\t\t// Death\n\t\tconst death = extractFact(personData, \"DEATH\");\n\t\tif (death) {\n\t\t\tlines.push(\"1 DEAT\");\n\t\t\tif (death.date) {\n\t\t\t\tlines.push(`2 DATE ${death.date}`);\n\t\t\t}\n\t\t\tif (death.place) {\n\t\t\t\tlines.push(`2 PLAC ${death.place}`);\n\t\t\t}\n\t\t}\n\n\t\t// Add all other facts from fullDetails\n\t\tpersonData.facts?.forEach((fact) => {\n\t\t\tif (\n\t\t\t\tfact.type &&\n\t\t\t\tfact.type !== \"http://gedcomx.org/Birth\" &&\n\t\t\t\tfact.type !== \"http://gedcomx.org/Death\"\n\t\t\t) {\n\t\t\t\tconst factLines = convertFactToGedcom(fact);\n\t\t\t\tfactLines.forEach((line) => lines.push(line));\n\t\t\t}\n\t\t});\n\n\t\t// Add notes\n\t\tif (includeNotes && person.notes?.persons?.[0]?.notes) {\n\t\t\tperson.notes.persons[0].notes.forEach((note) => {\n\t\t\t\tif (note.text) {\n\t\t\t\t\tconst noteText = note.text.replace(/\\n/g, \" \");\n\t\t\t\t\tlines.push(`1 NOTE ${noteText}`);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\t// ==============================================\n\t\t// ADD SOURCE CITATIONS TO PERSON\n\t\t// ==============================================\n\t\tconst personSources = (\n\t\t\tpersonData as PersonData & { sources?: SourceReference[] }\n\t\t)?.sources;\n\n\t\tif (personSources && Array.isArray(personSources)) {\n\t\t\tpersonSources.forEach((sourceRef) => {\n\t\t\t\tconst sourceId = sourceRef.descriptionId;\n\t\t\t\tif (!sourceId) return;\n\n\t\t\t\t// Find source index\n\t\t\t\tconst sourceIds = Array.from(sourceMap.keys());\n\t\t\t\tconst sourceIndex = sourceIds.indexOf(sourceId);\n\t\t\t\tif (sourceIndex === -1) return;\n\n\t\t\t\tconst gedcomSourceId = `@S${sourceIndex + 1}@`;\n\t\t\t\tlines.push(`1 SOUR ${gedcomSourceId}`);\n\n\t\t\t\t// Add qualifiers as notes\n\t\t\t\tif (\n\t\t\t\t\tsourceRef.qualifiers &&\n\t\t\t\t\tArray.isArray(sourceRef.qualifiers)\n\t\t\t\t) {\n\t\t\t\t\tsourceRef.qualifiers.forEach((qualifier) => {\n\t\t\t\t\t\tif (qualifier.name && qualifier.value) {\n\t\t\t\t\t\t\tlines.push(\n\t\t\t\t\t\t\t\t`2 NOTE ${qualifier.name}: ${qualifier.value}`\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t});\n\n\t// ==============================================\n\t// STEP 6: CREATE FAM RECORDS (WITH ORPHAN FILTERING)\n\t// ==============================================\n\n\t// Create FAM records\n\tlet famIndex = 1;\n\tconst familyIdMap = new Map<string, string>();\n\n\tfamilies.forEach((family, key) => {\n\t\t// ==============================================\n\t\t// INVALID FAM RECORD PREVENTION\n\t\t// ==============================================\n\n\t\t// Check if parents exist in personIdMap\n\t\tconst spouseArray = Array.from(family.spouses);\n\t\tconst parentsInMap = spouseArray.filter((id) => personIdMap.has(id));\n\n\t\tconst hasNoParents = parentsInMap.length === 0;\n\t\tconst hasSingleParentNoChildren =\n\t\t\tparentsInMap.length === 1 && family.children.length === 0;\n\n\t\t// Skip invalid FAM records\n\t\tif (hasNoParents) {\n\t\t\t// Orphaned child - no parents exist in dataset\n\t\t\tif (family.children.length > 0) {\n\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`[FS SDK GEDCOM] Skipping FAM for orphaned child(ren): ${family.children.length} child(ren) with 0 parents`\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn; // Skip this FAM record\n\t\t}\n\n\t\tif (hasSingleParentNoChildren) {\n\t\t\t// Single spouse with no children and no other spouse\n\t\t\t// This is an orphaned single-spouse family (invalid per GEDCOM 5.5)\n\t\t\treturn; // Skip this FAM record\n\t\t}\n\n\t\t// Check if this is an orphan family\n\t\t// Family is orphan if NO members (neither spouses NOR children) are connectable to root person\n\t\t// This means the family is isolated and doesn't connect to the ancestry tree\n\t\tconst anyMemberConnectable =\n\t\t\tspouseArray.some((spouseId) => connectablePersons.has(spouseId)) ||\n\t\t\tfamily.children.some((childId) => connectablePersons.has(childId));\n\n\t\tconst isOrphanFamily = !anyMemberConnectable;\n\n\t\t// If orphan families are NOT allowed, skip them entirely\n\t\tif (isOrphanFamily && !allowOrphanFamilies) {\n\t\t\treturn; // Skip this family - no FAM record created\n\t\t}\n\n\t\tconst famId = `@F${famIndex++}@`;\n\t\tfamilyIdMap.set(key, famId);\n\n\t\tlines.push(`0 ${famId} FAM`);\n\n\t\t// Add _IS_ORPHAN_FAMILY tag if this is an orphan family (and allowed)\n\t\tif (isOrphanFamily && allowOrphanFamilies) {\n\t\t\tlines.push(`1 _IS_ORPHAN_FAMILY Y`);\n\t\t}\n\n\t\tif (spouseArray.length === 2) {\n\t\t\tconst [person1, person2] = spouseArray;\n\t\t\tconst person1Data = pedigreeData.persons?.find(\n\t\t\t\t(p) => p.id === person1\n\t\t\t);\n\t\t\tconst person2Data = pedigreeData.persons?.find(\n\t\t\t\t(p) => p.id === person2\n\t\t\t);\n\n\t\t\tconst gender1 = extractGender(\n\t\t\t\tperson1Data?.fullDetails?.persons?.[0] || person1Data\n\t\t\t);\n\t\t\tconst gender2 = extractGender(\n\t\t\t\tperson2Data?.fullDetails?.persons?.[0] || person2Data\n\t\t\t);\n\n\t\t\tconst p1 = personIdMap.get(person1);\n\t\t\tconst p2 = personIdMap.get(person2);\n\t\t\tif (gender1 === \"M\" || gender2 === \"F\") {\n\t\t\t\tif (p1) lines.push(`1 HUSB ${p1}`);\n\t\t\t\tif (p2) lines.push(`1 WIFE ${p2}`);\n\t\t\t} else {\n\t\t\t\tif (p2) lines.push(`1 HUSB ${p2}`);\n\t\t\t\tif (p1) lines.push(`1 WIFE ${p1}`);\n\t\t\t}\n\n\t\t\t// Add marriage facts\n\t\t\taddMarriageFacts(lines, allRelationships, person1, person2);\n\t\t} else if (spouseArray.length === 1) {\n\t\t\tconst parentData = pedigreeData.persons?.find(\n\t\t\t\t(p) => p.id === spouseArray[0]\n\t\t\t);\n\t\t\tconst gender = extractGender(\n\t\t\t\tparentData?.fullDetails?.persons?.[0] || parentData\n\t\t\t);\n\n\t\t\tif (gender === \"M\") {\n\t\t\t\tlines.push(`1 HUSB ${personIdMap.get(spouseArray[0])}`);\n\t\t\t} else {\n\t\t\t\tlines.push(`1 WIFE ${personIdMap.get(spouseArray[0])}`);\n\t\t\t}\n\t\t}\n\n\t\t// Add children\n\t\tfamily.children.forEach((childId) => {\n\t\t\tconst childGedcomId = personIdMap.get(childId);\n\t\t\tif (childGedcomId) {\n\t\t\t\tlines.push(`1 CHIL ${childGedcomId}`);\n\t\t\t}\n\t\t});\n\t});\n\n\t// Add FAMC links to individuals\n\tchildToParents.forEach((parents, childId) => {\n\t\tconst childGedcomId = personIdMap.get(childId);\n\t\tif (!childGedcomId) return;\n\n\t\tlet famId: string | undefined;\n\t\tif (parents.length >= 2) {\n\t\t\tconst famKey = parents.slice(0, 2).sort().join(\"-\");\n\t\t\tfamId = familyIdMap.get(famKey);\n\t\t} else if (parents.length === 1) {\n\t\t\tconst famKey = `single-${parents[0]}`;\n\t\t\tfamId = familyIdMap.get(famKey);\n\t\t}\n\n\t\tif (famId) {\n\t\t\tconst indiRecordIndex = lines.findIndex(\n\t\t\t\t(line) => line === `0 ${childGedcomId} INDI`\n\t\t\t);\n\t\t\tif (indiRecordIndex !== -1) {\n\t\t\t\tlines.splice(indiRecordIndex + 1, 0, `1 FAMC ${famId}`);\n\t\t\t}\n\t\t}\n\t});\n\n\t// Add FAMS links to individuals\n\tfamilies.forEach((family, key) => {\n\t\tconst famId = familyIdMap.get(key);\n\t\tif (!famId) return;\n\n\t\tfamily.spouses.forEach((spouseId) => {\n\t\t\tconst spouseGedcomId = personIdMap.get(spouseId);\n\t\t\tif (!spouseGedcomId) return;\n\n\t\t\tconst indiRecordIndex = lines.findIndex(\n\t\t\t\t(line) => line === `0 ${spouseGedcomId} INDI`\n\t\t\t);\n\t\t\tif (indiRecordIndex !== -1) {\n\t\t\t\tlet insertIndex = indiRecordIndex + 1;\n\t\t\t\twhile (\n\t\t\t\t\tinsertIndex < lines.length &&\n\t\t\t\t\tlines[insertIndex].startsWith(\"1 FAMC\")\n\t\t\t\t) {\n\t\t\t\t\tinsertIndex++;\n\t\t\t\t}\n\t\t\t\tlines.splice(insertIndex, 0, `1 FAMS ${famId}`);\n\t\t\t}\n\t\t});\n\t});\n\n\t// Final validation: Check for orphaned persons (not in any family)\n\tconst personsInFamilies = new Set<string>();\n\tfamilies.forEach((family) => {\n\t\tfamily.spouses.forEach((id) => personsInFamilies.add(id));\n\t\tfamily.children.forEach((id) => personsInFamilies.add(id));\n\t});\n\n\t// GEDCOM Trailer\n\tlines.push(\"0 TRLR\");\n\n\treturn lines.join(\"\\n\");\n}\n\n/**\n * Helper to add marriage facts to FAM record\n */\nfunction addMarriageFacts(\n\tlines: string[],\n\trelationships: Relationship[],\n\tperson1: string,\n\tperson2: string\n): void {\n\tconst relKey = [person1, person2].sort().join(\"-\");\n\n\tconst rel = relationships.find((r) => {\n\t\tconst a = r.person1?.resourceId || r.person1?.resource?.resourceId;\n\t\tconst b = r.person2?.resourceId || r.person2?.resource?.resourceId;\n\t\tif (!a || !b) return false;\n\t\treturn [a, b].sort().join(\"-\") === relKey;\n\t});\n\n\tif (!rel) return;\n\n\tconst marriageFacts: PersonFact[] = [];\n\n\t// Check facts directly on relationship\n\tif (rel.facts && Array.isArray(rel.facts)) {\n\t\trel.facts.forEach((f) => {\n\t\t\tif (f.type?.includes(\"Marriage\")) {\n\t\t\t\tmarriageFacts.push(f);\n\t\t\t}\n\t\t});\n\t}\n\n\t// Check details.facts\n\tif (rel.details?.facts && Array.isArray(rel.details.facts)) {\n\t\tmarriageFacts.push(\n\t\t\t...rel.details.facts.filter((f) => f.type?.includes(\"Marriage\"))\n\t\t);\n\t}\n\n\t// Check details.persons[].facts\n\tif (rel.details?.persons && Array.isArray(rel.details.persons)) {\n\t\trel.details.persons.forEach((p) => {\n\t\t\tif (p.facts && Array.isArray(p.facts)) {\n\t\t\t\tp.facts.forEach((f) => {\n\t\t\t\t\tif (f.type?.includes(\"Marriage\")) {\n\t\t\t\t\t\tmarriageFacts.push(f);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t}\n\n\t// Add marriage facts to FAM record\n\tmarriageFacts.forEach((mf) => {\n\t\tconst factLines = convertFactToGedcom(mf);\n\t\tfactLines.forEach((line) => lines.push(line));\n\t});\n}\n\n// Alias for backwards compatibility\nexport const convertFamilySearchToGedcom = convertToGedcom;\n"]}
@@ -0,0 +1,46 @@
1
+ import { r as EnhancedPedigreeData } from '../index-D6H-lvis.cjs';
2
+
3
+ /**
4
+ * FamilySearch to GEDCOM Converter
5
+ *
6
+ * Converts FamilySearch API responses into GEDCOM 5.5 format
7
+ */
8
+
9
+ /**
10
+ * Options for GEDCOM conversion
11
+ */
12
+ interface GedcomConversionOptions {
13
+ /** Tree name for the GEDCOM file header */
14
+ treeName?: string;
15
+ /** Include FamilySearch links in output */
16
+ includeLinks?: boolean;
17
+ /** Include notes in output */
18
+ includeNotes?: boolean;
19
+ /** FamilySearch environment (production, beta, integration) */
20
+ environment?: "production" | "beta" | "integration";
21
+ /** Allow orphan families (families not connected to root person) */
22
+ allowOrphanFamilies?: boolean;
23
+ /**
24
+ * Set of person IDs who are in the direct ancestry of the root person.
25
+ * These are the persons returned by the ancestry API before fullTree expansion.
26
+ * Used to determine which persons are "connectable" to the root person.
27
+ */
28
+ ancestryPersonIds?: Set<string>;
29
+ }
30
+ /**
31
+ * Convert FamilySearch pedigree data to GEDCOM format
32
+ *
33
+ * @param pedigreeData - Enhanced pedigree data from FamilySearch
34
+ * @param options - Conversion options
35
+ * @returns GEDCOM 5.5 formatted string
36
+ *
37
+ * @example
38
+ * ```typescript
39
+ * const pedigree = await fetchPedigree(sdk);
40
+ * const gedcom = convertToGedcom(pedigree, { treeName: "My Family Tree" });
41
+ * ```
42
+ */
43
+ declare function convertToGedcom(pedigreeData: EnhancedPedigreeData, options?: GedcomConversionOptions): string;
44
+ declare const convertFamilySearchToGedcom: typeof convertToGedcom;
45
+
46
+ export { type GedcomConversionOptions, convertFamilySearchToGedcom, convertToGedcom };
@@ -0,0 +1,46 @@
1
+ import { r as EnhancedPedigreeData } from '../index-D6H-lvis.js';
2
+
3
+ /**
4
+ * FamilySearch to GEDCOM Converter
5
+ *
6
+ * Converts FamilySearch API responses into GEDCOM 5.5 format
7
+ */
8
+
9
+ /**
10
+ * Options for GEDCOM conversion
11
+ */
12
+ interface GedcomConversionOptions {
13
+ /** Tree name for the GEDCOM file header */
14
+ treeName?: string;
15
+ /** Include FamilySearch links in output */
16
+ includeLinks?: boolean;
17
+ /** Include notes in output */
18
+ includeNotes?: boolean;
19
+ /** FamilySearch environment (production, beta, integration) */
20
+ environment?: "production" | "beta" | "integration";
21
+ /** Allow orphan families (families not connected to root person) */
22
+ allowOrphanFamilies?: boolean;
23
+ /**
24
+ * Set of person IDs who are in the direct ancestry of the root person.
25
+ * These are the persons returned by the ancestry API before fullTree expansion.
26
+ * Used to determine which persons are "connectable" to the root person.
27
+ */
28
+ ancestryPersonIds?: Set<string>;
29
+ }
30
+ /**
31
+ * Convert FamilySearch pedigree data to GEDCOM format
32
+ *
33
+ * @param pedigreeData - Enhanced pedigree data from FamilySearch
34
+ * @param options - Conversion options
35
+ * @returns GEDCOM 5.5 formatted string
36
+ *
37
+ * @example
38
+ * ```typescript
39
+ * const pedigree = await fetchPedigree(sdk);
40
+ * const gedcom = convertToGedcom(pedigree, { treeName: "My Family Tree" });
41
+ * ```
42
+ */
43
+ declare function convertToGedcom(pedigreeData: EnhancedPedigreeData, options?: GedcomConversionOptions): string;
44
+ declare const convertFamilySearchToGedcom: typeof convertToGedcom;
45
+
46
+ export { type GedcomConversionOptions, convertFamilySearchToGedcom, convertToGedcom };