@digitalculture/ochre-sdk 0.2.3 → 0.2.5
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 -12
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +28 -12
- package/package.json +2 -1
package/dist/index.cjs
CHANGED
|
@@ -331,7 +331,11 @@ function parseStringDocumentItem(item, footnotes) {
|
|
|
331
331
|
}
|
|
332
332
|
} else if ("person" in link) {
|
|
333
333
|
const linkPerson = Array.isArray(link.person) ? link.person[0] : link.person;
|
|
334
|
-
const linkContent = linkPerson.identification ?
|
|
334
|
+
const linkContent = linkPerson.identification ? ["string", "number", "boolean"].includes(
|
|
335
|
+
typeof linkPerson.identification.label
|
|
336
|
+
) ? parseFakeString(linkPerson.identification.label) : parseStringContent(
|
|
337
|
+
linkPerson.identification.label
|
|
338
|
+
) : null;
|
|
335
339
|
if (linkPerson.publicationDateTime != null) {
|
|
336
340
|
return `<ExternalLink href="https:\\/\\/ochre.lib.uchicago.edu/ochre?uuid=${linkPerson.uuid}" type="${linkPerson.type ?? "person"}" ${linkContent !== null ? `content="${linkContent}"` : ""}>${itemString}</ExternalLink>`;
|
|
337
341
|
} else {
|
|
@@ -602,7 +606,7 @@ var componentSchema = import_zod3.z.enum(
|
|
|
602
606
|
function parseIdentification(identification) {
|
|
603
607
|
try {
|
|
604
608
|
const returnIdentification = {
|
|
605
|
-
label: parseStringContent(identification.label),
|
|
609
|
+
label: ["string", "number", "boolean"].includes(typeof identification.label) ? parseFakeString(identification.label) : parseStringContent(identification.label),
|
|
606
610
|
abbreviation: ""
|
|
607
611
|
};
|
|
608
612
|
for (const key of Object.keys(identification).filter(
|
|
@@ -885,13 +889,21 @@ function parseProperties(properties, language = "eng") {
|
|
|
885
889
|
const returnProperties = [];
|
|
886
890
|
for (const property of properties) {
|
|
887
891
|
const valuesToParse = "value" in property && property.value ? Array.isArray(property.value) ? property.value : [property.value] : [];
|
|
888
|
-
const values = valuesToParse.map(
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
892
|
+
const values = valuesToParse.map(
|
|
893
|
+
(value) => !["string", "number", "boolean"].includes(typeof value) && typeof value === "object" && "uuid" in value ? {
|
|
894
|
+
content: parseStringContent(value),
|
|
895
|
+
type: value.type,
|
|
896
|
+
category: value.category !== "value" ? value.category ?? null : null,
|
|
897
|
+
uuid: value.uuid ?? null,
|
|
898
|
+
publicationDateTime: value.publicationDateTime != null ? new Date(value.publicationDateTime) : null
|
|
899
|
+
} : {
|
|
900
|
+
content: parseFakeString(value),
|
|
901
|
+
type: "string",
|
|
902
|
+
category: "value",
|
|
903
|
+
uuid: null,
|
|
904
|
+
publicationDateTime: null
|
|
905
|
+
}
|
|
906
|
+
);
|
|
895
907
|
returnProperties.push({
|
|
896
908
|
label: parseStringContent(property.label, language).replace(/\s*\.{3}$/, "").trim(),
|
|
897
909
|
values,
|
|
@@ -1127,7 +1139,7 @@ function parseSet(set) {
|
|
|
1127
1139
|
license: parseLicense(set.availability),
|
|
1128
1140
|
identification: parseIdentification(set.identification),
|
|
1129
1141
|
isSuppressingBlanks: set.suppressBlanks ?? false,
|
|
1130
|
-
description: set.description ? parseStringContent(set.description) : "",
|
|
1142
|
+
description: set.description ? ["string", "number", "boolean"].includes(typeof set.description) ? parseFakeString(set.description) : parseStringContent(set.description) : "",
|
|
1131
1143
|
creators: set.creators ? parsePersons(
|
|
1132
1144
|
Array.isArray(set.creators.creator) ? set.creators.creator : [set.creators.creator]
|
|
1133
1145
|
) : [],
|
|
@@ -1223,7 +1235,9 @@ function parseSpatialUnit(spatialUnit, isNested = false) {
|
|
|
1223
1235
|
license: "availability" in spatialUnit && spatialUnit.availability ? parseLicense(spatialUnit.availability) : null,
|
|
1224
1236
|
identification: parseIdentification(spatialUnit.identification),
|
|
1225
1237
|
image: spatialUnit.image ? parseImage(spatialUnit.image) : null,
|
|
1226
|
-
description: spatialUnit.description ?
|
|
1238
|
+
description: spatialUnit.description ? ["string", "number", "boolean"].includes(
|
|
1239
|
+
typeof spatialUnit.description
|
|
1240
|
+
) ? parseFakeString(spatialUnit.description) : parseStringContent(spatialUnit.description) : "",
|
|
1227
1241
|
coordinates: spatialUnit.coordinates ? parseCoordinates(spatialUnit.coordinates) : null,
|
|
1228
1242
|
observations: "observations" in spatialUnit && spatialUnit.observations ? parseObservations(
|
|
1229
1243
|
Array.isArray(spatialUnit.observations.observation) ? spatialUnit.observations.observation : [spatialUnit.observations.observation]
|
|
@@ -1419,7 +1433,9 @@ async function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
1419
1433
|
}
|
|
1420
1434
|
properties.href = href;
|
|
1421
1435
|
properties.isExternal = isExternal;
|
|
1422
|
-
properties.label =
|
|
1436
|
+
properties.label = ["string", "number", "boolean"].includes(
|
|
1437
|
+
typeof elementResource.identification.label
|
|
1438
|
+
) ? parseFakeString(elementResource.identification.label) : parseStringContent(
|
|
1423
1439
|
elementResource.identification.label
|
|
1424
1440
|
);
|
|
1425
1441
|
break;
|
package/dist/index.d.cts
CHANGED
|
@@ -792,7 +792,7 @@ type OchreSet = {
|
|
|
792
792
|
identification: OchreIdentification;
|
|
793
793
|
date?: string; // YYYY-MM-DD
|
|
794
794
|
suppressBlanks?: boolean;
|
|
795
|
-
description?: OchreStringContent;
|
|
795
|
+
description?: OchreStringContent | FakeString;
|
|
796
796
|
creators?: { creator: OchrePerson | Array<OchrePerson> };
|
|
797
797
|
items:
|
|
798
798
|
| string
|
|
@@ -857,7 +857,7 @@ type OchreSpatialUnit = {
|
|
|
857
857
|
context?: OchreContext;
|
|
858
858
|
identification: OchreIdentification;
|
|
859
859
|
image?: OchreImage;
|
|
860
|
-
description?: OchreStringContent;
|
|
860
|
+
description?: OchreStringContent | FakeString;
|
|
861
861
|
coordinates?: OchreCoordinates;
|
|
862
862
|
events?: { event: OchreEvent | Array<OchreEvent> };
|
|
863
863
|
observations?: { observation: OchreObservation | Array<OchreObservation> };
|
|
@@ -909,7 +909,7 @@ type OchrePropertyValue = OchreStringContent & {
|
|
|
909
909
|
*/
|
|
910
910
|
type OchreProperty = {
|
|
911
911
|
label: OchreStringContent & { uuid: string };
|
|
912
|
-
value?: OchrePropertyValue | Array<OchrePropertyValue
|
|
912
|
+
value?: OchrePropertyValue | Array<OchrePropertyValue> | FakeString;
|
|
913
913
|
comment?: FakeString;
|
|
914
914
|
property?: OchreProperty | Array<OchreProperty>;
|
|
915
915
|
};
|
|
@@ -918,8 +918,8 @@ type OchreProperty = {
|
|
|
918
918
|
* Raw identification structure corresponding to the parsed Identification type
|
|
919
919
|
*/
|
|
920
920
|
type OchreIdentification = {
|
|
921
|
-
label: OchreStringContent;
|
|
922
|
-
abbreviation?: OchreStringContent;
|
|
921
|
+
label: OchreStringContent | FakeString;
|
|
922
|
+
abbreviation?: OchreStringContent | FakeString;
|
|
923
923
|
MIMEType?: string;
|
|
924
924
|
widthPreview?: number;
|
|
925
925
|
heightPreview?: number;
|
package/dist/index.d.ts
CHANGED
|
@@ -792,7 +792,7 @@ type OchreSet = {
|
|
|
792
792
|
identification: OchreIdentification;
|
|
793
793
|
date?: string; // YYYY-MM-DD
|
|
794
794
|
suppressBlanks?: boolean;
|
|
795
|
-
description?: OchreStringContent;
|
|
795
|
+
description?: OchreStringContent | FakeString;
|
|
796
796
|
creators?: { creator: OchrePerson | Array<OchrePerson> };
|
|
797
797
|
items:
|
|
798
798
|
| string
|
|
@@ -857,7 +857,7 @@ type OchreSpatialUnit = {
|
|
|
857
857
|
context?: OchreContext;
|
|
858
858
|
identification: OchreIdentification;
|
|
859
859
|
image?: OchreImage;
|
|
860
|
-
description?: OchreStringContent;
|
|
860
|
+
description?: OchreStringContent | FakeString;
|
|
861
861
|
coordinates?: OchreCoordinates;
|
|
862
862
|
events?: { event: OchreEvent | Array<OchreEvent> };
|
|
863
863
|
observations?: { observation: OchreObservation | Array<OchreObservation> };
|
|
@@ -909,7 +909,7 @@ type OchrePropertyValue = OchreStringContent & {
|
|
|
909
909
|
*/
|
|
910
910
|
type OchreProperty = {
|
|
911
911
|
label: OchreStringContent & { uuid: string };
|
|
912
|
-
value?: OchrePropertyValue | Array<OchrePropertyValue
|
|
912
|
+
value?: OchrePropertyValue | Array<OchrePropertyValue> | FakeString;
|
|
913
913
|
comment?: FakeString;
|
|
914
914
|
property?: OchreProperty | Array<OchreProperty>;
|
|
915
915
|
};
|
|
@@ -918,8 +918,8 @@ type OchreProperty = {
|
|
|
918
918
|
* Raw identification structure corresponding to the parsed Identification type
|
|
919
919
|
*/
|
|
920
920
|
type OchreIdentification = {
|
|
921
|
-
label: OchreStringContent;
|
|
922
|
-
abbreviation?: OchreStringContent;
|
|
921
|
+
label: OchreStringContent | FakeString;
|
|
922
|
+
abbreviation?: OchreStringContent | FakeString;
|
|
923
923
|
MIMEType?: string;
|
|
924
924
|
widthPreview?: number;
|
|
925
925
|
heightPreview?: number;
|
package/dist/index.js
CHANGED
|
@@ -254,7 +254,11 @@ function parseStringDocumentItem(item, footnotes) {
|
|
|
254
254
|
}
|
|
255
255
|
} else if ("person" in link) {
|
|
256
256
|
const linkPerson = Array.isArray(link.person) ? link.person[0] : link.person;
|
|
257
|
-
const linkContent = linkPerson.identification ?
|
|
257
|
+
const linkContent = linkPerson.identification ? ["string", "number", "boolean"].includes(
|
|
258
|
+
typeof linkPerson.identification.label
|
|
259
|
+
) ? parseFakeString(linkPerson.identification.label) : parseStringContent(
|
|
260
|
+
linkPerson.identification.label
|
|
261
|
+
) : null;
|
|
258
262
|
if (linkPerson.publicationDateTime != null) {
|
|
259
263
|
return `<ExternalLink href="https:\\/\\/ochre.lib.uchicago.edu/ochre?uuid=${linkPerson.uuid}" type="${linkPerson.type ?? "person"}" ${linkContent !== null ? `content="${linkContent}"` : ""}>${itemString}</ExternalLink>`;
|
|
260
264
|
} else {
|
|
@@ -525,7 +529,7 @@ var componentSchema = z3.enum(
|
|
|
525
529
|
function parseIdentification(identification) {
|
|
526
530
|
try {
|
|
527
531
|
const returnIdentification = {
|
|
528
|
-
label: parseStringContent(identification.label),
|
|
532
|
+
label: ["string", "number", "boolean"].includes(typeof identification.label) ? parseFakeString(identification.label) : parseStringContent(identification.label),
|
|
529
533
|
abbreviation: ""
|
|
530
534
|
};
|
|
531
535
|
for (const key of Object.keys(identification).filter(
|
|
@@ -808,13 +812,21 @@ function parseProperties(properties, language = "eng") {
|
|
|
808
812
|
const returnProperties = [];
|
|
809
813
|
for (const property of properties) {
|
|
810
814
|
const valuesToParse = "value" in property && property.value ? Array.isArray(property.value) ? property.value : [property.value] : [];
|
|
811
|
-
const values = valuesToParse.map(
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
815
|
+
const values = valuesToParse.map(
|
|
816
|
+
(value) => !["string", "number", "boolean"].includes(typeof value) && typeof value === "object" && "uuid" in value ? {
|
|
817
|
+
content: parseStringContent(value),
|
|
818
|
+
type: value.type,
|
|
819
|
+
category: value.category !== "value" ? value.category ?? null : null,
|
|
820
|
+
uuid: value.uuid ?? null,
|
|
821
|
+
publicationDateTime: value.publicationDateTime != null ? new Date(value.publicationDateTime) : null
|
|
822
|
+
} : {
|
|
823
|
+
content: parseFakeString(value),
|
|
824
|
+
type: "string",
|
|
825
|
+
category: "value",
|
|
826
|
+
uuid: null,
|
|
827
|
+
publicationDateTime: null
|
|
828
|
+
}
|
|
829
|
+
);
|
|
818
830
|
returnProperties.push({
|
|
819
831
|
label: parseStringContent(property.label, language).replace(/\s*\.{3}$/, "").trim(),
|
|
820
832
|
values,
|
|
@@ -1050,7 +1062,7 @@ function parseSet(set) {
|
|
|
1050
1062
|
license: parseLicense(set.availability),
|
|
1051
1063
|
identification: parseIdentification(set.identification),
|
|
1052
1064
|
isSuppressingBlanks: set.suppressBlanks ?? false,
|
|
1053
|
-
description: set.description ? parseStringContent(set.description) : "",
|
|
1065
|
+
description: set.description ? ["string", "number", "boolean"].includes(typeof set.description) ? parseFakeString(set.description) : parseStringContent(set.description) : "",
|
|
1054
1066
|
creators: set.creators ? parsePersons(
|
|
1055
1067
|
Array.isArray(set.creators.creator) ? set.creators.creator : [set.creators.creator]
|
|
1056
1068
|
) : [],
|
|
@@ -1146,7 +1158,9 @@ function parseSpatialUnit(spatialUnit, isNested = false) {
|
|
|
1146
1158
|
license: "availability" in spatialUnit && spatialUnit.availability ? parseLicense(spatialUnit.availability) : null,
|
|
1147
1159
|
identification: parseIdentification(spatialUnit.identification),
|
|
1148
1160
|
image: spatialUnit.image ? parseImage(spatialUnit.image) : null,
|
|
1149
|
-
description: spatialUnit.description ?
|
|
1161
|
+
description: spatialUnit.description ? ["string", "number", "boolean"].includes(
|
|
1162
|
+
typeof spatialUnit.description
|
|
1163
|
+
) ? parseFakeString(spatialUnit.description) : parseStringContent(spatialUnit.description) : "",
|
|
1150
1164
|
coordinates: spatialUnit.coordinates ? parseCoordinates(spatialUnit.coordinates) : null,
|
|
1151
1165
|
observations: "observations" in spatialUnit && spatialUnit.observations ? parseObservations(
|
|
1152
1166
|
Array.isArray(spatialUnit.observations.observation) ? spatialUnit.observations.observation : [spatialUnit.observations.observation]
|
|
@@ -1342,7 +1356,9 @@ async function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
1342
1356
|
}
|
|
1343
1357
|
properties.href = href;
|
|
1344
1358
|
properties.isExternal = isExternal;
|
|
1345
|
-
properties.label =
|
|
1359
|
+
properties.label = ["string", "number", "boolean"].includes(
|
|
1360
|
+
typeof elementResource.identification.label
|
|
1361
|
+
) ? parseFakeString(elementResource.identification.label) : parseStringContent(
|
|
1346
1362
|
elementResource.identification.label
|
|
1347
1363
|
);
|
|
1348
1364
|
break;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digitalculture/ochre-sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Node.js library for working with OCHRE (Online Cultural and Historical Research Environment) data",
|
|
@@ -49,6 +49,7 @@
|
|
|
49
49
|
"@changesets/cli": "^2.27.12",
|
|
50
50
|
"@total-typescript/ts-reset": "^0.6.1",
|
|
51
51
|
"@types/node": "^22.13.1",
|
|
52
|
+
"eslint": "^9.19.0",
|
|
52
53
|
"eslint-plugin-unused-imports": "^4.1.4",
|
|
53
54
|
"prettier": "^3.4.2",
|
|
54
55
|
"tsup": "^8.3.6",
|