verify: serverWidget typings vs Oracle pages (addButton, addSecretKeyField, DATETIME)

Open
#70 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
typescript
Domain
testing

Research direction

The issue names src/rules/requireServerWidgetOptions.ts, src/rules/noUnsupportedServerWidgetFieldType.ts, and docs/rule-priority.md. First, deploy the supplied Suitelet in a NetSuite account and run the additional createList probe; record the account version and outputs in an issue comment. Then use that runtime evidence to update the rule comments and priority guidance; done means the results and resulting guidance are documented, with any upstream typings issue opened only if the evidence confirms a mismatch.

Written by the indexing model from the issue text.

Description

documentation ready-for-human

Run it with verify:run. Write a probe in verification/probes/, then npm run verify:doctor and npm run verify:run -- <slug> --draft (docs/verification/README.md, automation.md). The snippets below are the test recipes; paste output by hand only for what a probe cannot run (the runner is a RESTlet, so Suitelets, N/ui and client scripts need the user). These snippets use N/ui/serverWidget, which is not available in a RESTlet, so this one cannot run through the runner yet and stays with the user.

Question

For N/ui/serverWidget, Oracle's method pages and the type definitions disagree, and the repo follows the type definitions without runtime confirmation:

  • requireServerWidgetOptions: the pages make addButton's id and addSecretKeyField's restrictToScriptIds required, the type definitions make them optional. The rule follows the type definitions.
  • noUnsupportedServerWidgetFieldType: Oracle says "The DATETIME field type is not supported with addField methods, you must specify DATETIMETZ", but the type definitions have no DATETIME member in serverWidget.FieldType.

What to do

Deploy this Suitelet and paste its output (or the error message if it fails to run) as a comment, with the account version.

/**
 * @NApiVersion 2.1
 * @NScriptType Suitelet
 */
define(['N/ui/serverWidget'], (ui) => ({
  onRequest({ response }) {
    const r = {};
    const t = (k, f) => { try { r[k] = f(); } catch (e) { r[k] = 'THROWS: ' + e.name + ': ' + e.message; } };
    const form = ui.createForm({ title: 'probe' });
    t('addButton with id', () => !!form.addButton({ id: 'custpage_b1', label: 'B1', functionName: 'f' }));
    t('addButton without id', () => !!form.addButton({ label: 'B2', functionName: 'f' }));
    t('addSecretKeyField with restrictToScriptIds', () => !!form.addSecretKeyField({ id: 'custpage_s1', label: 'S1', restrictToScriptIds: ['customscript_probe'] }));
    t('addSecretKeyField without restrictToScriptIds', () => !!form.addSecretKeyField({ id: 'custpage_s2', label: 'S2' }));
    t('typeof FieldType.DATETIME', () => typeof ui.FieldType.DATETIME);
    t("addField 'datetime'", () => !!form.addField({ id: 'custpage_d1', label: 'D1', type: 'datetime' }));
    t('addField FieldType.DATETIMETZ', () => !!form.addField({ id: 'custpage_d2', label: 'D2', type: ui.FieldType.DATETIMETZ }));
    t('List.addColumn CHECKBOX', () => !!form.addSublist({ id: 'custpage_l1', label: 'L', type: ui.SublistType.LIST }).addField({ id: 'custpage_c1', label: 'C', type: ui.FieldType.CHECKBOX }));
    response.write(JSON.stringify(r, null, 1));
  },
}));

The last line tests a Sublist.addField with a checkbox, which is allowed. To test the List.addColumn restriction ("CHECKBOX, DATETIME, DATETIMETZ, FILE, HELP, INLINEHTML, LABEL, MULTISELECT, SELECT and RADIO are not supported"), also create a list with ui.createList({ title: 'x' }) and call addColumn({ id, label, type: ui.FieldType.CHECKBOX }); paste what happens.

Then

  • Update the rule comments in src/rules/requireServerWidgetOptions.ts and src/rules/noUnsupportedServerWidgetFieldType.ts with the result.
  • If the pages are right and the type definitions are wrong, runtime evidence outranks both (once the runtime-verification tier lands), so follow the pages. Open an upstream issue with the type definitions project only after the result is confirmed.

Where

  • src/rules/requireServerWidgetOptions.ts, src/rules/noUnsupportedServerWidgetFieldType.ts
  • docs/rule-priority.md (conflicts between the type definitions and Oracle's documentation)
Dominant language
TypeScript
Stars
1
Forks
0
Avg merge
2h 8m
Merged PRs (30d)
64

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from nemchik/biome-plugin-suitescript

All issues in nemchik/biome-plugin-suitescript

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.