@rapidrest/service-core 1.0.0-rc.2 → 1.0.0-rc.21

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 (250) hide show
  1. package/dist/lib/BackgroundService.js +0 -4
  2. package/dist/lib/BackgroundService.js.map +1 -1
  3. package/dist/lib/BackgroundServiceManager.js +21 -4
  4. package/dist/lib/BackgroundServiceManager.js.map +1 -1
  5. package/dist/lib/EventListenerManager.js.map +1 -1
  6. package/dist/lib/OpenApiSpec.js +3 -2
  7. package/dist/lib/OpenApiSpec.js.map +1 -1
  8. package/dist/lib/Server.js +18 -79
  9. package/dist/lib/Server.js.map +1 -1
  10. package/dist/lib/database/TypeOrmSupport.js +18 -2
  11. package/dist/lib/database/TypeOrmSupport.js.map +1 -1
  12. package/dist/lib/decorators/DocDecorators.js +19 -1
  13. package/dist/lib/decorators/DocDecorators.js.map +1 -1
  14. package/dist/lib/decorators/PersistenceDecorators.js.map +1 -1
  15. package/dist/lib/decorators/RouteDecorators.js +71 -20
  16. package/dist/lib/decorators/RouteDecorators.js.map +1 -1
  17. package/dist/lib/http/Adapters.js +45 -2
  18. package/dist/lib/http/Adapters.js.map +1 -1
  19. package/dist/lib/http/Router.js +53 -56
  20. package/dist/lib/http/Router.js.map +1 -1
  21. package/dist/lib/models/ModelUtils.js +18 -8
  22. package/dist/lib/models/ModelUtils.js.map +1 -1
  23. package/dist/lib/models/RepoUtils.js +96 -31
  24. package/dist/lib/models/RepoUtils.js.map +1 -1
  25. package/dist/lib/routes/{AdminRoute.js → BaseAdminRoute.js} +51 -36
  26. package/dist/lib/routes/BaseAdminRoute.js.map +1 -0
  27. package/dist/lib/routes/{MetricsRoute.js → BaseMetricsRoute.js} +28 -15
  28. package/dist/lib/routes/BaseMetricsRoute.js.map +1 -0
  29. package/dist/lib/routes/{OpenAPIRoute.js → BaseOpenAPIRoute.js} +31 -32
  30. package/dist/lib/routes/BaseOpenAPIRoute.js.map +1 -0
  31. package/dist/lib/routes/BasePushRoute.js +193 -0
  32. package/dist/lib/routes/BasePushRoute.js.map +1 -0
  33. package/dist/lib/routes/BaseStaticRoute.js +152 -0
  34. package/dist/lib/routes/BaseStaticRoute.js.map +1 -0
  35. package/dist/lib/routes/BaseStatusRoute.js +79 -0
  36. package/dist/lib/routes/BaseStatusRoute.js.map +1 -0
  37. package/dist/lib/routes/CRUDRoute.js +238 -0
  38. package/dist/lib/routes/CRUDRoute.js.map +1 -0
  39. package/dist/lib/routes/ModelRoute.js +20 -28
  40. package/dist/lib/routes/ModelRoute.js.map +1 -1
  41. package/dist/lib/routes/index.js +7 -4
  42. package/dist/lib/routes/index.js.map +1 -1
  43. package/dist/lib/security/ACLUtils.js +10 -13
  44. package/dist/lib/security/ACLUtils.js.map +1 -1
  45. package/dist/lib/security/AccessControlListMongo.js +5 -1
  46. package/dist/lib/security/AccessControlListMongo.js.map +1 -1
  47. package/dist/lib/security/AccessControlListSQL.js +7 -3
  48. package/dist/lib/security/AccessControlListSQL.js.map +1 -1
  49. package/dist/lib/security/BaseACLRoute.js +239 -0
  50. package/dist/lib/security/BaseACLRoute.js.map +1 -0
  51. package/dist/lib/security/index.js +3 -0
  52. package/dist/lib/security/index.js.map +1 -1
  53. package/dist/lib/test/request.js +6 -2
  54. package/dist/lib/test/request.js.map +1 -1
  55. package/dist/types/BackgroundService.d.ts +0 -5
  56. package/dist/types/BackgroundServiceManager.d.ts +1 -1
  57. package/dist/types/EventListenerManager.d.ts +4 -4
  58. package/dist/types/Server.d.ts +21 -6
  59. package/dist/types/decorators/DocDecorators.d.ts +9 -0
  60. package/dist/types/decorators/PersistenceDecorators.d.ts +7 -0
  61. package/dist/types/decorators/RouteDecorators.d.ts +14 -5
  62. package/dist/types/http/Adapters.d.ts +19 -0
  63. package/dist/types/http/Router.d.ts +6 -6
  64. package/dist/types/models/ModelUtils.d.ts +2 -1
  65. package/dist/types/routes/BaseAdminRoute.d.ts +59 -0
  66. package/dist/types/routes/BaseMetricsRoute.d.ts +37 -0
  67. package/dist/types/routes/BaseOpenAPIRoute.d.ts +33 -0
  68. package/dist/types/routes/BasePushRoute.d.ts +39 -0
  69. package/dist/types/routes/BaseStaticRoute.d.ts +44 -0
  70. package/dist/types/routes/BaseStatusRoute.d.ts +37 -0
  71. package/dist/types/routes/CRUDRoute.d.ts +47 -0
  72. package/dist/types/routes/ModelRoute.d.ts +23 -16
  73. package/dist/types/routes/index.d.ts +7 -4
  74. package/dist/types/security/ACLUtils.d.ts +1 -1
  75. package/dist/types/security/AccessControlList.d.ts +1 -1
  76. package/dist/types/security/AccessControlListMongo.d.ts +1 -1
  77. package/dist/types/security/AccessControlListSQL.d.ts +1 -1
  78. package/dist/types/security/BaseACLRoute.d.ts +73 -0
  79. package/dist/types/security/index.d.ts +3 -0
  80. package/package.json +132 -129
  81. package/tsconfig.export.json +17 -0
  82. package/dist/lib/routes/AdminRoute.js.map +0 -1
  83. package/dist/lib/routes/MetricsRoute.js.map +0 -1
  84. package/dist/lib/routes/OpenAPIRoute.js.map +0 -1
  85. package/dist/lib/routes/StatusRoute.js +0 -55
  86. package/dist/lib/routes/StatusRoute.js.map +0 -1
  87. package/dist/lib/security/ACLRouteMongo.js +0 -194
  88. package/dist/lib/security/ACLRouteMongo.js.map +0 -1
  89. package/dist/lib/security/ACLRouteSQL.js +0 -193
  90. package/dist/lib/security/ACLRouteSQL.js.map +0 -1
  91. package/dist/types/routes/AdminRoute.d.ts +0 -47
  92. package/dist/types/routes/MetricsRoute.d.ts +0 -15
  93. package/dist/types/routes/OpenAPIRoute.d.ts +0 -17
  94. package/dist/types/routes/StatusRoute.d.ts +0 -11
  95. package/dist/types/security/ACLRouteMongo.d.ts +0 -19
  96. package/dist/types/security/ACLRouteSQL.d.ts +0 -19
  97. package/docs/Makefile +0 -20
  98. package/docs/conf.py +0 -58
  99. package/docs/index.rst +0 -17
  100. package/docs/make.bat +0 -35
  101. package/docs/reference/@rapidrest/namespaces/DatabaseDecorators/README.md +0 -13
  102. package/docs/reference/@rapidrest/namespaces/DatabaseDecorators/functions/MongoRepository.md +0 -25
  103. package/docs/reference/@rapidrest/namespaces/DatabaseDecorators/functions/RedisConnection.md +0 -25
  104. package/docs/reference/@rapidrest/namespaces/DatabaseDecorators/functions/Repository.md +0 -25
  105. package/docs/reference/@rapidrest/namespaces/DocDecorators/README.md +0 -23
  106. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Default.md +0 -25
  107. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Description.md +0 -25
  108. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Document.md +0 -25
  109. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Example.md +0 -25
  110. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Format.md +0 -25
  111. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Returns.md +0 -28
  112. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Summary.md +0 -25
  113. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Tags.md +0 -25
  114. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/TypeInfo.md +0 -28
  115. package/docs/reference/@rapidrest/namespaces/DocDecorators/interfaces/DocumentsData.md +0 -57
  116. package/docs/reference/@rapidrest/namespaces/EventDecorators/README.md +0 -12
  117. package/docs/reference/@rapidrest/namespaces/EventDecorators/functions/EventListener.md +0 -17
  118. package/docs/reference/@rapidrest/namespaces/EventDecorators/functions/OnEvent.md +0 -26
  119. package/docs/reference/@rapidrest/namespaces/ModelDecorators/README.md +0 -26
  120. package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/Cache.md +0 -25
  121. package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/ChildEntity.md +0 -18
  122. package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/DataStore.md +0 -25
  123. package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/Identifier.md +0 -27
  124. package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/Protect.md +0 -35
  125. package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/Reference.md +0 -25
  126. package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/Shard.md +0 -27
  127. package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/TrackChanges.md +0 -26
  128. package/docs/reference/@rapidrest/namespaces/ModelDecorators/interfaces/PendingTypeOrmColumn.md +0 -45
  129. package/docs/reference/@rapidrest/namespaces/ModelDecorators/variables/pendingTypeOrmColumns.md +0 -14
  130. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/README.md +0 -27
  131. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/Column.md +0 -25
  132. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/Entity.md +0 -25
  133. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/Index.md +0 -119
  134. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/PrimaryColumn.md +0 -25
  135. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/Unique.md +0 -68
  136. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/getColumnMetadata.md +0 -26
  137. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/getEntityName.md +0 -26
  138. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/getIndexMetadata.md +0 -27
  139. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/interfaces/CollationOptions.md +0 -79
  140. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/interfaces/ColumnInfo.md +0 -41
  141. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/interfaces/ColumnOptions.md +0 -51
  142. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/interfaces/EntityOptions.md +0 -32
  143. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/interfaces/IndexInfo.md +0 -41
  144. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/interfaces/IndexOptions.md +0 -61
  145. package/docs/reference/@rapidrest/namespaces/RouteDecorators/README.md +0 -36
  146. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/After.md +0 -26
  147. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Auth.md +0 -33
  148. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/AuthResult.md +0 -31
  149. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Before.md +0 -25
  150. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/ContentType.md +0 -25
  151. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Delete.md +0 -25
  152. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Get.md +0 -25
  153. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Head.md +0 -25
  154. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Header.md +0 -25
  155. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Method.md +0 -31
  156. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Model.md +0 -25
  157. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Options.md +0 -25
  158. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Param.md +0 -26
  159. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Patch.md +0 -25
  160. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Post.md +0 -25
  161. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Protect.md +0 -31
  162. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Put.md +0 -25
  163. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Query.md +0 -26
  164. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Request.md +0 -31
  165. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/RequiresRole.md +0 -26
  166. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Response.md +0 -31
  167. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Route.md +0 -25
  168. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Socket.md +0 -33
  169. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/User.md +0 -31
  170. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Validate.md +0 -25
  171. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/WebSocket.md +0 -25
  172. package/docs/reference/README.md +0 -20
  173. package/docs/reference/classes/ACLUtils.md +0 -263
  174. package/docs/reference/classes/AdminRoute.md +0 -51
  175. package/docs/reference/classes/AuthMiddleware.md +0 -173
  176. package/docs/reference/classes/BackgroundService.md +0 -117
  177. package/docs/reference/classes/BackgroundServiceManager.md +0 -172
  178. package/docs/reference/classes/BaseEntity.md +0 -82
  179. package/docs/reference/classes/BaseMongoEntity.md +0 -107
  180. package/docs/reference/classes/BasicStrategy.md +0 -131
  181. package/docs/reference/classes/BasicStrategyOptions.md +0 -115
  182. package/docs/reference/classes/BulkError.md +0 -271
  183. package/docs/reference/classes/ConnectionManager.md +0 -75
  184. package/docs/reference/classes/EventListenerManager.md +0 -88
  185. package/docs/reference/classes/HttpRouter.md +0 -343
  186. package/docs/reference/classes/JWTStrategy.md +0 -100
  187. package/docs/reference/classes/JWTStrategyOptions.md +0 -97
  188. package/docs/reference/classes/MetricsRoute.md +0 -27
  189. package/docs/reference/classes/ModelRoute.md +0 -527
  190. package/docs/reference/classes/ModelUtils.md +0 -430
  191. package/docs/reference/classes/MongoConnection.md +0 -218
  192. package/docs/reference/classes/MongoRepository.md +0 -390
  193. package/docs/reference/classes/MongoSchemaSync.md +0 -97
  194. package/docs/reference/classes/NetUtils.md +0 -90
  195. package/docs/reference/classes/NotificationUtils.md +0 -77
  196. package/docs/reference/classes/ObjectFactory.md +0 -336
  197. package/docs/reference/classes/OpenAPIRoute.md +0 -77
  198. package/docs/reference/classes/OpenApiSpec.md +0 -892
  199. package/docs/reference/classes/RecoverableBaseEntity.md +0 -114
  200. package/docs/reference/classes/RecoverableBaseMongoEntity.md +0 -124
  201. package/docs/reference/classes/RedisTransport.md +0 -2202
  202. package/docs/reference/classes/RepoUtils.md +0 -482
  203. package/docs/reference/classes/RouteUtils.md +0 -191
  204. package/docs/reference/classes/Server.md +0 -408
  205. package/docs/reference/classes/SimpleEntity.md +0 -48
  206. package/docs/reference/classes/SimpleMongoEntity.md +0 -66
  207. package/docs/reference/classes/StatusExtraData.md +0 -57
  208. package/docs/reference/classes/StatusRoute.md +0 -26
  209. package/docs/reference/classes/UWSRequest.md +0 -226
  210. package/docs/reference/classes/UWSResponse.md +0 -257
  211. package/docs/reference/classes/UWSWebSocketShim.md +0 -958
  212. package/docs/reference/enumerations/ACLAction.md +0 -63
  213. package/docs/reference/enumerations/ApiErrorMessages.md +0 -123
  214. package/docs/reference/enumerations/ApiErrors.md +0 -123
  215. package/docs/reference/functions/createWebSocketStream.md +0 -27
  216. package/docs/reference/functions/isSqlDataSource.md +0 -26
  217. package/docs/reference/functions/readBody.md +0 -29
  218. package/docs/reference/functions/resolveCollectionName.md +0 -33
  219. package/docs/reference/functions/runChain.md +0 -40
  220. package/docs/reference/functions/snakeCase.md +0 -28
  221. package/docs/reference/globals.md +0 -106
  222. package/docs/reference/interfaces/ACLRecord.md +0 -96
  223. package/docs/reference/interfaces/AccessControlList.md +0 -76
  224. package/docs/reference/interfaces/AuthResult.md +0 -55
  225. package/docs/reference/interfaces/AuthStrategy.md +0 -95
  226. package/docs/reference/interfaces/CreateRequestOptions.md +0 -121
  227. package/docs/reference/interfaces/DeleteRequestOptions.md +0 -137
  228. package/docs/reference/interfaces/FindRequestOptions.md +0 -133
  229. package/docs/reference/interfaces/HttpRequest.md +0 -147
  230. package/docs/reference/interfaces/HttpResponse.md +0 -164
  231. package/docs/reference/interfaces/JWTAuthResult.md +0 -84
  232. package/docs/reference/interfaces/RepoCreateOptions.md +0 -95
  233. package/docs/reference/interfaces/RepoDeleteOptions.md +0 -105
  234. package/docs/reference/interfaces/RepoFindOptions.md +0 -125
  235. package/docs/reference/interfaces/RepoOperationOptions.md +0 -69
  236. package/docs/reference/interfaces/RepoUpdateOptions.md +0 -101
  237. package/docs/reference/interfaces/RequestOptions.md +0 -112
  238. package/docs/reference/interfaces/RequestWS.md +0 -225
  239. package/docs/reference/interfaces/TruncateRequestOptions.md +0 -161
  240. package/docs/reference/interfaces/UpdateRequestOptions.md +0 -139
  241. package/docs/reference/type-aliases/ErrorHandler.md +0 -35
  242. package/docs/reference/type-aliases/NextFunction.md +0 -23
  243. package/docs/reference/type-aliases/OneOrMany.md +0 -19
  244. package/docs/reference/type-aliases/OneOrNull.md +0 -19
  245. package/docs/reference/type-aliases/PartialBaseEntity.md +0 -17
  246. package/docs/reference/type-aliases/PartialSimpleEntity.md +0 -17
  247. package/docs/reference/type-aliases/RequestHandler.md +0 -31
  248. package/docs/reference/type-aliases/UpdateObject.md +0 -19
  249. package/docs/reference/type-aliases/WsUpgradeAuth.md +0 -27
  250. package/docs/reference/type-aliases/WsUpgradeAuthResult.md +0 -47
