Registry / database / ut-port-sql

ut-port-sql

JSON →
library9.2.9jsnpmunverified

A port module for the UT framework that provides SQL Server database integration via the mssql driver. It handles connection management, database/ schema creation, synchronization of database objects from file folders, and automatic linking of stored procedures as callable methods. Current stable version is 9.2.9, released under the MIT license. Peer dependency on ut-run ^10.78.17. Key differentiators: automated schema sync from file system, stored procedure linking, support for both tedious and msnodesqlv8 drivers, optional automatic database creation with elevated credentials.

npm install ut-port-sql
INSTALL
IMPORT
SIG · UT-PORT-SQL
U
ut-port-sql
databasejavascriptv9.2.9
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ut-port-sql
const sqlPort = require('ut-port-sql')
import sqlPort from 'ut-port-sql'
This package is CJS-only; no ESM exports. Use require().
default export (class factory)
require('ut-port-sql')(...arguments)
new require('ut-port-sql')()
The module exports a function that returns a class when called with arguments. Do not instantiate directly.
bus.importMethod
bus.importMethod('schema1.storedProcedureName')({param1: 1})
bus.importMethod('storedProcedureName')({})
Method names include schema prefix if linked via linkSP: true. Omitting schema will fail.

Shows how to require ut-port-sql, extend the returned class, provide configuration, and initialize the port.

const sqlPort = require('ut-port-sql'); class db extends sqlPort({ config: { test: false }, // With actual ut-run bus instance bus: { importMethod: () => () => {}, config: { implementation: 'db', main: {}, bus: {} } } }) { get defaults() { return { namespace: ['db/moduleName'], imports: ['sql', 'utModuleName.sql'] }; } } const dbInstance = new db(); dbInstance.init().then(() => { console.log('Port initialized'); }).catch(err => console.error(err));
Debug
Known issues
breakingPeer dependency ut-run ^10.78.17 required; incompatible with older ut-run versions.
fix
Ensure ut-run is at version 10.78.17 or higher.
affects: >=9.0.0
gotchaStored procedure names must include schema prefix when called via bus.importMethod if linkSP is true.
fix
Use full schema.procedureName as method name.
affects: >=1.0.0
deprecatedThe msnodesqlv8 driver support is considered legacy; tedious driver is recommended.
fix
Use driver: 'tedious' (default) rather than 'msnodesqlv8' for Windows authentication.
affects: >=8.0.0
gotchaAutomatic database creation requires separate 'create' user with elevated privileges; missing this will cause creation to fail silently.
fix
Supply db.create.user and db.create.password in configuration for auto-creation.
affects: >=1.0.0
breakingNode.js engines required: ^12.16.3 || ^14.15.3 || ^16.14.0; older or newer versions may not work.
fix
Use Node.js 14.15.3+ or 16.14.0+.
affects: >=9.0.0
Errors
Common errors & fixes
Error: Cannot find module 'ut-port-sql'
Package not installed or missing from node_modules.
fix
Run 'npm install ut-port-sql' or ensure it is in package.json dependencies.
TypeError: ut_port_sql is not a function
Using ES import syntax or assigning the default export incorrectly (e.g., import sqlPort from 'ut-port-sql').
fix
Use 'const sqlPort = require("ut-port-sql");' 
Error: Method 'schema1.storedProcedureName' not found
Procedure not linked or schema not synced; or method name used without schema prefix.
fix
Ensure schema folder has linkSP: true and method name includes schema prefix.
ConnectionError: Failed to connect to server: db-server\instance
Invalid connection configuration or SQL Server not reachable.
fix
Check db.connection.server, database, credentials, and network/firewall settings.
Upgrade
Version history
9.2.9latest on npm
Audit
Dependencies
ut-runrequiredPeer dependency required for framework integration; provides bus and method infrastructure.
Agent activity
33 hits · last 30 days
node
24
Meta
2
OpenAI (training)
2
Amazon
1
Resources
ut-port-sql — npm install ut-port-sql · libregistry