@digitalculture/ochre-sdk 0.7.19 → 0.7.20

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.cjs CHANGED
@@ -11,4 +11,4 @@ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=
11
11
  {$q/metadata/item}
12
12
  {$filtered[position() >= ${((o-1)*s+1).toString()} and position() < ${(o*s+1).toString()}]}
13
13
  </gallery>
14
- `)}&format=json`);if(!c.ok)throw Error(`Error fetching gallery items, please try again later.`);let l=await c.json();if(!(`gallery`in l.result))throw Error(`Failed to fetch gallery`);let u=P(l.result.gallery.item.identification),d=P(l.result.gallery.project.identification),f={identification:u,projectIdentification:d,resources:X(l.result.gallery.resource?Array.isArray(l.result.gallery.resource)?l.result.gallery.resource:[l.result.gallery.resource]:[]),maxLength:l.result.gallery.maxLength};return{item:f,error:null}}catch(e){return console.error(e),{item:null,error:e instanceof Error?e.message:`Failed to fetch gallery`}}}async function je(e){try{let t=l.parse(e),n=await fetch(`https://ochre.lib.uchicago.edu/ochre?xquery=${encodeURIComponent(`for $q in input()/ochre[@uuid='${t}']/metadata return ($q/item, $q/project)`)}&format=json`);if(!n.ok)throw Error(`Failed to fetch metadata`);let r=await n.json(),i=P(r.result.project.identification),a={...i,website:r.result.project.identification.website??null},o={item:{uuid:e,name:S(r.result.item.label),type:r.result.item.type},project:{name:a.label,website:a.website??null}};return{item:o,error:null}}catch(e){return{item:null,error:e instanceof Error?e.message:`Unknown error`}}}async function Me(e){try{let t=await fetch(`https://ochre.lib.uchicago.edu/ochre?xquery=for $q in input()/ochre[tree[@type='lesson'][identification/abbreviation='${e.toLocaleLowerCase(`en-US`)}']] return $q&format=json`);if(!t.ok)throw Error(`Failed to fetch website`);let n=await t.json();if(!(`ochre`in n.result)||!(`tree`in n.result.ochre))throw Error(`Failed to fetch website`);let r=n.result.ochre.metadata.project?.identification?P(n.result.ochre.metadata.project.identification):null,i=await ke(n.result.ochre.tree,r?.label??``,n.result.ochre.metadata.project?.identification.website??null);return i}catch(e){return console.error(e),null}}exports.fetchByUuidMetadata=je,exports.fetchFootnotes=ee,exports.fetchGallery=Ae,exports.fetchItem=N,exports.fetchWebsite=Me,exports.filterProperties=j,exports.getPropertyByLabel=O,exports.getPropertyByUuid=te,exports.getPropertyValueByLabel=A,exports.getPropertyValueByUuid=ne,exports.getPropertyValuesByLabel=k,exports.getPropertyValuesByUuid=D,exports.getUniqueProperties=re,exports.getUniquePropertyLabels=ie;
14
+ `)}&format=json`);if(!c.ok)throw Error(`Error fetching gallery items, please try again later.`);let l=await c.json();if(!(`gallery`in l.result))throw Error(`Failed to fetch gallery`);let u=P(l.result.gallery.item.identification),d=P(l.result.gallery.project.identification),f={identification:u,projectIdentification:d,resources:X(l.result.gallery.resource?Array.isArray(l.result.gallery.resource)?l.result.gallery.resource:[l.result.gallery.resource]:[]),maxLength:l.result.gallery.maxLength};return{item:f,error:null}}catch(e){return console.error(e),{item:null,error:e instanceof Error?e.message:`Failed to fetch gallery`}}}async function je(e){try{let t=l.parse(e),n=await fetch(`https://ochre.lib.uchicago.edu/ochre?xquery=${encodeURIComponent(`for $q in input()/ochre[@uuid='${t}']/metadata return ($q/item, $q/project)`)}&format=json`);if(!n.ok)throw Error(`Failed to fetch metadata`);let r=await n.json(),i=P(r.result.project.identification),a={...i,website:r.result.project.identification.website??null},o={item:{uuid:e,name:P(r.result.item.identification).label,type:r.result.item.type},project:{name:a.label,website:a.website??null}};return{item:o,error:null}}catch(e){return{item:null,error:e instanceof Error?e.message:`Unknown error`}}}async function Me(e){try{let t=await fetch(`https://ochre.lib.uchicago.edu/ochre?xquery=for $q in input()/ochre[tree[@type='lesson'][identification/abbreviation='${e.toLocaleLowerCase(`en-US`)}']] return $q&format=json`);if(!t.ok)throw Error(`Failed to fetch website`);let n=await t.json();if(!(`ochre`in n.result)||!(`tree`in n.result.ochre))throw Error(`Failed to fetch website`);let r=n.result.ochre.metadata.project?.identification?P(n.result.ochre.metadata.project.identification):null,i=await ke(n.result.ochre.tree,r?.label??``,n.result.ochre.metadata.project?.identification.website??null);return i}catch(e){return console.error(e),null}}exports.fetchByUuidMetadata=je,exports.fetchFootnotes=ee,exports.fetchGallery=Ae,exports.fetchItem=N,exports.fetchWebsite=Me,exports.filterProperties=j,exports.getPropertyByLabel=O,exports.getPropertyByUuid=te,exports.getPropertyValueByLabel=A,exports.getPropertyValueByUuid=ne,exports.getPropertyValuesByLabel=k,exports.getPropertyValuesByUuid=D,exports.getUniqueProperties=re,exports.getUniquePropertyLabels=ie;
package/dist/index.d.cts CHANGED
@@ -413,6 +413,20 @@ type Gallery = {
413
413
  resources: Array<Resource>;
414
414
  maxLength: number;
415
415
  };
