@digitalculture/ochre-sdk 0.6.2 → 0.6.3
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 +28 -0
- package/dist/index.d.cts +32 -1
- package/dist/index.d.ts +32 -1
- package/dist/index.js +27 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -23,6 +23,7 @@ __export(index_exports, {
|
|
|
23
23
|
fetchByUuid: () => fetchByUuid,
|
|
24
24
|
fetchGallery: () => fetchGallery,
|
|
25
25
|
fetchItem: () => fetchItem,
|
|
26
|
+
fetchWebsite: () => fetchWebsite,
|
|
26
27
|
filterProperties: () => filterProperties,
|
|
27
28
|
getAllPropertyLabels: () => getAllPropertyLabels,
|
|
28
29
|
getPropertyByLabel: () => getPropertyByLabel,
|
|
@@ -2666,11 +2667,38 @@ async function fetchGallery(uuid, filter, page, perPage) {
|
|
|
2666
2667
|
};
|
|
2667
2668
|
}
|
|
2668
2669
|
}
|
|
2670
|
+
|
|
2671
|
+
// src/utils/fetchers/website.ts
|
|
2672
|
+
async function fetchWebsite(abbreviation) {
|
|
2673
|
+
try {
|
|
2674
|
+
const response = await fetch(
|
|
2675
|
+
`https://ochre.lib.uchicago.edu/ochre?xquery=for $q in input()/ochre[tree[@type='lesson'][identification/abbreviation='${abbreviation.toLocaleLowerCase("en-US")}']] return $q&format=json`
|
|
2676
|
+
);
|
|
2677
|
+
if (!response.ok) {
|
|
2678
|
+
throw new Error("Failed to fetch website");
|
|
2679
|
+
}
|
|
2680
|
+
const data = await response.json();
|
|
2681
|
+
if (!("ochre" in data.result) || !("tree" in data.result.ochre)) {
|
|
2682
|
+
throw new Error("Failed to fetch website");
|
|
2683
|
+
}
|
|
2684
|
+
const projectIdentification = data.result.ochre.metadata.project?.identification ? parseIdentification(data.result.ochre.metadata.project.identification) : null;
|
|
2685
|
+
const website = await parseWebsite(
|
|
2686
|
+
data.result.ochre.tree,
|
|
2687
|
+
projectIdentification?.label ?? "",
|
|
2688
|
+
data.result.ochre.metadata.project?.identification.website ?? null
|
|
2689
|
+
);
|
|
2690
|
+
return website;
|
|
2691
|
+
} catch (error) {
|
|
2692
|
+
console.error(error);
|
|
2693
|
+
return null;
|
|
2694
|
+
}
|
|
2695
|
+
}
|
|
2669
2696
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2670
2697
|
0 && (module.exports = {
|
|
2671
2698
|
fetchByUuid,
|
|
2672
2699
|
fetchGallery,
|
|
2673
2700
|
fetchItem,
|
|
2701
|
+
fetchWebsite,
|
|
2674
2702
|
filterProperties,
|
|
2675
2703
|
getAllPropertyLabels,
|
|
2676
2704
|
getPropertyByLabel,
|
package/dist/index.d.cts
CHANGED
|
@@ -1290,6 +1290,37 @@ type OchrePropertyValue = {
|
|
|
1290
1290
|
*/
|
|
1291
1291
|
declare function fetchByUuid(uuid: string): Promise<[null, OchreData] | [string, null]>;
|
|
1292
1292
|
|
|
1293
|
+
/**
|
|
1294
|
+
* Fetches and parses a website configuration from the OCHRE API
|
|
1295
|
+
*
|
|
1296
|
+
* @param abbreviation - The abbreviation identifier for the website
|
|
1297
|
+
* @returns The parsed website configuration or null if the fetch/parse fails
|
|
1298
|
+
*
|
|
1299
|
+
* @example
|
|
1300
|
+
* ```ts
|
|
1301
|
+
* const website = await fetchWebsite("guerrilla-television");
|
|
1302
|
+
* if (website === null) {
|
|
1303
|
+
* console.error("Failed to fetch website");
|
|
1304
|
+
* return;
|
|
1305
|
+
* }
|
|
1306
|
+
* console.log(`Fetched website: ${website.identification.label}`);
|
|
1307
|
+
* console.log(`Contains ${website.pages.length.toLocaleString()} pages`);
|
|
1308
|
+
* ```
|
|
1309
|
+
*
|
|
1310
|
+
* @remarks
|
|
1311
|
+
* The returned website configuration includes:
|
|
1312
|
+
* - Website metadata and identification
|
|
1313
|
+
* - Page structure and content
|
|
1314
|
+
* - Layout and styling properties
|
|
1315
|
+
* - Navigation configuration
|
|
1316
|
+
* - Sidebar elements
|
|
1317
|
+
* - Project information
|
|
1318
|
+
* - Creator details
|
|
1319
|
+
*
|
|
1320
|
+
* The abbreviation is case-insensitive and should match the website's configured abbreviation in OCHRE.
|
|
1321
|
+
*/
|
|
1322
|
+
declare function fetchWebsite(abbreviation: string): Promise<Website | null>;
|
|
1323
|
+
|
|
1293
1324
|
/**
|
|
1294
1325
|
* Options for property search operations
|
|
1295
1326
|
*/
|
|
@@ -1678,4 +1709,4 @@ declare function parseStringDocumentItem(item: OchreStringRichTextItem, footnote
|
|
|
1678
1709
|
*/
|
|
1679
1710
|
declare function parseStringContent(content: OchreStringContent, language?: string): string;
|
|
1680
1711
|
|
|
1681
|
-
export { type Bibliography, type Concept, type Context, type ContextItem, type ContextNode, type Coordinates, type Data, type DataCategory, 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 Note, type Observation, type Period, type Person, type Property, type PropertyValue, type PropertyValueContent, type PropertyValueContentType, 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, fetchByUuid, fetchGallery, fetchItem, 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, parseProperty, parsePropertyValue, parsePropertyValues, parseResource, parseResources, parseSet, parseSpatialUnit, parseSpatialUnits, parseStringContent, parseStringDocumentItem, parseStringItem, parseTree, parseWebsite };
|
|
1712
|
+
export { type Bibliography, type Concept, type Context, type ContextItem, type ContextNode, type Coordinates, type Data, type DataCategory, 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 Note, type Observation, type Period, type Person, type Property, type PropertyValue, type PropertyValueContent, type PropertyValueContentType, 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, fetchByUuid, fetchGallery, fetchItem, 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, parseProperty, parsePropertyValue, parsePropertyValues, parseResource, parseResources, parseSet, parseSpatialUnit, parseSpatialUnits, parseStringContent, parseStringDocumentItem, parseStringItem, parseTree, parseWebsite };
|
package/dist/index.d.ts
CHANGED
|
@@ -1290,6 +1290,37 @@ type OchrePropertyValue = {
|
|
|
1290
1290
|
*/
|
|
1291
1291
|
declare function fetchByUuid(uuid: string): Promise<[null, OchreData] | [string, null]>;
|
|
1292
1292
|
|
|
1293
|
+
/**
|
|
1294
|
+
* Fetches and parses a website configuration from the OCHRE API
|
|
1295
|
+
*
|
|
1296
|
+
* @param abbreviation - The abbreviation identifier for the website
|
|
1297
|
+
* @returns The parsed website configuration or null if the fetch/parse fails
|
|
1298
|
+
*
|
|
1299
|
+
* @example
|
|
1300
|
+
* ```ts
|
|
1301
|
+
* const website = await fetchWebsite("guerrilla-television");
|
|
1302
|
+
* if (website === null) {
|
|
1303
|
+
* console.error("Failed to fetch website");
|
|
1304
|
+
* return;
|
|
1305
|
+
* }
|
|
1306
|
+
* console.log(`Fetched website: ${website.identification.label}`);
|
|
1307
|
+
* console.log(`Contains ${website.pages.length.toLocaleString()} pages`);
|
|
1308
|
+
* ```
|
|
1309
|
+
*
|
|
1310
|
+
* @remarks
|
|
1311
|
+
* The returned website configuration includes:
|
|
1312
|
+
* - Website metadata and identification
|
|
1313
|
+
* - Page structure and content
|
|
1314
|
+
* - Layout and styling properties
|
|
1315
|
+
* - Navigation configuration
|
|
1316
|
+
* - Sidebar elements
|
|
1317
|
+
* - Project information
|
|
1318
|
+
* - Creator details
|
|
1319
|
+
*
|
|
1320
|
+
* The abbreviation is case-insensitive and should match the website's configured abbreviation in OCHRE.
|
|
1321
|
+
*/
|
|
1322
|
+
declare function fetchWebsite(abbreviation: string): Promise<Website | null>;
|
|
1323
|
+
|
|
1293
1324
|
/**
|
|
1294
1325
|
* Options for property search operations
|
|
1295
1326
|
*/
|
|
@@ -1678,4 +1709,4 @@ declare function parseStringDocumentItem(item: OchreStringRichTextItem, footnote
|
|
|
1678
1709
|
*/
|
|
1679
1710
|
declare function parseStringContent(content: OchreStringContent, language?: string): string;
|
|
1680
1711
|
|
|
1681
|
-
export { type Bibliography, type Concept, type Context, type ContextItem, type ContextNode, type Coordinates, type Data, type DataCategory, 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 Note, type Observation, type Period, type Person, type Property, type PropertyValue, type PropertyValueContent, type PropertyValueContentType, 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, fetchByUuid, fetchGallery, fetchItem, 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, parseProperty, parsePropertyValue, parsePropertyValues, parseResource, parseResources, parseSet, parseSpatialUnit, parseSpatialUnits, parseStringContent, parseStringDocumentItem, parseStringItem, parseTree, parseWebsite };
|
|
1712
|
+
export { type Bibliography, type Concept, type Context, type ContextItem, type ContextNode, type Coordinates, type Data, type DataCategory, 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 Note, type Observation, type Period, type Person, type Property, type PropertyValue, type PropertyValueContent, type PropertyValueContentType, 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, fetchByUuid, fetchGallery, fetchItem, 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, parseProperty, parsePropertyValue, parsePropertyValues, parseResource, parseResources, parseSet, parseSpatialUnit, parseSpatialUnits, parseStringContent, parseStringDocumentItem, parseStringItem, parseTree, parseWebsite };
|
package/dist/index.js
CHANGED
|
@@ -2593,10 +2593,37 @@ async function fetchGallery(uuid, filter, page, perPage) {
|
|
|
2593
2593
|
};
|
|
2594
2594
|
}
|
|
2595
2595
|
}
|
|
2596
|
+
|
|
2597
|
+
// src/utils/fetchers/website.ts
|
|
2598
|
+
async function fetchWebsite(abbreviation) {
|
|
2599
|
+
try {
|
|
2600
|
+
const response = await fetch(
|
|
2601
|
+
`https://ochre.lib.uchicago.edu/ochre?xquery=for $q in input()/ochre[tree[@type='lesson'][identification/abbreviation='${abbreviation.toLocaleLowerCase("en-US")}']] return $q&format=json`
|
|
2602
|
+
);
|
|
2603
|
+
if (!response.ok) {
|
|
2604
|
+
throw new Error("Failed to fetch website");
|
|
2605
|
+
}
|
|
2606
|
+
const data = await response.json();
|
|
2607
|
+
if (!("ochre" in data.result) || !("tree" in data.result.ochre)) {
|
|
2608
|
+
throw new Error("Failed to fetch website");
|
|
2609
|
+
}
|
|
2610
|
+
const projectIdentification = data.result.ochre.metadata.project?.identification ? parseIdentification(data.result.ochre.metadata.project.identification) : null;
|
|
2611
|
+
const website = await parseWebsite(
|
|
2612
|
+
data.result.ochre.tree,
|
|
2613
|
+
projectIdentification?.label ?? "",
|
|
2614
|
+
data.result.ochre.metadata.project?.identification.website ?? null
|
|
2615
|
+
);
|
|
2616
|
+
return website;
|
|
2617
|
+
} catch (error) {
|
|
2618
|
+
console.error(error);
|
|
2619
|
+
return null;
|
|
2620
|
+
}
|
|
2621
|
+
}
|
|
2596
2622
|
export {
|
|
2597
2623
|
fetchByUuid,
|
|
2598
2624
|
fetchGallery,
|
|
2599
2625
|
fetchItem,
|
|
2626
|
+
fetchWebsite,
|
|
2600
2627
|
filterProperties,
|
|
2601
2628
|
getAllPropertyLabels,
|
|
2602
2629
|
getPropertyByLabel,
|
package/package.json
CHANGED