ochre-sdk 1.0.58 → 1.0.61

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.
@@ -1,5 +1,4 @@
1
1
  import { X2jOptions } from "fast-xml-parser";
2
-
3
2
  //#region src/constants.d.ts
4
3
  declare const XML_ARRAY_TAGS: ReadonlyArray<string>;
5
4
  declare const XML_PARSER_OPTIONS: X2jOptions;
@@ -1,6 +1,5 @@
1
1
  import { Gallery } from "../types/index.mjs";
2
2
  import { FetchBaseOptions, FetchLanguages } from "../parsers/helpers.mjs";
3
-
4
3
  //#region src/fetchers/gallery.d.ts
5
4
  /**
6
5
  * Fetches and parses a gallery from the OCHRE API
@@ -1,6 +1,5 @@
1
1
  import { ContainedItemCategoryFromOption, ContainedItemCategoryOption, Item, ItemCategory, ItemCategoryFromOption, ItemCategoryOption, ItemContainerCategory, SetItemCategory, TreeItemCategory } from "../types/index.mjs";
2
2
  import { FetchBaseOptions, FetchLanguages } from "../parsers/helpers.mjs";
3
-
4
3
  //#region src/fetchers/item-children.d.ts
5
4
  type FetchItemChildrenResult<TItems> = Promise<{
6
5
  items: TItems;
@@ -1,6 +1,5 @@
1
1
  import { ContainedItemCategoryFromOption, ContainedItemCategoryOption, Item, ItemCategory, ItemContainerCategory } from "../types/index.mjs";
2
2
  import { FetchBaseOptions, FetchLanguages } from "../parsers/helpers.mjs";
3
-
4
3
  //#region src/fetchers/item-links.d.ts
5
4
  /**
6
5
  * Fetches linked OCHRE items by source-item UUID.
@@ -1,6 +1,5 @@
1
1
  import { ContainedItemCategoryFromOption, ContainedItemCategoryOption, Item, ItemCategory, ItemCategoryFromOption, ItemCategoryOption, ItemCategoryWithEmbeddedItems, ItemContainerCategory, ItemWithoutEmbeddedItems } from "../types/index.mjs";
2
2
  import { FetchBaseOptions, FetchLanguages } from "../parsers/helpers.mjs";
3
-
4
3
  //#region src/fetchers/item.d.ts
5
4
  type FetchItemResult<TItem> = Promise<{
6
5
  item: TItem;
@@ -1,6 +1,5 @@
1
1
  import { Query, SetItem, SetItemCategory, SetItemsSort } from "../../types/index.mjs";
2
2
  import { FetchBaseOptions, FetchLanguages } from "../../parsers/helpers.mjs";
3
-
4
3
  //#region src/fetchers/set/items.d.ts
5
4
  type FetchSetItemsCategory<TContainedItemCategories extends ReadonlyArray<SetItemCategory> | undefined> = TContainedItemCategories extends ReadonlyArray<infer U> ? Extract<U, SetItemCategory> : SetItemCategory;
6
5
  /**
@@ -1,5 +1,4 @@
1
1
  import { PropertyValueQueryItem, Query, SetAttributeValueQueryItem } from "../../types/index.mjs";
2
-
3
2
  //#region src/fetchers/set/property-values.d.ts
4
3
  /**
5
4
  * Fetches and parses Set property values from the OCHRE API
@@ -1,6 +1,5 @@
1
1
  import { WebsiteMetadata } from "../types/website.mjs";
2
2
  import { FetchBaseOptions, FetchLanguages } from "../parsers/helpers.mjs";
3
-
4
3
  //#region src/fetchers/website-metadata.d.ts
5
4
  /**
6
5
  * Fetches and parses a page-scoped website metadata projection from the OCHRE
@@ -1,23 +1,36 @@
1
- import { Website } from "../types/website.mjs";
1
+ import { ProtectedWebsite, Website } from "../types/website.mjs";
2
2
  import { LanguageCodes } from "../types/index.mjs";
3
3
  import { FetchFunction } from "../parsers/helpers.mjs";
4
-
5
4
  //#region src/fetchers/website.d.ts
6
5
  /**
7
- * Fetches and parses a website configuration from the OCHRE API
6
+ * Fetches and parses a website configuration from the OCHRE API.
8
7
  *
9
- * @param abbreviation - The abbreviation identifier for the website
10
- * @returns The parsed website configuration or null if the fetch/parse fails
8
+ * For password-protected or OCHRE-credential-protected websites, if no credentials
9
+ * are provided the function returns a minimal `protectedWebsite` object instead of
10
+ * the full website. Pass `credentials` (a shared password string, or an object with
11
+ * `username` and `password` for OCHRE accounts) to authenticate and receive the full
12
+ * website data.
11
13
  */
12
14
  declare function fetchWebsite<const T extends LanguageCodes = LanguageCodes>(abbreviation: string, options?: {
13
15
  fetch?: FetchFunction;
14
16
  languages?: T;
17
+ credentials?: string | {
18
+ username: string;
19
+ password: string;
20
+ };
15
21
  }): Promise<{
16
22
  website: Website<T>;
23
+ protectedWebsite: null;
17
24
  error: null;
18
25
  detailedError: null;
19
26
  } | {
20
27
  website: null;
28
+ protectedWebsite: ProtectedWebsite<T>;
29
+ error: null;
30
+ detailedError: null;
31
+ } | {
32
+ website: null;
33
+ protectedWebsite: null;
21
34
  error: string;
22
35
  detailedError: string;
23
36
  }>;
@@ -6,30 +6,64 @@ import { parseWebsite } from "../parsers/website/index.mjs";
6
6
  import * as v from "valibot";
7
7
  import { XMLParser } from "fast-xml-parser";
8
8
  //#region src/fetchers/website.ts
9
+ async function validateWebsiteCredentials(uuid, credentials, fetcher) {
10
+ const security = typeof credentials === "string" ? { validate: credentials } : {
11
+ validate: credentials.password,
12
+ userOCHRE: credentials.username
13
+ };
14
+ return (await fetcher("https://ochre.lib.uchicago.edu/ochre/v2/ochre.php", {
15
+ method: "POST",
16
+ body: JSON.stringify({
17
+ uuid,
18
+ data: { security }
19
+ }),
20
+ headers: { "Content-Type": "application/json" }
21
+ })).ok;
22
+ }
9
23
  /**
10
- * Fetches and parses a website configuration from the OCHRE API
24
+ * Fetches and parses a website configuration from the OCHRE API.
11
25
  *
12
- * @param abbreviation - The abbreviation identifier for the website
13
- * @returns The parsed website configuration or null if the fetch/parse fails
26
+ * For password-protected or OCHRE-credential-protected websites, if no credentials
27
+ * are provided the function returns a minimal `protectedWebsite` object instead of
28
+ * the full website. Pass `credentials` (a shared password string, or an object with
29
+ * `username` and `password` for OCHRE accounts) to authenticate and receive the full
30
+ * website data.
14
31
  */
15
32
  async function fetchWebsite(abbreviation, options) {
16
33
  try {
34
+ const fetcher = options?.fetch ?? fetch;
17
35
  const cleanAbbreviation = abbreviation.trim().toLocaleLowerCase("en-US");
18
- const response = await (options?.fetch ?? fetch)(`https://ochre.lib.uchicago.edu/ochre/v2/ochre.php?xquery=${encodeURIComponent(`collection('ochre/tree')/ochre[tree/identification/abbreviation/content/string='${cleanAbbreviation}']`)}&xsl=none&lang="*"`);
36
+ const response = await fetcher(`https://ochre.lib.uchicago.edu/ochre/v2/ochre.php?xquery=${encodeURIComponent(`collection('ochre/tree')/ochre[tree/identification/abbreviation/content/string='${cleanAbbreviation}']`)}&xsl=none&lang="*"`);
19
37
  if (!response.ok) throw new Error("Failed to fetch website", { cause: response.statusText });
20
38
  const dataRaw = await response.text();
21
39
  const data = new XMLParser(XML_PARSER_OPTIONS).parse(dataRaw);
22
40
  const { success, issues, output } = v.safeParse(XMLWebsiteData, data);
23
41
  if (!success) throw createSchemaValidationError("Failed to parse website XML", issues);
24
42
  restoreXMLMetadata(output, data);
43
+ const website = parseWebsite(output, { languages: options?.languages });
44
+ if (website.properties.privacy !== "public") {
45
+ if (options?.credentials == null) return {
46
+ website: null,
47
+ protectedWebsite: {
48
+ uuid: website.uuid,
49
+ identification: website.identification,
50
+ properties: { privacy: website.properties.privacy }
51
+ },
52
+ error: null,
53
+ detailedError: null
54
+ };
55
+ if (!await validateWebsiteCredentials(website.uuid, options.credentials, fetcher)) throw new Error("Invalid credentials for protected website");
56
+ }
25
57
  return {
26
- website: parseWebsite(output, { languages: options?.languages }),
58
+ website,
59
+ protectedWebsite: null,
27
60
  error: null,
28
61
  detailedError: null
29
62
  };
30
63
  } catch (error) {
31
64
  return {
32
65
  website: null,
66
+ protectedWebsite: null,
33
67
  ...getErrorOutput(error, "Unknown error")
34
68
  };
35
69
  }
@@ -1,11 +1,12 @@
1
1
  import { LanguageCodes, Property, PropertyLike, PropertyValueContent, SetItemProperty, SetItemSimplifiedProperty, SimplifiedProperty } from "./types/index.mjs";
2
-
3
2
  //#region src/getters.d.ts
4
3
  /**
5
4
  * Options for property search operations.
6
5
  */
7
6
  type PropertyOptions = {
8
- /** Whether to recursively search through nested properties. */includeNestedProperties?: boolean; /** Whether to limit property values to leaf values. */
7
+ /** Whether to recursively search through nested properties. */
8
+ includeNestedProperties?: boolean;
9
+ /** Whether to limit property values to leaf values. */
9
10
  limitToLeafPropertyValues?: boolean;
10
11
  };
11
12
  type PropertyContent<T extends LanguageCodes> = PropertyValueContent<T>["content"];
@@ -1,5 +1,4 @@
1
1
  import { ContainedItemCategory, Item, ItemCategory, ItemPayloadKind, LanguageCodes, SetItemProperty } from "./types/index.mjs";
2
-
3
2
  //#region src/helpers.d.ts
4
3
  type FlattenedItem<U, T extends LanguageCodes> = Omit<U, "properties"> & {
5
4
  properties: Array<SetItemProperty<T>>;
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { MultilingualOptions, MultilingualString, MultilingualStringEntries, MultilingualStringEntry, MultilingualStringInput, MultilingualStringJSON, MultilingualStringObject, MultilingualStringText } from "./parsers/multilingual.mjs";
2
- import { AccordionWebBlock, ContextTree, ContextTreeFilterLevel, ContextTreeLevel, ContextTreeLevelItem, Scope, Style, StylesheetCategory, StylesheetItem, WebAccordionItem, WebBlock, WebBlockByLayout, WebBlockItem, WebBlockLayout, WebElement, WebElementComponent, WebElementComponentName, WebElementComponentOf, WebElementOf, WebImage, WebSidebar, WebTitle, Webpage, Website, WebsiteMetadata, WebsitePropertyQuery, WebsitePropertyQueryNode, WebsiteSegment, WebsiteType } from "./types/website.mjs";
2
+ import { AccordionWebBlock, ContextTree, ContextTreeFilterLevel, ContextTreeLevel, ContextTreeLevelItem, ProtectedWebsite, Scope, Style, StylesheetCategory, StylesheetItem, WebAccordionItem, WebBlock, WebBlockByLayout, WebBlockItem, WebBlockLayout, WebElement, WebElementComponent, WebElementComponentName, WebElementComponentOf, WebElementOf, WebImage, WebSidebar, WebTitle, Webpage, Website, WebsiteMetadata, WebsitePropertyQuery, WebsitePropertyQueryNode, WebsiteSegment, WebsiteType } from "./types/website.mjs";
3
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, Prettify, 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 { fetchItemChildren } from "./fetchers/item-children.mjs";
@@ -11,4 +11,4 @@ import { fetchWebsiteMetadata } from "./fetchers/website-metadata.mjs";
11
11
  import { fetchWebsite } from "./fetchers/website.mjs";
12
12
  import { PropertyOptions, filterProperties, getLeafPropertyValues, getPropertyByVariableLabel, getPropertyByVariableLabelAndValue, getPropertyByVariableLabelAndValueContent, getPropertyByVariableLabelAndValueContents, getPropertyByVariableLabelAndValues, getPropertyByVariableUuid, getPropertyValueByVariableLabel, getPropertyValueByVariableUuid, getPropertyValueContentByVariableLabel, getPropertyValueContentByVariableUuid, getPropertyValueContentsByVariableUuid, getPropertyValuesByVariableLabel, getPropertyValuesByVariableUuid, getUniqueProperties, getUniquePropertyVariableLabels } from "./getters.mjs";
13
13
  import { DEFAULT_PAGE_SIZE, flattenItemProperties } from "./helpers.mjs";
14
- 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 Prettify, 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 WebSidebar, type WebTitle, type Webpage, type Website, type WebsiteMetadata, type WebsitePropertyQuery, type WebsitePropertyQueryNode, type WebsiteSegment, type WebsiteType, defineLanguages, fetchGallery, fetchItem, fetchItemChildren, fetchItemLinks, fetchSetItems, fetchSetPropertyValues, fetchWebsite, fetchWebsiteMetadata, filterProperties, flattenItemProperties, getLeafPropertyValues, getPropertyByVariableLabel, getPropertyByVariableLabelAndValue, getPropertyByVariableLabelAndValueContent, getPropertyByVariableLabelAndValueContents, getPropertyByVariableLabelAndValues, getPropertyByVariableUuid, getPropertyValueByVariableLabel, getPropertyValueByVariableUuid, getPropertyValueContentByVariableLabel, getPropertyValueContentByVariableUuid, getPropertyValueContentsByVariableUuid, getPropertyValuesByVariableLabel, getPropertyValuesByVariableUuid, getUniqueProperties, getUniquePropertyVariableLabels, withLanguages };
14
+ 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 Prettify, type Property, type PropertyLike, PropertyOptions, type PropertyRelation, 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 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 WebSidebar, type WebTitle, type Webpage, type Website, type WebsiteMetadata, type WebsitePropertyQuery, type WebsitePropertyQueryNode, type WebsiteSegment, type WebsiteType, defineLanguages, fetchGallery, fetchItem, fetchItemChildren, fetchItemLinks, fetchSetItems, fetchSetPropertyValues, fetchWebsite, fetchWebsiteMetadata, filterProperties, flattenItemProperties, getLeafPropertyValues, getPropertyByVariableLabel, getPropertyByVariableLabelAndValue, getPropertyByVariableLabelAndValueContent, getPropertyByVariableLabelAndValueContents, getPropertyByVariableLabelAndValues, getPropertyByVariableUuid, getPropertyValueByVariableLabel, getPropertyValueByVariableUuid, getPropertyValueContentByVariableLabel, getPropertyValueContentByVariableUuid, getPropertyValueContentsByVariableUuid, getPropertyValuesByVariableLabel, getPropertyValuesByVariableUuid, getUniqueProperties, getUniquePropertyVariableLabels, withLanguages };
@@ -1,7 +1,6 @@
1
1
  import { MultilingualString } from "./multilingual.mjs";
