@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,226 @@
1
+ import { RepoOperationOptions, RepoUtils } from "../models/RepoUtils.js";
2
+ import { BaseEntity } from "../models/BaseEntity.js";
3
+ import { Redis } from "ioredis";
4
+ import type { HttpRequest as XRequest, HttpResponse as XResponse } from "../http/index.js";
5
+ import { SimpleEntity } from "../models/SimpleEntity.js";
6
+ import { AccessControlList } from "../security/AccessControlList.js";
7
+ import { ACLUtils } from "../security/ACLUtils.js";
8
+ import { NotificationUtils } from "../NotificationUtils.js";
9
+ import { ObjectFactory } from "../ObjectFactory.js";
10
+ /**
11
+ * The set of options required by all request handlers.
12
+ */
13
+ export interface RequestOptions extends RepoOperationOptions {
14
+ /** The originating client request. */
15
+ req?: XRequest;
16
+ /** The outgoing client response. */
17
+ res?: XResponse;
18
+ }
19
+ /**
20
+ * The set of options required by create request handlers.
21
+ */
22
+ export interface CreateRequestOptions extends RequestOptions {
23
+ acl?: AccessControlList | AccessControlList[];
24
+ /** An additional list of channel names to send push notifications to. */
25
+ pushChannels?: string[];
26
+ /** Set to `true` to not send a push notification. */
27
+ skipPush?: boolean;
28
+ }
29
+ /**
30
+ * The set of options required by delete request handlers.
31
+ */
32
+ export interface DeleteRequestOptions extends RequestOptions {
33
+ /** The desired product uid of the resource to delete. */
34
+ productUid?: string;
35
+ /** Set to true to permanently remove the object from the database (if applicable). */
36
+ purge?: boolean;
37
+ /** An additional list of channel names to send push notifications to. */
38
+ pushChannels?: string[];
39
+ /** Set to `true` to not send a push notification. */
40
+ skipPush?: boolean;
41
+ /** The desired version number of the resource to delete. */
42
+ version?: number | string;
43
+ }
44
+ /**
45
+ * The set of options required by search request handlers.
46
+ */
47
+ export interface FindRequestOptions extends RequestOptions {
48
+ /** The list of URL parameters to use in the search. */
49
+ params?: any;
50
+ /** The list of query parameters to use in the search. */
51
+ query: any;
52
+ }
53
+ /**
54
+ * The set of options required by truncate request handlers.
55
+ */
56
+ export interface TruncateRequestOptions extends DeleteRequestOptions {
57
+ /** The list of URL parameters to use in the search. */
58
+ params: any;
59
+ /** An additional list of channel names to send push notifications to. */
60
+ pushChannels?: string[];
61
+ /** The list of query parameters to use in the search. */
62
+ query: any;
63
+ /** Set to `true` to not send a push notification. */
64
+ skipPush?: boolean;
65
+ }
66
+ /** A Partial type for a BaseEntity or SimpleEntity. */
67
+ export type UpdateObject<T extends BaseEntity | SimpleEntity> = Partial<T> & Pick<T, "uid">;
68
+ /**
69
+ * The set of options required by update request handlers.
70
+ */
71
+ export interface UpdateRequestOptions<T extends BaseEntity | SimpleEntity> extends RequestOptions {
72
+ /** The existing object that has already been recently pulled from the datastore. */
73
+ existing?: T | null;
74
+ /** The desired product uid of the resource to update. */
75
+ productUid?: string;
76
+ /** An additional list of channel names to send push notifications to. */
77
+ pushChannels?: string[];
78
+ /** Set to `true` to not send a push notification. */
79
+ skipPush?: boolean;
80
+ /** The desired version number of the resource to update. */
81
+ version?: number | string;
82
+ }
83
+ /**
84
+ * The `ModelRoute` is an abstract base class that provides a set of built-in route behavior functions for handling
85
+ * requests for a given data model that is managed by a persistent datastore.
86
+ *
87
+ * Provided behaviors:
88
+ * * `count` - Counts the number of objects matching the provided set of criteria in the request's query parameters.
89
+ * * `create` - Adds a new object to the datastore.
90
+ * * `delete` - Removes an existing object from the datastore.
91
+ * * `find` - Finds all objects matching the provided set of criteria in the request's query parameters.
92
+ * * `findById` - Finds a single object with a specified unique identifier.
93
+ * * `truncate` - Removes all objects from the datastore.
94
+ * * `update` - Modifies an existing object in the datastore.
95
+ *
96
+ * @author Jean-Philippe Steinmetz
97
+ */
98
+ export declare abstract class ModelRoute<T extends BaseEntity | SimpleEntity> {
99
+ protected aclUtils?: ACLUtils;
100
+ /** The redis client that will be used as a 2nd level cache for all cacheable models. */
101
+ protected cacheClient?: Redis;
102
+ /** The global application configuration. */
103
+ protected config?: any;
104
+ /** The unique identifier of the default ACL for the model type. */
105
+ protected defaultACLUid: string;
106
+ protected logger: any;
107
+ protected notificationUtils?: NotificationUtils;
108
+ protected objectFactory?: ObjectFactory;
109
+ /** The class of the RepoUtils to use when instantiating the utility. */
110
+ protected readonly abstract repoUtilsClass: any;
111
+ /** The repository utility class to use for common operations. */
112
+ protected repoUtils?: RepoUtils<T>;
113
+ /**
114
+ * The number of previous document versions to store in the database. A negative value indicates storing all
115
+ * versions, a value of `0` stores no versions.
116
+ */
117
+ protected trackChanges: number;
118
+ protected trustedRoles: string[];
119
+ /**
120
+ * The class type of the model this route is associated with.
121
+ */
122
+ protected get modelClass(): any;
123
+ /**
124
+ * Called on server startup to initialize the route with any defaults.
125
+ */
126
+ private superInitialize;
127
+ /**
128
+ * Attempts to retrieve the number of data model objects matching the given set of criteria as specified in the
129
+ * request `query`. Any results that have been found are set to the `content-length` header of the `res` argument.
130
+ *
131
+ * @param options The options to process the request using.
132
+ */
133
+ protected doCount(options: FindRequestOptions): Promise<XResponse>;
134
+ /**
135
+ * Attempts to store an object provided in `options.req.body` into the datastore. Upon success, sets the newly persisted
136
+ * object(s) to the `result` property of the `options.res` argument, otherwise sends a `400 BAD REQUEST` response to the
137
+ * client.
138
+ *
139
+ * @param obj The object to store in the database.
140
+ * @param options The options to process the request using.
141
+ */
142
+ protected doCreateObject(obj: Partial<T>, options: CreateRequestOptions): Promise<T>;
143
+ /**
144
+ * Attempts to store a collection of objects provided in `options.req.body` into the datastore. Upon success, sets the newly persisted
145
+ * object(s) to the `result` property of the `options.res` argument, otherwise sends a `400 BAD REQUEST` response to the
146
+ * client.
147
+ *
148
+ * @param objs The object(s) to store in the database.
149
+ * @param options The options to process the request using.
150
+ */
151
+ protected doBulkCreate(objs: Partial<T>[], options: CreateRequestOptions): Promise<T[]>;
152
+ /**
153
+ * Attempts to store one or more objects provided in `options.req.body` into the datastore. Upon success, sets the newly persisted
154
+ * object(s) to the `result` property of the `options.res` argument, otherwise sends a `400 BAD REQUEST` response to the
155
+ * client.
156
+ *
157
+ * @param obj The object(s) to store in the database.
158
+ * @param options The options to process the request using.
159
+ */
160
+ protected doCreate(obj: Partial<T> | Partial<T>[], options: CreateRequestOptions): Promise<T | T[]>;
161
+ /**
162
+ * Attempts to delete an existing data model object with a given unique identifier encoded by the URI parameter
163
+ * `id`.
164
+ *
165
+ * @param id The unique identifier of the object to delete.
166
+ * @param options The options to process the request using.
167
+ */
168
+ protected doDelete(id: string, options: DeleteRequestOptions): Promise<void>;
169
+ /**
170
+ * Attempts to determine if an existing object with the given unique identifier exists.
171
+ *
172
+ * @param id The unique identifier of the object to verify exists.
173
+ * @param options The options to process the request using.
174
+ */
175
+ protected doExists(id: string, options: FindRequestOptions): Promise<any>;
176
+ /**
177
+ * Attempts to retrieve all data model objects matching the given set of criteria as specified in the request
178
+ * `query`. Any results that have been found are set to the `result` property of the `res` argument. `result` is
179
+ * never null.
180
+ *
181
+ * @param options The options to process the request using.
182
+ */
183
+ protected doFindAll(options: FindRequestOptions): Promise<T[]>;
184
+ /**
185
+ * Attempts to retrieve a single data model object as identified by the `id` parameter in the URI.
186
+ *
187
+ * @param options The options to process the request using.
188
+ */
189
+ protected doFindById(id: string, options: FindRequestOptions): Promise<T | null>;
190
+ /**
191
+ * Attempts to remove all entries of the data model type from the datastore matching the given
192
+ * parameters and query.
193
+ *
194
+ * @param options The options to process the request using.
195
+ */
196
+ protected doTruncate(options: TruncateRequestOptions): Promise<void>;
197
+ /**
198
+ * Attempts to modify a collection of existing data model objects.
199
+ *
200
+ * @param objs The object(s) to bulk update in the database.
201
+ * @param options The options to process the request using.
202
+ */
203
+ protected doBulkUpdate(objs: UpdateObject<T>[], options: UpdateRequestOptions<T>): Promise<T[]>;
204
+ /**
205
+ * Attempts to modify an existing data model object as identified by the `id` parameter in the URI.
206
+ *
207
+ * @param obj The object to update in the database
208
+ * @param options The options to process the request using.
209
+ */
210
+ protected doUpdate(id: string, obj: UpdateObject<T>, options: UpdateRequestOptions<T>): Promise<T>;
211
+ /**
212
+ * Attempts to modify a single property of an existing data model object as identified by the `id` parameter in the URI.
213
+ *
214
+ * Note that this effectively bypasses optimistic locking and can cause unexpected data overwrites. Use with care.
215
+ *
216
+ * @param id The unique identifier of the object to update.
217
+ * @param propertyName The name of the property to update.
218
+ * @param value The value of the property to set.
219
+ * @param options The options to process the request using.
220
+ */
221
+ protected doUpdateProperty(id: string, propertyName: string, value: any, options: UpdateRequestOptions<T>): Promise<T>;
222
+ /**
223
+ * Calls `repoUtils.validate()` to validate the object(s) provided.
224
+ */
225
+ protected doValidate(objs: Partial<T> | Partial<T>[], options?: CreateRequestOptions | UpdateRequestOptions<T>): Promise<void>;
226
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * The `OpenAPIRoute` provides default routes to expose the service's OpenAPI specification.
3
+ *
4
+ * - `GET /` — Swagger UI HTML (loads swagger-ui-dist from CDN)
5
+ * - `GET /openapi.json` — raw OpenAPI specification as JSON
6
+ * - `GET /openapi.yaml` — raw OpenAPI specification as YAML
7
+ *
8
+ * @author Jean-Philippe Steinmetz
9
+ */
10
+ export declare class OpenAPIRoute {
11
+ /** The underlying OpenAPI specification. */
12
+ private apiSpec;
13
+ getHTML(): string;
14
+ getAPIDocs(): string;
15
+ getJSON(): any;
16
+ getYAML(): string;
17
+ }
@@ -0,0 +1,55 @@
1
+ import type { RequestHandler } from "../http/types.js";
2
+ /**
3
+ * Provides a set of utilities for converting Route classes to HTTP middleware.
4
+ *
5
+ * @author Jean-Philippe Steinmetz <rapidrests@gmail.com>
6
+ */
7
+ export declare class RouteUtils {
8
+ private aclUtils?;
9
+ private apiSpec;
10
+ private authMiddleware?;
11
+ private logger?;
12
+ /**
13
+ * Creates a middleware function that verifies the incoming request is from a valid user with at least
14
+ * one of the specified roles.
15
+ */
16
+ checkRequiredPerms(aclUid: string): RequestHandler;
17
+ /**
18
+ * Creates a middleware function that verifies the incoming request is from a valid user with at least
19
+ * one of the specified roles.
20
+ *
21
+ * @param requiredRoles The list of roles that the authenticated user must have.
22
+ */
23
+ checkRequiredRoles(requiredRoles: string[]): RequestHandler;
24
+ /**
25
+ * Converts the given array of string or Function objects to functions bound to the given route object.
26
+ *
27
+ * @param route The route object that the list of functions is bound to.
28
+ * @param funcs The array of functions (or function names) to return.
29
+ * @param send Set to true to have the last wrapped function send its payload to the client.
30
+ * @returns An array of Function objects mapping to the route object.
31
+ */
32
+ getFuncArray(route: any, funcs: (Function | string)[], send?: boolean): RequestHandler[];
33
+ /**
34
+ * Searches an route object for any functions that implement a `@Method` decorator.
35
+ *
36
+ * @param route The route object to search.
37
+ * @returns The list of `@Method` decorated functions that were found.
38
+ */
39
+ getRouteMethods(route: any): Map<string, any>;
40
+ /**
41
+ * Registers the provided route object containing a set of decorated endpoints to the server.
42
+ *
43
+ * @param app The HTTP application/router to register the route to.
44
+ * @param route The route object to register.
45
+ */
46
+ registerRoute(app: any, route: any): Promise<void>;
47
+ /**
48
+ * Wraps the provided function with HTTP handling based on the function's defined decorators.
49
+ *
50
+ * @param obj The bound object whose middleware function will be wrapped.
51
+ * @param func The decorated function to wrap.
52
+ * @param send Set to true to have `func`'s result sent to the client.
53
+ */
54
+ wrapMiddleware(obj: any, func: Function, send?: boolean): RequestHandler;
55
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * The `StatusRoute` provides a default `/status` endpoint the returns metadata information about the service such as
3
+ * name, version.
4
+ *
5
+ * @author Jean-Philippe Steinmetz
6
+ */
7
+ export declare class StatusRoute {
8
+ private config;
9
+ private statusExtraData;
10
+ private get;
11
+ }
@@ -0,0 +1,6 @@
1
+ export * from "./AdminRoute.js";
2
+ export * from "./MetricsRoute.js";
3
+ export * from "./ModelRoute.js";
4
+ export * from "./OpenAPIRoute.js";
5
+ export * from "./RouteUtils.js";
6
+ export * from "./StatusRoute.js";
@@ -0,0 +1,19 @@
1
+ import { AccessControlListMongo } from "./AccessControlListMongo.js";
2
+ import { MongoRepository as Repo } from "../database/MongoRepository.js";
3
+ import { ModelRoute } from "../routes/ModelRoute.js";
4
+ export declare class ACLRouteMongo extends ModelRoute<AccessControlListMongo> {
5
+ protected repo?: Repo<AccessControlListMongo>;
6
+ protected readonly repoUtilsClass: any;
7
+ constructor();
8
+ /**
9
+ * The base key used to get or set data in the cache.
10
+ */
11
+ protected get baseCacheKey(): string;
12
+ private create;
13
+ private updateBulk;
14
+ private count;
15
+ private findAll;
16
+ private delete;
17
+ private findById;
18
+ private update;
19
+ }
@@ -0,0 +1,19 @@
1
+ import { AccessControlListSQL } from "./AccessControlListSQL.js";
2
+ import type { Repository as Repo } from "typeorm";
3
+ import { ModelRoute } from "../routes/ModelRoute.js";
4
+ export declare class ACLRouteSQL extends ModelRoute<AccessControlListSQL> {
5
+ protected repo?: Repo<AccessControlListSQL>;
6
+ protected readonly repoUtilsClass: any;
7
+ constructor();
8
+ /**
9
+ * The base key used to get or set data in the cache.
10
+ */
11
+ protected get baseCacheKey(): string;
12
+ private create;
13
+ private updateBulk;
14
+ private count;
15
+ private findAll;
16
+ private delete;
17
+ private findById;
18
+ private update;
19
+ }
@@ -0,0 +1,94 @@
1
+ import { JWTUser } from "@rapidrest/core";
2
+ import type { HttpRequest as Request } from "../http/index.js";
3
+ import { AccessControlList, ACLAction, ACLRecord } from "./AccessControlList.js";
4
+ /**
5
+ * Common utility functions for working with `AccessControlList` objects and validating user permissions.
6
+ */
7
+ export declare class ACLUtils {
8
+ private cacheTTL;
9
+ private connMgr?;
10
+ private trustedRoles;
11
+ private get cacheClient();
12
+ private get repo();
13
+ /**
14
+ * Checks to see if the provided user matches the providedUserOrRoleId.
15
+ * @param user The user to check.
16
+ * @param userOrRoleId The ACL record id to check against.
17
+ * @returns `true` if the user contains a `uid` or `role` that matches the `userOrRoleId`, otherwise `false`.
18
+ */
19
+ private userMatchesId;
20
+ /**
21
+ * Validates that the user has permission to perform the request operation against the URL path for the
22
+ * provided request. If ACLUtils has not been initialized or the `acl` datastore has not been configured
23
+ * then always returns `true`.
24
+ *
25
+ * @param uid The uid of the access control list to verify against.
26
+ * @param user The user to validate.
27
+ * @param req The request whose URL path and method will be verified.
28
+ */
29
+ checkRequestPerms(uid: string, user: JWTUser | undefined, req: Request): Promise<boolean>;
30
+ /**
31
+ * Validates that the user has permission to perform the provided action using the given access control list.
32
+ *
33
+ * @param user The user to validate permissions of.
34
+ * @param acl The ACL or uid of an ACL to validate permissions against.
35
+ * @param action The action that the user desires permission for.
36
+ * @returns `true` if the user has at least one of the permissions granted for the given entity, otherwise `false`.
37
+ */
38
+ hasPermission(user: JWTUser | undefined, acl: AccessControlList | string, action: ACLAction): Promise<boolean>;
39
+ /**
40
+ * Retrieves the access control list with the associated identifier and populates the parent(s).
41
+ *
42
+ * @param entityId The unique identifier of the ACL to retrieve.
43
+ * @param parentUids The list of already found parent UIDs. This is used to break circular dependencies.
44
+ */
45
+ findACL(entityId: string, parentUids?: string[]): Promise<AccessControlList | null>;
46
+ /**
47
+ * Deletes the ACL with the given identifier from the database.
48
+ * @param uid The unique identifier of the ACL to remove.
49
+ */
50
+ removeACL(uid: string): Promise<void>;
51
+ /**
52
+ * Compares two ACLs to see if they have been modified and returns the total number of changes between them.
53
+ *
54
+ * @param aclA The source ACL to compare against.
55
+ * @param aclB The new ACL to compare with.
56
+ * @returns The total number of changes between the two ACLs.
57
+ */
58
+ private diffACL;
59
+ /**
60
+ * Stores the given access control list into the ACL database.
61
+ *
62
+ * @param acl The ACL to store.
63
+ * @return Returns the ACL that was stored in the database.
64
+ */
65
+ saveACL(acl: AccessControlList): Promise<AccessControlList | null>;
66
+ /**
67
+ * Stores the given default access control list into the ACL database. A default ACL is a special type of ACL
68
+ * that is primarily defined and maintained within the code but allows for user-specific overrides. To accomplish
69
+ * this, the provided ACL is split in two. A new record is automatically created with the `uid` of the form
70
+ * `default_<uid>` that stores the exact record as provided by code. Then a second ACL record is created
71
+ * with the `uid` being that of what is passed as the argument. This second ACL is used to store user-defined
72
+ * overrides. As the `default_<uid>` record is always overwritten with the lastest version of the code, any
73
+ * user-defined changes made to it are lost on service restart.
74
+ *
75
+ * @param defaultAcl
76
+ * @returns
77
+ */
78
+ saveDefaultACL(acl: AccessControlList): Promise<AccessControlList | null>;
79
+ /**
80
+ * Retrieves the first available record in the provided ACL associated with the provided user.
81
+ *
82
+ * @param acl The access control list that will be searched.
83
+ * @param user The user to find a record for.
84
+ * @returns The ACL record associated with the given user if found, otherwise `undefined`.
85
+ */
86
+ getRecord(acl: AccessControlList, user: JWTUser | undefined): ACLRecord | null;
87
+ /**
88
+ * Attempts to retrieve the parent access control list for the given ACL object.
89
+ *
90
+ * @param acl The access control list whose parents will be populated.
91
+ * @param parentUids The list of already found parent UIDs. This is used to break circular dependencies.
92
+ */
93
+ populateParent(acl: AccessControlList, parentUids?: string[]): Promise<void>;
94
+ }
@@ -0,0 +1,103 @@
1
+ /**
2
+ * Describes the various permission actions that can be performed against an entity.
3
+ *
4
+ * @author Jean-Philippe Steinmetz <rapidrests@gmail.com>
5
+ */
6
+ export declare enum ACLAction {
7
+ CREATE = "CREATE",
8
+ DELETE = "DELETE",
9
+ FULL = "FULL",
10
+ READ = "READ",
11
+ SPECIAL = "SPECIAL",
12
+ UPDATE = "UPDATE"
13
+ }
14
+ /**
15
+ * The `ACLRecord` interface describes a single permissions entry in an `AccessControlList` that grants or denies
16
+ * a set of permissions to a single user or role.
17
+ *
18
+ * Each permission can be one of the following actions:
19
+ * - `Create` - The user or role can create a new record or object.
20
+ * - `Read` - The user or role can read the record or object.
21
+ * - `Update` - The user or role can modify existing records or objects.
22
+ * - `Delete` - The user or role can delete existing records or objects.
23
+ * - `Special` - The user or role has special prilieges to edit the ACL permissions.
24
+ * - `Full` - The user or role has total control over the record or object and supersedes any of the above.
25
+ *
26
+ * @author Jean-Philippe Steinmetz <rapidrests@gmail.com>
27
+ */
28
+ export interface ACLRecord {
29
+ /**
30
+ * The unique identifier of the user or role that the record belongs to.
31
+ */
32
+ userOrRoleId: string;
33
+ /**
34
+ * Indicates that the user or role has permission to create new records of the entity.
35
+ */
36
+ create: boolean | null;
37
+ /**
38
+ * Indicates that the user or role has permission to read records of the entity.
39
+ */
40
+ read: boolean | null;
41
+ /**
42
+ * Indicates that the user or role has permission to modify existing records of the entity.
43
+ */
44
+ update: boolean | null;
45
+ /**
46
+ * Indicates that the user or role has permission to delete existing records of the entity.
47
+ */
48
+ delete: boolean | null;
49
+ /**
50
+ * Indicates that the user or role has special permission over records of the entity. The exact meaning of this
51
+ * may vary by service.
52
+ */
53
+ special: boolean | null;
54
+ /**
55
+ * Indicates that the user or role has total control over records of the entity. This supersedes all of the above
56
+ * permissions.
57
+ */
58
+ full: boolean | null;
59
+ }
60
+ /**
61
+ * The access control list provides a generic interface for the storage of user and roles permissions. Each ACL object
62
+ * represents the permission set for a single entity within the system. The entity is identified generically by its
63
+ * universally unique identifier (`uuid`). Each entry in the ACL records the permissions available to a particular user
64
+ * or role.
65
+ *
66
+ * Each permission can be one of the following actions:
67
+ * - `Create` - The user or role can create a new record or object.
68
+ * - `Read` - The user or role can read the record or object.
69
+ * - `Update` - The user or role can modify existing records or objects.
70
+ * - `Delete` - The user or role can delete existing records or objects.
71
+ * - `Special` - The user or role has special prilieges to edit the ACL permissions.
72
+ * - `Full` - The user or role has total control over the record or object and supersedes any of the above.
73
+ *
74
+ * For each of the above actions the user or role will be granted either an `allow` permission or a `deny` permission.
75
+ * If an `allow` is granted, the user or role has permission to perform that action. If a `deny` is set, then the user
76
+ * or role is denied that action. If no explicit `allow` or `deny` is set then the user or role will inherit the
77
+ * permission from a parent role or ACL.
78
+ *
79
+ * ACLs can be chained via single inheritance through the specification of the `parentUid`. This allows the ability to
80
+ * create complex trees of permissions that can easily inherit control schemes to make the definition of permissions
81
+ * easier.
82
+ *
83
+ * @author Jean-Philippe Steinmetz <rapidrests@gmail.com>
84
+ */
85
+ export interface AccessControlList {
86
+ /**
87
+ * The universally unique identifier (`uuid`) of the entity that the access control list belongs to.
88
+ */
89
+ uid: string;
90
+ /**
91
+ * The parent access control list that this instance inherits permissions from.
92
+ */
93
+ parent?: AccessControlList | null;
94
+ /**
95
+ * The universally unique identifier of the parent `AccessControlList` that this object will inherit permissions
96
+ * from.
97
+ */
98
+ parentUid?: string;
99
+ /**
100
+ * The list of all permission records associated with this access control list.
101
+ */
102
+ records: ACLRecord[];
103
+ }
@@ -0,0 +1,24 @@
1
+ import { BaseMongoEntity } from "../models/index.js";
2
+ import { AccessControlList, ACLRecord } from "./AccessControlList.js";
3
+ /**
4
+ * Implementation of the `ACLRecord` interface for use with MongoDB databases.
5
+ */
6
+ export declare class ACLRecordMongo implements ACLRecord {
7
+ userOrRoleId: string;
8
+ create: boolean | null;
9
+ read: boolean | null;
10
+ update: boolean | null;
11
+ delete: boolean | null;
12
+ special: boolean | null;
13
+ full: boolean | null;
14
+ constructor(other?: any);
15
+ }
16
+ /**
17
+ * Implementation of the `AccessControlList` interface for use with MongoDB databases.
18
+ */
19
+ export declare class AccessControlListMongo extends BaseMongoEntity implements AccessControlList {
20
+ parent?: AccessControlList;
21
+ parentUid?: string | undefined;
22
+ records: ACLRecordMongo[];
23
+ constructor(other?: any);
24
+ }
@@ -0,0 +1,24 @@
1
+ import { BaseEntity } from "../models/BaseEntity.js";
2
+ import { AccessControlList, ACLRecord } from "./AccessControlList.js";
3
+ /**
4
+ * Implementation of the `ACLRecord` interface for use with SQL databases.
5
+ */
6
+ export declare class ACLRecordSQL implements ACLRecord {
7
+ userOrRoleId: string;
8
+ create: boolean | null;
9
+ read: boolean | null;
10
+ update: boolean | null;
11
+ delete: boolean | null;
12
+ special: boolean | null;
13
+ full: boolean | null;
14
+ constructor(other?: any);
15
+ }
16
+ /**
17
+ * Implementation of the `AccessControlList` interface for use with SQL databases.
18
+ */
19
+ export declare class AccessControlListSQL extends BaseEntity implements AccessControlList {
20
+ parent?: AccessControlList;
21
+ parentUid?: string | undefined;
22
+ records: ACLRecordSQL[];
23
+ constructor(other?: any);
24
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./AccessControlList.js";
2
+ export * from "./ACLUtils.js";
@@ -0,0 +1,2 @@
1
+ export * from "./request.js";
2
+ export * from "./requestws.js";
@@ -0,0 +1,24 @@
1
+ /** Minimal supertest-compatible response shape. */
2
+ export interface TestResponse {
3
+ status: number;
4
+ statusCode: number;
5
+ body: any;
6
+ text: string;
7
+ /** MIME type extracted from the content-type header (without charset). */
8
+ type: string;
9
+ headers: Record<string, string>;
10
+ ok: boolean;
11
+ }
12
+ /**
13
+ * Creates a supertest-style request builder that sends requests via axios to
14
+ * `http://localhost:<port>`.
15
+ */
16
+ export declare function request(app: any): {
17
+ get: (url: string) => any;
18
+ post: (url: string) => any;
19
+ put: (url: string) => any;
20
+ delete: (url: string) => any;
21
+ patch: (url: string) => any;
22
+ head: (url: string) => any;
23
+ options: (url: string) => any;
24
+ };
@@ -0,0 +1,21 @@
1
+ /** Fluent WebSocket test chain, mirrors the superwstest API. */
2
+ export declare class WsChain {
3
+ private readonly url;
4
+ private readonly wsOptions?;
5
+ private readonly actions;
6
+ constructor(url: string, wsOptions?: any);
7
+ expectText(value: string): this;
8
+ expectJson(value: any): this;
9
+ expectClosed(code?: number, reason?: string): this;
10
+ sendText(value: string): this;
11
+ sendJson(value: any): this;
12
+ close(): this;
13
+ /** Execute the queued actions and resolve when all pass. */
14
+ then<TResult1 = void, TResult2 = never>(onFulfilled?: ((value: void) => TResult1 | PromiseLike<TResult1>) | null, onRejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
15
+ catch<TResult = never>(onRejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null): Promise<void | TResult>;
16
+ private _run;
17
+ }
18
+ /** Creates a superwstest-style chain connected to `ws://localhost:<port>`. */
19
+ export declare function requestws(appOrPort: any): {
20
+ ws(path: string, options?: any): WsChain;
21
+ };