primer cambio

This commit is contained in:
beseira13
2026-01-19 12:12:38 -03:00
parent 5f59dba52d
commit 44990f015a
4759 changed files with 588702 additions and 0 deletions

152
node_modules/promise-mysql/lib/connection.js generated vendored Normal file
View File

@@ -0,0 +1,152 @@
'use strict';
const Promise = require(`bluebird`);
const mysql = require(`mysql`);
const promiseCallback = require(`./helper`).promiseCallback;
class connection {
constructor(config = {}, _connection) {
let mysqlValue = mysql;
let mysqlWrapperCallbackPromise;
if (typeof config !== 'string') {
if (config.mysqlWrapper) {
let callback;
mysqlWrapperCallbackPromise = new Promise((resolve, reject) => {
callback = (err, mysql) => {
if (err) {
return reject(err);
}
return resolve(mysql);
}
})
mysqlValue = config.mysqlWrapper(mysql, callback);
config.mysqlWrapper = undefined;
}
if (config.returnArgumentsArray) {
this.returnArgumentsArray = config.returnArgumentsArray;
config.returnArgumentsArray = undefined;
}
if (config.reconnect === true || config.reconnect === undefined) {
this.reconnect = true;
config.reconnect = undefined;
}
}
this.config = config;
return Promise.resolve(mysqlValue || mysqlWrapperCallbackPromise).then((mysql) => {
if (_connection && this.reconnect) {
addReconnectHandler(_connection, mysql, this.config, this.reconnect);
} else if (!_connection) {
_connection = connect(mysql, this.config, this.reconnect);
}
return _connection;
}).then((connection) => {
this.connection = connection;
return this;
})
}
query() {
return promiseCallback.apply(this.connection, [`query`, arguments, this.returnArgumentsArray]);
}
queryStream(sql, values) {
return this.connection.query(sql, values);
};
beginTransaction() {
return promiseCallback.apply(this.connection, [`beginTransaction`, arguments, this.returnArgumentsArray]);
}
commit() {
return promiseCallback.apply(this.connection, [`commit`, arguments, this.returnArgumentsArray]);
}
rollback() {
return promiseCallback.apply(this.connection, [`rollback`, arguments, this.returnArgumentsArray]);
}
changeUser() {
return promiseCallback.apply(this.connection, [`changeUser`, arguments, this.returnArgumentsArray]);
}
ping() {
return promiseCallback.apply(this.connection, [`ping`, arguments, this.returnArgumentsArray]);
}
statistics() {
return promiseCallback.apply(this.connection, [`statistics`, arguments, this.returnArgumentsArray]);
}
end() {
return promiseCallback.apply(this.connection, [`end`, arguments, this.returnArgumentsArray]);
}
destroy() {
this.connection.destroy();
}
pause() {
this.connection.pause();
}
resume() {
this.connection.resume();
}
escape(value) {
return this.connection.escape(value);
}
escapeId(value) {
return this.connection.escapeId(value);
}
format(sql, values) {
return this.connection.format(sql, values);
}
on(event, fn) {
this.connection.on(event, fn);
}
}
const connect = (mysql, config, reconnect) => {
const connection = mysql.createConnection(config);
return new Promise((resolve, reject) => {
connection.connect((err) => {
if (err) {
return reject(err);
} else {
if (reconnect) {
addReconnectHandler(connection, mysql, config, reconnect);
}
return resolve(connection);
}
})
});
}
const addReconnectHandler = (connection, mysql, config, reconnect) => {
connection.once(`error`, (err) => {
if(
err.code === `PROTOCOL_CONNECTION_LOST` ||
err.code === `ECONNRESET` ||
err.code === `PROTOCOL_ENQUEUE_AFTER_FATAL_ERROR`
) {
connect(mysql, config, reconnect);
}
});
}
module.exports = connection;

29
node_modules/promise-mysql/lib/helper.js generated vendored Normal file
View File

