
Security News
PyPI Expands Trusted Publishing to GitLab Self-Managed as Adoption Passes 25 Percent
PyPI adds Trusted Publishing support for GitLab Self-Managed as adoption reaches 25% of uploads
@stedi/typesuite
Advanced tools
TypeSuite™ is a TypeScript client for the NetSuite SuiteTalk Web Services API.
Note: TypeSuite is currently in alpha and subject to several limitations. There are still several features to add and bugs to fix, and there will likely be breaking changes. We'd love to get your feedback to get it out of alpha ASAP.
TypeSuite was built by the team at Stedi, a platform for B2B trade. If you're using TypeSuite to improve how your business operates, we'd love to hear from you.
You can install TypeSuite via npm:
npm install --save git+https://github.com/Stedi/TypeSuite.git
Or add it to your package.json manually.
import { Configuration, TypeSuiteClient } from "typesuite";
// You can fetch your credentials from your NetSuite instance
// We recommend storing them somewhere secure like AWS Secrets Manager
const config: Configuration = {
account: "NetSuite Account ID",
apiVersion: "NetSuite API Version",
token: {
consumerKey: "NetSuite Consumer Key",
consumerSecret: "NetSuite Consumer Secret",
tokenKey: "NetSuite Token Key",
tokenSecret: "NetSuite Token Secret",
},
};
// Create NetSuite client using above credentials
const client = new TypeSuiteClient(config);
The Configuration object holds generic NetSuite configuration information, including the account ID and auth
credentials, API version information, and can even contain shared query options, if desired.
const config: Configuration = {
account: "NetSuite Account ID",
apiVersion: "2019_2",
token: {
...
},
};
Currently, TypeSuite only supports the 2019_2 WSDL;
therefore, the only acceptable configuration option for apiVersion is "2019_2".
We aim to support additional API versions in future versions of TypeSuite, and will update the docs accordingly.
TypeSuite uses NetSuite Token Based Auth (TBA),
which requires a consumerKey, consumerSecret, tokenKey, and tokenSecret.
const config: Configuration = {
account: "...",
apiVersion: "...",
token: {
consumerKey: "NetSuite Consumer Key",
consumerSecret: "NetSuite Consumer Secret",
tokenKey: "NetSuite Token Key",
tokenSecret: "NetSuite Token Secret",
},
};
You can search NetSuite for all records of a certain type (e.g. a _purchaseOrder), matching all other criteria
(e.g. a status of "pending receipt") in a given time period:
// Add additional imports from our API version
import { SearchRequest } from "typesuite/2019_2/platform_messages";
import { TransactionSearchAdvanced } from "typesuite/2019_2/transactions_sales";
// Set up the correct time you'd like to start the search from
const dateTime = ZonedDateTime.of(
LocalDateTime.parse("2020-01-01T00:00"),
ZoneId.UTC
);
const isoFormatter = new DateTimeFormatterBuilder()
.appendInstant(3)
.toFormatter(ResolverStyle.STRICT);
// Construct the search request
const searchAdvancedRequest = new SearchRequest({
searchRecord: new TransactionSearchAdvanced({
columns: {
basic: {
internalId: [{}],
},
itemJoin: {
internalId: [{}],
},
},
criteria: {
basic: {
closed: false,
mainLine: true,
status: {
operator: "anyOf",
searchValue: ["_purchaseOrderPendingReceipt"],
},
type: {
operator: "anyOf",
searchValue: ["_purchaseOrder"],
},
dateCreated: {
operator: "after",
searchValue: dateTime.format(isoFormatter),
},
},
},
}),
});
// Perform NetSuite Search
const response: any = await client
.search(searchAdvancedRequest)
.catch((error: any) => {
console.log("Error during search");
throw error;
});
// Do interesting things with the response
console.log("Found %d purchase orders", response.searchResult.totalRecords);
Note that this will return the record references, not the actual record. You'll need to fetch a record, as shown below, to get the full contents.
You can fetch an individual record (e.g. a particular purchase order) from NetSuite:
// Add additional imports
import { GetRequest } from "typesuite/2019_2/platform_messages";
import { PurchaseOrder } from "typesuite/2019_2/transactions_purchases";
// Create a PO GET request
const getRequest = new GetRequest({
baseRef: new RecordRef({
internalId: "NetSuite Document ID",
type: "purchaseOrder",
}),
});
// Perform the request
const response = await client.get(getRequest).catch(function (error: any) {
console.log("Error fetching purchaseOrder");
throw error;
});
// Cast the response record appropriately
const purchaseOrder = response.readResponse.record as PurchaseOrder;
While TypeSuite currently supports types that can be written back to NetSuite, we don't yet have examples. Stay tuned for more!
Building requests to the NetSuite SuiteTalk API frequently involves instantiating quite a few objects. In order to
minimize the amount of code required to build all the necessary objects, in many cases an object literal can be
provided instead of a fully instantiated object. There are two cases where a fully instantiated object is
required. The first case is the outermost object, typically the Request object, which must be created by calling
the class' constructor. In the example below, a SearchRequest is explicitly instantiated via new.
const SearchRequest = new SearchRequest({
...
});
The second case where a fully instantiated object is required is where you provide an object that is a subclass of
type that is expected for that field. For example, SearchRequest has single field called searchRecord whose
type is PlatformCore.SearchRecord. PlatformCore.SearchRecord is an abstract type that isn't meant to be used
directly. Instead, you provide one of its subclasses, which includes TransactionSearchBasic. In order for the
correct xml for this request to be generated, you must provide a fully instantiated TransactionSearchBasic.
const SearchRequest = new SearchRequest({
searchRecord: new TransactionSearchBasic({
...
}),
});
In all other cases you can simply supply an object literal with the data needed for your request. For example,
the status and type fields of TransactionSearchBasic have a type of PlatformCore.SearchEnumMultiSelectField,
but it is not necessary to create these objects by calling new.
const searchRequest = new SearchRequest({
searchRecord: new TransactionSearchBasic({
status: {
operator: "anyOf",
searchValue: ["_purchaseOrderPendingReceipt"],
},
type: {
operator: "anyOf",
searchValue: ["_purchaseOrder"],
},
}),
});
As mentioned above, TypeSuite only supports the 2019_2 WSDL.
Right now, you must convert Dates to a string manually. This is due to a complication with one of
the underlying libraries that TypeSuite uses and will be fixed in a later release. However, it will always be
possible to provide a string for any field in the NetSuite API that holds a Date.
const dateTime = ZonedDateTime.of(
LocalDateTime.parse("2020-01-01T00:00"),
ZoneId.UTC
);
const isoFormatter = new DateTimeFormatterBuilder()
.appendInstant(3)
.toFormatter(ResolverStyle.STRICT);
const searchRequest = new SearchRequest({
searchRecord: new TransactionSearchBasic({
dateCreated: {
operator: "after",
searchValue: dateTime.format(isoFormatter),
},
}),
});
To build TypeSuite, run npm run build. Source code is located in /src.
To test TypeSuite, run npm run test. Tests are located in /test and use Jest.
FAQs
TypeScript client for NetSuite SuiteTalk SOAP API
We found that @stedi/typesuite demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
PyPI adds Trusted Publishing support for GitLab Self-Managed as adoption reaches 25% of uploads

Research
/Security News
A malicious Chrome extension posing as an Ethereum wallet steals seed phrases by encoding them into Sui transactions, enabling full wallet takeover.

Security News
Socket is heading to London! Stop by our booth or schedule a meeting to see what we've been working on.