@sqb/connect 4.1.2 → 4.1.3

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.
@@ -3,6 +3,11 @@ import { Entity } from './decorators/entity.decorator';
3
3
  export declare function getInsertColumnNames<T, K extends keyof PickWritable<T>>(ctor: Type<T>): K[];
4
4
  export declare function getUpdateColumnNames<T, K extends keyof PickWritable<T>>(ctor: Type<T>): K[];
5
5
  export declare function getNonAssociationElementNames<T, K extends keyof PickWritable<T>>(ctor: Type<T>): K[];
6
+ export declare function mixinEntities<A, B>(derivedCtor: Type<A>, baseB: Type<B>): Type<A & B>;
7
+ export declare function mixinEntities<A, B, C>(derivedCtor: Type<A>, baseB: Type<B>, baseC: Type<C>): Type<A & B & C>;
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>;
9
+ export declare function mixinEntities<A, B, C, D, E>(derivedCtor: Type<A>, baseB: Type<B>, baseC: Type<C>, baseD: Type<D>, baseE: Type<E>): Type<A & B & C & D & E>;
10
+ export declare function mixinEntities<A, B, C, D, E, F>(derivedCtor: Type<A>, baseB: Type<B>, baseC: Type<C>, baseD: Type<D>, baseE: Type<E>, baseF: Type<F>): Type<A & B & C & D & E & F>;
6
11
  export declare const OmitEntity: typeof Entity.Omit;
7
12
  export declare const PickEntity: typeof Entity.Pick;
8
13
  export declare const UnionEntity: typeof Entity.Union;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UnionEntity = exports.PickEntity = exports.OmitEntity = exports.getNonAssociationElementNames = exports.getUpdateColumnNames = exports.getInsertColumnNames = void 0;
3
+ exports.UnionEntity = exports.PickEntity = exports.OmitEntity = exports.mixinEntities = exports.getNonAssociationElementNames = exports.getUpdateColumnNames = exports.getInsertColumnNames = void 0;
4
4
  const entity_decorator_1 = require("./decorators/entity.decorator");
