@pristine-ts/networking 0.0.162 → 0.0.166

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.
Files changed (186) hide show
  1. package/dist/lib/cjs/decorators/body.decorator.js +20 -1
  2. package/dist/lib/cjs/decorators/body.decorator.js.map +1 -1
  3. package/dist/lib/cjs/decorators/controller.decorator.js +13 -1
  4. package/dist/lib/cjs/decorators/controller.decorator.js.map +1 -1
  5. package/dist/lib/cjs/decorators/decorators.js +1 -1
  6. package/dist/lib/cjs/decorators/decorators.js.map +1 -1
  7. package/dist/lib/cjs/decorators/headers.decorator.js +20 -1
  8. package/dist/lib/cjs/decorators/headers.decorator.js.map +1 -1
  9. package/dist/lib/cjs/decorators/identity.decorator.js +20 -1
  10. package/dist/lib/cjs/decorators/identity.decorator.js.map +1 -1
  11. package/dist/lib/cjs/decorators/query-parameter.decorator.js +22 -1
  12. package/dist/lib/cjs/decorators/query-parameter.decorator.js.map +1 -1
  13. package/dist/lib/cjs/decorators/query-parameters.decorator.js +20 -1
  14. package/dist/lib/cjs/decorators/query-parameters.decorator.js.map +1 -1
  15. package/dist/lib/cjs/decorators/request.decorator.js +20 -1
  16. package/dist/lib/cjs/decorators/request.decorator.js.map +1 -1
  17. package/dist/lib/cjs/decorators/response-header.decorator.js +24 -2
  18. package/dist/lib/cjs/decorators/response-header.decorator.js.map +1 -1
  19. package/dist/lib/cjs/decorators/route-parameter.decorator.js +21 -1
  20. package/dist/lib/cjs/decorators/route-parameter.decorator.js.map +1 -1
  21. package/dist/lib/cjs/decorators/route.decorator.js +21 -1
  22. package/dist/lib/cjs/decorators/route.decorator.js.map +1 -1
  23. package/dist/lib/cjs/enrichers/router-response.enricher.js +4 -0
  24. package/dist/lib/cjs/enrichers/router-response.enricher.js.map +1 -1
  25. package/dist/lib/cjs/errors/errors.js +3 -1
  26. package/dist/lib/cjs/errors/errors.js.map +1 -1
  27. package/dist/lib/cjs/errors/http.error.js +1 -1
  28. package/dist/lib/cjs/errors/http.error.js.map +1 -1
  29. package/dist/lib/cjs/errors/method-router-adding.error.js +25 -0
  30. package/dist/lib/cjs/errors/method-router-adding.error.js.map +1 -0
  31. package/dist/lib/cjs/errors/path-router-adding.error.js +3 -2
  32. package/dist/lib/cjs/errors/path-router-adding.error.js.map +1 -1
  33. package/dist/lib/cjs/errors/path-router-instantiation.error.js +3 -2
  34. package/dist/lib/cjs/errors/path-router-instantiation.error.js.map +1 -1
  35. package/dist/lib/cjs/interfaces/interfaces.js +2 -2
  36. package/dist/lib/cjs/interfaces/interfaces.js.map +1 -1
  37. package/dist/lib/cjs/models/models.js +0 -1
  38. package/dist/lib/cjs/models/models.js.map +1 -1
  39. package/dist/lib/cjs/models/request.js +10 -4
  40. package/dist/lib/cjs/models/request.js.map +1 -1
  41. package/dist/lib/cjs/models/response.js +6 -0
  42. package/dist/lib/cjs/models/response.js.map +1 -1
  43. package/dist/lib/cjs/models/route.js +4 -0
  44. package/dist/lib/cjs/models/route.js.map +1 -1
  45. package/dist/lib/cjs/networking.module.js +0 -6
  46. package/dist/lib/cjs/networking.module.js.map +1 -1
  47. package/dist/lib/cjs/nodes/method-router.node.js +19 -4
  48. package/dist/lib/cjs/nodes/method-router.node.js.map +1 -1
  49. package/dist/lib/cjs/nodes/path-router.node.js +22 -12
  50. package/dist/lib/cjs/nodes/path-router.node.js.map +1 -1
  51. package/dist/lib/cjs/resolvers/body-parameter-decorator.resolver.js +18 -0
  52. package/dist/lib/cjs/resolvers/body-parameter-decorator.resolver.js.map +1 -1
  53. package/dist/lib/cjs/resolvers/controller-method-parameter-decorator.resolver.js +14 -0
  54. package/dist/lib/cjs/resolvers/controller-method-parameter-decorator.resolver.js.map +1 -1
  55. package/dist/lib/cjs/resolvers/headers-parameter-decorator.resolver.js +18 -0
  56. package/dist/lib/cjs/resolvers/headers-parameter-decorator.resolver.js.map +1 -1
  57. package/dist/lib/cjs/resolvers/identity-parameter-decorator.resolver.js +18 -0
  58. package/dist/lib/cjs/resolvers/identity-parameter-decorator.resolver.js.map +1 -1
  59. package/dist/lib/cjs/resolvers/query-parameter-decorator.resolver.js +19 -0
  60. package/dist/lib/cjs/resolvers/query-parameter-decorator.resolver.js.map +1 -1
  61. package/dist/lib/cjs/resolvers/query-parameters-decorator.resolver.js +18 -0
  62. package/dist/lib/cjs/resolvers/query-parameters-decorator.resolver.js.map +1 -1
  63. package/dist/lib/cjs/resolvers/request-parameter-decorator.resolver.js +18 -0
  64. package/dist/lib/cjs/resolvers/request-parameter-decorator.resolver.js.map +1 -1
  65. package/dist/lib/cjs/resolvers/route-parameter-decorator.resolver.js +18 -0
  66. package/dist/lib/cjs/resolvers/route-parameter-decorator.resolver.js.map +1 -1
  67. package/dist/lib/cjs/router.js +25 -10
  68. package/dist/lib/cjs/router.js.map +1 -1
  69. package/dist/lib/esm/decorators/body.decorator.js +20 -1
  70. package/dist/lib/esm/decorators/body.decorator.js.map +1 -1
  71. package/dist/lib/esm/decorators/controller.decorator.js +13 -1
  72. package/dist/lib/esm/decorators/controller.decorator.js.map +1 -1
  73. package/dist/lib/esm/decorators/decorators.js +1 -1
  74. package/dist/lib/esm/decorators/decorators.js.map +1 -1
  75. package/dist/lib/esm/decorators/headers.decorator.js +20 -1
  76. package/dist/lib/esm/decorators/headers.decorator.js.map +1 -1
  77. package/dist/lib/esm/decorators/identity.decorator.js +20 -1
  78. package/dist/lib/esm/decorators/identity.decorator.js.map +1 -1
  79. package/dist/lib/esm/decorators/query-parameter.decorator.js +22 -1
  80. package/dist/lib/esm/decorators/query-parameter.decorator.js.map +1 -1
  81. package/dist/lib/esm/decorators/query-parameters.decorator.js +20 -1
  82. package/dist/lib/esm/decorators/query-parameters.decorator.js.map +1 -1
  83. package/dist/lib/esm/decorators/request.decorator.js +20 -1
  84. package/dist/lib/esm/decorators/request.decorator.js.map +1 -1
  85. package/dist/lib/esm/decorators/response-header.decorator.js +24 -2
  86. package/dist/lib/esm/decorators/response-header.decorator.js.map +1 -1
  87. package/dist/lib/esm/decorators/route-parameter.decorator.js +21 -1
  88. package/dist/lib/esm/decorators/route-parameter.decorator.js.map +1 -1
  89. package/dist/lib/esm/decorators/route.decorator.js +21 -1
  90. package/dist/lib/esm/decorators/route.decorator.js.map +1 -1
  91. package/dist/lib/esm/enrichers/router-response.enricher.js +4 -0
  92. package/dist/lib/esm/enrichers/router-response.enricher.js.map +1 -1
  93. package/dist/lib/esm/errors/errors.js +3 -1
  94. package/dist/lib/esm/errors/errors.js.map +1 -1
  95. package/dist/lib/esm/errors/http.error.js +1 -1
  96. package/dist/lib/esm/errors/http.error.js.map +1 -1
  97. package/dist/lib/esm/errors/method-router-adding.error.js +21 -0
  98. package/dist/lib/esm/errors/method-router-adding.error.js.map +1 -0
  99. package/dist/lib/esm/errors/path-router-adding.error.js +3 -2
  100. package/dist/lib/esm/errors/path-router-adding.error.js.map +1 -1
  101. package/dist/lib/esm/errors/path-router-instantiation.error.js +3 -2
  102. package/dist/lib/esm/errors/path-router-instantiation.error.js.map +1 -1
  103. package/dist/lib/esm/interfaces/interfaces.js +2 -2
  104. package/dist/lib/esm/interfaces/interfaces.js.map +1 -1
  105. package/dist/lib/esm/models/models.js +0 -1
  106. package/dist/lib/esm/models/models.js.map +1 -1
  107. package/dist/lib/esm/models/request.js +10 -4
  108. package/dist/lib/esm/models/request.js.map +1 -1
  109. package/dist/lib/esm/models/response.js +6 -0
  110. package/dist/lib/esm/models/response.js.map +1 -1
  111. package/dist/lib/esm/models/route.js +4 -0
  112. package/dist/lib/esm/models/route.js.map +1 -1
  113. package/dist/lib/esm/networking.module.js +0 -6
  114. package/dist/lib/esm/networking.module.js.map +1 -1
  115. package/dist/lib/esm/nodes/method-router.node.js +19 -4
  116. package/dist/lib/esm/nodes/method-router.node.js.map +1 -1
  117. package/dist/lib/esm/nodes/path-router.node.js +22 -12
  118. package/dist/lib/esm/nodes/path-router.node.js.map +1 -1
  119. package/dist/lib/esm/resolvers/body-parameter-decorator.resolver.js +18 -0
  120. package/dist/lib/esm/resolvers/body-parameter-decorator.resolver.js.map +1 -1
  121. package/dist/lib/esm/resolvers/controller-method-parameter-decorator.resolver.js +14 -0
  122. package/dist/lib/esm/resolvers/controller-method-parameter-decorator.resolver.js.map +1 -1
  123. package/dist/lib/esm/resolvers/headers-parameter-decorator.resolver.js +18 -0
  124. package/dist/lib/esm/resolvers/headers-parameter-decorator.resolver.js.map +1 -1
  125. package/dist/lib/esm/resolvers/identity-parameter-decorator.resolver.js +18 -0
  126. package/dist/lib/esm/resolvers/identity-parameter-decorator.resolver.js.map +1 -1
  127. package/dist/lib/esm/resolvers/query-parameter-decorator.resolver.js +19 -0
  128. package/dist/lib/esm/resolvers/query-parameter-decorator.resolver.js.map +1 -1
  129. package/dist/lib/esm/resolvers/query-parameters-decorator.resolver.js +18 -0
  130. package/dist/lib/esm/resolvers/query-parameters-decorator.resolver.js.map +1 -1
  131. package/dist/lib/esm/resolvers/request-parameter-decorator.resolver.js +18 -0
  132. package/dist/lib/esm/resolvers/request-parameter-decorator.resolver.js.map +1 -1
  133. package/dist/lib/esm/resolvers/route-parameter-decorator.resolver.js +18 -0
  134. package/dist/lib/esm/resolvers/route-parameter-decorator.resolver.js.map +1 -1
  135. package/dist/lib/esm/router.js +25 -10
  136. package/dist/lib/esm/router.js.map +1 -1
  137. package/dist/types/decorators/body.decorator.d.ts +3 -0
  138. package/dist/types/decorators/controller.decorator.d.ts +4 -0
  139. package/dist/types/decorators/decorators.d.ts +1 -1
  140. package/dist/types/decorators/headers.decorator.d.ts +3 -0
  141. package/dist/types/decorators/identity.decorator.d.ts +3 -0
  142. package/dist/types/decorators/query-parameter.decorator.d.ts +4 -0
  143. package/dist/types/decorators/query-parameters.decorator.d.ts +3 -0
  144. package/dist/types/decorators/request.decorator.d.ts +3 -0
  145. package/dist/types/decorators/response-header.decorator.d.ts +7 -0
  146. package/dist/types/decorators/route-parameter.decorator.d.ts +4 -0
  147. package/dist/types/decorators/route.decorator.d.ts +6 -1
  148. package/dist/types/enrichers/router-response.enricher.d.ts +4 -0
  149. package/dist/types/errors/errors.d.ts +3 -1
  150. package/dist/types/errors/http.error.d.ts +1 -1
  151. package/dist/types/errors/method-router-adding.error.d.ts +10 -0
  152. package/dist/types/errors/path-router-adding.error.d.ts +4 -3
  153. package/dist/types/errors/path-router-instantiation.error.d.ts +4 -3
  154. package/dist/types/interfaces/controller-method-parameter-decorator-resolver.interface.d.ts +19 -2
  155. package/dist/types/interfaces/interfaces.d.ts +2 -2
  156. package/dist/types/interfaces/parameter-decorator.interface.d.ts +4 -0
  157. package/dist/types/interfaces/query-parameters-decorator.interface.d.ts +4 -0
  158. package/dist/types/interfaces/route-parameter-decorator.interface.d.ts +1 -1
  159. package/dist/types/interfaces/router.interface.d.ts +2 -2
  160. package/dist/types/models/models.d.ts +0 -1
  161. package/dist/types/models/request.d.ts +16 -4
  162. package/dist/types/models/response.d.ts +15 -0
  163. package/dist/types/models/route.d.ts +4 -0
  164. package/dist/types/nodes/method-router.node.d.ts +17 -4
  165. package/dist/types/nodes/path-router.node.d.ts +11 -7
  166. package/dist/types/nodes/router.node.d.ts +3 -3
  167. package/dist/types/resolvers/body-parameter-decorator.resolver.d.ts +22 -2
  168. package/dist/types/resolvers/controller-method-parameter-decorator.resolver.d.ts +14 -0
  169. package/dist/types/resolvers/headers-parameter-decorator.resolver.d.ts +22 -2
  170. package/dist/types/resolvers/identity-parameter-decorator.resolver.d.ts +22 -2
  171. package/dist/types/resolvers/query-parameter-decorator.resolver.d.ts +23 -2
  172. package/dist/types/resolvers/query-parameters-decorator.resolver.d.ts +22 -2
  173. package/dist/types/resolvers/request-parameter-decorator.resolver.d.ts +22 -2
  174. package/dist/types/resolvers/route-parameter-decorator.resolver.d.ts +22 -2
  175. package/dist/types/router.d.ts +13 -3
  176. package/package.json +5 -5
  177. package/dist/lib/cjs/enums/enums.js +0 -1
  178. package/dist/lib/cjs/enums/enums.js.map +0 -1
  179. package/dist/lib/cjs/models/error-response-body.js +0 -7
  180. package/dist/lib/cjs/models/error-response-body.js.map +0 -1
  181. package/dist/lib/esm/enums/enums.js +0 -1
  182. package/dist/lib/esm/enums/enums.js.map +0 -1
  183. package/dist/lib/esm/models/error-response-body.js +0 -3
  184. package/dist/lib/esm/models/error-response-body.js.map +0 -1
  185. package/dist/types/enums/enums.d.ts +0 -0
  186. package/dist/types/models/error-response-body.d.ts +0 -4
