@treeviz/familysearch-sdk 1.0.13 → 1.0.15
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.
- package/README.md +35 -0
- package/dist/auth/index.d.cts +1 -1
- package/dist/auth/index.d.ts +1 -1
- package/dist/{client-ohjqX4t5.d.cts → client-C9fvn-wZ.d.cts} +19 -1
- package/dist/{client-DIpYSHtx.d.ts → client-DYad9DOD.d.ts} +19 -1
- package/dist/{index-D6H-lvis.d.cts → index-jdvA0fPb.d.cts} +17 -1
- package/dist/{index-D6H-lvis.d.ts → index-jdvA0fPb.d.ts} +17 -1
- package/dist/index.cjs +72 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +72 -0
- package/dist/index.js.map +1 -1
- package/dist/places/index.d.cts +2 -2
- package/dist/places/index.d.ts +2 -2
- package/dist/tree/index.d.cts +2 -2
- package/dist/tree/index.d.ts +2 -2
- package/dist/utils/index.cjs +41 -0
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.cts +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +41 -0
- package/dist/utils/index.js.map +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -15,6 +15,7 @@ A modern, TypeScript-first SDK for the FamilySearch API v3.
|
|
|
15
15
|
- 📝 **GEDCOM export** - Convert FamilySearch data to GEDCOM 5.5 format
|
|
16
16
|
- 📍 **Places API** helpers for location searches
|
|
17
17
|
- 👨👩👧 **Tree/Pedigree API** for ancestry data
|
|
18
|
+
- 📚 **Sources API** - Fetch source references linked to persons
|
|
18
19
|
|
|
19
20
|
## Installation
|
|
20
21
|
|
|
@@ -131,6 +132,36 @@ const pedigree = await fetchPedigree(sdk, undefined, {
|
|
|
131
132
|
});
|
|
132
133
|
```
|
|
133
134
|
|
|
135
|
+
## Sources API
|
|
136
|
+
|
|
137
|
+
Retrieve source references linked to persons.
|
|
138
|
+
|
|
139
|
+
```typescript
|
|
140
|
+
import { createFamilySearchSDK } from 'familysearch-sdk';
|
|
141
|
+
|
|
142
|
+
const sdk = createFamilySearchSDK({ accessToken: 'token' });
|
|
143
|
+
|
|
144
|
+
// Fetch sources for a person
|
|
145
|
+
const sources = await sdk.getPersonSources('KWQS-BBQ');
|
|
146
|
+
|
|
147
|
+
// Access source references
|
|
148
|
+
if (sources?.persons?.[0]?.sources) {
|
|
149
|
+
sources.persons[0].sources.forEach(source => {
|
|
150
|
+
console.log('Source ID:', source.descriptionId);
|
|
151
|
+
console.log('Qualifiers:', source.qualifiers);
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// Access source descriptions
|
|
156
|
+
if (sources?.sourceDescriptions) {
|
|
157
|
+
sources.sourceDescriptions.forEach(desc => {
|
|
158
|
+
console.log('Title:', desc.titles?.[0]?.value);
|
|
159
|
+
console.log('Citation:', desc.citations?.[0]?.value);
|
|
160
|
+
console.log('About:', desc.about);
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
134
165
|
## GEDCOM Conversion
|
|
135
166
|
|
|
136
167
|
Convert FamilySearch data to GEDCOM 5.5 format.
|
|
@@ -218,6 +249,10 @@ const sdk = createFamilySearchSDK({
|
|
|
218
249
|
- `getPersonWithDetails(sdk, personId)` - Get person details
|
|
219
250
|
- `fetchMultiplePersons(sdk, personIds)` - Batch fetch persons
|
|
220
251
|
|
|
252
|
+
### Person Sources
|
|
253
|
+
|
|
254
|
+
- `sdk.getPersonSources(personId)` - Get source references for a person
|
|
255
|
+
|
|
221
256
|
### Utils (`/utils`)
|
|
222
257
|
|
|
223
258
|
- `convertToGedcom(pedigreeData, options)` - Convert to GEDCOM
|
package/dist/auth/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { F as FamilySearchEnvironment,
|
|
1
|
+
import { F as FamilySearchEnvironment, x as OAuthEndpoints, y as OAuthConfig, O as OAuthTokenResponse, z as OAuthStateValidation } from '../index-jdvA0fPb.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* FamilySearch OAuth Authentication Module
|
package/dist/auth/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { F as FamilySearchEnvironment,
|
|
1
|
+
import { F as FamilySearchEnvironment, x as OAuthEndpoints, y as OAuthConfig, O as OAuthTokenResponse, z as OAuthStateValidation } from '../index-jdvA0fPb.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* FamilySearch OAuth Authentication Module
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as FamilySearchSDKConfig, F as FamilySearchEnvironment, E as EnvironmentConfig, b as FamilySearchApiResponse, d as FamilySearchUser, e as FamilySearchPerson, i as PersonWithRelationships, j as PersonNotesResponse,
|
|
1
|
+
import { a as FamilySearchSDKConfig, F as FamilySearchEnvironment, E as EnvironmentConfig, b as FamilySearchApiResponse, d as FamilySearchUser, e as FamilySearchPerson, i as PersonWithRelationships, j as PersonNotesResponse, k as PersonMemoriesResponse, m as PersonSourcesResponse, h as RelationshipDetails, u as PedigreeData, l as PersonSearchResponse, p as FamilySearchPlace } from './index-jdvA0fPb.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* FamilySearch SDK Client
|
|
@@ -98,6 +98,24 @@ declare class FamilySearchSDK {
|
|
|
98
98
|
* Get memories for a person
|
|
99
99
|
*/
|
|
100
100
|
getPersonMemories(personId: string): Promise<PersonMemoriesResponse | null>;
|
|
101
|
+
/**
|
|
102
|
+
* Get sources for a person
|
|
103
|
+
* Fetches all source references linked to a person
|
|
104
|
+
*
|
|
105
|
+
* @param personId - FamilySearch person ID
|
|
106
|
+
* @returns Person sources response with source references and descriptions, or null if error
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```typescript
|
|
110
|
+
* const sources = await sdk.getPersonSources('KWQS-BBQ');
|
|
111
|
+
* if (sources?.persons?.[0]?.sources) {
|
|
112
|
+
* sources.persons[0].sources.forEach(source => {
|
|
113
|
+
* console.log('Source:', source.descriptionId);
|
|
114
|
+
* });
|
|
115
|
+
* }
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
getPersonSources(personId: string): Promise<PersonSourcesResponse | null>;
|
|
101
119
|
/**
|
|
102
120
|
* Get couple relationship details
|
|
103
121
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as FamilySearchSDKConfig, F as FamilySearchEnvironment, E as EnvironmentConfig, b as FamilySearchApiResponse, d as FamilySearchUser, e as FamilySearchPerson, i as PersonWithRelationships, j as PersonNotesResponse,
|
|
1
|
+
import { a as FamilySearchSDKConfig, F as FamilySearchEnvironment, E as EnvironmentConfig, b as FamilySearchApiResponse, d as FamilySearchUser, e as FamilySearchPerson, i as PersonWithRelationships, j as PersonNotesResponse, k as PersonMemoriesResponse, m as PersonSourcesResponse, h as RelationshipDetails, u as PedigreeData, l as PersonSearchResponse, p as FamilySearchPlace } from './index-jdvA0fPb.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* FamilySearch SDK Client
|
|
@@ -98,6 +98,24 @@ declare class FamilySearchSDK {
|
|
|
98
98
|
* Get memories for a person
|
|
99
99
|
*/
|
|
100
100
|
getPersonMemories(personId: string): Promise<PersonMemoriesResponse | null>;
|
|
101
|
+
/**
|
|
102
|
+
* Get sources for a person
|
|
103
|
+
* Fetches all source references linked to a person
|
|
104
|
+
*
|
|
105
|
+
* @param personId - FamilySearch person ID
|
|
106
|
+
* @returns Person sources response with source references and descriptions, or null if error
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```typescript
|
|
110
|
+
* const sources = await sdk.getPersonSources('KWQS-BBQ');
|
|
111
|
+
* if (sources?.persons?.[0]?.sources) {
|
|
112
|
+
* sources.persons[0].sources.forEach(source => {
|
|
113
|
+
* console.log('Source:', source.descriptionId);
|
|
114
|
+
* });
|
|
115
|
+
* }
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
getPersonSources(personId: string): Promise<PersonSourcesResponse | null>;
|
|
101
119
|
/**
|
|
102
120
|
* Get couple relationship details
|
|
103
121
|
*/
|
|
@@ -386,6 +386,7 @@ interface PersonNotesResponse {
|
|
|
386
386
|
interface EnhancedPerson extends PersonData {
|
|
387
387
|
fullDetails?: PersonWithRelationships;
|
|
388
388
|
notes?: PersonNotesResponse;
|
|
389
|
+
sources?: PersonSourcesResponse;
|
|
389
390
|
}
|
|
390
391
|
/**
|
|
391
392
|
* Person with relationships response from getPersonWithDetails API
|
|
@@ -422,6 +423,21 @@ interface SourceReference {
|
|
|
422
423
|
value: string;
|
|
423
424
|
}>;
|
|
424
425
|
}
|
|
426
|
+
/**
|
|
427
|
+
* Person sources response from FamilySearch API
|
|
428
|
+
* Returned by GET /platform/tree/persons/{personId}/sources
|
|
429
|
+
*/
|
|
430
|
+
interface PersonSourcesResponse {
|
|
431
|
+
/** Array of persons with their sources */
|
|
432
|
+
persons?: Array<{
|
|
433
|
+
/** Person ID */
|
|
434
|
+
id?: string;
|
|
435
|
+
/** Source references attached to the person */
|
|
436
|
+
sources?: SourceReference[];
|
|
437
|
+
}>;
|
|
438
|
+
/** Source descriptions providing details about sources */
|
|
439
|
+
sourceDescriptions?: SourceDescription[];
|
|
440
|
+
}
|
|
425
441
|
/**
|
|
426
442
|
* Enhanced pedigree with full details
|
|
427
443
|
*/
|
|
@@ -481,4 +497,4 @@ type ProgressCallback = (progress: {
|
|
|
481
497
|
percent: number;
|
|
482
498
|
}) => void;
|
|
483
499
|
|
|
484
|
-
export type { ChildAndParentsRelationship as C, EnvironmentConfig as E, FamilySearchEnvironment as F, NameForm as N, OAuthTokenResponse as O, PersonDisplay as P, Relationship as R, SDKLogger as S, FamilySearchSDKConfig as a, FamilySearchApiResponse as b, FamilySearchApiError as c, FamilySearchUser as d, FamilySearchPerson as e, PersonFact as f, PersonData as g, RelationshipDetails as h, PersonWithRelationships as i, PersonNotesResponse as j,
|
|
500
|
+
export type { ProgressCallback as A, ChildAndParentsRelationship as C, EnvironmentConfig as E, FamilySearchEnvironment as F, NameForm as N, OAuthTokenResponse as O, PersonDisplay as P, Relationship as R, SDKLogger as S, FamilySearchSDKConfig as a, FamilySearchApiResponse as b, FamilySearchApiError as c, FamilySearchUser as d, FamilySearchPerson as e, PersonFact as f, PersonData as g, RelationshipDetails as h, PersonWithRelationships as i, PersonNotesResponse as j, PersonMemoriesResponse as k, PersonSearchResponse as l, PersonSourcesResponse as m, SourceDescription as n, SourceReference as o, FamilySearchPlace as p, PlaceDescription as q, PlaceSearchResult as r, PlaceSearchResponse as s, PlaceDetailsResponse as t, PedigreeData as u, EnhancedPerson as v, EnhancedPedigreeData as w, OAuthEndpoints as x, OAuthConfig as y, OAuthStateValidation as z };
|
|
@@ -386,6 +386,7 @@ interface PersonNotesResponse {
|
|
|
386
386
|
interface EnhancedPerson extends PersonData {
|
|
387
387
|
fullDetails?: PersonWithRelationships;
|
|
388
388
|
notes?: PersonNotesResponse;
|
|
389
|
+
sources?: PersonSourcesResponse;
|
|
389
390
|
}
|
|
390
391
|
/**
|
|
391
392
|
* Person with relationships response from getPersonWithDetails API
|
|
@@ -422,6 +423,21 @@ interface SourceReference {
|
|
|
422
423
|
value: string;
|
|
423
424
|
}>;
|
|
424
425
|
}
|
|
426
|
+
/**
|
|
427
|
+
* Person sources response from FamilySearch API
|
|
428
|
+
* Returned by GET /platform/tree/persons/{personId}/sources
|
|
429
|
+
*/
|
|
430
|
+
interface PersonSourcesResponse {
|
|
431
|
+
/** Array of persons with their sources */
|
|
432
|
+
persons?: Array<{
|
|
433
|
+
/** Person ID */
|
|
434
|
+
id?: string;
|
|
435
|
+
/** Source references attached to the person */
|
|
436
|
+
sources?: SourceReference[];
|
|
437
|
+
}>;
|
|
438
|
+
/** Source descriptions providing details about sources */
|
|
439
|
+
sourceDescriptions?: SourceDescription[];
|
|
440
|
+
}
|
|
425
441
|
/**
|
|
426
442
|
* Enhanced pedigree with full details
|
|
427
443
|
*/
|
|
@@ -481,4 +497,4 @@ type ProgressCallback = (progress: {
|
|
|
481
497
|
percent: number;
|
|
482
498
|
}) => void;
|
|
483
499
|
|
|
484
|
-
export type { ChildAndParentsRelationship as C, EnvironmentConfig as E, FamilySearchEnvironment as F, NameForm as N, OAuthTokenResponse as O, PersonDisplay as P, Relationship as R, SDKLogger as S, FamilySearchSDKConfig as a, FamilySearchApiResponse as b, FamilySearchApiError as c, FamilySearchUser as d, FamilySearchPerson as e, PersonFact as f, PersonData as g, RelationshipDetails as h, PersonWithRelationships as i, PersonNotesResponse as j,
|
|
500
|
+
export type { ProgressCallback as A, ChildAndParentsRelationship as C, EnvironmentConfig as E, FamilySearchEnvironment as F, NameForm as N, OAuthTokenResponse as O, PersonDisplay as P, Relationship as R, SDKLogger as S, FamilySearchSDKConfig as a, FamilySearchApiResponse as b, FamilySearchApiError as c, FamilySearchUser as d, FamilySearchPerson as e, PersonFact as f, PersonData as g, RelationshipDetails as h, PersonWithRelationships as i, PersonNotesResponse as j, PersonMemoriesResponse as k, PersonSearchResponse as l, PersonSourcesResponse as m, SourceDescription as n, SourceReference as o, FamilySearchPlace as p, PlaceDescription as q, PlaceSearchResult as r, PlaceSearchResponse as s, PlaceDetailsResponse as t, PedigreeData as u, EnhancedPerson as v, EnhancedPedigreeData as w, OAuthEndpoints as x, OAuthConfig as y, OAuthStateValidation as z };
|
package/dist/index.cjs
CHANGED
|
@@ -264,6 +264,37 @@ var FamilySearchSDK = class {
|
|
|
264
264
|
return null;
|
|
265
265
|
}
|
|
266
266
|
}
|
|
267
|
+
/**
|
|
268
|
+
* Get sources for a person
|
|
269
|
+
* Fetches all source references linked to a person
|
|
270
|
+
*
|
|
271
|
+
* @param personId - FamilySearch person ID
|
|
272
|
+
* @returns Person sources response with source references and descriptions, or null if error
|
|
273
|
+
*
|
|
274
|
+
* @example
|
|
275
|
+
* ```typescript
|
|
276
|
+
* const sources = await sdk.getPersonSources('KWQS-BBQ');
|
|
277
|
+
* if (sources?.persons?.[0]?.sources) {
|
|
278
|
+
* sources.persons[0].sources.forEach(source => {
|
|
279
|
+
* console.log('Source:', source.descriptionId);
|
|
280
|
+
* });
|
|
281
|
+
* }
|
|
282
|
+
* ```
|
|
283
|
+
*/
|
|
284
|
+
async getPersonSources(personId) {
|
|
285
|
+
try {
|
|
286
|
+
const response = await this.get(
|
|
287
|
+
`/platform/tree/persons/${personId}/sources`
|
|
288
|
+
);
|
|
289
|
+
return response.data || null;
|
|
290
|
+
} catch (error) {
|
|
291
|
+
this.logger.error(
|
|
292
|
+
`[FamilySearch SDK] Failed to get sources for ${personId}:`,
|
|
293
|
+
error
|
|
294
|
+
);
|
|
295
|
+
return null;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
267
298
|
/**
|
|
268
299
|
* Get couple relationship details
|
|
269
300
|
*/
|
|
@@ -1490,6 +1521,47 @@ function convertToGedcom(pedigreeData, options = {}) {
|
|
|
1490
1521
|
}
|
|
1491
1522
|
});
|
|
1492
1523
|
}
|
|
1524
|
+
if (person.sources?.persons?.[0]?.sources) {
|
|
1525
|
+
const sourceDescMap = /* @__PURE__ */ new Map();
|
|
1526
|
+
if (person.sources.sourceDescriptions && Array.isArray(person.sources.sourceDescriptions)) {
|
|
1527
|
+
person.sources.sourceDescriptions.forEach((desc) => {
|
|
1528
|
+
if (desc.id) {
|
|
1529
|
+
sourceDescMap.set(desc.id, desc);
|
|
1530
|
+
}
|
|
1531
|
+
});
|
|
1532
|
+
}
|
|
1533
|
+
person.sources.persons[0].sources.forEach((sourceRef) => {
|
|
1534
|
+
if (sourceRef.descriptionId) {
|
|
1535
|
+
lines.push(`1 _FS_SOUR ${sourceRef.descriptionId}`);
|
|
1536
|
+
const sourceDesc = sourceDescMap.get(sourceRef.descriptionId);
|
|
1537
|
+
if (sourceDesc) {
|
|
1538
|
+
if (sourceDesc.titles?.[0]?.value) {
|
|
1539
|
+
lines.push(`2 TITL ${sourceDesc.titles[0].value}`);
|
|
1540
|
+
}
|
|
1541
|
+
if (sourceDesc.citations?.[0]?.value) {
|
|
1542
|
+
lines.push(`2 TEXT ${sourceDesc.citations[0].value}`);
|
|
1543
|
+
}
|
|
1544
|
+
if (sourceDesc.about) {
|
|
1545
|
+
const webUrl = transformSourceUrl(sourceDesc.about);
|
|
1546
|
+
lines.push(`2 WWW ${webUrl}`);
|
|
1547
|
+
}
|
|
1548
|
+
if (sourceDesc.resourceType) {
|
|
1549
|
+
lines.push(`2 NOTE Resource Type: ${sourceDesc.resourceType}`);
|
|
1550
|
+
}
|
|
1551
|
+
}
|
|
1552
|
+
if (sourceRef.description) {
|
|
1553
|
+
lines.push(`2 NOTE ${sourceRef.description}`);
|
|
1554
|
+
}
|
|
1555
|
+
if (sourceRef.qualifiers && Array.isArray(sourceRef.qualifiers)) {
|
|
1556
|
+
sourceRef.qualifiers.forEach((qualifier) => {
|
|
1557
|
+
if (qualifier.name && qualifier.value) {
|
|
1558
|
+
lines.push(`2 NOTE ${qualifier.name}: ${qualifier.value}`);
|
|
1559
|
+
}
|
|
1560
|
+
});
|
|
1561
|
+
}
|
|
1562
|
+
}
|
|
1563
|
+
});
|
|
1564
|
+
}
|
|
1493
1565
|
});
|
|
1494
1566
|
let famIndex = 1;
|
|
1495
1567
|
const familyIdMap = /* @__PURE__ */ new Map();
|