<@U5375UUJ2> can you create standard NS scripts wi...
# suitescript
c
@stalbert can you create standard NS scripts with NFT?
e.g. a TypeScript map/reduce?
There's not a lot of documentation that explains how to get going.
I might be asking the wrong question - maybe it's the HITC docs I need to be looking at?
So if I want to use TS classes/abstract classes etc, this has nothing to do with NS script types and their entry points, the NS script types are still created as per-usual except with hitc TS then the entry point scripts can create/call/instantiate any classes etc that you write in pure TS?
s
the @hitc/netsuite-types is only type declarations for the SuiteScript API
NFT on the other hand is TS code that surfaces NS data as simple objects and collections (for one thing)
NFT has a readme, but admittedly it's not entirely comprehensive
to answer your original question, yes, the whole idea of NFT is to create suitescripts more effectively
but you can get started with TS just by including the netsuite-types and use the
tsconfig.json
patterned after the one in that repo
If you want a ready-to-go project starter I have a zip laying around I could send. wait here is a version from history https://netsuiteprofessionals.slack.com/files/U5375UUJ2/F02FKTN4WLF/webstorm-template.zip
that's probably referring to an older NFT so you'd have to update that if interested in playing with NFT
c
@stalbert thanks for the example, that's super useful. In regards to OOP and design patterns, if I want to implement SOLID principles, I guess the NS script types don't really fit within those patterns
But those scripts could basically just be an entry point into a larger TS/OOP/SOLID application.
s
NFT is a very thin layer that enables common design patterns seen frequently outside NS. Indeed the SuiteScript API isn't very OO, and NFT being written in TS makes it a very natural fit for taking a more OO design approach. However, it's easy to fall into the trap of over-engineering. For us, we use NFT and embrace the OO approach for basic data access (ActiveRecord pattern) but we don't try to turn the entire script into something complex. We used to do that but upon deeper inspection it provided no value and only complicated things at the script level. If you're building an application it's a different story. But building the small-ish solutions we typically need in NS has taught me to keep the software architecture small as welll. I have a strong KISS tendency, and scripts written with NFT do a great job with that.
In any case, even if you don't use NFT, that template project should be pre-configured to be ready to go with plain TypeScript development for NS.
c
I'm mostly looking at this to build more complex integrations.
Particularly around ecommerce and warehouse management integrations where you might want multiple systems to be involved in an end-to-end business process. It's much easier to model these things with objects/classes using SOLID principals to ensure loose coupling and adaptor patterns that allow us to have multiple implementations of interfaces that can support modelling several systems.
But yeah, for a simple script to update record fields based on user actions etc, you wouldn't want to over engineer it with inheritance and polymorphism etc.
Thanks @stalbert!
s
Sounds good, I'd be curious what you come up with in the end!