Deploy your first customer portal →
SuitePortal/NetSuite ORM

Code Generation

How SuitePortal generates TypeScript types from your schema.

The generator reads schema.json and emits TypeScript code that gives you full type safety and autocomplete for your NetSuite data.

Running

npx suiteportal generate

Output

Three files are generated in .suiteportal/client/:

types.ts

A TypeScript interface for every record in your schema:

/** Customer — 233 fields */
export interface Customer {
  /** Internal ID */
  id?: number;
  /** Company Name */
  companyname?: string;
  /** Email */
  email?: string;
  /** Phone */
  phone?: string;
  /** Inactive */
  isinactive?: boolean;
  // ... all 233 fields
}

All fields are optional because SuiteQL SELECT may not return every field.

client.ts

A typed client wrapper that maps record names to their interfaces:

export interface SuitePortalClient {
  customer: TypedModelDelegate<Customer>;
  salesorder: TypedModelDelegate<Salesorder>;
  invoice: TypedModelDelegate<Invoice>;
  // ... all 142 records
  $queryRaw<T>(sql: string): Promise<T[]>;
  $disconnect(): void;
}

index.ts

A barrel export so you can import everything from one path:

import { createClient } from './.suiteportal/client';
import type { Customer, Salesorder } from './.suiteportal/client';

Type Mapping

The generator maps normalized field types to TypeScript:

Field TypeTypeScript Type
string, text, richtext, email, url, phonestring
integer, float, currency, percentnumber
booleanboolean
date, datetimestring
selectstring | number
multiselectstring
unknownunknown

Date fields map to string because SuiteQL returns dates as formatted strings, not JavaScript Date objects.

Regenerating

Run npx suiteportal generate whenever your schema changes. The generated files are in .suiteportal/client/ — you can add this to .gitignore if you prefer to regenerate on each build, or commit it for stable types.

On this page