@@ -4,30 +4,42 @@ import { RequestInterface } from "@pristine-ts/common";
4
4
  * This Request object represents the class used internally that represents a Request.
5
5
  */
6
6
  export declare class Request implements RequestInterface {
7
+ /**
8
+ * The http method of the request.
9
+ */
7
10
  httpMethod: HttpMethod | string;
11
+ /**
12
+ * The url of the request.
13
+ */
8
14
  url: string;
15
+ /**
16
+ * The headers of the request.
17
+ */
9
18
  headers: {
10
19
  [key: string]: string;
11
20
  };
21
+ /**
22
+ * The body of the request.
23
+ */
12
24
  body: any;
13
25
  constructor(requestInterface: RequestInterface);
14
26
  /**
15
27
  * This method sets a header parameter in the Request.
16
28
  *
17
- * @param name
18
- * @param value
29
+ * @param name The name of the header.
30
+ * @param value The value of the header.
19
31
  */
20
32
  setHeader(name: string, value: string): void;
21
33
  /**
22
34
  * This method returns whether or not the header exists in the Request.
23
35
  *
24
- * @param name
36
+ * @param name The name of the header.
25
37
  */
26
38
  hasHeader(name: string): boolean;
27
39
  /**
28
40
  * This method returns the header corresponding to the name or undefined if it doesn't exist.
29
41
  *
30
- * @param name
42
+ * @param name The name of the header.
31
43
  */
32
44
  getHeader(name: string): string | undefined;
33
45
  }
@@ -1,9 +1,24 @@
1
1
  import { RequestInterface } from "@pristine-ts/common";
2
+ /**
3
+ * This Response object represents the class used internally that represents a Response.
4
+ */
2
5
  export declare class Response {
6
+ /**
7
+ * The status code of the response. By default we return a 200.
8
+ */
3
9
  status: number;
10
+ /**
11
+ * The headers of the response.
12
+ */
4
13
  headers?: {
5
14
  [key: string]: string;
6
15
  };
16
+ /**
17
+ * The body of the response.
18
+ */
7
19
  body?: any;
20
+ /**
21
+ * The request that triggered this response.
22
+ */
8
23
  request?: RequestInterface;
9
24
  }
@@ -13,5 +13,9 @@ export declare class Route {
13
13
  * This contains the Route context for dynamic usage.
14
14
  */
15
15
  context?: any;
16
+ /**
17
+ * @param controllerInstantiationToken The instantiation token of the controller. Usually this will be the controller's constructor name.
18
+ * @param methodPropertyKey The name of the method that corresponds to the route in the controller.
19
+ */
16
20
  constructor(controllerInstantiationToken: any, methodPropertyKey: string);
17
21
  }
@@ -4,12 +4,24 @@ import { PathRouterNode } from "./path-router.node";
4
4
  import { Route } from "../models/route";
