@libsql/client
Advanced tools
Comparing version 0.6.1 to 0.6.2
@@ -39,14 +39,30 @@ "use strict"; | ||
async function getIsSchemaDatabase({ authToken, baseUrl, }) { | ||
const url = normalizeURLScheme(baseUrl + "/v1/jobs"); | ||
console.log("url: ", url); | ||
const result = await fetch(url, { | ||
method: "GET", | ||
headers: { | ||
Authorization: `Bearer ${authToken}`, | ||
}, | ||
}); | ||
console.log("result: ", result); | ||
const json = (await result.json()); | ||
const isChildDatabase = result.status === 400 && json.error === "Invalid namespace"; | ||
return !isChildDatabase; | ||
let responseStatusCode; | ||
try { | ||
if (baseUrl.startsWith("http://127.0.0.1")) { | ||
return false; | ||
} | ||
const url = normalizeURLScheme(baseUrl + "/v1/jobs"); | ||
const result = await fetch(url, { | ||
method: "GET", | ||
headers: { | ||
Authorization: `Bearer ${authToken}`, | ||
}, | ||
}); | ||
if (result.status === 404 || result.status === 500) { | ||
return false; | ||
} | ||
const json = (await result.json()); | ||
const isChildDatabase = result.status === 400 && json.error === "Invalid namespace"; | ||
return !isChildDatabase; | ||
} | ||
catch (e) { | ||
console.error([ | ||
`There has been an error while retrieving the database type.`, | ||
`Debug information:`, | ||
`- URL: ${baseUrl}`, | ||
`- Response Status Code: ${responseStatusCode ? responseStatusCode : "N/A"}`, | ||
].join("\n")); | ||
throw e; | ||
} | ||
} | ||
@@ -53,0 +69,0 @@ exports.getIsSchemaDatabase = getIsSchemaDatabase; |
@@ -36,14 +36,30 @@ const SCHEMA_MIGRATION_SLEEP_TIME_IN_MS = 1000; | ||
export async function getIsSchemaDatabase({ authToken, baseUrl, }) { | ||
const url = normalizeURLScheme(baseUrl + "/v1/jobs"); | ||
console.log("url: ", url); | ||
const result = await fetch(url, { | ||
method: "GET", | ||
headers: { | ||
Authorization: `Bearer ${authToken}`, | ||
}, | ||
}); | ||
console.log("result: ", result); | ||
const json = (await result.json()); | ||
const isChildDatabase = result.status === 400 && json.error === "Invalid namespace"; | ||
return !isChildDatabase; | ||
let responseStatusCode; | ||
try { | ||
if (baseUrl.startsWith("http://127.0.0.1")) { | ||
return false; | ||
} | ||
const url = normalizeURLScheme(baseUrl + "/v1/jobs"); | ||
const result = await fetch(url, { | ||
method: "GET", | ||
headers: { | ||
Authorization: `Bearer ${authToken}`, | ||
}, | ||
}); | ||
if (result.status === 404 || result.status === 500) { | ||
return false; | ||
} | ||
const json = (await result.json()); | ||
const isChildDatabase = result.status === 400 && json.error === "Invalid namespace"; | ||
return !isChildDatabase; | ||
} | ||
catch (e) { | ||
console.error([ | ||
`There has been an error while retrieving the database type.`, | ||
`Debug information:`, | ||
`- URL: ${baseUrl}`, | ||
`- Response Status Code: ${responseStatusCode ? responseStatusCode : "N/A"}`, | ||
].join("\n")); | ||
throw e; | ||
} | ||
} | ||
@@ -50,0 +66,0 @@ async function getLastMigrationJob({ authToken, baseUrl, }) { |
{ | ||
"name": "@libsql/client", | ||
"version": "0.6.1", | ||
"version": "0.6.2", | ||
"keywords": [ | ||
@@ -105,3 +105,3 @@ "libsql", | ||
"dependencies": { | ||
"@libsql/core": "^0.6.1", | ||
"@libsql/core": "^0.6.2", | ||
"@libsql/hrana-client": "^0.6.0", | ||
@@ -108,0 +108,0 @@ "js-base64": "^3.7.5", |
123941
3005
Updated@libsql/core@^0.6.2