416
+ /**
417
+ * Represents a metadata object given a UUID
418
+ */
419
+ type UuidMetadata = {
420
+ item: {
421
+ uuid: string;
422
+ name: string;
423
+ type: string;
424
+ };
425
+ project: {
426
+ name: string;
427
+ website: string | null;
428
+ };
429
+ } | null;
416
430
  /**
417
431
  * Represents a website with its properties and elements
418
432
  */
@@ -767,22 +781,6 @@ declare function fetchItem<T extends DataCategory, U extends DataCategory>(uuid:
767
781
  }>;
768
782
 
769
783
  //#endregion
770
- //#region src/types/internal.raw.d.ts
771
-
772
- /**
773
- * Raw UUID metadata structure
774
- */
775
- type OchreUuidMetadata = {
776
- item: {
777
- uuid: string;
778
- name: string;
779
- type: "image" | "resource" | "tree" | "internalDocument" | "iiif" | "timeline";
780
- };
781
- project: {
782
- name: string;
783
- website: string | null;
784
- };
785
- } | null; //#endregion
786
784
  //#region src/utils/fetchers/uuid-metadata.d.ts
787
785
  /**
788
786
  * Fetches raw OCHRE metadata by UUID from the OCHRE API
@@ -801,7 +799,7 @@ type OchreUuidMetadata = {
801
799
  * ```
802
800
  */
803
801
  declare function fetchByUuidMetadata(uuid: string): Promise<{
804
- item: OchreUuidMetadata | null;
802
+ item: UuidMetadata | null;
805
803
  error: string | null;
806
804
  }>;
807
805
 
@@ -1008,4 +1006,4 @@ declare function filterProperties(property: Property, filter: {
1008
1006
  }, options?: PropertyOptions): boolean;
1009
1007
 
1010
1008
  //#endregion
1011
- export { Bibliography, Concept, Context, ContextItem, ContextNode, Coordinates, Data, DataCategory, Document, Event, Footnote, Gallery, Identification, Image, ImageMap, ImageMapArea, Interpretation, License, Link, Metadata, Note, Observation, Period, Person, Property, PropertyValue, PropertyValueContent, PropertyValueContentType, Resource, Set, SpatialUnit, Style, Tree, WebBlock, WebElement, WebElementComponent, WebImage, WebSectionSidebarItem, Webpage, WebpageProperties, Website, WebsiteProperties, fetchByUuidMetadata, fetchFootnotes, fetchGallery, fetchItem, fetchWebsite, filterProperties, getPropertyByLabel, getPropertyByUuid, getPropertyValueByLabel, getPropertyValueByUuid, getPropertyValuesByLabel, getPropertyValuesByUuid, getUniqueProperties, getUniquePropertyLabels };
1009
+ export { Bibliography, Concept, Context, ContextItem, ContextNode, Coordinates, Data, DataCategory, Document, Event, Footnote, Gallery, Identification, Image, ImageMap, ImageMapArea, Interpretation, License, Link, Metadata, Note, Observation, Period, Person, Property, PropertyValue, PropertyValueContent, PropertyValueContentType, Resource, Set, SpatialUnit, Style, Tree, UuidMetadata, WebBlock, WebElement, WebElementComponent, WebImage, WebSectionSidebarItem, Webpage, WebpageProperties, Website, WebsiteProperties, fetchByUuidMetadata, fetchFootnotes, fetchGallery, fetchItem, fetchWebsite, filterProperties, getPropertyByLabel, getPropertyByUuid, getPropertyValueByLabel, getPropertyValueByUuid, getPropertyValuesByLabel, getPropertyValuesByUuid, getUniqueProperties, getUniquePropertyLabels };
package/dist/index.d.ts CHANGED
@@ -413,6 +413,20 @@ type Gallery = {
413
413
  resources: Array<Resource>;
414
414
  maxLength: number;
415
415
  };
