Does anyone know where to find a SS2.0 JSDOC definition library?

蓝咒 提交于 2019-12-20 03:20:38

问题


Does anyone know or has a JSDOC definition library I can use for SS2.0??

The current one I have for SS1.0 looks like the one below, and I use it to plug into my IDE and get autocompletion.

/** * Loads an existing saved search. The saved search could have been created using the UI, or created using nlapiCreateSearch(type, filters, columns) in conjunction with nlobjSearch.saveSearch(title, scriptId). 
*<br>API Governance: 5 
* @param {String} recType [optional] - The record internal ID of the record type you are searching (for example, customer|lead|prospect|partner|vendor|contact). This parameter is case-insensitive. 
* @param {String} searchId - The internal ID or script ID of the saved search. The script ID of the saved search is required, regardless of whether you specify the search type. If you do not specify the search type, you must set type to null and then set the script/search ID. 
* @returns {nlobjSearch} nlobjSearch
* @since 2012.1 */ 
function nlapiLoadSearch(recType, searchId) { };

Not really a technical question but would come in handy for everyone.


回答1:


You may consider what I did which there is no need to download other plugins.
You will be able to enable the code assist if you have the copy of SS2.0 API and then use "@param" and "@type" JSDOC tag.
Then, there will be suggestion every time you type then 'CTRL' + 'SPACE".
Aside from that, your IDE will also provide description for each function.
So this is what will you do.


  1. On your NetSuite accoun, download the SuiteScript 2.0 JavaScript files. You can do this by nagaviting at >Documents>Files>SuiteScripts>. Then at right portion of your screen, you should see links for "SuiteScript 2.0 API" and "SuiteSCript 1.0 API". Click for SS2.0 to download.
  2. On Eclipse IDE, create a new JavaScript project for SS2.0 or include it on your existing project.
  3. Next on the project you are working, right click then select “Properties”. Under >JavaScript>Include Path and then at “Projects” subtab, add the project where SS2.0 APIs are included.
  4. You will now have code assist for object literal APIs of SS2.0. These are 'N/log' and 'N'util' modules.
  5. Next to enable the code assist for object constructor APIs of SS2.0 like 'N/record' and 'N/search' modules, we should be adding "@param" JSDoc tag on each function declaration.

    So if we are going to use the 'N/record', 'N/search' and 'N/error' modules in our script, we should have below sample comments before function declaration. But please take note that it should match the value inside the "{[VALUE HERE]}" tag and the module name. Also the variable name on the comment section and function declaration.

    /**
    * Do something.
    * 
    * @param {record} objRec
    * @param {search} objSearch
    * @param {error} objError
    * 
    */
    function doSomething(objRec, objSearch, objError)
    {
           //CODE HERE
    }
    


    You may also use '@type' for your variable declaration. Below is the sample code.

    /**
    * Do something.
    * 
    */
    function doSomething()
    {
           /*** @type record**/
           var recCustomerRefund = record.create(
                {
                    type : 'customerrefund',
                    isDynamic : true
                }); 
    }
    




回答2:


The way SS2 works you are essentially out of luck.

consider

define(['N/search'], function(bob){
    var srch = bob.load({id:'customsearch_my_search'});
}

What is bob? Your IDE will have to be considerably smarter to know that bob is part of the search namespace. It's of course doable but less likely to work with a simple downloadable file that you can just plug into your IDE. If you just use 'search' that may make things more likely to work but now you've used up a very generic name that you cannot use elsewhere.

Also if an IDE can determine what 'bob' is now your arguments is an unordered hash so positional @params don't work anymore.

Typescript may help. I've been maintaining a Typescript definition file for SS1 at https://github.com/BKnights/KotN-Netsuite. As I start doing more with SS2.0 I may do the same for that. Then your IDE would have more of a chance:

define(['N/search'], function(bob:NSearch){...

So your Typescript aware IDE could use that for member completion and at least you'd have a compile time check on types



来源:https://stackoverflow.com/questions/37444741/does-anyone-know-where-to-find-a-ss2-0-jsdoc-definition-library

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!