@digitalculture/ochre-sdk
Version:
Node.js library for working with OCHRE (Online Cultural and Historical Research Environment) data
1,304 lines • 40.7 kB
text/typescript
//#region src/types/main.d.ts
/**
* Represents the core data structure containing item information and metadata
*/
type Data<T extends DataCategory = DataCategory, U extends DataCategory | Array<DataCategory> = (T extends "tree" ? Exclude<DataCategory, "tree"> : T extends "set" ? Array<DataCategory> : never)> = {
uuid: string;
belongsTo: {
uuid: string;
abbreviation: string;
};
publicationDateTime: Date;
persistentUrl: string | null;
item: Item<T, U>;
};
/**
* Represents the category of the data
*/
type DataCategory = "resource" | "spatialUnit" | "concept" | "period" | "bibliography" | "person" | "propertyVariable" | "propertyValue" | "text" | "tree" | "set";
/**
* Represents the item of the data, with proper type narrowing based on category
*/
type Item<T extends DataCategory = DataCategory, U extends DataCategory | Array<DataCategory> = (T extends "tree" ? Exclude<DataCategory, "tree"> : T extends "set" ? Array<DataCategory> : never)> = T extends "resource" ? Resource : T extends "spatialUnit" ? SpatialUnit : T extends "concept" ? Concept : T extends "period" ? Period : T extends "bibliography" ? Bibliography : T extends "person" ? Person : T extends "propertyVariable" ? PropertyVariable : T extends "propertyValue" ? PropertyValue : T extends "text" ? Text : T extends "tree" ? Tree<U extends Array<DataCategory> ? Exclude<U[number], "tree"> : Exclude<U, "tree">> : T extends "set" ? Set<U extends Array<DataCategory> ? U : Array<U>> : Resource | SpatialUnit | Concept | Period | Bibliography | Person | PropertyVariable | PropertyValue | Tree<U extends Array<DataCategory> ? Exclude<U[number], "tree"> : Exclude<U, "tree">> | Set<U extends Array<DataCategory> ? U : Array<U>>;
/**
* Basic identification information used across multiple types
*/
type Identification = {
label: string;
abbreviation: string;
code: string | null;
};
/**
* Metadata information for items including project, publisher and language details
*/
type Metadata = {
project: {
identification: Identification & {
website: string | null;
};
dateFormat: string | null;
page: "item" | "entry" | null;
} | null;
collection: {
identification: Identification;
page: "item" | "entry";
} | null;
publication: {
identification: Identification;
page: "item" | "entry";
} | null;
item: {
identification: Identification;
category: string;
type: string;
maxLength: number | null;
} | null;
dataset: string;
publisher: string;
languages: Array<string>;
identifier: string;
description: string;
};
/**
* Represents a single item in a context hierarchy with its metadata
*/
type ContextItem = {
uuid: string;
publicationDateTime: Date | null;
number: number;
content: string;
};
/**
* Represents a node in the context tree containing tree, project and spatial unit information
*/
type ContextNode = {
tree: ContextItem;
project: ContextItem;
spatialUnit: Array<ContextItem>;
};
/**
* Contains the full context information including nodes and display path
*/
type Context = {
nodes: Array<ContextNode>;
displayPath: string;
};
/**
* License information for content items
*/
type License = {
content: string;
url: string;
};
/**
* Represents a person (author, creator, etc.) with their identification and metadata
*/
type Person = {
uuid: string;
category: "person";
belongsTo: {
uuid: string;
abbreviation: string;
} | null;
metadata: Metadata | null;
publicationDateTime: Date | null;
persistentUrl: string | null;
type: string | null;
number: number | null;
context: Context | null;
availability: License | null;
date: string | null;
identification: Identification | null;
image: Image | null;
address: {
country: string | null;
city: string | null;
state: string | null;
} | null;
description: string | null;
coordinates: Array<Coordinate>;
content: string | null;
notes: Array<Note>;
links: Array<Link>;
events: Array<Event>;
properties: Array<Property>;
bibliographies: Array<Bibliography>;
};
/**
* Represents a note with number, title and content
*/
type Note = {
number: number;
title: string | null;
date: string | null;
authors: Array<Person>;
content: string;
};
/**
* Represents an image with its metadata and content
*/
type Image = {
publicationDateTime: Date | null;
identification: Identification | null;
url: string | null;
htmlPrefix: string | null;
content: string | null;
widthPreview: number | null;
heightPreview: number | null;
width: number | null;
height: number | null;
};
/**
* Represents a file format
*/
type FileFormat = "image/jpeg" | "image/gif" | "image/tiff" | "image/bmp" | "image/png" | "image/svg+xml" | "image/jpeg-imageMap" | "image/gif-imageMap" | "image/tiff-imageMap" | "image/bmp-imageMap" | "image/png-imageMap" | "image/svg+xml-imageMap" | "video/mpeg" | "video/mp4" | "video/quicktime" | "video/x-msvideo" | "video/x-ms-wmv" | "video/x-ms-asf" | "drawing/dwg" | "audio/aiff" | "audio/basic" | "audio/midi" | "audio/mp4" | "audio/mpeg" | "audio/x-ms-wax" | "audio/x-ms-wma" | "audio/wav" | "text/pdf" | "text/doc" | "text/ppt" | "text/html" | "text/plain" | "application/xls" | "application/xlsx" | "application/ai" | "application/octet-stream" | "application/IIIF" | "image/fits" | "image/ptm" | "model/obj";
/**
* Represents a link to another item with optional image and bibliographic references
*/
type Link = {
uuid: string | null;
publicationDateTime: Date | null;
type: string | null;
category: string | null;
identification: Identification | null;
description: string | null;
content: string | null;
href: string | null;
fileFormat: FileFormat | null;
fileSize: number | null;
image: {
isInline: boolean;
isPrimary: boolean;
heightPreview: number;
widthPreview: number;
height: number;
width: number;
} | null;
bibliographies: Array<Bibliography> | null;
};
/**
* Represents a clickable/interactive area on an image map
*/
type ImageMapArea = {
uuid: string;
publicationDateTime: Date | null;
category: string;
title: string;
shape: "rectangle" | "circle" | "polygon";
coords: Array<number>;
slug: string | null;
};
/**
* Contains image map areas and dimensions
*/
type ImageMap = {
area: Array<ImageMapArea>;
width: number;
height: number;
};
/**
* Geographic coordinate with optional type and label
*/
type Coordinate = {
type: "point";
latitude: number;
longitude: number;
altitude: number | null;
source: {
context: "self";
uuid: string;
label: string;
} | {
context: "related";
uuid: string;
label: string;
value: string;
} | {
context: "inherited";
item: {
uuid: string;
label: string;
};
uuid: string;
label: string;
} | null;
} | {
type: "plane";
minimum: {
latitude: number;
longitude: number;
};
maximum: {
latitude: number;
longitude: number;
};
source: {
context: "self";
uuid: string;
label: string;
} | {
context: "related";
uuid: string;
label: string;
value: string;
} | {
context: "inherited";
item: {
uuid: string;
label: string;
};
uuid: string;
label: string;
} | null;
};
/**
* Represents an observation with notes, links and properties
*/
type Observation = {
number: number;
date: string | null;
observers: Array<string> | Array<Person>;
notes: Array<Note>;
links: Array<Link>;
properties: Array<Property>;
bibliographies: Array<Bibliography>;
};
/**
* Represents an event with date, label and optional agent
*/
type Event = {
dateTime: string | null;
label: string;
agent: {
uuid: string;
publicationDateTime: Date | null;
content: string;
} | null;
location: {
uuid: string;
publicationDateTime: Date | null;
content: string;
} | null;
comment: string | null;
other: {
uuid: string | null;
category: string | null;
content: string;
} | null;
value: string | null;
};
/**
* Represents an interpretation with date and properties
*/
type Interpretation = {
date: string | null;
number: number;
links: Array<Link>;
properties: Array<Property>;
bibliographies: Array<Bibliography>;
};
/**
* Represents a resource item with associated metadata, content and relationships
*/
type Resource = {
uuid: string;
category: "resource";
belongsTo: {
uuid: string;
abbreviation: string;
} | null;
metadata: Metadata | null;
publicationDateTime: Date | null;
persistentUrl: string | null;
type: string;
number: number;
context: Context | null;
license: License | null;
copyright: string | null;
watermark: string | null;
identification: Identification;
date: string | null;
image: Image | null;
creators: Array<Person>;
notes: Array<Note>;
description: string;
coordinates: Array<Coordinate>;
document: string | null;
href: string | null;
fileFormat: FileFormat | null;
fileSize: number | null;
imageMap: ImageMap | null;
periods: Array<Period>;
links: Array<Link>;
reverseLinks: Array<Link>;
properties: Array<Property>;
bibliographies: Array<Bibliography>;
resources: Array<Resource>;
};
/**
* Represents a spatial unit with geographic coordinates and observations
*/
type SpatialUnit = {
uuid: string;
category: "spatialUnit";
belongsTo: {
uuid: string;
abbreviation: string;
} | null;
metadata: Metadata | null;
publicationDateTime: Date | null;
persistentUrl: string | null;
number: number;
context: Context | null;
license: License | null;
identification: Identification;
image: Image | null;
description: string | null;
coordinates: Array<Coordinate>;
mapData: {
geoJSON: {
multiPolygon: string;
EPSG: number;
};
} | null;
observations: Array<Observation>;
events: Array<Event>;
properties: Array<Property>;
bibliographies: Array<Bibliography>;
};
/**
* Represents a concept with associated interpretations
*/
type Concept = {
uuid: string;
category: "concept";
belongsTo: {
uuid: string;
abbreviation: string;
} | null;
metadata: Metadata | null;
publicationDateTime: Date | null;
persistentUrl: string | null;
number: number;
license: License | null;
context: Context | null;
identification: Identification;
image: Image | null;
description: string | null;
coordinates: Array<Coordinate>;
interpretations: Array<Interpretation>;
properties: Array<Property>;
bibliographies: Array<Bibliography>;
};
/**
* Represents a set that can contain resources, spatial units and concepts
*/
type Set<U extends Array<DataCategory> = Array<DataCategory>> = {
uuid: string;
category: "set";
belongsTo: {
uuid: string;
abbreviation: string;
} | null;
metadata: Metadata | null;
itemCategories: U;
publicationDateTime: Date | null;
persistentUrl: string | null;
type: string;
number: number;
date: string | null;
license: License | null;
identification: Identification;
isSuppressingBlanks: boolean;
description: string;
creators: Array<Person>;
items: [DataCategory] extends [U] ? Array<Item> : U extends "resource" ? Array<Resource> : U extends "spatialUnit" ? Array<SpatialUnit> : U extends "concept" ? Array<Concept> : U extends "period" ? Array<Period> : U extends "bibliography" ? Array<Bibliography> : U extends "person" ? Array<Person> : U extends "propertyVariable" ? Array<PropertyVariable> : U extends "propertyValue" ? Array<PropertyValue> : U extends "tree" ? Array<Tree<Exclude<DataCategory, "tree">>> : U extends "set" ? Array<Set<Array<DataCategory>>> : Array<Item>;
};
/**
* Represents a bibliography entry with citation and publication information
*/
type Bibliography = {
uuid: string | null;
zoteroId: string | null;
category: "bibliography";
belongsTo: {
uuid: string;
abbreviation: string;
} | null;
metadata: Metadata | null;
publicationDateTime: Date | null;
persistentUrl: string | null;
type: string | null;
number: number | null;
identification: Identification | null;
projectIdentification: Identification | null;
context: Context | null;
image: Image | null;
citation: {
details: string | null;
format: string | null;
short: string | null;
long: string | null;
};
publicationInfo: {
publishers: Array<Person>;
startDate: Date | null;
};
entryInfo: {
startIssue: string;
startVolume: string;
} | null;
sourceResources: Array<Pick<Resource, "uuid" | "category" | "publicationDateTime" | "type" | "identification" | "href">>;
periods: Array<Period>;
authors: Array<Person>;
links: Array<Link>;
reverseLinks: Array<Link>;
properties: Array<Property>;
};
/**
* Represents a time period with identification
*/
type Period = {
uuid: string;
category: "period";
belongsTo: {
uuid: string;
abbreviation: string;
} | null;
metadata: Metadata | null;
publicationDateTime: Date | null;
persistentUrl: string | null;
type: string | null;
number: number | null;
identification: Identification;
coordinates: Array<Coordinate>;
description: string | null;
};
/**
* Represents a property variable
*/
type PropertyVariable = {
uuid: string;
category: "propertyVariable";
belongsTo: {
uuid: string;
abbreviation: string;
} | null;
metadata: Metadata | null;
persistentUrl: string | null;
type: string;
number: number;
publicationDateTime: Date | null;
context: Context | null;
availability: License | null;
identification: Identification;
};
/**
* Represents a property value with type information
*/
type PropertyValue = {
uuid: string;
category: "propertyValue";
belongsTo: {
uuid: string;
abbreviation: string;
} | null;
metadata: Metadata | null;
persistentUrl: string | null;
number: number;
publicationDateTime: Date | null;
context: Context | null;
availability: License | null;
identification: Identification;
date: string | null;
creators: Array<Person>;
description: string;
coordinates: Array<Coordinate>;
notes: Array<Note>;
links: Array<Link>;
};
type PropertyValueContentType = "string" | "integer" | "decimal" | "boolean" | "date" | "dateTime" | "time" | "coordinate" | "IDREF";
/**
* Represents a property value with type information
*/
type PropertyValueContent<T extends PropertyValueContentType> = {
hierarchy: {
isLeaf: boolean;
level: number | null;
};
content: (T extends "integer" ? number : T extends "decimal" ? number : T extends "time" ? number : T extends "boolean" ? boolean : string) | null;
dataType: T;
label: string | null;
isUncertain: boolean;
unit: string | null;
height: number | null;
width: number | null;
fileSize: number | null;
category: string | null;
type: string | null;
uuid: string | null;
publicationDateTime: Date | null;
href: string | null;
slug: string | null;
};
/**
* Represents a property with label, values and nested properties
*/
type Property<T extends PropertyValueContentType = PropertyValueContentType> = {
uuid: string;
label: string;
values: Array<PropertyValueContent<T>>;
comment: string | null;
properties: Array<Property>;
};
/**
* Represents a resource item with associated metadata, content and relationships
*/
type Text = {
uuid: string;
category: "text";
belongsTo: {
uuid: string;
abbreviation: string;
} | null;
metadata: Metadata | null;
publicationDateTime: Date | null;
persistentUrl: string | null;
type: string | null;
language: string | null;
number: number;
context: Context | null;
license: License | null;
copyright: string | null;
watermark: string | null;
identification: Identification;
image: Image | null;
creators: Array<Person>;
editors: Array<Person>;
notes: Array<Note>;
description: string;
coordinates: Array<Coordinate>;
periods: Array<Period>;
links: Array<Link>;
reverseLinks: Array<Link>;
properties: Array<Property>;
bibliographies: Array<Bibliography>;
sections: Array<Section>;
};
/**
* Represents a section of a text
*/
type Section = {
uuid: string;
variant: "translation" | "phonemic";
type: string;
identification: Identification;
projectIdentification: Identification | null;
};
/**
* Represents a tree structure containing resources, spatial units and concepts
*/
type Tree<U extends Exclude<DataCategory, "tree"> = Exclude<DataCategory, "tree">> = {
uuid: string;
category: "tree";
belongsTo: {
uuid: string;
abbreviation: string;
} | null;
metadata: Metadata | null;
publicationDateTime: Date | null;
persistentUrl: string | null;
type: string;
number: number;
date: string | null;
license: License | null;
identification: Identification;
creators: Array<Person>;
properties: Array<Property>;
items: [Exclude<DataCategory, "tree">] extends [U] ? Array<Item> : U extends "resource" ? Array<Resource> : U extends "spatialUnit" ? Array<SpatialUnit> : U extends "concept" ? Array<Concept> : U extends "period" ? Array<Period> : U extends "bibliography" ? Array<Bibliography> : U extends "person" ? Array<Person> : U extends "propertyVariable" ? Array<PropertyVariable> : U extends "propertyValue" ? Array<PropertyValue> : U extends "text" ? Array<Text> : U extends "set" ? Array<Set<U extends Array<DataCategory> ? U : Array<U>>> : Array<Item>;
};
/**
* Represents a gallery with its identification, project identification, resources and max length
*/
type Gallery = {
identification: Identification;
projectIdentification: Identification;
resources: Array<Resource>;
maxLength: number;
};
/**
* Represents a property query item with its UUID, raw value, count, and content
*/
type PropertyValueQueryItem = {
count: number;
dataType: Exclude<PropertyValueContentType, "coordinate">;
content: string | number | boolean | null;
label: string | null;
};
/**
* Represents a metadata object given a UUID
*/
type UuidMetadata = {
item: {
uuid: string;
name: string;
type: string;
};
project: {
name: string;
website: string | null;
};
} | null;
/**
* Represents a level context item with a variable and value
*/
type LevelContextItem = {
variableUuid: string;
valueUuid: string | null;
};
/**
* Represents a level context with a context item
*/
type LevelContext = {
context: Array<LevelContextItem>;
identification: Identification;
type: string;
};
/**
* Represents property contexts with its levels
*/
type PropertyContexts = {
flatten: Array<LevelContext>;
suppress: Array<LevelContext>;
filter: Array<LevelContext>;
sort: Array<LevelContext>;
detail: Array<LevelContext>;
download: Array<LevelContext>;
label: Array<LevelContext>;
prominent: Array<LevelContext>;
};
/**
* Represents a scope with its UUID, type and identification
*/
type Scope = {
uuid: string;
type: string;
identification: Identification;
};
type ApiVersion = 1 | 2;
/**
* Represents a website with its properties and elements
*/
type Website = {
uuid: string;
version: ApiVersion;
belongsTo: {
uuid: string;
abbreviation: string;
} | null;
metadata: Metadata;
publicationDateTime: Date | null;
identification: Identification;
creators: Array<Person>;
license: License | null;
pages: Array<Webpage>;
sidebar: {
elements: Array<WebElement>;
title: WebElement["title"];
layout: "start" | "end";
mobileLayout: "default" | "inline";
cssStyles: {
default: Array<Style>;
tablet: Array<Style>;
mobile: Array<Style>;
};
} | null;
properties: {
type: "traditional" | "digital-collection" | "plum" | "cedar" | "elm" | "maple" | "oak" | "palm";
privacy: "public" | "password" | "private";
status: "development" | "preview" | "production";
contact: {
name: string;
email: string | null;
} | null;
isHeaderDisplayed: boolean;
headerVariant: "default" | "floating" | "inline";
headerAlignment: "start" | "center" | "end";
isHeaderProjectDisplayed: boolean;
isFooterDisplayed: boolean;
isSidebarDisplayed: boolean;
headerSearchBarBoundElementUuid: string | null;
supportsThemeToggle: boolean;
defaultTheme: "light" | "dark" | null;
logoUrl: string | null;
itemPage: {
isMainContentDisplayed: boolean;
isDescriptionDisplayed: boolean;
isDocumentDisplayed: boolean;
isNotesDisplayed: boolean;
isEventsDisplayed: boolean;
isPeriodsDisplayed: boolean;
isPropertiesDisplayed: boolean;
isBibliographyDisplayed: boolean;
isPropertyValuesGrouped: boolean;
iiifViewer: "universal-viewer" | "clover";
};
options: {
contexts: PropertyContexts | null;
scopes: Array<Scope> | null;
labels: {
title: string | null;
};
};
};
};
/**
* Represents a webpage with its title, slug, properties, items and subpages
*/
type Webpage = {
title: string;
slug: string;
publicationDateTime: Date | null;
properties: {
displayedInHeader: boolean;
width: "full" | "large" | "narrow" | "default";
variant: "default" | "no-background";
backgroundImageUrl: string | null;
isBreadcrumbsDisplayed: boolean;
isSidebarDisplayed: boolean;
isHeaderSearchBarDisplayed: boolean;
cssStyles: {
default: Array<Style>;
tablet: Array<Style>;
mobile: Array<Style>;
};
};
items: Array<WebElement | WebBlock>;
webpages: Array<Webpage>;
};
/**
* Represents a title with its label and variant
*/
type WebTitle = {
label: string;
variant: "default" | "simple";
properties: {
isNameDisplayed: boolean;
isDescriptionDisplayed: boolean;
isDateDisplayed: boolean;
isCreatorsDisplayed: boolean;
isCountDisplayed: boolean;
};
};
/**
* Base properties for web elements
*/
type WebElement = {
uuid: string;
type: "element";
title: WebTitle;
cssStyles: {
default: Array<Style>;
tablet: Array<Style>;
mobile: Array<Style>;
};
} & WebElementComponent;
/**
* Union type of all possible web element components
*/
type WebElementComponent = {
component: "3d-viewer";
resourceId: string;
fileSize: number | null;
isInteractive: boolean;
isControlsDisplayed: boolean;
} | {
component: "advanced-search";
boundElementUuid: string | null;
href: string | null;
} | {
component: "annotated-document";
documentId: string;
} | {
component: "annotated-image";
imageUuid: string;
isFilterInputDisplayed: boolean;
isOptionsDisplayed: boolean;
isAnnotationHighlightsDisplayed: boolean;
isAnnotationTooltipsDisplayed: boolean;
} | {
component: "audio-player";
audioId: string;
isSpeedControlsDisplayed: boolean;
isVolumeControlsDisplayed: boolean;
isSeekBarDisplayed: boolean;
} | {
component: "bibliography";
itemUuids: Array<string>;
bibliographies: Array<Bibliography>;
layout: "long" | "short";
isSourceDocumentDisplayed: boolean;
} | {
component: "entries";
entriesId: string;
variant: "entry" | "item";
isFilterInputDisplayed: boolean;
} | {
component: "button";
variant: "default" | "transparent" | "link";
href: string;
isExternal: boolean;
label: string;
startIcon: string | null;
endIcon: string | null;
image: WebImage | null;
} | {
component: "collection";
collectionIds: Array<string>;
displayedProperties: Array<{
uuid: string;
label: string;
}> | null;
variant: "full" | "highlights";
itemVariant: "detailed" | "card" | "tile";
paginationVariant: "default" | "numeric";
layout: "image-top" | "image-bottom" | "image-start" | "image-end";
imageQuality: "high" | "low";
isSortDisplayed: boolean;
isUsingQueryParams: boolean;
filter: {
isSidebarDisplayed: boolean;
isResultsBarDisplayed: boolean;
isMapDisplayed: boolean;
isInputDisplayed: boolean;
isLimitedToTitleQuery: boolean;
isLimitedToLeafPropertyValues: boolean;
sidebarSort: "default" | "alphabetical";
};
options: {
attributeFilters: {
bibliographies: boolean;
periods: boolean;
};
scopes: Array<Scope> | null;
contexts: PropertyContexts | null;
labels: {
title: string | null;
};
};
} | {
component: "empty-space";
height: string | null;
width: string | null;
} | {
component: "iframe";
href: string;
height: string | null;
width: string | null;
} | {
component: "iiif-viewer";
iiifId: string;
variant: "universal-viewer" | "clover";
} | {
component: "image";
images: Array<WebImage>;
variant: "default" | "carousel" | "grid" | "hero";
width: number | null;
height: number | null;
isFullWidth: boolean;
isFullHeight: boolean;
imageQuality: "high" | "low";
captionSource: "name" | "abbreviation" | "description";
captionLayout: "top" | "bottom" | "inset" | "suppress";
altTextSource: "name" | "abbreviation" | "description";
isTransparentBackground: boolean;
isCover: boolean;
carouselOptions: {
secondsPerImage: number;
} | null;
heroOptions: {
isBackgroundImageDisplayed: boolean;
isDocumentDisplayed: boolean;
} | null;
} | {
component: "image-gallery";
galleryId: string;
isFilterInputDisplayed: boolean;
} | {
component: "map";
mapId: string;
customBasemap: string | null;
initialBounds: [[number, number], [number, number]] | null;
maximumBounds: [[number, number], [number, number]] | null;
isControlsDisplayed: boolean;
isInteractive: boolean;
isClustered: boolean;
isUsingPins: boolean;
isFullHeight: boolean;
} | {
component: "network-graph";
} | {
component: "query";
itemCategory: "resource" | "spatialUnit" | "concept" | "text" | null;
queries: Array<{
label: string;
propertyVariableUuids: Array<string>;
startIcon: string | null;
endIcon: string | null;
}>;
displayedProperties: Array<{
uuid: string;
label: string;
}> | null;
itemVariant: "detailed" | "card" | "tile";
paginationVariant: "default" | "numeric";
layout: "image-top" | "image-bottom" | "image-start" | "image-end";
} | {
component: "search-bar";
queryVariant: "submit" | "change";
placeholder: string | null;
baseFilterQueries: string | null;
boundElementUuid: string | null;
href: string | null;
} | {
component: "table";
tableId: string;
} | {
component: "text";
variant: {
name: "title" | "block" | "banner";
} | {
name: "paragraph";
size: "xs" | "sm" | "md" | "lg";
} | {
name: "label";
size: "xs" | "sm" | "md" | "lg" | "xl";
} | {
name: "heading";
size: "xs" | "sm" | "md" | "lg" | "xl" | "2xl";
} | {
name: "display";
size: "xs" | "sm" | "md" | "lg";
};
headingLevel: "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | null;
content: string;
} | {
component: "timeline";
timelineId: string;
} | {
component: "video";
isChaptersDisplayed: boolean;
};
/**
* Represents an image used in web elements
*/
type WebImage = {
uuid: string | null;
url: string;
label: string | null;
description: string | null;
width: number;
height: number;
};
/**
* Represents a CSS style with label and value
*/
type Style = {
label: string;
value: string;
};
type WebBlockLayout = "vertical" | "horizontal" | "grid" | "vertical-flex" | "horizontal-flex" | "accordion";
/**
* Represents a block of vertical or horizontal content alignment
*/
type WebBlock<T extends WebBlockLayout = WebBlockLayout> = {
uuid: string;
type: "block";
title: WebTitle;
items: T extends "accordion" ? Array<Extract<WebElement, {
component: "text";
}> & {
items: Array<WebElement | WebBlock>;
}> : Array<WebElement | WebBlock>;
properties: {
default: {
layout: T;
/**
* valid `gridTemplateColumns` or `gridTemplateRows` CSS property value
*/
spacing: string | undefined;
/**
* `gap` CSS property value
*/
gap: string | undefined;
isAccordionEnabled: T extends "accordion" ? boolean : never;
isAccordionExpandedByDefault: T extends "accordion" ? boolean : never;
isAccordionSidebarDisplayed: T extends "accordion" ? boolean : never;
};
tablet: Partial<WebBlock["properties"]["default"]> | null;
mobile: Partial<WebBlock["properties"]["default"]> | null;
};
cssStyles: {
default: Array<Style>;
tablet: Array<Style>;
mobile: Array<Style>;
};
};
//#endregion
//#region src/utils/fetchers/gallery.d.ts
/**
* Fetches and parses a gallery from the OCHRE API
*
* @param uuid - The UUID of the gallery
* @param filter - The filter to apply to the gallery
* @param page - The page number to fetch
* @param pageSize - The number of items per page
* @param options - The options for the fetch
* @param options.fetch - The fetch function to use
* @param options.version - The version of the OCHRE API to use
* @returns The parsed gallery or an error message if the fetch/parse fails
*/
declare function fetchGallery(uuid: string, filter: string, page: number, pageSize: number, options?: {
fetch?: (input: string | URL | globalThis.Request, init?: RequestInit) => Promise<Response>;
version?: ApiVersion;
}): Promise<{
item: Gallery | null;
error: null;
} | {
item: null;
error: string;
}>;
//#endregion
//#region src/utils/fetchers/item.d.ts
/**
* Fetches and parses an OCHRE item from the OCHRE API
*
* @param uuid - The UUID of the OCHRE item to fetch
* @returns Object containing the parsed OCHRE item, or an error message if the fetch/parse fails
*/
declare function fetchItem<T extends DataCategory = DataCategory, U extends DataCategory | Array<DataCategory> = (T extends "tree" ? Exclude<DataCategory, "tree"> : T extends "set" ? Array<DataCategory> : never)>(uuid: string, category?: T, itemCategories?: U, options?: {
fetch?: (input: string | URL | globalThis.Request, init?: RequestInit) => Promise<Response>;
version?: ApiVersion;
}): Promise<{
error: null;
item: Item<T, U>;
} | {
error: string;
item: never;
}>;
//#endregion
//#region src/utils/fetchers/items-by-property-values.d.ts
/**
* Fetches and parses items by property values from the OCHRE API
*
* @param params - The parameters for the fetch
* @param params.projectScopeUuid - The UUID of the project scope
* @param params.belongsToCollectionScopeUuids - The collection scope UUIDs to filter by
* @param params.propertyVariableUuids - The property variable UUIDs to query by
* @param params.propertyValues - The property values to query by
* @param params.page - The page number (1-indexed)
* @param params.pageSize - The number of items per page
* @param params.itemCategory - The category of the items to fetch
* @param params.includeChildItems - Whether to include child items of the same category
* @param categoryParams - The category parameters for the fetch
* @param categoryParams.category - The category of the items to fetch
* @param categoryParams.itemCategories - The categories of the items to fetch
* @param options - Options for the fetch
* @param options.fetch - The fetch function to use
* @param options.version - The version of the OCHRE API to use
* @returns The parsed items by property values or null if the fetch/parse fails
*/
declare function fetchItemsByPropertyValues<T extends DataCategory = DataCategory, U extends DataCategory | Array<DataCategory> = (T extends "tree" ? Exclude<DataCategory, "tree"> : T extends "set" ? Array<DataCategory> : never)>(params: {
projectScopeUuid: string;
belongsToCollectionScopeUuids: Array<string>;
propertyVariableUuids: Array<string>;
propertyValues: Array<{
dataType: Exclude<PropertyValueContentType, "coordinate">;
value: string;
}>;
page: number;
pageSize?: number;
itemCategory?: "resource" | "spatialUnit" | "concept" | "text";
includeChildItems?: boolean;
}, categoryParams?: {
category?: T;
itemCategories?: U;
}, options?: {
fetch?: (input: string | URL | globalThis.Request, init?: RequestInit) => Promise<Response>;
version?: ApiVersion;
}): Promise<{
totalCount: number;
page: number;
pageSize: number;
items: Array<Item<T, U>>;
error: null;
} | {
totalCount: null;
page: null;
pageSize: null;
items: null;
error: string;
}>;
//#endregion
//#region src/utils/fetchers/property-values-by-property-variables.d.ts
/**
* Fetches and parses property values by property variables from the OCHRE API
*
* @param params - The parameters for the fetch
* @param params.projectScopeUuid - The UUID of the project scope
* @param params.belongsToCollectionScopeUuids - The collection scope UUIDs to filter by
* @param params.propertyVariableUuids - The property variable UUIDs to query by
* @param options - Options for the fetch
* @param options.fetch - The fetch function to use
* @param options.version - The version of the OCHRE API to use
* @returns The parsed property values by property variables or null if the fetch/parse fails
*/
declare function fetchPropertyValuesByPropertyVariables(params: {
projectScopeUuid: string;
belongsToCollectionScopeUuids: Array<string>;
propertyVariableUuids: Array<string>;
}, options?: {
fetch?: (input: string | URL | globalThis.Request, init?: RequestInit) => Promise<Response>;
version?: ApiVersion;
}): Promise<{
items: Array<PropertyValueQueryItem> | null;
error: null;
} | {
items: null;
error: string;
}>;
//#endregion
//#region src/utils/fetchers/website.d.ts
/**
* Fetches and parses a website configuration from the OCHRE API
*
* @param abbreviation - The abbreviation identifier for the website
* @returns The parsed website configuration or null if the fetch/parse fails
*/
declare function fetchWebsite(abbreviation: string, options?: {
fetch?: (input: string | URL | globalThis.Request, init?: RequestInit) => Promise<Response>;
version?: ApiVersion;
}): Promise<[null, Website] | [string, null]>;
//#endregion
//#region src/utils/getters.d.ts
/**
* Options for property search operations
*/
type PropertyOptions = {
/** Whether to recursively search through nested properties */includeNestedProperties: boolean;
};
/**
* Finds a property by its UUID in an array of properties
*
* @param properties - Array of properties to search through
* @param uuid - The UUID to search for
* @param options - Search options, including whether to include nested properties
* @returns The matching Property object, or null if not found
*/
declare function getPropertyByUuid(properties: Array<Property>, uuid: string, options?: PropertyOptions): Property | null;
/**
* Retrieves all values for a property with the given UUID
*
* @param properties - Array of properties to search through
* @param uuid - The UUID to search for
* @param options - Search options, including whether to include nested properties
* @returns Array of property values as strings, or null if property not found
*/
declare function getPropertyValuesByUuid(properties: Array<Property>, uuid: string, options?: PropertyOptions): Array<string | number | boolean | Date | null> | null;
/**
* Gets the first value of a property with the given UUID
*
* @param properties - Array of properties to search through
* @param uuid - The UUID to search for
* @param options - Search options, including whether to include nested properties
* @returns The first property value as string, or null if property not found
*/
declare function getPropertyValueByUuid(properties: Array<Property>, uuid: string, options?: PropertyOptions): string | number | boolean | Date | null;
/**
* Finds a property by its label in an array of properties
*
* @param properties - Array of properties to search through
* @param label - The label to search for
* @param options - Search options, including whether to include nested properties
* @returns The matching Property object, or null if not found
*/
declare function getPropertyByLabel(properties: Array<Property>, label: string, options?: PropertyOptions): Property | null;
/**
* Retrieves all values for a property with the given label
*
* @param properties - Array of properties to search through
* @param label - The label to search for
* @param options - Search options, including whether to include nested properties
* @returns Array of property values as strings, or null if property not found
*/
declare function getPropertyValuesByLabel(properties: Array<Property>, label: string, options?: PropertyOptions): Array<string | number | boolean | Date | null> | null;
/**
* Gets the first value of a property with the given label
*
* @param properties - Array of properties to search through
* @param label - The label to search for
* @param options - Search options, including whether to include nested properties
* @returns The first property value as string, or null if property not found
*/
declare function getPropertyValueByLabel(properties: Array<Property>, label: string, options?: PropertyOptions): string | number | boolean | Date | null;
/**
* Gets all unique properties from an array of properties
*
* @param properties - Array of properties to get unique properties from
* @param options - Search options, including whether to include nested properties
* @returns Array of unique properties
*/
declare function getUniqueProperties(properties: Array<Property>, options?: PropertyOptions): Array<Property>;
/**
* Gets all unique property labels from an array of properties
*
* @param properties - Array of properties to get unique property labels from
* @param options - Search options, including whether to include nested properties
* @returns Array of unique property labels
*/
declare function getUniquePropertyLabels(properties: Array<Property>, options?: PropertyOptions): Array<string>;
/**
* Filters a property based on a label and value criteria
*
* @param property - The property to filter
* @param filter - Filter criteria containing label and value to match
* @param filter.label - The label to filter by
* @param filter.value - The value to filter by
* @param options - Search options, including whether to include nested properties
* @returns True if the property matches the filter criteria, false otherwise
*/
declare function filterProperties(property: Property, filter: {
label: string;
value: string | number | boolean | Date;
}, options?: PropertyOptions): boolean;
//#endregion
//#region src/utils/helpers.d.ts
/**
* The default API version to use
*
* @remarks
* Version 1 of the OCHRE API is deprecated and will be removed in the future.
* It points to the old Tamino server.
*
* Version 2 of the OCHRE API is the current version and is the default.
* It points to the new MarkLogic server.
*/
declare const DEFAULT_API_VERSION = 2;
/**
* The default page size to use for fetching paginated items
*/
declare const DEFAULT_PAGE_SIZE = 48;
/**
* Flatten the properties of an item
* @param item - The item whose properties to flatten
* @returns The item with the properties flattened
*/
declare function flattenItemProperties<T extends DataCategory = DataCategory, U extends DataCategory | Array<DataCategory> = (T extends "tree" ? Exclude<DataCategory, "tree"> : T extends "set" ? Array<DataCategory> : never)>(item: Item<T, U>): Item<T, U>;
/**
* Get the leaf property values from an array of property values
* @param propertyValues - The array of property values to get the leaf property values from
* @returns The array of leaf property values
*/
declare function getLeafPropertyValues<T extends PropertyValueContentType = PropertyValueContentType>(propertyValues: Array<PropertyValueContent<T>>): Array<PropertyValueContent<T>>;
//#endregion
export { ApiVersion, Bibliography, Concept, Context, ContextItem, ContextNode, Coordinate, DEFAULT_API_VERSION, DEFAULT_PAGE_SIZE, Data, DataCategory, Event, FileFormat, Gallery, Identification, Image, ImageMap, ImageMapArea, Interpretation, Item, LevelContext, LevelContextItem, License, Link, Metadata, Note, Observation, Period, Person, Property, PropertyContexts, PropertyValue, PropertyValueContent, PropertyValueContentType, PropertyValueQueryItem, PropertyVariable, Resource, Scope, Section, Set, SpatialUnit, Style, Text, Tree, UuidMetadata, WebBlock, WebBlockLayout, WebElement, WebElementComponent, WebImage, WebTitle, Webpage, Website, fetchGallery, fetchItem, fetchItemsByPropertyValues, fetchPropertyValuesByPropertyVariables, fetchWebsite, filterProperties, flattenItemProperties, getLeafPropertyValues, getPropertyByLabel, getPropertyByUuid, getPropertyValueByLabel, getPropertyValueByUuid, getPropertyValuesByLabel, getPropertyValuesByUuid, getUniqueProperties, getUniquePropertyLabels };