416
+ /**
417
+ * Represents a metadata object given a UUID
418
+ */
419
+ type UuidMetadata = {
420
+ item: {
421
+ uuid: string;
422
+ name: string;
423
+ type: string;
424
+ };
425
+ project: {
426
+ name: string;
427
+ website: string | null;
428
+ };
429
+ } | null;
416
430
  /**
417
431
  * Represents a website with its properties and elements
418
432
  */
@@ -767,22 +781,6 @@ declare function fetchItem<T extends DataCategory, U extends DataCategory>(uuid:
767
781
  }>;
768
782
 
769
783
  //#endregion
770
- //#region src/types/internal.raw.d.ts
771
-
772
- /**
773
- * Raw UUID metadata structure
774
- */
775
- type OchreUuidMetadata = {
776
- item: {
777
- uuid: string;
778
- name: string;
779
- type: "image" | "resource" | "tree" | "internalDocument" | "iiif" | "timeline";
780
- };
781
- project: {
782
- name: string;
783
- website: string | null;
784
- };
785
- } | null; //#endregion
786
784
  //#region src/utils/fetchers/uuid-metadata.d.ts
787
785
  /**
788
786
  * Fetches raw OCHRE metadata by UUID from the OCHRE API
@@ -801,7 +799,7 @@ type OchreUuidMetadata = {
801
799
  * ```
802
800
  */
803
801
  declare function fetchByUuidMetadata(uuid: string): Promise<{
804
- item: OchreUuidMetadata | null;
802
+ item: UuidMetadata | null;
805
803
  error: string | null;
806
804
  }>;
807
805
 
@@ -1008,4 +1006,4 @@ declare function filterProperties(property: Property, filter: {
1008
1006
  }, options?: PropertyOptions): boolean;
1009
1007
 
1010
1008
  //#endregion
1011
- export { Bibliography, Concept, Context, ContextItem, ContextNode, Coordinates, Data, DataCategory, Document, Event, Footnote, Gallery, Identification, Image, ImageMap, ImageMapArea, Interpretation, License, Link, Metadata, Note, Observation, Period, Person, Property, PropertyValue, PropertyValueContent, PropertyValueContentType, Resource, Set, SpatialUnit, Style, Tree, WebBlock, WebElement, WebElementComponent, WebImage, WebSectionSidebarItem, Webpage, WebpageProperties, Website, WebsiteProperties, fetchByUuidMetadata, fetchFootnotes, fetchGallery, fetchItem, fetchWebsite, filterProperties, getPropertyByLabel, getPropertyByUuid, getPropertyValueByLabel, getPropertyValueByUuid, getPropertyValuesByLabel, getPropertyValuesByUuid, getUniqueProperties, getUniquePropertyLabels };
1009
+ export { Bibliography, Concept, Context, ContextItem, ContextNode, Coordinates, Data, DataCategory, Document, Event, Footnote, Gallery, Identification, Image, ImageMap, ImageMapArea, Interpretation, License, Link, Metadata, Note, Observation, Period, Person, Property, PropertyValue, PropertyValueContent, PropertyValueContentType, Resource, Set, SpatialUnit, Style, Tree, UuidMetadata, WebBlock, WebElement, WebElementComponent, WebImage, WebSectionSidebarItem, Webpage, WebpageProperties, Website, WebsiteProperties, fetchByUuidMetadata, fetchFootnotes, fetchGallery, fetchItem, fetchWebsite, filterProperties, getPropertyByLabel, getPropertyByUuid, getPropertyValueByLabel, getPropertyValueByUuid, getPropertyValuesByLabel, getPropertyValuesByUuid, getUniqueProperties, getUniquePropertyLabels };
package/dist/index.js CHANGED
@@ -11,4 +11,4 @@ import{z as e}from"zod/v4";const t=e.uuid({message:`Invalid UUID provided`}),n=e
11
11
  {$q/metadata/item}
12
12
  {$filtered[position() >= ${((s-1)*c+1).toString()} and position() < ${(s*c+1).toString()}]}
13
13
  </gallery>
