diff --git a/appveyor.yml b/appveyor.yml index 9960a43a..260ae8d2 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -11,7 +11,6 @@ environment: matrix: - nodejs_version: 20 - nodejs_version: 18 - - nodejs_version: 16 test_script: - ps: Write-Host "msnodesqlv8 test script" diff --git a/lib/index.d.ts b/lib/index.d.ts index 587b5a2c..679fec0d 100644 --- a/lib/index.d.ts +++ b/lib/index.d.ts @@ -1,1154 +1,1153 @@ +declare namespace MsNodeSqlV8 { + export type sqlJsColumnType = string | boolean | Date | number | Buffer + export type sqlRecordType = Record + export type sqlObjectType = sqlRecordType | object | any + export type sqlQueryParamType = sqlJsColumnType | sqlJsColumnType[] | ConcreteColumnType | ConcreteColumnType[] | TvpParam + export type sqlPoolEventType = MessageCb | PoolStatusRecordCb | PoolOptionsEventCb | StatusCb + export type sqlQueryEventType = SubmittedEventCb | ColumnEventCb | EventColumnCb | StatusCb | RowEventCb | MetaEventCb | RowCountEventCb + export type sqlProcParamType = sqlObjectType | sqlQueryParamType + export type sqlQueryType = string | QueryDescription + export type sqlConnectType = string | ConnectDescription + export type sqlColumnResultsType = sqlObjectType | sqlJsColumnType | any + export type sqlBulkType = sqlObjectType[] + + export interface GetSetUTC { + /** + * used to switch on date conversion for date columns from database to UTC + * @param utc flag to turn conversio on or off + */ + setUseUTC: (utc: boolean) => void + /** + * fetch the current UTC conversion status. + * @returns a flag for conversion. + */ + getUseUTC: () => boolean + } + + export interface SubmitQuery { + /** + * submit query on an open connection with optional paramteters that will be bound + * by native driver. Can either use an event stream driven mechanism by subscribing to + * returned query e.g. on('column', ..) , on ('meta', ..) or provide a callback which + * will be invoked when all results are ready. Event subscription for large queries + * can be much more memory efficient as the data will not be cached in driver as results + * are built. However a callback can be more convenient. + * + * @param sqlOrQuery the textual query to submit + * @param paramsOrCb optional bound parameters either array of JS native types or bound user defined parameters, + * else an optional callback invoked with results of query. + * @param cb optional callback invoked when query completes with array of objects built from column names + * as properties. e.g. { cola: 1, colb: 'hello }. Note the oberhead required which for large bumbers + * of rows will grow the node process significantly. + * @returns a query object which can be used to cancel, pause, resume or subscribe for events. + */ + query: (sqlOrQuery: sqlQueryType, paramsOrCb?: sqlQueryParamType[] | QueryCb, cb?: QueryCb) => Query + queryRaw: (sqlOrQuery: sqlQueryType, paramsOrCb?: sqlQueryParamType[] | QueryRawCb, cb?: QueryRawCb) => Query + } + + export interface AggregatorPromises { + /** + * + * @param sql the textual query to submit + * @param params optional bound parameters either array of JS native types or bound user defined parameters + * @param options optional parameters for query execution e.g. timeout + * @returns a promise to return all results from all compounded queries submitted + */ + query: (sql: string, params?: sqlQueryParamType[], options?: QueryAggregatorOptions) => Promise + /** + * + * @param name the name of procedure to call + * @param params optional bound parameters either array of JS native types or bound user defined parameters + * or object with properties assigned matching procedure parameter names. + * alter PROCEDURE (@a INT = 5) + * then call with object parameter { a: 4 } to override default value 5 + * @param options optional parameters for query execution e.g. timeout + * @returns a promise to return all results from all compounded queries submitted + */ + callProc: (name: string, params?: sqlProcParamType, options?: QueryAggregatorOptions) => Promise + } + + export interface SqlClientPromises { + /** + * adhoc query where connection is opened, query submitted, results fetched, connection closed + * and results returned as a promide completed when connection is closed. + * @param conn_str connection string or connection object + * @param sql the sql to execute on server + * @param params an array of parameters which can be simple JS types or bound types including metadata of type + * @param options - query options such as timeout. + */ + query: (conn_str: sqlConnectType, sql: string, params?: sqlQueryParamType[], options?: QueryAggregatorOptions) => Promise + /** + * adhoc call to a stored procedure using a connection string, proc name and params + * the connection is opened, the proc definition bound, call made and connection closed. + * results returned once close is complete. Note this is not efficient for many calls + * + * @param conn_str - the connection string or object + * @param name - the name of the stored proc to call + * @param params optional bound parameters either array of JS native types or bound user defined parameters + * or object with properties assigned matching procedure parameter names. + * alter PROCEDURE (@a INT = 5) + * then call with object parameter { a: 4 } to override default value 5 or {} taking default. + * @param options - query options such as timeout. + * @returns promise to await for results from query. + */ + callProc: (conn_str: sqlConnectType, name: string, params?: sqlProcParamType, options?: QueryAggregatorOptions) => Promise + /** + * open a connection to server using an odbc style connection string. + * @param conn_str - the connection string or object + * @returns - a promise to await for a new connection to the database + */ + open: (conn_str: sqlConnectType) => Promise + } + + export interface UserTypeColumnType { + offset: number + declaration: string + length: number + } + export interface UserTypeColumn { + name: string + userType: string + scale: number + precision: number + type: UserTypeColumnType + } + + /*** + * representation of a table user type used in TVP bulk operations + */ + export interface Table { + /** + * of the table to which this type refers. + */ + name: string + /** + * the rows to be included within the TVP query + */ + rows: sqlJsColumnType[][] + /** + * metadata describing the columns of table type. + */ + columns: UserTypeColumn[] + /** + * add rows of data as an object array where each instance holds + * properties for columns { cola: 'hello' }, { cola: 'world' } + * @param vec the object array to be converted into rows. + */ + addRowsFromObjects: (vec: sqlObjectType[]) => void + } + export interface SqlServerVersion { + MajorVersion: number + ProductLevel: string + Edition: string + ProductVersion: string + Cat: string + } + + export interface PoolOptions { + /** + * minimum number of connections to keep open even when quiet. + */ + floor?: number + /** + * never exceed this many open connections, work will queue. + */ + ceiling?: number + /** + * during no activity a heartbeat is sent every interval to check connection + */ + heartbeatSecs?: number + /** + * override the sql used to test the connection + */ + heartbeatSql?: string + /** + * if no queries for this period issued close connection and reopen when required. + */ + inactivityTimeoutSecs?: number + /** + * convert date time cols to UTC + */ + useUTC?: boolean + /** + * avoid bigint overflow return string + */ + useNumericString?: boolean + /** + * nvarchar(max) prepared columns must be constrained (Default 8k) + */ + maxPreparedColumnSize?: number + /** + * the connection string used for each connection opened in pool + */ + connectionString: string + } + + export interface QueryAggregatorResults { + /** + * the local date when this aggregation query was started + */ + beginAt: Date + /** + * the promise is resolved or rejected at this local time. In case of + * completing, this will be when the unmanaged native statement + * handle is released by the cpp. + */ + endAt: Date + /** + * the local date when query submitted to native driver - + * it may have been held on a queue waiting to be submitted + * on the designated connection + */ + submittedAt: Date + /** + * elapsed ms for call to complete + */ + elapsed: number + /** + * for a compund query select * from a; select * from b + * each time a new statement is started a new elapsed + * ms count is added such that a breakdown of where + * time is spent in each statement. + * + */ + metaElapsed: number[] + /** + * array of meta for each query i.e. an array holding an array of meta descriptions one per column + */ + meta: Meta[][] + /** + * the first meta to arrive for the query submitted which + * corresponds data rows held in first + */ + firstMeta: Meta[] + /** + * first set of rows i.e. results[0] if any else null + */ + first: (sqlColumnResultsType[]) + /** + * each result set either as array of arrays or array of objects with column names as properties + */ + results: sqlColumnResultsType[][] + /** + * output params if any from a proc call + */ + output: sqlJsColumnType[] + /** + * prints from procedure collected + */ + info: string[] + /** + * row counts returned from update, insert, delete statements. + */ + counts: number[] + /** + * return code from procedure + */ + returns: sqlJsColumnType + /** + * errors collected by running sql (up to promise reject) + */ + errors: Error[] + /** + * the options submitted on query + */ + options: QueryAggregatorOptions + /** + * a running total incremented on each new row arriving + * select top 10 ... will expect this to equal 10 + */ + rows: number + /** + * the approximate number of rows per second received + * over duration of query. + */ + rowRate: number + /** + * the sql submitted to server producing these results. + */ + sql: string + } + + export interface QueryAggregatorOptions { + /** + * default 0 i.e. no timeout - else force query to cancel early + */ + timeoutMs?: number + /** + * results as arrays or objects with column names + */ + raw?: boolean + /** + * replace meta empty col name with Column0, Column1 + */ + replaceEmptyColumnNames?: boolean + } + + export interface PoolPromises extends AggregatorPromises { + /** + * open connections to database and ready pool for use. + * @returns promise returning pool when connections are up. + */ + open: () => Promise + /** + * terminate all open connections. + * @returns promise to await for close to complete. + */ + close: () => Promise + /** + * utility method to fetch a user table type definition containing + * the column metadata representing the type. + * @param name the user type definition to fetch + * @returns a promise of table type definition + */ + getUserTypeTable: (name: string) => Promise + /** + * fetch a table definition which can be used for bulk insert operations + * @param name of table to bind too + * @returns promise of bound table with methods to insert objects. + */ + getTable: (name: string) => Promise + /** + * fetch a stored procedure definition which can be called with + * correctly bound parameter types. + * @param name of stored procedure to fetch. + * @returns promise of bound proc to call. + */ + getProc: (name: string) => Promise + } + + export class Pool implements GetSetUTC, SubmitQuery { + constructor (poolOptions: PoolOptions) + promises: PoolPromises + getUseUTC (): boolean + setUseUTC (utc: boolean): void + open (cb?: PoolOpenCb): void + /** + * close the pool such that all active connections are closed and pool is no longer + * usable. + * @param cb callback when operation is complete + */ + close (cb?: StatusCb): void + query (sqlOrQuery: sqlQueryType, paramsOrCb?: sqlQueryParamType[] | QueryCb, cb?: QueryCb): Query + queryRaw (sqlOrQuery: sqlQueryType, paramsOrCb?: sqlQueryParamType[] | QueryRawCb, cb?: QueryRawCb): Query + isClosed (): boolean + /** + * event subscription + * e.g. pool.on('debug', msg => { console.log(msg) }) + * @param event one of + * + * 'debug' - a debug record showing internal state of the pool + * + * 'open' - event on the pool being opened and ready to work. + * + * 'error' - propagated from connection errors + * + * 'status' - information relating to latet operation + * + * 'submitted' - raised when query is submitted where previously was on a queue + * + * @param cb callback related to event subscribed + */ + on (event: string, cb?: sqlPoolEventType): void + } + + export interface TableColumn { + /** + * unique name for this column unique for this table + */ + name: string + /** + * the type of the column as specified in column definition + * without any scaling i.e. date,time,bit,char,varchar + */ + type: string + schema_name: string + /** + * used for bcp based bulk insert and represents the ordinal numeric position + * of the column within the table. + */ + ordinal_position: number + table_catalog: string + /** + * schema to which parent user type table belongs e.g. 'dbo' + */ + table_schema: string + /** + * the table name for which this column belongs + */ + table_name: string + /** + * expression or value describing efault for this column + */ + column_default: string + /** + * the max space the column occupies + */ + max_length: number + /** + * related to certain column types e.g. decimal(precision,scale) + */ + precision: number + /** + * related to certain column types e.g. decimal(precision,scale) + */ + scale: number + /** + * is the column nullable = 1, else 0 + */ + is_nullable: number + /** + * is the column computed = 1, else 0 + */ + is_computed: number + /** + * is the column an identity = 1, else 0 + */ + is_identity: number + /** + * unique object id for this column + */ + object_id: number + generated_always_type: bigint + generated_always_type_desc: string + is_hidden: number + /** + * is the column part of primary key for table = 1, else 0 + */ + is_primary_key: number + /** + * is the column a foreign key for table = 1, else 0 + */ + is_foreign_key: number + /** + * type declaration if using as a proc parameter i.e. without + * the null decorator char(15) + */ + procTyped: () => string + /** + * sql declared type used by table builder / user type + * @param user flag is this user type declaration (or table column) + * @param withDecorator i.e. should include 'null' 'not null' etc + */ + typed: (user?: boolean, withDecorator?: boolean) => string + /** + * is column considered readonly based on is_computed etc + * @returns flag indicates if this column is insertable or readonly + */ + isReadOnly: () => boolean + /** + * based on type - is date field requiring tz adjustment + * @returns flag indicating if column is tz adjusted. + */ + isTzAdjusted: () => boolean + /** + * the length decorator for string column description i.e + * 10 or MAX for + * @returns decorator part of type description. + */ + maxLength: () => number | string + /** + * specifies if this column is insertable or is computed + * @param v 0 = not computed, 1 = this column is computed + * @returns this column instance for fluent calls + */ + // helper methods when manually adding tables with table builder + isComputed: (v?: number) => TableColumn + /** + * specifies an epression representing this column + * @param s e.g. 'AS ([OrganizationNode].[GetLevel]())' + * @returns this column instance for fluent calls + */ + asExpression: (s: string) => TableColumn + /** + * nominates the column as identity type and hence auto increments + * and maintains a unique identity. + * @param v 1: is an identity, 0 column is not identity + * @param start defaults to 1 starting number for identity + * @param inc defaults to 1 increments by inc on next insert + */ + isIdentity: (v: number, start?: number, inc?: number) => TableColumn + + isHidden: (v: number) => TableColumn + + isPrimaryKey: (v: number) => TableColumn + + isForeignKey: (v: number) => TableColumn + /** + * nominate column as boolean 'bit' + * @returns this column instance for fluent calls + */ + asBit: () => TableColumn + /** + * nominate column as int32 signed 32 bit 'int' + * @returns this column instance for fluent calls + */ + asInt: () => TableColumn + /** + * nominate column as int64 signed 64 bit 'bigint' + * @returns this column instance for fluent calls + */ + asBigInt: () => TableColumn + /** + * nominate column as int16 signed 16 bit 'smallint' + * @returns this column instance for fluent calls + */ + asSmallInt: () => TableColumn + /** + * nominate column as int8 signed 8 bit 'byte' + * @returns this column instance for fluent calls + */ + asTinyInt: () => TableColumn + /** + * nominate column as Unicode 'nvarchar(max)' + * @returns this column instance for fluent calls + */ + asNVarCharMax: () => TableColumn + /** + * nominate column as Unicode 'nvarchar(p)' defaults to nvarchar(28) + * @returns this column instance for fluent calls + */ + asNVarChar: (length: number) => TableColumn + /** + * nominate column as non-Unicode 'varchar(p)' defaults to varchar(28) + * @returns this column instance for fluent calls + */ + asVarChar: (length: number) => TableColumn + /** + * nominate column as 'date' + * @returns this column instance for fluent calls + */ + asDate: () => TableColumn + /** + * nominate column as 'time' + * @returns this column instance for fluent calls + */ + asTime: (scale?: number) => TableColumn + /** + * nominate column as 'datetime2' + * @returns this column instance for fluent calls + */ + asDateTime2: () => TableColumn + /** + * nominate column as 'datetime' + * @returns this column instance for fluent calls + */ + asDateTime: () => TableColumn + /** + * nominate column as 'datetimeoffset' + * @returns this column instance for fluent calls + */ + asDateTimeOffset: () => TableColumn + /** + * nominate column as 'money' + * @returns this column instance for fluent calls + */ + asMoney: () => TableColumn + + asSmallMoney: () => TableColumn + /** + * nominate column as 'numeric(p,s)' defaults to numeric(20,15) + * @returns this column instance for fluent calls + */ + asNumeric: (precision: number, length: number) => TableColumn + /** + * nominate column as 'decimal(p,s)' defaults to decimal(23,18) + * @returns this column instance for fluent calls + */ + asDecimal: (precision?: number, scale?: number) => TableColumn + /** + * nominate column as 'uniqueidentifier' + * @returns this column instance for fluent calls + */ + asUniqueIdentifier: () => TableColumn + /** + * nominate column as 'hierarchyid' + * @returns this column instance for fluent calls + */ + asHierarchyId: () => TableColumn + /** + * nominate column as 'varbinary(l)' + * @param length of column + * @returns this column instance for fluent calls + */ + asVarBinary: (length: number) => TableColumn + /** + * nominate column as 'float' + * @returns this column instance for fluent calls + */ + asFloat: (scale: number) => TableColumn + /** + * nominate column as 'real' + * @returns this column instance for fluent calls + */ + asReal: () => TableColumn + /** + * nominate column as Unicode 'nchar(l)' defaults nchar(128) + * @param length of column + * @returns this column instance for fluent calls + */ + asNChar: (length: number) => TableColumn + /** + * nominate column as non-Unicode'char(l)' defaults char(128) + * @param length of column + * @returns this column instance for fluent calls + */ + asChar: (length: number) => TableColumn + /** + * add to the type declaration as part of the column definition + * e.g. to use always on encryption + * builder.addColumn('[NationalIDNumber]') + * .asNVarChar(15) + * .withDecorator(encryptHelper.txtWithEncrypt) + * .notNull()`) + * @param string representing decorator to add to declaration + */ + withDecorator: (v: string) => TableColumn + /** + * specifies if this column is not nullable i.e. adds 'not null' to decorator on type + * @returns this column instance for fluent calls + */ + notNull: () => TableColumn + /** + * specifies if this column is nullable i.e. adds 'null' to decorator on type + * @returns this column instance for fluent calls + */ + null: () => TableColumn + } + + export interface ConnectionPromises extends AggregatorPromises { + prepare: (sql: sqlQueryType) => Promise + getTable: (name: string) => Promise + getProc: (name: string) => Promise + getUserTypeTable: (name: string) => Promise
+ /** + * close the active connection and release ODBC handle within + * native driver. + * @returns promise to await for connection to close. + */ + close: () => Promise + /** + * cancel the provided query - note await con.promises.cancel(q) + * is equivalent to await q.promises.cancel() + * @returns await promise for cancel to complete on provided query. + */ + cancel: (query: Query) => Promise + /** + * open a transaction on this connection instance. Expected to commit or rollback + * at some later point in time. + * @returns promise to await for transaction to be opened + */ + beginTransaction: () => Promise + /** + * commit the currently opened transaction. Expected to have previously called beginTransaction + * @returns promise to await for transaction to be committed + */ + commit: () => Promise + /** + * rollback the currently opened transaction. Expected to have previously called beginTransaction + * @returns promise to await for transaction to be rolled back + */ + rollback: () => Promise + } + + export interface Connection extends GetSetUTC, SubmitQuery { + /** + * collection of promises to close connection, get a proc, table, prepare a query + * and transaction management. + * @returns a set of utility promises on this connection instance. + */ + promises: ConnectionPromises + /** + * given a type of form create type MyType AS TABLE (col1, col2) fetch metadata + * describing that type. + * @param name the name as defined in database for table type. + * @param cb callback containing the metadata describing the table. + */ + getUserTypeTable: (name: string, cb: TableCb) => void + /** + * numeric integer representing this connection instance. + * @returns the unique id + */ + id: number + /** + * optionally return all number based columns as strings + * to prevent exceeding max numeric for JS + * @param numericString boolean true for numers as strings. + */ + setUseNumericString: (numericString: boolean) => void + /** + * returns flag to indicate if numeric conversion to strings is active + * @returns flag for numeric to string. + */ + getUseNumericString: () => boolean + /** + * set max length of prepared strings or binary columns. Note this + * will not work for a connection with always on encryption enabled + * else a column marked nvarchar(max) is given a max size allocated + * in prepared statement defaults to 8k. Truncation will occur for + * parameters exceeding this size. + * @param size + */ + setMaxPreparedColumnSize: (size: number) => void + getMaxPreparedColumnSize: () => number + /** + * permanently closes connection and frees unmanaged native resources + * related to connection ie. connection ODBC handle along with any + * remaining statement handles. + * @param cb callback when connection closed. + */ + close: (cb: StatusCb) => void + beginTransaction: (cb?: StatusCb) => void + commit: (cb?: StatusCb) => void + rollback: (cb?: StatusCb) => void + /** + * note - can use promises.callProc, callProc or callprocAggregator directly. + * provides access to procedure manager where proc definitions can be manually + * registered and called. + * @returns the procedure manager instance. + */ + procedureMgr: () => ProcedureManager + /** + * note - can use getTable, promises.getTable directly. + * provides access to table manager where tables can be manually registered + * or bound + * @returns the table manager instance. + */ + tableMgr: () => TableManager + pollingMode: (q: Query, v: boolean, cb?: SimpleCb) => void + cancelQuery: (q: Query, cb?: StatusCb) => void + prepare: (sql: sqlQueryType, cb: PrepareCb) => void + setFilterNonCriticalErrors: (flag: boolean) => void + callproc: (name: string, params?: sqlProcParamType[], cb?: CallProcedureCb) => Query + getTable: (tableName: string, cb: GetTableCb) => void + callprocAggregator: (name: string, params?: sqlProcParamType, optons?: QueryAggregatorOptions) => Promise + /** + * flag indicating if connection is closed and hence can no longer be used + * for queries. + */ + isClosed: () => boolean + } + + export interface QueryPromises { + /** + * promise to cancel current executing query - will wait + * for 'free' event where resources related to query have + * been cleaned from native driver. If expected 'error' is + * raised from driver this is returned by promise. Any other error + * or if timeout occurs then promise is rejected. + * @param timeout defaults 5000ms it should not br necessary + * to change the default as when query is canceled the timer + * is cleared. + * @returns the expected error raised by driver when the query + * is canceled. Any other error will reject promise. + */ + cancel: (timeout?: number) => Promise + } + + export interface Query { + promises: QueryPromises + /** + * subscribe for an event relating to query progress where events are + * @param event - 'meta', 'submitted', 'rowcount', column', 'row', 'error', 'info', 'done', 'free' + * + * + * 'meta' - array of Meta relating to query submitted indexed by column ID + * + * + * 'submitted' - raised when query submitted to native driver (maybe held on outbound q) + * + * + * 'column' - column index and data returned as results are returned - can index into + * meta array previously returned. + * + * + * 'row' - indicating the start of a new row of data along with row index 0,1 .. + * + * + * 'rowcount' - number of rows effected + * + * + * 'error' - critical error that caused the query to end + * + * + * 'info' - non-critical warning raised during query execution + * + * + * 'done' - the JS has consumed all data and query is complete. + * + * + * 'free' - when the native driver releases resources relating to query and entire lifecycle + * comes to an end. the ODBC statement handle has been released at this point by native driver + * + * + * @param cb - callback containing data related to subscription + */ + on: (event: string, cb: sqlQueryEventType) => void + /** + * cancel active query - this will submit cancel on native driver on a different + * thread such that if the query thread is blocked, the query will still be + * cancelled. If results are being streamed then the results are halted + * and query is terminated. + * @param qcb status callback indicating the cancel has been actioned. + */ + cancelQuery: (qcb?: StatusCb) => void + /** + * temporarily suspend flow of data sent by native driver to be used + * as flow control where for example expensive time consuming processing + * is taken place on a batch - receive N rows, pause, process, resume + * this prevents large memory build up where data arrives faster than + * it is being processed. + * @param qcb callback indicating query is paused. + */ + pauseQuery: (qcb?: StatusCb) => void + /** + * resume processing i.e. instruct native driver to send more data which + * will continue unless query is paused once more. + * @param qcb + */ + resumeQuery: (qcb?: StatusCb) => void + /** + * is this instance of query currently paused in which case + * no more results will be returned until query is resumed. + * @returns flag indicating if the query is paused. + */ + isPaused: () => boolean + } + + export interface ConnectDescription { + conn_str: string + conn_timeout?: number + } + + export interface QueryDescription { + /** + * the sql to submit to server to execute. + */ + query_str: string + /** + * for BigInt can return string to avoid overflow + */ + numeric_string?: boolean + query_timeout?: number + query_polling?: boolean + query_tz_adjustment?: number + /** + * constrain nvarchar(max) columns for prepared statements - i.e. will + * set aefault 8k max size on nvarchar(max) columns. Note this + * will not work when an encrypted connection is beng used - the + * query will not prepare and return an error. + */ + max_prepared_column_size?: number + } + + export interface Meta { + name: string + nullable: boolean + size: number + sqlType: string + type: string + } + + export interface Error { + code?: number + severity?: number + lineNumber?: number + serverName?: string + procName?: string + message: string + sqlstate?: string + } + + export interface RawData { + meta: Meta[] + rows: sqlJsColumnType[][] + } + + export interface PoolStatusRecord { + time: Date + parked: number + idle: number + busy: number + pause: number + parking: number + workQueue: number + activity: string + op: string + lastSql?: string + } + + export type PoolStatusRecordCb = (status: PoolStatusRecord) => void + + export type QueryDescriptionCb = (description: QueryDescription) => void + + export type MessageCb = (msg: string) => void + + export type PoolOptionsEventCb = (options: PoolOptions) => void + + export type PoolOpenCb = (err: Error, options: PoolOptions) => void + + export type SimpleCb = () => void + + export type TableCb = (err: Error, table: Table) => void + + export type BindCb = (cb: BulkTableMgr) => void + + export type GetTableCb = (err: Error, table: BulkTableMgr) => void + + export type OpenCb = (err: Error, connection: Connection) => void + + export type QueryCb = (err?: Error, rows?: sqlObjectType[], more?: boolean) => void + + export type CallProcedureCb = (err?: Error, rows?: sqlObjectType[], outputParams?: sqlJsColumnType[]) => void + + export type QueryRawCb = (err?: Error, raw?: RawData, more?: boolean) => void + + export type StatusCb = (err?: Error) => void + + export type PrepareCb = (err?: Error, statement?: PreparedStatement) => void + + export type MetaEventCb = (meta: Meta[]) => void + + export type RowCountEventCb = (rowcount: number) => void + + export type RowEventCb = (row: number) => void -declare module 'msnodesqlv8/types' { - type sqlJsColumnType = string | boolean | Date | number | Buffer - type sqlRecordType = Record - type sqlObjectType = sqlRecordType | object | any - type sqlQueryParamType = sqlJsColumnType | sqlJsColumnType[] | ConcreteColumnType | ConcreteColumnType[] | TvpParam - type sqlPoolEventType = MessageCb | PoolStatusRecordCb | PoolOptionsEventCb | StatusCb - type sqlQueryEventType = SubmittedEventCb | ColumnEventCb | EventColumnCb | StatusCb | RowEventCb | MetaEventCb | RowCountEventCb - type sqlProcParamType = sqlObjectType | sqlQueryParamType - type sqlQueryType = string | QueryDescription - type sqlConnectType = string | ConnectDescription - type sqlColumnResultsType = sqlObjectType | sqlJsColumnType | any - type sqlBulkType = sqlObjectType[] - - interface GetSetUTC { - /** - * used to switch on date conversion for date columns from database to UTC - * @param utc flag to turn conversio on or off - */ - setUseUTC: (utc: boolean) => void - /** - * fetch the current UTC conversion status. - * @returns a flag for conversion. - */ - getUseUTC: () => boolean - } - - interface SubmitQuery { - /** - * submit query on an open connection with optional paramteters that will be bound - * by native driver. Can either use an event stream driven mechanism by subscribing to - * returned query e.g. on('column', ..) , on ('meta', ..) or provide a callback which - * will be invoked when all results are ready. Event subscription for large queries - * can be much more memory efficient as the data will not be cached in driver as results - * are built. However a callback can be more convenient. - * - * @param sqlOrQuery the textual query to submit - * @param paramsOrCb optional bound parameters either array of JS native types or bound user defined parameters, - * else an optional callback invoked with results of query. - * @param cb optional callback invoked when query completes with array of objects built from column names - * as properties. e.g. { cola: 1, colb: 'hello }. Note the oberhead required which for large bumbers - * of rows will grow the node process significantly. - * @returns a query object which can be used to cancel, pause, resume or subscribe for events. - */ - query: (sqlOrQuery: sqlQueryType, paramsOrCb?: sqlQueryParamType[] | QueryCb, cb?: QueryCb) => Query - queryRaw: (sqlOrQuery: sqlQueryType, paramsOrCb?: sqlQueryParamType[] | QueryRawCb, cb?: QueryRawCb) => Query - } - - interface AggregatorPromises { - /** - * - * @param sql the textual query to submit - * @param params optional bound parameters either array of JS native types or bound user defined parameters - * @param options optional parameters for query execution e.g. timeout - * @returns a promise to return all results from all compounded queries submitted - */ - query: (sql: string, params?: sqlQueryParamType[], options?: QueryAggregatorOptions) => Promise - /** - * - * @param name the name of procedure to call - * @param params optional bound parameters either array of JS native types or bound user defined parameters - * or object with properties assigned matching procedure parameter names. - * alter PROCEDURE (@a INT = 5) - * then call with object parameter { a: 4 } to override default value 5 - * @param options optional parameters for query execution e.g. timeout - * @returns a promise to return all results from all compounded queries submitted - */ - callProc: (name: string, params?: sqlProcParamType, options?: QueryAggregatorOptions) => Promise - } - - interface SqlClientPromises { - /** - * adhoc query where connection is opened, query submitted, results fetched, connection closed - * and results returned as a promide completed when connection is closed. - * @param conn_str connection string or connection object - * @param sql the sql to execute on server - * @param params an array of parameters which can be simple JS types or bound types including metadata of type - * @param options - query options such as timeout. - */ - query: (conn_str: sqlConnectType, sql: string, params?: sqlQueryParamType[], options?: QueryAggregatorOptions) => Promise - /** - * adhoc call to a stored procedure using a connection string, proc name and params - * the connection is opened, the proc definition bound, call made and connection closed. - * results returned once close is complete. Note this is not efficient for many calls - * - * @param conn_str - the connection string or object - * @param name - the name of the stored proc to call - * @param params optional bound parameters either array of JS native types or bound user defined parameters - * or object with properties assigned matching procedure parameter names. - * alter PROCEDURE (@a INT = 5) - * then call with object parameter { a: 4 } to override default value 5 or {} taking default. - * @param options - query options such as timeout. - * @returns promise to await for results from query. - */ - callProc: (conn_str: sqlConnectType, name: string, params?: sqlProcParamType, options?: QueryAggregatorOptions) => Promise - /** - * open a connection to server using an odbc style connection string. - * @param conn_str - the connection string or object - * @returns - a promise to await for a new connection to the database - */ - open: (conn_str: sqlConnectType) => Promise - } - - interface UserTypeColumnType { - offset: number - declaration: string - length: number - } - interface UserTypeColumn { - name: string - userType: string - scale: number - precision: number - type: UserTypeColumnType - } - - /*** - * representation of a table user type used in TVP bulk operations - */ - interface Table { - /** - * of the table to which this type refers. - */ - name: string - /** - * the rows to be included within the TVP query - */ - rows: sqlJsColumnType[][] - /** - * metadata describing the columns of table type. - */ - columns: UserTypeColumn[] - /** - * add rows of data as an object array where each instance holds - * properties for columns { cola: 'hello' }, { cola: 'world' } - * @param vec the object array to be converted into rows. - */ - addRowsFromObjects: (vec: sqlObjectType[]) => void - } - interface SqlServerVersion { - MajorVersion: number - ProductLevel: string - Edition: string - ProductVersion: string - Cat: string - } - - interface PoolOptions { - /** - * minimum number of connections to keep open even when quiet. - */ - floor?: number - /** - * never exceed this many open connections, work will queue. - */ - ceiling?: number - /** - * during no activity a heartbeat is sent every interval to check connection - */ - heartbeatSecs?: number - /** - * override the sql used to test the connection - */ - heartbeatSql?: string - /** - * if no queries for this period issued close connection and reopen when required. - */ - inactivityTimeoutSecs?: number - /** - * convert date time cols to UTC - */ - useUTC?: boolean - /** - * avoid bigint overflow return string - */ - useNumericString?: boolean - /** - * nvarchar(max) prepared columns must be constrained (Default 8k) - */ - maxPreparedColumnSize?: number - /** - * the connection string used for each connection opened in pool - */ - connectionString: string - } - - interface QueryAggregatorResults { - /** - * the local date when this aggregation query was started - */ - beginAt: Date - /** - * the promise is resolved or rejected at this local time. In case of - * completing, this will be when the unmanaged native statement - * handle is released by the cpp. - */ - endAt: Date - /** - * the local date when query submitted to native driver - - * it may have been held on a queue waiting to be submitted - * on the designated connection - */ - submittedAt: Date - /** - * elapsed ms for call to complete - */ - elapsed: number - /** - * for a compund query select * from a; select * from b - * each time a new statement is started a new elapsed - * ms count is added such that a breakdown of where - * time is spent in each statement. - * - */ - metaElapsed: number[] - /** - * array of meta for each query i.e. an array holding an array of meta descriptions one per column - */ - meta: Meta[][] - /** - * the first meta to arrive for the query submitted which - * corresponds data rows held in first - */ - firstMeta: Meta[] - /** - * first set of rows i.e. results[0] if any else null - */ - first: (sqlColumnResultsType[]) - /** - * each result set either as array of arrays or array of objects with column names as properties - */ - results: sqlColumnResultsType[][] - /** - * output params if any from a proc call - */ - output: sqlJsColumnType[] - /** - * prints from procedure collected - */ - info: string[] - /** - * row counts returned from update, insert, delete statements. - */ - counts: number[] - /** - * return code from procedure - */ - returns: sqlJsColumnType - /** - * errors collected by running sql (up to promise reject) - */ - errors: Error[] - /** - * the options submitted on query - */ - options: QueryAggregatorOptions - /** - * a running total incremented on each new row arriving - * select top 10 ... will expect this to equal 10 - */ - rows: number - /** - * the approximate number of rows per second received - * over duration of query. - */ - rowRate: number - /** - * the sql submitted to server producing these results. - */ - sql: string - } - - interface QueryAggregatorOptions { - /** - * default 0 i.e. no timeout - else force query to cancel early - */ - timeoutMs?: number - /** - * results as arrays or objects with column names - */ - raw?: boolean - /** - * replace meta empty col name with Column0, Column1 - */ - replaceEmptyColumnNames?: boolean - } - - interface PoolPromises extends AggregatorPromises { - /** - * open connections to database and ready pool for use. - * @returns promise returning pool when connections are up. - */ - open: () => Promise - /** - * terminate all open connections. - * @returns promise to await for close to complete. - */ - close: () => Promise - /** - * utility method to fetch a user table type definition containing - * the column metadata representing the type. - * @param name the user type definition to fetch - * @returns a promise of table type definition - */ - getUserTypeTable: (name: string) => Promise
- /** - * fetch a table definition which can be used for bulk insert operations - * @param name of table to bind too - * @returns promise of bound table with methods to insert objects. - */ - getTable: (name: string) => Promise - /** - * fetch a stored procedure definition which can be called with - * correctly bound parameter types. - * @param name of stored procedure to fetch. - * @returns promise of bound proc to call. - */ - getProc: (name: string) => Promise - } - - class Pool implements GetSetUTC, SubmitQuery { - constructor (poolOptions: PoolOptions) - promises: PoolPromises - getUseUTC (): boolean - setUseUTC (utc: boolean): void - open (cb?: PoolOpenCb): void - /** - * close the pool such that all active connections are closed and pool is no longer - * usable. - * @param cb callback when operation is complete - */ - close (cb?: StatusCb): void - query (sqlOrQuery: sqlQueryType, paramsOrCb?: sqlQueryParamType[] | QueryCb, cb?: QueryCb): Query - queryRaw (sqlOrQuery: sqlQueryType, paramsOrCb?: sqlQueryParamType[] | QueryRawCb, cb?: QueryRawCb): Query - isClosed (): boolean - /** - * event subscription - * e.g. pool.on('debug', msg => { console.log(msg) }) - * @param event one of - * - * 'debug' - a debug record showing internal state of the pool - * - * 'open' - event on the pool being opened and ready to work. - * - * 'error' - propagated from connection errors - * - * 'status' - information relating to latet operation - * - * 'submitted' - raised when query is submitted where previously was on a queue - * - * @param cb callback related to event subscribed - */ - on (event: string, cb?: sqlPoolEventType): void - } - - interface TableColumn { - /** - * unique name for this column unique for this table - */ - name: string - /** - * the type of the column as specified in column definition - * without any scaling i.e. date,time,bit,char,varchar - */ - type: string - schema_name: string - /** - * used for bcp based bulk insert and represents the ordinal numeric position - * of the column within the table. - */ - ordinal_position: number - table_catalog: string - /** - * schema to which parent user type table belongs e.g. 'dbo' - */ - table_schema: string - /** - * the table name for which this column belongs - */ - table_name: string - /** - * expression or value describing efault for this column - */ - column_default: string - /** - * the max space the column occupies - */ - max_length: number - /** - * related to certain column types e.g. decimal(precision,scale) - */ - precision: number - /** - * related to certain column types e.g. decimal(precision,scale) - */ - scale: number - /** - * is the column nullable = 1, else 0 - */ - is_nullable: number - /** - * is the column computed = 1, else 0 - */ - is_computed: number - /** - * is the column an identity = 1, else 0 - */ - is_identity: number - /** - * unique object id for this column - */ - object_id: number - generated_always_type: bigint - generated_always_type_desc: string - is_hidden: number - /** - * is the column part of primary key for table = 1, else 0 - */ - is_primary_key: number - /** - * is the column a foreign key for table = 1, else 0 - */ - is_foreign_key: number - /** - * type declaration if using as a proc parameter i.e. without - * the null decorator char(15) - */ - procTyped: () => string - /** - * sql declared type used by table builder / user type - * @param user flag is this user type declaration (or table column) - * @param withDecorator i.e. should include 'null' 'not null' etc - */ - typed: (user?: boolean, withDecorator?: boolean) => string - /** - * is column considered readonly based on is_computed etc - * @returns flag indicates if this column is insertable or readonly - */ - isReadOnly: () => boolean - /** - * based on type - is date field requiring tz adjustment - * @returns flag indicating if column is tz adjusted. - */ - isTzAdjusted: () => boolean - /** - * the length decorator for string column description i.e - * 10 or MAX for - * @returns decorator part of type description. - */ - maxLength: () => number | string - /** - * specifies if this column is insertable or is computed - * @param v 0 = not computed, 1 = this column is computed - * @returns this column instance for fluent calls - */ - // helper methods when manually adding tables with table builder - isComputed: (v?: number) => TableColumn - /** - * specifies an epression representing this column - * @param s e.g. 'AS ([OrganizationNode].[GetLevel]())' - * @returns this column instance for fluent calls - */ - asExpression: (s: string) => TableColumn - /** - * nominates the column as identity type and hence auto increments - * and maintains a unique identity. - * @param v 1: is an identity, 0 column is not identity - * @param start defaults to 1 starting number for identity - * @param inc defaults to 1 increments by inc on next insert - */ - isIdentity: (v: number, start?: number, inc?: number) => TableColumn - - isHidden: (v: number) => TableColumn - - isPrimaryKey: (v: number) => TableColumn - - isForeignKey: (v: number) => TableColumn - /** - * nominate column as boolean 'bit' - * @returns this column instance for fluent calls - */ - asBit: () => TableColumn - /** - * nominate column as int32 signed 32 bit 'int' - * @returns this column instance for fluent calls - */ - asInt: () => TableColumn - /** - * nominate column as int64 signed 64 bit 'bigint' - * @returns this column instance for fluent calls - */ - asBigInt: () => TableColumn - /** - * nominate column as int16 signed 16 bit 'smallint' - * @returns this column instance for fluent calls - */ - asSmallInt: () => TableColumn - /** - * nominate column as int8 signed 8 bit 'byte' - * @returns this column instance for fluent calls - */ - asTinyInt: () => TableColumn - /** - * nominate column as Unicode 'nvarchar(max)' - * @returns this column instance for fluent calls - */ - asNVarCharMax: () => TableColumn - /** - * nominate column as Unicode 'nvarchar(p)' defaults to nvarchar(28) - * @returns this column instance for fluent calls - */ - asNVarChar: (length: number) => TableColumn - /** - * nominate column as non-Unicode 'varchar(p)' defaults to varchar(28) - * @returns this column instance for fluent calls - */ - asVarChar: (length: number) => TableColumn - /** - * nominate column as 'date' - * @returns this column instance for fluent calls - */ - asDate: () => TableColumn - /** - * nominate column as 'time' - * @returns this column instance for fluent calls - */ - asTime: (scale?: number) => TableColumn - /** - * nominate column as 'datetime2' - * @returns this column instance for fluent calls - */ - asDateTime2: () => TableColumn - /** - * nominate column as 'datetime' - * @returns this column instance for fluent calls - */ - asDateTime: () => TableColumn - /** - * nominate column as 'datetimeoffset' - * @returns this column instance for fluent calls - */ - asDateTimeOffset: () => TableColumn - /** - * nominate column as 'money' - * @returns this column instance for fluent calls - */ - asMoney: () => TableColumn - - asSmallMoney: () => TableColumn - /** - * nominate column as 'numeric(p,s)' defaults to numeric(20,15) - * @returns this column instance for fluent calls - */ - asNumeric: (precision: number, length: number) => TableColumn - /** - * nominate column as 'decimal(p,s)' defaults to decimal(23,18) - * @returns this column instance for fluent calls - */ - asDecimal: (precision?: number, scale?: number) => TableColumn - /** - * nominate column as 'uniqueidentifier' - * @returns this column instance for fluent calls - */ - asUniqueIdentifier: () => TableColumn - /** - * nominate column as 'hierarchyid' - * @returns this column instance for fluent calls - */ - asHierarchyId: () => TableColumn - /** - * nominate column as 'varbinary(l)' - * @param length of column - * @returns this column instance for fluent calls - */ - asVarBinary: (length: number) => TableColumn - /** - * nominate column as 'float' - * @returns this column instance for fluent calls - */ - asFloat: (scale: number) => TableColumn - /** - * nominate column as 'real' - * @returns this column instance for fluent calls - */ - asReal: () => TableColumn - /** - * nominate column as Unicode 'nchar(l)' defaults nchar(128) - * @param length of column - * @returns this column instance for fluent calls - */ - asNChar: (length: number) => TableColumn - /** - * nominate column as non-Unicode'char(l)' defaults char(128) - * @param length of column - * @returns this column instance for fluent calls - */ - asChar: (length: number) => TableColumn - /** - * add to the type declaration as part of the column definition - * e.g. to use always on encryption - * builder.addColumn('[NationalIDNumber]') - * .asNVarChar(15) - * .withDecorator(encryptHelper.txtWithEncrypt) - * .notNull()`) - * @param string representing decorator to add to declaration - */ - withDecorator: (v: string) => TableColumn - /** - * specifies if this column is not nullable i.e. adds 'not null' to decorator on type - * @returns this column instance for fluent calls - */ - notNull: () => TableColumn - /** - * specifies if this column is nullable i.e. adds 'null' to decorator on type - * @returns this column instance for fluent calls - */ - null: () => TableColumn - } - - interface ConnectionPromises extends AggregatorPromises { - prepare: (sql: sqlQueryType) => Promise - getTable: (name: string) => Promise - getProc: (name: string) => Promise - getUserTypeTable: (name: string) => Promise
- /** - * close the active connection and release ODBC handle within - * native driver. - * @returns promise to await for connection to close. - */ - close: () => Promise - /** - * cancel the provided query - note await con.promises.cancel(q) - * is equivalent to await q.promises.cancel() - * @returns await promise for cancel to complete on provided query. - */ - cancel: (query: Query) => Promise - /** - * open a transaction on this connection instance. Expected to commit or rollback - * at some later point in time. - * @returns promise to await for transaction to be opened - */ - beginTransaction: () => Promise - /** - * commit the currently opened transaction. Expected to have previously called beginTransaction - * @returns promise to await for transaction to be committed - */ - commit: () => Promise - /** - * rollback the currently opened transaction. Expected to have previously called beginTransaction - * @returns promise to await for transaction to be rolled back - */ - rollback: () => Promise - } - - interface Connection extends GetSetUTC, SubmitQuery { - /** - * collection of promises to close connection, get a proc, table, prepare a query - * and transaction management. - * @returns a set of utility promises on this connection instance. - */ - promises: ConnectionPromises - /** - * given a type of form create type MyType AS TABLE (col1, col2) fetch metadata - * describing that type. - * @param name the name as defined in database for table type. - * @param cb callback containing the metadata describing the table. - */ - getUserTypeTable: (name: string, cb: TableCb) => void - /** - * numeric integer representing this connection instance. - * @returns the unique id - */ - id: number - /** - * optionally return all number based columns as strings - * to prevent exceeding max numeric for JS - * @param numericString boolean true for numers as strings. - */ - setUseNumericString: (numericString: boolean) => void - /** - * returns flag to indicate if numeric conversion to strings is active - * @returns flag for numeric to string. - */ - getUseNumericString: () => boolean - /** - * set max length of prepared strings or binary columns. Note this - * will not work for a connection with always on encryption enabled - * else a column marked nvarchar(max) is given a max size allocated - * in prepared statement defaults to 8k. Truncation will occur for - * parameters exceeding this size. - * @param size - */ - setMaxPreparedColumnSize: (size: number) => void - getMaxPreparedColumnSize: () => number - /** - * permanently closes connection and frees unmanaged native resources - * related to connection ie. connection ODBC handle along with any - * remaining statement handles. - * @param cb callback when connection closed. - */ - close: (cb: StatusCb) => void - beginTransaction: (cb?: StatusCb) => void - commit: (cb?: StatusCb) => void - rollback: (cb?: StatusCb) => void - /** - * note - can use promises.callProc, callProc or callprocAggregator directly. - * provides access to procedure manager where proc definitions can be manually - * registered and called. - * @returns the procedure manager instance. - */ - procedureMgr: () => ProcedureManager - /** - * note - can use getTable, promises.getTable directly. - * provides access to table manager where tables can be manually registered - * or bound - * @returns the table manager instance. - */ - tableMgr: () => TableManager - pollingMode: (q: Query, v: boolean, cb?: SimpleCb) => void - cancelQuery: (q: Query, cb?: StatusCb) => void - prepare: (sql: sqlQueryType, cb: PrepareCb) => void - setFilterNonCriticalErrors: (flag: boolean) => void - callproc: (name: string, params?: sqlProcParamType[], cb?: CallProcedureCb) => Query - getTable: (tableName: string, cb: GetTableCb) => void - callprocAggregator: (name: string, params?: sqlProcParamType, optons?: QueryAggregatorOptions) => Promise - /** - * flag indicating if connection is closed and hence can no longer be used - * for queries. - */ - isClosed: () => boolean - } - - interface QueryPromises { - /** - * promise to cancel current executing query - will wait - * for 'free' event where resources related to query have - * been cleaned from native driver. If expected 'error' is - * raised from driver this is returned by promise. Any other error - * or if timeout occurs then promise is rejected. - * @param timeout defaults 5000ms it should not br necessary - * to change the default as when query is canceled the timer - * is cleared. - * @returns the expected error raised by driver when the query - * is canceled. Any other error will reject promise. - */ - cancel: (timeout?: number) => Promise - } - - interface Query { - promises: QueryPromises - /** - * subscribe for an event relating to query progress where events are - * @param event - 'meta', 'submitted', 'rowcount', column', 'row', 'error', 'info', 'done', 'free' - * - * - * 'meta' - array of Meta relating to query submitted indexed by column ID - * - * - * 'submitted' - raised when query submitted to native driver (maybe held on outbound q) - * - * - * 'column' - column index and data returned as results are returned - can index into - * meta array previously returned. - * - * - * 'row' - indicating the start of a new row of data along with row index 0,1 .. - * - * - * 'rowcount' - number of rows effected - * - * - * 'error' - critical error that caused the query to end - * - * - * 'info' - non-critical warning raised during query execution - * - * - * 'done' - the JS has consumed all data and query is complete. - * - * - * 'free' - when the native driver releases resources relating to query and entire lifecycle - * comes to an end. the ODBC statement handle has been released at this point by native driver - * - * - * @param cb - callback containing data related to subscription - */ - on: (event: string, cb: sqlQueryEventType) => void - /** - * cancel active query - this will submit cancel on native driver on a different - * thread such that if the query thread is blocked, the query will still be - * cancelled. If results are being streamed then the results are halted - * and query is terminated. - * @param qcb status callback indicating the cancel has been actioned. - */ - cancelQuery: (qcb?: StatusCb) => void - /** - * temporarily suspend flow of data sent by native driver to be used - * as flow control where for example expensive time consuming processing - * is taken place on a batch - receive N rows, pause, process, resume - * this prevents large memory build up where data arrives faster than - * it is being processed. - * @param qcb callback indicating query is paused. - */ - pauseQuery: (qcb?: StatusCb) => void - /** - * resume processing i.e. instruct native driver to send more data which - * will continue unless query is paused once more. - * @param qcb - */ - resumeQuery: (qcb?: StatusCb) => void - /** - * is this instance of query currently paused in which case - * no more results will be returned until query is resumed. - * @returns flag indicating if the query is paused. - */ - isPaused: () => boolean - } - - interface ConnectDescription { - conn_str: string - conn_timeout?: number - } - - interface QueryDescription { - /** - * the sql to submit to server to execute. - */ - query_str: string - /** - * for BigInt can return string to avoid overflow - */ - numeric_string?: boolean - query_timeout?: number - query_polling?: boolean - query_tz_adjustment?: number - /** - * constrain nvarchar(max) columns for prepared statements - i.e. will - * set aefault 8k max size on nvarchar(max) columns. Note this - * will not work when an encrypted connection is beng used - the - * query will not prepare and return an error. - */ - max_prepared_column_size?: number - } - - interface Meta { - name: string - nullable: boolean - size: number - sqlType: string - type: string - } - - interface Error { - code?: number - severity?: number - lineNumber?: number - serverName?: string - procName?: string - message: string - sqlstate?: string - } - - interface RawData { - meta: Meta[] - rows: sqlJsColumnType[][] - } - - interface PoolStatusRecord { - time: Date - parked: number - idle: number - busy: number - pause: number - parking: number - workQueue: number - activity: string - op: string - lastSql?: string - } - - type PoolStatusRecordCb = (status: PoolStatusRecord) => void - - type QueryDescriptionCb = (description: QueryDescription) => void - - type MessageCb = (msg: string) => void - - type PoolOptionsEventCb = (options: PoolOptions) => void - - type PoolOpenCb = (err: Error, options: PoolOptions) => void - - type SimpleCb = () => void - - type TableCb = (err: Error, table: Table) => void - - type BindCb = (cb: BulkTableMgr) => void - - type GetTableCb = (err: Error, table: BulkTableMgr) => void - - type OpenCb = (err: Error, connection: Connection) => void - - type QueryCb = (err?: Error, rows?: sqlObjectType[], more?: boolean) => void - - type CallProcedureCb = (err?: Error, rows?: sqlObjectType[], outputParams?: sqlJsColumnType[]) => void - - type QueryRawCb = (err?: Error, raw?: RawData, more?: boolean) => void - - type StatusCb = (err?: Error) => void - - type PrepareCb = (err?: Error, statement?: PreparedStatement) => void - - type MetaEventCb = (meta: Meta[]) => void - - type RowCountEventCb = (rowcount: number) => void - - type RowEventCb = (row: number) => void - - type ColumnEventCb = (index: number, data: sqlJsColumnType) => void + export type ColumnEventCb = (index: number, data: sqlJsColumnType) => void - type SubmittedEventCb = (description: QueryDescription) => void + export type SubmittedEventCb = (description: QueryDescription) => void - type EventColumnCb = (colIndex: number, data: any, more: boolean) => void + export type EventColumnCb = (colIndex: number, data: any, more: boolean) => void - type BulkSelectCb = (err: Error, rows: sqlObjectType[]) => void + export type BulkSelectCb = (err: Error, rows: sqlObjectType[]) => void - type DescribeProcedureCb = (description?: ProcedureSummary) => void + export type DescribeProcedureCb = (description?: ProcedureSummary) => void - type GetProcedureCb = (procedure?: ProcedureDefinition) => void + export type GetProcedureCb = (procedure?: ProcedureDefinition) => void - type GetProcCb = (err: Error, procedure?: ProcedureDefinition) => void + export type GetProcCb = (err: Error, procedure?: ProcedureDefinition) => void - interface BulkMgrSummary { - insertSignature: string - whereColumns: TableColumn[] - updateColumns: TableColumn[] - selectSignature: string - deleteSignature: string - updateSignature: string - columns: TableColumn[] - primaryColumns: TableColumn[] - assignableColumns: TableColumn - } + export interface BulkMgrSummary { + insertSignature: string + whereColumns: TableColumn[] + updateColumns: TableColumn[] + selectSignature: string + deleteSignature: string + updateSignature: string + columns: TableColumn[] + primaryColumns: TableColumn[] + assignableColumns: TableColumn + } - interface BulkTableMgrPromises { - select: (cols: sqlObjectType[]) => Promise - /** - * promise to submit rows to database where each row is represented - * by column name - * { - * id: 1, - * col_a: 'hello' - * } - * each column is bound precisely as defined on the table hence - * will work with always on encryption. - * @param rows - array of objects to be inserted as rows. - */ - insert: (rows: sqlBulkType) => Promise + export interface BulkTableMgrPromises { + select: (cols: sqlObjectType[]) => Promise + /** + * promise to submit rows to database where each row is represented + * by column name + * { + * id: 1, + * col_a: 'hello' + * } + * each column is bound precisely as defined on the table hence + * will work with always on encryption. + * @param rows - array of objects to be inserted as rows. + */ + insert: (rows: sqlBulkType) => Promise - delete: (rows: sqlBulkType) => Promise + delete: (rows: sqlBulkType) => Promise - update: (rows: sqlBulkType) => Promise - } + update: (rows: sqlBulkType) => Promise + } - interface BulkTableMgr { - asTableType: (name?: string) => Table - /** - * utiity method returning a SQL definition of an equivalent user table type - * that can be used for a TVP stored proc param type allowing bulk select - * and insert into the table to which this type represents. - * @param name - */ - asUserType: (name?: string) => string - deleteRows: (rows: object[], cb: StatusCb) => void - getAssignableColumns: () => TableColumn[] + export interface BulkTableMgr { + asTableType: (name?: string) => Table + /** + * utiity method returning a SQL definition of an equivalent user table type + * that can be used for a TVP stored proc param type allowing bulk select + * and insert into the table to which this type represents. + * @param name + */ + asUserType: (name?: string) => string + deleteRows: (rows: object[], cb: StatusCb) => void + getAssignableColumns: () => TableColumn[] - // the driver will be sent column types in table rather than deriving from data - // necessary to switch on for TZ adjustment i.e. for non UTC times sent - /** - * current driver version used by driver to dynamically load library for bcp - * @returns the driver version - */ - getBcpVersion: () => number + // the driver will be sent column types in table rather than deriving from data + // necessary to switch on for TZ adjustment i.e. for non UTC times sent + /** + * current driver version used by driver to dynamically load library for bcp + * @returns the driver version + */ + getBcpVersion: () => number - getColumnsByName: () => TableColumn[] + getColumnsByName: () => TableColumn[] - getDeleteSignature: () => string + getDeleteSignature: () => string - getInsertSignature: () => string + getInsertSignature: () => string - getPrimaryColumns: () => TableColumn[] + getPrimaryColumns: () => TableColumn[] - getSelectSignature: () => string + getSelectSignature: () => string - getSummary: () => BulkMgrSummary - - getUpdateColumns: () => TableColumn[] - - getUpdateSignature: () => string - - /** - * get current bcp mode ie. is bcp on - * @returns bcp status - */ - getUseBcp: () => boolean - - getWhereColumns: () => TableColumn[] - - insertRows: (rows: object[], cb: StatusCb) => void - - /** - * for a set of objects extract primary key fields only - * @param vec - array of objects - * @returns - array of objects containing only primary keys - */ - keys: (vec: object[]) => object[] - - promises: BulkTableMgrPromises - - selectRows: (cols: object[], cb: BulkSelectCb) => void - - setBatchSize: (size: number) => void - - /** - * bcp requires the ms odbc driver to be dynamically loaded as it is not part of - * ODBC. If driver default as below is used, this method is automatically called - * with 17, 18 (numeric). The default value is 17. If using an alias or DCN entry - * may need to manually call this method. - * "UAT18": "Driver={ODBC Driver 18 for SQL Server}; Server= ... Database=node;TrustServerCertificate=yes;", - * "UAT": "Driver={ODBC Driver 17 for SQL Server}; Server= ... Database=node", - * @param v the driver version used for bcp - */ - setBcpVersion: (v: number) => void - - setUpdateCols: (cols: object[]) => void - - /** - * effects insert only - use bcp for increased bcp speed - * only works on ODBC Driver 17/18 for SQL Server - * bcp will bind block of memory and copy rows into that block - * and send to server - resulting in fast insert speeds. - * @param bcp - switch insert bcp on/off - */ - setUseBcp: (bcp: boolean) => void - - setWhereCols: (cols: object[]) => void - - updateRows: (rows: object[], cb: StatusCb) => void - - useMetaType: (yn: boolean) => void - } - - interface TableValueColumn { - - name: string - column_id: number - ordered_column: string - column_name: string - type_id: string - data_type: string - nullable: string - length: number - precision: number - scale: number - collation: number - } - - interface ProcedureParam { - is_user_defined?: boolean - is_output: boolean - name: string - type_id: string - max_length: number - precision: number - scale: number - order: number - update_signature: string - collation: any - val: sqlProcParamType - } - - interface TvpParam extends ProcedureParam { - /** - * the strongly typed parameters relating to the table type - * repremted as rows i.e. array of values per column type - */ - table_value_param: ConcreteColumnType[] - /** - * user table type to which the tvp is targetting - */ - table_name: string - /** - * original table used to populate the tvp - * data within this table has been copied into - * table_value_param - */ - value: Table - /** - * number rows to be bound - */ - row_count: number - /** - * schema to which table belongs - */ - schema: string - } - - interface ProcedureDefinitionPromises { - call: (params?: sqlProcParamType, options?: QueryAggregatorOptions) => Promise - } - - interface ProcedureDefinition { - promises: ProcedureDefinitionPromises - setDialect: (dialect: ServerDialect) => boolean - /** - * @deprecated - given an object containing parameters as proeprties produce - * an array of parameters that can be provided to call. This is no longer - * necessary, an object can be passed directly to call. - * @param params - * @returns an array to be used in method 'call' - */ - paramsArray: (params: sqlObjectType) => sqlProcParamType[] - /** - * call a stored procedure witb optional parameters - * @param params object parameters { p1: 6, p2: 'hello' } or ordered - * array [ 6, 'p2' ]. Note the values given are enriched with metadata for - * parameters defined such that they can be precisely bound thus allowing - * always on encryption to work for procedure calls. - * @param cb optional callback called when procedure call completes - * @returns query object which can be used as an event stream or - * used to cancel query. - */ - call: (params?: sqlProcParamType, cb?: CallProcedureCb) => Query - - setTimeout: (to: number) => void - - setPolling: (polling: boolean) => void - - getMeta: () => ProcedureSummary - /** - * the name of the bound stored procedure - */ - getName: () => string - } - - interface ProcedureSummary { - select: string - signature: string - summary: string - params: ProcedureParam[] - } - - /* + getSummary: () => BulkMgrSummary + + getUpdateColumns: () => TableColumn[] + + getUpdateSignature: () => string + + /** + * get current bcp mode ie. is bcp on + * @returns bcp status + */ + getUseBcp: () => boolean + + getWhereColumns: () => TableColumn[] + + insertRows: (rows: object[], cb: StatusCb) => void + + /** + * for a set of objects extract primary key fields only + * @param vec - array of objects + * @returns - array of objects containing only primary keys + */ + keys: (vec: object[]) => object[] + + promises: BulkTableMgrPromises + + selectRows: (cols: object[], cb: BulkSelectCb) => void + + setBatchSize: (size: number) => void + + /** + * bcp requires the ms odbc driver to be dynamically loaded as it is not part of + * ODBC. If driver default as below is used, this method is automatically called + * with 17, 18 (numeric). The default value is 17. If using an alias or DCN entry + * may need to manually call this method. + * "UAT18": "Driver={ODBC Driver 18 for SQL Server}; Server= ... Database=node;TrustServerCertificate=yes;", + * "UAT": "Driver={ODBC Driver 17 for SQL Server}; Server= ... Database=node", + * @param v the driver version used for bcp + */ + setBcpVersion: (v: number) => void + + setUpdateCols: (cols: object[]) => void + + /** + * effects insert only - use bcp for increased bcp speed + * only works on ODBC Driver 17/18 for SQL Server + * bcp will bind block of memory and copy rows into that block + * and send to server - resulting in fast insert speeds. + * @param bcp - switch insert bcp on/off + */ + setUseBcp: (bcp: boolean) => void + + setWhereCols: (cols: object[]) => void + + updateRows: (rows: object[], cb: StatusCb) => void + + useMetaType: (yn: boolean) => void + } + + export interface TableValueColumn { + + name: string + column_id: number + ordered_column: string + column_name: string + type_id: string + data_type: string + nullable: string + length: number + precision: number + scale: number + collation: number + } + + export interface ProcedureParam { + is_user_defined?: boolean + is_output: boolean + name: string + type_id: string + max_length: number + precision: number + scale: number + order: number + update_signature: string + collation: any + val: sqlProcParamType + } + + export interface TvpParam extends ProcedureParam { + /** + * the strongly typed parameters relating to the table type + * repremted as rows i.e. array of values per column type + */ + table_value_param: ConcreteColumnType[] + /** + * user table type to which the tvp is targetting + */ + table_name: string + /** + * original table used to populate the tvp + * data within this table has been copied into + * table_value_param + */ + value: Table + /** + * number rows to be bound + */ + row_count: number + /** + * schema to which table belongs + */ + schema: string + } + + export interface ProcedureDefinitionPromises { + call: (params?: sqlProcParamType, options?: QueryAggregatorOptions) => Promise + } + + export interface ProcedureDefinition { + promises: ProcedureDefinitionPromises + setDialect: (dialect: ServerDialect) => boolean + /** + * @deprecated - given an object containing parameters as proeprties produce + * an array of parameters that can be provided to call. This is no longer + * necessary, an object can be passed directly to call. + * @param params + * @returns an array to be used in method 'call' + */ + paramsArray: (params: sqlObjectType) => sqlProcParamType[] + /** + * call a stored procedure witb optional parameters + * @param params object parameters { p1: 6, p2: 'hello' } or ordered + * array [ 6, 'p2' ]. Note the values given are enriched with metadata for + * parameters defined such that they can be precisely bound thus allowing + * always on encryption to work for procedure calls. + * @param cb optional callback called when procedure call completes + * @returns query object which can be used as an event stream or + * used to cancel query. + */ + call: (params?: sqlProcParamType, cb?: CallProcedureCb) => Query + + setTimeout: (to: number) => void + + setPolling: (polling: boolean) => void + + getMeta: () => ProcedureSummary + /** + * the name of the bound stored procedure + */ + getName: () => string + } + + export interface ProcedureSummary { + select: string + signature: string + summary: string + params: ProcedureParam[] + } + + /* user define and register a proc e.g. for Sybase Adaptive Server @last_name varchar(30) = "knowles", @@ -1166,60 +1165,60 @@ declare module 'msnodesqlv8/types' { pm.addProc(spName, params) */ - interface ProcedureManager { - /** - * @deprecated Please use `getProc` - this is not promise friendly - */ - get: (name: string, cb?: GetProcedureCb) => void // cannot promisify (proc) - getProc: (name: string, cb?: GetProcCb) => void // promise friendly (err, proc) - callproc: (name: string, params?: any[], cb?: CallProcedureCb) => Query - /*** - * manually register a stored procedure. - * const params = [ - * pm.makeParam(spName, '@last_name', 'varchar', 30, false), - * pm.makeParam(spName, '@first_name', 'varchar', 18, false) - * ] - * @param procName - name of proc to which this param belongs - * @param paramName - unique name of the parameter. - * @param paramType - the undecorated type declaration varchar, int - * @param paramLength - the length of parameter - * @param isOutput - is this an output param - * @returns the param type equivalent to that fetched when using getProc - */ - makeParam: (procName: string, paramName: string, paramType: string, paramLength: number, isOutput: boolean) => ProcedureParamMeta - /** - * manually register a procedure ie pm.addProc(spName, params) - * @param name of the stored procedure to register - * @param paramVector the list of parameters making up call - * @returns defintion equivalent to that fetched in getProc - */ - addProc: (name: string, paramVector: ProcedureParamMeta[]) => ProcedureDefinition - - describe: (name: string, cb?: DescribeProcedureCb) => void - - setTimeout: (timeout: number) => void - - setPolling: (poll: boolean) => void - - ServerDialect: ServerDialect - } - - interface ProcedureParamMeta { - proc_name: string - type_desc: string - object_id: number - has_default_value: boolean - default_value: string - is_output: boolean - name: string - type_id: string - max_length: number - order: number - collation: string - is_user_defined: boolean - } - - /* + export interface ProcedureManager { + /** + * @deprecated Please use `getProc` - this is not promise friendly + */ + get: (name: string, cb?: GetProcedureCb) => void // cannot promisify (proc) + getProc: (name: string, cb?: GetProcCb) => void // promise friendly (err, proc) + callproc: (name: string, params?: any[], cb?: CallProcedureCb) => Query + /*** + * manually register a stored procedure. + * const params = [ + * pm.makeParam(spName, '@last_name', 'varchar', 30, false), + * pm.makeParam(spName, '@first_name', 'varchar', 18, false) + * ] + * @param procName - name of proc to which this param belongs + * @param paramName - unique name of the parameter. + * @param paramType - the undecorated type declaration varchar, int + * @param paramLength - the length of parameter + * @param isOutput - is this an output param + * @returns the param type equivalent to that fetched when using getProc + */ + makeParam: (procName: string, paramName: string, paramType: string, paramLength: number, isOutput: boolean) => ProcedureParamMeta + /** + * manually register a procedure ie pm.addProc(spName, params) + * @param name of the stored procedure to register + * @param paramVector the list of parameters making up call + * @returns defintion equivalent to that fetched in getProc + */ + addProc: (name: string, paramVector: ProcedureParamMeta[]) => ProcedureDefinition + + describe: (name: string, cb?: DescribeProcedureCb) => void + + setTimeout: (timeout: number) => void + + setPolling: (poll: boolean) => void + + ServerDialect: ServerDialect + } + + export interface ProcedureParamMeta { + proc_name: string + type_desc: string + object_id: number + has_default_value: boolean + default_value: string + is_output: boolean + name: string + type_id: string + max_length: number + order: number + collation: string + is_user_defined: boolean + } + + /* const tableName = 'tmpTableBuilder' const mgr = theConnection.tableMgr() const builder = mgr.makeBuilder(tableName, 'scratch') @@ -1237,495 +1236,594 @@ declare module 'msnodesqlv8/types' { const vec = getVec(20) */ - interface ServerDialect { - SqlServer: ServerDialect - Sybase: ServerDialect - } - - interface TableBuilder { - // can use utility method e.g. builder.addColumn('col_b').asVarChar(100) - /** - * e.g. builder.addColumn('col_b').asVarChar(100) - * @param columnName must be unique for table and reprents new column - * @param columnType the textual type as represented in database - * @param maxLength optional for certain types - * @param isPrimaryKey 1 is prmary key - * @returns the column instance that can be further specialised with fluent api - */ - addColumn: (columnName: string, columnType?: string, maxLength?: number, isPrimaryKey?: number) => TableColumn - - // builder.setDialect(mgr.ServerDialect.Sybase) - /** - * - * @param dialect specifies if using Sybase, defaults to SQL server - */ - setDialect: (dialect: ServerDialect) => boolean - - /** - * recompute the table properties based on columns added - */ - compute: () => void - - /** - * constructs a bulk table manager to register which will be used - * rather than via a call to server to obtain meta data. - * @returns a bulk table that can be registered with table manager. - */ - toTable: () => BulkTableMgr - - /** - * used for testing where table can be dropped ready for re-creation. - * @returns await promise to drop the table - */ - drop: () => Promise - - /** - * used for testing where table is created in server based on columns - * @returns promise to await for table created. - */ - create: () => Promise - - /** - * used for testing where table can be truncated. - * @returns promise to await for table to be truncated. - */ - truncate: () => Promise - - /** - * remove all columns added so far - */ - clear: () => void - - // a wrapper procedure definition with column as parameters - /** - * a stored proc which has params representing the columns where a row - * is inserted into table. - * @param procname the name of the procedure - * @returns sql representing a stored proc to insert a row into the table. - */ - insertProcSql: (procname?: string) => string - - // proc to accept tvp param for table and copy/bulk insert - /** - * a stored proc which has a single TVP param representing the columns where rows - * are inserted into table by selecting from tvp - * @param procname the name of the procedure - * @param tableTypeName the name of the tvp type as param of proc - * @returns sql representing a stored proc to insert a row into the table. - */ - insertTvpProcSql: (procname?: string, tableTypeName?: string) => string - - /** - * the name of table type represented by table e.g. dbo.tmpTableBuilderType - */ - typeName: string - /** - * the columns added into the table - */ - columns: TableColumn[] - /** - * the columns which are not readonly and form part of insert statement - */ - insertColumns: TableColumn[] - /** - * sql to drop the table type e.g. - * IF TYPE_ID(N'dbo.tmpTableBuilderType') IS not NULL drop type dbo.tmpTableBuilderType - */ - // - dropTypeSql: string - /** - * sql to create the table type representing the table. - * e.g. CREATE TYPE dbo.tmpTableBuilderType AS TABLE ([id] int , [MatterColumn] varchar (100) NOT NULL, [SearchTerm] nvarchar (MAX) NOT NULL, [Comparator] nvarchar (20) NOT NULL) - */ - // - userTypeTableSql: string - /** - * the sql to dtop the table - * e.g. IF OBJECT_ID('dbo.tmpTableBuilder', 'U') IS NOT NULL DROP TABLE dbo.tmpTableBuilder; - */ - // - dropTableSql: string - /** - * the sql to create the table - * e.g. CREATE TABLE dbo.tmpTableBuilder ([id] int , [MatterColumn] varchar (100) NOT NULL, [SearchTerm] nvarchar (MAX) NOT NULL, [Comparator] nvarchar (20) NOT NULL) - */ - createTableSql: string - /** - * sql for a clustered index around primary keys - */ - clusteredSql: string - /** - * the select signature to fetch all columns - */ - selectSql: string - /** - * sql to insert into server. - */ - insertSql: string - /** - * sql to truncate the table - */ - truncateSql: string - /** - * sql of the signature of insert params - * e.g. ('?', '?') - */ - paramsSql: string - insertParamsSql: string - /** - * the proc sql to insert a row via params - */ - insertTvpProcedureName: string - /** - * the proc sql taking a tvp param - */ - insertProcedureTvpSql: string - - /** - * drop the insertProcedureTvpSql proc if it exists - */ - dropInsertTvpProcedure: string - } - - interface TableManagerPromises { - getTable: (name: string) => Promise - - getUserTypeTable: (name: string) => Promise
- } - - interface TableManager { - promises: TableManagerPromises - - /** - * @deprecated Please use `getTable` - */ - bind: (tableName: string, cb: BindCb) => void // cannot promisify (table) - getTable: (tableName: string, cb: GetTableCb) => void // promise friendly (err, table) - // manually register a table - addTable: (tableName: string, cols: TableColumn[]) => BulkTableMgr - - // utility class to help manually add tables - makeBuilder: (tableName: string, tableCatelog?: string, tableSchema?: string) => TableBuilder - - // or use builder to build columns - ServerDialect: ServerDialect - - makeColumn: (tableName: string, tableSchema: string, position: number, columnName: string, paramType: string, paramLength: number, isPrimaryKey: number) => TableColumn - } - - interface PreparedPromises { - /** - * free the unmanaged resources representing the prepared statement - * @returns promise to await for statement to be released on server - */ - free: () => Promise - - /** - * submit a query on a prepared statement - * @param params array of parameters previously bound in prepared query. - * @param options optional params on query such as timeout - * @returns promise to await for query results - */ - query: (params?: any[], options?: QueryAggregatorOptions) => Promise - } - - interface PreparedStatement { - /** - * promises to query and free the statement - */ - promises: PreparedPromises - - /** - * submit bound query using provided params - * @param params - the param array on query - * @param cb - called with query results. - */ - preparedQuery: (params?: any[], cb?: QueryCb) => Query - - /** - * free the prepared statement - * @param cb called when server frees the statement - */ - free: (cb?: StatusCb) => void - - /** - * the sql representing the bound query. - * @returns sql submitted to bind statement. - */ - getSignature: () => string - - /** - * the id representing the prepared query - * @returns the numeric id of statement - */ - getId: () => number - - /** - * metadata returned by binding the prepared query. - * @returns array of bound parameter information describing parameter. - */ - getMeta: () => Meta[] - } - - interface ConcreteColumnType { - /*** - * the ODBC type which will be used to bind parameter. If this is not - * provided, the value is used to guess what binding should be used. - * This works for all non encrypted columns as the server will cast - * the parameter to target colmn type. When using encryption the driver - * assigns this and precision, scale based on metadata describing the - * column or parameter type. - */ - sql_type: number - /** - * the actual JS value sent to native driver to be comverted to native - * c type and on to the server. - */ - value?: sqlQueryParamType - precision?: number - scale?: number - /** - * used in datetimeoffset based parameters - */ - offset?: number - /** - * is the parameter a datetime type. - * do not set - this is computed and used by native driver in binding parameter. - */ - isDateTime: boolean - /** - * is the parameter a time2 type. - * do not set - this is computed and used by native driver in binding parameter. - */ - isTime2: boolean - fraction?: number - } + export interface ServerDialect { + SqlServer: ServerDialect + Sybase: ServerDialect + } + + export interface TableBuilder { + // can use utility method e.g. builder.addColumn('col_b').asVarChar(100) + /** + * e.g. builder.addColumn('col_b').asVarChar(100) + * @param columnName must be unique for table and reprents new column + * @param columnType the textual type as represented in database + * @param maxLength optional for certain types + * @param isPrimaryKey 1 is prmary key + * @returns the column instance that can be further specialised with fluent api + */ + addColumn: (columnName: string, columnType?: string, maxLength?: number, isPrimaryKey?: number) => TableColumn + + // builder.setDialect(mgr.ServerDialect.Sybase) + /** + * + * @param dialect specifies if using Sybase, defaults to SQL server + */ + setDialect: (dialect: ServerDialect) => boolean + + /** + * recompute the table properties based on columns added + */ + compute: () => void + + /** + * constructs a bulk table manager to register which will be used + * rather than via a call to server to obtain meta data. + * @returns a bulk table that can be registered with table manager. + */ + toTable: () => BulkTableMgr + + /** + * used for testing where table can be dropped ready for re-creation. + * @returns await promise to drop the table + */ + drop: () => Promise + + /** + * used for testing where table is created in server based on columns + * @returns promise to await for table created. + */ + create: () => Promise + + /** + * used for testing where table can be truncated. + * @returns promise to await for table to be truncated. + */ + truncate: () => Promise + + /** + * remove all columns added so far + */ + clear: () => void + + // a wrapper procedure definition with column as parameters + /** + * a stored proc which has params representing the columns where a row + * is inserted into table. + * @param procname the name of the procedure + * @returns sql representing a stored proc to insert a row into the table. + */ + insertProcSql: (procname?: string) => string + + // proc to accept tvp param for table and copy/bulk insert + /** + * a stored proc which has a single TVP param representing the columns where rows + * are inserted into table by selecting from tvp + * @param procname the name of the procedure + * @param tableTypeName the name of the tvp type as param of proc + * @returns sql representing a stored proc to insert a row into the table. + */ + insertTvpProcSql: (procname?: string, tableTypeName?: string) => string + + /** + * the name of table type represented by table e.g. dbo.tmpTableBuilderType + */ + typeName: string + /** + * the columns added into the table + */ + columns: TableColumn[] + /** + * the columns which are not readonly and form part of insert statement + */ + insertColumns: TableColumn[] + /** + * sql to drop the table type e.g. + * IF TYPE_ID(N'dbo.tmpTableBuilderType') IS not NULL drop type dbo.tmpTableBuilderType + */ + // + dropTypeSql: string + /** + * sql to create the table type representing the table. + * e.g. CREATE TYPE dbo.tmpTableBuilderType AS TABLE ([id] int , [MatterColumn] varchar (100) NOT NULL, [SearchTerm] nvarchar (MAX) NOT NULL, [Comparator] nvarchar (20) NOT NULL) + */ + // + userTypeTableSql: string + /** + * the sql to dtop the table + * e.g. IF OBJECT_ID('dbo.tmpTableBuilder', 'U') IS NOT NULL DROP TABLE dbo.tmpTableBuilder; + */ + // + dropTableSql: string + /** + * the sql to create the table + * e.g. CREATE TABLE dbo.tmpTableBuilder ([id] int , [MatterColumn] varchar (100) NOT NULL, [SearchTerm] nvarchar (MAX) NOT NULL, [Comparator] nvarchar (20) NOT NULL) + */ + createTableSql: string + /** + * sql for a clustered index around primary keys + */ + clusteredSql: string + /** + * the select signature to fetch all columns + */ + selectSql: string + /** + * sql to insert into server. + */ + insertSql: string + /** + * sql to truncate the table + */ + truncateSql: string + /** + * sql of the signature of insert params + * e.g. ('?', '?') + */ + paramsSql: string + insertParamsSql: string + /** + * the proc sql to insert a row via params + */ + insertTvpProcedureName: string + /** + * the proc sql taking a tvp param + */ + insertProcedureTvpSql: string + + /** + * drop the insertProcedureTvpSql proc if it exists + */ + dropInsertTvpProcedure: string + } + + export interface TableManagerPromises { + getTable: (name: string) => Promise + + getUserTypeTable: (name: string) => Promise
+ } + + export interface TableManager { + promises: TableManagerPromises + + /** + * @deprecated Please use `getTable` + */ + bind: (tableName: string, cb: BindCb) => void // cannot promisify (table) + getTable: (tableName: string, cb: GetTableCb) => void // promise friendly (err, table) + // manually register a table + addTable: (tableName: string, cols: TableColumn[]) => BulkTableMgr + + // utility class to help manually add tables + makeBuilder: (tableName: string, tableCatelog?: string, tableSchema?: string) => TableBuilder + + // or use builder to build columns + ServerDialect: ServerDialect + + makeColumn: (tableName: string, tableSchema: string, position: number, columnName: string, paramType: string, paramLength: number, isPrimaryKey: number) => TableColumn + } + + export interface PreparedPromises { + /** + * free the unmanaged resources representing the prepared statement + * @returns promise to await for statement to be released on server + */ + free: () => Promise + + /** + * submit a query on a prepared statement + * @param params array of parameters previously bound in prepared query. + * @param options optional params on query such as timeout + * @returns promise to await for query results + */ + query: (params?: any[], options?: QueryAggregatorOptions) => Promise + } + + export interface PreparedStatement { + /** + * promises to query and free the statement + */ + promises: PreparedPromises + + /** + * submit bound query using provided params + * @param params - the param array on query + * @param cb - called with query results. + */ + preparedQuery: (params?: any[], cb?: QueryCb) => Query + + /** + * free the prepared statement + * @param cb called when server frees the statement + */ + free: (cb?: StatusCb) => void + + /** + * the sql representing the bound query. + * @returns sql submitted to bind statement. + */ + getSignature: () => string + + /** + * the id representing the prepared query + * @returns the numeric id of statement + */ + getId: () => number + + /** + * metadata returned by binding the prepared query. + * @returns array of bound parameter information describing parameter. + */ + getMeta: () => Meta[] + } + + export interface ConcreteColumnType { + /*** + * the ODBC type which will be used to bind parameter. If this is not + * provided, the value is used to guess what binding should be used. + * This works for all non encrypted columns as the server will cast + * the parameter to target colmn type. When using encryption the driver + * assigns this and precision, scale based on metadata describing the + * column or parameter type. + */ + sql_type: number + /** + * the actual JS value sent to native driver to be comverted to native + * c type and on to the server. + */ + value?: sqlQueryParamType + precision?: number + scale?: number + /** + * used in datetimeoffset based parameters + */ + offset?: number + /** + * is the parameter a datetime type. + * do not set - this is computed and used by native driver in binding parameter. + */ + isDateTime: boolean + /** + * is the parameter a time2 type. + * do not set - this is computed and used by native driver in binding parameter. + */ + isTime2: boolean + fraction?: number + } - enum QueryEvent { - meta = 'meta', - column = 'column', - partial = 'partial', - rowCount = 'rowCount', - row = 'row', - done = 'done', - free = 'free', - error = 'error', - warning = 'warning', - closed = 'closed', - submitted = 'submitted', - output = 'output' - } + export enum QueryEvent { + meta = 'meta', + column = 'column', + partial = 'partial', + rowCount = 'rowCount', + row = 'row', + done = 'done', + free = 'free', + error = 'error', + warning = 'warning', + closed = 'closed', + submitted = 'submitted', + output = 'output' + } - interface UserConversion { - Bit: (v: number) => ConcreteColumnType + export interface UserConversion { + Bit: (v: number) => ConcreteColumnType - BigInt: (v: number) => ConcreteColumnType + BigInt: (v: number) => ConcreteColumnType - Int: (v: number) => ConcreteColumnType + Int: (v: number) => ConcreteColumnType - TinyInt: (v: number) => ConcreteColumnType + TinyInt: (v: number) => ConcreteColumnType - SmallInt: (v: number) => ConcreteColumnType + SmallInt: (v: number) => ConcreteColumnType - Float: (v: number) => ConcreteColumnType + Float: (v: number) => ConcreteColumnType - Numeric: (v: number) => ConcreteColumnType - - Money: (v: number) => ConcreteColumnType - - SmallMoney: (v: number) => ConcreteColumnType - - Decimal: (v: number) => ConcreteColumnType - - Double: (v: number) => ConcreteColumnType + Numeric: (v: number) => ConcreteColumnType + + Money: (v: number) => ConcreteColumnType + + SmallMoney: (v: number) => ConcreteColumnType + + Decimal: (v: number) => ConcreteColumnType + + Double: (v: number) => ConcreteColumnType - Real: (v: number) => ConcreteColumnType + Real: (v: number) => ConcreteColumnType - WVarChar: (v: string) => ConcreteColumnType + WVarChar: (v: string) => ConcreteColumnType - Char: (v: string) => ConcreteColumnType + Char: (v: string) => ConcreteColumnType - VarChar: (v: string) => ConcreteColumnType + VarChar: (v: string) => ConcreteColumnType - NChar: (v: string) => ConcreteColumnType + NChar: (v: string) => ConcreteColumnType - NVarChar: (v: string) => ConcreteColumnType + NVarChar: (v: string) => ConcreteColumnType - Text: (v: string) => ConcreteColumnType + Text: (v: string) => ConcreteColumnType - NText: (v: string) => ConcreteColumnType + NText: (v: string) => ConcreteColumnType - Xml: (v: string) => ConcreteColumnType + Xml: (v: string) => ConcreteColumnType - WLongVarChar: (v: string) => ConcreteColumnType + WLongVarChar: (v: string) => ConcreteColumnType - UniqueIdentifier: (v: string) => ConcreteColumnType + UniqueIdentifier: (v: string) => ConcreteColumnType - VarBinary: (v: Buffer) => ConcreteColumnType + VarBinary: (v: Buffer) => ConcreteColumnType - LongVarBinary: (v: Buffer) => ConcreteColumnType + LongVarBinary: (v: Buffer) => ConcreteColumnType - Image: (v: Buffer) => ConcreteColumnType + Image: (v: Buffer) => ConcreteColumnType - Time: (v: Date) => ConcreteColumnType + Time: (v: Date) => ConcreteColumnType - Date: (v: Date) => ConcreteColumnType + Date: (v: Date) => ConcreteColumnType - DateTime: (v: Date) => ConcreteColumnType + DateTime: (v: Date) => ConcreteColumnType - DateTime2: (v: Date) => ConcreteColumnType + DateTime2: (v: Date) => ConcreteColumnType - DateRound: (v: Date) => ConcreteColumnType + DateRound: (v: Date) => ConcreteColumnType - SmallDateTime: (v: Date) => ConcreteColumnType + SmallDateTime: (v: Date) => ConcreteColumnType - DateTimeOffset: (v: Date) => ConcreteColumnType - } + DateTimeOffset: (v: Date) => ConcreteColumnType + } - interface NativeReadColumnInfo { - end_rows: boolean - data: any[] - } + export interface NativeReadColumnInfo { + end_rows: boolean + data: any[] + } - interface NativeNextResultInfo { - endOfResults: boolean - endOfRows: boolean - preRowCount: boolean - rowCount: number - meta?: Meta[] - } + export interface NativeNextResultInfo { + endOfResults: boolean + endOfRows: boolean + preRowCount: boolean + rowCount: number + meta?: Meta[] + } - type NativeReadColumnCb = (err: Error, results: NativeReadColumnInfo) => void + export type NativeReadColumnCb = (err: Error, results: NativeReadColumnInfo) => void - type NativeNextResultCb = (err: Error, results: NativeNextResultInfo) => void + export type NativeNextResultCb = (err: Error, results: NativeNextResultInfo) => void - type NativeUnbindCb = (err: Error, outputVector: any[]) => void + export type NativeUnbindCb = (err: Error, outputVector: any[]) => void - type NativePrepareCb = (err: Error, meta: Meta[]) => void + export type NativePrepareCb = (err: Error, meta: Meta[]) => void - type NativeQueryCb = (err: Error, results: NativeNextResultInfo, more: boolean) => void + export type NativeQueryCb = (err: Error, results: NativeNextResultInfo, more: boolean) => void - interface NativeQueryObj { - query_str: string - numeric_string?: boolean - query_polling?: boolean - query_timeout?: number - max_prepared_column_size?: number - } + export interface NativeQueryObj { + query_str: string + numeric_string?: boolean + query_polling?: boolean + query_timeout?: number + max_prepared_column_size?: number + } - interface NativeCustomBinding { - precision?: number - scale?: number - offset?: number - value?: sqlQueryParamType - } + export interface NativeCustomBinding { + precision?: number + scale?: number + offset?: number + value?: sqlQueryParamType + } - interface NativeParam { - is_user_defined?: boolean - type_id?: number - schema?: string - bcp?: boolean - bcp_version?: number - table_name?: string - ordinal_position?: number - scale?: number - offset?: number - precision?: number - is_output?: boolean - name?: string - value?: sqlQueryParamType - } + export interface NativeParam { + is_user_defined?: boolean + type_id?: number + schema?: string + bcp?: boolean + bcp_version?: number + table_name?: string + ordinal_position?: number + scale?: number + offset?: number + precision?: number + is_output?: boolean + name?: string + value?: sqlQueryParamType + } - class NativeConnection { - constructor () + export class NativeConnection { + constructor () - readColumn (queryId: number, rowBatchSize: number, cb: NativeReadColumnCb): void + readColumn (queryId: number, rowBatchSize: number, cb: NativeReadColumnCb): void - nextResult (queryId: number, cb: NativeNextResultCb): void + nextResult (queryId: number, cb: NativeNextResultCb): void - unbind (queryId: number, cb: NativeUnbindCb): void + unbind (queryId: number, cb: NativeUnbindCb): void - close (cb: StatusCb): void - - cancelQuery (qid: number, cb: StatusCb): void - - freeStatement (qid: number, cb: StatusCb): void - - beginTransaction (cb: StatusCb): void - - rollback (cb: StatusCb): void - - commit (cb: StatusCb): void - - prepare (qid: number, queryObj: NativeQueryObj, cb: NativePrepareCb): void - - bindQuery (qid: number, params: NativeParam[], cb: NativePrepareCb): void - - query (qid: number, queryObj: NativeQueryObj, params: NativeParam[], cb: NativeQueryCb): void - - callProcedure (qid: number, procedure: string, params: NativeParam[], cb: NativeQueryCb): void - } - - interface SqlClient extends UserConversion { - /** - * helper promises allowing async style await to open connection or - * submit adhoc query on a temporarily opened connection. - */ - promises: SqlClientPromises - /** - * instanitate an instance of connection pool which improves concurrency - * by using a number of connections to balance load where a queue of - * queries is serviced by next available connection. Pool will if configured - * close idle connections and test with periodic keep alive. - */ - Pool: ((options: PoolOptions) => Pool) & (new(options?: PoolOptions) => Pool) - - // Connection: { () : NativeConnection } & { new () : NativeConnection } - /** - * async operation to open a connection to the database - * @param connStrOrDescription - either string representing connection of form - * Driver={ODBC Driver 17 for SQL Server};Server= .. or a connection description - * containing the connection string. - * @param cb - return error or connection object in form (err, Connection) - */ - open: (connStrOrDescription: string | ConnectDescription, cb: OpenCb) => void - /** - * adhoc async query with supplied parameters to open connection to database, execute a query - * and close connection. If a callback is provided results or error are returned when the - * connection is closed. The call can be used in an event driven fashion by using - * the returned query object and using the on notification call. - * - * @param conn_str - string representing connection - * @param sqlOrQuery - the textual string submitted to database or query object containing query and options - * @param paramsOrCb - with no callback this represents parameters, if any, provided with query. - * Note that the supplied parameter can be a raw value such as a string, an array of raw values when - * binding a bulk query or a concrete type where the specific binding is supplied to the driver. This is - * done autimatically by the getTable or callProc functions. - * @param cb - optional callback containing error or array of objects with column names as proeprties - * @returns - a query object which can be used to monitor progress via event notification - */ - query: (conn_str: string, sqlOrQuery: sqlQueryType, paramsOrCb?: sqlQueryParamType[] | QueryCb, cb?: QueryCb) => Query - queryRaw: (conn_str: string, sqlOrQuery: sqlQueryType, paramsOrCb?: sqlQueryParamType[] | QueryRawCb, cb?: QueryRawCb) => Query - PollingQuery: (s: string) => QueryDescription - TimeoutQuery: (s: string, to: number) => QueryDescription - TzOffsetQuery: (s: string, offsetMinutes?: number) => QueryDescription - /** - * construct a tvp parameter the native driver will recognise from an input - * table - note once this parameter has been constructed the input - * table.rows can be reset table.rows=[] as the data has been - * copied along with column metadta ready for binding by driver. - * this parameter can be used as part of a stored prcedure call or - * query where bulk select from TVP is then possible. It is an efficient - * way of sending data to the database. - * @param table - * @returns the Table Value Parameter instance ready for use in query - */ - TvpFromTable: (table: Table) => TvpParam - } + close (cb: StatusCb): void + + cancelQuery (qid: number, cb: StatusCb): void + + freeStatement (qid: number, cb: StatusCb): void + + beginTransaction (cb: StatusCb): void + + rollback (cb: StatusCb): void + + commit (cb: StatusCb): void + + prepare (qid: number, queryObj: NativeQueryObj, cb: NativePrepareCb): void + + bindQuery (qid: number, params: NativeParam[], cb: NativePrepareCb): void + + query (qid: number, queryObj: NativeQueryObj, params: NativeParam[], cb: NativeQueryCb): void + + callProcedure (qid: number, procedure: string, params: NativeParam[], cb: NativeQueryCb): void + } + + export interface SqlClient extends UserConversion { + /** + * helper promises allowing async style await to open connection or + * submit adhoc query on a temporarily opened connection. + */ + promises: SqlClientPromises + /** + * instanitate an instance of connection pool which improves concurrency + * by using a number of connections to balance load where a queue of + * queries is serviced by next available connection. Pool will if configured + * close idle connections and test with periodic keep alive. + */ + Pool: ((options: PoolOptions) => Pool) & (new(options?: PoolOptions) => Pool) + + // Connection: { () : NativeConnection } & { new () : NativeConnection } + /** + * async operation to open a connection to the database + * @param connStrOrDescription - either string representing connection of form + * Driver={ODBC Driver 17 for SQL Server};Server= .. or a connection description + * containing the connection string. + * @param cb - return error or connection object in form (err, Connection) + */ + open: (connStrOrDescription: string | ConnectDescription, cb: OpenCb) => void + /** + * adhoc async query with supplied parameters to open connection to database, execute a query + * and close connection. If a callback is provided results or error are returned when the + * connection is closed. The call can be used in an event driven fashion by using + * the returned query object and using the on notification call. + * + * @param conn_str - string representing connection + * @param sqlOrQuery - the textual string submitted to database or query object containing query and options + * @param paramsOrCb - with no callback this represents parameters, if any, provided with query. + * Note that the supplied parameter can be a raw value such as a string, an array of raw values when + * binding a bulk query or a concrete type where the specific binding is supplied to the driver. This is + * done autimatically by the getTable or callProc functions. + * @param cb - optional callback containing error or array of objects with column names as proeprties + * @returns - a query object which can be used to monitor progress via event notification + */ + query: (conn_str: string, sqlOrQuery: sqlQueryType, paramsOrCb?: sqlQueryParamType[] | QueryCb, cb?: QueryCb) => Query + queryRaw: (conn_str: string, sqlOrQuery: sqlQueryType, paramsOrCb?: sqlQueryParamType[] | QueryRawCb, cb?: QueryRawCb) => Query + PollingQuery: (s: string) => QueryDescription + TimeoutQuery: (s: string, to: number) => QueryDescription + TzOffsetQuery: (s: string, offsetMinutes?: number) => QueryDescription + /** + * construct a tvp parameter the native driver will recognise from an input + * table - note once this parameter has been constructed the input + * table.rows can be reset table.rows=[] as the data has been + * copied along with column metadta ready for binding by driver. + * this parameter can be used as part of a stored prcedure call or + * query where bulk select from TVP is then possible. It is an efficient + * way of sending data to the database. + * @param table + * @returns the Table Value Parameter instance ready for use in query + */ + TvpFromTable: (table: Table) => TvpParam + } +} + +declare module 'msnodesqlv8/types' { + export import sqlJsColumnType = MsNodeSqlV8.sqlJsColumnType + export import sqlRecordType = MsNodeSqlV8.sqlRecordType + export import sqlObjectType = MsNodeSqlV8.sqlObjectType + export import sqlQueryParamType = MsNodeSqlV8.sqlQueryParamType + export import sqlPoolEventType = MsNodeSqlV8.sqlPoolEventType + export import sqlQueryEventType = MsNodeSqlV8.sqlQueryEventType + export import sqlProcParamType = MsNodeSqlV8.sqlProcParamType + export import sqlQueryType = MsNodeSqlV8.sqlQueryType + export import sqlConnectType = MsNodeSqlV8.sqlConnectType + export import sqlColumnResultsType = MsNodeSqlV8.sqlColumnResultsType + export import sqlBulkType = MsNodeSqlV8.sqlBulkType + + export import GetSetUTC = MsNodeSqlV8.GetSetUTC + export import SubmitQuery = MsNodeSqlV8.SubmitQuery + export import AggregatorPromises = MsNodeSqlV8.AggregatorPromises + export import SqlClientPromises = MsNodeSqlV8.SqlClientPromises + export import UserTypeColumnType = MsNodeSqlV8.UserTypeColumnType + export import UserTypeColumn = MsNodeSqlV8.UserTypeColumn + + export import Table = MsNodeSqlV8.Table + export import SqlServerVersion = MsNodeSqlV8.SqlServerVersion + export import PoolOptions = MsNodeSqlV8.PoolOptions + export import QueryAggregatorResults = MsNodeSqlV8.QueryAggregatorResults + export import QueryAggregatorOptions = MsNodeSqlV8.QueryAggregatorOptions + export import PoolPromises = MsNodeSqlV8.PoolPromises + export import Pool = MsNodeSqlV8.Pool + export import TableColumn = MsNodeSqlV8.TableColumn + export import ConnectionPromises = MsNodeSqlV8.ConnectionPromises + export import Connection = MsNodeSqlV8.Connection + export import QueryPromises = MsNodeSqlV8.QueryPromises + export import Query = MsNodeSqlV8.Query + + export import ConnectDescription = MsNodeSqlV8.ConnectDescription + export import QueryDescription = MsNodeSqlV8.QueryDescription + export import Meta = MsNodeSqlV8.Meta + export import Error = MsNodeSqlV8.Error + export import RawData = MsNodeSqlV8.RawData + export import PoolStatusRecord = MsNodeSqlV8.PoolStatusRecord + export import PoolStatusRecordCb = MsNodeSqlV8.PoolStatusRecordCb + export import QueryDescriptionCb = MsNodeSqlV8.QueryDescriptionCb + export import MessageCb = MsNodeSqlV8.MessageCb + export import PoolOptionsEventCb = MsNodeSqlV8.PoolOptionsEventCb + export import PoolOpenCb = MsNodeSqlV8.PoolOpenCb + export import SimpleCb = MsNodeSqlV8.SimpleCb + export import TableCb = MsNodeSqlV8.TableCb + export import BindCb = MsNodeSqlV8.BindCb + export import GetTableCb = MsNodeSqlV8.GetTableCb + export import OpenCb = MsNodeSqlV8.OpenCb + export import QueryCb = MsNodeSqlV8.QueryCb + export import CallProcedureCb = MsNodeSqlV8.CallProcedureCb + export import QueryRawCb = MsNodeSqlV8.QueryRawCb + export import StatusCb = MsNodeSqlV8.StatusCb + export import PrepareCb = MsNodeSqlV8.PrepareCb + export import MetaEventCb = MsNodeSqlV8.MetaEventCb + export import RowCountEventCb = MsNodeSqlV8.RowCountEventCb + export import RowEventCb = MsNodeSqlV8.RowEventCb + export import ColumnEventCb = MsNodeSqlV8.ColumnEventCb + export import SubmittedEventCb = MsNodeSqlV8.SubmittedEventCb + export import EventColumnCb = MsNodeSqlV8.EventColumnCb + export import BulkSelectCb = MsNodeSqlV8.BulkSelectCb + export import DescribeProcedureCb = MsNodeSqlV8.DescribeProcedureCb + export import GetProcedureCb = MsNodeSqlV8.GetProcedureCb + export import GetProcCb = MsNodeSqlV8.GetProcCb + export import BulkMgrSummary = MsNodeSqlV8.BulkMgrSummary + export import BulkTableMgrPromises = MsNodeSqlV8.BulkTableMgrPromises + export import BulkTableMgr = MsNodeSqlV8.BulkTableMgr + export import TableValueColumn = MsNodeSqlV8.TableValueColumn + export import ProcedureParam = MsNodeSqlV8.ProcedureParam + export import TvpParam = MsNodeSqlV8.TvpParam + export import ProcedureDefinitionPromises = MsNodeSqlV8.ProcedureDefinitionPromises + export import ProcedureDefinition = MsNodeSqlV8.ProcedureDefinition + export import ProcedureSummary = MsNodeSqlV8.ProcedureSummary + export import ProcedureManager = MsNodeSqlV8.ProcedureManager + export import ProcedureParamMeta = MsNodeSqlV8.ProcedureParamMeta + export import ServerDialect = MsNodeSqlV8.ServerDialect + export import TableBuilder = MsNodeSqlV8.TableBuilder + export import TableManagerPromises = MsNodeSqlV8.TableManagerPromises + export import TableManager = MsNodeSqlV8.TableManager + export import PreparedPromises = MsNodeSqlV8.PreparedPromises + export import PreparedStatement = MsNodeSqlV8.PreparedStatement + export import ConcreteColumnType = MsNodeSqlV8.ConcreteColumnType + export import QueryEvent = MsNodeSqlV8.QueryEvent + export import UserConversion = MsNodeSqlV8.UserConversion + export import NativeReadColumnInfo = MsNodeSqlV8.NativeReadColumnInfo + export import NativeNextResultInfo = MsNodeSqlV8.NativeNextResultInfo + export import NativeReadColumnCb = MsNodeSqlV8.NativeReadColumnCb + export import NativeNextResultCb = MsNodeSqlV8.NativeNextResultCb + export import NativeUnbindCb = MsNodeSqlV8.NativeUnbindCb + export import NativePrepareCb = MsNodeSqlV8.NativePrepareCb + export import NativeQueryCb = MsNodeSqlV8.NativeQueryCb + export import NativeQueryObj = MsNodeSqlV8.NativeQueryObj + export import NativeCustomBinding = MsNodeSqlV8.NativeCustomBinding + export import NativeParam = MsNodeSqlV8.NativeParam + export import NativeConnection = MsNodeSqlV8.NativeConnection + export import SqlClient = MsNodeSqlV8.SqlClient + export default SqlClient } declare module 'msnodesqlv8' { - import { SqlClient } from 'msnodesqlv8/types' - const sql: SqlClient - export = sql + import { SqlClient } from 'msnodesqlv8/types' + const sql: SqlClient + export = sql } diff --git a/lib/pool.js b/lib/pool.js index 40b780e4..1d5523ad 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -102,7 +102,7 @@ const poolModule = (() => { } getQueryId () { - return this.queryObj != null ? this.queryObj : -1 + return this.queryObj ?? -1 } isPendingCancel () { @@ -375,7 +375,7 @@ const poolModule = (() => { if (closed) { return } - grow().then(() => { + void grow().then(() => { promotePause() while (workQueue.length > 0 && idle.length > 0) { const work = workQueue.pop() @@ -688,7 +688,7 @@ const poolModule = (() => { const promisedClose = description.connection.promises.close() toPromise.push(promisedClose) } - Promise.all(toPromise).then(() => { + void Promise.all(toPromise).then(() => { clientPromises.open(options.connectionString).then(conn => { description.recreate(conn) checkin('recreate', description) diff --git a/lib/user.js b/lib/user.js index 35660f8d..dc1cf0b9 100644 --- a/lib/user.js +++ b/lib/user.js @@ -92,8 +92,8 @@ const userModule = ((() => { } parse (s) { - if (!this.parseHHMMSS(s) && !this.parseMMSS(s) && !this.parseSS(s)) { - this.value = s + if (!this.parseHHMMSS(s) && !this.parseMMSS(s) /* && !this.parseSS(s) */) { + this.value = (typeof s === 'string') ? new Date(s) : s } } diff --git a/package-lock.json b/package-lock.json index 22f730e9..3bfd3989 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "msnodesqlv8", - "version": "4.1.2", + "version": "4.2.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "msnodesqlv8", - "version": "4.1.2", + "version": "4.2.0", "hasInstallScript": true, "license": "Apache-2.0", "os": [ @@ -15,34 +15,34 @@ "darwin" ], "dependencies": { - "nan": "^2.18.0", - "node-abi": "^3.51.0", - "prebuild-install": "^7.1.1" + "nan": "^2.19.0", + "node-abi": "^3.60.0", + "prebuild-install": "^7.1.2" }, "devDependencies": { "@types/chai": "^4.3.10", "@types/chai-as-promised": "^7.1.8", - "@types/mocha": "^10.0.4", + "@types/mocha": "^10.0.6", "@types/mochawesome": "^6.2.4", - "@types/node": "^20.9.0", - "@types/sequelize": "^4.28.18", + "@types/node": "^20.12.7", + "@types/sequelize": "^4.28.20", "@typescript-eslint/eslint-plugin": "^6.11.0", "@typescript-eslint/parser": "^6.11.0", "chai": "^4.3.10", "chai-as-promised": "^7.1.1", - "electron": "^27.1.0", + "electron": "^30.0.1", "electron-rebuild": "^3.2.9", "env-cmd": "^10.1.0", "eslint": "^8.53.0", "eslint-config-standard-with-typescript": "^39.1.1", "minimist": "^1.2.8", - "mocha": "^10.2.0", + "mocha": "^10.4.0", "mochawesome": "^7.1.3", - "node-gyp": "^10.0.1", + "node-gyp": "^10.1.0", "nyc": "^15.1.0", - "prebuild": "^12.1.0", - "sequelize": "^6.35.0", - "typescript": "^5.2.2" + "prebuild": "^13.0.0", + "sequelize": "^6.37.3", + "typescript": "^5.4.5" }, "engines": { "node": ">=10" @@ -1154,9 +1154,9 @@ "dev": true }, "node_modules/@types/mocha": { - "version": "10.0.4", - "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-10.0.4.tgz", - "integrity": "sha512-xKU7bUjiFTIttpWaIZ9qvgg+22O1nmbA+HRxdlR+u6TWsGfmFdXrheJoK4fFxrHNVIOBDvDNKZG+LYBpMHpX3w==", + "version": "10.0.6", + "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-10.0.6.tgz", + "integrity": "sha512-dJvrYWxP/UcXm36Qn36fxhUKu8A/xMRXVT2cliFF1Z7UA9liG5Psj3ezNSZw+5puH2czDXRLcXQxf8JbJt0ejg==", "dev": true }, "node_modules/@types/mochawesome": { @@ -1175,9 +1175,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "20.9.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.9.0.tgz", - "integrity": "sha512-nekiGu2NDb1BcVofVcEKMIwzlx4NjHlcjhoxxKBNLtz15Y1z7MYf549DFvkHSId02Ax6kGwWntIBPC3l/JZcmw==", + "version": "20.12.7", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.7.tgz", + "integrity": "sha512-wq0cICSkRLVaf3UGLMGItu/PtdY7oaXaI/RVU+xliKVOtRna3PRY57ZDfztpDL0n11vfymMUnXv8QwYCO7L1wg==", "dev": true, "dependencies": { "undici-types": "~5.26.4" @@ -1199,9 +1199,9 @@ "dev": true }, "node_modules/@types/sequelize": { - "version": "4.28.18", - "resolved": "https://registry.npmjs.org/@types/sequelize/-/sequelize-4.28.18.tgz", - "integrity": "sha512-p9RRutrfuWn5wvzY51+pY8uD4XxhyVvSVTTwdUNJ8j5TUhn19ZRz/pIC8MqSFlv9FRGe5g/vbzeykE4pzVQ2bw==", + "version": "4.28.20", + "resolved": "https://registry.npmjs.org/@types/sequelize/-/sequelize-4.28.20.tgz", + "integrity": "sha512-XaGOKRhdizC87hDgQ0u3btxzbejlF+t6Hhvkek1HyphqCI4y7zVBIVAGmuc4cWJqGpxusZ1RiBToHHnNK/Edlw==", "dev": true, "dependencies": { "@types/bluebird": "*", @@ -1869,12 +1869,12 @@ "dev": true }, "node_modules/axios": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.5.0.tgz", - "integrity": "sha512-D4DdjDo5CY50Qms0qGQTTw6Q44jl7zRwY7bthds06pUGfChBCTcQs+N743eFWGEd6pRTMd6A+I87aWyFV5wiZQ==", + "version": "1.6.8", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.8.tgz", + "integrity": "sha512-v/ZHtJDU39mDpyBoFVkETcd/uNdxrWRrg3bKpOKzXFA6Bvqopts6ALSMU3y6ijYxbw2B+wPrIv46egTzJXCLGQ==", "dev": true, "dependencies": { - "follow-redirects": "^1.15.0", + "follow-redirects": "^1.15.6", "form-data": "^4.0.0", "proxy-from-env": "^1.1.0" } @@ -1894,9 +1894,9 @@ } }, "node_modules/b4a": { - "version": "1.6.4", - "resolved": "https://registry.npmjs.org/b4a/-/b4a-1.6.4.tgz", - "integrity": "sha512-fpWrvyVHEKyeEvbKZTVOeZF3VSKKWtJxFIxX/jaVPf+cLbGUSitjb49pHLqPV2BUNNZ0LcoeEGfE/YCpyDYHIw==", + "version": "1.6.6", + "resolved": "https://registry.npmjs.org/b4a/-/b4a-1.6.6.tgz", + "integrity": "sha512-5Tk1HLk6b6ctmjIkAcU/Ujv/1WqiDl0F0JdRCR80VsOcUlHcu7pWeWRlOqQLHfDEsVx9YH/aif5AG4ehoCtTmg==", "dev": true }, "node_modules/balanced-match": { @@ -1905,6 +1905,13 @@ "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", "dev": true }, + "node_modules/bare-events": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/bare-events/-/bare-events-2.2.2.tgz", + "integrity": "sha512-h7z00dWdG0PYOQEvChhOSWvOfkIKsdZGkWr083FgN/HyoQuebSew/cgirYqh9SCuy/hRvxc5Vy6Fw8xAmYHLkQ==", + "dev": true, + "optional": true + }, "node_modules/base64-js": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", @@ -2527,24 +2534,24 @@ } }, "node_modules/cmake-js": { - "version": "7.2.1", - "resolved": "https://registry.npmjs.org/cmake-js/-/cmake-js-7.2.1.tgz", - "integrity": "sha512-AdPSz9cSIJWdKvm0aJgVu3X8i0U3mNTswJkSHzZISqmYVjZk7Td4oDFg0mCBA383wO+9pG5Ix7pEP1CZH9x2BA==", + "version": "7.3.0", + "resolved": "https://registry.npmjs.org/cmake-js/-/cmake-js-7.3.0.tgz", + "integrity": "sha512-dXs2zq9WxrV87bpJ+WbnGKv8WUBXDw8blNiwNHoRe/it+ptscxhQHKB1SJXa1w+kocLMeP28Tk4/eTCezg4o+w==", "dev": true, "dependencies": { - "axios": "^1.3.2", + "axios": "^1.6.5", "debug": "^4", - "fs-extra": "^10.1.0", + "fs-extra": "^11.2.0", "lodash.isplainobject": "^4.0.6", "memory-stream": "^1.0.0", - "node-api-headers": "^0.0.2", + "node-api-headers": "^1.1.0", "npmlog": "^6.0.2", "rc": "^1.2.7", - "semver": "^7.3.8", - "tar": "^6.1.11", + "semver": "^7.5.4", + "tar": "^6.2.0", "url-join": "^4.0.1", "which": "^2.0.2", - "yargs": "^17.6.0" + "yargs": "^17.7.2" }, "bin": { "cmake-js": "bin/cmake-js" @@ -2581,9 +2588,9 @@ } }, "node_modules/cmake-js/node_modules/fs-extra": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", - "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", + "version": "11.2.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.2.0.tgz", + "integrity": "sha512-PmDi3uwK5nFuXh7XDTlVnS17xJS7vW36is2+w3xcv8SVxiB4NyATf4ctkVY5bkSjX0Y4nbvZCq1/EjtEyr9ktw==", "dev": true, "dependencies": { "graceful-fs": "^4.2.0", @@ -2591,7 +2598,7 @@ "universalify": "^2.0.0" }, "engines": { - "node": ">=12" + "node": ">=14.14" } }, "node_modules/cmake-js/node_modules/gauge": { @@ -2655,9 +2662,9 @@ } }, "node_modules/cmake-js/node_modules/semver": { - "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", + "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", "dev": true, "dependencies": { "lru-cache": "^6.0.0" @@ -2670,9 +2677,9 @@ } }, "node_modules/cmake-js/node_modules/universalify": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", - "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", + "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", "dev": true, "engines": { "node": ">= 10.0.0" @@ -3115,14 +3122,14 @@ } }, "node_modules/electron": { - "version": "27.1.0", - "resolved": "https://registry.npmjs.org/electron/-/electron-27.1.0.tgz", - "integrity": "sha512-XPdJiO475QJ8cx59/goWNNWnlV0vab+Ut3occymos7VDxkHV5mFrlW6tcGi+M3bW6gBfwpJocWMng8tw542vww==", + "version": "30.0.1", + "resolved": "https://registry.npmjs.org/electron/-/electron-30.0.1.tgz", + "integrity": "sha512-iwxkI/n2wBd29NH7TH0ZY8aWGzCoKpzJz+D10u7aGSJi1TV6d4MSM3rWyKvT/UkAHkTKOEgYfUyCa2vWQm8L0g==", "dev": true, "hasInstallScript": true, "dependencies": { "@electron/get": "^2.0.0", - "@types/node": "^18.11.18", + "@types/node": "^20.9.0", "extract-zip": "^2.0.1" }, "bin": { @@ -3596,12 +3603,6 @@ "integrity": "sha512-mfBcbqc0qc6RlxrsIgLG2wCqkiPAjEezHxGTu7p3dHHFOurH4EjS9rFZndX5axC8264rI1Pcbw8uQP39oZckeA==", "dev": true }, - "node_modules/electron/node_modules/@types/node": { - "version": "18.16.5", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.16.5.tgz", - "integrity": "sha512-seOA34WMo9KB+UA78qaJoCO20RJzZGVXQ5Sh6FWu0g/hfT44nKXnej3/tCQl7FL97idFpBhisLYCTB50S0EirA==", - "dev": true - }, "node_modules/emoji-regex": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", @@ -4473,9 +4474,9 @@ "dev": true }, "node_modules/follow-redirects": { - "version": "1.15.3", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.3.tgz", - "integrity": "sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q==", + "version": "1.15.6", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz", + "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==", "dev": true, "funding": [ { @@ -6513,9 +6514,9 @@ "integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==" }, "node_modules/mocha": { - "version": "10.2.0", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.2.0.tgz", - "integrity": "sha512-IDY7fl/BecMwFHzoqF2sg/SHHANeBoMMXFlS9r0OXKDssYE1M5O43wUY/9BVPeIvfH2zmEbBfseqN9gBQZzXkg==", + "version": "10.4.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.4.0.tgz", + "integrity": "sha512-eqhGB8JKapEYcC4ytX/xrzKforgEc3j1pGlAXVy3eRwrtAy5/nIfT1SvgGzfN0XZZxeLq0aQWkOUAmqIJiv+bA==", "dev": true, "dependencies": { "ansi-colors": "4.1.1", @@ -6525,13 +6526,12 @@ "diff": "5.0.0", "escape-string-regexp": "4.0.0", "find-up": "5.0.0", - "glob": "7.2.0", + "glob": "8.1.0", "he": "1.2.0", "js-yaml": "4.1.0", "log-symbols": "4.1.0", "minimatch": "5.0.1", "ms": "2.1.3", - "nanoid": "3.3.3", "serialize-javascript": "6.0.0", "strip-json-comments": "3.1.1", "supports-color": "8.1.1", @@ -6546,10 +6546,6 @@ }, "engines": { "node": ">= 14.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/mochajs" } }, "node_modules/mocha/node_modules/brace-expansion": { @@ -6561,6 +6557,25 @@ "balanced-match": "^1.0.0" } }, + "node_modules/mocha/node_modules/glob": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz", + "integrity": "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^5.0.1", + "once": "^1.3.0" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/mocha/node_modules/minimatch": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz", @@ -6722,21 +6737,9 @@ "dev": true }, "node_modules/nan": { - "version": "2.18.0", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.18.0.tgz", - "integrity": "sha512-W7tfG7vMOGtD30sHoZSSc/JVYiyDPEyQVso/Zz+/uQd0B0L46gtC+pHha5FFMRpil6fm/AoEcRWyOVi4+E/f8w==" - }, - "node_modules/nanoid": { - "version": "3.3.3", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.3.tgz", - "integrity": "sha512-p1sjXuopFs0xg+fPASzQ28agW1oHD7xDsd9Xkf3T15H3c/cifrFHVwrh74PdoklAPi+i7MdRsE47vm2r6JoB+w==", - "dev": true, - "bin": { - "nanoid": "bin/nanoid.cjs" - }, - "engines": { - "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" - } + "version": "2.19.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.19.0.tgz", + "integrity": "sha512-nO1xXxfh/RWNxfd/XPfbIfFk5vgLsAxUR9y5O0cHMJu/AW9U95JLXqthYHjEp+8gQ5p96K9jUp8nbVOxCdRbtw==" }, "node_modules/napi-build-utils": { "version": "1.0.2", @@ -6765,9 +6768,9 @@ "dev": true }, "node_modules/node-abi": { - "version": "3.51.0", - "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.51.0.tgz", - "integrity": "sha512-SQkEP4hmNWjlniS5zdnfIXTk1x7Ome85RDzHlTbBtzE97Gfwz/Ipw4v/Ryk20DWIy3yCNVLVlGKApCnmvYoJbA==", + "version": "3.60.0", + "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.60.0.tgz", + "integrity": "sha512-zcGgwoXbzw9NczqbGzAWL/ToDYAxv1V8gL1D67ClbdkIfeeDBbY0GelZtC25ayLvVjr2q2cloHeQV1R0QAWqRQ==", "dependencies": { "semver": "^7.3.5" }, @@ -6796,9 +6799,9 @@ "dev": true }, "node_modules/node-api-headers": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/node-api-headers/-/node-api-headers-0.0.2.tgz", - "integrity": "sha512-YsjmaKGPDkmhoNKIpkChtCsPVaRE0a274IdERKnuc/E8K1UJdBZ4/mvI006OijlQZHCfpRNOH3dfHQs92se8gg==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/node-api-headers/-/node-api-headers-1.1.0.tgz", + "integrity": "sha512-ucQW+SbYCUPfprvmzBsnjT034IGRB2XK8rRc78BgjNKhTdFKgAwAmgW704bKIBmcYW48it0Gkjpkd39Azrwquw==", "dev": true }, "node_modules/node-api-version": { @@ -6826,9 +6829,9 @@ } }, "node_modules/node-gyp": { - "version": "10.0.1", - "resolved": "https://registry.npmjs.org/node-gyp/-/node-gyp-10.0.1.tgz", - "integrity": "sha512-gg3/bHehQfZivQVfqIyy8wTdSymF9yTyP4CJifK73imyNMU8AIGQE2pUa7dNWfmMeG9cDVF2eehiRMv0LC1iAg==", + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/node-gyp/-/node-gyp-10.1.0.tgz", + "integrity": "sha512-B4J5M1cABxPc5PwfjhbV5hoy2DP9p8lFXASnEN6hugXOa61416tnTZ29x9sSwAd0o99XNIcpvDDy1swAExsVKA==", "dev": true, "dependencies": { "env-paths": "^2.2.0", @@ -8008,12 +8011,12 @@ "peer": true }, "node_modules/path-scurry": { - "version": "1.10.1", - "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.10.1.tgz", - "integrity": "sha512-MkhCqzzBEpPvxxQ71Md0b1Kk51W01lrYvlMzSUaIzNsODdd7mqhiimSZlr+VegAz5Z6Vzt9Xg2ttE//XBhH3EQ==", + "version": "1.10.2", + "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.10.2.tgz", + "integrity": "sha512-7xTavNy5RQXnsjANvVvMkEjvloOinkAjv/Z6Ildz9v2RinZ4SBKTWFOVRbaF8p0vpHnyjV/UwNDdKuUv6M5qcA==", "dev": true, "dependencies": { - "lru-cache": "^9.1.1 || ^10.0.0", + "lru-cache": "^10.2.0", "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0" }, "engines": { @@ -8024,13 +8027,10 @@ } }, "node_modules/path-scurry/node_modules/lru-cache": { - "version": "10.0.2", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.0.2.tgz", - "integrity": "sha512-Yj9mA8fPiVgOUpByoTZO5pNrcl5Yk37FcSHsUINpAsaBIEZIuqcCclDZJCVxqQShDsmYX8QG63svJiTbOATZwg==", + "version": "10.2.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.2.0.tgz", + "integrity": "sha512-2bIM8x+VAf6JT4bKAljS1qUWgMsqZRPGJS6FSahIMPVvctcNhyVp7AJu7quxOW9jwkryBReKZY5tY5JYv2n/7Q==", "dev": true, - "dependencies": { - "semver": "^7.3.5" - }, "engines": { "node": "14 || >=16.14" } @@ -8044,33 +8044,6 @@ "node": ">=16 || 14 >=14.17" } }, - "node_modules/path-scurry/node_modules/semver": { - "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", - "dev": true, - "dependencies": { - "lru-cache": "^6.0.0" - }, - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/path-scurry/node_modules/semver/node_modules/lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dev": true, - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/path-type": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", @@ -8199,22 +8172,22 @@ } }, "node_modules/prebuild": { - "version": "12.1.0", - "resolved": "https://registry.npmjs.org/prebuild/-/prebuild-12.1.0.tgz", - "integrity": "sha512-7VxOp28zmb68lVMAqNMYr8jyIIHdRp52MSki01jAsdgDlnQYsVNhRpC9nHoax2wVhV/fnbyUUb1u57qUjrbbEg==", + "version": "13.0.0", + "resolved": "https://registry.npmjs.org/prebuild/-/prebuild-13.0.0.tgz", + "integrity": "sha512-KCcbv2keUKwcBxyRUdNNyk/iEInTTR6cDXfPCKy0ESz5l4KRe/q7vNzy5MmIb1ELDQQNCO5YfChHqTLOt/x8Eg==", "dev": true, "dependencies": { - "cmake-js": "^7.2.1", + "cmake-js": "^7.3.0", "detect-libc": "^2.0.2", "each-series-async": "^1.0.1", "execspawn": "^1.0.1", "ghreleases": "^3.0.2", "github-from-package": "0.0.0", - "glob": "^7.2.3", + "glob": "^10.3.10", "minimist": "^1.2.8", "napi-build-utils": "^1.0.2", - "node-abi": "^3.47.0", - "node-gyp": "^9.4.0", + "node-abi": "^3.54.0", + "node-gyp": "^10.0.1", "node-ninja": "^1.0.2", "noop-logger": "^0.1.1", "npm-which": "^3.0.1", @@ -8222,19 +8195,19 @@ "nw-gyp": "^3.6.6", "rc": "^1.2.8", "run-waterfall": "^1.1.7", - "tar-stream": "^3.1.6" + "tar-stream": "^3.1.7" }, "bin": { "prebuild": "bin.js" }, "engines": { - "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + "node": "^16.14.0 || >=18.0.0" } }, "node_modules/prebuild-install": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-7.1.1.tgz", - "integrity": "sha512-jAXscXWMcCK8GgCoHOfIr0ODh5ai8mj63L2nWrjuAgXE6tDyYGnx4/8o/rCgU+B4JSyZBKbeZqzhtwtC3ovxjw==", + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-7.1.2.tgz", + "integrity": "sha512-UnNke3IQb6sgarcZIDU3gbMeTp/9SSU1DAIkil7PrqG1vZlBtY5msYccSKSHDqa3hNg436IXK+SNImReuA1wEQ==", "dependencies": { "detect-libc": "^2.0.0", "expand-template": "^2.0.3", @@ -8256,44 +8229,6 @@ "node": ">=10" } }, - "node_modules/prebuild/node_modules/@npmcli/fs": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/@npmcli/fs/-/fs-2.1.2.tgz", - "integrity": "sha512-yOJKRvohFOaLqipNtwYB9WugyZKhC/DZC4VYPmpaCzDBrA8YpK3qHZ8/HGscMnE4GqbkLNuVcCnxkeQEdGt6LQ==", - "dev": true, - "dependencies": { - "@gar/promisify": "^1.1.3", - "semver": "^7.3.5" - }, - "engines": { - "node": "^12.13.0 || ^14.15.0 || >=16.0.0" - } - }, - "node_modules/prebuild/node_modules/agent-base": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", - "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", - "dev": true, - "dependencies": { - "debug": "4" - }, - "engines": { - "node": ">= 6.0.0" - } - }, - "node_modules/prebuild/node_modules/are-we-there-yet": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-3.0.1.tgz", - "integrity": "sha512-QZW4EDmGwlYur0Yyf/b2uGucHQMa8aFUP7eu9ddR73vvhFyt4V0Vl3QHPcTNJ8l6qYOBdxgXdnBXQrHilfRQBg==", - "dev": true, - "dependencies": { - "delegates": "^1.0.0", - "readable-stream": "^3.6.0" - }, - "engines": { - "node": "^12.13.0 || ^14.15.0 || >=16.0.0" - } - }, "node_modules/prebuild/node_modules/brace-expansion": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", @@ -8303,335 +8238,84 @@ "balanced-match": "^1.0.0" } }, - "node_modules/prebuild/node_modules/cacache": { - "version": "16.1.3", - "resolved": "https://registry.npmjs.org/cacache/-/cacache-16.1.3.tgz", - "integrity": "sha512-/+Emcj9DAXxX4cwlLmRI9c166RuL3w30zp4R7Joiv2cQTtTtA+jeuCAjH3ZlGnYS3tKENSrKhAzVVP9GVyzeYQ==", - "dev": true, - "dependencies": { - "@npmcli/fs": "^2.1.0", - "@npmcli/move-file": "^2.0.0", - "chownr": "^2.0.0", - "fs-minipass": "^2.1.0", - "glob": "^8.0.1", - "infer-owner": "^1.0.4", - "lru-cache": "^7.7.1", - "minipass": "^3.1.6", - "minipass-collect": "^1.0.2", - "minipass-flush": "^1.0.5", - "minipass-pipeline": "^1.2.4", - "mkdirp": "^1.0.4", - "p-map": "^4.0.0", - "promise-inflight": "^1.0.1", - "rimraf": "^3.0.2", - "ssri": "^9.0.0", - "tar": "^6.1.11", - "unique-filename": "^2.0.0" - }, - "engines": { - "node": "^12.13.0 || ^14.15.0 || >=16.0.0" - } - }, - "node_modules/prebuild/node_modules/cacache/node_modules/glob": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz", - "integrity": "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==", + "node_modules/prebuild/node_modules/foreground-child": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.1.1.tgz", + "integrity": "sha512-TMKDUnIte6bfb5nWv7V/caI169OHgvwjb7V4WkeUvbQQdjr5rWKqHFiKWb/fcOwB+CzBT+qbWjvj+DVwRskpIg==", "dev": true, "dependencies": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^5.0.1", - "once": "^1.3.0" + "cross-spawn": "^7.0.0", + "signal-exit": "^4.0.1" }, "engines": { - "node": ">=12" + "node": ">=14" }, "funding": { "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/prebuild/node_modules/cacache/node_modules/lru-cache": { - "version": "7.18.3", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.18.3.tgz", - "integrity": "sha512-jumlc0BIUrS3qJGgIkWZsyfAM7NCWiBcCDhnd+3NNM5KbBmLTgHVfWBcg6W+rLUsIpzpERPsvwUP7CckAQSOoA==", - "dev": true, - "engines": { - "node": ">=12" - } - }, - "node_modules/prebuild/node_modules/cacache/node_modules/minimatch": { - "version": "5.1.6", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", - "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", - "dev": true, - "dependencies": { - "brace-expansion": "^2.0.1" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/prebuild/node_modules/gauge": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/gauge/-/gauge-4.0.4.tgz", - "integrity": "sha512-f9m+BEN5jkg6a0fZjleidjN51VE1X+mPFQ2DJ0uv1V39oCLCbsGe6yjbBnp7eK7z/+GAon99a3nHuqbuuthyPg==", - "dev": true, - "dependencies": { - "aproba": "^1.0.3 || ^2.0.0", - "color-support": "^1.1.3", - "console-control-strings": "^1.1.0", - "has-unicode": "^2.0.1", - "signal-exit": "^3.0.7", - "string-width": "^4.2.3", - "strip-ansi": "^6.0.1", - "wide-align": "^1.1.5" - }, - "engines": { - "node": "^12.13.0 || ^14.15.0 || >=16.0.0" - } - }, "node_modules/prebuild/node_modules/glob": { - "version": "7.2.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", - "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", - "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": "*" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/prebuild/node_modules/http-proxy-agent": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-5.0.0.tgz", - "integrity": "sha512-n2hY8YdoRE1i7r6M0w9DIw5GgZN0G25P8zLCRQ8rjXtTU3vsNFBI/vWK/UIeE6g5MUUz6avwAPXmL6Fy9D/90w==", + "version": "10.3.12", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.3.12.tgz", + "integrity": "sha512-TCNv8vJ+xz4QiqTpfOJA7HvYv+tNIRHKfUWw/q+v2jdgN4ebz+KY9tGx5J4rHP0o84mNP+ApH66HRX8us3Khqg==", "dev": true, "dependencies": { - "@tootallnate/once": "2", - "agent-base": "6", - "debug": "4" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/prebuild/node_modules/https-proxy-agent": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", - "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==", - "dev": true, - "dependencies": { - "agent-base": "6", - "debug": "4" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/prebuild/node_modules/make-fetch-happen": { - "version": "10.2.1", - "resolved": "https://registry.npmjs.org/make-fetch-happen/-/make-fetch-happen-10.2.1.tgz", - "integrity": "sha512-NgOPbRiaQM10DYXvN3/hhGVI2M5MtITFryzBGxHM5p4wnFxsVCbxkrBrDsk+EZ5OB4jEOT7AjDxtdF+KVEFT7w==", - "dev": true, - "dependencies": { - "agentkeepalive": "^4.2.1", - "cacache": "^16.1.0", - "http-cache-semantics": "^4.1.0", - "http-proxy-agent": "^5.0.0", - "https-proxy-agent": "^5.0.0", - "is-lambda": "^1.0.1", - "lru-cache": "^7.7.1", - "minipass": "^3.1.6", - "minipass-collect": "^1.0.2", - "minipass-fetch": "^2.0.3", - "minipass-flush": "^1.0.5", - "minipass-pipeline": "^1.2.4", - "negotiator": "^0.6.3", - "promise-retry": "^2.0.1", - "socks-proxy-agent": "^7.0.0", - "ssri": "^9.0.0" - }, - "engines": { - "node": "^12.13.0 || ^14.15.0 || >=16.0.0" - } - }, - "node_modules/prebuild/node_modules/make-fetch-happen/node_modules/lru-cache": { - "version": "7.18.3", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.18.3.tgz", - "integrity": "sha512-jumlc0BIUrS3qJGgIkWZsyfAM7NCWiBcCDhnd+3NNM5KbBmLTgHVfWBcg6W+rLUsIpzpERPsvwUP7CckAQSOoA==", - "dev": true, - "engines": { - "node": ">=12" - } - }, - "node_modules/prebuild/node_modules/minipass-fetch": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/minipass-fetch/-/minipass-fetch-2.1.2.tgz", - "integrity": "sha512-LT49Zi2/WMROHYoqGgdlQIZh8mLPZmOrN2NdJjMXxYe4nkN6FUyuPuOAOedNJDrx0IRGg9+4guZewtp8hE6TxA==", - "dev": true, - "dependencies": { - "minipass": "^3.1.6", - "minipass-sized": "^1.0.3", - "minizlib": "^2.1.2" - }, - "engines": { - "node": "^12.13.0 || ^14.15.0 || >=16.0.0" - }, - "optionalDependencies": { - "encoding": "^0.1.13" - } - }, - "node_modules/prebuild/node_modules/mkdirp": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", - "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", - "dev": true, - "bin": { - "mkdirp": "bin/cmd.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/prebuild/node_modules/node-gyp": { - "version": "9.4.1", - "resolved": "https://registry.npmjs.org/node-gyp/-/node-gyp-9.4.1.tgz", - "integrity": "sha512-OQkWKbjQKbGkMf/xqI1jjy3oCTgMKJac58G2+bjZb3fza6gW2YrCSdMQYaoTb70crvE//Gngr4f0AgVHmqHvBQ==", - "dev": true, - "dependencies": { - "env-paths": "^2.2.0", - "exponential-backoff": "^3.1.1", - "glob": "^7.1.4", - "graceful-fs": "^4.2.6", - "make-fetch-happen": "^10.0.3", - "nopt": "^6.0.0", - "npmlog": "^6.0.0", - "rimraf": "^3.0.2", - "semver": "^7.3.5", - "tar": "^6.1.2", - "which": "^2.0.2" + "foreground-child": "^3.1.0", + "jackspeak": "^2.3.6", + "minimatch": "^9.0.1", + "minipass": "^7.0.4", + "path-scurry": "^1.10.2" }, "bin": { - "node-gyp": "bin/node-gyp.js" - }, - "engines": { - "node": "^12.13 || ^14.13 || >=16" - } - }, - "node_modules/prebuild/node_modules/node-gyp/node_modules/npmlog": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-6.0.2.tgz", - "integrity": "sha512-/vBvz5Jfr9dT/aFWd0FIRf+T/Q2WBsLENygUaFUqstqsycmZAP/t5BvFJTK0viFmSUxiUKTUplWy5vt+rvKIxg==", - "dev": true, - "dependencies": { - "are-we-there-yet": "^3.0.0", - "console-control-strings": "^1.1.0", - "gauge": "^4.0.3", - "set-blocking": "^2.0.0" + "glob": "dist/esm/bin.mjs" }, "engines": { - "node": "^12.13.0 || ^14.15.0 || >=16.0.0" - } - }, - "node_modules/prebuild/node_modules/nopt": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/nopt/-/nopt-6.0.0.tgz", - "integrity": "sha512-ZwLpbTgdhuZUnZzjd7nb1ZV+4DoiC6/sfiVKok72ym/4Tlf+DFdlHYmT2JPmcNNWV6Pi3SDf1kT+A4r9RTuT9g==", - "dev": true, - "dependencies": { - "abbrev": "^1.0.0" - }, - "bin": { - "nopt": "bin/nopt.js" + "node": ">=16 || 14 >=14.17" }, - "engines": { - "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + "funding": { + "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/prebuild/node_modules/readable-stream": { - "version": "3.6.2", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", - "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", + "node_modules/prebuild/node_modules/minimatch": { + "version": "9.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.4.tgz", + "integrity": "sha512-KqWh+VchfxcMNRAJjj2tnsSJdNbHsVgnkBhTNrW7AjVo6OvLtxw8zfT9oLw1JSohlFzJ8jCoTgaoXvJ+kHt6fw==", "dev": true, "dependencies": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" + "brace-expansion": "^2.0.1" }, "engines": { - "node": ">= 6" - } - }, - "node_modules/prebuild/node_modules/rimraf": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", - "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", - "dev": true, - "dependencies": { - "glob": "^7.1.3" - }, - "bin": { - "rimraf": "bin.js" + "node": ">=16 || 14 >=14.17" }, "funding": { "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/prebuild/node_modules/semver": { - "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "node_modules/prebuild/node_modules/minipass": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.0.4.tgz", + "integrity": "sha512-jYofLM5Dam9279rdkWzqHozUo4ybjdZmCsDHePy5V/PbBcVMiSZR97gmAy45aqi8CK1lG2ECd356FU86avfwUQ==", "dev": true, - "dependencies": { - "lru-cache": "^6.0.0" - }, - "bin": { - "semver": "bin/semver.js" - }, "engines": { - "node": ">=10" + "node": ">=16 || 14 >=14.17" } }, - "node_modules/prebuild/node_modules/socks-proxy-agent": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-7.0.0.tgz", - "integrity": "sha512-Fgl0YPZ902wEsAyiQ+idGd1A7rSFx/ayC1CQVMw5P+EQx2V0SgpGtf6OKFhVjPflPUl9YMmEOnmfjCdMUsygww==", + "node_modules/prebuild/node_modules/signal-exit": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", "dev": true, - "dependencies": { - "agent-base": "^6.0.2", - "debug": "^4.3.3", - "socks": "^2.6.2" - }, "engines": { - "node": ">= 10" - } - }, - "node_modules/prebuild/node_modules/ssri": { - "version": "9.0.1", - "resolved": "https://registry.npmjs.org/ssri/-/ssri-9.0.1.tgz", - "integrity": "sha512-o57Wcn66jMQvfHG1FlYbWeZWW/dHZhJXjpIcTfXldXEk5nz5lStPo3mK0OJQfGR3RbZUlbISexbljkJzuEj/8Q==", - "dev": true, - "dependencies": { - "minipass": "^3.1.1" + "node": ">=14" }, - "engines": { - "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + "funding": { + "url": "https://github.com/sponsors/isaacs" } }, "node_modules/prebuild/node_modules/tar-stream": { - "version": "3.1.6", - "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-3.1.6.tgz", - "integrity": "sha512-B/UyjYwPpMBv+PaFSWAmtYjwdrlEaZQEhMIBFNC5oEG8lpiW8XjcSdmEaClj28ArfKScKHs2nshz3k2le6crsg==", + "version": "3.1.7", + "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-3.1.7.tgz", + "integrity": "sha512-qJj60CXt7IU1Ffyc3NJMjh6EkuCFej46zUqJ4J7pqYlThyd9bO0XBTmcOIhSzZJVWfsLks0+nle/j538YAW9RQ==", "dev": true, "dependencies": { "b4a": "^1.6.4", @@ -8639,30 +8323,6 @@ "streamx": "^2.15.0" } }, - "node_modules/prebuild/node_modules/unique-filename": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/unique-filename/-/unique-filename-2.0.1.tgz", - "integrity": "sha512-ODWHtkkdx3IAR+veKxFV+VBkUMcN+FaqzUUd7IZzt+0zhDZFPFxhlqwPF3YQvMHx1TD0tdgYl+kuPnJ8E6ql7A==", - "dev": true, - "dependencies": { - "unique-slug": "^3.0.0" - }, - "engines": { - "node": "^12.13.0 || ^14.15.0 || >=16.0.0" - } - }, - "node_modules/prebuild/node_modules/unique-slug": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/unique-slug/-/unique-slug-3.0.0.tgz", - "integrity": "sha512-8EyMynh679x/0gqE9fT9oilG+qEt+ibFyqjuVTsZn1+CMxH+XLlpvr2UZx4nVcCwTpx81nICr2JQFkM+HPLq4w==", - "dev": true, - "dependencies": { - "imurmurhash": "^0.1.4" - }, - "engines": { - "node": "^12.13.0 || ^14.15.0 || >=16.0.0" - } - }, "node_modules/prelude-ls": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", @@ -9200,9 +8860,9 @@ "optional": true }, "node_modules/sequelize": { - "version": "6.35.0", - "resolved": "https://registry.npmjs.org/sequelize/-/sequelize-6.35.0.tgz", - "integrity": "sha512-cnxnmjUfphGfSKCwTtNZ3YD/F35fqMTNPw/Qe9xsMij49t6LkW2G57sNQkuKac8fkQgSX+M8OZOQsxCS6dnUwQ==", + "version": "6.37.3", + "resolved": "https://registry.npmjs.org/sequelize/-/sequelize-6.37.3.tgz", + "integrity": "sha512-V2FTqYpdZjPy3VQrZvjTPnOoLm0KudCRXfGWp48QwhyPPp2yW8z0p0sCYZd/em847Tl2dVxJJ1DR+hF+O77T7A==", "dev": true, "funding": [ { @@ -9567,13 +9227,16 @@ } }, "node_modules/streamx": { - "version": "2.15.1", - "resolved": "https://registry.npmjs.org/streamx/-/streamx-2.15.1.tgz", - "integrity": "sha512-fQMzy2O/Q47rgwErk/eGeLu/roaFWV0jVsogDmrszM9uIw8L5OA+t+V93MgYlufNptfjmYR1tOMWhei/Eh7TQA==", + "version": "2.16.1", + "resolved": "https://registry.npmjs.org/streamx/-/streamx-2.16.1.tgz", + "integrity": "sha512-m9QYj6WygWyWa3H1YY69amr4nVgy61xfjys7xO7kviL5rfIEc2naf+ewFiOA+aEJD7y0JO3h2GoiUv4TDwEGzQ==", "dev": true, "dependencies": { "fast-fifo": "^1.1.0", "queue-tick": "^1.0.1" + }, + "optionalDependencies": { + "bare-events": "^2.2.0" } }, "node_modules/string_decoder": { @@ -9749,20 +9412,20 @@ } }, "node_modules/tar": { - "version": "6.1.11", - "resolved": "https://registry.npmjs.org/tar/-/tar-6.1.11.tgz", - "integrity": "sha512-an/KZQzQUkZCkuoAA64hM92X0Urb6VpRhAFllDzz44U2mcD5scmT3zBc4VgVpkugF580+DQn8eAFSyoQt0tznA==", + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/tar/-/tar-6.2.1.tgz", + "integrity": "sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==", "dev": true, "dependencies": { "chownr": "^2.0.0", "fs-minipass": "^2.0.0", - "minipass": "^3.0.0", + "minipass": "^5.0.0", "minizlib": "^2.1.1", "mkdirp": "^1.0.3", "yallist": "^4.0.0" }, "engines": { - "node": ">= 10" + "node": ">=10" } }, "node_modules/tar-fs": { @@ -9809,6 +9472,15 @@ "node": ">= 6" } }, + "node_modules/tar/node_modules/minipass": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-5.0.0.tgz", + "integrity": "sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/tar/node_modules/mkdirp": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", @@ -10091,9 +9763,9 @@ } }, "node_modules/typescript": { - "version": "5.2.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz", - "integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==", + "version": "5.4.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.5.tgz", + "integrity": "sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==", "dev": true, "bin": { "tsc": "bin/tsc", diff --git a/package.json b/package.json index 8ae8c088..84713242 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "name": "Stephen James" } ], - "version": "4.1.2", + "version": "4.2.0", "keywords": [ "sql", "prepared", @@ -61,30 +61,30 @@ } }, "dependencies": { - "nan": "^2.18.0", - "node-abi": "^3.51.0", - "prebuild-install": "^7.1.1" + "nan": "^2.19.0", + "node-abi": "^3.60.0", + "prebuild-install": "^7.1.2" }, "devDependencies": { "@types/chai": "^4.3.10", "@types/chai-as-promised": "^7.1.8", - "@types/mocha": "^10.0.4", + "@types/mocha": "^10.0.6", "@types/mochawesome": "^6.2.4", - "@types/node": "^20.9.0", - "@types/sequelize": "^4.28.18", + "@types/node": "^20.12.7", + "@types/sequelize": "^4.28.20", "chai": "^4.3.10", "chai-as-promised": "^7.1.1", - "electron": "^27.1.0", + "electron": "^30.0.1", "electron-rebuild": "^3.2.9", "env-cmd": "^10.1.0", "minimist": "^1.2.8", - "mocha": "^10.2.0", + "mocha": "^10.4.0", "mochawesome": "^7.1.3", - "node-gyp": "^10.0.1", + "node-gyp": "^10.1.0", "nyc": "^15.1.0", - "prebuild": "^12.1.0", - "sequelize": "^6.35.0", - "typescript": "^5.2.2", + "prebuild": "^13.0.0", + "sequelize": "^6.37.3", + "typescript": "^5.4.5", "@typescript-eslint/eslint-plugin": "^6.11.0", "@typescript-eslint/parser": "^6.11.0", "eslint": "^8.53.0", @@ -103,8 +103,8 @@ "prebuild-all": "npm run prebuild-node && npm run prebuild-node-ia32 && npm run prebuild-electron && npm run prebuild-electron-ia32", "prebuild-node": "prebuild -t 10.16.0 -t 11.15.0 -t 12.18.3 -t 13.14.0 -t 14.14.0 -t 15.11.0 -t 16.13.0 -t 17.0.1 -t 18.7.0 -t 19.2.0 -t 20.0.0 -t 21.0.0 --strip ", "prebuild-node-ia32": "prebuild -t 10.16.0 -t 11.15.0 -t 12.18.3 -t 13.14.0 -t 14.14.0 -t 15.11.0 -t 16.13.0 -t 17.0.1 -t 18.7.0 -t 19.2.0 -t 20.0.0 -t 21.0.0 -a ia32 --strip", - "prebuild-electron": "prebuild -t 6.1.9 -t 7.2.1 -t 8.2.3 -t 9.0.5 -t 10.1.4 -t 11.3.0 -t 12.0.0 -t 13.0.0 -t 14.0.0 -t 14.2.5 -t 15.0.0 -t 16.0.1 -t 17.0.0 -t 18.1.0 -t 19.0.10 -t 20.3.0 -t 21.3.1 -t 22.0.0 -t 23.0.0 -t 24.0.0 -t 25.1.0 -t 26.0.0 -r electron -t 27.0.0 --strip", - "prebuild-electron-ia32": "prebuild -t 6.1.9 -t 7.2.1 -t 8.2.3 -t 9.0.5 -t 10.1.4 -t 11.3.0 -t 12.0.0 -t 13.0.0 -t 14.0.0 -t 14.2.5 -t 15.0.0 -t 16.0.1 -t 17.0.0 -t 18.1.0 -t 19.0.10 -t 20.3.0 -t 21.3.1 -t 22.0.0 -t 23.0.0 -t 24.0.0 -t 25.1.0 -t 26.0.0 -t 27.0.0 -r electron -a ia32 --strip", + "prebuild-electron": "prebuild -t 6.1.9 -t 7.2.1 -t 8.2.3 -t 9.0.5 -t 10.1.4 -t 11.3.0 -t 12.0.0 -t 13.0.0 -t 14.0.0 -t 14.2.5 -t 15.0.0 -t 16.0.1 -t 17.0.0 -t 18.1.0 -t 19.0.10 -t 20.3.0 -t 21.3.1 -t 22.0.0 -t 23.0.0 -t 24.0.0 -t 25.1.0 -t 26.0.0 -t 27.0.0 -t 29.0.0 -t 30.0.0 -r electron --strip", + "prebuild-electron-ia32": "prebuild -t 6.1.9 -t 7.2.1 -t 8.2.3 -t 9.0.5 -t 10.1.4 -t 11.3.0 -t 12.0.0 -t 13.0.0 -t 14.0.0 -t 14.2.5 -t 15.0.0 -t 16.0.1 -t 17.0.0 -t 18.1.0 -t 19.0.10 -t 20.3.0 -t 21.3.1 -t 22.0.0 -t 23.0.0 -t 24.0.0 -t 25.1.0 -t 26.0.0 -t 27.0.0 -t 29.0.0 -t 30.0.0 -r electron -a ia32 --strip", "test": "nyc --reporter=html --reporter=text mocha --reporter mochawesome --require mochawesome/register", "bench-comments": "node dist/test/env/cmd-test.js -t benchmark --repeats=5 --delay=4500 2>&1", "bench-columns": "node dist/test/env/cmd-test.js -t benchmark --table=syscolumns --repeats=5 --delay=5000 2>&1", diff --git a/tsconfig.json b/tsconfig.json index a3d95be5..6d8e5f4e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,6 +13,7 @@ "inlineSources": true, "pretty": true, "strictNullChecks": true, + "forceConsistentCasingInFileNames": true, "outDir": "./dist" }, "compileOnSave": true,