@digitalculture/ochre-sdk 0.8.6 → 0.8.7

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() >= ${((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=P(u.result.gallery.item.identification),f=P(u.result.gallery.project.identification),p={identification:d,projectIdentification:f,resources:X(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 je(e,t){try{let n=l.parse(e),r=await(t??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=P(i.result.project.identification),o={...a,website:i.result.project.identification.website??null},s={item:{uuid:e,name:P(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 Me(e,t){try{let n=await(t??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(!n.ok)throw Error(`Failed to fetch website`);let r=await n.json();if(!(`ochre`in r.result)||!(`tree`in r.result.ochre))throw Error(`Failed to fetch website`);let i=r.result.ochre.metadata.project?.identification?P(r.result.ochre.metadata.project.identification):null,a=await ke(r.result.ochre.tree,i?.label??``,r.result.ochre.metadata.project?.identification.website??null);return a}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(!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=P(u.result.gallery.item.identification),f=P(u.result.gallery.project.identification),p={identification:d,projectIdentification:f,resources:X(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 je(e,t){try{let n=l.parse(e),r=await(t??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=P(i.result.project.identification),o={...a,website:i.result.project.identification.website??null},s={item:{uuid:e,name:P(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 Me(e,t){try{let n=await(t??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(!n.ok)throw Error(`Failed to fetch website`);let r=await n.json();if(!(`ochre`in r.result)||!(`tree`in r.result.ochre))throw Error(`Failed to fetch website`);let i=r.result.ochre.metadata.project?.identification?P(r.result.ochre.metadata.project.identification):null,a=await ke(r.result.ochre.tree,i?.label??``,r.result.ochre.metadata.project?.identification.website??null);return[null,a]}catch(e){return console.error(e),[e instanceof Error?e.message:`Unknown error`,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
@@ -901,7 +901,7 @@ declare function fetchByUuidMetadata(uuid: string, customFetch?: (input: string
901
901
  *
902
902
  * The abbreviation is case-insensitive and should match the website's configured abbreviation in OCHRE.
903
903
  */
904
- declare function fetchWebsite(abbreviation: string, customFetch?: (input: string | URL | globalThis.Request, init?: RequestInit) => Promise<Response>): Promise<Website | null>;
904
+ declare function fetchWebsite(abbreviation: string, customFetch?: (input: string | URL | globalThis.Request, init?: RequestInit) => Promise<Response>): Promise<[null, Website] | [string, null]>;
905
905
  //#endregion
906
906
  //#region src/utils/getters.d.ts
907
907
  /**
package/dist/index.d.ts CHANGED
@@ -901,7 +901,7 @@ declare function fetchByUuidMetadata(uuid: string, customFetch?: (input: string
901
901
  *
902
902
  * The abbreviation is case-insensitive and should match the website's configured abbreviation in OCHRE.
903
903
  */
904
- declare function fetchWebsite(abbreviation: string, customFetch?: (input: string | URL | globalThis.Request, init?: RequestInit) => Promise<Response>): Promise<Website | null>;
904
+ declare function fetchWebsite(abbreviation: string, customFetch?: (input: string | URL | globalThis.Request, init?: RequestInit) => Promise<Response>): Promise<[null, Website] | [string, null]>;
905
905
  //#endregion
906
906
  //#region src/utils/getters.d.ts
907
907
  /**
package/dist/index.js CHANGED
@@ -11,4 +11,4 @@ import{z as e}from"zod/v4";const t=e.uuid({error:`Invalid UUID provided`}),n=e.o
11
11
  {$q/metadata/item}
12
12
  {$filtered[position() >= ${((c-1)*l+1).toString()} and position() < ${(c*l+1).toString()}]}
13
13
  </gallery>
14
- `)}&format=json`);if(!u.ok)throw Error(`Error fetching gallery items, please try again later.`);let d=await u.json();if(!(`gallery`in d.result))throw Error(`Failed to fetch gallery`);let f=A(d.result.gallery.item.identification),p=A(d.result.gallery.project.identification),m={identification:f,projectIdentification:p,resources:Y(d.result.gallery.resource?Array.isArray(d.result.gallery.resource)?d.result.gallery.resource:[d.result.gallery.resource]:[]),maxLength:d.result.gallery.maxLength};return{item:m,error:null}}catch(e){return console.error(e),{item:null,error:e instanceof Error?e.message:`Failed to fetch gallery`}}}async function Ce(e,n){try{let r=t.parse(e),i=await(n??fetch)(`https://ochre.lib.uchicago.edu/ochre?xquery=${encodeURIComponent(`for $q in input()/ochre[@uuid='${r}']/metadata return ($q/item, $q/project)`)}&format=json`);if(!i.ok)throw Error(`Failed to fetch metadata`);let a=await i.json(),o=A(a.result.project.identification),s={...o,website:a.result.project.identification.website??null},c={item:{uuid:e,name:A(a.result.item.identification).label,type:a.result.item.type},project:{name:s.label,website:s.website??null}};return{item:c,error:null}}catch(e){return{item:null,error:e instanceof Error?e.message:`Unknown error`}}}async function we(e,t){try{let n=await(t??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(!n.ok)throw Error(`Failed to fetch website`);let r=await n.json();if(!(`ochre`in r.result)||!(`tree`in r.result.ochre))throw Error(`Failed to fetch website`);let i=r.result.ochre.metadata.project?.identification?A(r.result.ochre.metadata.project.identification):null,a=await xe(r.result.ochre.tree,i?.label??``,r.result.ochre.metadata.project?.identification.website??null);return a}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(!u.ok)throw Error(`Error fetching gallery items, please try again later.`);let d=await u.json();if(!(`gallery`in d.result))throw Error(`Failed to fetch gallery`);let f=A(d.result.gallery.item.identification),p=A(d.result.gallery.project.identification),m={identification:f,projectIdentification:p,resources:Y(d.result.gallery.resource?Array.isArray(d.result.gallery.resource)?d.result.gallery.resource:[d.result.gallery.resource]:[]),maxLength:d.result.gallery.maxLength};return{item:m,error:null}}catch(e){return console.error(e),{item:null,error:e instanceof Error?e.message:`Failed to fetch gallery`}}}async function Ce(e,n){try{let r=t.parse(e),i=await(n??fetch)(`https://ochre.lib.uchicago.edu/ochre?xquery=${encodeURIComponent(`for $q in input()/ochre[@uuid='${r}']/metadata return ($q/item, $q/project)`)}&format=json`);if(!i.ok)throw Error(`Failed to fetch metadata`);let a=await i.json(),o=A(a.result.project.identification),s={...o,website:a.result.project.identification.website??null},c={item:{uuid:e,name:A(a.result.item.identification).label,type:a.result.item.type},project:{name:s.label,website:s.website??null}};return{item:c,error:null}}catch(e){return{item:null,error:e instanceof Error?e.message:`Unknown error`}}}async function we(e,t){try{let n=await(t??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(!n.ok)throw Error(`Failed to fetch website`);let r=await n.json();if(!(`ochre`in r.result)||!(`tree`in r.result.ochre))throw Error(`Failed to fetch website`);let i=r.result.ochre.metadata.project?.identification?A(r.result.ochre.metadata.project.identification):null,a=await xe(r.result.ochre.tree,i?.label??``,r.result.ochre.metadata.project?.identification.website??null);return[null,a]}catch(e){return console.error(e),[e instanceof Error?e.message:`Unknown error`,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.8.6",
3
+ "version": "0.8.7",
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",