@tsed/di 6.75.11 → 6.77.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.
@@ -1,5 +1,6 @@
1
1
  import { getClassOrSymbol, Store, isClass, classOf, nameOf, StoreSet, decoratorTypeOf, UnsupportedDecoratorType, DecoratorTypes, Metadata, useDecorators, isArrayOrArrayClass, isString, getConstructorArgNames, proxyDelegation, setValue, getValue, deepMerge, deepClone, ancestorsOf, prototypeOf, isPromise, catchError, isInheritedFrom, isFunction, Env } from '@tsed/core';
2
2
  import { levels, Logger, $log } from '@tsed/logger';
3
+ import { Path, Children } from '@tsed/schema';
3
4
  import { __decorate, __metadata } from 'tslib';
4
5
  import chalk from 'chalk';
5
6
 
@@ -125,6 +126,14 @@ class Provider {
125
126
  get store() {
126
127
  return this._store;
127
128
  }
129
+
130
+ get path() {
131
+ return this.store.get("path", "/");
132
+ }
133
+
134
+ set path(path) {
135
+ this.store.set("path", path);
136
+ }
128
137
  /**
129
138
  * Get the scope of the provider.
130
139
  *
@@ -161,6 +170,10 @@ class Provider {
161
170
  this.store.set("configuration", configuration);
162
171
  }
163
172
 
173
+ get children() {
174
+ return this.store.get("childrenControllers", []);
175
+ }
176
+
164
177
  get(key) {
165
178
  return this.store.get(key) || this._tokenStore.get(key);
166
179
  }
@@ -172,6 +185,24 @@ class Provider {
172
185
  clone() {
173
186
  return new (classOf(this))(this._provide, this);
174
187
  }
188
+ /**
189
+ *
190
+ * @returns {boolean}
191
+ */
192
+
193
+
194
+ hasChildren() {
195
+ return !!this.children.length;
196
+ }
197
+ /**
198
+ *
199
+ * @returns {boolean}
200
+ */
201
+
202
+
203
+ hasParent() {
204
+ return !!this.store.get("parentController");
205
+ }
175
206
 
176
207
  toString() {
177
208
  return ["Token", this.name, this.useClass && nameOf(this.useClass), this.useFactory && "Factory", this.useValue && "Value", this.useAsyncFactory && "AsyncFactory"].filter(Boolean).join(":");
@@ -1222,7 +1253,7 @@ function UseOpts(options) {
1222
1253
  };
1223
1254
  }
1224
1255
 
1225
- const _excluded = ["children"];
1256
+ const _excluded = ["children", "path"];
1226
1257
 
1227
1258
  function mapOptions(options) {
1228
1259
  if (typeof options === "string" || options instanceof RegExp || isArrayOrArrayClass(options)) {
@@ -1266,19 +1297,16 @@ function mapOptions(options) {
1266
1297
  function Controller(options) {
1267
1298
  const _mapOptions = mapOptions(options),
1268
1299
  {
1269
- children = []
1300
+ children = [],
1301
+ path
1270
1302
  } = _mapOptions,
1271
1303
  opts = _objectWithoutPropertiesLoose(_mapOptions, _excluded);
1272
1304
 
1273
- return target => {
1305
+ return useDecorators(target => {
1274
1306
  registerController(_extends({
1275
1307
  provide: target
1276
1308
  }, opts));
1277
- Store.from(target).set("childrenControllers", children);
1278
- children.forEach(childToken => {
1279
- Store.from(childToken).set("parentController", target);
1280
- });
1281
- };
1309
+ }, path && Path(path), Children(...children));
1282
1310
  }
1283
1311
 
1284
1312
  class InjectionError extends Error {
@@ -1767,6 +1795,7 @@ let InjectorService = InjectorService_1 = class InjectorService extends Containe
1767
1795
 
1768
1796
 
1769
1797
  locals = this.loadSync(locals);
1798
+ await locals.emit("$beforeInit");
1770
1799
  await locals.emit("$onInit");
1771
1800
  return locals;
1772
1801
  }
@@ -1782,7 +1811,7 @@ let InjectorService = InjectorService_1 = class InjectorService extends Containe
1782
1811
 
1783
1812
  const mergedConfiguration = new Map();
1784
1813
  super.forEach(provider => {
1785
- if (provider.configuration) {
1814
+ if (provider.configuration && provider.type !== "server:module") {
1786
1815
  Object.entries(provider.configuration).forEach(([key, value]) => {
1787
1816
  value = mergedConfiguration.has(key) ? deepMerge(mergedConfiguration.get(key), value) : deepClone(value);
1788
1817
  mergedConfiguration.set(key, value);