@hitc/netsuite-types
TypeScript typings for SuiteScript 2.0
Last updated 25 days ago by hitc .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @hitc/netsuite-types 
SYNC missed versions from official npm registry.

SuiteScript 2.0 Typings

Build Status devDependencies Status Join the chat at https://gitter.im/typings-suitescript-2-0/Lobby

Installation Instructions

npm install --save-dev @hitc/netsuite-types

Usage

Once installed, you need to configure TypeScript to find the library declarations and import the libraries as needed into your scripts.

TSC (TypeScript Compiler) Configuration

You can import the modules and use them like normal using standard TypeScript syntax. Just make sure your compiler is configured to use the amd module format and the es5 target. Create a file called tsconfig.json in your project root and have these options configured:

{
  "compilerOptions": {
    "module": "amd",
    "target": "es5",
    "moduleResolution":"node",
    "sourceMap": false,
    "newLine": "LF",
    "experimentalDecorators": true,
    "noImplicitUseStrict": true,
    "baseUrl": ".",
    "lib": ["es5", "es2015.promise", "dom"],
    "paths": {
      "N": ["node_modules/@hitc/netsuite-types/N"],
      "N/*": ["node_modules/@hitc/netsuite-types/N/*"]
    }
  },
  "exclude": ["node_modules"]
}

The key components are baseUrl and paths.

Then simply import your modules and go.

Writing SuiteScript

At the top of every script you will want to have the following lines added:

/**
 * @NAPIVersion 2.0
 * @NScriptType ClientScript
 */

import {EntryPoints} from 'N/types';

N/types and EntryPoints isn't actually in the NetSuite API, but it is something that is included with this library to give you type definitons for your entry point functions. For example:

import {EntryPoints} from 'N/types';
export let pageInit: EntryPoints.Client.pageInit = (context: EntryPoints.Client.pageInitContext) => {
  //Your IDE will now autocomplete from the context argument. For instance use this to access context.mode and context.currentRecord in this pageInit example
}

Notice that we are exporting the function pageInit that will need to be referenced in the NetSuite Client Script record as an entry point.

Then if you're using a TypeScript-aware text editor you'll get syntax highlighting, error detection, embedded apidocs, type-cheking, and autocomplete for all of the SuiteScript 2.0 modules and types. For instance the free VSCode from Microsoft will work out of the box.

User Event Example

Full example for a User Event Script might look something like this:

/**
 * @NAPIVersion 2.0
 * @NScriptType UserEventScript
 */

import {EntryPoints} from 'N/types';
import * as log from 'N/log';

export let beforeSubmit: EntryPoints.UserEvent.beforeSubmit = (context: EntryPoints.UserEvent.beforeSubmitContext) => {
    let x = context.newRecord.getValue({fieldId: 'companyname'});
    log.audit('value', `companyname is: ${x}`);
};

Suitelet Example

/**
 * @NApiVersion 2.x
 * @NScriptType Suitelet
 */

import {EntryPoints} from 'N/types';
import * as record from 'N/record';

export let onRequest: EntryPoints.Suitelet.onRequest = (context: EntryPoints.Suitelet.onRequestContext) => {
    let folder = record.load({type: 'folder', id: 36464});
    let allfields = folder.getFields().join(', ');
    context.response.write(`<br>all fields: ${allfields}`);
};

This example exports the function onRequest that needs to be referenced in the script record.

Updates

You can download the latest published typings library at any time by simply running the command:

npm install --save-dev @hitc/netsuite-types

Current Tags

  • 2020.1.14                                ...           latest (25 days ago)
  • 3.0.0                                ...           TS20 (4 years ago)

