ochre-sdk 1.0.71 → 1.0.72
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/parsers/string.mjs +5 -1
- package/dist/xml/schemas.mjs +8 -4
- package/dist/xml/types.d.mts +13 -6
- package/package.json +2 -2
package/dist/parsers/string.mjs
CHANGED
|
@@ -468,11 +468,15 @@ function parseXMLContent(item, options) {
|
|
|
468
468
|
}
|
|
469
469
|
function parseXMLContentItem(contentItem, options) {
|
|
470
470
|
const rawMDXBlocks = [];
|
|
471
|
-
const
|
|
471
|
+
const nestedRichText = parseNestedStringItems(contentItem.string, contentItem, {
|
|
472
472
|
...options,
|
|
473
473
|
rendering: "rich",
|
|
474
474
|
rawMDXBlocks
|
|
475
475
|
});
|
|
476
|
+
const richText = hasRichTextEnvelope(contentItem) ? renderRichTextItem(contentItem, nestedRichText, contentItem, {
|
|
477
|
+
...options,
|
|
478
|
+
rendering: "rich"
|
|
479
|
+
}) : nestedRichText;
|
|
476
480
|
let serializedRichText = serializeMDXContent(richText);
|
|
477
481
|
for (const [index, rawMDXBlock] of rawMDXBlocks.entries()) serializedRichText = serializedRichText.replaceAll(`${RAW_MDX_BLOCK_PLACEHOLDER_PREFIX}${index}${RAW_MDX_BLOCK_PLACEHOLDER_SUFFIX}`, () => rawMDXBlock);
|
|
478
482
|
return {
|
package/dist/xml/schemas.mjs
CHANGED
|
@@ -42,19 +42,23 @@ const ITEM_CATEGORIES = [
|
|
|
42
42
|
"set"
|
|
43
43
|
];
|
|
44
44
|
const XMLItemCategory = v.picklist(ITEM_CATEGORIES);
|
|
45
|
+
const XMLRichTextEnvelope = {
|
|
46
|
+
links: v.optional(v.lazy(() => XMLLink)),
|
|
47
|
+
properties: v.optional(v.object({ property: v.array(v.lazy(() => XMLProperty), "XMLRichTextEnvelope: properties is array of XMLProperty") })),
|
|
48
|
+
annotation: v.optional(v.string("XMLRichTextEnvelope: annotation is string and optional"))
|
|
49
|
+
};
|
|
45
50
|
const XMLString = v.lazy(() => v.object({
|
|
46
51
|
payload: v.optional(v.string("XMLString: payload is string and optional")),
|
|
47
52
|
rend: v.optional(v.string("XMLString: rend is string and optional")),
|
|
48
53
|
whitespace: v.optional(v.string("XMLString: whitespace is string and optional")),
|
|
49
|
-
|
|
50
|
-
properties: v.optional(v.object({ property: v.array(v.lazy(() => XMLProperty), "XMLString: properties is array of XMLProperty") })),
|
|
51
|
-
annotation: v.optional(v.string("XMLString: annotation is string and optional")),
|
|
54
|
+
...XMLRichTextEnvelope,
|
|
52
55
|
string: v.optional(v.array(XMLString, "XMLString: string is array of XMLString"))
|
|
53
56
|
}, "XMLString: Shape error"));
|
|
54
57
|
const XMLContent = v.object({ content: v.array(v.object({
|
|
55
58
|
string: v.array(XMLString),
|
|
56
59
|
title: v.optional(v.string("XMLContent: title is string and optional")),
|
|
57
|
-
lang: v.string("XMLContent: lang is string and required")
|
|
60
|
+
lang: v.string("XMLContent: lang is string and required"),
|
|
61
|
+
...XMLRichTextEnvelope
|
|
58
62
|
}), "XMLContent: content is array of object with string, title, and lang") }, "XMLContent: Shape error");
|
|
59
63
|
const XMLNumber = v.pipe(v.union([v.string("XMLNumber: string is string and required"), XMLString]), v.check(isXMLNumber, "XMLNumber: string is not a number"), v.transform(parseXMLNumber));
|
|
60
64
|
const XMLOptionalNumber = v.optional(v.pipe(v.union([v.string("XMLNumber: string is string and required"), XMLString]), v.check(isOptionalXMLNumber, "XMLNumber: string is not a number"), v.transform(parseOptionalXMLNumber)));
|
package/dist/xml/types.d.mts
CHANGED
|
@@ -2,19 +2,26 @@
|
|
|
2
2
|
type XMLItemCategory = "tree" | "bibliography" | "spatialUnit" | "concept" | "period" | "person" | "propertyVariable" | "variable" | "propertyValue" | "value" | "text" | "resource" | "set";
|
|
3
3
|
type XMLHeadingItemCategory = Exclude<XMLItemCategory, "tree" | "bibliography" | "spatialUnit" | "concept" | "period">;
|
|
4
4
|
type XMLRecursiveItemCategory = Exclude<XMLItemCategory, "tree" | "person" | "propertyVariable" | "propertyValue" | "set">;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Rich text envelope shared by `<string>` and `<content>` nodes, carrying the
|
|
7
|
+
* inline links, presentation properties and annotation identifier that turn a
|
|
8
|
+
* span of text into an annotation.
|
|
9
|
+
*/
|
|
10
|
+
type XMLRichTextEnvelope = {
|
|
9
11
|
links?: XMLLink;
|
|
10
12
|
properties?: {
|
|
11
13
|
property: Array<XMLProperty>;
|
|
12
14
|
};
|
|
13
15
|
annotation?: string;
|
|
16
|
+
};
|
|
17
|
+
type XMLString = XMLRichTextEnvelope & {
|
|
18
|
+
payload?: string;
|
|
19
|
+
rend?: string;
|
|
20
|
+
whitespace?: string;
|
|
14
21
|
string?: Array<XMLString>;
|
|
15
22
|
};
|
|
16
23
|
type XMLContent = {
|
|
17
|
-
content: Array<{
|
|
24
|
+
content: Array<XMLRichTextEnvelope & {
|
|
18
25
|
string: Array<XMLString>;
|
|
19
26
|
lang: string;
|
|
20
27
|
title?: string;
|
|
@@ -956,4 +963,4 @@ type XMLWebsiteData = {
|
|
|
956
963
|
};
|
|
957
964
|
};
|
|
958
965
|
//#endregion
|
|
959
|
-
export { XMLBaseItem, XMLBibliography, XMLBoolean, XMLConcept, XMLContent, XMLContext, XMLContextGroup, XMLContextItem, XMLContextValue, XMLCoordinate, XMLCoordinates, XMLCoordinatesSource, XMLData, XMLDataItem, XMLDictionaryUnit, XMLEmptyContext, XMLEvent, XMLGallery, XMLGalleryData, XMLHeading, XMLHeadingItemCategory, XMLIdentification, XMLImage, XMLImageMap, XMLImageMapArea, XMLInterpretation, XMLItemCategory, XMLItemLinks, XMLItemLinksData, XMLLicense, XMLLink, XMLLinkedBaseItem, XMLLinkedBibliography, XMLLinkedConcept, XMLLinkedPeriod, XMLLinkedPerson, XMLLinkedPropertyValue, XMLLinkedPropertyVariable, XMLLinkedResource, XMLLinkedSet, XMLLinkedSpatialUnit, XMLLinkedText, XMLLinkedTree, XMLMetadata, XMLNote, XMLNumber, XMLObservation, XMLOcr, XMLOcrMatch, XMLOcrMatchItem, XMLOcrMatchesData, XMLOcrPage, XMLOcrString, XMLOcrTextBlock, XMLOcrTextLine, XMLPeriod, XMLPerson, XMLProperty, XMLPropertyRelation, XMLPropertyValue, XMLPropertyVariable, XMLRecursiveItemCategory, XMLResource, XMLSection, XMLSet, XMLSetItems, XMLSetItemsData, XMLSimplifiedProperty, XMLSpatialUnit, XMLString, XMLText, XMLTree, XMLWebsiteContext, XMLWebsiteContextItem, XMLWebsiteContextLevel, XMLWebsiteData, XMLWebsiteFilterContext, XMLWebsiteFilterContextItem, XMLWebsiteOptions, XMLWebsiteProperties, XMLWebsiteResource, XMLWebsiteResourceGroup, XMLWebsiteResourceItem, XMLWebsiteScope, XMLWebsiteSegment, XMLWebsiteStyle, XMLWebsiteTree };
|
|
966
|
+
export { XMLBaseItem, XMLBibliography, XMLBoolean, XMLConcept, XMLContent, XMLContext, XMLContextGroup, XMLContextItem, XMLContextValue, XMLCoordinate, XMLCoordinates, XMLCoordinatesSource, XMLData, XMLDataItem, XMLDictionaryUnit, XMLEmptyContext, XMLEvent, XMLGallery, XMLGalleryData, XMLHeading, XMLHeadingItemCategory, XMLIdentification, XMLImage, XMLImageMap, XMLImageMapArea, XMLInterpretation, XMLItemCategory, XMLItemLinks, XMLItemLinksData, XMLLicense, XMLLink, XMLLinkedBaseItem, XMLLinkedBibliography, XMLLinkedConcept, XMLLinkedPeriod, XMLLinkedPerson, XMLLinkedPropertyValue, XMLLinkedPropertyVariable, XMLLinkedResource, XMLLinkedSet, XMLLinkedSpatialUnit, XMLLinkedText, XMLLinkedTree, XMLMetadata, XMLNote, XMLNumber, XMLObservation, XMLOcr, XMLOcrMatch, XMLOcrMatchItem, XMLOcrMatchesData, XMLOcrPage, XMLOcrString, XMLOcrTextBlock, XMLOcrTextLine, XMLPeriod, XMLPerson, XMLProperty, XMLPropertyRelation, XMLPropertyValue, XMLPropertyVariable, XMLRecursiveItemCategory, XMLResource, XMLRichTextEnvelope, XMLSection, XMLSet, XMLSetItems, XMLSetItemsData, XMLSimplifiedProperty, XMLSpatialUnit, XMLString, XMLText, XMLTree, XMLWebsiteContext, XMLWebsiteContextItem, XMLWebsiteContextLevel, XMLWebsiteData, XMLWebsiteFilterContext, XMLWebsiteFilterContextItem, XMLWebsiteOptions, XMLWebsiteProperties, XMLWebsiteResource, XMLWebsiteResourceGroup, XMLWebsiteResourceItem, XMLWebsiteScope, XMLWebsiteSegment, XMLWebsiteStyle, XMLWebsiteTree };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ochre-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.72",
|
|
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",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"bumpp": "^12.1.1",
|
|
57
57
|
"eslint": "^10.8.0",
|
|
58
58
|
"knip": "^6.31.0",
|
|
59
|
-
"oxfmt": "^0.
|
|
59
|
+
"oxfmt": "^0.62.0",
|
|
60
60
|
"tsdown": "^0.22.14",
|
|
61
61
|
"typescript": "^6.0.3",
|
|
62
62
|
"vitest": "^4.1.10"
|