2
2
  import { License } from "../types/index.mjs";
3
3
  import { XMLContent, XMLString } from "../xml/types.mjs";
4
-
5
4
  //#region src/parsers/helpers.d.ts
6
5
  type FetchFunction = (input: string | URL | globalThis.Request, init?: RequestInit) => Promise<Response>;
7
6
  type FetchBaseOptions<TLanguages extends ReadonlyArray<string> | undefined = undefined> = {
@@ -2,7 +2,6 @@ import { Webpage } from "../types/website.mjs";
2
2
  import { Bibliography, ContainedItemCategoryFromOption, ContainedItemCategoryOption, Gallery, Identification, Item, ItemCategory, ItemCategoryFromOption, ItemCategoryOption, ItemContainerCategory, ItemLinks, Metadata, Note, Person, Property, Resource, SetItem, SetItemCategory, SimplifiedProperty } from "../types/index.mjs";
3
3
  import { XMLBibliography, XMLData, XMLDataItem, XMLGalleryData, XMLIdentification, XMLItemLinks, XMLLink, XMLMetadata, XMLNote, XMLPerson, XMLProperty, XMLResource, XMLSetItems, XMLSimplifiedProperty } from "../xml/types.mjs";
4
4
  import { ParserOptions, getParserOptions, parseStringLike } from "./helpers.mjs";
5
-
6
5
  //#region src/parsers/index.d.ts
7
6
  type RawOchre = XMLData["result"]["ochre"];
8
7
  type ResourceViewParser<T extends ReadonlyArray<string>> = (view: XMLResource["view"], context: Pick<Resource<T, "topLevel">, "belongsTo" | "metadata">) => Webpage<T> | null;
@@ -26,8 +26,11 @@ type MultilingualStringEntries<T extends ReadonlyArray<string> = ReadonlyArray<s
26
26
  * Options for creating and working with multilingual strings
27
27
  */
28
28
  type MultilingualOptions = {
29
- /** Default language to use for fallbacks */defaultLanguage?: string; /** Available languages for this string */
30
- availableLanguages?: ReadonlyArray<string>; /** Alias values carried by OCHRE as zxx content */
29
+ /** Default language to use for fallbacks */
30
+ defaultLanguage?: string;
31
+ /** Available languages for this string */
32
+ availableLanguages?: ReadonlyArray<string>;
33
+ /** Alias values carried by OCHRE as zxx content */
31
34
  aliases?: ReadonlyArray<string>;
32
35
  };
33
36
  type MultilingualContent<T extends ReadonlyArray<string>> = Partial<Record<T[number], ReadonlyArray<MultilingualStringEntry>>>;
@@ -1,6 +1,5 @@
1
1
  import { MultilingualString, MultilingualStringText } from "./multilingual.mjs";
2
2
  import { XMLContent, XMLString } from "../xml/types.mjs";
3
-
4
3
  //#region src/parsers/string.d.ts
5
4
  declare function transformPermanentIdentificationUrl(url: string): string;
6
5
  declare function parseXMLString(string: XMLString): MultilingualStringText;
@@ -1,7 +1,6 @@
1
1
  import { Webpage, Website } from "../../types/website.mjs";
2
2
  import { XMLWebsiteData, XMLWebsiteResource } from "../../xml/types.mjs";
3
3
  import { ParserOptions } from "../helpers.mjs";
4
-
5
4
  //#region src/parsers/website/index.d.ts
6
5
  /**
7
6
  * Parses raw bounds data into a standardized bounds structure
@@ -1,7 +1,6 @@
1
1
  import { MultilingualString } from "../multilingual.mjs";
2
2
  import { LanguageCodes, PropertyValueContent, SimplifiedProperty } from "../../types/index.mjs";
3
3
  import { ParserOptions } from "../helpers.mjs";
4
-
5
4
  //#region src/parsers/website/reader.d.ts
6
5
  type WebsitePropertyContent<T extends LanguageCodes> = PropertyValueContent<T>["content"];
7
6
  declare class WebsitePresentationReader<T extends LanguageCodes> {
package/dist/query.d.mts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { Query } from "./types/index.mjs";
2
-
3
2
  //#region src/query.d.ts
4
3
  declare function buildAndCtsQueryExpression(queryExpressions: Array<string>): string | null;
5
4
  declare function buildBelongsToCollectionQueryExpression(belongsToCollectionScopeUuids: Array<string>, belongsToCollectionPropertyVariableUuid: string): string | null;
@@ -1,6 +1,5 @@
1
1
  import { Query } from "./types/index.mjs";
2
2
  import * as v from "valibot";
3
-
4
3
  //#region src/schemas.d.ts
5
4
  /**
6
5
  * Schema for validating UUIDs
@@ -1,8 +1,7 @@
1
1
  import { MultilingualString } from "../parsers/multilingual.mjs";
2
2
  import { Webpage } from "./website.mjs";
3
-
4
3
  //#region src/types/index.d.ts
5
- type Prettify<T> = { [K in keyof T]: T[K] } & {};
4
+ type Prettify<T> = { [K in keyof T]: T[K]; } & {};
6
5
  /**
7
6
  * Language-code tuple or array used by OCHRE multilingual fields.
8
7
  *
@@ -511,7 +510,7 @@ type Set<U extends SetItemCategory = SetItemCategory, T extends LanguageCodes =
511
510
  properties: Array<Property<T>>;
512
511
  items: Array<SetItem<U, T>>;
513
512
  }>;
514
- type SetBibliography<T extends LanguageCodes = LanguageCodes> = Bibliography<T, "embedded"> extends infer U ? U extends {
513
+ type SetBibliography<T extends LanguageCodes = LanguageCodes> = Bibliography<T, "embedded"> extends (infer U) ? U extends {
515
514
  properties: Array<Property<T>>;
516
515
  } ? Prettify<Omit<U, "properties" | "items"> & {
517
516
  properties: Array<SetItemProperty<T>>;
@@ -1,6 +1,5 @@
1
1
  import { MultilingualString } from "../parsers/multilingual.mjs";
2
2
  import { Bibliography, Identification, ItemCategory, LanguageCodes, License, Metadata, Person, Prettify, QueryablePropertyValueDataType } from "./index.mjs";
3
-
4
3
  //#region src/types/website.d.ts
5
4
  /**
6
5
  * Represents a context tree level item with a variable and value
@@ -126,7 +125,7 @@ type Website<T extends LanguageCodes = LanguageCodes> = {
126
125
  type: WebsiteType;
127
126
  status: "development" | "preview" | "production";
128
127
  versionLabel: "experimental" | "alpha" | "beta" | "test" | "staging" | "pre-release" | "release";
129
- privacy: "public" | "password" | "private";
128
+ privacy: "public" | "password" | "password-ochre";
130
129
  contact: {
131
130
  name: string;
132
131
  email: string | null;
@@ -527,5 +526,12 @@ type WebsiteMetadata<T extends LanguageCodes = LanguageCodes> = {
527
526
  };
528
527
  };
529
528
  };
529
+ type ProtectedWebsite<T extends LanguageCodes = LanguageCodes> = {
530
+ uuid: string;
531
+ identification: Identification<T>;
532
+ properties: {
533
+ privacy: "password" | "password-ochre";
534
+ };
535
+ };
530
536
  //#endregion
531
- export { AccordionWebBlock, ContextTree, ContextTreeFilterLevel, ContextTreeLevel, ContextTreeLevelItem, Scope, Style, StylesheetCategory, StylesheetItem, WebAccordionItem, WebBlock, WebBlockByLayout, WebBlockItem, WebBlockLayout, WebElement, WebElementComponent, WebElementComponentName, WebElementComponentOf, WebElementOf, WebImage, WebSidebar, WebTitle, Webpage, Website, WebsiteMetadata, WebsitePropertyQuery, WebsitePropertyQueryNode, WebsiteSegment, WebsiteType };
537
+ export { AccordionWebBlock, ContextTree, ContextTreeFilterLevel, ContextTreeLevel, ContextTreeLevelItem, ProtectedWebsite, Scope, Style, StylesheetCategory, StylesheetItem, WebAccordionItem, WebBlock, WebBlockByLayout, WebBlockItem, WebBlockLayout, WebElement, WebElementComponent, WebElementComponentName, WebElementComponentOf, WebElementOf, WebImage, WebSidebar, WebTitle, Webpage, Website, WebsiteMetadata, WebsitePropertyQuery, WebsitePropertyQueryNode, WebsiteSegment, WebsiteType };
@@ -1,6 +1,5 @@
1
1
  import { LanguageCodes, Property, SetItemProperty } from "./types/index.mjs";
2
2
  import * as v from "valibot";
3
-
4
3
  //#region src/utilities.d.ts
5
4
  type SchemaValidationIssue = v.BaseIssue<unknown>;
6
5
  declare function getErrorOutput(error: unknown, fallbackMessage: string): {
@@ -1,6 +1,5 @@
1
1
  import { XMLData as XMLData$1, XMLDataItem as XMLDataItem$1, XMLGalleryData as XMLGalleryData$1, XMLItemLinksData as XMLItemLinksData$1, XMLLink as XMLLink$1, XMLSetItemsData as XMLSetItemsData$1, XMLWebsiteData as XMLWebsiteData$1 } from "./types.mjs";
2
2
  import * as v from "valibot";
3
-
4
3
  //#region src/xml/schemas.d.ts
5
4
  declare const XMLLink: v.GenericSchema<unknown, XMLLink$1>;
6
5
  declare const XMLDataItem: v.GenericSchema<unknown, XMLDataItem$1>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ochre-sdk",
3
- "version": "1.0.58",
3
+ "version": "1.0.61",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "Node.js library for working with OCHRE (Online Cultural and Historical Research Environment) data",
@@ -46,20 +46,20 @@
46
46
  ],
47
47
  "dependencies": {
48
48
  "date-fns": "^4.4.0",
49
- "fast-equals": "^6.0.0",
50
- "fast-xml-parser": "^5.9.3",
49
+ "fast-equals": "^6.0.2",
50
+ "fast-xml-parser": "^5.10.0",
51
51
  "valibot": "^1.4.2"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@antfu/eslint-config": "^9.1.0",
55
- "@types/node": "^24.13.2",
55
+ "@types/node": "^24.13.3",
56
56
  "bumpp": "^11.1.0",
57
- "eslint": "^10.6.0",
58
- "knip": "^6.23.0",
59
- "oxfmt": "^0.56.0",
60
- "tsdown": "^0.22.3",
57
+ "eslint": "^10.7.0",
58
+ "knip": "^6.26.0",
59
+ "oxfmt": "^0.58.0",
60
+ "tsdown": "^0.22.7",
61
61
  "typescript": "^6.0.3",
62
- "vitest": "^4.1.9"
62
+ "vitest": "^4.1.10"
63
63
  },
64
64
  "scripts": {
65
65
  "dev": "tsdown src/index.ts --watch",