Skip to content

Commit b873a62

Browse files
authored
docs: Update jsdoc for ProgramCall.js (#236)
1 parent 5ba3b97 commit b873a62

File tree

1 file changed

+92
-10
lines changed

1 file changed

+92
-10
lines changed

lib/ProgramCall.js

Lines changed: 92 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,22 @@
1919

2020
class ProgramCall {
2121
/**
22-
* @description creates a new ProgramCall object
22+
* ProgramCall Configuration
23+
* @typedef {object} programCallConfig
24+
* @property {string} lib - The library where the program exists.
25+
* @property {string} [error=fast] - Determines action when an error is encountered.
26+
* Valid options are ``on``, ``off``, or ``fast``. Default is ``fast``. Using ``on``
27+
* will cause the script execution to stop and log a full error report.
28+
* Using ``off`` or ``fast`` continues executing the script. The Difference is that ``fast``
29+
* will log a brief error report and ``off`` will not.
30+
* @property {string} [func] - The target function of the service program.
31+
*/
32+
33+
/**
34+
* @description Creates a new ProgramCall object.
2335
* @constructor
24-
* @param {string} program
25-
* @param {object} [options]
36+
* @param {string} program - The program or service program name.
37+
* @param {programCallConfig} [options]
2638
*/
2739
constructor(program, options = {}) {
2840
this.xml = `<pgm name='${program}'`;
@@ -32,7 +44,8 @@ class ProgramCall {
3244
}
3345

3446
/**
35-
* Internal function to handle ds and data within <parm> node
47+
* @private
48+
* @description Internal function to handle ds and data within <parm> node
3649
* There is an open propsal to add private methods to JS.
3750
* https://github.com/tc39/proposal-private-methods
3851
* We should update to use private methods in the future.
@@ -66,8 +79,54 @@ class ProgramCall {
6679
}
6780

6881
/**
69-
* @description adds a parameter to the program XML
70-
* @param {object} parmeter
82+
* Data Object Within DS
83+
* @typedef {object} data
84+
* @property {string} type - The XMLSERVICE data type.
85+
* @property {string} value - The value of the data.
86+
* @property {string} [name] - The name of the data.
87+
* @property {string} [varying] - Marks data as a varying length character type
88+
* (ie. varchar) and specifies the size of the length prefix. Valid values are ``on``, ``off``,
89+
* ``2``, or '4' (``on`` is equivalent to ``2``). NOTE: This is only valid for character types.
90+
* @property {string} [enddo] - The label that marks the end of the ``dou``` (do until) label.
91+
* @property {string} [setlen] - The label to set the length of the data
92+
* based on the matching ``len`` label.
93+
* @property {string} [hex] - Whether to interpret the data as hex.
94+
* Valid values are ``on`` or ``off``. Default is ``off``.
95+
* @property {string} [trim] - Whether to allow trim. Valid values are ``on`` or ``off``.
96+
* Default is ``on``.
97+
*/
98+
99+
/**
100+
* Parameter Config Object
101+
* @typedef {object} parameterConfig
102+
* @property {string} type - The XMLSERVICE data type or ds for a data structure.
103+
* @property {string} value - The value of the data.
104+
* @property {string} [name] - The name of the parameter.
105+
* @property {data[]} [fields] - The array of data objects for a ds.
106+
* @property {string} [io] - Whether the parameter is used for input, output, or both.
107+
* Valid values are ``in``, ``out``, or ``both``.
108+
* @property {string} [by] - Whether to pass the parameter by reference or value.
109+
* Valid values are ``ref`` or ``val``. NOTE: Pass by value requires ``XMLSERVICE >= 1.9.9.3``.
110+
* @property {string} [dim] - Sets ds array dimension value.
111+
* @property {string} [dou] - Marks ds with do until label.
112+
* @property {string} [len] - Marks ds with len label.
113+
* @property {string} [varying] - Marks data as a varying length character type
114+
* (ie. varchar) and specifies the size of the length prefix. Valid values are 'on', ``off``,
115+
* ``2``, or ``4`` (``on`` is equivalent to ``2``). NOTE: This is only valid for character types.
116+
* @property {string} [enddo] - The label that marks the end of the ``dou`` (do until) label.
117+
* @property {string} [setlen] - The label to set the length of the data
118+
* based on the matching ``len`` label.
119+
* @property {string} [hex] - Whether to interpret the data as hex.
120+
* Valid values are ``on`` or ``off``. Default is ``off``.
121+
* @property {string} [trim] - Whether to allow trim. Valid values are ``on`` or ``off``.
122+
* Default is ``on``.
123+
*/
124+
125+
/**
126+
* @description Adds a parameter to the program XML.
127+
* @param {parameterConfig} parmeter
128+
* @throws Will throw an error when the first parameter is not an object.
129+
* @throws Will throw an error when the object does set the ``type`` key.
71130
*/
72131
addParam(parameter = {}) {
73132
if (typeof parameter !== 'object') {
@@ -88,8 +147,32 @@ class ProgramCall {
88147
}
89148

90149
/**
91-
* @description adds a return element to the program XML
92-
* @param {object} data
150+
* Return Config Object
151+
* @typedef {object} returnConfig
152+
* @property {string} type - The XMLSERVICE data type or ds for a data structure.
153+
* @property {string} value - The value of the data node.
154+
* @property {string} [name] - The name of the return data.
155+
* @property {data[]} [fields] - The array of data objects for a ds.
156+
* @property {string} [dim] - Sets ds array dimension value.
157+
* @property {string} [dou] - Marks ds with do until label.
158+
* @property {string} [len] - Marks ds with len label.
159+
* @property {string} [varying] - Marks data as a varying length character type
160+
* (ie. varchar) and specifies the size of the length prefix. Valid values are ``on``, ``off``,
161+
* ``2``, or ``4`` (``on`` is equivalent to ``2``). NOTE: This is only valid for character types.
162+
* @property {string} [enddo] - The label that marks the end of the ``dou`` (do until) label.
163+
* @property {string} [setlen] - The label to set the length of the data
164+
* based on the matching ``len`` label.
165+
* @property {string} [hex] - Whether to interpret the input as hex.
166+
* Valid values are ``on`` or ``off``. Default is ``off``.
167+
* @property {string} [trim] - Whether to allow trim. Valid values are ``on`` or ``off``.
168+
* Default is ``on``.
169+
*/
170+
171+
/**
172+
* @description Specifies the type of the return value for the service program function.
173+
* @param {returnConfig} data
174+
* @throws Will throw an error when the first parameter is not an object.
175+
* @throws Will throw an error when the object does set the ``type`` key.
93176
*/
94177
addReturn(data = {}) {
95178
if (typeof data !== 'object') {
@@ -105,8 +188,7 @@ class ProgramCall {
105188
}
106189

107190
/**
108-
* @description returns the current program XML
109-
* @returns {string} - the generated program XML
191+
* @returns {string} the generated program XML
110192
*/
111193
toXML() {
112194
return `${this.xml}</pgm>`;

0 commit comments

Comments
 (0)