5
5
  function getInsertColumnNames(ctor) {
6
6
  return entity_decorator_1.Entity.getInsertColumnNames(ctor);
@@ -14,6 +14,11 @@ function getNonAssociationElementNames(ctor) {
14
14
  return entity_decorator_1.Entity.getNonAssociationElementNames(ctor);
15
15
  }
16
16
  exports.getNonAssociationElementNames = getNonAssociationElementNames;
17
+ function mixinEntities(derivedCtor, ...bases) {
18
+ // @ts-ignore
19
+ return entity_decorator_1.Entity.mixin(derivedCtor, ...bases);
20
+ }
21
+ exports.mixinEntities = mixinEntities;
17
22
  exports.OmitEntity = entity_decorator_1.Entity.Omit;
18
23
  exports.PickEntity = entity_decorator_1.Entity.Pick;
19
24
  exports.UnionEntity = entity_decorator_1.Entity.Union;
@@ -23,6 +23,11 @@ export declare namespace Entity {
23
23
  function getUpdateColumnNames(ctor: Type): string[];
24
24
  function getPrimaryIndex(ctor: Type): Maybe<IndexMetadata>;
25
25
  function getPrimaryIndexColumns(ctor: Type): ColumnElementMetadata[];
26
+ function mixin<A, B>(derivedCtor: Type<A>, baseB: Type<B>): Type<A & B>;
27
+ function mixin<A, B, C>(derivedCtor: Type<A>, baseB: Type<B>, baseC: Type<C>): Type<A & B & C>;
28
+ function mixin<A, B, C, D>(derivedCtor: Type<A>, baseB: Type<B>, baseC: Type<C>, baseD: Type<D>): Type<A & B & C & D>;
29
+ function mixin<A, B, C, D, E>(derivedCtor: Type<A>, baseB: Type<B>, baseC: Type<C>, baseD: Type<D>, baseE: Type<E>): Type<A & B & C & D & E>;
30
+ function mixin<A, B, C, D, E, F>(derivedCtor: Type<A>, baseB: Type<B>, baseC: Type<C>, baseD: Type<D>, baseE: Type<E>, baseF: Type<F>): Type<A & B & C & D & E & F>;
26
31
  function Pick<T, K extends keyof T>(classRef: Type<T>, keys: readonly K[]): Type<Pick<T, typeof keys[number]>>;
27
32
  function Omit<T, K extends keyof T>(classRef: Type<T>, keys: readonly K[]): Type<Omit<T, typeof keys[number]>>;
28
33
  function Union<A, B>(baseA: Type<A>, baseB: Type<B>): Type<A & B>;
@@ -94,6 +94,18 @@ exports.Entity = Entity;
94
94
  return entity_metadata_1.EntityMetadata.getPrimaryIndexColumns(model);
95
95
  }
96
96
  Entity.getPrimaryIndexColumns = getPrimaryIndexColumns;
97
+ function mixin(derivedCtor, ...bases) {
98
+ const trgMeta = entity_metadata_1.EntityMetadata.inject(derivedCtor);
99
+ for (const base of bases) {
100
+ (0, apply_mixins_1.applyMixins)(derivedCtor, base);
101
+ const srcMeta = entity_metadata_1.EntityMetadata.get(base);
102
+ if (srcMeta) {
103
+ entity_metadata_1.EntityMetadata.mixin(trgMeta, srcMeta);
104
+ }
105
+ }
106
+ return derivedCtor;
107
+ }
108
+ Entity.mixin = mixin;
97
109
  function Pick(classRef, keys) {
98
110
  const PickEntityClass = class {
99
111
  constructor(...args) {
@@ -135,11 +147,11 @@ exports.Entity = Entity;
135
147
  applyConstructorProperties(this, c, args);
136
148
  }
137
149
  };
150
+ const trgMeta = entity_metadata_1.EntityMetadata.inject(UnionClass);
138
151
  for (const base of bases) {
139
152
  (0, apply_mixins_1.applyMixins)(UnionClass, base);
140
153
  const srcMeta = entity_metadata_1.EntityMetadata.get(base);
141
154
  if (srcMeta) {
142
- const trgMeta = entity_metadata_1.EntityMetadata.inject(UnionClass);
143
155
  entity_metadata_1.EntityMetadata.mixin(trgMeta, srcMeta);
144
156
  }
145
157
  }
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.1.2",
4
+ "version": "4.1.3",
5
5
  "author": "Panates",
6
6
  "contributors": [
7
7
  "Eray Hanoglu <e.hanoglu@panates.com>"
@@ -36,17 +36,17 @@
36
36
  "putil-merge": "^3.8.0",
37
37
  "putil-promisify": "^1.8.5",
38
38
  "putil-taskqueue": "^2.5.4",
39
- "putil-varhelpers": "^1.6.3",
39
+ "putil-varhelpers": "^1.6.4",
40
40
  "reflect-metadata": "^0.1.13",
41
41
  "strict-typed-events": "^2.1.0",
42
42
  "ts-gems": "^1.5.2"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@types/debug": "^4.1.7",
46
- "@types/lodash": "^4.14.180"
46
+ "@types/lodash": "^4.14.182"
47
47
  },
48
48
  "peerDependencies": {
49
- "@sqb/builder": "^4.x.x"
49
+ "@sqb/builder": "^4.1.0"
50
50
  },
51
51
  "main": "dist/index.js",
52
52
  "types": "dist/index.d.ts",
@@ -72,4 +72,4 @@
72
72
  "lint": "eslint src/** --no-error-on-unmatched-pattern",
73
73
  "test": "TS_NODE_PROJECT='./test/tsconfig.json' mocha -r ts-node/register -r tsconfig-paths/register --reporter spec test/**/*.spec.ts"
74
74
  }
75
- }
75
+ }