1515// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1616// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1717
18- const idbCall = ( config , xmlInput , cb ) => {
19- const {
20- dbconn, dbstmt, IN , CLOB , CHAR , SQL_ATTR_DBC_SYS_NAMING , SQL_FALSE ,
21- // idb-connector is an optional dependency, since users may not use this transport
22- // thus we can't globally require it
23- // eslint-disable-next-line max-len
24- // eslint-disable-next-line global-require, import/no-extraneous-dependencies, import/no-unresolved
25- } = require ( 'idb-connector' ) ;
18+ let idb = null ;
19+
20+ try {
21+ // eslint-disable-next-line global-require
22+ idb = require ( 'idb-connector' ) ;
23+ } catch ( e ) {
24+ if ( e . code !== 'MODULE_NOT_FOUND' ) {
25+ throw e ;
26+ }
27+ }
2628
29+ function idbCall ( config , xmlInput , cb ) {
2730 const {
2831 database = '*LOCAL' ,
2932 username = null ,
@@ -37,9 +40,9 @@ const idbCall = (config, xmlInput, cb) => {
3740 let xmlOutput = '' ;
3841 const sql = `call ${ xslib } .iPLUGR512K(?,?,?)` ;
3942 // eslint-disable-next-line new-cap
40- const conn = new dbconn ( ) ;
43+ const conn = new idb . dbconn ( ) ;
4144
42- conn . setConnAttr ( SQL_ATTR_DBC_SYS_NAMING , SQL_FALSE ) ;
45+ conn . setConnAttr ( idb . SQL_ATTR_DBC_SYS_NAMING , idb . SQL_FALSE ) ;
4346
4447 if ( typeof verbose === 'boolean' ) {
4548 conn . debug ( verbose ) ;
@@ -56,12 +59,12 @@ const idbCall = (config, xmlInput, cb) => {
5659 return ;
5760 }
5861 // eslint-disable-next-line new-cap
59- const stmt = new dbstmt ( conn ) ;
62+ const stmt = new idb . dbstmt ( conn ) ;
6063
6164 const parameters = [
62- [ ipc , IN , CHAR ] ,
63- [ ctl , IN , CHAR ] ,
64- [ xmlInput , IN , CLOB ] ,
65+ [ ipc , idb . IN , idb . CHAR ] ,
66+ [ ctl , idb . IN , idb . CHAR ] ,
67+ [ xmlInput , idb . IN , idb . CLOB ] ,
6568 ] ;
6669
6770 // Before returning to caller, we must clean up
@@ -109,6 +112,6 @@ const idbCall = (config, xmlInput, cb) => {
109112 } ) ;
110113 } ) ;
111114 } ) ;
112- } ;
115+ }
113116
114117exports . idbCall = idbCall ;
0 commit comments