{"_id":"@cafeasp/netsuite-core","name":"@cafeasp/netsuite-core","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@cafeasp/netsuite-core","version":"0.1.0","description":"NetSuite REST API and SuiteQL client library","type":"module","main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"build":"tsup","dev":"tsup --watch"},"publishConfig":{"access":"public"},"license":"MIT","author":{"name":"cafeasp"},"repository":{"type":"git","url":"git+https://github.com/cafeasp/netsuite-cli-mcp-server.git","directory":"packages/core"},"keywords":["netsuite","suiteql","rest-api","tba","oauth","erp"],"engines":{"node":">=18"},"_id":"@cafeasp/netsuite-core@0.1.0","gitHead":"45aa7f72c6d0e9b5888a93321ce3c932867d94b6","bugs":{"url":"https://github.com/cafeasp/netsuite-cli-mcp-server/issues"},"homepage":"https://github.com/cafeasp/netsuite-cli-mcp-server#readme","_nodeVersion":"22.22.0","_npmVersion":"10.9.4","dist":{"integrity":"sha512-elCfnrVewsEi5Cf6vQKNKDz/IIVL4wqfV9wijZ3N/0kicVHs8AICaF1R6Ik9lVmKDflPCb3lAjVhjCfRXw7rww==","shasum":"c4cae3fbd2e31e39c6d457b5b0621133c8ad2a91","tarball":"https://registry.npmjs.org/@cafeasp/netsuite-core/-/netsuite-core-0.1.0.tgz","fileCount":5,"unpackedSize":38009,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCI/V2UF7mpXmYkce7DZ+p4G6jiLiqTSjPpMWr6mNkL9QIgbdmecyWCzDZTjA9anqsSGZ3TBWXpjlxjZUwJFQG42HM="}]},"_npmUser":{"name":"cafeasp","email":"vpacheco99@gmail.com"},"directories":{},"maintainers":[{"name":"cafeasp","email":"vpacheco99@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/netsuite-core_0.1.0_1775408482061_0.0014916001116864752"},"_hasShrinkwrap":false}},"time":{"created":"2026-04-05T17:01:21.937Z","0.1.0":"2026-04-05T17:01:22.206Z","modified":"2026-04-05T17:01:22.474Z"},"maintainers":[{"name":"cafeasp","email":"vpacheco99@gmail.com"}],"description":"NetSuite REST API and SuiteQL client library","homepage":"https://github.com/cafeasp/netsuite-cli-mcp-server#readme","keywords":["netsuite","suiteql","rest-api","tba","oauth","erp"],"repository":{"type":"git","url":"git+https://github.com/cafeasp/netsuite-cli-mcp-server.git","directory":"packages/core"},"author":{"name":"cafeasp"},"bugs":{"url":"https://github.com/cafeasp/netsuite-cli-mcp-server/issues"},"license":"MIT","readme":"# @cafeasp/netsuite-core\n\nNetSuite REST API and SuiteQL client library for Node.js. Zero runtime dependencies — uses only Node.js built-in modules.\n\n## Installation\n\n```bash\nnpm install @cafeasp/netsuite-core\n```\n\n## Quick Start\n\n```typescript\nimport {\n  loadConfig,\n  createAuthProvider,\n  NetSuiteClient,\n  SuiteQLClient,\n} from \"@cafeasp/netsuite-core\";\n\n// Load config from ~/.netsuite/config.json or environment variables\nconst config = loadConfig();\nconst auth = createAuthProvider(config);\nconst client = new NetSuiteClient(auth, config.accountId);\nconst suiteql = new SuiteQLClient(client);\n\n// Run a SuiteQL query\nconst customers = await suiteql.query(\n  \"SELECT id, companyname, email FROM customer\",\n  { limit: 10 }\n);\nconsole.log(customers.items);\n\n// Auto-paginate through all results\nconst allCustomers = await suiteql.queryAll(\n  \"SELECT id, companyname FROM customer\"\n);\n\n// CRUD operations\nconst record = await client.getRecord(\"customer\", \"123\");\nconst list = await client.listRecords(\"item\", { limit: 50 });\nawait client.createRecord(\"customer\", { companyname: \"Acme Corp\" });\nawait client.updateRecord(\"customer\", \"123\", { email: \"new@acme.com\" });\nawait client.deleteRecord(\"customer\", \"456\");\n```\n\n## Authentication\n\nUses **Token-Based Authentication (TBA)** with HMAC-SHA256 signing.\n\n### Setup in NetSuite\n\n1. Enable **REST Web Services** and **Token-Based Authentication** in Setup > Company > Enable Features\n2. Create an **Integration Record** — save the Consumer Key and Consumer Secret\n3. Create an **Access Token** — save the Token ID and Token Secret\n\n### Configuration\n\n**Option A: Config file** (`~/.netsuite/config.json`)\n\n```json\n{\n  \"profiles\": {\n    \"default\": {\n      \"authMethod\": \"tba\",\n      \"accountId\": \"YOUR_ACCOUNT_ID\",\n      \"consumerKey\": \"...\",\n      \"consumerSecret\": \"...\",\n      \"tokenId\": \"...\",\n      \"tokenSecret\": \"...\"\n    }\n  }\n}\n```\n\n**Option B: Environment variables**\n\n```bash\nexport NETSUITE_ACCOUNT_ID=YOUR_ACCOUNT_ID\nexport NETSUITE_CONSUMER_KEY=...\nexport NETSUITE_CONSUMER_SECRET=...\nexport NETSUITE_TOKEN_ID=...\nexport NETSUITE_TOKEN_SECRET=...\n```\n\nEnvironment variables override file config.\n\n## API\n\n### `loadConfig(options?)`\nLoad config from file and/or environment. Options: `{ profile?: string, configPath?: string }`\n\n### `createAuthProvider(config)`\nCreate an auth provider from config. Returns an `AuthProvider` instance.\n\n### `NetSuiteClient`\n- `getRecord(type, id, options?)` — GET a record\n- `listRecords(type, options?)` — List records with filtering\n- `createRecord(type, body)` — Create a record\n- `updateRecord(type, id, body)` — Update a record\n- `deleteRecord(type, id)` — Delete a record\n- `request(method, path, body?, headers?)` — Raw HTTP request\n\n### `SuiteQLClient`\n- `query(sql, options?)` — Execute SuiteQL (max 1000 rows per call)\n- `queryAll(sql)` — Auto-paginate through all results\n\n### `NetSuiteError`\nExtends `Error` with `statusCode`, `errorCode`, and `body` properties. Use `NetSuiteError.fromResponse(status, body)` to parse NetSuite error responses.\n\n## Related Packages\n\n- [@cafeasp/netsuite-cli](../cli) — Terminal interface\n- [@cafeasp/netsuite-mcp](../mcp-server) — MCP server for AI clients\n\n## License\n\nMIT\n","readmeFilename":"README.md","_rev":"1-e21169bbd99d075b3a20dbe2701c8f5a"}