ochre-sdk 1.1.0 → 1.1.2
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 +51 -2
- package/dist/fetchers/container-items.d.mts +52 -0
- package/dist/fetchers/container-items.mjs +171 -0
- package/dist/fetchers/set/items.mjs +9 -148
- package/dist/fetchers/set/property-values.mjs +4 -3
- package/dist/fetchers/tree/items.d.mts +53 -0
- package/dist/fetchers/tree/items.mjs +38 -0
- package/dist/getters.d.mts +11 -0
- package/dist/getters.mjs +11 -1
- package/dist/index.d.mts +5 -4
- package/dist/index.mjs +3 -2
- package/dist/parsers/multilingual.d.mts +101 -0
- package/dist/parsers/multilingual.mjs +149 -0
- package/dist/query.d.mts +42 -9
- package/dist/query.mjs +37 -18
- package/dist/schemas.d.mts +28 -4
- package/dist/schemas.mjs +14 -3
- package/dist/types/index.d.mts +39 -0
- package/dist/types/website.d.mts +6 -1
- package/dist/xml/schemas.d.mts +30 -10
- package/dist/xml/schemas.mjs +3 -2
- package/dist/xml/types.d.mts +2 -1
- package/package.json +6 -6
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
|
-
import { ContextTree, ContextTreeFilterLevel, ContextTreeFilterVariant, ContextTreeLevel, ContextTreeLevelItem, ProtectedWebsite, ResponsiveStyles, Scope, Style, StylesheetItem, WebAccordionItem, WebBlock, WebBlockByLayout, WebBlockItem, WebBlockLayout, WebElement, WebElementComponent, WebElementComponentName, WebElementComponentOf, WebElementOf, WebIiifViewer, WebImage, WebLoadingVariant, WebOptions, WebSectionDisplay, WebSectionVariant, WebSidebar, WebTitle, Webpage, Website, WebsiteMetadata, WebsitePrivacy, WebsitePropertyQuery, WebsitePropertyQueryNode, WebsiteSegment, WebsiteType } from "./types/website.mjs";
|
|
3
|
-
import { BaseItem, BaseItemLink, BelongsTo, Bibliography, BibliographyEntryInfo, BibliographyItemLink, BibliographySourceDocument, Concept, ConceptItemLink, ContainedItemCategory, ContainedItemCategoryFromOption, ContainedItemCategoryOption, Context, ContextItem, ContextItemCategory, ContextNode, Coordinates, CoordinatesSource, DictionaryUnitItemLink, Event, Gallery, Heading, HeadingItemCategory, Identification, Image, ImageMap, ImageMapArea, Interpretation, Item, ItemCategory, ItemCategoryFromOption, ItemCategoryOption, ItemCategoryWithEmbeddedItems, ItemContainerCategory, ItemLink, ItemLinkCategory, ItemLinks, ItemPayloadKind, 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, Resource, ResourceItemLink, Section, Set, SetAttributeValueQueryItem, SetBibliography, SetConcept, SetItem, SetItemCategory, SetItemLink, SetItemProperty, SetItemSimplifiedProperty, SetItemsSort, SetItemsSortDirection, SetPeriod, SetResource, SetSpatialUnit, SetTree, SimplifiedProperty, SpatialUnit, SpatialUnitItemLink, Text, TextItemLink, Tree, TreeItemCategory, TreeItemLink } from "./types/index.mjs";
|
|
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, 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, SetItemProperty, SetItemSimplifiedProperty, SetItemsSort, SetItemsSortDirection, SetPeriod, SetResource, SetSpatialUnit, 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";
|
|
@@ -9,9 +9,10 @@ import { fetchItemOcrData } from "./fetchers/item-ocr-data.mjs";
|
|
|
9
9
|
import { fetchItem } from "./fetchers/item.mjs";
|
|
10
10
|
import { fetchSetItems } from "./fetchers/set/items.mjs";
|
|
11
11
|
import { fetchSetPropertyValues } from "./fetchers/set/property-values.mjs";
|
|
12
|
+
import { fetchTreeItems } from "./fetchers/tree/items.mjs";
|
|
12
13
|
import { fetchWebsiteMetadata } from "./fetchers/website-metadata.mjs";
|
|
13
14
|
import { fetchWebsite } from "./fetchers/website.mjs";
|
|
14
|
-
import { PropertyOptions, PropertySelector, getProperty, getPropertyValue, getPropertyValues, getUniqueProperties, getUniquePropertyVariableLabels, isPropertyMatchingFilter, normalizePropertyVariableLabel } from "./getters.mjs";
|
|
15
|
+
import { PropertyOptions, PropertySelector, getLeafPropertyValues, getProperty, getPropertyValue, getPropertyValues, getUniqueProperties, getUniquePropertyVariableLabels, isPropertyMatchingFilter, normalizePropertyVariableLabel } from "./getters.mjs";
|
|
15
16
|
import { flattenItemProperties } from "./helpers.mjs";
|
|
16
17
|
import { defineLanguages } from "./parsers/languages.mjs";
|
|
17
|
-
export { 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 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 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 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 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 SetTree, type SimplifiedProperty, type SpatialUnit, type SpatialUnitItemLink, type Style, type StylesheetItem, type Text, type TextItemLink, 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 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, fetchItemOcrData, fetchSetItems, fetchSetPropertyValues, fetchWebsite, fetchWebsiteMetadata, flattenItemProperties, getProperty, getPropertyValue, getPropertyValues, getUniqueProperties, getUniquePropertyVariableLabels, isPropertyMatchingFilter, normalizePropertyVariableLabel };
|
|
18
|
+
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, type Observation, 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 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 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, fetchItemOcrData, fetchSetItems, fetchSetPropertyValues, fetchTreeItems, fetchWebsite, fetchWebsiteMetadata, flattenItemProperties, getLeafPropertyValues, getProperty, getPropertyValue, getPropertyValues, getUniqueProperties, getUniquePropertyVariableLabels, isPropertyMatchingFilter, normalizePropertyVariableLabel };
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DEFAULT_PAGE_SIZE } from "./constants.mjs";
|
|
2
|
-
import { getProperty, getPropertyValue, getPropertyValues, getUniqueProperties, getUniquePropertyVariableLabels, isPropertyMatchingFilter, normalizePropertyVariableLabel } from "./getters.mjs";
|
|
2
|
+
import { getLeafPropertyValues, getProperty, getPropertyValue, getPropertyValues, getUniqueProperties, getUniquePropertyVariableLabels, isPropertyMatchingFilter, normalizePropertyVariableLabel } from "./getters.mjs";
|
|
3
3
|
import { flattenItemProperties } from "./helpers.mjs";
|
|
4
4
|
import { MultilingualString } from "./parsers/multilingual.mjs";
|
|
5
5
|
import { defineLanguages } from "./parsers/languages.mjs";
|
|
@@ -10,6 +10,7 @@ import { fetchItemOcrData } from "./fetchers/item-ocr-data.mjs";
|
|
|
10
10
|
import { fetchItem } from "./fetchers/item.mjs";
|
|
11
11
|
import { fetchSetItems } from "./fetchers/set/items.mjs";
|
|
12
12
|
import { fetchSetPropertyValues } from "./fetchers/set/property-values.mjs";
|
|
13
|
+
import { fetchTreeItems } from "./fetchers/tree/items.mjs";
|
|
13
14
|
import { fetchWebsiteMetadata } from "./fetchers/website-metadata.mjs";
|
|
14
15
|
import { fetchWebsite } from "./fetchers/website.mjs";
|
|
15
|
-
export { DEFAULT_PAGE_SIZE, MultilingualString, defineLanguages, fetchGallery, fetchItem, fetchItemChildren, fetchItemLinks, fetchItemOcrData, fetchSetItems, fetchSetPropertyValues, fetchWebsite, fetchWebsiteMetadata, flattenItemProperties, getProperty, getPropertyValue, getPropertyValues, getUniqueProperties, getUniquePropertyVariableLabels, isPropertyMatchingFilter, normalizePropertyVariableLabel };
|
|
16
|
+
export { DEFAULT_PAGE_SIZE, MultilingualString, defineLanguages, fetchGallery, fetchItem, fetchItemChildren, fetchItemLinks, fetchItemOcrData, fetchSetItems, fetchSetPropertyValues, fetchTreeItems, fetchWebsite, fetchWebsiteMetadata, flattenItemProperties, getLeafPropertyValues, getProperty, getPropertyValue, getPropertyValues, getUniqueProperties, getUniquePropertyVariableLabels, isPropertyMatchingFilter, normalizePropertyVariableLabel };
|
|
@@ -126,6 +126,29 @@ export declare class MultilingualString<T extends ReadonlyArray<string> = Readon
|
|
|
126
126
|
* Get every entry for a specific language, with no fallback
|
|
127
127
|
*/
|
|
128
128
|
getExactEntries(language: T[number]): Array<MultilingualStringEntry>;
|
|
129
|
+
/**
|
|
130
|
+
* Get every entry for a language, falling back when it has none
|
|
131
|
+
*
|
|
132
|
+
* The multi-entry counterpart of {@link MultilingualString.getText}: OCHRE
|
|
133
|
+
* can carry several entries for one language, and this returns all of them
|
|
134
|
+
* rather than only the primary. Each entry carries both `text` and
|
|
135
|
+
* `richText`, so a caller rendering a rich field reads them from here.
|
|
136
|
+
* @param language - The language to read, or undefined for the default
|
|
137
|
+
* @returns The entries, or an empty array when no language has any
|
|
138
|
+
*/
|
|
139
|
+
getEntries(language?: T[number]): Array<MultilingualStringEntry>;
|
|
140
|
+
/**
|
|
141
|
+
* Get the text of every entry for a language, falling back when it has none
|
|
142
|
+
* @param language - The language to read, or undefined for the default
|
|
143
|
+
* @returns The texts, or an empty array when no language has any
|
|
144
|
+
*/
|
|
145
|
+
getTexts(language?: T[number]): Array<string>;
|
|
146
|
+
/**
|
|
147
|
+
* Get the text of every entry for a language, with no fallback
|
|
148
|
+
* @param language - The language to read
|
|
149
|
+
* @returns The texts, or an empty array when that language has none
|
|
150
|
+
*/
|
|
151
|
+
getExactTexts(language: T[number]): Array<string>;
|
|
129
152
|
/**
|
|
130
153
|
* Get the alias values OCHRE carries as `zxx` content
|
|
131
154
|
*/
|
|
@@ -138,6 +161,46 @@ export declare class MultilingualString<T extends ReadonlyArray<string> = Readon
|
|
|
138
161
|
* Get the language reads fall back to before trying the rest
|
|
139
162
|
*/
|
|
140
163
|
getDefaultLanguage(): T[number];
|
|
164
|
+
/**
|
|
165
|
+
* Get every language this string was built to hold
|
|
166
|
+
*
|
|
167
|
+
* The configured language list, which is not the same question as
|
|
168
|
+
* {@link MultilingualString.getAvailableLanguages}: that one answers which
|
|
169
|
+
* languages actually carry content, and is a subset of this.
|
|
170
|
+
* @returns The supported languages
|
|
171
|
+
*/
|
|
172
|
+
getSupportedLanguages(): Array<T[number]>;
|
|
173
|
+
/**
|
|
174
|
+
* Whether any language carries an entry
|
|
175
|
+
*
|
|
176
|
+
* Answers the structural question. A language whose only entry is blank
|
|
177
|
+
* still counts here; {@link MultilingualString.hasContent} is the question
|
|
178
|
+
* about text. Aliases are not entries, so a string carrying only aliases is
|
|
179
|
+
* empty by this measure and {@link MultilingualString.hasAliases} is true.
|
|
180
|
+
* @returns True when no language carries an entry
|
|
181
|
+
*/
|
|
182
|
+
isEmpty(): boolean;
|
|
183
|
+
/**
|
|
184
|
+
* Whether any entry in any language carries text that is not whitespace
|
|
185
|
+
*
|
|
186
|
+
* Deliberately not the negation of {@link MultilingualString.isEmpty}, which
|
|
187
|
+
* only asks whether entries exist. OCHRE does serve fields holding a single
|
|
188
|
+
* whitespace entry, so a caller deciding whether to render something wants
|
|
189
|
+
* this one, and it looks at every entry rather than only the primary.
|
|
190
|
+
* @returns True when some entry has non-whitespace text
|
|
191
|
+
*/
|
|
192
|
+
hasContent(): boolean;
|
|
193
|
+
/**
|
|
194
|
+
* Whether a specific language carries an entry, with no fallback
|
|
195
|
+
* @param language - The language to test
|
|
196
|
+
* @returns True when that language carries at least one entry
|
|
197
|
+
*/
|
|
198
|
+
hasLanguage(language: T[number]): boolean;
|
|
199
|
+
/**
|
|
200
|
+
* Whether OCHRE carried any `zxx` alias values for this string
|
|
201
|
+
* @returns True when there is at least one alias
|
|
202
|
+
*/
|
|
203
|
+
hasAliases(): boolean;
|
|
141
204
|
/**
|
|
142
205
|
* Set the text for a language, or append another entry to it
|
|
143
206
|
* @param language - The language to write
|
|
@@ -158,6 +221,44 @@ export declare class MultilingualString<T extends ReadonlyArray<string> = Readon
|
|
|
158
221
|
* @returns A new multilingual string
|
|
159
222
|
*/
|
|
160
223
|
without(language: T[number]): MultilingualString<T>;
|
|
224
|
+
/**
|
|
225
|
+
* Replace the alias values
|
|
226
|
+
*
|
|
227
|
+
* Aliases are the `zxx` content OCHRE carries alongside a field's languages,
|
|
228
|
+
* so they are set as a whole rather than per language. Empty strings are
|
|
229
|
+
* dropped, matching how they are read from a payload.
|
|
230
|
+
* @param aliases - The aliases to carry
|
|
231
|
+
* @returns A new multilingual string
|
|
232
|
+
*/
|
|
233
|
+
withAliases(aliases: ReadonlyArray<string>): MultilingualString<T>;
|
|
234
|
+
/**
|
|
235
|
+
* Transform the text of every entry in every language
|
|
236
|
+
*
|
|
237
|
+
* Replaces the old `map`, which corrupted rich text: it wrote the
|
|
238
|
+
* transformed plain text and left the entry's `richText` to be re-derived,
|
|
239
|
+
* so a transform such as uppercasing turned `<InternalLink uuid="abc">` into
|
|
240
|
+
* markup OCHRE never wrote. The transform here runs against plain text only,
|
|
241
|
+
* and the entry's rich text is rebuilt from the result, so the two can never
|
|
242
|
+
* disagree.
|
|
243
|
+
*
|
|
244
|
+
* A transform that needs to keep or rewrite markup returns
|
|
245
|
+
* `{ text, richText }` instead of a string, and both are used verbatim.
|
|
246
|
+
* @param transform - Produces the new text for one entry
|
|
247
|
+
* @returns A new multilingual string
|
|
248
|
+
*/
|
|
249
|
+
mapText(transform: (text: string, language: T[number]) => MultilingualStringInput): MultilingualString<T>;
|
|
250
|
+
/**
|
|
251
|
+
* Keep only the entries a predicate accepts
|
|
252
|
+
*
|
|
253
|
+
* The callback receives the whole entry rather than just its text, so it
|
|
254
|
+
* can also test `richText` and `isPrimary`. Dropping every entry of a
|
|
255
|
+
* language removes that language, and when that was the default the default
|
|
256
|
+
* moves to the first language that still has content, so reads keep
|
|
257
|
+
* resolving.
|
|
258
|
+
* @param shouldKeep - Whether to keep one entry
|
|
259
|
+
* @returns A new multilingual string
|
|
260
|
+
*/
|
|
261
|
+
filterEntries(shouldKeep: (entry: MultilingualStringEntry, language: T[number]) => boolean): MultilingualString<T>;
|
|
161
262
|
/**
|
|
162
263
|
* Get the string representation, using the default language
|
|
163
264
|
*/
|
|
@@ -222,6 +222,35 @@ var MultilingualString = class MultilingualString {
|
|
|
222
222
|
return Array.from(this.resolveEntries(language, true), (entry) => ({ ...entry }));
|
|
223
223
|
}
|
|
224
224
|
/**
|
|
225
|
+
* Get every entry for a language, falling back when it has none
|
|
226
|
+
*
|
|
227
|
+
* The multi-entry counterpart of {@link MultilingualString.getText}: OCHRE
|
|
228
|
+
* can carry several entries for one language, and this returns all of them
|
|
229
|
+
* rather than only the primary. Each entry carries both `text` and
|
|
230
|
+
* `richText`, so a caller rendering a rich field reads them from here.
|
|
231
|
+
* @param language - The language to read, or undefined for the default
|
|
232
|
+
* @returns The entries, or an empty array when no language has any
|
|
233
|
+
*/
|
|
234
|
+
getEntries(language) {
|
|
235
|
+
return Array.from(this.resolveEntries(language, false), (entry) => ({ ...entry }));
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Get the text of every entry for a language, falling back when it has none
|
|
239
|
+
* @param language - The language to read, or undefined for the default
|
|
240
|
+
* @returns The texts, or an empty array when no language has any
|
|
241
|
+
*/
|
|
242
|
+
getTexts(language) {
|
|
243
|
+
return Array.from(this.resolveEntries(language, false), (entry) => entry.text);
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Get the text of every entry for a language, with no fallback
|
|
247
|
+
* @param language - The language to read
|
|
248
|
+
* @returns The texts, or an empty array when that language has none
|
|
249
|
+
*/
|
|
250
|
+
getExactTexts(language) {
|
|
251
|
+
return Array.from(this.resolveEntries(language, true), (entry) => entry.text);
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
225
254
|
* Get the alias values OCHRE carries as `zxx` content
|
|
226
255
|
*/
|
|
227
256
|
getAliases() {
|
|
@@ -240,6 +269,60 @@ var MultilingualString = class MultilingualString {
|
|
|
240
269
|
return this._options.defaultLanguage;
|
|
241
270
|
}
|
|
242
271
|
/**
|
|
272
|
+
* Get every language this string was built to hold
|
|
273
|
+
*
|
|
274
|
+
* The configured language list, which is not the same question as
|
|
275
|
+
* {@link MultilingualString.getAvailableLanguages}: that one answers which
|
|
276
|
+
* languages actually carry content, and is a subset of this.
|
|
277
|
+
* @returns The supported languages
|
|
278
|
+
*/
|
|
279
|
+
getSupportedLanguages() {
|
|
280
|
+
return [...this._options.availableLanguages];
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Whether any language carries an entry
|
|
284
|
+
*
|
|
285
|
+
* Answers the structural question. A language whose only entry is blank
|
|
286
|
+
* still counts here; {@link MultilingualString.hasContent} is the question
|
|
287
|
+
* about text. Aliases are not entries, so a string carrying only aliases is
|
|
288
|
+
* empty by this measure and {@link MultilingualString.hasAliases} is true.
|
|
289
|
+
* @returns True when no language carries an entry
|
|
290
|
+
*/
|
|
291
|
+
isEmpty() {
|
|
292
|
+
return this._availableLanguages.length === 0;
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Whether any entry in any language carries text that is not whitespace
|
|
296
|
+
*
|
|
297
|
+
* Deliberately not the negation of {@link MultilingualString.isEmpty}, which
|
|
298
|
+
* only asks whether entries exist. OCHRE does serve fields holding a single
|
|
299
|
+
* whitespace entry, so a caller deciding whether to render something wants
|
|
300
|
+
* this one, and it looks at every entry rather than only the primary.
|
|
301
|
+
* @returns True when some entry has non-whitespace text
|
|
302
|
+
*/
|
|
303
|
+
hasContent() {
|
|
304
|
+
for (const language of this._availableLanguages) {
|
|
305
|
+
const entries = this._content[language] ?? [];
|
|
306
|
+
for (const entry of entries) if (entry.text.trim() !== "") return true;
|
|
307
|
+
}
|
|
308
|
+
return false;
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Whether a specific language carries an entry, with no fallback
|
|
312
|
+
* @param language - The language to test
|
|
313
|
+
* @returns True when that language carries at least one entry
|
|
314
|
+
*/
|
|
315
|
+
hasLanguage(language) {
|
|
316
|
+
return (this._content[language]?.length ?? 0) > 0;
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Whether OCHRE carried any `zxx` alias values for this string
|
|
320
|
+
* @returns True when there is at least one alias
|
|
321
|
+
*/
|
|
322
|
+
hasAliases() {
|
|
323
|
+
return this._aliases.length > 0;
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
243
326
|
* Set the text for a language, or append another entry to it
|
|
244
327
|
* @param language - The language to write
|
|
245
328
|
* @param text - The text to write
|
|
@@ -274,6 +357,72 @@ var MultilingualString = class MultilingualString {
|
|
|
274
357
|
}, newAvailableLanguages);
|
|
275
358
|
}
|
|
276
359
|
/**
|
|
360
|
+
* Replace the alias values
|
|
361
|
+
*
|
|
362
|
+
* Aliases are the `zxx` content OCHRE carries alongside a field's languages,
|
|
363
|
+
* so they are set as a whole rather than per language. Empty strings are
|
|
364
|
+
* dropped, matching how they are read from a payload.
|
|
365
|
+
* @param aliases - The aliases to carry
|
|
366
|
+
* @returns A new multilingual string
|
|
367
|
+
*/
|
|
368
|
+
withAliases(aliases) {
|
|
369
|
+
return MultilingualString.fromNormalized(cloneContent(this._content), {
|
|
370
|
+
...this._options,
|
|
371
|
+
aliases: normalizeAliases(aliases)
|
|
372
|
+
}, this._availableLanguages);
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* Transform the text of every entry in every language
|
|
376
|
+
*
|
|
377
|
+
* Replaces the old `map`, which corrupted rich text: it wrote the
|
|
378
|
+
* transformed plain text and left the entry's `richText` to be re-derived,
|
|
379
|
+
* so a transform such as uppercasing turned `<InternalLink uuid="abc">` into
|
|
380
|
+
* markup OCHRE never wrote. The transform here runs against plain text only,
|
|
381
|
+
* and the entry's rich text is rebuilt from the result, so the two can never
|
|
382
|
+
* disagree.
|
|
383
|
+
*
|
|
384
|
+
* A transform that needs to keep or rewrite markup returns
|
|
385
|
+
* `{ text, richText }` instead of a string, and both are used verbatim.
|
|
386
|
+
* @param transform - Produces the new text for one entry
|
|
387
|
+
* @returns A new multilingual string
|
|
388
|
+
*/
|
|
389
|
+
mapText(transform) {
|
|
390
|
+
const newContent = {};
|
|
391
|
+
for (const language of this._availableLanguages) {
|
|
392
|
+
const currentEntries = this._content[language] ?? [];
|
|
393
|
+
newContent[language] = normalizePrimary(Array.from(currentEntries, (entry) => ({
|
|
394
|
+
...normalizeInputText(transform(entry.text, language)),
|
|
395
|
+
isPrimary: entry.isPrimary
|
|
396
|
+
})));
|
|
397
|
+
}
|
|
398
|
+
return MultilingualString.fromNormalized(newContent, this._options, this._availableLanguages);
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* Keep only the entries a predicate accepts
|
|
402
|
+
*
|
|
403
|
+
* The callback receives the whole entry rather than just its text, so it
|
|
404
|
+
* can also test `richText` and `isPrimary`. Dropping every entry of a
|
|
405
|
+
* language removes that language, and when that was the default the default
|
|
406
|
+
* moves to the first language that still has content, so reads keep
|
|
407
|
+
* resolving.
|
|
408
|
+
* @param shouldKeep - Whether to keep one entry
|
|
409
|
+
* @returns A new multilingual string
|
|
410
|
+
*/
|
|
411
|
+
filterEntries(shouldKeep) {
|
|
412
|
+
const newContent = {};
|
|
413
|
+
for (const language of this._availableLanguages) {
|
|
414
|
+
const currentEntries = this._content[language] ?? [];
|
|
415
|
+
const entries = [];
|
|
416
|
+
for (const entry of currentEntries) if (shouldKeep({ ...entry }, language)) entries.push({ ...entry });
|
|
417
|
+
newContent[language] = normalizePrimary(entries);
|
|
418
|
+
}
|
|
419
|
+
const newAvailableLanguages = getLanguagesWithEntries(newContent, this._options.availableLanguages);
|
|
420
|
+
return MultilingualString.fromNormalized(newContent, {
|
|
421
|
+
...this._options,
|
|
422
|
+
defaultLanguage: newAvailableLanguages.includes(this._options.defaultLanguage) ? this._options.defaultLanguage : resolveDefaultLanguageOption(newAvailableLanguages, this._options.availableLanguages)
|
|
423
|
+
}, newAvailableLanguages);
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
277
426
|
* Get the string representation, using the default language
|
|
278
427
|
*/
|
|
279
428
|
toString() {
|
package/dist/query.d.mts
CHANGED
|
@@ -2,12 +2,38 @@ import { PropertyRelation, Query } from "./types/index.mjs";
|
|
|
2
2
|
import { OchreQueryContext } from "./xquery.mjs";
|
|
3
3
|
//#region src/query.d.ts
|
|
4
4
|
export declare function buildBelongsToCollectionQueryExpression(belongsToCollectionScopeUuids: ReadonlyArray<string>, belongsToCollectionPropertyVariableUuid: string): string | null;
|
|
5
|
+
/**
|
|
6
|
+
* The scope variable and searchable path of each item container
|
|
7
|
+
*
|
|
8
|
+
* A path has to stay inline in `cts:search`: binding it to a variable first
|
|
9
|
+
* materializes the sequence and makes every query `XDMP-UNSEARCHABLE`, even a
|
|
10
|
+
* plain word query. Each references its own scope variable, which
|
|
11
|
+
* {@link compileContainerItemsQuery} declares.
|
|
12
|
+
*
|
|
13
|
+
* A Tree nests its items under headings to any depth, so its path walks the
|
|
14
|
+
* descendant axis and then keeps only the nodes a heading or `items` holds
|
|
15
|
+
* directly, which is what distinguishes an item from the elements inside one.
|
|
16
|
+
* Excluding `heading` matters twice: a heading is not an item, and searching
|
|
17
|
+
* over headings would match every item under a heading whose own text matches.
|
|
18
|
+
* The union form `items/(* | heading/*)` is deliberately not used, because
|
|
19
|
+
* MarkLogic rejects a union as `XDMP-UNSEARCHABLE`.
|
|
20
|
+
*/
|
|
21
|
+
declare const ITEMS_CONTAINERS: {
|
|
22
|
+
readonly set: {
|
|
23
|
+
readonly scopeVariable: "$setScopeUuids";
|
|
24
|
+
readonly itemsExpression: "doc()/ochre/set[@uuid = $setScopeUuids]/items/*";
|
|
25
|
+
};
|
|
26
|
+
readonly tree: {
|
|
27
|
+
readonly scopeVariable: "$treeScopeUuids";
|
|
28
|
+
readonly itemsExpression: "doc()/ochre/tree[@uuid = $treeScopeUuids]/items/descendant::*[not(self::heading)][parent::items or parent::heading]";
|
|
29
|
+
};
|
|
30
|
+
};
|
|
5
31
|
/**
|
|
6
32
|
* Compile a query tree into the clauses that bind the matching Set items
|
|
7
33
|
*
|
|
8
34
|
* The returned `itemsClause` binds {@link ITEMS_VARIABLE} and has to be placed
|
|
9
35
|
* inside an XQuery body, with `prolog` declared ahead of it.
|
|
10
|
-
* {@link
|
|
36
|
+
* {@link compileContainerItemsQuery} does both and is what fetchers should use;
|
|
11
37
|
* this is exposed for tests that assert on the compiled CTS.
|
|
12
38
|
* @param parameters - The plan parameters
|
|
13
39
|
* @param parameters.queries - The query tree to compile, or null to match every item
|
|
@@ -30,15 +56,21 @@ export declare function buildQueryPlan(parameters: {
|
|
|
30
56
|
}>;
|
|
31
57
|
};
|
|
32
58
|
/**
|
|
33
|
-
*
|
|
59
|
+
* The OCHRE item containers a paginated item query can run over
|
|
60
|
+
*/
|
|
61
|
+
export type ItemsContainer = keyof typeof ITEMS_CONTAINERS;
|
|
62
|
+
/**
|
|
63
|
+
* Compile an item query over a Set or a Tree into a complete XQuery document
|
|
34
64
|
*
|
|
35
65
|
* Owns everything a caller would otherwise have to know and restate: the
|
|
36
|
-
* version declaration, the
|
|
37
|
-
*
|
|
38
|
-
* that it is only declared when non-empty, the `<ochre>`
|
|
39
|
-
* of the variable holding the matching items. The body
|
|
66
|
+
* version declaration, the scope variable, the supplemental-stripping prolog,
|
|
67
|
+
* the inline searchable path for the container, where the compiled helper
|
|
68
|
+
* prolog goes and that it is only declared when non-empty, the `<ochre>`
|
|
69
|
+
* wrapper, and the name of the variable holding the matching items. The body
|
|
70
|
+
* receives that name, so it is identical for either container.
|
|
40
71
|
* @param parameters - The query parameters
|
|
41
|
-
* @param parameters.
|
|
72
|
+
* @param parameters.container - Whether the scope UUIDs name Sets or Trees
|
|
73
|
+
* @param parameters.scopeUuids - The container UUIDs to search within
|
|
42
74
|
* @param parameters.belongsToCollectionScopeUuids - Collection scope UUIDs to narrow to
|
|
43
75
|
* @param parameters.queries - The query tree to compile, or null to match every item
|
|
44
76
|
* @param parameters.declarations - Extra prolog declarations, placed before the compiled prolog
|
|
@@ -46,8 +78,9 @@ export declare function buildQueryPlan(parameters: {
|
|
|
46
78
|
* @returns A complete XQuery document
|
|
47
79
|
* @internal
|
|
48
80
|
*/
|
|
49
|
-
export declare function
|
|
50
|
-
|
|
81
|
+
export declare function compileContainerItemsQuery(parameters: {
|
|
82
|
+
container: ItemsContainer;
|
|
83
|
+
scopeUuids: ReadonlyArray<string>;
|
|
51
84
|
belongsToCollectionScopeUuids: ReadonlyArray<string>;
|
|
52
85
|
queries: Query | null;
|
|
53
86
|
declarations?: ReadonlyArray<string>;
|
package/dist/query.mjs
CHANGED
|
@@ -1111,22 +1111,38 @@ function buildBelongsToCollectionQueryExpression(belongsToCollectionScopeUuids,
|
|
|
1111
1111
|
* @returns The prolog declaring the query helpers, and the `let` clauses binding `$items`
|
|
1112
1112
|
*/
|
|
1113
1113
|
const ITEMS_VARIABLE = "$items";
|
|
1114
|
-
const SET_SCOPE_VARIABLE = "$setScopeUuids";
|
|
1115
1114
|
/**
|
|
1116
|
-
* The
|
|
1115
|
+
* The scope variable and searchable path of each item container
|
|
1117
1116
|
*
|
|
1118
|
-
*
|
|
1117
|
+
* A path has to stay inline in `cts:search`: binding it to a variable first
|
|
1119
1118
|
* materializes the sequence and makes every query `XDMP-UNSEARCHABLE`, even a
|
|
1120
|
-
* plain word query.
|
|
1121
|
-
* {@link
|
|
1119
|
+
* plain word query. Each references its own scope variable, which
|
|
1120
|
+
* {@link compileContainerItemsQuery} declares.
|
|
1121
|
+
*
|
|
1122
|
+
* A Tree nests its items under headings to any depth, so its path walks the
|
|
1123
|
+
* descendant axis and then keeps only the nodes a heading or `items` holds
|
|
1124
|
+
* directly, which is what distinguishes an item from the elements inside one.
|
|
1125
|
+
* Excluding `heading` matters twice: a heading is not an item, and searching
|
|
1126
|
+
* over headings would match every item under a heading whose own text matches.
|
|
1127
|
+
* The union form `items/(* | heading/*)` is deliberately not used, because
|
|
1128
|
+
* MarkLogic rejects a union as `XDMP-UNSEARCHABLE`.
|
|
1122
1129
|
*/
|
|
1123
|
-
const
|
|
1130
|
+
const ITEMS_CONTAINERS = {
|
|
1131
|
+
set: {
|
|
1132
|
+
scopeVariable: "$setScopeUuids",
|
|
1133
|
+
itemsExpression: "doc()/ochre/set[@uuid = $setScopeUuids]/items/*"
|
|
1134
|
+
},
|
|
1135
|
+
tree: {
|
|
1136
|
+
scopeVariable: "$treeScopeUuids",
|
|
1137
|
+
itemsExpression: "doc()/ochre/tree[@uuid = $treeScopeUuids]/items/descendant::*[not(self::heading)][parent::items or parent::heading]"
|
|
1138
|
+
}
|
|
1139
|
+
};
|
|
1124
1140
|
/**
|
|
1125
1141
|
* Compile a query tree into the clauses that bind the matching Set items
|
|
1126
1142
|
*
|
|
1127
1143
|
* The returned `itemsClause` binds {@link ITEMS_VARIABLE} and has to be placed
|
|
1128
1144
|
* inside an XQuery body, with `prolog` declared ahead of it.
|
|
1129
|
-
* {@link
|
|
1145
|
+
* {@link compileContainerItemsQuery} does both and is what fetchers should use;
|
|
1130
1146
|
* this is exposed for tests that assert on the compiled CTS.
|
|
1131
1147
|
* @param parameters - The plan parameters
|
|
1132
1148
|
* @param parameters.queries - The query tree to compile, or null to match every item
|
|
@@ -1178,15 +1194,17 @@ function buildQueryPlan(parameters) {
|
|
|
1178
1194
|
};
|
|
1179
1195
|
}
|
|
1180
1196
|
/**
|
|
1181
|
-
* Compile a Set
|
|
1197
|
+
* Compile an item query over a Set or a Tree into a complete XQuery document
|
|
1182
1198
|
*
|
|
1183
1199
|
* Owns everything a caller would otherwise have to know and restate: the
|
|
1184
|
-
* version declaration, the
|
|
1185
|
-
*
|
|
1186
|
-
* that it is only declared when non-empty, the `<ochre>`
|
|
1187
|
-
* of the variable holding the matching items. The body
|
|
1200
|
+
* version declaration, the scope variable, the supplemental-stripping prolog,
|
|
1201
|
+
* the inline searchable path for the container, where the compiled helper
|
|
1202
|
+
* prolog goes and that it is only declared when non-empty, the `<ochre>`
|
|
1203
|
+
* wrapper, and the name of the variable holding the matching items. The body
|
|
1204
|
+
* receives that name, so it is identical for either container.
|
|
1188
1205
|
* @param parameters - The query parameters
|
|
1189
|
-
* @param parameters.
|
|
1206
|
+
* @param parameters.container - Whether the scope UUIDs name Sets or Trees
|
|
1207
|
+
* @param parameters.scopeUuids - The container UUIDs to search within
|
|
1190
1208
|
* @param parameters.belongsToCollectionScopeUuids - Collection scope UUIDs to narrow to
|
|
1191
1209
|
* @param parameters.queries - The query tree to compile, or null to match every item
|
|
1192
1210
|
* @param parameters.declarations - Extra prolog declarations, placed before the compiled prolog
|
|
@@ -1194,17 +1212,18 @@ function buildQueryPlan(parameters) {
|
|
|
1194
1212
|
* @returns A complete XQuery document
|
|
1195
1213
|
* @internal
|
|
1196
1214
|
*/
|
|
1197
|
-
function
|
|
1198
|
-
const {
|
|
1215
|
+
function compileContainerItemsQuery(parameters) {
|
|
1216
|
+
const { container, scopeUuids, belongsToCollectionScopeUuids, queries, declarations = [], body } = parameters;
|
|
1217
|
+
const { scopeVariable, itemsExpression } = ITEMS_CONTAINERS[container];
|
|
1199
1218
|
const plan = buildQueryPlan({
|
|
1200
1219
|
queries,
|
|
1201
|
-
baseItemsExpression:
|
|
1220
|
+
baseItemsExpression: itemsExpression,
|
|
1202
1221
|
scopeQueryExpression: buildBelongsToCollectionQueryExpression(belongsToCollectionScopeUuids, BELONGS_TO_COLLECTION_UUID)
|
|
1203
1222
|
});
|
|
1204
1223
|
return compileOchreQuery({
|
|
1205
1224
|
declarations: [
|
|
1206
1225
|
...declarations,
|
|
1207
|
-
`declare variable ${
|
|
1226
|
+
`declare variable ${scopeVariable} := (${Array.from(scopeUuids, (uuid) => stringLiteral(uuid)).join(", ")});`,
|
|
1208
1227
|
...plan.prolog === "" ? [] : [plan.prolog]
|
|
1209
1228
|
],
|
|
1210
1229
|
body: (context) => `<ochre>{
|
|
@@ -1268,4 +1287,4 @@ function getPropertyFacetSelectors(queries) {
|
|
|
1268
1287
|
return selectors.values().toArray();
|
|
1269
1288
|
}
|
|
1270
1289
|
//#endregion
|
|
1271
|
-
export { buildBelongsToCollectionQueryExpression, buildQueryPlan,
|
|
1290
|
+
export { buildBelongsToCollectionQueryExpression, buildQueryPlan, compileContainerItemsQuery, getItemFilterQueries, getPropertyFacetSelectors };
|
package/dist/schemas.d.mts
CHANGED
|
@@ -65,12 +65,32 @@ export declare const itemOcrDataParametersSchema: v.ObjectSchema<{
|
|
|
65
65
|
readonly matchMode: v.OptionalSchema<v.PicklistSchema<["includes", "exact"], undefined>, "includes">;
|
|
66
66
|
readonly isCaseSensitive: v.GenericSchema<unknown, boolean>;
|
|
67
67
|
}, undefined>;
|
|
68
|
-
/**
|
|
69
|
-
* Schema for validating Set items parameters
|
|
70
|
-
* @internal
|
|
71
|
-
*/
|
|
72
68
|
export declare const setItemsParametersSchema: v.ObjectSchema<{
|
|
69
|
+
readonly belongsToCollectionScopeUuids: v.OptionalSchema<v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Invalid pseudo-UUID">]>, undefined>, readonly []>;
|
|
70
|
+
readonly queries: v.OptionalSchema<v.NullableSchema<v.GenericSchema<unknown, Query>, undefined>, null>;
|
|
71
|
+
readonly sort: v.OptionalSchema<v.VariantSchema<"target", [v.StrictObjectSchema<{
|
|
72
|
+
readonly target: v.LiteralSchema<"none", undefined>;
|
|
73
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
74
|
+
readonly target: v.LiteralSchema<"title", undefined>;
|
|
75
|
+
readonly direction: v.OptionalSchema<v.PicklistSchema<["asc", "desc"], undefined>, "asc">;
|
|
76
|
+
readonly language: v.GenericSchema<unknown, string>;
|
|
77
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
78
|
+
readonly target: v.LiteralSchema<"date", undefined>;
|
|
79
|
+
readonly direction: v.OptionalSchema<v.PicklistSchema<["asc", "desc"], undefined>, "asc">;
|
|
80
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
81
|
+
readonly target: v.LiteralSchema<"propertyValue", undefined>;
|
|
82
|
+
readonly propertyVariableUuid: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Invalid pseudo-UUID">]>;
|
|
83
|
+
readonly dataType: v.PicklistSchema<readonly ["string", "integer", "decimal", "boolean", "date", "dateTime", "time", "IDREF"], undefined>;
|
|
84
|
+
readonly direction: v.OptionalSchema<v.PicklistSchema<["asc", "desc"], undefined>, "asc">;
|
|
85
|
+
readonly language: v.GenericSchema<unknown, string>;
|
|
86
|
+
}, undefined>], undefined>, {
|
|
87
|
+
readonly target: "none";
|
|
88
|
+
}>;
|
|
89
|
+
readonly page: v.OptionalSchema<v.GenericSchema<unknown, number>, 1>;
|
|
90
|
+
readonly pageSize: v.OptionalSchema<v.GenericSchema<unknown, number>, 48>;
|
|
73
91
|
readonly setScopeUuids: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Invalid pseudo-UUID">]>, undefined>, v.MinLengthAction<string[], 1, "At least one set scope UUID is required">]>;
|
|
92
|
+
}, undefined>;
|
|
93
|
+
export declare const treeItemsParametersSchema: v.ObjectSchema<{
|
|
74
94
|
readonly belongsToCollectionScopeUuids: v.OptionalSchema<v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Invalid pseudo-UUID">]>, undefined>, readonly []>;
|
|
75
95
|
readonly queries: v.OptionalSchema<v.NullableSchema<v.GenericSchema<unknown, Query>, undefined>, null>;
|
|
76
96
|
readonly sort: v.OptionalSchema<v.VariantSchema<"target", [v.StrictObjectSchema<{
|
|
@@ -79,6 +99,9 @@ export declare const setItemsParametersSchema: v.ObjectSchema<{
|
|
|
79
99
|
readonly target: v.LiteralSchema<"title", undefined>;
|
|
80
100
|
readonly direction: v.OptionalSchema<v.PicklistSchema<["asc", "desc"], undefined>, "asc">;
|
|
81
101
|
readonly language: v.GenericSchema<unknown, string>;
|
|
102
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
103
|
+
readonly target: v.LiteralSchema<"date", undefined>;
|
|
104
|
+
readonly direction: v.OptionalSchema<v.PicklistSchema<["asc", "desc"], undefined>, "asc">;
|
|
82
105
|
}, undefined>, v.StrictObjectSchema<{
|
|
83
106
|
readonly target: v.LiteralSchema<"propertyValue", undefined>;
|
|
84
107
|
readonly propertyVariableUuid: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Invalid pseudo-UUID">]>;
|
|
@@ -90,5 +113,6 @@ export declare const setItemsParametersSchema: v.ObjectSchema<{
|
|
|
90
113
|
}>;
|
|
91
114
|
readonly page: v.OptionalSchema<v.GenericSchema<unknown, number>, 1>;
|
|
92
115
|
readonly pageSize: v.OptionalSchema<v.GenericSchema<unknown, number>, 48>;
|
|
116
|
+
readonly treeScopeUuids: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Invalid pseudo-UUID">]>, undefined>, v.MinLengthAction<string[], 1, "At least one tree scope UUID is required">]>;
|
|
93
117
|
}, undefined>;
|
|
94
118
|
//#endregion
|
package/dist/schemas.mjs
CHANGED
|
@@ -195,6 +195,10 @@ const setItemsSortSchema = v.optional(v.variant("target", [
|
|
|
195
195
|
direction: sortDirectionSchema,
|
|
196
196
|
language: defaultString("eng")
|
|
197
197
|
}),
|
|
198
|
+
v.strictObject({
|
|
199
|
+
target: v.literal("date"),
|
|
200
|
+
direction: sortDirectionSchema
|
|
201
|
+
}),
|
|
198
202
|
v.strictObject({
|
|
199
203
|
target: v.literal("propertyValue"),
|
|
200
204
|
propertyVariableUuid: uuidSchema,
|
|
@@ -243,13 +247,20 @@ const itemOcrDataParametersSchema = v.object({
|
|
|
243
247
|
* Schema for validating Set items parameters
|
|
244
248
|
* @internal
|
|
245
249
|
*/
|
|
246
|
-
const
|
|
247
|
-
setScopeUuids: v.pipe(v.array(uuidSchema), v.minLength(1, "At least one set scope UUID is required")),
|
|
250
|
+
const containerItemsParametersEntries = {
|
|
248
251
|
belongsToCollectionScopeUuids: v.optional(v.array(uuidSchema), []),
|
|
249
252
|
queries: setQueriesSchema,
|
|
250
253
|
sort: setItemsSortSchema,
|
|
251
254
|
page: v.optional(positiveNumber("Page must be positive"), 1),
|
|
252
255
|
pageSize: v.optional(positiveNumber("Page size must be positive"), 48)
|
|
256
|
+
};
|
|
257
|
+
const setItemsParametersSchema = v.object({
|
|
258
|
+
setScopeUuids: v.pipe(v.array(uuidSchema), v.minLength(1, "At least one set scope UUID is required")),
|
|
259
|
+
...containerItemsParametersEntries
|
|
260
|
+
});
|
|
261
|
+
const treeItemsParametersSchema = v.object({
|
|
262
|
+
treeScopeUuids: v.pipe(v.array(uuidSchema), v.minLength(1, "At least one tree scope UUID is required")),
|
|
263
|
+
...containerItemsParametersEntries
|
|
253
264
|
});
|
|
254
265
|
//#endregion
|
|
255
|
-
export { componentSchema, gallerySchema, isPseudoUuid, iso639_3Schema, itemOcrDataParametersSchema, renderOptionsSchema, setItemsParametersSchema, setPropertyValuesParametersSchema, uuidSchema };
|
|
266
|
+
export { componentSchema, gallerySchema, isPseudoUuid, iso639_3Schema, itemOcrDataParametersSchema, renderOptionsSchema, setItemsParametersSchema, setPropertyValuesParametersSchema, treeItemsParametersSchema, uuidSchema };
|