ochre-sdk 1.3.12 → 1.3.14
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/README.md +1 -4
- package/dist/categories.d.mts +1 -3
- package/dist/categories.mjs +1 -2
- package/dist/constants.d.mts +1 -3
- package/dist/constants.mjs +14 -4
- package/dist/errors.d.mts +0 -2
- package/dist/errors.mjs +1 -2
- package/dist/fetchers/container-items.d.mts +1 -3
- package/dist/fetchers/container-items.mjs +1 -2
- package/dist/fetchers/gallery.d.mts +1 -3
- package/dist/fetchers/gallery.mjs +1 -2
- package/dist/fetchers/item-children.d.mts +0 -2
- package/dist/fetchers/item-children.mjs +1 -2
- package/dist/fetchers/item-links.d.mts +1 -3
- package/dist/fetchers/item-links.mjs +1 -2
- package/dist/fetchers/item-locations.d.mts +39 -0
- package/dist/fetchers/item-locations.mjs +98 -0
- package/dist/fetchers/item-ocr-data.d.mts +1 -3
- package/dist/fetchers/item-ocr-data.mjs +1 -2
- package/dist/fetchers/item.d.mts +0 -2
- package/dist/fetchers/item.mjs +1 -2
- package/dist/fetchers/map-layers.d.mts +28 -0
- package/dist/fetchers/map-layers.mjs +160 -0
- package/dist/fetchers/request.d.mts +1 -3
- package/dist/fetchers/request.mjs +1 -2
- package/dist/fetchers/set/items.d.mts +0 -2
- package/dist/fetchers/set/items.mjs +1 -2
- package/dist/fetchers/set/property-values.d.mts +1 -3
- package/dist/fetchers/set/property-values.mjs +1 -2
- package/dist/fetchers/tree/items.d.mts +0 -2
- package/dist/fetchers/tree/items.mjs +1 -2
- package/dist/fetchers/website-metadata.d.mts +1 -3
- package/dist/fetchers/website-metadata.mjs +1 -2
- package/dist/fetchers/website.d.mts +1 -3
- package/dist/fetchers/website.mjs +11 -3
- package/dist/getters.d.mts +0 -2
- package/dist/getters.mjs +1 -2
- package/dist/helpers.d.mts +0 -2
- package/dist/helpers.mjs +1 -2
- package/dist/index.d.mts +4 -3
- package/dist/index.mjs +3 -2
- package/dist/languages.d.mts +1 -3
- package/dist/languages.mjs +1 -2
- package/dist/ocr.d.mts +1 -3
- package/dist/ocr.mjs +1 -2
- package/dist/parsers/helpers.d.mts +1 -3
- package/dist/parsers/helpers.mjs +1 -2
- package/dist/parsers/index.d.mts +3 -4
- package/dist/parsers/index.mjs +28 -10
- package/dist/parsers/languages.d.mts +1 -3
- package/dist/parsers/languages.mjs +1 -2
- package/dist/parsers/mdx.d.mts +1 -3
- package/dist/parsers/mdx.mjs +1 -2
- package/dist/parsers/multilingual.d.mts +0 -2
- package/dist/parsers/multilingual.mjs +1 -2
- package/dist/parsers/property-token.d.mts +0 -2
- package/dist/parsers/property-token.mjs +1 -2
- package/dist/parsers/string.d.mts +1 -3
- package/dist/parsers/string.mjs +1 -2
- package/dist/parsers/website/bounds.d.mts +1 -3
- package/dist/parsers/website/bounds.mjs +1 -2
- package/dist/parsers/website/components.d.mts +0 -2
- package/dist/parsers/website/components.mjs +5 -5
- package/dist/parsers/website/index.d.mts +1 -3
- package/dist/parsers/website/index.mjs +6 -4
- package/dist/parsers/website/links.d.mts +1 -3
- package/dist/parsers/website/links.mjs +1 -2
- package/dist/parsers/website/messages.d.mts +1 -3
- package/dist/parsers/website/messages.mjs +1 -2
- package/dist/parsers/website/options.d.mts +1 -3
- package/dist/parsers/website/options.mjs +1 -2
- package/dist/parsers/website/properties.d.mts +1 -3
- package/dist/parsers/website/properties.mjs +1 -2
- package/dist/parsers/website/reader.d.mts +0 -2
- package/dist/parsers/website/reader.mjs +1 -2
- package/dist/parsers/website/slug.d.mts +1 -3
- package/dist/parsers/website/slug.mjs +1 -2
- package/dist/parsers/website/styles.d.mts +2 -4
- package/dist/parsers/website/styles.mjs +2 -2
- package/dist/parsers/website/walk.d.mts +1 -3
- package/dist/parsers/website/walk.mjs +1 -2
- package/dist/query.d.mts +0 -2
- package/dist/query.mjs +1 -2
- package/dist/reflection.d.mts +1 -3
- package/dist/reflection.mjs +1 -2
- package/dist/schemas.d.mts +14 -7
- package/dist/schemas.mjs +9 -8
- package/dist/types/index.d.mts +41 -3
- package/dist/types/utilities.d.mts +1 -3
- package/dist/types/website.d.mts +5 -6
- package/dist/xml/dates.d.mts +1 -3
- package/dist/xml/dates.mjs +1 -2
- package/dist/xml/metadata.d.mts +1 -3
- package/dist/xml/metadata.mjs +1 -2
- package/dist/xml/schemas.d.mts +351 -13
- package/dist/xml/schemas.mjs +53 -19
- package/dist/xml/types.d.mts +47 -6
- package/dist/xquery.d.mts +1 -3
- package/dist/xquery.mjs +1 -2
- package/package.json +9 -8
- package/dist/fetchers/set/item-locations.d.mts +0 -35
- package/dist/fetchers/set/item-locations.mjs +0 -83
|
@@ -3,7 +3,7 @@ import { createSchemaValidationError } from "../errors.mjs";
|
|
|
3
3
|
import { restoreXMLMetadata } from "../xml/metadata.mjs";
|
|
4
4
|
import * as v from "valibot";
|
|
5
5
|
import { XMLParser } from "fast-xml-parser";
|
|
6
|
-
|
|
6
|
+
// src/fetchers/request.ts
|
|
7
7
|
const OCHRE_XQUERY_ENDPOINT = `${OCHRE_ENDPOINT}?xquery&xsl=none&lang="*"`;
|
|
8
8
|
const xmlParser = new XMLParser(XML_PARSER_OPTIONS);
|
|
9
9
|
function resolveSignal(options) {
|
|
@@ -97,5 +97,4 @@ async function isOchreJsonAccepted(parameters) {
|
|
|
97
97
|
if (response.status >= 500) throw new Error(`Failed to post ${label}: OCHRE API responded with status ${response.status}`, { cause: response.statusText });
|
|
98
98
|
return response.ok;
|
|
99
99
|
}
|
|
100
|
-
//#endregion
|
|
101
100
|
export { decodeOchreResponse, isOchreJsonAccepted, requestOchre };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Query, SetItem, SetItemCategory, SetItemsSort } from "../../types/index.mjs";
|
|
2
2
|
import { FetchBaseOptions, FetchLanguages } from "../../parsers/helpers.mjs";
|
|
3
|
-
//#region src/fetchers/set/items.d.ts
|
|
4
3
|
type FetchSetItemsCategory<TContainedItemCategories extends ReadonlyArray<SetItemCategory> | undefined> = TContainedItemCategories extends ReadonlyArray<infer U> ? Extract<U, SetItemCategory> : SetItemCategory;
|
|
5
4
|
/**
|
|
6
5
|
* Fetches and parses Set items from the OCHRE API
|
|
@@ -38,5 +37,4 @@ export declare function fetchSetItems<const TContainedItemCategories extends Rea
|
|
|
38
37
|
error: string;
|
|
39
38
|
detailedError: string;
|
|
40
39
|
}>;
|
|
41
|
-
//#endregion
|
|
42
40
|
export {};
|
|
@@ -2,7 +2,7 @@ import { getErrorOutput } from "../../errors.mjs";
|
|
|
2
2
|
import { setItemsParametersSchema } from "../../schemas.mjs";
|
|
3
3
|
import { fetchContainerItems } from "../container-items.mjs";
|
|
4
4
|
import * as v from "valibot";
|
|
5
|
-
|
|
5
|
+
// src/fetchers/set/items.ts
|
|
6
6
|
async function fetchSetItems(parameters, containedItemCategories, options) {
|
|
7
7
|
try {
|
|
8
8
|
const { setScopeUuids, belongsToCollectionScopeUuids, queries, sort, page, pageSize } = v.parse(setItemsParametersSchema, parameters);
|
|
@@ -32,5 +32,4 @@ async function fetchSetItems(parameters, containedItemCategories, options) {
|
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
-
//#endregion
|
|
36
35
|
export { fetchSetItems };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { PropertyValueQueryItem, Query, SetAttributeValueQueryItem } from "../../types/index.mjs";
|
|
2
2
|
import { OchreRequestOptions } from "../request.mjs";
|
|
3
|
-
//#region src/fetchers/set/property-values.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Fetches and parses Set property values from the OCHRE API
|
|
6
5
|
*
|
|
@@ -41,5 +40,4 @@ export declare function fetchSetPropertyValues(parameters: {
|
|
|
41
40
|
attributeValues: null;
|
|
42
41
|
error: string;
|
|
43
42
|
detailedError: string;
|
|
44
|
-
}>;
|
|
45
|
-
//#endregion
|
|
43
|
+
}>;
|
|
@@ -7,7 +7,7 @@ import { parseXMLContent } from "../../parsers/string.mjs";
|
|
|
7
7
|
import { stringLiteral } from "../../xquery.mjs";
|
|
8
8
|
import { compileContainerItemsQuery, getItemFilterQueries, getPropertyFacetSelectors } from "../../query.mjs";
|
|
9
9
|
import * as v from "valibot";
|
|
10
|
-
|
|
10
|
+
// src/fetchers/set/property-values.ts
|
|
11
11
|
function getLabelContentLanguages(content) {
|
|
12
12
|
const languages = [];
|
|
13
13
|
for (const contentItem of content) if (contentItem.lang !== "zxx" && !languages.includes(contentItem.lang)) languages.push(contentItem.lang);
|
|
@@ -491,5 +491,4 @@ async function fetchSetPropertyValues(parameters, options) {
|
|
|
491
491
|
};
|
|
492
492
|
}
|
|
493
493
|
}
|
|
494
|
-
//#endregion
|
|
495
494
|
export { fetchSetPropertyValues };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Query, SetItem, SetItemsSort, TreeItemCategory } from "../../types/index.mjs";
|
|
2
2
|
import { FetchBaseOptions, FetchLanguages } from "../../parsers/helpers.mjs";
|
|
3
|
-
//#region src/fetchers/tree/items.d.ts
|
|
4
3
|
type FetchTreeItemsCategory<TContainedItemCategories extends ReadonlyArray<TreeItemCategory> | undefined> = TContainedItemCategories extends ReadonlyArray<infer U> ? Extract<U, TreeItemCategory> : TreeItemCategory;
|
|
5
4
|
/**
|
|
6
5
|
* Fetches and parses Tree items from the OCHRE API
|
|
@@ -50,5 +49,4 @@ export declare function fetchTreeItems<const TContainedItemCategories extends Re
|
|
|
50
49
|
error: string;
|
|
51
50
|
detailedError: string;
|
|
52
51
|
}>;
|
|
53
|
-
//#endregion
|
|
54
52
|
export {};
|
|
@@ -2,7 +2,7 @@ import { getErrorOutput } from "../../errors.mjs";
|
|
|
2
2
|
import { treeItemsParametersSchema } from "../../schemas.mjs";
|
|
3
3
|
import { fetchContainerItems } from "../container-items.mjs";
|
|
4
4
|
import * as v from "valibot";
|
|
5
|
-
|
|
5
|
+
// src/fetchers/tree/items.ts
|
|
6
6
|
async function fetchTreeItems(parameters, containedItemCategories, options) {
|
|
7
7
|
try {
|
|
8
8
|
const { treeScopeUuids, belongsToCollectionScopeUuids, queries, sort, page, pageSize } = v.parse(treeItemsParametersSchema, parameters);
|
|
@@ -34,5 +34,4 @@ async function fetchTreeItems(parameters, containedItemCategories, options) {
|
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
//#endregion
|
|
38
37
|
export { fetchTreeItems };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { WebsiteMetadata } from "../types/website.mjs";
|
|
2
2
|
import { FetchBaseOptions, FetchLanguages } from "../parsers/helpers.mjs";
|
|
3
|
-
//#region src/fetchers/website-metadata.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Fetches and parses a page-scoped website metadata projection from the OCHRE
|
|
6
5
|
* API.
|
|
@@ -15,5 +14,4 @@ export declare function fetchWebsiteMetadata<const TLanguages extends ReadonlyAr
|
|
|
15
14
|
websiteMetadata: null;
|
|
16
15
|
error: string;
|
|
17
16
|
detailedError: string;
|
|
18
|
-
}>;
|
|
19
|
-
//#endregion
|
|
17
|
+
}>;
|
|
@@ -7,7 +7,7 @@ import { XMLWebsiteData } from "../xml/schemas.mjs";
|
|
|
7
7
|
import { OCHRE_RESPONSE_PADDING, compileOchreQuery, stringLiteral } from "../xquery.mjs";
|
|
8
8
|
import { websitePresentationReader } from "../parsers/website/reader.mjs";
|
|
9
9
|
import { WEBSITE_WALK_DECLARATIONS } from "../parsers/website/walk.mjs";
|
|
10
|
-
|
|
10
|
+
// src/fetchers/website-metadata.ts
|
|
11
11
|
/**
|
|
12
12
|
* The presentation properties the metadata projection carries
|
|
13
13
|
*
|
|
@@ -154,5 +154,4 @@ async function fetchWebsiteMetadata(abbreviation, options) {
|
|
|
154
154
|
};
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
|
-
//#endregion
|
|
158
157
|
export { fetchWebsiteMetadata };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ProtectedWebsite, Website } from "../types/website.mjs";
|
|
2
2
|
import { LanguageCodes } from "../types/index.mjs";
|
|
3
3
|
import { OchreRequestOptions } from "./request.mjs";
|
|
4
|
-
//#region src/fetchers/website.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Fetches and parses a website configuration from the OCHRE API.
|
|
7
6
|
*
|
|
@@ -32,5 +31,4 @@ export declare function fetchWebsite<const T extends LanguageCodes = LanguageCod
|
|
|
32
31
|
protectedWebsite: null;
|
|
33
32
|
error: string;
|
|
34
33
|
detailedError: string;
|
|
35
|
-
}>;
|
|
36
|
-
//#endregion
|
|
34
|
+
}>;
|
|
@@ -4,7 +4,7 @@ import { parseLanguages } from "../parsers/languages.mjs";
|
|
|
4
4
|
import { XMLWebsiteData } from "../xml/schemas.mjs";
|
|
5
5
|
import { OCHRE_RESPONSE_PADDING, compileOchreQuery, stringLiteral } from "../xquery.mjs";
|
|
6
6
|
import { parseWebsite } from "../parsers/website/index.mjs";
|
|
7
|
-
|
|
7
|
+
// src/fetchers/website.ts
|
|
8
8
|
async function areWebsiteCredentialsValid(uuid, credentials, options) {
|
|
9
9
|
const security = typeof credentials === "string" ? { validate: credentials } : {
|
|
10
10
|
validate: credentials.password,
|
|
@@ -29,7 +29,16 @@ function buildXQuery(abbreviation) {
|
|
|
29
29
|
return compileOchreQuery({ body: ({ omitSupplemental }) => `let $ochre := collection("ochre/tree")/ochre[tree/identification/abbreviation/content/string = ${stringLiteral(abbreviation)}][1]
|
|
30
30
|
return
|
|
31
31
|
if (empty($ochre)) then <ochre>${OCHRE_RESPONSE_PADDING}</ochre>
|
|
32
|
-
else element ochre {
|
|
32
|
+
else element ochre {
|
|
33
|
+
$ochre/@*,
|
|
34
|
+
${omitSupplemental("$ochre/node()")},
|
|
35
|
+
<styleLabels>{
|
|
36
|
+
for $style in $ochre/tree/styleOptions/style[@valueUuid]
|
|
37
|
+
let $value := (doc()/ochre[@uuidBelongsTo = $ochre/@uuidBelongsTo]//property[label/@uuid = $style/@variableUuid]/value[@uuid = $style/@valueUuid][content])[1]
|
|
38
|
+
where exists($value)
|
|
39
|
+
return <styleLabel valueUuid="{$style/@valueUuid}">{$value/content}</styleLabel>
|
|
40
|
+
}</styleLabels>
|
|
41
|
+
}` });
|
|
33
42
|
}
|
|
34
43
|
/**
|
|
35
44
|
* Fetches and parses a website configuration from the OCHRE API.
|
|
@@ -78,5 +87,4 @@ async function fetchWebsite(abbreviation, options) {
|
|
|
78
87
|
};
|
|
79
88
|
}
|
|
80
89
|
}
|
|
81
|
-
//#endregion
|
|
82
90
|
export { fetchWebsite };
|
package/dist/getters.d.mts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { LanguageCodes, PropertyLike, PropertyValueContent } from "./types/index.mjs";
|
|
2
|
-
//#region src/getters.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Options for property search operations.
|
|
5
4
|
*/
|
|
@@ -135,5 +134,4 @@ export declare function isPropertyMatchingFilter<T extends LanguageCodes = Langu
|
|
|
135
134
|
variableLabel: string;
|
|
136
135
|
value: PropertyValueContent<T>;
|
|
137
136
|
}, options?: PropertyOptions): boolean;
|
|
138
|
-
//#endregion
|
|
139
137
|
export {};
|
package/dist/getters.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { deepEqual } from "fast-equals";
|
|
2
|
-
|
|
2
|
+
// src/getters.ts
|
|
3
3
|
/**
|
|
4
4
|
* The variable label that asks a filter to match against every property
|
|
5
5
|
*/
|
|
@@ -233,5 +233,4 @@ function isPropertyMatchingFilter(property, filter, options = DEFAULT_OPTIONS) {
|
|
|
233
233
|
}
|
|
234
234
|
return false;
|
|
235
235
|
}
|
|
236
|
-
//#endregion
|
|
237
236
|
export { getLeafPropertyValues, getProperty, getPropertyValue, getPropertyValues, getUniqueProperties, getUniquePropertyVariableLabels, isPropertyMatchingFilter, normalizePropertyVariableLabel };
|
package/dist/helpers.d.mts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ContainedItemCategory, Item, ItemCategory, ItemPayloadKind, LanguageCodes, SetItemProperty } from "./types/index.mjs";
|
|
2
|
-
//#region src/helpers.d.ts
|
|
3
2
|
type FlattenedItem<U, T extends LanguageCodes> = Omit<U, "properties"> & {
|
|
4
3
|
properties: Array<SetItemProperty<T>>;
|
|
5
4
|
};
|
|
@@ -9,5 +8,4 @@ type FlattenedItem<U, T extends LanguageCodes> = Omit<U, "properties"> & {
|
|
|
9
8
|
* @returns The item with the properties flattened
|
|
10
9
|
*/
|
|
11
10
|
export declare function flattenItemProperties<U extends ItemCategory = ItemCategory, V extends ContainedItemCategory<U> = ContainedItemCategory<U>, T extends LanguageCodes = LanguageCodes, W extends ItemPayloadKind = "topLevel">(item: Item<U, V, T, W>): FlattenedItem<Item<U, V, T, W>, T>;
|
|
12
|
-
//#endregion
|
|
13
11
|
export {};
|
package/dist/helpers.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/helpers.ts
|
|
2
2
|
/**
|
|
3
3
|
* Flatten the properties of an item
|
|
4
4
|
* @param item - The item whose properties to flatten
|
|
@@ -42,5 +42,4 @@ function flattenProperties(properties) {
|
|
|
42
42
|
}
|
|
43
43
|
return result;
|
|
44
44
|
}
|
|
45
|
-
//#endregion
|
|
46
45
|
export { flattenItemProperties };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { MultilingualOptions, MultilingualString, MultilingualStringEntries, MultilingualStringEntry, MultilingualStringInput, MultilingualStringJSON, MultilingualStringObject, MultilingualStringText } from "./parsers/multilingual.mjs";
|
|
2
2
|
import { AccordionWebBlock, ContextTree, ContextTreeFilterLevel, ContextTreeFilterVariant, ContextTreeLevel, ContextTreeLevelItem, ProtectedWebsite, ResponsiveStyles, Scope, Style, StylesheetCategory, StylesheetItem, WebAccordionItem, WebBlock, WebBlockByLayout, WebBlockItem, WebBlockLayout, WebElement, WebElementComponent, WebElementComponentName, WebElementComponentOf, WebElementOf, WebIiifViewer, WebImage, WebLoadingVariant, WebOptions, WebRelationVariant, WebSectionDisplay, WebSectionVariant, WebSidebar, WebTitle, Webpage, Website, WebsiteMetadata, WebsitePrivacy, WebsitePropertyQuery, WebsitePropertyQueryNode, WebsiteSegment, WebsiteType } from "./types/website.mjs";
|
|
3
|
-
import { AnyBibliography, AnyConcept, AnyItem, AnyPeriod, AnyPerson, AnyPropertyValue, AnyPropertyVariable, AnyResource, AnySet, AnySpatialUnit, AnyText, AnyTree, BaseItem, BaseItemLink, BelongsTo, Bibliography, BibliographyEntryInfo, BibliographyItemLink, BibliographySourceDocument, Concept, ConceptItemLink, ContainedItemCategory, ContainedItemCategoryFromOption, ContainedItemCategoryOption, Context, ContextItem, ContextItemCategory, ContextNode, Coordinates, CoordinatesSource, DictionaryUnitItemLink, EmbeddedBibliography, EmbeddedConcept, EmbeddedItem, EmbeddedPeriod, EmbeddedPerson, EmbeddedPropertyValue, EmbeddedPropertyVariable, EmbeddedResource, EmbeddedSet, EmbeddedSpatialUnit, EmbeddedText, EmbeddedTree, Event, Gallery, Heading, HeadingItemCategory, Identification, Image, ImageMap, ImageMapArea, Interpretation, Item, ItemCategory, ItemCategoryFromOption, ItemCategoryOption, ItemCategoryWithEmbeddedItems, ItemContainerCategory, ItemLink, ItemLinkCategory, ItemLinks, ItemPayloadKind, ItemProperty, ItemWithoutEmbeddedItems, LanguageCodes, License, Metadata, Note, Observation, OcrString, Period, PeriodItemLink, Person, PersonItemLink, Property, PropertyLike, PropertyRelation, PropertyValue, PropertyValueContent, PropertyValueDataType, PropertyValueItemLink, PropertyValueQueryItem, PropertyVariable, PropertyVariableItemLink, Query, QueryGroup, QueryLeaf, QueryablePropertyValueDataType, RecursiveItemCategory, Resource, ResourceItemLink, Section, Set, SetAttributeValueQueryItem, SetBibliography, SetConcept, SetItem, SetItemCategory, SetItemLink,
|
|
3
|
+
import { AnyBibliography, AnyConcept, AnyItem, AnyPeriod, AnyPerson, AnyPropertyValue, AnyPropertyVariable, AnyResource, AnySet, AnySpatialUnit, AnyText, AnyTree, BaseItem, BaseItemLink, BelongsTo, Bibliography, BibliographyEntryInfo, BibliographyItemLink, BibliographySourceDocument, Concept, ConceptItemLink, ContainedItemCategory, ContainedItemCategoryFromOption, ContainedItemCategoryOption, Context, ContextItem, ContextItemCategory, ContextNode, Coordinates, CoordinatesSource, DictionaryUnitItemLink, DownloadOption, EmbeddedBibliography, EmbeddedConcept, EmbeddedItem, EmbeddedPeriod, EmbeddedPerson, EmbeddedPropertyValue, EmbeddedPropertyVariable, EmbeddedResource, EmbeddedSet, EmbeddedSpatialUnit, EmbeddedText, EmbeddedTree, Event, Gallery, Heading, HeadingItemCategory, Identification, Image, ImageMap, ImageMapArea, Interpretation, Item, ItemCategory, ItemCategoryFromOption, ItemCategoryOption, ItemCategoryWithEmbeddedItems, ItemContainerCategory, ItemLink, ItemLinkCategory, ItemLinks, ItemLocation, ItemPayloadKind, ItemProperty, ItemWithoutEmbeddedItems, LanguageCodes, License, MapLayer, Metadata, Note, Observation, OcrString, Period, PeriodItemLink, Person, PersonItemLink, Property, PropertyLike, PropertyRelation, PropertyValue, PropertyValueContent, PropertyValueDataType, PropertyValueItemLink, PropertyValueQueryItem, PropertyVariable, PropertyVariableItemLink, Query, QueryGroup, QueryLeaf, QueryablePropertyValueDataType, RecursiveItemCategory, Resource, ResourceItemLink, Section, Set, SetAttributeValueQueryItem, SetBibliography, SetConcept, SetItem, SetItemCategory, SetItemLink, SetItemProperty, SetItemSimplifiedProperty, SetItemsSort, SetItemsSortDirection, SetPeriod, SetResource, SetSpatialUnit, SetStyle, SetStyleProperty, SetTree, SimplifiedProperty, SpatialUnit, SpatialUnitItemLink, Text, TextItemLink, TopLevelItem, Tree, TreeItemCategory, TreeItemLink } from "./types/index.mjs";
|
|
4
4
|
import { DEFAULT_PAGE_SIZE } from "./constants.mjs";
|
|
5
5
|
import { fetchGallery } from "./fetchers/gallery.mjs";
|
|
6
6
|
import { fetchItemChildren } from "./fetchers/item-children.mjs";
|
|
7
7
|
import { fetchItemLinks } from "./fetchers/item-links.mjs";
|
|
8
|
+
import { fetchItemLocations } from "./fetchers/item-locations.mjs";
|
|
8
9
|
import { fetchItemOcrData } from "./fetchers/item-ocr-data.mjs";
|
|
9
10
|
import { fetchItem } from "./fetchers/item.mjs";
|
|
10
|
-
import {
|
|
11
|
+
import { fetchMapLayers } from "./fetchers/map-layers.mjs";
|
|
11
12
|
import { fetchSetItems } from "./fetchers/set/items.mjs";
|
|
12
13
|
import { fetchSetPropertyValues } from "./fetchers/set/property-values.mjs";
|
|
13
14
|
import { fetchTreeItems } from "./fetchers/tree/items.mjs";
|
|
@@ -17,4 +18,4 @@ import { PropertyOptions, PropertySelector, getLeafPropertyValues, getProperty,
|
|
|
17
18
|
import { flattenItemProperties } from "./helpers.mjs";
|
|
18
19
|
import { OCHRE_LANGUAGES, OchreLanguage, OchreLanguageCode, OchreLanguageKind, OchreLanguageStandard, getOchreLanguage, getOchreLanguageCode, isOchreLanguageCode } from "./languages.mjs";
|
|
19
20
|
import { defineLanguages } from "./parsers/languages.mjs";
|
|
20
|
-
export { type AccordionWebBlock, type AnyBibliography, type AnyConcept, type AnyItem, type AnyPeriod, type AnyPerson, type AnyPropertyValue, type AnyPropertyVariable, type AnyResource, type AnySet, type AnySpatialUnit, type AnyText, type AnyTree, type BaseItem, type BaseItemLink, type BelongsTo, type Bibliography, type BibliographyEntryInfo, type BibliographyItemLink, type BibliographySourceDocument, type Concept, type ConceptItemLink, type ContainedItemCategory, type ContainedItemCategoryFromOption, type ContainedItemCategoryOption, type Context, type ContextItem, type ContextItemCategory, type ContextNode, type ContextTree, type ContextTreeFilterLevel, type ContextTreeFilterVariant, type ContextTreeLevel, type ContextTreeLevelItem, type Coordinates, type CoordinatesSource, DEFAULT_PAGE_SIZE, type DictionaryUnitItemLink, type EmbeddedBibliography, type EmbeddedConcept, type EmbeddedItem, type EmbeddedPeriod, type EmbeddedPerson, type EmbeddedPropertyValue, type EmbeddedPropertyVariable, type EmbeddedResource, type EmbeddedSet, type EmbeddedSpatialUnit, type EmbeddedText, type EmbeddedTree, type Event, type Gallery, type Heading, type HeadingItemCategory, type Identification, type Image, type ImageMap, type ImageMapArea, type Interpretation, type Item, type ItemCategory, type ItemCategoryFromOption, type ItemCategoryOption, type ItemCategoryWithEmbeddedItems, type ItemContainerCategory, type ItemLink, type ItemLinkCategory, type ItemLinks, type ItemPayloadKind, type ItemProperty, type ItemWithoutEmbeddedItems, type LanguageCodes, type License, type Metadata, type MultilingualOptions, MultilingualString, type MultilingualStringEntries, type MultilingualStringEntry, type MultilingualStringInput, type MultilingualStringJSON, type MultilingualStringObject, type MultilingualStringText, type Note, OCHRE_LANGUAGES, type Observation, type OchreLanguage, type OchreLanguageCode, type OchreLanguageKind, type OchreLanguageStandard, type OcrString, type Period, type PeriodItemLink, type Person, type PersonItemLink, type Property, type PropertyLike, type PropertyOptions, type PropertyRelation, type PropertySelector, type PropertyValue, type PropertyValueContent, type PropertyValueDataType, type PropertyValueItemLink, type PropertyValueQueryItem, type PropertyVariable, type PropertyVariableItemLink, type ProtectedWebsite, type Query, type QueryGroup, type QueryLeaf, type QueryablePropertyValueDataType, type RecursiveItemCategory, type Resource, type ResourceItemLink, type ResponsiveStyles, type Scope, type Section, type Set, type SetAttributeValueQueryItem, type SetBibliography, type SetConcept, type SetItem, type SetItemCategory, type SetItemLink, type
|
|
21
|
+
export { type AccordionWebBlock, type AnyBibliography, type AnyConcept, type AnyItem, type AnyPeriod, type AnyPerson, type AnyPropertyValue, type AnyPropertyVariable, type AnyResource, type AnySet, type AnySpatialUnit, type AnyText, type AnyTree, type BaseItem, type BaseItemLink, type BelongsTo, type Bibliography, type BibliographyEntryInfo, type BibliographyItemLink, type BibliographySourceDocument, type Concept, type ConceptItemLink, type ContainedItemCategory, type ContainedItemCategoryFromOption, type ContainedItemCategoryOption, type Context, type ContextItem, type ContextItemCategory, type ContextNode, type ContextTree, type ContextTreeFilterLevel, type ContextTreeFilterVariant, type ContextTreeLevel, type ContextTreeLevelItem, type Coordinates, type CoordinatesSource, DEFAULT_PAGE_SIZE, type DictionaryUnitItemLink, type DownloadOption, type EmbeddedBibliography, type EmbeddedConcept, type EmbeddedItem, type EmbeddedPeriod, type EmbeddedPerson, type EmbeddedPropertyValue, type EmbeddedPropertyVariable, type EmbeddedResource, type EmbeddedSet, type EmbeddedSpatialUnit, type EmbeddedText, type EmbeddedTree, type Event, type Gallery, type Heading, type HeadingItemCategory, type Identification, type Image, type ImageMap, type ImageMapArea, type Interpretation, type Item, type ItemCategory, type ItemCategoryFromOption, type ItemCategoryOption, type ItemCategoryWithEmbeddedItems, type ItemContainerCategory, type ItemLink, type ItemLinkCategory, type ItemLinks, type ItemLocation, type ItemPayloadKind, type ItemProperty, type ItemWithoutEmbeddedItems, type LanguageCodes, type License, type MapLayer, type Metadata, type MultilingualOptions, MultilingualString, type MultilingualStringEntries, type MultilingualStringEntry, type MultilingualStringInput, type MultilingualStringJSON, type MultilingualStringObject, type MultilingualStringText, type Note, OCHRE_LANGUAGES, type Observation, type OchreLanguage, type OchreLanguageCode, type OchreLanguageKind, type OchreLanguageStandard, type OcrString, type Period, type PeriodItemLink, type Person, type PersonItemLink, type Property, type PropertyLike, type PropertyOptions, type PropertyRelation, type PropertySelector, type PropertyValue, type PropertyValueContent, type PropertyValueDataType, type PropertyValueItemLink, type PropertyValueQueryItem, type PropertyVariable, type PropertyVariableItemLink, type ProtectedWebsite, type Query, type QueryGroup, type QueryLeaf, type QueryablePropertyValueDataType, type RecursiveItemCategory, type Resource, type ResourceItemLink, type ResponsiveStyles, type Scope, type Section, type Set, type SetAttributeValueQueryItem, type SetBibliography, type SetConcept, type SetItem, type SetItemCategory, type SetItemLink, type SetItemProperty, type SetItemSimplifiedProperty, type SetItemsSort, type SetItemsSortDirection, type SetPeriod, type SetResource, type SetSpatialUnit, type SetStyle, type SetStyleProperty, type SetTree, type SimplifiedProperty, type SpatialUnit, type SpatialUnitItemLink, type Style, type StylesheetCategory, type StylesheetItem, type Text, type TextItemLink, type TopLevelItem, type Tree, type TreeItemCategory, type TreeItemLink, type WebAccordionItem, type WebBlock, type WebBlockByLayout, type WebBlockItem, type WebBlockLayout, type WebElement, type WebElementComponent, type WebElementComponentName, type WebElementComponentOf, type WebElementOf, type WebIiifViewer, type WebImage, type WebLoadingVariant, type WebOptions, type WebRelationVariant, type WebSectionDisplay, type WebSectionVariant, type WebSidebar, type WebTitle, type Webpage, type Website, type WebsiteMetadata, type WebsitePrivacy, type WebsitePropertyQuery, type WebsitePropertyQueryNode, type WebsiteSegment, type WebsiteType, defineLanguages, fetchGallery, fetchItem, fetchItemChildren, fetchItemLinks, fetchItemLocations, fetchItemOcrData, fetchMapLayers, fetchSetItems, fetchSetPropertyValues, fetchTreeItems, fetchWebsite, fetchWebsiteMetadata, flattenItemProperties, getLeafPropertyValues, getOchreLanguage, getOchreLanguageCode, getProperty, getPropertyValue, getPropertyValues, getUniqueProperties, getUniquePropertyVariableLabels, isOchreLanguageCode, isPropertyMatchingFilter, normalizePropertyVariableLabel };
|
package/dist/index.mjs
CHANGED
|
@@ -7,12 +7,13 @@ import { defineLanguages } from "./parsers/languages.mjs";
|
|
|
7
7
|
import { fetchGallery } from "./fetchers/gallery.mjs";
|
|
8
8
|
import { fetchItemChildren } from "./fetchers/item-children.mjs";
|
|
9
9
|
import { fetchItemLinks } from "./fetchers/item-links.mjs";
|
|
10
|
+
import { fetchItemLocations } from "./fetchers/item-locations.mjs";
|
|
10
11
|
import { fetchItemOcrData } from "./fetchers/item-ocr-data.mjs";
|
|
11
12
|
import { fetchItem } from "./fetchers/item.mjs";
|
|
12
|
-
import {
|
|
13
|
+
import { fetchMapLayers } from "./fetchers/map-layers.mjs";
|
|
13
14
|
import { fetchSetItems } from "./fetchers/set/items.mjs";
|
|
14
15
|
import { fetchSetPropertyValues } from "./fetchers/set/property-values.mjs";
|
|
15
16
|
import { fetchTreeItems } from "./fetchers/tree/items.mjs";
|
|
16
17
|
import { fetchWebsiteMetadata } from "./fetchers/website-metadata.mjs";
|
|
17
18
|
import { fetchWebsite } from "./fetchers/website.mjs";
|
|
18
|
-
export { DEFAULT_PAGE_SIZE, MultilingualString, OCHRE_LANGUAGES, defineLanguages, fetchGallery, fetchItem, fetchItemChildren, fetchItemLinks, fetchItemOcrData,
|
|
19
|
+
export { DEFAULT_PAGE_SIZE, MultilingualString, OCHRE_LANGUAGES, defineLanguages, fetchGallery, fetchItem, fetchItemChildren, fetchItemLinks, fetchItemLocations, fetchItemOcrData, fetchMapLayers, fetchSetItems, fetchSetPropertyValues, fetchTreeItems, fetchWebsite, fetchWebsiteMetadata, flattenItemProperties, getLeafPropertyValues, getOchreLanguage, getOchreLanguageCode, getProperty, getPropertyValue, getPropertyValues, getUniqueProperties, getUniquePropertyVariableLabels, isOchreLanguageCode, isPropertyMatchingFilter, normalizePropertyVariableLabel };
|
package/dist/languages.d.mts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/languages.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* What an OCHRE language code tags
|
|
4
3
|
*
|
|
@@ -672,5 +671,4 @@ export declare function getOchreLanguage(code: string): OchreLanguage | null;
|
|
|
672
671
|
* @returns The OCHRE code of the language itself, not of a transliteration,
|
|
673
672
|
* or null when OCHRE publishes no code for it
|
|
674
673
|
*/
|
|
675
|
-
export declare function getOchreLanguageCode(iso639_3: string): OchreLanguageCode | null;
|
|
676
|
-
//#endregion
|
|
674
|
+
export declare function getOchreLanguageCode(iso639_3: string): OchreLanguageCode | null;
|
package/dist/languages.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/languages.ts
|
|
2
2
|
/**
|
|
3
3
|
* Every language code OCHRE publishes, mapped to the ISO 639-3 and BCP 47
|
|
4
4
|
* codes it stands for
|
|
@@ -629,5 +629,4 @@ function getOchreLanguageCode(iso639_3) {
|
|
|
629
629
|
for (const [code, language] of Object.entries(OCHRE_LANGUAGES)) if (language.kind === "language" && language.iso639_3 === iso639_3 && isOchreLanguageCode(code)) return code;
|
|
630
630
|
return null;
|
|
631
631
|
}
|
|
632
|
-
//#endregion
|
|
633
632
|
export { OCHRE_LANGUAGES, getOchreLanguage, getOchreLanguageCode, isOchreLanguageCode };
|
package/dist/ocr.d.mts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/ocr.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* The name of the element wrapping an OCR layer inside an OCHRE document
|
|
4
3
|
* @internal
|
|
@@ -33,5 +32,4 @@ export declare const OCR_WORD_QNAMES: string;
|
|
|
33
32
|
* @returns The XQuery path
|
|
34
33
|
* @internal
|
|
35
34
|
*/
|
|
36
|
-
export declare function buildOcrWordPath(rootExpression: string): string;
|
|
37
|
-
//#endregion
|
|
35
|
+
export declare function buildOcrWordPath(rootExpression: string): string;
|
package/dist/ocr.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { stringLiteral } from "./xquery.mjs";
|
|
2
|
-
|
|
2
|
+
// src/ocr.ts
|
|
3
3
|
const ALTO_NAMESPACE = "http://www.loc.gov/standards/alto/ns-v2#";
|
|
4
4
|
/**
|
|
5
5
|
* The local names OCHRE serves OCR word elements under
|
|
@@ -48,5 +48,4 @@ const OCR_WORD_QNAMES = `(${[...OCR_WORD_LOCAL_NAMES.map((localName) => `fn:QNam
|
|
|
48
48
|
function buildOcrWordPath(rootExpression) {
|
|
49
49
|
return `${rootExpression}//*[lower-case(local-name(.)) = ${stringLiteral("ocr")}]//*[lower-case(local-name(.)) = ${stringLiteral(OCR_WORD_CASE_FOLDED_LOCAL_NAME)}][@${OCR_WORD_CONTENT_ATTRIBUTE}]`;
|
|
50
50
|
}
|
|
51
|
-
//#endregion
|
|
52
51
|
export { OCR_LAYER_ELEMENT_NAME, OCR_WORD_CONTENT_ATTRIBUTE, OCR_WORD_QNAMES, buildOcrWordPath };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { MultilingualString } from "./multilingual.mjs";
|
|
2
2
|
import { License } from "../types/index.mjs";
|
|
3
3
|
import { XMLContent, XMLString } from "../xml/types.mjs";
|
|
4
|
-
//#region src/parsers/helpers.d.ts
|
|
5
4
|
export type FetchFunction = (input: string | URL | globalThis.Request, init?: RequestInit) => Promise<Response>;
|
|
6
5
|
export type FetchBaseOptions<TLanguages extends ReadonlyArray<string> | undefined = undefined> = {
|
|
7
6
|
languages?: TLanguages;
|
|
@@ -59,5 +58,4 @@ export declare function multilingualFromText<T extends ReadonlyArray<string>>(te
|
|
|
59
58
|
export declare function parseContentLike<T extends ReadonlyArray<string>>(value: XMLContent | XMLString | string | undefined, options: ParserOptions<T>): MultilingualString<T> | null;
|
|
60
59
|
export declare function parseRequiredContentLike<T extends ReadonlyArray<string>>(value: XMLContent | XMLString, options: ParserOptions<T>): MultilingualString<T>;
|
|
61
60
|
export declare function parseContentLikeText<T extends ReadonlyArray<string>>(value: XMLContent | XMLString | undefined, options: ParserOptions<T>): string;
|
|
62
|
-
export declare function parseStringContent(value: XMLContent | XMLString | string | undefined, options?: ParserOptions<ReadonlyArray<string>>): string;
|
|
63
|
-
//#endregion
|
|
61
|
+
export declare function parseStringContent(value: XMLContent | XMLString | string | undefined, options?: ParserOptions<ReadonlyArray<string>>): string;
|
package/dist/parsers/helpers.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DEFAULT_LANGUAGES } from "../constants.mjs";
|
|
2
2
|
import { MultilingualString } from "./multilingual.mjs";
|
|
3
3
|
import { parseXMLContent, parseXMLString } from "./string.mjs";
|
|
4
|
-
|
|
4
|
+
// src/parsers/helpers.ts
|
|
5
5
|
const FALLBACK_PARSER_OPTIONS = { languages: DEFAULT_LANGUAGES };
|
|
6
6
|
function getParserOptions(options) {
|
|
7
7
|
return {
|
|
@@ -73,5 +73,4 @@ function parseStringContent(value, options = FALLBACK_PARSER_OPTIONS) {
|
|
|
73
73
|
}
|
|
74
74
|
return parseXMLString(value).text;
|
|
75
75
|
}
|
|
76
|
-
//#endregion
|
|
77
76
|
export { cleanObject, getParserOptions, isXMLContent, multilingualFromText, parseContentLike, parseContentLikeText, parseLicense, parseRequiredContentLike, parseStringContent, parseStringLike };
|
package/dist/parsers/index.d.mts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Webpage } from "../types/website.mjs";
|
|
2
|
-
import { Bibliography, ContainedItemCategoryFromOption, ContainedItemCategoryOption, Coordinates, Gallery, Identification, Item, ItemCategory, ItemCategoryFromOption, ItemCategoryOption, ItemContainerCategory, ItemLinks, Metadata, Note, Person, Property, Resource, SetItem, SetItemCategory, SimplifiedProperty } from "../types/index.mjs";
|
|
3
|
-
import { XMLBibliography, XMLCoordinates, XMLData, XMLDataItem, XMLGalleryData, XMLIdentification, XMLItemLinks, XMLLink, XMLMetadata, XMLNote, XMLPerson, XMLProperty, XMLResource, XMLSetItems, XMLSimplifiedProperty } from "../xml/types.mjs";
|
|
2
|
+
import { Bibliography, ContainedItemCategoryFromOption, ContainedItemCategoryOption, Coordinates, Gallery, Identification, Item, ItemCategory, ItemCategoryFromOption, ItemCategoryOption, ItemContainerCategory, ItemLinks, Metadata, Note, Person, Property, Resource, SetItem, SetItemCategory, SimplifiedProperty, SpatialUnit } from "../types/index.mjs";
|
|
3
|
+
import { XMLBibliography, XMLCoordinates, XMLData, XMLDataItem, XMLGalleryData, XMLIdentification, XMLItemLinks, XMLLink, XMLMetadata, XMLNote, XMLPerson, XMLProperty, XMLResource, XMLSetItems, XMLSimplifiedProperty, XMLSpatialUnit } from "../xml/types.mjs";
|
|
4
4
|
import { ParserOptions, getParserOptions, parseStringLike } from "./helpers.mjs";
|
|
5
|
-
//#region src/parsers/index.d.ts
|
|
6
5
|
export type RawOchre = XMLData["result"]["ochre"];
|
|
7
6
|
type ResourceViewParser<T extends ReadonlyArray<string>> = (view: XMLResource["view"], context: Pick<Resource<T, "topLevel">, "belongsTo" | "metadata">) => Webpage<T> | null;
|
|
8
7
|
type SetItemCategoryFromCategories<T extends ReadonlyArray<SetItemCategory> | undefined> = T extends ReadonlyArray<infer U> ? Extract<U, SetItemCategory> : SetItemCategory;
|
|
@@ -22,6 +21,7 @@ export declare function parseBibliographyList<T extends ReadonlyArray<string>>(r
|
|
|
22
21
|
bibliography: Array<XMLBibliography>;
|
|
23
22
|
} | undefined, options: ParserOptions<T>): Array<Bibliography<T, "embedded">>;
|
|
24
23
|
export declare function parsePersonList<T extends ReadonlyArray<string>>(rawPersons: Array<XMLPerson> | undefined, options: ParserOptions<T>): Array<Person<T, "embedded">>;
|
|
24
|
+
export declare function parseSpatialUnitMapData(mapData: XMLSpatialUnit["mapData"]): SpatialUnit<ReadonlyArray<string>, "embedded">["mapData"];
|
|
25
25
|
export declare function parseMetadata<T extends ReadonlyArray<string>>(rawOchre: {
|
|
26
26
|
uuidBelongsTo: string;
|
|
27
27
|
metadata: XMLMetadata;
|
|
@@ -53,5 +53,4 @@ export declare function parseItem(rawData: XMLData, options: {
|
|
|
53
53
|
languages: ReadonlyArray<string>;
|
|
54
54
|
parseResourceView?: ResourceViewParser<ReadonlyArray<string>>;
|
|
55
55
|
}): Item<ItemCategory, SetItemCategory, ReadonlyArray<string>>;
|
|
56
|
-
//#endregion
|
|
57
56
|
export { type ParserOptions, getParserOptions, parseStringLike };
|
package/dist/parsers/index.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import { parseXMLString, transformPermanentIdentificationUrl } from "./string.mj
|
|
|
7
7
|
import { getParserOptions, multilingualFromText, parseContentLike, parseContentLikeText, parseLicense, parseRequiredContentLike, parseStringLike } from "./helpers.mjs";
|
|
8
8
|
import { parseMetadataLanguages, resolveDefaultLanguage, resolveLanguages } from "./languages.mjs";
|
|
9
9
|
import * as v from "valibot";
|
|
10
|
-
|
|
10
|
+
// src/parsers/index.ts
|
|
11
11
|
function isXMLContextGroup(context) {
|
|
12
12
|
return "context" in context;
|
|
13
13
|
}
|
|
@@ -318,6 +318,13 @@ function parseImage(rawImage, options) {
|
|
|
318
318
|
base64: rawImage.payload ?? null
|
|
319
319
|
};
|
|
320
320
|
}
|
|
321
|
+
function parseDownloadOptions(rawDownloadOptions) {
|
|
322
|
+
return Array.from(rawDownloadOptions?.option ?? [], (option) => ({
|
|
323
|
+
type: option.type,
|
|
324
|
+
href: transformPermanentIdentificationUrl(option.href),
|
|
325
|
+
fileFormat: option.fileFormat
|
|
326
|
+
}));
|
|
327
|
+
}
|
|
321
328
|
function parseHref(href) {
|
|
322
329
|
return href == null ? null : transformPermanentIdentificationUrl(href);
|
|
323
330
|
}
|
|
@@ -351,13 +358,22 @@ function parseCoordinatesSource(source, options) {
|
|
|
351
358
|
}
|
|
352
359
|
function parseCoordinate(coordinate, options) {
|
|
353
360
|
switch (coordinate.type) {
|
|
354
|
-
case "point":
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
+
case "point": {
|
|
362
|
+
const [x, y, z] = (coordinate.rawValue ?? "").split(",").map((part) => part.trim() === "" ? NaN : Number(part));
|
|
363
|
+
return {
|
|
364
|
+
type: "point",
|
|
365
|
+
latitude: coordinate.latitude,
|
|
366
|
+
longitude: coordinate.longitude,
|
|
367
|
+
altitude: coordinate.altitude ?? null,
|
|
368
|
+
crs: x != null && y != null && coordinate.WKID != null && coordinate.WKID !== 4326 && Number.isFinite(x) && Number.isFinite(y) ? {
|
|
369
|
+
wkid: coordinate.WKID,
|
|
370
|
+
x,
|
|
371
|
+
y,
|
|
372
|
+
z: z != null && Number.isFinite(z) ? z : null
|
|
373
|
+
} : null,
|
|
374
|
+
source: parseCoordinatesSource(coordinate.source, options)
|
|
375
|
+
};
|
|
376
|
+
}
|
|
361
377
|
case "plane": return {
|
|
362
378
|
type: "plane",
|
|
363
379
|
minimum: {
|
|
@@ -785,6 +801,7 @@ function parseObservation(rawObservation, options) {
|
|
|
785
801
|
periods: parsePeriodList(rawObservation.periods, options),
|
|
786
802
|
links: parseLinks(rawObservation.links, options),
|
|
787
803
|
reverseLinks: parseReverseLinks(rawObservation.reverseLinks, options),
|
|
804
|
+
downloadOptions: parseDownloadOptions(rawObservation.downloadOptions),
|
|
788
805
|
notes: parseNotes(rawObservation.notes, options),
|
|
789
806
|
properties: parseProperties(rawObservation.properties, options),
|
|
790
807
|
bibliographies: parseBibliographyList(rawObservation.bibliographies, options)
|
|
@@ -940,6 +957,7 @@ function parseBibliography(rawBibliography, options) {
|
|
|
940
957
|
citationFormatSpan: parseStringLike(rawBibliography.citationFormatSpan),
|
|
941
958
|
referenceFormatDiv: parseStringLike(rawBibliography.referenceFormatDiv),
|
|
942
959
|
image: parseImage(rawBibliography.image, options),
|
|
960
|
+
downloadOptions: parseDownloadOptions(rawBibliography.downloadOptions),
|
|
943
961
|
sourceDocument: parseBibliographySourceDocument(rawBibliography.sourceDocument),
|
|
944
962
|
publicationInfo: rawBibliography.publicationInfo == null ? null : {
|
|
945
963
|
publishers: parsePersonList(rawBibliography.publicationInfo.publishers == null ? void 0 : "publisher" in rawBibliography.publicationInfo.publishers ? rawBibliography.publicationInfo.publishers.publisher : rawBibliography.publicationInfo.publishers.publishers.person, options),
|
|
@@ -1062,6 +1080,7 @@ function parseResource(rawResource, options) {
|
|
|
1062
1080
|
image: parseImage(rawResource.image, options),
|
|
1063
1081
|
document: parseContentLike(rawResource.document, options),
|
|
1064
1082
|
imageMap: parseImageMap(rawResource.imagemap),
|
|
1083
|
+
downloadOptions: parseDownloadOptions(rawResource.downloadOptions),
|
|
1065
1084
|
coordinates: parseCoordinates(rawResource.coordinates, options),
|
|
1066
1085
|
periods: parsePeriodList(rawResource.periods, options),
|
|
1067
1086
|
links: parseLinks(rawResource.links, options),
|
|
@@ -1228,5 +1247,4 @@ function parseItem(rawData, options) {
|
|
|
1228
1247
|
persistentUrl
|
|
1229
1248
|
};
|
|
1230
1249
|
}
|
|
1231
|
-
|
|
1232
|
-
export { getParserOptions, parseBibliographyList, parseCoordinates, parseGallery, parseIdentification, parseItem, parseLinkedItems, parseLinks, parseMetadata, parseNotes, parsePersonList, parseProperties, parseSetItems, parseSimplifiedProperties, parseStringLike };
|
|
1250
|
+
export { getParserOptions, parseBibliographyList, parseCoordinates, parseGallery, parseIdentification, parseItem, parseLinkedItems, parseLinks, parseMetadata, parseNotes, parsePersonList, parseProperties, parseSetItems, parseSimplifiedProperties, parseSpatialUnitMapData, parseStringLike };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { XMLMetadata } from "../xml/types.mjs";
|
|
2
|
-
//#region src/parsers/languages.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Validate language codes while preserving literal tuple inference
|
|
5
4
|
* @param languages - The language codes to validate
|
|
@@ -66,5 +65,4 @@ export declare function resolveLanguages<T extends ReadonlyArray<string>>(reques
|
|
|
66
65
|
*/
|
|
67
66
|
export declare function resolveDefaultLanguage<T extends ReadonlyArray<string>>(rawOchre: {
|
|
68
67
|
metadata: XMLMetadata;
|
|
69
|
-
}, languages: T): T[number];
|
|
70
|
-
//#endregion
|
|
68
|
+
}, languages: T): T[number];
|
|
@@ -3,7 +3,7 @@ import { readArrayProperty, readEntries } from "../reflection.mjs";
|
|
|
3
3
|
import { ochreLanguageCodeSchema } from "../schemas.mjs";
|
|
4
4
|
import { parseStringLike } from "./helpers.mjs";
|
|
5
5
|
import * as v from "valibot";
|
|
6
|
-
|
|
6
|
+
// src/parsers/languages.ts
|
|
7
7
|
/**
|
|
8
8
|
* A content entry carrying a language tag
|
|
9
9
|
*
|
|
@@ -123,5 +123,4 @@ function resolveDefaultLanguage(rawOchre, languages) {
|
|
|
123
123
|
if (firstLanguage == null) throw new Error("Default language not found", { cause: languages });
|
|
124
124
|
return firstLanguage;
|
|
125
125
|
}
|
|
126
|
-
//#endregion
|
|
127
126
|
export { defineLanguages, parseLanguages, parseMetadataLanguages, parseRequestedLanguages, resolveContentLanguages, resolveDefaultLanguage, resolveLanguages };
|
package/dist/parsers/mdx.d.mts
CHANGED
package/dist/parsers/mdx.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/parsers/mdx.ts
|
|
2
2
|
const MDX_LITERAL_EXPRESSION_REGEX = /[!#*<>[\]_`{|}~]/;
|
|
3
3
|
const MDX_LITERAL_BLOCK_REGEX = /(?:^|\n)[\t ]*(?:import|export|[+>-]|\d+[).])(?:[\t ]|$)/;
|
|
4
4
|
const MDX_MULTIPLE_SPACES_REGEX = / {2,}/g;
|
|
@@ -18,5 +18,4 @@ function serializeMDXContent(value) {
|
|
|
18
18
|
if (!MDX_INLINE_BOUNDARY_REGEX.test(content)) return content;
|
|
19
19
|
return content.endsWith("\n") ? `<>\n${content}</>` : `<>\n${content}\n</>`;
|
|
20
20
|
}
|
|
21
|
-
//#endregion
|
|
22
21
|
export { serializeMDXContent, serializeMDXText };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/parsers/multilingual.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* One text entry for a language. When OCHRE exposes multiple entries for the
|
|
4
3
|
* same language, the first one is primary.
|
|
@@ -310,5 +309,4 @@ export declare class MultilingualString<T extends ReadonlyArray<string> = Readon
|
|
|
310
309
|
*/
|
|
311
310
|
toJSON(): MultilingualStringJSON<T>;
|
|
312
311
|
}
|
|
313
|
-
//#endregion
|
|
314
312
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DEFAULT_LANGUAGES } from "../constants.mjs";
|
|
2
2
|
import { readProperty } from "../reflection.mjs";
|
|
3
3
|
import { serializeMDXText } from "./mdx.mjs";
|
|
4
|
-
|
|
4
|
+
// src/parsers/multilingual.ts
|
|
5
5
|
const MULTILINGUAL_STRING_INTERNAL_INIT = Symbol("MultilingualString.internalInit");
|
|
6
6
|
function normalizeInputText(text) {
|
|
7
7
|
return typeof text === "string" ? {
|
|
@@ -503,5 +503,4 @@ var MultilingualString = class MultilingualString {
|
|
|
503
503
|
};
|
|
504
504
|
}
|
|
505
505
|
};
|
|
506
|
-
//#endregion
|
|
507
506
|
export { MultilingualString };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/parsers/property-token.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* The attributes a property value can carry its text in
|
|
4
3
|
*/
|
|
@@ -31,5 +30,4 @@ export declare function readPropertyValueText(value: PropertyValueTextSource, re
|
|
|
31
30
|
export declare function readPropertyValueUuid(value: {
|
|
32
31
|
uuid?: string;
|
|
33
32
|
} | undefined): string | null;
|
|
34
|
-
//#endregion
|
|
35
33
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/parsers/property-token.ts
|
|
2
2
|
/**
|
|
3
3
|
* The text a property value stands for
|
|
4
4
|
*
|
|
@@ -25,5 +25,4 @@ function readPropertyValueText(value, readContentText) {
|
|
|
25
25
|
function readPropertyValueUuid(value) {
|
|
26
26
|
return value?.uuid == null || value.uuid === "" ? null : value.uuid;
|
|
27
27
|
}
|
|
28
|
-
//#endregion
|
|
29
28
|
export { readPropertyValueText, readPropertyValueUuid };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { MultilingualString, MultilingualStringText } from "./multilingual.mjs";
|
|
2
2
|
import { XMLContent, XMLString } from "../xml/types.mjs";
|
|
3
|
-
//#region src/parsers/string.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Rewrite a permanent identification URL as an OCHRE API endpoint
|
|
6
5
|
*
|
|
@@ -45,5 +44,4 @@ export declare function parseXMLContent<V extends ReadonlyArray<string>>(item: X
|
|
|
45
44
|
*
|
|
46
45
|
* @internal
|
|
47
46
|
*/
|
|
48
|
-
export declare function extractAliases(content: XMLContent | undefined): Array<string> | null;
|
|
49
|
-
//#endregion
|
|
47
|
+
export declare function extractAliases(content: XMLContent | undefined): Array<string> | null;
|
package/dist/parsers/string.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import { MultilingualString } from "./multilingual.mjs";
|
|
|
6
6
|
import { readPropertyValueText, readPropertyValueUuid } from "./property-token.mjs";
|
|
7
7
|
import { renderOptionsSchema } from "../schemas.mjs";
|
|
8
8
|
import * as v from "valibot";
|
|
9
|
-
|
|
9
|
+
// src/parsers/string.ts
|
|
10
10
|
const TEXT_ANNOTATION_TOKEN = "text-annotation";
|
|
11
11
|
const TEXT_STYLING_TOKEN = "text-styling";
|
|
12
12
|
const HOVER_CARD_TOKEN = "hover-card";
|
|
@@ -507,5 +507,4 @@ function extractAliases(content) {
|
|
|
507
507
|
}
|
|
508
508
|
return aliases.length > 0 ? aliases : null;
|
|
509
509
|
}
|
|
510
|
-
//#endregion
|
|
511
510
|
export { extractAliases, parseXMLContent, parseXMLString, transformPermanentIdentificationUrl, transformPermanentIdentificationUrlToItemLink };
|