
Security News
Risky Biz Podcast: Making Reachability Analysis Work in Real-World Codebases
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
@scottybee84/mock-netsuite
Advanced tools
Mock NetSuite API and SuiteScript host for testing SuiteQL queries and SuiteScripts without a NetSuite account
Mock NetSuite API and SuiteScript host for learning and testing without a NetSuite account.
π₯ NEW in v0.2.0: Full SuiteScript hosting support! Run Suitelets, Restlets, User Events, and Map/Reduce scripts against a mock database.
Built with TypeScript and compiled to JavaScript for production use. Features auto-seeding and a CLI for easy setup.
β οΈ Important: Node.js Version
This package requires Node.js 18-22 (tested on 18/20/22). It will NOT work with Node.js 23+ due to better-sqlite3 ABI compatibility.
# Check your version
node --version
# If you need to switch (using nvm):
nvm install 20
nvm use 20
# Or install Volta for automatic switching:
# https://volta.sh
curl https://get.volta.sh | bash
volta pin node@20
π‘ For consuming projects: Install Volta to automatically use the correct Node version when working with this package.
npm install -g @scottybee84/mock-netsuite
mock-netsuite
# Run a Suitelet as a web page
mock-netsuite --suitelet path/to/my_suitelet.js
# Access at: http://localhost:3000/app/site/hosting/script/my_suitelet
# Run a Restlet as a REST API
mock-netsuite --restlet path/to/my_restlet.js
# Access at: http://localhost:3000/app/site/hosting/restlet/my_restlet
mock-netsuite
# Basic API endpoints at http://localhost:3000
The CLI will automatically:
π Quick Setup:
./dev.sh setup # One-time setup
./dev.sh watch # Auto-rebuild + restart on file changes
π Manual Commands:
npm install
npm run build # Compile TypeScript β dist/
npm run dev:watch # Watch TypeScript files for changes
npm run dev:cli # Build and test CLI
npm run reset # Reset database with fresh data
npm run dev # Build and start server once
π― VS Code Integration:
Ctrl+Shift+P
β "Tasks: Run Task" β "Watch TypeScript"Ctrl+Shift+P
β "Tasks: Run Task" β "Start CLI"Write real NetSuite SuiteScript code and test it locally! The mock environment includes:
Create a Suitelet (my_suitelet.js
):
/**
* @NApiVersion 2.1
* @NScriptType Suitelet
*/
import * as record from "N/record";
import * as log from "N/log";
export function onRequest(ctx) {
const customer = record.load({ type: "customer", id: 1 });
const name = customer.getValue({ fieldId: "companyname" });
log.audit("Customer Loaded", name);
ctx.response.write(`<h1>Customer: ${name}</h1>`);
}
Run it:
mock-netsuite --suitelet my_suitelet.js
# Visit: http://localhost:3000/app/site/hosting/script/my_suitelet
For complete examples and advanced usage, see SUITESCRIPT-GUIDE.md.
The package includes an example showing how to integrate Google's Gemini AI for customer analysis:
// examples/sl_customer_lookup.js with AI analysis
import * as https from "N/https";
import { GEMINI_API_KEY } from "./config.js";
function analyzeCustomerWithAI(customerData) {
const response = https.post({
url: `https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash-latest:generateContent?key=${GEMINI_API_KEY}`,
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
/* Gemini payload */
}),
});
return JSON.parse(response.body);
}
To try the AI example:
examples/config.js
with your API keynode suitescript-runtime.js
See examples/AI_CUSTOMER_ANALYSIS.md for complete setup and technical details.
π¦ Publishing:
./dev.sh publish # Automated: test β build β version β publish β git push
# OR manually:
npm run build && npm version patch && npm publish
POST http://localhost:3000/query/v1/suiteql
Content-Type: application/json
{
"query": "SELECT tranid,total,duedate,status FROM invoice WHERE status='Overdue' AND total > 10000 ORDER BY duedate ASC LIMIT 5;"
}
GET /record/v1/customer/{id}
GET /record/v1/invoice/{id}
# Health check
curl -s http://localhost:3000/health
# SuiteQL query example
curl -s -X POST http://localhost:3000/query/v1/suiteql \
-H "Content-Type: application/json" \
-d '{"query":"SELECT c.companyname, i.tranid, i.total FROM customer c JOIN invoice i ON c.id = i.customerid LIMIT 3;"}' | jq
src/
- TypeScript source files
cli.ts
- Command-line interface with auto-seedingserver.ts
- Express API serverseed.ts
- Database seeding scriptdist/
- Compiled JavaScript files (auto-generated)schema.sql
- SQLite database schema with NetSuite-style field namestsconfig.json
- TypeScript configurationThe database uses NetSuite internal ID conventions:
entityid
(not entity_id
)companyname
(not company_name
)tranid
(not tran_id
)customerid
(not customer_id
)duedate
(not due_date
)datecreated
(not created_at
)MIT - See LICENSE file for details. AI β SuiteQL without a NetSuite account.
Built with TypeScript and compiled to JavaScript for production use.
npm install
npm run build # Compile TypeScript to dist/
npm run reset # Reset database with fresh data
npm run dev # Start server
npm run dev:watch # Watch TypeScript files for changes
POST http://localhost:3000/query/v1/suiteql
{ "query": "SELECT tranid,total,duedate,status FROM invoice WHERE status='Overdue' AND total > 10000 ORDER BY duedate ASC LIMIT 20;" }
In VS Code terminal:
npm i
npm run seed
npm run dev
Test (Terminal or Postman):
curl -s -X POST http://localhost:3000/query/v1/suiteql \
-H "Content-Type: application/json" \
-d '{"query":"SELECT tranid,total,duedate,status FROM invoice WHERE status=''Overdue'' AND total > 10000 ORDER BY duedate ASC LIMIT 5;"}' | jq
## Version Compatibility
**Node.js Support:** This package supports Node.js 18-22 (tested on 18/20/22) with fail-fast version checking.
**ABI Compatibility:** Uses `better-sqlite3` which requires native compilation. Version constraints ensure compatibility across the tested Node.js matrix.
**Auto-Version Management:**
- **Volta users:** Run `volta pin node@20` in your consuming project for automatic version switching
- **nvm users:** Use the included `.nvmrc` file with `nvm use`
- **CI/CD:** The `engines` field in package.json enforces version constraints
**Installation Flow:**
1. `preinstall` hook runs `scripts/check-node.js` for immediate version verification
2. `postinstall` hook rebuilds native modules for your specific Node version
3. Helpful error messages guide users to version management solutions
You should see an items array of invoices.
Back in GitHub Desktop: commit β βinit mock-netsuiteβ β Publish repository (public).
FAQs
Mock NetSuite API and SuiteScript host for testing SuiteQL queries and SuiteScripts without a NetSuite account
The npm package @scottybee84/mock-netsuite receives a total of 824 weekly downloads. As such, @scottybee84/mock-netsuite popularity was classified as not popular.
We found that @scottybee84/mock-netsuite demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.Β It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socketβs AI scanner detected the supply chain attack and flagged the malware.
Security News
CISAβs 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.