@baseai/core
Advanced tools
Comparing version 0.9.1 to 0.9.2
# `langbase` SDK | ||
## 0.9.2 | ||
### Patch Changes | ||
- 👌 IMPROVE: Error handling check if BaseAI dev is running | ||
## 0.9.1 | ||
@@ -4,0 +10,0 @@ |
@@ -121,7 +121,2 @@ "use strict"; | ||
this.status = void 0; | ||
console.warn( | ||
` | ||
Please check if BaseAI dev server is running. If not, run 'npx baseai dev' in the root directory. | ||
` | ||
); | ||
if (cause) this.cause = cause; | ||
@@ -783,2 +778,37 @@ } | ||
// src/utils/local-server-running.ts | ||
async function isLocalServerRunning() { | ||
try { | ||
const endpoint = getApiUrl(); | ||
const response = await fetch(endpoint, { | ||
mode: "no-cors", | ||
cache: "no-cache" | ||
// Prevents caching of the request | ||
}); | ||
const portUseError = ` | ||
Port 9000 is already in use. | ||
Terminate the process running on it. | ||
Run npx baseai@latest dev in an new terminal to start the dev server. | ||
`; | ||
if (!response.ok) { | ||
console.error(portUseError); | ||
return false; | ||
} | ||
const res = await response.json(); | ||
if (!res.success) { | ||
console.error(portUseError); | ||
return false; | ||
} | ||
return true; | ||
} catch (error) { | ||
console.error( | ||
` | ||
BaseAI dev server is not running. | ||
Please run npx baseai@latest dev in a new teriminal to start dev server. | ||
` | ||
); | ||
return false; | ||
} | ||
} | ||
// src/pipes/pipes.ts | ||
@@ -849,2 +879,5 @@ var Pipe = class { | ||
let response = await this.createRequest(endpoint, body); | ||
if (Object.entries(response).length === 0) { | ||
return {}; | ||
} | ||
console.log("pipe.run.response"); | ||
@@ -914,3 +947,8 @@ console.dir(response, { depth: null, colors: true }); | ||
}; | ||
return this.request.post(isProd() ? prodOptions : localOptions); | ||
const isProdEnv = isProd(); | ||
if (!isProdEnv) { | ||
const isServerRunning = await isLocalServerRunning(); | ||
if (!isServerRunning) return {}; | ||
} | ||
return this.request.post(isProdEnv ? prodOptions : localOptions); | ||
} | ||
@@ -917,0 +955,0 @@ }; |
@@ -105,7 +105,2 @@ "use strict"; | ||
this.status = void 0; | ||
console.warn( | ||
` | ||
Please check if BaseAI dev server is running. If not, run 'npx baseai dev' in the root directory. | ||
` | ||
); | ||
if (cause) this.cause = cause; | ||
@@ -767,2 +762,37 @@ } | ||
// src/utils/local-server-running.ts | ||
async function isLocalServerRunning() { | ||
try { | ||
const endpoint = getApiUrl(); | ||
const response = await fetch(endpoint, { | ||
mode: "no-cors", | ||
cache: "no-cache" | ||
// Prevents caching of the request | ||
}); | ||
const portUseError = ` | ||
Port 9000 is already in use. | ||
Terminate the process running on it. | ||
Run npx baseai@latest dev in an new terminal to start the dev server. | ||
`; | ||
if (!response.ok) { | ||
console.error(portUseError); | ||
return false; | ||
} | ||
const res = await response.json(); | ||
if (!res.success) { | ||
console.error(portUseError); | ||
return false; | ||
} | ||
return true; | ||
} catch (error) { | ||
console.error( | ||
` | ||
BaseAI dev server is not running. | ||
Please run npx baseai@latest dev in a new teriminal to start dev server. | ||
` | ||
); | ||
return false; | ||
} | ||
} | ||
// src/pipes/pipes.ts | ||
@@ -833,2 +863,5 @@ var Pipe = class { | ||
let response = await this.createRequest(endpoint, body); | ||
if (Object.entries(response).length === 0) { | ||
return {}; | ||
} | ||
console.log("pipe.run.response"); | ||
@@ -898,3 +931,8 @@ console.dir(response, { depth: null, colors: true }); | ||
}; | ||
return this.request.post(isProd() ? prodOptions : localOptions); | ||
const isProdEnv = isProd(); | ||
if (!isProdEnv) { | ||
const isServerRunning = await isLocalServerRunning(); | ||
if (!isServerRunning) return {}; | ||
} | ||
return this.request.post(isProdEnv ? prodOptions : localOptions); | ||
} | ||
@@ -901,0 +939,0 @@ }; |
{ | ||
"name": "@baseai/core", | ||
"description": "The Web AI Framework's core - BaseAI.dev", | ||
"version": "0.9.1", | ||
"version": "0.9.2", | ||
"license": "Apache-2.0", | ||
@@ -6,0 +6,0 @@ "sideEffects": false, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
416400
5039
11