@rapidrest/service-core 1.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (332) hide show
  1. package/LICENSE +23 -0
  2. package/README.md +16 -0
  3. package/dist/lib/ApiErrors.js +41 -0
  4. package/dist/lib/ApiErrors.js.map +1 -0
  5. package/dist/lib/BackgroundService.js +16 -0
  6. package/dist/lib/BackgroundService.js.map +1 -0
  7. package/dist/lib/BackgroundServiceManager.js +135 -0
  8. package/dist/lib/BackgroundServiceManager.js.map +1 -0
  9. package/dist/lib/BulkError.js +24 -0
  10. package/dist/lib/BulkError.js.map +1 -0
  11. package/dist/lib/EventListenerManager.js +161 -0
  12. package/dist/lib/EventListenerManager.js.map +1 -0
  13. package/dist/lib/NetUtils.js +103 -0
  14. package/dist/lib/NetUtils.js.map +1 -0
  15. package/dist/lib/NotificationUtils.js +34 -0
  16. package/dist/lib/NotificationUtils.js.map +1 -0
  17. package/dist/lib/ObjectFactory.js +90 -0
  18. package/dist/lib/ObjectFactory.js.map +1 -0
  19. package/dist/lib/OpenApiSpec.js +748 -0
  20. package/dist/lib/OpenApiSpec.js.map +1 -0
  21. package/dist/lib/Server.js +549 -0
  22. package/dist/lib/Server.js.map +1 -0
  23. package/dist/lib/Types.js +2 -0
  24. package/dist/lib/Types.js.map +1 -0
  25. package/dist/lib/auth/AuthMiddleware.js +229 -0
  26. package/dist/lib/auth/AuthMiddleware.js.map +1 -0
  27. package/dist/lib/auth/AuthStrategy.js +2 -0
  28. package/dist/lib/auth/AuthStrategy.js.map +1 -0
  29. package/dist/lib/auth/BasicStrategy.js +106 -0
  30. package/dist/lib/auth/BasicStrategy.js.map +1 -0
  31. package/dist/lib/auth/JWTStrategy.js +161 -0
  32. package/dist/lib/auth/JWTStrategy.js.map +1 -0
  33. package/dist/lib/auth/index.js +5 -0
  34. package/dist/lib/auth/index.js.map +1 -0
  35. package/dist/lib/database/ConnectionKinds.js +14 -0
  36. package/dist/lib/database/ConnectionKinds.js.map +1 -0
  37. package/dist/lib/database/ConnectionManager.js +161 -0
  38. package/dist/lib/database/ConnectionManager.js.map +1 -0
  39. package/dist/lib/database/MongoConnection.js +86 -0
  40. package/dist/lib/database/MongoConnection.js.map +1 -0
  41. package/dist/lib/database/MongoRepository.js +136 -0
  42. package/dist/lib/database/MongoRepository.js.map +1 -0
  43. package/dist/lib/database/MongoSchemaSync.js +136 -0
  44. package/dist/lib/database/MongoSchemaSync.js.map +1 -0
  45. package/dist/lib/database/NamingUtils.js +52 -0
  46. package/dist/lib/database/NamingUtils.js.map +1 -0
  47. package/dist/lib/database/TypeOrmSupport.js +146 -0
  48. package/dist/lib/database/TypeOrmSupport.js.map +1 -0
  49. package/dist/lib/database/index.js +7 -0
  50. package/dist/lib/database/index.js.map +1 -0
  51. package/dist/lib/decorators/DatabaseDecorators.js +52 -0
  52. package/dist/lib/decorators/DatabaseDecorators.js.map +1 -0
  53. package/dist/lib/decorators/DocDecorators.js +120 -0
  54. package/dist/lib/decorators/DocDecorators.js.map +1 -0
  55. package/dist/lib/decorators/EventDecorators.js +24 -0
  56. package/dist/lib/decorators/EventDecorators.js.map +1 -0
  57. package/dist/lib/decorators/ModelDecorators.js +173 -0
  58. package/dist/lib/decorators/ModelDecorators.js.map +1 -0
  59. package/dist/lib/decorators/PersistenceDecorators.js +177 -0
  60. package/dist/lib/decorators/PersistenceDecorators.js.map +1 -0
  61. package/dist/lib/decorators/RouteDecorators.js +324 -0
  62. package/dist/lib/decorators/RouteDecorators.js.map +1 -0
  63. package/dist/lib/decorators/index.js +7 -0
  64. package/dist/lib/decorators/index.js.map +1 -0
  65. package/dist/lib/http/Adapters.js +230 -0
  66. package/dist/lib/http/Adapters.js.map +1 -0
  67. package/dist/lib/http/Router.js +403 -0
  68. package/dist/lib/http/Router.js.map +1 -0
  69. package/dist/lib/http/WebSocket.js +82 -0
  70. package/dist/lib/http/WebSocket.js.map +1 -0
  71. package/dist/lib/http/index.js +4 -0
  72. package/dist/lib/http/index.js.map +1 -0
  73. package/dist/lib/http/types.js +5 -0
  74. package/dist/lib/http/types.js.map +1 -0
  75. package/dist/lib/index.js +18 -0
  76. package/dist/lib/index.js.map +1 -0
  77. package/dist/lib/models/BaseEntity.js +83 -0
  78. package/dist/lib/models/BaseEntity.js.map +1 -0
  79. package/dist/lib/models/BaseMongoEntity.js +40 -0
  80. package/dist/lib/models/BaseMongoEntity.js.map +1 -0
  81. package/dist/lib/models/ModelUtils.js +645 -0
  82. package/dist/lib/models/ModelUtils.js.map +1 -0
  83. package/dist/lib/models/RecoverableBaseEntity.js +39 -0
  84. package/dist/lib/models/RecoverableBaseEntity.js.map +1 -0
  85. package/dist/lib/models/RecoverableBaseMongoEntity.js +40 -0
  86. package/dist/lib/models/RecoverableBaseMongoEntity.js.map +1 -0
  87. package/dist/lib/models/RepoUtils.js +717 -0
  88. package/dist/lib/models/RepoUtils.js.map +1 -0
  89. package/dist/lib/models/SimpleEntity.js +42 -0
  90. package/dist/lib/models/SimpleEntity.js.map +1 -0
  91. package/dist/lib/models/SimpleMongoEntity.js +38 -0
  92. package/dist/lib/models/SimpleMongoEntity.js.map +1 -0
  93. package/dist/lib/models/StatusExtraData.js +15 -0
  94. package/dist/lib/models/StatusExtraData.js.map +1 -0
  95. package/dist/lib/models/index.js +10 -0
  96. package/dist/lib/models/index.js.map +1 -0
  97. package/dist/lib/routes/AdminRoute.js +268 -0
  98. package/dist/lib/routes/AdminRoute.js.map +1 -0
  99. package/dist/lib/routes/MetricsRoute.js +86 -0
  100. package/dist/lib/routes/MetricsRoute.js.map +1 -0
  101. package/dist/lib/routes/ModelRoute.js +481 -0
  102. package/dist/lib/routes/ModelRoute.js.map +1 -0
  103. package/dist/lib/routes/OpenAPIRoute.js +115 -0
  104. package/dist/lib/routes/OpenAPIRoute.js.map +1 -0
  105. package/dist/lib/routes/RouteUtils.js +445 -0
  106. package/dist/lib/routes/RouteUtils.js.map +1 -0
  107. package/dist/lib/routes/StatusRoute.js +55 -0
  108. package/dist/lib/routes/StatusRoute.js.map +1 -0
  109. package/dist/lib/routes/index.js +7 -0
  110. package/dist/lib/routes/index.js.map +1 -0
  111. package/dist/lib/security/ACLRouteMongo.js +194 -0
  112. package/dist/lib/security/ACLRouteMongo.js.map +1 -0
  113. package/dist/lib/security/ACLRouteSQL.js +193 -0
  114. package/dist/lib/security/ACLRouteSQL.js.map +1 -0
  115. package/dist/lib/security/ACLUtils.js +457 -0
  116. package/dist/lib/security/ACLUtils.js.map +1 -0
  117. package/dist/lib/security/AccessControlList.js +18 -0
  118. package/dist/lib/security/AccessControlList.js.map +1 -0
  119. package/dist/lib/security/AccessControlListMongo.js +155 -0
  120. package/dist/lib/security/AccessControlListMongo.js.map +1 -0
  121. package/dist/lib/security/AccessControlListSQL.js +149 -0
  122. package/dist/lib/security/AccessControlListSQL.js.map +1 -0
  123. package/dist/lib/security/index.js +3 -0
  124. package/dist/lib/security/index.js.map +1 -0
  125. package/dist/lib/test/index.js +3 -0
  126. package/dist/lib/test/index.js.map +1 -0
  127. package/dist/lib/test/request.js +99 -0
  128. package/dist/lib/test/request.js.map +1 -0
  129. package/dist/lib/test/requestws.js +173 -0
  130. package/dist/lib/test/requestws.js.map +1 -0
  131. package/dist/types/ApiErrors.d.ts +38 -0
  132. package/dist/types/BackgroundService.d.ts +30 -0
  133. package/dist/types/BackgroundServiceManager.d.ts +66 -0
  134. package/dist/types/BulkError.d.ts +11 -0
  135. package/dist/types/EventListenerManager.d.ts +36 -0
  136. package/dist/types/NetUtils.d.ts +29 -0
  137. package/dist/types/NotificationUtils.d.ts +25 -0
  138. package/dist/types/ObjectFactory.d.ts +17 -0
  139. package/dist/types/OpenApiSpec.d.ts +114 -0
  140. package/dist/types/Server.d.ts +180 -0
  141. package/dist/types/Types.d.ts +8 -0
  142. package/dist/types/auth/AuthMiddleware.d.ts +42 -0
  143. package/dist/types/auth/AuthStrategy.d.ts +32 -0
  144. package/dist/types/auth/BasicStrategy.d.ts +33 -0
  145. package/dist/types/auth/JWTStrategy.d.ts +61 -0
  146. package/dist/types/auth/index.d.ts +4 -0
  147. package/dist/types/database/ConnectionKinds.d.ts +7 -0
  148. package/dist/types/database/ConnectionManager.d.ts +35 -0
  149. package/dist/types/database/MongoConnection.d.ts +54 -0
  150. package/dist/types/database/MongoRepository.d.ts +92 -0
  151. package/dist/types/database/MongoSchemaSync.d.ts +41 -0
  152. package/dist/types/database/NamingUtils.d.ts +24 -0
  153. package/dist/types/database/TypeOrmSupport.d.ts +20 -0
  154. package/dist/types/database/index.d.ts +6 -0
  155. package/dist/types/decorators/DatabaseDecorators.d.ts +18 -0
  156. package/dist/types/decorators/DocDecorators.d.ts +69 -0
  157. package/dist/types/decorators/EventDecorators.d.ts +12 -0
  158. package/dist/types/decorators/ModelDecorators.d.ts +80 -0
  159. package/dist/types/decorators/PersistenceDecorators.d.ts +117 -0
  160. package/dist/types/decorators/RouteDecorators.d.ts +172 -0
  161. package/dist/types/decorators/index.d.ts +6 -0
  162. package/dist/types/http/Adapters.d.ts +68 -0
  163. package/dist/types/http/Router.d.ts +99 -0
  164. package/dist/types/http/WebSocket.d.ts +56 -0
  165. package/dist/types/http/index.d.ts +6 -0
  166. package/dist/types/http/types.d.ts +54 -0
  167. package/dist/types/index.d.ts +17 -0
  168. package/dist/types/models/BaseEntity.d.ts +29 -0
  169. package/dist/types/models/BaseMongoEntity.d.ts +13 -0
  170. package/dist/types/models/ModelUtils.d.ts +166 -0
  171. package/dist/types/models/RecoverableBaseEntity.d.ts +16 -0
  172. package/dist/types/models/RecoverableBaseMongoEntity.d.ts +16 -0
  173. package/dist/types/models/RepoUtils.d.ts +154 -0
  174. package/dist/types/models/SimpleEntity.d.ts +14 -0
  175. package/dist/types/models/SimpleMongoEntity.d.ts +15 -0
  176. package/dist/types/models/StatusExtraData.d.ts +6 -0
  177. package/dist/types/models/index.d.ts +9 -0
  178. package/dist/types/routes/AdminRoute.d.ts +47 -0
  179. package/dist/types/routes/MetricsRoute.d.ts +15 -0
  180. package/dist/types/routes/ModelRoute.d.ts +226 -0
  181. package/dist/types/routes/OpenAPIRoute.d.ts +17 -0
  182. package/dist/types/routes/RouteUtils.d.ts +55 -0
  183. package/dist/types/routes/StatusRoute.d.ts +11 -0
  184. package/dist/types/routes/index.d.ts +6 -0
  185. package/dist/types/security/ACLRouteMongo.d.ts +19 -0
  186. package/dist/types/security/ACLRouteSQL.d.ts +19 -0
  187. package/dist/types/security/ACLUtils.d.ts +94 -0
  188. package/dist/types/security/AccessControlList.d.ts +103 -0
  189. package/dist/types/security/AccessControlListMongo.d.ts +24 -0
  190. package/dist/types/security/AccessControlListSQL.d.ts +24 -0
  191. package/dist/types/security/index.d.ts +2 -0
  192. package/dist/types/test/index.d.ts +2 -0
  193. package/dist/types/test/request.d.ts +24 -0
  194. package/dist/types/test/requestws.d.ts +21 -0
  195. package/docs/Makefile +20 -0
  196. package/docs/conf.py +58 -0
  197. package/docs/index.rst +17 -0
  198. package/docs/make.bat +35 -0
  199. package/docs/reference/@rapidrest/namespaces/DatabaseDecorators/README.md +13 -0
  200. package/docs/reference/@rapidrest/namespaces/DatabaseDecorators/functions/MongoRepository.md +25 -0
  201. package/docs/reference/@rapidrest/namespaces/DatabaseDecorators/functions/RedisConnection.md +25 -0
  202. package/docs/reference/@rapidrest/namespaces/DatabaseDecorators/functions/Repository.md +25 -0
  203. package/docs/reference/@rapidrest/namespaces/DocDecorators/README.md +23 -0
  204. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Default.md +25 -0
  205. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Description.md +25 -0
  206. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Document.md +25 -0
  207. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Example.md +25 -0
  208. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Format.md +25 -0
  209. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Returns.md +28 -0
  210. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Summary.md +25 -0
  211. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Tags.md +25 -0
  212. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/TypeInfo.md +28 -0
  213. package/docs/reference/@rapidrest/namespaces/DocDecorators/interfaces/DocumentsData.md +57 -0
  214. package/docs/reference/@rapidrest/namespaces/EventDecorators/README.md +12 -0
  215. package/docs/reference/@rapidrest/namespaces/EventDecorators/functions/EventListener.md +17 -0
  216. package/docs/reference/@rapidrest/namespaces/EventDecorators/functions/OnEvent.md +26 -0
  217. package/docs/reference/@rapidrest/namespaces/ModelDecorators/README.md +26 -0
  218. package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/Cache.md +25 -0
  219. package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/ChildEntity.md +18 -0
  220. package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/DataStore.md +25 -0
  221. package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/Identifier.md +27 -0
  222. package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/Protect.md +35 -0
  223. package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/Reference.md +25 -0
  224. package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/Shard.md +27 -0
  225. package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/TrackChanges.md +26 -0
  226. package/docs/reference/@rapidrest/namespaces/ModelDecorators/interfaces/PendingTypeOrmColumn.md +45 -0
  227. package/docs/reference/@rapidrest/namespaces/ModelDecorators/variables/pendingTypeOrmColumns.md +14 -0
  228. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/README.md +25 -0
  229. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/Column.md +25 -0
  230. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/Entity.md +26 -0
  231. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/Index.md +119 -0
  232. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/PrimaryColumn.md +25 -0
  233. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/Unique.md +68 -0
  234. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/getColumnMetadata.md +26 -0
  235. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/getEntityName.md +26 -0
  236. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/getIndexMetadata.md +27 -0
  237. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/interfaces/ColumnInfo.md +41 -0
  238. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/interfaces/ColumnOptions.md +51 -0
  239. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/interfaces/IndexInfo.md +41 -0
  240. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/interfaces/IndexOptions.md +51 -0
  241. package/docs/reference/@rapidrest/namespaces/RouteDecorators/README.md +36 -0
  242. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/After.md +26 -0
  243. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Auth.md +33 -0
  244. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/AuthResult.md +31 -0
  245. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Before.md +25 -0
  246. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/ContentType.md +25 -0
  247. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Delete.md +25 -0
  248. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Get.md +25 -0
  249. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Head.md +25 -0
  250. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Header.md +25 -0
  251. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Method.md +31 -0
  252. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Model.md +25 -0
  253. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Options.md +25 -0
  254. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Param.md +26 -0
  255. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Patch.md +25 -0
  256. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Post.md +25 -0
  257. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Protect.md +31 -0
  258. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Put.md +25 -0
  259. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Query.md +26 -0
  260. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Request.md +31 -0
  261. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/RequiresRole.md +26 -0
  262. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Response.md +31 -0
  263. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Route.md +25 -0
  264. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Socket.md +33 -0
  265. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/User.md +31 -0
  266. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Validate.md +25 -0
  267. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/WebSocket.md +25 -0
  268. package/docs/reference/README.md +20 -0
  269. package/docs/reference/classes/ACLUtils.md +251 -0
  270. package/docs/reference/classes/AdminRoute.md +51 -0
  271. package/docs/reference/classes/AuthMiddleware.md +131 -0
  272. package/docs/reference/classes/BackgroundService.md +117 -0
  273. package/docs/reference/classes/BackgroundServiceManager.md +172 -0
  274. package/docs/reference/classes/BaseEntity.md +82 -0
  275. package/docs/reference/classes/BaseMongoEntity.md +107 -0
  276. package/docs/reference/classes/BasicStrategy.md +89 -0
  277. package/docs/reference/classes/BasicStrategyOptions.md +91 -0
  278. package/docs/reference/classes/BulkError.md +271 -0
  279. package/docs/reference/classes/ConnectionManager.md +75 -0
  280. package/docs/reference/classes/EventListenerManager.md +88 -0
  281. package/docs/reference/classes/JWTStrategy.md +77 -0
  282. package/docs/reference/classes/JWTStrategyOptions.md +97 -0
  283. package/docs/reference/classes/MetricsRoute.md +27 -0
  284. package/docs/reference/classes/ModelRoute.md +527 -0
  285. package/docs/reference/classes/ModelUtils.md +448 -0
  286. package/docs/reference/classes/MongoConnection.md +218 -0
  287. package/docs/reference/classes/MongoRepository.md +354 -0
  288. package/docs/reference/classes/MongoSchemaSync.md +67 -0
  289. package/docs/reference/classes/NetUtils.md +90 -0
  290. package/docs/reference/classes/NotificationUtils.md +77 -0
  291. package/docs/reference/classes/ObjectFactory.md +336 -0
  292. package/docs/reference/classes/OpenAPIRoute.md +77 -0
  293. package/docs/reference/classes/OpenApiSpec.md +892 -0
  294. package/docs/reference/classes/RecoverableBaseEntity.md +114 -0
  295. package/docs/reference/classes/RecoverableBaseMongoEntity.md +124 -0
  296. package/docs/reference/classes/RedisTransport.md +2202 -0
  297. package/docs/reference/classes/RepoUtils.md +486 -0
  298. package/docs/reference/classes/RouteUtils.md +191 -0
  299. package/docs/reference/classes/Server.md +408 -0
  300. package/docs/reference/classes/SimpleEntity.md +48 -0
  301. package/docs/reference/classes/SimpleMongoEntity.md +66 -0
  302. package/docs/reference/classes/StatusExtraData.md +57 -0
  303. package/docs/reference/classes/StatusRoute.md +26 -0
  304. package/docs/reference/enumerations/ACLAction.md +63 -0
  305. package/docs/reference/enumerations/ApiErrorMessages.md +123 -0
  306. package/docs/reference/enumerations/ApiErrors.md +123 -0
  307. package/docs/reference/functions/isSqlDataSource.md +26 -0
  308. package/docs/reference/functions/resolveCollectionName.md +33 -0
  309. package/docs/reference/functions/snakeCase.md +28 -0
  310. package/docs/reference/globals.md +91 -0
  311. package/docs/reference/interfaces/ACLRecord.md +96 -0
  312. package/docs/reference/interfaces/AccessControlList.md +76 -0
  313. package/docs/reference/interfaces/AuthResult.md +55 -0
  314. package/docs/reference/interfaces/AuthStrategy.md +57 -0
  315. package/docs/reference/interfaces/CreateRequestOptions.md +121 -0
  316. package/docs/reference/interfaces/DeleteRequestOptions.md +147 -0
  317. package/docs/reference/interfaces/FindRequestOptions.md +133 -0
  318. package/docs/reference/interfaces/JWTAuthResult.md +84 -0
  319. package/docs/reference/interfaces/RepoCreateOptions.md +95 -0
  320. package/docs/reference/interfaces/RepoDeleteOptions.md +115 -0
  321. package/docs/reference/interfaces/RepoFindOptions.md +135 -0
  322. package/docs/reference/interfaces/RepoOperationOptions.md +69 -0
  323. package/docs/reference/interfaces/RepoUpdateOptions.md +111 -0
  324. package/docs/reference/interfaces/RequestOptions.md +112 -0
  325. package/docs/reference/interfaces/TruncateRequestOptions.md +175 -0
  326. package/docs/reference/interfaces/UpdateRequestOptions.md +149 -0
  327. package/docs/reference/type-aliases/OneOrMany.md +19 -0
  328. package/docs/reference/type-aliases/OneOrNull.md +19 -0
  329. package/docs/reference/type-aliases/PartialBaseEntity.md +17 -0
  330. package/docs/reference/type-aliases/PartialSimpleEntity.md +17 -0
  331. package/docs/reference/type-aliases/UpdateObject.md +19 -0
  332. package/package.json +125 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AccessControlListMongo.js","sourceRoot":"","sources":["../../../src/security/AccessControlListMongo.ts"],"names":[],"mappings":";;;;;;;;;AAAA,+EAA+E;AAC/E,wEAAwE;AACxE,+EAA+E;AAC/E,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,wCAAwC,CAAC;AAC/E,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,GAAG,aAAa,CAAC;AAChD,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,eAAe,CAAC;AAE7C;;GAEG;AAYI,IAAM,cAAc,GAApB,MAAM,cAAc;IAsCvB,YAAY,KAAW;QACnB,IAAI,KAAK,EAAE,CAAC;YACR,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,YAAY,CAAC;YACvC,IAAI,CAAC,MAAM,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C;IAClB,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC;;yDACmB;AAK/B;IAHN,WAAW,CAAC,8EAA8E,CAAC;IAC3F,MAAM,EAAE;IACR,QAAQ,CAAC,CAAC,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC;;uDACE;AAd7B,sBAAsB;IAxBlC,SAAS,CAAC,KAAK,CAAC;IAChB,MAAM,EAAE;IACR,KAAK,CAAC,IAAI,CAAC;IACX,WAAW,CAAC;;;;;;;;;;;;;;;;;;;;SAoBJ,CAAC;;GACG,sBAAsB,CAgClC"}
@@ -0,0 +1,149 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ ///////////////////////////////////////////////////////////////////////////////
11
+ // Copyright (C) 2020-2026 Jean-Philippe Steinmetz. All rights reserved.
12
+ ///////////////////////////////////////////////////////////////////////////////
13
+ import { DocDecorators, ModelDecorators } from "../decorators/index.js";
14
+ import { BaseEntity } from "../models/BaseEntity.js";
15
+ import { Column, Entity, Index } from "../decorators/PersistenceDecorators.js";
16
+ const { Description, TypeInfo } = DocDecorators;
17
+ const { Cache, DataStore } = ModelDecorators;
18
+ /**
19
+ * Implementation of the `ACLRecord` interface for use with SQL databases.
20
+ */
21
+ let ACLRecordSQL = class ACLRecordSQL {
22
+ constructor(other) {
23
+ if (other) {
24
+ this.userOrRoleId = other.userOrRoleId;
25
+ this.create = "create" in other ? other.create : null;
26
+ this.read = "read" in other ? other.read : null;
27
+ this.update = "update" in other ? other.update : null;
28
+ this.delete = "delete" in other ? other.delete : null;
29
+ this.special = "special" in other ? other.special : null;
30
+ this.full = "full" in other ? other.full : null;
31
+ }
32
+ else {
33
+ throw new Error("Argument other cannot be null.");
34
+ }
35
+ }
36
+ };
37
+ __decorate([
38
+ Description("The unique identiifer of the user or role that the record will apply to. This can also be a regular expression to match multiple users or roles."),
39
+ Column(),
40
+ Index("userOrRoleId"),
41
+ __metadata("design:type", String)
42
+ ], ACLRecordSQL.prototype, "userOrRoleId", void 0);
43
+ __decorate([
44
+ Description("The user or role can create a new record or object."),
45
+ Column(),
46
+ TypeInfo([Boolean]),
47
+ __metadata("design:type", Object)
48
+ ], ACLRecordSQL.prototype, "create", void 0);
49
+ __decorate([
50
+ Description("The user or role can read the record or object."),
51
+ Column(),
52
+ TypeInfo([Boolean]),
53
+ __metadata("design:type", Object)
54
+ ], ACLRecordSQL.prototype, "read", void 0);
55
+ __decorate([
56
+ Description("The user or role can modify existing records or objects."),
57
+ Column(),
58
+ TypeInfo([Boolean]),
59
+ __metadata("design:type", Object)
60
+ ], ACLRecordSQL.prototype, "update", void 0);
61
+ __decorate([
62
+ Description("The user or role can delete existing records or objects."),
63
+ Column(),
64
+ TypeInfo([Boolean]),
65
+ __metadata("design:type", Object)
66
+ ], ACLRecordSQL.prototype, "delete", void 0);
67
+ __decorate([
68
+ Description("The user or role has special prilieges to edit the ACL permissions."),
69
+ Column(),
70
+ TypeInfo([Boolean]),
71
+ __metadata("design:type", Object)
72
+ ], ACLRecordSQL.prototype, "special", void 0);
73
+ __decorate([
74
+ Description("The user or role has total control over the record or object and supersedes any of the above."),
75
+ Column(),
76
+ TypeInfo([Boolean]),
77
+ __metadata("design:type", Object)
78
+ ], ACLRecordSQL.prototype, "full", void 0);
79
+ ACLRecordSQL = __decorate([
80
+ Entity(),
81
+ Description(`
82
+ The \`ACLRecord\` interface describes a single permissions entry in an \`AccessControlList\` that grants or denies a set of permissions to a single user or role.
83
+
84
+ Each permission can be one of the following actions:
85
+ - \`Create\` - The user or role can create a new record or object.
86
+ - \`Read\` - The user or role can read the record or object.
87
+ - \`Update\` - The user or role can modify existing records or objects.
88
+ - \`Delete\` - The user or role can delete existing records or objects.
89
+ - \`Special\` - The user or role has special prilieges to edit the ACL permissions.
90
+ - \`Full\` - The user or role has total control over the record or object and supersedes any of the above.`),
91
+ __metadata("design:paramtypes", [Object])
92
+ ], ACLRecordSQL);
93
+ export { ACLRecordSQL };
94
+ /**
95
+ * Implementation of the `AccessControlList` interface for use with SQL databases.
96
+ */
97
+ let AccessControlListSQL = class AccessControlListSQL extends BaseEntity {
98
+ constructor(other) {
99
+ super(other);
100
+ this.records = [];
101
+ if (other) {
102
+ this.parent = "parent" in other ? other.parent : this.parent;
103
+ this.parentUid = "parentUid" in other ? other.parentUid : this.parentUid;
104
+ this.records = "records" in other ? other.records : this.records;
105
+ }
106
+ }
107
+ };
108
+ __decorate([
109
+ Description("The universally unique identifier of the parent `AccessControlList` that this object will inherit permissions from."),
110
+ Column(),
111
+ Index("parentUid"),
112
+ TypeInfo([String]),
113
+ __metadata("design:type", Object)
114
+ ], AccessControlListSQL.prototype, "parentUid", void 0);
115
+ __decorate([
116
+ Description("The list of all permission records associated with this access control list."),
117
+ Column(),
118
+ TypeInfo([[Array, ACLRecordSQL]]),
119
+ __metadata("design:type", Array)
120
+ ], AccessControlListSQL.prototype, "records", void 0);
121
+ AccessControlListSQL = __decorate([
122
+ DataStore("acl"),
123
+ Entity(),
124
+ Cache(),
125
+ Description(`The access control list provides a generic interface for the storage of user and roles permissions. Each ACL object
126
+ represents the permission set for a single entity within the system. The entity is identified generically by its
127
+ universally unique identifier (\`uuid\`). Each entry in the ACL records the permissions available to a particular user
128
+ or role.
129
+
130
+ Each permission can be one of the following actions:
131
+ - \`Create\` - The user or role can create a new record or object.
132
+ - \`Read\` - The user or role can read the record or object.
133
+ - \`Update\` - The user or role can modify existing records or objects.
134
+ - \`Delete\` - The user or role can delete existing records or objects.
135
+ - \`Special\` - The user or role has special prilieges to edit the ACL permissions.
136
+ - \`Full\` - The user or role has total control over the record or object and supersedes any of the above.
137
+
138
+ For each of the above actions the user or role will be granted either an \`allow\` permission or a \`deny\` permission.
139
+ If an \`allow\` is granted, the user or role has permission to perform that action. If a \`deny\` is set, then the user
140
+ or role is denied that action. If no explicit \`allow\` or \`deny\` is set then the user or role will inherit the
141
+ permission from a parent role or ACL.
142
+
143
+ ACLs can be chained via single inheritance through the specification of the \`parentUid\`. This allows the ability to
144
+ create complex trees of permissions that can easily inherit control schemes to make the definition of permissions
145
+ easier.`),
146
+ __metadata("design:paramtypes", [Object])
147
+ ], AccessControlListSQL);
148
+ export { AccessControlListSQL };
149
+ //# sourceMappingURL=AccessControlListSQL.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AccessControlListSQL.js","sourceRoot":"","sources":["../../../src/security/AccessControlListSQL.ts"],"names":[],"mappings":";;;;;;;;;AAAA,+EAA+E;AAC/E,wEAAwE;AACxE,+EAA+E;AAC/E,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,wCAAwC,CAAC;AAC/E,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,GAAG,aAAa,CAAC;AAChD,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,eAAe,CAAC;AAE7C;;GAEG;AAYI,IAAM,YAAY,GAAlB,MAAM,YAAY;IAsCrB,YAAY,KAAW;QACnB,IAAI,KAAK,EAAE,CAAC;YACR,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,YAAY,CAAC;YACvC,IAAI,CAAC,MAAM,GAAG,QAAQ,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,M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K,CAAC;IAChB,MAAM,EAAE;IACR,KAAK,EAAE;IACP,WAAW,CAAC;;;;;;;;;;;;;;;;;;;;SAoBJ,CAAC;;GACG,oBAAoB,CAyBhC"}
@@ -0,0 +1,3 @@
1
+ export * from "./AccessControlList.js";
2
+ export * from "./ACLUtils.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/security/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,eAAe,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from "./request.js";
2
+ export * from "./requestws.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/test/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC"}
@@ -0,0 +1,99 @@
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2020-2026 Jean-Philippe Steinmetz. All rights reserved.
3
+ ///////////////////////////////////////////////////////////////////////////////
4
+ /**
5
+ * Supertest-compatible HTTP test helper built on axios.
6
+ * Accepts either a Server instance (extracts port from server.port) or a port number.
7
+ */
8
+ import axios from "axios";
9
+ function extractPort(app) {
10
+ if (typeof app === "number")
11
+ return app;
12
+ // Server instance
13
+ if (app && typeof app.port === "number")
14
+ return app.port;
15
+ // HttpRouter instance
16
+ if (app && typeof app.listenPort === "number")
17
+ return app.listenPort;
18
+ throw new Error("request(): cannot determine port from argument");
19
+ }
20
+ function extractMimeType(contentType) {
21
+ if (!contentType)
22
+ return "";
23
+ return contentType.split(";")[0].trim();
24
+ }
25
+ /**
26
+ * Creates a supertest-style request builder that sends requests via axios to
27
+ * `http://localhost:<port>`.
28
+ */
29
+ export function request(app) {
30
+ const port = extractPort(app);
31
+ const baseUrl = `http://localhost:${port}`;
32
+ function makeChain(method, url) {
33
+ const hdrs = {};
34
+ let body = undefined;
35
+ const chain = {
36
+ set(key, value) {
37
+ hdrs[key] = value;
38
+ return chain;
39
+ },
40
+ send(data) {
41
+ body = data;
42
+ return chain;
43
+ },
44
+ then(onFulfilled, onRejected) {
45
+ // Auto-set Content-Type for JSON object bodies
46
+ if (body !== undefined && typeof body === "object" && !Buffer.isBuffer(body)) {
47
+ hdrs["content-type"] = hdrs["content-type"] || "application/json";
48
+ }
49
+ return axios
50
+ .request({
51
+ method,
52
+ url: baseUrl + url,
53
+ data: body,
54
+ headers: hdrs,
55
+ validateStatus: () => true,
56
+ responseType: "text",
57
+ transformResponse: (data) => data,
58
+ })
59
+ .then((res) => {
60
+ const raw = res.data;
61
+ const ct = res.headers["content-type"];
62
+ const mime = extractMimeType(ct);
63
+ let parsed;
64
+ try {
65
+ parsed = JSON.parse(raw);
66
+ }
67
+ catch {
68
+ parsed = raw;
69
+ }
70
+ const result = {
71
+ status: res.status,
72
+ statusCode: res.status,
73
+ body: parsed,
74
+ text: raw,
75
+ type: mime,
76
+ headers: res.headers,
77
+ ok: res.status >= 200 && res.status < 300,
78
+ };
79
+ return onFulfilled ? onFulfilled(result) : result;
80
+ })
81
+ .catch(onRejected);
82
+ },
83
+ catch(onRejected) {
84
+ return chain.then(undefined, onRejected);
85
+ },
86
+ };
87
+ return chain;
88
+ }
89
+ return {
90
+ get: (url) => makeChain("GET", url),
91
+ post: (url) => makeChain("POST", url),
92
+ put: (url) => makeChain("PUT", url),
93
+ delete: (url) => makeChain("DELETE", url),
94
+ patch: (url) => makeChain("PATCH", url),
95
+ head: (url) => makeChain("HEAD", url),
96
+ options: (url) => makeChain("OPTIONS", url),
97
+ };
98
+ }
99
+ //# sourceMappingURL=request.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request.js","sourceRoot":"","sources":["../../../src/test/request.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,wEAAwE;AACxE,+EAA+E;AAC/E;;;GAGG;AACH,OAAO,KAAK,MAAM,OAAO,CAA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C,UAAU,CAAC,CAAC;YAC3B,CAAC;YACD,KAAK,CAAC,UAAe;gBACjB,OAAO,KAAK,CAAC,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;YAC7C,CAAC;SACJ,CAAC;QAEF,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,OAAO;QACH,GAAG,EAAE,CAAC,GAAW,EAAE,EAAE,CAAC,SAAS,CAAC,KAAK,EAAE,GAAG,CAAC;QAC3C,IAAI,EAAE,CAAC,GAAW,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,EAAE,GAAG,CAAC;QAC7C,GAAG,EAAE,CAAC,GAAW,EAAE,EAAE,CAAC,SAAS,CAAC,KAAK,EAAE,GAAG,CAAC;QAC3C,MAAM,EAAE,CAAC,GAAW,EAAE,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,GAAG,CAAC;QACjD,KAAK,EAAE,CAAC,GAAW,EAAE,EAAE,CAAC,SAAS,CAAC,OAAO,EAAE,GAAG,CAAC;QAC/C,IAAI,EAAE,CAAC,GAAW,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,EAAE,GAAG,CAAC;QAC7C,OAAO,EAAE,CAAC,GAAW,EAAE,EAAE,CAAC,SAAS,CAAC,SAAS,EAAE,GAAG,CAAC;KACtD,CAAC;AACN,CAAC"}
@@ -0,0 +1,173 @@
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2020-2026 Jean-Philippe Steinmetz. All rights reserved.
3
+ ///////////////////////////////////////////////////////////////////////////////
4
+ /**
5
+ * Superwstest-compatible WebSocket test helper built on the `ws` package.
6
+ * Accepts a port number (or a Server instance with a `port` property).
7
+ */
8
+ import { WebSocket } from "ws";
9
+ /** Fluent WebSocket test chain, mirrors the superwstest API. */
10
+ export class WsChain {
11
+ constructor(url, wsOptions) {
12
+ this.actions = [];
13
+ this.url = url;
14
+ this.wsOptions = wsOptions;
15
+ }
16
+ expectText(value) {
17
+ this.actions.push({ kind: "expectText", value });
18
+ return this;
19
+ }
20
+ expectJson(value) {
21
+ this.actions.push({ kind: "expectJson", value });
22
+ return this;
23
+ }
24
+ expectClosed(code, reason) {
25
+ this.actions.push({ kind: "expectClosed", code, reason });
26
+ return this;
27
+ }
28
+ sendText(value) {
29
+ this.actions.push({ kind: "sendText", value });
30
+ return this;
31
+ }
32
+ sendJson(value) {
33
+ this.actions.push({ kind: "sendJson", value });
34
+ return this;
35
+ }
36
+ close() {
37
+ this.actions.push({ kind: "close" });
38
+ return this;
39
+ }
40
+ /** Execute the queued actions and resolve when all pass. */
41
+ then(onFulfilled, onRejected) {
42
+ return this._run().then(onFulfilled, onRejected);
43
+ }
44
+ catch(onRejected) {
45
+ return this._run().catch(onRejected);
46
+ }
47
+ _run() {
48
+ return new Promise((resolve, reject) => {
49
+ const actions = [...this.actions];
50
+ let actionIndex = 0;
51
+ let closed = false;
52
+ const ws = new WebSocket(this.url, this.wsOptions);
53
+ const timeout = setTimeout(() => {
54
+ ws.terminate();
55
+ reject(new Error(`WebSocket test timed out at action ${actionIndex}: ${JSON.stringify(actions[actionIndex])}`));
56
+ }, 10000);
57
+ const fail = (err) => {
58
+ clearTimeout(timeout);
59
+ ws.terminate();
60
+ reject(err instanceof Error ? err : new Error(String(err)));
61
+ };
62
+ const done = () => {
63
+ clearTimeout(timeout);
64
+ ws.terminate();
65
+ resolve();
66
+ };
67
+ /** Execute the next action, or resolve if all done. */
68
+ const next = () => {
69
+ if (actionIndex >= actions.length) {
70
+ done();
71
+ return;
72
+ }
73
+ const action = actions[actionIndex++];
74
+ if (action.kind === "sendText") {
75
+ ws.send(action.value, (err) => {
76
+ if (err) {
77
+ fail(err);
78
+ return;
79
+ }
80
+ next();
81
+ });
82
+ }
83
+ else if (action.kind === "sendJson") {
84
+ ws.send(JSON.stringify(action.value), (err) => {
85
+ if (err) {
86
+ fail(err);
87
+ return;
88
+ }
89
+ next();
90
+ });
91
+ }
92
+ else if (action.kind === "close") {
93
+ ws.close();
94
+ next();
95
+ }
96
+ else if (action.kind === "expectClosed") {
97
+ const checkClose = (code, _reason) => {
98
+ if (action.code !== undefined && code !== action.code) {
99
+ fail(new Error(`Expected close code ${action.code} but got ${code}`));
100
+ return;
101
+ }
102
+ if (action.reason !== undefined) {
103
+ const reasonStr = _reason.toString();
104
+ if (reasonStr !== action.reason) {
105
+ fail(new Error(`Expected close reason "${action.reason}" but got "${reasonStr}"`));
106
+ return;
107
+ }
108
+ }
109
+ closed = true;
110
+ next();
111
+ };
112
+ if (closed) {
113
+ next();
114
+ }
115
+ else {
116
+ ws.once("close", checkClose);
117
+ }
118
+ }
119
+ else {
120
+ // expectText / expectJson — wait for next message
121
+ ws.once("message", (raw) => {
122
+ try {
123
+ const text = raw.toString();
124
+ if (action.kind === "expectText") {
125
+ if (text !== action.value) {
126
+ fail(new Error(`Expected text "${action.value}" but got "${text}"`));
127
+ return;
128
+ }
129
+ }
130
+ else if (action.kind === "expectJson") {
131
+ const parsed = JSON.parse(text);
132
+ // Deep equal check
133
+ const exp = JSON.stringify(action.value);
134
+ const got = JSON.stringify(parsed);
135
+ if (exp !== got) {
136
+ fail(new Error(`Expected JSON ${exp} but got ${got}`));
137
+ return;
138
+ }
139
+ }
140
+ next();
141
+ }
142
+ catch (err) {
143
+ fail(err);
144
+ }
145
+ });
146
+ }
147
+ };
148
+ ws.on("error", fail);
149
+ ws.on("close", () => { closed = true; });
150
+ ws.on("open", () => {
151
+ next();
152
+ });
153
+ });
154
+ }
155
+ }
156
+ /** Creates a superwstest-style chain connected to `ws://localhost:<port>`. */
157
+ export function requestws(appOrPort) {
158
+ const port = typeof appOrPort === "number"
159
+ ? appOrPort
160
+ : appOrPort?.port ?? appOrPort?.listenPort;
161
+ if (!port) {
162
+ throw new Error("requestws(): cannot determine port from argument");
163
+ }
164
+ return {
165
+ ws(path, options) {
166
+ const wsOptions = options
167
+ ? { headers: options.headers }
168
+ : undefined;
169
+ return new WsChain(`ws://localhost:${port}${path}`, wsOptions);
170
+ },
171
+ };
172
+ }
173
+ //# sourceMappingURL=requestws.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"requestws.js","sourceRoot":"","sources":["../../../src/test/requestws.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,wEAAwE;AACxE,+EAA+E;AAC/E;;;GAGG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAU/B,gEAAgE;AAChE,MAAM,OAAO,OAAO;IAKhB,YAAY,GAAW,EAAE,SAAe;QAFvB,YAAO,GAAe,EAAE,CAAC;QAGtC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC/B,CAAC;IAED,UAAU,CAAC,KAAa;QACpB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC,CAAC;QACjD,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,UAAU,CAAC,KAAU;QACjB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC,CAAC;QACjD,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,YAAY,CAAC,IAAa,EAAE,MAAe;QACvC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;QAC1D,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,QAAQ,CAAC,KAAa;QAClB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;QAC/C,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,QAAQ,CAAC,KAAU;QACf,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;QAC/C,OAAO,IAAI,CAAC;IAChB,CAAC;I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AAS,GAAG,OAAO;gBACrB,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE;gBAC9B,CAAC,CAAC,SAAS,CAAC;YAChB,OAAO,IAAI,OAAO,CAAC,kBAAkB,IAAI,GAAG,IAAI,EAAE,EAAE,SAAS,CAAC,CAAC;QACnE,CAAC;KACJ,CAAC;AACN,CAAC"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Defines the unique codes for all common API errors.
3
+ */
4
+ export declare enum ApiErrors {
5
+ UNKNOWN = "api-001",
6
+ INTERNAL_ERROR = "api-002",
7
+ INVALID_REQUEST = "api-003",
8
+ NOT_FOUND = "api-010",
9
+ IDENTIFIER_EXISTS = "api-011",
10
+ INVALID_OBJECT_VERSION = "api-012",
11
+ OBJECT_ID_MISMATCH = "api-013",
12
+ SEARCH_INVALID_RANGE = "api-014",
13
+ SEARCH_INVALID_ME_REFERENCE = "api-015",
14
+ BULK_CREATE_FAILURE = "api-021",
15
+ BULK_UPDATE_FAILURE = "api-022",
16
+ AUTH_REQUIRED = "api-100",
17
+ AUTH_FAILED = "api-101",
18
+ AUTH_PERMISSION_FAILURE = "api-102"
19
+ }
20
+ /**
21
+ * Defines the default message of all common API errors.
22
+ */
23
+ export declare enum ApiErrorMessages {
24
+ UNKNOWN = "An unknown error has occurred. Please try again.",
25
+ INTERNAL_ERROR = "An internal error has occurred. Please contact the adminstrator.",
26
+ INVALID_REQUEST = "Invalid message or request.",
27
+ NOT_FOUND = "No resource could be found with the specified identifier.",
28
+ IDENTIFIER_EXISTS = "A resource with that identifier already exists.",
29
+ INVALID_OBJECT_VERSION = "Invalid object version. Do you have the latest version?",
30
+ OBJECT_ID_MISMATCH = "The object provided does not match the identifier given.",
31
+ SEARCH_INVALID_RANGE = "Invalid range value: '{{value}}'. Expected 2 arguments, got {{length}}",
32
+ SEARCH_INVALID_ME_REFERENCE = "Use of the `me` reference requires authentication.",
33
+ BULK_CREATE_FAILURE = "Failed to create one or more objects.",
34
+ BULK_UPDATE_FAILURE = "Failed to update one or more objects.",
35
+ AUTH_REQUIRED = "Authorization is required to access this resource.",
36
+ AUTH_FAILED = "Invalid or missing authentication token.",
37
+ AUTH_PERMISSION_FAILURE = "User does not have permission to perform this action."
38
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * The `BackgroundService` is an abstract base class for defining scheduled background services. A background service
3
+ * executes in the background once on startup or on a set schedule (like a cron job) and performs additional processing.
4
+ *
5
+ * @author Jean-Philippe Steinmetz <rapidrests@gmail.com>
6
+ */
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
+ /**
14
+ * Returns the desired execution interval that this service should be scheduled with. If `undefined` is returned
15
+ * the service is executed only once.
16
+ */
17
+ abstract get schedule(): string | undefined;
18
+ /**
19
+ * The processing function to execute at each scheduled interval.
20
+ */
21
+ abstract run(): Promise<void> | void;
22
+ /**
23
+ * Initializes the background service with any defaults.
24
+ */
25
+ abstract start(): Promise<void> | void;
26
+ /**
27
+ * Shuts down the background allowing the service to complete any outstanding tasks.
28
+ */
29
+ abstract stop(): Promise<void> | void;
30
+ }
@@ -0,0 +1,66 @@
1
+ import { BackgroundService } from "./BackgroundService.js";
2
+ import { ObjectFactory } from "./ObjectFactory.js";
3
+ /**
4
+ * The `BackgroundServiceManager` manages all configured background services in the application. It is responsible for
5
+ * initializing the jobs, scheduling them and performing any related shutdown tasks. See the `BackgroundService`
6
+ * class for details on how to create a background service class to be used by this manager.
7
+ *
8
+ * ## Usage
9
+ * To use the manager instantiate a new object and provide the required constructor arguments. Then simply call the
10
+ * `startAll` function. When shutting your application down you should call the `stopAll` function.
11
+ *
12
+ * ```
13
+ * import { BackgroundServiceManager } from "@rapidrest/service-core";
14
+ *
15
+ * const manager: BackgroundServiceManager = new BackgroundServiceManager(objectFactory, serviceClasses, config, logger);
16
+ * await manager.startAll();
17
+ * ...
18
+ * await manager.stopAll();
19
+ * ```
20
+ *
21
+ * You may optionally start and stop individual services using the `start` and `stop` functions respectively.
22
+ *
23
+ * ```
24
+ * await manager.start("MyService");
25
+ * ...
26
+ * await manger.stop("MyService");
27
+ * ```
28
+ * @author Jean-Philippe Steinmetz <rapidrests@gmail.com>
29
+ */
30
+ export declare class BackgroundServiceManager {
31
+ private readonly config;
32
+ private classes;
33
+ private jobs;
34
+ private readonly logger;
35
+ private objectFactory;
36
+ private services;
37
+ constructor(objectFactory: ObjectFactory, classes: {}, config: any, logger: any);
38
+ /**
39
+ * Returns the service instance with the given name.
40
+ *
41
+ * @param name The name of the background service to retrieve.
42
+ */
43
+ getService(name: string): BackgroundService | undefined;
44
+ /**
45
+ * Starts all configured background services.
46
+ */
47
+ startAll(): Promise<void>;
48
+ /**
49
+ * Starts the background service with the given name.
50
+ *
51
+ * @param serviceName The name of the background service to start.
52
+ * @param clazz The class type of the service to start. If not specified the name is used to lookup the class type.
53
+ * @param args The list of arguments to pass into the service constructor
54
+ */
55
+ start(serviceName: string, clazz?: any, ...args: any): Promise<void>;
56
+ /**
57
+ * Stops all currently active background services that are owned by the manager.
58
+ */
59
+ stopAll(): Promise<void>;
60
+ /**
61
+ * Stops the background service with the given name.
62
+ *
63
+ * @param serviceName The name of the background service to stop.
64
+ */
65
+ stop(serviceName: string): Promise<void>;
66
+ }
@@ -0,0 +1,11 @@
1
+ import { ApiError } from "@rapidrest/core";
2
+ /**
3
+ * An error take that takes an array of other errors.
4
+ */
5
+ export declare class BulkError extends ApiError {
6
+ /**
7
+ * The list of errors that have been thrown.
8
+ */
9
+ readonly errors: (Error | null)[];
10
+ constructor(errs: (Error | null)[], code: string, defaultStatus: number, message?: string);
11
+ }