pigallery2-extension-kit 3.5.2 → 3.6.0-edge

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 (420) hide show
  1. package/README.md +11 -5
  2. package/index.d.ts +1 -0
  3. package/index.js +2 -3
  4. package/lib/backend/Logger.d.ts +7 -7
  5. package/lib/backend/Logger.js +104 -0
  6. package/lib/backend/ProjectPath.d.ts +12 -0
  7. package/lib/backend/ProjectPath.js +28 -2
  8. package/lib/backend/exceptions/DirectoryNotFound.d.ts +2 -0
  9. package/lib/backend/exceptions/DirectoryNotFound.js +7 -0
  10. package/lib/backend/exceptions/FileAlreadyExists.js +10 -0
  11. package/lib/backend/exceptions/FolderNotWritable.d.ts +2 -0
  12. package/lib/backend/exceptions/FolderNotWritable.js +7 -0
  13. package/lib/backend/exceptions/LocationLookupException.js +10 -0
  14. package/lib/backend/index.d.ts +1 -1
  15. package/lib/backend/middlewares/AlbumMWs.js +61 -0
  16. package/lib/backend/middlewares/GalleryMWs.d.ts +4 -0
  17. package/lib/backend/middlewares/GalleryMWs.js +380 -0
  18. package/lib/backend/middlewares/MetaFileMWs.js +41 -0
  19. package/lib/backend/middlewares/NotificationMWs.js +21 -0
  20. package/lib/backend/middlewares/PersonMWs.d.ts +1 -1
  21. package/lib/backend/middlewares/PersonMWs.js +64 -0
  22. package/lib/backend/middlewares/RenderingMWs.d.ts +24 -0
  23. package/lib/backend/middlewares/RenderingMWs.js +182 -0
  24. package/lib/backend/middlewares/RequestParams.d.ts +13 -0
  25. package/lib/backend/middlewares/RequestParams.js +25 -0
  26. package/lib/backend/middlewares/RequestSession.d.ts +9 -0
  27. package/lib/backend/middlewares/RequestSession.js +16 -0
  28. package/lib/backend/middlewares/ServerTimingMWs.d.ts +6 -6
  29. package/lib/backend/middlewares/ServerTimingMWs.js +108 -0
  30. package/lib/backend/middlewares/SharingMWs.d.ts +2 -1
  31. package/lib/backend/middlewares/SharingMWs.js +240 -0
  32. package/lib/backend/middlewares/UploadMWs.js +95 -0
  33. package/lib/backend/middlewares/VersionMWs.d.ts +1 -1
  34. package/lib/backend/middlewares/VersionMWs.js +41 -0
  35. package/lib/backend/middlewares/admin/AdminMWs.js +115 -0
  36. package/lib/backend/middlewares/admin/ExtensionMWs.js +85 -0
  37. package/lib/backend/middlewares/admin/SettingsMWs.js +54 -0
  38. package/lib/backend/middlewares/thumbnail/ThumbnailGeneratorMWs.d.ts +1 -1
  39. package/lib/backend/middlewares/thumbnail/ThumbnailGeneratorMWs.js +153 -0
  40. package/lib/backend/middlewares/user/AuthenticationMWs.d.ts +37 -0
  41. package/lib/backend/middlewares/user/AuthenticationMWs.js +346 -0
  42. package/lib/backend/middlewares/user/OIDCAuthService.d.ts +36 -5
  43. package/lib/backend/middlewares/user/OIDCAuthService.js +216 -0
  44. package/lib/backend/middlewares/user/OIDCMWs.d.ts +10 -0
  45. package/lib/backend/middlewares/user/OIDCMWs.js +30 -0
  46. package/lib/backend/middlewares/user/UserMWs.d.ts +1 -0
  47. package/lib/backend/middlewares/user/UserMWs.js +120 -0
  48. package/lib/backend/middlewares/user/UserRequestConstrainsMWs.d.ts +0 -1
  49. package/lib/backend/middlewares/user/UserRequestConstrainsMWs.js +29 -0
  50. package/lib/backend/model/DirectoryAccess.d.ts +78 -0
  51. package/lib/backend/model/DirectoryAccess.js +222 -0
  52. package/lib/backend/model/EventLoopHandler.d.ts +1 -1
  53. package/lib/backend/model/EventLoopHandler.js +24 -0
  54. package/lib/backend/model/FFmpeg.d.ts +47 -0
  55. package/lib/backend/model/FFmpeg.js +75 -0
  56. package/lib/backend/model/FFmpegFactory.d.ts +11 -2
  57. package/lib/backend/model/FFmpegFactory.js +28 -0
  58. package/lib/backend/model/Localizations.js +19 -0
  59. package/lib/backend/model/ObjectManagers.d.ts +1 -1
  60. package/lib/backend/model/ObjectManagers.js +253 -0
  61. package/lib/backend/model/PasswordHelper.d.ts +1 -1
  62. package/lib/backend/model/PasswordHelper.js +6 -2
  63. package/lib/backend/model/SessionContext.d.ts +16 -6
  64. package/lib/backend/model/SessionContext.js +11 -0
  65. package/lib/backend/model/UploadManager.d.ts +6 -3
  66. package/lib/backend/model/UploadManager.js +101 -0
  67. package/lib/backend/model/database/AlbumManager.js +122 -0
  68. package/lib/backend/model/database/CoverManager.d.ts +8 -2
  69. package/lib/backend/model/database/CoverManager.js +169 -0
  70. package/lib/backend/model/database/GalleryManager.d.ts +15 -9
  71. package/lib/backend/model/database/GalleryManager.js +363 -0
  72. package/lib/backend/model/database/IObjectManager.js +2 -0
  73. package/lib/backend/model/database/IndexingManager.d.ts +7 -7
  74. package/lib/backend/model/database/IndexingManager.js +452 -0
  75. package/lib/backend/model/database/LocationManager.d.ts +2 -3
  76. package/lib/backend/model/database/LocationManager.js +39 -0
  77. package/lib/backend/model/database/PersonManager.d.ts +5 -3
  78. package/lib/backend/model/database/PersonManager.js +248 -0
  79. package/lib/backend/model/database/ProjectedCacheManager.d.ts +9 -8
  80. package/lib/backend/model/database/ProjectedCacheManager.js +297 -0
  81. package/lib/backend/model/database/ProjectionAwareManager.d.ts +4 -4
  82. package/lib/backend/model/database/ProjectionAwareManager.js +56 -0
  83. package/lib/backend/model/database/SQLConnection.d.ts +4 -2
  84. package/lib/backend/model/database/SQLConnection.js +295 -0
  85. package/lib/backend/model/database/SearchManager.d.ts +23 -8
  86. package/lib/backend/model/database/SearchManager.js +1032 -0
  87. package/lib/backend/model/database/SessionManager.d.ts +41 -4
  88. package/lib/backend/model/database/SessionManager.js +228 -0
  89. package/lib/backend/model/database/SharingManager.d.ts +11 -6
  90. package/lib/backend/model/database/SharingManager.js +160 -0
  91. package/lib/backend/model/database/UserManager.d.ts +8 -1
  92. package/lib/backend/model/database/UserManager.js +148 -0
  93. package/lib/backend/model/database/VersionManager.js +60 -0
  94. package/lib/backend/model/database/enitites/DirectoryEntity.d.ts +1 -1
  95. package/lib/backend/model/database/enitites/DirectoryEntity.js +76 -0
  96. package/lib/backend/model/database/enitites/EntityUtils.d.ts +22 -1
  97. package/lib/backend/model/database/enitites/EntityUtils.js +66 -0
  98. package/lib/backend/model/database/enitites/FileEntity.js +31 -0
  99. package/lib/backend/model/database/enitites/MDFileEntity.js +21 -0
  100. package/lib/backend/model/database/enitites/MediaEntity.d.ts +5 -2
  101. package/lib/backend/model/database/enitites/MediaEntity.js +223 -0
  102. package/lib/backend/model/database/enitites/PhotoEntity.js +19 -0
  103. package/lib/backend/model/database/enitites/ProjectedDirectoryCacheEntity.d.ts +2 -2
  104. package/lib/backend/model/database/enitites/ProjectedDirectoryCacheEntity.js +61 -0
  105. package/lib/backend/model/database/enitites/SharingEntity.d.ts +11 -5
  106. package/lib/backend/model/database/enitites/SharingEntity.js +100 -0
  107. package/lib/backend/model/database/enitites/UserEntity.d.ts +8 -5
  108. package/lib/backend/model/database/enitites/UserEntity.js +97 -0
  109. package/lib/backend/model/database/enitites/VersionEntity.js +19 -0
  110. package/lib/backend/model/database/enitites/VideoEntity.d.ts +2 -2
  111. package/lib/backend/model/database/enitites/VideoEntity.js +38 -0
  112. package/lib/backend/model/database/enitites/album/AlbumBaseEntity.js +32 -0
  113. package/lib/backend/model/database/enitites/album/ProjectedAlbumCacheEntity.d.ts +2 -2
  114. package/lib/backend/model/database/enitites/album/ProjectedAlbumCacheEntity.js +52 -0
  115. package/lib/backend/model/database/enitites/album/SavedSearchEntity.js +29 -0
  116. package/lib/backend/model/database/enitites/person/PersonEntry.js +36 -0
  117. package/lib/backend/model/database/enitites/person/PersonJunctionTable.js +37 -0
  118. package/lib/backend/model/database/enitites/person/ProjectedPersonCacheEntity.d.ts +1 -1
  119. package/lib/backend/model/database/enitites/person/ProjectedPersonCacheEntity.js +49 -0
  120. package/lib/backend/model/diagnostics/ConfigDiagnostics.d.ts +31 -12
  121. package/lib/backend/model/diagnostics/ConfigDiagnostics.js +537 -0
  122. package/lib/backend/model/extension/ExpressRouterWrapper.d.ts +10 -4
  123. package/lib/backend/model/extension/ExpressRouterWrapper.js +113 -0
  124. package/lib/backend/model/extension/ExtensionApp.d.ts +2 -3
  125. package/lib/backend/model/extension/ExtensionApp.js +18 -0
  126. package/lib/backend/model/extension/ExtensionConfig.js +17 -0
  127. package/lib/backend/model/extension/ExtensionConfigTemplateLoader.js +4 -3
  128. package/lib/backend/model/extension/ExtensionConfigWrapper.js +6 -5
  129. package/lib/backend/model/extension/ExtensionDB.d.ts +2 -2
  130. package/lib/backend/model/extension/ExtensionDB.js +22 -0
  131. package/lib/backend/model/extension/ExtensionDecorator.js +33 -0
  132. package/lib/backend/model/extension/ExtensionEvent.d.ts +12 -1
  133. package/lib/backend/model/extension/ExtensionEvent.js +81 -0
  134. package/lib/backend/model/extension/ExtensionManager.d.ts +22 -4
  135. package/lib/backend/model/extension/ExtensionManager.js +424 -0
  136. package/lib/backend/model/extension/ExtensionMessengerHandler.js +28 -0
  137. package/lib/backend/model/extension/ExtensionObject.d.ts +6 -3
  138. package/lib/backend/model/extension/ExtensionObject.js +45 -0
  139. package/lib/backend/model/extension/ExtensionRepository.js +69 -0
  140. package/lib/backend/model/extension/IExtension.d.ts +35 -18
  141. package/lib/backend/model/extension/IExtension.js +2 -0
  142. package/lib/backend/model/extension/UIExtension.js +23 -0
  143. package/lib/backend/model/fileaccess/DiskManager.d.ts +3 -1
  144. package/lib/backend/model/fileaccess/DiskManager.js +313 -0
  145. package/lib/backend/model/fileaccess/MetadataCreationDate.js +27 -0
  146. package/lib/backend/model/fileaccess/MetadataLoader.d.ts +17 -0
  147. package/lib/backend/model/fileaccess/MetadataLoader.js +765 -0
  148. package/lib/backend/model/fileaccess/PhotoWorker.js +159 -0
  149. package/lib/backend/model/fileaccess/TaskExecuter.js +41 -0
  150. package/lib/backend/model/fileaccess/TaskQue.d.ts +4 -4
  151. package/lib/backend/model/fileaccess/TaskQue.js +50 -0
  152. package/lib/backend/model/fileaccess/VideoConverterWorker.d.ts +4 -1
  153. package/lib/backend/model/fileaccess/VideoConverterWorker.js +59 -0
  154. package/lib/backend/model/fileaccess/fileprocessing/GPXProcessing.js +136 -0
  155. package/lib/backend/model/fileaccess/fileprocessing/PhotoProcessing.d.ts +3 -2
  156. package/lib/backend/model/fileaccess/fileprocessing/PhotoProcessing.js +251 -0
  157. package/lib/backend/model/fileaccess/fileprocessing/VideoProcessing.js +97 -0
  158. package/lib/backend/model/jobs/JobManager.d.ts +2 -4
  159. package/lib/backend/model/jobs/JobManager.js +129 -0
  160. package/lib/backend/model/jobs/JobProgressManager.d.ts +5 -3
  161. package/lib/backend/model/jobs/JobProgressManager.js +94 -0
  162. package/lib/backend/model/jobs/JobRepository.d.ts +1 -3
  163. package/lib/backend/model/jobs/JobRepository.js +50 -0
  164. package/lib/backend/model/jobs/jobs/AlbumCoverFillingJob.d.ts +1 -1
  165. package/lib/backend/model/jobs/jobs/AlbumCoverFillingJob.js +91 -0
  166. package/lib/backend/model/jobs/jobs/AlbumCoverResetJob.js +32 -0
  167. package/lib/backend/model/jobs/jobs/AlbumResetJob.js +30 -0
  168. package/lib/backend/model/jobs/jobs/FileJob.js +243 -0
  169. package/lib/backend/model/jobs/jobs/GPXCompressionJob.js +35 -0
  170. package/lib/backend/model/jobs/jobs/GPXCompressionResetJob.js +23 -0
  171. package/lib/backend/model/jobs/jobs/GalleryResetJob.js +30 -0
  172. package/lib/backend/model/jobs/jobs/IJob.js +2 -0
  173. package/lib/backend/model/jobs/jobs/IJobListener.d.ts +2 -2
  174. package/lib/backend/model/jobs/jobs/IJobListener.js +2 -0
  175. package/lib/backend/model/jobs/jobs/IndexingJob.js +99 -0
  176. package/lib/backend/model/jobs/jobs/Job.d.ts +4 -1
  177. package/lib/backend/model/jobs/jobs/Job.js +135 -0
  178. package/lib/backend/model/jobs/jobs/JobProgress.js +100 -0
  179. package/lib/backend/model/jobs/jobs/PhotoConvertingJob.js +78 -0
  180. package/lib/backend/model/jobs/jobs/TempFolderCleaningJob.js +122 -0
  181. package/lib/backend/model/jobs/jobs/TopPickSendJob.js +113 -0
  182. package/lib/backend/model/jobs/jobs/VideoConvertingJob.js +31 -0
  183. package/lib/backend/model/messenger/EmailMessenger.d.ts +1 -1
  184. package/lib/backend/model/messenger/EmailMessenger.js +87 -0
  185. package/lib/backend/model/messenger/ExtensionMessenger.js +16 -0
  186. package/lib/backend/model/messenger/Messenger.d.ts +1 -2
  187. package/lib/backend/model/messenger/Messenger.js +36 -0
  188. package/lib/backend/model/messenger/MessengerRepository.d.ts +1 -3
  189. package/lib/backend/model/messenger/MessengerRepository.js +38 -0
  190. package/lib/backend/model/messenger/StdoutMessenger.js +16 -0
  191. package/lib/backend/routes/AlbumRouter.js +39 -0
  192. package/lib/backend/routes/ErrorRouter.d.ts +1 -0
  193. package/lib/backend/routes/ErrorRouter.js +39 -0
  194. package/lib/backend/routes/GalleryRouter.d.ts +8 -0
  195. package/lib/backend/routes/GalleryRouter.js +165 -0
  196. package/lib/backend/routes/LoggerRouter.js +43 -0
  197. package/lib/backend/routes/NotificationRouter.js +19 -0
  198. package/lib/backend/routes/OIDCRouter.js +20 -0
  199. package/lib/backend/routes/PersonRouter.js +41 -0
  200. package/lib/backend/routes/PublicRouter.d.ts +3 -6
  201. package/lib/backend/routes/PublicRouter.js +301 -0
  202. package/lib/backend/routes/Router.js +36 -0
  203. package/lib/backend/routes/SharingRouter.d.ts +1 -1
  204. package/lib/backend/routes/SharingRouter.js +55 -0
  205. package/lib/backend/routes/UploadRouter.js +18 -0
  206. package/lib/backend/routes/UserRouter.d.ts +1 -0
  207. package/lib/backend/routes/UserRouter.js +53 -0
  208. package/lib/backend/routes/admin/AdminRouter.js +32 -0
  209. package/lib/backend/routes/admin/ExtensionRouter.js +30 -0
  210. package/lib/backend/routes/admin/SettingsRouter.js +18 -0
  211. package/lib/backend/server.d.ts +3 -3
  212. package/lib/backend/server.js +176 -0
  213. package/lib/common/CookieNames.js +10 -0
  214. package/lib/common/CustomHeaders.js +8 -0
  215. package/lib/common/DataStructureVersion.d.ts +1 -1
  216. package/lib/common/DataStructureVersion.js +7 -0
  217. package/lib/common/PG2ConfMap.js +36 -0
  218. package/lib/common/QueryParams.js +45 -0
  219. package/lib/common/SearchQueryParser.d.ts +2 -2
  220. package/lib/common/SearchQueryParser.js +611 -0
  221. package/lib/common/SearchQueryUtils.d.ts +71 -4
  222. package/lib/common/SearchQueryUtils.js +443 -0
  223. package/lib/common/SupportedFormats.d.ts +11 -1
  224. package/lib/common/SupportedFormats.js +13 -19
  225. package/lib/common/TextFold.d.ts +6 -0
  226. package/lib/common/TextFold.js +19 -0
  227. package/lib/common/UploadUtils.d.ts +4 -0
  228. package/lib/common/UploadUtils.js +20 -0
  229. package/lib/common/Utils.d.ts +23 -24
  230. package/lib/common/Utils.js +37 -97
  231. package/lib/common/config/private/Config.d.ts +1 -1
  232. package/lib/common/config/private/Config.js +2 -0
  233. package/lib/common/config/private/PrivateConfig.d.ts +17 -4
  234. package/lib/common/config/private/PrivateConfig.js +262 -33
  235. package/lib/common/config/private/PrivateConfigClass.js +10 -13
  236. package/lib/common/config/private/WebConfig.d.ts +1 -2
  237. package/lib/common/config/private/WebConfig.js +0 -2
  238. package/lib/common/config/private/subconfigs/MessagingConfig.js +8 -0
  239. package/lib/common/config/private/subconfigs/ServerExtensionsConfig.d.ts +2 -3
  240. package/lib/common/config/private/subconfigs/ServerExtensionsConfig.js +7 -3
  241. package/lib/common/config/public/ClientConfig.d.ts +55 -17
  242. package/lib/common/config/public/ClientConfig.js +291 -20
  243. package/lib/common/config/public/Config.js +5 -4
  244. package/lib/common/entities/AutoCompleteItem.d.ts +3 -3
  245. package/lib/common/entities/ContentWrapper.d.ts +21 -8
  246. package/lib/common/entities/ContentWrapper.js +286 -318
  247. package/lib/common/entities/DirectoryDTO.d.ts +7 -6
  248. package/lib/common/entities/DirectoryDTO.js +10 -5
  249. package/lib/common/entities/Error.d.ts +12 -7
  250. package/lib/common/entities/Error.js +15 -3
  251. package/lib/common/entities/MediaDTO.d.ts +13 -0
  252. package/lib/common/entities/MediaDTO.js +10 -7
  253. package/lib/common/entities/Message.d.ts +3 -3
  254. package/lib/common/entities/NotificationDTO.d.ts +2 -2
  255. package/lib/common/entities/SearchQueryDTO.d.ts +9 -1
  256. package/lib/common/entities/SearchQueryDTO.js +1 -0
  257. package/lib/common/entities/SharingDTO.d.ts +39 -5
  258. package/lib/common/entities/SortingMethods.d.ts +26 -2
  259. package/lib/common/entities/SortingMethods.js +14 -1
  260. package/lib/common/entities/UserDTO.d.ts +5 -2
  261. package/lib/common/entities/UserSettingsDTO.d.ts +3 -1
  262. package/lib/common/entities/VideoDTO.d.ts +2 -5
  263. package/lib/common/entities/album/AlbumBaseDTO.d.ts +2 -2
  264. package/lib/common/entities/extension/ExtensionListItem.d.ts +1 -1
  265. package/lib/common/entities/extension/IClientUIConfig.d.ts +19 -12
  266. package/lib/common/entities/job/JobDTO.d.ts +1 -1
  267. package/lib/common/entities/job/JobProgressDTO.d.ts +1 -1
  268. package/lib/common/entities/job/JobScheduleDTO.d.ts +5 -5
  269. package/lib/common/entities/job/JobScheduleDTO.js +9 -5
  270. package/lib/common/event/Event.js +49 -0
  271. package/lib/common/event/EventLimit.d.ts +1 -1
  272. package/package.json +21 -8
  273. package/REPOSITORY.md +0 -13
  274. package/events.drawio +0 -1
  275. package/events.png +0 -0
  276. package/index.js.map +0 -1
  277. package/index.ts +0 -2
  278. package/lib/backend/model/database/enitites/PersonEntry.d.ts +0 -11
  279. package/lib/backend/model/database/enitites/PersonJunctionTable.d.ts +0 -10
  280. package/lib/common/entities/ConentWrapper.d.ts +0 -18
  281. package/lib/common/entities/ConentWrapper.js +0 -490
  282. package/lib/frontend/app/app.component.d.ts +0 -18
  283. package/lib/frontend/app/app.module.d.ts +0 -23
  284. package/lib/frontend/app/app.routing.d.ts +0 -4
  285. package/lib/frontend/app/icon.component.d.ts +0 -7
  286. package/lib/frontend/app/model/IRenderable.d.ts +0 -17
  287. package/lib/frontend/app/model/backendtext.service.d.ts +0 -7
  288. package/lib/frontend/app/model/backendtext.service.spec.d.ts +0 -1
  289. package/lib/frontend/app/model/extension.service.d.ts +0 -5
  290. package/lib/frontend/app/model/navigation.service.d.ts +0 -12
  291. package/lib/frontend/app/model/network/autehentication.service.spec.d.ts +0 -1
  292. package/lib/frontend/app/model/network/authentication.service.d.ts +0 -22
  293. package/lib/frontend/app/model/network/helper/auth.guard.d.ts +0 -9
  294. package/lib/frontend/app/model/network/helper/csrf.interceptor.d.ts +0 -8
  295. package/lib/frontend/app/model/network/helper/error.interceptor.d.ts +0 -8
  296. package/lib/frontend/app/model/network/network.service.d.ts +0 -29
  297. package/lib/frontend/app/model/network/network.service.spec.d.ts +0 -1
  298. package/lib/frontend/app/model/network/user.service.d.ts +0 -13
  299. package/lib/frontend/app/model/network/user.service.spec.d.ts +0 -1
  300. package/lib/frontend/app/model/notification.service.d.ts +0 -28
  301. package/lib/frontend/app/model/page.helper.d.ts +0 -15
  302. package/lib/frontend/app/model/pi-title.service.d.ts +0 -15
  303. package/lib/frontend/app/model/query.service.d.ts +0 -19
  304. package/lib/frontend/app/model/seededRandom.service.d.ts +0 -7
  305. package/lib/frontend/app/model/theme.service.d.ts +0 -16
  306. package/lib/frontend/app/model/version.service.d.ts +0 -10
  307. package/lib/frontend/app/pipes/DurationPipe.d.ts +0 -4
  308. package/lib/frontend/app/pipes/FileDTOToPathPipe.d.ts +0 -5
  309. package/lib/frontend/app/pipes/FileDTOToRelativePathPipe.d.ts +0 -5
  310. package/lib/frontend/app/pipes/FileSizePipe.d.ts +0 -4
  311. package/lib/frontend/app/pipes/GPXFilesFilterPipe.d.ts +0 -5
  312. package/lib/frontend/app/pipes/MDFilesFilterPipe.d.ts +0 -6
  313. package/lib/frontend/app/pipes/ParseIntPipe.d.ts +0 -4
  314. package/lib/frontend/app/pipes/PhotoFilterPipe.d.ts +0 -6
  315. package/lib/frontend/app/pipes/SafeHTMLPipe.d.ts +0 -7
  316. package/lib/frontend/app/pipes/StringifyEnum.d.ts +0 -4
  317. package/lib/frontend/app/pipes/StringifyGridSize.d.ts +0 -5
  318. package/lib/frontend/app/pipes/StringifyRolePipe.d.ts +0 -4
  319. package/lib/frontend/app/pipes/StringifySearchQuery.d.ts +0 -8
  320. package/lib/frontend/app/pipes/StringifySearchType.d.ts +0 -5
  321. package/lib/frontend/app/pipes/StringifySortingMethod.d.ts +0 -4
  322. package/lib/frontend/app/ui/EnumTranslations.d.ts +0 -5
  323. package/lib/frontend/app/ui/admin/admin.component.d.ts +0 -36
  324. package/lib/frontend/app/ui/albums/album/album.component.d.ts +0 -26
  325. package/lib/frontend/app/ui/albums/albums.component.d.ts +0 -31
  326. package/lib/frontend/app/ui/albums/albums.service.d.ts +0 -12
  327. package/lib/frontend/app/ui/albums/saved-search-popup/saved-search-popup.component.d.ts +0 -15
  328. package/lib/frontend/app/ui/duplicates/duplicates.component.d.ts +0 -36
  329. package/lib/frontend/app/ui/duplicates/duplicates.service.d.ts +0 -9
  330. package/lib/frontend/app/ui/duplicates/photo/photo.duplicates.component.d.ts +0 -11
  331. package/lib/frontend/app/ui/faces/Person.d.ts +0 -9
  332. package/lib/frontend/app/ui/faces/face/face.component.d.ts +0 -22
  333. package/lib/frontend/app/ui/faces/faces.component.d.ts +0 -18
  334. package/lib/frontend/app/ui/faces/faces.service.d.ts +0 -14
  335. package/lib/frontend/app/ui/faces/navigator/navigator.faces.component.d.ts +0 -15
  336. package/lib/frontend/app/ui/frame/frame.component.d.ts +0 -60
  337. package/lib/frontend/app/ui/gallery/Media.d.ts +0 -15
  338. package/lib/frontend/app/ui/gallery/MediaIcon.d.ts +0 -29
  339. package/lib/frontend/app/ui/gallery/blog/blog.gallery.component.d.ts +0 -16
  340. package/lib/frontend/app/ui/gallery/blog/blog.service.d.ts +0 -85
  341. package/lib/frontend/app/ui/gallery/blog/blog.service.spec.d.ts +0 -1
  342. package/lib/frontend/app/ui/gallery/cache.gallery.service.d.ts +0 -51
  343. package/lib/frontend/app/ui/gallery/content.service.d.ts +0 -11
  344. package/lib/frontend/app/ui/gallery/contentLoader.service.d.ts +0 -37
  345. package/lib/frontend/app/ui/gallery/directories/directories.component.d.ts +0 -14
  346. package/lib/frontend/app/ui/gallery/directories/directory/directory.gallery.component.d.ts +0 -20
  347. package/lib/frontend/app/ui/gallery/filter/filter.gallery.component.d.ts +0 -32
  348. package/lib/frontend/app/ui/gallery/filter/filter.service.d.ts +0 -51
  349. package/lib/frontend/app/ui/gallery/filter/filter.service.spec.d.ts +0 -1
  350. package/lib/frontend/app/ui/gallery/fullscreen.service.d.ts +0 -7
  351. package/lib/frontend/app/ui/gallery/gallery.component.d.ts +0 -64
  352. package/lib/frontend/app/ui/gallery/gallery.component.spec.d.ts +0 -1
  353. package/lib/frontend/app/ui/gallery/gallery.service.d.ts +0 -13
  354. package/lib/frontend/app/ui/gallery/grid/GridMedia.d.ts +0 -13
  355. package/lib/frontend/app/ui/gallery/grid/GridRowBuilder.d.ts +0 -16
  356. package/lib/frontend/app/ui/gallery/grid/grid.gallery.component.d.ts +0 -88
  357. package/lib/frontend/app/ui/gallery/grid/grid.gallery.component.spec.d.ts +0 -1
  358. package/lib/frontend/app/ui/gallery/grid/photo/loading/loading.photo.grid.gallery.component.d.ts +0 -4
  359. package/lib/frontend/app/ui/gallery/grid/photo/media-button-modal/media-button-modal.component.d.ts +0 -20
  360. package/lib/frontend/app/ui/gallery/grid/photo/media-button-modal/media-button-modal.service.d.ts +0 -27
  361. package/lib/frontend/app/ui/gallery/grid/photo/photo.grid.gallery.component.d.ts +0 -53
  362. package/lib/frontend/app/ui/gallery/lightbox/controls/controls.lightbox.gallery.component.d.ts +0 -103
  363. package/lib/frontend/app/ui/gallery/lightbox/infopanel/info-panel.lightbox.gallery.component.d.ts +0 -51
  364. package/lib/frontend/app/ui/gallery/lightbox/lightbox.gallery.component.d.ts +0 -95
  365. package/lib/frontend/app/ui/gallery/lightbox/lightbox.gallery.component.spec.d.ts +0 -1
  366. package/lib/frontend/app/ui/gallery/lightbox/lightbox.service.d.ts +0 -45
  367. package/lib/frontend/app/ui/gallery/lightbox/media/media.lightbox.gallery.component.d.ts +0 -71
  368. package/lib/frontend/app/ui/gallery/map/MarkerFactory.d.ts +0 -12
  369. package/lib/frontend/app/ui/gallery/map/lightbox/lightbox.map.gallery.component.d.ts +0 -80
  370. package/lib/frontend/app/ui/gallery/map/map.gallery.component.d.ts +0 -36
  371. package/lib/frontend/app/ui/gallery/map/map.service.d.ts +0 -30
  372. package/lib/frontend/app/ui/gallery/navigator/navigator.gallery.component.d.ts +0 -81
  373. package/lib/frontend/app/ui/gallery/navigator/navigator.service.d.ts +0 -14
  374. package/lib/frontend/app/ui/gallery/navigator/sorting.service.d.ts +0 -38
  375. package/lib/frontend/app/ui/gallery/overlay.service.d.ts +0 -9
  376. package/lib/frontend/app/ui/gallery/photo-frame-builder/photo-frame-builder.gallery.component.d.ts +0 -40
  377. package/lib/frontend/app/ui/gallery/random-query-builder/random-query-builder.gallery.component.d.ts +0 -30
  378. package/lib/frontend/app/ui/gallery/search/AutoCompleteRenderItem.d.ts +0 -11
  379. package/lib/frontend/app/ui/gallery/search/autocomplete.service.d.ts +0 -33
  380. package/lib/frontend/app/ui/gallery/search/query-builder/query-bulder.gallery.component.d.ts +0 -22
  381. package/lib/frontend/app/ui/gallery/search/query-enrty/query-entry.search.gallery.component.d.ts +0 -43
  382. package/lib/frontend/app/ui/gallery/search/search-field/search-field.gallery.component.d.ts +0 -31
  383. package/lib/frontend/app/ui/gallery/search/search-field-base/search-field-base.gallery.component.d.ts +0 -57
  384. package/lib/frontend/app/ui/gallery/search/search-query-parser.service.d.ts +0 -7
  385. package/lib/frontend/app/ui/gallery/search/search.gallery.component.d.ts +0 -39
  386. package/lib/frontend/app/ui/gallery/share/share.gallery.component.d.ts +0 -67
  387. package/lib/frontend/app/ui/gallery/share.service.d.ts +0 -35
  388. package/lib/frontend/app/ui/gallery/thumbnailLoader.service.d.ts +0 -41
  389. package/lib/frontend/app/ui/gallery/thumbnailManager.service.d.ts +0 -46
  390. package/lib/frontend/app/ui/gallery/uploader/uploader.gallery.component.d.ts +0 -15
  391. package/lib/frontend/app/ui/gallery/uploader/uploader.service.d.ts +0 -36
  392. package/lib/frontend/app/ui/gallery/wakelock.service.d.ts +0 -19
  393. package/lib/frontend/app/ui/language/language.component.d.ts +0 -10
  394. package/lib/frontend/app/ui/login/login.component.d.ts +0 -18
  395. package/lib/frontend/app/ui/settings/extension-installer/extension-installer.component.d.ts +0 -18
  396. package/lib/frontend/app/ui/settings/extension-installer/extension-installer.service.d.ts +0 -10
  397. package/lib/frontend/app/ui/settings/gallery-statistic/gallery-statistic.component.d.ts +0 -5
  398. package/lib/frontend/app/ui/settings/scheduled-jobs.service.d.ts +0 -41
  399. package/lib/frontend/app/ui/settings/settings.service.d.ts +0 -27
  400. package/lib/frontend/app/ui/settings/sharings-list/sharings-list.component.d.ts +0 -14
  401. package/lib/frontend/app/ui/settings/template/CustomSettingsEntries.d.ts +0 -57
  402. package/lib/frontend/app/ui/settings/template/ISettingsComponent.d.ts +0 -13
  403. package/lib/frontend/app/ui/settings/template/settings-entry/settings-entry.component.d.ts +0 -118
  404. package/lib/frontend/app/ui/settings/template/settings-entry/sorting-method/sorting-method.settings-entry.component.d.ts +0 -28
  405. package/lib/frontend/app/ui/settings/template/template.component.d.ts +0 -97
  406. package/lib/frontend/app/ui/settings/users/users.component.d.ts +0 -47
  407. package/lib/frontend/app/ui/settings/users/users.service.d.ts +0 -12
  408. package/lib/frontend/app/ui/settings/workflow/button/job-button.settings.component.d.ts +0 -32
  409. package/lib/frontend/app/ui/settings/workflow/progress/job-progress.settings.component.d.ts +0 -25
  410. package/lib/frontend/app/ui/settings/workflow/workflow.component.d.ts +0 -68
  411. package/lib/frontend/app/ui/sharelogin/share-login.component.d.ts +0 -16
  412. package/lib/frontend/app/ui/utils/grid-size-icon/grid-size-icon.component.d.ts +0 -5
  413. package/lib/frontend/app/ui/utils/sorting-method-icon/sorting-method-icon.component.d.ts +0 -13
  414. package/lib/frontend/app/ui/utils/timestamp-datepicker/datepicker.component.d.ts +0 -10
  415. package/lib/frontend/app/ui/utils/timestamp-timepicker/timepicker.component.d.ts +0 -11
  416. package/lib/frontend/environments/environment.d.ts +0 -3
  417. package/lib/frontend/environments/environment.prod.d.ts +0 -3
  418. package/lib/frontend/main.d.ts +0 -21
  419. package/lib/frontend/polyfills.d.ts +0 -60
  420. package/lib/frontend/test.d.ts +0 -1
