Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@sqb/connect

Package Overview
Dependencies
Maintainers
1
Versions
137
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sqb/connect - npm Package Compare versions

Comparing version 4.0.1-beta.42 to 4.0.1-beta.43

5

dist/client/Cursor.js

@@ -27,3 +27,3 @@ "use strict";

this._request = request;
this._prefetchRows = (request === null || request === void 0 ? void 0 : request.fetchRows) || 100;
this._prefetchRows = request?.fetchRows || 100;
}

@@ -186,7 +186,6 @@ /**

await this._taskQueue.enqueue(async function () {
var _a;
/* If moving backward */
if (step < 0) {
/* Seek cache */
while (step < 0 && ((_a = _this._cache) === null || _a === void 0 ? void 0 : _a.cursor)) {
while (step < 0 && _this._cache?.cursor) {
_this._row = _this._cache.prev();

@@ -193,0 +192,0 @@ _this._rowNum--;

4

dist/client/CursorStream.js

@@ -17,4 +17,4 @@ "use strict";

this._cursor = cursor;
this._objectMode = options === null || options === void 0 ? void 0 : options.objectMode;
this._limit = (options === null || options === void 0 ? void 0 : options.limit) || Number.MAX_SAFE_INTEGER;
this._objectMode = options?.objectMode;
this._limit = options?.limit || Number.MAX_SAFE_INTEGER;
this.on('end', () => {

@@ -21,0 +21,0 @@ this.close().catch(() => false);

@@ -33,3 +33,3 @@ "use strict";

if (name)
return Object.assign(Object.assign({}, f), { name, index });
return { ...f, name, index };
};

@@ -49,7 +49,7 @@ const result = new FieldInfoMap_1.FieldInfoMap();

function normalizeRowsToObjectRows(fields, rowType, oldRows, options) {
return normalizeRows(fields, rowType, oldRows, Object.assign(Object.assign({}, options), { objectRows: true }));
return normalizeRows(fields, rowType, oldRows, { ...options, objectRows: true });
}
exports.normalizeRowsToObjectRows = normalizeRowsToObjectRows;
function normalizeRowsToArrayRows(fields, rowType, oldRows, options) {
return normalizeRows(fields, rowType, oldRows, Object.assign(Object.assign({}, options), { objectRows: false }));
return normalizeRows(fields, rowType, oldRows, { ...options, objectRows: false });
}

@@ -56,0 +56,0 @@ exports.normalizeRowsToArrayRows = normalizeRowsToArrayRows;

@@ -50,3 +50,3 @@ "use strict";

poolOptions.validation = (0, putil_varhelpers_1.coerceToBoolean)(popts.validation, false);
const cfg = Object.assign({}, config);
const cfg = { ...config };
const poolFactory = {

@@ -102,3 +102,3 @@ create: () => adapter.connect(cfg),

const adapterConnection = await this._pool.acquire();
const opts = Object.assign({ autoCommit: this.defaults.autoCommit }, options);
const opts = { autoCommit: this.defaults.autoCommit, ...options };
const connection = new SqbConnection_1.SqbConnection(this, adapterConnection, opts);

@@ -156,3 +156,3 @@ this.emit('acquire', connection);

throw new Error(`You must provide an @Entity annotated constructor`);
return new repository_class_1.Repository(entityDef, this, opts === null || opts === void 0 ? void 0 : opts.schema);
return new repository_class_1.Repository(entityDef, this, opts?.schema);
}

@@ -159,0 +159,0 @@ getEntity(name) {

@@ -101,3 +101,3 @@ "use strict";

throw new Error(`You must provide an @Entity annotated constructor`);
return new repository_class_1.Repository(entityDef, this, opts === null || opts === void 0 ? void 0 : opts.schema);
return new repository_class_1.Repository(entityDef, this, opts?.schema);
}

@@ -195,3 +195,2 @@ async getSchema() {

_prepareQueryRequest(query, options = {}) {
var _a;
if (!this._intlcon)

@@ -204,3 +203,3 @@ throw new Error('Session released');

autoCommit: this.inTransaction ? false :
(0, putil_varhelpers_1.coerceToBoolean)((0, putil_varhelpers_1.coalesce)(options.autoCommit, (_a = this._options) === null || _a === void 0 ? void 0 : _a.autoCommit, defaults.autoCommit), true),
(0, putil_varhelpers_1.coerceToBoolean)((0, putil_varhelpers_1.coalesce)(options.autoCommit, this._options?.autoCommit, defaults.autoCommit), true),
cursor: (0, putil_varhelpers_1.coerceToBoolean)((0, putil_varhelpers_1.coalesce)(options.cursor, defaults.cursor), false),

@@ -207,0 +206,0 @@ objectRows: (0, putil_varhelpers_1.coerceToBoolean)((0, putil_varhelpers_1.coalesce)(options.objectRows, defaults.objectRows), true),

@@ -52,3 +52,2 @@ "use strict";

async function prepareFilter(entityDef, filter, trgOp, tableAlias = 'T') {
var _a;
let srcOp;

@@ -123,3 +122,3 @@ if ((0, builder_1.isLogicalOperator)(filter))

const targetColumn = await node.resolveTargetProperty();
const joinAlias = 'J' + ((((_a = subSelect === null || subSelect === void 0 ? void 0 : subSelect._joins) === null || _a === void 0 ? void 0 : _a.length) || 0) + 1);
const joinAlias = 'J' + (((subSelect?._joins?.length) || 0) + 1);
subSelect.join((0, builder_1.InnerJoin)(targetEntity.tableName + ' ' + joinAlias)

@@ -126,0 +125,0 @@ .on((0, builder_1.Eq)(joinAlias + '.' + targetColumn.fieldName, (0, builder_1.Raw)(_curAlias + '.' + sourceColumn.fieldName))));

@@ -12,3 +12,2 @@ "use strict";

static async execute(args) {
var _a;
const { entity } = args;

@@ -37,3 +36,3 @@ const tableName = entity.tableName;

});
if (args.returning && qr.fields && ((_a = qr.rows) === null || _a === void 0 ? void 0 : _a.length)) {
if (args.returning && qr.fields && qr.rows?.length) {
const keyValues = {};

@@ -40,0 +39,0 @@ for (const f of qr.fields.values()) {

@@ -263,4 +263,4 @@ "use strict";

const resp = await args.connection.execute(query, {
params: args === null || args === void 0 ? void 0 : args.params,
fetchRows: args === null || args === void 0 ? void 0 : args.limit,
params: args?.params,
fetchRows: args?.limit,
objectRows: false,

@@ -267,0 +267,0 @@ cursor: false

@@ -11,5 +11,5 @@ "use strict";

.defineObjectElement(propertyKey, type);
if (options === null || options === void 0 ? void 0 : options.fieldNamePrefix)
if (options?.fieldNamePrefix)
el.fieldNamePrefix = options.fieldNamePrefix;
if (options === null || options === void 0 ? void 0 : options.fieldNameSuffix)
if (options?.fieldNameSuffix)
el.fieldNameSuffix = options.fieldNameSuffix;

@@ -16,0 +16,0 @@ };

@@ -88,3 +88,3 @@ "use strict";

}
if (options === null || options === void 0 ? void 0 : options.isArray)
if (options?.isArray)
prop.isArray = true;

@@ -104,3 +104,3 @@ if (!this.elements.has(propertyKey.toLowerCase()))

while (l) {
l.name = this.name + '.' + propertyKey + '#' + (i++) + ')';
l.name = this.name + '.' + propertyKey + '#' + (i++);
l = l.next;

@@ -228,3 +228,3 @@ }

for (const fk of current.foreignKeys) {
const newFk = new association_1.Association(fk.name, Object.assign(Object.assign({}, fk), { source: ctor }));
const newFk = new association_1.Association(fk.name, { ...fk, source: ctor });
entity.foreignKeys.push(newFk);

@@ -231,0 +231,0 @@ }

@@ -27,3 +27,3 @@ "use strict";

return this._execute(async (connection) => {
return this._create(values, Object.assign(Object.assign({}, options), { connection }));
return this._create(values, { ...options, connection });
}, options);

@@ -33,3 +33,3 @@ }

return this._execute(async (connection) => {
return this._createOnly(values, Object.assign(Object.assign({}, options), { connection }));
return this._createOnly(values, { ...options, connection });
}, options);

@@ -39,3 +39,3 @@ }

return this._execute(async (connection) => {
return this._exists(keyValue, Object.assign(Object.assign({}, options), { connection }));
return this._exists(keyValue, { ...options, connection });
}, options);

@@ -45,3 +45,3 @@ }

return this._execute(async (connection) => {
return this._count(Object.assign(Object.assign({}, options), { connection }));
return this._count({ ...options, connection });
}, options);

@@ -51,3 +51,3 @@ }

return this._execute(async (connection) => {
return this._findAll(Object.assign(Object.assign({}, options), { connection }));
return this._findAll({ ...options, connection });
}, options);

@@ -57,3 +57,3 @@ }

return this._execute(async (connection) => {
return this._findOne(Object.assign(Object.assign({}, options), { connection }));
return this._findOne({ ...options, connection });
}, options);

@@ -63,3 +63,3 @@ }

return this._execute(async (connection) => {
return this._findByPk(keyValue, Object.assign(Object.assign({}, options), { connection }));
return this._findByPk(keyValue, { ...options, connection });
}, options);

@@ -69,3 +69,3 @@ }

return this._execute(async (connection) => {
return this._destroy(keyValue, Object.assign(Object.assign({}, options), { connection }));
return this._destroy(keyValue, { ...options, connection });
}, options);

@@ -75,3 +75,3 @@ }

return this._execute(async (connection) => {
return this._destroyAll(Object.assign(Object.assign({}, options), { connection }));
return this._destroyAll({ ...options, connection });
}, options);

@@ -81,3 +81,3 @@ }

