@digitalculture/ochre-sdk 0.5.11 → 0.5.12
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 +32 -0
- package/dist/index.d.cts +30 -1
- package/dist/index.d.ts +30 -1
- package/dist/index.js +31 -0
- 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,
|
|
@@ -2542,6 +2543,36 @@ async function fetchPeriod(uuid) {
|
|
|
2542
2543
|
}
|
|
2543
2544
|
}
|
|
2544
2545
|
|
|
2546
|
+
// src/utils/fetchers/property-value.ts
|
|
2547
|
+
async function fetchPropertyValue(uuid) {
|
|
2548
|
+
try {
|
|
2549
|
+
const [error, dataRaw] = await fetchByUuid(uuid);
|
|
2550
|
+
if (error !== null) {
|
|
2551
|
+
throw new Error(error);
|
|
2552
|
+
}
|
|
2553
|
+
if (!("propertyValue" in dataRaw.ochre)) {
|
|
2554
|
+
throw new Error(
|
|
2555
|
+
"Invalid OCHRE data: API response missing 'propertyValue' key"
|
|
2556
|
+
);
|
|
2557
|
+
}
|
|
2558
|
+
const propertyValueItem = parsePropertyValue(dataRaw.ochre.propertyValue);
|
|
2559
|
+
const data = {
|
|
2560
|
+
uuid: parseFakeString(dataRaw.ochre.uuid),
|
|
2561
|
+
publicationDateTime: new Date(dataRaw.ochre.publicationDateTime),
|
|
2562
|
+
belongsTo: {
|
|
2563
|
+
uuid: dataRaw.ochre.uuidBelongsTo,
|
|
2564
|
+
abbreviation: parseFakeString(dataRaw.ochre.belongsTo)
|
|
2565
|
+
},
|
|
2566
|
+
metadata: parseMetadata(dataRaw.ochre.metadata),
|
|
2567
|
+
item: propertyValueItem
|
|
2568
|
+
};
|
|
2569
|
+
return { metadata: data.metadata, propertyValue: data.item };
|
|
2570
|
+
} catch (error) {
|
|
2571
|
+
console.error(error);
|
|
2572
|
+
return null;
|
|
2573
|
+
}
|
|
2574
|
+
}
|
|
2575
|
+
|
|
2545
2576
|
// src/utils/fetchers/set.ts
|
|
2546
2577
|
async function fetchSet(uuid) {
|
|
2547
2578
|
try {
|
|
@@ -2663,6 +2694,7 @@ async function fetchWebsite(abbreviation) {
|
|
|
2663
2694
|
fetchConcept,
|
|
2664
2695
|
fetchGallery,
|
|
2665
2696
|
fetchPeriod,
|
|
2697
|
+
fetchPropertyValue,
|
|
2666
2698
|
fetchResource,
|
|
2667
2699
|
fetchSet,
|
|
2668
2700
|
fetchSpatialUnit,
|
package/dist/index.d.cts
CHANGED
|
@@ -1342,6 +1342,35 @@ declare function fetchPeriod(uuid: string): Promise<{
|
|
|
1342
1342
|
period: Period;
|
|
1343
1343
|
} | null>;
|
|
1344
1344
|
|
|
1345
|
+
/**
|
|
1346
|
+
* Fetches and parses a property value from the OCHRE API
|
|
1347
|
+
*
|
|
1348
|
+
* @param uuid - The UUID of the property value to fetch
|
|
1349
|
+
* @returns Object containing the parsed property value and its metadata, or null if the fetch/parse fails
|
|
1350
|
+
*
|
|
1351
|
+
* @example
|
|
1352
|
+
* ```ts
|
|
1353
|
+
* const result = await fetchPropertyValue("123e4567-e89b-12d3-a456-426614174000");
|
|
1354
|
+
* if (result === null) {
|
|
1355
|
+
* console.error("Failed to fetch property value");
|
|
1356
|
+
* return;
|
|
1357
|
+
* }
|
|
1358
|
+
* const { metadata, item } = result;
|
|
1359
|
+
* console.log(`Fetched property value: ${item.identification.label}`);
|
|
1360
|
+
* ```
|
|
1361
|
+
*
|
|
1362
|
+
* @remarks
|
|
1363
|
+
* The returned property value includes:
|
|
1364
|
+
* - Identification
|
|
1365
|
+
* - Description
|
|
1366
|
+
* - Notes
|
|
1367
|
+
* - Links
|
|
1368
|
+
*/
|
|
1369
|
+
declare function fetchPropertyValue(uuid: string): Promise<{
|
|
1370
|
+
metadata: Metadata;
|
|
1371
|
+
propertyValue: PropertyValue;
|
|
1372
|
+
} | null>;
|
|
1373
|
+
|
|
1345
1374
|
/**
|
|
1346
1375
|
* Fetches and parses a resource from the OCHRE API
|
|
1347
1376
|
*
|
|
@@ -1891,4 +1920,4 @@ declare function parseStringDocumentItem(item: OchreStringRichTextItem, footnote
|
|
|
1891
1920
|
*/
|
|
1892
1921
|
declare function parseStringContent(content: OchreStringContent, language?: string): string;
|
|
1893
1922
|
|
|
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 };
|
|
1923
|
+
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
|
@@ -1342,6 +1342,35 @@ declare function fetchPeriod(uuid: string): Promise<{
|
|
|
1342
1342
|
period: Period;
|
|
1343
1343
|
} | null>;
|
|
1344
1344
|
|
|
1345
|
+
/**
|
|
1346
|
+
* Fetches and parses a property value from the OCHRE API
|
|
1347
|
+
*
|
|
1348
|
+
* @param uuid - The UUID of the property value to fetch
|
|
1349
|
+
* @returns Object containing the parsed property value and its metadata, or null if the fetch/parse fails
|
|
1350
|
+
*
|
|
1351
|
+
* @example
|
|
1352
|
+
* ```ts
|
|
1353
|
+
* const result = await fetchPropertyValue("123e4567-e89b-12d3-a456-426614174000");
|
|
1354
|
+
* if (result === null) {
|
|
1355
|
+
* console.error("Failed to fetch property value");
|
|
1356
|
+
* return;
|
|
1357
|
+
* }
|
|
1358
|
+
* const { metadata, item } = result;
|
|
1359
|
+
* console.log(`Fetched property value: ${item.identification.label}`);
|
|
1360
|
+
* ```
|
|
1361
|
+
*
|
|
1362
|
+
* @remarks
|
|
1363
|
+
* The returned property value includes:
|
|
1364
|
+
* - Identification
|
|
1365
|
+
* - Description
|
|
1366
|
+
* - Notes
|
|
1367
|
+
* - Links
|
|
1368
|
+
*/
|
|
1369
|
+
declare function fetchPropertyValue(uuid: string): Promise<{
|
|
1370
|
+
metadata: Metadata;
|
|
1371
|
+
propertyValue: PropertyValue;
|
|
1372
|
+
} | null>;
|
|
1373
|
+
|
|
1345
1374
|
/**
|
|
1346
1375
|
* Fetches and parses a resource from the OCHRE API
|
|
1347
1376
|
*
|
|
@@ -1891,4 +1920,4 @@ declare function parseStringDocumentItem(item: OchreStringRichTextItem, footnote
|
|
|
1891
1920
|
*/
|
|
1892
1921
|
declare function parseStringContent(content: OchreStringContent, language?: string): string;
|
|
1893
1922
|
|
|
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 };
|
|
1923
|
+
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
|
@@ -2463,6 +2463,36 @@ async function fetchPeriod(uuid) {
|
|
|
2463
2463
|
}
|
|
2464
2464
|
}
|
|
2465
2465
|
|
|
2466
|
+
// src/utils/fetchers/property-value.ts
|
|
2467
|
+
async function fetchPropertyValue(uuid) {
|
|
2468
|
+
try {
|
|
2469
|
+
const [error, dataRaw] = await fetchByUuid(uuid);
|
|
2470
|
+
if (error !== null) {
|
|
2471
|
+
throw new Error(error);
|
|
2472
|
+
}
|
|
2473
|
+
if (!("propertyValue" in dataRaw.ochre)) {
|
|
2474
|
+
throw new Error(
|
|
2475
|
+
"Invalid OCHRE data: API response missing 'propertyValue' key"
|
|
2476
|
+
);
|
|
2477
|
+
}
|
|
2478
|
+
const propertyValueItem = parsePropertyValue(dataRaw.ochre.propertyValue);
|
|
2479
|
+
const data = {
|
|
2480
|
+
uuid: parseFakeString(dataRaw.ochre.uuid),
|
|
2481
|
+
publicationDateTime: new Date(dataRaw.ochre.publicationDateTime),
|
|
2482
|
+
belongsTo: {
|
|
2483
|
+
uuid: dataRaw.ochre.uuidBelongsTo,
|
|
2484
|
+
abbreviation: parseFakeString(dataRaw.ochre.belongsTo)
|
|
2485
|
+
},
|
|
2486
|
+
metadata: parseMetadata(dataRaw.ochre.metadata),
|
|
2487
|
+
item: propertyValueItem
|
|
2488
|
+
};
|
|
2489
|
+
return { metadata: data.metadata, propertyValue: data.item };
|
|
2490
|
+
} catch (error) {
|
|
2491
|
+
console.error(error);
|
|
2492
|
+
return null;
|
|
2493
|
+
}
|
|
2494
|
+
}
|
|
2495
|
+
|
|
2466
2496
|
// src/utils/fetchers/set.ts
|
|
2467
2497
|
async function fetchSet(uuid) {
|
|
2468
2498
|
try {
|
|
@@ -2583,6 +2613,7 @@ export {
|
|
|
2583
2613
|
fetchConcept,
|
|
2584
2614
|
fetchGallery,
|
|
2585
2615
|
fetchPeriod,
|
|
2616
|
+
fetchPropertyValue,
|
|
2586
2617
|
fetchResource,
|
|
2587
2618
|
fetchSet,
|
|
2588
2619
|
fetchSpatialUnit,
|
package/package.json
CHANGED