@sqb/connect 4.10.6 → 4.11.1

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/README.md CHANGED
@@ -1,10 +1,9 @@
1
-
2
1
  <p style="text-align:center">
3
2
  <img src="https://user-images.githubusercontent.com/3836517/32965280-1a2b63ce-cbe7-11e7-8ee1-ba47313503c5.png" width="500px" alt="SQB Logo"/>
4
3
  </p>
5
4
 
6
5
  <br>
7
-
6
+
8
7
  [![NPM Version][npm-image]][npm-url]
9
8
  [![NPM Downloads][downloads-image]][downloads-url]
10
9
  [![Build Status][travis-image]][travis-url]
@@ -13,7 +12,6 @@
13
12
  [![DevDependencies][devdependencies-image]][devdependencies-url]
14
13
  [![Package Quality][quality-image]][quality-url]
15
14
 
16
-
17
15
  ## About SQB
18
16
 
19
17
  SQB is an extensible, multi-dialect SQL query builder and Database connection wrapper for NodeJS.
@@ -25,8 +23,7 @@ SQB is an extensible, multi-dialect SQL query builder and Database connection wr
25
23
  - Fast applications with low memory requirements
26
24
  - Let applications work with large data tables efficiently
27
25
  - Support latest JavaScript language standards
28
- - Lightweight and extensible framework.
29
-
26
+ - Lightweight and extensible framework.
30
27
 