271 Versions

  • 2020.1.14                                ...           25 days ago
  • 2020.1.13                                ...           a month ago
  • 2020.1.12                                ...           2 months ago
  • 2020.1.11                                ...           2 months ago
  • 2020.1.10                                ...           2 months ago
  • 2020.1.9                                ...           2 months ago
  • 2020.1.8                                ...           3 months ago
  • 2020.1.7                                ...           3 months ago
  • 2020.1.6                                ...           4 months ago
  • 2020.1.5                                ...           5 months ago
  • 2020.1.4                                ...           5 months ago
  • 2020.1.3                                ...           5 months ago
  • 2020.1.2                                ...           5 months ago
  • 2020.1.1                                ...           6 months ago
  • 2020.1.0                                ...           6 months ago
  • 2019.2.9                                ...           7 months ago
  • 2019.2.8                                ...           7 months ago
  • 2019.2.7                                ...           8 months ago
  • 2019.2.6                                ...           8 months ago
  • 2019.2.5                                ...           10 months ago
  • 2019.2.4                                ...           10 months ago
  • 2019.2.3                                ...           a year ago
  • 2019.2.2                                ...           a year ago
  • 2019.2.1                                ...           a year ago
  • 2019.2.0                                ...           a year ago
  • 2019.1.11                                ...           a year ago
  • 2019.1.10                                ...           a year ago
  • 2019.1.9                                ...           a year ago
  • 2019.1.8                                ...           a year ago
  • 2019.1.7                                ...           a year ago
  • 2019.1.6                                ...           a year ago
  • 2019.1.5                                ...           a year ago
  • 2019.1.4                                ...           a year ago
  • 2019.1.3                                ...           a year ago
  • 2019.1.2                                ...           a year ago
  • 2019.1.1                                ...           a year ago
  • 2019.1.0                                ...           a year ago
  • 2018.2.14                                ...           2 years ago
  • 2018.2.13                                ...           2 years ago
  • 2018.2.12                                ...           2 years ago
  • 2018.2.11                                ...           2 years ago
  • 2018.2.10                                ...           2 years ago
  • 2018.2.9                                ...           2 years ago
  • 2018.2.8                                ...           2 years ago
  • 2018.2.7                                ...           2 years ago
  • 2018.2.6                                ...           2 years ago
  • 2018.2.5                                ...           2 years ago
  • 2018.2.4                                ...           2 years ago
  • 2018.2.3                                ...           2 years ago
  • 2018.2.2                                ...           2 years ago
  • 2018.2.1                                ...           2 years ago
  • 2018.1.5                                ...           2 years ago
  • 2018.1.4                                ...           2 years ago
  • 2018.1.3                                ...           2 years ago
  • 2018.1.2                                ...           2 years ago
  • 2018.1.1                                ...           2 years ago
  • 2018.1.0                                ...           2 years ago
  • 2017.2.32                                ...           2 years ago
  • 2017.2.31                                ...           2 years ago
  • 2017.2.30                                ...           2 years ago
  • 2017.2.29                                ...           2 years ago
  • 2017.2.28                                ...           2 years ago
  • 2017.2.27                                ...           2 years ago
  • 2017.2.26                                ...           2 years ago
  • 2017.2.25                                ...           2 years ago
  • 2017.2.24                                ...           3 years ago
  • 2017.2.23                                ...           3 years ago
  • 2017.2.22                                ...           3 years ago
  • 2017.2.21                                ...           3 years ago
  • 2017.2.20                                ...           3 years ago
  • 2017.2.19                                ...           3 years ago
  • 2017.2.18                                ...           3 years ago
  • 2017.2.17                                ...           3 years ago
  • 2017.2.16                                ...           3 years ago
  • 2017.2.15                                ...           3 years ago
  • 2017.2.14                                ...           3 years ago
  • 2017.2.13                                ...           3 years ago
  • 2017.2.12                                ...           3 years ago
  • 2017.2.11                                ...           3 years ago
  • 2017.2.10                                ...           3 years ago
  • 2017.2.9                                ...           3 years ago
  • 2017.2.8                                ...           3 years ago
  • 2017.2.6                                ...           3 years ago
  • 2017.2.5                                ...           3 years ago
  • 2017.2.4                                ...           3 years ago
  • 2017.2.3                                ...           3 years ago
  • 2017.2.2                                ...           3 years ago
  • 2017.2.1                                ...           3 years ago
  • 2017.1.27                                ...           3 years ago
  • 2017.1.26                                ...           3 years ago
  • 2017.1.25                                ...           3 years ago
  • 2017.1.24                                ...           3 years ago
  • 2017.1.23                                ...           3 years ago
  • 2017.1.22                                ...           3 years ago
  • 2017.1.21                                ...           3 years ago
  • 2017.1.20                                ...           3 years ago
  • 2017.1.19                                ...           3 years ago
  • 2017.1.18                                ...           3 years ago
  • 2017.1.17                                ...           3 years ago
  • 2017.1.16                                ...           3 years ago
  • 2017.1.14                                ...           3 years ago
  • 2017.1.12                                ...           3 years ago
  • 2017.1.11                                ...           3 years ago
  • 2017.1.10                                ...           3 years ago
  • 2017.1.9                                ...           3 years ago
  • 2017.1.8                                ...           3 years ago
  • 2017.1.7                                ...           3 years ago
  • 2017.1.6                                ...           3 years ago
  • 2017.1.5                                ...           3 years ago
  • 2017.1.4                                ...           3 years ago
  • 2017.1.3                                ...           3 years ago
  • 2017.1.2                                ...           3 years ago
  • 2017.1.1                                ...           3 years ago
  • 2017.1.0                                ...           3 years ago
  • 2016.2.25                                ...           3 years ago
  • 2016.2.24                                ...           3 years ago
  • 2016.2.23                                ...           3 years ago
  • 2016.2.22                                ...           3 years ago
  • 2016.2.21                                ...           3 years ago
  • 2016.2.20                                ...           3 years ago
  • 2016.2.19                                ...           4 years ago
  • 2016.2.18                                ...           4 years ago
  • 2016.2.17                                ...           4 years ago
  • 2016.2.16                                ...           4 years ago
  • 2016.2.15                                ...           4 years ago
  • 2016.2.14                                ...           4 years ago
  • 2016.2.13                                ...           4 years ago
  • 2016.2.12                                ...           4 years ago
  • 2016.2.11                                ...           4 years ago
  • 2016.2.10                                ...           4 years ago
  • 2016.2.9                                ...           4 years ago
  • 2016.2.8                                ...           4 years ago
  • 2016.2.7                                ...           4 years ago
  • 2016.2.6                                ...           4 years ago
  • 2016.2.5                                ...           4 years ago
  • 2016.2.4                                ...           4 years ago
  • 2016.2.3                                ...           4 years ago
  • 2016.2.2                                ...           4 years ago
  • 2016.2.1                                ...           4 years ago
  • 2016.2.0                                ...           4 years ago
  • 3.0.0                                ...           4 years ago
  • 3.0.5                                ...           4 years ago
  • 3.0.4                                ...           4 years ago
  • 3.0.3                                ...           4 years ago
  • 3.0.2                                ...           4 years ago
  • 2.8.13                                ...           4 years ago
  • 2.8.12                                ...           4 years ago
  • 2.8.11                                ...           4 years ago
  • 2.8.10                                ...           4 years ago
  • 2.8.9                                ...           4 years ago
  • 2.8.8                                ...           4 years ago
  • 2.8.7                                ...           4 years ago
  • 2.8.6                                ...           4 years ago
  • 2.8.5                                ...           4 years ago
  • 2.8.4                                ...           4 years ago
  • 2.8.3                                ...           4 years ago
  • 2.8.2                                ...           4 years ago
  • 2.8.1                                ...           4 years ago
  • 2.8.0                                ...           4 years ago
  • 2.7.36                                ...           4 years ago
  • 2.7.35                                ...           4 years ago
  • 2.7.34                                ...           4 years ago
  • 2.7.33                                ...           4 years ago
  • 2.7.32                                ...           4 years ago
  • 2.7.31                                ...           4 years ago
  • 2.7.30                                ...           4 years ago
  • 2.7.29                                ...           4 years ago
  • 2.7.28                                ...           4 years ago
  • 2.7.27                                ...           4 years ago
  • 2.7.26                                ...           4 years ago
  • 2.7.10                                ...           4 years ago
  • 2.7.25                                ...           4 years ago
  • 2.7.24                                ...           4 years ago
  • 2.7.23                                ...           4 years ago
  • 2.7.22                                ...           4 years ago
  • 2.7.21                                ...           4 years ago
  • 2.7.20                                ...           4 years ago
  • 2.7.19                                ...           4 years ago
  • 2.7.18                                ...           4 years ago
  • 2.7.17                                ...           4 years ago
  • 2.7.16                                ...           4 years ago
  • 2.7.15                                ...           4 years ago
  • 2.7.14                                ...           4 years ago
  • 2.7.13                                ...           4 years ago
  • 2.7.12                                ...           4 years ago
  • 2.7.11                                ...           4 years ago
  • 2.7.9                                ...           4 years ago
  • 2.7.8                                ...           4 years ago
  • 2.7.7                                ...           4 years ago
  • 2.7.6                                ...           4 years ago
  • 2.7.5                                ...           4 years ago
  • 2.7.4                                ...           4 years ago
  • 2.7.3                                ...           4 years ago
  • 2.7.1                                ...           4 years ago
  • 2.7.0                                ...           4 years ago
  • 2.6.4                                ...           4 years ago
  • 2.6.3                                ...           4 years ago
  • 2.6.2                                ...           4 years ago
  • 2.6.1                                ...           4 years ago
  • 2.6.0                                ...           4 years ago
  • 2.5.9                                ...           4 years ago
  • 2.5.8                                ...           4 years ago
  • 2.5.7                                ...           4 years ago
  • 2.5.6                                ...           4 years ago
  • 2.5.5                                ...           4 years ago
  • 2.5.4                                ...           4 years ago
  • 2.5.3                                ...           4 years ago
  • 2.5.2                                ...           4 years ago
  • 2.5.1                                ...           4 years ago
  • 2.5.0                                ...           4 years ago
  • 2.4.0                                ...           4 years ago
  • 2.3.2                                ...           4 years ago
  • 2.3.1                                ...           4 years ago
  • 2.3.0                                ...           4 years ago
  • 2.2.0                                ...           4 years ago
  • 2.1.1                                ...           4 years ago
  • 2.1.0                                ...           4 years ago
  • 2.0.6                                ...           4 years ago
  • 2.0.5                                ...           4 years ago
  • 2.0.4                                ...           4 years ago
  • 2.0.3                                ...           4 years ago
  • 2.0.2                                ...           4 years ago
  • 2.0.1                                ...           5 years ago
  • 2.0.0                                ...           5 years ago
  • 1.0.46                                ...           5 years ago
  • 1.0.45                                ...           5 years ago
  • 1.0.44                                ...           5 years ago
  • 1.0.43                                ...           5 years ago
  • 1.0.42                                ...           5 years ago
  • 1.0.41                                ...           5 years ago
  • 1.0.40                                ...           5 years ago
  • 1.0.39                                ...           5 years ago
  • 1.0.38                                ...           5 years ago
  • 1.0.37                                ...           5 years ago
  • 1.0.36                                ...           5 years ago
  • 1.0.35                                ...           5 years ago
  • 1.0.34                                ...           5 years ago
  • 1.0.33                                ...           5 years ago
  • 1.0.32                                ...           5 years ago
  • 1.0.31                                ...           5 years ago
  • 1.0.30                                ...           5 years ago
  • 1.0.29                                ...           5 years ago
  • 1.0.28                                ...           5 years ago
  • 1.0.27                                ...           5 years ago
  • 1.0.26                                ...           5 years ago
  • 1.0.25                                ...           5 years ago
  • 1.0.24                                ...           5 years ago
  • 1.0.23                                ...           5 years ago
  • 1.0.22                                ...           5 years ago
  • 1.0.21                                ...           5 years ago
  • 1.0.20                                ...           5 years ago
  • 1.0.19                                ...           5 years ago
  • 1.0.18                                ...           5 years ago
  • 1.0.17                                ...           5 years ago
  • 1.0.16                                ...           5 years ago
  • 1.0.15                                ...           5 years ago
  • 1.0.14                                ...           5 years ago
  • 1.0.13                                ...           5 years ago
  • 1.0.12                                ...           5 years ago
  • 1.0.11                                ...           5 years ago
  • 1.0.10                                ...           5 years ago
  • 1.0.9                                ...           5 years ago
  • 1.0.8                                ...           5 years ago
  • 1.0.7                                ...           5 years ago
  • 1.0.6                                ...           5 years ago
  • 1.0.5                                ...           5 years ago
  • 1.0.4                                ...           5 years ago
  • 1.0.3                                ...           5 years ago
  • 1.0.2                                ...           5 years ago
  • 1.0.1                                ...           5 years ago
  • 1.0.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 30
Dependencies (0)
None
Dev Dependencies (9)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |