@sqb/connect 4.9.1 → 4.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/client/cursor-stream.js +2 -5
- package/cjs/client/cursor.js +5 -12
- package/cjs/client/field-info-map.js +0 -2
- package/cjs/client/sqb-client.js +1 -4
- package/cjs/client/sqb-connection.js +3 -6
- package/cjs/orm/base-entity.js +0 -1
- package/cjs/orm/commands/find.command.js +7 -11
- package/cjs/orm/commands/row-converter.js +1 -4
- package/cjs/orm/model/association-node.js +0 -3
- package/cjs/orm/model/association.js +0 -13
- package/cjs/orm/model/link-chain.js +0 -3
- package/cjs/orm/repository.class.js +0 -3
- package/esm/client/cursor-stream.js +2 -5
- package/esm/client/cursor.js +5 -12
- package/esm/client/field-info-map.js +0 -2
- package/esm/client/sqb-client.js +1 -4
- package/esm/client/sqb-connection.js +3 -6
- package/esm/orm/base-entity.js +0 -1
- package/esm/orm/commands/find.command.js +7 -11
- package/esm/orm/commands/row-converter.js +1 -4
- package/esm/orm/model/association-node.js +0 -3
- package/esm/orm/model/association.js +0 -13
- package/esm/orm/model/link-chain.js +0 -3
- package/esm/orm/repository.class.js +0 -3
- package/package.json +14 -20
- package/esm/client/adapter.d.ts +0 -57
- package/esm/client/cursor-stream.d.ts +0 -29
- package/esm/client/cursor.d.ts +0 -116
- package/esm/client/extensions.d.ts +0 -4
- package/esm/client/field-info-map.d.ts +0 -12
- package/esm/client/helpers.d.ts +0 -9
- package/esm/client/sqb-client.d.ts +0 -65
- package/esm/client/sqb-connection.d.ts +0 -74
- package/esm/client/types.d.ts +0 -181
- package/esm/index.d.ts +0 -34
- package/esm/orm/backward.d.ts +0 -13
- package/esm/orm/base-entity.d.ts +0 -8
- package/esm/orm/commands/command.helper.d.ts +0 -14
- package/esm/orm/commands/count.command.d.ts +0 -11
- package/esm/orm/commands/create.command.d.ts +0 -20
- package/esm/orm/commands/delete.command.d.ts +0 -11
- package/esm/orm/commands/find.command.d.ts +0 -44
- package/esm/orm/commands/row-converter.d.ts +0 -55
- package/esm/orm/commands/update.command.d.ts +0 -22
- package/esm/orm/decorators/column.decorator.d.ts +0 -4
- package/esm/orm/decorators/embedded.decorator.d.ts +0 -3
- package/esm/orm/decorators/entity.decorator.d.ts +0 -38
- package/esm/orm/decorators/events.decorator.d.ts +0 -6
- package/esm/orm/decorators/foreignkey.decorator.d.ts +0 -2
- package/esm/orm/decorators/index.decorator.d.ts +0 -3
- package/esm/orm/decorators/link.decorator.d.ts +0 -13
- package/esm/orm/decorators/primarykey.decorator.d.ts +0 -3
- package/esm/orm/decorators/transform.decorator.d.ts +0 -3
- package/esm/orm/model/association-field-metadata.d.ts +0 -12
- package/esm/orm/model/association-node.d.ts +0 -9
- package/esm/orm/model/association.d.ts +0 -27
- package/esm/orm/model/column-field-metadata.d.ts +0 -75
- package/esm/orm/model/embedded-field-metadata.d.ts +0 -14
- package/esm/orm/model/entity-metadata.d.ts +0 -50
- package/esm/orm/model/field-metadata.d.ts +0 -16
- package/esm/orm/model/index-metadata.d.ts +0 -18
- package/esm/orm/model/link-chain.d.ts +0 -13
- package/esm/orm/orm.const.d.ts +0 -2
- package/esm/orm/orm.type.d.ts +0 -20
- package/esm/orm/repository.class.d.ts +0 -140
- package/esm/orm/util/apply-mixins.d.ts +0 -1
- package/esm/orm/util/extract-keyvalues.d.ts +0 -2
- package/esm/orm/util/orm.helper.d.ts +0 -13
- package/esm/orm/util/serialize-field.d.ts +0 -2
- package/esm/types.d.ts +0 -12
|
@@ -7,13 +7,10 @@ const stream_1 = require("stream");
|
|
|
7
7
|
const inspect = Symbol.for('nodejs.util.inspect.custom');
|
|
8
8
|
const debug = (0, debug_1.default)('sqb:cursorstream');
|
|
9
9
|
class CursorStream extends stream_1.Readable {
|
|
10
|
-
_cursor;
|
|
11
|
-
_objectMode;
|
|
12
|
-
_limit;
|
|
13
|
-
_rowNum = -1;
|
|
14
|
-
_eof = false;
|
|
15
10
|
constructor(cursor, options) {
|
|
16
11
|
super(options);
|
|
12
|
+
this._rowNum = -1;
|
|
13
|
+
this._eof = false;
|
|
17
14
|
this._cursor = cursor;
|
|
18
15
|
this._objectMode = options?.objectMode;
|
|
19
16
|
this._limit = options?.limit || Number.MAX_SAFE_INTEGER;
|
package/cjs/client/cursor.js
CHANGED
|
@@ -11,20 +11,13 @@ const cursor_stream_js_1 = require("./cursor-stream.js");
|
|
|
11
11
|
const helpers_js_1 = require("./helpers.js");
|
|
12
12
|
const debug = (0, debug_1.default)('sqb:cursor');
|
|
13
13
|
class Cursor extends (0, strict_typed_events_1.TypedEventEmitterClass)(strict_typed_events_1.AsyncEventEmitter) {
|
|
14
|
-
_connection;
|
|
15
|
-
_fields;
|
|
16
|
-
_prefetchRows;
|
|
17
|
-
_request;
|
|
18
|
-
_intlcur;
|
|
19
|
-
_taskQueue = new power_tasks_1.TaskQueue();
|
|
20
|
-
_fetchCache = new doublylinked_1.default();
|
|
21
|
-
_rowNum = 0;
|
|
22
|
-
_fetchedAll = false;
|
|
23
|
-
_fetchedRows = 0;
|
|
24
|
-
_row;
|
|
25
|
-
_cache;
|
|
26
14
|
constructor(connection, fields, adapterCursor, request) {
|
|
27
15
|
super();
|
|
16
|
+
this._taskQueue = new power_tasks_1.TaskQueue();
|
|
17
|
+
this._fetchCache = new doublylinked_1.default();
|
|
18
|
+
this._rowNum = 0;
|
|
19
|
+
this._fetchedAll = false;
|
|
20
|
+
this._fetchedRows = 0;
|
|
28
21
|
this._connection = connection;
|
|
29
22
|
this._intlcur = adapterCursor;
|
|
30
23
|
this._fields = fields;
|
package/cjs/client/sqb-client.js
CHANGED
|
@@ -13,12 +13,9 @@ const sqb_connection_js_1 = require("./sqb-connection.js");
|
|
|
13
13
|
const debug = (0, debug_1.default)('sqb:client');
|
|
14
14
|
const inspect = Symbol.for('nodejs.util.inspect.custom');
|
|
15
15
|
class SqbClient extends (0, strict_typed_events_1.TypedEventEmitterClass)(strict_typed_events_1.AsyncEventEmitter) {
|
|
16
|
-
_adapter;
|
|
17
|
-
_pool;
|
|
18
|
-
_defaults;
|
|
19
|
-
_entities = {};
|
|
20
16
|
constructor(config) {
|
|
21
17
|
super();
|
|
18
|
+
this._entities = {};
|
|
22
19
|
if (!(config && typeof config === 'object'))
|
|
23
20
|
throw new TypeError('Configuration object required');
|
|
24
21
|
let adapter;
|
|
@@ -14,15 +14,12 @@ const cursor_js_1 = require("./cursor.js");
|
|
|
14
14
|
const helpers_js_1 = require("./helpers.js");
|
|
15
15
|
const debug = (0, debug_1.default)('sqb:connection');
|
|
16
16
|
class SqbConnection extends (0, strict_typed_events_1.TypedEventEmitterClass)(strict_typed_events_1.AsyncEventEmitter) {
|
|
17
|
-
client;
|
|
18
|
-
_intlcon;
|
|
19
|
-
_tasks = new power_tasks_1.TaskQueue();
|
|
20
|
-
_options;
|
|
21
|
-
_inTransaction = false;
|
|
22
|
-
_refCount = 1;
|
|
23
17
|
constructor(client, adapterConnection, options) {
|
|
24
18
|
super();
|
|
25
19
|
this.client = client;
|
|
20
|
+
this._tasks = new power_tasks_1.TaskQueue();
|
|
21
|
+
this._inTransaction = false;
|
|
22
|
+
this._refCount = 1;
|
|
26
23
|
this._intlcon = adapterConnection;
|
|
27
24
|
this._options = options || {};
|
|
28
25
|
}
|
package/cjs/orm/base-entity.js
CHANGED
|
@@ -4,7 +4,6 @@ exports.BaseEntity = void 0;
|
|
|
4
4
|
const entity_decorator_js_1 = require("./decorators/entity.decorator.js");
|
|
5
5
|
const orm_const_js_1 = require("./orm.const.js");
|
|
6
6
|
class BaseEntity {
|
|
7
|
-
[orm_const_js_1.REPOSITORY_KEY];
|
|
8
7
|
constructor(partial) {
|
|
9
8
|
const fields = entity_decorator_js_1.Entity.getColumnFieldNames(Object.getPrototypeOf(this).constructor);
|
|
10
9
|
if (fields && partial) {
|
|
@@ -11,18 +11,14 @@ const command_helper_js_1 = require("./command.helper.js");
|
|
|
11
11
|
const row_converter_js_1 = require("./row-converter.js");
|
|
12
12
|
const SORT_ORDER_PATTERN = /^([-+])?(.*)$/;
|
|
13
13
|
class FindCommand {
|
|
14
|
-
maxEagerFetch = 100000;
|
|
15
|
-
maxSubQueries = 5;
|
|
16
|
-
mainEntity;
|
|
17
|
-
resultEntity;
|
|
18
|
-
converter;
|
|
19
|
-
mainAlias = 'T';
|
|
20
|
-
resultAlias = 'T';
|
|
21
|
-
_joins = [];
|
|
22
|
-
_selectColumns = {};
|
|
23
|
-
_filter = (0, builder_1.And)();
|
|
24
|
-
_sort;
|
|
25
14
|
constructor(selectEntity, outputEntity) {
|
|
15
|
+
this.maxEagerFetch = 100000;
|
|
16
|
+
this.maxSubQueries = 5;
|
|
17
|
+
this.mainAlias = 'T';
|
|
18
|
+
this.resultAlias = 'T';
|
|
19
|
+
this._joins = [];
|
|
20
|
+
this._selectColumns = {};
|
|
21
|
+
this._filter = (0, builder_1.And)();
|
|
26
22
|
this.mainEntity = selectEntity;
|
|
27
23
|
this.resultEntity = outputEntity;
|
|
28
24
|
this.converter = new row_converter_js_1.RowConverter(outputEntity.ctor);
|
|
@@ -12,13 +12,10 @@ const isNestedProperty = (prop) => {
|
|
|
12
12
|
return prop.converter && prop.findCommand;
|
|
13
13
|
};
|
|
14
14
|
class RowConverter {
|
|
15
|
-
resultType;
|
|
16
|
-
parent;
|
|
17
|
-
_properties = {};
|
|
18
|
-
_propertyKeys;
|
|
19
15
|
constructor(resultType, parent) {
|
|
20
16
|
this.resultType = resultType;
|
|
21
17
|
this.parent = parent;
|
|
18
|
+
this._properties = {};
|
|
22
19
|
}
|
|
23
20
|
addValueProperty(args) {
|
|
24
21
|
this._propertyKeys = undefined;
|
|
@@ -3,9 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.AssociationNode = void 0;
|
|
4
4
|
const association_js_1 = require("./association.js");
|
|
5
5
|
class AssociationNode extends association_js_1.Association {
|
|
6
|
-
prior;
|
|
7
|
-
next;
|
|
8
|
-
conditions;
|
|
9
6
|
getFirst() {
|
|
10
7
|
let l = this;
|
|
11
8
|
while (l.prior)
|
|
@@ -5,19 +5,6 @@ const putil_varhelpers_1 = require("putil-varhelpers");
|
|
|
5
5
|
const orm_helper_js_1 = require("../util/orm.helper.js");
|
|
6
6
|
const entity_metadata_js_1 = require("./entity-metadata.js");
|
|
7
7
|
class Association {
|
|
8
|
-
_resolved;
|
|
9
|
-
_source; // cached value
|
|
10
|
-
_target; // cached value
|
|
11
|
-
_sourceKey; // cached value
|
|
12
|
-
_targetKey; // cached value
|
|
13
|
-
_sourceProperty;
|
|
14
|
-
_targetProperty;
|
|
15
|
-
name;
|
|
16
|
-
source;
|
|
17
|
-
target;
|
|
18
|
-
sourceKey;
|
|
19
|
-
targetKey;
|
|
20
|
-
many;
|
|
21
8
|
constructor(name, args) {
|
|
22
9
|
this.name = name;
|
|
23
10
|
this.source = args.source;
|
|
@@ -3,9 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.LinkChain = void 0;
|
|
4
4
|
const association_node_js_1 = require("./association-node.js");
|
|
5
5
|
class LinkChain {
|
|
6
|
-
target;
|
|
7
|
-
first;
|
|
8
|
-
current;
|
|
9
6
|
constructor(target, targetKey, sourceKey, many) {
|
|
10
7
|
this.target = target;
|
|
11
8
|
this.first = this.current = new association_node_js_1.AssociationNode('', {
|
|
@@ -10,9 +10,6 @@ const find_command_js_1 = require("./commands/find.command.js");
|
|
|
10
10
|
const update_command_js_1 = require("./commands/update.command.js");
|
|
11
11
|
const extract_keyvalues_js_1 = require("./util/extract-keyvalues.js");
|
|
12
12
|
class Repository extends (0, strict_typed_events_1.TypedEventEmitterClass)(strict_typed_events_1.AsyncEventEmitter) {
|
|
13
|
-
_executor;
|
|
14
|
-
_entity;
|
|
15
|
-
_schema;
|
|
16
13
|
constructor(entityDef, executor, schema) {
|
|
17
14
|
super();
|
|
18
15
|
this._executor = executor;
|
|
@@ -3,13 +3,10 @@ import { Readable } from 'stream';
|
|
|
3
3
|
const inspect = Symbol.for('nodejs.util.inspect.custom');
|
|
4
4
|
const debug = _debug('sqb:cursorstream');
|
|
5
5
|
export class CursorStream extends Readable {
|
|
6
|
-
_cursor;
|
|
7
|
-
_objectMode;
|
|
8
|
-
_limit;
|
|
9
|
-
_rowNum = -1;
|
|
10
|
-
_eof = false;
|
|
11
6
|
constructor(cursor, options) {
|
|
12
7
|
super(options);
|
|
8
|
+
this._rowNum = -1;
|
|
9
|
+
this._eof = false;
|
|
13
10
|
this._cursor = cursor;
|
|
14
11
|
this._objectMode = options?.objectMode;
|
|
15
12
|
this._limit = options?.limit || Number.MAX_SAFE_INTEGER;
|
package/esm/client/cursor.js
CHANGED
|
@@ -7,20 +7,13 @@ import { CursorStream } from './cursor-stream.js';
|
|
|
7
7
|
import { callFetchHooks, normalizeRowsToArrayRows, normalizeRowsToObjectRows } from './helpers.js';
|
|
8
8
|
const debug = _debug('sqb:cursor');
|
|
9
9
|
export class Cursor extends TypedEventEmitterClass(AsyncEventEmitter) {
|
|
10
|
-
_connection;
|
|
11
|
-
_fields;
|
|
12
|
-
_prefetchRows;
|
|
13
|
-
_request;
|
|
14
|
-
_intlcur;
|
|
15
|
-
_taskQueue = new TaskQueue();
|
|
16
|
-
_fetchCache = new DoublyLinked();
|
|
17
|
-
_rowNum = 0;
|
|
18
|
-
_fetchedAll = false;
|
|
19
|
-
_fetchedRows = 0;
|
|
20
|
-
_row;
|
|
21
|
-
_cache;
|
|
22
10
|
constructor(connection, fields, adapterCursor, request) {
|
|
23
11
|
super();
|
|
12
|
+
this._taskQueue = new TaskQueue();
|
|
13
|
+
this._fetchCache = new DoublyLinked();
|
|
14
|
+
this._rowNum = 0;
|
|
15
|
+
this._fetchedAll = false;
|
|
16
|
+
this._fetchedRows = 0;
|
|
24
17
|
this._connection = connection;
|
|
25
18
|
this._intlcur = adapterCursor;
|
|
26
19
|
this._fields = fields;
|
package/esm/client/sqb-client.js
CHANGED
|
@@ -9,12 +9,9 @@ import { SqbConnection } from './sqb-connection.js';
|
|
|
9
9
|
const debug = _debug('sqb:client');
|
|
10
10
|
const inspect = Symbol.for('nodejs.util.inspect.custom');
|
|
11
11
|
export class SqbClient extends TypedEventEmitterClass(AsyncEventEmitter) {
|
|
12
|
-
_adapter;
|
|
13
|
-
_pool;
|
|
14
|
-
_defaults;
|
|
15
|
-
_entities = {};
|
|
16
12
|
constructor(config) {
|
|
17
13
|
super();
|
|
14
|
+
this._entities = {};
|
|
18
15
|
if (!(config && typeof config === 'object'))
|
|
19
16
|
throw new TypeError('Configuration object required');
|
|
20
17
|
let adapter;
|
|
@@ -10,15 +10,12 @@ import { Cursor } from './cursor.js';
|
|
|
10
10
|
import { callFetchHooks, normalizeRowsToArrayRows, normalizeRowsToObjectRows, wrapAdapterFields } from './helpers.js';
|
|
11
11
|
const debug = _debug('sqb:connection');
|
|
12
12
|
export class SqbConnection extends TypedEventEmitterClass(AsyncEventEmitter) {
|
|
13
|
-
client;
|
|
14
|
-
_intlcon;
|
|
15
|
-
_tasks = new TaskQueue();
|
|
16
|
-
_options;
|
|
17
|
-
_inTransaction = false;
|
|
18
|
-
_refCount = 1;
|
|
19
13
|
constructor(client, adapterConnection, options) {
|
|
20
14
|
super();
|
|
21
15
|
this.client = client;
|
|
16
|
+
this._tasks = new TaskQueue();
|
|
17
|
+
this._inTransaction = false;
|
|
18
|
+
this._refCount = 1;
|
|
22
19
|
this._intlcon = adapterConnection;
|
|
23
20
|
this._options = options || {};
|
|
24
21
|
}
|
package/esm/orm/base-entity.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Entity } from './decorators/entity.decorator.js';
|
|
2
2
|
import { REPOSITORY_KEY } from './orm.const.js';
|
|
3
3
|
export class BaseEntity {
|
|
4
|
-
[REPOSITORY_KEY];
|
|
5
4
|
constructor(partial) {
|
|
6
5
|
const fields = Entity.getColumnFieldNames(Object.getPrototypeOf(this).constructor);
|
|
7
6
|
if (fields && partial) {
|
|
@@ -8,18 +8,14 @@ import { joinAssociationGetLast, prepareFilter } from './command.helper.js';
|
|
|
8
8
|
import { RowConverter } from './row-converter.js';
|
|
9
9
|
const SORT_ORDER_PATTERN = /^([-+])?(.*)$/;
|
|
10
10
|
export class FindCommand {
|
|
11
|
-
maxEagerFetch = 100000;
|
|
12
|
-
maxSubQueries = 5;
|
|
13
|
-
mainEntity;
|
|
14
|
-
resultEntity;
|
|
15
|
-
converter;
|
|
16
|
-
mainAlias = 'T';
|
|
17
|
-
resultAlias = 'T';
|
|
18
|
-
_joins = [];
|
|
19
|
-
_selectColumns = {};
|
|
20
|
-
_filter = And();
|
|
21
|
-
_sort;
|
|
22
11
|
constructor(selectEntity, outputEntity) {
|
|
12
|
+
this.maxEagerFetch = 100000;
|
|
13
|
+
this.maxSubQueries = 5;
|
|
14
|
+
this.mainAlias = 'T';
|
|
15
|
+
this.resultAlias = 'T';
|
|
16
|
+
this._joins = [];
|
|
17
|
+
this._selectColumns = {};
|
|
18
|
+
this._filter = And();
|
|
23
19
|
this.mainEntity = selectEntity;
|
|
24
20
|
this.resultEntity = outputEntity;
|
|
25
21
|
this.converter = new RowConverter(outputEntity.ctor);
|
|
@@ -9,13 +9,10 @@ const isNestedProperty = (prop) => {
|
|
|
9
9
|
return prop.converter && prop.findCommand;
|
|
10
10
|
};
|
|
11
11
|
export class RowConverter {
|
|
12
|
-
resultType;
|
|
13
|
-
parent;
|
|
14
|
-
_properties = {};
|
|
15
|
-
_propertyKeys;
|
|
16
12
|
constructor(resultType, parent) {
|
|
17
13
|
this.resultType = resultType;
|
|
18
14
|
this.parent = parent;
|
|
15
|
+
this._properties = {};
|
|
19
16
|
}
|
|
20
17
|
addValueProperty(args) {
|
|
21
18
|
this._propertyKeys = undefined;
|
|
@@ -2,19 +2,6 @@ import { camelCase } from 'putil-varhelpers';
|
|
|
2
2
|
import { resolveEntityMeta } from '../util/orm.helper.js';
|
|
3
3
|
import { EntityMetadata } from './entity-metadata.js';
|
|
4
4
|
export class Association {
|
|
5
|
-
_resolved;
|
|
6
|
-
_source; // cached value
|
|
7
|
-
_target; // cached value
|
|
8
|
-
_sourceKey; // cached value
|
|
9
|
-
_targetKey; // cached value
|
|
10
|
-
_sourceProperty;
|
|
11
|
-
_targetProperty;
|
|
12
|
-
name;
|
|
13
|
-
source;
|
|
14
|
-
target;
|
|
15
|
-
sourceKey;
|
|
16
|
-
targetKey;
|
|
17
|
-
many;
|
|
18
5
|
constructor(name, args) {
|
|
19
6
|
this.name = name;
|
|
20
7
|
this.source = args.source;
|
|
@@ -7,9 +7,6 @@ import { FindCommand } from './commands/find.command.js';
|
|
|
7
7
|
import { UpdateCommand } from './commands/update.command.js';
|
|
8
8
|
import { extractKeyValues } from './util/extract-keyvalues.js';
|
|
9
9
|
export class Repository extends TypedEventEmitterClass(AsyncEventEmitter) {
|
|
10
|
-
_executor;
|
|
11
|
-
_entity;
|
|
12
|
-
_schema;
|
|
13
10
|
constructor(entityDef, executor, schema) {
|
|
14
11
|
super();
|
|
15
12
|
this._executor = executor;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sqb/connect",
|
|
3
3
|
"description": "Multi-dialect database connection framework written with TypeScript",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.10.0",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"contributors": [
|
|
7
7
|
"Eray Hanoglu <e.hanoglu@panates.com>",
|
|
@@ -13,6 +13,10 @@
|
|
|
13
13
|
"url": "https://github.com/sqbjs/sqb.git",
|
|
14
14
|
"directory": "packages/connect"
|
|
15
15
|
},
|
|
16
|
+
"type": "module",
|
|
17
|
+
"module": "./esm/index.js",
|
|
18
|
+
"main": "./cjs/index.js",
|
|
19
|
+
"types": "./types/index.d.ts",
|
|
16
20
|
"scripts": {
|
|
17
21
|
"compile": "tsc",
|
|
18
22
|
"prebuild": "npm run lint && npm run clean",
|
|
@@ -30,33 +34,23 @@
|
|
|
30
34
|
},
|
|
31
35
|
"dependencies": {
|
|
32
36
|
"debug": "^4.3.4",
|
|
33
|
-
"lightning-pool": "^4.2.
|
|
37
|
+
"lightning-pool": "^4.2.2",
|
|
34
38
|
"lodash": "^4.17.21",
|
|
35
|
-
"power-tasks": "^1.7.
|
|
39
|
+
"power-tasks": "^1.7.2",
|
|
36
40
|
"putil-isplainobject": "^1.1.5",
|
|
37
|
-
"putil-merge": "^3.
|
|
38
|
-
"putil-promisify": "^1.10.
|
|
41
|
+
"putil-merge": "^3.12.1",
|
|
42
|
+
"putil-promisify": "^1.10.1",
|
|
39
43
|
"putil-varhelpers": "^1.6.5",
|
|
40
44
|
"reflect-metadata": "^0.1.13",
|
|
41
|
-
"strict-typed-events": "^2.3.
|
|
42
|
-
"ts-gems": "^2.
|
|
45
|
+
"strict-typed-events": "^2.3.2",
|
|
46
|
+
"ts-gems": "^2.5.0"
|
|
43
47
|
},
|
|
44
48
|
"devDependencies": {
|
|
45
|
-
"@types/debug": "^4.1.
|
|
46
|
-
"@types/lodash": "^4.14.
|
|
49
|
+
"@types/debug": "^4.1.12",
|
|
50
|
+
"@types/lodash": "^4.14.201"
|
|
47
51
|
},
|
|
48
52
|
"peerDependencies": {
|
|
49
|
-
"@sqb/builder": "^4.
|
|
50
|
-
},
|
|
51
|
-
"type": "module",
|
|
52
|
-
"types": "esm/index.d.ts",
|
|
53
|
-
"exports": {
|
|
54
|
-
".": {
|
|
55
|
-
"require": "./cjs/index.js",
|
|
56
|
-
"default": "./esm/index.js"
|
|
57
|
-
},
|
|
58
|
-
"./cjs": "./cjs/index.js",
|
|
59
|
-
"./esm": "./esm/index.js"
|
|
53
|
+
"@sqb/builder": "^4.10.0"
|
|
60
54
|
},
|
|
61
55
|
"engines": {
|
|
62
56
|
"node": ">=16.0",
|
package/esm/client/adapter.d.ts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { Maybe } from 'ts-gems';
|
|
2
|
-
import { classes } from '@sqb/builder';
|
|
3
|
-
import { ClientConfiguration, DataType, QueryRequest, RowType } from './types.js';
|
|
4
|
-
export interface Adapter {
|
|
5
|
-
driver: string;
|
|
6
|
-
dialect: string;
|
|
7
|
-
features?: {
|
|
8
|
-
cursor?: boolean;
|
|
9
|
-
schema?: boolean;
|
|
10
|
-
fetchAsString?: DataType[];
|
|
11
|
-
};
|
|
12
|
-
connect: (config: ClientConfiguration) => Promise<Adapter.Connection>;
|
|
13
|
-
}
|
|
14
|
-
export declare namespace Adapter {
|
|
15
|
-
interface Connection {
|
|
16
|
-
sessionId: any;
|
|
17
|
-
execute: (request: QueryRequest) => Promise<Response>;
|
|
18
|
-
close: () => Promise<void>;
|
|
19
|
-
reset: () => Promise<void>;
|
|
20
|
-
test: () => Promise<void>;
|
|
21
|
-
startTransaction: () => Promise<void>;
|
|
22
|
-
setSavepoint?: (savepoint: string) => Promise<void>;
|
|
23
|
-
releaseSavepoint?: (savepoint: string) => Promise<void>;
|
|
24
|
-
rollbackSavepoint?: (savepoint: string) => Promise<void>;
|
|
25
|
-
commit: () => Promise<void>;
|
|
26
|
-
rollback: () => Promise<void>;
|
|
27
|
-
setSchema?: (schema: string) => Promise<void>;
|
|
28
|
-
getSchema?: () => Promise<string>;
|
|
29
|
-
onGenerateQuery?: (request: QueryRequest, query: classes.Query) => void;
|
|
30
|
-
getInTransaction?: () => boolean;
|
|
31
|
-
}
|
|
32
|
-
interface Cursor {
|
|
33
|
-
readonly isClosed: boolean;
|
|
34
|
-
readonly rowType: RowType;
|
|
35
|
-
close: () => Promise<void>;
|
|
36
|
-
fetch: (rows: number) => Promise<Maybe<any[]>>;
|
|
37
|
-
}
|
|
38
|
-
interface Response {
|
|
39
|
-
fields?: Field[];
|
|
40
|
-
rows?: Record<string, any>[] | any[][];
|
|
41
|
-
rowType?: RowType;
|
|
42
|
-
cursor?: Adapter.Cursor;
|
|
43
|
-
rowsAffected?: number;
|
|
44
|
-
}
|
|
45
|
-
interface Field {
|
|
46
|
-
fieldName: string;
|
|
47
|
-
dataType: string;
|
|
48
|
-
jsType: string;
|
|
49
|
-
isArray?: boolean;
|
|
50
|
-
elementDataType?: string;
|
|
51
|
-
nullable?: boolean;
|
|
52
|
-
fixedLength?: boolean;
|
|
53
|
-
size?: number;
|
|
54
|
-
precision?: number;
|
|
55
|
-
_inf: any;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { Readable } from 'stream';
|
|
3
|
-
import { Cursor } from './cursor.js';
|
|
4
|
-
export interface CursorStreamOptions {
|
|
5
|
-
objectMode?: boolean;
|
|
6
|
-
limit?: number;
|
|
7
|
-
}
|
|
8
|
-
declare const inspect: unique symbol;
|
|
9
|
-
export declare class CursorStream extends Readable {
|
|
10
|
-
private readonly _cursor;
|
|
11
|
-
private readonly _objectMode?;
|
|
12
|
-
private readonly _limit;
|
|
13
|
-
private _rowNum;
|
|
14
|
-
private _eof;
|
|
15
|
-
constructor(cursor: Cursor, options?: CursorStreamOptions);
|
|
16
|
-
/**
|
|
17
|
-
* Returns if stream is closed.
|
|
18
|
-
*/
|
|
19
|
-
get isClosed(): boolean;
|
|
20
|
-
/**
|
|
21
|
-
* Closes stream and releases the cursor
|
|
22
|
-
*/
|
|
23
|
-
close(): Promise<void>;
|
|
24
|
-
toString(): string;
|
|
25
|
-
[inspect](): string;
|
|
26
|
-
_read(): void;
|
|
27
|
-
emit(event: string | symbol, ...args: any[]): boolean;
|
|
28
|
-
}
|
|
29
|
-
export {};
|
package/esm/client/cursor.d.ts
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { Adapter } from './adapter.js';
|
|
2
|
-
import { CursorStream, CursorStreamOptions } from './cursor-stream.js';
|
|
3
|
-
import { FieldInfoMap } from './field-info-map.js';
|
|
4
|
-
import { SqbConnection } from './sqb-connection.js';
|
|
5
|
-
import { ObjectRow, QueryRequest } from './types.js';
|
|
6
|
-
interface CursorEvents {
|
|
7
|
-
close: () => void;
|
|
8
|
-
error: (error: unknown) => void;
|
|
9
|
-
eof: () => void;
|
|
10
|
-
reset: () => void;
|
|
11
|
-
move: (row: any, rowNum: number) => void;
|
|
12
|
-
fetch: (row: any, rowNum: number) => void;
|
|
13
|
-
}
|
|
14
|
-
declare const Cursor_base: import("strict-typed-events").Type<import("strict-typed-events").TypedEventEmitter<any, CursorEvents, CursorEvents>>;
|
|
15
|
-
export declare class Cursor extends Cursor_base {
|
|
16
|
-
private readonly _connection;
|
|
17
|
-
private readonly _fields;
|
|
18
|
-
private readonly _prefetchRows;
|
|
19
|
-
private readonly _request;
|
|
20
|
-
private _intlcur?;
|
|
21
|
-
private _taskQueue;
|
|
22
|
-
private _fetchCache;
|
|
23
|
-
private _rowNum;
|
|
24
|
-
private _fetchedAll;
|
|
25
|
-
private _fetchedRows;
|
|
26
|
-
private _row;
|
|
27
|
-
private _cache?;
|
|
28
|
-
constructor(connection: SqbConnection, fields: FieldInfoMap, adapterCursor: Adapter.Cursor, request: QueryRequest);
|
|
29
|
-
/**
|
|
30
|
-
* Returns the Connection instance
|
|
31
|
-
*/
|
|
32
|
-
get connection(): SqbConnection;
|
|
33
|
-
/**
|
|
34
|
-
* Returns if cursor is before first record.
|
|
35
|
-
*/
|
|
36
|
-
get isBof(): boolean;
|
|
37
|
-
/**
|
|
38
|
-
* Returns if cursor is closed.
|
|
39
|
-
*/
|
|
40
|
-
get isClosed(): boolean;
|
|
41
|
-
/**
|
|
42
|
-
* Returns if cursor is after last record.
|
|
43
|
-
*/
|
|
44
|
-
get isEof(): boolean;
|
|
45
|
-
/**
|
|
46
|
-
* Returns number of fetched record count from database.
|
|
47
|
-
*/
|
|
48
|
-
get fetchedRows(): number;
|
|
49
|
-
/**
|
|
50
|
-
* Returns object instance which contains information about fields.
|
|
51
|
-
*/
|
|
52
|
-
get fields(): FieldInfoMap;
|
|
53
|
-
/**
|
|
54
|
-
* Returns current row
|
|
55
|
-
*/
|
|
56
|
-
get row(): any;
|
|
57
|
-
/**
|
|
58
|
-
* Returns current row number.
|
|
59
|
-
*/
|
|
60
|
-
get rowNum(): number;
|
|
61
|
-
/**
|
|
62
|
-
* Enables cache
|
|
63
|
-
*/
|
|
64
|
-
cached(): void;
|
|
65
|
-
/**
|
|
66
|
-
* Closes cursor
|
|
67
|
-
*/
|
|
68
|
-
close(): Promise<void>;
|
|
69
|
-
/**
|
|
70
|
-
* If cache is enabled, this call fetches and keeps all records in the internal cache.
|
|
71
|
-
* Otherwise it throws error. Once all all records fetched,
|
|
72
|
-
* you can close Cursor safely and can continue to use it in memory.
|
|
73
|
-
* Returns number of fetched rows
|
|
74
|
-
*/
|
|
75
|
-
fetchAll(): Promise<number>;
|
|
76
|
-
/**
|
|
77
|
-
* Moves cursor to given row number.
|
|
78
|
-
* cursor can move both forward and backward if cache enabled.
|
|
79
|
-
* Otherwise it throws error.
|
|
80
|
-
*/
|
|
81
|
-
moveTo(rowNum: number): Promise<ObjectRow>;
|
|
82
|
-
/**
|
|
83
|
-
* Moves cursor forward by one row and returns that row.
|
|
84
|
-
* And also it allows iterating over rows easily.
|
|
85
|
-
*/
|
|
86
|
-
next(): Promise<ObjectRow>;
|
|
87
|
-
/**
|
|
88
|
-
* Moves cursor back by one row and returns that row.
|
|
89
|
-
* And also it allows iterating over rows easily.
|
|
90
|
-
*/
|
|
91
|
-
prev(): Promise<ObjectRow>;
|
|
92
|
-
/**
|
|
93
|
-
* Moves cursor before first row. (Required cache enabled)
|
|
94
|
-
*/
|
|
95
|
-
reset(): void;
|
|
96
|
-
/**
|
|
97
|
-
* Moves cursor by given step. If caching is enabled,
|
|
98
|
-
* cursor can move both forward and backward. Otherwise it throws error.
|
|
99
|
-
*/
|
|
100
|
-
seek(step: number): Promise<ObjectRow>;
|
|
101
|
-
/**
|
|
102
|
-
* Creates and returns a readable stream.
|
|
103
|
-
*/
|
|
104
|
-
toStream(options?: CursorStreamOptions): CursorStream;
|
|
105
|
-
toString(): string;
|
|
106
|
-
inspect(): string;
|
|
107
|
-
/**
|
|
108
|
-
*
|
|
109
|
-
*/
|
|
110
|
-
_seek(step: number, silent?: boolean): Promise<number>;
|
|
111
|
-
/**
|
|
112
|
-
*
|
|
113
|
-
*/
|
|
114
|
-
_fetchRows(): Promise<void>;
|
|
115
|
-
}
|
|
116
|
-
export {};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { FieldInfo } from './types.js';
|
|
2
|
-
export declare class FieldInfoMap {
|
|
3
|
-
private _obj;
|
|
4
|
-
private _arr;
|
|
5
|
-
constructor();
|
|
6
|
-
add(field: FieldInfo): void;
|
|
7
|
-
get(k: string | number): FieldInfo;
|
|
8
|
-
entries(): [string, FieldInfo][];
|
|
9
|
-
keys(): string[];
|
|
10
|
-
values(): FieldInfo[];
|
|
11
|
-
toJSON(): Record<string, FieldInfo>;
|
|
12
|
-
}
|