Client API
API reference for the SuitePortal client.
createClient
Creates a typed SuitePortal client and loads the schema.
import { createClient } from './.suiteportal/client';
const client = await createClient(config, options?);Parameters
| Parameter | Type | Description |
|---|---|---|
config | NetSuiteConfig | NetSuite connection credentials |
options.schemaPath | string | Path to schema.json. Default: '.suiteportal/schema.json' |
NetSuiteConfig
interface NetSuiteConfig {
accountId: string; // e.g. '1234567_SB1'
consumerKey: string; // OAuth consumer key
consumerSecret: string; // OAuth consumer secret
tokenId: string; // OAuth token ID
tokenSecret: string; // OAuth token secret
timeout?: number; // Request timeout in ms (default: 30000)
concurrency?: number; // Max concurrent requests (default: 5)
maxRetries?: number; // Retry attempts for failures (default: 3)
}ModelDelegate
Each record type on the client is a ModelDelegate with query and mutation methods.
findMany
const rows = await client.customer.findMany({
where?: WhereInput,
select?: SelectInput,
include?: IncludeInput,
orderBy?: OrderByInput,
take?: number, // default: 1000
skip?: number, // default: 0
});
// Returns: Record<string, unknown>[]findFirst
const row = await client.customer.findFirst({
where?: WhereInput,
select?: SelectInput,
include?: IncludeInput,
orderBy?: OrderByInput,
skip?: number,
});
// Returns: Record<string, unknown> | nullcount
const n = await client.customer.count({
where?: WhereInput,
});
// Returns: numbercreate
Create a new record via the REST Record API:
const customer = await client.customer.create({
data: { companyname: 'Acme Corp', email: 'hello@acme.com' },
});
// Returns: Record<string, unknown> (the created record with id)update
Update a record by ID via the REST Record API:
const updated = await client.customer.update({
where: { id: { equals: 123 } },
data: { email: 'new@acme.com' },
});
// Returns: Record<string, unknown> (the updated record)delete
Delete a record by ID via the REST Record API:
await client.customer.delete({
where: { id: { equals: 123 } },
});
// Returns: void$queryRaw
Execute a raw SuiteQL query:
const rows = await client.$queryRaw<T>(sql: string);
// Returns: T[]$disconnect
Clear the schema cache and internal state:
client.$disconnect();$loadSchema
Manually load/reload the schema (called automatically by createClient):
await client.$loadSchema();