@digitalculture/ochre-sdk 0.1.22 → 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 +67 -3
- package/dist/index.d.cts +64 -1
- package/dist/index.d.ts +64 -1
- package/dist/index.js +65 -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(
|
|
@@ -935,6 +937,7 @@ function parseImageMap(imageMap) {
|
|
|
935
937
|
function parsePeriod(period) {
|
|
936
938
|
return {
|
|
937
939
|
uuid: period.uuid,
|
|
940
|
+
category: "period",
|
|
938
941
|
publicationDateTime: period.publicationDateTime != null ? new Date(period.publicationDateTime) : null,
|
|
939
942
|
type: period.type ?? null,
|
|
940
943
|
number: period.n ?? null,
|
|
@@ -963,6 +966,7 @@ function parseBibliography(bibliography) {
|
|
|
963
966
|
}
|
|
964
967
|
return {
|
|
965
968
|
uuid: bibliography.uuid,
|
|
969
|
+
category: "bibliography",
|
|
966
970
|
publicationDateTime: bibliography.publicationDateTime != null ? new Date(bibliography.publicationDateTime) : null,
|
|
967
971
|
type: bibliography.type ?? null,
|
|
968
972
|
number: bibliography.n ?? null,
|
|
@@ -1874,6 +1878,36 @@ async function parseWebsite(websiteTree, projectName, website) {
|
|
|
1874
1878
|
};
|
|
1875
1879
|
}
|
|
1876
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
|
+
|
|
1877
1911
|
// src/utils/fetchers/concept.ts
|
|
1878
1912
|
async function fetchConcept(uuid) {
|
|
1879
1913
|
try {
|
|
@@ -1952,6 +1986,34 @@ async function fetchGallery(uuid, filter, page, perPage) {
|
|
|
1952
1986
|
}
|
|
1953
1987
|
}
|
|
1954
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
|
+
|
|
1955
2017
|
// src/utils/fetchers/set.ts
|
|
1956
2018
|
async function fetchSet(uuid) {
|
|
1957
2019
|
try {
|
|
@@ -2068,9 +2130,11 @@ async function fetchWebsite(abbreviation) {
|
|
|
2068
2130
|
}
|
|
2069
2131
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2070
2132
|
0 && (module.exports = {
|
|
2133
|
+
fetchBibliography,
|
|
2071
2134
|
fetchByUuid,
|
|
2072
2135
|
fetchConcept,
|
|
2073
2136
|
fetchGallery,
|
|
2137
|
+
fetchPeriod,
|
|
2074
2138
|
fetchResource,
|
|
2075
2139
|
fetchSet,
|
|
2076
2140
|
fetchSpatialUnit,
|
package/dist/index.d.cts
CHANGED
|
@@ -295,6 +295,7 @@ type Set = {
|
|
|
295
295
|
*/
|
|
296
296
|
type Bibliography = {
|
|
297
297
|
uuid: string;
|
|
298
|
+
category: "bibliography";
|
|
298
299
|
publicationDateTime: Date | null;
|
|
299
300
|
type: string | null;
|
|
300
301
|
number: number | null;
|
|
@@ -326,6 +327,7 @@ type Bibliography = {
|
|
|
326
327
|
*/
|
|
327
328
|
type Period = {
|
|
328
329
|
uuid: string;
|
|
330
|
+
category: "period";
|
|
329
331
|
publicationDateTime: Date | null;
|
|
330
332
|
type: string | null;
|
|
331
333
|
number: number | null;
|
|
@@ -530,6 +532,37 @@ type Style = {
|
|
|
530
532
|
value: string;
|
|
531
533
|
};
|
|
532
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
|
+
|
|
533
566
|
/**
|
|
534
567
|
* Fetches and parses a concept from the OCHRE API
|
|
535
568
|
*
|
|
@@ -680,6 +713,7 @@ type OchreData = {
|
|
|
680
713
|
| { resource: OchreResource }
|
|
681
714
|
| { spatialUnit: OchreSpatialUnit }
|
|
682
715
|
| { concept: OchreConcept }
|
|
716
|
+
| { period: OchrePeriod }
|
|
683
717
|
| { bibliography: OchreBibliography }
|
|
684
718
|
);
|
|
685
719
|
};
|
|
@@ -1153,6 +1187,35 @@ type OchreInterpretation = {
|
|
|
1153
1187
|
*/
|
|
1154
1188
|
declare function fetchByUuid(uuid: string): Promise<[null, OchreData] | [string, null]>;
|
|
1155
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
|
+
|
|
1156
1219
|
/**
|
|
1157
1220
|
* Fetches and parses a resource from the OCHRE API
|
|
1158
1221
|
*
|
|
@@ -1695,4 +1758,4 @@ declare function trimEndLineBreaks(string: string): string;
|
|
|
1695
1758
|
*/
|
|
1696
1759
|
declare function parseStringContent(content: OchreStringContent, language?: string): string;
|
|
1697
1760
|
|
|
1698
|
-
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
|
@@ -295,6 +295,7 @@ type Set = {
|
|
|
295
295
|
*/
|
|
296
296
|
type Bibliography = {
|
|
297
297
|
uuid: string;
|
|
298
|
+
category: "bibliography";
|
|
298
299
|
publicationDateTime: Date | null;
|
|
299
300
|
type: string | null;
|
|
300
301
|
number: number | null;
|
|
@@ -326,6 +327,7 @@ type Bibliography = {
|
|
|
326
327
|
*/
|
|
327
328
|
type Period = {
|
|
328
329
|
uuid: string;
|
|
330
|
+
category: "period";
|
|
329
331
|
publicationDateTime: Date | null;
|
|
330
332
|
type: string | null;
|
|
331
333
|
number: number | null;
|
|
@@ -530,6 +532,37 @@ type Style = {
|
|
|
530
532
|
value: string;
|
|
531
533
|
};
|
|
532
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
|
+
|
|
533
566
|
/**
|
|
534
567
|
* Fetches and parses a concept from the OCHRE API
|
|
535
568
|
*
|
|
@@ -680,6 +713,7 @@ type OchreData = {
|
|
|
680
713
|
| { resource: OchreResource }
|
|
681
714
|
| { spatialUnit: OchreSpatialUnit }
|
|
682
715
|
| { concept: OchreConcept }
|
|
716
|
+
| { period: OchrePeriod }
|
|
683
717
|
| { bibliography: OchreBibliography }
|
|
684
718
|
);
|
|
685
719
|
};
|
|
@@ -1153,6 +1187,35 @@ type OchreInterpretation = {
|
|
|
1153
1187
|
*/
|
|
1154
1188
|
declare function fetchByUuid(uuid: string): Promise<[null, OchreData] | [string, null]>;
|
|
1155
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
|
+
|
|
1156
1219
|
/**
|
|
1157
1220
|
* Fetches and parses a resource from the OCHRE API
|
|
1158
1221
|
*
|
|
@@ -1695,4 +1758,4 @@ declare function trimEndLineBreaks(string: string): string;
|
|
|
1695
1758
|
*/
|
|
1696
1759
|
declare function parseStringContent(content: OchreStringContent, language?: string): string;
|
|
1697
1760
|
|
|
1698
|
-
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(
|
|
@@ -860,6 +860,7 @@ function parseImageMap(imageMap) {
|
|
|
860
860
|
function parsePeriod(period) {
|
|
861
861
|
return {
|
|
862
862
|
uuid: period.uuid,
|
|
863
|
+
category: "period",
|
|
863
864
|
publicationDateTime: period.publicationDateTime != null ? new Date(period.publicationDateTime) : null,
|
|
864
865
|
type: period.type ?? null,
|
|
865
866
|
number: period.n ?? null,
|
|
@@ -888,6 +889,7 @@ function parseBibliography(bibliography) {
|
|
|
888
889
|
}
|
|
889
890
|
return {
|
|
890
891
|
uuid: bibliography.uuid,
|
|
892
|
+
category: "bibliography",
|
|
891
893
|
publicationDateTime: bibliography.publicationDateTime != null ? new Date(bibliography.publicationDateTime) : null,
|
|
892
894
|
type: bibliography.type ?? null,
|
|
893
895
|
number: bibliography.n ?? null,
|
|
@@ -1799,6 +1801,36 @@ async function parseWebsite(websiteTree, projectName, website) {
|
|
|
1799
1801
|
};
|
|
1800
1802
|
}
|
|
1801
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
|
+
|
|
1802
1834
|
// src/utils/fetchers/concept.ts
|
|
1803
1835
|
async function fetchConcept(uuid) {
|
|
1804
1836
|
try {
|
|
@@ -1877,6 +1909,34 @@ async function fetchGallery(uuid, filter, page, perPage) {
|
|
|
1877
1909
|
}
|
|
1878
1910
|
}
|
|
1879
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
|
+
|
|
1880
1940
|
// src/utils/fetchers/set.ts
|
|
1881
1941
|
async function fetchSet(uuid) {
|
|
1882
1942
|
try {
|
|
@@ -1992,9 +2052,11 @@ async function fetchWebsite(abbreviation) {
|
|
|
1992
2052
|
}
|
|
1993
2053
|
}
|
|
1994
2054
|
export {
|
|
2055
|
+
fetchBibliography,
|
|
1995
2056
|
fetchByUuid,
|
|
1996
2057
|
fetchConcept,
|
|
1997
2058
|
fetchGallery,
|
|
2059
|
+
fetchPeriod,
|
|
1998
2060
|
fetchResource,
|
|
1999
2061
|
fetchSet,
|
|
2000
2062
|
fetchSpatialUnit,
|
package/package.json
CHANGED