@digitalculture/ochre-sdk 0.2.2 → 0.2.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 +16 -5
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +16 -5
- package/package.json +5 -4
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(
|
|
@@ -622,6 +626,9 @@ function parseIdentification(identification) {
|
|
|
622
626
|
}
|
|
623
627
|
}
|
|
624
628
|
function parseLanguages(language) {
|
|
629
|
+
if (language == null) {
|
|
630
|
+
return ["eng"];
|
|
631
|
+
}
|
|
625
632
|
if (Array.isArray(language)) {
|
|
626
633
|
return language.map((lang) => parseStringContent(lang));
|
|
627
634
|
} else {
|
|
@@ -1124,7 +1131,7 @@ function parseSet(set) {
|
|
|
1124
1131
|
license: parseLicense(set.availability),
|
|
1125
1132
|
identification: parseIdentification(set.identification),
|
|
1126
1133
|
isSuppressingBlanks: set.suppressBlanks ?? false,
|
|
1127
|
-
description: set.description ? parseStringContent(set.description) : "",
|
|
1134
|
+
description: set.description ? ["string", "number", "boolean"].includes(typeof set.description) ? parseFakeString(set.description) : parseStringContent(set.description) : "",
|
|
1128
1135
|
creators: set.creators ? parsePersons(
|
|
1129
1136
|
Array.isArray(set.creators.creator) ? set.creators.creator : [set.creators.creator]
|
|
1130
1137
|
) : [],
|
|
@@ -1220,7 +1227,9 @@ function parseSpatialUnit(spatialUnit, isNested = false) {
|
|
|
1220
1227
|
license: "availability" in spatialUnit && spatialUnit.availability ? parseLicense(spatialUnit.availability) : null,
|
|
1221
1228
|
identification: parseIdentification(spatialUnit.identification),
|
|
1222
1229
|
image: spatialUnit.image ? parseImage(spatialUnit.image) : null,
|
|
1223
|
-
description: spatialUnit.description ?
|
|
1230
|
+
description: spatialUnit.description ? ["string", "number", "boolean"].includes(
|
|
1231
|
+
typeof spatialUnit.description
|
|
1232
|
+
) ? parseFakeString(spatialUnit.description) : parseStringContent(spatialUnit.description) : "",
|
|
1224
1233
|
coordinates: spatialUnit.coordinates ? parseCoordinates(spatialUnit.coordinates) : null,
|
|
1225
1234
|
observations: "observations" in spatialUnit && spatialUnit.observations ? parseObservations(
|
|
1226
1235
|
Array.isArray(spatialUnit.observations.observation) ? spatialUnit.observations.observation : [spatialUnit.observations.observation]
|
|
@@ -1416,7 +1425,9 @@ async function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
1416
1425
|
}
|
|
1417
1426
|
properties.href = href;
|
|
1418
1427
|
properties.isExternal = isExternal;
|
|
1419
|
-
properties.label =
|
|
1428
|
+
properties.label = ["string", "number", "boolean"].includes(
|
|
1429
|
+
typeof elementResource.identification.label
|
|
1430
|
+
) ? parseFakeString(elementResource.identification.label) : parseStringContent(
|
|
1420
1431
|
elementResource.identification.label
|
|
1421
1432
|
);
|
|
1422
1433
|
break;
|
package/dist/index.d.cts
CHANGED
|
@@ -752,7 +752,7 @@ type OchreMetadata = {
|
|
|
752
752
|
publisher: OchreStringContent;
|
|
753
753
|
dataset: OchreStringContent;
|
|
754
754
|
project?: { identification: OchreIdentification };
|
|
755
|
-
language
|
|
755
|
+
language?: OchreLanguage | Array<OchreLanguage>;
|
|
756
756
|
description: OchreStringContent;
|
|
757
757
|
};
|
|
758
758
|
|
|
@@ -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> };
|
|
@@ -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;
|
|
@@ -1506,7 +1506,7 @@ declare function parseIdentification(identification: OchreIdentification): Ident
|
|
|
1506
1506
|
* @param language - Raw language data, either single or array
|
|
1507
1507
|
* @returns Array of language codes as strings
|
|
1508
1508
|
*/
|
|
1509
|
-
declare function parseLanguages(language: OchreLanguage | Array<OchreLanguage>): Array<string>;
|
|
1509
|
+
declare function parseLanguages(language: OchreLanguage | Array<OchreLanguage> | undefined): Array<string>;
|
|
1510
1510
|
/**
|
|
1511
1511
|
* Parses raw metadata into the standardized Metadata type
|
|
1512
1512
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -752,7 +752,7 @@ type OchreMetadata = {
|
|
|
752
752
|
publisher: OchreStringContent;
|
|
753
753
|
dataset: OchreStringContent;
|
|
754
754
|
project?: { identification: OchreIdentification };
|
|
755
|
-
language
|
|
755
|
+
language?: OchreLanguage | Array<OchreLanguage>;
|
|
756
756
|
description: OchreStringContent;
|
|
757
757
|
};
|
|
758
758
|
|
|
@@ -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> };
|
|
@@ -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;
|
|
@@ -1506,7 +1506,7 @@ declare function parseIdentification(identification: OchreIdentification): Ident
|
|
|
1506
1506
|
* @param language - Raw language data, either single or array
|
|
1507
1507
|
* @returns Array of language codes as strings
|
|
1508
1508
|
*/
|
|
1509
|
-
declare function parseLanguages(language: OchreLanguage | Array<OchreLanguage>): Array<string>;
|
|
1509
|
+
declare function parseLanguages(language: OchreLanguage | Array<OchreLanguage> | undefined): Array<string>;
|
|
1510
1510
|
/**
|
|
1511
1511
|
* Parses raw metadata into the standardized Metadata type
|
|
1512
1512
|
*
|
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(
|
|
@@ -545,6 +549,9 @@ function parseIdentification(identification) {
|
|
|
545
549
|
}
|
|
546
550
|
}
|
|
547
551
|
function parseLanguages(language) {
|
|
552
|
+
if (language == null) {
|
|
553
|
+
return ["eng"];
|
|
554
|
+
}
|
|
548
555
|
if (Array.isArray(language)) {
|
|
549
556
|
return language.map((lang) => parseStringContent(lang));
|
|
550
557
|
} else {
|
|
@@ -1047,7 +1054,7 @@ function parseSet(set) {
|
|
|
1047
1054
|
license: parseLicense(set.availability),
|
|
1048
1055
|
identification: parseIdentification(set.identification),
|
|
1049
1056
|
isSuppressingBlanks: set.suppressBlanks ?? false,
|
|
1050
|
-
description: set.description ? parseStringContent(set.description) : "",
|
|
1057
|
+
description: set.description ? ["string", "number", "boolean"].includes(typeof set.description) ? parseFakeString(set.description) : parseStringContent(set.description) : "",
|
|
1051
1058
|
creators: set.creators ? parsePersons(
|
|
1052
1059
|
Array.isArray(set.creators.creator) ? set.creators.creator : [set.creators.creator]
|
|
1053
1060
|
) : [],
|
|
@@ -1143,7 +1150,9 @@ function parseSpatialUnit(spatialUnit, isNested = false) {
|
|
|
1143
1150
|
license: "availability" in spatialUnit && spatialUnit.availability ? parseLicense(spatialUnit.availability) : null,
|
|
1144
1151
|
identification: parseIdentification(spatialUnit.identification),
|
|
1145
1152
|
image: spatialUnit.image ? parseImage(spatialUnit.image) : null,
|
|
1146
|
-
description: spatialUnit.description ?
|
|
1153
|
+
description: spatialUnit.description ? ["string", "number", "boolean"].includes(
|
|
1154
|
+
typeof spatialUnit.description
|
|
1155
|
+
) ? parseFakeString(spatialUnit.description) : parseStringContent(spatialUnit.description) : "",
|
|
1147
1156
|
coordinates: spatialUnit.coordinates ? parseCoordinates(spatialUnit.coordinates) : null,
|
|
1148
1157
|
observations: "observations" in spatialUnit && spatialUnit.observations ? parseObservations(
|
|
1149
1158
|
Array.isArray(spatialUnit.observations.observation) ? spatialUnit.observations.observation : [spatialUnit.observations.observation]
|
|
@@ -1339,7 +1348,9 @@ async function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
1339
1348
|
}
|
|
1340
1349
|
properties.href = href;
|
|
1341
1350
|
properties.isExternal = isExternal;
|
|
1342
|
-
properties.label =
|
|
1351
|
+
properties.label = ["string", "number", "boolean"].includes(
|
|
1352
|
+
typeof elementResource.identification.label
|
|
1353
|
+
) ? parseFakeString(elementResource.identification.label) : parseStringContent(
|
|
1343
1354
|
elementResource.identification.label
|
|
1344
1355
|
);
|
|
1345
1356
|
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.4",
|
|
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",
|
|
@@ -44,16 +44,17 @@
|
|
|
44
44
|
"zod": "^3.24.1"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@antfu/eslint-config": "^4.1.
|
|
47
|
+
"@antfu/eslint-config": "^4.1.1",
|
|
48
48
|
"@arethetypeswrong/cli": "^0.17.3",
|
|
49
49
|
"@changesets/cli": "^2.27.12",
|
|
50
50
|
"@total-typescript/ts-reset": "^0.6.1",
|
|
51
|
-
"@types/node": "^22.
|
|
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",
|
|
55
56
|
"typescript": "^5.7.3",
|
|
56
|
-
"vitest": "^3.0.
|
|
57
|
+
"vitest": "^3.0.5"
|
|
57
58
|
},
|
|
58
59
|
"scripts": {
|
|
59
60
|
"dev": "tsup src/index.ts --watch",
|