npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

netsuite-starter

v1.0.22

Published

Scaffold to build NetSuite account customizations

Downloads

1,438

Readme

NetSuite Starter

Instructions

  1. Install SuiteCloud CLI for Node.js: npm install -g @oracle/suitecloud-cli

  2. Install NetSuite Starter CLI: npm install -g netsuite-starter

  3. Create new project: nsx project

  4. Fill in prompted details

  5. Enter working directory: cd my-project

  6. Install dependencies: npm install

  7. Read the generated README.md file for further instructions

Libraries

Browser


const browserLibrary = new BrowserLibrary();

// MESSAGE

// Create a confirmation message on screen for 5 seconds
// Methods available include: confirmation, error, info, and warning
browserLibrary.message.confirmation({
    message: " This is a message",
    title: "Hi",
    duration: 5000
});

// QUERY

// Get an JSON with key/value query parameters
browserLibrary.query.get();
// => {foo: "bar"}

// Get an JSON with key/value query parameters from the previous page
browserLibrary.query.getPrevious();
// => {foo: "baz"}

// Use query parameters to populate current record body fields
browserLibrary.query.populate(currentRecord, false);

// STORAGE

// Set key/value on session storage
browserLibrary.storage.set("foo", "bar");

// Get session storage item by key
browserLibrary.storage.get("foo");
// => "bar"

// Get session storage item by key
browserLibrary.storage.getAllKeys();
// => ["foo"]

// Remove key from session storage
browserLibrary.storage.remove("foo");

// Clear session storage
browserLibrary.storage.clear();

Cache


const cacheLibrary = new CacheLibrary({

    // Name
    name: "cooks",

    // Scope
    scope: Scope.PRIVATE,

    // ttl (optional) ==> Defaults to 300. Has to be greater than 300
    ttl: 60 * 15,

    // Boolean control field (optional) ==> Used as an on/off switch for the cache
    // If a loader is provided it will return that value, if not it returns {key: null}
    toggle: "custscript_myscript_toggle"
});

// Set a formatter for the cache key name
cacheLibrary.formatCacheName((keyName) => {
    return `my_prefix_${keyName}`;
});

// Set cache duration. The calculator is used for convenience
cacheLibrary.setTTL(cacheLibrary.ttlCalculator(({
    hours: 1,
    minutes: 20,
    seconds: 30
})));

// Set key-value pairs
cacheLibrary.set({jim: {cook: true}, john: {cook: false}});

// Get a single key
cacheLibrary.get({name: "jim"});
// => {jim: {cook: true}}

// Get multiple keys
cacheLibrary.get({name: ["jim", "john"]});
// => {jim: {cook: true}, john: {cook: false}}

// Get a single key and provide a loader if not found
cacheLibrary.get({
    name: "jim",
    loader: (key) => {
        // Here we just use the native NetSuite loader
    }
});
// => {jim: {cook: true}}

// Get multiple keys and provide a loader any are not found
cacheLibrary.get({
    name: ["jim", "john"],
    loader: (key) => {
        // Here we just use the native NetSuite loader
    }
});
// All missing keys are cached, and the full result object is returned
// => {jim: {cook: true}, john: {cook: false}}

// Remove a single key
cacheLibrary.remove("jim");

// Remove multiple keys
cacheLibrary.remove(["jim", "john"]);

CSV


// Load CSV file by ID
// At this point we can set two customizations:
// - cellCleaner: RegEx used to clean cell contents, defaults to /\s*(.*?)\s*/g
// - columnDelimiter: Used to split columns, defaults to ","
const csvLibrary = new CsvLibrary({
    id: "12345",
    cellCleaner: /"/g,
    columnDelimiter: "','"
});

csvLibrary.getFile()
// => Returns file object

csvLibrary.getRawContents()
// => Returns CSV content string

csvLibrary.jsonToCSV([{foo:"bar"}, {foo:"zoo"}]);
// => "foo\nbar\nzoo"

csvLibrary.toJSON();
// => Returns JSON array with all headers as properties

csvLibrary.toJSON(["Name", "Email"]);
// => Returns JSON array with named headers as properties

GOVERNANCE


const governanceLibrary = new GovernanceLibrary();

// Evaluate if we have governance points remaining
governanceLibrary.hasRemaining();

// Get governance points remaining
governanceLibrary.getRemaining();

// Update minimum points required
governanceLibrary.updateFloor(200);

// Run until we exhaust governance points
governanceLibrary.runUntil(
    (remaining) => {
        // Perform record operations
    },
    () => {
        // Optional callback for when we run out of governance
    });

Search


// We create the response we want
type Response = { email: string, phone: string };

// Create a search
const searchLibraryCreated = new SearchLibrary({
    type: "customer",
    filters: [{
        name: "firstname",
        operator: Operator.IS,
        values: ["Peter"]
    }],
    columns: [{
        name: "phone"
    }]
});

// Load an existing search
const searchLibraryLoaded = new SearchLibrary({
    type: "customer",
    id: "12345",
});

// Add a column to the search
searchLibraryCreated.addColumn({
    name: "email"
});

// Remove a column to the search
searchLibraryCreated.removeColumn({
    name: "email"
});

// Add a filter to the search
searchLibraryCreated.addFilter({
    name: "lastname",
    operator: Operator.IS,
    values: ["Griffin"]
});

// Remove a filter to the search
searchLibraryCreated.removeFilter({
    name: "lastname",
    operator: Operator.IS,
    values: ["Griffin"]
});

// Set the transform function: This is mandatory and takes care of converting the results
// Response must be in the format {continue: boolean, response: Response}
// If continue is false the search will stop
searchLibraryCreated.setTransform <Response>((result) => {
    return {
        continue: true,
        response: {
            email: result.getValue({
                name: "email"
            }),
            phone: result.getValue({
                name: "phone"
            }),
        }
    };
});

// Get the first two records
const rangeResponse = searchLibraryCreated.getRange<Response>({start: 1, end: 2});
// => [
// {email: "[email protected]", phone: "9999999"},
// {email: "[email protected]", phone: "9999999"}
// ]

// Get the all records with a page size of 5
searchLibraryCreated.pageSize = 5;
const response = searchLibraryCreated.getResults<Response>();
// => [
// {email: "[email protected]", phone: "9999999"},
// {email: "[email protected]", phone: "9999999"},
// {email: "[email protected]", phone: "9999999"},
// ]

// Async get the all records
searchLibraryCreated.getResultsClient<Response>((response, error) => {

    if (error) {
        throw new Error(error);
    }

    // response => [
    // {email: "[email protected]", phone: "9999999"},
    // {email: "[email protected]", phone: "9999999"},
    // {email: "[email protected]", phone: "9999999"},
    // ]
});

License

GNU GPL see LICENSE.

Author

Felipe Chang [email protected]