@digitalculture/ochre-sdk 0.11.29 → 0.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -524,6 +524,7 @@ type LevelContext = {
524
524
  */
525
525
  type Website = {
526
526
  uuid: string;
527
+ version: 1 | 2;
527
528
  publicationDateTime: Date | null;
528
529
  identification: Identification;
529
530
  project: {
@@ -545,33 +546,6 @@ type Website = {
545
546
  };
546
547
  } | null;
547
548
  properties: WebsiteProperties;
548
- searchOptions: {
549
- filters: Array<{
550
- uuid: string;
551
- type: string;
552
- }>;
553
- attributeFilters: {
554
- bibliographies: boolean;
555
- periods: boolean;
556
- };
557
- scopes: Array<{
558
- uuid: string;
559
- type: string;
560
- identification: Identification;
561
- }>;
562
- };
563
- globalOptions: {
564
- contexts: {
565
- flatten: Array<LevelContext>;
566
- suppress: Array<LevelContext>;
567
- filter: Array<LevelContext>;
568
- sort: Array<LevelContext>;
569
- detail: Array<LevelContext>;
570
- download: Array<LevelContext>;
571
- label: Array<LevelContext>;
572
- prominent: Array<LevelContext>;
573
- };
574
- };
575
549
  };
576
550
  /**
577
551
  * Properties for configuring website display and styling
@@ -691,6 +665,27 @@ type WebElementComponent = {
691
665
  isFilterDisplayed: boolean;
692
666
  filterSort: "default" | "alphabetical";
693
667
  layout: "image-top" | "image-bottom" | "image-start" | "image-end";
668
+ options: {
669
+ attributeFilters: {
670
+ bibliographies: boolean;
671
+ periods: boolean;
672
+ };
673
+ scopes: Array<{
674
+ uuid: string;
675
+ type: string;
676
+ identification: Identification;
677
+ }>;
678
+ contexts: {
679
+ flatten: Array<LevelContext>;
680
+ suppress: Array<LevelContext>;
681
+ filter: Array<LevelContext>;
682
+ sort: Array<LevelContext>;
683
+ detail: Array<LevelContext>;
684
+ download: Array<LevelContext>;
685
+ label: Array<LevelContext>;
686
+ prominent: Array<LevelContext>;
687
+ };
688
+ };
694
689
  } | {
695
690
  component: "empty-space";
696
691
  height: string | null;
@@ -915,7 +910,10 @@ declare function fetchGallery(uuid: string, filter: string, page: number, perPag
915
910
  *
916
911
  * If the fetch/parse fails, the returned object will have an `error` property.
917
912
  */
918
- declare function fetchItem<T extends DataCategory, U extends DataCategory>(uuid: string, category?: T, setCategory?: T extends "set" ? U : never, customFetch?: (input: string | URL | globalThis.Request, init?: RequestInit) => Promise<Response>): Promise<{
913
+ declare function fetchItem<T extends DataCategory, U extends DataCategory>(uuid: string, category?: T, setCategory?: T extends "set" ? U : never, options?: {
914
+ customFetch?: (input: string | URL | globalThis.Request, init?: RequestInit) => Promise<Response>;
915
+ isVersion2: boolean;
916
+ }): Promise<{
919
917
  error: null;
920
918
  metadata: Metadata;
921
919
  belongsTo: {
@@ -938,7 +936,9 @@ declare function fetchItem<T extends DataCategory, U extends DataCategory>(uuid:
938
936
  *
939
937
  * @param scopeUuids - The scope UUIDs to filter by
940
938
  * @param propertyUuids - The property UUIDs to query by
941
- * @param customFetch - A custom fetch function to use instead of the default fetch
939
+ * @param options - Options for the fetch
940
+ * @param options.customFetch - A custom fetch function to use instead of the default fetch
941
+ * @param options.isVersion2 - Whether to use the v2 API
942
942
  * @returns The parsed property query or null if the fetch/parse fails
943
943
  *
944
944
  * @example
@@ -955,7 +955,10 @@ declare function fetchItem<T extends DataCategory, U extends DataCategory>(uuid:
955
955
  * The returned property query includes:
956
956
  * - Property items
957
957
  */
958
- declare function fetchPropertyQuery(scopeUuids: Array<string>, propertyUuids: Array<string>, customFetch?: (input: string | URL | globalThis.Request, init?: RequestInit) => Promise<Response>): Promise<{
958
+ declare function fetchPropertyQuery(scopeUuids: Array<string>, propertyUuids: Array<string>, options?: {
959
+ customFetch?: (input: string | URL | globalThis.Request, init?: RequestInit) => Promise<Response>;
960
+ isVersion2?: boolean;
961
+ }): Promise<{
959
962
  items: Array<PropertyQueryItem> | null;
960
963
  error: null;
961
964
  } | {
@@ -1015,7 +1018,10 @@ declare function fetchByUuidMetadata(uuid: string, customFetch?: (input: string
1015
1018
  *
1016
1019
  * The abbreviation is case-insensitive and should match the website's configured abbreviation in OCHRE.
1017
1020
  */
1018
- declare function fetchWebsite(abbreviation: string, customFetch?: (input: string | URL | globalThis.Request, init?: RequestInit) => Promise<Response>): Promise<[null, Website] | [string, null]>;
1021
+ declare function fetchWebsite(abbreviation: string, options?: {
1022
+ customFetch?: (input: string | URL | globalThis.Request, init?: RequestInit) => Promise<Response>;
1023
+ isVersion2?: boolean;
1024
+ }): Promise<[null, Website] | [string, null]>;
1019
1025
  //#endregion
1020
1026
  //#region src/utils/getters.d.ts
1021
1027
  /**
package/dist/index.mjs CHANGED
@@ -1,4 +1,5 @@
1
- import { z } from "zod";
1
+ import * as z from "zod";
2
+ import { writeFileSync } from "node:fs";
2
3
 
3
4
  //#region src/schemas.ts
4
5
  /**
@@ -1801,6 +1802,47 @@ function parseWebElementProperties(componentProperty, elementResource) {
1801
1802
  filterSort ??= "default";
1802
1803
  let layout = getPropertyValueByLabel(componentProperty.properties, "layout");
1803
1804
  layout ??= "image-start";
1805
+ const options = {
1806
+ attributeFilters: {
1807
+ bibliographies: elementResource.options?.filterBibliography ?? false,
1808
+ periods: elementResource.options?.filterPeriods ?? false
1809
+ },
1810
+ scopes: elementResource.options?.scopes != null ? (Array.isArray(elementResource.options.scopes.scope) ? elementResource.options.scopes.scope : [elementResource.options.scopes.scope]).map((scope) => ({
1811
+ uuid: scope.uuid.content,
1812
+ type: scope.uuid.type,
1813
+ identification: parseIdentification(scope.identification)
1814
+ })) : [],
1815
+ contexts: {
1816
+ flatten: [],
1817
+ filter: [],
1818
+ sort: [],
1819
+ detail: [],
1820
+ download: [],
1821
+ label: [],
1822
+ suppress: [],
1823
+ prominent: []
1824
+ }
1825
+ };
1826
+ if ("options" in elementResource && elementResource.options) {
1827
+ const flattenContextsRaw = elementResource.options.flattenContexts != null ? Array.isArray(elementResource.options.flattenContexts) ? elementResource.options.flattenContexts : [elementResource.options.flattenContexts] : [];
1828
+ const suppressContextsRaw = elementResource.options.suppressContexts != null ? Array.isArray(elementResource.options.suppressContexts) ? elementResource.options.suppressContexts : [elementResource.options.suppressContexts] : [];
1829
+ const filterContextsRaw = elementResource.options.filterContexts != null ? Array.isArray(elementResource.options.filterContexts) ? elementResource.options.filterContexts : [elementResource.options.filterContexts] : [];
1830
+ const sortContextsRaw = elementResource.options.sortContexts != null ? Array.isArray(elementResource.options.sortContexts) ? elementResource.options.sortContexts : [elementResource.options.sortContexts] : [];
1831
+ const detailContextsRaw = elementResource.options.detailContexts != null ? Array.isArray(elementResource.options.detailContexts) ? elementResource.options.detailContexts : [elementResource.options.detailContexts] : [];
1832
+ const downloadContextsRaw = elementResource.options.downloadContexts != null ? Array.isArray(elementResource.options.downloadContexts) ? elementResource.options.downloadContexts : [elementResource.options.downloadContexts] : [];
1833
+ const labelContextsRaw = elementResource.options.labelContexts != null ? Array.isArray(elementResource.options.labelContexts) ? elementResource.options.labelContexts : [elementResource.options.labelContexts] : [];
1834
+ const prominentContextsRaw = elementResource.options.prominentContexts != null ? Array.isArray(elementResource.options.prominentContexts) ? elementResource.options.prominentContexts : [elementResource.options.prominentContexts] : [];
1835
+ options.contexts = {
1836
+ flatten: parseContexts(flattenContextsRaw),
1837
+ filter: parseContexts(filterContextsRaw),
1838
+ sort: parseContexts(sortContextsRaw),
1839
+ detail: parseContexts(detailContextsRaw),
1840
+ download: parseContexts(downloadContextsRaw),
1841
+ label: parseContexts(labelContextsRaw),
1842
+ suppress: parseContexts(suppressContextsRaw),
1843
+ prominent: parseContexts(prominentContextsRaw)
1844
+ };
1845
+ }
1804
1846
  properties.collectionId = collectionLink.uuid;
1805
1847
  properties.variant = variant;
1806
1848
  properties.itemVariant = itemVariant;
@@ -1809,6 +1851,7 @@ function parseWebElementProperties(componentProperty, elementResource) {
1809
1851
  properties.isFilterDisplayed = isFilterDisplayed;
1810
1852
  properties.filterSort = filterSort;
1811
1853
  properties.layout = layout;
1854
+ properties.options = options;
1812
1855
  break;
1813
1856
  }
1814
1857
  case "empty-space": {
@@ -2627,72 +2670,27 @@ function parseContexts(contexts) {
2627
2670
  }
2628
2671
  return contextsParsed;
2629
2672
  }
2630
- function parseWebsite(websiteTree, projectName, website) {
2673
+ function parseWebsite(websiteTree, projectName, website$1, { isVersion2 = false } = {}) {
2631
2674
  if (!websiteTree.properties) throw new Error("Website properties not found");
2632
2675
  const properties = parseWebsiteProperties(Array.isArray(websiteTree.properties.property) ? websiteTree.properties.property : [websiteTree.properties.property]);
2633
2676
  if (typeof websiteTree.items === "string" || !("resource" in websiteTree.items)) throw new Error("Website pages not found");
2634
2677
  const resources = Array.isArray(websiteTree.items.resource) ? websiteTree.items.resource : [websiteTree.items.resource];
2635
2678
  const pages = parseWebpages(resources);
2636
2679
  const sidebar = parseSidebar(resources);
2637
- let globalOptions = { contexts: {
2638
- flatten: [],
2639
- filter: [],
2640
- sort: [],
2641
- detail: [],
2642
- download: [],
2643
- label: [],
2644
- suppress: [],
2645
- prominent: []
2646
- } };
2647
- if (websiteTree.websiteOptions) {
2648
- const flattenContextsRaw = websiteTree.websiteOptions.flattenContexts != null ? Array.isArray(websiteTree.websiteOptions.flattenContexts) ? websiteTree.websiteOptions.flattenContexts : [websiteTree.websiteOptions.flattenContexts] : [];
2649
- const suppressContextsRaw = websiteTree.websiteOptions.suppressContexts != null ? Array.isArray(websiteTree.websiteOptions.suppressContexts) ? websiteTree.websiteOptions.suppressContexts : [websiteTree.websiteOptions.suppressContexts] : [];
2650
- const filterContextsRaw = websiteTree.websiteOptions.filterContexts != null ? Array.isArray(websiteTree.websiteOptions.filterContexts) ? websiteTree.websiteOptions.filterContexts : [websiteTree.websiteOptions.filterContexts] : [];
2651
- const sortContextsRaw = websiteTree.websiteOptions.sortContexts != null ? Array.isArray(websiteTree.websiteOptions.sortContexts) ? websiteTree.websiteOptions.sortContexts : [websiteTree.websiteOptions.sortContexts] : [];
2652
- const detailContextsRaw = websiteTree.websiteOptions.detailContexts != null ? Array.isArray(websiteTree.websiteOptions.detailContexts) ? websiteTree.websiteOptions.detailContexts : [websiteTree.websiteOptions.detailContexts] : [];
2653
- const downloadContextsRaw = websiteTree.websiteOptions.downloadContexts != null ? Array.isArray(websiteTree.websiteOptions.downloadContexts) ? websiteTree.websiteOptions.downloadContexts : [websiteTree.websiteOptions.downloadContexts] : [];
2654
- const labelContextsRaw = websiteTree.websiteOptions.labelContexts != null ? Array.isArray(websiteTree.websiteOptions.labelContexts) ? websiteTree.websiteOptions.labelContexts : [websiteTree.websiteOptions.labelContexts] : [];
2655
- const prominentContextsRaw = websiteTree.websiteOptions.prominentContexts != null ? Array.isArray(websiteTree.websiteOptions.prominentContexts) ? websiteTree.websiteOptions.prominentContexts : [websiteTree.websiteOptions.prominentContexts] : [];
2656
- globalOptions = { contexts: {
2657
- flatten: parseContexts(flattenContextsRaw),
2658
- filter: parseContexts(filterContextsRaw),
2659
- sort: parseContexts(sortContextsRaw),
2660
- detail: parseContexts(detailContextsRaw),
2661
- download: parseContexts(downloadContextsRaw),
2662
- label: parseContexts(labelContextsRaw),
2663
- suppress: parseContexts(suppressContextsRaw),
2664
- prominent: parseContexts(prominentContextsRaw)
2665
- } };
2666
- }
2667
2680
  return {
2668
2681
  uuid: websiteTree.uuid,
2682
+ version: isVersion2 ? 2 : 1,
2669
2683
  publicationDateTime: websiteTree.publicationDateTime ? new Date(websiteTree.publicationDateTime) : null,
2670
2684
  identification: parseIdentification(websiteTree.identification),
2671
2685
  project: {
2672
2686
  name: parseFakeString(projectName),
2673
- website: website !== null ? parseFakeString(website) : null
2687
+ website: website$1 !== null ? parseFakeString(website$1) : null
2674
2688
  },
2675
2689
  creators: websiteTree.creators ? parsePersons(Array.isArray(websiteTree.creators.creator) ? websiteTree.creators.creator : [websiteTree.creators.creator]) : [],
2676
2690
  license: parseLicense(websiteTree.availability),
2677
2691
  sidebar,
2678
2692
  pages,
2679
- properties,
2680
- searchOptions: {
2681
- filters: websiteTree.searchOptions?.filterUuids != null ? (Array.isArray(websiteTree.searchOptions.filterUuids.uuid) ? websiteTree.searchOptions.filterUuids.uuid : [websiteTree.searchOptions.filterUuids.uuid]).map((uuid) => ({
2682
- uuid: uuid.content,
2683
- type: uuid.type
2684
- })) : [],
2685
- attributeFilters: {
2686
- bibliographies: websiteTree.searchOptions?.filterUuids?.filterBibliography ?? false,
2687
- periods: websiteTree.searchOptions?.filterUuids?.filterPeriods ?? false
2688
- },
2689
- scopes: websiteTree.searchOptions?.scopes != null ? (Array.isArray(websiteTree.searchOptions.scopes.scope) ? websiteTree.searchOptions.scopes.scope : [websiteTree.searchOptions.scopes.scope]).map((scope) => ({
2690
- uuid: scope.uuid.content,
2691
- type: scope.uuid.type,
2692
- identification: parseIdentification(scope.identification)
2693
- })) : []
2694
- },
2695
- globalOptions
2693
+ properties
2696
2694
  };
2697
2695
  }
2698
2696
 
@@ -2783,10 +2781,12 @@ async function fetchGallery(uuid, filter, page, perPage, customFetch) {
2783
2781
  *
2784
2782
  * @internal
2785
2783
  */
2786
- async function fetchByUuid(uuid, customFetch) {
2784
+ async function fetchByUuid(uuid, options) {
2787
2785
  try {
2786
+ const customFetch = options?.customFetch;
2787
+ const isVersion2 = options?.isVersion2 ?? false;
2788
2788
  const parsedUuid = uuidSchema.parse(uuid);
2789
- const response = await (customFetch ?? fetch)(`https://ochre.lib.uchicago.edu/ochre?uuid=${parsedUuid}&format=json&lang="*"`);
2789
+ const response = await (customFetch ?? fetch)(isVersion2 ? `https://ochre.lib.uchicago.edu/ochre/v2/ochre.php?uuid=${parsedUuid}&format=json&lang="*"` : `https://ochre.lib.uchicago.edu/ochre?uuid=${parsedUuid}&format=json&lang="*"`);
2790
2790
  if (!response.ok) throw new Error("Failed to fetch OCHRE data");
2791
2791
  const dataRaw = await response.json();
2792
2792
  if (!("ochre" in dataRaw)) throw new Error("Invalid OCHRE data: API response missing 'ochre' key");
@@ -2831,9 +2831,13 @@ async function fetchByUuid(uuid, customFetch) {
2831
2831
  *
2832
2832
  * If the fetch/parse fails, the returned object will have an `error` property.
2833
2833
  */
2834
- async function fetchItem(uuid, category, setCategory, customFetch) {
2834
+ async function fetchItem(uuid, category, setCategory, options) {
2835
2835
  try {
2836
- const [error, data] = await fetchByUuid(uuid, customFetch);
2836
+ const customFetch = options?.customFetch;
2837
+ const [error, data] = await fetchByUuid(uuid, {
2838
+ customFetch,
2839
+ isVersion2: options?.isVersion2 ?? false
2840
+ });
2837
2841
  if (error !== null) throw new Error(error);
2838
2842
  const categoryKey = getItemCategory(Object.keys(data.ochre));
2839
2843
  let item;
@@ -2897,11 +2901,17 @@ async function fetchItem(uuid, category, setCategory, customFetch) {
2897
2901
  }
2898
2902
  }
2899
2903
 
2904
+ //#endregion
2905
+ //#region src/constants.ts
2906
+ /**
2907
+ * The UUID of the `<unassigned>` property value in OCHRE
2908
+ */
2909
+ const UNASSIGNED_UUID = "e28e29af-b663-c0ac-ceb6-11a688fca0dd";
2910
+
2900
2911
  //#endregion
2901
2912
  //#region src/utils/fetchers/property-query.ts
2902
2913
  const PROJECT_SCOPE = "0c0aae37-7246-495b-9547-e25dbf5b99a3";
2903
2914
  const BELONG_TO_COLLECTION_UUID = "30054cb2-909a-4f34-8db9-8fe7369d691d";
2904
- const UNASSIGNED_UUID = "e28e29af-b663-c0ac-ceb6-11a688fca0dd";
2905
2915
  /**
2906
2916
  * Check if a string is a valid UUID
2907
2917
  * @param value - The string to check
@@ -2955,7 +2965,9 @@ return <item>
2955
2965
  *
2956
2966
  * @param scopeUuids - The scope UUIDs to filter by
2957
2967
  * @param propertyUuids - The property UUIDs to query by
2958
- * @param customFetch - A custom fetch function to use instead of the default fetch
2968
+ * @param options - Options for the fetch
2969
+ * @param options.customFetch - A custom fetch function to use instead of the default fetch
2970
+ * @param options.isVersion2 - Whether to use the v2 API
2959
2971
  * @returns The parsed property query or null if the fetch/parse fails
2960
2972
  *
2961
2973
  * @example
@@ -2972,10 +2984,12 @@ return <item>
2972
2984
  * The returned property query includes:
2973
2985
  * - Property items
2974
2986
  */
2975
- async function fetchPropertyQuery(scopeUuids, propertyUuids, customFetch) {
2987
+ async function fetchPropertyQuery(scopeUuids, propertyUuids, options) {
2976
2988
  try {
2989
+ const customFetch = options?.customFetch;
2990
+ const isVersion2 = options?.isVersion2 ?? false;
2977
2991
  const xquery = buildXQuery(scopeUuids, propertyUuids);
2978
- const response = await (customFetch ?? fetch)(`https://ochre.lib.uchicago.edu/ochre?xquery=${encodeURIComponent(xquery)}&format=json`);
2992
+ const response = await (customFetch ?? fetch)(isVersion2 ? `https://ochre.lib.uchicago.edu/ochre/v2/ochre.php?xquery=${encodeURIComponent(xquery)}&format=json&lang="*"` : `https://ochre.lib.uchicago.edu/ochre?xquery=${encodeURIComponent(xquery)}&format=json&lang="*"`);
2979
2993
  if (!response.ok) throw new Error(`OCHRE API responded with status: ${response.status}`);
2980
2994
  const data = await response.json();
2981
2995
  const parsedResultRaw = responseSchema.parse(data);
@@ -3078,6 +3092,7 @@ const KNOWN_ABBREVIATIONS = {
3078
3092
  ssmc: "8ff977dd-d440-40f5-ad93-8ad7e2d39e74",
3079
3093
  "sosc-core-at-smart": "db26c953-9b2a-4691-a909-5e8726b531d7"
3080
3094
  };
3095
+ const V2_ABBREVIATIONS = new Set(["bengali-song"]);
3081
3096
  /**
3082
3097
  * Fetches and parses a website configuration from the OCHRE API
3083
3098
  *
@@ -3107,21 +3122,39 @@ const KNOWN_ABBREVIATIONS = {
3107
3122
  *
3108
3123
  * The abbreviation is case-insensitive and should match the website's configured abbreviation in OCHRE.
3109
3124
  */
3110
- async function fetchWebsite(abbreviation, customFetch) {
3125
+ async function fetchWebsite(abbreviation, options) {
3111
3126
  try {
3112
- const uuid = KNOWN_ABBREVIATIONS[abbreviation.toLocaleLowerCase("en-US")];
3113
- const response = await (customFetch ?? fetch)(uuid != null ? `https://ochre.lib.uchicago.edu/ochre?uuid=${uuid}&format=json` : `https://ochre.lib.uchicago.edu/ochre?xquery=for $q in input()/ochre[tree[@type='lesson'][identification/abbreviation='${abbreviation.toLocaleLowerCase("en-US")}']] return $q&format=json`);
3114
- if (!response.ok) throw new Error("Failed to fetch website");
3115
- const data = await response.json();
3116
- const result = "result" in data && !Array.isArray(data.result) ? data.result : !("result" in data) ? data : null;
3117
- if (result == null || !("tree" in result.ochre)) throw new Error("Failed to fetch website");
3118
- const projectIdentification = result.ochre.metadata.project?.identification ? parseIdentification(result.ochre.metadata.project.identification) : null;
3119
- return [null, parseWebsite(result.ochre.tree, projectIdentification?.label ?? "", result.ochre.metadata.project?.identification.website ?? null)];
3127
+ const customFetch = options?.customFetch;
3128
+ const isVersion2 = options?.isVersion2 ?? false;
3129
+ const cleanAbbreviation = abbreviation.trim().toLocaleLowerCase("en-US");
3130
+ let metadata = null;
3131
+ let tree = null;
3132
+ if (V2_ABBREVIATIONS.has(cleanAbbreviation) || isVersion2) {
3133
+ const response = await (customFetch ?? fetch)(`https://ochre.lib.uchicago.edu/ochre/v2/ochre.php?xquery=${encodeURIComponent(`collection('ochre/tree')/ochre[tree/identification/abbreviation/content/string='${cleanAbbreviation}']`)}&format=json&lang="*"`);
3134
+ if (!response.ok) throw new Error("Failed to fetch website");
3135
+ const data = await response.json();
3136
+ if (Array.isArray(data.result) || !("tree" in data.result.ochre)) throw new Error("Failed to fetch website");
3137
+ metadata = data.result.ochre.metadata;
3138
+ tree = data.result.ochre.tree;
3139
+ } else {
3140
+ const uuid = KNOWN_ABBREVIATIONS[cleanAbbreviation];
3141
+ const response = await (customFetch ?? fetch)(uuid != null ? `https://ochre.lib.uchicago.edu/ochre?uuid=${uuid}&format=json` : `https://ochre.lib.uchicago.edu/ochre?xquery=${encodeURIComponent(`for $q in input()/ochre[tree[@type='lesson'][identification/abbreviation='${cleanAbbreviation}']] return $q`)}&format=json`);
3142
+ if (!response.ok) throw new Error("Failed to fetch website");
3143
+ const data = await response.json();
3144
+ const result = "result" in data && !Array.isArray(data.result) ? data.result : !("result" in data) ? data : null;
3145
+ if (result == null || !("tree" in result.ochre)) throw new Error("Failed to fetch website");
3146
+ metadata = result.ochre.metadata;
3147
+ tree = result.ochre.tree;
3148
+ }
3149
+ const projectIdentification = metadata.project?.identification ? parseIdentification(metadata.project.identification) : null;
3150
+ return [null, parseWebsite(tree, projectIdentification?.label ?? "", metadata.project?.identification.website ?? null, { isVersion2: true })];
3120
3151
  } catch (error) {
3121
3152
  console.error(error);
3122
3153
  return [error instanceof Error ? error.message : "Unknown error", null];
3123
3154
  }
3124
3155
  }
3156
+ const [_, website] = await fetchWebsite("bengali-song");
3157
+ writeFileSync("website.json", JSON.stringify(website, null, 2));
3125
3158
 
3126
3159
  //#endregion
3127
3160
  export { fetchByUuidMetadata, fetchGallery, fetchItem, fetchPropertyQuery, fetchWebsite, filterProperties, getPropertyByLabel, getPropertyByUuid, getPropertyValueByLabel, getPropertyValueByUuid, getPropertyValuesByLabel, getPropertyValuesByUuid, getUniqueProperties, getUniquePropertyLabels };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digitalculture/ochre-sdk",
3
- "version": "0.11.29",
3
+ "version": "0.12.1",
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",
@@ -49,9 +49,9 @@
49
49
  "eslint": "^9.39.1",
50
50
  "prettier": "^3.6.2",
51
51
  "terser": "^5.44.1",
52
- "tsdown": "^0.16.0",
52
+ "tsdown": "^0.16.1",
53
53
  "typescript": "^5.9.3",
54
- "vitest": "^4.0.7"
54
+ "vitest": "^4.0.8"
55
55
  },
56
56
  "scripts": {
57
57
  "dev": "tsdown src/index.ts --watch",