5
5
  /**
6
6
  * This class represents the Leaf node of the RouteTree.
7
+ * It will always have a parent node that will be a PathRouterNode.
7
8
  */
8
9
  export declare class MethodRouterNode extends RouterNode {
9
10
  readonly method: HttpMethod | string;
10
11
  readonly route: Route;
11
12
  readonly levelFromRoot: number;
13
+ /**
14
+ * @param parent The parent node of the current node.
15
+ * @param method The http method of the current method node.
16
+ * @param route The route associated with the current node.
17
+ * @param levelFromRoot The depth level from the root node.
18
+ */
12
19
  constructor(parent: PathRouterNode, method: HttpMethod | string, route: Route, levelFromRoot: number);
20
+ /**
21
+ * Returns whether or not the node matches.
22
+ * This verification is made by verify the http method matches with the http method of the current node.
23
+ * @param method The http method to compare.
24
+ */
13
25
  matches(method: HttpMethod | string): boolean;
14
26
  /**
15
27
  * A MethodRouterNode is never a catch-all node.
@@ -17,19 +29,20 @@ export declare class MethodRouterNode extends RouterNode {
17
29
  isCatchAll(): boolean;
18
30
  /**
19
31
  * This method adds all the required nodes to match the splitPaths and the method.
20
- *
32
+ * Since a MethodRouterNode is a leaf node, you can't add anything after it, this method therefore doesn't do anything.
21
33
  * @param splitPaths
22
34
  * @param method
23
35
  * @param route
24
36
  */
25
37
  add(splitPaths: string[], method: HttpMethod | string, route: Route): void;
26
38
  /**
27
- * This method checks to see if the method matches. If yes,
39
+ * This method receives an array of path and recursively calls its children if this node matches
40
+ * the first splitPath. If the node is a MethodRouterNode, it checks to see if the method matches. If yes,
28
41
  * it returns itself as the node found. This method should always return a MethodRouterNode. However, Typescript
29
42
  * doesn't like these recursive imports so we return the base class
30
43
  *
31
- * @param splitPaths
32
- * @param method
44
+ * @param splitPaths A list of all the parts of the paths spliced at the forward slashes.
45
+ * @param method The http method for which to find a node.
33
46
  */
34
47
  find(splitPaths: string[], method: HttpMethod | string): RouterNode | null;
35
48
  }
@@ -6,13 +6,17 @@ import { Route } from "../models/route";
6
6
  */
