This commit is contained in:
2025-10-24 17:06:14 -05:00
parent 12d0690b91
commit df8c75603f
11289 changed files with 1209053 additions and 318 deletions

View File

@@ -0,0 +1,22 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AggregateError = void 0;
class AggregateError extends Error {
constructor(errors) {
super();
this.errors = errors;
this.name = 'AggregateError';
}
toString() {
const message = `AggregateError of:\n${this.errors
.map((error) => error === this
? '[Circular AggregateError]'
: error instanceof AggregateError
? String(error).replace(/\n$/, '').replace(/^/gm, ' ')
: String(error).replace(/^/gm, ' ').substring(2))
.join('\n')}\n`;
return message;
}
}
exports.AggregateError = AggregateError;
//# sourceMappingURL=AggregateError.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"AggregateError.js","sourceRoot":"","sources":["../src/AggregateError.ts"],"names":[],"mappings":";;;AAGA,MAAa,cAAe,SAAQ,KAAK;IAGvC,YAAY,MAAe;QACzB,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAC/B,CAAC;IAED,QAAQ;QACN,MAAM,OAAO,GAAG,uBAAuB,IAAI,CAAC,MAAM;aAC/C,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CACb,KAAK,KAAK,IAAI;YACZ,CAAC,CAAC,2BAA2B;YAC7B,CAAC,CAAC,KAAK,YAAY,cAAc;gBACjC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC;gBACvD,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CACtD;aACA,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;QAClB,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AArBD,wCAqBC"}

View File

@@ -0,0 +1,38 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Deferred = void 0;
const TimeoutError_1 = require("./TimeoutError");
class Deferred {
constructor() {
this._promise = new Promise((resolve, reject) => {
this._reject = reject;
this._resolve = resolve;
});
}
registerTimeout(timeoutInMillis, callback) {
if (this._timeout)
return;
this._timeout = setTimeout(() => {
callback();
this.reject(new TimeoutError_1.TimeoutError('Operation timeout'));
}, timeoutInMillis);
}
_clearTimeout() {
if (!this._timeout)
return;
clearTimeout(this._timeout);
}
resolve(value) {
this._clearTimeout();
this._resolve(value);
}
reject(error) {
this._clearTimeout();
this._reject(error);
}
promise() {
return this._promise;
}
}
exports.Deferred = Deferred;
//# sourceMappingURL=Deferred.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"Deferred.js","sourceRoot":"","sources":["../src/Deferred.ts"],"names":[],"mappings":";;;AAAA,iDAA8C;AAO9C,MAAa,QAAQ;IAMnB;QACE,IAAI,CAAC,QAAQ,GAAG,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAC9C,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;YACtB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QAC1B,CAAC,CAAC,CAAC;IACL,CAAC;IAED,eAAe,CAAC,eAAuB,EAAE,QAAkB;QACzD,IAAI,IAAI,CAAC,QAAQ;YAAE,OAAO;QAE1B,IAAI,CAAC,QAAQ,GAAG,UAAU,CAAC,GAAG,EAAE;YAC9B,QAAQ,EAAE,CAAC;YACX,IAAI,CAAC,MAAM,CAAC,IAAI,2BAAY,CAAC,mBAAmB,CAAC,CAAC,CAAC;QACrD,CAAC,EAAE,eAAe,CAAC,CAAC;IACtB,CAAC;IAES,aAAa;QACrB,IAAI,CAAC,IAAI,CAAC,QAAQ;YAAE,OAAO;QAC3B,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC9B,CAAC;IAED,OAAO,CAAC,KAAQ;QACd,IAAI,CAAC,aAAa,EAAE,CAAC;QACrB,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IAED,MAAM,CAAC,KAAY;QACjB,IAAI,CAAC,aAAa,EAAE,CAAC;QACrB,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;IAED,OAAO;QACL,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;CACF;AAxCD,4BAwCC"}

291
qwen/nodejs/node_modules/sequelize-pool/lib/Pool.js generated vendored Normal file
View File