return this._execute(async (connection) => {
const opts = Object.assign(Object.assign({}, options), { connection });
const opts = { ...options, connection };
const keyValues = await this._update(keyValue, values, opts);

@@ -90,3 +90,3 @@ if (keyValues)

return this._execute(async (connection) => {
return !!(await this._update(keyValue, values, Object.assign(Object.assign({}, options), { connection })));
return !!(await this._update(keyValue, values, { ...options, connection }));
}, options);

@@ -96,7 +96,7 @@ }

return this._execute(async (connection) => {
return this._updateAll(values, Object.assign(Object.assign({}, options), { connection }));
return this._updateAll(values, { ...options, connection });
});
}
async _execute(fn, opts) {
let connection = opts === null || opts === void 0 ? void 0 : opts.connection;
let connection = opts?.connection;
if (!connection && this._executor instanceof SqbConnection_1.SqbConnection)

@@ -117,3 +117,8 @@ connection = this._executor;

async _create(values, options) {
const keyValues = await create_command_1.CreateCommand.execute(Object.assign(Object.assign({}, options), { entity: this._entity, values, returning: true }));
const keyValues = await create_command_1.CreateCommand.execute({
...options,
entity: this._entity,
values,
returning: true
});
const result = keyValues && (await this.findByPk(keyValues, options));

@@ -125,3 +130,8 @@ if (!result)

async _createOnly(values, options) {
await create_command_1.CreateCommand.execute(Object.assign(Object.assign({}, options), { entity: this._entity, values, returning: false }));
await create_command_1.CreateCommand.execute({
...options,
entity: this._entity,
values,
returning: false
});
}

@@ -136,12 +146,26 @@ async _exists(keyValue, options) {

}
return !!(await count_command_1.CountCommand.execute(Object.assign(Object.assign({}, options), { filter, entity: this._entity })));
return !!(await count_command_1.CountCommand.execute({
...options,
filter,
entity: this._entity
}));
}
async _count(options) {
return count_command_1.CountCommand.execute(Object.assign(Object.assign({}, options), { entity: this._entity }));
return count_command_1.CountCommand.execute({
...options,
entity: this._entity
});
}
async _findAll(options) {
return await find_command_1.FindCommand.execute(Object.assign(Object.assign({}, options), { entity: this._entity }));
return await find_command_1.FindCommand.execute({
...options,
entity: this._entity,
});
}
async _findOne(options) {
const rows = await find_command_1.FindCommand.execute(Object.assign(Object.assign({}, options), { entity: this._entity, limit: 1 }));
const rows = await find_command_1.FindCommand.execute({
...options,
entity: this._entity,
limit: 1
});
return rows && rows[0];

@@ -157,3 +181,3 @@ }

}
return await this._findOne(Object.assign(Object.assign({}, options), { filter, offset: 0 }));
return await this._findOne({ ...options, filter, offset: 0 });
}

