@dkodemonkey-llc/ns-sdk
v1.1.0
Published
NetSuite SuiteScript Development SDK - Libraries for search conversion, error handling, OAuth, and more
Maintainers
Readme
NS-SDK
A comprehensive NetSuite SuiteScript Development SDK providing libraries for search conversion, error handling, OAuth authentication, record operations, and more.
Features
- SuiteQLHelper - Convert NetSuite Saved Searches to SuiteQL queries automatically
- Currency - Precision currency handling with integer-based arithmetic
- searchHelper - Utilities for working with N/search API
- recordHelper - Record operation helpers
- errorHelper - Standardized error handling and logging
- oauth1.0 - OAuth 1.0 authentication utilities
- Third-party libraries - Moment.js and PapaParse for date/time and CSV handling
Installation
Prerequisites
Enable SDF for your NetSuite Account
Install SDF CLI locally
Deployment
- Clone this repository
- Deploy the
srcfolder to NetSuite using SDF - Add the following to your script headers for shorthand library access:
/** * @NAmdConfig /SuiteScripts/NS-SDK/ns-sdk-amd.json */
Quick Start
Using SuiteQLHelper
define(['N/query', 'SuiteQLHelper'], function(query, SuiteQLHelper) {
// Convert a saved search to SuiteQL
const result = SuiteQLHelper.convertSearchToSuiteQL({ id: 2413 });
const sqlQuery = result.sql;
// Run the query
const results = query.runSuiteQL({ query: sqlQuery }).asMappedResults();
});Using Currency
define(['Currency'], function(Currency) {
const amount = new Currency(100.50);
const tax = amount.multiply(0.08);
const total = amount.add(tax);
// Works directly with NetSuite fields
record.setValue('amount', total); // Sets 108.54
});Using searchHelper
define(['N/search', 'searchHelper'], function(search, searchHelper) {
const mySearch = search.create({
type: search.Type.TRANSACTION,
filters: [['type', 'anyof', 'SalesOrd']],
columns: ['tranid', 'trandate', 'amount']
});
// Get all results as JSON
const results = searchHelper.getAllResults(mySearch, true, true);
});Library Documentation
- Currency.js - Precision currency calculations
- Currency Code Review - Implementation analysis
- searchHelper.js - Search utilities
- errorHelper.js - Error handling
- SuiteQL Conversion Guide - Detailed conversion documentation
- Project Guide - Comprehensive project documentation
Development
Running Tests
npm test # Run all tests
npm run test:watch # Run tests in watch mode
npm run test:coverage # Generate coverage reportLinting
npm run lint # Check for linting errors
npm run lint:fix # Fix linting errors automaticallyVS Code Snippets
This project includes VS Code snippets for NetSuite script boilerplate. The snippets are automatically available when you open this project in VS Code.
Available snippets:
ue-before- User Event Before Submitue-after- User Event After Submitmr-getinput- Map/Reduce Get Input Stagemr-map- Map/Reduce Map Stagemr-reduce- Map/Reduce Reduce Stagemr-summarize- Map/Reduce Summarize Stage- And more...
Project Structure
ns-sdk/
├── src/FileCabinet/SuiteScripts/NS-SDK/
│ ├── lib/ # Core libraries
│ │ ├── SuiteQLHelper.js # Search to SuiteQL converter
│ │ ├── Currency.js # Precision currency handling
│ │ ├── searchHelper.js # Search utilities
│ │ ├── recordHelper.js # Record operations
│ │ ├── errorHelper.js # Error handling
│ │ ├── oauth1.0.js # OAuth utilities
│ │ ├── moment.min.js # Date/time library
│ │ └── papaparse.min.js # CSV parsing
│ └── ns-sdk-amd.json # AMD module config
├── test/ # Unit tests
├── docs/ # Documentation
├── .vscode/ # VS Code snippets
└── .claude/ # AI assistant documentationContributing
This is an internal development SDK for DKODEMONKEY LLC. For issues or questions, please contact the development team.
License
MIT
Author
DKODEMONKEY LLC
