From 37f0f8dab9cd28cac4cbcbfe57026a77a31dbb19 Mon Sep 17 00:00:00 2001 From: dhmlau Date: Wed, 16 Jul 2025 10:56:09 -0400 Subject: [PATCH] chore: add CI - commit and code linting Signed-off-by: dhmlau --- .github/workflows/continuous-integration.yml | 65 +++ commitlint.config.js | 18 + lib/globalize.js | 4 +- lib/ibmdb.js | 257 +++++----- lib/migration.js | 52 +- package-lock.json | 513 ++++++++++--------- package.json | 9 +- test/connect.test.js | 8 +- test/functional.test.js | 16 +- test/ibmdb.config.test.js | 4 +- test/init.js | 6 +- 11 files changed, 539 insertions(+), 413 deletions(-) create mode 100644 .github/workflows/continuous-integration.yml create mode 100644 commitlint.config.js diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml new file mode 100644 index 0000000..593306c --- /dev/null +++ b/.github/workflows/continuous-integration.yml @@ -0,0 +1,65 @@ +name: Continuous Integration + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +permissions: {} + +env: + NODE_OPTIONS: --max-old-space-size=4096 + +jobs: + test: + name: Test + timeout-minutes: 30 + strategy: + matrix: + os: [ubuntu-latest] + node-version: [20, 22, 24] + include: + - os: windows-latest + node-version: 22 # LTS + - os: macos-latest + node-version: 22 # LTS + fail-fast: false + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + - run: npm install + - name: Run test + run: npm test --ignore-scripts + + code-lint: + name: Code Lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 22 # LTS + - run: npm install --ignore-scripts + - name: Verify code linting + run: npx --no eslint . + + commit-lint: + name: Commit Lint + runs-on: ubuntu-latest + if: ${{ github.event.pull_request }} + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + fetch-depth: 0 + - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 + with: + node-version: 22 # LTS + - name: Install dependencies + run: npm install + - name: Verify commit linting + run: npx commitlint --from origin/master --to HEAD --verbose diff --git a/commitlint.config.js b/commitlint.config.js new file mode 100644 index 0000000..9fefa1d --- /dev/null +++ b/commitlint.config.js @@ -0,0 +1,18 @@ +// Copyright IBM Corp. and LoopBack contributors 2025. All Rights Reserved. +// Node module: loopback-connector-postgresql +// This file is licensed under the MIT License. +// License text available at https://opensource.org/licenses/MIT + +'use strict'; + +module.exports = { + extends: [ + '@commitlint/config-conventional', + ], + rules: { + 'header-max-length': [2, 'always', 100], + 'body-leading-blank': [2, 'always'], + 'footer-leading-blank': [0, 'always'], + 'signed-off-by': [2, 'always', 'Signed-off-by:'], + }, +}; diff --git a/lib/globalize.js b/lib/globalize.js index cafab66..93f7d7b 100644 --- a/lib/globalize.js +++ b/lib/globalize.js @@ -5,8 +5,8 @@ 'use strict'; -var path = require('path'); -var SG = require('strong-globalize'); +const path = require('path'); +const SG = require('strong-globalize'); SG.SetRootDir(path.join(__dirname, '..'), {autonomousMsgLoading: 'all'}); module.exports = SG(); diff --git a/lib/ibmdb.js b/lib/ibmdb.js index 5830036..8d887b1 100644 --- a/lib/ibmdb.js +++ b/lib/ibmdb.js @@ -5,22 +5,22 @@ 'use strict'; -var g = require('./globalize'); +const g = require('./globalize'); /*! * Common connector infrastructure for IBM database connectors. */ -var SQLConnector = require('loopback-connector').SQLConnector; -var Driver = require('ibm_db'); -var util = require('util'); -var debug = require('debug')('loopback:connector:ibmdb'); -var async = require('async'); +const SQLConnector = require('loopback-connector').SQLConnector; +const Driver = require('ibm_db'); +const util = require('util'); +const debug = require('debug')('loopback:connector:ibmdb'); +const async = require('async'); -var ParameterizedSQL = IBMDB.ParameterizedSQL = SQLConnector.ParameterizedSQL; -var Transaction = IBMDB.Transaction = SQLConnector.Transaction; +const ParameterizedSQL = IBMDB.ParameterizedSQL = SQLConnector.ParameterizedSQL; +const Transaction = IBMDB.Transaction = SQLConnector.Transaction; // The generic placeholder -var PLACEHOLDER = SQLConnector.PLACEHOLDER = ParameterizedSQL.PLACEHOLDER; +const PLACEHOLDER = SQLConnector.PLACEHOLDER = ParameterizedSQL.PLACEHOLDER; /** * Initialize the IBMDB connector for the given data source @@ -51,12 +51,12 @@ function IBMDB(name, settings) { this.setConnectionProperties(name, settings); this.client = new Driver.Pool(this.connectionOptions); this.client.init(this.connectionOptions.minPoolSize, this.connStr); -}; +} util.inherits(IBMDB, SQLConnector); IBMDB.prototype.setConnectionProperties = function(name, settings) { - var self = this; + const self = this; self.dbname = (settings.database || settings.db || 'testdb'); self.dsn = settings.dsn; self.hostname = (settings.hostname || settings.host); @@ -72,17 +72,17 @@ IBMDB.prototype.setConnectionProperties = function(name, settings) { self.connectionOptions.connectionTimeout = parseInt(settings.connectionTimeout, 10) || 60; - var dsn = settings.dsn; + const dsn = settings.dsn; if (dsn) { self.connStr = dsn; - var DSNObject = self.parseDSN(dsn); + const DSNObject = self.parseDSN(dsn); if (!('CurrentSchema' in DSNObject)) { self.connStr += ';CurrentSchema=' + DSNObject.UID; } self.schema = DSNObject.CurrentSchema || DSNObject.UID; } else { - var connStrGenerate = + const connStrGenerate = 'DRIVER={' + name + '}' + ';DATABASE=' + this.dbname + ';HOSTNAME=' + this.hostname + @@ -103,16 +103,16 @@ IBMDB.prototype.setConnectionProperties = function(name, settings) { IBMDB.prototype.parseDSN = function(dsn) { // Split dsn into an array of optionStr - var dsnOption = dsn.split(';'); + const dsnOption = dsn.split(';'); // Handle dsn string ended with ';' if (!dsnOption[dsnOption.length - 1]) { dsnOption.pop(); } // Convert Array into Object - var result = {}; + const result = {}; dsnOption.forEach(function(str) { - var strSplit = str.split('='); + const strSplit = str.split('='); result[strSplit[0]] = strSplit[1]; }); @@ -120,14 +120,14 @@ IBMDB.prototype.parseDSN = function(dsn) { }; IBMDB.prototype.tableEscaped = function(model) { - var escapedName = this.escapeName(this.table(model)); + const escapedName = this.escapeName(this.table(model)); return escapedName; }; IBMDB.prototype.ping = function(cb) { debug('IBM.prototype.ping'); - var self = this; - var sql = 'SELECT COUNT(*) AS COUNT FROM SYSIBM.SYSDUMMY1'; + const self = this; + const sql = 'SELECT COUNT(*) AS COUNT FROM SYSIBM.SYSDUMMY1'; if (self.dataSource.connection) { ping(self.dataSource.connection, cb); @@ -158,7 +158,7 @@ IBMDB.prototype.ping = function(cb) { }; IBMDB.prototype.testConnection = function(conn, sql) { - var rows = conn.querySync(sql, null); + const rows = conn.querySync(sql, null); debug('IBMDB.prototype.testConnection: sql=%j, rows=%j', sql, rows); @@ -175,7 +175,7 @@ IBMDB.prototype.testConnection = function(conn, sql) { * {Function} [cb] The callback after the connect */ IBMDB.prototype.connect = function(cb) { - var self = this; + const self = this; if (!self.dsn && (!self.hostname || !self.portnumber || @@ -222,12 +222,12 @@ IBMDB.prototype.executeSQL = function(sql, params, options, callback) { debug('IBMDB.prototype.executeSQL (enter)', sql, params, options); - var self = this; + const self = this; function executeStatement(conn, cb) { - var limit = 0; - var offset = 0; - var stmt = {}; + let limit = 0; + let offset = 0; + const stmt = {}; stmt.noResults = options && options.noResultSet ? options.noResultSet : false; @@ -236,7 +236,7 @@ IBMDB.prototype.executeSQL = function(sql, params, options, callback) { // are configured off by default. Enable these to // leverage LIMIT and OFFSET. if (!self.useLimitOffset) { - var res = sql.match(self.limitRE); + let res = sql.match(self.limitRE); if (res) { limit = parseInt(res[1], 10); sql = sql.replace(self.limitRE, ''); @@ -267,10 +267,10 @@ IBMDB.prototype.executeSQL = function(sql, params, options, callback) { return cb && cb(err, data); }); - }; + } if (options.transaction) { - var conn = options.transaction.connection; + const conn = options.transaction.connection; executeStatement(conn, function(err, data) { callback(err, data); }); } else { this.connect(function(err, conn) { @@ -286,13 +286,13 @@ IBMDB.prototype.executeSQL = function(sql, params, options, callback) { }; function dateToIBMDB(val) { - var dateStr = val.getFullYear() + '-' + + const dateStr = val.getFullYear() + '-' + fillZeros(val.getMonth() + 1) + '-' + fillZeros(val.getDate()) + '-' + fillZeros(val.getHours()) + '.' + fillZeros(val.getMinutes()) + '.' + fillZeros(val.getSeconds()) + '.'; - var ms = val.getMilliseconds(); + let ms = val.getMilliseconds(); if (ms < 10) { ms = '00' + ms + '000'; } else if (ms < 100) { @@ -304,7 +304,7 @@ function dateToIBMDB(val) { function fillZeros(v) { return v < 10 ? '0' + v : v; } -}; +} IBMDB.prototype.toColumnValue = function(prop, val) { debug('IBMDB.prototype.toColumnValue prop=%j val=%j', prop, val); @@ -434,11 +434,11 @@ IBMDB.prototype.getPlaceholderForValue = function(key) { */ IBMDB.prototype.buildInsertDefaultValues = function(model) { debug('IBMDB.prototype.buildInsertDefaultValues'); - var def = this.getModelDefinition(model); - var num = Object.keys(def.properties).length; - var result = ''; + const def = this.getModelDefinition(model); + const num = Object.keys(def.properties).length; + let result = ''; if (num > 0) result = 'DEFAULT'; - for (var i = 1; i < num && num > 1; i++) { + for (let i = 1; i < num && num > 1; i++) { result = result.concat(',DEFAULT'); } return 'VALUES(' + result + ')'; @@ -455,20 +455,20 @@ IBMDB.prototype.updateOrCreate = IBMDB.prototype.save = function(model, data, options, callback) { debug('IBMDB.prototype.updateOrCreate (enter): model=%j, data=%j, ' + 'options=%j ', model, data, options); - var self = this; - var idName = self.idName(model); - var stmt; - var tableName = self.tableEscaped(model); - var meta = {}; + const self = this; + const idName = self.idName(model); + let stmt; + const tableName = self.tableEscaped(model); + const meta = {}; function executeWithConnection(connection, cb) { // Execution for updateOrCreate requires running two // separate SQL statements. The second depends on the // result of the first. - var where = {}; + const where = {}; where[idName] = data[idName]; - var countStmt = new ParameterizedSQL('SELECT COUNT(*) AS CNT FROM '); + const countStmt = new ParameterizedSQL('SELECT COUNT(*) AS CNT FROM '); countStmt.merge(tableName); countStmt.merge(self.buildWhere(model, where)); countStmt.noResults = false; @@ -497,7 +497,7 @@ IBMDB.prototype.updateOrCreate = IBMDB.prototype.save = cb(null, data, meta); }); }); - }; + } if (options.transaction) { executeWithConnection(options.transaction.connection, @@ -550,11 +550,11 @@ IBMDB.prototype.updateOrCreate = IBMDB.prototype.save = IBMDB.prototype._replace = function(model, where, data, options, callback) { debug('IBMDB.prototype._replace (enter): model=%j, data=%j, ' + 'options=%j\n', model, data, options); - var self = this; - var idName = self.idName(model); - var stmt; - var tableName = self.tableEscaped(model); - var meta = {}; + const self = this; + const idName = self.idName(model); + let stmt; + const tableName = self.tableEscaped(model); + const meta = {}; function executeWithConnection(connection, cb) { // Execution for _replace requires running 3 @@ -563,7 +563,7 @@ IBMDB.prototype._replace = function(model, where, data, options, callback) { // idColumnEscaped(model) will find the id property for this model (e.g. awardId), // and will escape it with a columnName value (e.g. AWARD_ID) if it is specified. - var selectStmt = new ParameterizedSQL('SELECT ' + + const selectStmt = new ParameterizedSQL('SELECT ' + self.idColumnEscaped(model) + ' FROM '); selectStmt.merge(tableName); selectStmt.merge(self.buildWhere(model, where)); @@ -602,7 +602,7 @@ IBMDB.prototype._replace = function(model, where, data, options, callback) { return cb(errorIdNotFoundForReplace(where.id)); } }); - }; + } if (options.transaction) { executeWithConnection(options.transaction.connection, @@ -652,21 +652,21 @@ IBMDB.prototype._replace = function(model, where, data, options, callback) { IBMDB.prototype.replaceOrCreate = function(model, data, options, callback) { debug('IBMDB.prototype.replaceOrCreate (enter): model=%j, data=%j, ' + 'options=%j\n', model, data, options); - var self = this; - var idName = self.idName(model); - var stmt; - var tableName = self.tableEscaped(model); - var meta = {}; + const self = this; + const idName = self.idName(model); + let stmt; + const tableName = self.tableEscaped(model); + const meta = {}; function executeWithConnection(connection, cb) { // Execution for replaceOrCreate requires running 3 // separate SQL statements. The last depends on the // result of the first couple. - var where = {}; + const where = {}; where[idName] = data[idName]; - var selectStmt = new ParameterizedSQL('SELECT ' + self.escapeName(idName) + - ' FROM '); + const selectStmt = new ParameterizedSQL('SELECT ' + + self.escapeName(idName) + ' FROM '); selectStmt.merge(tableName); selectStmt.merge(self.buildWhere(model, where)); selectStmt.noResults = false; @@ -711,7 +711,7 @@ IBMDB.prototype.replaceOrCreate = function(model, data, options, callback) { }); } }); - }; + } if (options.transaction) { executeWithConnection(options.transaction.connection, @@ -752,13 +752,16 @@ IBMDB.prototype.replaceOrCreate = function(model, data, options, callback) { IBMDB.prototype.buildReplace = function(model, where, data, options) { debug('IBMDB.prototype.buildReplace: model=$s, where=%j, options=%j', model, where, options); - var self = this; - var idName = self.idName(model); - var fields = self.buildFieldsForReplace(model, data); - var updateClause = new ParameterizedSQL('UPDATE ' + self.tableEscaped(model)); - var whereClause = self.buildWhere(model, where); - var selectClause = new ParameterizedSQL('SELECT COUNT(\"' + idName + '\") ' + - 'AS \"affectedRows\" FROM FINAL TABLE('); + const self = this; + const idName = self.idName(model); + const fields = self.buildFieldsForReplace(model, data); + const updateClause = new ParameterizedSQL('UPDATE ' + + self.tableEscaped(model)); + const whereClause = self.buildWhere(model, where); + const selectClause = new ParameterizedSQL( + 'SELECT COUNT(\"' + idName + '\") ' + + 'AS \"affectedRows\" FROM FINAL TABLE(', + ); updateClause.merge([fields, whereClause]); selectClause.merge([updateClause, ')']); @@ -767,7 +770,7 @@ IBMDB.prototype.buildReplace = function(model, where, data, options) { }; IBMDB.prototype.getCountForAffectedRows = function(model, info) { - var affectedRows = info && info[0] && + const affectedRows = info && info[0] && typeof info[0].affectedRows === 'number' ? info[0].affectedRows : undefined; return affectedRows; @@ -775,22 +778,22 @@ IBMDB.prototype.getCountForAffectedRows = function(model, info) { IBMDB.prototype.createTable = function(model, cb) { debug('IBMDB.prototype.createTable'); - var self = this; - var tableName = self.tableEscaped(model); - var tableSchema = self.schema; - var columnDefinitions = self.buildColumnDefinitions(model); - var tasks = []; - var options = { + const self = this; + const tableName = self.tableEscaped(model); + const tableSchema = self.schema; + const columnDefinitions = self.buildColumnDefinitions(model); + const tasks = []; + const options = { noResultSet: true, }; tasks.push(function(callback) { - var sql = 'CREATE TABLE ' + tableSchema + '.' + tableName + + const sql = 'CREATE TABLE ' + tableSchema + '.' + tableName + ' (' + columnDefinitions + ');'; self.execute(sql, null, options, callback); }); - var indexes = self.buildIndexes(model); + const indexes = self.buildIndexes(model); indexes.forEach(function(i) { tasks.push(function(callback) { self.execute(i, null, options, callback); @@ -808,10 +811,10 @@ IBMDB.prototype.createTable = function(model, cb) { */ IBMDB.prototype.dropTable = function(model, cb) { debug('IBMDB.prototype.dropTable'); - var self = this; - var dropStmt = 'DROP TABLE ' + self.schema + '.' + + const self = this; + const dropStmt = 'DROP TABLE ' + self.schema + '.' + self.tableEscaped(model); - var options = { + const options = { noResultSet: true, }; @@ -829,14 +832,14 @@ IBMDB.prototype.dropTable = function(model, cb) { IBMDB.prototype.buildColumnDefinitions = function(model) { debug('IBMDB.prototype.buildColumnDefinitions'); - var self = this; - var sql = []; - var definition = this.getModelDefinition(model); - var pks = this.idNames(model).map(function(i) { + const self = this; + const sql = []; + const definition = this.getModelDefinition(model); + const pks = this.idNames(model).map(function(i) { return self.columnEscaped(model, i); }); Object.keys(definition.properties).forEach(function(prop) { - var colName = self.columnEscaped(model, prop); + const colName = self.columnEscaped(model, prop); sql.push(colName + ' ' + self.buildColumnDefinition(model, prop)); }); if (pks.length > 0) { @@ -857,8 +860,8 @@ IBMDB.prototype.buildColumnDefinitions = function(model) { IBMDB.prototype.buildExpression = function(columnName, operator, columnValue, propertyValue) { function buildClause(columnValue, separator, grouping) { - var values = []; - for (var i = 0, n = columnValue.length; i < n; i++) { + const values = []; + for (let i = 0, n = columnValue.length; i < n; i++) { if (columnValue[i] instanceof ParameterizedSQL) { values.push(columnValue[i]); } else { @@ -866,16 +869,16 @@ function(columnName, operator, columnValue, propertyValue) { } } separator = separator || ','; - var clause = ParameterizedSQL.join(values, separator); + const clause = ParameterizedSQL.join(values, separator); if (grouping) { clause.sql = '(' + clause.sql + ')'; } return clause; } - var self = this; - var sqlExp = columnName; - var clause, stmt; + const self = this; + let sqlExp = columnName; + let clause; if (columnValue instanceof ParameterizedSQL) { clause = columnValue; } else { @@ -920,35 +923,35 @@ function(columnName, operator, columnValue, propertyValue) { break; case 'regexp': // doc on `regexp_like`: https://www.ibm.com/support/knowledgecenter/SSEPGG_11.1.0/com.ibm.db2.luw.sql.ref.doc/doc/r0061494.html - var ignCaseFlag = columnValue.ignoreCase ? 'i' : 'c'; - var multiLineFlag = columnValue.multiline ? 'm' : ''; - var flags = ignCaseFlag + multiLineFlag; + const ignCaseFlag = columnValue.ignoreCase ? 'i' : 'c'; + const multiLineFlag = columnValue.multiline ? 'm' : ''; + const flags = ignCaseFlag + multiLineFlag; sqlExp = `REGEXP_LIKE(${columnName}, '${columnValue.source}', '${flags}')`; return sqlExp; } - stmt = ParameterizedSQL.join([sqlExp, clause], ''); + const stmt = ParameterizedSQL.join([sqlExp, clause], ''); return stmt; }; IBMDB.prototype.buildIndex = function(model, property) { debug('IBMDB.prototype.buildIndex'); - var self = this; - var prop = self.getPropertyDefinition(model, property); - var i = prop && prop.index; + const self = this; + const prop = self.getPropertyDefinition(model, property); + const i = prop && prop.index; if (!i) { return ''; } - var statement = new ParameterizedSQL('CREATE'); + const statement = new ParameterizedSQL('CREATE'); if (i.kind) { statement.merge(i.kind); } else if (i.unique) { statement.merge('UNIQUE'); } - var columnName = self.columnEscaped(model, property); + const columnName = self.columnEscaped(model, property); statement.merge('INDEX ' + columnName + ' ON ' + self.schema + '.'); statement.merge(self.tableEscaped(model) + '(' + columnName + ')'); @@ -958,10 +961,10 @@ IBMDB.prototype.buildIndex = function(model, property) { IBMDB.prototype.buildIndexes = function(model) { debug('IBMDB.prototype.buildIndexes'); - var self = this; - var indexClauses = []; - var definition = this.getModelDefinition(model); - var indexes = definition.settings.indexes || {}; + const self = this; + const indexClauses = []; + const definition = this.getModelDefinition(model); + const indexes = definition.settings.indexes || {}; /*! This module did not allow to define indexes the "new" way loopback wants to. - The new way to define indexes in loopback @@ -979,9 +982,9 @@ IBMDB.prototype.buildIndexes = function(model) { The module now allows both ways to define the indexes. */ // Build model level indexes - for (var index in indexes) { - var i = indexes[index]; - var statement = new ParameterizedSQL('CREATE'); + for (const index in indexes) { + const i = indexes[index]; + const statement = new ParameterizedSQL('CREATE'); if (i.kind) { statement.merge(i.kind); } else if ((i.options && i.options.unique && i.options.unique === true) || @@ -989,12 +992,12 @@ IBMDB.prototype.buildIndexes = function(model) { // if index unique indicator is configured statement.merge('UNIQUE'); } - var indexedColumns = []; - var columns = ''; + const indexedColumns = []; + let columns = ''; // if indexes are configured as "keys" if (i.keys) { // for each field in "keys" object - for (var key in i.keys) { + for (const key in i.keys) { // index in asc order if (i.keys[key] !== -1) { indexedColumns.push(key); @@ -1023,19 +1026,19 @@ IBMDB.prototype.buildIndexes = function(model) { IBMDB.prototype.buildColumnDefinition = function(model, prop) { debug('IBMDB.prototype.buildColumnDefinition: prop = %j', prop); - var p = this.getPropertyDefinition(model, prop); + const p = this.getPropertyDefinition(model, prop); if (p.id && p.generated) { return 'INT NOT NULL GENERATED BY DEFAULT' + ' AS IDENTITY (START WITH 1 INCREMENT BY 1)'; } - var line = this.columnDataType(model, prop) + ' ' + + const line = this.columnDataType(model, prop) + ' ' + (this.isNullable(p) ? '' : 'NOT NULL'); return line; }; IBMDB.prototype.columnDataType = function(model, property) { debug('IBMDB.prototype.columnDataType: property = %j', property); - var prop = this.getPropertyDefinition(model, property); + const prop = this.getPropertyDefinition(model, property); if (!prop) { return null; } @@ -1045,10 +1048,10 @@ IBMDB.prototype.columnDataType = function(model, property) { IBMDB.prototype.buildColumnType = function buildColumnType(propertyDefinition) { debug('IBMDB.prototype.buildColumnType: propertyDefinition=%j', propertyDefinition); - var self = this; - var dt = ''; - var p = propertyDefinition; - var type = p.type.name; + const self = this; + let dt = ''; + const p = propertyDefinition; + const type = p.type.name; switch (type) { default: @@ -1083,9 +1086,9 @@ IBMDB.prototype.buildColumnType = function buildColumnType(propertyDefinition) { IBMDB.prototype.convertTextType = function convertTextType(p, defaultType) { debug('IBMDB.prototype.convertTextType: defaultType = %j', defaultType); - var self = this; - var dt = defaultType; - var len = p.length || + const self = this; + let dt = defaultType; + let len = p.length || ((p.type !== String) ? 4096 : p.id ? 255 : 512); if (p[self.name]) { @@ -1109,10 +1112,10 @@ IBMDB.prototype.convertTextType = function convertTextType(p, defaultType) { IBMDB.prototype.convertNumberType = function convertNumberType(p, defaultType) { debug('IBMDB.prototype.convertNumberType: defaultType = %j', defaultType); - var self = this; - var dt = defaultType; - var precision = p.precision; - var scale = p.scale; + const self = this; + let dt = defaultType; + let precision = p.precision; + let scale = p.scale; if (p[self.name] && p[self.name].dataType) { dt = String(p[self.name].dataType); @@ -1148,7 +1151,7 @@ function stringOptions(p, columnType) { columnType += ' COLLATE ' + p.collation; } return columnType; -}; +} function buildLimit(limit, offset) { if (isNaN(limit)) { limit = 0; } @@ -1167,14 +1170,14 @@ function buildLimit(limit, offset) { IBMDB.prototype.applyPagination = function(model, stmt, filter) { debug('IBMDB.prototype.applyPagination'); - var limitClause = buildLimit(filter.limit, filter.offset || filter.skip); + const limitClause = buildLimit(filter.limit, filter.offset || filter.skip); return stmt.merge(limitClause); }; function errorIdNotFoundForReplace(idValue) { - var msg = g.f('Could not replace. Object with id %s does not exist!', + const msg = g.f('Could not replace. Object with id %s does not exist!', idValue); - var error = new Error(msg); + const error = new Error(msg); error.statusCode = error.status = 404; return error; } diff --git a/lib/migration.js b/lib/migration.js index 1959262..1555838 100644 --- a/lib/migration.js +++ b/lib/migration.js @@ -5,13 +5,13 @@ 'use strict'; -var async = require('async'); -var debug = require('debug')('loopback:ibmdb'); +const async = require('async'); +const debug = require('debug')('loopback:ibmdb'); module.exports = function(IBMDB) { IBMDB.prototype.showFields = function(model, cb) { - var self = this; - var sql = 'SELECT COLNAME AS NAME, TYPENAME AS DATATYPE, ' + + const self = this; + const sql = 'SELECT COLNAME AS NAME, TYPENAME AS DATATYPE, ' + 'COLNO, LENGTH AS DATALENGTH, NULLS FROM SYSCAT.COLUMNS ' + 'WHERE TRIM(TABNAME) LIKE \'' + self.table(model) + '\' ' + @@ -28,8 +28,8 @@ module.exports = function(IBMDB) { }; IBMDB.prototype.showIndexes = function(model, cb) { - var self = this; - var sql = 'SELECT TABNAME, TABSCHEMA, INDNAME, ' + + const self = this; + const sql = 'SELECT TABNAME, TABSCHEMA, INDNAME, ' + 'COLNAMES, UNIQUERULE FROM SYSCAT.INDEXES ' + 'WHERE TRIM(TABNAME) LIKE \'' + self.table(model) + '\' ' + @@ -45,18 +45,18 @@ module.exports = function(IBMDB) { }; IBMDB.prototype.getColumnsToAdd = function(model, actualFields) { - var self = this; - var m = self._models[model]; - var propNames = Object.keys(m.properties).filter(function(name) { + const self = this; + const m = self._models[model]; + const propNames = Object.keys(m.properties).filter(function(name) { return !!m.properties[name]; }); - var operations = []; + const operations = []; // change/add new fields propNames.forEach(function(propName) { if (m.properties[propName] && self.id(model, propName)) return; - var found; + let found; if (actualFields) { actualFields.forEach(function(f) { if (f.NAME === propName) { @@ -74,7 +74,7 @@ module.exports = function(IBMDB) { }); function actualize(propName, oldSettings) { - var newSettings = m.properties[propName]; + const newSettings = m.properties[propName]; if (newSettings && changed(newSettings, oldSettings)) { // TODO: NO TESTS EXECUTE THIS CODE PATH operations.push('CHANGE COLUMN ' + self.columnEscaped(model, propName) + @@ -102,18 +102,18 @@ module.exports = function(IBMDB) { }; IBMDB.prototype.getColumnsToDrop = function(model, actualFields) { - var self = this; - var m = this._models[model]; - var propNames = Object.keys(m.properties).filter(function(name) { + const self = this; + const m = this._models[model]; + const propNames = Object.keys(m.properties).filter(function(name) { return !!m.properties[name]; }); - var operations = []; + const operations = []; // drop columns if (actualFields) { actualFields.forEach(function(f) { - var notFound = !~propNames.indexOf(f.NAME); + const notFound = !~propNames.indexOf(f.NAME); if (m.properties[f.NAME] && self.id(model, f.NAME)) return; if (notFound || !m.properties[f.NAME]) { operations.push('DROP COLUMN ' + self.columnEscaped(model, f.NAME)); @@ -124,15 +124,15 @@ module.exports = function(IBMDB) { }; IBMDB.prototype.dropIndexes = function(model, actualIndexes) { - var self = this; - var operations = []; + const self = this; + const operations = []; // If there are indexes for this table then we need to drop them. // Generate the statements here to drop all known indexes. if (actualIndexes) { actualIndexes.forEach(function(i) { - var isPrimaryIndex = i.UNIQUERULE === 'P'; - var stmt; + const isPrimaryIndex = i.UNIQUERULE === 'P'; + let stmt; if (isPrimaryIndex) { stmt = 'ALTER TABLE ' + self.schema + '.' + self.tableEscaped(model) + ' ' + 'DROP PRIMARY KEY'; @@ -150,10 +150,10 @@ module.exports = function(IBMDB) { callback, checkOnly) { debug('IBMDB.prototype.alterTable %j %j %j %j', model, actualFields, actualIndexes, checkOnly); - var self = this; - var sql = []; - var tasks = []; - var pks = this.idNames(model).map(function(i) { + const self = this; + let sql = []; + const tasks = []; + const pks = this.idNames(model).map(function(i) { return self.columnEscaped(model, i); }); @@ -163,7 +163,7 @@ module.exports = function(IBMDB) { // Add/Modify and drop column statements for ALTER TABLE are generated // prior to re-building the indexes as defined in the model. - var operations = self.getAddModifyColumns(model, actualFields); + let operations = self.getAddModifyColumns(model, actualFields); operations = operations.concat(self.getDropColumns(model, actualFields)); if (operations.length) { diff --git a/package-lock.json b/package-lock.json index 4b51952..4160901 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,14 +16,14 @@ "strong-globalize": "^6.0.6" }, "devDependencies": { - "eslint": "^9.31.0", + "eslint": "^8.57.1", "eslint-config-loopback": "^13.1.0", "jscs": "^3.0.7", "loopback-datasource-juggler": "^5.1.10", "mocha": "^11.7.1" }, "engines": { - "node": ">=8.9" + "node": ">=20" } }, "node_modules/@eslint-community/eslint-utils": { @@ -45,19 +45,6 @@ "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" } }, - "node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys": { - "version": "3.4.3", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", - "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", - "dev": true, - "license": "Apache-2.0", - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - } - }, "node_modules/@eslint-community/regexpp": { "version": "4.12.1", "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.12.1.tgz", @@ -68,55 +55,16 @@ "node": "^12.0.0 || ^14.0.0 || >=16.0.0" } }, - "node_modules/@eslint/config-array": { - "version": "0.21.0", - "resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.21.0.tgz", - "integrity": "sha512-ENIdc4iLu0d93HeYirvKmrzshzofPw6VkZRKQGe9Nv46ZnWUzcF1xV01dcvEg/1wXUR61OmmlSfyeyO7EvjLxQ==", - "dev": true, - "license": "Apache-2.0", - "dependencies": { - "@eslint/object-schema": "^2.1.6", - "debug": "^4.3.1", - "minimatch": "^3.1.2" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - } - }, - "node_modules/@eslint/config-helpers": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/@eslint/config-helpers/-/config-helpers-0.3.0.tgz", - "integrity": "sha512-ViuymvFmcJi04qdZeDc2whTHryouGcDlaxPqarTD0ZE10ISpxGUVZGZDx4w01upyIynL3iu6IXH2bS1NhclQMw==", - "dev": true, - "license": "Apache-2.0", - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - } - }, - "node_modules/@eslint/core": { - "version": "0.15.1", - "resolved": "https://registry.npmjs.org/@eslint/core/-/core-0.15.1.tgz", - "integrity": "sha512-bkOp+iumZCCbt1K1CmWf0R9pM5yKpDv+ZXtvSyQpudrI9kuFLp+bM2WOPXImuD/ceQuaa8f5pj93Y7zyECIGNA==", - "dev": true, - "license": "Apache-2.0", - "dependencies": { - "@types/json-schema": "^7.0.15" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - } - }, "node_modules/@eslint/eslintrc": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.3.1.tgz", - "integrity": "sha512-gtF186CXhIl1p4pJNGZw8Yc6RlshoePRvE0X91oPGb3vZ8pM3qOS9W9NGPat9LziaBV7XrJWGylNQXkGcnM3IQ==", + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.4.tgz", + "integrity": "sha512-269Z39MS6wVJtsoUl10L60WdkhJVdPG24Q4eZTH3nnF6lpvSShEK3wQjDX9JRWAUPvPh7COouPpU9IrqaZFvtQ==", "dev": true, - "license": "MIT", "dependencies": { "ajv": "^6.12.4", "debug": "^4.3.2", - "espree": "^10.0.1", - "globals": "^14.0.0", + "espree": "^9.6.0", + "globals": "^13.19.0", "ignore": "^5.2.0", "import-fresh": "^3.2.1", "js-yaml": "^4.1.0", @@ -124,85 +72,34 @@ "strip-json-comments": "^3.1.1" }, "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, "funding": { "url": "https://opencollective.com/eslint" } }, "node_modules/@eslint/js": { - "version": "9.31.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.31.0.tgz", - "integrity": "sha512-LOm5OVt7D4qiKCqoiPbA7LWmI+tbw1VbTUowBcUMgQSuM6poJufkFkYDcQpo5KfgD39TnNySV26QjOh7VFpSyw==", - "dev": true, - "license": "MIT", - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "url": "https://eslint.org/donate" - } - }, - "node_modules/@eslint/object-schema": { - "version": "2.1.6", - "resolved": "https://registry.npmjs.org/@eslint/object-schema/-/object-schema-2.1.6.tgz", - "integrity": "sha512-RBMg5FRL0I0gs51M/guSAj5/e14VQ4tpZnQNWwuDT66P14I43ItmPfIZRhO9fUVIPOAQXU47atlywZ/czoqFPA==", - "dev": true, - "license": "Apache-2.0", - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - } - }, - "node_modules/@eslint/plugin-kit": { - "version": "0.3.3", - "resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.3.3.tgz", - "integrity": "sha512-1+WqvgNMhmlAambTvT3KPtCl/Ibr68VldY2XY40SL1CE0ZXiakFR/cbTspaF5HsnpDMvcYYoJHfl4980NBjGag==", + "version": "8.57.1", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.57.1.tgz", + "integrity": "sha512-d9zaMRSTIKDLhctzH12MtXvJKSSUhaHcjV+2Z+GK+EEY7XKpP5yR4x+N3TAcHTcu963nIr+TMcCb4DBCYX1z6Q==", "dev": true, - "license": "Apache-2.0", - "dependencies": { - "@eslint/core": "^0.15.1", - "levn": "^0.4.1" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - } - }, - "node_modules/@humanfs/core": { - "version": "0.19.1", - "resolved": "https://registry.npmjs.org/@humanfs/core/-/core-0.19.1.tgz", - "integrity": "sha512-5DyQ4+1JEUzejeK1JGICcideyfUbGixgS9jNgex5nqkW+cY7WZhxBigmieN5Qnw9ZosSNVC9KQKyb+GUaGyKUA==", - "dev": true, - "license": "Apache-2.0", "engines": { - "node": ">=18.18.0" + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" } }, - "node_modules/@humanfs/node": { - "version": "0.16.6", - "resolved": "https://registry.npmjs.org/@humanfs/node/-/node-0.16.6.tgz", - "integrity": "sha512-YuI2ZHQL78Q5HbhDiBA1X4LmYdXCKCMQIfw0pw7piHJwyREFebJUvrQN4cMssyES6x+vfUbx1CIpaQUKYdQZOw==", + "node_modules/@humanwhocodes/config-array": { + "version": "0.13.0", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.13.0.tgz", + "integrity": "sha512-DZLEEqFWQFiyK6h5YIeynKx7JlvCYWL0cImfSRXZ9l4Sg2efkFGTuFf6vzXjK1cq6IYkU+Eg/JizXw+TD2vRNw==", + "deprecated": "Use @eslint/config-array instead", "dev": true, - "license": "Apache-2.0", "dependencies": { - "@humanfs/core": "^0.19.1", - "@humanwhocodes/retry": "^0.3.0" + "@humanwhocodes/object-schema": "^2.0.3", + "debug": "^4.3.1", + "minimatch": "^3.0.5" }, "engines": { - "node": ">=18.18.0" - } - }, - "node_modules/@humanfs/node/node_modules/@humanwhocodes/retry": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/@humanwhocodes/retry/-/retry-0.3.1.tgz", - "integrity": "sha512-JBxkERygn7Bv/GbN5Rv8Ul6LVknS+5Bp6RgDC/O8gEBU/yeH5Ui5C/OlWrTb6qct7LjjfT6Re2NxB0ln0yYybA==", - "dev": true, - "license": "Apache-2.0", - "engines": { - "node": ">=18.18" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/nzakas" + "node": ">=10.10.0" } }, "node_modules/@humanwhocodes/module-importer": { @@ -219,19 +116,12 @@ "url": "https://github.com/sponsors/nzakas" } }, - "node_modules/@humanwhocodes/retry": { - "version": "0.4.3", - "resolved": "https://registry.npmjs.org/@humanwhocodes/retry/-/retry-0.4.3.tgz", - "integrity": "sha512-bV0Tgo9K4hfPCek+aMAn81RppFKv2ySDQeMoSZuvTASywNTnVJCArCZE2FWqpvIatKu7VMRLWlR1EazvVhDyhQ==", - "dev": true, - "license": "Apache-2.0", - "engines": { - "node": ">=18.18" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/nzakas" - } + "node_modules/@humanwhocodes/object-schema": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.3.tgz", + "integrity": "sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA==", + "deprecated": "Use @eslint/object-schema instead", + "dev": true }, "node_modules/@isaacs/balanced-match": { "version": "4.0.1", @@ -359,6 +249,41 @@ "url": "https://github.com/chalk/wrap-ansi?sponsor=1" } }, + "node_modules/@nodelib/fs.scandir": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", + "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", + "dev": true, + "dependencies": { + "@nodelib/fs.stat": "2.0.5", + "run-parallel": "^1.1.9" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.stat": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", + "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", + "dev": true, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.walk": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", + "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", + "dev": true, + "dependencies": { + "@nodelib/fs.scandir": "2.1.5", + "fastq": "^1.6.0" + }, + "engines": { + "node": ">= 8" + } + }, "node_modules/@pkgjs/parseargs": { "version": "0.11.0", "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", @@ -370,19 +295,11 @@ "node": ">=14" } }, - "node_modules/@types/estree": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.8.tgz", - "integrity": "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==", - "dev": true, - "license": "MIT" - }, - "node_modules/@types/json-schema": { - "version": "7.0.15", - "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", - "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", - "dev": true, - "license": "MIT" + "node_modules/@ungap/structured-clone": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.3.0.tgz", + "integrity": "sha512-WmoN8qaIAo7WTYWbAZuG8PYEhn5fkz7dZrqTBZ7dtt//lL2Gwms1IcnQ5yHqjDfX8Ft5j4YzDM23f87zBfDe9g==", + "dev": true }, "node_modules/accept-language": { "version": "3.0.20", @@ -398,7 +315,6 @@ "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.15.0.tgz", "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==", "dev": true, - "license": "MIT", "bin": { "acorn": "bin/acorn" }, @@ -411,7 +327,6 @@ "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", "dev": true, - "license": "MIT", "peerDependencies": { "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" } @@ -430,7 +345,6 @@ "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", "dev": true, - "license": "MIT", "dependencies": { "fast-deep-equal": "^3.1.1", "fast-json-stable-stringify": "^2.0.0", @@ -759,7 +673,6 @@ "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", "dev": true, - "license": "MIT", "engines": { "node": ">=6" } @@ -1224,6 +1137,18 @@ "node": ">=0.3.1" } }, + "node_modules/doctrine": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", + "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==", + "dev": true, + "dependencies": { + "esutils": "^2.0.2" + }, + "engines": { + "node": ">=6.0.0" + } + }, "node_modules/dom-serializer": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.2.2.tgz", @@ -1436,64 +1361,59 @@ } }, "node_modules/eslint": { - "version": "9.31.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.31.0.tgz", - "integrity": "sha512-QldCVh/ztyKJJZLr4jXNUByx3gR+TDYZCRXEktiZoUR3PGy4qCmSbkxcIle8GEwGpb5JBZazlaJ/CxLidXdEbQ==", + "version": "8.57.1", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.57.1.tgz", + "integrity": "sha512-ypowyDxpVSYpkXr9WPv2PAZCtNip1Mv5KTW0SCurXv/9iOpcrH9PaqUElksqEB6pChqHGDRCFTyrZlGhnLNGiA==", + "deprecated": "This version is no longer supported. Please see https://eslint.org/version-support for other options.", "dev": true, - "license": "MIT", "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", - "@eslint-community/regexpp": "^4.12.1", - "@eslint/config-array": "^0.21.0", - "@eslint/config-helpers": "^0.3.0", - "@eslint/core": "^0.15.0", - "@eslint/eslintrc": "^3.3.1", - "@eslint/js": "9.31.0", - "@eslint/plugin-kit": "^0.3.1", - "@humanfs/node": "^0.16.6", + "@eslint-community/regexpp": "^4.6.1", + "@eslint/eslintrc": "^2.1.4", + "@eslint/js": "8.57.1", + "@humanwhocodes/config-array": "^0.13.0", "@humanwhocodes/module-importer": "^1.0.1", - "@humanwhocodes/retry": "^0.4.2", - "@types/estree": "^1.0.6", - "@types/json-schema": "^7.0.15", + "@nodelib/fs.walk": "^1.2.8", + "@ungap/structured-clone": "^1.2.0", "ajv": "^6.12.4", "chalk": "^4.0.0", - "cross-spawn": "^7.0.6", + "cross-spawn": "^7.0.2", "debug": "^4.3.2", + "doctrine": "^3.0.0", "escape-string-regexp": "^4.0.0", - "eslint-scope": "^8.4.0", - "eslint-visitor-keys": "^4.2.1", - "espree": "^10.4.0", - "esquery": "^1.5.0", + "eslint-scope": "^7.2.2", + "eslint-visitor-keys": "^3.4.3", + "espree": "^9.6.1", + "esquery": "^1.4.2", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", - "file-entry-cache": "^8.0.0", + "file-entry-cache": "^6.0.1", "find-up": "^5.0.0", "glob-parent": "^6.0.2", + "globals": "^13.19.0", + "graphemer": "^1.4.0", "ignore": "^5.2.0", "imurmurhash": "^0.1.4", "is-glob": "^4.0.0", + "is-path-inside": "^3.0.3", + "js-yaml": "^4.1.0", "json-stable-stringify-without-jsonify": "^1.0.1", + "levn": "^0.4.1", "lodash.merge": "^4.6.2", "minimatch": "^3.1.2", "natural-compare": "^1.4.0", - "optionator": "^0.9.3" + "optionator": "^0.9.3", + "strip-ansi": "^6.0.1", + "text-table": "^0.2.0" }, "bin": { "eslint": "bin/eslint.js" }, "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, "funding": { - "url": "https://eslint.org/donate" - }, - "peerDependencies": { - "jiti": "*" - }, - "peerDependenciesMeta": { - "jiti": { - "optional": true - } + "url": "https://opencollective.com/eslint" } }, "node_modules/eslint-config-loopback": { @@ -1523,48 +1443,45 @@ } }, "node_modules/eslint-scope": { - "version": "8.4.0", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-8.4.0.tgz", - "integrity": "sha512-sNXOfKCn74rt8RICKMvJS7XKV/Xk9kA7DyJr8mJik3S7Cwgy3qlkkmyS2uQB3jiJg6VNdZd/pDBJu0nvG2NlTg==", + "version": "7.2.2", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz", + "integrity": "sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg==", "dev": true, - "license": "BSD-2-Clause", "dependencies": { "esrecurse": "^4.3.0", "estraverse": "^5.2.0" }, "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, "funding": { "url": "https://opencollective.com/eslint" } }, "node_modules/eslint-visitor-keys": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.1.tgz", - "integrity": "sha512-Uhdk5sfqcee/9H/rCOJikYz67o0a2Tw2hGRPOG2Y1R2dg7brRe1uG0yaNQDHu+TO/uQPF/5eCapvYSmHUjt7JQ==", + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", "dev": true, - "license": "Apache-2.0", "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, "funding": { "url": "https://opencollective.com/eslint" } }, "node_modules/espree": { - "version": "10.4.0", - "resolved": "https://registry.npmjs.org/espree/-/espree-10.4.0.tgz", - "integrity": "sha512-j6PAQ2uUr79PZhBjP5C5fhl8e39FmRnOjsD5lGnWrFU8i2G776tBK7+nP8KuQUTTyAZUwfQqXAgrVH5MbH9CYQ==", + "version": "9.6.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.6.1.tgz", + "integrity": "sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ==", "dev": true, - "license": "BSD-2-Clause", "dependencies": { - "acorn": "^8.15.0", + "acorn": "^8.9.0", "acorn-jsx": "^5.3.2", - "eslint-visitor-keys": "^4.2.1" + "eslint-visitor-keys": "^3.4.1" }, "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, "funding": { "url": "https://opencollective.com/eslint" @@ -1602,7 +1519,6 @@ "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", "dev": true, - "license": "BSD-2-Clause", "dependencies": { "estraverse": "^5.2.0" }, @@ -1675,15 +1591,13 @@ "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", - "dev": true, - "license": "MIT" + "dev": true }, "node_modules/fast-json-stable-stringify": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", - "dev": true, - "license": "MIT" + "dev": true }, "node_modules/fast-levenshtein": { "version": "2.0.6", @@ -1692,17 +1606,25 @@ "dev": true, "license": "MIT" }, + "node_modules/fastq": { + "version": "1.19.1", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.19.1.tgz", + "integrity": "sha512-GwLTyxkCXjXbxqIhTsMI2Nui8huMPtnxg7krajPJAjnEG/iiOS7i+zCtWGZR9G0NBKbXKh6X9m9UIsYX/N6vvQ==", + "dev": true, + "dependencies": { + "reusify": "^1.0.4" + } + }, "node_modules/file-entry-cache": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-8.0.0.tgz", - "integrity": "sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ==", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", + "integrity": "sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==", "dev": true, - "license": "MIT", "dependencies": { - "flat-cache": "^4.0.0" + "flat-cache": "^3.0.4" }, "engines": { - "node": ">=16.0.0" + "node": "^10.12.0 || >=12.0.0" } }, "node_modules/file-uri-to-path": { @@ -1739,25 +1661,61 @@ } }, "node_modules/flat-cache": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-4.0.1.tgz", - "integrity": "sha512-f7ccFPK3SXFHpx15UIGyRJ/FJQctuKZ0zVuN3frBo4HnK3cay9VEW0R6yPYFHC0AgqhukPzKjq22t5DmAyqGyw==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.2.0.tgz", + "integrity": "sha512-CYcENa+FtcUKLmhhqyctpclsq7QF38pKjZHsGNiSQF5r4FtoKDWabFDl3hzaEQMvT1LHEysw5twgLvpYYb4vbw==", "dev": true, - "license": "MIT", "dependencies": { "flatted": "^3.2.9", - "keyv": "^4.5.4" + "keyv": "^4.5.3", + "rimraf": "^3.0.2" + }, + "engines": { + "node": "^10.12.0 || >=12.0.0" + } + }, + "node_modules/flat-cache/node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "deprecated": "Glob versions prior to v9 are no longer supported", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" }, "engines": { - "node": ">=16" + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/flat-cache/node_modules/rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "deprecated": "Rimraf versions prior to v4 are no longer supported", + "dev": true, + "dependencies": { + "glob": "^7.1.3" + }, + "bin": { + "rimraf": "bin.js" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" } }, "node_modules/flatted": { "version": "3.3.3", "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.3.3.tgz", "integrity": "sha512-GX+ysw4PBCz0PzosHDepZGANEuFCMLrnRTiEy9McGjmkCQYwRq4A/X786G/fjM/+OjsWSU1ZrY5qyARZmO/uwg==", - "dev": true, - "license": "ISC" + "dev": true }, "node_modules/follow-redirects": { "version": "1.15.9", @@ -1988,13 +1946,15 @@ } }, "node_modules/globals": { - "version": "14.0.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz", - "integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==", + "version": "13.24.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.24.0.tgz", + "integrity": "sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ==", "dev": true, - "license": "MIT", + "dependencies": { + "type-fest": "^0.20.2" + }, "engines": { - "node": ">=18" + "node": ">=8" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" @@ -2025,6 +1985,12 @@ "dev": true, "license": "MIT" }, + "node_modules/graphemer": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", + "integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==", + "dev": true + }, "node_modules/has-ansi": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", @@ -2231,7 +2197,6 @@ "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz", "integrity": "sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==", "dev": true, - "license": "MIT", "engines": { "node": ">= 4" } @@ -2241,7 +2206,6 @@ "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.1.tgz", "integrity": "sha512-TR3KfrTZTYLPB6jUjfx6MF9WcWrHL9su5TObK4ZkYgBdWKPOFoSoQIdEuTuR82pmtxH2spWG9h6etwfr1pLBqQ==", "dev": true, - "license": "MIT", "dependencies": { "parent-module": "^1.0.0", "resolve-from": "^4.0.0" @@ -2506,6 +2470,15 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/is-path-inside": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", + "integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/is-plain-obj": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", @@ -2955,15 +2928,13 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==", - "dev": true, - "license": "MIT" + "dev": true }, "node_modules/json-schema-traverse": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", - "dev": true, - "license": "MIT" + "dev": true }, "node_modules/json-stable-stringify-without-jsonify": { "version": "1.0.1", @@ -3014,7 +2985,6 @@ "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", "integrity": "sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==", "dev": true, - "license": "MIT", "dependencies": { "json-buffer": "3.0.1" } @@ -3755,7 +3725,6 @@ "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", "dev": true, - "license": "MIT", "dependencies": { "callsites": "^3.0.0" }, @@ -3923,7 +3892,6 @@ "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", "dev": true, - "license": "MIT", "engines": { "node": ">=6" } @@ -3955,6 +3923,26 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/queue-microtask": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", + "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, "node_modules/ramda": { "version": "0.26.1", "resolved": "https://registry.npmjs.org/ramda/-/ramda-0.26.1.tgz", @@ -4083,11 +4071,20 @@ "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", "dev": true, - "license": "MIT", "engines": { "node": ">=4" } }, + "node_modules/reusify": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.1.0.tgz", + "integrity": "sha512-g6QUff04oZpHs0eG5p83rFLhHeV00ug/Yf9nZM6fLeUrPguBTkTQOdpAWWspMh55TZfVQDPaN3NQJfbVRAxdIw==", + "dev": true, + "engines": { + "iojs": ">=1.0.0", + "node": ">=0.10.0" + } + }, "node_modules/revalidator": { "version": "0.1.8", "resolved": "https://registry.npmjs.org/revalidator/-/revalidator-0.1.8.tgz", @@ -4134,6 +4131,29 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/run-parallel": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", + "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "queue-microtask": "^1.2.2" + } + }, "node_modules/safe-buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", @@ -4643,6 +4663,12 @@ "tar-fs": "^1.8.1" } }, + "node_modules/text-table": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", + "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", + "dev": true + }, "node_modules/to-buffer": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/to-buffer/-/to-buffer-1.2.1.tgz", @@ -4703,6 +4729,18 @@ "node": ">= 0.8.0" } }, + "node_modules/type-fest": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", + "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/typed-array-buffer": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/typed-array-buffer/-/typed-array-buffer-1.0.3.tgz", @@ -4757,7 +4795,6 @@ "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", "dev": true, - "license": "BSD-2-Clause", "dependencies": { "punycode": "^2.1.0" } diff --git a/package.json b/package.json index 393adb3..04bffee 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "2.6.1", "description": "LoopBack Connector common code for IBM databases", "engines": { - "node": ">=8.9" + "node": ">=20" }, "keywords": [ "IBM", @@ -16,6 +16,7 @@ "main": "index.js", "scripts": { "lint": "eslint .", + "lint:fix": "eslint . --fix", "test": "mocha --timeout 10000 --require test/init.js test/*.js", "posttest": "npm run lint" }, @@ -27,11 +28,13 @@ "strong-globalize": "^6.0.6" }, "devDependencies": { - "eslint": "^9.31.0", + "eslint": "^8.57.1", "eslint-config-loopback": "^13.1.0", "jscs": "^3.0.7", "loopback-datasource-juggler": "^5.1.10", - "mocha": "^11.7.1" + "mocha": "^11.7.1", + "@commitlint/cli": "^19.0.0", + "@commitlint/config-conventional": "^19.0.0" }, "repository": { "type": "git", diff --git a/test/connect.test.js b/test/connect.test.js index 315e426..763323c 100644 --- a/test/connect.test.js +++ b/test/connect.test.js @@ -6,12 +6,12 @@ 'use strict'; /* eslint-env node, mocha */ -var EventEmitter = require('events').EventEmitter; -var IBMDB = require('../').IBMDB; +const EventEmitter = require('events').EventEmitter; +const IBMDB = require('../').IBMDB; describe('basic connector', function() { - var ds = new EventEmitter; - var connection = null; + const ds = new EventEmitter; + let connection = null; it('can be constructed', function(done) { ds.connector = new IBMDB('db2', global.config); diff --git a/test/functional.test.js b/test/functional.test.js index 4586b60..d8c025c 100644 --- a/test/functional.test.js +++ b/test/functional.test.js @@ -7,11 +7,11 @@ /* eslint-env node, mocha */ process.env.NODE_ENV = 'test'; -var assert = require('assert'); -var EventEmitter = require('events').EventEmitter; -var IBMDB = require('../').IBMDB; +const assert = require('assert'); +const EventEmitter = require('events').EventEmitter; +const IBMDB = require('../').IBMDB; -var db = new EventEmitter; +const db = new EventEmitter; describe('functional test', function() { before(function(done) { @@ -20,19 +20,19 @@ describe('functional test', function() { done(); }); it('`fromColumnValue` function', function(done) { - var result = db.connector.fromColumnValue({}, undefined); + const result = db.connector.fromColumnValue({}, undefined); assert.equal(result, undefined); done(); }); it('`toColumnValue` function returns ms in the first 3 digits of µs', function(done) { - var prop = { + const prop = { type: { name: 'Date', }, }; - var dateValue = new Date(1999, 0, 9, 10, 11, 12, 1); - var result = db.connector.toColumnValue(prop, dateValue); + const dateValue = new Date(1999, 0, 9, 10, 11, 12, 1); + let result = db.connector.toColumnValue(prop, dateValue); assert.equal(result, '1999-01-09-10.11.12.001000'); dateValue.setMilliseconds(12); result = db.connector.toColumnValue(prop, dateValue); diff --git a/test/ibmdb.config.test.js b/test/ibmdb.config.test.js index 882beb0..7778940 100644 --- a/test/ibmdb.config.test.js +++ b/test/ibmdb.config.test.js @@ -7,9 +7,9 @@ /* eslint-env node, mocha */ process.env.NODE_ENV = 'test'; -var assert = require('assert'); +const assert = require('assert'); -var config; +let config; before(function() { config = global.config; diff --git a/test/init.js b/test/init.js index 4210cc4..268e75a 100644 --- a/test/init.js +++ b/test/init.js @@ -5,9 +5,9 @@ 'use strict'; -var DataSource = require('loopback-datasource-juggler').DataSource; +const DataSource = require('loopback-datasource-juggler').DataSource; -var config = { +const config = { username: process.env.DB2_USERNAME, password: process.env.DB2_PASSWORD, hostname: process.env.DB2_HOSTNAME || 'localhost', @@ -19,7 +19,7 @@ var config = { global.config = config; global.getDataSource = global.getSchema = function(options) { - var db = new DataSource(require('../'), config); + const db = new DataSource(require('../'), config); return db; };