@@ -0,0 +1,291 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Pool = void 0;
const Deferred_1 = require("./Deferred");
const AggregateError_1 = require("./AggregateError");
class Pool {
constructor(factory) {
this.log = false;
if (!factory.create) {
throw new Error('create function is required');
}
if (!factory.destroy) {
throw new Error('destroy function is required');
}
if (!factory.validate) {
throw new Error('validate function is required');
}
if (typeof factory.min !== 'number' ||
factory.min < 0 ||
factory.min !== Math.round(factory.min)) {
throw new Error('min must be an integer >= 0');
}
if (typeof factory.max !== 'number' ||
factory.max <= 0 ||
factory.max !== Math.round(factory.max)) {
throw new Error('max must be an integer > 0');
}
if (factory.min > factory.max) {
throw new Error('max is smaller than min');
}
if (factory.maxUses !== undefined &&
(typeof factory.maxUses !== 'number' || factory.maxUses < 0)) {
throw new Error('maxUses must be an integer >= 0');
}
this.idleTimeoutMillis = factory.idleTimeoutMillis || 30000;
this.acquireTimeoutMillis = factory.acquireTimeoutMillis || 30000;
this.reapIntervalMillis = factory.reapIntervalMillis || 1000;
this.maxUsesPerResource = factory.maxUses || Infinity;
this.log = factory.log || false;
this._factory = factory;
this._count = 0;
this._draining = false;
this._pendingAcquires = [];
this._inUseObjects = [];
this._availableObjects = [];
this._removeIdleScheduled = false;
}
get size() {
return this._count;
}
get name() {
return this._factory.name;
}
get available() {
return this._availableObjects.length;
}
get using() {
return this._inUseObjects.length;
}
get waiting() {
return this._pendingAcquires.length;
}
get maxSize() {
return this._factory.max;
}
get minSize() {
return this._factory.min;
}
_log(message, level) {
if (typeof this.log === 'function') {
this.log(message, level);
}
else if (this.log) {
console.log(`${level.toUpperCase()} pool ${this.name || ''} - ${message}`);
}
}
_removeIdle() {
const toRemove = [];
const now = Date.now();
let i;
let available = this._availableObjects.length;
const maxRemovable = this.size - this.minSize;
let timeout;
this._removeIdleScheduled = false;
for (i = 0; i < available && maxRemovable > toRemove.length; i++) {
timeout = this._availableObjects[i].timeout;
if (now >= timeout) {
this._log('removeIdle() destroying obj - now:' + now + ' timeout:' + timeout, 'verbose');
toRemove.push(this._availableObjects[i].resource);
}
}
toRemove.forEach(this.destroy, this);
available = this._availableObjects.length;
if (available > 0) {
this._log('this._availableObjects.length=' + available, 'verbose');
this._scheduleRemoveIdle();
}
else {
this._log('removeIdle() all objects removed', 'verbose');
}
}
_scheduleRemoveIdle() {
if (!this._removeIdleScheduled) {
this._removeIdleScheduled = true;
this._removeIdleTimer = setTimeout(() => {
this._removeIdle();
}, this.reapIntervalMillis);
}
}
_dispense() {
let wrappedResource = null;
const waitingCount = this._pendingAcquires.length;
this._log(`dispense() clients=${waitingCount} available=${this._availableObjects.length}`, 'info');
if (waitingCount < 1) {
return;
}
while (this._availableObjects.length > 0) {
this._log('dispense() - reusing obj', 'verbose');
wrappedResource = this._availableObjects[this._availableObjects.length - 1];
if (!this._factory.validate(wrappedResource.resource)) {
this.destroy(wrappedResource.resource);
continue;
}
this._availableObjects.pop();
this._addResourceToInUseObjects(wrappedResource.resource, wrappedResource.useCount);
const deferred = this._pendingAcquires.shift();
return deferred.resolve(wrappedResource.resource);
}
if (this.size < this.maxSize) {
this._createResource();
}
}
_createResource() {
this._count += 1;
this._log(`createResource() - creating obj - count=${this.size} min=${this.minSize} max=${this.maxSize}`, 'verbose');
this._factory
.create()
.then((resource) => {
const deferred = this._pendingAcquires.shift();
if (deferred) {
this._addResourceToInUseObjects(resource, 0);
deferred.resolve(resource);
}
else {
this._addResourceToAvailableObjects(resource, 0);
}
})
.catch((error) => {
const deferred = this._pendingAcquires.shift();
this._count -= 1;
if (this._count < 0)
this._count = 0;
if (deferred) {
deferred.reject(error);
}
process.nextTick(() => {
this._dispense();
});
});
}
_addResourceToAvailableObjects(resource, useCount) {
const wrappedResource = {
resource: resource,
useCount: useCount,
timeout: Date.now() + this.idleTimeoutMillis,
};
this._availableObjects.push(wrappedResource);
this._dispense();
this._scheduleRemoveIdle();
}
_addResourceToInUseObjects(resource, useCount) {
const wrappedResource = {
resource: resource,
useCount: useCount,
};
this._inUseObjects.push(wrappedResource);
}
_ensureMinimum() {
let i, diff;
if (!this._draining && this.size < this.minSize) {
diff = this.minSize - this.size;
for (i = 0; i < diff; i++) {
this._createResource();
}
}
}
acquire() {
if (this._draining) {
return Promise.reject(new Error('pool is draining and cannot accept work'));
}
const deferred = new Deferred_1.Deferred();
deferred.registerTimeout(this.acquireTimeoutMillis, () => {
this._pendingAcquires = this._pendingAcquires.filter((pending) => pending !== deferred);
});
this._pendingAcquires.push(deferred);
this._dispense();
return deferred.promise();
}
release(resource) {
if (this._availableObjects.some((resourceWithTimeout) => resourceWithTimeout.resource === resource)) {
this._log('release called twice for the same resource: ' + new Error().stack, 'error');
return;
}
const index = this._inUseObjects.findIndex((wrappedResource) => wrappedResource.resource === resource);
if (index < 0) {
this._log('attempt to release an invalid resource: ' + new Error().stack, 'error');
return;
}
const wrappedResource = this._inUseObjects[index];
wrappedResource.useCount += 1;
if (wrappedResource.useCount >= this.maxUsesPerResource) {
this._log('release() destroying obj - useCount:' +
wrappedResource.useCount +
' maxUsesPerResource:' +
this.maxUsesPerResource, 'verbose');
this.destroy(wrappedResource.resource);
this._dispense();
}
else {
this._inUseObjects.splice(index, 1);
this._addResourceToAvailableObjects(wrappedResource.resource, wrappedResource.useCount);
}
}
async destroy(resource) {
const available = this._availableObjects.length;
const using = this._inUseObjects.length;
this._availableObjects = this._availableObjects.filter((object) => object.resource !== resource);
this._inUseObjects = this._inUseObjects.filter((object) => object.resource !== resource);
if (available === this._availableObjects.length &&
using === this._inUseObjects.length) {
this._ensureMinimum();
return;
}
this._count -= 1;
if (this._count < 0)
this._count = 0;
try {
await this._factory.destroy(resource);
}
finally {
this._ensureMinimum();
if (!this._draining) {
process.nextTick(() => {
this._dispense();
});
}
}
}
drain() {
this._log('draining', 'info');
this._draining = true;
const check = (callback) => {
if (this._pendingAcquires.length > 0) {
this._dispense();
setTimeout(() => {
check(callback);
}, 100);
return;
}
if (this._availableObjects.length !== this._count) {
setTimeout(() => {
check(callback);
}, 100);
return;
}
callback();
};
return new Promise((resolve) => check(resolve));
}
async destroyAllNow() {
this._log('force destroying all objects', 'info');
this._removeIdleScheduled = false;
clearTimeout(this._removeIdleTimer);
const resources = this._availableObjects.map((resource) => resource.resource);
const errors = [];
for (const resource of resources) {
try {
await this.destroy(resource);
}
catch (ex) {
this._log('Error destroying resource: ' + ex.stack, 'error');
errors.push(ex);
}
}
if (errors.length > 0) {
throw new AggregateError_1.AggregateError(errors);
}
}
}
exports.Pool = Pool;
//# sourceMappingURL=Pool.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TimeoutError = void 0;
class TimeoutError extends Error {
}
exports.TimeoutError = TimeoutError;
//# sourceMappingURL=TimeoutError.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"TimeoutError.js","sourceRoot":"","sources":["../src/TimeoutError.ts"],"names":[],"mappings":";;;AAGA,MAAa,YAAa,SAAQ,KAAK;CAAG;AAA1C,oCAA0C"}

10
qwen/nodejs/node_modules/sequelize-pool/lib/index.js generated vendored Normal file
View File

@@ -0,0 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Pool = exports.AggregateError = exports.TimeoutError = void 0;
var TimeoutError_1 = require("./TimeoutError");
Object.defineProperty(exports, "TimeoutError", { enumerable: true, get: function () { return TimeoutError_1.TimeoutError; } });
var AggregateError_1 = require("./AggregateError");
Object.defineProperty(exports, "AggregateError", { enumerable: true, get: function () { return AggregateError_1.AggregateError; } });
var Pool_1 = require("./Pool");
Object.defineProperty(exports, "Pool", { enumerable: true, get: function () { return Pool_1.Pool; } });
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AACrB,mDAAkD;AAAzC,gHAAA,cAAc,OAAA;AACvB,+BAA8C;AAArC,4FAAA,IAAI,OAAA"}