14
- `)}&format=json`);if(!l.ok)throw Error(`Error fetching gallery items, please try again later.`);let u=await l.json();if(!(`gallery`in u.result))throw Error(`Failed to fetch gallery`);let d=A(u.result.gallery.item.identification),f=A(u.result.gallery.project.identification),p={identification:d,projectIdentification:f,resources:Y(u.result.gallery.resource?Array.isArray(u.result.gallery.resource)?u.result.gallery.resource:[u.result.gallery.resource]:[]),maxLength:u.result.gallery.maxLength};return{item:p,error:null}}catch(e){return console.error(e),{item:null,error:e instanceof Error?e.message:`Failed to fetch gallery`}}}async function Ce(e){try{let n=t.parse(e),r=await fetch(`https://ochre.lib.uchicago.edu/ochre?xquery=${encodeURIComponent(`for $q in input()/ochre[@uuid='${n}']/metadata return ($q/item, $q/project)`)}&format=json`);if(!r.ok)throw Error(`Failed to fetch metadata`);let i=await r.json(),a=A(i.result.project.identification),o={...a,website:i.result.project.identification.website??null},s={item:{uuid:e,name:m(i.result.item.label),type:i.result.item.type},project:{name:o.label,website:o.website??null}};return{item:s,error:null}}catch(e){return{item:null,error:e instanceof Error?e.message:`Unknown error`}}}async function we(e){try{let t=await fetch(`https://ochre.lib.uchicago.edu/ochre?xquery=for $q in input()/ochre[tree[@type='lesson'][identification/abbreviation='${e.toLocaleLowerCase(`en-US`)}']] return $q&format=json`);if(!t.ok)throw Error(`Failed to fetch website`);let n=await t.json();if(!(`ochre`in n.result)||!(`tree`in n.result.ochre))throw Error(`Failed to fetch website`);let r=n.result.ochre.metadata.project?.identification?A(n.result.ochre.metadata.project.identification):null,i=await xe(n.result.ochre.tree,r?.label??``,n.result.ochre.metadata.project?.identification.website??null);return i}catch(e){return console.error(e),null}}export{Ce as fetchByUuidMetadata,v as fetchFootnotes,Se as fetchGallery,k as fetchItem,we as fetchWebsite,O as filterProperties,C as getPropertyByLabel,b as getPropertyByUuid,T as getPropertyValueByLabel,S as getPropertyValueByUuid,w as getPropertyValuesByLabel,x as getPropertyValuesByUuid,E as getUniqueProperties,D as getUniquePropertyLabels};
14
+ `)}&format=json`);if(!l.ok)throw Error(`Error fetching gallery items, please try again later.`);let u=await l.json();if(!(`gallery`in u.result))throw Error(`Failed to fetch gallery`);let d=A(u.result.gallery.item.identification),f=A(u.result.gallery.project.identification),p={identification:d,projectIdentification:f,resources:Y(u.result.gallery.resource?Array.isArray(u.result.gallery.resource)?u.result.gallery.resource:[u.result.gallery.resource]:[]),maxLength:u.result.gallery.maxLength};return{item:p,error:null}}catch(e){return console.error(e),{item:null,error:e instanceof Error?e.message:`Failed to fetch gallery`}}}async function Ce(e){try{let n=t.parse(e),r=await fetch(`https://ochre.lib.uchicago.edu/ochre?xquery=${encodeURIComponent(`for $q in input()/ochre[@uuid='${n}']/metadata return ($q/item, $q/project)`)}&format=json`);if(!r.ok)throw Error(`Failed to fetch metadata`);let i=await r.json(),a=A(i.result.project.identification),o={...a,website:i.result.project.identification.website??null},s={item:{uuid:e,name:A(i.result.item.identification).label,type:i.result.item.type},project:{name:o.label,website:o.website??null}};return{item:s,error:null}}catch(e){return{item:null,error:e instanceof Error?e.message:`Unknown error`}}}async function we(e){try{let t=await fetch(`https://ochre.lib.uchicago.edu/ochre?xquery=for $q in input()/ochre[tree[@type='lesson'][identification/abbreviation='${e.toLocaleLowerCase(`en-US`)}']] return $q&format=json`);if(!t.ok)throw Error(`Failed to fetch website`);let n=await t.json();if(!(`ochre`in n.result)||!(`tree`in n.result.ochre))throw Error(`Failed to fetch website`);let r=n.result.ochre.metadata.project?.identification?A(n.result.ochre.metadata.project.identification):null,i=await xe(n.result.ochre.tree,r?.label??``,n.result.ochre.metadata.project?.identification.website??null);return i}catch(e){return console.error(e),null}}export{Ce as fetchByUuidMetadata,v as fetchFootnotes,Se as fetchGallery,k as fetchItem,we as fetchWebsite,O as filterProperties,C as getPropertyByLabel,b as getPropertyByUuid,T as getPropertyValueByLabel,S as getPropertyValueByUuid,w as getPropertyValuesByLabel,x as getPropertyValuesByUuid,E as getUniqueProperties,D as getUniquePropertyLabels};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digitalculture/ochre-sdk",
3
- "version": "0.7.19",
3
+ "version": "0.7.20",
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",