@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,457 @@
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 { ObjectDecorators, UserUtils, sleep } from "@rapidrest/core";
14
+ import { AccessControlListSQL } from "./AccessControlListSQL.js";
15
+ import { AccessControlListMongo } from "./AccessControlListMongo.js";
16
+ import { ACLAction } from "./AccessControlList.js";
17
+ import { ConnectionManager } from "../database/ConnectionManager.js";
18
+ import { isSqlDataSource } from "../database/ConnectionKinds.js";
19
+ import { MongoConnection } from "../database/MongoConnection.js";
20
+ import { MongoRepository } from "../database/MongoRepository.js";
21
+ const { Config, Inject } = ObjectDecorators;
22
+ const CACHE_BASE_KEY = "db.cache.AccessControlList";
23
+ /**
24
+ * Common utility functions for working with `AccessControlList` objects and validating user permissions.
25
+ */
26
+ export class ACLUtils {
27
+ constructor() {
28
+ this.cacheTTL = 30;
29
+ this.trustedRoles = ["admin"];
30
+ }
31
+ get cacheClient() {
32
+ return this.connMgr?.connections.get("cache");
33
+ }
34
+ get repo() {
35
+ const conn = this.connMgr?.connections.get("acl");
36
+ if (conn instanceof MongoConnection) {
37
+ return conn.getRepository(AccessControlListMongo);
38
+ }
39
+ else if (isSqlDataSource(conn)) {
40
+ return conn.getRepository(AccessControlListSQL.name);
41
+ }
42
+ return undefined;
43
+ }
44
+ /**
45
+ * Checks to see if the provided user matches the providedUserOrRoleId.
46
+ * @param user The user to check.
47
+ * @param userOrRoleId The ACL record id to check against.
48
+ * @returns `true` if the user contains a `uid` or `role` that matches the `userOrRoleId`, otherwise `false`.
49
+ */
50
+ userMatchesId(user, userOrRoleId) {
51
+ if (!user?.uid) {
52
+ return userOrRoleId === "anonymous";
53
+ }
54
+ // Explicit wildcards — match any authenticated user; no regex engine involved
55
+ if (userOrRoleId === ".*" || userOrRoleId === "*")
56
+ return true;
57
+ if (user.uid === userOrRoleId)
58
+ return true;
59
+ if (user.roles) {
60
+ for (const role of user.roles) {
61
+ if (role === userOrRoleId)
62
+ return true;
63
+ }
64
+ }
65
+ return false;
66
+ }
67
+ /**
68
+ * Validates that the user has permission to perform the request operation against the URL path for the
69
+ * provided request. If ACLUtils has not been initialized or the `acl` datastore has not been configured
70
+ * then always returns `true`.
71
+ *
72
+ * @param uid The uid of the access control list to verify against.
73
+ * @param user The user to validate.
74
+ * @param req The request whose URL path and method will be verified.
75
+ */
76
+ async checkRequestPerms(uid, user, req) {
77
+ let result = true;
78
+ // If no repo is set then ACL support is not configured so just return
79
+ if (!this.repo) {
80
+ return result;
81
+ }
82
+ let acl = await this.findACL(uid);
83
+ if (acl) {
84
+ // Make sure all parents are populated
85
+ if (!acl.parent) {
86
+ await this.populateParent(acl);
87
+ }
88
+ // First check if the user is trusted. Trusted users always have permission. We pass in the ACL uid as
89
+ // it may be an organization id in which case we want to also check for organizational trusted users.
90
+ if (UserUtils.hasRoles(user, this.trustedRoles, acl.uid)) {
91
+ result = true;
92
+ }
93
+ else {
94
+ // Check for the FULL permission. If granted it will supersede any others. Otherwise, we'll
95
+ // check individually based on the request method.
96
+ result = await this.hasPermission(user, acl, ACLAction.FULL);
97
+ if (!result) {
98
+ // Map the request method to an ACLAction and test for permission
99
+ switch (req.method.toLowerCase()) {
100
+ case "delete":
101
+ result = await this.hasPermission(user, acl, ACLAction.DELETE);
102
+ break;
103
+ case "get":
104
+ result = await this.hasPermission(user, acl, ACLAction.READ);
105
+ break;
106
+ case "post":
107
+ result = await this.hasPermission(user, acl, ACLAction.CREATE);
108
+ break;
109
+ case "put":
110
+ result = await this.hasPermission(user, acl, ACLAction.UPDATE);
111
+ break;
112
+ }
113
+ }
114
+ }
115
+ }
116
+ return result;
117
+ }
118
+ /**
119
+ * Validates that the user has permission to perform the provided action using the given access control list.
120
+ *
121
+ * @param user The user to validate permissions of.
122
+ * @param acl The ACL or uid of an ACL to validate permissions against.
123
+ * @param action The action that the user desires permission for.
124
+ * @returns `true` if the user has at least one of the permissions granted for the given entity, otherwise `false`.
125
+ */
126
+ async hasPermission(user, acl, action) {
127
+ let result = null;
128
+ // If the repo isn't available, no acl was provided or the ACL string is empty just return, assume always true
129
+ if (!this.repo || !acl || acl === "") {
130
+ return true;
131
+ }
132
+ // First check if the user is trusted. Trusted users always have permission. We pass in the ACL uid as
133
+ // it may be an organization id in which case we want to also check for organizational trusted users.
134
+ if (UserUtils.hasRoles(user, this.trustedRoles, typeof acl === "string" ? acl : acl.uid)) {
135
+ return true;
136
+ }
137
+ // If a uid has been given look up the ACL associated with it and then process
138
+ if (typeof acl === "string") {
139
+ const entry = await this.findACL(acl);
140
+ return entry ? await this.hasPermission(user, entry, action) : false;
141
+ }
142
+ // Look for the first available record for the given user
143
+ const record = this.getRecord(acl, user);
144
+ // Validate the requested action against the record.
145
+ if (record) {
146
+ // A `FULL` permission grant overrides everything else
147
+ result = record.full;
148
+ if (!result) {
149
+ switch (action) {
150
+ case ACLAction.CREATE:
151
+ result = record.create;
152
+ break;
153
+ case ACLAction.DELETE:
154
+ result = record.delete;
155
+ break;
156
+ case ACLAction.FULL:
157
+ result =
158
+ record.full ||
159
+ (record.create && record.delete && record.read && record.special && record.update);
160
+ break;
161
+ case ACLAction.READ:
162
+ result = record.read;
163
+ break;
164
+ case ACLAction.SPECIAL:
165
+ result = record.special;
166
+ break;
167
+ case ACLAction.UPDATE:
168
+ result = record.update;
169
+ break;
170
+ }
171
+ }
172
+ }
173
+ // No matching record found — deny by default
174
+ return result !== null && result !== undefined ? result : false;
175
+ }
176
+ /**
177
+ * Retrieves the access control list with the associated identifier and populates the parent(s).
178
+ *
179
+ * @param entityId The unique identifier of the ACL to retrieve.
180
+ * @param parentUids The list of already found parent UIDs. This is used to break circular dependencies.
181
+ */
182
+ async findACL(entityId, parentUids = []) {
183
+ if (!this.repo) {
184
+ return null;
185
+ }
186
+ let acl = null;
187
+ // Retrieve the ACL from the cache if present
188
+ if (this.cacheClient) {
189
+ const json = await this.cacheClient.get(`${CACHE_BASE_KEY}.${entityId}`);
190
+ if (json) {
191
+ try {
192
+ acl = JSON.parse(json);
193
+ }
194
+ catch (err) {
195
+ // We don't care if this fails
196
+ }
197
+ }
198
+ }
199
+ // If the acl wasn't found in the cache look in the database
200
+ if (!acl) {
201
+ if (this.repo instanceof MongoRepository) {
202
+ acl = await this.repo
203
+ .aggregate([{ $match: { uid: entityId } }])
204
+ .limit(1)
205
+ .next();
206
+ acl = acl ? new AccessControlListMongo(acl) : null;
207
+ }
208
+ else {
209
+ acl = await this.repo.findOne({ uid: entityId });
210
+ acl = acl ? new AccessControlListSQL(acl) : null;
211
+ }
212
+ // Store a copy in the cache for faster retrieval next time
213
+ if (acl && this.cacheClient) {
214
+ await this.cacheClient.setex(`${CACHE_BASE_KEY}.${entityId}`, this.cacheTTL, JSON.stringify(acl));
215
+ }
216
+ }
217
+ // Retrieve the parent ACL and assign it if available. Don't populate parents we've
218
+ // already found to prevent a circular dependency.
219
+ if (acl && acl.parentUid && !parentUids.includes(acl.parentUid)) {
220
+ parentUids.push(acl.parentUid);
221
+ acl.parent = await this.findACL(acl.parentUid, parentUids);
222
+ }
223
+ return acl;
224
+ }
225
+ /**
226
+ * Deletes the ACL with the given identifier from the database.
227
+ * @param uid The unique identifier of the ACL to remove.
228
+ */
229
+ async removeACL(uid) {
230
+ try {
231
+ if (this.repo instanceof MongoRepository) {
232
+ await this.repo.deleteOne({ uid });
233
+ }
234
+ else if (this.repo) {
235
+ await this.repo.delete({ uid });
236
+ }
237
+ }
238
+ catch (err) {
239
+ // It's okay if this fails because no document exists
240
+ }
241
+ }
242
+ /**
243
+ * Compares two ACLs to see if they have been modified and returns the total number of changes between them.
244
+ *
245
+ * @param aclA The source ACL to compare against.
246
+ * @param aclB The new ACL to compare with.
247
+ * @returns The total number of changes between the two ACLs.
248
+ */
249
+ diffACL(aclA, aclB) {
250
+ let result = 0;
251
+ // Did the parent change?
252
+ if (aclA.parentUid !== aclB.parentUid) {
253
+ result++;
254
+ }
255
+ // Did any of the records change from A to B?
256
+ for (const recordA of aclA.records) {
257
+ let foundRecord = undefined;
258
+ // Look for the same record in aclA
259
+ for (const recordB of aclB.records) {
260
+ if (recordA.userOrRoleId === recordB.userOrRoleId) {
261
+ foundRecord = recordB;
262
+ break;
263
+ }
264
+ }
265
+ if (foundRecord) {
266
+ // Check to see if any of the permissions changed for this record
267
+ result += foundRecord.create !== recordA.create ? 1 : 0;
268
+ result += foundRecord.delete !== recordA.delete ? 1 : 0;
269
+ result += foundRecord.full !== recordA.full ? 1 : 0;
270
+ result += foundRecord.read !== recordA.read ? 1 : 0;
271
+ result += foundRecord.special !== recordA.special ? 1 : 0;
272
+ result += foundRecord.update !== recordA.update ? 1 : 0;
273
+ }
274
+ else {
275
+ result++;
276
+ }
277
+ }
278
+ // Did any of the records change from B to A?
279
+ for (const recordB of aclB.records) {
280
+ let foundRecord = undefined;
281
+ // Look for the same record in aclA
282
+ for (const recordA of aclA.records) {
283
+ if (recordA.userOrRoleId === recordB.userOrRoleId) {
284
+ foundRecord = recordA;
285
+ break;
286
+ }
287
+ }
288
+ if (foundRecord) {
289
+ // Check to see if any of the permissions changed for this record
290
+ result += foundRecord.create !== recordB.create ? 1 : 0;
291
+ result += foundRecord.delete !== recordB.delete ? 1 : 0;
292
+ result += foundRecord.full !== recordB.full ? 1 : 0;
293
+ result += foundRecord.read !== recordB.read ? 1 : 0;
294
+ result += foundRecord.special !== recordB.special ? 1 : 0;
295
+ result += foundRecord.update !== recordB.update ? 1 : 0;
296
+ }
297
+ else {
298
+ result++;
299
+ }
300
+ }
301
+ return result;
302
+ }
303
+ /**
304
+ * Stores the given access control list into the ACL database.
305
+ *
306
+ * @param acl The ACL to store.
307
+ * @return Returns the ACL that was stored in the database.
308
+ */
309
+ async saveACL(acl) {
310
+ let result = null;
311
+ if (!acl) {
312
+ return result;
313
+ }
314
+ if (this.repo instanceof MongoRepository) {
315
+ const mACL = new AccessControlListMongo(acl);
316
+ const existing = await this.repo.findOne({ uid: acl.uid });
317
+ // If no changes have been made between versions ignore this request
318
+ if (existing && this.diffACL(existing, acl) === 0) {
319
+ return existing;
320
+ }
321
+ // Make sure that the versions match before we proceed
322
+ if (existing && existing.version !== mACL.version) {
323
+ throw new Error(`The acl to save must be of the same version. ACL=${acl.uid}, Expected=${existing.version}, Actual=${mACL.version}`);
324
+ }
325
+ const aclMongo = new AccessControlListMongo({
326
+ ...acl,
327
+ dateModifed: new Date(),
328
+ version: existing ? mACL.version + 1 : 0,
329
+ });
330
+ result = await this.repo.save(aclMongo);
331
+ }
332
+ else if (this.repo) {
333
+ const sACL = new AccessControlListSQL(acl);
334
+ const existing = await this.repo.findOne({ uid: acl.uid });
335
+ // If no changes have been made between versions ignore this request
336
+ if (existing && this.diffACL(existing, acl) === 0) {
337
+ return existing;
338
+ }
339
+ // Make sure that the versions match before we proceed
340
+ if (existing && existing.version !== sACL.version) {
341
+ throw new Error(`The acl to save must be of the same version. ACL=${acl.uid}, Expected=${existing.version}, Actual=${sACL.version}`);
342
+ }
343
+ const aclSQL = new AccessControlListSQL({
344
+ ...acl,
345
+ dateModifed: new Date(),
346
+ version: existing ? sACL.version + 1 : 0,
347
+ });
348
+ result = await this.repo.save(aclSQL);
349
+ }
350
+ // Store a copy in the cache for faster retrieval next time
351
+ if (this.cacheClient && result) {
352
+ await this.cacheClient.setex(`${CACHE_BASE_KEY}.${result.uid}`, this.cacheTTL, JSON.stringify(result));
353
+ }
354
+ return result;
355
+ }
356
+ /**
357
+ * Stores the given default access control list into the ACL database. A default ACL is a special type of ACL
358
+ * that is primarily defined and maintained within the code but allows for user-specific overrides. To accomplish
359
+ * this, the provided ACL is split in two. A new record is automatically created with the `uid` of the form
360
+ * `default_<uid>` that stores the exact record as provided by code. Then a second ACL record is created
361
+ * with the `uid` being that of what is passed as the argument. This second ACL is used to store user-defined
362
+ * overrides. As the `default_<uid>` record is always overwritten with the lastest version of the code, any
363
+ * user-defined changes made to it are lost on service restart.
364
+ *
365
+ * @param defaultAcl
366
+ * @returns
367
+ */
368
+ async saveDefaultACL(acl) {
369
+ let result = null;
370
+ if (!acl) {
371
+ return result;
372
+ }
373
+ // Make a copy of `acl` with a new name for our default_ record
374
+ let defaultAcl = {
375
+ ...acl,
376
+ uid: `default_${acl.uid}`,
377
+ };
378
+ // Attempt to update the default ACL record. If a version mismatch occurs we will try again.
379
+ const maxAttempts = 3;
380
+ let attempts = 0;
381
+ while (attempts++ < maxAttempts) {
382
+ try {
383
+ // Two documents are stored for each default ACL. A record named `default_<NAME>`
384
+ // and another named `<NAME>`. The `<NAME>` record stores the user-defined
385
+ // overrides that overlay the `default_<NAME>` document. The `default_<NAME>` is
386
+ // therefore always updated with whatever is provided as the `defaultAcl` argument.
387
+ const existing = await this.findACL(defaultAcl.uid);
388
+ if (existing) {
389
+ // Copy over the new records from code
390
+ existing.records = defaultAcl.records;
391
+ defaultAcl = existing;
392
+ }
393
+ else {
394
+ // Create the user-defined override record
395
+ result = await this.saveACL({
396
+ uid: acl.uid,
397
+ parentUid: defaultAcl.uid,
398
+ records: [],
399
+ });
400
+ }
401
+ // Always save the ACL into the datastore
402
+ await this.saveACL(defaultAcl);
403
+ attempts = maxAttempts;
404
+ }
405
+ catch (err) {
406
+ if (attempts < maxAttempts) {
407
+ // Wait a brief moment before we try again. Stagger the time to avoid race conditions.
408
+ await sleep(Math.floor(Math.random() * 1000));
409
+ }
410
+ else {
411
+ // Rethrow if we're out of retries
412
+ throw err;
413
+ }
414
+ }
415
+ }
416
+ return result;
417
+ }
418
+ /**
419
+ * Retrieves the first available record in the provided ACL associated with the provided user.
420
+ *
421
+ * @param acl The access control list that will be searched.
422
+ * @param user The user to find a record for.
423
+ * @returns The ACL record associated with the given user if found, otherwise `undefined`.
424
+ */
425
+ getRecord(acl, user) {
426
+ if (!acl) {
427
+ return null;
428
+ }
429
+ for (const record of acl.records) {
430
+ if (this.userMatchesId(user, record.userOrRoleId)) {
431
+ return record;
432
+ }
433
+ }
434
+ return acl.parent ? this.getRecord(acl.parent, user) : null;
435
+ }
436
+ /**
437
+ * Attempts to retrieve the parent access control list for the given ACL object.
438
+ *
439
+ * @param acl The access control list whose parents will be populated.
440
+ * @param parentUids The list of already found parent UIDs. This is used to break circular dependencies.
441
+ */
442
+ async populateParent(acl, parentUids = []) {
443
+ if (acl && acl.parentUid) {
444
+ parentUids.push(acl.parentUid);
445
+ acl.parent = await this.findACL(acl.parentUid, parentUids);
446
+ }
447
+ }
448
+ }
449
+ __decorate([
450
+ Inject(ConnectionManager),
451
+ __metadata("design:type", ConnectionManager)
452
+ ], ACLUtils.prototype, "connMgr", void 0);
453
+ __decorate([
454
+ Config("trusted_roles", ["admin"]),
455
+ __metadata("design:type", Array)
456
+ ], ACLUtils.prototype, "trustedRoles", void 0);
457
+ //# sourceMappingURL=ACLUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ACLUtils.js","sourceRoot":"","sources":["../../../src/security/ACLUtils.ts"],"names":[],"mappings":";;;;;;;;;AAAA,+EAA+E;AAC/E,wEAAwE;AACxE,+EAA+E;AAC/E,OAAO,EAAW,gBAAgB,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAC9E,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAGrE,OAAO,EAAqB,SAAS,EAAa,MAAM,wBAAwB,CAAC;AAEjF,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,gBAAgB,CAAC;AAE5C,MAAM,cAAc,GAAW,4BAA4B,CAAC;AAE5D;;GAEG;AACH,MAAM,OAAO,QAAQ;IAArB;QACY,aAAQ,GAAW,EAAE,CAAC;QAItB,iBAAY,GAAa,CAAC,OAAO,CAAC,CAAC;IA0c/C,CAAC;IAxcG,IAAY,WAAW;QACnB,OAAO,IAAI,CAAC,OAAO,EAAE,WAAW,CAAC,GAAG,CAAC,OAAO,CAAsB,CAAC;IACvE,CAAC;IAED,IAAY,IAAI;QACZ,MAAM,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BAAiB;yCAAC;AAE5B;IADP,MAAM,CAAC,eAAe,EAAE,CAAC,OAAO,CAAC,CAAC;;8CACQ"}
@@ -0,0 +1,18 @@
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2020-2026 Jean-Philippe Steinmetz. All rights reserved.
3
+ ///////////////////////////////////////////////////////////////////////////////
4
+ /**
5
+ * Describes the various permission actions that can be performed against an entity.
6
+ *
7
+ * @author Jean-Philippe Steinmetz <rapidrests@gmail.com>
8
+ */
9
+ export var ACLAction;
10
+ (function (ACLAction) {
11
+ ACLAction["CREATE"] = "CREATE";
12
+ ACLAction["DELETE"] = "DELETE";
13
+ ACLAction["FULL"] = "FULL";
14
+ ACLAction["READ"] = "READ";
15
+ ACLAction["SPECIAL"] = "SPECIAL";
16
+ ACLAction["UPDATE"] = "UPDATE";
17
+ })(ACLAction || (ACLAction = {}));
18
+ //# sourceMappingURL=AccessControlList.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AccessControlList.js","sourceRoot":"","sources":["../../../src/security/AccessControlList.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,wEAAwE;AACxE,+EAA+E;AAE/E;;;;GAIG;AACH,MAAM,CAAN,IAAY,SAOX;AAPD,WAAY,SAAS;IACjB,8BAAiB,CAAA;IACjB,8BAAiB,CAAA;IACjB,0BAAa,CAAA;IACb,0BAAa,CAAA;IACb,gCAAmB,CAAA;IACnB,8BAAiB,CAAA;AACrB,CAAC,EAPW,SAAS,KAAT,SAAS,QAOpB"}
@@ -0,0 +1,155 @@
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 { BaseMongoEntity } from "../models/index.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 MongoDB databases.
20
+ */
21
+ let ACLRecordMongo = class ACLRecordMongo {
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
+ ], ACLRecordMongo.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
+ ], ACLRecordMongo.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
+ ], ACLRecordMongo.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
+ ], ACLRecordMongo.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
+ ], ACLRecordMongo.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
+ ], ACLRecordMongo.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
+ ], ACLRecordMongo.prototype, "full", void 0);
79
+ ACLRecordMongo = __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
+ ], ACLRecordMongo);
93
+ export { ACLRecordMongo };
94
+ /**
95
+ * Implementation of the `AccessControlList` interface for use with MongoDB databases.
96
+ */
97
+ let AccessControlListMongo = class AccessControlListMongo extends BaseMongoEntity {
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
+ if (other.records) {
105
+ this.records = [];
106
+ for (const record of other.records) {
107
+ const newRecord = new ACLRecordMongo(record);
108
+ this.records.push(newRecord);
109
+ }
110
+ }
111
+ }
112
+ }
113
+ };
114
+ __decorate([
115
+ Description("The universally unique identifier of the parent `AccessControlList` that this object will inherit permissions from."),
116
+ Column(),
117
+ Index("parentUid"),
118
+ TypeInfo([String]),
119
+ __metadata("design:type", Object)
120
+ ], AccessControlListMongo.prototype, "parentUid", void 0);
121
+ __decorate([
122
+ Description("The list of all permission records associated with this access control list."),
123
+ Column(),
124
+ TypeInfo([[Array, ACLRecordMongo]]),
125
+ __metadata("design:type", Array)
126
+ ], AccessControlListMongo.prototype, "records", void 0);
127
+ AccessControlListMongo = __decorate([
128
+ DataStore("acl"),
129
+ Entity(),
130
+ Cache(3600),
131
+ Description(`The access control list provides a generic interface for the storage of user and roles permissions. Each ACL object
132
+ represents the permission set for a single entity within the system. The entity is identified generically by its
133
+ universally unique identifier (\`uuid\`). Each entry in the ACL records the permissions available to a particular user
134
+ or role.
135
+
136
+ Each permission can be one of the following actions:
137
+ - \`Create\` - The user or role can create a new record or object.
138
+ - \`Read\` - The user or role can read the record or object.
139
+ - \`Update\` - The user or role can modify existing records or objects.
140
+ - \`Delete\` - The user or role can delete existing records or objects.
141
+ - \`Special\` - The user or role has special prilieges to edit the ACL permissions.
142
+ - \`Full\` - The user or role has total control over the record or object and supersedes any of the above.
143
+
144
+ For each of the above actions the user or role will be granted either an \`allow\` permission or a \`deny\` permission.
145
+ If an \`allow\` is granted, the user or role has permission to perform that action. If a \`deny\` is set, then the user
146
+ or role is denied that action. If no explicit \`allow\` or \`deny\` is set then the user or role will inherit the
147
+ permission from a parent role or ACL.
148
+
149
+ ACLs can be chained via single inheritance through the specification of the \`parentUid\`. This allows the ability to
150
+ create complex trees of permissions that can easily inherit control schemes to make the definition of permissions
151
+ easier.`),
152
+ __metadata("design:paramtypes", [Object])
153
+ ], AccessControlListMongo);
154
+ export { AccessControlListMongo };
155
+ //# sourceMappingURL=AccessControlListMongo.js.map