@@ -0,0 +1,29 @@
'use strict';
const Promise = require('bluebird');
module.exports = {
promiseCallback: function(functionName, params, returnArgumentsArray = false) {
params = Array.prototype.slice.call(params, 0);
return new Promise((resolve, reject) => {
params.push(function(err) {
const args = Array.prototype.slice.call(arguments, 1);
if (err) {
return reject(err);
}
process.nextTick(() => {
if (returnArgumentsArray) {
args.push(call);
return resolve(args)
}
return resolve(args[0]);
})
});
const call = this[functionName].apply(this, params);
});
}
};

77
node_modules/promise-mysql/lib/pool.js generated vendored Normal file
View File

@@ -0,0 +1,77 @@
'use strict';
const Promise = require('bluebird');
const mysql = require('mysql');
const PoolConnection = require('./poolConnection.js');
const promiseCallback = require('./helper').promiseCallback;
class pool {
constructor(config = {}, _pool) {
if (_pool) {
this.pool = _pool;
return this;
}
let mysqlValue = mysql;
let mysqlWrapperCallbackPromise;
if (config.mysqlWrapper) {
let callback;
mysqlWrapperCallbackPromise = new Promise((resolve, reject) => {
callback = (err, mysql) => {
if (err) {
return reject(err);
}
return resolve(mysql);
}
})
mysqlValue = config.mysqlWrapper(mysql, callback);
delete config.mysqlWrapper;
}
if (config.returnArgumentsArray) {
this.returnArgumentsArray = config.returnArgumentsArray;
config.returnArgumentsArray = undefined;
}
return Promise.resolve(mysqlValue || mysqlWrapperCallbackPromise).then((mysql) => {
this.pool = mysql.createPool(config);
return Promise.resolve(this);
});
}
getConnection() {
return promiseCallback.apply(this.pool, ['getConnection', arguments])
.then((_connection) => {
const config = {
returnArgumentsArray: this.returnArgumentsArray,
reconnect: false
};
return new PoolConnection(config, _connection);
});
}
query() {
return promiseCallback.apply(this.pool, ['query', arguments, this.returnArgumentsArray]);
}
end() {
return promiseCallback.apply(this.pool, ['end', arguments, this.returnArgumentsArray]);
}
escape(value) {
return this.pool.escape(value);
}
escapeId(value) {
return this.pool.escapeId(value);
}
on(event, fn) {
this.pool.on(event, fn);
}
}
module.exports = pool;

55
node_modules/promise-mysql/lib/poolCluster.js generated vendored Normal file
View File

@@ -0,0 +1,55 @@
'use strict';
const Promise = require('bluebird');
const mysql = require('mysql');
const Pool = require('./pool');
const PoolConnection = require('./poolConnection.js');
const promiseCallback = require('./helper').promiseCallback;
class poolCluster {
constructor(config = {}) {
if (config.returnArgumentsArray) {
this.returnArgumentsArray = config.returnArgumentsArray;
config.returnArgumentsArray = undefined;
}
return Promise.resolve(mysql).then((mysql) => {
this.poolCluster = mysql.createPoolCluster(config);
return Promise.resolve(this);
});
}
add(id, config) {
return this.poolCluster.add(id, config);
}
end() {
return promiseCallback.apply(this.poolCluster, ['end', arguments, this.returnArgumentsArray]);
}
of(pattern, selector) {
const pool = this.poolCluster.of(pattern, selector);
return new Pool(undefined, pool);
}
remove(pattern) {
return this.poolCluster.remove(pattern);
}
getConnection() {
return promiseCallback.apply(this.poolCluster, ['getConnection', arguments, this.returnArgumentsArray])
.then((_connection) => {
const config = {
reconnect: false
};
return new PoolConnection(config, _connection);
});
}
on(event, fn) {
return this.poolCluster.on(event, fn);
}
}
module.exports = poolCluster;

13
node_modules/promise-mysql/lib/poolConnection.js generated vendored Normal file
View File

@@ -0,0 +1,13 @@
const Connection = require('./connection.js');
class poolConnection extends Connection {
constructor(config, _connection) {
super(config, _connection);
}
release() {
this.connection.release();
}
}
module.exports = poolConnection;