31
28
  You can report bugs and discuss features on the [GitHub issues](https://github.com/sqbjs/sqb/issues) page
32
29
 
@@ -34,7 +31,6 @@ Thanks to all of the great [contributions](https://github.com/sqbjs/sqb/graphs/c
34
31
 
35
32
  You may want to check detailed [DOCUMENTATION](https://sqbjs.github.io/sqb/)
36
33
 
37
-
38
34
  ## Installation
39
35
 
40
36
  ```bash
@@ -43,25 +39,40 @@ $ npm install @sqb/connect --save
43
39
 
44
40
  ## Node Compatibility
45
41
 
46
- - node >= 16.x
47
-
48
-
42
+ - node >= 16.x
43
+
49
44
  ### License
45
+
50
46
  SQB is available under [MIT](LICENSE) license.
51
47
 
52
48
  [npm-image]: https://img.shields.io/npm/v/@sqb/connect.svg
49
+
53
50
  [npm-url]: https://npmjs.org/package/@sqb/connect
51
+
54
52
  [travis-image]: https://img.shields.io/travis/sqbjs/@sqb/connect/master.svg
53
+
55
54
  [travis-url]: https://travis-ci.org/sqbjs/@sqb/connect
55
+
56
56
  [coveralls-image]: https://img.shields.io/coveralls/sqbjs/@sqb/connect/master.svg
57
+
57
58
  [coveralls-url]: https://coveralls.io/r/sqbjs/@sqb/connect
59
+
58
60
  [downloads-image]: https://img.shields.io/npm/dm/@sqb/connect.svg
61
+
59
62
  [downloads-url]: https://npmjs.org/package/@sqb/connect
63
+
60
64
  [gitter-image]: https://badges.gitter.im/sqbjs/@sqb/connect.svg
65
+
61
66
  [gitter-url]: https://gitter.im/sqbjs/@sqb/connect?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
67
+
62
68
  [dependencies-image]: https://david-dm.org/sqbjs/@sqb/connect/status.svg
69
+
63
70
  [dependencies-url]:https://david-dm.org/sqbjs/@sqb/connect
71
+
64
72
  [devdependencies-image]: https://david-dm.org/sqbjs/@sqb/connect/dev-status.svg
73
+
65
74
  [devdependencies-url]:https://david-dm.org/sqbjs/@sqb/connect?type=dev
75
+
66
76
  [quality-image]: http://npm.packagequality.com/shield/@sqb/connect.png
77
+
67
78
  [quality-url]: http://packagequality.com/#?package=@sqb/connect
package/cjs/index.js CHANGED
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isEntityClass = exports.isAssociationField = exports.isEmbeddedField = exports.isColumnField = exports.unRegisterAdapter = exports.registerAdapter = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  require("reflect-metadata");
6
- tslib_1.__exportStar(require("./types.js"), exports);
7
6
  tslib_1.__exportStar(require("./client/types.js"), exports);
8
7
  tslib_1.__exportStar(require("./client/adapter.js"), exports);
9
8
  tslib_1.__exportStar(require("./client/sqb-client.js"), exports);
@@ -70,7 +70,7 @@ class CreateCommand {
70
70
  }
71
71
  column_field_metadata_js_1.ColumnFieldMetadata.checkEnumValue(col, v);
72
72
  const fieldName = prefix + col.fieldName + suffix;
73
- const k = '$input_' + fieldName;
73
+ const k = ('I$_' + fieldName).substring(0, 30);
74
74
  ctx.queryValues[fieldName] = (0, builder_1.Param)({
75
75
  name: k,
76
76
  dataType: col.dataType,
@@ -65,7 +65,7 @@ class UpdateCommand {
65
65
  continue;
66
66
  column_field_metadata_js_1.ColumnFieldMetadata.checkEnumValue(col, v);
67
67
  const fieldName = prefix + col.fieldName + suffix;
68
- const k = '$input_' + fieldName;
68
+ const k = ('I$_' + fieldName).substring(0, 30);
69
69
  ctx.queryValues[fieldName] = (0, builder_1.Param)({
70
70
  name: k,
71
71
  dataType: col.dataType,
@@ -47,7 +47,11 @@ class Repository extends (0, strict_typed_events_1.TypedEventEmitterClass)(stric
47
47
  return this._count({ ...options, connection });
48
48
  }, options);
49
49
  }
50
+ /** @deprecated - Use findById instead */
50
51
  find(keyValue, options) {
52
+ return this.findById(keyValue, options);
53
+ }
54
+ findById(keyValue, options) {
51
55
  return this._execute(async (connection) => {
52
56
  return this._find(keyValue, { ...options, connection });
53
57
  }, options);
@@ -93,34 +97,6 @@ class Repository extends (0, strict_typed_events_1.TypedEventEmitterClass)(stric
93
97
  return this._updateMany(values, { ...options, connection });
94
98
  });
95
99
  }
96
- /**
97
- *
98
- * @deprecated
99
- */
100
- destroy(keyValue, options) {
101
- return this.deleteOne(keyValue, options);
102
- }
103
- /**
104
- *
105
- * @deprecated
106
- */
107
- destroyAll(options) {
108
- return this.deleteMany(options);
109
- }
110
- /**
111
- *
112
- * @deprecated
113
- */
114
- findAll(options) {
115
- return this.findMany(options);
116
- }
117
- /**
118
- *
119
- * @deprecated
120
- */
121
- updateAll(values, options) {
122
- return this.updateMany(values, options);
123
- }
124
100
  async _execute(fn, opts) {
125
101
  let connection = opts?.connection;
126
102
  if (!connection && this._executor instanceof sqb_connection_js_1.SqbConnection)
package/esm/index.js CHANGED
@@ -1,5 +1,4 @@
1
1
  import 'reflect-metadata';
2
- export * from './types.js';
3
2
  export * from './client/types.js';
4
3
  export * from './client/adapter.js';
5
4
  export * from './client/sqb-client.js';
@@ -67,7 +67,7 @@ export class CreateCommand {
67
67
  }
68
68
  ColumnFieldMetadata.checkEnumValue(col, v);
69
69
  const fieldName = prefix + col.fieldName + suffix;
70
- const k = '$input_' + fieldName;
70
+ const k = ('I$_' + fieldName).substring(0, 30);
71
71
  ctx.queryValues[fieldName] = Param({
72
72
  name: k,
73
73
  dataType: col.dataType,
@@ -62,7 +62,7 @@ export class UpdateCommand {
62
62
  continue;
63
63
  ColumnFieldMetadata.checkEnumValue(col, v);
64
64
  const fieldName = prefix + col.fieldName + suffix;
65
- const k = '$input_' + fieldName;
65
+ const k = ('I$_' + fieldName).substring(0, 30);
66
66
  ctx.queryValues[fieldName] = Param({
67
67
  name: k,
68
68
  dataType: col.dataType,
@@ -44,7 +44,11 @@ export class Repository extends TypedEventEmitterClass(AsyncEventEmitter) {
44
44
  return this._count({ ...options, connection });
45
45
  }, options);
46
46
  }
47
+ /** @deprecated - Use findById instead */
47
48
  find(keyValue, options) {
49
+ return this.findById(keyValue, options);
50
+ }
51
+ findById(keyValue, options) {
48
52
  return this._execute(async (connection) => {
49
53
  return this._find(keyValue, { ...options, connection });
50
54
  }, options);
@@ -90,34 +94,6 @@ export class Repository extends TypedEventEmitterClass(AsyncEventEmitter) {
90
94
  return this._updateMany(values, { ...options, connection });
91
95
  });
92
96
  }
93
- /**
94
- *
95
- * @deprecated
96
- */
97
- destroy(keyValue, options) {
98
- return this.deleteOne(keyValue, options);
99
- }
100
- /**
101
- *
102
- * @deprecated
103
- */
104
- destroyAll(options) {
105
- return this.deleteMany(options);
106
- }
107
- /**
108
- *
109
- * @deprecated
110
- */
111
- findAll(options) {
112
- return this.findMany(options);
113
- }
114
- /**
115
- *
116
- * @deprecated
117
- */
118
- updateAll(values, options) {
119
- return this.updateMany(values, options);
120
- }
121
97
  async _execute(fn, opts) {
122
98
  let connection = opts?.connection;
123
99
  if (!connection && this._executor instanceof SqbConnection)
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.10.6",
4
+ "version": "4.11.1",
5
5
  "author": "Panates",
6
6
  "contributors": [
7
7
  "Eray Hanoglu <e.hanoglu@panates.com>",
@@ -24,7 +24,7 @@
24
24
  "build:cjs": "tsc -b tsconfig-build-cjs.json",
25
25
  "build:esm": "tsc -b tsconfig-build-esm.json",
26
26
  "postbuild": "cp README.md package.json ../../LICENSE ../../build/connect && cp ../../package.cjs.json ../../build/connect/cjs/package.json",
27
- "lint": "eslint .",
27
+ "lint": "eslint . --max-warnings=0",
28
28
  "test": "jest",
29
29
  "cover": "jest --collect-coverage",
30
30
  "clean": "npm run clean:src | npm run clean:dist | npm run clean:cover",
@@ -36,21 +36,21 @@
36
36
  "debug": "^4.3.4",
37
37
  "lightning-pool": "^4.2.2",
38
38
  "lodash": "^4.17.21",
39
- "power-tasks": "^1.7.2",
39
+ "power-tasks": "^1.7.3",
40
40
  "putil-isplainobject": "^1.1.5",
41
41
  "putil-merge": "^3.12.1",
42
42
  "putil-promisify": "^1.10.1",
43
43
  "putil-varhelpers": "^1.6.5",
44
- "reflect-metadata": "^0.1.13",
45
- "strict-typed-events": "^2.3.2",
46
- "ts-gems": "^2.7.1"
44
+ "reflect-metadata": "^0.1.14",
45
+ "strict-typed-events": "^2.3.3",
46
+ "ts-gems": "^3.2.1"
47
47
  },
48
48
  "devDependencies": {
49
49
  "@types/debug": "^4.1.12",
50
- "@types/lodash": "^4.14.202"
50
+ "@types/lodash": "^4.17.0"
51
51
  },
52
52
  "peerDependencies": {
53
- "@sqb/builder": "^4.10.6"
53
+ "@sqb/builder": "^4.11.1"
54
54
  },
55
55
  "engines": {
56
56
  "node": ">=16.0",
package/types/index.d.ts CHANGED
@@ -1,7 +1,4 @@
1
1
  import 'reflect-metadata';
2
- import { DeepBuildable, DeepPartial, DeepPickWritable, Maybe, Type } from 'ts-gems';
3
- export { Type, Maybe, DeepPartial, DeepPickWritable, DeepBuildable };
4
- export * from './types.js';
5
2
  export * from './client/types.js';
6
3
  export * from './client/adapter.js';
7
4
  export * from './client/sqb-client.js';
@@ -1,8 +1,8 @@
1
- import { PickWritable, Type } from 'ts-gems';
1
+ import { MutableKeys, Type } from 'ts-gems';
2
2
  import { Entity } from './decorators/entity.decorator.js';
3
- export declare function getInsertColumnNames<T, K extends keyof PickWritable<T>>(ctor: Type<T>): K[];
4
- export declare function getUpdateColumnNames<T, K extends keyof PickWritable<T>>(ctor: Type<T>): K[];
5
- export declare function getNonAssociationElementNames<T, K extends keyof PickWritable<T>>(ctor: Type<T>): K[];
3
+ export declare function getInsertColumnNames<T, K extends MutableKeys<T>>(ctor: Type<T>): K[];
4
+ export declare function getUpdateColumnNames<T, K extends MutableKeys<T>>(ctor: Type<T>): K[];
5
+ export declare function getNonAssociationElementNames<T, K extends MutableKeys<T>>(ctor: Type<T>): K[];
6
6
  export declare function mixinEntities<A, B>(derivedCtor: Type<A>, baseB: Type<B>): Type<A & B>;
7
7
  export declare function mixinEntities<A, B, C>(derivedCtor: Type<A>, baseB: Type<B>, baseC: Type<C>): Type<A & B & C>;
8
8
  export declare function mixinEntities<A, B, C, D>(derivedCtor: Type<A>, baseB: Type<B>, baseC: Type<C>, baseD: Type<D>): Type<A & B & C & D>;
@@ -1,9 +1,8 @@
1
- import { StrictOmit, Type } from 'ts-gems';
1
+ import { PartialDTO, PatchDTO, StrictOmit, Type } from 'ts-gems';
2
2
  import { FieldInfoMap } from '../client/field-info-map.js';
3
3
  import { SqbClient } from '../client/sqb-client.js';
4
4
  import { SqbConnection } from '../client/sqb-connection.js';
5
5
  import { QueryRequest, TransactionFunction } from '../client/types.js';
6
- import { EntityInput, EntityOutput } from '../types.js';
7
6
  import { EntityMetadata } from './model/entity-metadata.js';
8
7
  interface Projection {
9
8
  pick?: string[];
@@ -46,18 +45,6 @@ export declare namespace Repository {
46
45
  }
47
46
  interface UpdateManyOptions extends CommandOptions, Filtering {
48
47
  }
49
- /**
50
- * @deprecated
51
- */
52
- type FindAllOptions = FindManyOptions;
53
- /**
54
- * @deprecated
55
- */
56
- type DestroyOptions = DeleteOptions;
57
- /**
58
- * @deprecated
59
- */
60
- type UpdateAllOptions = UpdateManyOptions;
61
48
  }
62
49
  interface RepositoryEvents {
63
50
  execute: (request: QueryRequest) => void;
@@ -72,40 +59,22 @@ export declare class Repository<T> extends Repository_base {
72
59
  constructor(entityDef: EntityMetadata, executor: SqbClient | SqbConnection, schema?: string);
73
60
  get entity(): EntityMetadata;
74
61
  get type(): Type<T>;
75
- create(values: EntityInput<T>, options?: Repository.CreateOptions): Promise<EntityOutput<T>>;
76
- createOnly(values: EntityInput<T>, options?: StrictOmit<Repository.CreateOptions, keyof Projection>): Promise<void>;
62
+ create(values: PartialDTO<T>, options?: Repository.CreateOptions): Promise<PartialDTO<T>>;
63
+ createOnly(values: PartialDTO<T>, options?: StrictOmit<Repository.CreateOptions, keyof Projection>): Promise<void>;
77
64
  exists(keyValue: any | Record<string, any>, options?: Repository.ExistsOptions): Promise<boolean>;
78
65
  count(options?: Repository.CountOptions): Promise<number>;
79
- find(keyValue: any | Record<string, any>, options?: Repository.FindOptions): Promise<EntityOutput<T> | undefined>;
80
- findOne(options?: Repository.FindOneOptions): Promise<EntityOutput<T> | undefined>;
81
- findMany(options?: Repository.FindManyOptions): Promise<EntityOutput<T>[]>;
66
+ /** @deprecated - Use findById instead */
67
+ find(keyValue: any | Record<string, any>, options?: Repository.FindOptions): Promise<PartialDTO<T> | undefined>;
68
+ findById(keyValue: any | Record<string, any>, options?: Repository.FindOptions): Promise<PartialDTO<T> | undefined>;
69
+ findOne(options?: Repository.FindOneOptions): Promise<PartialDTO<T> | undefined>;
70
+ findMany(options?: Repository.FindManyOptions): Promise<PartialDTO<T>[]>;
82
71
  delete(keyValue: any | Record<string, any>, options?: Repository.DeleteOptions): Promise<boolean>;
83
72
  deleteMany(options?: Repository.DeleteManyOptions): Promise<number>;
84
- update(keyValue: any | Record<string, any>, values: EntityInput<T>, options?: Repository.UpdateOptions): Promise<EntityOutput<T> | undefined>;
85
- updateOnly(keyValue: any | Record<string, any>, values: EntityInput<T>, options?: StrictOmit<Repository.UpdateOptions, keyof Projection>): Promise<boolean>;
86
- updateMany(values: EntityInput<T>, options?: Repository.UpdateManyOptions): Promise<number>;
87
- /**
88
- *
89
- * @deprecated
90
- */
91
- destroy(keyValue: any | Record<string, any>, options?: Repository.DeleteOptions): Promise<boolean>;
92
- /**
93
- *
94
- * @deprecated
95
- */
96
- destroyAll(options?: Repository.DeleteManyOptions): Promise<number>;
97
- /**
98
- *
99
- * @deprecated
100
- */
101
- findAll(options?: Repository.FindManyOptions): Promise<EntityOutput<T>[]>;
102
- /**
103
- *
104
- * @deprecated
105
- */
106
- updateAll(values: EntityInput<T>, options?: Repository.UpdateManyOptions): Promise<number>;
73
+ update(keyValue: any | Record<string, any>, values: PatchDTO<T>, options?: Repository.UpdateOptions): Promise<PartialDTO<T> | undefined>;
74
+ updateOnly(keyValue: any | Record<string, any>, values: PatchDTO<T>, options?: StrictOmit<Repository.UpdateOptions, keyof Projection>): Promise<boolean>;
75
+ updateMany(values: PartialDTO<T>, options?: Repository.UpdateManyOptions): Promise<number>;
107
76
  protected _execute(fn: TransactionFunction, opts?: Repository.CommandOptions): Promise<any>;
108
- protected _create(values: EntityInput<T>, options: Repository.CreateOptions & {
77
+ protected _create(values: PartialDTO<T>, options: Repository.CreateOptions & {
109
78
  connection: SqbConnection;
110
79
  returning?: boolean;
111
80
  }): Promise<any>;
@@ -117,23 +86,23 @@ export declare class Repository<T> extends Repository_base {
117
86
  }): Promise<number>;
118
87
  protected _findMany(options: Repository.FindManyOptions & {
119
88
  connection: SqbConnection;
120
- }): Promise<EntityOutput<T>[]>;
89
+ }): Promise<PartialDTO<T>[]>;
121
90
  protected _findOne(options: Repository.FindOneOptions & {
122
91
  connection: SqbConnection;
123
- }): Promise<EntityOutput<T> | undefined>;
92
+ }): Promise<PartialDTO<T> | undefined>;
124
93
  protected _find(keyValue: any | Record<string, any>, options: Repository.FindOptions & {
125
94
  connection: SqbConnection;
126
- }): Promise<EntityOutput<T> | undefined>;
95
+ }): Promise<PartialDTO<T> | undefined>;
127
96
  protected _delete(keyValue: any | Record<string, any>, options: Repository.DeleteOptions & {
128
97
  connection: SqbConnection;
129
98
  }): Promise<boolean>;
130
99
  protected _deleteMany(options: Repository.DeleteManyOptions & {
131
100
  connection: SqbConnection;
132
101
  }): Promise<number>;
133
- protected _update(keyValue: any | Record<string, any>, values: EntityInput<T>, options: Repository.UpdateOptions & {
102
+ protected _update(keyValue: any | Record<string, any>, values: PatchDTO<T>, options: Repository.UpdateOptions & {
134
103
  connection: SqbConnection;
135
104
  }): Promise<Record<string, any> | undefined>;
136
- protected _updateMany(values: EntityInput<T>, options: Repository.UpdateManyOptions & {
105
+ protected _updateMany(values: PartialDTO<T>, options: Repository.UpdateManyOptions & {
137
106
  connection: SqbConnection;
138
107
  }): Promise<number>;
139
108
  }
package/cjs/types.js DELETED
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
package/esm/types.js DELETED
@@ -1 +0,0 @@
1
- export {};
package/types/types.d.ts DELETED
@@ -1,5 +0,0 @@
1
- import { DeepPickWritable, HighDeepNullish } from 'ts-gems';
2
- export type PartialInput<T> = HighDeepNullish<DeepPickWritable<T>>;
3
- export type PartialOutput<T> = HighDeepNullish<T>;
4
- export type EntityInput<T> = PartialInput<T>;
5
- export type EntityOutput<T> = PartialOutput<T>;