7
7
  export declare class PathRouterNode extends RouterNode {
8
8
  readonly path: string;
9
+ /**
10
+ * @param path The path associated with the current node.
11
+ * @param parent The parent node of the current node.
12
+ */
9
13
  constructor(path: string, parent?: PathRouterNode);
10
14
  /**
11
15
  * This method adds all the required nodes to match the splitPaths and the method.
12
16
  *
13
- * @param splitPaths
14
- * @param method
15
- * @param route
17
+ * @param splitPaths A list of all the parts of the paths spliced at the forward slashes.
18
+ * @param method The http method for this route.
19
+ * @param route The route.
16
20
  */
17
21
  add(splitPaths: string[], method: HttpMethod | string, route: Route, levelFromRoot: number): void;
18
22
  /**
@@ -21,14 +25,14 @@ export declare class PathRouterNode extends RouterNode {
21
25
  * it returns itself as the node found. This method should always return a MethodRouterNode. However, Typescript
22
26
  * doesn't like these recursive imports so we return the base class
23
27
  *
24
- * @param splitPaths
25
- * @param method
28
+ * @param splitPaths A list of all the parts of the paths spliced at the forward slashes.
29
+ * @param method The http method for which to find a node.
26
30
  */
27
31
  find(splitPaths: string[], method: HttpMethod | string): RouterNode | null;
28
32
  /**
29
33
  * This httpMethod navigates the tree upwards and returns all the routeParameters
30
34
  *
31
- * @param splitPaths
35
+ * @param splitPaths A list of all the parts of the paths spliced at the forward slashes.
32
36
  */
33
37
  getRouteParameters(splitPaths: string[]): {
34
38
  [key: string]: string;
@@ -38,7 +42,7 @@ export declare class PathRouterNode extends RouterNode {
38
42
  */
39
43
  isCatchAll(): boolean;
40
44
  /**
41
- * This method returns whether or not this pathRouterNode represents a route parameter, e.g.: /{id} or :id
45
+ * This method returns whether or not this pathRouterNode represents a route parameter, e.g.: /{id} or /:id
42
46
  */
43
47
  isRouteParameter(): boolean;
44
48
  /**
@@ -20,7 +20,7 @@ export declare abstract class RouterNode {
20
20
  /**
21
21
  * This method adds all the required nodes to match the splitPaths and the method.
22
22
  *
23
- * @param splitPaths
23
+ * @param splitPaths A list of all the parts of the paths spliced at the forward slashes.
24
24
  * @param method
25
25
  * @param route
26
26
  * @param levelFromRoot This parameter represents the number of level from the root. The root is at 0.
@@ -32,8 +32,8 @@ export declare abstract class RouterNode {
32
32
  * it returns itself as the node found. This method should always return a MethodRouterNode. However, Typescript
33
33
  * doesn't like these recursive imports so we return the base class
34
34
  *
35
- * @param splitPaths
36
- * @param method
35
+ * @param splitPaths A list of all the parts of the paths spliced at the forward slashes.
36
+ * @param method The http method for which to find a node.
37
37
  */
38
38
  abstract find(splitPaths: string[], method: HttpMethod | string): RouterNode | null;
39
39
  /**
@@ -2,9 +2,29 @@ import "reflect-metadata";
2
2
  import { ControllerMethodParameterDecoratorResolverInterface } from "../interfaces/controller-method-parameter-decorator-resolver.interface";
3
3
  import { Request } from "../models/request";
4
4
  import { IdentityInterface } from "@pristine-ts/common";
5
+ import { ParameterDecoratorInterface } from "../interfaces/parameter-decorator.interface";
6
+ import { BodyParameterDecoratorInterface } from "../interfaces/body-parameter-decorator.interface";
7
+ /**
8
+ * The BodyParameterDecoratorResolver resolves the value of the body of the request so that it can be injected it into the
9
+ * parameter of the route of the controller that was annotated with the @body decorator.
10
+ * It is tagged as an MethodParameterDecoratorResolver so it can be automatically injected with the all the other MethodParameterDecoratorResolvers.
11
+ */
5
12
  export declare class BodyParameterDecoratorResolver implements ControllerMethodParameterDecoratorResolverInterface {
6
- resolve(methodArgument: any, request: Request, routeParameters: {
13
+ /**
14
+ * Resolves the value of the body of the request.
15
+ * The router than injects that value into the parameter of the controller method.
16
+ * @param methodArgument The method argument created by the decorator.
17
+ * @param request The request
18
+ * @param routeParameters The router parameters
19
+ * @param identity The identity making the request
20
+ */
21
+ resolve(methodArgument: BodyParameterDecoratorInterface, request: Request, routeParameters: {
7
22
  [p: string]: string;
8
23
  }, identity?: IdentityInterface): Promise<any>;
9
- supports(methodArgument: any): boolean;
24
+ /**
25
+ * Returns whether or not the resolver support such a method argument.
26
+ * Usually we will check the methodArgument.type field to determine if it is a supported type.
27
+ * @param methodArgument
28
+ */
29
+ supports(methodArgument: ParameterDecoratorInterface): boolean;
10
30
  }
@@ -2,9 +2,23 @@ import { IdentityInterface } from "@pristine-ts/common";
2
2
  import { ControllerMethodParameterDecoratorResolverInterface } from "../interfaces/controller-method-parameter-decorator-resolver.interface";
3
3
  import { Request } from "../models/request";
4
4
  import { ParameterDecoratorInterface } from "../interfaces/parameter-decorator.interface";
5
+ /**
6
+ * This service calls the resolvers to resolve the value to be injected in the parameter of a method.
7
+ */
5
8
  export declare class ControllerMethodParameterDecoratorResolver {
6
9
  private readonly methodParameterDecoratorResolvers;
10
+ /**
11
+ * This service calls the resolvers to resolve the value to be injected in the parameter of a method.
12
+ * @param methodParameterDecoratorResolvers The parameter decorator resolvers. All services with the tag ServiceDefinitionTagEnum.MethodParameterDecoratorResolver will be automatically injected here.
13
+ */
7
14
  constructor(methodParameterDecoratorResolvers: ControllerMethodParameterDecoratorResolverInterface[]);
15
+ /**
16
+ * This method calls the parameter decorator resolver that supports the type of the decorator and resolves the value to be injected in the parameter.
17
+ * @param methodArgument The method argument created by the decorator.
18
+ * @param request The request
19
+ * @param routeParameters The router parameters
20
+ * @param identity The identity making the request
21
+ */
8
22
  resolve(methodArgument: ParameterDecoratorInterface, request: Request, routeParameters: {
9
23
  [key: string]: string;
10
24
  }, identity?: IdentityInterface): Promise<any>;
@@ -2,9 +2,29 @@ import "reflect-metadata";
2
2
  import { ControllerMethodParameterDecoratorResolverInterface } from "../interfaces/controller-method-parameter-decorator-resolver.interface";
3
3
  import { Request } from "../models/request";
4
4
  import { IdentityInterface } from "@pristine-ts/common";
5
+ import { ParameterDecoratorInterface } from "../interfaces/parameter-decorator.interface";
6
+ import { HeadersParameterDecoratorInterface } from "../interfaces/headers-parameter-decorator.interface";
7
+ /**
8
+ * The HeadersParameterDecoratorResolver resolves the value of the headers of the request so that it can be injected it into the
9
+ * parameter of the route of the controller that was annotated with the @headers decorator.
10
+ * It is tagged as an MethodParameterDecoratorResolver so it can be automatically injected with the all the other MethodParameterDecoratorResolvers.
11
+ */
5
12
  export declare class HeadersParameterDecoratorResolver implements ControllerMethodParameterDecoratorResolverInterface {
6
- resolve(methodArgument: any, request: Request, routeParameters: {
13
+ /**
14
+ * Resolves the value of the headers of the request.
15
+ * The router than injects that value into the parameter of the controller method.
16
+ * @param methodArgument The method argument created by the decorator.
17
+ * @param request The request
18
+ * @param routeParameters The router parameters
19
+ * @param identity The identity making the request
20
+ */
21
+ resolve(methodArgument: HeadersParameterDecoratorInterface, request: Request, routeParameters: {
7
22
  [p: string]: string;
8
23
  }, identity?: IdentityInterface): Promise<any>;
9
- supports(methodArgument: any): boolean;
24
+ /**
25
+ * Returns whether or not the resolver support such a method argument.
26
+ * Usually we will check the methodArgument.type field to determine if it is a supported type.
27
+ * @param methodArgument
28
+ */
29
+ supports(methodArgument: ParameterDecoratorInterface): boolean;
10
30
  }
@@ -2,9 +2,29 @@ import "reflect-metadata";
2
2
  import { ControllerMethodParameterDecoratorResolverInterface } from "../interfaces/controller-method-parameter-decorator-resolver.interface";
3
3
  import { Request } from "../models/request";
4
4
  import { IdentityInterface } from "@pristine-ts/common";
5
+ import { ParameterDecoratorInterface } from "../interfaces/parameter-decorator.interface";
6
+ import { IdentityParameterDecoratorInterface } from "../interfaces/identity-parameteter-decorator.interface";
7
+ /**
8
+ * The IdentityParameterDecoratorResolver resolves the value of the identity (parsed by the authenticator) of the request
9
+ * so that it can be injected it into the parameter of the route of the controller that was annotated with the @identity decorator.
10
+ * It is tagged as an MethodParameterDecoratorResolver so it can be automatically injected with the all the other MethodParameterDecoratorResolvers.
11
+ */
5
12
  export declare class IdentityParameterDecoratorResolver implements ControllerMethodParameterDecoratorResolverInterface {
6
- resolve(methodArgument: any, request: Request, routeParameters: {
13
+ /**
14
+ * Resolves the value of the identity of the request.
15
+ * The router than injects that value into the parameter of the controller method.
16
+ * @param methodArgument The method argument created by the decorator.
17
+ * @param request The request
18
+ * @param routeParameters The router parameters
19
+ * @param identity The identity making the request
20
+ */
21
+ resolve(methodArgument: IdentityParameterDecoratorInterface, request: Request, routeParameters: {
7
22
  [p: string]: string;
8
23
  }, identity?: IdentityInterface): Promise<any>;
9
- supports(methodArgument: any): boolean;
24
+ /**
25
+ * Returns whether or not the resolver support such a method argument.
26
+ * Usually we will check the methodArgument.type field to determine if it is a supported type.
27
+ * @param methodArgument
28
+ */
29
+ supports(methodArgument: ParameterDecoratorInterface): boolean;
10
30
  }
@@ -1,9 +1,30 @@
1
1
  import { ControllerMethodParameterDecoratorResolverInterface } from "../interfaces/controller-method-parameter-decorator-resolver.interface";
2
2
  import { Request } from "../models/request";
3
3
  import { IdentityInterface } from "@pristine-ts/common";
4
+ import { ParameterDecoratorInterface } from "../interfaces/parameter-decorator.interface";
5
+ import { QueryParameterDecoratorInterface } from "../interfaces/query-parameter-decorator.interface";
6
+ /**
7
+ * The QueryParameterDecoratorResolver resolves the value of the query parameter with the name passed to the decorator
8
+ * of the request so that it can be injected it into the parameter of the route of the controller that was annotated
9
+ * with the @queryParameter decorator.
10
+ * It is tagged as an MethodParameterDecoratorResolver so it can be automatically injected with the all the other MethodParameterDecoratorResolvers.
11
+ */
4
12
  export declare class QueryParameterDecoratorResolver implements ControllerMethodParameterDecoratorResolverInterface {
5
- resolve(methodArgument: any, request: Request, routeParameters: {
13
+ /**
14
+ * Resolves the value of the query parameter with the specified name of the request.
15
+ * The router than injects that value into the parameter of the controller method.
16
+ * @param methodArgument The method argument created by the decorator including the query parameter name.
17
+ * @param request The request
18
+ * @param routeParameters The router parameters
19
+ * @param identity The identity making the request
20
+ */
21
+ resolve(methodArgument: QueryParameterDecoratorInterface, request: Request, routeParameters: {
6
22
  [p: string]: string;
7
23
  }, identity?: IdentityInterface): Promise<any>;
8
- supports(methodArgument: any): boolean;
24
+ /**
25
+ * Returns whether or not the resolver support such a method argument.
26
+ * Usually we will check the methodArgument.type field to determine if it is a supported type.
27
+ * @param methodArgument
28
+ */
29
+ supports(methodArgument: ParameterDecoratorInterface): boolean;
9
30
  }
@@ -1,9 +1,29 @@
1
1
  import { ControllerMethodParameterDecoratorResolverInterface } from "../interfaces/controller-method-parameter-decorator-resolver.interface";
2
2
  import { Request } from "../models/request";
3
3
  import { IdentityInterface } from "@pristine-ts/common";
4
+ import { ParameterDecoratorInterface } from "../interfaces/parameter-decorator.interface";
5
+ import { QueryParametersDecoratorInterface } from "../interfaces/query-parameters-decorator.interface";
6
+ /**
7
+ * The QueryParametersDecoratorResolver resolves the value (a map) of the query parameters of the request so that it can be injected it into the
8
+ * parameter of the route of the controller that was annotated with the @queryParameters decorator.
9
+ * It is tagged as an MethodParameterDecoratorResolver so it can be automatically injected with the all the other MethodParameterDecoratorResolvers.
10
+ */
4
11
  export declare class QueryParametersDecoratorResolver implements ControllerMethodParameterDecoratorResolverInterface {
5
- resolve(methodArgument: any, request: Request, routeParameters: {
12
+ /**
13
+ * Resolves the value of all the query parameters of the request.
14
+ * The router than injects that value into the parameter of the controller method.
15
+ * @param methodArgument The method argument created by the decorator.
16
+ * @param request The request
17
+ * @param routeParameters The router parameters
18
+ * @param identity The identity making the request
19
+ */
20
+ resolve(methodArgument: QueryParametersDecoratorInterface, request: Request, routeParameters: {
6
21
  [p: string]: string;
7
22
  }, identity?: IdentityInterface): Promise<any>;
8
- supports(methodArgument: any): boolean;
23
+ /**
24
+ * Returns whether or not the resolver support such a method argument.
25
+ * Usually we will check the methodArgument.type field to determine if it is a supported type.
26
+ * @param methodArgument
27
+ */
28
+ supports(methodArgument: ParameterDecoratorInterface): boolean;
9
29
  }
@@ -2,9 +2,29 @@ import "reflect-metadata";
2
2
  import { ControllerMethodParameterDecoratorResolverInterface } from "../interfaces/controller-method-parameter-decorator-resolver.interface";
3
3
  import { Request } from "../models/request";
4
4
  import { IdentityInterface } from "@pristine-ts/common";
5
+ import { RequestParameterDecoratorInterface } from "../interfaces/request-parameter-decorator.interface";
6
+ import { ParameterDecoratorInterface } from "../interfaces/parameter-decorator.interface";
7
+ /**
8
+ * The RequestParameterDecoratorResolver resolves the value of the whole request so that it can be injected it into the
9
+ * parameter of the route of the controller that was annotated with the @request decorator.
10
+ * It is tagged as an MethodParameterDecoratorResolver so it can be automatically injected with the all the other MethodParameterDecoratorResolvers.
11
+ */
5
12
  export declare class RequestParameterDecoratorResolver implements ControllerMethodParameterDecoratorResolverInterface {
6
- resolve(methodArgument: any, request: Request, routeParameters: {
13
+ /**
14
+ * Resolves the value of the whole request.
15
+ * The router than injects that value into the parameter of the controller method.
16
+ * @param methodArgument The method argument created by the decorator.
17
+ * @param request The request
18
+ * @param routeParameters The router parameters
19
+ * @param identity The identity making the request
20
+ */
21
+ resolve(methodArgument: RequestParameterDecoratorInterface, request: Request, routeParameters: {
7
22
  [p: string]: string;
8
23
  }, identity?: IdentityInterface): Promise<any>;
9
- supports(methodArgument: any): boolean;
24
+ /**
25
+ * Returns whether or not the resolver support such a method argument.
26
+ * Usually we will check the methodArgument.type field to determine if it is a supported type.
27
+ * @param methodArgument
28
+ */
29
+ supports(methodArgument: ParameterDecoratorInterface): boolean;
10
30
  }
@@ -1,9 +1,29 @@
1
1
  import { ControllerMethodParameterDecoratorResolverInterface } from "../interfaces/controller-method-parameter-decorator-resolver.interface";
2
2
  import { Request } from "../models/request";
3
3
  import { IdentityInterface } from "@pristine-ts/common";
4
+ import { RouteParameterDecoratorInterface } from "../interfaces/route-parameter-decorator.interface";
5
+ import { ParameterDecoratorInterface } from "../interfaces/parameter-decorator.interface";
6
+ /**
7
+ * The RouteParameterDecoratorResolver resolves the value of the route parameter specified of the request so that it can be injected it into the
8
+ * parameter of the route of the controller that was annotated with the @routeParameter decorator.
9
+ * It is tagged as an MethodParameterDecoratorResolver so it can be automatically injected with the all the other MethodParameterDecoratorResolvers.
10
+ */
4
11
  export declare class RouteParameterDecoratorResolver implements ControllerMethodParameterDecoratorResolverInterface {
5
- resolve(methodArgument: any, request: Request, routeParameters: {
12
+ /**
13
+ * Resolves the value of the the route parameter with the specified name of the request.
14
+ * The router than injects that value into the parameter of the controller method.
15
+ * @param methodArgument The method argument created by the decorator, including the name of the parameter to resolve.
16
+ * @param request The request
17
+ * @param routeParameters The router parameters
18
+ * @param identity The identity making the request
19
+ */
20
+ resolve(methodArgument: RouteParameterDecoratorInterface, request: Request, routeParameters: {
6
21
  [p: string]: string;
7
22
  }, identity?: IdentityInterface): Promise<any>;
8
- supports(methodArgument: any): boolean;
23
+ /**
24
+ * Returns whether or not the resolver support such a method argument.
25
+ * Usually we will check the methodArgument.type field to determine if it is a supported type.
26
+ * @param methodArgument
27
+ */
28
+ supports(methodArgument: ParameterDecoratorInterface): boolean;
9
29
  }
@@ -7,15 +7,25 @@ import { ControllerMethodParameterDecoratorResolver } from "./resolvers/controll
7
7
  import { HttpMethod } from "@pristine-ts/common";
8
8
  import { AuthenticationManagerInterface, AuthorizerManagerInterface } from "@pristine-ts/security";
9
9
  import { LogHandlerInterface } from "@pristine-ts/logging";
10
- import { TracingManagerInterface } from "@pristine-ts/telemetry";
10
+ /**
11
+ * The router service is the service that creates the routing tree from the controllers.
12
+ * It also executes a request properly by routing it to the intended controller and returns the response.
13
+ */
11
14
  export declare class Router implements RouterInterface {
12
15
  private readonly loghandler;
13
16
  private readonly controllerMethodParameterDecoratorResolver;
14
17
  private readonly authorizerManager;
15
18
  private readonly authenticationManager;
16
- private readonly tracingManager;
17
19
  private root;
18
- constructor(loghandler: LogHandlerInterface, controllerMethodParameterDecoratorResolver: ControllerMethodParameterDecoratorResolver, authorizerManager: AuthorizerManagerInterface, authenticationManager: AuthenticationManagerInterface, tracingManager: TracingManagerInterface);
20
+ /**
21
+ * The router service is the service that creates the routing tree from the controllers.
22
+ * It also executes a request properly by routing it to the intended controller and returns the response.
23
+ * @param loghandler The log handler
24
+ * @param controllerMethodParameterDecoratorResolver The controller method parameter decorator resolver used to resolve the values.
25
+ * @param authorizerManager The authorizer manager to validate authorization.
26
+ * @param authenticationManager The authentication manager to validate authentication.
27
+ */
28
+ constructor(loghandler: LogHandlerInterface, controllerMethodParameterDecoratorResolver: ControllerMethodParameterDecoratorResolver, authorizerManager: AuthorizerManagerInterface, authenticationManager: AuthenticationManagerInterface);
19
29
  /**
20
30
  * This method registers a Route into the Route Tree maintained by the router.
21
31
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pristine-ts/networking",
3
- "version": "0.0.162",
3
+ "version": "0.0.166",
4
4
  "description": "",
5
5
  "module": "dist/lib/esm/networking.module.js",
6
6
  "main": "dist/lib/cjs/networking.module.js",
@@ -19,9 +19,9 @@
19
19
  "access": "public"
20
20
  },
21
21
  "dependencies": {
22
- "@pristine-ts/common": "^0.0.162",
23
- "@pristine-ts/security": "^0.0.162",
24
- "@pristine-ts/telemetry": "^0.0.162",
22
+ "@pristine-ts/common": "^0.0.166",
23
+ "@pristine-ts/security": "^0.0.166",
24
+ "@pristine-ts/telemetry": "^0.0.166",
25
25
  "url-parse": "^1.4.7"
26
26
  },
27
27
  "jest": {
@@ -58,5 +58,5 @@
58
58
  "src/*.{js,ts}"
59
59
  ]
60
60
  },
61
- "gitHead": "3e5edd96d10fe71784bccf975ee9c0170bce566c"
61
+ "gitHead": "c452544a69d17814c83d6a99a4fd788fdaa0daff"
62
62
  }
@@ -1 +0,0 @@
1
- //# sourceMappingURL=enums.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"enums.js","sourceRoot":"","sources":["../../../../src/enums/enums.ts"],"names":[],"mappings":""}
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ErrorResponseBody = void 0;
4
- class ErrorResponseBody {
5
- }
6
- exports.ErrorResponseBody = ErrorResponseBody;
7
- //# sourceMappingURL=error-response-body.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"error-response-body.js","sourceRoot":"","sources":["../../../../src/models/error-response-body.ts"],"names":[],"mappings":";;;AAAA,MAAa,iBAAiB;CAG7B;AAHD,8CAGC"}
@@ -1 +0,0 @@
1
- //# sourceMappingURL=enums.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"enums.js","sourceRoot":"","sources":["../../../../src/enums/enums.ts"],"names":[],"mappings":""}
@@ -1,3 +0,0 @@
1
- export class ErrorResponseBody {
2
- }
3
- //# sourceMappingURL=error-response-body.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"error-response-body.js","sourceRoot":"","sources":["../../../../src/models/error-response-body.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,iBAAiB;CAG7B"}
File without changes
@@ -1,4 +0,0 @@
1
- export declare class ErrorResponseBody {
2
- message: string;
3
- errors?: any[];
4
- }