@tsed/core 6.80.1 → 6.84.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.
@@ -1,5 +1,4 @@
1
1
  export * from "./DecoratorTypes";
2
- export * from "./Entity";
3
2
  export * from "./Env";
4
3
  export * from "./Hooks";
5
4
  export * from "./Metadata";
package/lib/index.js CHANGED
@@ -1,5 +1,25 @@
1
1
  require('reflect-metadata');
2
2
 
3
+ function _interopNamespace(e) {
4
+ if (e && e.__esModule) return e;
5
+ var n = Object.create(null);
6
+ if (e) {
7
+ Object.keys(e).forEach(function (k) {
8
+ if (k !== 'default') {
9
+ var d = Object.getOwnPropertyDescriptor(e, k);
10
+ Object.defineProperty(n, k, d.get ? d : {
11
+ enumerable: true,
12
+ get: function () {
13
+ return e[k];
14
+ }
15
+ });
16
+ }
17
+ });
18
+ }
19
+ n['default'] = e;
20
+ return n;
21
+ }
22
+
3
23
  function catchError(cb) {
4
24
  try {
5
25
  cb();
@@ -125,6 +145,18 @@ function uniqBy(list, key = "id") {
125
145
  return Array.from(map.values());
126
146
  }
127
147
 
148
+ async function importPackage(packageName, loaderFn = () => Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(packageName)); }), optional = false) {
149
+ try {
150
+ return await loaderFn();
151
+ } catch (e) {
152
+ if (!optional) {
153
+ throw new Error(`The "${packageName}\" package is missing.`);
154
+ }
155
+
156
+ return {};
157
+ }
158
+ }
159
+
128
160
  /**
129
161
  * Get the provide constructor if target is an instance.
130
162
  * @param target
@@ -240,6 +272,11 @@ function methodsOf(target) {
240
272
  function descriptorOf(target, propertyKey) {
241
273
  return Object.getOwnPropertyDescriptor(target && target.prototype || target, propertyKey);
242
274
  }
275
+ function isMethodDescriptor(target, propertyKey) {
276
+ var _descriptorOf;
277
+
278
+ return (_descriptorOf = descriptorOf(target, propertyKey)) == null ? void 0 : _descriptorOf.value;
279
+ }
243
280
 
244
281
  exports.DecoratorTypes = void 0;
245
282
 
@@ -1689,121 +1726,6 @@ function toMap(input, keyOrFn) {
1689
1726
  }, new Map());
1690
1727
  }
1691
1728
 
1692
- class Entity {
1693
- constructor({
1694
- target,
1695
- propertyKey,
1696
- descriptor,
1697
- index
1698
- }) {
1699
- this._target = target;
1700
- this.propertyKey = propertyKey;
1701
- this.propertyName = String(propertyKey);
1702
- this.descriptor = descriptor;
1703
- this.index = index;
1704
- this.decoratorType = decoratorTypeOf([target, propertyKey, descriptor || index]);
1705
- this.token = target && classOf(target);
1706
- }
1707
- /**
1708
- * Reference to the class
1709
- */
1710
-
1711
-
1712
- get target() {
1713
- return this._target;
1714
- }
1715
- /**
1716
- * Return the class name of the entity.
1717
- * @returns {string}
1718
- */
1719
-
1720
-
1721
- get targetName() {
1722
- return nameOf(this.token);
1723
- }
1724
- /**
1725
- *
1726
- * @returns {Type<any>}
1727
- */
1728
-
1729
-
1730
- get type() {
1731
- return this._type;
1732
- }
1733
- /**
1734
- * Get original type without transformation
1735
- * @param value
1736
- */
1737
-
1738
-
1739
- set type(value) {
1740
- this._type = value;
1741
- }
1742
- /**
1743
- * Return the itemSchema target type. if the type is a function used for recursive model, the function will be called to
1744
- * get the right type.
1745
- */
1746
-
1747
-
1748
- get computedType() {
1749
- return this._type;
1750
- }
1751
- /**
1752
- *
1753
- * @returns {boolean}
1754
- */
1755
-
1756
-
1757
- get isCollection() {
1758
- return !!this.collectionType;
1759
- }
1760
- /**
1761
- *
1762
- * @returns {boolean}
1763
- */
1764
-
1765
-
1766
- get isArray() {
1767
- return isArrayOrArrayClass(this.collectionType);
1768
- }
1769
- /**
1770
- *
1771
- * @returns {boolean}
1772
- */
1773
-
1774
-
1775
- get isPrimitive() {
1776
- return isPrimitiveOrPrimitiveClass(this._type);
1777
- }
1778
- /**
1779
- *
1780
- * @returns {boolean}
1781
- */
1782
-
1783
-
1784
- get isDate() {
1785
- return isDate(this.computedType);
1786
- }
1787
- /**
1788
- *
1789
- * @returns {boolean}
1790
- */
1791
-
1792
-
1793
- get isObject() {
1794
- return isObject(this.computedType);
1795
- }
1796
- /**
1797
- *
1798
- */
1799
-
1800
-
1801
- get isClass() {
1802
- return isClass(this.computedType);
1803
- }
1804
-
1805
- }
1806
-
1807
1729
  /**
1808
1730
  *
1809
1731
  */
@@ -2303,7 +2225,6 @@ exports.AnyToPromise = AnyToPromise;
2303
2225
  exports.CLASS_STORE = CLASS_STORE;
2304
2226
  exports.Configurable = Configurable;
2305
2227
  exports.Deprecated = Deprecated;
2306
- exports.Entity = Entity;
2307
2228
  exports.Enumerable = Enumerable;
2308
2229
  exports.EnvTypes = EnvTypes;
2309
2230
  exports.Hooks = Hooks;
@@ -2342,6 +2263,7 @@ exports.getConstructorArgNames = getConstructorArgNames;
2342
2263
  exports.getEnumerableKeys = getEnumerableKeys;
2343
2264
  exports.getInheritedClass = getInheritedClass;
2344
2265
  exports.getValue = getValue;
2266
+ exports.importPackage = importPackage;
2345
2267
  exports.inheritedDescriptorOf = inheritedDescriptorOf;
2346
2268
  exports.isArray = isArray;
2347
2269
  exports.isArrayOrArrayClass = isArrayOrArrayClass;
@@ -2356,6 +2278,7 @@ exports.isEmpty = isEmpty;
2356
2278
  exports.isEnumerable = isEnumerable;
2357
2279
  exports.isFunction = isFunction;
2358
2280
  exports.isInheritedFrom = isInheritedFrom;
2281
+ exports.isMethodDescriptor = isMethodDescriptor;
2359
2282
  exports.isNil = isNil;
2360
2283
  exports.isNumber = isNumber;
2361
2284
  exports.isNumberOrNumberClass = isNumberOrNumberClass;