@digitalculture/ochre-sdk 0.1.23 → 0.1.24
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 +65 -3
- package/dist/index.d.cts +62 -1
- package/dist/index.d.ts +62 -1
- package/dist/index.js +63 -3
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -20,9 +20,11 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
+
fetchBibliography: () => fetchBibliography,
|
|
23
24
|
fetchByUuid: () => fetchByUuid,
|
|
24
25
|
fetchConcept: () => fetchConcept,
|
|
25
26
|
fetchGallery: () => fetchGallery,
|
|
27
|
+
fetchPeriod: () => fetchPeriod,
|
|
26
28
|
fetchResource: () => fetchResource,
|
|
27
29
|
fetchSet: () => fetchSet,
|
|
28
30
|
fetchSpatialUnit: () => fetchSpatialUnit,
|
|
@@ -73,6 +75,9 @@ __export(index_exports, {
|
|
|
73
75
|
});
|
|
74
76
|
module.exports = __toCommonJS(index_exports);
|
|
75
77
|
|
|
78
|
+
// src/utils/parse.ts
|
|
79
|
+
var import_zod3 = require("zod");
|
|
80
|
+
|
|
76
81
|
// src/utils/fetchers/generic.ts
|
|
77
82
|
var import_zod = require("zod");
|
|
78
83
|
var uuidSchema = import_zod.z.string().uuid({ message: "Invalid UUID provided" });
|
|
@@ -98,9 +103,6 @@ async function fetchByUuid(uuid) {
|
|
|
98
103
|
}
|
|
99
104
|
}
|
|
100
105
|
|
|
101
|
-
// src/utils/parse.ts
|
|
102
|
-
var import_zod3 = require("zod");
|
|
103
|
-
|
|
104
106
|
// src/utils/string.ts
|
|
105
107
|
var import_zod2 = require("zod");
|
|
106
108
|
var renderOptionsSchema = import_zod2.z.string().transform((str) => str.split(" ")).pipe(
|
|
@@ -1876,6 +1878,36 @@ async function parseWebsite(websiteTree, projectName, website) {
|
|
|
1876
1878
|
};
|
|
1877
1879
|
}
|
|
1878
1880
|
|
|
1881
|
+
// src/utils/fetchers/bibliography.ts
|
|
1882
|
+
async function fetchBibliography(uuid) {
|
|
1883
|
+
try {
|
|
1884
|
+
const [error, dataRaw] = await fetchByUuid(uuid);
|
|
1885
|
+
if (error !== null) {
|
|
1886
|
+
throw new Error(error);
|
|
1887
|
+
}
|
|
1888
|
+
if (!("bibliography" in dataRaw.ochre)) {
|
|
1889
|
+
throw new Error(
|
|
1890
|
+
"Invalid OCHRE data: API response missing 'bibliography' key"
|
|
1891
|
+
);
|
|
1892
|
+
}
|
|
1893
|
+
const bibliographyItem = parseBibliography(dataRaw.ochre.bibliography);
|
|
1894
|
+
const data = {
|
|
1895
|
+
uuid: parseFakeString(dataRaw.ochre.uuid),
|
|
1896
|
+
publicationDateTime: new Date(dataRaw.ochre.publicationDateTime),
|
|
1897
|
+
belongsTo: {
|
|
1898
|
+
uuid: dataRaw.ochre.uuidBelongsTo,
|
|
1899
|
+
abbreviation: parseFakeString(dataRaw.ochre.belongsTo)
|
|
1900
|
+
},
|
|
1901
|
+
metadata: parseMetadata(dataRaw.ochre.metadata),
|
|
1902
|
+
item: bibliographyItem
|
|
1903
|
+
};
|
|
1904
|
+
return { metadata: data.metadata, resource: data.item };
|
|
1905
|
+
} catch (error) {
|
|
1906
|
+
console.error(error);
|
|
1907
|
+
return null;
|
|
1908
|
+
}
|
|
1909
|
+
}
|
|
1910
|
+
|
|
1879
1911
|
// src/utils/fetchers/concept.ts
|
|
1880
1912
|
async function fetchConcept(uuid) {
|
|
1881
1913
|
try {
|
|
@@ -1954,6 +1986,34 @@ async function fetchGallery(uuid, filter, page, perPage) {
|
|
|
1954
1986
|
}
|
|
1955
1987
|
}
|
|
1956
1988
|
|
|
1989
|
+
// src/utils/fetchers/period.ts
|
|
1990
|
+
async function fetchPeriod(uuid) {
|
|
1991
|
+
try {
|
|
1992
|
+
const [error, dataRaw] = await fetchByUuid(uuid);
|
|
1993
|
+
if (error !== null) {
|
|
1994
|
+
throw new Error(error);
|
|
1995
|
+
}
|
|
1996
|
+
if (!("period" in dataRaw.ochre)) {
|
|
1997
|
+
throw new Error("Invalid OCHRE data: API response missing 'period' key");
|
|
1998
|
+
}
|
|
1999
|
+
const periodItem = parsePeriod(dataRaw.ochre.period);
|
|
2000
|
+
const data = {
|
|
2001
|
+
uuid: parseFakeString(dataRaw.ochre.uuid),
|
|
2002
|
+
publicationDateTime: new Date(dataRaw.ochre.publicationDateTime),
|
|
2003
|
+
belongsTo: {
|
|
2004
|
+
uuid: dataRaw.ochre.uuidBelongsTo,
|
|
2005
|
+
abbreviation: parseFakeString(dataRaw.ochre.belongsTo)
|
|
2006
|
+
},
|
|
2007
|
+
metadata: parseMetadata(dataRaw.ochre.metadata),
|
|
2008
|
+
item: periodItem
|
|
2009
|
+
};
|
|
2010
|
+
return { metadata: data.metadata, resource: data.item };
|
|
2011
|
+
} catch (error) {
|
|
2012
|
+
console.error(error);
|
|
2013
|
+
return null;
|
|
2014
|
+
}
|
|
2015
|
+
}
|
|
2016
|
+
|
|
1957
2017
|
// src/utils/fetchers/set.ts
|
|
1958
2018
|
async function fetchSet(uuid) {
|
|
1959
2019
|
try {
|
|
@@ -2070,9 +2130,11 @@ async function fetchWebsite(abbreviation) {
|
|
|
2070
2130
|
}
|
|
2071
2131
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2072
2132
|
0 && (module.exports = {
|
|
2133
|
+
fetchBibliography,
|
|
2073
2134
|
fetchByUuid,
|
|
2074
2135
|
fetchConcept,
|
|
2075
2136
|
fetchGallery,
|
|
2137
|
+
fetchPeriod,
|
|
2076
2138
|
fetchResource,
|
|
2077
2139
|
fetchSet,
|
|
2078
2140
|
fetchSpatialUnit,
|
package/dist/index.d.cts
CHANGED
|
@@ -532,6 +532,37 @@ type Style = {
|
|
|
532
532
|
value: string;
|
|
533
533
|
};
|
|
534
534
|
|
|
535
|
+
/**
|
|
536
|
+
* Fetches and parses a bibliography from the OCHRE API
|
|
537
|
+
*
|
|
538
|
+
* @param uuid - The UUID of the bibliography to fetch
|
|
539
|
+
* @returns Object containing the parsed bibliography and its metadata, or null if the fetch/parse fails
|
|
540
|
+
*
|
|
541
|
+
* @example
|
|
542
|
+
* ```ts
|
|
543
|
+
* const result = await fetchBibliography("123e4567-e89b-12d3-a456-426614174000");
|
|
544
|
+
* if (result === null) {
|
|
545
|
+
* console.error("Failed to fetch bibliography");
|
|
546
|
+
* return;
|
|
547
|
+
* }
|
|
548
|
+
* const { metadata, item } = result;
|
|
549
|
+
* console.log(`Fetched bibliography: ${item.identification.label}`);
|
|
550
|
+
* ```
|
|
551
|
+
*
|
|
552
|
+
* @remarks
|
|
553
|
+
* The returned bibliography includes:
|
|
554
|
+
* - Full bibliography metadata
|
|
555
|
+
* - Citation and reference information
|
|
556
|
+
* - Publication information
|
|
557
|
+
* - Source information
|
|
558
|
+
* - Author information
|
|
559
|
+
* - Properties
|
|
560
|
+
*/
|
|
561
|
+
declare function fetchBibliography(uuid: string): Promise<{
|
|
562
|
+
metadata: Metadata;
|
|
563
|
+
resource: Bibliography;
|
|
564
|
+
} | null>;
|
|
565
|
+
|
|
535
566
|
/**
|
|
536
567
|
* Fetches and parses a concept from the OCHRE API
|
|
537
568
|
*
|
|
@@ -682,6 +713,7 @@ type OchreData = {
|
|
|
682
713
|
| { resource: OchreResource }
|
|
683
714
|
| { spatialUnit: OchreSpatialUnit }
|
|
684
715
|
| { concept: OchreConcept }
|
|
716
|
+
| { period: OchrePeriod }
|
|
685
717
|
| { bibliography: OchreBibliography }
|
|
686
718
|
);
|
|
687
719
|
};
|
|
@@ -1155,6 +1187,35 @@ type OchreInterpretation = {
|
|
|
1155
1187
|
*/
|
|
1156
1188
|
declare function fetchByUuid(uuid: string): Promise<[null, OchreData] | [string, null]>;
|
|
1157
1189
|
|
|
1190
|
+
/**
|
|
1191
|
+
* Fetches and parses a period from the OCHRE API
|
|
1192
|
+
*
|
|
1193
|
+
* @param uuid - The UUID of the period to fetch
|
|
1194
|
+
* @returns Object containing the parsed period and its metadata, or null if the fetch/parse fails
|
|
1195
|
+
*
|
|
1196
|
+
* @example
|
|
1197
|
+
* ```ts
|
|
1198
|
+
* const result = await fetchPeriod("123e4567-e89b-12d3-a456-426614174000");
|
|
1199
|
+
* if (result === null) {
|
|
1200
|
+
* console.error("Failed to fetch period");
|
|
1201
|
+
* return;
|
|
1202
|
+
* }
|
|
1203
|
+
* const { metadata, item } = result;
|
|
1204
|
+
* console.log(`Fetched period: ${item.identification.label}`);
|
|
1205
|
+
* ```
|
|
1206
|
+
*
|
|
1207
|
+
* @remarks
|
|
1208
|
+
* The returned period includes:
|
|
1209
|
+
* - Full period metadata
|
|
1210
|
+
* - Identification information
|
|
1211
|
+
* - Description
|
|
1212
|
+
* - Properties
|
|
1213
|
+
*/
|
|
1214
|
+
declare function fetchPeriod(uuid: string): Promise<{
|
|
1215
|
+
metadata: Metadata;
|
|
1216
|
+
resource: Period;
|
|
1217
|
+
} | null>;
|
|
1218
|
+
|
|
1158
1219
|
/**
|
|
1159
1220
|
* Fetches and parses a resource from the OCHRE API
|
|
1160
1221
|
*
|
|
@@ -1697,4 +1758,4 @@ declare function trimEndLineBreaks(string: string): string;
|
|
|
1697
1758
|
*/
|
|
1698
1759
|
declare function parseStringContent(content: OchreStringContent, language?: string): string;
|
|
1699
1760
|
|
|
1700
|
-
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 PropertyValueType, type Resource, type Set, type SpatialUnit, type Style, type Tree, type WebElement, type WebElementComponent, type WebImage, type Webpage, type WebpageProperties, type Website, type WebsiteProperties, fetchByUuid, fetchConcept, fetchGallery, fetchResource, fetchSet, fetchSpatialUnit, fetchTree, fetchWebsite, filterProperties, getAllPropertyLabels, getPropertyByLabel, getPropertyValueByLabel, getPropertyValuesByLabel, parseBibliographies, parseBibliography, parseConcept, parseConcepts, parseContext, parseCoordinates, parseDocument, parseEmailAndUrl, parseEvents, parseFakeString, parseIdentification, parseImage, parseImageMap, parseInterpretations, parseLanguages, parseLicense, parseLink, parseLinks, parseMetadata, parseNotes, parseObservation, parseObservations, parsePeriod, parsePeriods, parsePersons, parseProperties, parseResource, parseResources, parseSet, parseSpatialUnit, parseSpatialUnits, parseStringContent, parseStringDocumentItem, parseStringItem, parseTree, parseWebsite, trimEndLineBreaks };
|
|
1761
|
+
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 PropertyValueType, type Resource, type Set, type SpatialUnit, type Style, type Tree, 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, parseEmailAndUrl, parseEvents, parseFakeString, parseIdentification, parseImage, parseImageMap, parseInterpretations, parseLanguages, parseLicense, parseLink, parseLinks, parseMetadata, parseNotes, parseObservation, parseObservations, parsePeriod, parsePeriods, parsePersons, parseProperties, parseResource, parseResources, parseSet, parseSpatialUnit, parseSpatialUnits, parseStringContent, parseStringDocumentItem, parseStringItem, parseTree, parseWebsite, trimEndLineBreaks };
|
package/dist/index.d.ts
CHANGED
|
@@ -532,6 +532,37 @@ type Style = {
|
|
|
532
532
|
value: string;
|
|
533
533
|
};
|
|
534
534
|
|
|
535
|
+
/**
|
|
536
|
+
* Fetches and parses a bibliography from the OCHRE API
|
|
537
|
+
*
|
|
538
|
+
* @param uuid - The UUID of the bibliography to fetch
|
|
539
|
+
* @returns Object containing the parsed bibliography and its metadata, or null if the fetch/parse fails
|
|
540
|
+
*
|
|
541
|
+
* @example
|
|
542
|
+
* ```ts
|
|
543
|
+
* const result = await fetchBibliography("123e4567-e89b-12d3-a456-426614174000");
|
|
544
|
+
* if (result === null) {
|
|
545
|
+
* console.error("Failed to fetch bibliography");
|
|
546
|
+
* return;
|
|
547
|
+
* }
|
|
548
|
+
* const { metadata, item } = result;
|
|
549
|
+
* console.log(`Fetched bibliography: ${item.identification.label}`);
|
|
550
|
+
* ```
|
|
551
|
+
*
|
|
552
|
+
* @remarks
|
|
553
|
+
* The returned bibliography includes:
|
|
554
|
+
* - Full bibliography metadata
|
|
555
|
+
* - Citation and reference information
|
|
556
|
+
* - Publication information
|
|
557
|
+
* - Source information
|
|
558
|
+
* - Author information
|
|
559
|
+
* - Properties
|
|
560
|
+
*/
|
|
561
|
+
declare function fetchBibliography(uuid: string): Promise<{
|
|
562
|
+
metadata: Metadata;
|
|
563
|
+
resource: Bibliography;
|
|
564
|
+
} | null>;
|
|
565
|
+
|
|
535
566
|
/**
|
|
536
567
|
* Fetches and parses a concept from the OCHRE API
|
|
537
568
|
*
|
|
@@ -682,6 +713,7 @@ type OchreData = {
|
|
|
682
713
|
| { resource: OchreResource }
|
|
683
714
|
| { spatialUnit: OchreSpatialUnit }
|
|
684
715
|
| { concept: OchreConcept }
|
|
716
|
+
| { period: OchrePeriod }
|
|
685
717
|
| { bibliography: OchreBibliography }
|
|
686
718
|
);
|
|
687
719
|
};
|
|
@@ -1155,6 +1187,35 @@ type OchreInterpretation = {
|
|
|
1155
1187
|
*/
|
|
1156
1188
|
declare function fetchByUuid(uuid: string): Promise<[null, OchreData] | [string, null]>;
|
|
1157
1189
|
|
|
1190
|
+
/**
|
|
1191
|
+
* Fetches and parses a period from the OCHRE API
|
|
1192
|
+
*
|
|
1193
|
+
* @param uuid - The UUID of the period to fetch
|
|
1194
|
+
* @returns Object containing the parsed period and its metadata, or null if the fetch/parse fails
|
|
1195
|
+
*
|
|
1196
|
+
* @example
|
|
1197
|
+
* ```ts
|
|
1198
|
+
* const result = await fetchPeriod("123e4567-e89b-12d3-a456-426614174000");
|
|
1199
|
+
* if (result === null) {
|
|
1200
|
+
* console.error("Failed to fetch period");
|
|
1201
|
+
* return;
|
|
1202
|
+
* }
|
|
1203
|
+
* const { metadata, item } = result;
|
|
1204
|
+
* console.log(`Fetched period: ${item.identification.label}`);
|
|
1205
|
+
* ```
|
|
1206
|
+
*
|
|
1207
|
+
* @remarks
|
|
1208
|
+
* The returned period includes:
|
|
1209
|
+
* - Full period metadata
|
|
1210
|
+
* - Identification information
|
|
1211
|
+
* - Description
|
|
1212
|
+
* - Properties
|
|
1213
|
+
*/
|
|
1214
|
+
declare function fetchPeriod(uuid: string): Promise<{
|
|
1215
|
+
metadata: Metadata;
|
|
1216
|
+
resource: Period;
|
|
1217
|
+
} | null>;
|
|
1218
|
+
|
|
1158
1219
|
/**
|
|
1159
1220
|
* Fetches and parses a resource from the OCHRE API
|
|
1160
1221
|
*
|
|
@@ -1697,4 +1758,4 @@ declare function trimEndLineBreaks(string: string): string;
|
|
|
1697
1758
|
*/
|
|
1698
1759
|
declare function parseStringContent(content: OchreStringContent, language?: string): string;
|
|
1699
1760
|
|
|
1700
|
-
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 PropertyValueType, type Resource, type Set, type SpatialUnit, type Style, type Tree, type WebElement, type WebElementComponent, type WebImage, type Webpage, type WebpageProperties, type Website, type WebsiteProperties, fetchByUuid, fetchConcept, fetchGallery, fetchResource, fetchSet, fetchSpatialUnit, fetchTree, fetchWebsite, filterProperties, getAllPropertyLabels, getPropertyByLabel, getPropertyValueByLabel, getPropertyValuesByLabel, parseBibliographies, parseBibliography, parseConcept, parseConcepts, parseContext, parseCoordinates, parseDocument, parseEmailAndUrl, parseEvents, parseFakeString, parseIdentification, parseImage, parseImageMap, parseInterpretations, parseLanguages, parseLicense, parseLink, parseLinks, parseMetadata, parseNotes, parseObservation, parseObservations, parsePeriod, parsePeriods, parsePersons, parseProperties, parseResource, parseResources, parseSet, parseSpatialUnit, parseSpatialUnits, parseStringContent, parseStringDocumentItem, parseStringItem, parseTree, parseWebsite, trimEndLineBreaks };
|
|
1761
|
+
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 PropertyValueType, type Resource, type Set, type SpatialUnit, type Style, type Tree, 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, parseEmailAndUrl, parseEvents, parseFakeString, parseIdentification, parseImage, parseImageMap, parseInterpretations, parseLanguages, parseLicense, parseLink, parseLinks, parseMetadata, parseNotes, parseObservation, parseObservations, parsePeriod, parsePeriods, parsePersons, parseProperties, parseResource, parseResources, parseSet, parseSpatialUnit, parseSpatialUnits, parseStringContent, parseStringDocumentItem, parseStringItem, parseTree, parseWebsite, trimEndLineBreaks };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// src/utils/parse.ts
|
|
2
|
+
import { z as z3 } from "zod";
|
|
3
|
+
|
|
1
4
|
// src/utils/fetchers/generic.ts
|
|
2
5
|
import { z } from "zod";
|
|
3
6
|
var uuidSchema = z.string().uuid({ message: "Invalid UUID provided" });
|
|
@@ -23,9 +26,6 @@ async function fetchByUuid(uuid) {
|
|
|
23
26
|
}
|
|
24
27
|
}
|
|
25
28
|
|
|
26
|
-
// src/utils/parse.ts
|
|
27
|
-
import { z as z3 } from "zod";
|
|
28
|
-
|
|
29
29
|
// src/utils/string.ts
|
|
30
30
|
import { z as z2 } from "zod";
|
|
31
31
|
var renderOptionsSchema = z2.string().transform((str) => str.split(" ")).pipe(
|
|
@@ -1801,6 +1801,36 @@ async function parseWebsite(websiteTree, projectName, website) {
|
|
|
1801
1801
|
};
|
|
1802
1802
|
}
|
|
1803
1803
|
|
|
1804
|
+
// src/utils/fetchers/bibliography.ts
|
|
1805
|
+
async function fetchBibliography(uuid) {
|
|
1806
|
+
try {
|
|
1807
|
+
const [error, dataRaw] = await fetchByUuid(uuid);
|
|
1808
|
+
if (error !== null) {
|
|
1809
|
+
throw new Error(error);
|
|
1810
|
+
}
|
|
1811
|
+
if (!("bibliography" in dataRaw.ochre)) {
|
|
1812
|
+
throw new Error(
|
|
1813
|
+
"Invalid OCHRE data: API response missing 'bibliography' key"
|
|
1814
|
+
);
|
|
1815
|
+
}
|
|
1816
|
+
const bibliographyItem = parseBibliography(dataRaw.ochre.bibliography);
|
|
1817
|
+
const data = {
|
|
1818
|
+
uuid: parseFakeString(dataRaw.ochre.uuid),
|
|
1819
|
+
publicationDateTime: new Date(dataRaw.ochre.publicationDateTime),
|
|
1820
|
+
belongsTo: {
|
|
1821
|
+
uuid: dataRaw.ochre.uuidBelongsTo,
|
|
1822
|
+
abbreviation: parseFakeString(dataRaw.ochre.belongsTo)
|
|
1823
|
+
},
|
|
1824
|
+
metadata: parseMetadata(dataRaw.ochre.metadata),
|
|
1825
|
+
item: bibliographyItem
|
|
1826
|
+
};
|
|
1827
|
+
return { metadata: data.metadata, resource: data.item };
|
|
1828
|
+
} catch (error) {
|
|
1829
|
+
console.error(error);
|
|
1830
|
+
return null;
|
|
1831
|
+
}
|
|
1832
|
+
}
|
|
1833
|
+
|
|
1804
1834
|
// src/utils/fetchers/concept.ts
|
|
1805
1835
|
async function fetchConcept(uuid) {
|
|
1806
1836
|
try {
|
|
@@ -1879,6 +1909,34 @@ async function fetchGallery(uuid, filter, page, perPage) {
|
|
|
1879
1909
|
}
|
|
1880
1910
|
}
|
|
1881
1911
|
|
|
1912
|
+
// src/utils/fetchers/period.ts
|
|
1913
|
+
async function fetchPeriod(uuid) {
|
|
1914
|
+
try {
|
|
1915
|
+
const [error, dataRaw] = await fetchByUuid(uuid);
|
|
1916
|
+
if (error !== null) {
|
|
1917
|
+
throw new Error(error);
|
|
1918
|
+
}
|
|
1919
|
+
if (!("period" in dataRaw.ochre)) {
|
|
1920
|
+
throw new Error("Invalid OCHRE data: API response missing 'period' key");
|
|
1921
|
+
}
|
|
1922
|
+
const periodItem = parsePeriod(dataRaw.ochre.period);
|
|
1923
|
+
const data = {
|
|
1924
|
+
uuid: parseFakeString(dataRaw.ochre.uuid),
|
|
1925
|
+
publicationDateTime: new Date(dataRaw.ochre.publicationDateTime),
|
|
1926
|
+
belongsTo: {
|
|
1927
|
+
uuid: dataRaw.ochre.uuidBelongsTo,
|
|
1928
|
+
abbreviation: parseFakeString(dataRaw.ochre.belongsTo)
|
|
1929
|
+
},
|
|
1930
|
+
metadata: parseMetadata(dataRaw.ochre.metadata),
|
|
1931
|
+
item: periodItem
|
|
1932
|
+
};
|
|
1933
|
+
return { metadata: data.metadata, resource: data.item };
|
|
1934
|
+
} catch (error) {
|
|
1935
|
+
console.error(error);
|
|
1936
|
+
return null;
|
|
1937
|
+
}
|
|
1938
|
+
}
|
|
1939
|
+
|
|
1882
1940
|
// src/utils/fetchers/set.ts
|
|
1883
1941
|
async function fetchSet(uuid) {
|
|
1884
1942
|
try {
|
|
@@ -1994,9 +2052,11 @@ async function fetchWebsite(abbreviation) {
|
|
|
1994
2052
|
}
|
|
1995
2053
|
}
|
|
1996
2054
|
export {
|
|
2055
|
+
fetchBibliography,
|
|
1997
2056
|
fetchByUuid,
|
|
1998
2057
|
fetchConcept,
|
|
1999
2058
|
fetchGallery,
|
|
2059
|
+
fetchPeriod,
|
|
2000
2060
|
fetchResource,
|
|
2001
2061
|
fetchSet,
|
|
2002
2062
|
fetchSpatialUnit,
|
package/package.json
CHANGED