@digitalculture/ochre-sdk 0.14.5 → 0.14.6
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.mjs +2 -2
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -3020,8 +3020,8 @@ async function fetchByUuid(uuid, options) {
|
|
|
3020
3020
|
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="*"`);
|
|
3021
3021
|
if (!response.ok) throw new Error("Failed to fetch OCHRE data");
|
|
3022
3022
|
const dataRaw = await response.json();
|
|
3023
|
-
if (!("ochre" in dataRaw)) throw new Error("Invalid OCHRE data: API response missing 'ochre' key");
|
|
3024
|
-
return [null, dataRaw];
|
|
3023
|
+
if (isVersion2 && (!("result" in dataRaw) || !("ochre" in dataRaw.result)) || !isVersion2 && !("ochre" in dataRaw)) throw new Error("Invalid OCHRE data: API response missing 'ochre' key");
|
|
3024
|
+
return [null, "result" in dataRaw && !Array.isArray(dataRaw.result) && "ochre" in dataRaw.result ? dataRaw.result : "ochre" in dataRaw ? dataRaw : null];
|
|
3025
3025
|
} catch (error) {
|
|
3026
3026
|
return [error instanceof Error ? error.message : "Unknown error", null];
|
|
3027
3027
|
}
|
package/package.json
CHANGED