@@ -0,0 +1,182 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RenderingMWs = void 0;
4
+ const Error_1 = require("../../common/entities/Error");
5
+ const Message_1 = require("../../common/entities/Message");
6
+ const UserDTO_1 = require("../../common/entities/UserDTO");
7
+ const NotifocationManager_1 = require("../model/NotifocationManager");
8
+ const Logger_1 = require("../Logger");
9
+ const Utils_1 = require("../../common/Utils");
10
+ const LoggerRouter_1 = require("../routes/LoggerRouter");
11
+ const ExtensionConfigWrapper_1 = require("../model/extension/ExtensionConfigWrapper");
12
+ const Config_1 = require("../../common/config/private/Config");
13
+ const forcedDebug = process.env['NODE_ENV'] === 'debug';
14
+ class RenderingMWs {
15
+ static renderResult(req, res, next) {
16
+ if (typeof req.resultPipe === 'undefined') {
17
+ return next();
18
+ }
19
+ return RenderingMWs.renderMessage(res, req.resultPipe);
20
+ }
21
+ static renderSessionUser(req, res, next) {
22
+ if (!req.session.context?.user) {
23
+ return next(new Error_1.ErrorDTO(Error_1.ErrorCodes.GENERAL_ERROR, 'User not exists'));
24
+ }
25
+ const user = {
26
+ id: req.session.context.user.id,
27
+ name: req.session.context.user.name,
28
+ role: req.session.context.user.role,
29
+ usedSharingKey: req.session.context.user.usedSharingKey,
30
+ projectionKey: req.session.context.user.projectionKey,
31
+ };
32
+ RenderingMWs.renderMessage(res, user);
33
+ }
34
+ static renderSharing(req, res, next) {
35
+ if (!req.resultPipe) {
36
+ return next();
37
+ }
38
+ const { password, creator, ...sharing } = req.resultPipe;
39
+ sharing.passwordProtected = Config_1.Config.Sharing.passwordRequired || (typeof password === 'string' && password !== '');
40
+ RenderingMWs.renderMessage(res, sharing);
41
+ }
42
+ static renderSharingList(req, res, next) {
43
+ if (!req.resultPipe) {
44
+ return next();
45
+ }
46
+ const shares = Utils_1.Utils.clone(req.resultPipe);
47
+ const rs = shares.map((s) => {
48
+ const ret = s;
49
+ ret.passwordProtected = Config_1.Config.Sharing.passwordRequired || (typeof s.password === 'string' && s.password !== '');
50
+ delete s.password;
51
+ delete s.creator.password;
52
+ return ret;
53
+ });
54
+ return RenderingMWs.renderMessage(res, rs);
55
+ }
56
+ /**
57
+ * For media that rarely changes under the same URL (photos, thumbnails, previews).
58
+ * Cached for a day only: a photo can be replaced in the folder, a thumbnail regenerated with other settings.
59
+ * private: these are behind authentication, so shared caches (proxies, CDNs) must not store them.
60
+ */
61
+ static renderFile(req, res, next) {
62
+ return RenderingMWs.sendFile(req, res, next, 'private, max-age=86400');
63
+ }
64
+ /**
65
+ * For files that can change under the same URL (e.g. bestFit switches to the transcoded video once it is ready).
66
+ * The browser revalidates them with the ETag.
67
+ */
68
+ static renderFileNoCache(req, res, next) {
69
+ return RenderingMWs.sendFile(req, res, next, 'private, no-cache');
70
+ }
71
+ /**
72
+ * For responses that differ on every request (e.g. random photo).
73
+ */
74
+ static renderFileNoStore(req, res, next) {
75
+ return RenderingMWs.sendFile(req, res, next, 'no-store');
76
+ }
77
+ static sendFile(req, res, next, cacheControl) {
78
+ if (!req.resultPipe) {
79
+ return next();
80
+ }
81
+ return res.sendFile(req.resultPipe, {
82
+ cacheControl: false,
83
+ // only set on a successful transfer, so errors are not cached
84
+ headers: { 'Cache-Control': cacheControl },
85
+ dotfiles: 'allow',
86
+ });
87
+ }
88
+ static renderOK(req, res) {
89
+ const message = new Message_1.Message(null, 'ok');
90
+ res.json(message);
91
+ }
92
+ static async renderConfig(req, res) {
93
+ const originalConf = await ExtensionConfigWrapper_1.ExtensionConfigWrapper.original();
94
+ // These are sensitive information, do not send to the client side
95
+ originalConf.Server.sessionSecret = [];
96
+ const originalConfJSON = JSON.parse(JSON.stringify(originalConf.toJSON({
97
+ attachState: true,
98
+ attachVolatile: true,
99
+ skipTags: { secret: true }
100
+ })));
101
+ const message = new Message_1.Message(null, originalConfJSON);
102
+ res.json(message);
103
+ }
104
+ static notFound(req, res, next) {
105
+ return next(new Error_1.ErrorDTO(Error_1.ErrorCodes.PATH_ERROR, 'Unknown API path: ' + req.method + ' ' + req.baseUrl + req.path));
106
+ }
107
+ static renderError(err, req, res, next) {
108
+ if (err instanceof Error_1.ErrorDTO) {
109
+ if (err.details) {
110
+ const logFn = Logger_1.Logger.logLevelForError(err.code);
111
+ LoggerRouter_1.LoggerRouter.log(logFn, req, res);
112
+ // use separate rendering for detailsStr
113
+ const d = err.detailsStr;
114
+ delete err.detailsStr;
115
+ logFn(err);
116
+ err.detailsStr = d;
117
+ delete err.details; // do not send back error object to the client side
118
+ // hide error details for non developers
119
+ if (!(forcedDebug ||
120
+ (req.session &&
121
+ req.session.context?.user &&
122
+ req.session.context?.user.role >= UserDTO_1.UserRoles.Developer))) {
123
+ delete err.detailsStr;
124
+ }
125
+ }
126
+ res.status(RenderingMWs.httpStatus(err.code));
127
+ const message = new Message_1.Message(err, null);
128
+ res.json(message);
129
+ return;
130
+ }
131
+ if (RenderingMWs.isClientHttpError(err)) {
132
+ // e.g. a range past the end of a video (send: 416) or a body that is not JSON (body-parser: 400)
133
+ Logger_1.Logger.debug('[RenderingMWs]', 'Client error', req.method, req.originalUrl, err.status, err.message);
134
+ res.status(err.status);
135
+ if (err.headers) {
136
+ res.set(err.headers);
137
+ }
138
+ res.json(new Message_1.Message(new Error_1.ErrorDTO(Error_1.ErrorCodes.INPUT_ERROR, err.message), null));
139
+ return;
140
+ }
141
+ NotifocationManager_1.NotificationManager.error('Unknown server error', err, req);
142
+ return next(err);
143
+ }
144
+ /**
145
+ * An http-errors error of the client (status 4xx), raised by express or its middlewares.
146
+ */
147
+ static isClientHttpError(err) {
148
+ const status = err?.status;
149
+ return err instanceof Error && typeof status === 'number' && status >= 400 && status < 500;
150
+ }
151
+ static httpStatus(code) {
152
+ switch (code) {
153
+ case Error_1.ErrorCodes.NOT_AUTHENTICATED:
154
+ case Error_1.ErrorCodes.NOT_AUTHENTICATED_SHARING:
155
+ case Error_1.ErrorCodes.CREDENTIAL_NOT_FOUND:
156
+ return 401;
157
+ case Error_1.ErrorCodes.NOT_AUTHORISED:
158
+ case Error_1.ErrorCodes.PERMISSION_DENIED:
159
+ case Error_1.ErrorCodes.USER_MANAGEMENT_DISABLED:
160
+ return 403;
161
+ case Error_1.ErrorCodes.DIRECTORY_NOT_FOUND:
162
+ case Error_1.ErrorCodes.PATH_ERROR:
163
+ case Error_1.ErrorCodes.SHARING_NOT_FOUND:
164
+ case Error_1.ErrorCodes.LocationLookUp_ERROR:
165
+ return 404;
166
+ case Error_1.ErrorCodes.ALREADY_AUTHENTICATED:
167
+ case Error_1.ErrorCodes.USER_CREATION_ERROR:
168
+ case Error_1.ErrorCodes.INPUT_ERROR:
169
+ case Error_1.ErrorCodes.SETTINGS_ERROR:
170
+ case Error_1.ErrorCodes.ALBUM_ERROR:
171
+ case Error_1.ErrorCodes.UPLOAD_ERROR:
172
+ return 400;
173
+ default:
174
+ return 500;
175
+ }
176
+ }
177
+ static renderMessage(res, content) {
178
+ const message = new Message_1.Message(null, content);
179
+ res.json(message);
180
+ }
181
+ }
182
+ exports.RenderingMWs = RenderingMWs;
@@ -0,0 +1,13 @@
1
+ import { Request } from 'express';
2
+ export declare class RequestParams {
3
+ /**
4
+ * Reads a path param as a string.
5
+ * Express 5 gives a wildcard param (`/*name`) as the array of its decoded segments.
6
+ * They are joined back with '/', so `a%2Fb/c` reads as `a/b/c`, as in Express 4.
7
+ */
8
+ static get(req: Request, name: string): string | undefined;
9
+ /**
10
+ * Reads a path param that the route always has (see get()).
11
+ */
12
+ static getRequired(req: Request, name: string): string;
13
+ }
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RequestParams = void 0;
4
+ class RequestParams {
5
+ /**
6
+ * Reads a path param as a string.
7
+ * Express 5 gives a wildcard param (`/*name`) as the array of its decoded segments.
8
+ * They are joined back with '/', so `a%2Fb/c` reads as `a/b/c`, as in Express 4.
9
+ */
10
+ static get(req, name) {
11
+ const value = req.params[name];
12
+ return Array.isArray(value) ? value.join('/') : value;
13
+ }
14
+ /**
15
+ * Reads a path param that the route always has (see get()).
16
+ */
17
+ static getRequired(req, name) {
18
+ const value = RequestParams.get(req, name);
19
+ if (value === undefined) {
20
+ throw new Error('Missing path param: ' + name);
21
+ }
22
+ return value;
23
+ }
24
+ }
25
+ exports.RequestParams = RequestParams;
@@ -0,0 +1,9 @@
1
+ import { Request } from 'express';
2
+ import { SessionContext } from '../model/SessionContext';
3
+ export declare class RequestSession {
4
+ /**
5
+ * The context of the logged-in session.
6
+ * AuthenticationMWs.authenticate sets it, so a route that authenticates always has it.
7
+ */
8
+ static getContext(req: Request): SessionContext;
9
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RequestSession = void 0;
4
+ class RequestSession {
5
+ /**
6
+ * The context of the logged-in session.
7
+ * AuthenticationMWs.authenticate sets it, so a route that authenticates always has it.
8
+ */
9
+ static getContext(req) {
10
+ if (!req.session.context) {
11
+ throw new Error('No session context, the request is not authenticated');
12
+ }
13
+ return req.session.context;
14
+ }
15
+ }
16
+ exports.RequestSession = RequestSession;
@@ -1,17 +1,17 @@
1
1
  import { NextFunction, Request, Response } from 'express';
2
2
  export declare class ServerTimeEntry {
3
3
  name: string;
4
- startHR: [number, number];
5
- endTime: number;
4
+ startHR?: [number, number];
5
+ endTime: number | null;
6
6
  constructor(name: string);
7
7
  start(): void;
8
- end(): void;
8
+ end(): number;
9
9
  }
10
- export declare const FunctionTime: (id: string, name: string) => (target: unknown, propertyName: string, descriptor: TypedPropertyDescriptor<(...args: any[]) => any>) => void;
11
- export declare const ServerTime: (id: string, name: string) => (target: unknown, propertyName: string, descriptor: TypedPropertyDescriptor<(req: unknown, res: unknown, next: () => void) => void>) => void;
10
+ export declare const FunctionTime: (id: string, name: string) => <A extends unknown[], R>(target: unknown, propertyName: string, descriptor: TypedPropertyDescriptor<(...args: A) => R>) => void;
11
+ export declare const ServerTime: (id: string, name: string) => <T extends (req: Request, res: Response, next: NextFunction) => void | Promise<void>>(target: unknown, propertyName: string, descriptor: TypedPropertyDescriptor<T>) => void;
12
12
  export declare class ServerTimingMWs {
13
13
  /**
14
14
  * Add server timing
15
15
  */
16
- static addServerTiming(req: Request, res: Response, next: NextFunction): Promise<void>;
16
+ static addServerTiming(req: Request, res: Response, next: NextFunction): void;
17
17
  }
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ServerTimingMWs = exports.ServerTime = exports.FunctionTime = exports.ServerTimeEntry = void 0;
4
+ const Config_1 = require("../../common/config/private/Config");
5
+ class ServerTimeEntry {
6
+ constructor(name) {
7
+ this.endTime = null;
8
+ this.name = name;
9
+ }
10
+ start() {
11
+ this.startHR = process.hrtime();
12
+ }
13
+ end() {
14
+ const duration = process.hrtime(this.startHR);
15
+ this.endTime = duration[0] * 1e3 + duration[1] * 1e-6;
16
+ return this.endTime;
17
+ }
18
+ }
19
+ exports.ServerTimeEntry = ServerTimeEntry;
20
+ const FunctionTime = (id, name) => {
21
+ return (target, propertyName, descriptor) => {
22
+ if (Config_1.Config.Server.Log.logServerTiming === false) {
23
+ return;
24
+ }
25
+ const originalMethod = descriptor.value;
26
+ if (!originalMethod) {
27
+ return;
28
+ }
29
+ descriptor.value = function (...args) {
30
+ const timer = new ServerTimeEntry(name);
31
+ timer.start();
32
+ try {
33
+ const result = originalMethod.apply(this, args);
34
+ // Handle both sync and async functions
35
+ if (result instanceof Promise) {
36
+ // Async function - return a promise that logs timing when resolved
37
+ return result
38
+ .then((value) => {
39
+ const time = timer.end();
40
+ console.log(`[${id}] ${name}: ${time.toFixed(2)}ms`);
41
+ return value;
42
+ })
43
+ .catch((error) => {
44
+ const time = timer.end();
45
+ console.log(`[${id}] ${name}: ${time.toFixed(2)}ms (error)`);
46
+ throw error;
47
+ });
48
+ }
49
+ else {
50
+ // Sync function - log timing immediately
51
+ const time = timer.end();
52
+ console.log(`[${id}] ${name}: ${time.toFixed(2)}ms`);
53
+ return result;
54
+ }
55
+ }
56
+ catch (error) {
57
+ const time = timer.end();
58
+ console.log(`[${id}] ${name}: ${time.toFixed(2)}ms (error)`);
59
+ throw error;
60
+ }
61
+ };
62
+ };
63
+ };
64
+ exports.FunctionTime = FunctionTime;
65
+ const ServerTime = (id, name) => {
66
+ return (target, propertyName, descriptor) => {
67
+ if (Config_1.Config.Server.Log.logServerTiming === false) {
68
+ return;
69
+ }
70
+ const m = descriptor.value;
71
+ if (!m) {
72
+ return;
73
+ }
74
+ const customAction = (req, res, next) => {
75
+ req.timing = req.timing || {};
76
+ const entry = new ServerTimeEntry(name);
77
+ req.timing[id] = entry;
78
+ entry.start();
79
+ // return the promise of an async middleware, so Express catches its rejection
80
+ return m(req, res, (err) => {
81
+ entry.end();
82
+ next(err);
83
+ });
84
+ };
85
+ // keep the name of the middleware
86
+ Object.defineProperty(customAction, 'name', { value: m.name });
87
+ descriptor.value = customAction;
88
+ };
89
+ };
90
+ exports.ServerTime = ServerTime;
91
+ const forcedDebug = process.env['NODE_ENV'] === 'debug';
92
+ class ServerTimingMWs {
93
+ /**
94
+ * Add server timing
95
+ */
96
+ static addServerTiming(req, res, next) {
97
+ if ((Config_1.Config.Server.Log.logServerTiming === false && !forcedDebug) ||
98
+ !req.timing) {
99
+ return next();
100
+ }
101
+ const l = Object.entries(req.timing)
102
+ .filter((e) => e[1].endTime)
103
+ .map((e) => `${e[0]};dur=${e[1].endTime};desc="${e[1].name}"`);
104
+ res.header('Server-Timing', l.join(', '));
105
+ next();
106
+ }
107
+ }
108
+ exports.ServerTimingMWs = ServerTimingMWs;
@@ -1,7 +1,8 @@
1
1
  import { NextFunction, Request, Response } from 'express';
2
2
  export declare class SharingMWs {
3
+ private static exactDirectoryQuery;
3
4
  static getSharing(req: Request, res: Response, next: NextFunction): Promise<void>;
4
- static getSharingKey(req: Request, res: Response, next: NextFunction): Promise<void>;
5
+ static getSharingPublicInfo(req: Request, res: Response, next: NextFunction): Promise<void>;
5
6
  static createSharing(req: Request, res: Response, next: NextFunction): Promise<void>;
6
7
  static updateSharing(req: Request, res: Response, next: NextFunction): Promise<void>;
7
8
  static deleteSharing(req: Request, res: Response, next: NextFunction): Promise<void>;
@@ -0,0 +1,240 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SharingMWs = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const ObjectManagers_1 = require("../model/ObjectManagers");
6
+ const Error_1 = require("../../common/entities/Error");
7
+ const Config_1 = require("../../common/config/private/Config");
8
+ const QueryParams_1 = require("../../common/QueryParams");
9
+ const UserDTO_1 = require("../../common/entities/UserDTO");
10
+ const SearchQueryDTO_1 = require("../../common/entities/SearchQueryDTO");
11
+ const crypto = tslib_1.__importStar(require("node:crypto"));
12
+ const RequestParams_1 = require("./RequestParams");
13
+ const RequestSession_1 = require("./RequestSession");
14
+ class SharingMWs {
15
+ static exactDirectoryQuery(directoryName) {
16
+ return {
17
+ type: SearchQueryDTO_1.SearchQueryTypes.directory,
18
+ value: directoryName,
19
+ matchType: SearchQueryDTO_1.TextSearchQueryMatchTypes.exact_match,
20
+ negate: false
21
+ };
22
+ }
23
+ static async getSharing(req, res, next) {
24
+ try {
25
+ if (Config_1.Config.Sharing.enabled === false) {
26
+ return next();
27
+ }
28
+ const sharingKey = RequestParams_1.RequestParams.getRequired(req, QueryParams_1.QueryParams.gallery.sharingKey_params);
29
+ req.resultPipe =
30
+ await ObjectManagers_1.ObjectManagers.getInstance().SharingManager.findOne(sharingKey);
31
+ return next();
32
+ }
33
+ catch (err) {
34
+ return next(new Error_1.ErrorDTO(Error_1.ErrorCodes.GENERAL_ERROR, 'Error during retrieving sharing link', err));
35
+ }
36
+ }
37
+ static async getSharingPublicInfo(req, res, next) {
38
+ try {
39
+ if (Config_1.Config.Sharing.enabled === false) {
40
+ return next();
41
+ }
42
+ const sharingKey = RequestParams_1.RequestParams.getRequired(req, QueryParams_1.QueryParams.gallery.sharingKey_params);
43
+ const sharing = await ObjectManagers_1.ObjectManagers.getInstance().SharingManager.findOne(sharingKey);
44
+ if (!sharing) {
45
+ return next(new Error_1.ErrorDTO(Error_1.ErrorCodes.SHARING_NOT_FOUND, 'Sharing not found'));
46
+ }
47
+ req.resultPipe =
48
+ {
49
+ sharingKey: sharing.sharingKey,
50
+ passwordProtected: Config_1.Config.Sharing.passwordRequired || (typeof sharing.password === 'string' && sharing.password !== '')
51
+ };
52
+ return next();
53
+ }
54
+ catch (err) {
55
+ return next(new Error_1.ErrorDTO(Error_1.ErrorCodes.GENERAL_ERROR, 'Error during retrieving sharing key', err));
56
+ }
57
+ }
58
+ static async createSharing(req, res, next) {
59
+ try {
60
+ if (Config_1.Config.Sharing.enabled === false) {
61
+ return next();
62
+ }
63
+ const body = req.body;
64
+ if (typeof body === 'undefined' ||
65
+ typeof body.createSharing === 'undefined') {
66
+ return next(new Error_1.ErrorDTO(Error_1.ErrorCodes.INPUT_ERROR, 'createSharing filed is missing'));
67
+ }
68
+ const createSharing = body.createSharing;
69
+ if (Config_1.Config.Sharing.passwordRequired && !createSharing.password) {
70
+ return next(new Error_1.ErrorDTO(Error_1.ErrorCodes.INPUT_ERROR, 'Password is required.'));
71
+ }
72
+ let sharingKey = SharingMWs.generateKey(Config_1.Config.Sharing.sharingKeyLength);
73
+ // create one not yet used
74
+ while (true) {
75
+ try {
76
+ await ObjectManagers_1.ObjectManagers.getInstance().SharingManager.findOne(sharingKey);
77
+ sharingKey = this.generateKey(Config_1.Config.Sharing.sharingKeyLength);
78
+ }
79
+ catch {
80
+ break;
81
+ }
82
+ }
83
+ // normalized by AuthenticationMWs.normalizePathParam
84
+ const directoryName = RequestParams_1.RequestParams.getRequired(req, 'directory');
85
+ const searchQuery = createSharing.searchQuery || null;
86
+ // without any query, the sharing is about the directory (legacy directory sharing)
87
+ const directoryQuery = createSharing.directoryQuery ||
88
+ (!searchQuery ? SharingMWs.exactDirectoryQuery(directoryName) : null);
89
+ // the id is set when the sharing is saved
90
+ const sharing = {
91
+ sharingKey,
92
+ searchQuery,
93
+ directoryQuery,
94
+ password: createSharing.password,
95
+ defaultSearchView: null,
96
+ defaultDirectoryView: null,
97
+ creator: RequestSession_1.RequestSession.getContext(req).user, // only the user id is used
98
+ expires: createSharing.valid >= 0 // if === -1 it's forever
99
+ ? Date.now() + createSharing.valid
100
+ : new Date(9999, 0, 1).getTime(), // never expire
101
+ timeStamp: Date.now(),
102
+ };
103
+ if (createSharing.defaultDirectoryView && createSharing.defaultSearchView) {
104
+ return next(new Error_1.ErrorDTO(Error_1.ErrorCodes.INPUT_ERROR, 'defaultDirectoryView and defaultSearchView cannot be set at the same time'));
105
+ }
106
+ if (createSharing.defaultDirectoryView) {
107
+ sharing.defaultDirectoryView = createSharing.defaultDirectoryView;
108
+ }
109
+ if (createSharing.defaultSearchView) {
110
+ sharing.defaultSearchView = createSharing.defaultSearchView;
111
+ }
112
+ req.resultPipe =
113
+ await ObjectManagers_1.ObjectManagers.getInstance().SharingManager.createSharing(sharing);
114
+ return next();
115
+ }
116
+ catch (err) {
117
+ console.warn(err);
118
+ return next(new Error_1.ErrorDTO(Error_1.ErrorCodes.GENERAL_ERROR, 'Error during creating sharing link', err));
119
+ }
120
+ }
121
+ static async updateSharing(req, res, next) {
122
+ try {
123
+ if (Config_1.Config.Sharing.enabled === false) {
124
+ return next();
125
+ }
126
+ const body = req.body;
127
+ if (typeof body === 'undefined' ||
128
+ typeof body.updateSharing === 'undefined') {
129
+ return next(new Error_1.ErrorDTO(Error_1.ErrorCodes.INPUT_ERROR, 'updateSharing filed is missing'));
130
+ }
131
+ const updateSharing = body.updateSharing;
132
+ if (typeof updateSharing.id !== 'number') {
133
+ throw new Error('Invalid sharing, id is missing');
134
+ }
135
+ // normalized by AuthenticationMWs.normalizePathParam
136
+ const directoryName = RequestParams_1.RequestParams.getRequired(req, 'directory');
137
+ const searchQuery = updateSharing.searchQuery || null;
138
+ // without any query, the sharing is about the directory (legacy directory sharing)
139
+ const directoryQuery = updateSharing.directoryQuery ||
140
+ (!searchQuery ? SharingMWs.exactDirectoryQuery(directoryName) : null);
141
+ const sharing = {
142
+ id: updateSharing.id,
143
+ searchQuery,
144
+ directoryQuery,
145
+ sharingKey: '',
146
+ password: updateSharing.password && updateSharing.password !== ''
147
+ ? updateSharing.password
148
+ : null,
149
+ creator: RequestSession_1.RequestSession.getContext(req).user,
150
+ expires: updateSharing.valid >= 0 // if === -1 its forever
151
+ ? Date.now() + updateSharing.valid
152
+ : new Date(9999, 0, 1).getTime(), // never expire
153
+ timeStamp: Date.now(),
154
+ };
155
+ if (updateSharing.defaultDirectoryView && updateSharing.defaultSearchView) {
156
+ return next(new Error_1.ErrorDTO(Error_1.ErrorCodes.INPUT_ERROR, 'defaultDirectoryView and defaultSearchView cannot be set at the same time'));
157
+ }
158
+ if (updateSharing.defaultDirectoryView) {
159
+ sharing.defaultDirectoryView = updateSharing.defaultDirectoryView;
160
+ }
161
+ if (updateSharing.defaultSearchView) {
162
+ sharing.defaultSearchView = updateSharing.defaultSearchView;
163
+ }
164
+ const forceUpdate = RequestSession_1.RequestSession.getContext(req).user.role >= UserDTO_1.UserRoles.Admin;
165
+ req.resultPipe =
166
+ await ObjectManagers_1.ObjectManagers.getInstance().SharingManager.updateSharing(sharing, forceUpdate);
167
+ return next();
168
+ }
169
+ catch (err) {
170
+ return next(new Error_1.ErrorDTO(Error_1.ErrorCodes.GENERAL_ERROR, 'Error during updating sharing link', err));
171
+ }
172
+ }
173
+ static async deleteSharing(req, res, next) {
174
+ try {
175
+ if (Config_1.Config.Sharing.enabled === false) {
176
+ return next();
177
+ }
178
+ const sharingKey = typeof req.params === 'undefined' ? undefined : RequestParams_1.RequestParams.get(req, 'sharingKey');
179
+ if (typeof sharingKey === 'undefined') {
180
+ return next(new Error_1.ErrorDTO(Error_1.ErrorCodes.INPUT_ERROR, 'sharingKey is missing'));
181
+ }
182
+ // Check if user has the right to delete sharing.
183
+ if (RequestSession_1.RequestSession.getContext(req).user.role < UserDTO_1.UserRoles.Admin) {
184
+ const s = await ObjectManagers_1.ObjectManagers.getInstance().SharingManager.findOne(sharingKey);
185
+ if (!s || s.creator.id !== RequestSession_1.RequestSession.getContext(req).user.id) {
186
+ return next(new Error_1.ErrorDTO(Error_1.ErrorCodes.NOT_AUTHORISED, 'Can\'t delete sharing.'));
187
+ }
188
+ }
189
+ req.resultPipe =
190
+ await ObjectManagers_1.ObjectManagers.getInstance().SharingManager.deleteSharing(sharingKey);
191
+ req.resultPipe = 'ok';
192
+ return next();
193
+ }
194
+ catch (err) {
195
+ return next(new Error_1.ErrorDTO(Error_1.ErrorCodes.GENERAL_ERROR, 'Error during deleting sharing', err));
196
+ }
197
+ }
198
+ static async listSharing(req, res, next) {
199
+ try {
200
+ if (Config_1.Config.Sharing.enabled === false) {
201
+ return next();
202
+ }
203
+ req.resultPipe =
204
+ await ObjectManagers_1.ObjectManagers.getInstance().SharingManager.listAll();
205
+ return next();
206
+ }
207
+ catch (err) {
208
+ return next(new Error_1.ErrorDTO(Error_1.ErrorCodes.GENERAL_ERROR, 'Error during listing shares', err));
209
+ }
210
+ }
211
+ static async listSharingForQuery(req, res, next) {
212
+ try {
213
+ if (Config_1.Config.Sharing.enabled === false) {
214
+ return next();
215
+ }
216
+ if (!req.resultPipe) {
217
+ return next();
218
+ }
219
+ const query = req.resultPipe;
220
+ if (RequestSession_1.RequestSession.getContext(req).user.role >= UserDTO_1.UserRoles.Admin) {
221
+ req.resultPipe =
222
+ await ObjectManagers_1.ObjectManagers.getInstance().SharingManager.listAllForQuery(query);
223
+ }
224
+ else {
225
+ req.resultPipe =
226
+ await ObjectManagers_1.ObjectManagers.getInstance().SharingManager.listAllForQuery(query, req.session.context?.user);
227
+ }
228
+ return next();
229
+ }
230
+ catch (err) {
231
+ return next(new Error_1.ErrorDTO(Error_1.ErrorCodes.GENERAL_ERROR, 'Error during listing shares', err));
232
+ }
233
+ }
234
+ static generateKey(length) {
235
+ return crypto.randomBytes(Math.ceil(length * 3 / 4))
236
+ .toString('base64url')
237
+ .slice(0, length);
238
+ }
239
+ }
240
+ exports.SharingMWs = SharingMWs;