ochre-sdk 1.0.26 → 1.0.28
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/fetchers/item.d.mts +4 -4
- package/dist/fetchers/item.mjs +21 -13
- package/dist/fetchers/set/items.mjs +1 -0
- package/dist/fetchers/set/property-values.mjs +23 -13
- package/dist/index.d.mts +2 -2
- package/dist/parsers/index.mjs +4 -2
- package/dist/query.mjs +30 -6
- package/dist/schemas.mjs +7 -1
- package/dist/types/index.d.mts +9 -1
- package/dist/xml/schemas.mjs +5 -2
- package/dist/xml/types.d.mts +4 -1
- package/package.json +1 -1
package/dist/fetchers/item.d.mts
CHANGED
|
@@ -35,7 +35,7 @@ declare function withLanguages<const TLanguages extends ReadonlyArray<string>>(l
|
|
|
35
35
|
* single category when it is known, or an array when the item may be any
|
|
36
36
|
* category in that list.
|
|
37
37
|
* @param options.containedItemCategory - The category of items inside the OCHRE item to fetch. Only valid for Trees and Sets. Tree accepts one category; Set accepts one category or an array.
|
|
38
|
-
* @param options.shouldOmitEmbeddedItems - Whether to omit the embedded item hierarchy when fetching a recursive item category.
|
|
38
|
+
* @param options.shouldOmitEmbeddedItems - Whether to omit the embedded item hierarchy when fetching a recursive item category. Ignored when the fetched item does not expose recursive embedded items.
|
|
39
39
|
* @param options.languages - Language codes to parse. Inline arrays preserve literal types automatically.
|
|
40
40
|
* @param options.fetch - Custom fetch function to use instead of the default fetch
|
|
41
41
|
* @returns An object containing the parsed item
|
|
@@ -49,7 +49,7 @@ declare function fetchItem<const TContainedItemCategory extends ContainedItemCat
|
|
|
49
49
|
category?: undefined;
|
|
50
50
|
containedItemCategory?: TContainedItemCategory;
|
|
51
51
|
shouldOmitEmbeddedItems?: true;
|
|
52
|
-
}): FetchItemResult<ItemWithoutEmbeddedItems<ItemCategoryWithEmbeddedItems, ContainedItemCategoryFromOption<ItemContainerCategory, TContainedItemCategory>, FetchLanguages<TLanguages>>>;
|
|
52
|
+
}): FetchItemResult<ItemWithoutEmbeddedItems<ItemCategoryWithEmbeddedItems, ContainedItemCategoryFromOption<ItemContainerCategory, TContainedItemCategory>, FetchLanguages<TLanguages>> | Item<Exclude<ItemCategory, ItemCategoryWithEmbeddedItems>, never, FetchLanguages<TLanguages>>>;
|
|
53
53
|
declare function fetchItem<const TCategory extends ItemCategoryOption, const TContainedItemCategory extends ContainedItemCategoryOption<ItemCategoryFromOption<TCategory>> | undefined = undefined, const TLanguages extends ReadonlyArray<string> | undefined = undefined>(uuid: string, options: FetchBaseOptions<TLanguages> & {
|
|
54
54
|
category: TCategory;
|
|
55
55
|
containedItemCategory?: TContainedItemCategory;
|
|
@@ -58,7 +58,7 @@ declare function fetchItem<const TCategory extends ItemCategoryOption, const TCo
|
|
|
58
58
|
declare function fetchItem<const TCategory extends ItemCategoryOption, const TContainedItemCategory extends ContainedItemCategoryOption<Extract<ItemCategoryFromOption<TCategory>, ItemCategoryWithEmbeddedItems>> | undefined = undefined, const TLanguages extends ReadonlyArray<string> | undefined = undefined>(uuid: string, options: FetchBaseOptions<TLanguages> & {
|
|
59
59
|
category: TCategory;
|
|
60
60
|
containedItemCategory?: TContainedItemCategory;
|
|
61
|
-
shouldOmitEmbeddedItems:
|
|
62
|
-
}): FetchItemResult<ItemWithoutEmbeddedItems<Extract<ItemCategoryFromOption<TCategory>, ItemCategoryWithEmbeddedItems>, ContainedItemCategoryFromOption<Extract<ItemCategoryFromOption<TCategory>, ItemCategoryWithEmbeddedItems>, TContainedItemCategory>, FetchLanguages<TLanguages>>>;
|
|
61
|
+
shouldOmitEmbeddedItems: true;
|
|
62
|
+
}): FetchItemResult<ItemWithoutEmbeddedItems<Extract<ItemCategoryFromOption<TCategory>, ItemCategoryWithEmbeddedItems>, ContainedItemCategoryFromOption<Extract<ItemCategoryFromOption<TCategory>, ItemCategoryWithEmbeddedItems>, TContainedItemCategory>, FetchLanguages<TLanguages>> | Item<Exclude<ItemCategoryFromOption<TCategory>, ItemCategoryWithEmbeddedItems>, never, FetchLanguages<TLanguages>>>;
|
|
63
63
|
//#endregion
|
|
64
64
|
export { defineLanguages, fetchItem, withLanguages };
|
package/dist/fetchers/item.mjs
CHANGED
|
@@ -23,11 +23,6 @@ function assertItemCategoryAllowed(category, containedItemCategory) {
|
|
|
23
23
|
for (const possibleCategory of categories) if (isItemContainerCategory(possibleCategory)) return;
|
|
24
24
|
throw new Error(`containedItemCategory can only be used when category is "tree" or "set"; received category "${categories.join(", ")}"`);
|
|
25
25
|
}
|
|
26
|
-
function assertShouldOmitEmbeddedItemsAllowed(category, shouldOmitEmbeddedItems) {
|
|
27
|
-
if (!shouldOmitEmbeddedItems || category == null) return;
|
|
28
|
-
const categories = typeof category === "string" ? [category] : category;
|
|
29
|
-
for (const possibleCategory of categories) if (!isItemCategoryWithEmbeddedItems(possibleCategory)) throw new Error(`shouldOmitEmbeddedItems can only be used when the item category contains embedded items; received category "${possibleCategory}"`);
|
|
30
|
-
}
|
|
31
26
|
function buildOmitEmbeddedItemsXQuery(uuid, category) {
|
|
32
27
|
const collectionCategories = [];
|
|
33
28
|
const categories = category == null ? [
|
|
@@ -106,25 +101,39 @@ async function fetchItem(uuid, options) {
|
|
|
106
101
|
const parsedUuid = v.parse(uuidSchema, uuid);
|
|
107
102
|
assertItemCategoryAllowed(options?.category, options?.containedItemCategory);
|
|
108
103
|
const shouldOmitEmbeddedItems = options?.shouldOmitEmbeddedItems === true;
|
|
109
|
-
|
|
104
|
+
let shouldFetchOmittedEmbeddedItems = shouldOmitEmbeddedItems;
|
|
110
105
|
let omitEmbeddedItemsCategory;
|
|
111
|
-
if (options?.category != null) if (typeof options.category === "string")
|
|
112
|
-
|
|
113
|
-
|
|
106
|
+
if (options?.category != null) if (typeof options.category === "string") if (isItemCategoryWithEmbeddedItems(options.category)) omitEmbeddedItemsCategory = options.category;
|
|
107
|
+
else shouldFetchOmittedEmbeddedItems = false;
|
|
108
|
+
else {
|
|
114
109
|
const categories = [];
|
|
115
110
|
for (const possibleCategory of options.category) if (isItemCategoryWithEmbeddedItems(possibleCategory)) categories.push(possibleCategory);
|
|
116
111
|
omitEmbeddedItemsCategory = categories;
|
|
112
|
+
shouldFetchOmittedEmbeddedItems = categories.length > 0;
|
|
117
113
|
}
|
|
118
114
|
const languages = options?.languages == null ? [] : parseLanguages(options.languages);
|
|
119
115
|
const fetcher = options?.fetch ?? fetch;
|
|
120
|
-
const
|
|
116
|
+
const regularItemUrl = `https://ochre.lib.uchicago.edu/ochre/v2/ochre.php?uuid=${parsedUuid}&xsl=none&lang="*"`;
|
|
117
|
+
let response = shouldFetchOmittedEmbeddedItems ? await fetcher("https://ochre.lib.uchicago.edu/ochre/v2/ochre.php?xquery&xsl=none&lang=\"*\"", {
|
|
121
118
|
method: "POST",
|
|
122
119
|
body: buildOmitEmbeddedItemsXQuery(parsedUuid, omitEmbeddedItemsCategory),
|
|
123
120
|
headers: { "Content-Type": "application/xquery" }
|
|
124
|
-
}) : await fetcher(
|
|
121
|
+
}) : await fetcher(regularItemUrl);
|
|
125
122
|
if (!response.ok) throw new Error("Failed to fetch OCHRE data", { cause: response.statusText });
|
|
126
123
|
const dataRaw = await response.text();
|
|
127
|
-
const
|
|
124
|
+
const parser = new XMLParser(XML_PARSER_OPTIONS);
|
|
125
|
+
let data = parser.parse(dataRaw);
|
|
126
|
+
if (shouldFetchOmittedEmbeddedItems && typeof data === "object" && data != null && "result" in data) {
|
|
127
|
+
const result = data.result;
|
|
128
|
+
if (typeof result === "object" && result != null && "ochre" in result) {
|
|
129
|
+
const ochre = result.ochre;
|
|
130
|
+
if (typeof ochre === "object" && ochre != null && (Object.keys(ochre).length === 0 || "payload" in ochre && ochre.payload === "" && Object.keys(ochre).length === 1)) {
|
|
131
|
+
response = await fetcher(regularItemUrl);
|
|
132
|
+
if (!response.ok) throw new Error("Failed to fetch OCHRE data", { cause: response.statusText });
|
|
133
|
+
data = parser.parse(await response.text());
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
128
137
|
const { success, issues, output } = v.safeParse(XMLData, data);
|
|
129
138
|
if (!success) throw createSchemaValidationError("Failed to parse OCHRE data", issues);
|
|
130
139
|
restoreXMLMetadata(output, data);
|
|
@@ -135,7 +144,6 @@ async function fetchItem(uuid, options) {
|
|
|
135
144
|
parseResourceView: (view, context) => parseWebpageView(view, { languages: context.metadata.languages }, context)
|
|
136
145
|
});
|
|
137
146
|
assertItemCategoryAllowed(parsedItem.category, options?.containedItemCategory);
|
|
138
|
-
assertShouldOmitEmbeddedItemsAllowed(parsedItem.category, shouldOmitEmbeddedItems);
|
|
139
147
|
return {
|
|
140
148
|
item: shouldOmitEmbeddedItems && isItemWithEmbeddedItems(parsedItem) ? omitEmbeddedItems(parsedItem) : parsedItem,
|
|
141
149
|
error: null,
|
|
@@ -143,6 +143,7 @@ function buildExactStringPropertyPredicate(query) {
|
|
|
143
143
|
const propertyPredicates = [];
|
|
144
144
|
const value = stringLiteral(query.value);
|
|
145
145
|
if (query.propertyVariable != null) propertyPredicates.push(`label/@uuid = ${stringLiteral(query.propertyVariable)}`);
|
|
146
|
+
if (query.propertyRelation != null) propertyPredicates.push(`label/@relation = ${stringLiteral(query.propertyRelation)}`);
|
|
146
147
|
propertyPredicates.push(`value[
|
|
147
148
|
not(@inherited = "true")
|
|
148
149
|
and (
|
|
@@ -68,19 +68,25 @@ const propertyValueLabelContentSchema = v.object({
|
|
|
68
68
|
lang: v.string(),
|
|
69
69
|
string: v.array(propertyValueLabelStringSchema)
|
|
70
70
|
});
|
|
71
|
-
function
|
|
72
|
-
const
|
|
71
|
+
function getPropertyFacetSelectorsFromQueries(queries) {
|
|
72
|
+
const propertyFacetSelectors = /* @__PURE__ */ new Map();
|
|
73
73
|
if (queries == null) return [];
|
|
74
74
|
const pendingQueries = [queries];
|
|
75
75
|
for (const query of pendingQueries) {
|
|
76
76
|
if ("target" in query) {
|
|
77
77
|
if (query.target !== "property") continue;
|
|
78
|
-
if (query.propertyVariable != null)
|
|
78
|
+
if (query.propertyVariable != null) {
|
|
79
|
+
const relation = query.propertyRelation ?? null;
|
|
80
|
+
propertyFacetSelectors.set(`${query.propertyVariable}|${relation}`, {
|
|
81
|
+
uuid: query.propertyVariable,
|
|
82
|
+
relation
|
|
83
|
+
});
|
|
84
|
+
}
|
|
79
85
|
continue;
|
|
80
86
|
}
|
|
81
87
|
pendingQueries.push(..."and" in query ? query.and : query.or);
|
|
82
88
|
}
|
|
83
|
-
return [...
|
|
89
|
+
return [...propertyFacetSelectors.values()];
|
|
84
90
|
}
|
|
85
91
|
function getItemFilterQueriesFromPropertyValueQueries(queries) {
|
|
86
92
|
if (queries == null) return null;
|
|
@@ -171,7 +177,7 @@ const responseSchema = v.object({ result: v.object({ ochre: v.object({
|
|
|
171
177
|
* @param params.setScopeUuids - An array of set scope UUIDs to filter by
|
|
172
178
|
* @param params.belongsToCollectionScopeUuids - An array of collection scope UUIDs to filter by
|
|
173
179
|
* @param params.queries - Recursive query tree used to filter matching items
|
|
174
|
-
* @param params.
|
|
180
|
+
* @param params.propertyFacetSelectors - Property variable/relation selectors to aggregate, if any
|
|
175
181
|
* @param params.attributes - Whether to return values for bibliographies and periods
|
|
176
182
|
* @param params.attributes.bibliographies - Whether to return values for bibliographies
|
|
177
183
|
* @param params.attributes.periods - Whether to return values for periods
|
|
@@ -179,7 +185,7 @@ const responseSchema = v.object({ result: v.object({ ochre: v.object({
|
|
|
179
185
|
* @returns An XQuery string
|
|
180
186
|
*/
|
|
181
187
|
function buildXQuery(params) {
|
|
182
|
-
const { setScopeUuids, belongsToCollectionScopeUuids, queries,
|
|
188
|
+
const { setScopeUuids, belongsToCollectionScopeUuids, queries, propertyFacetSelectors, attributes, isLimitedToLeafPropertyValues } = params;
|
|
183
189
|
const setScopeDeclaration = `declare variable $setScopeUuids := (${setScopeUuids.map((uuid) => stringLiteral(uuid)).join(", ")});`;
|
|
184
190
|
const baseItemsExpression = "doc()/ochre/set[@uuid = $setScopeUuids]/items/*";
|
|
185
191
|
const compiledQueryPlan = buildQueryPlan({ queries: getItemFilterQueriesFromPropertyValueQueries(queries) });
|
|
@@ -306,9 +312,13 @@ declare function local:add-attribute-facet($counts, $seen, $key) {
|
|
|
306
312
|
};`
|
|
307
313
|
];
|
|
308
314
|
if (compiledQueryPlan.prolog !== "") xqueryDeclarations.push(compiledQueryPlan.prolog);
|
|
309
|
-
if (
|
|
310
|
-
const
|
|
311
|
-
|
|
315
|
+
if (propertyFacetSelectors.length > 0) {
|
|
316
|
+
const facetPropertyPredicates = [];
|
|
317
|
+
for (const selector of propertyFacetSelectors) {
|
|
318
|
+
const uuidPredicate = `label/@uuid = ${stringLiteral(selector.uuid)}`;
|
|
319
|
+
facetPropertyPredicates.push(selector.relation == null ? uuidPredicate : `(${uuidPredicate} and label/@relation = ${stringLiteral(selector.relation)})`);
|
|
320
|
+
}
|
|
321
|
+
const facetPropertyPredicate = facetPropertyPredicates.length === 1 ? facetPropertyPredicates[0] ?? "false()" : `(${facetPropertyPredicates.join(" or ")})`;
|
|
312
322
|
queryBlocks.push(`let $global-property-counts := map:map()
|
|
313
323
|
let $variable-property-counts := map:map()
|
|
314
324
|
let $variable-property-details := map:map()
|
|
@@ -318,7 +328,7 @@ let $_property-aggregation := xdmp:eager(
|
|
|
318
328
|
let $global-seen := map:map()
|
|
319
329
|
let $variable-seen := map:map()
|
|
320
330
|
return
|
|
321
|
-
for $p in $item/properties/property[
|
|
331
|
+
for $p in $item/properties/property[${facetPropertyPredicate}]
|
|
322
332
|
let $variable-uuid := string($p/label/@uuid)
|
|
323
333
|
for $v in $p/value${valueFilter}
|
|
324
334
|
let $value-uuid := string($v/@uuid)
|
|
@@ -420,8 +430,8 @@ return (${returnedSequences.join(", ")})
|
|
|
420
430
|
async function fetchSetPropertyValues(params, options) {
|
|
421
431
|
try {
|
|
422
432
|
const { setScopeUuids, belongsToCollectionScopeUuids, queries, attributes, isLimitedToLeafPropertyValues } = v.parse(setPropertyValuesParamsSchema, params);
|
|
423
|
-
const
|
|
424
|
-
if (
|
|
433
|
+
const propertyFacetSelectors = getPropertyFacetSelectorsFromQueries(queries);
|
|
434
|
+
if (propertyFacetSelectors.length === 0 && !attributes.bibliographies && !attributes.periods) return {
|
|
425
435
|
propertyValues: [],
|
|
426
436
|
propertyValuesByPropertyVariableUuid: {},
|
|
427
437
|
attributeValues: {
|
|
@@ -435,7 +445,7 @@ async function fetchSetPropertyValues(params, options) {
|
|
|
435
445
|
setScopeUuids,
|
|
436
446
|
belongsToCollectionScopeUuids,
|
|
437
447
|
queries,
|
|
438
|
-
|
|
448
|
+
propertyFacetSelectors,
|
|
439
449
|
attributes,
|
|
440
450
|
isLimitedToLeafPropertyValues
|
|
441
451
|
});
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MultilingualOptions, MultilingualString, MultilingualStringEntries, MultilingualStringEntry, MultilingualStringInput, MultilingualStringJSON, MultilingualStringObject, MultilingualStringText } from "./parsers/multilingual.mjs";
|
|
2
2
|
import { AccordionWebBlock, ContextTree, ContextTreeFilterLevel, ContextTreeLevel, ContextTreeLevelItem, Scope, Style, StylesheetCategory, StylesheetItem, WebAccordionItem, WebBlock, WebBlockByLayout, WebBlockItem, WebBlockLayout, WebElement, WebElementComponent, WebElementComponentName, WebElementComponentOf, WebElementOf, WebImage, WebTitle, Webpage, Website, WebsiteMetadata, 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, Period, PeriodItemLink, Person, PersonItemLink, Property, PropertyLike, 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, SetTree, SimplifiedProperty, SpatialUnit, SpatialUnitItemLink, Text, TextItemLink, TopLevelItem, Tree, TreeItemCategory, TreeItemLink } from "./types/index.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, 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, SetTree, SimplifiedProperty, SpatialUnit, SpatialUnitItemLink, Text, TextItemLink, TopLevelItem, Tree, TreeItemCategory, TreeItemLink } from "./types/index.mjs";
|
|
4
4
|
import { fetchGallery } from "./fetchers/gallery.mjs";
|
|
5
5
|
import { fetchItemLinks } from "./fetchers/item-links.mjs";
|
|
6
6
|
import { defineLanguages, fetchItem, withLanguages } from "./fetchers/item.mjs";
|
|
@@ -10,4 +10,4 @@ import { fetchWebsiteMetadata } from "./fetchers/website-metadata.mjs";
|
|
|
10
10
|
import { fetchWebsite } from "./fetchers/website.mjs";
|
|
11
11
|
import { PropertyOptions, filterProperties, getLeafPropertyValues, getPropertyByVariableLabel, getPropertyByVariableLabelAndValue, getPropertyByVariableLabelAndValueContent, getPropertyByVariableLabelAndValueContents, getPropertyByVariableLabelAndValues, getPropertyByVariableUuid, getPropertyValueByVariableLabel, getPropertyValueByVariableUuid, getPropertyValueContentByVariableLabel, getPropertyValueContentByVariableUuid, getPropertyValueContentsByVariableUuid, getPropertyValuesByVariableLabel, getPropertyValuesByVariableUuid, getUniqueProperties, getUniquePropertyVariableLabels } from "./getters.mjs";
|
|
12
12
|
import { DEFAULT_PAGE_SIZE, flattenItemProperties } from "./helpers.mjs";
|
|
13
|
-
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 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, type Observation, type Period, type PeriodItemLink, type Person, type PersonItemLink, type Property, type PropertyLike, PropertyOptions, type PropertyValue, type PropertyValueContent, type PropertyValueDataType, type PropertyValueItemLink, type PropertyValueQueryItem, type PropertyVariable, type PropertyVariableItemLink, type Query, type QueryGroup, type QueryLeaf, type QueryablePropertyValueDataType, type RecursiveItemCategory, type Resource, type ResourceItemLink, 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 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 WebImage, type WebTitle, type Webpage, type Website, type WebsiteMetadata, type WebsitePropertyQuery, type WebsitePropertyQueryNode, type WebsiteSegment, type WebsiteType, defineLanguages, fetchGallery, fetchItem, fetchItemLinks, fetchSetItems, fetchSetPropertyValues, fetchWebsite, fetchWebsiteMetadata, filterProperties, flattenItemProperties, getLeafPropertyValues, getPropertyByVariableLabel, getPropertyByVariableLabelAndValue, getPropertyByVariableLabelAndValueContent, getPropertyByVariableLabelAndValueContents, getPropertyByVariableLabelAndValues, getPropertyByVariableUuid, getPropertyValueByVariableLabel, getPropertyValueByVariableUuid, getPropertyValueContentByVariableLabel, getPropertyValueContentByVariableUuid, getPropertyValueContentsByVariableUuid, getPropertyValuesByVariableLabel, getPropertyValuesByVariableUuid, getUniqueProperties, getUniquePropertyVariableLabels, withLanguages };
|
|
13
|
+
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 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, type Observation, type Period, type PeriodItemLink, type Person, type PersonItemLink, type Property, type PropertyLike, PropertyOptions, type PropertyRelation, type PropertyValue, type PropertyValueContent, type PropertyValueDataType, type PropertyValueItemLink, type PropertyValueQueryItem, type PropertyVariable, type PropertyVariableItemLink, type Query, type QueryGroup, type QueryLeaf, type QueryablePropertyValueDataType, type RecursiveItemCategory, type Resource, type ResourceItemLink, 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 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 WebImage, type WebTitle, type Webpage, type Website, type WebsiteMetadata, type WebsitePropertyQuery, type WebsitePropertyQueryNode, type WebsiteSegment, type WebsiteType, defineLanguages, fetchGallery, fetchItem, fetchItemLinks, fetchSetItems, fetchSetPropertyValues, fetchWebsite, fetchWebsiteMetadata, filterProperties, flattenItemProperties, getLeafPropertyValues, getPropertyByVariableLabel, getPropertyByVariableLabelAndValue, getPropertyByVariableLabelAndValueContent, getPropertyByVariableLabelAndValueContents, getPropertyByVariableLabelAndValues, getPropertyByVariableUuid, getPropertyValueByVariableLabel, getPropertyValueByVariableUuid, getPropertyValueContentByVariableLabel, getPropertyValueContentByVariableUuid, getPropertyValueContentsByVariableUuid, getPropertyValuesByVariableLabel, getPropertyValuesByVariableUuid, getUniqueProperties, getUniquePropertyVariableLabels, withLanguages };
|
package/dist/parsers/index.mjs
CHANGED
|
@@ -522,7 +522,8 @@ function parseProperty(rawProperty, options) {
|
|
|
522
522
|
variable: {
|
|
523
523
|
uuid: rawProperty.label.uuid,
|
|
524
524
|
label: parseRequiredContentLike(rawProperty.label, options),
|
|
525
|
-
publicationDateTime: rawProperty.label.publicationDateTime ?? null
|
|
525
|
+
publicationDateTime: rawProperty.label.publicationDateTime ?? null,
|
|
526
|
+
relation: rawProperty.label.relation ?? null
|
|
526
527
|
},
|
|
527
528
|
values,
|
|
528
529
|
comment: parseContentLike(rawProperty.comment, options),
|
|
@@ -543,7 +544,8 @@ function parseSimplifiedProperty(rawProperty, options) {
|
|
|
543
544
|
variable: {
|
|
544
545
|
uuid: rawProperty.label.uuid,
|
|
545
546
|
label: parseContentLikeText(rawProperty.label, options),
|
|
546
|
-
publicationDateTime: rawProperty.label.publicationDateTime ?? null
|
|
547
|
+
publicationDateTime: rawProperty.label.publicationDateTime ?? null,
|
|
548
|
+
relation: rawProperty.label.relation ?? null
|
|
547
549
|
},
|
|
548
550
|
values,
|
|
549
551
|
comment: parseContentLike(rawProperty.comment, options),
|
package/dist/query.mjs
CHANGED
|
@@ -320,13 +320,18 @@ function buildContentTargetQueryExpression(params) {
|
|
|
320
320
|
}));
|
|
321
321
|
}
|
|
322
322
|
function buildPropertyQueryExpression(params) {
|
|
323
|
-
const { propertyVariable, queryExpression } = params;
|
|
323
|
+
const { propertyVariable, propertyRelation, queryExpression } = params;
|
|
324
324
|
const propertyQueryExpressions = [queryExpression];
|
|
325
325
|
if (propertyVariable != null) propertyQueryExpressions.unshift(buildPropertyLabelQuery(propertyVariable));
|
|
326
|
+
if (propertyRelation != null) propertyQueryExpressions.unshift(buildPlainElementAttributeValueQueryExpression({
|
|
327
|
+
elementName: "label",
|
|
328
|
+
attributeName: "relation",
|
|
329
|
+
value: propertyRelation
|
|
330
|
+
}));
|
|
326
331
|
return buildNestedElementQuery(["properties", "property"], buildAndCtsQueryExpressionInternal(propertyQueryExpressions));
|
|
327
332
|
}
|
|
328
333
|
function buildPropertyTextMatchQueryExpression(params) {
|
|
329
|
-
const { propertyVariable, valueFilters = [], contentQueryExpression, rawValueQueryExpression, bareValueQueryExpression } = params;
|
|
334
|
+
const { propertyVariable, propertyRelation, valueFilters = [], contentQueryExpression, rawValueQueryExpression, bareValueQueryExpression } = params;
|
|
330
335
|
const letBindings = [];
|
|
331
336
|
const valueMatchReferences = [];
|
|
332
337
|
if (contentQueryExpression != null) {
|
|
@@ -345,6 +350,11 @@ function buildPropertyTextMatchQueryExpression(params) {
|
|
|
345
350
|
if (valueMatchReferences.length > 0) valueQueryExpressions.push(buildOrCtsQueryExpressionInternal(valueMatchReferences));
|
|
346
351
|
const propertyQueryExpressions = [];
|
|
347
352
|
if (propertyVariable != null) propertyQueryExpressions.push(buildPropertyLabelQuery(propertyVariable));
|
|
353
|
+
if (propertyRelation != null) propertyQueryExpressions.push(buildPlainElementAttributeValueQueryExpression({
|
|
354
|
+
elementName: "label",
|
|
355
|
+
attributeName: "relation",
|
|
356
|
+
value: propertyRelation
|
|
357
|
+
}));
|
|
348
358
|
propertyQueryExpressions.push(buildNestedElementQuery(["value"], buildAndCtsQueryExpressionInternal(valueQueryExpressions)));
|
|
349
359
|
const propertyQueryExpression = buildNestedElementQuery(["properties", "property"], buildAndCtsQueryExpressionInternal(propertyQueryExpressions));
|
|
350
360
|
if (letBindings.length === 0) return propertyQueryExpression;
|
|
@@ -353,13 +363,15 @@ function buildPropertyTextMatchQueryExpression(params) {
|
|
|
353
363
|
function buildPropertyPresenceQueryExpression(params) {
|
|
354
364
|
return buildPropertyQueryExpression({
|
|
355
365
|
propertyVariable: params.propertyVariable,
|
|
366
|
+
propertyRelation: params.propertyRelation,
|
|
356
367
|
queryExpression: "cts:true-query()"
|
|
357
368
|
});
|
|
358
369
|
}
|
|
359
370
|
function buildPropertyStringQueryExpression(params) {
|
|
360
|
-
const { propertyVariable, value, matchMode, isCaseSensitive, language } = params;
|
|
371
|
+
const { propertyVariable, propertyRelation, value, matchMode, isCaseSensitive, language } = params;
|
|
361
372
|
return buildPropertyTextMatchQueryExpression({
|
|
362
373
|
propertyVariable,
|
|
374
|
+
propertyRelation,
|
|
363
375
|
valueFilters: [buildValueNotInheritedQuery()],
|
|
364
376
|
contentQueryExpression: buildValueContentInnerQuery({
|
|
365
377
|
language,
|
|
@@ -380,9 +392,10 @@ function buildPropertyStringQueryExpression(params) {
|
|
|
380
392
|
});
|
|
381
393
|
}
|
|
382
394
|
function buildPropertyScalarQueryExpression(params) {
|
|
383
|
-
const { propertyVariable, value, matchMode, isCaseSensitive } = params;
|
|
395
|
+
const { propertyVariable, propertyRelation, value, matchMode, isCaseSensitive } = params;
|
|
384
396
|
return buildPropertyQueryExpression({
|
|
385
397
|
propertyVariable,
|
|
398
|
+
propertyRelation,
|
|
386
399
|
queryExpression: buildNestedElementQuery(["value"], buildOrCtsQueryExpressionInternal([buildValueRawValueInnerQuery({
|
|
387
400
|
value,
|
|
388
401
|
matchMode,
|
|
@@ -398,6 +411,7 @@ function buildPropertyAllQueryExpression(params) {
|
|
|
398
411
|
const { query, value, matchMode } = params;
|
|
399
412
|
return buildPropertyTextMatchQueryExpression({
|
|
400
413
|
propertyVariable: query.propertyVariable,
|
|
414
|
+
propertyRelation: query.propertyRelation,
|
|
401
415
|
valueFilters: [buildValueNotIdRefQuery()],
|
|
402
416
|
contentQueryExpression: buildValueContentInnerQuery({
|
|
403
417
|
language: query.language,
|
|
@@ -418,9 +432,10 @@ function buildPropertyAllQueryExpression(params) {
|
|
|
418
432
|
});
|
|
419
433
|
}
|
|
420
434
|
function buildPropertyIdRefQueryExpression(params) {
|
|
421
|
-
const { propertyVariable, value } = params;
|
|
435
|
+
const { propertyVariable, propertyRelation, value } = params;
|
|
422
436
|
return buildPropertyQueryExpression({
|
|
423
437
|
propertyVariable,
|
|
438
|
+
propertyRelation,
|
|
424
439
|
queryExpression: buildNestedElementQuery(["value"], buildPlainElementAttributeValueQueryExpression({
|
|
425
440
|
elementName: "value",
|
|
426
441
|
attributeName: "uuid",
|
|
@@ -434,6 +449,7 @@ function buildPropertyDateRangeQueryExpression(query) {
|
|
|
434
449
|
if (query.to != null) rangeQueryExpressions.push(`cts:element-attribute-range-query(xs:QName("value"), xs:QName("rawValue"), "<=", ${stringLiteral(query.to)})`);
|
|
435
450
|
return buildPropertyQueryExpression({
|
|
436
451
|
propertyVariable: query.propertyVariable,
|
|
452
|
+
propertyRelation: query.propertyRelation,
|
|
437
453
|
queryExpression: buildNestedElementQuery(["value"], buildAndCtsQueryExpressionInternal(rangeQueryExpressions))
|
|
438
454
|
});
|
|
439
455
|
}
|
|
@@ -498,10 +514,12 @@ function buildLeafValueQueryExpression(params) {
|
|
|
498
514
|
});
|
|
499
515
|
case "IDREF": return buildPropertyIdRefQueryExpression({
|
|
500
516
|
propertyVariable: query.propertyVariable,
|
|
517
|
+
propertyRelation: query.propertyRelation,
|
|
501
518
|
value
|
|
502
519
|
});
|
|
503
520
|
case "string": return buildPropertyStringQueryExpression({
|
|
504
521
|
propertyVariable: query.propertyVariable,
|
|
522
|
+
propertyRelation: query.propertyRelation,
|
|
505
523
|
value,
|
|
506
524
|
matchMode,
|
|
507
525
|
isCaseSensitive: query.isCaseSensitive,
|
|
@@ -514,6 +532,7 @@ function buildLeafValueQueryExpression(params) {
|
|
|
514
532
|
case "date":
|
|
515
533
|
case "dateTime": return buildPropertyScalarQueryExpression({
|
|
516
534
|
propertyVariable: query.propertyVariable,
|
|
535
|
+
propertyRelation: query.propertyRelation,
|
|
517
536
|
value,
|
|
518
537
|
matchMode,
|
|
519
538
|
isCaseSensitive: query.isCaseSensitive
|
|
@@ -590,6 +609,7 @@ function getLeafHelperKey(params) {
|
|
|
590
609
|
query.target,
|
|
591
610
|
query.dataType,
|
|
592
611
|
query.propertyVariable ?? "",
|
|
612
|
+
query.propertyRelation ?? "",
|
|
593
613
|
value,
|
|
594
614
|
query.isCaseSensitive ? "case-sensitive" : "case-insensitive",
|
|
595
615
|
query.language
|
|
@@ -636,6 +656,7 @@ function getIncludesLeafHelperKey(params) {
|
|
|
636
656
|
query.target,
|
|
637
657
|
query.dataType,
|
|
638
658
|
query.propertyVariable ?? "",
|
|
659
|
+
query.propertyRelation ?? "",
|
|
639
660
|
query.isCaseSensitive ? "case-sensitive" : "case-insensitive",
|
|
640
661
|
query.language,
|
|
641
662
|
isWildcarded ? "wildcarded" : "unwildcarded",
|
|
@@ -659,7 +680,10 @@ function registerIncludesLeafHelper(params) {
|
|
|
659
680
|
});
|
|
660
681
|
}
|
|
661
682
|
function buildLeafQueryExpression(context, query) {
|
|
662
|
-
if (query.target === "property" && query.dataType !== "date" && query.dataType !== "dateTime" && !("value" in query) && query.propertyVariable != null) return buildPropertyPresenceQueryExpression({
|
|
683
|
+
if (query.target === "property" && query.dataType !== "date" && query.dataType !== "dateTime" && !("value" in query) && (query.propertyVariable != null || query.propertyRelation != null)) return buildPropertyPresenceQueryExpression({
|
|
684
|
+
propertyVariable: query.propertyVariable,
|
|
685
|
+
propertyRelation: query.propertyRelation
|
|
686
|
+
});
|
|
663
687
|
if (query.target === "property" && (query.dataType === "date" || query.dataType === "dateTime") && query.value == null) return buildPropertyDateRangeQueryExpression(query);
|
|
664
688
|
const searchValue = getLeafSearchValue(query);
|
|
665
689
|
if (searchValue == null) throw new Error("Missing searchable value for query leaf", { cause: query });
|
package/dist/schemas.mjs
CHANGED
|
@@ -77,6 +77,7 @@ const standardQueryFields = {
|
|
|
77
77
|
language: defaultString("eng"),
|
|
78
78
|
isNegated: defaultBoolean(false)
|
|
79
79
|
};
|
|
80
|
+
const propertyRelationSchema = v.picklist(["related", "inverse"]);
|
|
80
81
|
/**
|
|
81
82
|
* Shared schema for Set queries
|
|
82
83
|
* @internal
|
|
@@ -85,6 +86,7 @@ const setQueryLeafSchema = v.union([
|
|
|
85
86
|
v.pipe(v.strictObject({
|
|
86
87
|
target: v.literal("property"),
|
|
87
88
|
propertyVariable: v.optional(uuidSchema),
|
|
89
|
+
propertyRelation: v.optional(propertyRelationSchema),
|
|
88
90
|
dataType: v.picklist([
|
|
89
91
|
"string",
|
|
90
92
|
"integer",
|
|
@@ -95,10 +97,11 @@ const setQueryLeafSchema = v.union([
|
|
|
95
97
|
]),
|
|
96
98
|
value: v.optional(v.string()),
|
|
97
99
|
...standardQueryFields
|
|
98
|
-
}), v.check((value) => value.propertyVariable != null || value.value != null, "Property queries must include at least one propertyVariable or value")),
|
|
100
|
+
}), v.check((value) => value.propertyVariable != null || value.propertyRelation != null || value.value != null, "Property queries must include at least one propertyVariable, propertyRelation, or value")),
|
|
99
101
|
v.strictObject({
|
|
100
102
|
target: v.literal("property"),
|
|
101
103
|
propertyVariable: uuidSchema,
|
|
104
|
+
propertyRelation: v.optional(propertyRelationSchema),
|
|
102
105
|
dataType: dateDataTypeSchema,
|
|
103
106
|
value: v.string(),
|
|
104
107
|
from: v.optional(v.never()),
|
|
@@ -108,6 +111,7 @@ const setQueryLeafSchema = v.union([
|
|
|
108
111
|
v.strictObject({
|
|
109
112
|
target: v.literal("property"),
|
|
110
113
|
propertyVariable: uuidSchema,
|
|
114
|
+
propertyRelation: v.optional(propertyRelationSchema),
|
|
111
115
|
dataType: dateDataTypeSchema,
|
|
112
116
|
value: v.optional(v.never()),
|
|
113
117
|
from: v.string(),
|
|
@@ -117,6 +121,7 @@ const setQueryLeafSchema = v.union([
|
|
|
117
121
|
v.strictObject({
|
|
118
122
|
target: v.literal("property"),
|
|
119
123
|
propertyVariable: uuidSchema,
|
|
124
|
+
propertyRelation: v.optional(propertyRelationSchema),
|
|
120
125
|
dataType: dateDataTypeSchema,
|
|
121
126
|
value: v.optional(v.never()),
|
|
122
127
|
from: v.optional(v.string()),
|
|
@@ -126,6 +131,7 @@ const setQueryLeafSchema = v.union([
|
|
|
126
131
|
v.strictObject({
|
|
127
132
|
target: v.literal("property"),
|
|
128
133
|
propertyVariable: v.optional(uuidSchema),
|
|
134
|
+
propertyRelation: v.optional(propertyRelationSchema),
|
|
129
135
|
dataType: v.literal("all"),
|
|
130
136
|
value: v.string(),
|
|
131
137
|
...standardQueryFields
|
package/dist/types/index.d.mts
CHANGED
|
@@ -296,6 +296,7 @@ type Property<T extends LanguageCodes = LanguageCodes> = {
|
|
|
296
296
|
uuid: string;
|
|
297
297
|
label: MultilingualString<T>;
|
|
298
298
|
publicationDateTime: Date | null;
|
|
299
|
+
relation: PropertyRelation | null;
|
|
299
300
|
};
|
|
300
301
|
values: Array<PropertyValueContent<T>>;
|
|
301
302
|
comment: MultilingualString<T> | null;
|
|
@@ -310,6 +311,7 @@ type SimplifiedProperty<T extends LanguageCodes = LanguageCodes> = {
|
|
|
310
311
|
uuid: string;
|
|
311
312
|
label: string;
|
|
312
313
|
publicationDateTime: Date | null;
|
|
314
|
+
relation: PropertyRelation | null;
|
|
313
315
|
};
|
|
314
316
|
values: Array<PropertyValueContent<T>>;
|
|
315
317
|
comment: MultilingualString<T> | null;
|
|
@@ -324,6 +326,7 @@ type PropertyLike<T extends LanguageCodes = LanguageCodes> = Property<T> | SetIt
|
|
|
324
326
|
type ItemProperty<T extends LanguageCodes = LanguageCodes> = Property<T> | SetItemProperty<T>;
|
|
325
327
|
type PropertyValueDataType = PropertyValueContent["dataType"];
|
|
326
328
|
type QueryablePropertyValueDataType = Exclude<PropertyValueDataType, "coordinate">;
|
|
329
|
+
type PropertyRelation = "related" | "inverse";
|
|
327
330
|
type WithSetItemProperties<U extends {
|
|
328
331
|
properties: Array<Property<T>>;
|
|
329
332
|
}, T extends LanguageCodes> = U extends {
|
|
@@ -765,6 +768,7 @@ type SetItemsSort = {
|
|
|
765
768
|
type QueryLeaf = {
|
|
766
769
|
target: "property";
|
|
767
770
|
propertyVariable?: string;
|
|
771
|
+
propertyRelation?: PropertyRelation;
|
|
768
772
|
dataType: Exclude<QueryablePropertyValueDataType, "date" | "dateTime">;
|
|
769
773
|
value?: string;
|
|
770
774
|
from?: never;
|
|
@@ -776,6 +780,7 @@ type QueryLeaf = {
|
|
|
776
780
|
} | {
|
|
777
781
|
target: "property";
|
|
778
782
|
propertyVariable: string;
|
|
783
|
+
propertyRelation?: PropertyRelation;
|
|
779
784
|
dataType: "date" | "dateTime";
|
|
780
785
|
value: string;
|
|
781
786
|
from?: never;
|
|
@@ -787,6 +792,7 @@ type QueryLeaf = {
|
|
|
787
792
|
} | {
|
|
788
793
|
target: "property";
|
|
789
794
|
propertyVariable: string;
|
|
795
|
+
propertyRelation?: PropertyRelation;
|
|
790
796
|
dataType: "date" | "dateTime";
|
|
791
797
|
value?: never;
|
|
792
798
|
from: string;
|
|
@@ -798,6 +804,7 @@ type QueryLeaf = {
|
|
|
798
804
|
} | {
|
|
799
805
|
target: "property";
|
|
800
806
|
propertyVariable: string;
|
|
807
|
+
propertyRelation?: PropertyRelation;
|
|
801
808
|
dataType: "date" | "dateTime";
|
|
802
809
|
value?: never;
|
|
803
810
|
from?: string;
|
|
@@ -809,6 +816,7 @@ type QueryLeaf = {
|
|
|
809
816
|
} | {
|
|
810
817
|
target: "property";
|
|
811
818
|
propertyVariable?: string;
|
|
819
|
+
propertyRelation?: PropertyRelation;
|
|
812
820
|
dataType: "all";
|
|
813
821
|
value: string;
|
|
814
822
|
matchMode: "includes" | "exact";
|
|
@@ -843,4 +851,4 @@ type QueryGroup = {
|
|
|
843
851
|
*/
|
|
844
852
|
type Query = QueryLeaf | QueryGroup;
|
|
845
853
|
//#endregion
|
|
846
|
-
export { 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, Period, PeriodItemLink, Person, PersonItemLink, Property, PropertyLike, 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, SetTree, SimplifiedProperty, SpatialUnit, SpatialUnitItemLink, Text, TextItemLink, TopLevelItem, Tree, TreeItemCategory, TreeItemLink };
|
|
854
|
+
export { 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, 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, SetTree, SimplifiedProperty, SpatialUnit, SpatialUnitItemLink, Text, TextItemLink, TopLevelItem, Tree, TreeItemCategory, TreeItemLink };
|
package/dist/xml/schemas.mjs
CHANGED
|
@@ -229,10 +229,12 @@ const XMLNote = v.object({
|
|
|
229
229
|
date: v.optional(customDateTime("XMLNote: date is not a valid datetime")),
|
|
230
230
|
authors: v.optional(v.object({ author: v.array(v.lazy(() => XMLPerson)) }, "XMLNote: authors is object with author array of XMLPerson"))
|
|
231
231
|
}, "XMLNote: Shape error");
|
|
232
|
+
const XMLPropertyRelation = v.picklist(["related", "inverse"]);
|
|
232
233
|
const XMLProperty = v.lazy(() => v.object({
|
|
233
234
|
label: v.intersect([v.union([XMLContent, XMLString]), v.object({
|
|
234
235
|
uuid: v.union([v.literal(""), v.pipe(v.string("XMLProperty: uuid is string and required"), v.check(isPseudoUuid, "XMLProperty: uuid is not a valid pseudo-UUID"))], "XMLProperty: uuid is string and required"),
|
|
235
|
-
publicationDateTime: v.optional(customDateTime("XMLProperty: publicationDateTime is not a valid datetime"))
|
|
236
|
+
publicationDateTime: v.optional(customDateTime("XMLProperty: publicationDateTime is not a valid datetime")),
|
|
237
|
+
relation: v.optional(XMLPropertyRelation)
|
|
236
238
|
}, "XMLProperty: label is object with uuid")]),
|
|
237
239
|
value: v.optional(v.array(v.object({
|
|
238
240
|
...v.partial(XMLContent).entries,
|
|
@@ -259,7 +261,8 @@ const XMLProperty = v.lazy(() => v.object({
|
|
|
259
261
|
const XMLSimplifiedProperty = v.lazy(() => v.object({
|
|
260
262
|
label: v.intersect([v.union([XMLContent, XMLString]), v.object({
|
|
261
263
|
uuid: v.union([v.literal(""), v.pipe(v.string("XMLSimplifiedProperty: uuid is string and required"), v.check(isPseudoUuid, "XMLSimplifiedProperty: uuid is not a valid pseudo-UUID"))], "XMLSimplifiedProperty: uuid is string and required"),
|
|
262
|
-
publicationDateTime: v.optional(customDateTime("XMLSimplifiedProperty: publicationDateTime is not a valid datetime"))
|
|
264
|
+
publicationDateTime: v.optional(customDateTime("XMLSimplifiedProperty: publicationDateTime is not a valid datetime")),
|
|
265
|
+
relation: v.optional(XMLPropertyRelation)
|
|
263
266
|
}, "XMLSimplifiedProperty: label is object with uuid")]),
|
|
264
267
|
value: v.optional(v.array(v.object({
|
|
265
268
|
...v.partial(XMLContent).entries,
|
package/dist/xml/types.d.mts
CHANGED
|
@@ -182,10 +182,12 @@ type XMLNote = Partial<XMLContent> & XMLString & {
|
|
|
182
182
|
author: Array<XMLPerson>;
|
|
183
183
|
};
|
|
184
184
|
};
|
|
185
|
+
type XMLPropertyRelation = "related" | "inverse";
|
|
185
186
|
type XMLProperty = {
|
|
186
187
|
label: (XMLContent | XMLString) & {
|
|
187
188
|
uuid: string;
|
|
188
189
|
publicationDateTime?: Date;
|
|
190
|
+
relation?: XMLPropertyRelation;
|
|
189
191
|
};
|
|
190
192
|
value?: Array<Partial<XMLContent> & {
|
|
191
193
|
i?: XMLNumber;
|
|
@@ -212,6 +214,7 @@ type XMLSimplifiedProperty = {
|
|
|
212
214
|
label: (XMLContent | XMLString) & {
|
|
213
215
|
uuid: string;
|
|
214
216
|
publicationDateTime?: Date;
|
|
217
|
+
relation?: XMLPropertyRelation;
|
|
215
218
|
};
|
|
216
219
|
value?: Array<Partial<XMLContent> & {
|
|
217
220
|
i?: XMLNumber;
|
|
@@ -898,4 +901,4 @@ type XMLWebsiteData = {
|
|
|
898
901
|
};
|
|
899
902
|
};
|
|
900
903
|
//#endregion
|
|
901
|
-
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, XMLPeriod, XMLPerson, XMLProperty, 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 };
|
|
904
|
+
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, 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 };
|