@@ -168,6 +192,15 @@ async _destroy(keyValue, options) {

}
return !!(await destroy_command_1.DestroyCommand.execute(Object.assign(Object.assign({}, options), { filter, entity: this._entity })));
return !!(await destroy_command_1.DestroyCommand.execute({
...options,
filter,
entity: this._entity,
}));
}
async _destroyAll(options) {
return destroy_command_1.DestroyCommand.execute(Object.assign(Object.assign({}, options), { entity: this._entity, filter: options === null || options === void 0 ? void 0 : options.filter, params: options === null || options === void 0 ? void 0 : options.params }));
return destroy_command_1.DestroyCommand.execute({
...options,
entity: this._entity,
filter: options?.filter,
params: options?.params
});
}

@@ -183,11 +216,20 @@ async _update(keyValue, values, options) {

}
const updateValues = Object.assign({}, values);
const updateValues = { ...values };
Object.keys(keyValues).forEach(k => delete updateValues[k]);
const rowsAffected = await update_command_1.UpdateCommand.execute(Object.assign(Object.assign({}, options), { entity: this._entity, values: updateValues, filter }));
const rowsAffected = await update_command_1.UpdateCommand.execute({
...options,
entity: this._entity,
values: updateValues,
filter
});
return rowsAffected ? keyValues : undefined;
}
async _updateAll(values, options) {
return await update_command_1.UpdateCommand.execute(Object.assign(Object.assign({}, options), { entity: this._entity, values }));
return await update_command_1.UpdateCommand.execute({
...options,
entity: this._entity,
values
});
}
}
exports.Repository = Repository;

