@adaas/a-concept 0.3.1 → 0.3.2

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.
@@ -507,7 +507,7 @@ var A_CONCEPT_BASE_ENV = class {
507
507
  * Environment of the application e.g. development, production, staging
508
508
  */
509
509
  static get A_CONCEPT_ENVIRONMENT() {
510
- return "production";
510
+ return "development";
511
511
  }
512
512
  /**
513
513
  * Runtime environment of the application e.g. browser, node
@@ -2136,6 +2136,49 @@ function A_Dependency_All() {
2136
2136
  };
2137
2137
  }
2138
2138
 
2139
+ // src/lib/A-Dependency/A-Dependency-Query.decorator.ts
2140
+ function A_Dependency_Query(query, pagination) {
2141
+ return function(target, methodName, parameterIndex) {
2142
+ const componentName = A_CommonHelper.getComponentName(target);
2143
+ if (!A_TypeGuards.isTargetAvailableForInjection(target)) {
2144
+ throw new A_DependencyError(
2145
+ A_DependencyError.InvalidDependencyTarget,
2146
+ `A-All cannot be used on the target of type ${typeof target} (${componentName})`
2147
+ );
2148
+ }
2149
+ const method = methodName ? String(methodName) : "constructor";
2150
+ let metaKey;
2151
+ switch (true) {
2152
+ case (A_TypeGuards.isComponentConstructor(target) || A_TypeGuards.isComponentInstance(target)):
2153
+ metaKey = "a-component-injections" /* INJECTIONS */;
2154
+ break;
2155
+ case A_TypeGuards.isContainerInstance(target):
2156
+ metaKey = "a-container-injections" /* INJECTIONS */;
2157
+ break;
2158
+ case A_TypeGuards.isEntityInstance(target):
2159
+ metaKey = "a-component-injections" /* INJECTIONS */;
2160
+ break;
2161
+ }
2162
+ const existedMeta = A_Context.meta(target).get(metaKey) || new A_Meta();
2163
+ const paramsArray = existedMeta.get(method) || [];
2164
+ paramsArray[parameterIndex].resolutionStrategy = {
2165
+ query: {
2166
+ ...paramsArray[parameterIndex].resolutionStrategy.query,
2167
+ ...query
2168
+ },
2169
+ pagination: {
2170
+ ...paramsArray[parameterIndex].resolutionStrategy.pagination,
2171
+ ...pagination
2172
+ }
2173
+ };
2174
+ existedMeta.set(method, paramsArray);
2175
+ A_Context.meta(target).set(
2176
+ metaKey,
2177
+ existedMeta
2178
+ );
2179
+ };
2180
+ }
2181
+
2139
2182
  // src/lib/A-Dependency/A-Dependency.class.ts
2140
2183
  var A_Dependency = class {
2141
2184
  /**
@@ -2215,6 +2258,15 @@ var A_Dependency = class {
2215
2258
  static get All() {
2216
2259
  return A_Dependency_All;
2217
2260
  }
2261
+ /**
2262
+ * Allows to indicate that the dependency should be resolved by specific query parameters
2263
+ * e.g. by ASEID, name, type, custom properties, etc.
2264
+ *
2265
+ * @returns
2266
+ */
2267
+ static get Query() {
2268
+ return A_Dependency_Query;
2269
+ }
2218
2270
  get flat() {
2219
2271
  return this._resolutionStrategy.flat;
2220
2272
  }
@@ -5006,13 +5058,6 @@ var A_Context = class _A_Context {
5006
5058
  if (!this.isAllowedForScopeAllocation(param1) && !this.isAllowedToBeRegistered(param1))
5007
5059
  throw new A_ContextError(A_ContextError.InvalidScopeParameterError, `Invalid parameter provided to get scope. Component of type ${name} is not allowed for scope allocation.`);
5008
5060
  switch (true) {
5009
- case this.isAllowedForScopeAllocation(param1):
5010
- if (!instance._registry.has(param1))
5011
- throw new A_ContextError(
5012
- A_ContextError.ScopeNotFoundError,
5013
- `Invalid parameter provided to get scope. Component of type ${name} does not have a scope allocated. Make sure to allocate a scope using A_Context.allocate() method before trying to get the scope.`
5014
- );
5015
- return instance._registry.get(param1);
5016
5061
  case this.isAllowedToBeRegistered(param1):
5017
5062
  if (!instance._scopeStorage.has(param1))
5018
5063
  throw new A_ContextError(
@@ -5020,6 +5065,13 @@ var A_Context = class _A_Context {
5020
5065
  `Invalid parameter provided to get scope. Component of type ${name} does not have a scope registered. Make sure to register the component using A_Context.register() method before trying to get the scope.`
5021
5066
  );
5022
5067
  return instance._scopeStorage.get(param1);
5068
+ case this.isAllowedForScopeAllocation(param1):
5069
+ if (!instance._registry.has(param1))
5070
+ throw new A_ContextError(
5071
+ A_ContextError.ScopeNotFoundError,
5072
+ `Invalid parameter provided to get scope. Component of type ${name} does not have a scope allocated. Make sure to allocate a scope using A_Context.allocate() method before trying to get the scope.`
5073
+ );
5074
+ return instance._registry.get(param1);
5023
5075
  default:
5024
5076
  throw new A_ContextError(A_ContextError.InvalidScopeParameterError, `Invalid parameter provided to get scope. Component of type ${name} is not allowed to be registered.`);
5025
5077
  }
@@ -5237,7 +5289,7 @@ var A_Context = class _A_Context {
5237
5289
  * @returns
5238
5290
  */
5239
5291
  static isAllowedForScopeAllocation(param) {
5240
- return A_TypeGuards.isContainerInstance(param) || A_TypeGuards.isFeatureInstance(param);
5292
+ return A_TypeGuards.isContainerInstance(param) || A_TypeGuards.isFeatureInstance(param) || A_TypeGuards.isEntityInstance(param);
5241
5293
  }
5242
5294
  /**
5243
5295
  * Type guard to check if the param is allowed to be registered in the context.
@@ -5726,6 +5778,7 @@ exports.A_Dependency_Default = A_Dependency_Default;
5726
5778
  exports.A_Dependency_Flat = A_Dependency_Flat;
5727
5779
  exports.A_Dependency_Load = A_Dependency_Load;
5728
5780
  exports.A_Dependency_Parent = A_Dependency_Parent;
5781
+ exports.A_Dependency_Query = A_Dependency_Query;
5729
5782
  exports.A_Dependency_Require = A_Dependency_Require;
5730
5783
  exports.A_Entity = A_Entity;
5731
5784
  exports.A_EntityError = A_EntityError;