@sqb/connect 4.14.0 → 4.15.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.
Files changed (50) hide show
  1. package/cjs/client/sqb-connection.js +1 -1
  2. package/cjs/orm/repository.class.js +77 -19
  3. package/esm/client/adapter.js +2 -1
  4. package/esm/client/cursor-stream.js +9 -4
  5. package/esm/client/cursor.js +22 -17
  6. package/esm/client/extensions.js +5 -1
  7. package/esm/client/field-info-map.js +5 -1
  8. package/esm/client/helpers.js +19 -12
  9. package/esm/client/sqb-client.js +32 -27
  10. package/esm/client/sqb-connection.js +42 -37
  11. package/esm/client/types.js +5 -1
  12. package/esm/index.js +40 -32
  13. package/esm/orm/backward.js +19 -12
  14. package/esm/orm/base-entity.js +10 -6
  15. package/esm/orm/commands/command.helper.js +34 -28
  16. package/esm/orm/commands/count.command.js +10 -6
  17. package/esm/orm/commands/create.command.js +18 -14
  18. package/esm/orm/commands/delete.command.js +10 -6
  19. package/esm/orm/commands/find.command.js +34 -30
  20. package/esm/orm/commands/row-converter.js +7 -3
  21. package/esm/orm/commands/update.command.js +18 -14
  22. package/esm/orm/decorators/column.decorator.js +10 -7
  23. package/esm/orm/decorators/embedded.decorator.js +7 -4
  24. package/esm/orm/decorators/entity.decorator.js +56 -53
  25. package/esm/orm/decorators/events.decorator.js +27 -19
  26. package/esm/orm/decorators/foreignkey.decorator.js +7 -4
  27. package/esm/orm/decorators/index.decorator.js +9 -6
  28. package/esm/orm/decorators/link.decorator.js +11 -8
  29. package/esm/orm/decorators/primarykey.decorator.js +11 -8
  30. package/esm/orm/decorators/transform.decorator.js +11 -7
  31. package/esm/orm/model/association-field-metadata.js +8 -4
  32. package/esm/orm/model/association-node.js +6 -2
  33. package/esm/orm/model/association.js +20 -16
  34. package/esm/orm/model/column-field-metadata.js +8 -4
  35. package/esm/orm/model/embedded-field-metadata.js +7 -4
  36. package/esm/orm/model/entity-metadata.js +50 -47
  37. package/esm/orm/model/field-metadata.js +2 -1
  38. package/esm/orm/model/index-metadata.js +2 -1
  39. package/esm/orm/model/link-chain.js +8 -4
  40. package/esm/orm/orm.const.js +6 -3
  41. package/esm/orm/orm.type.js +2 -1
  42. package/esm/orm/repository.class.js +103 -41
  43. package/esm/orm/util/apply-mixins.js +4 -1
  44. package/esm/orm/util/extract-keyvalues.js +9 -6
  45. package/esm/orm/util/orm.helper.js +20 -10
  46. package/esm/orm/util/parse-fields-projection.js +11 -6
  47. package/esm/orm/util/serialize-field.js +13 -10
  48. package/package.json +30 -24
  49. package/types/orm/repository.class.d.ts +110 -11
  50. package/cjs/package.json +0 -3