@@ -22,3 +22,3 @@ "use strict";

for (const fk of src.foreignKeys) {
const newFk = new association_1.Association(fk.name, Object.assign(Object.assign({}, fk), { source: derived }));
const newFk = new association_1.Association(fk.name, { ...fk, source: derived });
trg.foreignKeys.push(newFk);

@@ -57,3 +57,3 @@ }

if (fk.sourceKey && pickKeys.includes(fk.sourceKey.toLowerCase())) {
const newFk = new association_1.Association(fk.name, Object.assign(Object.assign({}, fk), { source: derived }));
const newFk = new association_1.Association(fk.name, { ...fk, source: derived });
trg.foreignKeys.push(newFk);

@@ -85,3 +85,3 @@ }

if (!(fk.sourceKey && omitKeys.includes(fk.sourceKey.toLowerCase()))) {
const newFk = new association_1.Association(fk.name, Object.assign(Object.assign({}, fk), { source: derived }));
const newFk = new association_1.Association(fk.name, { ...fk, source: derived });
trg.foreignKeys.push(newFk);

@@ -148,5 +148,5 @@ }

}
catch (_a) {
catch {
//
}
}
{
"name": "@sqb/connect",
"description": "Multi-dialect database connection framework written with TypeScript",
"version": "4.0.1-beta.42",
"version": "4.0.1-beta.43",
"author": "Panates Ltd.",

@@ -48,6 +48,9 @@ "contributors": [

"peerDependencies": {
"@sqb/builder": "^4.0.1-beta.36"
"@sqb/builder": "^4.0.1-beta.43"
},
"main": "dist/index.js",
"types": "dist/index.d.ts",
"engines": {
"node": ">= 14.0"
},
"directories": {

@@ -72,2 +75,2 @@ "lib": "dist",

}
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc