@digitalculture/ochre-sdk 0.5.11 → 0.5.13
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/dist/index.cjs +38 -2
- package/dist/index.d.cts +41 -4
- package/dist/index.d.ts +41 -4
- package/dist/index.js +37 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -25,6 +25,7 @@ __export(index_exports, {
|
|
|
25
25
|
fetchConcept: () => fetchConcept,
|
|
26
26
|
fetchGallery: () => fetchGallery,
|
|
27
27
|
fetchPeriod: () => fetchPeriod,
|
|
28
|
+
fetchPropertyValue: () => fetchPropertyValue,
|
|
28
29
|
fetchResource: () => fetchResource,
|
|
29
30
|
fetchSet: () => fetchSet,
|
|
30
31
|
fetchSpatialUnit: () => fetchSpatialUnit,
|
|
@@ -1026,10 +1027,16 @@ function parsePropertyValue(propertyValue) {
|
|
|
1026
1027
|
category: "propertyValue",
|
|
1027
1028
|
n: propertyValue.n,
|
|
1028
1029
|
publicationDateTime: propertyValue.publicationDateTime ? new Date(propertyValue.publicationDateTime) : null,
|
|
1030
|
+
context: propertyValue.context ? parseContext(propertyValue.context) : null,
|
|
1031
|
+
availability: propertyValue.availability ? parseLicense(propertyValue.availability) : null,
|
|
1029
1032
|
identification: parseIdentification(propertyValue.identification),
|
|
1030
|
-
|
|
1033
|
+
date: propertyValue.date ? new Date(propertyValue.date) : null,
|
|
1034
|
+
creators: propertyValue.creators ? parsePersons(
|
|
1035
|
+
Array.isArray(propertyValue.creators.creator) ? propertyValue.creators.creator : [propertyValue.creators.creator]
|
|
1036
|
+
) : [],
|
|
1037
|
+
description: propertyValue.description ? ["string", "number", "boolean"].includes(
|
|
1031
1038
|
typeof propertyValue.description
|
|
1032
|
-
) ? parseFakeString(propertyValue.description) : parseStringContent(propertyValue.description),
|
|
1039
|
+
) ? parseFakeString(propertyValue.description) : parseStringContent(propertyValue.description) : "",
|
|
1033
1040
|
notes: propertyValue.notes ? parseNotes(
|
|
1034
1041
|
Array.isArray(propertyValue.notes.note) ? propertyValue.notes.note : [propertyValue.notes.note]
|
|
1035
1042
|
) : [],
|
|
@@ -2542,6 +2549,34 @@ async function fetchPeriod(uuid) {
|
|
|
2542
2549
|
}
|
|
2543
2550
|
}
|
|
2544
2551
|
|
|
2552
|
+
// src/utils/fetchers/property-value.ts
|
|
2553
|
+
async function fetchPropertyValue(uuid) {
|
|
2554
|
+
try {
|
|
2555
|
+
const [error, dataRaw] = await fetchByUuid(uuid);
|
|
2556
|
+
if (error !== null) {
|
|
2557
|
+
throw new Error(error);
|
|
2558
|
+
}
|
|
2559
|
+
if (!("value" in dataRaw.ochre)) {
|
|
2560
|
+
throw new Error("Invalid OCHRE data: API response missing 'value' key");
|
|
2561
|
+
}
|
|
2562
|
+
const propertyValueItem = parsePropertyValue(dataRaw.ochre.value);
|
|
2563
|
+
const data = {
|
|
2564
|
+
uuid: parseFakeString(dataRaw.ochre.uuid),
|
|
2565
|
+
publicationDateTime: new Date(dataRaw.ochre.publicationDateTime),
|
|
2566
|
+
belongsTo: {
|
|
2567
|
+
uuid: dataRaw.ochre.uuidBelongsTo,
|
|
2568
|
+
abbreviation: parseFakeString(dataRaw.ochre.belongsTo)
|
|
2569
|
+
},
|
|
2570
|
+
metadata: parseMetadata(dataRaw.ochre.metadata),
|
|
2571
|
+
item: propertyValueItem
|
|
2572
|
+
};
|
|
2573
|
+
return { metadata: data.metadata, propertyValue: data.item };
|
|
2574
|
+
} catch (error) {
|
|
2575
|
+
console.error(error);
|
|
2576
|
+
return null;
|
|
2577
|
+
}
|
|
2578
|
+
}
|
|
2579
|
+
|
|
2545
2580
|
// src/utils/fetchers/set.ts
|
|
2546
2581
|
async function fetchSet(uuid) {
|
|
2547
2582
|
try {
|
|
@@ -2663,6 +2698,7 @@ async function fetchWebsite(abbreviation) {
|
|
|
2663
2698
|
fetchConcept,
|
|
2664
2699
|
fetchGallery,
|
|
2665
2700
|
fetchPeriod,
|
|
2701
|
+
fetchPropertyValue,
|
|
2666
2702
|
fetchResource,
|
|
2667
2703
|
fetchSet,
|
|
2668
2704
|
fetchSpatialUnit,
|
package/dist/index.d.cts
CHANGED
|
@@ -351,7 +351,11 @@ type PropertyValue = {
|
|
|
351
351
|
category: "propertyValue";
|
|
352
352
|
n: number;
|
|
353
353
|
publicationDateTime: Date | null;
|
|
354
|
+
context: Context | null;
|
|
355
|
+
availability: License | null;
|
|
354
356
|
identification: Identification;
|
|
357
|
+
date: Date | null;
|
|
358
|
+
creators: Array<Person>;
|
|
355
359
|
description: string;
|
|
356
360
|
notes: Array<Note>;
|
|
357
361
|
links: Array<Link>;
|
|
@@ -810,7 +814,7 @@ type OchreData = {
|
|
|
810
814
|
| { period: OchrePeriod }
|
|
811
815
|
| { bibliography: OchreBibliography }
|
|
812
816
|
| { person: OchrePerson }
|
|
813
|
-
| {
|
|
817
|
+
| { value: OchrePropertyValue }
|
|
814
818
|
);
|
|
815
819
|
};
|
|
816
820
|
|
|
@@ -1285,10 +1289,14 @@ type OchreInterpretation = {
|
|
|
1285
1289
|
*/
|
|
1286
1290
|
type OchrePropertyValue = {
|
|
1287
1291
|
uuid: string;
|
|
1292
|
+
publicationDateTime?: string; // YYYY-MM-DDThh:mm:ssZ
|
|
1288
1293
|
n: number;
|
|
1289
|
-
|
|
1294
|
+
context?: OchreContext;
|
|
1295
|
+
availability?: OchreLicense;
|
|
1290
1296
|
identification: OchreIdentification;
|
|
1291
|
-
|
|
1297
|
+
date?: string; // YYYY-MM-DD
|
|
1298
|
+
creators?: { creator: OchrePerson | Array<OchrePerson> };
|
|
1299
|
+
description?: OchreStringContent | FakeString;
|
|
1292
1300
|
notes?: { note: OchreNote | Array<OchreNote> };
|
|
1293
1301
|
links?: OchreLink | Array<OchreLink>;
|
|
1294
1302
|
};
|
|
@@ -1342,6 +1350,35 @@ declare function fetchPeriod(uuid: string): Promise<{
|
|
|
1342
1350
|
period: Period;
|
|
1343
1351
|
} | null>;
|
|
1344
1352
|
|
|
1353
|
+
/**
|
|
1354
|
+
* Fetches and parses a property value from the OCHRE API
|
|
1355
|
+
*
|
|
1356
|
+
* @param uuid - The UUID of the property value to fetch
|
|
1357
|
+
* @returns Object containing the parsed property value and its metadata, or null if the fetch/parse fails
|
|
1358
|
+
*
|
|
1359
|
+
* @example
|
|
1360
|
+
* ```ts
|
|
1361
|
+
* const result = await fetchPropertyValue("123e4567-e89b-12d3-a456-426614174000");
|
|
1362
|
+
* if (result === null) {
|
|
1363
|
+
* console.error("Failed to fetch property value");
|
|
1364
|
+
* return;
|
|
1365
|
+
* }
|
|
1366
|
+
* const { metadata, item } = result;
|
|
1367
|
+
* console.log(`Fetched property value: ${item.identification.label}`);
|
|
1368
|
+
* ```
|
|
1369
|
+
*
|
|
1370
|
+
* @remarks
|
|
1371
|
+
* The returned property value includes:
|
|
1372
|
+
* - Identification
|
|
1373
|
+
* - Description
|
|
1374
|
+
* - Notes
|
|
1375
|
+
* - Links
|
|
1376
|
+
*/
|
|
1377
|
+
declare function fetchPropertyValue(uuid: string): Promise<{
|
|
1378
|
+
metadata: Metadata;
|
|
1379
|
+
propertyValue: PropertyValue;
|
|
1380
|
+
} | null>;
|
|
1381
|
+
|
|
1345
1382
|
/**
|
|
1346
1383
|
* Fetches and parses a resource from the OCHRE API
|
|
1347
1384
|
*
|
|
@@ -1891,4 +1928,4 @@ declare function parseStringDocumentItem(item: OchreStringRichTextItem, footnote
|
|
|
1891
1928
|
*/
|
|
1892
1929
|
declare function parseStringContent(content: OchreStringContent, language?: string): string;
|
|
1893
1930
|
|
|
1894
|
-
export { type Bibliography, type Concept, type Context, type ContextItem, type ContextNode, type Coordinates, type Data, type Document, type Event, type Footnote, type Gallery, type Identification, type Image, type ImageMap, type ImageMapArea, type Interpretation, type License, type Link, type Metadata, type NestedConcept, type NestedResource, type NestedSpatialUnit, type Note, type Observation, type Period, type Person, type Property, type PropertyValue, type PropertyValueContent, type Resource, type Set, type SpatialUnit, type Style, type Tree, type WebBlock, type WebElement, type WebElementComponent, type WebImage, type Webpage, type WebpageProperties, type Website, type WebsiteProperties, fetchBibliography, fetchByUuid, fetchConcept, fetchGallery, fetchPeriod, fetchResource, fetchSet, fetchSpatialUnit, fetchTree, fetchWebsite, filterProperties, getAllPropertyLabels, getPropertyByLabel, getPropertyValueByLabel, getPropertyValuesByLabel, parseBibliographies, parseBibliography, parseConcept, parseConcepts, parseContext, parseCoordinates, parseDocument, parseEmail, parseEvents, parseFakeString, parseIdentification, parseImage, parseImageMap, parseInterpretations, parseLanguages, parseLicense, parseLink, parseLinks, parseMetadata, parseNotes, parseObservation, parseObservations, parsePeriod, parsePeriods, parsePerson, parsePersons, parseProperties, parsePropertyValue, parsePropertyValues, parseResource, parseResources, parseSet, parseSpatialUnit, parseSpatialUnits, parseStringContent, parseStringDocumentItem, parseStringItem, parseTree, parseWebsite };
|
|
1931
|
+
export { type Bibliography, type Concept, type Context, type ContextItem, type ContextNode, type Coordinates, type Data, type Document, type Event, type Footnote, type Gallery, type Identification, type Image, type ImageMap, type ImageMapArea, type Interpretation, type License, type Link, type Metadata, type NestedConcept, type NestedResource, type NestedSpatialUnit, type Note, type Observation, type Period, type Person, type Property, type PropertyValue, type PropertyValueContent, type Resource, type Set, type SpatialUnit, type Style, type Tree, type WebBlock, type WebElement, type WebElementComponent, type WebImage, type Webpage, type WebpageProperties, type Website, type WebsiteProperties, fetchBibliography, fetchByUuid, fetchConcept, fetchGallery, fetchPeriod, fetchPropertyValue, fetchResource, fetchSet, fetchSpatialUnit, fetchTree, fetchWebsite, filterProperties, getAllPropertyLabels, getPropertyByLabel, getPropertyValueByLabel, getPropertyValuesByLabel, parseBibliographies, parseBibliography, parseConcept, parseConcepts, parseContext, parseCoordinates, parseDocument, parseEmail, parseEvents, parseFakeString, parseIdentification, parseImage, parseImageMap, parseInterpretations, parseLanguages, parseLicense, parseLink, parseLinks, parseMetadata, parseNotes, parseObservation, parseObservations, parsePeriod, parsePeriods, parsePerson, parsePersons, parseProperties, parsePropertyValue, parsePropertyValues, parseResource, parseResources, parseSet, parseSpatialUnit, parseSpatialUnits, parseStringContent, parseStringDocumentItem, parseStringItem, parseTree, parseWebsite };
|
package/dist/index.d.ts
CHANGED
|
@@ -351,7 +351,11 @@ type PropertyValue = {
|
|
|
351
351
|
category: "propertyValue";
|
|
352
352
|
n: number;
|
|
353
353
|
publicationDateTime: Date | null;
|
|
354
|
+
context: Context | null;
|
|
355
|
+
availability: License | null;
|
|
354
356
|
identification: Identification;
|
|
357
|
+
date: Date | null;
|
|
358
|
+
creators: Array<Person>;
|
|
355
359
|
description: string;
|
|
356
360
|
notes: Array<Note>;
|
|
357
361
|
links: Array<Link>;
|
|
@@ -810,7 +814,7 @@ type OchreData = {
|
|
|
810
814
|
| { period: OchrePeriod }
|
|
811
815
|
| { bibliography: OchreBibliography }
|
|
812
816
|
| { person: OchrePerson }
|
|
813
|
-
| {
|
|
817
|
+
| { value: OchrePropertyValue }
|
|
814
818
|
);
|
|
815
819
|
};
|
|
816
820
|
|
|
@@ -1285,10 +1289,14 @@ type OchreInterpretation = {
|
|
|
1285
1289
|
*/
|
|
1286
1290
|
type OchrePropertyValue = {
|
|
1287
1291
|
uuid: string;
|
|
1292
|
+
publicationDateTime?: string; // YYYY-MM-DDThh:mm:ssZ
|
|
1288
1293
|
n: number;
|
|
1289
|
-
|
|
1294
|
+
context?: OchreContext;
|
|
1295
|
+
availability?: OchreLicense;
|
|
1290
1296
|
identification: OchreIdentification;
|
|
1291
|
-
|
|
1297
|
+
date?: string; // YYYY-MM-DD
|
|
1298
|
+
creators?: { creator: OchrePerson | Array<OchrePerson> };
|
|
1299
|
+
description?: OchreStringContent | FakeString;
|
|
1292
1300
|
notes?: { note: OchreNote | Array<OchreNote> };
|
|
1293
1301
|
links?: OchreLink | Array<OchreLink>;
|
|
1294
1302
|
};
|
|
@@ -1342,6 +1350,35 @@ declare function fetchPeriod(uuid: string): Promise<{
|
|
|
1342
1350
|
period: Period;
|
|
1343
1351
|
} | null>;
|
|
1344
1352
|
|
|
1353
|
+
/**
|
|
1354
|
+
* Fetches and parses a property value from the OCHRE API
|
|
1355
|
+
*
|
|
1356
|
+
* @param uuid - The UUID of the property value to fetch
|
|
1357
|
+
* @returns Object containing the parsed property value and its metadata, or null if the fetch/parse fails
|
|
1358
|
+
*
|
|
1359
|
+
* @example
|
|
1360
|
+
* ```ts
|
|
1361
|
+
* const result = await fetchPropertyValue("123e4567-e89b-12d3-a456-426614174000");
|
|
1362
|
+
* if (result === null) {
|
|
1363
|
+
* console.error("Failed to fetch property value");
|
|
1364
|
+
* return;
|
|
1365
|
+
* }
|
|
1366
|
+
* const { metadata, item } = result;
|
|
1367
|
+
* console.log(`Fetched property value: ${item.identification.label}`);
|
|
1368
|
+
* ```
|
|
1369
|
+
*
|
|
1370
|
+
* @remarks
|
|
1371
|
+
* The returned property value includes:
|
|
1372
|
+
* - Identification
|
|
1373
|
+
* - Description
|
|
1374
|
+
* - Notes
|
|
1375
|
+
* - Links
|
|
1376
|
+
*/
|
|
1377
|
+
declare function fetchPropertyValue(uuid: string): Promise<{
|
|
1378
|
+
metadata: Metadata;
|
|
1379
|
+
propertyValue: PropertyValue;
|
|
1380
|
+
} | null>;
|
|
1381
|
+
|
|
1345
1382
|
/**
|
|
1346
1383
|
* Fetches and parses a resource from the OCHRE API
|
|
1347
1384
|
*
|
|
@@ -1891,4 +1928,4 @@ declare function parseStringDocumentItem(item: OchreStringRichTextItem, footnote
|
|
|
1891
1928
|
*/
|
|
1892
1929
|
declare function parseStringContent(content: OchreStringContent, language?: string): string;
|
|
1893
1930
|
|
|
1894
|
-
export { type Bibliography, type Concept, type Context, type ContextItem, type ContextNode, type Coordinates, type Data, type Document, type Event, type Footnote, type Gallery, type Identification, type Image, type ImageMap, type ImageMapArea, type Interpretation, type License, type Link, type Metadata, type NestedConcept, type NestedResource, type NestedSpatialUnit, type Note, type Observation, type Period, type Person, type Property, type PropertyValue, type PropertyValueContent, type Resource, type Set, type SpatialUnit, type Style, type Tree, type WebBlock, type WebElement, type WebElementComponent, type WebImage, type Webpage, type WebpageProperties, type Website, type WebsiteProperties, fetchBibliography, fetchByUuid, fetchConcept, fetchGallery, fetchPeriod, fetchResource, fetchSet, fetchSpatialUnit, fetchTree, fetchWebsite, filterProperties, getAllPropertyLabels, getPropertyByLabel, getPropertyValueByLabel, getPropertyValuesByLabel, parseBibliographies, parseBibliography, parseConcept, parseConcepts, parseContext, parseCoordinates, parseDocument, parseEmail, parseEvents, parseFakeString, parseIdentification, parseImage, parseImageMap, parseInterpretations, parseLanguages, parseLicense, parseLink, parseLinks, parseMetadata, parseNotes, parseObservation, parseObservations, parsePeriod, parsePeriods, parsePerson, parsePersons, parseProperties, parsePropertyValue, parsePropertyValues, parseResource, parseResources, parseSet, parseSpatialUnit, parseSpatialUnits, parseStringContent, parseStringDocumentItem, parseStringItem, parseTree, parseWebsite };
|
|
1931
|
+
export { type Bibliography, type Concept, type Context, type ContextItem, type ContextNode, type Coordinates, type Data, type Document, type Event, type Footnote, type Gallery, type Identification, type Image, type ImageMap, type ImageMapArea, type Interpretation, type License, type Link, type Metadata, type NestedConcept, type NestedResource, type NestedSpatialUnit, type Note, type Observation, type Period, type Person, type Property, type PropertyValue, type PropertyValueContent, type Resource, type Set, type SpatialUnit, type Style, type Tree, type WebBlock, type WebElement, type WebElementComponent, type WebImage, type Webpage, type WebpageProperties, type Website, type WebsiteProperties, fetchBibliography, fetchByUuid, fetchConcept, fetchGallery, fetchPeriod, fetchPropertyValue, fetchResource, fetchSet, fetchSpatialUnit, fetchTree, fetchWebsite, filterProperties, getAllPropertyLabels, getPropertyByLabel, getPropertyValueByLabel, getPropertyValuesByLabel, parseBibliographies, parseBibliography, parseConcept, parseConcepts, parseContext, parseCoordinates, parseDocument, parseEmail, parseEvents, parseFakeString, parseIdentification, parseImage, parseImageMap, parseInterpretations, parseLanguages, parseLicense, parseLink, parseLinks, parseMetadata, parseNotes, parseObservation, parseObservations, parsePeriod, parsePeriods, parsePerson, parsePersons, parseProperties, parsePropertyValue, parsePropertyValues, parseResource, parseResources, parseSet, parseSpatialUnit, parseSpatialUnits, parseStringContent, parseStringDocumentItem, parseStringItem, parseTree, parseWebsite };
|
package/dist/index.js
CHANGED
|
@@ -947,10 +947,16 @@ function parsePropertyValue(propertyValue) {
|
|
|
947
947
|
category: "propertyValue",
|
|
948
948
|
n: propertyValue.n,
|
|
949
949
|
publicationDateTime: propertyValue.publicationDateTime ? new Date(propertyValue.publicationDateTime) : null,
|
|
950
|
+
context: propertyValue.context ? parseContext(propertyValue.context) : null,
|
|
951
|
+
availability: propertyValue.availability ? parseLicense(propertyValue.availability) : null,
|
|
950
952
|
identification: parseIdentification(propertyValue.identification),
|
|
951
|
-
|
|
953
|
+
date: propertyValue.date ? new Date(propertyValue.date) : null,
|
|
954
|
+
creators: propertyValue.creators ? parsePersons(
|
|
955
|
+
Array.isArray(propertyValue.creators.creator) ? propertyValue.creators.creator : [propertyValue.creators.creator]
|
|
956
|
+
) : [],
|
|
957
|
+
description: propertyValue.description ? ["string", "number", "boolean"].includes(
|
|
952
958
|
typeof propertyValue.description
|
|
953
|
-
) ? parseFakeString(propertyValue.description) : parseStringContent(propertyValue.description),
|
|
959
|
+
) ? parseFakeString(propertyValue.description) : parseStringContent(propertyValue.description) : "",
|
|
954
960
|
notes: propertyValue.notes ? parseNotes(
|
|
955
961
|
Array.isArray(propertyValue.notes.note) ? propertyValue.notes.note : [propertyValue.notes.note]
|
|
956
962
|
) : [],
|
|
@@ -2463,6 +2469,34 @@ async function fetchPeriod(uuid) {
|
|
|
2463
2469
|
}
|
|
2464
2470
|
}
|
|
2465
2471
|
|
|
2472
|
+
// src/utils/fetchers/property-value.ts
|
|
2473
|
+
async function fetchPropertyValue(uuid) {
|
|
2474
|
+
try {
|
|
2475
|
+
const [error, dataRaw] = await fetchByUuid(uuid);
|
|
2476
|
+
if (error !== null) {
|
|
2477
|
+
throw new Error(error);
|
|
2478
|
+
}
|
|
2479
|
+
if (!("value" in dataRaw.ochre)) {
|
|
2480
|
+
throw new Error("Invalid OCHRE data: API response missing 'value' key");
|
|
2481
|
+
}
|
|
2482
|
+
const propertyValueItem = parsePropertyValue(dataRaw.ochre.value);
|
|
2483
|
+
const data = {
|
|
2484
|
+
uuid: parseFakeString(dataRaw.ochre.uuid),
|
|
2485
|
+
publicationDateTime: new Date(dataRaw.ochre.publicationDateTime),
|
|
2486
|
+
belongsTo: {
|
|
2487
|
+
uuid: dataRaw.ochre.uuidBelongsTo,
|
|
2488
|
+
abbreviation: parseFakeString(dataRaw.ochre.belongsTo)
|
|
2489
|
+
},
|
|
2490
|
+
metadata: parseMetadata(dataRaw.ochre.metadata),
|
|
2491
|
+
item: propertyValueItem
|
|
2492
|
+
};
|
|
2493
|
+
return { metadata: data.metadata, propertyValue: data.item };
|
|
2494
|
+
} catch (error) {
|
|
2495
|
+
console.error(error);
|
|
2496
|
+
return null;
|
|
2497
|
+
}
|
|
2498
|
+
}
|
|
2499
|
+
|
|
2466
2500
|
// src/utils/fetchers/set.ts
|
|
2467
2501
|
async function fetchSet(uuid) {
|
|
2468
2502
|
try {
|
|
@@ -2583,6 +2617,7 @@ export {
|
|
|
2583
2617
|
fetchConcept,
|
|
2584
2618
|
fetchGallery,
|
|
2585
2619
|
fetchPeriod,
|
|
2620
|
+
fetchPropertyValue,
|
|
2586
2621
|
fetchResource,
|
|
2587
2622
|
fetchSet,
|
|
2588
2623
|
fetchSpatialUnit,
|
package/package.json
CHANGED