@@ -5,11 +5,6 @@
5
5
  * @author Jean-Philippe Steinmetz <rapidrests@gmail.com>
6
6
  */
7
7
  export declare abstract class BackgroundService {
8
- /** The global application configuration that the service can reference. */
9
- protected config: any;
10
- /** The logging utility to use. */
11
- protected logger: any;
12
- constructor(config: any, logger: any);
13
8
  /**
14
9
  * Returns the desired execution interval that this service should be scheduled with. If `undefined` is returned
15
10
  * the service is executed only once.
@@ -34,7 +34,7 @@ export declare class BackgroundServiceManager {
34
34
  private readonly logger;
35
35
  private objectFactory;
36
36
  private services;
37
- constructor(objectFactory: ObjectFactory, classes: {}, config: any, logger: any);
37
+ constructor(objectFactory: ObjectFactory, classes: {});
38
38
  /**
39
39
  * Returns the service instance with the given name.
40
40
  *
@@ -10,11 +10,11 @@ import { ObjectFactory } from "./ObjectFactory.js";
10
10
  * @author Jean-Philippe Steinmetz <rapidrests@gmail.com>
11
11
  */
12
12
  export declare class EventListenerManager {
13
- private channels;
14
- private logger;
15
- private objectFactory;
13
+ private readonly channels;
14
+ private readonly logger;
15
+ private readonly objectFactory;
16
16
  private handlers;
17
- private redis;
17
+ private readonly redis;
18
18
  constructor(objectFactory: ObjectFactory, redis: Redis);
19
19
  init(): Promise<void>;
20
20
  destroy(): Promise<void>;
@@ -1,12 +1,28 @@
1
1
  import * as prom from "prom-client";
2
2
  import "reflect-metadata";
3
3
  import { ConnectionManager } from "./database/ConnectionManager.js";
4
+ import { ClassLoader } from "@rapidrest/core";
4
5
  import { ObjectFactory } from "./ObjectFactory.js";
5
6
  import { BackgroundServiceManager } from "./BackgroundServiceManager.js";
6
7
  import { RouteUtils } from "./routes/RouteUtils.js";
7
8
  import { OpenApiSpec } from "./OpenApiSpec.js";
8
9
  import { EventListenerManager } from "./EventListenerManager.js";
9
10
  import { HttpRouter } from "./http/Router.js";
11
+ /**
12
+ * The configuration options to use when constructing a new Server instance.
13
+ */
14
+ export interface ServerOptions {
15
+ /** The nconf-compatible configuration object to initialize the server with. */
16
+ config: any;
17
+ /** The base file system path that models and routes will be searched from. Default is `.` */
18
+ basePath?: string;
19
+ /** The logging utility to use for outputing to console/file. Default is `Logger()` from `@rapidrest/core`. */
20
+ logger?: any;
21
+ /** The ClassLoader used to scan the source for all exported classes. */
22
+ classLoader?: ClassLoader;
23
+ /** The object factory to use for automatic dependency injection (IOC). */
24
+ objectFactory?: ObjectFactory;
25
+ }
10
26
  /**
11
27
  * Provides an HTTP server utilizing uWebSockets.js. The server automatically registers all routes, and
12
28
  * establishes database connections for all configured data stores. Additionally provides automatic authentication
@@ -124,6 +140,8 @@ export declare class Server {
124
140
  protected readonly config?: any;
125
141
  /** The manager for handling database connections. */
126
142
  protected connectionManager?: ConnectionManager;
143
+ /** The ClassLoader used to scan the source for all exported classes. */
144
+ protected classLoader: ClassLoader;
127
145
  /** The manager for handling events. */
128
146
  protected eventListenerManager?: EventListenerManager;
129
147
  /** The logging utility to use when outputing to console/file. */
@@ -141,14 +159,11 @@ export declare class Server {
141
159
  protected metricFailedRequests: prom.Counter<string>;
142
160
  protected metricTotalRequests: prom.Counter<string>;
143
161
  /**
144
- * Creates a new instance of Server with the specified defaults.
162
+ * Creates a new instance of Server with the specified default options.
145
163
  *
146
- * @param {any} config The nconf-compatible configuration object to initialize the server with.
147
- * @param {string} basePath The base file system path that models and routes will be searched from.
148
- * @param {Logger} logger The logging utility to use for outputing to console/file.
149
- * @param objectFactory The object factory to use for automatic dependency injection (IOC).
164
+ * @param options The configuration options to apply for this server.
150
165
  */
151
- constructor(config: any, basePath?: string, logger?: any, objectFactory?: ObjectFactory);
166
+ constructor(options: ServerOptions);
152
167
  /**
153
168
  * Returns the HTTP router instance.
154
169
  */
@@ -67,3 +67,12 @@ export declare function Returns(types?: any | any[]): (target: any, propertyKey:
67
67
  * becomes `[[Array, MyClass]]`).
68
68
  */
69
69
  export declare function TypeInfo(types?: any | any[]): (target: any, propertyKey: string) => void;
70
+ /**
71
+ * Retrieves the typing information of a class property or function, preferring the richer description provided by
72
+ * `@TypeInfo` and falling back to TypeScript's own `design:type` reflection metadata when `@TypeInfo` was not
73
+ * applied.
74
+ *
75
+ * @param target The class prototype (or class, for static members) to retrieve type information for.
76
+ * @param propertyKey The name of the property or function to retrieve type information for.
77
+ */
78
+ export declare function getTypeInfo(target: any, propertyKey: string): any;
@@ -26,6 +26,13 @@ export interface ColumnOptions {
26
26
  primary?: boolean;
27
27
  /** Set to `true` if the column stores a MongoDB `ObjectId` value. */
28
28
  isObjectId?: boolean;
29
+ /**
30
+ * Explicitly declares the SQL column type, overriding the type that would otherwise be inferred from
31
+ * TypeScript's reflected property type. Required whenever the design-time type cannot be reliably inferred,
32
+ * such as nullable/union-typed properties (which TypeScript reflects as `Object`) or properties whose value is
33
+ * a complex/nested structure that has no direct SQL column equivalent (e.g. `"simple-json"`).
34
+ */
35
+ type?: string | Function;
29
36
  }
30
37
  /**
31
38
  * The set of options to use when declaring a persistent class type via the `@Entity` decorator.
@@ -8,10 +8,19 @@ import { AccessControlList } from "../security/AccessControlList.js";
8
8
  */
9
9
  export declare function After(func: Function | string | (Function | string)[]): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
10
10
  /**
11
- * Applies PassportJS authentication to the decorated route or method for the provided strategy or list of strategies
11
+ * Indicates that the decorated class contains route definitions. This prepends `/api` or `/api/v{version}` to
12
+ * all provided path(s). e.g. `@ApiRoute('my-api')` results in `/api/my-api`. `@ApiRoute('my-api',2) results in
13
+ * `/api/v2/my-api`.
14
+ *
15
+ * @param paths The base path(s) that all route definitions will use.
16
+ * @param version The optional version number to prepend the path with. Prefixes the provided version with `v` in the path.
17
+ */
18
+ export declare function ApiRoute(paths: string | string[], version?: string | number): (target: Function) => void;
19
+ /**
20
+ * Applies authentication to the decorated route or method for the provided strategy or list of strategies
12
21
  * should be attempted before processing the route.
13
22
  *
14
- * @param strategies The PassportJS strategies that will be applied when incoming requests are processed.
23
+ * @param strategies The strategies that will be applied when incoming requests are processed.
15
24
  * @param require Set to `true` to indicate that at least one of the specified authentication strategies must pass to
16
25
  * proceed, otherwise set to `false`. Default is `true`.
17
26
  */
@@ -127,11 +136,11 @@ export declare function Protect(acl?: PartialACL): (target: any, propertyKey?: s
127
136
  */
128
137
  export declare function Query(name?: string | undefined): (target: any, propertyKey: string, index: number) => void;
129
138
  /**
130
- * Injects the Express request object as the value of the decorated argument.
139
+ * Injects the HTTP request object as the value of the decorated argument.
131
140
  */
132
141
  export declare function Request(target: any, propertyKey: string, index: number): void;
133
142
  /**
134
- * Injects the Express response object as the value of the decorated argument.
143
+ * Injects the HTTP response object as the value of the decorated argument.
135
144
  */
136
145
  export declare function Response(target: any, propertyKey: string, index: number): void;
137
146
  /**
@@ -142,7 +151,7 @@ export declare function Response(target: any, propertyKey: string, index: number
142
151
  */
143
152
  export declare function RequiresRole(roles: string | string[]): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
144
153
  /**
145
- * Indicates that the decorated class contains Express route definitions.
154
+ * Indicates that the decorated class contains route definitions.
146
155
  *
147
156
  * @param paths The base path(s) that all route definitions will use.
148
157
  */
@@ -40,7 +40,9 @@ export declare class UWSResponse implements HttpResponse {
40
40
  private _headers;
41
41
  private _headersSent;
42
42
  private _writableEnded;
43
+ private _streaming;
43
44
  private _aborted;
45
+ private _abortHandlers;
44
46
  /** Set to true for HEAD requests — body bytes must not be sent. */
45
47
  isHead: boolean;
46
48
  /** Intermediate result passed between middleware. */
@@ -57,6 +59,23 @@ export declare class UWSResponse implements HttpResponse {
57
59
  json(data: any): void;
58
60
  send(data?: any): void;
59
61
  end(data?: any): void;
62
+ /**
63
+ * Flushes status and headers to the wire immediately without ending the response.
64
+ * Required before streaming data (e.g. SSE). Safe to call multiple times — only
65
+ * acts on the first call.
66
+ */
67
+ flushHeaders(): void;
68
+ /**
69
+ * Writes a chunk to the response without ending it (streaming / SSE).
70
+ * Flushes headers on the first call if they haven't been sent yet.
71
+ */
72
+ write(data: string | Buffer): void;
73
+ /**
74
+ * Registers a callback to run when the client aborts the connection.
75
+ * Safe to call multiple times — all registered callbacks are invoked on abort.
76
+ * Uses the single uWS `onAborted` slot registered in the constructor.
77
+ */
78
+ onAbort(callback: () => void): void;
60
79
  /** Converts a numeric status code to the "200 OK" string format uWS expects. */
61
80
  private _statusToString;
62
81
  }
@@ -38,7 +38,6 @@ export type WsUpgradeAuth = (req: HttpRequest) => WsUpgradeAuthResult;
38
38
  *
39
39
  * Also supports:
40
40
  * - `ws(path, handlers)` — native uWS WebSocket routing
41
- * - `static(basePath)` — basic static file serving
42
41
  * - `listen(host, port)` / `close()` — server lifecycle
43
42
  */
44
43
  export declare class HttpRouter {
@@ -52,6 +51,12 @@ export declare class HttpRouter {
52
51
  private preRouteCount;
53
52
  /** The port the server is currently listening on (set after a successful `listen()` call). */
54
53
  listenPort: number;
54
+ /**
55
+ * HTTP verbs for which the application has already registered its own literal `/*` route
56
+ * (e.g. a `BaseStaticRoute` mounted at the site root via `@Route("/")`). Used by `listen()` to
57
+ * avoid clobbering an app-defined root catch-all with the default JSON 404 fallback.
58
+ */
59
+ private readonly rootWildcardVerbs;
55
60
  constructor(uwsApp: uWS.TemplatedApp);
56
61
  /** Returns `true` if the server is currently listening. */
57
62
  get isListening(): boolean;
@@ -83,11 +88,6 @@ export declare class HttpRouter {
83
88
  * Both `path` and `path + "/"` are registered to avoid trailing-slash mismatch.
84
89
  */
85
90
  ws(routePath: string, handlers: RequestHandler[], wsOptions?: Partial<uWS.WebSocketBehavior<any>>, upgradeAuth?: WsUpgradeAuth): this;
86
- /**
87
- * Serves static files from a directory via a wildcard GET route.
88
- * Files not found on disk return 404.
89
- */
90
- static(basePath: string): this;
91
91
  /**
92
92
  * Starts listening on the given host and port.
93
93
  * Resolves when the server is ready; rejects if the port cannot be bound.
@@ -9,6 +9,7 @@ import "reflect-metadata";
9
9
  export declare class ModelUtils {
10
10
  /** The `typeorm` module containing the query operators used to build SQL queries. */
11
11
  private static typeOrm;
12
+ private static idPropertyCache;
12
13
  /**
13
14
  * Provides the `typeorm` module to use when building SQL queries. This is called automatically when a SQL
14
15
  * datastore connection is established.
@@ -19,7 +20,7 @@ export declare class ModelUtils {
19
20
  /**
20
21
  * Returns the `typeorm` module, throwing an error if it has not been provided.
21
22
  */
22
- private static get orm();
23
+ static get orm(): any;
23
24
  /**
24
25
  * Retrieves a list of all of the specified class's properties that have the @Identifier decorator applied.
25
26
  *
@@ -0,0 +1,59 @@
1
+ import { JWTUser } from "@rapidrest/core";
2
+ import { Redis } from "ioredis";
3
+ import Transport from "winston-transport";
4
+ import { type UWSWebSocketShim } from "../http/WebSocket.js";
5
+ /**
6
+ * Implements a Winston transport that pipes incoming log messages to a configured redis pubsub channel.
7
+ */
8
+ export declare class RedisTransport extends Transport {
9
+ private channel;
10
+ private redis;
11
+ constructor(opts: any);
12
+ close(): void;
13
+ log(info: any, next: Function): any;
14
+ }
15
+ /**
16
+ * The `BaseAdminRoute` class provides a base set of endpoints that gives trusted users the ability to perform common adminstrative actions
17
+ * with the server.
18
+ *
19
+ * Exposed endpoints:
20
+ *
21
+ * | Name | HTTP Method | What it does |
22
+ * | --- | --- | --- |
23
+ * | `clearCache` | `GET /<base_path>/clear-cache` | Clears the Redis-based cache system. |
24
+ * | `logs` | `UPGRADE /<base_path>/logs` | Live tail the service logs |
25
+ * | `getReleaseNotes` | `GET /<base_path>/release-notes` | Retrieve the server release notes. |
26
+ * | `restart` | `GET /<base_path>/restart` | ` Restart the server |
27
+ *
28
+ * !!Note!! that the `BaseAdminRoute` is not automatically registered with a server by default. You must create
29
+ * your own class that extends `AdminRoute` and apply the desired base path with `@Route()`.
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * import { BaseAdminRoute, RouteDecorators } from "@rapidrest/service-core";
34
+ * const { Route } = RouteDecorators;
35
+ *
36
+ * @Route("/admin")
37
+ * export class AdminRoute extends BaseAdminRoute {}
38
+ * ```
39
+ *
40
+ * @author Jean-Philippe Steinmetz
41
+ */
42
+ export declare class BaseAdminRoute {
43
+ /** A map of user uid's to active sockets. */
44
+ protected activeSockets: Map<string, any[]>;
45
+ protected cacheClient?: Redis;
46
+ protected cacheConnConfig: any;
47
+ protected logger: any;
48
+ protected logsConnConfig: any;
49
+ protected redisClient?: Redis;
50
+ /** The underlying ReleaseNotes specification. */
51
+ protected releaseNotes?: string;
52
+ protected serviceName?: string;
53
+ protected trustedRoles: string[];
54
+ protected init(): Promise<void>;
55
+ clearCache(user?: JWTUser): Promise<void>;
56
+ logs(socket: UWSWebSocketShim, user: JWTUser): Promise<void>;
57
+ getReleaseNotes(user?: JWTUser): string | undefined;
58
+ restart(user?: JWTUser): void;
59
+ }
@@ -0,0 +1,37 @@
1
+ import * as prom from "prom-client";
2
+ import { JWTUser } from "@rapidrest/core";
3
+ /**
4
+ * The `BaseMetricsRoute` class provides a base set of endpoints for exposing Prometheus metrics.
5
+ *
6
+ * Exposed endpoints:
7
+ *
8
+ * | Name | HTTP Method | What it does |
9
+ * | --- | --- | --- |
10
+ * | `getMetrics` | `GET /<base_path>` | Returns all Prometheus metrics gathered by the system |
11
+ * | `getSingleMetric` | `GET /<base_path>/:metric` | Returns a single Prometheus metric with the given name |
12
+ *
13
+ * Services that wish to provide metrics to be exposed via this route can register them using the global registry
14
+ * from the provided `prom-client` dependency. See the `prom-client` documentation for more details.
15
+ *
16
+ * !!Note!! that the `BaseMetricsRoute` is not automatically registered with a server by default. You must create
17
+ * your own class that extends `AdminRoute` and apply the desired base path with `@Route()`.
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * import { BaseMetricsRoute, RouteDecorators } from "@rapidrest/service-core";
22
+ * const { Route } = RouteDecorators;
23
+ *
24
+ * @Route("/metrics")
25
+ * export class MetricsRoute extends BaseMetricsRoute {}
26
+ * ```
27
+ */
28
+ export declare class BaseMetricsRoute {
29
+ protected metricsConfig: {
30
+ authRequired: boolean;
31
+ };
32
+ protected registry: prom.Registry;
33
+ protected trustedRoles: string[];
34
+ constructor();
35
+ getMetrics(user?: JWTUser): Promise<string>;
36
+ getSingleMetric(metric: any, user?: JWTUser): Promise<string>;
37
+ }
@@ -0,0 +1,33 @@
1
+ import { OpenApiSpec } from "../OpenApiSpec.js";
2
+ /**
3
+ * The `BaseOpenAPIRoute` class provides a base set of endpoints exposing the server's OpenAPI specification.
4
+ *
5
+ * Exposed endpoints:
6
+ *
7
+ * | Name | HTTP Method | What it does |
8
+ * | --- | --- | --- |
9
+ * | `getHTML` | `GET /<base_path>` | Swagger UI HTML (loads swagger-ui-dist from CDN) |
10
+ * | `getJSON` | `GET /<base_path>/json` | raw OpenAPI specification as JSON |
11
+ * | `getYAML` | `GET /<base_path>/yaml` | raw OpenAPI specification as YAML |
12
+ *
13
+ * !!Note!! that the `BaseAdminRoute` is not automatically registered with a server by default. You must create
14
+ * your own class that extends `AdminRoute` and apply the desired base path with `@Route()`.
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * import { BaseOpenAPIRoute, RouteDecorators } from "@rapidrest/service-core";
19
+ * const { Route } = RouteDecorators;
20
+ *
21
+ * @Route("/openapi")
22
+ * export class OpenAPIRoute extends BaseOpenAPIRoute {}
23
+ * ```
24
+ *
25
+ * @author Jean-Philippe Steinmetz
26
+ */
27
+ export declare class BaseOpenAPIRoute {
28
+ /** The underlying OpenAPI specification. */
29
+ protected apiSpec: OpenApiSpec;
30
+ getHTML(): string;
31
+ getJSON(): any;
32
+ getYAML(): string;
33
+ }
@@ -0,0 +1,39 @@
1
+ import ws from "ws";
2
+ /**
3
+ * The `BasePushRoute` class provides a base set of endpoints for implement client push notifications.
4
+ *
5
+ * Exposed endpoints:
6
+ *
7
+ * | Name | HTTP Method | What it does |
8
+ * | --- | --- | --- |
9
+ * | `connect` | `UPGRADE /<base_path>/connect` | Establishes a connection to the push notification system. |
10
+ * | `send` | `POST /<base_path>/:id` | Sends a push notification message to the channel with the given id |
11
+ *
12
+ * !!Note!! that the `BasePushRoute` is not automatically registered with a server by default. You must create
13
+ * your own class that extends `AdminRoute` and apply the desired base path with `@Route()`.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * import { BasePushRoute, RouteDecorators } from "@rapidrest/service-core";
18
+ * const { Route } = RouteDecorators;
19
+ *
20
+ * @Route("/push")
21
+ * export class PushRoute extends BasePushRoute {}
22
+ * ```
23
+ *
24
+ * @author Jean-Philippe Steinmetz
25
+ */
26
+ export declare class BasePushRoute {
27
+ private aclUtils?;
28
+ /** A map of active socket connections to users. */
29
+ private activeSocks;
30
+ /** A map of active subscription uids to users. */
31
+ private activeSubs;
32
+ private logger;
33
+ private redisConfig;
34
+ /** A persistent redis client used to publish outgoing push messages. */
35
+ private redisPub?;
36
+ private init;
37
+ connect(sock: ws, user: any): Promise<void>;
38
+ send(id: string, msg: any, user: any): Promise<void>;
39
+ }
@@ -0,0 +1,44 @@
1
+ import { HttpRequest, HttpResponse } from "../http/types.js";
2
+ /**
3
+ * The `BaseStaticRoute` class provides a single endpoint for serving static files from a designated path on the filesystem (e.g. `./public`).
4
+ * Uses the path specified in the project configuration key `static_files`. Default is `public`.
5
+ *
6
+ * Exposed endpoints:
7
+ *
8
+ * | Name | HTTP Method | What it does |
9
+ * | --- | --- | --- |
10
+ * | `get` | `GET /<base_path>/*` | Serves static files from the configured `static_files`. |
11
+ *
12
+ * !!Note!! that the `BaseStaticRoute` is not automatically registered with a server by default. You must create
13
+ * your own class that extends `AdminRoute` and apply the desired base path with `@Route()`.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * import { BaseStaticRoute, RouteDecorators } from "@rapidrest/service-core";
18
+ * const { Route } = RouteDecorators;
19
+ *
20
+ * @Route("/static")
21
+ * export class StaticRoute extends BaseStaticRoute {}
22
+ * ```
23
+ *
24
+ * @author Jean-Philippe Steinmetz
25
+ */
26
+ export declare class BaseStaticRoute {
27
+ /**
28
+ * The URL prefix derived from `@Route` metadata at init time.
29
+ * E.g. `@Route("/app/*")` → prefix = "/app". Used to strip the prefix from req.path
30
+ * before resolving app page files, and to scope the dev-reload SSE endpoint.
31
+ */
32
+ protected routePrefix: string;
33
+ /** The location of the static files to serve. Defaults to `./public`. */
34
+ protected readonly staticDir: string;
35
+ protected init(): Promise<void>;
36
+ /**
37
+ * Resolve a file in the static directory by trying multiple extensions in order.
38
+ * If the path segment ends in a `/`, `index.html` is automatically appended.
39
+ *
40
+ * @returns The full path to the file on disk if exists, otherwise `null`.
41
+ */
42
+ private resolveFile;
43
+ get(req: HttpRequest, res: HttpResponse): Promise<any>;
44
+ }
@@ -0,0 +1,37 @@
1
+ import { StatusExtraData } from "../models/StatusExtraData.js";
2
+ /**
3
+ * The `BaseStatusRoute` class provides a base set of endpoints exposing status metadata information about the server.
4
+ *
5
+ * Included Metadata:
6
+ * | Name | Description |
7
+ * | --- | --- |
8
+ * | `name` | The name of the server (e.g. `petstore_example`) |
9
+ * | `time` | The current UTC timestamp of the server |
10
+ * | `version` | The release version of the server. (e.g. `1.0.0`) |
11
+ *
12
+ * Exposed endpoints:
13
+ *
14
+ * | Name | HTTP Method | What it does |
15
+ * | --- | --- | --- |
16
+ * | `get` | `GET /<base_path>` | Returns the server's status metadata |
17
+ *
18
+ * !!Note!! that the `BaseAdminRoute` is not automatically registered with a server by default. You must create
19
+ * your own class that extends `AdminRoute` and apply the desired base path with `@Route()`.
20
+ *
21
+ * @example
22
+ * ```ts
23
+ * import { BaseStatusRoute, RouteDecorators } from "@rapidrest/service-core";
24
+ * const { Route } = RouteDecorators;
25
+ *
26
+ * @Route("/status")
27
+ * export class StatusRoute extends BaseStatusRoute {}
28
+ * ```
29
+ *
30
+ * @author Jean-Philippe Steinmetz
31
+ */
32
+ export declare class BaseStatusRoute {
33
+ protected serviceName: any;
34
+ protected serviceVersion: any;
35
+ protected statusExtraData: StatusExtraData | undefined;
36
+ get(): any;
37
+ }
@@ -0,0 +1,47 @@
1
+ import { BaseEntity } from "../models/BaseEntity.js";
2
+ import type { HttpRequest, HttpResponse } from "../http/index.js";
3
+ import { SimpleEntity } from "../models/SimpleEntity.js";
4
+ import { JWTUser } from "@rapidrest/core";
5
+ import { ModelRoute, UpdateObject } from "./ModelRoute.js";
6
+ /**
7
+ * The `CRUDRoute` provides a base implementation of all CRUD endpoint behaviors that `ModelRoute` offers for a given
8
+ * data model class. This class provides the most common default settings for each route handler. If you desire additional
9
+ * functionality you may override the handler function and add desired functionality via additional decorators or override
10
+ * existing decorator behavior.
11
+ *
12
+ * The route endpoints provided by this class do not explicitly require authentication. However, if the RBAC system
13
+ * is enabled these handlers will still validate permissions appropriately.
14
+ *
15
+ * Included Endpoints:
16
+ *
17
+ * | Name | HTTP Method | What it does |
18
+ * | --- | --- | --- |
19
+ * | `count` | `HEAD /` | Counts the number of objects matching the provided set of criteria in the request's query parameters. Returns the count as the value of the `Content-Length` header. |
20
+ * | `create` | `POST /` | Adds one or more new objects to the datastore. |
21
+ * | `delete` | `DELETE /:id` | Removes an existing object from the datastore. |
22
+ * | `exists` | `HEAD /:id` | Checks if the object with the given ID exists in the datastore. Sets `Content-Length` header to `1` if the object exists, otherwise `0`. |
23
+ * | `find` | `GET /` | Returns all objects matching the provided set of criteria in the request's query parameters. |
24
+ * | `findById` | `GET /:id` | Returns a single object with a specified unique identifier. |
25
+ * | `truncate` | `DELETE /` | Removes all objects from the datastore. |
26
+ * | `update` | `PUT /:id` | Modifies an existing object in the datastore. |
27
+ * | `updateBulk` | `PUT /` | Modifies multiple existing objects in the datastore. |
28
+ * | `updateProperty` | `PUT /:id/:property` | Modifies an single property of the given name of an existing object in the datastore. |
29
+ *
30
+ * @author Jean-Philippe Steinmetz
31
+ */
32
+ export declare abstract class CRUDRoute<T extends BaseEntity | SimpleEntity> extends ModelRoute<T> {
33
+ protected readonly repoUtilsClass: any;
34
+ count(params: any, query: any, res: HttpResponse, user?: JWTUser): Promise<any>;
35
+ protected validateCreate(obj: Partial<T> | Partial<T>[], user?: JWTUser): Promise<void>;
36
+ create(obj: T | T[], req: HttpRequest, user?: JWTUser): Promise<T | Array<T>>;
37
+ delete(id: string, version: string | undefined, purge: string | undefined, req: HttpRequest, user?: JWTUser): Promise<void>;
38
+ exists(id: string, query: any, res: HttpResponse, user?: JWTUser): Promise<any>;
39
+ find(params: any, query: any, user?: JWTUser): Promise<Array<T>>;
40
+ findById(id: string, query: any, user?: JWTUser): Promise<T | null>;
41
+ truncate(params: any, query: any, user?: JWTUser): Promise<void>;
42
+ protected validateUpdate(id: string, obj: UpdateObject<T>, user?: JWTUser): Promise<void>;
43
+ update(id: string, obj: UpdateObject<T>, req: HttpRequest, user?: JWTUser): Promise<T>;
44
+ protected validateUpdateBulk(objs: UpdateObject<T>[], user?: JWTUser): Promise<void>;
45
+ updateBulk(obj: UpdateObject<T>[], req: HttpRequest, user?: JWTUser): Promise<T[]>;
46
+ updateProperty(id: string, propertyName: string, obj: any, user?: JWTUser): Promise<T>;
47
+ }
@@ -1,7 +1,7 @@
1
1
  import { RepoOperationOptions, RepoUtils } from "../models/RepoUtils.js";
2
2
  import { BaseEntity } from "../models/BaseEntity.js";
3
3
  import { Redis } from "ioredis";
4
- import type { HttpRequest as XRequest, HttpResponse as XResponse } from "../http/index.js";
4
+ import type { HttpRequest, HttpResponse } from "../http/index.js";
5
5
  import { SimpleEntity } from "../models/SimpleEntity.js";
6
6
  import { AccessControlList } from "../security/AccessControlList.js";
7
7
  import { ACLUtils } from "../security/ACLUtils.js";
@@ -12,9 +12,9 @@ import { ObjectFactory } from "../ObjectFactory.js";
12
12
  */
13
13
  export interface RequestOptions extends RepoOperationOptions {
14
14
  /** The originating client request. */
15
- req?: XRequest;
15
+ req?: HttpRequest;
16
16
  /** The outgoing client response. */
17
- res?: XResponse;
17
+ res?: HttpResponse;
18
18
  }
19
19
  /**
20
20
  * The set of options required by create request handlers.
@@ -78,16 +78,23 @@ export interface UpdateRequestOptions<T extends BaseEntity | SimpleEntity> exten
78
78
  }
79
79
  /**
80
80
  * The `ModelRoute` is an abstract base class that provides a set of built-in route behavior functions for handling
81
- * requests for a given data model that is managed by a persistent datastore.
81
+ * requests for a given data model that is managed by a persistent datastore. This class _does not_ provide route
82
+ * handlers for the defined behaviors. This class is intended to serve as a base class for you to extend and hook
83
+ * up your own route handlers that use the included functionality as desired so that you only expose the CRUD
84
+ * endpoints for your model that you desire. If you desire a fully functional set of route handlers that implements
85
+ * all of these behaviors you should extend the `CRUDRoute` class instead.
82
86
  *
83
87
  * Provided behaviors:
84
- * * `count` - Counts the number of objects matching the provided set of criteria in the request's query parameters.
85
- * * `create` - Adds a new object to the datastore.
86
- * * `delete` - Removes an existing object from the datastore.
87
- * * `find` - Finds all objects matching the provided set of criteria in the request's query parameters.
88
- * * `findById` - Finds a single object with a specified unique identifier.
89
- * * `truncate` - Removes all objects from the datastore.
90
- * * `update` - Modifies an existing object in the datastore.
88
+ * * `doCount`: Counts the number of objects matching the provided set of criteria in the request's query parameters. Returns the count as the value of the `Content-Length` header.
89
+ * * `doCreate`: Adds one or more new objects to the datastore.
90
+ * * `doDelete`: Removes an existing object from the datastore.
91
+ * * `doExists`: Checks if the object with the given ID exists in the datastore. Sets `Content-Length` header to `1` if the object exists, otherwise `0`.
92
+ * * `doFind`: Returns all objects matching the provided set of criteria in the request's query parameters.
93
+ * * `doFindById`: Returns a single object with a specified unique identifier.
94
+ * * `doTruncate`: Removes all objects from the datastore.
95
+ * * `doUpdate`: Modifies an existing object in the datastore.
96
+ * * `doUpdateBulk`: Modifies multiple existing objects in the datastore.
97
+ * * `doUpdateProperty`: Modifies an single property of the given name of an existing object in the datastore.
91
98
  *
92
99
  * @author Jean-Philippe Steinmetz
93
100
  */
@@ -103,7 +110,7 @@ export declare abstract class ModelRoute<T extends BaseEntity | SimpleEntity> {
103
110
  protected notificationUtils?: NotificationUtils;
104
111
  protected objectFactory?: ObjectFactory;
105
112
  /** The class of the RepoUtils to use when instantiating the utility. */
106
- protected readonly abstract repoUtilsClass: any;
113
+ protected abstract readonly repoUtilsClass: any;
107
114
  /** The repository utility class to use for common operations. */
108
115
  protected repoUtils?: RepoUtils<T>;
109
116
  /**
@@ -115,7 +122,7 @@ export declare abstract class ModelRoute<T extends BaseEntity | SimpleEntity> {
115
122
  /**
116
123
  * The class type of the model this route is associated with.
117
124
  */
118
- protected get modelClass(): any;
125
+ get modelClass(): any;
119
126
  /**
120
127
  * Called on server startup to initialize the route with any defaults.
121
128
  */
@@ -126,7 +133,7 @@ export declare abstract class ModelRoute<T extends BaseEntity | SimpleEntity> {
126
133
  *
127
134
  * @param options The options to process the request using.
128
135
  */
129
- protected doCount(options: FindRequestOptions): Promise<XResponse>;
136
+ protected doCount(options: FindRequestOptions): Promise<HttpResponse>;
130
137
  /**
131
138
  * Attempts to store an object provided in `options.req.body` into the datastore. Upon success, sets the newly persisted
132
139
  * object(s) to the `result` property of the `options.res` argument, otherwise sends a `400 BAD REQUEST` response to the
@@ -176,7 +183,7 @@ export declare abstract class ModelRoute<T extends BaseEntity | SimpleEntity> {
176
183
  *
177
184
  * @param options The options to process the request using.
178
185
  */
179
- protected doFindAll(options: FindRequestOptions): Promise<T[]>;
186
+ protected doFind(options: FindRequestOptions): Promise<T[]>;
180
187
  /**
181
188
  * Attempts to retrieve a single data model object as identified by the `id` parameter in the URI.
182
189
  *
@@ -218,5 +225,5 @@ export declare abstract class ModelRoute<T extends BaseEntity | SimpleEntity> {
218
225
  /**
219
226
  * Calls `repoUtils.validate()` to validate the object(s) provided.
220
227
  */
221
- protected doValidate(objs: Partial<T> | Partial<T>[], options?: CreateRequestOptions | UpdateRequestOptions<T>): Promise<void>;
228
+ validate(objs: Partial<T> | Partial<T>[], options?: CreateRequestOptions | UpdateRequestOptions<T>): Promise<void>;
222
229
  }