@@ -1,12 +1,19 @@
1
- import { AsyncEventEmitter, TypedEventEmitterClass } from 'strict-typed-events';
2
- import { SqbConnection } from '../client/sqb-connection.js';
3
- import { CountCommand } from './commands/count.command.js';
4
- import { CreateCommand } from './commands/create.command.js';
5
- import { DeleteCommand } from './commands/delete.command.js';
6
- import { FindCommand } from './commands/find.command.js';
7
- import { UpdateCommand } from './commands/update.command.js';
8
- import { extractKeyValues } from './util/extract-keyvalues.js';
9
- export class Repository extends TypedEventEmitterClass(AsyncEventEmitter) {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Repository = void 0;
4
+ const strict_typed_events_1 = require("strict-typed-events");
5
+ const sqb_connection_js_1 = require("../client/sqb-connection.js");
6
+ const count_command_js_1 = require("./commands/count.command.js");
7
+ const create_command_js_1 = require("./commands/create.command.js");
8
+ const delete_command_js_1 = require("./commands/delete.command.js");
9
+ const find_command_js_1 = require("./commands/find.command.js");
10
+ const update_command_js_1 = require("./commands/update.command.js");
11
+ const extract_keyvalues_js_1 = require("./util/extract-keyvalues.js");
12
+ /**
13
+ * @class Repository
14
+ * @template T - The data type class type of the record
15
+ */
16
+ class Repository extends (0, strict_typed_events_1.TypedEventEmitterClass)(strict_typed_events_1.AsyncEventEmitter) {
10
17
  constructor(entityDef, executor, schema) {
11
18
  super();
12
19
  this._executor = executor;
@@ -19,29 +26,74 @@ export class Repository extends TypedEventEmitterClass(AsyncEventEmitter) {
19
26
  get type() {
20
27
  return this._entity.ctor;
21
28
  }
22
- create(values, options) {
29
+ create(input, options) {
23
30
  return this._execute(async (connection) => {
24
- const keyValue = await this._create(values, { ...options, connection, returning: true });
31
+ const keyValue = await this._create(input, { ...options, connection, returning: true });
25
32
  const result = keyValue && (await this._find(keyValue, { ...options, connection }));
26
33
  if (!result)
27
34
  throw new Error('Unable to insert new row');
28
35
  return result;
29
36
  }, options);
30
37
  }
31
- createOnly(values, options) {
38
+ /**
39
+ * Creates a new resource but returns nothing
40
+ *
41
+ * @param {PartialDTO<T>} input - The input data
42
+ * @param {Repository.CreateOptions} [options] - The options object
43
+ * @throws {Error} if an unknown error occurs while creating the resource
44
+ */
45
+ createOnly(input, options) {
32
46
  return this._execute(async (connection) => {
33
- await this._create(values, { ...options, connection, returning: false });
47
+ await this._create(input, { ...options, connection, returning: false });
34
48
  }, options);
35
49
  }
50
+ /**
51
+ * Returns the count of records based on the provided options
52
+ *
53
+ * @param {Repository.CountOptions} options - The options for the count operation.
54
+ * @return {Promise<number>} - A promise that resolves to the count of records
55
+ */
56
+ count(options) {
57
+ return this._execute(async (connection) => this._count({ ...options, connection }), options);
58
+ }
59
+ /**
60
+ * Deletes a record from the collection.
61
+ *
62
+ * @param {any} keyValue - The ID of the resource to delete.
63
+ * @param {Repository.DeleteOptions} [options] - Optional delete options.
64
+ * @return {Promise<boolean>} - A Promise that resolves true or false. True when resource deleted.
65
+ */
66
+ delete(keyValue, options) {
67
+ return this._execute(async (connection) => this._delete(keyValue, { ...options, connection }), options);
68
+ }
69
+ /**
70
+ * Deletes multiple documents from the collection that meet the specified filter criteria.
71
+ *
72
+ * @param {Repository.DeleteManyOptions} options - The options for the delete operation.
73
+ * @return {Promise<number>} - A promise that resolves to the number of resources deleted.
74
+ */
75
+ deleteMany(options) {
76
+ return this._execute(async (connection) => this._deleteMany({ ...options, connection }), options);
77
+ }
78
+ /**
79
+ * Checks if a record with the given id exists.
80
+ *
81
+ * @param {any} keyValue - The id of the object to check.
82
+ * @param {Repository.ExistsOptions} [options] - The options for the query (optional).
83
+ * @return {Promise<boolean>} - A Promise that resolves to a boolean indicating whether the record exists or not.
84
+ */
36
85
  exists(keyValue, options) {
37
86
  return this._execute(async (connection) => this._exists(keyValue, { ...options, connection }), options);
38
87
  }
88
+ /**
89
+ * Checks if a record with the given arguments exists.
90
+ *
91
+ * @param {Repository.ExistsOptions} [options] - The options for the query (optional).
92
+ * @return {Promise<boolean>} - A Promise that resolves to a boolean indicating whether the record exists or not.
93
+ */
39
94
  existsOne(options) {
40
95
  return this._execute(async (connection) => this._existsOne({ ...options, connection }), options);
41
96
  }
42
- count(options) {
43
- return this._execute(async (connection) => this._count({ ...options, connection }), options);
44
- }
45
97
  findById(keyValue, options) {
46
98
  return this._execute(async (connection) => this._find(keyValue, { ...options, connection }), options);
47
99
  }
@@ -54,29 +106,38 @@ export class Repository extends TypedEventEmitterClass(AsyncEventEmitter) {
54
106
  findMany(options) {
55
107
  return this._execute(async (connection) => this._findMany({ ...options, connection }), options);
56
108
  }
57
- delete(keyValue, options) {
58
- return this._execute(async (connection) => this._delete(keyValue, { ...options, connection }), options);
59
- }
60
- deleteMany(options) {
61
- return this._execute(async (connection) => this._deleteMany({ ...options, connection }), options);
62
- }
63
- update(keyValue, values, options) {
109
+ update(keyValue, input, options) {
64
110
  return this._execute(async (connection) => {
65
111
  const opts = { ...options, connection };
66
- const keyValues = await this._update(keyValue, values, opts);
112
+ const keyValues = await this._update(keyValue, input, opts);
67
113
  if (keyValues)
68
114
  return this._find(keyValues, opts);
69
115
  }, options);
70
116
  }
71
- updateOnly(keyValue, values, options) {
72
- return this._execute(async (connection) => !!(await this._update(keyValue, values, { ...options, connection })), options);
117
+ /**
118
+ * Updates a record in the collection with the specified ID and returns updated record count
119
+ *
120
+ * @param {any} keyValue - The ID of the document to update.
121
+ * @param {PatchDTO<T>} input - The partial input data to update the document with.
122
+ * @param {Repository.UpdateOptions} options - The options for updating the document.
123
+ * @returns {Promise<number>} - A Promise that resolves true or false. True when resource updated.
124
+ */
125
+ updateOnly(keyValue, input, options) {
126
+ return this._execute(async (connection) => !!(await this._update(keyValue, input, { ...options, connection })), options);
73
127
  }
74
- updateMany(values, options) {
75
- return this._execute(async (connection) => this._updateMany(values, { ...options, connection }));
128
+ /**
129
+ * Updates multiple records in the collection based on the specified input and options.
130
+ *
131
+ * @param {PatchDTO<T>} input - The partial input to update the documents with.
132
+ * @param {Repository.UpdateManyOptions} options - The options for updating the documents.
133
+ * @return {Promise<number>} - A promise that resolves to the number of documents matched and modified.
134
+ */
135
+ updateMany(input, options) {
136
+ return this._execute(async (connection) => this._updateMany(input, { ...options, connection }));
76
137
  }
77
138
  async _execute(fn, opts) {
78
139
  let connection = opts?.connection;
79
- if (!connection && this._executor instanceof SqbConnection)
140
+ if (!connection && this._executor instanceof sqb_connection_js_1.SqbConnection)
80
141
  connection = this._executor;
81
142
  if (connection) {
82
143
  if (this._schema)
@@ -93,7 +154,7 @@ export class Repository extends TypedEventEmitterClass(AsyncEventEmitter) {
93
154
  async _create(values, options) {
94
155
  if (!values)
95
156
  throw new TypeError('You must provide values');
96
- const keyValues = await CreateCommand.execute({
157
+ const keyValues = await create_command_js_1.CreateCommand.execute({
97
158
  ...options,
98
159
  entity: this._entity,
99
160
  values,
@@ -103,7 +164,7 @@ export class Repository extends TypedEventEmitterClass(AsyncEventEmitter) {
103
164
  return keyValues;
104
165
  }
105
166
  async _exists(keyValue, options) {
106
- const filter = [extractKeyValues(this._entity, keyValue, true)];
167
+ const filter = [(0, extract_keyvalues_js_1.extractKeyValues)(this._entity, keyValue, true)];
107
168
  if (options && options.filter) {
108
169
  if (Array.isArray(options.filter))
109
170
  filter.push(...options.filter);
@@ -123,7 +184,7 @@ export class Repository extends TypedEventEmitterClass(AsyncEventEmitter) {
123
184
  else
124
185
  filter.push(options.filter);
125
186
  }
126
- const resp = await FindCommand.execute({
187
+ const resp = await find_command_js_1.FindCommand.execute({
127
188
  ...options,
128
189
  filter,
129
190
  entity: this._entity,
@@ -131,13 +192,13 @@ export class Repository extends TypedEventEmitterClass(AsyncEventEmitter) {
131
192
  return resp.length > 0;
132
193
  }
133
194
  async _count(options) {
134
- return CountCommand.execute({
195
+ return count_command_js_1.CountCommand.execute({
135
196
  ...options,
136
197
  entity: this._entity,
137
198
  });
138
199
  }
139
200
  async _findMany(options) {
140
- return await FindCommand.execute({
201
+ return await find_command_js_1.FindCommand.execute({
141
202
  ...options,
142
203
  entity: this._entity,
143
204
  });
@@ -150,7 +211,7 @@ export class Repository extends TypedEventEmitterClass(AsyncEventEmitter) {
150
211
  return rows && rows[0];
151
212
  }
152
213
  async _find(keyValue, options) {
153
- const filter = [extractKeyValues(this._entity, keyValue, true)];
214
+ const filter = [(0, extract_keyvalues_js_1.extractKeyValues)(this._entity, keyValue, true)];
154
215
  if (options && options.filter) {
155
216
  if (Array.isArray(options.filter))
156
217
  filter.push(...options.filter);
@@ -160,21 +221,21 @@ export class Repository extends TypedEventEmitterClass(AsyncEventEmitter) {
160
221
  return await this._findOne({ ...options, filter, offset: 0 });
161
222
  }
162
223
  async _delete(keyValue, options) {
163
- const filter = [extractKeyValues(this._entity, keyValue, true)];
224
+ const filter = [(0, extract_keyvalues_js_1.extractKeyValues)(this._entity, keyValue, true)];
164
225
  if (options && options.filter) {
165
226
  if (Array.isArray(options.filter))
166
227
  filter.push(...options.filter);
167
228
  else
168
229
  filter.push(options.filter);
169
230
  }
170
- return !!(await DeleteCommand.execute({
231
+ return !!(await delete_command_js_1.DeleteCommand.execute({
171
232
  ...options,
172
233
  filter,
173
234
  entity: this._entity,
174
235
  }));
175
236
  }
176
237
  async _deleteMany(options) {
177
- return DeleteCommand.execute({
238
+ return delete_command_js_1.DeleteCommand.execute({
178
239
  ...options,
179
240
  entity: this._entity,
180
241
  filter: options?.filter,
@@ -184,7 +245,7 @@ export class Repository extends TypedEventEmitterClass(AsyncEventEmitter) {
184
245
  async _update(keyValue, values, options) {
185
246
  if (!values)
186
247
  throw new TypeError('You must provide values');
187
- const keyValues = extractKeyValues(this._entity, keyValue, true);
248
+ const keyValues = (0, extract_keyvalues_js_1.extractKeyValues)(this._entity, keyValue, true);
188
249
  const filter = [keyValues];
189
250
  if (options.filter) {
190
251
  if (Array.isArray(options.filter))
@@ -194,7 +255,7 @@ export class Repository extends TypedEventEmitterClass(AsyncEventEmitter) {
194
255
  }
195
256
  const updateValues = { ...values };
196
257
  Object.keys(keyValues).forEach(k => delete updateValues[k]);
197
- const rowsAffected = await UpdateCommand.execute({
258
+ const rowsAffected = await update_command_js_1.UpdateCommand.execute({
198
259
  ...options,
199
260
  entity: this._entity,
200
261
  values: updateValues,
@@ -205,10 +266,11 @@ export class Repository extends TypedEventEmitterClass(AsyncEventEmitter) {
205
266
  async _updateMany(values, options) {
206
267
  if (!values)
207
268
  throw new TypeError('You must provide values');
208
- return await UpdateCommand.execute({
269
+ return await update_command_js_1.UpdateCommand.execute({
209
270
  ...options,
210
271
  entity: this._entity,
211
272
  values,
212
273
  });
213
274
  }
214
275
  }
276
+ exports.Repository = Repository;
@@ -1,4 +1,7 @@
1
- export function applyMixins(derivedCtor, baseCtor, filter) {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.applyMixins = applyMixins;
4
+ function applyMixins(derivedCtor, baseCtor, filter) {
2
5
  for (const name of Object.getOwnPropertyNames(baseCtor.prototype)) {
3
6
  if (name === 'constructor' ||
4
7
  name === '__proto__' ||
@@ -1,14 +1,17 @@
1
- import { EntityMetadata } from '../model/entity-metadata.js';
2
- import { isColumnField } from './orm.helper.js';
3
- export function extractKeyValues(entityDef, valueOrInstance, keepOther) {
4
- const primaryIndex = EntityMetadata.getPrimaryIndex(entityDef);
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extractKeyValues = extractKeyValues;
4
+ const entity_metadata_js_1 = require("../model/entity-metadata.js");
5
+ const orm_helper_js_1 = require("./orm.helper.js");
6
+ function extractKeyValues(entityDef, valueOrInstance, keepOther) {
7
+ const primaryIndex = entity_metadata_js_1.EntityMetadata.getPrimaryIndex(entityDef);
5
8
  if (!primaryIndex)
6
9
  throw new Error(`No primary fields defined for "${entityDef.name}" entity`);
7
10
  const validateCol = k => {
8
- const col = EntityMetadata.getField(entityDef, k);
11
+ const col = entity_metadata_js_1.EntityMetadata.getField(entityDef, k);
9
12
  if (!col)
10
13
  throw new Error(`Unknown column (${k}) defined as primary key in entity "${entityDef.name}"`);
11
- if (!isColumnField(col)) {
14
+ if (!(0, orm_helper_js_1.isColumnField)(col)) {
12
15
  throw new Error(`Column (${k}) defined as primary key in entity "${entityDef.name}" is not a data column`);
13
16
  }
14
17
  };
@@ -1,16 +1,26 @@
1
- import { ENTITY_METADATA_KEY } from '../orm.const.js';
2
- export function isClass(fn) {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isAssociationField = exports.isEmbeddedField = void 0;
4
+ exports.isClass = isClass;
5
+ exports.isEntityClass = isEntityClass;
6
+ exports.isColumnField = isColumnField;
7
+ exports.resolveEntity = resolveEntity;
8
+ exports.resolveEntityMeta = resolveEntityMeta;
9
+ const orm_const_js_1 = require("../orm.const.js");
10
+ function isClass(fn) {
3
11
  return typeof fn === 'function' && /^\s*class/.test(fn.toString());
4
12
  }
5
- export function isEntityClass(fn) {
6
- return isClass(fn) && Reflect.hasMetadata(ENTITY_METADATA_KEY, fn);
13
+ function isEntityClass(fn) {
14
+ return isClass(fn) && Reflect.hasMetadata(orm_const_js_1.ENTITY_METADATA_KEY, fn);
7
15
  }
8
- export function isColumnField(f) {
16
+ function isColumnField(f) {
9
17
  return !!(f && f.name && f.kind === 'column');
10
18
  }
11
- export const isEmbeddedField = (f) => !!(f && f.name && f.kind === 'object');
12
- export const isAssociationField = (f) => !!(f && f.name && f.kind === 'association');
13
- export async function resolveEntity(ctorThunk) {
19
+ const isEmbeddedField = (f) => !!(f && f.name && f.kind === 'object');
20
+ exports.isEmbeddedField = isEmbeddedField;
21
+ const isAssociationField = (f) => !!(f && f.name && f.kind === 'association');
22
+ exports.isAssociationField = isAssociationField;
23
+ async function resolveEntity(ctorThunk) {
14
24
  if (typeof ctorThunk !== 'function')
15
25
  return;
16
26
  if (!isClass(ctorThunk))
@@ -18,7 +28,7 @@ export async function resolveEntity(ctorThunk) {
18
28
  if (isEntityClass(ctorThunk))
19
29
  return ctorThunk;
20
30
  }
21
- export async function resolveEntityMeta(ctorThunk) {
31
+ async function resolveEntityMeta(ctorThunk) {
22
32
  const ctor = await resolveEntity(ctorThunk);
23
- return ctor && Reflect.getMetadata(ENTITY_METADATA_KEY, ctor);
33
+ return ctor && Reflect.getMetadata(orm_const_js_1.ENTITY_METADATA_KEY, ctor);
24
34
  }
@@ -1,14 +1,19 @@
1
- import { splitString } from 'fast-tokenizer';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FieldsProjection = void 0;
4
+ exports.parseFieldsProjection = parseFieldsProjection;
5
+ const fast_tokenizer_1 = require("fast-tokenizer");
2
6
  const FIELD_PATTERN = /^([+-])?([a-z_$]\w*)$/i;
3
7
  const NO_DOT_BRACKET_PATTERN = /[^.]\(/g;
4
- export class FieldsProjection {
8
+ class FieldsProjection {
5
9
  }
10
+ exports.FieldsProjection = FieldsProjection;
6
11
  (function (FieldsProjection) {
7
12
  class Item {
8
13
  }
9
14
  FieldsProjection.Item = Item;
10
- })(FieldsProjection || (FieldsProjection = {}));
11
- export function parseFieldsProjection(projection, keepCase) {
15
+ })(FieldsProjection || (exports.FieldsProjection = FieldsProjection = {}));
16
+ function parseFieldsProjection(projection, keepCase) {
12
17
  const arr = Array.isArray(projection) ? projection : [projection];
13
18
  if (!(arr && arr.length))
14
19
  return;
@@ -23,7 +28,7 @@ export function parseFieldsProjection(projection, keepCase) {
23
28
  function parse(input, target) {
24
29
  /** Add dot before brackets which is required to split fields */
25
30
  input = input.replace(NO_DOT_BRACKET_PATTERN, s => s.charAt(0) + '.' + s.substring(1));
26
- const fields = splitString(input, {
31
+ const fields = (0, fast_tokenizer_1.splitString)(input, {
27
32
  delimiters: '.',
28
33
  brackets: true,
29
34
  keepBrackets: false,
@@ -31,7 +36,7 @@ function parse(input, target) {
31
36
  for (let i = 0; i < fields.length; i++) {
32
37
  const f = fields[i];
33
38
  if (f.includes(',')) {
34
- const subFields = splitString(f, {
39
+ const subFields = (0, fast_tokenizer_1.splitString)(f, {
35
40
  delimiters: ',',
36
41
  brackets: true,
37
42
  keepBrackets: true,
@@ -1,13 +1,16 @@
1
- import { DataType } from '@sqb/builder';
2
- import { isColumnField } from './orm.helper.js';
3
- export function serializeColumn(col, v) {
4
- if (isColumnField(col)) {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.serializeColumn = serializeColumn;
4
+ const builder_1 = require("@sqb/builder");
5
+ const orm_helper_js_1 = require("./orm.helper.js");
6
+ function serializeColumn(col, v) {
7
+ if ((0, orm_helper_js_1.isColumnField)(col)) {
5
8
  if (col.isArray) {
6
9
  if (Array.isArray(v))
7
- return v.map(x => serializeDataValue(col.dataType || DataType.VARCHAR, x));
8
- return [serializeDataValue(col.dataType || DataType.VARCHAR, v)];
10
+ return v.map(x => serializeDataValue(col.dataType || builder_1.DataType.VARCHAR, x));
11
+ return [serializeDataValue(col.dataType || builder_1.DataType.VARCHAR, v)];
9
12
  }
10
- return serializeDataValue(col.dataType || DataType.VARCHAR, v);
13
+ return serializeDataValue(col.dataType || builder_1.DataType.VARCHAR, v);
11
14
  }
12
15
  if (typeof v === 'object' && typeof v.toJSON === 'function')
13
16
  return v.toJSON();
@@ -17,19 +20,19 @@ const padZero = (n) => (n < 9 ? '0' : '') + n;
17
20
  function serializeDataValue(dataType, v) {
18
21
  if (v == null)
19
22
  return;
20
- if (v instanceof Date && (dataType === DataType.DATE || dataType === DataType.TIMESTAMP)) {
23
+ if (v instanceof Date && (dataType === builder_1.DataType.DATE || dataType === builder_1.DataType.TIMESTAMP)) {
21
24
  return (v.getFullYear() +
22
25
  '-' +
23
26
  padZero(v.getMonth() + 1) +
24
27
  '-' +
25
28
  padZero(v.getDate()) +
26
- (dataType === DataType.TIMESTAMP
29
+ (dataType === builder_1.DataType.TIMESTAMP
27
30
  ? 'T' + padZero(v.getHours()) + ':' + padZero(v.getMinutes()) + ':' + padZero(v.getSeconds())
28
31
  : ''));
29
32
  }
30
33
  if (v instanceof Buffer)
31
34
  return v.toString('base64');
32
- if (typeof v === 'number' && (dataType === DataType.SMALLINT || dataType === DataType.INTEGER))
35
+ if (typeof v === 'number' && (dataType === builder_1.DataType.SMALLINT || dataType === builder_1.DataType.INTEGER))
33
36
  return Math.trunc(v);
34
37
  if (typeof v === 'bigint')
35
38
  return v.toString();
package/package.json CHANGED
@@ -1,29 +1,16 @@
1
1
  {
2
2
  "name": "@sqb/connect",
3
3
  "description": "Multi-dialect database connection framework written with TypeScript",
4
- "version": "4.14.0",
4
+ "version": "4.15.0",
5
5
  "author": "Panates",
6
- "contributors": [
7
- "Eray Hanoglu <e.hanoglu@panates.com>",
8
- "Ilker Gurelli <i.gurelli@panates.com>"
9
- ],
10
6
  "license": "Apache-2.0",
11
- "repository": {
12
- "type": "git",
13
- "url": "https://github.com/sqbjs/sqb.git",
14
- "directory": "packages/connect"
15
- },
16
- "type": "module",
17
- "module": "./esm/index.js",
18
- "main": "./cjs/index.js",
19
- "types": "./types/index.d.ts",
20
7
  "scripts": {
21
8
  "compile": "tsc",
22
9
  "prebuild": "npm run lint && npm run clean",
23
10
  "build": "npm run build:cjs && npm run build:esm",
24
11
  "build:cjs": "tsc -b tsconfig-build-cjs.json",
25
12
  "build:esm": "tsc -b tsconfig-build-esm.json",
26
- "postbuild": "cp README.md package.json ../../LICENSE ../../build/connect && cp ../../package.cjs.json ../../build/connect/cjs/package.json",
13
+ "postbuild": "cp README.md package.json ../../LICENSE ../../build/connect",
27
14
  "lint": "eslint . --max-warnings=0",
28
15
  "lint:fix": "eslint . --max-warnings=0 --fix",
29
16
  "format": "prettier . --write --log-level=warn",
@@ -35,28 +22,47 @@
35
22
  "clean:cover": "rimraf ../../coverage/connect"
36
23
  },
37
24
  "dependencies": {
38
- "debug": "^4.3.5",
25
+ "debug": "^4.3.6",
39
26
  "doublylinked": "^2.5.4",
40
- "fast-tokenizer": "^1.3.0",
41
- "lightning-pool": "^4.2.2",
27
+ "fast-tokenizer": "^1.4.0",
28
+ "lightning-pool": "^4.5.0",
42
29
  "lodash": "^4.17.21",
43
- "power-tasks": "^1.7.4",
30
+ "power-tasks": "^1.8.0",
44
31
  "putil-isplainobject": "^1.1.5",
45
- "putil-merge": "^3.12.1",
32
+ "putil-merge": "^3.13.0",
46
33
  "putil-promisify": "^1.10.1",
47
34
  "putil-varhelpers": "^1.6.5",
48
- "strict-typed-events": "^2.3.3",
49
- "ts-gems": "^3.4.0"
35
+ "strict-typed-events": "^2.5.0",
36
+ "ts-gems": "^3.5.0"
50
37
  },
51
38
  "devDependencies": {
52
39
  "@types/debug": "^4.1.12",
53
40
  "@types/lodash": "^4.17.7",
54
- "postgrejs": "^2.15.1"
41
+ "postgrejs": "^2.16.0"
55
42
  },
56
43
  "peerDependencies": {
57
- "@sqb/builder": "^4.14.0",
44
+ "@sqb/builder": "^4.15.0",
58
45
  "reflect-metadata": "^0.2.2"
59
46
  },
47
+ "main": "./cjs/index.js",
48
+ "module": "./esm/index.js",
49
+ "types": "./types/index.d.ts",
50
+ "exports": {
51
+ ".": {
52
+ "require": "./cjs/index.js",
53
+ "import": "./esm/index.js",
54
+ "types": "./types/index.d.ts"
55
+ }
56
+ },
57
+ "contributors": [
58
+ "Eray Hanoglu <e.hanoglu@panates.com>",
59
+ "Ilker Gurelli <i.gurelli@panates.com>"
60
+ ],
61
+ "repository": {
62
+ "type": "git",
63
+ "url": "https://github.com/sqbjs/sqb.git",
64
+ "directory": "packages/connect"
65
+ },
60
66
  "engines": {
61
67
  "node": ">=16.0",
62
68
  "npm": ">=7.0.0"