@digitalculture/ochre-sdk 0.6.2 → 0.6.4
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 +29 -0
- package/dist/index.d.cts +33 -1
- package/dist/index.d.ts +33 -1
- package/dist/index.js +28 -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,
|
|
@@ -842,6 +843,7 @@ function parseLicense(license) {
|
|
|
842
843
|
function parsePerson(person) {
|
|
843
844
|
return {
|
|
844
845
|
uuid: person.uuid,
|
|
846
|
+
category: "person",
|
|
845
847
|
publicationDateTime: person.publicationDateTime != null ? new Date(person.publicationDateTime) : null,
|
|
846
848
|
type: person.type ?? null,
|
|
847
849
|
date: person.date != null ? new Date(person.date) : null,
|
|
@@ -2666,11 +2668,38 @@ async function fetchGallery(uuid, filter, page, perPage) {
|
|
|
2666
2668
|
};
|
|
2667
2669
|
}
|
|
2668
2670
|
}
|
|
2671
|
+
|
|
2672
|
+
// src/utils/fetchers/website.ts
|
|
2673
|
+
async function fetchWebsite(abbreviation) {
|
|
2674
|
+
try {
|
|
2675
|
+
const response = await fetch(
|
|
2676
|
+
`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`
|
|
2677
|
+
);
|
|
2678
|
+
if (!response.ok) {
|
|
2679
|
+
throw new Error("Failed to fetch website");
|
|
2680
|
+
}
|
|
2681
|
+
const data = await response.json();
|
|
2682
|
+
if (!("ochre" in data.result) || !("tree" in data.result.ochre)) {
|
|
2683
|
+
throw new Error("Failed to fetch website");
|
|
2684
|
+
}
|
|
2685
|
+
const projectIdentification = data.result.ochre.metadata.project?.identification ? parseIdentification(data.result.ochre.metadata.project.identification) : null;
|
|
2686
|
+
const website = await parseWebsite(
|
|
2687
|
+
data.result.ochre.tree,
|
|
2688
|
+
projectIdentification?.label ?? "",
|
|
2689
|
+
data.result.ochre.metadata.project?.identification.website ?? null
|
|
2690
|
+
);
|
|
2691
|
+
return website;
|
|
2692
|
+
} catch (error) {
|
|
2693
|
+
console.error(error);
|
|
2694
|
+
return null;
|
|
2695
|
+
}
|
|
2696
|
+
}
|
|
2669
2697
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2670
2698
|
0 && (module.exports = {
|
|
2671
2699
|
fetchByUuid,
|
|
2672
2700
|
fetchGallery,
|
|
2673
2701
|
fetchItem,
|
|
2702
|
+
fetchWebsite,
|
|
2674
2703
|
filterProperties,
|
|
2675
2704
|
getAllPropertyLabels,
|
|
2676
2705
|
getPropertyByLabel,
|
package/dist/index.d.cts
CHANGED
|
@@ -78,6 +78,7 @@ type License = {
|
|
|
78
78
|
*/
|
|
79
79
|
type Person = {
|
|
80
80
|
uuid: string;
|
|
81
|
+
category: "person";
|
|
81
82
|
publicationDateTime: Date | null;
|
|
82
83
|
type: string | null;
|
|
83
84
|
date: Date | null;
|
|
@@ -1290,6 +1291,37 @@ type OchrePropertyValue = {
|
|
|
1290
1291
|
*/
|
|
1291
1292
|
declare function fetchByUuid(uuid: string): Promise<[null, OchreData] | [string, null]>;
|
|
1292
1293
|
|
|
1294
|
+
/**
|
|
1295
|
+
* Fetches and parses a website configuration from the OCHRE API
|
|
1296
|
+
*
|
|
1297
|
+
* @param abbreviation - The abbreviation identifier for the website
|
|
1298
|
+
* @returns The parsed website configuration or null if the fetch/parse fails
|
|
1299
|
+
*
|
|
1300
|
+
* @example
|
|
1301
|
+
* ```ts
|
|
1302
|
+
* const website = await fetchWebsite("guerrilla-television");
|
|
1303
|
+
* if (website === null) {
|
|
1304
|
+
* console.error("Failed to fetch website");
|
|
1305
|
+
* return;
|
|
1306
|
+
* }
|
|
1307
|
+
* console.log(`Fetched website: ${website.identification.label}`);
|
|
1308
|
+
* console.log(`Contains ${website.pages.length.toLocaleString()} pages`);
|
|
1309
|
+
* ```
|
|
1310
|
+
*
|
|
1311
|
+
* @remarks
|
|
1312
|
+
* The returned website configuration includes:
|
|
1313
|
+
* - Website metadata and identification
|
|
1314
|
+
* - Page structure and content
|
|
1315
|
+
* - Layout and styling properties
|
|
1316
|
+
* - Navigation configuration
|
|
1317
|
+
* - Sidebar elements
|
|
1318
|
+
* - Project information
|
|
1319
|
+
* - Creator details
|
|
1320
|
+
*
|
|
1321
|
+
* The abbreviation is case-insensitive and should match the website's configured abbreviation in OCHRE.
|
|
1322
|
+
*/
|
|
1323
|
+
declare function fetchWebsite(abbreviation: string): Promise<Website | null>;
|
|
1324
|
+
|
|
1293
1325
|
/**
|
|
1294
1326
|
* Options for property search operations
|
|
1295
1327
|
*/
|
|
@@ -1678,4 +1710,4 @@ declare function parseStringDocumentItem(item: OchreStringRichTextItem, footnote
|
|
|
1678
1710
|
*/
|
|
1679
1711
|
declare function parseStringContent(content: OchreStringContent, language?: string): string;
|
|
1680
1712
|
|
|
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 };
|
|
1713
|
+
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
|
@@ -78,6 +78,7 @@ type License = {
|
|
|
78
78
|
*/
|
|
79
79
|
type Person = {
|
|
80
80
|
uuid: string;
|
|
81
|
+
category: "person";
|
|
81
82
|
publicationDateTime: Date | null;
|
|
82
83
|
type: string | null;
|
|
83
84
|
date: Date | null;
|
|
@@ -1290,6 +1291,37 @@ type OchrePropertyValue = {
|
|
|
1290
1291
|
*/
|
|
1291
1292
|
declare function fetchByUuid(uuid: string): Promise<[null, OchreData] | [string, null]>;
|
|
1292
1293
|
|
|
1294
|
+
/**
|
|
1295
|
+
* Fetches and parses a website configuration from the OCHRE API
|
|
1296
|
+
*
|
|
1297
|
+
* @param abbreviation - The abbreviation identifier for the website
|
|
1298
|
+
* @returns The parsed website configuration or null if the fetch/parse fails
|
|
1299
|
+
*
|
|
1300
|
+
* @example
|
|
1301
|
+
* ```ts
|
|
1302
|
+
* const website = await fetchWebsite("guerrilla-television");
|
|
1303
|
+
* if (website === null) {
|
|
1304
|
+
* console.error("Failed to fetch website");
|
|
1305
|
+
* return;
|
|
1306
|
+
* }
|
|
1307
|
+
* console.log(`Fetched website: ${website.identification.label}`);
|
|
1308
|
+
* console.log(`Contains ${website.pages.length.toLocaleString()} pages`);
|
|
1309
|
+
* ```
|
|
1310
|
+
*
|
|
1311
|
+
* @remarks
|
|
1312
|
+
* The returned website configuration includes:
|
|
1313
|
+
* - Website metadata and identification
|
|
1314
|
+
* - Page structure and content
|
|
1315
|
+
* - Layout and styling properties
|
|
1316
|
+
* - Navigation configuration
|
|
1317
|
+
* - Sidebar elements
|
|
1318
|
+
* - Project information
|
|
1319
|
+
* - Creator details
|
|
1320
|
+
*
|
|
1321
|
+
* The abbreviation is case-insensitive and should match the website's configured abbreviation in OCHRE.
|
|
1322
|
+
*/
|
|
1323
|
+
declare function fetchWebsite(abbreviation: string): Promise<Website | null>;
|
|
1324
|
+
|
|
1293
1325
|
/**
|
|
1294
1326
|
* Options for property search operations
|
|
1295
1327
|
*/
|
|
@@ -1678,4 +1710,4 @@ declare function parseStringDocumentItem(item: OchreStringRichTextItem, footnote
|
|
|
1678
1710
|
*/
|
|
1679
1711
|
declare function parseStringContent(content: OchreStringContent, language?: string): string;
|
|
1680
1712
|
|
|
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 };
|
|
1713
|
+
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
|
@@ -769,6 +769,7 @@ function parseLicense(license) {
|
|
|
769
769
|
function parsePerson(person) {
|
|
770
770
|
return {
|
|
771
771
|
uuid: person.uuid,
|
|
772
|
+
category: "person",
|
|
772
773
|
publicationDateTime: person.publicationDateTime != null ? new Date(person.publicationDateTime) : null,
|
|
773
774
|
type: person.type ?? null,
|
|
774
775
|
date: person.date != null ? new Date(person.date) : null,
|
|
@@ -2593,10 +2594,37 @@ async function fetchGallery(uuid, filter, page, perPage) {
|
|
|
2593
2594
|
};
|
|
2594
2595
|
}
|
|
2595
2596
|
}
|
|
2597
|
+
|
|
2598
|
+
// src/utils/fetchers/website.ts
|
|
2599
|
+
async function fetchWebsite(abbreviation) {
|
|
2600
|
+
try {
|
|
2601
|
+
const response = await fetch(
|
|
2602
|
+
`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`
|
|
2603
|
+
);
|
|
2604
|
+
if (!response.ok) {
|
|
2605
|
+
throw new Error("Failed to fetch website");
|
|
2606
|
+
}
|
|
2607
|
+
const data = await response.json();
|
|
2608
|
+
if (!("ochre" in data.result) || !("tree" in data.result.ochre)) {
|
|
2609
|
+
throw new Error("Failed to fetch website");
|
|
2610
|
+
}
|
|
2611
|
+
const projectIdentification = data.result.ochre.metadata.project?.identification ? parseIdentification(data.result.ochre.metadata.project.identification) : null;
|
|
2612
|
+
const website = await parseWebsite(
|
|
2613
|
+
data.result.ochre.tree,
|
|
2614
|
+
projectIdentification?.label ?? "",
|
|
2615
|
+
data.result.ochre.metadata.project?.identification.website ?? null
|
|
2616
|
+
);
|
|
2617
|
+
return website;
|
|
2618
|
+
} catch (error) {
|
|
2619
|
+
console.error(error);
|
|
2620
|
+
return null;
|
|
2621
|
+
}
|
|
2622
|
+
}
|
|
2596
2623
|
export {
|
|
2597
2624
|
fetchByUuid,
|
|
2598
2625
|
fetchGallery,
|
|
2599
2626
|
fetchItem,
|
|
2627
|
+
fetchWebsite,
|
|
2600
2628
|
filterProperties,
|
|
2601
2629
|
getAllPropertyLabels,
|
|
2602
2630
|
getPropertyByLabel,
|
package/package.json
CHANGED